From 4e5398775ea594f8096cc8a8dae71577091eaadd Mon Sep 17 00:00:00 2001 From: Matthew McEachen Date: Fri, 8 Mar 2024 15:03:21 -0800 Subject: [PATCH] v2024.3.1-prealpha --- CHANGELOG.md | 22 ++++++- VERSION.json | 10 +-- bin/info.js | 2 +- bin/list.js | 2 +- bin/logcat.js | 2 +- bin/logtail.js | 2 +- bin/main.js | 2 +- bin/photostructure.js | 2 +- bin/sync.js | 2 +- bin/web.js | 2 +- bin/worker.js | 2 +- .../models/20240307_rebuild_progress_nofk.sql | 57 ++++++++++++++++++ defaults.env | 13 ++-- package.json | 2 +- photostructure | 2 +- public/3rd-party-licenses.txt.gz | Bin 48190 -> 48190 bytes public/app/about.css.gz | Bin 3832 -> 3832 bytes public/app/about.css.map.gz | Bin 1259 -> 1259 bytes public/app/about.js.gz | Bin 4576 -> 4576 bytes public/app/about.js.map.gz | Bin 50069 -> 0 bytes public/app/app.css.gz | Bin 9778 -> 9778 bytes public/app/app.css.map.gz | Bin 3799 -> 3799 bytes public/app/app.js.gz | Bin 112735 -> 112735 bytes public/app/app.js.map.gz | Bin 320419 -> 0 bytes public/app/health.css.gz | Bin 5446 -> 5446 bytes public/app/health.css.map.gz | Bin 1829 -> 1829 bytes public/app/health.js.gz | Bin 70458 -> 70458 bytes public/app/health.js.map.gz | Bin 208976 -> 0 bytes public/app/install.js.gz | Bin 5944 -> 5944 bytes public/app/install.js.map.gz | Bin 51698 -> 0 bytes public/app/settings.css.gz | Bin 6117 -> 6117 bytes public/app/settings.css.map.gz | Bin 2114 -> 2114 bytes public/app/settings.js.gz | Bin 11294 -> 11294 bytes public/app/settings.js.map.gz | Bin 69420 -> 0 bytes public/app/splash.css.gz | Bin 1408 -> 1408 bytes public/app/splash.css.map.gz | Bin 558 -> 558 bytes public/app/splash.js.gz | Bin 5111 -> 5111 bytes public/app/splash.js.map.gz | Bin 49765 -> 0 bytes 38 files changed, 99 insertions(+), 25 deletions(-) create mode 100644 data/migrations/models/20240307_rebuild_progress_nofk.sql delete mode 100644 public/app/about.js.map.gz delete mode 100644 public/app/app.js.map.gz delete mode 100644 public/app/health.js.map.gz delete mode 100644 public/app/install.js.map.gz delete mode 100644 public/app/settings.js.map.gz delete mode 100644 public/app/splash.js.map.gz diff --git a/CHANGELOG.md b/CHANGELOG.md index 90672f6..d1e30ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,12 +23,28 @@ This is a detailed list of changes in each version. + +## v2024.3.1-prealpha ["Zep"](https://discord.com/channels/818905168107012097/818905168690413611/1215774241979502612) + +**Released 2023-03-08** + +- 🐛 Extended database migration timeouts to 2 minutes by default. See `dbMaintenanceTimeoutMs` setting for details. Should resolve [this issue](https://discord.com/channels/818905168107012097/818907922767544340/1215748274401710191). + +- 🐛 Added new migration to re-assert the `Progress` table schema. Should resolve [this issue](https://discord.com/channels/818905168107012097/1215730724020293752). + +- 🐛 The webservice now re-writes `settings.toml` files from prior versions, to ensure the latest settings are visible. Thanks for reporting, [@tkohhh](https://discord.com/channels/818905168107012097/1215760858664140841)! Older versions of `settings.toml` are now moved to `./archive` (it had been `./old`). + +- 🐛 `sync` won't be started if any health checks post fatal errors. + +- 🐛 `main` renders service startup errors to `stderr` now _and still tries to spin up the web service_ (in an effort to try to get the health check page to the user) + + -## v2024.3.0-alpha +## v2024.3.0-prealpha -**To be released** +**Released 2023-03-08** ### ✒️ Version format change @@ -40,7 +56,7 @@ As an example, a build might be `v2024.1.7-beta`. If it proves sufficiently stab PhotoStructure now adds `Where/Country/Region/City` tags for those photos and videos with Latitude and Longitude metadata. -Note that this feature is uses an embedded geo database, so no network access is required. This initial implementation only inclues cities with a population of 1000 or greater. See the new `tagGeo` and `tagGeoTemplate` [settings](/go/settings) for more details. +Note that this feature is uses an embedded geo database, so no network access is required. This initial implementation only inclues cities with a population of 1000 or greater. See the new `tagGeo` and `tagGeoTemplate` [settings](/go/settings) for more details. ### 🔃 Sync improvements diff --git a/VERSION.json b/VERSION.json index 0d1eeab..7986f3f 100644 --- a/VERSION.json +++ b/VERSION.json @@ -1,12 +1,12 @@ { - "version": "2024.3.0-prealpha", + "version": "2024.3.1-prealpha", "versionMajor": 2024, "versionMinor": 3, - "versionPatch": 0, + "versionPatch": 1, "versionPrerelease": [ "prealpha" ], - "release": "2024.3.0-prealpha+20240308102353", - "gitSha": "92cba1b21937cb9ca770f6a339e44b0fbee04bf9", - "gitDate": "2024-03-08T18:23:53.000Z" + "release": "2024.3.1-prealpha+20240308150212", + "gitSha": "d92384e8659ff46fbae8e6f81fa5867114a4a843", + "gitDate": "2024-03-08T23:02:12.000Z" } diff --git a/bin/info.js b/bin/info.js index 1596e68..21c284c 100755 --- a/bin/info.js +++ b/bin/info.js @@ -6,4 +6,4 @@ * IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THIS SOFTWARE */ -(()=>{var __webpack_modules__={60308:e=>{const t={PasetoNotSupported:"ERR_PASETO_NOT_SUPPORTED",PasetoDecryptionFailed:"ERR_PASETO_DECRYPTION_FAILED",PasetoInvalid:"ERR_PASETO_INVALID",PasetoVerificationFailed:"ERR_PASETO_VERIFICATION_FAILED",PasetoClaimInvalid:"ERR_PASETO_CLAIM_INVALID"};class i extends Error{constructor(e){super(e),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}e.exports.PasetoError=i,e.exports.PasetoNotSupported=class extends i{},e.exports.PasetoDecryptionFailed=class extends i{},e.exports.PasetoInvalid=class extends i{},e.exports.PasetoVerificationFailed=class extends i{},e.exports.PasetoClaimInvalid=class extends i{}},78972:(e,t,i)=>{const{PasetoInvalid:r,PasetoNotSupported:s}=i(60308),{decode:n}=i(47859),a=i(40816);e.exports=(e,{parse:t=!0}={})=>{if("string"!=typeof e)throw new TypeError("token must be a string");const{0:i,1:o,2:l,3:u,length:c}=e.split(".");if(3!==c&&4!==c)throw new r("token is not a PASETO formatted value");if("v1"!==i&&"v2"!==i&&"v3"!==i&&"v4"!==i)throw new s("unsupported PASETO version");if("local"!==o&&"public"!==o)throw new s("unsupported PASETO purpose");const d={footer:u?n(u):void 0,payload:void 0,version:i,purpose:o};if("local"===o)return d;const h="v1"===i?256:"v3"===i?96:64;let f;try{f=n(l).subarray(0,-h)}catch{throw new r("token is not a PASETO formatted value")}return d.payload=t?a(f):f,d}},2744:(e,t,i)=>{const r=i(78972);e.exports={decode:r}},67814:(e,t,i)=>{const r=i(85223);e.exports=({audience:e,expiresIn:t,iat:i=!0,issuer:s,jti:n,kid:a,notBefore:o,now:l=new Date,subject:u},c)=>{if(!(l instanceof Date&&l.getTime()))throw new TypeError("options.now must be a valid Date object");const d=l.getTime();if(void 0!==i){if("boolean"!=typeof i)throw new TypeError("options.iat must be a boolean");i&&(c.iat=new Date(d))}if(void 0!==t){if("string"!=typeof t)throw new TypeError("options.expiresIn must be a string");c.exp=new Date(d+r(t))}if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.notBefore must be a string");c.nbf=new Date(d+r(o))}if(void 0!==e){if("string"!=typeof e)throw new TypeError("options.audience must be a string");c.aud=e}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.issuer must be a string");c.iss=s}if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.subject must be a string");c.sub=u}if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.kid must be a string");c.kid=a}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.jti must be a string");c.jti=n}return c}},10968:(e,t,i)=>{const{PasetoClaimInvalid:r}=i(60308),s=i(85223);e.exports=({ignoreExp:e,ignoreNbf:t,ignoreIat:i,maxTokenAge:n,subject:a,issuer:o,clockTolerance:l,audience:u,now:c=new Date},d)=>{if(!(c instanceof Date&&c.getTime()))throw new TypeError("options.now must be a valid Date object");const h=c.getTime();if("iss"in d&&"string"!=typeof d.iss)throw new r("payload.iss must be a string");if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.issuer must be a string");if(d.iss!==o)throw new r("issuer mismatch")}if("sub"in d&&"string"!=typeof d.sub)throw new r("payload.sub must be a string");if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.subject must be a string");if(d.sub!==a)throw new r("subject mismatch")}if("aud"in d&&"string"!=typeof d.aud)throw new r("payload.aud must be a string");if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.audience must be a string");if(d.aud!==u)throw new r("audience mismatch")}if(void 0!==l&&"string"!=typeof l)throw new TypeError("options.clockTolerance must be a string");const f=l?s(l):0;let m;if("iat"in d){if("string"!=typeof d.iat)throw new r("payload.iat must be a string");if(m=new Date(d.iat).getTime(),!m)throw new r("payload.iat must be a valid ISO8601 string");if(!i&&m>h+f)throw new r("token issued in the future")}if("nbf"in d){if("string"!=typeof d.nbf)throw new r("payload.nbf must be a string");const e=new Date(d.nbf).getTime();if(!e)throw new r("payload.nbf must be a valid ISO8601 string");if(!t&&e>h+f)throw new r("token is not active yet")}if("exp"in d){if("string"!=typeof d.exp)throw new r("payload.exp must be a string");const t=new Date(d.exp).getTime();if(!t)throw new r("payload.exp must be a valid ISO8601 string");if(!e&&t<=h-f)throw new r("token is expired")}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.maxTokenAge must be a string");if(!("iat"in d))throw new r("missing iat claim");if(m+s(n){e.exports.encode=e=>e.toString("base64url"),e.exports.decode=e=>Buffer.from(e,"base64")},80608:e=>{e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if("string"!=typeof e)throw new TypeError("options.assertion must be a string, or a Buffer");return Buffer.from(e,"utf8")}},83561:(e,t,i)=>{const r=i(65825);e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if(r(e))return Buffer.from(JSON.stringify(e),"utf8");if("string"!=typeof e)throw new TypeError("options.footer must be a string, Buffer, or a plain object");return Buffer.from(e,"utf8")}},1658:(e,t,i)=>{const r=i(67814),s=i(65825);e.exports=(e,t)=>{if(Buffer.isBuffer(e)){if(0!==Object.keys(t).length)throw new TypeError("options cannot contain claims when payload is a Buffer");return e}if(!s(e))throw new TypeError("payload must be a Buffer or a plain object");return e=(e=>JSON.parse(JSON.stringify(e)))(e),e=r(t,e),Buffer.from(JSON.stringify(e),"utf-8")}},82115:e=>{e.exports=e=>{const{x:t,y:i}=e.export({format:"jwk"}),r=Buffer.from(i,"base64"),s=2+(1&r[r.length-1]);return Buffer.concat([Buffer.alloc(1,s),Buffer.from(t,"base64")])}},88965:(e,t,i)=>{const r=i(64770),{PasetoInvalid:s}=i(60308),n=i(10968),{decode:a}=i(47859),o=i(40816);e.exports={post:function(e,t,i,r,s,a,l){if(t){if(0!==Object.keys(i).length)throw new TypeError("options cannot contain claims when options.buffer is true");return r?{payload:s,footer:a?.length?a:void 0,version:e,purpose:l}:s}const u=o(s);return n(i,u),r?{payload:u,footer:a?.length?a:void 0,version:e,purpose:l}:u},pre:function(e,t){if("string"!=typeof t)throw new TypeError("token must be a string, got: "+typeof t);if(t.slice(0,e.length)!==e)throw new s(`token is not a ${e.slice(0,e.length-1)} PASETO`);let{0:i,1:n="",length:o}=t.slice(e.length).split(".");try{r(o<=2),i=a(i),n=a(n)}catch{throw new s("token is not a PASETO formatted value")}return{raw:i,f:n}}}},56463:(e,t,i)=>{const r=i(76982),s=i(92460),n=i(70761),a=i(29534),{PasetoDecryptionFailed:o}=i(60308),l=i(82682),{webcrypto:{subtle:u}}=r,c=s.promisify(r.hkdf),d=Buffer.from("paseto-encryption-key"),h=Buffer.from("paseto-auth-key-for-aead"),f=Buffer.alloc(0),m=(e,t)=>r.createHmac("sha384",t).update(e).digest(),p=async(e,t,i,r)=>u[e]({name:"AES-CTR",counter:r,length:16},await u.importKey("raw",i,"AES-CTR",!1,[e]),t).then(Buffer.from),g=p.bind(void 0,"encrypt"),y=p.bind(void 0,"decrypt");e.exports={sign:s.promisify(r.sign),verify:s.promisify(r.verify),"v1.local-encrypt":async function(e,t,i){const s="v1.local.",o=m(e,r.randomBytes(32)).subarray(0,32),l=o.subarray(0,16),[u,f]=await Promise.all([c("sha384",i,l,d,32).then(Buffer.from),c("sha384",i,l,h,32).then(Buffer.from)]),p=await g(e,u,o.subarray(16)),y=n(s,o,p,t),v=m(y,f);return a(s,t,o,p,v)},"v1.local-decrypt":async function(e,t,i){const r=e.subarray(0,32),s=e.subarray(-48),a=e.subarray(32,-48),u=r.subarray(0,16),[f,p]=await Promise.all([c("sha384",i,u,d,32).then(Buffer.from),c("sha384",i,u,h,32).then(Buffer.from)]),g=n("v1.local.",r,a,t),v=m(g,p);if(!l(s,v))throw new o("decryption failed");const w=await y(a,f,r.subarray(16));if(!w)throw new o("decryption failed");return w},"v3.local-encrypt":async function(e,t,i,s){const o="v3.local.",l=r.randomBytes(32),[u,p]=await Promise.all([c("sha384",i,f,Buffer.concat([d,l]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,l]),48).then(Buffer.from)]),y=u.subarray(0,32),v=u.subarray(32),w=await g(e,y,v),b=n(o,l,w,t,s),S=m(b,p);return a(o,t,l,w,S)},"v3.local-decrypt":async function(e,t,i,r){const s=e.subarray(0,32),a=e.subarray(-48),u=e.subarray(32,-48),[p,g]=await Promise.all([c("sha384",i,f,Buffer.concat([d,s]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,s]),48).then(Buffer.from)]),v=p.subarray(0,32),w=p.subarray(32),b=n("v3.local.",s,u,t,r),S=m(b,g);if(!l(a,S))throw new o("decryption failed");const P=await y(u,v,w);if(!P)throw new o("decryption failed");return P}}},70981:(e,t,i)=>{const{KeyObject:r}=i(76982);let{isKeyObject:s}=i(75162);s||(s=e=>null!=e&&e instanceof r),e.exports=s},65825:e=>{e.exports=e=>!!e&&e.constructor===Object},41726:(e,t,i)=>{const{PasetoNotSupported:r}=i(60308);e.exports=e=>{if(!Number.isSafeInteger(e))throw new r("message is too long for Node.js to safely process");const t=~~(e/4294967295),i=e%4294967295-t,s=Buffer.allocUnsafe(8);return s.writeUInt32LE(t,4),s.writeUInt32LE(i,0),s}},85223:e=>{const t=36e5,i=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;e.exports=e=>{const r=i.exec(e);if(!r)throw new TypeError(`invalid time period format ("${e}")`);const s=parseFloat(r[1]);switch(r[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(1e3*s);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(6e4*s);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(s*t);case"day":case"days":case"d":return Math.round(864e5*s);case"week":case"weeks":case"w":return Math.round(6048e5*s);case"year":case"years":case"yr":case"yrs":case"y":return Math.round(315576e5*s)}}},29534:(e,t,i)=>{const{encode:r}=i(47859);e.exports=function(e,t,...i){let s=`${e}${r(Buffer.concat(i))}`;return t.byteLength&&(s+=`.${r(t)}`),s}},70761:(e,t,i)=>{const r=i(41726);e.exports=(...e)=>{e=e.filter(Boolean);let t=r(e.length);for(let i of e){i=Buffer.from(i,"utf8");const e=r(Buffer.byteLength(i));t=Buffer.concat([t,e,i])}return t}},40816:(e,t,i)=>{const{PasetoInvalid:r}=i(60308),{strict:s}=i(64770),n=i(65825);e.exports=e=>{try{const t=JSON.parse(e);return s(n(t)),t}catch{throw new r("All PASETO payloads MUST be a JSON object")}}},92366:(e,t,i)=>{const{sign:r}=i(56463),s=i(70761),n=i(29534);e.exports=async function(e,t,i,a,o,l,u){const c=s(u,e,t,i,l),d=await r(a,c,o);return n(e,i,t,d)}},495:(e,t,i)=>{const{createSecretKey:r}=i(76982),s=i(70981);e.exports=function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}`)&&(t=Buffer.from(t.slice(e.length),"base64url")),!s(t))try{t=r(t)}catch{}if(!s(t))throw new TypeError("invalid key provided");if("secret"!==t.type||32!==t.symmetricKeySize)throw new TypeError(`${e} secret key must be 32 bytes long symmetric key`);return t}},82682:(e,t,i)=>{const{timingSafeEqual:r}=i(76982),s=(e,t)=>{if(e.length===t)return e;const i=Buffer.alloc(t);return e.copy(i),i};e.exports=(e,t)=>{const i=Math.max(e.length,t.length);return r(s(e,i),s(t,i))}},49826:(e,t,i)=>{const{PasetoVerificationFailed:r}=i(60308),{verify:s}=i(56463),n=i(70761),{pre:a}=i(88965);e.exports=async function(e,t,i,o,l,u,c){const{raw:d,f:h}=a(e,t),f=d.subarray(0,-o),m=d.subarray(-o),p=n(c,e,f,h,u);if(!await s(i,p,l,m))throw new r("invalid signature");return{m:f,footer:h.length?h:void 0}}},91227:(e,t,i)=>{const r=i(60308),s=i(79665),n=i(56120),a=i(50015),o=i(64230),{decode:l}=i(2744);e.exports={decode:l,V1:s,V2:n,V3:a,V4:o,errors:r}},39324:(e,t,i)=>{const{"v1.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v1.local"),{pre:n,post:a}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:o=!1,...l}={}){const{raw:u,f:c}=n("v1.local.",e),d=(t=s(t)).export(),h=await r(u,c,d);return a("v1",o,l,i,h,c,"local")}},21472:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v1.local"),n=i(1658),{"v1.local-encrypt":a}=i(56463);e.exports=async function(e,t,{footer:i,...o}={}){const l=n(e,o);t=s(t);const u=r(i),c=t.export();return a(l,u,c)}},79665:(e,t,i)=>{const r=i(77868),s=i(77256),n=i(21472),a=i(39324),o=i(70866);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o}},70866:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=s(r.generateKeyPair),o=s(r.generateKey);e.exports=async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await o("aes",{length:256});return"paserk"===t?`k1.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await a("rsa",{modulusLength:2048});return"paserk"===t?{secretKey:`k1.secret.${e.export({format:"der",type:"pkcs1"}).toString("base64url")}`,publicKey:`k1.public.${i.export({format:"der",type:"pkcs1"}).toString("base64url")}`}:e}default:throw new n("unsupported v1 purpose")}}},77868:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPrivateKey:n}=i(76982),a=i(83561),o=i(1658),l=i(92366),u=i(70981);e.exports=async function(e,t,{footer:i,...c}={}){const d=o(e,c),h=a(i);return t=function(e){if("string"==typeof e&&e.startsWith("k1.secret."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!u(e))try{e=n(e)}catch{}if(!u(e))throw new TypeError("invalid key provided");if("private"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public signing key must be a private RSA key with 2048 bit modulus length");return e}(t),l("v1.public.",d,h,"sha384",{key:t,padding:r,saltLength:s})}},77256:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPublicKey:n}=i(76982),a=i(49826),o=i(70981),{post:l}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:u=!1,...c}={}){t=function(e){if("string"==typeof e&&e.startsWith("k1.public."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!o(e)||"private"===e.type)try{e=n(e)}catch{}if(!o(e))throw new TypeError("invalid key provided");if("public"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public verify key must be a public RSA key with 2048 bit modulus length");return e}(t);const{m:d,footer:h}=await a("v1.public.",e,"sha384",256,{key:t,padding:r,saltLength:s});return l("v1",u,c,i,d,h,"public")}},56120:(e,t,i)=>{const r=i(88451),s=i(859),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(62827);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},62827:(e,t,i)=>{const r=i(64770),s=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:a}=i(60308),o=i(70981),l=n(s.generateKeyPair);async function u(e,t,{format:i="keyobject"}={}){if("keyobject"!==i&&"paserk"!==i)throw new TypeError("invalid format");if("public"===t){const{privateKey:t,publicKey:r}=await l("ed25519");return"paserk"===i?{secretKey:`k${e.slice(1)}.secret.${h(t).toString("base64url")}`,publicKey:`k${e.slice(1)}.public.${h(r).toString("base64url")}`}:t}throw new a(`unsupported ${e} purpose`)}function c(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 64:{const t=s.createPrivateKey({key:Buffer.concat([Buffer.from("302e020100300506032b657004220420","hex"),e.subarray(0,32)]),format:"der",type:"pkcs8"});if(!e.subarray(32).equals(Buffer.from(t.export({format:"jwk"}).x,"base64")))throw new TypeError("invalid byte sequence");return t}case 32:return s.createPublicKey({key:Buffer.concat([Buffer.from("302a300506032b6570032100","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 64 bytes (private key), or 32 bytes (public key)")}}function d(e,t){if(!o(t))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public key must be an Ed25519 key`);switch(t.type){case"public":return Buffer.from(t.export({format:"jwk"}).x,"base64");case"private":{const{d:e,x:i}=t.export({format:"jwk"});return Buffer.concat([Buffer.from(e,"base64"),Buffer.from(i,"base64")])}}}function h(...e){return d("v2",...e)}e.exports={_checkPrivateKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.secret.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,64)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t))try{t=s.createPrivateKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("private"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public signing key must be a private ed25519 key`);return t},_checkPublicKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.public.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,32)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t)||"private"===t.type)try{t=s.createPublicKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("public"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public verify key must be a public ed25519 key`);return t},_generateKey:u,_keyObjectToBytes:d,bytesToKeyObject:c,generateKey:async function(...e){return u("v2",...e)},keyObjectToBytes:h}},88451:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(92366),{_checkPrivateKey:a}=i(62827),o=a.bind(void 0,"v2");e.exports=async function(e,t,{footer:i,...a}={}){const l=s(e,a);t=o(t);const u=r(i);return n("v2.public.",l,u,void 0,t)}},859:(e,t,i)=>{const r=i(49826),{_checkPublicKey:s}=i(62827),{post:n}=i(88965),a=s.bind(void 0,"v2");e.exports=async function(e,t,{complete:i=!1,buffer:s=!1,...o}={}){t=a(t);const{m:l,footer:u}=await r("v2.public.",e,void 0,64,t);return n("v2",s,o,i,l,u,"public")}},18582:(e,t,i)=>{const{"v3.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v3.local"),n=i(80608),{pre:a,post:o}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:l=!1,assertion:u,...c}={}){const{raw:d,f:h}=a("v3.local.",e);t=s(t);const f=n(u),m=t.export(),p=await r(d,h,m,f);return o("v3",l,c,i,p,h,"local")}},43406:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v3.local"),n=i(1658),a=i(80608),{"v3.local-encrypt":o}=i(56463);e.exports=async function(e,t,{footer:i,assertion:l,...u}={}){const c=n(e,u);t=s(t);const d=r(i),h=a(l),f=t.export();return o(c,d,f,h)}},50015:(e,t,i)=>{const r=i(42438),s=i(65466),n=i(43406),a=i(18582),{generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}=i(80568);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}},80568:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=i(70981),o=i(82115),l=s(r.generateKeyPair),u=s(r.generateKey);function c(e){if(!a(e))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public key must be an EC P-384 key");switch(e.type){case"public":return o(e);case"private":return Buffer.from(e.export({format:"jwk"}).d,"base64")}}e.exports={generateKey:async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await u("aes",{length:256});return"paserk"===t?`k3.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await l("ec",{namedCurve:"P-384"});return"paserk"===t?{secretKey:`k3.secret.${c(e).toString("base64url")}`,publicKey:`k3.public.${c(i).toString("base64url")}`}:e}default:throw new n("unsupported v3 purpose")}},bytesToKeyObject:function(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 48:return r.createPrivateKey({key:Buffer.concat([Buffer.from("303e0201010430","hex"),e,Buffer.from("a00706052b81040022","hex")]),format:"der",type:"sec1"});case 49:if(2!==e[0]&&3!==e[0])throw new TypeError("invalid compressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3046301006072a8648ce3d020106052b81040022033200","hex"),e]),format:"der",type:"spki"});case 97:if(4!==e[0])throw new TypeError("invalid uncompressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3076301006072a8648ce3d020106052b81040022036200","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 48 bytes (private key), 49 bytes (compressed public key), or 97 bytes (uncompressed public key)")}},keyObjectToBytes:c}},42438:(e,t,i)=>{const{createPrivateKey:r}=i(76982),s=i(83561),n=i(1658),a=i(80608),o=i(92366),l=i(70981),{bytesToKeyObject:u}=i(80568),c=i(82115);e.exports=async function(e,t,{footer:i,assertion:d,...h}={}){const f=n(e,h),m=s(i),p=a(d);return t=function(e){if("string"==typeof e&&e.startsWith("k3.secret."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,48)}catch{}if(Buffer.isBuffer(e))try{e=u(e)}catch{}if(!l(e))try{e=r(e)}catch{}if(!l(e))throw new TypeError("invalid key provided");if("private"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public signing key must be a private EC P-384 key");return e}(t),o("v3.public.",f,m,"sha384",{key:t,dsaEncoding:"ieee-p1363"},p,c(t))}},65466:(e,t,i)=>{const{createPublicKey:r}=i(76982),s=i(80608),n=i(49826),a=i(70981),{bytesToKeyObject:o}=i(80568),l=i(82115),{post:u}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:c=!1,assertion:d,...h}={}){t=function(e){if("string"==typeof e&&e.startsWith("k3.public."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,49)}catch{}if(Buffer.isBuffer(e))try{e=o(e)}catch{}if(!a(e)||"private"===e.type)try{e=r(e)}catch{}if(!a(e))throw new TypeError("invalid key provided");if("public"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public verify key must be a public EC P-384 key");return e}(t);const f=s(d),{m,footer:p}=await n("v3.public.",e,"sha384",96,{key:t,dsaEncoding:"ieee-p1363"},f,l(t));return u("v3",c,h,i,m,p,"public")}},64230:(e,t,i)=>{const r=i(29901),s=i(77933),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(24961);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},24961:(e,t,i)=>{const{_checkPrivateKey:r,_checkPublicKey:s,_generateKey:n,_keyObjectToBytes:a,bytesToKeyObject:o}=i(62827);e.exports={_checkPrivateKey:r,_checkPublicKey:s,bytesToKeyObject:o,generateKey:async function(...e){return n("v4",...e)},keyObjectToBytes:function(...e){return a("v4",...e)}}},29901:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(80608),a=i(92366),{_checkPrivateKey:o}=i(24961),l=o.bind(void 0,"v4");e.exports=async function(e,t,{footer:i,assertion:o,...u}={}){const c=s(e,u),d=n(o);t=l(t);const h=r(i);return a("v4.public.",c,h,void 0,t,d)}},77933:(e,t,i)=>{const r=i(80608),s=i(49826),{_checkPublicKey:n}=i(24961),{post:a}=i(88965),o=n.bind(void 0,"v4");e.exports=async function(e,t,{complete:i=!1,buffer:n=!1,assertion:l,...u}={}){t=o(t);const c=r(l),{m:d,footer:h}=await s("v4.public.",e,void 0,64,t,c);return a("v4",n,u,i,d,h,"public")}},37975:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),s=i(38639),n=i(44198);function a(){return(0,s.toNotBoolean)((0,n.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,n.env)().NO_COLOR)||["dumb","unknown"].includes((0,n.env)().TERM))}t.noColor=a;let o=!a();function l(){return o}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){o=e??!a()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),s=i(7282),n=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,s.isProd)()?"":`-${(0,s.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+n.version))},48884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),s=i(36783),n=i(76790),a=i(22573),o=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const s=new Set(t.map(i));return e.filter((e=>s.has(i(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...v(e.slice(i+1))]}function w(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function b(e){return P(e,(e=>e.valueOf()))}function S(e){return _(e,(e=>e.valueOf()))}function P(e,t){return T(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return T(e,t,((e,t)=>(0,h.gt)(e,t)))}function M(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function T(e,t,i){return E(e,t,i).index}function E(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let s,n=-1;for(let r=0;re.slice(i,i+t)))}async function D(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,o.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(a.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,o.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,s.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let s=0;for(const n of e)(t(n,s++)?i:r).push(n);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let s=0;se.slice(0,t+1)))},t.min=function(e){return e[b(e)]},t.leastIndex=b,t.max=function(e){return e[S(e)]},t.greatestIndex=S,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=M,t.least=function(e){return M(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const i=E(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=k,t.collectBatched=function(e,t,i){const s=[];for(const n of k((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(i(n)));return s},t.collectBatchedAsync=async function(e,t,i){const s=[];for(const n of k((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(await i(n)));return s},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await D(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+s;if(re+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const o=i(77988),l=a(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),v=i(25764),w=i(38836),b=i(99331),S=i(95937),P=i(98314),_=i(38835),M=i(70025),T=i(8769),E=i(43334),k=i(95402),D=i(28874),x=i(63870);class C extends w.EndableWrapper{constructor(e,t,i=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>n(this,r,"m",s).call(this)),i,"worker"===e?(0,x.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const a=t;a.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,k.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),a.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),a.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,S.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),a.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),a.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),a.on("noTaskData",((e,i,r)=>{const s=t.options.streamFlushMillis;s{this.logger.error("observeBatchCluster.endError()",e)})),a.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&k.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof o.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,b.ending)()||!0===(0,M.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,T.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=C,r=new WeakSet,s=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(E.isWin?3:1)*c.minuteMs,maxTasksPerProcess:D.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:D.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:D.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:D.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:D.Settings.taskTimeoutMs.valueOrDefault}}},71371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedGreatestSet=void 0;const r=i(92322);t.BoundedGreatestSet=class{constructor(e,t){this.maxLength=e,this.toValue=t,this.sortedArray=new r.SortedSet(t)}toA(){return this.vacuum(),this.sortedArray.toA()}vacuum(){return this.sortedArray.retainLastN(this.maxLength)}add(...e){this.maxLength<=0||(this.sortedArray.addAll(...e),this.sortedArray.length>=2*this.maxLength&&this.vacuum())}}},89788:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(r.add(this),this.maxLength=e,s.set(this,void 0),n.set(this,0),a.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,s,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]=t))}get length(){return u(this,n,"f")}set length(e){l(this,n,(0,d.clamp)(0,u(this,n,"f"),e),"f")}clear(){this.length=0}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,n,"f")),e<0||e>=u(this,n,"f")?void 0:t((e+u(this,a,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,s,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,n,"f"){u(this,s,"f")[e]=c}));return u(this,n,"f")}pop(){return u(this,r,"m",o).call(this,u(this,n,"f")-1,(e=>{var t;return l(this,n,(t=u(this,n,"f"),--t),"f"),u(this,s,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,n,"f"){u(this,s,"f")[e]=c,l(this,a,e,"f")}));return u(this,n,"f")}shift(){return u(this,r,"m",o).call(this,0,(e=>{var t,i;return l(this,a,(t=u(this,a,"f"),++t),"f"),l(this,n,(i=u(this,n,"f"),--i),"f"),u(this,s,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",o).call(this,u(this,n,"f")-1-e,(e=>{const i=u(this,s,"f")[e];u(this,s,"f")[e]=u(this,s,"f")[t],u(this,s,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),s=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function n(e){for(const{bom:t,encoding:i}of s)if(a(e,t))return e.subarray(t.length).toString(i);return e.toString()}function a(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=n,t.bufferToString=function(e){return Buffer.isBuffer(e)?n(e):(0,r.toS)(e)},t.bufferStartsWith=a},9092:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=s},36638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=s},40583:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const a=i(40958),o=i(23838),l=n(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new o.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,a.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,s=-1;for(const[i,n]of this.m.entries()){const a=(0,c.diceCoeff)(i,e);if(a>t&&a>s){const e=this.getFirst(n);null!=e&&(r=e,s=a)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),s=i(31586),n=i(68708),a=i(54993),o=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new o.Average(0);for(const t of this.keys()){if(!(0,s.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,a.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,s.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,n.tap)(new o.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,s]of this.m.entries()){const n=e(r);t.fill(n,i,i+s),i+=s}return t}}t.CountingSet=u},79840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),s=i(72993),n=i(45969),a=i(43334);t.EditionType=(0,r.lazy)((()=>a.isElectron?"Desktops":(0,n.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>s.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),s=i(55835),n=i(68708);var a=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return a.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,s.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.omit)(e,...i),(0,n.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,s.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),s=i(19851),n=i(95696);t.examples=(0,s.lazy)((()=>n.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),s=i(65843),n=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,s.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,n.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(31586),o=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,a.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,a.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,s.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,s.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,n.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,o.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,o.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,o.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,a.isNumber)(e.__uid)&&(0,a.isNumber)(e.__start)}},80049:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),s.set(this,0),n.set(this,0),a.set(this,0),o.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,s,l(this,s,"f")+e.cacheHitsAsync,"f"),u(this,n,l(this,n,"f")+e.cacheMisses,"f"),u(this,a,l(this,a,"f")+e.rejections,"f"),u(this,o,l(this,o,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,s,"f"),cacheMisses:l(this,n,"f"),rejections:l(this,a,"f"),timeouts:l(this,o,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,a,o;if(!this.cache.has(e))return void u(this,n,(t=l(this,n,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,s,(i=l(this,s,"f"),++i),"f"),c.promise):(u(this,r,(a=l(this,r,"f"),++a),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(o=l(this,r,"f"),++o),"f"),c}get(e){var t,i;const s=this.cache.get(e);return null==s||s instanceof m.Deferred&&s.isPending?u(this,n,(t=l(this,n,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),s instanceof m.Deferred?s.value:s}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,s,0,"f"),u(this,n,0,"f"),u(this,a,0,"f"),u(this,o,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,a,(t=l(this,a,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,o,(r=l(this,o,"f"),++r),"f")})),r.promise}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap},54127:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,a.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,s.range)(0,r).filter((e=>this.rows.every((t=>(0,n.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,o.fromEntries)(e))).filter((e=>(0,o.values)(e).some(n.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,o=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(o,r.index);(0,n.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),h=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:h});else{const e=(0,s.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,a.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}o=t.lastIndex}const l=(0,s.last)(i);return null!=l&&((0,n.blank)(this.headerRow.slice(o))?l.rightIdx=(0,a.max_)(...this.rows.map((e=>e.length))):l.rightIdx=o),i}}t.Fixed=m},73168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const r=i(55835),s=i(20014),n=i(55222),a=i(97352),o=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,a.within)(-90,90,e)&&0!==e}function c(e){return(0,a.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function h(e,t,i=o){return(0,r.map)(m(e,t,l(i)),(e=>n.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=o){return h(e?.lat,e?.lon,t)},t.geohash=h,t.geohashNumericShort=function(e,t){return m(e,t,30)};const f=new s.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=o){return d(e,t)?f.zip([t,e],l(i)):void 0}function p(e,t=o){return f.unzip(e,l(t))?.reverse()}function g(e,t=o){const[i,r]=p(e,t);return{lat:i,lon:r}}t.geohashNumeric=m,t.ungeohash=function(e,t=o){return(0,r.map)(n.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,r=t.lat*Math.PI/180,s=(t.lat-e.lat)*Math.PI/180,n=(t.lon-e.lon)*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(r)*Math.sin(n/2)*Math.sin(n/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},66364:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSuspended=void 0;const r=i(19851);t.isSuspended=(0,r.lazy)((()=>!1))},80875:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),s=i(98553);var n=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return n.parseJSON}}),t.mapParsed=function(e,t){const i=(0,s.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,s.parseJSON)((await(0,r.readFile)(e)).toString())}},19851:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const a=i(57975),o=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&n(this,r,"m",s).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,o.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,o.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=b(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>S(v()??await(m.isWin?P():m.isMac?M():T()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function b(e){if((0,n.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=w.exec(e.trim())?.groups;return null==i?void 0:(0,s.compact)([i.lang,i.country]).join("-")}function S(e){return b(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=S,t.localeWin=P;const _={timeoutMs:10*a.secondMs};async function M(){return b(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function T(){return S(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=M,t.localePosix=T,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),s=i(1708),n=i(45599),a=i(68708),o=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,n.defer)((()=>{(0,o.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:s.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,a.pick)(s.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:s.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),s=i(32105),n=i(14593);t.rootLoggers=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));const a=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));t.mkLogger=function(e){return new n.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new n.ContextualLogger(e,a)}},56639:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),s=i(55835),n=i(59455),a=i(48884);function o(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,a.concat)(...e.map((e=>t(e)))))},t.compactMap=o,t.toMap=function(e,t){return o((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:o(await Promise.all((0,r.compact)((0,n.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,s.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),s=i(54557);t.memoize=function(e,t){let i=0;const n=new s.FifoCache(t.maxSize,t.ttlMs),a=t=>{if(null!=t)return i++,n.getOrSet((0,r.stringify)(t),(()=>e(t)))};return a.clear=e=>null==e?n.clear():n.delete((0,r.stringify)(e)),a.size=()=>n.size,a.callCount=()=>i,a}},31578:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const r=i(1708),s=i(31586),n=i(12168),a=i(70417);function o(){const e=(0,r.memoryUsage)();return(0,a.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,r.memoryUsage)().rss}t.memoryUsageBytes=o,t.memoryUsageMb=function(){return(0,s.sigFigs)(o()/n.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,s.sigFigs)(l()/n.MB,2)}},7282:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const s=r(i(1708)),n=i(38639),a=i(54993),o=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,o.lazy)((()=>s.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,a.toS)(s.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return s.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,n.isTrue)(s.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){s.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},26033:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._isSupportedNode=t.RequiredNodeRange=t.isSupportedNode=void 0;const r=i(45599),s=i(76280);function n(e=process.versions.node){return(0,s.semverSatisfies)(e,t.RequiredNodeRange)}t.isSupportedNode=(0,r.defer)(n),t.RequiredNodeRange="18||20||21",t._isSupportedNode=n},97352:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55835),o=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,o.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(o.gt0)},t.firstNonZero=function(...e){for(const t of(0,n.flatten)(e)){const e=(0,o.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,a.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,o.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,o.toInt)(e),s=(0,o.toInt)(t);return null!=r&&r>0&&null!=s&&s>0?i(r,s):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,o.isNumber)(e))return e;if((0,s.blank)(e))return;const t=String(e);return(0,a.map)(f.exec(t),(e=>(0,o.toFloat)(t.substr(e.index))))}function p(e){return(0,o.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,a.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,a.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const s=i*e.length;for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),s=i(42659),n=i(96249),a=i(55835),o=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,s.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,s]of(0,l.entries)(e)){const e=t(r,s);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,a.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(a.defined)},t.firstDefinedField=function(e,...t){return(0,a.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,a.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const s of t)r[s]=i(s,e[s]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let s=0;for(const n of(0,l.keys)(e))if(r[n]=t(n,e[n]),s++,(0,o.gt)(s,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,n.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),s=i(73024),n=i(48161),a=i(19851),o=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),v=i(30933),w=(0,a.lazy)((()=>(0,f.mkLogger)("os")));function b(){return(0,n.platform)()+" "+(0,n.release)()}t.osArch=(0,a.lazy)((()=>`${function(){switch((0,n.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return C();case"win32":return F();default:return b()}}()} on ${(0,n.arch)()}`)),t.osFullName=(0,a.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const S=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function _(){return"ubuntu"===(0,t.osDistributionLinux)()}function M(){return"fedora"===(0,t.osDistributionLinux)()}function T(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,a.lazy)((()=>{if(g.isLinux)for(const e of S)try{const t=(0,s.readFileSync)(e).toString();if((0,o.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,a.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,o.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),b)})),t.osDistributionLinux=(0,a.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=_,t.hasApt=function(){return P()||_()},t.isFedora=M,t.isAlpine=T;const E={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},k={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function D(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),s=t[i];return(0,c.isString)(s)?s:s?.[r]}const x=(0,a.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function C(e=x()){try{return(0,o.mapNotBlankOr)(function(e=x()){return D(e,E)}(e),(t=>`macOS ${t} (${e})`),b)}catch(e){return w().warn("osNameMac(): unknown release",e),b()}}function F(e=(0,n.release)()){const t=e.startsWith("10.0.22")?"11":D(e,k);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=C,t.osNameWin=F,t.CPUs=(0,a.lazy)((()=>(0,h.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,a.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(F())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=x();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(_())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(M())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(T())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},45393:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetVersion=t.AssetFileVersion=void 0,t.AssetFileVersion=12,t.AssetVersion=4},12801:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const s=r(i(48161)),n=i(50989);t.PriorityClasses=(0,n.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:s.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:s.default.constants.priority.PRIORITY_NORMAL,BelowNormal:s.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:s.default.constants.priority.PRIORITY_LOW,Low:s.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeRandomUid=t.safeRandomChars=void 0;const r=i(55222),s=i(65713);t.safeRandomChars=function({radix:e=r.TokenRadix,length:t}){return(0,s.decuss)((()=>e.randomChars(t)))},t.safeRandomUid=function(e){return(0,s.decuss)((()=>(e?.radix??r.TokenRadix).randomUid(e?.chars??20,e?.splitEveryN??5,e?.sepChar??"-")))}},409:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),s=i(56409),n=i(31586),a=i(22911),o=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...r){f=!0,m=Date.now()+(0,n.max_)(t,i);const s=d=new a.Deferred(c);(0,n.gt0)(i)&&s.setTimeout(i);try{s.resolve(await e(...r))}catch(e){s.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,o.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return s.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,r.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new s.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),s=i(54993);function n(e){return e instanceof a?e.source:(0,s.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let s;for(;null!=(s=e.exec(t));)s.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(s,"index","groups"));return i},t.escapeRegExp=n,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(n(t))}const s=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(s,i)};class a{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=a;class o extends a{static from(...e){const t=l(e);return new o("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,o=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof a||t instanceof RegExp?(i+=t.source,r||(r=t.global),o||(o=t.ignoreCase),l||(l=t.multiline)):i+=n((0,s.toS)(t));return new RegExp(i,t??(r?"g":"")+(o?"i":"")+(l?"m":""))}t.RegExpOptional=o,t.concatRegexp=l},79089:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),v=i(34102),w=i(43334),b=i(24399),S=i(28874),P=(0,a.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>T.prior()?.clear()))));const _=(0,a.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",n.default.basename(S.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,o.compactBlanks)([n.default.basename(e),...t.map((e=>n.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let M=!0;const T=(0,a.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||T().has(e))return;T().add(e);const i=(0,p.priorityPosixToClass)(t)??S.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),M)try{return s.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;M=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await b.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const s=r(i(1708)),n=i(19851),a=i(40958),o=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===o.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===o.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===o.ServiceNames.sync}function p(){return(0,t.serviceName)()===o.ServiceNames.test}t.serviceName=(0,n.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,n.lazy)((()=>(0,a.compactBlanks)([t.serviceName.prior(),(0,l.toS)(s.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return o.ServiceNames.indexOf(e)??o.ServiceNames.length+1},t.MainServices=[o.ServiceNames.main,o.ServiceNames.desktop],t.DbServices=[o.ServiceNames.sync,o.ServiceNames.info,o.ServiceNames.web,o.ServiceNames.list,o.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[o.ServiceNames.sync,o.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===o.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===o.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,n.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function s(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=s,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=s(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=s(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),s=i(57150),n=i(7282),a=i(23560),o=i(17181);t.setServiceName=function(e){(0,a.isMainService)(e)&&(e=r.ServiceNames.main);const t=a.serviceName.prior();t!==e&&((0,n.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),a.serviceName.set(e),(0,o.setupLogger)(),(0,s.logStartup)())}},28850:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const o=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends o.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),s.set(this,void 0),n(this,r,e,"f")}_call(){return(0,l.time)(a(this,r,"f")+(null==a(this,s,"f")?"(local)":"(remote)"),null==a(this,s,"f")?this.impl():a(this,s,"f").call(this))}setShim(e){n(this,s,e,"f")}hasShim(){return null!=a(this,s,"f")}clearShim(){n(this,s,void 0,"f")}}r=new WeakMap,s=new WeakMap},12089:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,a){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=a,s.set(this,void 0),n.set(this,void 0),l(this,s,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",o).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",a).call(this,e),(()=>u(this,r,"m",o).call(this,e)))}setShim(e){l(this,n,e,"f")}hasShim(){return null!=u(this,n,"f")}clearShim(){l(this,n,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",a).call(this,e))}}s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},o=function(e){return(0,m.time)(u(this,s,"f")+(null==u(this,n,"f")?"(local)":"(remote)"),null==u(this,n,"f")?this.impl(e):u(this,n,"f").call(this,e))}},45255:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const n=i(76790),a=i(17586);class o{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return s(this,r,"f")[Symbol.iterator]()}get length(){return s(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=s(this,r,"f").length-1;for(;t<=i;){const n=t+Math.floor((i-t)/2),a=this.valueOf(s(this,r,"f")[n]);if(e===a)return{found:!0,index:n};e>a?t=n+1:i=n-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&s(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...s(this,r,"f")];const a=t=>t<0||t>s(this,r,"f").length-1?null:(i??this.diff)(s(this,r,"f")[t],e),o=this.findIndex(e);if(null==o)return;let l=o.index-1,u=a(l),c=o.index,d=a(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return s(this,r,"f").shift()}at(e){return(0,a.at)(s(this,r,"f"),e)}toA(){return[...s(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===s(this,r,"f").length-1){const e=[...s(this,r,"f")];return s(this,r,"f").length=0,e}return s(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return s(this,r,"f").splice(e,t)}retainLastN(e){return e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),s=i(82328),n=i(84542),a=i(95705),o=i(28874);t.consoleLog=function(e,...t){o.Settings.quiet.valueOrDefault||(0,s.stdoutEnded)()||console.log((0,n.crlf)(e),...t)},t.consoleError=function(e){o.Settings.quiet.valueOrDefault||(0,a.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=o.Settings.quiet.envValue;try{return o.Settings.quiet.envValue=!0,await e()}finally{o.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),s=i(95705);t.stdoutEnded=function(){return(0,s.streamEnded)(r.stdout)}},71567:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const s=r(i(1708)),n=i(22573),a=i(98553),o=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:s.default.stdout})}function f({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const s=(0,a.stringify)(e,void 0,(0,o.isInfoService)()||(0,o.isMainService)()?2:void 0);r.write(s+"\n"),(0,o.isWorkerService)()&&null!=i&&(s.includes(u.FailStr)||(0,c.isFatalError)(s)||(0,c.isHealthCheckError)(s)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||s.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:s.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,n.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const s=t.indexOf(i,r);return-1===s?0:1+e(t,i,s+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,n.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,o.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,h.toS)(e),s=(0,h.toS)(t);return s.length>0&&(0,c.equalsIgnoreCase)(r.slice(-s.length),s,i)?r.slice(0,-s.length):r},t.gist=function(e,t=80,i=80){const r=(0,h.toS)(e),s=r.length-(t+i);return s<=0?r:r.slice(0,t).trim()+" …(+"+s+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function b(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function S(e){return(0,d.toA)(e).sort(b)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,n.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=b,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=S,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,a.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=b(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,n.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),s=t.indexOf(r);if(s>=0)return{index:s,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function M(e){return _.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=M;const T=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,n.blank)(e)||(e=(0,h.toS)(e).trim(),null!=T.exec(M(e))&&(e=e.slice(1,-1).trim())),e};const E=/^['‘’].*['‘’]$/,k=/^["“”„«»〃].*["“”„«»〃]$/;function D(e,t){const i=x(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function x(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let s,n=0;for(;null!=(s=t.exec(e));)s.index===t.lastIndex?t.lastIndex++:(t.lastIndex=s[0].length+s.index,i.push(e.substring(n,s.index)),r.push(e.substring(s.index,t.lastIndex)),n=t.lastIndex);return n(0,o.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),E.test(e)||k.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),s=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,a.map)(i[e],(e=>t+=e))));return t},t.splitKeep=D,t.splitUp=x,t.sortNaturalBy=C,t.sortNatural=function(e){return(0,s.sortBy)(e,(e=>C(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=S((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,s.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,n.blank)(e)||(0,n.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,o.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const F=/#.*$/gm;t.stripComments=function(e){return e.replace(F,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,n.blank)(r))for(const e of r.split(t))(0,n.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,n.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),s=e.findIndex((e=>r.test(e))),a=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(s<0)return e;for(let t=s+1;te.trim()))))}},83556:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function s(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=s,t.asObjectKey=function(e){return s(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const s=r(i(77598)),n=i(73913),a=i(55222);function o(e,t=n.HashBits){return s.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=a.Radix58,r=224){return i.encodeBuffer(o(e,r)).substring(0,t)}t.stringShaToBuffer=o,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=a.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(31586),o=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,s="";for(let n=0;n=r&&(r=i.get(n,a),s=(0,l.substr)(e,n-r+1,r)));return s}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),s=t.normalize();return e!==r||t!==s?y(r,s):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function v(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===r?1:void 0),(()=>(0,n.blank)(e)!==(0,n.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(i),t=w(r);return 2*b(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function b(e,t){const i=(0,f.intersection)(e,t),s=[];return i.forEach((i=>{const n=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,a.times)(n,(()=>s.push(i)))})),s}function S(e,t,i){const s=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,s))-i((0,l.strslice)(t,s))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,s.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[i,r]=[e,t].map(P).map((e=>(0,n.blank)(e)?"":e));return S(i,r,(e=>(0,a.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(n.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=b,t.lnsDiff=_;const M=/[^\da-z]+/gi;function T(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(M,"").toLowerCase()));return S(i,r,(e=>c.RadixAlphaNum.decode(e)))}function E(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const s=(0,a.mapNumericOr)(e.charCodeAt(r),(e=>e),256),n=(0,a.mapNumericOr)(t.charCodeAt(r),(e=>e),256),o=(0,a.clamp)(-256,256,s-n);i=null==i?o:(i+o)/2}return i}t.radixDiff=T,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:_(e,t),radixDiff:T(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=E,t.paddedPositionalDiff=function(e,t,i=8){return E((0,o.leftPad)(e,i," "),(0,o.leftPad)(t,i," "))}},84885:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),s=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,s.sortedKeys)(e))}},75387:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",s.set(this,[]),n.set(this,new Map),a.set(this,void 0),o.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,a,"f")}set ttlMs(e){h(this,a,e,"f"),null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),h(this,o,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,n,"f").clear(),this}delete(e){return d(this,n,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,n,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,n,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,n,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const s=t();return null!=s&&this.set(e,s),s}lastSetOrGetTs(e){return d(this,n,"f").get(e)?.ts}set(e,t){return d(this,n,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,n,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,n,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,f.sortBy)(d(this,n,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,s,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,n,"f").delete(e);for(const i of d(this,s,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,n,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[a]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return o(this,r,"m",n).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>o(this,r,"m",n).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||o(this,r,"m",s).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)o(this,r,"m",s).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!o(this,r,"m",s).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield[t,t])}()}toA(){return o(this,r,"m",n).call(this),[...this.delegate.keys()]}[(r=new WeakSet,a=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,s=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},n=function(){for(const[e,t]of this.delegate)o(this,r,"m",s).call(this,e,t)}},84699:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},65211:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resetUid=t.sortByUid=t.tsFromUid=t.isUID=t.uidForTs=t.uid=t.uidSuffix=void 0;const r=i(19851),s=i(76790),n=i(22573),a=i(54993),o=i(7282),l=i(55222);let u=0;const c=l.GeoRadix;function d(e){return c.encode(e)+(0,t.uidSuffix)()}t.uidSuffix=(0,r.lazy)((()=>"-"+c.randomChars(7))),t.uid=function(){return u=Math.max(Date.now(),u+1),d(u)},t.uidForTs=d;const h=/^[\da-z]{9}-[\da-z]{7}$/i;function f(e){const t=(0,a.toS)(e).replace(/(?<=\S)-.*/,"");return(0,n.blank)(t)?void 0:c.decode(t)}t.isUID=function(e){return h.test((0,a.toS)(e))},t.tsFromUid=f,t.sortByUid=function(e){return(0,s.sortBy)(e,(e=>f(e.uid)))},t.resetUid=function(){if(!(0,o.isTest)())throw new Error("unsupported");t.uidSuffix.unset(),u=0}},94174:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,a.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,a.lazy)((()=>(0,o.uniq)([n.default.geteuid?.(),n.default.getuid?.(),s.default.userInfo().uid]))),t.userid=(0,a.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,a.lazy)((()=>(0,o.uniq)([n.default.getegid?.(),n.default.getgid?.(),s.default.userInfo().gid]))),t.groupid=(0,a.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,a.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,a.lazy)((()=>(0,l.toNotBlank)(s.default.userInfo()?.username))),t.userNameFromWhoami=(0,a.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,a.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,a.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,a.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.0-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=0,t.versionPrerelease=["prealpha"],t.release="2024.3.0-prealpha+20240308102353",t.gitSha="92cba1b21937cb9ca770f6a339e44b0fbee04bf9",t.gitDate=new Date(1709922233e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48299:function(e,t){"use strict";var i,r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.WeakCache=void 0;class o{constructor(){i.add(this),this[n]="WeakCache",r.set(this,new Map)}clear(){return a(this,r,"f").clear(),this}delete(e){return a(this,r,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of this.entries())e(i,t,this)}findEntry(e){for(const[t,i]of this.entries())if(e(i,t,this))return i}deleteValueIf(e){for(const[t,i]of this.entries())e(i,t,this)&&a(this,r,"f").delete(t)}get(e){const t=a(this,r,"f").get(e),i=t?.deref();return null==i&&null!=t&&a(this,r,"f").delete(e),i}getOrMaybeSet(e,t){const i=a(this,r,"f").get(e)?.deref();if(null!=i)return i;const s=t();return null!=s&&this.set(e,s),s}set(e,t){return a(this,r,"f").set(e,new WeakRef(t)),this}has(e){return null!=a(this,r,"f").get(e)?.deref()}get size(){return a(this,i,"m",s).call(this),a(this,r,"f").size}keys(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries())null==i.deref()?a(e,r,"f").delete(t):yield t}()}values(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield s}}()}entries(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield[t,s]}}()}[(r=new WeakMap,i=new WeakSet,n=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}}t.WeakCache=o,s=function(){for(const[e,t]of a(this,r,"f").entries())null==t.deref()&&a(this,r,"f").delete(e)}},48963:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),s=i(55835),n=i(31586),a=i(97790),o=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,n.toInt)(e)));if(!(0,s.allDefined)(i))return;const[a,o,u,c,d,h,f]=i,m=(0,n.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(a,o-1,u,c,d,h,f/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,a.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(n.toInt).filter((e=>(0,o.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},79184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aggregateAssetFiles=void 0;const r=i(59455),s=i(48884),n=i(22859),a=i(28874),o=i(79781),l=i(92434);t.aggregateAssetFiles=async function(e){const t=(0,r.toA)((0,l.sortAssetFiles)(e)??e);return(a.Settings.assetAggregation.valueOrDefault===n.AggregateTypes.union?s.clusterSome:s.clusterEvery)(t,o.isSimilarAssetFile)}},79781:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotSimilarAssetFile=t.isSimilarAssetFile=t.whyNotSameAsset=t.VideoImageMismatchMsg=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(50357),o=i(55835),l=i(31586),u=i(68708),c=i(12168),d=i(23467),h=i(73168),f=i(50213),m=i(86580),p=i(48368),g=i(80361),y=i(28874),v=i(28544),w=i(75767),b=i(16170),S=(0,r.lazy)((()=>(0,f.mkLogger)("sync-file.AssetFileComparator")));function P(e,t,i,r=((e,t)=>[e,t])){const s=e[i],o=t[i];if((0,n.blank)(s)||(0,n.blank)(o)||(0,a.eql)(s,o))return;const[l,u]=r(s,o);return(0,a.eql)(l,u)||(0,a.eql)(s,u)||(0,a.eql)(l,o)?void 0:`Different ${String(i)}: ${s} ≠ ${o}`}function _(e){return(0,n.mapNotBlank)(e,(e=>e.toLowerCase().trim().normalize()))}function M(e,t){return[_(e),_(t)]}function T(e,t,i){const r=(0,w.findInequalFields)(e[i],t[i]);return null==r?void 0:`Different ${i} (${r.aKey}:${r.aValue} ≠ ${r.aKey}:${r.aValue})`}function E(e,i){if(!(0,u.allKeysDefined)(e,"width","height","mimetype","sha"))return"af1 was missing required fields";if(!(0,u.allKeysDefined)(i,"width","height","mimetype","sha"))return"af2 was missing required fields";if((0,d.definedAndEql)(e.sha,i.sha))return void S().debug("matching SHA",{af1:e,af2:i});const r=(0,b.isVideoMimeType)(e.mimetype),n=(0,b.isVideoMimeType)(i.mimetype);if(r!==n)return S().tap({msg:"whyNotIsSimilar",result:t.VideoImageMismatchMsg,meta:{af1:e.uri,af2:i.uri,af1IsVideo:r,af2IsVideo:n}});const a=v.CapturedAt.fromAssetFile(e),f=v.CapturedAt.fromAssetFile(i);if(null==a)return"af1 missing capturedAt metadata";if(null==f)return"af2 missing capturedAt metadata";const _=a.isFuzzy||f.isFuzzy;if(_&&y.Settings.allowFuzzyDateImageHashMatches.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if((0,g.isSimilarImageHash)(t,r,{rotationsToCheck:(0,m.validRotations)(e,i)}))return void S().info("allowFuzzyDateImageHashMatches mode: image hashes match",{af1:e,af2:i})}if(!a.overlaps(f))return`captured-at ${a.toISOStringWithPrecision()} != ${f.toISOStringWithPrecision()}`;const E=P(e,i,"make",M)??P(e,i,"model",M);if(null!=E)return E;const k=(0,o.map)((0,h.geohashDistanceMeters)(e.geohash,i.geohash),(e=>(0,l.sigFigs)(e,2))),D={cameraId:T(e,i,"cameraId")??null,imageId:T(e,i,"imageId")??null,lensId:T(e,i,"lensId")??null,exposureSettings:(0,w.whyExposureSettingsNotSimilar)(e,i)??null,closeGeoHash:(0,l.gt)(k,y.Settings.gpsErrorMeters.valueOrDefault)?"geohashes are "+(0,c.fmt)(k)+"m different: too far apart":null};S().debug("whyNotSimilar()",{fields:D});const x=(0,s.compact)((0,u.values)(D));if((0,s.isNotEmpty)(x))return x.join(";");if(y.Settings.useImageHashes.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if(null!=t&&null!=r){const e=(0,g.compareImageHashes)(t,r,{capturedAtIsFuzzy:_});return!0===e?.isSimilar?void 0:e?.whyNotSimilar}}return(0,u.keys)(D).filter((e=>null==D[e])).length>=y.Settings.minMatchesWithoutImageHashes.valueOrDefault?void 0:"Insufficient metadata correlation"}t.VideoImageMismatchMsg="Videos ≠ images",t.whyNotSameAsset=function(e,t,i){{const i=E(e,t);if(null!=i)return i}if("intersection"===y.Settings.assetAggregation.valueOrDefault)for(const r of i)if(r.id!==t?.id){const t=E(e,r);if(null!=t)return t}},t.isSimilarAssetFile=function(e,t){return null==E(e,t)},t.whyNotSimilarAssetFile=E},13991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkSortableAssetFile_=t.mkAssetFile_=t.assetFileMetadata_=t.assetFileImageHashFields_=t.imageHashToAssetFileImageHashFields=t.assetFileStatFields_=t.assetFileUriFields_=void 0;const r=i(19851),s=i(55835),n=i(31586),a=i(59455),o=i(73168),l=i(50213),u=i(12089),c=i(76490),d=i(95696),h=i(48368),f=i(70417),m=i(28874),p=i(43207),g=i(47783),y=(0,r.lazy)((()=>(0,l.mkLogger)("asset-file.AssetFileFactory")));async function v(e){try{return{nativePath:e.nativePath,uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath}}catch(t){return y().throw("Failed to build URI for "+e,{error:t})}}async function w(e){const t=await e.stat_(),i=await e.sidecareStats();return{mtime:Math.floor((0,f.max)([t.mtimeMs,...(0,a.toA)(i).map((e=>e.mtimeMs))])),fileSize:t.size}}function b(e){return{...e,...c.DominantColor.toModeData(e.dominantColors)}}async function S(e){if(!m.Settings.useImageHashes.valueOrDefault)return;const t=await(0,h.imageHash_)(e.nativePath);return null==t?y().throw("Failed to extract image hash for "+e):b(t)}async function P(e){const[i,r,s,n]=await Promise.all([v(e),w(e),(0,t.assetFileMetadata_)(e),e.sha_()]);return{...i,...r,...s,sha:n}}t.assetFileUriFields_=v,t.assetFileStatFields_=w,t.imageHashToAssetFileImageHashFields=b,t.assetFileImageHashFields_=S,t.assetFileMetadata_=(0,u.shim1)({name:"asset-file.assetFileMetadata",impl:async function(e){try{const t=d.PosixFile.for(e),i=await(0,g.readTags)(t);if(null==i)throw new Error("Failed to read tags");if(null==i.capturedAt)throw new Error("Failed to read capturedAt");const r=i.capturedAt.toAssetFileFields();return null==r?y().throw("Failed to render assetFileFields from capturedAt",{capturedAt:i.capturedAt}):{...r,...i.exposureSettings,...i.dimensions,mimetype:i.mimetype,rotation:i.rotation,make:i.Make,model:i.Model,rating:i.rating,cameraId:i.cameraId,imageId:i.imageId,lensId:i.lensId,geohash:(0,o.geohashNumericShort)(i.GPSLatitude,i.GPSLongitude),durationMs:(0,p.extractDurationMs)(i),fps:(0,s.map)((0,n.toFloat)(i.VideoFrameRate),Math.floor)}}catch(t){return y().throw("_assetFileMetadata_() failed",{nativePath:e,error:t})}}}),t.mkAssetFile_=async function(e){const[t,i]=await Promise.all([P(e),S(e)]);return{...t,...i}},t.mkSortableAssetFile_=P},92434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestExistingAssetFile=t.assetFileSortCriteria=t.assetFileSortFields=t.assetFileSortCriteriaPojo=t.sortAssetFiles=t.mtime2sort=t.sortScale=t.dim2sort=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(23838),u=i(31586),c=i(68708),d=i(34666),h=i(50989),f=i(89937),m=i(50213),p=i(4001),g=i(29882),y=i(28874),v=i(14036),w=i(45200),b=i(34238),S=(0,r.lazy)((()=>(0,m.mkLogger)("img.AssetFileSorter"))),P=(0,h.strEnum)("file",f.PS_NETWORK_FILESYSTEM_SCHEME,f.PS_LOCAL_FILE_SCHEME,f.PS_LIBRARY_SCHEME);function _(e){return(0,u.map2Numeric)(e?.width,e?.height,((e,t)=>M(e*t)))}function M(e){if((0,u.gt0)(e))return Math.round(Math.pow(e,y.Settings.variantSortCriteriaPower.valueOrDefault))}function T(e){return Math.round(e/(5*o.minuteMs))}t.dim2sort=_,t.sortScale=M,t.mtime2sort=T;const E=["make","model","rating","cameraId","imageId","lensId","geohash"];function k(e){for(const t of(0,l.groupBy)(e,(e=>e.sha)).values())if(t.length>1){const e=Math.max(...(0,s.compact)(t.map((e=>e.mtime))));for(const i of t)i.mtime=e}return(0,n.sortBy)(e,C).reverse()}function D(e){const t=b.URI.parse(e.uri);if((0,a.blank)(t?.scheme)||(0,a.blank)(t?.path))return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI)",{uri_scheme:t?.scheme,uri_path:t?.path,af:e,parsedURI:t});const i=_(e);if(null==i)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid resolution)",{resolution:i,af:e,parsedURI:t});const r=P.indexOf(t.scheme);if(null==r)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI scheme)",{uri_scheme:t.scheme,af:e,parsedURI:t});const s=e.mtime??0,n=(0,g.parsePosixPath)(t.path),l=[];for(const t of E)(0,a.blank)(e[t])||l.push(t);const u={resolution:i,schemeIdx:r,capturedAtPrecision:-(e.capturedAtPrecisionMs??o.weekMs),metadataCoverage:l.length,metadataFields:l.join(","),isBrowserSupported:(0,v.isSupportedByCurrentBrowserExt)(n.ext),mtime:T(s),isEditOrUpdate:/edit|update/i.test(n.base),isCover:/cover/i.test(n.base),count:Math.abs((0,p.copySuffixCountFromName)(n.name)??0),basename:d.CmpReverseFlag+n.base,parentBasename:d.CmpReverseFlag+(0,g.parentBasename)(e.nativePath??t.path),uri:d.CmpReverseFlag+e.uri};return S().tap({msg:"assetFileSortCriteriaPojo()",result:(0,c.toReqValued)(u)})}function x(){return(0,s.uniq)([...y.Settings.variantSortCriteria.values,"uri"])}function C(e){const t=D(e);if(null==t)return;const i=[];for(const e of x())i.push(t[e]);return i}t.sortAssetFiles=k,t.assetFileSortCriteriaPojo=D,t.assetFileSortFields=x,t.assetFileSortCriteria=C,t.bestExistingAssetFile=async function(e){for(const t of k(e))if(await(0,w.uriExists)(t.uri,t.nativePath))return S().tap({msg:"bestExistingAssetFile()",result:t,meta:{files:e.map((e=>e.uri))}});return S().tap({msg:"bestExistingAssetFile(): no existing uris",result:void 0,meta:{files:e.map((e=>e.uri))}})}},54296:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetFileNativePath=void 0;const r=i(45200);t.getAssetFileNativePath=async function(e){return e.nativePath??(e.nativePath=await(0,r.uri2nativePath)(e.uri,e.mountpoint))}},73568:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const o=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),s.set(this,(0,o.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,n(this,s,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return n(this,s,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,n(this,s,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),a(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=n(this,r,"f")&&clearTimeout(n(this,r,"f")),a(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,s=new WeakMap},69591:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const s=r(i(87997)),n=i(31586);t.debounce=function(e,t){let i,r=[];const a=(0,n.gt0)(t)?(...n)=>{r=n,null!=i&&s.default.clearTimeout(i),i=s.default.setTimeout((()=>{e(...r)}),t)}:e;return a.reset=()=>{null!=i&&s.default.clearTimeout(i),i=void 0},a.force=()=>{a.reset(),e()},a.setTimeoutMs=e=>{a.reset(),t=e},a.timeoutMs=()=>t,a}},22911:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(i(87997)),w=y(i(57975)),b=i(45599),S=i(26905),P=i(55835),_=i(31586),M=i(68708),T=i(20214),E=i(57153),k=i(85556),D=i(50213),x=i(70025),C=i(95937),F="TIMEOUT",A=(0,b.defer)((()=>(0,D.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,_.gt0)(t)?new s(F).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const s=i[r];if(s.isSettled){if(s.name===F)return void A().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield s.value}}if(i.every((e=>e.name===F)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new s(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),a.set(this,void 0),o.set(this,E.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=s,s,(y=p(i,s,"f",n),m=y++,y),"f",n),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,D.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof s&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,o,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,M.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,a,"f")}get elapsedMs(){return(p(this,a,"f")??Date.now())-this.startedAt}get[(a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,T.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,T.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new k.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,C.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,o,"f")===E.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,o,"f")!==E.PromiseStates.pending}get isResolved(){return p(this,o,"f")===E.PromiseStates.resolved}get isRejected(){return p(this,o,"f")===E.PromiseStates.rejected}get settledMs(){return null==p(this,a,"f")?void 0:p(this,a,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,o,E.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,x.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,S.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,o,E.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,s=I,m=function(e){if(p(this,o,"f")===E.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,a,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},n={value:0}},27395:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(23838),o=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new a.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*n.minuteMs);const y=5*n.secondMs;async function v(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,o.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,s.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,s.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",a).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,s.set(this,void 0),n.set(this,void 0),o.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,s,"f")}hasTimeout(){return null!=u(this,n,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",a).call(this);const h=()=>{u(this,r,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,s,(0,d.setInterval)(u(this,o,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,n,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,o,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref()):h(),!0}}t.EndableInterval=v,s=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(){(0,h.map)(u(this,s,"f"),d.clearInterval),c(this,s,void 0,"f"),(0,h.map)(u(this,n,"f"),d.clearTimeout),c(this,n,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const o=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,a){this.endTimeoutMs=a,r.set(this,void 0),this.onEnds=[],s.set(this,(0,o.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),n(this,s,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){a(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return n(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return n(this,s,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,s=new WeakMap},99331:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let s=!1;t.ending=function(){return s},t.setEnding=function(e){s=(0,r.isTest)()?e:e||s}},45608:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const s=r(i(1708)),n=i(22573),a=i(45599),o=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,a.defer)((()=>(0,l.mkLogger)((0,o.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,a.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,n.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,f.endEndables)(),s.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,a.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])s.default[e].on(t,(i=>{v({reason:`${e}:${t}`,status:0,error:i})}))}))},39250:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LastOneInWins=void 0;const n=i(23838),a=i(54993),o=i(15674),l=i(73568),u=i(76740),c=i(99331),d=i(42638);t.LastOneInWins=class{constructor(e,t=o.maxCpus){this.name=e,this.maxConcurrency=t,r.set(this,new n.MultiMap),this.p=new d.Promises(e,t)}vacuum(){return s(this,r,"f").filterInPlace(((e,t)=>t.isPending&&!0!==t.payload?.aborted)),s(this,r,"f").valueCount()}enqueue({key:e,abortable:t,fn:i}){for(const t of s(this,r,"f").get(e)??[])t.payload?.abort("aborted by new work");if(this.vacuum(),(0,c.ending)())throw new l.AbortError("ending");const n=t??new u.Abortable,o=this.p.serial((0,a.toS)(e),(()=>i(n)),n);return s(this,r,"f").add(e,o),o}},r=new WeakMap},60172:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,r)=>{t=e,i=r})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,s.set(this,void 0),n.set(this,0),a.set(this,void 0),o.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,a,"f")}unset(){d(this,n,0,"f"),d(this,s,void 0,"f"),d(this,a,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,o,"f").push(e)}prior(){return this.isStale()?void 0:c(this,a,"f")}lastValue(){return c(this,a,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,n,"f")}isStale(){return null==c(this,s,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,s,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,s,"f")?void 0:Date.now()-c(this,s,"f")}elapsedMs(){return c(this,a,"f")?.settledMs??c(this,a,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,o,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,o,"f"))e.onError(t)}finally{d(this,n,(i=c(this,n,"f"),++i),"f")}},u=function(e){d(this,s,Date.now(),"f");const t=c(this,a,"f");return d(this,a,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,a,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,a,"f")),c(this,a,"f")}},1728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),s=i(80049);t.memoizeAsync=function(e,t){let i=0;const n=new s.FifoCacheAsync(t),a=t=>(i++,n.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return a.clear=e=>{if(null==e)return n.clear();{const t=(0,r.stringify)(e);return n.deleteIf((e=>t===e))}},a.size=()=>n.size,a.callCount=()=>i,a}},22781:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),s.set(this,!1),n.set(this,!1)}_call(){return a(this,s,"f")?(o(this,n,!0,"f"),!0===this.undefinedIfBusy?void 0:a(this,r,"f")):(o(this,s,!0,"f"),o(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{o(this,s,!1,"f"),!0===this.runLaterIfBusy&&a(this,n,"f")&&(o(this,n,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return a(this,s,"f")}prior(){return a(this,r,"f")}async force(){return await a(this,r,"f"),this._call()}}r=new WeakMap,s=new WeakMap,n=new WeakMap},37461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),s=i(76790),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),v=i(15674),w=i(42638);var b=i(20214);async function S(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:i,timeoutMs:s}){const n=[];for(const a of(0,r.compact)(await t))try{const e=await((0,l.gt0)(s)?(0,c.thenOrTimeoutError)(i(a),s):i(a));null!=e&&n.push([e,a])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:a,error:t})}return n}async function M({arr:e,f:t,name:i,maxConcurrent:s,timeoutMs:n,promises:a}){if(null==e)return[];const o=(0,r.compact)(await e);if((0,r.isEmpty)(o))return[];if((s=Math.round(s??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:i,timeoutMs:n});const u=a??(o.length<=s?w.PermissivePromises:new w.Promises(i,(()=>s))),d=(0,l.gt0)(n)?e=>(0,c.thenOrTimeoutError)(t(e),n):t,h=await u.enqueueAll(i,o.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return b.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=S,t.thenCollectBatched=async function(e,t,i){const r=[];for(const s of(0,p.batches)((0,f.toA)(await e),t)){const e=await S(s);r.push(...await S(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,o.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=M,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n}){return(await M({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:s,timeoutMs:n}){return(await M({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:s,timeoutMs:n})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await M({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,n.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,n.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*a.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,s=null;try{r=await((0,h.isFunction)(e)?e():e)}catch(e){s=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(s??r)}catch{}if(null!=s)throw s;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,n.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const s=await t;return null!=s?i(r,s):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const s=await t(r);return null==s?i():s},t.thenMap2Or=async function(e,t,i,r){const s=await e;if(null==s)return r();const n=await t;if(null==n)return r();const a=await i(s,n);return null==a?r():a},t.thenAnd=async function(e,t){return null!=e&&(0,n.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await M({name:e,arr:t,f:i});return(0,s.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),v=i(25764),w=i(38836),b=i(73614);function S(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),s=(0,l.clamp)(10*a.secondMs,a.minuteMs,Math.round(this.times.get(e)?.p98??0)),n=(0,b.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),s);try{const s=await(0,c.tot)(t),n=Date.now()-r;return i?.(s,n),this.push(e,n),s}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(n)}}get entriesBySumDesc(){return(0,n.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(S(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,o.getOrSet)(this.times,S(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(S(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/a.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function _(e,t,i){return P.instance().time(e,t,i)}function M(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,s.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const i=Date.now(),r=t();return M(e,Date.now()-i),r},t.pushTime=M,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>_(e,t)),i)}},42638:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),v=i(54993),w=i(89788),b=i(82647),S=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){r.add(this),this.name=e,this.ee=new f.default.EventEmitter,s.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new b.Average,n.set(this,0),a.set(this,[]),o.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,s,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,S.maxCpus)(),d(this,s,"f")?.call(this)??(0,S.maxCpus)()))}end(){return d(this,o,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,a,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,n,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,a,"f").map((e=>e.name)),pendingNames:d(this,o,"f").map((e=>e.d.name)),totalWorkCount:d(this,n,"f")}}enqueue({name:e,l:t,payload:i,serialId:s}){const n=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:s});return this.laterPop(),n}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,a,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,o,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,o,"f").length,e),i=this.runningSerialIds,s=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,a,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,o,"f").length}hasPending(){return d(this,o,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,o,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,o,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const s=new P.Deferred(e,{payload:i,serialId:r});return d(this,o,"f").push({d:s,l:t}),s},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,n,(t=d(this,n,"f"),++t),"f"),(0,m.remove)(d(this,a,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,a,"f").push(e),e},t.maybeRun=function(e,t){const i=new _(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new _(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},59189:function(e,t){"use strict";var i,r=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},s=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SerialLaterQueue=void 0,t.SerialLaterQueue=class{constructor(){i.set(this,Promise.resolve())}enqueue(e){return s(this,i,r(this,i,"f").catch().then(e),"f")}},i=new WeakMap},4867:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),s=i(34546),n=i(41400),a=i(31586),o=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let o=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>o=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>{if(o)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(o)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>l=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>o.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),s=i(42659),n=i(41400),a=i(32639),o=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,o.clamp)(10*m,l.ShortCommandTimeoutMs,(t??s.minuteMs)/5);await(0,n.delay)(r,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const s=r(i(1708)),n=i(45599),a=i(41400),o=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),v=i(50213),w=i(7282),b=i(88158),S=i(45969),P=i(43334),_=i(28874),M=i(3790);function T(e){return E().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const E=(0,n.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,b.sortedKeys)((0,l.filter)((0,d.env)(),(e=>T(e))))},(0,a.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const k=["HOME","LANG","USER"],D=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],x=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?k:D),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function C(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,S.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,_.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,o.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(s.default.env,(e=>T(e)||!(0,M.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=C,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:A({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let F=!1;function A({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const s=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...x(),...i?(0,g.childProcLocale)():{},...C(r),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(s);if((0,y.isLogged)("debug")&&!F){F=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(s).map((([e,t])=>[e,(0,M.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>T(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return s}t.childEnv=A},84777:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const s=r(i(31421)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),v=i(79089),w=i(45255),b=i(22911),S=i(4867),P=i(73614),_=i(70025),M=i(57159),T=i(36868),E=i(66184),k=i(45643),D=i(95402),x=i(9727),C=(0,a.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function F(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function A(e,t=30*u.secondMs){if(null==e)return!1;C().debug("endProcess()",F(e));const i=e.pid;if(null==i||i<=0)return C().warn("endProcess(): asked to end invalid pid",F(e)),!1;if(i===n.default.pid)return C().warn("endProcess(): asked to end MY pid",F(e)),!1;if(i===n.default.ppid)return C().warn("endProcess(): asked to end my parent pid",F(e)),!1;(0,T.closeStreams)(e);{const t=e.kill();C().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,D.killPid)(i).catch((e=>{C().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,k.waitForPidExit)(i,t))return C().debug("endProcess(): exitted",F(e)),!0;{D.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");C().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,D.killPid)(i,!0).catch((e=>{C().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,k.waitForPidExit)(i,5e3)}function I(e,i,r,s=0){const a=new Date,o=[];return(0,v.niceable)(i,r)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(s,u.secondMs)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&A(e)}),s-250)),o.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,D.addPid)({pid:e.pid,cmd:i,timeoutMs:s,ppid:n.default.pid},a)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>o.forEach(clearTimeout))),e}function O(e,t,i,r){const n=(0,x.spawnOptions)(r);return(0,E.isLogged)("trace",C().context)?C().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:n}):C().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(s.default.execFile(e,t,n),e,t,i)}async function L(e,t,i){const r=i.quiet??!1,s=i.ignoreStderr??!1,n=i.ignoreExitCode??!1,a=O(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{a.disconnect?.()}catch{}return{result:"",pid:a.pid}}const u=a.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new b.Deferred(f);a.on("error",(e=>g.push(e))),a.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),a.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,T.endStream)(a.stdin);const v=new d.Latch;null==a.stdout?v.resolve():(a.stdout.on("error",(e=>g.push(e))),a.stdout.on("data",(e=>m.push(e))),a.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==a.stderr||s?P.resolve():(a.stderr?.on("error",(e=>g.push(e))),a.stderr?.on("data",(e=>p.push(e))),a.stderr?.on("end",(()=>P.resolve()))),C().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,S.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),C().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,S.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt}),await(0,S.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt});const E=p.join("");(0,l.notBlank)(E)&&g.push(new Error(E)),!r&&(0,o.isNotEmpty)(g)&&C().warn(f+" resulted in errors:",g);const k=i.isIgnorableError??_.isIgnorableError,D=g.filter((e=>!0!==k(e)));if(D.length>0)throw 1===D.length?D[0]:new M.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:D});if(!n&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:E}}catch(e){throw C().error("stdoutResult_() failed",e),await(0,D.killPid)(a.pid,!0),e}}t.endProcess=A,t.ReniceAfterMs=(0,a.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,a.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const n=(0,x.spawnOptions)(r);return C().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(s.default.spawn(e,t,n),e,t,i)},t.execFile=O,t.stdoutResult_=L,t.stdout_=async function(e,t,i){const r=await L(e,t,i);return C().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},3790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),s=i(41400),n=i(19851),a=i(28874);(0,s.later)((()=>a.Settings.sensitiveEnvRegExp.watchLater((()=>o.unset()))));const o=(0,n.lazy)((()=>{try{return new RegExp(a.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${a.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(a.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&o().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||a.Settings.license.includesEnvKey(e)}},34330:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(54993),w=i(27395),b=i(25764),S=i(99331),P=i(42638),_=i(38835),M=i(8769),T=i(57159),E=i(66003),k=i(50213),D=i(45643),x=i(28874),C=i(84777);t.mkBasicWatchedChild=function(e){return new F({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,C.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class F{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,k.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),s.set(this,!1),this.onError=(e,t,i)=>{const n=new T.WrappedError(e,{cause:t}),a=!1!==n.ignorable;this.logger().log(a?"warn":"error","onError()",n),u(this,s,"f")||a||(this.lastError=n,(0,M.onError)(n),!0!==n.fatal?(i??this.opts.onError(e,n))&&(this.logger().warn("onError requested restart",{src:e,error:n}),u(this,r,"m",o).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:x.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:b.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,w.addEndable)(this.opts.endableRank,this),u(this,r,"m",o).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,s,"f")}async end(){return c(this,s,!0,"f"),u(this,r,"m",n).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",n).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,s,"f")}),!u(this,s,"f")&&!(0,S.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",n).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=F,s=new WeakMap,r=new WeakSet,n=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,s,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",a).call(this,e)},a=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,D.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,C.endProcess)(e,this.endTimeoutMs)},o=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",n).call(this),!this._stopped&&!u(this,s,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,M.onError)("Can't restart "+this.name+", failure rate is too high."+_.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,s,"f")}),this._stopped||u(this,s,"f")||(0,S.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,E.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,v.toS)(e).includes("Error: Cannot find module")&&(0,M.onError)("Failed to start "+this.name+_.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,s,"f")}),(0,S.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",o).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const a=n(i(53916)),o=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,o.toNativePath_)(e);const i=f.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),s=i.sibling(r);if(s.isSelfOrDescendantOf((0,l.examples)()))return a.join("$examples",s.posixPathFrom((0,l.examples)()));const n=(0,d.originalsDir)();if(s.isSelfOrDescendantOf(n))return a.join("$library",s.posixPathFrom(n));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?a.join("$library",s.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const n=i(6858),a=i(1708),o=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),h=i(43334),f=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return s(this,r,"f").push(...e),this}async parse(e=a.argv,t){let i=(0,m.addHelpFooter)(new n.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of s(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":o.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,a.exit)(0)})),i.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=i.opts();for(const e of s(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),s=i(31586),n=i(51926),a=i(17344),o=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,s.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,n.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,a.EditionName)()+" v"+o.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const r=i(38639),s=i(17181),n=i(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,r.mapBoolean)(e.color,(e=>{n.Settings.logColor.envValue=e,(0,s.setupLogFormatter)()}))}}},83210:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDaemon=void 0;const s=r(i(1708)),n=i(22573),a=i(38639);t.isDaemon=function(e){return(0,a.isTrue)(s.default.env.__is_daemon)||(0,a.isTrue)(e?.daemon)||!(0,n.blank)(e?.pidfile)}},53978:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimingArg=void 0;const r=i(28874),s=i(38639);t.TimingArg={beforeParse:e=>e.option("--timing","On exit, emit timing information to stdout."),afterParse:async e=>{(0,s.isTrue)(e.timing)&&(r.Settings.emitTimingsOnExit.value=!0)}}},94361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),s=i(40958),n=i(55835),a=i(31586),o=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,a.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,s.compactBlanks)([c("user id","PUID",(0,o.userids)()),c("group id","PGID",(0,o.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,n.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},43380:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WriteSettingsArg=void 0;const r=i(28874),s=i(2858),n=i(22573),a=i(38639),o=i(46292);t.WriteSettingsArg={beforeParse:e=>e.option("--write-settings","Write (or re-write, if they exist) system and library settings.toml files. See https://phstr.com/settings"),afterParse:async e=>{if((0,a.isTrue)(e.writeSettings)){const e=await(0,s.writeSystemSettings_)();if(null==e?console.info("--write-settings: Failed write system settings: no system configuration directory was found.",{checkedDirectories:(0,o.osConfigDirs)()}):console.info(`--write-settings: Wrote system settings to ${e}`),(0,n.blank)(r.Settings.libraryDir.valueOrDefault))console.error("--write-settings: Failed to write library settings: no PS_LIBRARY_DIR is set.");else{const e=await(0,s.writeLibrarySettings_)();console.info(`--write-settings: Wrote library settings to ${e}`)}}}}},54772:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestLabhashName=t.bestLabName=t.bestRgbName=t.colorToTuple=t.bestRgbTripletName=t.ColorNames=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(31586),o=i(48884),l=i(50213),u=i(81168),c=i(85810),d=i(42079),h=i(91482),f=i(3048),m=i(85409),p=i(16050),g=i(42022),y=i(85042),v=(0,r.lazy)((()=>(0,l.mkLogger)("color.ColorNames")));function w(e){const t=(0,y.normalizeRgbHex)(e.rgb);if(null==t)return void v().warn(`skipping invalid entry (bad rgb): ${e.rgb}`,e);const i=(0,c.rgbhex2Lab)(t);if(null==i)return void v().warn(`skipping invalid entry (failed to convert to L*a*b): ${t}`,e);const r=(0,c.toLabhash)(i,g.ModeBits);return{...e,rgb:t,lab:i,labhash:r,closeLabhashes:[r],closeRgb:[t],name:(0,u.capitalize)(e.name)}}function b(e,i){return null==e?void 0:(0,o.leastBy)(i??(0,t.ColorNames)(),(t=>(0,f.ciede2000_delta_e)(t.lab,e)))}t.ColorNames=(0,r.lazy)((()=>(0,s.compact)([...d.CrayonColors,...d.CrayonSupplements,...h.DarkWikipediaColors,...p.LightWikipediaColors,...m.Greys].map(w)))),t.bestRgbTripletName=function(e,i=(0,t.ColorNames)()){return b((0,c.rgb2lab)(e),i)},t.colorToTuple=w,t.bestRgbName=function(e){return P((0,c.rgbhex2Labhash)(e))},t.bestLabName=b;const S=new Map;function P(e){return(0,a.gte0)(e)?(0,n.getOrSet)(S,e,(()=>{const i=(0,t.ColorNames)().find((t=>t.labhash===e));if(null!=i)return i;const r=(0,c.unlabhash)(e),n=b(r);return null!=r&&null!=n&&((0,s.pushUniq)(n.closeLabhashes,e),(0,s.pushUniq)(n.closeRgb,(0,c.lab2rgbhex)(r))),n})):void 0}t.bestLabhashName=P},85810:(e,t,i)=>{"use strict";e=i.nmd(e),Object.defineProperty(t,"__esModule",{value:!0}),t.hsv2rgb=t.hsl2hsv=t.hsv2hsl=t.hsl2rgb=t.rgb2hsl=t.rgbhex2hsl=t.rgb2hsv=t.closestLab=t.maxLabhash=t.minLabhash=t.unlabhash=t.toLabhash=t.LabBitZip=t.xyz2rgb=t.lab2xyz=t.xyz2lab=t.rgb2xyz=t.clampLab=t.lab2rgb=t.rgb2lab=t.rgb2labArray=t.rgb2labTriplets=t.lab2rgbhex=t.rgbhex2Labhash=t.rgbhex2Lab=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(55835),o=i(31586),l=i(48884),u=i(20014),c=i(75503),d=i(3048),h=i(42022),f=i(85042),m=[[.4124564,.3575761,.1804375],[.2126729,.7151522,.072175],[.0193339,.119192,.9503041]],p=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]];function g(e){return _(w(e))}function y(e){return(0,f.clampRGB)(T(M(e)))}function v(e){return(0,t.LabBitZip)().clampValue(e)}function w(e){const t=(0,f.clampRGB)(e).map((e=>e/255)).map((e=>e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92));return(0,c.matXvec)(m,t)}t.rgbhex2Lab=function(e){return(0,a.map)((0,f.rgbhex2triplet)(e),g)},t.rgbhex2Labhash=function(e,t=h.ModeBits){return(0,a.map)((0,f.rgbhex2triplet)(e),(e=>E(g(e),t)))},t.lab2rgbhex=function(e){return(0,f.rgbTriplet2hex)(y(e))},t.rgb2labTriplets=function(e){return(0,s.stepRange)(0,e.length,3).map((t=>g([e[t],e[t+1],e[t+2]])))},t.rgb2labArray=function(e){const t=[],i=[],r=[];for(let s=0;se>S?Math.pow(e,1/3):(P*e+16)/116));return v([116*i-16,500*(t-i),200*(i-r)])}function M(e){const[t,i,r]=v(e),s=(t+16)/116,n=i/500+s,a=s-r/200,o=n*n*n,l=a*a*a,u=o>S?o:(116*n-16)/P,c=t>8?Math.pow(s,3):t/P,d=l>S?l:(116*a-16)/P;return[u*b.X,c*b.Y,d*b.Z]}function T(e){return(0,c.matXvec)(p,e).map((e=>{const t=e<0?-1:1,i=e*t;return(0,o.round)(255*t*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055))}))}function E(e,i=h.ModeBits){return(0,t.LabBitZip)().zip(e,i)}t.xyz2lab=_,t.lab2xyz=M,t.xyz2rgb=T,t.LabBitZip=(0,r.lazy)((()=>new u.BitZip([{min:0,max:100},{min:-79,max:90},{min:-102,max:89}]))),t.toLabhash=E;const k=new Map;function D(e,i=h.ModeBits){return(0,t.LabBitZip)().unzip(e,i)}function x(e){const[t,i,r]=(0,f.clampRGB)(e),s=Math.max(t,i,r),n=s-Math.min(t,i,r),a=n?s===t?(i-r)/n:s===i?2+(r-t)/n:4+(t-i)/n:0;return[60*(a<0?a+6:a),s?n/s*100:0,s/255*100]}function C(e){return F(x(e))}function F(e){const[t,i,r]=e,s=(200-i)*r/100;return[t,s>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,s/2]}function A(e){const[t,i,r]=e,s=i*(r<50?r:100-r)/100;return[t,s>0?2*s/(r+s)*100:0,r+s]}function I(e){const t=e[0]/360*6,i=e[1]/100,r=e[2]/100,s=Math.floor(t),n=r*(1-i),a=r*(1-(t-s)*i),o=r*(1-(1-t+s)*i),l=s%6;return(0,f.clampRGB)([255*[r,a,n,n,o,r][l],255*[o,r,r,a,n,n][l],255*[n,n,o,r,r,a][l]])}t.unlabhash=function(e,t=h.ModeBits){return t===h.ModeBits?(0,n.getOrSet)(k,e,(()=>D(e,t))):D(e,t)},t.minLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMin(h.ModeBits))),t.maxLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMax(h.ModeBits))),t.closestLab=function(e,t){return(0,l.leastBy)(e,(e=>(0,d.ciede2000_delta_e)(e,t)))},t.rgb2hsv=x,t.rgbhex2hsl=function(e){return C((0,f.rgbhex2triplet)(e))},t.rgb2hsl=C,t.hsl2rgb=function(e){return I(A(e))},t.hsv2hsl=F,t.hsl2hsv=A,t.hsv2rgb=I,i.c[i.s]===e&&console.log(E([0,0,0]))},42079:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CrayonSupplements=t.CrayonColors=void 0,t.CrayonColors=[{name:"Aquamarine",rgb:"#95E0E8"},{name:"Asparagus",rgb:"#7BA05B"},{name:"Blue-green",rgb:"#0095B7"},{name:"Royal blue",rgb:"#273BE2"},{name:"Blush",rgb:"#DB5079"},{name:"Brilliant rose",rgb:"#E667CE"},{name:"Brown",rgb:"#AF593E"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Burnt umber",rgb:"#805533"},{name:"Cadet blue",rgb:"#A9B2C3"},{name:"Canary",rgb:"#FFFF99"},{name:"Carmine",rgb:"#E62E6B"},{name:"Carnation pink",rgb:"#FFA6C9"},{name:"Celestial blue",rgb:"#7070CC"},{name:"Cerise",rgb:"#DA3287"},{name:"Cerulean blue",rgb:"#339ACC"},{name:"Chestnut",rgb:"#B94E48"},{name:"Cobalt blue",rgb:"#8C90C8"},{name:"Copper",rgb:"#DA8A67"},{name:"Cornflower",rgb:"#93CCEA"},{name:"Cotton candy",rgb:"#FFB7D5"},{name:"Denim",rgb:"#1560BD"},{name:"Eggplant",rgb:"#614051"},{name:"Fern",rgb:"#63B76C"},{name:"Fuchsia",rgb:"#C154C1"},{name:"Russet",rgb:"#87421F"},{name:"Green",rgb:"#01A638"},{name:"Green-yellow",rgb:"#F1E788"},{name:"Indigo",rgb:"#4F69C6"},{name:"Jungle green",rgb:"#29AB87"},{name:"Magenta",rgb:"#F653A6"},{name:"Maize",rgb:"#F2C649"},{name:"Maroon",rgb:"#C32148"},{name:"Medium chrome green",rgb:"#6CA67C"},{name:"Medium violet",rgb:"#8F47B3"},{name:"Melon",rgb:"#FEBAAD"},{name:"Middle blue-green",rgb:"#8DD9CC"},{name:"Middle blue-purple",rgb:"#8B72BE"},{name:"Green-yellow",rgb:"#ACBF60"},{name:"Middle purple",rgb:"#D982B5"},{name:"Middle yellow-red",rgb:"#ECAC76"},{name:"Midnight blue",rgb:"#003366"},{name:"Mulberry",rgb:"#C8509B"},{name:"Navy blue",rgb:"#0066CC"},{name:"Olive green",rgb:"#B5B35C"},{name:"Orange",rgb:"#FF8833"},{name:"Orchid",rgb:"#E29CD2"},{name:"Peach",rgb:"#FFCBA4"},{name:"Periwinkle",rgb:"#C3CDE6"},{name:"Pine green",rgb:"#01796F"},{name:"Pink flamingo",rgb:"#FC74FD"},{name:"Plum",rgb:"#8E3179"},{name:"Raw umber",rgb:"#665233"},{name:"Red-orange",rgb:"#FF681F"},{name:"Red",rgb:"#ED0A3F"},{name:"Salmon",rgb:"#FF91A4"},{name:"Vivid scarlet",rgb:"#FD0E35"},{name:"Sea green",rgb:"#93DFB8"},{name:"Sepia",rgb:"#9E5B40"},{name:"Shamrock",rgb:"#33CC99"},{name:"Sky blue",rgb:"#76D7EA"},{name:"Spring green",rgb:"#ECEBBD"},{name:"Sunset orange",rgb:"#FE4C40"},{name:"Tan",rgb:"#FA9D5A"},{name:"Teal blue",rgb:"#008080"},{name:"Thistle",rgb:"#D8BFD8"},{name:"Vivid tangerine",rgb:"#ED3C10"},{name:"Vivid violet",rgb:"#a625c3"},{name:"Wisteria",rgb:"#C9A0DC"},{name:"Yellow-green",rgb:"#C5E17A"},{name:"Yellow-orange",rgb:"#FFAE42"},{name:"Yellow",rgb:"#FBE870"}],t.CrayonSupplements=[{name:"Artichoke",rgb:"#8F9779"},{name:"Aubergine",rgb:"#48213A"},{name:"Brandy rose",rgb:"#B1847F"},{name:"Burgundy",rgb:"#800020"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Crimson red",rgb:"#990000"},{name:"Dark brown",rgb:"#664228"},{name:"Dark coral",rgb:"#CD5B45"},{name:"Dark green",rgb:"#006400"},{name:"Dark raspberry",rgb:"#872657"},{name:"Dark turquoise",rgb:"#610079"},{name:"Deep teal",rgb:"#004040"},{name:"Deep coffee",rgb:"#704241"},{name:"Dusty rasberry",rgb:"#917980"},{name:"Ecru",rgb:"#BCAC7C"},{name:"Evergreen",rgb:"#05472A"},{name:"Eggplant",rgb:"#380835"},{name:"Eggplant purple",rgb:"#430541"},{name:"Emerald green",rgb:"#028F1E"},{name:"Flamingo pink",rgb:"#D67C99"},{name:"Grape",rgb:"#6C3461"},{name:"Kelly green",rgb:"#4CBB17"},{name:"Light forest green",rgb:"#4F9153"},{name:"Medium dark brown",rgb:"#AF7200"},{name:"Medium dark cyan-blue",rgb:"#2D537C"},{name:"Mustard",rgb:"#FAAF18"},{name:"Neon green",rgb:"#39FF14"},{name:"Pear",rgb:"#D1E231"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Phthalo blue",rgb:"#0016C7"},{name:"Pink lace",rgb:"#FFDDF4"},{name:"Raw sienna",rgb:"#884B15"},{name:"Rebecca purple",rgb:"#663399"},{name:"Sap green",rgb:"#536916"},{name:"Blue sapphire",rgb:"#133ECB"},{name:"Sand",rgb:"#B38751"},{name:"Shadow blue",rgb:"#778BA5"},{name:"Shadow green",rgb:"#121E06"},{name:"Swamp green",rgb:"#748500"},{name:"Verdigris",rgb:"#43B3AE"},{name:"Vivid blue-magenta",rgb:"#4817E8"},{name:"Vivid blue-purple",rgb:"#ACACE6"},{name:"Vivid blue",rgb:"#47ABCC"},{name:"Vivid green-yellow",rgb:"#D9E650"},{name:"Vivid green",rgb:"#7BE214"},{name:"Vivid turqoise",rgb:"#06ECD2"},{name:"Vivid lavender",rgb:"#A354FD"},{name:"Vivid mint",rgb:"#00F28C"},{name:"Vivid pink",rgb:"#D752FB"},{name:"Vivid red-purple",rgb:"#C31D7E"},{name:"Vivid red",rgb:"#D92121"},{name:"Vivid yellow-red",rgb:"#F2BA49"},{name:"Vivid yellow",rgb:"#FAFA37"}]},91482:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarkWikipediaColors=void 0,t.DarkWikipediaColors=[{name:"Bistre",rgb:"#3D2B1F"},{name:"Black bean",rgb:"#3D0C02"},{name:"Black pearl",rgb:"#041322"},{name:"Shadow blue",rgb:"#001440"},{name:"Charcoal",rgb:"#36454F"},{name:"Dark indigo",rgb:"#1F0A52"},{name:"Dark magenta",rgb:"#8B008B"},{name:"Dark moss green",rgb:"#4A5D23"},{name:"Dark navy",rgb:"#02075D"},{name:"Dark pastel blue",rgb:"#779ECB"},{name:"Dark purple",rgb:"#580040"},{name:"Dark tan",rgb:"#918151"},{name:"Dark yellow-green",rgb:"#304000"},{name:"Dark yellow",rgb:"#9B870C"},{name:"Deep violet",rgb:"#330066"},{name:"Dusk",rgb:"#4E5481"},{name:"Elderberry",rgb:"#1d1a34"},{name:"Grey jade",rgb:"#757C55"},{name:"Grey magenta",rgb:"#83667F"},{name:"Grey ochre",rgb:"#716659"},{name:"Grey olive",rgb:"#656c5a"},{name:"Grey sage",rgb:"#69724d"},{name:"Taupe",rgb:"#483C32"}]},3048:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciede2000_delta_e=t.diffCIECorr=t.MaxCie=t.MinCie=t.cie94_delta_e=t.cie76_delta_e=void 0;const r=i(31586),s=i(97352);t.cie76_delta_e=function(e,t){return Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2)},t.cie94_delta_e=function(e,t){const[i,r,n]=e,[a,o,l]=t,u=i-a,c=r-o,d=n-l,h=(0,s.sqrt)(r**2+n**2),f=h-(0,s.sqrt)(o**2+l**2),m=(0,s.sqrt)(c**2+d**2-f**2);return(0,s.sqrt)((u/1)**2+(f/(1+.045*h))**2+(m/(1+.015*h))**2)},t.MinCie=2,t.MaxCie=20,t.diffCIECorr=function(e,i){return null==e||null==i?1:(0,r.clamp)(0,t.MaxCie,l(e,i)-t.MinCie)/t.MaxCie};const n=1,a=1,o=1;function l(e,t){const[i,r,l]=e,u=(0,s.sqrt)(r**2+l**2),[c,d,h]=t,f=(u+(0,s.sqrt)(d**2+h**2))/2,m=.5*(1-(0,s.sqrt)(Math.pow(f,7)/(Math.pow(f,7)+Math.pow(25,7)))),p=r*(1+m),g=d*(1+m),y=(0,s.sqrt)(p*p+l*l),v=(0,s.sqrt)(g*g+h*h);let w=Math.abs(p)+Math.abs(l)===0?0:Math.atan2(l,p);w+=2*(w<0?1:0)*Math.PI;let b=Math.abs(g)+Math.abs(h)===0?0:Math.atan2(h,g);b+=2*(b<0?1:0)*Math.PI;const S=c-i,P=v-y;let _=y*v==0?0:b-w;_-=2*(_>Math.PI?1:0)*Math.PI,_+=2*(_<-Math.PI?1:0)*Math.PI;const M=2*(0,s.sqrt)(y*v)*Math.sin(_/2),T=(i+c)/2,E=(y+v)/2;let k;y*v==0?k=w+b:(k=(w+b)/2,k-=(Math.abs(w-b)>Math.PI?1:0)*Math.PI,k+=2*(k<0?1:0)*Math.PI);const D=(T-50)**2,x=1-.17*Math.cos(k-Math.PI/6)+.24*Math.cos(2*k)+.32*Math.cos(3*k+Math.PI/30)-.2*Math.cos(4*k-63*Math.PI/180),C=1+.015*D/(0,s.sqrt)(20+D),F=1+.045*E,A=1+.015*E*x,I=30*Math.PI/180*Math.exp(-1*((180/Math.PI*k-275)/25)**2),O=2*(0,s.sqrt)(Math.pow(E,7)/(Math.pow(E,7)+Math.pow(25,7))),L=-1*Math.sin(2*I)*O;return(0,s.sqrt)(Math.pow(S/(n*C),2)+Math.pow(P/(a*F),2)+Math.pow(M/(o*A),2)+L*P/(a*F)*M/(o*A))}t.ciede2000_delta_e=l},76490:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColor=t.dominantColorsToRgbHex=void 0;const r=i(40958),s=i(31586),n=i(97352),a=i(54772),o=i(85810),l=i(42022),u=i(1971);t.dominantColorsToRgbHex=function(e){return(0,r.compact)(e.map((e=>[e.rgbhex,(0,s.fmtPct)(e.pct)])))};class c{static fromModeData(e){return(0,r.compact)((0,s.times)(u.ModeCount,(t=>c.fromLabhash({labhash:e[`mode${t}`],pct:e[`mode${t}pct`]}))))}static toModeData(e){const t={};return(0,s.times)(u.ModeCount,(i=>{t["mode"+i]=e[i]?.labhash??null,t["mode"+i+"pct"]=e[i]?.pct??null})),t}static fromLabhash({labhash:e,labhashBits:t=l.ModeBits,pct:i}){const r=(0,n.mapGt0)(e,(e=>(0,o.unlabhash)(e,t)));return null!=r&&(0,s.gt0)(i)?new c(r,i,e):void 0}static fromCentroid(e,t){return new c(e.centroid,Math.round(e.size/t*100))}constructor(e,t,i){this.lab=e,this.pct=(0,s.clamp)(0,100,t),this.labhash=i??(0,o.toLabhash)(e,l.ModeBits)}get rgbhex(){return(0,o.lab2rgbhex)(this.lab)}get color(){return(0,a.bestLabhashName)(this.labhash)}toGreyscale(){return new c([this.lab[0],0,0],this.pct)}eql(e){return this.labhash===e.labhash&&(0,s.closeTo)(this.pct,e.pct,5)}}t.DominantColor=c},32848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scaled_delta_e=t.dominantColorCorrelation=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(48884),o=i(31843),l=i(70417),u=i(3048);function c(e,t){const i=(0,s.sum)(e,(e=>(0,n.clamp)(0,100,e.pct))),r=(0,s.sum)(e,(e=>function(e,t){const i=(0,a.leastBy)(t,(t=>(0,u.ciede2000_delta_e)(e.lab,t.lab)));if(null==i)return 0;const r=(0,u.ciede2000_delta_e)(e.lab,i.lab),s=(0,n.clamp)(0,e.pct,(0,l.avg)([e.pct,i.pct])),o=h(r);return(0,n.clamp)(0,100,s)*o}(e,t)));return r/i}t.dominantColorCorrelation=function(e,t){return e=(0,s.compact)(e),t=(0,s.compact)(t),(0,s.isEmpty)(e)||(0,s.isEmpty)(t)?0:(0,l.avg)([c(e,t),c(t,e)])};const d=(0,r.lazy)((()=>[{x:0,y:1},{x:9,y:.8},{x:16,y:.3},{x:20,y:0}]));function h(e){return(0,n.clamp)(0,1,(0,o.lerp2d)(e,...d()))}t.scaled_delta_e=h},40401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeNearCentroids=t.mergeLabhashes=t.dominantColorsFromModes=t.maybeFilterGrey=t.centroidsScore=t.extractDominantColors=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(41400),o=i(98553),l=i(31586),u=i(68708),c=i(48884),d=i(22454),h=i(50213),f=i(56038),m=i(82647),p=i(44983),g=i(70417),y=i(28874),v=i(85810),w=i(3048),b=i(76490),S=i(1971),P=(0,r.lazy)((()=>(0,h.mkLogger)("color.DominantColors")));t.extractDominantColors=function(e,t=S.ModeCount){return(0,f.timeSync)("img.extractDominantColors",(()=>function(e,t=S.ModeCount){const i=Date.now(),r=y.Settings.dominantColorKmeansRuns.valueOrDefault,a=new d.CountingSet;for(const i of E({labs:e,minK:t}))a.incr((0,v.toLabhash)(i));const h=M[y.Settings.dominantColorDeltaE.valueOrDefault]??w.ciede2000_delta_e;const f=a.sortedByKey().valuesToA((e=>(0,v.unlabhash)(e)));let g=(0,l.round)(t+y.Settings.dominantColorMergeThreshold.valueOrDefault);function D(e){const i=t,r=4*t;g=Math.round(Math.max(i,Math.min(r,e)))}const C=f.length<=g?[]:(0,s.compact)(_.slice(0,r).map((e=>{const r=(0,p.kmeans)(f,g,{...T,seed:e}),s=x(r.centroids,f.length);if(s.lengtht&&D(g-1);const n=s.slice(0,t),o=(0,l.sigFigs)(function(e){const t=new m.Average;for(const[i,r]of a.entries()){const s=(0,v.unlabhash)(i),n=(0,c.leastByCtx)(e,(e=>h(e.centroid,s)));null!=n&&(0,l.times)(r,(()=>t.push(n.value)))}return t.p84}(n),2);return{...r,centroids:n,description:{kIn:g,kOut:r.centroids.length,kMerged:s.length,score:o,iterations:r.iterations,uniqColors:a.size,elapsedMs:Date.now()-i},score:o}})));P().trace("extractDominantColors()",{kmeansResults:C.map((e=>(0,u.pick)(e,"description","score")))});const F=(0,c.leastBy)(C,(e=>e.score));if(null==F)return P().info("kmeans failed or was disabled, using dominantColorsFromModes",{runs:r}),k(a,t);const A=(0,o.stringify)({...F?.description,elapsedMs:Date.now()-i}),I=(0,n.sortBy)(F?.centroids,(e=>-e.size)).map((e=>b.DominantColor.fromCentroid(e,f.length)));return P().debug("extractDominantColors() result",{description:A,score:F?.score,totalColors:a.size,totalPixels:f.length,iters:F?.iterations,dominantColors:(0,b.dominantColorsToRgbHex)(I),pixelCount:f.length}),{dominantColors:I,description:A,dominantColorScore:F?.score}}(e,t)))},t.centroidsScore=function(e,t){const i=new m.Average;for(const r of e){const e=(0,c.leastBy)(t,(e=>(0,w.ciede2000_delta_e)(e.centroid,r)));null!=e&&i.push((0,w.ciede2000_delta_e)(e.centroid,r))}return i};const _=[6147062518717073,8176726750919909,5426648081701673,0xce2a345532a3c,0x713f9716da824,6348935463312109,5900323173950995,7358780886584433,5704068712193493,0x51ceeef755892,0xe1557fe94c084,0xd42d7cc96d6b4,0xcbc36dfd76e8a,6738189173486085,8537822851166899,5390086061821835,7712057976331355,0xe9b820db7a8e4,0xb96cebcd6aa40,7036994544380825,5353634786120155,0x99a11417794bc,0xa93d36019aaae,0x74a470887095e,5481147022770415,5347523348244809,0x541d1098e90fc,0xa24d9fb3510c2,0x78aa8e4f692fa,6354921850669697,0x714e1ec1b0a14,8622097963014773,0x6ff5d462d8eb6,0x6782a6b5166b8,7128984079394103,0xe6efba28a3752,5088704486053871,0xc84df40627fae,8018285280412081,4524300326741245,8307147030534695,8135486835878813,7699950603263999,0xb2889592968ae,5903399874280295,7462660765348991,6442509751447017,0xe218d44834db6,7214173935589545,6001326758941961,0x53eb7d39bbb50,0xc3a7ab8add332,0x4e6e81bc443e2,6757635537583321,8501611905255957,0x51840465cc07c,5958243312989149,8928005021308717,5032083390680559,0xb35d70ac51c68,0xfc3826a2dfe7c,0xd155853c61e96,0xda2045ee9be1e,4753952745315177],M={cie76:w.cie76_delta_e,cie94:w.cie94_delta_e,ciede2000:w.ciede2000_delta_e},T=(0,r.lazy)((()=>({maxIterations:50,initialization:"kmeans++",distanceFunction:M[y.Settings.dominantColorDeltaE.valueOrDefault]})));function E({labs:e,minK:t,thresh:i,retries:r=3}){if(r<0)return P().debug("maybeFilterGrey(): exhausted retries: grey filtering disabled."),e;const s=i??y.Settings.dominantColorGreyThreshold.valueOrDefault;if(!(0,l.gt0)(s))return P().debug("maybeFilterGrey(): grey threshold is <= 0: grey filtering disabled."),e;const n=e.filter((e=>Math.abs(e[1])+Math.abs(e[2])>=s));return n.length>=e.length/2?(P().debug("maybeFilterGrey(): sufficient remaining pixels with this threshold.",{greyThreshold:s,minK:t,pixelCount:e.length,filteredCount:n.length}),n):(P().debug("maybeFilterGrey(): insufficient remaining pixels with this threshold. Retrying with smaller threshold.",{greyThreshold:s,minK:t,retries:r,pixelCount:e.length,filteredCount:n.length}),E({labs:e,minK:t,thresh:.75*s,retries:r-1}))}function k(e,t){const i=e.countSum,r=e.size;D(e);const n=e.size,a=(0,s.compact)(e.top(t).map((([e,t])=>b.DominantColor.fromLabhash({labhash:e,pct:Math.round(100*t/i)})))),l=100-(0,g.sumf)(a,(e=>e.pct));return{dominantColors:a,description:"dominantColorsFromModes: "+(0,o.stringify)({uniqColors:r,mergedColors:n,pixelCount:i,pctOmitted:l})}}function D(e,t=y.Settings.dominantColorMergeThreshold.valueOrDefault){const i=[];for(const[r,s]of[...e.entriesByCountDesc()]){const n=(0,v.unlabhash)(r),a=i.find((e=>(0,w.ciede2000_delta_e)(e.lab,n)<=t));null==a?i.push({lab:n,labhash:r}):(e.delete(r),e.incr(a.labhash,s))}return e}function x(e,t,i=y.Settings.dominantColorMergeThreshold.valueOrDefault){if(i<=0)return e;const r=[];for(const t of e){const e=r.find((e=>(0,w.ciede2000_delta_e)(t.centroid,e.centroid)<=i));null==e?r.push(t):e.size+=t.size}const s=t/100;return(0,n.sortBy)(r.filter((e=>e.size>s)),(e=>-e.size))}(0,a.later)((()=>{y.Settings.dominantColorDeltaE.watchLater((()=>{T.unset()}))})),t.maybeFilterGrey=E,t.dominantColorsFromModes=k,t.mergeLabhashes=D,t.mergeNearCentroids=x},85409:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Greys=void 0,t.Greys=[{name:"Black",rgb:"#000000"},{name:"90% black",rgb:"#1b1b1b"},{name:"80% black",rgb:"#303030"},{name:"70% black",rgb:"#474747"},{name:"60% black",rgb:"#5e5e5e"},{name:"Grey",rgb:"#777777"},{name:"60% white",rgb:"#919191"},{name:"70% white",rgb:"#ababab"},{name:"80% white",rgb:"#c6c6c6"},{name:"90% white",rgb:"#e2e2e2"},{name:"White",rgb:"#ffffff"}]},86758:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.labsAreGreyscale=t.isLab=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(82647),o=i(28874),l=i(85810),u=(0,r.lazy)((()=>(0,n.mkLogger)("color.Lab")));t.isLab=function(e){return Array.isArray(e)&&3===e.length&&(0,s.within)(0,100,e[0])&&(0,s.within)(-110,110,e[1])&&(0,s.within)(-110,110,e[2])},t.labsAreGreyscale=function(e){const t=o.Settings.greyscaleColorThreshold.valueOrDefault,i=new a.Average,r=new a.Average;for(const t of e){const e=(0,l.clampLab)(t);i.push(e[1]),r.push(e[2])}const s=(i.stdDev??0)+(r.stdDev??0),n=s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LightWikipediaColors=void 0,t.LightWikipediaColors=[{name:"Beige",rgb:"#F5F5DC"},{name:"Laurel green",rgb:"#A9BA9D"},{name:"Light sage",rgb:"#93A58B"},{name:"Light green-cyan",rgb:"#CFEADE"},{name:"Pastel purple",rgb:"#B39EB5"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Powder blue",rgb:"#B0E0E6"},{name:"Vanilla",rgb:"#F3E5AB"}]},42022:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeBits=void 0,t.ModeBits=12},1971:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeCount=void 0,t.ModeCount=7},85434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitModeData=t.pickModeData=t.ModeDataKeys=t.isModeData=void 0;const r=i(31586),s=i(68708),n=i(50989);t.isModeData=function(e){return(0,r.gt0)(e.mode0)&&(0,r.gt0)(e.mode0pct)},t.ModeDataKeys=(0,n.strEnum)("mode0","mode0pct","mode1","mode1pct","mode2","mode2pct","mode3","mode3pct","mode4","mode4pct","mode5","mode5pct","mode6","mode6pct"),t.pickModeData=function(e){return(0,s.pick)(e,...t.ModeDataKeys.values)},t.omitModeData=function(e){return(0,s.omit)(e,...t.ModeDataKeys.values)}},85042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clampRGB=t.rgbTriplet2hex=t.rgbhex2triplet=t.normalizeRgbHex=void 0;const r=i(31586),s=i(39926),n=i(51926),a=i(54993),o=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;function l(e){return[e[0],e[1],e[2]].map((e=>(0,r.clamp)(0,255,Math.round(e))))}t.normalizeRgbHex=function(e){const t=(0,a.toS)(e).trim();return o.test(t)?(0,n.ensurePrefix)(t,"#").toUpperCase():void 0},t.rgbhex2triplet=function(e){const t=(0,a.toS)(e).trim().match(o);if(null!=t)try{return[t[1],t[2],t[3]].map((e=>(0,r.clamp)(0,255,parseInt(e,16))))}catch{return}},t.rgbTriplet2hex=function(e){return"#"+l(e).map((e=>(0,s.leftPad)(Math.round(e).toString(16).toUpperCase(),2,"0"))).join("")},t.clampRGB=l},76596:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),s=i(19851),n=i(22573),a=i(42659),o=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,s.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,o.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,o.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,a.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const r=i(77988),s=i(19851),n=i(55835),a=i(31586),o=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,s.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),h=["year","month","day","hour","minute","second","millisecond"];class f{static fromISO(e,t){const i=d().exec((0,o.toS)(e).trim()),r=i?.groups;return null==r?void 0:f.for((0,c.parseExifDateTime)(r.start,t),(0,c.parseExifDateTime)(r.end,t),(0,a.toInt)(r.index),(0,a.toInt)(r.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,n.map)(e.start,(e=>r.ExifDateTime.fromJSON(e))),(0,n.map)(e.end,(e=>r.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,r=1){if(null==e||!e.isValid||null==t||!t.isValid)return;r=(0,a.clamp)(1,1e3,(0,a.toInt)(r,{defaultValue:1})),i=(0,a.clamp)(0,r-1,(0,a.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const s=e.toMillis(),n=(t.toMillis()-s)/(r+1)*(i+1),o=e.plus({milliseconds:n});return null==o?void 0:new f(e,o,t,i,r)}constructor(e,t,i,r=0,s=1){this.start=e,this.middle=t,this.end=i,this.index=r,this.splits=s,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=h.map((r=>function({start:e,end:t,middle:i,field:r}){return null!=e[r]&&null!=t[r]?i[r]:void 0}({start:e,middle:t,end:i,field:r})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new f(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=f},79842:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(76790),o=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),h=i(51926),f=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),v=i(21330),w=i(928),b=i(54261),S=i(73389),P=i(51275),_=(0,n.lazy)((()=>(0,f.mkLogger)("date.Dated")));function M(e){return null!=e&&(e instanceof v.FuzzyDate||e instanceof r.ExifDate||e instanceof r.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,S.isDateTime)(e)||(0,m.isDateObject)(e))}function T(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof r.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function E(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof r.ExifDate?e.toMillis(l.dayMs):e instanceof v.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),D(e),((e,t)=>e+t))}function k(e){try{if(null==e||(0,h.isString)(e)||(0,c.isNumber)(e))return;return(0,S.isDateTime)(e)?e:e instanceof r.ExifDateTime||e instanceof v.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?s.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void _().warn("datedToDateTime() failed",{d:e,error:t})}}function D(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,b.hasTime)(e)){if((0,c.gt0)((0,w.getMillisecond)(e)))return 0;if((0,c.gt0)((0,w.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,w.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,w.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,w.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,w.getMonth)(e))?l.monthMs-1:l.yearMs-1}function x(e,t){const i=T(e),r=E(e);if(null!=i&&null!=r)return(0,c.gt0)(t)&&t>r-i?{start:Math.round((i+r)/2-t/2),end:Math.round((i+r)/2+t/2)}:{start:i,end:r}}function C(e,t,i,r){const[s,n]=(0,a.sortBy)([x(e,i),x(t,r)],(e=>e?.start));return null!=s&&null!=n&&null!=s&&null!=n&&(s.start===n.start||s.end>=Math.min(n.start,n.end))}function F(e,t){return(0,o.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??v.FuzzyDate.fromISO(e)}t.isDated=M,t.toDated=function(e){return M(e)?e:void 0},t.mapDated=function(e,t){return M(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=T,t.datedToEndTs=E,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof r.ExifDate?s.DateTime.fromObject(e):k(e)},t.datedToDateTime=k,t.datedToPrecisionMs=D,t.isoToPrecisionMs=function(e){return(0,u.map)(F(e),D)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:r}){if(null==e||null==t)return!1;if(i??(i=D(e)),r??(r=D(t)),C(e,t,i,r))return!0;const s=(0,P.getZoneName)(e),n=(0,P.getZoneName)(t);return null==s&&null!=n&&(e=(0,v.setZone)(e,n)??e),null==n&&null!=s&&(t=(0,v.setZone)(t,s)??t),C(e,t,i,r)},t.isoToDated=F,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof s.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const r=i(31586),s=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,s.isString)(e))return(0,r.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),s=i(31586),n=i(54557),a=i(91655),o=new n.FifoCache(512);function l(e){return(0,s.isNumber)(e)?e:(0,r.blank)(e)?void 0:o.getOrSet(e,(()=>(0,a.parseDuration)(e)))}t.decodeDuration=l;const u=new n.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,a.fmtFullDuration)((0,s.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),s=i(40958),n=i(22573),a=i(42659),o=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,o.isNumber)(e))return;if((0,o.isNumber)(e))return e;if((0,o.isDigits)(e))return(0,o.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,s.compact)(d.map((e=>function(e,t){const i=(0,o.toFloat)(e);if(null!=i){if((0,n.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*a.yearMs;case"weeks":case"week":case"w":return i*a.weekMs;case"days":case"day":case"d":return i*a.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*a.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*a.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*a.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,o.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:a.yearMs,s:"y"},{ms:a.weekMs,s:"w"},{ms:a.dayMs,s:"d"},{ms:a.hourMs,s:"h"},{ms:a.minuteMs,s:"m"},{ms:a.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,o.isNumber)(t))return;if(0===t)return"0";if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},98247:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),h=i(68852),f=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function v(e,t,i){const r=t.exec(e);if(null==r||(0,u.isEmptyObj)(r.groups))return;const{year:s,month:n,day:a,hour:c,minute:h,second:p}=(0,d.mapEntries)(r.groups,((e,t)=>(0,l.toInt)(t)));if(null==s||null==n||null==a)return;if(!f.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==h))return;const g=(0,o.map)((0,l.toFloat)(r.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),v=(0,y.timezoneOffsetFromRegExpMatch)(r);return S({year:s,month:n,day:a,hour:c??0,minute:h??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(v)??i,rawValue:e,tzoffsetMinutes:v})}t.UnsetZone=s.Info.normalizeZone(r.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof r.ExifDate&&t instanceof r.ExifTime))return;const i=new r.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:n}){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromFormat(e,i,{zone:n??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,a.blank)(e)?void 0:r.ExifDateTime.from(e,t)??v(e,b(),t)},t.parseExifDateTimeRe=v;const w=/[-:_\s]?/,b=(0,n.lazy)((()=>(0,h.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,w,p.monthRE,w,p.dayRE,/[T\s]/,p.hourRE,w,p.minuteRE,w,p.secondRE,p.subsecRE,/\s?/,h.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function S(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof r.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=r.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,o.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=S},74417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const r=i(51168),s=i(22573),n=i(42659),a=i(49769),o=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),h=i(66649),f=i(98725),m=i(88600);t.recent=function(e,t=5*n.secondMs){return(0,c.isRecentMs)((0,h.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=r.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,s.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,s.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=r.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,a.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,h.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,o.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*n.secondMs):void 0)??(0,f.parseDateTime)(t)?.toMillis()}},12959:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filestampUTC=t.filestamp=void 0;const r=i(39926);t.filestamp=function(e=new Date){return[e.getFullYear(),(0,r.pad2)(e.getMonth()+1),(0,r.pad2)(e.getDate()),"-",(0,r.pad2)(e.getHours()),(0,r.pad2)(e.getMinutes()),(0,r.pad2)(e.getSeconds())].join("")},t.filestampUTC=function(e=new Date){return[e.getUTCFullYear(),(0,r.pad2)(e.getUTCMonth()+1),(0,r.pad2)(e.getUTCDate()),"-",(0,r.pad2)(e.getUTCHours()),(0,r.pad2)(e.getUTCMinutes()),(0,r.pad2)(e.getUTCSeconds())].join("")}},21330:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const n=i(77988),a=i(51168),o=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(31586),f=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),v=i(79842),w=i(66649),b=i(98247),S=i(98725),P=i(928),_=i(54261),M=i(73389),T=i(89724),E=i(17415),k=i(88600),D=i(51275);function x(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class C{constructor(e,t,i){this.year=e,this.month=t,this.day=i,r.set(this,(0,p.lazy)((()=>(0,k.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(S.ISO_YMD_RE.exec(e)?.groups??S.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,h.toGt0)(e?.year);if(null==e||null==t||tx(e))).join("-")}toLocal(){return(0,T.datedToLocal)(this)}toDateTime(){return a.DateTime.fromObject((0,f.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,f.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,f.pick)(e.plus({month:1}),"year","month"):(0,f.pick)(e.plus({year:1}),"year");return new C(t.year,t.month,t.day)}}function F(e,t){if(e instanceof n.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,_.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,E.zoneToTzOffsetMinutes)((0,w.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(r=>(0,d.map)((0,P.getMonth)(e),(s=>(0,d.map)((0,P.getDay)(e),(n=>(0,d.map)((0,P.getHour)(e),(a=>(0,b.dateObjectToExifDateTime)({year:r,month:s,day:n,hour:a,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=C,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",r=15*(0,h.round)(e/15),s=Math.abs(r),n=Math.floor(s/60),a=Math.floor(Math.abs(s%60));return`${t?"UTC":""}${i}${x(n)}:${x(a)}`},t.toExifDateTime=F,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof n.ExifDateTime?e.tzoffsetMinutes:(0,M.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,_.hasTime)(e)||(i??(0,v.datedToPrecisionMs)(e))>=c.dayMs?O(e):F(e,(0,D.getZoneName)(e))?.toISOString({includeOffset:t})};const A="yyyy:MM:dd HH:mm:ss.SSS",I=A+"ZZ";function O(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>x(e))).join(t)}function L(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new C(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,r]=[e,t].map(w.datedToMillis);return null==i||null==r?void 0:i-r}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,h.isNumber)(t)?a.DateTime.fromMillis(t):(0,v.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,D.hasZone)(t)?I:A):void 0},t.datedToYMD=O,t.toFuzzyDate=L,t.sameDay=function(e,t){return(0,h.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,h.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,r=1){if(null==(0,w.datedToMillis)(e)||null==(0,w.datedToMillis)(t))return;const[s,n]=[e,t].map((e=>(0,w.datedToMillis)(e))).sort(),o=(n-s)/(r+1),l=(0,D.getZoneName)(e),u=l===(0,D.getZoneName)(t)?l:void 0,c=a.DateTime.fromMillis(s+o*i,{zone:u});return[e,t].some((e=>!(0,_.hasTime)(e)))?L(c):c},t.setZone=function(e,t,i){const r={...(0,f.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,D.hasZone)(e)},s=(0,E.normalizeZone)(t);if(null!=e&&null!=s&&(0,_.hasTime)(e))return e instanceof y.DateInterval?e.setZone(s,r):F(e)?.setZone(s,r)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,h.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,v.datedToDateTime)(e);if(null==i)return;const r=(0,D.getZoneName)(e);return null!=r&&"UTC"!==r||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const o=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),h=i(49769),f=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),v=i(68852),w=i(4001),b=i(28874),S=i(24689),P=i(79842),_=i(66649),M=i(98247),T=i(21330),E=i(54261),k=i(73389),D=i(16400),x=i(88600),C=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return C().tap({msg:"extractDateFromPath",result:O.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return O.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return O.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,f.mapNumeric)((0,_.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,v.concatRegexp)([/^/,t.yearRE,v.RegExpOptional.from(/-/,t.monthRE,v.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,v.concatRegexp)([/^/,t.yearishRE,v.RegExpOptional.from(/-/,t.monthishRE,v.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=I({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,k.isDateTime)(i)?i:(0,E.isExifDateTime)(i)?i.toDateTime():void 0};const F=new Map;function A(e,t,i){try{const r=(0,M.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=r)return r;const s=(0,h.getOrSet)(F,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void C().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,M.parseExifDateTimeFormat)({input:s?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void C().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function I({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:r=!0,descPredicate:s=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const n=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(w.stripDSC));if(0!==n.length)for(const{desc:e,f:a}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>S.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,M.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:M.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(b.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(b.Settings.extraDateTimeFormats.values)){const r=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${r})`,f:i=>A(i,r,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>o.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of O.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:r}))if(s(e))for(const e of n){const t=a(e);if(null!=t&&(0,x.isValidDate)(t))return t}}t.parseDated=I;class O{constructor(e={}){r.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&b.Settings.fuzzyDateParsing.watchLater((()=>a(this,r,"m",n).call(this))),null==e.fuzzyYearParsing&&b.Settings.fuzzyYearParsing.watchLater((()=>a(this,r,"m",n).call(this))),a(this,r,"m",n).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??b.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??b.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!b.Settings.usePathsToInferDates.valueOrDefault)return;T.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=I({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=O,r=new WeakSet,s=function(e){const t=new L(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},n=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new v.RegExpEscaped("(?"+(0,D.monthNames)().map(v.escapeRegExp).join("|")+")");a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE]),a(this,r,"m",s).call(this,[e,t.seps,t.yearRE]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,e]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},O.instance=(0,u.lazy)((()=>new O));class L{constructor(e){this.regex=e instanceof RegExp?e:(0,v.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return T.FuzzyDate.for({year:(0,f.toInt)(t.year),month:(0,f.toInt)(t.month)??(0,D.monthName2index)(t.monthname),day:(0,f.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const r=i(55835),s=i(31586),n=i(54261);function a(e){return e instanceof Date?e.getMinutes():e?.minute}function o(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=a,t.getSecond=o,t.getMillisecond=l,t.getCentisecond=function(e){return(0,r.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,n.hasTime)(e)&&((0,s.gt0)(a(e))||(0,s.gt0)(o(e))||(0,s.gt0)(l(e)))},t.getSecMs=function(e){return(0,r.map)(o(e),(t=>{const i=l(e)??0;let r=(t+i/1e3).toString();for(t<10&&(r="0"+r),0===i&&(r+=".");r.length<6;)r+="0";return r}))}},54261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const r=i(77988),s=i(31586),n=i(68708);t.hasTime=function(e){if(!(0,n.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,s.gt0)(t.hour)||(0,s.gt0)(t.minute)||(0,s.gt0)(t.second)||(0,s.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof r.ExifDateTime}},73389:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const r=i(51168);t.isDateTime=function(e){return r.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const r=i(51168),s=i(19851),n=i(42659),a=i(55835),o=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),h=i(74417),f=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,s.lazy)((()=>v(l.Settings.datesBeforeAreEstimated.valueOrDefault)??v(l.Settings.datesBeforeAreEstimated.defaultValue)));function v(e){return(0,a.map)((0,c.isoToDated)(e),w)}function w(e){return(0,o.isNumber)(e)?M(e):100*b(e)+((0,m.getCentisecond)(e)??0)}function b(e){if((0,o.isNumber)(e))return Math.floor(M(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function S(e,t){if(null==e||e<0)return;let i=e;const r=()=>{const e=i%100;return i=Math.floor(i/100),e},s=10*r(),n=r(),a=r(),l=(0,o.toGt0)(r()),u=(0,o.toGt0)(r()),c=(0,o.toGt0)(r());return{year:i,month:c,day:u,hour:l,minute:a,second:n,millisecond:s,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=S(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):f.FuzzyDate.for(i)}function _(e,t){return M(Date.now()-e,t)}function M(e,t){return w(r.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const r=i(19851),s=i(76790),n=i(31586),a=i(9092),o=(0,r.lazy)((()=>{const e=new a.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const r=new Intl.DateTimeFormat(t,{month:i});(0,n.times)(12,(s=>{const n=r.format(new Date(2017,s));e.set(n,s+1),"short"===i&&"en-US"===t&&e.set(n+".",s+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:o().get(e)},t.monthNames=function(){return(0,s.sort)([...o().keys()])}},17415:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),h=i(54993),f=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,n.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const r=(0,f.leastBy)(g(),(t=>Math.abs(t-e)));return null!=r&&Math.abs(r-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(r)}t.isUTCZone=function(e){return b(e)||0===S(e)?.offset(Date.now())},t.normalizeZone=S,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,o.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=_,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:_(i)};const M=/\b(?Z|UTC|GMT)\b/,T=/(?[-±+−])/,E=/[-−]/,k=/(?[01]\d)/,D=/(?[01]?\d)/,x=/(?::(?\d\d))/;function C(e){return b(e)?0:F((0,t.TimezoneOffsetRE)().exec(e))}function F(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,a.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=E.test((0,h.toS)(e.groups.tzSign))?-1:1,r=(0,l.toInt)(e.groups.tzMinutes)??0,s=null==t?void 0:i*(60*t+r);return v(s)?s:void 0}t.TimezoneOffsetRE=(0,n.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),M,new m.RegExpEscaped("|"),T,k,m.RegExpOptional.from(x),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=C,t.timezoneOffsetFromRegExpMatch=F;const A=/\b(?(?:Etc\/)?GMT)\b/,I=(0,n.lazy)((()=>(0,m.concatRegexp)([A,T,D,m.RegExpOptional.from(x)])));function O(e){return F(I().exec(e))}t.ianaZoneToOffsetMinutes=O,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,a.blank)(e))return;const i=O(e)??C(e);if(null!=i)return _(i);if(null!=t){const i=S(e);if(null!=i)return _(i.offset(t))}}},88600:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),h=i(28874),f=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),v=(0,s.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),w=(0,s.lazy)((()=>(0,n.compact)(h.Settings.badDates.values.map((e=>(0,f.isoToDated)(e)))))),b=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,p.datedToISO)(e)))))),S=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,y.datedToLocal)(e)))))),P=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,m.datedToMillis)(e))))));function _(e){if(null==e)return!1;const t=T(e);return v().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return _(e)?e:void 0},t.isValidDate=_;const M=String(new Date("bad"));function T(e){try{if(!(0,f.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===M)return M;const t=(0,n.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const s=[];if((0,l.isNumber)(e)||s.push("year is not a number"),(0,l.lt)(e,h.Settings.minValidYear.valueOrDefault)&&s.push("year is less than "+h.Settings.minValidYear.key),(0,u.gt)(e,E())&&s.push("year is in the future"),null==t&&null!=i&&s.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const n=r.DateTime.fromObject({year:e,month:t,day:i});n.isValid||s.push(n.invalidExplanation??"not valid")}return(0,n.compact)(s)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=h.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const r=(0,m.datedToMillis)(e);(0,u.gt)(r,Date.now()+i)&&t.push("date is too far in the future: see "+h.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):S().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):b().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,a.toNotBlank)((0,n.uniq)((0,n.compactBlanks)(t)).join("; "))}catch(t){return v().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=T;const E=(0,s.lazy)((()=>r.DateTime.now().plus({milliseconds:h.Settings.maxValidFutureMs.valueOrDefault}).year),o.dayMs);t.mapValidDate=function(e,t){return _(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==T({year:e,month:t,day:i})}},51275:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const r=i(77988),s=i(31586),n=i(24689),a=i(73389);t.hasZone=function(e){return null!=e&&!(0,s.isNumber)(e)&&(e instanceof n.DateInterval||e instanceof r.ExifDateTime?e.hasZone:!!(0,a.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==r.UnsetZoneName&&e.zone.offset(Date.now())!==r.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,a.isDateTime)(e)?e.zoneName===r.UnsetZoneName?void 0:e.zone?.name:e instanceof r.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},82261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cacheDbDir_=void 0;const r=i(51926),s=i(49776),n=i(38835),a=i(95696),o=i(70854),l=i(73428),u=i(28874),c=i(15056);t.cacheDbDir_=async function(e=u.Settings.libraryDir.valueOrDefault,t=c.Schemas.models){const i=(0,o.libraryUidStore)(e);if(null==i)throw new Error("Library directory is not set"+n.NoLibraryErrorFlag);const d=await i.readUid_(),h=a.PosixFile.for((0,s.cacheDir_)()).join(t+"-live-db",d);await h.mkdirp_();const f=h.join("README.txt");return await(0,l.writeTextfile_)(f.nativePath,...(0,r.wrap)(["This folder is used by PhotoStructure for your library stored in",e,"You will corrupt your library if you remove this directory while PhotoStructure is running.","See https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837 for details."].join("\n\n"))),h}},92407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLiveDbDir_=t.cacheDbFile_=void 0;const r=i(19851),s=i(87290),n=i(50213),a=i(28874),o=i(82261),l=i(15056),u=i(7311),c=i(44955),d=(0,r.lazy)((()=>(0,n.mkLogger)("db.CheckLocalDbReplica")));async function h({libraryDir:e=a.Settings.libraryDir.valueOrDefault,schema:t=l.Schemas.models}={}){return(await(0,o.cacheDbDir_)(e,t)).join(u.SqliteBase)}t.cacheDbFile_=h,t.getLiveDbDir_=async function(e=a.Settings.libraryDir.valueOrDefault){if(!a.Settings.forceLocalDbReplica.valueOrDefault){const t=(0,l.pathToDb)(await(0,s.setupLibraryDataDir_)(e),l.Schemas.models);try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!1}}catch(e){d().info("SQLite cannot directly write to the library: trying to use a local db replica.",{libraryDb:t,error:e})}}const t=await h({libraryDir:e,schema:l.Schemas.models});try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!0}}catch(e){return d().throw("SQLite cannot directly write to the library or the cacheDir.",{cacheDbFile:t,error:e})}}},5531:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},55332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupCold_=void 0;const r=i(19851),s=i(50213),n=i(76187),a=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbBackupCold")));t.dbBackupCold_=async function(e,t){await t.mkdirp_();const i=[];try{for(const r of(0,n.sqliteFiles)(e)){const e=t.join(r.base).wip();i.push(e),await r.copyFile_(e)}return a().tap({msg:"completed",level:"info",result:await Promise.all(i.map((e=>e.unwip_()))),meta:{srcDbFile:e,destDir:t}})}catch(e){throw await Promise.all(i.map((e=>e.unlink()))),e}}},91872:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleDbRetries_=void 0;const r=i(50213),s=i(70025),n=i(28874),a=i(45599),o=i(41400),l=i(30976),u=i(56038),c=(0,a.defer)((()=>(0,r.mkLogger)("db.DbRetries")));t.handleDbRetries_=function(e,t,i,r){const a=Date.now();let d=0;const h=a+n.Settings.maxBusyDbMs.valueOrDefault;return(0,u.time)(e,(async()=>{for(;Date.now()=h)throw c().error(e+": Caught db error. Not retrying.",{error:t}),t;{const i=(0,l.randomInt)(500,1500)*++d;c().warn(e+": Caught db error. Retrying in "+i+"ms.",{name:e,error:t}),r?.(),await(0,o.delay)(i)}}return t().close(),c().throw(e+": handleDbRetries(): timeout after "+n.Settings.maxBusyDbMs.valueOrDefault+"ms")}))}},12943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toDbValued=t.isDbValued=t.isDbValue=void 0;const r=i(79842),s=i(66649),n=i(40958),a=i(68708);function o(e){return null===e||(0,n.includes)(["number","string"],typeof e)}t.isDbValue=o,t.isDbValued=function e(t){return null!=t&&Array.isArray(t)?t.every(e):(0,a.entries)(t).every((([,e])=>o(e)))},t.toDbValued=function(e){return(0,a.mapFields)(e,((e,t)=>{if(!e.startsWith("$"))return"boolean"==typeof t?[e,t?1:0]:o(t)?[e,t]:(0,r.isDated)(t)?[e,(0,s.datedToMillis)(t)]:void 0}))}},65753:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maxBatchPluckSize=void 0;const r=i(19851),s=i(7282),n=i(28874);t.maxBatchPluckSize=(0,r.lazy)((()=>Math.round(n.Settings.dbBatchSelectSize.valueOrDefault*((0,s.isTest)()?.25:5))))},80632:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pageSizeBytes=t.mkdb_=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(54993),u=i(50213),c=i(23560),d=i(65211),h=i(29882),f=i(53265),m=i(66430),p=i(66184),g=i(28874),y=i(15674),v=i(87550);function w(){const e=g.Settings.dbPageSizeBytes.valueOrDefault;return Math.pow(2,(0,a.clamp)(1,28,Math.round(Math.log2(e))))}t.mkdb_=function({nativePath:e,timeoutMs:t=g.Settings.dbBusyTimeoutMs.valueOrDefault,logSql:i=g.Settings.logSql.valueOrDefault}){e=(0,f.resolve)(e),(0,h.mkdirpSync_)((0,r.dirname)(e));const b=(0,h.posixPathFromGrandparent)(e),S=(0,m.nativePathSizeSync)(e),P=(0,u.mkLogger)("db.mkdb("+b+")");if(null!=S){const E=Math.round(S/o.MiB),k=Math.ceil(1.5*E);k>g.Settings.dbCacheSizeMb.valueOrDefault&&(P.info("Dynamically setting dbCacheSize to "+g.Settings.dbCacheSizeMb.value,{db:e,dbFileSizeMb:E}),g.Settings.dbCacheSizeMb.envValue=k);const D=Math.round(1.5*E);D>g.Settings.maxMemoryMb.valueOrDefault&&(P.warn("Large database: setting maxMemoryDb to "+D+"MB",{dbFileSizeMb:E,"Settings.maxMemoryMb":g.Settings.maxMemoryMb.valueOrDefault}),g.Settings.maxMemoryMb.envValue=D)}P.info("Opening "+e+"...");const _={fileMustExist:!1,readonly:!1};if((0,a.gt0)(t)&&(_.timeout=Math.ceil(t)),i){const x=(0,u.mkLogger)("SQLite("+b+")"),C=(0,p.defaultLogLevel)();function F(e,...t){var i;(0,n.blank)(e)||x.log(C,(i=e,(0,l.toS)(i).replace(/\s{2,}/g," ")),{args:t})}_.verbose=F}const M=new v(e,_);P.info("Open. Setting PRAGMAs...");for(const A of(0,s.compact)(['encoding = "UTF-8"',"threads = "+(0,y.maxCpus)(),"foreign_keys = ON","page_size = "+w(),"trusted_schema = 0","cache_size = -"+Math.round(g.Settings.dbCacheSizeMb.valueOrDefault*o.MiB/1024),"locking_mode = NORMAL","journal_mode = WAL",(0,a.gt0)(g.Settings.dbBusyTimeoutMs.valueOrDefault)?"busy_timeout = "+g.Settings.dbBusyTimeoutMs.valueOrDefault:null,"temp_store = MEMORY","synchronous = "+g.Settings.dbSynchronousMode.valueOrDefault,"case_sensitive_like = 0","wal_autocheckpoint = "+((0,c.isDbJanitorService)()?(0,l.toS)(g.Settings.dbWalAutoCheckpoint.valueOrDefault):"0"),"auto_vacuum = "+g.Settings.dbAutoVacuumMode.valueOrDefault]))P.tapThunk({msg:"PRAGMA "+A,result:()=>M.pragma(A)});const T=M;return T.__uid=(0,d.uid)(),T},t.pageSizeBytes=w},99315:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},95704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withIdBatches=void 0;const r=i(40958),s=i(31586),n=i(59455),a=i(65753),o=i(51040);t.withIdBatches=async function(e){const t=(0,s.toGt0)(e.batchSize)??(0,a.maxBatchPluckSize)(),i=(0,o.dbValueToEscapedString)(e.primaryKeyColumnName),l=(0,r.compactBlanks)([i+" > :min",...(0,n.toA)(e.whereClauses)]).join(" AND "),u=e.db.prepare((0,r.compactBlanks)(["SELECT "+i,"FROM "+(0,o.dbValueToEscapedString)(e.tableName),"WHERE "+l,"ORDER BY "+i,"LIMIT :limit"]).join(" "));let c=-1;for(;;){const i=u.pluck().all({min:c,limit:t});if(0===i.length)return;await e.fn(i),c=(0,r.last)(i)}}},76187:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSqliteFile=t.sqliteSizeBytes=t.sqliteFiles=void 0;const r=i(17217),s=i(87391),n=i(7311);t.sqliteFiles=function(e){return[e,...s.SQLiteSuffixes.map((t=>e.sibling(e.base+t)))].filter((e=>e.existsSync({refresh:!0})))},t.sqliteSizeBytes=async function(e){return(await e.size({refresh:!0})??0)+(await e.sibling(e.base+"-wal").size({refresh:!0})??0)};const a=[n.SqliteExt,...[...s.SQLiteSuffixes,"-shm"].map((e=>n.SqliteExt+e))];t.isSqliteFile=function(e){const t=(0,r.basename)(e);for(const e of a)if(t.endsWith(e))return!0;return!1}},51040:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitBatchSql=t.dbValueToEscapedString=void 0;const r=i(40958),s=i(31586),n=i(54993),a=/^\w+$/;t.dbValueToEscapedString=function(e){if((0,s.isNumber)(e))return e.toString();const t=(0,n.toS)(e);return a.test(t)?t:`'${t.replace(/'/g,"''")}'`};const o=/--.+$/gm,l=/\s+/g;t.splitBatchSql=function(e){const t=(0,r.compactBlanks)((0,n.toS)(e).split(/;/).map((e=>e.replace(o,"").replace(l," ").trim()))),i=[];let s;for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertDirSQLiteReadWrite_=t.isDirSQLiteReadWrite=t.firstDirSQLiteReadWrite=void 0;const r=i(19851),s=i(50357),n=i(30976),a=i(50213),o=i(95696),l=i(80632),u=i(76187),c=(0,r.lazy)((()=>(0,a.mkLogger)("db.SQLiteReadWrite")));async function d(e){try{return await h(e),c().info("isDirSQLiteReadWrite(): true",{dirNativePath:e}),!0}catch(t){return c().warn("isDirSQLiteReadWrite(): false",{dirNativePath:e,error:t}),!1}}async function h(e){const t=o.PosixFile.for(e),i=(0,n.randomChars)(8),r=t.child(".test-"+i+".sqlite");let a=null;try{await t.mkdirp_(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3}),a.exec("CREATE TABLE t (s VARCHAR(16) NOT NULL)"),a.exec(`INSERT INTO t (s) VALUES ('${i}')`);{const e=a.prepare("SELECT s FROM t").all();(0,s.eql)(e,[{s:i}])||c().throw("unexpected rows",{rows:e})}a.exec("VACUUM"),a.close(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3});{const e=(0,n.randomChars)(8);a.exec(`INSERT INTO t (s) VALUES ('${e}')`);const t=a.prepare("SELECT s FROM t ORDER BY s").pluck().all();(0,s.eql)(t,[i,e].sort())||c().throw("unexpected rows",{rows:t})}}finally{try{a?.close()}catch{}await Promise.all((0,u.sqliteFiles)(r).map((e=>e.rm())))}}t.firstDirSQLiteReadWrite=async function(...e){for(const t of e)if(null!=t&&await d(t))return t},t.isDirSQLiteReadWrite=d,t.assertDirSQLiteReadWrite_=h},87391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SQLiteSuffixes=void 0,t.SQLiteSuffixes=["-wal","-journal"]},27180:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteVersion_=void 0;const r=i(5916),s=i(84777),n=i(89966),a=i(63870),o=i(87550);t.sqliteVersion_=(0,r.lazyAsync)({later:async function(){let e;try{e=new o(":memory:");const t=e.prepare("select sqlite_version()").pluck().get(),i=await(0,n.sqliteNativePath_)(),r=(await(0,s.stdout_)(i,["-version"],{timeoutMs:(0,a.commandTimeoutMs)()})).trim();return{libraryVersion:t,toolVersion:r.split(/\s+/,1)[0],fullToolVersion:r,sqliteNativePath:i}}finally{e?.close()}},timeoutMs:(0,a.commandTimeoutMs)()})},15056:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),s=i(7311);function n(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=n,t.pathToDb=function(e,t){return n(e,t).join(s.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const a=n(i(76760)),o=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),v=i(70698),w=i(64680),b=i(29882),S=i(45969),P=i(43334),_=i(28874),M=i(41692),T=i(32774),E=i(80612),k=i(32551),D=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function x(){if((0,S.isDocker)())return[{dir:"/tmp/.photostructure-cache"+D(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,a.join)(i,".photostructure-cache"+D()),preexistingDir:i});return e}}function C(){if((0,S.isDocker)())return(0,o.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,a.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:T.DefaultDockerLibraryDir+"/.photostructure/cache"+D(),preexistingDir:T.DefaultDockerLibraryDir},...x()]);const e=(0,o.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),a.default.resolve((0,k.homeDir)(),"AppData","Local")]:P.isMac?[a.default.resolve((0,k.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,a.join)((0,k.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,a.join)(e,t),preexistingDir:e})));return i.push(...x()),i}t.tmpCacheDirs=x,t.tmpDirs=function(){return(0,E.filterDirs)({dirs:x(),desc:"tmp"})},t.cacheDirs=C,t.defaultCacheDir=(0,d.lazy)((()=>(0,E.firstDir)({dirs:C(),desc:"cache"})));const F=(0,d.lazy)((()=>{(0,M.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(A)}));function A(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{F();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,b.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=A},46292:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),s=i(45969),n=i(41692),a=i(32774),o=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,n.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,s.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,o.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:a.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:a.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,s.isDocker)()?c:(0,o.desktopConfigDirs)()).map((e=>e.dir))}},79960:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultApplePhotosLibrary=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(45255),o=i(84777),l=i(16287),u=i(57902),c=i(43334),d=(0,r.lazy)((()=>(0,n.mkLogger)("dir.DefaultApplePhotosLibrary"))),h=["read","com.apple.photolibraryd","SystemLibraryPath"];t.defaultApplePhotosLibrary=async function(){if(c.isMac)try{const e=await(0,o.stdout_)("defaults",h,{timeoutMs:a.ShortCommandTimeoutMs});if((0,s.blank)(e))return void d().warn(`"defaults ${h.join(" ")}" returned blank (!!)`);{const t=await(0,l.isReadableDirectory)(e);return d().tap({msg:"defaultApplePhotosLibrary()",level:u.LogLevels.info,result:t?e:void 0,meta:{isReadable:t}})}}catch(e){return void d().warn("defaultApplePhotosLibrary()",e)}}},32774:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),s=i(45969),n=i(32774);t.defaultLibraryDir=function(){return(0,s.isDocker)()?n.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,s.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const s=r(i(76760)),n=i(40958),a=i(72993),o=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),s.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(s.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,o.env)().XDG_DATA_HOME,(0,o.env)().XDG_CONFIG_HOME,s.default.resolve((0,d.homeDir)(),".config")),(0,n.compactBlanks)(e).map((e=>({dir:s.default.join(e,(0,a.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),s=i(96706),n=i(29882);t.envConfigDir=function(){const e=(0,s.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,n.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),s=i(40958),n=i(22573),a=i(66430);function o({dirs:e,desc:t}){for(const{dir:i,preexistingDir:o}of(0,s.compact)(e))if(!(0,n.blank)(i)){if((0,a.isReadWriteableDirectorySync)(i))return i;if((0,n.blank)(o)||(0,a.isReadWriteableDirectorySync)(o))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=o,t.filterDirs=function({dirs:e,desc:t}){return(0,s.compact)(e.map((e=>o({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),s=i(76760),n=i(1708),a=i(19851),o=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,a.lazy)((()=>{const e=[];u.isWin?e.push(n.env.USERPROFILE):e.push(n.env.HOME);for(const t of(0,o.compactBlanks)(e)){const e=(0,s.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),s=i(49776),n=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[n.libraryDataDir,n.libraryPreviewsDir,s.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},48195:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotLibraryDir=t.isLibraryDir=void 0;const r=i(19851),s=i(22573),n=i(98553),a=i(12168),o=i(50213),l=i(15056),u=i(98314),c=i(17217),d=i(16287),h=i(2858),f=i(87290),m=(0,r.lazy)((()=>(0,o.mkLogger)("dir.IsLibraryDir")));function p(e){return null==e?"(null)":(0,n.stringify)((0,c.toNativePath_)(e))}async function g(e){return m().tap({msg:"whyNotLibraryDir("+e+")",result:await y(e)})}async function y(e){if((0,s.blank)(e))return"blank path";const t=(0,c.toNativePath_)(e);try{const e=await(0,d.stat_)(t);if(null==e||!e.isDirectory())return"not a directory"}catch(e){return"cannot read: "+(0,u.errorToS)(e)}const i=(0,f.libraryDataDirPosixFile)(t);if(!0!==await(i?.isDirectory({refresh:!0,logLevel:"trace"})))return"library data directory, "+p(i)+", is not a directory";const r=(0,h.librarySettingsFile)(t)?.clear();if(null==r||!await r.isNonEmptyFile())return"library settings, "+p(r)+", is empty or missing";const n=(0,l.pathToDb)(i,"models")?.clear();if(null==n||!await(n?.isNonEmptyFile(a.KB)))return"library database, "+p(n)+", is empty or missing";const o=(0,f.libraryPreviewsDirPosixFile)(t);return!0!==await(o?.isDirectory({refresh:!0,logLevel:"trace"}))?"library previews, "+p(o)+", is empty or missing":void 0}t.isLibraryDir=async function(e){return null==await g(e)},t.whyNotLibraryDir=g},9595:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),s=i(54993),n=i(29882),a=i(28874);function o(e){return(0,r.toNotBlank)((0,s.toS)(e))??a.Settings.libraryDir.valueOrDefault}t.libraryDir=o,t.originalsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,n.resolveMaybe)(o(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),s=i(55835),n=i(37805),a=i(15056),o=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${n.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function v(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+o.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function w(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function b(e){return y(w(e),!1)}function S(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(S(e))}function _(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function M(e){return y(_(e))}async function T(e){return y((0,s.map)(g(e),(e=>(0,a.pathToDbDir)(e,a.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await v(t);return(0,r.uniq)([t,i,await b(t),await P(t),await M(t),await T(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=v,t.libraryOriginalsDirPosixFile=w,t.setupLibraryOriginalsDir_=b,t.libraryPreviewsDirPosixFile=S,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=_,t.setupLibrarySyncReportsDir_=M,t.setupLibraryDbDir_=T},46296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),v=i(80612),w=i(32551);function b(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:s.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,a.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>s.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function S(){return(0,v.firstDir)({dirs:b(),desc:"logs"})}t.defaultLogDirs=b,t.defaultLogDir_=S,t.logDir=(0,n.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,o.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,o.notBlank)(i)?i:S()}catch(e){return console.error("defaultLogDir_() failed",e),s.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(44198),o=i(43334),l=i(24399),u=i(32551);async function c(){return o.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,s.lazy)((async()=>{if(o.isWin){const e=await c();if((0,n.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,s.lazy)((()=>(0,a.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),s=i(7282),n=i(29325),a=i(44198);t.getDevEnvFlag=function(e){return!(0,s.isProd)()&&!(0,n.isPacked)()&&((0,r.toBoolean)((0,a.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,a.env)()[e]=String(t)}},34580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),s=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,s.env)().DO_NOT_TRACK)}},44198:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const s=r(i(73024)),n=i(76760),a=r(i(1708)),o=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),v=i(6012),w=i(96706);t.env=(0,o.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>a.default.env[e])).join(n.delimiter).split(n.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===a.default.env.PS_LICENSE||e.push((0,n.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),i={...a.default.env};for(const r of e)try{const e=(0,d.debom)(s.default.readFileSync((0,p.resolve)(r))),n=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(n))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),s=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let n;for(const a of(0,s.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(n=e.exec(a));){if(null==n.groups)continue;const{key:e,val:s}=n.groups;if((0,r.blank)(e)||null==s)continue;const a=s.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=a}}return i}},96706:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const s=r(i(1708)),n=i(19851),a=i(22573),o=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,n.lazy)((()=>(0,a.firstNotBlank)(s.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,s.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,n.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,n.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,o.isTrue)(g(e))}},98314:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),s=i(19851),n=i(40958),a=i(22573),o=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),v=i(70025),w=i(57159);function b(...e){if((0,n.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(o.errorName),...e.map(o.errorCode),...(0,n.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(o.ErrorDelimiter)))];return(0,n.uniqSubstrings)(S((0,l.flatten)(i)))}function S(e){return(0,n.compact)(e).filter((e=>!o.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(a.notBlank)}function P(e,t){const i=(0,n.uniqSubstrings)(S(e)),r=t?.maxLen??400,s=t?.trailingChars??64,a=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(i.join(o.ErrorDelimiter)),r-a.length,s)+a.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,a.blank)(e)?"":P(b(e),t)}t.StartTs=Date.now(),t.logger=(0,s.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,a.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,a.notBlank)(i))return i}},t.splitErrorMessage=b,t.normalizeErrorMessages=S,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,a.blank)(e)&&(e=t.MissingError),_(e,{maxLen:i})+" at "+(0,o.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),s=i(26905),n=i(55835),a=i(54993),o=i(81168);t.describeError=function(e){const t=(0,o.stripSuffix)((0,a.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,n.map)((0,s.errorErrno)(i),(e=>t.push(u.get(e)))),(0,n.map)((0,s.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),s=i(76790),n=i(50989),a=i(68852);t.ErrorFlags=(0,n.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,s.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(a.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),s=i(38639),n=i(26905),a=i(54993),o=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,a.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,a.toS)(e)+(0,r.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,o.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function b(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function S(e){return!!((0,s.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||b(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=b,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===S(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,n.errorCode)(e)||v(e)||w(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=S;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,s.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,s.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},51837:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalError=void 0;const r=i(38835);class s extends Error{constructor(e){super(e+r.InternalErrorFlag)}}t.InternalError=s},8769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),s=i(31586),n=i(68708),a=i(7282),o=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,n.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const s=!0===i.fatal,c=!0===i.ignorable;if(!s&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),s&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!s||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!s||(0,a.isTest)()||(0,o.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),s}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,s.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,o.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,s.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,s.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(26905),o=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,s.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,s.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,a.errorName)(t)??(0,d.first)(this.causes,a.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(a.errorCode)],a.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,a.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,n.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,n.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,n.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,s.blank)(r)||(i=(0,h.dedupeNeedle)(i,r,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,o.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const a=i(49769),o=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),s.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,a.getOrSet)(n(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),a=n(this,r,"f").get(e);return null!=a&&(a.resolve(t),n(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,s=new WeakMap},34102:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),s=i(19851),n=i(15197);t.ee=(0,s.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new n.CapturingEventEmitter(e)}))},64660:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const s=r(i(73024)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,a.lazy)((()=>n.default.geteuid?.())),h=(0,a.lazy)((()=>n.default.getgroups?.()));function f(e,t){try{return!(0,o.blank)(e)&&(s.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,s.default.constants.R_OK|s.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,s.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:s,processGid:n}){if(null==e)return!1;const a=s??d(),o=null!=n?[n]:h()??[],l=0===a,u=l||e.uid===a,f=l||o.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const s=r(i(76760)),n=i(19851),a=i(81168),o=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,n.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,a.equalsIgnoreCase)(e.basename,i.base))return s.default.join(r,e.basename);throw new o.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),s=i(76760);function n(e){return[...a(e)]}function*a(e){for(;e!==(0,s.dirname)(e);)e=(0,s.dirname)(e),yield e}function o(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=o(e);return t.every((e=>i.includes(e)))}t.ancestors=n,t.ancestorG=a,t.selfAndAncestorG=function*(e){yield e,yield*a(e)},t.childrenSync=o,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return n(e).find((e=>l(e,t)))}},83278:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),v=f(i(1708)),w=i(46466),b=f(i(57975)),S=f(i(38522)),P=i(19851),_=i(40958),M=i(5233),T=i(22573),E=i(42659),k=i(50357),D=i(96249),x=i(98553),C=i(55835),F=i(31586),A=i(68708),I=i(97790),O=i(39926),L=i(51926),R=i(59455),N=i(54993),B=i(48884),j=i(22911),z=i(99331),V=i(56519),W=i(56038),U=i(31562),H=i(76850),q=i(70025),G=i(34102),$=i(80875),J=i(50213),K=i(70417),Y=i(43334),Z=i(81168),X=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),se=i(89968),ne=i(20197),ae=i(88561),oe=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),ve=i(27794),we=i(73428),be=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const Se=(0,P.lazy)((()=>new ae.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),s.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),a.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(s=new WeakMap,a=new WeakMap,r=new WeakSet,b.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,B.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,T.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=Se().get(i);if(null!=r)return r;const s=(0,fe.resolve)(i),n=new Pe(s,t);return Se().set(i,n),Se().set(s,n),n}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,s,"f").unset(),h(this,a,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,C.map)(this.statSync(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,s,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",n).call(this)??await d(e=this.clearThisAndParent(),r,"m",n).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,R.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,F.gt0)(t))return;const i=await d(this,s,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,k.eql)(["."],e)||e.every(T.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,C.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,O.pad2)(t+1),(0,O.pad2)(i))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,D.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,E.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),B.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>=(0,E.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>(0,E.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,C.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*E.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,oe.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,oe.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,$.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,$.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,H.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,be.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces),(0,A.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,M.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,z.ending)()?1:3,timeoutMs:0,retryDelay:E.secondMs,errorIsRetriable:q.isRetriableError})}async gunzip(){return d(this,r,"m",o).call(this,(0,Z.stripSuffix)(this.base,".gz"),S.default.createGunzip())}async gzip(){return d(this,r,"m",o).call(this,this.base+".gz",S.default.createGzip())}async compressBrotli(){return d(this,r,"m",o).call(this,this.base+".br",S.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,ne.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,ne.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(S.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,_.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new j.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,L.newlineRe)(),(r=>{const s=e.exec(r);null!=s&&(t.maybeResolve(s),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,F.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new j.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),_e)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,s)=>{try{const n=await e.f(r,(0,C.denull)(s));t(n)&&i.resolve(n)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,F.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,n=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,B.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,C.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},o=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*E.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},19748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const r=i(28874),s=i(88840),n=i(14036),a=i(29882);function o(e){return t=>r.Settings.respectFileExtensions.valueOrDefault?(0,n.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,a.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=o,t.isBrowserExtension=o(s.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=o(s.ExtTypes.Video),t.isAssetFileExtension=o(s.ExtTypes.AssetFile)},84542:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),s=i(96249),n=i(51926),a=i(54993),o=i(43334);function l(...e){return(0,s.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,a.toS)(e).split((0,n.newlineRe)()))))}t.Newline=o.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(a.toS).join("\n");return o.isWin?t.replace((0,n.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),s=i(19851),n=i(50213),a=i(37805),o=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,s.lazy)((()=>(0,n.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,o.mkdirp_)(i),await(0,d.writeTextfile_)((0,o.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+a.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,a.lazy)((()=>[...(0,o.mapNotBlankOr)(n.default.env.SYSTEMROOT,(e=>[e,s.default.join(e,"System32"),s.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const o=n(i(44652)),l=a(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),v=i(14427),w=i(17217),b=i(16287),S=i(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class M{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new M(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},s=await o.stat(t);return new M(i,new P(r,s))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return M.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new M(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>M.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new M(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,S.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,b.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await o.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await o.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=M},20197:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const s=r(i(76760)),n=i(39926),a=i(29882),o=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if(await(0,a.mkdirp_)(r.dir),!i.requireNumber&&await(0,o.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,o.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if((0,a.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},92423:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notInHiddenPhotoStructureDir=t.whyExcludedDirectoryRecursive=t.notExcludedDirs=t.isExcludedDirectory=t.whyExcludedDirectory=t.notExcludedDirPredicates=t.isExcludedFile=t.whyExcludedFile=t.notExcludedFilePredicates=t.excludeBundles=t.excludeGlobs=t.defaultFilePredicates=t.defaultDirPredicates=t.formatPathForGlob=void 0;const l=o(i(83058)),u=i(19851),c=i(40958),d=i(76790),h=i(22573),f=i(55835),m=i(51926),p=i(54993),g=i(48884),y=i(9092),v=i(54557),w=i(50213),b=i(88158),S=i(56519),P=i(46292),_=i(32551),M=i(35280),T=i(87290),E=i(96706),k=i(57902),D=i(43334),x=i(78984),C=i(33995),F=i(28874),A=i(21144),I=i(83278),O=i(48313),L=i(85772),R=i(78133),N=i(46356),B=i(17217),j=(0,u.lazy)((()=>(0,w.mkLogger)("fs.ExcludeGlobs"))),z=new v.FifoCache(256),V=/[\\/]$/;function W(e){const t=(0,p.toS)(e),i=z.get(t);if(null!=i)return i;const r=(0,B.isSimpleFile)(e)?e:I.BaseFile.for(e),s=V.test(t)||r.isDirectorySync(),n=(0,R.native2posix)(r.nativePath),a=s?(0,m.ensureSuffix)(n,"/"):n;return z.set(t,a),z.set(a,a),z.set(r.nativePath,a),a}t.formatPathForGlob=W;class U{constructor(e,t,i=!0){if(r.add(this),this.pattern=e,this.desc=t,this.exclude=i,e.includes("\\")){const t=e;e=(0,R.native2posix)(t),j().warn("globToPredicate(): backslash in patterns aren't supported: assuming you meant forward-slash?",{given:t,input:e})}this.reason=(0,c.compactBlanks)([this.exclude?"not":"",t,"("+(0,m.ellipsize)(e,48,12)+")"]).join(" ");try{this.re=l.default.makeRe(this.pattern,{nocase:F.Settings.globsCaseInsensitive.valueOrDefault,dot:!0,posixSlashes:!0}),this.valid=!0}catch(e){this.valid=!1,j().warn("Cannot parse pattern",{glob:this.pattern,error:e})}this.bundle=this.valid&&null!=this.re?(0,b.pairToObject)(this.reason,a(this,r,"m",s).bind(this)):{}}}r=new WeakSet,s=function(e){const t=W(e),i=this.re.test(t)??this.exclude;return j().tap({msg:"apply()",level:i?k.LogLevels.debug:k.LogLevels.trace,result:i?!this.exclude:this.exclude,meta:{desc:this.desc,pattern:this.pattern,exclude:this.exclude,posixPath:t,matched:i}})};class H{constructor(){n.set(this,[])}push(...e){for(const t of e){if(!t.valid){j().warn("Ignoring invalid glob",{glob:t});continue}const e=a(this,n,"f").find((e=>e.pattern===t.pattern));null==e?a(this,n,"f").push(t):j().debug("Ignoring duplicate glob",{glob:t,prior:e})}}pushNativePath(e,t){this.push(new U((0,R.native2posix)(e),t))}toA(){return a(this,n,"f")}}n=new WeakMap;const q=new U("**/.*","hidden file"),G=new U("**/.*/","hidden directory"),$=(0,u.lazy)((()=>{const e=new H;e.push(G,q);for(const t of[{s:"bin",desc:"command binary"},{s:"dev",desc:"device file"},{s:"etc",desc:"system configuration file"},{s:"initrd",desc:"initial ramdisk"},{s:"proc",desc:"process metadata"},{s:"sbin",desc:"system binary"},{s:"snap",desc:"snap software"},{s:"sys",desc:"system metadata"},{s:"Dell",desc:"Windows driver"},{s:"Drivers",desc:"Windows driver"},{s:"Intel",desc:"Windows driver"},{s:"Microsoft",desc:"Windows driver"},{s:"NVIDIA",desc:"Windows driver"},{s:"Windows.old",desc:"Windows system"},{s:"Windows",desc:"Windows system"}])e.push(new U((D.isWin?"*":"")+"/"+t.s+"/",t.desc));if(D.isWin)for(const t of["ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemRoot","windir"]){const i=(0,E.getEnv)(t);(0,h.blank)(i)||e.pushNativePath(i,`%${t}%`)}D.isLinux&&e.push(new U(`${(0,_.homeDir)()}/snap/`,"Snap software"));for(const t of[{s:"__MACOSX",desc:"macOS resource fork"},{s:"_includes",desc:"code"},{s:"@eaDir",desc:"Synology thumbnail"},{s:"@Recently-Snapshot",desc:"QNAP snapshot"},{s:"@Recycle",desc:"QNAP trash"},{s:"@SynoResource",desc:"Synology metadata"},{s:"#recycle",desc:"Synology trash"},{s:"#snapshot",desc:"Synology snapshot"},{s:"$Recycle.Bin",desc:"Windows trash"},{s:"$SysReset",desc:"Windows"},{s:"3rdParty",desc:"code"},{s:"Application Data",desc:"Windows apps"},{s:"Application Support",desc:"macOS apps"},{s:"Applications",desc:"macOS apps"},{s:"arangodb",desc:"3rd party"},{s:"cache",desc:"Cache directory"},{s:"CacheClip",desc:"Movie cache directory"},{s:"caches",desc:"Cache directory"},{s:"Chipset_Software",desc:"Windows apps"},{s:"cmake",desc:"code"},{s:"com.apple.TimeMachine.localsnapshots",desc:"macOS"},{s:"cpan",desc:"code"},{s:"DefinitelyTyped",desc:"TypeScript type"},{s:"Desktop DB",desc:"macOS metadata"},{s:"Desktop DF",desc:"macOS metadata"},{s:"Desktop.ini",desc:"macOS metadata"},{s:"DisplayDriver",desc:"Windows driver"},{s:"DLLs",desc:"Windows library"},{s:"dyld",desc:"macOS library"},{s:"ehthumbs.db",desc:"Windows thumbnail"},{s:"i18n",desc:"i18n code"},{s:"iMovie Cache",desc:"Apple iMovie cache"},{s:"iTunes Cache",desc:"Apple iTunes"},{s:"iTunes Media",desc:"Apple iTunes"},{s:"iTunes",desc:"Apple iTunes"},{s:"lib?(32|64|x64|s)",desc:"program library directory"},{s:"lost+found",desc:"fsck recovered directory"},{s:"macOS Install*",desc:"macOS installer"},{s:"Network Trash",desc:"AFP trash"},{s:"node_modules",desc:"Node.js library"},{s:"pkgconfig",desc:"code"},{s:"pkgs",desc:"Python code"},{s:"Program Files (x86)",desc:"Windows apps"},{s:"Program Files",desc:"Windows apps"},{s:"ProgramData",desc:"Windows application support"},{s:"resources/media/face",desc:"face thumbnail"},{s:"rubygems-*",desc:"Ruby code"},{s:"site-packages",desc:"Python code"},{s:"spotifycache",desc:"Spotify cache"},{s:"SteamApps",desc:"Game files"},{s:"System Volume Information",desc:"Windows system metadata"},{s:"System32",desc:"Windows system"},{s:"SystemTemp",desc:"Windows temporary"},{s:"temp",desc:"temporary"},{s:"Temporary Items",desc:"temporary"},{s:"test_suite",desc:"code"},{s:"testutil?(s)",desc:"code"},{s:"third_party",desc:"code"},{s:"Thumbnail?(s)",desc:"thumbnail"},{s:"Thumbs.db",desc:"Windows thumbnail"},{s:"tmp",desc:"temporary"},{s:"Trash",desc:"trash directory"},{s:"Windows",desc:"Windows"},{s:"Windows.old",desc:"Windows"},{s:"Windows10Upgrade",desc:"Windows upgrade"},{s:"Xcode.app",desc:"macOS code"},{s:"*.sparsebundle/bands",desc:"Time Machine backup"},{s:"ImageMagick*",desc:"ImageMagick source"},{s:"Install OS X*",desc:"macOS installer"},{s:"Install macOS*",desc:"macOS installer"},{s:"*.lrdata",desc:"LightRoom data"},{s:"MinGW*",desc:"code"},{s:"msys*",desc:"code"},{s:"vcpkg",desc:"code"}])e.push(new U("**/"+t.s+"/",t.desc));function t(t,i,r){if(!(0,h.blank)(t)){const s=(0,d.sort)((0,c.uniq)((0,c.compactBlanks)(i).map((e=>e.toLowerCase()))));1===s.length&&e.push(new U(`**/${t}/${s[0]}/`,r)),s.length>1&&e.push(new U(`**/${t}/(${s.join("|")})/`,r))}}(0,f.map)((0,P.configDir)(),(t=>e.pushNativePath(t,"PhotoStructure configuration"))),t("nix",["store"],"NixOS package"),e.push(new U("**/*.(photo|photos|ap)library/!(master|masters|modified|original|originals)/","Apple Photos/Aperture library")),e.push(new U("**/facetile*","face thumbnail"));const i=["bin","cygdrive","dev","etc","games","include","lib?(32|64|x64)","local","locale","man","proc","sbin","share","src","tmp","usr","var"];t("usr",i,"FHS system"),t("cygwin?(64)",i,"Cygwin"),t("local",i,"FHS system"),t("Windows",["assembly","Boot","Containers","Cursors","Fonts","Help","Installer","Logs","Microsoft.NET","Servicing","SoftwareDistribution","System32","SystemApps","SysWOW64","Temp","WinSxS"],"Windows"),t("Recovery",["Customizations","OEM"],"Windows"),t("lib",["firmware","modules","systemd","udev","x86_64-linux-gnu"],"Linux system package"),t("opt",["google","x11",...i],"FHS package"),t("lfs",["incomplete","objects"],"Git LFS object");const r=["cache","crash","games","lib","local","lock","log","logs","mail","run","snap","spool","tmp"];t("var",r,"Linux /var"),t("mnt",r,"Linux /mnt"),t("dev",["block","bsg","bus","char","cpu","disk","dri","fd","hugepages","input","lightnvm","mapper","mqueue","net","pts","shm","snd","ubuntu-vg","usb","vfio"],"Linux /dev backup"),t("proc",["acpi","asound","bus","driver","fs","ipmi","irq","net","scsi","self","sys","sysvipc","thread-self","tty"],"Linux /proc backup"),t("library",["Apple","Assistant","Bluetooth","com.apple.iTunesCloud","Containers","CoreAnalytics","Developer","Desktop Pictures","Documentation","Extensions","Finance","Fonts","Frameworks","FrontBoard","Group Containers","HTTPStorages","iTunes","KeyboardServices","Keychains","Logs","Messages","News","Passes","Photos","Preferences","Ruby","Saved Application State","Scripts","User Pictures","Updates","User Template","WebKit","WebServer"],"macOS Library"),t("packages",["*.pkg","*.mpkg"],"macOS package"),t("src/**",["bin","ci","dist","doc?(s)","etc","lib?(s)","main","spec?(s)","src","test?(s)","tools","util"],"code"),t("docs",["admin","content","general","generated","sql"],"code"),t("pkg",["acceptance","ccl","cli","cmd","server","sql","storage","ui","util","workload"],"code"),t("osv",["apps","arch","compiler","external","include","java","modules","musl","tests"],"code"),t("go",["bin","blog","cmd","doc","lib","misc","pkg","src","test","vt"],"code"),t("Perl?(64)",["bin","eg","etc","html","lib","site"],"code"),t("Python*",["dlls","doc?(s)","include","lib?(s)","scripts","tools","tcl"],"code"),t("Ruby*",["bin","include","lib","msys*","packages","share","ssl"],"code"),t("msys*",["clang*","dev","etc","mingw*","tmp","ucrt*","var"],"code"),t("sdk",["build-tools","emulator","extras","patcher","platforms","platform-tools","sources","tools"],"code"),t("test",["fixtures"],"code"),t("data",["$of"],"windows backup"),t("System",["Applications","Developer","DriverKit","Library","iOSSupport"],"macOS System"),t("contents",["frameworks","plugins","resources","sharedsupport"],"macOS application"),t("pg",["pgsql"],"code");for(const e of["local","locallow","roaming"])t("appdata",[e],"Windows default AppData");return t("ps",["cache","config","logs","tmp"],"PhotoStructure docker directory"),e.toA()})),J=()=>{t.excludeGlobs.unset(),t.excludeBundles.unset()},K=()=>{t.notExcludedDirs.unset()},Y=(0,u.lazy)((()=>{F.Settings.excludeGlobsOmitDefaults.watchLater(J),F.Settings.excludeGlobsAdd.watchLater(J),F.Settings.excludeGlobsOmit.watchLater(J),F.Settings.globsCaseInsensitive.watchLater(J),F.Settings.libraryDir.watchLater(K),F.Settings.originalsDir.watchLater(K),F.Settings.scanPaths.watchLater(K),F.Settings.argvScanPaths.watchLater(K)}));t.defaultDirPredicates=(0,u.lazy)((()=>[{notSymlinkLoop:re,notInHiddenPhotoStructureDir:ne,whyNoMedia:L.whyNoMedia,notHidden:se}])),t.defaultFilePredicates=(0,u.lazy)((()=>[{notInHiddenPhotoStructureDir:ne}])),t.excludeGlobs=(0,u.lazy)((()=>{Y();const e=new y.CaseInsensitiveMap;function t(t){if(null!=t&&t.valid){const i=t.pattern.trim();e.has(i)&&j().warn("Duplicate glob:",{glob:t}),e.set(i,t)}}function i(t){const i=t.trim();e.has(i)?e.delete(i):j().warn("Failed to find and remove glob specified in PS_EXCLUDE_GLOBS_OMIT",{glob:t})}if(!F.Settings.excludeGlobsOmitDefaults.valueOrDefault)for(const e of $())t(e);for(const e of F.Settings.excludeGlobsOmit.values)i(e);for(const e of F.Settings.excludeGlobsAdd.values)t(new U(e,"(from PS_EXCLUDED_GLOBS_ADD)"));const r=(0,d.sortBy)(e.values(),(e=>(0,c.compactBlanks)(e.pattern.toLowerCase().split("/")))),[s,n]=(0,g.partition)(r,(e=>e.pattern.endsWith("/")));return{dir:s,file:n}})),t.excludeBundles=(0,u.lazy)((()=>{const e=(0,t.excludeGlobs)();return{dir:[...(0,t.defaultDirPredicates)(),...e.dir.map((e=>e.bundle))],file:[...(0,t.defaultFilePredicates)(),...e.file.map((e=>e.bundle))]}}));const Z=[{disableAllFilters:()=>!0}],X=[{notBlank:()=>!1}];function Q(e){return F.Settings.disableAllFilters.valueOrDefault?Z:(0,h.blank)(e)?X:(0,t.excludeBundles)().file}function ee(e){return C.SyncPredicates.whyRejected(e,...Q(e))}function te(e){return F.Settings.disableAllFilters.valueOrDefault?Z:(0,h.blank)(e)?X:(0,t.excludeBundles)().dir}async function ie(e){return F.Settings.disableAllFilters.valueOrDefault?void 0:x.Predicates.whyRejected(e,...te(e))}function re(e){return!(0,N.seemsLikeSymlinkLoop)(e)}function se(e){return(0,S.thenNot)((0,O.isHidden)(e))}function ne(e){return!(0,M.inHiddenPhotoStructureDir)(e)}t.notExcludedFilePredicates=Q,t.whyExcludedFile=ee,t.isExcludedFile=function(e){return null!=ee(e)},t.notExcludedDirPredicates=te,t.whyExcludedDirectory=ie,t.isExcludedDirectory=async function(e){return null!=await ie(e)},t.notExcludedDirs=(0,u.lazy)((async()=>{const e=(0,c.uniq)((0,c.compactBlanks)([(0,T.libraryDirPosixFile)(),(0,T.libraryOriginalsDirPosixFile)(),...F.Settings.argvScanPaths.values,...F.Settings.scanPaths.values]));return j().tap({msg:"notExcludedDirs() (these directories will never be excluded)",level:"info",result:(0,c.uniq)([...e,...await Promise.all(e.map((e=>(0,A.actualPath)(e))))])})})),t.whyExcludedDirectoryRecursive=async function(e){const i=await(0,t.notExcludedDirs)();for(let t=e;null!=t&&!t.isRoot;t=await(t?.parent())){if(i.includes(t?.nativePath))return;const e=await ie(t);if(null!=e)return e}},t.notInHiddenPhotoStructureDir=ne},88561:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const a=i(40958),o=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>n(this,r,"m",s).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,a.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,r=new WeakSet,s=async function(e){if((0,o.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},79267:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCleanup=void 0;const c=i(19851),d=i(40958),h=i(42659),f=i(31586),m=i(71371),p=i(50213),g=i(7282),y=i(409),v=i(78406),w=i(25764),b=i(99331),S=i(91655),P=i(34102),_=i(89968),M=i(85772);class T{static for(e){return new T(e.name,e.rootNativePath,e.staleMs,e.isPrunable,e.minRetained)}constructor(e,t,i,a,d=0){r.add(this),this.name=e,this.rootNativePath=t,this.staleMs=i,this.isPrunable=a,this.minRetained=d,s.set(this,void 0),this.intervalMs=(0,c.lazy)((()=>(0,f.clamp)((0,g.isTest)()?0:5*h.minuteMs,h.dayMs,this.staleMs/2))),n.set(this,void 0),this.cleanup=(0,y.rateLimited)({name:this.name,minCallDelayMs:this.intervalMs()/4,f:()=>u(this,r,"m",o).call(this)}),l(this,s,(0,p.mkLogger)("fs.FileCleanup("+e+")"),"f")}scheduleInterval(){return(null==u(this,n,"f")||u(this,n,"f").ended)&&l(this,n,new v.EndableInterval({name:this.name,callback:()=>this.cleanup(),intervalMs:this.intervalMs(),rank:w.EndableRanks.first}),"f"),u(this,n,"f")}cancelInterval(){u(this,n,"f")?.end(),l(this,n,void 0,"f")}}t.FileCleanup=T,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(e){if(!(0,f.gt0)(this.minRetained))return new Set;const t=new m.BoundedGreatestSet(this.minRetained??0,(e=>e.mtimeMs()));return await e.visitDescendants((e=>{e.isFile()&&t.add(e)})),new Set(t.vacuum().map((e=>e.nativePath)))},o=async function(){try{if((0,b.ending)())return;const e=await this.rootNativePath();if(null==e)return[];const t=await _.DirectoryEntry.for(e);if(null==t)return[];u(this,s,"f").info("cleanup(): starting",{root:t,staleMs:(0,S.fmtFullDuration)(this.staleMs," ")});const i=await u(this,r,"m",a).call(this,t),n=Date.now()-this.staleMs,o=new Set,l=[],c=[];await t.clear().visitDescendants((async e=>{if((e.dir!==t.nativePath||!(0,M.isNoMediaName)(e.base))&&!i.has(e.nativePath)&&(o.has(e.nativePath)||!(0,f.gte)(e.mtimeMs(),n)))if(e.isDirectory())try{await e.rmdir_(),c.push(e.nativePath),o.add(e.dir)}catch(t){"ENOENT"===t.code&&(u(this,s,"f").warn("cleanup(): ENOENT "+e,t),(0,P.ee)().emit("clearCache")),"ENOTEMPTY"!==t.code&&u(this,s,"f").warn("cleanup(): failed to rmdir "+e,t)}else if(!1!==await(this.isPrunable?.(e)))try{await e.unlink_(),l.push(e.nativePath),o.add(e.dir)}catch(t){u(this,s,"f").warn("cleanup(): failed to clean up tmpfile "+e,t)}}));const h=[...l,...c];return(0,d.isNotEmpty)(h)&&t.clear(),u(this,s,"f").info("cleanup(): done",{root:t,pruned_file_count:l.length,pruned_dir_count:c.length}),h}catch(e){return void u(this,s,"f").error("cleanup() failed",{error:e})}}},32144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),s=i(22573),n=i(45599),a=i(96249),o=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,n.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,s.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,a.flatten)((0,o.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),s=i(17217),n=i(16287),a=i(68284);async function o(e){return(0,r.pick)(await(0,n.stat_)((0,s.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=o,t.fileStats=async function(e){try{return await o(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,a.statSync)((0,s.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const r=i(68817),s=i(19851),n=i(22573),a=i(50213),o=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),h=i(95696),f=i(93854),m=i(16287),p=(0,s.lazy)((()=>(0,a.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,f.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,r.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const s=(0,n.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),a=(0,l.normalizeExt)(h.PosixFile.for(e))??(0,c.mimetypeExt)(s);return(0,n.blank)(s)||(0,n.blank)(a)?void 0:{ext:a,mime:s}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new o.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,s.set(this,[]),n.set(this,void 0),a.set(this,void 0),l(this,a,(0,f.fileStatsSync)(e),"f"),l(this,n,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",o).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,s,"f").push(e)}close(){u(this,n,"f").close()}}t.FileWatcher=m,s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,a,"f"),t)){l(this,a,t,"f");for(const t of u(this,s,"f"))t(e,this.nativePath)}}},13829:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withFsAdvisoryLocks_=t.defaultFsAdvisoryLockDir=void 0;const r=i(55835),s=i(13538),n=i(81168),a=i(37628),o=i(46292),l=i(73209),u=i(95696);function c(){return(0,r.map)((0,o.configDir)(),(e=>u.PosixFile.for(e).join("advisory-locks")))}t.defaultFsAdvisoryLockDir=c,t.withFsAdvisoryLocks_=async function({name:e,lockNames:t,f:i,timeoutMs:r,lockDir:o=c()}){if(null==o)return i();await o.mkdirp_();const u=(0,n.sortIgnoreCase)(t).map((e=>l.FsLock.for({name:e,file:o.join((0,a.shortFsStringSha)(e)),timeoutMs:r})));try{for(const t of u)if(!0!==await(0,s.thenOrTimeout)(t.acquire_(),r))throw new Error("Failed to acquire lock for "+e+": "+t.opts.name+" was busy");return await i()}finally{for(const e of u)e.release()}}},73209:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,v,w,b=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},S=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const _=i(58587),M=P(i(44652)),T=i(87997),E=i(40958),k=i(17586),D=i(42659),x=i(50357),C=i(75240),F=i(55835),A=i(31586),I=i(30976),O=i(13538),L=i(54993),R=i(7282),N=i(68852),B=i(23560),j=i(25764),z=i(38836),V=i(99331),W=i(22781),U=i(38835),H=i(55222),q=i(63870),G=i(69734),$=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)(G.PsLockExt)+"$");class K extends z.EndableWrapper{static newUid(e=process.pid){return S(this,s,Math.max(Date.now(),b(this,s,"f",n)+1),"f",n),(0,E.compactBlanks)([H.TokenRadix.encode(b(this,s,"f",n)),B.serviceName.prior(),(0,L.toS)(e)]).join("-")}static pidFromLockfile(e){return s.pidFromBasename((0,$.basename)(e))}static pidFromBasename(e){return(0,A.toInt)(J.exec((0,L.toS)(e))?.groups?.pid)}static for(e){return b(this,s,"f",o).find((t=>t.opts.file===e.file))??new s(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>b(this,r,"m",w).call(this)),e.endableRank??j.EndableRanks.postdb,(0,q.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,S(t=s,s,(i=b(t,s,"f",a),++i),"f",a)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(b(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,G.fsLockFileBasename)(s.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await b(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,G.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+b(this,l,"f")),this.staleMs=(0,A.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),b(s,s,"f",o).push(this)}get acquired(){return b(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await b(this,r,"m",f).call(this,e)??b(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,k.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,x.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==b(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:D.secondMs);S(this,c,setInterval((()=>b(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=b(this,c,"f")&&(clearInterval(b(this,c,"f")),S(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(b(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),S(this,u,!1,"f"),(0,F.map)(b(this,d,"f"),(e=>(0,T.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?b(this,r,"m",v).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),S(this,d,setTimeout((()=>b(this,r,"m",v).call(this)),(0,A.toGt0)(this.staleMs)??D.secondMs),"f"),b(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(b(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,O.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,s=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,r=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,A.gt0)(this.staleMs)&&Date.now()>b(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await b(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){S(this,h,Date.now(),"f");const e=[],t=await b(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,A.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+D.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,G.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;s.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const n=i[0]===this.lockfile.base;if(n)S(this,u,!0,"f");else if(!0!==t?.vacuum){const t=s.pidFromBasename(i[0]);if((0,A.gt0)(t)&&!(0,_.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),b(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:n,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await b(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},v=async function(){await b(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},w=function(){(0,E.filterInPlace)(b(s,s,"f",o),(e=>b(e,l,"f")!==b(this,l,"f")))},n={value:0},K.internalErrors=0,a={value:0},o={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),s=i(51926),n=i(54993),a=i(17217);function o(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,s.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,s.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,n.toS)(e)))return;const i=(0,a.basename)(e);return o(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&o((0,a.basename)(e))}},4001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),s=i(55835),n=i(31586),a=i(51926),o=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,r.toNotBlank)(e.name)??(0,o.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,n.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:f(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const s=(0,u.parsePosixPath)(i),n=h(s,{aggressive:!1});return[...t,n+s.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,a.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),r=(0,a.stripPrefix)(t.toLowerCase().normalize(),i);return(0,s.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,a.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,s.map)(m.exec(t),(e=>t=e[1].trim())),(0,s.map)(g.exec(t),(e=>t=e[1].trim())),t}},19254:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fileGrep_=t.GrepReader=void 0;const s=r(i(73024)),n=i(57075),a=i(46466),o=i(54993),l=i(33456),u=i(17217),c=i(58722);class d extends n.Transform{constructor(e,t="\n"){super({objectMode:!1,autoDestroy:!0}),this.pattern=e,this.sep=t}_transform(e,t,i){const r=(0,o.toS)(e).match(this.pattern);null!=r&&this.push(r[1]??r[0]+this.sep),i()}}t.GrepReader=d,t.fileGrep_=async function(e,t){const i=new c.WritableToBuffer;return await(0,a.pipeline)([s.default.createReadStream((0,u.toNativePath_)(e)),new l.LineReader,new d(t),i]),(await i.buffer).toString()}},14977:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const s=r(i(44652)),n=r(i(73024)),a=i(46466),o=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,a.pipeline)(n.default.createReadStream(e,{autoClose:!0}),o.default.createGzip(),n.default.createWriteStream(t,{autoClose:!0})),await s.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const s=r(i(77598)),n=r(i(73024)),a=i(46466),o=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),v=i(16287),w=(0,o.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),b=(0,o.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function S(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=b().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),b().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await _(n.default.createReadStream(i)),stats:(0,u.pick)(await(0,v.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],i="sha512"){const r=s.default.createHash(i);return await(0,a.pipeline)([e,...t,r]),r.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:b,impl:P}),t.fileShaMeta_=S,t.fileSha_=async function(e){return(await S(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return s.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),s=i(42659),n=i(55835),a=i(31586),o=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,o.stdout_)("chflags",["hidden",t],{timeoutMs:10*s.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,n.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,o.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*s.secondMs}),i=(0,a.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),s=i(54993),n=i(7282),a=i(43334),o=i(69375),l=/^\/dev(?:\/|$)/i,u=a.isMac||(0,n.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=a.isMac||(0,n.isTest)()?/^\/private\//i:void 0,d=a.isMac||(0,n.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=a.isMac||(0,n.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,s.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,o.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},87128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonFileStore=void 0;const r=i(19851),s=i(55835),n=i(57159),a=i(50213);t.JsonFileStore=class{constructor(e,t,i){this.file=e,this.mkObject=t,this.onWrite=i,this.prior=(0,r.lazy)((()=>this.file.readJson("debug")))}async read_(){return await this.prior()??(0,s.map)(await this.mkObject(),(e=>this.write_(e)))}async write_(e){try{return await this.file.writeJson_(e,{spaces:2}),this.prior.set(Promise.resolve(e)),(0,a.mkLogger)("fs.JsonFileStore").info("wrote to "+this.file,e),null!=this.onWrite&&await this.onWrite(this.file,e),e}catch(e){throw new n.WrappedError("Failed to write to "+this.file,{cause:e,path:this.file.nativePath})}}}},33456:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),s=i(51926),n=i(54993);class a extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,n.toS)(e)).split((0,s.newlineRe)()),a=r.pop();this._prior=a??"";let o=!1;for(const e of r)o||(o=!this.push(e));o?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=a},64680:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const s=r(i(76760)),n=i(17217),a=i(73428);t.mkNoMedia_=function(e){return(0,a.writeTextfile_)(s.default.join((0,n.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},61704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nativePathsEql=t.nativePathsEqlSync=void 0;const r=i(21144),s=i(17217);t.nativePathsEqlSync=function(e,t){if(null==e||null==t)return!1;if(e===t)return!0;try{const i=(0,s.toNativePath_)(e),r=(0,s.toNativePath_)(t);return null!=i&&null!=r&&i===r}catch{return!1}},t.nativePathsEql=async function(e,t){try{return null!=e&&null!=t&&await(0,r.actualPath_)((0,s.toNativePath_)(e))===await(0,r.actualPath_)((0,s.toNativePath_)(t))}catch{return!1}}},85772:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const a=n(i(76760)),o=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),v=i(83278),w=i(70698),b=i(88561),S=i(65238),P=i(16287),_=(0,o.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),M="NoMedia",T=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(a.default.sep),"/"]).join("")+"])\\.?"+M+"$","im"),E=Object.freeze(["."+M,M]),k=Object.freeze((0,u.flatten)(E.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function D(e){return null!=T.exec(e)}t.isNoMediaName=D;const x=(0,o.lazy)((()=>new b.FileCache({name:"fs.noMediaDirsCache"})));async function C(e,t){if(null==e)return null;const i=v.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return D(i.base)||await(0,w.isCachedirTagFile)(i)?x().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):C(i.parent());{const e=await x().getOrSetAsync(i.nativePath,(()=>F(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:C(i.parent())}}async function F(e){if(D(e.base))return x().set(e.parent().nativePath,e.nativePath),_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,S.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,r=await Promise.race([A(e.nativePath,i),(0,S.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,w.isCachedirTagDirectory)(e)?_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(w.CACHEDIR_TAG).nativePath)}):null}async function A(e,t){for(const i of g.isCaseSensitiveFs?k:E){if(!0===t?.aborted)return null;const r=a.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return _().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function I(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(D(r.basename))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,a.join)(e,r.basename))});if(r.basename===w.CACHEDIR_TAG){const t=(0,a.join)(e,r.basename);if(await(0,w.isCachedirTagFile)(t))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await C(e,t)},t.whyNoMedia=C,t.whyNoMediaDir=F,t._dirHasNoMediaChild=A},29882:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),v=i(78133),w=i(53265),b=i(17217),S=i(16287),P=i(66430),_=i(5545);function M(e){return((0,b.isSimpleFile)(e)?e.base:n.default.basename(n.default.resolve(e))).startsWith(".")}t.logger=(0,a.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=M,t.containsHiddenPathname=function(e){return C(e).some(M)},t.isNotHiddenPosixPath=function(e){return C(e).every((e=>!M(e)))},t.resolveSimpleFile=function(e){return(0,b.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return E((0,v.posix2native)(e))},t.extname=function(e){return E(e).ext},t.dirname=function(e){return n.default.dirname((0,b.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(n.default.parse(e).ext,n.default.parse(t).ext)};const T=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function E(e){const t=T.exec(e)?.groups,i=t?.ext2??"",r=n.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function k(e){const t=n.default.parse((0,b.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,n.default.sep)}function D(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,b.toNativePath_)(e.ancestor),i=(0,b.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,n.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function x(e,t,i){if(null==t||null==i)return!1;const r=e(t),s=e(i);return null!=r&&null!=s&&(y.isLinux?r===s:(0,p.equalsIgnoreCase)(r,s))}function C(e){return(0,b.isSimpleFile)(e)?e.pathnames:e.split(n.default.sep).filter((e=>null!=e&&""!==e))}function F(e){return(0,u.notBlank)(e)&&C(e).length===(y.isWin?1:0)}function A({p:e,maxLength:t}){const i=(0,b.toNativePath_)(e);if(i.length<=t)return i;const r=C(e),s=[],n=[r.pop()];for(;r.length>0;)if(s.length=t){r.unshift(s.pop());break}}else if(n.unshift(r.pop()),O([...s,...n]).length>=t){r.push(n.shift());break}return r.length>0&&s.push("…"),O([...s,...n])}function I(e){return e.startsWith("\\\\")}function O(e){return(0,h.ensurePrefix)((0,o.compactBlanks)(e).join(n.default.sep),y.isWin?"":n.default.sep)}t.parseNativePath=E,t.parentBasename=k,t.grandParentBasename=function(e){return k(n.default.parse((0,b.toNativePath_)(e)).dir)},t.containedByNativePath=D,t.eqlBasename=function(e,t){return x(b.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return x(b.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return x(b.toNativePath_,e,t)},t.toPathnames=C,t.pathIsRoot=F,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:C(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,b.toNativePath_)(e),r=(0,b.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,v.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=A,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const s=[];for(const r of e.slice(0,i))s.push(A({p:r,maxLength:t}));return s.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return C(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return C(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=E(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,S.isReadableDirectory)(e))return;if(F(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await s.default.mkdirp(e)}catch(t){if(await(0,S.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;s.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>s.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,b.toNativePath_)(e).split(n.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=O,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:O(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>D({ancestor:t,descendant:e,acceptSelf:!0})?[(0,b.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),v=i(64660),w=i(21144),b=i(16287),S=(0,n.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const i=await(0,b.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,v.isStatRX)(i,e)}function M(){if(y.isWin){const e=(0,o.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,o.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,o.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,s.default.join(e,"System32"),s.default.join(e,"System32","Wbem"),s.default.join(i,"chocolatey","bin"),s.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function T(){const e=(0,h.toS)((0,m.env)().PATH).split(s.default.delimiter);return(0,a.uniq)((0,a.compactBlanks)([...e,...M()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,a.uniq)((0,a.compactBlanks)([...T(),...(0,d.toA)(i)]));for(const i of(0,a.uniq)((0,a.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=s.default.join(t,e);if(await _(i))return y.isLinux?i:(0,w.actualPath)(i)}}S().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){"use strict";var r,s,n,a=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return o(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),v=i(76790),w=i(5233),b=i(22573),S=i(42659),P=i(26905),_=i(75240),M=i(55835),T=i(31586),E=i(68708),k=i(13538),D=i(89937),x=i(12168),C=i(54993),F=i(48884),A=i(50213),I=i(45255),O=i(81168),L=i(56519),R=i(56038),N=i(31562),B=i(84777),j=i(9595),z=i(38835),V=i(70025),W=i(57902),U=i(55222),H=i(43334),q=i(33847),G=i(24399),$=i(28874),J=i(79915),K=i(45200),Y=i(34238),Z=i(87001),X=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),se=i(73209),ne=i(48313),ae=i(29882),oe=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,F.contextFilter)(function(e){return(0,v.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,A.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Y.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,L.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,L.thenMapOr)((0,X.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>H.isMac?(0,B.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,b.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,b.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,O.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,oe.toNativePath_)(e),r=new fe(i,t);return(0,O.isString)(e)&&he().set(e,r),he().set(i,r),r}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,L.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,ae.containedByNativePath)({ancestor:(0,j.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,ae.containedByNativePath)({ancestor:(0,j.originalsDir)(),descendant:this,acceptSelf:!0}))return H.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,M.map)((0,ee.bestMountpoint)(this.nativePath,await(0,X.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,M.map)((0,b.notBlankOr)(e,(()=>this.uri_())),Y.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,C.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===D.PS_LIBRARY_SCHEME?1:t.scheme===D.PS_LOCAL_FILE_SCHEME?2:t.scheme===D.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,O.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(H.isWin||H.isMac)return this.trap("hide",(async()=>(await(0,ne.hide_)(this),this)))}async hidden(){return(0,ne.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,O.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,F.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,M.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,E.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:s,skipWip:n=!1,skipFsLock:a=!1,retries:o=2,dirty:l=!1}){return(0,w.retryOnReject_)((async()=>{const o=await this.clear().isNonEmptyFile(i);if(!o){if(n&&a)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:a,minSizeBytes:i,timeoutMs:s,dirty:l})}return o&&r?void 0:this.utimes()}),{maxRetries:o,timeoutMs:2*s,retryDelay:3*S.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,T.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:s,dirty:n=!1}){return await this.parent().mkdirp_(),(0,se.withLock_)({file:this,skipFsLock:r,timeoutMs:s,dirty:n},(async()=>{const r=this.wip();try{await r.unlink("trace");const n=await(0,k.thenOrTimeoutError)(e(r),s);if(n===t.NoOp)return n;if(await(0,N.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),n;throw new Error(this+"applyWip(): still empty after waiting "+(0,_.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==$.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",s).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",n).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();$.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:S.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,T.clamp)(I.ShortCommandTimeoutMs,10*S.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,b.notBlank)(this.ext)&&(0,b.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,S.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,M.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,L.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,O.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,ae.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,ae.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,Z.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,r=new WeakSet,s=async function(e){let t,i=e;const r=e.wip();try{const s=await this.stat_();if(null==s)return this.pflog().throw("Can't copy missing files"+z.NonRetriableErrorFlag);if(s.size>0){if($.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+z.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,r.nativePath,h.default.constants.COPYFILE_FICLONE),s.size>5*x.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},s.size,(()=>r.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,T.approximates)(s.size,await r.size({refresh:!0}))),{intervalMs:S.secondMs,timeoutMs:S.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:s.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:s.birthtimeMs,mtimeMs:s.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,s.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${s.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,M.map)(t,(e=>e.end()))}},n=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),s=r?.size;return null==r||null==s?this.pflog().throw("Can't copy missing files"):(s>5*x.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},s,(()=>e.clear().size()))),H.isWin?await G.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,G.pwshQuote)(this.nativePath)} -Destination ${(0,G.pwshQuote)(i.nativePath)}`,(e=>e)):H.isMac?await(0,B.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,B.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+z.DoNotSendErrorFlag,{error:t})}finally{(0,M.map)(t,(e=>e.end()))}}},62105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.acceptFile=t.whyRejectFile=t.expensiveFileFiltersFor=t.acceptParentAndFileAndSimple=t.acceptFileSimple=t.whyRejectFileSimple=t.simpleFileFiltersFor=t.notFileTooBig=t.notFileTooSmall=t.notFileMissing=t.hasBrowserImgMimeType=t.notDimensionsTooSmall=t.requiredTagsFilter=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(54993),o=i(48884),l=i(56519),u=i(78984),c=i(28874),d=i(43207),h=i(47783),f=i(97573),m=i(16170),p=i(54979),g=i(1078),y=i(42231),v=i(83278),w=i(19748),b=i(92423),S=i(16287);function P(e){return async t=>(0,l.thenMapOr)((0,h.readRawTags)(t,!1),e,(()=>!1))}async function _(e){if(!(0,n.gt0)(c.Settings.minVideoDimension.valueOrDefault)&&!(0,n.gt0)(c.Settings.minImageDimension.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);if(null==t||!t.startsWith("image/")&&!t.startsWith("video/"))return!1;const i=t.startsWith("video/")?c.Settings.minVideoDimension.valueOrDefault:c.Settings.minImageDimension.valueOrDefault;return(0,n.gt0)(i)?(0,l.thenMapOr)((0,g.extractSizeInfoFromFile)(e),(e=>(0,n.gte)(e.ImageWidth,i)&&(0,n.gte)(e.ImageHeight,i)),(()=>!1)):null}async function M(e){if(!(0,n.gt0)(c.Settings.minVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.gte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.minVideoDurationSec.valueOrDefault):null)}async function T(e){if(!(0,n.gt0)(c.Settings.maxVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.lte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.maxVideoDurationSec.valueOrDefault):null)}async function E(e){return!(0,s.blank)(await(0,p.readMimeType)(e))}async function k(e){if(-100===c.Settings.rejectRatingsLessThan.valueOrDefault)return null;const t=await(0,h.readTags)(e),i=(0,n.toInt)(t?.Rating);return null==i||i>=c.Settings.rejectRatingsLessThan.valueOrDefault}async function D(e){return 0===c.Settings.keywordBlocklist.values.length?null:(0,f.rawTagKeywords)(await(0,h.readTags)(e)).every((e=>!0!==(0,y.leafIsExcluded)(e,c.Settings.keywordBlocklist.values)))}async function x(e){if(!c.Settings.requireMakeModel.valueOrDefault)return null;const t=await(0,h.readRawTags)(e);return null==t||(0,s.blank)(t.MIMEType)?null:t.MIMEType.startsWith("image/")?null!=t&&(0,s.notBlank)(t.Make)&&(0,s.notBlank)(t.Model):null}async function C(e){return(0,v.isBaseFile)(e)?e.exists():(0,S.exists)(e.nativePath)}async function F(e){const t=c.Settings.minAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.gte)(i,t)}async function A(e){const t=c.Settings.maxAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.lte)(i,t)}function I(e){return[{isSupportedFileExtension:w.isAssetFileExtension},...(0,b.notExcludedFilePredicates)(e),{notFileMissing:C},{notFileTooSmall:F,notFileTooBig:A}]}function O(e){return[...I(e),{notMissingMimeType:E},{supportedMimeType:m.isAssetFileMimeType},{notMissingMakeAndModelTags:x},{notDimensionsTooSmall:_},{notVideoTooShort:M},{notVideoTooLong:T},{notRejectedRating:k},{notExcludedKeyword:D}]}async function L(e,t){return await u.Predicates.whyRejected(e,...t??O(e))??await(0,b.whyExcludedDirectoryRecursive)(e.parent())}t.requiredTagsFilter=function(e){return P((t=>(0,o.allNotBlank)(...e.map((e=>t[e])))))},t.notDimensionsTooSmall=_,t.hasBrowserImgMimeType=P((e=>(0,r.includes)(["image/jpeg","image/png"],(0,a.toS)(e.MIMEType)))),t.notFileMissing=C,t.notFileTooSmall=F,t.notFileTooBig=A,t.simpleFileFiltersFor=I,t.whyRejectFileSimple=function(e){return u.Predicates.whyRejected(e,...I(e))},t.acceptFileSimple=function(e){return u.Predicates.accepted(e,...I(e))},t.acceptParentAndFileAndSimple=async function(e){const t=await e.parent();return null!=t&&!await(0,b.isExcludedDirectory)(t)&&await u.Predicates.accepted(e,...I(e))},t.expensiveFileFiltersFor=O,t.whyRejectFile=L,t.acceptFile=async function(e){return null==await L(e)}},78133:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const s=r(i(76760)),n=i(22573),a=i(81168);t.posix2native=function(e,t){if((0,n.blank)(e))return e;if(s.default.sep===s.default.posix.sep)return e;const i=(0,n.notBlank)(t)?s.default.sep+s.default.sep+t+s.default.sep:"",r=e.split(s.default.posix.sep);return(0,a.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(s.default.sep)},t.native2posix=function(e){return(0,n.blank)(e)||s.default.sep===s.default.posix.sep||s.default.posix.sep===s.default.sep?e:e.split(s.default.sep).join(s.default.posix.sep)}},43899:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,a.lazy)((()=>s.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,a.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(s.default.join((0,p.execDir)(),"resources"),s.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,o.compactBlanks)([(0,p.execDir)(),n.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const r=s.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),s=i(19851),n=i(31586),a=i(50213),o=i(57902),l=i(69428),u=(0,s.lazy)((()=>(0,a.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=o.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,n.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),s=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let n=-1;try{const s=i??(await(0,r.stat)(e)).size-t,a=Buffer.alloc(s);return n=await(0,r.open)(e,"r"),await(0,r.read)(n,a,0,s,t)}finally{(0,s.mapGte0)(n,r.close)}}},69428:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const a=n(i(73024));t.readFileSync=function(e){try{return a.readFileSync(e)}catch{}}},55690:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),s=i(84542);t.readLines_=async function(e){return(0,s.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class s extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=s},65238:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const s=r(i(51455)),n=i(76760),a=i(19851),o=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),v=i(28874),w=i(63870),b=i(88561),S=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,a.lazy)((()=>(0,n.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,a.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await s.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const M=(0,a.lazy)((()=>new b.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function T(e){(0,l.blank)(e)||M.prior()?.delete(e)}async function E(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await M().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,S.statTimeoutMs)(),r=k(e),s=await(0,h.thenOrTimeout)(r,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,S.statTimeoutMs)());if(s===f.Timeout&&(0,g.onTimeout)({soft:!1}),s!==f.Timeout&&s.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=T,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),M.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():T(e)))})),t.slowDirs=(0,a.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!M().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){T(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=M().get(e)},t.childDirectories_=async function(e){return(await E(e)).filter((e=>e.isDirectory)).map((t=>(0,n.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?E(e):k(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=E,t.readdirCached=function(e){return M().get(e)},t.readdirUncached_=k},53265:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const s=i(73024),n=r(i(76760)),a=i(40958),o=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,a.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=n.default.resolve(t,...e);if((0,s.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,o.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(o.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??n.default.resolve(...e))},t.execDir=(0,l.defer)((()=>n.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},46356:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.seemsLikeSymlinkLoop=void 0;const r=i(22454),s=i(28874),n=i(29882);t.seemsLikeSymlinkLoop=function(e){const t=new r.CountingSet;for(const i of(0,n.toPathnames)(e))t.incr(i.toLowerCase().normalize());return t.max()>s.Settings.maxDuplicatePathElements.valueOrDefault}},50274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),s=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,s.isBoolean)(e.isFile)&&(0,s.isBoolean)(e.isDirectory)}},17217:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const s=r(i(73024)),n=r(i(76760)),a=i(22573),o=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,a.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,a.blank)(e.nativePath))throw new Error(`toNativePath(${(0,o.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof s.default.Dirent?e.name:f(e)?e.base:n.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:n.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(n.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,o.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(s.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,o.blank)(e)?void 0:v(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function b(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function S(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=b(e),r=b(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],s=t[i],n=(0,u.diff)(S(r),S(s));if(null==n||n>1)return"unmatched "+i+": "+r+" ≠ "+s}}t.stat_=v,t.statMaybe=w,t.statToType=b,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const i=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await w(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,a.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const s=r(i(73024)),n=i(22573);function a(e){try{return(0,n.blank)(e)?void 0:s.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function o(e){return null==e||e.isFile()&&0===e.size}t.statSync=a,t.isEmptyStats=o,t.isFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=a(e);return t.emptyIsNew?null==i:o(i)},t.isNonEmptyFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===a(e)?.isDirectory()}},41080:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),s=i(56409);t.onDataChunked=function(e,t,i){const r=new n(t,i,!0);return r.read(e),r.done};class n{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new s.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=n},95705:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const s=r(i(57075)),n=i(41400),a=i(55835),o=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends s.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,n.delay)(50);try{(0,o.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,a.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends s.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const s=r(i(73024)),n=i(76760),a=i(22573),o=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,a.blank)(e))return!1;try{return s.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,o.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,a.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,a.notBlank)(t)){const e=(0,n.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,a.blank)(e)&&d((0,u.posix2native)(e))}},74128:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncReport=t.syncReport=t.recentSyncReports=t.ensureSyncReportReadme=t.syncReportReadme=t.syncReportDir=t.SyncReportHeaders=t.isRejectedState=t.SyncReportStates=t.SyncDirStates=t.FileDoneStates=t.SyncFileStates=t.AssetFileSyncStates=void 0;const p=i(51168),g=i(73024),y=i(4927),v=i(19851),w=i(40958),b=i(22573),S=i(42659),P=i(98553),_=i(31586),M=i(68708),T=i(50989),E=i(51926),k=i(85556),D=i(54993),x=i(89788),C=i(23467),F=i(7282),A=i(23560),I=i(77377),O=i(71567),L=i(73568),R=i(25764),N=i(38836),B=i(99331),j=i(12959),z=i(87290),V=i(46296),W=i(98314),U=i(38835),H=i(5012),q=i(32144),G=i(95696),$=i(36868),J=i(57902),K=i(28874),Y=i(84542),Z=i(73428);t.AssetFileSyncStates=(0,T.strEnum)("noop","deleted","skipped","synced","unknown"),t.SyncFileStates=(0,T.strEnum)(...t.AssetFileSyncStates.values,"canceled","rejected","failed","timeout","enqueued","started","copied","blocklisted","note"),t.FileDoneStates=(0,I.diff)(t.SyncFileStates.values,["enqueued","started","note"]),t.SyncDirStates=(0,T.strEnum)("scanning","canceled","failed","timeout","skipped","scanned"),t.SyncReportStates=(0,T.strEnum)(...t.SyncFileStates.values,...t.SyncDirStates.values),t.isRejectedState=function(e){return null==e||["canceled","deleted","failed","rejected","timeout","unknown"].includes(e)};const X={enqueued:"the file looks promising, and will be attempted to be imported soon.",rejected:"the file did not pass all import filters. The details column will explain why.",started:"the file was dequeued from the work queue, and is now going to be processed.",noop:"the current file metadata already matches your library database, so no operation was needed to sync this file.",deleted:"the file was determined to be deleted (the prior mountpoint exists, but the file doesn't exist anymore)",skipped:"the file lives on a volume that isn't currently mounted.",synced:"the file was imported.",blocklisted:"the file was blocklisted and files with the same SHA will not be imported in the future.",failed:"something went wrong. The details column will explain why.",timeout:"the file wasn't processed in a reasonable amount of time.",copied:'"automatic organization" is enabled (copyAssetsToLibrary=true), and the photo or video was copied into your library originals directory. The details column will contain the source file path.',note:"sidecars will be referenced here. The details column will specify which source file(s) it will be associated with.",canceled:"PhotoStructure was shut down while the file was processed.",unknown:"an internal error occurred during processing."},Q={scanning:"the directory contents are about to be read.",scanned:"the directory contents were completely processed.",skipped:"the directory was excluded. The details column will explain why.",canceled:"PhotoStructure was shut down before the directory was processed.",failed:"reading the directory contents failed.",timeout:"reading the directory contents took too long."};function ee(e){return(0,M.entries)(e).map((([e,t])=>` - "${e}": ${t}`)).join("\n")}const te=new Set([t.AssetFileSyncStates.deleted,t.SyncFileStates.failed,t.SyncFileStates.timeout,t.SyncDirStates.canceled]);function ie(){return(0,z.librarySyncReportsDir)()??G.PosixFile.for((0,V.logDir)()).join("sync-reports")}function re(){return ie().join("README.txt")}t.SyncReportHeaders=(0,T.strEnum)(...(0,M.keys)(new class{constructor(e,t,i,r,s,n,a,o,l={}){this.ts=e,this.at=t,this.path=i,this.state=r,this.from=s,this.elapsedMs=n,this.details=a,this.url=o,this.meta=l}}(0,"","","unknown","",0,"",""))),t.syncReportDir=ie,t.syncReportReadme=re,t.ensureSyncReportReadme=(0,v.lazy)((()=>(0,Z.writeTextfile_)(re().nativePath,(0,E.wrap)(`\n\nHowdy from PhotoStructure!\n\nThis directory contains your recent "sync reports". \n\nThese files are written as your scan paths are examined for photos and videos.\n\nPhotoStructure creates a new file when it restarts and when it completes importing a given scan path directory.\n\nThese CSV files can be opened with most spreadsheet applications, like LibreOffice.\n\n\nColumn descriptions\n===================\n\nThe "ts" column is the timestamp for the row, in millis from 1970-01-01. Most spreadsheet applications don’t know how to parse these values, though, so we also add the at column.\n\nThe "at" column is ts in ISO format with only second resolution, and should be parsable by most spreadsheet software.\n\nThe "path" column is the native path of the directory or file. It will be empty for messages about system state.\n\nThe "state" column explains why that row was added.\n\nThe "from" column specifies which codepath added the sync report row.\n\nThe "elapsedMs" column is only added to rows completing a given path, and records how long that process took.\n\nThe "details" column will include information about the path, like why a given file or folder were rejected.\n\nThe "url" column is only added to rows when a file or directory is imported. You may need to adjust the domain name of the URL to make it work correctly (it defaults to localhost).\n\n\nDirectory state values\n======================\n\nThe "state" column for directories will be\n\n${ee(Q)}\n\n\nFile state values\n=================\n\nThe "state" column for files will be\n\n${ee(X)}\n\n\nSee https://photostructure.com/go/sync-reports\n\n`,{maxLineLen:80}).join("\n")))),t.recentSyncReports=async function(e=S.dayMs){const t=Date.now()-e;return ie().descendants((async e=>(0,q.isCsvExt)(e)&&(0,_.gte)(e.mtimeMs(),t)))},t.syncReport=(0,v.lazy)((()=>new se));class se extends N.EndableWrapper{constructor(){super("fs.SyncReport()",(()=>f(this,r,"m",d).call(this)),R.EndableRanks.predb),r.add(this),s.set(this,void 0),n.set(this,void 0),a.set(this,void 0),o.set(this,0),l.set(this,0),this.outputFiles=new x.BoundedList(64),(0,t.ensureSyncReportReadme)()}get outputNativePath(){return f(this,s,"f")?.nativePath}get rowCount(){return f(this,l,"f")}onProgress(e){if(null==e||(0,b.blank)(e.state))return this.logger.error(".onProgress(): invalid input",{s:e,from:(0,H.stack)()});{this.logger.log(te.has(e.state)?J.LogLevels.warn:J.LogLevels.info,"onProgress()",e);const t=Date.now(),i={path:(0,D.toS)(e.path),state:e.state,details:(0,D.toS)(e.details).trim().replace(/\r?\n/g,"; ")},s={ts:t,at:new Date(t).toISOString(),...i,...(0,M.pick)(e,"from","elapsedMs","url")};(0,M.isEmptyObj)(e.meta)||(s.meta=(0,P.stringify)(e.meta)),(0,F.isTest)()&&process.stdout.write((0,P.stringify)(e)+Y.Newline),f(this,r,"m",u).call(this,s)}}maybeSystemData(e){(0,A.isSyncService)()&&this.onProgress(e)}async wrap_({path:e,from:i,fn_:r}){const s=Date.now();this.onProgress({path:e,from:i,state:t.SyncFileStates.started});try{const n=await r(),a=n.state??(null!=n.error?t.SyncFileStates.failed:t.SyncFileStates.unknown);return a===t.SyncFileStates.unknown&&this.logger.error(i+" returned result with no state!"+U.InternalErrorFlag,{path:e,result:n}),this.onProgress({path:e,from:i,elapsedMs:Date.now()-s,...n,state:a}),n}catch(r){throw this.logger.warn("wrap_() caught error",{error:r}),this.onProgress({path:e,from:i,state:(0,B.ending)()||r instanceof L.AbortError?t.SyncFileStates.canceled:r instanceof k.TimeoutError?t.SyncFileStates.timeout:t.SyncFileStates.failed,details:(0,B.ending)()?void 0:(0,W.errorToS)(r),elapsedMs:Date.now()-s}),r}}get output(){return f(this,n,"f")??f(this,r,"m",h).call(this)}async flushClose(){return f(this,r,"m",u).call(this),this.close()}async close(){this.logger.info("Closing sync report");const e=f(this,n,"f");return m(this,n,void 0,"f"),m(this,l,0,"f"),await(0,$.endStream)(e),null==e?void 0:f(this,s,"f")}}t.SyncReport=se,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,r=new WeakSet,u=function(e){var t;const i=f(this,a,"f");if(m(this,a,e,"f"),null!=e&&(0,C.eqlPicked)(e,i,"path","state","details"))return this.logger.debug("deduping row",e),void m(this,o,(t=f(this,o,"f"),t++,t),"f");null!=i&&(0===f(this,o,"f")?f(this,r,"m",c).call(this,i):(f(this,r,"m",c).call(this,{...i,details:(0,w.compactBlanks)([i.details,`(repeated ${f(this,o,"f")+1} times)`]).join(" ")}),m(this,o,0,"f")))},c=function(e){var i;const r=(0,y.unparse)([e],{header:!1,columns:t.SyncReportHeaders.values});this.output.write(r+Y.Newline,(e=>{null!=e&&this.logger.error("Failed to write",e)})),m(this,l,(i=f(this,l,"f"),++i),"f")>K.Settings.syncReportMaxRows.valueOrDefault&&this.close()},d=function(){return this.logger.info("sync report ended",{rowCount:f(this,l,"f"),outputFiles:this.outputFiles}),this.flushClose()},h=function(){return m(this,s,function(){const e=p.DateTime.now();return ie().join(e.toFormat("y-MM-dd"),(0,j.filestamp)()+"-sync-report.csv")}().ensureNewSync_({emptyIsNew:!1}),"f"),this.outputFiles.push(f(this,s,"f").nativePath),this.logger.info("Opening new report: "+f(this,s,"f")),(0,F.isTest)()&&(0,O.stdoutWrite)({syncReport:f(this,s,"f").nativePath},!1),m(this,n,(0,g.createWriteStream)(f(this,s,"f").nativePath),"f"),f(this,n,"f").write((0,y.unparse)([t.SyncReportHeaders.values],{header:!1})+Y.Newline),f(this,n,"f")}},89966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const s=r(i(48161)),n=i(19851),a=i(55835),o=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),h=i(8103),f=i(43899);function m(){return(0,a.map)(f.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,a.map)(m(),(e=>e.join(c.platformName+"-"+s.default.arch())))}async function g(e){if(c.isWin&&(e=(0,o.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,h.pathIfExists)(m()?.join("bin",e))),(()=>(0,h.pathIfExists)(m()?.join(e))),(()=>(0,h.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,h.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,n.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,n.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,n.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,n.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const s=r(i(44652)),n=i(19851),a=i(22573),o=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,o.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,a.blank)(t.file))throw new Error("can't touch blank path");const r=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const o=(0,n.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await o())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await o())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(s.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(n){if(!i||"ENOENT"!==n.code)throw n;await(0,c.thenOrTimeoutError)(s.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},79847:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.trashOrUnlinkFileUri=t.trashOrUnlinkFileUris_=void 0;const o=n(i(51455)),l=a(i(49378)),u=i(40958),c=i(22573),d=i(13538),h=i(83104),f=i(45255),m=i(31562),p=i(98314),g=i(34102),y=i(28874),v=i(45200),w=i(16287),b=i(74128),S=i(84258),P="fs.Trash";async function _(e){const t=Date.now(),i=y.Settings.commandTimeoutMs.valueOrDefault,r=(0,c.toNotBlank)(e.nativePath)??await(0,d.thenOrTimeout)((0,v.uri2nativePath)(e.uri,e.mountpoint),i);if((0,c.blank)(r)||r===h.Timeout)return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not convert URI to native path",path:e.uri,elapsedMs:Date.now()-t}),{uri:e.uri,unlinked:!1};const s=await(0,w.statMaybe)(r);if(null==s)return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: no such file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(!s.isFile())return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: not a file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(y.Settings.trySoftDeletes.valueOrDefault)try{if(await(0,d.thenOrTimeoutError)((0,l.default)(r,{glob:!1}),i),await function(e){return(0,m.untilTrue)((async()=>null==await(0,w.statMaybe)(e)),{timeoutMs:f.ShortCommandTimeoutMs})}(r))return(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Moved file to trash",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0};(0,S.logger)().warn("soft-delete("+r+") didn't seem to work: the file is still there?")}catch(e){(0,b.syncReport)().onProgress({from:P,state:"note",details:"Failed to soft-delete file to trash: "+(0,p.errorToS)(e),path:r,elapsedMs:Date.now()-t}),(0,S.logger)().warn("Tried to soft-delete, but that failed. We'll try to hard-delete.",{error:e})}try{return await(0,d.thenOrTimeoutError)(o.unlink(r),i),(0,g.ee)().emit("fileChanged",r),(0,S.logger)().info("unlink("+r+") successful"),(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Permanently deleted file",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0}}catch(i){return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not move file to trash or delete: "+(0,p.errorToS)(i),path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!1}}}t.trashOrUnlinkFileUris_=async function(e){const t=[];for(const{uri:i,mountpoint:r}of(0,u.uniqBy)(e,(e=>e.uri)))try{t.push(await _({uri:i,mountpoint:r}))}catch(e){t.push({uri:i,unlinked:!1,error:e})}return t},t.trashOrUnlinkFileUri=_},70854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryUidStore=t.LibraryUIDStore=t.SystemUIDStore=t.UIDStore=t.mkuid=void 0;const r=i(19851),s=i(41400),n=i(55835),a=i(92782),o=i(37805),l=i(46292),u=i(34102),c=i(55222),d=i(28874),h=i(87128),f=i(95696);function m(){return(0,a.safeRandomUid)({radix:c.TokenRadix,chars:24,splitEveryN:4})}t.mkuid=m;class p extends h.JsonFileStore{constructor(e,t){super(e.join("."+t+"-uid.json"),(()=>({uid:m(),version:o.version,type:this.type,createdAt:Date.now()})),(e=>e.hide())),this.rootDir=e,this.type=t,this.readUid_=(0,r.lazy)((async()=>(await this.read_())?.uid))}}function g(e=d.Settings.libraryDir.valueOrDefault){return(0,n.map)(f.PosixFile.forMaybe(e),(e=>new p(e,"library")))}t.UIDStore=p,t.SystemUIDStore=(0,r.lazy)((()=>(0,n.map)((0,l.configDir)(),(e=>new p(f.PosixFile.for(e),"system"))))),t.LibraryUIDStore=(0,r.lazy)(g),t.libraryUidStore=g,(0,s.later)((()=>{(0,u.ee)().on("clearCache",(()=>{t.SystemUIDStore.unset(),t.LibraryUIDStore.unset()})),d.Settings.libraryDir.watchLater((()=>t.LibraryUIDStore.unset()))}))},84258:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const a=n(i(51455)),o=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,o.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const r of(0,l.toA)(e))try{null!=r&&await a.unlink((0,c.toNativePath_)(r))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+r,{error:e})}}},5545:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const s=r(i(76760)),n=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,n.toS)(i.path??s.default.sep)}},70257:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),s=i(45255),n=i(17217);t.WipTimeoutMs=s.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const a=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(a,"")},t.isWip=function(e){return a.test((0,n.basename)(e)??"")}},58722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),s=i(22911);class n extends r.Writable{constructor(e){super(e),this.deferred=new s.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=n},73428:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(51926),o=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=n.default.dirname(e);await(0,c.mkdirp_)(i),await s.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=n.default.dirname(e);(0,c.mkdirpSync_)(i),s.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,a.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))}},13047:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const s=r(i(73024)),n=i(76760),a=i(46466),o=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await S(e,t)).toString()}async function b(e,t,i){const r=[],n=[s.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?n.push((0,o.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&n.push((0,o.createBrotliDecompress)().on("error",(e=>r.push(e)))),n.push(t),await(0,a.pipeline)(n),(0,u.isNotEmpty)(r))throw new f.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function S(e,t){const i=new y.WritableToBuffer;return await b(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await S(e))}async function _(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,n.parse)(e).dir),await(0,a.pipeline)(new g.ReadableBuffer(i),(0,o.createGzip)(),s.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=b,t.zCopyToBuffer_=S,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void v().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await _(e,t)}catch(t){v().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},60526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.exiftoolHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(98314),a=i(47783),o=i(63335),l=i(18454);t.exiftoolHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Tools",id:"tools-exiftool",ordinal:1,pendingMsg:"Checking ExifTool…",settings:[],later:async()=>{try{const e=await(0,a.exiftoolVersion_)();return{level:"ok",msg:["ExifTool is OK","ExifTool "+(0,o.ver)(e),(0,r.tt)((0,a.exiftool)().options.exiftoolPath)],meta:{exiftoolVersion:e}}}catch(e){return{level:"error",msg:"Something's amiss with ExifTool: "+(0,n.errorToS)(e)}}}})))},19652:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.externalDirectoryCheck=void 0;const a=i(51455),o=n(i(22915)),l=i(40958),u=i(82950),c=i(22573),d=i(45599),h=i(12168),f=i(50213),m=i(79960),p=i(32551),g=i(98314),y=(0,d.defer)((()=>(0,f.mkLogger)("health.externalDirectoryCheck")));t.externalDirectoryCheck=async function(){const e=(0,l.uniq)([(0,p.homeDir)(),o.getHomeFolder(),o.getPicturesFolder(),o.getVideosFolder(),o.getDesktopFolder(),await(0,m.defaultApplePhotosLibrary)()]).sort(),t=new Map,i=(0,l.uniq)(e.filter(c.notBlank)).sort();for(const e of i)try{await(0,a.readdir)(e,{withFileTypes:!0})}catch(i){if(["ENOTDIR","ENOENT"].includes(i?.code))continue;t.set(e,i)}const r=0===t.size?{level:"ok",msg:["Default media directories are OK","The following directories are readable:",(0,u.li)(i.map(u.tt))]}:{level:"warn",msg:["Error reading "+(0,h.plur)(t.size,"media directory")+":",(0,u.li)([...t.entries()].map((([e,t])=>(0,u.tt)(e)+":"+(0,g.errorToS)(t,{maxLen:80}))))]};return y().tap({msg:"externalDirectoryCheck",result:r})}},79483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.externalDirsHealthCheck=void 0;const r=i(45599),s=i(45969),n=i(19652),a=i(18454);t.externalDirsHealthCheck=(0,r.defer)((()=>(0,s.isDocker)()?void 0:a.HealthCheck.for({section:"System",id:"media-directories",pendingMsg:"Checking default photo directories…",settings:[],later:n.externalDirectoryCheck})))},63664:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRemoteOrLocalHealthSummarySync=t.getRemoteOrLocalHealthSummary=t.getLocalHealthSummary=t.getRemoteHealthSummary=void 0;const r=i(22573),s=i(45599),n=i(41400),a=i(50268),o=i(98553),l=i(50213),u=i(23560),c=i(45255),d=i(5916),h=i(28874),f=i(34238),m=i(51140),p=i(4988),g=i(18454),y=(0,s.defer)((()=>(0,l.mkLogger)("health.GetHealthSummary")));t.getRemoteHealthSummary=(0,d.lazyAsync)({later:async()=>{try{if((0,u.isWebService)())return;const e=await(0,p.get_)(f.URI.from({scheme:"http",authority:"127.0.0.1:"+h.Settings.httpPort.valueOrDefault,path:"/api/health"}),{timeoutMs:c.ShortCommandTimeoutMs}),t=(0,o.parseJSON_)(e.data);if(m.HttpStatusIs.ok(e.statusCode)&&(0,a.isHealthCheckSummary)(t))return"ready"===t.state&&(0,r.toNotBlank)(t.libraryDir)!==(0,r.toNotBlank)(h.Settings.libraryDir.valueOrDefault)&&(y().error("getHealthSummary(): libraryDir mismatch! Switching to that library directory...",{local:h.Settings.libraryDir.valueOrDefault,remote:t.libraryDir}),h.Settings.libraryDir.value=t.libraryDir),y().debug("getHealthSummary()",{response:e}),t;y().warn("getHealthSummary(): invalid response",{response:e})}catch(e){y().warn("Failed to get health check summary from web service",{error:e})}}}),t.getLocalHealthSummary=(0,d.lazyAsync)({later:()=>g.HealthCheck.awaitSettled()}),(0,n.later)((()=>{h.Settings.healthCheckIntervalMs.watch((e=>{t.getRemoteHealthSummary.setTTL(e),t.getLocalHealthSummary.setTTL(e)}))})),t.getRemoteOrLocalHealthSummary=async function(){return await(0,t.getRemoteHealthSummary)()??await(0,t.getLocalHealthSummary)()},t.getRemoteOrLocalHealthSummarySync=function(){return t.getRemoteHealthSummary.syncValue()??t.getLocalHealthSummary.syncValue()}},18454:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,v,w,b,S,P,_=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},M=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const T=i(19851),E=i(40958),k=i(76790),D=i(41400),x=i(50357),C=i(26905),F=i(50268),A=i(55835),I=i(68708),O=i(30976),L=i(51926),R=i(13538),N=i(42279),B=i(59455),j=i(54993),z=i(48884),V=i(89788),W=i(22454),U=i(50213),H=i(69591),q=i(22911),G=i(99331),$=i(5916),J=i(42638),K=i(77740),Y=i(98314),Z=i(70025),X=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),re=i(21525),se=i(82638),ne=(0,T.lazy)((()=>(0,U.mkLogger)("health.HealthCheck")));class ae{static traceLater_(e,t){const i=new q.Deferred(e);i.catch((t=>{_(this,s,"f",l).push(e+": failed: "+(0,Y.errorToS)(t)),this.onResultChange()})),_(this,s,"m",o).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return _(this,s,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){_(this,s,"f",l).push((0,L.isString)(e)?e:(0,Y.errorToS)(e)),this.onResultChange()}static lastErrors(){return _(this,s,"f",l).toA()}static addLoadingMsg(e){_(this,s,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,E.compact)((0,B.toA)(e)).map(j.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return ne().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:_(this,s,"f",h).entriesByCountDesc()}),(0,A.map)((0,z.leastBy)(e,(e=>[_(this,s,"f",h).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=_(this,s,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,A.map)(e,(e=>_(this,s,"f",h).incr(e.msg))),ne().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return X.Settings.skipHealthCheckIds.envValue=t,s.reset()}static findById(e){return _(this,s,"f",f).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,F.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=_(this,s,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=s.summary();if(e.pendingCount>0){const t=await Promise.all(s.testResultsCritical());e=s.summaryFromResults(t),ne().info("awaitSettled(): summary result",{summary:e,results:t})}return ne().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){s.summary.unset()}static reset(){if((0,G.ending)())ne().warn("Rejecting reset() when ending()",(0,C.shortStack)());else{this.onResultChange(),_(this,s,"f",l).clear(),_(this,s,"f",d).clear(),_(this,s,"f",h).clear(),_(this,s,"f",c).clear(),this.summary.clear(),M(this,s,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new s(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return _(this,s,"f",f).push(i),this.all.unset(),i}constructor(e,t,i,n,o,l,u,c,d,h,f,m,S,P=Q.commandTimeoutMs){r.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=n,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=h,this.errorLinks=f,this.onReset=m,this.ttlMs=S,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),w.set(this,(0,T.lazy)((async()=>{await _(this,p,"f").prior(),(0,x.eql)(_(this,g,"f"),_(this,r,"m",v).call(this))||(this.onReset?.(),await this.refresh(),_(this,w,"f").unset())}))),this.refresh=(0,T.lazy)((()=>new q.Deferred("refresh").observe((async()=>{await _(this,p,"f").prior();const e=_(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,U.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[F.HealthCheckSections.ordinal(this.section),l??999,this.id],M(this,p,(0,$.lazyAsync)({desc:this.pendingMsg,later:()=>_(s,s,"f",a).enqueue({name:this.id,l:()=>_(this,r,"m",b).call(this,o)}),ttlMs:S}),"f"),this.isCritical&&_(this,p,"f").watchLater({onChange:s.onCriticalResult,onError:s.onCriticalResult});for(const e of this.settings)X.Settings[e].watchLater((()=>_(this,w,"f").call(this)))}isStale(){return _(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return _(this,p,"f").settledCount()}reset(){return _(this,p,"f").unset(),this.onReset?.(),M(this,g,{starting:!0},"f"),this}setTTL(e){_(this,p,"f").setTTL(e)}result(){return _(this,p,"f").call(this)}isSkipped(){return X.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return _(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return _(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??_(this,r,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function oe(e){if((0,E.isEmpty)(e))return{};const[t,i]=(0,z.partition)(e,(e=>"button"===e.type||"POST"===e.method)),r={};return(0,E.isNotEmpty)(i)&&(r.links=(0,E.uniqBy)(i)),(0,E.isNotEmpty)(t)&&(r.buttons=(0,E.uniqBy)(t)),r}t.HealthCheck=ae,s=ae,p=new WeakMap,g=new WeakMap,y=new WeakMap,w=new WeakMap,r=new WeakSet,o=function(){return(0,E.filterInPlace)(_(this,s,"f",n),(e=>!e.isPending)),_(this,s,"f",n)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=ne().tap({level:"warn",msg:"#summary()",result:(0,se.summarizeHealthChecksSync)({errors:_(this,s,"f",l),skipPending:_(this,s,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&M(this,s,!0,"f",u),i.state!==_(this,s,"f",c).last?.state&&_(this,s,"f",c).push({state:i.state,ts:Date.now()}),i},v=function(){return(0,I.fromEntries)(this.settings.map((e=>[e,X.Settings[e].valueOrDefault])))},b=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();ne().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,C.shortStack)()}),M(this,g,_(this,r,"m",v).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,D.delay)((0,O.randomInt)(.3*i,.7*i)),this.isSkipped())return _(this,r,"m",S).call(this,{test:{level:"disabled",msg:["Disabled by "+X.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const s=await(0,R.thenOrTimeoutError)(e(),i);return _(this,r,"m",S).call(this,{test:s,elapsedMs:Date.now()-t})}catch(e){return _(this,r,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},S=function({test:e,src:t="#toResult",elapsedMs:i}){var r,n;const a=s.normalizeMsg(e.msg),o=e.level??((0,j.toS)(a).toLowerCase().includes("error")?"error":(0,j.toS)(a).toLowerCase().includes("warn")?"warn":"ok"),l=(0,E.compact)([...e?.links??("ok"===o||"pending"===o?this.okLinks:"warn"===o?this.warnLinks:"no-library"===o?this.noLibraryLinks:"error"===o?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:o,msg:a,elapsedMs:i,...oe(l)};return u.runCount=(M(this,y,(n=_(this,y,"f"),r=n++,n),"f"),r),(0,G.ending)()?u:this.logger.tap({level:re.HealthCheckLevelToLogLevel[o],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const s=(0,L.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,A.map)(e,Y.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,Z.isFatalError)(e)&&s.toLowerCase().includes("warn")?"warn":"error"),_(this,r,"m",S).call(this,{test:{msg:s,level:t},src:"#toErrorResult",elapsedMs:i})},n={value:[]},a={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},h={value:new W.CountingSet},f={value:[]},ae.all=(0,T.lazy)((()=>Object.freeze((0,k.sortBy)(_(s,s,"f",f),(e=>e.sortBy))))),ae.onCriticalResult=(0,H.debounce)((()=>{ne().info("onCriticalResult()",s.summary.refresh())}),250),ae.summary=(0,T.lazy)((()=>_(s,s,"m",m).call(s))),ae.resetDebounced=(0,H.debounce)((()=>s.reset()),50)},33866:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const r=i(82950),s=i(50268),n=i(459),a=i(23560),o=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,a.isPermaService)(t)&&(e===s.HealthCheckLevels.error||(0,a.isLibraryRequiredService)(t)&&e===s.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,o.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,r.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new n.UnreachableCaseError(e)}}},88625:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.healthCheckSetup=t.testHealthCheck=void 0;const r=i(19851),s=i(82950),n=i(45599),a=i(50268),o=i(50213),l=i(7282),u=i(44198),c=i(34102),d=i(2858),h=i(60526),f=i(79483),m=i(18454),p=i(39214),g=i(86403),y=i(42482),v=i(35675),w=i(89035),b=i(31974),S=i(20752),P=i(85200),_=i(37301),M=i(65756),T=i(15024),E=i(3956),k=i(29332),D=i(61274),x=i(38372),C=i(49913),F=i(84728),A=i(7245),I=i(16264),O=(0,n.defer)((()=>(0,o.mkLogger)("health.HealthCheckSetup")));t.testHealthCheck=(0,n.defer)((()=>m.HealthCheck.for({section:"System",id:"test-health-check",ordinal:0,settings:[],pendingMsg:"Test check…",later:async()=>{const e=a.HealthCheckLevels.validOrElse((0,u.env)().PS_TEST_HEALTH_CHECK_LEVEL,a.HealthCheckLevels.ok);return{level:e,msg:[`Test health check: ${e.toUpperCase()}`,`These are ${(0,s.b)("details")}:`,(0,s.li)("alpha",(0,s.tt)("bravo"),"charlie")]}}}))),t.healthCheckSetup=(0,r.lazy)((()=>{(0,h.exiftoolHealthCheck)(),(0,p.heifHealthCheck)(),(0,y.libraryDirectoriesCheck)(),(0,v.libraryFreeSpaceCheck)(),(0,E.settingsEnvHealthCheck)(),(0,D.settingsSystemHealthCheck)(),(0,k.settingsLibraryHealthCheck)(),(0,f.externalDirsHealthCheck)(),(0,w.memoryHealthCheck)(),(0,b.nodejsHealthCheck)(),(0,S.notInDMGHealthCheck)(),(0,P.osHealthCheck)(),(0,_.powershellHealthCheck)(),(0,x.sharpHealthCheck)(),(0,g.jpegtranHealthCheck)(),(0,T.securityHealthCheck)(),(0,M.sqliteHealthCheck)(),(0,C.systemLoadHealthCheck)(),(0,A.videoHealthCheck)(),(0,I.volumeHealthCheck)(),(0,F.versionHealthCheck)(),(0,l.isProd)()||(0,t.testHealthCheck)();let e=(0,d.libraryHasSettings)();d.libraryHasSettings.watchLater((t=>{null!=t&&e!==t&&(O().info("libraryHasSettings changed. Resetting health checks.",{newValue:t}),e=t,m.HealthCheck.resetDebounced())}));for(const e of["volumesChanged","mountpointsChanged","error"])(0,c.ee)().on(e,(()=>{O().debug("Clearing health check cache",{event:e}),m.HealthCheck.resetDebounced()}));(0,c.ee)().on("fatal",(e=>m.HealthCheck.addError(e)))}))},39214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heifHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(41400),a=i(55835),o=i(34102),l=i(277),u=i(45969),c=i(63335),d=i(18454);t.heifHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-heif",pendingMsg:"Checking HEIF/HEIC tooling…",settings:["heifConvertPath"],links:[{text:"Read how to set up HEIF support with PhotoStructure",url:"https://photostructure.com/getting-started/heif-support/",icon:"docs"}],warnLinks:(0,u.isDocker)()?[]:[{text:"Re-check for HEIF tooling",icon:"refresh",method:"POST",type:"button",url:"/admin/recheck-tools"}],later:async()=>{const e=await(0,l.getHeifSupportDetails)();return null!=e&&!1!==e.isSupportedVersion?{level:"ok",msg:["HEIF images will be imported",(0,a.map)(e.version,c.ver),(0,a.map)(e.path,r.tt)]}:{level:"warn",msg:["HEIF images will not be imported","No HEIF tooling was found."]}}}))),(0,n.later)((()=>{(0,o.ee)().on("clearToolCache",(()=>t.heifHealthCheck.prior()?.reset()))}))},86403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.testJpegtran_=t.jpegtranHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(55835),a=i(98314),o=i(89966),l=i(51210),u=i(76280),c=i(63335),d=i(18454);async function h(){const e=await(0,o.jpegtranNativePath_)(),t=await(0,l.jpegtranVersion_)();return{nativePath:e,version:t,satisfies:(0,u.semverSatisfies)(t,">=1.5")}}t.jpegtranHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-jpegtran",ordinal:2,pendingMsg:"Checking "+(0,r.tt)("jpegtran")+"…",settings:[],later:async()=>{try{const e=await h();return{level:"ok",msg:["jpegtran is OK",(0,n.map)(e.version,c.ver),(0,n.map)(e.nativePath,r.tt)]}}catch(e){return{level:"error",msg:["Something's amiss with jpegtran",(0,a.errorToS)(e)]}}}}))),t.testJpegtran_=h},42495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const r=i(40958),s=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,r.compact)([(0,s.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},42482:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryDirectoriesCheck=void 0;const r=i(82950),s=i(42659),n=i(45599),a=i(98553),o=i(31586),l=i(94174),u=i(87290),c=i(98314),d=i(29882),h=i(45969),f=i(43334),m=i(28874),p=i(2858),g=i(59107),y=i(18454),v=i(42495);async function w(){const e=await(0,u.setupLibraryDirs_)();return(0,p.libraryHasSettings)()?{level:"ok",msg:["Library directories are OK","Verified directory permissions for the following directories:",(0,r.li)(...e.map((e=>(0,r.tt)(e))))]}:{level:"no-library",msg:["Your PhotoStructure library hasn't been set up yet"]}}t.libraryDirectoriesCheck=(0,n.defer)((()=>y.HealthCheck.for({section:"Library",id:"library-directories",ordinal:0,pendingMsg:"Checking library directories…",settings:["libraryDir","originalsDir","previewsDir","cacheDir"],ttlMs:s.minuteMs,links:[{text:'What\'s a "PhotoStructure library?"',icon:"docs",url:"https://photostructure.com/faq/library/"},...(0,h.isDocker)()?[{text:"Read how to setup up Docker",icon:"docs",url:"https://photostructure.com/server/photostructure-for-docker/"}]:[]],okLinks:[{type:"button",text:"Run library maintenance jobs",url:"/admin/run-maintenance",method:"POST",icon:"handyman"}],later:async()=>(await(0,p.readSettings)(),(0,h.isDocker)()?async function(){const e=(0,u.libraryDirPosixFile)();if(null==e)return{level:"error",msg:[`Something's amiss: ${(0,r.tt)("PS_LIBRARY_DIR")} is blank`,`The default is ${(0,r.tt)(m.Settings.libraryDir.toEnvLine(m.Settings.libraryDir.defaultValue))}`]};const t=await(0,g.mountpoints_)(),i=(0,d.bestMountpointForDir)(e,t);if(null==i||"/"===i)return{level:"warn",msg:[e.nativePath+" is not a bind-mount",`Your library directory, ${(0,r.tt)(e)}, does not seem to be a bind mount.`,"Your library contents will disappear when you shut down this container."],links:[v.DockerVolumeLink]};try{if(!await e.isReadWriteExecutable_()){const t=await e.stat(),i=[`Your library directory, ${(0,r.tt)(e)}, is not read/write${f.isWin?"":"/execute"} by ${await(0,l.userDesc)()}`];return null!=t&&(0,o.gte0)(t.uid)&&i.push("The owner of this directory is userid "+(0,r.tt)(t.uid)+", groupid "+(0,r.tt)(t.gid)),{level:"error",msg:[...i,"Please fix the permissions for this bind mount and restart the container."],links:[v.DockerVolumeLink]}}return await w()}catch(t){return{level:"error",msg:[`Your library directory, ${(0,r.tt)(e)}, can't be set up for ${await(0,l.userDesc)()}.`,(0,c.errorToS)(t,{maxLen:80}),"Please fix the permissions for this bind mount and restart the container."],links:[v.DockerVolumeLink]}}}():async function(){const e=(0,u.libraryDirPosixFile)();if(null==e)return{level:"no-library",msg:["No PhotoStructure library is open",(0,a.stringify)(m.Settings.libraryDir.getState())]};if(!(0,p.libraryHasSettings)())return{level:"no-library",msg:["No PhotoStructure library is open",m.Settings.libraryDir.hasValue()?(0,r.tt)(m.Settings.libraryDir.toEnvLine()):void 0]};try{return await e.isReadWriteExecutable_()?await w():{level:"no-library",msg:[`Your library directory, ${(0,r.tt)(e)}, is not read/write${f.isWin?"":"/execute"} by ${await(0,l.userDesc)()}`,"Please fix the permissions or pick a new library directory."]}}catch(t){return{level:"no-library",msg:[`Your library directory, ${(0,r.tt)(e)}, can't be set up for ${await(0,l.userDesc)()}`,(0,c.errorToS)(t,{maxLen:80}),"Please fix the permissions for this bind mount and restart the container."]}}}())})))},35675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFreeSpaceCheck=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(31586),l=i(68708),u=i(12168),c=i(87290),d=i(77740),h=i(28874),f=i(7014),m=i(18454);t.libraryFreeSpaceCheck=(0,a.defer)((()=>(0,l.tap)(m.HealthCheck.for({section:"Library",id:"library-free-space",settings:["libraryDir","minDiskFreeGb","originalsDir","previewsDir","cacheDir"],pendingMsg:"Checking free space on library volume(s)…",ttlMs:n.dayMs,later:async()=>{if(!(0,o.gt0)(h.Settings.minDiskFreeGb.valueOrDefault))return{level:"disabled",msg:`Library disk free test disabled: ${(0,s.tt)(h.Settings.minDiskFreeGb.key+"=0")}`};const e=(0,c.libraryDirPosixFile)();if(null==e)return{level:"disabled",msg:"Library disk free test disabled: no library is open"};if(!0!==await e.isDirectory())return{level:"disabled",msg:`Library disk free test disabled: ${(0,s.tt)(e)} is not a directory`};const t=[];for(const e of await(0,c.setupLibraryDirs_)()){const i=await(0,f.bestVolumeForPath)(e);if(null==i)return{level:"warn",msg:`Could not check for minimum disk free: no volume found for library path ${(0,s.tt)(e)}`};let r=t.find((e=>e.vol.mountpoint===i.mountpoint));null==r&&(r={vol:i,paths:[]},t.push(r)),r.paths.push(e.nativePath)}const i=h.Settings.minDiskFreeGb.valueOrDefault*u.GB,n=[];for(const{vol:e,paths:a}of t){const t=(0,s.b)(`Volume ${(0,s.tt)(e.mountpoint)} has ${(0,u.fmtBytes)(e.available)} free.`)+`\nThis volume is used for these PhotoStructure directories:\n${(0,s.li)((0,r.uniq)(a).sort().map(s.tt))}`;if(e.available{for(const t of["minDiskFreeGb","libraryDir","originalsDir","configDir"])h.Settings[t].watchLater((()=>e.reset()))}))))},89035:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const s=r(i(48161)),n=i(19851),a=i(82950),o=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),h=i(23560),f=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:r}){return{level:i,msg:[e+" from "+(0,h.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,a.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(r,2)])]}}function g(){return s.default.totalmem()f.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(f.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*f.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,n.lazy)((()=>"ok"!==g().level),o.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:o.minuteMs,later:async()=>g()})))},31974:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.nodejsHealthCheck=void 0;const s=r(i(1708)),n=i(82950),a=i(45599),o=i(26033),l=i(63335),u=i(18454);t.nodejsHealthCheck=(0,a.defer)((()=>u.HealthCheck.for({section:"Tools",id:"nodejs-version",ordinal:4,pendingMsg:"Checking Node.js…",settings:[],links:[{text:"Read about PhotoStructure NodeJS support",icon:"docs",url:"https://photostructure.com/server/photostructure-for-node/#prerequisites"}],later:async()=>{const e="You're running Node.js "+(0,l.ver)(s.default.versions.node)+".\nPhotoStructure requires "+(0,n.tt)(o.RequiredNodeRange)+".";return(0,o.isSupportedNode)()?{level:"ok",msg:["Node.js is OK",e]}:{level:"warn",msg:["Node.js is not a supported version",e]}}})))},20752:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notInDMGHealthCheck=void 0;const r=i(45599),s=i(43899),n=i(43334),a=i(18454);t.notInDMGHealthCheck=(0,r.defer)((()=>n.isMac&&n.isElectron?a.HealthCheck.for({section:"System",id:"proc-not-in-dmg",pendingMsg:"Checking PhotoStructure installation directory…",settings:[],later:async()=>s.ProjectPath.isInDMG()?{level:"error",msg:"PhotoStructure cannot run directly from a DMG disk image. Please drag and drop the PhotoStructure icon onto your Applications folder to install.",checkboxLabel:"Open https://photostructure.com/getting-started/installation/ in your browser"}:{level:"ok",msg:"PhotoStructure isn't running directly from a DMG disk image"}}):void 0))},85200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osHealthCheck=void 0;const r=i(45599),s=i(96175),n=i(18454);t.osHealthCheck=(0,r.defer)((()=>n.HealthCheck.for({section:"System",id:"system-version",pendingMsg:"Checking operating system…",settings:[],links:[{text:"What do I need to run PhotoStructure?",icon:"docs",url:"https://forum.photostructure.com/t/what-do-i-need-to-run-photostructure/44"}],later:async()=>{const e=(0,s.whyOsNotSupported)();return null==e?{level:"ok",msg:["Operating system is OK","PhotoStructure supports "+(0,s.osFullName)()]}:{level:"warn",msg:["Operating system is not supported",(0,s.osFullName)()+" was detected, but only "+e+"."]}}})))},37301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.powershellHealthCheck=void 0;const r=i(42659),s=i(45599),n=i(98314),a=i(43334),o=i(24399),l=i(63335),u=i(18454);t.powershellHealthCheck=(0,s.defer)((()=>a.isWin?u.HealthCheck.for({section:"Tools",id:"tools-powershell",pendingMsg:"Checking PowerShell…",settings:["powerShellArgs"],ttlMs:r.minuteMs,links:[{text:"How to fix PowerShell issues",url:"https://photostructure.com/fix-pwsh/"}],later:async()=>{try{const e=await(0,o.checkPowerShell_)();return{level:"ok",msg:["PowerShell is OK",(0,l.ver)(e)],meta:{version:e}}}catch(e){return{level:"error",msg:"PowerShell failed: "+(0,n.errorToS)(e)}}}}):void 0))},65756:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(27180),a=i(98314),o=i(63335),l=i(18454);t.sqliteHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Tools",id:"tools-sqlite-version",ordinal:0,pendingMsg:"Checking SQLite…",settings:[],links:[{text:"Read about PhotoStructure SQLite support",url:"https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837",icon:"docs"}],async later(){try{const e=await n.sqliteVersion_.refresh();return null==e?{level:"error",msg:"SQLite version could not be found"}:{level:"ok",msg:["SQLite is OK",(0,r.li)(["embedded: "+(0,o.ver)(e.libraryVersion),(0,r.tt)(e.sqliteNativePath)+": "+(0,o.ver)(e.toolVersion)])]}}catch(e){return{level:"error",msg:"Something's amiss with SQLite: "+(0,a.errorToS)(e)}}}})))},15024:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.securityHealthCheck=void 0;const r=i(40958),s=i(82950),n=i(45599),a=i(31586),o=i(94174),l=i(77740),u=i(44198),c=i(59958),d=i(43334),h=i(18454);t.securityHealthCheck=(0,n.defer)((()=>{const e=d.isWin?"an administrator":"root";return h.HealthCheck.for({section:"System",id:"proc-not-superuser",pendingMsg:"Checking user permission level…",settings:[],later:async()=>{if("0"===(0,u.env)().PUID)return{level:"disabled",msg:`Admin health check is disabled (${(0,s.tt)("PUID=0")}).`};const t=(0,r.compact)([(0,a.gte0)((0,o.userid)())?"Current user id: "+(0,s.b)((0,s.tt)((0,o.userid)())):void 0,(0,a.gte0)((0,o.groupid)())?"Current group id: "+(0,s.b)((0,s.tt)((0,o.groupid)())):void 0,"Current user name: "+(0,s.b)((0,s.tt)(await(0,o.username)()??"(unknown)"))]);return!0===await(0,o.isRootUser)()||(0,l.getDevEnvFlag)(c.DevEnvFlags.PS_FAIL_SECURITY_HEALTH_CHECK)?{level:"warn",msg:["PhotoStructure should not be run as "+e,...t],links:[{text:"Read why PhotoStructure should not be run as "+e,url:"https://photostructure.com/server/photostructure-for-docker/#why-not-run-as-root"}]}:{msg:["PhotoStructure is not running as "+e,...t],level:"ok"}}})}))},3956:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsEnvHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(12168),a=i(28874),o=i(63225),l=i(18454);t.settingsEnvHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Library",id:"settings-env",pendingMsg:"Checking environment settings…",settings:[],links:[{text:"Read about PhotoStructure environment settings",url:"https://photostructure.com/faq/environment-variables/",icon:"docs"}],later:async()=>{const e=[];for(const t of(0,a.allSettings)())if(t.hasValue()&&null!=t._envValue()){const i=!0===t.opts.sensitive?"********":t.toEnvValue(t._envValue());null!=i&&e.push((0,r.tt)(t.key+"="+i))}const t=[(0,n.plur)(e.length,"environment setting"),(0,r.li)(e)],i=(0,o.verifyPsEnvSettings)();return i.length>0?{level:"warn",msg:["Some environment settings may be misconfigured:",(0,r.li)(i.map((e=>(0,r.tt)(e.envKey)+": "+e.msg))),"---",...t]}:{level:"ok",msg:t}}})))},29332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsLibraryHealthCheck=void 0;const r=i(45599),s=i(2858),n=i(18454),a=i(61274);t.settingsLibraryHealthCheck=(0,r.defer)((()=>n.HealthCheck.for({section:"Library",id:"settings-library",pendingMsg:"Checking library settings…",settings:["libraryDir"],links:[{text:"Read about PhotoStructure library settings",url:"https://photostructure.com/getting-started/advanced-settings/#library-settings",icon:"docs"}],later:()=>(0,a.validateSettingsToml)((0,s.librarySettingsFile)(),"library")})))},61274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsSystemHealthCheck=t.validateSettingsToml=void 0;const r=i(40958),s=i(82950),n=i(45599),a=i(12168),o=i(81168),l=i(98314),u=i(95696),c=i(2858),d=i(32707),h=i(18454);async function f(e,t){try{if(null==e)return{level:"disabled",msg:"No "+t+" settings is set."};if(await e.notExists())return{level:"disabled",msg:(0,o.capitalize)(t)+" settings file "+(0,s.tt)(e)+" does not exist."};const i=await(0,c.importFileSettings_)(e);return(0,r.isNotEmpty)(i.warnings)?{level:"warn",msg:(0,s.tt)(e)+": "+i.warnings.join(", ")}:{level:"ok",msg:[(0,a.plur)(i.settings.length,t+" setting override"),(0,s.b)("Source:"),(0,s.tt)(e),(0,s.b)("Settings:"),(0,s.li)(i.settings.map((e=>(0,s.tt)(e.key+"="+e.toEnvValue(e.value)))))]}}catch(t){return{level:"error",msg:"Failed to parse "+e+":\n"+(0,l.errorToS)(t)}}}t.validateSettingsToml=f,t.settingsSystemHealthCheck=(0,n.defer)((()=>h.HealthCheck.for({section:"Library",id:"settings-system",pendingMsg:"Checking system settings…",settings:[],links:[{text:"Read about PhotoStructure system settings",url:"https://photostructure.com/getting-started/advanced-settings/#system-settings",icon:"docs"}],later:()=>f(u.PosixFile.forMaybe((0,d.systemSettingsFile)()),"system")})))},38372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpHealthCheck=void 0;const r=i(45599),s=i(98314),n=i(21473),a=i(18454);t.sharpHealthCheck=(0,r.defer)((()=>a.HealthCheck.for({section:"Tools",id:"tools-sharp",ordinal:2,pendingMsg:"Checking Sharp…",settings:[],later:async()=>{try{return await(0,n.testSharp_)(),{level:"ok",msg:["Sharp is OK","Image processing is working as expected."]}}catch(e){return{level:"error",msg:["Something's amiss with Sharp",(0,s.errorToS)(e)]}}}})))},82638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const r=i(40958),s=i(42659),n=i(45599),a=i(41400),o=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),h=i(23560),f=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,n.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function v({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:r}){const s=new Map;for(const e of t??[])s.set(e.id,e);if(null!=e)for await(const t of f.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),r))s.set(t.id,t);return[...s.values()]}t.summarizeHealthChecks=async function(e){return b({...e,healthCheckResults:await v(e)})};const w=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:h.serviceName.prior()??process.title}})));function b(e){const t=(0,r.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),n=i.length,a=i.map((e=>e.id)),c=t.length-n,d=0===n,h=(0,r.uniq)((0,r.compactBlanks)(e.errors));if(h.length>0)return{...w(),level:l.HealthCheckLevels.error,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",h.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const s=t.filter((e=>e.level===i));if((0,r.isNotEmpty)(s)){const e=t.filter((e=>!s.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+s.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...w(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:a,pendingCount:n,settledCount:c,linkIds:s.map((e=>e.id)),ts:Date.now(),msg:(0,r.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,o.flatten)([...s,...e].map((e=>e.msg[0])))])},meta:{checks:s.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...w(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,s.fmtDateShort)(Date.now())]}})}(0,a.later)((()=>{m.Settings.libraryDir.watchLater((()=>w.unset()))})),t.summarizeHealthChecksSync=b},49913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemLoadHealthCheck=void 0;const r=i(82950),s=i(42659),n=i(45599),a=i(31586),o=i(28874),l=i(14854),u=i(18454);t.systemLoadHealthCheck=(0,n.defer)((()=>u.HealthCheck.for({section:"System",id:"system-load",pendingMsg:"Checking system load…",settings:["cpuBusyPercent"],ttlMs:s.minuteMs,later:async()=>{if(o.Settings.cpuBusyPercent.valueOrDefault<=0)return{level:"ok",msg:["CPU utilization is not monitored",(0,r.tt)(o.Settings.cpuBusyPercent.key)+" is set to <= 0"]};const e=l.CpuUsage.instance().busyPct(),i=(0,l.isTooBusy)();return(0,t.systemLoadHealthCheck)().setTTL((i?6:60)*s.secondMs),{level:i?"stop-sync":"ok",msg:"CPU utilization is "+(0,a.fmtPct)(e)+"\n"+(i?"PhotoStructure sync is paused until CPU utilization drops below":"PhotoStructure sync will pause if CPU utilization exceeds")+" "+(0,r.tt)(o.Settings.cpuBusyPercent.key)+": "+(0,a.fmtPct)(o.Settings.cpuBusyPercent.valueOrDefault)}}})))},84728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionHealthCheck=void 0;const r=i(42659),s=i(45599),n=i(40044),a=i(18454);t.versionHealthCheck=(0,s.defer)((()=>a.HealthCheck.for({section:"System",id:"ps-version",pendingMsg:"Checking PhotoStructure version…",settings:["autoUpdateCheck","configDir","libraryDir","optOut"],ttlMs:r.hourMs,links:[{text:"Change auto-update setting",icon:"settings",url:"/settings#update-check-section"},{text:"What's new?",icon:"docs",url:"https://photostructure.com/whats-new/"},{text:"Update checking & privacy",icon:"docs",url:"https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956"}],later:n.checkVersion_})))},7245:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.videoHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(41400),a=i(55835),o=i(34102),l=i(66106),u=i(45969),c=i(63335),d=i(18454);t.videoHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-video",pendingMsg:"Checking video tooling…",settings:["ffmpegPath"],links:[{text:"Read how to set up video support with PhotoStructure",url:"https://photostructure.com/getting-started/video-support/",icon:"docs"}],warnLinks:(0,u.isDocker)()?[]:[{text:"Re-check for video tooling",icon:"refresh",method:"POST",type:"button",url:"/admin/recheck-tools"}],later:async()=>{const e=await(0,l.getVideoToolDetails_)();return null!=e&&!1!==e.isSupportedVersion?{level:"ok",msg:["Videos will be imported",(0,a.map)(e.version,c.ver),(0,a.map)(e.path,r.tt)]}:{level:"warn",msg:["Videos will not be imported","No video tooling was found."]}}}))),(0,n.later)((()=>{(0,o.ee)().on("clearToolCache",(()=>t.videoHealthCheck.prior()?.reset()))}))},16264:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeHealthCheck=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(13538),l=i(83104),u=i(12168),c=i(48884),d=i(45255),h=i(43334),f=i(69108),m=i(48165),p=i(63870),g=i(7014),y=i(18454);t.volumeHealthCheck=(0,a.defer)((()=>y.HealthCheck.for({section:"System",id:"system-volumes",ordinal:0,pendingMsg:"Checking volumes…",settings:[],links:[{text:"What's a “volume”?",url:"https://photostructure.com/faq/what-is-a-volume/",icon:"docs"}],warnLinks:h.isWin?[{text:"Check this page for troubleshooting tips",url:"https://photostructure.com/faq/windows-troubleshooting/#unhealthy-network-shares"}]:void 0,later:async()=>{const e=Date.now(),i=await(0,o.thenOrTimeout)((0,g.volumes)(),(0,p.commandTimeoutMs)());if(i===l.Timeout){const i=await(0,o.thenOrTimeout)(h.isWin?(0,m.getLocalVolumesWin_)():(0,f.dfPosixRawLocal_)(),d.ShortCommandTimeoutMs);return(0,t.volumeHealthCheck)().logger.warn("volumes() timed out, retrying in 5m"),setTimeout((()=>(0,t.volumeHealthCheck)().refresh()),5*n.minuteMs),{level:"warn",msg:[i===l.Timeout?"Something seems wrong with your computer's volumes":"Something seems wrong with one or more remote filesystem mounts","Gathering volume metadata took longer than "+(0,n.fmtAgo)(e,"")+"."]}}const a=i.filter((e=>!1===e.ok));if((0,r.isNotEmpty)(a))return{level:"warn",msg:["One or more volumes are not healthy","Check the following:",(0,s.li)(a.map((e=>(0,s.tt)(e.mountpoint))))]};const[y,v]=(0,c.partition)(i,(e=>!0===e.remote)),w=["Storage volumes are OK"];return(0,r.isNotEmpty)(v)&&w.push((0,s.b)((0,u.plur)(v.length,"local volume")+":"),(0,s.li)(...v.map((e=>(0,s.tt)(e.mountpoint))))),(0,r.isNotEmpty)(y)&&w.push((0,s.b)((0,u.plur)(y.length,"remote volume")+":"),(0,s.li)(...y.map((e=>(0,s.tt)(e.mountpoint))))),{level:"ok",msg:w}}})))},95242:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviewBuilder=t.mkPreviewAssetFile_=void 0;const a=i(57975),o=i(40958),l=i(22573),u=i(33374),c=i(98553),d=i(55835),h=i(68708),f=i(48884),m=i(50213),p=i(92434),g=i(54296),y=i(51837),v=i(57159),w=i(83278),b=i(95696),S=i(62105),P=i(84258),_=i(38156),M=i(69589),T=i(28874),E=i(47783),k=i(29990),D=i(16047),x=i(42725),C=i(4192),F=i(32876),A=i(50961),I=i(181);t.mkPreviewAssetFile_=async function(e){const t=await(0,E.readTags)(e);return{nativePath:e.nativePath,fileSize:await e.size(),mtime:await e.thisOrSidecareMaxMtimeMs(),uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath,mimetype:t.mimetype,rotation:t.rotation,...t.dimensions,sha:await e.sha_()}};class O{constructor(e,t,i){r.add(this),this.ap=e,this.assetFiles=t,this.logger=(0,m.mkLogger)("AssetPreviewBuilder("+e.assetId+")"),this.ctx=(0,M.forceContextOrSetting)(i),this.assetFiles=(0,p.sortAssetFiles)(this.assetFiles)}[(r=new WeakSet,a.inspect.custom)](){return{ctor:"AssetPreviewBuilder",assetId:this.ap.assetId,assetFiles:this.assetFiles}}async build_(){this.logger.info("build_(): asset file candidates:",this.assetFiles.map((e=>(0,h.pick)(e,"id","uri"))));const e=[];for(const t of this.assetFiles){const i=b.PosixFile.forMaybe(await(0,g.getAssetFileNativePath)(t));if(null!=i){{const e=await(0,S.whyRejectFile)(i);(0,l.blank)(e)||this.logger.info("skipping: rejected",{pf:i,whyRejected:e})}try{return await n(this,r,"m",s).call(this,i,t)}catch(i){e.push(i),this.logger.warn("Failed to set shown file to ",{best:t,error:i})}finally{this.ap.parent.clear()}}else this.logger.info("skipping: failed to get PosixFile",{af:t}),e.push(new Error("Cannot get path from URI "+(0,c.stringify)((0,h.pick)(t,"uri","mountpoint","nativePath"))))}return this.logger.throw("Cannot build previews: none of the files are valid",{doNotSend:!0,retriable:!1,files:this.assetFiles.map((e=>e.nativePath??e.uri)),causes:e})}async infoForBest_(e,t){await(0,I.throwIfInvalidFile_)(e);const i=await e.size(),r=await e.thisOrSidecareMaxMtimeMs();if(this.logger.debug("_build",{filesize:i,mtime:r,best:t.uri}),null==i||null==r)return this.logger.throw("build(): missing stat info for best file",{ignorable:!0,best:t});const{uri:s,width:n,height:a,sha:l,mimetype:u}=t;if(null==s||null==n||null==a||null==u||null==l)return this.logger.throw("build(): internal error: missing fields for best file "+e,{ignorable:!0,best:t});const c=(0,k.fitSizes)(t,t.mimetype);return{assetId:t.assetId,assetFileId:t.id,uri:s,uris:this.assetFiles.map((e=>e.uri)),path:e.nativePath,mtime:r,filesize:i,width:n,height:a,sha:l,mimetype:u,fitSizes:c.map((([,e])=>e.name)).join(","),sqWidths:(0,o.compact)(x.ImageSize.sq().map((e=>e.outputSize(t)?.width))),fitWidths:c.map((([e])=>e.width))}}async priorIfValid_(e,t){if(this.ctx.forceSync||this.ctx.forceRebuildPreviews)return;const i=await this.ap.readInfo.refresh();if(null!=i){if(i.assetId!==t.assetId)throw new y.InternalError("priorIfValid_(): mismatched asset IDs for "+e+": "+(0,c.stringify)({priorInfo:i,info:t}));const r=i.fitSizes.split(","),s=t.fitSizes.split(",");if(null!=i.sha&&i.sha===t.sha&&i.rotation===t.rotation&&(0,k.equivalentFitSizes)(r,s)){const n=(0,k.fitSizes)(e,e.mimetype),a=(0,o.diff)(r,s);if((0,o.isNotEmpty)(a)){this.logger.info("priorIfValid_(): removing previews that aren't required anymore.",{leftovers:a});for(const e of a){const t=n.find((([,t])=>t.name===e));if(null==t)this.logger.warn("priorIfValid_(): Failed to clean up: missing fit size",{fitsize:t,fits:n});else{const e=this.ap.fileForWidth(t[1].reducer.name,t[0].width);this.logger.debug("priorIfValid_(): unlinking unwanted preview "+e,{fitsize:t}),await e.unlink("warn")}}}return this.logger.debug("priorIfValid_(): SHA and rotation match, and previews exist.",{info:t,priorInfo:i}),await this.ap.writeInfo(t),t}}}}t.AssetPreviewBuilder=O,s=async function(e,t){this.logger.info("_build("+e+")",{uri:t.uri});const i=await this.infoForBest_(e,t),r=await this.priorIfValid_(t,i);if(null!=r)return r;const s=new _.PushProgressObserver({path:e.nativePath,op:"Building previews"},x.ImageSize.sq().length+x.ImageSize.fit().length);if(this.logger.debug("Rebuilding all previews from "+t.uri,{assetId:t.assetId,info:i}),null==await this.ap.parent.mkdirp())throw new Error("build(): Failed to create previews directory, "+this.ap.parent+" for "+t);const n=await this.ap.existingFiles(),a=await(0,A.sharpReadable_)({src:e,minDim:x.ImageSize.largestFit().max});if(null==a)throw new v.WrappedError("AssetPreviewBuilder.build(): "+t.uri+", "+e.nativePath+", is not readable by sharp.",{retriable:!1});const o=(0,A.toSharp)(a);if(t.mimetype.startsWith("image/")&&!(0,D.isHeifMimeType)(t.mimetype)&&null!=t.rotation&&0!==t.rotation&&(o.rotate(t.rotation),this.logger.debug("build(): rotating "+t.rotation+"°")),(0,w.isBaseFile)(a)&&a.desc.toLowerCase().includes("thumbnail"))try{o.trim(1)}catch{}const l=(0,k.fitSizes)(t,t.mimetype),c=[],m=[];let p,g;const y=x.ImageSize.largestSq(),b=(0,f.leastBy)(l,(([e,t])=>(0,d.map)(y.outputSize(e),(()=>t.megapixels()))))?.[1].name,S=(0,h.pick)(t,"width","height");{let e=o.clone(),t=S;for(const[i,r]of l){const n=Date.now(),a=t,o=this.ap.fileForWidth(r.reducer.name,i.width).wip();e=r.resize(i,e),t=i,r.name===b&&(g=e.clone(),p=i),(0,u.dmegapixels)(i)>=1&&r.reducer===F.Fit&&T.Settings.includePreviewTags.valueOrDefault&&m.push(o),await r.toJpeg({path:o.nativePath,sh:e,outputSize:i}),s.onProgress(),this.logger.debug("resize("+r.name+") "+(0,u.fmtDim)(a)+" -> "+(0,u.fmtDim)(i)+" in "+(Date.now()-n)+" ms"),c.push(o)}}{null==g?(this.logger.debug("square resize(): resorting to ",{origDim:S,bestFitNameForSq:b}),g=o,p=S):this.logger.debug("square resize(): using to ",{sqDim:p,bestFitNameForSq:b});let e=!1;for(const t of x.ImageSize.sq()){const i=Date.now(),r=p,n=t.outputSize(p??S);if(null==n){this.logger.debug("skipping square output for "+t.max);continue}e||(n.position=T.Settings.squareThumbStrategy.valueOrDefault,e=!0),this.logger.debug("Applying ",{outputSize:n});const a=this.ap.fileForWidth(t.reducer.name,n.width).wip();t.resize(n,g),p=n,await t.toJpeg({path:a.nativePath,sh:g,outputSize:n}),s.onProgress(),c.push(a),this.logger.debug("resize("+t.name+") "+(0,u.fmtDim)(r)+" -> "+(0,u.fmtDim)(n)+" in "+(Date.now()-i)+" ms")}}try{await(0,C.includePreviewTags_)(e,m).catch((t=>{this.logger.warn("Failed to restore metadata tags into previews for "+e,{error:t})}));const t=new Set(n.map((e=>e.nativePath)));for(const e of c){const i=await e.unwip_();t.delete(i.nativePath)}await(0,P.unlink)(t),await this.ap.writeInfo(i),this.logger.debug("Previews unwipped and info written",{info:i})}catch(t){throw await(0,P.unlink)(c),new v.WrappedError("Failed to create previews from "+e,{cause:t,path:e.nativePath,fatal:!1})}return i}},35721:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkDownloadableTitle=t.previewToDownloadable=t.extractPreviewInfo=void 0;const r=i(75761),s=i(33374),n=i(11371),a=i(55835),o=i(31586),l=i(56519),u=i(29882),c=i(50213),d=i(97352),h=i(81168),f=i(89782),m=(0,c.mkLogger)("extractPreviewInfo");function p(e,t,i,r){return`Download ${t} ${e.ext} ${i} (${(0,s.fmtDim)(r)})`}t.extractPreviewInfo=function(e,t){const i=t.posixPathFrom(e).replace(/\//g,"").split("-"),r=(0,o.toInt)(i[0]),s=n.ReducerNames.getCI(i[1]),a=(0,d.extractInt)(i[2]);return(0,o.gt0)(r)?{file:t,assetId:r,reducer:s,width:a}:void m.warn("Failed to extract preview info",{file:t,previewsRoot:e,arr:i,assetId:r,reducer:s,width:a})},t.previewToDownloadable=async function(e,t){return(0,a.map2)(t.assetId,t.width,((i,a)=>(0,l.thenMap)((0,f.dimensions)(t.file),(o=>{const l=(0,s.dimToSize)(o);return{size:l,basename:`${(0,h.stripSuffix)(e,(0,u.extname)(e))}-${l}${t.file.ext}`,title:p(t.file,l,"image",o),description:`Download ${l}`,details:`(${(0,s.fmtDim)(o)} ${t.file.ext})`,href:(0,r.assetImgLink)({assetId:i,reducer:n.ReducerNames.fit,width:a})}}))))},t.mkDownloadableTitle=p},16524:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviews=void 0;const a=i(19851),o=i(40958),l=i(75761),u=i(11371),c=i(68708),d=i(39926),h=i(58939),f=i(48884),m=i(50213),p=i(81168),g=i(56519),y=i(38835),v=i(70417),w=i(35721);t.AssetPreviews=class{constructor(e,t){r.add(this),this.previewsRoot=e,this.readInfo=(0,a.lazy)((()=>this.infoJson().readJson("debug"))),this.logger=(0,m.mkLogger)("AssetPreviews(assetId:"+(0,h.id2id)(t)+")"),this.assetId=(0,h.id2id)(t);const i=(0,d.leftPad)(this.assetId,8,"0"),s=(0,p.splitEvery)(i,3);this.basename=s.pop()+"-",this.parent=e.join(...s)}parentNotExists(){return this.parent.clear().notExists()}async existingFiles(){return await this.parent.clear().childFiles((e=>e.base.startsWith(this.basename)))??[]}async existingJpgs(){return(await this.existingFiles()).filter((e=>".jpg"===e.ext))}async previewInfos(){return(0,g.sortByAsync)({name:"img.AssetPreviews.previews",arr:n(this,r,"m",s).call(this),f:e=>e?.file.size()})}async deleteAll(){const e=await this.existingFiles();if(e.length>20)throw new Error("deleteAll(): rejected: > 20 existing files?!"+y.InternalErrorFlag);for(const t of e)await t.unlink();return e}fileForSuffix(e){return this.parent.join(this.basename+e)}mp4(){return this.fileForSuffix("video.mp4")}infoJson(){return this.fileForSuffix("info.json")}writeInfo(e){return this.readInfo.unset(),this.infoJson().writeJson((0,c.pick)(e,"assetId","assetFileId","uri","uris","path","mimetype","width","height","mtime","filesize","sha","rotation","fitSizes","fitWidths"))}fileForWidth(e,t){return this.fileForSuffix(e+"-w"+t+".jpg")}async filesForReducer(e){const t=this.basename+e+"-";return this.logger.tap({msg:"filesForReducer("+e+")",result:(await this.existingFiles()).filter((e=>e.base.startsWith(t)))})}async smallestFileForReducer(e){return(0,f.leastBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async largestFileForReducer(e){return(0,f.greatestBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async widths(e){const t=await this.readInfo(),i=e===u.ReducerNames.sq?"sqWidths":"fitWidths",r=t?.[i];if(!(0,o.isEmpty)(r))return r;const s=(0,o.compact)((await this.previewInfos()).filter((t=>t.reducer===e)).map((e=>e.width)));return null!=t&&(t[i]=s,await this.writeInfo(t)),s}async posterLink(){const e=await this.widths(u.ReducerNames.fit);return(0,l.assetImgLink)({assetId:this.assetId,reducer:u.ReducerNames.fit,width:(0,v.max)(e)})}async imgAttrs(e,t=!1,i=!0){if(t||e!==u.ReducerNames.sq){const t=e===u.ReducerNames.fit?await this.readInfo():void 0;return(0,l.assetImgAttrs)({assetId:this.assetId,reducer:e,widths:await this.widths(e),lazyLoad:i,af:t})}return(0,l.assetSqImgAttrs)({assetId:this.assetId,lazyLoad:i})}},r=new WeakSet,s=async function(){const e=[];for(const t of await this.existingFiles()){const i=(0,w.extractPreviewInfo)(this.previewsRoot,t);null!=i&&e.push(i)}return e}},52086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},33106:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.dctPixels=t.dctHashCIELAB=t.dctHash=void 0;const s=r(i(9288)),n=i(96249),a=i(85810),o=32,l=function(e){const t=new Array(32);for(let e=1;e<32;e++)t[e]=1;return t[0]=1/Math.sqrt(2),t}(),u=function(e){const t=new Array(32);for(let e=0;e<32;e++){t[e]=new Array(32);for(let i=0;i<32;i++)t[e][i]=Math.cos((2*e+1)/64*i*Math.PI)}return t}();function c(e){const t=new Array(o);for(let i=0;is?1:0);return n}t.dctHash=async function(e){return c(await e.greyscale().resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer())},t.dctHashCIELAB=async function(e){const t=await e.resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer(),i=(0,a.rgb2labArray)(t);return(0,n.flatten)(i.map(c))},t.dctPixels=c},86580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(21605),o=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,n.gt0)(e.width)&&(0,n.gt0)(e.height)?(0,n.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,s.dmegapixels)(e.dimensions):(0,n.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,n.lt)(e.width,t.width)&&(0,n.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,n.lte)(e?.width,t?.width)&&(0,n.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,n.lt)(e.width,t.width)||(0,n.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,r.compact)((0,o.toS)(e).split(/[x×]/).map((e=>(0,n.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,r=Math.round(Math.sqrt(t*i));return{width:r,height:Math.round(r/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const r=u(e,i);return null==r?[]:a.Rotations.filter((e=>u(c(t,e),i)===r))}},89782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(56519),o=i(1078),l=i(5733),u=(0,r.lazy)((()=>(0,n.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,s.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,a.thenMap)((0,o.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},29990:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.equivalentFitSizes=t.fitSizes=void 0;const r=i(40958),s=i(33374),n=i(16170),a=i(42725),o=[a.ImageSize.QVGA,a.ImageSize.QQVGA];function l(e){return"qhd"===e?"wvga":"uhd"===e?"uhd4k":e}t.fitSizes=function(e,t){const i=a.ImageSize.fit(),r=[];let l=(0,n.isMimeTypeSupportedByBrowser)(t)?e:void 0;for(let t=0;t3||(0,s.dmegapixels)(a)-(0,s.dmegapixels)(l)>2.5)&&(l=a,r.push([a,n])))}return r},t.equivalentFitSizes=function(e,t){return(0,r.includesAll)((0,r.compactBlanks)(e).map(l),(0,r.compactBlanks)(t).map(l))}},277:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const r=i(22573),s=i(41400),n=i(54993),a=i(19851),o=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),h=i(78330),f=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),v=(0,a.lazy)((()=>(0,o.mkLogger)("img.Heif")));function w(e){return(0,n.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function b(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,a.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,r.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){v().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,r.blank)(e))return void v().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=w(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,r.blank)(i)&&(0,l.hasApt)()){const t=await(0,h.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,r.blank)(i)&&(0,f.hasPacman)()&&(i=(await(0,f.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,r.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void v().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=w,t.isHeifSupported=b,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await b()?(0,g.heif2png_)(e):void v().throw("HEIF support is missing",{src:e.nativePath})},(0,s.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(41400),o=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),h=i(28874),f=i(89782),m=i(13940),p=(0,r.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,s.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,r.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:h.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?n.minuteMs:void 0),e})),(0,a.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,f.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(h.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:h.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(o.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const r=i(22573),s=i(54993),n=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,r.blank)(e)&&n.test((0,s.toS)(e))}},13940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),s=i(19851),n=i(42659),a=i(59455),o=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),v=i(55222),w=i(63870),b=(0,s.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,s.lazy)((()=>(S(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const S=(0,s.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const s=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const n=s.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await n.mkdirp_(),await n.utimes();const a=n.join(i+r);return b().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:a}),a}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,a.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+v.TokenRadix.randomChars(2),v.TokenRadix.randomChars(16)+(0,o.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*n.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const s=await P(e,t,i);return await s.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,w.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),s}catch(r){return b().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},48368:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashDim=t.toImageHash=t.isImageHash=t._imageHash_=t.imageHash_=t.imageHash=t.maxPerBits=void 0;const s=r(i(9288)),n=i(19851),a=i(40958),o=i(22573),l=i(42659),u=i(33374),c=i(56038),d=i(85810),h=i(76490),f=i(40401),m=i(86758),p=i(85434),g=i(96706),y=i(38835),v=i(88561),w=i(95696),b=i(17217),S=i(50213),P=i(23624),_=i(28874),M=i(12089),T=i(16170),E=i(1078),k=i(33106),D=i(86580),x=i(78011),C=i(50961);t.maxPerBits=function(e){return Math.floor(52/e)};const F=(0,n.lazy)((()=>(0,S.mkLogger)("img.ImageHash")));t.imageHash=async function(e){try{return await(0,t.imageHash_)((0,b.toNativePath_)(e))}catch(t){return void F().warn("imageHash() failed for "+e,t)}};const A=(0,n.lazy)((()=>new v.FileCache({name:"img.imageHash",timeoutMs:l.minuteMs})));async function I(e){const t=w.PosixFile.for(e),i=await(0,E.extractSizeInfoFromFile)(t);if(null==i)throw new Error("Failed to read dimensions for "+e+y.NonFatalErrorFlag+y.DoNotSendErrorFlag);const r=(0,D.fitToResolution)(i.dimensions,Math.round(_.Settings.dominantColorPixels.valueOrDefault)),n=await(0,C.sharpReadable_)({src:t,minDim:r});return(0,c.time)("img.imageHash",(()=>async function({file:e,readable:t,sizeInfo:i}){const r=(0,S.mkLogger)("ImageHash("+e+")");if(null==t)return r.throw("Cannot build readable stream");const n=(0,D.fitToResolution)(i.dimensions,_.Settings.dominantColorPixels.valueOrDefault);if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-orig.jpg";await(0,C.toSharp)(t).jpeg().toFile(i),console.log({out:i,readable:t})}let a=(0,C.toSharp)(t).removeAlpha();(0,T.isVideoMimeType)(t.mimetype)||(a=a.rotate(i.rotation)),(0,u.dmegapixels)(i.dimensions)<.1&&(a=a.trim({background:"#000",threshold:0})),a=a.resize({fit:s.default.fit.outside,...n,withoutEnlargement:!0});const{data:o,info:l}=await a.raw().toBuffer({resolveWithObject:!0});if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-"+l.width+"w.jpg";await(0,s.default)(o,{raw:{...l,channels:3}}).jpeg().toFile(i),console.log({out:i,rgbInfo:l,readable:t})}const c=(0,d.rgb2labTriplets)(o),h=(0,f.extractDominantColors)(c),p=(0,m.labsAreGreyscale)(c),y=()=>(0,s.default)(o,{raw:{...l,channels:3}}),v=await(p?x.meanDiffHash:x.meanDiffHashCIELAB)(y()),w=await(p?k.dctHash:k.dctHashCIELAB)(y());return{meanHash:(0,P.b64encodeBits)(v.meanHash),diffHash:(0,P.b64encodeBits)(v.diffHash),dctHash:(0,P.b64encodeBits)(w),dominantColors:h.dominantColors,dominantColorsDescription:h.description,dominantColorScore:h.dominantColorScore,isGreyscale:p,mimetype:(0,T.normalizeMimetype)(t.mimetype),...i.dimensions,rotation:i.rotation??0}}({file:t,readable:n,sizeInfo:i})))}function O(e){return null!=e&&(0,o.notBlank)(e.meanHash)&&(0,o.notBlank)(e.mimetype)&&(0,a.isNotEmpty)(e.dominantColors)}t.imageHash_=(0,M.shim1)({name:"img.imageHash",cache:A,impl:I}),t._imageHash_=I,t.isImageHash=O,t.toImageHash=function(e){if(null!=e){if(O(e))return e;if((0,p.isModeData)(e)){const t={...(0,p.omitModeData)(e),dominantColors:h.DominantColor.fromModeData(e)};if(O(t))return t}}},t.HashDim=8},80361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageHashSimilarity=t.isVerySimilarComparison=t.isVerySimilarImageHash=t.isSimilarImageHash=t.isVerySimilarImage=t.compareImageHashes=t.isSimilarImage=t.hammRatio=t.meanHashVariants=t.isGreyscaleMeanHash=t.labsCorr2=t.isImageHashComparison=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(38639),o=i(33374),l=i(57924),u=i(55835),c=i(31586),d=i(68708),h=i(39926),f=i(21605),m=i(48884),p=i(50213),g=i(97352),y=i(85810),v=i(3048),w=i(32848),b=i(82647),S=i(38812),P=i(70417),_=i(23624),M=i(28874),T=i(86580),E=i(48368),k=i(2090),D=(0,r.lazy)((()=>(0,p.mkLogger)("img.ImageHashComparison")));t.isImageHashComparison=function(e){return null!=e&&(0,E.isImageHash)(e.a)&&(0,E.isImageHash)(e.b)&&[e.imageCorr,e.colorCorr,e.aRotation].every(c.isNumber)},t.labsCorr2=function(e,t){const i=(0,s.sum)(e,(e=>(0,v.diffCIECorr)(e,(0,y.closestLab)(t,e))))+(0,s.sum)(t,(t=>(0,v.diffCIECorr)(t,(0,y.closestLab)(e,t)))),r=Math.max(e.length,t.length,i);return(r-i)/r};const x=/A{20}=?$/;function C(e){return null!=e&&((0,g.within)(7,12,e.length)||null!=e?.match(x))}function F(e,t,i=E.HashDim){const r=(0,_.b64decode)(e).toString(2).split("").map((e=>"1"===e?1:0)),s=i*i;for(;r.length%s!=0;)r.unshift(0);return r.length===s||t?r.slice(0,s):r.slice(0,s).map(((e,t)=>4*e+2*r[t+s]+r[t+2*s]))}function A({a:e,b:t,greyscale:i,dim:r=E.HashDim,rotationsToCheck:a}){if((0,n.blank)(e)||(0,n.blank)(t))return{hammRatio:0,bRotation:0};if(e===t)return{hammRatio:1,bRotation:0};const o=F(e,i,r),l=F(t,i,r);(0,s.isEmpty)(a)&&(a=[0]);const u=a.map((e=>({bRotation:e,hammRatio:(0,c.sigFigs)((0,g.hammRatioIntArrays)(o,(0,S.rotateSquareMatrix)(l,e),i?1:3),2)})));D().debug("hammRatio()",{results:u,rotationsToCheck:a});const d=(0,m.greatestBy)(u,(e=>[(0,c.sigFigs)(e.hammRatio,1),-f.Rotations.indexOf(e.bRotation)]));return{bRotation:d.bRotation,hammRatio:(0,c.sigFigs)(d.hammRatio,2)}}async function I(e,t,i="debug",r={}){return D().tap({msg:`isSimilarImage(${e},${t})`,level:i,result:L(await(0,E.imageHash)(e),await(0,E.imageHash)(t),r)})}function O(e,t,i={}){const r=(0,E.toImageHash)(e),s=(0,E.toImageHash)(t);if(null==r||null==s)return;const n=(0,a.isTrue)(i.capturedAtIsFuzzy),h=!(0,a.isTrue)(i.forceColor)&&((0,a.isTrue)(i.forceGreyscale)||(r.isGreyscale??C(r.meanHash))||(s.isGreyscale??C(s.meanHash))),f=A({a:r.meanHash,b:s.meanHash,greyscale:h,rotationsToCheck:i.rotationsToCheck??(0,T.validRotations)(r,s)}),m=A({a:r.diffHash,b:s.diffHash,greyscale:h,rotationsToCheck:[]}),p=A({a:r.dctHash,b:s.dctHash,greyscale:h,rotationsToCheck:[]}),g=(0,w.dominantColorCorrelation)(r.dominantColors,s.dominantColors);if(null==g)return void D().debug("imageHashCompare(): missing color correlation");const y=r.mimetype===s.mimetype,v=(0,T.aspectRatio)(r),S=(0,T.aspectRatio)((0,o.maybeDimSwap)(s,f.bRotation)),P=null!=v&&null!=S&&!(0,o.isCloseAspectRatio)(v,S);let _=0,x=0;n&&(x+=M.Settings.imageHashFuzzyDateDelta.valueOrDefault,_+=M.Settings.imageHashFuzzyDateDelta.valueOrDefault),y||(x+=M.Settings.imageHashDifferentMimetypesDelta.valueOrDefault,_+=M.Settings.imageHashDifferentMimetypesDelta.valueOrDefault),h&&(_+=M.Settings.imageHashGreyscaleDelta.valueOrDefault,x+=M.Settings.imageHashGreyscaleDelta.valueOrDefault);const F=R((_+(i.minImageCorr??M.Settings.minImageCoeffPct.valueOrDefault))/100),I=R((x+(i.minColorCorr??M.Settings.minColorCoeffPct.valueOrDefault))/100),O=[];P&&O.push(`aspect ratio mismatch (${(0,k.fmtAspectRatio)(v)} vs ${(0,k.fmtAspectRatio)(S)})`);const L=[],N=new b.Average;N.push(f.hammRatio),f.hammRatioN.push(e))),(0,u.map)(p?.hammRatio,(e=>N.push(e))),(0,c.lt)(m?.hammRatio,F)&&L.push("gradient"),(0,c.lt)(p?.hammRatio,F)&&L.push("DCT")),L.length>0&&O.push("different image content ("+(0,l.andList)(L)+")");const j=g>=I,z=j&&N.avg>=F;j||O.push("different dominant colors");const V={meanHashCorr:(0,c.sigFigs)(f.hammRatio,2),diffHashCorr:B?void 0:(0,u.map)(m,(e=>(0,c.sigFigs)(e.hammRatio,2))),dctHashCorr:B?void 0:(0,u.map)(p,(e=>(0,c.sigFigs)(e.hammRatio,2))),hashCorrAvg:N.avg,minImageCorr:F,imageCoeffDelta:_,colorCorr:(0,c.sigFigs)(g,2),minColorCorr:I,colorCoeffDelta:x,isGreyscale:h,bRotation:f.bRotation,aAspectRatio:v,bAspectRatio:S,isSimilar:z,whyNotSimilar:z?void 0:(0,l.andList)(O)};return D().info("compareImageHashes",{a:(0,d.pickCompact)(r,"uri","id","assetId"),b:(0,d.pickCompact)(s,"uri","id","assetId"),...V}),{a:r,b:s,...V}}function L(e,t,i){return O(e,t,i)?.isSimilar??!1}function R(e){return(0,c.sigFigs)((0,c.clamp)(0,1,e),3)}function N(e){return null!=e&&(0,c.gte)(e.meanHashCorr,.9)&&(0,c.gte)(e.colorCorr,.9)}t.isGreyscaleMeanHash=C,t.meanHashVariants=function(e,t=!1,i=E.HashDim){const r=(t=t||null!=e.match(x))?(0,h.padding)("0",2*i*i):"",s=F(e,t,i);return f.Rotations.map((e=>(0,_.b64encode)(BigInt("0b0"+(0,S.rotateSquareMatrix)(s,e).map((e=>e.toString(2))).join("")+r))))},t.hammRatio=A,t.isSimilarImage=I,t.compareImageHashes=O,t.isVerySimilarImage=async function(e,t,i="debug",r={}){return I(e,t,i,{rotationsToCheck:[0],...r,minImageCorr:.92,minColorCorr:.92})},t.isSimilarImageHash=L,t.isVerySimilarImageHash=function(e,t,i={}){return N(O(e,t,i))},t.isVerySimilarComparison=N,t.imageHashSimilarity=function(e,t){return(0,u.map)(O(e,t),(e=>(0,P.avg)([e.meanHashCorr,e.colorCorr])))}},42725:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ImageSize=void 0;const a=i(57975),o=i(19851),l=i(33374),u=i(12168),c=i(48884),d=i(28874),h=i(32876),f=i(5733);class m{static sq(){return n(this,r,"f",s).filter((e=>e.reducer===h.Square))}static largestSq(){return(0,c.greatestBy)(this.sq(),(e=>e.megapixels()))}static fit(){const e=d.Settings.previewResolutions.valueOrDefault;return n(this,r,"f",s).filter((t=>t.reducer===h.Fit&&e.includes(t.name)))}static largestFit(){return(0,c.greatestBy)(this.fit(),(e=>e.megapixels()))}static all(){return[...n(this,r,"f",s)]}constructor(e,t,i,a,l=!0){this.name=e,this.maxWidth=t,this.maxHeight=i,this.reducer=a,this.rotational=l,this.megapixels=(0,o.lazy)((()=>(0,u.megapixels)(this.maxWidth*this.maxHeight))),this.max={width:t,height:i},n(r,r,"f",s).push(this)}[a.inspect.custom](){return{ctor:"ImageSize",name:this.name+" ("+this.reducer.name+")",maxDim:this.maxWidth+"×"+this.maxHeight,maxMP:this.megapixels()}}get aspectRatio(){return this.maxWidth/this.maxHeight}get maxPixels(){return this.maxWidth*this.maxHeight}get minDimension(){return Math.min(this.maxWidth,this.maxHeight)}outputSize(e){return this.reducer.reduce(this.rotational&&(0,l.isPortrait)(e)?(0,l.dimSwap)(this.max):this.max,e)}resize(e,t){return t.resize({...e,fit:this.reducer.fit,withoutEnlargement:!0})}toJpeg({path:e,sh:t,outputSize:i}){return((0,l.dmegapixels)(i)<2||d.Settings.previewSharpen.valueOrDefault)&&(t=t.sharpen()),t.jpeg((0,f.sharpRenderOptions)()).toFile(e)}toString(){return this.name}}t.ImageSize=m,r=m,s={value:[]},m.UHD8k=new r("uhd8k",7680,4320,h.Fit,!1),m.UHD5k=new r("uhd5k",5120,2880,h.Fit,!1),m.UHD=new r("uhd4k",4096,2160,h.Fit),m.QHD=new r("qhd",3120,1440,h.Fit),m.FHD=new r("fhd",1920,1080,h.Fit),m.HD=new r("hd",1280,720,h.Fit),m.WVGA=new r("wvga",720,480,h.Fit),m.QVGA=new r("qvga",320,240,h.Fit),m.QQVGA=new r("qqvga",160,120,h.Fit),m.S480=new r("s480",480,480,h.Square),m.S240=new r("s240",240,240,h.Square),m.S120=new r("s120",120,120,h.Square),m.S60=new r("s60",60,60,h.Square)},4192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includePreviewTags_=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(50213),o=i(56038),l=i(28874),u=i(47783),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.includePreviewTags")));t.includePreviewTags_=async function(e,t){!1===l.Settings.includePreviewTags.valueOrDefault||l.Settings.includedPreviewTags.isEmpty()||(0,s.isEmpty)(t)||(c().info("Re-adding metadata to previews..."),await(0,o.time)("img.includePreviewTags",(async()=>{const i=(0,n.pick)(await(0,u.readTags)(e),...l.Settings.includedPreviewTags.values),r=i?.capturedAt;null!=r&&(delete i.capturedAt,(0,n.assignFields)(i,r.asExifTag()));const s=i?.exposureSettings;null!=s&&(delete i.exposureSettings,i.FocalLength=s.focalLength,i.FNumber=s.aperture,i.ExposureTime=s.shutterSpeed,i.ISO=s.iso),l.Settings.includedPreviewTags.has("Source")&&(i.Source=e.nativePath),(0,n.isEmptyObj)(i)?c().warn("not adding tags to previews: no values for tags in source file",{src:e,includedPreviewTags:l.Settings.includedPreviewTags.values}):(c().info("Overwriting preview tags...",{src:e,writeTags:i}),await Promise.all(t.map((e=>(0,u.overwriteTags_)(e,i)))))})))}},78011:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.meanDiffHashCIELAB=t.meanDiffHash=t.dhash=t.mhash=void 0;const s=r(i(9288)),n=i(96249),a=i(59455),o=i(85810),l=i(70417),u=i(48368);function c(e){const t=(0,l.avg)(e);return null==t?[]:(0,a.toA)(e).map((e=>e>=t?1:0))}function d(e){const t=(0,a.toA)(e),i=Math.round(Math.sqrt(t.length));return t.map(((t,r)=>t>=(0===r?e[i]:r%i==0?e[r-i]:e[r-1])?1:0))}t.mhash=c,t.dhash=d,t.meanDiffHash=async function(e,t=u.HashDim){const i=await e.greyscale().resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer();return{meanHash:c(i),diffHash:d(i)}},t.meanDiffHashCIELAB=async function(e,t=u.HashDim){const i=await e.resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer(),r=(0,o.rgb2labArray)(i);return{meanHash:(0,n.flatten)(r.map(c)),diffHash:(0,n.flatten)(r.map(d))}}},48604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildAssetPreviews_=t.Previews=void 0;const r=i(19851),s=i(55835),n=i(50213),a=i(12089),o=i(87290),l=i(95242),u=i(16524);class c{constructor(e){this.root=e}apb(e,t,i){return new l.AssetPreviewBuilder(this.ap(e),t,i)}ap(e){return new u.AssetPreviews(this.root,e)}}t.Previews=c,c.instance=(0,r.lazy)((()=>((0,n.mkLogger)("Previews").info(".instance()",{libraryPreviewsDir:(0,o.libraryPreviewsDirPosixFile)()}),(0,s.map)((0,o.libraryPreviewsDirPosixFile)(),(e=>new c(e)))))),t.buildAssetPreviews_=(0,a.shim1)({name:"img.buildAssetPreviews",impl:e=>c.instance().apb(e.assetId,e.assetFiles,e).build_()})},2090:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(34666),o=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,n.isNumber)(e)?e:((0,n.toGt0)(e.width)??0)/((0,n.toGt0)(e.height)??0),(e=>(0,o.leastBy)(t.StandardAspectRatios,(t=>{const r=Math.abs(e-t);return r>i?void 0:r}))??e))}function c(e,i,r=t.RatioEpsilon){return(0,a.lt)((0,n.absdiff)(u(e),u(i)),r)}function d(e,i){return(0,o.leastByCtx)(t.Ratios,(t=>{const r=Math.abs(t.i-e);return r[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,s.maybeDimSwap)(e.dimensions,e.rotation),(0,s.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,n.sigFigs)(e,3))}},34943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const r=i(19851),s=i(31586),n=i(80049),a=i(50213),o=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),h=(0,r.lazy)((()=>(0,a.mkLogger)("img.RawInfo"))),f=(0,r.lazy)((()=>new n.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:o.ShortCommandTimeoutMs})));async function m(e){return f().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,r,n,a]=e.split("\t"),o=(0,s.toGt0)(n),l=(0,s.toGt0)(a);return null==o||null==l?h().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):h().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:r,ImageSize:{width:o,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>f.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?f.prior()?.clear():f.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{h().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},32876:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Reducers=t.Fit=t.fitInsideToMaxPixels=t.fitInsideToAspectRatio=t.Square=t.SharpFits=void 0;const r=i(19851),s=i(33374),n=i(4188),a=i(11371),o=i(31586),l=i(68708),u=i(50989),c=i(50213),d=i(86580);var h,f;t.SharpFits=(0,u.strEnum)("cover","contain","fill","inside","outside"),function(e){const i=(0,r.lazy)((()=>(0,c.mkLogger)("img.Reducers.Square")));e.name=a.ReducerNames.sq,e.fit="cover",e.reduce=function(e,r){const s=(0,d.lteBoth)(e,r)?{...e,fit:t.SharpFits.cover}:void 0;return i().tap({msg:"reduce()",result:s,meta:{max:e,input:(0,l.pick)(r,"width","height","nativePath")}})}}(h||(t.Square=h={})),t.fitInsideToAspectRatio=function(e,t){return e.width/e.height>=t?{width:Math.floor(e.height*t),height:e.height}:{width:e.width,height:Math.floor(e.width/t)}},t.fitInsideToMaxPixels=function(e,t){if(null==e||!(0,o.gt0)(e.width)||!(0,o.gt0)(e.height))return;if((0,s.pixels)(e)(0,c.mkLogger)("img.Reducers.Fit")));e.name=a.ReducerNames.fit,e.fit="inside",e.reduce=function(e,i){if(!(0,d.ltBoth)(i,e))return(0,n.fitInside)(i,e);t().trace(`reduce(): input ${(0,s.fmtDim)(i)} is too small for ${(0,s.fmtDim)(e)}`)}}(f||(t.Fit=f={})),t.Reducers=[h,f]},5733:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const s=r(i(9288)),n=i(19851),a=i(41400),o=i(50213),l=i(28874),u=i(15674),c=(0,n.lazy)((()=>(0,o.mkLogger)("img.Sharp")));function d(e,t){return(0,s.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,n.lazy)((()=>{s.default.simd(l.Settings.enableSIMD.valueOrDefault),s.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),s.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,a.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},50961:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractImageForThumbs_=t.sharpReadable_=t.toSharp=t.imgFromExif_=t._imgFromExif_=void 0;const s=i(77988),n=r(i(9288)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(33374),d=i(98553),h=i(31586),f=i(68708),m=i(51926),p=i(41583),g=i(50213),y=i(97352),v=i(56519),w=i(56038),b=i(57159),S=i(95696),P=i(17217),_=i(28874),M=i(47783),T=i(16170),E=i(95141),k=i(54979),D=i(1078),x=i(63870),C=i(86580),F=i(277),A=i(16047),I=i(13940),O=i(5733),L=i(66106),R=i(19350),N=(0,a.lazy)((()=>(0,g.mkLogger)("img.SharpReadable")));async function B(e,t,i){return i?await(0,M.exiftool)().extractBinaryTagToBuffer(t,e.nativePath):(await z(e,t))?.nativePath}async function j(e,t,i,r,a){const o=t?.[i];if(!(o instanceof s.BinaryField))return;const l=o.bytes<_.Settings.maxEmbeddedBuffer.valueOrDefault;try{const t=await B(e,i,l);if(null==t)return;const s=(0,n.default)(t,{failOn:_.Settings.imageFailOn.valueOrDefault}),o=await s.metadata(),u=(0,C.aspectRatio)(o);if(null!=a&&null!=u&&!(0,h.closeTo)(a,u,.2))return void N().info("imgFromExif("+e+", "+i+"): rejecting (aspect ratio mismatch)",{fileAspectRatio:a,renderedAspectRatio:u});const c=(0,C.lteBoth)(r,o);return N().debug("imgFromExif("+e+", "+i+")",{valid:c,minDim:r,useBuffer:l,fileAspectRatio:a,renderedAspectRatio:u,dim:(0,f.pick)(o,"width","height")}),c?{sharp:s,file:(0,m.isString)(t)?S.PosixFile.for(t):void 0}:void 0}catch(t){return void N().info("Failed to read image from EXIF tag "+i,{src:e,error:t})}}async function z(e,t){const i=t.toLowerCase().endsWith("tiff")?".tiff":".jpg";try{const r=await(0,I.tmpImageFile_)({src:e,tag:t,ext:i});return await r.applyIfEmpty_({retries:2,fn_:i=>(0,M.extractBinaryTag)(t,e.nativePath,i.nativePath),timeoutMs:(0,x.commandTimeoutMs)()})}catch(i){return void N().throw("Failed to extract embedded "+t+" from "+e.nativePath,{error:i})}}t._imgFromExif_=B,t.imgFromExif_=j,t.toSharp=function(e){const t=e;if((0,O.isSharp)(t.sharp))return t.sharp;if((0,P.isSimpleFile)(t.file))return(0,n.default)(t.file.nativePath,{failOn:_.Settings.imageFailOn.valueOrDefault});throw new Error("toSharp(): not a Sharp object: "+(0,d.stringify)(e))},t.sharpReadable_=function(e){return(0,w.time)(`img.sharpReadable${e.src.ext.toUpperCase()}`,(()=>async function({src:e,minDim:t,skipEmbedded:i}){const r=N().addParameterContext(e.nativePath);(0,O.setupSharp)();const n=await(0,k.readMimeType)(e);if((0,u.blank)(n))return r.throw(e+" is not supported (missing MIMEType)",{doNotSend:!0});const a=await(0,D.extractSizeInfoFromFile)(e);if(null==a)return void r.warn("Failed to extract size info from "+e);const d=[];function f(e,t){t.desc=e,d.push(t)}const m=a.rotation,g=(0,T.isVideoMimeType)(n),S=(0,T.isLibrawMimeType)(n),P=a.dimensions,x=t??(0,y.map2Gt0)(P.width,P.height,((e,t)=>({width:Math.round(.9*e),height:Math.round(.9*t)})));if(null==x?.width||null==x?.height)return r.throw(e+" is not supported (missing dimensions)",{dim:x,doNotSend:!0,mimetype:n,isRaw:S,isVideo:g});const I=(0,C.aspectRatio)(a.fileDimensions),B=(0,h.lt)(I,1),z=(0,T.isSharpMimeType)(n)&&null==t,V=(0,E.orientationRequiresMirroring)(a.orientation);if(!0===i||g||B||z||V)r.debug("not pulling previews from tags",{isVideo:g,isFilePortrait:B,isSharpMimeAndNoMinDim:z,isMirrorOrientation:V});else{const i=!1,n=await(0,M.readRawTags)(e,i);if(null==n)r.warn("Cannot pull previews from tags: readRawTags() failed");else{const i=[..._.Settings.embeddedPreviews.values];null!=t&&(0,c.dmegapixels)(t)<1&&i.unshift(..._.Settings.embeddedThumbnails.values);const a=x.width*x.height*.2,u=x.width*x.height*.05,d=(0,l.sortBy)(i.filter((e=>n[e]instanceof s.BinaryField)),(e=>{const t=n[e]?.bytes;return(0,h.gt)(t,u)?Math.abs(t-a):void 0}));if(!(0,o.isEmpty)(d)){r.debug("checking previews from tags",{sizeSortedTagNames:d});for(const t of d)f("imgFromExif."+t,(()=>j(e,n,t,x,I)))}}}(0,T.isSharpMimeType)(n)&&f("sharp",(async()=>({file:e}))),(0,A.isHeifMimeType)(n)&&await(0,F.isHeifSupported)()&&f("heif",(()=>(0,v.thenMap)((0,F.heif2img)(e),(e=>({file:e}))))),S&&f("raw2tiff",(()=>(0,v.thenMap)((0,R.raw2tiff_)(e),(e=>({file:e}))))),g&&f("extractVideoFrame",(async()=>{if(await(0,L.isVideoSupported)())try{return await(0,v.thenMap)((0,L.extractVideoFrame_)(e),(e=>({file:e})))}catch(t){throw new b.WrappedError("Failed to extract video frame for "+e,t)}else r.warn("video file, but video support is missing",{src:e.nativePath,mimetype:n,minDim:t})}));const W=[];for(const i of d)try{const s=await(0,w.time)("img.read."+i.desc,i);if(null!=s)return r.debug(i.desc+" strategy succeeded",{src:e,minDim:t,rot:m,img:s.file?.nativePath}),{desc:i.desc,rot:m,mimetype:n,...s};r.debug(i.desc+" returned null",{src:e,minDim:t,rot:m})}catch(e){r.warn(i.desc+" failed",e),W.push((0,p.toErr)(e))}throw new b.WrappedError("Failed to render "+e,{causes:W,path:String(e),fatal:!1,doNotSend:!0,retriable:!1})}(e)))},t.extractImageForThumbs_=z},21473:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.testSharp_=void 0;const s=r(i(34589)),n=i(76760),a=r(i(9288)),o=i(50357),l=i(98553),u=i(68708),c=i(23560),d=i(43899),h=i(28874),f=i(5733);t.testSharp_=async function e(t){try{(0,f.setupSharp)();const e=t??(0,n.join)(d.ProjectPath.Public(),"images","logo@5x.png"),i=(0,a.default)(e,{failOn:"error"}),r=await i.resize(24,32,{fit:"cover",position:"attention"}).toFormat("jpeg").toBuffer({resolveWithObject:!0});(0,s.default)((0,o.eql)((0,u.pick)(r.info,"format","width","height","channels"),{format:"jpeg",width:24,height:32,channels:3}),"Unexpected sharp output: "+(0,l.stringify)(r.info))}catch(i){if(!(0,c.isWorkerService)()&&h.Settings.enableSIMD.valueOrDefault)return h.Settings.enableSIMD.envValue=!1,e(t);throw i}}},181:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.whyInvalidFile=t.clearInvalidFileCache=t.throwIfInvalidFile_=t.isValidFile=void 0;const s=r(i(9288)),n=i(19851),a=i(22573),o=i(42659),l=i(98553),u=i(50213),c=i(12089),d=i(81168),h=i(57159),f=i(88561),m=i(95696),p=i(17217),g=i(28874),y=i(16170),v=i(54979),w=i(63870),b=i(5733),S=i(50961),P=i(66106),_=i(51210),M=(0,n.lazy)((()=>(0,u.mkLogger)("img.ValidFile")));t.isValidFile=async function(e){return(0,a.blank)(await(0,t.whyInvalidFile)((0,p.toNativePath_)(e)))},t.throwIfInvalidFile_=async function(e){if(!g.Settings.validateJpegImages.valueOrDefault&&!g.Settings.validateRawImages.valueOrDefault&&!g.Settings.validateVideos.valueOrDefault)return void M().debug("file validation is disabled for "+e,{validateJpegImages:g.Settings.validateJpegImages.valueOrDefault,validateRawImages:g.Settings.validateRawImages.valueOrDefault,validateVideos:g.Settings.validateVideos.valueOrDefault});const i=(0,p.toNativePath_)(e),r=M().tap({msg:"whyInvalidFile("+i+")",result:await(0,t.whyInvalidFile)(i)});(0,a.notBlank)(r)&&M().throw(r,{path:i,retriable:!1,doNotSend:!0,ignorable:!0})};const T=(0,n.lazy)((()=>new f.FileCache({name:"img.validFile",maxSize:256,timeoutMs:Math.max(o.minuteMs,g.Settings.validateVideos.valueOrDefault?5*o.minuteMs:(0,w.commandTimeoutMs)())})));t.clearInvalidFileCache=function(){return T().clear()},t.whyInvalidFile=(0,c.shim1)({name:"img.whyInvalidFile",cache:T,toKey:p.toNativePath_,impl:async e=>{const t=m.PosixFile.for(e);if(!await t.isFile()||!await t.isReadable())return t+" is not a readable file";if(await t.isEmpty())return t+" is empty";try{const e=await(0,v.readMimeType)(t);if(null==e)throw new Error("Cannot validate, no mimetype");if((0,y.isVideoMimeType)(e))g.Settings.validateVideos.valueOrDefault&&(M().debug("validating "+t),await(0,P.validVideo_)(t));else{if(!e.startsWith("image/"))throw new Error("Unsupported mimetype "+(0,l.stringify)(e));if("image/jpeg"===e)g.Settings.validateJpegImages.valueOrDefault&&await(0,_.validJpeg_)(t);else if(g.Settings.validateRawImages.valueOrDefault)if((0,d.includesIgnoreCase)(g.Settings.validateMimetypeSkiplist.values,e))M().info("Skipping validation of "+t+": validateMimetypeSkiplist matches",{mime:e});else{const e=await(0,S.sharpReadable_)({src:t,skipEmbedded:!0}),i=await async function(e,t=g.Settings.imageFailOn.valueOrDefault){const i=e;if((0,p.isSimpleFile)(i.file))return(0,s.default)(i.file.nativePath,{failOn:t});if((0,b.isSharp)(i.sharp)){const{data:e,info:t}=await i.sharp.raw().toBuffer({resolveWithObject:!0});return(0,s.default)(e,{...t,failOnError:!0})}throw new Error("Cannot read input "+e?.desc)}(e);await i.tiff().toBuffer()}}return""}catch(t){return new h.WrappedError("Failed to validate",{cause:t,path:e,doNotSend:!0}).toS()}}})},19769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const r=i(19851),s=i(40958),n=i(41400),a=i(50213),o=i(68852),l=i(98314),u=i(28874),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:h().test(t)||!d().test(t),meta:{err:e,allow:h().test(t),block:d().test(t),validationErrorAllowlist:h().source,validationErrorBlocklist:d().source}})};const d=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),h=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,n.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>h.unset()))}))},66106:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const r=i(19851),s=i(40958),n=i(38639),a=i(42659),o=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),h=i(7282),f=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),v=i(56038),w=i(31562),b=i(34102),S=i(88561),P=i(95696),_=i(17217),M=i(31843),T=i(70417),E=i(33847),k=i(28874),D=i(94678),x=i(43207),C=i(47783),F=i(16170),A=i(95141),I=i(1078),O=i(63870),L=i(89782),R=i(13940),N=i(34592),B=(0,r.lazy)((()=>(0,d.mkLogger)("img.Video")));function j(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function z(e){return(0,h.isProd)()&&(e=void 0),(0,n.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=z,t.isVideoSupported=(0,r.lazy)((async()=>{try{return!0===(await z())?.isSupportedVersion}catch(e){return B().warn("isVideoSupported",{error:e}),!1}})),(0,o.later)((()=>(0,b.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,M.lerp2d)(e,{x:76800,y:k.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:k.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,r.lazy)((()=>new S.FileCache({name:"img.videoFrame",timeoutMs:a.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,_.toNativePath_)(e))):void 0}async function U(e,t){const i=j("extractVideoFrame",e),r=P.PosixFile.for(e);if(!(0,n.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const s=await(0,R.cachedImageFile_)(r,"frame",".jpg");i.debug("extractVideoFrame("+s+")");const o=await r.mtimeMs();if(null==o)return i.throw("null mtime");const l=await(0,C.readRawTags)(r,!1);if(null==l)return i.throw("no tags");const u=(0,A.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,I.extractSizeInfoFromTags)(l,u)?.dimensions,d=await s.stat(),h=null==d?void 0:await(0,L.dimensions)(s);if(null!=d&&d.mtimeMs>o&&null!=h&&(null==c||h.height===c.height&&h.width===c.width))return i.debug("prior dest, "+s+" seems reasonable",{srcDim:c,destDim:h}),s.nativePath;const f=(0,x.extractDurationSec)(l),m=Math.min(f??0,k.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:f}),await s.applyIfEmpty_({fn_:async e=>{const t={src:r,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,w.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*a.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,C.deleteAllTags_)(e,e)},timeoutMs:(0,O.commandTimeoutMs)()}),s.nativePath}async function H(){return k.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function q(e){const t=j("needsTranscoding",e);if(!await H())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,C.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const r=i.MIMEType;if(!(0,F.isVideoMimeType)(r))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:r}});const n=(0,x.extractDurationSec)(i);if(!(0,c.gt)(n,k.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:n}});const a=(0,s.compactBlanks)([i.AudioFormat]),o=a.some((e=>(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,s.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeMimeTypes.values,r);return t.tap({level:"info",msg:"result",result:!(o&&u&&d),meta:{mimetype:r,isSafeMimeType:d,audioCodecs:a,isSafeAudioCodec:o,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>U(e)}),t.__extractVideoFrame_=U,t.isVideoTranscodingSupported=H,t.needsTranscoding=q;const G=new g.TTLMap(a.hourMs);function $(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,r){if(!await H())return;const s=j("transcode",e);{!function(){for(const[e,t]of G.entries())t.isSettled&&G.delete(e)}();const t=G.get(e.nativePath)??G.get(i.nativePath);if(null!=t)return s.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await q(e))return void s.info("no transcoding needed");const n=await e.size();if(!(0,u.gt0)(n))return s.throw("source is empty or cannot read");const a=await(0,C.readTags)(e),o=(0,I.extractSizeInfoFromTags)(a),d=(0,x.extractDurationSec)(a);if(null==a||null==o||null==d)return s.throw("failed: missing video metadata",{sizeInfo:o,durationSec:d});{const e=G.get(i.nativePath);if(null!=e)return s.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const h=new y.Deferred("transcode "+e);G.set(e.nativePath,h),G.set(i.nativePath,h);const m=(0,u.toGt0)(a.VideoFrameRate)??(0,u.toGt0)(a.FrameRate)??30,p=Math.round(o.dimensions.width*o.dimensions.height*(0,T.max)([(0,u.toGt0)(a.FrameCount),(0,u.toGt0)(a.VideoFrameCount),m*d]));if(!0===r?.force)await i.unlink();else if(await async function(e,t){const i=await(0,C.readRawTags)(t),r=await(0,C.readRawTags)(e),s=(0,x.extractDurationSec)(r),n=(0,x.extractDurationSec)(i);return B().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(s,n,1.5),meta:{srcDurationSec:s,destDurationSec:n,src:e.nativePath,dest:t.nativePath}})}(e,i))return s.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const r=j("extractMaxBitrate",e),s=k.Settings.minVideoDimension.valueOrDefault,n=i.ImageWidth;if(null!=n&&!(0,u.gte)(n,s))return r.throw("invalid width: "+n,{ignorable:!0});const a=i.ImageHeight;if(null!=a&&!(0,u.gte)(a,s))return r.throw("invalid height: "+a,{ignorable:!0});const o=(0,D.extractBitrateKbps)(i)??k.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,f.mapGt0)(n,(e=>(0,f.mapGt0)(a,(i=>(0,u.clamp)(0,o,(0,t.bitrateKps)(e*i)))))),c={width:n,height:a,videoBitrateKbps:l};return r.debug("dim()",{src:e,result:c}),c}(e,a);return await h.observe((0,v.time)("video.transcode:"+e,(async()=>{const t=$(n,g.videoBitrateKbps,d);return await i.applyWip_({fn_:n=>async function(n){s.info("starting...",{destWip:n});const o=new E.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:n,fps:m,halt:r.halt,...g},h=k.Settings.transcodeMaxDim.valueOrDefault,f=(0,T.max)([a.dimensions.height,a.dimensions.width]);if((0,u.gt0)(h)&&(0,c.gt)(f,h)){const e=(0,l.fitInside)(a.dimensions,{width:h,height:h});null==e?s.warn("Cannot downsample transcoded video: fitInside() returned null",{input:a.dimensions,maxPixels:h}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),s.info("Downsampling transcoded video",{original:a.dimensions,output:e}))}const p=await o.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&s.throw("transcode failed with code "+p.code)}(n),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&s.info("transcode complete",{src:e,dest:i,elapsedMs:h.elapsedMs,pixels:p}),i},t.guessExpectedSize=$,t.validVideo_=async function(e){return null==await W(e)&&j("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),h=i(56519),f=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),v=i(84258),w=i(28874),b=i(76280),S=i(63870),P=i(19769),_=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function M(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:w.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=M;const T=/ffmpeg version n?(?\S+)/i,E=(0,u.lazy)((async()=>{const e=await M();if(null==e)return void _().info("failed to find ffmpeg in $PATH",{ffmpegPath:w.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,S.commandTimeoutMs)(),ignoreStderr:!0}),i=T.exec(t.result)?.[1];return _().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,b.semverSatisfies)(i,">=3.2")}}));function k(){E.unset(),t.ffmpegVersionDescription.unset()}function D(e){const t=e?.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault;return(0,s.blank)(t)||(0,n.isDisabled)(t)?[]:["-hwaccel",t]}function x(e){const t=[...w.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(w.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),r=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+r),t}function C(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function F(e){const t=w.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,h.thenMapOr)(E(),(e=>"version "+e),(()=>"(not found)")))),(0,o.later)((()=>{(0,g.ee)().on("clearCache",k),(0,g.ee)().on("clearToolCache",k)})),t.ffmpegVersion_=async function(){return await E.prior()??E.refresh()},t.isFFmpegSupported=async function(){return null!=await E()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await M(),(0,r.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:a.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,f.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*a.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=x,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await M(),(0,r.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...x(t),...F(t),...D(t),"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...C(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){_().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,v.unlink)(t.dest,"debug");const r=(0,p.errorToS)(i,{maxLen:1024});if(!(0,n.isDisabled)(t.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(r))return _().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return _().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await M(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},51210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotate_=t.rotateInPlace_=t.validJpeg_=t.jpegtranVersion_=void 0;const r=i(19851),s=i(42659),n=i(21605),a=i(50213),o=i(84777),l=i(57159),u=i(95696),c=i(89966),d=i(43334),h=i(63870),f=i(19769),m=d.isWin?"NUL":"/dev/null",p=(0,r.lazy)((()=>(0,a.mkLogger)("img.jpegtran")));async function g(e,t,i){const r=await(0,c.jpegtranNativePath_)();if(!(0,n.isRotation)(i))throw new Error("refusing to rotate("+e+", "+i+")");await(0,o.stdout_)(r,["-copy","all","-trim","-rotate",i.toFixed(0),"-outfile",t.nativePath,e.nativePath],{timeoutMs:s.minuteMs}),t.clear()}t.jpegtranVersion_=async function(){const e=await(0,o.stdoutResult_)(await(0,c.jpegtranNativePath_)(),["-version"],{quiet:!0,timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:()=>!0});return(e.stderr??e.result).replace(/^libjpeg-turbo version/,"").trim()},t.validJpeg_=async function(e){const t=u.PosixFile.for(e),i=await(0,c.jpegtranNativePath_)();try{await(0,o.stdoutResult_)(i,["-outfile",m,t.nativePath],{timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:f.isIgnorableValidationError,ignoreExitCode:!0})}catch(e){throw p().warn("validJpeg caught invalid file",{src:t,cause:e}),new l.WrappedError("Invalid JPEG: "+t,{cause:e,path:t.nativePath,doNotSend:!0,fatal:!1,retriable:!1})}},t.rotateInPlace_=async function(e,t){p().info("rotateInPlace("+e+")",t),await e.applyWip_({fn_:i=>g(e,i,t),skipFsLock:!1,minSizeBytes:512,timeoutMs:s.minuteMs})},t.rotate_=g},19350:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dcraw_emu_=t.raw2tiff_=t.librawSupported=void 0;const r=i(19851),s=i(40958),n=i(33374),a=i(12168),o=i(23541),l=i(54993),u=i(50213),c=i(84777),d=i(98314),h=i(38835),f=i(57159),m=i(89966),p=i(28874),g=i(16170),y=i(54979),v=i(89782),w=i(13940),b=i(42725),S=i(19769),P=(0,r.lazy)((()=>(0,u.mkLogger)("img.libraw")));t.librawSupported=async function(e){try{return(0,g.isLibrawMimeType)(await(0,y.readMimeType)(e.nativePath))}catch(t){return P().warn("librawSupported("+e+"): failed to read filetype",t),!1}},t.raw2tiff_=async function(e){return(0,w.readableToFile_)({src:e,desc:"dcraw",suffix:".tiff",f:t=>k(e,t)})};const _=["-T"],M=["-Z","-"],T=["-o","1"],E=["-t","0","-j"];async function k(e,t){const i=await(0,v.dimensions)(e);if(null==i)return P().throw("Cannot decode RAW "+e+": no EXIF dimensions."+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);const r=b.ImageSize.largestFit().outputSize(i),u=[];null!=r&&4*(0,n.dmegapixels)(r)<(0,n.dmegapixels)(i)&&(P().debug("Large original source: using -h"),u.push("-h"));const g=await(0,m.dcrawEmuNativePath_)(),y=[..._,...M,...T,...u,...E,...p.Settings.dcrawEmuArgs.values,e.nativePath],w={encoding:"buffer",timeout:p.Settings.taskTimeoutMs.valueOrDefault,maxBuffer:250*a.MB};P().debug("dcraw_emu()",{cmd:g,args:y,opts:w});const k=(0,c.execFile)(g,y,void 0,w),D=[];function x(t){const i=(0,o.isError)(t)?(0,d.errorToS)(t):(0,l.toS)(t);if((0,S.isIgnorableValidationError)(i))P().info("dcraw_emu(): warning",{src:e,msg:i});else{P().warn("dcraw_emu(): error",{src:e,msg:i});const r=(0,o.isError)(t)?t:(0,f.toWrappedError)(i,{fatal:!1});D.push(r)}}if(k.on("error",x),k.stderr.on("data",x),await t.writeStream_(k.stdout),(0,s.isNotEmpty)(D))throw new f.WrappedError("Failed to convert RAW image "+e,{causes:D,path:e.nativePath});(0,c.endProcess)(k)}t.dcraw_emu_=k},36192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const r=i(19851),s=i(84777),n=i(8103),a=i(43334),o=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,r.lazy)((async()=>a.isMac?(0,n.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,s.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(o.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},71706:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.j=void 0;const r=i(38522);t.j=function(e){return JSON.parse((0,r.brotliDecompressSync)(Buffer.from(e,"base64")).toString("utf8"))}},83950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.L=void 0;const r=i(79114),s=i(40958),n=i(42659),a=i(34666),o=i(48884),l=i(97352),u=i(81674),c=i(84194);t.L=class{static for(e){return new this(e.str,e.l,e.sids,e.src)}constructor(e,t,i,r){this.s=e,this._l=t,this._sids=i,this.meta={src:r}}get l(){return this._l}get ok(){if(null==this._l)return!1;const e=(0,o.intersection)(this._sids,this._l.uids),t=(0,s.uniq)(e.map(c.getScheme)),i=(0,s.compact)(t.map((e=>(0,c.prefix2scheme)(e)))),r=i.length>=this._l.mat,a=(0,l.within)(this._l.iat?.getTime(),this._l.exp?.getTime()+n.dayMs,Date.now());return this.meta[(0,u.k)().o]=a,this.meta[(0,u.k)().u]=r,this.meta[(0,u.k)().m]=i,a&&r}cmpVal(){return[this.ok,-(r.S.indexOf(this.l?.[(0,u.k)().T])??0),this.l?.exp?.getTime()??1,this.meta.matchedSchemes]}cmp(e){return(0,a.cmp)(this.cmpVal(),e.cmpVal())}}},81674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p=t.l=t.t=t.b=t.m=t.vok=t.v=t.v_=t.k=void 0;const r=i(76790),s=i(22573),n=i(38639),a=i(45599),o=i(41400),l=i(96249),u=i(55835),c=i(31586),d=i(51926),h=i(79114),f=i(23541),m=i(59455),p=i(54993),g=i(72993),y=i(19851),v=i(50213),w=i(56519),b=i(76596),S=i(46292),P=i(87290),_=i(77740),M=i(34102),T=i(83278),E=i(28874),k=i(37692),D=i(71706),x=i(83950),C=i(72042),F=i(33603),A=i(48132);t.k=(0,y.rolazy)((()=>(0,D.j)("G1UBABwHdkz4hUIkFCfPXW5LlfvrWKSr9W3AIyIhUiw68NDfvLLHVop/bGoNnRxQlnqi2TZp0IJaX+lUHBoi+vMy2LMNpHCv8xVkUGsmQsgB8ldHoDqJeUQzbdybwikWVRs2KSWKjE5LnuqhTNSp3gTLhNfE9EqBLeaXP+UM9YqTGSXcyrcL03rIPMDAVyJplSZC0xoUgguOYJKvrcYFbNArN7BrQsnnsJ4hMtcSxOTxxRdxzETtL93qa3vjDw==")));const I=(0,a.defer)((()=>(0,v.mkLogger)((0,t.k)().l)));async function O(e){const i=await(0,C.V)((0,d.ensurePrefix)((0,p.toS)(e).trim(),(0,t.k)().p)),r=(0,b.utcIsoToTs)(i[(0,t.k)().i]);if(null==r)throw new Error("bad "+(0,t.k)().i+": "+i[(0,t.k)().i]+" ("+e+")");const s=(0,b.utcIsoToTs)(i[(0,t.k)().r]);if(null==s)throw new Error("bad "+(0,t.k)().r+": "+i[(0,t.k)().r]+" ("+e+")");return(0,_.getDevEnvFlag)((0,t.k)().y)&&(i[(0,t.k)().t]=!0),i[(0,t.k)().a]=(0,c.toGte0)(i[(0,t.k)().a])??2,i[(0,t.k)().i]=new Date(r),i[(0,t.k)().r]=new Date(s),i[(0,t.k)().b]=(0,p.toS)(i.uids).split(","),i}async function L(e,i,r,n){try{return(0,s.blank)(e)||e===(0,t.k)().f?void 0:x.L.for({str:e,l:await O(e),sids:null!=n?n:await(0,F.sids)({timeoutMs:r}),src:i})}catch(i){return I().tap({msg:(0,t.k)().v,result:{s:e,ok:!1,meta:{err:i}}})}}async function R(e,t){const i=[],r=await(0,w.sortByAsync)({name:"rawLicenseFromDir("+e+")",arr:e?.childFiles(),f:e=>e.mtimeMs()});for(const e of r.reverse()){const r=await L((0,m.toA)(await e.readLines()).map((e=>e.trim())).join(""),e.nativePath,A.UserTimeoutMs,t);null!=r&&i.push(r)}return i}async function N(){const e=await(0,t.m)();return e[0]?.ok?e[0]:void 0}async function B(){return(await N())?.l?.[(0,t.k)().T]??(0,t.k)().f}t.v_=O,t.v=L,t.vok=async function(e,t,i){if((0,s.blank)(e))return;const r=await L(e,t,i);return(0,n.isTrue)(r?.ok)&&r instanceof x.L?r:void 0},t.m=(0,y.rolazy)((async()=>{if((0,_.getDevEnvFlag)((0,t.k)().x))return[];const e=await(0,F.sids)({timeoutMs:A.UserTimeoutMs}),i=(0,u.map)((0,S.configDir)(),(e=>T.BaseFile.for(e))),s=(n=(0,l.flatten)((await(0,w.someOrTimeout)([()=>function(e){return L(E.Settings[(0,t.k)().L].value,"Settings",A.UserTimeoutMs,e)}(e),()=>R(i?.join((0,t.k)().d),e),()=>R((0,P.libraryDataDirPosixFile)()?.join((0,t.k)().d),e),()=>R(i?.sibling((0,g.AppName)().toLowerCase()).join((0,t.k)().d),e)],{timeoutMs:A.UserTimeoutMs})).filter((e=>!(e instanceof Error)))),(0,r.sortBy)(n.filter((e=>null!=e&&((0,f.isError)(e)&&I().warn((0,t.k)().d+": ",e),null!=e&&!(0,f.isError)(e)&&null!=e?.l))),(e=>[!e.ok,h.S.indexOf(e.l?.[(0,t.k)().T])??h.S.length+1,-(e.l?.exp?.getTime()??1)])));var n;return I().tap({msg:(0,t.k)().d+"()",result:s})})),(0,o.later)((()=>{(0,M.ee)().on("clearCache",(()=>t.m.unset())),(0,M.ee)().on((0,t.k)().c,(()=>t.m.unset())),k.stateEvents.on((0,t.k)().c,(()=>t.m.unset()))})),t.b=N,t.t=B,t.l=async function(){try{return await B()===(0,t.k)().f}catch{return!0}},t.p=async function(){try{return await B()===(0,t.k)().g}catch{return!1}}},72042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.V=t.l=void 0;const r=i(91227),s=i(19851),n=i(22573),a=i(71706);t.l=(0,s.lazy)((()=>(0,a.j)("G54BgBwHzrkukKDR8Ar6KkW29gbXlfrqQX46gTu5Wfq6dELYTjfBokB0d5+E2SAINBtxlmPquWe3PMUoNgaJrD982QMslkNeZ4BEqcBbQT59DVl9RnoTNi50diuT7NQg0YHxkr8SwDwtmFUOf+LwNVDDnPXUrzTOU++M3b+lcyfr7PXZndKHzho8iztNkZgt+/19//aXe+gvmC0HIdnn64wdLeYeLM7S9jmjTp52SzFsvIVbd4D0+rdtdjiz6R4vc2cmY398kuXiKG7fNXWS/I93etxXiVNPd4RXJF+k6JnuMUKk03GWHQQ="))),t.V=function(e){const i=(0,r.decode)(e).payload;if(null==i)throw new Error("Missing payload");const s=(0,n.notBlankOr)(i.k,(0,t.l)().d),a=(0,t.l)().o.find((e=>e.k===s));if(null==a)throw new Error("Unknown key");return r.V2.verify(e,a)}},84194:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SchemeCounts=t.isValidUid=t.toUID=t.UidLength=t.prefix2scheme=t.sortUids=t.getScheme=t.S=void 0;const n=i(40958),a=i(76790),o=i(22573),l=i(45599),u=i(50989),c=i(54993),d=i(22454),h=i(19851),f=i(50213),m=i(37628),p=i(55222),g=i(71706),y=(0,l.defer)((()=>(0,g.j)("GyABAIzUYs0Z7mSuLfVL1SwGefr+3nCwyXBMg6nD0qduA8HycFjUGK1N/ikYqhiqYLGbs7oxTBbzRPxteP9gA3L9DS0EJ2BJ1pYNa/DtEE2aPI2o03hHx3k9MhdE7jAeRUvKQ6tY3Q1fcIPe8GBMZvOeKibTymyo3Cw/7Ua42DKPjpL3wxWv+7TCGA==")));function v(e){const i=e.split(":",1)[0];return t.S.has(i)?i:void 0}t.S=(0,u.strEnum)("cu","lc","lm","lp","lb","mp","ms","wm","cm","bm","nm","li","si","vl"),t.getScheme=v,t.sortUids=function(e){return(0,a.sortBy)((0,n.uniq)(e.filter(S)),(e=>[t.S.indexOf(v(e))??t.S.length+1,e]))},t.prefix2scheme=function(e){return y()[e]};const w=["uninitialized","b08dfa6083e7567a1921a715000001fb"];t.UidLength=15,t.toUID=function(e,i){try{const r=(0,c.toS)(i).replace(/[^a-z\d=/+]+/gi,"");return(0,o.blank)(r)||w.includes(r.toLowerCase())||null!=r.match(/^[\s0:_/-]*$/)?void 0:e+":"+(0,m.shortStringSha)(r,t.UidLength,p.Radix58)}catch(t){return void(0,f.mkLogger)("toUID").warn("failed",{pfx:e,err:t})}};const b=(0,l.defer)((()=>new RegExp(`^(?:${t.S.values.join("|")}):[0-9a-zA-Z]{${t.UidLength}}$`)));function S(e){return null!=e&&null!=b().exec(e)}t.isValidUid=S,t.SchemeCounts=class{constructor(e){r.set(this,new Set),this.schemeCounts=(0,h.lazy)((()=>{const e=new d.CountingSet;for(const t of s(this,r,"f")){const i=v(t);null!=i&&e.incr(i)}return e})),null!=e&&this.addUids(e)}get size(){return s(this,r,"f").size}addUids(e){for(const t of e)null==v(t)||s(this,r,"f").has(t)||(s(this,r,"f").add(t),this.schemeCounts.unset())}count(e){return this.schemeCounts().get(e)}},r=new WeakMap},33603:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearSids=t.addSids=t.sids=t.win_machineGuid_=t.readInfo=t.k=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(45599),o=i(96249),l=i(68708),u=i(51926),c=i(59455),d=i(54993),h=i(50213),f=i(7282),m=i(56519),p=i(84777),g=i(84542),y=i(19254),v=i(45879),w=i(70854),b=i(57902),S=i(72308),P=i(43334),_=i(24399),M=i(7014),T=i(30933),E=i(71706),k=i(84194);t.k=(0,a.defer)((()=>(0,E.j)("G9ABYIzDOIZ8NLQ4t7qW8tNrmrOzz+qFGfAxl8jW4E2tLxwWRZT5TueCnPcwgTzT1DN3veRB+e7EYGlYHg6nhjBDQv7zI6EcYWk35z6QuZC3Q0itjrLCbmgd0iED0BvGiYLBJwRU1O9/3Agbl8IfG6ITVFWDRwyTw3rbUMo/XMyAVW7R23mkwUx0l4/7iA13RV/nmPuJFKp5BvJW7SoXJZoWEfdSNYYhN5UCtkbC7O1AaPIbU3P6uRLmEyb4TaHWzFigvrlmZVUzzp9j/Mz55vqN88ewd1Nrfh7gkVRQ7TtB7Ztz3XJxYC3ogdJHg8HGsG4=")));const D=(0,a.defer)((()=>(0,h.mkLogger)((0,t.k)().n)));async function x(e=(0,t.k)().pc){if(P.isLinux)try{const t=await(0,y.fileGrep_)(e,/^\s*(?:hardware|revision|serial|model)\s*[:=]\s*[a-z\d]{6}.*$/i),i=(0,r.compactBlanks)((0,g.splitLines)(t).map((e=>e.replace(/\s+/g," ")))).sort();return i.some((e=>null!=e.match(/^serial/i)))?i:void 0}catch{return}}t.readInfo=x;const C=(0,a.defer)((()=>(0,m.thenMap)(x(),(e=>(0,k.toUID)(k.S.lc,e.join(",")))))),F=/o\.e\.m\./i;async function A(e){return(0,r.uniq)(await Promise.all((0,t.k)()[e].map((e=>(0,v.readFileMaybe)(e,b.LogLevels.trace))))).map(d.toS).filter((e=>(0,s.notBlank)(e)&&null==e.match(F)))}async function I(){return P.isLinux?(await A("lm")).map((e=>(0,k.toUID)(k.S.lm,e))):void 0}async function O(){return P.isLinux?(await A("lp")).map((e=>(0,k.toUID)(k.S.lp,e))):void 0}async function L(){return P.isLinux?(await A("lb")).map((e=>(0,k.toUID)(k.S.lb,e))):void 0}async function R(){if(P.isMac)try{return(0,l.entries)(await async function(){const e=await(0,p.stdout_)((0,t.k)().i,(0,t.k)().ia,{timeoutMs:5*n.secondMs}),i=e.match(/uuid" = "([a-z\d-]{12,})"/i)?.[1],r=e.match(/SerialNumber" = "([a-z\d-]{10,})"/i)?.[1];return{mp:i,ms:r}}()).map((([e,t])=>(0,k.toUID)(e,t)))}catch(e){return void D().warn((0,t.k)().i+" failed",e)}}async function N(){return(await _.PowerShell.instance().executeJson((0,t.k)().w))?.MachineGuid}async function B(){return P.isWin?(0,k.toUID)(k.S.wm,await N()):void 0}t.win_machineGuid_=N;const j=(0,a.defer)((()=>(0,k.toUID)(k.S.cm,(0,T.cpuInfo)()[0].model)));async function z(){return P.isLinux?(0,k.toUID)(k.S.bm,(0,r.compactBlanks)(await A("bm")).map((e=>e.trim())).join("\n")):[]}async function V(){return(0,k.toUID)(k.S.li,await((0,w.LibraryUIDStore)()?.readUid_()))}async function W(){return(0,k.toUID)(k.S.si,await((0,w.SystemUIDStore)()?.readUid_()))}function U(){return(0,S.networkMacAddresses)().map((e=>(0,k.toUID)(k.S.nm,e)))}async function H(){return(0,c.toA)(await(0,M.volumes)()).map((e=>(0,k.toUID)(k.S.vl,e.uuid)))}const q=new Set;t.sids=async function({timeoutMs:e}){const t=Date.now(),i=[j,C,R,V,W,z,I,O,L,B,U,H],r=(0,o.flatten)(await(0,m.someOrTimeout)(i,{timeoutMs:e})).filter(u.isString);for(const e of r)q.add(e);return D().tap({msg:"sids()",result:(0,k.sortUids)([...q,...r]),meta:{timeoutMs:e,elapsedMs:Date.now()-t}})},t.addSids=function(e){if((0,f.isTest)())for(const t of e)q.add(t)},t.clearSids=function(){(0,f.isTest)()&&q.clear()}},48132:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserTimeoutMs=void 0;const r=i(42659);t.UserTimeoutMs=7*r.secondMs},49794:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),s=i(19851),n=i(40958),a=i(22573),o=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,s.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,a.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,n.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),s=i(23560),n=i(66184),a=i(72210);class o{log(e,t,i,r){this.enabled(e,t)&&(0,a.pushLogEntries)({ts:Date.now(),l:e,from:(0,s.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,n.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=o,o.instance=(0,r.lazy)((()=>new o))},14593:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),s=i(22573),n=i(26905),a=i(55835),o=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,s.toNotBlank)(e)??(0,n.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,o.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),s=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:s}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,a.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,o.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),s=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof s.LogWriter))}},28981:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),s=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new s.PlaintextLogFormatter))},31256:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(41400),o=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,n.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,a.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,s.uniq)((0,s.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,o.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,o.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const n=i(77030),a=i(19851),o=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),v=i(31256),w=i(28538),b=(0,a.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),S=String.fromCharCode(0);t.logBroadcaster=(0,a.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,o.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&b().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,n.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{b().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){b().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),s(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,n){if(this.enabled(e,t))try{const a=this.socket;null==a?s(this,r,"f").call(this):a.write(this.logFormatter.format(e,t,i,n)+S)}catch(r){b().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:n,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),s=i(42659),n=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??n.Settings.logDir.valueOrDefault,(0,s.fmtIsoDate)(t??new Date))}},12495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogDirCleanup=void 0;const r=i(19851),s=i(42659),n=i(23560),a=i(79267),o=i(32144),l=i(28874);t.LogDirCleanup=(0,r.lazy)((()=>(0,n.isBillingService)()?void 0:a.FileCleanup.for({name:"logDirCleanup",rootNativePath:()=>l.Settings.logDir.valueOrDefault,staleMs:s.weekMs,isPrunable:e=>(0,o.isLogExt)(e.ext)})))},4904:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),s=i(31586),n=i(51926),a=i(57902);t.isLogEntry=function(e){return null!=e&&(0,s.isNumber)(e?.ts)&&(0,n.isString)(e?.msg)&&a.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),s=i(57902);class n{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,s.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,s.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=n,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new n(s.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>s.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,s.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,s.set(this,[]),n.set(this,(0,l.lazy)((()=>{o(this,s,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:o(this,s,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>o(this,n,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=o(this,r,"m",a).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=o(this,r,"m",a).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){if(null==e||0===o(this,s,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return o(this,s,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),s=i(31586),n=i(50989);t.LogLevels=(0,n.strEnum)("fatal","error","warn","info","debug","trace");const a=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??a},t.levelGte=function(e,i){return(0,s.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const o=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return o.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),s=i(68708),n=i(20214),a=i(51926),o=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,a.isString)(i)||Buffer.isBuffer(i))return(0,a.ellipsize)(i.toString(),256,32);if((0,o.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,n.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const o=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,s.keys)(i),(0,s.keys)(o));return(0,r.isNotEmpty)(c)&&(o["…"]="omitted: "+(0,a.ellipsize)(c.join(", "),128,32)),o}return i}},24068:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),s=i(76760),n=i(1708),a=i(87997),o=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),v=i(22277),w=i(25764),b=i(38836),S=i(99331),P=i(42638),_=i(76596),M=i(98314),T=i(89968),E=i(29882),k=i(28874),D=i(28981),x=i(20839),C=i(21727),F=i(66184),A=i(57902),I=i(72210),O=i(98192);function L(e){const t=(0,D.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=L;class R extends b.EndableWrapper{constructor(e=void 0,t=L){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,o.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,k.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,E.mkdirp_)(e),this.root=await T.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=s.sep+(0,p.serviceName)()+"-"+n.pid+"-",n.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,a.setInterval)((()=>this.flush()),x.DefaultLogFlushMs/2),this.scanTimeout=(0,a.setInterval)((()=>this.scan()),u.minuteMs),n.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,S.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,F.ifLog)(A.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,s.join)(e,i))}))}catch(t){return void(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,M.errorToS)(t))))}}))}async scan(e=!1){if((0,S.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,_.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,S.ending)()||this.ended)return;const t=(0,C.datedLogDir)(this.root.nativePath);try{await(0,E.mkdirp_)(t),this.watchDir(t)}catch(e){(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,M.errorToS)(e))))}(0,S.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,a.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,a.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await T.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(r,i))return;await(0,f.thenMap)((0,O.readLogEntries)(e,{start:r,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,M.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,o.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),s=i(82328),n=i(28981),a=i(20839),o=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(o.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,s.stdoutEnded)()||console.log((0,n.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*a.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),v=i(31586),w=i(409),b=i(23560),S=i(81168),P=i(78406),_=i(25764),M=i(20197),T=i(14977),E=i(36868),k=i(28874),D=i(32105),x=i(20839),C=i(21727),F=i(66184),A=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class O extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*x.DefaultLogFlushMs),rank:_.EndableRanks.logger,unref:!0,onEnd:()=>c(this,s,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,s.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:D.ConsoleLogger.instance(),flushEveryMs:x.DefaultLogFlushMs,processName:b.processName,logFilter:F.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",n).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const s={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(s.meta=(0,A.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(s)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=O,s=new WeakMap,r=new WeakSet,n=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),s=e.splice(0,i);this._linesSinceRotate+=s.length,t.write(s.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},a=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},o=function(e){return t=>(c(this,r,"m",a).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,S.stripAnsiEsc)(this.logOpts.processName()),t=await(0,M.ensureNewNativePath_)({nativePath:(0,f.join)((0,C.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,r,"m",o).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,E.endStream)(e.stream),k.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,T.gzip_)(e.nativePath))}catch(e){c(this,r,"m",a).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(68708),o=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,a.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,s.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,n.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),s=i(84542),n=i(4001),a=i(13047),o=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,o.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,n.stripCopySuffixFromName)(e.name),r=[],o=await(0,a.zcat)(e.nativePath,t);if(null!=o)for(const e of(0,s.splitLines)(o)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),s=i(76790),n=i(68708),a=i(89788),o=i(57902);t.SentLogLevels=(0,r.lazy)((()=>o.LogLevels.values.filter((e=>e!==o.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,n.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new a.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,n.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,n.values)(l()))e.push(...t.toA());return(0,s.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),s=i(41400),n=i(55835),a=i(37975),o=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),v=i(66184),w=i(28538),b=i(24068),S=i(43705),P=i(51879);function _(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),M();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new S.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,n.map)((0,y.logBroadcaster)(),(e=>i.push(e))),o.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&b.LogTail.instance()}function M(){const e=h.Settings.logColor.valueOrDefault;(0,a.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=_,t.setupLogFormatter=M,(0,s.later)((()=>{h.Settings.logStdout.watchLater(_),h.Settings.logDir.watchLater(_),h.Settings.tailLogs.watchLater(_),h.Settings.logColor.watchLater(M),h.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},82647:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const a=i(57975),o=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,a.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return n(this,r,"m",s).call(this,-1)}get p29(){return n(this,r,"m",s).call(this,-.5)}get p38(){return n(this,r,"m",s).call(this,-.25)}get p69(){return n(this,r,"m",s).call(this,.5)}get p84(){return n(this,r,"m",s).call(this,1)}get p98(){return n(this,r,"m",s).call(this,2)}get p99(){return n(this,r,"m",s).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,o.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,o.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,o.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,s=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),s=i(55835),n=i(31586),a=i(30976),o=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,n.clamp)(0,i,(0,n.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,s.map2)(e,t,((e,t)=>(0,r.sum)((0,o.zip)(u(e,i),u(t,i)),(([e,t])=>(0,n.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,n.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,a.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),s=this.clampValue(e);let n=0;for(let e=0;ea?(n+=1,i[t]=a):r[t]=a}return n}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let s=0;s(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,n.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;in?(t+=1,s.min=n):s.max=n}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},44983:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.kmeans=void 0;const r=i(76790),s=i(93973);t.kmeans=function(e,t,i){const n=s(e,t,i);return{...n,centroids:(0,r.sortBy)(n.centroids.filter((e=>e.size>0)),(e=>-e.size))}}},31843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const r=i(76790);function s(e,t,i=.5){return(1-i)*e+i*t}t.lerp=s,t.lerp2d=function(e,...t){const i=(0,r.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[n,a]=(0,r.sortBy)(i,(e=>e.x)),o=a.x-n.x,l=(e-n.x)/o;return s(n.y,a.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},75503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modeReduce=t.submatrixCollect=t.greatestHalf=t.leastVariantQuarter=t.leastMagQuarter=t.submatrixMode=t.submatrixStdDev=t.submatrixMagnitude=t.submatrixForEach=t.index1D=t.slice=t.matXvec=t.vecXvec=void 0;const r=i(40958),s=i(31586),n=i(48884),a=i(82647),o=i(70417);function l(e,t,i,r){const s=Math.floor(Math.max(0,t.row)),n=Math.ceil(Math.min(e.row,i.row)),a=Math.floor(Math.max(0,t.col)),o=Math.ceil(Math.min(e.col,i.col));for(let t=s;t(0,s.mapFinite)(e[t],(e=>n+=e*e)))),Math.sqrt(n)}function c(e,t,i,r){const n=new a.Average;return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),n.stdDev}function d(e,t,i,r){const n=[];return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),(0,o.mode)(n)}t.vecXvec=function(e,t){return e.map(((e,i)=>e*t[i]))},t.matXvec=function(e,t){return e.map(((e,i)=>{if(e.length!==t.length)throw new Error("misshaped matrix on row "+i);return(0,o.sumf)(e,((e,i)=>e*t[i]))}))},t.slice=function(e,t,i){const s=Math.max(0,t.row),n=Math.min(e.length,i.row),a=Math.max(0,t.col),o=Math.min(e[0].length,i.col);return(0,r.range)(s,n,(t=>e[t].slice(a,o)))},t.index1D=function(e,t,i){return t*e.col+i},t.submatrixForEach=l,t.submatrixMagnitude=u,t.submatrixStdDev=c,t.submatrixMode=d,t.leastMagQuarter=function(e,t){const i=t.col,r=t.row,s=[u(e,t,{col:i/2,row:0},{col:i,row:r/2}),u(e,t,{col:0,row:0},{col:i/2,row:r/2}),u(e,t,{col:0,row:r/2},{col:i/2,row:r}),u(e,t,{col:i/2,row:r/2},{col:i,row:r})];return(0,n.leastIndex)(s)},t.leastVariantQuarter=function(e,t){const i=t.col,r=t.row;return(0,n.leastIndex)([c(e,t,{col:i/2,row:0},{col:i,row:r/2}),c(e,t,{col:0,row:0},{col:i/2,row:r/2}),c(e,t,{col:0,row:r/2},{col:i/2,row:r}),c(e,t,{col:i/2,row:r/2},{col:i,row:r})])},t.greatestHalf=function(e,t){const i=t.col,r=t.row,s=[d(e,t,{col:0,row:0},{col:i,row:r/2}),d(e,t,{col:0,row:0},{col:i/2,row:r}),d(e,t,{col:0,row:r/2},{col:i,row:r}),d(e,t,{col:i/2,row:0},{col:i,row:r})];return(0,n.greatestIndex)(s)},t.submatrixCollect=function(e,t,i){const r=[];return l(e,t,i,(e=>r.push(e))),r},t.modeReduce=function(e,t,i){const o=Math.floor(t.col/i.col),u=Math.floor(t.row/i.row),c=new a.Average(Math.ceil(o*u));return(0,n.concat)(...(0,r.stepRange)(0,t.row,u,(i=>(0,r.stepRange)(0,t.col,o,(r=>(c.clear(),l(t,{col:r,row:i},{col:r+o,row:i+u},(t=>(0,s.mapFinite)(e[t],(e=>c.push(e))))),c.sampleMode))))))}},36372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stableContentShuffle=t.stableIndexShuffle=t.factors=t.primeSeeds=t.primeInt=t.primes=t.prng=t.prngOrderByClause=void 0;const r=i(76790),s=i(42659),n=i(31586),a=i(97238),o=i(50597),l=i(9103),u=i(55222);function c(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e),u=(s*i*i+n*i)%r,c=(a*i+o)%r;return Math.round((u*c+l)%r)}function d(e){return(0,u.encodeDigits)(a.PrimesPerBin,e,a.PrimeBins).map(((e,i)=>t.primes[i][e]))}t.prngOrderByClause=function(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e);return`(((${s}*${i}*${i}+${n}*${i})%${r})*((${a}*${i}+${o})%${r})+${l})%${r}`},t.prng=c,t.primes=[[353868013,472882027,479001599,517294153],[1012573,1230587,1355297,1572751],[756065159,812182027,899809343,989450477],[3959297,4514113,4823201,5133127],[573259391,666101999,694847533,746151647],[2275327,2770513,3073703,3511973],[173313197,182557181,203457869,222230231],[6054613,6189107,7752103,9852103]],t.primeInt=[1012573,1101689,1183811,1196089,1230587,1355297,1419641,1483733,1572751,2275327,2770513,3010349,3073703,3118691,3174823,3511973,3959297,4514113,4690451,4823201,5133127,5375327,6019889,6054613,6189107,7752103,7752103,9852103],t.primeSeeds=d,t.factors=(0,l.memoize)((e=>{const[i,r,s,o,l,u,c,h]=d(e%a.SeedCount),f=[i/r,s/o,l/u,c/h].map((e=>(0,n.sigFigs)(e,7)));return f.push(t.primeInt[e%t.primeInt.length]),f}),{maxSize:128,ttlMs:s.minuteMs}),t.stableIndexShuffle=function(e,t=1){return(0,r.sortBy)(e,((i,r)=>c(t,r,e.length)))},t.stableContentShuffle=function(e,t=1){return(0,r.sortBy)(e,(e=>(0,o.numericSha)(String(e)+t)))}},55222:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),s=i(22573),n=i(55835),a=i(32639),o=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,n.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,s.blank)(e))return;const t="-"===(e=(0,a.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),s=this.normalizeToken(t);return r.length>=i&&r===s}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const r=i(31586),s=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,r.toInt)(e)]??(0,s.toS)(e)}},38812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SquareMatrix=t.rotateSquareMatrix=void 0;const r=i(21605);t.rotateSquareMatrix=function(e,t){return 0===(0,r.normalizeRotation)(t)?e:new s([...e]).rotate(t).m};class s{constructor(e,t=1){if(this.m=e,this.ary=t,this.rows=Math.sqrt(e.length/t),this.rows!==Math.floor(this.rows))throw new Error(`Only square tuple matrices are supported: ${1===this.ary?"":this.ary}(${this.rows}×${this.rows}) != ${e.length}`)}index(e,t){return this.ary*(t+e*this.rows)}swap(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),s=i(65713);function n(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=n,t.safeUUID=function(){return(0,s.decuss)(n)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const o=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function v(e,t){let i=0,r=0;for(const s of e){if(null!=s){const e=t(s,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=v;class w{constructor(){r.set(this,0),s.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(a(this,s,null==n(this,s,"f")?e:n(this,s,"f")*n(this,r,"f")/(n(this,r,"f")+1)+e/(n(this,r,"f")+1),"f"),a(this,r,(t=n(this,r,"f"),++t),"f"))}get mean(){return n(this,s,"f")}}function b(e){const t=new w;for(const i of e)t.push(i);return t.mean}function S(e){const t=b(e);if(null==t)return;let i=0,r=0;for(const s of e)(0,u.isNumber)(s)&&(r++,i+=(s-t)*(s-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function _(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+a*(e-s)/n)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=b(t);if(null!=i){const e=(t.length-1)/2,r=v(t,((t,r)=>(t-i)*(r-e))),s=v(t,(e=>(e-i)**2));return 0===s?0:r/s}},t.variance=S,t.stdDev=function(e){return(0,l.map)(S(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,o.isEmpty)(e)&&(0,o.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},23624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64encodeBits=t.b64hammRatio=t.gz64decodeString=t.d=t.gz64encodeString=t.b64decode=t.b64encode=t.hex2b64=void 0;const r=i(38522),s=i(22573),n=i(97352);function a(e){const t=e.toString(16),i=t.length%2==0?"":"0";return Buffer.from(i+t,"hex").toString("base64")}function o(e){return BigInt("0x0"+Buffer.from(e,"base64").toString("hex"))}function l(e){return(0,r.gunzipSync)(Buffer.from(e,"base64")).toString("utf8")}t.hex2b64=function(e){return Buffer.from(e,"hex").toString("base64")},t.b64encode=a,t.b64decode=o,t.gz64encodeString=function(e){return(0,r.gzipSync)(Buffer.from(e,"utf8")).toString("base64")},t.d=l,t.gz64decodeString=l,t.b64hammRatio=function(e,t){return(0,s.mapNotBlank)(e,(e=>(0,s.mapNotBlank)(t,(t=>(0,n.hammRatioBigInt)(o(e),o(t))))))},t.b64encodeBits=function(e){return a(BigInt("0b0"+e.map((e=>1===e?"1":"0")).join("")))}},49076:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const s=r(i(48161)),n=i(19851),a=i(22573),o=i(41400),l=i(81168),u=i(28874);t.hostname=(0,n.lazy)((()=>u.Settings.hostname.value??s.default.hostname())),(0,o.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,a.blank)(e)&&!(0,a.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??s.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},43205:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemUserAgent=t.simpleUserAgent=t.userAgent=void 0;const r=i(72993),s=i(17344),n=i(96175),a=i(37805),o=i(81674),l=i(28874);function u(){return r.SimpleAppName+a.version}async function c(){return u()+" ("+(0,n.osFullName)()+") "+(0,s.EditionType)().toLowerCase()+"/"+await(0,o.t)()}t.userAgent=async function(){return l.Settings.allowUserAgent.valueOrDefault?c():u()},t.simpleUserAgent=u,t.systemUserAgent=c},72308:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLocalhost=t.isLoopback=t.myExternalIp4Addresses=t.myExternalIpAddresses=t.networkMacAddresses=t.myIpAddresses=void 0;const r=i(48161),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(96249),u=i(31586),c=i(68708),d=i(50213),h=i(81168);function f(){return(0,t.myIpAddresses)().filter((e=>!g(e)))}t.myIpAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.address))))),o.minuteMs),t.networkMacAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.mac)))).filter((e=>"00:00:00:00:00:00"!==e))),o.minuteMs),t.myExternalIpAddresses=f,t.myExternalIp4Addresses=function(){return f().filter((e=>!e.includes(":")))};const m=(0,s.lazy)((()=>(0,d.mkLogger)("net.ip"))),p=[/^(?:::ffff:)?127\.\d{1,3}.\d{1,3}.\d{1,3}$/i,/^::1$/];function g(e){return(0,a.notBlank)(e)&&(127===function(e){const t=e.split(".").map((e=>(0,u.toInt)(e)));return 4!==t.length||t.some((e=>null==e||!(0,u.within)(0,255,e)))?void 0:t}(e)?.[0]||p.some((t=>null!=t.exec(e))))}t.isLoopback=g,t.isLocalhost=function(e){return m().tap({msg:"isLocalhost",level:"info",result:!(0,a.blank)(e)&&((0,t.myIpAddresses)().includes(e)||(0,t.myIpAddresses)().includes((0,h.stripPrefix)(e,"::ffff:"))||g(e)),meta:{address:e}})}},96128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),v=i(34102),w=i(26293),b=new RegExp("^"+w.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==b.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const S=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=S.exec(e)}function _(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=_,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,n.blank)(e)){if(null!=_(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void M().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs});const M=(0,s.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,o.later)((()=>(0,v.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=_(e)?r.promises.reverse(e):r.promises.resolve4(e),5*a.secondMs);if(t===c.Timeout)return M().info("nslookup("+e+"): timeout"),e;const i=t.find(n.notBlank);return null==i?(M().warn("No name found for "+e),e):i}catch(t){return M().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,n.blank)(e)&&!(0,n.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),s=i(42659),n=i(31586),a=i(97790),o=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*s.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,n.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,a.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,o.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs})},78330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const r=i(40958),s=i(22573),n=i(45599),a=i(59455),o=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),h=i(63870),f=(0,n.defer)((()=>(0,o.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,a.toA)(await async function(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return f().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,r.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(f().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),s=i(38639),n=i(19851),a=i(59958),o=i(43334);t.isDocker=(0,n.lazy)((()=>o.isLinux&&((0,s.toBoolean)(process.env[a.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),s=i(19851),n=i(54993);t.isPacked=(0,s.lazy)((()=>!(0,n.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const r=i(45599),s=i(50213),n=i(84777),a=i(68284),o=i(63870),l=i(43334),u=(0,r.defer)((()=>(0,s.mkLogger)("platform.Pacman")));t.hasPacman=(0,r.defer)((()=>l.isLinux&&(0,a.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,n.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,o.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(22573),o=i(38639),l=i(59958),u=s.default.platform();t.inspectFlag=n.default.argv.includes("--inspect")||(0,o.isTrue)(n.default.env.NODE_INSPECT),t.isCI=(0,o.isTrue)(n.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,a.notBlank)(n.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===s.default.arch(),t.isArm=null!=/^arm\b/i.exec(s.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,a.notBlank)(n.default.env.APPIMAGE)||(0,a.notBlank)(n.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,a.notBlank)(n.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=n.default.versions.electron,t.isElectron=t.isMainElectron||(0,o.isTrue)(n.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const s=r(i(73024)),n=i(19851),a=i(43334);function o(e="/proc/cpuinfo"){if(a.isWin||a.isMac)return!1;try{return null!=s.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=o,t.isRaspberryPi=(0,n.lazy)((()=>a.isLinux_arm&&o())),t.procDeviceModel=(0,n.lazy)((()=>{try{return a.isLinux?s.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},94137:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.negateFilterName=void 0;const r=i(22573),s=i(51926),n=i(83556);t.negateFilterName=function(e){if((0,r.blank)(e))return;const t=/\s/.test(e)?e:(0,n.camel2words)(e).replace(/\bphoto structure\b/gi,"PhotoStructure");return t.match(/^not\b/)?t.replace(/^not\b/,"").trim():"not "+(0,s.stripPrefix)(t,"is ")}},78984:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Predicates=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(51926),o=i(50213),l=i(94137),u=(0,r.lazy)((()=>(0,o.mkLogger)("predicates.Predicates")));class c{static async accepted(e,...t){for(const i of t)for(const t of(0,n.values)(i)){const i=await t(e);if(!1===i||(0,a.isString)(i))return!1}return!0}static async rejected(e,...t){return!await c.accepted(e,...t)}static async explain(e,...t){const i=[],r=[],s=[];for(const o of t)for(const[t,l]of(0,n.entries)(o)){const n=await l(e);!0===n?i.push(t):!1===n||(0,a.isString)(n)?r.push(t):s.push(t)}return{accepted:i,rejected:r,notApplicable:s}}static async whyRejected(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))try{const i=await r(e);if(null==i||!0===i)continue;return(0,a.isString)(i)?i:(0,l.negateFilterName)(t)}catch(e){u().warn("whyRejected() caught from "+t,{error:e})}}static async logged({a:e,logger:t,msg:i,predicates:r}){const{accepted:n,rejected:a}=await c.explain(e,...r);return t.tap({msg:i,result:(0,s.isEmpty)(a),meta:{a:e,accepted:n,rejected:a}})}}t.Predicates=c},33995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncPredicates=void 0;const r=i(68708),s=i(94137);class n{static firstFalse(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!1===s(e))return t}static firstTrue(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!0===s(e))return t}static firstDefined(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i)){const i=s(e);if(null!=i)return{name:t,result:i}}}static accepted(e,...t){return null==n.firstFalse(e,...t)}static whyRejected(e,...t){return(0,s.negateFilterName)(n.firstFalse(e,...t))}}t.SyncPredicates=n},45643:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),s=i(59455),n=i(31562);t.existingPids=function(e){return(0,s.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,n.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(97790),w=i(59455),b=i(54993),S=i(54557),P=i(19851),_=i(50213),M=i(88158),T=i(409),E=i(78406),k=i(25764),D=i(99331),x=i(56519),C=i(46292),F=i(8769),A=i(83278),I=i(32144),O=i(29882),L=i(43334),R=i(24399),N=i(58261),B=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),j=10*p.secondMs;function z(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,O.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))B().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,T.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{B().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??L.isWin,r=await this.pidfiles(),s=await this.pids(r??[]);if((0,f.isEmpty)(s))return B().info("killOldProcs(): no pidfiles"),[];const n=[],a=[],o=await(0,N.pidInfos)(s);if(null!=o){for(const s of r){const r=await s.readJson();if(null==r){B().warn("killOldProcs(): failed to read pidfile "+s.base),await s.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){B().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+s.base,{json:r,pid:l}),await s.unlink("debug");continue}const u=o.find((e=>e.pid===l));if(null==u||!z(r,u)){B().debug("killOldProcs(): pid no longer present: unlinking "+s.base,{json:r,pidEntry:u}),await s.unlink("debug"),n.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(B().info("killOldProcs(): killing",{reason:d,json:r}),a.push(W(l,i,!1)),n.push({...r,...u}))}return a.length>0&&await Promise.allSettled(a),n}(0,F.onError)("Pids.killOldProcs(): failed to get process information")}}),a.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const a=e.pid;if(!(0,y.gt0)(a))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(a)?(i&&o(this,s,"f").delete(l),o(this,s,"f").getOrSet(l,(async()=>{const i=o(this,r,"m",n).call(this,e.pid),s=(0,v.opt)((0,M.Try)((()=>(0,O.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),a=t.getTime(),l={...e,cmd:s,startTime:a};return await i.writeJson_(l),B().debug("addPid() wrote "+i,l),i}))):(o(this,s,"f").delete(l),void B().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=o(this,r,"m",n).call(this,e);return(0,x.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{B().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==o(this,a,"f")||o(this,a,"f").ended)&&l(this,a,new E.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:k.EndableRanks.first}),"f"),o(this,a,"f")}cancelInterval(){o(this,a,"f")?.end(),l(this,a,void 0,"f")}}t.Pids=U,s=new WeakMap,a=new WeakMap,r=new WeakSet,n=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,C.configDir)(),(e=>new U(A.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const s=i(31421),n=i(48161),a=r(i(1708)),o=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),v=i(84968),w=i(48963),b=i(56519),S=i(84777),P=i(8103),_=i(45879),M=i(43334),T=i(24399),E=i(45643),k=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function D(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function x(e){if(M.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,_.readFileMaybe)("/proc/"+i+"/stat")));return k().tap({msg:"pidInfoProc",result:(0,o.compact)(t)})}(e);const t=(0,E.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,M.isWin?I:N)).filter((e=>D(e)&&t.includes(e.pid)));return k().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=D,t.pidInfo=async function(e){return(0,b.thenMap)(x([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,o.isEmpty)(e)?[]:(0,b.thenMap)((0,E.existingPids)(e),(t=>{const i=[a.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=x;const C="Get-Process",F="| Select-Object -Property Id,ProcessName,StartTime";function A(e){return(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).join(",")}async function I(e){if(T.PowerShell.instance().ended)return R(e);const t=[C,"-Id",A(e),"-ErrorAction SilentlyContinue",F].join(" ");return(0,b.thenMap)(T.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const O={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},L=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,o.isNotEmpty)(e)){const i=(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",L.join(","));const i=await(0,S.stdoutResult_)((0,P.wmic)(),t,O),r=(0,d.onlyReqValued)((0,p.parseFixed)(L,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return r.find((e=>e.pid===a.default.pid))||r.push({pid:a.default.pid,start:new Date(v.StartTs),cmd:"node "+a.default.title}),r}async function N(e){return t=(await(0,S.stdoutResult_)("ps",["-p",A(e),"-wwwo","pid,lstart,command"],{...O,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const B=(0,g.lazy)((()=>{try{if(M.isLinux)return(0,c.toGt0)((0,s.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){k().warn("clk_tck failed",{error:e})}return 100})),j=(0,g.lazy)((()=>Date.now()-(0,n.uptime)()*u.secondMs)),z=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=z.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,s=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(s)?{pid:i,cmd:r,start:new Date(j()+s/B()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(29882),o=i(97352);t.progressEvtToS=function(e){const t=(0,s.blank)(e.path)?null:(0,a.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,n.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,s.notBlank)(e.op)&&(0,o.within)(0,100,e.pct)}},41944:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),s=i(42659),n=i(31586),a=i(12089),o=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new o.TTLMap(15*s.secondMs))),t.recentDone=(0,r.lazy)((()=>new o.TTLMap(2*s.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,n.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,a.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),s=i(31586),n=i(409),a=i(78406),o=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends a.EndableInterval{constructor(e,t,i,s=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:s,rank:o.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=s,this.start=Date.now(),this.onInterval=(0,n.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,s.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,s.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},38156:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushProgressObserver=void 0;const r=i(31586),s=i(41944);t.PushProgressObserver=class{constructor(e,t){this.context=e,this.total=t,this.start=Date.now()}toJSON(){}incrProgress(e=1){this.onProgress(e+(this.current??0))}onProgress(e){this.current=(e??this.current??0)+1,(0,r.gte)(this.current,this.total)&&(this.done=!0),this.emit()}completed(){this.done=!0,this.current=this.total,this.emit()}emit(){(0,s.emitProgressEvt)({...this.context,pct:(0,r.pct)(this.current,this.total),elapsedMs:Date.now()-this.start,done:this.done})}}},24399:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),v=i(99331),w=i(56519),b=i(31562),S=i(84777),P=i(34102),_=i(43334),M=i(28874),T=i(63870),E="{ready}",k=" | ConvertTo-Json -Compress";function D(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=D,(0,o.later)((()=>(0,P.ee)().on("clearCache",(()=>x.instance.prior()?.clearMockResults()))));class x extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,S.execFile)("powershell",M.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${E}"}`,...(0,n.mapNotBlankOr)(M.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:E,fail:"Error",exitCommand:"exit",maxProcs:M.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,T.commandTimeoutMs)(),maxIdleMsPerProcess:a.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),M.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(M.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,k),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,s)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,s)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,k),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,n.blank)(t.stdout)||(0,n.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+D(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=x,x.instance=(0,s.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new x})),t.checkPowerShell_=async function(){const e=x.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,T.commandTimeoutMs)());if((0,n.blank)(t)){const t=await(0,b.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),s=i(38639),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toBoolean})}}t.BooleanSetting=a},90536:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).flatMap(parseFloat).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=o},75164:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).filter(r.notBlank).flatMap(s.toInt).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,s.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=o},10546:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),s=i(22573),n=i(45599),a=i(50213),o=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,n.defer)((()=>(0,a.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,o.trimQuotes)(e);return void((0,s.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,s.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),s=i(91655),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,s.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=a;class o extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=o},9945:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.FloatSetting=a},69589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.forceContextOrSetting=t.pickForceContext=void 0;const r=i(38639),s=i(68708),n=i(50989),a=i(76740),o=i(28874),l=(0,n.strEnum)("forceSync","forceFilters","skipPreviews","forceRebuildPreviews","skipAssetTagging","recountAllTags","skipAssetRepair");t.pickForceContext=function(e){return(0,s.pick)(e,...l.values)},t.forceContextOrSetting=function(e){const t={...(0,s.pick)(e??{},"retries","halt","path"),...(0,s.fromEntries)(l.values.map((t=>[t,e?.[t]??(0,r.isTrue)(o.Settings[t]?.valueOrDefault)])))};return t.retries??(t.retries=0),t.halt??(t.halt=new a.Abortable),t}},74589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt})}}t.IntegerSetting=a},4175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),s=i(22573),n=i(38639),a=i(42659),o=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function v(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function w(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){_(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&v(),y("strictDeduping",e)&&w(),(y("optOut",e)||y("noNetwork",e))&&M()},t.handleDeprecatedSettings=async function(){if((0,n.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,s.blank)(m.Settings.assetPathnameFormat.value)&&(0,s.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*a.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=v,t.setStrictDeduping=w;const b=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],S={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function _(e){for(const t of b)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:S;for(const[e,i]of(0,o.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function M(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=_,t.disableExternalNetworkRequests=M},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),s=i(53265),n=i(87652);class a extends n.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,s.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=a},23561:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.OptionalFloatSetting=a},69005:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=a},87652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=s},4936:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathToLibraryAsset=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(55835),l=i(51926),u=i(50213),c=i(81168),d=i(79842),h=i(21330),f=i(51275),m=i(29882),p=i(28874),g=(0,s.lazy)((()=>(0,u.mkLogger)("settings.PathToLibraryAsset")));function y(e){return(0,a.blank)(e)?"":"'"+e.replace(/'/g,"′")+"'"}t.pathToLibraryAsset=function(e,t){const i=(0,d.datedToDateTime)(e)??(0,o.map)((0,h.datedToISO)(e),(e=>r.DateTime.fromISO(e)));if(null==i||!i.isValid)return g().tap({msg:"pathToLibraryAsset(): failed to convert to a valid date",result:void 0,meta:{capturedAt:e,src:t,dt:i}});const s=(0,f.hasZone)(e),a=p.Settings.assetPathnameFormat.valueOrDefault,u=(0,c.splitKeep)(a,/((?:GRAND)?PARENT|BASE|NAME|EXT|ISO)/g);for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),s=i(83556);t.nameFromEnv=function(e){return(0,s.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,s.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const a=i(19851),o=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),v=i(40583),w=i(81168),b=i(44198),S=i(96706),P=i(34102),_=i(28283),M=i(81075),T=i(98778),E=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,a.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?n(this,r,"m",s).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?n(this,r,"m",s).call(this,e??t)+": "+i:null==this.fromEnv(e)?n(this,r,"m",s).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,S.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,b.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,o.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,o.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,o.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return M.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,b.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&S.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,b.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&S.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,S.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],E.WrapComments);function i(e,i){(0,o.isEmpty)(i)||t.push(...(0,w.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],E.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,w.wrap)(["",e+": "+r],E.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,T.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,T.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,T.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,s=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),s=i(76760),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),v=i(79840),w=i(7282),b=i(12801),S=i(4328),P=i(70488),_=i(84248),M=i(5531),T=i(99315),E=i(34365),k=i(34580),D=i(96706),x=i(50274),C=i(33866),F=i(52086),A=i(48584),I=i(45969),O=i(43334),L=i(24540),R=i(70379),N=i(71300),B=i(33209),j=i(48987),z=i(68268),V=i(61208),W=i(99023),U=i(30577),H=i(1485),q=i(19861),G=i(55111),$=i(30933),J=i(22859),K=i(71988),Y=i(38483),Z=i(90536),X=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),se=i(9945),ne=i(74589),ae=i(844),oe=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,n.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new oe.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new ne.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new ne.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>q.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>H.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:H.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>H.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>O.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new ne.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!O.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>O.isMac?"100ms":O.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new se.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new ne.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>b.PriorityClasses.BelowNormal,strEnum:b.PriorityClasses}),maxMemoryMb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:M.CheckpointTypes,defaultValue:M.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:E.SynchronousModes,defaultValue:E.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:T.RepairModes,defaultValue:T.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 1 minute is very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"1m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:C.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>O.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new ne.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,k.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new ne.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new ne.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new ne.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,L.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,$.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:x.SidecarExts,defaultValue:x.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new se.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,$.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:F.CropStrategies.attention,strEnum:F.CropStrategies}),videoFrameAtSec:new se.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,a.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new ne.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(O.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>B.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new ne.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new ne.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:A.SharpFailOns.truncated,strEnum:A.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>j.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:ae.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new se.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:z.KeywordReparentingStrategies.move,strEnum:z.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function be(e){const i=((0,l.blank)(e)?"":e).split(s.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,a.uniq)(i).filter(l.notBlank).join(s.delimiter)}function Se(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=be,t.pathWithDefaults=(0,n.lazy)((()=>be((0,D.getEnv)("PATH")))),t.allSettings=(0,n.lazy)((()=>(0,o.sortBy)((0,d.values)(t.Settings),Se))),t.persistedSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,n.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,n.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),s=i(31586),n=i(7282),a=i(49776),o=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),v=i(15674),w=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{w.Settings.configDir.opts.defaultValue=o.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=a.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,n.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,n.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,s.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),v=i(54993),w=i(50213),b=i(81168),S=i(83556),P=i(37805),_=i(87290),M=i(98314),T=i(34102),E=i(83278),k=i(95696),D=i(60865),x=i(4175),C=i(83179),F=i(81075),A=i(28874),I=i(41692),O=i(84438),L=i(32707),R=i(6707),N=i(55018),B=i(10357),j=(0,r.lazy)((()=>(0,w.mkLogger)("settings.SettingsIO")));function z(e){return(0,_.libraryDataDirPosixFile)(e)?.join(O.SettingsToml)}async function V(e=(0,L.systemSettingsFile)()){if(null!=e)return Q(E.BaseFile.for(e))}async function W(){try{return(0,a.toNotBlank)((await(0,R.readTomlFile_)((0,L.systemSettingsFile)()))?.[A.Settings.libraryDir.name])}catch{return}}async function U(){return J((0,L.systemSettingsFile)())}async function H(e){return(0,m.map)(z(e),(e=>J(e)))}function q(){t.libraryHasSettings.refresh()}function G(e){const t=z(e);return j().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:A.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}t.librarySettingsFile=z,t.readSettings=(0,r.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await Z()}),o.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return A.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=U,t.librarySettingsVersion=H,t.maybeUpgradeSystemSettings=async function(){P.version!==await U()&&await Y()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&P.version!==await H()&&await X()},t.libraryHasSettings=(0,r.lazy)((()=>G())),t.libraryHasSettings.unset=()=>{j().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,T.ee)().on("clearCache",q),(0,T.ee)().on("settingsChanged",q),A.Settings.libraryDir.watchLater(q)})),t._libraryHasSettings=G;const $=/^# PhotoStructure v(?\d+\.\d+\.\d+(?:-\S+)?)$/i;async function J(e){if((0,a.blank)(e))return;const t=await E.BaseFile.for(e).firstMatchingLine($);return t?.groups?.version}async function K(e,i){if(null==e)return void j().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),s=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...re("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","-- ","","PhotoStructure v"+(0,t.versionForSettings)())),r.push("","");let s="";for(const e of i){const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==s&&(s=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,T.ee)().emitDebounced("settingsChanged")}(s,i),j().info("writeToml(): wrote settings",{dest:s,file:e,nonDefaults:(0,C.settingsToObj)(i),wip:r}),r){const t=await(0,R.readTomlFile_)(s),i=await(0,R.readTomlFile_)(e);(0,u.eql)(t,i)?(j().info("Equivalent contents",{dest:s,file:e,a:t,b:i}),await s.unlink()):(j().info("Archiving prior, different contents",{dest:s,file:e}),await e.renameYMDHMS_({subdir:"old"}),await s.unwip_())}}async function Y(e=(0,L.systemSettingsFile)()){const t=k.PosixFile.forMaybe(e);return null!=t&&await K(t,(0,A.persistedSystemSettings)()),t}function Z(e){return Q(z(e))}async function X(e){await(0,_.setupLibraryDataDir_)((0,a.firstNotBlank)(e,A.Settings.libraryDir.value));const i=z(e);return j().info("writeLibrarySettings()",{file:i}),null!=i&&(await K(i,(0,A.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function Q(e){if(null==e)return[];const t=j().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await ee(e);return(0,s.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,M.errorToS)(e)),[]}}async function ee(e){const t=j().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,R.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const n=[],a=(0,s.compact)((0,p.entries)(r).map((([e,t])=>{const i=(0,A.getSettingByNameOrKey)(e);if(null==i)n.push(`Failed to import "${e}"${(0,m.mapOr)((0,A.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;n.push(e)}})));return t.info("loaded",{settings:(0,C.settingsToObj)(a),warnings:(0,s.toNotEmpty)(n)}),await(0,x.handleDeprecatedSettings)(),(0,x.handleMetaSettings)(a),{settings:a,warnings:n}}t.versionForSettings=(0,r.lazy)((()=>P.version)),t.writeSystemSettings_=Y,t.writeAllSettings_=function(e){return K(k.PosixFile.for(e),(0,A.persistedSettings)())},t.readLibrarySettings=Z,t.writeLibrarySettings_=X,t._readSettings=Q,t.importFileSettings_=ee;const te=(0,r.lazy)((()=>new Set([A.Settings.noNetwork,A.Settings.httpPort,A.Settings.license,A.Settings.logStdout,A.Settings.logLevel].map((e=>e.key)))));function ie(){for(const e of(0,p.values)(A.Settings))te().has(e.key)||e.unset();(0,T.ee)().emit("settingsChanged")}function re(...e){return(0,d.flatten)(e.map((e=>(0,b.wrap)(e,B.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),A.Settings.libraryDir.unset(),await Y()},t.clearSettings=ie,t.nukeSettings=async function(){ie(),await(k.PosixFile.forMaybe((0,L.systemSettingsFile)())?.unlink("trace")),await(k.PosixFile.forMaybe(z())?.unlink("trace")),(0,T.ee)().emit("clearCache"),I.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...re("",`Welcome to PhotoStructure! These are the settings for version ${(0,D.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...re("","The following settings categories are stored in the system settings.toml:","",...(0,n.sort)([...F.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,n.sort)([...F.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...re("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...re("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const n=`${e.key} or ${e.name}`,a={...e.addToJSON()};(0,s.mapNotEmpty)(e.altKeys,(e=>a.aliases=(0,h.orList)(e)));const o=(0,p.entries)(a).map((([e,t])=>`${(0,b.capitalize)((0,S.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,s.isNotEmpty)(o)&&o.push(""),i.push(...re((0,g.padding)("-",n.length),n,(0,g.padding)("-",n.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...o,`${e.key}=${(0,f.stringify)((0,v.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(98553),o=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,a.stringify)(e)}t._join=c;function d(e){return(0,o.map)(function(e){const t=(0,n.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,s.compact)((0,l.toA)(JSON.parse(t)).map(n.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,s.compactBlankish)(t.split(e));return[t]}}(e),s.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,n.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,s.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,s.isEmpty)(e)||(this.value=this.toValidValues((0,s.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,s.isEmpty)(this.values)}isNotEmpty(){return(0,s.isNotEmpty)(this.values)}toNotEmpty(){return(0,s.toNotEmpty)((0,s.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=s},72564:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),s=i(98553),n=i(55835),a=i(58305);class o extends a.StringArraySetting{constructor(e){super({toEnv:e=>(0,n.map)(e,(e=>(0,s.stringify)((0,r.uniq)(e)))),fromEnv:t=>{return i=t,s=e.strEnum,(0,r.compact)((0,a.splitStringArray)(i)?.map((e=>s.getCI(e))));var i,s},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=o},80372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),s=i(81168),n=i(83179);class a extends n.Setting{constructor(e){super({toEnv:o,fromEnv:o,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function o(e){return null==e?void 0:(0,s.trimQuotes)(e)}t.StringSetting=a},32707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),s=i(55835),n=i(46292),a=i(84438);t.systemSettingsFile=function(){return(0,s.map)((0,n.configDir)(),(e=>(0,r.join)(e,a.SettingsToml)))}},80496:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),s=i(44652),n=i(22573),a=i(76850),o=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,a.debom)(e),(0,n.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,n.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,s.readFileSync)(t)):void 0}catch(e){return void(0,o.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,n.mapNotBlank)(e,(async e=>f(await(0,s.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,s.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),s=i(96249),n=i(98553),a=i(68708),o=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const s=e+" = "+(0,n.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[s]:(0,o.wrap)(s.split("\n"),i)}t.stringifyToml=function(e){return(0,s.flatten)((0,a.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,o.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},63225:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyPsEnvSettings=void 0;const r=i(68708),s=i(81168),n=i(44198),a=i(59958),o=i(28874);t.verifyPsEnvSettings=function(e=(0,n.env)(),t=.25){const i=[];for(const n of(0,r.keys)(e).filter((e=>{const t=e.toUpperCase();return t.startsWith("PS_")&&!a.IgnorableEnvKeys.includes(t)}))){const r=e[n],a=(0,o.ciSettings)().lookup(n);if(null!=a){const e=a.value.whyInvalidEnvValue(r);null!=e&&i.push({envKey:n,msg:e})}else{const e=(0,o.ciSettings)().lookupNearest(n,t);null==e?i.push({envKey:n,msg:`No setting was found like "${n}"`}):(0,s.equalsIgnoreCase)(e.key,n)||i.push({envKey:n,msg:`Did you mean setting "${e.value.key}"?`})}}return i}},10357:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const r=i(54993),s=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=a(e[t]);if(null!=i)return i}};const n=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function a(e){const t=(0,s.extractFloat)(e);if(null==t)return;const i=(0,r.toS)(e).toLowerCase();for(const e of n)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),s=i(81168);t.bname=function(e,t=!0){let i=(0,s.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,s.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),h=i(31586),f=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),v=i(81168),w=i(76596),b=i(79842),S=i(66649),P=i(21330),_=i(98725),M=i(928),T=i(54261),E=i(89724),k=i(17415),D=i(88600),x=i(51275),C=i(29882),F=i(17217),A=i(68284),I=i(57902),O=i(28874),L=i(65162),R=i(71300),N=i(14036),B=i(61424),j=(0,s.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function z(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,f.isObject)(e)&&(0,o.notBlank)(e.nativePath)&&(0,b.isDated)(e.date)&&(0,o.notBlank)(e.src)}t.capturedAtSrcFromTags=z,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class U{static fromAssetFile(e){return(0,d.map)((0,E.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>U.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof U?e:W(e)?new U(e):void 0}constructor(e){var t;this.nativePath=(0,F.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,h.toGt0)(e.local)??(0,E.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,b.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(O.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,S.datedToMillis)(e.mtime)??(0,A.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:U.name,...(0,f.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,_.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,k.fmtOffsetMinutes)});return null==t?void 0:new U({...e,date:t})}spread(e){return new U({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,k.fmtOffsetMinutes)(this.offset)}get isFromTags(){return z(this.src)}get isInferred(){return!z(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,E.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,w.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,x.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,T.hasTime)(this.date)}hasMillis(){return(0,h.gt0)((0,M.getMillisecond)(this.date))}toMillis(){return(0,S.datedToMillis)(this.date)}get isValid(){return(0,D.isValidDate)(this.date)}get zoneName(){return(0,r.offsetMinutesToZoneName)(this.offset)??(0,x.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,k.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?O.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,b.datedToStartDateTime)(this.date)??(0,b.datedToDateTime)(this.date);if(null!=i)return{start:(0,E.datedToLocal)(i.minus(t)),end:(0,E.datedToLocal)(i.plus(t))};j().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:O.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),r=Math.max(t,e.fuzzyPrecisionMs());return j().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,b.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:r}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:r}})}}function H(e,t){if(null==e)return;const i=(0,n.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>U.for(e))));for(const r of t){let t=e[r],s=r;if((0,D.isValidDate)(t)){if((0,k.isValidZone)(e.tz)&&(!(0,x.hasZone)(t)||R.OverrideUTCZoneTags.includes(s))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,o.blank)(e.tzSource)?"":" from "+(0,v.stripPrefix)(e.tzSource,"from ");s+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,E.datedToLocalSec)(t),date:t,src:s,precisionMs:(0,b.datedToPrecisionMs)(t),rawValue:e[r]?.rawValue})}}const r=(0,p.leastBy)(i,(e=>(0,b.datedToStartTs)(e.date)));if(null==r)return;const s=i.filter((e=>(0,u.eql)(e.date,r.date)||e.precisionMs<=r.precisionMs&&(0,b.datedOverlap)({a:e.date,b:r.date,aPrecisionMs:e.precisionMs,bPrecisionMs:r.precisionMs}))),a=(0,p.leastBy)(s,(e=>[Math.floor(e.localSec/1e6),(0,x.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return j().debug("capturedAtFromTags()",{least:r,overlapsWithLeast:s,earliest:a}),a}function q(e,t){if(O.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,n.uniq)([(0,L.bname)(e,!0),(0,L.bname)(e,!1)])){const e=(0,_.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,b.datedToPrecisionMs)(e),l.secondMs])}}}function G(e){if(O.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,_.extractDateFromPath)(e.pathsForDateParsing)}}async function $(e){if(O.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=U,t.bestCapturedAt=function(e){const t=(0,a.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const r=await e.mtimeMs();function s(t,i){return W(i)?U.for(i):null!=i&&null!=i.date&&(0,D.isValidDate)(i.date)?U.for({nativePath:e.nativePath,date:i.date,local:(0,E.datedToLocal)(i.date),src:(0,v.uniqPath)([t,i.src]),mtime:r,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const n=function(e,t){return null==e||t||!O.Settings.usePathsToInferDates.valueOrDefault||!O.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,C.containedByNativePath)({ancestor:O.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),a=s("tags",H(t,O.Settings.capturedAtTags.values))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??s("tags",H(t,O.Settings.capturedAtTagsFallback.values))??(n?void 0:s("bname+stat",await(0,B.extractStatBname)(e)))??(n?void 0:s("path+stat",await(0,B.extractStatPathTime)(e)))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??(n?void 0:s("bname",q(e,t)))??(n?void 0:s("path",G(e)))??(O.Settings.useStatToInferDates.valueOrDefault?s("stat",await $(e)):void 0);return j().tap({level:I.LogLevels.debug,msg:"extractCapturedAt()",result:a})},t.capturedAtFromTags=function(e){return H(e,O.Settings.capturedAtTags.values)},t.capturedAtFromBasename=q,t.capturedAtFromPath=G,t.capturedAtFromStat=$},70379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const r=i(31586),s=i(97352),n=i(95696),a=i(47783),o=i(16170);function l(e){if(null!=e&&(0,o.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,r.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,s.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=n.PosixFile.for(e);return l(await(0,a.readRawTags)(t,!1))}},47783:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const s=i(77988),n=r(i(76760)),a=r(i(1708)),o=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(23838),f=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),v=i(12168),w=i(56038),b=i(4867),S=i(36557),P=i(98247),_=i(21330),M=i(98725),T=i(23467),E=i(88561),k=i(95696),D=i(17217),x=i(16287),C=i(50213),F=i(17921),A=i(7282),I=i(88158),O=i(23560),L=i(28874),R=i(12089),N=i(45255),B=i(81168),j=i(63870),z=i(15674),V=i(28544),W=i(43207),U=i(75767),H=i(12788),q=i(80495),G=i(14036),$=i(67083),J=i(3432),K=i(28630),Y=i(15912),Z=i(30748),X=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),re=i(61424),se=i(8791),ne=(0,o.lazy)((()=>(0,C.mkLogger)("exiftool.ExifTool")));let ae=!1;t.addInstanceIdsToTags=function(e){ae=e},t.setExifToolProcs=function(e){return L.Settings.exiftoolProcsPerChild.envValue=e,ue()};const oe=(0,o.lazy)((()=>new S.BatchClusterObserver("ExifTool",new s.ExifTool({useMWG:L.Settings.useMWG.valueOrDefault,backfillTimezones:L.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:L.Settings.defaultVideosToUTC.valueOrDefault,...(0,S.batchClusterOptions)((0,A.isTest)()?8:(0,O.isSyncService)()?L.Settings.exiftoolProcsPerChild.value??(0,z.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=oe();return e.ended?oe.refresh():e}function ue(e=!1){return(0,d.map)(oe.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,b.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(oe.prior(),(e=>e.ended?void 0:(0,b.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,j.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,f.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,D.toNativePath_)(e))}async function he(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function fe(e){const t=[];return L.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*v.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,B.includesIgnoreCase)(L.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return ne().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const r=i??await(0,te.readMimeType)(e),s=await e.sidecar(),n=(0,X.isImageMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,a=(0,X.isVideoMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,o=L.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await s.exists(),l=n||a||o;return ne().tap({msg:"writeTagDest()",result:l?s:e,meta:{src:e,tagName:t,mimetype:r,writeMetadataToSidecarsIfImage:n,writeMetadataToSidecarsIfVideo:a,writeMetadataToSidecarsIfSidecarExists:o}})}async function pe(e,i=!0){const r=k.PosixFile.for(e);if(r.isSidecar()&&(i=!1),!await r.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(r.nativePath),void ne().debug("readRawTags("+r+"): invalid file, returning null.");const s=await(0,t._readRawTags)(r.nativePath);if(null==s||!i)return s;ne().trace("readRawTags()",{pf:r,pickedFileTags:(0,f.pick)(s,"tz","tzSource",...L.Settings.capturedAtTags.values)});const n=[];for(const e of await r.jsonSidecars())n.push([e,(0,K.readJsonSidecar)(e,s.tz)]);for(const e of await r.existingExifSidecars())n.push([e,(0,t._readRawTags)(e.nativePath)]);const a={original:{},MIMEType:(0,u.mapNotBlank)(s.MIMEType,X.normalizeMimetype),...s},o=[];for(const[e,i]of n){if(null==i)continue;const r=await i;if(null==r)continue;const s=(0,f.omit)(r,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,f.values)(s))?((a.sidecars??(a.sidecars=[])).push(e.base),o.push(...(0,g.toA)(r.History)),(0,I.assignNullishFields)(a.original,(0,f.pick)(a,...(0,f.keys)(s))),(0,f.assignFields)(a,s),ne().debug("readRawTags() sidecar had values",{sidecar:e.base})):ne().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return a.inferred=(0,$.getInferredHistoricValues)(o,e),(0,I.assignNullishFields)(a,a.inferred),a.Rotation=(0,Q.orientationToRotation)(a.Rotation),ne().debug("readRawTags() final",{pf:r,inferred:a.inferred,pickedResult:(0,f.pick)(a,"tz","tzSource",...L.Settings.capturedAtTags.values)}),a}async function ge(e,t){return null==t?void 0:(0,w.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,r=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,X.normalizeMimetype);if((0,u.blank)(r))return void ne().debug("No mimetype for "+i);const n={...t.inferred??{},...t};if(n.inferred??(n.inferred={}),n.original??(n.original={}),L.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const t=n[e];if((0,p.isString)(t)){const i=(0,M.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(ne().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),n[e]=i)}}const o=!await(0,re.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,n,o);if(ne().debug("parseTags()",{tzMeta:l,skipSiblingInference:o}),null!=l?.tz){const e=n.tzSource!==s.defaultVideosToUTC&&void 0;for(const t of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const i=n[t];i instanceof s.ExifDateTime&&(n[t]=(0,_.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,f.assignUndefinedFields)(n.original,n,"tz","tzSource"),(0,f.assignFields)(n,l),(0,f.assignFields)(n.inferred,l)}const c=o?(0,Z.extractMakeAndModel)(n):await(0,re.inferMakeAndModel)(e,n);c.Make!==(0,Z.make)(n.Make)&&(n.original.Make=n.Make,n.inferred.Make=c.Make),c.Model!==(0,Z.model)(c.Make,n.Model)&&(n.original.Model=n.Model,n.inferred.Model=c.Model),!(0,u.blank)(L.Settings.defaultCopyright.valueOrDefault)&&(0,H.isExifUnset)(n.Copyright)&&(n.Copyright=L.Settings.defaultCopyright.valueOrDefault);const d=(0,Y.extractLensMakeModel)(n),h=await(0,V.extractCapturedAt)(e,n,o);if(null==h)return void ne().info("No capturedAt for "+e);!o&&h.isInferred&&(n.inferred.capturedAt=h);const m=(0,q.extractExposureSettings)(n),g=await(0,ie.extractSizeInfoFromFile)(e,n);if(null==g)return void ne().info("No size info for "+i);const y={...c,mimetype:r,capturedAt:h,exposureSettings:m,...(0,se.extractTitleDescription)(n),...d,cameraId:(0,U.cameraIdFromTags)(n),imageId:(0,U.imageIdFromTags)(n),lensId:(0,U.lensIdFromLensInfo)({...d,...(0,f.pick)(n,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(n),tz:n.tz,rating:(0,ee.extractRating)(n)};(0,A.isTest)()&&(y.__parsedBy__=a.default.pid);const v={...n,...y};return ne().debug("parsedTags",{nativePath:i,skipInference:o,...y,inferred:n.inferred,original:n.original,pickedResult:(0,f.pick)(v,"capturedAt","tz","tzSource","Make","Model")}),(0,f.definedValues)(v)}catch(e){return void ne().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,f.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,f.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,T.eqlAsync)(e.sha(),t.sha())||await(0,T.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=k.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,D.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,D.toNativePath_)(e),["-"+t]);return(0,I.pluckCaseInsensitive)(i,t)}catch(e){return void ne().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=he,t.overwriteTags_=async function(e,t){try{await(0,w.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await fe(e)),e.clearThisAndParent()}))}catch(i){ne().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,w.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=fe,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,w.time)("exiftool.writeTags:"+e,(async()=>{const r=new h.MultiMap;for(const[s,n]of(0,f.entries)(t)){const t=await me(e,s,i);r.add(t.nativePath,[s,n])}for(const[t,i]of r.entriesArray()){const r=k.PosixFile.for(t),s=(0,f.fromEntries)(i);ne().info("writeTags()",{src:e,dest:t,t:s}),await le().write(r.nativePath,s,await fe(r)),L.Settings.overwriteOriginal.valueOrDefault||await he(r),r.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,x.nativePathIsFile)(e))return ne().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);ne().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...L.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,G.isVideoExt)(n.default.extname(e))?[]:["-fast"]],r=await(0,w.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{ne().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==r)return;ne().debug("_readRawTags()",{nativePath:e,pickedTags:(0,f.pick)(r,"tz","tzSource",...L.Settings.capturedAtTags.values)}),r.MIMEType=(0,u.mapNotBlank)(r.MIMEType,X.normalizeMimetype),r.GPSDateTime??(r.GPSDateTime=(0,P.concatDateTime)(r.GPSDateStamp,r.GPSTimeStamp));for(const e of(0,f.keys)(r)){const t=r[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete r[e])}const s=(0,l.compactBlanks)([r.Error,...r.errors??[],r.Warning].map(y.toS));return(0,l.isNotEmpty)(s)&&(r.problems=s),ae&&(r.__instance=(0,F.safeUUID)()),r}}),t.parseTags=ge},75767:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(98553),o=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),h=i(54993),f=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),v=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const w=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function b(e){const t=null==e?[]:e.filter((([,e])=>!(0,n.blank)(e)));return 0===t.length?void 0:(0,a.stringify)((0,u.fromEntries)(t))}function S(e){return(0,h.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new o.MultiMap,r=[];for(const a of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(s=e[a])||(0,n.blankish)(s)||(0,l.isNumber)(s)&&(0===s||1===s)||null!=t.zeroesRe.exec((0,h.toS)(s)))continue;const o=e[a],u=S(e[a]),c=(0,t.Tag2SynonymGroup)().get(a);if(null!=c){if(i.includes(c,o)||i.includes(c,u))continue;i.add(c,o)}r.push([a,(0,l.gt0)(o)?o:u])}var s;return b(r)}function _(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function M(e){if((0,n.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([_(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(_)):(0,u.compactBlankValues)(t)}function T({a:e,b:t,field:i,desc:r,parser:s}){const n=s(e[i]),a=s(t[i]),o=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==n||null==a||(0,l.approximates)(n,a,o)?void 0:"Different "+r+": "+e[i]+" ≠ "+t[i]}function E(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,n.blank)(e.lensMake)||(0,n.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,r.lazy)((()=>{const e=new Map;for(const t of w){const i=t[0];for(const r of t)e.set(r,i)}return e})),t.Tag2Synonyms=(0,r.lazy)((()=>{const e=new Map;for(const t of w)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=b,t.renderExifUidId=P,t.decodeExifUid=M,t.findInequalFields=function(e,i){const r=M(e),n=M(i);if(null==r||null==n||e===i)return;const a=(0,f.intersection)((0,u.keys)(r),(0,u.keys)(n)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of a){const t=r[e],i=n[e];if(S(t)!==S(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of w){const t=(0,u.pick)(r,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(n,...e);if((0,u.isEmptyObj)(i))continue;const a=(0,u.values)(t).map(h.toS),o=(0,u.values)(i).map(h.toS);if((0,s.includesAny)(a,o))continue;const l=(0,f.least)((0,u.keys)(t)),c=(0,f.least)((0,u.keys)(i));return{aKey:l,aValue:r[l],bKey:c,bValue:n[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>T({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>T({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>T({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>T({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return E({...(0,v.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=E,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const r=i(22573),s=i(54993),n=/undefined|null|none|n\/a|unknown/i;function a(e){return null==e||(0,r.blank)(e)||n.test((0,s.toS)(e))}t.isExifUnset=a,t.toExifDefined=function(e){return a(e)?void 0:e}},80495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const r=i(19851),s=i(22573),n=i(31586),a=i(68708),o=i(54993),l=i(50213),u=i(97352),c=(0,r.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,s.firstNotBlank)((0,o.toS)(e.ExposureTime),(0,o.toS)(e.ShutterSpeed),(0,o.toS)(e.ShutterSpeedValue),(0,o.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,a.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,n.gt0)(e))return e;const[t,i]=(0,o.toS)(e).split("/").map((e=>(0,n.toInt)(e)));return(0,n.gt0)(t)&&(0,n.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,n.toFloat)(e);return(0,n.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),s=i(40958),n=i(96249),a=i(23838),o=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,o.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,o.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new a.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,n.flatten)((0,o.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function v(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=v,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return v(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return v(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return v(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return v(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return v(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return v(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),h=i(50989),f=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),v=i(50213),w=i(81168),b=i(66649),S=i(17415),P=i(29882),_=i(95696),M=i(17217),T=i(28874),E=i(47783);function k(e,t){return(0,d.entries)(t??{}).map((([t,i])=>D({action:e,key:t,value:i})))}function D({action:e,key:t,value:i,ts:s}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:r.ExifDateTime.fromMillis(s??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,h.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=k,t.mkHistoryRecord=D,t.InferAction="infer";const x=(0,s.lazy)((()=>(0,v.mkLogger)("tags.History")));function C(e,t){if(null==e||null==e.History||(0,f.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function F(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,o.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function A(e){if(null==e)return;const t={};for(const[i,r]of(0,d.entries)(e))(0,w.isFirstCharAZ)(i)&&(t[i]=r);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,S.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function I(e,i,r){if(null==e||(0,o.blank)(e))return void x().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const s=(0,M.toNativePath_)(e),a=await(0,E._readRawTags)(s),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!C(a,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...r??{}};if((0,n.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void x().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:r,tagsToWrite:c});x().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:r});const h=_.PosixFile.for(e);return await(0,E.overwriteTags_)(h,c),h.clearThisAndParent(),u}t.tagsContainHistory=C,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const s=(0,m.toA)(e);if((0,n.isEmpty)(s))return{};const l=(0,a.sortBy)(s.filter((e=>(0,w.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,b.datedToMillis)((0,o.mapNotBlank)(e.When,(e=>r.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,o.notBlank)(t)){const r=F(e);(0,o.blank)(r.nativePath)||(0,P.eqlNameWithoutExt)(r.nativePath,i)?u[t]=r:x().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=F,t.inferredToTags=A,t.ensureInferredHistoryRecords=async function(e,i,r){const s=k(t.Actions.infer,r),n=(T.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?A(r):void 0)??{};return T.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(n.Source=e.nativePath),x().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:s,additionalTags:n}),I(i,s,n)},t.ensureHistoryRecords=I},3432:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const s=r(i(53705)),n=i(77988),a=i(19851),o=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),h=i(17415),f=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),v=i(61424),w=(0,a.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function b(e,t,i){{const e=S(t);if(null!=e&&(0,h.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,h.isValidZone)(t.tz)||t.tzSource===n.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,o.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof n.ExifDateTime&&(0,h.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,v.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function S(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,s.default)(t,i),r=(0,h.normalizeZone)(e);return w().tap({msg:"zoneFromLatLon()",result:r,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,f.isValidDate)(i))for(const r of g.Settings.capturedAtTags.values){const s=(0,u.toDated)(t[r]);if(null==s||(0,f.isValidDate)(s))continue;const n=Math.round(15*i.diff(s,"minutes").as("minutes")/15),a=(0,h.normalizeZoneOffsetMinutes)(n),o=0===a?void 0:(0,h.normalizeZone)(a);if(null!=o)return w().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:o.name,tzSource:"infer:filename (diff with "+r+")"},meta:{dt:(0,c.datedToISO)(s),rawTzoffsetMinutes:n,normalizedOffsetMinutes:a}})}}t.maybeInferTimezone=async function(e,t,i){return w().tap({msg:"maybeInferTimezone()",result:await b(e,t,i)})},t.zoneFromLatLon=S,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const r=i(77988),s=i(40958),n=i(22573),a=i(38639),o=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),h=i(48884),f=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const s=(0,p.normalizeZone)(e?.formatted),n=r.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:s??t??r.UnsetZone});if(!0===n?.isValid)return n}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,n.toNotBlank)(e.title),Description:(0,n.toNotBlank)(e.description),GPSLatitude:(0,h.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,f.validLat)(e)?e:void 0)),GPSLongitude:(0,h.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,f.validLon)(e)?e:void 0)),GPSAltitude:(0,h.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,o.map)(e.favorited,a.isTrue),peopleNames:(0,s.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,s.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},97573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rawTagKeywords=t.parseKeywordStruct=t.isKeywordStruct=t.parseCategories=t.splitKeywords=t.splitKeyword=t.delimRe=t.keywordToPath=void 0;const r=i(77988),s=i(66150),n=i(19851),a=i(40958),o=i(22573),l=i(41400),u=i(96249),c=i(68708),d=i(59455),h=i(48884),f=i(50213),m=i(68852),p=i(81168),g=i(28874),y=(0,n.lazy)((()=>(0,f.mkLogger)("tags.KeywordTags"))),v=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordPathSeparators.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g")))));function w(e){const i=(0,t.delimRe)();return null==i?[e]:(0,a.compactBlanks)(e.split(i))}function b(e){return null==e||e instanceof r.BinaryField?[]:(0,a.compactBlanks)(Array.isArray(e)?(0,u.flatten)(e.map(b)):w(e))}function S(e){return null==e?[]:(0,p.isString)(e)?(0,o.blank)(e)?[]:[[e]]:(0,u.flatten)((0,d.toA)(e.Category).map(S).map((t=>t.map((t=>(0,a.compact)([e._,...t]))))))}(0,l.later)((()=>{g.Settings.keywordPathSeparators.watchLater((()=>v.unset()))})),t.keywordToPath=function(e){const t=v();return(0,a.compactBlanks)(null==t?[e]:e.split(t))},t.delimRe=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g"))))),g.Settings.keywordDelimiters.watchLater((()=>t.delimRe.unset())),t.splitKeyword=w,t.splitKeywords=b;const P=/^\(?none\)?$/i;function _(e){if(!(0,o.blank)(e)&&null==P.exec(e))try{const t=new s.XMLParser({textNodeName:"_"}).parse(e);return(0,u.flatten)((0,d.toA)(t?.Categories?.Category).map(S))}catch(t){return void y().warn("parseCategories() failed:",{err:t,s:e})}}function M(e){return Array.isArray(e)&&e.every(M)||null!=e&&(0,p.isString)(e.Keyword)&&(null==e.Children||Array.isArray(e.Children)&&e.Children.every(M))}function T(e){if(null==e)return[];if(Array.isArray(e)&&e.every(M))return(0,h.flatMap)(e,T);if((0,o.blank)(e.Keyword))return[];const t=(0,d.toA)(e.Children);return(0,a.isEmpty)(t)?[[e.Keyword]]:(0,h.flatMap)(t,T).map((t=>[e.Keyword,...t]))}t.parseCategories=_,t.isKeywordStruct=M,t.parseKeywordStruct=T,t.rawTagKeywords=function(e){const t=[];if(null!=e){const i=[...g.Settings.keywordTags.values];if(i.includes("Categories")){(0,h.remove)(i,"Categories");const r=_(e.Categories);null!=r&&t.push(...r)}for(const r of i){const i=(0,c.pluckDeep)(e,r)?.value;(0,o.blank)(i)||(M(i)?t.push(...T(i)):t.push(...Array.isArray(i)?i:b(i)))}}return y().tap({msg:"rawTagKeywords()",result:(0,a.compactBlankish)((0,a.uniq)(t)),meta:{t:null==e?void 0:(0,c.pick)(e,...g.Settings.keywordTags.values)}})}},15912:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(55835),o=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),h=i(28874),f=i(30748),m=(0,r.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,f.make)(e.LensMake),i=(0,f.make)(e.Make),r=[],o=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],b),u=(0,s.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:o,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&r.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==b(e))continue;(0,n.notBlank)(t)&&r.push({lensMake:t,lensModel:e,lensInfo:o});const a=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))a.includes(t)&&r.push({lensMake:i,lensModel:e,lensInfo:o});for(const i of(0,s.compactBlanks)([t,...h.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&r.push({lensMake:i,lensModel:e,lensInfo:o});a.startsWith("vr ")&&"Nikon"===i&&r.push({lensMake:"Nikon",lensModel:e,lensInfo:o})}for(const e of r){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=S(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,a.map)(e.lensInfo,S)}return(0,c.greatestBy)(r,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const v=/([\d. -]+)\s?mm\b/i,w=/\bf\/?([\d.\-]+)/i;function b(e){if((0,n.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=v.exec(e)?.[1].replace(/\s/g,""),i=w.exec(e)?.[1];return y(t)&&y(i)?S(`${t}mm f/${i}`):void 0}function S(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,a.mapOr)((0,o.toFloat)(e),(e=>String((0,o.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=b,t.cleanBogusPrecision=S,t.normalizeLensModel=function(e){return S(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(68708),o=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function h(e,t,i=""){const r=e.replace(t,i);return r===e?e:h(r,t,i)}const f=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=f.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,r.lazy)((()=>new p)),y=/\bgopro\b/i;function v(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=h(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=v(e.Make)??b(e.Software)??b(e.CreatorTool)??function(e){return y.test((0,o.toS)(e.HandlerDescription))||y.test((0,o.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,a.compactValues)({Make:t,Model:i})??{}},t.make=v;const w={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function b(e){if(!(0,s.blank)(e))for(const[t,i]of(0,a.entries)(w))if(i.test(e))return t}t.makeFromSoftware=b;const S=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=S.exec(i);null!=e&&(i=e[1].trim())}const r=(0,n.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=r)return r[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,n.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=h(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},38010:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MergedTags=t.revisionToResourceEvent=t.resourceEventToRevision=t.isSetRevision=t.isPrimitiveRevision=t.isBaseRevision=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(55835),u=i(31586),c=i(68708),d=i(67478),h=i(59455),f=i(54993),m=i(72993),p=i(50213),g=i(84885),y=i(66649),v=i(98725),w=(0,s.lazy)((()=>(0,p.mkLogger)("tags.MergedTags")));function b(e){return(0,u.isNumber)(e?.createdAt)&&(0,o.notBlank)(e?.field)}function S(e){return null==e?.op&&b(e)}function P(e){return e?.sourceIsPrimary??e?.shown??!1}function _(e){return e?.sourceModifiedTime??e?.mtime??0}t.isBaseRevision=b,t.isPrimitiveRevision=S,t.isSetRevision=function(e){return["add","delete"].includes(e?.op)&&b(e)},t.resourceEventToRevision=function(e){if(null==e||!(0,f.toS)(e.SoftwareAgent).startsWith((0,m.AppName)()))return w().tap({msg:"resourceEventToRevision() invalid",result:void 0,meta:{resourceEvent:e}});const t=e.Changed;if((0,o.blank)(t))return w().tap({msg:"resourceEventToRevision() missing Changed field name",result:void 0,meta:{resourceEvent:e}});const i=(0,c.pick)((0,o.mapNotBlank)(e.Parameters,d.parseJSON)??{},"newValue","priorValue");if((0,c.isEmptyObj)(i))return w().tap({msg:"resourceEventToRevision() missing Parameter fields",result:void 0,meta:{resourceEvent:e}});const r=(0,y.datedToMillis)((0,v.parseDated)({input:e.When}));return null==r?w().tap({msg:"resourceEventToRevision() missing createdAt (When)",result:void 0,meta:{resourceEvent:e}}):(0,o.blank)(e.Action)?w().tap({msg:"resourceEventToRevision() missing op (Action)",result:void 0,meta:{resourceEvent:e}}):w().tap({msg:"resourceEventToRevision()",result:{createdAt:r,field:t,op:"assign"===e.Action?void 0:e.Action,...i},meta:{resourceEvent:e}})},t.revisionToResourceEvent=function(e){return{Action:e.op??"assign",Changed:e.field,InstanceID:(0,l.map)(e.id,f.toS),Parameters:(0,g.stringifySorted)((0,c.pick)(e,"newValue","priorValue")),SoftwareAgent:(0,m.AppNameVersion)(),When:r.ExifDateTime.fromMillis(e.createdAt??Date.now())}},t.MergedTags=class{constructor(e){this.name=e,this.revisions=[],this.tags=[],this.logger=(0,p.mkLogger)(`MergedTags(${e})`)}addRevision(...e){this.revisions.push(...e)}addTag(...e){this.tags.push(...e),(0,a.sortBy)(this.tags,(e=>[!P(e),-_(e)]))}get(e){const t=(0,a.sortBy)(this.revisions.filter((t=>t.field===e)),(e=>e.createdAt)),i=this.tags.find((t=>null!=t[e]));let r=i?.[e];const s=[];var l;null!=r&&(0,o.mapNotBlank)((l=i,l?.SourceFile??l?.uri),(e=>s.push(e)));const u=t.every(S)&&this.tags.every((t=>!Array.isArray(t[e])));if(u){for(const i of t)null!=r&&r!==i.priorValue&&r!==i.newValue?this.logger.info("get("+e+"): skipping revision because expected prior or new value didn't match current value",{revision:i}):(r=i.newValue,s.push(`Revision@${i.createdAt}`));return null==r?void 0:{value:r,source:s}}{const e=(0,h.toA)(r);for(const i of t)if("add"===i.op&&null!=i.newValue)s.push(`Revision@${i.createdAt}`),(0,n.pushUniq)(e,...(0,h.toA)(i.newValue));else if("delete"===i.op&&null!=i.priorValue){s.push(`Revision@${i.createdAt}`);for(const t of(0,h.toA)(i.priorValue))(0,n.remove)(e,t)}return{value:e,source:s}}}}},16170:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const r=i(22573),s=i(54993),n=i(2322),a=i(277),o=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function h(e){return(0,r.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function f(e){const t=(0,s.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,n.isChrome)(t)||(0,n.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,s.toS)(e))},t.isImageMimeType=function(e){return(0,s.toS)(e).startsWith("image/")},t.isVideoMimeType=h,t.normalizeMimetype=f,t.isSharpMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,r.blank)(t)&&(h(t)?await(0,l.isVideoSupported)():(0,o.isHeifMimeType)(t)?await(0,a.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},66039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderNameTag=t.parseName=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(55835),l=i(75020),u=i(59455),c=i(50213),d=i(68852),h=i(81168),f=i(70417),m=i(28874),p=(0,r.lazy)((()=>(0,c.mkLogger)("tags.Names")));function g(e){return(0,d.matchQuotes)((0,d.escapeRegExp)(e))}const y=/(\(\s*\d+\s*-\s*[\d?]{0,4}\s*\)?)/,v=/([,\s]+(?:jr\.?|junior|sr\.?|senior|[iv]+\.?))$/i,w=/\b([A-Z‘’']+[-A-Z‘’']{2})\b/,b=/^[()[\]/.\-_]+$/;function S(e){if((0,a.blank)(e))return;let t=e.replace(/\s+/g," ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").trim();const i=(0,o.map)((0,h.spliceCapture)(t,y),(e=>(t=e.unmatched.trim(),e.captured.replace(/\s+/g,"")))),r=(0,o.map)((0,h.spliceCapture)(t,v),(e=>(t=e.unmatched.trim(),e.captured.trim()))),l=[],c=[],b=[];for(const e of m.Settings.tagNamesGiven.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(l.push(i.captured),t=i.unmatched.trim())}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesGivenSurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`(${(0,d.escapeRegExp)(e.charAt(0))}\\s*[^${(0,d.escapeRegExp)(e.charAt(0))}]+\\s*${(0,d.escapeRegExp)(e.charAt(1))})`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(c.push(i.captured),t=i.unmatched.trim())}while(null!=i)}let S;function _(e){(null==S||S>e.matchedIndex)&&(S=(0,f.min)([S,e.matchedIndex]))}if(m.Settings.tagNamesCapitalizedAsFamily.valueOrDefault){let e;do{e=(0,h.spliceCapture)(t,w),null!=e&&(_(e),b.push(e.captured),t=e.unmatched.trim())}while(null!=e)}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesFamilySurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`${(0,d.escapeRegExp)(e.charAt(0))}\\s*([^${(0,d.escapeRegExp)(e.charAt(0))}]*)\\s*${(0,d.escapeRegExp)(e.charAt(1))}`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}while(null!=i)}if(m.Settings.tagNamesLexical.valueOrDefault){const e=t.indexOf(",");e>=0&&(S=void 0,b.push(t.substring(0,e).trim()),l.push(t.substring(e+1).trim()),t="")}for(const e of m.Settings.tagNamesSurnames.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}for(const e of(0,u.toA)((0,s.mapNotEmpty)((0,s.compactBlanks)(m.Settings.tagNamesSurnamePrefixes.values),(e=>(0,n.sortBy)(e,(e=>-e.length)).map((e=>new RegExp(`\\b(${g(e)}\\s+\\S+)`,"i"))))))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}null!=S&&t.length>S&&(0,s.mapNotEmpty)((0,s.compactBlanks)(t.slice(S).split(/\s+/)),(e=>{b.push(...e),t=t.slice(0,S)}));const M=(0,s.compactBlanks)(t.split(/\s+/)),T=l.length,E=b.length;if(M.length>0)if(0===T&&E>0)l.push(...M);else if(0===E&&T>0&&1===M.length)b.push(...M);else if(1===M.length)l.push(...M);else{const e="western"===m.Settings.tagNamesOrder.valueOrDefault;b.push(e?M.pop():M.shift()),l.push(...M)}return{givenNames:P([...l,...c]),modifier:r,lifespan:i,familyNames:P(b),minFamilyNameIndex:S}}function P(e){return(0,s.uniq)((0,s.compactBlanks)(e).filter((e=>null==b.exec(e))))}function _(e){let t="";for(const i of(0,s.compactBlanks)(e))t+=i.startsWith(",")?i:" "+i;return t.trim()}function M(e,t,i){return _("western"===m.Settings.tagNamesOrder.valueOrDefault?[t,e,i]:[e,t,i])}t.parseName=S,t.renderNameTag=function(e){if((0,a.blank)(e))return[];const t=m.Settings.tagNamesFormatter.valueOrDefault,i="family/given"===t;if("family/fullname"===t||i){const t=S(e);if(null==t)return[];{const e=_([t.modifier,t.lifespan]),r=_(t.givenNames);return(0,s.compactBlanks)((0,s.notEmptyOr)(t.familyNames,[m.Settings.tagNamesDefaultFamily.valueOrDefault])).map((t=>[l.TagRoots.Who,t,i?_([r,e]):M(t,r,e)]))}}return[[l.TagRoots.Who,e.trim()]]}},95141:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const r=i(21605),s=i(54993),n=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,n.isVideoMimeType)(e.MIMEType)?(0,r.normalizeRotation)(e.Rotation):void 0)??o(e.Orientation)};const a=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function o(e){return(0,r.isRotation)(e)?e:null!=e?a.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,s.toS)(e).startsWith("Mirror")},t.orientationToRotation=o;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,r.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,r.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const r=i(55835),s=i(31586),n=i(28874);function a(e){const t=(0,s.toInt)(e);return null==t?void 0:(0,s.clamp)(-1,5,t)}function o(e){return a(e?.Rating)??(0,s.mapNumeric)((0,s.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,r.map)(e?.favorited,(e=>!0===e?n.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=a,t.extractRating=o,t.extractLiked=function(e){const t=o(e);return null==t?void 0:t>=n.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(88561),o=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,r.lazy)((()=>new a.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,s.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,n.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,o.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),s=i(40958),n=i(22573),a=i(81168),o=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,a.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const o=(0,u.isJsonExt)(i.ext),l=o||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=o||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,s.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,s.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return o&&function(e,i){const r=(0,a.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function s(e){return(0,n.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const o=s(e.slice(r.length)),l=s(i.slice(r.length));return o&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,o.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,a.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(33374),o=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),h=i(34943),f=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),v=(0,r.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),w=(0,r.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:n.minuteMs})));async function b(e,t){if(null==e)return;const i=null==t||(0,s.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const r=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return S(i,r,await(0,h.rawInfo)(e));const n=S(i,r);if(null!=n)return n;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await b(await(0,f.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function S(e,t,i){t??(t=(0,y.extractRotation)(e));const r=(0,o.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,a.isDimensions)(e)?e:void 0));if(null==r)return v().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo,fileDimensions:r}});const s=(0,a.maybeDimSwap)(r,t);return v().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:s.height,ImageWidth:s.width,aspectRatio:(0,d.aspectRatio)(s),dimensions:s,rotation:t,fileDimensions:r,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return w().getOrSetAsync(i.nativePath,(()=>b(i,t)))},t.extractSizeInfoFromTags=S},3127:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tag_fts_path=t.tag_fts_root=void 0;const r=i(54993),s=i(42231);t.tag_fts_root=function(e){const t=(0,r.toS)(e).indexOf(s.TagSep);return-1===t?"":e.substring(0,t)},t.tag_fts_path=function(e){return(0,r.toS)(e).split(s.TagSep).filter((e=>null!=e&&""!==e.trim())).join(" ")}},61424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),h=i(48884),f=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),v=i(79842),w=i(21330),b=i(98725),S=i(51275),P=i(35280),_=i(19748),M=i(88561),T=i(95696),E=i(65238),k=i(17217),D=i(57902),x=i(28874),C=i(80496),F=i(65162),A=i(28544),I=i(47783),O=i(88840),L=i(30748),R=i(16170),N=(0,n.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),B=7;async function j(e){return x.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+x.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(x.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.auto&&await(0,E.isSlowDir)(e.nativePath)&&!await(0,E.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function z(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of r){const r=(0,L.extractMakeAndModel)(await(0,I.readRawTags)(t));if((0,f.definedAndNotEql)(r.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:r});else if((0,f.definedAndNotEql)(r.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:r});else if(null!=r.Make&&null!=r.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:D.LogLevels.info,result:r,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await j(e.parent()))return;const t=await W(e);return null!=t&&(0,w.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,w.toExifDateTime)(t.before.date,(0,S.getZoneName)(t.before.date)),(0,w.toExifDateTime)(t.after.date,(0,S.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,n.lazy)((()=>new M.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await q(e),i=await z(t?.younger),r=await z(t?.older);return null==i||null==r?void 0:{before:i,after:r,index:i.index,slots:i.index+r.index+1}}))}t.beforeAfterCapturedAt=W;const U=(0,_.extFilter)(O.ExtTypes.AssetFile);function H(e){return null==e?[]:(0,a.compact)((0,h.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function q(e,t=7,i=!0){if(!await j(e.parent()))return;const r=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(U(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==r)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const s=(0,o.sortBy)(r,(e=>(0,F.bname)(e))),n=(0,k.findFileIndex)(e,s);if(n<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),q(e,t,!1)):void 0;const l=x.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[s.slice(n-2*t,n),s.slice(n+1,n+1+2*t)],d=[],h=[];for(;(0,a.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,a.isNotEmpty)(c)&&h.length=l&&h.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:h},meta:{f:e}})}t.nearestSiblings=q,t.nearestSiblingTzOffset=async function(e){if(!await j(e.parent()))return;const t=H(await q(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,B);for(const t of e){const e=await(0,I.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==r.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,a.uniq)([(0,F.bname)(e,!0),(0,F.bname)(e,!1)]),i=(0,b.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const r=await e.stat();if(null!=r){for(const e of["birthtime","atime","mtime","ctime"])if((0,v.datedOverlap)({a:i,b:r[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:r}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:r}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,b.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const r=i[e];if(null!=r&&!0===(0,v.datedOverlap)({a:t,b:r}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:s.DateTime.fromJSDate(r)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),h=i(81168);function f(e){return(0,u.toS)((0,o.isString)(e)?e:e?.name).normalize()}function m(e){return(0,r.compact)((0,l.toA)(e).map(f))}function p(e,i=t.TagSep){return m(e).map((e=>(0,o.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(n.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function v(e){return(0,n.blank)(e)?void 0:Array.isArray(e)?f((0,r.last)(e)):(0,r.last)(g(e))}function w(e,t){if((0,r.isEmpty)(e)||(0,r.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,h.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=f,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,r.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,r.uniqBy)((0,l.toA)(e),(e=>(0,r.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,r.compact)(t).map((e=>y(e))));return(0,r.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=v,t.leafIsExcluded=function(e,t){return(0,a.mapOr)(v(e),(e=>(0,h.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=w,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,s.sortBy)(e.filter(r.isNotEmpty),(e=>-e.length)))t.some((e=>w(i,e)))||t.push(i);return(0,s.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const r=i(40958),s=i(22573),n=i(68708),a=i(54993);t.extractTitleDescription=function(e){const t=(0,r.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,s.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const r of i){const i=(0,a.toS)(e[r]).trim();if((0,s.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,n.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(96249),o=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),v=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function w(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function b(e){const t=await w(e);return(0,s.uniq)((0,a.flatten)(t.map(m.uriEncodingVariants)))}async function S(e,t){if((0,n.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void v().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case o.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case o.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case o.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,n.blank)(e)?v().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=w,t.nativePath2uriVariants=b,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(S(e,t),b))),(0,s.uniq)(i)},t.uri2nativePath=S,t.uriExists=async function(e,t){const i=await S(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),s=i(57975),n=i(90595),a=i(22573),o=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",v=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class w{static isUri(e){return e instanceof w||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,s,n=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,n),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=s??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,n))}get fsPath(){return T(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:s,fragment:n}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===s?s=this.query:null===s&&(s=g),void 0===n?n=this.fragment:null===n&&(n=g),t===this.scheme&&i===this.authority&&r===this.path&&s===this.query&&n===this.fragment?this:new S(t,i,r,s,n)}static parse(e,t=!1){const i=v.exec(e);if(!i)return new S(g,g,g,g,g);const r=i[2]||g,s=x(i[4]||g),n=(i[5]||g).split("/").map(x).join("/"),a="psfile"===r&&n.startsWith("//")?n.slice(1):n,o=(0,u.toURLSearchParams)(i[7]),l=x(i[9]||g);return new S(r,s,a,o,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new S("file",t,e,g,g)}static from(e){return new S(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?w.file(r.win32.join(T(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,o.map)(this.path,(e=>(0,d.findLast)(e.split(y),a.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return E(this,e)}toJSON(){return this}[s.inspect.custom](){return this.toString()}}t.URI=w;const b=h.isWinPortable?1:void 0;class S extends w{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=T(this,!1)),this._fsPath}toString(e=!1){return e?E(this,!0):(null==this._formatted&&(this._formatted=E(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=b),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,a.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function _(e,t){let i,r=-1;for(let s=0;s=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||45===n||46===n||95===n||126===n||t&&47===n)-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),void 0!==i&&(i+=e.charAt(s));else{void 0===i&&(i=e.substr(0,s));const t=P[n];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),i+=t):-1===r&&(r=s)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function M(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function E(e,t){const i=t?M:_;let r="";const{scheme:s,query:n,fragment:o}=e;let{authority:l,path:u}=e;if(s&&(r+=s,r+=":"),(l||"file"===s)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,a.mapNotBlank)(n,(e=>r+="?"+e)),o&&(r+="#",r+=t?o:_(o,!1)),r}function k(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+k(e.substr(3)):e}}t.encodeURIComponentFast=_,t.uriToFsPath=T;const D=/(?:%[\dA-Z][\dA-Z])+/gi;function x(e){return e.startsWith("xn--")?(0,n.toUnicode)(e):e.match(D)?e.replace(D,(e=>k(e))):e}t.percentDecode=x,t.toURI=function(e){return w.isUri(e)?e:w.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),s=i(40958),n=i(50357),a=i(89937),o=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",a.PS_LOCAL_FILE_SCHEME,a.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,o.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&f(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,n.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,s.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),s=i(22573),n=i(51926),a=i(89937),o=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,s.blank)(e))return;if(null==(t=null!=t&&(0,o.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,s.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,n.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:a.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==a.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,s.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,n=(0,s.notBlank)(t)&&!t.includes(i);if(n&&!(0,s.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const o=await(0,c.bestVolumeForVolsha)(e.authority);return null!=o?f(o.mountpoint,e.path):n&&(0,s.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),s=i(22573),n=i(51926),a=i(89937),o=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,s.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,s.blank)(t))return;const i=(0,r.uniq)([t,(0,o.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,n.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==a.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,o.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,n.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const a=n(i(76760)),o=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,o.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,o.notBlank)(t.remoteHost)&&(0,o.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:a.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,o.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,o.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(a.sep)}`;const s=i.slice(1),n=await(0,p.volumes)();for(const t of(0,u.toA)(n))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return a.join(t.mountpoint,...s);return await(0,h.isReadableDirectory)(t)?a.join(t,...s):void 0}},85087:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),s=i(42659),n=i(9103),a=i(37628);t.volsha=(0,n.memoize)((e=>(0,r.mapNotBlank)(e,a.shortStringSha)),{maxSize:128,ttlMs:s.minuteMs})},50036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.channelVersionsCache=void 0;const r=i(46292),s=i(95696);t.channelVersionsCache=function(){return s.PosixFile.forMaybe((0,r.configDir)())?.join("channel-versions.json")}},60865:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),s=i(30577);t.channel=function(){return(0,s.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),s=i(22573),n=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function a(e){if(e instanceof r.SemVer)return e.version;const t=n.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=a,t.semverSatisfies=function(e,t){if((0,s.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const n=a(e);return null!=n&&(0,r.satisfies)(n,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},27274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.semverGte=t.semverLatest=void 0;const r=i(54993),s=i(48884),n=i(76280),a=i(30577);function o(e){const t=(0,n.toSemver)(e),i=a.UpdateChannels.ordinal((0,a.extractUpdateChannel)((0,r.toS)(e)));return null==t?void 0:[t.major,t.minor,t.patch,i,...t.prerelease.slice(1)]}function l(...e){return(0,s.greatestBy)(e,o)}t.semverLatest=l,t.semverGte=function(e,t){return l(e,t)===e}},38244:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isUpdateChannelVersion=void 0;const r=i(68708),s=i(51926),n=i(30577);t.isUpdateChannelVersion=function(e){return(0,r.isObject)(e)&&n.UpdateChannels.has(e.channel)&&(0,s.isString)(e.version)}},30577:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},63335:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ver=void 0;const r=i(22573);t.ver=function(e){return(0,r.blank)(e)?"(missing version)":e.replace(/^(?:v|ver|version)?\s*/,"version ")}},40044:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getChannelVersions_=t.checkVersion_=t.currentChannel=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(75240),l=i(17344),u=i(50213),c=i(37805),d=i(5916),h=i(46292),f=i(16287),m=i(43205),p=i(28874),g=i(63870),y=i(89372),v=i(50036),w=i(60865),b=i(27274),S=i(38244),P=i(30577),_=i(63335),M=(0,a.defer)((()=>(0,u.mkLogger)("VersionCheck")));t.currentChannel=function(){const e=[p.Settings.updateChannel.valueOrDefault,(0,w.channel)()].map((e=>P.UpdateChannels.ordinal(e))).sort()[0];return P.UpdateChannels.values[e]??p.Settings.updateChannel.valueOrDefault},t.checkVersion_=async function(e){if(p.Settings.noNetwork.valueOrDefault)return{level:"disabled",msg:["PhotoStructure version checking is disabled","Set "+(0,s.tt)(p.Settings.noNetwork.toEnvLine(!1))+" to enable."]};if(!p.Settings.autoUpdateCheck.valueOrDefault){const e=["PhotoStructure version checking is disabled"];return!0===p.Settings.optOut.value?e.push("Set "+(0,s.tt)(p.Settings.optOut.toEnvLine(!1))+" to enable."):!1===p.Settings.autoUpdateCheck.value?e.push("Set "+(0,s.tt)(p.Settings.autoUpdateCheck.toEnvLine(!0))+" to enable."):e.push("Finish setup, or set "+(0,s.tt)(p.Settings.autoUpdateCheck.toEnvLine(!0))+" to enable."),{level:"disabled",msg:e}}const i=(0,h.configDir)();if(null==i||!await(0,f.isDirectory)(i))return{level:"warn",msg:["PhotoStructure version checking is disabled","No suitable configuration directory exists."]};const a=await(0,t.getChannelVersions_)();if(null==a)return{level:"warn",msg:["Failed to fetch PhotoStructure version information"]};const u=e?.installedVersion??c.version,d=(0,P.extractUpdateChannel)(u),m=(0,P.eligibleForChannel)(d),g=a.versions.filter((e=>m.includes(e.channel))).map((e=>e.version)),y=e?.latestVersion??(0,b.semverLatest)(...g);if(null==y)return{level:"warn",msg:["PhotoStructure version checking failed","No suitable version was found for "+p.Settings.updateChannel.toEnvLine()]};const v=(0,P.extractUpdateChannel)(y),w="You are running "+(0,l.EditionName)()+" "+(0,_.ver)(u),S="The latest published "+(0,s.tt)(v)+" build is "+(0,_.ver)(y),M=v===d?void 0:"You should consider switching to the "+(0,s.tt)(v)+" channel.",T=Date.now()-a.updatedAt,E="Last checked "+(T{const e=(0,v.channelVersionsCache)(),i=await(0,y.httpGetJson_)({url:"https://photostructure.com/channel-versions.json",headers:{"User-Agent":await(0,m.userAgent)()},cache:e,ttlMs:n.dayMs,preCacheTransform:e=>({versions:e,updatedAt:Date.now(),updatedByVersion:c.version})}),r=i.data;if(null==r||!Array.isArray(r.versions)||0===r.versions.length||r.versions.some((e=>!(0,S.isUpdateChannelVersion)(e)))||r.updatedByVersion!==c.version){if(i.fromCache)return M().info("getChannelVersions_(): Invalid or stale cached response. Retrying after wiping cache",{result:r,cache:e}),await e.unlink_(),t.getChannelVersions_.refresh();M().throw("getChannelVersions_(): Invalid response",{result:r})}return M().tap({msg:"getChannelVersions_()",result:r})}})},8540:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),s=i(9595),n=i(29882),a=i(43334),o=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([o.Settings.libraryDir.valueOrDefault,(0,s.originalsDir)(),...o.Settings.scanPaths.values]))if((!a.isPosix||!(0,n.pathIsRoot)(t))&&(0,n.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},42233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentVolumeRoots=void 0;const r=i(45200),s=i(98770),n=i(7014);t.currentVolumeRoots=(0,s.lazyFsAsync)("currentVolumeRoots",(async function(){const e=[],t=[];for(const i of await(0,n.volumes)()){t.push(i.mountpoint);const s=(await(0,r.nativePath2uri)(i.mountpoint,i))?.toString();null!=s&&e.push(s)}return{uris:e,mountpoints:t}}))},1485:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),s=i(22573),n=i(59455),a=i(50213),o=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.DfPosix"))),v=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function w(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),s=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),n=t&&(i||r||s);return y().tap({msg:"acceptPosixVolume()",result:!n,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:s}})}t.acceptPosixVolume=w,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,n.toA)(await v());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,s.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,n.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,o.assignMissingPrimitives)(i,e))}return t.filter(w)}},69108:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,a.toInt)(e,{defaultValue:0})*o.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,s.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const s=m(e.Used)??0,n=m(e.Available)??0;if(0!==s||0!==n)return{filesystem:t,mountpoint:i,size:d.isMac?s+n:r,used:s,available:n};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:s,available:n})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,s.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,n.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const a=p(i);return!0===e&&a.forEach((e=>e.remote=!1)),a},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),v=i(24399),w=i(28874),b=i(24541),S=i(60224),P=i(63870),_=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const M=/([a-z]+)(?::\\)?/i;function T(e){return e?.match(M)?.[1]?.toUpperCase()}function E(e){return(0,l.map)(T(e),(e=>e+":\\"))}function k(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(T(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function D(e){return null!=e&&!(0,a.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,a.notBlank)(e.DisplayRoot),...(0,l.map)((0,S.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function x(e){return`Get-Volume ${(0,f.toS)(T(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=E,t.getPsDriveCommand=k,t.getVolumeCommand=x,t.getLocalVolumesWin_=function(){return v.PowerShell.instance().executeJsonToA(x())};const C=/\{([-a-z\d]{7,})\}/i;function F(e,t){return e=e?.trim(),(0,a.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function A(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void _().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=E(e.DriveLetter);if(null==t)return void _().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,s.compact)([F(e.HealthStatus,"healthy"),F(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,a.notBlank)(e.DriveLetter)&&(0,a.blank)(i);return _().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(n=e.UniqueId,_().tap({msg:"uniqueId2uuid",result:(0,l.map)(C.exec((0,f.toS)(n)),(e=>e[1])),meta:{s:n}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var n}async function I(){const e=(0,s.uniq)((0,h.toA)(await(0,b.mountpointsWin)()).map(E)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(k(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,s.compact)((0,o.flatten)(t).map(D)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(x(e)).catch((t=>(_().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),a=(0,s.compact)((0,o.flatten)(r).map(A)),l=(0,s.uniq)([...i,...a].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,n.sort)((0,s.uniq)([...i,...a].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));_().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:a,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...a.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=A,t.volumeInfoWin=I},68884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),v=i(83278),w=i(8103),b=i(16287),S=i(45969),P=i(43334),_=i(69108),M=i(98770),T=i(44224),E=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,S.isDocker)()||(0,d.isBillingService)()||null==await(0,w.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,E.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const k=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?k().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,T.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),b.isReadableDirectory),(e=>e.map((e=>v.BaseFile.for(e).clear().childDirectories())))))}):k().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,s.isEmpty)(e)?[]:(k().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,E.mountpointsTtlMs)(),f:async e=>{const t=await(0,_.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void k().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await D(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,E.mountpointsTtlMs)()}))),(0,o.later)((()=>(0,M.setupVolumeTTL)(t.gioVolumes)));const D=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,E.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,n.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(n.notBlank).get()}}catch(t){return void k().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs})},98770:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),s=i(5233),n=i(41400),a=i(56038),o=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,a.time)("volumes."+e,(()=>(0,s.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,o.isRetriableError)(e)&&!1!==(0,o.isIgnorableError)(e)})))),i);return(0,n.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),v=i(98770),w=i(63870),b=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>b().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>b().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const n=(0,c.sortIgnoreCase)((0,s.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),a=[];for(const t of n){const s=e.find((e=>e.mountpoint===t)),n=i?.find((e=>e.mountpoint===t)),o={...s,...n},u=r?.find((e=>e.filesystem===o.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(o,u),null==o.size||null==o.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];b().info("backfilling mountpoint",{info:n,vol:s,df:e}),null!=e&&(0,l.assignMissingPrimitives)(o,e)}a.push(o)}return a};const S=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return S.exec(e)?.[1]?.split(".").map((e=>(0,a.toInt)(e)))})),_=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,a.gte)(t[0],2)&&(0,a.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,v.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await _()],{timeoutMs:(0,w.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,n.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,a.toInt)(e.fsused),r=(0,a.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return b().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,v.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,w.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,n.toNotBlank)(e.PARTLABEL)??(0,n.toNotBlank)(e.LABEL),uuid:(0,n.toNotBlank)(e.PARTUUID)??(0,n.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),s=i(19851),n=i(40958),a=i(22573),o=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),v=(0,s.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,n.uniq)(e.map((e=>e.filesystem?.match(w)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),s=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of s)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,a.blank)(t.MountPoint)||(0,o.isTrue)(t.OSInternal)?v().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){v().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const w=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),v=i(84777),w=i(34330),b=i(8769),S=i(34102),P=i(17217),_=i(16287),M=i(43334),T=i(28874),E=i(8540),k=i(68884),D=i(44224),x=i(24541),C=i(69375),F=i(63870),A=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function O(e=(0,F.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function L(){I()}t.localMountpointSetup=(0,r.lazy)((async()=>{T.Settings.libraryDir.watchLater(I),T.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&T.Settings.scanAllDrives.valueOrDefault?(0,o.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(M.isMac&&(e.info("Setting up Mac diskutil activity watcher"),O((0,F.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),M.isLinux){const i=(0,D.maybeWatchProcMounts)();await(0,k.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),O((0,F.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),O((0,F.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),a.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=T.Settings.mountpoints.values;if((0,s.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",M.isWin?x.mountpointsWin:D.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,s.isEmpty)(e))return A().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,n.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,F.commandTimeoutMs)(),f:async e=>!(!(0,E.mightBeAssetMountpoint)(e)&&(0,C.isExcludedMountpoint)(e)||T.Settings.validateMountpoints.valueOrDefault&&!await(0,_.isReadableDirectory)(e)&&(A().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,b.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(M.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return M.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,o.later)((()=>{(0,S.ee)().on("clearCache",(()=>{k.gioVolumes.unset(),I()})),T.Settings.mountpointsTtlMs.watch(O)}),(0,c.isTest)()?1:a.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>L(),minCallDelayMs:1.5*a.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:k.GioCommand,args:k.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(k.gioVolumes.unset(),L()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const N=(0,r.lazy)((async()=>{if(!M.isLinux)return!1;try{return 0===(await(0,v.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,F.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>L(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(48884),o=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),v=i(28874),w=i(69108),b=i(68884),S=i(59107),P=i(69375),_=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await k()??await(0,c.thenMap)((0,w.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,b.isGioSupported)())try{await(0,c.thenMap)((0,b.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){_().warn("Failed to fetch gio volumes",e)}return e};const M="/proc/mounts";function T(e){return!v.Settings.excludedFilesystemTypes.has(e)}function E(e){return!(0,P.isExcludedMountpoint)(e)&&(!v.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function k(e=M,t=T,i=E){if(y.isLinux)try{const r=await(0,f.readLines_)(e),n=(0,s.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,a.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),o=await(0,c.filterAsync)({name:"mountpoints filter",arr:n,f:async([e,r])=>{const s=t(e),n=await i(r);return _().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:s&&n,meta:{fs:e,mp:r,fsOK:s,mpOK:n}})}});return _().tap({msg:"readProcMounts()",result:o.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void _().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=T,t.readProcMounts=k,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(M)?new h.FileWatcher(M,{recursive:!1,persistent:!1},(()=>{_().info("detected change in "+M),(0,d.setUnrefTimeout)((()=>S.mountpoints.refresh()),n.secondMs)})):void 0))},24541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),s=i(42659),n=i(13538),a=i(50213),o=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,n.thenOrTimeoutError)(f(),o.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*s.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(9103),o=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,n.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,s.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,o.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,o.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,o.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,o.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,s.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,a.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),s=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,n=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function a(e){if((0,r.blank)(e))return;const i=s.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(n,""),remoteShare:i.remoteShare};const a=t.nfsRe.exec(e);if(null!=a){const e=a[1],t=a[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=a(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=a},60224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(55835),o=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),v=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await T()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,a.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const w=["LocalName","RemoteName","Status"],b=["NETUSE","get",w.join(",")],S=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function _(e){if(!(0,s.blank)(e))return(0,o.opt)(e).flatMap((e=>S.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,o.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,s.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,o.opt)(e.pathname).filter(s.notBlank).getOrElse((()=>"/"))}))))).get()}async function M(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,b,{timeoutMs:15*n.secondMs}),i=(0,u.parseFixed)(w,t);return(0,r.compact)(i.map((e=>(0,a.map)(S.exec((0,l.toS)(e.RemoteName)),(t=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=_,t._netInfoWinWmic=M;const T=(0,v.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?M():(0,r.compact)(e.filter((e=>(0,s.notBlank)(e.LocalName))).map((e=>(0,a.map)(_(e.RemoteName),(({host:t,share:i})=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,h.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),s=i(12168),n=i(28874);t.mountpointsTtlMs=function(){return n.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return n.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return n.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=s.MiB/r.secondMs},86848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(38639),o=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),v=i(95696),w=i(45969),b=i(28874),S=i(59107),P=i(63870),_=i(68995),M=(0,s.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),T=(0,s.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function E(e){return(0,a.isTrue)(e.ignorable)||(0,w.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function k(e){if((0,n.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function D(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=k(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function x(e){if(b.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of b.Settings.volumeUuidFilePaths.values){const i=v.PosixFile.for(e.mountpoint).join(t),r=await D(i).catch((e=>M().info("Failed to read "+i,{error:e})));if(null!=r)return M().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,_.volumeUuidSubpath)());if("/"===e.mountpoint)return M().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(b.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return M().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(b.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,_.writeVolumeUuid)(e);if(!(0,n.blank)(t))return M().tap({msg:"readVolumeUUID(): wrote new "+(0,_.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return M().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,o.later)((()=>{(0,m.ee)().on("clearCache",(()=>T.clear())),S.mountpoints.watchLater((()=>T.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(E(e))return;if((0,a.isFalse)(e.ok))return;const t=await T().getOrSetAsync(e.mountpoint,(async()=>x(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>M().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=E,t.toVolumeUUID=k,t.readUuidFile_=D,t.readVolumeUUID=x},7014:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),v=i(59455),w=i(48884),b=i(50213),S=i(7282),P=i(23560),_=i(28850),M=i(45255),T=i(81168),E=i(56519),k=i(4867),D=i(49776),x=i(9595),C=i(77740),F=i(44198),A=i(96706),I=i(8769),O=i(57159),L=(i(34102),i(21144)),R=i(73209),N=i(29882),B=i(95696),j=i(17217),z=i(16287),V=i(49076),W=i(96128),U=i(45969),H=i(43334),q=i(28874),G=i(85087),$=i(50424),J=i(48165),K=i(98770),Y=i(27461),Z=i(66840),X=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,a.lazy)((()=>(0,b.mkLogger)("volumes.Volumes"))),se=s.default.platform(),ne=new Map,ae=new Map,oe=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,G.volsha)(t.uuid),(e=>ae.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,ne),le((0,G.volsha)(e.uuid),e,oe),e}function ce(){return(0,o.compact)([B.PosixFile.forMaybe((0,D.cacheDir)())?.join("volumes"),B.PosixFile.forMaybe((0,x.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),ae))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),ne.clear(),oe.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,E.mapAsync)({name:"readCachedVolumes",arr:(0,E.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,o.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,T.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),s=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:r,os:se}))),n=new Map;for(const e of s)for(const t of(0,o.compactBlanks)([(0,G.volsha)(e.uuid),(0,G.volsha)(e.mountpoint)]))n.set(t,e);const a=ce();for(const e of a)await(0,R.withLock_)({file:e,timeoutMs:M.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of n.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:a,vol_mountpoints:s.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,o.isNotEmpty)(e))return e;const i=(0,v.toA)(await(0,X.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,q.Settings.volumeMetadataTtlMs.valueOrDefault),s=0!==q.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),n=!(0,o.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:s,priorIsMissingMountpoints:n}),s||n?void 0:e}async function me(e,i){const r=(0,m.map)(e,j.toNativePath_);if((0,u.blank)(r))return;const s=await(0,L.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,o.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(s,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:s,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:s}})}async function pe(e,t,i){const r=i.filter((e=>(0,T.equalsIgnoreCase)(t,e.remoteShare)));if((0,o.isEmpty)(r))return;const s=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,T.equalsIgnoreCase)(e,t.remoteHost)));if(null!=s)return s;const n=await(0,W.friendlyname)(e);return(0,E.asyncFind)(r,(async e=>(0,T.equalsIgnoreCase)(n,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,a.lazy)((()=>(0,P.isSyncService)()||(0,S.isTest)())),t.priorWriteVolumesToCacheLatch=(0,a.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,a.lazy)((async()=>{const e=(0,o.compact)(await de()),t=(0,v.toA)(await(0,X.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,o.isNotEmpty)(i)?i:e.filter((e=>se===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,k.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,k.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,o.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,O.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,_.shim0)({name:"fs.volumes",impl:async function(){if((0,S.isTest)()){const e=(0,p.toInt)((0,F.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,C.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,k.thenOrTimeoutError)({p:H.isWin?(0,J.dfWin)():(0,$.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=q.Settings.validateMountpoints.valueOrDefault?(0,o.compact)(await(0,E.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,z.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,k.thenOrTimeoutError)({p:H.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(H.isWin?t:H.isMac?await(0,Z.addLocalVolumeInfoMac)(t):await(0,Y.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await he(r),Object.freeze(r)}}),t.rootPath=(0,a.lazy)((()=>H.isWin?(0,g.opt)((0,A.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,T.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,o.isEmpty)(t)?void 0:(0,w.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,o.commonPrefixLength)(e.split(n.default.sep),t.split(n.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,v.toA)(await i.vols()).find((t=>(0,G.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,E.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return oe.get(e)??(await de())?.find((t=>(0,G.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,G.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(50213),o=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,s.lazy)((()=>(0,a.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,n.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,f());t=(0,n.toNotBlank)(t)??(0,c.safeUUID)();const s=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(s))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+o.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},89372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.httpGetJson_=void 0;const r=i(45599),s=i(98553),n=i(31586),a=i(50213),o=i(51140),l=i(4988),u=(0,r.defer)((()=>(0,a.mkLogger)("web.HttpGet")));t.httpGetJson_=async function(e){const t=e.cache,i=await t.mtimeMs();if(null!=i&&(0,n.gt0)(await t.size())&&(0,n.gte)(i,Date.now()-e.ttlMs))return{data:await t.readJson_(),updatedAt:i,fromCache:!0};const r=await(0,l.get_)(e.url,{headers:e.headers});o.HttpStatusIs.success(r.statusCode)||u().throw("Failed",{url:e.url,response:r});const a=(0,s.parseJSON_)(r.data),c=e.preCacheTransform?.(a)??a;return u().info("Fetch success. Caching",{args:e,json:c,cache:t}),await t.writeJson_(c),{data:c,updatedAt:Date.now(),fromCache:!1}}},51140:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpStatusIs=t.HttpStatus=void 0;const r=i(31586);t.HttpStatus=Object.freeze({OK:200,Accepted:202,MovedPermanently:301,Found:302,SeeOther:303,BadRequest:400,Unauthorized:401,Forbidden:403,NotFound:404,EnhanceYourCalm:420,InternalServerError:500,NotImplemented:501,ServiceUnavailable:503}),t.HttpStatusIs=Object.freeze({ok:e=>(0,r.within)(200,299,e),success:e=>(0,r.within)(200,299,e),redirect:e=>(0,r.within)(300,399,e),clientError:e=>(0,r.within)(400,499,e),serverError:e=>(0,r.within)(500,599,e),error:e=>(0,r.within)(400,599,e)})},21404:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToTagPath=void 0;const r=i(75020),s=i(40958),n=i(22573),a=i(89937),o=i(34238);t.uriToTagPath=function({uri:e,isFile:t}){if(null==e)return;const i=(0,o.toURI)(e),l=i.scheme===a.PS_LIBRARY_SCHEME?r.LibraryTagName:i.scheme===a.PS_LOCAL_FILE_SCHEME?i.authority:void 0;if((0,n.blank)(l))return;const u=i.path.split("/");return(0,s.compactBlanks)([r.TagRoots.fs,l,...t?u.slice(0,-1):u])}},98604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkAssetUrl=t.mkFolderUrl=t.myWebUrl=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(27776),o=i(49076),l=i(72308),u=i(28874),c=i(42231),d=i(45200),h=i(34238),f=i(21404);function m(e=u.Settings.httpPort.valueOrDefault){const t=[u.Settings.localhost.valueOrDefault];u.Settings.exposeNetworkWithoutAuth.valueOrDefault&&t.push(...(0,s.compactBlanks)([(0,l.myExternalIp4Addresses)()[0],(0,o.hostname)()]));const i=(0,h.toURI)("http://a");return t.map((t=>i.with({authority:t+":"+e})))}t.default=m,t.myWebUrl=(0,r.lazy)((()=>m()[0])),t.mkFolderUrl=async function(e){const i=await(0,d.nativePath2uri)(e),r=(0,f.uriToTagPath)({uri:i,isFile:!1});if((0,s.isEmpty)(r))return;const n=(0,a.mkTagUri)((0,c.tagPathToStringArray)(r));return(0,t.myWebUrl)()?.with(n)},t.mkAssetUrl=function(e){return(0,n.gt0)(e)?(0,t.myWebUrl)()?.with({path:"/asset/"+e}):void 0}},4988:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.httpRequest_=t.get_=t.HttpMethods=void 0;const a=n(i(37067)),o=n(i(44708)),l=i(22573),u=i(45599),c=i(50989),d=i(51926),h=i(50213),f=i(45255),m=i(22911),p=i(43205),g=i(34238),y=i(51140),v=(0,u.defer)((()=>(0,h.mkLogger)("net.get")));async function w(e,t){return b({...t,url:e})}async function b(e){const t=(0,g.toURI)(e.url),i=new m.Deferred("get "+t.toString()),r="http"===t.scheme?a.request:"https"===t.scheme?o.request:v().throw("unsupported scheme: "+t.scheme),s=e?.maxRedirects??8,n=e?.timeoutMs??f.ShortCommandTimeoutMs,u={...e?.headers,"user-agent":await(0,p.userAgent)()},c=e?.method??"GET",h=e?.agent??!1,b=r(t.toString(),{method:c,headers:u,timeout:n,agent:h},(e=>{let r="";e.setEncoding("utf8").on("data",(e=>r+=e.toString())).resume().on("end",(()=>{const a={url:(0,l.toNotBlank)(e.url)??t.toString(),contentType:e.headers["content-type"],statusCode:e.statusCode??-1,data:r};s>0&&y.HttpStatusIs.redirect(a.statusCode)&&!(0,l.blank)(e.headers.location)?(console.log("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),v().info("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),i.observe(w(e.headers.location,{timeoutMs:n,maxRedirects:s}))):(v().debug("complete",{...a,data:(0,d.ellipsize)(r,64),data_length:r.length}),i.resolve(a))}))})).on("error",(e=>i.reject(e)));return(0,l.blank)(e.body)||b.write(e.body),b.end(),i}t.HttpMethods=(0,c.strEnum)("GET","PUT","POST","PATCH","DELETE"),t.get_=w,t.httpRequest_=b},65713:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),s=i(19851),n=i(23838),a=i(81168),o=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,s.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,s.lazy)((async()=>{const e=(0,o.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,s.lazy)((()=>({trie:new n.MultiMap,small:[]}))),h=3;function f(e){const t=new n.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=s)return s}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),s=i(96249),n=i(23838),a=i(59455),o=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=n.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,a.toA)(u[t])],n=c(e.substring(1));return(0,s.flatten)(n.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,o.stripDiacritics)(e).normalize())}},30933:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const s=r(i(48161)),n=i(19851),a=i(42659),o=i(31586),l=i(50213),u=i(28874),c=(0,n.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,n.lazy)((()=>s.default.cpus()),5*a.minuteMs),t.cpuCount=(0,n.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=s.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,o.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},14854:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CpuUsage=t.isTooBusy=void 0;const d=c(i(48161)),h=i(42659),f=i(45599),m=i(55835),p=i(31586),g=i(68708),y=i(19851),v=i(50213),w=i(7282),b=i(78406),S=i(25764),P=i(38835),_=i(74128),M=i(82647),T=i(43334),E=i(28874),k=i(30933),D=i(15674),x=(0,y.lazy)((()=>(0,v.mkLogger)("work.CpuUsage"))),C=(0,y.lazy)((()=>{const e=F.instance().busyPct();(0,_.syncReport)().maybeSystemData({from:"cpuUsage",state:"note",details:"Current system load is too high to schedule more work",meta:(0,g.compactValues)({loadCpuPct:I(),cpuBusyPct:e})}),x().warn("Current system load is too high to schedule more work",{cpuBusyPct:e,max:E.Settings.cpuBusyPercent.valueOrDefault})}),((0,w.isTest)()?15:60)*h.secondMs);t.isTooBusy=function(){if(E.Settings.cpuBusyPercent.valueOrDefault<=0)return!1;const e=F.instance().busyPct(),t=(0,p.clamp)(1,150,Math.round(4*E.Settings.cpuBusyPercent.valueOrDefault/3));return(0,p.gte)(e,t)?(C(),!0):(C.unset(),!1)};class F extends b.EndableInterval{constructor(){super({name:"CpuUsage()",callback:()=>l(this,r,"m",o).call(this),intervalMs:((0,D.singleThreadedMode)()?60:T.isWin?20:10)*h.secondMs,rank:S.EndableRanks.first}),r.add(this),s.set(this,new M.Average(5)),n.set(this,new A),(0,p.mapFinite)(I(),(e=>l(this,s,"f").push(e))),l(this,r,"m",o).call(this)}get cpuCount(){return l(this,n,"f").cpuCount}idlePct(){return(0,m.map)(this.busyPct(),(e=>100-e))}busyPct(){return l(this,s,"f").sampleAvg??I()}}t.CpuUsage=F,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){(0,p.gte0)(e)&&l(this,s,"f").push(e)},o=function(){l(this,r,"m",a).call(this,I());const e=new A;l(this,r,"m",a).call(this,e.busyPct(l(this,n,"f"))),u(this,n,e,"f")},F.instance=(0,f.defer)((()=>new F));class A{constructor(e=d.default.cpus()){let t=0,i=0;for(const r of e)t+=r.times.user+r.times.nice+r.times.sys+r.times.irq,i+=r.times.idle;this.busyMs=t,this.idleMs=i,this.cpuCount=e.length}busyPct(e){const t=this.busyMs-e?.busyMs,i=this.idleMs-e?.idleMs,r=t+i;return e?.cpuCount===this.cpuCount&&(0,p.gte0)(t)&&(0,p.gte0)(i)&&(0,p.gt0)(r)?(0,p.sigFigs)(t/r*100,3):void x().warn("busyPct(): Unexpected CpuTimes. If this continues, busyPct() will be incorrect."+P.InternalErrorFlag,{self:this,prior:e,busyMs:t,idleMs:i,totalMs:r})}}function I(){return T.isWin?void 0:(0,p.sigFigs)(d.default.loadavg()[0]/(0,k.cpuInfo)().length*100,3)}},58444:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const s=r(i(48161)),n=i(19851),a=i(31586),o=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,n.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,n.lazy)((()=>{const e=s.default.freemem(),t=s.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,a.gt0)(r))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,o.fmtBytes)(i),freemem:(0,o.fmtBytes)(e),totalmem:(0,o.fmtBytes)(t)}})}))},69385:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOnResume=t._setPaused=t.resume=t.pause=t.isPaused=void 0;const r=i(34102),s=i(37692);let n=!1;function a(){return n}function o(e=!0){l(e),(0,s.writeStateFile)({paused:e})}function l(e){e!==n&&(n=e,(0,r.ee)().emit(e?"pause":"resume"))}t.isPaused=a,t.pause=o,t.resume=function(){return o(!1)},t._setPaused=l;const u=Promise.resolve();t.resolveOnResume=function(){return a()?new Promise((e=>{(0,r.ee)().once("resume",e)})):u}},15674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),s=i(42659),n=i(41400),a=i(31586),o=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,n.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,r.lazy)((()=>{const e=(0,a.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*o.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/o.MB),worstCaseMemPerProcMb:Math.ceil(e/o.MB)}})}),s.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,a.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function b(){return((0,a.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=b,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(b()*(0,f.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(b()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=w();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const s=Math.min(e,v());return t=(0,a.clamp)(1,s,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:b(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,a.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,a.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,a.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},37692:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addStateEvent=t.writeStateFile=t.readStateFile=t.stateEvents=t.StateEvents=t.StateEventFns=void 0;const s=r(i(78474)),n=i(40958),a=i(76790),o=i(42659),l=i(45599),u=i(41400),c=i(68708),d=i(50989),h=i(87290),f=i(73787),m=i(19851),p=i(50213),g=i(28874),y=i(69385),v=(0,l.defer)((()=>(0,p.mkLogger)("work.SharedState")));let w;t.StateEventFns={checkTasks(){},reloadLicenses(){}},t.StateEvents=(0,d.strEnum)(...(0,c.keys)(t.StateEventFns)),t.stateEvents=new s.default;let b=0;function S(){const e=(0,h.libraryDataDirPosixFile)()?.join("state.json"),t=Date.now(),i=t-b>o.minuteMs;i&&(b=t);const r=e?.existsSync({refresh:i})??!1;return r&&null!=e&&e.eql(w?.nativePath)||(w?.close(),w=void 0),r&&null!=e&&(w??(w=new f.FileWatcher(e.nativePath,{encoding:"utf8",persistent:!1,recursive:!1},P))),e}(0,u.later)((()=>{g.Settings.libraryDir.watchLater(P)}));const P=(0,m.lazy)((()=>t.readStateFile.refresh()),25);t.readStateFile=(0,m.lazy)((()=>{const e=S()?.readJsonSync();for(const i of e?.events??[])_.get(i.e)!==i.ts&&(v().info("emitting event "+i.e),t.stateEvents.emit(i.e),_.set(i.e,i.ts));return(0,y._setPaused)(e?.paused??!1),e}));const _=new Map;function M(e){const i=S();if(null==i)v().error("overwrite(): failed: no library directory");else{const r=i?.readJsonSync(),s=function(e){const t=Date.now()-10*o.minuteMs;return(0,n.uniqByLast)((0,a.sortBy)((e??[]).filter((e=>e.ts>t)),(e=>e.ts)),(e=>e.e))}([...r?.events??[],...e.events??[]]),l={paused:e.paused??r?.paused??g.Settings.startPaused.valueOrDefault,events:s};(0,y._setPaused)(l.paused),t.readStateFile.set(l),i.writeJsonSync(l)}}t.writeStateFile=M,t.addStateEvent=function(e){const t=Date.now();_.set(e,t),M({events:[{e,ts:t}]})}},22751:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),s=i(87997),n=i(19851),a=i(42659),o=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,n.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,n.lazy)((()=>new r.Rate(5*a.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,n.lazy)((()=>(0,s.setInterval)(g,a.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,o.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),s=i(22573),n=i(50357),a=i(98553),o=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function v(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function b(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function S(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,o.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const s=[];if(et;n-=i)s.push(r(n));return s}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),s=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===s[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,n.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const s of t){const t=i(s);r.includes(t)||(e.push(s),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>!(0,n.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=b,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(s.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=b(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return S(t,(e=>(0,l.isPrimitive)(e)?e:(0,a.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,n.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=b(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=S,t.uniqByLast=function(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of b(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,a.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const s=new Set(i.map(r));return e.filter((e=>!s.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),s=i(36783),n=i(41801),a=i(98553),o=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,s.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const r of e)(0,o.getOrSet)(i,(0,a.stringify)(t(r)),(()=>r));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,s.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,n.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},75761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetImgAttrs=t.assetSqImgAttrs=t.assetVideoLink=t.assetImgActualLink=t.assetImgLink=t.assetLinkAttrs=t.assetUrl=void 0;const r=i(58939),s=i(40958),n=i(22573),a=i(42659),o=i(11371),l=i(73722),u=i(31586),c=i(54993),d=i(29652),h=i(22403),f=i(2322);function m(e,t){return e+" "+t+"w"}function p(e,t){let i=null==t?void 0:(0,d.mergeURLSearchParams)(...t);const r=(0,c.toS)(e.v);return(0,n.blank)(r)||"1"===r||(i??(i=new URLSearchParams)).append("v",r),i}function g({assetId:e,params:t}){return null==e?"":(0,d.assembleFullPath)("/asset/"+(0,r.id2id)(e),p(e,t))}function y({assetId:e,reducer:t,width:i,params:s}){return(0,d.assembleFullPath)(`/img/${(0,r.id2id)(e)}/${t}/${(0,u.toGt0)(i)??320}`,p(e,s))}function v({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/img/${(0,s.compact)([(0,r.id2id)(e),t]).join("/")}/actual`,p(e,i))}function w({assetId:e,params:t,reducer:i,widths:s,lazyLoad:n,af:l}){if(null==(0,r.id2id)(e))return{src:"/images/clear-64.png"};0===(s=(s??[]).filter(u.gt0)).length&&s.push(320);const d=Math.min(...s),p={width:(0,c.toS)(d)},g=(0,a.fmtLocalToShort)(e.capturedAtLocal);null!=g&&(p.title=g);const w=y({assetId:e,params:t,reducer:i,width:d});n??(n=!0);const b=n&&(0,f.isSafari)((0,h.ua)());b?(p.src="/images/clear-64.png",p["data-src"]=w):p.src=w,(0,f.isSafari)((0,h.ua)())||(p.loading=n?"lazy":"eager"),i===o.ReducerNames.sq&&(p.height=(0,c.toS)(d));const S=s.map((r=>m(y({assetId:e,params:t,reducer:i,width:r}),r)));return null!=l&&S.push(m(v({assetId:e,params:t,assetFileId:l.assetFileId}),l.width)),p[(b?"data-":"")+"srcSet"]=S.join(","),p}t.assetUrl=g,t.assetLinkAttrs=function({assetId:e,params:t}){const i=g({assetId:e,params:t});return(0,n.blank)(i)?{}:{href:i}},t.assetImgLink=y,t.assetImgActualLink=v,t.assetVideoLink=function({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/video/${(0,r.id2id)(e)}-${t}`,p(e,i))},t.assetSqImgAttrs=function({assetId:e,params:t,lazyLoad:i,size:r="m"}){return{...w({assetId:e,params:t,reducer:"sq",widths:l.SqWidths,lazyLoad:i}),sizes:("s"===r?80:"m"===r?160:320)*(0,u.numericOr)(globalThis?.window?.devicePixelRatio,1)+"px"}},t.assetImgAttrs=w},5233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),s=i(31586),n=i(13538),a=i(41583);t.retryOnReject_=async function(e,t){const i=(0,s.gt0)(t.timeoutMs)?()=>(0,n.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const o=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,a.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await o(l),u()}};return u()}},17586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55938),o=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,a.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,a.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,s.blank)(e)?"":"```"+(0,o.toS)(e)+"```"},t.b=function(e){return"**"+(0,o.toS)(e)+"**"},t.li=function(...e){return(0,r.compactBlankish)((0,n.flatten)(e)).map((e=>"- "+(0,o.toS)(e))).join("\n")}},22573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),s=i(42279),n=i(54993);function a(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function o(e){return!a(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,n.toS)(e);return o(i)?t(i):void 0}t.blank=a,t.notBlank=o,t.notBlankToS=function(e){return o(e)&&"undefined"!==e?(0,n.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,n.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,s.tot)(t);const i=(0,n.toS)(e).trim();return i.length>0?i:(0,s.tot)(t)},t.notBlankAnd=function(e,t){return!a(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,n.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{"use strict";function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),s=i(22573),n=i(30301),a=i(55835),o=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,a.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,o.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const s=Math.floor(e/t.minuteMs);e-=s*t.minuteMs;const n=Math.floor(e/t.secondMs),a=Math.floor(e-n*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(s)+":"+(0,l.pad2)(n)+(i.includeMs?"."+(0,l.pad3)(a):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),s=i(),n=i(),a=i(),o=i(),l=i();return new Date(t,l-1,o,a,n,s,r)}function w(){return(new Date).setHours(24,0,0,0)}function b(e,i="ago"){return e<1e3?"just now":(i=(0,s.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const n=Math.floor(e/r.ms);e-=n*r.ms,n>0&&(r.ms>=t.dayMs?i:s).push(n+r.s)}return e>0&&s.push((0,o.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(s)?"":"T"+s.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,a.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return b(Date.now()-e,t)},t.fmtElapsedMs=b},95892:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),s=i(73872);function n(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function a(e,t,i,r){if(null==i||y(e)||y(t))return;let s=i.get(e);null!=s?s.set(t,r):(s=new WeakMap,s.set(t,r),i.set(e,s))}function o(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const s=l(e,t);return null!==s?s:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=n(e,t,u);if(null!==f)return f;const m=n(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return a(e,t,u,i),i;const s=l(e,t);if(null!==s)return s}const y=s(e);if(y!==s(t))return a(e,t,u,!1),!1;a(e,t,u,!0);const v=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return o(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],s=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){s.push([e,t])})),c(r.sort(),s.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return a(e,t,u,v),v}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let s=-1;for(;++s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const s=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return s.prior=()=>t,s.hasPrior=()=>r,s}},41400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),s=i(35556),n=i(31586),a=i(68708);function o(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const n=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&s.isNode&&n.unref?.()}}))}t.delayUntil=function(e){const t=((0,n.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return o(t).then((()=>t))},t.delay=o,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),n=s.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return s.isBrowser||t<=r.secondMs?n:(0,a.maybeCall)(n,"unref")??n}},33374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const r=i(31586),s=i(21605),n=i(12168);function a(e){return{width:e.height,height:e.width}}function o(e){return((0,r.toGt0)(e?.width)??0)*((0,r.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,r.gt0)(e.width)&&(0,r.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,r.gt0)(e)&&(0,r.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,n.pixels2size)(e.width*e.height)},t.dimSwap=a,t.maybeDimSwap=function(e,t){return(0,s.swappableRotation)(t)?a(e):e},t.maybeFlipInPlace=function(e,t){(0,s.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,n.megapixels)(o(e))},t.pixels=o},50357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),s=i(68708),n=i(34666),a=i(32639);function o(e,t){return(0,r.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,a.isFunction)(e)&&(0,a.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=o,t.eqlSubset=function(e,t){if(null==e||null==t||(0,n.isPrimitive)(e)||(0,n.isPrimitive)(t))return e===t;if(!(0,s.isObject)(e)||!(0,s.isObject)(t))return!1;for(const i of(0,s.keys)(e))if(!o(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(31586),o=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,s.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,a.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,n.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,s.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,s.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,s.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(s.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,o.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,o.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,o.assignFields)(new Error,(0,o.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},4188:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),s=i(42659),n=i(55835),a=i(31586),o=i(12168),l=[{ms:s.yearMs,s:"year",p:"years"},{ms:s.yearMs/12,s:"month",p:"months"},{ms:s.weekMs,s:"week",p:"weeks"},{ms:s.dayMs,s:"day",p:"days"},{ms:s.hourMs,s:"hour",p:"hours"},{ms:s.minuteMs,s:"minute",p:"minutes"},{ms:s.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,s){if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,n.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,o.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,n.mapOr)(s,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function s(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=s,t.orList=function(e){return s(e,"or")},t.andList=function(e){return s(e,"and")}},50268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const r=i(22573),s=i(38639),n=i(68708),a=i(62220),o=i(50989);t.HealthCheckSections=(0,o.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,o.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,n.isObject)(e)&&!(0,r.blank)(e.id)&&!(0,r.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,r.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,n.isObject)(e)&&a.RunStates.has(e.state)&&(0,s.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},11371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReducerNames=void 0;const r=i(50989);t.ReducerNames=(0,r.strEnum)("fit","sq")},73722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const s=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,s){if((0,isFunction_1.isFunction)(r))return;let n,a,o,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(n=0;nnew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),s=i(50357),n=i(31586),a=i(65812);t.lazy=function(e,t){let i,o;const l=[];function u(){return u.isStale()&&u.setResult(e()),o}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const n=await e,o=await i;if(!(0,s.eql)(n,o))for(const e of l)e(o);null!=t&&t>0&&void 0!==o&&(0,a.setUnrefTimeout)((()=>u.vacuum()),t)}(o,e),o=e},u.isStale=function(){return null==i||(0,n.gt0)(t)&&i+t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),s=i(54993);function n(e,t){return null==e?void 0:t(e)}function a(e,t,i){return null==e||null==t?void 0:i(e,t)}function o(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=n,t.mapTry=function(e,t){try{return n(e(),t)}catch{return}},t.map2=a,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=o,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return o(a(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,s.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class s extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=s},23838:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),s=i(76790),n=i(50357),a=i(98553),o=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,o.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,o.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,n.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),s=null==i?[]:e(t,i);(0,r.isEmpty)(s)?this.store.delete(t):this.store.set(t,s)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,s]of this.store.entries()){const n=(0,r.findIndexes)(s,(t=>!e(i,t,s)));if(n.length>0){t=!0;for(const e of n.reverse())s.splice(e,1)}0===s.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,a.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,s.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),s=i(22573),n=i(42279),a=i(54993);function o(e){return"number"==typeof e&&isFinite(e)}t.isNumber=o,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,a.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return o(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,a.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>o(t)&&o(i)&&e(t,i);function f(e,i,s){return!(null==s||!o(s))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,s)&&(0,t.gte)(i,s))}function m(e){if(!o(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,s.blank)(e))return t.defaultValue;if(o(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return o(e)&&e>0}function b(e){return o(e)&&e>=0}function S(e,t){return o(e)?t(e):void 0}function P(e){return o(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function M(e,t,i){if(e>t||!o(e)||!o(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return o(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return o(e)?e:t},t.diff=function(e,t){return o(e)&&o(t)?e-t:void 0},t.absdiff=function(e,t){return o(e)&&o(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!o(e)||!o(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return f(t-r,t+r,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)o(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return o(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return o(e)&&o(t)&&e>t?e:void 0},t.lte0=function(e){return o(e)&&e<=0},t.gte0=b,t.toGte0=function(e){return b(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=v(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=S,t.map2Numeric=function(e,t,i){return S(e,(e=>S(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return o(e)?t(e):i},t.numericOr=function(e,t){return o(e)?e:(0,n.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return S(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d+\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!o(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=M,t.times=function(e,t){if(!w(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return M(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!o(i))return;t+=i}return t}},68708:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(32639),o=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function w(e,t,i={}){return y((0,r.compact)((0,s.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function b(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const s={};for(const e of(0,r.uniq)((0,r.flatMap)(i,h)))s[e]=b(...i.map((t=>t[e])));return s}function S(e,t){if(!d(e)||(0,n.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=v(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,s]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==s&&!0!==i?.assignNullish||(e[r]=s));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,o.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,n.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=b,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,n.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=o.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function s(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:b(i,t)}for(const r of i){const[i,a]=(0,c.splitFirst)(r,"."),o=S(t,i);null!=o?.value&&s(o.key,(0,n.blank)(a)?o.value:e(o.value,a))}for(const r of h(t))((0,l.toInt)(r)??-1)>=0&&s(r,e(t[r],...i));return r},t.pluck=S,t.pluckDeep=function e(t,i){if(null==t||(0,n.blank)(i))return;if(Array.isArray(t)){const s=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(s)?void 0:{key:s[0].key,value:(0,r.flatMap)(s,(e=>e.value))}}const[s,a]=(0,c.splitFirst)(i,"."),o=S(t,s);if(null==o)return;if((0,n.blank)(a))return o;const l=e(o.value,a);return null==l?void 0:{key:o.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,n.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,a.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,n.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=w(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>n(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return s(t)?t:n(t)}filter(e){return n(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return n(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return n(e).flatMap((e=>n(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return n(e).flatMap((e=>n(t).flatMap((t=>n(i).flatMap((i=>r(this.a,e,t,i)))))))}}function s(e){return e instanceof r||e===t.None}function n(e){return s(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=s,t.opt=n},97238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSeed=t.prngSeed=t.SeedCount=t.PrimeBins=t.PrimesPerBin=void 0;const r=i(31586),s=i(30976),n=i(54993);t.PrimesPerBin=4,t.PrimeBins=8,t.SeedCount=t.PrimesPerBin**t.PrimeBins,t.prngSeed=function(){return(0,s.randomInt)(0,t.SeedCount)},t.toSeed=function(e){const i=(0,r.toInt)((0,n.toS)(e));return(0,r.within)(0,t.SeedCount,i)?i:void 0}},39926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),s=i(54993),n={};function a(e,t){if(t<1)return"";if(!(0,r.gte)(n[e]?.length,t)){let i=n[e]??e;for(;i.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var r=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return r.parseJSON}})},46891:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),s=new Map([["child","children"],["photo","photos"],["video","videos"]]),n=/([sxz]|ss|sh|ch)$/,a=/[^aeiou]y$/,o=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=s.get(e);return null!=t?t:null!=e.match(n)?e+"es":null!=e.match(a)?e.replace(/y$/i,"ies"):null!=e.match(o)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),s=i(54993),n=["number","string","boolean"];function a(e){return-1!==n.indexOf(typeof e)}t.isPrimitive=a,t.mapPrimitive=function(e,t){return a(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return a(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(a)};const o=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,n=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==n&&"symbol"!==n)){const r=(0,s.toS)(e),n=(0,s.toS)(i),a=r.localeCompare(n);return r[0]===t.CmpReverseFlag&&n[0]===t.CmpReverseFlag?-a:a}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==n?o.indexOf(r)-o.indexOf(n):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function s(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const s of(0,r.toA)(await e))if(null!=s){const e=await s;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=s,t.isPromise=function(e){return s(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),s=i(31586);function n(e,t){return Math.floor(Math.random()*(t-e))+e}function a(e,t,i){return null==i||0===i.length?n(e,t):o(e,t,1,i)[0]}function o(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const s=t-e,a=new Set(r??[]);if(t===e&&0===s&&0===a.size&&1===i)return[e];const o=s-a.size;if(i>o)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:s,size:i,slotsRemaining:o})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of o(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,s.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let r=e;t.global||(t=new RegExp(t,"g"));let s=null;for(;null!=(s=t.exec(e));)s.index===t.lastIndex&&t.lastIndex++,r=r.slice(0,s.index)+i(s)+r.slice(s.index+s[0].length);return r}},21605:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const r=i(31586);function s(e){if(!(0,r.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,r.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=s,t.swappableRotation=function(e){const t=s(e);return 90===t||270===t}},62220:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const r=i(50989);t.RunStates=(0,r.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),s=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),n={};for(const e of t)n[e]=e;const a=e=>null!=e?i[e]:void 0,o=e=>null!=a(e);return{...n,values:t,length:t.length,has:o,includes:o,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:a,ordinal:e=>a(e)??t.length,validOrElse:(e,t)=>o(e)?e:(0,s.tot)(t),mapValid:(e,t)=>o(e)?t(e):void 0,cmp:(e,t)=>{const i=a(e),r=a(t);return null==i||null==r?void 0:i>r?1:i{const i=a(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),s=i(17586),n=i(22573),a=i(96249),o=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=f();return null!=r?(0,o.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function b(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function S(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),s=(0,c.toS)(t);return r.length===s.length&&(r===s||r.toLowerCase()===s.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?s.normalize():s,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,n.blank)(t)?void 0:e.find((e=>S(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,s.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,o.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return w(v(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=b,t.wrap=function e(t,i){const r=i?.maxLineLen??80,s=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,a.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,a.flatten)(r.map((t=>e(t,i))))}if((t=v((0,c.toS)(t),s).trim()).length<=r)return[t];const n=b(t," ",r);if(n>s.length)return[m(t,0,n),...e(m(t,n+1),i)];{const r=t.indexOf(" ",s.length+1);return r>0&&r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),s=i(68708),n=i(42279),a=i(83104),o=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let s=!0;const n=setTimeout((()=>{s&&(s=!1,i(a.Timeout))}),t);try{n.unref?.();const t=await e;s&&(s=!1,i(t))}catch(e){s&&(s=!1,r(e))}finally{clearTimeout(n)}}))}async function u(e,t,i=!0){const s=await l(e,t,i);if(s===a.Timeout)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return s}t.toNotTimeout=function(e){return e===a.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?a.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,n)=>{let a=!0;try{const o=setTimeout((async()=>{if(a){a=!1;try{r(await i())}catch(e){n(e)}}}),t);(0,s.maybeCall)(o,"unref");const l=await e;a&&(a=!1,clearTimeout(o),r(l))}catch(e){a&&(a=!1,n(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const s=t-Date.now();if(s<=0)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(s)+")");return u(e,s,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const s=await l(e,t,r);return s===a.Timeout?(0,n.tot)(i):s}},42279:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),s=i(22573),n=i(54993);function a(e){return"URLSearchParams"===e?.constructor?.name}function o(e){return null==e?void 0:a(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(o)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=a,t.toURLSearchParams=o,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,n.toS)(l(...t));return e+((0,s.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,n.toS)(l(...t));return(0,s.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),s=i(30301),n=i(31586),a=i(46891),o=i(50989),l=i(51926),u=(0,s.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,n.isNumber)(r)&&(i+=r/t.MB);return(0,n.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,n.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,n.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),s=Math.pow(10,3*r),a=d[r];return(0,n.sigFigs)(e/s,t)+" "+a}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),s=Math.pow(2,10*r),a=h[r];return(0,n.sigFigs)(e/s,t)+" "+a},t.MP=1e6,t.megapixels=function(e){return(0,n.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,o.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,a.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,a.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},22403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ua=void 0;const r=i(30301),s=i(54993);t.ua=(0,r.lazy)((()=>(0,s.toS)(globalThis?.navigator?.userAgent)))},2322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,r=/\bSafari\b/,s=/\bFirefox\b/,n=/\biPad\b/,a=/\biPhone\b/;function o(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return o(e,i)}function u(e){return o(e,s)}t.isChrome=l,t.isSafari=function(e){return o(e,r)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return o(e,n)},t.isIphone=function(e){return o(e,a)}},58939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.idEql=t.id2id=void 0;const r=i(55835),s=i(31586);function n(e){const t=e;return(0,s.isNumber)(e)?e:(0,s.isNumber)(t.id)?t.id:(0,s.isNumber)(t.assetId)?t.assetId:(0,s.isNumber)(t.tagId)?t.tagId:void 0}t.id2id=n,t.idEql=function(e,t){return(0,r.map2Or)(n(e),n(t),((e,t)=>e===t),(()=>!1))}},79114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.S=void 0;const r=i(50989);t.S=(0,r.strEnum)("plus","lite")},75020:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInfoTag=t.NotInfoPanelTags=t.LibraryTagName=t.TagRoots=t.isTagRef=t.ctxToS=t.TagGalleryProps=t.nextChildTagsUrl=t.nextAssetsUrl=t.BeforeAfterStreamLimit=t.ThumbsPerSample=void 0;const r=i(76790),s=i(22573),n=i(98553),a=i(31586),o=i(50989),l=i(51926),u=i(29652);t.ThumbsPerSample=128,t.BeforeAfterStreamLimit=8,t.nextAssetsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/assets`,i)},t.nextChildTagsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.seed,(e=>i.seed=e.toString())),(0,a.mapNumeric)(t.limit,(e=>i.limit=e.toString())),(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/child-tags`,i)},t.TagGalleryProps=["tagId","tagPath","assetCount","assetIds","nextAssets","childTags","nextChildTags"],t.ctxToS=function(e){return(0,n.stringify)({seed:e.seed,tagIds:(0,r.sort)([...e.tagIds])})},t.isTagRef=function(e){return null!=e&&!(0,l.isString)(e)&&(0,s.notBlank)(e.name)},t.TagRoots=(0,o.strEnum)("When","Who","Where","What","Camera","Lens","Albums","Keywords","Type","fs"),t.LibraryTagName="Library",t.NotInfoPanelTags=[t.TagRoots.When,t.TagRoots.Camera,t.TagRoots.Lens,t.TagRoots.Type,t.TagRoots.fs],t.isInfoTag=function(e){if(null==e)return!1;const i=(0,l.isString)(e)?e:e.tagPath?.[0];return!t.NotInfoPanelTags.includes(i)}},27776:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkTagUri=t.mkTagFullPath=t.mkHomeFullPath=t.urlSeed=void 0;const r=i(40958),s=i(30301),n=i(31586),a=i(97238),o=i(29652);function l(e,i){const r=(0,o.toURLSearchParams)(e);if(i||!(0,n.isDigits)(r?.get("seed"))){const e=(0,t.urlSeed)().toString();return r?.set("seed",e),r??{seed:e}}return r}function u(e,t,i=!1){const r=c(e,t,i);return(0,o.assembleFullPath)(r.path,r.query)}function c(e,t,i=!1){return{path:"/tag/"+((0,r.isEmpty)(e)?"":e.map(encodeURIComponent).join("/")),query:l(t,i)}}t.urlSeed=(0,s.lazy)(a.prngSeed,100),t.mkHomeFullPath=function(e){return u([],e,!0)},t.mkTagFullPath=u,t.mkTagUri=c},23541:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),s=i(51926);function n(e){return Array.isArray(e)?e:null==e?void 0:(0,s.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return n(e)??[]},t.optToA=n},41583:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),s=i(23541),n=i(59455),a=i(54993);function o(e){return null==e?void 0:(0,s.isError)(e)?e:new Error((0,a.toS)(e))}t.toErr=o,t.toErrs=function(...e){return(0,r.compact)((0,n.toA)(e).map(o))}},54993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return n(e,",")};const s={}.toString;function n(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>n(e,t))).join(t):e.toString!==s?e.toString():(0,r.stringify)(e)}}t.toStr=n},98401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cancelFileAndProcCleanups=t.scheduleFileAndProcCleanups=t.fileCleanups=t.cleanup_=t.maybeCleanup_=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(56519),o=i(76187),l=i(87290),u=i(79267),c=i(32144),d=i(13829),h=i(69734),f=i(95696),m=i(65238),p=i(70257),g=i(13940),y=i(12495),v=i(95402),w=i(28874),b=i(40958),S=i(42659),P=i(31586),_=i(64526),M=i(22526),T=i(69032),E=(0,r.lazy)((()=>(0,s.mkLogger)("library.Cleanup")));async function k(){const e=_.Library.instance();if(null==e)E().info("No library to vacuum.");else{E().info("Running tag and search maintenance...");try{await(0,T.runTagMaintenance)()}catch(e){E().warn("Failed to run tag maintenance",{error:e})}E().info("Vacuuming db..."),await(await e.dbModelSetup_()).db.vacuum(),(0,n.isDbJanitorService)()&&(E().info("Running database maintenance..."),await e.runDbBackup_())}E().info("Cleaning child processes..."),await(v.Pids.instance()?.killOldProcs()),E().info("Cleaning stale and temp files..."),await D(),await(0,a.mapAsync)({name:"fileCleanup",arr:j(),f:e=>e.cleanup()})}t.maybeCleanup_=(0,r.lazy)(k,5*S.minuteMs),t.cleanup_=k;const D=(0,r.lazy)((()=>(0,l.libraryDataDirPosixFile)()?.join("shared-state").rmrf())),x=(0,r.lazy)((()=>u.FileCleanup.for({name:"imageCacheCleanup",rootNativePath:g.imageCacheDir_,staleMs:w.Settings.imageCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(g.ImageCacheName)}))),C=(0,r.lazy)((()=>u.FileCleanup.for({name:"readdirCacheCleanup",rootNativePath:async()=>f.PosixFile.for((0,m.readdirCacheDir)()),staleMs:w.Settings.readdirCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(m.ReadDirCacheName)}))),F=(0,r.lazy)((()=>u.FileCleanup.for({name:"previewWipCleanup",rootNativePath:l.libraryPreviewsDirPosixFile,staleMs:S.hourMs,isPrunable:e=>(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)}))),A=(0,r.lazy)((()=>u.FileCleanup.for({name:"advisoryLockWipCleanup",rootNativePath:d.defaultFsAdvisoryLockDir,staleMs:S.hourMs,isPrunable:h.isPsLockFileOrDir}))),I=(0,r.lazy)((()=>u.FileCleanup.for({name:"syncReportCleanup",rootNativePath:()=>(0,P.gt0)(w.Settings.syncReportRetentionCount.valueOrDefault)?(0,l.librarySyncReportsDir)():void 0,staleMs:S.hourMs,isPrunable:e=>(0,p.isWip)(e)||(0,c.isCsvExt)(e)})));function O(e){return(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)||(0,o.isSqliteFile)(e)}const L=(0,r.lazy)((()=>u.FileCleanup.for({name:"oldLibraryDbBackupCleanup",rootNativePath:()=>(0,M.libraryDbObjects_)().libraryDbBackupDir.sibling("backup"),staleMs:S.hourMs,isPrunable:O}))),R=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryDbBackupCleanup",rootNativePath:()=>(0,M.libraryDbObjects_)().libraryDbBackupDir,staleMs:S.hourMs,minRetained:w.Settings.dbBackupRetentionCount.valueOrDefault,isPrunable:O})));async function N(){const e=await(_.Library.instance()?.dbModelSetup_());return null!=e&&e.useReplica?e.db.localBackupDir():void 0}const B=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryReplicaDbBackupCleanup",rootNativePath:N,staleMs:S.hourMs,minRetained:1,isPrunable:O})));function j(){return(0,b.compact)([x(),C(),F(),A(),(0,y.LogDirCleanup)(),I(),L(),R(),B()])}t.fileCleanups=j,t.scheduleFileAndProcCleanups=(0,r.lazy)((()=>{v.Pids.instance()?.scheduleInterval();for(const e of j())e.scheduleInterval()})),t.cancelFileAndProcCleanups=function(){t.scheduleFileAndProcCleanups.unset(),v.Pids.instance()?.cancelInterval();for(const e of j())e.cancelInterval()}},64526:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Library=void 0;const l=i(27395),u=i(25764),c=i(38836),d=i(99331),h=i(45608),f=i(15056),m=i(87290),p=i(38835),g=i(57159),y=i(61704),v=i(95696),w=i(18454),b=i(13940),S=i(48604),P=i(19851),_=i(23560),M=i(28874),T=i(2858),E=i(7014),k=i(63870),D=i(15674),x=i(22573),C=i(38639),F=i(42659),A=i(56409),I=i(68708),O=i(25470),L=i(22526),R=i(41844);class N extends c.EndableWrapper{static instance(){const e=M.Settings.libraryDir.valueOrDefault,t=a(this,r,"f",s)?.rootDir.nativePath,i=!0===a(this,r,"f",s)?.isReadySync(),n=!0===a(this,r,"f",s)?.ended;return(0,y.nativePathsEqlSync)(t,e)&&!n?a(this,r,"f",s):(0,_.isSyncService)()&&i?void(0,h.exit)({reason:`Library changed mid-run. Shutting down to pick up new library at ${e}.`,status:0}):((0,l.end)(a(this,r,"f",s)),o(this,r,(0,x.blank)(e)||!(0,T._libraryHasSettings)(e)?void 0:new r(e),"f",s))}static get priorInstance(){return a(this,r,"f",s)}static endPriorInstance(){const e=a(this,r,"f",s);return o(this,r,void 0,"f",s),(0,l.end)(e)}static async instanceReady(){const e=r.instance();return await(e?.ready),e}static instanceRequired_(){const e=r.instance();if(null==e)throw new Error("Library is undefined"+p.FatalErrorFlag);return e}constructor(e){super(`library.Library(${e})`,(()=>this.onEnd()),u.EndableRanks.predb),this.start=Date.now(),this.readyLatch=new A.Latch,n.set(this,(0,P.lazy)((async()=>{try{this.logger.debug("setup() started"),this.logger.throwIfAborted_(),await(0,T.readLibrarySettings)(this.rootDir.nativePath),await(0,m.setupLibraryDirs_)(this.rootDir),await(0,b.imageCacheDir_)(),this.logger.throwIfAborted_();const e=await(0,E.bestVolumeForPath)((0,m.libraryPreviewsDirPosixFile)(this.rootDir));if((0,C.isTrue)(e?.remote)){const e=M.Settings.maxConcurrentImportsWhenRemote.valueOrDefault;M.Settings.maxConcurrentImports.hasValue()||(M.Settings.maxConcurrentImports.tmpValue=e,(0,D.clearMaxWorkCaches)()),this.logger.warn(`Library previews are on a remote volume. Setting maxSyncFileJobsMax to ${e}.`)}this.logger.throwIfAborted_(),(0,_.isDbService)()&&await this.dbModelJanitor(),this.previews(),this.logger.throwIfAborted_(),this.readyLatch.isPending()&&(this.logger.info("Library.setup() finished."),this.readyLatch.resolve())}catch(e){this.ended||(0,d.ending)()||(this.logger.warn("setup() failed:",{error:e}),w.HealthCheck.addError(e),this.readyLatch.reject(new g.WrappedError("Failed to start library",{cause:e})))}}))),this.previews=(0,P.lazy)((()=>(0,I.tap)(new S.Previews((0,m.libraryPreviewsDirPosixFile)(this.rootDir)),(e=>S.Previews.instance.set(e))))),this.originalsDir=(0,P.lazy)((()=>(0,m.libraryOriginalsDirPosixFile)(this.rootDir))),this.assetFileRepository=(0,P.lazy)((()=>new R.AssetFileRepository(this.originalsDir()))),this.libraryDbFile=(0,P.lazy)((()=>(0,f.pathToDb)(this.dataDir,"models"))),this.dbModelSetup_=(0,P.lazy)((async()=>{if((0,_.isDbService)())return(0,L.dbModelSetup_)(this.rootDir);throw new Error("Not a db service")})),this.dbFsLock=(0,P.lazy)((async()=>(await this.dbModelSetup_()).fslock)),this.useReplica=(0,P.lazy)((async()=>(await this.dbModelSetup_()).useReplica)),this.modelDb=(0,P.lazy)((async()=>(await this.dbModelSetup_()).db)),this.dbModelJanitor=(0,P.lazy)((async()=>O.DbModelJanitor.for(await this.dbModelSetup_()))),this.onEnd=(0,P.lazy)((async()=>{if(!(0,d.ending)())for(const{ea:e,t}of[{ea:this.dbModelJanitor.clear(),t:5*F.minuteMs},{ea:this.dbFsLock.clear(),t:(0,k.commandTimeoutMs)()}])await(0,l.end)(e,t);this.logger.info("onEnd(): finished.")})),this.rootDir=v.PosixFile.for(e),this.dataDir=(0,m.libraryDataDirPosixFile)(this.rootDir),this.logger.info("new()"),a(this,n,"f").call(this)}get isPendingSetup(){return this.readyLatch.isPending()}get ready(){return this.readyLatch.promise.then((()=>this))}isReadySync(){return this.readyLatch.isResolved()}async runDbBackup_(){return(await this.dbModelJanitor())?.backup_()}}t.Library=N,r=N,n=new WeakMap,s={value:void 0}},19113:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFileFiltersFor=void 0;const r=i(62105),s=i(181),n=i(94448),a=i(39604);t.libraryFileFiltersFor=function(e,{validateFile:t=!1}={}){const i=(0,r.expensiveFileFiltersFor)(e);return null!=(0,n.modelDb)()&&i.push({notBlocklistedSha:a.notBlocklistedSha}),t&&i.push({isValidFile:s.isValidFile}),i}},56992:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.calcVolumesTTL=t.setVolumesTTL=void 0;const r=i(19851),s=i(50213),n=i(76596),a=i(87290),o=i(28874),l=i(2858),u=i(63870),c=i(7014),d=i(42659),h=i(31586),f=i(12168),m=(0,r.lazy)((()=>(0,s.mkLogger)("SetVolumesTTL")));async function p(){if(!(0,l.libraryHasSettings)())return;const e=[],t=await(0,c.volumes)(),i=o.Settings.minDiskFreeGb.defaultValue*f.GB;for(const r of[(0,a.libraryOriginalsDirPosixFile)(),(0,a.libraryPreviewsDirPosixFile)()]){const s=await(0,c.bestVolumeForPath)(r,t);if(null==s)return void m().warn("Can't find volume for "+r+", using default TTL for volumes()");if(s.available(0,l.mkLogger)("library.SuggestedLibraryDir")));class A{static async for(e,t){if((0,D.blank)(e))return;const i=await(0,T.bestVolumeForPath)(e,t);if(null==i)return void F().warn("Skipping library directory suggestion: failed to find mountpoint volume",{nativePath:e});const r=await(0,m.isLibraryDir)(e);return new A(e,r,i)}constructor(e,t,i){this.nativePath=e,this.isLibrary=t,this.vol=i,this.isCurrentLibrary=M.Settings.libraryDir.value===this.nativePath}async whyExcluded(e=M.Settings.minDiskFreeGb.valueOrDefault*C.GB){if(this.isLibrary)return;const t=await(0,P.statMaybe)(this.nativePath,"trace"),i={msg:"whyExcluded()",meta:{nativePath:this.nativePath,stat:t,availableBytes:this.availableBytes,minAvailableBytes:e}};if((0,b.containsHiddenPathname)(this.nativePath))return F().tap({...i,result:"contains hidden path"});{const e=await(0,w.whyExcludedDirectoryRecursive)(v.BaseFile.for(this.nativePath));if(null!=e)return F().tap({...i,result:e})}return null==t||t.isDirectory()?await(0,y.canRWXFirstExistingAncestor)(this.nativePath)?(0,x.gt0)(e)&&this.availableBytesnew A(e,!1,{mountpoint:"/test",available:C.GB})))});const l=[],d=[],y=await i??await(0,T.volumes)();if(null==y||(0,E.isEmpty)(y))return F().warn("volumes() is empty: they don't get any suggestions."),[];async function v(t){const i=await A.for(t,y);if(null!=i)return i.isLibrary||i.isCurrentLibrary?(F().info("addSuggestion(): path is a library",i),void l.push(i)):void(null==await i.whyExcluded(e)&&d.push(i))}if(await v(M.Settings.libraryDir.value),(0,_.isDocker)())return[...l,...d];await v(await(0,p.picturesDir)());const w=[n.default.cwd(),...await(0,S.childDirectories_)(n.default.cwd())];(0,_.isDocker)()||w.push(...await(0,S.childDirectories_)((0,f.homeDir)())),(0,E.filterInPlace)(w,(e=>(0,b.isNotHiddenPosixPath)(e)));for(const e of w)await(0,m.isLibraryDir)(e)&&(F().info("current working dir is a library",e),await v(e));function P(){return Date.now()-r>c.ShortCommandTimeoutMs-500&&(F().debug("...ran out of time, stopping."),!0)}(0,_.isDocker)()||await v(s.default.join((0,f.homeDir)(),(0,a.AppName)())),await(0,h.mapAsync)({name:"suggestedLibraryDirs.addVolume",arr:y,f:e=>async function(e){try{if(await(0,m.isLibraryDir)(e.mountpoint))return F().info("addVolume(): vol.mountpoint is a library",e.mountpoint),void await v(e.mountpoint);for(const t of await(0,S.childDirectories_)(e.mountpoint)){if(P())break;if(await(0,m.isLibraryDir)(t))F().info("addVolume(): dir is a library",t),await v(e.mountpoint);else for(const i of await(0,S.childDirectories_)(t)){if(P())break;await(0,m.isLibraryDir)(i)&&(F().info("addVolume(): dir is a library",t),await v(e.mountpoint))}}const t=s.default.join(e.mountpoint,(0,a.AppName)());F().info("addVolume(): adding default suggestion",t),await v(t)}catch(t){F().warn("addVolume(): Failed to add suggestion",{err:t,vol:e})}}(e),timeoutMs:c.ShortCommandTimeoutMs}),F().debug("Finished gathering suggestions. Filtering...",{priorLibraries:l,suggestions:d});const D=l;for(const e of(0,k.sortBy)(d,(e=>[-e.availableBytes,-e.nativePath.length]))){if(D.length>=t)break;D.some((t=>t.nativePath===e.nativePath||t.mountpoint===e.mountpoint))||(F().debug("adding new path",e),D.push(e))}return(0,E.uniqBy)((0,k.sortBy)(D,(e=>[!e.isCurrentLibrary,!e.isLibrary,-e.free,e.nativePath])),(e=>e.nativePath))}t.SuggestedLibraryDir=A,t.suggestedLibraryDirs=(0,o.lazy)((()=>I())),t._suggestedLibraryDirs=I},77948:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemInformation=t.libraryMetrics=void 0;const r=i(21330),s=i(46296),n=i(17344),a=i(18454),o=i(81674),l=i(66184),u=i(96175),c=i(24540),d=i(23560),h=i(28874),f=i(2858),m=i(84968),p=i(94174),g=i(37805),y=i(14854),v=i(15674),w=i(40958),b=i(22573),S=i(38639),P=i(75240),_=i(55835),M=i(31586),T=i(20214),E=i(51926),k=i(12168),D=i(43487),x=i(54017),C=i(48723);async function F(){if(null==D.Asset.db())return;const e=[];e.push((0,k.plurMetric)(D.Asset.shownCount(),"asset"));const t=x.AssetFile.assetFileCountByMimeTypeRoots();for(const i of t){const t=(0,E.stripSuffix)(i.mimeTypeRoot,"/");e.push((0,k.plurMetric)(i.assetFileCount,t+" file"))}return e.push((0,k.plurMetric)(C.Tag.rows(),"tag")),e}t.libraryMetrics=F;const A={pending:"pending",ok:"ok","no-library":"warn",warn:"warn","stop-sync":"warn",error:"fail",disabled:"ok"};t.systemInformation=async function(){const e=await(0,o.b)(),t=e?.l?.tier??"lite",i=a.HealthCheck.summary();return(0,w.compact)([{term:"Version",defn:g.version},{term:"Edition",defn:(0,n.EditionName)()},{term:"Health checks",defnClass:A[i.level],defnTitle:"Click to see all health checks",termURL:"/health",defn:i.msg[0]},{term:"Subscription",defnClass:t,defn:t,termURL:"/plans/billing?then=/about",defnTitle:"Click to manage your PhotoStructure subscription"},...(0,S.isTrue)(e?.ok)?[{term:"Licensed to",defn:e?.l?.sub},{term:"Expires or renews",defn:(0,_.mapOr)(e?.l?.exp,(e=>(0,r.toIsoDate)(e)),"--"),termURL:"/plans/billing?then=/about",defnTitle:"Click to manage your PhotoStructure subscription"}]:[],{term:"OS",defn:(0,u.osFullName)()},{term:"CPUs",defn:(0,u.CPUs)()},{term:"System load",defn:(0,_.map)(y.CpuUsage.instance().busyPct(),(e=>(0,M.fmtPct)(e)+" busy"))??"(unavailable)"},{term:"Concurrency",defn:`Target system use: ${Math.round(h.Settings.cpuBusyPercent.valueOrDefault)}% (${(0,v.maxConcurrentImports)()} concurrent imports, ${(0,v.sharpThreadsPerProcess)()} gfx/process)`},(0,d.isWebService)()?{term:"Web uptime",defn:(0,P.fmtDuration)((0,m.runtimeMs)())}:void 0,(0,b.mapNotBlank)((0,c.procDeviceModel)(),(e=>({term:"Device",defn:e}))),{term:"Current user",defn:await(0,p.username)()+((0,M.gte0)((0,p.userid)())?"":" (userid: "+(0,p.userid)()+", groupid: "+(0,p.groupid)()+")")},(0,f.libraryHasSettings)()?{term:"Library path",defn:h.Settings.libraryDir.valueOrDefault,defnClass:"library"}:void 0,await(0,T.thenMap)(F(),(e=>({term:"Library metrics",termURL:"https://photostructure.com/faq/metrics/",defn:e}))),{term:"Log directory",defn:(0,s.logDir)()},{term:"Log level",termURL:"https://photostructure.com/faq/error-reports/#log-levels",defn:(0,l.defaultLogLevel)()}]).filter((({term:e,defn:t})=>(0,b.notBlank)(e)&&(0,b.notBlank)(t)))}},31503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogArgs=void 0;const r=i(23560),s=i(83210),n=i(28874),a=i(38639);function o(){return(0,r.isMainService)()||(0,r.isSyncService)()}t.LogArgs={beforeParse:e=>{const t=(o()?', "PS_TAIL_LOGS=true"':"")+' and "PS_LOG_STDOUT=true".';return o()?e.option("-v, --verbose",'Verbose logging from all processes. Shortcut for "--info --tail". Caution: noisy during imports!'):e.option("-v, --verbose","Verbose logging. Equivalent to --info."),e.option("--error",`Emit "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=error"${t}`),e.option("--warn",`Emit "warn" and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=warn"${t}`),e.option("--info",`Emit "info", "warn", and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=info"${t}`),e.option("--debug",`Emit "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY NOISY. Sets "PS_LOG_LEVEL=debug"${t}}`),e.option("--trace",`Emit "trace", "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY VERY NOISY. Sets "PS_LOG_LEVEL=trace"${t}}`),o()&&e.option("--tail",'Emit log messages from both this process and all other concurrently running PhotoStructure processes on this host to stdout. This can be really helpful in seeing how PhotoStructure\'s processes are coordinating work. Caution: very noisy especially during imports. Sets "PS_TAIL_LOGS=true".'),e},afterParse:e=>{const t=(0,a.isTrue)(e.error),i=(0,a.isTrue)(e.warn),r=(0,a.isTrue)(e.info)||(0,a.isTrue)(e.verbose)||(0,a.isTrue)(e.v),l=(0,a.isTrue)(e.debug),u=(0,a.isTrue)(e.trace);u?n.Settings.logLevel.envValue="trace":l?n.Settings.logLevel.envValue="debug":r?n.Settings.logLevel.envValue="info":i?n.Settings.logLevel.envValue="warn":t&&(n.Settings.logLevel.envValue="error"),(0,s.isDaemon)(e)?(n.Settings.tailLogs.envValue=!1,n.Settings.logStdout.envValue=!1):((0,a.isTrue)(e.tail)&&(n.Settings.tailLogs.envValue=!0),(t||i||r||l||u)&&(n.Settings.logStdout.tmpValue=!0,o()&&(n.Settings.tailLogs.tmpValue=!0)),(n.Settings.tailLogs.valueOrDefault||n.Settings.logStdout.valueOrDefault)&&n.Settings.logLevel.isUnset()&&(n.Settings.logLevel.envValue="info"))}}},46628:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.albumsFromTags=t.tagFilesWithAlbums=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(81168),o=i(74417),l=i(28874),u=i(47783),c=i(97573),d=i(42231),h=i(40958),f=i(22573),m=i(68708),p=i(75020),g=i(54993),y=(0,s.lazy)((()=>(0,n.mkLogger)("curators.AlbumTagger")));function v(e){return(0,f.blank)(e)?void 0:l.Settings.tagAlbumTitleHierarchies.valueOrDefault?(0,c.keywordToPath)(e):[e]}function w(e){if(null==e)return[];const t=(0,h.uniq)((0,r.flatMap)(l.Settings.tagAlbumTitle.values,(t=>(0,m.pluckDeep)(e,t)?.value))),i=(0,h.compact)(t.map(v));if((0,h.isEmpty)(i))return[];if(i.length>1)return y().tap({level:"info",msg:"albumFromFile()",result:i.map((e=>[p.TagRoots.Albums,...e]))});const s=i[0],n=(0,r.first)(l.Settings.tagAlbumDescription.values,(t=>(0,m.pluckDeep)(e,t)?.value)),u=(0,h.isEmpty)(s)?"(blank title)":(0,a.firstSubstringIgnoreCase)(l.Settings.tagAlbumsExcluded.values,[...s,(0,g.toS)(n)].join(" ")),c=null==u?[p.TagRoots.Albums,...s]:void 0;if(null!=c){const t={name:c[c.length-1],description:n};for(const i of l.Settings.tagAlbumDate.values){const r=(0,o.parseJsonDateToMillis)((0,m.pluckDeep)(e,i)?.value);if(null!=r){t.releasedAt=r;break}}c[c.length-1]=t}return y().tap({level:"info",msg:"albumFromFile()",result:(0,h.compact)([c]),meta:{titles:i,desc:n,whyExclude:u}})}t.tagFilesWithAlbums=async function(e){const t=[];for(const i of e){t.push(...w(await(0,u.readTags)(i)));for(const e of l.Settings.tagAlbumFilenames.values)t.push(...w(await(0,u.readRawTags)(i.sibling(e),!1)))}return y().tap({msg:"tagFilesWithAlbums()",result:(0,d.uniqTagPaths)(t),meta:{files:e}})},t.albumsFromTags=w},88224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagAsset=t.tagAndUpsertAsset_=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(28874),o=i(42231),l=i(40958),u=i(20214),c=i(43487),d=i(46628),h=i(63175),f=i(4407),m=i(58886),p=i(32646),g=i(48144),y=i(60047),v=i(6186),w=i(42003),b=i(43723),S=(0,r.lazy)((()=>(0,s.mkLogger)("curators.AssetTagger")));async function P({primaryVariation:e,files:t,priorTagPaths:i,capturedAts:r,uris:s}){const u=[];if(t=(0,l.uniqBy)([e,...t],(e=>e.nativePath)),a.Settings.tagCamera.valueOrDefault&&await(0,n.thenMap)((0,h.cameraTagFile)(e),(t=>{S().debug("Camera tag for "+e+":",t),u.push(t)})),a.Settings.tagLens.valueOrDefault&&await(0,n.thenMap)((0,y.lensTagFile)(e),(t=>{S().debug("Lens tag for "+e+":",t),u.push(t)})),a.Settings.tagGeo.valueOrDefault)for(const e of t){const t=await(0,p.geoTagFile)(e);if(null!=t){u.push(t);break}}await(0,n.thenMap)((0,f.dateTagFile)(e,r),(t=>{S().debug("Date tag for "+e+":",t),u.push(t)}));const c=await(0,b.whoTagFiles)(t)??[];S().debug("whoTagFiles for "+e+":",c),u.push(...c),await(0,n.thenMap)((0,g.keywordTagFiles)(t,c),(t=>{S().debug("Keyword tags for "+e+":",t),u.push(...t)})),a.Settings.tagFileType.valueOrDefault&&await(0,n.thenMap)((0,w.typeTagFiles)(t),(t=>{S().debug("MIME type tags for "+e+":",t),u.push(...t)})),await(0,n.thenMap)((0,m.tagAssetPaths)(s),(e=>{S().debug("file paths for uris",{uris:s,arr:e}),u.push(...e)})),await(0,n.thenMap)((0,d.tagFilesWithAlbums)(t),(t=>{S().debug("Album tags for "+e+":",t),u.push(...t)}));const P=(0,o.omitAncestorTags)((0,l.uniqBy)(u.map(v.normalizeTagRoot),o.joinTagPath)),_=await(0,v.tagDeltas)(i,P);return S().info("tagAsset("+e+")",{priorTagPaths:i,after:P,result:_}),_}t.tagAndUpsertAsset_=async function(e){const t=await e.getExistingAssetFiles();S().info("tagAndUpsertAsset()",{asset:e,existing_uris:t.map((e=>e.uri))});const i=t.find((e=>e.shown)),r=await(i?.posixFile_());if(null==i||null==r)return void S().throw("tagAndUpsertAsset(): no existing or primary asset file",{asset:e,existingPrimaryAssetFile:i,primaryVariant:r,doNotSend:!0,fatal:!1});const s=e.getShown();s?.id!==i.id&&(S().warn("Changing primary asset we're using a different variant for tagging.",{newPrimary:i.uri,priorPrimary:s?.uri}),e.setShown_(i));const n=await(0,u.thenCollect)(t,(e=>e.posixFile_())),l=e.getAssetFiles().map((e=>e.uri)),d=e.getTagPaths(),h=await e.getCapturedAts(),f=await P({primaryVariation:r,files:n,priorTagPaths:d,capturedAts:h,uris:l});S().info("tagAndUpsertAsset",f);const m=f.add.find((e=>(0,o.leafIsExcluded)(e,a.Settings.keywordBlocklist.values)));if(null!=m){if(!0!==e.shown)return S().info("this asset has an excluded tag, and it wasn't shown yet, so we're removing it.",{excludedTag:m}),await c.Asset.remove({assetId:e.id,blocklistShas:!1,unlinkAssetFiles:!1}),S().throw("tagAndUpsertAsset(): asset had excluded tag. Removed.",{excludedTag:m,uris:l,files:n.map((e=>e.nativePath))});S().info("this asset has an excluded tag, marking excluded",{excludedTag:m}),e.excludedAt=Date.now()}return e.applyTagPathDeltas(f),await e.updateFromFiles(),f},t.tagAsset=P},63175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cameraTagFile=t.cameraTag=void 0;const r=i(47783),s=i(75020),n=i(40958),a=i(22573);function o(e){return null==e||(0,a.blank)(e.Make)?void 0:(0,n.compactBlankish)([s.TagRoots.Camera,e.Make,e.Model])}t.cameraTag=o,t.cameraTagFile=async function(e){return o(await(0,r.readTags)(e))}},4407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateTagFile=t.dateTag=t.dayTagRef=t.monthTagRef=t.yearTagRef=t.dayToOrdinal=t.ordinalToMonth=t.monthToOrdinal=t.yearToOrdinal=void 0;const r=i(19851),s=i(19043),n=i(97352),a=i(81168),o=i(928),l=i(34102),u=i(28874),c=i(28544),d=i(47783),h=i(40958),f=i(55835),m=i(31586),p=i(75020),g=i(54993),y=(0,r.lazy)((()=>new Intl.DateTimeFormat((0,s.localeSync)(),{month:"short"}))),v=(0,r.lazy)((()=>{const e=y();return(0,h.range)(0,12,(t=>e.format(new Date(2016,t,1)))).map((e=>(0,a.stripSuffix)(e,".")))}));function w(e){return 1e4-e}function b(e){return 13-e}function S(e){return 33-e}function P(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:w(e)})))}function _(e){if((0,m.within)(1,12,e))return(0,f.map)(v()[e-1],(t=>({name:String(e),displayName:t,ordinal:b(e)})))}function M(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:S(e)})))}function T(e){const t=(0,g.toS)(u.Settings.tagYMD.valueOrDefault).toLowerCase();if(null==e||""===t||"off"===t||t.startsWith("disable"))return;const i=[p.TagRoots.When];if(t.startsWith("y")){const t=(0,f.map)((0,o.getYear)(e),P);if(null==t)return;i.push(t)}if(t.startsWith("ym")){const t=(0,f.map)((0,o.getMonth)(e),_);if(null==t)return i;i.push(t)}if(t.startsWith("ymd")){const t=(0,f.map)((0,o.getDay)(e),M);if(null==t)return i;i.push(t)}return i}(0,l.ee)().on("clearCache",(()=>{y.unset(),v.unset()})),t.yearToOrdinal=w,t.monthToOrdinal=b,t.ordinalToMonth=function(e){return 13-e},t.dayToOrdinal=S,t.yearTagRef=P,t.monthTagRef=_,t.dayTagRef=M,t.dateTag=T,t.dateTagFile=async function(e,t){if(""===u.Settings.tagYMD.valueOrDefault)return;const i=[...t];(0,h.isEmpty)(t)&&i.push((await(0,d.readTags)(e))?.capturedAt);const r=(0,c.bestCapturedAt)(i);return null==r||(0,c.capturedAtSrcFromStat)(r.src)&&!u.Settings.tagDateFromStat.valueOrDefault?void 0:T(r.date)}},58886:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addFileUriTagsToAsset=t.addFilesTagsToAsset=t.isFsTag=t.tagAssetPaths=void 0;const r=i(19851),s=i(50213),n=i(42231),a=i(21404),o=i(40958),l=i(89937),u=i(75020),c=i(54017),d=i(94448),h=i(69032),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.FilePathTagger")));function m(e,t){return e.applyTagPathDeltas({add:(0,o.compact)(t.map((e=>(0,a.uriToTagPath)({uri:e,isFile:!0}))))})}t.tagAssetPaths=async function(e){const t=[];for(const i of e)try{const e=(0,a.uriToTagPath)({uri:i,isFile:!0});if(null==e)continue;if(i.startsWith(l.PS_LOCAL_FILE_SCHEME)&&null!=(0,d.modelDb)()){const t=(0,n.tagRefToS)(e[1]);e[1]={name:t,displayName:await(0,h.displayNameForVolsha)(t)},f().info("tagAssetPaths()",{uri:i,tp:e})}t.push(e)}catch(e){f().warn("Failed to parse asset file URI",{uri:i})}return t},t.isFsTag=function(e){return(0,n.tagRefToS)(e[0]).toLowerCase()===u.TagRoots.fs},t.addFilesTagsToAsset=function(e){const t=c.AssetFile.dbl.pluckAllf((t=>t.select("uri").where({asset:e})));return m(e,t)},t.addFileUriTagsToAsset=m},32646:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.geoTagFile=t.geoTag=void 0;const r=i(48884),s=i(56519),n=i(28874),a=i(47783),o=i(75020),l=i(40958);function u(e){const t=(0,r.compactRight)(n.Settings.tagGeoTemplate.valueOrDefault.map((t=>e?.[t])));return 0===t.length||t.some((e=>null==e))?void 0:(0,l.compact)([o.TagRoots.Where,...t])}t.geoTag=u,t.geoTagFile=function(e){return(0,s.thenMap)((0,a.readTags)(e),u)}},48144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.keywordTagFiles=t.processKeywords=t.dedupeKeywordPaths=t.normalizeKeywordPaths=t.extractPathnameTags=t.extractDashDashTags=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(68852),o=i(81168),l=i(96859),u=i(56519),c=i(28874),d=i(47783),h=i(97573),f=i(42231),m=i(40958),p=i(76790),g=i(22573),y=i(41400),v=i(96249),w=i(55835),b=i(75020),S=i(54993),P=i(6186),_=i(43723),M=(0,s.lazy)((()=>(0,n.mkLogger)("curators.KeywordTagger"))),T=(0,s.lazy)((()=>(0,g.mapNotBlank)(c.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[ /${(0,a.escapeRegExp)(e)}]`)))));function E(e){return M().tap({msg:"extractDashDashTags()",result:(0,w.mapOr)((0,S.toS)(e).split("--")[1],(e=>(0,m.compactBlanks)((0,w.mapOr)(T(),(t=>e.split(t)),[e]))),(()=>[])),meta:{s:e}})}function k(e){return[...E(e.parent().posixPath),...E(e.name)]}(0,y.later)((()=>{c.Settings.keywordDelimiters.watchLater((()=>T.unset()))})),t.extractDashDashTags=E,t.extractPathnameTags=k;const D=/\w{2,7}:\/\/\S+/g;function x(e){const t=[],i=[],s=[];for(const t of(0,m.compact)(e))if(Array.isArray(t))s.push(t);else{const e=(0,S.toS)(t).replace(D,(e=>(i.push(e),"")));s.push(...(0,w.mapOr)((0,h.delimRe)(),(t=>e.split(t)),[e]))}const n=s.map((e=>(0,o.isString)(e)?(0,h.keywordToPath)(e):e)).map((e=>Array.isArray(e)&&1===e.length?e[0]:e)),[a,l]=(0,r.partition)(n,Array.isArray),u=a.map((e=>(0,m.compactBlanks)(e.map((e=>e.trim()))))).filter(m.isNotEmpty),d=(0,o.uniqIgnoreCase)((0,v.flatten)(u));t.push(...u);const f=[...l,...i].map((e=>e.trim())).filter((e=>(0,g.notBlank)(e)&&!(0,o.includesIgnoreCase)(d,e))),p="copy"===c.Settings.keywordReparenting.valueOrDefault,y="retain"===c.Settings.keywordReparenting.valueOrDefault,P=c.Settings.rootTagKeywordsAliases.values;for(const e of[...t])(0,o.includesIgnoreCase)(P,e[0])&&(e[0]=b.TagRoots.Keywords),e[0]!==b.TagRoots.Keywords&&(p?t.push([b.TagRoots.Keywords,...e]):y&&e.unshift(b.TagRoots.Keywords));for(const e of f)t.push([b.TagRoots.Keywords,e]);return(0,m.uniq)(t)}function C(e){return(0,m.uniqBy2)((0,p.sortBy)(e.map(P.normalizeTagRoot),(e=>{const t=(0,f.joinTagPath)(e);return[t.normalize().toLowerCase(),-1*(0,l.lcdiff)(t)]})),((e,t)=>(0,o.equalsIgnoreCase)((0,f.joinTagPath)(e),(0,f.joinTagPath)(t))))}function F(e,t){const[i,s]=(0,r.partition)(x(e),_.isWhoTag),n=(0,v.flatten)(i.map(_.nameTag)),a=(0,m.uniq)((0,v.flatten)([...n,...t].map((e=>{const t=(0,P.stripTagRoot)(e);return[t.join(", "),t.join(" "),[...t].reverse().join(" ")]})))),l=C([...s.filter((e=>!(0,o.includesIgnoreCase)(a,(0,P.stripTagRoot)(e).join(" ")))),...n]);return M().tap({msg:"processKeywords()",level:"info",result:l})}t.normalizeKeywordPaths=x,t.dedupeKeywordPaths=C,t.processKeywords=F,t.keywordTagFiles=async function(e,t){return F([...c.Settings.tagKeywordsFromPath.valueOrDefault?(0,v.flatten)(e.map(k)):[],...c.Settings.tagKeywordsFromMetadata.valueOrDefault?(0,v.flatten)(await(0,u.mapAsyncSerial)({name:"keywordTagFiles",arr:e,f:e=>(0,u.thenMap)((0,d.readRawTags)(e),h.rawTagKeywords)})):[]],t)}},60047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lensTagFile=t.lensTag=void 0;const r=i(56519),s=i(28874),n=i(47783),a=i(75020),o=i(40958),l=i(22573),u=i(55835);function c(e){return(0,u.map)(e,(e=>(0,l.mapNotBlank)(e.lensMake,(t=>(0,l.mapNotBlank)((0,o.compactBlanks)(s.Settings.tagFullLensModel.valueOrDefault?[e.lensModel,e.lensInfo]:[e.lensInfo,e.lensModel])[0],(e=>[a.TagRoots.Lens,t,e]))))))}t.lensTag=c,t.lensTagFile=function(e){return(0,r.thenMap)((0,n.readTags)(e),c)}},6186:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagDeltas=t.normalizeTagRoot=t.stripTagRoot=t.hasTagRoot=t.Roots=t.KwRoot=t.WhoRoot=t.AlbumsRoot=t.WhenRoot=void 0;const r=i(50213),s=i(28874),n=i(42231),a=i(75020),o=i(40958),l=i(22573),u=i(45599);t.WhenRoot={name:a.TagRoots.When,ordinal:1},t.AlbumsRoot={name:a.TagRoots.Albums,ordinal:2},t.WhoRoot={name:a.TagRoots.Who,ordinal:4},t.KwRoot={name:a.TagRoots.Keywords,ordinal:7};const c=(0,u.defer)((()=>(0,r.mkLogger)("curators.Taggers")));t.Roots=[t.WhenRoot,t.AlbumsRoot,{name:a.TagRoots.fs,ordinal:3},t.WhoRoot,{name:a.TagRoots.Camera,ordinal:5},{name:a.TagRoots.Lens,ordinal:6},t.KwRoot,{name:a.TagRoots.Type,ordinal:8}];const d=(0,o.uniq)([...a.TagRoots.values,...s.Settings.rootTagKeywordsAliases.values,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function h(e){return d.includes((0,n.tagRefToS)(e[0]).toLowerCase())}t.hasTagRoot=h,t.stripTagRoot=function(e){return h(e)?e.slice(1):e};const f=(0,o.uniq)([a.TagRoots.Albums,...s.Settings.rootTagAlbumsAliases.values].map((e=>e.toLowerCase()))),m=(0,o.uniq)([a.TagRoots.Keywords,...s.Settings.rootTagKeywordsAliases.values].map((e=>e.toLowerCase()))),p=(0,o.uniq)([a.TagRoots.Who,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));t.normalizeTagRoot=function(e){const i=(0,n.tagRefToS)(e[0]).toLowerCase();return(0,l.blank)(i)?e:m.includes(i)||m.includes(i)?[t.KwRoot,...e.slice(1)]:p.includes(i)?[t.WhoRoot,...e.slice(1)]:f.includes(i)?[t.AlbumsRoot,...e.slice(1)]:e},t.tagDeltas=async function(e,t){const i=(0,n.tagDiff)(t,e),r=(0,n.tagDiff)(e,t),a=s.Settings.excludedRootTags.valueOrDefault;return(0,o.filterInPlace)(i,(e=>{const t=a.includes((0,n.tagRefToS)(e[0]).toLowerCase());return t&&!(0,n.tagPathsInclude)(e,r)&&(r.push(e),c().info("tagDeltas(): removing excluded tag",e)),!t})),{add:i,remove:r}}},42003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fixCase=t.friendlySubtype=t.mimeTypeToTag=t.typeTagFiles=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(56519),o=i(54979),l=i(40958),u=i(22573),c=i(55835),d=i(42279),h=i(75020),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.TypeTagger")));t.typeTagFiles=async function(e){const t=(0,l.uniq)(await(0,a.mapAsyncSerial)({name:"typeTagFiles",arr:e,f:o.readMimeType}));return(0,l.compact)(t.map(p))};const m=new Map(["M2TS","JPEG","QuickTime"].map((e=>[e.toLowerCase(),e])));function p(e){const[t,i]=e.split("/");if(!(0,u.blank)(t)&&!(0,u.blank)(i))return f().tap({msg:"mimetypeToTag("+e+")",result:(0,c.map)(y(i,e),(e=>(0,l.compactBlanks)([h.TagRoots.Type,(0,n.capitalize)(t),...e])))})}t.mimeTypeToTag=p;const g=(0,r.lazy)((()=>new Map([["image/x-adobe-dng",["Raw","DNG"]],["image/x-fuji-raf",["Raw","Fujifilm"]],["video/m2ts",["MPEG-2"]],["video/mp2t",["MPEG-2"]],["video/mp4",["MPEG-4"]],["video/quicktime",["QuickTime"]],["video/x-msvideo",["AVI"]]])));function y(e,t){return(0,d.firstDefinedThunk)([()=>g().get(t.trim().toLowerCase()),()=>(0,c.map)(e.match(/^x-(\w{4,})-\w{3}/),(e=>["Raw",(0,n.capitalize)(e[1])])),()=>[v(e.replace(/^(?:x-|vnd\.|prs\.)/i,"").replace(/-/g," "))]])}function v(e){return null!=e.match(/[a-z\d]{3,4}/i)?e.toUpperCase():m.get(e.trim().toLowerCase())??(0,n.capitalize)(e)}t.friendlySubtype=y,t.fixCase=v},43723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nameTag=t.isWhoTag=t.whoTagFiles=void 0;const r=i(19851),s=i(50213),n=i(28874),a=i(47783),o=i(28630),l=i(66039),u=i(42231),c=i(40958),d=i(22573),h=i(96249),f=i(68708),m=i(75020),p=i(59455),g=(0,r.lazy)((()=>(0,s.mkLogger)("curators.WhoTagger")));t.whoTagFiles=async function(e){const t=[];if(n.Settings.tagJsonFaces.valueOrDefault){const i=[];for(const t of e)i.push(...(0,p.toA)(await t.jsonSidecars()));for(const e of i){const i=await(0,o.readJsonSidecar)(e),r=i?.peopleNames;(0,c.isNotEmpty)(r)&&t.push(...r)}}if(n.Settings.tagFaceRegions.valueOrDefault)for(const i of e){const e=await(0,a.readRawTags)(i,!0);if(null!=e)for(const i of(0,f.values)(e)){const e=i?.RegionList;if(Array.isArray(e))for(const i of e)"Face"===i.Type&&t.push(i.Name)}}if((0,c.isNotEmpty)(n.Settings.whoTags.values))for(const i of e){const e=await(0,a.readRawTags)(i,!0);for(const i of n.Settings.whoTags.values)t.push(...(0,p.toA)((0,f.pluckDeep)(e,i)?.value))}const i=(0,c.uniq)((0,h.flatten)((0,c.uniq)(t).map(w)));return g().tap({msg:"whoTagFiles()",level:"info",result:i,meta:{names:t,files:e.map((e=>e.nativePath))}})};const y=(0,c.uniq)([m.TagRoots.Who,...n.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function v(e){return y.includes((0,u.tagRefToS)(e[0]).toLowerCase())}function w(e){if(!(0,d.blank)(e))return Array.isArray(e)?(v(e)&&e.shift(),0===e.length?void 0:1===e.length?(0,l.renderNameTag)(e[0]):[[m.TagRoots.Who,...e]]):(0,l.renderNameTag)(e)}t.isWhoTag=v,t.nameTag=w},98348:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Db=void 0;const c=i(48884),d=i(19851),h=i(23560),f=i(25764),m=i(38836),p=i(99331),g=i(12959),y=i(55332),v=i(91872),w=i(80632),b=i(51040),S=i(44955),P=i(15056),_=i(70025),M=i(57159),T=i(18454),E=i(28874),k=i(5233),D=i(42659),x=i(31586),C=i(68708),F=i(30976),A=i(17036),I=i(27134),O=i(35052);class L extends m.EndableWrapper{constructor(e,t){super("db.Db("+e+")",(()=>this.closeDb()),f.EndableRanks.db),r.add(this),this.schema=e,this.dbFile=t,s.set(this,0),n.set(this,void 0),this.endTimeoutMs=D.minuteMs,this.onRetry=(0,d.lazy)((()=>this.closeDb()),E.Settings.maxBusyDbMs.valueOrDefault/2),this.maxUpdatedAt=(0,d.lazy)((()=>"models"===this.schema?l(this,r,"m",a).call(this,"Asset","AssetFile","Example"):0),5*D.secondMs),this.migrate_=(0,d.lazy)((async()=>{let e=!1;const t=this.dbFile;if(null==this.dbFile)throw new Error("Cannot migrate database: missing db");let i;if(await this.dbFile.isNonEmptyFile())try{await(0,I.verifyDb_)((()=>this.db))}catch(e){this.logger.warn("verifyDb failed before attempting Migration.",{error:e}),i=e}(null!=i||E.Settings.dbForceRecover.valueOrDefault)&&(T.HealthCheck.addLoadingMsg("Repairing database..."),await this.repair_(),e=!0);const r=new A.Migration(this.schema,this.db,t);return{appliedMigrations:await r.apply_(),migration:r,repaired:e}})),this.tableInfo_=(0,d.lazy)((()=>(0,O.localTableInfo)(this.db)))}toJSON(){return(0,C.pick)(this,"schema","dbFile")}get isOpen(){return!0===l(this,n,"f")?.open}get inTransaction(){return this.isOpen&&!0===l(this,n,"f")?.inTransaction}prepare(e){return this.db.prepare(e)}pragma(e,t){return this.logger.tapThunk({msg:"PRAGMA "+e,result:()=>this.db.pragma(e,t)})}get db(){var e;const t=null==l(this,n,"f");if(t||!this.isOpen){this.logger.info("setting up new db connection to "+this.dbFile,{priorWasNull:t});try{u(this,n,(0,w.mkdb_)({nativePath:this.dbFile.nativePath}),"f")}catch(e){throw new M.WrappedError("Failed to set up "+this.dbFile,{cause:e,path:this.dbFile.nativePath})}}return(0,h.isSyncService)()&&"INCREMENTAL"===E.Settings.dbAutoVacuumMode.valueOrDefault&&(0,x.gt0)(E.Settings.dbWalAutoCheckpoint.valueOrDefault)&&u(this,s,(e=l(this,s,"f"),++e),"f")%E.Settings.dbWalAutoCheckpoint.valueOrDefault==0&&(this.logger.info("running incremental_vacuum..."),l(this,n,"f")?.pragma("incremental_vacuum")),l(this,n,"f")}async verify_(){await(0,I.verifyDb_)((()=>this.db))}assertHeartbeat_(){const e=(0,F.randomChars)(64),t=Date.now();try{this.db.prepare("INSERT INTO heartbeat (name, createdAt, updatedAt) VALUES (?,?,?)").run(e,t,t);const i=this.db.prepare("SELECT * FROM heartbeat WHERE name = ?").get(e);if(i?.name!==e)throw new Error("heartbeat INSERT/SELECT roundtrip failed")}finally{try{this.db.prepare("DELETE FROM heartbeat WHERE name = ?").run(e)}catch{}}}async closeDb(){try{this.logger.info("closing db",l(this,n,"f")),await(0,k.retryOnReject_)((()=>{!0===l(this,n,"f")?.open&&l(this,n,"f")?.close()}),{timeoutMs:E.Settings.dbBusyTimeoutMs.valueOrDefault,maxRetries:5,errorIsRetriable:_.isSqliteBusyError,retryDelay:D.secondMs})}catch(e){this.logger.warn("closeDb(): .close() failed",e)}u(this,n,void 0,"f")}async vacuum(){try{await(0,v.handleDbRetries_)("db.checkpoint",(()=>this.db),(()=>(0,I.checkpoint_)({db:this.db})),this.onRetry),await(0,v.handleDbRetries_)("db.optimize",(()=>this.db),(()=>this.db.pragma("OPTIMIZE")),this.onRetry),await(0,v.handleDbRetries_)("db.vacuum",(()=>this.db),(()=>this.db.exec("VACUUM")),this.onRetry)}catch(e){throw this.logger.warn("vacuum(): failed",{error:e}),e}}async repair_(){this.logger.warn("repair_(): Attempting restore of "+this.dbFile),await this.closeDb(),await(0,I.repairDbFile_)(this.dbFile),this.logger.info("repair_(): Database restoration was successful!")}localBackupDir(){return(0,P.dbBackupDir)(this.dbFile)}async backup_(e,t){const i=t??await(0,S.isDirSQLiteReadWrite)(e),s=(i?e:this.localBackupDir().join((0,g.filestamp)())).join(this.dbFile.base);return await l(this,r,"m",o).call(this,s),i||await(0,y.dbBackupCold_)(s,e),e.join(this.dbFile.base)}}t.Db=L,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(...e){const t=[];for(const i of e)try{t.push(this.db.prepare("SELECT MAX(updatedAt) FROM "+(0,b.dbValueToEscapedString)(i)).pluck().get())}catch(e){this.logger.warn(`#maxUpdatedAt(): failed to get max updatedAt for ${i}`,e)}return(0,c.max)(t)},o=async function(e){await e.parent().mkdirp_(),await this.db.backup(e.nativePath,{progress:e=>(this.logger.log((0,p.ending)()?"info":"debug","backup() "+(0,x.fmtPct)(100-e.remainingPages/e.totalPages*100)+" completed"),(0,p.ending)()?1e3:100)})}},25470:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.DbModelJanitor=t.Contested=t.NoOp=t.NoWriteLock=void 0;const c=i(66364),d=i(50213),h=i(23560),f=i(78406),m=i(25764),p=i(38836),g=i(99331),y=i(56038),v=i(12959),w=i(55332),b=i(76187),S=i(73209),P=i(28874),_=i(42659),M=i(75240),T=i(95700),E=i(22526),k=i(45648),D=5*_.minuteMs;t.NoWriteLock=Symbol("NoWriteLock"),t.NoOp=Symbol("NoOp"),t.Contested=Symbol("Contested");class x extends f.EndableInterval{static for(e){return new x(e.db,e.fslock,e.libraryDbFile,e.libraryDbBackupDir)}constructor(e,t,i,o){super({name:"db.DbModelJanitor",callback:()=>l(this,r,"m",n).call(this),intervalMs:P.Settings.dbBackupIntervalMs.valueOrDefault,initialDelayMs:_.minuteMs,rank:m.EndableRanks.db,endTimeoutMs:5*_.minuteMs,onEnd:()=>l(this,r,"m",a).call(this)}),r.add(this),this.db=e,this.dbFslock=t,this.libraryDbFile=i,this.libraryDbBackupDir=o,this.logger=(0,d.mkLogger)(this.name),this.fslockRelease=new p.EndableWrapper("db.DbModelJanitor.fslockRelease",(()=>this.dbFslock.release()),m.EndableRanks.postdb,D),s.set(this,0),this.dbFslock.tryAcquire_()}get useReplica(){return!this.db.dbFile.eql(this.libraryDbFile)}forceBackup_(){return this.backup_(!0)}async backup_(e=!1){return await(0,S.withLock_)({file:this.libraryDbBackupDir,timeoutMs:5*_.minuteMs,noopIfContested:!e},(async()=>{if(e&&u(this,s,0,"f"),(0,k.hasDbSetupErrors)())return this.logger.warn("backup_(): db has setup errors, skipping backup",{errors:(0,k.dbSetupErrors)()}),t.NoOp;if(!await this.dbFslock.tryAcquire_())return this.logger.info("backup_(): no-op: someone else has the fslock",{me:this.dbFslock.lockfile?.base,owner:(await this.dbFslock.selfAndSiblingNames_())[0]}),t.NoWriteLock;l(this,r,"m",o).call(this)||await(0,T.runMaintenanceTasks)();const i=this.db.maxUpdatedAt();return null!=i&&i>l(this,s,"f")?(0,y.time)("db.DbModelJanitor.backup_()",(async()=>{l(this,r,"m",o).call(this)?this.logger.info("backup_(): posthaste: skipping vacuum"):await this.db.vacuum(),u(this,s,i,"f");const e=this.libraryDbBackupDir.join((0,v.filestamp)()),t=await this.db.backup_(e,!this.useReplica);return this.useReplica&&await(0,w.dbBackupCold_)(t,this.libraryDbFile.parent()),this.logger.info("backup_(): backup successful",{destDbFile:t}),t})):(this.logger.info("backup_(): no update to the db since last backup",{ago:(0,M.fmtDuration)(Date.now()-l(this,s,"f"))}),t.NoOp)}))??t.Contested}}t.DbModelJanitor=x,s=new WeakMap,r=new WeakSet,n=async function(){try{await this.backup_()}catch(e){this.logger.error("backup_() failed",{error:e})}},a=async function(){const e=S.FsLock.for({file:this.libraryDbFile.sibling("db-teardown"),timeoutMs:D,endableRank:m.EndableRanks.postdb,noopIfContested:!1});(0,h.isDbManager)()&&await e.withLock_((async()=>{if(await this.dbFslock.iAmOnly_({vacuum:!0})){if(this.logger.info("#teardown(): I'm the last one in. Running backup and cleanup."),await this.backup_(),this.useReplica){const e=[(0,E.libraryDbInfoFromDbFile)(this.libraryDbFile),...(0,b.sqliteFiles)(this.db.dbFile)];this.logger.info("#teardown(): Removing replica artifacts",{victims:e});for(const t of e)await t.unlink()}}else this.logger.info("#teardown(): no-op: other processes are still running")})),await this.db.closeDb()},o=function(){return this.ended||(0,g.ending)()||(0,c.isSuspended)()}},22526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelSetup_=t.assertValidDbInfo_=t.libraryDbInfoFromDbFile=t.libraryDbInfoJsonFile=t.fsLockForDb=t.libraryDbObjects_=void 0;const r=i(19851),s=i(50213),n=i(92407),a=i(55332),o=i(44955),l=i(15056),u=i(87290),c=i(98314),d=i(38835),h=i(73209),f=i(95696),m=i(17217),p=i(18454),g=i(57902),y=i(28874),v=i(2858),w=i(40958),b=i(22573),S=i(42659),P=i(94448),_=i(98348),M=i(45648),T=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbModelSetup")));function E(e=y.Settings.libraryDir.valueOrDefault){if((0,b.blank)(e))throw new Error("Library directory is not set"+d.NoLibraryErrorFlag);const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dataDir"+d.NoLibraryErrorFlag);if(!(0,v._libraryHasSettings)(e))throw new Error(`Library at ${e} does not have a settings file`+d.NoLibraryErrorFlag);const i=(0,l.pathToDb)(t,"models");return{dataDir:t,libraryDbFile:i,libraryDbBackupDir:(0,l.dbBackupDir)(i)}}function k(e){return h.FsLock.for({file:e,timeoutMs:0,noopIfContested:!1})}function D(e=y.Settings.libraryDir.valueOrDefault){const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dir"+d.NoLibraryErrorFlag);return x((0,l.pathToDb)(t,"models"))}function x(e){return e.sibling("db-info.json")}async function C(e=D(),t){try{const i=await e.readJson(g.LogLevels.info);if(null==i)throw new Error(e+" is missing"+d.DbSetupErrorFlag);if(null!=t&&!await t.equalsUri_(i.uri))throw new Error(e+" expects the live db to be "+i.uri+" but the live db is "+await t.uri_()+d.DbSetupErrorFlag);const r=await f.PosixFile.forUri(i.uri);if(null==r)throw new Error(e+" expects the live db to be "+i.uri+" but that URI cannot be resolved."+d.DbSetupErrorFlag);try{await(0,o.assertDirSQLiteReadWrite_)(r.parent())}catch(t){throw T().error("assertValidDbInfo_(): failed to assert live dir was r/w",{error:t,liveDbFile:r,infoJsonFile:e}),new Error("Failed to validate that the live database directory, "+r.dir+", was read-writable by SQLite: "+(0,c.errorToS)(t)+d.DbSetupErrorFlag)}return{liveDbFile:r}}catch(e){throw(0,M.addDbSetupError)(e),e}}t.libraryDbObjects_=E,t.fsLockForDb=k,t.libraryDbInfoJsonFile=D,t.libraryDbInfoFromDbFile=x,t.assertValidDbInfo_=C,t.dbModelSetup_=async function(e=y.Settings.libraryDir.valueOrDefault){const{libraryDbFile:t,fslock:i,libraryDbBackupDir:r}=await async function(e=y.Settings.libraryDir.valueOrDefault){const t=E(e);return{...t,fslock:k(t.libraryDbFile)}}((0,b.mapNotBlank)(e,m.toNativePath_));let s,o;await i.tryAcquire_();const u=x(t);try{if(await(0,h.withLock_)({file:u,timeoutMs:5*S.minuteMs},(async()=>{const i=await u.readJson(g.LogLevels.info);if(s=i?.useReplica,null!=i){const{liveDbFile:e}=await C(u,t);o=new _.Db(l.Schemas.models,e)}if(null==s||null==o){const i=await(0,n.getLiveDbDir_)(e),r=await i.db.uri_();s=i.useReplica,s&&await p.HealthCheck.traceLater_("Setting up local replica database",(0,a.dbBackupCold_)(t,i.db.parent())).catch((e=>T().throw("Failed to set up replica db"+d.DbSetupErrorFlag,{src:t,dest:i.db,error:e}))),o=new _.Db(l.Schemas.models,i.db),await u.writeJson_({uri:r,useReplica:s})}})),null==o||null==s)return T().throw("Failed to open model db"+d.DbSetupErrorFlag+d.InternalErrorFlag,{libraryDir:e});if(await i.tryAcquire_()){const e=await o.migrate_();s&&(e.repaired||(0,w.isNotEmpty)(e.appliedMigrations))&&await o.backup_(t.parent(),!s),(0,M.clearDbSetupErrors)()}P.modelDb.set(o)}catch(e){throw T().error("Failed to set up model db",{error:e}),(0,M.addDbSetupError)(e),i.release(),e}return T().tap({msg:"dbModelSetup()",result:{db:o,useReplica:s,libraryDbFile:t,libraryDbBackupDir:r,fslock:i}})}},86859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DbRequest=void 0;const r=i(54557),s=i(50213),n=i(99331),a=i(56038),o=i(65753),l=i(66184),u=i(70417),c=i(28874),d=i(40958),h=i(22573),f=i(45599),m=i(96249),p=i(31586),g=i(51926),y=i(57038),v=i(21074),w=(0,f.defer)((()=>(0,s.mkLogger)("db.DbRequest")));t.DbRequest=class{constructor(e,t){this.db=e,this.tableName=t,this.cachedStatements=new r.FifoCache(256)}qb(){return(0,y.knex)()(this.tableName)}prep(e,t=!1){const i=(0,v.toSqlQuery)(e);try{const r=this.cachedStatements.getOrSet(this.db().db.__uid+":"+(!0===t?"pluck:":"")+i.sql,(()=>{const e=this.db().prepare(i.sql);return!0===t?e.pluck():e}));return r.database.open?{sq:i,stmt:r}:(this.cachedStatements.clear(),this.prep(e,t))}catch(e){return w().throw("prep() failed",{error:e,sqlQuery:i,retriable:!1})}}wrap({q:e,pluck:t,m:i}){try{const{sq:r,stmt:s}=this.prep(e,t);c.Settings.logSql.valueOrDefault&&w().log((0,l.defaultLogLevel)(),i+"(): "+(0,v.sqlQueryToS)(r));const n=s[i].bind(s);return null==r.bindings?n():n(r.bindings)}catch(t){if(!0===t.message?.includes("AdvisoryLock"))throw t;w().throw(t,{method:i,...(0,v.toSqlQuery)(e)})}}run(e){return this.wrap({q:e,m:"run"})}runScript(e,t=""){const i=(0,a.mkElapsed)("db.runScript()");for(const r of e){if((0,h.blank)(r)||r.trim().startsWith("--"))continue;this.run({sql:r});const e=(0,g.replaceAll)((0,g.ellipsize)(r,60),t,"");i.elapsed(e)}}mapRun(e){return e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return null==t.bindings?i.run():i.run(t.bindings)}))}runf(e){return this.wrap({q:e(this.qb()),m:"run"})}upsert(e){const t=(0,v.toSqlQuery)(e(this.qb()));return t.sql=t.sql.replace(/^(?:update|insert)\b/i,(e=>e.toUpperCase()+" OR REPLACE ")),this.wrap({q:t,m:"run"})}first(e){return this.wrap({q:e,m:"get"})}firstf(e){return this.wrap({q:e(this.qb()),m:"get"})}mapAll(e){return(0,m.flatten)(e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return i.all(t.bindings)})))}all(e){return this.wrap({q:e,m:"all"})}allf(e){return this.wrap({q:e(this.qb()),m:"all"})}async batched(e){let t,i=0;do{t=this.wrap({q:e.qb(this.qb(),t).limit((0,o.maxBatchPluckSize)()),m:"all"}),(0,d.isNotEmpty)(t)&&(await e.onResults(t),i+=t.length)}while((0,d.isNotEmpty)(t)&&!(0,n.ending)()&&(null==e.maxResults||e.maxResults>i));return{resultCount:i,done:null==t||t.length<(0,o.maxBatchPluckSize)()}}pluckFirst(e){return this.wrap({q:e,pluck:!0,m:"get"})}pluckFirstf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"get"})}pluckAll(e){return this.wrap({q:e,pluck:!0,m:"all"})}pluckAllf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"all"})}async pluckBatched(e){let t=0;const i=(0,u.min)([e.limit??(0,o.maxBatchPluckSize)(),e.maxResults]);if(i<=0||(0,p.lte0)(e.maxResults))return{done:!1,resultCount:t};let r;for(;null==e.maxResults||e.maxResults<=0||t(0,o.mkLogger)("db.DbSchemaValid")));function y(e){return l.PosixFile.for(s.default.join(u.ProjectPath.Data(),e+"-schema.json"))}t.schemaJsonFile=y,t.assertValidDbSchema_=async function(e){try{await e.migrate_();const t=(0,p.localTableInfo)(e.db),i=t.map((e=>e.tableName)),r=(await y(e.schema).readJson_()).tableInfo;{const e=r.map((e=>e.tableName)),t=(0,c.diff)(e,i);(0,c.isNotEmpty)(t)&&g().throw("Db is missing "+(0,f.plur)(t.length,"table")+" : "+(0,h.andList)(t))}for(const e of t){const t=r.find((t=>t.tableName===e.tableName));if(null==t)g().warn("Unexpected table in db",e);else{const i=(0,n.diffEql)(t.columns,e.columns);(0,c.isNotEmpty)(i)&&g().throw("Db is missing "+(0,f.plur)(i.length,"column")+" from table "+e.tableName+" : "+(0,h.andList)(i.map((e=>e.name))))}}g().info("Validated schema.",{from:(0,d.shortStack)()})}catch(e){throw(0,m.dbModelHealthCheck)().reset(),e}},t.writeSchemaJsonFile_=function(e,t){return y(e).writeJson_({info:"This is used in validating PhotoStructure library databases after repair and restore operations.",tableInfo:(0,p.localTableInfo)(t)},{spaces:2})}},45648:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDbSetupErrorListener=t.hasDbSetupErrors=t.clearDbSetupErrors=t.addDbSetupError=t.dbSetupErrors=t._dbSetupErrors=void 0;const r=i(98314),s=i(22573),n=i(23541);t._dbSetupErrors=new Set;const a=[];t.dbSetupErrors=function(){return[...t._dbSetupErrors.values()]},t.addDbSetupError=function(e){if((0,n.isError)(e)||!(0,s.blank)(e)){t._dbSetupErrors.add((0,r.errorToS)(e));for(const e of a)e()}},t.clearDbSetupErrors=function({notifyListeners:e=!0}={}){if(t._dbSetupErrors.clear(),e)for(const e of a)e()},t.hasDbSetupErrors=function(){return t._dbSetupErrors.size>0},t.addDbSetupErrorListener=function(e){a.push(e)}},36908:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dedupeTags_=t.mergeTags_=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(42231),o=i(40958),l=i(76790),u=i(23838),c=i(31586),d=i(54993),h=(0,r.lazy)((()=>(0,s.mkLogger)("db.DedupeTags")));function f(e,t){function i(t){return e.prepare(t).run()}(0,o.isEmpty)(t)&&h().warn("mergeTags(): empty tagIds",{tagIds:t}),h().info("mergeTags() starting",{tagIds:t});const r=e.prepare("SELECT id, _path, parentId FROM Tag WHERE id IN ("+t.join(",")+") ORDER BY ID").all(),s=(0,o.compactBlanks)(r.map((e=>(0,a.tagPathLeaf)(e._path))).sort()),n=r[0],l=r.slice(1),u=n?.id;if((0,o.isEmpty)(s)||(0,o.isEmpty)(l)||null==n||!(0,c.gt0)(u))return void h().warn("mergeTags(): missing winner",{winner:n,winnerId:u,leafs:s,losers:l});const d=(0,a.splitTagPath)(n._path).slice(0,-1),f=[...d,s[0]];n._path=(0,a.joinTagPath)(f),n.parentId=0===d.length?null:e.prepare("SELECT id from Tag where _path LIKE ?").pluck().get((0,a.joinTagPath)(d))??n.parentId,h().info("mergeTags()",{winner:n,losers:l,winnerTagPath:f,leafs:s});const m=l.map((e=>e.id)).join(",");i(`UPDATE OR IGNORE AssetTag SET tagId = ${u} WHERE tagId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`DELETE FROM AssetTag WHERE tagId in (${m})`),i(`DELETE FROM Tag WHERE id in (${m})`),e.prepare("UPDATE Tag SET parentId = :parentId, _path = :path WHERE id = :id").run({parentId:n.parentId,path:n._path,id:u});const p=e.prepare("SELECT id, _path FROM Tag WHERE id != :winnerId AND _path LIKE :like COLLATE NOCASE").all({winnerId:u,like:n._path+"%"});for(const t of p){const i=(0,a.splitTagPath)(t._path).slice(f.length),r=(0,a.joinTagPath)([...f,...i]);t._path!==r&&(h().info("mergeTags(): repairing tag path",{ea:t,newPath:r}),e.prepare("UPDATE OR IGNORE Tag SET _path = :path, updatedAt = :updatedAt WHERE id = :id").run({id:t.id,updatedAt:Date.now(),path:r}))}return h().tap({msg:"mergeTags()",level:"info",result:{winner:n,losers:r}})}t.mergeTags_=f,t.dedupeTags_=function(e){const t=new u.MultiMap;for(const{id:i,_path:r}of e.prepare("SELECT id, _path FROM Tag ORDER BY id").iterate())t.add((0,n.stripSuffix)((0,d.toS)(r).trim(),a.TagSep).toLowerCase().normalize(),i);const i=(0,l.sortBy)(t.entriesArray().filter((([,e])=>e.length>1)),(([e])=>[-(0,n.countChars)(e,a.TagSep),-e.length,e]));for(const[,t]of i)f(e,t)}},57038:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstMigratedAt=t.knex=void 0;const s=r(i(31832)),n=i(19851),a=i(56519),o=i(55835),l=i(68708);t.knex=(0,n.lazy)((()=>(0,s.default)({client:"better-sqlite3",useNullAsDefault:!0}))),t.firstMigratedAt=async function(e){return(0,a.thenMap)(e("migrations").min("migration_time").first(),(e=>(0,o.map)((0,l.values)(e)[0],(e=>new Date(e)))))}},17036:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Migration=void 0;const o=i(77598),l=i(19851),u=i(50213),c=i(7282),d=i(37805),h=i(4867),f=i(51040),m=i(77740),p=i(38835),g=i(8769),y=i(57159),v=i(34102),w=i(73209),b=i(95696),S=i(43899),P=i(18454),_=i(40958),M=i(42659),T=i(41400),E=i(98553),k=i(55835),D=i(34666),x=i(32639),C=i(45648),F=i(94715),A=i(27134);t.Migration=class{constructor(e,t,i){r.add(this),this.schema=e,this.db=t,this.dbFile=i,this.fsMigrations_=(0,l.lazy)((()=>this.migrationsDir.children_((e=>e.isFile&&e.basename.endsWith(".sql"))).catch((e=>this.logger.throw("Failed to read migration directory, "+this.migrationsDir+p.InternalErrorFlag,{error:e}))))),this.ensureMigrationTable_=(0,l.lazy)((()=>{this.db.exec("\nCREATE TABLE IF NOT EXISTS migrations (\n id INTEGER NOT NULL PRIMARY KEY,\n name TEXT NOT NULL,\n migration_time INTEGER NOT NULL\n) STRICT\n")})),this.unknownMigrations_=(0,l.lazy)((()=>this.migrationsInDatabase_().filter((e=>!(0,D.lt)((0,F.migrationNameToDate)(e),d.gitDate))))),this.assertKnownMigrations_=(0,l.lazy)((()=>{const e=this.unknownMigrations_();if((0,_.isNotEmpty)(e)){const t=new y.WrappedError("Please upgrade PhotoStructure to a newer version to open this library: Unknown migrations: "+e.join(","));throw(0,g.onError)(t),t}})),this.logger=(0,u.mkLogger)("db.Migration("+(0,E.stringify)({schema:e,db:i.nativePath})+")"),this.migrationsDir=b.PosixFile.for(S.ProjectPath.Migrations()).join(this.schema)}async pendingMigrationFiles_(){const e=this.migrationsInDatabase_();return(await this.fsMigrations_()).filter((t=>!e.includes(t.name)))}migrationsInDatabase_(){return this.ensureMigrationTable_(),this.db.prepare("SELECT name from migrations").pluck().all()}async apply_(e){return(0,w.withLock_)({file:this.dbFile.sibling("migrate"),timeoutMs:2*M.minuteMs},(()=>a(this,r,"m",s).call(this,e)))}async applyMigration_(e,t){try{const i=Date.now(),s=F.Migrations[e.name.replace(/^[\d_-]+/,"")],o=(0,x.isFunction)(s);return o?await s.bind(F.Migrations)(this.db):await a(this,r,"m",n).call(this,e),this.logger.debug("applyMigration() completed",{elapsedMs:Date.now()-i,codeMigration:o,migration:e.baseWithParent}),t?.run(e.name,Date.now())}finally{(0,v.ee)().emit("clearDbCache")}}},r=new WeakSet,s=async function(e){try{this.ensureMigrationTable_(),(0,c.isProd)()&&this.assertKnownMigrations_();const t=[],i=this.db.prepare("INSERT INTO migrations (name, migration_time) VALUES (?, ?)");for(const r of await this.pendingMigrationFiles_())await P.HealthCheck.traceLater_("Upgrading database ("+r.name+")",(async()=>{if((0,m.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");(0,m.getDevEnvFlag)("PS_SLOMO")&&await(0,T.delay)((0,o.randomInt)(M.secondMs,3*M.secondMs)),await(0,k.map)(e,(e=>e(r))),await(0,h.thenOrTimeoutError)({p:this.applyMigration_(r,i),timeoutMs:M.minuteMs}).catch((e=>{throw new y.WrappedError("Migration "+r.name+" timed out.",{cause:e,fatal:!0,ignorable:!1})}))})),t.push(r.base);return this.logger.info("Migration complete",{appliedMigrations:t}),t}catch(e){const t=new y.WrappedError("Migrating the "+this.schema+" db failed",{cause:e});throw(0,C.addDbSetupError)(t),P.HealthCheck.addError(t),t}},n=async function(e){const t=e.name.includes("_nofk");try{const i=await e.readTextFile(),r=(0,f.splitBatchSql)(i);if((0,_.isEmpty)(r))this.logger.info("No-op migration: "+e);else{t&&this.db.pragma("foreign_keys = OFF");for(const t of r)try{this.db.exec(t)}catch(i){this.logger.throw("Failed to apply SQL",{stmt:t,migration:e.baseWithParent,cause:i,fatal:!0})}t&&(0,A.foreignKeyCheck_)(this.db)}}finally{t&&this.db.pragma("foreign_keys = ON")}}},94715:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Migrations=t.isoToPrecisionMs=t.fix_root_tags=t.tag_path_suffix=t.migrationNameToDate=t.plucklabmodeb6=t.lowercase_psnet_function=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(97352),o=i(68852),l=i(81168),u=i(85810),c=i(42022),d=i(1971),h=i(79842),f=i(89724),m=i(17415),p=i(88600),g=i(20014),y=i(42231),v=i(87001),w=i(40958),b=i(55835),S=i(31586),P=i(97790),_=i(89937),M=i(54993),T=i(7656),E=i(36908),k=(0,s.lazy)((()=>(0,n.mkLogger)("db.Migrations"))),D=new RegExp(`^(${(0,o.escapeRegExp)(_.PS_NETWORK_FILESYSTEM_SCHEME)}://.*?/)(.*)$`);function x(e,t){return(0,a.mapGt0)(e,(()=>(0,b.map)(function(e,t=c.ModeBits){return(0,g.splitBits)(e,t).map((e=>(0,u.unlabhash)(e,t)))}(e,6)[t],(e=>(0,u.toLabhash)(e,c.ModeBits)))))}function C(e){return e.endsWith(y.TagSep)?e:e+y.TagSep}function F(e){for(const t of e.prepare("SELECT id, parentId, _path FROM Tag WHERE id = parentId").iterate())k().warn("fix_root_tags(): broken tag",{broken:t}),(0,l.countChars)(t._path,y.TagSep)<2&&e.prepare("UPDATE Tag set parentId = null where id = ?").run(t.id)}function A(e){return(0,b.map)((0,h.isoToDated)(e),h.datedToPrecisionMs)??-1}t.lowercase_psnet_function=e=>(0,P.opt)(e).filter(l.isString).flatMap((e=>D.exec(e))).map((e=>e[1].toLowerCase()+e[2])).getOrElse((()=>e)),t.plucklabmodeb6=x,t.migrationNameToDate=function(e){const[t,i,r]=[e.slice(0,4),e.slice(4,6),e.slice(6,8)].map((e=>(0,S.toInt)(e)));return(0,p.validYMD)(t,i,r)?new Date(t,i-1,r):void 0},t.tag_path_suffix=C,t.fix_root_tags=F,t.isoToPrecisionMs=A,t.Migrations={fix_root_tags:F,lowercase_psnet_hostname:e=>{e.function("lowercase_psnet_hostname",{deterministic:!0},t.lowercase_psnet_function),e.exec("DROP INDEX IF EXISTS assetfile_uri_udx"),e.exec("UPDATE AssetFile SET uri = lowercase_psnet_hostname(uri)"),e.exec("CREATE UNIQUE INDEX assetfile_uri_udx ON AssetFile(uri)")},numeric_captured_at:e=>{e.function("isoToLocal",{deterministic:!0},f.isoToLocal),e.function("isoToOffsetMinutes",{deterministic:!0},m.isoToOffsetMinutes),e.function("isoToPrecisionMs",{deterministic:!0},A),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtLocal bigint"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtOffset integer"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtPrecisionMs integer"),e.exec("UPDATE AssetFile SET capturedAtLocal = isoToLocal(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtOffset = isoToOffsetMinutes(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtPrecisionMs = isoToPrecisionMs(capturedAtISO)"),e.exec("DROP INDEX asset_captured_at_geohash_idx"),e.exec("DROP INDEX assetfile_exifuid_idx"),e.exec("CREATE INDEX assetfile_capturedAtLocal_idx ON AssetFile(capturedAtLocal)")},spread_modes:e=>{e.function("plucklabmodeb6",{deterministic:!0},x),(0,S.times)(d.ModeCount,(t=>e.exec(`ALTER TABLE AssetFile ADD COLUMN mode${t} integer`))),e.exec("UPDATE AssetFile SET "+(0,S.times)(d.ModeCount,(e=>`mode${e} = plucklabmodeb6(mode8b6, ${e})`)).join(", "))},normalize_asset_file_uris:e=>{e.function("normalizeURI",{deterministic:!0},v.normalizeURI);const t=e.prepare("SELECT normalizeURI(uri) AS nuri, count(*) AS cnt, GROUP_CONCAT(id) AS ids FROM AssetFile GROUP BY nuri HAVING cnt > 1").all(),i=[];for(const s of t){const t=(0,M.toS)(s.ids).split(","),n=e.prepare("SELECT id, shown, version, updatedAt FROM AssetFile WHERE id in ("+t.join(",")+")").all(),a=(0,r.greatestBy)(n,(e=>[e.shown,e.version,e.updatedAt])),o=n.filter((e=>e.id!==a?.id));i.push(...o.map((e=>e.id)))}for(const t of(0,r.batches)(i,256))e.exec("DELETE FROM AssetFile WHERE id in ("+t.join(",")+")");e.exec("UPDATE AssetFile SET uri = normalizeURI(uri)")},dedupe_tag_paths:E.dedupeTags_,suffix_tag_paths:e=>{e.function("tag_path_suffix",{deterministic:!0},C),(0,E.dedupeTags_)(e),e.exec("UPDATE Tag SET _path = tag_path_suffix(_path)")},normalize_tag_paths:e=>{const t=e.prepare("SELECT id, _path FROM Tag WHERE _path LIKE '%' || char(31) || char(31) || '%'").all();k().info("normalize_tag_paths():",{badTags:t});for(const i of t){const t=(0,y.normalizeTagPath)(i._path);(0,E.mergeTags_)(e,(0,w.compact)([i.id,...e.prepare("SELECT id FROM Tag WHERE _path LIKE ?").pluck().all(t)]))}},drop_tc_tables:e=>{const t=/^(ct|taf|tag_counts)_[a-z\d]{6}$/i,i=e.prepare("SELECT name FROM sqlite_master WHERE type='table'").pluck().all(),r=i.filter((e=>null!=t.exec(e)));k().info("drop_tc_tables()",{tables:i,victims:r});for(const t of r)e.exec("DROP TABLE "+t)},rebuild_rotated_heic:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype = 'image/heif' AND rotation <> 0")},rebuild_videos:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%'"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where mimetype LIKE 'video/%')")},copy_asset_duration:e=>{e.exec("CREATE INDEX tmp_af_idx ON AssetFile (assetId, durationMs)"),e.exec("UPDATE Asset SET durationMs = (SELECT durationMs FROM AssetFile WHERE assetId = Asset.id AND durationMs IS NOT NULL LIMIT 1) WHERE durationMs IS NULL"),e.exec("DROP INDEX tmp_af_idx"),e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%' and durationMs IS NULL"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where version = 0)")},rebuild_tag_asset_counts:T.rebuildTagAssetCounts,create_tag_fts:e=>{e.exec("DROP TABLE IF EXISTS tag_fts"),e.exec("CREATE VIRTUAL TABLE tag_fts USING fts5 (root, path, content='', contentless_delete=1, tokenize=\"unicode61\");")}}},27134:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.repairDbFile_=t.checkpoint_=t.verifyDbFile_=t.verifyDb_=t.foreignKeyCheck_=t.integrityCheck_=t.quickCheck_=t.backupDbFile_=t.sqlite=void 0;const r=i(14121),s=i(19851),n=i(50213),a=i(84777),o=i(12959),l=i(5531),u=i(91872),c=i(99315),d=i(76187),h=i(51040),f=i(38835),m=i(57159),p=i(29882),g=i(95696),y=i(89966),v=i(38156),w=i(28874),b=i(63870),S=i(5233),P=i(42659),_=i(41400),M=i(50357),T=i(98553),E=i(56409),k=i(31586),D=i(20214),x=i(51926),C=i(12168),F=i(59455),A=i(54993),I=i(94448),O=i(9508),L=(0,s.lazy)((()=>(0,n.mkLogger)("db.SQLite")));function R({db:e,pragma:t,okResult:i}){L().debug("pragmaOrThrow_()",{db:N(e),db_open:e?.open,pragma:t,okResult:i});const r=(0,x.isString)(i)?e.pragma(t,{simple:!0}):e.pragma(t);(0,M.eql)(r,i)||L().throw(`${t} failed for ${N(e)}: ${(0,T.stringify)({result:r})}`)}function N(e){return(0,p.ellipsizePath)({p:e.name,maxLength:80})}function B(e){return R({db:e,pragma:"quick_check",okResult:"ok"})}function j(e){return R({db:e,pragma:"integrity_check",okResult:"ok"})}function z(e){const t=(0,F.toA)(e.pragma("foreign_key_check"));t.length>w.Settings.dbInvalidFKThreshold.valueOrDefault&&L().throw("foreignKeyCheck_(): too many invalid foreign keys to repair",{dbInvalidForeignKeyThreshold:w.Settings.dbInvalidFKThreshold.valueOrDefault,badRowsCount:t.length,badRows:t});for(const i of t)L().warn("repairDbFile_(): deleting row with invalid foreign key",{row:i}),e.prepare(`DELETE FROM ${(0,h.dbValueToEscapedString)(i.table)} WHERE rowid = ?`).run(i.rowid)}async function V(e){await(0,u.handleDbRetries_)("db.quickCheck",e,B),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.integrityCheck",e,j),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.foreignKeyCheck",e,z)}function W(e){return(0,O.withDbSync)(e,V,(0,b.commandTimeoutMs)())}t.sqlite=async function({dbFile:e,sql:t,args:i}){const s=await(0,y.sqliteNativePath_)(),n=await(0,r.thenElapsed)((0,a.stdout_)(s,[...(0,F.toA)(i),e.nativePath,t],{timeoutMs:1*P.minuteMs}));return L().debug("sqlite("+t+") on "+e+" in "+n.elapsedMs+"ms",n.result),n.result},t.backupDbFile_=function(e,t){return(0,S.retryOnReject_)((()=>async function(e,t){try{await t.parent().mkdirp_(),await t.unlink("trace");const i=await e.size();if(!(0,k.gt0)(i))return void L().warn("backupDbFile_(): "+e+" is empty");await((0,I.modelDb)()?.end()),await(0,O.withDb)(e,(async e=>e.exec("VACUUM INTO "+(0,h.dbValueToEscapedString)(t.nativePath))),2*P.minuteMs),L().info("backupDbFile_(): Finished "+e+" -> "+t)}catch(i){throw new m.WrappedError(`Could not back up db ${e} -> ${t}`,{cause:i})}}(e,t)),{maxRetries:3,retryDelay:P.secondMs,timeoutMs:P.minuteMs,errorIsRetriable:()=>!0})},t.quickCheck_=B,t.integrityCheck_=j,t.foreignKeyCheck_=z,t.verifyDb_=V,t.verifyDbFile_=W,t.checkpoint_=async function e({db:t,retries:i=3,checkpointType:r=w.Settings.dbWalCheckpointType.valueOrDefault}){if((r=l.CheckpointTypes.getCI(r)??l.CheckpointTypes.AUTO)===l.CheckpointTypes.AUTO)return;const s="wal_checkpoint("+r+")",[n]=(0,F.toA)(t.pragma(s));return L().info("checkpoint()",{pragma:s,result:n}),(0,k.gt0)(n?.busy)&&i>0?(await(0,_.delay)(250),e({db:t,retries:i-1})):n};const U=/no such table: sqlite_\w+/i;t.repairDbFile_=async function(e,t=c.RepairModes.dump){const i=g.PosixFile.for(e),r=(await i.parent().join("db-"+t,(0,o.filestamp)()).mkdirp_()).join(i.base);L().info(`repairDbFile_(${i} -> ${r})`);try{const e=await(0,y.sqliteNativePath_)(),s=4*Math.min(20*C.MiB,await(0,d.sqliteSizeBytes)(i)),n=new v.PushProgressObserver({path:(0,A.toS)(i),op:"Repairing your database"},s),o=new E.Latch,l=(0,a.execFile)(e,[i.nativePath,"."+t],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});l.stdout.on("error",(e=>{const i=(0,A.toS)(e);U.test(i)?L().info("repairDbFile_(): ignoring stderr",{err:i}):o.reject(new Error("sqlite "+t+" failed: "+i))}));const u=(0,a.execFile)(e,[r.nativePath],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});u.on("exit",(()=>o.resolve())),l.stdout.on("end",(()=>{u.stdin.end(null)})),l.stdout.on("data",(e=>{const t=e.length;n.incrProgress(t),u.stdin.write(e)})),await o,L().info(`repairDbFile_(): recovered to ${r}.`),await W(r),L().info(`repairDbFile_(): ${r} is valid, finishing repair.`);const c=await(0,D.thenCollect)((0,d.sqliteFiles)(i),(e=>e.renameYMDHMS_({subdir:"needed-repair"})));return await(0,D.thenCollect)((0,d.sqliteFiles)(r),(e=>e.mv_(i.parent()))),c.find((e=>".db"===e.ext||e.ext.startsWith(".sqlite")))}catch(e){return L().throw("failed to recover DB via dump and restore. Please see https://photostructure.com/faq/restore-db-from-backup/ "+f.FatalErrorFlag,{error:e})}}},21074:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqlWhereInClause=t.isQueryBuilder=t.sqlQueryToS=t.toSqlQuery=t.isSqlQuery=void 0;const r=i(48884),s=i(68852),n=i(81168),a=i(12943),o=i(96249),l=i(98553),u=i(31586),c=i(68708),d=i(32639),h=i(54993);function f(e){return null!=e&&(0,n.isString)(e.sql)&&(null==e.bindings||(0,a.isDbValued)(e.bindings))}t.isSqlQuery=f,t.toSqlQuery=function(e){if(null==e)throw new Error("null sql");if(f(e))return e;if((0,n.isString)(e))return{sql:e};if((0,d.isFunction)(e.toSQL))return(0,c.omit)(e.toSQL(),"__knexQueryUid");throw new Error("not queryish: "+(0,l.stringify)(e))},t.sqlQueryToS=function(e){if(null==e.bindings)return e.sql;if(Array.isArray(e.bindings))return(0,o.flatten)((0,r.zip)(e.sql.split("?"),e.bindings.map((e=>(0,l.stringify)(e))))).join("");{let t=e.sql;for(const i of(0,c.keys)(e.bindings))t=t.replace(new RegExp("[@:$]"+(0,s.escapeRegExp)(i),"gi"),(0,h.toS)(e.bindings[i]));return t}},t.isQueryBuilder=function(e){return(0,d.isFunction)(e?.where)&&(0,d.isFunction)(e?.limit)},t.sqlWhereInClause=function(e){return"("+(0,u.times)(e,(()=>"?")).join(",")+")"}},35052:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localTableInfo=t.parseTableInfo=void 0;const r=i(22573),s=i(23838);function n(e){const t=new s.MultiMap;for(const i of e)i.tableName.includes("fts")||i.tableName.includes("sqlite_")||(0,r.blank)(i.name)||(0,r.blank)(i.type)||t.add(i.tableName,{name:i.name,type:i.type.toUpperCase().trim().replace(/\s+/g,""),notnull:1===i.notnull,pk:1===i.pk});return t.entriesArray().map((([e,t])=>({tableName:e,columns:t})))}t.parseTableInfo=n,t.localTableInfo=function(e){return n(e.prepare("SELECT \nm.tbl_name as tableName,\np.*\nFROM sqlite_master AS m\nJOIN pragma_table_info(m.name) AS p\nORDER BY m.tbl_name, p.cid").all())}},9508:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withDb=t.withDbSync=void 0;const r=i(80632),s=i(28874),n=i(30301),a=i(54993);t.withDbSync=function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const o=(0,n.lazy)((()=>(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i})));try{return t((function(){const e=o();return e.open?e:o.refresh()}))}finally{o.prior()?.close()}},t.withDb=async function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const n=(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i});try{return await t(n)}finally{n.close()}}},74085:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelHealthCheck=void 0;const r=i(77740),s=i(98314),n=i(18454),a=i(28874),o=i(82950),l=i(42659),u=i(45599),c=i(64526),d=i(16185),h=i(45648),f=i(31687),m={text:"Attempt database repair",title:"Run a dump and reload of your library database to try to repair it",type:"button",method:"POST",url:"/admin/repair-db",icon:"database"};t.dbModelHealthCheck=(0,u.defer)((()=>{const e=n.HealthCheck.for({section:"Library",id:"library-db",ordinal:1,pendingMsg:"Checking library database…",settings:["libraryDir","forceLocalDbReplica"],timeoutMs:()=>10*a.Settings.dbMaintenanceTimeoutMs.valueOrDefault,ttlMs:l.minuteMs,onReset:()=>(0,h.clearDbSetupErrors)({notifyListeners:!1}),links:[{text:"Read about PhotoStructure and SQLite",icon:"docs",url:"https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837"}],later:async()=>{const e=await(c.Library.instance()?.ready);if(null==e)return{level:"disabled",msg:["Library database tests disabled: no library is open"]};let t,i=!1;try{const s=Date.now();if(i=!1,(0,h.hasDbSetupErrors)())return{level:"error",msg:["Something is wrong with your library database.",(0,o.li)((0,h.dbSetupErrors)())],links:[m]};if(t=await e.modelDb(),(0,r.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");await(0,d.assertValidDbSchema_)(t),i=!0,await t.verify_(),await t.vacuum(),f.Heartbeat.assertPing_();const n=await e.dbModelSetup_();return{level:"ok",msg:["Library database is OK",(0,o.li)(["Schema validation, vacuum, optimize, and upsert round-trip took "+(Date.now()-s)+"ms","Live db is "+(0,o.tt)(t.dbFile.nativePath),"Local replica mode is "+(0,o.tt)(n.useReplica),n.useReplica?"Cold library db is "+(0,o.tt)(n.libraryDbFile):void 0])]}}catch(r){return{level:"error",msg:["Library database validation failed",(i?"":"Unrecoverable: ")+(0,s.errorToS)(r),null==t?void 0:"Live db is "+(0,o.tt)(t.dbFile.nativePath),null==e?void 0:"Local replica mode is "+(0,o.tt)(await e.useReplica())],links:i?[m]:void 0}}}});return(0,h.addDbSetupErrorListener)((()=>e.refresh())),e}))},8400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryHealthCheckSetup=void 0;const r=i(19851),s=i(88625),n=i(2858),a=i(74085),o=i(1991),l=i(40549);t.libraryHealthCheckSetup=(0,r.lazy)((async()=>{await(0,n.readSettings)(),(0,s.healthCheckSetup)(),(0,o.syncHealthCheck)(),(0,a.dbModelHealthCheck)(),(0,l.volumeUuidHealthCheck)()}))},1991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syncHealthCheck=void 0;const r=i(48884),s=i(50213),n=i(95696),a=i(62105),o=i(18454),l=i(2858),u=i(40958),c=i(82950),d=i(45599),h=i(94019),f=(0,d.defer)((()=>(0,s.mkLogger)("health.SyncHealthCheck")));t.syncHealthCheck=(0,d.defer)((()=>o.HealthCheck.for({section:"Library",id:"library-nothing-to-sync",ordinal:99,settings:["scanAllDrives","scanPaths","scanLibraryFirst","scanLibraryLast"],pendingMsg:"Checking synced directories…",later:async()=>{if(!(0,l.libraryHasSettings)())return{level:"disabled",msg:"Library sync paths test disabled: no library is open"};const e=(await(0,h.pathsToSync)()).map((e=>e.nativePath));if((0,u.isEmpty)(e))return{level:"warn",msg:"No paths are configured to scan\n"+(0,c.li)([(0,c.tt)("PS_SCAN_ALL_DRIVES")+" is false",(0,c.tt)("PS_SCAN_PATHS")+" is empty","both "+(0,c.tt)("PS_SCAN_LIBRARY_FIRST")+" and "+(0,c.tt)("PS_SCAN_LIBRARY_LAST")+" are false"]),links:[{text:"Read more",url:"https://photostructure.com/go/nothing-to-scan"}]};{const t=e.map((e=>n.PosixFile.for(e)));return f().info("Checking if any paths are empty",{posixFiles:t}),null==await(0,r.findAsync)(t,(async e=>null!=await e.someDescendant((e=>e.isDirectorySync()||(0,a.acceptParentAndFileAndSimple)(e)),1)))?{level:"warn",msg:["No eligible files found in scanned paths","Checked paths:",(0,c.li)(e.map(c.tt))],links:[{text:"Read more",url:"https://photostructure.com/go/nothing-to-scan"}]}:{level:"ok",msg:["At least one directory with eligible files is configured to be synced","Checked paths:",(0,c.li)(e.map(c.tt))]}}}})))},40549:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeUuidHealthCheck=void 0;const r=i(50213),s=i(56519),n=i(18454),a=i(28874),o=i(2858),l=i(85087),u=i(63870),c=i(86848),d=i(7014),h=i(40958),f=i(82950),m=i(45599),p=i(57924),g=i(23838),y=i(68708),v=i(94019),w=(0,m.defer)((()=>(0,r.mkLogger)("health.VolumeUUIDHealthCheck")));t.volumeUuidHealthCheck=(0,m.defer)((()=>n.HealthCheck.for({section:"Library",id:"volume-uuids",pendingMsg:"Checking volumes…",settings:["scanAllDrives"],links:[{text:"What's a “volume”?",url:"https://photostructure.com/faq/what-is-a-volume/",icon:"docs"}],later:async()=>{if(!(0,o.libraryHasSettings)())return{level:"disabled",msg:"Volume UUID test disabled: no library is open"};const e=[],t=[];if(a.Settings.scanAllDrives.valueOrDefault)e.push(...await(0,d.volumes)());else{const i=await(0,v.scanPaths)(),r=await(0,s.mapAsyncSerial)({name:"scannedVolumes",arr:i.result.map((e=>e.nativePath)),f:e=>(0,d.bestVolumeForPath)(e),timeoutMs:(0,u.commandTimeoutMs)()});e.push(...(0,h.uniqBy)(r,(e=>e.mountpoint))),t.push(...i.noUriPaths)}const i=[...(0,g.groupBy)(e,(e=>e.uuid)).values()].filter((e=>e.length>1)),r=e.filter((e=>null==e.uuid&&!(0,c.volumeUuidNotExpected)(e))).map((e=>e.mountpoint)),n=(await(0,d.volumes)()).filter((e=>!1===e.ok)).map((e=>(0,h.compactBlanks)([e.mountpoint,e.status]).join(": ")));if(w().debug("volumeHealthCheck result",{missingUUIDs:r,noUriPaths:t,unhealthyVolumes:n,scannedVolumes:e.map((e=>(0,y.pick)(e,"uuid","mountpoint")))}),(0,h.isEmpty)(r)&&(0,h.isEmpty)(i)&&(0,h.isEmpty)(t)&&(0,h.isEmpty)(n))return(0,h.isEmpty)(e)?{msg:["No volumes need UUIDs",(0,f.tt)(a.Settings.scanAllDrives.key)+" is false, and no volumes other than the library are configured to be scanned."],level:"ok"}:{msg:["All scanned volume UUIDs are OK",(0,f.li)(e.map((e=>(0,f.tt)((0,l.volsha)(e.uuid)+" → "+e.mountpoint))))],level:"ok"};{const e=[];return(0,h.isEmpty)(n)||e.push("Some volumes are unhealthy",(0,f.li)(n.map((e=>(0,f.tt)(e))))+"PhotoStructure may crash or hang when accessing unhealthy volumes."),(0,h.isEmpty)(r)||e.push("Some volumes are missing UUIDs",(0,f.li)(r.map((e=>(0,f.tt)(e)))),"This can cause problems with deduplication and library portability."),(0,h.isEmpty)(i)||e.push("Some volumes have duplicate UUIDs",i.map((e=>(0,f.li)((0,p.andList)(e.map((e=>(0,f.tt)(e.mountpoint))))+" share UUID "+(0,f.tt)(e[0].uuid)))).join("\n---\n"),"This can cause problems with deduplication and library portability."),(0,h.isEmpty)(t)||e.push("Some paths failed to have URIs generated",(0,f.li)(t.map((e=>(0,f.tt)(e)))),"This will prevent these paths from being imported."),{level:"warn",msg:e.join("\n---\n"),links:[{text:"How to manually add a UUID",icon:"handyman",url:"https://photostructure.com/faq/what-is-a-volume/#add-uuid"},{text:"Rescan volumes",type:"button",method:"POST",url:"/admin/clear-caches",icon:"refresh"}]}}}})))},86801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});try{i(93944).install()}catch{}const r=i(98314),s=i(98424);process.on("unhandledRejection",(e=>console.error("UNHANDLED REJECTION",(0,r.errorToS)(e)))),process.on("uncaughtException",(e=>console.error("UNCAUGHT EXCEPTION",(0,r.errorToS)(e)))),(0,s.run)()},64501:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InfoArgs=void 0,t.InfoArgs={beforeParse:e=>e.option("--volumes","Emit a table with currently mounted volume metadata. See https://photostructure.com/volumes for details.").option("--mountpoints","Emit a table with currently mountpoints. See https://photostructure.com/volumes for details.").option("--sync-paths","Emit a table listing the paths that will be synced next.").option("--plan, --licensing","Emit plan/licensing information. See the About page in the web UI for more details or to activate a subscription.").option("--child-env","Emit the environment variables provided to all spawned processes.").option("--validate","Only run file validation on the given filenames (requires current PLUS subscription).").option("-j, --json","Emit metadata as un-indented, uncolorized JSON.").option("--load-library","Load the library database so more metadata can be shown (like if a file is currently in your library). This adds a second or two (depending on the size of your library).").option("--filter ",'Case-insensitively filter keys by . may have dots. Note that .nativePath is always included. Repeat to filter for multiple terms ("--filter foo --filter bar").',((e,t)=>t.concat([e])),[]).option("--file-filters","Include an exhaustive list of file and directory filters. This is hundreds of lines long, so it's not included by default.").option("--image-hash",'Automatically filter image hash fields. Equivalent to "--filter imageHash --filter imageHashComparison"').option("--flat","Only return values for objects with only one field").option("--suggested-libraries","Emit the suggested library directories (as seen on the settings page).").option("--volumes-ttl","Emit the volume cache time-to-live (use with --debug to see details).").option("--is-library ","Run a couple quick checks to see if looks like a PhotoStructure library.").option("--read-settings ","Read the given file and output the parsed settings.").option("--reindex","Rebuild the tag full-text index and recount every asset tag count. This may take a minute or two. Don't have a sync running concurrently. Implies --cleanup.").option("--globs, --exclude-globs","Emit all file and directory exclusion globs.").option("--health","Emit details for all health checks.").option("--doctor","Emit details for all health checks that aren't OK.").option("--skip-health","Disable health checks.").option("--version-check","Check now if the current version is the latest.").option("--table","Emit with console.table() (useful with --volumes or --filter).").option("--cleanup","Run a bunch of maintenance tasks."),afterParse:function(){}}},98424:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.run=void 0;const s=r(i(57975)),n=i(19851),a=i(50213),o=i(88158),l=i(23560),u=i(19913),c=i(83556),d=i(94174),h=i(79184),f=i(79781),m=i(13991),p=i(92434),g=i(45608),y=i(56519),v=i(31562),w=i(9727),b=i(69554),S=i(38790),P=i(53978),_=i(43380),M=i(91655),T=i(15056),E=i(49776),k=i(48195),D=i(87290),x=i(46296),C=i(98314),F=i(8769),A=i(57159),I=i(83278),O=i(92423),L=i(95696),R=i(89966),N=i(63664),B=i(18454),j=i(80361),z=i(181),V=i(34592),W=i(81674),U=i(17181),H=i(43205),q=i(28874),G=i(2858),$=i(32707),J=i(63225),K=i(85087),Y=i(50036),Z=i(40044),X=i(59107),Q=i(63870),ee=i(7014),te=i(14854),ie=i(40958),re=i(22573),se=i(38639),ne=i(42659),ae=i(55835),oe=i(68708),le=i(34666),ue=i(5670),ce=i(12168),de=i(59455),he=i(98401),fe=i(64526),me=i(56992),pe=i(57064),ge=i(77948),ye=i(31503),ve=i(8400),we=i(92244),be=i(64501),Se=i(46854);t.run=async function(){try{await async function(){const e=await new b.CLI(ue.ServiceNames.info,"[FILE...]",["* Omit any filenames to run diagnostics and output system configuration, tooling, and health check information.","* File paths should be absolute or relative to cwd.","* Provide 2 file paths to see why PhotoStructure may consider them variants of the same asset.","* To emit valid JSON, set NO_COLOR=1 or use --json."].join("\n")).add(be.InfoArgs,_.WriteSettingsArg,ye.LogArgs,S.ColorArgs,P.TimingArg).parse();(0,u.setServiceName)("info"),(0,U.setupLogger)();const t=e.opts(),i=(0,ie.uniq)(e.args),r=(0,se.isTrue)(t.flat),g=(0,se.isTrue)(t.table),F=!0===t.reindex;F&&(q.Settings.recountAllTags.envValue=!0);const A=F||(0,se.isTrue)(t.cleanup);(0,se.isTrue)(t.imageHash)&&(t.filter??(t.filter=[]),t.filter.push("imageHash"),t.filter.push("imageHashComparison"));const Pe=(0,se.isTrue)(t.fileFilters),_e=(0,n.lazy)((()=>{if((0,ie.isEmpty)(t.filter))return;const e=(0,de.toA)(t.filter);return r&&i.length<=1||e.unshift("nativePath"),2===i.length&&e.push(...e.map((e=>"a."+e)),...e.map((e=>"b."+e))),e}));function Me(e){e=function(e){const t=_e();return null==t?e:Array.isArray(e)?e.map((e=>(0,oe.pickDeep)(e,...t))):(0,oe.pickDeep)(e,...t)}(e),r&&(e=(0,oe.flattenObject)(e));const i=(0,se.isTrue)(t.json);r&&(0,le.isPrimitive)(e)?console.log(e):i||(0,se.isFalse)(q.Settings.logColor.value)?console.log(JSON.stringify(e,void 0,i?void 0:2)):g?console.table(e):console.log(s.default.inspect(e,{depth:7,colors:!0,maxArrayLength:1024}))}let Te;if((0,u.setServiceName)("info"),(0,se.isTrue)(t.skipHealth)?B.HealthCheck.disableAll(!0):Te=await(0,N.getRemoteHealthSummary)(),(0,re.notBlank)(t.readSettings)){const e=await(0,G.importFileSettings_)(I.BaseFile.for(t.readSettings));return Me({settings:(0,oe.fromEntries)(e.settings.map((e=>[e.name,e.value]))),warnings:e.warnings})}if(await(0,G.readSettings)(),A&&(l.isDbJanitorService.set(!0),q.Settings.logLevel.isUnset()&&(q.Settings.logStdout.envValue=!0,q.Settings.logLevel.envValue="warn",(0,U.setupLogger)())),(0,se.isTrue)(t.versionCheck))return await((0,Y.channelVersionsCache)()?.unlink()),q.Settings.autoUpdateCheck.tmpValueIfUnset=!0,Me(await(0,Z.checkVersion_)());if((0,se.isTrue)(t.globs)||(0,se.isTrue)(t.excludeGlobs)){const e=(0,O.excludeGlobs)();return Me({excludeGlobs:{file:e.file.map((e=>(0,oe.pick)(e,"pattern","desc"))),dir:e.dir.map((e=>(0,oe.pick)(e,"pattern","desc")))}})}if((0,se.isTrue)(t.volumes)){const e=await(0,ee.volumes)();if(null!=e)return Me(e.filter((e=>!0!==e.ignorable)).map((e=>({filesystem:e.filesystem,...e,size:(0,ce.fmtBytes)(e.size),used:(0,ce.fmtBytes)(e.used),available:(0,ce.fmtBytes)(e.available),volsha:(0,K.volsha)(e.uuid)}))));console.error("--volumes failed. Please retry with --info for details.")}if((0,se.isTrue)(t.mountpoints)){const e=await(0,X.mountpoints)();if(null!=e)return Me(e);console.error("--mountpoints failed. Please retry with --info for details.")}if((0,se.isTrue)(t.plan)||(0,se.isTrue)(t.licensing)){const e=(await(0,W.m)())[0],t=(0,ae.map)(e?.l,(t=>({email:t.sub,trial:t.trial,issued_at:t.iat,expires:t.exp,meta:e.meta})));return Me({plan:await(0,W.t)(),current_license:t})}if((0,se.isTrue)(t.suggestedLibraries))return Me(await(0,pe.suggestedLibraryDirs)());if((0,se.isTrue)(t.volumesTtl))return Me({volumesTTL:await(0,me.calcVolumesTTL)()??(0,Q.volumeMetadataTtlMs)()});if((0,se.isTrue)(t.childEnv))return Me((0,w.childEnv)());const Ee=(0,a.mkLogger)("info");if((0,se.isTrue)(t.loadLibrary)||(0,se.isTrue)(t.syncPaths)||A){const e=(0,D.libraryDataDirPosixFile)();if(null==e)return console.error("Error: please set up your library.");if(!await e.isDirectory())return console.error("Error: your library data dir, "+e+", is missing.");Ee.info("Waiting for library to spin up...");const t=fe.Library.instance();try{await(t?.ready)}catch(e){Ee.warn("Failed to spin up library",e)}const i=(0,T.pathToDb)(e,"models");if(!await i.isNonEmptyFile())return console.error("Error: your library database, "+i+" is missing.")}if(A)return await(0,he.cleanup_)(),Me({cleanup:"OK"});if((0,se.isTrue)(t.syncPaths))return Me(await(0,we.syncPathsForUI)());if((0,re.notBlank)(t.isLibrary)){const e=await(0,k.whyNotLibraryDir)(t.isLibrary);return Me((0,oe.compactValues)({isLibrary:null==e,why:e}))}if((0,se.isTrue)(t.validate)){if((0,ie.isEmpty)(i))throw new Error("--validate requires filenames");return q.Settings.validateVideos.envValue=!0,q.Settings.validateJpegImages.envValue=!0,q.Settings.validateRawImages.envValue=!0,Me(await Promise.all(i.map((async e=>[e,(0,re.notBlankOr)(await(0,z.whyInvalidFile)(e),"OK")]))))}if((0,ie.isEmpty)(i)){await(0,v.until)((()=>te.CpuUsage.instance().busyPct()),{timeoutMs:2*ne.secondMs,intervalMs:250});const e={systemInfo:(0,oe.fromEntries)((await(0,ge.systemInformation)()).map((({term:e,defn:t})=>[(0,c.asObjectKey)(e),t])))};return e.versionCheck={userAgent:await(0,H.userAgent)(),...await(0,Z.checkVersion_)().catch((e=>({error:(0,C.errorToS)(e)}))),currentChannel:(0,Z.currentChannel)()},e.user_ids=(0,d.userids)(),e.group_ids=(0,d.groupids)(),e.username=await(0,d.username)(),e.paths={libraryDir:q.Settings.libraryDir.valueOrDefault,originalsDir:(0,D.libraryOriginalsDirPosixFile)()?.nativePath,systemSettingsFile:(0,$.systemSettingsFile)(),librarySettingsFile:(0,G.librarySettingsFile)()?.nativePath,libraryPreviewsDir:(0,D.libraryPreviewsDirPosixFile)()?.nativePath,librarySyncReportsDir:(0,D.librarySyncReportsDir)()?.nativePath,cacheDir:(0,E.cacheDir)(),logDir:(0,x.logDir)(),toolsDir:(0,R.toolsDir)()?.nativePath,osToolsDir:(0,R.osToolsDir)()?.nativePath,ffmpeg:await(0,V.ffmpegNativePath)(),sqlite:await(0,R.sqliteNativePath_)().catch((e=>"not found: "+(0,C.errorToS)(e)))},(0,se.isTrue)(t.health)?(e.healthSummary=await(0,N.getLocalHealthSummary)(),e.healthChecks=await Promise.all(B.HealthCheck.testResults())):(0,se.isTrue)(t.doctor)?(await(0,ve.libraryHealthCheckSetup)(),e.healthChecks=await B.HealthCheck.notOkResults()):e.healthSummary=Te??await(0,N.getLocalHealthSummary)(),e.wrongPsEnvValues=(0,J.verifyPsEnvSettings)(),(0,se.isTrue)(t.loadLibrary)&&(e.libraryMetrics=(0,oe.fromEntries)((await(0,ge.libraryMetrics)())?.map((e=>[(0,c.asObjectKey)(e.desc),e.count]))??[])),e.volumesTTL=(0,M.fmtFullDuration)(await(0,me.calcVolumesTTL)()),e.nonDefaultSettings=(0,oe.fromEntries)((0,oe.values)(q.Settings).filter((e=>e.hasValue())).map((e=>[e.name,e.humanValue]))),Me(e)}if(2===i.length){const e=L.PosixFile.for(i[0]),t=L.PosixFile.for(i[1]),r=await(0,m.mkAssetFile_)(e),s=await(0,m.mkAssetFile_)(t),n=[];if(null==r&&n.push("Failed to read "+e),null==s&&n.push("Failed to read "+t),(0,ie.isNotEmpty)(n))return Me({errors:n});const a=(0,f.whyNotSimilarAssetFile)(r,s),l=null==a?"These two files will be aggregated into a single asset.":"These files represent different assets: "+a;let u,c;if(null==a){const e=(0,p.sortAssetFiles)([r,s]);u=e[0]?.nativePath,c=(0,o.zipPojos)(...await Promise.all(e.map(p.assetFileSortCriteriaPojo)))}const d={fileComparison:l,primary:u,a:await(0,Se.info)(e,Pe),b:await(0,Se.info)(t,Pe),cmpArr:c};return q.Settings.useImageHashes.valueOrDefault&&(d.imageHashComparison=(0,oe.omit)((0,j.compareImageHashes)(r,s),"a","b")),Me(d)}{const e=await(0,y.mapAsync)({name:"info",arr:i,f:e=>(0,Se.info)(e,Pe)}),t=(0,oe.fromEntries)(e?.map(((e,t)=>[t,e])));if(e.length>1){const e=(0,ie.compact)(await(0,y.mapAsync)({name:"mkAssetFile",arr:i,f:e=>(0,m.mkAssetFile_)(L.PosixFile.for(e)).catch((t=>{console.error("Failed to read "+e,t)}))})),r=await(0,h.aggregateAssetFiles)(e);t.clusters=r.map((e=>e.map((e=>e.uri))))}return Me(t)}}()}catch(e){(0,F.onError)((0,A.toWrappedError)("Failed",{cause:e,fatal:!0}))}finally{await(0,g.exit)({reason:"done",status:0})}}},46854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.info=void 0;const r=i(50213),s=i(88158),n=i(13991),a=i(92434),o=i(85434),l=i(98314),u=i(92423),c=i(32144),d=i(95696),h=i(62105),f=i(17217),m=i(181),p=i(66106),g=i(78984),y=i(4936),v=i(47783),w=i(16170),b=i(54979),S=i(22573),P=i(42659),_=i(45599),M=i(68708),T=i(20214),E=i(64526),k=i(19113),D=i(88224),x=i(54017),C=i(94448),F=i(3996),A=(0,_.defer)((()=>(0,r.mkLogger)("info.InfoImpl")));t.info=async function(e,t){try{const i=d.PosixFile.for(e),r=await(0,b.readMimeType)(i);if(null==r)return{nativePath:i.nativePath,error:`Could not read mimetype for ${i.nativePath}`};if((0,c.isSidecarMimetype)(r))return{nativePath:i.nativePath,mimetype:r,error:"Skipping sidecar mimetype"};if(!await(0,w.isAssetFileMimeType)(i))return{nativePath:i.nativePath,mimetype:r,error:"Skipping non-asset file mimetype"};const l=i.parent();A().throwIfAborted_();const f=await(0,n.mkAssetFile_)(i),_=t?await g.Predicates.explain(l,...(0,u.notExcludedDirPredicates)(l)):void 0,I=t?await g.Predicates.explain(i,...(0,k.libraryFileFiltersFor)(i,{validateFile:!0})):void 0,O=f.dominantColors?.filter((e=>null!=e?.color?.name)).map((e=>({rgb:e.rgbhex,name:e.color?.name,pct:e.pct}))),L=await(0,D.tagAsset)({primaryVariation:i,files:[],priorTagPaths:[],capturedAts:[],uris:[await i.uri_()]}),R=null==(0,C.modelDb)()?void 0:await new F.AssetFileFinder(i).prior(),N=await(R?.matchesFile()),B=await(0,T.thenCollect)(x.AssetFile.sameShaInLibrary(i),(e=>e.getNativePath()));A().throwIfAborted_();const j=await(0,v.readTags)(i),z=(0,h.whyRejectFile)(i,!0===E.Library.instance()?.isReadySync()?(0,k.libraryFileFiltersFor)(i):void 0),V=(0,M.compactValues)({...(0,o.omitModeData)(f),...(0,M.pick)(j,"tz","tzSource","errors","inferred","duration"),dirFilters:_,dominantColors:O,fileFilters:I,needsTranscoding:await(0,p.needsTranscoding)(i),pathsInLibrary:B,pathToLibraryAsset:(0,y.pathToLibraryAsset)((0,P.localToDate)(f.capturedAtLocal),i),priorAssetFile:R?.toJSON(),priorIsInSync:N,sidecars:(await i.existingSidecars()).map((e=>e.base)),tagResult:L,validFile:(0,S.notBlankOr)(await(0,m.whyInvalidFile)(i.nativePath),"OK"),variantSortCriteria:(0,a.assetFileSortCriteriaPojo)(f),whyExcludedDirectoryRecursive:await(0,u.whyExcludedDirectoryRecursive)(l),whyRejected:z});return(0,M.compactValues)({nativePath:i.nativePath,mimetype:r,...(0,s.sortedKeys)(V)})}catch(t){return{nativePath:(0,f.toNativePath_)(e),error:(0,l.errorToS)(t)}}}},43487:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Asset=void 0;const u=i(48884),c=i(19851),d=i(50213),h=i(88158),f=i(45393),m=i(56519),p=i(89724),g=i(38835),y=i(74128),v=i(79847),w=i(28874),b=i(47783),S=i(38010),P=i(40958),_=i(76790),M=i(75761),T=i(38639),E=i(11371),k=i(98553),D=i(55835),x=i(31586),C=i(20214),F=i(59455),A=i(64526),I=i(4407),O=i(54017),L=i(48722),R=i(37094),N=i(45295),B=i(39604),j=i(48723),z=i(41507),V=i(72761),W={"Asset.shown":1,"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null};class U extends V.TimestampedModel{constructor(){super(...arguments),r.add(this),this.attrs={},this.assetIdish=(0,c.lazy)((()=>({assetId:this.id,v:this.updateCount,capturedAtLocal:this.capturedAtLocal}))),this.mergedTags=(0,c.lazy)((async()=>{const e=[];for(const t of this.getAssetFiles()){const i=await t.posixFile(),r=await(0,b.readTags)(i),s=await(i?.mtimeMs());null!=i&&null!=r&&null!=s&&e.push({...r,SourceFile:i.nativePath,sourceModifiedTime:s,sourceIsPrimary:(0,T.isTrue)(t.shown)})}const t=R.AssetRevision.ops().allf((e=>e.where({assetId:this.id}))),i=new S.MergedTags("Asset:"+this.id);return i.addTag(...e,...this.assetFiles),i.addRevision(...t),i}))}static shownUnhidden(e){return null==e?s.query().where(W):e.andWhere(W)}static findUnhiddenById(e){return(0,x.gt0)(e)?s.ops().firstf((t=>s.shownUnhidden(t.where({id:e})))):void 0}static shownRemovable(e,t){return(t??s.query()).whereNotNull(e).andWhere({"Asset.shown":1})}static shownCount(){return s.ops().count(s.shownUnhidden().countDistinct("Asset.id"))}static deletePreviews(e){return A.Library.instance().previews().ap(e).deleteAll()}static async remove({assetId:e,blocklistShas:t,unlinkAssetFiles:i}){const r=(0,d.mkLogger)("Asset("+e+").remove()"),n=s.ops().findById(e);if(null==n)return void r.warn("asset not found");const a=n.isActive(),o=n.tagIds();r.info("starting",{unlinkAssetFiles:i});const l=n.getAssetFiles({refresh:!0});if(t){(0,B.upsertToShaBlockslist)(...l.map((e=>e.sha)));for(const e of l)(0,y.syncReport)().onProgress({from:"Asset.remove",path:await e.getNativePath()??e.uri,state:"blocklisted",details:"sha blocklisted (files with the same sha will not be imported)"})}N.AssetTag.dbl.runf((t=>t.delete().where({assetId:e}))),O.AssetFile.dbl.runf((t=>t.delete().where({assetId:e}))),R.AssetRevision.dbl.runf((t=>t.delete().where({assetId:e}))),s.dbl.runf((t=>t.delete().where({id:e}))),a&&j.Tag.deltaAssetCountAndAncestors(o,-1);try{await s.deletePreviews(e)}catch(e){r.error("Failed to delete previews",{error:e})}return{deletedMeta:i?await(0,v.trashOrUnlinkFileUris_)(l):[],assetFileMeta:l}}static nextOutdated(e=h.identity){return this.ops().findOne(e(l(this,s,"m",n).call(this)))}static nextOutdateds(e){return this.ops().all(e(l(this,s,"m",n).call(this)))}static outdatedCount(e=h.identity){return this.dbl.pluckFirst(e(l(this,s,"m",n).call(this)).count())}static findFirstByFile(e){return this.ops().findOne(e(this.query().select("Asset.*").join("AssetFile","AssetFile.assetId","Asset.id")))}static unshownAssetIds(){return this.dbl.pluckAll("\n SELECT DISTINCT af1.assetId\n FROM AssetFile af1\n LEFT JOIN (SELECT DISTINCT assetId FROM AssetFile WHERE shown = 1) AS af2 \n ON af1.assetId = af2.assetId\n WHERE af2.assetId IS NULL")}static archive(e){null!=s.ops().findById(e)&&(N.AssetTag.dbl.runf((t=>t.where({assetId:e}).delete())),O.AssetFile.dbl.runf((t=>t.where({assetId:e}).delete())),s.dbl.runf((t=>t.where({id:e}).delete())))}markUnshownAndUpsert(){this.shown=!1,this.version=f.AssetVersion,this.upsert()}markShownAndUpsert_(e){const t=this.getShown()?.id;if(null!=e){const t=e.shown;this.setShown_(e,{skipUpsert:!0}),!0!==t&&e.upsert()}this.shown=!0,this.version=f.AssetVersion,t!==this.getShown()?.id&&(this.updateCount=(this.updateCount??0)+1),this.upsert()}async updateFromFiles(){const e=await this.mergedTags();(0,D.map)(e.get("rating"),(e=>{this.logger().info("updateFromFiles()",{rating:e}),this.rating=e.value}))}isActive(){return(0,x.gt0)(this.id)&&!0===this.shown&&null==this.excludedAt&&null==this.deletedAt&&(null==this.rating||(0,x.gte)(this.rating,w.Settings.rejectRatingsLessThan.valueOrDefault))}toAssetId(){return(0,L.toAssetId)(this)}renderCaption(e){return(0,D.map)(this.capturedAtLocal,(t=>"Taken "+(0,p.fmtLocalDateShort)(t,e)))}async whenApiTag(){const e=(0,I.dateTag)((0,p.localToDateObject)(this.capturedAtLocal));return null==e?void 0:j.Tag.findOrCreate(e).toApiTag()}findAssetFileByUri(e){return this.getAssetFiles()?.find((t=>t.uri===e))}addAssetFile(e){(0,P.filterInPlace)(e.asset?.assetFiles??[],(t=>!(t.id===e.id||t.uri===e.uri))),e.assetId=this.id,e.asset=this,e.shown=!1,this.getAssetFiles().push(e),this.clear(),this.capturedAtLocal??(this.capturedAtLocal=e.capturedAtLocal),this.rating??(this.rating=e.rating),this.durationMs??(this.durationMs=e.durationMs)}async assetFileForFile_(e,t){const i=await e.uri();if(null==i)return this.logger().throw("assetFileForFile_(): null uri",{f:e});const r=this.getAssetFiles().find((e=>e.uri===i));if(null!=r)return r;const s=new O.AssetFile;return this.addAssetFile(s),!0!==t?.skipUpsert?await s.upsertIfNeeded_(e):await s.setFile_(e),s}static getTags(e){return j.Tag.ops().all(j.Tag.query().select("Tag.*").join("AssetTag","AssetTag.tagId","Tag.id").where("AssetTag.assetId",e).orderByRaw("COALESCE(Tag.ordinal, Tag._path)"))}tagIds(e){return!0===e?.refresh&&(this.tags=void 0),this.tags?.map((e=>e.id))??N.AssetTag.dbl.pluckAllf((e=>e.select("tagId").where({assetId:this.id})))}getTags(e){return!0===e?.refresh&&(this.tags=void 0),this.tags??(this.tags=s.getTags(this.id))}tagPaths(){return this.getTags().map((e=>e.path.join("/"))).sort()}setTagIds(e){const t=this.tagIds({refresh:!0});if((0,u.eqlUnordered)(t,e))return void this.logger().debug("setTagIds(): no-op, tagIds unchanged");const i=e.filter((e=>!t.includes(e))),r=t.filter((t=>!e.includes(t)));return this.applyTagIdDeltas({tagIdsToAdd:i,tagIdsToRemove:r})}applyTagPathDeltas(e){return this.applyTagIdDeltas({tagIdsToAdd:j.Tag.findOrCreateByPathN(e.add??[]).map((e=>e.id)),tagIdsToRemove:j.Tag.findByPathN(e.remove??[]).map((e=>e.id))})}applyTagIdDeltas(e={}){const t=this.tagIds({refresh:!0}),i=(0,P.uniq)((0,F.toA)(e.tagIdsToAdd).filter((e=>(0,x.gt0)(e)&&!t.includes(e)))),r=(0,P.uniq)((0,F.toA)(e.tagIdsToRemove).filter((e=>(0,x.gt0)(e)&&t.includes(e))));if((0,P.isEmpty)(i)&&(0,P.isEmpty)(r))return this.logger().info("applyTagIdDeltas(): no-op, no changes",{currentTagIds:t,...e}),t;this.isActive()&&j.Tag.deltaAssetCountAndAncestors(t,-1),(0,P.isEmpty)(i)||N.AssetTag.dbl.runf((e=>e.insert(i.map((e=>({assetId:this.id,tagId:e})))).onConflict(["assetId","tagId"]).ignore())),(0,P.isEmpty)(r)||N.AssetTag.dbl.runf((e=>e.whereIn("tagId",r).andWhere({assetId:this.id}).delete())),this.tags=void 0;const s=(0,P.uniq)([...t,...i]).filter((e=>!r.includes(e)));return this.isActive()&&j.Tag.deltaAssetCountAndAncestors(s,1),s}getStreams(e){if(null==this.streams){const t=this.getTags();this.logger().info("getStreams(): fetched tags "+t,{limit:e});const i=t.map((t=>t.getAssetStream(this,e)));this.streams=(0,z.coalesceStreams)((0,P.compact)(i));for(const e of this.streams)for(const t of e.tags)t.getAncestors()}return this.streams}getBeforeAfterId(){const e=s.dbl.all(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",this.capturedAtLocal).orderBy("assetId"));this.afterId=e.find((e=>e.assetId>this.id)),this.beforeId=e.reverse().find((e=>e.assetIde.path))}getAssetFiles({refresh:e=!1}={}){return null!=this.id&&(e&&(this.assetFiles=void 0),this.assetFiles??(this.assetFiles=(0,_.sortBy)(O.AssetFile.ops().findBy({assetId:this.id}),(e=>[!(0,T.isTrue)(e.shown),-e.mtime])))),this.assetFiles??[]}setShown_(e,t){e instanceof O.AssetFile&&(this.getAssetFiles(),this.assetFiles?.some(((t,i)=>{const r=t.id===e.id||t.uri===e.uri;return r&&(this.assetFiles[i]=e),r})));const i=e instanceof O.AssetFile?e.id:e;if(this.getShown()?.id===i)return void this.logger().debug("setShown_(): no-op, already set",{afId:i});this.logger().info("setShown_()",{assetId:this.id,assetFileId:i}),(0,x.gt0)(this.id)&&(0,x.gt0)(i)||this.logger().throw("setShown_(): invalid IDs: "+(0,k.stringify)({assetId:this.id,assetFileId:i})+g.InternalErrorFlag);const r=Date.now();O.AssetFile.dbl.runf((e=>e.update({shown:0,updatedAt:r}).where({assetId:this.id}))).changes<=0&&this.logger().warn("setShown_(): all asset files were already unshown",{afId:i});const s=O.AssetFile.dbl.runf((e=>e.update({shown:1,updatedAt:r}).where({id:i})));1!==s.changes&&this.logger().throw("setShown_(): failed to update asset file: unexpected changed rows",{runResult:s});const n=this.assetFiles?.find((e=>e.id===i))??this.getAssetFiles({refresh:!0}).find((e=>e.id===i));if(null!=n){this.capturedAtLocal=n.capturedAtLocal,this.rating=n.rating,this.durationMs=n.durationMs;for(const e of this.assetFiles??[])e.shown=e.id===i;!0!==t?.skipUpsert&&this.upsert()}else this.logger().throw("setShown_(): failed to find shown asset file",{af:e})}getShown(e){return this.getAssetFiles(e)?.find((e=>(0,T.isTrue)(e.shown)))??this.getAssetFiles({refresh:!0})?.find((e=>(0,T.isTrue)(e.shown)))}getShownNativePath(){return this.getShown()?.getNativePath()}async getCapturedAts(){return(0,C.thenCollect)(this.getAssetFiles(),(e=>e.capturedAt()))}link(){return"/asset/"+this.id}sqAttrs(e=!0){return{...(0,M.assetSqImgAttrs)({assetId:this.assetIdish(),lazyLoad:e}),title:this.renderCaption(),...this.attrs}}async getImgAttrs(e,t,i=!1){if(null==this.imgAttrs&&(this.imgAttrs=new Map),null==this.imgAttrs.get(t)){const r=e.ap(this.id);await(0,m.thenMap)(r.readInfo(),(async e=>{e.mimetype.startsWith("video/")&&(this.poster=await r.posterLink())}));const s=!0;this.imgAttrs.set(t,await r.imgAttrs(t,s,i))}return this.imgAttrs.get(t)}async fitAttrs(e){return{...await this.getImgAttrs(e,E.ReducerNames.fit),...this.attrs}}isVideo(){if(null==this.assetFiles)throw new Error(".video called before getFiles()");return this.assetFiles.some((e=>e.isVideo))}videoAttrs(){return{controls:!0,autoplay:!0,poster:this.poster,...this.attrs}}async videoSources(){const e=[];let t;for(const i of this.getAssetFiles())e.some((e=>e.type===i.mimetype))||await i.exists()&&(t??(t=i),e.push({src:(0,M.assetVideoLink)({assetId:this.assetIdish(),assetFileId:i.id}),type:i.mimetype}));return e.some((e=>"video/mp4"===e.type))||null==t||e.unshift({src:(0,M.assetVideoLink)({assetId:this.assetIdish(),assetFileId:t.id})+".mp4",type:"video/mp4"}),e}async getPosixFiles(){return(0,C.thenCollect)(this.getAssetFiles(),(e=>e.posixFile_()))}async getExistingAssetFiles(){return(0,m.filterAsync)({name:"getExistingAssetFiles",arr:this.getAssetFiles(),f:e=>e.exists()})}async findOrCreateByFile(e){const t=await e.uri_();if(null==t)return;const i=(0,F.toA)(O.AssetFile.ops().findBy({assetId:this.id,uri:t}))[0];return(0,D.orElse)(i,(async()=>{const t=new O.AssetFile;return t.asset=this,t.assetId=this.id,await t.setFile_(e),t}))}partialSimpleAsset(){return{assetId:this.id,liked:(0,x.gte)(this.rating,w.Settings.likeRating.valueOrDefault),hidden:(0,T.isTrue)(this.hidden),excluded:null!=this.excludedAt,deleted:null!=this.deletedAt}}clear(){return this.imgAttrs=void 0,this.streams=void 0,this.tags=void 0,this.mergedTags.unset(),this}}t.Asset=U,s=U,r=new WeakSet,n=function(){return s.shownUnhidden().andWhere("version","<",f.AssetVersion)},a=function(){return this.beforeId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal","<",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId",order:"desc"}]))},o=function(){return this.afterId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",">",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"asc"},{column:"assetId",order:"asc"}]))},U.$tableName="Asset",U.$uniqueColumnName="id",U.$booleanFields=["shown","hidden"]},54017:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFile=void 0;const a=i(76760),o=i(19851),l=i(88158),u=i(45393),c=i(68852),d=i(81168),h=i(13991),f=i(54296),m=i(56519),p=i(76490),g=i(89724),y=i(98314),v=i(38835),w=i(8769),b=i(29882),S=i(95696),P=i(62105),_=i(74128),M=i(35721),T=i(69589),E=i(28874),k=i(28544),D=i(16170),x=i(45200),C=i(34238),F=i(87001),A=i(42233),I=i(21404),O=i(40958),L=i(17586),R=i(22573),N=i(38639),B=i(42659),j=i(33374),z=i(50357),V=i(75240),W=i(11371),U=i(55835),H=i(31586),q=i(68708),G=i(34666),$=i(89937),J=i(75020),K=i(64526),Y=i(41844),Z=i(43487),X=i(48723),Q=i(94710),ee=i(72761);class te extends ee.TimestampedModel{constructor(){super(...arguments),r.add(this),this.uriObj=(0,o.lazy)((()=>C.URI.parse(this.uri))),this.whyRejected=(0,o.lazy)((async()=>{const e=await this.posixFile_();return null==e?"invalid URI":!0===await this.isFileDeleted()?"deleted":(0,P.whyRejectFile)(e)})),this.posixFile_=(0,o.lazy)((async()=>S.PosixFile.for(await this.getNativePath())))}static outdatedQuery(e){let t=(e.q??this.query()).where("version","<",u.AssetFileVersion);return null!=e.maxUpdatedAt&&(t=t.andWhere("updatedAt","<",e.maxUpdatedAt)),t.andWhere((t=>{(0,O.isNotEmpty)(e.mountpoints)&&(t=t.whereIn("mountpoint",e.mountpoints));for(const i of e.uris)t=t.orWhereLike("uri",i+"%");return t})).orderBy("id")}static async nextOutdated(e=l.identity){return this.ops().findOne(e(this.outdatedQuery(await(0,A.currentVolumeRoots)())))}static async outdatedCount(e=l.identity){const t=this.outdatedQuery(await(0,A.currentVolumeRoots)());return this.dbl.pluckFirst(e(t.count("id")))}static shownAssetFileId(e){return this.dbl.pluckFirstf((t=>t.where({assetId:e,shown:1}).limit(1)))}static primaryForAssetId(e){return(0,H.gt0)(e)?te.ops().first(Z.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id").select("AssetFile.*").where({assetId:e,"AssetFile.shown":1})):void 0}static shownUnhidden({uriRoot:e}={}){let t=Z.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id");return(0,R.blank)(e)||(t=t.andWhereLike("AssetFile.uri",e+"%")),t}static recentAssetIdsByUriRoot(e,t,i=64){const r=Date.now()-t;return this.dbl.pluckAll(te.shownUnhidden({uriRoot:e}).distinct("AssetFile.assetId").where("AssetFile.updatedAt",">",r).orderBy("AssetFile.updatedAt","desc").limit(i))}static assetFileCountByMimeType(e){const t=te.shownUnhidden({uriRoot:e}).select("mimetype").countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"}).groupBy("mimetype").orderBy("mimetype");return this.dbl.all(t)}static assetFileCountWithMimeType(e,t){let i=te.shownUnhidden({uriRoot:t}).countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"});return i=e.endsWith("/")?i.andWhereLike("mimetype",e+"%"):i.andWhere("mimetype",e),this.dbl.first(i)}static assetFileCountByMimeTypeRoots(e=["image/","video/"],t){return e.map((e=>({mimeTypeRoot:e,assetFileCount:te.assetFileCountWithMimeType(e,t)?.assetFileCount??0})))}static children(e,t){const i=this.query().whereLike("uri",e+"/%").andWhere("uri","regexp",`^${(0,c.escapeRegExp)(e)}/[^/]+$}`);return this.ops().all(null==t?i:t(i))}static async sameShaInLibrary(e){if(null==this.db())return;const t=await e.sha(),i=await e.size();return null!=t&&null!=i?this.ops().allf((e=>e.where({sha:t,fileSize:i}).andWhereLike("uri",$.PS_LIBRARY_PROTOCOL+"%"))):void 0}static sameAssetFileInLibrary(e){return this.ops().allf((t=>t.where((0,q.pick)(e,"sha","fileSize")).andWhere((e=>e.whereLike("uri",$.PS_LIBRARY_PROTOCOL+"%"))).andWhere((t=>t.whereNot({id:e.id})))))}librarySiblings(){return this.getAsset()?.getAssetFiles().filter((e=>e.id!==this.id&&e.uri.startsWith($.PS_LIBRARY_PROTOCOL)))}capturedAtLocale(e){return(0,g.fmtLocalDateShort)(this.capturedAtLocal,e)}get dominantColors(){return p.DominantColor.fromModeData(this)}set dominantColors(e){(0,q.assignAllFields)(this,p.DominantColor.toModeData(e))}get posixPathFromGrandparent(){return(0,U.map)(this.uriObj()?.fsPath,b.posixPathFromGrandparent)}async whyNotMatchesFile(e){const t=n(this,r,"m",s).call(this);if(null!=t)return t;if(null==this.fileSize||null==this.mtime)return"missing file metadata";if(null!=e){const t=await e.uri();if(null==t)return"file has no URI";if(!await(0,F.uriIsEquivalent)(this.uri,t))return"file URI mismatch"}try{const t=e??await this.posixFile_();if(!await t.exists())return"file is missing";const i=await this.fileFields_(t);return null==i?!0===await(t?.isDeleted())?"file is deleted":"file is unreadable":i.fileSize!==this.fileSize?"file size changed since last sync":(0,H.closeTo)(i.mtime,this.mtime,2*B.secondMs)?void 0:"file mtime changed since last sync"}catch(e){return(0,y.errorToS)(e)}}async matchesFile(e){const t=await this.whyNotMatchesFile(e);return this.logger().tap({level:"info",msg:"matchesFile()",result:null==t,meta:{whyNot:t}})}async whyNotInSyncWithFile(e){return E.Settings.forceSync.valueOrDefault?E.Settings.forceSync.key+"=true":this.version!==u.AssetFileVersion?"AssetFileVersion: "+this.version+" != "+u.AssetFileVersion:this.whyNotMatchesFile(e)}async inSyncWithFile(e){const t=await this.whyNotInSyncWithFile(e);return this.logger().tap({msg:"inSyncWithFile()",result:null==t,meta:{whyNotInSync:t}})}async fileFields_(e){const t=e??await this.posixFile_();return null==t?void 0:await(0,h.assetFileStatFields_)(t)}isInLibrary(){return this.uri.startsWith($.PS_LIBRARY_PROTOCOL)}async isNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){const t=await this.whyNotNoop(e);return this.logger().tap({msg:"isNoop()",result:null==t,meta:{whyNotNoop:t}})}async whyNotNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){if(!0===e.forceSync)return"forceSync is true";if(!(0,H.gt0)(this.id))return"missing .id";if(!(0,H.gt0)(this.assetId))return"missing .assetId";{const e=await this.whyNotInSyncWithFile();if(null!=e)return e}if(await(0,Y.mayCopyAssetsToLibrary)()){const e=K.Library.instanceRequired_().assetFileRepository(),t=e.whyNotCopyFile(await this.posixFile_());if((0,R.blank)(t)&&null==await e.existingLibraryAssetFile(this))return"need to copy into library"}this.syncState=_.AssetFileSyncStates.noop}isVersionUpToDate(){return(0,G.gte)(this.version,u.AssetFileVersion)}async siblingCount(){return te.dbl.pluckFirstf((e=>e.count().where({assetId:this.assetId}).andWhereNot({id:this.id})))}async upsertIfNeeded_(e,t=(0,T.forceContextOrSetting)()){if(null!=e&&await this.setFile_(e),await this.matchesFile()&&(0,H.gt0)(this.id)&&!t.forceSync)return void(null==this.syncState&&(this.upsert(),this.syncState??(this.syncState=_.AssetFileSyncStates.noop)));const i=await this.isFileDeleted();if(!0===i)return this.syncState=_.AssetFileSyncStates.deleted,this.delete(),!0!==t.skipAssetRepair&&Q.Task.addOne("repairAsset",{assetId:this.assetId}),this;if(!1===i){const i=await this.updateFromFile_(e,t);return this.syncState??(this.syncState=null==i?_.AssetFileSyncStates.noop:_.AssetFileSyncStates.synced),this.upsert()}return this.syncState??(this.syncState=_.AssetFileSyncStates.skipped),this}async updateFileFields_(e){(0,q.assignFields)(this,await this.fileFields_(e))}async updateFromFile_(e,t=(0,T.forceContextOrSetting)()){const i=Date.now(),r=this.logger().addContext(".updateFromFile_()");if(null!=this.id&&!0!==t.forceSync&&await this.matchesFile(e))return void r.info("updateFromFile() no-op: up-to-date version and file stat matches since last update");if(null!=e&&await this.setFile_(e),null==e&&(e=await this.posixFile_()),null==e||await e.clear().notExists())return this.syncState=_.AssetFileSyncStates.deleted,void r.info("no-op, "+e+" is missing");const s=await(0,h.mkAssetFile_)(e);return s.uri!==this.uri&&((0,R.blank)(this.uri)||!0===this.uri?.startsWith("file:"))&&(this.logger().warn("updateFromFile() upgrading uri",{prior:this.uri,new:s.uri}),this.uri=s.uri),(0,q.assignAllFields)(this,(0,q.omit)(s,"uri")),this.version=u.AssetFileVersion,this.syncState=_.SyncFileStates.synced,r.elapsed("finished",Date.now()-i,this.toJSON()),this}async updateFromShaSibling_(e){const t=n(e,r,"m",s).call(e);if(null==t){if(await this.exists())return this.logger().debug("updateFromShaSibling",e),null!=e.sha&&await e.matchesFile()&&this.sha===e.sha?((0,q.assignFields)(this,(0,q.omit)(e,"id","posixFile","uriObj","shown","uri","mtime","fileSize","mountpoint","createdAt","updatedAt","updateCount",...te.$transientFields)),this.updateFileFields_()):this.updateFromFile_();this.logger().warn("updateFromShaSibling(): fail: file is missing")}else this.logger().warn("updateFromShaSibling() sibling is invalid",{whySiblingIsInvalid:t})}getAsset(){return this.asset??(this.asset=(0,H.gt0)(this.assetId)?Z.Asset.ops().findById(this.assetId):void 0)}exists(){return(0,x.uriExists)(this.uri,this.mountpoint)}async isFileDeleted(){return(await this.posixFile_())?.isDeletedUri(this.uri)}async accepted(){return(0,R.blank)(await this.whyRejected())}async setFile_(e){const t=await e.uri_();if(null==t)return this.logger().throw("setFile(): no URI for "+e);const i=await e.mountpoint();if(null!=this.uri&&!await(0,F.uriIsEquivalent)(t,this.uri))return this.logger().throw("setFile(): cannot reassign non-equivalent URI",{prior:this.uri,new:t,file:e.nativePath});const r=await e.uriObject_();return null==r?this.logger().throw("failed to create URI for "+e):(this.uri=t,this.uriObj.set(r),this.mountpoint=i?.nativePath,this.nativePath=e.nativePath,this.posixFile_.set(Promise.resolve(e)),this)}get basename(){return(0,R.blank)(this.uri)?void 0:decodeURIComponent(this.uri.slice(this.uri.lastIndexOf("/")+1))}posixFile(){return this.posixFile_().catch((()=>{}))}async getNativePath(){return(0,R.blank)(this.nativePath)&&(null==this.uri?this.logger().error(".getNativePath() called before .setFile_()"+v.InternalErrorFlag):this.nativePath=await(0,f.getAssetFileNativePath)(this)),this.nativePath}async capturedAt(){return null==this.nativePath&&await this.getNativePath(),k.CapturedAt.fromAssetFile(this)}async originalDownloadable({brief:e=!1}={}){const t=this.basename;if(!0===e)return null==t?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:`Download ${t}`,basename:t,description:"Download original"};const i=await this.posixFile_();return this.logger().tap({msg:"originalDownloadable()",level:"info",result:null==i||await i.isEmpty()?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:e?`Download ${i.base}`:(0,M.mkDownloadableTitle)(i,"original",this.isVideo?"video":"image",{width:this.width,height:this.height}),basename:i.base,description:"Download original",details:`(${(0,j.fmtDim)(this)} ${i.ext})`},meta:{posixFile:i}})}async downloadables(e,t){try{const i=await this.posixFile_();if(null==i)return[];const r=e.ap(this.assetId),s=[];if(await(0,m.thenMap)(this.originalDownloadable(),(e=>s.push(e))),this.isVideo)return s;if(!(0,N.isTrue)(this.shown)&&this.sha!==t)return s;const n=(0,O.compact)(await Promise.all([...await r.previewInfos()].reverse().filter((e=>e.reducer===W.ReducerNames.fit)).map((e=>(0,M.previewToDownloadable)(i.base,e)))));return s.push(...(0,O.uniqBy)(n,(e=>e.size))),s}catch(e){return(0,w.onError)("AssetFile.downloadables failed for "+this.uri,e),[]}}async pathInfo(){try{const e=C.URI.parse(this.uri),t=(0,U.map)((0,I.uriToTagPath)({uri:e,isFile:!0}),(e=>X.Tag.findByPath(e)));return this._pathInfo_(await(t?.toApiPathElements()))}catch(e){return void this.logger().warn("pathInfo(): failed",e)}}async _pathInfo_(e){const t=await this.posixFile_();if(null==t)return this.logger().throw("pathInfo(): no posixFile",{uri:this.uri});const i=t.nativePath,r=C.URI.parse(this.uri),s=await t.exists();if(null==e||(0,O.isEmpty)(e))return this.logger().warn("pathInfo(): failed to find existing Tag. Returning a simple path.",{uri:this.uri,nativePath:i,tagLineage:e}),{nativePath:i,pathElements:[],nativePathSuffix:i,pathSep:a.sep,exists:s};function n(){return(0,L.at)((0,L.at)(e,-1)?.tagPath,-1)}(0,z.eql)(e[0]?.tagPath,[J.TagRoots.fs])&&(e=e.slice(1));const o=r.scheme===$.PS_LIBRARY_SCHEME,l=o?r.path.split("/").slice(1):t.pathnames,u=l.pop(),c=[];for(;l.length>0&&(0,d.equalsIgnoreCase)(n(),(0,L.at)(l,-1));){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("added matching tag",t)}if(o&&n()===J.LibraryTagName){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("pslib: added matching library tag",t)}if(r.scheme===$.PS_LOCAL_FILE_SCHEME){const t=C.URI.parse(this.uri).authority;if(this.logger().debug("psfile: pop last?",{lastTagName:n(),thisVolSha:t}),n()===t){l.pop();const t=e.pop();c.unshift(t)}else this.logger().warn("weird: I expected to be able to include the volsha tag element, but it doesn't seem to match",{thisVolSha:t,tagVolSha:n()})}return this.logger().tap({msg:"pathInfo()",result:{nativePath:i,pathElements:c,nativePathSuffix:u,pathSep:a.sep,exists:s}})}async toApi(e,t){return(0,m.thenMap)(this.pathInfo(),(async i=>(0,q.reqValuedOrElse)({assetId:this.assetId,assetFileId:this.id,...i,mimetype:this.mimetype,shown:(0,N.isTrue)(this.shown),name:this.basename,width:this.width,height:this.height,rotation:this.rotation??0,fileSize:this.fileSize,mtime:this.mtime,downloadables:await this.downloadables(e,t),createdAtLocale:ie(this.createdAt),updatedAtLocale:ie(this.updatedAt)})))}get isVideo(){return(0,D.isVideoMimeType)(this.mimetype)}}function ie(e){return(0,U.map)(e,(e=>(0,V.fmtDuration)(Date.now()-e,1)+" ago"))}t.AssetFile=te,r=new WeakSet,s=function(){if((0,R.blank)(this.uri))return"blank uri";if((0,R.blank)(this.sha))return"blank sha";if(!(0,H.gt0)(this.width))return"missing width";if(!(0,H.gt0)(this.height))return"missing height";if(!(0,H.gt0)(this.capturedAtLocal))return"missing capturedAtLocal";if(!(0,H.gte0)(this.capturedAtPrecisionMs))return"missing capturedAtPrecisionMs";if(E.Settings.useImageHashes.valueOrDefault){const e=[];for(const t of["dctHash","diffHash","meanHash"])(0,R.blank)(this[t])&&e.push(t);if(1===e.length)return"missing image hash: "+e[0];if(e.length>1)return"missing image hashes: "+e.join(", ")}return this.isVersionUpToDate()?void 0:"outdated version"},te.$tableName="AssetFile",te.$uniqueColumnName="uri",te.$booleanFields=["shown"],te.$transientFields=["nativePath","syncState"]},48722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toAssetId=void 0;const r=i(76596),s=i(31586);t.toAssetId=function(e){const t=(0,s.toGt0)(e?.assetId)??(0,s.toGt0)(e?.id);if(null==e||null==t||!(0,s.isNumber)(e?.capturedAtLocal))return;const i=((0,s.toGt0)(e.v)??(0,s.toGt0)(e.updateCount)??(0,s.toGt0)(e.updatedAt)??0)%1e6,n={assetId:t,capturedAtLocal:e.capturedAtLocal,v:i};return(0,s.gt0)(e.durationMs)&&(n.durationHMS=(0,r.durationHMS)(e.durationMs)),n}},37094:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetRevision=void 0;const r=i(98553),s=i(67478),n=i(55046);class a extends n.Model{static insert(...e){return a.ops().insert(e.map((e=>({assetId:e.assetId,createdAt:Date.now(),field:e.field,op:e.op,_priorValueJson:(0,r.stringify)(e.priorValue),_newValueJson:(0,r.stringify)(e.newValue)}))))}get priorValue(){return(0,s.parseJSON)(this._priorValueJson)}get newValue(){return(0,s.parseJSON)(this._newValueJson)}}t.AssetRevision=a,a.$tableName="AssetRevision"},45295:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetTag=void 0;const r=i(55046);class s extends r.Model{$pk(){return this.assetId+":"+this.tagId}}t.AssetTag=s,s.$tableName="AssetTag",s.$uniqueColumnName="assetId,tagId",s.$useCache=!1,s.$pkColumnNames=["assetId","tagId"]},61204:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeMonthTag=t.normalizeDateTags=t.getMonthTags=void 0;const r=i(19851),s=i(50213),n=i(97352),a=i(75020),o=i(4407),l=i(48723),u=`'${a.TagRoots.When}' || char(31) || '%' || char(31) || '%' || char(31)`,c=u+" || '%' || char(31)",d=(0,r.lazy)((()=>(0,s.mkLogger)("model.DateTagNormalizer")));function h(){return l.Tag.ops().allf((e=>e.whereNotNull("ordinal").andWhereRaw("_path LIKE "+u+" AND _path NOT LIKE "+c).limit(2400)))}function f(e){const t=(0,n.mapGt0)(e.ordinal,(e=>(0,o.monthTagRef)((0,o.ordinalToMonth)(e))));null==t?d().warn("failed to fix tag (no monthTagRef)",{t:e}):t.name!==e.name&&(d().info("Fixing month name",{tagRef:t,tag:e}),e.changeName(t.name)),e.maybeUpsertDisplayName(t?.displayName)}t.getMonthTags=h,t.normalizeDateTags=async function(){for(const e of h())f(e)},t.normalizeMonthTag=f},31687:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Heartbeat=void 0;const r=i(38835),s=i(42659),n=i(31586),a=i(72761);class o extends a.TimestampedModel{static ping(e){return o.ops().upsertOne({name:e})}static assertPing_(e="ping-"+Date.now()){if(null==o.db())throw new Error("no library is open"+r.NoLibraryErrorFlag);try{o.ping(e);const t=o.ops().findOneBy({name:e});if(null==t||t.name!==e||(0,n.lt)(t.updatedAt,Date.now()-20*s.secondMs))throw new Error("Heartbeat row wasn't inserted")}finally{try{o.dbl.runf((t=>t.delete().where({name:e})))}catch{}}}}t.Heartbeat=o,o.$tableName="Heartbeat",o.$uniqueColumnName="name",o.$useCache=!1},95700:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runMaintenanceTasks=void 0;const r=i(19851),s=i(56038),n=i(28874),a=i(42659),o=i(41400),l=i(69032),u=i(61204),c=i(49796);t.runMaintenanceTasks=async function({force:e}={}){await d(),await(!0===e?h.refresh():h());try{await(!0===e?(0,l.forceRunTagMaintenance)():(0,l.runTagMaintenance)())}catch{}};const d=(0,r.lazy)((()=>(0,s.time)("db.normalizeDateTags",u.normalizeDateTags))),h=(0,r.lazy)((()=>(0,s.time)("db.Progress.vacuum",(()=>c.Progress.vacuum()))),2*a.hourMs);(0,o.later)((()=>{n.Settings.libraryDir.watchLater((()=>{d.unset(),h.unset()}))}))},55046:(e,t,i)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const s=i(57975),n=i(50213),a=i(7282),o=i(65211),l=i(40958),u=i(38639),c=i(45599),d=i(31586),h=i(68708),f=i(34666),m=i(54993),p=i(57038),g=i(94448),y=i(33572),v=i(63872);class w{constructor(){this.$instanceId=(0,a.isTest)()?(0,o.uid)():void 0}static get $ctor(){return this.$schema+"."+this.$tableName}static query(){return(0,p.knex)()(this.$tableName)}static queryBy(e){return this.query().where(e)}static queryOneBy(e){return this.queryBy(e)}static ops(){return this._ops??(this._ops=new v.ModelOps(this,this.db))}static get dbl(){return this.ops().dbl}static rows(){return this.ops().rows()}static truncate(){if((0,a.isProd)())throw new Error("rejecting attempt to truncate in prod");this.dbl.run("DELETE FROM "+this.$tableName)}static ucn(e){const t=this.$uniqueColumnName.split(",").map((t=>e[t]));return t.some((e=>null==e))?void 0:1===t.length?t[0]:t.join(",")}static hasId(e){return this.$pkColumnNames.every((t=>null!=e[t]))}static pickId(e){return(0,h.pick)(e,...this.$pkColumnNames)}$ops(){return this.class().ops()}class(){return this.constructor}$pk(){return(0,m.toS)(this.id)}$ucn(){return this.class().ucn(this)}$tableName(){return this.class().$tableName}$uid(){return`${this.$tableName()}(${this.id??this.$ucn()})${!0===this.shown?"!":""}`}logger(){return(0,n.mkLogger)(this.class().$schema+"."+(0,m.toS)(this.valueOf()))}[s.inspect.custom](){return{...this.$toShallowJSON(),$instanceId:this.$instanceId}}toString(){return this.$uid()}valueOf(){return this.$uid()}static fromJSON(e){return(0,y.fromJSON)(this,e)}static toJSON(e){return this.fromJSON(e).toJSON()}$toShallowJSON(){return this.$_toJSON({encodeBool:u.isTrue})}$toDbJSON(e){return this.$_toJSON({encodeBool:u.boolToInt,includeCtor:!1,includeTransient:!1,colNames:e})}$clone(){return(0,y.fromJSON)(this.class(),this.toJSON())}toJSON(){return this.$_toJSON({encodeBool:u.isTrue})}_get(e,t,i=!0){const r=this[e];return null===r?[e,null]:!(0,f.isPrimitive)(r)||!i&&(0,l.includes)(this.class().$transientFields,e)?void 0:(0,l.includes)(this.class().$booleanFields,e)?[e,t(r)]:[e,r]}$_toJSON({encodeBool:e,includeCtor:t=!0,includeTransient:i=!0,colNames:r}){const s=this.class(),n=(0,l.notEmptyOr)(r,s.ops().columnNames());return(0,h.fromEntries)(n.map((t=>this._get(t,e,i))),t?{$ctor:s.$ctor}:{})}insert(){return this.logger().debug("insert()",{self:this.toJSON()}),this.class().ops().insertOne(this)}update(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("update()",{self:this.toJSON()}),this.class().ops().updateOne(this)}upsert(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("upsert()",{self:this.toJSON(),arg:e}),this.class().ops().upsertOne(this)}$afterInsert(){}$beforeUpsert(){}$afterUpsert(){}reload(){return this.class().ops().reloadOne(this)}delete(){(0,d.gt0)(this.id)&&this.class().ops().delete([this.id])}}t.Model=w,r=w,w.$schema="models",w.$logger=(0,c.defer)((()=>(0,n.mkLogger)(r.$schema+"."+r.$tableName))),w.db=g.modelDb,w.$pkColumnNames=["id"]},94448:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryModelDbFile=t.modelDb=void 0;const r=i(15056),s=i(87290),n=i(19851),a=i(55835);t.modelDb=(0,n.lazy)((()=>{})),t.libraryModelDbFile=function(e){return(0,a.map)((0,s.libraryDataDirPosixFile)(e),(e=>(0,r.pathToDb)(e,"models")))}},33572:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toJSON=t.assignFromJSON=t.fromJSON=t.addModelClass=void 0;const r=i(50213),s=i(40958),n=i(22573),a=i(38639),o=i(97790),l=i(51926),u=new Map;function c(e){u.set(e.$ctor,e)}function d(e,t,i=[]){const r=e.class();for(const[n,o]of Object.entries(t)){if("$ctor"===n)continue;if(void 0===o)continue;const t=(0,l.stripPrefixes)(n,i);e[t]=null==o?o:(0,s.includes)(r.$booleanFields,t)?(0,a.isTrue)(o):o}return e}t.addModelClass=c,t.fromJSON=function(e,t){if(null==t)throw new Error("json is null");if(null!=e&&(0,n.notBlank)(e.$ctor)&&!u.has(e.$ctor)&&c(e),t instanceof e)return t;const i=(0,o.opt)(t.$ctor).flatMap((e=>u.get(e))).getOrElse((()=>e));if(t instanceof i)return t;const r=new i;return null==t?r:d(r,t,(0,s.uniq)([e.$tableName+".",i.$tableName+"."]))},t.assignFromJSON=d,t.toJSON=function e(t,i,s){if(null!=t)return Array.isArray(t)?t.map(((t,r)=>e(t,i,`${s}[${r}]`))):"function"==typeof t.toJSON?t.toJSON():void(0,r.mkLogger)("ModelJSON.toJSON()").warn("Failed",{m:t,key:s,mc:i.$ctor})}},63872:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ModelOps=void 0;const f=i(48884),m=i(19851),p=i(50213),g=i(81168),y=i(48299),v=i(12943),w=i(38835),b=i(34102),S=i(28874),P=i(40958),_=i(76790),M=i(22573),T=i(50357),E=i(96249),k=i(98553),D=i(55835),x=i(31586),C=i(68708),F=i(59455),A=i(86859),I=i(33572);t.ModelOps=class{constructor(e,t){r.add(this),this.model=e,this.db=t,s.set(this,void 0),n.set(this,!0),a.set(this,new y.WeakCache),o.set(this,new Set),this.columnNames=(0,m.lazy)((()=>this.db().tableInfo_().find((e=>(0,g.equalsIgnoreCase)(e.tableName,this.tableName))).columns.map((e=>e.name)))),this.updatableColumnNames=(0,m.lazy)((()=>(0,P.diff)(this.columnNames(),this.immutableColumnNames))),this.ucnFieldNames=(0,m.lazy)((()=>this.ucn.split(","))),d(this,s,(0,p.mkLogger)(`ModelOps(${e.$tableName})`),"f"),(0,I.addModelClass)(e),d(this,n,e.$useCache??!0,"f"),this.dbl=new A.DbRequest(this.db,e.$tableName),(0,b.ee)().on("clearCache",(()=>h(this,a,"f").clear())),(0,b.ee)().on("clearDbCache",(()=>h(this,a,"f").clear()))}clearDbCache(){h(this,a,"f").clear()}get $cache(){return h(this,a,"f")}$cachedByJson(e){if(null==e||!h(this,n,"f"))return;const t=this.$pickModelUcn(e);return(null==t?void 0:h(this,a,"f").get((0,k.stringify)(t)))??this.$cachedById(e.id)}$cachedById(e){return(0,x.gt0)(e)&&h(this,n,"f")?h(this,a,"f").get((0,k.stringify)(e))??h(this,a,"f").findEntry((t=>t.id===e)):void 0}get dbOpen(){return(0,D.mapOr)(this.db(),(e=>e.isOpen),(()=>!1))}get tableName(){return this.model.$tableName}query(){return this.model.query()}toDbValued(e){const t=this.model.fromJSON(e),i=(0,v.toDbValued)(t);return(0,C.pick)(i,...this.columnNames())}run(e){return this.dbl.run(e)}fromJSON(e){if((0,C.isEmptyObj)(e))return;const t=this.model.fromJSON(e);return h(this,r,"m",u).call(this,t)}fromJSONs(e){return(0,P.compact)(e.map((e=>this.fromJSON(e))))}first(e){return this.fromJSON(this.dbl.first(e))}firstf(e){return this.first(e(this.query()))}all(e=this.query()){return this.fromJSONs(this.dbl.all(e))}allf(e){return this.all(e(this.query()))}findOne(e){return this.fromJSON(this.dbl.first(e))}findOneBy(e){return this.findOne(this.model.query().where(e))}findById(e,t){return this.findOneBy({...t,id:e})}findByIds(e){e=(0,F.toA)(e).filter(x.gt0);const t=[],i=[];for(const r of e){const e=this.$cachedById(r);null!=e?t.push(e):i.push(r)}const r=(0,f.batches)(i,S.Settings.dbBatchSelectSize.valueOrDefault).map((e=>this.dbl.all(this.query().whereIn("id",e))));return(0,_.sortBy)([...t,...this.fromJSONs((0,E.flatten)(r))],(t=>e.indexOf(t.id)))}findBy(e){return this.all(this.model.queryBy(e))}findWhereIn(e,t){return this.all(this.model.query().whereIn(e,t))}rows(e){return this.count(e??this.model.query().count())}count(e){return(0,x.toGt0)(this.dbl.pluckFirst(e))??0}countf(e){return this.count(e(this.query()))}insert(e){return(0,F.toA)(e).map((e=>this.insertOne(e)))}upsertOne(e){return this.modelSupportsUpsert?this.upsert([e])[0]:this.insertOrUpdateOne(e)}insertOrUpdateOne(e){return null==e.id?this.insertOne(e):this.updateOne(e)}insertOne(e){if(this.model.hasId(e))throw new Error("insert called for "+(0,k.stringify)(e)+w.NonRetriableErrorFlag);const t=this.fromJSON(e);if(null==t)return h(this,s,"f").throw("insertOne(): fromJSON returned null"+w.InternalErrorFlag,{t:e});t instanceof this.model&&h(this,r,"m",u).call(this,t),t.$beforeUpsert();const i=t.$toDbJSON(this.columnNames()),n=this.dbl.runf((e=>e.insert(i)));return t.id=(0,x.toInt)(n.lastInsertRowid),t.$afterInsert(),t.$afterUpsert(),t}unsetField(e,t){return(0,D.map)(this.$cachedById(e),(e=>{e[t]=null})),this.dbl.runf((i=>i.where({id:e}).update(t,null)))}updateOne(e){if(null==e.id)throw new Error("update called for "+(0,k.stringify)(e)+w.NonRetriableErrorFlag+w.InternalErrorFlag);const t=this.model.fromJSON(e);t.$beforeUpsert();const i=t.$toDbJSON(this.updatableColumnNames());return this.dbl.runf((t=>t.where({id:e.id}).update(i))),t.$afterUpsert(),h(this,r,"m",u).call(this,t)??t}get ucn(){return(0,M.toNotBlank)(this.model.$uniqueColumnName)??"id"}get modelSupportsUpsert(){return null!=this.ucn&&"id"!==this.ucn}get ucnConstraint(){return`(${this.ucn})`}get immutableColumnNames(){return(0,P.uniq)([...this.ucnFieldNames(),"id","createdAt"])}onConflictClause(e){const t=this.immutableColumnNames,i=e.filter((e=>!t.includes(e))).sort().map((e=>`${e}=excluded.${e}`)).join(","),r=["ON CONFLICT",this.ucnConstraint];return(0,M.blank)(i)?r.push("DO NOTHING"):r.push("DO UPDATE SET",i),r.join(" ")}$pickModelUcn(e){const t={};for(const i of this.ucnFieldNames()){const r=e[i];if(null==r)return;t[i]=r}return t}reloadOne(e){if(h(this,o,"f").has(e.id))return;const t=this.$pickModelUcn(e);if(null!=t){const i=h(this,r,"m",u).call(this,e),s=this.findOneBy(t);if(null==s)return;return h(this,r,"m",l).call(this,i,s),i!==e&&h(this,r,"m",l).call(this,e,i),i}h(this,s,"f").warn(".reloadOne(): failed to reload "+(0,k.stringify)(e))}reload(e){const t=[],i=this.allf((i=>{for(const r of e){const e=this.model.hasId(r)?this.model.pickId(r):this.$pickModelUcn(r);null!=e?(t.push([r,e]),i=i.orWhere(e)):h(this,s,"f").warn("reload(): given insufficient partial model",{fragment:r})}return i})),n=[];for(const[e,a]of t){const t=i.find((e=>(0,T.eqlSubset)(a,e)));if(null==t)h(this,s,"f").warn("reload(): failed to find result in db",{prior:e,dbArr:i});else{const i=h(this,r,"m",u).call(this,e);h(this,r,"m",l).call(this,i,t),i!==e&&h(this,r,"m",l).call(this,i,t),n.push(t)}}return n}upsert(e){if(e=(0,P.compact)(e),!this.modelSupportsUpsert)return e.map((e=>this.insertOrUpdateOne(e)));const t=this.columnNames(),i=[];for(const s of(0,f.batches)((0,F.toA)(e),S.Settings.dbBatchUpsertSize.valueOrDefault)){const e=new Map,n=new Set,a=(0,P.compact)(s.map((e=>this.fromJSON(e))));for(const t of a){const i=(0,k.stringify)(this.$pickModelUcn(t));e.set(i,t),this.model.hasId(t)||n.add(i),t.$beforeUpsert()}h(this,r,"m",c).call(this,a.map((e=>e.$toDbJSON(t))));const o=this.reload(a),l=new Map(o.map((e=>[(0,k.stringify)(this.$pickModelUcn(e)),e])));for(const e of a){const t=(0,k.stringify)(this.$pickModelUcn(e)),r=l.get(t)??e;n.has(t)&&r.$afterInsert(),r.$afterUpsert(),i.push(r)}}return i}delete(e){const t=(0,F.toA)(e).filter(x.gt0);for(const e of t)h(this,o,"f").add(e);return h(this,a,"f").deleteValueIf((e=>t.includes(e.id))),this.run(this.model.query().delete().whereIn("id",t))}async batched(e){const t=e.batchSize??S.Settings.dbBatchSelectSize.valueOrDefault;let i,r;do{i=this.allf((i=>(i=e.qb(i),null!=r&&(i=i.andWhere("id",">",r)),i.orderBy("id","asc").limit(t)))),(0,P.isNotEmpty)(i)&&(r=Math.max(...i.map((e=>e.id))),await e.onResults(i))}while((0,P.isNotEmpty)(i))}},s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function(e,t){(0,C.assignFields)(e,t,{omitKeys:["$instanceId"],assignNullish:!0})},u=function(e){if(h(this,n,"f")){const t=this.$cachedByJson(e);if(null!=t)return h(this,r,"m",l).call(this,t,e),t;{const t=this.$pickModelUcn(e)??e.id;null!=t&&h(this,a,"f").set((0,k.stringify)(t),e)}}return e},c=function(e){const t=this.query().insert(e).toSQL(),i=new Set;for(const t of e)for(const e of(0,C.keys)(t))i.add(e);const s={sql:t.sql+" "+this.onConflictClause([...i.values()]),bindings:t.bindings};this.run(s);for(const t of e){const e=this.$cachedByJson(t);null!=e&&h(this,r,"m",l).call(this,e,this.model.fromJSON(t))}}},20958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Operation=t.OperationNames=void 0;const r=i(19851),s=i(50213),n=i(88158),a=i(99331),o=i(70025),l=i(8769),u=i(22573),c=i(98553),d=i(50989),h=i(72761);t.OperationNames=(0,d.strEnum)("rebuildLibrary","forceRestartSync");const f=(0,r.lazy)((()=>(0,s.mkLogger)("model.Operation")));class m extends h.TimestampedModel{static incomplete(){return this.ops().allf((e=>e.whereIn("id",(e=>e.table(m.$tableName).min("id").whereNull("completedAt")))))}static ensurePendingOp(e){return m.getFirstPendingOp(e)??m.ops().insertOne(e)}static getFirstPendingOp(e){return f().tap({msg:"getFirstPendingOp",level:"info",result:this.ops().firstf((t=>{const i=t.whereNull("completedAt").orderBy("createdAt","asc");return null!=e?i.andWhere(e):i})),meta:{crit:e}})}static markOpCompleted(e,t){return(0,u.blank)(e?.name)?f().throw("markOpCompleted(): bad query",{crit:e}):this.dbl.runf((i=>i.whereNull("completedAt").andWhere(e).update({completedAt:Date.now(),...t})))}static async applyIfPending(e,t){const i=this.ops().firstf((t=>t.whereNull("completedAt").andWhere(e)));return f().info("applyIfPending()",{crit:e,op:i}),null==i?void 0:t(i)}static async applyOnce_(e,t,i=n.identity){const r=this.ops().firstf((t=>i(t.whereNotNull("completedAt").andWhere(e))));if(null!=r)return void f().debug("applyOnce(): already done",{priorCompleted:r});const s=this.ops().insertOne(e);try{const e=await t(s);return(0,a.ending)()||s.markCompleted(),e}catch(t){if((0,o.isRedoableError)(t))return void f().info("applyOnce(): redoable error",{crit:e,error:t});throw(0,l.onError)("Operation.applyOnce(): "+(0,c.stringify)(e),t),t}}markCompleted(){null==this.completedAt&&(this.completedAt=Date.now(),this.upsert())}}t.Operation=m,m.$tableName="Operation",m.$uniqueColumnName="id",m.$useCache=!1},49796:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Progress=t.defaultMinCreatedAt=t.toPct=void 0;const r=i(48161),s=i(1708),n=i(48884),a=i(50213),o=i(28874),l=i(40958),u=i(42659),c=i(45599),d=i(98553),h=i(55835),f=i(31586),m=i(68708),p=i(67478),g=i(51926),y=i(59455),v=i(54993),w=i(76386),b=i(33572),S=i(55009),P=i(72761),_=(0,c.defer)((()=>(0,a.mkLogger)("model.Progress")));function M(e){return null==e||!(0,f.isNumber)(e)||e<0||e>100?void 0:(0,f.sigFigs)(e,3)}t.toPct=M;const T=(0,g.compressWhitespace)("\nSELECT\n p1.uri,\n p1.id as lastProgressId,\n p1.createdAt as lastStartedAt,\n p1.updatedAt as lastUpdatedAt,\n p3.lastCompletedAt\nFROM\n Progress AS p1\n JOIN (\n SELECT\n uri,\n max(updatedAt) AS lastUpdatedAt\n FROM\n Progress\n GROUP BY\n 1\n ) AS p2 ON p1.uri = p2.uri\n AND p1.updatedAt = p2.lastUpdatedAt\n LEFT JOIN (\n SELECT\n uri,\n max(completedAt) AS lastCompletedAt\n FROM\n Progress\n WHERE\n CAST(completedAt AS int) > 0\n GROUP BY\n 1\n ) AS p3 ON p1.uri = p3.uri\nGROUP BY\n p1.uri");function E(){const e=o.Settings.progressStaleDays.valueOrDefault;return e<=0?0:Date.now()-e*u.dayMs}t.defaultMinCreatedAt=E;class k extends P.TimestampedModel{static vacuum(e=o.Settings.progressRetentionDays.valueOrDefault*u.dayMs){const t=Date.now()-e,i=this.dbl.pluckAllf((e=>e.select("id").where("createdAt","<=",t)));for(const e of(0,n.batches)(i,o.Settings.dbBatchSelectSize.valueOrDefault))S.ProgressMeta.dbl.runf((t=>t.whereIn("progressId",e).delete())),k.dbl.runf((t=>t.whereIn("id",e).delete()))}static countCompletedDirectorySyncs(){return this.dbl.pluckFirstf((e=>e.where({state:"done"}).whereNotNull("completedAt").where("uri","like","ps%")))}static times(){return _().tap({msg:"times()",result:this.dbl.all({sql:T})})}static insertNew(e){const t=(0,h.map)(e.dek,d.stringify);return this.ops().insertOne({...(0,m.omit)(e,"dek"),dekJSON:t})}upsert(e){return null!=e&&this.assignFromPojo(e),super.upsert()}$beforeUpsert(){super.$beforeUpsert(),null==this.id&&(this.pid??(this.pid=s.pid),this.hostname??(this.hostname=(0,r.hostname)())),"done"===this.state&&(this.completedAt??(this.completedAt=Date.now())),this.completePct=M(this.completePct),this.incompletePct=M(this.incompletePct),this.scanningPct=M(this.scanningPct)}$afterUpsert(){super.$afterUpsert(),(0,w.tellWebProgressUpdated)()}toSyncState(){return{id:this.id,uri:this.uri,volume:this.volume,state:this.state,hed:this.hed,dek:this.dek,completePct:this.completePct,incompletePct:this.incompletePct,scanningPct:this.scanningPct}}get dek(){return(0,l.compactBlanks)((0,p.parseJSON)(this.dekJSON))}set dek(e){var t;this.dekJSON=(t=e,(0,d.stringify)((0,l.compactBlanks)((0,y.toA)(t))))}assignFromPojo(e){return(0,b.assignFromJSON)(this,(0,m.omit)(e,"volume","uri"))}getMeta(){return S.ProgressMeta.ops().allf((e=>e.where({progressId:this.id}).orderBy("createdAt")))}getPriorIncomplete(e=E()){return this.logger().tap({msg:"priorIncompleteProgress()",result:k.ops().firstf((t=>t.where({hostname:this.hostname,uri:this.uri,completedAt:null}).andWhere("createdAt",">",e).orderBy("updatedAt","desc")))})}getLastCompletedAt(e=E()){return k.dbl.pluckFirstf((t=>t.max("completedAt").where({uri:this.uri}).andWhere("createdAt",">",e)))}getLastIncompleteStartAt(){return k.dbl.pluckFirstf((e=>e.min("createdAt").where({uri:this.uri}).andWhere("createdAt",">",this.getLastCompletedAt()??0)))}setMeta(e,t){return this.logger().debug("setMeta()",{progressId:this.id,name:e,value:t}),S.ProgressMeta.ops().upsertOne({progressId:this.id,name:e,value:t})}setMetaRecord(e){const t=this.getMeta(),i=(0,l.diff)(t.map((e=>e.name)),Object.keys(e));this.logger().debug("setMetaRecord()",{progressId:this.id,keysToDelete:i,record:e}),S.ProgressMeta.ops().upsert((0,m.entries)(e).map((([e,t])=>({progressId:this.id,name:e,value:(0,v.toS)(t)})))),(0,l.isNotEmpty)(i)&&S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).whereIn("name",i).delete()))}deleteMeta(...e){return this.logger().debug("deleteMeta()",{progressId:this.id,names:e}),S.ProgressMeta.dbl.runf((t=>t.whereIn("name",e).andWhere({progressId:this.id}).delete()))}deleteAllMeta(){return this.logger().debug("deleteAllMeta()",{progressId:this.id}),S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).delete()))}getMetaAsRecord(){return this.logger().tap({msg:"getMetaAsRecord()",result:(0,m.fromEntries)(this.getMeta().map((e=>[e.name,e.value])))??{}})}}t.Progress=k,k.$tableName="Progress",k.$uniqueColumnName="id"},55009:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressMeta=t.ProgressMetaNames=t.DirSyncProgressMetaNames=void 0;const r=i(50989),s=i(72761);t.DirSyncProgressMetaNames=(0,r.strEnum)("lastScannedDirectory","scannedDirectoryCount","completedDirectoryScan","enqueuedStaleFiles","processedImageCount","processedVideoCount","completedDirectorySync"),t.ProgressMetaNames=(0,r.strEnum)(...t.DirSyncProgressMetaNames.values);class n extends s.TimestampedModel{}t.ProgressMeta=n,n.$tableName="ProgressMeta",n.$uniqueColumnName="progressId,name"},39604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.upsertToShaBlockslist=t.upsertFileToShaBlockslist=t.isShaBlockslisted=t.notBlocklistedSha=void 0;const r=i(19851),s=i(50213),n=i(95696),a=i(40958),o=i(22573),l=i(86859),u=i(94448),c=(0,r.lazy)((()=>(0,s.mkLogger)("model.ShaBlocklist"))),d=(0,r.lazy)((()=>new l.DbRequest(u.modelDb,"ShaBlocklist")));function h(e){return null!=(0,u.modelDb)()&&!(0,o.blank)(e)&&c().tap({msg:"isShaBlockslisted",result:null!=d().pluckFirstf((t=>t.where({sha:e}).limit(1))),meta:{sha:e}})}function f(...e){if(null==u.modelDb.prior())return;const t=(0,a.uniq)(e).map((e=>({sha:e})));return(0,a.isEmpty)(t)?void 0:d().upsert((e=>e.insert(t)))}t.notBlocklistedSha=async function(e){if(null==(0,u.modelDb)())return null;const t=h(await n.PosixFile.for(e).sha());return null==t?null:!t},t.isShaBlockslisted=h,t.upsertFileToShaBlockslist=async function(e){if(null==(0,u.modelDb)())return;const t=await n.PosixFile.for(e).sha();return null==t?void 0:f(t)},t.upsertToShaBlockslist=f},48723:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Tag=t.UpdateTagAssetCountTimeName=void 0;const a=i(56038),o=i(34102),l=i(19851),u=i(50213),c=i(36372),d=i(97352),h=i(28874),f=i(81168),m=i(42231),p=i(75020),g=i(40958),y=i(22573),v=i(42659),w=i(41400),b=i(50357),S=i(55835),P=i(31586),_=i(34666),M=i(20214),T=i(51926),E=i(59455),k=i(12168),D=i(6186),x=i(57038),C=i(21074),F=i(7656),A=i(43487),I=i(48722),O=i(45295),L=i(98784),R=i(41507),N=i(72761),B=4*v.secondMs,j=(0,l.lazy)((()=>(0,u.mkLogger)("model.Tag")));(0,w.later)((()=>{(0,o.ee)().on("clearCache",(()=>z.clear())),(0,o.ee)().on("clearDbCache",(()=>z.clear()))})),t.UpdateTagAssetCountTimeName="db.updateTagAssetCountTimeName";class z extends N.TimestampedModel{constructor(){super(...arguments),this.displayPath=(0,l.lazy)((()=>{const e=this.getParent();return(0,g.compactBlanks)([...null==e?[]:e.displayPath(),this.displayName])})),this.ancestorIds=(0,l.lazy)((()=>0===this.parentId||null==this.parentId?[]:r.dbl.pluckAll({sql:(0,T.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.id","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}}))),this.firstNonInterstitialTagId=(0,l.lazy)((()=>{if(!this.isRoot&&0===this.directAssetCount()&&1===this.getChildrenCount()){const e=this.getChildren();if(1===e?.length)return e[0].firstNonInterstitialTagId()}return this.id})),this.directAssetCount=(0,l.lazy)((()=>0===this.id?0:A.Asset.dbl.pluckFirst(A.Asset.shownUnhidden().join("AssetTag","AssetTag.assetId","Asset.id").where("AssetTag.tagId",this.id).countDistinct("Asset.id"))))}static orderBy(e){return e.orderByRaw("COALESCE(ordinal, _path) COLLATE NOCASE")}static clear(){this.root.unset(),this.roots.unset(),this._upsertDefaultRoots.unset(),this.ops().clearDbCache()}static validate_(){return(0,a.timeSync)("Tag.validate_",(()=>{r.clear();for(const e of this.ops().allf((e=>e.whereRaw("id = parentId")))){j().warn(`Tag ${e.id} has itself as parentId. Attempting to fix...`);const t=e.path.slice(0,-1),i=(0,g.isEmpty)(t)?void 0:this.findOrCreate(t);e.update({parentId:i?.id??null})}for(const e of r.roots())e.validate_([])}))}validate_(e){const t=this.path;if(!(0,b.eql)(t.slice(0,-1),e))throw new Error(`Tag:${this.id} path ${t.join("/")} does not match expected parent ${e.join("/")}`);for(const e of this.getChildren())e.validate_(t)}static deltaAssetCountAndAncestors(e,t=1){return r.incrAssetCount(r.selfAndAncestorIds(e),t)}static incrAssetCount(e,t=1){(0,g.isEmpty)(e)||r.dbl.runf((i=>i.whereIn("id",e).andWhereNot({assetCount:null}).update({assetCount:(0,x.knex)().raw("assetCount + "+Math.round(t)),updatedAt:Date.now()})))}static selfAndAncestorIds(e){const t=(0,E.toA)(e).filter(P.gt0);return r.dbl.pluckAll({sql:(0,T.compressWhitespace)("WITH RECURSIVE ancestors(id) AS ("," SELECT id FROM Tag where id in "+(0,C.sqlWhereInClause)(t.length)," UNION ALL"," SELECT Tag.parentId as id"," FROM Tag, ancestors"," WHERE Tag.id = ancestors.id",")","SELECT distinct(id)","FROM ancestors","WHERE id IS NOT NULL"),bindings:t})}static updateAssetCount(e){if((0,P.gt0)(e))return(0,a.timeSync)(t.UpdateTagAssetCountTimeName,(()=>{const t=r.dbl.pluckFirst({sql:F.RecursiveAssetCountForTagQuery,bindings:{tagId:e}});r.dbl.runf((i=>i.update({assetCount:t,updatedAt:Date.now()}).where({id:e}))),j().debug("Updated asset counts for tag ",{tagId:e,assetCount:t})}))}static findByIdOrPath(e,t){return 0===e?r.root():(0,P.gt0)(e)?this.findById(e):this.findByPath(t)}static findById(e){return 0===e?r.root():this.ops().findById(e)}static findByPath(e){if((0,g.isEmpty)(e))return r.root();const t=(0,m.joinTagPath)(e);return this.ops().firstf((e=>e.whereLike("_path",t)))}static findByPathN(e){const t=(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,y.toNotBlank)((0,m.joinTagPath)(e))));return(0,g.compact)(t.map((e=>this.findByPath(e))))}static getPagedAssets(e,t){const i=new r;return i.id=e,i.getPagedAssetIds(t)}static findOrCreate(e){if((0,g.isEmpty)(e))throw new Error("empty tagPath");const t=this.findByPath(e);if(null!=t)return t;const i=n(this,r,"m",s).call(this,e),a=i.depth<=1?void 0:this.findOrCreate(e.slice(0,-1));return(0,S.map)(a,(e=>i.parentId=e.id)),this.ops().upsertOne(i)}static findOrCreateByPathN(e){return(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,m.joinTagPath)(e))).map((e=>this.findOrCreate(e)))}clear(){return this.parent=void 0,this.root=void 0,this.children=void 0,this.ancestors=void 0,this.assets=void 0,this.relatedAssets=void 0,this.ancestorIds.unset(),this}$afterInsert(){L.TagFts.insertFts([this])}siblingPath(e){return(0,m.joinTagPath)([...this.parentPath,e])}changeName(e){return this.changePath(this.siblingPath(e))}maybeUpsertDisplayName(e){return(0,y.blank)(e)||e===this._displayName?void 0:this.upsert({_displayName:e})}changePath(e,t=!0){const i=this._path,s=r.findByPath((0,m.splitTagPath)(e));this.logger().info("changePath(): ",{priorPath:i,newPath:e,existingSibling:s});try{if(null==s)r.dbl.runf((t=>t.whereLike("_path",i+"%").update({updatedAt:Date.now(),_path:(0,x.knex)().raw("REPLACE(_path, ?, ?)",[i,e])}))),this._path=e;else{e=s._path,this.logger().info("changePath(): replacing with sibling",e),O.AssetTag.dbl.upsert((e=>e.where({tagId:this.id}).update({tagId:s.id}))),O.AssetTag.dbl.runf((e=>e.where({tagId:this.id}).delete()));for(const e of this.getChildren())e.changePath((0,m.joinTagPath)([...s.path,e.name]),!1);r.dbl.runf((e=>e.where({parentId:this.id}).update({parentId:s.id}))),this.delete()}}finally{t&&r.clear()}}get name(){const e=this.path;return e[e.length-1]}get path(){return(0,m.splitTagPath)(this._path)}get displayName(){return(0,y.toNotBlank)(this._displayName)??this.name}get isRoot(){return 0===this.id}get depth(){return this.path.length}get parentPath(){return this.path.slice(0,-1)}get sortBy(){return[this.depth,null==this.ordinal?2**51:this.ordinal,this.path.map((e=>e.toLowerCase()))]}$childrenQuery(){return r.orderBy(r.query().where({parentId:this.id}))}$assetsQuery(){return A.Asset.shownUnhidden().columns("Asset.*").join("AssetTag","AssetTag.assetId","Asset.id").where({tagId:this.id})}$selectAssetIdColumns(e){return e.clearSelect().select({assetId:"Asset.id",capturedAtLocal:"Asset.capturedAtLocal",updateCount:"Asset.updateCount",durationMs:"Asset.durationMs"})}$assetIdsQuery(){return this.$selectAssetIdColumns(this.$assetsQuery())}setAncestors(e){this.ancestors=e,this.parent=e[e.length-1],(0,S.map)(this.parent,(t=>t.setAncestors(e.slice(0,-1))))}async toApiPathElements(){return(0,M.thenCollect)(this.getAncestorsAndSelf(),(e=>e.toPathTag()))}toPathTag(){return{tagPath:this.path,displayName:this.displayName}}toApiTag(){return{tagId:this.id,tagPath:this.path,displayPath:this.displayPath(),description:this.description,assetCount:this.assetCount}}toStringId(){return"Tag("+this.path.join("/")+")"}getParent(){if(!this.isRoot)return null!=this.parentId&&null==this.parent?this.parent=r.findById(this.parentId):this.parent}getPagedChildren(e){if(0===this.id){const t=e.offset??0,i=t+(e.limit??this.children.length);return[...this.children].slice(t,i)}const t=this.$childrenQuery();return(0,d.mapGt0)(e.offset,(e=>{t.offset(e)})),(0,d.mapGt0)(e.limit,(e=>{t.limit(e)})),r.ops().all(t)}getChildrenCount(){return null!=this.children?this.children.length:r.dbl.pluckFirstf((e=>(this.isRoot?e.whereNull("parentId"):e.where({parentId:this.id})).count()))}getChildren(){return this.isRoot||(this.children=r.ops().all(this.$childrenQuery()),this.children.forEach((e=>{e.parent=this}))),this.children}link(){return"/tag/"+this.path.map(encodeURIComponent).join("/")}get rootName(){return this.path[0]}get ancestorsAndSelf(){return[...this.ancestors,this]}getAncestors(){return this.ancestors??(this.ancestors=this._getAncestors())}getAncestorsAndSelf(){return[...this.getAncestors(),this]}_getAncestors(){return 0===this.parentId||null==this.parentId?[]:r.ops().all({sql:(0,T.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.*","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}})}getPagedAssetIds(e){let t=this.$assetIdsQuery();return t=t.limit(p.ThumbsPerSample),(0,P.gt0)(e.offset)&&(t=t.offset(e.offset)),t=t.orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId"}]),(0,g.compact)(A.Asset.dbl.all(t).map(I.toAssetId))}getAssets(){const e=this.$assetsQuery().orderBy("capturedAtLocal","desc");return A.Asset.ops().all(e)}async assetCountDesc(e){const t=this.assetCount;return(null==t||null==e||e.length===t||0===e.length?"":(0,k.fmt)(e.length)+" of ")+(0,k.plur)(t,"asset")}getAssetCount(){return 0===this.id?r.dbl.pluckFirst({sql:(0,T.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," Asset","WHERE"," Asset.shown = 1"," AND Asset.excluded = 0"," AND Asset.hidden = 0"," AND Asset.deletedAt IS NULL")}):r.dbl.pluckFirst({sql:F.RecursiveAssetCountForTagQuery,bindings:{tagId:this.id}})}$assetStreamQuery(e,t,i){let r=this.path[0]===p.TagRoots.When?A.Asset.shownUnhidden():this.$assetsQuery();return r=r.distinct().where("capturedAtLocal",i,e.capturedAtLocal).andWhereNot("Asset.id",e.id).limit("="===i?2*t:t),"="===i?r.orderByRaw(`ABS(Asset.id-${e.id})`):r.orderBy([{column:"capturedAtLocal",order:">"===i?"asc":"desc"},"Asset.id"])}getAssetStream(e,t){t=(0,P.gt0)(t)?t:p.BeforeAfterStreamLimit;const[i,r,s]=["<","=",">"].map((i=>(0,g.compact)(A.Asset.ops().all(this.$assetStreamQuery(e,t,i)).map(I.toAssetId))));for(const t of r)t.assetIdA.Asset.shownUnhidden(this.$selectAssetIdColumns(r)).distinct().join("Asset","Asset.id","AssetTag.assetId").join("Tag","Tag.id","AssetTag.tagId").whereLike("_path",this._path+"%").orderByRaw((0,c.prngOrderByClause)(e+(this.id??0),"Asset.id",i)).limit(t))).map(I.toAssetId));return this.logger().debug(this.path+": Found "+r.length+" related assets"),r}get attrs(){return{href:this.link(),title:this.name}}}t.Tag=z,r=z,s=function(e){const t=new r;t._path=(0,m.joinTagPath)(e);const i=e[e.length-1];return"object"==typeof i&&((0,y.mapNotBlank)(i.displayName,(e=>t._displayName=e)),(0,P.mapNumeric)(i.ordinal,(e=>t.ordinal=e)),(0,y.mapNotBlank)(i.description,(e=>t.description=e)),(0,P.mapNumeric)(i.releasedAt,(e=>t.releasedAt=e))),t},z.$tableName="Tag",z.$uniqueColumnName="_path",z.$useCache=!0,z.cmp=(e,t)=>(0,_.cmp)([e.ordinal??Number.MAX_SAFE_INTEGER,...e.path],[t.ordinal??Number.MAX_SAFE_INTEGER,...t.path]),z.root=(0,l.lazy)((()=>{const e=new r;return e.id=0,e._path=m.TagSep,e.parentId=void 0,e.children=r.roots().filter((e=>!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.name)&&!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.description??""))),e.ancestors=[],e.assetCount=A.Asset.shownCount(),e.upsert=()=>{throw new Error("upsert not supported on root")},e}),B),z._upsertDefaultRoots=(0,l.lazy)((()=>r.ops().upsert(D.Roots.map((e=>({_path:(0,m.joinTagPath)([e.name]),ordinal:e.ordinal})))))),z.roots=(0,l.lazy)((()=>{r._upsertDefaultRoots();const e=r.ops().all(r.orderBy(r.query().whereNull("parentId")));for(const t of e)t.parentId=void 0,t.ancestors=[];return e}),B);const V=(0,l.lazy)((()=>A.Asset.dbl.pluckFirstf((e=>e.count()))),v.minuteMs)},98784:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagFts=void 0;const r=i(38156),s=i(3127),n=i(40958),a=i(41400),o=i(94715),l=i(55046),u=i(48723);class c extends l.Model{static insertFts(e){try{const t=e.filter((e=>null!=e.parentId)).map((e=>({rowid:e.id,root:(0,s.tag_fts_root)(e._path),path:(0,s.tag_fts_path)(e._path)})));(0,n.isEmpty)(t)||this.dbl.runf((e=>e.insert(t)))}catch(e){this.$logger().warn("Failed to update tag_fts",{error:e})}}static async rebuild(){const e=new r.PushProgressObserver({op:"Rebuilding tag search index"},u.Tag.dbl.pluckFirstf((e=>e.count("*")))),t=this.dbl.db();o.Migrations.create_tag_fts(t.db),await u.Tag.ops().batched({qb:e=>e,onResults:t=>(this.$logger().throwIfAborted_(),this.insertFts(t),e.incrProgress(t.length),(0,a.delay)(1))}),e.completed()}}t.TagFts=c,c.$tableName="tag_fts",c.$uniqueColumnName="rowid",c.$booleanFields=[]},41507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.coalesceStreams=t.TaggedAssetStream=t.cmpAssetDesc=t.cmpAssetAsc=void 0;const r=i(48884),s=i(50213),n=i(28874),a=i(40958),o=i(76790),l=i(31586),u=i(34666),c=i(20214),d=i(59455);t.cmpAssetAsc=(e,t)=>(0,u.cmp)([e.capturedAtLocal,e.id],[t.capturedAtLocal,t.id]),t.cmpAssetDesc=(e,t)=>(0,u.cmp)([t.capturedAtLocal,t.id],[e.capturedAtLocal,e.id]),t.TaggedAssetStream=class{constructor(e,t,i,r){this.tags=e,this.before=t,this.after=i,this.limit=r,this.logger=()=>(0,s.mkLogger)("model.TaggedAssetStream("+this.toString()+")"),this.logger().info("new",this.toJSON())}vacuum(){(0,o.sortByInPlace)(this.before,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainFirstN)(this.before,this.limit),(0,o.sortByInPlace)(this.after,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainLastN)(this.after,this.limit)}toString(){return this.tags.map((e=>e.path.join("/"))).join(",")}valueOf(){return this.toString()}get length(){return(0,d.toA)(this.before).length+(0,d.toA)(this.after).length}leftPad(e){return[...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+1),capturedAtLocal:-1,v:0}))),...e]}rightPad(e){return[...e,...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+this.limit+1),capturedAtLocal:-1,v:0})))]}toJSON(){return{tags:this.tags.map((e=>e.toString())),assetIdsAfter:this.after,assetIdsBefore:this.before}}mergeWith(e){(0,a.pushUniqBy)(this.tags,e.tags,(e=>e.path)),(0,a.pushUniqBy)(this.before,e.before,(e=>e.assetId)),(0,a.pushUniqBy)(this.after,e.after,(e=>e.assetId)),this.logger().debug("mergeWith() complete",{tas:e.toJSON(),tags:this.tags.map((e=>e.path)),beforeIds:this.before,afterIds:this.after})}async toApi(){return this.vacuum(),this.logger().tap({msg:"toApi()",result:{tags:await(0,c.thenCollect)(this.tags,(e=>e.toApiTag())),assetIdsAfter:this.leftPad(this.after),assetIdsBefore:this.rightPad(this.before)}})}streamCoeff(e){return this.logger().tap({msg:"streamCoeff",meta:{this:this.tags.map((e=>e.path)),tas:e.tags.map((e=>e.path))},result:(0,r.diceCoeff)([...this.before,...this.after],[...e.before,...e.after],(e=>e.assetId))})}},t.coalesceStreams=function(e){const t=n.Settings.minStreamCorrPct.valueOrDefault/100,i=[],s=e.filter((e=>e.length>5));for(const e of s){const s=(0,r.greatestBy)(i,(i=>(0,l.gtOrElse)(i.streamCoeff(e),t)));null==s?i.push(e):s.mergeWith(e)}return i}},94710:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Task=t.StaleTaskError=t.InvalidTaskError=t.TaskNames=t.Tasks=t.testTask=void 0;const c=i(78474),d=i(22454),h=i(23560),f=i(12089),m=i(76740),p=i(22911),g=i(99331),y=i(31562),v=i(38835),w=i(70025),b=i(8769),S=i(74128),P=i(28874),_=i(37692),M=i(40958),T=i(22573),E=i(42659),k=i(45599),D=i(98553),x=i(49769),C=i(68708),F=i(50989),A=i(59455),I=i(58723),O=i(34274),L=i(90901),R=i(61989),N=i(93755),B=i(69032),j=i(55046);t.testTask=(0,f.shim1)({name:"testTask",impl:async e=>{}}),t.Tasks={applyDeleted:I.applyDeleted,applyExcluded:I.applyExcluded,runTagMaintenance:B.runTagMaintenance,repairAsset:async function(e){e.forceSync=!0,e.skipPreviews=!0,e.skipAssetTagging=!0;const t=await(0,R.updateAsset_)(e);return(0,M.isNotEmpty)(t?.assetIdsToUpdate)&&H.add(t?.assetIdsToUpdate.map((t=>({fn:"repairAsset",args:{...e,assetId:t},priority:W.repairAsset+1})))),null!=t&&!0!==t.deleted&&(0,T.blank)((0,A.toA)(t.rejected).join(""))&&(0,T.blank)(t.error)&&H.addOne("assetPostUpsertTasks",(0,C.omit)(e,"skipPreviews","skipAssetTagging")),t},assetPostUpsertTasks:L.assetPostUpsertTasks,updateAssetFile:N.updateAssetFile_,syncFile:O.importFileToResult_,testTask:t.testTask},t.TaskNames=(0,F.strEnum)(...(0,C.keys)(t.Tasks));class z extends Error{}t.InvalidTaskError=z;class V extends Error{}t.StaleTaskError=V;const W={applyDeleted:16,applyExcluded:16,runTagMaintenance:14,repairAsset:12,assetPostUpsertTasks:10,updateAssetFile:8,syncFile:0,testTask:-1},U=["repairAsset"];class H extends j.Model{constructor(){super(...arguments),r.add(this),o.set(this,(0,k.defer)((()=>new m.Abortable)))}static countTaskNames(){const e={};for(const t of s.dbl.allf((e=>e.select("fn").count().groupBy("fn"))))e[t.fn]=t["count(*)"];return e}static orderBy(e){return e.orderBy([{column:"priority",order:"desc"},{column:"retries",order:"desc"},{column:"id",order:"asc"}])}static count(){return s.dbl.pluckFirstf((e=>e.count("id")))}static freeSlots(){return P.Settings.taskListCap.valueOrDefault-s.count()}static countByFn(e){return s.dbl.pluckFirstf((t=>t.where({fn:e}).count("id")))}static nextByFn(e,t=(e=>e)){return s.ops().allf((i=>s.orderBy(t(i.where({fn:e})))))}set args(e){this.argsJSON=(0,D.stringify)(e)}get args(){const e=(0,D.parseJSON)(this.argsJSON);return(0,C.notEmptyObj)(e)&&(e.halt=u(this,o,"f").call(this)),e}get isSerial(){return U.includes(this.fn)}toString(){return`Task#${this.fn}(${this.argsJSON})`}static addOne(e,t){return s.add([{fn:e,args:t}])[0]}static add(e,t=!1){if((0,M.isEmpty)(e))return[];const i=s.ops().upsert(e.map((e=>({fn:e.fn,argsJSON:(0,D.stringify)(e.args)})),t));return s.ee.emit("added",i),(0,h.isTaskListManager)()||(0,_.addStateEvent)("checkTasks"),i}$beforeUpsert(){this.priority??(this.priority=W[this.fn]),this.retries??(this.retries=P.Settings.maxRetries.valueOrDefault)}donePromise(){return(0,h.isTaskListManager)()?(0,x.getOrSet)(u(s,s,"f",n),this.id,(()=>new p.Deferred(this.toString(),{payload:this}))):(0,y.untilTrue)((()=>null==s.ops().findById(this.id)),{intervalMs:E.secondMs})}abort(e){this.logger().warn("aborting task",{reason:e,task:this}),u(this,o,"f").call(this).abort(e),this.delete(),(0,T.blank)(this.args.path)||(0,S.syncReport)().onProgress({path:this.args.path,from:this.fn,state:S.SyncFileStates.failed,details:e})}async _run(){if(this.retries<0)throw this.logger().warn(".run(): too many retries"+v.InternalErrorFlag,{job:this}),this.delete(),new z;if(!u(this,r,"m",l).call(this))throw this.logger().warn(".run(): someone already started this task",{job:this}),new V;try{const e=Date.now(),i=await t.Tasks[this.fn](this.args);return this.logger().throwIfAborted_(u(this,o,"f").prior()),s.taskResolvedCounts.incr(this.fn),s.ee.emit("resolved",this,i,Date.now()-e),this.delete(),u(s,s,"f",n).get(this.id)?.resolve(i),i}catch(e){if((0,g.ending)())throw this.logger().info("task failed, but we're ending. We'll leave it for next time.",{task:this}),e;throw s.taskRejectedCounts.incr(this.fn),(0,w.isRedoableError)(e)?(this.retries++,this.priority--,this.upsert()):!0===(0,w.isRetriableError)(e)&&this.retries>=0?this.logger().warn("run failed, but we can retry it later",{task:this,error:e}):(s.ee.emit("rejected",this,e),this.delete(),u(s,s,"f",n).get(this.id)?.reject(e),(0,b.onError)(this.toString()+" failed",e)),e}finally{u(s,s,"m",a).call(s)}}}t.Task=H,s=H,o=new WeakMap,r=new WeakSet,a=function(){for(const[e,t]of u(this,s,"f",n).entries())t.isSettled&&u(this,s,"f",n).delete(e)},l=function(){const e=this.retries;if(1===s.dbl.runf((t=>t.where({id:this.id,retries:e}).update({retries:e-1}))).changes)return--this.retries,!0;{const e=this.toJSON(),t=this.reload();return this.logger().warn(".#decrRetries(): someone already started this task",{before:e,reloaded:t}),!1}},H.$tableName="Task",H.$uniqueColumnName="fn,argsJSON",H.$useCache=!1,H.taskResolvedCounts=new d.CountingSet,H.taskRejectedCounts=new d.CountingSet,H.ee=new c.EventEmitter,n={value:new Map}},72761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimestampedModel=void 0;const r=i(97352),s=i(40958),n=i(31586),a=i(59455),o=i(55046);class l extends o.Model{static touch(e,t={}){t.updatedAt??(t.updatedAt=Date.now()),delete t.id;const i=(0,a.toA)(e).filter(n.gt0);return(0,s.isEmpty)(i)?void 0:this.dbl.runf((e=>e.whereIn("id",i).update(t)))}get createdAtDate(){return(0,r.mapGt0)(this.createdAt,(e=>new Date(e)))}get updatedAtDate(){return(0,r.mapGt0)(this.updatedAt,(e=>new Date(e)))}touch(e={}){e.updatedAt??(e.updatedAt=Date.now());const t=this.id;null==t?this.upsert():this.class().dbl.runf((i=>i.where({id:t}).update(e)))}$beforeUpsert(){if(super.$beforeUpsert(),this.createdAt??(this.createdAt=Date.now()),this.updatedAt=Date.now(),"updateCount"in this){const e=this,t=e.updateCount;e.updateCount=((0,n.toGt0)(e.updateCount)??0)+1,this.logger().debug("$beforeUpsert(): incr updateCount",{prior:t,now:e.updateCount})}}}t.TimestampedModel=l},58723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyExcluded=t.applyDeleted=void 0;const r=i(50213),s=i(43487),n=(0,r.mkLogger)("ops.ApplyRemovable");async function a(e,t,i){const r=e?"Deleting":"Excluding",a=e?"deletedAt":"excludedAt";await s.Asset.dbl.batched({qb:e=>e.select("id").where("shown",0).andWhere(a,"<=",t),onResults:async t=>{for(const a of t){n.throwIfAborted_(i);try{await s.Asset.remove({assetId:a,blocklistShas:!0,unlinkAssetFiles:e})}catch(e){n.error(r+" failed",{assetId:a,error:e})}}}})}t.applyDeleted=function(e){return a(!0,e.createdAt,e.halt)},t.applyExcluded=function(e){return a(!1,e.createdAt,e.halt)}},76386:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiProgressPatchPath=t.tellWebProgressUpdated=t.ProgressRateMs=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(24540),o=i(28874),l=i(34238),u=i(4988),c=i(15674),d=i(42659),h=(0,i(45599).defer)((()=>(0,s.mkLogger)("progress.Progress")));t.ProgressRateMs=(0,r.lazy)((()=>d.secondMs*((0,a.isRaspberryPi)()||(0,c.maxCpus)()<=3?5:1.5))),t.tellWebProgressUpdated=(0,r.lazy)((async()=>{if((0,n.isWebService)())return;const e=l.URI.from({scheme:"http",authority:"127.0.0.1:"+o.Settings.httpPort.valueOrDefault,path:t.ApiProgressPatchPath}).toString();await(0,u.httpRequest_)({url:e,method:"PATCH"}).catch((e=>h().warn(".tellWebProgressUpdated: failed",{error:e})))}),(0,t.ProgressRateMs)()),t.ApiProgressPatchPath="/api/progress"},3996:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileFinder=t.isFileInSync=void 0;const o=i(19851),l=i(50213),u=i(79781),c=i(56519),d=i(56038),h=i(59189),f=i(38835),m=i(95696),p=i(48368),g=i(181),y=i(69589),v=i(28874),w=i(47783),b=i(87001),S=i(40958),P=i(76790),_=i(22573),M=i(42659),T=i(55835),E=i(31586),k=i(43487),D=i(54017);t.isFileInSync=async function(e){return new C(m.PosixFile.for(e)).alreadySynced()};const x=new h.SerialLaterQueue;class C{constructor(e,t=(0,y.forceContextOrSetting)()){this.file=e,this.ctx=t,r.set(this,void 0),s.set(this,new Set),this.alreadySynced=(0,d.timedLazy)("sync-file.AssetFileFinder.alreadySynced: "+this.file,(async()=>a(this,r,"f").tap({msg:"alreadySynced",result:null!=await this.priorIfSynced()}))),this.newAssetFile_=(0,d.timedLazy)("sync-file.AssetFileFinder.newAssetFile: "+this.file,(async()=>{const e=await(new D.AssetFile).updateFromFile_(this.file);return null==e?a(this,r,"f").throw("AssetFile.updateFromFile returned null",{fatal:!1}):e})),this.tags_=(0,o.lazy)((async()=>{const e=await(0,w.readTags)(this.file);if(null==e)throw new Error(this.file+" doesn't have metadata");return e})),this.imageHash=(0,o.lazy)((()=>v.Settings.useImageHashes.valueOrDefault?(0,p.imageHash)(this.file):void 0)),this.dominantLabhashes=(0,o.lazy)((()=>(0,c.thenMap)(this.imageHash(),(e=>(0,S.uniq)(e.dominantColors.filter((e=>e.pct>5)).map((e=>e.labhash))))))),this.capturedAtLocal=(0,o.lazy)((async()=>{const e=await this.capturedAt_();return a(this,r,"f").tap({msg:"capturedAtLocal",result:e?.local,meta:{capturedAt:e}})})),this.mapSibling=e=>this.newAssetFileForAsset(e?.getAsset()),this.apply_=(0,d.timedLazy)("sync-file.AssetFileFinder: "+this.file,(async()=>{if((0,_.blank)(await this.file.uri_()))throw new Error("Cannot import, file URI is blank for "+this.file);{const e=await this.byExistingAsset_();if(null!=e)return a(this,r,"f").info("Found existing asset for file"),e}const e=await this.newAssetFile_(),t=await x.enqueue((async()=>{const t=await this.byExistingAsset_();if(null!=t?.assetId)return a(this,r,"f").info("Found existing asset for file after acquiring lock",{withExistingAsset:t}),t.assetId;const i=new k.Asset;return i.capturedAtLocal=e.capturedAtLocal,i.addAssetFile(e),i.upsert(),i.id}));return e.assetId=t,e.upsert()})),this.byExistingAsset_=()=>(0,d.time)("sync-file.AssetFileFinder.byExistingAsset: "+this.file,(async()=>{const e=[{name:"byUri",f:()=>this.byUri()},{name:"byNormalizedPathUri",f:()=>this.newAssetFileForAsset(this.assetByNormalizedPathUri())},{name:"bySha",f:()=>this.newAssetFileForAsset(this.assetBySha())},{name:"hasTags",f:async()=>{await this.tags_()}},{name:"validFile",f:async()=>{await(0,g.throwIfInvalidFile_)(this.file)}},{name:"byCapturedAtOrImageHash",f:()=>this.newAssetFileForAsset(this.assetByCapturedAtOrImageHash())}];for(const{name:t,f:i}of e)try{const e=await(0,d.time)("sync-file.assetFileFinder."+t+": "+this.file,i);if(null!=e)return a(this,r,"f").info("apply(): "+t,{assetFileId:e.id,assetId:e.assetId}),e;a(this,r,"f").debug("apply(): "+t+": returned null")}catch(e){throw a(this,r,"f").debug("apply(): "+t+" rejected: "+e),e}})),n(this,r,(0,l.mkLogger)("sync-file.AssetFileFinder("+e.baseWithGrandparent+")"),"f")}async prior(){return this.byUri()}async priorIfSynced(){if(this.ctx.forceSync)return;const e=await this.prior();return!0===await(e?.matchesFile())?e:void 0}async newAssetFileForAsset(e){const t=await e;if(null!=t){if(null!=t.id){const e=await this.newAssetFile_();return t.addAssetFile(e),e.insert(),a(this,r,"f").debug("newAssetFileForAsset() upsert success!",{af:e}),e}a(this,r,"f").throw("newAssetFileForAsset(): given non-persisted Asset")}}async capturedAt_(){return(await this.tags_()).capturedAt}async byUri(e=this.file){const t=await e.uri_();if(null!=t)return D.AssetFile.ops().firstf((e=>e.whereIn("uri",[...(0,b.uriEncodingVariants)(t),this.file.fileuri()])));a(this,r,"f").warn("byUri() uri is null",{file:e})}async assetByNormalizedPathUri(){const e=await this.file.normalize();return e.nativePath===this.file.nativePath?void 0:(await this.byUri(e))?.getAsset()}assetBySha(){return(0,c.thenMap)(this.file.sha(),(e=>k.Asset.findFirstByFile((t=>t.where("AssetFile.sha",e)))))}async assetByCapturedAtOrImageHash(){const e=await this.capturedAt_();if(null==e)return a(this,r,"f").throw("Cannot import, capturedAt is null"+f.InternalErrorFlag);if(v.Settings.strictDeduping.valueOrDefault)return this.firstSimilarAsset(D.AssetFile.ops().allf((t=>t.where({capturedAtLocal:e.local}))));const t=v.Settings.maxContemporaryAdoptionAssets.valueOrDefault,i=()=>{let i=D.AssetFile.query();return(0,E.gt0)(t)&&(i=i.limit(t)),i.orderByRaw(`abs(capturedAtLocal - ${e.local})`)},s=Math.max(M.secondMs,v.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault);return(0,d.time)("sync-file.AssetFileFinder.assetByCapturedAtAndImageHash: "+this.file,(async()=>{{const t=e.localBoundaries({delta:s});if(null==t)a(this,r,"f").warn("Failed to fetch localBoundaries, cannot fetch similar assets by localtime",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("captured-at",i().whereBetween("capturedAtLocal",[t.start,t.end]))??(v.Settings.checkBasenameMatches.valueOrDefault?this.firstSimilarAssetByQuery("basename",i().whereILike("uri","%/"+this.file.name+"%")):void 0);if(null!=e)return e}}const t=await this.imageHash();if(null==t)return void a(this,r,"f").warn("assetByCapturedAtAndImageHash: no imageHash");const n=await this.dominantLabhashes();if((0,S.isNotEmpty)(n)){const t=e.localBoundaries({delta:4*s});if(null==t)a(this,r,"f").error("Failed to fetch localBoundaries, cannot fetch similar assets by wide localtime + image hash",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("wide captured-at and dominant color",i().whereBetween("capturedAtLocal",[t.start,t.end]).andWhere((e=>e.whereIn("mode0",n).orWhereIn("mode1",n).orWhereIn("mode2",n))));if(null!=e)return e}}return this.firstSimilarAssetByQuery("image hash",i().where("meanHash",t.meanHash).orWhere("diffHash",t.diffHash).orWhere("dctHash",t.dctHash))}))}async firstSimilarAssetByQuery(e,t){a(this,s,"f").size>0&&(t=t.whereNotIn("AssetFile.id",Array.from(a(this,s,"f"))));const i=await this.firstSimilarAsset(D.AssetFile.ops().all(t));return null!=i&&a(this,r,"f").info("Found similar asset by "+e,{result:i}),i}async firstSimilarAsset(e){const t=await this.newAssetFile_(),i=await this.capturedAtLocal();if(null==t)throw new Error("Failed to update from "+this.file);const n=(0,P.sortBy)(e.filter((e=>!a(this,s,"f").has(e.id))),(e=>[(0,T.mapOr)(i,(t=>Math.abs(e.capturedAtLocal-t)),-e.capturedAtLocal),e.id]));for(const e of n)if(null!=e){await e.getNativePath();const i=D.AssetFile.ops().findBy({assetId:e.assetId});await Promise.all(i.map((e=>e.getNativePath())));const n=(0,u.whyNotSameAsset)(t,e,i);if(null==n)return a(this,r,"f").info("Found sibling AssetFile",e),k.Asset.ops().findById(e.assetId);a(this,s,"f").add(e.id),a(this,r,"f").debug("Contemporary assetFile not similar: "+n,e?.uri)}}}t.AssetFileFinder=C,r=new WeakMap,s=new WeakMap},34274:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileImporter=t.importFileToResult_=void 0;const u=i(19851),c=i(50213),d=i(73568),h=i(38835),f=i(95696),m=i(62105),p=i(74128),g=i(181),y=i(69589),v=i(28874),w=i(40958),b=i(22573),S=i(38639),P=i(59455),_=i(64526),M=i(19113),T=i(94710),E=i(3996),k=i(90901);t.importFileToResult_=async function(e){const t=_.Library.instanceRequired_();return(0,p.syncReport)().wrap_({path:e.path,from:"AssetFileImporter",fn_:()=>new D(f.PosixFile.for(e.path),t.assetFileRepository(),e).apply_()})};class D{constructor(e,t,i){r.add(this),this.file=e,this.repo=t,this.start=Date.now(),s.set(this,void 0),n.set(this,void 0),this.whyRejected=(0,u.lazy)((async()=>{const e=[],t=await this.file.uri_();if(null==t)e.push("Cannot make URI"+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);else{if(!0===await this.file.isDeletedUri(t))e.push("File was deleted");else if(this.ctx.forceFilters||null==await this.prior()){const t=await(0,m.whyRejectFile)(this.file,(0,M.libraryFileFiltersFor)(this.file));null!=t&&e.push(t)}l(this,s,"f").throwIfAborted_();const i=await this.prior();if((0,w.isNotEmpty)(e)&&null!=i&&(l(this,s,"f").info("Deleting prior AssetFile",{rejected:e,prior:i}),i.delete(),this.ctx.skipAssetRepair?l(this,s,"f").info("Skipping asset repair",{assetId:i.assetId}):(l(this,s,"f").info("Scheduling asset repair",{assetId:i.assetId}),T.Task.addOne("repairAsset",{assetId:i.assetId,forceRebuildPreviews:(0,S.isTrue)(i.shown)}))),null!=i){const t=i.getAsset();null!=t?.deletedAt&&e.push("Asset is marked as deleted"),null!=t?.excludedAt&&e.push("Asset is marked as excluded")}if(l(this,s,"f").throwIfAborted_(),0===e.length&&(null==i||!await i.inSyncWithFile())){const t=await(0,g.whyInvalidFile)(this.file.nativePath);(0,b.blank)(t)||e.push(t)}}return e})),this.assetFile_=(0,u.lazy)((async()=>{const e=await l(this,n,"f").apply_(),t=e.getAsset();return l(this,s,"f").info("assetFileFinder.apply_() result",{asset:t,assetFile:e}),null==t?l(this,s,"f").throw("assetFile.getAsset() was null",{srcAssetFile:e}):null==t.id?l(this,s,"f").throw("repoAssetFile asset has null id",{asset:t}):e})),this.prior=(0,u.lazy)((()=>l(this,n,"f").prior())),this.apply_=(0,u.lazy)((()=>l(this,r,"m",a).call(this))),this.ctx=(0,y.forceContextOrSetting)(i),o(this,s,(0,c.mkLogger)("sync-file."+this.toString()),"f"),o(this,n,new E.AssetFileFinder(e,this.ctx),"f")}toString(){return"AssetFileImporter("+this.file.nativePath+")"}newAssetFile(){return l(this,n,"f").newAssetFile_()}}t.AssetFileImporter=D,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(){l(this,s,"f").throwIfAborted_();const e=await l(this,s,"f").tapAsync_({msg:"whyRejected",result:this.whyRejected(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if((0,w.isNotEmpty)(e)){const t=e.join(", ");return{path:this.file.nativePath,state:p.SyncFileStates.rejected,details:t}}l(this,s,"f").throwIfAborted_();const t=await l(this,s,"f").tapAsync_({msg:"prior()",result:this.prior(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if(null!=t&&await t.isNoop(this.ctx))return{path:this.file.nativePath,state:p.AssetFileSyncStates.noop,assetId:t.assetId,assetFileId:t.id,assetFile:t,asset:t.getAsset(),uri:t.uri};l(this,s,"f").throwIfAborted_();const i=await l(this,s,"f").tapAsync_({msg:"assetFile()",result:this.assetFile_(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if(null==i)return l(this,s,"f").throw("_apply(): unexpected null assetFile");const r=i.id;if(null==r)return l(this,s,"f").throw("_apply(): unexpected null assetFileId");const n=i.uri;if(null==n)return l(this,s,"f").throw("_apply(): unexpected null assetFile.uri");const a=i.getAsset();if(null==a)return l(this,s,"f").throw("_apply(): unexpected null assetFile.getAsset()");let o;await l(this,s,"f").tapAsync_({msg:"assetFile.upsertIfNeeded_()",result:i.upsertIfNeeded_(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault}),l(this,s,"f").throwIfAborted_();try{o=await(0,k.assetPostUpsertTasks_)({asset:a,...this.ctx})}catch(e){e instanceof d.AbortError?l(this,s,"f").warn("aborted (caller/process after me will complete)",{error:e}):l(this,s,"f").throw("Post-upsert tasks failed",{error:e})}return{path:this.file.nativePath,state:i.syncState??p.SyncFileStates.synced,assetId:a.id,assetFileId:r,assetFile:i,asset:a,uri:n,uris:[n,...(0,P.toA)(o?.newAssetFileUris)]}}},41844:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileRepository=t.mayCopyAssetsToLibrary=void 0;const u=i(50213),c=i(74128),d=i(81674),h=i(57902),f=i(4936),m=i(28874),p=i(47783),g=i(67083),y=i(16170),v=i(54979),w=i(98604),b=i(40958),S=i(22573),P=i(98553),_=i(89937),M=i(59455),T=i(54017),E=i(94710);t.mayCopyAssetsToLibrary=async function(){return m.Settings.copyAssetsToLibrary.valueOrDefault&&await(0,d.p)()},t.AssetFileRepository=class{constructor(e){r.add(this),this.originalsDir=e,this.logger=(0,u.mkLogger)("AssetFileRepository")}async shouldCopy(e){const t=await this.whyNotCopyFile(e);return this.logger.tap({level:"info",msg:"shouldCopy()",result:null==t,meta:{file:e?.nativePath,whyNot:t}})}async whyNotCopyFile(e){if(null==e||(0,S.blank)(e.nativePath))return"blank nativePath";if(!0!==m.Settings.copyAssetsToLibrary.value)return"copyAssetsToLibrary !== true";if(await(0,d.l)())return"no active subscription";if(await e.notExists({refresh:!0}))return"file doesn't exist";if(e.isDescendantOf(this.originalsDir))return e+" already contained by "+this.originalsDir;if(e.isDescendantOf(m.Settings.libraryDir.valueOrDefault))return e+" already contained by "+m.Settings.libraryDir.valueOrDefault;const t=await(0,v.readMimeType)(e);return null==t?"readMimeType("+e+") was null":(0,y.isMimeTypeIncluded)(t,m.Settings.copyToLibraryMimeTypes.values)?null:"mimetype "+t+" is not included in copyToLibraryMimeTypes"}async existingLibraryAssetFile(e){if(e.uri.startsWith(_.PS_LIBRARY_PROTOCOL))return e;const t=(0,b.uniqBy)((0,M.toA)(e.librarySiblings()?.filter((t=>t.sha===e.sha))).concat(T.AssetFile.sameAssetFileInLibrary(e)),(e=>e.id));for(const i of t)if(await i.exists()){if(i.assetId!==e.assetId){this.logger.warn("Existing library asset file with a matching SHA is associated to a different asset. Requesting repair of the two impacted assets.",{af:e,prior:i});const t=i.assetId;e.getAsset()?.addAssetFile(i),E.Task.addOne("repairAsset",{assetId:t,forceSync:!0})}return this.logger.info("whyNotCopyAssetFile("+e.uri+"): found existing db record",{af:e,prior:i}),i}return null}async findLibraryFileWithSameContents(e,t){if(await e.matchesContent(t))return t;let i=t.parent();for(;i.isSelfOrDescendantOf(this.originalsDir);){const t=i.childWithSameContents(e);if(null!=t)return t;i=i.parent()}}async importFile_(e){const t=await l(this,r,"m",s).call(this,e);return null!=t&&(await l(this,r,"m",n).call(this,e,t),await l(this,r,"m",o).call(this,e,t)),t}async maybeCopyToLibrary_(e,t){const i=Date.now(),s=await e.posixFile_();null==s&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): posixFile is null",{ignorable:!1,retriable:!1});{const e=await this.whyNotCopyFile(s);if(!(0,S.blank)(e))return this.logger.tap({level:h.LogLevels.info,msg:"maybeCopyToLibrary_(): not copying: "+e,result:void 0})}const a=e.getAsset();null==a&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): null asset");{const u=await this.existingLibraryAssetFile(e);if(null!=u){const e=await u.posixFile_();if(null!=e){const d=await l(this,r,"m",n).call(this,s,e),h=null!=await l(this,r,"m",o).call(this,s,e),f=null!=await u.upsertIfNeeded_(void 0,t);return!h&&(0,b.isEmpty)(d)&&!f||(0,c.syncReport)().onProgress({path:e.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.synced,details:"Found and synced prior replica already in your library "+(0,P.stringify)({src:s.nativePath,upsertNeeded:f,copiedSidecars:d,copiedInferredMetadata:h}),elapsedMs:Date.now()-i,url:(0,w.mkAssetUrl)(a.id)?.toString()}),u}this.logger.warn("existingLibraryAssetFile() returned an assetFile that could not be resolved to a PosixFile",{prior:u})}}const u=await this.importFile_(s);if(null==u)return void this.logger.info("importFile() returned null",{srcAssetFile:e});if(u.nativePath===s.nativePath)return void this.logger.info("importFile() returned the same nativePath as src",{srcAssetFile:e,dest:u});const d=await a.assetFileForFile_(u,{skipUpsert:!0});await d.updateFromShaSibling_(e);const f=d.upsert();return a.addAssetFile(d),(0,c.syncReport)().onProgress({path:u.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.copied,details:"Copied into your library from "+s.nativePath,elapsedMs:Date.now()-i,url:(0,w.mkAssetUrl)(a.id)?.toString()}),f}},r=new WeakSet,s=async function(e){const t=await(0,p.readCapturedAt)(e),i=(0,f.pathToLibraryAsset)(t?.date,e);if(this.logger.debug("importFile("+e+")",{capturedAt:t,assetPath:i}),null==i)throw new Error(e.nativePath+" failed to create a library path");const r=this.originalsDir.join(...i),s=await this.findLibraryFileWithSameContents(e,r);if(null!=s)return this.logger.debug("#importFile_("+e+"): found existing file",{src:e,existing:s}),s;const n=await r.ensureNew_();return this.logger.info("#importFile_("+e+"): copying...",{uniqDest:n,dest:r}),e.copyFile_(n)},n=async function(e,t){const i=await e.existingSidecars(),s=[];for(const e of i)s.push(await l(this,r,"m",a).call(this,e,t));return(0,b.compact)(s)},a=async function(e,t){for(const i of await t.existingSidecars())if(await(0,p.sidecarEql)(e,i))return void this.logger.info("handleSidecar(): metadata already exists.",{srcSidecar:e,destSidecar:i,dest:t});const i=await t.parent().join(t.name+e.ext).ensureNew_({emptyIsNew:!0});return e.copyFile_(i)},o=async function(e,t){if(null==e||null==t||e.eql(t))return;const i=await(0,p.readTags)(e);if(null!=i)return(0,g.ensureInferredHistoryRecords)(e,await t.sidecar(),i.inferred);this.logger.warn("#handleInferred(): Failed to read tags from "+e,{dest:t})}},90901:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetPostUpsertTasks_=t.assetPostUpsertTasks=void 0;const r=i(50213),s=i(92434),n=i(73568),a=i(99331),o=i(39250),l=i(38835),u=i(57159),c=i(48604),d=i(66106),h=i(69589),f=i(40958),m=i(45599),p=i(23838),g=i(31586),y=i(64526),v=i(88224),w=i(43487),b=i(41844),S=i(68640),P=(0,m.defer)((()=>(0,r.mkLogger)("sync-file.AssetPostUpsertTasks"))),_=(0,m.defer)((()=>new o.LastOneInWins("Asset tasks")));async function M(e){const t=e,i=e,r=(0,g.toGt0)(t.asset?.id)??(0,g.toGt0)(i.assetId);if(null==r)throw new Error("assetPostUpsertTasks_(): unexpected null assetId"+l.InternalErrorFlag);const o=(0,h.forceContextOrSetting)(e),m=P().addContext(`.postUpsertAssetTasks_(Asset:${r})`);if(m.abortable=o.halt,o.skipPreviews&&o.skipAssetTagging)return void m.info("skipped (skipPreviews && skipAssetTagging)");const M=t.asset??w.Asset.ops().findById(r);if(null==M)return m.throw("unexpected null asset",{asset:M});try{return await _().enqueue({key:r,abortable:m.abortable,fn:()=>async function(e,t,i){const r=(0,h.forceContextOrSetting)(i),n=t.id,a=t.getAssetFiles({refresh:!0}),o={newAssetFileUris:[],previewsUpdated:!1,tagResult:void 0,transcoded:!1};if(e.throwIfAborted_(),(0,f.isEmpty)(a)&&(await w.Asset.remove({assetId:n,blocklistShas:!1,unlinkAssetFiles:!1}),e.throw(`Asset:${n} had no asset files. Deleted.`)),await(0,b.mayCopyAssetsToLibrary)())for(const[t,i]of(0,p.groupBy)(a,(e=>e.sha)).entries()){e.throwIfAborted_();try{for(const r of i)r.isInLibrary()&&await r.exists()&&e.debug("no-op for file SHA: already in library.",{sha:t,uri:r.uri});for(const e of i)if(await e.exists()){const t=await y.Library.instanceRequired_().assetFileRepository().maybeCopyToLibrary_(e,r);if(null!=t){o.newAssetFileUris.push(t.uri);continue}}}catch(r){e.warn("Failed to copy variation to library, but we'll try to continue",{sha:t,uris:i.map((e=>e.uri)),error:r})}}e.throwIfAborted_();const l=r.skipPreviews?void 0:await(0,S.updateAssetPreviews_)({asset:t,assetFiles:t.getAssetFiles(),...r}),u=await async function(e,t){if((0,g.gt0)(t?.assetFileId)){const i=e.getAssetFiles({refresh:!0}).find((e=>e.id===t?.assetFileId));return null==i?P().throw("AssetPreviewInfo referenced unknown assetFileId",{asset:e,info:t}):i}const i=e.getShown();return null!=i?i:(0,s.bestExistingAssetFile)(e.getAssetFiles())}(t,l);if(null==u)return e.throw("null primaryOrShownAssetFile_()",{asset:t});const m=await u.posixFile_();if(!0!==r.skipPreviews&&t.isVideo()){if(null==m)return e.throw("null primary.posixFile()",{asset:t,assetFiles:t.getAssetFiles()});o.transcoded=null!=await(0,d.transcode_)(m,c.Previews.instance().ap(n).mp4(),{force:r.forceRebuildPreviews,halt:r.halt})}return e.throwIfAborted_(),t.markShownAndUpsert_(u),r.skipAssetTagging?e.info("skipping asset tagging"):o.tagResult=await(0,v.tagAndUpsertAsset_)(t),o}(m,M,{...e,...o})})}catch(e){if(e instanceof n.AbortError)return void m.warn("aborted, next caller will clean up my mess",{error:e});const t=[e];if(!(0,a.ending)()){m.error("failed, marking asset unshown",{error:e});try{M.markUnshownAndUpsert()}catch(e){m.error("failed to mark asset unshown",{upsertError:e}),t.push(e)}}throw new u.WrappedError("Failed to post-process assset "+M.id,{causes:t})}}t.assetPostUpsertTasks=function(e){try{return M(e)}catch(e){if(e instanceof n.AbortError)return void P().warn("aborted, next caller will clean up my mess",{error:e});throw e}},t.assetPostUpsertTasks_=M},61989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAsset_=t.updateAsset=void 0;const r=i(48884),s=i(50213),n=i(45393),a=i(79184),o=i(79781),l=i(92434),u=i(56519),c=i(70417),d=i(69589),h=i(28874),f=i(40958),m=i(22573),p=i(38639),g=i(50357),y=i(43487),v=i(54017),w=i(90901);async function b(e){const t=(0,d.forceContextOrSetting)(e),i=e.assetId,r=(0,s.mkLogger)(`sync-file.UpdateAsset(${i})`);r.abortable=t.halt;const b=y.Asset.ops().findById(i);if(null==b)return r.throw("no such asset");const P=b.getAssetFiles({refresh:!0});if((0,f.isEmpty)(P))return r.warn("No asset files: deleting."),b.delete(),{asset:b,rejected:"Empty asset (no AssetFiles)"};const _=b.$clone(),M=b.getShown()?.$clone();for(const e of P)r.throwIfAborted_(),await e.upsertIfNeeded_(void 0,t);P.some((e=>(0,p.isTrue)(e.deleted)||(0,m.notBlank)(e.rejected)))&&b.clear(),await S(r,P);const T=(0,l.sortAssetFiles)(P),E=T?.[0];if((0,f.isEmpty)(T)||null==E)return r.warn("No existing files. Skipping for now."),b.markUnshownAndUpsert(),{asset:b,rejected:"Empty asset (no AssetFiles after sorting). Un-showing Asset:"+i};if(!E.isVersionUpToDate())return r.warn("Best file needs update, and we already tried to update all files. Skipping this asset.",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, could not be updated. Un-showing Asset:${i}`};const k=await E.capturedAt();if(null==k)return r.warn("Best file failed to extract a captured-at",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, failed to extract a captured-at. Un-showing Asset:${i}`};const D=new Set,[x,C]=await(0,u.partitionAsync)(T,(e=>(0,o.isSimilarAssetFile)(e,E)));if(r.throwIfAborted_(),(0,f.isNotEmpty)(C)){const e=await(0,a.aggregateAssetFiles)(C);for(const t of e){if((0,f.isEmpty)(t))continue;const e=y.Asset.ops().insertOne({capturedAtLocal:t[0].capturedAtLocal,shown:!1,version:0});D.add(e.id);for(const i of t)e.addAssetFile(i);v.AssetFile.dbl.runf((i=>i.update({assetId:e.id,shown:0}).whereIn("id",(0,f.compact)(t.map((e=>e.id)))))),r.info("Pushed rejected asset files into new asset",{rejectAssetId:e.id,rejectCluster:t.map((e=>({id:e.id,uri:e.uri})))})}}function F(e){return(0,f.uniq)(x.map((t=>t[e])))}const A=await Promise.all(x.map((e=>e.capturedAt()))),I=h.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,O=A.map((e=>e?.localBoundaries({delta:I}))),L=(0,c.min)(O.map((e=>e?.start)))??k.localBoundaries({delta:I})?.start,R=(0,c.max)(O.map((e=>e?.end)))??k.localBoundaries({delta:I})?.end,N=v.AssetFile.ops().all(v.AssetFile.query().limit(h.Settings.maxContemporaryAdoptionAssets.valueOrDefault).orderByRaw(`abs(AssetFile.capturedAtLocal - ${E.capturedAtLocal})`).select("AssetFile.*").distinct().join("Asset","Asset.id","AssetFile.assetId").where("AssetFile.assetId","!=",i).andWhere("Asset.version","!=",n.AssetVersion).andWhere((e=>(e=e.whereIn("AssetFile.sha",F("sha")),null==L||null==R?r.warn("external asset file check: unset start or end localtime boundary",{capturedAts:A,startBoundary:L,endBoundary:R}):e=e.orWhereBetween("AssetFile.capturedAtLocal",[L,R]),e.orWhereIn("AssetFile.meanHash",F("meanHash")).orWhereIn("AssetFile.diffHash",F("diffHash")).orWhereIn("AssetFile.dctHash",F("dctHash"))))));r.throwIfAborted_(),r.info("asset file candidates for adoption: ",N.map((e=>e.posixPathFromGrandparent)));const B=[];for(const e of N){r.throwIfAborted_();try{await e.updateFromFile_(),(0,o.isSimilarAssetFile)(e,E)&&(r.info("adopting similar asset file",{af:e}),D.add(e.assetId),e.shown=!1,b.addAssetFile(e),e.upsert(),B.push(e))}catch(t){r.warn("Error updating external asset file. Leaving asset file record as-is.",{af:e,error:t})}}r.info("fetched expansion",{retainAFs:x.map((e=>e.id)),rejectAFs:C.map((e=>e.id)),externalAssetFiles:N.map((e=>e.posixPathFromGrandparent)),similarAssetFiles:B.map((e=>e.posixPathFromGrandparent))}),await S(r,[...x,...B]),t.skipPreviews&&t.skipAssetTagging?(r.info("skipping previews and tagging",t),b.upsert()):await(0,w.assetPostUpsertTasks_)({...t,asset:b});const j=!(0,g.eql)(_,b),z=!(0,g.eql)(M,b.getShown()),V=!(j||z||t.forceRebuildPreviews||t.forceSync);return r.tap({msg:"updateAsset() result",level:"info",result:{asset:b,assetIdsToUpdate:Array.from(D),assetFiles:b.assetFiles,skipped:V},meta:{ctx:t,assetChanged:j,primaryAssetFileChanged:z}})}async function S(e,t){const[i,s]=(0,r.partition)(t,(e=>e.isVersionUpToDate()));for(const t of s){e.throwIfAborted_();const r=i.find((e=>e.sha===t.sha));if(null!=r){e.info("backfilling",{sibling:r,dest:t});const i=await t.updateFromShaSibling_(r);null!=i&&i.upsert()}}}t.updateAsset=async function(e){try{const t=await b(e);return{id:e.assetId,skipped:null==t?.asset,...t}}catch(t){return{id:e.assetId,error:t}}},t.updateAsset_=b},93755:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetFileIfNeeded=t.handleAssetFileUriChange=t.updateAssetFile_=t.updateAssetFile=void 0;const r=i(50213),s=i(92434),n=i(98314),a=i(74128),o=i(69589),l=i(87001),u=i(40958),c=i(22573),d=i(68708),h=i(43487),f=i(54017),m=i(94710);async function p(e){const t=Date.now(),i=e,s=e,n=s.af?.id??i.assetFileId,u=(0,r.mkLogger)(`updateAssetFile(${n})`),d=s.af??f.AssetFile.ops().findById(n);if(null==d)return u.throw("db record not found",{assetFileId:n});const h=await d.posixFile_(),p=(0,o.forceContextOrSetting)(e),v={id:n,assetFileId:n,path:h?.nativePath,uri:d?.uri};if(null==h)return{...v,error:"file for URI not found"};const w=await(h?.isDeletedUri(d.uri));if(null==w)return u.info("no-op: file URI points to an unmounted volume",v),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:"volume is not currently mounted",state:a.SyncFileStates.skipped}),{...v,skipped:!0};const b=e.whyReject??await d.whyRejected();if(w||!(0,c.blank)(b)){const e={...v,rejected:b,deleted:w};return u.warn("file was deleted or rejected. Deleting.",e),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:w?"file no longer exists":"rejected: "+b,state:a.SyncFileStates.deleted}),d.delete(),!0!==p.skipAssetRepair&&m.Task.addOne("repairAsset",{assetId:d.assetId}),e}const S=await h.uri_();if(!await(0,l.uriIsEquivalent)(S,d.uri)){const e=await g(d,S,p);if(null!=e)return{...v,...e}}return!p.forceSync&&await d.matchesFile()?(u.info("no-op: file already matches db record",v),d.touch(),{...v,skipped:!0}):{...v,...await y(d,p)}}async function g(e,t,i){const n=(0,r.mkLogger)(`handleAssetFileUriChange(${e.id})`),a=(0,u.uniq)([...(0,l.uriEncodingVariants)(e.uri),...(0,l.uriEncodingVariants)(t)]);n.warn("URI is changing. Avoiding duplicate keys.",{priorUri:e.uri,variants:a});const o=f.AssetFile.ops().allf((t=>t.whereIn("uri",a).andWhereNot({id:e.id})));if((0,u.isNotEmpty)(o)){n.warn("Found other AssetFiles with equivalent URIs.",{afIds:o.map((e=>e.id))});const t=[e,...o],r=(0,s.sortAssetFiles)(t);if((0,u.isEmpty)(r))return n.warn("sortAssetFiles returned undefined",{arr:t.map((e=>(0,d.pick)(e,"id","uri"))),variants:a}),{error:"sortAssetFiles returned undefined"};const l=t.map((e=>e.id));for(const e of r)if(await e.exists()){f.AssetFile.dbl.runf((t=>t.whereIn("id",l.filter((t=>t!==e.id))).delete()));const r=y(e,i);return h.Asset.dbl.runf((e=>e.update({version:0,updatedAt:Date.now()}).whereIn("id",(0,u.uniq)(t.map((e=>e.assetId)))))),r}}n.info("no-op, no duplicate URIs.")}async function y(e,t){const i=Date.now();return null!=await e.upsertIfNeeded_(void 0,t)&&h.Asset.touch([e.assetId]),(0,a.syncReport)().onProgress({path:await e.getNativePath(),elapsedMs:Date.now()-i,from:"updateAssetFileIfNeeded()",state:e.syncState??a.SyncFileStates.unknown}),{assetFileId:e.id}}t.updateAssetFile=async function(e){try{return await p(e)}catch(t){return{id:e.assetFileId,...e,error:(0,n.errorToS)(t)}}},t.updateAssetFile_=p,t.handleAssetFileUriChange=g,t.updateAssetFileIfNeeded=y},68640:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetPreviews_=void 0;const r=i(99331),s=i(38835),n=i(48604),a=i(50213),o=i(69589),l=i(87001),u=i(40958),c=i(45599),d=i(50357),h=i(31586),f=i(68708),m=i(59455),p=i(43487),g=(0,c.defer)((()=>(0,a.mkLogger)("sync-file.UpdateAssetPreviews")));t.updateAssetPreviews_=async function(e){const t=e.assetId??e.asset?.id??(0,m.toA)(e.assetFiles).find((e=>(0,h.gt0)(e.assetId)))?.assetId,i=(0,o.forceContextOrSetting)(e),a=g().addContext(".Asset:"+t);if(i.skipPreviews)return void a.warn("skipPreviews is true: no-op");if(!(0,h.gt0)(t))return a.throw("invalid assetId",{assetId:t});const c=e.asset??p.Asset.ops().findById(t);if(null==c)return a.throw("Asset:"+t+" not found");a.throwIfAborted_(i.halt);try{const e=await c.getExistingAssetFiles();if((0,u.isEmpty)(e))return void a.warn("no existing assetFiles",{asset:c});const r=n.Previews.instance().ap(t),o=await r.readInfo();a.throwIfAborted_(i.halt);const h=await(0,n.buildAssetPreviews_)({...i,assetId:t,assetFiles:e}),m=e.find((e=>e.id===h?.assetFileId))??e.find((e=>(0,l.uriIsEquivalent)(h?.uri,e.uri)));a.info("buildAssetPreviews_()",{result:h,primaryAssetFile:m});const p=await(m?.posixFile_());if(null==m||null==p||!0!==await(p?.exists()))return a.throw("buildAssetPreviews_() returned invalid assetFileId"+s.InternalErrorFlag,{newInfo:h,assetFiles:e.map((e=>(0,f.pick)(e,"id","uri"))),primaryAssetFile:m,primaryPosixFile:p});const g=(0,d.eql)(o,h),y=null==h||g;return{...h,noop:y}}catch(e){throw(0,r.ending)()||(a.warn("Failed to update previews. Un-showing asset "+t,{error:e}),c.markUnshownAndUpsert()),e}}},94019:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathsToSync=t.scanPaths=t.logger=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(87290),o=i(34102),l=i(16287),u=i(45969),c=i(43334),d=i(28874),h=i(45200),f=i(69375),m=i(7014),p=i(41400),g=i(31586),y=i(92244),v=i(46832);t.logger=(0,r.lazy)((()=>(0,s.mkLogger)("sync.PathsToSync")));const w=(0,r.lazy)((async()=>{const e=[];for(const t of await(0,m.volumes)()){if(!0===t.ignorable||!1===t.ok||(c.isMac||(0,u.isDocker)())&&"/"===t.mountpoint||(0,f.isExcludedMountpoint)(t.mountpoint)||!(0,g.gt0)(t.size))continue;const i=await(0,v.toUriPath)(t.mountpoint,(0,h.nativePath2uri)(t.mountpoint,t));null!=i&&e.push(i)}return e}));async function b(){const e=[],i=[],r=d.Settings.argvScanPaths.toNotEmpty()??d.Settings.scanPaths.values;for(const s of r)if(await(0,l.isReadableDirectory)(s)){const r=await(0,v.toUriPath)(s);null==r?(e.push(s),(0,t.logger)().warn("Ignoring scanPath element: failed to create URI path",s)):i.push(r)}else(0,t.logger)().warn("Ignoring scanPath element: not readable directory",s);return{result:i,noUriPaths:e}}t.scanPaths=b,(0,p.later)((()=>{(0,o.ee)().on("volumesChanged",(()=>{w.unset()}))})),t.pathsToSync=async function(){const e=[];if(d.Settings.argvScanPaths.isNotEmpty()){for(const i of d.Settings.argvScanPaths.values){const r=await(0,v.toUriPath)(i);null!=r?e.push(r):(0,t.logger)().warn("pathsToSync(): Ignoring scanPath element: failed to create URI path",i)}return e}e.push(...(await b()).result),!0===d.Settings.scanAllDrives.value&&e.push(...await w());const i=await(0,n.thenMapOr)((0,a.libraryOriginalsDirPosixFile)(),v.posixFileToUriPath,(()=>(0,t.logger)().throw("libraryOriginalsDir was null",{libraryDir:d.Settings.libraryDir.valueOrDefault,originalsDir:d.Settings.originalsDir.value})));d.Settings.scanLibraryFirst.valueOrDefault&&e.unshift(i),d.Settings.scanLibraryLast.valueOrDefault&&e.push(i);const r=await(0,n.filterAsync)({name:"pathsToSync",arr:e,f:e=>!y.nativePathBlocklist.has(e.nativePath)&&(0,l.isReadableDirectory)(e.nativePath)});return(0,t.logger)().info("pathsToSync",r),r}},98622:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runTimeIsStale=t.SyncCron=void 0;const r=i(28874),s=i(41400),n=i(30301),a=i(31586);t.SyncCron=(0,n.lazy)((()=>r.Settings.syncCron.cron({timezone:r.Settings.syncCronTZ.value}))),(0,s.later)((()=>{r.Settings.syncCron.watchLater((()=>t.SyncCron.unset())),r.Settings.syncCronTZ.watchLater((()=>t.SyncCron.unset()))})),t.runTimeIsStale=function(e){return null==e||(0,a.lte)((0,t.SyncCron)().nextRun(new Date(e))?.getTime(),Date.now())}},92244:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syncPathsForUI=t.bestStable=t.isStale=t.bestPathToSync=t.stalePathsToSync=t.pathsAndTimesToSync=t.nativePathBlocklist=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(23560),o=i(22277),l=i(87290),u=i(57902),c=i(28874),d=i(40958),h=i(76790),f=i(42659),m=i(75240),p=i(31586),g=i(20958),y=i(49796),v=i(94019),w=i(98622),b=(0,s.lazy)((()=>(0,n.mkLogger)("sync.SyncPaths")));t.nativePathBlocklist=new o.TTLSet(10*f.minuteMs);const S=10*f.minuteMs;async function P(){const e=await(0,v.pathsToSync)(),t=c.Settings.forceSync.valueOrDefault?[]:await y.Progress.times();return b().tap({msg:"pathsAndTimesToSync()",level:u.LogLevels.info,result:e.map((e=>({...e,...t.find((t=>t.uri===e.uri))})))})}function _(e,t){return null==e.lastStartedAt||null==e.lastCompletedAt||(0,p.lte)(e.lastStartedAt,t)||(0,w.runTimeIsStale)(e.lastCompletedAt)}function M(){return g.Operation.getFirstPendingOp({name:g.OperationNames.forceRestartSync})}async function T(e){const t=M(),i=t?.createdAt,s=e.filter((e=>_(e,i)));if((0,d.isEmpty)(s))return(0,a.isSyncService)()&&t?.markCompleted(),b().tap({msg:"bestStable(): No stale paths to sync!",level:"info",result:void 0,meta:{arr:e,forceRestartOp:t}});{const e=(0,r.greatestBy)(s,(e=>e.lastUpdatedAt));if(null!=e&&(0,p.gt)(e.lastUpdatedAt,Date.now()-10*f.minuteMs))return b().tap({msg:"bestStable(): returning most recently updated",level:"info",result:{...e,why:"recently updated"}})}const n=(0,r.leastBy)(s,(e=>[e.lastStartedAt??0,e.lastCompletedAt??0]));return b().tap({msg:"bestStable(): returning least-recently-started or least-recently-completed:",level:"info",result:null==n?void 0:{...n,why:"least recently started or completed"},meta:{stale:s}})}function E(e,t){return null==e.lastStartedAt?"new":null==e.lastCompletedAt?"todo":(0,p.gt)(e.lastUpdatedAt,Date.now()-f.minuteMs)?"syncing":_(e,t)?"stale":"synced"}function k(e){return null==e?void 0:new Date(e).toISOString()}function D(e){if(null==e)return;const t=Date.now()-e;return t<2*f.secondMs?"just now":(0,m.fmtDuration)(t)+" ago"}t.pathsAndTimesToSync=P,t.stalePathsToSync=async function(){const e=await P(),t=M(),i=t?.createdAt,r=e.filter((e=>_(e,i)));return(0,h.sortBy)(r,(e=>[null!=e.lastUpdatedAt&&Date.now()-Se.nativePath)),t=await T(e),i=(0,l.libraryOriginalsDirPosixFile)()?.nativePath,r=M()?.createdAt;return e.map((e=>({path:e.nativePath,library:i===e.nativePath,status:E(e,r),isNext:e.nativePath===t?.nativePath,lastStartedISO:k(e.lastStartedAt),lastStarted:D(e.lastStartedAt),lastCompletedISO:k(e.lastCompletedAt),lastCompleted:D(e.lastCompletedAt)})))}},46832:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.posixFileToUriPath=t.toUriPath=void 0;const r=i(53265),s=i(45200),n=i(22573),a=i(68708),o=i(54993);async function l(e,t){if((0,a.isObject)(e)&&!(0,n.blank)(e.nativePath)&&!(0,n.blank)(e.uri))return e;const i=(0,r.resolve)((0,o.toS)(e)),l=await t??await(0,s.nativePath2uri)(i);return null==l?void 0:{nativePath:i,uri:l.toString()}}t.toUriPath=l,t.posixFileToUriPath=function(e){return l(e.nativePath,e.uriObject_())}},7656:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rebuildTagAssetCounts=t.DirectAssetCountForTagQuery=t.RecursiveAssetCountForTagQuery=t.nonLeafTagIds=void 0;const r=i(50213),s=i(56038),n=i(95704),a=i(38156),o=i(42659),l=i(45599),u=i(41400),c=i(31586),d=i(51926),h=(0,l.defer)((()=>(0,r.mkLogger)("tag.TagAssetCounts")));function f(e){return e.prepare((0,d.compressWhitespace)("SELECT"," t1.id,"," count(t2.id) AS cnt","FROM"," Tag t1"," JOIN Tag t2 ON t1.id = t2.parentId","GROUP BY"," 1","HAVING"," cnt > 0")).pluck().all()}async function m(e,i=[]){const r=e.prepare(t.RecursiveAssetCountForTagQuery).pluck(),o=e.prepare(t.DirectAssetCountForTagQuery).pluck(),l=e.prepare("UPDATE Tag SET assetCount = :assetCount, updatedAt = :updatedAt WHERE id = :tagId"),c=new Set(f(e)),d=new a.PushProgressObserver({op:"Rebuilding tag asset counts"},e.prepare("SELECT count(*) FROM Tag").pluck().get());await(0,n.withIdBatches)({db:e,tableName:"Tag",primaryKeyColumnName:"id",whereClauses:i,async fn(e){for(const t of e){const e=!c.has(t);(0,s.timeSync)("db.rebuildTagAssetCounts("+(e?"leaf":"cte")+")",(()=>{const s=(e?o:r).get({tagId:t});l.run({tagId:t,assetCount:s,updatedAt:Date.now()}),d.incrProgress(),h().debug("_rebuildTagAssetCounts()",{isLeaf:e,whereClauses:i,tagId:t,assetCount:s})})),t%10==0&&(h().throwIfAborted_(),await(0,u.delay)(1))}}}),d.completed()}t.nonLeafTagIds=f,t.RecursiveAssetCountForTagQuery=(0,d.compressWhitespace)("WITH RECURSIVE descendants(id) AS ("," VALUES (:tagId)"," UNION"," SELECT Tag.id"," FROM Tag, descendants"," WHERE Tag.parentId = descendants.id",")","SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," descendants"," JOIN AssetTag ON AssetTag.tagId = descendants.id"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL"),t.DirectAssetCountForTagQuery=(0,d.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," AssetTag"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," AssetTag.tagId = :tagId"," AND Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL;"),t.rebuildTagAssetCounts=async function(e,t=o.minuteMs){if(await(0,s.time)("db.rebuildNullTagAssetCounts",(()=>m(e,["assetCount IS NULL"]))),(0,c.gt0)(t)){const i=e.prepare("SELECT min(updatedAt) FROM Tag").pluck().get(),r=Date.now()-i;if(rm(e)))}},69032:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.displayNameForVolsha=t.fixFileRootTag=t.runTagMaintenance=t.forceRunTagMaintenance=t.tagFtsRebuild=void 0;const s=r(i(76760)),n=i(19851),a=i(50213),o=i(7282),l=i(409),u=i(1728),c=i(56038),d=i(34102),h=i(49076),f=i(69589),m=i(28874),p=i(42231),g=i(85087),y=i(98770),v=i(59107),w=i(63870),b=i(7014),S=i(22573),P=i(42659),_=i(41400),M=i(75240),T=i(31586),E=i(34666),k=i(51926),D=i(75020),x=i(54017),C=i(48723),F=i(98784),A=i(7656),I=(0,n.lazy)((()=>(0,a.mkLogger)("tag.TagSql")));t.tagFtsRebuild=(0,n.lazy)((()=>(0,c.time)("db.rebuildTagFts",(()=>F.TagFts.rebuild()))),10*P.minuteMs),t.forceRunTagMaintenance=async function(e={forceSync:!0,recountAllTags:!0}){return I().info("forceRunTagMaintenance()"),await t.runTagMaintenance.force(e)};const O=((0,o.isTest)()?5:30)*P.secondMs;t.runTagMaintenance=(0,l.rateLimited)({name:"runTagMaintenance",minCallDelayMs:O,f:async e=>{const i=(0,f.forceContextOrSetting)(e),r=Date.now(),s=I().addContext(".runTagMaintenance()");s.info("starting",{ctx:i});try{s.info("validating all tags..."),C.Tag.validate_(),s.throwIfAborted_(i?.halt),await L(),i.recountAllTags&&(s.info("rebuilding tag search index..."),await(0,t.tagFtsRebuild)(),s.info("rebuilding tag asset counts..."),await(0,A.rebuildTagAssetCounts)(C.Tag.dbl.db().db,0))}catch(e){I().warn("runTagMaintenance() failed",e)}const n=Date.now()-r,a=(0,T.clamp)(O,15*P.minuteMs,20*n);t.runTagMaintenance.setMinCallDelayMs(a),I().info("runTagMaintenance(): complete.",{newMinCallDelayMs:a,elapsedMs:n})}});const L=(0,y.lazyFsAsync)("updateTagMountpoints",(async()=>{I().info("updating tag mountpoints...");const e=C.Tag.findByPath([D.TagRoots.fs]);if(null!=e){e.maybeUpsertDisplayName(m.Settings.tagDisplayNameFS.valueOrDefault);for(const t of e.getChildren())await N(t)}else(0,a.mkLogger)("updateTagMountpoints()").info("No root filesystem tag (new db, I hope?)")}));function R(){t.tagFtsRebuild.unset(),L.unset()}async function N(e){if(null==e||2!==e.depth||!e._path.startsWith(D.TagRoots.fs+p.TagSep))return;const i=(0,a.mkLogger)("fixFileRootTag("+e+")");if(e.name===D.LibraryTagName)return void(1!==e.ordinal&&(i.info("fixing library ordinal",{id:e.id,path:e.path}),e.upsert({ordinal:1}),C.Tag.clear()));if((0,f.forceContextOrSetting)().forceSync&&(0,S.notBlank)(e.displayName)&&(0,E.gt)(e.updatedAt,Date.now()-(0,w.volumeMetadataTtlMs)()))return void i.info("no-op: tag recently updated",{id:e.id,path:e.path,updated:(0,M.fmtDuration)(Date.now()-e.updatedAt)+" ago"});const r=await(0,t.displayNameForVolsha)(e.name);(0,S.notBlank)(r)?(e.maybeUpsertDisplayName(r),i.info("updated tag",{id:e.id,path:e.path,displayName:r}),C.Tag.clear()):i.debug("cannot update tag: no current volume.",{id:e.id,path:e.path})}(0,_.later)((()=>{(0,d.ee)().on("clearCache",R),m.Settings.libraryDir.watchLater(R)})),t.fixFileRootTag=N,t.displayNameForVolsha=(0,u.memoizeAsync)((async e=>{const t=(0,a.mkLogger)("displayNameForVolsha("+e+")"),i=await(0,b.volumes)();if(null!=i){const r=i.find((t=>(0,g.volsha)(t.uuid)===e));return t.info("find()",{vol:r}),null!=r?m.Settings.tagDisplayNameFSLabels.valueOrDefault&&(0,S.notBlank)(r.label)?r.label.trim():"/"===r.mountpoint?m.Settings.tagDisplayNameFSRoot.valueOrDefault+(m.Settings.tagDisplayNameFSRootWithHostname.valueOrDefault?" on "+(0,h.hostname)():""):(0,S.notBlankOr)((0,k.stripPrefixSuffix)(r.mountpoint,{prefix:s.default.sep,suffix:s.default.sep}),s.default.sep):x.AssetFile.dbl.pluckFirstf((t=>t.select("mountpoint").whereLike("uri","psfile://"+e+"/%").limit(1)))}}),{name:"tag.displayNameForVolsha",maxSize:64,timeoutMs:(0,w.volumeMetadataTtlMs)()}),(0,_.later)((()=>{v.mountpoints.watch((()=>t.displayNameForVolsha.clear()))}))},90858:e=>{"use strict";e.exports=require("@iarna/toml")},53705:e=>{"use strict";e.exports=require("@photostructure/tz-lookup")},64770:e=>{"use strict";e.exports=require("assert")},58587:e=>{"use strict";e.exports=require("batch-cluster")},87550:e=>{"use strict";e.exports=require("better-sqlite3")},6858:e=>{"use strict";e.exports=require("commander")},36507:e=>{"use strict";e.exports=require("croner")},66261:e=>{"use strict";e.exports=require("events")},77988:e=>{"use strict";e.exports=require("exiftool-vendored")},66150:e=>{"use strict";e.exports=require("fast-xml-parser")},68817:e=>{"use strict";e.exports=require("file-type")},44652:e=>{"use strict";e.exports=require("fs-extra")},28787:e=>{"use strict";e.exports=require("he")},31832:e=>{"use strict";e.exports=require("knex")},51168:e=>{"use strict";e.exports=require("luxon")},93973:e=>{"use strict";e.exports=require("ml-kmeans")},4927:e=>{"use strict";e.exports=require("papaparse")},83058:e=>{"use strict";e.exports=require("picomatch")},22915:e=>{"use strict";e.exports=require("platform-folders")},57272:e=>{"use strict";e.exports=require("plist")},90595:e=>{"use strict";e.exports=require("punycode")},38064:e=>{"use strict";e.exports=require("semver")},9288:e=>{"use strict";e.exports=require("sharp")},93944:e=>{"use strict";e.exports=require("source-map-support")},49378:e=>{"use strict";e.exports=require("trash")},73872:e=>{"use strict";e.exports=require("type-detect")},92460:e=>{"use strict";e.exports=require("util")},75162:e=>{"use strict";e.exports=require("util/types")},76982:e=>{"use strict";e.exports=require("crypto")},34589:e=>{"use strict";e.exports=require("node:assert")},31421:e=>{"use strict";e.exports=require("node:child_process")},77598:e=>{"use strict";e.exports=require("node:crypto")},40610:e=>{"use strict";e.exports=require("node:dns")},78474:e=>{"use strict";e.exports=require("node:events")},73024:e=>{"use strict";e.exports=require("node:fs")},51455:e=>{"use strict";e.exports=require("node:fs/promises")},37067:e=>{"use strict";e.exports=require("node:http")},44708:e=>{"use strict";e.exports=require("node:https")},77030:e=>{"use strict";e.exports=require("node:net")},48161:e=>{"use strict";e.exports=require("node:os")},76760:e=>{"use strict";e.exports=require("node:path")},53916:e=>{"use strict";e.exports=require("node:path/posix")},1708:e=>{"use strict";e.exports=require("node:process")},57075:e=>{"use strict";e.exports=require("node:stream")},46466:e=>{"use strict";e.exports=require("node:stream/promises")},87997:e=>{"use strict";e.exports=require("node:timers")},57975:e=>{"use strict";e.exports=require("node:util")},38522:e=>{"use strict";e.exports=require("node:zlib")},16928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=86801);module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{var __webpack_modules__={60308:e=>{const t={PasetoNotSupported:"ERR_PASETO_NOT_SUPPORTED",PasetoDecryptionFailed:"ERR_PASETO_DECRYPTION_FAILED",PasetoInvalid:"ERR_PASETO_INVALID",PasetoVerificationFailed:"ERR_PASETO_VERIFICATION_FAILED",PasetoClaimInvalid:"ERR_PASETO_CLAIM_INVALID"};class i extends Error{constructor(e){super(e),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}e.exports.PasetoError=i,e.exports.PasetoNotSupported=class extends i{},e.exports.PasetoDecryptionFailed=class extends i{},e.exports.PasetoInvalid=class extends i{},e.exports.PasetoVerificationFailed=class extends i{},e.exports.PasetoClaimInvalid=class extends i{}},78972:(e,t,i)=>{const{PasetoInvalid:r,PasetoNotSupported:s}=i(60308),{decode:n}=i(47859),a=i(40816);e.exports=(e,{parse:t=!0}={})=>{if("string"!=typeof e)throw new TypeError("token must be a string");const{0:i,1:o,2:l,3:u,length:c}=e.split(".");if(3!==c&&4!==c)throw new r("token is not a PASETO formatted value");if("v1"!==i&&"v2"!==i&&"v3"!==i&&"v4"!==i)throw new s("unsupported PASETO version");if("local"!==o&&"public"!==o)throw new s("unsupported PASETO purpose");const d={footer:u?n(u):void 0,payload:void 0,version:i,purpose:o};if("local"===o)return d;const h="v1"===i?256:"v3"===i?96:64;let f;try{f=n(l).subarray(0,-h)}catch{throw new r("token is not a PASETO formatted value")}return d.payload=t?a(f):f,d}},2744:(e,t,i)=>{const r=i(78972);e.exports={decode:r}},67814:(e,t,i)=>{const r=i(85223);e.exports=({audience:e,expiresIn:t,iat:i=!0,issuer:s,jti:n,kid:a,notBefore:o,now:l=new Date,subject:u},c)=>{if(!(l instanceof Date&&l.getTime()))throw new TypeError("options.now must be a valid Date object");const d=l.getTime();if(void 0!==i){if("boolean"!=typeof i)throw new TypeError("options.iat must be a boolean");i&&(c.iat=new Date(d))}if(void 0!==t){if("string"!=typeof t)throw new TypeError("options.expiresIn must be a string");c.exp=new Date(d+r(t))}if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.notBefore must be a string");c.nbf=new Date(d+r(o))}if(void 0!==e){if("string"!=typeof e)throw new TypeError("options.audience must be a string");c.aud=e}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.issuer must be a string");c.iss=s}if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.subject must be a string");c.sub=u}if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.kid must be a string");c.kid=a}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.jti must be a string");c.jti=n}return c}},10968:(e,t,i)=>{const{PasetoClaimInvalid:r}=i(60308),s=i(85223);e.exports=({ignoreExp:e,ignoreNbf:t,ignoreIat:i,maxTokenAge:n,subject:a,issuer:o,clockTolerance:l,audience:u,now:c=new Date},d)=>{if(!(c instanceof Date&&c.getTime()))throw new TypeError("options.now must be a valid Date object");const h=c.getTime();if("iss"in d&&"string"!=typeof d.iss)throw new r("payload.iss must be a string");if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.issuer must be a string");if(d.iss!==o)throw new r("issuer mismatch")}if("sub"in d&&"string"!=typeof d.sub)throw new r("payload.sub must be a string");if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.subject must be a string");if(d.sub!==a)throw new r("subject mismatch")}if("aud"in d&&"string"!=typeof d.aud)throw new r("payload.aud must be a string");if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.audience must be a string");if(d.aud!==u)throw new r("audience mismatch")}if(void 0!==l&&"string"!=typeof l)throw new TypeError("options.clockTolerance must be a string");const f=l?s(l):0;let m;if("iat"in d){if("string"!=typeof d.iat)throw new r("payload.iat must be a string");if(m=new Date(d.iat).getTime(),!m)throw new r("payload.iat must be a valid ISO8601 string");if(!i&&m>h+f)throw new r("token issued in the future")}if("nbf"in d){if("string"!=typeof d.nbf)throw new r("payload.nbf must be a string");const e=new Date(d.nbf).getTime();if(!e)throw new r("payload.nbf must be a valid ISO8601 string");if(!t&&e>h+f)throw new r("token is not active yet")}if("exp"in d){if("string"!=typeof d.exp)throw new r("payload.exp must be a string");const t=new Date(d.exp).getTime();if(!t)throw new r("payload.exp must be a valid ISO8601 string");if(!e&&t<=h-f)throw new r("token is expired")}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.maxTokenAge must be a string");if(!("iat"in d))throw new r("missing iat claim");if(m+s(n){e.exports.encode=e=>e.toString("base64url"),e.exports.decode=e=>Buffer.from(e,"base64")},80608:e=>{e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if("string"!=typeof e)throw new TypeError("options.assertion must be a string, or a Buffer");return Buffer.from(e,"utf8")}},83561:(e,t,i)=>{const r=i(65825);e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if(r(e))return Buffer.from(JSON.stringify(e),"utf8");if("string"!=typeof e)throw new TypeError("options.footer must be a string, Buffer, or a plain object");return Buffer.from(e,"utf8")}},1658:(e,t,i)=>{const r=i(67814),s=i(65825);e.exports=(e,t)=>{if(Buffer.isBuffer(e)){if(0!==Object.keys(t).length)throw new TypeError("options cannot contain claims when payload is a Buffer");return e}if(!s(e))throw new TypeError("payload must be a Buffer or a plain object");return e=(e=>JSON.parse(JSON.stringify(e)))(e),e=r(t,e),Buffer.from(JSON.stringify(e),"utf-8")}},82115:e=>{e.exports=e=>{const{x:t,y:i}=e.export({format:"jwk"}),r=Buffer.from(i,"base64"),s=2+(1&r[r.length-1]);return Buffer.concat([Buffer.alloc(1,s),Buffer.from(t,"base64")])}},88965:(e,t,i)=>{const r=i(64770),{PasetoInvalid:s}=i(60308),n=i(10968),{decode:a}=i(47859),o=i(40816);e.exports={post:function(e,t,i,r,s,a,l){if(t){if(0!==Object.keys(i).length)throw new TypeError("options cannot contain claims when options.buffer is true");return r?{payload:s,footer:a?.length?a:void 0,version:e,purpose:l}:s}const u=o(s);return n(i,u),r?{payload:u,footer:a?.length?a:void 0,version:e,purpose:l}:u},pre:function(e,t){if("string"!=typeof t)throw new TypeError("token must be a string, got: "+typeof t);if(t.slice(0,e.length)!==e)throw new s(`token is not a ${e.slice(0,e.length-1)} PASETO`);let{0:i,1:n="",length:o}=t.slice(e.length).split(".");try{r(o<=2),i=a(i),n=a(n)}catch{throw new s("token is not a PASETO formatted value")}return{raw:i,f:n}}}},56463:(e,t,i)=>{const r=i(76982),s=i(92460),n=i(70761),a=i(29534),{PasetoDecryptionFailed:o}=i(60308),l=i(82682),{webcrypto:{subtle:u}}=r,c=s.promisify(r.hkdf),d=Buffer.from("paseto-encryption-key"),h=Buffer.from("paseto-auth-key-for-aead"),f=Buffer.alloc(0),m=(e,t)=>r.createHmac("sha384",t).update(e).digest(),p=async(e,t,i,r)=>u[e]({name:"AES-CTR",counter:r,length:16},await u.importKey("raw",i,"AES-CTR",!1,[e]),t).then(Buffer.from),g=p.bind(void 0,"encrypt"),y=p.bind(void 0,"decrypt");e.exports={sign:s.promisify(r.sign),verify:s.promisify(r.verify),"v1.local-encrypt":async function(e,t,i){const s="v1.local.",o=m(e,r.randomBytes(32)).subarray(0,32),l=o.subarray(0,16),[u,f]=await Promise.all([c("sha384",i,l,d,32).then(Buffer.from),c("sha384",i,l,h,32).then(Buffer.from)]),p=await g(e,u,o.subarray(16)),y=n(s,o,p,t),v=m(y,f);return a(s,t,o,p,v)},"v1.local-decrypt":async function(e,t,i){const r=e.subarray(0,32),s=e.subarray(-48),a=e.subarray(32,-48),u=r.subarray(0,16),[f,p]=await Promise.all([c("sha384",i,u,d,32).then(Buffer.from),c("sha384",i,u,h,32).then(Buffer.from)]),g=n("v1.local.",r,a,t),v=m(g,p);if(!l(s,v))throw new o("decryption failed");const w=await y(a,f,r.subarray(16));if(!w)throw new o("decryption failed");return w},"v3.local-encrypt":async function(e,t,i,s){const o="v3.local.",l=r.randomBytes(32),[u,p]=await Promise.all([c("sha384",i,f,Buffer.concat([d,l]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,l]),48).then(Buffer.from)]),y=u.subarray(0,32),v=u.subarray(32),w=await g(e,y,v),b=n(o,l,w,t,s),S=m(b,p);return a(o,t,l,w,S)},"v3.local-decrypt":async function(e,t,i,r){const s=e.subarray(0,32),a=e.subarray(-48),u=e.subarray(32,-48),[p,g]=await Promise.all([c("sha384",i,f,Buffer.concat([d,s]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,s]),48).then(Buffer.from)]),v=p.subarray(0,32),w=p.subarray(32),b=n("v3.local.",s,u,t,r),S=m(b,g);if(!l(a,S))throw new o("decryption failed");const P=await y(u,v,w);if(!P)throw new o("decryption failed");return P}}},70981:(e,t,i)=>{const{KeyObject:r}=i(76982);let{isKeyObject:s}=i(75162);s||(s=e=>null!=e&&e instanceof r),e.exports=s},65825:e=>{e.exports=e=>!!e&&e.constructor===Object},41726:(e,t,i)=>{const{PasetoNotSupported:r}=i(60308);e.exports=e=>{if(!Number.isSafeInteger(e))throw new r("message is too long for Node.js to safely process");const t=~~(e/4294967295),i=e%4294967295-t,s=Buffer.allocUnsafe(8);return s.writeUInt32LE(t,4),s.writeUInt32LE(i,0),s}},85223:e=>{const t=36e5,i=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;e.exports=e=>{const r=i.exec(e);if(!r)throw new TypeError(`invalid time period format ("${e}")`);const s=parseFloat(r[1]);switch(r[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(1e3*s);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(6e4*s);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(s*t);case"day":case"days":case"d":return Math.round(864e5*s);case"week":case"weeks":case"w":return Math.round(6048e5*s);case"year":case"years":case"yr":case"yrs":case"y":return Math.round(315576e5*s)}}},29534:(e,t,i)=>{const{encode:r}=i(47859);e.exports=function(e,t,...i){let s=`${e}${r(Buffer.concat(i))}`;return t.byteLength&&(s+=`.${r(t)}`),s}},70761:(e,t,i)=>{const r=i(41726);e.exports=(...e)=>{e=e.filter(Boolean);let t=r(e.length);for(let i of e){i=Buffer.from(i,"utf8");const e=r(Buffer.byteLength(i));t=Buffer.concat([t,e,i])}return t}},40816:(e,t,i)=>{const{PasetoInvalid:r}=i(60308),{strict:s}=i(64770),n=i(65825);e.exports=e=>{try{const t=JSON.parse(e);return s(n(t)),t}catch{throw new r("All PASETO payloads MUST be a JSON object")}}},92366:(e,t,i)=>{const{sign:r}=i(56463),s=i(70761),n=i(29534);e.exports=async function(e,t,i,a,o,l,u){const c=s(u,e,t,i,l),d=await r(a,c,o);return n(e,i,t,d)}},495:(e,t,i)=>{const{createSecretKey:r}=i(76982),s=i(70981);e.exports=function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}`)&&(t=Buffer.from(t.slice(e.length),"base64url")),!s(t))try{t=r(t)}catch{}if(!s(t))throw new TypeError("invalid key provided");if("secret"!==t.type||32!==t.symmetricKeySize)throw new TypeError(`${e} secret key must be 32 bytes long symmetric key`);return t}},82682:(e,t,i)=>{const{timingSafeEqual:r}=i(76982),s=(e,t)=>{if(e.length===t)return e;const i=Buffer.alloc(t);return e.copy(i),i};e.exports=(e,t)=>{const i=Math.max(e.length,t.length);return r(s(e,i),s(t,i))}},49826:(e,t,i)=>{const{PasetoVerificationFailed:r}=i(60308),{verify:s}=i(56463),n=i(70761),{pre:a}=i(88965);e.exports=async function(e,t,i,o,l,u,c){const{raw:d,f:h}=a(e,t),f=d.subarray(0,-o),m=d.subarray(-o),p=n(c,e,f,h,u);if(!await s(i,p,l,m))throw new r("invalid signature");return{m:f,footer:h.length?h:void 0}}},91227:(e,t,i)=>{const r=i(60308),s=i(79665),n=i(56120),a=i(50015),o=i(64230),{decode:l}=i(2744);e.exports={decode:l,V1:s,V2:n,V3:a,V4:o,errors:r}},39324:(e,t,i)=>{const{"v1.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v1.local"),{pre:n,post:a}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:o=!1,...l}={}){const{raw:u,f:c}=n("v1.local.",e),d=(t=s(t)).export(),h=await r(u,c,d);return a("v1",o,l,i,h,c,"local")}},21472:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v1.local"),n=i(1658),{"v1.local-encrypt":a}=i(56463);e.exports=async function(e,t,{footer:i,...o}={}){const l=n(e,o);t=s(t);const u=r(i),c=t.export();return a(l,u,c)}},79665:(e,t,i)=>{const r=i(77868),s=i(77256),n=i(21472),a=i(39324),o=i(70866);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o}},70866:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=s(r.generateKeyPair),o=s(r.generateKey);e.exports=async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await o("aes",{length:256});return"paserk"===t?`k1.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await a("rsa",{modulusLength:2048});return"paserk"===t?{secretKey:`k1.secret.${e.export({format:"der",type:"pkcs1"}).toString("base64url")}`,publicKey:`k1.public.${i.export({format:"der",type:"pkcs1"}).toString("base64url")}`}:e}default:throw new n("unsupported v1 purpose")}}},77868:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPrivateKey:n}=i(76982),a=i(83561),o=i(1658),l=i(92366),u=i(70981);e.exports=async function(e,t,{footer:i,...c}={}){const d=o(e,c),h=a(i);return t=function(e){if("string"==typeof e&&e.startsWith("k1.secret."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!u(e))try{e=n(e)}catch{}if(!u(e))throw new TypeError("invalid key provided");if("private"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public signing key must be a private RSA key with 2048 bit modulus length");return e}(t),l("v1.public.",d,h,"sha384",{key:t,padding:r,saltLength:s})}},77256:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPublicKey:n}=i(76982),a=i(49826),o=i(70981),{post:l}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:u=!1,...c}={}){t=function(e){if("string"==typeof e&&e.startsWith("k1.public."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!o(e)||"private"===e.type)try{e=n(e)}catch{}if(!o(e))throw new TypeError("invalid key provided");if("public"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public verify key must be a public RSA key with 2048 bit modulus length");return e}(t);const{m:d,footer:h}=await a("v1.public.",e,"sha384",256,{key:t,padding:r,saltLength:s});return l("v1",u,c,i,d,h,"public")}},56120:(e,t,i)=>{const r=i(88451),s=i(859),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(62827);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},62827:(e,t,i)=>{const r=i(64770),s=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:a}=i(60308),o=i(70981),l=n(s.generateKeyPair);async function u(e,t,{format:i="keyobject"}={}){if("keyobject"!==i&&"paserk"!==i)throw new TypeError("invalid format");if("public"===t){const{privateKey:t,publicKey:r}=await l("ed25519");return"paserk"===i?{secretKey:`k${e.slice(1)}.secret.${h(t).toString("base64url")}`,publicKey:`k${e.slice(1)}.public.${h(r).toString("base64url")}`}:t}throw new a(`unsupported ${e} purpose`)}function c(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 64:{const t=s.createPrivateKey({key:Buffer.concat([Buffer.from("302e020100300506032b657004220420","hex"),e.subarray(0,32)]),format:"der",type:"pkcs8"});if(!e.subarray(32).equals(Buffer.from(t.export({format:"jwk"}).x,"base64")))throw new TypeError("invalid byte sequence");return t}case 32:return s.createPublicKey({key:Buffer.concat([Buffer.from("302a300506032b6570032100","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 64 bytes (private key), or 32 bytes (public key)")}}function d(e,t){if(!o(t))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public key must be an Ed25519 key`);switch(t.type){case"public":return Buffer.from(t.export({format:"jwk"}).x,"base64");case"private":{const{d:e,x:i}=t.export({format:"jwk"});return Buffer.concat([Buffer.from(e,"base64"),Buffer.from(i,"base64")])}}}function h(...e){return d("v2",...e)}e.exports={_checkPrivateKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.secret.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,64)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t))try{t=s.createPrivateKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("private"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public signing key must be a private ed25519 key`);return t},_checkPublicKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.public.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,32)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t)||"private"===t.type)try{t=s.createPublicKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("public"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public verify key must be a public ed25519 key`);return t},_generateKey:u,_keyObjectToBytes:d,bytesToKeyObject:c,generateKey:async function(...e){return u("v2",...e)},keyObjectToBytes:h}},88451:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(92366),{_checkPrivateKey:a}=i(62827),o=a.bind(void 0,"v2");e.exports=async function(e,t,{footer:i,...a}={}){const l=s(e,a);t=o(t);const u=r(i);return n("v2.public.",l,u,void 0,t)}},859:(e,t,i)=>{const r=i(49826),{_checkPublicKey:s}=i(62827),{post:n}=i(88965),a=s.bind(void 0,"v2");e.exports=async function(e,t,{complete:i=!1,buffer:s=!1,...o}={}){t=a(t);const{m:l,footer:u}=await r("v2.public.",e,void 0,64,t);return n("v2",s,o,i,l,u,"public")}},18582:(e,t,i)=>{const{"v3.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v3.local"),n=i(80608),{pre:a,post:o}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:l=!1,assertion:u,...c}={}){const{raw:d,f:h}=a("v3.local.",e);t=s(t);const f=n(u),m=t.export(),p=await r(d,h,m,f);return o("v3",l,c,i,p,h,"local")}},43406:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v3.local"),n=i(1658),a=i(80608),{"v3.local-encrypt":o}=i(56463);e.exports=async function(e,t,{footer:i,assertion:l,...u}={}){const c=n(e,u);t=s(t);const d=r(i),h=a(l),f=t.export();return o(c,d,f,h)}},50015:(e,t,i)=>{const r=i(42438),s=i(65466),n=i(43406),a=i(18582),{generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}=i(80568);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}},80568:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=i(70981),o=i(82115),l=s(r.generateKeyPair),u=s(r.generateKey);function c(e){if(!a(e))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public key must be an EC P-384 key");switch(e.type){case"public":return o(e);case"private":return Buffer.from(e.export({format:"jwk"}).d,"base64")}}e.exports={generateKey:async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await u("aes",{length:256});return"paserk"===t?`k3.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await l("ec",{namedCurve:"P-384"});return"paserk"===t?{secretKey:`k3.secret.${c(e).toString("base64url")}`,publicKey:`k3.public.${c(i).toString("base64url")}`}:e}default:throw new n("unsupported v3 purpose")}},bytesToKeyObject:function(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 48:return r.createPrivateKey({key:Buffer.concat([Buffer.from("303e0201010430","hex"),e,Buffer.from("a00706052b81040022","hex")]),format:"der",type:"sec1"});case 49:if(2!==e[0]&&3!==e[0])throw new TypeError("invalid compressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3046301006072a8648ce3d020106052b81040022033200","hex"),e]),format:"der",type:"spki"});case 97:if(4!==e[0])throw new TypeError("invalid uncompressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3076301006072a8648ce3d020106052b81040022036200","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 48 bytes (private key), 49 bytes (compressed public key), or 97 bytes (uncompressed public key)")}},keyObjectToBytes:c}},42438:(e,t,i)=>{const{createPrivateKey:r}=i(76982),s=i(83561),n=i(1658),a=i(80608),o=i(92366),l=i(70981),{bytesToKeyObject:u}=i(80568),c=i(82115);e.exports=async function(e,t,{footer:i,assertion:d,...h}={}){const f=n(e,h),m=s(i),p=a(d);return t=function(e){if("string"==typeof e&&e.startsWith("k3.secret."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,48)}catch{}if(Buffer.isBuffer(e))try{e=u(e)}catch{}if(!l(e))try{e=r(e)}catch{}if(!l(e))throw new TypeError("invalid key provided");if("private"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public signing key must be a private EC P-384 key");return e}(t),o("v3.public.",f,m,"sha384",{key:t,dsaEncoding:"ieee-p1363"},p,c(t))}},65466:(e,t,i)=>{const{createPublicKey:r}=i(76982),s=i(80608),n=i(49826),a=i(70981),{bytesToKeyObject:o}=i(80568),l=i(82115),{post:u}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:c=!1,assertion:d,...h}={}){t=function(e){if("string"==typeof e&&e.startsWith("k3.public."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,49)}catch{}if(Buffer.isBuffer(e))try{e=o(e)}catch{}if(!a(e)||"private"===e.type)try{e=r(e)}catch{}if(!a(e))throw new TypeError("invalid key provided");if("public"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public verify key must be a public EC P-384 key");return e}(t);const f=s(d),{m,footer:p}=await n("v3.public.",e,"sha384",96,{key:t,dsaEncoding:"ieee-p1363"},f,l(t));return u("v3",c,h,i,m,p,"public")}},64230:(e,t,i)=>{const r=i(29901),s=i(77933),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(24961);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},24961:(e,t,i)=>{const{_checkPrivateKey:r,_checkPublicKey:s,_generateKey:n,_keyObjectToBytes:a,bytesToKeyObject:o}=i(62827);e.exports={_checkPrivateKey:r,_checkPublicKey:s,bytesToKeyObject:o,generateKey:async function(...e){return n("v4",...e)},keyObjectToBytes:function(...e){return a("v4",...e)}}},29901:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(80608),a=i(92366),{_checkPrivateKey:o}=i(24961),l=o.bind(void 0,"v4");e.exports=async function(e,t,{footer:i,assertion:o,...u}={}){const c=s(e,u),d=n(o);t=l(t);const h=r(i);return a("v4.public.",c,h,void 0,t,d)}},77933:(e,t,i)=>{const r=i(80608),s=i(49826),{_checkPublicKey:n}=i(24961),{post:a}=i(88965),o=n.bind(void 0,"v4");e.exports=async function(e,t,{complete:i=!1,buffer:n=!1,assertion:l,...u}={}){t=o(t);const c=r(l),{m:d,footer:h}=await s("v4.public.",e,void 0,64,t,c);return a("v4",n,u,i,d,h,"public")}},37975:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),s=i(38639),n=i(44198);function a(){return(0,s.toNotBoolean)((0,n.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,n.env)().NO_COLOR)||["dumb","unknown"].includes((0,n.env)().TERM))}t.noColor=a;let o=!a();function l(){return o}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){o=e??!a()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),s=i(7282),n=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,s.isProd)()?"":`-${(0,s.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+n.version))},48884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),s=i(36783),n=i(76790),a=i(22573),o=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const s=new Set(t.map(i));return e.filter((e=>s.has(i(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...v(e.slice(i+1))]}function w(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function b(e){return P(e,(e=>e.valueOf()))}function S(e){return _(e,(e=>e.valueOf()))}function P(e,t){return T(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return T(e,t,((e,t)=>(0,h.gt)(e,t)))}function M(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function T(e,t,i){return E(e,t,i).index}function E(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let s,n=-1;for(let r=0;re.slice(i,i+t)))}async function D(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,o.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(a.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,o.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,s.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let s=0;for(const n of e)(t(n,s++)?i:r).push(n);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let s=0;se.slice(0,t+1)))},t.min=function(e){return e[b(e)]},t.leastIndex=b,t.max=function(e){return e[S(e)]},t.greatestIndex=S,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=M,t.least=function(e){return M(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const i=E(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=k,t.collectBatched=function(e,t,i){const s=[];for(const n of k((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(i(n)));return s},t.collectBatchedAsync=async function(e,t,i){const s=[];for(const n of k((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(await i(n)));return s},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await D(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+s;if(re+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const o=i(77988),l=a(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),v=i(25764),w=i(38836),b=i(99331),S=i(95937),P=i(98314),_=i(38835),M=i(70025),T=i(8769),E=i(43334),k=i(95402),D=i(28874),x=i(63870);class C extends w.EndableWrapper{constructor(e,t,i=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>n(this,r,"m",s).call(this)),i,"worker"===e?(0,x.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const a=t;a.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,k.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),a.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),a.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,S.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),a.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),a.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),a.on("noTaskData",((e,i,r)=>{const s=t.options.streamFlushMillis;s{this.logger.error("observeBatchCluster.endError()",e)})),a.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&k.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof o.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,b.ending)()||!0===(0,M.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,T.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=C,r=new WeakSet,s=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(E.isWin?3:1)*c.minuteMs,maxTasksPerProcess:D.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:D.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:D.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:D.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:D.Settings.taskTimeoutMs.valueOrDefault}}},71371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedGreatestSet=void 0;const r=i(92322);t.BoundedGreatestSet=class{constructor(e,t){this.maxLength=e,this.toValue=t,this.sortedArray=new r.SortedSet(t)}toA(){return this.vacuum(),this.sortedArray.toA()}vacuum(){return this.sortedArray.retainLastN(this.maxLength)}add(...e){this.maxLength<=0||(this.sortedArray.addAll(...e),this.sortedArray.length>=2*this.maxLength&&this.vacuum())}}},89788:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(r.add(this),this.maxLength=e,s.set(this,void 0),n.set(this,0),a.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,s,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]=t))}get length(){return u(this,n,"f")}set length(e){l(this,n,(0,d.clamp)(0,u(this,n,"f"),e),"f")}clear(){this.length=0}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,n,"f")),e<0||e>=u(this,n,"f")?void 0:t((e+u(this,a,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,s,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,n,"f"){u(this,s,"f")[e]=c}));return u(this,n,"f")}pop(){return u(this,r,"m",o).call(this,u(this,n,"f")-1,(e=>{var t;return l(this,n,(t=u(this,n,"f"),--t),"f"),u(this,s,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,n,"f"){u(this,s,"f")[e]=c,l(this,a,e,"f")}));return u(this,n,"f")}shift(){return u(this,r,"m",o).call(this,0,(e=>{var t,i;return l(this,a,(t=u(this,a,"f"),++t),"f"),l(this,n,(i=u(this,n,"f"),--i),"f"),u(this,s,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",o).call(this,u(this,n,"f")-1-e,(e=>{const i=u(this,s,"f")[e];u(this,s,"f")[e]=u(this,s,"f")[t],u(this,s,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),s=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function n(e){for(const{bom:t,encoding:i}of s)if(a(e,t))return e.subarray(t.length).toString(i);return e.toString()}function a(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=n,t.bufferToString=function(e){return Buffer.isBuffer(e)?n(e):(0,r.toS)(e)},t.bufferStartsWith=a},9092:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=s},36638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=s},40583:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const a=i(40958),o=i(23838),l=n(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new o.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,a.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,s=-1;for(const[i,n]of this.m.entries()){const a=(0,c.diceCoeff)(i,e);if(a>t&&a>s){const e=this.getFirst(n);null!=e&&(r=e,s=a)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),s=i(31586),n=i(68708),a=i(54993),o=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new o.Average(0);for(const t of this.keys()){if(!(0,s.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,a.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,s.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,n.tap)(new o.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,s]of this.m.entries()){const n=e(r);t.fill(n,i,i+s),i+=s}return t}}t.CountingSet=u},79840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),s=i(72993),n=i(45969),a=i(43334);t.EditionType=(0,r.lazy)((()=>a.isElectron?"Desktops":(0,n.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>s.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),s=i(55835),n=i(68708);var a=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return a.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,s.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.omit)(e,...i),(0,n.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,s.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),s=i(19851),n=i(95696);t.examples=(0,s.lazy)((()=>n.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),s=i(65843),n=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,s.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,n.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(31586),o=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,a.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,a.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,s.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,s.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,n.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,o.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,o.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,o.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,a.isNumber)(e.__uid)&&(0,a.isNumber)(e.__start)}},80049:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),s.set(this,0),n.set(this,0),a.set(this,0),o.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,s,l(this,s,"f")+e.cacheHitsAsync,"f"),u(this,n,l(this,n,"f")+e.cacheMisses,"f"),u(this,a,l(this,a,"f")+e.rejections,"f"),u(this,o,l(this,o,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,s,"f"),cacheMisses:l(this,n,"f"),rejections:l(this,a,"f"),timeouts:l(this,o,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,a,o;if(!this.cache.has(e))return void u(this,n,(t=l(this,n,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,s,(i=l(this,s,"f"),++i),"f"),c.promise):(u(this,r,(a=l(this,r,"f"),++a),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(o=l(this,r,"f"),++o),"f"),c}get(e){var t,i;const s=this.cache.get(e);return null==s||s instanceof m.Deferred&&s.isPending?u(this,n,(t=l(this,n,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),s instanceof m.Deferred?s.value:s}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,s,0,"f"),u(this,n,0,"f"),u(this,a,0,"f"),u(this,o,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,a,(t=l(this,a,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,o,(r=l(this,o,"f"),++r),"f")})),r.promise}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap},54127:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,a.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,s.range)(0,r).filter((e=>this.rows.every((t=>(0,n.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,o.fromEntries)(e))).filter((e=>(0,o.values)(e).some(n.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,o=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(o,r.index);(0,n.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),h=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:h});else{const e=(0,s.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,a.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}o=t.lastIndex}const l=(0,s.last)(i);return null!=l&&((0,n.blank)(this.headerRow.slice(o))?l.rightIdx=(0,a.max_)(...this.rows.map((e=>e.length))):l.rightIdx=o),i}}t.Fixed=m},73168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const r=i(55835),s=i(20014),n=i(55222),a=i(97352),o=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,a.within)(-90,90,e)&&0!==e}function c(e){return(0,a.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function h(e,t,i=o){return(0,r.map)(m(e,t,l(i)),(e=>n.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=o){return h(e?.lat,e?.lon,t)},t.geohash=h,t.geohashNumericShort=function(e,t){return m(e,t,30)};const f=new s.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=o){return d(e,t)?f.zip([t,e],l(i)):void 0}function p(e,t=o){return f.unzip(e,l(t))?.reverse()}function g(e,t=o){const[i,r]=p(e,t);return{lat:i,lon:r}}t.geohashNumeric=m,t.ungeohash=function(e,t=o){return(0,r.map)(n.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,r=t.lat*Math.PI/180,s=(t.lat-e.lat)*Math.PI/180,n=(t.lon-e.lon)*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(r)*Math.sin(n/2)*Math.sin(n/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},66364:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSuspended=void 0;const r=i(19851);t.isSuspended=(0,r.lazy)((()=>!1))},80875:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),s=i(98553);var n=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return n.parseJSON}}),t.mapParsed=function(e,t){const i=(0,s.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,s.parseJSON)((await(0,r.readFile)(e)).toString())}},19851:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const a=i(57975),o=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&n(this,r,"m",s).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,o.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,o.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=b(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>S(v()??await(m.isWin?P():m.isMac?M():T()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function b(e){if((0,n.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=w.exec(e.trim())?.groups;return null==i?void 0:(0,s.compact)([i.lang,i.country]).join("-")}function S(e){return b(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=S,t.localeWin=P;const _={timeoutMs:10*a.secondMs};async function M(){return b(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function T(){return S(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=M,t.localePosix=T,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),s=i(1708),n=i(45599),a=i(68708),o=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,n.defer)((()=>{(0,o.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:s.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,a.pick)(s.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:s.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),s=i(32105),n=i(14593);t.rootLoggers=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));const a=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));t.mkLogger=function(e){return new n.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new n.ContextualLogger(e,a)}},56639:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),s=i(55835),n=i(59455),a=i(48884);function o(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,a.concat)(...e.map((e=>t(e)))))},t.compactMap=o,t.toMap=function(e,t){return o((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:o(await Promise.all((0,r.compact)((0,n.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,s.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),s=i(54557);t.memoize=function(e,t){let i=0;const n=new s.FifoCache(t.maxSize,t.ttlMs),a=t=>{if(null!=t)return i++,n.getOrSet((0,r.stringify)(t),(()=>e(t)))};return a.clear=e=>null==e?n.clear():n.delete((0,r.stringify)(e)),a.size=()=>n.size,a.callCount=()=>i,a}},31578:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const r=i(1708),s=i(31586),n=i(12168),a=i(70417);function o(){const e=(0,r.memoryUsage)();return(0,a.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,r.memoryUsage)().rss}t.memoryUsageBytes=o,t.memoryUsageMb=function(){return(0,s.sigFigs)(o()/n.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,s.sigFigs)(l()/n.MB,2)}},7282:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const s=r(i(1708)),n=i(38639),a=i(54993),o=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,o.lazy)((()=>s.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,a.toS)(s.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return s.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,n.isTrue)(s.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){s.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},26033:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._isSupportedNode=t.RequiredNodeRange=t.isSupportedNode=void 0;const r=i(45599),s=i(76280);function n(e=process.versions.node){return(0,s.semverSatisfies)(e,t.RequiredNodeRange)}t.isSupportedNode=(0,r.defer)(n),t.RequiredNodeRange="18||20||21",t._isSupportedNode=n},97352:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55835),o=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,o.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(o.gt0)},t.firstNonZero=function(...e){for(const t of(0,n.flatten)(e)){const e=(0,o.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,a.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,o.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,o.toInt)(e),s=(0,o.toInt)(t);return null!=r&&r>0&&null!=s&&s>0?i(r,s):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,o.isNumber)(e))return e;if((0,s.blank)(e))return;const t=String(e);return(0,a.map)(f.exec(t),(e=>(0,o.toFloat)(t.substr(e.index))))}function p(e){return(0,o.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,a.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,a.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const s=i*e.length;for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),s=i(42659),n=i(96249),a=i(55835),o=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,s.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,s]of(0,l.entries)(e)){const e=t(r,s);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,a.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(a.defined)},t.firstDefinedField=function(e,...t){return(0,a.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,a.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const s of t)r[s]=i(s,e[s]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let s=0;for(const n of(0,l.keys)(e))if(r[n]=t(n,e[n]),s++,(0,o.gt)(s,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,n.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),s=i(73024),n=i(48161),a=i(19851),o=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),v=i(30933),w=(0,a.lazy)((()=>(0,f.mkLogger)("os")));function b(){return(0,n.platform)()+" "+(0,n.release)()}t.osArch=(0,a.lazy)((()=>`${function(){switch((0,n.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return C();case"win32":return F();default:return b()}}()} on ${(0,n.arch)()}`)),t.osFullName=(0,a.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const S=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function _(){return"ubuntu"===(0,t.osDistributionLinux)()}function M(){return"fedora"===(0,t.osDistributionLinux)()}function T(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,a.lazy)((()=>{if(g.isLinux)for(const e of S)try{const t=(0,s.readFileSync)(e).toString();if((0,o.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,a.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,o.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),b)})),t.osDistributionLinux=(0,a.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=_,t.hasApt=function(){return P()||_()},t.isFedora=M,t.isAlpine=T;const E={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},k={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function D(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),s=t[i];return(0,c.isString)(s)?s:s?.[r]}const x=(0,a.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function C(e=x()){try{return(0,o.mapNotBlankOr)(function(e=x()){return D(e,E)}(e),(t=>`macOS ${t} (${e})`),b)}catch(e){return w().warn("osNameMac(): unknown release",e),b()}}function F(e=(0,n.release)()){const t=e.startsWith("10.0.22")?"11":D(e,k);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=C,t.osNameWin=F,t.CPUs=(0,a.lazy)((()=>(0,h.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,a.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(F())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=x();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(_())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(M())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(T())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},45393:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetVersion=t.AssetFileVersion=void 0,t.AssetFileVersion=12,t.AssetVersion=4},12801:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const s=r(i(48161)),n=i(50989);t.PriorityClasses=(0,n.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:s.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:s.default.constants.priority.PRIORITY_NORMAL,BelowNormal:s.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:s.default.constants.priority.PRIORITY_LOW,Low:s.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeRandomUid=t.safeRandomChars=void 0;const r=i(55222),s=i(65713);t.safeRandomChars=function({radix:e=r.TokenRadix,length:t}){return(0,s.decuss)((()=>e.randomChars(t)))},t.safeRandomUid=function(e){return(0,s.decuss)((()=>(e?.radix??r.TokenRadix).randomUid(e?.chars??20,e?.splitEveryN??5,e?.sepChar??"-")))}},409:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),s=i(56409),n=i(31586),a=i(22911),o=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...r){f=!0,m=Date.now()+(0,n.max_)(t,i);const s=d=new a.Deferred(c);(0,n.gt0)(i)&&s.setTimeout(i);try{s.resolve(await e(...r))}catch(e){s.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,o.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return s.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,r.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new s.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),s=i(54993);function n(e){return e instanceof a?e.source:(0,s.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let s;for(;null!=(s=e.exec(t));)s.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(s,"index","groups"));return i},t.escapeRegExp=n,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(n(t))}const s=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(s,i)};class a{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=a;class o extends a{static from(...e){const t=l(e);return new o("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,o=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof a||t instanceof RegExp?(i+=t.source,r||(r=t.global),o||(o=t.ignoreCase),l||(l=t.multiline)):i+=n((0,s.toS)(t));return new RegExp(i,t??(r?"g":"")+(o?"i":"")+(l?"m":""))}t.RegExpOptional=o,t.concatRegexp=l},79089:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),v=i(34102),w=i(43334),b=i(24399),S=i(28874),P=(0,a.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>T.prior()?.clear()))));const _=(0,a.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",n.default.basename(S.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,o.compactBlanks)([n.default.basename(e),...t.map((e=>n.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let M=!0;const T=(0,a.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||T().has(e))return;T().add(e);const i=(0,p.priorityPosixToClass)(t)??S.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),M)try{return s.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;M=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await b.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const s=r(i(1708)),n=i(19851),a=i(40958),o=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===o.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===o.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===o.ServiceNames.sync}function p(){return(0,t.serviceName)()===o.ServiceNames.test}t.serviceName=(0,n.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,n.lazy)((()=>(0,a.compactBlanks)([t.serviceName.prior(),(0,l.toS)(s.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return o.ServiceNames.indexOf(e)??o.ServiceNames.length+1},t.MainServices=[o.ServiceNames.main,o.ServiceNames.desktop],t.DbServices=[o.ServiceNames.sync,o.ServiceNames.info,o.ServiceNames.web,o.ServiceNames.list,o.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[o.ServiceNames.sync,o.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===o.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===o.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,n.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function s(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=s,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=s(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=s(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),s=i(57150),n=i(7282),a=i(23560),o=i(17181);t.setServiceName=function(e){(0,a.isMainService)(e)&&(e=r.ServiceNames.main);const t=a.serviceName.prior();t!==e&&((0,n.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),a.serviceName.set(e),(0,o.setupLogger)(),(0,s.logStartup)())}},28850:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const o=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends o.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),s.set(this,void 0),n(this,r,e,"f")}_call(){return(0,l.time)(a(this,r,"f")+(null==a(this,s,"f")?"(local)":"(remote)"),null==a(this,s,"f")?this.impl():a(this,s,"f").call(this))}setShim(e){n(this,s,e,"f")}hasShim(){return null!=a(this,s,"f")}clearShim(){n(this,s,void 0,"f")}}r=new WeakMap,s=new WeakMap},12089:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,a){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=a,s.set(this,void 0),n.set(this,void 0),l(this,s,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",o).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",a).call(this,e),(()=>u(this,r,"m",o).call(this,e)))}setShim(e){l(this,n,e,"f")}hasShim(){return null!=u(this,n,"f")}clearShim(){l(this,n,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",a).call(this,e))}}s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},o=function(e){return(0,m.time)(u(this,s,"f")+(null==u(this,n,"f")?"(local)":"(remote)"),null==u(this,n,"f")?this.impl(e):u(this,n,"f").call(this,e))}},45255:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const n=i(76790),a=i(17586);class o{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return s(this,r,"f")[Symbol.iterator]()}get length(){return s(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=s(this,r,"f").length-1;for(;t<=i;){const n=t+Math.floor((i-t)/2),a=this.valueOf(s(this,r,"f")[n]);if(e===a)return{found:!0,index:n};e>a?t=n+1:i=n-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&s(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...s(this,r,"f")];const a=t=>t<0||t>s(this,r,"f").length-1?null:(i??this.diff)(s(this,r,"f")[t],e),o=this.findIndex(e);if(null==o)return;let l=o.index-1,u=a(l),c=o.index,d=a(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return s(this,r,"f").shift()}at(e){return(0,a.at)(s(this,r,"f"),e)}toA(){return[...s(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===s(this,r,"f").length-1){const e=[...s(this,r,"f")];return s(this,r,"f").length=0,e}return s(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return s(this,r,"f").splice(e,t)}retainLastN(e){return e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),s=i(82328),n=i(84542),a=i(95705),o=i(28874);t.consoleLog=function(e,...t){o.Settings.quiet.valueOrDefault||(0,s.stdoutEnded)()||console.log((0,n.crlf)(e),...t)},t.consoleError=function(e){o.Settings.quiet.valueOrDefault||(0,a.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=o.Settings.quiet.envValue;try{return o.Settings.quiet.envValue=!0,await e()}finally{o.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),s=i(95705);t.stdoutEnded=function(){return(0,s.streamEnded)(r.stdout)}},71567:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const s=r(i(1708)),n=i(22573),a=i(98553),o=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:s.default.stdout})}function f({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const s=(0,a.stringify)(e,void 0,(0,o.isInfoService)()||(0,o.isMainService)()?2:void 0);r.write(s+"\n"),(0,o.isWorkerService)()&&null!=i&&(s.includes(u.FailStr)||(0,c.isFatalError)(s)||(0,c.isHealthCheckError)(s)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||s.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:s.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,n.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const s=t.indexOf(i,r);return-1===s?0:1+e(t,i,s+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,n.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,o.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,h.toS)(e),s=(0,h.toS)(t);return s.length>0&&(0,c.equalsIgnoreCase)(r.slice(-s.length),s,i)?r.slice(0,-s.length):r},t.gist=function(e,t=80,i=80){const r=(0,h.toS)(e),s=r.length-(t+i);return s<=0?r:r.slice(0,t).trim()+" …(+"+s+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function b(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function S(e){return(0,d.toA)(e).sort(b)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,n.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=b,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=S,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,a.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=b(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,n.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),s=t.indexOf(r);if(s>=0)return{index:s,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function M(e){return _.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=M;const T=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,n.blank)(e)||(e=(0,h.toS)(e).trim(),null!=T.exec(M(e))&&(e=e.slice(1,-1).trim())),e};const E=/^['‘’].*['‘’]$/,k=/^["“”„«»〃].*["“”„«»〃]$/;function D(e,t){const i=x(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function x(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let s,n=0;for(;null!=(s=t.exec(e));)s.index===t.lastIndex?t.lastIndex++:(t.lastIndex=s[0].length+s.index,i.push(e.substring(n,s.index)),r.push(e.substring(s.index,t.lastIndex)),n=t.lastIndex);return n(0,o.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),E.test(e)||k.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),s=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,a.map)(i[e],(e=>t+=e))));return t},t.splitKeep=D,t.splitUp=x,t.sortNaturalBy=C,t.sortNatural=function(e){return(0,s.sortBy)(e,(e=>C(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=S((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,s.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,n.blank)(e)||(0,n.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,o.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const F=/#.*$/gm;t.stripComments=function(e){return e.replace(F,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,n.blank)(r))for(const e of r.split(t))(0,n.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,n.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),s=e.findIndex((e=>r.test(e))),a=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(s<0)return e;for(let t=s+1;te.trim()))))}},83556:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function s(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=s,t.asObjectKey=function(e){return s(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const s=r(i(77598)),n=i(73913),a=i(55222);function o(e,t=n.HashBits){return s.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=a.Radix58,r=224){return i.encodeBuffer(o(e,r)).substring(0,t)}t.stringShaToBuffer=o,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=a.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(31586),o=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,s="";for(let n=0;n=r&&(r=i.get(n,a),s=(0,l.substr)(e,n-r+1,r)));return s}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),s=t.normalize();return e!==r||t!==s?y(r,s):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function v(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===r?1:void 0),(()=>(0,n.blank)(e)!==(0,n.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(i),t=w(r);return 2*b(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function b(e,t){const i=(0,f.intersection)(e,t),s=[];return i.forEach((i=>{const n=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,a.times)(n,(()=>s.push(i)))})),s}function S(e,t,i){const s=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,s))-i((0,l.strslice)(t,s))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,s.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[i,r]=[e,t].map(P).map((e=>(0,n.blank)(e)?"":e));return S(i,r,(e=>(0,a.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(n.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=b,t.lnsDiff=_;const M=/[^\da-z]+/gi;function T(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(M,"").toLowerCase()));return S(i,r,(e=>c.RadixAlphaNum.decode(e)))}function E(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const s=(0,a.mapNumericOr)(e.charCodeAt(r),(e=>e),256),n=(0,a.mapNumericOr)(t.charCodeAt(r),(e=>e),256),o=(0,a.clamp)(-256,256,s-n);i=null==i?o:(i+o)/2}return i}t.radixDiff=T,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:_(e,t),radixDiff:T(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=E,t.paddedPositionalDiff=function(e,t,i=8){return E((0,o.leftPad)(e,i," "),(0,o.leftPad)(t,i," "))}},84885:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),s=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,s.sortedKeys)(e))}},75387:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",s.set(this,[]),n.set(this,new Map),a.set(this,void 0),o.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,a,"f")}set ttlMs(e){h(this,a,e,"f"),null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),h(this,o,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,n,"f").clear(),this}delete(e){return d(this,n,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,n,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,n,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,n,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const s=t();return null!=s&&this.set(e,s),s}lastSetOrGetTs(e){return d(this,n,"f").get(e)?.ts}set(e,t){return d(this,n,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,n,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,n,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,f.sortBy)(d(this,n,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,s,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,n,"f").delete(e);for(const i of d(this,s,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,n,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[a]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return o(this,r,"m",n).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>o(this,r,"m",n).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||o(this,r,"m",s).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)o(this,r,"m",s).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!o(this,r,"m",s).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield[t,t])}()}toA(){return o(this,r,"m",n).call(this),[...this.delegate.keys()]}[(r=new WeakSet,a=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,s=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},n=function(){for(const[e,t]of this.delegate)o(this,r,"m",s).call(this,e,t)}},84699:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},65211:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resetUid=t.sortByUid=t.tsFromUid=t.isUID=t.uidForTs=t.uid=t.uidSuffix=void 0;const r=i(19851),s=i(76790),n=i(22573),a=i(54993),o=i(7282),l=i(55222);let u=0;const c=l.GeoRadix;function d(e){return c.encode(e)+(0,t.uidSuffix)()}t.uidSuffix=(0,r.lazy)((()=>"-"+c.randomChars(7))),t.uid=function(){return u=Math.max(Date.now(),u+1),d(u)},t.uidForTs=d;const h=/^[\da-z]{9}-[\da-z]{7}$/i;function f(e){const t=(0,a.toS)(e).replace(/(?<=\S)-.*/,"");return(0,n.blank)(t)?void 0:c.decode(t)}t.isUID=function(e){return h.test((0,a.toS)(e))},t.tsFromUid=f,t.sortByUid=function(e){return(0,s.sortBy)(e,(e=>f(e.uid)))},t.resetUid=function(){if(!(0,o.isTest)())throw new Error("unsupported");t.uidSuffix.unset(),u=0}},94174:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,a.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,a.lazy)((()=>(0,o.uniq)([n.default.geteuid?.(),n.default.getuid?.(),s.default.userInfo().uid]))),t.userid=(0,a.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,a.lazy)((()=>(0,o.uniq)([n.default.getegid?.(),n.default.getgid?.(),s.default.userInfo().gid]))),t.groupid=(0,a.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,a.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,a.lazy)((()=>(0,l.toNotBlank)(s.default.userInfo()?.username))),t.userNameFromWhoami=(0,a.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,a.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,a.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,a.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.1-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=1,t.versionPrerelease=["prealpha"],t.release="2024.3.1-prealpha+20240308150212",t.gitSha="d92384e8659ff46fbae8e6f81fa5867114a4a843",t.gitDate=new Date(1709938932e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48299:function(e,t){"use strict";var i,r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.WeakCache=void 0;class o{constructor(){i.add(this),this[n]="WeakCache",r.set(this,new Map)}clear(){return a(this,r,"f").clear(),this}delete(e){return a(this,r,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of this.entries())e(i,t,this)}findEntry(e){for(const[t,i]of this.entries())if(e(i,t,this))return i}deleteValueIf(e){for(const[t,i]of this.entries())e(i,t,this)&&a(this,r,"f").delete(t)}get(e){const t=a(this,r,"f").get(e),i=t?.deref();return null==i&&null!=t&&a(this,r,"f").delete(e),i}getOrMaybeSet(e,t){const i=a(this,r,"f").get(e)?.deref();if(null!=i)return i;const s=t();return null!=s&&this.set(e,s),s}set(e,t){return a(this,r,"f").set(e,new WeakRef(t)),this}has(e){return null!=a(this,r,"f").get(e)?.deref()}get size(){return a(this,i,"m",s).call(this),a(this,r,"f").size}keys(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries())null==i.deref()?a(e,r,"f").delete(t):yield t}()}values(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield s}}()}entries(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield[t,s]}}()}[(r=new WeakMap,i=new WeakSet,n=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}}t.WeakCache=o,s=function(){for(const[e,t]of a(this,r,"f").entries())null==t.deref()&&a(this,r,"f").delete(e)}},48963:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),s=i(55835),n=i(31586),a=i(97790),o=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,n.toInt)(e)));if(!(0,s.allDefined)(i))return;const[a,o,u,c,d,h,f]=i,m=(0,n.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(a,o-1,u,c,d,h,f/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,a.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(n.toInt).filter((e=>(0,o.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},79184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aggregateAssetFiles=void 0;const r=i(59455),s=i(48884),n=i(22859),a=i(28874),o=i(79781),l=i(92434);t.aggregateAssetFiles=async function(e){const t=(0,r.toA)((0,l.sortAssetFiles)(e)??e);return(a.Settings.assetAggregation.valueOrDefault===n.AggregateTypes.union?s.clusterSome:s.clusterEvery)(t,o.isSimilarAssetFile)}},79781:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotSimilarAssetFile=t.isSimilarAssetFile=t.whyNotSameAsset=t.VideoImageMismatchMsg=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(50357),o=i(55835),l=i(31586),u=i(68708),c=i(12168),d=i(23467),h=i(73168),f=i(50213),m=i(86580),p=i(48368),g=i(80361),y=i(28874),v=i(28544),w=i(75767),b=i(16170),S=(0,r.lazy)((()=>(0,f.mkLogger)("sync-file.AssetFileComparator")));function P(e,t,i,r=((e,t)=>[e,t])){const s=e[i],o=t[i];if((0,n.blank)(s)||(0,n.blank)(o)||(0,a.eql)(s,o))return;const[l,u]=r(s,o);return(0,a.eql)(l,u)||(0,a.eql)(s,u)||(0,a.eql)(l,o)?void 0:`Different ${String(i)}: ${s} ≠ ${o}`}function _(e){return(0,n.mapNotBlank)(e,(e=>e.toLowerCase().trim().normalize()))}function M(e,t){return[_(e),_(t)]}function T(e,t,i){const r=(0,w.findInequalFields)(e[i],t[i]);return null==r?void 0:`Different ${i} (${r.aKey}:${r.aValue} ≠ ${r.aKey}:${r.aValue})`}function E(e,i){if(!(0,u.allKeysDefined)(e,"width","height","mimetype","sha"))return"af1 was missing required fields";if(!(0,u.allKeysDefined)(i,"width","height","mimetype","sha"))return"af2 was missing required fields";if((0,d.definedAndEql)(e.sha,i.sha))return void S().debug("matching SHA",{af1:e,af2:i});const r=(0,b.isVideoMimeType)(e.mimetype),n=(0,b.isVideoMimeType)(i.mimetype);if(r!==n)return S().tap({msg:"whyNotIsSimilar",result:t.VideoImageMismatchMsg,meta:{af1:e.uri,af2:i.uri,af1IsVideo:r,af2IsVideo:n}});const a=v.CapturedAt.fromAssetFile(e),f=v.CapturedAt.fromAssetFile(i);if(null==a)return"af1 missing capturedAt metadata";if(null==f)return"af2 missing capturedAt metadata";const _=a.isFuzzy||f.isFuzzy;if(_&&y.Settings.allowFuzzyDateImageHashMatches.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if((0,g.isSimilarImageHash)(t,r,{rotationsToCheck:(0,m.validRotations)(e,i)}))return void S().info("allowFuzzyDateImageHashMatches mode: image hashes match",{af1:e,af2:i})}if(!a.overlaps(f))return`captured-at ${a.toISOStringWithPrecision()} != ${f.toISOStringWithPrecision()}`;const E=P(e,i,"make",M)??P(e,i,"model",M);if(null!=E)return E;const k=(0,o.map)((0,h.geohashDistanceMeters)(e.geohash,i.geohash),(e=>(0,l.sigFigs)(e,2))),D={cameraId:T(e,i,"cameraId")??null,imageId:T(e,i,"imageId")??null,lensId:T(e,i,"lensId")??null,exposureSettings:(0,w.whyExposureSettingsNotSimilar)(e,i)??null,closeGeoHash:(0,l.gt)(k,y.Settings.gpsErrorMeters.valueOrDefault)?"geohashes are "+(0,c.fmt)(k)+"m different: too far apart":null};S().debug("whyNotSimilar()",{fields:D});const x=(0,s.compact)((0,u.values)(D));if((0,s.isNotEmpty)(x))return x.join(";");if(y.Settings.useImageHashes.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if(null!=t&&null!=r){const e=(0,g.compareImageHashes)(t,r,{capturedAtIsFuzzy:_});return!0===e?.isSimilar?void 0:e?.whyNotSimilar}}return(0,u.keys)(D).filter((e=>null==D[e])).length>=y.Settings.minMatchesWithoutImageHashes.valueOrDefault?void 0:"Insufficient metadata correlation"}t.VideoImageMismatchMsg="Videos ≠ images",t.whyNotSameAsset=function(e,t,i){{const i=E(e,t);if(null!=i)return i}if("intersection"===y.Settings.assetAggregation.valueOrDefault)for(const r of i)if(r.id!==t?.id){const t=E(e,r);if(null!=t)return t}},t.isSimilarAssetFile=function(e,t){return null==E(e,t)},t.whyNotSimilarAssetFile=E},13991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkSortableAssetFile_=t.mkAssetFile_=t.assetFileMetadata_=t.assetFileImageHashFields_=t.imageHashToAssetFileImageHashFields=t.assetFileStatFields_=t.assetFileUriFields_=void 0;const r=i(19851),s=i(55835),n=i(31586),a=i(59455),o=i(73168),l=i(50213),u=i(12089),c=i(76490),d=i(95696),h=i(48368),f=i(70417),m=i(28874),p=i(43207),g=i(47783),y=(0,r.lazy)((()=>(0,l.mkLogger)("asset-file.AssetFileFactory")));async function v(e){try{return{nativePath:e.nativePath,uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath}}catch(t){return y().throw("Failed to build URI for "+e,{error:t})}}async function w(e){const t=await e.stat_(),i=await e.sidecareStats();return{mtime:Math.floor((0,f.max)([t.mtimeMs,...(0,a.toA)(i).map((e=>e.mtimeMs))])),fileSize:t.size}}function b(e){return{...e,...c.DominantColor.toModeData(e.dominantColors)}}async function S(e){if(!m.Settings.useImageHashes.valueOrDefault)return;const t=await(0,h.imageHash_)(e.nativePath);return null==t?y().throw("Failed to extract image hash for "+e):b(t)}async function P(e){const[i,r,s,n]=await Promise.all([v(e),w(e),(0,t.assetFileMetadata_)(e),e.sha_()]);return{...i,...r,...s,sha:n}}t.assetFileUriFields_=v,t.assetFileStatFields_=w,t.imageHashToAssetFileImageHashFields=b,t.assetFileImageHashFields_=S,t.assetFileMetadata_=(0,u.shim1)({name:"asset-file.assetFileMetadata",impl:async function(e){try{const t=d.PosixFile.for(e),i=await(0,g.readTags)(t);if(null==i)throw new Error("Failed to read tags");if(null==i.capturedAt)throw new Error("Failed to read capturedAt");const r=i.capturedAt.toAssetFileFields();return null==r?y().throw("Failed to render assetFileFields from capturedAt",{capturedAt:i.capturedAt}):{...r,...i.exposureSettings,...i.dimensions,mimetype:i.mimetype,rotation:i.rotation,make:i.Make,model:i.Model,rating:i.rating,cameraId:i.cameraId,imageId:i.imageId,lensId:i.lensId,geohash:(0,o.geohashNumericShort)(i.GPSLatitude,i.GPSLongitude),durationMs:(0,p.extractDurationMs)(i),fps:(0,s.map)((0,n.toFloat)(i.VideoFrameRate),Math.floor)}}catch(t){return y().throw("_assetFileMetadata_() failed",{nativePath:e,error:t})}}}),t.mkAssetFile_=async function(e){const[t,i]=await Promise.all([P(e),S(e)]);return{...t,...i}},t.mkSortableAssetFile_=P},92434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestExistingAssetFile=t.assetFileSortCriteria=t.assetFileSortFields=t.assetFileSortCriteriaPojo=t.sortAssetFiles=t.mtime2sort=t.sortScale=t.dim2sort=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(23838),u=i(31586),c=i(68708),d=i(34666),h=i(50989),f=i(89937),m=i(50213),p=i(4001),g=i(29882),y=i(28874),v=i(14036),w=i(45200),b=i(34238),S=(0,r.lazy)((()=>(0,m.mkLogger)("img.AssetFileSorter"))),P=(0,h.strEnum)("file",f.PS_NETWORK_FILESYSTEM_SCHEME,f.PS_LOCAL_FILE_SCHEME,f.PS_LIBRARY_SCHEME);function _(e){return(0,u.map2Numeric)(e?.width,e?.height,((e,t)=>M(e*t)))}function M(e){if((0,u.gt0)(e))return Math.round(Math.pow(e,y.Settings.variantSortCriteriaPower.valueOrDefault))}function T(e){return Math.round(e/(5*o.minuteMs))}t.dim2sort=_,t.sortScale=M,t.mtime2sort=T;const E=["make","model","rating","cameraId","imageId","lensId","geohash"];function k(e){for(const t of(0,l.groupBy)(e,(e=>e.sha)).values())if(t.length>1){const e=Math.max(...(0,s.compact)(t.map((e=>e.mtime))));for(const i of t)i.mtime=e}return(0,n.sortBy)(e,C).reverse()}function D(e){const t=b.URI.parse(e.uri);if((0,a.blank)(t?.scheme)||(0,a.blank)(t?.path))return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI)",{uri_scheme:t?.scheme,uri_path:t?.path,af:e,parsedURI:t});const i=_(e);if(null==i)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid resolution)",{resolution:i,af:e,parsedURI:t});const r=P.indexOf(t.scheme);if(null==r)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI scheme)",{uri_scheme:t.scheme,af:e,parsedURI:t});const s=e.mtime??0,n=(0,g.parsePosixPath)(t.path),l=[];for(const t of E)(0,a.blank)(e[t])||l.push(t);const u={resolution:i,schemeIdx:r,capturedAtPrecision:-(e.capturedAtPrecisionMs??o.weekMs),metadataCoverage:l.length,metadataFields:l.join(","),isBrowserSupported:(0,v.isSupportedByCurrentBrowserExt)(n.ext),mtime:T(s),isEditOrUpdate:/edit|update/i.test(n.base),isCover:/cover/i.test(n.base),count:Math.abs((0,p.copySuffixCountFromName)(n.name)??0),basename:d.CmpReverseFlag+n.base,parentBasename:d.CmpReverseFlag+(0,g.parentBasename)(e.nativePath??t.path),uri:d.CmpReverseFlag+e.uri};return S().tap({msg:"assetFileSortCriteriaPojo()",result:(0,c.toReqValued)(u)})}function x(){return(0,s.uniq)([...y.Settings.variantSortCriteria.values,"uri"])}function C(e){const t=D(e);if(null==t)return;const i=[];for(const e of x())i.push(t[e]);return i}t.sortAssetFiles=k,t.assetFileSortCriteriaPojo=D,t.assetFileSortFields=x,t.assetFileSortCriteria=C,t.bestExistingAssetFile=async function(e){for(const t of k(e))if(await(0,w.uriExists)(t.uri,t.nativePath))return S().tap({msg:"bestExistingAssetFile()",result:t,meta:{files:e.map((e=>e.uri))}});return S().tap({msg:"bestExistingAssetFile(): no existing uris",result:void 0,meta:{files:e.map((e=>e.uri))}})}},54296:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetFileNativePath=void 0;const r=i(45200);t.getAssetFileNativePath=async function(e){return e.nativePath??(e.nativePath=await(0,r.uri2nativePath)(e.uri,e.mountpoint))}},73568:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const o=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),s.set(this,(0,o.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,n(this,s,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return n(this,s,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,n(this,s,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),a(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=n(this,r,"f")&&clearTimeout(n(this,r,"f")),a(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,s=new WeakMap},69591:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const s=r(i(87997)),n=i(31586);t.debounce=function(e,t){let i,r=[];const a=(0,n.gt0)(t)?(...n)=>{r=n,null!=i&&s.default.clearTimeout(i),i=s.default.setTimeout((()=>{e(...r)}),t)}:e;return a.reset=()=>{null!=i&&s.default.clearTimeout(i),i=void 0},a.force=()=>{a.reset(),e()},a.setTimeoutMs=e=>{a.reset(),t=e},a.timeoutMs=()=>t,a}},22911:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(i(87997)),w=y(i(57975)),b=i(45599),S=i(26905),P=i(55835),_=i(31586),M=i(68708),T=i(20214),E=i(57153),k=i(85556),D=i(50213),x=i(70025),C=i(95937),F="TIMEOUT",A=(0,b.defer)((()=>(0,D.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,_.gt0)(t)?new s(F).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const s=i[r];if(s.isSettled){if(s.name===F)return void A().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield s.value}}if(i.every((e=>e.name===F)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new s(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),a.set(this,void 0),o.set(this,E.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=s,s,(y=p(i,s,"f",n),m=y++,y),"f",n),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,D.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof s&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,o,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,M.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,a,"f")}get elapsedMs(){return(p(this,a,"f")??Date.now())-this.startedAt}get[(a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,T.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,T.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new k.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,C.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,o,"f")===E.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,o,"f")!==E.PromiseStates.pending}get isResolved(){return p(this,o,"f")===E.PromiseStates.resolved}get isRejected(){return p(this,o,"f")===E.PromiseStates.rejected}get settledMs(){return null==p(this,a,"f")?void 0:p(this,a,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,o,E.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,x.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,S.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,o,E.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,s=I,m=function(e){if(p(this,o,"f")===E.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,a,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},n={value:0}},27395:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(23838),o=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new a.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*n.minuteMs);const y=5*n.secondMs;async function v(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,o.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,s.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,s.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",a).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,s.set(this,void 0),n.set(this,void 0),o.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,s,"f")}hasTimeout(){return null!=u(this,n,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",a).call(this);const h=()=>{u(this,r,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,s,(0,d.setInterval)(u(this,o,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,n,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,o,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref()):h(),!0}}t.EndableInterval=v,s=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(){(0,h.map)(u(this,s,"f"),d.clearInterval),c(this,s,void 0,"f"),(0,h.map)(u(this,n,"f"),d.clearTimeout),c(this,n,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const o=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,a){this.endTimeoutMs=a,r.set(this,void 0),this.onEnds=[],s.set(this,(0,o.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),n(this,s,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){a(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return n(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return n(this,s,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,s=new WeakMap},99331:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let s=!1;t.ending=function(){return s},t.setEnding=function(e){s=(0,r.isTest)()?e:e||s}},45608:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const s=r(i(1708)),n=i(22573),a=i(45599),o=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,a.defer)((()=>(0,l.mkLogger)((0,o.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,a.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,n.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,f.endEndables)(),s.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,a.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])s.default[e].on(t,(i=>{v({reason:`${e}:${t}`,status:0,error:i})}))}))},39250:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LastOneInWins=void 0;const n=i(23838),a=i(54993),o=i(15674),l=i(73568),u=i(76740),c=i(99331),d=i(42638);t.LastOneInWins=class{constructor(e,t=o.maxCpus){this.name=e,this.maxConcurrency=t,r.set(this,new n.MultiMap),this.p=new d.Promises(e,t)}vacuum(){return s(this,r,"f").filterInPlace(((e,t)=>t.isPending&&!0!==t.payload?.aborted)),s(this,r,"f").valueCount()}enqueue({key:e,abortable:t,fn:i}){for(const t of s(this,r,"f").get(e)??[])t.payload?.abort("aborted by new work");if(this.vacuum(),(0,c.ending)())throw new l.AbortError("ending");const n=t??new u.Abortable,o=this.p.serial((0,a.toS)(e),(()=>i(n)),n);return s(this,r,"f").add(e,o),o}},r=new WeakMap},60172:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,r)=>{t=e,i=r})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,s.set(this,void 0),n.set(this,0),a.set(this,void 0),o.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,a,"f")}unset(){d(this,n,0,"f"),d(this,s,void 0,"f"),d(this,a,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,o,"f").push(e)}prior(){return this.isStale()?void 0:c(this,a,"f")}lastValue(){return c(this,a,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,n,"f")}isStale(){return null==c(this,s,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,s,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,s,"f")?void 0:Date.now()-c(this,s,"f")}elapsedMs(){return c(this,a,"f")?.settledMs??c(this,a,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,o,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,o,"f"))e.onError(t)}finally{d(this,n,(i=c(this,n,"f"),++i),"f")}},u=function(e){d(this,s,Date.now(),"f");const t=c(this,a,"f");return d(this,a,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,a,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,a,"f")),c(this,a,"f")}},1728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),s=i(80049);t.memoizeAsync=function(e,t){let i=0;const n=new s.FifoCacheAsync(t),a=t=>(i++,n.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return a.clear=e=>{if(null==e)return n.clear();{const t=(0,r.stringify)(e);return n.deleteIf((e=>t===e))}},a.size=()=>n.size,a.callCount=()=>i,a}},22781:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),s.set(this,!1),n.set(this,!1)}_call(){return a(this,s,"f")?(o(this,n,!0,"f"),!0===this.undefinedIfBusy?void 0:a(this,r,"f")):(o(this,s,!0,"f"),o(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{o(this,s,!1,"f"),!0===this.runLaterIfBusy&&a(this,n,"f")&&(o(this,n,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return a(this,s,"f")}prior(){return a(this,r,"f")}async force(){return await a(this,r,"f"),this._call()}}r=new WeakMap,s=new WeakMap,n=new WeakMap},37461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),s=i(76790),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),v=i(15674),w=i(42638);var b=i(20214);async function S(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:i,timeoutMs:s}){const n=[];for(const a of(0,r.compact)(await t))try{const e=await((0,l.gt0)(s)?(0,c.thenOrTimeoutError)(i(a),s):i(a));null!=e&&n.push([e,a])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:a,error:t})}return n}async function M({arr:e,f:t,name:i,maxConcurrent:s,timeoutMs:n,promises:a}){if(null==e)return[];const o=(0,r.compact)(await e);if((0,r.isEmpty)(o))return[];if((s=Math.round(s??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:i,timeoutMs:n});const u=a??(o.length<=s?w.PermissivePromises:new w.Promises(i,(()=>s))),d=(0,l.gt0)(n)?e=>(0,c.thenOrTimeoutError)(t(e),n):t,h=await u.enqueueAll(i,o.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return b.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=S,t.thenCollectBatched=async function(e,t,i){const r=[];for(const s of(0,p.batches)((0,f.toA)(await e),t)){const e=await S(s);r.push(...await S(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,o.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=M,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n}){return(await M({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:s,timeoutMs:n}){return(await M({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:s,timeoutMs:n})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await M({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,n.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,n.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*a.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,s=null;try{r=await((0,h.isFunction)(e)?e():e)}catch(e){s=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(s??r)}catch{}if(null!=s)throw s;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,n.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const s=await t;return null!=s?i(r,s):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const s=await t(r);return null==s?i():s},t.thenMap2Or=async function(e,t,i,r){const s=await e;if(null==s)return r();const n=await t;if(null==n)return r();const a=await i(s,n);return null==a?r():a},t.thenAnd=async function(e,t){return null!=e&&(0,n.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await M({name:e,arr:t,f:i});return(0,s.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),v=i(25764),w=i(38836),b=i(73614);function S(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),s=(0,l.clamp)(10*a.secondMs,a.minuteMs,Math.round(this.times.get(e)?.p98??0)),n=(0,b.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),s);try{const s=await(0,c.tot)(t),n=Date.now()-r;return i?.(s,n),this.push(e,n),s}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(n)}}get entriesBySumDesc(){return(0,n.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(S(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,o.getOrSet)(this.times,S(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(S(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/a.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function _(e,t,i){return P.instance().time(e,t,i)}function M(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,s.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const i=Date.now(),r=t();return M(e,Date.now()-i),r},t.pushTime=M,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>_(e,t)),i)}},42638:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),v=i(54993),w=i(89788),b=i(82647),S=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){r.add(this),this.name=e,this.ee=new f.default.EventEmitter,s.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new b.Average,n.set(this,0),a.set(this,[]),o.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,s,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,S.maxCpus)(),d(this,s,"f")?.call(this)??(0,S.maxCpus)()))}end(){return d(this,o,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,a,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,n,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,a,"f").map((e=>e.name)),pendingNames:d(this,o,"f").map((e=>e.d.name)),totalWorkCount:d(this,n,"f")}}enqueue({name:e,l:t,payload:i,serialId:s}){const n=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:s});return this.laterPop(),n}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,a,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,o,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,o,"f").length,e),i=this.runningSerialIds,s=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,a,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,o,"f").length}hasPending(){return d(this,o,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,o,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,o,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const s=new P.Deferred(e,{payload:i,serialId:r});return d(this,o,"f").push({d:s,l:t}),s},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,n,(t=d(this,n,"f"),++t),"f"),(0,m.remove)(d(this,a,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,a,"f").push(e),e},t.maybeRun=function(e,t){const i=new _(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new _(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},59189:function(e,t){"use strict";var i,r=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},s=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SerialLaterQueue=void 0,t.SerialLaterQueue=class{constructor(){i.set(this,Promise.resolve())}enqueue(e){return s(this,i,r(this,i,"f").catch().then(e),"f")}},i=new WeakMap},4867:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),s=i(34546),n=i(41400),a=i(31586),o=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let o=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>o=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>{if(o)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(o)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>l=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>o.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),s=i(42659),n=i(41400),a=i(32639),o=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,o.clamp)(10*m,l.ShortCommandTimeoutMs,(t??s.minuteMs)/5);await(0,n.delay)(r,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const s=r(i(1708)),n=i(45599),a=i(41400),o=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),v=i(50213),w=i(7282),b=i(88158),S=i(45969),P=i(43334),_=i(28874),M=i(3790);function T(e){return E().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const E=(0,n.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,b.sortedKeys)((0,l.filter)((0,d.env)(),(e=>T(e))))},(0,a.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const k=["HOME","LANG","USER"],D=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],x=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?k:D),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function C(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,S.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,_.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,o.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(s.default.env,(e=>T(e)||!(0,M.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=C,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:A({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let F=!1;function A({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const s=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...x(),...i?(0,g.childProcLocale)():{},...C(r),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(s);if((0,y.isLogged)("debug")&&!F){F=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(s).map((([e,t])=>[e,(0,M.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>T(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return s}t.childEnv=A},84777:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const s=r(i(31421)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),v=i(79089),w=i(45255),b=i(22911),S=i(4867),P=i(73614),_=i(70025),M=i(57159),T=i(36868),E=i(66184),k=i(45643),D=i(95402),x=i(9727),C=(0,a.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function F(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function A(e,t=30*u.secondMs){if(null==e)return!1;C().debug("endProcess()",F(e));const i=e.pid;if(null==i||i<=0)return C().warn("endProcess(): asked to end invalid pid",F(e)),!1;if(i===n.default.pid)return C().warn("endProcess(): asked to end MY pid",F(e)),!1;if(i===n.default.ppid)return C().warn("endProcess(): asked to end my parent pid",F(e)),!1;(0,T.closeStreams)(e);{const t=e.kill();C().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,D.killPid)(i).catch((e=>{C().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,k.waitForPidExit)(i,t))return C().debug("endProcess(): exitted",F(e)),!0;{D.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");C().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,D.killPid)(i,!0).catch((e=>{C().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,k.waitForPidExit)(i,5e3)}function I(e,i,r,s=0){const a=new Date,o=[];return(0,v.niceable)(i,r)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(s,u.secondMs)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&A(e)}),s-250)),o.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,D.addPid)({pid:e.pid,cmd:i,timeoutMs:s,ppid:n.default.pid},a)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>o.forEach(clearTimeout))),e}function O(e,t,i,r){const n=(0,x.spawnOptions)(r);return(0,E.isLogged)("trace",C().context)?C().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:n}):C().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(s.default.execFile(e,t,n),e,t,i)}async function L(e,t,i){const r=i.quiet??!1,s=i.ignoreStderr??!1,n=i.ignoreExitCode??!1,a=O(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{a.disconnect?.()}catch{}return{result:"",pid:a.pid}}const u=a.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new b.Deferred(f);a.on("error",(e=>g.push(e))),a.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),a.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,T.endStream)(a.stdin);const v=new d.Latch;null==a.stdout?v.resolve():(a.stdout.on("error",(e=>g.push(e))),a.stdout.on("data",(e=>m.push(e))),a.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==a.stderr||s?P.resolve():(a.stderr?.on("error",(e=>g.push(e))),a.stderr?.on("data",(e=>p.push(e))),a.stderr?.on("end",(()=>P.resolve()))),C().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,S.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),C().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,S.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt}),await(0,S.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt});const E=p.join("");(0,l.notBlank)(E)&&g.push(new Error(E)),!r&&(0,o.isNotEmpty)(g)&&C().warn(f+" resulted in errors:",g);const k=i.isIgnorableError??_.isIgnorableError,D=g.filter((e=>!0!==k(e)));if(D.length>0)throw 1===D.length?D[0]:new M.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:D});if(!n&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:E}}catch(e){throw C().error("stdoutResult_() failed",e),await(0,D.killPid)(a.pid,!0),e}}t.endProcess=A,t.ReniceAfterMs=(0,a.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,a.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const n=(0,x.spawnOptions)(r);return C().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(s.default.spawn(e,t,n),e,t,i)},t.execFile=O,t.stdoutResult_=L,t.stdout_=async function(e,t,i){const r=await L(e,t,i);return C().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},3790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),s=i(41400),n=i(19851),a=i(28874);(0,s.later)((()=>a.Settings.sensitiveEnvRegExp.watchLater((()=>o.unset()))));const o=(0,n.lazy)((()=>{try{return new RegExp(a.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${a.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(a.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&o().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||a.Settings.license.includesEnvKey(e)}},34330:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(54993),w=i(27395),b=i(25764),S=i(99331),P=i(42638),_=i(38835),M=i(8769),T=i(57159),E=i(66003),k=i(50213),D=i(45643),x=i(28874),C=i(84777);t.mkBasicWatchedChild=function(e){return new F({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,C.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class F{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,k.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),s.set(this,!1),this.onError=(e,t,i)=>{const n=new T.WrappedError(e,{cause:t}),a=!1!==n.ignorable;this.logger().log(a?"warn":"error","onError()",n),u(this,s,"f")||a||(this.lastError=n,(0,M.onError)(n),!0!==n.fatal?(i??this.opts.onError(e,n))&&(this.logger().warn("onError requested restart",{src:e,error:n}),u(this,r,"m",o).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:x.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:b.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,w.addEndable)(this.opts.endableRank,this),u(this,r,"m",o).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,s,"f")}async end(){return c(this,s,!0,"f"),u(this,r,"m",n).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",n).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,s,"f")}),!u(this,s,"f")&&!(0,S.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",n).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=F,s=new WeakMap,r=new WeakSet,n=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,s,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",a).call(this,e)},a=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,D.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,C.endProcess)(e,this.endTimeoutMs)},o=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",n).call(this),!this._stopped&&!u(this,s,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,M.onError)("Can't restart "+this.name+", failure rate is too high."+_.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,s,"f")}),this._stopped||u(this,s,"f")||(0,S.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,E.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,v.toS)(e).includes("Error: Cannot find module")&&(0,M.onError)("Failed to start "+this.name+_.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,s,"f")}),(0,S.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",o).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const a=n(i(53916)),o=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,o.toNativePath_)(e);const i=f.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),s=i.sibling(r);if(s.isSelfOrDescendantOf((0,l.examples)()))return a.join("$examples",s.posixPathFrom((0,l.examples)()));const n=(0,d.originalsDir)();if(s.isSelfOrDescendantOf(n))return a.join("$library",s.posixPathFrom(n));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?a.join("$library",s.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const n=i(6858),a=i(1708),o=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),h=i(43334),f=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return s(this,r,"f").push(...e),this}async parse(e=a.argv,t){let i=(0,m.addHelpFooter)(new n.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of s(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":o.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,a.exit)(0)})),i.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=i.opts();for(const e of s(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),s=i(31586),n=i(51926),a=i(17344),o=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,s.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,n.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,a.EditionName)()+" v"+o.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const r=i(38639),s=i(17181),n=i(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,r.mapBoolean)(e.color,(e=>{n.Settings.logColor.envValue=e,(0,s.setupLogFormatter)()}))}}},83210:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDaemon=void 0;const s=r(i(1708)),n=i(22573),a=i(38639);t.isDaemon=function(e){return(0,a.isTrue)(s.default.env.__is_daemon)||(0,a.isTrue)(e?.daemon)||!(0,n.blank)(e?.pidfile)}},53978:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimingArg=void 0;const r=i(28874),s=i(38639);t.TimingArg={beforeParse:e=>e.option("--timing","On exit, emit timing information to stdout."),afterParse:async e=>{(0,s.isTrue)(e.timing)&&(r.Settings.emitTimingsOnExit.value=!0)}}},94361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),s=i(40958),n=i(55835),a=i(31586),o=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,a.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,s.compactBlanks)([c("user id","PUID",(0,o.userids)()),c("group id","PGID",(0,o.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,n.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},43380:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WriteSettingsArg=void 0;const r=i(28874),s=i(2858),n=i(22573),a=i(38639),o=i(46292);t.WriteSettingsArg={beforeParse:e=>e.option("--write-settings","Write (or re-write, if they exist) system and library settings.toml files. See https://phstr.com/settings"),afterParse:async e=>{if((0,a.isTrue)(e.writeSettings)){const e=await(0,s.writeSystemSettings_)();if(null==e?console.info("--write-settings: Failed write system settings: no system configuration directory was found.",{checkedDirectories:(0,o.osConfigDirs)()}):console.info(`--write-settings: Wrote system settings to ${e}`),(0,n.blank)(r.Settings.libraryDir.valueOrDefault))console.error("--write-settings: Failed to write library settings: no PS_LIBRARY_DIR is set.");else{const e=await(0,s.writeLibrarySettings_)();console.info(`--write-settings: Wrote library settings to ${e}`)}}}}},54772:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestLabhashName=t.bestLabName=t.bestRgbName=t.colorToTuple=t.bestRgbTripletName=t.ColorNames=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(31586),o=i(48884),l=i(50213),u=i(81168),c=i(85810),d=i(42079),h=i(91482),f=i(3048),m=i(85409),p=i(16050),g=i(42022),y=i(85042),v=(0,r.lazy)((()=>(0,l.mkLogger)("color.ColorNames")));function w(e){const t=(0,y.normalizeRgbHex)(e.rgb);if(null==t)return void v().warn(`skipping invalid entry (bad rgb): ${e.rgb}`,e);const i=(0,c.rgbhex2Lab)(t);if(null==i)return void v().warn(`skipping invalid entry (failed to convert to L*a*b): ${t}`,e);const r=(0,c.toLabhash)(i,g.ModeBits);return{...e,rgb:t,lab:i,labhash:r,closeLabhashes:[r],closeRgb:[t],name:(0,u.capitalize)(e.name)}}function b(e,i){return null==e?void 0:(0,o.leastBy)(i??(0,t.ColorNames)(),(t=>(0,f.ciede2000_delta_e)(t.lab,e)))}t.ColorNames=(0,r.lazy)((()=>(0,s.compact)([...d.CrayonColors,...d.CrayonSupplements,...h.DarkWikipediaColors,...p.LightWikipediaColors,...m.Greys].map(w)))),t.bestRgbTripletName=function(e,i=(0,t.ColorNames)()){return b((0,c.rgb2lab)(e),i)},t.colorToTuple=w,t.bestRgbName=function(e){return P((0,c.rgbhex2Labhash)(e))},t.bestLabName=b;const S=new Map;function P(e){return(0,a.gte0)(e)?(0,n.getOrSet)(S,e,(()=>{const i=(0,t.ColorNames)().find((t=>t.labhash===e));if(null!=i)return i;const r=(0,c.unlabhash)(e),n=b(r);return null!=r&&null!=n&&((0,s.pushUniq)(n.closeLabhashes,e),(0,s.pushUniq)(n.closeRgb,(0,c.lab2rgbhex)(r))),n})):void 0}t.bestLabhashName=P},85810:(e,t,i)=>{"use strict";e=i.nmd(e),Object.defineProperty(t,"__esModule",{value:!0}),t.hsv2rgb=t.hsl2hsv=t.hsv2hsl=t.hsl2rgb=t.rgb2hsl=t.rgbhex2hsl=t.rgb2hsv=t.closestLab=t.maxLabhash=t.minLabhash=t.unlabhash=t.toLabhash=t.LabBitZip=t.xyz2rgb=t.lab2xyz=t.xyz2lab=t.rgb2xyz=t.clampLab=t.lab2rgb=t.rgb2lab=t.rgb2labArray=t.rgb2labTriplets=t.lab2rgbhex=t.rgbhex2Labhash=t.rgbhex2Lab=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(55835),o=i(31586),l=i(48884),u=i(20014),c=i(75503),d=i(3048),h=i(42022),f=i(85042),m=[[.4124564,.3575761,.1804375],[.2126729,.7151522,.072175],[.0193339,.119192,.9503041]],p=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]];function g(e){return _(w(e))}function y(e){return(0,f.clampRGB)(T(M(e)))}function v(e){return(0,t.LabBitZip)().clampValue(e)}function w(e){const t=(0,f.clampRGB)(e).map((e=>e/255)).map((e=>e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92));return(0,c.matXvec)(m,t)}t.rgbhex2Lab=function(e){return(0,a.map)((0,f.rgbhex2triplet)(e),g)},t.rgbhex2Labhash=function(e,t=h.ModeBits){return(0,a.map)((0,f.rgbhex2triplet)(e),(e=>E(g(e),t)))},t.lab2rgbhex=function(e){return(0,f.rgbTriplet2hex)(y(e))},t.rgb2labTriplets=function(e){return(0,s.stepRange)(0,e.length,3).map((t=>g([e[t],e[t+1],e[t+2]])))},t.rgb2labArray=function(e){const t=[],i=[],r=[];for(let s=0;se>S?Math.pow(e,1/3):(P*e+16)/116));return v([116*i-16,500*(t-i),200*(i-r)])}function M(e){const[t,i,r]=v(e),s=(t+16)/116,n=i/500+s,a=s-r/200,o=n*n*n,l=a*a*a,u=o>S?o:(116*n-16)/P,c=t>8?Math.pow(s,3):t/P,d=l>S?l:(116*a-16)/P;return[u*b.X,c*b.Y,d*b.Z]}function T(e){return(0,c.matXvec)(p,e).map((e=>{const t=e<0?-1:1,i=e*t;return(0,o.round)(255*t*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055))}))}function E(e,i=h.ModeBits){return(0,t.LabBitZip)().zip(e,i)}t.xyz2lab=_,t.lab2xyz=M,t.xyz2rgb=T,t.LabBitZip=(0,r.lazy)((()=>new u.BitZip([{min:0,max:100},{min:-79,max:90},{min:-102,max:89}]))),t.toLabhash=E;const k=new Map;function D(e,i=h.ModeBits){return(0,t.LabBitZip)().unzip(e,i)}function x(e){const[t,i,r]=(0,f.clampRGB)(e),s=Math.max(t,i,r),n=s-Math.min(t,i,r),a=n?s===t?(i-r)/n:s===i?2+(r-t)/n:4+(t-i)/n:0;return[60*(a<0?a+6:a),s?n/s*100:0,s/255*100]}function C(e){return F(x(e))}function F(e){const[t,i,r]=e,s=(200-i)*r/100;return[t,s>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,s/2]}function A(e){const[t,i,r]=e,s=i*(r<50?r:100-r)/100;return[t,s>0?2*s/(r+s)*100:0,r+s]}function I(e){const t=e[0]/360*6,i=e[1]/100,r=e[2]/100,s=Math.floor(t),n=r*(1-i),a=r*(1-(t-s)*i),o=r*(1-(1-t+s)*i),l=s%6;return(0,f.clampRGB)([255*[r,a,n,n,o,r][l],255*[o,r,r,a,n,n][l],255*[n,n,o,r,r,a][l]])}t.unlabhash=function(e,t=h.ModeBits){return t===h.ModeBits?(0,n.getOrSet)(k,e,(()=>D(e,t))):D(e,t)},t.minLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMin(h.ModeBits))),t.maxLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMax(h.ModeBits))),t.closestLab=function(e,t){return(0,l.leastBy)(e,(e=>(0,d.ciede2000_delta_e)(e,t)))},t.rgb2hsv=x,t.rgbhex2hsl=function(e){return C((0,f.rgbhex2triplet)(e))},t.rgb2hsl=C,t.hsl2rgb=function(e){return I(A(e))},t.hsv2hsl=F,t.hsl2hsv=A,t.hsv2rgb=I,i.c[i.s]===e&&console.log(E([0,0,0]))},42079:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CrayonSupplements=t.CrayonColors=void 0,t.CrayonColors=[{name:"Aquamarine",rgb:"#95E0E8"},{name:"Asparagus",rgb:"#7BA05B"},{name:"Blue-green",rgb:"#0095B7"},{name:"Royal blue",rgb:"#273BE2"},{name:"Blush",rgb:"#DB5079"},{name:"Brilliant rose",rgb:"#E667CE"},{name:"Brown",rgb:"#AF593E"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Burnt umber",rgb:"#805533"},{name:"Cadet blue",rgb:"#A9B2C3"},{name:"Canary",rgb:"#FFFF99"},{name:"Carmine",rgb:"#E62E6B"},{name:"Carnation pink",rgb:"#FFA6C9"},{name:"Celestial blue",rgb:"#7070CC"},{name:"Cerise",rgb:"#DA3287"},{name:"Cerulean blue",rgb:"#339ACC"},{name:"Chestnut",rgb:"#B94E48"},{name:"Cobalt blue",rgb:"#8C90C8"},{name:"Copper",rgb:"#DA8A67"},{name:"Cornflower",rgb:"#93CCEA"},{name:"Cotton candy",rgb:"#FFB7D5"},{name:"Denim",rgb:"#1560BD"},{name:"Eggplant",rgb:"#614051"},{name:"Fern",rgb:"#63B76C"},{name:"Fuchsia",rgb:"#C154C1"},{name:"Russet",rgb:"#87421F"},{name:"Green",rgb:"#01A638"},{name:"Green-yellow",rgb:"#F1E788"},{name:"Indigo",rgb:"#4F69C6"},{name:"Jungle green",rgb:"#29AB87"},{name:"Magenta",rgb:"#F653A6"},{name:"Maize",rgb:"#F2C649"},{name:"Maroon",rgb:"#C32148"},{name:"Medium chrome green",rgb:"#6CA67C"},{name:"Medium violet",rgb:"#8F47B3"},{name:"Melon",rgb:"#FEBAAD"},{name:"Middle blue-green",rgb:"#8DD9CC"},{name:"Middle blue-purple",rgb:"#8B72BE"},{name:"Green-yellow",rgb:"#ACBF60"},{name:"Middle purple",rgb:"#D982B5"},{name:"Middle yellow-red",rgb:"#ECAC76"},{name:"Midnight blue",rgb:"#003366"},{name:"Mulberry",rgb:"#C8509B"},{name:"Navy blue",rgb:"#0066CC"},{name:"Olive green",rgb:"#B5B35C"},{name:"Orange",rgb:"#FF8833"},{name:"Orchid",rgb:"#E29CD2"},{name:"Peach",rgb:"#FFCBA4"},{name:"Periwinkle",rgb:"#C3CDE6"},{name:"Pine green",rgb:"#01796F"},{name:"Pink flamingo",rgb:"#FC74FD"},{name:"Plum",rgb:"#8E3179"},{name:"Raw umber",rgb:"#665233"},{name:"Red-orange",rgb:"#FF681F"},{name:"Red",rgb:"#ED0A3F"},{name:"Salmon",rgb:"#FF91A4"},{name:"Vivid scarlet",rgb:"#FD0E35"},{name:"Sea green",rgb:"#93DFB8"},{name:"Sepia",rgb:"#9E5B40"},{name:"Shamrock",rgb:"#33CC99"},{name:"Sky blue",rgb:"#76D7EA"},{name:"Spring green",rgb:"#ECEBBD"},{name:"Sunset orange",rgb:"#FE4C40"},{name:"Tan",rgb:"#FA9D5A"},{name:"Teal blue",rgb:"#008080"},{name:"Thistle",rgb:"#D8BFD8"},{name:"Vivid tangerine",rgb:"#ED3C10"},{name:"Vivid violet",rgb:"#a625c3"},{name:"Wisteria",rgb:"#C9A0DC"},{name:"Yellow-green",rgb:"#C5E17A"},{name:"Yellow-orange",rgb:"#FFAE42"},{name:"Yellow",rgb:"#FBE870"}],t.CrayonSupplements=[{name:"Artichoke",rgb:"#8F9779"},{name:"Aubergine",rgb:"#48213A"},{name:"Brandy rose",rgb:"#B1847F"},{name:"Burgundy",rgb:"#800020"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Crimson red",rgb:"#990000"},{name:"Dark brown",rgb:"#664228"},{name:"Dark coral",rgb:"#CD5B45"},{name:"Dark green",rgb:"#006400"},{name:"Dark raspberry",rgb:"#872657"},{name:"Dark turquoise",rgb:"#610079"},{name:"Deep teal",rgb:"#004040"},{name:"Deep coffee",rgb:"#704241"},{name:"Dusty rasberry",rgb:"#917980"},{name:"Ecru",rgb:"#BCAC7C"},{name:"Evergreen",rgb:"#05472A"},{name:"Eggplant",rgb:"#380835"},{name:"Eggplant purple",rgb:"#430541"},{name:"Emerald green",rgb:"#028F1E"},{name:"Flamingo pink",rgb:"#D67C99"},{name:"Grape",rgb:"#6C3461"},{name:"Kelly green",rgb:"#4CBB17"},{name:"Light forest green",rgb:"#4F9153"},{name:"Medium dark brown",rgb:"#AF7200"},{name:"Medium dark cyan-blue",rgb:"#2D537C"},{name:"Mustard",rgb:"#FAAF18"},{name:"Neon green",rgb:"#39FF14"},{name:"Pear",rgb:"#D1E231"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Phthalo blue",rgb:"#0016C7"},{name:"Pink lace",rgb:"#FFDDF4"},{name:"Raw sienna",rgb:"#884B15"},{name:"Rebecca purple",rgb:"#663399"},{name:"Sap green",rgb:"#536916"},{name:"Blue sapphire",rgb:"#133ECB"},{name:"Sand",rgb:"#B38751"},{name:"Shadow blue",rgb:"#778BA5"},{name:"Shadow green",rgb:"#121E06"},{name:"Swamp green",rgb:"#748500"},{name:"Verdigris",rgb:"#43B3AE"},{name:"Vivid blue-magenta",rgb:"#4817E8"},{name:"Vivid blue-purple",rgb:"#ACACE6"},{name:"Vivid blue",rgb:"#47ABCC"},{name:"Vivid green-yellow",rgb:"#D9E650"},{name:"Vivid green",rgb:"#7BE214"},{name:"Vivid turqoise",rgb:"#06ECD2"},{name:"Vivid lavender",rgb:"#A354FD"},{name:"Vivid mint",rgb:"#00F28C"},{name:"Vivid pink",rgb:"#D752FB"},{name:"Vivid red-purple",rgb:"#C31D7E"},{name:"Vivid red",rgb:"#D92121"},{name:"Vivid yellow-red",rgb:"#F2BA49"},{name:"Vivid yellow",rgb:"#FAFA37"}]},91482:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarkWikipediaColors=void 0,t.DarkWikipediaColors=[{name:"Bistre",rgb:"#3D2B1F"},{name:"Black bean",rgb:"#3D0C02"},{name:"Black pearl",rgb:"#041322"},{name:"Shadow blue",rgb:"#001440"},{name:"Charcoal",rgb:"#36454F"},{name:"Dark indigo",rgb:"#1F0A52"},{name:"Dark magenta",rgb:"#8B008B"},{name:"Dark moss green",rgb:"#4A5D23"},{name:"Dark navy",rgb:"#02075D"},{name:"Dark pastel blue",rgb:"#779ECB"},{name:"Dark purple",rgb:"#580040"},{name:"Dark tan",rgb:"#918151"},{name:"Dark yellow-green",rgb:"#304000"},{name:"Dark yellow",rgb:"#9B870C"},{name:"Deep violet",rgb:"#330066"},{name:"Dusk",rgb:"#4E5481"},{name:"Elderberry",rgb:"#1d1a34"},{name:"Grey jade",rgb:"#757C55"},{name:"Grey magenta",rgb:"#83667F"},{name:"Grey ochre",rgb:"#716659"},{name:"Grey olive",rgb:"#656c5a"},{name:"Grey sage",rgb:"#69724d"},{name:"Taupe",rgb:"#483C32"}]},3048:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciede2000_delta_e=t.diffCIECorr=t.MaxCie=t.MinCie=t.cie94_delta_e=t.cie76_delta_e=void 0;const r=i(31586),s=i(97352);t.cie76_delta_e=function(e,t){return Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2)},t.cie94_delta_e=function(e,t){const[i,r,n]=e,[a,o,l]=t,u=i-a,c=r-o,d=n-l,h=(0,s.sqrt)(r**2+n**2),f=h-(0,s.sqrt)(o**2+l**2),m=(0,s.sqrt)(c**2+d**2-f**2);return(0,s.sqrt)((u/1)**2+(f/(1+.045*h))**2+(m/(1+.015*h))**2)},t.MinCie=2,t.MaxCie=20,t.diffCIECorr=function(e,i){return null==e||null==i?1:(0,r.clamp)(0,t.MaxCie,l(e,i)-t.MinCie)/t.MaxCie};const n=1,a=1,o=1;function l(e,t){const[i,r,l]=e,u=(0,s.sqrt)(r**2+l**2),[c,d,h]=t,f=(u+(0,s.sqrt)(d**2+h**2))/2,m=.5*(1-(0,s.sqrt)(Math.pow(f,7)/(Math.pow(f,7)+Math.pow(25,7)))),p=r*(1+m),g=d*(1+m),y=(0,s.sqrt)(p*p+l*l),v=(0,s.sqrt)(g*g+h*h);let w=Math.abs(p)+Math.abs(l)===0?0:Math.atan2(l,p);w+=2*(w<0?1:0)*Math.PI;let b=Math.abs(g)+Math.abs(h)===0?0:Math.atan2(h,g);b+=2*(b<0?1:0)*Math.PI;const S=c-i,P=v-y;let _=y*v==0?0:b-w;_-=2*(_>Math.PI?1:0)*Math.PI,_+=2*(_<-Math.PI?1:0)*Math.PI;const M=2*(0,s.sqrt)(y*v)*Math.sin(_/2),T=(i+c)/2,E=(y+v)/2;let k;y*v==0?k=w+b:(k=(w+b)/2,k-=(Math.abs(w-b)>Math.PI?1:0)*Math.PI,k+=2*(k<0?1:0)*Math.PI);const D=(T-50)**2,x=1-.17*Math.cos(k-Math.PI/6)+.24*Math.cos(2*k)+.32*Math.cos(3*k+Math.PI/30)-.2*Math.cos(4*k-63*Math.PI/180),C=1+.015*D/(0,s.sqrt)(20+D),F=1+.045*E,A=1+.015*E*x,I=30*Math.PI/180*Math.exp(-1*((180/Math.PI*k-275)/25)**2),O=2*(0,s.sqrt)(Math.pow(E,7)/(Math.pow(E,7)+Math.pow(25,7))),L=-1*Math.sin(2*I)*O;return(0,s.sqrt)(Math.pow(S/(n*C),2)+Math.pow(P/(a*F),2)+Math.pow(M/(o*A),2)+L*P/(a*F)*M/(o*A))}t.ciede2000_delta_e=l},76490:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColor=t.dominantColorsToRgbHex=void 0;const r=i(40958),s=i(31586),n=i(97352),a=i(54772),o=i(85810),l=i(42022),u=i(1971);t.dominantColorsToRgbHex=function(e){return(0,r.compact)(e.map((e=>[e.rgbhex,(0,s.fmtPct)(e.pct)])))};class c{static fromModeData(e){return(0,r.compact)((0,s.times)(u.ModeCount,(t=>c.fromLabhash({labhash:e[`mode${t}`],pct:e[`mode${t}pct`]}))))}static toModeData(e){const t={};return(0,s.times)(u.ModeCount,(i=>{t["mode"+i]=e[i]?.labhash??null,t["mode"+i+"pct"]=e[i]?.pct??null})),t}static fromLabhash({labhash:e,labhashBits:t=l.ModeBits,pct:i}){const r=(0,n.mapGt0)(e,(e=>(0,o.unlabhash)(e,t)));return null!=r&&(0,s.gt0)(i)?new c(r,i,e):void 0}static fromCentroid(e,t){return new c(e.centroid,Math.round(e.size/t*100))}constructor(e,t,i){this.lab=e,this.pct=(0,s.clamp)(0,100,t),this.labhash=i??(0,o.toLabhash)(e,l.ModeBits)}get rgbhex(){return(0,o.lab2rgbhex)(this.lab)}get color(){return(0,a.bestLabhashName)(this.labhash)}toGreyscale(){return new c([this.lab[0],0,0],this.pct)}eql(e){return this.labhash===e.labhash&&(0,s.closeTo)(this.pct,e.pct,5)}}t.DominantColor=c},32848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scaled_delta_e=t.dominantColorCorrelation=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(48884),o=i(31843),l=i(70417),u=i(3048);function c(e,t){const i=(0,s.sum)(e,(e=>(0,n.clamp)(0,100,e.pct))),r=(0,s.sum)(e,(e=>function(e,t){const i=(0,a.leastBy)(t,(t=>(0,u.ciede2000_delta_e)(e.lab,t.lab)));if(null==i)return 0;const r=(0,u.ciede2000_delta_e)(e.lab,i.lab),s=(0,n.clamp)(0,e.pct,(0,l.avg)([e.pct,i.pct])),o=h(r);return(0,n.clamp)(0,100,s)*o}(e,t)));return r/i}t.dominantColorCorrelation=function(e,t){return e=(0,s.compact)(e),t=(0,s.compact)(t),(0,s.isEmpty)(e)||(0,s.isEmpty)(t)?0:(0,l.avg)([c(e,t),c(t,e)])};const d=(0,r.lazy)((()=>[{x:0,y:1},{x:9,y:.8},{x:16,y:.3},{x:20,y:0}]));function h(e){return(0,n.clamp)(0,1,(0,o.lerp2d)(e,...d()))}t.scaled_delta_e=h},40401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeNearCentroids=t.mergeLabhashes=t.dominantColorsFromModes=t.maybeFilterGrey=t.centroidsScore=t.extractDominantColors=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(41400),o=i(98553),l=i(31586),u=i(68708),c=i(48884),d=i(22454),h=i(50213),f=i(56038),m=i(82647),p=i(44983),g=i(70417),y=i(28874),v=i(85810),w=i(3048),b=i(76490),S=i(1971),P=(0,r.lazy)((()=>(0,h.mkLogger)("color.DominantColors")));t.extractDominantColors=function(e,t=S.ModeCount){return(0,f.timeSync)("img.extractDominantColors",(()=>function(e,t=S.ModeCount){const i=Date.now(),r=y.Settings.dominantColorKmeansRuns.valueOrDefault,a=new d.CountingSet;for(const i of E({labs:e,minK:t}))a.incr((0,v.toLabhash)(i));const h=M[y.Settings.dominantColorDeltaE.valueOrDefault]??w.ciede2000_delta_e;const f=a.sortedByKey().valuesToA((e=>(0,v.unlabhash)(e)));let g=(0,l.round)(t+y.Settings.dominantColorMergeThreshold.valueOrDefault);function D(e){const i=t,r=4*t;g=Math.round(Math.max(i,Math.min(r,e)))}const C=f.length<=g?[]:(0,s.compact)(_.slice(0,r).map((e=>{const r=(0,p.kmeans)(f,g,{...T,seed:e}),s=x(r.centroids,f.length);if(s.lengtht&&D(g-1);const n=s.slice(0,t),o=(0,l.sigFigs)(function(e){const t=new m.Average;for(const[i,r]of a.entries()){const s=(0,v.unlabhash)(i),n=(0,c.leastByCtx)(e,(e=>h(e.centroid,s)));null!=n&&(0,l.times)(r,(()=>t.push(n.value)))}return t.p84}(n),2);return{...r,centroids:n,description:{kIn:g,kOut:r.centroids.length,kMerged:s.length,score:o,iterations:r.iterations,uniqColors:a.size,elapsedMs:Date.now()-i},score:o}})));P().trace("extractDominantColors()",{kmeansResults:C.map((e=>(0,u.pick)(e,"description","score")))});const F=(0,c.leastBy)(C,(e=>e.score));if(null==F)return P().info("kmeans failed or was disabled, using dominantColorsFromModes",{runs:r}),k(a,t);const A=(0,o.stringify)({...F?.description,elapsedMs:Date.now()-i}),I=(0,n.sortBy)(F?.centroids,(e=>-e.size)).map((e=>b.DominantColor.fromCentroid(e,f.length)));return P().debug("extractDominantColors() result",{description:A,score:F?.score,totalColors:a.size,totalPixels:f.length,iters:F?.iterations,dominantColors:(0,b.dominantColorsToRgbHex)(I),pixelCount:f.length}),{dominantColors:I,description:A,dominantColorScore:F?.score}}(e,t)))},t.centroidsScore=function(e,t){const i=new m.Average;for(const r of e){const e=(0,c.leastBy)(t,(e=>(0,w.ciede2000_delta_e)(e.centroid,r)));null!=e&&i.push((0,w.ciede2000_delta_e)(e.centroid,r))}return i};const _=[6147062518717073,8176726750919909,5426648081701673,0xce2a345532a3c,0x713f9716da824,6348935463312109,5900323173950995,7358780886584433,5704068712193493,0x51ceeef755892,0xe1557fe94c084,0xd42d7cc96d6b4,0xcbc36dfd76e8a,6738189173486085,8537822851166899,5390086061821835,7712057976331355,0xe9b820db7a8e4,0xb96cebcd6aa40,7036994544380825,5353634786120155,0x99a11417794bc,0xa93d36019aaae,0x74a470887095e,5481147022770415,5347523348244809,0x541d1098e90fc,0xa24d9fb3510c2,0x78aa8e4f692fa,6354921850669697,0x714e1ec1b0a14,8622097963014773,0x6ff5d462d8eb6,0x6782a6b5166b8,7128984079394103,0xe6efba28a3752,5088704486053871,0xc84df40627fae,8018285280412081,4524300326741245,8307147030534695,8135486835878813,7699950603263999,0xb2889592968ae,5903399874280295,7462660765348991,6442509751447017,0xe218d44834db6,7214173935589545,6001326758941961,0x53eb7d39bbb50,0xc3a7ab8add332,0x4e6e81bc443e2,6757635537583321,8501611905255957,0x51840465cc07c,5958243312989149,8928005021308717,5032083390680559,0xb35d70ac51c68,0xfc3826a2dfe7c,0xd155853c61e96,0xda2045ee9be1e,4753952745315177],M={cie76:w.cie76_delta_e,cie94:w.cie94_delta_e,ciede2000:w.ciede2000_delta_e},T=(0,r.lazy)((()=>({maxIterations:50,initialization:"kmeans++",distanceFunction:M[y.Settings.dominantColorDeltaE.valueOrDefault]})));function E({labs:e,minK:t,thresh:i,retries:r=3}){if(r<0)return P().debug("maybeFilterGrey(): exhausted retries: grey filtering disabled."),e;const s=i??y.Settings.dominantColorGreyThreshold.valueOrDefault;if(!(0,l.gt0)(s))return P().debug("maybeFilterGrey(): grey threshold is <= 0: grey filtering disabled."),e;const n=e.filter((e=>Math.abs(e[1])+Math.abs(e[2])>=s));return n.length>=e.length/2?(P().debug("maybeFilterGrey(): sufficient remaining pixels with this threshold.",{greyThreshold:s,minK:t,pixelCount:e.length,filteredCount:n.length}),n):(P().debug("maybeFilterGrey(): insufficient remaining pixels with this threshold. Retrying with smaller threshold.",{greyThreshold:s,minK:t,retries:r,pixelCount:e.length,filteredCount:n.length}),E({labs:e,minK:t,thresh:.75*s,retries:r-1}))}function k(e,t){const i=e.countSum,r=e.size;D(e);const n=e.size,a=(0,s.compact)(e.top(t).map((([e,t])=>b.DominantColor.fromLabhash({labhash:e,pct:Math.round(100*t/i)})))),l=100-(0,g.sumf)(a,(e=>e.pct));return{dominantColors:a,description:"dominantColorsFromModes: "+(0,o.stringify)({uniqColors:r,mergedColors:n,pixelCount:i,pctOmitted:l})}}function D(e,t=y.Settings.dominantColorMergeThreshold.valueOrDefault){const i=[];for(const[r,s]of[...e.entriesByCountDesc()]){const n=(0,v.unlabhash)(r),a=i.find((e=>(0,w.ciede2000_delta_e)(e.lab,n)<=t));null==a?i.push({lab:n,labhash:r}):(e.delete(r),e.incr(a.labhash,s))}return e}function x(e,t,i=y.Settings.dominantColorMergeThreshold.valueOrDefault){if(i<=0)return e;const r=[];for(const t of e){const e=r.find((e=>(0,w.ciede2000_delta_e)(t.centroid,e.centroid)<=i));null==e?r.push(t):e.size+=t.size}const s=t/100;return(0,n.sortBy)(r.filter((e=>e.size>s)),(e=>-e.size))}(0,a.later)((()=>{y.Settings.dominantColorDeltaE.watchLater((()=>{T.unset()}))})),t.maybeFilterGrey=E,t.dominantColorsFromModes=k,t.mergeLabhashes=D,t.mergeNearCentroids=x},85409:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Greys=void 0,t.Greys=[{name:"Black",rgb:"#000000"},{name:"90% black",rgb:"#1b1b1b"},{name:"80% black",rgb:"#303030"},{name:"70% black",rgb:"#474747"},{name:"60% black",rgb:"#5e5e5e"},{name:"Grey",rgb:"#777777"},{name:"60% white",rgb:"#919191"},{name:"70% white",rgb:"#ababab"},{name:"80% white",rgb:"#c6c6c6"},{name:"90% white",rgb:"#e2e2e2"},{name:"White",rgb:"#ffffff"}]},86758:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.labsAreGreyscale=t.isLab=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(82647),o=i(28874),l=i(85810),u=(0,r.lazy)((()=>(0,n.mkLogger)("color.Lab")));t.isLab=function(e){return Array.isArray(e)&&3===e.length&&(0,s.within)(0,100,e[0])&&(0,s.within)(-110,110,e[1])&&(0,s.within)(-110,110,e[2])},t.labsAreGreyscale=function(e){const t=o.Settings.greyscaleColorThreshold.valueOrDefault,i=new a.Average,r=new a.Average;for(const t of e){const e=(0,l.clampLab)(t);i.push(e[1]),r.push(e[2])}const s=(i.stdDev??0)+(r.stdDev??0),n=s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LightWikipediaColors=void 0,t.LightWikipediaColors=[{name:"Beige",rgb:"#F5F5DC"},{name:"Laurel green",rgb:"#A9BA9D"},{name:"Light sage",rgb:"#93A58B"},{name:"Light green-cyan",rgb:"#CFEADE"},{name:"Pastel purple",rgb:"#B39EB5"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Powder blue",rgb:"#B0E0E6"},{name:"Vanilla",rgb:"#F3E5AB"}]},42022:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeBits=void 0,t.ModeBits=12},1971:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeCount=void 0,t.ModeCount=7},85434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitModeData=t.pickModeData=t.ModeDataKeys=t.isModeData=void 0;const r=i(31586),s=i(68708),n=i(50989);t.isModeData=function(e){return(0,r.gt0)(e.mode0)&&(0,r.gt0)(e.mode0pct)},t.ModeDataKeys=(0,n.strEnum)("mode0","mode0pct","mode1","mode1pct","mode2","mode2pct","mode3","mode3pct","mode4","mode4pct","mode5","mode5pct","mode6","mode6pct"),t.pickModeData=function(e){return(0,s.pick)(e,...t.ModeDataKeys.values)},t.omitModeData=function(e){return(0,s.omit)(e,...t.ModeDataKeys.values)}},85042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clampRGB=t.rgbTriplet2hex=t.rgbhex2triplet=t.normalizeRgbHex=void 0;const r=i(31586),s=i(39926),n=i(51926),a=i(54993),o=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;function l(e){return[e[0],e[1],e[2]].map((e=>(0,r.clamp)(0,255,Math.round(e))))}t.normalizeRgbHex=function(e){const t=(0,a.toS)(e).trim();return o.test(t)?(0,n.ensurePrefix)(t,"#").toUpperCase():void 0},t.rgbhex2triplet=function(e){const t=(0,a.toS)(e).trim().match(o);if(null!=t)try{return[t[1],t[2],t[3]].map((e=>(0,r.clamp)(0,255,parseInt(e,16))))}catch{return}},t.rgbTriplet2hex=function(e){return"#"+l(e).map((e=>(0,s.leftPad)(Math.round(e).toString(16).toUpperCase(),2,"0"))).join("")},t.clampRGB=l},76596:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),s=i(19851),n=i(22573),a=i(42659),o=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,s.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,o.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,o.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,a.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const r=i(77988),s=i(19851),n=i(55835),a=i(31586),o=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,s.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),h=["year","month","day","hour","minute","second","millisecond"];class f{static fromISO(e,t){const i=d().exec((0,o.toS)(e).trim()),r=i?.groups;return null==r?void 0:f.for((0,c.parseExifDateTime)(r.start,t),(0,c.parseExifDateTime)(r.end,t),(0,a.toInt)(r.index),(0,a.toInt)(r.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,n.map)(e.start,(e=>r.ExifDateTime.fromJSON(e))),(0,n.map)(e.end,(e=>r.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,r=1){if(null==e||!e.isValid||null==t||!t.isValid)return;r=(0,a.clamp)(1,1e3,(0,a.toInt)(r,{defaultValue:1})),i=(0,a.clamp)(0,r-1,(0,a.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const s=e.toMillis(),n=(t.toMillis()-s)/(r+1)*(i+1),o=e.plus({milliseconds:n});return null==o?void 0:new f(e,o,t,i,r)}constructor(e,t,i,r=0,s=1){this.start=e,this.middle=t,this.end=i,this.index=r,this.splits=s,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=h.map((r=>function({start:e,end:t,middle:i,field:r}){return null!=e[r]&&null!=t[r]?i[r]:void 0}({start:e,middle:t,end:i,field:r})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new f(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=f},79842:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(76790),o=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),h=i(51926),f=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),v=i(21330),w=i(928),b=i(54261),S=i(73389),P=i(51275),_=(0,n.lazy)((()=>(0,f.mkLogger)("date.Dated")));function M(e){return null!=e&&(e instanceof v.FuzzyDate||e instanceof r.ExifDate||e instanceof r.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,S.isDateTime)(e)||(0,m.isDateObject)(e))}function T(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof r.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function E(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof r.ExifDate?e.toMillis(l.dayMs):e instanceof v.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),D(e),((e,t)=>e+t))}function k(e){try{if(null==e||(0,h.isString)(e)||(0,c.isNumber)(e))return;return(0,S.isDateTime)(e)?e:e instanceof r.ExifDateTime||e instanceof v.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?s.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void _().warn("datedToDateTime() failed",{d:e,error:t})}}function D(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,b.hasTime)(e)){if((0,c.gt0)((0,w.getMillisecond)(e)))return 0;if((0,c.gt0)((0,w.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,w.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,w.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,w.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,w.getMonth)(e))?l.monthMs-1:l.yearMs-1}function x(e,t){const i=T(e),r=E(e);if(null!=i&&null!=r)return(0,c.gt0)(t)&&t>r-i?{start:Math.round((i+r)/2-t/2),end:Math.round((i+r)/2+t/2)}:{start:i,end:r}}function C(e,t,i,r){const[s,n]=(0,a.sortBy)([x(e,i),x(t,r)],(e=>e?.start));return null!=s&&null!=n&&null!=s&&null!=n&&(s.start===n.start||s.end>=Math.min(n.start,n.end))}function F(e,t){return(0,o.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??v.FuzzyDate.fromISO(e)}t.isDated=M,t.toDated=function(e){return M(e)?e:void 0},t.mapDated=function(e,t){return M(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=T,t.datedToEndTs=E,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof r.ExifDate?s.DateTime.fromObject(e):k(e)},t.datedToDateTime=k,t.datedToPrecisionMs=D,t.isoToPrecisionMs=function(e){return(0,u.map)(F(e),D)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:r}){if(null==e||null==t)return!1;if(i??(i=D(e)),r??(r=D(t)),C(e,t,i,r))return!0;const s=(0,P.getZoneName)(e),n=(0,P.getZoneName)(t);return null==s&&null!=n&&(e=(0,v.setZone)(e,n)??e),null==n&&null!=s&&(t=(0,v.setZone)(t,s)??t),C(e,t,i,r)},t.isoToDated=F,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof s.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const r=i(31586),s=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,s.isString)(e))return(0,r.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),s=i(31586),n=i(54557),a=i(91655),o=new n.FifoCache(512);function l(e){return(0,s.isNumber)(e)?e:(0,r.blank)(e)?void 0:o.getOrSet(e,(()=>(0,a.parseDuration)(e)))}t.decodeDuration=l;const u=new n.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,a.fmtFullDuration)((0,s.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),s=i(40958),n=i(22573),a=i(42659),o=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,o.isNumber)(e))return;if((0,o.isNumber)(e))return e;if((0,o.isDigits)(e))return(0,o.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,s.compact)(d.map((e=>function(e,t){const i=(0,o.toFloat)(e);if(null!=i){if((0,n.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*a.yearMs;case"weeks":case"week":case"w":return i*a.weekMs;case"days":case"day":case"d":return i*a.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*a.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*a.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*a.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,o.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:a.yearMs,s:"y"},{ms:a.weekMs,s:"w"},{ms:a.dayMs,s:"d"},{ms:a.hourMs,s:"h"},{ms:a.minuteMs,s:"m"},{ms:a.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,o.isNumber)(t))return;if(0===t)return"0";if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},98247:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),h=i(68852),f=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function v(e,t,i){const r=t.exec(e);if(null==r||(0,u.isEmptyObj)(r.groups))return;const{year:s,month:n,day:a,hour:c,minute:h,second:p}=(0,d.mapEntries)(r.groups,((e,t)=>(0,l.toInt)(t)));if(null==s||null==n||null==a)return;if(!f.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==h))return;const g=(0,o.map)((0,l.toFloat)(r.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),v=(0,y.timezoneOffsetFromRegExpMatch)(r);return S({year:s,month:n,day:a,hour:c??0,minute:h??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(v)??i,rawValue:e,tzoffsetMinutes:v})}t.UnsetZone=s.Info.normalizeZone(r.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof r.ExifDate&&t instanceof r.ExifTime))return;const i=new r.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:n}){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromFormat(e,i,{zone:n??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,a.blank)(e)?void 0:r.ExifDateTime.from(e,t)??v(e,b(),t)},t.parseExifDateTimeRe=v;const w=/[-:_\s]?/,b=(0,n.lazy)((()=>(0,h.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,w,p.monthRE,w,p.dayRE,/[T\s]/,p.hourRE,w,p.minuteRE,w,p.secondRE,p.subsecRE,/\s?/,h.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function S(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof r.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=r.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,o.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=S},74417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const r=i(51168),s=i(22573),n=i(42659),a=i(49769),o=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),h=i(66649),f=i(98725),m=i(88600);t.recent=function(e,t=5*n.secondMs){return(0,c.isRecentMs)((0,h.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=r.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,s.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,s.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=r.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,a.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,h.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,o.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*n.secondMs):void 0)??(0,f.parseDateTime)(t)?.toMillis()}},12959:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filestampUTC=t.filestamp=void 0;const r=i(39926);t.filestamp=function(e=new Date){return[e.getFullYear(),(0,r.pad2)(e.getMonth()+1),(0,r.pad2)(e.getDate()),"-",(0,r.pad2)(e.getHours()),(0,r.pad2)(e.getMinutes()),(0,r.pad2)(e.getSeconds())].join("")},t.filestampUTC=function(e=new Date){return[e.getUTCFullYear(),(0,r.pad2)(e.getUTCMonth()+1),(0,r.pad2)(e.getUTCDate()),"-",(0,r.pad2)(e.getUTCHours()),(0,r.pad2)(e.getUTCMinutes()),(0,r.pad2)(e.getUTCSeconds())].join("")}},21330:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const n=i(77988),a=i(51168),o=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(31586),f=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),v=i(79842),w=i(66649),b=i(98247),S=i(98725),P=i(928),_=i(54261),M=i(73389),T=i(89724),E=i(17415),k=i(88600),D=i(51275);function x(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class C{constructor(e,t,i){this.year=e,this.month=t,this.day=i,r.set(this,(0,p.lazy)((()=>(0,k.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(S.ISO_YMD_RE.exec(e)?.groups??S.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,h.toGt0)(e?.year);if(null==e||null==t||tx(e))).join("-")}toLocal(){return(0,T.datedToLocal)(this)}toDateTime(){return a.DateTime.fromObject((0,f.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,f.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,f.pick)(e.plus({month:1}),"year","month"):(0,f.pick)(e.plus({year:1}),"year");return new C(t.year,t.month,t.day)}}function F(e,t){if(e instanceof n.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,_.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,E.zoneToTzOffsetMinutes)((0,w.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(r=>(0,d.map)((0,P.getMonth)(e),(s=>(0,d.map)((0,P.getDay)(e),(n=>(0,d.map)((0,P.getHour)(e),(a=>(0,b.dateObjectToExifDateTime)({year:r,month:s,day:n,hour:a,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=C,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",r=15*(0,h.round)(e/15),s=Math.abs(r),n=Math.floor(s/60),a=Math.floor(Math.abs(s%60));return`${t?"UTC":""}${i}${x(n)}:${x(a)}`},t.toExifDateTime=F,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof n.ExifDateTime?e.tzoffsetMinutes:(0,M.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,_.hasTime)(e)||(i??(0,v.datedToPrecisionMs)(e))>=c.dayMs?O(e):F(e,(0,D.getZoneName)(e))?.toISOString({includeOffset:t})};const A="yyyy:MM:dd HH:mm:ss.SSS",I=A+"ZZ";function O(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>x(e))).join(t)}function L(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new C(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,r]=[e,t].map(w.datedToMillis);return null==i||null==r?void 0:i-r}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,h.isNumber)(t)?a.DateTime.fromMillis(t):(0,v.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,D.hasZone)(t)?I:A):void 0},t.datedToYMD=O,t.toFuzzyDate=L,t.sameDay=function(e,t){return(0,h.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,h.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,r=1){if(null==(0,w.datedToMillis)(e)||null==(0,w.datedToMillis)(t))return;const[s,n]=[e,t].map((e=>(0,w.datedToMillis)(e))).sort(),o=(n-s)/(r+1),l=(0,D.getZoneName)(e),u=l===(0,D.getZoneName)(t)?l:void 0,c=a.DateTime.fromMillis(s+o*i,{zone:u});return[e,t].some((e=>!(0,_.hasTime)(e)))?L(c):c},t.setZone=function(e,t,i){const r={...(0,f.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,D.hasZone)(e)},s=(0,E.normalizeZone)(t);if(null!=e&&null!=s&&(0,_.hasTime)(e))return e instanceof y.DateInterval?e.setZone(s,r):F(e)?.setZone(s,r)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,h.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,v.datedToDateTime)(e);if(null==i)return;const r=(0,D.getZoneName)(e);return null!=r&&"UTC"!==r||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const o=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),h=i(49769),f=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),v=i(68852),w=i(4001),b=i(28874),S=i(24689),P=i(79842),_=i(66649),M=i(98247),T=i(21330),E=i(54261),k=i(73389),D=i(16400),x=i(88600),C=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return C().tap({msg:"extractDateFromPath",result:O.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return O.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return O.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,f.mapNumeric)((0,_.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,v.concatRegexp)([/^/,t.yearRE,v.RegExpOptional.from(/-/,t.monthRE,v.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,v.concatRegexp)([/^/,t.yearishRE,v.RegExpOptional.from(/-/,t.monthishRE,v.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=I({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,k.isDateTime)(i)?i:(0,E.isExifDateTime)(i)?i.toDateTime():void 0};const F=new Map;function A(e,t,i){try{const r=(0,M.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=r)return r;const s=(0,h.getOrSet)(F,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void C().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,M.parseExifDateTimeFormat)({input:s?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void C().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function I({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:r=!0,descPredicate:s=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const n=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(w.stripDSC));if(0!==n.length)for(const{desc:e,f:a}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>S.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,M.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:M.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(b.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(b.Settings.extraDateTimeFormats.values)){const r=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${r})`,f:i=>A(i,r,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>o.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of O.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:r}))if(s(e))for(const e of n){const t=a(e);if(null!=t&&(0,x.isValidDate)(t))return t}}t.parseDated=I;class O{constructor(e={}){r.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&b.Settings.fuzzyDateParsing.watchLater((()=>a(this,r,"m",n).call(this))),null==e.fuzzyYearParsing&&b.Settings.fuzzyYearParsing.watchLater((()=>a(this,r,"m",n).call(this))),a(this,r,"m",n).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??b.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??b.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!b.Settings.usePathsToInferDates.valueOrDefault)return;T.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=I({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=O,r=new WeakSet,s=function(e){const t=new L(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},n=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new v.RegExpEscaped("(?"+(0,D.monthNames)().map(v.escapeRegExp).join("|")+")");a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE]),a(this,r,"m",s).call(this,[e,t.seps,t.yearRE]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,e]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},O.instance=(0,u.lazy)((()=>new O));class L{constructor(e){this.regex=e instanceof RegExp?e:(0,v.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return T.FuzzyDate.for({year:(0,f.toInt)(t.year),month:(0,f.toInt)(t.month)??(0,D.monthName2index)(t.monthname),day:(0,f.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const r=i(55835),s=i(31586),n=i(54261);function a(e){return e instanceof Date?e.getMinutes():e?.minute}function o(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=a,t.getSecond=o,t.getMillisecond=l,t.getCentisecond=function(e){return(0,r.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,n.hasTime)(e)&&((0,s.gt0)(a(e))||(0,s.gt0)(o(e))||(0,s.gt0)(l(e)))},t.getSecMs=function(e){return(0,r.map)(o(e),(t=>{const i=l(e)??0;let r=(t+i/1e3).toString();for(t<10&&(r="0"+r),0===i&&(r+=".");r.length<6;)r+="0";return r}))}},54261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const r=i(77988),s=i(31586),n=i(68708);t.hasTime=function(e){if(!(0,n.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,s.gt0)(t.hour)||(0,s.gt0)(t.minute)||(0,s.gt0)(t.second)||(0,s.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof r.ExifDateTime}},73389:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const r=i(51168);t.isDateTime=function(e){return r.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const r=i(51168),s=i(19851),n=i(42659),a=i(55835),o=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),h=i(74417),f=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,s.lazy)((()=>v(l.Settings.datesBeforeAreEstimated.valueOrDefault)??v(l.Settings.datesBeforeAreEstimated.defaultValue)));function v(e){return(0,a.map)((0,c.isoToDated)(e),w)}function w(e){return(0,o.isNumber)(e)?M(e):100*b(e)+((0,m.getCentisecond)(e)??0)}function b(e){if((0,o.isNumber)(e))return Math.floor(M(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function S(e,t){if(null==e||e<0)return;let i=e;const r=()=>{const e=i%100;return i=Math.floor(i/100),e},s=10*r(),n=r(),a=r(),l=(0,o.toGt0)(r()),u=(0,o.toGt0)(r()),c=(0,o.toGt0)(r());return{year:i,month:c,day:u,hour:l,minute:a,second:n,millisecond:s,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=S(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):f.FuzzyDate.for(i)}function _(e,t){return M(Date.now()-e,t)}function M(e,t){return w(r.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const r=i(19851),s=i(76790),n=i(31586),a=i(9092),o=(0,r.lazy)((()=>{const e=new a.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const r=new Intl.DateTimeFormat(t,{month:i});(0,n.times)(12,(s=>{const n=r.format(new Date(2017,s));e.set(n,s+1),"short"===i&&"en-US"===t&&e.set(n+".",s+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:o().get(e)},t.monthNames=function(){return(0,s.sort)([...o().keys()])}},17415:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),h=i(54993),f=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,n.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const r=(0,f.leastBy)(g(),(t=>Math.abs(t-e)));return null!=r&&Math.abs(r-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(r)}t.isUTCZone=function(e){return b(e)||0===S(e)?.offset(Date.now())},t.normalizeZone=S,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,o.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=_,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:_(i)};const M=/\b(?Z|UTC|GMT)\b/,T=/(?[-±+−])/,E=/[-−]/,k=/(?[01]\d)/,D=/(?[01]?\d)/,x=/(?::(?\d\d))/;function C(e){return b(e)?0:F((0,t.TimezoneOffsetRE)().exec(e))}function F(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,a.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=E.test((0,h.toS)(e.groups.tzSign))?-1:1,r=(0,l.toInt)(e.groups.tzMinutes)??0,s=null==t?void 0:i*(60*t+r);return v(s)?s:void 0}t.TimezoneOffsetRE=(0,n.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),M,new m.RegExpEscaped("|"),T,k,m.RegExpOptional.from(x),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=C,t.timezoneOffsetFromRegExpMatch=F;const A=/\b(?(?:Etc\/)?GMT)\b/,I=(0,n.lazy)((()=>(0,m.concatRegexp)([A,T,D,m.RegExpOptional.from(x)])));function O(e){return F(I().exec(e))}t.ianaZoneToOffsetMinutes=O,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,a.blank)(e))return;const i=O(e)??C(e);if(null!=i)return _(i);if(null!=t){const i=S(e);if(null!=i)return _(i.offset(t))}}},88600:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),h=i(28874),f=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),v=(0,s.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),w=(0,s.lazy)((()=>(0,n.compact)(h.Settings.badDates.values.map((e=>(0,f.isoToDated)(e)))))),b=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,p.datedToISO)(e)))))),S=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,y.datedToLocal)(e)))))),P=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,m.datedToMillis)(e))))));function _(e){if(null==e)return!1;const t=T(e);return v().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return _(e)?e:void 0},t.isValidDate=_;const M=String(new Date("bad"));function T(e){try{if(!(0,f.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===M)return M;const t=(0,n.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const s=[];if((0,l.isNumber)(e)||s.push("year is not a number"),(0,l.lt)(e,h.Settings.minValidYear.valueOrDefault)&&s.push("year is less than "+h.Settings.minValidYear.key),(0,u.gt)(e,E())&&s.push("year is in the future"),null==t&&null!=i&&s.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const n=r.DateTime.fromObject({year:e,month:t,day:i});n.isValid||s.push(n.invalidExplanation??"not valid")}return(0,n.compact)(s)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=h.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const r=(0,m.datedToMillis)(e);(0,u.gt)(r,Date.now()+i)&&t.push("date is too far in the future: see "+h.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):S().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):b().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,a.toNotBlank)((0,n.uniq)((0,n.compactBlanks)(t)).join("; "))}catch(t){return v().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=T;const E=(0,s.lazy)((()=>r.DateTime.now().plus({milliseconds:h.Settings.maxValidFutureMs.valueOrDefault}).year),o.dayMs);t.mapValidDate=function(e,t){return _(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==T({year:e,month:t,day:i})}},51275:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const r=i(77988),s=i(31586),n=i(24689),a=i(73389);t.hasZone=function(e){return null!=e&&!(0,s.isNumber)(e)&&(e instanceof n.DateInterval||e instanceof r.ExifDateTime?e.hasZone:!!(0,a.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==r.UnsetZoneName&&e.zone.offset(Date.now())!==r.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,a.isDateTime)(e)?e.zoneName===r.UnsetZoneName?void 0:e.zone?.name:e instanceof r.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},82261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cacheDbDir_=void 0;const r=i(51926),s=i(49776),n=i(38835),a=i(95696),o=i(70854),l=i(73428),u=i(28874),c=i(15056);t.cacheDbDir_=async function(e=u.Settings.libraryDir.valueOrDefault,t=c.Schemas.models){const i=(0,o.libraryUidStore)(e);if(null==i)throw new Error("Library directory is not set"+n.NoLibraryErrorFlag);const d=await i.readUid_(),h=a.PosixFile.for((0,s.cacheDir_)()).join(t+"-live-db",d);await h.mkdirp_();const f=h.join("README.txt");return await(0,l.writeTextfile_)(f.nativePath,...(0,r.wrap)(["This folder is used by PhotoStructure for your library stored in",e,"You will corrupt your library if you remove this directory while PhotoStructure is running.","See https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837 for details."].join("\n\n"))),h}},92407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLiveDbDir_=t.cacheDbFile_=void 0;const r=i(19851),s=i(87290),n=i(50213),a=i(28874),o=i(82261),l=i(15056),u=i(7311),c=i(44955),d=(0,r.lazy)((()=>(0,n.mkLogger)("db.CheckLocalDbReplica")));async function h({libraryDir:e=a.Settings.libraryDir.valueOrDefault,schema:t=l.Schemas.models}={}){return(await(0,o.cacheDbDir_)(e,t)).join(u.SqliteBase)}t.cacheDbFile_=h,t.getLiveDbDir_=async function(e=a.Settings.libraryDir.valueOrDefault){if(!a.Settings.forceLocalDbReplica.valueOrDefault){const t=(0,l.pathToDb)(await(0,s.setupLibraryDataDir_)(e),l.Schemas.models);try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!1}}catch(e){d().info("SQLite cannot directly write to the library: trying to use a local db replica.",{libraryDb:t,error:e})}}const t=await h({libraryDir:e,schema:l.Schemas.models});try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!0}}catch(e){return d().throw("SQLite cannot directly write to the library or the cacheDir.",{cacheDbFile:t,error:e})}}},5531:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},55332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupCold_=void 0;const r=i(19851),s=i(50213),n=i(76187),a=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbBackupCold")));t.dbBackupCold_=async function(e,t){await t.mkdirp_();const i=[];try{for(const r of(0,n.sqliteFiles)(e)){const e=t.join(r.base).wip();i.push(e),await r.copyFile_(e)}return a().tap({msg:"completed",level:"info",result:await Promise.all(i.map((e=>e.unwip_()))),meta:{srcDbFile:e,destDir:t}})}catch(e){throw await Promise.all(i.map((e=>e.unlink()))),e}}},91872:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleDbRetries_=void 0;const r=i(50213),s=i(70025),n=i(28874),a=i(45599),o=i(41400),l=i(30976),u=i(56038),c=(0,a.defer)((()=>(0,r.mkLogger)("db.DbRetries")));t.handleDbRetries_=function(e,t,i,r){const a=Date.now();let d=0;const h=a+n.Settings.dbMaintenanceTimeoutMs.valueOrDefault;return(0,u.time)(e,(async()=>{for(;Date.now()=h)throw c().error(e+": Caught db error. Not retrying.",{error:t}),t;{const i=(0,l.randomInt)(500,1500)*++d;c().warn(e+": Caught db error. Retrying in "+i+"ms.",{name:e,error:t}),r?.(),await(0,o.delay)(i)}}return t().close(),c().throw(e+": handleDbRetries(): timeout after "+n.Settings.dbMaintenanceTimeoutMs.valueOrDefault+"ms")}))}},12943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toDbValued=t.isDbValued=t.isDbValue=void 0;const r=i(79842),s=i(66649),n=i(40958),a=i(68708);function o(e){return null===e||(0,n.includes)(["number","string"],typeof e)}t.isDbValue=o,t.isDbValued=function e(t){return null!=t&&Array.isArray(t)?t.every(e):(0,a.entries)(t).every((([,e])=>o(e)))},t.toDbValued=function(e){return(0,a.mapFields)(e,((e,t)=>{if(!e.startsWith("$"))return"boolean"==typeof t?[e,t?1:0]:o(t)?[e,t]:(0,r.isDated)(t)?[e,(0,s.datedToMillis)(t)]:void 0}))}},65753:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maxBatchPluckSize=void 0;const r=i(19851),s=i(7282),n=i(28874);t.maxBatchPluckSize=(0,r.lazy)((()=>Math.round(n.Settings.dbBatchSelectSize.valueOrDefault*((0,s.isTest)()?.25:5))))},80632:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pageSizeBytes=t.mkdb_=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(54993),u=i(50213),c=i(23560),d=i(65211),h=i(29882),f=i(53265),m=i(66430),p=i(66184),g=i(28874),y=i(15674),v=i(87550);function w(){const e=g.Settings.dbPageSizeBytes.valueOrDefault;return Math.pow(2,(0,a.clamp)(1,28,Math.round(Math.log2(e))))}t.mkdb_=function({nativePath:e,timeoutMs:t=g.Settings.dbBusyTimeoutMs.valueOrDefault,logSql:i=g.Settings.logSql.valueOrDefault}){e=(0,f.resolve)(e),(0,h.mkdirpSync_)((0,r.dirname)(e));const b=(0,h.posixPathFromGrandparent)(e),S=(0,m.nativePathSizeSync)(e),P=(0,u.mkLogger)("db.mkdb("+b+")");if(null!=S){const E=Math.round(S/o.MiB),k=Math.ceil(1.5*E);k>g.Settings.dbCacheSizeMb.valueOrDefault&&(P.info("Dynamically setting dbCacheSize to "+g.Settings.dbCacheSizeMb.value,{db:e,dbFileSizeMb:E}),g.Settings.dbCacheSizeMb.envValue=k);const D=Math.round(1.5*E);D>g.Settings.maxMemoryMb.valueOrDefault&&(P.warn("Large database: setting maxMemoryDb to "+D+"MB",{dbFileSizeMb:E,"Settings.maxMemoryMb":g.Settings.maxMemoryMb.valueOrDefault}),g.Settings.maxMemoryMb.envValue=D)}P.info("Opening "+e+"...");const _={fileMustExist:!1,readonly:!1};if((0,a.gt0)(t)&&(_.timeout=Math.ceil(t)),i){const x=(0,u.mkLogger)("SQLite("+b+")"),C=(0,p.defaultLogLevel)();function F(e,...t){var i;(0,n.blank)(e)||x.log(C,(i=e,(0,l.toS)(i).replace(/\s{2,}/g," ")),{args:t})}_.verbose=F}const M=new v(e,_);P.info("Open. Setting PRAGMAs...");for(const A of(0,s.compact)(['encoding = "UTF-8"',"threads = "+(0,y.maxCpus)(),"foreign_keys = ON","page_size = "+w(),"trusted_schema = 0","cache_size = -"+Math.round(g.Settings.dbCacheSizeMb.valueOrDefault*o.MiB/1024),"locking_mode = NORMAL","journal_mode = WAL",(0,a.gt0)(g.Settings.dbBusyTimeoutMs.valueOrDefault)?"busy_timeout = "+g.Settings.dbBusyTimeoutMs.valueOrDefault:null,"temp_store = MEMORY","synchronous = "+g.Settings.dbSynchronousMode.valueOrDefault,"case_sensitive_like = 0","wal_autocheckpoint = "+((0,c.isDbJanitorService)()?(0,l.toS)(g.Settings.dbWalAutoCheckpoint.valueOrDefault):"0"),"auto_vacuum = "+g.Settings.dbAutoVacuumMode.valueOrDefault]))P.tapThunk({msg:"PRAGMA "+A,result:()=>M.pragma(A)});const T=M;return T.__uid=(0,d.uid)(),T},t.pageSizeBytes=w},99315:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},95704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withIdBatches=void 0;const r=i(40958),s=i(31586),n=i(59455),a=i(65753),o=i(51040);t.withIdBatches=async function(e){const t=(0,s.toGt0)(e.batchSize)??(0,a.maxBatchPluckSize)(),i=(0,o.dbValueToEscapedString)(e.primaryKeyColumnName),l=(0,r.compactBlanks)([i+" > :min",...(0,n.toA)(e.whereClauses)]).join(" AND "),u=e.db.prepare((0,r.compactBlanks)(["SELECT "+i,"FROM "+(0,o.dbValueToEscapedString)(e.tableName),"WHERE "+l,"ORDER BY "+i,"LIMIT :limit"]).join(" "));let c=-1;for(;;){const i=u.pluck().all({min:c,limit:t});if(0===i.length)return;await e.fn(i),c=(0,r.last)(i)}}},76187:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSqliteFile=t.sqliteSizeBytes=t.sqliteFiles=void 0;const r=i(17217),s=i(87391),n=i(7311);t.sqliteFiles=function(e){return[e,...s.SQLiteSuffixes.map((t=>e.sibling(e.base+t)))].filter((e=>e.existsSync({refresh:!0})))},t.sqliteSizeBytes=async function(e){return(await e.size({refresh:!0})??0)+(await e.sibling(e.base+"-wal").size({refresh:!0})??0)};const a=[n.SqliteExt,...[...s.SQLiteSuffixes,"-shm"].map((e=>n.SqliteExt+e))];t.isSqliteFile=function(e){const t=(0,r.basename)(e);for(const e of a)if(t.endsWith(e))return!0;return!1}},51040:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitBatchSql=t.dbValueToEscapedString=void 0;const r=i(40958),s=i(31586),n=i(54993),a=/^\w+$/;t.dbValueToEscapedString=function(e){if((0,s.isNumber)(e))return e.toString();const t=(0,n.toS)(e);return a.test(t)?t:`'${t.replace(/'/g,"''")}'`};const o=/--.+$/gm,l=/\s+/g;t.splitBatchSql=function(e){const t=(0,r.compactBlanks)((0,n.toS)(e).split(/;/).map((e=>e.replace(o,"").replace(l," ").trim()))),i=[];let s;for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertDirSQLiteReadWrite_=t.isDirSQLiteReadWrite=t.firstDirSQLiteReadWrite=void 0;const r=i(19851),s=i(50357),n=i(30976),a=i(50213),o=i(95696),l=i(80632),u=i(76187),c=(0,r.lazy)((()=>(0,a.mkLogger)("db.SQLiteReadWrite")));async function d(e){try{return await h(e),c().info("isDirSQLiteReadWrite(): true",{dirNativePath:e}),!0}catch(t){return c().warn("isDirSQLiteReadWrite(): false",{dirNativePath:e,error:t}),!1}}async function h(e){const t=o.PosixFile.for(e),i=(0,n.randomChars)(8),r=t.child(".test-"+i+".sqlite");let a=null;try{await t.mkdirp_(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3}),a.exec("CREATE TABLE t (s VARCHAR(16) NOT NULL)"),a.exec(`INSERT INTO t (s) VALUES ('${i}')`);{const e=a.prepare("SELECT s FROM t").all();(0,s.eql)(e,[{s:i}])||c().throw("unexpected rows",{rows:e})}a.exec("VACUUM"),a.close(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3});{const e=(0,n.randomChars)(8);a.exec(`INSERT INTO t (s) VALUES ('${e}')`);const t=a.prepare("SELECT s FROM t ORDER BY s").pluck().all();(0,s.eql)(t,[i,e].sort())||c().throw("unexpected rows",{rows:t})}}finally{try{a?.close()}catch{}await Promise.all((0,u.sqliteFiles)(r).map((e=>e.rm())))}}t.firstDirSQLiteReadWrite=async function(...e){for(const t of e)if(null!=t&&await d(t))return t},t.isDirSQLiteReadWrite=d,t.assertDirSQLiteReadWrite_=h},87391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SQLiteSuffixes=void 0,t.SQLiteSuffixes=["-wal","-journal"]},27180:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteVersion_=void 0;const r=i(5916),s=i(84777),n=i(89966),a=i(63870),o=i(87550);t.sqliteVersion_=(0,r.lazyAsync)({later:async function(){let e;try{e=new o(":memory:");const t=e.prepare("select sqlite_version()").pluck().get(),i=await(0,n.sqliteNativePath_)(),r=(await(0,s.stdout_)(i,["-version"],{timeoutMs:(0,a.commandTimeoutMs)()})).trim();return{libraryVersion:t,toolVersion:r.split(/\s+/,1)[0],fullToolVersion:r,sqliteNativePath:i}}finally{e?.close()}},timeoutMs:(0,a.commandTimeoutMs)()})},15056:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),s=i(7311);function n(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=n,t.pathToDb=function(e,t){return n(e,t).join(s.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const a=n(i(76760)),o=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),v=i(70698),w=i(64680),b=i(29882),S=i(45969),P=i(43334),_=i(28874),M=i(41692),T=i(32774),E=i(80612),k=i(32551),D=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function x(){if((0,S.isDocker)())return[{dir:"/tmp/.photostructure-cache"+D(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,a.join)(i,".photostructure-cache"+D()),preexistingDir:i});return e}}function C(){if((0,S.isDocker)())return(0,o.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,a.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:T.DefaultDockerLibraryDir+"/.photostructure/cache"+D(),preexistingDir:T.DefaultDockerLibraryDir},...x()]);const e=(0,o.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),a.default.resolve((0,k.homeDir)(),"AppData","Local")]:P.isMac?[a.default.resolve((0,k.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,a.join)((0,k.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,a.join)(e,t),preexistingDir:e})));return i.push(...x()),i}t.tmpCacheDirs=x,t.tmpDirs=function(){return(0,E.filterDirs)({dirs:x(),desc:"tmp"})},t.cacheDirs=C,t.defaultCacheDir=(0,d.lazy)((()=>(0,E.firstDir)({dirs:C(),desc:"cache"})));const F=(0,d.lazy)((()=>{(0,M.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(A)}));function A(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{F();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,b.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=A},46292:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),s=i(45969),n=i(41692),a=i(32774),o=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,n.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,s.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,o.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:a.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:a.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,s.isDocker)()?c:(0,o.desktopConfigDirs)()).map((e=>e.dir))}},79960:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultApplePhotosLibrary=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(45255),o=i(84777),l=i(16287),u=i(57902),c=i(43334),d=(0,r.lazy)((()=>(0,n.mkLogger)("dir.DefaultApplePhotosLibrary"))),h=["read","com.apple.photolibraryd","SystemLibraryPath"];t.defaultApplePhotosLibrary=async function(){if(c.isMac)try{const e=await(0,o.stdout_)("defaults",h,{timeoutMs:a.ShortCommandTimeoutMs});if((0,s.blank)(e))return void d().warn(`"defaults ${h.join(" ")}" returned blank (!!)`);{const t=await(0,l.isReadableDirectory)(e);return d().tap({msg:"defaultApplePhotosLibrary()",level:u.LogLevels.info,result:t?e:void 0,meta:{isReadable:t}})}}catch(e){return void d().warn("defaultApplePhotosLibrary()",e)}}},32774:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),s=i(45969),n=i(32774);t.defaultLibraryDir=function(){return(0,s.isDocker)()?n.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,s.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const s=r(i(76760)),n=i(40958),a=i(72993),o=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),s.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(s.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,o.env)().XDG_DATA_HOME,(0,o.env)().XDG_CONFIG_HOME,s.default.resolve((0,d.homeDir)(),".config")),(0,n.compactBlanks)(e).map((e=>({dir:s.default.join(e,(0,a.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),s=i(96706),n=i(29882);t.envConfigDir=function(){const e=(0,s.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,n.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),s=i(40958),n=i(22573),a=i(66430);function o({dirs:e,desc:t}){for(const{dir:i,preexistingDir:o}of(0,s.compact)(e))if(!(0,n.blank)(i)){if((0,a.isReadWriteableDirectorySync)(i))return i;if((0,n.blank)(o)||(0,a.isReadWriteableDirectorySync)(o))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=o,t.filterDirs=function({dirs:e,desc:t}){return(0,s.compact)(e.map((e=>o({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),s=i(76760),n=i(1708),a=i(19851),o=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,a.lazy)((()=>{const e=[];u.isWin?e.push(n.env.USERPROFILE):e.push(n.env.HOME);for(const t of(0,o.compactBlanks)(e)){const e=(0,s.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),s=i(49776),n=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[n.libraryDataDir,n.libraryPreviewsDir,s.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},48195:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotLibraryDir=t.isLibraryDir=void 0;const r=i(19851),s=i(22573),n=i(98553),a=i(12168),o=i(50213),l=i(15056),u=i(98314),c=i(17217),d=i(16287),h=i(2858),f=i(87290),m=(0,r.lazy)((()=>(0,o.mkLogger)("dir.IsLibraryDir")));function p(e){return null==e?"(null)":(0,n.stringify)((0,c.toNativePath_)(e))}async function g(e){return m().tap({msg:"whyNotLibraryDir("+e+")",result:await y(e)})}async function y(e){if((0,s.blank)(e))return"blank path";const t=(0,c.toNativePath_)(e);try{const e=await(0,d.stat_)(t);if(null==e||!e.isDirectory())return"not a directory"}catch(e){return"cannot read: "+(0,u.errorToS)(e)}const i=(0,f.libraryDataDirPosixFile)(t);if(!0!==await(i?.isDirectory({refresh:!0,logLevel:"trace"})))return"library data directory, "+p(i)+", is not a directory";const r=(0,h.librarySettingsFile)(t)?.clear();if(null==r||!await r.isNonEmptyFile())return"library settings, "+p(r)+", is empty or missing";const n=(0,l.pathToDb)(i,"models")?.clear();if(null==n||!await(n?.isNonEmptyFile(a.KB)))return"library database, "+p(n)+", is empty or missing";const o=(0,f.libraryPreviewsDirPosixFile)(t);return!0!==await(o?.isDirectory({refresh:!0,logLevel:"trace"}))?"library previews, "+p(o)+", is empty or missing":void 0}t.isLibraryDir=async function(e){return null==await g(e)},t.whyNotLibraryDir=g},9595:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),s=i(54993),n=i(29882),a=i(28874);function o(e){return(0,r.toNotBlank)((0,s.toS)(e))??a.Settings.libraryDir.valueOrDefault}t.libraryDir=o,t.originalsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,n.resolveMaybe)(o(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),s=i(55835),n=i(37805),a=i(15056),o=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${n.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function v(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+o.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function w(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function b(e){return y(w(e),!1)}function S(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(S(e))}function _(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function M(e){return y(_(e))}async function T(e){return y((0,s.map)(g(e),(e=>(0,a.pathToDbDir)(e,a.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await v(t);return(0,r.uniq)([t,i,await b(t),await P(t),await M(t),await T(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=v,t.libraryOriginalsDirPosixFile=w,t.setupLibraryOriginalsDir_=b,t.libraryPreviewsDirPosixFile=S,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=_,t.setupLibrarySyncReportsDir_=M,t.setupLibraryDbDir_=T},46296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),v=i(80612),w=i(32551);function b(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:s.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,a.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>s.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function S(){return(0,v.firstDir)({dirs:b(),desc:"logs"})}t.defaultLogDirs=b,t.defaultLogDir_=S,t.logDir=(0,n.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,o.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,o.notBlank)(i)?i:S()}catch(e){return console.error("defaultLogDir_() failed",e),s.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(44198),o=i(43334),l=i(24399),u=i(32551);async function c(){return o.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,s.lazy)((async()=>{if(o.isWin){const e=await c();if((0,n.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,s.lazy)((()=>(0,a.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),s=i(7282),n=i(29325),a=i(44198);t.getDevEnvFlag=function(e){return!(0,s.isProd)()&&!(0,n.isPacked)()&&((0,r.toBoolean)((0,a.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,a.env)()[e]=String(t)}},34580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),s=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,s.env)().DO_NOT_TRACK)}},44198:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const s=r(i(73024)),n=i(76760),a=r(i(1708)),o=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),v=i(6012),w=i(96706);t.env=(0,o.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>a.default.env[e])).join(n.delimiter).split(n.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===a.default.env.PS_LICENSE||e.push((0,n.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),i={...a.default.env};for(const r of e)try{const e=(0,d.debom)(s.default.readFileSync((0,p.resolve)(r))),n=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(n))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),s=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let n;for(const a of(0,s.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(n=e.exec(a));){if(null==n.groups)continue;const{key:e,val:s}=n.groups;if((0,r.blank)(e)||null==s)continue;const a=s.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=a}}return i}},96706:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const s=r(i(1708)),n=i(19851),a=i(22573),o=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,n.lazy)((()=>(0,a.firstNotBlank)(s.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,s.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,n.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,n.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,o.isTrue)(g(e))}},98314:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),s=i(19851),n=i(40958),a=i(22573),o=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),v=i(70025),w=i(57159);function b(...e){if((0,n.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(o.errorName),...e.map(o.errorCode),...(0,n.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(o.ErrorDelimiter)))];return(0,n.uniqSubstrings)(S((0,l.flatten)(i)))}function S(e){return(0,n.compact)(e).filter((e=>!o.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(a.notBlank)}function P(e,t){const i=(0,n.uniqSubstrings)(S(e)),r=t?.maxLen??400,s=t?.trailingChars??64,a=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(i.join(o.ErrorDelimiter)),r-a.length,s)+a.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,a.blank)(e)?"":P(b(e),t)}t.StartTs=Date.now(),t.logger=(0,s.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,a.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,a.notBlank)(i))return i}},t.splitErrorMessage=b,t.normalizeErrorMessages=S,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,a.blank)(e)&&(e=t.MissingError),_(e,{maxLen:i})+" at "+(0,o.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),s=i(26905),n=i(55835),a=i(54993),o=i(81168);t.describeError=function(e){const t=(0,o.stripSuffix)((0,a.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,n.map)((0,s.errorErrno)(i),(e=>t.push(u.get(e)))),(0,n.map)((0,s.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),s=i(76790),n=i(50989),a=i(68852);t.ErrorFlags=(0,n.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,s.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(a.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),s=i(38639),n=i(26905),a=i(54993),o=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,a.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,a.toS)(e)+(0,r.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,o.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function b(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function S(e){return!!((0,s.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||b(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=b,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===S(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,n.errorCode)(e)||v(e)||w(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=S;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,s.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,s.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},51837:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalError=void 0;const r=i(38835);class s extends Error{constructor(e){super(e+r.InternalErrorFlag)}}t.InternalError=s},8769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),s=i(31586),n=i(68708),a=i(7282),o=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,n.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const s=!0===i.fatal,c=!0===i.ignorable;if(!s&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),s&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!s||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!s||(0,a.isTest)()||(0,o.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),s}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,s.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,o.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,s.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,s.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(26905),o=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,s.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,s.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,a.errorName)(t)??(0,d.first)(this.causes,a.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(a.errorCode)],a.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,a.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,n.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,n.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,n.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,s.blank)(r)||(i=(0,h.dedupeNeedle)(i,r,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,o.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const a=i(49769),o=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),s.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,a.getOrSet)(n(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),a=n(this,r,"f").get(e);return null!=a&&(a.resolve(t),n(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,s=new WeakMap},34102:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),s=i(19851),n=i(15197);t.ee=(0,s.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new n.CapturingEventEmitter(e)}))},64660:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const s=r(i(73024)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,a.lazy)((()=>n.default.geteuid?.())),h=(0,a.lazy)((()=>n.default.getgroups?.()));function f(e,t){try{return!(0,o.blank)(e)&&(s.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,s.default.constants.R_OK|s.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,s.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:s,processGid:n}){if(null==e)return!1;const a=s??d(),o=null!=n?[n]:h()??[],l=0===a,u=l||e.uid===a,f=l||o.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const s=r(i(76760)),n=i(19851),a=i(81168),o=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,n.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,a.equalsIgnoreCase)(e.basename,i.base))return s.default.join(r,e.basename);throw new o.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),s=i(76760);function n(e){return[...a(e)]}function*a(e){for(;e!==(0,s.dirname)(e);)e=(0,s.dirname)(e),yield e}function o(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=o(e);return t.every((e=>i.includes(e)))}t.ancestors=n,t.ancestorG=a,t.selfAndAncestorG=function*(e){yield e,yield*a(e)},t.childrenSync=o,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return n(e).find((e=>l(e,t)))}},83278:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),v=f(i(1708)),w=i(46466),b=f(i(57975)),S=f(i(38522)),P=i(19851),_=i(40958),M=i(5233),T=i(22573),E=i(42659),k=i(50357),D=i(96249),x=i(98553),C=i(55835),F=i(31586),A=i(68708),I=i(97790),O=i(39926),L=i(51926),R=i(59455),N=i(54993),B=i(48884),j=i(22911),z=i(99331),V=i(56519),W=i(56038),U=i(31562),H=i(76850),q=i(70025),G=i(34102),$=i(80875),J=i(50213),K=i(70417),Y=i(43334),Z=i(81168),X=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),se=i(89968),ne=i(20197),ae=i(88561),oe=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),ve=i(27794),we=i(73428),be=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const Se=(0,P.lazy)((()=>new ae.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),s.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),a.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(s=new WeakMap,a=new WeakMap,r=new WeakSet,b.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,B.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,T.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=Se().get(i);if(null!=r)return r;const s=(0,fe.resolve)(i),n=new Pe(s,t);return Se().set(i,n),Se().set(s,n),n}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,s,"f").unset(),h(this,a,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,C.map)(this.statSync(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,s,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",n).call(this)??await d(e=this.clearThisAndParent(),r,"m",n).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,R.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,F.gt0)(t))return;const i=await d(this,s,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,k.eql)(["."],e)||e.every(T.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,C.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,O.pad2)(t+1),(0,O.pad2)(i))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,D.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,E.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),B.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>=(0,E.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>(0,E.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,C.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*E.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,oe.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,oe.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,$.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,$.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,H.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,be.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces),(0,A.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,M.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,z.ending)()?1:3,timeoutMs:0,retryDelay:E.secondMs,errorIsRetriable:q.isRetriableError})}async gunzip(){return d(this,r,"m",o).call(this,(0,Z.stripSuffix)(this.base,".gz"),S.default.createGunzip())}async gzip(){return d(this,r,"m",o).call(this,this.base+".gz",S.default.createGzip())}async compressBrotli(){return d(this,r,"m",o).call(this,this.base+".br",S.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,ne.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,ne.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(S.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,_.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new j.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,L.newlineRe)(),(r=>{const s=e.exec(r);null!=s&&(t.maybeResolve(s),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,F.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new j.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),_e)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,s)=>{try{const n=await e.f(r,(0,C.denull)(s));t(n)&&i.resolve(n)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,F.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,n=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,B.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,C.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},o=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*E.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},19748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const r=i(28874),s=i(88840),n=i(14036),a=i(29882);function o(e){return t=>r.Settings.respectFileExtensions.valueOrDefault?(0,n.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,a.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=o,t.isBrowserExtension=o(s.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=o(s.ExtTypes.Video),t.isAssetFileExtension=o(s.ExtTypes.AssetFile)},84542:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),s=i(96249),n=i(51926),a=i(54993),o=i(43334);function l(...e){return(0,s.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,a.toS)(e).split((0,n.newlineRe)()))))}t.Newline=o.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(a.toS).join("\n");return o.isWin?t.replace((0,n.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),s=i(19851),n=i(50213),a=i(37805),o=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,s.lazy)((()=>(0,n.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,o.mkdirp_)(i),await(0,d.writeTextfile_)((0,o.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+a.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,a.lazy)((()=>[...(0,o.mapNotBlankOr)(n.default.env.SYSTEMROOT,(e=>[e,s.default.join(e,"System32"),s.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const o=n(i(44652)),l=a(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),v=i(14427),w=i(17217),b=i(16287),S=i(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class M{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new M(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},s=await o.stat(t);return new M(i,new P(r,s))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return M.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new M(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>M.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new M(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,S.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,b.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await o.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await o.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=M},20197:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const s=r(i(76760)),n=i(39926),a=i(29882),o=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if(await(0,a.mkdirp_)(r.dir),!i.requireNumber&&await(0,o.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,o.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if((0,a.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},92423:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notInHiddenPhotoStructureDir=t.whyExcludedDirectoryRecursive=t.notExcludedDirs=t.isExcludedDirectory=t.whyExcludedDirectory=t.notExcludedDirPredicates=t.isExcludedFile=t.whyExcludedFile=t.notExcludedFilePredicates=t.excludeBundles=t.excludeGlobs=t.defaultFilePredicates=t.defaultDirPredicates=t.formatPathForGlob=void 0;const l=o(i(83058)),u=i(19851),c=i(40958),d=i(76790),h=i(22573),f=i(55835),m=i(51926),p=i(54993),g=i(48884),y=i(9092),v=i(54557),w=i(50213),b=i(88158),S=i(56519),P=i(46292),_=i(32551),M=i(35280),T=i(87290),E=i(96706),k=i(57902),D=i(43334),x=i(78984),C=i(33995),F=i(28874),A=i(21144),I=i(83278),O=i(48313),L=i(85772),R=i(78133),N=i(46356),B=i(17217),j=(0,u.lazy)((()=>(0,w.mkLogger)("fs.ExcludeGlobs"))),z=new v.FifoCache(256),V=/[\\/]$/;function W(e){const t=(0,p.toS)(e),i=z.get(t);if(null!=i)return i;const r=(0,B.isSimpleFile)(e)?e:I.BaseFile.for(e),s=V.test(t)||r.isDirectorySync(),n=(0,R.native2posix)(r.nativePath),a=s?(0,m.ensureSuffix)(n,"/"):n;return z.set(t,a),z.set(a,a),z.set(r.nativePath,a),a}t.formatPathForGlob=W;class U{constructor(e,t,i=!0){if(r.add(this),this.pattern=e,this.desc=t,this.exclude=i,e.includes("\\")){const t=e;e=(0,R.native2posix)(t),j().warn("globToPredicate(): backslash in patterns aren't supported: assuming you meant forward-slash?",{given:t,input:e})}this.reason=(0,c.compactBlanks)([this.exclude?"not":"",t,"("+(0,m.ellipsize)(e,48,12)+")"]).join(" ");try{this.re=l.default.makeRe(this.pattern,{nocase:F.Settings.globsCaseInsensitive.valueOrDefault,dot:!0,posixSlashes:!0}),this.valid=!0}catch(e){this.valid=!1,j().warn("Cannot parse pattern",{glob:this.pattern,error:e})}this.bundle=this.valid&&null!=this.re?(0,b.pairToObject)(this.reason,a(this,r,"m",s).bind(this)):{}}}r=new WeakSet,s=function(e){const t=W(e),i=this.re.test(t)??this.exclude;return j().tap({msg:"apply()",level:i?k.LogLevels.debug:k.LogLevels.trace,result:i?!this.exclude:this.exclude,meta:{desc:this.desc,pattern:this.pattern,exclude:this.exclude,posixPath:t,matched:i}})};class H{constructor(){n.set(this,[])}push(...e){for(const t of e){if(!t.valid){j().warn("Ignoring invalid glob",{glob:t});continue}const e=a(this,n,"f").find((e=>e.pattern===t.pattern));null==e?a(this,n,"f").push(t):j().debug("Ignoring duplicate glob",{glob:t,prior:e})}}pushNativePath(e,t){this.push(new U((0,R.native2posix)(e),t))}toA(){return a(this,n,"f")}}n=new WeakMap;const q=new U("**/.*","hidden file"),G=new U("**/.*/","hidden directory"),$=(0,u.lazy)((()=>{const e=new H;e.push(G,q);for(const t of[{s:"bin",desc:"command binary"},{s:"dev",desc:"device file"},{s:"etc",desc:"system configuration file"},{s:"initrd",desc:"initial ramdisk"},{s:"proc",desc:"process metadata"},{s:"sbin",desc:"system binary"},{s:"snap",desc:"snap software"},{s:"sys",desc:"system metadata"},{s:"Dell",desc:"Windows driver"},{s:"Drivers",desc:"Windows driver"},{s:"Intel",desc:"Windows driver"},{s:"Microsoft",desc:"Windows driver"},{s:"NVIDIA",desc:"Windows driver"},{s:"Windows.old",desc:"Windows system"},{s:"Windows",desc:"Windows system"}])e.push(new U((D.isWin?"*":"")+"/"+t.s+"/",t.desc));if(D.isWin)for(const t of["ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemRoot","windir"]){const i=(0,E.getEnv)(t);(0,h.blank)(i)||e.pushNativePath(i,`%${t}%`)}D.isLinux&&e.push(new U(`${(0,_.homeDir)()}/snap/`,"Snap software"));for(const t of[{s:"__MACOSX",desc:"macOS resource fork"},{s:"_includes",desc:"code"},{s:"@eaDir",desc:"Synology thumbnail"},{s:"@Recently-Snapshot",desc:"QNAP snapshot"},{s:"@Recycle",desc:"QNAP trash"},{s:"@SynoResource",desc:"Synology metadata"},{s:"#recycle",desc:"Synology trash"},{s:"#snapshot",desc:"Synology snapshot"},{s:"$Recycle.Bin",desc:"Windows trash"},{s:"$SysReset",desc:"Windows"},{s:"3rdParty",desc:"code"},{s:"Application Data",desc:"Windows apps"},{s:"Application Support",desc:"macOS apps"},{s:"Applications",desc:"macOS apps"},{s:"arangodb",desc:"3rd party"},{s:"cache",desc:"Cache directory"},{s:"CacheClip",desc:"Movie cache directory"},{s:"caches",desc:"Cache directory"},{s:"Chipset_Software",desc:"Windows apps"},{s:"cmake",desc:"code"},{s:"com.apple.TimeMachine.localsnapshots",desc:"macOS"},{s:"cpan",desc:"code"},{s:"DefinitelyTyped",desc:"TypeScript type"},{s:"Desktop DB",desc:"macOS metadata"},{s:"Desktop DF",desc:"macOS metadata"},{s:"Desktop.ini",desc:"macOS metadata"},{s:"DisplayDriver",desc:"Windows driver"},{s:"DLLs",desc:"Windows library"},{s:"dyld",desc:"macOS library"},{s:"ehthumbs.db",desc:"Windows thumbnail"},{s:"i18n",desc:"i18n code"},{s:"iMovie Cache",desc:"Apple iMovie cache"},{s:"iTunes Cache",desc:"Apple iTunes"},{s:"iTunes Media",desc:"Apple iTunes"},{s:"iTunes",desc:"Apple iTunes"},{s:"lib?(32|64|x64|s)",desc:"program library directory"},{s:"lost+found",desc:"fsck recovered directory"},{s:"macOS Install*",desc:"macOS installer"},{s:"Network Trash",desc:"AFP trash"},{s:"node_modules",desc:"Node.js library"},{s:"pkgconfig",desc:"code"},{s:"pkgs",desc:"Python code"},{s:"Program Files (x86)",desc:"Windows apps"},{s:"Program Files",desc:"Windows apps"},{s:"ProgramData",desc:"Windows application support"},{s:"resources/media/face",desc:"face thumbnail"},{s:"rubygems-*",desc:"Ruby code"},{s:"site-packages",desc:"Python code"},{s:"spotifycache",desc:"Spotify cache"},{s:"SteamApps",desc:"Game files"},{s:"System Volume Information",desc:"Windows system metadata"},{s:"System32",desc:"Windows system"},{s:"SystemTemp",desc:"Windows temporary"},{s:"temp",desc:"temporary"},{s:"Temporary Items",desc:"temporary"},{s:"test_suite",desc:"code"},{s:"testutil?(s)",desc:"code"},{s:"third_party",desc:"code"},{s:"Thumbnail?(s)",desc:"thumbnail"},{s:"Thumbs.db",desc:"Windows thumbnail"},{s:"tmp",desc:"temporary"},{s:"Trash",desc:"trash directory"},{s:"Windows",desc:"Windows"},{s:"Windows.old",desc:"Windows"},{s:"Windows10Upgrade",desc:"Windows upgrade"},{s:"Xcode.app",desc:"macOS code"},{s:"*.sparsebundle/bands",desc:"Time Machine backup"},{s:"ImageMagick*",desc:"ImageMagick source"},{s:"Install OS X*",desc:"macOS installer"},{s:"Install macOS*",desc:"macOS installer"},{s:"*.lrdata",desc:"LightRoom data"},{s:"MinGW*",desc:"code"},{s:"msys*",desc:"code"},{s:"vcpkg",desc:"code"}])e.push(new U("**/"+t.s+"/",t.desc));function t(t,i,r){if(!(0,h.blank)(t)){const s=(0,d.sort)((0,c.uniq)((0,c.compactBlanks)(i).map((e=>e.toLowerCase()))));1===s.length&&e.push(new U(`**/${t}/${s[0]}/`,r)),s.length>1&&e.push(new U(`**/${t}/(${s.join("|")})/`,r))}}(0,f.map)((0,P.configDir)(),(t=>e.pushNativePath(t,"PhotoStructure configuration"))),t("nix",["store"],"NixOS package"),e.push(new U("**/*.(photo|photos|ap)library/!(master|masters|modified|original|originals)/","Apple Photos/Aperture library")),e.push(new U("**/facetile*","face thumbnail"));const i=["bin","cygdrive","dev","etc","games","include","lib?(32|64|x64)","local","locale","man","proc","sbin","share","src","tmp","usr","var"];t("usr",i,"FHS system"),t("cygwin?(64)",i,"Cygwin"),t("local",i,"FHS system"),t("Windows",["assembly","Boot","Containers","Cursors","Fonts","Help","Installer","Logs","Microsoft.NET","Servicing","SoftwareDistribution","System32","SystemApps","SysWOW64","Temp","WinSxS"],"Windows"),t("Recovery",["Customizations","OEM"],"Windows"),t("lib",["firmware","modules","systemd","udev","x86_64-linux-gnu"],"Linux system package"),t("opt",["google","x11",...i],"FHS package"),t("lfs",["incomplete","objects"],"Git LFS object");const r=["cache","crash","games","lib","local","lock","log","logs","mail","run","snap","spool","tmp"];t("var",r,"Linux /var"),t("mnt",r,"Linux /mnt"),t("dev",["block","bsg","bus","char","cpu","disk","dri","fd","hugepages","input","lightnvm","mapper","mqueue","net","pts","shm","snd","ubuntu-vg","usb","vfio"],"Linux /dev backup"),t("proc",["acpi","asound","bus","driver","fs","ipmi","irq","net","scsi","self","sys","sysvipc","thread-self","tty"],"Linux /proc backup"),t("library",["Apple","Assistant","Bluetooth","com.apple.iTunesCloud","Containers","CoreAnalytics","Developer","Desktop Pictures","Documentation","Extensions","Finance","Fonts","Frameworks","FrontBoard","Group Containers","HTTPStorages","iTunes","KeyboardServices","Keychains","Logs","Messages","News","Passes","Photos","Preferences","Ruby","Saved Application State","Scripts","User Pictures","Updates","User Template","WebKit","WebServer"],"macOS Library"),t("packages",["*.pkg","*.mpkg"],"macOS package"),t("src/**",["bin","ci","dist","doc?(s)","etc","lib?(s)","main","spec?(s)","src","test?(s)","tools","util"],"code"),t("docs",["admin","content","general","generated","sql"],"code"),t("pkg",["acceptance","ccl","cli","cmd","server","sql","storage","ui","util","workload"],"code"),t("osv",["apps","arch","compiler","external","include","java","modules","musl","tests"],"code"),t("go",["bin","blog","cmd","doc","lib","misc","pkg","src","test","vt"],"code"),t("Perl?(64)",["bin","eg","etc","html","lib","site"],"code"),t("Python*",["dlls","doc?(s)","include","lib?(s)","scripts","tools","tcl"],"code"),t("Ruby*",["bin","include","lib","msys*","packages","share","ssl"],"code"),t("msys*",["clang*","dev","etc","mingw*","tmp","ucrt*","var"],"code"),t("sdk",["build-tools","emulator","extras","patcher","platforms","platform-tools","sources","tools"],"code"),t("test",["fixtures"],"code"),t("data",["$of"],"windows backup"),t("System",["Applications","Developer","DriverKit","Library","iOSSupport"],"macOS System"),t("contents",["frameworks","plugins","resources","sharedsupport"],"macOS application"),t("pg",["pgsql"],"code");for(const e of["local","locallow","roaming"])t("appdata",[e],"Windows default AppData");return t("ps",["cache","config","logs","tmp"],"PhotoStructure docker directory"),e.toA()})),J=()=>{t.excludeGlobs.unset(),t.excludeBundles.unset()},K=()=>{t.notExcludedDirs.unset()},Y=(0,u.lazy)((()=>{F.Settings.excludeGlobsOmitDefaults.watchLater(J),F.Settings.excludeGlobsAdd.watchLater(J),F.Settings.excludeGlobsOmit.watchLater(J),F.Settings.globsCaseInsensitive.watchLater(J),F.Settings.libraryDir.watchLater(K),F.Settings.originalsDir.watchLater(K),F.Settings.scanPaths.watchLater(K),F.Settings.argvScanPaths.watchLater(K)}));t.defaultDirPredicates=(0,u.lazy)((()=>[{notSymlinkLoop:re,notInHiddenPhotoStructureDir:ne,whyNoMedia:L.whyNoMedia,notHidden:se}])),t.defaultFilePredicates=(0,u.lazy)((()=>[{notInHiddenPhotoStructureDir:ne}])),t.excludeGlobs=(0,u.lazy)((()=>{Y();const e=new y.CaseInsensitiveMap;function t(t){if(null!=t&&t.valid){const i=t.pattern.trim();e.has(i)&&j().warn("Duplicate glob:",{glob:t}),e.set(i,t)}}function i(t){const i=t.trim();e.has(i)?e.delete(i):j().warn("Failed to find and remove glob specified in PS_EXCLUDE_GLOBS_OMIT",{glob:t})}if(!F.Settings.excludeGlobsOmitDefaults.valueOrDefault)for(const e of $())t(e);for(const e of F.Settings.excludeGlobsOmit.values)i(e);for(const e of F.Settings.excludeGlobsAdd.values)t(new U(e,"(from PS_EXCLUDED_GLOBS_ADD)"));const r=(0,d.sortBy)(e.values(),(e=>(0,c.compactBlanks)(e.pattern.toLowerCase().split("/")))),[s,n]=(0,g.partition)(r,(e=>e.pattern.endsWith("/")));return{dir:s,file:n}})),t.excludeBundles=(0,u.lazy)((()=>{const e=(0,t.excludeGlobs)();return{dir:[...(0,t.defaultDirPredicates)(),...e.dir.map((e=>e.bundle))],file:[...(0,t.defaultFilePredicates)(),...e.file.map((e=>e.bundle))]}}));const Z=[{disableAllFilters:()=>!0}],X=[{notBlank:()=>!1}];function Q(e){return F.Settings.disableAllFilters.valueOrDefault?Z:(0,h.blank)(e)?X:(0,t.excludeBundles)().file}function ee(e){return C.SyncPredicates.whyRejected(e,...Q(e))}function te(e){return F.Settings.disableAllFilters.valueOrDefault?Z:(0,h.blank)(e)?X:(0,t.excludeBundles)().dir}async function ie(e){return F.Settings.disableAllFilters.valueOrDefault?void 0:x.Predicates.whyRejected(e,...te(e))}function re(e){return!(0,N.seemsLikeSymlinkLoop)(e)}function se(e){return(0,S.thenNot)((0,O.isHidden)(e))}function ne(e){return!(0,M.inHiddenPhotoStructureDir)(e)}t.notExcludedFilePredicates=Q,t.whyExcludedFile=ee,t.isExcludedFile=function(e){return null!=ee(e)},t.notExcludedDirPredicates=te,t.whyExcludedDirectory=ie,t.isExcludedDirectory=async function(e){return null!=await ie(e)},t.notExcludedDirs=(0,u.lazy)((async()=>{const e=(0,c.uniq)((0,c.compactBlanks)([(0,T.libraryDirPosixFile)(),(0,T.libraryOriginalsDirPosixFile)(),...F.Settings.argvScanPaths.values,...F.Settings.scanPaths.values]));return j().tap({msg:"notExcludedDirs() (these directories will never be excluded)",level:"info",result:(0,c.uniq)([...e,...await Promise.all(e.map((e=>(0,A.actualPath)(e))))])})})),t.whyExcludedDirectoryRecursive=async function(e){const i=await(0,t.notExcludedDirs)();for(let t=e;null!=t&&!t.isRoot;t=await(t?.parent())){if(i.includes(t?.nativePath))return;const e=await ie(t);if(null!=e)return e}},t.notInHiddenPhotoStructureDir=ne},88561:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const a=i(40958),o=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>n(this,r,"m",s).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,a.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,r=new WeakSet,s=async function(e){if((0,o.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},79267:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCleanup=void 0;const c=i(19851),d=i(40958),h=i(42659),f=i(31586),m=i(71371),p=i(50213),g=i(7282),y=i(409),v=i(78406),w=i(25764),b=i(99331),S=i(91655),P=i(34102),_=i(89968),M=i(85772);class T{static for(e){return new T(e.name,e.rootNativePath,e.staleMs,e.isPrunable,e.minRetained)}constructor(e,t,i,a,d=0){r.add(this),this.name=e,this.rootNativePath=t,this.staleMs=i,this.isPrunable=a,this.minRetained=d,s.set(this,void 0),this.intervalMs=(0,c.lazy)((()=>(0,f.clamp)((0,g.isTest)()?0:5*h.minuteMs,h.dayMs,this.staleMs/2))),n.set(this,void 0),this.cleanup=(0,y.rateLimited)({name:this.name,minCallDelayMs:this.intervalMs()/4,f:()=>u(this,r,"m",o).call(this)}),l(this,s,(0,p.mkLogger)("fs.FileCleanup("+e+")"),"f")}scheduleInterval(){return(null==u(this,n,"f")||u(this,n,"f").ended)&&l(this,n,new v.EndableInterval({name:this.name,callback:()=>this.cleanup(),intervalMs:this.intervalMs(),rank:w.EndableRanks.first}),"f"),u(this,n,"f")}cancelInterval(){u(this,n,"f")?.end(),l(this,n,void 0,"f")}}t.FileCleanup=T,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(e){if(!(0,f.gt0)(this.minRetained))return new Set;const t=new m.BoundedGreatestSet(this.minRetained??0,(e=>e.mtimeMs()));return await e.visitDescendants((e=>{e.isFile()&&t.add(e)})),new Set(t.vacuum().map((e=>e.nativePath)))},o=async function(){try{if((0,b.ending)())return;const e=await this.rootNativePath();if(null==e)return[];const t=await _.DirectoryEntry.for(e);if(null==t)return[];u(this,s,"f").info("cleanup(): starting",{root:t,staleMs:(0,S.fmtFullDuration)(this.staleMs," ")});const i=await u(this,r,"m",a).call(this,t),n=Date.now()-this.staleMs,o=new Set,l=[],c=[];await t.clear().visitDescendants((async e=>{if((e.dir!==t.nativePath||!(0,M.isNoMediaName)(e.base))&&!i.has(e.nativePath)&&(o.has(e.nativePath)||!(0,f.gte)(e.mtimeMs(),n)))if(e.isDirectory())try{await e.rmdir_(),c.push(e.nativePath),o.add(e.dir)}catch(t){"ENOENT"===t.code&&(u(this,s,"f").warn("cleanup(): ENOENT "+e,t),(0,P.ee)().emit("clearCache")),"ENOTEMPTY"!==t.code&&u(this,s,"f").warn("cleanup(): failed to rmdir "+e,t)}else if(!1!==await(this.isPrunable?.(e)))try{await e.unlink_(),l.push(e.nativePath),o.add(e.dir)}catch(t){u(this,s,"f").warn("cleanup(): failed to clean up tmpfile "+e,t)}}));const h=[...l,...c];return(0,d.isNotEmpty)(h)&&t.clear(),u(this,s,"f").info("cleanup(): done",{root:t,pruned_file_count:l.length,pruned_dir_count:c.length}),h}catch(e){return void u(this,s,"f").error("cleanup() failed",{error:e})}}},32144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),s=i(22573),n=i(45599),a=i(96249),o=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,n.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,s.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,a.flatten)((0,o.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),s=i(17217),n=i(16287),a=i(68284);async function o(e){return(0,r.pick)(await(0,n.stat_)((0,s.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=o,t.fileStats=async function(e){try{return await o(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,a.statSync)((0,s.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const r=i(68817),s=i(19851),n=i(22573),a=i(50213),o=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),h=i(95696),f=i(93854),m=i(16287),p=(0,s.lazy)((()=>(0,a.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,f.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,r.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const s=(0,n.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),a=(0,l.normalizeExt)(h.PosixFile.for(e))??(0,c.mimetypeExt)(s);return(0,n.blank)(s)||(0,n.blank)(a)?void 0:{ext:a,mime:s}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new o.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,s.set(this,[]),n.set(this,void 0),a.set(this,void 0),l(this,a,(0,f.fileStatsSync)(e),"f"),l(this,n,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",o).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,s,"f").push(e)}close(){u(this,n,"f").close()}}t.FileWatcher=m,s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,a,"f"),t)){l(this,a,t,"f");for(const t of u(this,s,"f"))t(e,this.nativePath)}}},13829:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withFsAdvisoryLocks_=t.defaultFsAdvisoryLockDir=void 0;const r=i(55835),s=i(13538),n=i(81168),a=i(37628),o=i(46292),l=i(73209),u=i(95696);function c(){return(0,r.map)((0,o.configDir)(),(e=>u.PosixFile.for(e).join("advisory-locks")))}t.defaultFsAdvisoryLockDir=c,t.withFsAdvisoryLocks_=async function({name:e,lockNames:t,f:i,timeoutMs:r,lockDir:o=c()}){if(null==o)return i();await o.mkdirp_();const u=(0,n.sortIgnoreCase)(t).map((e=>l.FsLock.for({name:e,file:o.join((0,a.shortFsStringSha)(e)),timeoutMs:r})));try{for(const t of u)if(!0!==await(0,s.thenOrTimeout)(t.acquire_(),r))throw new Error("Failed to acquire lock for "+e+": "+t.opts.name+" was busy");return await i()}finally{for(const e of u)e.release()}}},73209:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,v,w,b=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},S=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const _=i(58587),M=P(i(44652)),T=i(87997),E=i(40958),k=i(17586),D=i(42659),x=i(50357),C=i(75240),F=i(55835),A=i(31586),I=i(30976),O=i(13538),L=i(54993),R=i(7282),N=i(68852),B=i(23560),j=i(25764),z=i(38836),V=i(99331),W=i(22781),U=i(38835),H=i(55222),q=i(63870),G=i(69734),$=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)(G.PsLockExt)+"$");class K extends z.EndableWrapper{static newUid(e=process.pid){return S(this,s,Math.max(Date.now(),b(this,s,"f",n)+1),"f",n),(0,E.compactBlanks)([H.TokenRadix.encode(b(this,s,"f",n)),B.serviceName.prior(),(0,L.toS)(e)]).join("-")}static pidFromLockfile(e){return s.pidFromBasename((0,$.basename)(e))}static pidFromBasename(e){return(0,A.toInt)(J.exec((0,L.toS)(e))?.groups?.pid)}static for(e){return b(this,s,"f",o).find((t=>t.opts.file===e.file))??new s(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>b(this,r,"m",w).call(this)),e.endableRank??j.EndableRanks.postdb,(0,q.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,S(t=s,s,(i=b(t,s,"f",a),++i),"f",a)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(b(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,G.fsLockFileBasename)(s.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await b(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,G.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+b(this,l,"f")),this.staleMs=(0,A.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),b(s,s,"f",o).push(this)}get acquired(){return b(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await b(this,r,"m",f).call(this,e)??b(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,k.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,x.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==b(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:D.secondMs);S(this,c,setInterval((()=>b(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=b(this,c,"f")&&(clearInterval(b(this,c,"f")),S(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(b(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),S(this,u,!1,"f"),(0,F.map)(b(this,d,"f"),(e=>(0,T.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?b(this,r,"m",v).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),S(this,d,setTimeout((()=>b(this,r,"m",v).call(this)),(0,A.toGt0)(this.staleMs)??D.secondMs),"f"),b(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(b(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,O.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,s=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,r=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,A.gt0)(this.staleMs)&&Date.now()>b(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await b(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){S(this,h,Date.now(),"f");const e=[],t=await b(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,A.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+D.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,G.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;s.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const n=i[0]===this.lockfile.base;if(n)S(this,u,!0,"f");else if(!0!==t?.vacuum){const t=s.pidFromBasename(i[0]);if((0,A.gt0)(t)&&!(0,_.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),b(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:n,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await b(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},v=async function(){await b(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},w=function(){(0,E.filterInPlace)(b(s,s,"f",o),(e=>b(e,l,"f")!==b(this,l,"f")))},n={value:0},K.internalErrors=0,a={value:0},o={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),s=i(51926),n=i(54993),a=i(17217);function o(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,s.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,s.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,n.toS)(e)))return;const i=(0,a.basename)(e);return o(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&o((0,a.basename)(e))}},4001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),s=i(55835),n=i(31586),a=i(51926),o=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,r.toNotBlank)(e.name)??(0,o.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,n.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:f(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const s=(0,u.parsePosixPath)(i),n=h(s,{aggressive:!1});return[...t,n+s.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,a.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),r=(0,a.stripPrefix)(t.toLowerCase().normalize(),i);return(0,s.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,a.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,s.map)(m.exec(t),(e=>t=e[1].trim())),(0,s.map)(g.exec(t),(e=>t=e[1].trim())),t}},19254:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fileGrep_=t.GrepReader=void 0;const s=r(i(73024)),n=i(57075),a=i(46466),o=i(54993),l=i(33456),u=i(17217),c=i(58722);class d extends n.Transform{constructor(e,t="\n"){super({objectMode:!1,autoDestroy:!0}),this.pattern=e,this.sep=t}_transform(e,t,i){const r=(0,o.toS)(e).match(this.pattern);null!=r&&this.push(r[1]??r[0]+this.sep),i()}}t.GrepReader=d,t.fileGrep_=async function(e,t){const i=new c.WritableToBuffer;return await(0,a.pipeline)([s.default.createReadStream((0,u.toNativePath_)(e)),new l.LineReader,new d(t),i]),(await i.buffer).toString()}},14977:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const s=r(i(44652)),n=r(i(73024)),a=i(46466),o=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,a.pipeline)(n.default.createReadStream(e,{autoClose:!0}),o.default.createGzip(),n.default.createWriteStream(t,{autoClose:!0})),await s.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const s=r(i(77598)),n=r(i(73024)),a=i(46466),o=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),v=i(16287),w=(0,o.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),b=(0,o.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function S(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=b().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),b().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await _(n.default.createReadStream(i)),stats:(0,u.pick)(await(0,v.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],i="sha512"){const r=s.default.createHash(i);return await(0,a.pipeline)([e,...t,r]),r.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:b,impl:P}),t.fileShaMeta_=S,t.fileSha_=async function(e){return(await S(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return s.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),s=i(42659),n=i(55835),a=i(31586),o=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,o.stdout_)("chflags",["hidden",t],{timeoutMs:10*s.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,n.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,o.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*s.secondMs}),i=(0,a.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),s=i(54993),n=i(7282),a=i(43334),o=i(69375),l=/^\/dev(?:\/|$)/i,u=a.isMac||(0,n.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=a.isMac||(0,n.isTest)()?/^\/private\//i:void 0,d=a.isMac||(0,n.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=a.isMac||(0,n.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,s.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,o.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},87128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonFileStore=void 0;const r=i(19851),s=i(55835),n=i(57159),a=i(50213);t.JsonFileStore=class{constructor(e,t,i){this.file=e,this.mkObject=t,this.onWrite=i,this.prior=(0,r.lazy)((()=>this.file.readJson("debug")))}async read_(){return await this.prior()??(0,s.map)(await this.mkObject(),(e=>this.write_(e)))}async write_(e){try{return await this.file.writeJson_(e,{spaces:2}),this.prior.set(Promise.resolve(e)),(0,a.mkLogger)("fs.JsonFileStore").info("wrote to "+this.file,e),null!=this.onWrite&&await this.onWrite(this.file,e),e}catch(e){throw new n.WrappedError("Failed to write to "+this.file,{cause:e,path:this.file.nativePath})}}}},33456:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),s=i(51926),n=i(54993);class a extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,n.toS)(e)).split((0,s.newlineRe)()),a=r.pop();this._prior=a??"";let o=!1;for(const e of r)o||(o=!this.push(e));o?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=a},64680:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const s=r(i(76760)),n=i(17217),a=i(73428);t.mkNoMedia_=function(e){return(0,a.writeTextfile_)(s.default.join((0,n.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},61704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nativePathsEql=t.nativePathsEqlSync=void 0;const r=i(21144),s=i(17217);t.nativePathsEqlSync=function(e,t){if(null==e||null==t)return!1;if(e===t)return!0;try{const i=(0,s.toNativePath_)(e),r=(0,s.toNativePath_)(t);return null!=i&&null!=r&&i===r}catch{return!1}},t.nativePathsEql=async function(e,t){try{return null!=e&&null!=t&&await(0,r.actualPath_)((0,s.toNativePath_)(e))===await(0,r.actualPath_)((0,s.toNativePath_)(t))}catch{return!1}}},85772:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const a=n(i(76760)),o=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),v=i(83278),w=i(70698),b=i(88561),S=i(65238),P=i(16287),_=(0,o.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),M="NoMedia",T=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(a.default.sep),"/"]).join("")+"])\\.?"+M+"$","im"),E=Object.freeze(["."+M,M]),k=Object.freeze((0,u.flatten)(E.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function D(e){return null!=T.exec(e)}t.isNoMediaName=D;const x=(0,o.lazy)((()=>new b.FileCache({name:"fs.noMediaDirsCache"})));async function C(e,t){if(null==e)return null;const i=v.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return D(i.base)||await(0,w.isCachedirTagFile)(i)?x().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):C(i.parent());{const e=await x().getOrSetAsync(i.nativePath,(()=>F(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:C(i.parent())}}async function F(e){if(D(e.base))return x().set(e.parent().nativePath,e.nativePath),_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,S.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,r=await Promise.race([A(e.nativePath,i),(0,S.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,w.isCachedirTagDirectory)(e)?_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(w.CACHEDIR_TAG).nativePath)}):null}async function A(e,t){for(const i of g.isCaseSensitiveFs?k:E){if(!0===t?.aborted)return null;const r=a.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return _().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function I(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(D(r.basename))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,a.join)(e,r.basename))});if(r.basename===w.CACHEDIR_TAG){const t=(0,a.join)(e,r.basename);if(await(0,w.isCachedirTagFile)(t))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await C(e,t)},t.whyNoMedia=C,t.whyNoMediaDir=F,t._dirHasNoMediaChild=A},29882:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),v=i(78133),w=i(53265),b=i(17217),S=i(16287),P=i(66430),_=i(5545);function M(e){return((0,b.isSimpleFile)(e)?e.base:n.default.basename(n.default.resolve(e))).startsWith(".")}t.logger=(0,a.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=M,t.containsHiddenPathname=function(e){return C(e).some(M)},t.isNotHiddenPosixPath=function(e){return C(e).every((e=>!M(e)))},t.resolveSimpleFile=function(e){return(0,b.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return E((0,v.posix2native)(e))},t.extname=function(e){return E(e).ext},t.dirname=function(e){return n.default.dirname((0,b.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(n.default.parse(e).ext,n.default.parse(t).ext)};const T=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function E(e){const t=T.exec(e)?.groups,i=t?.ext2??"",r=n.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function k(e){const t=n.default.parse((0,b.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,n.default.sep)}function D(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,b.toNativePath_)(e.ancestor),i=(0,b.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,n.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function x(e,t,i){if(null==t||null==i)return!1;const r=e(t),s=e(i);return null!=r&&null!=s&&(y.isLinux?r===s:(0,p.equalsIgnoreCase)(r,s))}function C(e){return(0,b.isSimpleFile)(e)?e.pathnames:e.split(n.default.sep).filter((e=>null!=e&&""!==e))}function F(e){return(0,u.notBlank)(e)&&C(e).length===(y.isWin?1:0)}function A({p:e,maxLength:t}){const i=(0,b.toNativePath_)(e);if(i.length<=t)return i;const r=C(e),s=[],n=[r.pop()];for(;r.length>0;)if(s.length=t){r.unshift(s.pop());break}}else if(n.unshift(r.pop()),O([...s,...n]).length>=t){r.push(n.shift());break}return r.length>0&&s.push("…"),O([...s,...n])}function I(e){return e.startsWith("\\\\")}function O(e){return(0,h.ensurePrefix)((0,o.compactBlanks)(e).join(n.default.sep),y.isWin?"":n.default.sep)}t.parseNativePath=E,t.parentBasename=k,t.grandParentBasename=function(e){return k(n.default.parse((0,b.toNativePath_)(e)).dir)},t.containedByNativePath=D,t.eqlBasename=function(e,t){return x(b.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return x(b.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return x(b.toNativePath_,e,t)},t.toPathnames=C,t.pathIsRoot=F,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:C(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,b.toNativePath_)(e),r=(0,b.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,v.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=A,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const s=[];for(const r of e.slice(0,i))s.push(A({p:r,maxLength:t}));return s.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return C(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return C(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=E(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,S.isReadableDirectory)(e))return;if(F(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await s.default.mkdirp(e)}catch(t){if(await(0,S.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;s.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>s.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,b.toNativePath_)(e).split(n.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=O,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:O(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>D({ancestor:t,descendant:e,acceptSelf:!0})?[(0,b.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),v=i(64660),w=i(21144),b=i(16287),S=(0,n.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const i=await(0,b.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,v.isStatRX)(i,e)}function M(){if(y.isWin){const e=(0,o.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,o.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,o.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,s.default.join(e,"System32"),s.default.join(e,"System32","Wbem"),s.default.join(i,"chocolatey","bin"),s.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function T(){const e=(0,h.toS)((0,m.env)().PATH).split(s.default.delimiter);return(0,a.uniq)((0,a.compactBlanks)([...e,...M()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,a.uniq)((0,a.compactBlanks)([...T(),...(0,d.toA)(i)]));for(const i of(0,a.uniq)((0,a.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=s.default.join(t,e);if(await _(i))return y.isLinux?i:(0,w.actualPath)(i)}}S().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){"use strict";var r,s,n,a=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return o(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),v=i(76790),w=i(5233),b=i(22573),S=i(42659),P=i(26905),_=i(75240),M=i(55835),T=i(31586),E=i(68708),k=i(13538),D=i(89937),x=i(12168),C=i(54993),F=i(48884),A=i(50213),I=i(45255),O=i(81168),L=i(56519),R=i(56038),N=i(31562),B=i(84777),j=i(9595),z=i(38835),V=i(70025),W=i(57902),U=i(55222),H=i(43334),q=i(33847),G=i(24399),$=i(28874),J=i(79915),K=i(45200),Y=i(34238),Z=i(87001),X=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),se=i(73209),ne=i(48313),ae=i(29882),oe=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,F.contextFilter)(function(e){return(0,v.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,A.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Y.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,L.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,L.thenMapOr)((0,X.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>H.isMac?(0,B.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,b.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,b.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,O.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,oe.toNativePath_)(e),r=new fe(i,t);return(0,O.isString)(e)&&he().set(e,r),he().set(i,r),r}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,L.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,ae.containedByNativePath)({ancestor:(0,j.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,ae.containedByNativePath)({ancestor:(0,j.originalsDir)(),descendant:this,acceptSelf:!0}))return H.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,M.map)((0,ee.bestMountpoint)(this.nativePath,await(0,X.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,M.map)((0,b.notBlankOr)(e,(()=>this.uri_())),Y.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,C.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===D.PS_LIBRARY_SCHEME?1:t.scheme===D.PS_LOCAL_FILE_SCHEME?2:t.scheme===D.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,O.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(H.isWin||H.isMac)return this.trap("hide",(async()=>(await(0,ne.hide_)(this),this)))}async hidden(){return(0,ne.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,O.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,F.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,M.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,E.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:s,skipWip:n=!1,skipFsLock:a=!1,retries:o=2,dirty:l=!1}){return(0,w.retryOnReject_)((async()=>{const o=await this.clear().isNonEmptyFile(i);if(!o){if(n&&a)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:a,minSizeBytes:i,timeoutMs:s,dirty:l})}return o&&r?void 0:this.utimes()}),{maxRetries:o,timeoutMs:2*s,retryDelay:3*S.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,T.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:s,dirty:n=!1}){return await this.parent().mkdirp_(),(0,se.withLock_)({file:this,skipFsLock:r,timeoutMs:s,dirty:n},(async()=>{const r=this.wip();try{await r.unlink("trace");const n=await(0,k.thenOrTimeoutError)(e(r),s);if(n===t.NoOp)return n;if(await(0,N.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),n;throw new Error(this+"applyWip(): still empty after waiting "+(0,_.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==$.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",s).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",n).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();$.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:S.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,T.clamp)(I.ShortCommandTimeoutMs,10*S.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,b.notBlank)(this.ext)&&(0,b.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,S.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,M.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,L.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,O.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,ae.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,ae.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,Z.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,r=new WeakSet,s=async function(e){let t,i=e;const r=e.wip();try{const s=await this.stat_();if(null==s)return this.pflog().throw("Can't copy missing files"+z.NonRetriableErrorFlag);if(s.size>0){if($.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+z.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,r.nativePath,h.default.constants.COPYFILE_FICLONE),s.size>5*x.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},s.size,(()=>r.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,T.approximates)(s.size,await r.size({refresh:!0}))),{intervalMs:S.secondMs,timeoutMs:S.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:s.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:s.birthtimeMs,mtimeMs:s.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,s.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${s.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,M.map)(t,(e=>e.end()))}},n=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),s=r?.size;return null==r||null==s?this.pflog().throw("Can't copy missing files"):(s>5*x.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},s,(()=>e.clear().size()))),H.isWin?await G.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,G.pwshQuote)(this.nativePath)} -Destination ${(0,G.pwshQuote)(i.nativePath)}`,(e=>e)):H.isMac?await(0,B.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,B.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+z.DoNotSendErrorFlag,{error:t})}finally{(0,M.map)(t,(e=>e.end()))}}},62105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.acceptFile=t.whyRejectFile=t.expensiveFileFiltersFor=t.acceptParentAndFileAndSimple=t.acceptFileSimple=t.whyRejectFileSimple=t.simpleFileFiltersFor=t.notFileTooBig=t.notFileTooSmall=t.notFileMissing=t.hasBrowserImgMimeType=t.notDimensionsTooSmall=t.requiredTagsFilter=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(54993),o=i(48884),l=i(56519),u=i(78984),c=i(28874),d=i(43207),h=i(47783),f=i(97573),m=i(16170),p=i(54979),g=i(1078),y=i(42231),v=i(83278),w=i(19748),b=i(92423),S=i(16287);function P(e){return async t=>(0,l.thenMapOr)((0,h.readRawTags)(t,!1),e,(()=>!1))}async function _(e){if(!(0,n.gt0)(c.Settings.minVideoDimension.valueOrDefault)&&!(0,n.gt0)(c.Settings.minImageDimension.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);if(null==t||!t.startsWith("image/")&&!t.startsWith("video/"))return!1;const i=t.startsWith("video/")?c.Settings.minVideoDimension.valueOrDefault:c.Settings.minImageDimension.valueOrDefault;return(0,n.gt0)(i)?(0,l.thenMapOr)((0,g.extractSizeInfoFromFile)(e),(e=>(0,n.gte)(e.ImageWidth,i)&&(0,n.gte)(e.ImageHeight,i)),(()=>!1)):null}async function M(e){if(!(0,n.gt0)(c.Settings.minVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.gte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.minVideoDurationSec.valueOrDefault):null)}async function T(e){if(!(0,n.gt0)(c.Settings.maxVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.lte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.maxVideoDurationSec.valueOrDefault):null)}async function E(e){return!(0,s.blank)(await(0,p.readMimeType)(e))}async function k(e){if(-100===c.Settings.rejectRatingsLessThan.valueOrDefault)return null;const t=await(0,h.readTags)(e),i=(0,n.toInt)(t?.Rating);return null==i||i>=c.Settings.rejectRatingsLessThan.valueOrDefault}async function D(e){return 0===c.Settings.keywordBlocklist.values.length?null:(0,f.rawTagKeywords)(await(0,h.readTags)(e)).every((e=>!0!==(0,y.leafIsExcluded)(e,c.Settings.keywordBlocklist.values)))}async function x(e){if(!c.Settings.requireMakeModel.valueOrDefault)return null;const t=await(0,h.readRawTags)(e);return null==t||(0,s.blank)(t.MIMEType)?null:t.MIMEType.startsWith("image/")?null!=t&&(0,s.notBlank)(t.Make)&&(0,s.notBlank)(t.Model):null}async function C(e){return(0,v.isBaseFile)(e)?e.exists():(0,S.exists)(e.nativePath)}async function F(e){const t=c.Settings.minAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.gte)(i,t)}async function A(e){const t=c.Settings.maxAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.lte)(i,t)}function I(e){return[{isSupportedFileExtension:w.isAssetFileExtension},...(0,b.notExcludedFilePredicates)(e),{notFileMissing:C},{notFileTooSmall:F,notFileTooBig:A}]}function O(e){return[...I(e),{notMissingMimeType:E},{supportedMimeType:m.isAssetFileMimeType},{notMissingMakeAndModelTags:x},{notDimensionsTooSmall:_},{notVideoTooShort:M},{notVideoTooLong:T},{notRejectedRating:k},{notExcludedKeyword:D}]}async function L(e,t){return await u.Predicates.whyRejected(e,...t??O(e))??await(0,b.whyExcludedDirectoryRecursive)(e.parent())}t.requiredTagsFilter=function(e){return P((t=>(0,o.allNotBlank)(...e.map((e=>t[e])))))},t.notDimensionsTooSmall=_,t.hasBrowserImgMimeType=P((e=>(0,r.includes)(["image/jpeg","image/png"],(0,a.toS)(e.MIMEType)))),t.notFileMissing=C,t.notFileTooSmall=F,t.notFileTooBig=A,t.simpleFileFiltersFor=I,t.whyRejectFileSimple=function(e){return u.Predicates.whyRejected(e,...I(e))},t.acceptFileSimple=function(e){return u.Predicates.accepted(e,...I(e))},t.acceptParentAndFileAndSimple=async function(e){const t=await e.parent();return null!=t&&!await(0,b.isExcludedDirectory)(t)&&await u.Predicates.accepted(e,...I(e))},t.expensiveFileFiltersFor=O,t.whyRejectFile=L,t.acceptFile=async function(e){return null==await L(e)}},78133:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const s=r(i(76760)),n=i(22573),a=i(81168);t.posix2native=function(e,t){if((0,n.blank)(e))return e;if(s.default.sep===s.default.posix.sep)return e;const i=(0,n.notBlank)(t)?s.default.sep+s.default.sep+t+s.default.sep:"",r=e.split(s.default.posix.sep);return(0,a.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(s.default.sep)},t.native2posix=function(e){return(0,n.blank)(e)||s.default.sep===s.default.posix.sep||s.default.posix.sep===s.default.sep?e:e.split(s.default.sep).join(s.default.posix.sep)}},43899:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,a.lazy)((()=>s.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,a.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(s.default.join((0,p.execDir)(),"resources"),s.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,o.compactBlanks)([(0,p.execDir)(),n.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const r=s.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),s=i(19851),n=i(31586),a=i(50213),o=i(57902),l=i(69428),u=(0,s.lazy)((()=>(0,a.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=o.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,n.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),s=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let n=-1;try{const s=i??(await(0,r.stat)(e)).size-t,a=Buffer.alloc(s);return n=await(0,r.open)(e,"r"),await(0,r.read)(n,a,0,s,t)}finally{(0,s.mapGte0)(n,r.close)}}},69428:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const a=n(i(73024));t.readFileSync=function(e){try{return a.readFileSync(e)}catch{}}},55690:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),s=i(84542);t.readLines_=async function(e){return(0,s.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class s extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=s},65238:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const s=r(i(51455)),n=i(76760),a=i(19851),o=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),v=i(28874),w=i(63870),b=i(88561),S=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,a.lazy)((()=>(0,n.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,a.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await s.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const M=(0,a.lazy)((()=>new b.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function T(e){(0,l.blank)(e)||M.prior()?.delete(e)}async function E(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await M().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,S.statTimeoutMs)(),r=k(e),s=await(0,h.thenOrTimeout)(r,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,S.statTimeoutMs)());if(s===f.Timeout&&(0,g.onTimeout)({soft:!1}),s!==f.Timeout&&s.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=T,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),M.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():T(e)))})),t.slowDirs=(0,a.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!M().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){T(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=M().get(e)},t.childDirectories_=async function(e){return(await E(e)).filter((e=>e.isDirectory)).map((t=>(0,n.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?E(e):k(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=E,t.readdirCached=function(e){return M().get(e)},t.readdirUncached_=k},53265:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const s=i(73024),n=r(i(76760)),a=i(40958),o=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,a.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=n.default.resolve(t,...e);if((0,s.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,o.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(o.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??n.default.resolve(...e))},t.execDir=(0,l.defer)((()=>n.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},46356:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.seemsLikeSymlinkLoop=void 0;const r=i(22454),s=i(28874),n=i(29882);t.seemsLikeSymlinkLoop=function(e){const t=new r.CountingSet;for(const i of(0,n.toPathnames)(e))t.incr(i.toLowerCase().normalize());return t.max()>s.Settings.maxDuplicatePathElements.valueOrDefault}},50274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),s=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,s.isBoolean)(e.isFile)&&(0,s.isBoolean)(e.isDirectory)}},17217:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const s=r(i(73024)),n=r(i(76760)),a=i(22573),o=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,a.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,a.blank)(e.nativePath))throw new Error(`toNativePath(${(0,o.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof s.default.Dirent?e.name:f(e)?e.base:n.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:n.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(n.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,o.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(s.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,o.blank)(e)?void 0:v(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function b(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function S(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=b(e),r=b(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],s=t[i],n=(0,u.diff)(S(r),S(s));if(null==n||n>1)return"unmatched "+i+": "+r+" ≠ "+s}}t.stat_=v,t.statMaybe=w,t.statToType=b,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const i=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await w(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,a.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const s=r(i(73024)),n=i(22573);function a(e){try{return(0,n.blank)(e)?void 0:s.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function o(e){return null==e||e.isFile()&&0===e.size}t.statSync=a,t.isEmptyStats=o,t.isFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=a(e);return t.emptyIsNew?null==i:o(i)},t.isNonEmptyFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===a(e)?.isDirectory()}},41080:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),s=i(56409);t.onDataChunked=function(e,t,i){const r=new n(t,i,!0);return r.read(e),r.done};class n{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new s.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=n},95705:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const s=r(i(57075)),n=i(41400),a=i(55835),o=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends s.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,n.delay)(50);try{(0,o.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,a.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends s.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const s=r(i(73024)),n=i(76760),a=i(22573),o=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,a.blank)(e))return!1;try{return s.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,o.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,a.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,a.notBlank)(t)){const e=(0,n.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,a.blank)(e)&&d((0,u.posix2native)(e))}},74128:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncReport=t.syncReport=t.recentSyncReports=t.ensureSyncReportReadme=t.syncReportReadme=t.syncReportDir=t.SyncReportHeaders=t.isRejectedState=t.SyncReportStates=t.SyncDirStates=t.FileDoneStates=t.SyncFileStates=t.AssetFileSyncStates=void 0;const p=i(51168),g=i(73024),y=i(4927),v=i(19851),w=i(40958),b=i(22573),S=i(42659),P=i(98553),_=i(31586),M=i(68708),T=i(50989),E=i(51926),k=i(85556),D=i(54993),x=i(89788),C=i(23467),F=i(7282),A=i(23560),I=i(77377),O=i(71567),L=i(73568),R=i(25764),N=i(38836),B=i(99331),j=i(12959),z=i(87290),V=i(46296),W=i(98314),U=i(38835),H=i(5012),q=i(32144),G=i(95696),$=i(36868),J=i(57902),K=i(28874),Y=i(84542),Z=i(73428);t.AssetFileSyncStates=(0,T.strEnum)("noop","deleted","skipped","synced","unknown"),t.SyncFileStates=(0,T.strEnum)(...t.AssetFileSyncStates.values,"canceled","rejected","failed","timeout","enqueued","started","copied","blocklisted","note"),t.FileDoneStates=(0,I.diff)(t.SyncFileStates.values,["enqueued","started","note"]),t.SyncDirStates=(0,T.strEnum)("scanning","canceled","failed","timeout","skipped","scanned"),t.SyncReportStates=(0,T.strEnum)(...t.SyncFileStates.values,...t.SyncDirStates.values),t.isRejectedState=function(e){return null==e||["canceled","deleted","failed","rejected","timeout","unknown"].includes(e)};const X={enqueued:"the file looks promising, and will be attempted to be imported soon.",rejected:"the file did not pass all import filters. The details column will explain why.",started:"the file was dequeued from the work queue, and is now going to be processed.",noop:"the current file metadata already matches your library database, so no operation was needed to sync this file.",deleted:"the file was determined to be deleted (the prior mountpoint exists, but the file doesn't exist anymore)",skipped:"the file lives on a volume that isn't currently mounted.",synced:"the file was imported.",blocklisted:"the file was blocklisted and files with the same SHA will not be imported in the future.",failed:"something went wrong. The details column will explain why.",timeout:"the file wasn't processed in a reasonable amount of time.",copied:'"automatic organization" is enabled (copyAssetsToLibrary=true), and the photo or video was copied into your library originals directory. The details column will contain the source file path.',note:"sidecars will be referenced here. The details column will specify which source file(s) it will be associated with.",canceled:"PhotoStructure was shut down while the file was processed.",unknown:"an internal error occurred during processing."},Q={scanning:"the directory contents are about to be read.",scanned:"the directory contents were completely processed.",skipped:"the directory was excluded. The details column will explain why.",canceled:"PhotoStructure was shut down before the directory was processed.",failed:"reading the directory contents failed.",timeout:"reading the directory contents took too long."};function ee(e){return(0,M.entries)(e).map((([e,t])=>` - "${e}": ${t}`)).join("\n")}const te=new Set([t.AssetFileSyncStates.deleted,t.SyncFileStates.failed,t.SyncFileStates.timeout,t.SyncDirStates.canceled]);function ie(){return(0,z.librarySyncReportsDir)()??G.PosixFile.for((0,V.logDir)()).join("sync-reports")}function re(){return ie().join("README.txt")}t.SyncReportHeaders=(0,T.strEnum)(...(0,M.keys)(new class{constructor(e,t,i,r,s,n,a,o,l={}){this.ts=e,this.at=t,this.path=i,this.state=r,this.from=s,this.elapsedMs=n,this.details=a,this.url=o,this.meta=l}}(0,"","","unknown","",0,"",""))),t.syncReportDir=ie,t.syncReportReadme=re,t.ensureSyncReportReadme=(0,v.lazy)((()=>(0,Z.writeTextfile_)(re().nativePath,(0,E.wrap)(`\n\nHowdy from PhotoStructure!\n\nThis directory contains your recent "sync reports". \n\nThese files are written as your scan paths are examined for photos and videos.\n\nPhotoStructure creates a new file when it restarts and when it completes importing a given scan path directory.\n\nThese CSV files can be opened with most spreadsheet applications, like LibreOffice.\n\n\nColumn descriptions\n===================\n\nThe "ts" column is the timestamp for the row, in millis from 1970-01-01. Most spreadsheet applications don’t know how to parse these values, though, so we also add the at column.\n\nThe "at" column is ts in ISO format with only second resolution, and should be parsable by most spreadsheet software.\n\nThe "path" column is the native path of the directory or file. It will be empty for messages about system state.\n\nThe "state" column explains why that row was added.\n\nThe "from" column specifies which codepath added the sync report row.\n\nThe "elapsedMs" column is only added to rows completing a given path, and records how long that process took.\n\nThe "details" column will include information about the path, like why a given file or folder were rejected.\n\nThe "url" column is only added to rows when a file or directory is imported. You may need to adjust the domain name of the URL to make it work correctly (it defaults to localhost).\n\n\nDirectory state values\n======================\n\nThe "state" column for directories will be\n\n${ee(Q)}\n\n\nFile state values\n=================\n\nThe "state" column for files will be\n\n${ee(X)}\n\n\nSee https://photostructure.com/go/sync-reports\n\n`,{maxLineLen:80}).join("\n")))),t.recentSyncReports=async function(e=S.dayMs){const t=Date.now()-e;return ie().descendants((async e=>(0,q.isCsvExt)(e)&&(0,_.gte)(e.mtimeMs(),t)))},t.syncReport=(0,v.lazy)((()=>new se));class se extends N.EndableWrapper{constructor(){super("fs.SyncReport()",(()=>f(this,r,"m",d).call(this)),R.EndableRanks.predb),r.add(this),s.set(this,void 0),n.set(this,void 0),a.set(this,void 0),o.set(this,0),l.set(this,0),this.outputFiles=new x.BoundedList(64),(0,t.ensureSyncReportReadme)()}get outputNativePath(){return f(this,s,"f")?.nativePath}get rowCount(){return f(this,l,"f")}onProgress(e){if(null==e||(0,b.blank)(e.state))return this.logger.error(".onProgress(): invalid input",{s:e,from:(0,H.stack)()});{this.logger.log(te.has(e.state)?J.LogLevels.warn:J.LogLevels.info,"onProgress()",e);const t=Date.now(),i={path:(0,D.toS)(e.path),state:e.state,details:(0,D.toS)(e.details).trim().replace(/\r?\n/g,"; ")},s={ts:t,at:new Date(t).toISOString(),...i,...(0,M.pick)(e,"from","elapsedMs","url")};(0,M.isEmptyObj)(e.meta)||(s.meta=(0,P.stringify)(e.meta)),(0,F.isTest)()&&process.stdout.write((0,P.stringify)(e)+Y.Newline),f(this,r,"m",u).call(this,s)}}maybeSystemData(e){(0,A.isSyncService)()&&this.onProgress(e)}async wrap_({path:e,from:i,fn_:r}){const s=Date.now();this.onProgress({path:e,from:i,state:t.SyncFileStates.started});try{const n=await r(),a=n.state??(null!=n.error?t.SyncFileStates.failed:t.SyncFileStates.unknown);return a===t.SyncFileStates.unknown&&this.logger.error(i+" returned result with no state!"+U.InternalErrorFlag,{path:e,result:n}),this.onProgress({path:e,from:i,elapsedMs:Date.now()-s,...n,state:a}),n}catch(r){throw this.logger.warn("wrap_() caught error",{error:r}),this.onProgress({path:e,from:i,state:(0,B.ending)()||r instanceof L.AbortError?t.SyncFileStates.canceled:r instanceof k.TimeoutError?t.SyncFileStates.timeout:t.SyncFileStates.failed,details:(0,B.ending)()?void 0:(0,W.errorToS)(r),elapsedMs:Date.now()-s}),r}}get output(){return f(this,n,"f")??f(this,r,"m",h).call(this)}async flushClose(){return f(this,r,"m",u).call(this),this.close()}async close(){this.logger.info("Closing sync report");const e=f(this,n,"f");return m(this,n,void 0,"f"),m(this,l,0,"f"),await(0,$.endStream)(e),null==e?void 0:f(this,s,"f")}}t.SyncReport=se,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,r=new WeakSet,u=function(e){var t;const i=f(this,a,"f");if(m(this,a,e,"f"),null!=e&&(0,C.eqlPicked)(e,i,"path","state","details"))return this.logger.debug("deduping row",e),void m(this,o,(t=f(this,o,"f"),t++,t),"f");null!=i&&(0===f(this,o,"f")?f(this,r,"m",c).call(this,i):(f(this,r,"m",c).call(this,{...i,details:(0,w.compactBlanks)([i.details,`(repeated ${f(this,o,"f")+1} times)`]).join(" ")}),m(this,o,0,"f")))},c=function(e){var i;const r=(0,y.unparse)([e],{header:!1,columns:t.SyncReportHeaders.values});this.output.write(r+Y.Newline,(e=>{null!=e&&this.logger.error("Failed to write",e)})),m(this,l,(i=f(this,l,"f"),++i),"f")>K.Settings.syncReportMaxRows.valueOrDefault&&this.close()},d=function(){return this.logger.info("sync report ended",{rowCount:f(this,l,"f"),outputFiles:this.outputFiles}),this.flushClose()},h=function(){return m(this,s,function(){const e=p.DateTime.now();return ie().join(e.toFormat("y-MM-dd"),(0,j.filestamp)()+"-sync-report.csv")}().ensureNewSync_({emptyIsNew:!1}),"f"),this.outputFiles.push(f(this,s,"f").nativePath),this.logger.info("Opening new report: "+f(this,s,"f")),(0,F.isTest)()&&(0,O.stdoutWrite)({syncReport:f(this,s,"f").nativePath},!1),m(this,n,(0,g.createWriteStream)(f(this,s,"f").nativePath),"f"),f(this,n,"f").write((0,y.unparse)([t.SyncReportHeaders.values],{header:!1})+Y.Newline),f(this,n,"f")}},89966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const s=r(i(48161)),n=i(19851),a=i(55835),o=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),h=i(8103),f=i(43899);function m(){return(0,a.map)(f.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,a.map)(m(),(e=>e.join(c.platformName+"-"+s.default.arch())))}async function g(e){if(c.isWin&&(e=(0,o.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,h.pathIfExists)(m()?.join("bin",e))),(()=>(0,h.pathIfExists)(m()?.join(e))),(()=>(0,h.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,h.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,n.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,n.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,n.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,n.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const s=r(i(44652)),n=i(19851),a=i(22573),o=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,o.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,a.blank)(t.file))throw new Error("can't touch blank path");const r=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const o=(0,n.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await o())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await o())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(s.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(n){if(!i||"ENOENT"!==n.code)throw n;await(0,c.thenOrTimeoutError)(s.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},79847:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.trashOrUnlinkFileUri=t.trashOrUnlinkFileUris_=void 0;const o=n(i(51455)),l=a(i(49378)),u=i(40958),c=i(22573),d=i(13538),h=i(83104),f=i(45255),m=i(31562),p=i(98314),g=i(34102),y=i(28874),v=i(45200),w=i(16287),b=i(74128),S=i(84258),P="fs.Trash";async function _(e){const t=Date.now(),i=y.Settings.commandTimeoutMs.valueOrDefault,r=(0,c.toNotBlank)(e.nativePath)??await(0,d.thenOrTimeout)((0,v.uri2nativePath)(e.uri,e.mountpoint),i);if((0,c.blank)(r)||r===h.Timeout)return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not convert URI to native path",path:e.uri,elapsedMs:Date.now()-t}),{uri:e.uri,unlinked:!1};const s=await(0,w.statMaybe)(r);if(null==s)return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: no such file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(!s.isFile())return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: not a file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(y.Settings.trySoftDeletes.valueOrDefault)try{if(await(0,d.thenOrTimeoutError)((0,l.default)(r,{glob:!1}),i),await function(e){return(0,m.untilTrue)((async()=>null==await(0,w.statMaybe)(e)),{timeoutMs:f.ShortCommandTimeoutMs})}(r))return(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Moved file to trash",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0};(0,S.logger)().warn("soft-delete("+r+") didn't seem to work: the file is still there?")}catch(e){(0,b.syncReport)().onProgress({from:P,state:"note",details:"Failed to soft-delete file to trash: "+(0,p.errorToS)(e),path:r,elapsedMs:Date.now()-t}),(0,S.logger)().warn("Tried to soft-delete, but that failed. We'll try to hard-delete.",{error:e})}try{return await(0,d.thenOrTimeoutError)(o.unlink(r),i),(0,g.ee)().emit("fileChanged",r),(0,S.logger)().info("unlink("+r+") successful"),(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Permanently deleted file",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0}}catch(i){return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not move file to trash or delete: "+(0,p.errorToS)(i),path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!1}}}t.trashOrUnlinkFileUris_=async function(e){const t=[];for(const{uri:i,mountpoint:r}of(0,u.uniqBy)(e,(e=>e.uri)))try{t.push(await _({uri:i,mountpoint:r}))}catch(e){t.push({uri:i,unlinked:!1,error:e})}return t},t.trashOrUnlinkFileUri=_},70854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryUidStore=t.LibraryUIDStore=t.SystemUIDStore=t.UIDStore=t.mkuid=void 0;const r=i(19851),s=i(41400),n=i(55835),a=i(92782),o=i(37805),l=i(46292),u=i(34102),c=i(55222),d=i(28874),h=i(87128),f=i(95696);function m(){return(0,a.safeRandomUid)({radix:c.TokenRadix,chars:24,splitEveryN:4})}t.mkuid=m;class p extends h.JsonFileStore{constructor(e,t){super(e.join("."+t+"-uid.json"),(()=>({uid:m(),version:o.version,type:this.type,createdAt:Date.now()})),(e=>e.hide())),this.rootDir=e,this.type=t,this.readUid_=(0,r.lazy)((async()=>(await this.read_())?.uid))}}function g(e=d.Settings.libraryDir.valueOrDefault){return(0,n.map)(f.PosixFile.forMaybe(e),(e=>new p(e,"library")))}t.UIDStore=p,t.SystemUIDStore=(0,r.lazy)((()=>(0,n.map)((0,l.configDir)(),(e=>new p(f.PosixFile.for(e),"system"))))),t.LibraryUIDStore=(0,r.lazy)(g),t.libraryUidStore=g,(0,s.later)((()=>{(0,u.ee)().on("clearCache",(()=>{t.SystemUIDStore.unset(),t.LibraryUIDStore.unset()})),d.Settings.libraryDir.watchLater((()=>t.LibraryUIDStore.unset()))}))},84258:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const a=n(i(51455)),o=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,o.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const r of(0,l.toA)(e))try{null!=r&&await a.unlink((0,c.toNativePath_)(r))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+r,{error:e})}}},5545:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const s=r(i(76760)),n=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,n.toS)(i.path??s.default.sep)}},70257:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),s=i(45255),n=i(17217);t.WipTimeoutMs=s.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const a=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(a,"")},t.isWip=function(e){return a.test((0,n.basename)(e)??"")}},58722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),s=i(22911);class n extends r.Writable{constructor(e){super(e),this.deferred=new s.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=n},73428:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(51926),o=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=n.default.dirname(e);await(0,c.mkdirp_)(i),await s.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=n.default.dirname(e);(0,c.mkdirpSync_)(i),s.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,a.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))}},13047:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const s=r(i(73024)),n=i(76760),a=i(46466),o=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await S(e,t)).toString()}async function b(e,t,i){const r=[],n=[s.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?n.push((0,o.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&n.push((0,o.createBrotliDecompress)().on("error",(e=>r.push(e)))),n.push(t),await(0,a.pipeline)(n),(0,u.isNotEmpty)(r))throw new f.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function S(e,t){const i=new y.WritableToBuffer;return await b(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await S(e))}async function _(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,n.parse)(e).dir),await(0,a.pipeline)(new g.ReadableBuffer(i),(0,o.createGzip)(),s.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=b,t.zCopyToBuffer_=S,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void v().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await _(e,t)}catch(t){v().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},60526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.exiftoolHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(98314),a=i(47783),o=i(63335),l=i(18454);t.exiftoolHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Tools",id:"tools-exiftool",ordinal:1,pendingMsg:"Checking ExifTool…",settings:[],later:async()=>{try{const e=await(0,a.exiftoolVersion_)();return{level:"ok",msg:["ExifTool is OK","ExifTool "+(0,o.ver)(e),(0,r.tt)((0,a.exiftool)().options.exiftoolPath)],meta:{exiftoolVersion:e}}}catch(e){return{level:"error",msg:"Something's amiss with ExifTool: "+(0,n.errorToS)(e)}}}})))},19652:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.externalDirectoryCheck=void 0;const a=i(51455),o=n(i(22915)),l=i(40958),u=i(82950),c=i(22573),d=i(45599),h=i(12168),f=i(50213),m=i(79960),p=i(32551),g=i(98314),y=(0,d.defer)((()=>(0,f.mkLogger)("health.externalDirectoryCheck")));t.externalDirectoryCheck=async function(){const e=(0,l.uniq)([(0,p.homeDir)(),o.getHomeFolder(),o.getPicturesFolder(),o.getVideosFolder(),o.getDesktopFolder(),await(0,m.defaultApplePhotosLibrary)()]).sort(),t=new Map,i=(0,l.uniq)(e.filter(c.notBlank)).sort();for(const e of i)try{await(0,a.readdir)(e,{withFileTypes:!0})}catch(i){if(["ENOTDIR","ENOENT"].includes(i?.code))continue;t.set(e,i)}const r=0===t.size?{level:"ok",msg:["Default media directories are OK","The following directories are readable:",(0,u.li)(i.map(u.tt))]}:{level:"warn",msg:["Error reading "+(0,h.plur)(t.size,"media directory")+":",(0,u.li)([...t.entries()].map((([e,t])=>(0,u.tt)(e)+":"+(0,g.errorToS)(t,{maxLen:80}))))]};return y().tap({msg:"externalDirectoryCheck",result:r})}},79483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.externalDirsHealthCheck=void 0;const r=i(45599),s=i(45969),n=i(19652),a=i(18454);t.externalDirsHealthCheck=(0,r.defer)((()=>(0,s.isDocker)()?void 0:a.HealthCheck.for({section:"System",id:"media-directories",pendingMsg:"Checking default photo directories…",settings:[],later:n.externalDirectoryCheck})))},63664:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRemoteOrLocalHealthSummarySync=t.getRemoteOrLocalHealthSummary=t.getLocalHealthSummary=t.getRemoteHealthSummary=void 0;const r=i(22573),s=i(45599),n=i(41400),a=i(50268),o=i(98553),l=i(50213),u=i(23560),c=i(45255),d=i(5916),h=i(28874),f=i(34238),m=i(51140),p=i(4988),g=i(18454),y=(0,s.defer)((()=>(0,l.mkLogger)("health.GetHealthSummary")));t.getRemoteHealthSummary=(0,d.lazyAsync)({later:async()=>{try{if((0,u.isWebService)())return;const e=await(0,p.get_)(f.URI.from({scheme:"http",authority:"127.0.0.1:"+h.Settings.httpPort.valueOrDefault,path:"/api/health"}),{timeoutMs:c.ShortCommandTimeoutMs}),t=(0,o.parseJSON_)(e.data);if(m.HttpStatusIs.ok(e.statusCode)&&(0,a.isHealthCheckSummary)(t))return"ready"===t.state&&(0,r.toNotBlank)(t.libraryDir)!==(0,r.toNotBlank)(h.Settings.libraryDir.valueOrDefault)&&(y().error("getHealthSummary(): libraryDir mismatch! Switching to that library directory...",{local:h.Settings.libraryDir.valueOrDefault,remote:t.libraryDir}),h.Settings.libraryDir.value=t.libraryDir),y().debug("getHealthSummary()",{response:e}),t;y().warn("getHealthSummary(): invalid response",{response:e})}catch(e){y().warn("Failed to get health check summary from web service",{error:e})}}}),t.getLocalHealthSummary=(0,d.lazyAsync)({later:()=>g.HealthCheck.awaitSettled()}),(0,n.later)((()=>{h.Settings.healthCheckIntervalMs.watch((e=>{t.getRemoteHealthSummary.setTTL(e),t.getLocalHealthSummary.setTTL(e)}))})),t.getRemoteOrLocalHealthSummary=async function(){return await(0,t.getRemoteHealthSummary)()??await(0,t.getLocalHealthSummary)()},t.getRemoteOrLocalHealthSummarySync=function(){return t.getRemoteHealthSummary.syncValue()??t.getLocalHealthSummary.syncValue()}},18454:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,v,w,b,S,P,_=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},M=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const T=i(19851),E=i(40958),k=i(76790),D=i(41400),x=i(50357),C=i(26905),F=i(50268),A=i(55835),I=i(68708),O=i(30976),L=i(51926),R=i(13538),N=i(42279),B=i(59455),j=i(54993),z=i(48884),V=i(89788),W=i(22454),U=i(50213),H=i(69591),q=i(22911),G=i(99331),$=i(5916),J=i(42638),K=i(77740),Y=i(98314),Z=i(70025),X=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),re=i(21525),se=i(82638),ne=(0,T.lazy)((()=>(0,U.mkLogger)("health.HealthCheck")));class ae{static traceLater_(e,t){const i=new q.Deferred(e);i.catch((t=>{_(this,s,"f",l).push(e+": failed: "+(0,Y.errorToS)(t)),this.onResultChange()})),_(this,s,"m",o).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return _(this,s,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){_(this,s,"f",l).push((0,L.isString)(e)?e:(0,Y.errorToS)(e)),this.onResultChange()}static lastErrors(){return _(this,s,"f",l).toA()}static addLoadingMsg(e){_(this,s,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,E.compact)((0,B.toA)(e)).map(j.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return ne().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:_(this,s,"f",h).entriesByCountDesc()}),(0,A.map)((0,z.leastBy)(e,(e=>[_(this,s,"f",h).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=_(this,s,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,A.map)(e,(e=>_(this,s,"f",h).incr(e.msg))),ne().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return X.Settings.skipHealthCheckIds.envValue=t,s.reset()}static findById(e){return _(this,s,"f",f).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,F.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=_(this,s,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=s.summary();if(e.pendingCount>0){const t=await Promise.all(s.testResultsCritical());e=s.summaryFromResults(t),ne().info("awaitSettled(): summary result",{summary:e,results:t})}return ne().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){s.summary.unset()}static reset(){if((0,G.ending)())ne().warn("Rejecting reset() when ending()",(0,C.shortStack)());else{this.onResultChange(),_(this,s,"f",l).clear(),_(this,s,"f",d).clear(),_(this,s,"f",h).clear(),_(this,s,"f",c).clear(),this.summary.clear(),M(this,s,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new s(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return _(this,s,"f",f).push(i),this.all.unset(),i}constructor(e,t,i,n,o,l,u,c,d,h,f,m,S,P=Q.commandTimeoutMs){r.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=n,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=h,this.errorLinks=f,this.onReset=m,this.ttlMs=S,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),w.set(this,(0,T.lazy)((async()=>{await _(this,p,"f").prior(),(0,x.eql)(_(this,g,"f"),_(this,r,"m",v).call(this))||(this.onReset?.(),await this.refresh(),_(this,w,"f").unset())}))),this.refresh=(0,T.lazy)((()=>new q.Deferred("refresh").observe((async()=>{await _(this,p,"f").prior();const e=_(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,U.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[F.HealthCheckSections.ordinal(this.section),l??999,this.id],M(this,p,(0,$.lazyAsync)({desc:this.pendingMsg,later:()=>_(s,s,"f",a).enqueue({name:this.id,l:()=>_(this,r,"m",b).call(this,o)}),ttlMs:S}),"f"),this.isCritical&&_(this,p,"f").watchLater({onChange:s.onCriticalResult,onError:s.onCriticalResult});for(const e of this.settings)X.Settings[e].watchLater((()=>_(this,w,"f").call(this)))}isStale(){return _(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return _(this,p,"f").settledCount()}reset(){return _(this,p,"f").unset(),this.onReset?.(),M(this,g,{starting:!0},"f"),this}setTTL(e){_(this,p,"f").setTTL(e)}result(){return _(this,p,"f").call(this)}isSkipped(){return X.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return _(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return _(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??_(this,r,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function oe(e){if((0,E.isEmpty)(e))return{};const[t,i]=(0,z.partition)(e,(e=>"button"===e.type||"POST"===e.method)),r={};return(0,E.isNotEmpty)(i)&&(r.links=(0,E.uniqBy)(i)),(0,E.isNotEmpty)(t)&&(r.buttons=(0,E.uniqBy)(t)),r}t.HealthCheck=ae,s=ae,p=new WeakMap,g=new WeakMap,y=new WeakMap,w=new WeakMap,r=new WeakSet,o=function(){return(0,E.filterInPlace)(_(this,s,"f",n),(e=>!e.isPending)),_(this,s,"f",n)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=ne().tap({level:"warn",msg:"#summary()",result:(0,se.summarizeHealthChecksSync)({errors:_(this,s,"f",l),skipPending:_(this,s,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&M(this,s,!0,"f",u),i.state!==_(this,s,"f",c).last?.state&&_(this,s,"f",c).push({state:i.state,ts:Date.now()}),i},v=function(){return(0,I.fromEntries)(this.settings.map((e=>[e,X.Settings[e].valueOrDefault])))},b=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();ne().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,C.shortStack)()}),M(this,g,_(this,r,"m",v).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,D.delay)((0,O.randomInt)(.3*i,.7*i)),this.isSkipped())return _(this,r,"m",S).call(this,{test:{level:"disabled",msg:["Disabled by "+X.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const s=await(0,R.thenOrTimeoutError)(e(),i);return _(this,r,"m",S).call(this,{test:s,elapsedMs:Date.now()-t})}catch(e){return _(this,r,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},S=function({test:e,src:t="#toResult",elapsedMs:i}){var r,n;const a=s.normalizeMsg(e.msg),o=e.level??((0,j.toS)(a).toLowerCase().includes("error")?"error":(0,j.toS)(a).toLowerCase().includes("warn")?"warn":"ok"),l=(0,E.compact)([...e?.links??("ok"===o||"pending"===o?this.okLinks:"warn"===o?this.warnLinks:"no-library"===o?this.noLibraryLinks:"error"===o?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:o,msg:a,elapsedMs:i,...oe(l)};return u.runCount=(M(this,y,(n=_(this,y,"f"),r=n++,n),"f"),r),(0,G.ending)()?u:this.logger.tap({level:re.HealthCheckLevelToLogLevel[o],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const s=(0,L.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,A.map)(e,Y.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,Z.isFatalError)(e)&&s.toLowerCase().includes("warn")?"warn":"error"),_(this,r,"m",S).call(this,{test:{msg:s,level:t},src:"#toErrorResult",elapsedMs:i})},n={value:[]},a={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},h={value:new W.CountingSet},f={value:[]},ae.all=(0,T.lazy)((()=>Object.freeze((0,k.sortBy)(_(s,s,"f",f),(e=>e.sortBy))))),ae.onCriticalResult=(0,H.debounce)((()=>{ne().info("onCriticalResult()",s.summary.refresh())}),250),ae.summary=(0,T.lazy)((()=>_(s,s,"m",m).call(s))),ae.resetDebounced=(0,H.debounce)((()=>s.reset()),50)},33866:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const r=i(82950),s=i(50268),n=i(459),a=i(23560),o=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,a.isPermaService)(t)&&(e===s.HealthCheckLevels.error||(0,a.isLibraryRequiredService)(t)&&e===s.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,o.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,r.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new n.UnreachableCaseError(e)}}},88625:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.healthCheckSetup=t.testHealthCheck=void 0;const r=i(19851),s=i(82950),n=i(45599),a=i(50268),o=i(50213),l=i(7282),u=i(44198),c=i(34102),d=i(2858),h=i(60526),f=i(79483),m=i(18454),p=i(39214),g=i(86403),y=i(42482),v=i(35675),w=i(89035),b=i(31974),S=i(20752),P=i(85200),_=i(37301),M=i(65756),T=i(15024),E=i(3956),k=i(29332),D=i(61274),x=i(38372),C=i(49913),F=i(84728),A=i(7245),I=i(16264),O=(0,n.defer)((()=>(0,o.mkLogger)("health.HealthCheckSetup")));t.testHealthCheck=(0,n.defer)((()=>m.HealthCheck.for({section:"System",id:"test-health-check",ordinal:0,settings:[],pendingMsg:"Test check…",later:async()=>{const e=a.HealthCheckLevels.validOrElse((0,u.env)().PS_TEST_HEALTH_CHECK_LEVEL,a.HealthCheckLevels.ok);return{level:e,msg:[`Test health check: ${e.toUpperCase()}`,`These are ${(0,s.b)("details")}:`,(0,s.li)("alpha",(0,s.tt)("bravo"),"charlie")]}}}))),t.healthCheckSetup=(0,r.lazy)((()=>{(0,h.exiftoolHealthCheck)(),(0,p.heifHealthCheck)(),(0,y.libraryDirectoriesCheck)(),(0,v.libraryFreeSpaceCheck)(),(0,E.settingsEnvHealthCheck)(),(0,D.settingsSystemHealthCheck)(),(0,k.settingsLibraryHealthCheck)(),(0,f.externalDirsHealthCheck)(),(0,w.memoryHealthCheck)(),(0,b.nodejsHealthCheck)(),(0,S.notInDMGHealthCheck)(),(0,P.osHealthCheck)(),(0,_.powershellHealthCheck)(),(0,x.sharpHealthCheck)(),(0,g.jpegtranHealthCheck)(),(0,T.securityHealthCheck)(),(0,M.sqliteHealthCheck)(),(0,C.systemLoadHealthCheck)(),(0,A.videoHealthCheck)(),(0,I.volumeHealthCheck)(),(0,F.versionHealthCheck)(),(0,l.isProd)()||(0,t.testHealthCheck)();let e=(0,d.libraryHasSettings)();d.libraryHasSettings.watchLater((t=>{null!=t&&e!==t&&(O().info("libraryHasSettings changed. Resetting health checks.",{newValue:t}),e=t,m.HealthCheck.resetDebounced())}));for(const e of["volumesChanged","mountpointsChanged","error"])(0,c.ee)().on(e,(()=>{O().debug("Clearing health check cache",{event:e}),m.HealthCheck.resetDebounced()}));(0,c.ee)().on("fatal",(e=>m.HealthCheck.addError(e)))}))},39214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heifHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(41400),a=i(55835),o=i(34102),l=i(277),u=i(45969),c=i(63335),d=i(18454);t.heifHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-heif",pendingMsg:"Checking HEIF/HEIC tooling…",settings:["heifConvertPath"],links:[{text:"Read how to set up HEIF support with PhotoStructure",url:"https://photostructure.com/getting-started/heif-support/",icon:"docs"}],warnLinks:(0,u.isDocker)()?[]:[{text:"Re-check for HEIF tooling",icon:"refresh",method:"POST",type:"button",url:"/admin/recheck-tools"}],later:async()=>{const e=await(0,l.getHeifSupportDetails)();return null!=e&&!1!==e.isSupportedVersion?{level:"ok",msg:["HEIF images will be imported",(0,a.map)(e.version,c.ver),(0,a.map)(e.path,r.tt)]}:{level:"warn",msg:["HEIF images will not be imported","No HEIF tooling was found."]}}}))),(0,n.later)((()=>{(0,o.ee)().on("clearToolCache",(()=>t.heifHealthCheck.prior()?.reset()))}))},86403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.testJpegtran_=t.jpegtranHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(55835),a=i(98314),o=i(89966),l=i(51210),u=i(76280),c=i(63335),d=i(18454);async function h(){const e=await(0,o.jpegtranNativePath_)(),t=await(0,l.jpegtranVersion_)();return{nativePath:e,version:t,satisfies:(0,u.semverSatisfies)(t,">=1.5")}}t.jpegtranHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-jpegtran",ordinal:2,pendingMsg:"Checking "+(0,r.tt)("jpegtran")+"…",settings:[],later:async()=>{try{const e=await h();return{level:"ok",msg:["jpegtran is OK",(0,n.map)(e.version,c.ver),(0,n.map)(e.nativePath,r.tt)]}}catch(e){return{level:"error",msg:["Something's amiss with jpegtran",(0,a.errorToS)(e)]}}}}))),t.testJpegtran_=h},42495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const r=i(40958),s=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,r.compact)([(0,s.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},42482:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryDirectoriesCheck=void 0;const r=i(82950),s=i(42659),n=i(45599),a=i(98553),o=i(31586),l=i(94174),u=i(87290),c=i(98314),d=i(29882),h=i(45969),f=i(43334),m=i(28874),p=i(2858),g=i(59107),y=i(18454),v=i(42495);async function w(){const e=await(0,u.setupLibraryDirs_)();return(0,p.libraryHasSettings)()?{level:"ok",msg:["Library directories are OK","Verified directory permissions for the following directories:",(0,r.li)(...e.map((e=>(0,r.tt)(e))))]}:{level:"no-library",msg:["Your PhotoStructure library hasn't been set up yet"]}}t.libraryDirectoriesCheck=(0,n.defer)((()=>y.HealthCheck.for({section:"Library",id:"library-directories",ordinal:0,pendingMsg:"Checking library directories…",settings:["libraryDir","originalsDir","previewsDir","cacheDir"],ttlMs:s.minuteMs,links:[{text:'What\'s a "PhotoStructure library?"',icon:"docs",url:"https://photostructure.com/faq/library/"},...(0,h.isDocker)()?[{text:"Read how to setup up Docker",icon:"docs",url:"https://photostructure.com/server/photostructure-for-docker/"}]:[]],okLinks:[{type:"button",text:"Run library maintenance jobs",url:"/admin/run-maintenance",method:"POST",icon:"handyman"}],later:async()=>(await(0,p.readSettings)(),(0,h.isDocker)()?async function(){const e=(0,u.libraryDirPosixFile)();if(null==e)return{level:"error",msg:[`Something's amiss: ${(0,r.tt)("PS_LIBRARY_DIR")} is blank`,`The default is ${(0,r.tt)(m.Settings.libraryDir.toEnvLine(m.Settings.libraryDir.defaultValue))}`]};const t=await(0,g.mountpoints_)(),i=(0,d.bestMountpointForDir)(e,t);if(null==i||"/"===i)return{level:"warn",msg:[e.nativePath+" is not a bind-mount",`Your library directory, ${(0,r.tt)(e)}, does not seem to be a bind mount.`,"Your library contents will disappear when you shut down this container."],links:[v.DockerVolumeLink]};try{if(!await e.isReadWriteExecutable_()){const t=await e.stat(),i=[`Your library directory, ${(0,r.tt)(e)}, is not read/write${f.isWin?"":"/execute"} by ${await(0,l.userDesc)()}`];return null!=t&&(0,o.gte0)(t.uid)&&i.push("The owner of this directory is userid "+(0,r.tt)(t.uid)+", groupid "+(0,r.tt)(t.gid)),{level:"error",msg:[...i,"Please fix the permissions for this bind mount and restart the container."],links:[v.DockerVolumeLink]}}return await w()}catch(t){return{level:"error",msg:[`Your library directory, ${(0,r.tt)(e)}, can't be set up for ${await(0,l.userDesc)()}.`,(0,c.errorToS)(t,{maxLen:80}),"Please fix the permissions for this bind mount and restart the container."],links:[v.DockerVolumeLink]}}}():async function(){const e=(0,u.libraryDirPosixFile)();if(null==e)return{level:"no-library",msg:["No PhotoStructure library is open",(0,a.stringify)(m.Settings.libraryDir.getState())]};if(!(0,p.libraryHasSettings)())return{level:"no-library",msg:["No PhotoStructure library is open",m.Settings.libraryDir.hasValue()?(0,r.tt)(m.Settings.libraryDir.toEnvLine()):void 0]};try{return await e.isReadWriteExecutable_()?await w():{level:"no-library",msg:[`Your library directory, ${(0,r.tt)(e)}, is not read/write${f.isWin?"":"/execute"} by ${await(0,l.userDesc)()}`,"Please fix the permissions or pick a new library directory."]}}catch(t){return{level:"no-library",msg:[`Your library directory, ${(0,r.tt)(e)}, can't be set up for ${await(0,l.userDesc)()}`,(0,c.errorToS)(t,{maxLen:80}),"Please fix the permissions for this bind mount and restart the container."]}}}())})))},35675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFreeSpaceCheck=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(31586),l=i(68708),u=i(12168),c=i(87290),d=i(77740),h=i(28874),f=i(7014),m=i(18454);t.libraryFreeSpaceCheck=(0,a.defer)((()=>(0,l.tap)(m.HealthCheck.for({section:"Library",id:"library-free-space",settings:["libraryDir","minDiskFreeGb","originalsDir","previewsDir","cacheDir"],pendingMsg:"Checking free space on library volume(s)…",ttlMs:n.dayMs,later:async()=>{if(!(0,o.gt0)(h.Settings.minDiskFreeGb.valueOrDefault))return{level:"disabled",msg:`Library disk free test disabled: ${(0,s.tt)(h.Settings.minDiskFreeGb.key+"=0")}`};const e=(0,c.libraryDirPosixFile)();if(null==e)return{level:"disabled",msg:"Library disk free test disabled: no library is open"};if(!0!==await e.isDirectory())return{level:"disabled",msg:`Library disk free test disabled: ${(0,s.tt)(e)} is not a directory`};const t=[];for(const e of await(0,c.setupLibraryDirs_)()){const i=await(0,f.bestVolumeForPath)(e);if(null==i)return{level:"warn",msg:`Could not check for minimum disk free: no volume found for library path ${(0,s.tt)(e)}`};let r=t.find((e=>e.vol.mountpoint===i.mountpoint));null==r&&(r={vol:i,paths:[]},t.push(r)),r.paths.push(e.nativePath)}const i=h.Settings.minDiskFreeGb.valueOrDefault*u.GB,n=[];for(const{vol:e,paths:a}of t){const t=(0,s.b)(`Volume ${(0,s.tt)(e.mountpoint)} has ${(0,u.fmtBytes)(e.available)} free.`)+`\nThis volume is used for these PhotoStructure directories:\n${(0,s.li)((0,r.uniq)(a).sort().map(s.tt))}`;if(e.available{for(const t of["minDiskFreeGb","libraryDir","originalsDir","configDir"])h.Settings[t].watchLater((()=>e.reset()))}))))},89035:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const s=r(i(48161)),n=i(19851),a=i(82950),o=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),h=i(23560),f=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:r}){return{level:i,msg:[e+" from "+(0,h.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,a.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(r,2)])]}}function g(){return s.default.totalmem()f.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(f.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*f.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,n.lazy)((()=>"ok"!==g().level),o.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:o.minuteMs,later:async()=>g()})))},31974:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.nodejsHealthCheck=void 0;const s=r(i(1708)),n=i(82950),a=i(45599),o=i(26033),l=i(63335),u=i(18454);t.nodejsHealthCheck=(0,a.defer)((()=>u.HealthCheck.for({section:"Tools",id:"nodejs-version",ordinal:4,pendingMsg:"Checking Node.js…",settings:[],links:[{text:"Read about PhotoStructure NodeJS support",icon:"docs",url:"https://photostructure.com/server/photostructure-for-node/#prerequisites"}],later:async()=>{const e="You're running Node.js "+(0,l.ver)(s.default.versions.node)+".\nPhotoStructure requires "+(0,n.tt)(o.RequiredNodeRange)+".";return(0,o.isSupportedNode)()?{level:"ok",msg:["Node.js is OK",e]}:{level:"warn",msg:["Node.js is not a supported version",e]}}})))},20752:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notInDMGHealthCheck=void 0;const r=i(45599),s=i(43899),n=i(43334),a=i(18454);t.notInDMGHealthCheck=(0,r.defer)((()=>n.isMac&&n.isElectron?a.HealthCheck.for({section:"System",id:"proc-not-in-dmg",pendingMsg:"Checking PhotoStructure installation directory…",settings:[],later:async()=>s.ProjectPath.isInDMG()?{level:"error",msg:"PhotoStructure cannot run directly from a DMG disk image. Please drag and drop the PhotoStructure icon onto your Applications folder to install.",checkboxLabel:"Open https://photostructure.com/getting-started/installation/ in your browser"}:{level:"ok",msg:"PhotoStructure isn't running directly from a DMG disk image"}}):void 0))},85200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osHealthCheck=void 0;const r=i(45599),s=i(96175),n=i(18454);t.osHealthCheck=(0,r.defer)((()=>n.HealthCheck.for({section:"System",id:"system-version",pendingMsg:"Checking operating system…",settings:[],links:[{text:"What do I need to run PhotoStructure?",icon:"docs",url:"https://forum.photostructure.com/t/what-do-i-need-to-run-photostructure/44"}],later:async()=>{const e=(0,s.whyOsNotSupported)();return null==e?{level:"ok",msg:["Operating system is OK","PhotoStructure supports "+(0,s.osFullName)()]}:{level:"warn",msg:["Operating system is not supported",(0,s.osFullName)()+" was detected, but only "+e+"."]}}})))},37301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.powershellHealthCheck=void 0;const r=i(42659),s=i(45599),n=i(98314),a=i(43334),o=i(24399),l=i(63335),u=i(18454);t.powershellHealthCheck=(0,s.defer)((()=>a.isWin?u.HealthCheck.for({section:"Tools",id:"tools-powershell",pendingMsg:"Checking PowerShell…",settings:["powerShellArgs"],ttlMs:r.minuteMs,links:[{text:"How to fix PowerShell issues",url:"https://photostructure.com/fix-pwsh/"}],later:async()=>{try{const e=await(0,o.checkPowerShell_)();return{level:"ok",msg:["PowerShell is OK",(0,l.ver)(e)],meta:{version:e}}}catch(e){return{level:"error",msg:"PowerShell failed: "+(0,n.errorToS)(e)}}}}):void 0))},65756:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(27180),a=i(98314),o=i(63335),l=i(18454);t.sqliteHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Tools",id:"tools-sqlite-version",ordinal:0,pendingMsg:"Checking SQLite…",settings:[],links:[{text:"Read about PhotoStructure SQLite support",url:"https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837",icon:"docs"}],async later(){try{const e=await n.sqliteVersion_.refresh();return null==e?{level:"error",msg:"SQLite version could not be found"}:{level:"ok",msg:["SQLite is OK",(0,r.li)(["embedded: "+(0,o.ver)(e.libraryVersion),(0,r.tt)(e.sqliteNativePath)+": "+(0,o.ver)(e.toolVersion)])]}}catch(e){return{level:"error",msg:"Something's amiss with SQLite: "+(0,a.errorToS)(e)}}}})))},15024:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.securityHealthCheck=void 0;const r=i(40958),s=i(82950),n=i(45599),a=i(31586),o=i(94174),l=i(77740),u=i(44198),c=i(59958),d=i(43334),h=i(18454);t.securityHealthCheck=(0,n.defer)((()=>{const e=d.isWin?"an administrator":"root";return h.HealthCheck.for({section:"System",id:"proc-not-superuser",pendingMsg:"Checking user permission level…",settings:[],later:async()=>{if("0"===(0,u.env)().PUID)return{level:"disabled",msg:`Admin health check is disabled (${(0,s.tt)("PUID=0")}).`};const t=(0,r.compact)([(0,a.gte0)((0,o.userid)())?"Current user id: "+(0,s.b)((0,s.tt)((0,o.userid)())):void 0,(0,a.gte0)((0,o.groupid)())?"Current group id: "+(0,s.b)((0,s.tt)((0,o.groupid)())):void 0,"Current user name: "+(0,s.b)((0,s.tt)(await(0,o.username)()??"(unknown)"))]);return!0===await(0,o.isRootUser)()||(0,l.getDevEnvFlag)(c.DevEnvFlags.PS_FAIL_SECURITY_HEALTH_CHECK)?{level:"warn",msg:["PhotoStructure should not be run as "+e,...t],links:[{text:"Read why PhotoStructure should not be run as "+e,url:"https://photostructure.com/server/photostructure-for-docker/#why-not-run-as-root"}]}:{msg:["PhotoStructure is not running as "+e,...t],level:"ok"}}})}))},3956:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsEnvHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(12168),a=i(28874),o=i(63225),l=i(18454);t.settingsEnvHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Library",id:"settings-env",pendingMsg:"Checking environment settings…",settings:[],links:[{text:"Read about PhotoStructure environment settings",url:"https://photostructure.com/faq/environment-variables/",icon:"docs"}],later:async()=>{const e=[];for(const t of(0,a.allSettings)())if(t.hasValue()&&null!=t._envValue()){const i=!0===t.opts.sensitive?"********":t.toEnvValue(t._envValue());null!=i&&e.push((0,r.tt)(t.key+"="+i))}const t=[(0,n.plur)(e.length,"environment setting"),(0,r.li)(e)],i=(0,o.verifyPsEnvSettings)();return i.length>0?{level:"warn",msg:["Some environment settings may be misconfigured:",(0,r.li)(i.map((e=>(0,r.tt)(e.envKey)+": "+e.msg))),"---",...t]}:{level:"ok",msg:t}}})))},29332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsLibraryHealthCheck=void 0;const r=i(45599),s=i(2858),n=i(18454),a=i(61274);t.settingsLibraryHealthCheck=(0,r.defer)((()=>n.HealthCheck.for({section:"Library",id:"settings-library",pendingMsg:"Checking library settings…",settings:["libraryDir"],links:[{text:"Read about PhotoStructure library settings",url:"https://photostructure.com/getting-started/advanced-settings/#library-settings",icon:"docs"}],later:()=>(0,a.validateSettingsToml)((0,s.librarySettingsFile)(),"library")})))},61274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsSystemHealthCheck=t.validateSettingsToml=void 0;const r=i(40958),s=i(82950),n=i(45599),a=i(12168),o=i(81168),l=i(98314),u=i(95696),c=i(2858),d=i(32707),h=i(18454);async function f(e,t){try{if(null==e)return{level:"disabled",msg:"No "+t+" settings is set."};if(await e.notExists())return{level:"disabled",msg:(0,o.capitalize)(t)+" settings file "+(0,s.tt)(e)+" does not exist."};const i=await(0,c.importFileSettings_)(e);return(0,r.isNotEmpty)(i.warnings)?{level:"warn",msg:(0,s.tt)(e)+": "+i.warnings.join(", ")}:{level:"ok",msg:[(0,a.plur)(i.settings.length,t+" setting override"),(0,s.b)("Source:"),(0,s.tt)(e),(0,s.b)("Settings:"),(0,s.li)(i.settings.map((e=>(0,s.tt)(e.key+"="+e.toEnvValue(e.value)))))]}}catch(t){return{level:"error",msg:"Failed to parse "+e+":\n"+(0,l.errorToS)(t)}}}t.validateSettingsToml=f,t.settingsSystemHealthCheck=(0,n.defer)((()=>h.HealthCheck.for({section:"Library",id:"settings-system",pendingMsg:"Checking system settings…",settings:[],links:[{text:"Read about PhotoStructure system settings",url:"https://photostructure.com/getting-started/advanced-settings/#system-settings",icon:"docs"}],later:()=>f(u.PosixFile.forMaybe((0,d.systemSettingsFile)()),"system")})))},38372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpHealthCheck=void 0;const r=i(45599),s=i(98314),n=i(21473),a=i(18454);t.sharpHealthCheck=(0,r.defer)((()=>a.HealthCheck.for({section:"Tools",id:"tools-sharp",ordinal:2,pendingMsg:"Checking Sharp…",settings:[],later:async()=>{try{return await(0,n.testSharp_)(),{level:"ok",msg:["Sharp is OK","Image processing is working as expected."]}}catch(e){return{level:"error",msg:["Something's amiss with Sharp",(0,s.errorToS)(e)]}}}})))},82638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const r=i(40958),s=i(42659),n=i(45599),a=i(41400),o=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),h=i(23560),f=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,n.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function v({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:r}){const s=new Map;for(const e of t??[])s.set(e.id,e);if(null!=e)for await(const t of f.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),r))s.set(t.id,t);return[...s.values()]}t.summarizeHealthChecks=async function(e){return b({...e,healthCheckResults:await v(e)})};const w=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:h.serviceName.prior()??process.title}})));function b(e){const t=(0,r.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),n=i.length,a=i.map((e=>e.id)),c=t.length-n,d=0===n,h=(0,r.uniq)((0,r.compactBlanks)(e.errors));if(h.length>0)return{...w(),level:l.HealthCheckLevels.error,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",h.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const s=t.filter((e=>e.level===i));if((0,r.isNotEmpty)(s)){const e=t.filter((e=>!s.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+s.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...w(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:a,pendingCount:n,settledCount:c,linkIds:s.map((e=>e.id)),ts:Date.now(),msg:(0,r.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,o.flatten)([...s,...e].map((e=>e.msg[0])))])},meta:{checks:s.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...w(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,s.fmtDateShort)(Date.now())]}})}(0,a.later)((()=>{m.Settings.libraryDir.watchLater((()=>w.unset()))})),t.summarizeHealthChecksSync=b},49913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemLoadHealthCheck=void 0;const r=i(82950),s=i(42659),n=i(45599),a=i(31586),o=i(28874),l=i(14854),u=i(18454);t.systemLoadHealthCheck=(0,n.defer)((()=>u.HealthCheck.for({section:"System",id:"system-load",pendingMsg:"Checking system load…",settings:["cpuBusyPercent"],ttlMs:s.minuteMs,later:async()=>{if(o.Settings.cpuBusyPercent.valueOrDefault<=0)return{level:"ok",msg:["CPU utilization is not monitored",(0,r.tt)(o.Settings.cpuBusyPercent.key)+" is set to <= 0"]};const e=l.CpuUsage.instance().busyPct(),i=(0,l.isTooBusy)();return(0,t.systemLoadHealthCheck)().setTTL((i?6:60)*s.secondMs),{level:i?"stop-sync":"ok",msg:"CPU utilization is "+(0,a.fmtPct)(e)+"\n"+(i?"PhotoStructure sync is paused until CPU utilization drops below":"PhotoStructure sync will pause if CPU utilization exceeds")+" "+(0,r.tt)(o.Settings.cpuBusyPercent.key)+": "+(0,a.fmtPct)(o.Settings.cpuBusyPercent.valueOrDefault)}}})))},84728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionHealthCheck=void 0;const r=i(42659),s=i(45599),n=i(40044),a=i(18454);t.versionHealthCheck=(0,s.defer)((()=>a.HealthCheck.for({section:"System",id:"ps-version",pendingMsg:"Checking PhotoStructure version…",settings:["autoUpdateCheck","configDir","libraryDir","optOut"],ttlMs:r.hourMs,links:[{text:"Change auto-update setting",icon:"settings",url:"/settings#update-check-section"},{text:"What's new?",icon:"docs",url:"https://photostructure.com/whats-new/"},{text:"Update checking & privacy",icon:"docs",url:"https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956"}],later:n.checkVersion_})))},7245:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.videoHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(41400),a=i(55835),o=i(34102),l=i(66106),u=i(45969),c=i(63335),d=i(18454);t.videoHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-video",pendingMsg:"Checking video tooling…",settings:["ffmpegPath"],links:[{text:"Read how to set up video support with PhotoStructure",url:"https://photostructure.com/getting-started/video-support/",icon:"docs"}],warnLinks:(0,u.isDocker)()?[]:[{text:"Re-check for video tooling",icon:"refresh",method:"POST",type:"button",url:"/admin/recheck-tools"}],later:async()=>{const e=await(0,l.getVideoToolDetails_)();return null!=e&&!1!==e.isSupportedVersion?{level:"ok",msg:["Videos will be imported",(0,a.map)(e.version,c.ver),(0,a.map)(e.path,r.tt)]}:{level:"warn",msg:["Videos will not be imported","No video tooling was found."]}}}))),(0,n.later)((()=>{(0,o.ee)().on("clearToolCache",(()=>t.videoHealthCheck.prior()?.reset()))}))},16264:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeHealthCheck=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(13538),l=i(83104),u=i(12168),c=i(48884),d=i(45255),h=i(43334),f=i(69108),m=i(48165),p=i(63870),g=i(7014),y=i(18454);t.volumeHealthCheck=(0,a.defer)((()=>y.HealthCheck.for({section:"System",id:"system-volumes",ordinal:0,pendingMsg:"Checking volumes…",settings:[],links:[{text:"What's a “volume”?",url:"https://photostructure.com/faq/what-is-a-volume/",icon:"docs"}],warnLinks:h.isWin?[{text:"Check this page for troubleshooting tips",url:"https://photostructure.com/faq/windows-troubleshooting/#unhealthy-network-shares"}]:void 0,later:async()=>{const e=Date.now(),i=await(0,o.thenOrTimeout)((0,g.volumes)(),(0,p.commandTimeoutMs)());if(i===l.Timeout){const i=await(0,o.thenOrTimeout)(h.isWin?(0,m.getLocalVolumesWin_)():(0,f.dfPosixRawLocal_)(),d.ShortCommandTimeoutMs);return(0,t.volumeHealthCheck)().logger.warn("volumes() timed out, retrying in 5m"),setTimeout((()=>(0,t.volumeHealthCheck)().refresh()),5*n.minuteMs),{level:"warn",msg:[i===l.Timeout?"Something seems wrong with your computer's volumes":"Something seems wrong with one or more remote filesystem mounts","Gathering volume metadata took longer than "+(0,n.fmtAgo)(e,"")+"."]}}const a=i.filter((e=>!1===e.ok));if((0,r.isNotEmpty)(a))return{level:"warn",msg:["One or more volumes are not healthy","Check the following:",(0,s.li)(a.map((e=>(0,s.tt)(e.mountpoint))))]};const[y,v]=(0,c.partition)(i,(e=>!0===e.remote)),w=["Storage volumes are OK"];return(0,r.isNotEmpty)(v)&&w.push((0,s.b)((0,u.plur)(v.length,"local volume")+":"),(0,s.li)(...v.map((e=>(0,s.tt)(e.mountpoint))))),(0,r.isNotEmpty)(y)&&w.push((0,s.b)((0,u.plur)(y.length,"remote volume")+":"),(0,s.li)(...y.map((e=>(0,s.tt)(e.mountpoint))))),{level:"ok",msg:w}}})))},95242:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviewBuilder=t.mkPreviewAssetFile_=void 0;const a=i(57975),o=i(40958),l=i(22573),u=i(33374),c=i(98553),d=i(55835),h=i(68708),f=i(48884),m=i(50213),p=i(92434),g=i(54296),y=i(51837),v=i(57159),w=i(83278),b=i(95696),S=i(62105),P=i(84258),_=i(38156),M=i(69589),T=i(28874),E=i(47783),k=i(29990),D=i(16047),x=i(42725),C=i(4192),F=i(32876),A=i(50961),I=i(181);t.mkPreviewAssetFile_=async function(e){const t=await(0,E.readTags)(e);return{nativePath:e.nativePath,fileSize:await e.size(),mtime:await e.thisOrSidecareMaxMtimeMs(),uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath,mimetype:t.mimetype,rotation:t.rotation,...t.dimensions,sha:await e.sha_()}};class O{constructor(e,t,i){r.add(this),this.ap=e,this.assetFiles=t,this.logger=(0,m.mkLogger)("AssetPreviewBuilder("+e.assetId+")"),this.ctx=(0,M.forceContextOrSetting)(i),this.assetFiles=(0,p.sortAssetFiles)(this.assetFiles)}[(r=new WeakSet,a.inspect.custom)](){return{ctor:"AssetPreviewBuilder",assetId:this.ap.assetId,assetFiles:this.assetFiles}}async build_(){this.logger.info("build_(): asset file candidates:",this.assetFiles.map((e=>(0,h.pick)(e,"id","uri"))));const e=[];for(const t of this.assetFiles){const i=b.PosixFile.forMaybe(await(0,g.getAssetFileNativePath)(t));if(null!=i){{const e=await(0,S.whyRejectFile)(i);(0,l.blank)(e)||this.logger.info("skipping: rejected",{pf:i,whyRejected:e})}try{return await n(this,r,"m",s).call(this,i,t)}catch(i){e.push(i),this.logger.warn("Failed to set shown file to ",{best:t,error:i})}finally{this.ap.parent.clear()}}else this.logger.info("skipping: failed to get PosixFile",{af:t}),e.push(new Error("Cannot get path from URI "+(0,c.stringify)((0,h.pick)(t,"uri","mountpoint","nativePath"))))}return this.logger.throw("Cannot build previews: none of the files are valid",{doNotSend:!0,retriable:!1,files:this.assetFiles.map((e=>e.nativePath??e.uri)),causes:e})}async infoForBest_(e,t){await(0,I.throwIfInvalidFile_)(e);const i=await e.size(),r=await e.thisOrSidecareMaxMtimeMs();if(this.logger.debug("_build",{filesize:i,mtime:r,best:t.uri}),null==i||null==r)return this.logger.throw("build(): missing stat info for best file",{ignorable:!0,best:t});const{uri:s,width:n,height:a,sha:l,mimetype:u}=t;if(null==s||null==n||null==a||null==u||null==l)return this.logger.throw("build(): internal error: missing fields for best file "+e,{ignorable:!0,best:t});const c=(0,k.fitSizes)(t,t.mimetype);return{assetId:t.assetId,assetFileId:t.id,uri:s,uris:this.assetFiles.map((e=>e.uri)),path:e.nativePath,mtime:r,filesize:i,width:n,height:a,sha:l,mimetype:u,fitSizes:c.map((([,e])=>e.name)).join(","),sqWidths:(0,o.compact)(x.ImageSize.sq().map((e=>e.outputSize(t)?.width))),fitWidths:c.map((([e])=>e.width))}}async priorIfValid_(e,t){if(this.ctx.forceSync||this.ctx.forceRebuildPreviews)return;const i=await this.ap.readInfo.refresh();if(null!=i){if(i.assetId!==t.assetId)throw new y.InternalError("priorIfValid_(): mismatched asset IDs for "+e+": "+(0,c.stringify)({priorInfo:i,info:t}));const r=i.fitSizes.split(","),s=t.fitSizes.split(",");if(null!=i.sha&&i.sha===t.sha&&i.rotation===t.rotation&&(0,k.equivalentFitSizes)(r,s)){const n=(0,k.fitSizes)(e,e.mimetype),a=(0,o.diff)(r,s);if((0,o.isNotEmpty)(a)){this.logger.info("priorIfValid_(): removing previews that aren't required anymore.",{leftovers:a});for(const e of a){const t=n.find((([,t])=>t.name===e));if(null==t)this.logger.warn("priorIfValid_(): Failed to clean up: missing fit size",{fitsize:t,fits:n});else{const e=this.ap.fileForWidth(t[1].reducer.name,t[0].width);this.logger.debug("priorIfValid_(): unlinking unwanted preview "+e,{fitsize:t}),await e.unlink("warn")}}}return this.logger.debug("priorIfValid_(): SHA and rotation match, and previews exist.",{info:t,priorInfo:i}),await this.ap.writeInfo(t),t}}}}t.AssetPreviewBuilder=O,s=async function(e,t){this.logger.info("_build("+e+")",{uri:t.uri});const i=await this.infoForBest_(e,t),r=await this.priorIfValid_(t,i);if(null!=r)return r;const s=new _.PushProgressObserver({path:e.nativePath,op:"Building previews"},x.ImageSize.sq().length+x.ImageSize.fit().length);if(this.logger.debug("Rebuilding all previews from "+t.uri,{assetId:t.assetId,info:i}),null==await this.ap.parent.mkdirp())throw new Error("build(): Failed to create previews directory, "+this.ap.parent+" for "+t);const n=await this.ap.existingFiles(),a=await(0,A.sharpReadable_)({src:e,minDim:x.ImageSize.largestFit().max});if(null==a)throw new v.WrappedError("AssetPreviewBuilder.build(): "+t.uri+", "+e.nativePath+", is not readable by sharp.",{retriable:!1});const o=(0,A.toSharp)(a);if(t.mimetype.startsWith("image/")&&!(0,D.isHeifMimeType)(t.mimetype)&&null!=t.rotation&&0!==t.rotation&&(o.rotate(t.rotation),this.logger.debug("build(): rotating "+t.rotation+"°")),(0,w.isBaseFile)(a)&&a.desc.toLowerCase().includes("thumbnail"))try{o.trim(1)}catch{}const l=(0,k.fitSizes)(t,t.mimetype),c=[],m=[];let p,g;const y=x.ImageSize.largestSq(),b=(0,f.leastBy)(l,(([e,t])=>(0,d.map)(y.outputSize(e),(()=>t.megapixels()))))?.[1].name,S=(0,h.pick)(t,"width","height");{let e=o.clone(),t=S;for(const[i,r]of l){const n=Date.now(),a=t,o=this.ap.fileForWidth(r.reducer.name,i.width).wip();e=r.resize(i,e),t=i,r.name===b&&(g=e.clone(),p=i),(0,u.dmegapixels)(i)>=1&&r.reducer===F.Fit&&T.Settings.includePreviewTags.valueOrDefault&&m.push(o),await r.toJpeg({path:o.nativePath,sh:e,outputSize:i}),s.onProgress(),this.logger.debug("resize("+r.name+") "+(0,u.fmtDim)(a)+" -> "+(0,u.fmtDim)(i)+" in "+(Date.now()-n)+" ms"),c.push(o)}}{null==g?(this.logger.debug("square resize(): resorting to ",{origDim:S,bestFitNameForSq:b}),g=o,p=S):this.logger.debug("square resize(): using to ",{sqDim:p,bestFitNameForSq:b});let e=!1;for(const t of x.ImageSize.sq()){const i=Date.now(),r=p,n=t.outputSize(p??S);if(null==n){this.logger.debug("skipping square output for "+t.max);continue}e||(n.position=T.Settings.squareThumbStrategy.valueOrDefault,e=!0),this.logger.debug("Applying ",{outputSize:n});const a=this.ap.fileForWidth(t.reducer.name,n.width).wip();t.resize(n,g),p=n,await t.toJpeg({path:a.nativePath,sh:g,outputSize:n}),s.onProgress(),c.push(a),this.logger.debug("resize("+t.name+") "+(0,u.fmtDim)(r)+" -> "+(0,u.fmtDim)(n)+" in "+(Date.now()-i)+" ms")}}try{await(0,C.includePreviewTags_)(e,m).catch((t=>{this.logger.warn("Failed to restore metadata tags into previews for "+e,{error:t})}));const t=new Set(n.map((e=>e.nativePath)));for(const e of c){const i=await e.unwip_();t.delete(i.nativePath)}await(0,P.unlink)(t),await this.ap.writeInfo(i),this.logger.debug("Previews unwipped and info written",{info:i})}catch(t){throw await(0,P.unlink)(c),new v.WrappedError("Failed to create previews from "+e,{cause:t,path:e.nativePath,fatal:!1})}return i}},35721:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkDownloadableTitle=t.previewToDownloadable=t.extractPreviewInfo=void 0;const r=i(75761),s=i(33374),n=i(11371),a=i(55835),o=i(31586),l=i(56519),u=i(29882),c=i(50213),d=i(97352),h=i(81168),f=i(89782),m=(0,c.mkLogger)("extractPreviewInfo");function p(e,t,i,r){return`Download ${t} ${e.ext} ${i} (${(0,s.fmtDim)(r)})`}t.extractPreviewInfo=function(e,t){const i=t.posixPathFrom(e).replace(/\//g,"").split("-"),r=(0,o.toInt)(i[0]),s=n.ReducerNames.getCI(i[1]),a=(0,d.extractInt)(i[2]);return(0,o.gt0)(r)?{file:t,assetId:r,reducer:s,width:a}:void m.warn("Failed to extract preview info",{file:t,previewsRoot:e,arr:i,assetId:r,reducer:s,width:a})},t.previewToDownloadable=async function(e,t){return(0,a.map2)(t.assetId,t.width,((i,a)=>(0,l.thenMap)((0,f.dimensions)(t.file),(o=>{const l=(0,s.dimToSize)(o);return{size:l,basename:`${(0,h.stripSuffix)(e,(0,u.extname)(e))}-${l}${t.file.ext}`,title:p(t.file,l,"image",o),description:`Download ${l}`,details:`(${(0,s.fmtDim)(o)} ${t.file.ext})`,href:(0,r.assetImgLink)({assetId:i,reducer:n.ReducerNames.fit,width:a})}}))))},t.mkDownloadableTitle=p},16524:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviews=void 0;const a=i(19851),o=i(40958),l=i(75761),u=i(11371),c=i(68708),d=i(39926),h=i(58939),f=i(48884),m=i(50213),p=i(81168),g=i(56519),y=i(38835),v=i(70417),w=i(35721);t.AssetPreviews=class{constructor(e,t){r.add(this),this.previewsRoot=e,this.readInfo=(0,a.lazy)((()=>this.infoJson().readJson("debug"))),this.logger=(0,m.mkLogger)("AssetPreviews(assetId:"+(0,h.id2id)(t)+")"),this.assetId=(0,h.id2id)(t);const i=(0,d.leftPad)(this.assetId,8,"0"),s=(0,p.splitEvery)(i,3);this.basename=s.pop()+"-",this.parent=e.join(...s)}parentNotExists(){return this.parent.clear().notExists()}async existingFiles(){return await this.parent.clear().childFiles((e=>e.base.startsWith(this.basename)))??[]}async existingJpgs(){return(await this.existingFiles()).filter((e=>".jpg"===e.ext))}async previewInfos(){return(0,g.sortByAsync)({name:"img.AssetPreviews.previews",arr:n(this,r,"m",s).call(this),f:e=>e?.file.size()})}async deleteAll(){const e=await this.existingFiles();if(e.length>20)throw new Error("deleteAll(): rejected: > 20 existing files?!"+y.InternalErrorFlag);for(const t of e)await t.unlink();return e}fileForSuffix(e){return this.parent.join(this.basename+e)}mp4(){return this.fileForSuffix("video.mp4")}infoJson(){return this.fileForSuffix("info.json")}writeInfo(e){return this.readInfo.unset(),this.infoJson().writeJson((0,c.pick)(e,"assetId","assetFileId","uri","uris","path","mimetype","width","height","mtime","filesize","sha","rotation","fitSizes","fitWidths"))}fileForWidth(e,t){return this.fileForSuffix(e+"-w"+t+".jpg")}async filesForReducer(e){const t=this.basename+e+"-";return this.logger.tap({msg:"filesForReducer("+e+")",result:(await this.existingFiles()).filter((e=>e.base.startsWith(t)))})}async smallestFileForReducer(e){return(0,f.leastBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async largestFileForReducer(e){return(0,f.greatestBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async widths(e){const t=await this.readInfo(),i=e===u.ReducerNames.sq?"sqWidths":"fitWidths",r=t?.[i];if(!(0,o.isEmpty)(r))return r;const s=(0,o.compact)((await this.previewInfos()).filter((t=>t.reducer===e)).map((e=>e.width)));return null!=t&&(t[i]=s,await this.writeInfo(t)),s}async posterLink(){const e=await this.widths(u.ReducerNames.fit);return(0,l.assetImgLink)({assetId:this.assetId,reducer:u.ReducerNames.fit,width:(0,v.max)(e)})}async imgAttrs(e,t=!1,i=!0){if(t||e!==u.ReducerNames.sq){const t=e===u.ReducerNames.fit?await this.readInfo():void 0;return(0,l.assetImgAttrs)({assetId:this.assetId,reducer:e,widths:await this.widths(e),lazyLoad:i,af:t})}return(0,l.assetSqImgAttrs)({assetId:this.assetId,lazyLoad:i})}},r=new WeakSet,s=async function(){const e=[];for(const t of await this.existingFiles()){const i=(0,w.extractPreviewInfo)(this.previewsRoot,t);null!=i&&e.push(i)}return e}},52086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},33106:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.dctPixels=t.dctHashCIELAB=t.dctHash=void 0;const s=r(i(9288)),n=i(96249),a=i(85810),o=32,l=function(e){const t=new Array(32);for(let e=1;e<32;e++)t[e]=1;return t[0]=1/Math.sqrt(2),t}(),u=function(e){const t=new Array(32);for(let e=0;e<32;e++){t[e]=new Array(32);for(let i=0;i<32;i++)t[e][i]=Math.cos((2*e+1)/64*i*Math.PI)}return t}();function c(e){const t=new Array(o);for(let i=0;is?1:0);return n}t.dctHash=async function(e){return c(await e.greyscale().resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer())},t.dctHashCIELAB=async function(e){const t=await e.resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer(),i=(0,a.rgb2labArray)(t);return(0,n.flatten)(i.map(c))},t.dctPixels=c},86580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(21605),o=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,n.gt0)(e.width)&&(0,n.gt0)(e.height)?(0,n.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,s.dmegapixels)(e.dimensions):(0,n.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,n.lt)(e.width,t.width)&&(0,n.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,n.lte)(e?.width,t?.width)&&(0,n.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,n.lt)(e.width,t.width)||(0,n.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,r.compact)((0,o.toS)(e).split(/[x×]/).map((e=>(0,n.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,r=Math.round(Math.sqrt(t*i));return{width:r,height:Math.round(r/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const r=u(e,i);return null==r?[]:a.Rotations.filter((e=>u(c(t,e),i)===r))}},89782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(56519),o=i(1078),l=i(5733),u=(0,r.lazy)((()=>(0,n.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,s.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,a.thenMap)((0,o.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},29990:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.equivalentFitSizes=t.fitSizes=void 0;const r=i(40958),s=i(33374),n=i(16170),a=i(42725),o=[a.ImageSize.QVGA,a.ImageSize.QQVGA];function l(e){return"qhd"===e?"wvga":"uhd"===e?"uhd4k":e}t.fitSizes=function(e,t){const i=a.ImageSize.fit(),r=[];let l=(0,n.isMimeTypeSupportedByBrowser)(t)?e:void 0;for(let t=0;t3||(0,s.dmegapixels)(a)-(0,s.dmegapixels)(l)>2.5)&&(l=a,r.push([a,n])))}return r},t.equivalentFitSizes=function(e,t){return(0,r.includesAll)((0,r.compactBlanks)(e).map(l),(0,r.compactBlanks)(t).map(l))}},277:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const r=i(22573),s=i(41400),n=i(54993),a=i(19851),o=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),h=i(78330),f=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),v=(0,a.lazy)((()=>(0,o.mkLogger)("img.Heif")));function w(e){return(0,n.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function b(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,a.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,r.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){v().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,r.blank)(e))return void v().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=w(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,r.blank)(i)&&(0,l.hasApt)()){const t=await(0,h.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,r.blank)(i)&&(0,f.hasPacman)()&&(i=(await(0,f.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,r.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void v().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=w,t.isHeifSupported=b,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await b()?(0,g.heif2png_)(e):void v().throw("HEIF support is missing",{src:e.nativePath})},(0,s.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(41400),o=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),h=i(28874),f=i(89782),m=i(13940),p=(0,r.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,s.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,r.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:h.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?n.minuteMs:void 0),e})),(0,a.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,f.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(h.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:h.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(o.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const r=i(22573),s=i(54993),n=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,r.blank)(e)&&n.test((0,s.toS)(e))}},13940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),s=i(19851),n=i(42659),a=i(59455),o=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),v=i(55222),w=i(63870),b=(0,s.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,s.lazy)((()=>(S(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const S=(0,s.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const s=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const n=s.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await n.mkdirp_(),await n.utimes();const a=n.join(i+r);return b().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:a}),a}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,a.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+v.TokenRadix.randomChars(2),v.TokenRadix.randomChars(16)+(0,o.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*n.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const s=await P(e,t,i);return await s.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,w.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),s}catch(r){return b().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},48368:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashDim=t.toImageHash=t.isImageHash=t._imageHash_=t.imageHash_=t.imageHash=t.maxPerBits=void 0;const s=r(i(9288)),n=i(19851),a=i(40958),o=i(22573),l=i(42659),u=i(33374),c=i(56038),d=i(85810),h=i(76490),f=i(40401),m=i(86758),p=i(85434),g=i(96706),y=i(38835),v=i(88561),w=i(95696),b=i(17217),S=i(50213),P=i(23624),_=i(28874),M=i(12089),T=i(16170),E=i(1078),k=i(33106),D=i(86580),x=i(78011),C=i(50961);t.maxPerBits=function(e){return Math.floor(52/e)};const F=(0,n.lazy)((()=>(0,S.mkLogger)("img.ImageHash")));t.imageHash=async function(e){try{return await(0,t.imageHash_)((0,b.toNativePath_)(e))}catch(t){return void F().warn("imageHash() failed for "+e,t)}};const A=(0,n.lazy)((()=>new v.FileCache({name:"img.imageHash",timeoutMs:l.minuteMs})));async function I(e){const t=w.PosixFile.for(e),i=await(0,E.extractSizeInfoFromFile)(t);if(null==i)throw new Error("Failed to read dimensions for "+e+y.NonFatalErrorFlag+y.DoNotSendErrorFlag);const r=(0,D.fitToResolution)(i.dimensions,Math.round(_.Settings.dominantColorPixels.valueOrDefault)),n=await(0,C.sharpReadable_)({src:t,minDim:r});return(0,c.time)("img.imageHash",(()=>async function({file:e,readable:t,sizeInfo:i}){const r=(0,S.mkLogger)("ImageHash("+e+")");if(null==t)return r.throw("Cannot build readable stream");const n=(0,D.fitToResolution)(i.dimensions,_.Settings.dominantColorPixels.valueOrDefault);if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-orig.jpg";await(0,C.toSharp)(t).jpeg().toFile(i),console.log({out:i,readable:t})}let a=(0,C.toSharp)(t).removeAlpha();(0,T.isVideoMimeType)(t.mimetype)||(a=a.rotate(i.rotation)),(0,u.dmegapixels)(i.dimensions)<.1&&(a=a.trim({background:"#000",threshold:0})),a=a.resize({fit:s.default.fit.outside,...n,withoutEnlargement:!0});const{data:o,info:l}=await a.raw().toBuffer({resolveWithObject:!0});if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-"+l.width+"w.jpg";await(0,s.default)(o,{raw:{...l,channels:3}}).jpeg().toFile(i),console.log({out:i,rgbInfo:l,readable:t})}const c=(0,d.rgb2labTriplets)(o),h=(0,f.extractDominantColors)(c),p=(0,m.labsAreGreyscale)(c),y=()=>(0,s.default)(o,{raw:{...l,channels:3}}),v=await(p?x.meanDiffHash:x.meanDiffHashCIELAB)(y()),w=await(p?k.dctHash:k.dctHashCIELAB)(y());return{meanHash:(0,P.b64encodeBits)(v.meanHash),diffHash:(0,P.b64encodeBits)(v.diffHash),dctHash:(0,P.b64encodeBits)(w),dominantColors:h.dominantColors,dominantColorsDescription:h.description,dominantColorScore:h.dominantColorScore,isGreyscale:p,mimetype:(0,T.normalizeMimetype)(t.mimetype),...i.dimensions,rotation:i.rotation??0}}({file:t,readable:n,sizeInfo:i})))}function O(e){return null!=e&&(0,o.notBlank)(e.meanHash)&&(0,o.notBlank)(e.mimetype)&&(0,a.isNotEmpty)(e.dominantColors)}t.imageHash_=(0,M.shim1)({name:"img.imageHash",cache:A,impl:I}),t._imageHash_=I,t.isImageHash=O,t.toImageHash=function(e){if(null!=e){if(O(e))return e;if((0,p.isModeData)(e)){const t={...(0,p.omitModeData)(e),dominantColors:h.DominantColor.fromModeData(e)};if(O(t))return t}}},t.HashDim=8},80361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageHashSimilarity=t.isVerySimilarComparison=t.isVerySimilarImageHash=t.isSimilarImageHash=t.isVerySimilarImage=t.compareImageHashes=t.isSimilarImage=t.hammRatio=t.meanHashVariants=t.isGreyscaleMeanHash=t.labsCorr2=t.isImageHashComparison=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(38639),o=i(33374),l=i(57924),u=i(55835),c=i(31586),d=i(68708),h=i(39926),f=i(21605),m=i(48884),p=i(50213),g=i(97352),y=i(85810),v=i(3048),w=i(32848),b=i(82647),S=i(38812),P=i(70417),_=i(23624),M=i(28874),T=i(86580),E=i(48368),k=i(2090),D=(0,r.lazy)((()=>(0,p.mkLogger)("img.ImageHashComparison")));t.isImageHashComparison=function(e){return null!=e&&(0,E.isImageHash)(e.a)&&(0,E.isImageHash)(e.b)&&[e.imageCorr,e.colorCorr,e.aRotation].every(c.isNumber)},t.labsCorr2=function(e,t){const i=(0,s.sum)(e,(e=>(0,v.diffCIECorr)(e,(0,y.closestLab)(t,e))))+(0,s.sum)(t,(t=>(0,v.diffCIECorr)(t,(0,y.closestLab)(e,t)))),r=Math.max(e.length,t.length,i);return(r-i)/r};const x=/A{20}=?$/;function C(e){return null!=e&&((0,g.within)(7,12,e.length)||null!=e?.match(x))}function F(e,t,i=E.HashDim){const r=(0,_.b64decode)(e).toString(2).split("").map((e=>"1"===e?1:0)),s=i*i;for(;r.length%s!=0;)r.unshift(0);return r.length===s||t?r.slice(0,s):r.slice(0,s).map(((e,t)=>4*e+2*r[t+s]+r[t+2*s]))}function A({a:e,b:t,greyscale:i,dim:r=E.HashDim,rotationsToCheck:a}){if((0,n.blank)(e)||(0,n.blank)(t))return{hammRatio:0,bRotation:0};if(e===t)return{hammRatio:1,bRotation:0};const o=F(e,i,r),l=F(t,i,r);(0,s.isEmpty)(a)&&(a=[0]);const u=a.map((e=>({bRotation:e,hammRatio:(0,c.sigFigs)((0,g.hammRatioIntArrays)(o,(0,S.rotateSquareMatrix)(l,e),i?1:3),2)})));D().debug("hammRatio()",{results:u,rotationsToCheck:a});const d=(0,m.greatestBy)(u,(e=>[(0,c.sigFigs)(e.hammRatio,1),-f.Rotations.indexOf(e.bRotation)]));return{bRotation:d.bRotation,hammRatio:(0,c.sigFigs)(d.hammRatio,2)}}async function I(e,t,i="debug",r={}){return D().tap({msg:`isSimilarImage(${e},${t})`,level:i,result:L(await(0,E.imageHash)(e),await(0,E.imageHash)(t),r)})}function O(e,t,i={}){const r=(0,E.toImageHash)(e),s=(0,E.toImageHash)(t);if(null==r||null==s)return;const n=(0,a.isTrue)(i.capturedAtIsFuzzy),h=!(0,a.isTrue)(i.forceColor)&&((0,a.isTrue)(i.forceGreyscale)||(r.isGreyscale??C(r.meanHash))||(s.isGreyscale??C(s.meanHash))),f=A({a:r.meanHash,b:s.meanHash,greyscale:h,rotationsToCheck:i.rotationsToCheck??(0,T.validRotations)(r,s)}),m=A({a:r.diffHash,b:s.diffHash,greyscale:h,rotationsToCheck:[]}),p=A({a:r.dctHash,b:s.dctHash,greyscale:h,rotationsToCheck:[]}),g=(0,w.dominantColorCorrelation)(r.dominantColors,s.dominantColors);if(null==g)return void D().debug("imageHashCompare(): missing color correlation");const y=r.mimetype===s.mimetype,v=(0,T.aspectRatio)(r),S=(0,T.aspectRatio)((0,o.maybeDimSwap)(s,f.bRotation)),P=null!=v&&null!=S&&!(0,o.isCloseAspectRatio)(v,S);let _=0,x=0;n&&(x+=M.Settings.imageHashFuzzyDateDelta.valueOrDefault,_+=M.Settings.imageHashFuzzyDateDelta.valueOrDefault),y||(x+=M.Settings.imageHashDifferentMimetypesDelta.valueOrDefault,_+=M.Settings.imageHashDifferentMimetypesDelta.valueOrDefault),h&&(_+=M.Settings.imageHashGreyscaleDelta.valueOrDefault,x+=M.Settings.imageHashGreyscaleDelta.valueOrDefault);const F=R((_+(i.minImageCorr??M.Settings.minImageCoeffPct.valueOrDefault))/100),I=R((x+(i.minColorCorr??M.Settings.minColorCoeffPct.valueOrDefault))/100),O=[];P&&O.push(`aspect ratio mismatch (${(0,k.fmtAspectRatio)(v)} vs ${(0,k.fmtAspectRatio)(S)})`);const L=[],N=new b.Average;N.push(f.hammRatio),f.hammRatioN.push(e))),(0,u.map)(p?.hammRatio,(e=>N.push(e))),(0,c.lt)(m?.hammRatio,F)&&L.push("gradient"),(0,c.lt)(p?.hammRatio,F)&&L.push("DCT")),L.length>0&&O.push("different image content ("+(0,l.andList)(L)+")");const j=g>=I,z=j&&N.avg>=F;j||O.push("different dominant colors");const V={meanHashCorr:(0,c.sigFigs)(f.hammRatio,2),diffHashCorr:B?void 0:(0,u.map)(m,(e=>(0,c.sigFigs)(e.hammRatio,2))),dctHashCorr:B?void 0:(0,u.map)(p,(e=>(0,c.sigFigs)(e.hammRatio,2))),hashCorrAvg:N.avg,minImageCorr:F,imageCoeffDelta:_,colorCorr:(0,c.sigFigs)(g,2),minColorCorr:I,colorCoeffDelta:x,isGreyscale:h,bRotation:f.bRotation,aAspectRatio:v,bAspectRatio:S,isSimilar:z,whyNotSimilar:z?void 0:(0,l.andList)(O)};return D().info("compareImageHashes",{a:(0,d.pickCompact)(r,"uri","id","assetId"),b:(0,d.pickCompact)(s,"uri","id","assetId"),...V}),{a:r,b:s,...V}}function L(e,t,i){return O(e,t,i)?.isSimilar??!1}function R(e){return(0,c.sigFigs)((0,c.clamp)(0,1,e),3)}function N(e){return null!=e&&(0,c.gte)(e.meanHashCorr,.9)&&(0,c.gte)(e.colorCorr,.9)}t.isGreyscaleMeanHash=C,t.meanHashVariants=function(e,t=!1,i=E.HashDim){const r=(t=t||null!=e.match(x))?(0,h.padding)("0",2*i*i):"",s=F(e,t,i);return f.Rotations.map((e=>(0,_.b64encode)(BigInt("0b0"+(0,S.rotateSquareMatrix)(s,e).map((e=>e.toString(2))).join("")+r))))},t.hammRatio=A,t.isSimilarImage=I,t.compareImageHashes=O,t.isVerySimilarImage=async function(e,t,i="debug",r={}){return I(e,t,i,{rotationsToCheck:[0],...r,minImageCorr:.92,minColorCorr:.92})},t.isSimilarImageHash=L,t.isVerySimilarImageHash=function(e,t,i={}){return N(O(e,t,i))},t.isVerySimilarComparison=N,t.imageHashSimilarity=function(e,t){return(0,u.map)(O(e,t),(e=>(0,P.avg)([e.meanHashCorr,e.colorCorr])))}},42725:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ImageSize=void 0;const a=i(57975),o=i(19851),l=i(33374),u=i(12168),c=i(48884),d=i(28874),h=i(32876),f=i(5733);class m{static sq(){return n(this,r,"f",s).filter((e=>e.reducer===h.Square))}static largestSq(){return(0,c.greatestBy)(this.sq(),(e=>e.megapixels()))}static fit(){const e=d.Settings.previewResolutions.valueOrDefault;return n(this,r,"f",s).filter((t=>t.reducer===h.Fit&&e.includes(t.name)))}static largestFit(){return(0,c.greatestBy)(this.fit(),(e=>e.megapixels()))}static all(){return[...n(this,r,"f",s)]}constructor(e,t,i,a,l=!0){this.name=e,this.maxWidth=t,this.maxHeight=i,this.reducer=a,this.rotational=l,this.megapixels=(0,o.lazy)((()=>(0,u.megapixels)(this.maxWidth*this.maxHeight))),this.max={width:t,height:i},n(r,r,"f",s).push(this)}[a.inspect.custom](){return{ctor:"ImageSize",name:this.name+" ("+this.reducer.name+")",maxDim:this.maxWidth+"×"+this.maxHeight,maxMP:this.megapixels()}}get aspectRatio(){return this.maxWidth/this.maxHeight}get maxPixels(){return this.maxWidth*this.maxHeight}get minDimension(){return Math.min(this.maxWidth,this.maxHeight)}outputSize(e){return this.reducer.reduce(this.rotational&&(0,l.isPortrait)(e)?(0,l.dimSwap)(this.max):this.max,e)}resize(e,t){return t.resize({...e,fit:this.reducer.fit,withoutEnlargement:!0})}toJpeg({path:e,sh:t,outputSize:i}){return((0,l.dmegapixels)(i)<2||d.Settings.previewSharpen.valueOrDefault)&&(t=t.sharpen()),t.jpeg((0,f.sharpRenderOptions)()).toFile(e)}toString(){return this.name}}t.ImageSize=m,r=m,s={value:[]},m.UHD8k=new r("uhd8k",7680,4320,h.Fit,!1),m.UHD5k=new r("uhd5k",5120,2880,h.Fit,!1),m.UHD=new r("uhd4k",4096,2160,h.Fit),m.QHD=new r("qhd",3120,1440,h.Fit),m.FHD=new r("fhd",1920,1080,h.Fit),m.HD=new r("hd",1280,720,h.Fit),m.WVGA=new r("wvga",720,480,h.Fit),m.QVGA=new r("qvga",320,240,h.Fit),m.QQVGA=new r("qqvga",160,120,h.Fit),m.S480=new r("s480",480,480,h.Square),m.S240=new r("s240",240,240,h.Square),m.S120=new r("s120",120,120,h.Square),m.S60=new r("s60",60,60,h.Square)},4192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includePreviewTags_=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(50213),o=i(56038),l=i(28874),u=i(47783),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.includePreviewTags")));t.includePreviewTags_=async function(e,t){!1===l.Settings.includePreviewTags.valueOrDefault||l.Settings.includedPreviewTags.isEmpty()||(0,s.isEmpty)(t)||(c().info("Re-adding metadata to previews..."),await(0,o.time)("img.includePreviewTags",(async()=>{const i=(0,n.pick)(await(0,u.readTags)(e),...l.Settings.includedPreviewTags.values),r=i?.capturedAt;null!=r&&(delete i.capturedAt,(0,n.assignFields)(i,r.asExifTag()));const s=i?.exposureSettings;null!=s&&(delete i.exposureSettings,i.FocalLength=s.focalLength,i.FNumber=s.aperture,i.ExposureTime=s.shutterSpeed,i.ISO=s.iso),l.Settings.includedPreviewTags.has("Source")&&(i.Source=e.nativePath),(0,n.isEmptyObj)(i)?c().warn("not adding tags to previews: no values for tags in source file",{src:e,includedPreviewTags:l.Settings.includedPreviewTags.values}):(c().info("Overwriting preview tags...",{src:e,writeTags:i}),await Promise.all(t.map((e=>(0,u.overwriteTags_)(e,i)))))})))}},78011:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.meanDiffHashCIELAB=t.meanDiffHash=t.dhash=t.mhash=void 0;const s=r(i(9288)),n=i(96249),a=i(59455),o=i(85810),l=i(70417),u=i(48368);function c(e){const t=(0,l.avg)(e);return null==t?[]:(0,a.toA)(e).map((e=>e>=t?1:0))}function d(e){const t=(0,a.toA)(e),i=Math.round(Math.sqrt(t.length));return t.map(((t,r)=>t>=(0===r?e[i]:r%i==0?e[r-i]:e[r-1])?1:0))}t.mhash=c,t.dhash=d,t.meanDiffHash=async function(e,t=u.HashDim){const i=await e.greyscale().resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer();return{meanHash:c(i),diffHash:d(i)}},t.meanDiffHashCIELAB=async function(e,t=u.HashDim){const i=await e.resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer(),r=(0,o.rgb2labArray)(i);return{meanHash:(0,n.flatten)(r.map(c)),diffHash:(0,n.flatten)(r.map(d))}}},48604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildAssetPreviews_=t.Previews=void 0;const r=i(19851),s=i(55835),n=i(50213),a=i(12089),o=i(87290),l=i(95242),u=i(16524);class c{constructor(e){this.root=e}apb(e,t,i){return new l.AssetPreviewBuilder(this.ap(e),t,i)}ap(e){return new u.AssetPreviews(this.root,e)}}t.Previews=c,c.instance=(0,r.lazy)((()=>((0,n.mkLogger)("Previews").info(".instance()",{libraryPreviewsDir:(0,o.libraryPreviewsDirPosixFile)()}),(0,s.map)((0,o.libraryPreviewsDirPosixFile)(),(e=>new c(e)))))),t.buildAssetPreviews_=(0,a.shim1)({name:"img.buildAssetPreviews",impl:e=>c.instance().apb(e.assetId,e.assetFiles,e).build_()})},2090:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(34666),o=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,n.isNumber)(e)?e:((0,n.toGt0)(e.width)??0)/((0,n.toGt0)(e.height)??0),(e=>(0,o.leastBy)(t.StandardAspectRatios,(t=>{const r=Math.abs(e-t);return r>i?void 0:r}))??e))}function c(e,i,r=t.RatioEpsilon){return(0,a.lt)((0,n.absdiff)(u(e),u(i)),r)}function d(e,i){return(0,o.leastByCtx)(t.Ratios,(t=>{const r=Math.abs(t.i-e);return r[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,s.maybeDimSwap)(e.dimensions,e.rotation),(0,s.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,n.sigFigs)(e,3))}},34943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const r=i(19851),s=i(31586),n=i(80049),a=i(50213),o=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),h=(0,r.lazy)((()=>(0,a.mkLogger)("img.RawInfo"))),f=(0,r.lazy)((()=>new n.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:o.ShortCommandTimeoutMs})));async function m(e){return f().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,r,n,a]=e.split("\t"),o=(0,s.toGt0)(n),l=(0,s.toGt0)(a);return null==o||null==l?h().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):h().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:r,ImageSize:{width:o,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>f.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?f.prior()?.clear():f.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{h().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},32876:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Reducers=t.Fit=t.fitInsideToMaxPixels=t.fitInsideToAspectRatio=t.Square=t.SharpFits=void 0;const r=i(19851),s=i(33374),n=i(4188),a=i(11371),o=i(31586),l=i(68708),u=i(50989),c=i(50213),d=i(86580);var h,f;t.SharpFits=(0,u.strEnum)("cover","contain","fill","inside","outside"),function(e){const i=(0,r.lazy)((()=>(0,c.mkLogger)("img.Reducers.Square")));e.name=a.ReducerNames.sq,e.fit="cover",e.reduce=function(e,r){const s=(0,d.lteBoth)(e,r)?{...e,fit:t.SharpFits.cover}:void 0;return i().tap({msg:"reduce()",result:s,meta:{max:e,input:(0,l.pick)(r,"width","height","nativePath")}})}}(h||(t.Square=h={})),t.fitInsideToAspectRatio=function(e,t){return e.width/e.height>=t?{width:Math.floor(e.height*t),height:e.height}:{width:e.width,height:Math.floor(e.width/t)}},t.fitInsideToMaxPixels=function(e,t){if(null==e||!(0,o.gt0)(e.width)||!(0,o.gt0)(e.height))return;if((0,s.pixels)(e)(0,c.mkLogger)("img.Reducers.Fit")));e.name=a.ReducerNames.fit,e.fit="inside",e.reduce=function(e,i){if(!(0,d.ltBoth)(i,e))return(0,n.fitInside)(i,e);t().trace(`reduce(): input ${(0,s.fmtDim)(i)} is too small for ${(0,s.fmtDim)(e)}`)}}(f||(t.Fit=f={})),t.Reducers=[h,f]},5733:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const s=r(i(9288)),n=i(19851),a=i(41400),o=i(50213),l=i(28874),u=i(15674),c=(0,n.lazy)((()=>(0,o.mkLogger)("img.Sharp")));function d(e,t){return(0,s.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,n.lazy)((()=>{s.default.simd(l.Settings.enableSIMD.valueOrDefault),s.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),s.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,a.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},50961:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractImageForThumbs_=t.sharpReadable_=t.toSharp=t.imgFromExif_=t._imgFromExif_=void 0;const s=i(77988),n=r(i(9288)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(33374),d=i(98553),h=i(31586),f=i(68708),m=i(51926),p=i(41583),g=i(50213),y=i(97352),v=i(56519),w=i(56038),b=i(57159),S=i(95696),P=i(17217),_=i(28874),M=i(47783),T=i(16170),E=i(95141),k=i(54979),D=i(1078),x=i(63870),C=i(86580),F=i(277),A=i(16047),I=i(13940),O=i(5733),L=i(66106),R=i(19350),N=(0,a.lazy)((()=>(0,g.mkLogger)("img.SharpReadable")));async function B(e,t,i){return i?await(0,M.exiftool)().extractBinaryTagToBuffer(t,e.nativePath):(await z(e,t))?.nativePath}async function j(e,t,i,r,a){const o=t?.[i];if(!(o instanceof s.BinaryField))return;const l=o.bytes<_.Settings.maxEmbeddedBuffer.valueOrDefault;try{const t=await B(e,i,l);if(null==t)return;const s=(0,n.default)(t,{failOn:_.Settings.imageFailOn.valueOrDefault}),o=await s.metadata(),u=(0,C.aspectRatio)(o);if(null!=a&&null!=u&&!(0,h.closeTo)(a,u,.2))return void N().info("imgFromExif("+e+", "+i+"): rejecting (aspect ratio mismatch)",{fileAspectRatio:a,renderedAspectRatio:u});const c=(0,C.lteBoth)(r,o);return N().debug("imgFromExif("+e+", "+i+")",{valid:c,minDim:r,useBuffer:l,fileAspectRatio:a,renderedAspectRatio:u,dim:(0,f.pick)(o,"width","height")}),c?{sharp:s,file:(0,m.isString)(t)?S.PosixFile.for(t):void 0}:void 0}catch(t){return void N().info("Failed to read image from EXIF tag "+i,{src:e,error:t})}}async function z(e,t){const i=t.toLowerCase().endsWith("tiff")?".tiff":".jpg";try{const r=await(0,I.tmpImageFile_)({src:e,tag:t,ext:i});return await r.applyIfEmpty_({retries:2,fn_:i=>(0,M.extractBinaryTag)(t,e.nativePath,i.nativePath),timeoutMs:(0,x.commandTimeoutMs)()})}catch(i){return void N().throw("Failed to extract embedded "+t+" from "+e.nativePath,{error:i})}}t._imgFromExif_=B,t.imgFromExif_=j,t.toSharp=function(e){const t=e;if((0,O.isSharp)(t.sharp))return t.sharp;if((0,P.isSimpleFile)(t.file))return(0,n.default)(t.file.nativePath,{failOn:_.Settings.imageFailOn.valueOrDefault});throw new Error("toSharp(): not a Sharp object: "+(0,d.stringify)(e))},t.sharpReadable_=function(e){return(0,w.time)(`img.sharpReadable${e.src.ext.toUpperCase()}`,(()=>async function({src:e,minDim:t,skipEmbedded:i}){const r=N().addParameterContext(e.nativePath);(0,O.setupSharp)();const n=await(0,k.readMimeType)(e);if((0,u.blank)(n))return r.throw(e+" is not supported (missing MIMEType)",{doNotSend:!0});const a=await(0,D.extractSizeInfoFromFile)(e);if(null==a)return void r.warn("Failed to extract size info from "+e);const d=[];function f(e,t){t.desc=e,d.push(t)}const m=a.rotation,g=(0,T.isVideoMimeType)(n),S=(0,T.isLibrawMimeType)(n),P=a.dimensions,x=t??(0,y.map2Gt0)(P.width,P.height,((e,t)=>({width:Math.round(.9*e),height:Math.round(.9*t)})));if(null==x?.width||null==x?.height)return r.throw(e+" is not supported (missing dimensions)",{dim:x,doNotSend:!0,mimetype:n,isRaw:S,isVideo:g});const I=(0,C.aspectRatio)(a.fileDimensions),B=(0,h.lt)(I,1),z=(0,T.isSharpMimeType)(n)&&null==t,V=(0,E.orientationRequiresMirroring)(a.orientation);if(!0===i||g||B||z||V)r.debug("not pulling previews from tags",{isVideo:g,isFilePortrait:B,isSharpMimeAndNoMinDim:z,isMirrorOrientation:V});else{const i=!1,n=await(0,M.readRawTags)(e,i);if(null==n)r.warn("Cannot pull previews from tags: readRawTags() failed");else{const i=[..._.Settings.embeddedPreviews.values];null!=t&&(0,c.dmegapixels)(t)<1&&i.unshift(..._.Settings.embeddedThumbnails.values);const a=x.width*x.height*.2,u=x.width*x.height*.05,d=(0,l.sortBy)(i.filter((e=>n[e]instanceof s.BinaryField)),(e=>{const t=n[e]?.bytes;return(0,h.gt)(t,u)?Math.abs(t-a):void 0}));if(!(0,o.isEmpty)(d)){r.debug("checking previews from tags",{sizeSortedTagNames:d});for(const t of d)f("imgFromExif."+t,(()=>j(e,n,t,x,I)))}}}(0,T.isSharpMimeType)(n)&&f("sharp",(async()=>({file:e}))),(0,A.isHeifMimeType)(n)&&await(0,F.isHeifSupported)()&&f("heif",(()=>(0,v.thenMap)((0,F.heif2img)(e),(e=>({file:e}))))),S&&f("raw2tiff",(()=>(0,v.thenMap)((0,R.raw2tiff_)(e),(e=>({file:e}))))),g&&f("extractVideoFrame",(async()=>{if(await(0,L.isVideoSupported)())try{return await(0,v.thenMap)((0,L.extractVideoFrame_)(e),(e=>({file:e})))}catch(t){throw new b.WrappedError("Failed to extract video frame for "+e,t)}else r.warn("video file, but video support is missing",{src:e.nativePath,mimetype:n,minDim:t})}));const W=[];for(const i of d)try{const s=await(0,w.time)("img.read."+i.desc,i);if(null!=s)return r.debug(i.desc+" strategy succeeded",{src:e,minDim:t,rot:m,img:s.file?.nativePath}),{desc:i.desc,rot:m,mimetype:n,...s};r.debug(i.desc+" returned null",{src:e,minDim:t,rot:m})}catch(e){r.warn(i.desc+" failed",e),W.push((0,p.toErr)(e))}throw new b.WrappedError("Failed to render "+e,{causes:W,path:String(e),fatal:!1,doNotSend:!0,retriable:!1})}(e)))},t.extractImageForThumbs_=z},21473:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.testSharp_=void 0;const s=r(i(34589)),n=i(76760),a=r(i(9288)),o=i(50357),l=i(98553),u=i(68708),c=i(23560),d=i(43899),h=i(28874),f=i(5733);t.testSharp_=async function e(t){try{(0,f.setupSharp)();const e=t??(0,n.join)(d.ProjectPath.Public(),"images","logo@5x.png"),i=(0,a.default)(e,{failOn:"error"}),r=await i.resize(24,32,{fit:"cover",position:"attention"}).toFormat("jpeg").toBuffer({resolveWithObject:!0});(0,s.default)((0,o.eql)((0,u.pick)(r.info,"format","width","height","channels"),{format:"jpeg",width:24,height:32,channels:3}),"Unexpected sharp output: "+(0,l.stringify)(r.info))}catch(i){if(!(0,c.isWorkerService)()&&h.Settings.enableSIMD.valueOrDefault)return h.Settings.enableSIMD.envValue=!1,e(t);throw i}}},181:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.whyInvalidFile=t.clearInvalidFileCache=t.throwIfInvalidFile_=t.isValidFile=void 0;const s=r(i(9288)),n=i(19851),a=i(22573),o=i(42659),l=i(98553),u=i(50213),c=i(12089),d=i(81168),h=i(57159),f=i(88561),m=i(95696),p=i(17217),g=i(28874),y=i(16170),v=i(54979),w=i(63870),b=i(5733),S=i(50961),P=i(66106),_=i(51210),M=(0,n.lazy)((()=>(0,u.mkLogger)("img.ValidFile")));t.isValidFile=async function(e){return(0,a.blank)(await(0,t.whyInvalidFile)((0,p.toNativePath_)(e)))},t.throwIfInvalidFile_=async function(e){if(!g.Settings.validateJpegImages.valueOrDefault&&!g.Settings.validateRawImages.valueOrDefault&&!g.Settings.validateVideos.valueOrDefault)return void M().debug("file validation is disabled for "+e,{validateJpegImages:g.Settings.validateJpegImages.valueOrDefault,validateRawImages:g.Settings.validateRawImages.valueOrDefault,validateVideos:g.Settings.validateVideos.valueOrDefault});const i=(0,p.toNativePath_)(e),r=M().tap({msg:"whyInvalidFile("+i+")",result:await(0,t.whyInvalidFile)(i)});(0,a.notBlank)(r)&&M().throw(r,{path:i,retriable:!1,doNotSend:!0,ignorable:!0})};const T=(0,n.lazy)((()=>new f.FileCache({name:"img.validFile",maxSize:256,timeoutMs:Math.max(o.minuteMs,g.Settings.validateVideos.valueOrDefault?5*o.minuteMs:(0,w.commandTimeoutMs)())})));t.clearInvalidFileCache=function(){return T().clear()},t.whyInvalidFile=(0,c.shim1)({name:"img.whyInvalidFile",cache:T,toKey:p.toNativePath_,impl:async e=>{const t=m.PosixFile.for(e);if(!await t.isFile()||!await t.isReadable())return t+" is not a readable file";if(await t.isEmpty())return t+" is empty";try{const e=await(0,v.readMimeType)(t);if(null==e)throw new Error("Cannot validate, no mimetype");if((0,y.isVideoMimeType)(e))g.Settings.validateVideos.valueOrDefault&&(M().debug("validating "+t),await(0,P.validVideo_)(t));else{if(!e.startsWith("image/"))throw new Error("Unsupported mimetype "+(0,l.stringify)(e));if("image/jpeg"===e)g.Settings.validateJpegImages.valueOrDefault&&await(0,_.validJpeg_)(t);else if(g.Settings.validateRawImages.valueOrDefault)if((0,d.includesIgnoreCase)(g.Settings.validateMimetypeSkiplist.values,e))M().info("Skipping validation of "+t+": validateMimetypeSkiplist matches",{mime:e});else{const e=await(0,S.sharpReadable_)({src:t,skipEmbedded:!0}),i=await async function(e,t=g.Settings.imageFailOn.valueOrDefault){const i=e;if((0,p.isSimpleFile)(i.file))return(0,s.default)(i.file.nativePath,{failOn:t});if((0,b.isSharp)(i.sharp)){const{data:e,info:t}=await i.sharp.raw().toBuffer({resolveWithObject:!0});return(0,s.default)(e,{...t,failOnError:!0})}throw new Error("Cannot read input "+e?.desc)}(e);await i.tiff().toBuffer()}}return""}catch(t){return new h.WrappedError("Failed to validate",{cause:t,path:e,doNotSend:!0}).toS()}}})},19769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const r=i(19851),s=i(40958),n=i(41400),a=i(50213),o=i(68852),l=i(98314),u=i(28874),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:h().test(t)||!d().test(t),meta:{err:e,allow:h().test(t),block:d().test(t),validationErrorAllowlist:h().source,validationErrorBlocklist:d().source}})};const d=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),h=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,n.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>h.unset()))}))},66106:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const r=i(19851),s=i(40958),n=i(38639),a=i(42659),o=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),h=i(7282),f=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),v=i(56038),w=i(31562),b=i(34102),S=i(88561),P=i(95696),_=i(17217),M=i(31843),T=i(70417),E=i(33847),k=i(28874),D=i(94678),x=i(43207),C=i(47783),F=i(16170),A=i(95141),I=i(1078),O=i(63870),L=i(89782),R=i(13940),N=i(34592),B=(0,r.lazy)((()=>(0,d.mkLogger)("img.Video")));function j(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function z(e){return(0,h.isProd)()&&(e=void 0),(0,n.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=z,t.isVideoSupported=(0,r.lazy)((async()=>{try{return!0===(await z())?.isSupportedVersion}catch(e){return B().warn("isVideoSupported",{error:e}),!1}})),(0,o.later)((()=>(0,b.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,M.lerp2d)(e,{x:76800,y:k.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:k.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,r.lazy)((()=>new S.FileCache({name:"img.videoFrame",timeoutMs:a.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,_.toNativePath_)(e))):void 0}async function U(e,t){const i=j("extractVideoFrame",e),r=P.PosixFile.for(e);if(!(0,n.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const s=await(0,R.cachedImageFile_)(r,"frame",".jpg");i.debug("extractVideoFrame("+s+")");const o=await r.mtimeMs();if(null==o)return i.throw("null mtime");const l=await(0,C.readRawTags)(r,!1);if(null==l)return i.throw("no tags");const u=(0,A.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,I.extractSizeInfoFromTags)(l,u)?.dimensions,d=await s.stat(),h=null==d?void 0:await(0,L.dimensions)(s);if(null!=d&&d.mtimeMs>o&&null!=h&&(null==c||h.height===c.height&&h.width===c.width))return i.debug("prior dest, "+s+" seems reasonable",{srcDim:c,destDim:h}),s.nativePath;const f=(0,x.extractDurationSec)(l),m=Math.min(f??0,k.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:f}),await s.applyIfEmpty_({fn_:async e=>{const t={src:r,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,w.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*a.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,C.deleteAllTags_)(e,e)},timeoutMs:(0,O.commandTimeoutMs)()}),s.nativePath}async function H(){return k.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function q(e){const t=j("needsTranscoding",e);if(!await H())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,C.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const r=i.MIMEType;if(!(0,F.isVideoMimeType)(r))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:r}});const n=(0,x.extractDurationSec)(i);if(!(0,c.gt)(n,k.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:n}});const a=(0,s.compactBlanks)([i.AudioFormat]),o=a.some((e=>(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,s.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeMimeTypes.values,r);return t.tap({level:"info",msg:"result",result:!(o&&u&&d),meta:{mimetype:r,isSafeMimeType:d,audioCodecs:a,isSafeAudioCodec:o,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>U(e)}),t.__extractVideoFrame_=U,t.isVideoTranscodingSupported=H,t.needsTranscoding=q;const G=new g.TTLMap(a.hourMs);function $(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,r){if(!await H())return;const s=j("transcode",e);{!function(){for(const[e,t]of G.entries())t.isSettled&&G.delete(e)}();const t=G.get(e.nativePath)??G.get(i.nativePath);if(null!=t)return s.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await q(e))return void s.info("no transcoding needed");const n=await e.size();if(!(0,u.gt0)(n))return s.throw("source is empty or cannot read");const a=await(0,C.readTags)(e),o=(0,I.extractSizeInfoFromTags)(a),d=(0,x.extractDurationSec)(a);if(null==a||null==o||null==d)return s.throw("failed: missing video metadata",{sizeInfo:o,durationSec:d});{const e=G.get(i.nativePath);if(null!=e)return s.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const h=new y.Deferred("transcode "+e);G.set(e.nativePath,h),G.set(i.nativePath,h);const m=(0,u.toGt0)(a.VideoFrameRate)??(0,u.toGt0)(a.FrameRate)??30,p=Math.round(o.dimensions.width*o.dimensions.height*(0,T.max)([(0,u.toGt0)(a.FrameCount),(0,u.toGt0)(a.VideoFrameCount),m*d]));if(!0===r?.force)await i.unlink();else if(await async function(e,t){const i=await(0,C.readRawTags)(t),r=await(0,C.readRawTags)(e),s=(0,x.extractDurationSec)(r),n=(0,x.extractDurationSec)(i);return B().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(s,n,1.5),meta:{srcDurationSec:s,destDurationSec:n,src:e.nativePath,dest:t.nativePath}})}(e,i))return s.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const r=j("extractMaxBitrate",e),s=k.Settings.minVideoDimension.valueOrDefault,n=i.ImageWidth;if(null!=n&&!(0,u.gte)(n,s))return r.throw("invalid width: "+n,{ignorable:!0});const a=i.ImageHeight;if(null!=a&&!(0,u.gte)(a,s))return r.throw("invalid height: "+a,{ignorable:!0});const o=(0,D.extractBitrateKbps)(i)??k.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,f.mapGt0)(n,(e=>(0,f.mapGt0)(a,(i=>(0,u.clamp)(0,o,(0,t.bitrateKps)(e*i)))))),c={width:n,height:a,videoBitrateKbps:l};return r.debug("dim()",{src:e,result:c}),c}(e,a);return await h.observe((0,v.time)("video.transcode:"+e,(async()=>{const t=$(n,g.videoBitrateKbps,d);return await i.applyWip_({fn_:n=>async function(n){s.info("starting...",{destWip:n});const o=new E.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:n,fps:m,halt:r.halt,...g},h=k.Settings.transcodeMaxDim.valueOrDefault,f=(0,T.max)([a.dimensions.height,a.dimensions.width]);if((0,u.gt0)(h)&&(0,c.gt)(f,h)){const e=(0,l.fitInside)(a.dimensions,{width:h,height:h});null==e?s.warn("Cannot downsample transcoded video: fitInside() returned null",{input:a.dimensions,maxPixels:h}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),s.info("Downsampling transcoded video",{original:a.dimensions,output:e}))}const p=await o.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&s.throw("transcode failed with code "+p.code)}(n),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&s.info("transcode complete",{src:e,dest:i,elapsedMs:h.elapsedMs,pixels:p}),i},t.guessExpectedSize=$,t.validVideo_=async function(e){return null==await W(e)&&j("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),h=i(56519),f=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),v=i(84258),w=i(28874),b=i(76280),S=i(63870),P=i(19769),_=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function M(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:w.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=M;const T=/ffmpeg version n?(?\S+)/i,E=(0,u.lazy)((async()=>{const e=await M();if(null==e)return void _().info("failed to find ffmpeg in $PATH",{ffmpegPath:w.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,S.commandTimeoutMs)(),ignoreStderr:!0}),i=T.exec(t.result)?.[1];return _().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,b.semverSatisfies)(i,">=3.2")}}));function k(){E.unset(),t.ffmpegVersionDescription.unset()}function D(e){const t=e?.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault;return(0,s.blank)(t)||(0,n.isDisabled)(t)?[]:["-hwaccel",t]}function x(e){const t=[...w.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(w.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),r=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+r),t}function C(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function F(e){const t=w.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,h.thenMapOr)(E(),(e=>"version "+e),(()=>"(not found)")))),(0,o.later)((()=>{(0,g.ee)().on("clearCache",k),(0,g.ee)().on("clearToolCache",k)})),t.ffmpegVersion_=async function(){return await E.prior()??E.refresh()},t.isFFmpegSupported=async function(){return null!=await E()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await M(),(0,r.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:a.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,f.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*a.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=x,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await M(),(0,r.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...x(t),...F(t),...D(t),"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...C(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){_().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,v.unlink)(t.dest,"debug");const r=(0,p.errorToS)(i,{maxLen:1024});if(!(0,n.isDisabled)(t.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(r))return _().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return _().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await M(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},51210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotate_=t.rotateInPlace_=t.validJpeg_=t.jpegtranVersion_=void 0;const r=i(19851),s=i(42659),n=i(21605),a=i(50213),o=i(84777),l=i(57159),u=i(95696),c=i(89966),d=i(43334),h=i(63870),f=i(19769),m=d.isWin?"NUL":"/dev/null",p=(0,r.lazy)((()=>(0,a.mkLogger)("img.jpegtran")));async function g(e,t,i){const r=await(0,c.jpegtranNativePath_)();if(!(0,n.isRotation)(i))throw new Error("refusing to rotate("+e+", "+i+")");await(0,o.stdout_)(r,["-copy","all","-trim","-rotate",i.toFixed(0),"-outfile",t.nativePath,e.nativePath],{timeoutMs:s.minuteMs}),t.clear()}t.jpegtranVersion_=async function(){const e=await(0,o.stdoutResult_)(await(0,c.jpegtranNativePath_)(),["-version"],{quiet:!0,timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:()=>!0});return(e.stderr??e.result).replace(/^libjpeg-turbo version/,"").trim()},t.validJpeg_=async function(e){const t=u.PosixFile.for(e),i=await(0,c.jpegtranNativePath_)();try{await(0,o.stdoutResult_)(i,["-outfile",m,t.nativePath],{timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:f.isIgnorableValidationError,ignoreExitCode:!0})}catch(e){throw p().warn("validJpeg caught invalid file",{src:t,cause:e}),new l.WrappedError("Invalid JPEG: "+t,{cause:e,path:t.nativePath,doNotSend:!0,fatal:!1,retriable:!1})}},t.rotateInPlace_=async function(e,t){p().info("rotateInPlace("+e+")",t),await e.applyWip_({fn_:i=>g(e,i,t),skipFsLock:!1,minSizeBytes:512,timeoutMs:s.minuteMs})},t.rotate_=g},19350:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dcraw_emu_=t.raw2tiff_=t.librawSupported=void 0;const r=i(19851),s=i(40958),n=i(33374),a=i(12168),o=i(23541),l=i(54993),u=i(50213),c=i(84777),d=i(98314),h=i(38835),f=i(57159),m=i(89966),p=i(28874),g=i(16170),y=i(54979),v=i(89782),w=i(13940),b=i(42725),S=i(19769),P=(0,r.lazy)((()=>(0,u.mkLogger)("img.libraw")));t.librawSupported=async function(e){try{return(0,g.isLibrawMimeType)(await(0,y.readMimeType)(e.nativePath))}catch(t){return P().warn("librawSupported("+e+"): failed to read filetype",t),!1}},t.raw2tiff_=async function(e){return(0,w.readableToFile_)({src:e,desc:"dcraw",suffix:".tiff",f:t=>k(e,t)})};const _=["-T"],M=["-Z","-"],T=["-o","1"],E=["-t","0","-j"];async function k(e,t){const i=await(0,v.dimensions)(e);if(null==i)return P().throw("Cannot decode RAW "+e+": no EXIF dimensions."+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);const r=b.ImageSize.largestFit().outputSize(i),u=[];null!=r&&4*(0,n.dmegapixels)(r)<(0,n.dmegapixels)(i)&&(P().debug("Large original source: using -h"),u.push("-h"));const g=await(0,m.dcrawEmuNativePath_)(),y=[..._,...M,...T,...u,...E,...p.Settings.dcrawEmuArgs.values,e.nativePath],w={encoding:"buffer",timeout:p.Settings.taskTimeoutMs.valueOrDefault,maxBuffer:250*a.MB};P().debug("dcraw_emu()",{cmd:g,args:y,opts:w});const k=(0,c.execFile)(g,y,void 0,w),D=[];function x(t){const i=(0,o.isError)(t)?(0,d.errorToS)(t):(0,l.toS)(t);if((0,S.isIgnorableValidationError)(i))P().info("dcraw_emu(): warning",{src:e,msg:i});else{P().warn("dcraw_emu(): error",{src:e,msg:i});const r=(0,o.isError)(t)?t:(0,f.toWrappedError)(i,{fatal:!1});D.push(r)}}if(k.on("error",x),k.stderr.on("data",x),await t.writeStream_(k.stdout),(0,s.isNotEmpty)(D))throw new f.WrappedError("Failed to convert RAW image "+e,{causes:D,path:e.nativePath});(0,c.endProcess)(k)}t.dcraw_emu_=k},36192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const r=i(19851),s=i(84777),n=i(8103),a=i(43334),o=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,r.lazy)((async()=>a.isMac?(0,n.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,s.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(o.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},71706:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.j=void 0;const r=i(38522);t.j=function(e){return JSON.parse((0,r.brotliDecompressSync)(Buffer.from(e,"base64")).toString("utf8"))}},83950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.L=void 0;const r=i(79114),s=i(40958),n=i(42659),a=i(34666),o=i(48884),l=i(97352),u=i(81674),c=i(84194);t.L=class{static for(e){return new this(e.str,e.l,e.sids,e.src)}constructor(e,t,i,r){this.s=e,this._l=t,this._sids=i,this.meta={src:r}}get l(){return this._l}get ok(){if(null==this._l)return!1;const e=(0,o.intersection)(this._sids,this._l.uids),t=(0,s.uniq)(e.map(c.getScheme)),i=(0,s.compact)(t.map((e=>(0,c.prefix2scheme)(e)))),r=i.length>=this._l.mat,a=(0,l.within)(this._l.iat?.getTime(),this._l.exp?.getTime()+n.dayMs,Date.now());return this.meta[(0,u.k)().o]=a,this.meta[(0,u.k)().u]=r,this.meta[(0,u.k)().m]=i,a&&r}cmpVal(){return[this.ok,-(r.S.indexOf(this.l?.[(0,u.k)().T])??0),this.l?.exp?.getTime()??1,this.meta.matchedSchemes]}cmp(e){return(0,a.cmp)(this.cmpVal(),e.cmpVal())}}},81674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p=t.l=t.t=t.b=t.m=t.vok=t.v=t.v_=t.k=void 0;const r=i(76790),s=i(22573),n=i(38639),a=i(45599),o=i(41400),l=i(96249),u=i(55835),c=i(31586),d=i(51926),h=i(79114),f=i(23541),m=i(59455),p=i(54993),g=i(72993),y=i(19851),v=i(50213),w=i(56519),b=i(76596),S=i(46292),P=i(87290),_=i(77740),M=i(34102),T=i(83278),E=i(28874),k=i(37692),D=i(71706),x=i(83950),C=i(72042),F=i(33603),A=i(48132);t.k=(0,y.rolazy)((()=>(0,D.j)("G1UBABwHdkz4hUIkFCfPXW5LlfvrWKSr9W3AIyIhUiw68NDfvLLHVop/bGoNnRxQlnqi2TZp0IJaX+lUHBoi+vMy2LMNpHCv8xVkUGsmQsgB8ldHoDqJeUQzbdybwikWVRs2KSWKjE5LnuqhTNSp3gTLhNfE9EqBLeaXP+UM9YqTGSXcyrcL03rIPMDAVyJplSZC0xoUgguOYJKvrcYFbNArN7BrQsnnsJ4hMtcSxOTxxRdxzETtL93qa3vjDw==")));const I=(0,a.defer)((()=>(0,v.mkLogger)((0,t.k)().l)));async function O(e){const i=await(0,C.V)((0,d.ensurePrefix)((0,p.toS)(e).trim(),(0,t.k)().p)),r=(0,b.utcIsoToTs)(i[(0,t.k)().i]);if(null==r)throw new Error("bad "+(0,t.k)().i+": "+i[(0,t.k)().i]+" ("+e+")");const s=(0,b.utcIsoToTs)(i[(0,t.k)().r]);if(null==s)throw new Error("bad "+(0,t.k)().r+": "+i[(0,t.k)().r]+" ("+e+")");return(0,_.getDevEnvFlag)((0,t.k)().y)&&(i[(0,t.k)().t]=!0),i[(0,t.k)().a]=(0,c.toGte0)(i[(0,t.k)().a])??2,i[(0,t.k)().i]=new Date(r),i[(0,t.k)().r]=new Date(s),i[(0,t.k)().b]=(0,p.toS)(i.uids).split(","),i}async function L(e,i,r,n){try{return(0,s.blank)(e)||e===(0,t.k)().f?void 0:x.L.for({str:e,l:await O(e),sids:null!=n?n:await(0,F.sids)({timeoutMs:r}),src:i})}catch(i){return I().tap({msg:(0,t.k)().v,result:{s:e,ok:!1,meta:{err:i}}})}}async function R(e,t){const i=[],r=await(0,w.sortByAsync)({name:"rawLicenseFromDir("+e+")",arr:e?.childFiles(),f:e=>e.mtimeMs()});for(const e of r.reverse()){const r=await L((0,m.toA)(await e.readLines()).map((e=>e.trim())).join(""),e.nativePath,A.UserTimeoutMs,t);null!=r&&i.push(r)}return i}async function N(){const e=await(0,t.m)();return e[0]?.ok?e[0]:void 0}async function B(){return(await N())?.l?.[(0,t.k)().T]??(0,t.k)().f}t.v_=O,t.v=L,t.vok=async function(e,t,i){if((0,s.blank)(e))return;const r=await L(e,t,i);return(0,n.isTrue)(r?.ok)&&r instanceof x.L?r:void 0},t.m=(0,y.rolazy)((async()=>{if((0,_.getDevEnvFlag)((0,t.k)().x))return[];const e=await(0,F.sids)({timeoutMs:A.UserTimeoutMs}),i=(0,u.map)((0,S.configDir)(),(e=>T.BaseFile.for(e))),s=(n=(0,l.flatten)((await(0,w.someOrTimeout)([()=>function(e){return L(E.Settings[(0,t.k)().L].value,"Settings",A.UserTimeoutMs,e)}(e),()=>R(i?.join((0,t.k)().d),e),()=>R((0,P.libraryDataDirPosixFile)()?.join((0,t.k)().d),e),()=>R(i?.sibling((0,g.AppName)().toLowerCase()).join((0,t.k)().d),e)],{timeoutMs:A.UserTimeoutMs})).filter((e=>!(e instanceof Error)))),(0,r.sortBy)(n.filter((e=>null!=e&&((0,f.isError)(e)&&I().warn((0,t.k)().d+": ",e),null!=e&&!(0,f.isError)(e)&&null!=e?.l))),(e=>[!e.ok,h.S.indexOf(e.l?.[(0,t.k)().T])??h.S.length+1,-(e.l?.exp?.getTime()??1)])));var n;return I().tap({msg:(0,t.k)().d+"()",result:s})})),(0,o.later)((()=>{(0,M.ee)().on("clearCache",(()=>t.m.unset())),(0,M.ee)().on((0,t.k)().c,(()=>t.m.unset())),k.stateEvents.on((0,t.k)().c,(()=>t.m.unset()))})),t.b=N,t.t=B,t.l=async function(){try{return await B()===(0,t.k)().f}catch{return!0}},t.p=async function(){try{return await B()===(0,t.k)().g}catch{return!1}}},72042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.V=t.l=void 0;const r=i(91227),s=i(19851),n=i(22573),a=i(71706);t.l=(0,s.lazy)((()=>(0,a.j)("G54BgBwHzrkukKDR8Ar6KkW29gbXlfrqQX46gTu5Wfq6dELYTjfBokB0d5+E2SAINBtxlmPquWe3PMUoNgaJrD982QMslkNeZ4BEqcBbQT59DVl9RnoTNi50diuT7NQg0YHxkr8SwDwtmFUOf+LwNVDDnPXUrzTOU++M3b+lcyfr7PXZndKHzho8iztNkZgt+/19//aXe+gvmC0HIdnn64wdLeYeLM7S9jmjTp52SzFsvIVbd4D0+rdtdjiz6R4vc2cmY398kuXiKG7fNXWS/I93etxXiVNPd4RXJF+k6JnuMUKk03GWHQQ="))),t.V=function(e){const i=(0,r.decode)(e).payload;if(null==i)throw new Error("Missing payload");const s=(0,n.notBlankOr)(i.k,(0,t.l)().d),a=(0,t.l)().o.find((e=>e.k===s));if(null==a)throw new Error("Unknown key");return r.V2.verify(e,a)}},84194:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SchemeCounts=t.isValidUid=t.toUID=t.UidLength=t.prefix2scheme=t.sortUids=t.getScheme=t.S=void 0;const n=i(40958),a=i(76790),o=i(22573),l=i(45599),u=i(50989),c=i(54993),d=i(22454),h=i(19851),f=i(50213),m=i(37628),p=i(55222),g=i(71706),y=(0,l.defer)((()=>(0,g.j)("GyABAIzUYs0Z7mSuLfVL1SwGefr+3nCwyXBMg6nD0qduA8HycFjUGK1N/ikYqhiqYLGbs7oxTBbzRPxteP9gA3L9DS0EJ2BJ1pYNa/DtEE2aPI2o03hHx3k9MhdE7jAeRUvKQ6tY3Q1fcIPe8GBMZvOeKibTymyo3Cw/7Ua42DKPjpL3wxWv+7TCGA==")));function v(e){const i=e.split(":",1)[0];return t.S.has(i)?i:void 0}t.S=(0,u.strEnum)("cu","lc","lm","lp","lb","mp","ms","wm","cm","bm","nm","li","si","vl"),t.getScheme=v,t.sortUids=function(e){return(0,a.sortBy)((0,n.uniq)(e.filter(S)),(e=>[t.S.indexOf(v(e))??t.S.length+1,e]))},t.prefix2scheme=function(e){return y()[e]};const w=["uninitialized","b08dfa6083e7567a1921a715000001fb"];t.UidLength=15,t.toUID=function(e,i){try{const r=(0,c.toS)(i).replace(/[^a-z\d=/+]+/gi,"");return(0,o.blank)(r)||w.includes(r.toLowerCase())||null!=r.match(/^[\s0:_/-]*$/)?void 0:e+":"+(0,m.shortStringSha)(r,t.UidLength,p.Radix58)}catch(t){return void(0,f.mkLogger)("toUID").warn("failed",{pfx:e,err:t})}};const b=(0,l.defer)((()=>new RegExp(`^(?:${t.S.values.join("|")}):[0-9a-zA-Z]{${t.UidLength}}$`)));function S(e){return null!=e&&null!=b().exec(e)}t.isValidUid=S,t.SchemeCounts=class{constructor(e){r.set(this,new Set),this.schemeCounts=(0,h.lazy)((()=>{const e=new d.CountingSet;for(const t of s(this,r,"f")){const i=v(t);null!=i&&e.incr(i)}return e})),null!=e&&this.addUids(e)}get size(){return s(this,r,"f").size}addUids(e){for(const t of e)null==v(t)||s(this,r,"f").has(t)||(s(this,r,"f").add(t),this.schemeCounts.unset())}count(e){return this.schemeCounts().get(e)}},r=new WeakMap},33603:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearSids=t.addSids=t.sids=t.win_machineGuid_=t.readInfo=t.k=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(45599),o=i(96249),l=i(68708),u=i(51926),c=i(59455),d=i(54993),h=i(50213),f=i(7282),m=i(56519),p=i(84777),g=i(84542),y=i(19254),v=i(45879),w=i(70854),b=i(57902),S=i(72308),P=i(43334),_=i(24399),M=i(7014),T=i(30933),E=i(71706),k=i(84194);t.k=(0,a.defer)((()=>(0,E.j)("G9ABYIzDOIZ8NLQ4t7qW8tNrmrOzz+qFGfAxl8jW4E2tLxwWRZT5TueCnPcwgTzT1DN3veRB+e7EYGlYHg6nhjBDQv7zI6EcYWk35z6QuZC3Q0itjrLCbmgd0iED0BvGiYLBJwRU1O9/3Agbl8IfG6ITVFWDRwyTw3rbUMo/XMyAVW7R23mkwUx0l4/7iA13RV/nmPuJFKp5BvJW7SoXJZoWEfdSNYYhN5UCtkbC7O1AaPIbU3P6uRLmEyb4TaHWzFigvrlmZVUzzp9j/Mz55vqN88ewd1Nrfh7gkVRQ7TtB7Ztz3XJxYC3ogdJHg8HGsG4=")));const D=(0,a.defer)((()=>(0,h.mkLogger)((0,t.k)().n)));async function x(e=(0,t.k)().pc){if(P.isLinux)try{const t=await(0,y.fileGrep_)(e,/^\s*(?:hardware|revision|serial|model)\s*[:=]\s*[a-z\d]{6}.*$/i),i=(0,r.compactBlanks)((0,g.splitLines)(t).map((e=>e.replace(/\s+/g," ")))).sort();return i.some((e=>null!=e.match(/^serial/i)))?i:void 0}catch{return}}t.readInfo=x;const C=(0,a.defer)((()=>(0,m.thenMap)(x(),(e=>(0,k.toUID)(k.S.lc,e.join(",")))))),F=/o\.e\.m\./i;async function A(e){return(0,r.uniq)(await Promise.all((0,t.k)()[e].map((e=>(0,v.readFileMaybe)(e,b.LogLevels.trace))))).map(d.toS).filter((e=>(0,s.notBlank)(e)&&null==e.match(F)))}async function I(){return P.isLinux?(await A("lm")).map((e=>(0,k.toUID)(k.S.lm,e))):void 0}async function O(){return P.isLinux?(await A("lp")).map((e=>(0,k.toUID)(k.S.lp,e))):void 0}async function L(){return P.isLinux?(await A("lb")).map((e=>(0,k.toUID)(k.S.lb,e))):void 0}async function R(){if(P.isMac)try{return(0,l.entries)(await async function(){const e=await(0,p.stdout_)((0,t.k)().i,(0,t.k)().ia,{timeoutMs:5*n.secondMs}),i=e.match(/uuid" = "([a-z\d-]{12,})"/i)?.[1],r=e.match(/SerialNumber" = "([a-z\d-]{10,})"/i)?.[1];return{mp:i,ms:r}}()).map((([e,t])=>(0,k.toUID)(e,t)))}catch(e){return void D().warn((0,t.k)().i+" failed",e)}}async function N(){return(await _.PowerShell.instance().executeJson((0,t.k)().w))?.MachineGuid}async function B(){return P.isWin?(0,k.toUID)(k.S.wm,await N()):void 0}t.win_machineGuid_=N;const j=(0,a.defer)((()=>(0,k.toUID)(k.S.cm,(0,T.cpuInfo)()[0].model)));async function z(){return P.isLinux?(0,k.toUID)(k.S.bm,(0,r.compactBlanks)(await A("bm")).map((e=>e.trim())).join("\n")):[]}async function V(){return(0,k.toUID)(k.S.li,await((0,w.LibraryUIDStore)()?.readUid_()))}async function W(){return(0,k.toUID)(k.S.si,await((0,w.SystemUIDStore)()?.readUid_()))}function U(){return(0,S.networkMacAddresses)().map((e=>(0,k.toUID)(k.S.nm,e)))}async function H(){return(0,c.toA)(await(0,M.volumes)()).map((e=>(0,k.toUID)(k.S.vl,e.uuid)))}const q=new Set;t.sids=async function({timeoutMs:e}){const t=Date.now(),i=[j,C,R,V,W,z,I,O,L,B,U,H],r=(0,o.flatten)(await(0,m.someOrTimeout)(i,{timeoutMs:e})).filter(u.isString);for(const e of r)q.add(e);return D().tap({msg:"sids()",result:(0,k.sortUids)([...q,...r]),meta:{timeoutMs:e,elapsedMs:Date.now()-t}})},t.addSids=function(e){if((0,f.isTest)())for(const t of e)q.add(t)},t.clearSids=function(){(0,f.isTest)()&&q.clear()}},48132:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserTimeoutMs=void 0;const r=i(42659);t.UserTimeoutMs=7*r.secondMs},49794:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),s=i(19851),n=i(40958),a=i(22573),o=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,s.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,a.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,n.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),s=i(23560),n=i(66184),a=i(72210);class o{log(e,t,i,r){this.enabled(e,t)&&(0,a.pushLogEntries)({ts:Date.now(),l:e,from:(0,s.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,n.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=o,o.instance=(0,r.lazy)((()=>new o))},14593:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),s=i(22573),n=i(26905),a=i(55835),o=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,s.toNotBlank)(e)??(0,n.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,o.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),s=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:s}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,a.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,o.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),s=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof s.LogWriter))}},28981:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),s=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new s.PlaintextLogFormatter))},31256:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(41400),o=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,n.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,a.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,s.uniq)((0,s.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,o.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,o.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const n=i(77030),a=i(19851),o=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),v=i(31256),w=i(28538),b=(0,a.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),S=String.fromCharCode(0);t.logBroadcaster=(0,a.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,o.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&b().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,n.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{b().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){b().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),s(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,n){if(this.enabled(e,t))try{const a=this.socket;null==a?s(this,r,"f").call(this):a.write(this.logFormatter.format(e,t,i,n)+S)}catch(r){b().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:n,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),s=i(42659),n=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??n.Settings.logDir.valueOrDefault,(0,s.fmtIsoDate)(t??new Date))}},12495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogDirCleanup=void 0;const r=i(19851),s=i(42659),n=i(23560),a=i(79267),o=i(32144),l=i(28874);t.LogDirCleanup=(0,r.lazy)((()=>(0,n.isBillingService)()?void 0:a.FileCleanup.for({name:"logDirCleanup",rootNativePath:()=>l.Settings.logDir.valueOrDefault,staleMs:s.weekMs,isPrunable:e=>(0,o.isLogExt)(e.ext)})))},4904:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),s=i(31586),n=i(51926),a=i(57902);t.isLogEntry=function(e){return null!=e&&(0,s.isNumber)(e?.ts)&&(0,n.isString)(e?.msg)&&a.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),s=i(57902);class n{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,s.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,s.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=n,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new n(s.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>s.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,s.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,s.set(this,[]),n.set(this,(0,l.lazy)((()=>{o(this,s,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:o(this,s,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>o(this,n,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=o(this,r,"m",a).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=o(this,r,"m",a).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){if(null==e||0===o(this,s,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return o(this,s,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),s=i(31586),n=i(50989);t.LogLevels=(0,n.strEnum)("fatal","error","warn","info","debug","trace");const a=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??a},t.levelGte=function(e,i){return(0,s.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const o=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return o.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),s=i(68708),n=i(20214),a=i(51926),o=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,a.isString)(i)||Buffer.isBuffer(i))return(0,a.ellipsize)(i.toString(),256,32);if((0,o.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,n.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const o=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,s.keys)(i),(0,s.keys)(o));return(0,r.isNotEmpty)(c)&&(o["…"]="omitted: "+(0,a.ellipsize)(c.join(", "),128,32)),o}return i}},24068:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),s=i(76760),n=i(1708),a=i(87997),o=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),v=i(22277),w=i(25764),b=i(38836),S=i(99331),P=i(42638),_=i(76596),M=i(98314),T=i(89968),E=i(29882),k=i(28874),D=i(28981),x=i(20839),C=i(21727),F=i(66184),A=i(57902),I=i(72210),O=i(98192);function L(e){const t=(0,D.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=L;class R extends b.EndableWrapper{constructor(e=void 0,t=L){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,o.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,k.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,E.mkdirp_)(e),this.root=await T.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=s.sep+(0,p.serviceName)()+"-"+n.pid+"-",n.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,a.setInterval)((()=>this.flush()),x.DefaultLogFlushMs/2),this.scanTimeout=(0,a.setInterval)((()=>this.scan()),u.minuteMs),n.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,S.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,F.ifLog)(A.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,s.join)(e,i))}))}catch(t){return void(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,M.errorToS)(t))))}}))}async scan(e=!1){if((0,S.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,_.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,S.ending)()||this.ended)return;const t=(0,C.datedLogDir)(this.root.nativePath);try{await(0,E.mkdirp_)(t),this.watchDir(t)}catch(e){(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,M.errorToS)(e))))}(0,S.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,a.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,a.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await T.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(r,i))return;await(0,f.thenMap)((0,O.readLogEntries)(e,{start:r,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,M.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,o.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),s=i(82328),n=i(28981),a=i(20839),o=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(o.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,s.stdoutEnded)()||console.log((0,n.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*a.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),v=i(31586),w=i(409),b=i(23560),S=i(81168),P=i(78406),_=i(25764),M=i(20197),T=i(14977),E=i(36868),k=i(28874),D=i(32105),x=i(20839),C=i(21727),F=i(66184),A=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class O extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*x.DefaultLogFlushMs),rank:_.EndableRanks.logger,unref:!0,onEnd:()=>c(this,s,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,s.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:D.ConsoleLogger.instance(),flushEveryMs:x.DefaultLogFlushMs,processName:b.processName,logFilter:F.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",n).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const s={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(s.meta=(0,A.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(s)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=O,s=new WeakMap,r=new WeakSet,n=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),s=e.splice(0,i);this._linesSinceRotate+=s.length,t.write(s.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},a=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},o=function(e){return t=>(c(this,r,"m",a).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,S.stripAnsiEsc)(this.logOpts.processName()),t=await(0,M.ensureNewNativePath_)({nativePath:(0,f.join)((0,C.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,r,"m",o).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,E.endStream)(e.stream),k.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,T.gzip_)(e.nativePath))}catch(e){c(this,r,"m",a).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(68708),o=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,a.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,s.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,n.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),s=i(84542),n=i(4001),a=i(13047),o=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,o.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,n.stripCopySuffixFromName)(e.name),r=[],o=await(0,a.zcat)(e.nativePath,t);if(null!=o)for(const e of(0,s.splitLines)(o)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),s=i(76790),n=i(68708),a=i(89788),o=i(57902);t.SentLogLevels=(0,r.lazy)((()=>o.LogLevels.values.filter((e=>e!==o.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,n.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new a.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,n.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,n.values)(l()))e.push(...t.toA());return(0,s.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),s=i(41400),n=i(55835),a=i(37975),o=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),v=i(66184),w=i(28538),b=i(24068),S=i(43705),P=i(51879);function _(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),M();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new S.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,n.map)((0,y.logBroadcaster)(),(e=>i.push(e))),o.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&b.LogTail.instance()}function M(){const e=h.Settings.logColor.valueOrDefault;(0,a.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=_,t.setupLogFormatter=M,(0,s.later)((()=>{h.Settings.logStdout.watchLater(_),h.Settings.logDir.watchLater(_),h.Settings.tailLogs.watchLater(_),h.Settings.logColor.watchLater(M),h.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},82647:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const a=i(57975),o=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,a.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return n(this,r,"m",s).call(this,-1)}get p29(){return n(this,r,"m",s).call(this,-.5)}get p38(){return n(this,r,"m",s).call(this,-.25)}get p69(){return n(this,r,"m",s).call(this,.5)}get p84(){return n(this,r,"m",s).call(this,1)}get p98(){return n(this,r,"m",s).call(this,2)}get p99(){return n(this,r,"m",s).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,o.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,o.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,o.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,s=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),s=i(55835),n=i(31586),a=i(30976),o=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,n.clamp)(0,i,(0,n.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,s.map2)(e,t,((e,t)=>(0,r.sum)((0,o.zip)(u(e,i),u(t,i)),(([e,t])=>(0,n.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,n.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,a.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),s=this.clampValue(e);let n=0;for(let e=0;ea?(n+=1,i[t]=a):r[t]=a}return n}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let s=0;s(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,n.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;in?(t+=1,s.min=n):s.max=n}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},44983:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.kmeans=void 0;const r=i(76790),s=i(93973);t.kmeans=function(e,t,i){const n=s(e,t,i);return{...n,centroids:(0,r.sortBy)(n.centroids.filter((e=>e.size>0)),(e=>-e.size))}}},31843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const r=i(76790);function s(e,t,i=.5){return(1-i)*e+i*t}t.lerp=s,t.lerp2d=function(e,...t){const i=(0,r.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[n,a]=(0,r.sortBy)(i,(e=>e.x)),o=a.x-n.x,l=(e-n.x)/o;return s(n.y,a.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},75503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modeReduce=t.submatrixCollect=t.greatestHalf=t.leastVariantQuarter=t.leastMagQuarter=t.submatrixMode=t.submatrixStdDev=t.submatrixMagnitude=t.submatrixForEach=t.index1D=t.slice=t.matXvec=t.vecXvec=void 0;const r=i(40958),s=i(31586),n=i(48884),a=i(82647),o=i(70417);function l(e,t,i,r){const s=Math.floor(Math.max(0,t.row)),n=Math.ceil(Math.min(e.row,i.row)),a=Math.floor(Math.max(0,t.col)),o=Math.ceil(Math.min(e.col,i.col));for(let t=s;t(0,s.mapFinite)(e[t],(e=>n+=e*e)))),Math.sqrt(n)}function c(e,t,i,r){const n=new a.Average;return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),n.stdDev}function d(e,t,i,r){const n=[];return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),(0,o.mode)(n)}t.vecXvec=function(e,t){return e.map(((e,i)=>e*t[i]))},t.matXvec=function(e,t){return e.map(((e,i)=>{if(e.length!==t.length)throw new Error("misshaped matrix on row "+i);return(0,o.sumf)(e,((e,i)=>e*t[i]))}))},t.slice=function(e,t,i){const s=Math.max(0,t.row),n=Math.min(e.length,i.row),a=Math.max(0,t.col),o=Math.min(e[0].length,i.col);return(0,r.range)(s,n,(t=>e[t].slice(a,o)))},t.index1D=function(e,t,i){return t*e.col+i},t.submatrixForEach=l,t.submatrixMagnitude=u,t.submatrixStdDev=c,t.submatrixMode=d,t.leastMagQuarter=function(e,t){const i=t.col,r=t.row,s=[u(e,t,{col:i/2,row:0},{col:i,row:r/2}),u(e,t,{col:0,row:0},{col:i/2,row:r/2}),u(e,t,{col:0,row:r/2},{col:i/2,row:r}),u(e,t,{col:i/2,row:r/2},{col:i,row:r})];return(0,n.leastIndex)(s)},t.leastVariantQuarter=function(e,t){const i=t.col,r=t.row;return(0,n.leastIndex)([c(e,t,{col:i/2,row:0},{col:i,row:r/2}),c(e,t,{col:0,row:0},{col:i/2,row:r/2}),c(e,t,{col:0,row:r/2},{col:i/2,row:r}),c(e,t,{col:i/2,row:r/2},{col:i,row:r})])},t.greatestHalf=function(e,t){const i=t.col,r=t.row,s=[d(e,t,{col:0,row:0},{col:i,row:r/2}),d(e,t,{col:0,row:0},{col:i/2,row:r}),d(e,t,{col:0,row:r/2},{col:i,row:r}),d(e,t,{col:i/2,row:0},{col:i,row:r})];return(0,n.greatestIndex)(s)},t.submatrixCollect=function(e,t,i){const r=[];return l(e,t,i,(e=>r.push(e))),r},t.modeReduce=function(e,t,i){const o=Math.floor(t.col/i.col),u=Math.floor(t.row/i.row),c=new a.Average(Math.ceil(o*u));return(0,n.concat)(...(0,r.stepRange)(0,t.row,u,(i=>(0,r.stepRange)(0,t.col,o,(r=>(c.clear(),l(t,{col:r,row:i},{col:r+o,row:i+u},(t=>(0,s.mapFinite)(e[t],(e=>c.push(e))))),c.sampleMode))))))}},36372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stableContentShuffle=t.stableIndexShuffle=t.factors=t.primeSeeds=t.primeInt=t.primes=t.prng=t.prngOrderByClause=void 0;const r=i(76790),s=i(42659),n=i(31586),a=i(97238),o=i(50597),l=i(9103),u=i(55222);function c(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e),u=(s*i*i+n*i)%r,c=(a*i+o)%r;return Math.round((u*c+l)%r)}function d(e){return(0,u.encodeDigits)(a.PrimesPerBin,e,a.PrimeBins).map(((e,i)=>t.primes[i][e]))}t.prngOrderByClause=function(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e);return`(((${s}*${i}*${i}+${n}*${i})%${r})*((${a}*${i}+${o})%${r})+${l})%${r}`},t.prng=c,t.primes=[[353868013,472882027,479001599,517294153],[1012573,1230587,1355297,1572751],[756065159,812182027,899809343,989450477],[3959297,4514113,4823201,5133127],[573259391,666101999,694847533,746151647],[2275327,2770513,3073703,3511973],[173313197,182557181,203457869,222230231],[6054613,6189107,7752103,9852103]],t.primeInt=[1012573,1101689,1183811,1196089,1230587,1355297,1419641,1483733,1572751,2275327,2770513,3010349,3073703,3118691,3174823,3511973,3959297,4514113,4690451,4823201,5133127,5375327,6019889,6054613,6189107,7752103,7752103,9852103],t.primeSeeds=d,t.factors=(0,l.memoize)((e=>{const[i,r,s,o,l,u,c,h]=d(e%a.SeedCount),f=[i/r,s/o,l/u,c/h].map((e=>(0,n.sigFigs)(e,7)));return f.push(t.primeInt[e%t.primeInt.length]),f}),{maxSize:128,ttlMs:s.minuteMs}),t.stableIndexShuffle=function(e,t=1){return(0,r.sortBy)(e,((i,r)=>c(t,r,e.length)))},t.stableContentShuffle=function(e,t=1){return(0,r.sortBy)(e,(e=>(0,o.numericSha)(String(e)+t)))}},55222:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),s=i(22573),n=i(55835),a=i(32639),o=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,n.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,s.blank)(e))return;const t="-"===(e=(0,a.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),s=this.normalizeToken(t);return r.length>=i&&r===s}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const r=i(31586),s=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,r.toInt)(e)]??(0,s.toS)(e)}},38812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SquareMatrix=t.rotateSquareMatrix=void 0;const r=i(21605);t.rotateSquareMatrix=function(e,t){return 0===(0,r.normalizeRotation)(t)?e:new s([...e]).rotate(t).m};class s{constructor(e,t=1){if(this.m=e,this.ary=t,this.rows=Math.sqrt(e.length/t),this.rows!==Math.floor(this.rows))throw new Error(`Only square tuple matrices are supported: ${1===this.ary?"":this.ary}(${this.rows}×${this.rows}) != ${e.length}`)}index(e,t){return this.ary*(t+e*this.rows)}swap(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),s=i(65713);function n(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=n,t.safeUUID=function(){return(0,s.decuss)(n)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const o=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function v(e,t){let i=0,r=0;for(const s of e){if(null!=s){const e=t(s,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=v;class w{constructor(){r.set(this,0),s.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(a(this,s,null==n(this,s,"f")?e:n(this,s,"f")*n(this,r,"f")/(n(this,r,"f")+1)+e/(n(this,r,"f")+1),"f"),a(this,r,(t=n(this,r,"f"),++t),"f"))}get mean(){return n(this,s,"f")}}function b(e){const t=new w;for(const i of e)t.push(i);return t.mean}function S(e){const t=b(e);if(null==t)return;let i=0,r=0;for(const s of e)(0,u.isNumber)(s)&&(r++,i+=(s-t)*(s-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function _(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+a*(e-s)/n)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=b(t);if(null!=i){const e=(t.length-1)/2,r=v(t,((t,r)=>(t-i)*(r-e))),s=v(t,(e=>(e-i)**2));return 0===s?0:r/s}},t.variance=S,t.stdDev=function(e){return(0,l.map)(S(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,o.isEmpty)(e)&&(0,o.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},23624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64encodeBits=t.b64hammRatio=t.gz64decodeString=t.d=t.gz64encodeString=t.b64decode=t.b64encode=t.hex2b64=void 0;const r=i(38522),s=i(22573),n=i(97352);function a(e){const t=e.toString(16),i=t.length%2==0?"":"0";return Buffer.from(i+t,"hex").toString("base64")}function o(e){return BigInt("0x0"+Buffer.from(e,"base64").toString("hex"))}function l(e){return(0,r.gunzipSync)(Buffer.from(e,"base64")).toString("utf8")}t.hex2b64=function(e){return Buffer.from(e,"hex").toString("base64")},t.b64encode=a,t.b64decode=o,t.gz64encodeString=function(e){return(0,r.gzipSync)(Buffer.from(e,"utf8")).toString("base64")},t.d=l,t.gz64decodeString=l,t.b64hammRatio=function(e,t){return(0,s.mapNotBlank)(e,(e=>(0,s.mapNotBlank)(t,(t=>(0,n.hammRatioBigInt)(o(e),o(t))))))},t.b64encodeBits=function(e){return a(BigInt("0b0"+e.map((e=>1===e?"1":"0")).join("")))}},49076:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const s=r(i(48161)),n=i(19851),a=i(22573),o=i(41400),l=i(81168),u=i(28874);t.hostname=(0,n.lazy)((()=>u.Settings.hostname.value??s.default.hostname())),(0,o.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,a.blank)(e)&&!(0,a.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??s.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},43205:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemUserAgent=t.simpleUserAgent=t.userAgent=void 0;const r=i(72993),s=i(17344),n=i(96175),a=i(37805),o=i(81674),l=i(28874);function u(){return r.SimpleAppName+a.version}async function c(){return u()+" ("+(0,n.osFullName)()+") "+(0,s.EditionType)().toLowerCase()+"/"+await(0,o.t)()}t.userAgent=async function(){return l.Settings.allowUserAgent.valueOrDefault?c():u()},t.simpleUserAgent=u,t.systemUserAgent=c},72308:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLocalhost=t.isLoopback=t.myExternalIp4Addresses=t.myExternalIpAddresses=t.networkMacAddresses=t.myIpAddresses=void 0;const r=i(48161),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(96249),u=i(31586),c=i(68708),d=i(50213),h=i(81168);function f(){return(0,t.myIpAddresses)().filter((e=>!g(e)))}t.myIpAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.address))))),o.minuteMs),t.networkMacAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.mac)))).filter((e=>"00:00:00:00:00:00"!==e))),o.minuteMs),t.myExternalIpAddresses=f,t.myExternalIp4Addresses=function(){return f().filter((e=>!e.includes(":")))};const m=(0,s.lazy)((()=>(0,d.mkLogger)("net.ip"))),p=[/^(?:::ffff:)?127\.\d{1,3}.\d{1,3}.\d{1,3}$/i,/^::1$/];function g(e){return(0,a.notBlank)(e)&&(127===function(e){const t=e.split(".").map((e=>(0,u.toInt)(e)));return 4!==t.length||t.some((e=>null==e||!(0,u.within)(0,255,e)))?void 0:t}(e)?.[0]||p.some((t=>null!=t.exec(e))))}t.isLoopback=g,t.isLocalhost=function(e){return m().tap({msg:"isLocalhost",level:"info",result:!(0,a.blank)(e)&&((0,t.myIpAddresses)().includes(e)||(0,t.myIpAddresses)().includes((0,h.stripPrefix)(e,"::ffff:"))||g(e)),meta:{address:e}})}},96128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),v=i(34102),w=i(26293),b=new RegExp("^"+w.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==b.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const S=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=S.exec(e)}function _(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=_,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,n.blank)(e)){if(null!=_(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void M().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs});const M=(0,s.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,o.later)((()=>(0,v.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=_(e)?r.promises.reverse(e):r.promises.resolve4(e),5*a.secondMs);if(t===c.Timeout)return M().info("nslookup("+e+"): timeout"),e;const i=t.find(n.notBlank);return null==i?(M().warn("No name found for "+e),e):i}catch(t){return M().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,n.blank)(e)&&!(0,n.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),s=i(42659),n=i(31586),a=i(97790),o=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*s.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,n.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,a.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,o.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs})},78330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const r=i(40958),s=i(22573),n=i(45599),a=i(59455),o=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),h=i(63870),f=(0,n.defer)((()=>(0,o.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,a.toA)(await async function(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return f().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,r.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(f().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),s=i(38639),n=i(19851),a=i(59958),o=i(43334);t.isDocker=(0,n.lazy)((()=>o.isLinux&&((0,s.toBoolean)(process.env[a.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),s=i(19851),n=i(54993);t.isPacked=(0,s.lazy)((()=>!(0,n.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const r=i(45599),s=i(50213),n=i(84777),a=i(68284),o=i(63870),l=i(43334),u=(0,r.defer)((()=>(0,s.mkLogger)("platform.Pacman")));t.hasPacman=(0,r.defer)((()=>l.isLinux&&(0,a.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,n.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,o.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(22573),o=i(38639),l=i(59958),u=s.default.platform();t.inspectFlag=n.default.argv.includes("--inspect")||(0,o.isTrue)(n.default.env.NODE_INSPECT),t.isCI=(0,o.isTrue)(n.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,a.notBlank)(n.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===s.default.arch(),t.isArm=null!=/^arm\b/i.exec(s.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,a.notBlank)(n.default.env.APPIMAGE)||(0,a.notBlank)(n.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,a.notBlank)(n.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=n.default.versions.electron,t.isElectron=t.isMainElectron||(0,o.isTrue)(n.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const s=r(i(73024)),n=i(19851),a=i(43334);function o(e="/proc/cpuinfo"){if(a.isWin||a.isMac)return!1;try{return null!=s.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=o,t.isRaspberryPi=(0,n.lazy)((()=>a.isLinux_arm&&o())),t.procDeviceModel=(0,n.lazy)((()=>{try{return a.isLinux?s.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},94137:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.negateFilterName=void 0;const r=i(22573),s=i(51926),n=i(83556);t.negateFilterName=function(e){if((0,r.blank)(e))return;const t=/\s/.test(e)?e:(0,n.camel2words)(e).replace(/\bphoto structure\b/gi,"PhotoStructure");return t.match(/^not\b/)?t.replace(/^not\b/,"").trim():"not "+(0,s.stripPrefix)(t,"is ")}},78984:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Predicates=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(51926),o=i(50213),l=i(94137),u=(0,r.lazy)((()=>(0,o.mkLogger)("predicates.Predicates")));class c{static async accepted(e,...t){for(const i of t)for(const t of(0,n.values)(i)){const i=await t(e);if(!1===i||(0,a.isString)(i))return!1}return!0}static async rejected(e,...t){return!await c.accepted(e,...t)}static async explain(e,...t){const i=[],r=[],s=[];for(const o of t)for(const[t,l]of(0,n.entries)(o)){const n=await l(e);!0===n?i.push(t):!1===n||(0,a.isString)(n)?r.push(t):s.push(t)}return{accepted:i,rejected:r,notApplicable:s}}static async whyRejected(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))try{const i=await r(e);if(null==i||!0===i)continue;return(0,a.isString)(i)?i:(0,l.negateFilterName)(t)}catch(e){u().warn("whyRejected() caught from "+t,{error:e})}}static async logged({a:e,logger:t,msg:i,predicates:r}){const{accepted:n,rejected:a}=await c.explain(e,...r);return t.tap({msg:i,result:(0,s.isEmpty)(a),meta:{a:e,accepted:n,rejected:a}})}}t.Predicates=c},33995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncPredicates=void 0;const r=i(68708),s=i(94137);class n{static firstFalse(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!1===s(e))return t}static firstTrue(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!0===s(e))return t}static firstDefined(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i)){const i=s(e);if(null!=i)return{name:t,result:i}}}static accepted(e,...t){return null==n.firstFalse(e,...t)}static whyRejected(e,...t){return(0,s.negateFilterName)(n.firstFalse(e,...t))}}t.SyncPredicates=n},45643:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),s=i(59455),n=i(31562);t.existingPids=function(e){return(0,s.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,n.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(97790),w=i(59455),b=i(54993),S=i(54557),P=i(19851),_=i(50213),M=i(88158),T=i(409),E=i(78406),k=i(25764),D=i(99331),x=i(56519),C=i(46292),F=i(8769),A=i(83278),I=i(32144),O=i(29882),L=i(43334),R=i(24399),N=i(58261),B=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),j=10*p.secondMs;function z(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,O.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))B().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,T.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{B().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??L.isWin,r=await this.pidfiles(),s=await this.pids(r??[]);if((0,f.isEmpty)(s))return B().info("killOldProcs(): no pidfiles"),[];const n=[],a=[],o=await(0,N.pidInfos)(s);if(null!=o){for(const s of r){const r=await s.readJson();if(null==r){B().warn("killOldProcs(): failed to read pidfile "+s.base),await s.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){B().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+s.base,{json:r,pid:l}),await s.unlink("debug");continue}const u=o.find((e=>e.pid===l));if(null==u||!z(r,u)){B().debug("killOldProcs(): pid no longer present: unlinking "+s.base,{json:r,pidEntry:u}),await s.unlink("debug"),n.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(B().info("killOldProcs(): killing",{reason:d,json:r}),a.push(W(l,i,!1)),n.push({...r,...u}))}return a.length>0&&await Promise.allSettled(a),n}(0,F.onError)("Pids.killOldProcs(): failed to get process information")}}),a.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const a=e.pid;if(!(0,y.gt0)(a))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(a)?(i&&o(this,s,"f").delete(l),o(this,s,"f").getOrSet(l,(async()=>{const i=o(this,r,"m",n).call(this,e.pid),s=(0,v.opt)((0,M.Try)((()=>(0,O.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),a=t.getTime(),l={...e,cmd:s,startTime:a};return await i.writeJson_(l),B().debug("addPid() wrote "+i,l),i}))):(o(this,s,"f").delete(l),void B().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=o(this,r,"m",n).call(this,e);return(0,x.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{B().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==o(this,a,"f")||o(this,a,"f").ended)&&l(this,a,new E.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:k.EndableRanks.first}),"f"),o(this,a,"f")}cancelInterval(){o(this,a,"f")?.end(),l(this,a,void 0,"f")}}t.Pids=U,s=new WeakMap,a=new WeakMap,r=new WeakSet,n=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,C.configDir)(),(e=>new U(A.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const s=i(31421),n=i(48161),a=r(i(1708)),o=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),v=i(84968),w=i(48963),b=i(56519),S=i(84777),P=i(8103),_=i(45879),M=i(43334),T=i(24399),E=i(45643),k=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function D(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function x(e){if(M.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,_.readFileMaybe)("/proc/"+i+"/stat")));return k().tap({msg:"pidInfoProc",result:(0,o.compact)(t)})}(e);const t=(0,E.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,M.isWin?I:N)).filter((e=>D(e)&&t.includes(e.pid)));return k().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=D,t.pidInfo=async function(e){return(0,b.thenMap)(x([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,o.isEmpty)(e)?[]:(0,b.thenMap)((0,E.existingPids)(e),(t=>{const i=[a.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=x;const C="Get-Process",F="| Select-Object -Property Id,ProcessName,StartTime";function A(e){return(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).join(",")}async function I(e){if(T.PowerShell.instance().ended)return R(e);const t=[C,"-Id",A(e),"-ErrorAction SilentlyContinue",F].join(" ");return(0,b.thenMap)(T.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const O={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},L=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,o.isNotEmpty)(e)){const i=(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",L.join(","));const i=await(0,S.stdoutResult_)((0,P.wmic)(),t,O),r=(0,d.onlyReqValued)((0,p.parseFixed)(L,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return r.find((e=>e.pid===a.default.pid))||r.push({pid:a.default.pid,start:new Date(v.StartTs),cmd:"node "+a.default.title}),r}async function N(e){return t=(await(0,S.stdoutResult_)("ps",["-p",A(e),"-wwwo","pid,lstart,command"],{...O,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const B=(0,g.lazy)((()=>{try{if(M.isLinux)return(0,c.toGt0)((0,s.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){k().warn("clk_tck failed",{error:e})}return 100})),j=(0,g.lazy)((()=>Date.now()-(0,n.uptime)()*u.secondMs)),z=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=z.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,s=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(s)?{pid:i,cmd:r,start:new Date(j()+s/B()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(29882),o=i(97352);t.progressEvtToS=function(e){const t=(0,s.blank)(e.path)?null:(0,a.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,n.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,s.notBlank)(e.op)&&(0,o.within)(0,100,e.pct)}},41944:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),s=i(42659),n=i(31586),a=i(12089),o=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new o.TTLMap(15*s.secondMs))),t.recentDone=(0,r.lazy)((()=>new o.TTLMap(2*s.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,n.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,a.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),s=i(31586),n=i(409),a=i(78406),o=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends a.EndableInterval{constructor(e,t,i,s=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:s,rank:o.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=s,this.start=Date.now(),this.onInterval=(0,n.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,s.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,s.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},38156:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushProgressObserver=void 0;const r=i(31586),s=i(41944);t.PushProgressObserver=class{constructor(e,t){this.context=e,this.total=t,this.start=Date.now()}toJSON(){}incrProgress(e=1){this.onProgress(e+(this.current??0))}onProgress(e){this.current=(e??this.current??0)+1,(0,r.gte)(this.current,this.total)&&(this.done=!0),this.emit()}completed(){this.done=!0,this.current=this.total,this.emit()}emit(){(0,s.emitProgressEvt)({...this.context,pct:(0,r.pct)(this.current,this.total),elapsedMs:Date.now()-this.start,done:this.done})}}},24399:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),v=i(99331),w=i(56519),b=i(31562),S=i(84777),P=i(34102),_=i(43334),M=i(28874),T=i(63870),E="{ready}",k=" | ConvertTo-Json -Compress";function D(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=D,(0,o.later)((()=>(0,P.ee)().on("clearCache",(()=>x.instance.prior()?.clearMockResults()))));class x extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,S.execFile)("powershell",M.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${E}"}`,...(0,n.mapNotBlankOr)(M.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:E,fail:"Error",exitCommand:"exit",maxProcs:M.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,T.commandTimeoutMs)(),maxIdleMsPerProcess:a.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),M.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(M.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,k),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,s)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,s)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,k),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,n.blank)(t.stdout)||(0,n.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+D(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=x,x.instance=(0,s.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new x})),t.checkPowerShell_=async function(){const e=x.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,T.commandTimeoutMs)());if((0,n.blank)(t)){const t=await(0,b.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),s=i(38639),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toBoolean})}}t.BooleanSetting=a},90536:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).flatMap(parseFloat).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=o},75164:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).filter(r.notBlank).flatMap(s.toInt).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,s.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=o},10546:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),s=i(22573),n=i(45599),a=i(50213),o=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,n.defer)((()=>(0,a.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,o.trimQuotes)(e);return void((0,s.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,s.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),s=i(91655),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,s.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=a;class o extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=o},9945:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.FloatSetting=a},69589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.forceContextOrSetting=t.pickForceContext=void 0;const r=i(38639),s=i(68708),n=i(50989),a=i(76740),o=i(28874),l=(0,n.strEnum)("forceSync","forceFilters","skipPreviews","forceRebuildPreviews","skipAssetTagging","recountAllTags","skipAssetRepair");t.pickForceContext=function(e){return(0,s.pick)(e,...l.values)},t.forceContextOrSetting=function(e){const t={...(0,s.pick)(e??{},"retries","halt","path"),...(0,s.fromEntries)(l.values.map((t=>[t,e?.[t]??(0,r.isTrue)(o.Settings[t]?.valueOrDefault)])))};return t.retries??(t.retries=0),t.halt??(t.halt=new a.Abortable),t}},74589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt})}}t.IntegerSetting=a},4175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),s=i(22573),n=i(38639),a=i(42659),o=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function v(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function w(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){_(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&v(),y("strictDeduping",e)&&w(),(y("optOut",e)||y("noNetwork",e))&&M()},t.handleDeprecatedSettings=async function(){if((0,n.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,s.blank)(m.Settings.assetPathnameFormat.value)&&(0,s.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*a.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=v,t.setStrictDeduping=w;const b=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],S={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function _(e){for(const t of b)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:S;for(const[e,i]of(0,o.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function M(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=_,t.disableExternalNetworkRequests=M},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),s=i(53265),n=i(87652);class a extends n.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,s.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=a},23561:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.OptionalFloatSetting=a},69005:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=a},87652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=s},4936:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathToLibraryAsset=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(55835),l=i(51926),u=i(50213),c=i(81168),d=i(79842),h=i(21330),f=i(51275),m=i(29882),p=i(28874),g=(0,s.lazy)((()=>(0,u.mkLogger)("settings.PathToLibraryAsset")));function y(e){return(0,a.blank)(e)?"":"'"+e.replace(/'/g,"′")+"'"}t.pathToLibraryAsset=function(e,t){const i=(0,d.datedToDateTime)(e)??(0,o.map)((0,h.datedToISO)(e),(e=>r.DateTime.fromISO(e)));if(null==i||!i.isValid)return g().tap({msg:"pathToLibraryAsset(): failed to convert to a valid date",result:void 0,meta:{capturedAt:e,src:t,dt:i}});const s=(0,f.hasZone)(e),a=p.Settings.assetPathnameFormat.valueOrDefault,u=(0,c.splitKeep)(a,/((?:GRAND)?PARENT|BASE|NAME|EXT|ISO)/g);for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),s=i(83556);t.nameFromEnv=function(e){return(0,s.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,s.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const a=i(19851),o=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),v=i(40583),w=i(81168),b=i(44198),S=i(96706),P=i(34102),_=i(28283),M=i(81075),T=i(98778),E=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,a.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?n(this,r,"m",s).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?n(this,r,"m",s).call(this,e??t)+": "+i:null==this.fromEnv(e)?n(this,r,"m",s).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,S.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,b.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,o.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,o.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,o.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return M.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,b.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&S.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,b.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&S.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,S.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],E.WrapComments);function i(e,i){(0,o.isEmpty)(i)||t.push(...(0,w.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],E.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,w.wrap)(["",e+": "+r],E.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,T.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,T.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,T.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,s=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),s=i(76760),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),v=i(79840),w=i(7282),b=i(12801),S=i(4328),P=i(70488),_=i(84248),M=i(5531),T=i(99315),E=i(34365),k=i(34580),D=i(96706),x=i(50274),C=i(33866),F=i(52086),A=i(48584),I=i(45969),O=i(43334),L=i(24540),R=i(70379),N=i(71300),B=i(33209),j=i(48987),z=i(68268),V=i(61208),W=i(99023),U=i(30577),H=i(1485),q=i(19861),G=i(55111),$=i(30933),J=i(22859),K=i(71988),Y=i(38483),Z=i(90536),X=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),se=i(9945),ne=i(74589),ae=i(844),oe=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,n.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new oe.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new ne.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new ne.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>q.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>H.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:H.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>H.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>O.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new ne.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!O.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>O.isMac?"100ms":O.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new se.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new ne.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>b.PriorityClasses.BelowNormal,strEnum:b.PriorityClasses}),maxMemoryMb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:M.CheckpointTypes,defaultValue:M.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:E.SynchronousModes,defaultValue:E.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:T.RepairModes,defaultValue:T.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to apply a migration, vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 2 minutes should be very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"2m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:C.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>O.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new ne.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,k.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new ne.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new ne.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new ne.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,L.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,$.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:x.SidecarExts,defaultValue:x.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new se.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,$.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:F.CropStrategies.attention,strEnum:F.CropStrategies}),videoFrameAtSec:new se.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,a.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new ne.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(O.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>B.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new ne.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new ne.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:A.SharpFailOns.truncated,strEnum:A.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>j.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:ae.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new se.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:z.KeywordReparentingStrategies.move,strEnum:z.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function be(e){const i=((0,l.blank)(e)?"":e).split(s.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,a.uniq)(i).filter(l.notBlank).join(s.delimiter)}function Se(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=be,t.pathWithDefaults=(0,n.lazy)((()=>be((0,D.getEnv)("PATH")))),t.allSettings=(0,n.lazy)((()=>(0,o.sortBy)((0,d.values)(t.Settings),Se))),t.persistedSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,n.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,n.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),s=i(31586),n=i(7282),a=i(49776),o=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),v=i(15674),w=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{w.Settings.configDir.opts.defaultValue=o.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=a.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,n.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,n.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,s.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),v=i(54993),w=i(50213),b=i(81168),S=i(83556),P=i(87290),_=i(98314),M=i(34102),T=i(83278),E=i(95696),k=i(60865),D=i(4175),x=i(83179),C=i(81075),F=i(28874),A=i(41692),I=i(84438),O=i(32707),L=i(6707),R=i(98778),N=i(55018),B=i(10357),j=(0,r.lazy)((()=>(0,w.mkLogger)("settings.SettingsIO")));function z(e){return(0,P.libraryDataDirPosixFile)(e)?.join(I.SettingsToml)}async function V(e=(0,O.systemSettingsFile)()){if(null!=e)return X(T.BaseFile.for(e))}async function W(){try{return(0,a.toNotBlank)((await(0,L.readTomlFile_)((0,O.systemSettingsFile)()))?.[F.Settings.libraryDir.name])}catch{return}}function U(e){return(0,L.readTomlFile_)(e).then((e=>e?.version),(()=>{}))}function H(){return U((0,O.systemSettingsFile)())}function q(e){return U(z(e))}function G(){t.libraryHasSettings.refresh()}function $(e){const t=z(e);return j().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:F.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}async function J(e,i){if(null==e)return void j().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),s=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...ie("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","This is the version of PhotoStructure that wrote this file--please don't edit the following line.")),r.push(...(0,R.stringifyToml)({version:(0,t.versionForSettings)()})),r.push("","");let s="";for(const e of i){const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==s&&(s=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,M.ee)().emitDebounced("settingsChanged")}(s,i),j().info("writeToml(): wrote settings",{dest:s,file:e,nonDefaults:(0,x.settingsToObj)(i),wip:r}),r){const t=await(0,L.readTomlFile_)(s),i=await(0,L.readTomlFile_)(e);(0,u.eql)(t,i)?(j().info("Equivalent contents",{dest:s,file:e,a:t,b:i}),await s.unlink()):(j().info("Archiving prior, different contents",{dest:s,file:e}),await e.renameYMDHMS_({subdir:"archive"}),await s.unwip_())}}async function K(e=(0,O.systemSettingsFile)()){const t=E.PosixFile.forMaybe(e);return null!=t&&await J(t,(0,F.persistedSystemSettings)()),t}function Y(e){return X(z(e))}async function Z(e){await(0,P.setupLibraryDataDir_)((0,a.firstNotBlank)(e,F.Settings.libraryDir.value));const i=z(e);return j().info("writeLibrarySettings()",{file:i}),null!=i&&(await J(i,(0,F.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function X(e){if(null==e)return[];const t=j().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await Q(e);return(0,s.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,_.errorToS)(e)),[]}}async function Q(e){const t=j().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,L.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const n=[],a=(0,s.compact)((0,p.entries)(r).map((([e,t])=>{if("version"===e)return;const i=(0,F.getSettingByNameOrKey)(e);if(null==i)n.push(`Failed to import "${e}"${(0,m.mapOr)((0,F.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;n.push(e)}})));return t.info("loaded",{settings:(0,x.settingsToObj)(a),warnings:(0,s.toNotEmpty)(n)}),await(0,D.handleDeprecatedSettings)(),(0,D.handleMetaSettings)(a),{settings:a,warnings:n}}t.librarySettingsFile=z,t.readSettings=(0,r.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await Y()}),o.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return F.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=H,t.librarySettingsVersion=q,t.maybeUpgradeSystemSettings=async function(){(0,t.versionForSettings)()!==await H()&&await K()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&(0,t.versionForSettings)()!==await q()&&await Z()},t.libraryHasSettings=(0,r.lazy)((()=>$())),t.libraryHasSettings.unset=()=>{j().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,M.ee)().on("clearCache",G),(0,M.ee)().on("settingsChanged",G),F.Settings.libraryDir.watchLater(G)})),t._libraryHasSettings=$,t.versionForSettings=(0,r.lazy)((()=>(0,k.baseVersion)())),t.writeSystemSettings_=K,t.writeAllSettings_=function(e){return J(E.PosixFile.for(e),(0,F.persistedSettings)())},t.readLibrarySettings=Y,t.writeLibrarySettings_=Z,t._readSettings=X,t.importFileSettings_=Q;const ee=(0,r.lazy)((()=>new Set([F.Settings.noNetwork,F.Settings.httpPort,F.Settings.license,F.Settings.logStdout,F.Settings.logLevel].map((e=>e.key)))));function te(){for(const e of(0,p.values)(F.Settings))ee().has(e.key)||e.unset();(0,M.ee)().emit("settingsChanged")}function ie(...e){return(0,d.flatten)(e.map((e=>(0,b.wrap)(e,B.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),F.Settings.libraryDir.unset(),await K()},t.clearSettings=te,t.nukeSettings=async function(){te(),await(E.PosixFile.forMaybe((0,O.systemSettingsFile)())?.unlink("trace")),await(E.PosixFile.forMaybe(z())?.unlink("trace")),(0,M.ee)().emit("clearCache"),A.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...ie("",`Welcome to PhotoStructure! These are the settings for version ${(0,k.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...ie("","The following settings categories are stored in the system settings.toml:","",...(0,n.sort)([...C.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,n.sort)([...C.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...ie("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...ie("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const n=`${e.key} or ${e.name}`,a={...e.addToJSON()};(0,s.mapNotEmpty)(e.altKeys,(e=>a.aliases=(0,h.orList)(e)));const o=(0,p.entries)(a).map((([e,t])=>`${(0,b.capitalize)((0,S.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,s.isNotEmpty)(o)&&o.push(""),i.push(...ie((0,g.padding)("-",n.length),n,(0,g.padding)("-",n.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...o,`${e.key}=${(0,f.stringify)((0,v.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(98553),o=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,a.stringify)(e)}t._join=c;function d(e){return(0,o.map)(function(e){const t=(0,n.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,s.compact)((0,l.toA)(JSON.parse(t)).map(n.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,s.compactBlankish)(t.split(e));return[t]}}(e),s.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,n.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,s.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,s.isEmpty)(e)||(this.value=this.toValidValues((0,s.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,s.isEmpty)(this.values)}isNotEmpty(){return(0,s.isNotEmpty)(this.values)}toNotEmpty(){return(0,s.toNotEmpty)((0,s.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=s},72564:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),s=i(98553),n=i(55835),a=i(58305);class o extends a.StringArraySetting{constructor(e){super({toEnv:e=>(0,n.map)(e,(e=>(0,s.stringify)((0,r.uniq)(e)))),fromEnv:t=>{return i=t,s=e.strEnum,(0,r.compact)((0,a.splitStringArray)(i)?.map((e=>s.getCI(e))));var i,s},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=o},80372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),s=i(81168),n=i(83179);class a extends n.Setting{constructor(e){super({toEnv:o,fromEnv:o,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function o(e){return null==e?void 0:(0,s.trimQuotes)(e)}t.StringSetting=a},32707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),s=i(55835),n=i(46292),a=i(84438);t.systemSettingsFile=function(){return(0,s.map)((0,n.configDir)(),(e=>(0,r.join)(e,a.SettingsToml)))}},80496:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),s=i(44652),n=i(22573),a=i(76850),o=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,a.debom)(e),(0,n.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,n.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,s.readFileSync)(t)):void 0}catch(e){return void(0,o.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,n.mapNotBlank)(e,(async e=>f(await(0,s.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,s.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),s=i(96249),n=i(98553),a=i(68708),o=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const s=e+" = "+(0,n.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[s]:(0,o.wrap)(s.split("\n"),i)}t.stringifyToml=function(e){return(0,s.flatten)((0,a.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,o.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},63225:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyPsEnvSettings=void 0;const r=i(68708),s=i(81168),n=i(44198),a=i(59958),o=i(28874);t.verifyPsEnvSettings=function(e=(0,n.env)(),t=.25){const i=[];for(const n of(0,r.keys)(e).filter((e=>{const t=e.toUpperCase();return t.startsWith("PS_")&&!a.IgnorableEnvKeys.includes(t)}))){const r=e[n],a=(0,o.ciSettings)().lookup(n);if(null!=a){const e=a.value.whyInvalidEnvValue(r);null!=e&&i.push({envKey:n,msg:e})}else{const e=(0,o.ciSettings)().lookupNearest(n,t);null==e?i.push({envKey:n,msg:`No setting was found like "${n}"`}):(0,s.equalsIgnoreCase)(e.key,n)||i.push({envKey:n,msg:`Did you mean setting "${e.value.key}"?`})}}return i}},10357:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const r=i(54993),s=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=a(e[t]);if(null!=i)return i}};const n=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function a(e){const t=(0,s.extractFloat)(e);if(null==t)return;const i=(0,r.toS)(e).toLowerCase();for(const e of n)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),s=i(81168);t.bname=function(e,t=!0){let i=(0,s.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,s.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),h=i(31586),f=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),v=i(81168),w=i(76596),b=i(79842),S=i(66649),P=i(21330),_=i(98725),M=i(928),T=i(54261),E=i(89724),k=i(17415),D=i(88600),x=i(51275),C=i(29882),F=i(17217),A=i(68284),I=i(57902),O=i(28874),L=i(65162),R=i(71300),N=i(14036),B=i(61424),j=(0,s.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function z(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,f.isObject)(e)&&(0,o.notBlank)(e.nativePath)&&(0,b.isDated)(e.date)&&(0,o.notBlank)(e.src)}t.capturedAtSrcFromTags=z,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class U{static fromAssetFile(e){return(0,d.map)((0,E.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>U.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof U?e:W(e)?new U(e):void 0}constructor(e){var t;this.nativePath=(0,F.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,h.toGt0)(e.local)??(0,E.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,b.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(O.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,S.datedToMillis)(e.mtime)??(0,A.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:U.name,...(0,f.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,_.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,k.fmtOffsetMinutes)});return null==t?void 0:new U({...e,date:t})}spread(e){return new U({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,k.fmtOffsetMinutes)(this.offset)}get isFromTags(){return z(this.src)}get isInferred(){return!z(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,E.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,w.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,x.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,T.hasTime)(this.date)}hasMillis(){return(0,h.gt0)((0,M.getMillisecond)(this.date))}toMillis(){return(0,S.datedToMillis)(this.date)}get isValid(){return(0,D.isValidDate)(this.date)}get zoneName(){return(0,r.offsetMinutesToZoneName)(this.offset)??(0,x.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,k.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?O.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,b.datedToStartDateTime)(this.date)??(0,b.datedToDateTime)(this.date);if(null!=i)return{start:(0,E.datedToLocal)(i.minus(t)),end:(0,E.datedToLocal)(i.plus(t))};j().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:O.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),r=Math.max(t,e.fuzzyPrecisionMs());return j().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,b.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:r}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:r}})}}function H(e,t){if(null==e)return;const i=(0,n.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>U.for(e))));for(const r of t){let t=e[r],s=r;if((0,D.isValidDate)(t)){if((0,k.isValidZone)(e.tz)&&(!(0,x.hasZone)(t)||R.OverrideUTCZoneTags.includes(s))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,o.blank)(e.tzSource)?"":" from "+(0,v.stripPrefix)(e.tzSource,"from ");s+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,E.datedToLocalSec)(t),date:t,src:s,precisionMs:(0,b.datedToPrecisionMs)(t),rawValue:e[r]?.rawValue})}}const r=(0,p.leastBy)(i,(e=>(0,b.datedToStartTs)(e.date)));if(null==r)return;const s=i.filter((e=>(0,u.eql)(e.date,r.date)||e.precisionMs<=r.precisionMs&&(0,b.datedOverlap)({a:e.date,b:r.date,aPrecisionMs:e.precisionMs,bPrecisionMs:r.precisionMs}))),a=(0,p.leastBy)(s,(e=>[Math.floor(e.localSec/1e6),(0,x.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return j().debug("capturedAtFromTags()",{least:r,overlapsWithLeast:s,earliest:a}),a}function q(e,t){if(O.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,n.uniq)([(0,L.bname)(e,!0),(0,L.bname)(e,!1)])){const e=(0,_.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,b.datedToPrecisionMs)(e),l.secondMs])}}}function G(e){if(O.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,_.extractDateFromPath)(e.pathsForDateParsing)}}async function $(e){if(O.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=U,t.bestCapturedAt=function(e){const t=(0,a.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const r=await e.mtimeMs();function s(t,i){return W(i)?U.for(i):null!=i&&null!=i.date&&(0,D.isValidDate)(i.date)?U.for({nativePath:e.nativePath,date:i.date,local:(0,E.datedToLocal)(i.date),src:(0,v.uniqPath)([t,i.src]),mtime:r,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const n=function(e,t){return null==e||t||!O.Settings.usePathsToInferDates.valueOrDefault||!O.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,C.containedByNativePath)({ancestor:O.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),a=s("tags",H(t,O.Settings.capturedAtTags.values))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??s("tags",H(t,O.Settings.capturedAtTagsFallback.values))??(n?void 0:s("bname+stat",await(0,B.extractStatBname)(e)))??(n?void 0:s("path+stat",await(0,B.extractStatPathTime)(e)))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??(n?void 0:s("bname",q(e,t)))??(n?void 0:s("path",G(e)))??(O.Settings.useStatToInferDates.valueOrDefault?s("stat",await $(e)):void 0);return j().tap({level:I.LogLevels.debug,msg:"extractCapturedAt()",result:a})},t.capturedAtFromTags=function(e){return H(e,O.Settings.capturedAtTags.values)},t.capturedAtFromBasename=q,t.capturedAtFromPath=G,t.capturedAtFromStat=$},70379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const r=i(31586),s=i(97352),n=i(95696),a=i(47783),o=i(16170);function l(e){if(null!=e&&(0,o.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,r.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,s.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=n.PosixFile.for(e);return l(await(0,a.readRawTags)(t,!1))}},47783:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const s=i(77988),n=r(i(76760)),a=r(i(1708)),o=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(23838),f=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),v=i(12168),w=i(56038),b=i(4867),S=i(36557),P=i(98247),_=i(21330),M=i(98725),T=i(23467),E=i(88561),k=i(95696),D=i(17217),x=i(16287),C=i(50213),F=i(17921),A=i(7282),I=i(88158),O=i(23560),L=i(28874),R=i(12089),N=i(45255),B=i(81168),j=i(63870),z=i(15674),V=i(28544),W=i(43207),U=i(75767),H=i(12788),q=i(80495),G=i(14036),$=i(67083),J=i(3432),K=i(28630),Y=i(15912),Z=i(30748),X=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),re=i(61424),se=i(8791),ne=(0,o.lazy)((()=>(0,C.mkLogger)("exiftool.ExifTool")));let ae=!1;t.addInstanceIdsToTags=function(e){ae=e},t.setExifToolProcs=function(e){return L.Settings.exiftoolProcsPerChild.envValue=e,ue()};const oe=(0,o.lazy)((()=>new S.BatchClusterObserver("ExifTool",new s.ExifTool({useMWG:L.Settings.useMWG.valueOrDefault,backfillTimezones:L.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:L.Settings.defaultVideosToUTC.valueOrDefault,...(0,S.batchClusterOptions)((0,A.isTest)()?8:(0,O.isSyncService)()?L.Settings.exiftoolProcsPerChild.value??(0,z.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=oe();return e.ended?oe.refresh():e}function ue(e=!1){return(0,d.map)(oe.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,b.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(oe.prior(),(e=>e.ended?void 0:(0,b.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,j.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,f.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,D.toNativePath_)(e))}async function he(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function fe(e){const t=[];return L.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*v.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,B.includesIgnoreCase)(L.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return ne().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const r=i??await(0,te.readMimeType)(e),s=await e.sidecar(),n=(0,X.isImageMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,a=(0,X.isVideoMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,o=L.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await s.exists(),l=n||a||o;return ne().tap({msg:"writeTagDest()",result:l?s:e,meta:{src:e,tagName:t,mimetype:r,writeMetadataToSidecarsIfImage:n,writeMetadataToSidecarsIfVideo:a,writeMetadataToSidecarsIfSidecarExists:o}})}async function pe(e,i=!0){const r=k.PosixFile.for(e);if(r.isSidecar()&&(i=!1),!await r.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(r.nativePath),void ne().debug("readRawTags("+r+"): invalid file, returning null.");const s=await(0,t._readRawTags)(r.nativePath);if(null==s||!i)return s;ne().trace("readRawTags()",{pf:r,pickedFileTags:(0,f.pick)(s,"tz","tzSource",...L.Settings.capturedAtTags.values)});const n=[];for(const e of await r.jsonSidecars())n.push([e,(0,K.readJsonSidecar)(e,s.tz)]);for(const e of await r.existingExifSidecars())n.push([e,(0,t._readRawTags)(e.nativePath)]);const a={original:{},MIMEType:(0,u.mapNotBlank)(s.MIMEType,X.normalizeMimetype),...s},o=[];for(const[e,i]of n){if(null==i)continue;const r=await i;if(null==r)continue;const s=(0,f.omit)(r,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,f.values)(s))?((a.sidecars??(a.sidecars=[])).push(e.base),o.push(...(0,g.toA)(r.History)),(0,I.assignNullishFields)(a.original,(0,f.pick)(a,...(0,f.keys)(s))),(0,f.assignFields)(a,s),ne().debug("readRawTags() sidecar had values",{sidecar:e.base})):ne().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return a.inferred=(0,$.getInferredHistoricValues)(o,e),(0,I.assignNullishFields)(a,a.inferred),a.Rotation=(0,Q.orientationToRotation)(a.Rotation),ne().debug("readRawTags() final",{pf:r,inferred:a.inferred,pickedResult:(0,f.pick)(a,"tz","tzSource",...L.Settings.capturedAtTags.values)}),a}async function ge(e,t){return null==t?void 0:(0,w.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,r=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,X.normalizeMimetype);if((0,u.blank)(r))return void ne().debug("No mimetype for "+i);const n={...t.inferred??{},...t};if(n.inferred??(n.inferred={}),n.original??(n.original={}),L.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const t=n[e];if((0,p.isString)(t)){const i=(0,M.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(ne().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),n[e]=i)}}const o=!await(0,re.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,n,o);if(ne().debug("parseTags()",{tzMeta:l,skipSiblingInference:o}),null!=l?.tz){const e=n.tzSource!==s.defaultVideosToUTC&&void 0;for(const t of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const i=n[t];i instanceof s.ExifDateTime&&(n[t]=(0,_.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,f.assignUndefinedFields)(n.original,n,"tz","tzSource"),(0,f.assignFields)(n,l),(0,f.assignFields)(n.inferred,l)}const c=o?(0,Z.extractMakeAndModel)(n):await(0,re.inferMakeAndModel)(e,n);c.Make!==(0,Z.make)(n.Make)&&(n.original.Make=n.Make,n.inferred.Make=c.Make),c.Model!==(0,Z.model)(c.Make,n.Model)&&(n.original.Model=n.Model,n.inferred.Model=c.Model),!(0,u.blank)(L.Settings.defaultCopyright.valueOrDefault)&&(0,H.isExifUnset)(n.Copyright)&&(n.Copyright=L.Settings.defaultCopyright.valueOrDefault);const d=(0,Y.extractLensMakeModel)(n),h=await(0,V.extractCapturedAt)(e,n,o);if(null==h)return void ne().info("No capturedAt for "+e);!o&&h.isInferred&&(n.inferred.capturedAt=h);const m=(0,q.extractExposureSettings)(n),g=await(0,ie.extractSizeInfoFromFile)(e,n);if(null==g)return void ne().info("No size info for "+i);const y={...c,mimetype:r,capturedAt:h,exposureSettings:m,...(0,se.extractTitleDescription)(n),...d,cameraId:(0,U.cameraIdFromTags)(n),imageId:(0,U.imageIdFromTags)(n),lensId:(0,U.lensIdFromLensInfo)({...d,...(0,f.pick)(n,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(n),tz:n.tz,rating:(0,ee.extractRating)(n)};(0,A.isTest)()&&(y.__parsedBy__=a.default.pid);const v={...n,...y};return ne().debug("parsedTags",{nativePath:i,skipInference:o,...y,inferred:n.inferred,original:n.original,pickedResult:(0,f.pick)(v,"capturedAt","tz","tzSource","Make","Model")}),(0,f.definedValues)(v)}catch(e){return void ne().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,f.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,f.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,T.eqlAsync)(e.sha(),t.sha())||await(0,T.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=k.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,D.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,D.toNativePath_)(e),["-"+t]);return(0,I.pluckCaseInsensitive)(i,t)}catch(e){return void ne().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=he,t.overwriteTags_=async function(e,t){try{await(0,w.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await fe(e)),e.clearThisAndParent()}))}catch(i){ne().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,w.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=fe,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,w.time)("exiftool.writeTags:"+e,(async()=>{const r=new h.MultiMap;for(const[s,n]of(0,f.entries)(t)){const t=await me(e,s,i);r.add(t.nativePath,[s,n])}for(const[t,i]of r.entriesArray()){const r=k.PosixFile.for(t),s=(0,f.fromEntries)(i);ne().info("writeTags()",{src:e,dest:t,t:s}),await le().write(r.nativePath,s,await fe(r)),L.Settings.overwriteOriginal.valueOrDefault||await he(r),r.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,x.nativePathIsFile)(e))return ne().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);ne().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...L.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,G.isVideoExt)(n.default.extname(e))?[]:["-fast"]],r=await(0,w.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{ne().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==r)return;ne().debug("_readRawTags()",{nativePath:e,pickedTags:(0,f.pick)(r,"tz","tzSource",...L.Settings.capturedAtTags.values)}),r.MIMEType=(0,u.mapNotBlank)(r.MIMEType,X.normalizeMimetype),r.GPSDateTime??(r.GPSDateTime=(0,P.concatDateTime)(r.GPSDateStamp,r.GPSTimeStamp));for(const e of(0,f.keys)(r)){const t=r[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete r[e])}const s=(0,l.compactBlanks)([r.Error,...r.errors??[],r.Warning].map(y.toS));return(0,l.isNotEmpty)(s)&&(r.problems=s),ae&&(r.__instance=(0,F.safeUUID)()),r}}),t.parseTags=ge},75767:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(98553),o=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),h=i(54993),f=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),v=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const w=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function b(e){const t=null==e?[]:e.filter((([,e])=>!(0,n.blank)(e)));return 0===t.length?void 0:(0,a.stringify)((0,u.fromEntries)(t))}function S(e){return(0,h.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new o.MultiMap,r=[];for(const a of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(s=e[a])||(0,n.blankish)(s)||(0,l.isNumber)(s)&&(0===s||1===s)||null!=t.zeroesRe.exec((0,h.toS)(s)))continue;const o=e[a],u=S(e[a]),c=(0,t.Tag2SynonymGroup)().get(a);if(null!=c){if(i.includes(c,o)||i.includes(c,u))continue;i.add(c,o)}r.push([a,(0,l.gt0)(o)?o:u])}var s;return b(r)}function _(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function M(e){if((0,n.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([_(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(_)):(0,u.compactBlankValues)(t)}function T({a:e,b:t,field:i,desc:r,parser:s}){const n=s(e[i]),a=s(t[i]),o=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==n||null==a||(0,l.approximates)(n,a,o)?void 0:"Different "+r+": "+e[i]+" ≠ "+t[i]}function E(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,n.blank)(e.lensMake)||(0,n.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,r.lazy)((()=>{const e=new Map;for(const t of w){const i=t[0];for(const r of t)e.set(r,i)}return e})),t.Tag2Synonyms=(0,r.lazy)((()=>{const e=new Map;for(const t of w)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=b,t.renderExifUidId=P,t.decodeExifUid=M,t.findInequalFields=function(e,i){const r=M(e),n=M(i);if(null==r||null==n||e===i)return;const a=(0,f.intersection)((0,u.keys)(r),(0,u.keys)(n)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of a){const t=r[e],i=n[e];if(S(t)!==S(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of w){const t=(0,u.pick)(r,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(n,...e);if((0,u.isEmptyObj)(i))continue;const a=(0,u.values)(t).map(h.toS),o=(0,u.values)(i).map(h.toS);if((0,s.includesAny)(a,o))continue;const l=(0,f.least)((0,u.keys)(t)),c=(0,f.least)((0,u.keys)(i));return{aKey:l,aValue:r[l],bKey:c,bValue:n[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>T({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>T({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>T({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>T({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return E({...(0,v.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=E,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const r=i(22573),s=i(54993),n=/undefined|null|none|n\/a|unknown/i;function a(e){return null==e||(0,r.blank)(e)||n.test((0,s.toS)(e))}t.isExifUnset=a,t.toExifDefined=function(e){return a(e)?void 0:e}},80495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const r=i(19851),s=i(22573),n=i(31586),a=i(68708),o=i(54993),l=i(50213),u=i(97352),c=(0,r.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,s.firstNotBlank)((0,o.toS)(e.ExposureTime),(0,o.toS)(e.ShutterSpeed),(0,o.toS)(e.ShutterSpeedValue),(0,o.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,a.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,n.gt0)(e))return e;const[t,i]=(0,o.toS)(e).split("/").map((e=>(0,n.toInt)(e)));return(0,n.gt0)(t)&&(0,n.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,n.toFloat)(e);return(0,n.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),s=i(40958),n=i(96249),a=i(23838),o=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,o.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,o.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new a.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,n.flatten)((0,o.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function v(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=v,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return v(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return v(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return v(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return v(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return v(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return v(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),h=i(50989),f=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),v=i(50213),w=i(81168),b=i(66649),S=i(17415),P=i(29882),_=i(95696),M=i(17217),T=i(28874),E=i(47783);function k(e,t){return(0,d.entries)(t??{}).map((([t,i])=>D({action:e,key:t,value:i})))}function D({action:e,key:t,value:i,ts:s}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:r.ExifDateTime.fromMillis(s??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,h.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=k,t.mkHistoryRecord=D,t.InferAction="infer";const x=(0,s.lazy)((()=>(0,v.mkLogger)("tags.History")));function C(e,t){if(null==e||null==e.History||(0,f.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function F(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,o.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function A(e){if(null==e)return;const t={};for(const[i,r]of(0,d.entries)(e))(0,w.isFirstCharAZ)(i)&&(t[i]=r);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,S.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function I(e,i,r){if(null==e||(0,o.blank)(e))return void x().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const s=(0,M.toNativePath_)(e),a=await(0,E._readRawTags)(s),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!C(a,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...r??{}};if((0,n.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void x().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:r,tagsToWrite:c});x().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:r});const h=_.PosixFile.for(e);return await(0,E.overwriteTags_)(h,c),h.clearThisAndParent(),u}t.tagsContainHistory=C,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const s=(0,m.toA)(e);if((0,n.isEmpty)(s))return{};const l=(0,a.sortBy)(s.filter((e=>(0,w.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,b.datedToMillis)((0,o.mapNotBlank)(e.When,(e=>r.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,o.notBlank)(t)){const r=F(e);(0,o.blank)(r.nativePath)||(0,P.eqlNameWithoutExt)(r.nativePath,i)?u[t]=r:x().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=F,t.inferredToTags=A,t.ensureInferredHistoryRecords=async function(e,i,r){const s=k(t.Actions.infer,r),n=(T.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?A(r):void 0)??{};return T.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(n.Source=e.nativePath),x().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:s,additionalTags:n}),I(i,s,n)},t.ensureHistoryRecords=I},3432:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const s=r(i(53705)),n=i(77988),a=i(19851),o=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),h=i(17415),f=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),v=i(61424),w=(0,a.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function b(e,t,i){{const e=S(t);if(null!=e&&(0,h.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,h.isValidZone)(t.tz)||t.tzSource===n.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,o.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof n.ExifDateTime&&(0,h.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,v.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function S(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,s.default)(t,i),r=(0,h.normalizeZone)(e);return w().tap({msg:"zoneFromLatLon()",result:r,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,f.isValidDate)(i))for(const r of g.Settings.capturedAtTags.values){const s=(0,u.toDated)(t[r]);if(null==s||(0,f.isValidDate)(s))continue;const n=Math.round(15*i.diff(s,"minutes").as("minutes")/15),a=(0,h.normalizeZoneOffsetMinutes)(n),o=0===a?void 0:(0,h.normalizeZone)(a);if(null!=o)return w().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:o.name,tzSource:"infer:filename (diff with "+r+")"},meta:{dt:(0,c.datedToISO)(s),rawTzoffsetMinutes:n,normalizedOffsetMinutes:a}})}}t.maybeInferTimezone=async function(e,t,i){return w().tap({msg:"maybeInferTimezone()",result:await b(e,t,i)})},t.zoneFromLatLon=S,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const r=i(77988),s=i(40958),n=i(22573),a=i(38639),o=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),h=i(48884),f=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const s=(0,p.normalizeZone)(e?.formatted),n=r.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:s??t??r.UnsetZone});if(!0===n?.isValid)return n}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,n.toNotBlank)(e.title),Description:(0,n.toNotBlank)(e.description),GPSLatitude:(0,h.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,f.validLat)(e)?e:void 0)),GPSLongitude:(0,h.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,f.validLon)(e)?e:void 0)),GPSAltitude:(0,h.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,o.map)(e.favorited,a.isTrue),peopleNames:(0,s.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,s.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},97573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rawTagKeywords=t.parseKeywordStruct=t.isKeywordStruct=t.parseCategories=t.splitKeywords=t.splitKeyword=t.delimRe=t.keywordToPath=void 0;const r=i(77988),s=i(66150),n=i(19851),a=i(40958),o=i(22573),l=i(41400),u=i(96249),c=i(68708),d=i(59455),h=i(48884),f=i(50213),m=i(68852),p=i(81168),g=i(28874),y=(0,n.lazy)((()=>(0,f.mkLogger)("tags.KeywordTags"))),v=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordPathSeparators.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g")))));function w(e){const i=(0,t.delimRe)();return null==i?[e]:(0,a.compactBlanks)(e.split(i))}function b(e){return null==e||e instanceof r.BinaryField?[]:(0,a.compactBlanks)(Array.isArray(e)?(0,u.flatten)(e.map(b)):w(e))}function S(e){return null==e?[]:(0,p.isString)(e)?(0,o.blank)(e)?[]:[[e]]:(0,u.flatten)((0,d.toA)(e.Category).map(S).map((t=>t.map((t=>(0,a.compact)([e._,...t]))))))}(0,l.later)((()=>{g.Settings.keywordPathSeparators.watchLater((()=>v.unset()))})),t.keywordToPath=function(e){const t=v();return(0,a.compactBlanks)(null==t?[e]:e.split(t))},t.delimRe=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g"))))),g.Settings.keywordDelimiters.watchLater((()=>t.delimRe.unset())),t.splitKeyword=w,t.splitKeywords=b;const P=/^\(?none\)?$/i;function _(e){if(!(0,o.blank)(e)&&null==P.exec(e))try{const t=new s.XMLParser({textNodeName:"_"}).parse(e);return(0,u.flatten)((0,d.toA)(t?.Categories?.Category).map(S))}catch(t){return void y().warn("parseCategories() failed:",{err:t,s:e})}}function M(e){return Array.isArray(e)&&e.every(M)||null!=e&&(0,p.isString)(e.Keyword)&&(null==e.Children||Array.isArray(e.Children)&&e.Children.every(M))}function T(e){if(null==e)return[];if(Array.isArray(e)&&e.every(M))return(0,h.flatMap)(e,T);if((0,o.blank)(e.Keyword))return[];const t=(0,d.toA)(e.Children);return(0,a.isEmpty)(t)?[[e.Keyword]]:(0,h.flatMap)(t,T).map((t=>[e.Keyword,...t]))}t.parseCategories=_,t.isKeywordStruct=M,t.parseKeywordStruct=T,t.rawTagKeywords=function(e){const t=[];if(null!=e){const i=[...g.Settings.keywordTags.values];if(i.includes("Categories")){(0,h.remove)(i,"Categories");const r=_(e.Categories);null!=r&&t.push(...r)}for(const r of i){const i=(0,c.pluckDeep)(e,r)?.value;(0,o.blank)(i)||(M(i)?t.push(...T(i)):t.push(...Array.isArray(i)?i:b(i)))}}return y().tap({msg:"rawTagKeywords()",result:(0,a.compactBlankish)((0,a.uniq)(t)),meta:{t:null==e?void 0:(0,c.pick)(e,...g.Settings.keywordTags.values)}})}},15912:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(55835),o=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),h=i(28874),f=i(30748),m=(0,r.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,f.make)(e.LensMake),i=(0,f.make)(e.Make),r=[],o=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],b),u=(0,s.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:o,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&r.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==b(e))continue;(0,n.notBlank)(t)&&r.push({lensMake:t,lensModel:e,lensInfo:o});const a=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))a.includes(t)&&r.push({lensMake:i,lensModel:e,lensInfo:o});for(const i of(0,s.compactBlanks)([t,...h.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&r.push({lensMake:i,lensModel:e,lensInfo:o});a.startsWith("vr ")&&"Nikon"===i&&r.push({lensMake:"Nikon",lensModel:e,lensInfo:o})}for(const e of r){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=S(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,a.map)(e.lensInfo,S)}return(0,c.greatestBy)(r,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const v=/([\d. -]+)\s?mm\b/i,w=/\bf\/?([\d.\-]+)/i;function b(e){if((0,n.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=v.exec(e)?.[1].replace(/\s/g,""),i=w.exec(e)?.[1];return y(t)&&y(i)?S(`${t}mm f/${i}`):void 0}function S(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,a.mapOr)((0,o.toFloat)(e),(e=>String((0,o.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=b,t.cleanBogusPrecision=S,t.normalizeLensModel=function(e){return S(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(68708),o=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function h(e,t,i=""){const r=e.replace(t,i);return r===e?e:h(r,t,i)}const f=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=f.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,r.lazy)((()=>new p)),y=/\bgopro\b/i;function v(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=h(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=v(e.Make)??b(e.Software)??b(e.CreatorTool)??function(e){return y.test((0,o.toS)(e.HandlerDescription))||y.test((0,o.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,a.compactValues)({Make:t,Model:i})??{}},t.make=v;const w={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function b(e){if(!(0,s.blank)(e))for(const[t,i]of(0,a.entries)(w))if(i.test(e))return t}t.makeFromSoftware=b;const S=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=S.exec(i);null!=e&&(i=e[1].trim())}const r=(0,n.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=r)return r[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,n.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=h(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},38010:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MergedTags=t.revisionToResourceEvent=t.resourceEventToRevision=t.isSetRevision=t.isPrimitiveRevision=t.isBaseRevision=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(55835),u=i(31586),c=i(68708),d=i(67478),h=i(59455),f=i(54993),m=i(72993),p=i(50213),g=i(84885),y=i(66649),v=i(98725),w=(0,s.lazy)((()=>(0,p.mkLogger)("tags.MergedTags")));function b(e){return(0,u.isNumber)(e?.createdAt)&&(0,o.notBlank)(e?.field)}function S(e){return null==e?.op&&b(e)}function P(e){return e?.sourceIsPrimary??e?.shown??!1}function _(e){return e?.sourceModifiedTime??e?.mtime??0}t.isBaseRevision=b,t.isPrimitiveRevision=S,t.isSetRevision=function(e){return["add","delete"].includes(e?.op)&&b(e)},t.resourceEventToRevision=function(e){if(null==e||!(0,f.toS)(e.SoftwareAgent).startsWith((0,m.AppName)()))return w().tap({msg:"resourceEventToRevision() invalid",result:void 0,meta:{resourceEvent:e}});const t=e.Changed;if((0,o.blank)(t))return w().tap({msg:"resourceEventToRevision() missing Changed field name",result:void 0,meta:{resourceEvent:e}});const i=(0,c.pick)((0,o.mapNotBlank)(e.Parameters,d.parseJSON)??{},"newValue","priorValue");if((0,c.isEmptyObj)(i))return w().tap({msg:"resourceEventToRevision() missing Parameter fields",result:void 0,meta:{resourceEvent:e}});const r=(0,y.datedToMillis)((0,v.parseDated)({input:e.When}));return null==r?w().tap({msg:"resourceEventToRevision() missing createdAt (When)",result:void 0,meta:{resourceEvent:e}}):(0,o.blank)(e.Action)?w().tap({msg:"resourceEventToRevision() missing op (Action)",result:void 0,meta:{resourceEvent:e}}):w().tap({msg:"resourceEventToRevision()",result:{createdAt:r,field:t,op:"assign"===e.Action?void 0:e.Action,...i},meta:{resourceEvent:e}})},t.revisionToResourceEvent=function(e){return{Action:e.op??"assign",Changed:e.field,InstanceID:(0,l.map)(e.id,f.toS),Parameters:(0,g.stringifySorted)((0,c.pick)(e,"newValue","priorValue")),SoftwareAgent:(0,m.AppNameVersion)(),When:r.ExifDateTime.fromMillis(e.createdAt??Date.now())}},t.MergedTags=class{constructor(e){this.name=e,this.revisions=[],this.tags=[],this.logger=(0,p.mkLogger)(`MergedTags(${e})`)}addRevision(...e){this.revisions.push(...e)}addTag(...e){this.tags.push(...e),(0,a.sortBy)(this.tags,(e=>[!P(e),-_(e)]))}get(e){const t=(0,a.sortBy)(this.revisions.filter((t=>t.field===e)),(e=>e.createdAt)),i=this.tags.find((t=>null!=t[e]));let r=i?.[e];const s=[];var l;null!=r&&(0,o.mapNotBlank)((l=i,l?.SourceFile??l?.uri),(e=>s.push(e)));const u=t.every(S)&&this.tags.every((t=>!Array.isArray(t[e])));if(u){for(const i of t)null!=r&&r!==i.priorValue&&r!==i.newValue?this.logger.info("get("+e+"): skipping revision because expected prior or new value didn't match current value",{revision:i}):(r=i.newValue,s.push(`Revision@${i.createdAt}`));return null==r?void 0:{value:r,source:s}}{const e=(0,h.toA)(r);for(const i of t)if("add"===i.op&&null!=i.newValue)s.push(`Revision@${i.createdAt}`),(0,n.pushUniq)(e,...(0,h.toA)(i.newValue));else if("delete"===i.op&&null!=i.priorValue){s.push(`Revision@${i.createdAt}`);for(const t of(0,h.toA)(i.priorValue))(0,n.remove)(e,t)}return{value:e,source:s}}}}},16170:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const r=i(22573),s=i(54993),n=i(2322),a=i(277),o=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function h(e){return(0,r.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function f(e){const t=(0,s.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,n.isChrome)(t)||(0,n.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,s.toS)(e))},t.isImageMimeType=function(e){return(0,s.toS)(e).startsWith("image/")},t.isVideoMimeType=h,t.normalizeMimetype=f,t.isSharpMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,r.blank)(t)&&(h(t)?await(0,l.isVideoSupported)():(0,o.isHeifMimeType)(t)?await(0,a.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},66039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderNameTag=t.parseName=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(55835),l=i(75020),u=i(59455),c=i(50213),d=i(68852),h=i(81168),f=i(70417),m=i(28874),p=(0,r.lazy)((()=>(0,c.mkLogger)("tags.Names")));function g(e){return(0,d.matchQuotes)((0,d.escapeRegExp)(e))}const y=/(\(\s*\d+\s*-\s*[\d?]{0,4}\s*\)?)/,v=/([,\s]+(?:jr\.?|junior|sr\.?|senior|[iv]+\.?))$/i,w=/\b([A-Z‘’']+[-A-Z‘’']{2})\b/,b=/^[()[\]/.\-_]+$/;function S(e){if((0,a.blank)(e))return;let t=e.replace(/\s+/g," ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").trim();const i=(0,o.map)((0,h.spliceCapture)(t,y),(e=>(t=e.unmatched.trim(),e.captured.replace(/\s+/g,"")))),r=(0,o.map)((0,h.spliceCapture)(t,v),(e=>(t=e.unmatched.trim(),e.captured.trim()))),l=[],c=[],b=[];for(const e of m.Settings.tagNamesGiven.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(l.push(i.captured),t=i.unmatched.trim())}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesGivenSurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`(${(0,d.escapeRegExp)(e.charAt(0))}\\s*[^${(0,d.escapeRegExp)(e.charAt(0))}]+\\s*${(0,d.escapeRegExp)(e.charAt(1))})`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(c.push(i.captured),t=i.unmatched.trim())}while(null!=i)}let S;function _(e){(null==S||S>e.matchedIndex)&&(S=(0,f.min)([S,e.matchedIndex]))}if(m.Settings.tagNamesCapitalizedAsFamily.valueOrDefault){let e;do{e=(0,h.spliceCapture)(t,w),null!=e&&(_(e),b.push(e.captured),t=e.unmatched.trim())}while(null!=e)}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesFamilySurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`${(0,d.escapeRegExp)(e.charAt(0))}\\s*([^${(0,d.escapeRegExp)(e.charAt(0))}]*)\\s*${(0,d.escapeRegExp)(e.charAt(1))}`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}while(null!=i)}if(m.Settings.tagNamesLexical.valueOrDefault){const e=t.indexOf(",");e>=0&&(S=void 0,b.push(t.substring(0,e).trim()),l.push(t.substring(e+1).trim()),t="")}for(const e of m.Settings.tagNamesSurnames.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}for(const e of(0,u.toA)((0,s.mapNotEmpty)((0,s.compactBlanks)(m.Settings.tagNamesSurnamePrefixes.values),(e=>(0,n.sortBy)(e,(e=>-e.length)).map((e=>new RegExp(`\\b(${g(e)}\\s+\\S+)`,"i"))))))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}null!=S&&t.length>S&&(0,s.mapNotEmpty)((0,s.compactBlanks)(t.slice(S).split(/\s+/)),(e=>{b.push(...e),t=t.slice(0,S)}));const M=(0,s.compactBlanks)(t.split(/\s+/)),T=l.length,E=b.length;if(M.length>0)if(0===T&&E>0)l.push(...M);else if(0===E&&T>0&&1===M.length)b.push(...M);else if(1===M.length)l.push(...M);else{const e="western"===m.Settings.tagNamesOrder.valueOrDefault;b.push(e?M.pop():M.shift()),l.push(...M)}return{givenNames:P([...l,...c]),modifier:r,lifespan:i,familyNames:P(b),minFamilyNameIndex:S}}function P(e){return(0,s.uniq)((0,s.compactBlanks)(e).filter((e=>null==b.exec(e))))}function _(e){let t="";for(const i of(0,s.compactBlanks)(e))t+=i.startsWith(",")?i:" "+i;return t.trim()}function M(e,t,i){return _("western"===m.Settings.tagNamesOrder.valueOrDefault?[t,e,i]:[e,t,i])}t.parseName=S,t.renderNameTag=function(e){if((0,a.blank)(e))return[];const t=m.Settings.tagNamesFormatter.valueOrDefault,i="family/given"===t;if("family/fullname"===t||i){const t=S(e);if(null==t)return[];{const e=_([t.modifier,t.lifespan]),r=_(t.givenNames);return(0,s.compactBlanks)((0,s.notEmptyOr)(t.familyNames,[m.Settings.tagNamesDefaultFamily.valueOrDefault])).map((t=>[l.TagRoots.Who,t,i?_([r,e]):M(t,r,e)]))}}return[[l.TagRoots.Who,e.trim()]]}},95141:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const r=i(21605),s=i(54993),n=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,n.isVideoMimeType)(e.MIMEType)?(0,r.normalizeRotation)(e.Rotation):void 0)??o(e.Orientation)};const a=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function o(e){return(0,r.isRotation)(e)?e:null!=e?a.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,s.toS)(e).startsWith("Mirror")},t.orientationToRotation=o;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,r.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,r.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const r=i(55835),s=i(31586),n=i(28874);function a(e){const t=(0,s.toInt)(e);return null==t?void 0:(0,s.clamp)(-1,5,t)}function o(e){return a(e?.Rating)??(0,s.mapNumeric)((0,s.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,r.map)(e?.favorited,(e=>!0===e?n.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=a,t.extractRating=o,t.extractLiked=function(e){const t=o(e);return null==t?void 0:t>=n.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(88561),o=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,r.lazy)((()=>new a.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,s.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,n.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,o.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),s=i(40958),n=i(22573),a=i(81168),o=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,a.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const o=(0,u.isJsonExt)(i.ext),l=o||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=o||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,s.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,s.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return o&&function(e,i){const r=(0,a.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function s(e){return(0,n.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const o=s(e.slice(r.length)),l=s(i.slice(r.length));return o&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,o.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,a.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(33374),o=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),h=i(34943),f=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),v=(0,r.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),w=(0,r.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:n.minuteMs})));async function b(e,t){if(null==e)return;const i=null==t||(0,s.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const r=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return S(i,r,await(0,h.rawInfo)(e));const n=S(i,r);if(null!=n)return n;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await b(await(0,f.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function S(e,t,i){t??(t=(0,y.extractRotation)(e));const r=(0,o.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,a.isDimensions)(e)?e:void 0));if(null==r)return v().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo,fileDimensions:r}});const s=(0,a.maybeDimSwap)(r,t);return v().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:s.height,ImageWidth:s.width,aspectRatio:(0,d.aspectRatio)(s),dimensions:s,rotation:t,fileDimensions:r,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return w().getOrSetAsync(i.nativePath,(()=>b(i,t)))},t.extractSizeInfoFromTags=S},3127:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tag_fts_path=t.tag_fts_root=void 0;const r=i(54993),s=i(42231);t.tag_fts_root=function(e){const t=(0,r.toS)(e).indexOf(s.TagSep);return-1===t?"":e.substring(0,t)},t.tag_fts_path=function(e){return(0,r.toS)(e).split(s.TagSep).filter((e=>null!=e&&""!==e.trim())).join(" ")}},61424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),h=i(48884),f=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),v=i(79842),w=i(21330),b=i(98725),S=i(51275),P=i(35280),_=i(19748),M=i(88561),T=i(95696),E=i(65238),k=i(17217),D=i(57902),x=i(28874),C=i(80496),F=i(65162),A=i(28544),I=i(47783),O=i(88840),L=i(30748),R=i(16170),N=(0,n.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),B=7;async function j(e){return x.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+x.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(x.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.auto&&await(0,E.isSlowDir)(e.nativePath)&&!await(0,E.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function z(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of r){const r=(0,L.extractMakeAndModel)(await(0,I.readRawTags)(t));if((0,f.definedAndNotEql)(r.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:r});else if((0,f.definedAndNotEql)(r.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:r});else if(null!=r.Make&&null!=r.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:D.LogLevels.info,result:r,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await j(e.parent()))return;const t=await W(e);return null!=t&&(0,w.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,w.toExifDateTime)(t.before.date,(0,S.getZoneName)(t.before.date)),(0,w.toExifDateTime)(t.after.date,(0,S.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,n.lazy)((()=>new M.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await q(e),i=await z(t?.younger),r=await z(t?.older);return null==i||null==r?void 0:{before:i,after:r,index:i.index,slots:i.index+r.index+1}}))}t.beforeAfterCapturedAt=W;const U=(0,_.extFilter)(O.ExtTypes.AssetFile);function H(e){return null==e?[]:(0,a.compact)((0,h.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function q(e,t=7,i=!0){if(!await j(e.parent()))return;const r=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(U(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==r)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const s=(0,o.sortBy)(r,(e=>(0,F.bname)(e))),n=(0,k.findFileIndex)(e,s);if(n<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),q(e,t,!1)):void 0;const l=x.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[s.slice(n-2*t,n),s.slice(n+1,n+1+2*t)],d=[],h=[];for(;(0,a.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,a.isNotEmpty)(c)&&h.length=l&&h.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:h},meta:{f:e}})}t.nearestSiblings=q,t.nearestSiblingTzOffset=async function(e){if(!await j(e.parent()))return;const t=H(await q(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,B);for(const t of e){const e=await(0,I.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==r.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,a.uniq)([(0,F.bname)(e,!0),(0,F.bname)(e,!1)]),i=(0,b.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const r=await e.stat();if(null!=r){for(const e of["birthtime","atime","mtime","ctime"])if((0,v.datedOverlap)({a:i,b:r[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:r}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:r}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,b.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const r=i[e];if(null!=r&&!0===(0,v.datedOverlap)({a:t,b:r}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:s.DateTime.fromJSDate(r)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),h=i(81168);function f(e){return(0,u.toS)((0,o.isString)(e)?e:e?.name).normalize()}function m(e){return(0,r.compact)((0,l.toA)(e).map(f))}function p(e,i=t.TagSep){return m(e).map((e=>(0,o.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(n.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function v(e){return(0,n.blank)(e)?void 0:Array.isArray(e)?f((0,r.last)(e)):(0,r.last)(g(e))}function w(e,t){if((0,r.isEmpty)(e)||(0,r.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,h.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=f,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,r.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,r.uniqBy)((0,l.toA)(e),(e=>(0,r.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,r.compact)(t).map((e=>y(e))));return(0,r.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=v,t.leafIsExcluded=function(e,t){return(0,a.mapOr)(v(e),(e=>(0,h.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=w,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,s.sortBy)(e.filter(r.isNotEmpty),(e=>-e.length)))t.some((e=>w(i,e)))||t.push(i);return(0,s.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const r=i(40958),s=i(22573),n=i(68708),a=i(54993);t.extractTitleDescription=function(e){const t=(0,r.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,s.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const r of i){const i=(0,a.toS)(e[r]).trim();if((0,s.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,n.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(96249),o=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),v=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function w(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function b(e){const t=await w(e);return(0,s.uniq)((0,a.flatten)(t.map(m.uriEncodingVariants)))}async function S(e,t){if((0,n.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void v().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case o.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case o.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case o.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,n.blank)(e)?v().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=w,t.nativePath2uriVariants=b,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(S(e,t),b))),(0,s.uniq)(i)},t.uri2nativePath=S,t.uriExists=async function(e,t){const i=await S(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),s=i(57975),n=i(90595),a=i(22573),o=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",v=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class w{static isUri(e){return e instanceof w||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,s,n=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,n),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=s??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,n))}get fsPath(){return T(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:s,fragment:n}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===s?s=this.query:null===s&&(s=g),void 0===n?n=this.fragment:null===n&&(n=g),t===this.scheme&&i===this.authority&&r===this.path&&s===this.query&&n===this.fragment?this:new S(t,i,r,s,n)}static parse(e,t=!1){const i=v.exec(e);if(!i)return new S(g,g,g,g,g);const r=i[2]||g,s=x(i[4]||g),n=(i[5]||g).split("/").map(x).join("/"),a="psfile"===r&&n.startsWith("//")?n.slice(1):n,o=(0,u.toURLSearchParams)(i[7]),l=x(i[9]||g);return new S(r,s,a,o,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new S("file",t,e,g,g)}static from(e){return new S(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?w.file(r.win32.join(T(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,o.map)(this.path,(e=>(0,d.findLast)(e.split(y),a.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return E(this,e)}toJSON(){return this}[s.inspect.custom](){return this.toString()}}t.URI=w;const b=h.isWinPortable?1:void 0;class S extends w{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=T(this,!1)),this._fsPath}toString(e=!1){return e?E(this,!0):(null==this._formatted&&(this._formatted=E(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=b),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,a.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function _(e,t){let i,r=-1;for(let s=0;s=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||45===n||46===n||95===n||126===n||t&&47===n)-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),void 0!==i&&(i+=e.charAt(s));else{void 0===i&&(i=e.substr(0,s));const t=P[n];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),i+=t):-1===r&&(r=s)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function M(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function E(e,t){const i=t?M:_;let r="";const{scheme:s,query:n,fragment:o}=e;let{authority:l,path:u}=e;if(s&&(r+=s,r+=":"),(l||"file"===s)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,a.mapNotBlank)(n,(e=>r+="?"+e)),o&&(r+="#",r+=t?o:_(o,!1)),r}function k(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+k(e.substr(3)):e}}t.encodeURIComponentFast=_,t.uriToFsPath=T;const D=/(?:%[\dA-Z][\dA-Z])+/gi;function x(e){return e.startsWith("xn--")?(0,n.toUnicode)(e):e.match(D)?e.replace(D,(e=>k(e))):e}t.percentDecode=x,t.toURI=function(e){return w.isUri(e)?e:w.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),s=i(40958),n=i(50357),a=i(89937),o=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",a.PS_LOCAL_FILE_SCHEME,a.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,o.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&f(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,n.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,s.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),s=i(22573),n=i(51926),a=i(89937),o=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,s.blank)(e))return;if(null==(t=null!=t&&(0,o.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,s.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,n.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:a.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==a.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,s.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,n=(0,s.notBlank)(t)&&!t.includes(i);if(n&&!(0,s.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const o=await(0,c.bestVolumeForVolsha)(e.authority);return null!=o?f(o.mountpoint,e.path):n&&(0,s.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),s=i(22573),n=i(51926),a=i(89937),o=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,s.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,s.blank)(t))return;const i=(0,r.uniq)([t,(0,o.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,n.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==a.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,o.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,n.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const a=n(i(76760)),o=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,o.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,o.notBlank)(t.remoteHost)&&(0,o.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:a.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,o.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,o.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(a.sep)}`;const s=i.slice(1),n=await(0,p.volumes)();for(const t of(0,u.toA)(n))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return a.join(t.mountpoint,...s);return await(0,h.isReadableDirectory)(t)?a.join(t,...s):void 0}},85087:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),s=i(42659),n=i(9103),a=i(37628);t.volsha=(0,n.memoize)((e=>(0,r.mapNotBlank)(e,a.shortStringSha)),{maxSize:128,ttlMs:s.minuteMs})},50036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.channelVersionsCache=void 0;const r=i(46292),s=i(95696);t.channelVersionsCache=function(){return s.PosixFile.forMaybe((0,r.configDir)())?.join("channel-versions.json")}},60865:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),s=i(30577);t.channel=function(){return(0,s.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),s=i(22573),n=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function a(e){if(e instanceof r.SemVer)return e.version;const t=n.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=a,t.semverSatisfies=function(e,t){if((0,s.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const n=a(e);return null!=n&&(0,r.satisfies)(n,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},27274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.semverGte=t.semverLatest=void 0;const r=i(54993),s=i(48884),n=i(76280),a=i(30577);function o(e){const t=(0,n.toSemver)(e),i=a.UpdateChannels.ordinal((0,a.extractUpdateChannel)((0,r.toS)(e)));return null==t?void 0:[t.major,t.minor,t.patch,i,...t.prerelease.slice(1)]}function l(...e){return(0,s.greatestBy)(e,o)}t.semverLatest=l,t.semverGte=function(e,t){return l(e,t)===e}},38244:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isUpdateChannelVersion=void 0;const r=i(68708),s=i(51926),n=i(30577);t.isUpdateChannelVersion=function(e){return(0,r.isObject)(e)&&n.UpdateChannels.has(e.channel)&&(0,s.isString)(e.version)}},30577:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},63335:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ver=void 0;const r=i(22573);t.ver=function(e){return(0,r.blank)(e)?"(missing version)":e.replace(/^(?:v|ver|version)?\s*/,"version ")}},40044:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getChannelVersions_=t.checkVersion_=t.currentChannel=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(75240),l=i(17344),u=i(50213),c=i(37805),d=i(5916),h=i(46292),f=i(16287),m=i(43205),p=i(28874),g=i(63870),y=i(89372),v=i(50036),w=i(60865),b=i(27274),S=i(38244),P=i(30577),_=i(63335),M=(0,a.defer)((()=>(0,u.mkLogger)("VersionCheck")));t.currentChannel=function(){const e=[p.Settings.updateChannel.valueOrDefault,(0,w.channel)()].map((e=>P.UpdateChannels.ordinal(e))).sort()[0];return P.UpdateChannels.values[e]??p.Settings.updateChannel.valueOrDefault},t.checkVersion_=async function(e){if(p.Settings.noNetwork.valueOrDefault)return{level:"disabled",msg:["PhotoStructure version checking is disabled","Set "+(0,s.tt)(p.Settings.noNetwork.toEnvLine(!1))+" to enable."]};if(!p.Settings.autoUpdateCheck.valueOrDefault){const e=["PhotoStructure version checking is disabled"];return!0===p.Settings.optOut.value?e.push("Set "+(0,s.tt)(p.Settings.optOut.toEnvLine(!1))+" to enable."):!1===p.Settings.autoUpdateCheck.value?e.push("Set "+(0,s.tt)(p.Settings.autoUpdateCheck.toEnvLine(!0))+" to enable."):e.push("Finish setup, or set "+(0,s.tt)(p.Settings.autoUpdateCheck.toEnvLine(!0))+" to enable."),{level:"disabled",msg:e}}const i=(0,h.configDir)();if(null==i||!await(0,f.isDirectory)(i))return{level:"warn",msg:["PhotoStructure version checking is disabled","No suitable configuration directory exists."]};const a=await(0,t.getChannelVersions_)();if(null==a)return{level:"warn",msg:["Failed to fetch PhotoStructure version information"]};const u=e?.installedVersion??c.version,d=(0,P.extractUpdateChannel)(u),m=(0,P.eligibleForChannel)(d),g=a.versions.filter((e=>m.includes(e.channel))).map((e=>e.version)),y=e?.latestVersion??(0,b.semverLatest)(...g);if(null==y)return{level:"warn",msg:["PhotoStructure version checking failed","No suitable version was found for "+p.Settings.updateChannel.toEnvLine()]};const v=(0,P.extractUpdateChannel)(y),w="You are running "+(0,l.EditionName)()+" "+(0,_.ver)(u),S="The latest published "+(0,s.tt)(v)+" build is "+(0,_.ver)(y),M=v===d?void 0:"You should consider switching to the "+(0,s.tt)(v)+" channel.",T=Date.now()-a.updatedAt,E="Last checked "+(T{const e=(0,v.channelVersionsCache)(),i=await(0,y.httpGetJson_)({url:"https://photostructure.com/channel-versions.json",headers:{"User-Agent":await(0,m.userAgent)()},cache:e,ttlMs:n.dayMs,preCacheTransform:e=>({versions:e,updatedAt:Date.now(),updatedByVersion:c.version})}),r=i.data;if(null==r||!Array.isArray(r.versions)||0===r.versions.length||r.versions.some((e=>!(0,S.isUpdateChannelVersion)(e)))||r.updatedByVersion!==c.version){if(i.fromCache)return M().info("getChannelVersions_(): Invalid or stale cached response. Retrying after wiping cache",{result:r,cache:e}),await e.unlink_(),t.getChannelVersions_.refresh();M().throw("getChannelVersions_(): Invalid response",{result:r})}return M().tap({msg:"getChannelVersions_()",result:r})}})},8540:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),s=i(9595),n=i(29882),a=i(43334),o=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([o.Settings.libraryDir.valueOrDefault,(0,s.originalsDir)(),...o.Settings.scanPaths.values]))if((!a.isPosix||!(0,n.pathIsRoot)(t))&&(0,n.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},42233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentVolumeRoots=void 0;const r=i(45200),s=i(98770),n=i(7014);t.currentVolumeRoots=(0,s.lazyFsAsync)("currentVolumeRoots",(async function(){const e=[],t=[];for(const i of await(0,n.volumes)()){t.push(i.mountpoint);const s=(await(0,r.nativePath2uri)(i.mountpoint,i))?.toString();null!=s&&e.push(s)}return{uris:e,mountpoints:t}}))},1485:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),s=i(22573),n=i(59455),a=i(50213),o=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.DfPosix"))),v=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function w(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),s=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),n=t&&(i||r||s);return y().tap({msg:"acceptPosixVolume()",result:!n,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:s}})}t.acceptPosixVolume=w,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,n.toA)(await v());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,s.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,n.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,o.assignMissingPrimitives)(i,e))}return t.filter(w)}},69108:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,a.toInt)(e,{defaultValue:0})*o.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,s.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const s=m(e.Used)??0,n=m(e.Available)??0;if(0!==s||0!==n)return{filesystem:t,mountpoint:i,size:d.isMac?s+n:r,used:s,available:n};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:s,available:n})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,s.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,n.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const a=p(i);return!0===e&&a.forEach((e=>e.remote=!1)),a},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),v=i(24399),w=i(28874),b=i(24541),S=i(60224),P=i(63870),_=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const M=/([a-z]+)(?::\\)?/i;function T(e){return e?.match(M)?.[1]?.toUpperCase()}function E(e){return(0,l.map)(T(e),(e=>e+":\\"))}function k(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(T(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function D(e){return null!=e&&!(0,a.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,a.notBlank)(e.DisplayRoot),...(0,l.map)((0,S.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function x(e){return`Get-Volume ${(0,f.toS)(T(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=E,t.getPsDriveCommand=k,t.getVolumeCommand=x,t.getLocalVolumesWin_=function(){return v.PowerShell.instance().executeJsonToA(x())};const C=/\{([-a-z\d]{7,})\}/i;function F(e,t){return e=e?.trim(),(0,a.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function A(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void _().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=E(e.DriveLetter);if(null==t)return void _().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,s.compact)([F(e.HealthStatus,"healthy"),F(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,a.notBlank)(e.DriveLetter)&&(0,a.blank)(i);return _().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(n=e.UniqueId,_().tap({msg:"uniqueId2uuid",result:(0,l.map)(C.exec((0,f.toS)(n)),(e=>e[1])),meta:{s:n}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var n}async function I(){const e=(0,s.uniq)((0,h.toA)(await(0,b.mountpointsWin)()).map(E)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(k(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,s.compact)((0,o.flatten)(t).map(D)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(x(e)).catch((t=>(_().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),a=(0,s.compact)((0,o.flatten)(r).map(A)),l=(0,s.uniq)([...i,...a].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,n.sort)((0,s.uniq)([...i,...a].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));_().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:a,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...a.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=A,t.volumeInfoWin=I},68884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),v=i(83278),w=i(8103),b=i(16287),S=i(45969),P=i(43334),_=i(69108),M=i(98770),T=i(44224),E=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,S.isDocker)()||(0,d.isBillingService)()||null==await(0,w.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,E.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const k=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?k().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,T.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),b.isReadableDirectory),(e=>e.map((e=>v.BaseFile.for(e).clear().childDirectories())))))}):k().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,s.isEmpty)(e)?[]:(k().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,E.mountpointsTtlMs)(),f:async e=>{const t=await(0,_.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void k().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await D(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,E.mountpointsTtlMs)()}))),(0,o.later)((()=>(0,M.setupVolumeTTL)(t.gioVolumes)));const D=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,E.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,n.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(n.notBlank).get()}}catch(t){return void k().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs})},98770:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),s=i(5233),n=i(41400),a=i(56038),o=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,a.time)("volumes."+e,(()=>(0,s.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,o.isRetriableError)(e)&&!1!==(0,o.isIgnorableError)(e)})))),i);return(0,n.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),v=i(98770),w=i(63870),b=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>b().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>b().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const n=(0,c.sortIgnoreCase)((0,s.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),a=[];for(const t of n){const s=e.find((e=>e.mountpoint===t)),n=i?.find((e=>e.mountpoint===t)),o={...s,...n},u=r?.find((e=>e.filesystem===o.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(o,u),null==o.size||null==o.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];b().info("backfilling mountpoint",{info:n,vol:s,df:e}),null!=e&&(0,l.assignMissingPrimitives)(o,e)}a.push(o)}return a};const S=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return S.exec(e)?.[1]?.split(".").map((e=>(0,a.toInt)(e)))})),_=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,a.gte)(t[0],2)&&(0,a.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,v.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await _()],{timeoutMs:(0,w.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,n.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,a.toInt)(e.fsused),r=(0,a.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return b().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,v.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,w.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,n.toNotBlank)(e.PARTLABEL)??(0,n.toNotBlank)(e.LABEL),uuid:(0,n.toNotBlank)(e.PARTUUID)??(0,n.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),s=i(19851),n=i(40958),a=i(22573),o=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),v=(0,s.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,n.uniq)(e.map((e=>e.filesystem?.match(w)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),s=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of s)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,a.blank)(t.MountPoint)||(0,o.isTrue)(t.OSInternal)?v().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){v().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const w=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),v=i(84777),w=i(34330),b=i(8769),S=i(34102),P=i(17217),_=i(16287),M=i(43334),T=i(28874),E=i(8540),k=i(68884),D=i(44224),x=i(24541),C=i(69375),F=i(63870),A=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function O(e=(0,F.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function L(){I()}t.localMountpointSetup=(0,r.lazy)((async()=>{T.Settings.libraryDir.watchLater(I),T.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&T.Settings.scanAllDrives.valueOrDefault?(0,o.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(M.isMac&&(e.info("Setting up Mac diskutil activity watcher"),O((0,F.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),M.isLinux){const i=(0,D.maybeWatchProcMounts)();await(0,k.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),O((0,F.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),O((0,F.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),a.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=T.Settings.mountpoints.values;if((0,s.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",M.isWin?x.mountpointsWin:D.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,s.isEmpty)(e))return A().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,n.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,F.commandTimeoutMs)(),f:async e=>!(!(0,E.mightBeAssetMountpoint)(e)&&(0,C.isExcludedMountpoint)(e)||T.Settings.validateMountpoints.valueOrDefault&&!await(0,_.isReadableDirectory)(e)&&(A().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,b.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(M.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return M.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,o.later)((()=>{(0,S.ee)().on("clearCache",(()=>{k.gioVolumes.unset(),I()})),T.Settings.mountpointsTtlMs.watch(O)}),(0,c.isTest)()?1:a.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>L(),minCallDelayMs:1.5*a.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:k.GioCommand,args:k.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(k.gioVolumes.unset(),L()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const N=(0,r.lazy)((async()=>{if(!M.isLinux)return!1;try{return 0===(await(0,v.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,F.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>L(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(48884),o=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),v=i(28874),w=i(69108),b=i(68884),S=i(59107),P=i(69375),_=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await k()??await(0,c.thenMap)((0,w.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,b.isGioSupported)())try{await(0,c.thenMap)((0,b.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){_().warn("Failed to fetch gio volumes",e)}return e};const M="/proc/mounts";function T(e){return!v.Settings.excludedFilesystemTypes.has(e)}function E(e){return!(0,P.isExcludedMountpoint)(e)&&(!v.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function k(e=M,t=T,i=E){if(y.isLinux)try{const r=await(0,f.readLines_)(e),n=(0,s.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,a.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),o=await(0,c.filterAsync)({name:"mountpoints filter",arr:n,f:async([e,r])=>{const s=t(e),n=await i(r);return _().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:s&&n,meta:{fs:e,mp:r,fsOK:s,mpOK:n}})}});return _().tap({msg:"readProcMounts()",result:o.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void _().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=T,t.readProcMounts=k,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(M)?new h.FileWatcher(M,{recursive:!1,persistent:!1},(()=>{_().info("detected change in "+M),(0,d.setUnrefTimeout)((()=>S.mountpoints.refresh()),n.secondMs)})):void 0))},24541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),s=i(42659),n=i(13538),a=i(50213),o=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,n.thenOrTimeoutError)(f(),o.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*s.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(9103),o=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,n.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,s.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,o.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,o.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,o.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,o.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,s.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,a.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),s=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,n=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function a(e){if((0,r.blank)(e))return;const i=s.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(n,""),remoteShare:i.remoteShare};const a=t.nfsRe.exec(e);if(null!=a){const e=a[1],t=a[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=a(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=a},60224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(55835),o=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),v=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await T()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,a.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const w=["LocalName","RemoteName","Status"],b=["NETUSE","get",w.join(",")],S=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function _(e){if(!(0,s.blank)(e))return(0,o.opt)(e).flatMap((e=>S.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,o.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,s.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,o.opt)(e.pathname).filter(s.notBlank).getOrElse((()=>"/"))}))))).get()}async function M(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,b,{timeoutMs:15*n.secondMs}),i=(0,u.parseFixed)(w,t);return(0,r.compact)(i.map((e=>(0,a.map)(S.exec((0,l.toS)(e.RemoteName)),(t=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=_,t._netInfoWinWmic=M;const T=(0,v.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?M():(0,r.compact)(e.filter((e=>(0,s.notBlank)(e.LocalName))).map((e=>(0,a.map)(_(e.RemoteName),(({host:t,share:i})=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,h.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),s=i(12168),n=i(28874);t.mountpointsTtlMs=function(){return n.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return n.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return n.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=s.MiB/r.secondMs},86848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(38639),o=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),v=i(95696),w=i(45969),b=i(28874),S=i(59107),P=i(63870),_=i(68995),M=(0,s.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),T=(0,s.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function E(e){return(0,a.isTrue)(e.ignorable)||(0,w.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function k(e){if((0,n.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function D(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=k(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function x(e){if(b.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of b.Settings.volumeUuidFilePaths.values){const i=v.PosixFile.for(e.mountpoint).join(t),r=await D(i).catch((e=>M().info("Failed to read "+i,{error:e})));if(null!=r)return M().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,_.volumeUuidSubpath)());if("/"===e.mountpoint)return M().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(b.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return M().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(b.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,_.writeVolumeUuid)(e);if(!(0,n.blank)(t))return M().tap({msg:"readVolumeUUID(): wrote new "+(0,_.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return M().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,o.later)((()=>{(0,m.ee)().on("clearCache",(()=>T.clear())),S.mountpoints.watchLater((()=>T.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(E(e))return;if((0,a.isFalse)(e.ok))return;const t=await T().getOrSetAsync(e.mountpoint,(async()=>x(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>M().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=E,t.toVolumeUUID=k,t.readUuidFile_=D,t.readVolumeUUID=x},7014:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),v=i(59455),w=i(48884),b=i(50213),S=i(7282),P=i(23560),_=i(28850),M=i(45255),T=i(81168),E=i(56519),k=i(4867),D=i(49776),x=i(9595),C=i(77740),F=i(44198),A=i(96706),I=i(8769),O=i(57159),L=(i(34102),i(21144)),R=i(73209),N=i(29882),B=i(95696),j=i(17217),z=i(16287),V=i(49076),W=i(96128),U=i(45969),H=i(43334),q=i(28874),G=i(85087),$=i(50424),J=i(48165),K=i(98770),Y=i(27461),Z=i(66840),X=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,a.lazy)((()=>(0,b.mkLogger)("volumes.Volumes"))),se=s.default.platform(),ne=new Map,ae=new Map,oe=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,G.volsha)(t.uuid),(e=>ae.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,ne),le((0,G.volsha)(e.uuid),e,oe),e}function ce(){return(0,o.compact)([B.PosixFile.forMaybe((0,D.cacheDir)())?.join("volumes"),B.PosixFile.forMaybe((0,x.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),ae))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),ne.clear(),oe.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,E.mapAsync)({name:"readCachedVolumes",arr:(0,E.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,o.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,T.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),s=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:r,os:se}))),n=new Map;for(const e of s)for(const t of(0,o.compactBlanks)([(0,G.volsha)(e.uuid),(0,G.volsha)(e.mountpoint)]))n.set(t,e);const a=ce();for(const e of a)await(0,R.withLock_)({file:e,timeoutMs:M.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of n.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:a,vol_mountpoints:s.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,o.isNotEmpty)(e))return e;const i=(0,v.toA)(await(0,X.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,q.Settings.volumeMetadataTtlMs.valueOrDefault),s=0!==q.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),n=!(0,o.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:s,priorIsMissingMountpoints:n}),s||n?void 0:e}async function me(e,i){const r=(0,m.map)(e,j.toNativePath_);if((0,u.blank)(r))return;const s=await(0,L.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,o.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(s,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:s,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:s}})}async function pe(e,t,i){const r=i.filter((e=>(0,T.equalsIgnoreCase)(t,e.remoteShare)));if((0,o.isEmpty)(r))return;const s=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,T.equalsIgnoreCase)(e,t.remoteHost)));if(null!=s)return s;const n=await(0,W.friendlyname)(e);return(0,E.asyncFind)(r,(async e=>(0,T.equalsIgnoreCase)(n,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,a.lazy)((()=>(0,P.isSyncService)()||(0,S.isTest)())),t.priorWriteVolumesToCacheLatch=(0,a.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,a.lazy)((async()=>{const e=(0,o.compact)(await de()),t=(0,v.toA)(await(0,X.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,o.isNotEmpty)(i)?i:e.filter((e=>se===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,k.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,k.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,o.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,O.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,_.shim0)({name:"fs.volumes",impl:async function(){if((0,S.isTest)()){const e=(0,p.toInt)((0,F.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,C.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,k.thenOrTimeoutError)({p:H.isWin?(0,J.dfWin)():(0,$.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=q.Settings.validateMountpoints.valueOrDefault?(0,o.compact)(await(0,E.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,z.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,k.thenOrTimeoutError)({p:H.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(H.isWin?t:H.isMac?await(0,Z.addLocalVolumeInfoMac)(t):await(0,Y.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await he(r),Object.freeze(r)}}),t.rootPath=(0,a.lazy)((()=>H.isWin?(0,g.opt)((0,A.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,T.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,o.isEmpty)(t)?void 0:(0,w.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,o.commonPrefixLength)(e.split(n.default.sep),t.split(n.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,v.toA)(await i.vols()).find((t=>(0,G.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,E.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return oe.get(e)??(await de())?.find((t=>(0,G.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,G.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(50213),o=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,s.lazy)((()=>(0,a.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,n.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,f());t=(0,n.toNotBlank)(t)??(0,c.safeUUID)();const s=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(s))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+o.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},89372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.httpGetJson_=void 0;const r=i(45599),s=i(98553),n=i(31586),a=i(50213),o=i(51140),l=i(4988),u=(0,r.defer)((()=>(0,a.mkLogger)("web.HttpGet")));t.httpGetJson_=async function(e){const t=e.cache,i=await t.mtimeMs();if(null!=i&&(0,n.gt0)(await t.size())&&(0,n.gte)(i,Date.now()-e.ttlMs))return{data:await t.readJson_(),updatedAt:i,fromCache:!0};const r=await(0,l.get_)(e.url,{headers:e.headers});o.HttpStatusIs.success(r.statusCode)||u().throw("Failed",{url:e.url,response:r});const a=(0,s.parseJSON_)(r.data),c=e.preCacheTransform?.(a)??a;return u().info("Fetch success. Caching",{args:e,json:c,cache:t}),await t.writeJson_(c),{data:c,updatedAt:Date.now(),fromCache:!1}}},51140:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpStatusIs=t.HttpStatus=void 0;const r=i(31586);t.HttpStatus=Object.freeze({OK:200,Accepted:202,MovedPermanently:301,Found:302,SeeOther:303,BadRequest:400,Unauthorized:401,Forbidden:403,NotFound:404,EnhanceYourCalm:420,InternalServerError:500,NotImplemented:501,ServiceUnavailable:503}),t.HttpStatusIs=Object.freeze({ok:e=>(0,r.within)(200,299,e),success:e=>(0,r.within)(200,299,e),redirect:e=>(0,r.within)(300,399,e),clientError:e=>(0,r.within)(400,499,e),serverError:e=>(0,r.within)(500,599,e),error:e=>(0,r.within)(400,599,e)})},21404:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToTagPath=void 0;const r=i(75020),s=i(40958),n=i(22573),a=i(89937),o=i(34238);t.uriToTagPath=function({uri:e,isFile:t}){if(null==e)return;const i=(0,o.toURI)(e),l=i.scheme===a.PS_LIBRARY_SCHEME?r.LibraryTagName:i.scheme===a.PS_LOCAL_FILE_SCHEME?i.authority:void 0;if((0,n.blank)(l))return;const u=i.path.split("/");return(0,s.compactBlanks)([r.TagRoots.fs,l,...t?u.slice(0,-1):u])}},98604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkAssetUrl=t.mkFolderUrl=t.myWebUrl=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(27776),o=i(49076),l=i(72308),u=i(28874),c=i(42231),d=i(45200),h=i(34238),f=i(21404);function m(e=u.Settings.httpPort.valueOrDefault){const t=[u.Settings.localhost.valueOrDefault];u.Settings.exposeNetworkWithoutAuth.valueOrDefault&&t.push(...(0,s.compactBlanks)([(0,l.myExternalIp4Addresses)()[0],(0,o.hostname)()]));const i=(0,h.toURI)("http://a");return t.map((t=>i.with({authority:t+":"+e})))}t.default=m,t.myWebUrl=(0,r.lazy)((()=>m()[0])),t.mkFolderUrl=async function(e){const i=await(0,d.nativePath2uri)(e),r=(0,f.uriToTagPath)({uri:i,isFile:!1});if((0,s.isEmpty)(r))return;const n=(0,a.mkTagUri)((0,c.tagPathToStringArray)(r));return(0,t.myWebUrl)()?.with(n)},t.mkAssetUrl=function(e){return(0,n.gt0)(e)?(0,t.myWebUrl)()?.with({path:"/asset/"+e}):void 0}},4988:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.httpRequest_=t.get_=t.HttpMethods=void 0;const a=n(i(37067)),o=n(i(44708)),l=i(22573),u=i(45599),c=i(50989),d=i(51926),h=i(50213),f=i(45255),m=i(22911),p=i(43205),g=i(34238),y=i(51140),v=(0,u.defer)((()=>(0,h.mkLogger)("net.get")));async function w(e,t){return b({...t,url:e})}async function b(e){const t=(0,g.toURI)(e.url),i=new m.Deferred("get "+t.toString()),r="http"===t.scheme?a.request:"https"===t.scheme?o.request:v().throw("unsupported scheme: "+t.scheme),s=e?.maxRedirects??8,n=e?.timeoutMs??f.ShortCommandTimeoutMs,u={...e?.headers,"user-agent":await(0,p.userAgent)()},c=e?.method??"GET",h=e?.agent??!1,b=r(t.toString(),{method:c,headers:u,timeout:n,agent:h},(e=>{let r="";e.setEncoding("utf8").on("data",(e=>r+=e.toString())).resume().on("end",(()=>{const a={url:(0,l.toNotBlank)(e.url)??t.toString(),contentType:e.headers["content-type"],statusCode:e.statusCode??-1,data:r};s>0&&y.HttpStatusIs.redirect(a.statusCode)&&!(0,l.blank)(e.headers.location)?(console.log("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),v().info("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),i.observe(w(e.headers.location,{timeoutMs:n,maxRedirects:s}))):(v().debug("complete",{...a,data:(0,d.ellipsize)(r,64),data_length:r.length}),i.resolve(a))}))})).on("error",(e=>i.reject(e)));return(0,l.blank)(e.body)||b.write(e.body),b.end(),i}t.HttpMethods=(0,c.strEnum)("GET","PUT","POST","PATCH","DELETE"),t.get_=w,t.httpRequest_=b},65713:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),s=i(19851),n=i(23838),a=i(81168),o=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,s.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,s.lazy)((async()=>{const e=(0,o.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,s.lazy)((()=>({trie:new n.MultiMap,small:[]}))),h=3;function f(e){const t=new n.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=s)return s}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),s=i(96249),n=i(23838),a=i(59455),o=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=n.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,a.toA)(u[t])],n=c(e.substring(1));return(0,s.flatten)(n.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,o.stripDiacritics)(e).normalize())}},30933:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const s=r(i(48161)),n=i(19851),a=i(42659),o=i(31586),l=i(50213),u=i(28874),c=(0,n.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,n.lazy)((()=>s.default.cpus()),5*a.minuteMs),t.cpuCount=(0,n.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=s.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,o.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},14854:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CpuUsage=t.isTooBusy=void 0;const d=c(i(48161)),h=i(42659),f=i(45599),m=i(55835),p=i(31586),g=i(68708),y=i(19851),v=i(50213),w=i(7282),b=i(78406),S=i(25764),P=i(38835),_=i(74128),M=i(82647),T=i(43334),E=i(28874),k=i(30933),D=i(15674),x=(0,y.lazy)((()=>(0,v.mkLogger)("work.CpuUsage"))),C=(0,y.lazy)((()=>{const e=F.instance().busyPct();(0,_.syncReport)().maybeSystemData({from:"cpuUsage",state:"note",details:"Current system load is too high to schedule more work",meta:(0,g.compactValues)({loadCpuPct:I(),cpuBusyPct:e})}),x().warn("Current system load is too high to schedule more work",{cpuBusyPct:e,max:E.Settings.cpuBusyPercent.valueOrDefault})}),((0,w.isTest)()?15:60)*h.secondMs);t.isTooBusy=function(){if(E.Settings.cpuBusyPercent.valueOrDefault<=0)return!1;const e=F.instance().busyPct(),t=(0,p.clamp)(1,150,Math.round(4*E.Settings.cpuBusyPercent.valueOrDefault/3));return(0,p.gte)(e,t)?(C(),!0):(C.unset(),!1)};class F extends b.EndableInterval{constructor(){super({name:"CpuUsage()",callback:()=>l(this,r,"m",o).call(this),intervalMs:((0,D.singleThreadedMode)()?60:T.isWin?20:10)*h.secondMs,rank:S.EndableRanks.first}),r.add(this),s.set(this,new M.Average(5)),n.set(this,new A),(0,p.mapFinite)(I(),(e=>l(this,s,"f").push(e))),l(this,r,"m",o).call(this)}get cpuCount(){return l(this,n,"f").cpuCount}idlePct(){return(0,m.map)(this.busyPct(),(e=>100-e))}busyPct(){return l(this,s,"f").sampleAvg??I()}}t.CpuUsage=F,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){(0,p.gte0)(e)&&l(this,s,"f").push(e)},o=function(){l(this,r,"m",a).call(this,I());const e=new A;l(this,r,"m",a).call(this,e.busyPct(l(this,n,"f"))),u(this,n,e,"f")},F.instance=(0,f.defer)((()=>new F));class A{constructor(e=d.default.cpus()){let t=0,i=0;for(const r of e)t+=r.times.user+r.times.nice+r.times.sys+r.times.irq,i+=r.times.idle;this.busyMs=t,this.idleMs=i,this.cpuCount=e.length}busyPct(e){const t=this.busyMs-e?.busyMs,i=this.idleMs-e?.idleMs,r=t+i;return e?.cpuCount===this.cpuCount&&(0,p.gte0)(t)&&(0,p.gte0)(i)&&(0,p.gt0)(r)?(0,p.sigFigs)(t/r*100,3):void x().warn("busyPct(): Unexpected CpuTimes. If this continues, busyPct() will be incorrect."+P.InternalErrorFlag,{self:this,prior:e,busyMs:t,idleMs:i,totalMs:r})}}function I(){return T.isWin?void 0:(0,p.sigFigs)(d.default.loadavg()[0]/(0,k.cpuInfo)().length*100,3)}},58444:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const s=r(i(48161)),n=i(19851),a=i(31586),o=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,n.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,n.lazy)((()=>{const e=s.default.freemem(),t=s.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,a.gt0)(r))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,o.fmtBytes)(i),freemem:(0,o.fmtBytes)(e),totalmem:(0,o.fmtBytes)(t)}})}))},69385:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOnResume=t._setPaused=t.resume=t.pause=t.isPaused=void 0;const r=i(34102),s=i(37692);let n=!1;function a(){return n}function o(e=!0){l(e),(0,s.writeStateFile)({paused:e})}function l(e){e!==n&&(n=e,(0,r.ee)().emit(e?"pause":"resume"))}t.isPaused=a,t.pause=o,t.resume=function(){return o(!1)},t._setPaused=l;const u=Promise.resolve();t.resolveOnResume=function(){return a()?new Promise((e=>{(0,r.ee)().once("resume",e)})):u}},15674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),s=i(42659),n=i(41400),a=i(31586),o=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,n.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,r.lazy)((()=>{const e=(0,a.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*o.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/o.MB),worstCaseMemPerProcMb:Math.ceil(e/o.MB)}})}),s.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,a.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function b(){return((0,a.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=b,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(b()*(0,f.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(b()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=w();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const s=Math.min(e,v());return t=(0,a.clamp)(1,s,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:b(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,a.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,a.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,a.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},37692:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addStateEvent=t.writeStateFile=t.readStateFile=t.stateEvents=t.StateEvents=t.StateEventFns=void 0;const s=r(i(78474)),n=i(40958),a=i(76790),o=i(42659),l=i(45599),u=i(41400),c=i(68708),d=i(50989),h=i(87290),f=i(73787),m=i(19851),p=i(50213),g=i(28874),y=i(69385),v=(0,l.defer)((()=>(0,p.mkLogger)("work.SharedState")));let w;t.StateEventFns={checkTasks(){},reloadLicenses(){}},t.StateEvents=(0,d.strEnum)(...(0,c.keys)(t.StateEventFns)),t.stateEvents=new s.default;let b=0;function S(){const e=(0,h.libraryDataDirPosixFile)()?.join("state.json"),t=Date.now(),i=t-b>o.minuteMs;i&&(b=t);const r=e?.existsSync({refresh:i})??!1;return r&&null!=e&&e.eql(w?.nativePath)||(w?.close(),w=void 0),r&&null!=e&&(w??(w=new f.FileWatcher(e.nativePath,{encoding:"utf8",persistent:!1,recursive:!1},P))),e}(0,u.later)((()=>{g.Settings.libraryDir.watchLater(P)}));const P=(0,m.lazy)((()=>t.readStateFile.refresh()),25);t.readStateFile=(0,m.lazy)((()=>{const e=S()?.readJsonSync();for(const i of e?.events??[])_.get(i.e)!==i.ts&&(v().info("emitting event "+i.e),t.stateEvents.emit(i.e),_.set(i.e,i.ts));return(0,y._setPaused)(e?.paused??!1),e}));const _=new Map;function M(e){const i=S();if(null==i)v().error("overwrite(): failed: no library directory");else{const r=i?.readJsonSync(),s=function(e){const t=Date.now()-10*o.minuteMs;return(0,n.uniqByLast)((0,a.sortBy)((e??[]).filter((e=>e.ts>t)),(e=>e.ts)),(e=>e.e))}([...r?.events??[],...e.events??[]]),l={paused:e.paused??r?.paused??g.Settings.startPaused.valueOrDefault,events:s};(0,y._setPaused)(l.paused),t.readStateFile.set(l),i.writeJsonSync(l)}}t.writeStateFile=M,t.addStateEvent=function(e){const t=Date.now();_.set(e,t),M({events:[{e,ts:t}]})}},22751:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),s=i(87997),n=i(19851),a=i(42659),o=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,n.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,n.lazy)((()=>new r.Rate(5*a.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,n.lazy)((()=>(0,s.setInterval)(g,a.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,o.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),s=i(22573),n=i(50357),a=i(98553),o=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function v(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function b(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function S(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,o.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const s=[];if(et;n-=i)s.push(r(n));return s}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),s=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===s[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,n.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const s of t){const t=i(s);r.includes(t)||(e.push(s),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>!(0,n.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=b,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(s.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=b(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return S(t,(e=>(0,l.isPrimitive)(e)?e:(0,a.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,n.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=b(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=S,t.uniqByLast=function(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of b(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,a.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const s=new Set(i.map(r));return e.filter((e=>!s.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),s=i(36783),n=i(41801),a=i(98553),o=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,s.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const r of e)(0,o.getOrSet)(i,(0,a.stringify)(t(r)),(()=>r));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,s.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,n.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},75761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetImgAttrs=t.assetSqImgAttrs=t.assetVideoLink=t.assetImgActualLink=t.assetImgLink=t.assetLinkAttrs=t.assetUrl=void 0;const r=i(58939),s=i(40958),n=i(22573),a=i(42659),o=i(11371),l=i(73722),u=i(31586),c=i(54993),d=i(29652),h=i(22403),f=i(2322);function m(e,t){return e+" "+t+"w"}function p(e,t){let i=null==t?void 0:(0,d.mergeURLSearchParams)(...t);const r=(0,c.toS)(e.v);return(0,n.blank)(r)||"1"===r||(i??(i=new URLSearchParams)).append("v",r),i}function g({assetId:e,params:t}){return null==e?"":(0,d.assembleFullPath)("/asset/"+(0,r.id2id)(e),p(e,t))}function y({assetId:e,reducer:t,width:i,params:s}){return(0,d.assembleFullPath)(`/img/${(0,r.id2id)(e)}/${t}/${(0,u.toGt0)(i)??320}`,p(e,s))}function v({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/img/${(0,s.compact)([(0,r.id2id)(e),t]).join("/")}/actual`,p(e,i))}function w({assetId:e,params:t,reducer:i,widths:s,lazyLoad:n,af:l}){if(null==(0,r.id2id)(e))return{src:"/images/clear-64.png"};0===(s=(s??[]).filter(u.gt0)).length&&s.push(320);const d=Math.min(...s),p={width:(0,c.toS)(d)},g=(0,a.fmtLocalToShort)(e.capturedAtLocal);null!=g&&(p.title=g);const w=y({assetId:e,params:t,reducer:i,width:d});n??(n=!0);const b=n&&(0,f.isSafari)((0,h.ua)());b?(p.src="/images/clear-64.png",p["data-src"]=w):p.src=w,(0,f.isSafari)((0,h.ua)())||(p.loading=n?"lazy":"eager"),i===o.ReducerNames.sq&&(p.height=(0,c.toS)(d));const S=s.map((r=>m(y({assetId:e,params:t,reducer:i,width:r}),r)));return null!=l&&S.push(m(v({assetId:e,params:t,assetFileId:l.assetFileId}),l.width)),p[(b?"data-":"")+"srcSet"]=S.join(","),p}t.assetUrl=g,t.assetLinkAttrs=function({assetId:e,params:t}){const i=g({assetId:e,params:t});return(0,n.blank)(i)?{}:{href:i}},t.assetImgLink=y,t.assetImgActualLink=v,t.assetVideoLink=function({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/video/${(0,r.id2id)(e)}-${t}`,p(e,i))},t.assetSqImgAttrs=function({assetId:e,params:t,lazyLoad:i,size:r="m"}){return{...w({assetId:e,params:t,reducer:"sq",widths:l.SqWidths,lazyLoad:i}),sizes:("s"===r?80:"m"===r?160:320)*(0,u.numericOr)(globalThis?.window?.devicePixelRatio,1)+"px"}},t.assetImgAttrs=w},5233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),s=i(31586),n=i(13538),a=i(41583);t.retryOnReject_=async function(e,t){const i=(0,s.gt0)(t.timeoutMs)?()=>(0,n.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const o=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,a.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await o(l),u()}};return u()}},17586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55938),o=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,a.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,a.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,s.blank)(e)?"":"```"+(0,o.toS)(e)+"```"},t.b=function(e){return"**"+(0,o.toS)(e)+"**"},t.li=function(...e){return(0,r.compactBlankish)((0,n.flatten)(e)).map((e=>"- "+(0,o.toS)(e))).join("\n")}},22573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),s=i(42279),n=i(54993);function a(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function o(e){return!a(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,n.toS)(e);return o(i)?t(i):void 0}t.blank=a,t.notBlank=o,t.notBlankToS=function(e){return o(e)&&"undefined"!==e?(0,n.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,n.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,s.tot)(t);const i=(0,n.toS)(e).trim();return i.length>0?i:(0,s.tot)(t)},t.notBlankAnd=function(e,t){return!a(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,n.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{"use strict";function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),s=i(22573),n=i(30301),a=i(55835),o=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,a.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,o.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const s=Math.floor(e/t.minuteMs);e-=s*t.minuteMs;const n=Math.floor(e/t.secondMs),a=Math.floor(e-n*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(s)+":"+(0,l.pad2)(n)+(i.includeMs?"."+(0,l.pad3)(a):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),s=i(),n=i(),a=i(),o=i(),l=i();return new Date(t,l-1,o,a,n,s,r)}function w(){return(new Date).setHours(24,0,0,0)}function b(e,i="ago"){return e<1e3?"just now":(i=(0,s.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const n=Math.floor(e/r.ms);e-=n*r.ms,n>0&&(r.ms>=t.dayMs?i:s).push(n+r.s)}return e>0&&s.push((0,o.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(s)?"":"T"+s.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,a.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return b(Date.now()-e,t)},t.fmtElapsedMs=b},95892:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),s=i(73872);function n(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function a(e,t,i,r){if(null==i||y(e)||y(t))return;let s=i.get(e);null!=s?s.set(t,r):(s=new WeakMap,s.set(t,r),i.set(e,s))}function o(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const s=l(e,t);return null!==s?s:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=n(e,t,u);if(null!==f)return f;const m=n(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return a(e,t,u,i),i;const s=l(e,t);if(null!==s)return s}const y=s(e);if(y!==s(t))return a(e,t,u,!1),!1;a(e,t,u,!0);const v=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return o(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],s=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){s.push([e,t])})),c(r.sort(),s.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return a(e,t,u,v),v}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let s=-1;for(;++s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const s=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return s.prior=()=>t,s.hasPrior=()=>r,s}},41400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),s=i(35556),n=i(31586),a=i(68708);function o(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const n=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&s.isNode&&n.unref?.()}}))}t.delayUntil=function(e){const t=((0,n.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return o(t).then((()=>t))},t.delay=o,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),n=s.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return s.isBrowser||t<=r.secondMs?n:(0,a.maybeCall)(n,"unref")??n}},33374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const r=i(31586),s=i(21605),n=i(12168);function a(e){return{width:e.height,height:e.width}}function o(e){return((0,r.toGt0)(e?.width)??0)*((0,r.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,r.gt0)(e.width)&&(0,r.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,r.gt0)(e)&&(0,r.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,n.pixels2size)(e.width*e.height)},t.dimSwap=a,t.maybeDimSwap=function(e,t){return(0,s.swappableRotation)(t)?a(e):e},t.maybeFlipInPlace=function(e,t){(0,s.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,n.megapixels)(o(e))},t.pixels=o},50357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),s=i(68708),n=i(34666),a=i(32639);function o(e,t){return(0,r.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,a.isFunction)(e)&&(0,a.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=o,t.eqlSubset=function(e,t){if(null==e||null==t||(0,n.isPrimitive)(e)||(0,n.isPrimitive)(t))return e===t;if(!(0,s.isObject)(e)||!(0,s.isObject)(t))return!1;for(const i of(0,s.keys)(e))if(!o(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(31586),o=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,s.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,a.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,n.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,s.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,s.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,s.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(s.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,o.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,o.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,o.assignFields)(new Error,(0,o.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},4188:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),s=i(42659),n=i(55835),a=i(31586),o=i(12168),l=[{ms:s.yearMs,s:"year",p:"years"},{ms:s.yearMs/12,s:"month",p:"months"},{ms:s.weekMs,s:"week",p:"weeks"},{ms:s.dayMs,s:"day",p:"days"},{ms:s.hourMs,s:"hour",p:"hours"},{ms:s.minuteMs,s:"minute",p:"minutes"},{ms:s.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,s){if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,n.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,o.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,n.mapOr)(s,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function s(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=s,t.orList=function(e){return s(e,"or")},t.andList=function(e){return s(e,"and")}},50268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const r=i(22573),s=i(38639),n=i(68708),a=i(62220),o=i(50989);t.HealthCheckSections=(0,o.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,o.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,n.isObject)(e)&&!(0,r.blank)(e.id)&&!(0,r.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,r.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,n.isObject)(e)&&a.RunStates.has(e.state)&&(0,s.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},11371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReducerNames=void 0;const r=i(50989);t.ReducerNames=(0,r.strEnum)("fit","sq")},73722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const s=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,s){if((0,isFunction_1.isFunction)(r))return;let n,a,o,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(n=0;nnew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),s=i(50357),n=i(31586),a=i(65812);t.lazy=function(e,t){let i,o;const l=[];function u(){return u.isStale()&&u.setResult(e()),o}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const n=await e,o=await i;if(!(0,s.eql)(n,o))for(const e of l)e(o);null!=t&&t>0&&void 0!==o&&(0,a.setUnrefTimeout)((()=>u.vacuum()),t)}(o,e),o=e},u.isStale=function(){return null==i||(0,n.gt0)(t)&&i+t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),s=i(54993);function n(e,t){return null==e?void 0:t(e)}function a(e,t,i){return null==e||null==t?void 0:i(e,t)}function o(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=n,t.mapTry=function(e,t){try{return n(e(),t)}catch{return}},t.map2=a,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=o,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return o(a(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,s.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class s extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=s},23838:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),s=i(76790),n=i(50357),a=i(98553),o=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,o.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,o.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,n.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),s=null==i?[]:e(t,i);(0,r.isEmpty)(s)?this.store.delete(t):this.store.set(t,s)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,s]of this.store.entries()){const n=(0,r.findIndexes)(s,(t=>!e(i,t,s)));if(n.length>0){t=!0;for(const e of n.reverse())s.splice(e,1)}0===s.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,a.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,s.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),s=i(22573),n=i(42279),a=i(54993);function o(e){return"number"==typeof e&&isFinite(e)}t.isNumber=o,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,a.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return o(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,a.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>o(t)&&o(i)&&e(t,i);function f(e,i,s){return!(null==s||!o(s))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,s)&&(0,t.gte)(i,s))}function m(e){if(!o(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,s.blank)(e))return t.defaultValue;if(o(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return o(e)&&e>0}function b(e){return o(e)&&e>=0}function S(e,t){return o(e)?t(e):void 0}function P(e){return o(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function M(e,t,i){if(e>t||!o(e)||!o(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return o(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return o(e)?e:t},t.diff=function(e,t){return o(e)&&o(t)?e-t:void 0},t.absdiff=function(e,t){return o(e)&&o(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!o(e)||!o(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return f(t-r,t+r,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)o(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return o(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return o(e)&&o(t)&&e>t?e:void 0},t.lte0=function(e){return o(e)&&e<=0},t.gte0=b,t.toGte0=function(e){return b(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=v(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=S,t.map2Numeric=function(e,t,i){return S(e,(e=>S(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return o(e)?t(e):i},t.numericOr=function(e,t){return o(e)?e:(0,n.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return S(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!o(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=M,t.times=function(e,t){if(!w(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return M(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!o(i))return;t+=i}return t}},68708:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(32639),o=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function w(e,t,i={}){return y((0,r.compact)((0,s.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function b(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const s={};for(const e of(0,r.uniq)((0,r.flatMap)(i,h)))s[e]=b(...i.map((t=>t[e])));return s}function S(e,t){if(!d(e)||(0,n.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=v(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,s]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==s&&!0!==i?.assignNullish||(e[r]=s));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,o.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,n.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=b,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,n.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=o.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function s(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:b(i,t)}for(const r of i){const[i,a]=(0,c.splitFirst)(r,"."),o=S(t,i);null!=o?.value&&s(o.key,(0,n.blank)(a)?o.value:e(o.value,a))}for(const r of h(t))((0,l.toInt)(r)??-1)>=0&&s(r,e(t[r],...i));return r},t.pluck=S,t.pluckDeep=function e(t,i){if(null==t||(0,n.blank)(i))return;if(Array.isArray(t)){const s=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(s)?void 0:{key:s[0].key,value:(0,r.flatMap)(s,(e=>e.value))}}const[s,a]=(0,c.splitFirst)(i,"."),o=S(t,s);if(null==o)return;if((0,n.blank)(a))return o;const l=e(o.value,a);return null==l?void 0:{key:o.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,n.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,a.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,n.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=w(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>n(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return s(t)?t:n(t)}filter(e){return n(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return n(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return n(e).flatMap((e=>n(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return n(e).flatMap((e=>n(t).flatMap((t=>n(i).flatMap((i=>r(this.a,e,t,i)))))))}}function s(e){return e instanceof r||e===t.None}function n(e){return s(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=s,t.opt=n},97238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSeed=t.prngSeed=t.SeedCount=t.PrimeBins=t.PrimesPerBin=void 0;const r=i(31586),s=i(30976),n=i(54993);t.PrimesPerBin=4,t.PrimeBins=8,t.SeedCount=t.PrimesPerBin**t.PrimeBins,t.prngSeed=function(){return(0,s.randomInt)(0,t.SeedCount)},t.toSeed=function(e){const i=(0,r.toInt)((0,n.toS)(e));return(0,r.within)(0,t.SeedCount,i)?i:void 0}},39926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),s=i(54993),n={};function a(e,t){if(t<1)return"";if(!(0,r.gte)(n[e]?.length,t)){let i=n[e]??e;for(;i.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var r=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return r.parseJSON}})},46891:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),s=new Map([["child","children"],["photo","photos"],["video","videos"]]),n=/([sxz]|ss|sh|ch)$/,a=/[^aeiou]y$/,o=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=s.get(e);return null!=t?t:null!=e.match(n)?e+"es":null!=e.match(a)?e.replace(/y$/i,"ies"):null!=e.match(o)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),s=i(54993),n=["number","string","boolean"];function a(e){return-1!==n.indexOf(typeof e)}t.isPrimitive=a,t.mapPrimitive=function(e,t){return a(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return a(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(a)};const o=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,n=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==n&&"symbol"!==n)){const r=(0,s.toS)(e),n=(0,s.toS)(i),a=r.localeCompare(n);return r[0]===t.CmpReverseFlag&&n[0]===t.CmpReverseFlag?-a:a}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==n?o.indexOf(r)-o.indexOf(n):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function s(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const s of(0,r.toA)(await e))if(null!=s){const e=await s;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=s,t.isPromise=function(e){return s(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),s=i(31586);function n(e,t){return Math.floor(Math.random()*(t-e))+e}function a(e,t,i){return null==i||0===i.length?n(e,t):o(e,t,1,i)[0]}function o(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const s=t-e,a=new Set(r??[]);if(t===e&&0===s&&0===a.size&&1===i)return[e];const o=s-a.size;if(i>o)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:s,size:i,slotsRemaining:o})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of o(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,s.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let r=e;t.global||(t=new RegExp(t,"g"));let s=null;for(;null!=(s=t.exec(e));)s.index===t.lastIndex&&t.lastIndex++,r=r.slice(0,s.index)+i(s)+r.slice(s.index+s[0].length);return r}},21605:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const r=i(31586);function s(e){if(!(0,r.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,r.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=s,t.swappableRotation=function(e){const t=s(e);return 90===t||270===t}},62220:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const r=i(50989);t.RunStates=(0,r.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),s=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),n={};for(const e of t)n[e]=e;const a=e=>null!=e?i[e]:void 0,o=e=>null!=a(e);return{...n,values:t,length:t.length,has:o,includes:o,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:a,ordinal:e=>a(e)??t.length,validOrElse:(e,t)=>o(e)?e:(0,s.tot)(t),mapValid:(e,t)=>o(e)?t(e):void 0,cmp:(e,t)=>{const i=a(e),r=a(t);return null==i||null==r?void 0:i>r?1:i{const i=a(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),s=i(17586),n=i(22573),a=i(96249),o=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=f();return null!=r?(0,o.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function b(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function S(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),s=(0,c.toS)(t);return r.length===s.length&&(r===s||r.toLowerCase()===s.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?s.normalize():s,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,n.blank)(t)?void 0:e.find((e=>S(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,s.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,o.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return w(v(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=b,t.wrap=function e(t,i){const r=i?.maxLineLen??80,s=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,a.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,a.flatten)(r.map((t=>e(t,i))))}if((t=v((0,c.toS)(t),s).trim()).length<=r)return[t];const n=b(t," ",r);if(n>s.length)return[m(t,0,n),...e(m(t,n+1),i)];{const r=t.indexOf(" ",s.length+1);return r>0&&r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),s=i(68708),n=i(42279),a=i(83104),o=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let s=!0;const n=setTimeout((()=>{s&&(s=!1,i(a.Timeout))}),t);try{n.unref?.();const t=await e;s&&(s=!1,i(t))}catch(e){s&&(s=!1,r(e))}finally{clearTimeout(n)}}))}async function u(e,t,i=!0){const s=await l(e,t,i);if(s===a.Timeout)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return s}t.toNotTimeout=function(e){return e===a.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?a.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,n)=>{let a=!0;try{const o=setTimeout((async()=>{if(a){a=!1;try{r(await i())}catch(e){n(e)}}}),t);(0,s.maybeCall)(o,"unref");const l=await e;a&&(a=!1,clearTimeout(o),r(l))}catch(e){a&&(a=!1,n(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const s=t-Date.now();if(s<=0)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(s)+")");return u(e,s,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const s=await l(e,t,r);return s===a.Timeout?(0,n.tot)(i):s}},42279:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),s=i(22573),n=i(54993);function a(e){return"URLSearchParams"===e?.constructor?.name}function o(e){return null==e?void 0:a(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(o)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=a,t.toURLSearchParams=o,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,n.toS)(l(...t));return e+((0,s.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,n.toS)(l(...t));return(0,s.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),s=i(30301),n=i(31586),a=i(46891),o=i(50989),l=i(51926),u=(0,s.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,n.isNumber)(r)&&(i+=r/t.MB);return(0,n.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,n.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,n.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),s=Math.pow(10,3*r),a=d[r];return(0,n.sigFigs)(e/s,t)+" "+a}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),s=Math.pow(2,10*r),a=h[r];return(0,n.sigFigs)(e/s,t)+" "+a},t.MP=1e6,t.megapixels=function(e){return(0,n.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,o.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,a.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,a.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},22403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ua=void 0;const r=i(30301),s=i(54993);t.ua=(0,r.lazy)((()=>(0,s.toS)(globalThis?.navigator?.userAgent)))},2322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,r=/\bSafari\b/,s=/\bFirefox\b/,n=/\biPad\b/,a=/\biPhone\b/;function o(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return o(e,i)}function u(e){return o(e,s)}t.isChrome=l,t.isSafari=function(e){return o(e,r)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return o(e,n)},t.isIphone=function(e){return o(e,a)}},58939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.idEql=t.id2id=void 0;const r=i(55835),s=i(31586);function n(e){const t=e;return(0,s.isNumber)(e)?e:(0,s.isNumber)(t.id)?t.id:(0,s.isNumber)(t.assetId)?t.assetId:(0,s.isNumber)(t.tagId)?t.tagId:void 0}t.id2id=n,t.idEql=function(e,t){return(0,r.map2Or)(n(e),n(t),((e,t)=>e===t),(()=>!1))}},79114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.S=void 0;const r=i(50989);t.S=(0,r.strEnum)("plus","lite")},75020:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInfoTag=t.NotInfoPanelTags=t.LibraryTagName=t.TagRoots=t.isTagRef=t.ctxToS=t.TagGalleryProps=t.nextChildTagsUrl=t.nextAssetsUrl=t.BeforeAfterStreamLimit=t.ThumbsPerSample=void 0;const r=i(76790),s=i(22573),n=i(98553),a=i(31586),o=i(50989),l=i(51926),u=i(29652);t.ThumbsPerSample=128,t.BeforeAfterStreamLimit=8,t.nextAssetsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/assets`,i)},t.nextChildTagsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.seed,(e=>i.seed=e.toString())),(0,a.mapNumeric)(t.limit,(e=>i.limit=e.toString())),(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/child-tags`,i)},t.TagGalleryProps=["tagId","tagPath","assetCount","assetIds","nextAssets","childTags","nextChildTags"],t.ctxToS=function(e){return(0,n.stringify)({seed:e.seed,tagIds:(0,r.sort)([...e.tagIds])})},t.isTagRef=function(e){return null!=e&&!(0,l.isString)(e)&&(0,s.notBlank)(e.name)},t.TagRoots=(0,o.strEnum)("When","Who","Where","What","Camera","Lens","Albums","Keywords","Type","fs"),t.LibraryTagName="Library",t.NotInfoPanelTags=[t.TagRoots.When,t.TagRoots.Camera,t.TagRoots.Lens,t.TagRoots.Type,t.TagRoots.fs],t.isInfoTag=function(e){if(null==e)return!1;const i=(0,l.isString)(e)?e:e.tagPath?.[0];return!t.NotInfoPanelTags.includes(i)}},27776:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkTagUri=t.mkTagFullPath=t.mkHomeFullPath=t.urlSeed=void 0;const r=i(40958),s=i(30301),n=i(31586),a=i(97238),o=i(29652);function l(e,i){const r=(0,o.toURLSearchParams)(e);if(i||!(0,n.isDigits)(r?.get("seed"))){const e=(0,t.urlSeed)().toString();return r?.set("seed",e),r??{seed:e}}return r}function u(e,t,i=!1){const r=c(e,t,i);return(0,o.assembleFullPath)(r.path,r.query)}function c(e,t,i=!1){return{path:"/tag/"+((0,r.isEmpty)(e)?"":e.map(encodeURIComponent).join("/")),query:l(t,i)}}t.urlSeed=(0,s.lazy)(a.prngSeed,100),t.mkHomeFullPath=function(e){return u([],e,!0)},t.mkTagFullPath=u,t.mkTagUri=c},23541:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),s=i(51926);function n(e){return Array.isArray(e)?e:null==e?void 0:(0,s.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return n(e)??[]},t.optToA=n},41583:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),s=i(23541),n=i(59455),a=i(54993);function o(e){return null==e?void 0:(0,s.isError)(e)?e:new Error((0,a.toS)(e))}t.toErr=o,t.toErrs=function(...e){return(0,r.compact)((0,n.toA)(e).map(o))}},54993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return n(e,",")};const s={}.toString;function n(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>n(e,t))).join(t):e.toString!==s?e.toString():(0,r.stringify)(e)}}t.toStr=n},98401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cancelFileAndProcCleanups=t.scheduleFileAndProcCleanups=t.fileCleanups=t.cleanup_=t.maybeCleanup_=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(56519),o=i(76187),l=i(87290),u=i(79267),c=i(32144),d=i(13829),h=i(69734),f=i(95696),m=i(65238),p=i(70257),g=i(13940),y=i(12495),v=i(95402),w=i(28874),b=i(40958),S=i(42659),P=i(31586),_=i(64526),M=i(22526),T=i(69032),E=(0,r.lazy)((()=>(0,s.mkLogger)("library.Cleanup")));async function k(){const e=_.Library.instance();if(null==e)E().info("No library to vacuum.");else{E().info("Running tag and search maintenance...");try{await(0,T.runTagMaintenance)()}catch(e){E().warn("Failed to run tag maintenance",{error:e})}E().info("Vacuuming db..."),await(await e.dbModelSetup_()).db.vacuum(),(0,n.isDbJanitorService)()&&(E().info("Running database maintenance..."),await e.runDbBackup_())}E().info("Cleaning child processes..."),await(v.Pids.instance()?.killOldProcs()),E().info("Cleaning stale and temp files..."),await D(),await(0,a.mapAsync)({name:"fileCleanup",arr:j(),f:e=>e.cleanup()})}t.maybeCleanup_=(0,r.lazy)(k,5*S.minuteMs),t.cleanup_=k;const D=(0,r.lazy)((()=>(0,l.libraryDataDirPosixFile)()?.join("shared-state").rmrf())),x=(0,r.lazy)((()=>u.FileCleanup.for({name:"imageCacheCleanup",rootNativePath:g.imageCacheDir_,staleMs:w.Settings.imageCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(g.ImageCacheName)}))),C=(0,r.lazy)((()=>u.FileCleanup.for({name:"readdirCacheCleanup",rootNativePath:async()=>f.PosixFile.for((0,m.readdirCacheDir)()),staleMs:w.Settings.readdirCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(m.ReadDirCacheName)}))),F=(0,r.lazy)((()=>u.FileCleanup.for({name:"previewWipCleanup",rootNativePath:l.libraryPreviewsDirPosixFile,staleMs:S.hourMs,isPrunable:e=>(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)}))),A=(0,r.lazy)((()=>u.FileCleanup.for({name:"advisoryLockWipCleanup",rootNativePath:d.defaultFsAdvisoryLockDir,staleMs:S.hourMs,isPrunable:h.isPsLockFileOrDir}))),I=(0,r.lazy)((()=>u.FileCleanup.for({name:"syncReportCleanup",rootNativePath:()=>(0,P.gt0)(w.Settings.syncReportRetentionCount.valueOrDefault)?(0,l.librarySyncReportsDir)():void 0,staleMs:S.hourMs,isPrunable:e=>(0,p.isWip)(e)||(0,c.isCsvExt)(e)})));function O(e){return(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)||(0,o.isSqliteFile)(e)}const L=(0,r.lazy)((()=>u.FileCleanup.for({name:"oldLibraryDbBackupCleanup",rootNativePath:()=>(0,M.libraryDbObjects_)().libraryDbBackupDir.sibling("backup"),staleMs:S.hourMs,isPrunable:O}))),R=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryDbBackupCleanup",rootNativePath:()=>(0,M.libraryDbObjects_)().libraryDbBackupDir,staleMs:S.hourMs,minRetained:w.Settings.dbBackupRetentionCount.valueOrDefault,isPrunable:O})));async function N(){const e=await(_.Library.instance()?.dbModelSetup_());return null!=e&&e.useReplica?e.db.localBackupDir():void 0}const B=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryReplicaDbBackupCleanup",rootNativePath:N,staleMs:S.hourMs,minRetained:1,isPrunable:O})));function j(){return(0,b.compact)([x(),C(),F(),A(),(0,y.LogDirCleanup)(),I(),L(),R(),B()])}t.fileCleanups=j,t.scheduleFileAndProcCleanups=(0,r.lazy)((()=>{v.Pids.instance()?.scheduleInterval();for(const e of j())e.scheduleInterval()})),t.cancelFileAndProcCleanups=function(){t.scheduleFileAndProcCleanups.unset(),v.Pids.instance()?.cancelInterval();for(const e of j())e.cancelInterval()}},64526:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Library=void 0;const l=i(27395),u=i(25764),c=i(38836),d=i(99331),h=i(45608),f=i(15056),m=i(87290),p=i(38835),g=i(57159),y=i(61704),v=i(95696),w=i(18454),b=i(13940),S=i(48604),P=i(19851),_=i(23560),M=i(28874),T=i(2858),E=i(7014),k=i(63870),D=i(15674),x=i(22573),C=i(38639),F=i(42659),A=i(56409),I=i(68708),O=i(25470),L=i(22526),R=i(41844);class N extends c.EndableWrapper{static instance(){const e=M.Settings.libraryDir.valueOrDefault,t=a(this,r,"f",s)?.rootDir.nativePath,i=!0===a(this,r,"f",s)?.isReadySync(),n=!0===a(this,r,"f",s)?.ended;return(0,y.nativePathsEqlSync)(t,e)&&!n?a(this,r,"f",s):(0,_.isSyncService)()&&i?void(0,h.exit)({reason:`Library changed mid-run. Shutting down to pick up new library at ${e}.`,status:0}):((0,l.end)(a(this,r,"f",s)),o(this,r,(0,x.blank)(e)||!(0,T._libraryHasSettings)(e)?void 0:new r(e),"f",s))}static get priorInstance(){return a(this,r,"f",s)}static endPriorInstance(){const e=a(this,r,"f",s);return o(this,r,void 0,"f",s),(0,l.end)(e)}static async instanceReady(){const e=r.instance();return await(e?.ready),e}static instanceRequired_(){const e=r.instance();if(null==e)throw new Error("Library is undefined"+p.FatalErrorFlag);return e}constructor(e){super(`library.Library(${e})`,(()=>this.onEnd()),u.EndableRanks.predb),this.start=Date.now(),this.readyLatch=new A.Latch,n.set(this,(0,P.lazy)((async()=>{try{this.logger.debug("setup() started"),this.logger.throwIfAborted_(),await(0,T.readLibrarySettings)(this.rootDir.nativePath),await(0,m.setupLibraryDirs_)(this.rootDir),await(0,b.imageCacheDir_)(),this.logger.throwIfAborted_();const e=await(0,E.bestVolumeForPath)((0,m.libraryPreviewsDirPosixFile)(this.rootDir));if((0,C.isTrue)(e?.remote)){const e=M.Settings.maxConcurrentImportsWhenRemote.valueOrDefault;M.Settings.maxConcurrentImports.hasValue()||(M.Settings.maxConcurrentImports.tmpValue=e,(0,D.clearMaxWorkCaches)()),this.logger.warn(`Library previews are on a remote volume. Setting maxSyncFileJobsMax to ${e}.`)}this.logger.throwIfAborted_(),(0,_.isDbService)()&&await this.dbModelJanitor(),this.previews(),this.logger.throwIfAborted_(),this.readyLatch.isPending()&&(this.logger.info("Library.setup() finished."),this.readyLatch.resolve())}catch(e){this.ended||(0,d.ending)()||(this.logger.warn("setup() failed:",{error:e}),w.HealthCheck.addError(e),this.readyLatch.reject(new g.WrappedError("Failed to start library",{cause:e})))}}))),this.previews=(0,P.lazy)((()=>(0,I.tap)(new S.Previews((0,m.libraryPreviewsDirPosixFile)(this.rootDir)),(e=>S.Previews.instance.set(e))))),this.originalsDir=(0,P.lazy)((()=>(0,m.libraryOriginalsDirPosixFile)(this.rootDir))),this.assetFileRepository=(0,P.lazy)((()=>new R.AssetFileRepository(this.originalsDir()))),this.libraryDbFile=(0,P.lazy)((()=>(0,f.pathToDb)(this.dataDir,"models"))),this.dbModelSetup_=(0,P.lazy)((async()=>{if((0,_.isDbService)())return(0,L.dbModelSetup_)(this.rootDir);throw new Error("Not a db service")})),this.dbFsLock=(0,P.lazy)((async()=>(await this.dbModelSetup_()).fslock)),this.useReplica=(0,P.lazy)((async()=>(await this.dbModelSetup_()).useReplica)),this.modelDb=(0,P.lazy)((async()=>(await this.dbModelSetup_()).db)),this.dbModelJanitor=(0,P.lazy)((async()=>O.DbModelJanitor.for(await this.dbModelSetup_()))),this.onEnd=(0,P.lazy)((async()=>{if(!(0,d.ending)())for(const{ea:e,t}of[{ea:this.dbModelJanitor.clear(),t:5*F.minuteMs},{ea:this.dbFsLock.clear(),t:(0,k.commandTimeoutMs)()}])await(0,l.end)(e,t);this.logger.info("onEnd(): finished.")})),this.rootDir=v.PosixFile.for(e),this.dataDir=(0,m.libraryDataDirPosixFile)(this.rootDir),this.logger.info("new()"),a(this,n,"f").call(this)}get isPendingSetup(){return this.readyLatch.isPending()}get ready(){return this.readyLatch.promise.then((()=>this))}isReadySync(){return this.readyLatch.isResolved()}async runDbBackup_(){return(await this.dbModelJanitor())?.backup_()}}t.Library=N,r=N,n=new WeakMap,s={value:void 0}},19113:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFileFiltersFor=void 0;const r=i(62105),s=i(181),n=i(94448),a=i(39604);t.libraryFileFiltersFor=function(e,{validateFile:t=!1}={}){const i=(0,r.expensiveFileFiltersFor)(e);return null!=(0,n.modelDb)()&&i.push({notBlocklistedSha:a.notBlocklistedSha}),t&&i.push({isValidFile:s.isValidFile}),i}},56992:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.calcVolumesTTL=t.setVolumesTTL=void 0;const r=i(19851),s=i(50213),n=i(76596),a=i(87290),o=i(28874),l=i(2858),u=i(63870),c=i(7014),d=i(42659),h=i(31586),f=i(12168),m=(0,r.lazy)((()=>(0,s.mkLogger)("SetVolumesTTL")));async function p(){if(!(0,l.libraryHasSettings)())return;const e=[],t=await(0,c.volumes)(),i=o.Settings.minDiskFreeGb.defaultValue*f.GB;for(const r of[(0,a.libraryOriginalsDirPosixFile)(),(0,a.libraryPreviewsDirPosixFile)()]){const s=await(0,c.bestVolumeForPath)(r,t);if(null==s)return void m().warn("Can't find volume for "+r+", using default TTL for volumes()");if(s.available(0,l.mkLogger)("library.SuggestedLibraryDir")));class A{static async for(e,t){if((0,D.blank)(e))return;const i=await(0,T.bestVolumeForPath)(e,t);if(null==i)return void F().warn("Skipping library directory suggestion: failed to find mountpoint volume",{nativePath:e});const r=await(0,m.isLibraryDir)(e);return new A(e,r,i)}constructor(e,t,i){this.nativePath=e,this.isLibrary=t,this.vol=i,this.isCurrentLibrary=M.Settings.libraryDir.value===this.nativePath}async whyExcluded(e=M.Settings.minDiskFreeGb.valueOrDefault*C.GB){if(this.isLibrary)return;const t=await(0,P.statMaybe)(this.nativePath,"trace"),i={msg:"whyExcluded()",meta:{nativePath:this.nativePath,stat:t,availableBytes:this.availableBytes,minAvailableBytes:e}};if((0,b.containsHiddenPathname)(this.nativePath))return F().tap({...i,result:"contains hidden path"});{const e=await(0,w.whyExcludedDirectoryRecursive)(v.BaseFile.for(this.nativePath));if(null!=e)return F().tap({...i,result:e})}return null==t||t.isDirectory()?await(0,y.canRWXFirstExistingAncestor)(this.nativePath)?(0,x.gt0)(e)&&this.availableBytesnew A(e,!1,{mountpoint:"/test",available:C.GB})))});const l=[],d=[],y=await i??await(0,T.volumes)();if(null==y||(0,E.isEmpty)(y))return F().warn("volumes() is empty: they don't get any suggestions."),[];async function v(t){const i=await A.for(t,y);if(null!=i)return i.isLibrary||i.isCurrentLibrary?(F().info("addSuggestion(): path is a library",i),void l.push(i)):void(null==await i.whyExcluded(e)&&d.push(i))}if(await v(M.Settings.libraryDir.value),(0,_.isDocker)())return[...l,...d];await v(await(0,p.picturesDir)());const w=[n.default.cwd(),...await(0,S.childDirectories_)(n.default.cwd())];(0,_.isDocker)()||w.push(...await(0,S.childDirectories_)((0,f.homeDir)())),(0,E.filterInPlace)(w,(e=>(0,b.isNotHiddenPosixPath)(e)));for(const e of w)await(0,m.isLibraryDir)(e)&&(F().info("current working dir is a library",e),await v(e));function P(){return Date.now()-r>c.ShortCommandTimeoutMs-500&&(F().debug("...ran out of time, stopping."),!0)}(0,_.isDocker)()||await v(s.default.join((0,f.homeDir)(),(0,a.AppName)())),await(0,h.mapAsync)({name:"suggestedLibraryDirs.addVolume",arr:y,f:e=>async function(e){try{if(await(0,m.isLibraryDir)(e.mountpoint))return F().info("addVolume(): vol.mountpoint is a library",e.mountpoint),void await v(e.mountpoint);for(const t of await(0,S.childDirectories_)(e.mountpoint)){if(P())break;if(await(0,m.isLibraryDir)(t))F().info("addVolume(): dir is a library",t),await v(e.mountpoint);else for(const i of await(0,S.childDirectories_)(t)){if(P())break;await(0,m.isLibraryDir)(i)&&(F().info("addVolume(): dir is a library",t),await v(e.mountpoint))}}const t=s.default.join(e.mountpoint,(0,a.AppName)());F().info("addVolume(): adding default suggestion",t),await v(t)}catch(t){F().warn("addVolume(): Failed to add suggestion",{err:t,vol:e})}}(e),timeoutMs:c.ShortCommandTimeoutMs}),F().debug("Finished gathering suggestions. Filtering...",{priorLibraries:l,suggestions:d});const D=l;for(const e of(0,k.sortBy)(d,(e=>[-e.availableBytes,-e.nativePath.length]))){if(D.length>=t)break;D.some((t=>t.nativePath===e.nativePath||t.mountpoint===e.mountpoint))||(F().debug("adding new path",e),D.push(e))}return(0,E.uniqBy)((0,k.sortBy)(D,(e=>[!e.isCurrentLibrary,!e.isLibrary,-e.free,e.nativePath])),(e=>e.nativePath))}t.SuggestedLibraryDir=A,t.suggestedLibraryDirs=(0,o.lazy)((()=>I())),t._suggestedLibraryDirs=I},77948:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemInformation=t.libraryMetrics=void 0;const r=i(21330),s=i(46296),n=i(17344),a=i(18454),o=i(81674),l=i(66184),u=i(96175),c=i(24540),d=i(23560),h=i(28874),f=i(2858),m=i(84968),p=i(94174),g=i(37805),y=i(14854),v=i(15674),w=i(40958),b=i(22573),S=i(38639),P=i(75240),_=i(55835),M=i(31586),T=i(20214),E=i(51926),k=i(12168),D=i(43487),x=i(54017),C=i(48723);async function F(){if(null==D.Asset.db())return;const e=[];e.push((0,k.plurMetric)(D.Asset.shownCount(),"asset"));const t=x.AssetFile.assetFileCountByMimeTypeRoots();for(const i of t){const t=(0,E.stripSuffix)(i.mimeTypeRoot,"/");e.push((0,k.plurMetric)(i.assetFileCount,t+" file"))}return e.push((0,k.plurMetric)(C.Tag.rows(),"tag")),e}t.libraryMetrics=F;const A={pending:"pending",ok:"ok","no-library":"warn",warn:"warn","stop-sync":"warn",error:"fail",disabled:"ok"};t.systemInformation=async function(){const e=await(0,o.b)(),t=e?.l?.tier??"lite",i=a.HealthCheck.summary();return(0,w.compact)([{term:"Version",defn:g.version},{term:"Edition",defn:(0,n.EditionName)()},{term:"Health checks",defnClass:A[i.level],defnTitle:"Click to see all health checks",termURL:"/health",defn:i.msg[0]},{term:"Subscription",defnClass:t,defn:t,termURL:"/plans/billing?then=/about",defnTitle:"Click to manage your PhotoStructure subscription"},...(0,S.isTrue)(e?.ok)?[{term:"Licensed to",defn:e?.l?.sub},{term:"Expires or renews",defn:(0,_.mapOr)(e?.l?.exp,(e=>(0,r.toIsoDate)(e)),"--"),termURL:"/plans/billing?then=/about",defnTitle:"Click to manage your PhotoStructure subscription"}]:[],{term:"OS",defn:(0,u.osFullName)()},{term:"CPUs",defn:(0,u.CPUs)()},{term:"System load",defn:(0,_.map)(y.CpuUsage.instance().busyPct(),(e=>(0,M.fmtPct)(e)+" busy"))??"(unavailable)"},{term:"Concurrency",defn:`Target system use: ${Math.round(h.Settings.cpuBusyPercent.valueOrDefault)}% (${(0,v.maxConcurrentImports)()} concurrent imports, ${(0,v.sharpThreadsPerProcess)()} gfx/process)`},(0,d.isWebService)()?{term:"Web uptime",defn:(0,P.fmtDuration)((0,m.runtimeMs)())}:void 0,(0,b.mapNotBlank)((0,c.procDeviceModel)(),(e=>({term:"Device",defn:e}))),{term:"Current user",defn:await(0,p.username)()+((0,M.gte0)((0,p.userid)())?"":" (userid: "+(0,p.userid)()+", groupid: "+(0,p.groupid)()+")")},(0,f.libraryHasSettings)()?{term:"Library path",defn:h.Settings.libraryDir.valueOrDefault,defnClass:"library"}:void 0,await(0,T.thenMap)(F(),(e=>({term:"Library metrics",termURL:"https://photostructure.com/faq/metrics/",defn:e}))),{term:"Log directory",defn:(0,s.logDir)()},{term:"Log level",termURL:"https://photostructure.com/faq/error-reports/#log-levels",defn:(0,l.defaultLogLevel)()}]).filter((({term:e,defn:t})=>(0,b.notBlank)(e)&&(0,b.notBlank)(t)))}},31503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogArgs=void 0;const r=i(23560),s=i(83210),n=i(28874),a=i(38639);function o(){return(0,r.isMainService)()||(0,r.isSyncService)()}t.LogArgs={beforeParse:e=>{const t=(o()?', "PS_TAIL_LOGS=true"':"")+' and "PS_LOG_STDOUT=true".';return o()?e.option("-v, --verbose",'Verbose logging from all processes. Shortcut for "--info --tail". Caution: noisy during imports!'):e.option("-v, --verbose","Verbose logging. Equivalent to --info."),e.option("--error",`Emit "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=error"${t}`),e.option("--warn",`Emit "warn" and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=warn"${t}`),e.option("--info",`Emit "info", "warn", and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=info"${t}`),e.option("--debug",`Emit "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY NOISY. Sets "PS_LOG_LEVEL=debug"${t}}`),e.option("--trace",`Emit "trace", "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY VERY NOISY. Sets "PS_LOG_LEVEL=trace"${t}}`),o()&&e.option("--tail",'Emit log messages from both this process and all other concurrently running PhotoStructure processes on this host to stdout. This can be really helpful in seeing how PhotoStructure\'s processes are coordinating work. Caution: very noisy especially during imports. Sets "PS_TAIL_LOGS=true".'),e},afterParse:e=>{const t=(0,a.isTrue)(e.error),i=(0,a.isTrue)(e.warn),r=(0,a.isTrue)(e.info)||(0,a.isTrue)(e.verbose)||(0,a.isTrue)(e.v),l=(0,a.isTrue)(e.debug),u=(0,a.isTrue)(e.trace);u?n.Settings.logLevel.envValue="trace":l?n.Settings.logLevel.envValue="debug":r?n.Settings.logLevel.envValue="info":i?n.Settings.logLevel.envValue="warn":t&&(n.Settings.logLevel.envValue="error"),(0,s.isDaemon)(e)?(n.Settings.tailLogs.envValue=!1,n.Settings.logStdout.envValue=!1):((0,a.isTrue)(e.tail)&&(n.Settings.tailLogs.envValue=!0),(t||i||r||l||u)&&(n.Settings.logStdout.tmpValue=!0,o()&&(n.Settings.tailLogs.tmpValue=!0)),(n.Settings.tailLogs.valueOrDefault||n.Settings.logStdout.valueOrDefault)&&n.Settings.logLevel.isUnset()&&(n.Settings.logLevel.envValue="info"))}}},46628:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.albumsFromTags=t.tagFilesWithAlbums=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(81168),o=i(74417),l=i(28874),u=i(47783),c=i(97573),d=i(42231),h=i(40958),f=i(22573),m=i(68708),p=i(75020),g=i(54993),y=(0,s.lazy)((()=>(0,n.mkLogger)("curators.AlbumTagger")));function v(e){return(0,f.blank)(e)?void 0:l.Settings.tagAlbumTitleHierarchies.valueOrDefault?(0,c.keywordToPath)(e):[e]}function w(e){if(null==e)return[];const t=(0,h.uniq)((0,r.flatMap)(l.Settings.tagAlbumTitle.values,(t=>(0,m.pluckDeep)(e,t)?.value))),i=(0,h.compact)(t.map(v));if((0,h.isEmpty)(i))return[];if(i.length>1)return y().tap({level:"info",msg:"albumFromFile()",result:i.map((e=>[p.TagRoots.Albums,...e]))});const s=i[0],n=(0,r.first)(l.Settings.tagAlbumDescription.values,(t=>(0,m.pluckDeep)(e,t)?.value)),u=(0,h.isEmpty)(s)?"(blank title)":(0,a.firstSubstringIgnoreCase)(l.Settings.tagAlbumsExcluded.values,[...s,(0,g.toS)(n)].join(" ")),c=null==u?[p.TagRoots.Albums,...s]:void 0;if(null!=c){const t={name:c[c.length-1],description:n};for(const i of l.Settings.tagAlbumDate.values){const r=(0,o.parseJsonDateToMillis)((0,m.pluckDeep)(e,i)?.value);if(null!=r){t.releasedAt=r;break}}c[c.length-1]=t}return y().tap({level:"info",msg:"albumFromFile()",result:(0,h.compact)([c]),meta:{titles:i,desc:n,whyExclude:u}})}t.tagFilesWithAlbums=async function(e){const t=[];for(const i of e){t.push(...w(await(0,u.readTags)(i)));for(const e of l.Settings.tagAlbumFilenames.values)t.push(...w(await(0,u.readRawTags)(i.sibling(e),!1)))}return y().tap({msg:"tagFilesWithAlbums()",result:(0,d.uniqTagPaths)(t),meta:{files:e}})},t.albumsFromTags=w},88224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagAsset=t.tagAndUpsertAsset_=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(28874),o=i(42231),l=i(40958),u=i(20214),c=i(43487),d=i(46628),h=i(63175),f=i(4407),m=i(58886),p=i(32646),g=i(48144),y=i(60047),v=i(6186),w=i(42003),b=i(43723),S=(0,r.lazy)((()=>(0,s.mkLogger)("curators.AssetTagger")));async function P({primaryVariation:e,files:t,priorTagPaths:i,capturedAts:r,uris:s}){const u=[];if(t=(0,l.uniqBy)([e,...t],(e=>e.nativePath)),a.Settings.tagCamera.valueOrDefault&&await(0,n.thenMap)((0,h.cameraTagFile)(e),(t=>{S().debug("Camera tag for "+e+":",t),u.push(t)})),a.Settings.tagLens.valueOrDefault&&await(0,n.thenMap)((0,y.lensTagFile)(e),(t=>{S().debug("Lens tag for "+e+":",t),u.push(t)})),a.Settings.tagGeo.valueOrDefault)for(const e of t){const t=await(0,p.geoTagFile)(e);if(null!=t){u.push(t);break}}await(0,n.thenMap)((0,f.dateTagFile)(e,r),(t=>{S().debug("Date tag for "+e+":",t),u.push(t)}));const c=await(0,b.whoTagFiles)(t)??[];S().debug("whoTagFiles for "+e+":",c),u.push(...c),await(0,n.thenMap)((0,g.keywordTagFiles)(t,c),(t=>{S().debug("Keyword tags for "+e+":",t),u.push(...t)})),a.Settings.tagFileType.valueOrDefault&&await(0,n.thenMap)((0,w.typeTagFiles)(t),(t=>{S().debug("MIME type tags for "+e+":",t),u.push(...t)})),await(0,n.thenMap)((0,m.tagAssetPaths)(s),(e=>{S().debug("file paths for uris",{uris:s,arr:e}),u.push(...e)})),await(0,n.thenMap)((0,d.tagFilesWithAlbums)(t),(t=>{S().debug("Album tags for "+e+":",t),u.push(...t)}));const P=(0,o.omitAncestorTags)((0,l.uniqBy)(u.map(v.normalizeTagRoot),o.joinTagPath)),_=await(0,v.tagDeltas)(i,P);return S().info("tagAsset("+e+")",{priorTagPaths:i,after:P,result:_}),_}t.tagAndUpsertAsset_=async function(e){const t=await e.getExistingAssetFiles();S().info("tagAndUpsertAsset()",{asset:e,existing_uris:t.map((e=>e.uri))});const i=t.find((e=>e.shown)),r=await(i?.posixFile_());if(null==i||null==r)return void S().throw("tagAndUpsertAsset(): no existing or primary asset file",{asset:e,existingPrimaryAssetFile:i,primaryVariant:r,doNotSend:!0,fatal:!1});const s=e.getShown();s?.id!==i.id&&(S().warn("Changing primary asset we're using a different variant for tagging.",{newPrimary:i.uri,priorPrimary:s?.uri}),e.setShown_(i));const n=await(0,u.thenCollect)(t,(e=>e.posixFile_())),l=e.getAssetFiles().map((e=>e.uri)),d=e.getTagPaths(),h=await e.getCapturedAts(),f=await P({primaryVariation:r,files:n,priorTagPaths:d,capturedAts:h,uris:l});S().info("tagAndUpsertAsset",f);const m=f.add.find((e=>(0,o.leafIsExcluded)(e,a.Settings.keywordBlocklist.values)));if(null!=m){if(!0!==e.shown)return S().info("this asset has an excluded tag, and it wasn't shown yet, so we're removing it.",{excludedTag:m}),await c.Asset.remove({assetId:e.id,blocklistShas:!1,unlinkAssetFiles:!1}),S().throw("tagAndUpsertAsset(): asset had excluded tag. Removed.",{excludedTag:m,uris:l,files:n.map((e=>e.nativePath))});S().info("this asset has an excluded tag, marking excluded",{excludedTag:m}),e.excludedAt=Date.now()}return e.applyTagPathDeltas(f),await e.updateFromFiles(),f},t.tagAsset=P},63175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cameraTagFile=t.cameraTag=void 0;const r=i(47783),s=i(75020),n=i(40958),a=i(22573);function o(e){return null==e||(0,a.blank)(e.Make)?void 0:(0,n.compactBlankish)([s.TagRoots.Camera,e.Make,e.Model])}t.cameraTag=o,t.cameraTagFile=async function(e){return o(await(0,r.readTags)(e))}},4407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateTagFile=t.dateTag=t.dayTagRef=t.monthTagRef=t.yearTagRef=t.dayToOrdinal=t.ordinalToMonth=t.monthToOrdinal=t.yearToOrdinal=void 0;const r=i(19851),s=i(19043),n=i(97352),a=i(81168),o=i(928),l=i(34102),u=i(28874),c=i(28544),d=i(47783),h=i(40958),f=i(55835),m=i(31586),p=i(75020),g=i(54993),y=(0,r.lazy)((()=>new Intl.DateTimeFormat((0,s.localeSync)(),{month:"short"}))),v=(0,r.lazy)((()=>{const e=y();return(0,h.range)(0,12,(t=>e.format(new Date(2016,t,1)))).map((e=>(0,a.stripSuffix)(e,".")))}));function w(e){return 1e4-e}function b(e){return 13-e}function S(e){return 33-e}function P(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:w(e)})))}function _(e){if((0,m.within)(1,12,e))return(0,f.map)(v()[e-1],(t=>({name:String(e),displayName:t,ordinal:b(e)})))}function M(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:S(e)})))}function T(e){const t=(0,g.toS)(u.Settings.tagYMD.valueOrDefault).toLowerCase();if(null==e||""===t||"off"===t||t.startsWith("disable"))return;const i=[p.TagRoots.When];if(t.startsWith("y")){const t=(0,f.map)((0,o.getYear)(e),P);if(null==t)return;i.push(t)}if(t.startsWith("ym")){const t=(0,f.map)((0,o.getMonth)(e),_);if(null==t)return i;i.push(t)}if(t.startsWith("ymd")){const t=(0,f.map)((0,o.getDay)(e),M);if(null==t)return i;i.push(t)}return i}(0,l.ee)().on("clearCache",(()=>{y.unset(),v.unset()})),t.yearToOrdinal=w,t.monthToOrdinal=b,t.ordinalToMonth=function(e){return 13-e},t.dayToOrdinal=S,t.yearTagRef=P,t.monthTagRef=_,t.dayTagRef=M,t.dateTag=T,t.dateTagFile=async function(e,t){if(""===u.Settings.tagYMD.valueOrDefault)return;const i=[...t];(0,h.isEmpty)(t)&&i.push((await(0,d.readTags)(e))?.capturedAt);const r=(0,c.bestCapturedAt)(i);return null==r||(0,c.capturedAtSrcFromStat)(r.src)&&!u.Settings.tagDateFromStat.valueOrDefault?void 0:T(r.date)}},58886:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addFileUriTagsToAsset=t.addFilesTagsToAsset=t.isFsTag=t.tagAssetPaths=void 0;const r=i(19851),s=i(50213),n=i(42231),a=i(21404),o=i(40958),l=i(89937),u=i(75020),c=i(54017),d=i(94448),h=i(69032),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.FilePathTagger")));function m(e,t){return e.applyTagPathDeltas({add:(0,o.compact)(t.map((e=>(0,a.uriToTagPath)({uri:e,isFile:!0}))))})}t.tagAssetPaths=async function(e){const t=[];for(const i of e)try{const e=(0,a.uriToTagPath)({uri:i,isFile:!0});if(null==e)continue;if(i.startsWith(l.PS_LOCAL_FILE_SCHEME)&&null!=(0,d.modelDb)()){const t=(0,n.tagRefToS)(e[1]);e[1]={name:t,displayName:await(0,h.displayNameForVolsha)(t)},f().info("tagAssetPaths()",{uri:i,tp:e})}t.push(e)}catch(e){f().warn("Failed to parse asset file URI",{uri:i})}return t},t.isFsTag=function(e){return(0,n.tagRefToS)(e[0]).toLowerCase()===u.TagRoots.fs},t.addFilesTagsToAsset=function(e){const t=c.AssetFile.dbl.pluckAllf((t=>t.select("uri").where({asset:e})));return m(e,t)},t.addFileUriTagsToAsset=m},32646:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.geoTagFile=t.geoTag=void 0;const r=i(48884),s=i(56519),n=i(28874),a=i(47783),o=i(75020),l=i(40958);function u(e){const t=(0,r.compactRight)(n.Settings.tagGeoTemplate.valueOrDefault.map((t=>e?.[t])));return 0===t.length||t.some((e=>null==e))?void 0:(0,l.compact)([o.TagRoots.Where,...t])}t.geoTag=u,t.geoTagFile=function(e){return(0,s.thenMap)((0,a.readTags)(e),u)}},48144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.keywordTagFiles=t.processKeywords=t.dedupeKeywordPaths=t.normalizeKeywordPaths=t.extractPathnameTags=t.extractDashDashTags=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(68852),o=i(81168),l=i(96859),u=i(56519),c=i(28874),d=i(47783),h=i(97573),f=i(42231),m=i(40958),p=i(76790),g=i(22573),y=i(41400),v=i(96249),w=i(55835),b=i(75020),S=i(54993),P=i(6186),_=i(43723),M=(0,s.lazy)((()=>(0,n.mkLogger)("curators.KeywordTagger"))),T=(0,s.lazy)((()=>(0,g.mapNotBlank)(c.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[ /${(0,a.escapeRegExp)(e)}]`)))));function E(e){return M().tap({msg:"extractDashDashTags()",result:(0,w.mapOr)((0,S.toS)(e).split("--")[1],(e=>(0,m.compactBlanks)((0,w.mapOr)(T(),(t=>e.split(t)),[e]))),(()=>[])),meta:{s:e}})}function k(e){return[...E(e.parent().posixPath),...E(e.name)]}(0,y.later)((()=>{c.Settings.keywordDelimiters.watchLater((()=>T.unset()))})),t.extractDashDashTags=E,t.extractPathnameTags=k;const D=/\w{2,7}:\/\/\S+/g;function x(e){const t=[],i=[],s=[];for(const t of(0,m.compact)(e))if(Array.isArray(t))s.push(t);else{const e=(0,S.toS)(t).replace(D,(e=>(i.push(e),"")));s.push(...(0,w.mapOr)((0,h.delimRe)(),(t=>e.split(t)),[e]))}const n=s.map((e=>(0,o.isString)(e)?(0,h.keywordToPath)(e):e)).map((e=>Array.isArray(e)&&1===e.length?e[0]:e)),[a,l]=(0,r.partition)(n,Array.isArray),u=a.map((e=>(0,m.compactBlanks)(e.map((e=>e.trim()))))).filter(m.isNotEmpty),d=(0,o.uniqIgnoreCase)((0,v.flatten)(u));t.push(...u);const f=[...l,...i].map((e=>e.trim())).filter((e=>(0,g.notBlank)(e)&&!(0,o.includesIgnoreCase)(d,e))),p="copy"===c.Settings.keywordReparenting.valueOrDefault,y="retain"===c.Settings.keywordReparenting.valueOrDefault,P=c.Settings.rootTagKeywordsAliases.values;for(const e of[...t])(0,o.includesIgnoreCase)(P,e[0])&&(e[0]=b.TagRoots.Keywords),e[0]!==b.TagRoots.Keywords&&(p?t.push([b.TagRoots.Keywords,...e]):y&&e.unshift(b.TagRoots.Keywords));for(const e of f)t.push([b.TagRoots.Keywords,e]);return(0,m.uniq)(t)}function C(e){return(0,m.uniqBy2)((0,p.sortBy)(e.map(P.normalizeTagRoot),(e=>{const t=(0,f.joinTagPath)(e);return[t.normalize().toLowerCase(),-1*(0,l.lcdiff)(t)]})),((e,t)=>(0,o.equalsIgnoreCase)((0,f.joinTagPath)(e),(0,f.joinTagPath)(t))))}function F(e,t){const[i,s]=(0,r.partition)(x(e),_.isWhoTag),n=(0,v.flatten)(i.map(_.nameTag)),a=(0,m.uniq)((0,v.flatten)([...n,...t].map((e=>{const t=(0,P.stripTagRoot)(e);return[t.join(", "),t.join(" "),[...t].reverse().join(" ")]})))),l=C([...s.filter((e=>!(0,o.includesIgnoreCase)(a,(0,P.stripTagRoot)(e).join(" ")))),...n]);return M().tap({msg:"processKeywords()",level:"info",result:l})}t.normalizeKeywordPaths=x,t.dedupeKeywordPaths=C,t.processKeywords=F,t.keywordTagFiles=async function(e,t){return F([...c.Settings.tagKeywordsFromPath.valueOrDefault?(0,v.flatten)(e.map(k)):[],...c.Settings.tagKeywordsFromMetadata.valueOrDefault?(0,v.flatten)(await(0,u.mapAsyncSerial)({name:"keywordTagFiles",arr:e,f:e=>(0,u.thenMap)((0,d.readRawTags)(e),h.rawTagKeywords)})):[]],t)}},60047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lensTagFile=t.lensTag=void 0;const r=i(56519),s=i(28874),n=i(47783),a=i(75020),o=i(40958),l=i(22573),u=i(55835);function c(e){return(0,u.map)(e,(e=>(0,l.mapNotBlank)(e.lensMake,(t=>(0,l.mapNotBlank)((0,o.compactBlanks)(s.Settings.tagFullLensModel.valueOrDefault?[e.lensModel,e.lensInfo]:[e.lensInfo,e.lensModel])[0],(e=>[a.TagRoots.Lens,t,e]))))))}t.lensTag=c,t.lensTagFile=function(e){return(0,r.thenMap)((0,n.readTags)(e),c)}},6186:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagDeltas=t.normalizeTagRoot=t.stripTagRoot=t.hasTagRoot=t.Roots=t.KwRoot=t.WhoRoot=t.AlbumsRoot=t.WhenRoot=void 0;const r=i(50213),s=i(28874),n=i(42231),a=i(75020),o=i(40958),l=i(22573),u=i(45599);t.WhenRoot={name:a.TagRoots.When,ordinal:1},t.AlbumsRoot={name:a.TagRoots.Albums,ordinal:2},t.WhoRoot={name:a.TagRoots.Who,ordinal:4},t.KwRoot={name:a.TagRoots.Keywords,ordinal:7};const c=(0,u.defer)((()=>(0,r.mkLogger)("curators.Taggers")));t.Roots=[t.WhenRoot,t.AlbumsRoot,{name:a.TagRoots.fs,ordinal:3},t.WhoRoot,{name:a.TagRoots.Camera,ordinal:5},{name:a.TagRoots.Lens,ordinal:6},t.KwRoot,{name:a.TagRoots.Type,ordinal:8}];const d=(0,o.uniq)([...a.TagRoots.values,...s.Settings.rootTagKeywordsAliases.values,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function h(e){return d.includes((0,n.tagRefToS)(e[0]).toLowerCase())}t.hasTagRoot=h,t.stripTagRoot=function(e){return h(e)?e.slice(1):e};const f=(0,o.uniq)([a.TagRoots.Albums,...s.Settings.rootTagAlbumsAliases.values].map((e=>e.toLowerCase()))),m=(0,o.uniq)([a.TagRoots.Keywords,...s.Settings.rootTagKeywordsAliases.values].map((e=>e.toLowerCase()))),p=(0,o.uniq)([a.TagRoots.Who,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));t.normalizeTagRoot=function(e){const i=(0,n.tagRefToS)(e[0]).toLowerCase();return(0,l.blank)(i)?e:m.includes(i)||m.includes(i)?[t.KwRoot,...e.slice(1)]:p.includes(i)?[t.WhoRoot,...e.slice(1)]:f.includes(i)?[t.AlbumsRoot,...e.slice(1)]:e},t.tagDeltas=async function(e,t){const i=(0,n.tagDiff)(t,e),r=(0,n.tagDiff)(e,t),a=s.Settings.excludedRootTags.valueOrDefault;return(0,o.filterInPlace)(i,(e=>{const t=a.includes((0,n.tagRefToS)(e[0]).toLowerCase());return t&&!(0,n.tagPathsInclude)(e,r)&&(r.push(e),c().info("tagDeltas(): removing excluded tag",e)),!t})),{add:i,remove:r}}},42003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fixCase=t.friendlySubtype=t.mimeTypeToTag=t.typeTagFiles=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(56519),o=i(54979),l=i(40958),u=i(22573),c=i(55835),d=i(42279),h=i(75020),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.TypeTagger")));t.typeTagFiles=async function(e){const t=(0,l.uniq)(await(0,a.mapAsyncSerial)({name:"typeTagFiles",arr:e,f:o.readMimeType}));return(0,l.compact)(t.map(p))};const m=new Map(["M2TS","JPEG","QuickTime"].map((e=>[e.toLowerCase(),e])));function p(e){const[t,i]=e.split("/");if(!(0,u.blank)(t)&&!(0,u.blank)(i))return f().tap({msg:"mimetypeToTag("+e+")",result:(0,c.map)(y(i,e),(e=>(0,l.compactBlanks)([h.TagRoots.Type,(0,n.capitalize)(t),...e])))})}t.mimeTypeToTag=p;const g=(0,r.lazy)((()=>new Map([["image/x-adobe-dng",["Raw","DNG"]],["image/x-fuji-raf",["Raw","Fujifilm"]],["video/m2ts",["MPEG-2"]],["video/mp2t",["MPEG-2"]],["video/mp4",["MPEG-4"]],["video/quicktime",["QuickTime"]],["video/x-msvideo",["AVI"]]])));function y(e,t){return(0,d.firstDefinedThunk)([()=>g().get(t.trim().toLowerCase()),()=>(0,c.map)(e.match(/^x-(\w{4,})-\w{3}/),(e=>["Raw",(0,n.capitalize)(e[1])])),()=>[v(e.replace(/^(?:x-|vnd\.|prs\.)/i,"").replace(/-/g," "))]])}function v(e){return null!=e.match(/[a-z\d]{3,4}/i)?e.toUpperCase():m.get(e.trim().toLowerCase())??(0,n.capitalize)(e)}t.friendlySubtype=y,t.fixCase=v},43723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nameTag=t.isWhoTag=t.whoTagFiles=void 0;const r=i(19851),s=i(50213),n=i(28874),a=i(47783),o=i(28630),l=i(66039),u=i(42231),c=i(40958),d=i(22573),h=i(96249),f=i(68708),m=i(75020),p=i(59455),g=(0,r.lazy)((()=>(0,s.mkLogger)("curators.WhoTagger")));t.whoTagFiles=async function(e){const t=[];if(n.Settings.tagJsonFaces.valueOrDefault){const i=[];for(const t of e)i.push(...(0,p.toA)(await t.jsonSidecars()));for(const e of i){const i=await(0,o.readJsonSidecar)(e),r=i?.peopleNames;(0,c.isNotEmpty)(r)&&t.push(...r)}}if(n.Settings.tagFaceRegions.valueOrDefault)for(const i of e){const e=await(0,a.readRawTags)(i,!0);if(null!=e)for(const i of(0,f.values)(e)){const e=i?.RegionList;if(Array.isArray(e))for(const i of e)"Face"===i.Type&&t.push(i.Name)}}if((0,c.isNotEmpty)(n.Settings.whoTags.values))for(const i of e){const e=await(0,a.readRawTags)(i,!0);for(const i of n.Settings.whoTags.values)t.push(...(0,p.toA)((0,f.pluckDeep)(e,i)?.value))}const i=(0,c.uniq)((0,h.flatten)((0,c.uniq)(t).map(w)));return g().tap({msg:"whoTagFiles()",level:"info",result:i,meta:{names:t,files:e.map((e=>e.nativePath))}})};const y=(0,c.uniq)([m.TagRoots.Who,...n.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function v(e){return y.includes((0,u.tagRefToS)(e[0]).toLowerCase())}function w(e){if(!(0,d.blank)(e))return Array.isArray(e)?(v(e)&&e.shift(),0===e.length?void 0:1===e.length?(0,l.renderNameTag)(e[0]):[[m.TagRoots.Who,...e]]):(0,l.renderNameTag)(e)}t.isWhoTag=v,t.nameTag=w},98348:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Db=void 0;const c=i(48884),d=i(19851),h=i(23560),f=i(25764),m=i(38836),p=i(99331),g=i(5916),y=i(12959),v=i(55332),w=i(91872),b=i(80632),S=i(51040),P=i(44955),_=i(15056),M=i(70025),T=i(57159),E=i(18454),k=i(28874),D=i(5233),x=i(42659),C=i(31586),F=i(68708),A=i(30976),I=i(17036),O=i(27134),L=i(35052);class R extends m.EndableWrapper{constructor(e,t){super("db.Db("+e+")",(()=>this.closeDb()),f.EndableRanks.db),r.add(this),this.schema=e,this.dbFile=t,s.set(this,0),n.set(this,void 0),this.endTimeoutMs=x.minuteMs,this.onRetry=(0,d.lazy)((()=>this.closeDb()),k.Settings.maxBusyDbMs.valueOrDefault/2),this.maxUpdatedAt=(0,d.lazy)((()=>"models"===this.schema?l(this,r,"m",a).call(this,"Asset","AssetFile","Example"):0),5*x.secondMs),this.migrate_=(0,g.lazyAsync)({desc:"db.migrate",later:async()=>{let e=!1;const t=this.dbFile;if(null==this.dbFile)throw new Error("Cannot migrate database: missing db");let i;if(await this.dbFile.isNonEmptyFile())try{await(0,O.verifyDb_)((()=>this.db))}catch(e){this.logger.warn("verifyDb failed before attempting Migration.",{error:e}),i=e}(null!=i||k.Settings.dbForceRecover.valueOrDefault)&&(E.HealthCheck.addLoadingMsg("Repairing database..."),await this.repair_(),e=!0);const r=new I.Migration(this.schema,this.db,t);return{appliedMigrations:await r.apply_(),migration:r,repaired:e}}}),this.tableInfo_=(0,d.lazy)((()=>(0,L.localTableInfo)(this.db)))}toJSON(){return(0,F.pick)(this,"schema","dbFile")}get isOpen(){return!0===l(this,n,"f")?.open}get inTransaction(){return this.isOpen&&!0===l(this,n,"f")?.inTransaction}prepare(e){return this.db.prepare(e)}pragma(e,t){return this.logger.tapThunk({msg:"PRAGMA "+e,result:()=>this.db.pragma(e,t)})}get db(){var e;const t=null==l(this,n,"f");if(t||!this.isOpen){this.logger.info("setting up new db connection to "+this.dbFile,{priorWasNull:t});try{u(this,n,(0,b.mkdb_)({nativePath:this.dbFile.nativePath}),"f")}catch(e){throw new T.WrappedError("Failed to set up "+this.dbFile,{cause:e,path:this.dbFile.nativePath})}}return(0,h.isSyncService)()&&"INCREMENTAL"===k.Settings.dbAutoVacuumMode.valueOrDefault&&(0,C.gt0)(k.Settings.dbWalAutoCheckpoint.valueOrDefault)&&u(this,s,(e=l(this,s,"f"),++e),"f")%k.Settings.dbWalAutoCheckpoint.valueOrDefault==0&&(this.logger.info("running incremental_vacuum..."),l(this,n,"f")?.pragma("incremental_vacuum")),l(this,n,"f")}async verify_(){await(0,O.verifyDb_)((()=>this.db))}assertHeartbeat_(){const e=(0,A.randomChars)(64),t=Date.now();try{this.db.prepare("INSERT INTO heartbeat (name, createdAt, updatedAt) VALUES (?,?,?)").run(e,t,t);const i=this.db.prepare("SELECT * FROM heartbeat WHERE name = ?").get(e);if(i?.name!==e)throw new Error("heartbeat INSERT/SELECT roundtrip failed")}finally{try{this.db.prepare("DELETE FROM heartbeat WHERE name = ?").run(e)}catch{}}}async closeDb(){try{this.logger.info("closing db",l(this,n,"f")),await(0,D.retryOnReject_)((()=>{!0===l(this,n,"f")?.open&&l(this,n,"f")?.close()}),{timeoutMs:k.Settings.dbBusyTimeoutMs.valueOrDefault,maxRetries:5,errorIsRetriable:M.isSqliteBusyError,retryDelay:x.secondMs})}catch(e){this.logger.warn("closeDb(): .close() failed",e)}u(this,n,void 0,"f")}async vacuum(){try{await(0,w.handleDbRetries_)("db.checkpoint",(()=>this.db),(()=>(0,O.checkpoint_)({db:this.db})),this.onRetry),await(0,w.handleDbRetries_)("db.optimize",(()=>this.db),(()=>this.db.pragma("OPTIMIZE")),this.onRetry),await(0,w.handleDbRetries_)("db.vacuum",(()=>this.db),(()=>this.db.exec("VACUUM")),this.onRetry)}catch(e){throw this.logger.warn("vacuum(): failed",{error:e}),e}}async repair_(){this.logger.warn("repair_(): Attempting restore of "+this.dbFile),await this.closeDb(),await(0,O.repairDbFile_)(this.dbFile),this.logger.info("repair_(): Database restoration was successful!")}localBackupDir(){return(0,_.dbBackupDir)(this.dbFile)}async backup_(e,t){const i=t??await(0,P.isDirSQLiteReadWrite)(e),s=(i?e:this.localBackupDir().join((0,y.filestamp)())).join(this.dbFile.base);return await l(this,r,"m",o).call(this,s),i||await(0,v.dbBackupCold_)(s,e),e.join(this.dbFile.base)}}t.Db=R,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(...e){const t=[];for(const i of e)try{t.push(this.db.prepare("SELECT MAX(updatedAt) FROM "+(0,S.dbValueToEscapedString)(i)).pluck().get())}catch(e){this.logger.warn(`#maxUpdatedAt(): failed to get max updatedAt for ${i}`,e)}return(0,c.max)(t)},o=async function(e){await e.parent().mkdirp_(),await this.db.backup(e.nativePath,{progress:e=>(this.logger.log((0,p.ending)()?"info":"debug","backup() "+(0,C.fmtPct)(100-e.remainingPages/e.totalPages*100)+" completed"),(0,p.ending)()?1e3:100)})}},25470:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.DbModelJanitor=t.Contested=t.NoOp=t.NoWriteLock=void 0;const c=i(66364),d=i(50213),h=i(23560),f=i(78406),m=i(25764),p=i(38836),g=i(99331),y=i(56038),v=i(12959),w=i(55332),b=i(76187),S=i(73209),P=i(28874),_=i(42659),M=i(75240),T=i(95700),E=i(22526),k=i(45648),D=5*_.minuteMs;t.NoWriteLock=Symbol("NoWriteLock"),t.NoOp=Symbol("NoOp"),t.Contested=Symbol("Contested");class x extends f.EndableInterval{static for(e){return new x(e.db,e.fslock,e.libraryDbFile,e.libraryDbBackupDir)}constructor(e,t,i,o){super({name:"db.DbModelJanitor",callback:()=>l(this,r,"m",n).call(this),intervalMs:P.Settings.dbBackupIntervalMs.valueOrDefault,initialDelayMs:_.minuteMs,rank:m.EndableRanks.db,endTimeoutMs:5*_.minuteMs,onEnd:()=>l(this,r,"m",a).call(this)}),r.add(this),this.db=e,this.dbFslock=t,this.libraryDbFile=i,this.libraryDbBackupDir=o,this.logger=(0,d.mkLogger)(this.name),this.fslockRelease=new p.EndableWrapper("db.DbModelJanitor.fslockRelease",(()=>this.dbFslock.release()),m.EndableRanks.postdb,D),s.set(this,0),this.dbFslock.tryAcquire_()}get useReplica(){return!this.db.dbFile.eql(this.libraryDbFile)}forceBackup_(){return this.backup_(!0)}async backup_(e=!1){return await(0,S.withLock_)({file:this.libraryDbBackupDir,timeoutMs:5*_.minuteMs,noopIfContested:!e},(async()=>{if(e&&u(this,s,0,"f"),(0,k.hasDbSetupErrors)())return this.logger.warn("backup_(): db has setup errors, skipping backup",{errors:(0,k.dbSetupErrors)()}),t.NoOp;if(!await this.dbFslock.tryAcquire_())return this.logger.info("backup_(): no-op: someone else has the fslock",{me:this.dbFslock.lockfile?.base,owner:(await this.dbFslock.selfAndSiblingNames_())[0]}),t.NoWriteLock;l(this,r,"m",o).call(this)||await(0,T.runMaintenanceTasks)();const i=this.db.maxUpdatedAt();return null!=i&&i>l(this,s,"f")?(0,y.time)("db.DbModelJanitor.backup_()",(async()=>{l(this,r,"m",o).call(this)?this.logger.info("backup_(): posthaste: skipping vacuum"):await this.db.vacuum(),u(this,s,i,"f");const e=this.libraryDbBackupDir.join((0,v.filestamp)()),t=await this.db.backup_(e,!this.useReplica);return this.useReplica&&await(0,w.dbBackupCold_)(t,this.libraryDbFile.parent()),this.logger.info("backup_(): backup successful",{destDbFile:t}),t})):(this.logger.info("backup_(): no update to the db since last backup",{ago:(0,M.fmtDuration)(Date.now()-l(this,s,"f"))}),t.NoOp)}))??t.Contested}}t.DbModelJanitor=x,s=new WeakMap,r=new WeakSet,n=async function(){try{await this.backup_()}catch(e){this.logger.error("backup_() failed",{error:e})}},a=async function(){const e=S.FsLock.for({file:this.libraryDbFile.sibling("db-teardown"),timeoutMs:D,endableRank:m.EndableRanks.postdb,noopIfContested:!1});(0,h.isDbManager)()&&await e.withLock_((async()=>{if(await this.dbFslock.iAmOnly_({vacuum:!0})){if(this.logger.info("#teardown(): I'm the last one in. Running backup and cleanup."),await this.backup_(),this.useReplica){const e=[(0,E.libraryDbInfoFromDbFile)(this.libraryDbFile),...(0,b.sqliteFiles)(this.db.dbFile)];this.logger.info("#teardown(): Removing replica artifacts",{victims:e});for(const t of e)await t.unlink()}}else this.logger.info("#teardown(): no-op: other processes are still running")})),await this.db.closeDb()},o=function(){return this.ended||(0,g.ending)()||(0,c.isSuspended)()}},22526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelSetup_=t.assertValidDbInfo_=t.libraryDbInfoFromDbFile=t.libraryDbInfoJsonFile=t.fsLockForDb=t.libraryDbObjects_=void 0;const r=i(19851),s=i(50213),n=i(92407),a=i(55332),o=i(44955),l=i(15056),u=i(87290),c=i(98314),d=i(38835),h=i(73209),f=i(95696),m=i(17217),p=i(18454),g=i(57902),y=i(28874),v=i(2858),w=i(40958),b=i(22573),S=i(42659),P=i(94448),_=i(98348),M=i(45648),T=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbModelSetup")));function E(e=y.Settings.libraryDir.valueOrDefault){if((0,b.blank)(e))throw new Error("Library directory is not set"+d.NoLibraryErrorFlag);const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dataDir"+d.NoLibraryErrorFlag);if(!(0,v._libraryHasSettings)(e))throw new Error(`Library at ${e} does not have a settings file`+d.NoLibraryErrorFlag);const i=(0,l.pathToDb)(t,"models");return{dataDir:t,libraryDbFile:i,libraryDbBackupDir:(0,l.dbBackupDir)(i)}}function k(e){return h.FsLock.for({file:e,timeoutMs:0,noopIfContested:!1})}function D(e=y.Settings.libraryDir.valueOrDefault){const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dir"+d.NoLibraryErrorFlag);return x((0,l.pathToDb)(t,"models"))}function x(e){return e.sibling("db-info.json")}async function C(e=D(),t){try{const i=await e.readJson(g.LogLevels.info);if(null==i)throw new Error(e+" is missing"+d.DbSetupErrorFlag);if(null!=t&&!await t.equalsUri_(i.uri))throw new Error(e+" expects the live db to be "+i.uri+" but the live db is "+await t.uri_()+d.DbSetupErrorFlag);const r=await f.PosixFile.forUri(i.uri);if(null==r)throw new Error(e+" expects the live db to be "+i.uri+" but that URI cannot be resolved."+d.DbSetupErrorFlag);try{await(0,o.assertDirSQLiteReadWrite_)(r.parent())}catch(t){throw T().error("assertValidDbInfo_(): failed to assert live dir was r/w",{error:t,liveDbFile:r,infoJsonFile:e}),new Error("Failed to validate that the live database directory, "+r.dir+", was read-writable by SQLite: "+(0,c.errorToS)(t)+d.DbSetupErrorFlag)}return{liveDbFile:r}}catch(e){throw(0,M.addDbSetupError)(e),e}}t.libraryDbObjects_=E,t.fsLockForDb=k,t.libraryDbInfoJsonFile=D,t.libraryDbInfoFromDbFile=x,t.assertValidDbInfo_=C,t.dbModelSetup_=async function(e=y.Settings.libraryDir.valueOrDefault){const{libraryDbFile:t,fslock:i,libraryDbBackupDir:r}=await async function(e=y.Settings.libraryDir.valueOrDefault){const t=E(e);return{...t,fslock:k(t.libraryDbFile)}}((0,b.mapNotBlank)(e,m.toNativePath_));let s,o;await i.tryAcquire_();const u=x(t);try{if(await(0,h.withLock_)({file:u,timeoutMs:5*S.minuteMs},(async()=>{const i=await u.readJson(g.LogLevels.info);if(s=i?.useReplica,null!=i){const{liveDbFile:e}=await C(u,t);o=new _.Db(l.Schemas.models,e)}if(null==s||null==o){const i=await(0,n.getLiveDbDir_)(e),r=await i.db.uri_();s=i.useReplica,s&&await p.HealthCheck.traceLater_("Setting up local replica database",(0,a.dbBackupCold_)(t,i.db.parent())).catch((e=>T().throw("Failed to set up replica db"+d.DbSetupErrorFlag,{src:t,dest:i.db,error:e}))),o=new _.Db(l.Schemas.models,i.db),await u.writeJson_({uri:r,useReplica:s})}})),null==o||null==s)return T().throw("Failed to open model db"+d.DbSetupErrorFlag+d.InternalErrorFlag,{libraryDir:e});if(await i.tryAcquire_()){const e=await o.migrate_();s&&(e.repaired||(0,w.isNotEmpty)(e.appliedMigrations))&&await o.backup_(t.parent(),!s),(0,M.clearDbSetupErrors)()}P.modelDb.set(o)}catch(e){throw T().error("Failed to set up model db",{error:e}),(0,M.addDbSetupError)(e),i.release(),e}return T().tap({msg:"dbModelSetup()",result:{db:o,useReplica:s,libraryDbFile:t,libraryDbBackupDir:r,fslock:i}})}},86859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DbRequest=void 0;const r=i(54557),s=i(50213),n=i(99331),a=i(56038),o=i(65753),l=i(66184),u=i(70417),c=i(28874),d=i(40958),h=i(22573),f=i(45599),m=i(96249),p=i(31586),g=i(51926),y=i(57038),v=i(21074),w=(0,f.defer)((()=>(0,s.mkLogger)("db.DbRequest")));t.DbRequest=class{constructor(e,t){this.db=e,this.tableName=t,this.cachedStatements=new r.FifoCache(256)}qb(){return(0,y.knex)()(this.tableName)}prep(e,t=!1){const i=(0,v.toSqlQuery)(e);try{const r=this.cachedStatements.getOrSet(this.db().db.__uid+":"+(!0===t?"pluck:":"")+i.sql,(()=>{const e=this.db().prepare(i.sql);return!0===t?e.pluck():e}));return r.database.open?{sq:i,stmt:r}:(this.cachedStatements.clear(),this.prep(e,t))}catch(e){return w().throw("prep() failed",{error:e,sqlQuery:i,retriable:!1})}}wrap({q:e,pluck:t,m:i}){try{const{sq:r,stmt:s}=this.prep(e,t);c.Settings.logSql.valueOrDefault&&w().log((0,l.defaultLogLevel)(),i+"(): "+(0,v.sqlQueryToS)(r));const n=s[i].bind(s);return null==r.bindings?n():n(r.bindings)}catch(t){if(!0===t.message?.includes("AdvisoryLock"))throw t;w().throw(t,{method:i,...(0,v.toSqlQuery)(e)})}}run(e){return this.wrap({q:e,m:"run"})}runScript(e,t=""){const i=(0,a.mkElapsed)("db.runScript()");for(const r of e){if((0,h.blank)(r)||r.trim().startsWith("--"))continue;this.run({sql:r});const e=(0,g.replaceAll)((0,g.ellipsize)(r,60),t,"");i.elapsed(e)}}mapRun(e){return e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return null==t.bindings?i.run():i.run(t.bindings)}))}runf(e){return this.wrap({q:e(this.qb()),m:"run"})}upsert(e){const t=(0,v.toSqlQuery)(e(this.qb()));return t.sql=t.sql.replace(/^(?:update|insert)\b/i,(e=>e.toUpperCase()+" OR REPLACE ")),this.wrap({q:t,m:"run"})}first(e){return this.wrap({q:e,m:"get"})}firstf(e){return this.wrap({q:e(this.qb()),m:"get"})}mapAll(e){return(0,m.flatten)(e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return i.all(t.bindings)})))}all(e){return this.wrap({q:e,m:"all"})}allf(e){return this.wrap({q:e(this.qb()),m:"all"})}async batched(e){let t,i=0;do{t=this.wrap({q:e.qb(this.qb(),t).limit((0,o.maxBatchPluckSize)()),m:"all"}),(0,d.isNotEmpty)(t)&&(await e.onResults(t),i+=t.length)}while((0,d.isNotEmpty)(t)&&!(0,n.ending)()&&(null==e.maxResults||e.maxResults>i));return{resultCount:i,done:null==t||t.length<(0,o.maxBatchPluckSize)()}}pluckFirst(e){return this.wrap({q:e,pluck:!0,m:"get"})}pluckFirstf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"get"})}pluckAll(e){return this.wrap({q:e,pluck:!0,m:"all"})}pluckAllf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"all"})}async pluckBatched(e){let t=0;const i=(0,u.min)([e.limit??(0,o.maxBatchPluckSize)(),e.maxResults]);if(i<=0||(0,p.lte0)(e.maxResults))return{done:!1,resultCount:t};let r;for(;null==e.maxResults||e.maxResults<=0||t(0,o.mkLogger)("db.DbSchemaValid")));function y(e){return l.PosixFile.for(s.default.join(u.ProjectPath.Data(),e+"-schema.json"))}t.schemaJsonFile=y,t.assertValidDbSchema_=async function(e){try{await e.migrate_();const t=(0,p.localTableInfo)(e.db),i=t.map((e=>e.tableName)),r=(await y(e.schema).readJson_()).tableInfo;{const e=r.map((e=>e.tableName)),t=(0,c.diff)(e,i);(0,c.isNotEmpty)(t)&&g().throw("Db is missing "+(0,f.plur)(t.length,"table")+": "+(0,h.andList)(t))}for(const e of t){const t=r.find((t=>t.tableName===e.tableName));if(null==t)g().warn("Unexpected table in db",e);else{const i=(0,n.diffEql)(t.columns,e.columns);(0,c.isNotEmpty)(i)&&g().throw("Db is missing "+(0,f.plur)(i.length,"column")+" from table "+e.tableName+": "+(0,h.andList)(i.map((e=>e.name))))}}g().info("Validated schema.",{from:(0,d.shortStack)()})}catch(e){throw(0,m.dbModelHealthCheck)().reset(),e}},t.writeSchemaJsonFile_=function(e,t){return y(e).writeJson_({info:"This is used in validating PhotoStructure library databases after repair and restore operations.",tableInfo:(0,p.localTableInfo)(t)},{spaces:2})}},45648:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDbSetupErrorListener=t.hasDbSetupErrors=t.clearDbSetupErrors=t.addDbSetupError=t.dbSetupErrors=t._dbSetupErrors=void 0;const r=i(98314),s=i(22573),n=i(23541);t._dbSetupErrors=new Set;const a=[];t.dbSetupErrors=function(){return[...t._dbSetupErrors.values()]},t.addDbSetupError=function(e){if((0,n.isError)(e)||!(0,s.blank)(e)){t._dbSetupErrors.add((0,r.errorToS)(e));for(const e of a)e()}},t.clearDbSetupErrors=function({notifyListeners:e=!0}={}){if(t._dbSetupErrors.clear(),e)for(const e of a)e()},t.hasDbSetupErrors=function(){return t._dbSetupErrors.size>0},t.addDbSetupErrorListener=function(e){a.push(e)}},36908:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dedupeTags_=t.mergeTags_=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(42231),o=i(40958),l=i(76790),u=i(23838),c=i(31586),d=i(54993),h=(0,r.lazy)((()=>(0,s.mkLogger)("db.DedupeTags")));function f(e,t){function i(t){return e.prepare(t).run()}(0,o.isEmpty)(t)&&h().warn("mergeTags(): empty tagIds",{tagIds:t}),h().info("mergeTags() starting",{tagIds:t});const r=e.prepare("SELECT id, _path, parentId FROM Tag WHERE id IN ("+t.join(",")+") ORDER BY ID").all(),s=(0,o.compactBlanks)(r.map((e=>(0,a.tagPathLeaf)(e._path))).sort()),n=r[0],l=r.slice(1),u=n?.id;if((0,o.isEmpty)(s)||(0,o.isEmpty)(l)||null==n||!(0,c.gt0)(u))return void h().warn("mergeTags(): missing winner",{winner:n,winnerId:u,leafs:s,losers:l});const d=(0,a.splitTagPath)(n._path).slice(0,-1),f=[...d,s[0]];n._path=(0,a.joinTagPath)(f),n.parentId=0===d.length?null:e.prepare("SELECT id from Tag where _path LIKE ?").pluck().get((0,a.joinTagPath)(d))??n.parentId,h().info("mergeTags()",{winner:n,losers:l,winnerTagPath:f,leafs:s});const m=l.map((e=>e.id)).join(",");i(`UPDATE OR IGNORE AssetTag SET tagId = ${u} WHERE tagId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`DELETE FROM AssetTag WHERE tagId in (${m})`),i(`DELETE FROM Tag WHERE id in (${m})`),e.prepare("UPDATE Tag SET parentId = :parentId, _path = :path WHERE id = :id").run({parentId:n.parentId,path:n._path,id:u});const p=e.prepare("SELECT id, _path FROM Tag WHERE id != :winnerId AND _path LIKE :like COLLATE NOCASE").all({winnerId:u,like:n._path+"%"});for(const t of p){const i=(0,a.splitTagPath)(t._path).slice(f.length),r=(0,a.joinTagPath)([...f,...i]);t._path!==r&&(h().info("mergeTags(): repairing tag path",{ea:t,newPath:r}),e.prepare("UPDATE OR IGNORE Tag SET _path = :path, updatedAt = :updatedAt WHERE id = :id").run({id:t.id,updatedAt:Date.now(),path:r}))}return h().tap({msg:"mergeTags()",level:"info",result:{winner:n,losers:r}})}t.mergeTags_=f,t.dedupeTags_=function(e){const t=new u.MultiMap;for(const{id:i,_path:r}of e.prepare("SELECT id, _path FROM Tag ORDER BY id").iterate())t.add((0,n.stripSuffix)((0,d.toS)(r).trim(),a.TagSep).toLowerCase().normalize(),i);const i=(0,l.sortBy)(t.entriesArray().filter((([,e])=>e.length>1)),(([e])=>[-(0,n.countChars)(e,a.TagSep),-e.length,e]));for(const[,t]of i)f(e,t)}},57038:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstMigratedAt=t.knex=void 0;const s=r(i(31832)),n=i(19851),a=i(56519),o=i(55835),l=i(68708);t.knex=(0,n.lazy)((()=>(0,s.default)({client:"better-sqlite3",useNullAsDefault:!0}))),t.firstMigratedAt=async function(e){return(0,a.thenMap)(e("migrations").min("migration_time").first(),(e=>(0,o.map)((0,l.values)(e)[0],(e=>new Date(e)))))}},17036:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Migration=void 0;const o=i(77598),l=i(19851),u=i(50213),c=i(7282),d=i(37805),h=i(4867),f=i(51040),m=i(77740),p=i(38835),g=i(8769),y=i(57159),v=i(34102),w=i(73209),b=i(95696),S=i(43899),P=i(18454),_=i(28874),M=i(40958),T=i(42659),E=i(41400),k=i(98553),D=i(55835),x=i(34666),C=i(32639),F=i(45648),A=i(94715),I=i(27134);t.Migration=class{constructor(e,t,i){r.add(this),this.schema=e,this.db=t,this.dbFile=i,this.fsMigrations_=(0,l.lazy)((()=>this.migrationsDir.children_((e=>e.isFile&&e.basename.endsWith(".sql"))).catch((e=>this.logger.throw("Failed to read migration directory, "+this.migrationsDir+p.InternalErrorFlag,{error:e}))))),this.ensureMigrationTable_=(0,l.lazy)((()=>{this.db.exec("\nCREATE TABLE IF NOT EXISTS migrations (\n id INTEGER NOT NULL PRIMARY KEY,\n name TEXT NOT NULL,\n migration_time INTEGER NOT NULL\n) STRICT\n")})),this.unknownMigrations_=(0,l.lazy)((()=>this.migrationsInDatabase_().filter((e=>!(0,x.lt)((0,A.migrationNameToDate)(e),d.gitDate))))),this.assertKnownMigrations_=(0,l.lazy)((()=>{const e=this.unknownMigrations_();if((0,M.isNotEmpty)(e)){const t=new y.WrappedError("Please upgrade PhotoStructure to a newer version to open this library: Unknown migrations: "+e.join(","));throw(0,g.onError)(t),t}})),this.logger=(0,u.mkLogger)("db.Migration("+(0,k.stringify)({schema:e,db:i.nativePath})+")"),this.migrationsDir=b.PosixFile.for(S.ProjectPath.Migrations()).join(this.schema)}async pendingMigrationFiles_(){const e=this.migrationsInDatabase_();return(await this.fsMigrations_()).filter((t=>!e.includes(t.name)))}migrationsInDatabase_(){return this.ensureMigrationTable_(),this.db.prepare("SELECT name from migrations").pluck().all()}async apply_(e){return(0,w.withLock_)({file:this.dbFile.sibling("migrate"),timeoutMs:_.Settings.dbMaintenanceTimeoutMs.valueOrDefault},(()=>a(this,r,"m",s).call(this,e)))}async applyMigration_(e,t){try{const i=Date.now(),s=A.Migrations[e.name.replace(/^[\d_-]+/,"")],o=(0,C.isFunction)(s);return o?await s.bind(A.Migrations)(this.db):await a(this,r,"m",n).call(this,e),this.logger.info("applyMigration() completed",{elapsedMs:Date.now()-i,codeMigration:o,migration:e.baseWithParent}),t?.run(e.name,Date.now())}finally{(0,v.ee)().emit("clearDbCache")}}},r=new WeakSet,s=async function(e){try{this.ensureMigrationTable_(),(0,c.isProd)()&&this.assertKnownMigrations_();const t=[],i=this.db.prepare("INSERT INTO migrations (name, migration_time) VALUES (?, ?)");for(const r of await this.pendingMigrationFiles_())await P.HealthCheck.traceLater_("Upgrading database ("+r.name+")",(async()=>{if((0,m.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");(0,m.getDevEnvFlag)("PS_SLOMO")&&await(0,E.delay)((0,o.randomInt)(T.secondMs,3*T.secondMs)),await(0,D.map)(e,(e=>e(r))),await(0,h.thenOrTimeoutError)({p:this.applyMigration_(r,i),timeoutMs:5*_.Settings.dbMaintenanceTimeoutMs.valueOrDefault}).catch((e=>{throw new y.WrappedError("Migration "+r.name+" timed out.",{cause:e,fatal:!0,ignorable:!1})}))})),t.push(r.base);return this.logger.info("Migration complete",{appliedMigrations:t}),t}catch(e){const t=new y.WrappedError("Migrating the "+this.schema+" db failed",{cause:e});throw(0,F.addDbSetupError)(t),P.HealthCheck.addError(t),t}},n=async function(e){const t=e.name.includes("_nofk");try{const i=await e.readTextFile(),r=(0,f.splitBatchSql)(i);if((0,M.isEmpty)(r))this.logger.info("No-op migration: "+e);else{t&&this.db.pragma("foreign_keys = OFF");for(const t of r)try{this.db.exec(t)}catch(i){this.logger.throw("Failed to apply SQL",{stmt:t,migration:e.baseWithParent,cause:i,fatal:!0})}t&&(0,I.foreignKeyCheck_)(this.db)}}finally{t&&this.db.pragma("foreign_keys = ON")}}},94715:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Migrations=t.isoToPrecisionMs=t.fix_root_tags=t.tag_path_suffix=t.migrationNameToDate=t.plucklabmodeb6=t.lowercase_psnet_function=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(97352),o=i(68852),l=i(81168),u=i(85810),c=i(42022),d=i(1971),h=i(79842),f=i(89724),m=i(17415),p=i(88600),g=i(20014),y=i(42231),v=i(87001),w=i(40958),b=i(55835),S=i(31586),P=i(97790),_=i(89937),M=i(54993),T=i(7656),E=i(36908),k=(0,s.lazy)((()=>(0,n.mkLogger)("db.Migrations"))),D=new RegExp(`^(${(0,o.escapeRegExp)(_.PS_NETWORK_FILESYSTEM_SCHEME)}://.*?/)(.*)$`);function x(e,t){return(0,a.mapGt0)(e,(()=>(0,b.map)(function(e,t=c.ModeBits){return(0,g.splitBits)(e,t).map((e=>(0,u.unlabhash)(e,t)))}(e,6)[t],(e=>(0,u.toLabhash)(e,c.ModeBits)))))}function C(e){return e.endsWith(y.TagSep)?e:e+y.TagSep}function F(e){for(const t of e.prepare("SELECT id, parentId, _path FROM Tag WHERE id = parentId").iterate())k().warn("fix_root_tags(): broken tag",{broken:t}),(0,l.countChars)(t._path,y.TagSep)<2&&e.prepare("UPDATE Tag set parentId = null where id = ?").run(t.id)}function A(e){return(0,b.map)((0,h.isoToDated)(e),h.datedToPrecisionMs)??-1}t.lowercase_psnet_function=e=>(0,P.opt)(e).filter(l.isString).flatMap((e=>D.exec(e))).map((e=>e[1].toLowerCase()+e[2])).getOrElse((()=>e)),t.plucklabmodeb6=x,t.migrationNameToDate=function(e){const[t,i,r]=[e.slice(0,4),e.slice(4,6),e.slice(6,8)].map((e=>(0,S.toInt)(e)));return(0,p.validYMD)(t,i,r)?new Date(t,i-1,r):void 0},t.tag_path_suffix=C,t.fix_root_tags=F,t.isoToPrecisionMs=A,t.Migrations={fix_root_tags:F,lowercase_psnet_hostname:e=>{e.function("lowercase_psnet_hostname",{deterministic:!0},t.lowercase_psnet_function),e.exec("DROP INDEX IF EXISTS assetfile_uri_udx"),e.exec("UPDATE AssetFile SET uri = lowercase_psnet_hostname(uri)"),e.exec("CREATE UNIQUE INDEX assetfile_uri_udx ON AssetFile(uri)")},numeric_captured_at:e=>{e.function("isoToLocal",{deterministic:!0},f.isoToLocal),e.function("isoToOffsetMinutes",{deterministic:!0},m.isoToOffsetMinutes),e.function("isoToPrecisionMs",{deterministic:!0},A),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtLocal bigint"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtOffset integer"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtPrecisionMs integer"),e.exec("UPDATE AssetFile SET capturedAtLocal = isoToLocal(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtOffset = isoToOffsetMinutes(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtPrecisionMs = isoToPrecisionMs(capturedAtISO)"),e.exec("DROP INDEX asset_captured_at_geohash_idx"),e.exec("DROP INDEX assetfile_exifuid_idx"),e.exec("CREATE INDEX assetfile_capturedAtLocal_idx ON AssetFile(capturedAtLocal)")},spread_modes:e=>{e.function("plucklabmodeb6",{deterministic:!0},x),(0,S.times)(d.ModeCount,(t=>e.exec(`ALTER TABLE AssetFile ADD COLUMN mode${t} integer`))),e.exec("UPDATE AssetFile SET "+(0,S.times)(d.ModeCount,(e=>`mode${e} = plucklabmodeb6(mode8b6, ${e})`)).join(", "))},normalize_asset_file_uris:e=>{e.function("normalizeURI",{deterministic:!0},v.normalizeURI);const t=e.prepare("SELECT normalizeURI(uri) AS nuri, count(*) AS cnt, GROUP_CONCAT(id) AS ids FROM AssetFile GROUP BY nuri HAVING cnt > 1").all(),i=[];for(const s of t){const t=(0,M.toS)(s.ids).split(","),n=e.prepare("SELECT id, shown, version, updatedAt FROM AssetFile WHERE id in ("+t.join(",")+")").all(),a=(0,r.greatestBy)(n,(e=>[e.shown,e.version,e.updatedAt])),o=n.filter((e=>e.id!==a?.id));i.push(...o.map((e=>e.id)))}for(const t of(0,r.batches)(i,256))e.exec("DELETE FROM AssetFile WHERE id in ("+t.join(",")+")");e.exec("UPDATE AssetFile SET uri = normalizeURI(uri)")},dedupe_tag_paths:E.dedupeTags_,suffix_tag_paths:e=>{e.function("tag_path_suffix",{deterministic:!0},C),(0,E.dedupeTags_)(e),e.exec("UPDATE Tag SET _path = tag_path_suffix(_path)")},normalize_tag_paths:e=>{const t=e.prepare("SELECT id, _path FROM Tag WHERE _path LIKE '%' || char(31) || char(31) || '%'").all();k().info("normalize_tag_paths():",{badTags:t});for(const i of t){const t=(0,y.normalizeTagPath)(i._path);(0,E.mergeTags_)(e,(0,w.compact)([i.id,...e.prepare("SELECT id FROM Tag WHERE _path LIKE ?").pluck().all(t)]))}},drop_tc_tables:e=>{const t=/^(ct|taf|tag_counts)_[a-z\d]{6}$/i,i=e.prepare("SELECT name FROM sqlite_master WHERE type='table'").pluck().all(),r=i.filter((e=>null!=t.exec(e)));k().info("drop_tc_tables()",{tables:i,victims:r});for(const t of r)e.exec("DROP TABLE "+t)},rebuild_rotated_heic:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype = 'image/heif' AND rotation <> 0")},rebuild_videos:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%'"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where mimetype LIKE 'video/%')")},copy_asset_duration:e=>{e.exec("CREATE INDEX tmp_af_idx ON AssetFile (assetId, durationMs)"),e.exec("UPDATE Asset SET durationMs = (SELECT durationMs FROM AssetFile WHERE assetId = Asset.id AND durationMs IS NOT NULL LIMIT 1) WHERE durationMs IS NULL"),e.exec("DROP INDEX tmp_af_idx"),e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%' and durationMs IS NULL"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where version = 0)")},rebuild_tag_asset_counts:T.rebuildTagAssetCounts,create_tag_fts:e=>{e.exec("DROP TABLE IF EXISTS tag_fts"),e.exec("CREATE VIRTUAL TABLE tag_fts USING fts5 (root, path, content='', contentless_delete=1, tokenize=\"unicode61\");")}}},27134:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.repairDbFile_=t.checkpoint_=t.verifyDbFile_=t.verifyDb_=t.foreignKeyCheck_=t.integrityCheck_=t.quickCheck_=t.backupDbFile_=t.sqlite=void 0;const r=i(14121),s=i(19851),n=i(50213),a=i(84777),o=i(12959),l=i(5531),u=i(91872),c=i(99315),d=i(76187),h=i(51040),f=i(38835),m=i(57159),p=i(29882),g=i(95696),y=i(89966),v=i(38156),w=i(28874),b=i(63870),S=i(5233),P=i(42659),_=i(41400),M=i(50357),T=i(98553),E=i(56409),k=i(31586),D=i(20214),x=i(51926),C=i(12168),F=i(59455),A=i(54993),I=i(94448),O=i(9508),L=(0,s.lazy)((()=>(0,n.mkLogger)("db.SQLite")));function R({db:e,pragma:t,okResult:i}){L().debug("pragmaOrThrow_()",{db:N(e),db_open:e?.open,pragma:t,okResult:i});const r=(0,x.isString)(i)?e.pragma(t,{simple:!0}):e.pragma(t);(0,M.eql)(r,i)||L().throw(`${t} failed for ${N(e)}: ${(0,T.stringify)({result:r})}`)}function N(e){return(0,p.ellipsizePath)({p:e.name,maxLength:80})}function B(e){return R({db:e,pragma:"quick_check",okResult:"ok"})}function j(e){return R({db:e,pragma:"integrity_check",okResult:"ok"})}function z(e){const t=(0,F.toA)(e.pragma("foreign_key_check"));t.length>w.Settings.dbInvalidFKThreshold.valueOrDefault&&L().throw("foreignKeyCheck_(): too many invalid foreign keys to repair",{dbInvalidForeignKeyThreshold:w.Settings.dbInvalidFKThreshold.valueOrDefault,badRowsCount:t.length,badRows:t});for(const i of t)L().warn("repairDbFile_(): deleting row with invalid foreign key",{row:i}),e.prepare(`DELETE FROM ${(0,h.dbValueToEscapedString)(i.table)} WHERE rowid = ?`).run(i.rowid)}async function V(e){await(0,u.handleDbRetries_)("db.quickCheck",e,B),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.integrityCheck",e,j),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.foreignKeyCheck",e,z)}function W(e){return(0,O.withDbSync)(e,V,(0,b.commandTimeoutMs)())}t.sqlite=async function({dbFile:e,sql:t,args:i}){const s=await(0,y.sqliteNativePath_)(),n=await(0,r.thenElapsed)((0,a.stdout_)(s,[...(0,F.toA)(i),e.nativePath,t],{timeoutMs:1*P.minuteMs}));return L().debug("sqlite("+t+") on "+e+" in "+n.elapsedMs+"ms",n.result),n.result},t.backupDbFile_=function(e,t){return(0,S.retryOnReject_)((()=>async function(e,t){try{await t.parent().mkdirp_(),await t.unlink("trace");const i=await e.size();if(!(0,k.gt0)(i))return void L().warn("backupDbFile_(): "+e+" is empty");await((0,I.modelDb)()?.end()),await(0,O.withDb)(e,(async e=>e.exec("VACUUM INTO "+(0,h.dbValueToEscapedString)(t.nativePath))),2*P.minuteMs),L().info("backupDbFile_(): Finished "+e+" -> "+t)}catch(i){throw new m.WrappedError(`Could not back up db ${e} -> ${t}`,{cause:i})}}(e,t)),{maxRetries:3,retryDelay:P.secondMs,timeoutMs:P.minuteMs,errorIsRetriable:()=>!0})},t.quickCheck_=B,t.integrityCheck_=j,t.foreignKeyCheck_=z,t.verifyDb_=V,t.verifyDbFile_=W,t.checkpoint_=async function e({db:t,retries:i=3,checkpointType:r=w.Settings.dbWalCheckpointType.valueOrDefault}){if((r=l.CheckpointTypes.getCI(r)??l.CheckpointTypes.AUTO)===l.CheckpointTypes.AUTO)return;const s="wal_checkpoint("+r+")",[n]=(0,F.toA)(t.pragma(s));return L().info("checkpoint()",{pragma:s,result:n}),(0,k.gt0)(n?.busy)&&i>0?(await(0,_.delay)(250),e({db:t,retries:i-1})):n};const U=/no such table: sqlite_\w+/i;t.repairDbFile_=async function(e,t=c.RepairModes.dump){const i=g.PosixFile.for(e),r=(await i.parent().join("db-"+t,(0,o.filestamp)()).mkdirp_()).join(i.base);L().info(`repairDbFile_(${i} -> ${r})`);try{const e=await(0,y.sqliteNativePath_)(),s=4*Math.min(20*C.MiB,await(0,d.sqliteSizeBytes)(i)),n=new v.PushProgressObserver({path:(0,A.toS)(i),op:"Repairing your database"},s),o=new E.Latch,l=(0,a.execFile)(e,[i.nativePath,"."+t],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});l.stdout.on("error",(e=>{const i=(0,A.toS)(e);U.test(i)?L().info("repairDbFile_(): ignoring stderr",{err:i}):o.reject(new Error("sqlite "+t+" failed: "+i))}));const u=(0,a.execFile)(e,[r.nativePath],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});u.on("exit",(()=>o.resolve())),l.stdout.on("end",(()=>{u.stdin.end(null)})),l.stdout.on("data",(e=>{const t=e.length;n.incrProgress(t),u.stdin.write(e)})),await o,L().info(`repairDbFile_(): recovered to ${r}.`),await W(r),L().info(`repairDbFile_(): ${r} is valid, finishing repair.`);const c=await(0,D.thenCollect)((0,d.sqliteFiles)(i),(e=>e.renameYMDHMS_({subdir:"needed-repair"})));return await(0,D.thenCollect)((0,d.sqliteFiles)(r),(e=>e.mv_(i.parent()))),c.find((e=>".db"===e.ext||e.ext.startsWith(".sqlite")))}catch(e){return L().throw("failed to recover DB via dump and restore. Please see https://photostructure.com/faq/restore-db-from-backup/ "+f.FatalErrorFlag,{error:e})}}},21074:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqlWhereInClause=t.isQueryBuilder=t.sqlQueryToS=t.toSqlQuery=t.isSqlQuery=void 0;const r=i(48884),s=i(68852),n=i(81168),a=i(12943),o=i(96249),l=i(98553),u=i(31586),c=i(68708),d=i(32639),h=i(54993);function f(e){return null!=e&&(0,n.isString)(e.sql)&&(null==e.bindings||(0,a.isDbValued)(e.bindings))}t.isSqlQuery=f,t.toSqlQuery=function(e){if(null==e)throw new Error("null sql");if(f(e))return e;if((0,n.isString)(e))return{sql:e};if((0,d.isFunction)(e.toSQL))return(0,c.omit)(e.toSQL(),"__knexQueryUid");throw new Error("not queryish: "+(0,l.stringify)(e))},t.sqlQueryToS=function(e){if(null==e.bindings)return e.sql;if(Array.isArray(e.bindings))return(0,o.flatten)((0,r.zip)(e.sql.split("?"),e.bindings.map((e=>(0,l.stringify)(e))))).join("");{let t=e.sql;for(const i of(0,c.keys)(e.bindings))t=t.replace(new RegExp("[@:$]"+(0,s.escapeRegExp)(i),"gi"),(0,h.toS)(e.bindings[i]));return t}},t.isQueryBuilder=function(e){return(0,d.isFunction)(e?.where)&&(0,d.isFunction)(e?.limit)},t.sqlWhereInClause=function(e){return"("+(0,u.times)(e,(()=>"?")).join(",")+")"}},35052:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localTableInfo=t.parseTableInfo=void 0;const r=i(22573),s=i(23838);function n(e){const t=new s.MultiMap;for(const i of e)i.tableName.includes("fts")||i.tableName.includes("sqlite_")||(0,r.blank)(i.name)||(0,r.blank)(i.type)||t.add(i.tableName,{name:i.name,type:i.type.toUpperCase().trim().replace(/\s+/g,""),notnull:1===i.notnull,pk:1===i.pk});return t.entriesArray().map((([e,t])=>({tableName:e,columns:t})))}t.parseTableInfo=n,t.localTableInfo=function(e){return n(e.prepare("SELECT \nm.tbl_name as tableName,\np.*\nFROM sqlite_master AS m\nJOIN pragma_table_info(m.name) AS p\nORDER BY m.tbl_name, p.cid").all())}},9508:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withDb=t.withDbSync=void 0;const r=i(80632),s=i(28874),n=i(30301),a=i(54993);t.withDbSync=function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const o=(0,n.lazy)((()=>(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i})));try{return t((function(){const e=o();return e.open?e:o.refresh()}))}finally{o.prior()?.close()}},t.withDb=async function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const n=(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i});try{return await t(n)}finally{n.close()}}},74085:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelHealthCheck=void 0;const r=i(77740),s=i(98314),n=i(18454),a=i(28874),o=i(82950),l=i(42659),u=i(45599),c=i(64526),d=i(16185),h=i(45648),f=i(31687),m={text:"Attempt database repair",title:"Run a dump and reload of your library database to try to repair it",type:"button",method:"POST",url:"/admin/repair-db",icon:"database"};t.dbModelHealthCheck=(0,u.defer)((()=>{const e=n.HealthCheck.for({section:"Library",id:"library-db",ordinal:1,pendingMsg:"Checking library database…",settings:["libraryDir","forceLocalDbReplica"],timeoutMs:()=>10*a.Settings.dbMaintenanceTimeoutMs.valueOrDefault,ttlMs:l.minuteMs,onReset:()=>(0,h.clearDbSetupErrors)({notifyListeners:!1}),links:[{text:"Read about PhotoStructure and SQLite",icon:"docs",url:"https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837"}],later:async()=>{const e=await(c.Library.instance()?.ready);if(null==e)return{level:"disabled",msg:["Library database tests disabled: no library is open"]};let t,i=!1;try{const s=Date.now();if(i=!1,(0,h.hasDbSetupErrors)())return{level:"error",msg:["Something is wrong with your library database.",(0,o.li)((0,h.dbSetupErrors)())],links:[m]};if(t=await e.modelDb(),(0,r.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");await(0,d.assertValidDbSchema_)(t),i=!0,await t.verify_(),await t.vacuum(),f.Heartbeat.assertPing_();const n=await e.dbModelSetup_();return{level:"ok",msg:["Library database is OK",(0,o.li)(["Schema validation, vacuum, optimize, and upsert round-trip took "+(Date.now()-s)+"ms","Live db is "+(0,o.tt)(t.dbFile.nativePath),"Local replica mode is "+(0,o.tt)(n.useReplica),n.useReplica?"Cold library db is "+(0,o.tt)(n.libraryDbFile):void 0])]}}catch(r){return{level:"error",msg:["Library database validation failed",(i?"":"Unrecoverable: ")+(0,s.errorToS)(r),null==t?void 0:"Live db is "+(0,o.tt)(t.dbFile.nativePath),null==e?void 0:"Local replica mode is "+(0,o.tt)(await e.useReplica())],links:i?[m]:void 0}}}});return(0,h.addDbSetupErrorListener)((()=>e.refresh())),e}))},8400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryHealthCheckSetup=void 0;const r=i(19851),s=i(88625),n=i(2858),a=i(74085),o=i(1991),l=i(40549);t.libraryHealthCheckSetup=(0,r.lazy)((async()=>{await(0,n.readSettings)(),(0,s.healthCheckSetup)(),(0,o.syncHealthCheck)(),(0,a.dbModelHealthCheck)(),(0,l.volumeUuidHealthCheck)()}))},1991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syncHealthCheck=void 0;const r=i(48884),s=i(50213),n=i(95696),a=i(62105),o=i(18454),l=i(2858),u=i(40958),c=i(82950),d=i(45599),h=i(94019),f=(0,d.defer)((()=>(0,s.mkLogger)("health.SyncHealthCheck")));t.syncHealthCheck=(0,d.defer)((()=>o.HealthCheck.for({section:"Library",id:"library-nothing-to-sync",ordinal:99,settings:["scanAllDrives","scanPaths","scanLibraryFirst","scanLibraryLast"],pendingMsg:"Checking synced directories…",later:async()=>{if(!(0,l.libraryHasSettings)())return{level:"disabled",msg:"Library sync paths test disabled: no library is open"};const e=(await(0,h.pathsToSync)()).map((e=>e.nativePath));if((0,u.isEmpty)(e))return{level:"warn",msg:"No paths are configured to scan\n"+(0,c.li)([(0,c.tt)("PS_SCAN_ALL_DRIVES")+" is false",(0,c.tt)("PS_SCAN_PATHS")+" is empty","both "+(0,c.tt)("PS_SCAN_LIBRARY_FIRST")+" and "+(0,c.tt)("PS_SCAN_LIBRARY_LAST")+" are false"]),links:[{text:"Read more",url:"https://photostructure.com/go/nothing-to-scan"}]};{const t=e.map((e=>n.PosixFile.for(e)));return f().info("Checking if any paths are empty",{posixFiles:t}),null==await(0,r.findAsync)(t,(async e=>null!=await e.someDescendant((e=>e.isDirectorySync()||(0,a.acceptParentAndFileAndSimple)(e)),1)))?{level:"warn",msg:["No eligible files found in scanned paths","Checked paths:",(0,c.li)(e.map(c.tt))],links:[{text:"Read more",url:"https://photostructure.com/go/nothing-to-scan"}]}:{level:"ok",msg:["At least one directory with eligible files is configured to be synced","Checked paths:",(0,c.li)(e.map(c.tt))]}}}})))},40549:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeUuidHealthCheck=void 0;const r=i(50213),s=i(56519),n=i(18454),a=i(28874),o=i(2858),l=i(85087),u=i(63870),c=i(86848),d=i(7014),h=i(40958),f=i(82950),m=i(45599),p=i(57924),g=i(23838),y=i(68708),v=i(94019),w=(0,m.defer)((()=>(0,r.mkLogger)("health.VolumeUUIDHealthCheck")));t.volumeUuidHealthCheck=(0,m.defer)((()=>n.HealthCheck.for({section:"Library",id:"volume-uuids",pendingMsg:"Checking volumes…",settings:["scanAllDrives"],links:[{text:"What's a “volume”?",url:"https://photostructure.com/faq/what-is-a-volume/",icon:"docs"}],later:async()=>{if(!(0,o.libraryHasSettings)())return{level:"disabled",msg:"Volume UUID test disabled: no library is open"};const e=[],t=[];if(a.Settings.scanAllDrives.valueOrDefault)e.push(...await(0,d.volumes)());else{const i=await(0,v.scanPaths)(),r=await(0,s.mapAsyncSerial)({name:"scannedVolumes",arr:i.result.map((e=>e.nativePath)),f:e=>(0,d.bestVolumeForPath)(e),timeoutMs:(0,u.commandTimeoutMs)()});e.push(...(0,h.uniqBy)(r,(e=>e.mountpoint))),t.push(...i.noUriPaths)}const i=[...(0,g.groupBy)(e,(e=>e.uuid)).values()].filter((e=>e.length>1)),r=e.filter((e=>null==e.uuid&&!(0,c.volumeUuidNotExpected)(e))).map((e=>e.mountpoint)),n=(await(0,d.volumes)()).filter((e=>!1===e.ok)).map((e=>(0,h.compactBlanks)([e.mountpoint,e.status]).join(": ")));if(w().debug("volumeHealthCheck result",{missingUUIDs:r,noUriPaths:t,unhealthyVolumes:n,scannedVolumes:e.map((e=>(0,y.pick)(e,"uuid","mountpoint")))}),(0,h.isEmpty)(r)&&(0,h.isEmpty)(i)&&(0,h.isEmpty)(t)&&(0,h.isEmpty)(n))return(0,h.isEmpty)(e)?{msg:["No volumes need UUIDs",(0,f.tt)(a.Settings.scanAllDrives.key)+" is false, and no volumes other than the library are configured to be scanned."],level:"ok"}:{msg:["All scanned volume UUIDs are OK",(0,f.li)(e.map((e=>(0,f.tt)((0,l.volsha)(e.uuid)+" → "+e.mountpoint))))],level:"ok"};{const e=[];return(0,h.isEmpty)(n)||e.push("Some volumes are unhealthy",(0,f.li)(n.map((e=>(0,f.tt)(e))))+"PhotoStructure may crash or hang when accessing unhealthy volumes."),(0,h.isEmpty)(r)||e.push("Some volumes are missing UUIDs",(0,f.li)(r.map((e=>(0,f.tt)(e)))),"This can cause problems with deduplication and library portability."),(0,h.isEmpty)(i)||e.push("Some volumes have duplicate UUIDs",i.map((e=>(0,f.li)((0,p.andList)(e.map((e=>(0,f.tt)(e.mountpoint))))+" share UUID "+(0,f.tt)(e[0].uuid)))).join("\n---\n"),"This can cause problems with deduplication and library portability."),(0,h.isEmpty)(t)||e.push("Some paths failed to have URIs generated",(0,f.li)(t.map((e=>(0,f.tt)(e)))),"This will prevent these paths from being imported."),{level:"warn",msg:e.join("\n---\n"),links:[{text:"How to manually add a UUID",icon:"handyman",url:"https://photostructure.com/faq/what-is-a-volume/#add-uuid"},{text:"Rescan volumes",type:"button",method:"POST",url:"/admin/clear-caches",icon:"refresh"}]}}}})))},86801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});try{i(93944).install()}catch{}const r=i(98314),s=i(98424);process.on("unhandledRejection",(e=>console.error("UNHANDLED REJECTION",(0,r.errorToS)(e)))),process.on("uncaughtException",(e=>console.error("UNCAUGHT EXCEPTION",(0,r.errorToS)(e)))),(0,s.run)()},64501:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InfoArgs=void 0,t.InfoArgs={beforeParse:e=>e.option("--volumes","Emit a table with currently mounted volume metadata. See https://photostructure.com/volumes for details.").option("--mountpoints","Emit a table with currently mountpoints. See https://photostructure.com/volumes for details.").option("--sync-paths","Emit a table listing the paths that will be synced next.").option("--plan, --licensing","Emit plan/licensing information. See the About page in the web UI for more details or to activate a subscription.").option("--child-env","Emit the environment variables provided to all spawned processes.").option("--validate","Only run file validation on the given filenames (requires current PLUS subscription).").option("-j, --json","Emit metadata as un-indented, uncolorized JSON.").option("--load-library","Load the library database so more metadata can be shown (like if a file is currently in your library). This adds a second or two (depending on the size of your library).").option("--filter ",'Case-insensitively filter keys by . may have dots. Note that .nativePath is always included. Repeat to filter for multiple terms ("--filter foo --filter bar").',((e,t)=>t.concat([e])),[]).option("--file-filters","Include an exhaustive list of file and directory filters. This is hundreds of lines long, so it's not included by default.").option("--image-hash",'Automatically filter image hash fields. Equivalent to "--filter imageHash --filter imageHashComparison"').option("--flat","Only return values for objects with only one field").option("--suggested-libraries","Emit the suggested library directories (as seen on the settings page).").option("--volumes-ttl","Emit the volume cache time-to-live (use with --debug to see details).").option("--is-library ","Run a couple quick checks to see if looks like a PhotoStructure library.").option("--read-settings ","Read the given file and output the parsed settings.").option("--reindex","Rebuild the tag full-text index and recount every asset tag count. This may take a minute or two. Don't have a sync running concurrently. Implies --cleanup.").option("--globs, --exclude-globs","Emit all file and directory exclusion globs.").option("--health","Emit details for all health checks.").option("--doctor","Emit details for all health checks that aren't OK.").option("--skip-health","Disable health checks.").option("--version-check","Check now if the current version is the latest.").option("--table","Emit with console.table() (useful with --volumes or --filter).").option("--cleanup","Run a bunch of maintenance tasks."),afterParse:function(){}}},98424:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.run=void 0;const s=r(i(57975)),n=i(19851),a=i(50213),o=i(88158),l=i(23560),u=i(19913),c=i(83556),d=i(94174),h=i(79184),f=i(79781),m=i(13991),p=i(92434),g=i(45608),y=i(56519),v=i(31562),w=i(9727),b=i(69554),S=i(38790),P=i(53978),_=i(43380),M=i(91655),T=i(15056),E=i(49776),k=i(48195),D=i(87290),x=i(46296),C=i(98314),F=i(8769),A=i(57159),I=i(83278),O=i(92423),L=i(95696),R=i(89966),N=i(63664),B=i(18454),j=i(80361),z=i(181),V=i(34592),W=i(81674),U=i(17181),H=i(43205),q=i(28874),G=i(2858),$=i(32707),J=i(63225),K=i(85087),Y=i(50036),Z=i(40044),X=i(59107),Q=i(63870),ee=i(7014),te=i(14854),ie=i(40958),re=i(22573),se=i(38639),ne=i(42659),ae=i(55835),oe=i(68708),le=i(34666),ue=i(5670),ce=i(12168),de=i(59455),he=i(98401),fe=i(64526),me=i(56992),pe=i(57064),ge=i(77948),ye=i(31503),ve=i(8400),we=i(92244),be=i(64501),Se=i(46854);t.run=async function(){try{await async function(){const e=await new b.CLI(ue.ServiceNames.info,"[FILE...]",["* Omit any filenames to run diagnostics and output system configuration, tooling, and health check information.","* File paths should be absolute or relative to cwd.","* Provide 2 file paths to see why PhotoStructure may consider them variants of the same asset.","* To emit valid JSON, set NO_COLOR=1 or use --json."].join("\n")).add(be.InfoArgs,_.WriteSettingsArg,ye.LogArgs,S.ColorArgs,P.TimingArg).parse();(0,u.setServiceName)("info"),(0,U.setupLogger)();const t=e.opts(),i=(0,ie.uniq)(e.args),r=(0,se.isTrue)(t.flat),g=(0,se.isTrue)(t.table),F=!0===t.reindex;F&&(q.Settings.recountAllTags.envValue=!0);const A=F||(0,se.isTrue)(t.cleanup);(0,se.isTrue)(t.imageHash)&&(t.filter??(t.filter=[]),t.filter.push("imageHash"),t.filter.push("imageHashComparison"));const Pe=(0,se.isTrue)(t.fileFilters),_e=(0,n.lazy)((()=>{if((0,ie.isEmpty)(t.filter))return;const e=(0,de.toA)(t.filter);return r&&i.length<=1||e.unshift("nativePath"),2===i.length&&e.push(...e.map((e=>"a."+e)),...e.map((e=>"b."+e))),e}));function Me(e){e=function(e){const t=_e();return null==t?e:Array.isArray(e)?e.map((e=>(0,oe.pickDeep)(e,...t))):(0,oe.pickDeep)(e,...t)}(e),r&&(e=(0,oe.flattenObject)(e));const i=(0,se.isTrue)(t.json);r&&(0,le.isPrimitive)(e)?console.log(e):i||(0,se.isFalse)(q.Settings.logColor.value)?console.log(JSON.stringify(e,void 0,i?void 0:2)):g?console.table(e):console.log(s.default.inspect(e,{depth:7,colors:!0,maxArrayLength:1024}))}let Te;if((0,u.setServiceName)("info"),(0,se.isTrue)(t.skipHealth)?B.HealthCheck.disableAll(!0):Te=await(0,N.getRemoteHealthSummary)(),(0,re.notBlank)(t.readSettings)){const e=await(0,G.importFileSettings_)(I.BaseFile.for(t.readSettings));return Me({settings:(0,oe.fromEntries)(e.settings.map((e=>[e.name,e.value]))),warnings:e.warnings})}if(await(0,G.readSettings)(),A&&(l.isDbJanitorService.set(!0),q.Settings.logLevel.isUnset()&&(q.Settings.logStdout.envValue=!0,q.Settings.logLevel.envValue="warn",(0,U.setupLogger)())),(0,se.isTrue)(t.versionCheck))return await((0,Y.channelVersionsCache)()?.unlink()),q.Settings.autoUpdateCheck.tmpValueIfUnset=!0,Me(await(0,Z.checkVersion_)());if((0,se.isTrue)(t.globs)||(0,se.isTrue)(t.excludeGlobs)){const e=(0,O.excludeGlobs)();return Me({excludeGlobs:{file:e.file.map((e=>(0,oe.pick)(e,"pattern","desc"))),dir:e.dir.map((e=>(0,oe.pick)(e,"pattern","desc")))}})}if((0,se.isTrue)(t.volumes)){const e=await(0,ee.volumes)();if(null!=e)return Me(e.filter((e=>!0!==e.ignorable)).map((e=>({filesystem:e.filesystem,...e,size:(0,ce.fmtBytes)(e.size),used:(0,ce.fmtBytes)(e.used),available:(0,ce.fmtBytes)(e.available),volsha:(0,K.volsha)(e.uuid)}))));console.error("--volumes failed. Please retry with --info for details.")}if((0,se.isTrue)(t.mountpoints)){const e=await(0,X.mountpoints)();if(null!=e)return Me(e);console.error("--mountpoints failed. Please retry with --info for details.")}if((0,se.isTrue)(t.plan)||(0,se.isTrue)(t.licensing)){const e=(await(0,W.m)())[0],t=(0,ae.map)(e?.l,(t=>({email:t.sub,trial:t.trial,issued_at:t.iat,expires:t.exp,meta:e.meta})));return Me({plan:await(0,W.t)(),current_license:t})}if((0,se.isTrue)(t.suggestedLibraries))return Me(await(0,pe.suggestedLibraryDirs)());if((0,se.isTrue)(t.volumesTtl))return Me({volumesTTL:await(0,me.calcVolumesTTL)()??(0,Q.volumeMetadataTtlMs)()});if((0,se.isTrue)(t.childEnv))return Me((0,w.childEnv)());const Ee=(0,a.mkLogger)("info");if((0,se.isTrue)(t.loadLibrary)||(0,se.isTrue)(t.syncPaths)||A){const e=(0,D.libraryDataDirPosixFile)();if(null==e)return console.error("Error: please set up your library.");if(!await e.isDirectory())return console.error("Error: your library data dir, "+e+", is missing.");Ee.info("Waiting for library to spin up...");const t=fe.Library.instance();try{await(t?.ready)}catch(e){Ee.warn("Failed to spin up library",e)}const i=(0,T.pathToDb)(e,"models");if(!await i.isNonEmptyFile())return console.error("Error: your library database, "+i+" is missing.")}if(A)return await(0,he.cleanup_)(),Me({cleanup:"OK"});if((0,se.isTrue)(t.syncPaths))return Me(await(0,we.syncPathsForUI)());if((0,re.notBlank)(t.isLibrary)){const e=await(0,k.whyNotLibraryDir)(t.isLibrary);return Me((0,oe.compactValues)({isLibrary:null==e,why:e}))}if((0,se.isTrue)(t.validate)){if((0,ie.isEmpty)(i))throw new Error("--validate requires filenames");return q.Settings.validateVideos.envValue=!0,q.Settings.validateJpegImages.envValue=!0,q.Settings.validateRawImages.envValue=!0,Me(await Promise.all(i.map((async e=>[e,(0,re.notBlankOr)(await(0,z.whyInvalidFile)(e),"OK")]))))}if((0,ie.isEmpty)(i)){await(0,v.until)((()=>te.CpuUsage.instance().busyPct()),{timeoutMs:2*ne.secondMs,intervalMs:250});const e={systemInfo:(0,oe.fromEntries)((await(0,ge.systemInformation)()).map((({term:e,defn:t})=>[(0,c.asObjectKey)(e),t])))};return e.versionCheck={userAgent:await(0,H.userAgent)(),...await(0,Z.checkVersion_)().catch((e=>({error:(0,C.errorToS)(e)}))),currentChannel:(0,Z.currentChannel)()},e.user_ids=(0,d.userids)(),e.group_ids=(0,d.groupids)(),e.username=await(0,d.username)(),e.paths={libraryDir:q.Settings.libraryDir.valueOrDefault,originalsDir:(0,D.libraryOriginalsDirPosixFile)()?.nativePath,systemSettingsFile:(0,$.systemSettingsFile)(),librarySettingsFile:(0,G.librarySettingsFile)()?.nativePath,libraryPreviewsDir:(0,D.libraryPreviewsDirPosixFile)()?.nativePath,librarySyncReportsDir:(0,D.librarySyncReportsDir)()?.nativePath,cacheDir:(0,E.cacheDir)(),logDir:(0,x.logDir)(),toolsDir:(0,R.toolsDir)()?.nativePath,osToolsDir:(0,R.osToolsDir)()?.nativePath,ffmpeg:await(0,V.ffmpegNativePath)(),sqlite:await(0,R.sqliteNativePath_)().catch((e=>"not found: "+(0,C.errorToS)(e)))},(0,se.isTrue)(t.health)?(e.healthSummary=await(0,N.getLocalHealthSummary)(),e.healthChecks=await Promise.all(B.HealthCheck.testResults())):(0,se.isTrue)(t.doctor)?(await(0,ve.libraryHealthCheckSetup)(),e.healthChecks=await B.HealthCheck.notOkResults()):e.healthSummary=Te??await(0,N.getLocalHealthSummary)(),e.wrongPsEnvValues=(0,J.verifyPsEnvSettings)(),(0,se.isTrue)(t.loadLibrary)&&(e.libraryMetrics=(0,oe.fromEntries)((await(0,ge.libraryMetrics)())?.map((e=>[(0,c.asObjectKey)(e.desc),e.count]))??[])),e.volumesTTL=(0,M.fmtFullDuration)(await(0,me.calcVolumesTTL)()),e.nonDefaultSettings=(0,oe.fromEntries)((0,oe.values)(q.Settings).filter((e=>e.hasValue())).map((e=>[e.name,e.humanValue]))),Me(e)}if(2===i.length){const e=L.PosixFile.for(i[0]),t=L.PosixFile.for(i[1]),r=await(0,m.mkAssetFile_)(e),s=await(0,m.mkAssetFile_)(t),n=[];if(null==r&&n.push("Failed to read "+e),null==s&&n.push("Failed to read "+t),(0,ie.isNotEmpty)(n))return Me({errors:n});const a=(0,f.whyNotSimilarAssetFile)(r,s),l=null==a?"These two files will be aggregated into a single asset.":"These files represent different assets: "+a;let u,c;if(null==a){const e=(0,p.sortAssetFiles)([r,s]);u=e[0]?.nativePath,c=(0,o.zipPojos)(...await Promise.all(e.map(p.assetFileSortCriteriaPojo)))}const d={fileComparison:l,primary:u,a:await(0,Se.info)(e,Pe),b:await(0,Se.info)(t,Pe),cmpArr:c};return q.Settings.useImageHashes.valueOrDefault&&(d.imageHashComparison=(0,oe.omit)((0,j.compareImageHashes)(r,s),"a","b")),Me(d)}{const e=await(0,y.mapAsync)({name:"info",arr:i,f:e=>(0,Se.info)(e,Pe)}),t=(0,oe.fromEntries)(e?.map(((e,t)=>[t,e])));if(e.length>1){const e=(0,ie.compact)(await(0,y.mapAsync)({name:"mkAssetFile",arr:i,f:e=>(0,m.mkAssetFile_)(L.PosixFile.for(e)).catch((t=>{console.error("Failed to read "+e,t)}))})),r=await(0,h.aggregateAssetFiles)(e);t.clusters=r.map((e=>e.map((e=>e.uri))))}return Me(t)}}()}catch(e){(0,F.onError)((0,A.toWrappedError)("Failed",{cause:e,fatal:!0}))}finally{await(0,g.exit)({reason:"done",status:0})}}},46854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.info=void 0;const r=i(50213),s=i(88158),n=i(13991),a=i(92434),o=i(85434),l=i(98314),u=i(92423),c=i(32144),d=i(95696),h=i(62105),f=i(17217),m=i(181),p=i(66106),g=i(78984),y=i(4936),v=i(47783),w=i(16170),b=i(54979),S=i(22573),P=i(42659),_=i(45599),M=i(68708),T=i(20214),E=i(64526),k=i(19113),D=i(88224),x=i(54017),C=i(94448),F=i(3996),A=(0,_.defer)((()=>(0,r.mkLogger)("info.InfoImpl")));t.info=async function(e,t){try{const i=d.PosixFile.for(e),r=await(0,b.readMimeType)(i);if(null==r)return{nativePath:i.nativePath,error:`Could not read mimetype for ${i.nativePath}`};if((0,c.isSidecarMimetype)(r))return{nativePath:i.nativePath,mimetype:r,error:"Skipping sidecar mimetype"};if(!await(0,w.isAssetFileMimeType)(i))return{nativePath:i.nativePath,mimetype:r,error:"Skipping non-asset file mimetype"};const l=i.parent();A().throwIfAborted_();const f=await(0,n.mkAssetFile_)(i),_=t?await g.Predicates.explain(l,...(0,u.notExcludedDirPredicates)(l)):void 0,I=t?await g.Predicates.explain(i,...(0,k.libraryFileFiltersFor)(i,{validateFile:!0})):void 0,O=f.dominantColors?.filter((e=>null!=e?.color?.name)).map((e=>({rgb:e.rgbhex,name:e.color?.name,pct:e.pct}))),L=await(0,D.tagAsset)({primaryVariation:i,files:[],priorTagPaths:[],capturedAts:[],uris:[await i.uri_()]}),R=null==(0,C.modelDb)()?void 0:await new F.AssetFileFinder(i).prior(),N=await(R?.matchesFile()),B=await(0,T.thenCollect)(x.AssetFile.sameShaInLibrary(i),(e=>e.getNativePath()));A().throwIfAborted_();const j=await(0,v.readTags)(i),z=(0,h.whyRejectFile)(i,!0===E.Library.instance()?.isReadySync()?(0,k.libraryFileFiltersFor)(i):void 0),V=(0,M.compactValues)({...(0,o.omitModeData)(f),...(0,M.pick)(j,"tz","tzSource","errors","inferred","duration"),dirFilters:_,dominantColors:O,fileFilters:I,needsTranscoding:await(0,p.needsTranscoding)(i),pathsInLibrary:B,pathToLibraryAsset:(0,y.pathToLibraryAsset)((0,P.localToDate)(f.capturedAtLocal),i),priorAssetFile:R?.toJSON(),priorIsInSync:N,sidecars:(await i.existingSidecars()).map((e=>e.base)),tagResult:L,validFile:(0,S.notBlankOr)(await(0,m.whyInvalidFile)(i.nativePath),"OK"),variantSortCriteria:(0,a.assetFileSortCriteriaPojo)(f),whyExcludedDirectoryRecursive:await(0,u.whyExcludedDirectoryRecursive)(l),whyRejected:z});return(0,M.compactValues)({nativePath:i.nativePath,mimetype:r,...(0,s.sortedKeys)(V)})}catch(t){return{nativePath:(0,f.toNativePath_)(e),error:(0,l.errorToS)(t)}}}},43487:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Asset=void 0;const u=i(48884),c=i(19851),d=i(50213),h=i(88158),f=i(45393),m=i(56519),p=i(89724),g=i(38835),y=i(74128),v=i(79847),w=i(28874),b=i(47783),S=i(38010),P=i(40958),_=i(76790),M=i(75761),T=i(38639),E=i(11371),k=i(98553),D=i(55835),x=i(31586),C=i(20214),F=i(59455),A=i(64526),I=i(4407),O=i(54017),L=i(48722),R=i(37094),N=i(45295),B=i(39604),j=i(48723),z=i(41507),V=i(72761),W={"Asset.shown":1,"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null};class U extends V.TimestampedModel{constructor(){super(...arguments),r.add(this),this.attrs={},this.assetIdish=(0,c.lazy)((()=>({assetId:this.id,v:this.updateCount,capturedAtLocal:this.capturedAtLocal}))),this.mergedTags=(0,c.lazy)((async()=>{const e=[];for(const t of this.getAssetFiles()){const i=await t.posixFile(),r=await(0,b.readTags)(i),s=await(i?.mtimeMs());null!=i&&null!=r&&null!=s&&e.push({...r,SourceFile:i.nativePath,sourceModifiedTime:s,sourceIsPrimary:(0,T.isTrue)(t.shown)})}const t=R.AssetRevision.ops().allf((e=>e.where({assetId:this.id}))),i=new S.MergedTags("Asset:"+this.id);return i.addTag(...e,...this.assetFiles),i.addRevision(...t),i}))}static shownUnhidden(e){return null==e?s.query().where(W):e.andWhere(W)}static findUnhiddenById(e){return(0,x.gt0)(e)?s.ops().firstf((t=>s.shownUnhidden(t.where({id:e})))):void 0}static shownRemovable(e,t){return(t??s.query()).whereNotNull(e).andWhere({"Asset.shown":1})}static shownCount(){return s.ops().count(s.shownUnhidden().countDistinct("Asset.id"))}static deletePreviews(e){return A.Library.instance().previews().ap(e).deleteAll()}static async remove({assetId:e,blocklistShas:t,unlinkAssetFiles:i}){const r=(0,d.mkLogger)("Asset("+e+").remove()"),n=s.ops().findById(e);if(null==n)return void r.warn("asset not found");const a=n.isActive(),o=n.tagIds();r.info("starting",{unlinkAssetFiles:i});const l=n.getAssetFiles({refresh:!0});if(t){(0,B.upsertToShaBlockslist)(...l.map((e=>e.sha)));for(const e of l)(0,y.syncReport)().onProgress({from:"Asset.remove",path:await e.getNativePath()??e.uri,state:"blocklisted",details:"sha blocklisted (files with the same sha will not be imported)"})}N.AssetTag.dbl.runf((t=>t.delete().where({assetId:e}))),O.AssetFile.dbl.runf((t=>t.delete().where({assetId:e}))),R.AssetRevision.dbl.runf((t=>t.delete().where({assetId:e}))),s.dbl.runf((t=>t.delete().where({id:e}))),a&&j.Tag.deltaAssetCountAndAncestors(o,-1);try{await s.deletePreviews(e)}catch(e){r.error("Failed to delete previews",{error:e})}return{deletedMeta:i?await(0,v.trashOrUnlinkFileUris_)(l):[],assetFileMeta:l}}static nextOutdated(e=h.identity){return this.ops().findOne(e(l(this,s,"m",n).call(this)))}static nextOutdateds(e){return this.ops().all(e(l(this,s,"m",n).call(this)))}static outdatedCount(e=h.identity){return this.dbl.pluckFirst(e(l(this,s,"m",n).call(this)).count())}static findFirstByFile(e){return this.ops().findOne(e(this.query().select("Asset.*").join("AssetFile","AssetFile.assetId","Asset.id")))}static unshownAssetIds(){return this.dbl.pluckAll("\n SELECT DISTINCT af1.assetId\n FROM AssetFile af1\n LEFT JOIN (SELECT DISTINCT assetId FROM AssetFile WHERE shown = 1) AS af2 \n ON af1.assetId = af2.assetId\n WHERE af2.assetId IS NULL")}static archive(e){null!=s.ops().findById(e)&&(N.AssetTag.dbl.runf((t=>t.where({assetId:e}).delete())),O.AssetFile.dbl.runf((t=>t.where({assetId:e}).delete())),s.dbl.runf((t=>t.where({id:e}).delete())))}markUnshownAndUpsert(){this.shown=!1,this.version=f.AssetVersion,this.upsert()}markShownAndUpsert_(e){const t=this.getShown()?.id;if(null!=e){const t=e.shown;this.setShown_(e,{skipUpsert:!0}),!0!==t&&e.upsert()}this.shown=!0,this.version=f.AssetVersion,t!==this.getShown()?.id&&(this.updateCount=(this.updateCount??0)+1),this.upsert()}async updateFromFiles(){const e=await this.mergedTags();(0,D.map)(e.get("rating"),(e=>{this.logger().info("updateFromFiles()",{rating:e}),this.rating=e.value}))}isActive(){return(0,x.gt0)(this.id)&&!0===this.shown&&null==this.excludedAt&&null==this.deletedAt&&(null==this.rating||(0,x.gte)(this.rating,w.Settings.rejectRatingsLessThan.valueOrDefault))}toAssetId(){return(0,L.toAssetId)(this)}renderCaption(e){return(0,D.map)(this.capturedAtLocal,(t=>"Taken "+(0,p.fmtLocalDateShort)(t,e)))}async whenApiTag(){const e=(0,I.dateTag)((0,p.localToDateObject)(this.capturedAtLocal));return null==e?void 0:j.Tag.findOrCreate(e).toApiTag()}findAssetFileByUri(e){return this.getAssetFiles()?.find((t=>t.uri===e))}addAssetFile(e){(0,P.filterInPlace)(e.asset?.assetFiles??[],(t=>!(t.id===e.id||t.uri===e.uri))),e.assetId=this.id,e.asset=this,e.shown=!1,this.getAssetFiles().push(e),this.clear(),this.capturedAtLocal??(this.capturedAtLocal=e.capturedAtLocal),this.rating??(this.rating=e.rating),this.durationMs??(this.durationMs=e.durationMs)}async assetFileForFile_(e,t){const i=await e.uri();if(null==i)return this.logger().throw("assetFileForFile_(): null uri",{f:e});const r=this.getAssetFiles().find((e=>e.uri===i));if(null!=r)return r;const s=new O.AssetFile;return this.addAssetFile(s),!0!==t?.skipUpsert?await s.upsertIfNeeded_(e):await s.setFile_(e),s}static getTags(e){return j.Tag.ops().all(j.Tag.query().select("Tag.*").join("AssetTag","AssetTag.tagId","Tag.id").where("AssetTag.assetId",e).orderByRaw("COALESCE(Tag.ordinal, Tag._path)"))}tagIds(e){return!0===e?.refresh&&(this.tags=void 0),this.tags?.map((e=>e.id))??N.AssetTag.dbl.pluckAllf((e=>e.select("tagId").where({assetId:this.id})))}getTags(e){return!0===e?.refresh&&(this.tags=void 0),this.tags??(this.tags=s.getTags(this.id))}tagPaths(){return this.getTags().map((e=>e.path.join("/"))).sort()}setTagIds(e){const t=this.tagIds({refresh:!0});if((0,u.eqlUnordered)(t,e))return void this.logger().debug("setTagIds(): no-op, tagIds unchanged");const i=e.filter((e=>!t.includes(e))),r=t.filter((t=>!e.includes(t)));return this.applyTagIdDeltas({tagIdsToAdd:i,tagIdsToRemove:r})}applyTagPathDeltas(e){return this.applyTagIdDeltas({tagIdsToAdd:j.Tag.findOrCreateByPathN(e.add??[]).map((e=>e.id)),tagIdsToRemove:j.Tag.findByPathN(e.remove??[]).map((e=>e.id))})}applyTagIdDeltas(e={}){const t=this.tagIds({refresh:!0}),i=(0,P.uniq)((0,F.toA)(e.tagIdsToAdd).filter((e=>(0,x.gt0)(e)&&!t.includes(e)))),r=(0,P.uniq)((0,F.toA)(e.tagIdsToRemove).filter((e=>(0,x.gt0)(e)&&t.includes(e))));if((0,P.isEmpty)(i)&&(0,P.isEmpty)(r))return this.logger().info("applyTagIdDeltas(): no-op, no changes",{currentTagIds:t,...e}),t;this.isActive()&&j.Tag.deltaAssetCountAndAncestors(t,-1),(0,P.isEmpty)(i)||N.AssetTag.dbl.runf((e=>e.insert(i.map((e=>({assetId:this.id,tagId:e})))).onConflict(["assetId","tagId"]).ignore())),(0,P.isEmpty)(r)||N.AssetTag.dbl.runf((e=>e.whereIn("tagId",r).andWhere({assetId:this.id}).delete())),this.tags=void 0;const s=(0,P.uniq)([...t,...i]).filter((e=>!r.includes(e)));return this.isActive()&&j.Tag.deltaAssetCountAndAncestors(s,1),s}getStreams(e){if(null==this.streams){const t=this.getTags();this.logger().info("getStreams(): fetched tags "+t,{limit:e});const i=t.map((t=>t.getAssetStream(this,e)));this.streams=(0,z.coalesceStreams)((0,P.compact)(i));for(const e of this.streams)for(const t of e.tags)t.getAncestors()}return this.streams}getBeforeAfterId(){const e=s.dbl.all(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",this.capturedAtLocal).orderBy("assetId"));this.afterId=e.find((e=>e.assetId>this.id)),this.beforeId=e.reverse().find((e=>e.assetIde.path))}getAssetFiles({refresh:e=!1}={}){return null!=this.id&&(e&&(this.assetFiles=void 0),this.assetFiles??(this.assetFiles=(0,_.sortBy)(O.AssetFile.ops().findBy({assetId:this.id}),(e=>[!(0,T.isTrue)(e.shown),-e.mtime])))),this.assetFiles??[]}setShown_(e,t){e instanceof O.AssetFile&&(this.getAssetFiles(),this.assetFiles?.some(((t,i)=>{const r=t.id===e.id||t.uri===e.uri;return r&&(this.assetFiles[i]=e),r})));const i=e instanceof O.AssetFile?e.id:e;if(this.getShown()?.id===i)return void this.logger().debug("setShown_(): no-op, already set",{afId:i});this.logger().info("setShown_()",{assetId:this.id,assetFileId:i}),(0,x.gt0)(this.id)&&(0,x.gt0)(i)||this.logger().throw("setShown_(): invalid IDs: "+(0,k.stringify)({assetId:this.id,assetFileId:i})+g.InternalErrorFlag);const r=Date.now();O.AssetFile.dbl.runf((e=>e.update({shown:0,updatedAt:r}).where({assetId:this.id}))).changes<=0&&this.logger().warn("setShown_(): all asset files were already unshown",{afId:i});const s=O.AssetFile.dbl.runf((e=>e.update({shown:1,updatedAt:r}).where({id:i})));1!==s.changes&&this.logger().throw("setShown_(): failed to update asset file: unexpected changed rows",{runResult:s});const n=this.assetFiles?.find((e=>e.id===i))??this.getAssetFiles({refresh:!0}).find((e=>e.id===i));if(null!=n){this.capturedAtLocal=n.capturedAtLocal,this.rating=n.rating,this.durationMs=n.durationMs;for(const e of this.assetFiles??[])e.shown=e.id===i;!0!==t?.skipUpsert&&this.upsert()}else this.logger().throw("setShown_(): failed to find shown asset file",{af:e})}getShown(e){return this.getAssetFiles(e)?.find((e=>(0,T.isTrue)(e.shown)))??this.getAssetFiles({refresh:!0})?.find((e=>(0,T.isTrue)(e.shown)))}getShownNativePath(){return this.getShown()?.getNativePath()}async getCapturedAts(){return(0,C.thenCollect)(this.getAssetFiles(),(e=>e.capturedAt()))}link(){return"/asset/"+this.id}sqAttrs(e=!0){return{...(0,M.assetSqImgAttrs)({assetId:this.assetIdish(),lazyLoad:e}),title:this.renderCaption(),...this.attrs}}async getImgAttrs(e,t,i=!1){if(null==this.imgAttrs&&(this.imgAttrs=new Map),null==this.imgAttrs.get(t)){const r=e.ap(this.id);await(0,m.thenMap)(r.readInfo(),(async e=>{e.mimetype.startsWith("video/")&&(this.poster=await r.posterLink())}));const s=!0;this.imgAttrs.set(t,await r.imgAttrs(t,s,i))}return this.imgAttrs.get(t)}async fitAttrs(e){return{...await this.getImgAttrs(e,E.ReducerNames.fit),...this.attrs}}isVideo(){if(null==this.assetFiles)throw new Error(".video called before getFiles()");return this.assetFiles.some((e=>e.isVideo))}videoAttrs(){return{controls:!0,autoplay:!0,poster:this.poster,...this.attrs}}async videoSources(){const e=[];let t;for(const i of this.getAssetFiles())e.some((e=>e.type===i.mimetype))||await i.exists()&&(t??(t=i),e.push({src:(0,M.assetVideoLink)({assetId:this.assetIdish(),assetFileId:i.id}),type:i.mimetype}));return e.some((e=>"video/mp4"===e.type))||null==t||e.unshift({src:(0,M.assetVideoLink)({assetId:this.assetIdish(),assetFileId:t.id})+".mp4",type:"video/mp4"}),e}async getPosixFiles(){return(0,C.thenCollect)(this.getAssetFiles(),(e=>e.posixFile_()))}async getExistingAssetFiles(){return(0,m.filterAsync)({name:"getExistingAssetFiles",arr:this.getAssetFiles(),f:e=>e.exists()})}async findOrCreateByFile(e){const t=await e.uri_();if(null==t)return;const i=(0,F.toA)(O.AssetFile.ops().findBy({assetId:this.id,uri:t}))[0];return(0,D.orElse)(i,(async()=>{const t=new O.AssetFile;return t.asset=this,t.assetId=this.id,await t.setFile_(e),t}))}partialSimpleAsset(){return{assetId:this.id,liked:(0,x.gte)(this.rating,w.Settings.likeRating.valueOrDefault),hidden:(0,T.isTrue)(this.hidden),excluded:null!=this.excludedAt,deleted:null!=this.deletedAt}}clear(){return this.imgAttrs=void 0,this.streams=void 0,this.tags=void 0,this.mergedTags.unset(),this}}t.Asset=U,s=U,r=new WeakSet,n=function(){return s.shownUnhidden().andWhere("version","<",f.AssetVersion)},a=function(){return this.beforeId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal","<",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId",order:"desc"}]))},o=function(){return this.afterId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",">",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"asc"},{column:"assetId",order:"asc"}]))},U.$tableName="Asset",U.$uniqueColumnName="id",U.$booleanFields=["shown","hidden"]},54017:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFile=void 0;const a=i(76760),o=i(19851),l=i(88158),u=i(45393),c=i(68852),d=i(81168),h=i(13991),f=i(54296),m=i(56519),p=i(76490),g=i(89724),y=i(98314),v=i(38835),w=i(8769),b=i(29882),S=i(95696),P=i(62105),_=i(74128),M=i(35721),T=i(69589),E=i(28874),k=i(28544),D=i(16170),x=i(45200),C=i(34238),F=i(87001),A=i(42233),I=i(21404),O=i(40958),L=i(17586),R=i(22573),N=i(38639),B=i(42659),j=i(33374),z=i(50357),V=i(75240),W=i(11371),U=i(55835),H=i(31586),q=i(68708),G=i(34666),$=i(89937),J=i(75020),K=i(64526),Y=i(41844),Z=i(43487),X=i(48723),Q=i(94710),ee=i(72761);class te extends ee.TimestampedModel{constructor(){super(...arguments),r.add(this),this.uriObj=(0,o.lazy)((()=>C.URI.parse(this.uri))),this.whyRejected=(0,o.lazy)((async()=>{const e=await this.posixFile_();return null==e?"invalid URI":!0===await this.isFileDeleted()?"deleted":(0,P.whyRejectFile)(e)})),this.posixFile_=(0,o.lazy)((async()=>S.PosixFile.for(await this.getNativePath())))}static outdatedQuery(e){let t=(e.q??this.query()).where("version","<",u.AssetFileVersion);return null!=e.maxUpdatedAt&&(t=t.andWhere("updatedAt","<",e.maxUpdatedAt)),t.andWhere((t=>{(0,O.isNotEmpty)(e.mountpoints)&&(t=t.whereIn("mountpoint",e.mountpoints));for(const i of e.uris)t=t.orWhereLike("uri",i+"%");return t})).orderBy("id")}static async nextOutdated(e=l.identity){return this.ops().findOne(e(this.outdatedQuery(await(0,A.currentVolumeRoots)())))}static async outdatedCount(e=l.identity){const t=this.outdatedQuery(await(0,A.currentVolumeRoots)());return this.dbl.pluckFirst(e(t.count("id")))}static shownAssetFileId(e){return this.dbl.pluckFirstf((t=>t.where({assetId:e,shown:1}).limit(1)))}static primaryForAssetId(e){return(0,H.gt0)(e)?te.ops().first(Z.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id").select("AssetFile.*").where({assetId:e,"AssetFile.shown":1})):void 0}static shownUnhidden({uriRoot:e}={}){let t=Z.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id");return(0,R.blank)(e)||(t=t.andWhereLike("AssetFile.uri",e+"%")),t}static recentAssetIdsByUriRoot(e,t,i=64){const r=Date.now()-t;return this.dbl.pluckAll(te.shownUnhidden({uriRoot:e}).distinct("AssetFile.assetId").where("AssetFile.updatedAt",">",r).orderBy("AssetFile.updatedAt","desc").limit(i))}static assetFileCountByMimeType(e){const t=te.shownUnhidden({uriRoot:e}).select("mimetype").countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"}).groupBy("mimetype").orderBy("mimetype");return this.dbl.all(t)}static assetFileCountWithMimeType(e,t){let i=te.shownUnhidden({uriRoot:t}).countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"});return i=e.endsWith("/")?i.andWhereLike("mimetype",e+"%"):i.andWhere("mimetype",e),this.dbl.first(i)}static assetFileCountByMimeTypeRoots(e=["image/","video/"],t){return e.map((e=>({mimeTypeRoot:e,assetFileCount:te.assetFileCountWithMimeType(e,t)?.assetFileCount??0})))}static children(e,t){const i=this.query().whereLike("uri",e+"/%").andWhere("uri","regexp",`^${(0,c.escapeRegExp)(e)}/[^/]+$}`);return this.ops().all(null==t?i:t(i))}static async sameShaInLibrary(e){if(null==this.db())return;const t=await e.sha(),i=await e.size();return null!=t&&null!=i?this.ops().allf((e=>e.where({sha:t,fileSize:i}).andWhereLike("uri",$.PS_LIBRARY_PROTOCOL+"%"))):void 0}static sameAssetFileInLibrary(e){return this.ops().allf((t=>t.where((0,q.pick)(e,"sha","fileSize")).andWhere((e=>e.whereLike("uri",$.PS_LIBRARY_PROTOCOL+"%"))).andWhere((t=>t.whereNot({id:e.id})))))}librarySiblings(){return this.getAsset()?.getAssetFiles().filter((e=>e.id!==this.id&&e.uri.startsWith($.PS_LIBRARY_PROTOCOL)))}capturedAtLocale(e){return(0,g.fmtLocalDateShort)(this.capturedAtLocal,e)}get dominantColors(){return p.DominantColor.fromModeData(this)}set dominantColors(e){(0,q.assignAllFields)(this,p.DominantColor.toModeData(e))}get posixPathFromGrandparent(){return(0,U.map)(this.uriObj()?.fsPath,b.posixPathFromGrandparent)}async whyNotMatchesFile(e){const t=n(this,r,"m",s).call(this);if(null!=t)return t;if(null==this.fileSize||null==this.mtime)return"missing file metadata";if(null!=e){const t=await e.uri();if(null==t)return"file has no URI";if(!await(0,F.uriIsEquivalent)(this.uri,t))return"file URI mismatch"}try{const t=e??await this.posixFile_();if(!await t.exists())return"file is missing";const i=await this.fileFields_(t);return null==i?!0===await(t?.isDeleted())?"file is deleted":"file is unreadable":i.fileSize!==this.fileSize?"file size changed since last sync":(0,H.closeTo)(i.mtime,this.mtime,2*B.secondMs)?void 0:"file mtime changed since last sync"}catch(e){return(0,y.errorToS)(e)}}async matchesFile(e){const t=await this.whyNotMatchesFile(e);return this.logger().tap({level:"info",msg:"matchesFile()",result:null==t,meta:{whyNot:t}})}async whyNotInSyncWithFile(e){return E.Settings.forceSync.valueOrDefault?E.Settings.forceSync.key+"=true":this.version!==u.AssetFileVersion?"AssetFileVersion: "+this.version+" != "+u.AssetFileVersion:this.whyNotMatchesFile(e)}async inSyncWithFile(e){const t=await this.whyNotInSyncWithFile(e);return this.logger().tap({msg:"inSyncWithFile()",result:null==t,meta:{whyNotInSync:t}})}async fileFields_(e){const t=e??await this.posixFile_();return null==t?void 0:await(0,h.assetFileStatFields_)(t)}isInLibrary(){return this.uri.startsWith($.PS_LIBRARY_PROTOCOL)}async isNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){const t=await this.whyNotNoop(e);return this.logger().tap({msg:"isNoop()",result:null==t,meta:{whyNotNoop:t}})}async whyNotNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){if(!0===e.forceSync)return"forceSync is true";if(!(0,H.gt0)(this.id))return"missing .id";if(!(0,H.gt0)(this.assetId))return"missing .assetId";{const e=await this.whyNotInSyncWithFile();if(null!=e)return e}if(await(0,Y.mayCopyAssetsToLibrary)()){const e=K.Library.instanceRequired_().assetFileRepository(),t=e.whyNotCopyFile(await this.posixFile_());if((0,R.blank)(t)&&null==await e.existingLibraryAssetFile(this))return"need to copy into library"}this.syncState=_.AssetFileSyncStates.noop}isVersionUpToDate(){return(0,G.gte)(this.version,u.AssetFileVersion)}async siblingCount(){return te.dbl.pluckFirstf((e=>e.count().where({assetId:this.assetId}).andWhereNot({id:this.id})))}async upsertIfNeeded_(e,t=(0,T.forceContextOrSetting)()){if(null!=e&&await this.setFile_(e),await this.matchesFile()&&(0,H.gt0)(this.id)&&!t.forceSync)return void(null==this.syncState&&(this.upsert(),this.syncState??(this.syncState=_.AssetFileSyncStates.noop)));const i=await this.isFileDeleted();if(!0===i)return this.syncState=_.AssetFileSyncStates.deleted,this.delete(),!0!==t.skipAssetRepair&&Q.Task.addOne("repairAsset",{assetId:this.assetId}),this;if(!1===i){const i=await this.updateFromFile_(e,t);return this.syncState??(this.syncState=null==i?_.AssetFileSyncStates.noop:_.AssetFileSyncStates.synced),this.upsert()}return this.syncState??(this.syncState=_.AssetFileSyncStates.skipped),this}async updateFileFields_(e){(0,q.assignFields)(this,await this.fileFields_(e))}async updateFromFile_(e,t=(0,T.forceContextOrSetting)()){const i=Date.now(),r=this.logger().addContext(".updateFromFile_()");if(null!=this.id&&!0!==t.forceSync&&await this.matchesFile(e))return void r.info("updateFromFile() no-op: up-to-date version and file stat matches since last update");if(null!=e&&await this.setFile_(e),null==e&&(e=await this.posixFile_()),null==e||await e.clear().notExists())return this.syncState=_.AssetFileSyncStates.deleted,void r.info("no-op, "+e+" is missing");const s=await(0,h.mkAssetFile_)(e);return s.uri!==this.uri&&((0,R.blank)(this.uri)||!0===this.uri?.startsWith("file:"))&&(this.logger().warn("updateFromFile() upgrading uri",{prior:this.uri,new:s.uri}),this.uri=s.uri),(0,q.assignAllFields)(this,(0,q.omit)(s,"uri")),this.version=u.AssetFileVersion,this.syncState=_.SyncFileStates.synced,r.elapsed("finished",Date.now()-i,this.toJSON()),this}async updateFromShaSibling_(e){const t=n(e,r,"m",s).call(e);if(null==t){if(await this.exists())return this.logger().debug("updateFromShaSibling",e),null!=e.sha&&await e.matchesFile()&&this.sha===e.sha?((0,q.assignFields)(this,(0,q.omit)(e,"id","posixFile","uriObj","shown","uri","mtime","fileSize","mountpoint","createdAt","updatedAt","updateCount",...te.$transientFields)),this.updateFileFields_()):this.updateFromFile_();this.logger().warn("updateFromShaSibling(): fail: file is missing")}else this.logger().warn("updateFromShaSibling() sibling is invalid",{whySiblingIsInvalid:t})}getAsset(){return this.asset??(this.asset=(0,H.gt0)(this.assetId)?Z.Asset.ops().findById(this.assetId):void 0)}exists(){return(0,x.uriExists)(this.uri,this.mountpoint)}async isFileDeleted(){return(await this.posixFile_())?.isDeletedUri(this.uri)}async accepted(){return(0,R.blank)(await this.whyRejected())}async setFile_(e){const t=await e.uri_();if(null==t)return this.logger().throw("setFile(): no URI for "+e);const i=await e.mountpoint();if(null!=this.uri&&!await(0,F.uriIsEquivalent)(t,this.uri))return this.logger().throw("setFile(): cannot reassign non-equivalent URI",{prior:this.uri,new:t,file:e.nativePath});const r=await e.uriObject_();return null==r?this.logger().throw("failed to create URI for "+e):(this.uri=t,this.uriObj.set(r),this.mountpoint=i?.nativePath,this.nativePath=e.nativePath,this.posixFile_.set(Promise.resolve(e)),this)}get basename(){return(0,R.blank)(this.uri)?void 0:decodeURIComponent(this.uri.slice(this.uri.lastIndexOf("/")+1))}posixFile(){return this.posixFile_().catch((()=>{}))}async getNativePath(){return(0,R.blank)(this.nativePath)&&(null==this.uri?this.logger().error(".getNativePath() called before .setFile_()"+v.InternalErrorFlag):this.nativePath=await(0,f.getAssetFileNativePath)(this)),this.nativePath}async capturedAt(){return null==this.nativePath&&await this.getNativePath(),k.CapturedAt.fromAssetFile(this)}async originalDownloadable({brief:e=!1}={}){const t=this.basename;if(!0===e)return null==t?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:`Download ${t}`,basename:t,description:"Download original"};const i=await this.posixFile_();return this.logger().tap({msg:"originalDownloadable()",level:"info",result:null==i||await i.isEmpty()?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:e?`Download ${i.base}`:(0,M.mkDownloadableTitle)(i,"original",this.isVideo?"video":"image",{width:this.width,height:this.height}),basename:i.base,description:"Download original",details:`(${(0,j.fmtDim)(this)} ${i.ext})`},meta:{posixFile:i}})}async downloadables(e,t){try{const i=await this.posixFile_();if(null==i)return[];const r=e.ap(this.assetId),s=[];if(await(0,m.thenMap)(this.originalDownloadable(),(e=>s.push(e))),this.isVideo)return s;if(!(0,N.isTrue)(this.shown)&&this.sha!==t)return s;const n=(0,O.compact)(await Promise.all([...await r.previewInfos()].reverse().filter((e=>e.reducer===W.ReducerNames.fit)).map((e=>(0,M.previewToDownloadable)(i.base,e)))));return s.push(...(0,O.uniqBy)(n,(e=>e.size))),s}catch(e){return(0,w.onError)("AssetFile.downloadables failed for "+this.uri,e),[]}}async pathInfo(){try{const e=C.URI.parse(this.uri),t=(0,U.map)((0,I.uriToTagPath)({uri:e,isFile:!0}),(e=>X.Tag.findByPath(e)));return this._pathInfo_(await(t?.toApiPathElements()))}catch(e){return void this.logger().warn("pathInfo(): failed",e)}}async _pathInfo_(e){const t=await this.posixFile_();if(null==t)return this.logger().throw("pathInfo(): no posixFile",{uri:this.uri});const i=t.nativePath,r=C.URI.parse(this.uri),s=await t.exists();if(null==e||(0,O.isEmpty)(e))return this.logger().warn("pathInfo(): failed to find existing Tag. Returning a simple path.",{uri:this.uri,nativePath:i,tagLineage:e}),{nativePath:i,pathElements:[],nativePathSuffix:i,pathSep:a.sep,exists:s};function n(){return(0,L.at)((0,L.at)(e,-1)?.tagPath,-1)}(0,z.eql)(e[0]?.tagPath,[J.TagRoots.fs])&&(e=e.slice(1));const o=r.scheme===$.PS_LIBRARY_SCHEME,l=o?r.path.split("/").slice(1):t.pathnames,u=l.pop(),c=[];for(;l.length>0&&(0,d.equalsIgnoreCase)(n(),(0,L.at)(l,-1));){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("added matching tag",t)}if(o&&n()===J.LibraryTagName){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("pslib: added matching library tag",t)}if(r.scheme===$.PS_LOCAL_FILE_SCHEME){const t=C.URI.parse(this.uri).authority;if(this.logger().debug("psfile: pop last?",{lastTagName:n(),thisVolSha:t}),n()===t){l.pop();const t=e.pop();c.unshift(t)}else this.logger().warn("weird: I expected to be able to include the volsha tag element, but it doesn't seem to match",{thisVolSha:t,tagVolSha:n()})}return this.logger().tap({msg:"pathInfo()",result:{nativePath:i,pathElements:c,nativePathSuffix:u,pathSep:a.sep,exists:s}})}async toApi(e,t){return(0,m.thenMap)(this.pathInfo(),(async i=>(0,q.reqValuedOrElse)({assetId:this.assetId,assetFileId:this.id,...i,mimetype:this.mimetype,shown:(0,N.isTrue)(this.shown),name:this.basename,width:this.width,height:this.height,rotation:this.rotation??0,fileSize:this.fileSize,mtime:this.mtime,downloadables:await this.downloadables(e,t),createdAtLocale:ie(this.createdAt),updatedAtLocale:ie(this.updatedAt)})))}get isVideo(){return(0,D.isVideoMimeType)(this.mimetype)}}function ie(e){return(0,U.map)(e,(e=>(0,V.fmtDuration)(Date.now()-e,1)+" ago"))}t.AssetFile=te,r=new WeakSet,s=function(){if((0,R.blank)(this.uri))return"blank uri";if((0,R.blank)(this.sha))return"blank sha";if(!(0,H.gt0)(this.width))return"missing width";if(!(0,H.gt0)(this.height))return"missing height";if(!(0,H.gt0)(this.capturedAtLocal))return"missing capturedAtLocal";if(!(0,H.gte0)(this.capturedAtPrecisionMs))return"missing capturedAtPrecisionMs";if(E.Settings.useImageHashes.valueOrDefault){const e=[];for(const t of["dctHash","diffHash","meanHash"])(0,R.blank)(this[t])&&e.push(t);if(1===e.length)return"missing image hash: "+e[0];if(e.length>1)return"missing image hashes: "+e.join(", ")}return this.isVersionUpToDate()?void 0:"outdated version"},te.$tableName="AssetFile",te.$uniqueColumnName="uri",te.$booleanFields=["shown"],te.$transientFields=["nativePath","syncState"]},48722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toAssetId=void 0;const r=i(76596),s=i(31586);t.toAssetId=function(e){const t=(0,s.toGt0)(e?.assetId)??(0,s.toGt0)(e?.id);if(null==e||null==t||!(0,s.isNumber)(e?.capturedAtLocal))return;const i=((0,s.toGt0)(e.v)??(0,s.toGt0)(e.updateCount)??(0,s.toGt0)(e.updatedAt)??0)%1e6,n={assetId:t,capturedAtLocal:e.capturedAtLocal,v:i};return(0,s.gt0)(e.durationMs)&&(n.durationHMS=(0,r.durationHMS)(e.durationMs)),n}},37094:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetRevision=void 0;const r=i(98553),s=i(67478),n=i(55046);class a extends n.Model{static insert(...e){return a.ops().insert(e.map((e=>({assetId:e.assetId,createdAt:Date.now(),field:e.field,op:e.op,_priorValueJson:(0,r.stringify)(e.priorValue),_newValueJson:(0,r.stringify)(e.newValue)}))))}get priorValue(){return(0,s.parseJSON)(this._priorValueJson)}get newValue(){return(0,s.parseJSON)(this._newValueJson)}}t.AssetRevision=a,a.$tableName="AssetRevision"},45295:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetTag=void 0;const r=i(55046);class s extends r.Model{$pk(){return this.assetId+":"+this.tagId}}t.AssetTag=s,s.$tableName="AssetTag",s.$uniqueColumnName="assetId,tagId",s.$useCache=!1,s.$pkColumnNames=["assetId","tagId"]},61204:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeMonthTag=t.normalizeDateTags=t.getMonthTags=void 0;const r=i(19851),s=i(50213),n=i(97352),a=i(75020),o=i(4407),l=i(48723),u=`'${a.TagRoots.When}' || char(31) || '%' || char(31) || '%' || char(31)`,c=u+" || '%' || char(31)",d=(0,r.lazy)((()=>(0,s.mkLogger)("model.DateTagNormalizer")));function h(){return l.Tag.ops().allf((e=>e.whereNotNull("ordinal").andWhereRaw("_path LIKE "+u+" AND _path NOT LIKE "+c).limit(2400)))}function f(e){const t=(0,n.mapGt0)(e.ordinal,(e=>(0,o.monthTagRef)((0,o.ordinalToMonth)(e))));null==t?d().warn("failed to fix tag (no monthTagRef)",{t:e}):t.name!==e.name&&(d().info("Fixing month name",{tagRef:t,tag:e}),e.changeName(t.name)),e.maybeUpsertDisplayName(t?.displayName)}t.getMonthTags=h,t.normalizeDateTags=async function(){for(const e of h())f(e)},t.normalizeMonthTag=f},31687:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Heartbeat=void 0;const r=i(38835),s=i(42659),n=i(31586),a=i(72761);class o extends a.TimestampedModel{static ping(e){return o.ops().upsertOne({name:e})}static assertPing_(e="ping-"+Date.now()){if(null==o.db())throw new Error("no library is open"+r.NoLibraryErrorFlag);try{o.ping(e);const t=o.ops().findOneBy({name:e});if(null==t||t.name!==e||(0,n.lt)(t.updatedAt,Date.now()-20*s.secondMs))throw new Error("Heartbeat row wasn't inserted")}finally{try{o.dbl.runf((t=>t.delete().where({name:e})))}catch{}}}}t.Heartbeat=o,o.$tableName="Heartbeat",o.$uniqueColumnName="name",o.$useCache=!1},95700:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runMaintenanceTasks=void 0;const r=i(19851),s=i(56038),n=i(28874),a=i(42659),o=i(41400),l=i(69032),u=i(61204),c=i(49796);t.runMaintenanceTasks=async function({force:e}={}){await d(),await(!0===e?h.refresh():h());try{await(!0===e?(0,l.forceRunTagMaintenance)():(0,l.runTagMaintenance)())}catch{}};const d=(0,r.lazy)((()=>(0,s.time)("db.normalizeDateTags",u.normalizeDateTags))),h=(0,r.lazy)((()=>(0,s.time)("db.Progress.vacuum",(()=>c.Progress.vacuum()))),2*a.hourMs);(0,o.later)((()=>{n.Settings.libraryDir.watchLater((()=>{d.unset(),h.unset()}))}))},55046:(e,t,i)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const s=i(57975),n=i(50213),a=i(7282),o=i(65211),l=i(40958),u=i(38639),c=i(45599),d=i(31586),h=i(68708),f=i(34666),m=i(54993),p=i(57038),g=i(94448),y=i(33572),v=i(63872);class w{constructor(){this.$instanceId=(0,a.isTest)()?(0,o.uid)():void 0}static get $ctor(){return this.$schema+"."+this.$tableName}static query(){return(0,p.knex)()(this.$tableName)}static queryBy(e){return this.query().where(e)}static queryOneBy(e){return this.queryBy(e)}static ops(){return this._ops??(this._ops=new v.ModelOps(this,this.db))}static get dbl(){return this.ops().dbl}static rows(){return this.ops().rows()}static truncate(){if((0,a.isProd)())throw new Error("rejecting attempt to truncate in prod");this.dbl.run("DELETE FROM "+this.$tableName)}static ucn(e){const t=this.$uniqueColumnName.split(",").map((t=>e[t]));return t.some((e=>null==e))?void 0:1===t.length?t[0]:t.join(",")}static hasId(e){return this.$pkColumnNames.every((t=>null!=e[t]))}static pickId(e){return(0,h.pick)(e,...this.$pkColumnNames)}$ops(){return this.class().ops()}class(){return this.constructor}$pk(){return(0,m.toS)(this.id)}$ucn(){return this.class().ucn(this)}$tableName(){return this.class().$tableName}$uid(){return`${this.$tableName()}(${this.id??this.$ucn()})${!0===this.shown?"!":""}`}logger(){return(0,n.mkLogger)(this.class().$schema+"."+(0,m.toS)(this.valueOf()))}[s.inspect.custom](){return{...this.$toShallowJSON(),$instanceId:this.$instanceId}}toString(){return this.$uid()}valueOf(){return this.$uid()}static fromJSON(e){return(0,y.fromJSON)(this,e)}static toJSON(e){return this.fromJSON(e).toJSON()}$toShallowJSON(){return this.$_toJSON({encodeBool:u.isTrue})}$toDbJSON(e){return this.$_toJSON({encodeBool:u.boolToInt,includeCtor:!1,includeTransient:!1,colNames:e})}$clone(){return(0,y.fromJSON)(this.class(),this.toJSON())}toJSON(){return this.$_toJSON({encodeBool:u.isTrue})}_get(e,t,i=!0){const r=this[e];return null===r?[e,null]:!(0,f.isPrimitive)(r)||!i&&(0,l.includes)(this.class().$transientFields,e)?void 0:(0,l.includes)(this.class().$booleanFields,e)?[e,t(r)]:[e,r]}$_toJSON({encodeBool:e,includeCtor:t=!0,includeTransient:i=!0,colNames:r}){const s=this.class(),n=(0,l.notEmptyOr)(r,s.ops().columnNames());return(0,h.fromEntries)(n.map((t=>this._get(t,e,i))),t?{$ctor:s.$ctor}:{})}insert(){return this.logger().debug("insert()",{self:this.toJSON()}),this.class().ops().insertOne(this)}update(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("update()",{self:this.toJSON()}),this.class().ops().updateOne(this)}upsert(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("upsert()",{self:this.toJSON(),arg:e}),this.class().ops().upsertOne(this)}$afterInsert(){}$beforeUpsert(){}$afterUpsert(){}reload(){return this.class().ops().reloadOne(this)}delete(){(0,d.gt0)(this.id)&&this.class().ops().delete([this.id])}}t.Model=w,r=w,w.$schema="models",w.$logger=(0,c.defer)((()=>(0,n.mkLogger)(r.$schema+"."+r.$tableName))),w.db=g.modelDb,w.$pkColumnNames=["id"]},94448:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryModelDbFile=t.modelDb=void 0;const r=i(15056),s=i(87290),n=i(19851),a=i(55835);t.modelDb=(0,n.lazy)((()=>{})),t.libraryModelDbFile=function(e){return(0,a.map)((0,s.libraryDataDirPosixFile)(e),(e=>(0,r.pathToDb)(e,"models")))}},33572:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toJSON=t.assignFromJSON=t.fromJSON=t.addModelClass=void 0;const r=i(50213),s=i(40958),n=i(22573),a=i(38639),o=i(97790),l=i(51926),u=new Map;function c(e){u.set(e.$ctor,e)}function d(e,t,i=[]){const r=e.class();for(const[n,o]of Object.entries(t)){if("$ctor"===n)continue;if(void 0===o)continue;const t=(0,l.stripPrefixes)(n,i);e[t]=null==o?o:(0,s.includes)(r.$booleanFields,t)?(0,a.isTrue)(o):o}return e}t.addModelClass=c,t.fromJSON=function(e,t){if(null==t)throw new Error("json is null");if(null!=e&&(0,n.notBlank)(e.$ctor)&&!u.has(e.$ctor)&&c(e),t instanceof e)return t;const i=(0,o.opt)(t.$ctor).flatMap((e=>u.get(e))).getOrElse((()=>e));if(t instanceof i)return t;const r=new i;return null==t?r:d(r,t,(0,s.uniq)([e.$tableName+".",i.$tableName+"."]))},t.assignFromJSON=d,t.toJSON=function e(t,i,s){if(null!=t)return Array.isArray(t)?t.map(((t,r)=>e(t,i,`${s}[${r}]`))):"function"==typeof t.toJSON?t.toJSON():void(0,r.mkLogger)("ModelJSON.toJSON()").warn("Failed",{m:t,key:s,mc:i.$ctor})}},63872:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ModelOps=void 0;const f=i(48884),m=i(19851),p=i(50213),g=i(81168),y=i(48299),v=i(12943),w=i(38835),b=i(34102),S=i(28874),P=i(40958),_=i(76790),M=i(22573),T=i(50357),E=i(96249),k=i(98553),D=i(55835),x=i(31586),C=i(68708),F=i(59455),A=i(86859),I=i(33572);t.ModelOps=class{constructor(e,t){r.add(this),this.model=e,this.db=t,s.set(this,void 0),n.set(this,!0),a.set(this,new y.WeakCache),o.set(this,new Set),this.columnNames=(0,m.lazy)((()=>this.db().tableInfo_().find((e=>(0,g.equalsIgnoreCase)(e.tableName,this.tableName))).columns.map((e=>e.name)))),this.updatableColumnNames=(0,m.lazy)((()=>(0,P.diff)(this.columnNames(),this.immutableColumnNames))),this.ucnFieldNames=(0,m.lazy)((()=>this.ucn.split(","))),d(this,s,(0,p.mkLogger)(`ModelOps(${e.$tableName})`),"f"),(0,I.addModelClass)(e),d(this,n,e.$useCache??!0,"f"),this.dbl=new A.DbRequest(this.db,e.$tableName),(0,b.ee)().on("clearCache",(()=>h(this,a,"f").clear())),(0,b.ee)().on("clearDbCache",(()=>h(this,a,"f").clear()))}clearDbCache(){h(this,a,"f").clear()}get $cache(){return h(this,a,"f")}$cachedByJson(e){if(null==e||!h(this,n,"f"))return;const t=this.$pickModelUcn(e);return(null==t?void 0:h(this,a,"f").get((0,k.stringify)(t)))??this.$cachedById(e.id)}$cachedById(e){return(0,x.gt0)(e)&&h(this,n,"f")?h(this,a,"f").get((0,k.stringify)(e))??h(this,a,"f").findEntry((t=>t.id===e)):void 0}get dbOpen(){return(0,D.mapOr)(this.db(),(e=>e.isOpen),(()=>!1))}get tableName(){return this.model.$tableName}query(){return this.model.query()}toDbValued(e){const t=this.model.fromJSON(e),i=(0,v.toDbValued)(t);return(0,C.pick)(i,...this.columnNames())}run(e){return this.dbl.run(e)}fromJSON(e){if((0,C.isEmptyObj)(e))return;const t=this.model.fromJSON(e);return h(this,r,"m",u).call(this,t)}fromJSONs(e){return(0,P.compact)(e.map((e=>this.fromJSON(e))))}first(e){return this.fromJSON(this.dbl.first(e))}firstf(e){return this.first(e(this.query()))}all(e=this.query()){return this.fromJSONs(this.dbl.all(e))}allf(e){return this.all(e(this.query()))}findOne(e){return this.fromJSON(this.dbl.first(e))}findOneBy(e){return this.findOne(this.model.query().where(e))}findById(e,t){return this.findOneBy({...t,id:e})}findByIds(e){e=(0,F.toA)(e).filter(x.gt0);const t=[],i=[];for(const r of e){const e=this.$cachedById(r);null!=e?t.push(e):i.push(r)}const r=(0,f.batches)(i,S.Settings.dbBatchSelectSize.valueOrDefault).map((e=>this.dbl.all(this.query().whereIn("id",e))));return(0,_.sortBy)([...t,...this.fromJSONs((0,E.flatten)(r))],(t=>e.indexOf(t.id)))}findBy(e){return this.all(this.model.queryBy(e))}findWhereIn(e,t){return this.all(this.model.query().whereIn(e,t))}rows(e){return this.count(e??this.model.query().count())}count(e){return(0,x.toGt0)(this.dbl.pluckFirst(e))??0}countf(e){return this.count(e(this.query()))}insert(e){return(0,F.toA)(e).map((e=>this.insertOne(e)))}upsertOne(e){return this.modelSupportsUpsert?this.upsert([e])[0]:this.insertOrUpdateOne(e)}insertOrUpdateOne(e){return null==e.id?this.insertOne(e):this.updateOne(e)}insertOne(e){if(this.model.hasId(e))throw new Error("insert called for "+(0,k.stringify)(e)+w.NonRetriableErrorFlag);const t=this.fromJSON(e);if(null==t)return h(this,s,"f").throw("insertOne(): fromJSON returned null"+w.InternalErrorFlag,{t:e});t instanceof this.model&&h(this,r,"m",u).call(this,t),t.$beforeUpsert();const i=t.$toDbJSON(this.columnNames()),n=this.dbl.runf((e=>e.insert(i)));return t.id=(0,x.toInt)(n.lastInsertRowid),t.$afterInsert(),t.$afterUpsert(),t}unsetField(e,t){return(0,D.map)(this.$cachedById(e),(e=>{e[t]=null})),this.dbl.runf((i=>i.where({id:e}).update(t,null)))}updateOne(e){if(null==e.id)throw new Error("update called for "+(0,k.stringify)(e)+w.NonRetriableErrorFlag+w.InternalErrorFlag);const t=this.model.fromJSON(e);t.$beforeUpsert();const i=t.$toDbJSON(this.updatableColumnNames());return this.dbl.runf((t=>t.where({id:e.id}).update(i))),t.$afterUpsert(),h(this,r,"m",u).call(this,t)??t}get ucn(){return(0,M.toNotBlank)(this.model.$uniqueColumnName)??"id"}get modelSupportsUpsert(){return null!=this.ucn&&"id"!==this.ucn}get ucnConstraint(){return`(${this.ucn})`}get immutableColumnNames(){return(0,P.uniq)([...this.ucnFieldNames(),"id","createdAt"])}onConflictClause(e){const t=this.immutableColumnNames,i=e.filter((e=>!t.includes(e))).sort().map((e=>`${e}=excluded.${e}`)).join(","),r=["ON CONFLICT",this.ucnConstraint];return(0,M.blank)(i)?r.push("DO NOTHING"):r.push("DO UPDATE SET",i),r.join(" ")}$pickModelUcn(e){const t={};for(const i of this.ucnFieldNames()){const r=e[i];if(null==r)return;t[i]=r}return t}reloadOne(e){if(h(this,o,"f").has(e.id))return;const t=this.$pickModelUcn(e);if(null!=t){const i=h(this,r,"m",u).call(this,e),s=this.findOneBy(t);if(null==s)return;return h(this,r,"m",l).call(this,i,s),i!==e&&h(this,r,"m",l).call(this,e,i),i}h(this,s,"f").warn(".reloadOne(): failed to reload "+(0,k.stringify)(e))}reload(e){const t=[],i=this.allf((i=>{for(const r of e){const e=this.model.hasId(r)?this.model.pickId(r):this.$pickModelUcn(r);null!=e?(t.push([r,e]),i=i.orWhere(e)):h(this,s,"f").warn("reload(): given insufficient partial model",{fragment:r})}return i})),n=[];for(const[e,a]of t){const t=i.find((e=>(0,T.eqlSubset)(a,e)));if(null==t)h(this,s,"f").warn("reload(): failed to find result in db",{prior:e,dbArr:i});else{const i=h(this,r,"m",u).call(this,e);h(this,r,"m",l).call(this,i,t),i!==e&&h(this,r,"m",l).call(this,i,t),n.push(t)}}return n}upsert(e){if(e=(0,P.compact)(e),!this.modelSupportsUpsert)return e.map((e=>this.insertOrUpdateOne(e)));const t=this.columnNames(),i=[];for(const s of(0,f.batches)((0,F.toA)(e),S.Settings.dbBatchUpsertSize.valueOrDefault)){const e=new Map,n=new Set,a=(0,P.compact)(s.map((e=>this.fromJSON(e))));for(const t of a){const i=(0,k.stringify)(this.$pickModelUcn(t));e.set(i,t),this.model.hasId(t)||n.add(i),t.$beforeUpsert()}h(this,r,"m",c).call(this,a.map((e=>e.$toDbJSON(t))));const o=this.reload(a),l=new Map(o.map((e=>[(0,k.stringify)(this.$pickModelUcn(e)),e])));for(const e of a){const t=(0,k.stringify)(this.$pickModelUcn(e)),r=l.get(t)??e;n.has(t)&&r.$afterInsert(),r.$afterUpsert(),i.push(r)}}return i}delete(e){const t=(0,F.toA)(e).filter(x.gt0);for(const e of t)h(this,o,"f").add(e);return h(this,a,"f").deleteValueIf((e=>t.includes(e.id))),this.run(this.model.query().delete().whereIn("id",t))}async batched(e){const t=e.batchSize??S.Settings.dbBatchSelectSize.valueOrDefault;let i,r;do{i=this.allf((i=>(i=e.qb(i),null!=r&&(i=i.andWhere("id",">",r)),i.orderBy("id","asc").limit(t)))),(0,P.isNotEmpty)(i)&&(r=Math.max(...i.map((e=>e.id))),await e.onResults(i))}while((0,P.isNotEmpty)(i))}},s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function(e,t){(0,C.assignFields)(e,t,{omitKeys:["$instanceId"],assignNullish:!0})},u=function(e){if(h(this,n,"f")){const t=this.$cachedByJson(e);if(null!=t)return h(this,r,"m",l).call(this,t,e),t;{const t=this.$pickModelUcn(e)??e.id;null!=t&&h(this,a,"f").set((0,k.stringify)(t),e)}}return e},c=function(e){const t=this.query().insert(e).toSQL(),i=new Set;for(const t of e)for(const e of(0,C.keys)(t))i.add(e);const s={sql:t.sql+" "+this.onConflictClause([...i.values()]),bindings:t.bindings};this.run(s);for(const t of e){const e=this.$cachedByJson(t);null!=e&&h(this,r,"m",l).call(this,e,this.model.fromJSON(t))}}},20958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Operation=t.OperationNames=void 0;const r=i(19851),s=i(50213),n=i(88158),a=i(99331),o=i(70025),l=i(8769),u=i(22573),c=i(98553),d=i(50989),h=i(72761);t.OperationNames=(0,d.strEnum)("rebuildLibrary","forceRestartSync");const f=(0,r.lazy)((()=>(0,s.mkLogger)("model.Operation")));class m extends h.TimestampedModel{static incomplete(){return this.ops().allf((e=>e.whereIn("id",(e=>e.table(m.$tableName).min("id").whereNull("completedAt")))))}static ensurePendingOp(e){return m.getFirstPendingOp(e)??m.ops().insertOne(e)}static getFirstPendingOp(e){return f().tap({msg:"getFirstPendingOp",level:"info",result:this.ops().firstf((t=>{const i=t.whereNull("completedAt").orderBy("createdAt","asc");return null!=e?i.andWhere(e):i})),meta:{crit:e}})}static markOpCompleted(e,t){return(0,u.blank)(e?.name)?f().throw("markOpCompleted(): bad query",{crit:e}):this.dbl.runf((i=>i.whereNull("completedAt").andWhere(e).update({completedAt:Date.now(),...t})))}static async applyIfPending(e,t){const i=this.ops().firstf((t=>t.whereNull("completedAt").andWhere(e)));return f().info("applyIfPending()",{crit:e,op:i}),null==i?void 0:t(i)}static async applyOnce_(e,t,i=n.identity){const r=this.ops().firstf((t=>i(t.whereNotNull("completedAt").andWhere(e))));if(null!=r)return void f().debug("applyOnce(): already done",{priorCompleted:r});const s=this.ops().insertOne(e);try{const e=await t(s);return(0,a.ending)()||s.markCompleted(),e}catch(t){if((0,o.isRedoableError)(t))return void f().info("applyOnce(): redoable error",{crit:e,error:t});throw(0,l.onError)("Operation.applyOnce(): "+(0,c.stringify)(e),t),t}}markCompleted(){null==this.completedAt&&(this.completedAt=Date.now(),this.upsert())}}t.Operation=m,m.$tableName="Operation",m.$uniqueColumnName="id",m.$useCache=!1},49796:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Progress=t.defaultMinCreatedAt=t.toPct=void 0;const r=i(48161),s=i(1708),n=i(48884),a=i(50213),o=i(28874),l=i(40958),u=i(42659),c=i(45599),d=i(98553),h=i(55835),f=i(31586),m=i(68708),p=i(67478),g=i(51926),y=i(59455),v=i(54993),w=i(76386),b=i(33572),S=i(55009),P=i(72761),_=(0,c.defer)((()=>(0,a.mkLogger)("model.Progress")));function M(e){return null==e||!(0,f.isNumber)(e)||e<0||e>100?void 0:(0,f.sigFigs)(e,3)}t.toPct=M;const T=(0,g.compressWhitespace)("\nSELECT\n p1.uri,\n p1.id as lastProgressId,\n p1.createdAt as lastStartedAt,\n p1.updatedAt as lastUpdatedAt,\n p3.lastCompletedAt\nFROM\n Progress AS p1\n JOIN (\n SELECT\n uri,\n max(updatedAt) AS lastUpdatedAt\n FROM\n Progress\n GROUP BY\n 1\n ) AS p2 ON p1.uri = p2.uri\n AND p1.updatedAt = p2.lastUpdatedAt\n LEFT JOIN (\n SELECT\n uri,\n max(completedAt) AS lastCompletedAt\n FROM\n Progress\n WHERE\n CAST(completedAt AS int) > 0\n GROUP BY\n 1\n ) AS p3 ON p1.uri = p3.uri\nGROUP BY\n p1.uri");function E(){const e=o.Settings.progressStaleDays.valueOrDefault;return e<=0?0:Date.now()-e*u.dayMs}t.defaultMinCreatedAt=E;class k extends P.TimestampedModel{static vacuum(e=o.Settings.progressRetentionDays.valueOrDefault*u.dayMs){const t=Date.now()-e,i=this.dbl.pluckAllf((e=>e.select("id").where("createdAt","<=",t)));for(const e of(0,n.batches)(i,o.Settings.dbBatchSelectSize.valueOrDefault))S.ProgressMeta.dbl.runf((t=>t.whereIn("progressId",e).delete())),k.dbl.runf((t=>t.whereIn("id",e).delete()))}static countCompletedDirectorySyncs(){return this.dbl.pluckFirstf((e=>e.where({state:"done"}).whereNotNull("completedAt").where("uri","like","ps%")))}static times(){return _().tap({msg:"times()",result:this.dbl.all({sql:T})})}static insertNew(e){const t=(0,h.map)(e.dek,d.stringify);return this.ops().insertOne({...(0,m.omit)(e,"dek"),dekJSON:t})}upsert(e){return null!=e&&this.assignFromPojo(e),super.upsert()}$beforeUpsert(){super.$beforeUpsert(),null==this.id&&(this.pid??(this.pid=s.pid),this.hostname??(this.hostname=(0,r.hostname)())),"done"===this.state&&(this.completedAt??(this.completedAt=Date.now())),this.completePct=M(this.completePct),this.incompletePct=M(this.incompletePct),this.scanningPct=M(this.scanningPct)}$afterUpsert(){super.$afterUpsert(),(0,w.tellWebProgressUpdated)()}toSyncState(){return{id:this.id,uri:this.uri,volume:this.volume,state:this.state,hed:this.hed,dek:this.dek,completePct:this.completePct,incompletePct:this.incompletePct,scanningPct:this.scanningPct}}get dek(){return(0,l.compactBlanks)((0,p.parseJSON)(this.dekJSON))}set dek(e){var t;this.dekJSON=(t=e,(0,d.stringify)((0,l.compactBlanks)((0,y.toA)(t))))}assignFromPojo(e){return(0,b.assignFromJSON)(this,(0,m.omit)(e,"volume","uri"))}getMeta(){return S.ProgressMeta.ops().allf((e=>e.where({progressId:this.id}).orderBy("createdAt")))}getPriorIncomplete(e=E()){return this.logger().tap({msg:"priorIncompleteProgress()",result:k.ops().firstf((t=>t.where({hostname:this.hostname,uri:this.uri,completedAt:null}).andWhere("createdAt",">",e).orderBy("updatedAt","desc")))})}getLastCompletedAt(e=E()){return k.dbl.pluckFirstf((t=>t.max("completedAt").where({uri:this.uri}).andWhere("createdAt",">",e)))}getLastIncompleteStartAt(){return k.dbl.pluckFirstf((e=>e.min("createdAt").where({uri:this.uri}).andWhere("createdAt",">",this.getLastCompletedAt()??0)))}setMeta(e,t){return this.logger().debug("setMeta()",{progressId:this.id,name:e,value:t}),S.ProgressMeta.ops().upsertOne({progressId:this.id,name:e,value:t})}setMetaRecord(e){const t=this.getMeta(),i=(0,l.diff)(t.map((e=>e.name)),Object.keys(e));this.logger().debug("setMetaRecord()",{progressId:this.id,keysToDelete:i,record:e}),S.ProgressMeta.ops().upsert((0,m.entries)(e).map((([e,t])=>({progressId:this.id,name:e,value:(0,v.toS)(t)})))),(0,l.isNotEmpty)(i)&&S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).whereIn("name",i).delete()))}deleteMeta(...e){return this.logger().debug("deleteMeta()",{progressId:this.id,names:e}),S.ProgressMeta.dbl.runf((t=>t.whereIn("name",e).andWhere({progressId:this.id}).delete()))}deleteAllMeta(){return this.logger().debug("deleteAllMeta()",{progressId:this.id}),S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).delete()))}getMetaAsRecord(){return this.logger().tap({msg:"getMetaAsRecord()",result:(0,m.fromEntries)(this.getMeta().map((e=>[e.name,e.value])))??{}})}}t.Progress=k,k.$tableName="Progress",k.$uniqueColumnName="id"},55009:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressMeta=t.ProgressMetaNames=t.DirSyncProgressMetaNames=void 0;const r=i(50989),s=i(72761);t.DirSyncProgressMetaNames=(0,r.strEnum)("lastScannedDirectory","scannedDirectoryCount","completedDirectoryScan","enqueuedStaleFiles","processedImageCount","processedVideoCount","completedDirectorySync"),t.ProgressMetaNames=(0,r.strEnum)(...t.DirSyncProgressMetaNames.values);class n extends s.TimestampedModel{}t.ProgressMeta=n,n.$tableName="ProgressMeta",n.$uniqueColumnName="progressId,name"},39604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.upsertToShaBlockslist=t.upsertFileToShaBlockslist=t.isShaBlockslisted=t.notBlocklistedSha=void 0;const r=i(19851),s=i(50213),n=i(95696),a=i(40958),o=i(22573),l=i(86859),u=i(94448),c=(0,r.lazy)((()=>(0,s.mkLogger)("model.ShaBlocklist"))),d=(0,r.lazy)((()=>new l.DbRequest(u.modelDb,"ShaBlocklist")));function h(e){return null!=(0,u.modelDb)()&&!(0,o.blank)(e)&&c().tap({msg:"isShaBlockslisted",result:null!=d().pluckFirstf((t=>t.where({sha:e}).limit(1))),meta:{sha:e}})}function f(...e){if(null==u.modelDb.prior())return;const t=(0,a.uniq)(e).map((e=>({sha:e})));return(0,a.isEmpty)(t)?void 0:d().upsert((e=>e.insert(t)))}t.notBlocklistedSha=async function(e){if(null==(0,u.modelDb)())return null;const t=h(await n.PosixFile.for(e).sha());return null==t?null:!t},t.isShaBlockslisted=h,t.upsertFileToShaBlockslist=async function(e){if(null==(0,u.modelDb)())return;const t=await n.PosixFile.for(e).sha();return null==t?void 0:f(t)},t.upsertToShaBlockslist=f},48723:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Tag=t.UpdateTagAssetCountTimeName=void 0;const a=i(56038),o=i(34102),l=i(19851),u=i(50213),c=i(36372),d=i(97352),h=i(28874),f=i(81168),m=i(42231),p=i(75020),g=i(40958),y=i(22573),v=i(42659),w=i(41400),b=i(50357),S=i(55835),P=i(31586),_=i(34666),M=i(20214),T=i(51926),E=i(59455),k=i(12168),D=i(6186),x=i(57038),C=i(21074),F=i(7656),A=i(43487),I=i(48722),O=i(45295),L=i(98784),R=i(41507),N=i(72761),B=4*v.secondMs,j=(0,l.lazy)((()=>(0,u.mkLogger)("model.Tag")));(0,w.later)((()=>{(0,o.ee)().on("clearCache",(()=>z.clear())),(0,o.ee)().on("clearDbCache",(()=>z.clear()))})),t.UpdateTagAssetCountTimeName="db.updateTagAssetCountTimeName";class z extends N.TimestampedModel{constructor(){super(...arguments),this.displayPath=(0,l.lazy)((()=>{const e=this.getParent();return(0,g.compactBlanks)([...null==e?[]:e.displayPath(),this.displayName])})),this.ancestorIds=(0,l.lazy)((()=>0===this.parentId||null==this.parentId?[]:r.dbl.pluckAll({sql:(0,T.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.id","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}}))),this.firstNonInterstitialTagId=(0,l.lazy)((()=>{if(!this.isRoot&&0===this.directAssetCount()&&1===this.getChildrenCount()){const e=this.getChildren();if(1===e?.length)return e[0].firstNonInterstitialTagId()}return this.id})),this.directAssetCount=(0,l.lazy)((()=>0===this.id?0:A.Asset.dbl.pluckFirst(A.Asset.shownUnhidden().join("AssetTag","AssetTag.assetId","Asset.id").where("AssetTag.tagId",this.id).countDistinct("Asset.id"))))}static orderBy(e){return e.orderByRaw("COALESCE(ordinal, _path) COLLATE NOCASE")}static clear(){this.root.unset(),this.roots.unset(),this._upsertDefaultRoots.unset(),this.ops().clearDbCache()}static validate_(){return(0,a.timeSync)("Tag.validate_",(()=>{r.clear();for(const e of this.ops().allf((e=>e.whereRaw("id = parentId")))){j().warn(`Tag ${e.id} has itself as parentId. Attempting to fix...`);const t=e.path.slice(0,-1),i=(0,g.isEmpty)(t)?void 0:this.findOrCreate(t);e.update({parentId:i?.id??null})}for(const e of r.roots())e.validate_([])}))}validate_(e){const t=this.path;if(!(0,b.eql)(t.slice(0,-1),e))throw new Error(`Tag:${this.id} path ${t.join("/")} does not match expected parent ${e.join("/")}`);for(const e of this.getChildren())e.validate_(t)}static deltaAssetCountAndAncestors(e,t=1){return r.incrAssetCount(r.selfAndAncestorIds(e),t)}static incrAssetCount(e,t=1){(0,g.isEmpty)(e)||r.dbl.runf((i=>i.whereIn("id",e).andWhereNot({assetCount:null}).update({assetCount:(0,x.knex)().raw("assetCount + "+Math.round(t)),updatedAt:Date.now()})))}static selfAndAncestorIds(e){const t=(0,E.toA)(e).filter(P.gt0);return r.dbl.pluckAll({sql:(0,T.compressWhitespace)("WITH RECURSIVE ancestors(id) AS ("," SELECT id FROM Tag where id in "+(0,C.sqlWhereInClause)(t.length)," UNION ALL"," SELECT Tag.parentId as id"," FROM Tag, ancestors"," WHERE Tag.id = ancestors.id",")","SELECT distinct(id)","FROM ancestors","WHERE id IS NOT NULL"),bindings:t})}static updateAssetCount(e){if((0,P.gt0)(e))return(0,a.timeSync)(t.UpdateTagAssetCountTimeName,(()=>{const t=r.dbl.pluckFirst({sql:F.RecursiveAssetCountForTagQuery,bindings:{tagId:e}});r.dbl.runf((i=>i.update({assetCount:t,updatedAt:Date.now()}).where({id:e}))),j().debug("Updated asset counts for tag ",{tagId:e,assetCount:t})}))}static findByIdOrPath(e,t){return 0===e?r.root():(0,P.gt0)(e)?this.findById(e):this.findByPath(t)}static findById(e){return 0===e?r.root():this.ops().findById(e)}static findByPath(e){if((0,g.isEmpty)(e))return r.root();const t=(0,m.joinTagPath)(e);return this.ops().firstf((e=>e.whereLike("_path",t)))}static findByPathN(e){const t=(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,y.toNotBlank)((0,m.joinTagPath)(e))));return(0,g.compact)(t.map((e=>this.findByPath(e))))}static getPagedAssets(e,t){const i=new r;return i.id=e,i.getPagedAssetIds(t)}static findOrCreate(e){if((0,g.isEmpty)(e))throw new Error("empty tagPath");const t=this.findByPath(e);if(null!=t)return t;const i=n(this,r,"m",s).call(this,e),a=i.depth<=1?void 0:this.findOrCreate(e.slice(0,-1));return(0,S.map)(a,(e=>i.parentId=e.id)),this.ops().upsertOne(i)}static findOrCreateByPathN(e){return(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,m.joinTagPath)(e))).map((e=>this.findOrCreate(e)))}clear(){return this.parent=void 0,this.root=void 0,this.children=void 0,this.ancestors=void 0,this.assets=void 0,this.relatedAssets=void 0,this.ancestorIds.unset(),this}$afterInsert(){L.TagFts.insertFts([this])}siblingPath(e){return(0,m.joinTagPath)([...this.parentPath,e])}changeName(e){return this.changePath(this.siblingPath(e))}maybeUpsertDisplayName(e){return(0,y.blank)(e)||e===this._displayName?void 0:this.upsert({_displayName:e})}changePath(e,t=!0){const i=this._path,s=r.findByPath((0,m.splitTagPath)(e));this.logger().info("changePath(): ",{priorPath:i,newPath:e,existingSibling:s});try{if(null==s)r.dbl.runf((t=>t.whereLike("_path",i+"%").update({updatedAt:Date.now(),_path:(0,x.knex)().raw("REPLACE(_path, ?, ?)",[i,e])}))),this._path=e;else{e=s._path,this.logger().info("changePath(): replacing with sibling",e),O.AssetTag.dbl.upsert((e=>e.where({tagId:this.id}).update({tagId:s.id}))),O.AssetTag.dbl.runf((e=>e.where({tagId:this.id}).delete()));for(const e of this.getChildren())e.changePath((0,m.joinTagPath)([...s.path,e.name]),!1);r.dbl.runf((e=>e.where({parentId:this.id}).update({parentId:s.id}))),this.delete()}}finally{t&&r.clear()}}get name(){const e=this.path;return e[e.length-1]}get path(){return(0,m.splitTagPath)(this._path)}get displayName(){return(0,y.toNotBlank)(this._displayName)??this.name}get isRoot(){return 0===this.id}get depth(){return this.path.length}get parentPath(){return this.path.slice(0,-1)}get sortBy(){return[this.depth,null==this.ordinal?2**51:this.ordinal,this.path.map((e=>e.toLowerCase()))]}$childrenQuery(){return r.orderBy(r.query().where({parentId:this.id}))}$assetsQuery(){return A.Asset.shownUnhidden().columns("Asset.*").join("AssetTag","AssetTag.assetId","Asset.id").where({tagId:this.id})}$selectAssetIdColumns(e){return e.clearSelect().select({assetId:"Asset.id",capturedAtLocal:"Asset.capturedAtLocal",updateCount:"Asset.updateCount",durationMs:"Asset.durationMs"})}$assetIdsQuery(){return this.$selectAssetIdColumns(this.$assetsQuery())}setAncestors(e){this.ancestors=e,this.parent=e[e.length-1],(0,S.map)(this.parent,(t=>t.setAncestors(e.slice(0,-1))))}async toApiPathElements(){return(0,M.thenCollect)(this.getAncestorsAndSelf(),(e=>e.toPathTag()))}toPathTag(){return{tagPath:this.path,displayName:this.displayName}}toApiTag(){return{tagId:this.id,tagPath:this.path,displayPath:this.displayPath(),description:this.description,assetCount:this.assetCount}}toStringId(){return"Tag("+this.path.join("/")+")"}getParent(){if(!this.isRoot)return null!=this.parentId&&null==this.parent?this.parent=r.findById(this.parentId):this.parent}getPagedChildren(e){if(0===this.id){const t=e.offset??0,i=t+(e.limit??this.children.length);return[...this.children].slice(t,i)}const t=this.$childrenQuery();return(0,d.mapGt0)(e.offset,(e=>{t.offset(e)})),(0,d.mapGt0)(e.limit,(e=>{t.limit(e)})),r.ops().all(t)}getChildrenCount(){return null!=this.children?this.children.length:r.dbl.pluckFirstf((e=>(this.isRoot?e.whereNull("parentId"):e.where({parentId:this.id})).count()))}getChildren(){return this.isRoot||(this.children=r.ops().all(this.$childrenQuery()),this.children.forEach((e=>{e.parent=this}))),this.children}link(){return"/tag/"+this.path.map(encodeURIComponent).join("/")}get rootName(){return this.path[0]}get ancestorsAndSelf(){return[...this.ancestors,this]}getAncestors(){return this.ancestors??(this.ancestors=this._getAncestors())}getAncestorsAndSelf(){return[...this.getAncestors(),this]}_getAncestors(){return 0===this.parentId||null==this.parentId?[]:r.ops().all({sql:(0,T.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.*","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}})}getPagedAssetIds(e){let t=this.$assetIdsQuery();return t=t.limit(p.ThumbsPerSample),(0,P.gt0)(e.offset)&&(t=t.offset(e.offset)),t=t.orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId"}]),(0,g.compact)(A.Asset.dbl.all(t).map(I.toAssetId))}getAssets(){const e=this.$assetsQuery().orderBy("capturedAtLocal","desc");return A.Asset.ops().all(e)}async assetCountDesc(e){const t=this.assetCount;return(null==t||null==e||e.length===t||0===e.length?"":(0,k.fmt)(e.length)+" of ")+(0,k.plur)(t,"asset")}getAssetCount(){return 0===this.id?r.dbl.pluckFirst({sql:(0,T.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," Asset","WHERE"," Asset.shown = 1"," AND Asset.excluded = 0"," AND Asset.hidden = 0"," AND Asset.deletedAt IS NULL")}):r.dbl.pluckFirst({sql:F.RecursiveAssetCountForTagQuery,bindings:{tagId:this.id}})}$assetStreamQuery(e,t,i){let r=this.path[0]===p.TagRoots.When?A.Asset.shownUnhidden():this.$assetsQuery();return r=r.distinct().where("capturedAtLocal",i,e.capturedAtLocal).andWhereNot("Asset.id",e.id).limit("="===i?2*t:t),"="===i?r.orderByRaw(`ABS(Asset.id-${e.id})`):r.orderBy([{column:"capturedAtLocal",order:">"===i?"asc":"desc"},"Asset.id"])}getAssetStream(e,t){t=(0,P.gt0)(t)?t:p.BeforeAfterStreamLimit;const[i,r,s]=["<","=",">"].map((i=>(0,g.compact)(A.Asset.ops().all(this.$assetStreamQuery(e,t,i)).map(I.toAssetId))));for(const t of r)t.assetIdA.Asset.shownUnhidden(this.$selectAssetIdColumns(r)).distinct().join("Asset","Asset.id","AssetTag.assetId").join("Tag","Tag.id","AssetTag.tagId").whereLike("_path",this._path+"%").orderByRaw((0,c.prngOrderByClause)(e+(this.id??0),"Asset.id",i)).limit(t))).map(I.toAssetId));return this.logger().debug(this.path+": Found "+r.length+" related assets"),r}get attrs(){return{href:this.link(),title:this.name}}}t.Tag=z,r=z,s=function(e){const t=new r;t._path=(0,m.joinTagPath)(e);const i=e[e.length-1];return"object"==typeof i&&((0,y.mapNotBlank)(i.displayName,(e=>t._displayName=e)),(0,P.mapNumeric)(i.ordinal,(e=>t.ordinal=e)),(0,y.mapNotBlank)(i.description,(e=>t.description=e)),(0,P.mapNumeric)(i.releasedAt,(e=>t.releasedAt=e))),t},z.$tableName="Tag",z.$uniqueColumnName="_path",z.$useCache=!0,z.cmp=(e,t)=>(0,_.cmp)([e.ordinal??Number.MAX_SAFE_INTEGER,...e.path],[t.ordinal??Number.MAX_SAFE_INTEGER,...t.path]),z.root=(0,l.lazy)((()=>{const e=new r;return e.id=0,e._path=m.TagSep,e.parentId=void 0,e.children=r.roots().filter((e=>!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.name)&&!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.description??""))),e.ancestors=[],e.assetCount=A.Asset.shownCount(),e.upsert=()=>{throw new Error("upsert not supported on root")},e}),B),z._upsertDefaultRoots=(0,l.lazy)((()=>r.ops().upsert(D.Roots.map((e=>({_path:(0,m.joinTagPath)([e.name]),ordinal:e.ordinal})))))),z.roots=(0,l.lazy)((()=>{r._upsertDefaultRoots();const e=r.ops().all(r.orderBy(r.query().whereNull("parentId")));for(const t of e)t.parentId=void 0,t.ancestors=[];return e}),B);const V=(0,l.lazy)((()=>A.Asset.dbl.pluckFirstf((e=>e.count()))),v.minuteMs)},98784:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagFts=void 0;const r=i(38156),s=i(3127),n=i(40958),a=i(41400),o=i(94715),l=i(55046),u=i(48723);class c extends l.Model{static insertFts(e){try{const t=e.filter((e=>null!=e.parentId)).map((e=>({rowid:e.id,root:(0,s.tag_fts_root)(e._path),path:(0,s.tag_fts_path)(e._path)})));(0,n.isEmpty)(t)||this.dbl.runf((e=>e.insert(t)))}catch(e){this.$logger().warn("Failed to update tag_fts",{error:e})}}static async rebuild(){const e=new r.PushProgressObserver({op:"Rebuilding tag search index"},u.Tag.dbl.pluckFirstf((e=>e.count("*")))),t=this.dbl.db();o.Migrations.create_tag_fts(t.db),await u.Tag.ops().batched({qb:e=>e,onResults:t=>(this.$logger().throwIfAborted_(),this.insertFts(t),e.incrProgress(t.length),(0,a.delay)(1))}),e.completed()}}t.TagFts=c,c.$tableName="tag_fts",c.$uniqueColumnName="rowid",c.$booleanFields=[]},41507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.coalesceStreams=t.TaggedAssetStream=t.cmpAssetDesc=t.cmpAssetAsc=void 0;const r=i(48884),s=i(50213),n=i(28874),a=i(40958),o=i(76790),l=i(31586),u=i(34666),c=i(20214),d=i(59455);t.cmpAssetAsc=(e,t)=>(0,u.cmp)([e.capturedAtLocal,e.id],[t.capturedAtLocal,t.id]),t.cmpAssetDesc=(e,t)=>(0,u.cmp)([t.capturedAtLocal,t.id],[e.capturedAtLocal,e.id]),t.TaggedAssetStream=class{constructor(e,t,i,r){this.tags=e,this.before=t,this.after=i,this.limit=r,this.logger=()=>(0,s.mkLogger)("model.TaggedAssetStream("+this.toString()+")"),this.logger().info("new",this.toJSON())}vacuum(){(0,o.sortByInPlace)(this.before,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainFirstN)(this.before,this.limit),(0,o.sortByInPlace)(this.after,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainLastN)(this.after,this.limit)}toString(){return this.tags.map((e=>e.path.join("/"))).join(",")}valueOf(){return this.toString()}get length(){return(0,d.toA)(this.before).length+(0,d.toA)(this.after).length}leftPad(e){return[...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+1),capturedAtLocal:-1,v:0}))),...e]}rightPad(e){return[...e,...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+this.limit+1),capturedAtLocal:-1,v:0})))]}toJSON(){return{tags:this.tags.map((e=>e.toString())),assetIdsAfter:this.after,assetIdsBefore:this.before}}mergeWith(e){(0,a.pushUniqBy)(this.tags,e.tags,(e=>e.path)),(0,a.pushUniqBy)(this.before,e.before,(e=>e.assetId)),(0,a.pushUniqBy)(this.after,e.after,(e=>e.assetId)),this.logger().debug("mergeWith() complete",{tas:e.toJSON(),tags:this.tags.map((e=>e.path)),beforeIds:this.before,afterIds:this.after})}async toApi(){return this.vacuum(),this.logger().tap({msg:"toApi()",result:{tags:await(0,c.thenCollect)(this.tags,(e=>e.toApiTag())),assetIdsAfter:this.leftPad(this.after),assetIdsBefore:this.rightPad(this.before)}})}streamCoeff(e){return this.logger().tap({msg:"streamCoeff",meta:{this:this.tags.map((e=>e.path)),tas:e.tags.map((e=>e.path))},result:(0,r.diceCoeff)([...this.before,...this.after],[...e.before,...e.after],(e=>e.assetId))})}},t.coalesceStreams=function(e){const t=n.Settings.minStreamCorrPct.valueOrDefault/100,i=[],s=e.filter((e=>e.length>5));for(const e of s){const s=(0,r.greatestBy)(i,(i=>(0,l.gtOrElse)(i.streamCoeff(e),t)));null==s?i.push(e):s.mergeWith(e)}return i}},94710:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Task=t.StaleTaskError=t.InvalidTaskError=t.TaskNames=t.Tasks=t.testTask=void 0;const c=i(78474),d=i(22454),h=i(23560),f=i(12089),m=i(76740),p=i(22911),g=i(99331),y=i(31562),v=i(38835),w=i(70025),b=i(8769),S=i(74128),P=i(28874),_=i(37692),M=i(40958),T=i(22573),E=i(42659),k=i(45599),D=i(98553),x=i(49769),C=i(68708),F=i(50989),A=i(59455),I=i(58723),O=i(34274),L=i(90901),R=i(61989),N=i(93755),B=i(69032),j=i(55046);t.testTask=(0,f.shim1)({name:"testTask",impl:async e=>{}}),t.Tasks={applyDeleted:I.applyDeleted,applyExcluded:I.applyExcluded,runTagMaintenance:B.runTagMaintenance,repairAsset:async function(e){e.forceSync=!0,e.skipPreviews=!0,e.skipAssetTagging=!0;const t=await(0,R.updateAsset_)(e);return(0,M.isNotEmpty)(t?.assetIdsToUpdate)&&H.add(t?.assetIdsToUpdate.map((t=>({fn:"repairAsset",args:{...e,assetId:t},priority:W.repairAsset+1})))),null!=t&&!0!==t.deleted&&(0,T.blank)((0,A.toA)(t.rejected).join(""))&&(0,T.blank)(t.error)&&H.addOne("assetPostUpsertTasks",(0,C.omit)(e,"skipPreviews","skipAssetTagging")),t},assetPostUpsertTasks:L.assetPostUpsertTasks,updateAssetFile:N.updateAssetFile_,syncFile:O.importFileToResult_,testTask:t.testTask},t.TaskNames=(0,F.strEnum)(...(0,C.keys)(t.Tasks));class z extends Error{}t.InvalidTaskError=z;class V extends Error{}t.StaleTaskError=V;const W={applyDeleted:16,applyExcluded:16,runTagMaintenance:14,repairAsset:12,assetPostUpsertTasks:10,updateAssetFile:8,syncFile:0,testTask:-1},U=["repairAsset"];class H extends j.Model{constructor(){super(...arguments),r.add(this),o.set(this,(0,k.defer)((()=>new m.Abortable)))}static countTaskNames(){const e={};for(const t of s.dbl.allf((e=>e.select("fn").count().groupBy("fn"))))e[t.fn]=t["count(*)"];return e}static orderBy(e){return e.orderBy([{column:"priority",order:"desc"},{column:"retries",order:"desc"},{column:"id",order:"asc"}])}static count(){return s.dbl.pluckFirstf((e=>e.count("id")))}static freeSlots(){return P.Settings.taskListCap.valueOrDefault-s.count()}static countByFn(e){return s.dbl.pluckFirstf((t=>t.where({fn:e}).count("id")))}static nextByFn(e,t=(e=>e)){return s.ops().allf((i=>s.orderBy(t(i.where({fn:e})))))}set args(e){this.argsJSON=(0,D.stringify)(e)}get args(){const e=(0,D.parseJSON)(this.argsJSON);return(0,C.notEmptyObj)(e)&&(e.halt=u(this,o,"f").call(this)),e}get isSerial(){return U.includes(this.fn)}toString(){return`Task#${this.fn}(${this.argsJSON})`}static addOne(e,t){return s.add([{fn:e,args:t}])[0]}static add(e,t=!1){if((0,M.isEmpty)(e))return[];const i=s.ops().upsert(e.map((e=>({fn:e.fn,argsJSON:(0,D.stringify)(e.args)})),t));return s.ee.emit("added",i),(0,h.isTaskListManager)()||(0,_.addStateEvent)("checkTasks"),i}$beforeUpsert(){this.priority??(this.priority=W[this.fn]),this.retries??(this.retries=P.Settings.maxRetries.valueOrDefault)}donePromise(){return(0,h.isTaskListManager)()?(0,x.getOrSet)(u(s,s,"f",n),this.id,(()=>new p.Deferred(this.toString(),{payload:this}))):(0,y.untilTrue)((()=>null==s.ops().findById(this.id)),{intervalMs:E.secondMs})}abort(e){this.logger().warn("aborting task",{reason:e,task:this}),u(this,o,"f").call(this).abort(e),this.delete(),(0,T.blank)(this.args.path)||(0,S.syncReport)().onProgress({path:this.args.path,from:this.fn,state:S.SyncFileStates.failed,details:e})}async _run(){if(this.retries<0)throw this.logger().warn(".run(): too many retries"+v.InternalErrorFlag,{job:this}),this.delete(),new z;if(!u(this,r,"m",l).call(this))throw this.logger().warn(".run(): someone already started this task",{job:this}),new V;try{const e=Date.now(),i=await t.Tasks[this.fn](this.args);return this.logger().throwIfAborted_(u(this,o,"f").prior()),s.taskResolvedCounts.incr(this.fn),s.ee.emit("resolved",this,i,Date.now()-e),this.delete(),u(s,s,"f",n).get(this.id)?.resolve(i),i}catch(e){if((0,g.ending)())throw this.logger().info("task failed, but we're ending. We'll leave it for next time.",{task:this}),e;throw s.taskRejectedCounts.incr(this.fn),(0,w.isRedoableError)(e)?(this.retries++,this.priority--,this.upsert()):!0===(0,w.isRetriableError)(e)&&this.retries>=0?this.logger().warn("run failed, but we can retry it later",{task:this,error:e}):(s.ee.emit("rejected",this,e),this.delete(),u(s,s,"f",n).get(this.id)?.reject(e),(0,b.onError)(this.toString()+" failed",e)),e}finally{u(s,s,"m",a).call(s)}}}t.Task=H,s=H,o=new WeakMap,r=new WeakSet,a=function(){for(const[e,t]of u(this,s,"f",n).entries())t.isSettled&&u(this,s,"f",n).delete(e)},l=function(){const e=this.retries;if(1===s.dbl.runf((t=>t.where({id:this.id,retries:e}).update({retries:e-1}))).changes)return--this.retries,!0;{const e=this.toJSON(),t=this.reload();return this.logger().warn(".#decrRetries(): someone already started this task",{before:e,reloaded:t}),!1}},H.$tableName="Task",H.$uniqueColumnName="fn,argsJSON",H.$useCache=!1,H.taskResolvedCounts=new d.CountingSet,H.taskRejectedCounts=new d.CountingSet,H.ee=new c.EventEmitter,n={value:new Map}},72761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimestampedModel=void 0;const r=i(97352),s=i(40958),n=i(31586),a=i(59455),o=i(55046);class l extends o.Model{static touch(e,t={}){t.updatedAt??(t.updatedAt=Date.now()),delete t.id;const i=(0,a.toA)(e).filter(n.gt0);return(0,s.isEmpty)(i)?void 0:this.dbl.runf((e=>e.whereIn("id",i).update(t)))}get createdAtDate(){return(0,r.mapGt0)(this.createdAt,(e=>new Date(e)))}get updatedAtDate(){return(0,r.mapGt0)(this.updatedAt,(e=>new Date(e)))}touch(e={}){e.updatedAt??(e.updatedAt=Date.now());const t=this.id;null==t?this.upsert():this.class().dbl.runf((i=>i.where({id:t}).update(e)))}$beforeUpsert(){if(super.$beforeUpsert(),this.createdAt??(this.createdAt=Date.now()),this.updatedAt=Date.now(),"updateCount"in this){const e=this,t=e.updateCount;e.updateCount=((0,n.toGt0)(e.updateCount)??0)+1,this.logger().debug("$beforeUpsert(): incr updateCount",{prior:t,now:e.updateCount})}}}t.TimestampedModel=l},58723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyExcluded=t.applyDeleted=void 0;const r=i(50213),s=i(43487),n=(0,r.mkLogger)("ops.ApplyRemovable");async function a(e,t,i){const r=e?"Deleting":"Excluding",a=e?"deletedAt":"excludedAt";await s.Asset.dbl.batched({qb:e=>e.select("id").where("shown",0).andWhere(a,"<=",t),onResults:async t=>{for(const a of t){n.throwIfAborted_(i);try{await s.Asset.remove({assetId:a,blocklistShas:!0,unlinkAssetFiles:e})}catch(e){n.error(r+" failed",{assetId:a,error:e})}}}})}t.applyDeleted=function(e){return a(!0,e.createdAt,e.halt)},t.applyExcluded=function(e){return a(!1,e.createdAt,e.halt)}},76386:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiProgressPatchPath=t.tellWebProgressUpdated=t.ProgressRateMs=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(24540),o=i(28874),l=i(34238),u=i(4988),c=i(15674),d=i(42659),h=(0,i(45599).defer)((()=>(0,s.mkLogger)("progress.Progress")));t.ProgressRateMs=(0,r.lazy)((()=>d.secondMs*((0,a.isRaspberryPi)()||(0,c.maxCpus)()<=3?5:1.5))),t.tellWebProgressUpdated=(0,r.lazy)((async()=>{if((0,n.isWebService)())return;const e=l.URI.from({scheme:"http",authority:"127.0.0.1:"+o.Settings.httpPort.valueOrDefault,path:t.ApiProgressPatchPath}).toString();await(0,u.httpRequest_)({url:e,method:"PATCH"}).catch((e=>h().warn(".tellWebProgressUpdated: failed",{error:e})))}),(0,t.ProgressRateMs)()),t.ApiProgressPatchPath="/api/progress"},3996:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileFinder=t.isFileInSync=void 0;const o=i(19851),l=i(50213),u=i(79781),c=i(56519),d=i(56038),h=i(59189),f=i(38835),m=i(95696),p=i(48368),g=i(181),y=i(69589),v=i(28874),w=i(47783),b=i(87001),S=i(40958),P=i(76790),_=i(22573),M=i(42659),T=i(55835),E=i(31586),k=i(43487),D=i(54017);t.isFileInSync=async function(e){return new C(m.PosixFile.for(e)).alreadySynced()};const x=new h.SerialLaterQueue;class C{constructor(e,t=(0,y.forceContextOrSetting)()){this.file=e,this.ctx=t,r.set(this,void 0),s.set(this,new Set),this.alreadySynced=(0,d.timedLazy)("sync-file.AssetFileFinder.alreadySynced: "+this.file,(async()=>a(this,r,"f").tap({msg:"alreadySynced",result:null!=await this.priorIfSynced()}))),this.newAssetFile_=(0,d.timedLazy)("sync-file.AssetFileFinder.newAssetFile: "+this.file,(async()=>{const e=await(new D.AssetFile).updateFromFile_(this.file);return null==e?a(this,r,"f").throw("AssetFile.updateFromFile returned null",{fatal:!1}):e})),this.tags_=(0,o.lazy)((async()=>{const e=await(0,w.readTags)(this.file);if(null==e)throw new Error(this.file+" doesn't have metadata");return e})),this.imageHash=(0,o.lazy)((()=>v.Settings.useImageHashes.valueOrDefault?(0,p.imageHash)(this.file):void 0)),this.dominantLabhashes=(0,o.lazy)((()=>(0,c.thenMap)(this.imageHash(),(e=>(0,S.uniq)(e.dominantColors.filter((e=>e.pct>5)).map((e=>e.labhash))))))),this.capturedAtLocal=(0,o.lazy)((async()=>{const e=await this.capturedAt_();return a(this,r,"f").tap({msg:"capturedAtLocal",result:e?.local,meta:{capturedAt:e}})})),this.mapSibling=e=>this.newAssetFileForAsset(e?.getAsset()),this.apply_=(0,d.timedLazy)("sync-file.AssetFileFinder: "+this.file,(async()=>{if((0,_.blank)(await this.file.uri_()))throw new Error("Cannot import, file URI is blank for "+this.file);{const e=await this.byExistingAsset_();if(null!=e)return a(this,r,"f").info("Found existing asset for file"),e}const e=await this.newAssetFile_(),t=await x.enqueue((async()=>{const t=await this.byExistingAsset_();if(null!=t?.assetId)return a(this,r,"f").info("Found existing asset for file after acquiring lock",{withExistingAsset:t}),t.assetId;const i=new k.Asset;return i.capturedAtLocal=e.capturedAtLocal,i.addAssetFile(e),i.upsert(),i.id}));return e.assetId=t,e.upsert()})),this.byExistingAsset_=()=>(0,d.time)("sync-file.AssetFileFinder.byExistingAsset: "+this.file,(async()=>{const e=[{name:"byUri",f:()=>this.byUri()},{name:"byNormalizedPathUri",f:()=>this.newAssetFileForAsset(this.assetByNormalizedPathUri())},{name:"bySha",f:()=>this.newAssetFileForAsset(this.assetBySha())},{name:"hasTags",f:async()=>{await this.tags_()}},{name:"validFile",f:async()=>{await(0,g.throwIfInvalidFile_)(this.file)}},{name:"byCapturedAtOrImageHash",f:()=>this.newAssetFileForAsset(this.assetByCapturedAtOrImageHash())}];for(const{name:t,f:i}of e)try{const e=await(0,d.time)("sync-file.assetFileFinder."+t+": "+this.file,i);if(null!=e)return a(this,r,"f").info("apply(): "+t,{assetFileId:e.id,assetId:e.assetId}),e;a(this,r,"f").debug("apply(): "+t+": returned null")}catch(e){throw a(this,r,"f").debug("apply(): "+t+" rejected: "+e),e}})),n(this,r,(0,l.mkLogger)("sync-file.AssetFileFinder("+e.baseWithGrandparent+")"),"f")}async prior(){return this.byUri()}async priorIfSynced(){if(this.ctx.forceSync)return;const e=await this.prior();return!0===await(e?.matchesFile())?e:void 0}async newAssetFileForAsset(e){const t=await e;if(null!=t){if(null!=t.id){const e=await this.newAssetFile_();return t.addAssetFile(e),e.insert(),a(this,r,"f").debug("newAssetFileForAsset() upsert success!",{af:e}),e}a(this,r,"f").throw("newAssetFileForAsset(): given non-persisted Asset")}}async capturedAt_(){return(await this.tags_()).capturedAt}async byUri(e=this.file){const t=await e.uri_();if(null!=t)return D.AssetFile.ops().firstf((e=>e.whereIn("uri",[...(0,b.uriEncodingVariants)(t),this.file.fileuri()])));a(this,r,"f").warn("byUri() uri is null",{file:e})}async assetByNormalizedPathUri(){const e=await this.file.normalize();return e.nativePath===this.file.nativePath?void 0:(await this.byUri(e))?.getAsset()}assetBySha(){return(0,c.thenMap)(this.file.sha(),(e=>k.Asset.findFirstByFile((t=>t.where("AssetFile.sha",e)))))}async assetByCapturedAtOrImageHash(){const e=await this.capturedAt_();if(null==e)return a(this,r,"f").throw("Cannot import, capturedAt is null"+f.InternalErrorFlag);if(v.Settings.strictDeduping.valueOrDefault)return this.firstSimilarAsset(D.AssetFile.ops().allf((t=>t.where({capturedAtLocal:e.local}))));const t=v.Settings.maxContemporaryAdoptionAssets.valueOrDefault,i=()=>{let i=D.AssetFile.query();return(0,E.gt0)(t)&&(i=i.limit(t)),i.orderByRaw(`abs(capturedAtLocal - ${e.local})`)},s=Math.max(M.secondMs,v.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault);return(0,d.time)("sync-file.AssetFileFinder.assetByCapturedAtAndImageHash: "+this.file,(async()=>{{const t=e.localBoundaries({delta:s});if(null==t)a(this,r,"f").warn("Failed to fetch localBoundaries, cannot fetch similar assets by localtime",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("captured-at",i().whereBetween("capturedAtLocal",[t.start,t.end]))??(v.Settings.checkBasenameMatches.valueOrDefault?this.firstSimilarAssetByQuery("basename",i().whereILike("uri","%/"+this.file.name+"%")):void 0);if(null!=e)return e}}const t=await this.imageHash();if(null==t)return void a(this,r,"f").warn("assetByCapturedAtAndImageHash: no imageHash");const n=await this.dominantLabhashes();if((0,S.isNotEmpty)(n)){const t=e.localBoundaries({delta:4*s});if(null==t)a(this,r,"f").error("Failed to fetch localBoundaries, cannot fetch similar assets by wide localtime + image hash",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("wide captured-at and dominant color",i().whereBetween("capturedAtLocal",[t.start,t.end]).andWhere((e=>e.whereIn("mode0",n).orWhereIn("mode1",n).orWhereIn("mode2",n))));if(null!=e)return e}}return this.firstSimilarAssetByQuery("image hash",i().where("meanHash",t.meanHash).orWhere("diffHash",t.diffHash).orWhere("dctHash",t.dctHash))}))}async firstSimilarAssetByQuery(e,t){a(this,s,"f").size>0&&(t=t.whereNotIn("AssetFile.id",Array.from(a(this,s,"f"))));const i=await this.firstSimilarAsset(D.AssetFile.ops().all(t));return null!=i&&a(this,r,"f").info("Found similar asset by "+e,{result:i}),i}async firstSimilarAsset(e){const t=await this.newAssetFile_(),i=await this.capturedAtLocal();if(null==t)throw new Error("Failed to update from "+this.file);const n=(0,P.sortBy)(e.filter((e=>!a(this,s,"f").has(e.id))),(e=>[(0,T.mapOr)(i,(t=>Math.abs(e.capturedAtLocal-t)),-e.capturedAtLocal),e.id]));for(const e of n)if(null!=e){await e.getNativePath();const i=D.AssetFile.ops().findBy({assetId:e.assetId});await Promise.all(i.map((e=>e.getNativePath())));const n=(0,u.whyNotSameAsset)(t,e,i);if(null==n)return a(this,r,"f").info("Found sibling AssetFile",e),k.Asset.ops().findById(e.assetId);a(this,s,"f").add(e.id),a(this,r,"f").debug("Contemporary assetFile not similar: "+n,e?.uri)}}}t.AssetFileFinder=C,r=new WeakMap,s=new WeakMap},34274:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileImporter=t.importFileToResult_=void 0;const u=i(19851),c=i(50213),d=i(73568),h=i(38835),f=i(95696),m=i(62105),p=i(74128),g=i(181),y=i(69589),v=i(28874),w=i(40958),b=i(22573),S=i(38639),P=i(59455),_=i(64526),M=i(19113),T=i(94710),E=i(3996),k=i(90901);t.importFileToResult_=async function(e){const t=_.Library.instanceRequired_();return(0,p.syncReport)().wrap_({path:e.path,from:"AssetFileImporter",fn_:()=>new D(f.PosixFile.for(e.path),t.assetFileRepository(),e).apply_()})};class D{constructor(e,t,i){r.add(this),this.file=e,this.repo=t,this.start=Date.now(),s.set(this,void 0),n.set(this,void 0),this.whyRejected=(0,u.lazy)((async()=>{const e=[],t=await this.file.uri_();if(null==t)e.push("Cannot make URI"+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);else{if(!0===await this.file.isDeletedUri(t))e.push("File was deleted");else if(this.ctx.forceFilters||null==await this.prior()){const t=await(0,m.whyRejectFile)(this.file,(0,M.libraryFileFiltersFor)(this.file));null!=t&&e.push(t)}l(this,s,"f").throwIfAborted_();const i=await this.prior();if((0,w.isNotEmpty)(e)&&null!=i&&(l(this,s,"f").info("Deleting prior AssetFile",{rejected:e,prior:i}),i.delete(),this.ctx.skipAssetRepair?l(this,s,"f").info("Skipping asset repair",{assetId:i.assetId}):(l(this,s,"f").info("Scheduling asset repair",{assetId:i.assetId}),T.Task.addOne("repairAsset",{assetId:i.assetId,forceRebuildPreviews:(0,S.isTrue)(i.shown)}))),null!=i){const t=i.getAsset();null!=t?.deletedAt&&e.push("Asset is marked as deleted"),null!=t?.excludedAt&&e.push("Asset is marked as excluded")}if(l(this,s,"f").throwIfAborted_(),0===e.length&&(null==i||!await i.inSyncWithFile())){const t=await(0,g.whyInvalidFile)(this.file.nativePath);(0,b.blank)(t)||e.push(t)}}return e})),this.assetFile_=(0,u.lazy)((async()=>{const e=await l(this,n,"f").apply_(),t=e.getAsset();return l(this,s,"f").info("assetFileFinder.apply_() result",{asset:t,assetFile:e}),null==t?l(this,s,"f").throw("assetFile.getAsset() was null",{srcAssetFile:e}):null==t.id?l(this,s,"f").throw("repoAssetFile asset has null id",{asset:t}):e})),this.prior=(0,u.lazy)((()=>l(this,n,"f").prior())),this.apply_=(0,u.lazy)((()=>l(this,r,"m",a).call(this))),this.ctx=(0,y.forceContextOrSetting)(i),o(this,s,(0,c.mkLogger)("sync-file."+this.toString()),"f"),o(this,n,new E.AssetFileFinder(e,this.ctx),"f")}toString(){return"AssetFileImporter("+this.file.nativePath+")"}newAssetFile(){return l(this,n,"f").newAssetFile_()}}t.AssetFileImporter=D,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(){l(this,s,"f").throwIfAborted_();const e=await l(this,s,"f").tapAsync_({msg:"whyRejected",result:this.whyRejected(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if((0,w.isNotEmpty)(e)){const t=e.join(", ");return{path:this.file.nativePath,state:p.SyncFileStates.rejected,details:t}}l(this,s,"f").throwIfAborted_();const t=await l(this,s,"f").tapAsync_({msg:"prior()",result:this.prior(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if(null!=t&&await t.isNoop(this.ctx))return{path:this.file.nativePath,state:p.AssetFileSyncStates.noop,assetId:t.assetId,assetFileId:t.id,assetFile:t,asset:t.getAsset(),uri:t.uri};l(this,s,"f").throwIfAborted_();const i=await l(this,s,"f").tapAsync_({msg:"assetFile()",result:this.assetFile_(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if(null==i)return l(this,s,"f").throw("_apply(): unexpected null assetFile");const r=i.id;if(null==r)return l(this,s,"f").throw("_apply(): unexpected null assetFileId");const n=i.uri;if(null==n)return l(this,s,"f").throw("_apply(): unexpected null assetFile.uri");const a=i.getAsset();if(null==a)return l(this,s,"f").throw("_apply(): unexpected null assetFile.getAsset()");let o;await l(this,s,"f").tapAsync_({msg:"assetFile.upsertIfNeeded_()",result:i.upsertIfNeeded_(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault}),l(this,s,"f").throwIfAborted_();try{o=await(0,k.assetPostUpsertTasks_)({asset:a,...this.ctx})}catch(e){e instanceof d.AbortError?l(this,s,"f").warn("aborted (caller/process after me will complete)",{error:e}):l(this,s,"f").throw("Post-upsert tasks failed",{error:e})}return{path:this.file.nativePath,state:i.syncState??p.SyncFileStates.synced,assetId:a.id,assetFileId:r,assetFile:i,asset:a,uri:n,uris:[n,...(0,P.toA)(o?.newAssetFileUris)]}}},41844:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileRepository=t.mayCopyAssetsToLibrary=void 0;const u=i(50213),c=i(74128),d=i(81674),h=i(57902),f=i(4936),m=i(28874),p=i(47783),g=i(67083),y=i(16170),v=i(54979),w=i(98604),b=i(40958),S=i(22573),P=i(98553),_=i(89937),M=i(59455),T=i(54017),E=i(94710);t.mayCopyAssetsToLibrary=async function(){return m.Settings.copyAssetsToLibrary.valueOrDefault&&await(0,d.p)()},t.AssetFileRepository=class{constructor(e){r.add(this),this.originalsDir=e,this.logger=(0,u.mkLogger)("AssetFileRepository")}async shouldCopy(e){const t=await this.whyNotCopyFile(e);return this.logger.tap({level:"info",msg:"shouldCopy()",result:null==t,meta:{file:e?.nativePath,whyNot:t}})}async whyNotCopyFile(e){if(null==e||(0,S.blank)(e.nativePath))return"blank nativePath";if(!0!==m.Settings.copyAssetsToLibrary.value)return"copyAssetsToLibrary !== true";if(await(0,d.l)())return"no active subscription";if(await e.notExists({refresh:!0}))return"file doesn't exist";if(e.isDescendantOf(this.originalsDir))return e+" already contained by "+this.originalsDir;if(e.isDescendantOf(m.Settings.libraryDir.valueOrDefault))return e+" already contained by "+m.Settings.libraryDir.valueOrDefault;const t=await(0,v.readMimeType)(e);return null==t?"readMimeType("+e+") was null":(0,y.isMimeTypeIncluded)(t,m.Settings.copyToLibraryMimeTypes.values)?null:"mimetype "+t+" is not included in copyToLibraryMimeTypes"}async existingLibraryAssetFile(e){if(e.uri.startsWith(_.PS_LIBRARY_PROTOCOL))return e;const t=(0,b.uniqBy)((0,M.toA)(e.librarySiblings()?.filter((t=>t.sha===e.sha))).concat(T.AssetFile.sameAssetFileInLibrary(e)),(e=>e.id));for(const i of t)if(await i.exists()){if(i.assetId!==e.assetId){this.logger.warn("Existing library asset file with a matching SHA is associated to a different asset. Requesting repair of the two impacted assets.",{af:e,prior:i});const t=i.assetId;e.getAsset()?.addAssetFile(i),E.Task.addOne("repairAsset",{assetId:t,forceSync:!0})}return this.logger.info("whyNotCopyAssetFile("+e.uri+"): found existing db record",{af:e,prior:i}),i}return null}async findLibraryFileWithSameContents(e,t){if(await e.matchesContent(t))return t;let i=t.parent();for(;i.isSelfOrDescendantOf(this.originalsDir);){const t=i.childWithSameContents(e);if(null!=t)return t;i=i.parent()}}async importFile_(e){const t=await l(this,r,"m",s).call(this,e);return null!=t&&(await l(this,r,"m",n).call(this,e,t),await l(this,r,"m",o).call(this,e,t)),t}async maybeCopyToLibrary_(e,t){const i=Date.now(),s=await e.posixFile_();null==s&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): posixFile is null",{ignorable:!1,retriable:!1});{const e=await this.whyNotCopyFile(s);if(!(0,S.blank)(e))return this.logger.tap({level:h.LogLevels.info,msg:"maybeCopyToLibrary_(): not copying: "+e,result:void 0})}const a=e.getAsset();null==a&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): null asset");{const u=await this.existingLibraryAssetFile(e);if(null!=u){const e=await u.posixFile_();if(null!=e){const d=await l(this,r,"m",n).call(this,s,e),h=null!=await l(this,r,"m",o).call(this,s,e),f=null!=await u.upsertIfNeeded_(void 0,t);return!h&&(0,b.isEmpty)(d)&&!f||(0,c.syncReport)().onProgress({path:e.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.synced,details:"Found and synced prior replica already in your library "+(0,P.stringify)({src:s.nativePath,upsertNeeded:f,copiedSidecars:d,copiedInferredMetadata:h}),elapsedMs:Date.now()-i,url:(0,w.mkAssetUrl)(a.id)?.toString()}),u}this.logger.warn("existingLibraryAssetFile() returned an assetFile that could not be resolved to a PosixFile",{prior:u})}}const u=await this.importFile_(s);if(null==u)return void this.logger.info("importFile() returned null",{srcAssetFile:e});if(u.nativePath===s.nativePath)return void this.logger.info("importFile() returned the same nativePath as src",{srcAssetFile:e,dest:u});const d=await a.assetFileForFile_(u,{skipUpsert:!0});await d.updateFromShaSibling_(e);const f=d.upsert();return a.addAssetFile(d),(0,c.syncReport)().onProgress({path:u.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.copied,details:"Copied into your library from "+s.nativePath,elapsedMs:Date.now()-i,url:(0,w.mkAssetUrl)(a.id)?.toString()}),f}},r=new WeakSet,s=async function(e){const t=await(0,p.readCapturedAt)(e),i=(0,f.pathToLibraryAsset)(t?.date,e);if(this.logger.debug("importFile("+e+")",{capturedAt:t,assetPath:i}),null==i)throw new Error(e.nativePath+" failed to create a library path");const r=this.originalsDir.join(...i),s=await this.findLibraryFileWithSameContents(e,r);if(null!=s)return this.logger.debug("#importFile_("+e+"): found existing file",{src:e,existing:s}),s;const n=await r.ensureNew_();return this.logger.info("#importFile_("+e+"): copying...",{uniqDest:n,dest:r}),e.copyFile_(n)},n=async function(e,t){const i=await e.existingSidecars(),s=[];for(const e of i)s.push(await l(this,r,"m",a).call(this,e,t));return(0,b.compact)(s)},a=async function(e,t){for(const i of await t.existingSidecars())if(await(0,p.sidecarEql)(e,i))return void this.logger.info("handleSidecar(): metadata already exists.",{srcSidecar:e,destSidecar:i,dest:t});const i=await t.parent().join(t.name+e.ext).ensureNew_({emptyIsNew:!0});return e.copyFile_(i)},o=async function(e,t){if(null==e||null==t||e.eql(t))return;const i=await(0,p.readTags)(e);if(null!=i)return(0,g.ensureInferredHistoryRecords)(e,await t.sidecar(),i.inferred);this.logger.warn("#handleInferred(): Failed to read tags from "+e,{dest:t})}},90901:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetPostUpsertTasks_=t.assetPostUpsertTasks=void 0;const r=i(50213),s=i(92434),n=i(73568),a=i(99331),o=i(39250),l=i(38835),u=i(57159),c=i(48604),d=i(66106),h=i(69589),f=i(40958),m=i(45599),p=i(23838),g=i(31586),y=i(64526),v=i(88224),w=i(43487),b=i(41844),S=i(68640),P=(0,m.defer)((()=>(0,r.mkLogger)("sync-file.AssetPostUpsertTasks"))),_=(0,m.defer)((()=>new o.LastOneInWins("Asset tasks")));async function M(e){const t=e,i=e,r=(0,g.toGt0)(t.asset?.id)??(0,g.toGt0)(i.assetId);if(null==r)throw new Error("assetPostUpsertTasks_(): unexpected null assetId"+l.InternalErrorFlag);const o=(0,h.forceContextOrSetting)(e),m=P().addContext(`.postUpsertAssetTasks_(Asset:${r})`);if(m.abortable=o.halt,o.skipPreviews&&o.skipAssetTagging)return void m.info("skipped (skipPreviews && skipAssetTagging)");const M=t.asset??w.Asset.ops().findById(r);if(null==M)return m.throw("unexpected null asset",{asset:M});try{return await _().enqueue({key:r,abortable:m.abortable,fn:()=>async function(e,t,i){const r=(0,h.forceContextOrSetting)(i),n=t.id,a=t.getAssetFiles({refresh:!0}),o={newAssetFileUris:[],previewsUpdated:!1,tagResult:void 0,transcoded:!1};if(e.throwIfAborted_(),(0,f.isEmpty)(a)&&(await w.Asset.remove({assetId:n,blocklistShas:!1,unlinkAssetFiles:!1}),e.throw(`Asset:${n} had no asset files. Deleted.`)),await(0,b.mayCopyAssetsToLibrary)())for(const[t,i]of(0,p.groupBy)(a,(e=>e.sha)).entries()){e.throwIfAborted_();try{for(const r of i)r.isInLibrary()&&await r.exists()&&e.debug("no-op for file SHA: already in library.",{sha:t,uri:r.uri});for(const e of i)if(await e.exists()){const t=await y.Library.instanceRequired_().assetFileRepository().maybeCopyToLibrary_(e,r);if(null!=t){o.newAssetFileUris.push(t.uri);continue}}}catch(r){e.warn("Failed to copy variation to library, but we'll try to continue",{sha:t,uris:i.map((e=>e.uri)),error:r})}}e.throwIfAborted_();const l=r.skipPreviews?void 0:await(0,S.updateAssetPreviews_)({asset:t,assetFiles:t.getAssetFiles(),...r}),u=await async function(e,t){if((0,g.gt0)(t?.assetFileId)){const i=e.getAssetFiles({refresh:!0}).find((e=>e.id===t?.assetFileId));return null==i?P().throw("AssetPreviewInfo referenced unknown assetFileId",{asset:e,info:t}):i}const i=e.getShown();return null!=i?i:(0,s.bestExistingAssetFile)(e.getAssetFiles())}(t,l);if(null==u)return e.throw("null primaryOrShownAssetFile_()",{asset:t});const m=await u.posixFile_();if(!0!==r.skipPreviews&&t.isVideo()){if(null==m)return e.throw("null primary.posixFile()",{asset:t,assetFiles:t.getAssetFiles()});o.transcoded=null!=await(0,d.transcode_)(m,c.Previews.instance().ap(n).mp4(),{force:r.forceRebuildPreviews,halt:r.halt})}return e.throwIfAborted_(),t.markShownAndUpsert_(u),r.skipAssetTagging?e.info("skipping asset tagging"):o.tagResult=await(0,v.tagAndUpsertAsset_)(t),o}(m,M,{...e,...o})})}catch(e){if(e instanceof n.AbortError)return void m.warn("aborted, next caller will clean up my mess",{error:e});const t=[e];if(!(0,a.ending)()){m.error("failed, marking asset unshown",{error:e});try{M.markUnshownAndUpsert()}catch(e){m.error("failed to mark asset unshown",{upsertError:e}),t.push(e)}}throw new u.WrappedError("Failed to post-process assset "+M.id,{causes:t})}}t.assetPostUpsertTasks=function(e){try{return M(e)}catch(e){if(e instanceof n.AbortError)return void P().warn("aborted, next caller will clean up my mess",{error:e});throw e}},t.assetPostUpsertTasks_=M},61989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAsset_=t.updateAsset=void 0;const r=i(48884),s=i(50213),n=i(45393),a=i(79184),o=i(79781),l=i(92434),u=i(56519),c=i(70417),d=i(69589),h=i(28874),f=i(40958),m=i(22573),p=i(38639),g=i(50357),y=i(43487),v=i(54017),w=i(90901);async function b(e){const t=(0,d.forceContextOrSetting)(e),i=e.assetId,r=(0,s.mkLogger)(`sync-file.UpdateAsset(${i})`);r.abortable=t.halt;const b=y.Asset.ops().findById(i);if(null==b)return r.throw("no such asset");const P=b.getAssetFiles({refresh:!0});if((0,f.isEmpty)(P))return r.warn("No asset files: deleting."),b.delete(),{asset:b,rejected:"Empty asset (no AssetFiles)"};const _=b.$clone(),M=b.getShown()?.$clone();for(const e of P)r.throwIfAborted_(),await e.upsertIfNeeded_(void 0,t);P.some((e=>(0,p.isTrue)(e.deleted)||(0,m.notBlank)(e.rejected)))&&b.clear(),await S(r,P);const T=(0,l.sortAssetFiles)(P),E=T?.[0];if((0,f.isEmpty)(T)||null==E)return r.warn("No existing files. Skipping for now."),b.markUnshownAndUpsert(),{asset:b,rejected:"Empty asset (no AssetFiles after sorting). Un-showing Asset:"+i};if(!E.isVersionUpToDate())return r.warn("Best file needs update, and we already tried to update all files. Skipping this asset.",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, could not be updated. Un-showing Asset:${i}`};const k=await E.capturedAt();if(null==k)return r.warn("Best file failed to extract a captured-at",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, failed to extract a captured-at. Un-showing Asset:${i}`};const D=new Set,[x,C]=await(0,u.partitionAsync)(T,(e=>(0,o.isSimilarAssetFile)(e,E)));if(r.throwIfAborted_(),(0,f.isNotEmpty)(C)){const e=await(0,a.aggregateAssetFiles)(C);for(const t of e){if((0,f.isEmpty)(t))continue;const e=y.Asset.ops().insertOne({capturedAtLocal:t[0].capturedAtLocal,shown:!1,version:0});D.add(e.id);for(const i of t)e.addAssetFile(i);v.AssetFile.dbl.runf((i=>i.update({assetId:e.id,shown:0}).whereIn("id",(0,f.compact)(t.map((e=>e.id)))))),r.info("Pushed rejected asset files into new asset",{rejectAssetId:e.id,rejectCluster:t.map((e=>({id:e.id,uri:e.uri})))})}}function F(e){return(0,f.uniq)(x.map((t=>t[e])))}const A=await Promise.all(x.map((e=>e.capturedAt()))),I=h.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,O=A.map((e=>e?.localBoundaries({delta:I}))),L=(0,c.min)(O.map((e=>e?.start)))??k.localBoundaries({delta:I})?.start,R=(0,c.max)(O.map((e=>e?.end)))??k.localBoundaries({delta:I})?.end,N=v.AssetFile.ops().all(v.AssetFile.query().limit(h.Settings.maxContemporaryAdoptionAssets.valueOrDefault).orderByRaw(`abs(AssetFile.capturedAtLocal - ${E.capturedAtLocal})`).select("AssetFile.*").distinct().join("Asset","Asset.id","AssetFile.assetId").where("AssetFile.assetId","!=",i).andWhere("Asset.version","!=",n.AssetVersion).andWhere((e=>(e=e.whereIn("AssetFile.sha",F("sha")),null==L||null==R?r.warn("external asset file check: unset start or end localtime boundary",{capturedAts:A,startBoundary:L,endBoundary:R}):e=e.orWhereBetween("AssetFile.capturedAtLocal",[L,R]),e.orWhereIn("AssetFile.meanHash",F("meanHash")).orWhereIn("AssetFile.diffHash",F("diffHash")).orWhereIn("AssetFile.dctHash",F("dctHash"))))));r.throwIfAborted_(),r.info("asset file candidates for adoption: ",N.map((e=>e.posixPathFromGrandparent)));const B=[];for(const e of N){r.throwIfAborted_();try{await e.updateFromFile_(),(0,o.isSimilarAssetFile)(e,E)&&(r.info("adopting similar asset file",{af:e}),D.add(e.assetId),e.shown=!1,b.addAssetFile(e),e.upsert(),B.push(e))}catch(t){r.warn("Error updating external asset file. Leaving asset file record as-is.",{af:e,error:t})}}r.info("fetched expansion",{retainAFs:x.map((e=>e.id)),rejectAFs:C.map((e=>e.id)),externalAssetFiles:N.map((e=>e.posixPathFromGrandparent)),similarAssetFiles:B.map((e=>e.posixPathFromGrandparent))}),await S(r,[...x,...B]),t.skipPreviews&&t.skipAssetTagging?(r.info("skipping previews and tagging",t),b.upsert()):await(0,w.assetPostUpsertTasks_)({...t,asset:b});const j=!(0,g.eql)(_,b),z=!(0,g.eql)(M,b.getShown()),V=!(j||z||t.forceRebuildPreviews||t.forceSync);return r.tap({msg:"updateAsset() result",level:"info",result:{asset:b,assetIdsToUpdate:Array.from(D),assetFiles:b.assetFiles,skipped:V},meta:{ctx:t,assetChanged:j,primaryAssetFileChanged:z}})}async function S(e,t){const[i,s]=(0,r.partition)(t,(e=>e.isVersionUpToDate()));for(const t of s){e.throwIfAborted_();const r=i.find((e=>e.sha===t.sha));if(null!=r){e.info("backfilling",{sibling:r,dest:t});const i=await t.updateFromShaSibling_(r);null!=i&&i.upsert()}}}t.updateAsset=async function(e){try{const t=await b(e);return{id:e.assetId,skipped:null==t?.asset,...t}}catch(t){return{id:e.assetId,error:t}}},t.updateAsset_=b},93755:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetFileIfNeeded=t.handleAssetFileUriChange=t.updateAssetFile_=t.updateAssetFile=void 0;const r=i(50213),s=i(92434),n=i(98314),a=i(74128),o=i(69589),l=i(87001),u=i(40958),c=i(22573),d=i(68708),h=i(43487),f=i(54017),m=i(94710);async function p(e){const t=Date.now(),i=e,s=e,n=s.af?.id??i.assetFileId,u=(0,r.mkLogger)(`updateAssetFile(${n})`),d=s.af??f.AssetFile.ops().findById(n);if(null==d)return u.throw("db record not found",{assetFileId:n});const h=await d.posixFile_(),p=(0,o.forceContextOrSetting)(e),v={id:n,assetFileId:n,path:h?.nativePath,uri:d?.uri};if(null==h)return{...v,error:"file for URI not found"};const w=await(h?.isDeletedUri(d.uri));if(null==w)return u.info("no-op: file URI points to an unmounted volume",v),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:"volume is not currently mounted",state:a.SyncFileStates.skipped}),{...v,skipped:!0};const b=e.whyReject??await d.whyRejected();if(w||!(0,c.blank)(b)){const e={...v,rejected:b,deleted:w};return u.warn("file was deleted or rejected. Deleting.",e),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:w?"file no longer exists":"rejected: "+b,state:a.SyncFileStates.deleted}),d.delete(),!0!==p.skipAssetRepair&&m.Task.addOne("repairAsset",{assetId:d.assetId}),e}const S=await h.uri_();if(!await(0,l.uriIsEquivalent)(S,d.uri)){const e=await g(d,S,p);if(null!=e)return{...v,...e}}return!p.forceSync&&await d.matchesFile()?(u.info("no-op: file already matches db record",v),d.touch(),{...v,skipped:!0}):{...v,...await y(d,p)}}async function g(e,t,i){const n=(0,r.mkLogger)(`handleAssetFileUriChange(${e.id})`),a=(0,u.uniq)([...(0,l.uriEncodingVariants)(e.uri),...(0,l.uriEncodingVariants)(t)]);n.warn("URI is changing. Avoiding duplicate keys.",{priorUri:e.uri,variants:a});const o=f.AssetFile.ops().allf((t=>t.whereIn("uri",a).andWhereNot({id:e.id})));if((0,u.isNotEmpty)(o)){n.warn("Found other AssetFiles with equivalent URIs.",{afIds:o.map((e=>e.id))});const t=[e,...o],r=(0,s.sortAssetFiles)(t);if((0,u.isEmpty)(r))return n.warn("sortAssetFiles returned undefined",{arr:t.map((e=>(0,d.pick)(e,"id","uri"))),variants:a}),{error:"sortAssetFiles returned undefined"};const l=t.map((e=>e.id));for(const e of r)if(await e.exists()){f.AssetFile.dbl.runf((t=>t.whereIn("id",l.filter((t=>t!==e.id))).delete()));const r=y(e,i);return h.Asset.dbl.runf((e=>e.update({version:0,updatedAt:Date.now()}).whereIn("id",(0,u.uniq)(t.map((e=>e.assetId)))))),r}}n.info("no-op, no duplicate URIs.")}async function y(e,t){const i=Date.now();return null!=await e.upsertIfNeeded_(void 0,t)&&h.Asset.touch([e.assetId]),(0,a.syncReport)().onProgress({path:await e.getNativePath(),elapsedMs:Date.now()-i,from:"updateAssetFileIfNeeded()",state:e.syncState??a.SyncFileStates.unknown}),{assetFileId:e.id}}t.updateAssetFile=async function(e){try{return await p(e)}catch(t){return{id:e.assetFileId,...e,error:(0,n.errorToS)(t)}}},t.updateAssetFile_=p,t.handleAssetFileUriChange=g,t.updateAssetFileIfNeeded=y},68640:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetPreviews_=void 0;const r=i(99331),s=i(38835),n=i(48604),a=i(50213),o=i(69589),l=i(87001),u=i(40958),c=i(45599),d=i(50357),h=i(31586),f=i(68708),m=i(59455),p=i(43487),g=(0,c.defer)((()=>(0,a.mkLogger)("sync-file.UpdateAssetPreviews")));t.updateAssetPreviews_=async function(e){const t=e.assetId??e.asset?.id??(0,m.toA)(e.assetFiles).find((e=>(0,h.gt0)(e.assetId)))?.assetId,i=(0,o.forceContextOrSetting)(e),a=g().addContext(".Asset:"+t);if(i.skipPreviews)return void a.warn("skipPreviews is true: no-op");if(!(0,h.gt0)(t))return a.throw("invalid assetId",{assetId:t});const c=e.asset??p.Asset.ops().findById(t);if(null==c)return a.throw("Asset:"+t+" not found");a.throwIfAborted_(i.halt);try{const e=await c.getExistingAssetFiles();if((0,u.isEmpty)(e))return void a.warn("no existing assetFiles",{asset:c});const r=n.Previews.instance().ap(t),o=await r.readInfo();a.throwIfAborted_(i.halt);const h=await(0,n.buildAssetPreviews_)({...i,assetId:t,assetFiles:e}),m=e.find((e=>e.id===h?.assetFileId))??e.find((e=>(0,l.uriIsEquivalent)(h?.uri,e.uri)));a.info("buildAssetPreviews_()",{result:h,primaryAssetFile:m});const p=await(m?.posixFile_());if(null==m||null==p||!0!==await(p?.exists()))return a.throw("buildAssetPreviews_() returned invalid assetFileId"+s.InternalErrorFlag,{newInfo:h,assetFiles:e.map((e=>(0,f.pick)(e,"id","uri"))),primaryAssetFile:m,primaryPosixFile:p});const g=(0,d.eql)(o,h),y=null==h||g;return{...h,noop:y}}catch(e){throw(0,r.ending)()||(a.warn("Failed to update previews. Un-showing asset "+t,{error:e}),c.markUnshownAndUpsert()),e}}},94019:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathsToSync=t.scanPaths=t.logger=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(87290),o=i(34102),l=i(16287),u=i(45969),c=i(43334),d=i(28874),h=i(45200),f=i(69375),m=i(7014),p=i(41400),g=i(31586),y=i(92244),v=i(46832);t.logger=(0,r.lazy)((()=>(0,s.mkLogger)("sync.PathsToSync")));const w=(0,r.lazy)((async()=>{const e=[];for(const t of await(0,m.volumes)()){if(!0===t.ignorable||!1===t.ok||(c.isMac||(0,u.isDocker)())&&"/"===t.mountpoint||(0,f.isExcludedMountpoint)(t.mountpoint)||!(0,g.gt0)(t.size))continue;const i=await(0,v.toUriPath)(t.mountpoint,(0,h.nativePath2uri)(t.mountpoint,t));null!=i&&e.push(i)}return e}));async function b(){const e=[],i=[],r=d.Settings.argvScanPaths.toNotEmpty()??d.Settings.scanPaths.values;for(const s of r)if(await(0,l.isReadableDirectory)(s)){const r=await(0,v.toUriPath)(s);null==r?(e.push(s),(0,t.logger)().warn("Ignoring scanPath element: failed to create URI path",s)):i.push(r)}else(0,t.logger)().warn("Ignoring scanPath element: not readable directory",s);return{result:i,noUriPaths:e}}t.scanPaths=b,(0,p.later)((()=>{(0,o.ee)().on("volumesChanged",(()=>{w.unset()}))})),t.pathsToSync=async function(){const e=[];if(d.Settings.argvScanPaths.isNotEmpty()){for(const i of d.Settings.argvScanPaths.values){const r=await(0,v.toUriPath)(i);null!=r?e.push(r):(0,t.logger)().warn("pathsToSync(): Ignoring scanPath element: failed to create URI path",i)}return e}e.push(...(await b()).result),!0===d.Settings.scanAllDrives.value&&e.push(...await w());const i=await(0,n.thenMapOr)((0,a.libraryOriginalsDirPosixFile)(),v.posixFileToUriPath,(()=>(0,t.logger)().throw("libraryOriginalsDir was null",{libraryDir:d.Settings.libraryDir.valueOrDefault,originalsDir:d.Settings.originalsDir.value})));d.Settings.scanLibraryFirst.valueOrDefault&&e.unshift(i),d.Settings.scanLibraryLast.valueOrDefault&&e.push(i);const r=await(0,n.filterAsync)({name:"pathsToSync",arr:e,f:e=>!y.nativePathBlocklist.has(e.nativePath)&&(0,l.isReadableDirectory)(e.nativePath)});return(0,t.logger)().info("pathsToSync",r),r}},98622:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runTimeIsStale=t.SyncCron=void 0;const r=i(28874),s=i(41400),n=i(30301),a=i(31586);t.SyncCron=(0,n.lazy)((()=>r.Settings.syncCron.cron({timezone:r.Settings.syncCronTZ.value}))),(0,s.later)((()=>{r.Settings.syncCron.watchLater((()=>t.SyncCron.unset())),r.Settings.syncCronTZ.watchLater((()=>t.SyncCron.unset()))})),t.runTimeIsStale=function(e){return null==e||(0,a.lte)((0,t.SyncCron)().nextRun(new Date(e))?.getTime(),Date.now())}},92244:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syncPathsForUI=t.bestStable=t.isStale=t.bestPathToSync=t.stalePathsToSync=t.pathsAndTimesToSync=t.nativePathBlocklist=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(23560),o=i(22277),l=i(87290),u=i(57902),c=i(28874),d=i(40958),h=i(76790),f=i(42659),m=i(75240),p=i(31586),g=i(20958),y=i(49796),v=i(94019),w=i(98622),b=(0,s.lazy)((()=>(0,n.mkLogger)("sync.SyncPaths")));t.nativePathBlocklist=new o.TTLSet(10*f.minuteMs);const S=10*f.minuteMs;async function P(){const e=await(0,v.pathsToSync)(),t=c.Settings.forceSync.valueOrDefault?[]:await y.Progress.times();return b().tap({msg:"pathsAndTimesToSync()",level:u.LogLevels.info,result:e.map((e=>({...e,...t.find((t=>t.uri===e.uri))})))})}function _(e,t){return null==e.lastStartedAt||null==e.lastCompletedAt||(0,p.lte)(e.lastStartedAt,t)||(0,w.runTimeIsStale)(e.lastCompletedAt)}function M(){return g.Operation.getFirstPendingOp({name:g.OperationNames.forceRestartSync})}async function T(e){const t=M(),i=t?.createdAt,s=e.filter((e=>_(e,i)));if((0,d.isEmpty)(s))return(0,a.isSyncService)()&&t?.markCompleted(),b().tap({msg:"bestStable(): No stale paths to sync!",level:"info",result:void 0,meta:{arr:e,forceRestartOp:t}});{const e=(0,r.greatestBy)(s,(e=>e.lastUpdatedAt));if(null!=e&&(0,p.gt)(e.lastUpdatedAt,Date.now()-10*f.minuteMs))return b().tap({msg:"bestStable(): returning most recently updated",level:"info",result:{...e,why:"recently updated"}})}const n=(0,r.leastBy)(s,(e=>[e.lastStartedAt??0,e.lastCompletedAt??0]));return b().tap({msg:"bestStable(): returning least-recently-started or least-recently-completed:",level:"info",result:null==n?void 0:{...n,why:"least recently started or completed"},meta:{stale:s}})}function E(e,t){return null==e.lastStartedAt?"new":null==e.lastCompletedAt?"todo":(0,p.gt)(e.lastUpdatedAt,Date.now()-f.minuteMs)?"syncing":_(e,t)?"stale":"synced"}function k(e){return null==e?void 0:new Date(e).toISOString()}function D(e){if(null==e)return;const t=Date.now()-e;return t<2*f.secondMs?"just now":(0,m.fmtDuration)(t)+" ago"}t.pathsAndTimesToSync=P,t.stalePathsToSync=async function(){const e=await P(),t=M(),i=t?.createdAt,r=e.filter((e=>_(e,i)));return(0,h.sortBy)(r,(e=>[null!=e.lastUpdatedAt&&Date.now()-Se.nativePath)),t=await T(e),i=(0,l.libraryOriginalsDirPosixFile)()?.nativePath,r=M()?.createdAt;return e.map((e=>({path:e.nativePath,library:i===e.nativePath,status:E(e,r),isNext:e.nativePath===t?.nativePath,lastStartedISO:k(e.lastStartedAt),lastStarted:D(e.lastStartedAt),lastCompletedISO:k(e.lastCompletedAt),lastCompleted:D(e.lastCompletedAt)})))}},46832:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.posixFileToUriPath=t.toUriPath=void 0;const r=i(53265),s=i(45200),n=i(22573),a=i(68708),o=i(54993);async function l(e,t){if((0,a.isObject)(e)&&!(0,n.blank)(e.nativePath)&&!(0,n.blank)(e.uri))return e;const i=(0,r.resolve)((0,o.toS)(e)),l=await t??await(0,s.nativePath2uri)(i);return null==l?void 0:{nativePath:i,uri:l.toString()}}t.toUriPath=l,t.posixFileToUriPath=function(e){return l(e.nativePath,e.uriObject_())}},7656:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rebuildTagAssetCounts=t.DirectAssetCountForTagQuery=t.RecursiveAssetCountForTagQuery=t.nonLeafTagIds=void 0;const r=i(50213),s=i(56038),n=i(95704),a=i(38156),o=i(42659),l=i(45599),u=i(41400),c=i(31586),d=i(51926),h=(0,l.defer)((()=>(0,r.mkLogger)("tag.TagAssetCounts")));function f(e){return e.prepare((0,d.compressWhitespace)("SELECT"," t1.id,"," count(t2.id) AS cnt","FROM"," Tag t1"," JOIN Tag t2 ON t1.id = t2.parentId","GROUP BY"," 1","HAVING"," cnt > 0")).pluck().all()}async function m(e,i=[]){const r=e.prepare(t.RecursiveAssetCountForTagQuery).pluck(),o=e.prepare(t.DirectAssetCountForTagQuery).pluck(),l=e.prepare("UPDATE Tag SET assetCount = :assetCount, updatedAt = :updatedAt WHERE id = :tagId"),c=new Set(f(e)),d=new a.PushProgressObserver({op:"Rebuilding tag asset counts"},e.prepare("SELECT count(*) FROM Tag").pluck().get());await(0,n.withIdBatches)({db:e,tableName:"Tag",primaryKeyColumnName:"id",whereClauses:i,async fn(e){for(const t of e){const e=!c.has(t);(0,s.timeSync)("db.rebuildTagAssetCounts("+(e?"leaf":"cte")+")",(()=>{const s=(e?o:r).get({tagId:t});l.run({tagId:t,assetCount:s,updatedAt:Date.now()}),d.incrProgress(),h().debug("_rebuildTagAssetCounts()",{isLeaf:e,whereClauses:i,tagId:t,assetCount:s})})),t%10==0&&(h().throwIfAborted_(),await(0,u.delay)(1))}}}),d.completed()}t.nonLeafTagIds=f,t.RecursiveAssetCountForTagQuery=(0,d.compressWhitespace)("WITH RECURSIVE descendants(id) AS ("," VALUES (:tagId)"," UNION"," SELECT Tag.id"," FROM Tag, descendants"," WHERE Tag.parentId = descendants.id",")","SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," descendants"," JOIN AssetTag ON AssetTag.tagId = descendants.id"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL"),t.DirectAssetCountForTagQuery=(0,d.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," AssetTag"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," AssetTag.tagId = :tagId"," AND Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL;"),t.rebuildTagAssetCounts=async function(e,t=o.minuteMs){if(await(0,s.time)("db.rebuildNullTagAssetCounts",(()=>m(e,["assetCount IS NULL"]))),(0,c.gt0)(t)){const i=e.prepare("SELECT min(updatedAt) FROM Tag").pluck().get(),r=Date.now()-i;if(rm(e)))}},69032:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.displayNameForVolsha=t.fixFileRootTag=t.runTagMaintenance=t.forceRunTagMaintenance=t.tagFtsRebuild=void 0;const s=r(i(76760)),n=i(19851),a=i(50213),o=i(7282),l=i(409),u=i(1728),c=i(56038),d=i(34102),h=i(49076),f=i(69589),m=i(28874),p=i(42231),g=i(85087),y=i(98770),v=i(59107),w=i(63870),b=i(7014),S=i(22573),P=i(42659),_=i(41400),M=i(75240),T=i(31586),E=i(34666),k=i(51926),D=i(75020),x=i(54017),C=i(48723),F=i(98784),A=i(7656),I=(0,n.lazy)((()=>(0,a.mkLogger)("tag.TagSql")));t.tagFtsRebuild=(0,n.lazy)((()=>(0,c.time)("db.rebuildTagFts",(()=>F.TagFts.rebuild()))),10*P.minuteMs),t.forceRunTagMaintenance=async function(e={forceSync:!0,recountAllTags:!0}){return I().info("forceRunTagMaintenance()"),await t.runTagMaintenance.force(e)};const O=((0,o.isTest)()?5:30)*P.secondMs;t.runTagMaintenance=(0,l.rateLimited)({name:"runTagMaintenance",minCallDelayMs:O,f:async e=>{const i=(0,f.forceContextOrSetting)(e),r=Date.now(),s=I().addContext(".runTagMaintenance()");s.info("starting",{ctx:i});try{s.info("validating all tags..."),C.Tag.validate_(),s.throwIfAborted_(i?.halt),await L(),i.recountAllTags&&(s.info("rebuilding tag search index..."),await(0,t.tagFtsRebuild)(),s.info("rebuilding tag asset counts..."),await(0,A.rebuildTagAssetCounts)(C.Tag.dbl.db().db,0))}catch(e){I().warn("runTagMaintenance() failed",e)}const n=Date.now()-r,a=(0,T.clamp)(O,15*P.minuteMs,20*n);t.runTagMaintenance.setMinCallDelayMs(a),I().info("runTagMaintenance(): complete.",{newMinCallDelayMs:a,elapsedMs:n})}});const L=(0,y.lazyFsAsync)("updateTagMountpoints",(async()=>{I().info("updating tag mountpoints...");const e=C.Tag.findByPath([D.TagRoots.fs]);if(null!=e){e.maybeUpsertDisplayName(m.Settings.tagDisplayNameFS.valueOrDefault);for(const t of e.getChildren())await N(t)}else(0,a.mkLogger)("updateTagMountpoints()").info("No root filesystem tag (new db, I hope?)")}));function R(){t.tagFtsRebuild.unset(),L.unset()}async function N(e){if(null==e||2!==e.depth||!e._path.startsWith(D.TagRoots.fs+p.TagSep))return;const i=(0,a.mkLogger)("fixFileRootTag("+e+")");if(e.name===D.LibraryTagName)return void(1!==e.ordinal&&(i.info("fixing library ordinal",{id:e.id,path:e.path}),e.upsert({ordinal:1}),C.Tag.clear()));if((0,f.forceContextOrSetting)().forceSync&&(0,S.notBlank)(e.displayName)&&(0,E.gt)(e.updatedAt,Date.now()-(0,w.volumeMetadataTtlMs)()))return void i.info("no-op: tag recently updated",{id:e.id,path:e.path,updated:(0,M.fmtDuration)(Date.now()-e.updatedAt)+" ago"});const r=await(0,t.displayNameForVolsha)(e.name);(0,S.notBlank)(r)?(e.maybeUpsertDisplayName(r),i.info("updated tag",{id:e.id,path:e.path,displayName:r}),C.Tag.clear()):i.debug("cannot update tag: no current volume.",{id:e.id,path:e.path})}(0,_.later)((()=>{(0,d.ee)().on("clearCache",R),m.Settings.libraryDir.watchLater(R)})),t.fixFileRootTag=N,t.displayNameForVolsha=(0,u.memoizeAsync)((async e=>{const t=(0,a.mkLogger)("displayNameForVolsha("+e+")"),i=await(0,b.volumes)();if(null!=i){const r=i.find((t=>(0,g.volsha)(t.uuid)===e));return t.info("find()",{vol:r}),null!=r?m.Settings.tagDisplayNameFSLabels.valueOrDefault&&(0,S.notBlank)(r.label)?r.label.trim():"/"===r.mountpoint?m.Settings.tagDisplayNameFSRoot.valueOrDefault+(m.Settings.tagDisplayNameFSRootWithHostname.valueOrDefault?" on "+(0,h.hostname)():""):(0,S.notBlankOr)((0,k.stripPrefixSuffix)(r.mountpoint,{prefix:s.default.sep,suffix:s.default.sep}),s.default.sep):x.AssetFile.dbl.pluckFirstf((t=>t.select("mountpoint").whereLike("uri","psfile://"+e+"/%").limit(1)))}}),{name:"tag.displayNameForVolsha",maxSize:64,timeoutMs:(0,w.volumeMetadataTtlMs)()}),(0,_.later)((()=>{v.mountpoints.watch((()=>t.displayNameForVolsha.clear()))}))},90858:e=>{"use strict";e.exports=require("@iarna/toml")},53705:e=>{"use strict";e.exports=require("@photostructure/tz-lookup")},64770:e=>{"use strict";e.exports=require("assert")},58587:e=>{"use strict";e.exports=require("batch-cluster")},87550:e=>{"use strict";e.exports=require("better-sqlite3")},6858:e=>{"use strict";e.exports=require("commander")},36507:e=>{"use strict";e.exports=require("croner")},66261:e=>{"use strict";e.exports=require("events")},77988:e=>{"use strict";e.exports=require("exiftool-vendored")},66150:e=>{"use strict";e.exports=require("fast-xml-parser")},68817:e=>{"use strict";e.exports=require("file-type")},44652:e=>{"use strict";e.exports=require("fs-extra")},28787:e=>{"use strict";e.exports=require("he")},31832:e=>{"use strict";e.exports=require("knex")},51168:e=>{"use strict";e.exports=require("luxon")},93973:e=>{"use strict";e.exports=require("ml-kmeans")},4927:e=>{"use strict";e.exports=require("papaparse")},83058:e=>{"use strict";e.exports=require("picomatch")},22915:e=>{"use strict";e.exports=require("platform-folders")},57272:e=>{"use strict";e.exports=require("plist")},90595:e=>{"use strict";e.exports=require("punycode")},38064:e=>{"use strict";e.exports=require("semver")},9288:e=>{"use strict";e.exports=require("sharp")},93944:e=>{"use strict";e.exports=require("source-map-support")},49378:e=>{"use strict";e.exports=require("trash")},73872:e=>{"use strict";e.exports=require("type-detect")},92460:e=>{"use strict";e.exports=require("util")},75162:e=>{"use strict";e.exports=require("util/types")},76982:e=>{"use strict";e.exports=require("crypto")},34589:e=>{"use strict";e.exports=require("node:assert")},31421:e=>{"use strict";e.exports=require("node:child_process")},77598:e=>{"use strict";e.exports=require("node:crypto")},40610:e=>{"use strict";e.exports=require("node:dns")},78474:e=>{"use strict";e.exports=require("node:events")},73024:e=>{"use strict";e.exports=require("node:fs")},51455:e=>{"use strict";e.exports=require("node:fs/promises")},37067:e=>{"use strict";e.exports=require("node:http")},44708:e=>{"use strict";e.exports=require("node:https")},77030:e=>{"use strict";e.exports=require("node:net")},48161:e=>{"use strict";e.exports=require("node:os")},76760:e=>{"use strict";e.exports=require("node:path")},53916:e=>{"use strict";e.exports=require("node:path/posix")},1708:e=>{"use strict";e.exports=require("node:process")},57075:e=>{"use strict";e.exports=require("node:stream")},46466:e=>{"use strict";e.exports=require("node:stream/promises")},87997:e=>{"use strict";e.exports=require("node:timers")},57975:e=>{"use strict";e.exports=require("node:util")},38522:e=>{"use strict";e.exports=require("node:zlib")},16928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=86801);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/bin/list.js b/bin/list.js index b35f2cd..adb4d42 100755 --- a/bin/list.js +++ b/bin/list.js @@ -6,4 +6,4 @@ * IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THIS SOFTWARE */ -(()=>{var __webpack_modules__={60308:e=>{const t={PasetoNotSupported:"ERR_PASETO_NOT_SUPPORTED",PasetoDecryptionFailed:"ERR_PASETO_DECRYPTION_FAILED",PasetoInvalid:"ERR_PASETO_INVALID",PasetoVerificationFailed:"ERR_PASETO_VERIFICATION_FAILED",PasetoClaimInvalid:"ERR_PASETO_CLAIM_INVALID"};class i extends Error{constructor(e){super(e),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}e.exports.PasetoError=i,e.exports.PasetoNotSupported=class extends i{},e.exports.PasetoDecryptionFailed=class extends i{},e.exports.PasetoInvalid=class extends i{},e.exports.PasetoVerificationFailed=class extends i{},e.exports.PasetoClaimInvalid=class extends i{}},78972:(e,t,i)=>{const{PasetoInvalid:r,PasetoNotSupported:s}=i(60308),{decode:n}=i(47859),a=i(40816);e.exports=(e,{parse:t=!0}={})=>{if("string"!=typeof e)throw new TypeError("token must be a string");const{0:i,1:o,2:l,3:u,length:c}=e.split(".");if(3!==c&&4!==c)throw new r("token is not a PASETO formatted value");if("v1"!==i&&"v2"!==i&&"v3"!==i&&"v4"!==i)throw new s("unsupported PASETO version");if("local"!==o&&"public"!==o)throw new s("unsupported PASETO purpose");const d={footer:u?n(u):void 0,payload:void 0,version:i,purpose:o};if("local"===o)return d;const h="v1"===i?256:"v3"===i?96:64;let f;try{f=n(l).subarray(0,-h)}catch{throw new r("token is not a PASETO formatted value")}return d.payload=t?a(f):f,d}},2744:(e,t,i)=>{const r=i(78972);e.exports={decode:r}},67814:(e,t,i)=>{const r=i(85223);e.exports=({audience:e,expiresIn:t,iat:i=!0,issuer:s,jti:n,kid:a,notBefore:o,now:l=new Date,subject:u},c)=>{if(!(l instanceof Date&&l.getTime()))throw new TypeError("options.now must be a valid Date object");const d=l.getTime();if(void 0!==i){if("boolean"!=typeof i)throw new TypeError("options.iat must be a boolean");i&&(c.iat=new Date(d))}if(void 0!==t){if("string"!=typeof t)throw new TypeError("options.expiresIn must be a string");c.exp=new Date(d+r(t))}if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.notBefore must be a string");c.nbf=new Date(d+r(o))}if(void 0!==e){if("string"!=typeof e)throw new TypeError("options.audience must be a string");c.aud=e}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.issuer must be a string");c.iss=s}if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.subject must be a string");c.sub=u}if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.kid must be a string");c.kid=a}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.jti must be a string");c.jti=n}return c}},10968:(e,t,i)=>{const{PasetoClaimInvalid:r}=i(60308),s=i(85223);e.exports=({ignoreExp:e,ignoreNbf:t,ignoreIat:i,maxTokenAge:n,subject:a,issuer:o,clockTolerance:l,audience:u,now:c=new Date},d)=>{if(!(c instanceof Date&&c.getTime()))throw new TypeError("options.now must be a valid Date object");const h=c.getTime();if("iss"in d&&"string"!=typeof d.iss)throw new r("payload.iss must be a string");if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.issuer must be a string");if(d.iss!==o)throw new r("issuer mismatch")}if("sub"in d&&"string"!=typeof d.sub)throw new r("payload.sub must be a string");if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.subject must be a string");if(d.sub!==a)throw new r("subject mismatch")}if("aud"in d&&"string"!=typeof d.aud)throw new r("payload.aud must be a string");if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.audience must be a string");if(d.aud!==u)throw new r("audience mismatch")}if(void 0!==l&&"string"!=typeof l)throw new TypeError("options.clockTolerance must be a string");const f=l?s(l):0;let m;if("iat"in d){if("string"!=typeof d.iat)throw new r("payload.iat must be a string");if(m=new Date(d.iat).getTime(),!m)throw new r("payload.iat must be a valid ISO8601 string");if(!i&&m>h+f)throw new r("token issued in the future")}if("nbf"in d){if("string"!=typeof d.nbf)throw new r("payload.nbf must be a string");const e=new Date(d.nbf).getTime();if(!e)throw new r("payload.nbf must be a valid ISO8601 string");if(!t&&e>h+f)throw new r("token is not active yet")}if("exp"in d){if("string"!=typeof d.exp)throw new r("payload.exp must be a string");const t=new Date(d.exp).getTime();if(!t)throw new r("payload.exp must be a valid ISO8601 string");if(!e&&t<=h-f)throw new r("token is expired")}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.maxTokenAge must be a string");if(!("iat"in d))throw new r("missing iat claim");if(m+s(n){e.exports.encode=e=>e.toString("base64url"),e.exports.decode=e=>Buffer.from(e,"base64")},80608:e=>{e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if("string"!=typeof e)throw new TypeError("options.assertion must be a string, or a Buffer");return Buffer.from(e,"utf8")}},83561:(e,t,i)=>{const r=i(65825);e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if(r(e))return Buffer.from(JSON.stringify(e),"utf8");if("string"!=typeof e)throw new TypeError("options.footer must be a string, Buffer, or a plain object");return Buffer.from(e,"utf8")}},1658:(e,t,i)=>{const r=i(67814),s=i(65825);e.exports=(e,t)=>{if(Buffer.isBuffer(e)){if(0!==Object.keys(t).length)throw new TypeError("options cannot contain claims when payload is a Buffer");return e}if(!s(e))throw new TypeError("payload must be a Buffer or a plain object");return e=(e=>JSON.parse(JSON.stringify(e)))(e),e=r(t,e),Buffer.from(JSON.stringify(e),"utf-8")}},82115:e=>{e.exports=e=>{const{x:t,y:i}=e.export({format:"jwk"}),r=Buffer.from(i,"base64"),s=2+(1&r[r.length-1]);return Buffer.concat([Buffer.alloc(1,s),Buffer.from(t,"base64")])}},88965:(e,t,i)=>{const r=i(64770),{PasetoInvalid:s}=i(60308),n=i(10968),{decode:a}=i(47859),o=i(40816);e.exports={post:function(e,t,i,r,s,a,l){if(t){if(0!==Object.keys(i).length)throw new TypeError("options cannot contain claims when options.buffer is true");return r?{payload:s,footer:a?.length?a:void 0,version:e,purpose:l}:s}const u=o(s);return n(i,u),r?{payload:u,footer:a?.length?a:void 0,version:e,purpose:l}:u},pre:function(e,t){if("string"!=typeof t)throw new TypeError("token must be a string, got: "+typeof t);if(t.slice(0,e.length)!==e)throw new s(`token is not a ${e.slice(0,e.length-1)} PASETO`);let{0:i,1:n="",length:o}=t.slice(e.length).split(".");try{r(o<=2),i=a(i),n=a(n)}catch{throw new s("token is not a PASETO formatted value")}return{raw:i,f:n}}}},56463:(e,t,i)=>{const r=i(76982),s=i(92460),n=i(70761),a=i(29534),{PasetoDecryptionFailed:o}=i(60308),l=i(82682),{webcrypto:{subtle:u}}=r,c=s.promisify(r.hkdf),d=Buffer.from("paseto-encryption-key"),h=Buffer.from("paseto-auth-key-for-aead"),f=Buffer.alloc(0),m=(e,t)=>r.createHmac("sha384",t).update(e).digest(),p=async(e,t,i,r)=>u[e]({name:"AES-CTR",counter:r,length:16},await u.importKey("raw",i,"AES-CTR",!1,[e]),t).then(Buffer.from),g=p.bind(void 0,"encrypt"),y=p.bind(void 0,"decrypt");e.exports={sign:s.promisify(r.sign),verify:s.promisify(r.verify),"v1.local-encrypt":async function(e,t,i){const s="v1.local.",o=m(e,r.randomBytes(32)).subarray(0,32),l=o.subarray(0,16),[u,f]=await Promise.all([c("sha384",i,l,d,32).then(Buffer.from),c("sha384",i,l,h,32).then(Buffer.from)]),p=await g(e,u,o.subarray(16)),y=n(s,o,p,t),w=m(y,f);return a(s,t,o,p,w)},"v1.local-decrypt":async function(e,t,i){const r=e.subarray(0,32),s=e.subarray(-48),a=e.subarray(32,-48),u=r.subarray(0,16),[f,p]=await Promise.all([c("sha384",i,u,d,32).then(Buffer.from),c("sha384",i,u,h,32).then(Buffer.from)]),g=n("v1.local.",r,a,t),w=m(g,p);if(!l(s,w))throw new o("decryption failed");const v=await y(a,f,r.subarray(16));if(!v)throw new o("decryption failed");return v},"v3.local-encrypt":async function(e,t,i,s){const o="v3.local.",l=r.randomBytes(32),[u,p]=await Promise.all([c("sha384",i,f,Buffer.concat([d,l]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,l]),48).then(Buffer.from)]),y=u.subarray(0,32),w=u.subarray(32),v=await g(e,y,w),b=n(o,l,v,t,s),S=m(b,p);return a(o,t,l,v,S)},"v3.local-decrypt":async function(e,t,i,r){const s=e.subarray(0,32),a=e.subarray(-48),u=e.subarray(32,-48),[p,g]=await Promise.all([c("sha384",i,f,Buffer.concat([d,s]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,s]),48).then(Buffer.from)]),w=p.subarray(0,32),v=p.subarray(32),b=n("v3.local.",s,u,t,r),S=m(b,g);if(!l(a,S))throw new o("decryption failed");const P=await y(u,w,v);if(!P)throw new o("decryption failed");return P}}},70981:(e,t,i)=>{const{KeyObject:r}=i(76982);let{isKeyObject:s}=i(75162);s||(s=e=>null!=e&&e instanceof r),e.exports=s},65825:e=>{e.exports=e=>!!e&&e.constructor===Object},41726:(e,t,i)=>{const{PasetoNotSupported:r}=i(60308);e.exports=e=>{if(!Number.isSafeInteger(e))throw new r("message is too long for Node.js to safely process");const t=~~(e/4294967295),i=e%4294967295-t,s=Buffer.allocUnsafe(8);return s.writeUInt32LE(t,4),s.writeUInt32LE(i,0),s}},85223:e=>{const t=36e5,i=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;e.exports=e=>{const r=i.exec(e);if(!r)throw new TypeError(`invalid time period format ("${e}")`);const s=parseFloat(r[1]);switch(r[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(1e3*s);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(6e4*s);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(s*t);case"day":case"days":case"d":return Math.round(864e5*s);case"week":case"weeks":case"w":return Math.round(6048e5*s);case"year":case"years":case"yr":case"yrs":case"y":return Math.round(315576e5*s)}}},29534:(e,t,i)=>{const{encode:r}=i(47859);e.exports=function(e,t,...i){let s=`${e}${r(Buffer.concat(i))}`;return t.byteLength&&(s+=`.${r(t)}`),s}},70761:(e,t,i)=>{const r=i(41726);e.exports=(...e)=>{e=e.filter(Boolean);let t=r(e.length);for(let i of e){i=Buffer.from(i,"utf8");const e=r(Buffer.byteLength(i));t=Buffer.concat([t,e,i])}return t}},40816:(e,t,i)=>{const{PasetoInvalid:r}=i(60308),{strict:s}=i(64770),n=i(65825);e.exports=e=>{try{const t=JSON.parse(e);return s(n(t)),t}catch{throw new r("All PASETO payloads MUST be a JSON object")}}},92366:(e,t,i)=>{const{sign:r}=i(56463),s=i(70761),n=i(29534);e.exports=async function(e,t,i,a,o,l,u){const c=s(u,e,t,i,l),d=await r(a,c,o);return n(e,i,t,d)}},495:(e,t,i)=>{const{createSecretKey:r}=i(76982),s=i(70981);e.exports=function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}`)&&(t=Buffer.from(t.slice(e.length),"base64url")),!s(t))try{t=r(t)}catch{}if(!s(t))throw new TypeError("invalid key provided");if("secret"!==t.type||32!==t.symmetricKeySize)throw new TypeError(`${e} secret key must be 32 bytes long symmetric key`);return t}},82682:(e,t,i)=>{const{timingSafeEqual:r}=i(76982),s=(e,t)=>{if(e.length===t)return e;const i=Buffer.alloc(t);return e.copy(i),i};e.exports=(e,t)=>{const i=Math.max(e.length,t.length);return r(s(e,i),s(t,i))}},49826:(e,t,i)=>{const{PasetoVerificationFailed:r}=i(60308),{verify:s}=i(56463),n=i(70761),{pre:a}=i(88965);e.exports=async function(e,t,i,o,l,u,c){const{raw:d,f:h}=a(e,t),f=d.subarray(0,-o),m=d.subarray(-o),p=n(c,e,f,h,u);if(!await s(i,p,l,m))throw new r("invalid signature");return{m:f,footer:h.length?h:void 0}}},91227:(e,t,i)=>{const r=i(60308),s=i(79665),n=i(56120),a=i(50015),o=i(64230),{decode:l}=i(2744);e.exports={decode:l,V1:s,V2:n,V3:a,V4:o,errors:r}},39324:(e,t,i)=>{const{"v1.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v1.local"),{pre:n,post:a}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:o=!1,...l}={}){const{raw:u,f:c}=n("v1.local.",e),d=(t=s(t)).export(),h=await r(u,c,d);return a("v1",o,l,i,h,c,"local")}},21472:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v1.local"),n=i(1658),{"v1.local-encrypt":a}=i(56463);e.exports=async function(e,t,{footer:i,...o}={}){const l=n(e,o);t=s(t);const u=r(i),c=t.export();return a(l,u,c)}},79665:(e,t,i)=>{const r=i(77868),s=i(77256),n=i(21472),a=i(39324),o=i(70866);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o}},70866:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=s(r.generateKeyPair),o=s(r.generateKey);e.exports=async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await o("aes",{length:256});return"paserk"===t?`k1.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await a("rsa",{modulusLength:2048});return"paserk"===t?{secretKey:`k1.secret.${e.export({format:"der",type:"pkcs1"}).toString("base64url")}`,publicKey:`k1.public.${i.export({format:"der",type:"pkcs1"}).toString("base64url")}`}:e}default:throw new n("unsupported v1 purpose")}}},77868:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPrivateKey:n}=i(76982),a=i(83561),o=i(1658),l=i(92366),u=i(70981);e.exports=async function(e,t,{footer:i,...c}={}){const d=o(e,c),h=a(i);return t=function(e){if("string"==typeof e&&e.startsWith("k1.secret."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!u(e))try{e=n(e)}catch{}if(!u(e))throw new TypeError("invalid key provided");if("private"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public signing key must be a private RSA key with 2048 bit modulus length");return e}(t),l("v1.public.",d,h,"sha384",{key:t,padding:r,saltLength:s})}},77256:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPublicKey:n}=i(76982),a=i(49826),o=i(70981),{post:l}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:u=!1,...c}={}){t=function(e){if("string"==typeof e&&e.startsWith("k1.public."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!o(e)||"private"===e.type)try{e=n(e)}catch{}if(!o(e))throw new TypeError("invalid key provided");if("public"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public verify key must be a public RSA key with 2048 bit modulus length");return e}(t);const{m:d,footer:h}=await a("v1.public.",e,"sha384",256,{key:t,padding:r,saltLength:s});return l("v1",u,c,i,d,h,"public")}},56120:(e,t,i)=>{const r=i(88451),s=i(859),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(62827);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},62827:(e,t,i)=>{const r=i(64770),s=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:a}=i(60308),o=i(70981),l=n(s.generateKeyPair);async function u(e,t,{format:i="keyobject"}={}){if("keyobject"!==i&&"paserk"!==i)throw new TypeError("invalid format");if("public"===t){const{privateKey:t,publicKey:r}=await l("ed25519");return"paserk"===i?{secretKey:`k${e.slice(1)}.secret.${h(t).toString("base64url")}`,publicKey:`k${e.slice(1)}.public.${h(r).toString("base64url")}`}:t}throw new a(`unsupported ${e} purpose`)}function c(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 64:{const t=s.createPrivateKey({key:Buffer.concat([Buffer.from("302e020100300506032b657004220420","hex"),e.subarray(0,32)]),format:"der",type:"pkcs8"});if(!e.subarray(32).equals(Buffer.from(t.export({format:"jwk"}).x,"base64")))throw new TypeError("invalid byte sequence");return t}case 32:return s.createPublicKey({key:Buffer.concat([Buffer.from("302a300506032b6570032100","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 64 bytes (private key), or 32 bytes (public key)")}}function d(e,t){if(!o(t))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public key must be an Ed25519 key`);switch(t.type){case"public":return Buffer.from(t.export({format:"jwk"}).x,"base64");case"private":{const{d:e,x:i}=t.export({format:"jwk"});return Buffer.concat([Buffer.from(e,"base64"),Buffer.from(i,"base64")])}}}function h(...e){return d("v2",...e)}e.exports={_checkPrivateKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.secret.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,64)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t))try{t=s.createPrivateKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("private"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public signing key must be a private ed25519 key`);return t},_checkPublicKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.public.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,32)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t)||"private"===t.type)try{t=s.createPublicKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("public"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public verify key must be a public ed25519 key`);return t},_generateKey:u,_keyObjectToBytes:d,bytesToKeyObject:c,generateKey:async function(...e){return u("v2",...e)},keyObjectToBytes:h}},88451:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(92366),{_checkPrivateKey:a}=i(62827),o=a.bind(void 0,"v2");e.exports=async function(e,t,{footer:i,...a}={}){const l=s(e,a);t=o(t);const u=r(i);return n("v2.public.",l,u,void 0,t)}},859:(e,t,i)=>{const r=i(49826),{_checkPublicKey:s}=i(62827),{post:n}=i(88965),a=s.bind(void 0,"v2");e.exports=async function(e,t,{complete:i=!1,buffer:s=!1,...o}={}){t=a(t);const{m:l,footer:u}=await r("v2.public.",e,void 0,64,t);return n("v2",s,o,i,l,u,"public")}},18582:(e,t,i)=>{const{"v3.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v3.local"),n=i(80608),{pre:a,post:o}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:l=!1,assertion:u,...c}={}){const{raw:d,f:h}=a("v3.local.",e);t=s(t);const f=n(u),m=t.export(),p=await r(d,h,m,f);return o("v3",l,c,i,p,h,"local")}},43406:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v3.local"),n=i(1658),a=i(80608),{"v3.local-encrypt":o}=i(56463);e.exports=async function(e,t,{footer:i,assertion:l,...u}={}){const c=n(e,u);t=s(t);const d=r(i),h=a(l),f=t.export();return o(c,d,f,h)}},50015:(e,t,i)=>{const r=i(42438),s=i(65466),n=i(43406),a=i(18582),{generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}=i(80568);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}},80568:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=i(70981),o=i(82115),l=s(r.generateKeyPair),u=s(r.generateKey);function c(e){if(!a(e))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public key must be an EC P-384 key");switch(e.type){case"public":return o(e);case"private":return Buffer.from(e.export({format:"jwk"}).d,"base64")}}e.exports={generateKey:async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await u("aes",{length:256});return"paserk"===t?`k3.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await l("ec",{namedCurve:"P-384"});return"paserk"===t?{secretKey:`k3.secret.${c(e).toString("base64url")}`,publicKey:`k3.public.${c(i).toString("base64url")}`}:e}default:throw new n("unsupported v3 purpose")}},bytesToKeyObject:function(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 48:return r.createPrivateKey({key:Buffer.concat([Buffer.from("303e0201010430","hex"),e,Buffer.from("a00706052b81040022","hex")]),format:"der",type:"sec1"});case 49:if(2!==e[0]&&3!==e[0])throw new TypeError("invalid compressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3046301006072a8648ce3d020106052b81040022033200","hex"),e]),format:"der",type:"spki"});case 97:if(4!==e[0])throw new TypeError("invalid uncompressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3076301006072a8648ce3d020106052b81040022036200","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 48 bytes (private key), 49 bytes (compressed public key), or 97 bytes (uncompressed public key)")}},keyObjectToBytes:c}},42438:(e,t,i)=>{const{createPrivateKey:r}=i(76982),s=i(83561),n=i(1658),a=i(80608),o=i(92366),l=i(70981),{bytesToKeyObject:u}=i(80568),c=i(82115);e.exports=async function(e,t,{footer:i,assertion:d,...h}={}){const f=n(e,h),m=s(i),p=a(d);return t=function(e){if("string"==typeof e&&e.startsWith("k3.secret."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,48)}catch{}if(Buffer.isBuffer(e))try{e=u(e)}catch{}if(!l(e))try{e=r(e)}catch{}if(!l(e))throw new TypeError("invalid key provided");if("private"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public signing key must be a private EC P-384 key");return e}(t),o("v3.public.",f,m,"sha384",{key:t,dsaEncoding:"ieee-p1363"},p,c(t))}},65466:(e,t,i)=>{const{createPublicKey:r}=i(76982),s=i(80608),n=i(49826),a=i(70981),{bytesToKeyObject:o}=i(80568),l=i(82115),{post:u}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:c=!1,assertion:d,...h}={}){t=function(e){if("string"==typeof e&&e.startsWith("k3.public."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,49)}catch{}if(Buffer.isBuffer(e))try{e=o(e)}catch{}if(!a(e)||"private"===e.type)try{e=r(e)}catch{}if(!a(e))throw new TypeError("invalid key provided");if("public"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public verify key must be a public EC P-384 key");return e}(t);const f=s(d),{m,footer:p}=await n("v3.public.",e,"sha384",96,{key:t,dsaEncoding:"ieee-p1363"},f,l(t));return u("v3",c,h,i,m,p,"public")}},64230:(e,t,i)=>{const r=i(29901),s=i(77933),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(24961);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},24961:(e,t,i)=>{const{_checkPrivateKey:r,_checkPublicKey:s,_generateKey:n,_keyObjectToBytes:a,bytesToKeyObject:o}=i(62827);e.exports={_checkPrivateKey:r,_checkPublicKey:s,bytesToKeyObject:o,generateKey:async function(...e){return n("v4",...e)},keyObjectToBytes:function(...e){return a("v4",...e)}}},29901:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(80608),a=i(92366),{_checkPrivateKey:o}=i(24961),l=o.bind(void 0,"v4");e.exports=async function(e,t,{footer:i,assertion:o,...u}={}){const c=s(e,u),d=n(o);t=l(t);const h=r(i);return a("v4.public.",c,h,void 0,t,d)}},77933:(e,t,i)=>{const r=i(80608),s=i(49826),{_checkPublicKey:n}=i(24961),{post:a}=i(88965),o=n.bind(void 0,"v4");e.exports=async function(e,t,{complete:i=!1,buffer:n=!1,assertion:l,...u}={}){t=o(t);const c=r(l),{m:d,footer:h}=await s("v4.public.",e,void 0,64,t,c);return a("v4",n,u,i,d,h,"public")}},37975:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),s=i(38639),n=i(44198);function a(){return(0,s.toNotBoolean)((0,n.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,n.env)().NO_COLOR)||["dumb","unknown"].includes((0,n.env)().TERM))}t.noColor=a;let o=!a();function l(){return o}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){o=e??!a()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),s=i(7282),n=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,s.isProd)()?"":`-${(0,s.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+n.version))},48884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),s=i(36783),n=i(76790),a=i(22573),o=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const s=new Set(t.map(i));return e.filter((e=>s.has(i(e))))}function w(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...w(e.slice(i+1))]}function v(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function b(e){return P(e,(e=>e.valueOf()))}function S(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function T(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,i){return E(e,t,i).index}function E(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let s,n=-1;for(let r=0;re.slice(i,i+t)))}async function x(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,o.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(a.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,o.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,s.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let s=0;for(const n of e)(t(n,s++)?i:r).push(n);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return w(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=v,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let s=0;se.slice(0,t+1)))},t.min=function(e){return e[b(e)]},t.leastIndex=b,t.max=function(e){return e[S(e)]},t.greatestIndex=S,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=T,t.least=function(e){return T(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const i=E(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=D,t.collectBatched=function(e,t,i){const s=[];for(const n of D((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(i(n)));return s},t.collectBatchedAsync=async function(e,t,i){const s=[];for(const n of D((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(await i(n)));return s},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await x(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+s;if(re+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const o=i(77988),l=a(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),w=i(25764),v=i(38836),b=i(99331),S=i(95937),P=i(98314),_=i(38835),T=i(70025),M=i(8769),E=i(43334),D=i(95402),x=i(28874),k=i(63870);class C extends v.EndableWrapper{constructor(e,t,i=w.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>n(this,r,"m",s).call(this)),i,"worker"===e?(0,k.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const a=t;a.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,D.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),a.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),a.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,S.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),a.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),a.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),a.on("noTaskData",((e,i,r)=>{const s=t.options.streamFlushMillis;s{this.logger.error("observeBatchCluster.endError()",e)})),a.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&D.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof o.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,b.ending)()||!0===(0,T.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=C,r=new WeakSet,s=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(E.isWin?3:1)*c.minuteMs,maxTasksPerProcess:x.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:x.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:x.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:x.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:x.Settings.taskTimeoutMs.valueOrDefault}}},71371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedGreatestSet=void 0;const r=i(92322);t.BoundedGreatestSet=class{constructor(e,t){this.maxLength=e,this.toValue=t,this.sortedArray=new r.SortedSet(t)}toA(){return this.vacuum(),this.sortedArray.toA()}vacuum(){return this.sortedArray.retainLastN(this.maxLength)}add(...e){this.maxLength<=0||(this.sortedArray.addAll(...e),this.sortedArray.length>=2*this.maxLength&&this.vacuum())}}},89788:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(r.add(this),this.maxLength=e,s.set(this,void 0),n.set(this,0),a.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,s,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]=t))}get length(){return u(this,n,"f")}set length(e){l(this,n,(0,d.clamp)(0,u(this,n,"f"),e),"f")}clear(){this.length=0}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,n,"f")),e<0||e>=u(this,n,"f")?void 0:t((e+u(this,a,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,s,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,n,"f"){u(this,s,"f")[e]=c}));return u(this,n,"f")}pop(){return u(this,r,"m",o).call(this,u(this,n,"f")-1,(e=>{var t;return l(this,n,(t=u(this,n,"f"),--t),"f"),u(this,s,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,n,"f"){u(this,s,"f")[e]=c,l(this,a,e,"f")}));return u(this,n,"f")}shift(){return u(this,r,"m",o).call(this,0,(e=>{var t,i;return l(this,a,(t=u(this,a,"f"),++t),"f"),l(this,n,(i=u(this,n,"f"),--i),"f"),u(this,s,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",o).call(this,u(this,n,"f")-1-e,(e=>{const i=u(this,s,"f")[e];u(this,s,"f")[e]=u(this,s,"f")[t],u(this,s,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),s=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function n(e){for(const{bom:t,encoding:i}of s)if(a(e,t))return e.subarray(t.length).toString(i);return e.toString()}function a(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=n,t.bufferToString=function(e){return Buffer.isBuffer(e)?n(e):(0,r.toS)(e)},t.bufferStartsWith=a},9092:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=s},36638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=s},40583:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const a=i(40958),o=i(23838),l=n(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new o.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,a.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,s=-1;for(const[i,n]of this.m.entries()){const a=(0,c.diceCoeff)(i,e);if(a>t&&a>s){const e=this.getFirst(n);null!=e&&(r=e,s=a)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),s=i(31586),n=i(68708),a=i(54993),o=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new o.Average(0);for(const t of this.keys()){if(!(0,s.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,a.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,s.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,n.tap)(new o.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,s]of this.m.entries()){const n=e(r);t.fill(n,i,i+s),i+=s}return t}}t.CountingSet=u},79840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),s=i(72993),n=i(45969),a=i(43334);t.EditionType=(0,r.lazy)((()=>a.isElectron?"Desktops":(0,n.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>s.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),s=i(55835),n=i(68708);var a=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return a.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,s.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.omit)(e,...i),(0,n.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,s.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),s=i(19851),n=i(95696);t.examples=(0,s.lazy)((()=>n.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),s=i(65843),n=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,s.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,n.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(31586),o=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,a.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,a.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,s.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,s.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,n.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,o.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,o.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,o.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,a.isNumber)(e.__uid)&&(0,a.isNumber)(e.__start)}},80049:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),s.set(this,0),n.set(this,0),a.set(this,0),o.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,s,l(this,s,"f")+e.cacheHitsAsync,"f"),u(this,n,l(this,n,"f")+e.cacheMisses,"f"),u(this,a,l(this,a,"f")+e.rejections,"f"),u(this,o,l(this,o,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,s,"f"),cacheMisses:l(this,n,"f"),rejections:l(this,a,"f"),timeouts:l(this,o,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,a,o;if(!this.cache.has(e))return void u(this,n,(t=l(this,n,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,s,(i=l(this,s,"f"),++i),"f"),c.promise):(u(this,r,(a=l(this,r,"f"),++a),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(o=l(this,r,"f"),++o),"f"),c}get(e){var t,i;const s=this.cache.get(e);return null==s||s instanceof m.Deferred&&s.isPending?u(this,n,(t=l(this,n,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),s instanceof m.Deferred?s.value:s}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,s,0,"f"),u(this,n,0,"f"),u(this,a,0,"f"),u(this,o,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,a,(t=l(this,a,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,o,(r=l(this,o,"f"),++r),"f")})),r.promise}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap},54127:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,a.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,s.range)(0,r).filter((e=>this.rows.every((t=>(0,n.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,o.fromEntries)(e))).filter((e=>(0,o.values)(e).some(n.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,o=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(o,r.index);(0,n.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),h=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:h});else{const e=(0,s.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,a.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}o=t.lastIndex}const l=(0,s.last)(i);return null!=l&&((0,n.blank)(this.headerRow.slice(o))?l.rightIdx=(0,a.max_)(...this.rows.map((e=>e.length))):l.rightIdx=o),i}}t.Fixed=m},73168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const r=i(55835),s=i(20014),n=i(55222),a=i(97352),o=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,a.within)(-90,90,e)&&0!==e}function c(e){return(0,a.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function h(e,t,i=o){return(0,r.map)(m(e,t,l(i)),(e=>n.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=o){return h(e?.lat,e?.lon,t)},t.geohash=h,t.geohashNumericShort=function(e,t){return m(e,t,30)};const f=new s.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=o){return d(e,t)?f.zip([t,e],l(i)):void 0}function p(e,t=o){return f.unzip(e,l(t))?.reverse()}function g(e,t=o){const[i,r]=p(e,t);return{lat:i,lon:r}}t.geohashNumeric=m,t.ungeohash=function(e,t=o){return(0,r.map)(n.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,r=t.lat*Math.PI/180,s=(t.lat-e.lat)*Math.PI/180,n=(t.lon-e.lon)*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(r)*Math.sin(n/2)*Math.sin(n/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},66364:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSuspended=void 0;const r=i(19851);t.isSuspended=(0,r.lazy)((()=>!1))},80875:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),s=i(98553);var n=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return n.parseJSON}}),t.mapParsed=function(e,t){const i=(0,s.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,s.parseJSON)((await(0,r.readFile)(e)).toString())}},57206:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDefaultJsonRevivers=void 0;const r=i(77988),s=i(51168),n=i(45599),a=i(98553),o=i(68708),l=i(24689),u=i(21330),c=i(57159),d=i(28544),h=(0,n.defer)((()=>{s.DateTime.prototype.toJSON=function(){return(0,o.compactValues)({_ctor:s.DateTime.name,ts:this.toMillis(),zone:"system"===this.zone?.type?void 0:this.zoneName})}})),f={name:s.DateTime.name,fromJSON:e=>s.DateTime.fromMillis(e.ts,(0,o.compactValues)({zone:e.zone}))};t.addDefaultJsonRevivers=(0,n.defer)((()=>{h(),(0,a.addJsonRevivers)(r.ExifDateTime,r.ExifDate,r.ExifTime,f,d.CapturedAt,l.DateInterval,u.FuzzyDate,r.BinaryField,c.WrappedError)}))},19851:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const a=i(57975),o=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&n(this,r,"m",s).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,o.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,o.mkLogger)("Locale")));function w(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=b(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>S(w()??await(m.isWin?P():m.isMac?T():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(w);const v=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function b(e){if((0,n.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=v.exec(e.trim())?.groups;return null==i?void 0:(0,s.compact)([i.lang,i.country]).join("-")}function S(e){return b(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=S,t.localeWin=P;const _={timeoutMs:10*a.secondMs};async function T(){return b(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return S(w((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=T,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),s=i(1708),n=i(45599),a=i(68708),o=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,n.defer)((()=>{(0,o.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:s.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,a.pick)(s.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:s.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),s=i(32105),n=i(14593);t.rootLoggers=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));const a=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));t.mkLogger=function(e){return new n.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new n.ContextualLogger(e,a)}},56639:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),s=i(55835),n=i(59455),a=i(48884);function o(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,a.concat)(...e.map((e=>t(e)))))},t.compactMap=o,t.toMap=function(e,t){return o((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:o(await Promise.all((0,r.compact)((0,n.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,s.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),s=i(54557);t.memoize=function(e,t){let i=0;const n=new s.FifoCache(t.maxSize,t.ttlMs),a=t=>{if(null!=t)return i++,n.getOrSet((0,r.stringify)(t),(()=>e(t)))};return a.clear=e=>null==e?n.clear():n.delete((0,r.stringify)(e)),a.size=()=>n.size,a.callCount=()=>i,a}},31578:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const r=i(1708),s=i(31586),n=i(12168),a=i(70417);function o(){const e=(0,r.memoryUsage)();return(0,a.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,r.memoryUsage)().rss}t.memoryUsageBytes=o,t.memoryUsageMb=function(){return(0,s.sigFigs)(o()/n.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,s.sigFigs)(l()/n.MB,2)}},7282:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const s=r(i(1708)),n=i(38639),a=i(54993),o=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,o.lazy)((()=>s.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,a.toS)(s.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return s.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,n.isTrue)(s.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){s.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55835),o=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,o.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(o.gt0)},t.firstNonZero=function(...e){for(const t of(0,n.flatten)(e)){const e=(0,o.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,a.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,o.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,o.toInt)(e),s=(0,o.toInt)(t);return null!=r&&r>0&&null!=s&&s>0?i(r,s):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,o.isNumber)(e))return e;if((0,s.blank)(e))return;const t=String(e);return(0,a.map)(f.exec(t),(e=>(0,o.toFloat)(t.substr(e.index))))}function p(e){return(0,o.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,a.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,a.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const s=i*e.length;for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),s=i(42659),n=i(96249),a=i(55835),o=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,s.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,s]of(0,l.entries)(e)){const e=t(r,s);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,a.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(a.defined)},t.firstDefinedField=function(e,...t){return(0,a.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,a.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const s of t)r[s]=i(s,e[s]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let s=0;for(const n of(0,l.keys)(e))if(r[n]=t(n,e[n]),s++,(0,o.gt)(s,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,n.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),s=i(73024),n=i(48161),a=i(19851),o=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),w=i(30933),v=(0,a.lazy)((()=>(0,f.mkLogger)("os")));function b(){return(0,n.platform)()+" "+(0,n.release)()}t.osArch=(0,a.lazy)((()=>`${function(){switch((0,n.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return C();case"win32":return F();default:return b()}}()} on ${(0,n.arch)()}`)),t.osFullName=(0,a.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const S=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function _(){return"ubuntu"===(0,t.osDistributionLinux)()}function T(){return"fedora"===(0,t.osDistributionLinux)()}function M(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,a.lazy)((()=>{if(g.isLinux)for(const e of S)try{const t=(0,s.readFileSync)(e).toString();if((0,o.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){v().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,a.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,o.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),b)})),t.osDistributionLinux=(0,a.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=_,t.hasApt=function(){return P()||_()},t.isFedora=T,t.isAlpine=M;const E={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},D={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function x(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),s=t[i];return(0,c.isString)(s)?s:s?.[r]}const k=(0,a.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function C(e=k()){try{return(0,o.mapNotBlankOr)(function(e=k()){return x(e,E)}(e),(t=>`macOS ${t} (${e})`),b)}catch(e){return v().warn("osNameMac(): unknown release",e),b()}}function F(e=(0,n.release)()){const t=e.startsWith("10.0.22")?"11":x(e,D);return null!=t?`Windows ${t} (${e})`:(v().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=C,t.osNameWin=F,t.CPUs=(0,a.lazy)((()=>(0,h.uniqCount)((0,w.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,a.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(F())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=k();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(_())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(T())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(M())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},45393:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetVersion=t.AssetFileVersion=void 0,t.AssetFileVersion=12,t.AssetVersion=4},12801:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const s=r(i(48161)),n=i(50989);t.PriorityClasses=(0,n.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:s.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:s.default.constants.priority.PRIORITY_NORMAL,BelowNormal:s.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:s.default.constants.priority.PRIORITY_LOW,Low:s.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setProcessTitle=t.setShortProcessNames=void 0;const r=i(72993),s=i(50213),n=i(23560),a=i(43334);let o=!a.isElectron;t.setShortProcessNames=function(e){o=e},t.setProcessTitle=function(){try{const e=[o?r.SimpleShortAppName:r.SimpleAppName];(0,n.isMainService)()&&a.isElectron||e.push((0,n.serviceName)());const t=e.join(a.isElectron?" ":"-");i(85949).title=t}catch(e){(0,s.mkLogger)("ServiceNames").warn("Failed to set friendly process name",e)}}},92782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeRandomUid=t.safeRandomChars=void 0;const r=i(55222),s=i(65713);t.safeRandomChars=function({radix:e=r.TokenRadix,length:t}){return(0,s.decuss)((()=>e.randomChars(t)))},t.safeRandomUid=function(e){return(0,s.decuss)((()=>(e?.radix??r.TokenRadix).randomUid(e?.chars??20,e?.splitEveryN??5,e?.sepChar??"-")))}},409:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),s=i(56409),n=i(31586),a=i(22911),o=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,v(...e)}}async function w(...r){f=!0,m=Date.now()+(0,n.max_)(t,i);const s=d=new a.Deferred(c);(0,n.gt0)(i)&&s.setTimeout(i);try{s.resolve(await e(...r))}catch(e){s.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,o.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return s.promise}const v=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,r.delay)(1).then((()=>t))}return w(...e)};return v.clear=()=>{h=void 0},v.donePromise=()=>{if(!f)return Promise.resolve();const e=new s.Latch;return p.push(e),e},v.force=async(...e)=>(h=void 0,f&&await v.donePromise(),w(...e)),v.isRateLimited=()=>g(),v.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),v.minCallDelayMs=()=>t,v.setMinCallDelayMs=e=>{t=e},v}},68852:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),s=i(54993);function n(e){return e instanceof a?e.source:(0,s.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let s;for(;null!=(s=e.exec(t));)s.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(s,"index","groups"));return i},t.escapeRegExp=n,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(n(t))}const s=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(s,i)};class a{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=a;class o extends a{static from(...e){const t=l(e);return new o("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,o=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof a||t instanceof RegExp?(i+=t.source,r||(r=t.global),o||(o=t.ignoreCase),l||(l=t.multiline)):i+=n((0,s.toS)(t));return new RegExp(i,t??(r?"g":"")+(o?"i":"")+(l?"m":""))}t.RegExpOptional=o,t.concatRegexp=l},79089:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),w=i(34102),v=i(43334),b=i(24399),S=i(28874),P=(0,a.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,w.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,a.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",n.default.basename(S.Settings.ffmpegPath.valueOrDefault)].map((e=>v.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,o.compactBlanks)([n.default.basename(e),...t.map((e=>n.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let T=!0;const M=(0,a.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const i=(0,p.priorityPosixToClass)(t)??S.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),T)try{return s.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;T=!1}try{return await(v.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await b.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const s=r(i(1708)),n=i(19851),a=i(40958),o=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===o.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===o.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===o.ServiceNames.sync}function p(){return(0,t.serviceName)()===o.ServiceNames.test}t.serviceName=(0,n.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,n.lazy)((()=>(0,a.compactBlanks)([t.serviceName.prior(),(0,l.toS)(s.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return o.ServiceNames.indexOf(e)??o.ServiceNames.length+1},t.MainServices=[o.ServiceNames.main,o.ServiceNames.desktop],t.DbServices=[o.ServiceNames.sync,o.ServiceNames.info,o.ServiceNames.web,o.ServiceNames.list,o.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[o.ServiceNames.sync,o.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===o.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===o.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,n.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function s(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=s,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=s(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=s(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),s=i(57150),n=i(7282),a=i(23560),o=i(17181);t.setServiceName=function(e){(0,a.isMainService)(e)&&(e=r.ServiceNames.main);const t=a.serviceName.prior();t!==e&&((0,n.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),a.serviceName.set(e),(0,o.setupLogger)(),(0,s.logStartup)())}},28850:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const o=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends o.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),s.set(this,void 0),n(this,r,e,"f")}_call(){return(0,l.time)(a(this,r,"f")+(null==a(this,s,"f")?"(local)":"(remote)"),null==a(this,s,"f")?this.impl():a(this,s,"f").call(this))}setShim(e){n(this,s,e,"f")}hasShim(){return null!=a(this,s,"f")}clearShim(){n(this,s,void 0,"f")}}r=new WeakMap,s=new WeakMap},12089:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,a){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=a,s.set(this,void 0),n.set(this,void 0),l(this,s,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",o).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",a).call(this,e),(()=>u(this,r,"m",o).call(this,e)))}setShim(e){l(this,n,e,"f")}hasShim(){return null!=u(this,n,"f")}clearShim(){l(this,n,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",a).call(this,e))}}s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},o=function(e){return(0,m.time)(u(this,s,"f")+(null==u(this,n,"f")?"(local)":"(remote)"),null==u(this,n,"f")?this.impl(e):u(this,n,"f").call(this,e))}},45255:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const n=i(76790),a=i(17586);class o{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return s(this,r,"f")[Symbol.iterator]()}get length(){return s(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=s(this,r,"f").length-1;for(;t<=i;){const n=t+Math.floor((i-t)/2),a=this.valueOf(s(this,r,"f")[n]);if(e===a)return{found:!0,index:n};e>a?t=n+1:i=n-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&s(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...s(this,r,"f")];const a=t=>t<0||t>s(this,r,"f").length-1?null:(i??this.diff)(s(this,r,"f")[t],e),o=this.findIndex(e);if(null==o)return;let l=o.index-1,u=a(l),c=o.index,d=a(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return s(this,r,"f").shift()}at(e){return(0,a.at)(s(this,r,"f"),e)}toA(){return[...s(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===s(this,r,"f").length-1){const e=[...s(this,r,"f")];return s(this,r,"f").length=0,e}return s(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return s(this,r,"f").splice(e,t)}retainLastN(e){return e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),s=i(82328),n=i(84542),a=i(95705),o=i(28874);t.consoleLog=function(e,...t){o.Settings.quiet.valueOrDefault||(0,s.stdoutEnded)()||console.log((0,n.crlf)(e),...t)},t.consoleError=function(e){o.Settings.quiet.valueOrDefault||(0,a.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=o.Settings.quiet.envValue;try{return o.Settings.quiet.envValue=!0,await e()}finally{o.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),s=i(95705);t.stdoutEnded=function(){return(0,s.streamEnded)(r.stdout)}},71567:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const s=r(i(1708)),n=i(22573),a=i(98553),o=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:s.default.stdout})}function f({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const s=(0,a.stringify)(e,void 0,(0,o.isInfoService)()||(0,o.isMainService)()?2:void 0);r.write(s+"\n"),(0,o.isWorkerService)()&&null!=i&&(s.includes(u.FailStr)||(0,c.isFatalError)(s)||(0,c.isHealthCheckError)(s)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||s.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:s.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,n.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const w=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const s=t.indexOf(i,r);return-1===s?0:1+e(t,i,s+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,n.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,o.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,h.toS)(e),s=(0,h.toS)(t);return s.length>0&&(0,c.equalsIgnoreCase)(r.slice(-s.length),s,i)?r.slice(0,-s.length):r},t.gist=function(e,t=80,i=80){const r=(0,h.toS)(e),s=r.length-(t+i);return s<=0?r:r.slice(0,t).trim()+" …(+"+s+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const v=/^[A-Z]/;function b(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function S(e){return(0,d.toA)(e).sort(b)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return v.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,n.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=b,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=S,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,a.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=b(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,n.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),s=t.indexOf(r);if(s>=0)return{index:s,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function T(e){return _.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=T;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,n.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(T(e))&&(e=e.slice(1,-1).trim())),e};const E=/^['‘’].*['‘’]$/,D=/^["“”„«»〃].*["“”„«»〃]$/;function x(e,t){const i=k(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function k(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let s,n=0;for(;null!=(s=t.exec(e));)s.index===t.lastIndex?t.lastIndex++:(t.lastIndex=s[0].length+s.index,i.push(e.substring(n,s.index)),r.push(e.substring(s.index,t.lastIndex)),n=t.lastIndex);return n(0,o.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),E.test(e)||D.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>w.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),s=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,a.map)(i[e],(e=>t+=e))));return t},t.splitKeep=x,t.splitUp=k,t.sortNaturalBy=C,t.sortNatural=function(e){return(0,s.sortBy)(e,(e=>C(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=S((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,s.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,n.blank)(e)||(0,n.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,o.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const F=/#.*$/gm;t.stripComments=function(e){return e.replace(F,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,n.blank)(r))for(const e of r.split(t))(0,n.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,n.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),s=e.findIndex((e=>r.test(e))),a=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(s<0)return e;for(let t=s+1;te.trim()))))}},83556:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function s(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=s,t.asObjectKey=function(e){return s(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const s=r(i(77598)),n=i(73913),a=i(55222);function o(e,t=n.HashBits){return s.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=a.Radix58,r=224){return i.encodeBuffer(o(e,r)).substring(0,t)}t.stringShaToBuffer=o,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=a.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(31586),o=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,s="";for(let n=0;n=r&&(r=i.get(n,a),s=(0,l.substr)(e,n-r+1,r)));return s}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),s=t.normalize();return e!==r||t!==s?y(r,s):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function w(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===r?1:void 0),(()=>(0,n.blank)(e)!==(0,n.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=v(i),t=v(r);return 2*b(e,t).length/(e.length+t.length)}))}function v(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function b(e,t){const i=(0,f.intersection)(e,t),s=[];return i.forEach((i=>{const n=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,a.times)(n,(()=>s.push(i)))})),s}function S(e,t,i){const s=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,s))-i((0,l.strslice)(t,s))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,s.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[i,r]=[e,t].map(P).map((e=>(0,n.blank)(e)?"":e));return S(i,r,(e=>(0,a.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(n.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=w,t.bigrams=v,t.nonUniqIntersection=b,t.lnsDiff=_;const T=/[^\da-z]+/gi;function M(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(T,"").toLowerCase()));return S(i,r,(e=>c.RadixAlphaNum.decode(e)))}function E(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const s=(0,a.mapNumericOr)(e.charCodeAt(r),(e=>e),256),n=(0,a.mapNumericOr)(t.charCodeAt(r),(e=>e),256),o=(0,a.clamp)(-256,256,s-n);i=null==i?o:(i+o)/2}return i}t.radixDiff=M,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:w(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=E,t.paddedPositionalDiff=function(e,t,i=8){return E((0,o.leftPad)(e,i," "),(0,o.leftPad)(t,i," "))}},84885:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),s=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,s.sortedKeys)(e))}},75387:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",s.set(this,[]),n.set(this,new Map),a.set(this,void 0),o.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,a,"f")}set ttlMs(e){h(this,a,e,"f"),null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),h(this,o,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,n,"f").clear(),this}delete(e){return d(this,n,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,n,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,n,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,n,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const s=t();return null!=s&&this.set(e,s),s}lastSetOrGetTs(e){return d(this,n,"f").get(e)?.ts}set(e,t){return d(this,n,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,n,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,n,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,f.sortBy)(d(this,n,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,s,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,n,"f").delete(e);for(const i of d(this,s,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,n,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[a]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return o(this,r,"m",n).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>o(this,r,"m",n).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||o(this,r,"m",s).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)o(this,r,"m",s).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!o(this,r,"m",s).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield[t,t])}()}toA(){return o(this,r,"m",n).call(this),[...this.delegate.keys()]}[(r=new WeakSet,a=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,s=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},n=function(){for(const[e,t]of this.delegate)o(this,r,"m",s).call(this,e,t)}},84699:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},65211:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resetUid=t.sortByUid=t.tsFromUid=t.isUID=t.uidForTs=t.uid=t.uidSuffix=void 0;const r=i(19851),s=i(76790),n=i(22573),a=i(54993),o=i(7282),l=i(55222);let u=0;const c=l.GeoRadix;function d(e){return c.encode(e)+(0,t.uidSuffix)()}t.uidSuffix=(0,r.lazy)((()=>"-"+c.randomChars(7))),t.uid=function(){return u=Math.max(Date.now(),u+1),d(u)},t.uidForTs=d;const h=/^[\da-z]{9}-[\da-z]{7}$/i;function f(e){const t=(0,a.toS)(e).replace(/(?<=\S)-.*/,"");return(0,n.blank)(t)?void 0:c.decode(t)}t.isUID=function(e){return h.test((0,a.toS)(e))},t.tsFromUid=f,t.sortByUid=function(e){return(0,s.sortBy)(e,(e=>f(e.uid)))},t.resetUid=function(){if(!(0,o.isTest)())throw new Error("unsupported");t.uidSuffix.unset(),u=0}},94174:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,a.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,a.lazy)((()=>(0,o.uniq)([n.default.geteuid?.(),n.default.getuid?.(),s.default.userInfo().uid]))),t.userid=(0,a.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,a.lazy)((()=>(0,o.uniq)([n.default.getegid?.(),n.default.getgid?.(),s.default.userInfo().gid]))),t.groupid=(0,a.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,a.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,a.lazy)((()=>(0,l.toNotBlank)(s.default.userInfo()?.username))),t.userNameFromWhoami=(0,a.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,a.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,a.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,a.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.0-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=0,t.versionPrerelease=["prealpha"],t.release="2024.3.0-prealpha+20240308102353",t.gitSha="92cba1b21937cb9ca770f6a339e44b0fbee04bf9",t.gitDate=new Date(1709922233e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48299:function(e,t){"use strict";var i,r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.WeakCache=void 0;class o{constructor(){i.add(this),this[n]="WeakCache",r.set(this,new Map)}clear(){return a(this,r,"f").clear(),this}delete(e){return a(this,r,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of this.entries())e(i,t,this)}findEntry(e){for(const[t,i]of this.entries())if(e(i,t,this))return i}deleteValueIf(e){for(const[t,i]of this.entries())e(i,t,this)&&a(this,r,"f").delete(t)}get(e){const t=a(this,r,"f").get(e),i=t?.deref();return null==i&&null!=t&&a(this,r,"f").delete(e),i}getOrMaybeSet(e,t){const i=a(this,r,"f").get(e)?.deref();if(null!=i)return i;const s=t();return null!=s&&this.set(e,s),s}set(e,t){return a(this,r,"f").set(e,new WeakRef(t)),this}has(e){return null!=a(this,r,"f").get(e)?.deref()}get size(){return a(this,i,"m",s).call(this),a(this,r,"f").size}keys(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries())null==i.deref()?a(e,r,"f").delete(t):yield t}()}values(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield s}}()}entries(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield[t,s]}}()}[(r=new WeakMap,i=new WeakSet,n=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}}t.WeakCache=o,s=function(){for(const[e,t]of a(this,r,"f").entries())null==t.deref()&&a(this,r,"f").delete(e)}},48963:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),s=i(55835),n=i(31586),a=i(97790),o=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,n.toInt)(e)));if(!(0,s.allDefined)(i))return;const[a,o,u,c,d,h,f]=i,m=(0,n.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(a,o-1,u,c,d,h,f/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,a.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(n.toInt).filter((e=>(0,o.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},79184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aggregateAssetFiles=void 0;const r=i(59455),s=i(48884),n=i(22859),a=i(28874),o=i(79781),l=i(92434);t.aggregateAssetFiles=async function(e){const t=(0,r.toA)((0,l.sortAssetFiles)(e)??e);return(a.Settings.assetAggregation.valueOrDefault===n.AggregateTypes.union?s.clusterSome:s.clusterEvery)(t,o.isSimilarAssetFile)}},79781:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotSimilarAssetFile=t.isSimilarAssetFile=t.whyNotSameAsset=t.VideoImageMismatchMsg=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(50357),o=i(55835),l=i(31586),u=i(68708),c=i(12168),d=i(23467),h=i(73168),f=i(50213),m=i(86580),p=i(48368),g=i(80361),y=i(28874),w=i(28544),v=i(75767),b=i(16170),S=(0,r.lazy)((()=>(0,f.mkLogger)("sync-file.AssetFileComparator")));function P(e,t,i,r=((e,t)=>[e,t])){const s=e[i],o=t[i];if((0,n.blank)(s)||(0,n.blank)(o)||(0,a.eql)(s,o))return;const[l,u]=r(s,o);return(0,a.eql)(l,u)||(0,a.eql)(s,u)||(0,a.eql)(l,o)?void 0:`Different ${String(i)}: ${s} ≠ ${o}`}function _(e){return(0,n.mapNotBlank)(e,(e=>e.toLowerCase().trim().normalize()))}function T(e,t){return[_(e),_(t)]}function M(e,t,i){const r=(0,v.findInequalFields)(e[i],t[i]);return null==r?void 0:`Different ${i} (${r.aKey}:${r.aValue} ≠ ${r.aKey}:${r.aValue})`}function E(e,i){if(!(0,u.allKeysDefined)(e,"width","height","mimetype","sha"))return"af1 was missing required fields";if(!(0,u.allKeysDefined)(i,"width","height","mimetype","sha"))return"af2 was missing required fields";if((0,d.definedAndEql)(e.sha,i.sha))return void S().debug("matching SHA",{af1:e,af2:i});const r=(0,b.isVideoMimeType)(e.mimetype),n=(0,b.isVideoMimeType)(i.mimetype);if(r!==n)return S().tap({msg:"whyNotIsSimilar",result:t.VideoImageMismatchMsg,meta:{af1:e.uri,af2:i.uri,af1IsVideo:r,af2IsVideo:n}});const a=w.CapturedAt.fromAssetFile(e),f=w.CapturedAt.fromAssetFile(i);if(null==a)return"af1 missing capturedAt metadata";if(null==f)return"af2 missing capturedAt metadata";const _=a.isFuzzy||f.isFuzzy;if(_&&y.Settings.allowFuzzyDateImageHashMatches.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if((0,g.isSimilarImageHash)(t,r,{rotationsToCheck:(0,m.validRotations)(e,i)}))return void S().info("allowFuzzyDateImageHashMatches mode: image hashes match",{af1:e,af2:i})}if(!a.overlaps(f))return`captured-at ${a.toISOStringWithPrecision()} != ${f.toISOStringWithPrecision()}`;const E=P(e,i,"make",T)??P(e,i,"model",T);if(null!=E)return E;const D=(0,o.map)((0,h.geohashDistanceMeters)(e.geohash,i.geohash),(e=>(0,l.sigFigs)(e,2))),x={cameraId:M(e,i,"cameraId")??null,imageId:M(e,i,"imageId")??null,lensId:M(e,i,"lensId")??null,exposureSettings:(0,v.whyExposureSettingsNotSimilar)(e,i)??null,closeGeoHash:(0,l.gt)(D,y.Settings.gpsErrorMeters.valueOrDefault)?"geohashes are "+(0,c.fmt)(D)+"m different: too far apart":null};S().debug("whyNotSimilar()",{fields:x});const k=(0,s.compact)((0,u.values)(x));if((0,s.isNotEmpty)(k))return k.join(";");if(y.Settings.useImageHashes.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if(null!=t&&null!=r){const e=(0,g.compareImageHashes)(t,r,{capturedAtIsFuzzy:_});return!0===e?.isSimilar?void 0:e?.whyNotSimilar}}return(0,u.keys)(x).filter((e=>null==x[e])).length>=y.Settings.minMatchesWithoutImageHashes.valueOrDefault?void 0:"Insufficient metadata correlation"}t.VideoImageMismatchMsg="Videos ≠ images",t.whyNotSameAsset=function(e,t,i){{const i=E(e,t);if(null!=i)return i}if("intersection"===y.Settings.assetAggregation.valueOrDefault)for(const r of i)if(r.id!==t?.id){const t=E(e,r);if(null!=t)return t}},t.isSimilarAssetFile=function(e,t){return null==E(e,t)},t.whyNotSimilarAssetFile=E},13991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkSortableAssetFile_=t.mkAssetFile_=t.assetFileMetadata_=t.assetFileImageHashFields_=t.imageHashToAssetFileImageHashFields=t.assetFileStatFields_=t.assetFileUriFields_=void 0;const r=i(19851),s=i(55835),n=i(31586),a=i(59455),o=i(73168),l=i(50213),u=i(12089),c=i(76490),d=i(95696),h=i(48368),f=i(70417),m=i(28874),p=i(43207),g=i(47783),y=(0,r.lazy)((()=>(0,l.mkLogger)("asset-file.AssetFileFactory")));async function w(e){try{return{nativePath:e.nativePath,uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath}}catch(t){return y().throw("Failed to build URI for "+e,{error:t})}}async function v(e){const t=await e.stat_(),i=await e.sidecareStats();return{mtime:Math.floor((0,f.max)([t.mtimeMs,...(0,a.toA)(i).map((e=>e.mtimeMs))])),fileSize:t.size}}function b(e){return{...e,...c.DominantColor.toModeData(e.dominantColors)}}async function S(e){if(!m.Settings.useImageHashes.valueOrDefault)return;const t=await(0,h.imageHash_)(e.nativePath);return null==t?y().throw("Failed to extract image hash for "+e):b(t)}async function P(e){const[i,r,s,n]=await Promise.all([w(e),v(e),(0,t.assetFileMetadata_)(e),e.sha_()]);return{...i,...r,...s,sha:n}}t.assetFileUriFields_=w,t.assetFileStatFields_=v,t.imageHashToAssetFileImageHashFields=b,t.assetFileImageHashFields_=S,t.assetFileMetadata_=(0,u.shim1)({name:"asset-file.assetFileMetadata",impl:async function(e){try{const t=d.PosixFile.for(e),i=await(0,g.readTags)(t);if(null==i)throw new Error("Failed to read tags");if(null==i.capturedAt)throw new Error("Failed to read capturedAt");const r=i.capturedAt.toAssetFileFields();return null==r?y().throw("Failed to render assetFileFields from capturedAt",{capturedAt:i.capturedAt}):{...r,...i.exposureSettings,...i.dimensions,mimetype:i.mimetype,rotation:i.rotation,make:i.Make,model:i.Model,rating:i.rating,cameraId:i.cameraId,imageId:i.imageId,lensId:i.lensId,geohash:(0,o.geohashNumericShort)(i.GPSLatitude,i.GPSLongitude),durationMs:(0,p.extractDurationMs)(i),fps:(0,s.map)((0,n.toFloat)(i.VideoFrameRate),Math.floor)}}catch(t){return y().throw("_assetFileMetadata_() failed",{nativePath:e,error:t})}}}),t.mkAssetFile_=async function(e){const[t,i]=await Promise.all([P(e),S(e)]);return{...t,...i}},t.mkSortableAssetFile_=P},92434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestExistingAssetFile=t.assetFileSortCriteria=t.assetFileSortFields=t.assetFileSortCriteriaPojo=t.sortAssetFiles=t.mtime2sort=t.sortScale=t.dim2sort=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(23838),u=i(31586),c=i(68708),d=i(34666),h=i(50989),f=i(89937),m=i(50213),p=i(4001),g=i(29882),y=i(28874),w=i(14036),v=i(45200),b=i(34238),S=(0,r.lazy)((()=>(0,m.mkLogger)("img.AssetFileSorter"))),P=(0,h.strEnum)("file",f.PS_NETWORK_FILESYSTEM_SCHEME,f.PS_LOCAL_FILE_SCHEME,f.PS_LIBRARY_SCHEME);function _(e){return(0,u.map2Numeric)(e?.width,e?.height,((e,t)=>T(e*t)))}function T(e){if((0,u.gt0)(e))return Math.round(Math.pow(e,y.Settings.variantSortCriteriaPower.valueOrDefault))}function M(e){return Math.round(e/(5*o.minuteMs))}t.dim2sort=_,t.sortScale=T,t.mtime2sort=M;const E=["make","model","rating","cameraId","imageId","lensId","geohash"];function D(e){for(const t of(0,l.groupBy)(e,(e=>e.sha)).values())if(t.length>1){const e=Math.max(...(0,s.compact)(t.map((e=>e.mtime))));for(const i of t)i.mtime=e}return(0,n.sortBy)(e,C).reverse()}function x(e){const t=b.URI.parse(e.uri);if((0,a.blank)(t?.scheme)||(0,a.blank)(t?.path))return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI)",{uri_scheme:t?.scheme,uri_path:t?.path,af:e,parsedURI:t});const i=_(e);if(null==i)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid resolution)",{resolution:i,af:e,parsedURI:t});const r=P.indexOf(t.scheme);if(null==r)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI scheme)",{uri_scheme:t.scheme,af:e,parsedURI:t});const s=e.mtime??0,n=(0,g.parsePosixPath)(t.path),l=[];for(const t of E)(0,a.blank)(e[t])||l.push(t);const u={resolution:i,schemeIdx:r,capturedAtPrecision:-(e.capturedAtPrecisionMs??o.weekMs),metadataCoverage:l.length,metadataFields:l.join(","),isBrowserSupported:(0,w.isSupportedByCurrentBrowserExt)(n.ext),mtime:M(s),isEditOrUpdate:/edit|update/i.test(n.base),isCover:/cover/i.test(n.base),count:Math.abs((0,p.copySuffixCountFromName)(n.name)??0),basename:d.CmpReverseFlag+n.base,parentBasename:d.CmpReverseFlag+(0,g.parentBasename)(e.nativePath??t.path),uri:d.CmpReverseFlag+e.uri};return S().tap({msg:"assetFileSortCriteriaPojo()",result:(0,c.toReqValued)(u)})}function k(){return(0,s.uniq)([...y.Settings.variantSortCriteria.values,"uri"])}function C(e){const t=x(e);if(null==t)return;const i=[];for(const e of k())i.push(t[e]);return i}t.sortAssetFiles=D,t.assetFileSortCriteriaPojo=x,t.assetFileSortFields=k,t.assetFileSortCriteria=C,t.bestExistingAssetFile=async function(e){for(const t of D(e))if(await(0,v.uriExists)(t.uri,t.nativePath))return S().tap({msg:"bestExistingAssetFile()",result:t,meta:{files:e.map((e=>e.uri))}});return S().tap({msg:"bestExistingAssetFile(): no existing uris",result:void 0,meta:{files:e.map((e=>e.uri))}})}},54296:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetFileNativePath=void 0;const r=i(45200);t.getAssetFileNativePath=async function(e){return e.nativePath??(e.nativePath=await(0,r.uri2nativePath)(e.uri,e.mountpoint))}},73568:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const o=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),s.set(this,(0,o.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,n(this,s,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return n(this,s,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,n(this,s,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),a(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=n(this,r,"f")&&clearTimeout(n(this,r,"f")),a(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,s=new WeakMap},69591:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const s=r(i(87997)),n=i(31586);t.debounce=function(e,t){let i,r=[];const a=(0,n.gt0)(t)?(...n)=>{r=n,null!=i&&s.default.clearTimeout(i),i=s.default.setTimeout((()=>{e(...r)}),t)}:e;return a.reset=()=>{null!=i&&s.default.clearTimeout(i),i=void 0},a.force=()=>{a.reset(),e()},a.setTimeoutMs=e=>{a.reset(),t=e},a.timeoutMs=()=>t,a}},22911:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const w=y(i(87997)),v=y(i(57975)),b=i(45599),S=i(26905),P=i(55835),_=i(31586),T=i(68708),M=i(20214),E=i(57153),D=i(85556),x=i(50213),k=i(70025),C=i(95937),F="TIMEOUT",A=(0,b.defer)((()=>(0,x.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,_.gt0)(t)?new s(F).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const s=i[r];if(s.isSettled){if(s.name===F)return void A().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield s.value}}if(i.every((e=>e.name===F)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new s(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),a.set(this,void 0),o.set(this,E.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=s,s,(y=p(i,s,"f",n),m=y++,y),"f",n),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,x.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof s&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,o,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,T.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,a,"f")}get elapsedMs(){return(p(this,a,"f")??Date.now())-this.startedAt}get[(a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[v.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(w.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,w.default.setTimeout((()=>{this.isPending&&(this.reject(new D.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,C.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,o,"f")===E.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,o,"f")!==E.PromiseStates.pending}get isResolved(){return p(this,o,"f")===E.PromiseStates.resolved}get isRejected(){return p(this,o,"f")===E.PromiseStates.rejected}get settledMs(){return null==p(this,a,"f")?void 0:p(this,a,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,o,E.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,k.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,S.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,o,E.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,s=I,m=function(e){if(p(this,o,"f")===E.PromiseStates.pending){(0,P.map)(p(this,h,"f"),w.default.clearTimeout),e(),g(this,a,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},n={value:0}},27395:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(23838),o=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new a.MultiMap;(0,m.setUnrefInterval)((()=>v()),10*n.minuteMs);const y=5*n.secondMs;async function w(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,o.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function v(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>w(e))))},t.end=w,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),v();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,s.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>w(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,s.compact)(g.valuesFlat()).map((e=>w(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class w extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",a).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,s.set(this,void 0),n.set(this,void 0),o.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,s,"f")}hasTimeout(){return null!=u(this,n,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",a).call(this);const h=()=>{u(this,r,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,s,(0,d.setInterval)(u(this,o,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,n,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,o,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref()):h(),!0}}t.EndableInterval=w,s=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(){(0,h.map)(u(this,s,"f"),d.clearInterval),c(this,s,void 0,"f"),(0,h.map)(u(this,n,"f"),d.clearTimeout),c(this,n,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const o=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,a){this.endTimeoutMs=a,r.set(this,void 0),this.onEnds=[],s.set(this,(0,o.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),n(this,s,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){a(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return n(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return n(this,s,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,s=new WeakMap},99331:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let s=!1;t.ending=function(){return s},t.setEnding=function(e){s=(0,r.isTest)()?e:e||s}},45608:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const s=r(i(1708)),n=i(22573),a=i(45599),o=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,a.defer)((()=>(0,l.mkLogger)((0,o.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,a.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function w(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,n.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,f.endEndables)(),s.default.exit(e.status))}t.exit=w,t.exitOnStdStream=(0,a.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])s.default[e].on(t,(i=>{w({reason:`${e}:${t}`,status:0,error:i})}))}))},39250:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LastOneInWins=void 0;const n=i(23838),a=i(54993),o=i(15674),l=i(73568),u=i(76740),c=i(99331),d=i(42638);t.LastOneInWins=class{constructor(e,t=o.maxCpus){this.name=e,this.maxConcurrency=t,r.set(this,new n.MultiMap),this.p=new d.Promises(e,t)}vacuum(){return s(this,r,"f").filterInPlace(((e,t)=>t.isPending&&!0!==t.payload?.aborted)),s(this,r,"f").valueCount()}enqueue({key:e,abortable:t,fn:i}){for(const t of s(this,r,"f").get(e)??[])t.payload?.abort("aborted by new work");if(this.vacuum(),(0,c.ending)())throw new l.AbortError("ending");const n=t??new u.Abortable,o=this.p.serial((0,a.toS)(e),(()=>i(n)),n);return s(this,r,"f").add(e,o),o}},r=new WeakMap},60172:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,r)=>{t=e,i=r})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,s.set(this,void 0),n.set(this,0),a.set(this,void 0),o.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,a,"f")}unset(){d(this,n,0,"f"),d(this,s,void 0,"f"),d(this,a,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,o,"f").push(e)}prior(){return this.isStale()?void 0:c(this,a,"f")}lastValue(){return c(this,a,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,n,"f")}isStale(){return null==c(this,s,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,s,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,s,"f")?void 0:Date.now()-c(this,s,"f")}elapsedMs(){return c(this,a,"f")?.settledMs??c(this,a,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,o,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,o,"f"))e.onError(t)}finally{d(this,n,(i=c(this,n,"f"),++i),"f")}},u=function(e){d(this,s,Date.now(),"f");const t=c(this,a,"f");return d(this,a,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,a,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,a,"f")),c(this,a,"f")}},1728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),s=i(80049);t.memoizeAsync=function(e,t){let i=0;const n=new s.FifoCacheAsync(t),a=t=>(i++,n.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return a.clear=e=>{if(null==e)return n.clear();{const t=(0,r.stringify)(e);return n.deleteIf((e=>t===e))}},a.size=()=>n.size,a.callCount=()=>i,a}},22781:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),s.set(this,!1),n.set(this,!1)}_call(){return a(this,s,"f")?(o(this,n,!0,"f"),!0===this.undefinedIfBusy?void 0:a(this,r,"f")):(o(this,s,!0,"f"),o(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{o(this,s,!1,"f"),!0===this.runLaterIfBusy&&a(this,n,"f")&&(o(this,n,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return a(this,s,"f")}prior(){return a(this,r,"f")}async force(){return await a(this,r,"f"),this._call()}}r=new WeakMap,s=new WeakMap,n=new WeakMap},37461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),s=i(76790),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),w=i(15674),v=i(42638);var b=i(20214);async function S(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:i,timeoutMs:s}){const n=[];for(const a of(0,r.compact)(await t))try{const e=await((0,l.gt0)(s)?(0,c.thenOrTimeoutError)(i(a),s):i(a));null!=e&&n.push([e,a])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:a,error:t})}return n}async function T({arr:e,f:t,name:i,maxConcurrent:s,timeoutMs:n,promises:a}){if(null==e)return[];const o=(0,r.compact)(await e);if((0,r.isEmpty)(o))return[];if((s=Math.round(s??(0,w.maxCpus)()))<=1)return _({arr:e,f:t,name:i,timeoutMs:n});const u=a??(o.length<=s?v.PermissivePromises:new v.Promises(i,(()=>s))),d=(0,l.gt0)(n)?e=>(0,c.thenOrTimeoutError)(t(e),n):t,h=await u.enqueueAll(i,o.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return b.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=S,t.thenCollectBatched=async function(e,t,i){const r=[];for(const s of(0,p.batches)((0,f.toA)(await e),t)){const e=await S(s);r.push(...await S(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,o.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=T,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n}){return(await T({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:s,timeoutMs:n}){return(await T({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:s,timeoutMs:n})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await T({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,n.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,n.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*a.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,s=null;try{r=await((0,h.isFunction)(e)?e():e)}catch(e){s=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(s??r)}catch{}if(null!=s)throw s;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,n.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const s=await t;return null!=s?i(r,s):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const s=await t(r);return null==s?i():s},t.thenMap2Or=async function(e,t,i,r){const s=await e;if(null==s)return r();const n=await t;if(null==n)return r();const a=await i(s,n);return null==a?r():a},t.thenAnd=async function(e,t){return null!=e&&(0,n.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await T({name:e,arr:t,f:i});return(0,s.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),w=i(25764),v=i(38836),b=i(73614);function S(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),s=(0,l.clamp)(10*a.secondMs,a.minuteMs,Math.round(this.times.get(e)?.p98??0)),n=(0,b.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),s);try{const s=await(0,c.tot)(t),n=Date.now()-r;return i?.(s,n),this.push(e,n),s}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(n)}}get entriesBySumDesc(){return(0,n.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(S(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,o.getOrSet)(this.times,S(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(S(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/a.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function _(e,t,i){return P.instance().time(e,t,i)}function T(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new v.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,s.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),w.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const i=Date.now(),r=t();return T(e,Date.now()-i),r},t.pushTime=T,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>_(e,t)),i)}},42638:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),w=i(54993),v=i(89788),b=i(82647),S=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,w.toS)(e)};class _{constructor(e,t){r.add(this),this.name=e,this.ee=new f.default.EventEmitter,s.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new b.Average,n.set(this,0),a.set(this,[]),o.set(this,[]),this.lastPushedNames=new v.BoundedList(16),c(this,s,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,S.maxCpus)(),d(this,s,"f")?.call(this)??(0,S.maxCpus)()))}end(){return d(this,o,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,a,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,n,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,a,"f").map((e=>e.name)),pendingNames:d(this,o,"f").map((e=>e.d.name)),totalWorkCount:d(this,n,"f")}}enqueue({name:e,l:t,payload:i,serialId:s}){const n=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:s});return this.laterPop(),n}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,a,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,o,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,o,"f").length,e),i=this.runningSerialIds,s=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,a,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,o,"f").length}hasPending(){return d(this,o,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,o,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,o,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const s=new P.Deferred(e,{payload:i,serialId:r});return d(this,o,"f").push({d:s,l:t}),s},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,n,(t=d(this,n,"f"),++t),"f"),(0,m.remove)(d(this,a,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,a,"f").push(e),e},t.maybeRun=function(e,t){const i=new _(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new _(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},59189:function(e,t){"use strict";var i,r=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},s=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SerialLaterQueue=void 0,t.SerialLaterQueue=class{constructor(){i.set(this,Promise.resolve())}enqueue(e){return s(this,i,r(this,i,"f").catch().then(e),"f")}},i=new WeakMap},4867:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),s=i(34546),n=i(41400),a=i(31586),o=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let o=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>o=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>{if(o)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(o)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>l=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>o.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),s=i(42659),n=i(41400),a=i(32639),o=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,o.clamp)(10*m,l.ShortCommandTimeoutMs,(t??s.minuteMs)/5);await(0,n.delay)(r,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const s=r(i(1708)),n=i(45599),a=i(41400),o=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),w=i(50213),v=i(7282),b=i(88158),S=i(45969),P=i(43334),_=i(28874),T=i(3790);function M(e){return E().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const E=(0,n.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,b.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,a.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const D=["HOME","LANG","USER"],x=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],k=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?D:x),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function C(e){const t={NODE_ENV:(0,v.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,S.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,_.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,o.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(s.default.env,(e=>M(e)||!(0,T.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=C,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:A({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let F=!1;function A({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const s=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...k(),...i?(0,g.childProcLocale)():{},...C(r),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(s);if((0,y.isLogged)("debug")&&!F){F=!0;const e=(0,w.mkLogger)("child.ChildEnv"),t=(0,l.entries)(s).map((([e,t])=>[e,(0,T.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return s}t.childEnv=A},84777:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const s=r(i(31421)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),w=i(79089),v=i(45255),b=i(22911),S=i(4867),P=i(73614),_=i(70025),T=i(57159),M=i(36868),E=i(66184),D=i(45643),x=i(95402),k=i(9727),C=(0,a.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function F(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function A(e,t=30*u.secondMs){if(null==e)return!1;C().debug("endProcess()",F(e));const i=e.pid;if(null==i||i<=0)return C().warn("endProcess(): asked to end invalid pid",F(e)),!1;if(i===n.default.pid)return C().warn("endProcess(): asked to end MY pid",F(e)),!1;if(i===n.default.ppid)return C().warn("endProcess(): asked to end my parent pid",F(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();C().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,x.killPid)(i).catch((e=>{C().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,D.waitForPidExit)(i,t))return C().debug("endProcess(): exitted",F(e)),!0;{x.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");C().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,x.killPid)(i,!0).catch((e=>{C().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,D.waitForPidExit)(i,5e3)}function I(e,i,r,s=0){const a=new Date,o=[];return(0,w.niceable)(i,r)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,w.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(s,u.secondMs)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&A(e)}),s-250)),o.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,x.addPid)({pid:e.pid,cmd:i,timeoutMs:s,ppid:n.default.pid},a)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>o.forEach(clearTimeout))),e}function O(e,t,i,r){const n=(0,k.spawnOptions)(r);return(0,E.isLogged)("trace",C().context)?C().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:n}):C().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(s.default.execFile(e,t,n),e,t,i)}async function L(e,t,i){const r=i.quiet??!1,s=i.ignoreStderr??!1,n=i.ignoreExitCode??!1,a=O(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{a.disconnect?.()}catch{}return{result:"",pid:a.pid}}const u=a.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new b.Deferred(f);a.on("error",(e=>g.push(e))),a.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),a.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(a.stdin);const w=new d.Latch;null==a.stdout?w.resolve():(a.stdout.on("error",(e=>g.push(e))),a.stdout.on("data",(e=>m.push(e))),a.stdout.on("end",(()=>w.resolve())));const P=new d.Latch;null==a.stderr||s?P.resolve():(a.stderr?.on("error",(e=>g.push(e))),a.stderr?.on("data",(e=>p.push(e))),a.stderr?.on("end",(()=>P.resolve()))),C().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,S.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),C().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:w.state(),stderr:P.state()}),await(0,S.thenOrTimeoutError)({p:w.promise,timeoutMs:v.ShortCommandTimeoutMs,halt:i.halt}),await(0,S.thenOrTimeoutError)({p:P.promise,timeoutMs:v.ShortCommandTimeoutMs,halt:i.halt});const E=p.join("");(0,l.notBlank)(E)&&g.push(new Error(E)),!r&&(0,o.isNotEmpty)(g)&&C().warn(f+" resulted in errors:",g);const D=i.isIgnorableError??_.isIgnorableError,x=g.filter((e=>!0!==D(e)));if(x.length>0)throw 1===x.length?x[0]:new T.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:x});if(!n&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:E}}catch(e){throw C().error("stdoutResult_() failed",e),await(0,x.killPid)(a.pid,!0),e}}t.endProcess=A,t.ReniceAfterMs=(0,a.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,a.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const n=(0,k.spawnOptions)(r);return C().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(s.default.spawn(e,t,n),e,t,i)},t.execFile=O,t.stdoutResult_=L,t.stdout_=async function(e,t,i){const r=await L(e,t,i);return C().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},3790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),s=i(41400),n=i(19851),a=i(28874);(0,s.later)((()=>a.Settings.sensitiveEnvRegExp.watchLater((()=>o.unset()))));const o=(0,n.lazy)((()=>{try{return new RegExp(a.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${a.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(a.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&o().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||a.Settings.license.includesEnvKey(e)}},55534:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceExitCommand=void 0,t.ServiceExitCommand="--exit"},85100:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serviceExitTimeoutMs=void 0;const r=i(23560),s=i(28874),n=i(45255);t.serviceExitTimeoutMs=function(e){return(0,r.isSyncService)(e)?s.Settings.syncExitTimeoutMs.valueOrDefault:n.ShortCommandTimeoutMs}},34330:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),w=i(54993),v=i(27395),b=i(25764),S=i(99331),P=i(42638),_=i(38835),T=i(8769),M=i(57159),E=i(66003),D=i(50213),x=i(45643),k=i(28874),C=i(84777);t.mkBasicWatchedChild=function(e){return new F({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,C.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class F{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,D.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),s.set(this,!1),this.onError=(e,t,i)=>{const n=new M.WrappedError(e,{cause:t}),a=!1!==n.ignorable;this.logger().log(a?"warn":"error","onError()",n),u(this,s,"f")||a||(this.lastError=n,(0,T.onError)(n),!0!==n.fatal?(i??this.opts.onError(e,n))&&(this.logger().warn("onError requested restart",{src:e,error:n}),u(this,r,"m",o).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:k.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:b.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,v.addEndable)(this.opts.endableRank,this),u(this,r,"m",o).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,s,"f")}async end(){return c(this,s,!0,"f"),u(this,r,"m",n).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",n).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,s,"f")}),!u(this,s,"f")&&!(0,S.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",n).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=F,s=new WeakMap,r=new WeakSet,n=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,s,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",a).call(this,e)},a=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,x.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,C.endProcess)(e,this.endTimeoutMs)},o=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",n).call(this),!this._stopped&&!u(this,s,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,T.onError)("Can't restart "+this.name+", failure rate is too high."+_.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,s,"f")}),this._stopped||u(this,s,"f")||(0,S.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,E.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,w.toS)(e).includes("Error: Cannot find module")&&(0,T.onError)("Failed to start "+this.name+_.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,s,"f")}),(0,S.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",o).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const a=n(i(53916)),o=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,o.toNativePath_)(e);const i=f.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),s=i.sibling(r);if(s.isSelfOrDescendantOf((0,l.examples)()))return a.join("$examples",s.posixPathFrom((0,l.examples)()));const n=(0,d.originalsDir)();if(s.isSelfOrDescendantOf(n))return a.join("$library",s.posixPathFrom(n));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?a.join("$library",s.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const n=i(6858),a=i(1708),o=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),h=i(43334),f=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return s(this,r,"f").push(...e),this}async parse(e=a.argv,t){let i=(0,m.addHelpFooter)(new n.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of s(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":o.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,a.exit)(0)})),i.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=i.opts();for(const e of s(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),s=i(31586),n=i(51926),a=i(17344),o=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,s.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,n.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,a.EditionName)()+" v"+o.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const r=i(38639),s=i(17181),n=i(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,r.mapBoolean)(e.color,(e=>{n.Settings.logColor.envValue=e,(0,s.setupLogFormatter)()}))}}},83210:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDaemon=void 0;const s=r(i(1708)),n=i(22573),a=i(38639);t.isDaemon=function(e){return(0,a.isTrue)(s.default.env.__is_daemon)||(0,a.isTrue)(e?.daemon)||!(0,n.blank)(e?.pidfile)}},53978:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimingArg=void 0;const r=i(28874),s=i(38639);t.TimingArg={beforeParse:e=>e.option("--timing","On exit, emit timing information to stdout."),afterParse:async e=>{(0,s.isTrue)(e.timing)&&(r.Settings.emitTimingsOnExit.value=!0)}}},94361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),s=i(40958),n=i(55835),a=i(31586),o=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,a.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,s.compactBlanks)([c("user id","PUID",(0,o.userids)()),c("group id","PGID",(0,o.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,n.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},54772:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestLabhashName=t.bestLabName=t.bestRgbName=t.colorToTuple=t.bestRgbTripletName=t.ColorNames=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(31586),o=i(48884),l=i(50213),u=i(81168),c=i(85810),d=i(42079),h=i(91482),f=i(3048),m=i(85409),p=i(16050),g=i(42022),y=i(85042),w=(0,r.lazy)((()=>(0,l.mkLogger)("color.ColorNames")));function v(e){const t=(0,y.normalizeRgbHex)(e.rgb);if(null==t)return void w().warn(`skipping invalid entry (bad rgb): ${e.rgb}`,e);const i=(0,c.rgbhex2Lab)(t);if(null==i)return void w().warn(`skipping invalid entry (failed to convert to L*a*b): ${t}`,e);const r=(0,c.toLabhash)(i,g.ModeBits);return{...e,rgb:t,lab:i,labhash:r,closeLabhashes:[r],closeRgb:[t],name:(0,u.capitalize)(e.name)}}function b(e,i){return null==e?void 0:(0,o.leastBy)(i??(0,t.ColorNames)(),(t=>(0,f.ciede2000_delta_e)(t.lab,e)))}t.ColorNames=(0,r.lazy)((()=>(0,s.compact)([...d.CrayonColors,...d.CrayonSupplements,...h.DarkWikipediaColors,...p.LightWikipediaColors,...m.Greys].map(v)))),t.bestRgbTripletName=function(e,i=(0,t.ColorNames)()){return b((0,c.rgb2lab)(e),i)},t.colorToTuple=v,t.bestRgbName=function(e){return P((0,c.rgbhex2Labhash)(e))},t.bestLabName=b;const S=new Map;function P(e){return(0,a.gte0)(e)?(0,n.getOrSet)(S,e,(()=>{const i=(0,t.ColorNames)().find((t=>t.labhash===e));if(null!=i)return i;const r=(0,c.unlabhash)(e),n=b(r);return null!=r&&null!=n&&((0,s.pushUniq)(n.closeLabhashes,e),(0,s.pushUniq)(n.closeRgb,(0,c.lab2rgbhex)(r))),n})):void 0}t.bestLabhashName=P},85810:(e,t,i)=>{"use strict";e=i.nmd(e),Object.defineProperty(t,"__esModule",{value:!0}),t.hsv2rgb=t.hsl2hsv=t.hsv2hsl=t.hsl2rgb=t.rgb2hsl=t.rgbhex2hsl=t.rgb2hsv=t.closestLab=t.maxLabhash=t.minLabhash=t.unlabhash=t.toLabhash=t.LabBitZip=t.xyz2rgb=t.lab2xyz=t.xyz2lab=t.rgb2xyz=t.clampLab=t.lab2rgb=t.rgb2lab=t.rgb2labArray=t.rgb2labTriplets=t.lab2rgbhex=t.rgbhex2Labhash=t.rgbhex2Lab=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(55835),o=i(31586),l=i(48884),u=i(20014),c=i(75503),d=i(3048),h=i(42022),f=i(85042),m=[[.4124564,.3575761,.1804375],[.2126729,.7151522,.072175],[.0193339,.119192,.9503041]],p=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]];function g(e){return _(v(e))}function y(e){return(0,f.clampRGB)(M(T(e)))}function w(e){return(0,t.LabBitZip)().clampValue(e)}function v(e){const t=(0,f.clampRGB)(e).map((e=>e/255)).map((e=>e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92));return(0,c.matXvec)(m,t)}t.rgbhex2Lab=function(e){return(0,a.map)((0,f.rgbhex2triplet)(e),g)},t.rgbhex2Labhash=function(e,t=h.ModeBits){return(0,a.map)((0,f.rgbhex2triplet)(e),(e=>E(g(e),t)))},t.lab2rgbhex=function(e){return(0,f.rgbTriplet2hex)(y(e))},t.rgb2labTriplets=function(e){return(0,s.stepRange)(0,e.length,3).map((t=>g([e[t],e[t+1],e[t+2]])))},t.rgb2labArray=function(e){const t=[],i=[],r=[];for(let s=0;se>S?Math.pow(e,1/3):(P*e+16)/116));return w([116*i-16,500*(t-i),200*(i-r)])}function T(e){const[t,i,r]=w(e),s=(t+16)/116,n=i/500+s,a=s-r/200,o=n*n*n,l=a*a*a,u=o>S?o:(116*n-16)/P,c=t>8?Math.pow(s,3):t/P,d=l>S?l:(116*a-16)/P;return[u*b.X,c*b.Y,d*b.Z]}function M(e){return(0,c.matXvec)(p,e).map((e=>{const t=e<0?-1:1,i=e*t;return(0,o.round)(255*t*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055))}))}function E(e,i=h.ModeBits){return(0,t.LabBitZip)().zip(e,i)}t.xyz2lab=_,t.lab2xyz=T,t.xyz2rgb=M,t.LabBitZip=(0,r.lazy)((()=>new u.BitZip([{min:0,max:100},{min:-79,max:90},{min:-102,max:89}]))),t.toLabhash=E;const D=new Map;function x(e,i=h.ModeBits){return(0,t.LabBitZip)().unzip(e,i)}function k(e){const[t,i,r]=(0,f.clampRGB)(e),s=Math.max(t,i,r),n=s-Math.min(t,i,r),a=n?s===t?(i-r)/n:s===i?2+(r-t)/n:4+(t-i)/n:0;return[60*(a<0?a+6:a),s?n/s*100:0,s/255*100]}function C(e){return F(k(e))}function F(e){const[t,i,r]=e,s=(200-i)*r/100;return[t,s>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,s/2]}function A(e){const[t,i,r]=e,s=i*(r<50?r:100-r)/100;return[t,s>0?2*s/(r+s)*100:0,r+s]}function I(e){const t=e[0]/360*6,i=e[1]/100,r=e[2]/100,s=Math.floor(t),n=r*(1-i),a=r*(1-(t-s)*i),o=r*(1-(1-t+s)*i),l=s%6;return(0,f.clampRGB)([255*[r,a,n,n,o,r][l],255*[o,r,r,a,n,n][l],255*[n,n,o,r,r,a][l]])}t.unlabhash=function(e,t=h.ModeBits){return t===h.ModeBits?(0,n.getOrSet)(D,e,(()=>x(e,t))):x(e,t)},t.minLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMin(h.ModeBits))),t.maxLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMax(h.ModeBits))),t.closestLab=function(e,t){return(0,l.leastBy)(e,(e=>(0,d.ciede2000_delta_e)(e,t)))},t.rgb2hsv=k,t.rgbhex2hsl=function(e){return C((0,f.rgbhex2triplet)(e))},t.rgb2hsl=C,t.hsl2rgb=function(e){return I(A(e))},t.hsv2hsl=F,t.hsl2hsv=A,t.hsv2rgb=I,i.c[i.s]===e&&console.log(E([0,0,0]))},42079:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CrayonSupplements=t.CrayonColors=void 0,t.CrayonColors=[{name:"Aquamarine",rgb:"#95E0E8"},{name:"Asparagus",rgb:"#7BA05B"},{name:"Blue-green",rgb:"#0095B7"},{name:"Royal blue",rgb:"#273BE2"},{name:"Blush",rgb:"#DB5079"},{name:"Brilliant rose",rgb:"#E667CE"},{name:"Brown",rgb:"#AF593E"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Burnt umber",rgb:"#805533"},{name:"Cadet blue",rgb:"#A9B2C3"},{name:"Canary",rgb:"#FFFF99"},{name:"Carmine",rgb:"#E62E6B"},{name:"Carnation pink",rgb:"#FFA6C9"},{name:"Celestial blue",rgb:"#7070CC"},{name:"Cerise",rgb:"#DA3287"},{name:"Cerulean blue",rgb:"#339ACC"},{name:"Chestnut",rgb:"#B94E48"},{name:"Cobalt blue",rgb:"#8C90C8"},{name:"Copper",rgb:"#DA8A67"},{name:"Cornflower",rgb:"#93CCEA"},{name:"Cotton candy",rgb:"#FFB7D5"},{name:"Denim",rgb:"#1560BD"},{name:"Eggplant",rgb:"#614051"},{name:"Fern",rgb:"#63B76C"},{name:"Fuchsia",rgb:"#C154C1"},{name:"Russet",rgb:"#87421F"},{name:"Green",rgb:"#01A638"},{name:"Green-yellow",rgb:"#F1E788"},{name:"Indigo",rgb:"#4F69C6"},{name:"Jungle green",rgb:"#29AB87"},{name:"Magenta",rgb:"#F653A6"},{name:"Maize",rgb:"#F2C649"},{name:"Maroon",rgb:"#C32148"},{name:"Medium chrome green",rgb:"#6CA67C"},{name:"Medium violet",rgb:"#8F47B3"},{name:"Melon",rgb:"#FEBAAD"},{name:"Middle blue-green",rgb:"#8DD9CC"},{name:"Middle blue-purple",rgb:"#8B72BE"},{name:"Green-yellow",rgb:"#ACBF60"},{name:"Middle purple",rgb:"#D982B5"},{name:"Middle yellow-red",rgb:"#ECAC76"},{name:"Midnight blue",rgb:"#003366"},{name:"Mulberry",rgb:"#C8509B"},{name:"Navy blue",rgb:"#0066CC"},{name:"Olive green",rgb:"#B5B35C"},{name:"Orange",rgb:"#FF8833"},{name:"Orchid",rgb:"#E29CD2"},{name:"Peach",rgb:"#FFCBA4"},{name:"Periwinkle",rgb:"#C3CDE6"},{name:"Pine green",rgb:"#01796F"},{name:"Pink flamingo",rgb:"#FC74FD"},{name:"Plum",rgb:"#8E3179"},{name:"Raw umber",rgb:"#665233"},{name:"Red-orange",rgb:"#FF681F"},{name:"Red",rgb:"#ED0A3F"},{name:"Salmon",rgb:"#FF91A4"},{name:"Vivid scarlet",rgb:"#FD0E35"},{name:"Sea green",rgb:"#93DFB8"},{name:"Sepia",rgb:"#9E5B40"},{name:"Shamrock",rgb:"#33CC99"},{name:"Sky blue",rgb:"#76D7EA"},{name:"Spring green",rgb:"#ECEBBD"},{name:"Sunset orange",rgb:"#FE4C40"},{name:"Tan",rgb:"#FA9D5A"},{name:"Teal blue",rgb:"#008080"},{name:"Thistle",rgb:"#D8BFD8"},{name:"Vivid tangerine",rgb:"#ED3C10"},{name:"Vivid violet",rgb:"#a625c3"},{name:"Wisteria",rgb:"#C9A0DC"},{name:"Yellow-green",rgb:"#C5E17A"},{name:"Yellow-orange",rgb:"#FFAE42"},{name:"Yellow",rgb:"#FBE870"}],t.CrayonSupplements=[{name:"Artichoke",rgb:"#8F9779"},{name:"Aubergine",rgb:"#48213A"},{name:"Brandy rose",rgb:"#B1847F"},{name:"Burgundy",rgb:"#800020"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Crimson red",rgb:"#990000"},{name:"Dark brown",rgb:"#664228"},{name:"Dark coral",rgb:"#CD5B45"},{name:"Dark green",rgb:"#006400"},{name:"Dark raspberry",rgb:"#872657"},{name:"Dark turquoise",rgb:"#610079"},{name:"Deep teal",rgb:"#004040"},{name:"Deep coffee",rgb:"#704241"},{name:"Dusty rasberry",rgb:"#917980"},{name:"Ecru",rgb:"#BCAC7C"},{name:"Evergreen",rgb:"#05472A"},{name:"Eggplant",rgb:"#380835"},{name:"Eggplant purple",rgb:"#430541"},{name:"Emerald green",rgb:"#028F1E"},{name:"Flamingo pink",rgb:"#D67C99"},{name:"Grape",rgb:"#6C3461"},{name:"Kelly green",rgb:"#4CBB17"},{name:"Light forest green",rgb:"#4F9153"},{name:"Medium dark brown",rgb:"#AF7200"},{name:"Medium dark cyan-blue",rgb:"#2D537C"},{name:"Mustard",rgb:"#FAAF18"},{name:"Neon green",rgb:"#39FF14"},{name:"Pear",rgb:"#D1E231"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Phthalo blue",rgb:"#0016C7"},{name:"Pink lace",rgb:"#FFDDF4"},{name:"Raw sienna",rgb:"#884B15"},{name:"Rebecca purple",rgb:"#663399"},{name:"Sap green",rgb:"#536916"},{name:"Blue sapphire",rgb:"#133ECB"},{name:"Sand",rgb:"#B38751"},{name:"Shadow blue",rgb:"#778BA5"},{name:"Shadow green",rgb:"#121E06"},{name:"Swamp green",rgb:"#748500"},{name:"Verdigris",rgb:"#43B3AE"},{name:"Vivid blue-magenta",rgb:"#4817E8"},{name:"Vivid blue-purple",rgb:"#ACACE6"},{name:"Vivid blue",rgb:"#47ABCC"},{name:"Vivid green-yellow",rgb:"#D9E650"},{name:"Vivid green",rgb:"#7BE214"},{name:"Vivid turqoise",rgb:"#06ECD2"},{name:"Vivid lavender",rgb:"#A354FD"},{name:"Vivid mint",rgb:"#00F28C"},{name:"Vivid pink",rgb:"#D752FB"},{name:"Vivid red-purple",rgb:"#C31D7E"},{name:"Vivid red",rgb:"#D92121"},{name:"Vivid yellow-red",rgb:"#F2BA49"},{name:"Vivid yellow",rgb:"#FAFA37"}]},91482:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarkWikipediaColors=void 0,t.DarkWikipediaColors=[{name:"Bistre",rgb:"#3D2B1F"},{name:"Black bean",rgb:"#3D0C02"},{name:"Black pearl",rgb:"#041322"},{name:"Shadow blue",rgb:"#001440"},{name:"Charcoal",rgb:"#36454F"},{name:"Dark indigo",rgb:"#1F0A52"},{name:"Dark magenta",rgb:"#8B008B"},{name:"Dark moss green",rgb:"#4A5D23"},{name:"Dark navy",rgb:"#02075D"},{name:"Dark pastel blue",rgb:"#779ECB"},{name:"Dark purple",rgb:"#580040"},{name:"Dark tan",rgb:"#918151"},{name:"Dark yellow-green",rgb:"#304000"},{name:"Dark yellow",rgb:"#9B870C"},{name:"Deep violet",rgb:"#330066"},{name:"Dusk",rgb:"#4E5481"},{name:"Elderberry",rgb:"#1d1a34"},{name:"Grey jade",rgb:"#757C55"},{name:"Grey magenta",rgb:"#83667F"},{name:"Grey ochre",rgb:"#716659"},{name:"Grey olive",rgb:"#656c5a"},{name:"Grey sage",rgb:"#69724d"},{name:"Taupe",rgb:"#483C32"}]},3048:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciede2000_delta_e=t.diffCIECorr=t.MaxCie=t.MinCie=t.cie94_delta_e=t.cie76_delta_e=void 0;const r=i(31586),s=i(97352);t.cie76_delta_e=function(e,t){return Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2)},t.cie94_delta_e=function(e,t){const[i,r,n]=e,[a,o,l]=t,u=i-a,c=r-o,d=n-l,h=(0,s.sqrt)(r**2+n**2),f=h-(0,s.sqrt)(o**2+l**2),m=(0,s.sqrt)(c**2+d**2-f**2);return(0,s.sqrt)((u/1)**2+(f/(1+.045*h))**2+(m/(1+.015*h))**2)},t.MinCie=2,t.MaxCie=20,t.diffCIECorr=function(e,i){return null==e||null==i?1:(0,r.clamp)(0,t.MaxCie,l(e,i)-t.MinCie)/t.MaxCie};const n=1,a=1,o=1;function l(e,t){const[i,r,l]=e,u=(0,s.sqrt)(r**2+l**2),[c,d,h]=t,f=(u+(0,s.sqrt)(d**2+h**2))/2,m=.5*(1-(0,s.sqrt)(Math.pow(f,7)/(Math.pow(f,7)+Math.pow(25,7)))),p=r*(1+m),g=d*(1+m),y=(0,s.sqrt)(p*p+l*l),w=(0,s.sqrt)(g*g+h*h);let v=Math.abs(p)+Math.abs(l)===0?0:Math.atan2(l,p);v+=2*(v<0?1:0)*Math.PI;let b=Math.abs(g)+Math.abs(h)===0?0:Math.atan2(h,g);b+=2*(b<0?1:0)*Math.PI;const S=c-i,P=w-y;let _=y*w==0?0:b-v;_-=2*(_>Math.PI?1:0)*Math.PI,_+=2*(_<-Math.PI?1:0)*Math.PI;const T=2*(0,s.sqrt)(y*w)*Math.sin(_/2),M=(i+c)/2,E=(y+w)/2;let D;y*w==0?D=v+b:(D=(v+b)/2,D-=(Math.abs(v-b)>Math.PI?1:0)*Math.PI,D+=2*(D<0?1:0)*Math.PI);const x=(M-50)**2,k=1-.17*Math.cos(D-Math.PI/6)+.24*Math.cos(2*D)+.32*Math.cos(3*D+Math.PI/30)-.2*Math.cos(4*D-63*Math.PI/180),C=1+.015*x/(0,s.sqrt)(20+x),F=1+.045*E,A=1+.015*E*k,I=30*Math.PI/180*Math.exp(-1*((180/Math.PI*D-275)/25)**2),O=2*(0,s.sqrt)(Math.pow(E,7)/(Math.pow(E,7)+Math.pow(25,7))),L=-1*Math.sin(2*I)*O;return(0,s.sqrt)(Math.pow(S/(n*C),2)+Math.pow(P/(a*F),2)+Math.pow(T/(o*A),2)+L*P/(a*F)*T/(o*A))}t.ciede2000_delta_e=l},76490:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColor=t.dominantColorsToRgbHex=void 0;const r=i(40958),s=i(31586),n=i(97352),a=i(54772),o=i(85810),l=i(42022),u=i(1971);t.dominantColorsToRgbHex=function(e){return(0,r.compact)(e.map((e=>[e.rgbhex,(0,s.fmtPct)(e.pct)])))};class c{static fromModeData(e){return(0,r.compact)((0,s.times)(u.ModeCount,(t=>c.fromLabhash({labhash:e[`mode${t}`],pct:e[`mode${t}pct`]}))))}static toModeData(e){const t={};return(0,s.times)(u.ModeCount,(i=>{t["mode"+i]=e[i]?.labhash??null,t["mode"+i+"pct"]=e[i]?.pct??null})),t}static fromLabhash({labhash:e,labhashBits:t=l.ModeBits,pct:i}){const r=(0,n.mapGt0)(e,(e=>(0,o.unlabhash)(e,t)));return null!=r&&(0,s.gt0)(i)?new c(r,i,e):void 0}static fromCentroid(e,t){return new c(e.centroid,Math.round(e.size/t*100))}constructor(e,t,i){this.lab=e,this.pct=(0,s.clamp)(0,100,t),this.labhash=i??(0,o.toLabhash)(e,l.ModeBits)}get rgbhex(){return(0,o.lab2rgbhex)(this.lab)}get color(){return(0,a.bestLabhashName)(this.labhash)}toGreyscale(){return new c([this.lab[0],0,0],this.pct)}eql(e){return this.labhash===e.labhash&&(0,s.closeTo)(this.pct,e.pct,5)}}t.DominantColor=c},32848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scaled_delta_e=t.dominantColorCorrelation=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(48884),o=i(31843),l=i(70417),u=i(3048);function c(e,t){const i=(0,s.sum)(e,(e=>(0,n.clamp)(0,100,e.pct))),r=(0,s.sum)(e,(e=>function(e,t){const i=(0,a.leastBy)(t,(t=>(0,u.ciede2000_delta_e)(e.lab,t.lab)));if(null==i)return 0;const r=(0,u.ciede2000_delta_e)(e.lab,i.lab),s=(0,n.clamp)(0,e.pct,(0,l.avg)([e.pct,i.pct])),o=h(r);return(0,n.clamp)(0,100,s)*o}(e,t)));return r/i}t.dominantColorCorrelation=function(e,t){return e=(0,s.compact)(e),t=(0,s.compact)(t),(0,s.isEmpty)(e)||(0,s.isEmpty)(t)?0:(0,l.avg)([c(e,t),c(t,e)])};const d=(0,r.lazy)((()=>[{x:0,y:1},{x:9,y:.8},{x:16,y:.3},{x:20,y:0}]));function h(e){return(0,n.clamp)(0,1,(0,o.lerp2d)(e,...d()))}t.scaled_delta_e=h},40401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeNearCentroids=t.mergeLabhashes=t.dominantColorsFromModes=t.maybeFilterGrey=t.centroidsScore=t.extractDominantColors=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(41400),o=i(98553),l=i(31586),u=i(68708),c=i(48884),d=i(22454),h=i(50213),f=i(56038),m=i(82647),p=i(44983),g=i(70417),y=i(28874),w=i(85810),v=i(3048),b=i(76490),S=i(1971),P=(0,r.lazy)((()=>(0,h.mkLogger)("color.DominantColors")));t.extractDominantColors=function(e,t=S.ModeCount){return(0,f.timeSync)("img.extractDominantColors",(()=>function(e,t=S.ModeCount){const i=Date.now(),r=y.Settings.dominantColorKmeansRuns.valueOrDefault,a=new d.CountingSet;for(const i of E({labs:e,minK:t}))a.incr((0,w.toLabhash)(i));const h=T[y.Settings.dominantColorDeltaE.valueOrDefault]??v.ciede2000_delta_e;const f=a.sortedByKey().valuesToA((e=>(0,w.unlabhash)(e)));let g=(0,l.round)(t+y.Settings.dominantColorMergeThreshold.valueOrDefault);function x(e){const i=t,r=4*t;g=Math.round(Math.max(i,Math.min(r,e)))}const C=f.length<=g?[]:(0,s.compact)(_.slice(0,r).map((e=>{const r=(0,p.kmeans)(f,g,{...M,seed:e}),s=k(r.centroids,f.length);if(s.lengtht&&x(g-1);const n=s.slice(0,t),o=(0,l.sigFigs)(function(e){const t=new m.Average;for(const[i,r]of a.entries()){const s=(0,w.unlabhash)(i),n=(0,c.leastByCtx)(e,(e=>h(e.centroid,s)));null!=n&&(0,l.times)(r,(()=>t.push(n.value)))}return t.p84}(n),2);return{...r,centroids:n,description:{kIn:g,kOut:r.centroids.length,kMerged:s.length,score:o,iterations:r.iterations,uniqColors:a.size,elapsedMs:Date.now()-i},score:o}})));P().trace("extractDominantColors()",{kmeansResults:C.map((e=>(0,u.pick)(e,"description","score")))});const F=(0,c.leastBy)(C,(e=>e.score));if(null==F)return P().info("kmeans failed or was disabled, using dominantColorsFromModes",{runs:r}),D(a,t);const A=(0,o.stringify)({...F?.description,elapsedMs:Date.now()-i}),I=(0,n.sortBy)(F?.centroids,(e=>-e.size)).map((e=>b.DominantColor.fromCentroid(e,f.length)));return P().debug("extractDominantColors() result",{description:A,score:F?.score,totalColors:a.size,totalPixels:f.length,iters:F?.iterations,dominantColors:(0,b.dominantColorsToRgbHex)(I),pixelCount:f.length}),{dominantColors:I,description:A,dominantColorScore:F?.score}}(e,t)))},t.centroidsScore=function(e,t){const i=new m.Average;for(const r of e){const e=(0,c.leastBy)(t,(e=>(0,v.ciede2000_delta_e)(e.centroid,r)));null!=e&&i.push((0,v.ciede2000_delta_e)(e.centroid,r))}return i};const _=[6147062518717073,8176726750919909,5426648081701673,0xce2a345532a3c,0x713f9716da824,6348935463312109,5900323173950995,7358780886584433,5704068712193493,0x51ceeef755892,0xe1557fe94c084,0xd42d7cc96d6b4,0xcbc36dfd76e8a,6738189173486085,8537822851166899,5390086061821835,7712057976331355,0xe9b820db7a8e4,0xb96cebcd6aa40,7036994544380825,5353634786120155,0x99a11417794bc,0xa93d36019aaae,0x74a470887095e,5481147022770415,5347523348244809,0x541d1098e90fc,0xa24d9fb3510c2,0x78aa8e4f692fa,6354921850669697,0x714e1ec1b0a14,8622097963014773,0x6ff5d462d8eb6,0x6782a6b5166b8,7128984079394103,0xe6efba28a3752,5088704486053871,0xc84df40627fae,8018285280412081,4524300326741245,8307147030534695,8135486835878813,7699950603263999,0xb2889592968ae,5903399874280295,7462660765348991,6442509751447017,0xe218d44834db6,7214173935589545,6001326758941961,0x53eb7d39bbb50,0xc3a7ab8add332,0x4e6e81bc443e2,6757635537583321,8501611905255957,0x51840465cc07c,5958243312989149,8928005021308717,5032083390680559,0xb35d70ac51c68,0xfc3826a2dfe7c,0xd155853c61e96,0xda2045ee9be1e,4753952745315177],T={cie76:v.cie76_delta_e,cie94:v.cie94_delta_e,ciede2000:v.ciede2000_delta_e},M=(0,r.lazy)((()=>({maxIterations:50,initialization:"kmeans++",distanceFunction:T[y.Settings.dominantColorDeltaE.valueOrDefault]})));function E({labs:e,minK:t,thresh:i,retries:r=3}){if(r<0)return P().debug("maybeFilterGrey(): exhausted retries: grey filtering disabled."),e;const s=i??y.Settings.dominantColorGreyThreshold.valueOrDefault;if(!(0,l.gt0)(s))return P().debug("maybeFilterGrey(): grey threshold is <= 0: grey filtering disabled."),e;const n=e.filter((e=>Math.abs(e[1])+Math.abs(e[2])>=s));return n.length>=e.length/2?(P().debug("maybeFilterGrey(): sufficient remaining pixels with this threshold.",{greyThreshold:s,minK:t,pixelCount:e.length,filteredCount:n.length}),n):(P().debug("maybeFilterGrey(): insufficient remaining pixels with this threshold. Retrying with smaller threshold.",{greyThreshold:s,minK:t,retries:r,pixelCount:e.length,filteredCount:n.length}),E({labs:e,minK:t,thresh:.75*s,retries:r-1}))}function D(e,t){const i=e.countSum,r=e.size;x(e);const n=e.size,a=(0,s.compact)(e.top(t).map((([e,t])=>b.DominantColor.fromLabhash({labhash:e,pct:Math.round(100*t/i)})))),l=100-(0,g.sumf)(a,(e=>e.pct));return{dominantColors:a,description:"dominantColorsFromModes: "+(0,o.stringify)({uniqColors:r,mergedColors:n,pixelCount:i,pctOmitted:l})}}function x(e,t=y.Settings.dominantColorMergeThreshold.valueOrDefault){const i=[];for(const[r,s]of[...e.entriesByCountDesc()]){const n=(0,w.unlabhash)(r),a=i.find((e=>(0,v.ciede2000_delta_e)(e.lab,n)<=t));null==a?i.push({lab:n,labhash:r}):(e.delete(r),e.incr(a.labhash,s))}return e}function k(e,t,i=y.Settings.dominantColorMergeThreshold.valueOrDefault){if(i<=0)return e;const r=[];for(const t of e){const e=r.find((e=>(0,v.ciede2000_delta_e)(t.centroid,e.centroid)<=i));null==e?r.push(t):e.size+=t.size}const s=t/100;return(0,n.sortBy)(r.filter((e=>e.size>s)),(e=>-e.size))}(0,a.later)((()=>{y.Settings.dominantColorDeltaE.watchLater((()=>{M.unset()}))})),t.maybeFilterGrey=E,t.dominantColorsFromModes=D,t.mergeLabhashes=x,t.mergeNearCentroids=k},85409:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Greys=void 0,t.Greys=[{name:"Black",rgb:"#000000"},{name:"90% black",rgb:"#1b1b1b"},{name:"80% black",rgb:"#303030"},{name:"70% black",rgb:"#474747"},{name:"60% black",rgb:"#5e5e5e"},{name:"Grey",rgb:"#777777"},{name:"60% white",rgb:"#919191"},{name:"70% white",rgb:"#ababab"},{name:"80% white",rgb:"#c6c6c6"},{name:"90% white",rgb:"#e2e2e2"},{name:"White",rgb:"#ffffff"}]},86758:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.labsAreGreyscale=t.isLab=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(82647),o=i(28874),l=i(85810),u=(0,r.lazy)((()=>(0,n.mkLogger)("color.Lab")));t.isLab=function(e){return Array.isArray(e)&&3===e.length&&(0,s.within)(0,100,e[0])&&(0,s.within)(-110,110,e[1])&&(0,s.within)(-110,110,e[2])},t.labsAreGreyscale=function(e){const t=o.Settings.greyscaleColorThreshold.valueOrDefault,i=new a.Average,r=new a.Average;for(const t of e){const e=(0,l.clampLab)(t);i.push(e[1]),r.push(e[2])}const s=(i.stdDev??0)+(r.stdDev??0),n=s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LightWikipediaColors=void 0,t.LightWikipediaColors=[{name:"Beige",rgb:"#F5F5DC"},{name:"Laurel green",rgb:"#A9BA9D"},{name:"Light sage",rgb:"#93A58B"},{name:"Light green-cyan",rgb:"#CFEADE"},{name:"Pastel purple",rgb:"#B39EB5"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Powder blue",rgb:"#B0E0E6"},{name:"Vanilla",rgb:"#F3E5AB"}]},42022:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeBits=void 0,t.ModeBits=12},1971:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeCount=void 0,t.ModeCount=7},85434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitModeData=t.pickModeData=t.ModeDataKeys=t.isModeData=void 0;const r=i(31586),s=i(68708),n=i(50989);t.isModeData=function(e){return(0,r.gt0)(e.mode0)&&(0,r.gt0)(e.mode0pct)},t.ModeDataKeys=(0,n.strEnum)("mode0","mode0pct","mode1","mode1pct","mode2","mode2pct","mode3","mode3pct","mode4","mode4pct","mode5","mode5pct","mode6","mode6pct"),t.pickModeData=function(e){return(0,s.pick)(e,...t.ModeDataKeys.values)},t.omitModeData=function(e){return(0,s.omit)(e,...t.ModeDataKeys.values)}},85042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clampRGB=t.rgbTriplet2hex=t.rgbhex2triplet=t.normalizeRgbHex=void 0;const r=i(31586),s=i(39926),n=i(51926),a=i(54993),o=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;function l(e){return[e[0],e[1],e[2]].map((e=>(0,r.clamp)(0,255,Math.round(e))))}t.normalizeRgbHex=function(e){const t=(0,a.toS)(e).trim();return o.test(t)?(0,n.ensurePrefix)(t,"#").toUpperCase():void 0},t.rgbhex2triplet=function(e){const t=(0,a.toS)(e).trim().match(o);if(null!=t)try{return[t[1],t[2],t[3]].map((e=>(0,r.clamp)(0,255,parseInt(e,16))))}catch{return}},t.rgbTriplet2hex=function(e){return"#"+l(e).map((e=>(0,s.leftPad)(Math.round(e).toString(16).toUpperCase(),2,"0"))).join("")},t.clampRGB=l},76596:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),s=i(19851),n=i(22573),a=i(42659),o=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,s.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,o.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,o.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,a.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const r=i(77988),s=i(19851),n=i(55835),a=i(31586),o=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,s.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),h=["year","month","day","hour","minute","second","millisecond"];class f{static fromISO(e,t){const i=d().exec((0,o.toS)(e).trim()),r=i?.groups;return null==r?void 0:f.for((0,c.parseExifDateTime)(r.start,t),(0,c.parseExifDateTime)(r.end,t),(0,a.toInt)(r.index),(0,a.toInt)(r.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,n.map)(e.start,(e=>r.ExifDateTime.fromJSON(e))),(0,n.map)(e.end,(e=>r.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,r=1){if(null==e||!e.isValid||null==t||!t.isValid)return;r=(0,a.clamp)(1,1e3,(0,a.toInt)(r,{defaultValue:1})),i=(0,a.clamp)(0,r-1,(0,a.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const s=e.toMillis(),n=(t.toMillis()-s)/(r+1)*(i+1),o=e.plus({milliseconds:n});return null==o?void 0:new f(e,o,t,i,r)}constructor(e,t,i,r=0,s=1){this.start=e,this.middle=t,this.end=i,this.index=r,this.splits=s,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=h.map((r=>function({start:e,end:t,middle:i,field:r}){return null!=e[r]&&null!=t[r]?i[r]:void 0}({start:e,middle:t,end:i,field:r})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new f(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=f},79842:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(76790),o=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),h=i(51926),f=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),w=i(21330),v=i(928),b=i(54261),S=i(73389),P=i(51275),_=(0,n.lazy)((()=>(0,f.mkLogger)("date.Dated")));function T(e){return null!=e&&(e instanceof w.FuzzyDate||e instanceof r.ExifDate||e instanceof r.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,S.isDateTime)(e)||(0,m.isDateObject)(e))}function M(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof r.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function E(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof r.ExifDate?e.toMillis(l.dayMs):e instanceof w.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),x(e),((e,t)=>e+t))}function D(e){try{if(null==e||(0,h.isString)(e)||(0,c.isNumber)(e))return;return(0,S.isDateTime)(e)?e:e instanceof r.ExifDateTime||e instanceof w.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?s.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void _().warn("datedToDateTime() failed",{d:e,error:t})}}function x(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,b.hasTime)(e)){if((0,c.gt0)((0,v.getMillisecond)(e)))return 0;if((0,c.gt0)((0,v.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,v.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,v.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,v.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,v.getMonth)(e))?l.monthMs-1:l.yearMs-1}function k(e,t){const i=M(e),r=E(e);if(null!=i&&null!=r)return(0,c.gt0)(t)&&t>r-i?{start:Math.round((i+r)/2-t/2),end:Math.round((i+r)/2+t/2)}:{start:i,end:r}}function C(e,t,i,r){const[s,n]=(0,a.sortBy)([k(e,i),k(t,r)],(e=>e?.start));return null!=s&&null!=n&&null!=s&&null!=n&&(s.start===n.start||s.end>=Math.min(n.start,n.end))}function F(e,t){return(0,o.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??w.FuzzyDate.fromISO(e)}t.isDated=T,t.toDated=function(e){return T(e)?e:void 0},t.mapDated=function(e,t){return T(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=M,t.datedToEndTs=E,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof r.ExifDate?s.DateTime.fromObject(e):D(e)},t.datedToDateTime=D,t.datedToPrecisionMs=x,t.isoToPrecisionMs=function(e){return(0,u.map)(F(e),x)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:r}){if(null==e||null==t)return!1;if(i??(i=x(e)),r??(r=x(t)),C(e,t,i,r))return!0;const s=(0,P.getZoneName)(e),n=(0,P.getZoneName)(t);return null==s&&null!=n&&(e=(0,w.setZone)(e,n)??e),null==n&&null!=s&&(t=(0,w.setZone)(t,s)??t),C(e,t,i,r)},t.isoToDated=F,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof s.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const r=i(31586),s=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,s.isString)(e))return(0,r.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),s=i(31586),n=i(54557),a=i(91655),o=new n.FifoCache(512);function l(e){return(0,s.isNumber)(e)?e:(0,r.blank)(e)?void 0:o.getOrSet(e,(()=>(0,a.parseDuration)(e)))}t.decodeDuration=l;const u=new n.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,a.fmtFullDuration)((0,s.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),s=i(40958),n=i(22573),a=i(42659),o=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,o.isNumber)(e))return;if((0,o.isNumber)(e))return e;if((0,o.isDigits)(e))return(0,o.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,s.compact)(d.map((e=>function(e,t){const i=(0,o.toFloat)(e);if(null!=i){if((0,n.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*a.yearMs;case"weeks":case"week":case"w":return i*a.weekMs;case"days":case"day":case"d":return i*a.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*a.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*a.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*a.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,o.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:a.yearMs,s:"y"},{ms:a.weekMs,s:"w"},{ms:a.dayMs,s:"d"},{ms:a.hourMs,s:"h"},{ms:a.minuteMs,s:"m"},{ms:a.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,o.isNumber)(t))return;if(0===t)return"0";if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},98247:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),h=i(68852),f=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function w(e,t,i){const r=t.exec(e);if(null==r||(0,u.isEmptyObj)(r.groups))return;const{year:s,month:n,day:a,hour:c,minute:h,second:p}=(0,d.mapEntries)(r.groups,((e,t)=>(0,l.toInt)(t)));if(null==s||null==n||null==a)return;if(!f.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==h))return;const g=(0,o.map)((0,l.toFloat)(r.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),w=(0,y.timezoneOffsetFromRegExpMatch)(r);return S({year:s,month:n,day:a,hour:c??0,minute:h??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(w)??i,rawValue:e,tzoffsetMinutes:w})}t.UnsetZone=s.Info.normalizeZone(r.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof r.ExifDate&&t instanceof r.ExifTime))return;const i=new r.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:n}){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromFormat(e,i,{zone:n??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,a.blank)(e)?void 0:r.ExifDateTime.from(e,t)??w(e,b(),t)},t.parseExifDateTimeRe=w;const v=/[-:_\s]?/,b=(0,n.lazy)((()=>(0,h.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,v,p.monthRE,v,p.dayRE,/[T\s]/,p.hourRE,v,p.minuteRE,v,p.secondRE,p.subsecRE,/\s?/,h.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function S(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof r.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=r.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,o.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=S},74417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const r=i(51168),s=i(22573),n=i(42659),a=i(49769),o=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),h=i(66649),f=i(98725),m=i(88600);t.recent=function(e,t=5*n.secondMs){return(0,c.isRecentMs)((0,h.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=r.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,s.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,s.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=r.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,a.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,h.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,o.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*n.secondMs):void 0)??(0,f.parseDateTime)(t)?.toMillis()}},12959:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filestampUTC=t.filestamp=void 0;const r=i(39926);t.filestamp=function(e=new Date){return[e.getFullYear(),(0,r.pad2)(e.getMonth()+1),(0,r.pad2)(e.getDate()),"-",(0,r.pad2)(e.getHours()),(0,r.pad2)(e.getMinutes()),(0,r.pad2)(e.getSeconds())].join("")},t.filestampUTC=function(e=new Date){return[e.getUTCFullYear(),(0,r.pad2)(e.getUTCMonth()+1),(0,r.pad2)(e.getUTCDate()),"-",(0,r.pad2)(e.getUTCHours()),(0,r.pad2)(e.getUTCMinutes()),(0,r.pad2)(e.getUTCSeconds())].join("")}},21330:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const n=i(77988),a=i(51168),o=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(31586),f=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),w=i(79842),v=i(66649),b=i(98247),S=i(98725),P=i(928),_=i(54261),T=i(73389),M=i(89724),E=i(17415),D=i(88600),x=i(51275);function k(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class C{constructor(e,t,i){this.year=e,this.month=t,this.day=i,r.set(this,(0,p.lazy)((()=>(0,D.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(S.ISO_YMD_RE.exec(e)?.groups??S.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,h.toGt0)(e?.year);if(null==e||null==t||tk(e))).join("-")}toLocal(){return(0,M.datedToLocal)(this)}toDateTime(){return a.DateTime.fromObject((0,f.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,f.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,f.pick)(e.plus({month:1}),"year","month"):(0,f.pick)(e.plus({year:1}),"year");return new C(t.year,t.month,t.day)}}function F(e,t){if(e instanceof n.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,_.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,E.zoneToTzOffsetMinutes)((0,v.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(r=>(0,d.map)((0,P.getMonth)(e),(s=>(0,d.map)((0,P.getDay)(e),(n=>(0,d.map)((0,P.getHour)(e),(a=>(0,b.dateObjectToExifDateTime)({year:r,month:s,day:n,hour:a,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=C,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",r=15*(0,h.round)(e/15),s=Math.abs(r),n=Math.floor(s/60),a=Math.floor(Math.abs(s%60));return`${t?"UTC":""}${i}${k(n)}:${k(a)}`},t.toExifDateTime=F,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof n.ExifDateTime?e.tzoffsetMinutes:(0,T.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,_.hasTime)(e)||(i??(0,w.datedToPrecisionMs)(e))>=c.dayMs?O(e):F(e,(0,x.getZoneName)(e))?.toISOString({includeOffset:t})};const A="yyyy:MM:dd HH:mm:ss.SSS",I=A+"ZZ";function O(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>k(e))).join(t)}function L(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new C(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,r]=[e,t].map(v.datedToMillis);return null==i||null==r?void 0:i-r}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,h.isNumber)(t)?a.DateTime.fromMillis(t):(0,w.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,x.hasZone)(t)?I:A):void 0},t.datedToYMD=O,t.toFuzzyDate=L,t.sameDay=function(e,t){return(0,h.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,h.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,r=1){if(null==(0,v.datedToMillis)(e)||null==(0,v.datedToMillis)(t))return;const[s,n]=[e,t].map((e=>(0,v.datedToMillis)(e))).sort(),o=(n-s)/(r+1),l=(0,x.getZoneName)(e),u=l===(0,x.getZoneName)(t)?l:void 0,c=a.DateTime.fromMillis(s+o*i,{zone:u});return[e,t].some((e=>!(0,_.hasTime)(e)))?L(c):c},t.setZone=function(e,t,i){const r={...(0,f.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,x.hasZone)(e)},s=(0,E.normalizeZone)(t);if(null!=e&&null!=s&&(0,_.hasTime)(e))return e instanceof y.DateInterval?e.setZone(s,r):F(e)?.setZone(s,r)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,h.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,w.datedToDateTime)(e);if(null==i)return;const r=(0,x.getZoneName)(e);return null!=r&&"UTC"!==r||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const o=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),h=i(49769),f=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),w=i(68852),v=i(4001),b=i(28874),S=i(24689),P=i(79842),_=i(66649),T=i(98247),M=i(21330),E=i(54261),D=i(73389),x=i(16400),k=i(88600),C=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return C().tap({msg:"extractDateFromPath",result:O.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return O.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return O.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,f.mapNumeric)((0,_.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,w.concatRegexp)([/^/,t.yearRE,w.RegExpOptional.from(/-/,t.monthRE,w.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,w.concatRegexp)([/^/,t.yearishRE,w.RegExpOptional.from(/-/,t.monthishRE,w.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=I({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,D.isDateTime)(i)?i:(0,E.isExifDateTime)(i)?i.toDateTime():void 0};const F=new Map;function A(e,t,i){try{const r=(0,T.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=r)return r;const s=(0,h.getOrSet)(F,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void C().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,T.parseExifDateTimeFormat)({input:s?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void C().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function I({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:r=!0,descPredicate:s=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const n=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(v.stripDSC));if(0!==n.length)for(const{desc:e,f:a}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>S.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,T.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:T.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(b.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(b.Settings.extraDateTimeFormats.values)){const r=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${r})`,f:i=>A(i,r,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>o.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of O.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:r}))if(s(e))for(const e of n){const t=a(e);if(null!=t&&(0,k.isValidDate)(t))return t}}t.parseDated=I;class O{constructor(e={}){r.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&b.Settings.fuzzyDateParsing.watchLater((()=>a(this,r,"m",n).call(this))),null==e.fuzzyYearParsing&&b.Settings.fuzzyYearParsing.watchLater((()=>a(this,r,"m",n).call(this))),a(this,r,"m",n).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??b.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??b.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!b.Settings.usePathsToInferDates.valueOrDefault)return;M.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=I({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=O,r=new WeakSet,s=function(e){const t=new L(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},n=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new w.RegExpEscaped("(?"+(0,x.monthNames)().map(w.escapeRegExp).join("|")+")");a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE]),a(this,r,"m",s).call(this,[e,t.seps,t.yearRE]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,e]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},O.instance=(0,u.lazy)((()=>new O));class L{constructor(e){this.regex=e instanceof RegExp?e:(0,w.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return M.FuzzyDate.for({year:(0,f.toInt)(t.year),month:(0,f.toInt)(t.month)??(0,x.monthName2index)(t.monthname),day:(0,f.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const r=i(55835),s=i(31586),n=i(54261);function a(e){return e instanceof Date?e.getMinutes():e?.minute}function o(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=a,t.getSecond=o,t.getMillisecond=l,t.getCentisecond=function(e){return(0,r.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,n.hasTime)(e)&&((0,s.gt0)(a(e))||(0,s.gt0)(o(e))||(0,s.gt0)(l(e)))},t.getSecMs=function(e){return(0,r.map)(o(e),(t=>{const i=l(e)??0;let r=(t+i/1e3).toString();for(t<10&&(r="0"+r),0===i&&(r+=".");r.length<6;)r+="0";return r}))}},54261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const r=i(77988),s=i(31586),n=i(68708);t.hasTime=function(e){if(!(0,n.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,s.gt0)(t.hour)||(0,s.gt0)(t.minute)||(0,s.gt0)(t.second)||(0,s.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof r.ExifDateTime}},73389:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const r=i(51168);t.isDateTime=function(e){return r.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const r=i(51168),s=i(19851),n=i(42659),a=i(55835),o=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),h=i(74417),f=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,s.lazy)((()=>w(l.Settings.datesBeforeAreEstimated.valueOrDefault)??w(l.Settings.datesBeforeAreEstimated.defaultValue)));function w(e){return(0,a.map)((0,c.isoToDated)(e),v)}function v(e){return(0,o.isNumber)(e)?T(e):100*b(e)+((0,m.getCentisecond)(e)??0)}function b(e){if((0,o.isNumber)(e))return Math.floor(T(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function S(e,t){if(null==e||e<0)return;let i=e;const r=()=>{const e=i%100;return i=Math.floor(i/100),e},s=10*r(),n=r(),a=r(),l=(0,o.toGt0)(r()),u=(0,o.toGt0)(r()),c=(0,o.toGt0)(r());return{year:i,month:c,day:u,hour:l,minute:a,second:n,millisecond:s,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=S(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):f.FuzzyDate.for(i)}function _(e,t){return T(Date.now()-e,t)}function T(e,t){return v(r.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const r=i(19851),s=i(76790),n=i(31586),a=i(9092),o=(0,r.lazy)((()=>{const e=new a.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const r=new Intl.DateTimeFormat(t,{month:i});(0,n.times)(12,(s=>{const n=r.format(new Date(2017,s));e.set(n,s+1),"short"===i&&"en-US"===t&&e.set(n+".",s+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:o().get(e)},t.monthNames=function(){return(0,s.sort)([...o().keys()])}},42499:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLuxon=void 0;const r=i(51168),s=i(19851),n=i(19043),a=i(28874);t.setupLuxon=(0,s.lazy)((async()=>{r.Settings.throwOnInvalid=!1,a.Settings.twoDigitCutoffYear.watch((e=>r.Settings.twoDigitCutoffYear=e)),r.Settings.defaultLocale=await(0,n.locale)()}))},17415:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),h=i(54993),f=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,n.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const r=(0,f.leastBy)(g(),(t=>Math.abs(t-e)));return null!=r&&Math.abs(r-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(r)}t.isUTCZone=function(e){return b(e)||0===S(e)?.offset(Date.now())},t.normalizeZone=S,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,o.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=_,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:_(i)};const T=/\b(?Z|UTC|GMT)\b/,M=/(?[-±+−])/,E=/[-−]/,D=/(?[01]\d)/,x=/(?[01]?\d)/,k=/(?::(?\d\d))/;function C(e){return b(e)?0:F((0,t.TimezoneOffsetRE)().exec(e))}function F(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,a.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=E.test((0,h.toS)(e.groups.tzSign))?-1:1,r=(0,l.toInt)(e.groups.tzMinutes)??0,s=null==t?void 0:i*(60*t+r);return w(s)?s:void 0}t.TimezoneOffsetRE=(0,n.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),T,new m.RegExpEscaped("|"),M,D,m.RegExpOptional.from(k),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=C,t.timezoneOffsetFromRegExpMatch=F;const A=/\b(?(?:Etc\/)?GMT)\b/,I=(0,n.lazy)((()=>(0,m.concatRegexp)([A,M,x,m.RegExpOptional.from(k)])));function O(e){return F(I().exec(e))}t.ianaZoneToOffsetMinutes=O,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,a.blank)(e))return;const i=O(e)??C(e);if(null!=i)return _(i);if(null!=t){const i=S(e);if(null!=i)return _(i.offset(t))}}},88600:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),h=i(28874),f=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),w=(0,s.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),v=(0,s.lazy)((()=>(0,n.compact)(h.Settings.badDates.values.map((e=>(0,f.isoToDated)(e)))))),b=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,p.datedToISO)(e)))))),S=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,y.datedToLocal)(e)))))),P=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,m.datedToMillis)(e))))));function _(e){if(null==e)return!1;const t=M(e);return w().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return _(e)?e:void 0},t.isValidDate=_;const T=String(new Date("bad"));function M(e){try{if(!(0,f.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===T)return T;const t=(0,n.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const s=[];if((0,l.isNumber)(e)||s.push("year is not a number"),(0,l.lt)(e,h.Settings.minValidYear.valueOrDefault)&&s.push("year is less than "+h.Settings.minValidYear.key),(0,u.gt)(e,E())&&s.push("year is in the future"),null==t&&null!=i&&s.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const n=r.DateTime.fromObject({year:e,month:t,day:i});n.isValid||s.push(n.invalidExplanation??"not valid")}return(0,n.compact)(s)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=h.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const r=(0,m.datedToMillis)(e);(0,u.gt)(r,Date.now()+i)&&t.push("date is too far in the future: see "+h.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):S().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):b().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,a.toNotBlank)((0,n.uniq)((0,n.compactBlanks)(t)).join("; "))}catch(t){return w().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=M;const E=(0,s.lazy)((()=>r.DateTime.now().plus({milliseconds:h.Settings.maxValidFutureMs.valueOrDefault}).year),o.dayMs);t.mapValidDate=function(e,t){return _(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==M({year:e,month:t,day:i})}},51275:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const r=i(77988),s=i(31586),n=i(24689),a=i(73389);t.hasZone=function(e){return null!=e&&!(0,s.isNumber)(e)&&(e instanceof n.DateInterval||e instanceof r.ExifDateTime?e.hasZone:!!(0,a.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==r.UnsetZoneName&&e.zone.offset(Date.now())!==r.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,a.isDateTime)(e)?e.zoneName===r.UnsetZoneName?void 0:e.zone?.name:e instanceof r.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},82261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cacheDbDir_=void 0;const r=i(51926),s=i(49776),n=i(38835),a=i(95696),o=i(70854),l=i(73428),u=i(28874),c=i(15056);t.cacheDbDir_=async function(e=u.Settings.libraryDir.valueOrDefault,t=c.Schemas.models){const i=(0,o.libraryUidStore)(e);if(null==i)throw new Error("Library directory is not set"+n.NoLibraryErrorFlag);const d=await i.readUid_(),h=a.PosixFile.for((0,s.cacheDir_)()).join(t+"-live-db",d);await h.mkdirp_();const f=h.join("README.txt");return await(0,l.writeTextfile_)(f.nativePath,...(0,r.wrap)(["This folder is used by PhotoStructure for your library stored in",e,"You will corrupt your library if you remove this directory while PhotoStructure is running.","See https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837 for details."].join("\n\n"))),h}},92407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLiveDbDir_=t.cacheDbFile_=void 0;const r=i(19851),s=i(87290),n=i(50213),a=i(28874),o=i(82261),l=i(15056),u=i(7311),c=i(44955),d=(0,r.lazy)((()=>(0,n.mkLogger)("db.CheckLocalDbReplica")));async function h({libraryDir:e=a.Settings.libraryDir.valueOrDefault,schema:t=l.Schemas.models}={}){return(await(0,o.cacheDbDir_)(e,t)).join(u.SqliteBase)}t.cacheDbFile_=h,t.getLiveDbDir_=async function(e=a.Settings.libraryDir.valueOrDefault){if(!a.Settings.forceLocalDbReplica.valueOrDefault){const t=(0,l.pathToDb)(await(0,s.setupLibraryDataDir_)(e),l.Schemas.models);try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!1}}catch(e){d().info("SQLite cannot directly write to the library: trying to use a local db replica.",{libraryDb:t,error:e})}}const t=await h({libraryDir:e,schema:l.Schemas.models});try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!0}}catch(e){return d().throw("SQLite cannot directly write to the library or the cacheDir.",{cacheDbFile:t,error:e})}}},5531:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},55332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupCold_=void 0;const r=i(19851),s=i(50213),n=i(76187),a=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbBackupCold")));t.dbBackupCold_=async function(e,t){await t.mkdirp_();const i=[];try{for(const r of(0,n.sqliteFiles)(e)){const e=t.join(r.base).wip();i.push(e),await r.copyFile_(e)}return a().tap({msg:"completed",level:"info",result:await Promise.all(i.map((e=>e.unwip_()))),meta:{srcDbFile:e,destDir:t}})}catch(e){throw await Promise.all(i.map((e=>e.unlink()))),e}}},91872:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleDbRetries_=void 0;const r=i(50213),s=i(70025),n=i(28874),a=i(45599),o=i(41400),l=i(30976),u=i(56038),c=(0,a.defer)((()=>(0,r.mkLogger)("db.DbRetries")));t.handleDbRetries_=function(e,t,i,r){const a=Date.now();let d=0;const h=a+n.Settings.maxBusyDbMs.valueOrDefault;return(0,u.time)(e,(async()=>{for(;Date.now()=h)throw c().error(e+": Caught db error. Not retrying.",{error:t}),t;{const i=(0,l.randomInt)(500,1500)*++d;c().warn(e+": Caught db error. Retrying in "+i+"ms.",{name:e,error:t}),r?.(),await(0,o.delay)(i)}}return t().close(),c().throw(e+": handleDbRetries(): timeout after "+n.Settings.maxBusyDbMs.valueOrDefault+"ms")}))}},12943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toDbValued=t.isDbValued=t.isDbValue=void 0;const r=i(79842),s=i(66649),n=i(40958),a=i(68708);function o(e){return null===e||(0,n.includes)(["number","string"],typeof e)}t.isDbValue=o,t.isDbValued=function e(t){return null!=t&&Array.isArray(t)?t.every(e):(0,a.entries)(t).every((([,e])=>o(e)))},t.toDbValued=function(e){return(0,a.mapFields)(e,((e,t)=>{if(!e.startsWith("$"))return"boolean"==typeof t?[e,t?1:0]:o(t)?[e,t]:(0,r.isDated)(t)?[e,(0,s.datedToMillis)(t)]:void 0}))}},65753:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maxBatchPluckSize=void 0;const r=i(19851),s=i(7282),n=i(28874);t.maxBatchPluckSize=(0,r.lazy)((()=>Math.round(n.Settings.dbBatchSelectSize.valueOrDefault*((0,s.isTest)()?.25:5))))},80632:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pageSizeBytes=t.mkdb_=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(54993),u=i(50213),c=i(23560),d=i(65211),h=i(29882),f=i(53265),m=i(66430),p=i(66184),g=i(28874),y=i(15674),w=i(87550);function v(){const e=g.Settings.dbPageSizeBytes.valueOrDefault;return Math.pow(2,(0,a.clamp)(1,28,Math.round(Math.log2(e))))}t.mkdb_=function({nativePath:e,timeoutMs:t=g.Settings.dbBusyTimeoutMs.valueOrDefault,logSql:i=g.Settings.logSql.valueOrDefault}){e=(0,f.resolve)(e),(0,h.mkdirpSync_)((0,r.dirname)(e));const b=(0,h.posixPathFromGrandparent)(e),S=(0,m.nativePathSizeSync)(e),P=(0,u.mkLogger)("db.mkdb("+b+")");if(null!=S){const E=Math.round(S/o.MiB),D=Math.ceil(1.5*E);D>g.Settings.dbCacheSizeMb.valueOrDefault&&(P.info("Dynamically setting dbCacheSize to "+g.Settings.dbCacheSizeMb.value,{db:e,dbFileSizeMb:E}),g.Settings.dbCacheSizeMb.envValue=D);const x=Math.round(1.5*E);x>g.Settings.maxMemoryMb.valueOrDefault&&(P.warn("Large database: setting maxMemoryDb to "+x+"MB",{dbFileSizeMb:E,"Settings.maxMemoryMb":g.Settings.maxMemoryMb.valueOrDefault}),g.Settings.maxMemoryMb.envValue=x)}P.info("Opening "+e+"...");const _={fileMustExist:!1,readonly:!1};if((0,a.gt0)(t)&&(_.timeout=Math.ceil(t)),i){const k=(0,u.mkLogger)("SQLite("+b+")"),C=(0,p.defaultLogLevel)();function F(e,...t){var i;(0,n.blank)(e)||k.log(C,(i=e,(0,l.toS)(i).replace(/\s{2,}/g," ")),{args:t})}_.verbose=F}const T=new w(e,_);P.info("Open. Setting PRAGMAs...");for(const A of(0,s.compact)(['encoding = "UTF-8"',"threads = "+(0,y.maxCpus)(),"foreign_keys = ON","page_size = "+v(),"trusted_schema = 0","cache_size = -"+Math.round(g.Settings.dbCacheSizeMb.valueOrDefault*o.MiB/1024),"locking_mode = NORMAL","journal_mode = WAL",(0,a.gt0)(g.Settings.dbBusyTimeoutMs.valueOrDefault)?"busy_timeout = "+g.Settings.dbBusyTimeoutMs.valueOrDefault:null,"temp_store = MEMORY","synchronous = "+g.Settings.dbSynchronousMode.valueOrDefault,"case_sensitive_like = 0","wal_autocheckpoint = "+((0,c.isDbJanitorService)()?(0,l.toS)(g.Settings.dbWalAutoCheckpoint.valueOrDefault):"0"),"auto_vacuum = "+g.Settings.dbAutoVacuumMode.valueOrDefault]))P.tapThunk({msg:"PRAGMA "+A,result:()=>T.pragma(A)});const M=T;return M.__uid=(0,d.uid)(),M},t.pageSizeBytes=v},99315:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},95704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withIdBatches=void 0;const r=i(40958),s=i(31586),n=i(59455),a=i(65753),o=i(51040);t.withIdBatches=async function(e){const t=(0,s.toGt0)(e.batchSize)??(0,a.maxBatchPluckSize)(),i=(0,o.dbValueToEscapedString)(e.primaryKeyColumnName),l=(0,r.compactBlanks)([i+" > :min",...(0,n.toA)(e.whereClauses)]).join(" AND "),u=e.db.prepare((0,r.compactBlanks)(["SELECT "+i,"FROM "+(0,o.dbValueToEscapedString)(e.tableName),"WHERE "+l,"ORDER BY "+i,"LIMIT :limit"]).join(" "));let c=-1;for(;;){const i=u.pluck().all({min:c,limit:t});if(0===i.length)return;await e.fn(i),c=(0,r.last)(i)}}},76187:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSqliteFile=t.sqliteSizeBytes=t.sqliteFiles=void 0;const r=i(17217),s=i(87391),n=i(7311);t.sqliteFiles=function(e){return[e,...s.SQLiteSuffixes.map((t=>e.sibling(e.base+t)))].filter((e=>e.existsSync({refresh:!0})))},t.sqliteSizeBytes=async function(e){return(await e.size({refresh:!0})??0)+(await e.sibling(e.base+"-wal").size({refresh:!0})??0)};const a=[n.SqliteExt,...[...s.SQLiteSuffixes,"-shm"].map((e=>n.SqliteExt+e))];t.isSqliteFile=function(e){const t=(0,r.basename)(e);for(const e of a)if(t.endsWith(e))return!0;return!1}},51040:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitBatchSql=t.dbValueToEscapedString=void 0;const r=i(40958),s=i(31586),n=i(54993),a=/^\w+$/;t.dbValueToEscapedString=function(e){if((0,s.isNumber)(e))return e.toString();const t=(0,n.toS)(e);return a.test(t)?t:`'${t.replace(/'/g,"''")}'`};const o=/--.+$/gm,l=/\s+/g;t.splitBatchSql=function(e){const t=(0,r.compactBlanks)((0,n.toS)(e).split(/;/).map((e=>e.replace(o,"").replace(l," ").trim()))),i=[];let s;for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertDirSQLiteReadWrite_=t.isDirSQLiteReadWrite=t.firstDirSQLiteReadWrite=void 0;const r=i(19851),s=i(50357),n=i(30976),a=i(50213),o=i(95696),l=i(80632),u=i(76187),c=(0,r.lazy)((()=>(0,a.mkLogger)("db.SQLiteReadWrite")));async function d(e){try{return await h(e),c().info("isDirSQLiteReadWrite(): true",{dirNativePath:e}),!0}catch(t){return c().warn("isDirSQLiteReadWrite(): false",{dirNativePath:e,error:t}),!1}}async function h(e){const t=o.PosixFile.for(e),i=(0,n.randomChars)(8),r=t.child(".test-"+i+".sqlite");let a=null;try{await t.mkdirp_(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3}),a.exec("CREATE TABLE t (s VARCHAR(16) NOT NULL)"),a.exec(`INSERT INTO t (s) VALUES ('${i}')`);{const e=a.prepare("SELECT s FROM t").all();(0,s.eql)(e,[{s:i}])||c().throw("unexpected rows",{rows:e})}a.exec("VACUUM"),a.close(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3});{const e=(0,n.randomChars)(8);a.exec(`INSERT INTO t (s) VALUES ('${e}')`);const t=a.prepare("SELECT s FROM t ORDER BY s").pluck().all();(0,s.eql)(t,[i,e].sort())||c().throw("unexpected rows",{rows:t})}}finally{try{a?.close()}catch{}await Promise.all((0,u.sqliteFiles)(r).map((e=>e.rm())))}}t.firstDirSQLiteReadWrite=async function(...e){for(const t of e)if(null!=t&&await d(t))return t},t.isDirSQLiteReadWrite=d,t.assertDirSQLiteReadWrite_=h},87391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SQLiteSuffixes=void 0,t.SQLiteSuffixes=["-wal","-journal"]},15056:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),s=i(7311);function n(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=n,t.pathToDb=function(e,t){return n(e,t).join(s.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const a=n(i(76760)),o=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),w=i(70698),v=i(64680),b=i(29882),S=i(45969),P=i(43334),_=i(28874),T=i(41692),M=i(32774),E=i(80612),D=i(32551),x=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function k(){if((0,S.isDocker)())return[{dir:"/tmp/.photostructure-cache"+x(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,a.join)(i,".photostructure-cache"+x()),preexistingDir:i});return e}}function C(){if((0,S.isDocker)())return(0,o.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,a.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+x(),preexistingDir:M.DefaultDockerLibraryDir},...k()]);const e=(0,o.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),a.default.resolve((0,D.homeDir)(),"AppData","Local")]:P.isMac?[a.default.resolve((0,D.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,a.join)((0,D.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,a.join)(e,t),preexistingDir:e})));return i.push(...k()),i}t.tmpCacheDirs=k,t.tmpDirs=function(){return(0,E.filterDirs)({dirs:k(),desc:"tmp"})},t.cacheDirs=C,t.defaultCacheDir=(0,d.lazy)((()=>(0,E.firstDir)({dirs:C(),desc:"cache"})));const F=(0,d.lazy)((()=>{(0,T.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(A)}));function A(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{F();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,b.mkdirpSync_)(e),(0,w.writeCachedirTag_)(e).then((()=>(0,v.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=A},46292:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),s=i(45969),n=i(41692),a=i(32774),o=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,n.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,s.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,o.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:a.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:a.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,s.isDocker)()?c:(0,o.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),s=i(45969),n=i(32774);t.defaultLibraryDir=function(){return(0,s.isDocker)()?n.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,s.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const s=r(i(76760)),n=i(40958),a=i(72993),o=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),s.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(s.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,o.env)().XDG_DATA_HOME,(0,o.env)().XDG_CONFIG_HOME,s.default.resolve((0,d.homeDir)(),".config")),(0,n.compactBlanks)(e).map((e=>({dir:s.default.join(e,(0,a.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),s=i(96706),n=i(29882);t.envConfigDir=function(){const e=(0,s.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,n.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),s=i(40958),n=i(22573),a=i(66430);function o({dirs:e,desc:t}){for(const{dir:i,preexistingDir:o}of(0,s.compact)(e))if(!(0,n.blank)(i)){if((0,a.isReadWriteableDirectorySync)(i))return i;if((0,n.blank)(o)||(0,a.isReadWriteableDirectorySync)(o))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=o,t.filterDirs=function({dirs:e,desc:t}){return(0,s.compact)(e.map((e=>o({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),s=i(76760),n=i(1708),a=i(19851),o=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,a.lazy)((()=>{const e=[];u.isWin?e.push(n.env.USERPROFILE):e.push(n.env.HOME);for(const t of(0,o.compactBlanks)(e)){const e=(0,s.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),s=i(49776),n=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[n.libraryDataDir,n.libraryPreviewsDir,s.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},9595:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),s=i(54993),n=i(29882),a=i(28874);function o(e){return(0,r.toNotBlank)((0,s.toS)(e))??a.Settings.libraryDir.valueOrDefault}t.libraryDir=o,t.originalsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,n.resolveMaybe)(o(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),s=i(55835),n=i(37805),a=i(15056),o=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${n.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function w(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+o.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function v(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function b(e){return y(v(e),!1)}function S(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(S(e))}function _(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function T(e){return y(_(e))}async function M(e){return y((0,s.map)(g(e),(e=>(0,a.pathToDbDir)(e,a.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await w(t);return(0,r.uniq)([t,i,await b(t),await P(t),await T(t),await M(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=w,t.libraryOriginalsDirPosixFile=v,t.setupLibraryOriginalsDir_=b,t.libraryPreviewsDirPosixFile=S,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=_,t.setupLibrarySyncReportsDir_=T,t.setupLibraryDbDir_=M},46296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),w=i(80612),v=i(32551);function b(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:s.default.resolve((0,v.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,v.homeDir)()}]:(0,a.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>s.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function S(){return(0,w.firstDir)({dirs:b(),desc:"logs"})}t.defaultLogDirs=b,t.defaultLogDir_=S,t.logDir=(0,n.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,o.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,o.notBlank)(i)?i:S()}catch(e){return console.error("defaultLogDir_() failed",e),s.default.resolve((0,v.homeDir)(),"logs")}}))},55939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(44198),o=i(43334),l=i(24399),u=i(32551);async function c(){return o.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,s.lazy)((async()=>{if(o.isWin){const e=await c();if((0,n.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,s.lazy)((()=>(0,a.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),s=i(7282),n=i(29325),a=i(44198);t.getDevEnvFlag=function(e){return!(0,s.isProd)()&&!(0,n.isPacked)()&&((0,r.toBoolean)((0,a.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,a.env)()[e]=String(t)}},34580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),s=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,s.env)().DO_NOT_TRACK)}},44198:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const s=r(i(73024)),n=i(76760),a=r(i(1708)),o=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),w=i(6012),v=i(96706);t.env=(0,o.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>a.default.env[e])).join(n.delimiter).split(n.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===a.default.env.PS_LICENSE||e.push((0,n.join)((0,f.homeDir)(),".psenv"));const t=(0,v.SensitiveEnvRE)(),i={...a.default.env};for(const r of e)try{const e=(0,d.debom)(s.default.readFileSync((0,p.resolve)(r))),n=(0,w.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(n))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),s=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let n;for(const a of(0,s.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(n=e.exec(a));){if(null==n.groups)continue;const{key:e,val:s}=n.groups;if((0,r.blank)(e)||null==s)continue;const a=s.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=a}}return i}},96706:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const s=r(i(1708)),n=i(19851),a=i(22573),o=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,n.lazy)((()=>(0,a.firstNotBlank)(s.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,s.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,n.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,n.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,o.isTrue)(g(e))}},98314:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),s=i(19851),n=i(40958),a=i(22573),o=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),w=i(70025),v=i(57159);function b(...e){if((0,n.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(o.errorName),...e.map(o.errorCode),...(0,n.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(o.ErrorDelimiter)))];return(0,n.uniqSubstrings)(S((0,l.flatten)(i)))}function S(e){return(0,n.compact)(e).filter((e=>!o.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(a.notBlank)}function P(e,t){const i=(0,n.uniqSubstrings)(S(e)),r=t?.maxLen??400,s=t?.trailingChars??64,a=(0,y.sortErrorFlags)([...t?.flags??[],...(0,w.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,w.stripErrorFlags)(i.join(o.ErrorDelimiter)),r-a.length,s)+a.sort().join("")}function _(e,t){return e instanceof v.WrappedError?e.toString():(0,a.blank)(e)?"":P(b(e),t)}t.StartTs=Date.now(),t.logger=(0,s.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,a.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,a.notBlank)(i))return i}},t.splitErrorMessage=b,t.normalizeErrorMessages=S,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,a.blank)(e)&&(e=t.MissingError),_(e,{maxLen:i})+" at "+(0,o.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),s=i(26905),n=i(55835),a=i(54993),o=i(81168);t.describeError=function(e){const t=(0,o.stripSuffix)((0,a.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,n.map)((0,s.errorErrno)(i),(e=>t.push(u.get(e)))),(0,n.map)((0,s.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),s=i(76790),n=i(50989),a=i(68852);t.ErrorFlags=(0,n.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,s.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(a.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},68301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorStore=t.ExtraEventsForPlease=void 0;const r=i(19851),s=i(42659),n=i(75240),a=i(55835),o=i(31586),l=i(68708),u=i(59455),c=i(54993),d=i(50213),h=i(45255),f=i(37628),m=i(99331),p=i(46292),g=i(38835),y=i(32144),w=i(29882),v=i(95696),b=i(55222),S=i(28874),P=(0,r.lazy)((()=>(0,d.mkLogger)("error.EventStore")));function _(e){return(0,l.omit)(e,"breadcrumbs")}t.ExtraEventsForPlease=7;class T{constructor(e){this.root=e}datedRoot(e=new Date){return this.root.join((0,c.toS)(e.getFullYear()),(0,c.toS)(e.getMonth()+1))}rmrf(){return this.root.rmrf()}msg2file(e){return this.datedRoot(new Date(e.timestamp*s.secondMs)).join((0,f.shortStringSha)(e.message,8,b.GeoRadix)+".json")}async eventsFrom(e=new Date,t=s.dayMs){const i=e.getTime(),r=i-t,a=i+t;return P().tap({msg:"eventsFrom()",result:(0,u.toA)(await this.datedRoot(e).clear().childFiles((async e=>P().tap({msg:"eventsFrom().childFiles() accept "+e.base,result:(0,y.isJsonExt)(e)&&!(0,w.isHiddenBasename)(e.base)&&(0,o.within)(r,a,e.mtimeMs())})))),meta:{when:e,deltaMs:(0,n.fmtDuration)(t)}})}async eventCount(e=new Date){return(await this.eventsFrom(e)).length}async eventQuotaExceeded(e){const i=(0,c.toS)(e).includes(g.PleaseSendErrorFlag)||(0,c.toS)(e.message).includes(g.PleaseSendErrorFlag),r=await this.eventCount(),s=S.Settings.maxErrorsPerDay.valueOrDefault+(i?t.ExtraEventsForPlease:0);return P().tap({msg:"eventQuotaExceeded()",result:r>=s,meta:{event:_(e),recentEventCount:r,maxErrorsPerDay:s,pleaseSend:i}})}async maybeSendEvent(e){if(e.timestamp=Math.floor(e.timestamp),(0,m.ending)())P().error("maybeSendEvent(): REJECT: we're ending.",{event:_(e)});else if(await this.eventQuotaExceeded(e))P().error("maybeSendEvent(): REJECT: too many recent events.",{event:_(e)});else try{const t=await this.writeEvent_(e);return P().tap({msg:"maybeSendEvent(): "+t==null?"REJECT: previously sent this event already this month":"ACCEPT",result:null!=t?e:void 0,meta:{eventFile:t}})}catch(e){return void P().error("maybeSendEvent(): REJECT: failed to write event.",e)}}writeEvent_(e){return this.msg2file(e).applyIfEmpty_({fn_:t=>t.writeJson_(e),minSizeBytes:3,returnUndefinedIfNotEmpty:!0,timeoutMs:h.ShortCommandTimeoutMs})}}t.ErrorStore=T,T.instance=(0,r.lazy)((()=>(0,a.map)((0,p.configDir)(),(e=>new T(v.PosixFile.for(e).join("events"))))))},70025:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),s=i(38639),n=i(26905),a=i(54993),o=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,a.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,a.toS)(e)+(0,r.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,o.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function w(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function v(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function b(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function S(e){return!!((0,s.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||b(e))||void 0}t.isSqliteBusyError=w,t.isSqliteDisconnectedError=v,t.isSqliteConstraintError=b,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===S(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,n.errorCode)(e)||w(e)||v(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=S;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,s.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,s.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},51837:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalError=void 0;const r=i(38835);class s extends Error{constructor(e){super(e+r.InternalErrorFlag)}}t.InternalError=s},8769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),s=i(31586),n=i(68708),a=i(7282),o=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,n.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const s=!0===i.fatal,c=!0===i.ignorable;if(!s&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),s&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!s||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!s||(0,a.isTest)()||(0,o.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),s}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,s.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,o.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,s.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,s.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(26905),o=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,s.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,s.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,a.errorName)(t)??(0,d.first)(this.causes,a.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(a.errorCode)],a.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,a.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,n.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,n.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,n.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,s.blank)(r)||(i=(0,h.dedupeNeedle)(i,r,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,o.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const a=i(49769),o=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),s.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,a.getOrSet)(n(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),a=n(this,r,"f").get(e);return null!=a&&(a.resolve(t),n(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,s=new WeakMap},34102:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),s=i(19851),n=i(15197);t.ee=(0,s.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new n.CapturingEventEmitter(e)}))},64660:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const s=r(i(73024)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,a.lazy)((()=>n.default.geteuid?.())),h=(0,a.lazy)((()=>n.default.getgroups?.()));function f(e,t){try{return!(0,o.blank)(e)&&(s.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,s.default.constants.R_OK|s.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,s.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:s,processGid:n}){if(null==e)return!1;const a=s??d(),o=null!=n?[n]:h()??[],l=0===a,u=l||e.uid===a,f=l||o.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const s=r(i(76760)),n=i(19851),a=i(81168),o=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,n.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,a.equalsIgnoreCase)(e.basename,i.base))return s.default.join(r,e.basename);throw new o.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),s=i(76760);function n(e){return[...a(e)]}function*a(e){for(;e!==(0,s.dirname)(e);)e=(0,s.dirname)(e),yield e}function o(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=o(e);return t.every((e=>i.includes(e)))}t.ancestors=n,t.ancestorG=a,t.selfAndAncestorG=function*(e){yield e,yield*a(e)},t.childrenSync=o,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return n(e).find((e=>l(e,t)))}},83278:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),w=f(i(1708)),v=i(46466),b=f(i(57975)),S=f(i(38522)),P=i(19851),_=i(40958),T=i(5233),M=i(22573),E=i(42659),D=i(50357),x=i(96249),k=i(98553),C=i(55835),F=i(31586),A=i(68708),I=i(97790),O=i(39926),L=i(51926),R=i(59455),N=i(54993),B=i(48884),j=i(22911),z=i(99331),V=i(56519),W=i(56038),U=i(31562),q=i(76850),H=i(70025),$=i(34102),G=i(80875),J=i(50213),K=i(70417),Y=i(43334),Z=i(81168),X=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),se=i(89968),ne=i(20197),ae=i(88561),oe=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),we=i(27794),ve=i(73428),be=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const Se=(0,P.lazy)((()=>new ae.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),s.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),a.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(s=new WeakMap,a=new WeakMap,r=new WeakSet,b.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,B.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,M.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=Se().get(i);if(null!=r)return r;const s=(0,fe.resolve)(i),n=new Pe(s,t);return Se().set(i,n),Se().set(s,n),n}static clear(e){(0,$.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,$.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,s,"f").unset(),h(this,a,void 0,"f"),this}clearThisAndParent(){return(0,$.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,C.map)(this.statSync(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,s,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",n).call(this)??await d(e=this.clearThisAndParent(),r,"m",n).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,R.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,F.gt0)(t))return;const i=await d(this,s,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,D.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,C.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,O.pad2)(t+1),(0,O.pad2)(i))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,x.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,E.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),B.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>=(0,E.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>(0,E.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,C.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*E.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,oe.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,oe.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,G.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,G.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,q.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,be.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,ve.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,ve.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,ve.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,ve.writeFileSync_)(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces),(0,A.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,we.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,we.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,T.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,z.ending)()?1:3,timeoutMs:0,retryDelay:E.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,r,"m",o).call(this,(0,Z.stripSuffix)(this.base,".gz"),S.default.createGunzip())}async gzip(){return d(this,r,"m",o).call(this,this.base+".gz",S.default.createGzip())}async compressBrotli(){return d(this,r,"m",o).call(this,this.base+".br",S.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,ne.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,ne.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(S.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,_.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new j.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,L.newlineRe)(),(r=>{const s=e.exec(r);null!=s&&(t.maybeResolve(s),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,F.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new j.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),_e)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,s)=>{try{const n=await e.f(r,(0,C.denull)(s));t(n)&&i.resolve(n)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,F.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,n=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,B.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,C.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},o=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,v.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*E.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(w.default.execPath).parent()}},19748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const r=i(28874),s=i(88840),n=i(14036),a=i(29882);function o(e){return t=>r.Settings.respectFileExtensions.valueOrDefault?(0,n.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,a.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=o,t.isBrowserExtension=o(s.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=o(s.ExtTypes.Video),t.isAssetFileExtension=o(s.ExtTypes.AssetFile)},84542:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),s=i(96249),n=i(51926),a=i(54993),o=i(43334);function l(...e){return(0,s.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,a.toS)(e).split((0,n.newlineRe)()))))}t.Newline=o.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(a.toS).join("\n");return o.isWin?t.replace((0,n.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),s=i(19851),n=i(50213),a=i(37805),o=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,s.lazy)((()=>(0,n.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,o.mkdirp_)(i),await(0,d.writeTextfile_)((0,o.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+a.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,a.lazy)((()=>[...(0,o.mapNotBlankOr)(n.default.env.SYSTEMROOT,(e=>[e,s.default.join(e,"System32"),s.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const o=n(i(44652)),l=a(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),w=i(14427),v=i(17217),b=i(16287),S=i(68284);class P{constructor(e,t){this.base=e,(0,w.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class T{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new T(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,v.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},s=await o.stat(t);return new T(i,new P(r,s))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return T.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new T(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>T.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new T(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,S.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,b.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await o.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await o.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=T},20197:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const s=r(i(76760)),n=i(39926),a=i(29882),o=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if(await(0,a.mkdirp_)(r.dir),!i.requireNumber&&await(0,o.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,o.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if((0,a.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},92423:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notInHiddenPhotoStructureDir=t.whyExcludedDirectoryRecursive=t.notExcludedDirs=t.isExcludedDirectory=t.whyExcludedDirectory=t.notExcludedDirPredicates=t.isExcludedFile=t.whyExcludedFile=t.notExcludedFilePredicates=t.excludeBundles=t.excludeGlobs=t.defaultFilePredicates=t.defaultDirPredicates=t.formatPathForGlob=void 0;const l=o(i(83058)),u=i(19851),c=i(40958),d=i(76790),h=i(22573),f=i(55835),m=i(51926),p=i(54993),g=i(48884),y=i(9092),w=i(54557),v=i(50213),b=i(88158),S=i(56519),P=i(46292),_=i(32551),T=i(35280),M=i(87290),E=i(96706),D=i(57902),x=i(43334),k=i(78984),C=i(33995),F=i(28874),A=i(21144),I=i(83278),O=i(48313),L=i(85772),R=i(78133),N=i(46356),B=i(17217),j=(0,u.lazy)((()=>(0,v.mkLogger)("fs.ExcludeGlobs"))),z=new w.FifoCache(256),V=/[\\/]$/;function W(e){const t=(0,p.toS)(e),i=z.get(t);if(null!=i)return i;const r=(0,B.isSimpleFile)(e)?e:I.BaseFile.for(e),s=V.test(t)||r.isDirectorySync(),n=(0,R.native2posix)(r.nativePath),a=s?(0,m.ensureSuffix)(n,"/"):n;return z.set(t,a),z.set(a,a),z.set(r.nativePath,a),a}t.formatPathForGlob=W;class U{constructor(e,t,i=!0){if(r.add(this),this.pattern=e,this.desc=t,this.exclude=i,e.includes("\\")){const t=e;e=(0,R.native2posix)(t),j().warn("globToPredicate(): backslash in patterns aren't supported: assuming you meant forward-slash?",{given:t,input:e})}this.reason=(0,c.compactBlanks)([this.exclude?"not":"",t,"("+(0,m.ellipsize)(e,48,12)+")"]).join(" ");try{this.re=l.default.makeRe(this.pattern,{nocase:F.Settings.globsCaseInsensitive.valueOrDefault,dot:!0,posixSlashes:!0}),this.valid=!0}catch(e){this.valid=!1,j().warn("Cannot parse pattern",{glob:this.pattern,error:e})}this.bundle=this.valid&&null!=this.re?(0,b.pairToObject)(this.reason,a(this,r,"m",s).bind(this)):{}}}r=new WeakSet,s=function(e){const t=W(e),i=this.re.test(t)??this.exclude;return j().tap({msg:"apply()",level:i?D.LogLevels.debug:D.LogLevels.trace,result:i?!this.exclude:this.exclude,meta:{desc:this.desc,pattern:this.pattern,exclude:this.exclude,posixPath:t,matched:i}})};class q{constructor(){n.set(this,[])}push(...e){for(const t of e){if(!t.valid){j().warn("Ignoring invalid glob",{glob:t});continue}const e=a(this,n,"f").find((e=>e.pattern===t.pattern));null==e?a(this,n,"f").push(t):j().debug("Ignoring duplicate glob",{glob:t,prior:e})}}pushNativePath(e,t){this.push(new U((0,R.native2posix)(e),t))}toA(){return a(this,n,"f")}}n=new WeakMap;const H=new U("**/.*","hidden file"),$=new U("**/.*/","hidden directory"),G=(0,u.lazy)((()=>{const e=new q;e.push($,H);for(const t of[{s:"bin",desc:"command binary"},{s:"dev",desc:"device file"},{s:"etc",desc:"system configuration file"},{s:"initrd",desc:"initial ramdisk"},{s:"proc",desc:"process metadata"},{s:"sbin",desc:"system binary"},{s:"snap",desc:"snap software"},{s:"sys",desc:"system metadata"},{s:"Dell",desc:"Windows driver"},{s:"Drivers",desc:"Windows driver"},{s:"Intel",desc:"Windows driver"},{s:"Microsoft",desc:"Windows driver"},{s:"NVIDIA",desc:"Windows driver"},{s:"Windows.old",desc:"Windows system"},{s:"Windows",desc:"Windows system"}])e.push(new U((x.isWin?"*":"")+"/"+t.s+"/",t.desc));if(x.isWin)for(const t of["ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemRoot","windir"]){const i=(0,E.getEnv)(t);(0,h.blank)(i)||e.pushNativePath(i,`%${t}%`)}x.isLinux&&e.push(new U(`${(0,_.homeDir)()}/snap/`,"Snap software"));for(const t of[{s:"__MACOSX",desc:"macOS resource fork"},{s:"_includes",desc:"code"},{s:"@eaDir",desc:"Synology thumbnail"},{s:"@Recently-Snapshot",desc:"QNAP snapshot"},{s:"@Recycle",desc:"QNAP trash"},{s:"@SynoResource",desc:"Synology metadata"},{s:"#recycle",desc:"Synology trash"},{s:"#snapshot",desc:"Synology snapshot"},{s:"$Recycle.Bin",desc:"Windows trash"},{s:"$SysReset",desc:"Windows"},{s:"3rdParty",desc:"code"},{s:"Application Data",desc:"Windows apps"},{s:"Application Support",desc:"macOS apps"},{s:"Applications",desc:"macOS apps"},{s:"arangodb",desc:"3rd party"},{s:"cache",desc:"Cache directory"},{s:"CacheClip",desc:"Movie cache directory"},{s:"caches",desc:"Cache directory"},{s:"Chipset_Software",desc:"Windows apps"},{s:"cmake",desc:"code"},{s:"com.apple.TimeMachine.localsnapshots",desc:"macOS"},{s:"cpan",desc:"code"},{s:"DefinitelyTyped",desc:"TypeScript type"},{s:"Desktop DB",desc:"macOS metadata"},{s:"Desktop DF",desc:"macOS metadata"},{s:"Desktop.ini",desc:"macOS metadata"},{s:"DisplayDriver",desc:"Windows driver"},{s:"DLLs",desc:"Windows library"},{s:"dyld",desc:"macOS library"},{s:"ehthumbs.db",desc:"Windows thumbnail"},{s:"i18n",desc:"i18n code"},{s:"iMovie Cache",desc:"Apple iMovie cache"},{s:"iTunes Cache",desc:"Apple iTunes"},{s:"iTunes Media",desc:"Apple iTunes"},{s:"iTunes",desc:"Apple iTunes"},{s:"lib?(32|64|x64|s)",desc:"program library directory"},{s:"lost+found",desc:"fsck recovered directory"},{s:"macOS Install*",desc:"macOS installer"},{s:"Network Trash",desc:"AFP trash"},{s:"node_modules",desc:"Node.js library"},{s:"pkgconfig",desc:"code"},{s:"pkgs",desc:"Python code"},{s:"Program Files (x86)",desc:"Windows apps"},{s:"Program Files",desc:"Windows apps"},{s:"ProgramData",desc:"Windows application support"},{s:"resources/media/face",desc:"face thumbnail"},{s:"rubygems-*",desc:"Ruby code"},{s:"site-packages",desc:"Python code"},{s:"spotifycache",desc:"Spotify cache"},{s:"SteamApps",desc:"Game files"},{s:"System Volume Information",desc:"Windows system metadata"},{s:"System32",desc:"Windows system"},{s:"SystemTemp",desc:"Windows temporary"},{s:"temp",desc:"temporary"},{s:"Temporary Items",desc:"temporary"},{s:"test_suite",desc:"code"},{s:"testutil?(s)",desc:"code"},{s:"third_party",desc:"code"},{s:"Thumbnail?(s)",desc:"thumbnail"},{s:"Thumbs.db",desc:"Windows thumbnail"},{s:"tmp",desc:"temporary"},{s:"Trash",desc:"trash directory"},{s:"Windows",desc:"Windows"},{s:"Windows.old",desc:"Windows"},{s:"Windows10Upgrade",desc:"Windows upgrade"},{s:"Xcode.app",desc:"macOS code"},{s:"*.sparsebundle/bands",desc:"Time Machine backup"},{s:"ImageMagick*",desc:"ImageMagick source"},{s:"Install OS X*",desc:"macOS installer"},{s:"Install macOS*",desc:"macOS installer"},{s:"*.lrdata",desc:"LightRoom data"},{s:"MinGW*",desc:"code"},{s:"msys*",desc:"code"},{s:"vcpkg",desc:"code"}])e.push(new U("**/"+t.s+"/",t.desc));function t(t,i,r){if(!(0,h.blank)(t)){const s=(0,d.sort)((0,c.uniq)((0,c.compactBlanks)(i).map((e=>e.toLowerCase()))));1===s.length&&e.push(new U(`**/${t}/${s[0]}/`,r)),s.length>1&&e.push(new U(`**/${t}/(${s.join("|")})/`,r))}}(0,f.map)((0,P.configDir)(),(t=>e.pushNativePath(t,"PhotoStructure configuration"))),t("nix",["store"],"NixOS package"),e.push(new U("**/*.(photo|photos|ap)library/!(master|masters|modified|original|originals)/","Apple Photos/Aperture library")),e.push(new U("**/facetile*","face thumbnail"));const i=["bin","cygdrive","dev","etc","games","include","lib?(32|64|x64)","local","locale","man","proc","sbin","share","src","tmp","usr","var"];t("usr",i,"FHS system"),t("cygwin?(64)",i,"Cygwin"),t("local",i,"FHS system"),t("Windows",["assembly","Boot","Containers","Cursors","Fonts","Help","Installer","Logs","Microsoft.NET","Servicing","SoftwareDistribution","System32","SystemApps","SysWOW64","Temp","WinSxS"],"Windows"),t("Recovery",["Customizations","OEM"],"Windows"),t("lib",["firmware","modules","systemd","udev","x86_64-linux-gnu"],"Linux system package"),t("opt",["google","x11",...i],"FHS package"),t("lfs",["incomplete","objects"],"Git LFS object");const r=["cache","crash","games","lib","local","lock","log","logs","mail","run","snap","spool","tmp"];t("var",r,"Linux /var"),t("mnt",r,"Linux /mnt"),t("dev",["block","bsg","bus","char","cpu","disk","dri","fd","hugepages","input","lightnvm","mapper","mqueue","net","pts","shm","snd","ubuntu-vg","usb","vfio"],"Linux /dev backup"),t("proc",["acpi","asound","bus","driver","fs","ipmi","irq","net","scsi","self","sys","sysvipc","thread-self","tty"],"Linux /proc backup"),t("library",["Apple","Assistant","Bluetooth","com.apple.iTunesCloud","Containers","CoreAnalytics","Developer","Desktop Pictures","Documentation","Extensions","Finance","Fonts","Frameworks","FrontBoard","Group Containers","HTTPStorages","iTunes","KeyboardServices","Keychains","Logs","Messages","News","Passes","Photos","Preferences","Ruby","Saved Application State","Scripts","User Pictures","Updates","User Template","WebKit","WebServer"],"macOS Library"),t("packages",["*.pkg","*.mpkg"],"macOS package"),t("src/**",["bin","ci","dist","doc?(s)","etc","lib?(s)","main","spec?(s)","src","test?(s)","tools","util"],"code"),t("docs",["admin","content","general","generated","sql"],"code"),t("pkg",["acceptance","ccl","cli","cmd","server","sql","storage","ui","util","workload"],"code"),t("osv",["apps","arch","compiler","external","include","java","modules","musl","tests"],"code"),t("go",["bin","blog","cmd","doc","lib","misc","pkg","src","test","vt"],"code"),t("Perl?(64)",["bin","eg","etc","html","lib","site"],"code"),t("Python*",["dlls","doc?(s)","include","lib?(s)","scripts","tools","tcl"],"code"),t("Ruby*",["bin","include","lib","msys*","packages","share","ssl"],"code"),t("msys*",["clang*","dev","etc","mingw*","tmp","ucrt*","var"],"code"),t("sdk",["build-tools","emulator","extras","patcher","platforms","platform-tools","sources","tools"],"code"),t("test",["fixtures"],"code"),t("data",["$of"],"windows backup"),t("System",["Applications","Developer","DriverKit","Library","iOSSupport"],"macOS System"),t("contents",["frameworks","plugins","resources","sharedsupport"],"macOS application"),t("pg",["pgsql"],"code");for(const e of["local","locallow","roaming"])t("appdata",[e],"Windows default AppData");return t("ps",["cache","config","logs","tmp"],"PhotoStructure docker directory"),e.toA()})),J=()=>{t.excludeGlobs.unset(),t.excludeBundles.unset()},K=()=>{t.notExcludedDirs.unset()},Y=(0,u.lazy)((()=>{F.Settings.excludeGlobsOmitDefaults.watchLater(J),F.Settings.excludeGlobsAdd.watchLater(J),F.Settings.excludeGlobsOmit.watchLater(J),F.Settings.globsCaseInsensitive.watchLater(J),F.Settings.libraryDir.watchLater(K),F.Settings.originalsDir.watchLater(K),F.Settings.scanPaths.watchLater(K),F.Settings.argvScanPaths.watchLater(K)}));t.defaultDirPredicates=(0,u.lazy)((()=>[{notSymlinkLoop:re,notInHiddenPhotoStructureDir:ne,whyNoMedia:L.whyNoMedia,notHidden:se}])),t.defaultFilePredicates=(0,u.lazy)((()=>[{notInHiddenPhotoStructureDir:ne}])),t.excludeGlobs=(0,u.lazy)((()=>{Y();const e=new y.CaseInsensitiveMap;function t(t){if(null!=t&&t.valid){const i=t.pattern.trim();e.has(i)&&j().warn("Duplicate glob:",{glob:t}),e.set(i,t)}}function i(t){const i=t.trim();e.has(i)?e.delete(i):j().warn("Failed to find and remove glob specified in PS_EXCLUDE_GLOBS_OMIT",{glob:t})}if(!F.Settings.excludeGlobsOmitDefaults.valueOrDefault)for(const e of G())t(e);for(const e of F.Settings.excludeGlobsOmit.values)i(e);for(const e of F.Settings.excludeGlobsAdd.values)t(new U(e,"(from PS_EXCLUDED_GLOBS_ADD)"));const r=(0,d.sortBy)(e.values(),(e=>(0,c.compactBlanks)(e.pattern.toLowerCase().split("/")))),[s,n]=(0,g.partition)(r,(e=>e.pattern.endsWith("/")));return{dir:s,file:n}})),t.excludeBundles=(0,u.lazy)((()=>{const e=(0,t.excludeGlobs)();return{dir:[...(0,t.defaultDirPredicates)(),...e.dir.map((e=>e.bundle))],file:[...(0,t.defaultFilePredicates)(),...e.file.map((e=>e.bundle))]}}));const Z=[{disableAllFilters:()=>!0}],X=[{notBlank:()=>!1}];function Q(e){return F.Settings.disableAllFilters.valueOrDefault?Z:(0,h.blank)(e)?X:(0,t.excludeBundles)().file}function ee(e){return C.SyncPredicates.whyRejected(e,...Q(e))}function te(e){return F.Settings.disableAllFilters.valueOrDefault?Z:(0,h.blank)(e)?X:(0,t.excludeBundles)().dir}async function ie(e){return F.Settings.disableAllFilters.valueOrDefault?void 0:k.Predicates.whyRejected(e,...te(e))}function re(e){return!(0,N.seemsLikeSymlinkLoop)(e)}function se(e){return(0,S.thenNot)((0,O.isHidden)(e))}function ne(e){return!(0,T.inHiddenPhotoStructureDir)(e)}t.notExcludedFilePredicates=Q,t.whyExcludedFile=ee,t.isExcludedFile=function(e){return null!=ee(e)},t.notExcludedDirPredicates=te,t.whyExcludedDirectory=ie,t.isExcludedDirectory=async function(e){return null!=await ie(e)},t.notExcludedDirs=(0,u.lazy)((async()=>{const e=(0,c.uniq)((0,c.compactBlanks)([(0,M.libraryDirPosixFile)(),(0,M.libraryOriginalsDirPosixFile)(),...F.Settings.argvScanPaths.values,...F.Settings.scanPaths.values]));return j().tap({msg:"notExcludedDirs() (these directories will never be excluded)",level:"info",result:(0,c.uniq)([...e,...await Promise.all(e.map((e=>(0,A.actualPath)(e))))])})})),t.whyExcludedDirectoryRecursive=async function(e){const i=await(0,t.notExcludedDirs)();for(let t=e;null!=t&&!t.isRoot;t=await(t?.parent())){if(i.includes(t?.nativePath))return;const e=await ie(t);if(null!=e)return e}},t.notInHiddenPhotoStructureDir=ne},88561:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const a=i(40958),o=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class w extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>n(this,r,"m",s).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,a.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=w,r=new WeakSet,s=async function(e){if((0,o.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),s=i(22573),n=i(45599),a=i(96249),o=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,n.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,s.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,a.flatten)((0,o.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),s=i(17217),n=i(16287),a=i(68284);async function o(e){return(0,r.pick)(await(0,n.stat_)((0,s.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=o,t.fileStats=async function(e){try{return await o(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,a.statSync)((0,s.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const r=i(68817),s=i(19851),n=i(22573),a=i(50213),o=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),h=i(95696),f=i(93854),m=i(16287),p=(0,s.lazy)((()=>(0,a.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,f.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,r.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const s=(0,n.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),a=(0,l.normalizeExt)(h.PosixFile.for(e))??(0,c.mimetypeExt)(s);return(0,n.blank)(s)||(0,n.blank)(a)?void 0:{ext:a,mime:s}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new o.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,s.set(this,[]),n.set(this,void 0),a.set(this,void 0),l(this,a,(0,f.fileStatsSync)(e),"f"),l(this,n,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",o).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,s,"f").push(e)}close(){u(this,n,"f").close()}}t.FileWatcher=m,s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,a,"f"),t)){l(this,a,t,"f");for(const t of u(this,s,"f"))t(e,this.nativePath)}}},73209:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,w,v,b=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},S=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const _=i(58587),T=P(i(44652)),M=i(87997),E=i(40958),D=i(17586),x=i(42659),k=i(50357),C=i(75240),F=i(55835),A=i(31586),I=i(30976),O=i(13538),L=i(54993),R=i(7282),N=i(68852),B=i(23560),j=i(25764),z=i(38836),V=i(99331),W=i(22781),U=i(38835),q=i(55222),H=i(63870),$=i(69734),G=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)($.PsLockExt)+"$");class K extends z.EndableWrapper{static newUid(e=process.pid){return S(this,s,Math.max(Date.now(),b(this,s,"f",n)+1),"f",n),(0,E.compactBlanks)([q.TokenRadix.encode(b(this,s,"f",n)),B.serviceName.prior(),(0,L.toS)(e)]).join("-")}static pidFromLockfile(e){return s.pidFromBasename((0,G.basename)(e))}static pidFromBasename(e){return(0,A.toInt)(J.exec((0,L.toS)(e))?.groups?.pid)}static for(e){return b(this,s,"f",o).find((t=>t.opts.file===e.file))??new s(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>b(this,r,"m",v).call(this)),e.endableRank??j.EndableRanks.postdb,(0,H.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,S(t=s,s,(i=b(t,s,"f",a),++i),"f",a)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(b(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,$.fsLockFileBasename)(s.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await b(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,$.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+b(this,l,"f")),this.staleMs=(0,A.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),b(s,s,"f",o).push(this)}get acquired(){return b(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await b(this,r,"m",f).call(this,e)??b(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,D.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,k.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==b(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:x.secondMs);S(this,c,setInterval((()=>b(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=b(this,c,"f")&&(clearInterval(b(this,c,"f")),S(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(b(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),S(this,u,!1,"f"),(0,F.map)(b(this,d,"f"),(e=>(0,M.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?b(this,r,"m",w).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),S(this,d,setTimeout((()=>b(this,r,"m",w).call(this)),(0,A.toGt0)(this.staleMs)??x.secondMs),"f"),b(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(b(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,O.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,s=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,r=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,A.gt0)(this.staleMs)&&Date.now()>b(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await b(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){S(this,h,Date.now(),"f");const e=[],t=await b(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,A.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+x.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,$.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;s.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const n=i[0]===this.lockfile.base;if(n)S(this,u,!0,"f");else if(!0!==t?.vacuum){const t=s.pidFromBasename(i[0]);if((0,A.gt0)(t)&&!(0,_.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),b(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:n,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await b(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},w=async function(){await b(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},v=function(){(0,E.filterInPlace)(b(s,s,"f",o),(e=>b(e,l,"f")!==b(this,l,"f")))},n={value:0},K.internalErrors=0,a={value:0},o={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),s=i(51926),n=i(54993),a=i(17217);function o(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,s.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,s.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,n.toS)(e)))return;const i=(0,a.basename)(e);return o(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&o((0,a.basename)(e))}},4001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),s=i(55835),n=i(31586),a=i(51926),o=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,r.toNotBlank)(e.name)??(0,o.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,n.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:f(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const s=(0,u.parsePosixPath)(i),n=h(s,{aggressive:!1});return[...t,n+s.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,a.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),r=(0,a.stripPrefix)(t.toLowerCase().normalize(),i);return(0,s.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,a.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,s.map)(m.exec(t),(e=>t=e[1].trim())),(0,s.map)(g.exec(t),(e=>t=e[1].trim())),t}},19254:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fileGrep_=t.GrepReader=void 0;const s=r(i(73024)),n=i(57075),a=i(46466),o=i(54993),l=i(33456),u=i(17217),c=i(58722);class d extends n.Transform{constructor(e,t="\n"){super({objectMode:!1,autoDestroy:!0}),this.pattern=e,this.sep=t}_transform(e,t,i){const r=(0,o.toS)(e).match(this.pattern);null!=r&&this.push(r[1]??r[0]+this.sep),i()}}t.GrepReader=d,t.fileGrep_=async function(e,t){const i=new c.WritableToBuffer;return await(0,a.pipeline)([s.default.createReadStream((0,u.toNativePath_)(e)),new l.LineReader,new d(t),i]),(await i.buffer).toString()}},14977:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const s=r(i(44652)),n=r(i(73024)),a=i(46466),o=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,a.pipeline)(n.default.createReadStream(e,{autoClose:!0}),o.default.createGzip(),n.default.createWriteStream(t,{autoClose:!0})),await s.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const s=r(i(77598)),n=r(i(73024)),a=i(46466),o=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),w=i(16287),v=(0,o.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),b=(0,o.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function S(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=b().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return v().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;v().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),b().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await _(n.default.createReadStream(i)),stats:(0,u.pick)(await(0,w.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],i="sha512"){const r=s.default.createHash(i);return await(0,a.pipeline)([e,...t,r]),r.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:b,impl:P}),t.fileShaMeta_=S,t.fileSha_=async function(e){return(await S(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return s.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),s=i(42659),n=i(55835),a=i(31586),o=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,o.stdout_)("chflags",["hidden",t],{timeoutMs:10*s.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,n.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,o.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*s.secondMs}),i=(0,a.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),s=i(54993),n=i(7282),a=i(43334),o=i(69375),l=/^\/dev(?:\/|$)/i,u=a.isMac||(0,n.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=a.isMac||(0,n.isTest)()?/^\/private\//i:void 0,d=a.isMac||(0,n.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=a.isMac||(0,n.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,s.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,o.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},87128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonFileStore=void 0;const r=i(19851),s=i(55835),n=i(57159),a=i(50213);t.JsonFileStore=class{constructor(e,t,i){this.file=e,this.mkObject=t,this.onWrite=i,this.prior=(0,r.lazy)((()=>this.file.readJson("debug")))}async read_(){return await this.prior()??(0,s.map)(await this.mkObject(),(e=>this.write_(e)))}async write_(e){try{return await this.file.writeJson_(e,{spaces:2}),this.prior.set(Promise.resolve(e)),(0,a.mkLogger)("fs.JsonFileStore").info("wrote to "+this.file,e),null!=this.onWrite&&await this.onWrite(this.file,e),e}catch(e){throw new n.WrappedError("Failed to write to "+this.file,{cause:e,path:this.file.nativePath})}}}},33456:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),s=i(51926),n=i(54993);class a extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,n.toS)(e)).split((0,s.newlineRe)()),a=r.pop();this._prior=a??"";let o=!1;for(const e of r)o||(o=!this.push(e));o?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=a},64680:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const s=r(i(76760)),n=i(17217),a=i(73428);t.mkNoMedia_=function(e){return(0,a.writeTextfile_)(s.default.join((0,n.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},61704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nativePathsEql=t.nativePathsEqlSync=void 0;const r=i(21144),s=i(17217);t.nativePathsEqlSync=function(e,t){if(null==e||null==t)return!1;if(e===t)return!0;try{const i=(0,s.toNativePath_)(e),r=(0,s.toNativePath_)(t);return null!=i&&null!=r&&i===r}catch{return!1}},t.nativePathsEql=async function(e,t){try{return null!=e&&null!=t&&await(0,r.actualPath_)((0,s.toNativePath_)(e))===await(0,r.actualPath_)((0,s.toNativePath_)(t))}catch{return!1}}},85772:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const a=n(i(76760)),o=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),w=i(83278),v=i(70698),b=i(88561),S=i(65238),P=i(16287),_=(0,o.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),T="NoMedia",M=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(a.default.sep),"/"]).join("")+"])\\.?"+T+"$","im"),E=Object.freeze(["."+T,T]),D=Object.freeze((0,u.flatten)(E.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function x(e){return null!=M.exec(e)}t.isNoMediaName=x;const k=(0,o.lazy)((()=>new b.FileCache({name:"fs.noMediaDirsCache"})));async function C(e,t){if(null==e)return null;const i=w.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return x(i.base)||await(0,v.isCachedirTagFile)(i)?k().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):C(i.parent());{const e=await k().getOrSetAsync(i.nativePath,(()=>F(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:C(i.parent())}}async function F(e){if(x(e.base))return k().set(e.parent().nativePath,e.nativePath),_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,S.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,r=await Promise.race([A(e.nativePath,i),(0,S.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,v.isCachedirTagDirectory)(e)?_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(v.CACHEDIR_TAG).nativePath)}):null}async function A(e,t){for(const i of g.isCaseSensitiveFs?D:E){if(!0===t?.aborted)return null;const r=a.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return _().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function I(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(x(r.basename))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,a.join)(e,r.basename))});if(r.basename===v.CACHEDIR_TAG){const t=(0,a.join)(e,r.basename);if(await(0,v.isCachedirTagFile)(t))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await C(e,t)},t.whyNoMedia=C,t.whyNoMediaDir=F,t._dirHasNoMediaChild=A},29882:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),w=i(78133),v=i(53265),b=i(17217),S=i(16287),P=i(66430),_=i(5545);function T(e){return((0,b.isSimpleFile)(e)?e.base:n.default.basename(n.default.resolve(e))).startsWith(".")}t.logger=(0,a.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=T,t.containsHiddenPathname=function(e){return C(e).some(T)},t.isNotHiddenPosixPath=function(e){return C(e).every((e=>!T(e)))},t.resolveSimpleFile=function(e){return(0,b.isSimpleFile)(e)?e.nativePath:(0,v.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,v.resolve)(...e)},t.parsePosixPath=function(e){return E((0,w.posix2native)(e))},t.extname=function(e){return E(e).ext},t.dirname=function(e){return n.default.dirname((0,b.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(n.default.parse(e).ext,n.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function E(e){const t=M.exec(e)?.groups,i=t?.ext2??"",r=n.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function D(e){const t=n.default.parse((0,b.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,n.default.sep)}function x(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,b.toNativePath_)(e.ancestor),i=(0,b.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,n.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function k(e,t,i){if(null==t||null==i)return!1;const r=e(t),s=e(i);return null!=r&&null!=s&&(y.isLinux?r===s:(0,p.equalsIgnoreCase)(r,s))}function C(e){return(0,b.isSimpleFile)(e)?e.pathnames:e.split(n.default.sep).filter((e=>null!=e&&""!==e))}function F(e){return(0,u.notBlank)(e)&&C(e).length===(y.isWin?1:0)}function A({p:e,maxLength:t}){const i=(0,b.toNativePath_)(e);if(i.length<=t)return i;const r=C(e),s=[],n=[r.pop()];for(;r.length>0;)if(s.length=t){r.unshift(s.pop());break}}else if(n.unshift(r.pop()),O([...s,...n]).length>=t){r.push(n.shift());break}return r.length>0&&s.push("…"),O([...s,...n])}function I(e){return e.startsWith("\\\\")}function O(e){return(0,h.ensurePrefix)((0,o.compactBlanks)(e).join(n.default.sep),y.isWin?"":n.default.sep)}t.parseNativePath=E,t.parentBasename=D,t.grandParentBasename=function(e){return D(n.default.parse((0,b.toNativePath_)(e)).dir)},t.containedByNativePath=x,t.eqlBasename=function(e,t){return k(b.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return k(b.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return k(b.toNativePath_,e,t)},t.toPathnames=C,t.pathIsRoot=F,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:C(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,b.toNativePath_)(e),r=(0,b.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,w.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,w.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=A,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const s=[];for(const r of e.slice(0,i))s.push(A({p:r,maxLength:t}));return s.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return C(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return C(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=E(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,S.isReadableDirectory)(e))return;if(F(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await s.default.mkdirp(e)}catch(t){if(await(0,S.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;s.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>s.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,b.toNativePath_)(e).split(n.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=O,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:O(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>x({ancestor:t,descendant:e,acceptSelf:!0})?[(0,b.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),w=i(64660),v=i(21144),b=i(16287),S=(0,n.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const i=await(0,b.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,w.isStatRX)(i,e)}function T(){if(y.isWin){const e=(0,o.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,o.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,o.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,s.default.join(e,"System32"),s.default.join(e,"System32","Wbem"),s.default.join(i,"chocolatey","bin"),s.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(s.default.delimiter);return(0,a.uniq)((0,a.compactBlanks)([...e,...T()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,a.uniq)((0,a.compactBlanks)([...M(),...(0,d.toA)(i)]));for(const i of(0,a.uniq)((0,a.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=s.default.join(t,e);if(await _(i))return y.isLinux?i:(0,v.actualPath)(i)}}S().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,w.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){"use strict";var r,s,n,a=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return o(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),w=i(76790),v=i(5233),b=i(22573),S=i(42659),P=i(26905),_=i(75240),T=i(55835),M=i(31586),E=i(68708),D=i(13538),x=i(89937),k=i(12168),C=i(54993),F=i(48884),A=i(50213),I=i(45255),O=i(81168),L=i(56519),R=i(56038),N=i(31562),B=i(84777),j=i(9595),z=i(38835),V=i(70025),W=i(57902),U=i(55222),q=i(43334),H=i(33847),$=i(24399),G=i(28874),J=i(79915),K=i(45200),Y=i(34238),Z=i(87001),X=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),se=i(73209),ne=i(48313),ae=i(29882),oe=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,F.contextFilter)(function(e){return(0,w.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,A.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Y.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,L.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,L.thenMapOr)((0,X.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>q.isMac?(0,B.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,b.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,b.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,O.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,oe.toNativePath_)(e),r=new fe(i,t);return(0,O.isString)(e)&&he().set(e,r),he().set(i,r),r}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,L.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,ae.containedByNativePath)({ancestor:(0,j.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,ae.containedByNativePath)({ancestor:(0,j.originalsDir)(),descendant:this,acceptSelf:!0}))return q.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,T.map)((0,ee.bestMountpoint)(this.nativePath,await(0,X.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,T.map)((0,b.notBlankOr)(e,(()=>this.uri_())),Y.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,C.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===x.PS_LIBRARY_SCHEME?1:t.scheme===x.PS_LOCAL_FILE_SCHEME?2:t.scheme===x.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,O.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(q.isWin||q.isMac)return this.trap("hide",(async()=>(await(0,ne.hide_)(this),this)))}async hidden(){return(0,ne.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,O.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,F.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,T.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,E.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:s,skipWip:n=!1,skipFsLock:a=!1,retries:o=2,dirty:l=!1}){return(0,v.retryOnReject_)((async()=>{const o=await this.clear().isNonEmptyFile(i);if(!o){if(n&&a)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:a,minSizeBytes:i,timeoutMs:s,dirty:l})}return o&&r?void 0:this.utimes()}),{maxRetries:o,timeoutMs:2*s,retryDelay:3*S.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,M.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:s,dirty:n=!1}){return await this.parent().mkdirp_(),(0,se.withLock_)({file:this,skipFsLock:r,timeoutMs:s,dirty:n},(async()=>{const r=this.wip();try{await r.unlink("trace");const n=await(0,D.thenOrTimeoutError)(e(r),s);if(n===t.NoOp)return n;if(await(0,N.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),n;throw new Error(this+"applyWip(): still empty after waiting "+(0,_.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==G.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",s).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",n).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();G.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:S.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,M.clamp)(I.ShortCommandTimeoutMs,10*S.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,b.notBlank)(this.ext)&&(0,b.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,S.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,T.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,L.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,O.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,ae.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,ae.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,Z.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,r=new WeakSet,s=async function(e){let t,i=e;const r=e.wip();try{const s=await this.stat_();if(null==s)return this.pflog().throw("Can't copy missing files"+z.NonRetriableErrorFlag);if(s.size>0){if(G.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+z.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,r.nativePath,h.default.constants.COPYFILE_FICLONE),s.size>5*k.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},s.size,(()=>r.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,M.approximates)(s.size,await r.size({refresh:!0}))),{intervalMs:S.secondMs,timeoutMs:S.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:s.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:s.birthtimeMs,mtimeMs:s.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,s.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${s.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,T.map)(t,(e=>e.end()))}},n=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),s=r?.size;return null==r||null==s?this.pflog().throw("Can't copy missing files"):(s>5*k.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},s,(()=>e.clear().size()))),q.isWin?await $.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,$.pwshQuote)(this.nativePath)} -Destination ${(0,$.pwshQuote)(i.nativePath)}`,(e=>e)):q.isMac?await(0,B.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,B.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+z.DoNotSendErrorFlag,{error:t})}finally{(0,T.map)(t,(e=>e.end()))}}},62105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.acceptFile=t.whyRejectFile=t.expensiveFileFiltersFor=t.acceptParentAndFileAndSimple=t.acceptFileSimple=t.whyRejectFileSimple=t.simpleFileFiltersFor=t.notFileTooBig=t.notFileTooSmall=t.notFileMissing=t.hasBrowserImgMimeType=t.notDimensionsTooSmall=t.requiredTagsFilter=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(54993),o=i(48884),l=i(56519),u=i(78984),c=i(28874),d=i(43207),h=i(47783),f=i(97573),m=i(16170),p=i(54979),g=i(1078),y=i(42231),w=i(83278),v=i(19748),b=i(92423),S=i(16287);function P(e){return async t=>(0,l.thenMapOr)((0,h.readRawTags)(t,!1),e,(()=>!1))}async function _(e){if(!(0,n.gt0)(c.Settings.minVideoDimension.valueOrDefault)&&!(0,n.gt0)(c.Settings.minImageDimension.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);if(null==t||!t.startsWith("image/")&&!t.startsWith("video/"))return!1;const i=t.startsWith("video/")?c.Settings.minVideoDimension.valueOrDefault:c.Settings.minImageDimension.valueOrDefault;return(0,n.gt0)(i)?(0,l.thenMapOr)((0,g.extractSizeInfoFromFile)(e),(e=>(0,n.gte)(e.ImageWidth,i)&&(0,n.gte)(e.ImageHeight,i)),(()=>!1)):null}async function T(e){if(!(0,n.gt0)(c.Settings.minVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.gte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.minVideoDurationSec.valueOrDefault):null)}async function M(e){if(!(0,n.gt0)(c.Settings.maxVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.lte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.maxVideoDurationSec.valueOrDefault):null)}async function E(e){return!(0,s.blank)(await(0,p.readMimeType)(e))}async function D(e){if(-100===c.Settings.rejectRatingsLessThan.valueOrDefault)return null;const t=await(0,h.readTags)(e),i=(0,n.toInt)(t?.Rating);return null==i||i>=c.Settings.rejectRatingsLessThan.valueOrDefault}async function x(e){return 0===c.Settings.keywordBlocklist.values.length?null:(0,f.rawTagKeywords)(await(0,h.readTags)(e)).every((e=>!0!==(0,y.leafIsExcluded)(e,c.Settings.keywordBlocklist.values)))}async function k(e){if(!c.Settings.requireMakeModel.valueOrDefault)return null;const t=await(0,h.readRawTags)(e);return null==t||(0,s.blank)(t.MIMEType)?null:t.MIMEType.startsWith("image/")?null!=t&&(0,s.notBlank)(t.Make)&&(0,s.notBlank)(t.Model):null}async function C(e){return(0,w.isBaseFile)(e)?e.exists():(0,S.exists)(e.nativePath)}async function F(e){const t=c.Settings.minAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.gte)(i,t)}async function A(e){const t=c.Settings.maxAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.lte)(i,t)}function I(e){return[{isSupportedFileExtension:v.isAssetFileExtension},...(0,b.notExcludedFilePredicates)(e),{notFileMissing:C},{notFileTooSmall:F,notFileTooBig:A}]}function O(e){return[...I(e),{notMissingMimeType:E},{supportedMimeType:m.isAssetFileMimeType},{notMissingMakeAndModelTags:k},{notDimensionsTooSmall:_},{notVideoTooShort:T},{notVideoTooLong:M},{notRejectedRating:D},{notExcludedKeyword:x}]}async function L(e,t){return await u.Predicates.whyRejected(e,...t??O(e))??await(0,b.whyExcludedDirectoryRecursive)(e.parent())}t.requiredTagsFilter=function(e){return P((t=>(0,o.allNotBlank)(...e.map((e=>t[e])))))},t.notDimensionsTooSmall=_,t.hasBrowserImgMimeType=P((e=>(0,r.includes)(["image/jpeg","image/png"],(0,a.toS)(e.MIMEType)))),t.notFileMissing=C,t.notFileTooSmall=F,t.notFileTooBig=A,t.simpleFileFiltersFor=I,t.whyRejectFileSimple=function(e){return u.Predicates.whyRejected(e,...I(e))},t.acceptFileSimple=function(e){return u.Predicates.accepted(e,...I(e))},t.acceptParentAndFileAndSimple=async function(e){const t=await e.parent();return null!=t&&!await(0,b.isExcludedDirectory)(t)&&await u.Predicates.accepted(e,...I(e))},t.expensiveFileFiltersFor=O,t.whyRejectFile=L,t.acceptFile=async function(e){return null==await L(e)}},78133:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const s=r(i(76760)),n=i(22573),a=i(81168);t.posix2native=function(e,t){if((0,n.blank)(e))return e;if(s.default.sep===s.default.posix.sep)return e;const i=(0,n.notBlank)(t)?s.default.sep+s.default.sep+t+s.default.sep:"",r=e.split(s.default.posix.sep);return(0,a.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(s.default.sep)},t.native2posix=function(e){return(0,n.blank)(e)||s.default.sep===s.default.posix.sep||s.default.posix.sep===s.default.sep?e:e.split(s.default.sep).join(s.default.posix.sep)}},43899:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,a.lazy)((()=>s.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,a.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(s.default.join((0,p.execDir)(),"resources"),s.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,o.compactBlanks)([(0,p.execDir)(),n.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const r=s.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),s=i(19851),n=i(31586),a=i(50213),o=i(57902),l=i(69428),u=(0,s.lazy)((()=>(0,a.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=o.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,n.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),s=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let n=-1;try{const s=i??(await(0,r.stat)(e)).size-t,a=Buffer.alloc(s);return n=await(0,r.open)(e,"r"),await(0,r.read)(n,a,0,s,t)}finally{(0,s.mapGte0)(n,r.close)}}},69428:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const a=n(i(73024));t.readFileSync=function(e){try{return a.readFileSync(e)}catch{}}},55690:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),s=i(84542);t.readLines_=async function(e){return(0,s.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class s extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=s},65238:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const s=r(i(51455)),n=i(76760),a=i(19851),o=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),w=i(28874),v=i(63870),b=i(88561),S=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,a.lazy)((()=>(0,n.join)(w.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,a.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await s.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const T=(0,a.lazy)((()=>new b.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,v.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||T.prior()?.delete(e)}async function E(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await T().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,S.statTimeoutMs)(),r=D(e),s=await(0,h.thenOrTimeout)(r,(0,d.toGt0)(w.Settings.fsCacheSlowMs.valueOrDefault)??(0,S.statTimeoutMs)());if(s===f.Timeout&&(0,g.onTimeout)({soft:!1}),s!==f.Timeout&&s.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{w.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),T.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,a.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!T().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=T().get(e)},t.childDirectories_=async function(e){return(await E(e)).filter((e=>e.isDirectory)).map((t=>(0,n.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(w.Settings.readdirCacheMs.valueOrDefault)?E(e):D(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=E,t.readdirCached=function(e){return T().get(e)},t.readdirUncached_=D},53265:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const s=i(73024),n=r(i(76760)),a=i(40958),o=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,a.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=n.default.resolve(t,...e);if((0,s.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,o.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(o.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??n.default.resolve(...e))},t.execDir=(0,l.defer)((()=>n.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},46356:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.seemsLikeSymlinkLoop=void 0;const r=i(22454),s=i(28874),n=i(29882);t.seemsLikeSymlinkLoop=function(e){const t=new r.CountingSet;for(const i of(0,n.toPathnames)(e))t.incr(i.toLowerCase().normalize());return t.max()>s.Settings.maxDuplicatePathElements.valueOrDefault}},50274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),s=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,s.isBoolean)(e.isFile)&&(0,s.isBoolean)(e.isDirectory)}},17217:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const s=r(i(73024)),n=r(i(76760)),a=i(22573),o=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,a.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,a.blank)(e.nativePath))throw new Error(`toNativePath(${(0,o.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof s.default.Dirent?e.name:f(e)?e.base:n.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:n.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(n.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function w(e){return(0,o.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(s.default.stat(e),(0,g.statTimeoutMs)(),!0)}function v(e,t=f.LogLevels.debug){return(0,o.blank)(e)?void 0:w(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function b(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function S(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=b(e),r=b(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],s=t[i],n=(0,u.diff)(S(r),S(s));if(null==n||n>1)return"unmatched "+i+": "+r+" ≠ "+s}}t.stat_=w,t.statMaybe=v,t.statToType=b,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await v(e,t)},t.isEmptyFile=async function(e,t){const i=await v(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await v(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await v(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await v(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await v(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await v(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await v(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,a.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const s=r(i(73024)),n=i(22573);function a(e){try{return(0,n.blank)(e)?void 0:s.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function o(e){return null==e||e.isFile()&&0===e.size}t.statSync=a,t.isEmptyStats=o,t.isFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=a(e);return t.emptyIsNew?null==i:o(i)},t.isNonEmptyFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===a(e)?.isDirectory()}},41080:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),s=i(56409);t.onDataChunked=function(e,t,i){const r=new n(t,i,!0);return r.read(e),r.done};class n{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new s.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=n},95705:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const s=r(i(57075)),n=i(41400),a=i(55835),o=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends s.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,n.delay)(50);try{(0,o.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,a.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends s.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const s=r(i(73024)),n=i(76760),a=i(22573),o=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,a.blank)(e))return!1;try{return s.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,o.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,a.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,a.notBlank)(t)){const e=(0,n.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,a.blank)(e)&&d((0,u.posix2native)(e))}},74128:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncReport=t.syncReport=t.recentSyncReports=t.ensureSyncReportReadme=t.syncReportReadme=t.syncReportDir=t.SyncReportHeaders=t.isRejectedState=t.SyncReportStates=t.SyncDirStates=t.FileDoneStates=t.SyncFileStates=t.AssetFileSyncStates=void 0;const p=i(51168),g=i(73024),y=i(4927),w=i(19851),v=i(40958),b=i(22573),S=i(42659),P=i(98553),_=i(31586),T=i(68708),M=i(50989),E=i(51926),D=i(85556),x=i(54993),k=i(89788),C=i(23467),F=i(7282),A=i(23560),I=i(77377),O=i(71567),L=i(73568),R=i(25764),N=i(38836),B=i(99331),j=i(12959),z=i(87290),V=i(46296),W=i(98314),U=i(38835),q=i(5012),H=i(32144),$=i(95696),G=i(36868),J=i(57902),K=i(28874),Y=i(84542),Z=i(73428);t.AssetFileSyncStates=(0,M.strEnum)("noop","deleted","skipped","synced","unknown"),t.SyncFileStates=(0,M.strEnum)(...t.AssetFileSyncStates.values,"canceled","rejected","failed","timeout","enqueued","started","copied","blocklisted","note"),t.FileDoneStates=(0,I.diff)(t.SyncFileStates.values,["enqueued","started","note"]),t.SyncDirStates=(0,M.strEnum)("scanning","canceled","failed","timeout","skipped","scanned"),t.SyncReportStates=(0,M.strEnum)(...t.SyncFileStates.values,...t.SyncDirStates.values),t.isRejectedState=function(e){return null==e||["canceled","deleted","failed","rejected","timeout","unknown"].includes(e)};const X={enqueued:"the file looks promising, and will be attempted to be imported soon.",rejected:"the file did not pass all import filters. The details column will explain why.",started:"the file was dequeued from the work queue, and is now going to be processed.",noop:"the current file metadata already matches your library database, so no operation was needed to sync this file.",deleted:"the file was determined to be deleted (the prior mountpoint exists, but the file doesn't exist anymore)",skipped:"the file lives on a volume that isn't currently mounted.",synced:"the file was imported.",blocklisted:"the file was blocklisted and files with the same SHA will not be imported in the future.",failed:"something went wrong. The details column will explain why.",timeout:"the file wasn't processed in a reasonable amount of time.",copied:'"automatic organization" is enabled (copyAssetsToLibrary=true), and the photo or video was copied into your library originals directory. The details column will contain the source file path.',note:"sidecars will be referenced here. The details column will specify which source file(s) it will be associated with.",canceled:"PhotoStructure was shut down while the file was processed.",unknown:"an internal error occurred during processing."},Q={scanning:"the directory contents are about to be read.",scanned:"the directory contents were completely processed.",skipped:"the directory was excluded. The details column will explain why.",canceled:"PhotoStructure was shut down before the directory was processed.",failed:"reading the directory contents failed.",timeout:"reading the directory contents took too long."};function ee(e){return(0,T.entries)(e).map((([e,t])=>` - "${e}": ${t}`)).join("\n")}const te=new Set([t.AssetFileSyncStates.deleted,t.SyncFileStates.failed,t.SyncFileStates.timeout,t.SyncDirStates.canceled]);function ie(){return(0,z.librarySyncReportsDir)()??$.PosixFile.for((0,V.logDir)()).join("sync-reports")}function re(){return ie().join("README.txt")}t.SyncReportHeaders=(0,M.strEnum)(...(0,T.keys)(new class{constructor(e,t,i,r,s,n,a,o,l={}){this.ts=e,this.at=t,this.path=i,this.state=r,this.from=s,this.elapsedMs=n,this.details=a,this.url=o,this.meta=l}}(0,"","","unknown","",0,"",""))),t.syncReportDir=ie,t.syncReportReadme=re,t.ensureSyncReportReadme=(0,w.lazy)((()=>(0,Z.writeTextfile_)(re().nativePath,(0,E.wrap)(`\n\nHowdy from PhotoStructure!\n\nThis directory contains your recent "sync reports". \n\nThese files are written as your scan paths are examined for photos and videos.\n\nPhotoStructure creates a new file when it restarts and when it completes importing a given scan path directory.\n\nThese CSV files can be opened with most spreadsheet applications, like LibreOffice.\n\n\nColumn descriptions\n===================\n\nThe "ts" column is the timestamp for the row, in millis from 1970-01-01. Most spreadsheet applications don’t know how to parse these values, though, so we also add the at column.\n\nThe "at" column is ts in ISO format with only second resolution, and should be parsable by most spreadsheet software.\n\nThe "path" column is the native path of the directory or file. It will be empty for messages about system state.\n\nThe "state" column explains why that row was added.\n\nThe "from" column specifies which codepath added the sync report row.\n\nThe "elapsedMs" column is only added to rows completing a given path, and records how long that process took.\n\nThe "details" column will include information about the path, like why a given file or folder were rejected.\n\nThe "url" column is only added to rows when a file or directory is imported. You may need to adjust the domain name of the URL to make it work correctly (it defaults to localhost).\n\n\nDirectory state values\n======================\n\nThe "state" column for directories will be\n\n${ee(Q)}\n\n\nFile state values\n=================\n\nThe "state" column for files will be\n\n${ee(X)}\n\n\nSee https://photostructure.com/go/sync-reports\n\n`,{maxLineLen:80}).join("\n")))),t.recentSyncReports=async function(e=S.dayMs){const t=Date.now()-e;return ie().descendants((async e=>(0,H.isCsvExt)(e)&&(0,_.gte)(e.mtimeMs(),t)))},t.syncReport=(0,w.lazy)((()=>new se));class se extends N.EndableWrapper{constructor(){super("fs.SyncReport()",(()=>f(this,r,"m",d).call(this)),R.EndableRanks.predb),r.add(this),s.set(this,void 0),n.set(this,void 0),a.set(this,void 0),o.set(this,0),l.set(this,0),this.outputFiles=new k.BoundedList(64),(0,t.ensureSyncReportReadme)()}get outputNativePath(){return f(this,s,"f")?.nativePath}get rowCount(){return f(this,l,"f")}onProgress(e){if(null==e||(0,b.blank)(e.state))return this.logger.error(".onProgress(): invalid input",{s:e,from:(0,q.stack)()});{this.logger.log(te.has(e.state)?J.LogLevels.warn:J.LogLevels.info,"onProgress()",e);const t=Date.now(),i={path:(0,x.toS)(e.path),state:e.state,details:(0,x.toS)(e.details).trim().replace(/\r?\n/g,"; ")},s={ts:t,at:new Date(t).toISOString(),...i,...(0,T.pick)(e,"from","elapsedMs","url")};(0,T.isEmptyObj)(e.meta)||(s.meta=(0,P.stringify)(e.meta)),(0,F.isTest)()&&process.stdout.write((0,P.stringify)(e)+Y.Newline),f(this,r,"m",u).call(this,s)}}maybeSystemData(e){(0,A.isSyncService)()&&this.onProgress(e)}async wrap_({path:e,from:i,fn_:r}){const s=Date.now();this.onProgress({path:e,from:i,state:t.SyncFileStates.started});try{const n=await r(),a=n.state??(null!=n.error?t.SyncFileStates.failed:t.SyncFileStates.unknown);return a===t.SyncFileStates.unknown&&this.logger.error(i+" returned result with no state!"+U.InternalErrorFlag,{path:e,result:n}),this.onProgress({path:e,from:i,elapsedMs:Date.now()-s,...n,state:a}),n}catch(r){throw this.logger.warn("wrap_() caught error",{error:r}),this.onProgress({path:e,from:i,state:(0,B.ending)()||r instanceof L.AbortError?t.SyncFileStates.canceled:r instanceof D.TimeoutError?t.SyncFileStates.timeout:t.SyncFileStates.failed,details:(0,B.ending)()?void 0:(0,W.errorToS)(r),elapsedMs:Date.now()-s}),r}}get output(){return f(this,n,"f")??f(this,r,"m",h).call(this)}async flushClose(){return f(this,r,"m",u).call(this),this.close()}async close(){this.logger.info("Closing sync report");const e=f(this,n,"f");return m(this,n,void 0,"f"),m(this,l,0,"f"),await(0,G.endStream)(e),null==e?void 0:f(this,s,"f")}}t.SyncReport=se,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,r=new WeakSet,u=function(e){var t;const i=f(this,a,"f");if(m(this,a,e,"f"),null!=e&&(0,C.eqlPicked)(e,i,"path","state","details"))return this.logger.debug("deduping row",e),void m(this,o,(t=f(this,o,"f"),t++,t),"f");null!=i&&(0===f(this,o,"f")?f(this,r,"m",c).call(this,i):(f(this,r,"m",c).call(this,{...i,details:(0,v.compactBlanks)([i.details,`(repeated ${f(this,o,"f")+1} times)`]).join(" ")}),m(this,o,0,"f")))},c=function(e){var i;const r=(0,y.unparse)([e],{header:!1,columns:t.SyncReportHeaders.values});this.output.write(r+Y.Newline,(e=>{null!=e&&this.logger.error("Failed to write",e)})),m(this,l,(i=f(this,l,"f"),++i),"f")>K.Settings.syncReportMaxRows.valueOrDefault&&this.close()},d=function(){return this.logger.info("sync report ended",{rowCount:f(this,l,"f"),outputFiles:this.outputFiles}),this.flushClose()},h=function(){return m(this,s,function(){const e=p.DateTime.now();return ie().join(e.toFormat("y-MM-dd"),(0,j.filestamp)()+"-sync-report.csv")}().ensureNewSync_({emptyIsNew:!1}),"f"),this.outputFiles.push(f(this,s,"f").nativePath),this.logger.info("Opening new report: "+f(this,s,"f")),(0,F.isTest)()&&(0,O.stdoutWrite)({syncReport:f(this,s,"f").nativePath},!1),m(this,n,(0,g.createWriteStream)(f(this,s,"f").nativePath),"f"),f(this,n,"f").write((0,y.unparse)([t.SyncReportHeaders.values],{header:!1})+Y.Newline),f(this,n,"f")}},89966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const s=r(i(48161)),n=i(19851),a=i(55835),o=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),h=i(8103),f=i(43899);function m(){return(0,a.map)(f.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,a.map)(m(),(e=>e.join(c.platformName+"-"+s.default.arch())))}async function g(e){if(c.isWin&&(e=(0,o.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,h.pathIfExists)(m()?.join("bin",e))),(()=>(0,h.pathIfExists)(m()?.join(e))),(()=>(0,h.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,h.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,n.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,n.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,n.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,n.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const s=r(i(44652)),n=i(19851),a=i(22573),o=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,o.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,a.blank)(t.file))throw new Error("can't touch blank path");const r=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const o=(0,n.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await o())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await o())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(s.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(n){if(!i||"ENOENT"!==n.code)throw n;await(0,c.thenOrTimeoutError)(s.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},79847:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.trashOrUnlinkFileUri=t.trashOrUnlinkFileUris_=void 0;const o=n(i(51455)),l=a(i(49378)),u=i(40958),c=i(22573),d=i(13538),h=i(83104),f=i(45255),m=i(31562),p=i(98314),g=i(34102),y=i(28874),w=i(45200),v=i(16287),b=i(74128),S=i(84258),P="fs.Trash";async function _(e){const t=Date.now(),i=y.Settings.commandTimeoutMs.valueOrDefault,r=(0,c.toNotBlank)(e.nativePath)??await(0,d.thenOrTimeout)((0,w.uri2nativePath)(e.uri,e.mountpoint),i);if((0,c.blank)(r)||r===h.Timeout)return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not convert URI to native path",path:e.uri,elapsedMs:Date.now()-t}),{uri:e.uri,unlinked:!1};const s=await(0,v.statMaybe)(r);if(null==s)return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: no such file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(!s.isFile())return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: not a file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(y.Settings.trySoftDeletes.valueOrDefault)try{if(await(0,d.thenOrTimeoutError)((0,l.default)(r,{glob:!1}),i),await function(e){return(0,m.untilTrue)((async()=>null==await(0,v.statMaybe)(e)),{timeoutMs:f.ShortCommandTimeoutMs})}(r))return(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Moved file to trash",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0};(0,S.logger)().warn("soft-delete("+r+") didn't seem to work: the file is still there?")}catch(e){(0,b.syncReport)().onProgress({from:P,state:"note",details:"Failed to soft-delete file to trash: "+(0,p.errorToS)(e),path:r,elapsedMs:Date.now()-t}),(0,S.logger)().warn("Tried to soft-delete, but that failed. We'll try to hard-delete.",{error:e})}try{return await(0,d.thenOrTimeoutError)(o.unlink(r),i),(0,g.ee)().emit("fileChanged",r),(0,S.logger)().info("unlink("+r+") successful"),(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Permanently deleted file",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0}}catch(i){return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not move file to trash or delete: "+(0,p.errorToS)(i),path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!1}}}t.trashOrUnlinkFileUris_=async function(e){const t=[];for(const{uri:i,mountpoint:r}of(0,u.uniqBy)(e,(e=>e.uri)))try{t.push(await _({uri:i,mountpoint:r}))}catch(e){t.push({uri:i,unlinked:!1,error:e})}return t},t.trashOrUnlinkFileUri=_},70854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryUidStore=t.LibraryUIDStore=t.SystemUIDStore=t.UIDStore=t.mkuid=void 0;const r=i(19851),s=i(41400),n=i(55835),a=i(92782),o=i(37805),l=i(46292),u=i(34102),c=i(55222),d=i(28874),h=i(87128),f=i(95696);function m(){return(0,a.safeRandomUid)({radix:c.TokenRadix,chars:24,splitEveryN:4})}t.mkuid=m;class p extends h.JsonFileStore{constructor(e,t){super(e.join("."+t+"-uid.json"),(()=>({uid:m(),version:o.version,type:this.type,createdAt:Date.now()})),(e=>e.hide())),this.rootDir=e,this.type=t,this.readUid_=(0,r.lazy)((async()=>(await this.read_())?.uid))}}function g(e=d.Settings.libraryDir.valueOrDefault){return(0,n.map)(f.PosixFile.forMaybe(e),(e=>new p(e,"library")))}t.UIDStore=p,t.SystemUIDStore=(0,r.lazy)((()=>(0,n.map)((0,l.configDir)(),(e=>new p(f.PosixFile.for(e),"system"))))),t.LibraryUIDStore=(0,r.lazy)(g),t.libraryUidStore=g,(0,s.later)((()=>{(0,u.ee)().on("clearCache",(()=>{t.SystemUIDStore.unset(),t.LibraryUIDStore.unset()})),d.Settings.libraryDir.watchLater((()=>t.LibraryUIDStore.unset()))}))},84258:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const a=n(i(51455)),o=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,o.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const r of(0,l.toA)(e))try{null!=r&&await a.unlink((0,c.toNativePath_)(r))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+r,{error:e})}}},5545:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const s=r(i(76760)),n=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,n.toS)(i.path??s.default.sep)}},70257:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),s=i(45255),n=i(17217);t.WipTimeoutMs=s.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const a=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(a,"")},t.isWip=function(e){return a.test((0,n.basename)(e)??"")}},58722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),s=i(22911);class n extends r.Writable{constructor(e){super(e),this.deferred=new s.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=n},73428:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(51926),o=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=n.default.dirname(e);await(0,c.mkdirp_)(i),await s.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=n.default.dirname(e);(0,c.mkdirpSync_)(i),s.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,a.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))}},13047:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const s=r(i(73024)),n=i(76760),a=i(46466),o=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),w=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function v(e,t){return(await S(e,t)).toString()}async function b(e,t,i){const r=[],n=[s.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?n.push((0,o.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&n.push((0,o.createBrotliDecompress)().on("error",(e=>r.push(e)))),n.push(t),await(0,a.pipeline)(n),(0,u.isNotEmpty)(r))throw new f.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function S(e,t){const i=new y.WritableToBuffer;return await b(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await S(e))}async function _(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,n.parse)(e).dir),await(0,a.pipeline)(new g.ReadableBuffer(i),(0,o.createGzip)(),s.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=v,t.zcat=async function(e,t){try{return v(e,t)}catch(t){return void w().warn("zcat failed to read "+e,t)}},t.zpipe_=b,t.zCopyToBuffer_=S,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void w().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await _(e,t)}catch(t){w().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},87408:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStatusSummary=void 0;const r=i(63870),s=i(18454),n=i(89035),a=i(82638);t.getStatusSummary=async function(e={}){return(0,a.summarizeHealthChecks)({healthChecks:[...s.HealthCheck.allCritical(),(0,n.memoryHealthCheck)()],errors:s.HealthCheck.lastErrors(),timeoutMs:(0,r.commandTimeoutMs)(),skipPending:!0,...e})}},18454:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,w,v,b,S,P,_=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},T=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const M=i(19851),E=i(40958),D=i(76790),x=i(41400),k=i(50357),C=i(26905),F=i(50268),A=i(55835),I=i(68708),O=i(30976),L=i(51926),R=i(13538),N=i(42279),B=i(59455),j=i(54993),z=i(48884),V=i(89788),W=i(22454),U=i(50213),q=i(69591),H=i(22911),$=i(99331),G=i(5916),J=i(42638),K=i(77740),Y=i(98314),Z=i(70025),X=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),re=i(21525),se=i(82638),ne=(0,M.lazy)((()=>(0,U.mkLogger)("health.HealthCheck")));class ae{static traceLater_(e,t){const i=new H.Deferred(e);i.catch((t=>{_(this,s,"f",l).push(e+": failed: "+(0,Y.errorToS)(t)),this.onResultChange()})),_(this,s,"m",o).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return _(this,s,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){_(this,s,"f",l).push((0,L.isString)(e)?e:(0,Y.errorToS)(e)),this.onResultChange()}static lastErrors(){return _(this,s,"f",l).toA()}static addLoadingMsg(e){_(this,s,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,E.compact)((0,B.toA)(e)).map(j.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return ne().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:_(this,s,"f",h).entriesByCountDesc()}),(0,A.map)((0,z.leastBy)(e,(e=>[_(this,s,"f",h).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=_(this,s,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,A.map)(e,(e=>_(this,s,"f",h).incr(e.msg))),ne().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return X.Settings.skipHealthCheckIds.envValue=t,s.reset()}static findById(e){return _(this,s,"f",f).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,F.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=_(this,s,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=s.summary();if(e.pendingCount>0){const t=await Promise.all(s.testResultsCritical());e=s.summaryFromResults(t),ne().info("awaitSettled(): summary result",{summary:e,results:t})}return ne().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){s.summary.unset()}static reset(){if((0,$.ending)())ne().warn("Rejecting reset() when ending()",(0,C.shortStack)());else{this.onResultChange(),_(this,s,"f",l).clear(),_(this,s,"f",d).clear(),_(this,s,"f",h).clear(),_(this,s,"f",c).clear(),this.summary.clear(),T(this,s,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new s(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return _(this,s,"f",f).push(i),this.all.unset(),i}constructor(e,t,i,n,o,l,u,c,d,h,f,m,S,P=Q.commandTimeoutMs){r.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=n,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=h,this.errorLinks=f,this.onReset=m,this.ttlMs=S,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),v.set(this,(0,M.lazy)((async()=>{await _(this,p,"f").prior(),(0,k.eql)(_(this,g,"f"),_(this,r,"m",w).call(this))||(this.onReset?.(),await this.refresh(),_(this,v,"f").unset())}))),this.refresh=(0,M.lazy)((()=>new H.Deferred("refresh").observe((async()=>{await _(this,p,"f").prior();const e=_(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,U.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[F.HealthCheckSections.ordinal(this.section),l??999,this.id],T(this,p,(0,G.lazyAsync)({desc:this.pendingMsg,later:()=>_(s,s,"f",a).enqueue({name:this.id,l:()=>_(this,r,"m",b).call(this,o)}),ttlMs:S}),"f"),this.isCritical&&_(this,p,"f").watchLater({onChange:s.onCriticalResult,onError:s.onCriticalResult});for(const e of this.settings)X.Settings[e].watchLater((()=>_(this,v,"f").call(this)))}isStale(){return _(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return _(this,p,"f").settledCount()}reset(){return _(this,p,"f").unset(),this.onReset?.(),T(this,g,{starting:!0},"f"),this}setTTL(e){_(this,p,"f").setTTL(e)}result(){return _(this,p,"f").call(this)}isSkipped(){return X.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return _(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return _(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??_(this,r,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function oe(e){if((0,E.isEmpty)(e))return{};const[t,i]=(0,z.partition)(e,(e=>"button"===e.type||"POST"===e.method)),r={};return(0,E.isNotEmpty)(i)&&(r.links=(0,E.uniqBy)(i)),(0,E.isNotEmpty)(t)&&(r.buttons=(0,E.uniqBy)(t)),r}t.HealthCheck=ae,s=ae,p=new WeakMap,g=new WeakMap,y=new WeakMap,v=new WeakMap,r=new WeakSet,o=function(){return(0,E.filterInPlace)(_(this,s,"f",n),(e=>!e.isPending)),_(this,s,"f",n)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=ne().tap({level:"warn",msg:"#summary()",result:(0,se.summarizeHealthChecksSync)({errors:_(this,s,"f",l),skipPending:_(this,s,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&T(this,s,!0,"f",u),i.state!==_(this,s,"f",c).last?.state&&_(this,s,"f",c).push({state:i.state,ts:Date.now()}),i},w=function(){return(0,I.fromEntries)(this.settings.map((e=>[e,X.Settings[e].valueOrDefault])))},b=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();ne().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,C.shortStack)()}),T(this,g,_(this,r,"m",w).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,x.delay)((0,O.randomInt)(.3*i,.7*i)),this.isSkipped())return _(this,r,"m",S).call(this,{test:{level:"disabled",msg:["Disabled by "+X.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const s=await(0,R.thenOrTimeoutError)(e(),i);return _(this,r,"m",S).call(this,{test:s,elapsedMs:Date.now()-t})}catch(e){return _(this,r,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},S=function({test:e,src:t="#toResult",elapsedMs:i}){var r,n;const a=s.normalizeMsg(e.msg),o=e.level??((0,j.toS)(a).toLowerCase().includes("error")?"error":(0,j.toS)(a).toLowerCase().includes("warn")?"warn":"ok"),l=(0,E.compact)([...e?.links??("ok"===o||"pending"===o?this.okLinks:"warn"===o?this.warnLinks:"no-library"===o?this.noLibraryLinks:"error"===o?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:o,msg:a,elapsedMs:i,...oe(l)};return u.runCount=(T(this,y,(n=_(this,y,"f"),r=n++,n),"f"),r),(0,$.ending)()?u:this.logger.tap({level:re.HealthCheckLevelToLogLevel[o],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const s=(0,L.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,A.map)(e,Y.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,Z.isFatalError)(e)&&s.toLowerCase().includes("warn")?"warn":"error"),_(this,r,"m",S).call(this,{test:{msg:s,level:t},src:"#toErrorResult",elapsedMs:i})},n={value:[]},a={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},h={value:new W.CountingSet},f={value:[]},ae.all=(0,M.lazy)((()=>Object.freeze((0,D.sortBy)(_(s,s,"f",f),(e=>e.sortBy))))),ae.onCriticalResult=(0,q.debounce)((()=>{ne().info("onCriticalResult()",s.summary.refresh())}),250),ae.summary=(0,M.lazy)((()=>_(s,s,"m",m).call(s))),ae.resetDebounced=(0,q.debounce)((()=>s.reset()),50)},85021:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckCommand=void 0,t.HealthCheckCommand="--health"},33866:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const r=i(82950),s=i(50268),n=i(459),a=i(23560),o=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,a.isPermaService)(t)&&(e===s.HealthCheckLevels.error||(0,a.isLibraryRequiredService)(t)&&e===s.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,o.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,r.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new n.UnreachableCaseError(e)}}},42495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const r=i(40958),s=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,r.compact)([(0,s.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},89035:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const s=r(i(48161)),n=i(19851),a=i(82950),o=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),h=i(23560),f=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:r}){return{level:i,msg:[e+" from "+(0,h.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,a.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(r,2)])]}}function g(){return s.default.totalmem()f.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(f.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*f.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,n.lazy)((()=>"ok"!==g().level),o.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:o.minuteMs,later:async()=>g()})))},82638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const r=i(40958),s=i(42659),n=i(45599),a=i(41400),o=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),h=i(23560),f=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,n.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function w({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:r}){const s=new Map;for(const e of t??[])s.set(e.id,e);if(null!=e)for await(const t of f.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),r))s.set(t.id,t);return[...s.values()]}t.summarizeHealthChecks=async function(e){return b({...e,healthCheckResults:await w(e)})};const v=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:h.serviceName.prior()??process.title}})));function b(e){const t=(0,r.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),n=i.length,a=i.map((e=>e.id)),c=t.length-n,d=0===n,h=(0,r.uniq)((0,r.compactBlanks)(e.errors));if(h.length>0)return{...v(),level:l.HealthCheckLevels.error,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",h.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const s=t.filter((e=>e.level===i));if((0,r.isNotEmpty)(s)){const e=t.filter((e=>!s.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+s.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...v(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:a,pendingCount:n,settledCount:c,linkIds:s.map((e=>e.id)),ts:Date.now(),msg:(0,r.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,o.flatten)([...s,...e].map((e=>e.msg[0])))])},meta:{checks:s.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...v(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,s.fmtDateShort)(Date.now())]}})}(0,a.later)((()=>{m.Settings.libraryDir.watchLater((()=>v.unset()))})),t.summarizeHealthChecksSync=b},95242:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviewBuilder=t.mkPreviewAssetFile_=void 0;const a=i(57975),o=i(40958),l=i(22573),u=i(33374),c=i(98553),d=i(55835),h=i(68708),f=i(48884),m=i(50213),p=i(92434),g=i(54296),y=i(51837),w=i(57159),v=i(83278),b=i(95696),S=i(62105),P=i(84258),_=i(38156),T=i(69589),M=i(28874),E=i(47783),D=i(29990),x=i(16047),k=i(42725),C=i(4192),F=i(32876),A=i(50961),I=i(181);t.mkPreviewAssetFile_=async function(e){const t=await(0,E.readTags)(e);return{nativePath:e.nativePath,fileSize:await e.size(),mtime:await e.thisOrSidecareMaxMtimeMs(),uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath,mimetype:t.mimetype,rotation:t.rotation,...t.dimensions,sha:await e.sha_()}};class O{constructor(e,t,i){r.add(this),this.ap=e,this.assetFiles=t,this.logger=(0,m.mkLogger)("AssetPreviewBuilder("+e.assetId+")"),this.ctx=(0,T.forceContextOrSetting)(i),this.assetFiles=(0,p.sortAssetFiles)(this.assetFiles)}[(r=new WeakSet,a.inspect.custom)](){return{ctor:"AssetPreviewBuilder",assetId:this.ap.assetId,assetFiles:this.assetFiles}}async build_(){this.logger.info("build_(): asset file candidates:",this.assetFiles.map((e=>(0,h.pick)(e,"id","uri"))));const e=[];for(const t of this.assetFiles){const i=b.PosixFile.forMaybe(await(0,g.getAssetFileNativePath)(t));if(null!=i){{const e=await(0,S.whyRejectFile)(i);(0,l.blank)(e)||this.logger.info("skipping: rejected",{pf:i,whyRejected:e})}try{return await n(this,r,"m",s).call(this,i,t)}catch(i){e.push(i),this.logger.warn("Failed to set shown file to ",{best:t,error:i})}finally{this.ap.parent.clear()}}else this.logger.info("skipping: failed to get PosixFile",{af:t}),e.push(new Error("Cannot get path from URI "+(0,c.stringify)((0,h.pick)(t,"uri","mountpoint","nativePath"))))}return this.logger.throw("Cannot build previews: none of the files are valid",{doNotSend:!0,retriable:!1,files:this.assetFiles.map((e=>e.nativePath??e.uri)),causes:e})}async infoForBest_(e,t){await(0,I.throwIfInvalidFile_)(e);const i=await e.size(),r=await e.thisOrSidecareMaxMtimeMs();if(this.logger.debug("_build",{filesize:i,mtime:r,best:t.uri}),null==i||null==r)return this.logger.throw("build(): missing stat info for best file",{ignorable:!0,best:t});const{uri:s,width:n,height:a,sha:l,mimetype:u}=t;if(null==s||null==n||null==a||null==u||null==l)return this.logger.throw("build(): internal error: missing fields for best file "+e,{ignorable:!0,best:t});const c=(0,D.fitSizes)(t,t.mimetype);return{assetId:t.assetId,assetFileId:t.id,uri:s,uris:this.assetFiles.map((e=>e.uri)),path:e.nativePath,mtime:r,filesize:i,width:n,height:a,sha:l,mimetype:u,fitSizes:c.map((([,e])=>e.name)).join(","),sqWidths:(0,o.compact)(k.ImageSize.sq().map((e=>e.outputSize(t)?.width))),fitWidths:c.map((([e])=>e.width))}}async priorIfValid_(e,t){if(this.ctx.forceSync||this.ctx.forceRebuildPreviews)return;const i=await this.ap.readInfo.refresh();if(null!=i){if(i.assetId!==t.assetId)throw new y.InternalError("priorIfValid_(): mismatched asset IDs for "+e+": "+(0,c.stringify)({priorInfo:i,info:t}));const r=i.fitSizes.split(","),s=t.fitSizes.split(",");if(null!=i.sha&&i.sha===t.sha&&i.rotation===t.rotation&&(0,D.equivalentFitSizes)(r,s)){const n=(0,D.fitSizes)(e,e.mimetype),a=(0,o.diff)(r,s);if((0,o.isNotEmpty)(a)){this.logger.info("priorIfValid_(): removing previews that aren't required anymore.",{leftovers:a});for(const e of a){const t=n.find((([,t])=>t.name===e));if(null==t)this.logger.warn("priorIfValid_(): Failed to clean up: missing fit size",{fitsize:t,fits:n});else{const e=this.ap.fileForWidth(t[1].reducer.name,t[0].width);this.logger.debug("priorIfValid_(): unlinking unwanted preview "+e,{fitsize:t}),await e.unlink("warn")}}}return this.logger.debug("priorIfValid_(): SHA and rotation match, and previews exist.",{info:t,priorInfo:i}),await this.ap.writeInfo(t),t}}}}t.AssetPreviewBuilder=O,s=async function(e,t){this.logger.info("_build("+e+")",{uri:t.uri});const i=await this.infoForBest_(e,t),r=await this.priorIfValid_(t,i);if(null!=r)return r;const s=new _.PushProgressObserver({path:e.nativePath,op:"Building previews"},k.ImageSize.sq().length+k.ImageSize.fit().length);if(this.logger.debug("Rebuilding all previews from "+t.uri,{assetId:t.assetId,info:i}),null==await this.ap.parent.mkdirp())throw new Error("build(): Failed to create previews directory, "+this.ap.parent+" for "+t);const n=await this.ap.existingFiles(),a=await(0,A.sharpReadable_)({src:e,minDim:k.ImageSize.largestFit().max});if(null==a)throw new w.WrappedError("AssetPreviewBuilder.build(): "+t.uri+", "+e.nativePath+", is not readable by sharp.",{retriable:!1});const o=(0,A.toSharp)(a);if(t.mimetype.startsWith("image/")&&!(0,x.isHeifMimeType)(t.mimetype)&&null!=t.rotation&&0!==t.rotation&&(o.rotate(t.rotation),this.logger.debug("build(): rotating "+t.rotation+"°")),(0,v.isBaseFile)(a)&&a.desc.toLowerCase().includes("thumbnail"))try{o.trim(1)}catch{}const l=(0,D.fitSizes)(t,t.mimetype),c=[],m=[];let p,g;const y=k.ImageSize.largestSq(),b=(0,f.leastBy)(l,(([e,t])=>(0,d.map)(y.outputSize(e),(()=>t.megapixels()))))?.[1].name,S=(0,h.pick)(t,"width","height");{let e=o.clone(),t=S;for(const[i,r]of l){const n=Date.now(),a=t,o=this.ap.fileForWidth(r.reducer.name,i.width).wip();e=r.resize(i,e),t=i,r.name===b&&(g=e.clone(),p=i),(0,u.dmegapixels)(i)>=1&&r.reducer===F.Fit&&M.Settings.includePreviewTags.valueOrDefault&&m.push(o),await r.toJpeg({path:o.nativePath,sh:e,outputSize:i}),s.onProgress(),this.logger.debug("resize("+r.name+") "+(0,u.fmtDim)(a)+" -> "+(0,u.fmtDim)(i)+" in "+(Date.now()-n)+" ms"),c.push(o)}}{null==g?(this.logger.debug("square resize(): resorting to ",{origDim:S,bestFitNameForSq:b}),g=o,p=S):this.logger.debug("square resize(): using to ",{sqDim:p,bestFitNameForSq:b});let e=!1;for(const t of k.ImageSize.sq()){const i=Date.now(),r=p,n=t.outputSize(p??S);if(null==n){this.logger.debug("skipping square output for "+t.max);continue}e||(n.position=M.Settings.squareThumbStrategy.valueOrDefault,e=!0),this.logger.debug("Applying ",{outputSize:n});const a=this.ap.fileForWidth(t.reducer.name,n.width).wip();t.resize(n,g),p=n,await t.toJpeg({path:a.nativePath,sh:g,outputSize:n}),s.onProgress(),c.push(a),this.logger.debug("resize("+t.name+") "+(0,u.fmtDim)(r)+" -> "+(0,u.fmtDim)(n)+" in "+(Date.now()-i)+" ms")}}try{await(0,C.includePreviewTags_)(e,m).catch((t=>{this.logger.warn("Failed to restore metadata tags into previews for "+e,{error:t})}));const t=new Set(n.map((e=>e.nativePath)));for(const e of c){const i=await e.unwip_();t.delete(i.nativePath)}await(0,P.unlink)(t),await this.ap.writeInfo(i),this.logger.debug("Previews unwipped and info written",{info:i})}catch(t){throw await(0,P.unlink)(c),new w.WrappedError("Failed to create previews from "+e,{cause:t,path:e.nativePath,fatal:!1})}return i}},35721:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkDownloadableTitle=t.previewToDownloadable=t.extractPreviewInfo=void 0;const r=i(75761),s=i(33374),n=i(11371),a=i(55835),o=i(31586),l=i(56519),u=i(29882),c=i(50213),d=i(97352),h=i(81168),f=i(89782),m=(0,c.mkLogger)("extractPreviewInfo");function p(e,t,i,r){return`Download ${t} ${e.ext} ${i} (${(0,s.fmtDim)(r)})`}t.extractPreviewInfo=function(e,t){const i=t.posixPathFrom(e).replace(/\//g,"").split("-"),r=(0,o.toInt)(i[0]),s=n.ReducerNames.getCI(i[1]),a=(0,d.extractInt)(i[2]);return(0,o.gt0)(r)?{file:t,assetId:r,reducer:s,width:a}:void m.warn("Failed to extract preview info",{file:t,previewsRoot:e,arr:i,assetId:r,reducer:s,width:a})},t.previewToDownloadable=async function(e,t){return(0,a.map2)(t.assetId,t.width,((i,a)=>(0,l.thenMap)((0,f.dimensions)(t.file),(o=>{const l=(0,s.dimToSize)(o);return{size:l,basename:`${(0,h.stripSuffix)(e,(0,u.extname)(e))}-${l}${t.file.ext}`,title:p(t.file,l,"image",o),description:`Download ${l}`,details:`(${(0,s.fmtDim)(o)} ${t.file.ext})`,href:(0,r.assetImgLink)({assetId:i,reducer:n.ReducerNames.fit,width:a})}}))))},t.mkDownloadableTitle=p},16524:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviews=void 0;const a=i(19851),o=i(40958),l=i(75761),u=i(11371),c=i(68708),d=i(39926),h=i(58939),f=i(48884),m=i(50213),p=i(81168),g=i(56519),y=i(38835),w=i(70417),v=i(35721);t.AssetPreviews=class{constructor(e,t){r.add(this),this.previewsRoot=e,this.readInfo=(0,a.lazy)((()=>this.infoJson().readJson("debug"))),this.logger=(0,m.mkLogger)("AssetPreviews(assetId:"+(0,h.id2id)(t)+")"),this.assetId=(0,h.id2id)(t);const i=(0,d.leftPad)(this.assetId,8,"0"),s=(0,p.splitEvery)(i,3);this.basename=s.pop()+"-",this.parent=e.join(...s)}parentNotExists(){return this.parent.clear().notExists()}async existingFiles(){return await this.parent.clear().childFiles((e=>e.base.startsWith(this.basename)))??[]}async existingJpgs(){return(await this.existingFiles()).filter((e=>".jpg"===e.ext))}async previewInfos(){return(0,g.sortByAsync)({name:"img.AssetPreviews.previews",arr:n(this,r,"m",s).call(this),f:e=>e?.file.size()})}async deleteAll(){const e=await this.existingFiles();if(e.length>20)throw new Error("deleteAll(): rejected: > 20 existing files?!"+y.InternalErrorFlag);for(const t of e)await t.unlink();return e}fileForSuffix(e){return this.parent.join(this.basename+e)}mp4(){return this.fileForSuffix("video.mp4")}infoJson(){return this.fileForSuffix("info.json")}writeInfo(e){return this.readInfo.unset(),this.infoJson().writeJson((0,c.pick)(e,"assetId","assetFileId","uri","uris","path","mimetype","width","height","mtime","filesize","sha","rotation","fitSizes","fitWidths"))}fileForWidth(e,t){return this.fileForSuffix(e+"-w"+t+".jpg")}async filesForReducer(e){const t=this.basename+e+"-";return this.logger.tap({msg:"filesForReducer("+e+")",result:(await this.existingFiles()).filter((e=>e.base.startsWith(t)))})}async smallestFileForReducer(e){return(0,f.leastBy)(await this.filesForReducer(e),(e=>(0,v.extractPreviewInfo)(this.previewsRoot,e)?.width))}async largestFileForReducer(e){return(0,f.greatestBy)(await this.filesForReducer(e),(e=>(0,v.extractPreviewInfo)(this.previewsRoot,e)?.width))}async widths(e){const t=await this.readInfo(),i=e===u.ReducerNames.sq?"sqWidths":"fitWidths",r=t?.[i];if(!(0,o.isEmpty)(r))return r;const s=(0,o.compact)((await this.previewInfos()).filter((t=>t.reducer===e)).map((e=>e.width)));return null!=t&&(t[i]=s,await this.writeInfo(t)),s}async posterLink(){const e=await this.widths(u.ReducerNames.fit);return(0,l.assetImgLink)({assetId:this.assetId,reducer:u.ReducerNames.fit,width:(0,w.max)(e)})}async imgAttrs(e,t=!1,i=!0){if(t||e!==u.ReducerNames.sq){const t=e===u.ReducerNames.fit?await this.readInfo():void 0;return(0,l.assetImgAttrs)({assetId:this.assetId,reducer:e,widths:await this.widths(e),lazyLoad:i,af:t})}return(0,l.assetSqImgAttrs)({assetId:this.assetId,lazyLoad:i})}},r=new WeakSet,s=async function(){const e=[];for(const t of await this.existingFiles()){const i=(0,v.extractPreviewInfo)(this.previewsRoot,t);null!=i&&e.push(i)}return e}},52086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},33106:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.dctPixels=t.dctHashCIELAB=t.dctHash=void 0;const s=r(i(9288)),n=i(96249),a=i(85810),o=32,l=function(e){const t=new Array(32);for(let e=1;e<32;e++)t[e]=1;return t[0]=1/Math.sqrt(2),t}(),u=function(e){const t=new Array(32);for(let e=0;e<32;e++){t[e]=new Array(32);for(let i=0;i<32;i++)t[e][i]=Math.cos((2*e+1)/64*i*Math.PI)}return t}();function c(e){const t=new Array(o);for(let i=0;is?1:0);return n}t.dctHash=async function(e){return c(await e.greyscale().resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer())},t.dctHashCIELAB=async function(e){const t=await e.resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer(),i=(0,a.rgb2labArray)(t);return(0,n.flatten)(i.map(c))},t.dctPixels=c},86580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(21605),o=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,n.gt0)(e.width)&&(0,n.gt0)(e.height)?(0,n.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,s.dmegapixels)(e.dimensions):(0,n.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,n.lt)(e.width,t.width)&&(0,n.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,n.lte)(e?.width,t?.width)&&(0,n.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,n.lt)(e.width,t.width)||(0,n.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,r.compact)((0,o.toS)(e).split(/[x×]/).map((e=>(0,n.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,r=Math.round(Math.sqrt(t*i));return{width:r,height:Math.round(r/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const r=u(e,i);return null==r?[]:a.Rotations.filter((e=>u(c(t,e),i)===r))}},89782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(56519),o=i(1078),l=i(5733),u=(0,r.lazy)((()=>(0,n.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,s.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,a.thenMap)((0,o.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},29990:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.equivalentFitSizes=t.fitSizes=void 0;const r=i(40958),s=i(33374),n=i(16170),a=i(42725),o=[a.ImageSize.QVGA,a.ImageSize.QQVGA];function l(e){return"qhd"===e?"wvga":"uhd"===e?"uhd4k":e}t.fitSizes=function(e,t){const i=a.ImageSize.fit(),r=[];let l=(0,n.isMimeTypeSupportedByBrowser)(t)?e:void 0;for(let t=0;t3||(0,s.dmegapixels)(a)-(0,s.dmegapixels)(l)>2.5)&&(l=a,r.push([a,n])))}return r},t.equivalentFitSizes=function(e,t){return(0,r.includesAll)((0,r.compactBlanks)(e).map(l),(0,r.compactBlanks)(t).map(l))}},277:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const r=i(22573),s=i(41400),n=i(54993),a=i(19851),o=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),h=i(78330),f=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),w=(0,a.lazy)((()=>(0,o.mkLogger)("img.Heif")));function v(e){return(0,n.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function b(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,a.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,r.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){w().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,r.blank)(e))return void w().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=v(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,r.blank)(i)&&(0,l.hasApt)()){const t=await(0,h.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,r.blank)(i)&&(0,f.hasPacman)()&&(i=(await(0,f.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,r.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void w().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=v,t.isHeifSupported=b,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await b()?(0,g.heif2png_)(e):void w().throw("HEIF support is missing",{src:e.nativePath})},(0,s.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(41400),o=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),h=i(28874),f=i(89782),m=i(13940),p=(0,r.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,s.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,r.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:h.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?n.minuteMs:void 0),e})),(0,a.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,f.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(h.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:h.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(o.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const r=i(22573),s=i(54993),n=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,r.blank)(e)&&n.test((0,s.toS)(e))}},13940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),s=i(19851),n=i(42659),a=i(59455),o=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),w=i(55222),v=i(63870),b=(0,s.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,s.lazy)((()=>(S(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const S=(0,s.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const s=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const n=s.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await n.mkdirp_(),await n.utimes();const a=n.join(i+r);return b().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:a}),a}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,a.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+w.TokenRadix.randomChars(2),w.TokenRadix.randomChars(16)+(0,o.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*n.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const s=await P(e,t,i);return await s.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,v.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),s}catch(r){return b().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},48368:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashDim=t.toImageHash=t.isImageHash=t._imageHash_=t.imageHash_=t.imageHash=t.maxPerBits=void 0;const s=r(i(9288)),n=i(19851),a=i(40958),o=i(22573),l=i(42659),u=i(33374),c=i(56038),d=i(85810),h=i(76490),f=i(40401),m=i(86758),p=i(85434),g=i(96706),y=i(38835),w=i(88561),v=i(95696),b=i(17217),S=i(50213),P=i(23624),_=i(28874),T=i(12089),M=i(16170),E=i(1078),D=i(33106),x=i(86580),k=i(78011),C=i(50961);t.maxPerBits=function(e){return Math.floor(52/e)};const F=(0,n.lazy)((()=>(0,S.mkLogger)("img.ImageHash")));t.imageHash=async function(e){try{return await(0,t.imageHash_)((0,b.toNativePath_)(e))}catch(t){return void F().warn("imageHash() failed for "+e,t)}};const A=(0,n.lazy)((()=>new w.FileCache({name:"img.imageHash",timeoutMs:l.minuteMs})));async function I(e){const t=v.PosixFile.for(e),i=await(0,E.extractSizeInfoFromFile)(t);if(null==i)throw new Error("Failed to read dimensions for "+e+y.NonFatalErrorFlag+y.DoNotSendErrorFlag);const r=(0,x.fitToResolution)(i.dimensions,Math.round(_.Settings.dominantColorPixels.valueOrDefault)),n=await(0,C.sharpReadable_)({src:t,minDim:r});return(0,c.time)("img.imageHash",(()=>async function({file:e,readable:t,sizeInfo:i}){const r=(0,S.mkLogger)("ImageHash("+e+")");if(null==t)return r.throw("Cannot build readable stream");const n=(0,x.fitToResolution)(i.dimensions,_.Settings.dominantColorPixels.valueOrDefault);if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-orig.jpg";await(0,C.toSharp)(t).jpeg().toFile(i),console.log({out:i,readable:t})}let a=(0,C.toSharp)(t).removeAlpha();(0,M.isVideoMimeType)(t.mimetype)||(a=a.rotate(i.rotation)),(0,u.dmegapixels)(i.dimensions)<.1&&(a=a.trim({background:"#000",threshold:0})),a=a.resize({fit:s.default.fit.outside,...n,withoutEnlargement:!0});const{data:o,info:l}=await a.raw().toBuffer({resolveWithObject:!0});if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-"+l.width+"w.jpg";await(0,s.default)(o,{raw:{...l,channels:3}}).jpeg().toFile(i),console.log({out:i,rgbInfo:l,readable:t})}const c=(0,d.rgb2labTriplets)(o),h=(0,f.extractDominantColors)(c),p=(0,m.labsAreGreyscale)(c),y=()=>(0,s.default)(o,{raw:{...l,channels:3}}),w=await(p?k.meanDiffHash:k.meanDiffHashCIELAB)(y()),v=await(p?D.dctHash:D.dctHashCIELAB)(y());return{meanHash:(0,P.b64encodeBits)(w.meanHash),diffHash:(0,P.b64encodeBits)(w.diffHash),dctHash:(0,P.b64encodeBits)(v),dominantColors:h.dominantColors,dominantColorsDescription:h.description,dominantColorScore:h.dominantColorScore,isGreyscale:p,mimetype:(0,M.normalizeMimetype)(t.mimetype),...i.dimensions,rotation:i.rotation??0}}({file:t,readable:n,sizeInfo:i})))}function O(e){return null!=e&&(0,o.notBlank)(e.meanHash)&&(0,o.notBlank)(e.mimetype)&&(0,a.isNotEmpty)(e.dominantColors)}t.imageHash_=(0,T.shim1)({name:"img.imageHash",cache:A,impl:I}),t._imageHash_=I,t.isImageHash=O,t.toImageHash=function(e){if(null!=e){if(O(e))return e;if((0,p.isModeData)(e)){const t={...(0,p.omitModeData)(e),dominantColors:h.DominantColor.fromModeData(e)};if(O(t))return t}}},t.HashDim=8},80361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageHashSimilarity=t.isVerySimilarComparison=t.isVerySimilarImageHash=t.isSimilarImageHash=t.isVerySimilarImage=t.compareImageHashes=t.isSimilarImage=t.hammRatio=t.meanHashVariants=t.isGreyscaleMeanHash=t.labsCorr2=t.isImageHashComparison=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(38639),o=i(33374),l=i(57924),u=i(55835),c=i(31586),d=i(68708),h=i(39926),f=i(21605),m=i(48884),p=i(50213),g=i(97352),y=i(85810),w=i(3048),v=i(32848),b=i(82647),S=i(38812),P=i(70417),_=i(23624),T=i(28874),M=i(86580),E=i(48368),D=i(2090),x=(0,r.lazy)((()=>(0,p.mkLogger)("img.ImageHashComparison")));t.isImageHashComparison=function(e){return null!=e&&(0,E.isImageHash)(e.a)&&(0,E.isImageHash)(e.b)&&[e.imageCorr,e.colorCorr,e.aRotation].every(c.isNumber)},t.labsCorr2=function(e,t){const i=(0,s.sum)(e,(e=>(0,w.diffCIECorr)(e,(0,y.closestLab)(t,e))))+(0,s.sum)(t,(t=>(0,w.diffCIECorr)(t,(0,y.closestLab)(e,t)))),r=Math.max(e.length,t.length,i);return(r-i)/r};const k=/A{20}=?$/;function C(e){return null!=e&&((0,g.within)(7,12,e.length)||null!=e?.match(k))}function F(e,t,i=E.HashDim){const r=(0,_.b64decode)(e).toString(2).split("").map((e=>"1"===e?1:0)),s=i*i;for(;r.length%s!=0;)r.unshift(0);return r.length===s||t?r.slice(0,s):r.slice(0,s).map(((e,t)=>4*e+2*r[t+s]+r[t+2*s]))}function A({a:e,b:t,greyscale:i,dim:r=E.HashDim,rotationsToCheck:a}){if((0,n.blank)(e)||(0,n.blank)(t))return{hammRatio:0,bRotation:0};if(e===t)return{hammRatio:1,bRotation:0};const o=F(e,i,r),l=F(t,i,r);(0,s.isEmpty)(a)&&(a=[0]);const u=a.map((e=>({bRotation:e,hammRatio:(0,c.sigFigs)((0,g.hammRatioIntArrays)(o,(0,S.rotateSquareMatrix)(l,e),i?1:3),2)})));x().debug("hammRatio()",{results:u,rotationsToCheck:a});const d=(0,m.greatestBy)(u,(e=>[(0,c.sigFigs)(e.hammRatio,1),-f.Rotations.indexOf(e.bRotation)]));return{bRotation:d.bRotation,hammRatio:(0,c.sigFigs)(d.hammRatio,2)}}async function I(e,t,i="debug",r={}){return x().tap({msg:`isSimilarImage(${e},${t})`,level:i,result:L(await(0,E.imageHash)(e),await(0,E.imageHash)(t),r)})}function O(e,t,i={}){const r=(0,E.toImageHash)(e),s=(0,E.toImageHash)(t);if(null==r||null==s)return;const n=(0,a.isTrue)(i.capturedAtIsFuzzy),h=!(0,a.isTrue)(i.forceColor)&&((0,a.isTrue)(i.forceGreyscale)||(r.isGreyscale??C(r.meanHash))||(s.isGreyscale??C(s.meanHash))),f=A({a:r.meanHash,b:s.meanHash,greyscale:h,rotationsToCheck:i.rotationsToCheck??(0,M.validRotations)(r,s)}),m=A({a:r.diffHash,b:s.diffHash,greyscale:h,rotationsToCheck:[]}),p=A({a:r.dctHash,b:s.dctHash,greyscale:h,rotationsToCheck:[]}),g=(0,v.dominantColorCorrelation)(r.dominantColors,s.dominantColors);if(null==g)return void x().debug("imageHashCompare(): missing color correlation");const y=r.mimetype===s.mimetype,w=(0,M.aspectRatio)(r),S=(0,M.aspectRatio)((0,o.maybeDimSwap)(s,f.bRotation)),P=null!=w&&null!=S&&!(0,o.isCloseAspectRatio)(w,S);let _=0,k=0;n&&(k+=T.Settings.imageHashFuzzyDateDelta.valueOrDefault,_+=T.Settings.imageHashFuzzyDateDelta.valueOrDefault),y||(k+=T.Settings.imageHashDifferentMimetypesDelta.valueOrDefault,_+=T.Settings.imageHashDifferentMimetypesDelta.valueOrDefault),h&&(_+=T.Settings.imageHashGreyscaleDelta.valueOrDefault,k+=T.Settings.imageHashGreyscaleDelta.valueOrDefault);const F=R((_+(i.minImageCorr??T.Settings.minImageCoeffPct.valueOrDefault))/100),I=R((k+(i.minColorCorr??T.Settings.minColorCoeffPct.valueOrDefault))/100),O=[];P&&O.push(`aspect ratio mismatch (${(0,D.fmtAspectRatio)(w)} vs ${(0,D.fmtAspectRatio)(S)})`);const L=[],N=new b.Average;N.push(f.hammRatio),f.hammRatioN.push(e))),(0,u.map)(p?.hammRatio,(e=>N.push(e))),(0,c.lt)(m?.hammRatio,F)&&L.push("gradient"),(0,c.lt)(p?.hammRatio,F)&&L.push("DCT")),L.length>0&&O.push("different image content ("+(0,l.andList)(L)+")");const j=g>=I,z=j&&N.avg>=F;j||O.push("different dominant colors");const V={meanHashCorr:(0,c.sigFigs)(f.hammRatio,2),diffHashCorr:B?void 0:(0,u.map)(m,(e=>(0,c.sigFigs)(e.hammRatio,2))),dctHashCorr:B?void 0:(0,u.map)(p,(e=>(0,c.sigFigs)(e.hammRatio,2))),hashCorrAvg:N.avg,minImageCorr:F,imageCoeffDelta:_,colorCorr:(0,c.sigFigs)(g,2),minColorCorr:I,colorCoeffDelta:k,isGreyscale:h,bRotation:f.bRotation,aAspectRatio:w,bAspectRatio:S,isSimilar:z,whyNotSimilar:z?void 0:(0,l.andList)(O)};return x().info("compareImageHashes",{a:(0,d.pickCompact)(r,"uri","id","assetId"),b:(0,d.pickCompact)(s,"uri","id","assetId"),...V}),{a:r,b:s,...V}}function L(e,t,i){return O(e,t,i)?.isSimilar??!1}function R(e){return(0,c.sigFigs)((0,c.clamp)(0,1,e),3)}function N(e){return null!=e&&(0,c.gte)(e.meanHashCorr,.9)&&(0,c.gte)(e.colorCorr,.9)}t.isGreyscaleMeanHash=C,t.meanHashVariants=function(e,t=!1,i=E.HashDim){const r=(t=t||null!=e.match(k))?(0,h.padding)("0",2*i*i):"",s=F(e,t,i);return f.Rotations.map((e=>(0,_.b64encode)(BigInt("0b0"+(0,S.rotateSquareMatrix)(s,e).map((e=>e.toString(2))).join("")+r))))},t.hammRatio=A,t.isSimilarImage=I,t.compareImageHashes=O,t.isVerySimilarImage=async function(e,t,i="debug",r={}){return I(e,t,i,{rotationsToCheck:[0],...r,minImageCorr:.92,minColorCorr:.92})},t.isSimilarImageHash=L,t.isVerySimilarImageHash=function(e,t,i={}){return N(O(e,t,i))},t.isVerySimilarComparison=N,t.imageHashSimilarity=function(e,t){return(0,u.map)(O(e,t),(e=>(0,P.avg)([e.meanHashCorr,e.colorCorr])))}},42725:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ImageSize=void 0;const a=i(57975),o=i(19851),l=i(33374),u=i(12168),c=i(48884),d=i(28874),h=i(32876),f=i(5733);class m{static sq(){return n(this,r,"f",s).filter((e=>e.reducer===h.Square))}static largestSq(){return(0,c.greatestBy)(this.sq(),(e=>e.megapixels()))}static fit(){const e=d.Settings.previewResolutions.valueOrDefault;return n(this,r,"f",s).filter((t=>t.reducer===h.Fit&&e.includes(t.name)))}static largestFit(){return(0,c.greatestBy)(this.fit(),(e=>e.megapixels()))}static all(){return[...n(this,r,"f",s)]}constructor(e,t,i,a,l=!0){this.name=e,this.maxWidth=t,this.maxHeight=i,this.reducer=a,this.rotational=l,this.megapixels=(0,o.lazy)((()=>(0,u.megapixels)(this.maxWidth*this.maxHeight))),this.max={width:t,height:i},n(r,r,"f",s).push(this)}[a.inspect.custom](){return{ctor:"ImageSize",name:this.name+" ("+this.reducer.name+")",maxDim:this.maxWidth+"×"+this.maxHeight,maxMP:this.megapixels()}}get aspectRatio(){return this.maxWidth/this.maxHeight}get maxPixels(){return this.maxWidth*this.maxHeight}get minDimension(){return Math.min(this.maxWidth,this.maxHeight)}outputSize(e){return this.reducer.reduce(this.rotational&&(0,l.isPortrait)(e)?(0,l.dimSwap)(this.max):this.max,e)}resize(e,t){return t.resize({...e,fit:this.reducer.fit,withoutEnlargement:!0})}toJpeg({path:e,sh:t,outputSize:i}){return((0,l.dmegapixels)(i)<2||d.Settings.previewSharpen.valueOrDefault)&&(t=t.sharpen()),t.jpeg((0,f.sharpRenderOptions)()).toFile(e)}toString(){return this.name}}t.ImageSize=m,r=m,s={value:[]},m.UHD8k=new r("uhd8k",7680,4320,h.Fit,!1),m.UHD5k=new r("uhd5k",5120,2880,h.Fit,!1),m.UHD=new r("uhd4k",4096,2160,h.Fit),m.QHD=new r("qhd",3120,1440,h.Fit),m.FHD=new r("fhd",1920,1080,h.Fit),m.HD=new r("hd",1280,720,h.Fit),m.WVGA=new r("wvga",720,480,h.Fit),m.QVGA=new r("qvga",320,240,h.Fit),m.QQVGA=new r("qqvga",160,120,h.Fit),m.S480=new r("s480",480,480,h.Square),m.S240=new r("s240",240,240,h.Square),m.S120=new r("s120",120,120,h.Square),m.S60=new r("s60",60,60,h.Square)},4192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includePreviewTags_=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(50213),o=i(56038),l=i(28874),u=i(47783),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.includePreviewTags")));t.includePreviewTags_=async function(e,t){!1===l.Settings.includePreviewTags.valueOrDefault||l.Settings.includedPreviewTags.isEmpty()||(0,s.isEmpty)(t)||(c().info("Re-adding metadata to previews..."),await(0,o.time)("img.includePreviewTags",(async()=>{const i=(0,n.pick)(await(0,u.readTags)(e),...l.Settings.includedPreviewTags.values),r=i?.capturedAt;null!=r&&(delete i.capturedAt,(0,n.assignFields)(i,r.asExifTag()));const s=i?.exposureSettings;null!=s&&(delete i.exposureSettings,i.FocalLength=s.focalLength,i.FNumber=s.aperture,i.ExposureTime=s.shutterSpeed,i.ISO=s.iso),l.Settings.includedPreviewTags.has("Source")&&(i.Source=e.nativePath),(0,n.isEmptyObj)(i)?c().warn("not adding tags to previews: no values for tags in source file",{src:e,includedPreviewTags:l.Settings.includedPreviewTags.values}):(c().info("Overwriting preview tags...",{src:e,writeTags:i}),await Promise.all(t.map((e=>(0,u.overwriteTags_)(e,i)))))})))}},78011:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.meanDiffHashCIELAB=t.meanDiffHash=t.dhash=t.mhash=void 0;const s=r(i(9288)),n=i(96249),a=i(59455),o=i(85810),l=i(70417),u=i(48368);function c(e){const t=(0,l.avg)(e);return null==t?[]:(0,a.toA)(e).map((e=>e>=t?1:0))}function d(e){const t=(0,a.toA)(e),i=Math.round(Math.sqrt(t.length));return t.map(((t,r)=>t>=(0===r?e[i]:r%i==0?e[r-i]:e[r-1])?1:0))}t.mhash=c,t.dhash=d,t.meanDiffHash=async function(e,t=u.HashDim){const i=await e.greyscale().resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer();return{meanHash:c(i),diffHash:d(i)}},t.meanDiffHashCIELAB=async function(e,t=u.HashDim){const i=await e.resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer(),r=(0,o.rgb2labArray)(i);return{meanHash:(0,n.flatten)(r.map(c)),diffHash:(0,n.flatten)(r.map(d))}}},48604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildAssetPreviews_=t.Previews=void 0;const r=i(19851),s=i(55835),n=i(50213),a=i(12089),o=i(87290),l=i(95242),u=i(16524);class c{constructor(e){this.root=e}apb(e,t,i){return new l.AssetPreviewBuilder(this.ap(e),t,i)}ap(e){return new u.AssetPreviews(this.root,e)}}t.Previews=c,c.instance=(0,r.lazy)((()=>((0,n.mkLogger)("Previews").info(".instance()",{libraryPreviewsDir:(0,o.libraryPreviewsDirPosixFile)()}),(0,s.map)((0,o.libraryPreviewsDirPosixFile)(),(e=>new c(e)))))),t.buildAssetPreviews_=(0,a.shim1)({name:"img.buildAssetPreviews",impl:e=>c.instance().apb(e.assetId,e.assetFiles,e).build_()})},2090:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(34666),o=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,n.isNumber)(e)?e:((0,n.toGt0)(e.width)??0)/((0,n.toGt0)(e.height)??0),(e=>(0,o.leastBy)(t.StandardAspectRatios,(t=>{const r=Math.abs(e-t);return r>i?void 0:r}))??e))}function c(e,i,r=t.RatioEpsilon){return(0,a.lt)((0,n.absdiff)(u(e),u(i)),r)}function d(e,i){return(0,o.leastByCtx)(t.Ratios,(t=>{const r=Math.abs(t.i-e);return r[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,s.maybeDimSwap)(e.dimensions,e.rotation),(0,s.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,n.sigFigs)(e,3))}},34943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const r=i(19851),s=i(31586),n=i(80049),a=i(50213),o=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),h=(0,r.lazy)((()=>(0,a.mkLogger)("img.RawInfo"))),f=(0,r.lazy)((()=>new n.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:o.ShortCommandTimeoutMs})));async function m(e){return f().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,r,n,a]=e.split("\t"),o=(0,s.toGt0)(n),l=(0,s.toGt0)(a);return null==o||null==l?h().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):h().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:r,ImageSize:{width:o,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>f.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?f.prior()?.clear():f.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{h().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},32876:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Reducers=t.Fit=t.fitInsideToMaxPixels=t.fitInsideToAspectRatio=t.Square=t.SharpFits=void 0;const r=i(19851),s=i(33374),n=i(4188),a=i(11371),o=i(31586),l=i(68708),u=i(50989),c=i(50213),d=i(86580);var h,f;t.SharpFits=(0,u.strEnum)("cover","contain","fill","inside","outside"),function(e){const i=(0,r.lazy)((()=>(0,c.mkLogger)("img.Reducers.Square")));e.name=a.ReducerNames.sq,e.fit="cover",e.reduce=function(e,r){const s=(0,d.lteBoth)(e,r)?{...e,fit:t.SharpFits.cover}:void 0;return i().tap({msg:"reduce()",result:s,meta:{max:e,input:(0,l.pick)(r,"width","height","nativePath")}})}}(h||(t.Square=h={})),t.fitInsideToAspectRatio=function(e,t){return e.width/e.height>=t?{width:Math.floor(e.height*t),height:e.height}:{width:e.width,height:Math.floor(e.width/t)}},t.fitInsideToMaxPixels=function(e,t){if(null==e||!(0,o.gt0)(e.width)||!(0,o.gt0)(e.height))return;if((0,s.pixels)(e)(0,c.mkLogger)("img.Reducers.Fit")));e.name=a.ReducerNames.fit,e.fit="inside",e.reduce=function(e,i){if(!(0,d.ltBoth)(i,e))return(0,n.fitInside)(i,e);t().trace(`reduce(): input ${(0,s.fmtDim)(i)} is too small for ${(0,s.fmtDim)(e)}`)}}(f||(t.Fit=f={})),t.Reducers=[h,f]},5733:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const s=r(i(9288)),n=i(19851),a=i(41400),o=i(50213),l=i(28874),u=i(15674),c=(0,n.lazy)((()=>(0,o.mkLogger)("img.Sharp")));function d(e,t){return(0,s.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,n.lazy)((()=>{s.default.simd(l.Settings.enableSIMD.valueOrDefault),s.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),s.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,a.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},50961:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractImageForThumbs_=t.sharpReadable_=t.toSharp=t.imgFromExif_=t._imgFromExif_=void 0;const s=i(77988),n=r(i(9288)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(33374),d=i(98553),h=i(31586),f=i(68708),m=i(51926),p=i(41583),g=i(50213),y=i(97352),w=i(56519),v=i(56038),b=i(57159),S=i(95696),P=i(17217),_=i(28874),T=i(47783),M=i(16170),E=i(95141),D=i(54979),x=i(1078),k=i(63870),C=i(86580),F=i(277),A=i(16047),I=i(13940),O=i(5733),L=i(66106),R=i(19350),N=(0,a.lazy)((()=>(0,g.mkLogger)("img.SharpReadable")));async function B(e,t,i){return i?await(0,T.exiftool)().extractBinaryTagToBuffer(t,e.nativePath):(await z(e,t))?.nativePath}async function j(e,t,i,r,a){const o=t?.[i];if(!(o instanceof s.BinaryField))return;const l=o.bytes<_.Settings.maxEmbeddedBuffer.valueOrDefault;try{const t=await B(e,i,l);if(null==t)return;const s=(0,n.default)(t,{failOn:_.Settings.imageFailOn.valueOrDefault}),o=await s.metadata(),u=(0,C.aspectRatio)(o);if(null!=a&&null!=u&&!(0,h.closeTo)(a,u,.2))return void N().info("imgFromExif("+e+", "+i+"): rejecting (aspect ratio mismatch)",{fileAspectRatio:a,renderedAspectRatio:u});const c=(0,C.lteBoth)(r,o);return N().debug("imgFromExif("+e+", "+i+")",{valid:c,minDim:r,useBuffer:l,fileAspectRatio:a,renderedAspectRatio:u,dim:(0,f.pick)(o,"width","height")}),c?{sharp:s,file:(0,m.isString)(t)?S.PosixFile.for(t):void 0}:void 0}catch(t){return void N().info("Failed to read image from EXIF tag "+i,{src:e,error:t})}}async function z(e,t){const i=t.toLowerCase().endsWith("tiff")?".tiff":".jpg";try{const r=await(0,I.tmpImageFile_)({src:e,tag:t,ext:i});return await r.applyIfEmpty_({retries:2,fn_:i=>(0,T.extractBinaryTag)(t,e.nativePath,i.nativePath),timeoutMs:(0,k.commandTimeoutMs)()})}catch(i){return void N().throw("Failed to extract embedded "+t+" from "+e.nativePath,{error:i})}}t._imgFromExif_=B,t.imgFromExif_=j,t.toSharp=function(e){const t=e;if((0,O.isSharp)(t.sharp))return t.sharp;if((0,P.isSimpleFile)(t.file))return(0,n.default)(t.file.nativePath,{failOn:_.Settings.imageFailOn.valueOrDefault});throw new Error("toSharp(): not a Sharp object: "+(0,d.stringify)(e))},t.sharpReadable_=function(e){return(0,v.time)(`img.sharpReadable${e.src.ext.toUpperCase()}`,(()=>async function({src:e,minDim:t,skipEmbedded:i}){const r=N().addParameterContext(e.nativePath);(0,O.setupSharp)();const n=await(0,D.readMimeType)(e);if((0,u.blank)(n))return r.throw(e+" is not supported (missing MIMEType)",{doNotSend:!0});const a=await(0,x.extractSizeInfoFromFile)(e);if(null==a)return void r.warn("Failed to extract size info from "+e);const d=[];function f(e,t){t.desc=e,d.push(t)}const m=a.rotation,g=(0,M.isVideoMimeType)(n),S=(0,M.isLibrawMimeType)(n),P=a.dimensions,k=t??(0,y.map2Gt0)(P.width,P.height,((e,t)=>({width:Math.round(.9*e),height:Math.round(.9*t)})));if(null==k?.width||null==k?.height)return r.throw(e+" is not supported (missing dimensions)",{dim:k,doNotSend:!0,mimetype:n,isRaw:S,isVideo:g});const I=(0,C.aspectRatio)(a.fileDimensions),B=(0,h.lt)(I,1),z=(0,M.isSharpMimeType)(n)&&null==t,V=(0,E.orientationRequiresMirroring)(a.orientation);if(!0===i||g||B||z||V)r.debug("not pulling previews from tags",{isVideo:g,isFilePortrait:B,isSharpMimeAndNoMinDim:z,isMirrorOrientation:V});else{const i=!1,n=await(0,T.readRawTags)(e,i);if(null==n)r.warn("Cannot pull previews from tags: readRawTags() failed");else{const i=[..._.Settings.embeddedPreviews.values];null!=t&&(0,c.dmegapixels)(t)<1&&i.unshift(..._.Settings.embeddedThumbnails.values);const a=k.width*k.height*.2,u=k.width*k.height*.05,d=(0,l.sortBy)(i.filter((e=>n[e]instanceof s.BinaryField)),(e=>{const t=n[e]?.bytes;return(0,h.gt)(t,u)?Math.abs(t-a):void 0}));if(!(0,o.isEmpty)(d)){r.debug("checking previews from tags",{sizeSortedTagNames:d});for(const t of d)f("imgFromExif."+t,(()=>j(e,n,t,k,I)))}}}(0,M.isSharpMimeType)(n)&&f("sharp",(async()=>({file:e}))),(0,A.isHeifMimeType)(n)&&await(0,F.isHeifSupported)()&&f("heif",(()=>(0,w.thenMap)((0,F.heif2img)(e),(e=>({file:e}))))),S&&f("raw2tiff",(()=>(0,w.thenMap)((0,R.raw2tiff_)(e),(e=>({file:e}))))),g&&f("extractVideoFrame",(async()=>{if(await(0,L.isVideoSupported)())try{return await(0,w.thenMap)((0,L.extractVideoFrame_)(e),(e=>({file:e})))}catch(t){throw new b.WrappedError("Failed to extract video frame for "+e,t)}else r.warn("video file, but video support is missing",{src:e.nativePath,mimetype:n,minDim:t})}));const W=[];for(const i of d)try{const s=await(0,v.time)("img.read."+i.desc,i);if(null!=s)return r.debug(i.desc+" strategy succeeded",{src:e,minDim:t,rot:m,img:s.file?.nativePath}),{desc:i.desc,rot:m,mimetype:n,...s};r.debug(i.desc+" returned null",{src:e,minDim:t,rot:m})}catch(e){r.warn(i.desc+" failed",e),W.push((0,p.toErr)(e))}throw new b.WrappedError("Failed to render "+e,{causes:W,path:String(e),fatal:!1,doNotSend:!0,retriable:!1})}(e)))},t.extractImageForThumbs_=z},181:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.whyInvalidFile=t.clearInvalidFileCache=t.throwIfInvalidFile_=t.isValidFile=void 0;const s=r(i(9288)),n=i(19851),a=i(22573),o=i(42659),l=i(98553),u=i(50213),c=i(12089),d=i(81168),h=i(57159),f=i(88561),m=i(95696),p=i(17217),g=i(28874),y=i(16170),w=i(54979),v=i(63870),b=i(5733),S=i(50961),P=i(66106),_=i(51210),T=(0,n.lazy)((()=>(0,u.mkLogger)("img.ValidFile")));t.isValidFile=async function(e){return(0,a.blank)(await(0,t.whyInvalidFile)((0,p.toNativePath_)(e)))},t.throwIfInvalidFile_=async function(e){if(!g.Settings.validateJpegImages.valueOrDefault&&!g.Settings.validateRawImages.valueOrDefault&&!g.Settings.validateVideos.valueOrDefault)return void T().debug("file validation is disabled for "+e,{validateJpegImages:g.Settings.validateJpegImages.valueOrDefault,validateRawImages:g.Settings.validateRawImages.valueOrDefault,validateVideos:g.Settings.validateVideos.valueOrDefault});const i=(0,p.toNativePath_)(e),r=T().tap({msg:"whyInvalidFile("+i+")",result:await(0,t.whyInvalidFile)(i)});(0,a.notBlank)(r)&&T().throw(r,{path:i,retriable:!1,doNotSend:!0,ignorable:!0})};const M=(0,n.lazy)((()=>new f.FileCache({name:"img.validFile",maxSize:256,timeoutMs:Math.max(o.minuteMs,g.Settings.validateVideos.valueOrDefault?5*o.minuteMs:(0,v.commandTimeoutMs)())})));t.clearInvalidFileCache=function(){return M().clear()},t.whyInvalidFile=(0,c.shim1)({name:"img.whyInvalidFile",cache:M,toKey:p.toNativePath_,impl:async e=>{const t=m.PosixFile.for(e);if(!await t.isFile()||!await t.isReadable())return t+" is not a readable file";if(await t.isEmpty())return t+" is empty";try{const e=await(0,w.readMimeType)(t);if(null==e)throw new Error("Cannot validate, no mimetype");if((0,y.isVideoMimeType)(e))g.Settings.validateVideos.valueOrDefault&&(T().debug("validating "+t),await(0,P.validVideo_)(t));else{if(!e.startsWith("image/"))throw new Error("Unsupported mimetype "+(0,l.stringify)(e));if("image/jpeg"===e)g.Settings.validateJpegImages.valueOrDefault&&await(0,_.validJpeg_)(t);else if(g.Settings.validateRawImages.valueOrDefault)if((0,d.includesIgnoreCase)(g.Settings.validateMimetypeSkiplist.values,e))T().info("Skipping validation of "+t+": validateMimetypeSkiplist matches",{mime:e});else{const e=await(0,S.sharpReadable_)({src:t,skipEmbedded:!0}),i=await async function(e,t=g.Settings.imageFailOn.valueOrDefault){const i=e;if((0,p.isSimpleFile)(i.file))return(0,s.default)(i.file.nativePath,{failOn:t});if((0,b.isSharp)(i.sharp)){const{data:e,info:t}=await i.sharp.raw().toBuffer({resolveWithObject:!0});return(0,s.default)(e,{...t,failOnError:!0})}throw new Error("Cannot read input "+e?.desc)}(e);await i.tiff().toBuffer()}}return""}catch(t){return new h.WrappedError("Failed to validate",{cause:t,path:e,doNotSend:!0}).toS()}}})},19769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const r=i(19851),s=i(40958),n=i(41400),a=i(50213),o=i(68852),l=i(98314),u=i(28874),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:h().test(t)||!d().test(t),meta:{err:e,allow:h().test(t),block:d().test(t),validationErrorAllowlist:h().source,validationErrorBlocklist:d().source}})};const d=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),h=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,n.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>h.unset()))}))},66106:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const r=i(19851),s=i(40958),n=i(38639),a=i(42659),o=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),h=i(7282),f=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),w=i(56038),v=i(31562),b=i(34102),S=i(88561),P=i(95696),_=i(17217),T=i(31843),M=i(70417),E=i(33847),D=i(28874),x=i(94678),k=i(43207),C=i(47783),F=i(16170),A=i(95141),I=i(1078),O=i(63870),L=i(89782),R=i(13940),N=i(34592),B=(0,r.lazy)((()=>(0,d.mkLogger)("img.Video")));function j(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function z(e){return(0,h.isProd)()&&(e=void 0),(0,n.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=z,t.isVideoSupported=(0,r.lazy)((async()=>{try{return!0===(await z())?.isSupportedVersion}catch(e){return B().warn("isVideoSupported",{error:e}),!1}})),(0,o.later)((()=>(0,b.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,T.lerp2d)(e,{x:76800,y:D.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:D.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,r.lazy)((()=>new S.FileCache({name:"img.videoFrame",timeoutMs:a.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,_.toNativePath_)(e))):void 0}async function U(e,t){const i=j("extractVideoFrame",e),r=P.PosixFile.for(e);if(!(0,n.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const s=await(0,R.cachedImageFile_)(r,"frame",".jpg");i.debug("extractVideoFrame("+s+")");const o=await r.mtimeMs();if(null==o)return i.throw("null mtime");const l=await(0,C.readRawTags)(r,!1);if(null==l)return i.throw("no tags");const u=(0,A.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,I.extractSizeInfoFromTags)(l,u)?.dimensions,d=await s.stat(),h=null==d?void 0:await(0,L.dimensions)(s);if(null!=d&&d.mtimeMs>o&&null!=h&&(null==c||h.height===c.height&&h.width===c.width))return i.debug("prior dest, "+s+" seems reasonable",{srcDim:c,destDim:h}),s.nativePath;const f=(0,k.extractDurationSec)(l),m=Math.min(f??0,D.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:f}),await s.applyIfEmpty_({fn_:async e=>{const t={src:r,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,v.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*a.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,C.deleteAllTags_)(e,e)},timeoutMs:(0,O.commandTimeoutMs)()}),s.nativePath}async function q(){return D.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function H(e){const t=j("needsTranscoding",e);if(!await q())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,C.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const r=i.MIMEType;if(!(0,F.isVideoMimeType)(r))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:r}});const n=(0,k.extractDurationSec)(i);if(!(0,c.gt)(n,D.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:n}});const a=(0,s.compactBlanks)([i.AudioFormat]),o=a.some((e=>(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,s.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeMimeTypes.values,r);return t.tap({level:"info",msg:"result",result:!(o&&u&&d),meta:{mimetype:r,isSafeMimeType:d,audioCodecs:a,isSafeAudioCodec:o,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>U(e)}),t.__extractVideoFrame_=U,t.isVideoTranscodingSupported=q,t.needsTranscoding=H;const $=new g.TTLMap(a.hourMs);function G(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,r){if(!await q())return;const s=j("transcode",e);{!function(){for(const[e,t]of $.entries())t.isSettled&&$.delete(e)}();const t=$.get(e.nativePath)??$.get(i.nativePath);if(null!=t)return s.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await H(e))return void s.info("no transcoding needed");const n=await e.size();if(!(0,u.gt0)(n))return s.throw("source is empty or cannot read");const a=await(0,C.readTags)(e),o=(0,I.extractSizeInfoFromTags)(a),d=(0,k.extractDurationSec)(a);if(null==a||null==o||null==d)return s.throw("failed: missing video metadata",{sizeInfo:o,durationSec:d});{const e=$.get(i.nativePath);if(null!=e)return s.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const h=new y.Deferred("transcode "+e);$.set(e.nativePath,h),$.set(i.nativePath,h);const m=(0,u.toGt0)(a.VideoFrameRate)??(0,u.toGt0)(a.FrameRate)??30,p=Math.round(o.dimensions.width*o.dimensions.height*(0,M.max)([(0,u.toGt0)(a.FrameCount),(0,u.toGt0)(a.VideoFrameCount),m*d]));if(!0===r?.force)await i.unlink();else if(await async function(e,t){const i=await(0,C.readRawTags)(t),r=await(0,C.readRawTags)(e),s=(0,k.extractDurationSec)(r),n=(0,k.extractDurationSec)(i);return B().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(s,n,1.5),meta:{srcDurationSec:s,destDurationSec:n,src:e.nativePath,dest:t.nativePath}})}(e,i))return s.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const r=j("extractMaxBitrate",e),s=D.Settings.minVideoDimension.valueOrDefault,n=i.ImageWidth;if(null!=n&&!(0,u.gte)(n,s))return r.throw("invalid width: "+n,{ignorable:!0});const a=i.ImageHeight;if(null!=a&&!(0,u.gte)(a,s))return r.throw("invalid height: "+a,{ignorable:!0});const o=(0,x.extractBitrateKbps)(i)??D.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,f.mapGt0)(n,(e=>(0,f.mapGt0)(a,(i=>(0,u.clamp)(0,o,(0,t.bitrateKps)(e*i)))))),c={width:n,height:a,videoBitrateKbps:l};return r.debug("dim()",{src:e,result:c}),c}(e,a);return await h.observe((0,w.time)("video.transcode:"+e,(async()=>{const t=G(n,g.videoBitrateKbps,d);return await i.applyWip_({fn_:n=>async function(n){s.info("starting...",{destWip:n});const o=new E.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:n,fps:m,halt:r.halt,...g},h=D.Settings.transcodeMaxDim.valueOrDefault,f=(0,M.max)([a.dimensions.height,a.dimensions.width]);if((0,u.gt0)(h)&&(0,c.gt)(f,h)){const e=(0,l.fitInside)(a.dimensions,{width:h,height:h});null==e?s.warn("Cannot downsample transcoded video: fitInside() returned null",{input:a.dimensions,maxPixels:h}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),s.info("Downsampling transcoded video",{original:a.dimensions,output:e}))}const p=await o.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&s.throw("transcode failed with code "+p.code)}(n),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&s.info("transcode complete",{src:e,dest:i,elapsedMs:h.elapsedMs,pixels:p}),i},t.guessExpectedSize=G,t.validVideo_=async function(e){return null==await W(e)&&j("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),h=i(56519),f=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),w=i(84258),v=i(28874),b=i(76280),S=i(63870),P=i(19769),_=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function T(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:v.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=T;const M=/ffmpeg version n?(?\S+)/i,E=(0,u.lazy)((async()=>{const e=await T();if(null==e)return void _().info("failed to find ffmpeg in $PATH",{ffmpegPath:v.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,S.commandTimeoutMs)(),ignoreStderr:!0}),i=M.exec(t.result)?.[1];return _().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,b.semverSatisfies)(i,">=3.2")}}));function D(){E.unset(),t.ffmpegVersionDescription.unset()}function x(e){const t=e?.ffmpegHwaccel??v.Settings.ffmpegHwaccel.valueOrDefault;return(0,s.blank)(t)||(0,n.isDisabled)(t)?[]:["-hwaccel",t]}function k(e){const t=[...v.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(v.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),r=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+r),t}function C(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function F(e){const t=v.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,h.thenMapOr)(E(),(e=>"version "+e),(()=>"(not found)")))),(0,o.later)((()=>{(0,g.ee)().on("clearCache",D),(0,g.ee)().on("clearToolCache",D)})),t.ffmpegVersion_=async function(){return await E.prior()??E.refresh()},t.isFFmpegSupported=async function(){return null!=await E()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await T(),(0,r.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:a.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,f.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*a.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=k,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await T(),(0,r.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...k(t),...F(t),...x(t),"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),...C(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){_().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,w.unlink)(t.dest,"debug");const r=(0,p.errorToS)(i,{maxLen:1024});if(!(0,n.isDisabled)(t.ffmpegHwaccel??v.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(r))return _().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return _().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await T(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},51210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotate_=t.rotateInPlace_=t.validJpeg_=t.jpegtranVersion_=void 0;const r=i(19851),s=i(42659),n=i(21605),a=i(50213),o=i(84777),l=i(57159),u=i(95696),c=i(89966),d=i(43334),h=i(63870),f=i(19769),m=d.isWin?"NUL":"/dev/null",p=(0,r.lazy)((()=>(0,a.mkLogger)("img.jpegtran")));async function g(e,t,i){const r=await(0,c.jpegtranNativePath_)();if(!(0,n.isRotation)(i))throw new Error("refusing to rotate("+e+", "+i+")");await(0,o.stdout_)(r,["-copy","all","-trim","-rotate",i.toFixed(0),"-outfile",t.nativePath,e.nativePath],{timeoutMs:s.minuteMs}),t.clear()}t.jpegtranVersion_=async function(){const e=await(0,o.stdoutResult_)(await(0,c.jpegtranNativePath_)(),["-version"],{quiet:!0,timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:()=>!0});return(e.stderr??e.result).replace(/^libjpeg-turbo version/,"").trim()},t.validJpeg_=async function(e){const t=u.PosixFile.for(e),i=await(0,c.jpegtranNativePath_)();try{await(0,o.stdoutResult_)(i,["-outfile",m,t.nativePath],{timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:f.isIgnorableValidationError,ignoreExitCode:!0})}catch(e){throw p().warn("validJpeg caught invalid file",{src:t,cause:e}),new l.WrappedError("Invalid JPEG: "+t,{cause:e,path:t.nativePath,doNotSend:!0,fatal:!1,retriable:!1})}},t.rotateInPlace_=async function(e,t){p().info("rotateInPlace("+e+")",t),await e.applyWip_({fn_:i=>g(e,i,t),skipFsLock:!1,minSizeBytes:512,timeoutMs:s.minuteMs})},t.rotate_=g},19350:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dcraw_emu_=t.raw2tiff_=t.librawSupported=void 0;const r=i(19851),s=i(40958),n=i(33374),a=i(12168),o=i(23541),l=i(54993),u=i(50213),c=i(84777),d=i(98314),h=i(38835),f=i(57159),m=i(89966),p=i(28874),g=i(16170),y=i(54979),w=i(89782),v=i(13940),b=i(42725),S=i(19769),P=(0,r.lazy)((()=>(0,u.mkLogger)("img.libraw")));t.librawSupported=async function(e){try{return(0,g.isLibrawMimeType)(await(0,y.readMimeType)(e.nativePath))}catch(t){return P().warn("librawSupported("+e+"): failed to read filetype",t),!1}},t.raw2tiff_=async function(e){return(0,v.readableToFile_)({src:e,desc:"dcraw",suffix:".tiff",f:t=>D(e,t)})};const _=["-T"],T=["-Z","-"],M=["-o","1"],E=["-t","0","-j"];async function D(e,t){const i=await(0,w.dimensions)(e);if(null==i)return P().throw("Cannot decode RAW "+e+": no EXIF dimensions."+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);const r=b.ImageSize.largestFit().outputSize(i),u=[];null!=r&&4*(0,n.dmegapixels)(r)<(0,n.dmegapixels)(i)&&(P().debug("Large original source: using -h"),u.push("-h"));const g=await(0,m.dcrawEmuNativePath_)(),y=[..._,...T,...M,...u,...E,...p.Settings.dcrawEmuArgs.values,e.nativePath],v={encoding:"buffer",timeout:p.Settings.taskTimeoutMs.valueOrDefault,maxBuffer:250*a.MB};P().debug("dcraw_emu()",{cmd:g,args:y,opts:v});const D=(0,c.execFile)(g,y,void 0,v),x=[];function k(t){const i=(0,o.isError)(t)?(0,d.errorToS)(t):(0,l.toS)(t);if((0,S.isIgnorableValidationError)(i))P().info("dcraw_emu(): warning",{src:e,msg:i});else{P().warn("dcraw_emu(): error",{src:e,msg:i});const r=(0,o.isError)(t)?t:(0,f.toWrappedError)(i,{fatal:!1});x.push(r)}}if(D.on("error",k),D.stderr.on("data",k),await t.writeStream_(D.stdout),(0,s.isNotEmpty)(x))throw new f.WrappedError("Failed to convert RAW image "+e,{causes:x,path:e.nativePath});(0,c.endProcess)(D)}t.dcraw_emu_=D},36192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const r=i(19851),s=i(84777),n=i(8103),a=i(43334),o=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,r.lazy)((async()=>a.isMac?(0,n.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,s.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(o.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},71706:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.j=void 0;const r=i(38522);t.j=function(e){return JSON.parse((0,r.brotliDecompressSync)(Buffer.from(e,"base64")).toString("utf8"))}},42042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEmail=void 0;const r=i(22573),s=i(28874),n=i(81674);t.getEmail=async function(){const e=s.Settings.email.value;if((0,r.notBlank)(e))return e;for(const e of await(0,n.m)())if((0,r.notBlank)(e.l?.sub))return e.l?.sub}},83950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.L=void 0;const r=i(79114),s=i(40958),n=i(42659),a=i(34666),o=i(48884),l=i(97352),u=i(81674),c=i(84194);t.L=class{static for(e){return new this(e.str,e.l,e.sids,e.src)}constructor(e,t,i,r){this.s=e,this._l=t,this._sids=i,this.meta={src:r}}get l(){return this._l}get ok(){if(null==this._l)return!1;const e=(0,o.intersection)(this._sids,this._l.uids),t=(0,s.uniq)(e.map(c.getScheme)),i=(0,s.compact)(t.map((e=>(0,c.prefix2scheme)(e)))),r=i.length>=this._l.mat,a=(0,l.within)(this._l.iat?.getTime(),this._l.exp?.getTime()+n.dayMs,Date.now());return this.meta[(0,u.k)().o]=a,this.meta[(0,u.k)().u]=r,this.meta[(0,u.k)().m]=i,a&&r}cmpVal(){return[this.ok,-(r.S.indexOf(this.l?.[(0,u.k)().T])??0),this.l?.exp?.getTime()??1,this.meta.matchedSchemes]}cmp(e){return(0,a.cmp)(this.cmpVal(),e.cmpVal())}}},81674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p=t.l=t.t=t.b=t.m=t.vok=t.v=t.v_=t.k=void 0;const r=i(76790),s=i(22573),n=i(38639),a=i(45599),o=i(41400),l=i(96249),u=i(55835),c=i(31586),d=i(51926),h=i(79114),f=i(23541),m=i(59455),p=i(54993),g=i(72993),y=i(19851),w=i(50213),v=i(56519),b=i(76596),S=i(46292),P=i(87290),_=i(77740),T=i(34102),M=i(83278),E=i(28874),D=i(37692),x=i(71706),k=i(83950),C=i(72042),F=i(33603),A=i(48132);t.k=(0,y.rolazy)((()=>(0,x.j)("G1UBABwHdkz4hUIkFCfPXW5LlfvrWKSr9W3AIyIhUiw68NDfvLLHVop/bGoNnRxQlnqi2TZp0IJaX+lUHBoi+vMy2LMNpHCv8xVkUGsmQsgB8ldHoDqJeUQzbdybwikWVRs2KSWKjE5LnuqhTNSp3gTLhNfE9EqBLeaXP+UM9YqTGSXcyrcL03rIPMDAVyJplSZC0xoUgguOYJKvrcYFbNArN7BrQsnnsJ4hMtcSxOTxxRdxzETtL93qa3vjDw==")));const I=(0,a.defer)((()=>(0,w.mkLogger)((0,t.k)().l)));async function O(e){const i=await(0,C.V)((0,d.ensurePrefix)((0,p.toS)(e).trim(),(0,t.k)().p)),r=(0,b.utcIsoToTs)(i[(0,t.k)().i]);if(null==r)throw new Error("bad "+(0,t.k)().i+": "+i[(0,t.k)().i]+" ("+e+")");const s=(0,b.utcIsoToTs)(i[(0,t.k)().r]);if(null==s)throw new Error("bad "+(0,t.k)().r+": "+i[(0,t.k)().r]+" ("+e+")");return(0,_.getDevEnvFlag)((0,t.k)().y)&&(i[(0,t.k)().t]=!0),i[(0,t.k)().a]=(0,c.toGte0)(i[(0,t.k)().a])??2,i[(0,t.k)().i]=new Date(r),i[(0,t.k)().r]=new Date(s),i[(0,t.k)().b]=(0,p.toS)(i.uids).split(","),i}async function L(e,i,r,n){try{return(0,s.blank)(e)||e===(0,t.k)().f?void 0:k.L.for({str:e,l:await O(e),sids:null!=n?n:await(0,F.sids)({timeoutMs:r}),src:i})}catch(i){return I().tap({msg:(0,t.k)().v,result:{s:e,ok:!1,meta:{err:i}}})}}async function R(e,t){const i=[],r=await(0,v.sortByAsync)({name:"rawLicenseFromDir("+e+")",arr:e?.childFiles(),f:e=>e.mtimeMs()});for(const e of r.reverse()){const r=await L((0,m.toA)(await e.readLines()).map((e=>e.trim())).join(""),e.nativePath,A.UserTimeoutMs,t);null!=r&&i.push(r)}return i}async function N(){const e=await(0,t.m)();return e[0]?.ok?e[0]:void 0}async function B(){return(await N())?.l?.[(0,t.k)().T]??(0,t.k)().f}t.v_=O,t.v=L,t.vok=async function(e,t,i){if((0,s.blank)(e))return;const r=await L(e,t,i);return(0,n.isTrue)(r?.ok)&&r instanceof k.L?r:void 0},t.m=(0,y.rolazy)((async()=>{if((0,_.getDevEnvFlag)((0,t.k)().x))return[];const e=await(0,F.sids)({timeoutMs:A.UserTimeoutMs}),i=(0,u.map)((0,S.configDir)(),(e=>M.BaseFile.for(e))),s=(n=(0,l.flatten)((await(0,v.someOrTimeout)([()=>function(e){return L(E.Settings[(0,t.k)().L].value,"Settings",A.UserTimeoutMs,e)}(e),()=>R(i?.join((0,t.k)().d),e),()=>R((0,P.libraryDataDirPosixFile)()?.join((0,t.k)().d),e),()=>R(i?.sibling((0,g.AppName)().toLowerCase()).join((0,t.k)().d),e)],{timeoutMs:A.UserTimeoutMs})).filter((e=>!(e instanceof Error)))),(0,r.sortBy)(n.filter((e=>null!=e&&((0,f.isError)(e)&&I().warn((0,t.k)().d+": ",e),null!=e&&!(0,f.isError)(e)&&null!=e?.l))),(e=>[!e.ok,h.S.indexOf(e.l?.[(0,t.k)().T])??h.S.length+1,-(e.l?.exp?.getTime()??1)])));var n;return I().tap({msg:(0,t.k)().d+"()",result:s})})),(0,o.later)((()=>{(0,T.ee)().on("clearCache",(()=>t.m.unset())),(0,T.ee)().on((0,t.k)().c,(()=>t.m.unset())),D.stateEvents.on((0,t.k)().c,(()=>t.m.unset()))})),t.b=N,t.t=B,t.l=async function(){try{return await B()===(0,t.k)().f}catch{return!0}},t.p=async function(){try{return await B()===(0,t.k)().g}catch{return!1}}},72042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.V=t.l=void 0;const r=i(91227),s=i(19851),n=i(22573),a=i(71706);t.l=(0,s.lazy)((()=>(0,a.j)("G54BgBwHzrkukKDR8Ar6KkW29gbXlfrqQX46gTu5Wfq6dELYTjfBokB0d5+E2SAINBtxlmPquWe3PMUoNgaJrD982QMslkNeZ4BEqcBbQT59DVl9RnoTNi50diuT7NQg0YHxkr8SwDwtmFUOf+LwNVDDnPXUrzTOU++M3b+lcyfr7PXZndKHzho8iztNkZgt+/19//aXe+gvmC0HIdnn64wdLeYeLM7S9jmjTp52SzFsvIVbd4D0+rdtdjiz6R4vc2cmY398kuXiKG7fNXWS/I93etxXiVNPd4RXJF+k6JnuMUKk03GWHQQ="))),t.V=function(e){const i=(0,r.decode)(e).payload;if(null==i)throw new Error("Missing payload");const s=(0,n.notBlankOr)(i.k,(0,t.l)().d),a=(0,t.l)().o.find((e=>e.k===s));if(null==a)throw new Error("Unknown key");return r.V2.verify(e,a)}},84194:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SchemeCounts=t.isValidUid=t.toUID=t.UidLength=t.prefix2scheme=t.sortUids=t.getScheme=t.S=void 0;const n=i(40958),a=i(76790),o=i(22573),l=i(45599),u=i(50989),c=i(54993),d=i(22454),h=i(19851),f=i(50213),m=i(37628),p=i(55222),g=i(71706),y=(0,l.defer)((()=>(0,g.j)("GyABAIzUYs0Z7mSuLfVL1SwGefr+3nCwyXBMg6nD0qduA8HycFjUGK1N/ikYqhiqYLGbs7oxTBbzRPxteP9gA3L9DS0EJ2BJ1pYNa/DtEE2aPI2o03hHx3k9MhdE7jAeRUvKQ6tY3Q1fcIPe8GBMZvOeKibTymyo3Cw/7Ua42DKPjpL3wxWv+7TCGA==")));function w(e){const i=e.split(":",1)[0];return t.S.has(i)?i:void 0}t.S=(0,u.strEnum)("cu","lc","lm","lp","lb","mp","ms","wm","cm","bm","nm","li","si","vl"),t.getScheme=w,t.sortUids=function(e){return(0,a.sortBy)((0,n.uniq)(e.filter(S)),(e=>[t.S.indexOf(w(e))??t.S.length+1,e]))},t.prefix2scheme=function(e){return y()[e]};const v=["uninitialized","b08dfa6083e7567a1921a715000001fb"];t.UidLength=15,t.toUID=function(e,i){try{const r=(0,c.toS)(i).replace(/[^a-z\d=/+]+/gi,"");return(0,o.blank)(r)||v.includes(r.toLowerCase())||null!=r.match(/^[\s0:_/-]*$/)?void 0:e+":"+(0,m.shortStringSha)(r,t.UidLength,p.Radix58)}catch(t){return void(0,f.mkLogger)("toUID").warn("failed",{pfx:e,err:t})}};const b=(0,l.defer)((()=>new RegExp(`^(?:${t.S.values.join("|")}):[0-9a-zA-Z]{${t.UidLength}}$`)));function S(e){return null!=e&&null!=b().exec(e)}t.isValidUid=S,t.SchemeCounts=class{constructor(e){r.set(this,new Set),this.schemeCounts=(0,h.lazy)((()=>{const e=new d.CountingSet;for(const t of s(this,r,"f")){const i=w(t);null!=i&&e.incr(i)}return e})),null!=e&&this.addUids(e)}get size(){return s(this,r,"f").size}addUids(e){for(const t of e)null==w(t)||s(this,r,"f").has(t)||(s(this,r,"f").add(t),this.schemeCounts.unset())}count(e){return this.schemeCounts().get(e)}},r=new WeakMap},33603:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearSids=t.addSids=t.sids=t.win_machineGuid_=t.readInfo=t.k=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(45599),o=i(96249),l=i(68708),u=i(51926),c=i(59455),d=i(54993),h=i(50213),f=i(7282),m=i(56519),p=i(84777),g=i(84542),y=i(19254),w=i(45879),v=i(70854),b=i(57902),S=i(72308),P=i(43334),_=i(24399),T=i(7014),M=i(30933),E=i(71706),D=i(84194);t.k=(0,a.defer)((()=>(0,E.j)("G9ABYIzDOIZ8NLQ4t7qW8tNrmrOzz+qFGfAxl8jW4E2tLxwWRZT5TueCnPcwgTzT1DN3veRB+e7EYGlYHg6nhjBDQv7zI6EcYWk35z6QuZC3Q0itjrLCbmgd0iED0BvGiYLBJwRU1O9/3Agbl8IfG6ITVFWDRwyTw3rbUMo/XMyAVW7R23mkwUx0l4/7iA13RV/nmPuJFKp5BvJW7SoXJZoWEfdSNYYhN5UCtkbC7O1AaPIbU3P6uRLmEyb4TaHWzFigvrlmZVUzzp9j/Mz55vqN88ewd1Nrfh7gkVRQ7TtB7Ztz3XJxYC3ogdJHg8HGsG4=")));const x=(0,a.defer)((()=>(0,h.mkLogger)((0,t.k)().n)));async function k(e=(0,t.k)().pc){if(P.isLinux)try{const t=await(0,y.fileGrep_)(e,/^\s*(?:hardware|revision|serial|model)\s*[:=]\s*[a-z\d]{6}.*$/i),i=(0,r.compactBlanks)((0,g.splitLines)(t).map((e=>e.replace(/\s+/g," ")))).sort();return i.some((e=>null!=e.match(/^serial/i)))?i:void 0}catch{return}}t.readInfo=k;const C=(0,a.defer)((()=>(0,m.thenMap)(k(),(e=>(0,D.toUID)(D.S.lc,e.join(",")))))),F=/o\.e\.m\./i;async function A(e){return(0,r.uniq)(await Promise.all((0,t.k)()[e].map((e=>(0,w.readFileMaybe)(e,b.LogLevels.trace))))).map(d.toS).filter((e=>(0,s.notBlank)(e)&&null==e.match(F)))}async function I(){return P.isLinux?(await A("lm")).map((e=>(0,D.toUID)(D.S.lm,e))):void 0}async function O(){return P.isLinux?(await A("lp")).map((e=>(0,D.toUID)(D.S.lp,e))):void 0}async function L(){return P.isLinux?(await A("lb")).map((e=>(0,D.toUID)(D.S.lb,e))):void 0}async function R(){if(P.isMac)try{return(0,l.entries)(await async function(){const e=await(0,p.stdout_)((0,t.k)().i,(0,t.k)().ia,{timeoutMs:5*n.secondMs}),i=e.match(/uuid" = "([a-z\d-]{12,})"/i)?.[1],r=e.match(/SerialNumber" = "([a-z\d-]{10,})"/i)?.[1];return{mp:i,ms:r}}()).map((([e,t])=>(0,D.toUID)(e,t)))}catch(e){return void x().warn((0,t.k)().i+" failed",e)}}async function N(){return(await _.PowerShell.instance().executeJson((0,t.k)().w))?.MachineGuid}async function B(){return P.isWin?(0,D.toUID)(D.S.wm,await N()):void 0}t.win_machineGuid_=N;const j=(0,a.defer)((()=>(0,D.toUID)(D.S.cm,(0,M.cpuInfo)()[0].model)));async function z(){return P.isLinux?(0,D.toUID)(D.S.bm,(0,r.compactBlanks)(await A("bm")).map((e=>e.trim())).join("\n")):[]}async function V(){return(0,D.toUID)(D.S.li,await((0,v.LibraryUIDStore)()?.readUid_()))}async function W(){return(0,D.toUID)(D.S.si,await((0,v.SystemUIDStore)()?.readUid_()))}function U(){return(0,S.networkMacAddresses)().map((e=>(0,D.toUID)(D.S.nm,e)))}async function q(){return(0,c.toA)(await(0,T.volumes)()).map((e=>(0,D.toUID)(D.S.vl,e.uuid)))}const H=new Set;t.sids=async function({timeoutMs:e}){const t=Date.now(),i=[j,C,R,V,W,z,I,O,L,B,U,q],r=(0,o.flatten)(await(0,m.someOrTimeout)(i,{timeoutMs:e})).filter(u.isString);for(const e of r)H.add(e);return x().tap({msg:"sids()",result:(0,D.sortUids)([...H,...r]),meta:{timeoutMs:e,elapsedMs:Date.now()-t}})},t.addSids=function(e){if((0,f.isTest)())for(const t of e)H.add(t)},t.clearSids=function(){(0,f.isTest)()&&H.clear()}},48132:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserTimeoutMs=void 0;const r=i(42659);t.UserTimeoutMs=7*r.secondMs},34474:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allRecentLogEntries=t.recentLogFiles=void 0;const r=i(40958),s=i(42659),n=i(41400),a=i(96249),o=i(68708),l=i(34666),u=i(20214),c=i(71371),d=i(50213),h=i(42638),f=i(31562),m=i(98314),p=i(89968),g=i(28874),y=i(4904),w=i(57902),v=i(89241),b=i(83954);function S(e=10*s.minuteMs){const t=Date.now()-e;return(0,u.thenMap)(p.DirectoryEntry.for(g.Settings.logDir.valueOrDefault),(e=>e.filterDescendantFiles((async e=>[".log",".log.gz"].includes(e.ext)&&(0,l.gte)(e.mtimeMs(),t)))))}t.recentLogFiles=S,t.allRecentLogEntries=async function(e=50){(0,b.writeRecentLogEntries)();const t=(0,o.fromEntries)(w.LogLevels.values.map((t=>[t,new c.BoundedGreatestSet(e,y.logEntrySorter)]))),i=Date.now()-s.hourMs,p=(0,d.mkLogger)("allRecentLogEntries()");return await(0,u.thenMap)(S(),(e=>(0,h.withBoundedConcurrency)({name:"allRecentLogEntries()",laters:e.map((e=>async()=>{try{const a=[],o=new v.LogReader(e,(e=>a.push(e)));for(await(0,f.untilTrue)((()=>o.ready()),{timeoutMs:10*s.secondMs});!o.complete()&&!o.hasErrors();){const e=o.shift();null==e?await(0,n.delay)(5):e.ts>i&&t[e.l]?.add(e)}(0,r.isNotEmpty)(a)&&(p.warn("Read error(s) for "+e,a),a.some((e=>"Z_BUF_ERROR"===e.code||(0,m.errorToS)(e).includes("unexpected end of file")))&&(0,l.lt)(e.mtimeMs(),Date.now()-s.minuteMs)&&(p.warn("Unlinking corrupt logfile "+e),await e.unlink_()))}catch(t){p.warn("Failed to read entries from "+e,t)}}))}))),(0,a.flatten)((0,o.values)(t).map((e=>e.vacuum()))).sort(((e,t)=>(0,l.cmp)(e.ts,t.ts)))}},49794:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),s=i(19851),n=i(40958),a=i(22573),o=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,s.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,a.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,n.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),s=i(23560),n=i(66184),a=i(72210);class o{log(e,t,i,r){this.enabled(e,t)&&(0,a.pushLogEntries)({ts:Date.now(),l:e,from:(0,s.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,n.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=o,o.instance=(0,r.lazy)((()=>new o))},14593:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),s=i(22573),n=i(26905),a=i(55835),o=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,s.toNotBlank)(e)??(0,n.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,o.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),s=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:s}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,a.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,o.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),s=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof s.LogWriter))}},28981:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),s=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new s.PlaintextLogFormatter))},31256:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(41400),o=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function w(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,n.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,a.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,s.uniq)((0,s.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,o.stringify)({...t,...w(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,o.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const n=i(77030),a=i(19851),o=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),w=i(31256),v=i(28538),b=(0,a.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),S=String.fromCharCode(0);t.logBroadcaster=(0,a.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,o.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&b().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new w.GelfLogFormatter,this.logFilter=new v.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,n.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{b().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){b().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),s(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,n){if(this.enabled(e,t))try{const a=this.socket;null==a?s(this,r,"f").call(this):a.write(this.logFormatter.format(e,t,i,n)+S)}catch(r){b().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:n,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),s=i(42659),n=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??n.Settings.logDir.valueOrDefault,(0,s.fmtIsoDate)(t??new Date))}},4904:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),s=i(31586),n=i(51926),a=i(57902);t.isLogEntry=function(e){return null!=e&&(0,s.isNumber)(e?.ts)&&(0,n.isString)(e?.msg)&&a.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),s=i(57902);class n{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,s.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,s.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=n,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new n(s.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>s.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,s.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,s.set(this,[]),n.set(this,(0,l.lazy)((()=>{o(this,s,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:o(this,s,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>o(this,n,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=o(this,r,"m",a).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=o(this,r,"m",a).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){if(null==e||0===o(this,s,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return o(this,s,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),s=i(31586),n=i(50989);t.LogLevels=(0,n.strEnum)("fatal","error","warn","info","debug","trace");const a=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??a},t.levelGte=function(e,i){return(0,s.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const o=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return o.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),s=i(68708),n=i(20214),a=i(51926),o=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,a.isString)(i)||Buffer.isBuffer(i))return(0,a.ellipsize)(i.toString(),256,32);if((0,o.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,n.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const o=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,s.keys)(i),(0,s.keys)(o));return(0,r.isNotEmpty)(c)&&(o["…"]="omitted: "+(0,a.ellipsize)(c.join(", "),128,32)),o}return i}},89241:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogReader=void 0;const d=i(73024),h=i(38522),f=i(4001),m=i(14977),p=i(33456),g=i(92322),y=i(4904),w=i(98192);t.LogReader=class{constructor(e,t){if(r.add(this),this.f=e,this.start=Date.now(),this.lines=new g.SortedSet(y.logEntrySorter),s.set(this,!1),n.set(this,!1),a.set(this,!1),this.from=(0,f.stripCopySuffixFromName)(e.name),this.fileStream=(0,d.createReadStream)(e.nativePath,{autoClose:!0}),!(0,m.isExtOrCompressedExt)(e.ext,".log"))throw new Error(e+" is not a logfile");this.stream=(e.ext.toLowerCase().endsWith(".gz")?this.fileStream.pipe((0,h.createGunzip)()):e.ext.toLowerCase().endsWith(".br")?this.fileStream.pipe((0,h.createBrotliDecompress)()):this.fileStream).pipe(new p.LineReader).on("error",(e=>{t(e),u(this,a,!0,"f")})),this.stream.on("data",c(this,r,"m",o).bind(this)),this.stream.on("close",(()=>{this.fileStream.resume(),u(this,s,!0,"f")})),this.stream.on("end",(()=>{u(this,s,!0,"f")}))}toString(){return"LogReader("+this.f.nativePath+")"}status(){return{hasErrors:c(this,a,"f"),ended:c(this,s,"f"),destroyed:this.stream.destroyed,lines:this.lines.length,paused:c(this,n,"f")}}hasErrors(){return c(this,a,"f")}get ended(){return c(this,s,"f")}ready(){return this.ended||this.lines.length>32}complete(){return this.ended&&0===this.lines.length}peek(){return this.ready()?this.lines.at(0):void 0}shift(){const e=this.lines.shift();return null!=e&&c(this,r,"m",l).call(this),e}shiftLte(e){const t=this.lines.shiftLte(e);return t.length>0&&c(this,r,"m",l).call(this),t}},s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e){if(null===e)u(this,s,!0,"f");else{const t=(0,w.chunkToLogEntry)(e);null!=t&&this.lines.add({...t,from:this.from}),this.lines.length>10240&&!c(this,n,"f")&&(this.fileStream.pause(),u(this,n,!0,"f"))}},l=function(){this.lines.length<1024&&c(this,n,"f")&&(this.fileStream.resume(),u(this,n,!1,"f"))}},24068:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),s=i(76760),n=i(1708),a=i(87997),o=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),w=i(22277),v=i(25764),b=i(38836),S=i(99331),P=i(42638),_=i(76596),T=i(98314),M=i(89968),E=i(29882),D=i(28874),x=i(28981),k=i(20839),C=i(21727),F=i(66184),A=i(57902),I=i(72210),O=i(98192);function L(e){const t=(0,x.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=L;class R extends b.EndableWrapper{constructor(e=void 0,t=L){super("LogTail",(()=>this.close()),v.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new w.TTLSet(5*u.secondMs),this.setup=(0,o.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,D.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,E.mkdirp_)(e),this.root=await M.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=s.sep+(0,p.serviceName)()+"-"+n.pid+"-",n.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,a.setInterval)((()=>this.flush()),k.DefaultLogFlushMs/2),this.scanTimeout=(0,a.setInterval)((()=>this.scan()),u.minuteMs),n.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,S.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,F.ifLog)(A.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,s.join)(e,i))}))}catch(t){return void(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,T.errorToS)(t))))}}))}async scan(e=!1){if((0,S.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,_.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,S.ending)()||this.ended)return;const t=(0,C.datedLogDir)(this.root.nativePath);try{await(0,E.mkdirp_)(t),this.watchDir(t)}catch(e){(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,T.errorToS)(e))))}(0,S.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,a.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,a.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await M.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(r,i))return;await(0,f.thenMap)((0,O.readLogEntries)(e,{start:r,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,T.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,o.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),s=i(82328),n=i(28981),a=i(20839),o=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(o.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,s.stdoutEnded)()||console.log((0,n.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*a.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),w=i(31586),v=i(409),b=i(23560),S=i(81168),P=i(78406),_=i(25764),T=i(20197),M=i(14977),E=i(36868),D=i(28874),x=i(32105),k=i(20839),C=i(21727),F=i(66184),A=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class O extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*k.DefaultLogFlushMs),rank:_.EndableRanks.logger,unref:!0,onEnd:()=>c(this,s,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,s.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:x.ConsoleLogger.instance(),flushEveryMs:k.DefaultLogFlushMs,processName:b.processName,logFilter:F.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,v.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",n).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const s={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(s.meta=(0,A.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(s)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=O,s=new WeakMap,r=new WeakSet,n=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,w.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),s=e.splice(0,i);this._linesSinceRotate+=s.length,t.write(s.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},a=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},o=function(e){return t=>(c(this,r,"m",a).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,S.stripAnsiEsc)(this.logOpts.processName()),t=await(0,T.ensureNewNativePath_)({nativePath:(0,f.join)((0,C.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,r,"m",o).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,E.endStream)(e.stream),D.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,M.gzip_)(e.nativePath))}catch(e){c(this,r,"m",a).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(68708),o=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,a.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,s.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,n.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),s=i(84542),n=i(4001),a=i(13047),o=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,o.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,n.stripCopySuffixFromName)(e.name),r=[],o=await(0,a.zcat)(e.nativePath,t);if(null!=o)for(const e of(0,s.splitLines)(o)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),s=i(76790),n=i(68708),a=i(89788),o=i(57902);t.SentLogLevels=(0,r.lazy)((()=>o.LogLevels.values.filter((e=>e!==o.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,n.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new a.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,n.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,n.values)(l()))e.push(...t.toA());return(0,s.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),s=i(41400),n=i(55835),a=i(37975),o=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),w=i(66184),v=i(28538),b=i(24068),S=i(43705),P=i(51879);function _(){(0,w.logFilter)()instanceof v.LogFilterImpl||w.logFilter.set(new v.LogFilterImpl),T();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new S.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,n.map)((0,y.logBroadcaster)(),(e=>i.push(e))),o.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&b.LogTail.instance()}function T(){const e=h.Settings.logColor.valueOrDefault;(0,a.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=_,t.setupLogFormatter=T,(0,s.later)((()=>{h.Settings.logStdout.watchLater(_),h.Settings.logDir.watchLater(_),h.Settings.tailLogs.watchLater(_),h.Settings.logColor.watchLater(T),h.Settings.logLevel.watchLater((()=>w.defaultLogLevel.unset()))}))},83954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeRecentLogEntries=void 0;const r=i(89179);t.writeRecentLogEntries=function(){return(0,r.currentFileLogger)()?.writeRecentLogEntries()}},82647:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const a=i(57975),o=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,a.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return n(this,r,"m",s).call(this,-1)}get p29(){return n(this,r,"m",s).call(this,-.5)}get p38(){return n(this,r,"m",s).call(this,-.25)}get p69(){return n(this,r,"m",s).call(this,.5)}get p84(){return n(this,r,"m",s).call(this,1)}get p98(){return n(this,r,"m",s).call(this,2)}get p99(){return n(this,r,"m",s).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,o.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,o.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,o.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,s=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),s=i(55835),n=i(31586),a=i(30976),o=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,n.clamp)(0,i,(0,n.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,s.map2)(e,t,((e,t)=>(0,r.sum)((0,o.zip)(u(e,i),u(t,i)),(([e,t])=>(0,n.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,n.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,a.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),s=this.clampValue(e);let n=0;for(let e=0;ea?(n+=1,i[t]=a):r[t]=a}return n}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let s=0;s(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,n.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;in?(t+=1,s.min=n):s.max=n}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},44983:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.kmeans=void 0;const r=i(76790),s=i(93973);t.kmeans=function(e,t,i){const n=s(e,t,i);return{...n,centroids:(0,r.sortBy)(n.centroids.filter((e=>e.size>0)),(e=>-e.size))}}},31843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const r=i(76790);function s(e,t,i=.5){return(1-i)*e+i*t}t.lerp=s,t.lerp2d=function(e,...t){const i=(0,r.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[n,a]=(0,r.sortBy)(i,(e=>e.x)),o=a.x-n.x,l=(e-n.x)/o;return s(n.y,a.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},75503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modeReduce=t.submatrixCollect=t.greatestHalf=t.leastVariantQuarter=t.leastMagQuarter=t.submatrixMode=t.submatrixStdDev=t.submatrixMagnitude=t.submatrixForEach=t.index1D=t.slice=t.matXvec=t.vecXvec=void 0;const r=i(40958),s=i(31586),n=i(48884),a=i(82647),o=i(70417);function l(e,t,i,r){const s=Math.floor(Math.max(0,t.row)),n=Math.ceil(Math.min(e.row,i.row)),a=Math.floor(Math.max(0,t.col)),o=Math.ceil(Math.min(e.col,i.col));for(let t=s;t(0,s.mapFinite)(e[t],(e=>n+=e*e)))),Math.sqrt(n)}function c(e,t,i,r){const n=new a.Average;return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),n.stdDev}function d(e,t,i,r){const n=[];return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),(0,o.mode)(n)}t.vecXvec=function(e,t){return e.map(((e,i)=>e*t[i]))},t.matXvec=function(e,t){return e.map(((e,i)=>{if(e.length!==t.length)throw new Error("misshaped matrix on row "+i);return(0,o.sumf)(e,((e,i)=>e*t[i]))}))},t.slice=function(e,t,i){const s=Math.max(0,t.row),n=Math.min(e.length,i.row),a=Math.max(0,t.col),o=Math.min(e[0].length,i.col);return(0,r.range)(s,n,(t=>e[t].slice(a,o)))},t.index1D=function(e,t,i){return t*e.col+i},t.submatrixForEach=l,t.submatrixMagnitude=u,t.submatrixStdDev=c,t.submatrixMode=d,t.leastMagQuarter=function(e,t){const i=t.col,r=t.row,s=[u(e,t,{col:i/2,row:0},{col:i,row:r/2}),u(e,t,{col:0,row:0},{col:i/2,row:r/2}),u(e,t,{col:0,row:r/2},{col:i/2,row:r}),u(e,t,{col:i/2,row:r/2},{col:i,row:r})];return(0,n.leastIndex)(s)},t.leastVariantQuarter=function(e,t){const i=t.col,r=t.row;return(0,n.leastIndex)([c(e,t,{col:i/2,row:0},{col:i,row:r/2}),c(e,t,{col:0,row:0},{col:i/2,row:r/2}),c(e,t,{col:0,row:r/2},{col:i/2,row:r}),c(e,t,{col:i/2,row:r/2},{col:i,row:r})])},t.greatestHalf=function(e,t){const i=t.col,r=t.row,s=[d(e,t,{col:0,row:0},{col:i,row:r/2}),d(e,t,{col:0,row:0},{col:i/2,row:r}),d(e,t,{col:0,row:r/2},{col:i,row:r}),d(e,t,{col:i/2,row:0},{col:i,row:r})];return(0,n.greatestIndex)(s)},t.submatrixCollect=function(e,t,i){const r=[];return l(e,t,i,(e=>r.push(e))),r},t.modeReduce=function(e,t,i){const o=Math.floor(t.col/i.col),u=Math.floor(t.row/i.row),c=new a.Average(Math.ceil(o*u));return(0,n.concat)(...(0,r.stepRange)(0,t.row,u,(i=>(0,r.stepRange)(0,t.col,o,(r=>(c.clear(),l(t,{col:r,row:i},{col:r+o,row:i+u},(t=>(0,s.mapFinite)(e[t],(e=>c.push(e))))),c.sampleMode))))))}},36372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stableContentShuffle=t.stableIndexShuffle=t.factors=t.primeSeeds=t.primeInt=t.primes=t.prng=t.prngOrderByClause=void 0;const r=i(76790),s=i(42659),n=i(31586),a=i(97238),o=i(50597),l=i(9103),u=i(55222);function c(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e),u=(s*i*i+n*i)%r,c=(a*i+o)%r;return Math.round((u*c+l)%r)}function d(e){return(0,u.encodeDigits)(a.PrimesPerBin,e,a.PrimeBins).map(((e,i)=>t.primes[i][e]))}t.prngOrderByClause=function(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e);return`(((${s}*${i}*${i}+${n}*${i})%${r})*((${a}*${i}+${o})%${r})+${l})%${r}`},t.prng=c,t.primes=[[353868013,472882027,479001599,517294153],[1012573,1230587,1355297,1572751],[756065159,812182027,899809343,989450477],[3959297,4514113,4823201,5133127],[573259391,666101999,694847533,746151647],[2275327,2770513,3073703,3511973],[173313197,182557181,203457869,222230231],[6054613,6189107,7752103,9852103]],t.primeInt=[1012573,1101689,1183811,1196089,1230587,1355297,1419641,1483733,1572751,2275327,2770513,3010349,3073703,3118691,3174823,3511973,3959297,4514113,4690451,4823201,5133127,5375327,6019889,6054613,6189107,7752103,7752103,9852103],t.primeSeeds=d,t.factors=(0,l.memoize)((e=>{const[i,r,s,o,l,u,c,h]=d(e%a.SeedCount),f=[i/r,s/o,l/u,c/h].map((e=>(0,n.sigFigs)(e,7)));return f.push(t.primeInt[e%t.primeInt.length]),f}),{maxSize:128,ttlMs:s.minuteMs}),t.stableIndexShuffle=function(e,t=1){return(0,r.sortBy)(e,((i,r)=>c(t,r,e.length)))},t.stableContentShuffle=function(e,t=1){return(0,r.sortBy)(e,(e=>(0,o.numericSha)(String(e)+t)))}},55222:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),s=i(22573),n=i(55835),a=i(32639),o=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,n.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,s.blank)(e))return;const t="-"===(e=(0,a.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),s=this.normalizeToken(t);return r.length>=i&&r===s}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const r=i(31586),s=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,r.toInt)(e)]??(0,s.toS)(e)}},38812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SquareMatrix=t.rotateSquareMatrix=void 0;const r=i(21605);t.rotateSquareMatrix=function(e,t){return 0===(0,r.normalizeRotation)(t)?e:new s([...e]).rotate(t).m};class s{constructor(e,t=1){if(this.m=e,this.ary=t,this.rows=Math.sqrt(e.length/t),this.rows!==Math.floor(this.rows))throw new Error(`Only square tuple matrices are supported: ${1===this.ary?"":this.ary}(${this.rows}×${this.rows}) != ${e.length}`)}index(e,t){return this.ary*(t+e*this.rows)}swap(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),s=i(65713);function n(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=n,t.safeUUID=function(){return(0,s.decuss)(n)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const o=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function w(e,t){let i=0,r=0;for(const s of e){if(null!=s){const e=t(s,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=w;class v{constructor(){r.set(this,0),s.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(a(this,s,null==n(this,s,"f")?e:n(this,s,"f")*n(this,r,"f")/(n(this,r,"f")+1)+e/(n(this,r,"f")+1),"f"),a(this,r,(t=n(this,r,"f"),++t),"f"))}get mean(){return n(this,s,"f")}}function b(e){const t=new v;for(const i of e)t.push(i);return t.mean}function S(e){const t=b(e);if(null==t)return;let i=0,r=0;for(const s of e)(0,u.isNumber)(s)&&(r++,i+=(s-t)*(s-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function _(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+a*(e-s)/n)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=b(t);if(null!=i){const e=(t.length-1)/2,r=w(t,((t,r)=>(t-i)*(r-e))),s=w(t,(e=>(e-i)**2));return 0===s?0:r/s}},t.variance=S,t.stdDev=function(e){return(0,l.map)(S(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,o.isEmpty)(e)&&(0,o.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},23624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64encodeBits=t.b64hammRatio=t.gz64decodeString=t.d=t.gz64encodeString=t.b64decode=t.b64encode=t.hex2b64=void 0;const r=i(38522),s=i(22573),n=i(97352);function a(e){const t=e.toString(16),i=t.length%2==0?"":"0";return Buffer.from(i+t,"hex").toString("base64")}function o(e){return BigInt("0x0"+Buffer.from(e,"base64").toString("hex"))}function l(e){return(0,r.gunzipSync)(Buffer.from(e,"base64")).toString("utf8")}t.hex2b64=function(e){return Buffer.from(e,"hex").toString("base64")},t.b64encode=a,t.b64decode=o,t.gz64encodeString=function(e){return(0,r.gzipSync)(Buffer.from(e,"utf8")).toString("base64")},t.d=l,t.gz64decodeString=l,t.b64hammRatio=function(e,t){return(0,s.mapNotBlank)(e,(e=>(0,s.mapNotBlank)(t,(t=>(0,n.hammRatioBigInt)(o(e),o(t))))))},t.b64encodeBits=function(e){return a(BigInt("0b0"+e.map((e=>1===e?"1":"0")).join("")))}},49076:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const s=r(i(48161)),n=i(19851),a=i(22573),o=i(41400),l=i(81168),u=i(28874);t.hostname=(0,n.lazy)((()=>u.Settings.hostname.value??s.default.hostname())),(0,o.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,a.blank)(e)&&!(0,a.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??s.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},43205:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemUserAgent=t.simpleUserAgent=t.userAgent=void 0;const r=i(72993),s=i(17344),n=i(96175),a=i(37805),o=i(81674),l=i(28874);function u(){return r.SimpleAppName+a.version}async function c(){return u()+" ("+(0,n.osFullName)()+") "+(0,s.EditionType)().toLowerCase()+"/"+await(0,o.t)()}t.userAgent=async function(){return l.Settings.allowUserAgent.valueOrDefault?c():u()},t.simpleUserAgent=u,t.systemUserAgent=c},72308:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLocalhost=t.isLoopback=t.myExternalIp4Addresses=t.myExternalIpAddresses=t.networkMacAddresses=t.myIpAddresses=void 0;const r=i(48161),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(96249),u=i(31586),c=i(68708),d=i(50213),h=i(81168);function f(){return(0,t.myIpAddresses)().filter((e=>!g(e)))}t.myIpAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.address))))),o.minuteMs),t.networkMacAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.mac)))).filter((e=>"00:00:00:00:00:00"!==e))),o.minuteMs),t.myExternalIpAddresses=f,t.myExternalIp4Addresses=function(){return f().filter((e=>!e.includes(":")))};const m=(0,s.lazy)((()=>(0,d.mkLogger)("net.ip"))),p=[/^(?:::ffff:)?127\.\d{1,3}.\d{1,3}.\d{1,3}$/i,/^::1$/];function g(e){return(0,a.notBlank)(e)&&(127===function(e){const t=e.split(".").map((e=>(0,u.toInt)(e)));return 4!==t.length||t.some((e=>null==e||!(0,u.within)(0,255,e)))?void 0:t}(e)?.[0]||p.some((t=>null!=t.exec(e))))}t.isLoopback=g,t.isLocalhost=function(e){return m().tap({msg:"isLocalhost",level:"info",result:!(0,a.blank)(e)&&((0,t.myIpAddresses)().includes(e)||(0,t.myIpAddresses)().includes((0,h.stripPrefix)(e,"::ffff:"))||g(e)),meta:{address:e}})}},96128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),w=i(34102),v=i(26293),b=new RegExp("^"+v.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==b.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const S=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=S.exec(e)}function _(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=_,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,n.blank)(e)){if(null!=_(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void T().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs});const T=(0,s.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,o.later)((()=>(0,w.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=_(e)?r.promises.reverse(e):r.promises.resolve4(e),5*a.secondMs);if(t===c.Timeout)return T().info("nslookup("+e+"): timeout"),e;const i=t.find(n.notBlank);return null==i?(T().warn("No name found for "+e),e):i}catch(t){return T().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,n.blank)(e)&&!(0,n.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),s=i(42659),n=i(31586),a=i(97790),o=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*s.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,n.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,a.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,o.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs})},78330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const r=i(40958),s=i(22573),n=i(45599),a=i(59455),o=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),h=i(63870),f=(0,n.defer)((()=>(0,o.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,a.toA)(await async function(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return f().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,r.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(f().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),s=i(38639),n=i(19851),a=i(59958),o=i(43334);t.isDocker=(0,n.lazy)((()=>o.isLinux&&((0,s.toBoolean)(process.env[a.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),s=i(19851),n=i(54993);t.isPacked=(0,s.lazy)((()=>!(0,n.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const r=i(45599),s=i(50213),n=i(84777),a=i(68284),o=i(63870),l=i(43334),u=(0,r.defer)((()=>(0,s.mkLogger)("platform.Pacman")));t.hasPacman=(0,r.defer)((()=>l.isLinux&&(0,a.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,n.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,o.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(22573),o=i(38639),l=i(59958),u=s.default.platform();t.inspectFlag=n.default.argv.includes("--inspect")||(0,o.isTrue)(n.default.env.NODE_INSPECT),t.isCI=(0,o.isTrue)(n.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,a.notBlank)(n.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===s.default.arch(),t.isArm=null!=/^arm\b/i.exec(s.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,a.notBlank)(n.default.env.APPIMAGE)||(0,a.notBlank)(n.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,a.notBlank)(n.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=n.default.versions.electron,t.isElectron=t.isMainElectron||(0,o.isTrue)(n.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const s=r(i(73024)),n=i(19851),a=i(43334);function o(e="/proc/cpuinfo"){if(a.isWin||a.isMac)return!1;try{return null!=s.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=o,t.isRaspberryPi=(0,n.lazy)((()=>a.isLinux_arm&&o())),t.procDeviceModel=(0,n.lazy)((()=>{try{return a.isLinux?s.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},94137:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.negateFilterName=void 0;const r=i(22573),s=i(51926),n=i(83556);t.negateFilterName=function(e){if((0,r.blank)(e))return;const t=/\s/.test(e)?e:(0,n.camel2words)(e).replace(/\bphoto structure\b/gi,"PhotoStructure");return t.match(/^not\b/)?t.replace(/^not\b/,"").trim():"not "+(0,s.stripPrefix)(t,"is ")}},78984:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Predicates=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(51926),o=i(50213),l=i(94137),u=(0,r.lazy)((()=>(0,o.mkLogger)("predicates.Predicates")));class c{static async accepted(e,...t){for(const i of t)for(const t of(0,n.values)(i)){const i=await t(e);if(!1===i||(0,a.isString)(i))return!1}return!0}static async rejected(e,...t){return!await c.accepted(e,...t)}static async explain(e,...t){const i=[],r=[],s=[];for(const o of t)for(const[t,l]of(0,n.entries)(o)){const n=await l(e);!0===n?i.push(t):!1===n||(0,a.isString)(n)?r.push(t):s.push(t)}return{accepted:i,rejected:r,notApplicable:s}}static async whyRejected(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))try{const i=await r(e);if(null==i||!0===i)continue;return(0,a.isString)(i)?i:(0,l.negateFilterName)(t)}catch(e){u().warn("whyRejected() caught from "+t,{error:e})}}static async logged({a:e,logger:t,msg:i,predicates:r}){const{accepted:n,rejected:a}=await c.explain(e,...r);return t.tap({msg:i,result:(0,s.isEmpty)(a),meta:{a:e,accepted:n,rejected:a}})}}t.Predicates=c},33995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncPredicates=void 0;const r=i(68708),s=i(94137);class n{static firstFalse(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!1===s(e))return t}static firstTrue(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!0===s(e))return t}static firstDefined(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i)){const i=s(e);if(null!=i)return{name:t,result:i}}}static accepted(e,...t){return null==n.firstFalse(e,...t)}static whyRejected(e,...t){return(0,s.negateFilterName)(n.firstFalse(e,...t))}}t.SyncPredicates=n},45643:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),s=i(59455),n=i(31562);t.existingPids=function(e){return(0,s.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,n.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),w=i(97790),v=i(59455),b=i(54993),S=i(54557),P=i(19851),_=i(50213),T=i(88158),M=i(409),E=i(78406),D=i(25764),x=i(99331),k=i(56519),C=i(46292),F=i(8769),A=i(83278),I=i(32144),O=i(29882),L=i(43334),R=i(24399),N=i(58261),B=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),j=10*p.secondMs;function z(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,O.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,v.toA)(t))B().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{B().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??L.isWin,r=await this.pidfiles(),s=await this.pids(r??[]);if((0,f.isEmpty)(s))return B().info("killOldProcs(): no pidfiles"),[];const n=[],a=[],o=await(0,N.pidInfos)(s);if(null!=o){for(const s of r){const r=await s.readJson();if(null==r){B().warn("killOldProcs(): failed to read pidfile "+s.base),await s.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){B().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+s.base,{json:r,pid:l}),await s.unlink("debug");continue}const u=o.find((e=>e.pid===l));if(null==u||!z(r,u)){B().debug("killOldProcs(): pid no longer present: unlinking "+s.base,{json:r,pidEntry:u}),await s.unlink("debug"),n.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(B().info("killOldProcs(): killing",{reason:d,json:r}),a.push(W(l,i,!1)),n.push({...r,...u}))}return a.length>0&&await Promise.allSettled(a),n}(0,F.onError)("Pids.killOldProcs(): failed to get process information")}}),a.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const a=e.pid;if(!(0,y.gt0)(a))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(a)?(i&&o(this,s,"f").delete(l),o(this,s,"f").getOrSet(l,(async()=>{const i=o(this,r,"m",n).call(this,e.pid),s=(0,w.opt)((0,T.Try)((()=>(0,O.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),a=t.getTime(),l={...e,cmd:s,startTime:a};return await i.writeJson_(l),B().debug("addPid() wrote "+i,l),i}))):(o(this,s,"f").delete(l),void B().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,v.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=o(this,r,"m",n).call(this,e);return(0,k.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{B().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==o(this,a,"f")||o(this,a,"f").ended)&&l(this,a,new E.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:D.EndableRanks.first}),"f"),o(this,a,"f")}cancelInterval(){o(this,a,"f")?.end(),l(this,a,void 0,"f")}}t.Pids=U,s=new WeakMap,a=new WeakMap,r=new WeakSet,n=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,C.configDir)(),(e=>new U(A.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const s=i(31421),n=i(48161),a=r(i(1708)),o=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),w=i(84968),v=i(48963),b=i(56519),S=i(84777),P=i(8103),_=i(45879),T=i(43334),M=i(24399),E=i(45643),D=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function x(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function k(e){if(T.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,_.readFileMaybe)("/proc/"+i+"/stat")));return D().tap({msg:"pidInfoProc",result:(0,o.compact)(t)})}(e);const t=(0,E.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,T.isWin?I:N)).filter((e=>x(e)&&t.includes(e.pid)));return D().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=x,t.pidInfo=async function(e){return(0,b.thenMap)(k([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,o.isEmpty)(e)?[]:(0,b.thenMap)((0,E.existingPids)(e),(t=>{const i=[a.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=k;const C="Get-Process",F="| Select-Object -Property Id,ProcessName,StartTime";function A(e){return(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).join(",")}async function I(e){if(M.PowerShell.instance().ended)return R(e);const t=[C,"-Id",A(e),"-ErrorAction SilentlyContinue",F].join(" ");return(0,b.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,v.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const O={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},L=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,o.isNotEmpty)(e)){const i=(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",L.join(","));const i=await(0,S.stdoutResult_)((0,P.wmic)(),t,O),r=(0,d.onlyReqValued)((0,p.parseFixed)(L,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,v.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return r.find((e=>e.pid===a.default.pid))||r.push({pid:a.default.pid,start:new Date(w.StartTs),cmd:"node "+a.default.title}),r}async function N(e){return t=(await(0,S.stdoutResult_)("ps",["-p",A(e),"-wwwo","pid,lstart,command"],{...O,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const B=(0,g.lazy)((()=>{try{if(T.isLinux)return(0,c.toGt0)((0,s.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){D().warn("clk_tck failed",{error:e})}return 100})),j=(0,g.lazy)((()=>Date.now()-(0,n.uptime)()*u.secondMs)),z=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=z.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,s=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(s)?{pid:i,cmd:r,start:new Date(j()+s/B()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(29882),o=i(97352);t.progressEvtToS=function(e){const t=(0,s.blank)(e.path)?null:(0,a.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,n.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,s.notBlank)(e.op)&&(0,o.within)(0,100,e.pct)}},41944:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),s=i(42659),n=i(31586),a=i(12089),o=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new o.TTLMap(15*s.secondMs))),t.recentDone=(0,r.lazy)((()=>new o.TTLMap(2*s.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,n.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,a.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),s=i(31586),n=i(409),a=i(78406),o=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends a.EndableInterval{constructor(e,t,i,s=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:s,rank:o.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=s,this.start=Date.now(),this.onInterval=(0,n.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,s.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,s.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},38156:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushProgressObserver=void 0;const r=i(31586),s=i(41944);t.PushProgressObserver=class{constructor(e,t){this.context=e,this.total=t,this.start=Date.now()}toJSON(){}incrProgress(e=1){this.onProgress(e+(this.current??0))}onProgress(e){this.current=(e??this.current??0)+1,(0,r.gte)(this.current,this.total)&&(this.done=!0),this.emit()}completed(){this.done=!0,this.current=this.total,this.emit()}emit(){(0,s.emitProgressEvt)({...this.context,pct:(0,r.pct)(this.current,this.total),elapsedMs:Date.now()-this.start,done:this.done})}}},24399:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),w=i(99331),v=i(56519),b=i(31562),S=i(84777),P=i(34102),_=i(43334),T=i(28874),M=i(63870),E="{ready}",D=" | ConvertTo-Json -Compress";function x(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=x,(0,o.later)((()=>(0,P.ee)().on("clearCache",(()=>k.instance.prior()?.clearMockResults()))));class k extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,S.execFile)("powershell",T.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${E}"}`,...(0,n.mapNotBlankOr)(T.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:E,fail:"Error",exitCommand:"exit",maxProcs:T.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:a.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),T.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(T.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,v.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,D),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,w.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,s)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,s)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,D),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,n.blank)(t.stdout)||(0,n.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,v.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+x(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=k,k.instance=(0,s.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new k})),t.checkPowerShell_=async function(){const e=k.instance();if(e.ended||(0,w.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,n.blank)(t)){const t=await(0,b.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),s=i(38639),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toBoolean})}}t.BooleanSetting=a},90536:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).flatMap(parseFloat).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=o},75164:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).filter(r.notBlank).flatMap(s.toInt).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,s.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=o},10546:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),s=i(22573),n=i(45599),a=i(50213),o=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,n.defer)((()=>(0,a.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,o.trimQuotes)(e);return void((0,s.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,s.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),s=i(91655),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,s.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=a;class o extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=o},9945:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.FloatSetting=a},69589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.forceContextOrSetting=t.pickForceContext=void 0;const r=i(38639),s=i(68708),n=i(50989),a=i(76740),o=i(28874),l=(0,n.strEnum)("forceSync","forceFilters","skipPreviews","forceRebuildPreviews","skipAssetTagging","recountAllTags","skipAssetRepair");t.pickForceContext=function(e){return(0,s.pick)(e,...l.values)},t.forceContextOrSetting=function(e){const t={...(0,s.pick)(e??{},"retries","halt","path"),...(0,s.fromEntries)(l.values.map((t=>[t,e?.[t]??(0,r.isTrue)(o.Settings[t]?.valueOrDefault)])))};return t.retries??(t.retries=0),t.halt??(t.halt=new a.Abortable),t}},74589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt})}}t.IntegerSetting=a},86941:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAndArchiveSystemSettingsDir_=t.mergeUserDataDirs_=void 0;const r=i(19851),s=i(59455),n=i(72993),a=i(46292),o=i(95696),l=i(50213),u=i(83179),c=i(28874),d=i(2858),h=i(84438),f=(0,r.lazy)((()=>(0,l.mkLogger)("settings.MergeConfigDirs")));async function m(e,t){let i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+e.baseWithGrandparent+" => "+t.baseWithGrandparent+")");const r=await e.resolve_(),n=await t.resolve_();if(null==r||null==n||n.nativePath===r.nativePath)return void i.info("no-op, missing or same directory",{priorResolvedConfigDir:r?.nativePath,currentResolvedConfigDir:n?.nativePath});if(i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+r.baseWithGrandparent+" => "+n.baseWithGrandparent+")"),!await r.isDirectory())return void i.info("no-op, prior directory doesn't exist");{const e=r.join(h.SettingsToml);if(await e.isNonEmptyFile()){const t=n.join(h.SettingsToml);await(0,d.readSystemSettings)(e),i.info("read prior settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.readSystemSettings)(t),i.info("read current settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.writeSystemSettings_)(t)}}{const e=r.join("licenses"),t=n.join("licenses");for(const r of(0,s.toA)(await e.childFiles())){const e=t.join(r.base);if(await e.notExists())try{await r.copyFile_(e),i.info("Copied license "+r.base)}catch(e){i.warn("Failed to copy license "+r.base,e)}}}const a=n.join("old");try{const e=await r.renameYMDHMS_({subdir:a.nativePath});i.info("merged and archived to "+e)}catch(e){i.warn("Failed to archive to "+a,e)}}t.mergeUserDataDirs_=async function(){const e=(0,a.configDir)();if(null==e)return;const t=o.PosixFile.for(e);for(const e of[t.join((0,n.AppName)()),t.join((0,n.AppName)().toLowerCase()),t.parent().join((0,n.AppName)().toLowerCase())])try{await m(e,t)}catch(i){f().error("Failed to merge "+e+" and "+t,i)}f().info("done")},t.mergeAndArchiveSystemSettingsDir_=m},4175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),s=i(22573),n=i(38639),a=i(42659),o=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function w(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function v(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){_(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&w(),y("strictDeduping",e)&&v(),(y("optOut",e)||y("noNetwork",e))&&T()},t.handleDeprecatedSettings=async function(){if((0,n.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,s.blank)(m.Settings.assetPathnameFormat.value)&&(0,s.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*a.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=w,t.setStrictDeduping=v;const b=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],S={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function _(e){for(const t of b)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:S;for(const[e,i]of(0,o.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function T(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=_,t.disableExternalNetworkRequests=T},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),s=i(53265),n=i(87652);class a extends n.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,s.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=a},23561:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.OptionalFloatSetting=a},69005:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=a},87652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=s},4936:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathToLibraryAsset=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(55835),l=i(51926),u=i(50213),c=i(81168),d=i(79842),h=i(21330),f=i(51275),m=i(29882),p=i(28874),g=(0,s.lazy)((()=>(0,u.mkLogger)("settings.PathToLibraryAsset")));function y(e){return(0,a.blank)(e)?"":"'"+e.replace(/'/g,"′")+"'"}t.pathToLibraryAsset=function(e,t){const i=(0,d.datedToDateTime)(e)??(0,o.map)((0,h.datedToISO)(e),(e=>r.DateTime.fromISO(e)));if(null==i||!i.isValid)return g().tap({msg:"pathToLibraryAsset(): failed to convert to a valid date",result:void 0,meta:{capturedAt:e,src:t,dt:i}});const s=(0,f.hasZone)(e),a=p.Settings.assetPathnameFormat.valueOrDefault,u=(0,c.splitKeep)(a,/((?:GRAND)?PARENT|BASE|NAME|EXT|ISO)/g);for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),s=i(83556);t.nameFromEnv=function(e){return(0,s.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,s.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const a=i(19851),o=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),w=i(40583),v=i(81168),b=i(44198),S=i(96706),P=i(34102),_=i(28283),T=i(81075),M=i(98778),E=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,a.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?n(this,r,"m",s).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?n(this,r,"m",s).call(this,e??t)+": "+i:null==this.fromEnv(e)?n(this,r,"m",s).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,v.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,S.caseInsensitiveEnv)():new w.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,b.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,o.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,o.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,o.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return T.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,b.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&S.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,b.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&S.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new w.CaseInsensitiveValued(e)))??(0,S.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,v.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],E.WrapComments);function i(e,i){(0,o.isEmpty)(i)||t.push(...(0,v.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],E.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,v.wrap)(["",e+": "+r],E.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,s=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),s=i(76760),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),w=i(79840),v=i(7282),b=i(12801),S=i(4328),P=i(70488),_=i(84248),T=i(5531),M=i(99315),E=i(34365),D=i(34580),x=i(96706),k=i(50274),C=i(33866),F=i(52086),A=i(48584),I=i(45969),O=i(43334),L=i(24540),R=i(70379),N=i(71300),B=i(33209),j=i(48987),z=i(68268),V=i(61208),W=i(99023),U=i(30577),q=i(1485),H=i(19861),$=i(55111),G=i(30933),J=i(22859),K=i(71988),Y=i(38483),Z=i(90536),X=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),se=i(9945),ne=i(74589),ae=i(844),oe=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,n.lazy)(v.isProd);const ye=()=>!(0,t.isProd)();function we(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function ve(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new oe.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new ne.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:ve}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new ne.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:ve}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>q.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:q.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>q.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>O.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new ne.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:$.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!O.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>O.isMac?"100ms":O.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>w.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new se.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new ne.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>b.PriorityClasses.BelowNormal,strEnum:b.PriorityClasses}),maxMemoryMb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!we()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!we()}),argon2TimeCost:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:T.CheckpointTypes,defaultValue:T.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:E.SynchronousModes,defaultValue:E.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 1 minute is very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"1m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:C.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>O.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new ne.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,D.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new ne.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new ne.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new ne.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,L.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,G.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:k.SidecarExts,defaultValue:k.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new se.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,G.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:F.CropStrategies.attention,strEnum:F.CropStrategies}),videoFrameAtSec:new se.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,a.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new ne.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(O.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>B.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new ne.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new ne.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:A.SharpFailOns.truncated,strEnum:A.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>j.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:ae.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new se.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:z.KeywordReparentingStrategies.move,strEnum:z.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function be(e){const i=((0,l.blank)(e)?"":e).split(s.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,a.uniq)(i).filter(l.notBlank).join(s.delimiter)}function Se(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=be,t.pathWithDefaults=(0,n.lazy)((()=>be((0,x.getEnv)("PATH")))),t.allSettings=(0,n.lazy)((()=>(0,o.sortBy)((0,d.values)(t.Settings),Se))),t.persistedSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,n.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,n.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),s=i(31586),n=i(7282),a=i(49776),o=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),w=i(15674),v=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{v.Settings.configDir.opts.defaultValue=o.configDir,v.Settings.logDir.opts.defaultValue=c.defaultLogDir_,v.Settings.logServerLevel.opts.defaultValue=()=>v.Settings.logLevel.valueOrDefault,v.Settings.cacheDir.opts.defaultValue=a.defaultCacheDir,v.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,v.Settings.libraryDir.opts.exampleValue=()=>(0,n.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,n.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),v.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,v.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,v.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],v.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,w.maxCpus)()/4)),v.Settings.useFsWatch.watch(f.useFsWatch),v.Settings.updateChannel.opts.defaultValue=g.channel,v.Settings.ffmpegThreads.opts.defaultValue=()=>(0,w.maxCpus)()>=12?2:1,v.Settings.minBusyPct.opts.defaultValue=()=>(0,s.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),w=i(54993),v=i(50213),b=i(81168),S=i(83556),P=i(37805),_=i(87290),T=i(98314),M=i(34102),E=i(83278),D=i(95696),x=i(60865),k=i(4175),C=i(83179),F=i(81075),A=i(28874),I=i(41692),O=i(84438),L=i(32707),R=i(6707),N=i(55018),B=i(10357),j=(0,r.lazy)((()=>(0,v.mkLogger)("settings.SettingsIO")));function z(e){return(0,_.libraryDataDirPosixFile)(e)?.join(O.SettingsToml)}async function V(e=(0,L.systemSettingsFile)()){if(null!=e)return Q(E.BaseFile.for(e))}async function W(){try{return(0,a.toNotBlank)((await(0,R.readTomlFile_)((0,L.systemSettingsFile)()))?.[A.Settings.libraryDir.name])}catch{return}}async function U(){return J((0,L.systemSettingsFile)())}async function q(e){return(0,m.map)(z(e),(e=>J(e)))}function H(){t.libraryHasSettings.refresh()}function $(e){const t=z(e);return j().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:A.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}t.librarySettingsFile=z,t.readSettings=(0,r.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await Z()}),o.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return A.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=U,t.librarySettingsVersion=q,t.maybeUpgradeSystemSettings=async function(){P.version!==await U()&&await Y()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&P.version!==await q()&&await X()},t.libraryHasSettings=(0,r.lazy)((()=>$())),t.libraryHasSettings.unset=()=>{j().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,M.ee)().on("clearCache",H),(0,M.ee)().on("settingsChanged",H),A.Settings.libraryDir.watchLater(H)})),t._libraryHasSettings=$;const G=/^# PhotoStructure v(?\d+\.\d+\.\d+(?:-\S+)?)$/i;async function J(e){if((0,a.blank)(e))return;const t=await E.BaseFile.for(e).firstMatchingLine(G);return t?.groups?.version}async function K(e,i){if(null==e)return void j().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),s=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...re("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","-- ","","PhotoStructure v"+(0,t.versionForSettings)())),r.push("","");let s="";for(const e of i){const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==s&&(s=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,M.ee)().emitDebounced("settingsChanged")}(s,i),j().info("writeToml(): wrote settings",{dest:s,file:e,nonDefaults:(0,C.settingsToObj)(i),wip:r}),r){const t=await(0,R.readTomlFile_)(s),i=await(0,R.readTomlFile_)(e);(0,u.eql)(t,i)?(j().info("Equivalent contents",{dest:s,file:e,a:t,b:i}),await s.unlink()):(j().info("Archiving prior, different contents",{dest:s,file:e}),await e.renameYMDHMS_({subdir:"old"}),await s.unwip_())}}async function Y(e=(0,L.systemSettingsFile)()){const t=D.PosixFile.forMaybe(e);return null!=t&&await K(t,(0,A.persistedSystemSettings)()),t}function Z(e){return Q(z(e))}async function X(e){await(0,_.setupLibraryDataDir_)((0,a.firstNotBlank)(e,A.Settings.libraryDir.value));const i=z(e);return j().info("writeLibrarySettings()",{file:i}),null!=i&&(await K(i,(0,A.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function Q(e){if(null==e)return[];const t=j().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await ee(e);return(0,s.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,T.errorToS)(e)),[]}}async function ee(e){const t=j().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,R.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const n=[],a=(0,s.compact)((0,p.entries)(r).map((([e,t])=>{const i=(0,A.getSettingByNameOrKey)(e);if(null==i)n.push(`Failed to import "${e}"${(0,m.mapOr)((0,A.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;n.push(e)}})));return t.info("loaded",{settings:(0,C.settingsToObj)(a),warnings:(0,s.toNotEmpty)(n)}),await(0,k.handleDeprecatedSettings)(),(0,k.handleMetaSettings)(a),{settings:a,warnings:n}}t.versionForSettings=(0,r.lazy)((()=>P.version)),t.writeSystemSettings_=Y,t.writeAllSettings_=function(e){return K(D.PosixFile.for(e),(0,A.persistedSettings)())},t.readLibrarySettings=Z,t.writeLibrarySettings_=X,t._readSettings=Q,t.importFileSettings_=ee;const te=(0,r.lazy)((()=>new Set([A.Settings.noNetwork,A.Settings.httpPort,A.Settings.license,A.Settings.logStdout,A.Settings.logLevel].map((e=>e.key)))));function ie(){for(const e of(0,p.values)(A.Settings))te().has(e.key)||e.unset();(0,M.ee)().emit("settingsChanged")}function re(...e){return(0,d.flatten)(e.map((e=>(0,b.wrap)(e,B.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),A.Settings.libraryDir.unset(),await Y()},t.clearSettings=ie,t.nukeSettings=async function(){ie(),await(D.PosixFile.forMaybe((0,L.systemSettingsFile)())?.unlink("trace")),await(D.PosixFile.forMaybe(z())?.unlink("trace")),(0,M.ee)().emit("clearCache"),I.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...re("",`Welcome to PhotoStructure! These are the settings for version ${(0,x.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...re("","The following settings categories are stored in the system settings.toml:","",...(0,n.sort)([...F.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,n.sort)([...F.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...re("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...re("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const n=`${e.key} or ${e.name}`,a={...e.addToJSON()};(0,s.mapNotEmpty)(e.altKeys,(e=>a.aliases=(0,h.orList)(e)));const o=(0,p.entries)(a).map((([e,t])=>`${(0,b.capitalize)((0,S.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,s.isNotEmpty)(o)&&o.push(""),i.push(...re((0,g.padding)("-",n.length),n,(0,g.padding)("-",n.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...o,`${e.key}=${(0,f.stringify)((0,w.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(98553),o=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,a.stringify)(e)}t._join=c;function d(e){return(0,o.map)(function(e){const t=(0,n.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,s.compact)((0,l.toA)(JSON.parse(t)).map(n.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,s.compactBlankish)(t.split(e));return[t]}}(e),s.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,n.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,s.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,s.isEmpty)(e)||(this.value=this.toValidValues((0,s.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,s.isEmpty)(this.values)}isNotEmpty(){return(0,s.isNotEmpty)(this.values)}toNotEmpty(){return(0,s.toNotEmpty)((0,s.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=s},72564:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),s=i(98553),n=i(55835),a=i(58305);class o extends a.StringArraySetting{constructor(e){super({toEnv:e=>(0,n.map)(e,(e=>(0,s.stringify)((0,r.uniq)(e)))),fromEnv:t=>function(e,t){return(0,r.compact)((0,a.splitStringArray)(e)?.map((e=>t.getCI(e))))}(t,e.strEnum),defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=o},80372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),s=i(81168),n=i(83179);class a extends n.Setting{constructor(e){super({toEnv:o,fromEnv:o,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function o(e){return null==e?void 0:(0,s.trimQuotes)(e)}t.StringSetting=a},32707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),s=i(55835),n=i(46292),a=i(84438);t.systemSettingsFile=function(){return(0,s.map)((0,n.configDir)(),(e=>(0,r.join)(e,a.SettingsToml)))}},80496:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),s=i(44652),n=i(22573),a=i(76850),o=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,a.debom)(e),(0,n.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,n.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,s.readFileSync)(t)):void 0}catch(e){return void(0,o.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,n.mapNotBlank)(e,(async e=>f(await(0,s.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,s.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),s=i(96249),n=i(98553),a=i(68708),o=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const s=e+" = "+(0,n.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[s]:(0,o.wrap)(s.split("\n"),i)}t.stringifyToml=function(e){return(0,s.flatten)((0,a.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,o.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},10357:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const r=i(54993),s=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=a(e[t]);if(null!=i)return i}};const n=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function a(e){const t=(0,s.extractFloat)(e);if(null==t)return;const i=(0,r.toS)(e).toLowerCase();for(const e of n)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),s=i(81168);t.bname=function(e,t=!0){let i=(0,s.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,s.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),h=i(31586),f=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),w=i(81168),v=i(76596),b=i(79842),S=i(66649),P=i(21330),_=i(98725),T=i(928),M=i(54261),E=i(89724),D=i(17415),x=i(88600),k=i(51275),C=i(29882),F=i(17217),A=i(68284),I=i(57902),O=i(28874),L=i(65162),R=i(71300),N=i(14036),B=i(61424),j=(0,s.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function z(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,f.isObject)(e)&&(0,o.notBlank)(e.nativePath)&&(0,b.isDated)(e.date)&&(0,o.notBlank)(e.src)}t.capturedAtSrcFromTags=z,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class U{static fromAssetFile(e){return(0,d.map)((0,E.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>U.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof U?e:W(e)?new U(e):void 0}constructor(e){var t;this.nativePath=(0,F.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,h.toGt0)(e.local)??(0,E.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,b.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(O.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,S.datedToMillis)(e.mtime)??(0,A.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:U.name,...(0,f.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,_.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,D.fmtOffsetMinutes)});return null==t?void 0:new U({...e,date:t})}spread(e){return new U({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,D.fmtOffsetMinutes)(this.offset)}get isFromTags(){return z(this.src)}get isInferred(){return!z(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,E.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,v.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,k.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,M.hasTime)(this.date)}hasMillis(){return(0,h.gt0)((0,T.getMillisecond)(this.date))}toMillis(){return(0,S.datedToMillis)(this.date)}get isValid(){return(0,x.isValidDate)(this.date)}get zoneName(){return(0,r.offsetMinutesToZoneName)(this.offset)??(0,k.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,D.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?O.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,b.datedToStartDateTime)(this.date)??(0,b.datedToDateTime)(this.date);if(null!=i)return{start:(0,E.datedToLocal)(i.minus(t)),end:(0,E.datedToLocal)(i.plus(t))};j().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:O.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),r=Math.max(t,e.fuzzyPrecisionMs());return j().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,b.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:r}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:r}})}}function q(e,t){if(null==e)return;const i=(0,n.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>U.for(e))));for(const r of t){let t=e[r],s=r;if((0,x.isValidDate)(t)){if((0,D.isValidZone)(e.tz)&&(!(0,k.hasZone)(t)||R.OverrideUTCZoneTags.includes(s))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,o.blank)(e.tzSource)?"":" from "+(0,w.stripPrefix)(e.tzSource,"from ");s+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,E.datedToLocalSec)(t),date:t,src:s,precisionMs:(0,b.datedToPrecisionMs)(t),rawValue:e[r]?.rawValue})}}const r=(0,p.leastBy)(i,(e=>(0,b.datedToStartTs)(e.date)));if(null==r)return;const s=i.filter((e=>(0,u.eql)(e.date,r.date)||e.precisionMs<=r.precisionMs&&(0,b.datedOverlap)({a:e.date,b:r.date,aPrecisionMs:e.precisionMs,bPrecisionMs:r.precisionMs}))),a=(0,p.leastBy)(s,(e=>[Math.floor(e.localSec/1e6),(0,k.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return j().debug("capturedAtFromTags()",{least:r,overlapsWithLeast:s,earliest:a}),a}function H(e,t){if(O.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,n.uniq)([(0,L.bname)(e,!0),(0,L.bname)(e,!1)])){const e=(0,_.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,b.datedToPrecisionMs)(e),l.secondMs])}}}function $(e){if(O.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,_.extractDateFromPath)(e.pathsForDateParsing)}}async function G(e){if(O.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=U,t.bestCapturedAt=function(e){const t=(0,a.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const r=await e.mtimeMs();function s(t,i){return W(i)?U.for(i):null!=i&&null!=i.date&&(0,x.isValidDate)(i.date)?U.for({nativePath:e.nativePath,date:i.date,local:(0,E.datedToLocal)(i.date),src:(0,w.uniqPath)([t,i.src]),mtime:r,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const n=function(e,t){return null==e||t||!O.Settings.usePathsToInferDates.valueOrDefault||!O.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,C.containedByNativePath)({ancestor:O.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),a=s("tags",q(t,O.Settings.capturedAtTags.values))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??s("tags",q(t,O.Settings.capturedAtTagsFallback.values))??(n?void 0:s("bname+stat",await(0,B.extractStatBname)(e)))??(n?void 0:s("path+stat",await(0,B.extractStatPathTime)(e)))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??(n?void 0:s("bname",H(e,t)))??(n?void 0:s("path",$(e)))??(O.Settings.useStatToInferDates.valueOrDefault?s("stat",await G(e)):void 0);return j().tap({level:I.LogLevels.debug,msg:"extractCapturedAt()",result:a})},t.capturedAtFromTags=function(e){return q(e,O.Settings.capturedAtTags.values)},t.capturedAtFromBasename=H,t.capturedAtFromPath=$,t.capturedAtFromStat=G},70379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const r=i(31586),s=i(97352),n=i(95696),a=i(47783),o=i(16170);function l(e){if(null!=e&&(0,o.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,r.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,s.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=n.PosixFile.for(e);return l(await(0,a.readRawTags)(t,!1))}},47783:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const s=i(77988),n=r(i(76760)),a=r(i(1708)),o=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(23838),f=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),w=i(12168),v=i(56038),b=i(4867),S=i(36557),P=i(98247),_=i(21330),T=i(98725),M=i(23467),E=i(88561),D=i(95696),x=i(17217),k=i(16287),C=i(50213),F=i(17921),A=i(7282),I=i(88158),O=i(23560),L=i(28874),R=i(12089),N=i(45255),B=i(81168),j=i(63870),z=i(15674),V=i(28544),W=i(43207),U=i(75767),q=i(12788),H=i(80495),$=i(14036),G=i(67083),J=i(3432),K=i(28630),Y=i(15912),Z=i(30748),X=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),re=i(61424),se=i(8791),ne=(0,o.lazy)((()=>(0,C.mkLogger)("exiftool.ExifTool")));let ae=!1;t.addInstanceIdsToTags=function(e){ae=e},t.setExifToolProcs=function(e){return L.Settings.exiftoolProcsPerChild.envValue=e,ue()};const oe=(0,o.lazy)((()=>new S.BatchClusterObserver("ExifTool",new s.ExifTool({useMWG:L.Settings.useMWG.valueOrDefault,backfillTimezones:L.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:L.Settings.defaultVideosToUTC.valueOrDefault,...(0,S.batchClusterOptions)((0,A.isTest)()?8:(0,O.isSyncService)()?L.Settings.exiftoolProcsPerChild.value??(0,z.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=oe();return e.ended?oe.refresh():e}function ue(e=!1){return(0,d.map)(oe.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,b.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(oe.prior(),(e=>e.ended?void 0:(0,b.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,j.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,f.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,x.toNativePath_)(e))}async function he(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function fe(e){const t=[];return L.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*w.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,B.includesIgnoreCase)(L.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return ne().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const r=i??await(0,te.readMimeType)(e),s=await e.sidecar(),n=(0,X.isImageMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,a=(0,X.isVideoMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,o=L.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await s.exists(),l=n||a||o;return ne().tap({msg:"writeTagDest()",result:l?s:e,meta:{src:e,tagName:t,mimetype:r,writeMetadataToSidecarsIfImage:n,writeMetadataToSidecarsIfVideo:a,writeMetadataToSidecarsIfSidecarExists:o}})}async function pe(e,i=!0){const r=D.PosixFile.for(e);if(r.isSidecar()&&(i=!1),!await r.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(r.nativePath),void ne().debug("readRawTags("+r+"): invalid file, returning null.");const s=await(0,t._readRawTags)(r.nativePath);if(null==s||!i)return s;ne().trace("readRawTags()",{pf:r,pickedFileTags:(0,f.pick)(s,"tz","tzSource",...L.Settings.capturedAtTags.values)});const n=[];for(const e of await r.jsonSidecars())n.push([e,(0,K.readJsonSidecar)(e,s.tz)]);for(const e of await r.existingExifSidecars())n.push([e,(0,t._readRawTags)(e.nativePath)]);const a={original:{},MIMEType:(0,u.mapNotBlank)(s.MIMEType,X.normalizeMimetype),...s},o=[];for(const[e,i]of n){if(null==i)continue;const r=await i;if(null==r)continue;const s=(0,f.omit)(r,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,f.values)(s))?((a.sidecars??(a.sidecars=[])).push(e.base),o.push(...(0,g.toA)(r.History)),(0,I.assignNullishFields)(a.original,(0,f.pick)(a,...(0,f.keys)(s))),(0,f.assignFields)(a,s),ne().debug("readRawTags() sidecar had values",{sidecar:e.base})):ne().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return a.inferred=(0,G.getInferredHistoricValues)(o,e),(0,I.assignNullishFields)(a,a.inferred),a.Rotation=(0,Q.orientationToRotation)(a.Rotation),ne().debug("readRawTags() final",{pf:r,inferred:a.inferred,pickedResult:(0,f.pick)(a,"tz","tzSource",...L.Settings.capturedAtTags.values)}),a}async function ge(e,t){return null==t?void 0:(0,v.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,r=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,X.normalizeMimetype);if((0,u.blank)(r))return void ne().debug("No mimetype for "+i);const n={...t.inferred??{},...t};if(n.inferred??(n.inferred={}),n.original??(n.original={}),L.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const t=n[e];if((0,p.isString)(t)){const i=(0,T.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(ne().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),n[e]=i)}}const o=!await(0,re.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,n,o);if(ne().debug("parseTags()",{tzMeta:l,skipSiblingInference:o}),null!=l?.tz){const e=n.tzSource!==s.defaultVideosToUTC&&void 0;for(const t of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const i=n[t];i instanceof s.ExifDateTime&&(n[t]=(0,_.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,f.assignUndefinedFields)(n.original,n,"tz","tzSource"),(0,f.assignFields)(n,l),(0,f.assignFields)(n.inferred,l)}const c=o?(0,Z.extractMakeAndModel)(n):await(0,re.inferMakeAndModel)(e,n);c.Make!==(0,Z.make)(n.Make)&&(n.original.Make=n.Make,n.inferred.Make=c.Make),c.Model!==(0,Z.model)(c.Make,n.Model)&&(n.original.Model=n.Model,n.inferred.Model=c.Model),!(0,u.blank)(L.Settings.defaultCopyright.valueOrDefault)&&(0,q.isExifUnset)(n.Copyright)&&(n.Copyright=L.Settings.defaultCopyright.valueOrDefault);const d=(0,Y.extractLensMakeModel)(n),h=await(0,V.extractCapturedAt)(e,n,o);if(null==h)return void ne().info("No capturedAt for "+e);!o&&h.isInferred&&(n.inferred.capturedAt=h);const m=(0,H.extractExposureSettings)(n),g=await(0,ie.extractSizeInfoFromFile)(e,n);if(null==g)return void ne().info("No size info for "+i);const y={...c,mimetype:r,capturedAt:h,exposureSettings:m,...(0,se.extractTitleDescription)(n),...d,cameraId:(0,U.cameraIdFromTags)(n),imageId:(0,U.imageIdFromTags)(n),lensId:(0,U.lensIdFromLensInfo)({...d,...(0,f.pick)(n,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(n),tz:n.tz,rating:(0,ee.extractRating)(n)};(0,A.isTest)()&&(y.__parsedBy__=a.default.pid);const w={...n,...y};return ne().debug("parsedTags",{nativePath:i,skipInference:o,...y,inferred:n.inferred,original:n.original,pickedResult:(0,f.pick)(w,"capturedAt","tz","tzSource","Make","Model")}),(0,f.definedValues)(w)}catch(e){return void ne().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,f.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,f.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,M.eqlAsync)(e.sha(),t.sha())||await(0,M.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=D.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,x.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,x.toNativePath_)(e),["-"+t]);return(0,I.pluckCaseInsensitive)(i,t)}catch(e){return void ne().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=he,t.overwriteTags_=async function(e,t){try{await(0,v.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await fe(e)),e.clearThisAndParent()}))}catch(i){ne().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,v.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=fe,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,v.time)("exiftool.writeTags:"+e,(async()=>{const r=new h.MultiMap;for(const[s,n]of(0,f.entries)(t)){const t=await me(e,s,i);r.add(t.nativePath,[s,n])}for(const[t,i]of r.entriesArray()){const r=D.PosixFile.for(t),s=(0,f.fromEntries)(i);ne().info("writeTags()",{src:e,dest:t,t:s}),await le().write(r.nativePath,s,await fe(r)),L.Settings.overwriteOriginal.valueOrDefault||await he(r),r.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,k.nativePathIsFile)(e))return ne().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);ne().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...L.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,$.isVideoExt)(n.default.extname(e))?[]:["-fast"]],r=await(0,v.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{ne().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==r)return;ne().debug("_readRawTags()",{nativePath:e,pickedTags:(0,f.pick)(r,"tz","tzSource",...L.Settings.capturedAtTags.values)}),r.MIMEType=(0,u.mapNotBlank)(r.MIMEType,X.normalizeMimetype),r.GPSDateTime??(r.GPSDateTime=(0,P.concatDateTime)(r.GPSDateStamp,r.GPSTimeStamp));for(const e of(0,f.keys)(r)){const t=r[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete r[e])}const s=(0,l.compactBlanks)([r.Error,...r.errors??[],r.Warning].map(y.toS));return(0,l.isNotEmpty)(s)&&(r.problems=s),ae&&(r.__instance=(0,F.safeUUID)()),r}}),t.parseTags=ge},75767:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(98553),o=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),h=i(54993),f=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),w=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const v=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function b(e){const t=null==e?[]:e.filter((([,e])=>!(0,n.blank)(e)));return 0===t.length?void 0:(0,a.stringify)((0,u.fromEntries)(t))}function S(e){return(0,h.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new o.MultiMap,r=[];for(const a of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(s=e[a])||(0,n.blankish)(s)||(0,l.isNumber)(s)&&(0===s||1===s)||null!=t.zeroesRe.exec((0,h.toS)(s)))continue;const o=e[a],u=S(e[a]),c=(0,t.Tag2SynonymGroup)().get(a);if(null!=c){if(i.includes(c,o)||i.includes(c,u))continue;i.add(c,o)}r.push([a,(0,l.gt0)(o)?o:u])}var s;return b(r)}function _(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function T(e){if((0,n.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([_(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(_)):(0,u.compactBlankValues)(t)}function M({a:e,b:t,field:i,desc:r,parser:s}){const n=s(e[i]),a=s(t[i]),o=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==n||null==a||(0,l.approximates)(n,a,o)?void 0:"Different "+r+": "+e[i]+" ≠ "+t[i]}function E(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,n.blank)(e.lensMake)||(0,n.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,r.lazy)((()=>{const e=new Map;for(const t of v){const i=t[0];for(const r of t)e.set(r,i)}return e})),t.Tag2Synonyms=(0,r.lazy)((()=>{const e=new Map;for(const t of v)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=b,t.renderExifUidId=P,t.decodeExifUid=T,t.findInequalFields=function(e,i){const r=T(e),n=T(i);if(null==r||null==n||e===i)return;const a=(0,f.intersection)((0,u.keys)(r),(0,u.keys)(n)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of a){const t=r[e],i=n[e];if(S(t)!==S(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of v){const t=(0,u.pick)(r,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(n,...e);if((0,u.isEmptyObj)(i))continue;const a=(0,u.values)(t).map(h.toS),o=(0,u.values)(i).map(h.toS);if((0,s.includesAny)(a,o))continue;const l=(0,f.least)((0,u.keys)(t)),c=(0,f.least)((0,u.keys)(i));return{aKey:l,aValue:r[l],bKey:c,bValue:n[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>M({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>M({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>M({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>M({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return E({...(0,w.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=E,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const r=i(22573),s=i(54993),n=/undefined|null|none|n\/a|unknown/i;function a(e){return null==e||(0,r.blank)(e)||n.test((0,s.toS)(e))}t.isExifUnset=a,t.toExifDefined=function(e){return a(e)?void 0:e}},80495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const r=i(19851),s=i(22573),n=i(31586),a=i(68708),o=i(54993),l=i(50213),u=i(97352),c=(0,r.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,s.firstNotBlank)((0,o.toS)(e.ExposureTime),(0,o.toS)(e.ShutterSpeed),(0,o.toS)(e.ShutterSpeedValue),(0,o.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,a.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,n.gt0)(e))return e;const[t,i]=(0,o.toS)(e).split("/").map((e=>(0,n.toInt)(e)));return(0,n.gt0)(t)&&(0,n.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,n.toFloat)(e);return(0,n.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),s=i(40958),n=i(96249),a=i(23838),o=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,o.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,o.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new a.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,n.flatten)((0,o.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function w(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=w,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return w(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return w(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return w(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return w(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return w(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return w(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return w(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return w(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),h=i(50989),f=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),w=i(50213),v=i(81168),b=i(66649),S=i(17415),P=i(29882),_=i(95696),T=i(17217),M=i(28874),E=i(47783);function D(e,t){return(0,d.entries)(t??{}).map((([t,i])=>x({action:e,key:t,value:i})))}function x({action:e,key:t,value:i,ts:s}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:r.ExifDateTime.fromMillis(s??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,h.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=D,t.mkHistoryRecord=x,t.InferAction="infer";const k=(0,s.lazy)((()=>(0,w.mkLogger)("tags.History")));function C(e,t){if(null==e||null==e.History||(0,f.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function F(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,o.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function A(e){if(null==e)return;const t={};for(const[i,r]of(0,d.entries)(e))(0,v.isFirstCharAZ)(i)&&(t[i]=r);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,S.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function I(e,i,r){if(null==e||(0,o.blank)(e))return void k().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const s=(0,T.toNativePath_)(e),a=await(0,E._readRawTags)(s),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!C(a,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...r??{}};if((0,n.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void k().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:r,tagsToWrite:c});k().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:r});const h=_.PosixFile.for(e);return await(0,E.overwriteTags_)(h,c),h.clearThisAndParent(),u}t.tagsContainHistory=C,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const s=(0,m.toA)(e);if((0,n.isEmpty)(s))return{};const l=(0,a.sortBy)(s.filter((e=>(0,v.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,b.datedToMillis)((0,o.mapNotBlank)(e.When,(e=>r.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,o.notBlank)(t)){const r=F(e);(0,o.blank)(r.nativePath)||(0,P.eqlNameWithoutExt)(r.nativePath,i)?u[t]=r:k().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=F,t.inferredToTags=A,t.ensureInferredHistoryRecords=async function(e,i,r){const s=D(t.Actions.infer,r),n=(M.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?A(r):void 0)??{};return M.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(n.Source=e.nativePath),k().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:s,additionalTags:n}),I(i,s,n)},t.ensureHistoryRecords=I},3432:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const s=r(i(53705)),n=i(77988),a=i(19851),o=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),h=i(17415),f=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),w=i(61424),v=(0,a.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function b(e,t,i){{const e=S(t);if(null!=e&&(0,h.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,h.isValidZone)(t.tz)||t.tzSource===n.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,o.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof n.ExifDateTime&&(0,h.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,w.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function S(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return v().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,s.default)(t,i),r=(0,h.normalizeZone)(e);return v().tap({msg:"zoneFromLatLon()",result:r,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return v().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,f.isValidDate)(i))for(const r of g.Settings.capturedAtTags.values){const s=(0,u.toDated)(t[r]);if(null==s||(0,f.isValidDate)(s))continue;const n=Math.round(15*i.diff(s,"minutes").as("minutes")/15),a=(0,h.normalizeZoneOffsetMinutes)(n),o=0===a?void 0:(0,h.normalizeZone)(a);if(null!=o)return v().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:o.name,tzSource:"infer:filename (diff with "+r+")"},meta:{dt:(0,c.datedToISO)(s),rawTzoffsetMinutes:n,normalizedOffsetMinutes:a}})}}t.maybeInferTimezone=async function(e,t,i){return v().tap({msg:"maybeInferTimezone()",result:await b(e,t,i)})},t.zoneFromLatLon=S,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const r=i(77988),s=i(40958),n=i(22573),a=i(38639),o=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),h=i(48884),f=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const s=(0,p.normalizeZone)(e?.formatted),n=r.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:s??t??r.UnsetZone});if(!0===n?.isValid)return n}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,n.toNotBlank)(e.title),Description:(0,n.toNotBlank)(e.description),GPSLatitude:(0,h.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,f.validLat)(e)?e:void 0)),GPSLongitude:(0,h.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,f.validLon)(e)?e:void 0)),GPSAltitude:(0,h.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,o.map)(e.favorited,a.isTrue),peopleNames:(0,s.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,s.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},97573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rawTagKeywords=t.parseKeywordStruct=t.isKeywordStruct=t.parseCategories=t.splitKeywords=t.splitKeyword=t.delimRe=t.keywordToPath=void 0;const r=i(77988),s=i(66150),n=i(19851),a=i(40958),o=i(22573),l=i(41400),u=i(96249),c=i(68708),d=i(59455),h=i(48884),f=i(50213),m=i(68852),p=i(81168),g=i(28874),y=(0,n.lazy)((()=>(0,f.mkLogger)("tags.KeywordTags"))),w=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordPathSeparators.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g")))));function v(e){const i=(0,t.delimRe)();return null==i?[e]:(0,a.compactBlanks)(e.split(i))}function b(e){return null==e||e instanceof r.BinaryField?[]:(0,a.compactBlanks)(Array.isArray(e)?(0,u.flatten)(e.map(b)):v(e))}function S(e){return null==e?[]:(0,p.isString)(e)?(0,o.blank)(e)?[]:[[e]]:(0,u.flatten)((0,d.toA)(e.Category).map(S).map((t=>t.map((t=>(0,a.compact)([e._,...t]))))))}(0,l.later)((()=>{g.Settings.keywordPathSeparators.watchLater((()=>w.unset()))})),t.keywordToPath=function(e){const t=w();return(0,a.compactBlanks)(null==t?[e]:e.split(t))},t.delimRe=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g"))))),g.Settings.keywordDelimiters.watchLater((()=>t.delimRe.unset())),t.splitKeyword=v,t.splitKeywords=b;const P=/^\(?none\)?$/i;function _(e){if(!(0,o.blank)(e)&&null==P.exec(e))try{const t=new s.XMLParser({textNodeName:"_"}).parse(e);return(0,u.flatten)((0,d.toA)(t?.Categories?.Category).map(S))}catch(t){return void y().warn("parseCategories() failed:",{err:t,s:e})}}function T(e){return Array.isArray(e)&&e.every(T)||null!=e&&(0,p.isString)(e.Keyword)&&(null==e.Children||Array.isArray(e.Children)&&e.Children.every(T))}function M(e){if(null==e)return[];if(Array.isArray(e)&&e.every(T))return(0,h.flatMap)(e,M);if((0,o.blank)(e.Keyword))return[];const t=(0,d.toA)(e.Children);return(0,a.isEmpty)(t)?[[e.Keyword]]:(0,h.flatMap)(t,M).map((t=>[e.Keyword,...t]))}t.parseCategories=_,t.isKeywordStruct=T,t.parseKeywordStruct=M,t.rawTagKeywords=function(e){const t=[];if(null!=e){const i=[...g.Settings.keywordTags.values];if(i.includes("Categories")){(0,h.remove)(i,"Categories");const r=_(e.Categories);null!=r&&t.push(...r)}for(const r of i){const i=(0,c.pluckDeep)(e,r)?.value;(0,o.blank)(i)||(T(i)?t.push(...M(i)):t.push(...Array.isArray(i)?i:b(i)))}}return y().tap({msg:"rawTagKeywords()",result:(0,a.compactBlankish)((0,a.uniq)(t)),meta:{t:null==e?void 0:(0,c.pick)(e,...g.Settings.keywordTags.values)}})}},15912:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(55835),o=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),h=i(28874),f=i(30748),m=(0,r.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,f.make)(e.LensMake),i=(0,f.make)(e.Make),r=[],o=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],b),u=(0,s.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:o,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&r.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==b(e))continue;(0,n.notBlank)(t)&&r.push({lensMake:t,lensModel:e,lensInfo:o});const a=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))a.includes(t)&&r.push({lensMake:i,lensModel:e,lensInfo:o});for(const i of(0,s.compactBlanks)([t,...h.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&r.push({lensMake:i,lensModel:e,lensInfo:o});a.startsWith("vr ")&&"Nikon"===i&&r.push({lensMake:"Nikon",lensModel:e,lensInfo:o})}for(const e of r){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=S(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,a.map)(e.lensInfo,S)}return(0,c.greatestBy)(r,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const w=/([\d. -]+)\s?mm\b/i,v=/\bf\/?([\d.\-]+)/i;function b(e){if((0,n.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=w.exec(e)?.[1].replace(/\s/g,""),i=v.exec(e)?.[1];return y(t)&&y(i)?S(`${t}mm f/${i}`):void 0}function S(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,a.mapOr)((0,o.toFloat)(e),(e=>String((0,o.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=b,t.cleanBogusPrecision=S,t.normalizeLensModel=function(e){return S(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(68708),o=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function h(e,t,i=""){const r=e.replace(t,i);return r===e?e:h(r,t,i)}const f=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=f.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,r.lazy)((()=>new p)),y=/\bgopro\b/i;function w(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=h(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=w(e.Make)??b(e.Software)??b(e.CreatorTool)??function(e){return y.test((0,o.toS)(e.HandlerDescription))||y.test((0,o.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,a.compactValues)({Make:t,Model:i})??{}},t.make=w;const v={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function b(e){if(!(0,s.blank)(e))for(const[t,i]of(0,a.entries)(v))if(i.test(e))return t}t.makeFromSoftware=b;const S=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=S.exec(i);null!=e&&(i=e[1].trim())}const r=(0,n.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=r)return r[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,n.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=h(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},38010:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MergedTags=t.revisionToResourceEvent=t.resourceEventToRevision=t.isSetRevision=t.isPrimitiveRevision=t.isBaseRevision=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(55835),u=i(31586),c=i(68708),d=i(67478),h=i(59455),f=i(54993),m=i(72993),p=i(50213),g=i(84885),y=i(66649),w=i(98725),v=(0,s.lazy)((()=>(0,p.mkLogger)("tags.MergedTags")));function b(e){return(0,u.isNumber)(e?.createdAt)&&(0,o.notBlank)(e?.field)}function S(e){return null==e?.op&&b(e)}function P(e){return e?.sourceIsPrimary??e?.shown??!1}function _(e){return e?.sourceModifiedTime??e?.mtime??0}t.isBaseRevision=b,t.isPrimitiveRevision=S,t.isSetRevision=function(e){return["add","delete"].includes(e?.op)&&b(e)},t.resourceEventToRevision=function(e){if(null==e||!(0,f.toS)(e.SoftwareAgent).startsWith((0,m.AppName)()))return v().tap({msg:"resourceEventToRevision() invalid",result:void 0,meta:{resourceEvent:e}});const t=e.Changed;if((0,o.blank)(t))return v().tap({msg:"resourceEventToRevision() missing Changed field name",result:void 0,meta:{resourceEvent:e}});const i=(0,c.pick)((0,o.mapNotBlank)(e.Parameters,d.parseJSON)??{},"newValue","priorValue");if((0,c.isEmptyObj)(i))return v().tap({msg:"resourceEventToRevision() missing Parameter fields",result:void 0,meta:{resourceEvent:e}});const r=(0,y.datedToMillis)((0,w.parseDated)({input:e.When}));return null==r?v().tap({msg:"resourceEventToRevision() missing createdAt (When)",result:void 0,meta:{resourceEvent:e}}):(0,o.blank)(e.Action)?v().tap({msg:"resourceEventToRevision() missing op (Action)",result:void 0,meta:{resourceEvent:e}}):v().tap({msg:"resourceEventToRevision()",result:{createdAt:r,field:t,op:"assign"===e.Action?void 0:e.Action,...i},meta:{resourceEvent:e}})},t.revisionToResourceEvent=function(e){return{Action:e.op??"assign",Changed:e.field,InstanceID:(0,l.map)(e.id,f.toS),Parameters:(0,g.stringifySorted)((0,c.pick)(e,"newValue","priorValue")),SoftwareAgent:(0,m.AppNameVersion)(),When:r.ExifDateTime.fromMillis(e.createdAt??Date.now())}},t.MergedTags=class{constructor(e){this.name=e,this.revisions=[],this.tags=[],this.logger=(0,p.mkLogger)(`MergedTags(${e})`)}addRevision(...e){this.revisions.push(...e)}addTag(...e){this.tags.push(...e),(0,a.sortBy)(this.tags,(e=>[!P(e),-_(e)]))}get(e){const t=(0,a.sortBy)(this.revisions.filter((t=>t.field===e)),(e=>e.createdAt)),i=this.tags.find((t=>null!=t[e]));let r=i?.[e];const s=[];var l;null!=r&&(0,o.mapNotBlank)((l=i,l?.SourceFile??l?.uri),(e=>s.push(e)));const u=t.every(S)&&this.tags.every((t=>!Array.isArray(t[e])));if(u){for(const i of t)null!=r&&r!==i.priorValue&&r!==i.newValue?this.logger.info("get("+e+"): skipping revision because expected prior or new value didn't match current value",{revision:i}):(r=i.newValue,s.push(`Revision@${i.createdAt}`));return null==r?void 0:{value:r,source:s}}{const e=(0,h.toA)(r);for(const i of t)if("add"===i.op&&null!=i.newValue)s.push(`Revision@${i.createdAt}`),(0,n.pushUniq)(e,...(0,h.toA)(i.newValue));else if("delete"===i.op&&null!=i.priorValue){s.push(`Revision@${i.createdAt}`);for(const t of(0,h.toA)(i.priorValue))(0,n.remove)(e,t)}return{value:e,source:s}}}}},16170:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const r=i(22573),s=i(54993),n=i(2322),a=i(277),o=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function h(e){return(0,r.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function f(e){const t=(0,s.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,n.isChrome)(t)||(0,n.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,s.toS)(e))},t.isImageMimeType=function(e){return(0,s.toS)(e).startsWith("image/")},t.isVideoMimeType=h,t.normalizeMimetype=f,t.isSharpMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,r.blank)(t)&&(h(t)?await(0,l.isVideoSupported)():(0,o.isHeifMimeType)(t)?await(0,a.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},66039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderNameTag=t.parseName=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(55835),l=i(75020),u=i(59455),c=i(50213),d=i(68852),h=i(81168),f=i(70417),m=i(28874),p=(0,r.lazy)((()=>(0,c.mkLogger)("tags.Names")));function g(e){return(0,d.matchQuotes)((0,d.escapeRegExp)(e))}const y=/(\(\s*\d+\s*-\s*[\d?]{0,4}\s*\)?)/,w=/([,\s]+(?:jr\.?|junior|sr\.?|senior|[iv]+\.?))$/i,v=/\b([A-Z‘’']+[-A-Z‘’']{2})\b/,b=/^[()[\]/.\-_]+$/;function S(e){if((0,a.blank)(e))return;let t=e.replace(/\s+/g," ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").trim();const i=(0,o.map)((0,h.spliceCapture)(t,y),(e=>(t=e.unmatched.trim(),e.captured.replace(/\s+/g,"")))),r=(0,o.map)((0,h.spliceCapture)(t,w),(e=>(t=e.unmatched.trim(),e.captured.trim()))),l=[],c=[],b=[];for(const e of m.Settings.tagNamesGiven.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(l.push(i.captured),t=i.unmatched.trim())}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesGivenSurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`(${(0,d.escapeRegExp)(e.charAt(0))}\\s*[^${(0,d.escapeRegExp)(e.charAt(0))}]+\\s*${(0,d.escapeRegExp)(e.charAt(1))})`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(c.push(i.captured),t=i.unmatched.trim())}while(null!=i)}let S;function _(e){(null==S||S>e.matchedIndex)&&(S=(0,f.min)([S,e.matchedIndex]))}if(m.Settings.tagNamesCapitalizedAsFamily.valueOrDefault){let e;do{e=(0,h.spliceCapture)(t,v),null!=e&&(_(e),b.push(e.captured),t=e.unmatched.trim())}while(null!=e)}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesFamilySurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`${(0,d.escapeRegExp)(e.charAt(0))}\\s*([^${(0,d.escapeRegExp)(e.charAt(0))}]*)\\s*${(0,d.escapeRegExp)(e.charAt(1))}`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}while(null!=i)}if(m.Settings.tagNamesLexical.valueOrDefault){const e=t.indexOf(",");e>=0&&(S=void 0,b.push(t.substring(0,e).trim()),l.push(t.substring(e+1).trim()),t="")}for(const e of m.Settings.tagNamesSurnames.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}for(const e of(0,u.toA)((0,s.mapNotEmpty)((0,s.compactBlanks)(m.Settings.tagNamesSurnamePrefixes.values),(e=>(0,n.sortBy)(e,(e=>-e.length)).map((e=>new RegExp(`\\b(${g(e)}\\s+\\S+)`,"i"))))))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}null!=S&&t.length>S&&(0,s.mapNotEmpty)((0,s.compactBlanks)(t.slice(S).split(/\s+/)),(e=>{b.push(...e),t=t.slice(0,S)}));const T=(0,s.compactBlanks)(t.split(/\s+/)),M=l.length,E=b.length;if(T.length>0)if(0===M&&E>0)l.push(...T);else if(0===E&&M>0&&1===T.length)b.push(...T);else if(1===T.length)l.push(...T);else{const e="western"===m.Settings.tagNamesOrder.valueOrDefault;b.push(e?T.pop():T.shift()),l.push(...T)}return{givenNames:P([...l,...c]),modifier:r,lifespan:i,familyNames:P(b),minFamilyNameIndex:S}}function P(e){return(0,s.uniq)((0,s.compactBlanks)(e).filter((e=>null==b.exec(e))))}function _(e){let t="";for(const i of(0,s.compactBlanks)(e))t+=i.startsWith(",")?i:" "+i;return t.trim()}function T(e,t,i){return _("western"===m.Settings.tagNamesOrder.valueOrDefault?[t,e,i]:[e,t,i])}t.parseName=S,t.renderNameTag=function(e){if((0,a.blank)(e))return[];const t=m.Settings.tagNamesFormatter.valueOrDefault,i="family/given"===t;if("family/fullname"===t||i){const t=S(e);if(null==t)return[];{const e=_([t.modifier,t.lifespan]),r=_(t.givenNames);return(0,s.compactBlanks)((0,s.notEmptyOr)(t.familyNames,[m.Settings.tagNamesDefaultFamily.valueOrDefault])).map((t=>[l.TagRoots.Who,t,i?_([r,e]):T(t,r,e)]))}}return[[l.TagRoots.Who,e.trim()]]}},95141:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const r=i(21605),s=i(54993),n=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,n.isVideoMimeType)(e.MIMEType)?(0,r.normalizeRotation)(e.Rotation):void 0)??o(e.Orientation)};const a=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function o(e){return(0,r.isRotation)(e)?e:null!=e?a.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,s.toS)(e).startsWith("Mirror")},t.orientationToRotation=o;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,r.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,r.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const r=i(55835),s=i(31586),n=i(28874);function a(e){const t=(0,s.toInt)(e);return null==t?void 0:(0,s.clamp)(-1,5,t)}function o(e){return a(e?.Rating)??(0,s.mapNumeric)((0,s.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,r.map)(e?.favorited,(e=>!0===e?n.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=a,t.extractRating=o,t.extractLiked=function(e){const t=o(e);return null==t?void 0:t>=n.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(88561),o=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,r.lazy)((()=>new a.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,s.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,n.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,o.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),s=i(40958),n=i(22573),a=i(81168),o=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,a.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const o=(0,u.isJsonExt)(i.ext),l=o||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=o||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,s.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,s.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return o&&function(e,i){const r=(0,a.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function s(e){return(0,n.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const o=s(e.slice(r.length)),l=s(i.slice(r.length));return o&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,o.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,a.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(33374),o=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),h=i(34943),f=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),w=(0,r.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),v=(0,r.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:n.minuteMs})));async function b(e,t){if(null==e)return;const i=null==t||(0,s.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const r=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return S(i,r,await(0,h.rawInfo)(e));const n=S(i,r);if(null!=n)return n;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await b(await(0,f.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function S(e,t,i){t??(t=(0,y.extractRotation)(e));const r=(0,o.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,a.isDimensions)(e)?e:void 0));if(null==r)return w().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo,fileDimensions:r}});const s=(0,a.maybeDimSwap)(r,t);return w().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:s.height,ImageWidth:s.width,aspectRatio:(0,d.aspectRatio)(s),dimensions:s,rotation:t,fileDimensions:r,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return v().getOrSetAsync(i.nativePath,(()=>b(i,t)))},t.extractSizeInfoFromTags=S},3127:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tag_fts_path=t.tag_fts_root=void 0;const r=i(54993),s=i(42231);t.tag_fts_root=function(e){const t=(0,r.toS)(e).indexOf(s.TagSep);return-1===t?"":e.substring(0,t)},t.tag_fts_path=function(e){return(0,r.toS)(e).split(s.TagSep).filter((e=>null!=e&&""!==e.trim())).join(" ")}},61424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),h=i(48884),f=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),w=i(79842),v=i(21330),b=i(98725),S=i(51275),P=i(35280),_=i(19748),T=i(88561),M=i(95696),E=i(65238),D=i(17217),x=i(57902),k=i(28874),C=i(80496),F=i(65162),A=i(28544),I=i(47783),O=i(88840),L=i(30748),R=i(16170),N=(0,n.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),B=7;async function j(e){return k.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+k.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(k.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.auto&&await(0,E.isSlowDir)(e.nativePath)&&!await(0,E.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function z(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of r){const r=(0,L.extractMakeAndModel)(await(0,I.readRawTags)(t));if((0,f.definedAndNotEql)(r.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:r});else if((0,f.definedAndNotEql)(r.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:r});else if(null!=r.Make&&null!=r.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:x.LogLevels.info,result:r,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await j(e.parent()))return;const t=await W(e);return null!=t&&(0,v.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,v.toExifDateTime)(t.before.date,(0,S.getZoneName)(t.before.date)),(0,v.toExifDateTime)(t.after.date,(0,S.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,n.lazy)((()=>new T.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await H(e),i=await z(t?.younger),r=await z(t?.older);return null==i||null==r?void 0:{before:i,after:r,index:i.index,slots:i.index+r.index+1}}))}t.beforeAfterCapturedAt=W;const U=(0,_.extFilter)(O.ExtTypes.AssetFile);function q(e){return null==e?[]:(0,a.compact)((0,h.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function H(e,t=7,i=!0){if(!await j(e.parent()))return;const r=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(U(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==r)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const s=(0,o.sortBy)(r,(e=>(0,F.bname)(e))),n=(0,D.findFileIndex)(e,s);if(n<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),H(e,t,!1)):void 0;const l=k.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[s.slice(n-2*t,n),s.slice(n+1,n+1+2*t)],d=[],h=[];for(;(0,a.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,a.isNotEmpty)(c)&&h.length=l&&h.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:h},meta:{f:e}})}t.nearestSiblings=H,t.nearestSiblingTzOffset=async function(e){if(!await j(e.parent()))return;const t=q(await H(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,B);for(const t of e){const e=await(0,I.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==r.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,a.uniq)([(0,F.bname)(e,!0),(0,F.bname)(e,!1)]),i=(0,b.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const r=await e.stat();if(null!=r){for(const e of["birthtime","atime","mtime","ctime"])if((0,w.datedOverlap)({a:i,b:r[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:r}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:r}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,b.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const r=i[e];if(null!=r&&!0===(0,w.datedOverlap)({a:t,b:r}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:s.DateTime.fromJSDate(r)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),h=i(81168);function f(e){return(0,u.toS)((0,o.isString)(e)?e:e?.name).normalize()}function m(e){return(0,r.compact)((0,l.toA)(e).map(f))}function p(e,i=t.TagSep){return m(e).map((e=>(0,o.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(n.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function w(e){return(0,n.blank)(e)?void 0:Array.isArray(e)?f((0,r.last)(e)):(0,r.last)(g(e))}function v(e,t){if((0,r.isEmpty)(e)||(0,r.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,h.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=f,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,r.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,r.uniqBy)((0,l.toA)(e),(e=>(0,r.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,r.compact)(t).map((e=>y(e))));return(0,r.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=w,t.leafIsExcluded=function(e,t){return(0,a.mapOr)(w(e),(e=>(0,h.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=v,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,s.sortBy)(e.filter(r.isNotEmpty),(e=>-e.length)))t.some((e=>v(i,e)))||t.push(i);return(0,s.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const r=i(40958),s=i(22573),n=i(68708),a=i(54993);t.extractTitleDescription=function(e){const t=(0,r.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,s.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const r of i){const i=(0,a.toS)(e[r]).trim();if((0,s.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,n.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(96249),o=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),w=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function v(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function b(e){const t=await v(e);return(0,s.uniq)((0,a.flatten)(t.map(m.uriEncodingVariants)))}async function S(e,t){if((0,n.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void w().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case o.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case o.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case o.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,n.blank)(e)?w().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=v,t.nativePath2uriVariants=b,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(S(e,t),b))),(0,s.uniq)(i)},t.uri2nativePath=S,t.uriExists=async function(e,t){const i=await S(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),s=i(57975),n=i(90595),a=i(22573),o=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",w=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class v{static isUri(e){return e instanceof v||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,s,n=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,n),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=s??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,n))}get fsPath(){return M(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:s,fragment:n}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===s?s=this.query:null===s&&(s=g),void 0===n?n=this.fragment:null===n&&(n=g),t===this.scheme&&i===this.authority&&r===this.path&&s===this.query&&n===this.fragment?this:new S(t,i,r,s,n)}static parse(e,t=!1){const i=w.exec(e);if(!i)return new S(g,g,g,g,g);const r=i[2]||g,s=k(i[4]||g),n=(i[5]||g).split("/").map(k).join("/"),a="psfile"===r&&n.startsWith("//")?n.slice(1):n,o=(0,u.toURLSearchParams)(i[7]),l=k(i[9]||g);return new S(r,s,a,o,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new S("file",t,e,g,g)}static from(e){return new S(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?v.file(r.win32.join(M(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,o.map)(this.path,(e=>(0,d.findLast)(e.split(y),a.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return E(this,e)}toJSON(){return this}[s.inspect.custom](){return this.toString()}}t.URI=v;const b=h.isWinPortable?1:void 0;class S extends v{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=M(this,!1)),this._fsPath}toString(e=!1){return e?E(this,!0):(null==this._formatted&&(this._formatted=E(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=b),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,a.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function _(e,t){let i,r=-1;for(let s=0;s=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||45===n||46===n||95===n||126===n||t&&47===n)-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),void 0!==i&&(i+=e.charAt(s));else{void 0===i&&(i=e.substr(0,s));const t=P[n];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),i+=t):-1===r&&(r=s)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function T(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function E(e,t){const i=t?T:_;let r="";const{scheme:s,query:n,fragment:o}=e;let{authority:l,path:u}=e;if(s&&(r+=s,r+=":"),(l||"file"===s)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,a.mapNotBlank)(n,(e=>r+="?"+e)),o&&(r+="#",r+=t?o:_(o,!1)),r}function D(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+D(e.substr(3)):e}}t.encodeURIComponentFast=_,t.uriToFsPath=M;const x=/(?:%[\dA-Z][\dA-Z])+/gi;function k(e){return e.startsWith("xn--")?(0,n.toUnicode)(e):e.match(x)?e.replace(x,(e=>D(e))):e}t.percentDecode=k,t.toURI=function(e){return v.isUri(e)?e:v.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),s=i(40958),n=i(50357),a=i(89937),o=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",a.PS_LOCAL_FILE_SCHEME,a.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,o.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&f(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,n.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,s.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),s=i(22573),n=i(51926),a=i(89937),o=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,s.blank)(e))return;if(null==(t=null!=t&&(0,o.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,s.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,n.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:a.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==a.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,s.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,n=(0,s.notBlank)(t)&&!t.includes(i);if(n&&!(0,s.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const o=await(0,c.bestVolumeForVolsha)(e.authority);return null!=o?f(o.mountpoint,e.path):n&&(0,s.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),s=i(22573),n=i(51926),a=i(89937),o=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,s.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,s.blank)(t))return;const i=(0,r.uniq)([t,(0,o.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,n.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==a.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,o.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,n.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const a=n(i(76760)),o=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,o.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,o.notBlank)(t.remoteHost)&&(0,o.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:a.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,o.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,o.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(a.sep)}`;const s=i.slice(1),n=await(0,p.volumes)();for(const t of(0,u.toA)(n))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return a.join(t.mountpoint,...s);return await(0,h.isReadableDirectory)(t)?a.join(t,...s):void 0}},85087:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),s=i(42659),n=i(9103),a=i(37628);t.volsha=(0,n.memoize)((e=>(0,r.mapNotBlank)(e,a.shortStringSha)),{maxSize:128,ttlMs:s.minuteMs})},60865:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),s=i(30577);t.channel=function(){return(0,s.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),s=i(22573),n=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function a(e){if(e instanceof r.SemVer)return e.version;const t=n.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=a,t.semverSatisfies=function(e,t){if((0,s.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const n=a(e);return null!=n&&(0,r.satisfies)(n,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},8540:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),s=i(9595),n=i(29882),a=i(43334),o=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([o.Settings.libraryDir.valueOrDefault,(0,s.originalsDir)(),...o.Settings.scanPaths.values]))if((!a.isPosix||!(0,n.pathIsRoot)(t))&&(0,n.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},42233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentVolumeRoots=void 0;const r=i(45200),s=i(98770),n=i(7014);t.currentVolumeRoots=(0,s.lazyFsAsync)("currentVolumeRoots",(async function(){const e=[],t=[];for(const i of await(0,n.volumes)()){t.push(i.mountpoint);const s=(await(0,r.nativePath2uri)(i.mountpoint,i))?.toString();null!=s&&e.push(s)}return{uris:e,mountpoints:t}}))},1485:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),s=i(22573),n=i(59455),a=i(50213),o=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.DfPosix"))),w=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function v(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),s=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),n=t&&(i||r||s);return y().tap({msg:"acceptPosixVolume()",result:!n,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:s}})}t.acceptPosixVolume=v,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,n.toA)(await w());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,s.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,n.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,o.assignMissingPrimitives)(i,e))}return t.filter(v)}},69108:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,a.toInt)(e,{defaultValue:0})*o.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,s.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const s=m(e.Used)??0,n=m(e.Available)??0;if(0!==s||0!==n)return{filesystem:t,mountpoint:i,size:d.isMac?s+n:r,used:s,available:n};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:s,available:n})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,s.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,n.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const a=p(i);return!0===e&&a.forEach((e=>e.remote=!1)),a},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),w=i(24399),v=i(28874),b=i(24541),S=i(60224),P=i(63870),_=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const T=/([a-z]+)(?::\\)?/i;function M(e){return e?.match(T)?.[1]?.toUpperCase()}function E(e){return(0,l.map)(M(e),(e=>e+":\\"))}function D(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(M(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function x(e){return null!=e&&!(0,a.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,a.notBlank)(e.DisplayRoot),...(0,l.map)((0,S.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function k(e){return`Get-Volume ${(0,f.toS)(M(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=E,t.getPsDriveCommand=D,t.getVolumeCommand=k,t.getLocalVolumesWin_=function(){return w.PowerShell.instance().executeJsonToA(k())};const C=/\{([-a-z\d]{7,})\}/i;function F(e,t){return e=e?.trim(),(0,a.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function A(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void _().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=E(e.DriveLetter);if(null==t)return void _().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,s.compact)([F(e.HealthStatus,"healthy"),F(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,a.notBlank)(e.DriveLetter)&&(0,a.blank)(i);return _().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(n=e.UniqueId,_().tap({msg:"uniqueId2uuid",result:(0,l.map)(C.exec((0,f.toS)(n)),(e=>e[1])),meta:{s:n}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var n}async function I(){const e=(0,s.uniq)((0,h.toA)(await(0,b.mountpointsWin)()).map(E)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>w.PowerShell.instance().executeJsonToA(D(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:v.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,s.compact)((0,o.flatten)(t).map(x)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>w.PowerShell.instance().executeJsonToA(k(e)).catch((t=>(_().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:v.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),a=(0,s.compact)((0,o.flatten)(r).map(A)),l=(0,s.uniq)([...i,...a].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,n.sort)((0,s.uniq)([...i,...a].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));_().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:a,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...a.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=A,t.volumeInfoWin=I},68884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),w=i(83278),v=i(8103),b=i(16287),S=i(45969),P=i(43334),_=i(69108),T=i(98770),M=i(44224),E=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,S.isDocker)()||(0,d.isBillingService)()||null==await(0,v.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,E.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const D=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?D().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,M.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),b.isReadableDirectory),(e=>e.map((e=>w.BaseFile.for(e).clear().childDirectories())))))}):D().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,s.isEmpty)(e)?[]:(D().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,E.mountpointsTtlMs)(),f:async e=>{const t=await(0,_.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void D().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await x(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,E.mountpointsTtlMs)()}))),(0,o.later)((()=>(0,T.setupVolumeTTL)(t.gioVolumes)));const x=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,E.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,n.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(n.notBlank).get()}}catch(t){return void D().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs})},98770:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),s=i(5233),n=i(41400),a=i(56038),o=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,a.time)("volumes."+e,(()=>(0,s.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,o.isRetriableError)(e)&&!1!==(0,o.isIgnorableError)(e)})))),i);return(0,n.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),w=i(98770),v=i(63870),b=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>b().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>b().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const n=(0,c.sortIgnoreCase)((0,s.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),a=[];for(const t of n){const s=e.find((e=>e.mountpoint===t)),n=i?.find((e=>e.mountpoint===t)),o={...s,...n},u=r?.find((e=>e.filesystem===o.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(o,u),null==o.size||null==o.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];b().info("backfilling mountpoint",{info:n,vol:s,df:e}),null!=e&&(0,l.assignMissingPrimitives)(o,e)}a.push(o)}return a};const S=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return S.exec(e)?.[1]?.split(".").map((e=>(0,a.toInt)(e)))})),_=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,a.gte)(t[0],2)&&(0,a.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,w.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await _()],{timeoutMs:(0,v.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,n.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,a.toInt)(e.fsused),r=(0,a.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return b().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,w.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,v.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,n.toNotBlank)(e.PARTLABEL)??(0,n.toNotBlank)(e.LABEL),uuid:(0,n.toNotBlank)(e.PARTUUID)??(0,n.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),s=i(19851),n=i(40958),a=i(22573),o=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),w=(0,s.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,n.uniq)(e.map((e=>e.filesystem?.match(v)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),s=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of s)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,a.blank)(t.MountPoint)||(0,o.isTrue)(t.OSInternal)?w().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){w().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const v=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),w=i(84777),v=i(34330),b=i(8769),S=i(34102),P=i(17217),_=i(16287),T=i(43334),M=i(28874),E=i(8540),D=i(68884),x=i(44224),k=i(24541),C=i(69375),F=i(63870),A=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function O(e=(0,F.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function L(){I()}t.localMountpointSetup=(0,r.lazy)((async()=>{M.Settings.libraryDir.watchLater(I),M.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&M.Settings.scanAllDrives.valueOrDefault?(0,o.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(T.isMac&&(e.info("Setting up Mac diskutil activity watcher"),O((0,F.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),T.isLinux){const i=(0,x.maybeWatchProcMounts)();await(0,D.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),O((0,F.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),O((0,F.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),a.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=M.Settings.mountpoints.values;if((0,s.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",T.isWin?k.mountpointsWin:x.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,s.isEmpty)(e))return A().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,n.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,F.commandTimeoutMs)(),f:async e=>!(!(0,E.mightBeAssetMountpoint)(e)&&(0,C.isExcludedMountpoint)(e)||M.Settings.validateMountpoints.valueOrDefault&&!await(0,_.isReadableDirectory)(e)&&(A().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,b.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(T.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return T.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,o.later)((()=>{(0,S.ee)().on("clearCache",(()=>{D.gioVolumes.unset(),I()})),M.Settings.mountpointsTtlMs.watch(O)}),(0,c.isTest)()?1:a.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>L(),minCallDelayMs:1.5*a.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:D.GioCommand,args:D.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(D.gioVolumes.unset(),L()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const N=(0,r.lazy)((async()=>{if(!T.isLinux)return!1;try{return 0===(await(0,w.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,F.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>L(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(48884),o=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),w=i(28874),v=i(69108),b=i(68884),S=i(59107),P=i(69375),_=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await D()??await(0,c.thenMap)((0,v.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,b.isGioSupported)())try{await(0,c.thenMap)((0,b.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){_().warn("Failed to fetch gio volumes",e)}return e};const T="/proc/mounts";function M(e){return!w.Settings.excludedFilesystemTypes.has(e)}function E(e){return!(0,P.isExcludedMountpoint)(e)&&(!w.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function D(e=T,t=M,i=E){if(y.isLinux)try{const r=await(0,f.readLines_)(e),n=(0,s.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,a.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),o=await(0,c.filterAsync)({name:"mountpoints filter",arr:n,f:async([e,r])=>{const s=t(e),n=await i(r);return _().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:s&&n,meta:{fs:e,mp:r,fsOK:s,mpOK:n}})}});return _().tap({msg:"readProcMounts()",result:o.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void _().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=M,t.readProcMounts=D,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(T)?new h.FileWatcher(T,{recursive:!1,persistent:!1},(()=>{_().info("detected change in "+T),(0,d.setUnrefTimeout)((()=>S.mountpoints.refresh()),n.secondMs)})):void 0))},24541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),s=i(42659),n=i(13538),a=i(50213),o=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,n.thenOrTimeoutError)(f(),o.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*s.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(9103),o=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,n.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,s.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,o.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,o.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,o.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,o.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,s.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,a.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),s=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,n=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function a(e){if((0,r.blank)(e))return;const i=s.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(n,""),remoteShare:i.remoteShare};const a=t.nfsRe.exec(e);if(null!=a){const e=a[1],t=a[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=a(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=a},60224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(55835),o=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),w=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await M()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,a.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const v=["LocalName","RemoteName","Status"],b=["NETUSE","get",v.join(",")],S=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function _(e){if(!(0,s.blank)(e))return(0,o.opt)(e).flatMap((e=>S.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,o.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,s.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,o.opt)(e.pathname).filter(s.notBlank).getOrElse((()=>"/"))}))))).get()}async function T(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,b,{timeoutMs:15*n.secondMs}),i=(0,u.parseFixed)(v,t);return(0,r.compact)(i.map((e=>(0,a.map)(S.exec((0,l.toS)(e.RemoteName)),(t=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=_,t._netInfoWinWmic=T;const M=(0,w.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?T():(0,r.compact)(e.filter((e=>(0,s.notBlank)(e.LocalName))).map((e=>(0,a.map)(_(e.RemoteName),(({host:t,share:i})=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,h.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),s=i(12168),n=i(28874);t.mountpointsTtlMs=function(){return n.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return n.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return n.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=s.MiB/r.secondMs},86848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(38639),o=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),w=i(95696),v=i(45969),b=i(28874),S=i(59107),P=i(63870),_=i(68995),T=(0,s.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),M=(0,s.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function E(e){return(0,a.isTrue)(e.ignorable)||(0,v.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function D(e){if((0,n.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function x(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=D(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function k(e){if(b.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of b.Settings.volumeUuidFilePaths.values){const i=w.PosixFile.for(e.mountpoint).join(t),r=await x(i).catch((e=>T().info("Failed to read "+i,{error:e})));if(null!=r)return T().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,_.volumeUuidSubpath)());if("/"===e.mountpoint)return T().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(b.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return T().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(b.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,_.writeVolumeUuid)(e);if(!(0,n.blank)(t))return T().tap({msg:"readVolumeUUID(): wrote new "+(0,_.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return T().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,o.later)((()=>{(0,m.ee)().on("clearCache",(()=>M.clear())),S.mountpoints.watchLater((()=>M.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(E(e))return;if((0,a.isFalse)(e.ok))return;const t=await M().getOrSetAsync(e.mountpoint,(async()=>k(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>T().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=E,t.toVolumeUUID=D,t.readUuidFile_=x,t.readVolumeUUID=k},7014:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),w=i(59455),v=i(48884),b=i(50213),S=i(7282),P=i(23560),_=i(28850),T=i(45255),M=i(81168),E=i(56519),D=i(4867),x=i(49776),k=i(9595),C=i(77740),F=i(44198),A=i(96706),I=i(8769),O=i(57159),L=(i(34102),i(21144)),R=i(73209),N=i(29882),B=i(95696),j=i(17217),z=i(16287),V=i(49076),W=i(96128),U=i(45969),q=i(43334),H=i(28874),$=i(85087),G=i(50424),J=i(48165),K=i(98770),Y=i(27461),Z=i(66840),X=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,a.lazy)((()=>(0,b.mkLogger)("volumes.Volumes"))),se=s.default.platform(),ne=new Map,ae=new Map,oe=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,$.volsha)(t.uuid),(e=>ae.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,ne),le((0,$.volsha)(e.uuid),e,oe),e}function ce(){return(0,o.compact)([B.PosixFile.forMaybe((0,x.cacheDir)())?.join("volumes"),B.PosixFile.forMaybe((0,k.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),ae))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),ne.clear(),oe.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,E.mapAsync)({name:"readCachedVolumes",arr:(0,E.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,o.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,M.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),s=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:r,os:se}))),n=new Map;for(const e of s)for(const t of(0,o.compactBlanks)([(0,$.volsha)(e.uuid),(0,$.volsha)(e.mountpoint)]))n.set(t,e);const a=ce();for(const e of a)await(0,R.withLock_)({file:e,timeoutMs:T.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of n.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:a,vol_mountpoints:s.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,o.isNotEmpty)(e))return e;const i=(0,w.toA)(await(0,X.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,H.Settings.volumeMetadataTtlMs.valueOrDefault),s=0!==H.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),n=!(0,o.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:s,priorIsMissingMountpoints:n}),s||n?void 0:e}async function me(e,i){const r=(0,m.map)(e,j.toNativePath_);if((0,u.blank)(r))return;const s=await(0,L.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,o.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(s,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:s,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:s}})}async function pe(e,t,i){const r=i.filter((e=>(0,M.equalsIgnoreCase)(t,e.remoteShare)));if((0,o.isEmpty)(r))return;const s=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,M.equalsIgnoreCase)(e,t.remoteHost)));if(null!=s)return s;const n=await(0,W.friendlyname)(e);return(0,E.asyncFind)(r,(async e=>(0,M.equalsIgnoreCase)(n,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,a.lazy)((()=>(0,P.isSyncService)()||(0,S.isTest)())),t.priorWriteVolumesToCacheLatch=(0,a.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,a.lazy)((async()=>{const e=(0,o.compact)(await de()),t=(0,w.toA)(await(0,X.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,o.isNotEmpty)(i)?i:e.filter((e=>se===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,D.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,D.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,o.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,O.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,_.shim0)({name:"fs.volumes",impl:async function(){if((0,S.isTest)()){const e=(0,p.toInt)((0,F.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,C.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,D.thenOrTimeoutError)({p:q.isWin?(0,J.dfWin)():(0,G.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=H.Settings.validateMountpoints.valueOrDefault?(0,o.compact)(await(0,E.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,z.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,D.thenOrTimeoutError)({p:q.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(q.isWin?t:q.isMac?await(0,Z.addLocalVolumeInfoMac)(t):await(0,Y.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await he(r),Object.freeze(r)}}),t.rootPath=(0,a.lazy)((()=>q.isWin?(0,g.opt)((0,A.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,M.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,o.isEmpty)(t)?void 0:(0,v.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,o.commonPrefixLength)(e.split(n.default.sep),t.split(n.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,w.toA)(await i.vols()).find((t=>(0,$.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,E.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return oe.get(e)??(await de())?.find((t=>(0,$.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,$.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(50213),o=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,s.lazy)((()=>(0,a.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,n.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,f());t=(0,n.toNotBlank)(t)??(0,c.safeUUID)();const s=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(s))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+o.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},51140:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpStatusIs=t.HttpStatus=void 0;const r=i(31586);t.HttpStatus=Object.freeze({OK:200,Accepted:202,MovedPermanently:301,Found:302,SeeOther:303,BadRequest:400,Unauthorized:401,Forbidden:403,NotFound:404,EnhanceYourCalm:420,InternalServerError:500,NotImplemented:501,ServiceUnavailable:503}),t.HttpStatusIs=Object.freeze({ok:e=>(0,r.within)(200,299,e),success:e=>(0,r.within)(200,299,e),redirect:e=>(0,r.within)(300,399,e),clientError:e=>(0,r.within)(400,499,e),serverError:e=>(0,r.within)(500,599,e),error:e=>(0,r.within)(400,599,e)})},21404:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToTagPath=void 0;const r=i(75020),s=i(40958),n=i(22573),a=i(89937),o=i(34238);t.uriToTagPath=function({uri:e,isFile:t}){if(null==e)return;const i=(0,o.toURI)(e),l=i.scheme===a.PS_LIBRARY_SCHEME?r.LibraryTagName:i.scheme===a.PS_LOCAL_FILE_SCHEME?i.authority:void 0;if((0,n.blank)(l))return;const u=i.path.split("/");return(0,s.compactBlanks)([r.TagRoots.fs,l,...t?u.slice(0,-1):u])}},98604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkAssetUrl=t.mkFolderUrl=t.myWebUrl=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(27776),o=i(49076),l=i(72308),u=i(28874),c=i(42231),d=i(45200),h=i(34238),f=i(21404);function m(e=u.Settings.httpPort.valueOrDefault){const t=[u.Settings.localhost.valueOrDefault];u.Settings.exposeNetworkWithoutAuth.valueOrDefault&&t.push(...(0,s.compactBlanks)([(0,l.myExternalIp4Addresses)()[0],(0,o.hostname)()]));const i=(0,h.toURI)("http://a");return t.map((t=>i.with({authority:t+":"+e})))}t.default=m,t.myWebUrl=(0,r.lazy)((()=>m()[0])),t.mkFolderUrl=async function(e){const i=await(0,d.nativePath2uri)(e),r=(0,f.uriToTagPath)({uri:i,isFile:!1});if((0,s.isEmpty)(r))return;const n=(0,a.mkTagUri)((0,c.tagPathToStringArray)(r));return(0,t.myWebUrl)()?.with(n)},t.mkAssetUrl=function(e){return(0,n.gt0)(e)?(0,t.myWebUrl)()?.with({path:"/asset/"+e}):void 0}},4988:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.httpRequest_=t.get_=t.HttpMethods=void 0;const a=n(i(37067)),o=n(i(44708)),l=i(22573),u=i(45599),c=i(50989),d=i(51926),h=i(50213),f=i(45255),m=i(22911),p=i(43205),g=i(34238),y=i(51140),w=(0,u.defer)((()=>(0,h.mkLogger)("net.get")));async function v(e,t){return b({...t,url:e})}async function b(e){const t=(0,g.toURI)(e.url),i=new m.Deferred("get "+t.toString()),r="http"===t.scheme?a.request:"https"===t.scheme?o.request:w().throw("unsupported scheme: "+t.scheme),s=e?.maxRedirects??8,n=e?.timeoutMs??f.ShortCommandTimeoutMs,u={...e?.headers,"user-agent":await(0,p.userAgent)()},c=e?.method??"GET",h=e?.agent??!1,b=r(t.toString(),{method:c,headers:u,timeout:n,agent:h},(e=>{let r="";e.setEncoding("utf8").on("data",(e=>r+=e.toString())).resume().on("end",(()=>{const a={url:(0,l.toNotBlank)(e.url)??t.toString(),contentType:e.headers["content-type"],statusCode:e.statusCode??-1,data:r};s>0&&y.HttpStatusIs.redirect(a.statusCode)&&!(0,l.blank)(e.headers.location)?(console.log("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),w().info("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),i.observe(v(e.headers.location,{timeoutMs:n,maxRedirects:s}))):(w().debug("complete",{...a,data:(0,d.ellipsize)(r,64),data_length:r.length}),i.resolve(a))}))})).on("error",(e=>i.reject(e)));return(0,l.blank)(e.body)||b.write(e.body),b.end(),i}t.HttpMethods=(0,c.strEnum)("GET","PUT","POST","PATCH","DELETE"),t.get_=v,t.httpRequest_=b},65713:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),s=i(19851),n=i(23838),a=i(81168),o=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,s.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,s.lazy)((async()=>{const e=(0,o.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,s.lazy)((()=>({trie:new n.MultiMap,small:[]}))),h=3;function f(e){const t=new n.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=s)return s}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),s=i(96249),n=i(23838),a=i(59455),o=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=n.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,a.toA)(u[t])],n=c(e.substring(1));return(0,s.flatten)(n.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,o.stripDiacritics)(e).normalize())}},30933:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const s=r(i(48161)),n=i(19851),a=i(42659),o=i(31586),l=i(50213),u=i(28874),c=(0,n.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,n.lazy)((()=>s.default.cpus()),5*a.minuteMs),t.cpuCount=(0,n.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=s.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,o.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const s=r(i(48161)),n=i(19851),a=i(31586),o=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,n.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,n.lazy)((()=>{const e=s.default.freemem(),t=s.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,a.gt0)(r))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,o.fmtBytes)(i),freemem:(0,o.fmtBytes)(e),totalmem:(0,o.fmtBytes)(t)}})}))},69385:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOnResume=t._setPaused=t.resume=t.pause=t.isPaused=void 0;const r=i(34102),s=i(37692);let n=!1;function a(){return n}function o(e=!0){l(e),(0,s.writeStateFile)({paused:e})}function l(e){e!==n&&(n=e,(0,r.ee)().emit(e?"pause":"resume"))}t.isPaused=a,t.pause=o,t.resume=function(){return o(!1)},t._setPaused=l;const u=Promise.resolve();t.resolveOnResume=function(){return a()?new Promise((e=>{(0,r.ee)().once("resume",e)})):u}},15674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),s=i(42659),n=i(41400),a=i(31586),o=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,n.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const w=(0,r.lazy)((()=>{const e=(0,a.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*o.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/o.MB),worstCaseMemPerProcMb:Math.ceil(e/o.MB)}})}),s.minuteMs);function v(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,a.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function b(){return((0,a.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=v,t.targetCpuLoadPct=b,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(b()*(0,f.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(b()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=v();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const s=Math.min(e,w());return t=(0,a.clamp)(1,s,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:b(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:w()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,a.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,a.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,a.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},37692:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addStateEvent=t.writeStateFile=t.readStateFile=t.stateEvents=t.StateEvents=t.StateEventFns=void 0;const s=r(i(78474)),n=i(40958),a=i(76790),o=i(42659),l=i(45599),u=i(41400),c=i(68708),d=i(50989),h=i(87290),f=i(73787),m=i(19851),p=i(50213),g=i(28874),y=i(69385),w=(0,l.defer)((()=>(0,p.mkLogger)("work.SharedState")));let v;t.StateEventFns={checkTasks(){},reloadLicenses(){}},t.StateEvents=(0,d.strEnum)(...(0,c.keys)(t.StateEventFns)),t.stateEvents=new s.default;let b=0;function S(){const e=(0,h.libraryDataDirPosixFile)()?.join("state.json"),t=Date.now(),i=t-b>o.minuteMs;i&&(b=t);const r=e?.existsSync({refresh:i})??!1;return r&&null!=e&&e.eql(v?.nativePath)||(v?.close(),v=void 0),r&&null!=e&&(v??(v=new f.FileWatcher(e.nativePath,{encoding:"utf8",persistent:!1,recursive:!1},P))),e}(0,u.later)((()=>{g.Settings.libraryDir.watchLater(P)}));const P=(0,m.lazy)((()=>t.readStateFile.refresh()),25);t.readStateFile=(0,m.lazy)((()=>{const e=S()?.readJsonSync();for(const i of e?.events??[])_.get(i.e)!==i.ts&&(w().info("emitting event "+i.e),t.stateEvents.emit(i.e),_.set(i.e,i.ts));return(0,y._setPaused)(e?.paused??!1),e}));const _=new Map;function T(e){const i=S();if(null==i)w().error("overwrite(): failed: no library directory");else{const r=i?.readJsonSync(),s=function(e){const t=Date.now()-10*o.minuteMs;return(0,n.uniqByLast)((0,a.sortBy)((e??[]).filter((e=>e.ts>t)),(e=>e.ts)),(e=>e.e))}([...r?.events??[],...e.events??[]]),l={paused:e.paused??r?.paused??g.Settings.startPaused.valueOrDefault,events:s};(0,y._setPaused)(l.paused),t.readStateFile.set(l),i.writeJsonSync(l)}}t.writeStateFile=T,t.addStateEvent=function(e){const t=Date.now();_.set(e,t),T({events:[{e,ts:t}]})}},22751:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),s=i(87997),n=i(19851),a=i(42659),o=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,n.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,n.lazy)((()=>new r.Rate(5*a.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,n.lazy)((()=>(0,s.setInterval)(g,a.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,o.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),s=i(22573),n=i(50357),a=i(98553),o=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function w(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function b(e){return null==e?[]:w((0,h.toA)(e),(e=>null!=e))}function S(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,o.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const s=[];if(et;n-=i)s.push(r(n));return s}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=w,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),s=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===s[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,n.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const s of t){const t=i(s);r.includes(t)||(e.push(s),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return w(e,(e=>t.every((t=>!(0,n.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return w(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=b,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(s.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=b(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return S(t,(e=>(0,l.isPrimitive)(e)?e:(0,a.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,n.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=b(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=S,t.uniqByLast=function(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of b(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,a.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const s=new Set(i.map(r));return e.filter((e=>!s.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),s=i(36783),n=i(41801),a=i(98553),o=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,s.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const r of e)(0,o.getOrSet)(i,(0,a.stringify)(t(r)),(()=>r));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,s.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,n.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},75761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetImgAttrs=t.assetSqImgAttrs=t.assetVideoLink=t.assetImgActualLink=t.assetImgLink=t.assetLinkAttrs=t.assetUrl=void 0;const r=i(58939),s=i(40958),n=i(22573),a=i(42659),o=i(11371),l=i(73722),u=i(31586),c=i(54993),d=i(29652),h=i(22403),f=i(2322);function m(e,t){return e+" "+t+"w"}function p(e,t){let i=null==t?void 0:(0,d.mergeURLSearchParams)(...t);const r=(0,c.toS)(e.v);return(0,n.blank)(r)||"1"===r||(i??(i=new URLSearchParams)).append("v",r),i}function g({assetId:e,params:t}){return null==e?"":(0,d.assembleFullPath)("/asset/"+(0,r.id2id)(e),p(e,t))}function y({assetId:e,reducer:t,width:i,params:s}){return(0,d.assembleFullPath)(`/img/${(0,r.id2id)(e)}/${t}/${(0,u.toGt0)(i)??320}`,p(e,s))}function w({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/img/${(0,s.compact)([(0,r.id2id)(e),t]).join("/")}/actual`,p(e,i))}function v({assetId:e,params:t,reducer:i,widths:s,lazyLoad:n,af:l}){if(null==(0,r.id2id)(e))return{src:"/images/clear-64.png"};0===(s=(s??[]).filter(u.gt0)).length&&s.push(320);const d=Math.min(...s),p={width:(0,c.toS)(d)},g=(0,a.fmtLocalToShort)(e.capturedAtLocal);null!=g&&(p.title=g);const v=y({assetId:e,params:t,reducer:i,width:d});n??(n=!0);const b=n&&(0,f.isSafari)((0,h.ua)());b?(p.src="/images/clear-64.png",p["data-src"]=v):p.src=v,(0,f.isSafari)((0,h.ua)())||(p.loading=n?"lazy":"eager"),i===o.ReducerNames.sq&&(p.height=(0,c.toS)(d));const S=s.map((r=>m(y({assetId:e,params:t,reducer:i,width:r}),r)));return null!=l&&S.push(m(w({assetId:e,params:t,assetFileId:l.assetFileId}),l.width)),p[(b?"data-":"")+"srcSet"]=S.join(","),p}t.assetUrl=g,t.assetLinkAttrs=function({assetId:e,params:t}){const i=g({assetId:e,params:t});return(0,n.blank)(i)?{}:{href:i}},t.assetImgLink=y,t.assetImgActualLink=w,t.assetVideoLink=function({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/video/${(0,r.id2id)(e)}-${t}`,p(e,i))},t.assetSqImgAttrs=function({assetId:e,params:t,lazyLoad:i,size:r="m"}){return{...v({assetId:e,params:t,reducer:"sq",widths:l.SqWidths,lazyLoad:i}),sizes:("s"===r?80:"m"===r?160:320)*(0,u.numericOr)(globalThis?.window?.devicePixelRatio,1)+"px"}},t.assetImgAttrs=v},5233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),s=i(31586),n=i(13538),a=i(41583);t.retryOnReject_=async function(e,t){const i=(0,s.gt0)(t.timeoutMs)?()=>(0,n.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const o=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,a.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await o(l),u()}};return u()}},17586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55938),o=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,a.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,a.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,s.blank)(e)?"":"```"+(0,o.toS)(e)+"```"},t.b=function(e){return"**"+(0,o.toS)(e)+"**"},t.li=function(...e){return(0,r.compactBlankish)((0,n.flatten)(e)).map((e=>"- "+(0,o.toS)(e))).join("\n")}},22573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),s=i(42279),n=i(54993);function a(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function o(e){return!a(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,n.toS)(e);return o(i)?t(i):void 0}t.blank=a,t.notBlank=o,t.notBlankToS=function(e){return o(e)&&"undefined"!==e?(0,n.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,n.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,s.tot)(t);const i=(0,n.toS)(e).trim();return i.length>0?i:(0,s.tot)(t)},t.notBlankAnd=function(e,t){return!a(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,n.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{"use strict";function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),s=i(22573),n=i(30301),a=i(55835),o=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,a.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,o.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const s=Math.floor(e/t.minuteMs);e-=s*t.minuteMs;const n=Math.floor(e/t.secondMs),a=Math.floor(e-n*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(s)+":"+(0,l.pad2)(n)+(i.includeMs?"."+(0,l.pad3)(a):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function w(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),s=i(),n=i(),a=i(),o=i(),l=i();return new Date(t,l-1,o,a,n,s,r)}function v(){return(new Date).setHours(24,0,0,0)}function b(e,i="ago"){return e<1e3?"just now":(i=(0,s.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const n=Math.floor(e/r.ms);e-=n*r.ms,n>0&&(r.ms>=t.dayMs?i:s).push(n+r.s)}return e>0&&s.push((0,o.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(s)?"":"T"+s.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=w,t.fmtLocalToShort=function(e){return(0,a.map)(w(e),m)},t.nextMidnightTs=v,t.msUntilMidnight=function(){return v()-Date.now()},t.fmtAgo=function(e,t="ago"){return b(Date.now()-e,t)},t.fmtElapsedMs=b},95892:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),s=i(73872);function n(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function a(e,t,i,r){if(null==i||y(e)||y(t))return;let s=i.get(e);null!=s?s.set(t,r):(s=new WeakMap,s.set(t,r),i.set(e,s))}function o(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const s=l(e,t);return null!==s?s:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=n(e,t,u);if(null!==f)return f;const m=n(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return a(e,t,u,i),i;const s=l(e,t);if(null!==s)return s}const y=s(e);if(y!==s(t))return a(e,t,u,!1),!1;a(e,t,u,!0);const w=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return o(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],s=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){s.push([e,t])})),c(r.sort(),s.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return a(e,t,u,w),w}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let s=-1;for(;++s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const s=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return s.prior=()=>t,s.hasPrior=()=>r,s}},41400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),s=i(35556),n=i(31586),a=i(68708);function o(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const n=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&s.isNode&&n.unref?.()}}))}t.delayUntil=function(e){const t=((0,n.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return o(t).then((()=>t))},t.delay=o,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),n=s.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return s.isBrowser||t<=r.secondMs?n:(0,a.maybeCall)(n,"unref")??n}},33374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const r=i(31586),s=i(21605),n=i(12168);function a(e){return{width:e.height,height:e.width}}function o(e){return((0,r.toGt0)(e?.width)??0)*((0,r.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,r.gt0)(e.width)&&(0,r.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,r.gt0)(e)&&(0,r.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,n.pixels2size)(e.width*e.height)},t.dimSwap=a,t.maybeDimSwap=function(e,t){return(0,s.swappableRotation)(t)?a(e):e},t.maybeFlipInPlace=function(e,t){(0,s.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,n.megapixels)(o(e))},t.pixels=o},50357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),s=i(68708),n=i(34666),a=i(32639);function o(e,t){return(0,r.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,a.isFunction)(e)&&(0,a.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=o,t.eqlSubset=function(e,t){if(null==e||null==t||(0,n.isPrimitive)(e)||(0,n.isPrimitive)(t))return e===t;if(!(0,s.isObject)(e)||!(0,s.isObject)(t))return!1;for(const i of(0,s.keys)(e))if(!o(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(31586),o=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,s.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,a.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,n.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,s.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,s.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,s.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(s.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,o.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,o.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,o.assignFields)(new Error,(0,o.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},4188:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),s=i(42659),n=i(55835),a=i(31586),o=i(12168),l=[{ms:s.yearMs,s:"year",p:"years"},{ms:s.yearMs/12,s:"month",p:"months"},{ms:s.weekMs,s:"week",p:"weeks"},{ms:s.dayMs,s:"day",p:"days"},{ms:s.hourMs,s:"hour",p:"hours"},{ms:s.minuteMs,s:"minute",p:"minutes"},{ms:s.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,s){if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,n.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,o.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,n.mapOr)(s,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function s(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=s,t.orList=function(e){return s(e,"or")},t.andList=function(e){return s(e,"and")}},50268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const r=i(22573),s=i(38639),n=i(68708),a=i(62220),o=i(50989);t.HealthCheckSections=(0,o.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,o.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,n.isObject)(e)&&!(0,r.blank)(e.id)&&!(0,r.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,r.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,n.isObject)(e)&&a.RunStates.has(e.state)&&(0,s.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},11371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReducerNames=void 0;const r=i(50989);t.ReducerNames=(0,r.strEnum)("fit","sq")},73722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const s=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,s){if((0,isFunction_1.isFunction)(r))return;let n,a,o,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(n=0;nnew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),s=i(50357),n=i(31586),a=i(65812);t.lazy=function(e,t){let i,o;const l=[];function u(){return u.isStale()&&u.setResult(e()),o}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const n=await e,o=await i;if(!(0,s.eql)(n,o))for(const e of l)e(o);null!=t&&t>0&&void 0!==o&&(0,a.setUnrefTimeout)((()=>u.vacuum()),t)}(o,e),o=e},u.isStale=function(){return null==i||(0,n.gt0)(t)&&i+t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),s=i(54993);function n(e,t){return null==e?void 0:t(e)}function a(e,t,i){return null==e||null==t?void 0:i(e,t)}function o(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=n,t.mapTry=function(e,t){try{return n(e(),t)}catch{return}},t.map2=a,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=o,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return o(a(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,s.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class s extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=s},23838:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),s=i(76790),n=i(50357),a=i(98553),o=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,o.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,o.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,n.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),s=null==i?[]:e(t,i);(0,r.isEmpty)(s)?this.store.delete(t):this.store.set(t,s)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,s]of this.store.entries()){const n=(0,r.findIndexes)(s,(t=>!e(i,t,s)));if(n.length>0){t=!0;for(const e of n.reverse())s.splice(e,1)}0===s.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,a.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,s.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),s=i(22573),n=i(42279),a=i(54993);function o(e){return"number"==typeof e&&isFinite(e)}t.isNumber=o,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,a.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return o(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,a.toS)(e).match(u)&&null!=w(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>o(t)&&o(i)&&e(t,i);function f(e,i,s){return!(null==s||!o(s))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,s)&&(0,t.gte)(i,s))}function m(e){if(!o(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,s.blank)(e))return t.defaultValue;if(o(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function w(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function v(e){return o(e)&&e>0}function b(e){return o(e)&&e>=0}function S(e,t){return o(e)?t(e):void 0}function P(e){return o(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function T(e,t,i){if(e>t||!o(e)||!o(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return o(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return o(e)?e:t},t.diff=function(e,t){return o(e)&&o(t)?e-t:void 0},t.absdiff=function(e,t){return o(e)&&o(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!o(e)||!o(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return f(t-r,t+r,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)o(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=w(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return o(e)&&e<0},t.gt0=v,t.firstGt0=function(...e){for(const t of e){if(v(t))return t;const e=y(t);if(v(e))return e}},t.gtOrElse=function(e,t){return o(e)&&o(t)&&e>t?e:void 0},t.lte0=function(e){return o(e)&&e<=0},t.gte0=b,t.toGte0=function(e){return b(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=w(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return v(t)?String(t):void 0},t.mapNumeric=S,t.map2Numeric=function(e,t,i){return S(e,(e=>S(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return o(e)?t(e):i},t.numericOr=function(e,t){return o(e)?e:(0,n.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return S(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d+\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!o(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=T,t.times=function(e,t){if(!v(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return T(0,100,v(t)?P(100*(v(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!o(i))return;t+=i}return t}},68708:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(32639),o=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function w(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function v(e,t,i={}){return y((0,r.compact)((0,s.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function b(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const s={};for(const e of(0,r.uniq)((0,r.flatMap)(i,h)))s[e]=b(...i.map((t=>t[e])));return s}function S(e,t){if(!d(e)||(0,n.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=w(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,s]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==s&&!0!==i?.assignNullish||(e[r]=s));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=w,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,o.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,n.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=v,t.mergeObjectsDeep=b,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,n.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=o.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function s(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:b(i,t)}for(const r of i){const[i,a]=(0,c.splitFirst)(r,"."),o=S(t,i);null!=o?.value&&s(o.key,(0,n.blank)(a)?o.value:e(o.value,a))}for(const r of h(t))((0,l.toInt)(r)??-1)>=0&&s(r,e(t[r],...i));return r},t.pluck=S,t.pluckDeep=function e(t,i){if(null==t||(0,n.blank)(i))return;if(Array.isArray(t)){const s=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(s)?void 0:{key:s[0].key,value:(0,r.flatMap)(s,(e=>e.value))}}const[s,a]=(0,c.splitFirst)(i,"."),o=S(t,s);if(null==o)return;if((0,n.blank)(a))return o;const l=e(o.value,a);return null==l?void 0:{key:o.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,n.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,a.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,n.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=v(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>n(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return s(t)?t:n(t)}filter(e){return n(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return n(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return n(e).flatMap((e=>n(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return n(e).flatMap((e=>n(t).flatMap((t=>n(i).flatMap((i=>r(this.a,e,t,i)))))))}}function s(e){return e instanceof r||e===t.None}function n(e){return s(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=s,t.opt=n},97238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSeed=t.prngSeed=t.SeedCount=t.PrimeBins=t.PrimesPerBin=void 0;const r=i(31586),s=i(30976),n=i(54993);t.PrimesPerBin=4,t.PrimeBins=8,t.SeedCount=t.PrimesPerBin**t.PrimeBins,t.prngSeed=function(){return(0,s.randomInt)(0,t.SeedCount)},t.toSeed=function(e){const i=(0,r.toInt)((0,n.toS)(e));return(0,r.within)(0,t.SeedCount,i)?i:void 0}},39926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),s=i(54993),n={};function a(e,t){if(t<1)return"";if(!(0,r.gte)(n[e]?.length,t)){let i=n[e]??e;for(;i.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var r=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return r.parseJSON}})},46891:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),s=new Map([["child","children"],["photo","photos"],["video","videos"]]),n=/([sxz]|ss|sh|ch)$/,a=/[^aeiou]y$/,o=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=s.get(e);return null!=t?t:null!=e.match(n)?e+"es":null!=e.match(a)?e.replace(/y$/i,"ies"):null!=e.match(o)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),s=i(54993),n=["number","string","boolean"];function a(e){return-1!==n.indexOf(typeof e)}t.isPrimitive=a,t.mapPrimitive=function(e,t){return a(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return a(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(a)};const o=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,n=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==n&&"symbol"!==n)){const r=(0,s.toS)(e),n=(0,s.toS)(i),a=r.localeCompare(n);return r[0]===t.CmpReverseFlag&&n[0]===t.CmpReverseFlag?-a:a}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==n?o.indexOf(r)-o.indexOf(n):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function s(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const s of(0,r.toA)(await e))if(null!=s){const e=await s;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=s,t.isPromise=function(e){return s(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),s=i(31586);function n(e,t){return Math.floor(Math.random()*(t-e))+e}function a(e,t,i){return null==i||0===i.length?n(e,t):o(e,t,1,i)[0]}function o(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const s=t-e,a=new Set(r??[]);if(t===e&&0===s&&0===a.size&&1===i)return[e];const o=s-a.size;if(i>o)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:s,size:i,slotsRemaining:o})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of o(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,s.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let r=e;t.global||(t=new RegExp(t,"g"));let s=null;for(;null!=(s=t.exec(e));)s.index===t.lastIndex&&t.lastIndex++,r=r.slice(0,s.index)+i(s)+r.slice(s.index+s[0].length);return r}},21605:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const r=i(31586);function s(e){if(!(0,r.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,r.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=s,t.swappableRotation=function(e){const t=s(e);return 90===t||270===t}},62220:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const r=i(50989);t.RunStates=(0,r.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),s=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),n={};for(const e of t)n[e]=e;const a=e=>null!=e?i[e]:void 0,o=e=>null!=a(e);return{...n,values:t,length:t.length,has:o,includes:o,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:a,ordinal:e=>a(e)??t.length,validOrElse:(e,t)=>o(e)?e:(0,s.tot)(t),mapValid:(e,t)=>o(e)?t(e):void 0,cmp:(e,t)=>{const i=a(e),r=a(t);return null==i||null==r?void 0:i>r?1:i{const i=a(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),s=i(17586),n=i(22573),a=i(96249),o=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=f();return null!=r?(0,o.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function b(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function S(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),s=(0,c.toS)(t);return r.length===s.length&&(r===s||r.toLowerCase()===s.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?s.normalize():s,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,n.blank)(t)?void 0:e.find((e=>S(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,s.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,o.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=w,t.ensureSuffix=v,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return v(w(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=b,t.wrap=function e(t,i){const r=i?.maxLineLen??80,s=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,a.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,a.flatten)(r.map((t=>e(t,i))))}if((t=w((0,c.toS)(t),s).trim()).length<=r)return[t];const n=b(t," ",r);if(n>s.length)return[m(t,0,n),...e(m(t,n+1),i)];{const r=t.indexOf(" ",s.length+1);return r>0&&r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),s=i(68708),n=i(42279),a=i(83104),o=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let s=!0;const n=setTimeout((()=>{s&&(s=!1,i(a.Timeout))}),t);try{n.unref?.();const t=await e;s&&(s=!1,i(t))}catch(e){s&&(s=!1,r(e))}finally{clearTimeout(n)}}))}async function u(e,t,i=!0){const s=await l(e,t,i);if(s===a.Timeout)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return s}t.toNotTimeout=function(e){return e===a.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?a.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,n)=>{let a=!0;try{const o=setTimeout((async()=>{if(a){a=!1;try{r(await i())}catch(e){n(e)}}}),t);(0,s.maybeCall)(o,"unref");const l=await e;a&&(a=!1,clearTimeout(o),r(l))}catch(e){a&&(a=!1,n(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const s=t-Date.now();if(s<=0)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(s)+")");return u(e,s,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const s=await l(e,t,r);return s===a.Timeout?(0,n.tot)(i):s}},42279:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),s=i(22573),n=i(54993);function a(e){return"URLSearchParams"===e?.constructor?.name}function o(e){return null==e?void 0:a(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(o)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=a,t.toURLSearchParams=o,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,n.toS)(l(...t));return e+((0,s.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,n.toS)(l(...t));return(0,s.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),s=i(30301),n=i(31586),a=i(46891),o=i(50989),l=i(51926),u=(0,s.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,n.isNumber)(r)&&(i+=r/t.MB);return(0,n.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,n.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,n.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),s=Math.pow(10,3*r),a=d[r];return(0,n.sigFigs)(e/s,t)+" "+a}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),s=Math.pow(2,10*r),a=h[r];return(0,n.sigFigs)(e/s,t)+" "+a},t.MP=1e6,t.megapixels=function(e){return(0,n.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,o.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,a.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,a.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},22403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ua=void 0;const r=i(30301),s=i(54993);t.ua=(0,r.lazy)((()=>(0,s.toS)(globalThis?.navigator?.userAgent)))},2322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,r=/\bSafari\b/,s=/\bFirefox\b/,n=/\biPad\b/,a=/\biPhone\b/;function o(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return o(e,i)}function u(e){return o(e,s)}t.isChrome=l,t.isSafari=function(e){return o(e,r)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return o(e,n)},t.isIphone=function(e){return o(e,a)}},58939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.idEql=t.id2id=void 0;const r=i(55835),s=i(31586);function n(e){const t=e;return(0,s.isNumber)(e)?e:(0,s.isNumber)(t.id)?t.id:(0,s.isNumber)(t.assetId)?t.assetId:(0,s.isNumber)(t.tagId)?t.tagId:void 0}t.id2id=n,t.idEql=function(e,t){return(0,r.map2Or)(n(e),n(t),((e,t)=>e===t),(()=>!1))}},79114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.S=void 0;const r=i(50989);t.S=(0,r.strEnum)("plus","lite")},75020:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInfoTag=t.NotInfoPanelTags=t.LibraryTagName=t.TagRoots=t.isTagRef=t.ctxToS=t.TagGalleryProps=t.nextChildTagsUrl=t.nextAssetsUrl=t.BeforeAfterStreamLimit=t.ThumbsPerSample=void 0;const r=i(76790),s=i(22573),n=i(98553),a=i(31586),o=i(50989),l=i(51926),u=i(29652);t.ThumbsPerSample=128,t.BeforeAfterStreamLimit=8,t.nextAssetsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/assets`,i)},t.nextChildTagsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.seed,(e=>i.seed=e.toString())),(0,a.mapNumeric)(t.limit,(e=>i.limit=e.toString())),(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/child-tags`,i)},t.TagGalleryProps=["tagId","tagPath","assetCount","assetIds","nextAssets","childTags","nextChildTags"],t.ctxToS=function(e){return(0,n.stringify)({seed:e.seed,tagIds:(0,r.sort)([...e.tagIds])})},t.isTagRef=function(e){return null!=e&&!(0,l.isString)(e)&&(0,s.notBlank)(e.name)},t.TagRoots=(0,o.strEnum)("When","Who","Where","What","Camera","Lens","Albums","Keywords","Type","fs"),t.LibraryTagName="Library",t.NotInfoPanelTags=[t.TagRoots.When,t.TagRoots.Camera,t.TagRoots.Lens,t.TagRoots.Type,t.TagRoots.fs],t.isInfoTag=function(e){if(null==e)return!1;const i=(0,l.isString)(e)?e:e.tagPath?.[0];return!t.NotInfoPanelTags.includes(i)}},27776:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkTagUri=t.mkTagFullPath=t.mkHomeFullPath=t.urlSeed=void 0;const r=i(40958),s=i(30301),n=i(31586),a=i(97238),o=i(29652);function l(e,i){const r=(0,o.toURLSearchParams)(e);if(i||!(0,n.isDigits)(r?.get("seed"))){const e=(0,t.urlSeed)().toString();return r?.set("seed",e),r??{seed:e}}return r}function u(e,t,i=!1){const r=c(e,t,i);return(0,o.assembleFullPath)(r.path,r.query)}function c(e,t,i=!1){return{path:"/tag/"+((0,r.isEmpty)(e)?"":e.map(encodeURIComponent).join("/")),query:l(t,i)}}t.urlSeed=(0,s.lazy)(a.prngSeed,100),t.mkHomeFullPath=function(e){return u([],e,!0)},t.mkTagFullPath=u,t.mkTagUri=c},23541:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),s=i(51926);function n(e){return Array.isArray(e)?e:null==e?void 0:(0,s.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return n(e)??[]},t.optToA=n},41583:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),s=i(23541),n=i(59455),a=i(54993);function o(e){return null==e?void 0:(0,s.isError)(e)?e:new Error((0,a.toS)(e))}t.toErr=o,t.toErrs=function(...e){return(0,r.compact)((0,n.toA)(e).map(o))}},54993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return n(e,",")};const s={}.toString;function n(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>n(e,t))).join(t):e.toString!==s?e.toString():(0,r.stringify)(e)}}t.toStr=n},64526:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Library=void 0;const l=i(27395),u=i(25764),c=i(38836),d=i(99331),h=i(45608),f=i(15056),m=i(87290),p=i(38835),g=i(57159),y=i(61704),w=i(95696),v=i(18454),b=i(13940),S=i(48604),P=i(19851),_=i(23560),T=i(28874),M=i(2858),E=i(7014),D=i(63870),x=i(15674),k=i(22573),C=i(38639),F=i(42659),A=i(56409),I=i(68708),O=i(25470),L=i(22526),R=i(41844);class N extends c.EndableWrapper{static instance(){const e=T.Settings.libraryDir.valueOrDefault,t=a(this,r,"f",s)?.rootDir.nativePath,i=!0===a(this,r,"f",s)?.isReadySync(),n=!0===a(this,r,"f",s)?.ended;return(0,y.nativePathsEqlSync)(t,e)&&!n?a(this,r,"f",s):(0,_.isSyncService)()&&i?void(0,h.exit)({reason:`Library changed mid-run. Shutting down to pick up new library at ${e}.`,status:0}):((0,l.end)(a(this,r,"f",s)),o(this,r,(0,k.blank)(e)||!(0,M._libraryHasSettings)(e)?void 0:new r(e),"f",s))}static get priorInstance(){return a(this,r,"f",s)}static endPriorInstance(){const e=a(this,r,"f",s);return o(this,r,void 0,"f",s),(0,l.end)(e)}static async instanceReady(){const e=r.instance();return await(e?.ready),e}static instanceRequired_(){const e=r.instance();if(null==e)throw new Error("Library is undefined"+p.FatalErrorFlag);return e}constructor(e){super(`library.Library(${e})`,(()=>this.onEnd()),u.EndableRanks.predb),this.start=Date.now(),this.readyLatch=new A.Latch,n.set(this,(0,P.lazy)((async()=>{try{this.logger.debug("setup() started"),this.logger.throwIfAborted_(),await(0,M.readLibrarySettings)(this.rootDir.nativePath),await(0,m.setupLibraryDirs_)(this.rootDir),await(0,b.imageCacheDir_)(),this.logger.throwIfAborted_();const e=await(0,E.bestVolumeForPath)((0,m.libraryPreviewsDirPosixFile)(this.rootDir));if((0,C.isTrue)(e?.remote)){const e=T.Settings.maxConcurrentImportsWhenRemote.valueOrDefault;T.Settings.maxConcurrentImports.hasValue()||(T.Settings.maxConcurrentImports.tmpValue=e,(0,x.clearMaxWorkCaches)()),this.logger.warn(`Library previews are on a remote volume. Setting maxSyncFileJobsMax to ${e}.`)}this.logger.throwIfAborted_(),(0,_.isDbService)()&&await this.dbModelJanitor(),this.previews(),this.logger.throwIfAborted_(),this.readyLatch.isPending()&&(this.logger.info("Library.setup() finished."),this.readyLatch.resolve())}catch(e){this.ended||(0,d.ending)()||(this.logger.warn("setup() failed:",{error:e}),v.HealthCheck.addError(e),this.readyLatch.reject(new g.WrappedError("Failed to start library",{cause:e})))}}))),this.previews=(0,P.lazy)((()=>(0,I.tap)(new S.Previews((0,m.libraryPreviewsDirPosixFile)(this.rootDir)),(e=>S.Previews.instance.set(e))))),this.originalsDir=(0,P.lazy)((()=>(0,m.libraryOriginalsDirPosixFile)(this.rootDir))),this.assetFileRepository=(0,P.lazy)((()=>new R.AssetFileRepository(this.originalsDir()))),this.libraryDbFile=(0,P.lazy)((()=>(0,f.pathToDb)(this.dataDir,"models"))),this.dbModelSetup_=(0,P.lazy)((async()=>{if((0,_.isDbService)())return(0,L.dbModelSetup_)(this.rootDir);throw new Error("Not a db service")})),this.dbFsLock=(0,P.lazy)((async()=>(await this.dbModelSetup_()).fslock)),this.useReplica=(0,P.lazy)((async()=>(await this.dbModelSetup_()).useReplica)),this.modelDb=(0,P.lazy)((async()=>(await this.dbModelSetup_()).db)),this.dbModelJanitor=(0,P.lazy)((async()=>O.DbModelJanitor.for(await this.dbModelSetup_()))),this.onEnd=(0,P.lazy)((async()=>{if(!(0,d.ending)())for(const{ea:e,t}of[{ea:this.dbModelJanitor.clear(),t:5*F.minuteMs},{ea:this.dbFsLock.clear(),t:(0,D.commandTimeoutMs)()}])await(0,l.end)(e,t);this.logger.info("onEnd(): finished.")})),this.rootDir=w.PosixFile.for(e),this.dataDir=(0,m.libraryDataDirPosixFile)(this.rootDir),this.logger.info("new()"),a(this,n,"f").call(this)}get isPendingSetup(){return this.readyLatch.isPending()}get ready(){return this.readyLatch.promise.then((()=>this))}isReadySync(){return this.readyLatch.isResolved()}async runDbBackup_(){return(await this.dbModelJanitor())?.backup_()}}t.Library=N,r=N,n=new WeakMap,s={value:void 0}},19113:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFileFiltersFor=void 0;const r=i(62105),s=i(181),n=i(94448),a=i(39604);t.libraryFileFiltersFor=function(e,{validateFile:t=!1}={}){const i=(0,r.expensiveFileFiltersFor)(e);return null!=(0,n.modelDb)()&&i.push({notBlocklistedSha:a.notBlocklistedSha}),t&&i.push({isValidFile:s.isValidFile}),i}},18449:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sentryEnabled=void 0;const r=i(7282),s=i(96706),n=i(29325),a=i(28874);t.sentryEnabled=function(){return(0,s.isEnvTrue)("ENABLE_SENTRY")||(0,r.isProd)()&&(0,n.isPacked)()&&!0===a.Settings.reportErrors.value}},95629:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelToSeverity=t.logEntryToBreadcrumb=t.mkBreadcrumbs=t.annotateEvent=t.sentryExceptionToS=t.sentryExceptionsToS=t.extractMessage=t.EventFilter=t.eventFilter=t.sendToSentry=t.installSentry=void 0;const o=n(i(16436)),l=a(i(48161)),u=a(i(1708)),c=i(19851),d=i(19043),h=i(50213),f=i(31578),m=i(7282),p=i(96175),g=i(23560),y=i(84968),w=i(81168),v=i(37805),b=i(25764),S=i(38836),P=i(99331),_=i(85100),T=i(98314),M=i(68301),E=i(70025),D=i(8769),x=i(34102),k=i(34592),C=i(42042),F=i(34474),A=i(20839),I=i(57902),O=i(45969),L=i(43334),R=i(40958),N=i(22573),B=i(42659),j=i(41400),z=i(98553),V=i(55835),W=i(12168),U=i(59455),q=i(54993),H=i(18449),$=(0,c.lazy)((()=>(0,h.mkLogger)("Sentry")));function G(e){(0,H.sentryEnabled)()&&null!=e&&!0!==(0,E.isDoNotSendError)(e)&&o.captureException(e)}t.installSentry=async function(e){try{return!!(0,H.sentryEnabled)()&&(o.init({dsn:L.isElectron?"https://0652cdd351054fe9853ff944b1f54e2c@o130922.ingest.sentry.io/289071":"https://5f52aefec1b3439eaed2e77b2d1210a8@o130922.ingest.sentry.io/1828379",shutdownTimeout:(0,_.serviceExitTimeoutMs)(e.name),release:v.release,environment:(0,m.nodeEnv)(),maxBreadcrumbs:100,integrations:[],beforeSend:(0,t.eventFilter)().beforeSend,onFatalError:e=>(0,D.onError)("sentry.onFatalError",e)}),$().info("Sentry initialized",{isElectron:L.isElectron}),!0)}catch(e){return $().warn("Failed to set up sentry",{error:e}),!1}},t.sendToSentry=G,t.eventFilter=(0,c.lazy)((()=>new J));class J{constructor(){this.beforeSend=async(e,t)=>{if(!(0,H.sentryEnabled)())return $().warn("Sentry.beforeSend(): not sending event",e),null;if(!0===await(M.ErrorStore.instance()?.eventQuotaExceeded(e)))return $().warn("Sentry.beforeSend(): event quota exceeded",e),null;const i=K(e,t);if(!0===(0,E.isDoNotSendError)(i))return $().info("Sentry.beforeSend(): event not sendable. vetoing",{event:e,hint:t,msg:i}),null;(0,N.blank)(e.message)&&(e.message=(0,w.ellipsize)(i,256));const r=await X(e);return await(M.ErrorStore.instance()?.maybeSendEvent(r))??null},(0,x.ee)().on("fatal",G),(0,x.ee)().on("nonFatal",G),new S.EndableWrapper("EventFilter",(()=>this.end()),b.EndableRanks.first)}end(){return(0,V.map)(o.getCurrentHub().getClient(),(e=>e.close(5*B.secondMs)))}}function K(e,t){return(0,R.uniq)((0,R.compactBlankish)([e.message,...(0,U.toA)(Y(e.exception?.values)),(0,T.errorToS)(t?.originalException)])).join(": ")}function Y(e){return(0,R.mapNotEmpty)(e,(e=>(0,R.compactBlanks)(e.map(Z))))}function Z(e){return(0,R.mapNotEmpty)((0,R.compactBlanks)([e?.type,e?.value].filter((e=>"error"!==(0,q.toS)(e).toLowerCase()))),(e=>e.join(": ")))}async function X(e){const t=await(0,C.getEmail)();(0,N.notBlank)(t)&&(null==e.user&&(e.user={}),e.user.email=t),(0,R.isEmpty)(e.breadcrumbs)&&(e.breadcrumbs=await Q());const i=e.extra??{};return i.pid=u.default.pid,i.serviceName=(0,g.serviceName)(),i.serviceEnding=(0,P.ending)(),i.runtimeMs=(0,y.runtimeMs)(),i.version=v.version,i.os=(0,p.osFullName)(),i.isDocker=(0,O.isDocker)(),i.nodeVersion=u.default.versions.node,i.locale=await(0,d.locale)(),i.cpus=(0,p.CPUs)(),i.memoryUsageMb=(0,f.memoryUsageMb)(),i.memoryUsageRssMb=(0,f.memoryUsageRssMb)(),i.systemMemory=(0,W.fmtBytes)(l.default.freemem())+" / "+(0,W.fmtBytes)(l.default.totalmem()),i.ffmpeg=await(0,k.ffmpegVersionDescription)(),i.argv=(0,z.stringify)(u.default.argv),e.extra=i,{timestamp:Date.now()/B.secondMs,...e}}async function Q(){await(0,j.delay)(3*A.DefaultLogFlushMs);const e=await(0,F.allRecentLogEntries)();return(0,R.compact)(e.map(ee))}function ee(e){return(0,V.map)(ie(e.l),(t=>({timestamp:e.ts/B.secondMs,level:t,category:e.from??(0,g.processName)(),message:(0,w.stripAnsiEsc)(e.ctx+": "+e.msg),data:"object"==typeof e.meta?e.meta:{value:(0,w.isString)(e.meta)?(0,w.stripAnsiEsc)(e.meta):e.meta}})))}t.EventFilter=J,t.extractMessage=K,t.sentryExceptionsToS=Y,t.sentryExceptionToS=Z,t.annotateEvent=X,t.mkBreadcrumbs=Q,t.logEntryToBreadcrumb=ee;const te=new Map([[I.LogLevels.fatal,"fatal"],[I.LogLevels.error,"error"],[I.LogLevels.warn,"warning"],[I.LogLevels.info,"info"],[I.LogLevels.debug,"debug"]]);function ie(e){return te.get(e)}t.logLevelToSeverity=ie},37158:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Service=t.setupEventHandlers=void 0;const p=m(i(29907)),g=m(i(1708)),y=i(57206),w=i(19851),v=i(50213),b=i(59880),S=i(23560),P=i(19913),_=i(71567),T=i(37805),M=i(38836),E=i(99331),D=i(45608),x=i(56038),k=i(55534),C=i(42499),F=i(49776),A=i(96706),I=i(98314),O=i(38835),L=i(70025),R=i(8769),N=i(57159),B=i(34102),j=i(33456),z=i(87408),V=i(85021),W=i(17181),U=i(86941),q=i(28874),H=i(41692),$=i(2858),G=i(69385),J=i(22573),K=i(42659),Y=i(41400),Z=i(56409),X=i(55835),Q=i(41583),ee=i(54993),te=i(95629);t.setupEventHandlers=(0,w.lazy)((()=>{(0,B.ee)().on("resume",(()=>(0,G.resume)())),(0,B.ee)().on("pause",(()=>(0,G.pause)()))}));class ie extends M.EndableWrapper{constructor(e){super(e),r.add(this),s.set(this,void 0),n.set(this,new Z.Latch),a.set(this,new Map),this.setup_=(0,w.lazy)((()=>(0,x.time)("Service.setup",(()=>f(this,r,"m",o).call(this))))),u.set(this,(0,w.lazy)((()=>{const e=g.default.stdin.pipe(new j.LineReader);return e.on("data",(e=>f(this,r,"m",d).call(this,(0,ee.toS)(e)))),e}))),(0,S.isBillingService)()||(0,H.setSettingsDefaults)(),h(this,s,(0,v.mkLogger)("Service("+this.name+")"),"f"),f(this,r,"m",c).call(this),this.setup_()}get name(){return super.name}get ready(){return f(this,n,"f").promise}get isReady(){return f(this,n,"f").isResolved()}setInputHandler(e,t){f(this,a,"f").set(e.trim().toLowerCase(),t)}}t.Service=ie,s=new WeakMap,n=new WeakMap,a=new WeakMap,u=new WeakMap,r=new WeakSet,o=async function(){try{(0,J.mapNotBlank)((0,A.getEnv)("PS_FATAL_"+this.name),(e=>{throw new N.WrappedError(e,{fatal:!0})})),(0,J.mapNotBlank)((0,A.getEnv)("PS_CRASH_"+this.name),(e=>{(0,Y.later)((()=>{throw new N.WrappedError(e)}),5*K.secondMs)})),(0,P.setServiceName)(this.name),(0,b.setProcessTitle)(),(0,S.isMainService)()&&await(0,U.mergeUserDataDirs_)(),await(0,$.readSettings)(),await f(this,r,"m",l).call(this),(0,W.setupLogger)(),(0,y.addDefaultJsonRevivers)(),(0,F.cacheDir)(),(0,t.setupEventHandlers)(),f(this,u,"f").call(this),await(0,C.setupLuxon)(),q.Settings.startPaused.valueOrDefault&&(0,G.pause)(),(0,E.ending)()?f(this,n,"f").reject():f(this,n,"f").resolve()}catch(e){console.error((0,I.errorToS)(e)),f(this,n,"f").reject((0,Q.toErr)(e)),(0,D.exit)({reason:(0,L.addErrorFlags)(this.name+" setup failed: "+(0,I.errorToS)(e),O.FatalErrorFlag),status:14})}},l=async function(){(0,S.isPermaService)()||(0,B.ee)().on("fatal",(e=>(0,D.exit)({error:e,status:12}))),g.default.on("unhandledRejection",(e=>(0,X.map)(e,(e=>(0,R.onError)("unhandledRejection",e))))),g.default.on("uncaughtException",(e=>(0,X.map)(e,(e=>(0,R.onError)("uncaughtException",e))))),g.default.on("SIGINT",(()=>(0,D.exit)({reason:"SIGINT",status:0}))),g.default.on("SIGHUP",(()=>(0,D.exit)({reason:"SIGHUP",status:0}))),g.default.on("SIGTERM",(()=>(0,D.exit)({reason:"SIGTERM",status:0}))),p.default.isWorker&&g.default.on("disconnect",(()=>(0,D.exit)({reason:"disconnect",status:0}))),await(0,te.installSentry)(this)},c=function(){this.setInputHandler("--version",(()=>(0,_.stdoutWrite)({version:T.version}))),this.setInputHandler(k.ServiceExitCommand,(()=>(0,Y.later)((()=>(0,D.exit)({reason:k.ServiceExitCommand+" from stdin",status:0}))))),this.setInputHandler("--times",(()=>(0,_.stdoutWrite)(x.PromiseTimer.instance().report()))),this.setInputHandler(V.HealthCheckCommand,(async()=>(0,_.stdoutWrite)(await(0,z.getStatusSummary)({refresh:!0}))))},d=async function(e){if(f(this,s,"f").debug("onLine()",{line:e,ending:this.ended||(0,E.ending)()}),await this.setup_(),e.startsWith("--")){const t=e.split(/\s+/,1)[0],i=f(this,a,"f").get(t);null==i?(f(this,s,"f").error("onLine(): unknown command",{line:e,knownCommands:[...f(this,a,"f").keys()]}),console.warn("unknown command "+e)):await i(e.slice(t.length).trim())}else f(this,s,"f").error("onLine(): failed to process",{line:e})}},31503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogArgs=void 0;const r=i(23560),s=i(83210),n=i(28874),a=i(38639);function o(){return(0,r.isMainService)()||(0,r.isSyncService)()}t.LogArgs={beforeParse:e=>{const t=(o()?', "PS_TAIL_LOGS=true"':"")+' and "PS_LOG_STDOUT=true".';return o()?e.option("-v, --verbose",'Verbose logging from all processes. Shortcut for "--info --tail". Caution: noisy during imports!'):e.option("-v, --verbose","Verbose logging. Equivalent to --info."),e.option("--error",`Emit "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=error"${t}`),e.option("--warn",`Emit "warn" and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=warn"${t}`),e.option("--info",`Emit "info", "warn", and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=info"${t}`),e.option("--debug",`Emit "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY NOISY. Sets "PS_LOG_LEVEL=debug"${t}}`),e.option("--trace",`Emit "trace", "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY VERY NOISY. Sets "PS_LOG_LEVEL=trace"${t}}`),o()&&e.option("--tail",'Emit log messages from both this process and all other concurrently running PhotoStructure processes on this host to stdout. This can be really helpful in seeing how PhotoStructure\'s processes are coordinating work. Caution: very noisy especially during imports. Sets "PS_TAIL_LOGS=true".'),e},afterParse:e=>{const t=(0,a.isTrue)(e.error),i=(0,a.isTrue)(e.warn),r=(0,a.isTrue)(e.info)||(0,a.isTrue)(e.verbose)||(0,a.isTrue)(e.v),l=(0,a.isTrue)(e.debug),u=(0,a.isTrue)(e.trace);u?n.Settings.logLevel.envValue="trace":l?n.Settings.logLevel.envValue="debug":r?n.Settings.logLevel.envValue="info":i?n.Settings.logLevel.envValue="warn":t&&(n.Settings.logLevel.envValue="error"),(0,s.isDaemon)(e)?(n.Settings.tailLogs.envValue=!1,n.Settings.logStdout.envValue=!1):((0,a.isTrue)(e.tail)&&(n.Settings.tailLogs.envValue=!0),(t||i||r||l||u)&&(n.Settings.logStdout.tmpValue=!0,o()&&(n.Settings.tailLogs.tmpValue=!0)),(n.Settings.tailLogs.valueOrDefault||n.Settings.logStdout.valueOrDefault)&&n.Settings.logLevel.isUnset()&&(n.Settings.logLevel.envValue="info"))}}},46628:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.albumsFromTags=t.tagFilesWithAlbums=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(81168),o=i(74417),l=i(28874),u=i(47783),c=i(97573),d=i(42231),h=i(40958),f=i(22573),m=i(68708),p=i(75020),g=i(54993),y=(0,s.lazy)((()=>(0,n.mkLogger)("curators.AlbumTagger")));function w(e){return(0,f.blank)(e)?void 0:l.Settings.tagAlbumTitleHierarchies.valueOrDefault?(0,c.keywordToPath)(e):[e]}function v(e){if(null==e)return[];const t=(0,h.uniq)((0,r.flatMap)(l.Settings.tagAlbumTitle.values,(t=>(0,m.pluckDeep)(e,t)?.value))),i=(0,h.compact)(t.map(w));if((0,h.isEmpty)(i))return[];if(i.length>1)return y().tap({level:"info",msg:"albumFromFile()",result:i.map((e=>[p.TagRoots.Albums,...e]))});const s=i[0],n=(0,r.first)(l.Settings.tagAlbumDescription.values,(t=>(0,m.pluckDeep)(e,t)?.value)),u=(0,h.isEmpty)(s)?"(blank title)":(0,a.firstSubstringIgnoreCase)(l.Settings.tagAlbumsExcluded.values,[...s,(0,g.toS)(n)].join(" ")),c=null==u?[p.TagRoots.Albums,...s]:void 0;if(null!=c){const t={name:c[c.length-1],description:n};for(const i of l.Settings.tagAlbumDate.values){const r=(0,o.parseJsonDateToMillis)((0,m.pluckDeep)(e,i)?.value);if(null!=r){t.releasedAt=r;break}}c[c.length-1]=t}return y().tap({level:"info",msg:"albumFromFile()",result:(0,h.compact)([c]),meta:{titles:i,desc:n,whyExclude:u}})}t.tagFilesWithAlbums=async function(e){const t=[];for(const i of e){t.push(...v(await(0,u.readTags)(i)));for(const e of l.Settings.tagAlbumFilenames.values)t.push(...v(await(0,u.readRawTags)(i.sibling(e),!1)))}return y().tap({msg:"tagFilesWithAlbums()",result:(0,d.uniqTagPaths)(t),meta:{files:e}})},t.albumsFromTags=v},88224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagAsset=t.tagAndUpsertAsset_=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(28874),o=i(42231),l=i(40958),u=i(20214),c=i(43487),d=i(46628),h=i(63175),f=i(4407),m=i(58886),p=i(32646),g=i(48144),y=i(60047),w=i(6186),v=i(42003),b=i(43723),S=(0,r.lazy)((()=>(0,s.mkLogger)("curators.AssetTagger")));async function P({primaryVariation:e,files:t,priorTagPaths:i,capturedAts:r,uris:s}){const u=[];if(t=(0,l.uniqBy)([e,...t],(e=>e.nativePath)),a.Settings.tagCamera.valueOrDefault&&await(0,n.thenMap)((0,h.cameraTagFile)(e),(t=>{S().debug("Camera tag for "+e+":",t),u.push(t)})),a.Settings.tagLens.valueOrDefault&&await(0,n.thenMap)((0,y.lensTagFile)(e),(t=>{S().debug("Lens tag for "+e+":",t),u.push(t)})),a.Settings.tagGeo.valueOrDefault)for(const e of t){const t=await(0,p.geoTagFile)(e);if(null!=t){u.push(t);break}}await(0,n.thenMap)((0,f.dateTagFile)(e,r),(t=>{S().debug("Date tag for "+e+":",t),u.push(t)}));const c=await(0,b.whoTagFiles)(t)??[];S().debug("whoTagFiles for "+e+":",c),u.push(...c),await(0,n.thenMap)((0,g.keywordTagFiles)(t,c),(t=>{S().debug("Keyword tags for "+e+":",t),u.push(...t)})),a.Settings.tagFileType.valueOrDefault&&await(0,n.thenMap)((0,v.typeTagFiles)(t),(t=>{S().debug("MIME type tags for "+e+":",t),u.push(...t)})),await(0,n.thenMap)((0,m.tagAssetPaths)(s),(e=>{S().debug("file paths for uris",{uris:s,arr:e}),u.push(...e)})),await(0,n.thenMap)((0,d.tagFilesWithAlbums)(t),(t=>{S().debug("Album tags for "+e+":",t),u.push(...t)}));const P=(0,o.omitAncestorTags)((0,l.uniqBy)(u.map(w.normalizeTagRoot),o.joinTagPath)),_=await(0,w.tagDeltas)(i,P);return S().info("tagAsset("+e+")",{priorTagPaths:i,after:P,result:_}),_}t.tagAndUpsertAsset_=async function(e){const t=await e.getExistingAssetFiles();S().info("tagAndUpsertAsset()",{asset:e,existing_uris:t.map((e=>e.uri))});const i=t.find((e=>e.shown)),r=await(i?.posixFile_());if(null==i||null==r)return void S().throw("tagAndUpsertAsset(): no existing or primary asset file",{asset:e,existingPrimaryAssetFile:i,primaryVariant:r,doNotSend:!0,fatal:!1});const s=e.getShown();s?.id!==i.id&&(S().warn("Changing primary asset we're using a different variant for tagging.",{newPrimary:i.uri,priorPrimary:s?.uri}),e.setShown_(i));const n=await(0,u.thenCollect)(t,(e=>e.posixFile_())),l=e.getAssetFiles().map((e=>e.uri)),d=e.getTagPaths(),h=await e.getCapturedAts(),f=await P({primaryVariation:r,files:n,priorTagPaths:d,capturedAts:h,uris:l});S().info("tagAndUpsertAsset",f);const m=f.add.find((e=>(0,o.leafIsExcluded)(e,a.Settings.keywordBlocklist.values)));if(null!=m){if(!0!==e.shown)return S().info("this asset has an excluded tag, and it wasn't shown yet, so we're removing it.",{excludedTag:m}),await c.Asset.remove({assetId:e.id,blocklistShas:!1,unlinkAssetFiles:!1}),S().throw("tagAndUpsertAsset(): asset had excluded tag. Removed.",{excludedTag:m,uris:l,files:n.map((e=>e.nativePath))});S().info("this asset has an excluded tag, marking excluded",{excludedTag:m}),e.excludedAt=Date.now()}return e.applyTagPathDeltas(f),await e.updateFromFiles(),f},t.tagAsset=P},63175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cameraTagFile=t.cameraTag=void 0;const r=i(47783),s=i(75020),n=i(40958),a=i(22573);function o(e){return null==e||(0,a.blank)(e.Make)?void 0:(0,n.compactBlankish)([s.TagRoots.Camera,e.Make,e.Model])}t.cameraTag=o,t.cameraTagFile=async function(e){return o(await(0,r.readTags)(e))}},4407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateTagFile=t.dateTag=t.dayTagRef=t.monthTagRef=t.yearTagRef=t.dayToOrdinal=t.ordinalToMonth=t.monthToOrdinal=t.yearToOrdinal=void 0;const r=i(19851),s=i(19043),n=i(97352),a=i(81168),o=i(928),l=i(34102),u=i(28874),c=i(28544),d=i(47783),h=i(40958),f=i(55835),m=i(31586),p=i(75020),g=i(54993),y=(0,r.lazy)((()=>new Intl.DateTimeFormat((0,s.localeSync)(),{month:"short"}))),w=(0,r.lazy)((()=>{const e=y();return(0,h.range)(0,12,(t=>e.format(new Date(2016,t,1)))).map((e=>(0,a.stripSuffix)(e,".")))}));function v(e){return 1e4-e}function b(e){return 13-e}function S(e){return 33-e}function P(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:v(e)})))}function _(e){if((0,m.within)(1,12,e))return(0,f.map)(w()[e-1],(t=>({name:String(e),displayName:t,ordinal:b(e)})))}function T(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:S(e)})))}function M(e){const t=(0,g.toS)(u.Settings.tagYMD.valueOrDefault).toLowerCase();if(null==e||""===t||"off"===t||t.startsWith("disable"))return;const i=[p.TagRoots.When];if(t.startsWith("y")){const t=(0,f.map)((0,o.getYear)(e),P);if(null==t)return;i.push(t)}if(t.startsWith("ym")){const t=(0,f.map)((0,o.getMonth)(e),_);if(null==t)return i;i.push(t)}if(t.startsWith("ymd")){const t=(0,f.map)((0,o.getDay)(e),T);if(null==t)return i;i.push(t)}return i}(0,l.ee)().on("clearCache",(()=>{y.unset(),w.unset()})),t.yearToOrdinal=v,t.monthToOrdinal=b,t.ordinalToMonth=function(e){return 13-e},t.dayToOrdinal=S,t.yearTagRef=P,t.monthTagRef=_,t.dayTagRef=T,t.dateTag=M,t.dateTagFile=async function(e,t){if(""===u.Settings.tagYMD.valueOrDefault)return;const i=[...t];(0,h.isEmpty)(t)&&i.push((await(0,d.readTags)(e))?.capturedAt);const r=(0,c.bestCapturedAt)(i);return null==r||(0,c.capturedAtSrcFromStat)(r.src)&&!u.Settings.tagDateFromStat.valueOrDefault?void 0:M(r.date)}},58886:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addFileUriTagsToAsset=t.addFilesTagsToAsset=t.isFsTag=t.tagAssetPaths=void 0;const r=i(19851),s=i(50213),n=i(42231),a=i(21404),o=i(40958),l=i(89937),u=i(75020),c=i(54017),d=i(94448),h=i(69032),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.FilePathTagger")));function m(e,t){return e.applyTagPathDeltas({add:(0,o.compact)(t.map((e=>(0,a.uriToTagPath)({uri:e,isFile:!0}))))})}t.tagAssetPaths=async function(e){const t=[];for(const i of e)try{const e=(0,a.uriToTagPath)({uri:i,isFile:!0});if(null==e)continue;if(i.startsWith(l.PS_LOCAL_FILE_SCHEME)&&null!=(0,d.modelDb)()){const t=(0,n.tagRefToS)(e[1]);e[1]={name:t,displayName:await(0,h.displayNameForVolsha)(t)},f().info("tagAssetPaths()",{uri:i,tp:e})}t.push(e)}catch(e){f().warn("Failed to parse asset file URI",{uri:i})}return t},t.isFsTag=function(e){return(0,n.tagRefToS)(e[0]).toLowerCase()===u.TagRoots.fs},t.addFilesTagsToAsset=function(e){const t=c.AssetFile.dbl.pluckAllf((t=>t.select("uri").where({asset:e})));return m(e,t)},t.addFileUriTagsToAsset=m},32646:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.geoTagFile=t.geoTag=void 0;const r=i(48884),s=i(56519),n=i(28874),a=i(47783),o=i(75020),l=i(40958);function u(e){const t=(0,r.compactRight)(n.Settings.tagGeoTemplate.valueOrDefault.map((t=>e?.[t])));return 0===t.length||t.some((e=>null==e))?void 0:(0,l.compact)([o.TagRoots.Where,...t])}t.geoTag=u,t.geoTagFile=function(e){return(0,s.thenMap)((0,a.readTags)(e),u)}},48144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.keywordTagFiles=t.processKeywords=t.dedupeKeywordPaths=t.normalizeKeywordPaths=t.extractPathnameTags=t.extractDashDashTags=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(68852),o=i(81168),l=i(96859),u=i(56519),c=i(28874),d=i(47783),h=i(97573),f=i(42231),m=i(40958),p=i(76790),g=i(22573),y=i(41400),w=i(96249),v=i(55835),b=i(75020),S=i(54993),P=i(6186),_=i(43723),T=(0,s.lazy)((()=>(0,n.mkLogger)("curators.KeywordTagger"))),M=(0,s.lazy)((()=>(0,g.mapNotBlank)(c.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[ /${(0,a.escapeRegExp)(e)}]`)))));function E(e){return T().tap({msg:"extractDashDashTags()",result:(0,v.mapOr)((0,S.toS)(e).split("--")[1],(e=>(0,m.compactBlanks)((0,v.mapOr)(M(),(t=>e.split(t)),[e]))),(()=>[])),meta:{s:e}})}function D(e){return[...E(e.parent().posixPath),...E(e.name)]}(0,y.later)((()=>{c.Settings.keywordDelimiters.watchLater((()=>M.unset()))})),t.extractDashDashTags=E,t.extractPathnameTags=D;const x=/\w{2,7}:\/\/\S+/g;function k(e){const t=[],i=[],s=[];for(const t of(0,m.compact)(e))if(Array.isArray(t))s.push(t);else{const e=(0,S.toS)(t).replace(x,(e=>(i.push(e),"")));s.push(...(0,v.mapOr)((0,h.delimRe)(),(t=>e.split(t)),[e]))}const n=s.map((e=>(0,o.isString)(e)?(0,h.keywordToPath)(e):e)).map((e=>Array.isArray(e)&&1===e.length?e[0]:e)),[a,l]=(0,r.partition)(n,Array.isArray),u=a.map((e=>(0,m.compactBlanks)(e.map((e=>e.trim()))))).filter(m.isNotEmpty),d=(0,o.uniqIgnoreCase)((0,w.flatten)(u));t.push(...u);const f=[...l,...i].map((e=>e.trim())).filter((e=>(0,g.notBlank)(e)&&!(0,o.includesIgnoreCase)(d,e))),p="copy"===c.Settings.keywordReparenting.valueOrDefault,y="retain"===c.Settings.keywordReparenting.valueOrDefault,P=c.Settings.rootTagKeywordsAliases.values;for(const e of[...t])(0,o.includesIgnoreCase)(P,e[0])&&(e[0]=b.TagRoots.Keywords),e[0]!==b.TagRoots.Keywords&&(p?t.push([b.TagRoots.Keywords,...e]):y&&e.unshift(b.TagRoots.Keywords));for(const e of f)t.push([b.TagRoots.Keywords,e]);return(0,m.uniq)(t)}function C(e){return(0,m.uniqBy2)((0,p.sortBy)(e.map(P.normalizeTagRoot),(e=>{const t=(0,f.joinTagPath)(e);return[t.normalize().toLowerCase(),-1*(0,l.lcdiff)(t)]})),((e,t)=>(0,o.equalsIgnoreCase)((0,f.joinTagPath)(e),(0,f.joinTagPath)(t))))}function F(e,t){const[i,s]=(0,r.partition)(k(e),_.isWhoTag),n=(0,w.flatten)(i.map(_.nameTag)),a=(0,m.uniq)((0,w.flatten)([...n,...t].map((e=>{const t=(0,P.stripTagRoot)(e);return[t.join(", "),t.join(" "),[...t].reverse().join(" ")]})))),l=C([...s.filter((e=>!(0,o.includesIgnoreCase)(a,(0,P.stripTagRoot)(e).join(" ")))),...n]);return T().tap({msg:"processKeywords()",level:"info",result:l})}t.normalizeKeywordPaths=k,t.dedupeKeywordPaths=C,t.processKeywords=F,t.keywordTagFiles=async function(e,t){return F([...c.Settings.tagKeywordsFromPath.valueOrDefault?(0,w.flatten)(e.map(D)):[],...c.Settings.tagKeywordsFromMetadata.valueOrDefault?(0,w.flatten)(await(0,u.mapAsyncSerial)({name:"keywordTagFiles",arr:e,f:e=>(0,u.thenMap)((0,d.readRawTags)(e),h.rawTagKeywords)})):[]],t)}},60047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lensTagFile=t.lensTag=void 0;const r=i(56519),s=i(28874),n=i(47783),a=i(75020),o=i(40958),l=i(22573),u=i(55835);function c(e){return(0,u.map)(e,(e=>(0,l.mapNotBlank)(e.lensMake,(t=>(0,l.mapNotBlank)((0,o.compactBlanks)(s.Settings.tagFullLensModel.valueOrDefault?[e.lensModel,e.lensInfo]:[e.lensInfo,e.lensModel])[0],(e=>[a.TagRoots.Lens,t,e]))))))}t.lensTag=c,t.lensTagFile=function(e){return(0,r.thenMap)((0,n.readTags)(e),c)}},6186:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagDeltas=t.normalizeTagRoot=t.stripTagRoot=t.hasTagRoot=t.Roots=t.KwRoot=t.WhoRoot=t.AlbumsRoot=t.WhenRoot=void 0;const r=i(50213),s=i(28874),n=i(42231),a=i(75020),o=i(40958),l=i(22573),u=i(45599);t.WhenRoot={name:a.TagRoots.When,ordinal:1},t.AlbumsRoot={name:a.TagRoots.Albums,ordinal:2},t.WhoRoot={name:a.TagRoots.Who,ordinal:4},t.KwRoot={name:a.TagRoots.Keywords,ordinal:7};const c=(0,u.defer)((()=>(0,r.mkLogger)("curators.Taggers")));t.Roots=[t.WhenRoot,t.AlbumsRoot,{name:a.TagRoots.fs,ordinal:3},t.WhoRoot,{name:a.TagRoots.Camera,ordinal:5},{name:a.TagRoots.Lens,ordinal:6},t.KwRoot,{name:a.TagRoots.Type,ordinal:8}];const d=(0,o.uniq)([...a.TagRoots.values,...s.Settings.rootTagKeywordsAliases.values,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function h(e){return d.includes((0,n.tagRefToS)(e[0]).toLowerCase())}t.hasTagRoot=h,t.stripTagRoot=function(e){return h(e)?e.slice(1):e};const f=(0,o.uniq)([a.TagRoots.Albums,...s.Settings.rootTagAlbumsAliases.values].map((e=>e.toLowerCase()))),m=(0,o.uniq)([a.TagRoots.Keywords,...s.Settings.rootTagKeywordsAliases.values].map((e=>e.toLowerCase()))),p=(0,o.uniq)([a.TagRoots.Who,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));t.normalizeTagRoot=function(e){const i=(0,n.tagRefToS)(e[0]).toLowerCase();return(0,l.blank)(i)?e:m.includes(i)||m.includes(i)?[t.KwRoot,...e.slice(1)]:p.includes(i)?[t.WhoRoot,...e.slice(1)]:f.includes(i)?[t.AlbumsRoot,...e.slice(1)]:e},t.tagDeltas=async function(e,t){const i=(0,n.tagDiff)(t,e),r=(0,n.tagDiff)(e,t),a=s.Settings.excludedRootTags.valueOrDefault;return(0,o.filterInPlace)(i,(e=>{const t=a.includes((0,n.tagRefToS)(e[0]).toLowerCase());return t&&!(0,n.tagPathsInclude)(e,r)&&(r.push(e),c().info("tagDeltas(): removing excluded tag",e)),!t})),{add:i,remove:r}}},42003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fixCase=t.friendlySubtype=t.mimeTypeToTag=t.typeTagFiles=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(56519),o=i(54979),l=i(40958),u=i(22573),c=i(55835),d=i(42279),h=i(75020),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.TypeTagger")));t.typeTagFiles=async function(e){const t=(0,l.uniq)(await(0,a.mapAsyncSerial)({name:"typeTagFiles",arr:e,f:o.readMimeType}));return(0,l.compact)(t.map(p))};const m=new Map(["M2TS","JPEG","QuickTime"].map((e=>[e.toLowerCase(),e])));function p(e){const[t,i]=e.split("/");if(!(0,u.blank)(t)&&!(0,u.blank)(i))return f().tap({msg:"mimetypeToTag("+e+")",result:(0,c.map)(y(i,e),(e=>(0,l.compactBlanks)([h.TagRoots.Type,(0,n.capitalize)(t),...e])))})}t.mimeTypeToTag=p;const g=(0,r.lazy)((()=>new Map([["image/x-adobe-dng",["Raw","DNG"]],["image/x-fuji-raf",["Raw","Fujifilm"]],["video/m2ts",["MPEG-2"]],["video/mp2t",["MPEG-2"]],["video/mp4",["MPEG-4"]],["video/quicktime",["QuickTime"]],["video/x-msvideo",["AVI"]]])));function y(e,t){return(0,d.firstDefinedThunk)([()=>g().get(t.trim().toLowerCase()),()=>(0,c.map)(e.match(/^x-(\w{4,})-\w{3}/),(e=>["Raw",(0,n.capitalize)(e[1])])),()=>[w(e.replace(/^(?:x-|vnd\.|prs\.)/i,"").replace(/-/g," "))]])}function w(e){return null!=e.match(/[a-z\d]{3,4}/i)?e.toUpperCase():m.get(e.trim().toLowerCase())??(0,n.capitalize)(e)}t.friendlySubtype=y,t.fixCase=w},43723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nameTag=t.isWhoTag=t.whoTagFiles=void 0;const r=i(19851),s=i(50213),n=i(28874),a=i(47783),o=i(28630),l=i(66039),u=i(42231),c=i(40958),d=i(22573),h=i(96249),f=i(68708),m=i(75020),p=i(59455),g=(0,r.lazy)((()=>(0,s.mkLogger)("curators.WhoTagger")));t.whoTagFiles=async function(e){const t=[];if(n.Settings.tagJsonFaces.valueOrDefault){const i=[];for(const t of e)i.push(...(0,p.toA)(await t.jsonSidecars()));for(const e of i){const i=await(0,o.readJsonSidecar)(e),r=i?.peopleNames;(0,c.isNotEmpty)(r)&&t.push(...r)}}if(n.Settings.tagFaceRegions.valueOrDefault)for(const i of e){const e=await(0,a.readRawTags)(i,!0);if(null!=e)for(const i of(0,f.values)(e)){const e=i?.RegionList;if(Array.isArray(e))for(const i of e)"Face"===i.Type&&t.push(i.Name)}}if((0,c.isNotEmpty)(n.Settings.whoTags.values))for(const i of e){const e=await(0,a.readRawTags)(i,!0);for(const i of n.Settings.whoTags.values)t.push(...(0,p.toA)((0,f.pluckDeep)(e,i)?.value))}const i=(0,c.uniq)((0,h.flatten)((0,c.uniq)(t).map(v)));return g().tap({msg:"whoTagFiles()",level:"info",result:i,meta:{names:t,files:e.map((e=>e.nativePath))}})};const y=(0,c.uniq)([m.TagRoots.Who,...n.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function w(e){return y.includes((0,u.tagRefToS)(e[0]).toLowerCase())}function v(e){if(!(0,d.blank)(e))return Array.isArray(e)?(w(e)&&e.shift(),0===e.length?void 0:1===e.length?(0,l.renderNameTag)(e[0]):[[m.TagRoots.Who,...e]]):(0,l.renderNameTag)(e)}t.isWhoTag=w,t.nameTag=v},98348:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Db=void 0;const c=i(48884),d=i(19851),h=i(23560),f=i(25764),m=i(38836),p=i(99331),g=i(12959),y=i(55332),w=i(91872),v=i(80632),b=i(51040),S=i(44955),P=i(15056),_=i(70025),T=i(57159),M=i(18454),E=i(28874),D=i(5233),x=i(42659),k=i(31586),C=i(68708),F=i(30976),A=i(17036),I=i(27134),O=i(35052);class L extends m.EndableWrapper{constructor(e,t){super("db.Db("+e+")",(()=>this.closeDb()),f.EndableRanks.db),r.add(this),this.schema=e,this.dbFile=t,s.set(this,0),n.set(this,void 0),this.endTimeoutMs=x.minuteMs,this.onRetry=(0,d.lazy)((()=>this.closeDb()),E.Settings.maxBusyDbMs.valueOrDefault/2),this.maxUpdatedAt=(0,d.lazy)((()=>"models"===this.schema?l(this,r,"m",a).call(this,"Asset","AssetFile","Example"):0),5*x.secondMs),this.migrate_=(0,d.lazy)((async()=>{let e=!1;const t=this.dbFile;if(null==this.dbFile)throw new Error("Cannot migrate database: missing db");let i;if(await this.dbFile.isNonEmptyFile())try{await(0,I.verifyDb_)((()=>this.db))}catch(e){this.logger.warn("verifyDb failed before attempting Migration.",{error:e}),i=e}(null!=i||E.Settings.dbForceRecover.valueOrDefault)&&(M.HealthCheck.addLoadingMsg("Repairing database..."),await this.repair_(),e=!0);const r=new A.Migration(this.schema,this.db,t);return{appliedMigrations:await r.apply_(),migration:r,repaired:e}})),this.tableInfo_=(0,d.lazy)((()=>(0,O.localTableInfo)(this.db)))}toJSON(){return(0,C.pick)(this,"schema","dbFile")}get isOpen(){return!0===l(this,n,"f")?.open}get inTransaction(){return this.isOpen&&!0===l(this,n,"f")?.inTransaction}prepare(e){return this.db.prepare(e)}pragma(e,t){return this.logger.tapThunk({msg:"PRAGMA "+e,result:()=>this.db.pragma(e,t)})}get db(){var e;const t=null==l(this,n,"f");if(t||!this.isOpen){this.logger.info("setting up new db connection to "+this.dbFile,{priorWasNull:t});try{u(this,n,(0,v.mkdb_)({nativePath:this.dbFile.nativePath}),"f")}catch(e){throw new T.WrappedError("Failed to set up "+this.dbFile,{cause:e,path:this.dbFile.nativePath})}}return(0,h.isSyncService)()&&"INCREMENTAL"===E.Settings.dbAutoVacuumMode.valueOrDefault&&(0,k.gt0)(E.Settings.dbWalAutoCheckpoint.valueOrDefault)&&u(this,s,(e=l(this,s,"f"),++e),"f")%E.Settings.dbWalAutoCheckpoint.valueOrDefault==0&&(this.logger.info("running incremental_vacuum..."),l(this,n,"f")?.pragma("incremental_vacuum")),l(this,n,"f")}async verify_(){await(0,I.verifyDb_)((()=>this.db))}assertHeartbeat_(){const e=(0,F.randomChars)(64),t=Date.now();try{this.db.prepare("INSERT INTO heartbeat (name, createdAt, updatedAt) VALUES (?,?,?)").run(e,t,t);const i=this.db.prepare("SELECT * FROM heartbeat WHERE name = ?").get(e);if(i?.name!==e)throw new Error("heartbeat INSERT/SELECT roundtrip failed")}finally{try{this.db.prepare("DELETE FROM heartbeat WHERE name = ?").run(e)}catch{}}}async closeDb(){try{this.logger.info("closing db",l(this,n,"f")),await(0,D.retryOnReject_)((()=>{!0===l(this,n,"f")?.open&&l(this,n,"f")?.close()}),{timeoutMs:E.Settings.dbBusyTimeoutMs.valueOrDefault,maxRetries:5,errorIsRetriable:_.isSqliteBusyError,retryDelay:x.secondMs})}catch(e){this.logger.warn("closeDb(): .close() failed",e)}u(this,n,void 0,"f")}async vacuum(){try{await(0,w.handleDbRetries_)("db.checkpoint",(()=>this.db),(()=>(0,I.checkpoint_)({db:this.db})),this.onRetry),await(0,w.handleDbRetries_)("db.optimize",(()=>this.db),(()=>this.db.pragma("OPTIMIZE")),this.onRetry),await(0,w.handleDbRetries_)("db.vacuum",(()=>this.db),(()=>this.db.exec("VACUUM")),this.onRetry)}catch(e){throw this.logger.warn("vacuum(): failed",{error:e}),e}}async repair_(){this.logger.warn("repair_(): Attempting restore of "+this.dbFile),await this.closeDb(),await(0,I.repairDbFile_)(this.dbFile),this.logger.info("repair_(): Database restoration was successful!")}localBackupDir(){return(0,P.dbBackupDir)(this.dbFile)}async backup_(e,t){const i=t??await(0,S.isDirSQLiteReadWrite)(e),s=(i?e:this.localBackupDir().join((0,g.filestamp)())).join(this.dbFile.base);return await l(this,r,"m",o).call(this,s),i||await(0,y.dbBackupCold_)(s,e),e.join(this.dbFile.base)}}t.Db=L,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(...e){const t=[];for(const i of e)try{t.push(this.db.prepare("SELECT MAX(updatedAt) FROM "+(0,b.dbValueToEscapedString)(i)).pluck().get())}catch(e){this.logger.warn(`#maxUpdatedAt(): failed to get max updatedAt for ${i}`,e)}return(0,c.max)(t)},o=async function(e){await e.parent().mkdirp_(),await this.db.backup(e.nativePath,{progress:e=>(this.logger.log((0,p.ending)()?"info":"debug","backup() "+(0,k.fmtPct)(100-e.remainingPages/e.totalPages*100)+" completed"),(0,p.ending)()?1e3:100)})}},25470:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.DbModelJanitor=t.Contested=t.NoOp=t.NoWriteLock=void 0;const c=i(66364),d=i(50213),h=i(23560),f=i(78406),m=i(25764),p=i(38836),g=i(99331),y=i(56038),w=i(12959),v=i(55332),b=i(76187),S=i(73209),P=i(28874),_=i(42659),T=i(75240),M=i(95700),E=i(22526),D=i(45648),x=5*_.minuteMs;t.NoWriteLock=Symbol("NoWriteLock"),t.NoOp=Symbol("NoOp"),t.Contested=Symbol("Contested");class k extends f.EndableInterval{static for(e){return new k(e.db,e.fslock,e.libraryDbFile,e.libraryDbBackupDir)}constructor(e,t,i,o){super({name:"db.DbModelJanitor",callback:()=>l(this,r,"m",n).call(this),intervalMs:P.Settings.dbBackupIntervalMs.valueOrDefault,initialDelayMs:_.minuteMs,rank:m.EndableRanks.db,endTimeoutMs:5*_.minuteMs,onEnd:()=>l(this,r,"m",a).call(this)}),r.add(this),this.db=e,this.dbFslock=t,this.libraryDbFile=i,this.libraryDbBackupDir=o,this.logger=(0,d.mkLogger)(this.name),this.fslockRelease=new p.EndableWrapper("db.DbModelJanitor.fslockRelease",(()=>this.dbFslock.release()),m.EndableRanks.postdb,x),s.set(this,0),this.dbFslock.tryAcquire_()}get useReplica(){return!this.db.dbFile.eql(this.libraryDbFile)}forceBackup_(){return this.backup_(!0)}async backup_(e=!1){return await(0,S.withLock_)({file:this.libraryDbBackupDir,timeoutMs:5*_.minuteMs,noopIfContested:!e},(async()=>{if(e&&u(this,s,0,"f"),(0,D.hasDbSetupErrors)())return this.logger.warn("backup_(): db has setup errors, skipping backup",{errors:(0,D.dbSetupErrors)()}),t.NoOp;if(!await this.dbFslock.tryAcquire_())return this.logger.info("backup_(): no-op: someone else has the fslock",{me:this.dbFslock.lockfile?.base,owner:(await this.dbFslock.selfAndSiblingNames_())[0]}),t.NoWriteLock;l(this,r,"m",o).call(this)||await(0,M.runMaintenanceTasks)();const i=this.db.maxUpdatedAt();return null!=i&&i>l(this,s,"f")?(0,y.time)("db.DbModelJanitor.backup_()",(async()=>{l(this,r,"m",o).call(this)?this.logger.info("backup_(): posthaste: skipping vacuum"):await this.db.vacuum(),u(this,s,i,"f");const e=this.libraryDbBackupDir.join((0,w.filestamp)()),t=await this.db.backup_(e,!this.useReplica);return this.useReplica&&await(0,v.dbBackupCold_)(t,this.libraryDbFile.parent()),this.logger.info("backup_(): backup successful",{destDbFile:t}),t})):(this.logger.info("backup_(): no update to the db since last backup",{ago:(0,T.fmtDuration)(Date.now()-l(this,s,"f"))}),t.NoOp)}))??t.Contested}}t.DbModelJanitor=k,s=new WeakMap,r=new WeakSet,n=async function(){try{await this.backup_()}catch(e){this.logger.error("backup_() failed",{error:e})}},a=async function(){const e=S.FsLock.for({file:this.libraryDbFile.sibling("db-teardown"),timeoutMs:x,endableRank:m.EndableRanks.postdb,noopIfContested:!1});(0,h.isDbManager)()&&await e.withLock_((async()=>{if(await this.dbFslock.iAmOnly_({vacuum:!0})){if(this.logger.info("#teardown(): I'm the last one in. Running backup and cleanup."),await this.backup_(),this.useReplica){const e=[(0,E.libraryDbInfoFromDbFile)(this.libraryDbFile),...(0,b.sqliteFiles)(this.db.dbFile)];this.logger.info("#teardown(): Removing replica artifacts",{victims:e});for(const t of e)await t.unlink()}}else this.logger.info("#teardown(): no-op: other processes are still running")})),await this.db.closeDb()},o=function(){return this.ended||(0,g.ending)()||(0,c.isSuspended)()}},22526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelSetup_=t.assertValidDbInfo_=t.libraryDbInfoFromDbFile=t.libraryDbInfoJsonFile=t.fsLockForDb=t.libraryDbObjects_=void 0;const r=i(19851),s=i(50213),n=i(92407),a=i(55332),o=i(44955),l=i(15056),u=i(87290),c=i(98314),d=i(38835),h=i(73209),f=i(95696),m=i(17217),p=i(18454),g=i(57902),y=i(28874),w=i(2858),v=i(40958),b=i(22573),S=i(42659),P=i(94448),_=i(98348),T=i(45648),M=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbModelSetup")));function E(e=y.Settings.libraryDir.valueOrDefault){if((0,b.blank)(e))throw new Error("Library directory is not set"+d.NoLibraryErrorFlag);const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dataDir"+d.NoLibraryErrorFlag);if(!(0,w._libraryHasSettings)(e))throw new Error(`Library at ${e} does not have a settings file`+d.NoLibraryErrorFlag);const i=(0,l.pathToDb)(t,"models");return{dataDir:t,libraryDbFile:i,libraryDbBackupDir:(0,l.dbBackupDir)(i)}}function D(e){return h.FsLock.for({file:e,timeoutMs:0,noopIfContested:!1})}function x(e=y.Settings.libraryDir.valueOrDefault){const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dir"+d.NoLibraryErrorFlag);return k((0,l.pathToDb)(t,"models"))}function k(e){return e.sibling("db-info.json")}async function C(e=x(),t){try{const i=await e.readJson(g.LogLevels.info);if(null==i)throw new Error(e+" is missing"+d.DbSetupErrorFlag);if(null!=t&&!await t.equalsUri_(i.uri))throw new Error(e+" expects the live db to be "+i.uri+" but the live db is "+await t.uri_()+d.DbSetupErrorFlag);const r=await f.PosixFile.forUri(i.uri);if(null==r)throw new Error(e+" expects the live db to be "+i.uri+" but that URI cannot be resolved."+d.DbSetupErrorFlag);try{await(0,o.assertDirSQLiteReadWrite_)(r.parent())}catch(t){throw M().error("assertValidDbInfo_(): failed to assert live dir was r/w",{error:t,liveDbFile:r,infoJsonFile:e}),new Error("Failed to validate that the live database directory, "+r.dir+", was read-writable by SQLite: "+(0,c.errorToS)(t)+d.DbSetupErrorFlag)}return{liveDbFile:r}}catch(e){throw(0,T.addDbSetupError)(e),e}}t.libraryDbObjects_=E,t.fsLockForDb=D,t.libraryDbInfoJsonFile=x,t.libraryDbInfoFromDbFile=k,t.assertValidDbInfo_=C,t.dbModelSetup_=async function(e=y.Settings.libraryDir.valueOrDefault){const{libraryDbFile:t,fslock:i,libraryDbBackupDir:r}=await async function(e=y.Settings.libraryDir.valueOrDefault){const t=E(e);return{...t,fslock:D(t.libraryDbFile)}}((0,b.mapNotBlank)(e,m.toNativePath_));let s,o;await i.tryAcquire_();const u=k(t);try{if(await(0,h.withLock_)({file:u,timeoutMs:5*S.minuteMs},(async()=>{const i=await u.readJson(g.LogLevels.info);if(s=i?.useReplica,null!=i){const{liveDbFile:e}=await C(u,t);o=new _.Db(l.Schemas.models,e)}if(null==s||null==o){const i=await(0,n.getLiveDbDir_)(e),r=await i.db.uri_();s=i.useReplica,s&&await p.HealthCheck.traceLater_("Setting up local replica database",(0,a.dbBackupCold_)(t,i.db.parent())).catch((e=>M().throw("Failed to set up replica db"+d.DbSetupErrorFlag,{src:t,dest:i.db,error:e}))),o=new _.Db(l.Schemas.models,i.db),await u.writeJson_({uri:r,useReplica:s})}})),null==o||null==s)return M().throw("Failed to open model db"+d.DbSetupErrorFlag+d.InternalErrorFlag,{libraryDir:e});if(await i.tryAcquire_()){const e=await o.migrate_();s&&(e.repaired||(0,v.isNotEmpty)(e.appliedMigrations))&&await o.backup_(t.parent(),!s),(0,T.clearDbSetupErrors)()}P.modelDb.set(o)}catch(e){throw M().error("Failed to set up model db",{error:e}),(0,T.addDbSetupError)(e),i.release(),e}return M().tap({msg:"dbModelSetup()",result:{db:o,useReplica:s,libraryDbFile:t,libraryDbBackupDir:r,fslock:i}})}},86859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DbRequest=void 0;const r=i(54557),s=i(50213),n=i(99331),a=i(56038),o=i(65753),l=i(66184),u=i(70417),c=i(28874),d=i(40958),h=i(22573),f=i(45599),m=i(96249),p=i(31586),g=i(51926),y=i(57038),w=i(21074),v=(0,f.defer)((()=>(0,s.mkLogger)("db.DbRequest")));t.DbRequest=class{constructor(e,t){this.db=e,this.tableName=t,this.cachedStatements=new r.FifoCache(256)}qb(){return(0,y.knex)()(this.tableName)}prep(e,t=!1){const i=(0,w.toSqlQuery)(e);try{const r=this.cachedStatements.getOrSet(this.db().db.__uid+":"+(!0===t?"pluck:":"")+i.sql,(()=>{const e=this.db().prepare(i.sql);return!0===t?e.pluck():e}));return r.database.open?{sq:i,stmt:r}:(this.cachedStatements.clear(),this.prep(e,t))}catch(e){return v().throw("prep() failed",{error:e,sqlQuery:i,retriable:!1})}}wrap({q:e,pluck:t,m:i}){try{const{sq:r,stmt:s}=this.prep(e,t);c.Settings.logSql.valueOrDefault&&v().log((0,l.defaultLogLevel)(),i+"(): "+(0,w.sqlQueryToS)(r));const n=s[i].bind(s);return null==r.bindings?n():n(r.bindings)}catch(t){if(!0===t.message?.includes("AdvisoryLock"))throw t;v().throw(t,{method:i,...(0,w.toSqlQuery)(e)})}}run(e){return this.wrap({q:e,m:"run"})}runScript(e,t=""){const i=(0,a.mkElapsed)("db.runScript()");for(const r of e){if((0,h.blank)(r)||r.trim().startsWith("--"))continue;this.run({sql:r});const e=(0,g.replaceAll)((0,g.ellipsize)(r,60),t,"");i.elapsed(e)}}mapRun(e){return e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return null==t.bindings?i.run():i.run(t.bindings)}))}runf(e){return this.wrap({q:e(this.qb()),m:"run"})}upsert(e){const t=(0,w.toSqlQuery)(e(this.qb()));return t.sql=t.sql.replace(/^(?:update|insert)\b/i,(e=>e.toUpperCase()+" OR REPLACE ")),this.wrap({q:t,m:"run"})}first(e){return this.wrap({q:e,m:"get"})}firstf(e){return this.wrap({q:e(this.qb()),m:"get"})}mapAll(e){return(0,m.flatten)(e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return i.all(t.bindings)})))}all(e){return this.wrap({q:e,m:"all"})}allf(e){return this.wrap({q:e(this.qb()),m:"all"})}async batched(e){let t,i=0;do{t=this.wrap({q:e.qb(this.qb(),t).limit((0,o.maxBatchPluckSize)()),m:"all"}),(0,d.isNotEmpty)(t)&&(await e.onResults(t),i+=t.length)}while((0,d.isNotEmpty)(t)&&!(0,n.ending)()&&(null==e.maxResults||e.maxResults>i));return{resultCount:i,done:null==t||t.length<(0,o.maxBatchPluckSize)()}}pluckFirst(e){return this.wrap({q:e,pluck:!0,m:"get"})}pluckFirstf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"get"})}pluckAll(e){return this.wrap({q:e,pluck:!0,m:"all"})}pluckAllf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"all"})}async pluckBatched(e){let t=0;const i=(0,u.min)([e.limit??(0,o.maxBatchPluckSize)(),e.maxResults]);if(i<=0||(0,p.lte0)(e.maxResults))return{done:!1,resultCount:t};let r;for(;null==e.maxResults||e.maxResults<=0||t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDbSetupErrorListener=t.hasDbSetupErrors=t.clearDbSetupErrors=t.addDbSetupError=t.dbSetupErrors=t._dbSetupErrors=void 0;const r=i(98314),s=i(22573),n=i(23541);t._dbSetupErrors=new Set;const a=[];t.dbSetupErrors=function(){return[...t._dbSetupErrors.values()]},t.addDbSetupError=function(e){if((0,n.isError)(e)||!(0,s.blank)(e)){t._dbSetupErrors.add((0,r.errorToS)(e));for(const e of a)e()}},t.clearDbSetupErrors=function({notifyListeners:e=!0}={}){if(t._dbSetupErrors.clear(),e)for(const e of a)e()},t.hasDbSetupErrors=function(){return t._dbSetupErrors.size>0},t.addDbSetupErrorListener=function(e){a.push(e)}},36908:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dedupeTags_=t.mergeTags_=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(42231),o=i(40958),l=i(76790),u=i(23838),c=i(31586),d=i(54993),h=(0,r.lazy)((()=>(0,s.mkLogger)("db.DedupeTags")));function f(e,t){function i(t){return e.prepare(t).run()}(0,o.isEmpty)(t)&&h().warn("mergeTags(): empty tagIds",{tagIds:t}),h().info("mergeTags() starting",{tagIds:t});const r=e.prepare("SELECT id, _path, parentId FROM Tag WHERE id IN ("+t.join(",")+") ORDER BY ID").all(),s=(0,o.compactBlanks)(r.map((e=>(0,a.tagPathLeaf)(e._path))).sort()),n=r[0],l=r.slice(1),u=n?.id;if((0,o.isEmpty)(s)||(0,o.isEmpty)(l)||null==n||!(0,c.gt0)(u))return void h().warn("mergeTags(): missing winner",{winner:n,winnerId:u,leafs:s,losers:l});const d=(0,a.splitTagPath)(n._path).slice(0,-1),f=[...d,s[0]];n._path=(0,a.joinTagPath)(f),n.parentId=0===d.length?null:e.prepare("SELECT id from Tag where _path LIKE ?").pluck().get((0,a.joinTagPath)(d))??n.parentId,h().info("mergeTags()",{winner:n,losers:l,winnerTagPath:f,leafs:s});const m=l.map((e=>e.id)).join(",");i(`UPDATE OR IGNORE AssetTag SET tagId = ${u} WHERE tagId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`DELETE FROM AssetTag WHERE tagId in (${m})`),i(`DELETE FROM Tag WHERE id in (${m})`),e.prepare("UPDATE Tag SET parentId = :parentId, _path = :path WHERE id = :id").run({parentId:n.parentId,path:n._path,id:u});const p=e.prepare("SELECT id, _path FROM Tag WHERE id != :winnerId AND _path LIKE :like COLLATE NOCASE").all({winnerId:u,like:n._path+"%"});for(const t of p){const i=(0,a.splitTagPath)(t._path).slice(f.length),r=(0,a.joinTagPath)([...f,...i]);t._path!==r&&(h().info("mergeTags(): repairing tag path",{ea:t,newPath:r}),e.prepare("UPDATE OR IGNORE Tag SET _path = :path, updatedAt = :updatedAt WHERE id = :id").run({id:t.id,updatedAt:Date.now(),path:r}))}return h().tap({msg:"mergeTags()",level:"info",result:{winner:n,losers:r}})}t.mergeTags_=f,t.dedupeTags_=function(e){const t=new u.MultiMap;for(const{id:i,_path:r}of e.prepare("SELECT id, _path FROM Tag ORDER BY id").iterate())t.add((0,n.stripSuffix)((0,d.toS)(r).trim(),a.TagSep).toLowerCase().normalize(),i);const i=(0,l.sortBy)(t.entriesArray().filter((([,e])=>e.length>1)),(([e])=>[-(0,n.countChars)(e,a.TagSep),-e.length,e]));for(const[,t]of i)f(e,t)}},57038:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstMigratedAt=t.knex=void 0;const s=r(i(31832)),n=i(19851),a=i(56519),o=i(55835),l=i(68708);t.knex=(0,n.lazy)((()=>(0,s.default)({client:"better-sqlite3",useNullAsDefault:!0}))),t.firstMigratedAt=async function(e){return(0,a.thenMap)(e("migrations").min("migration_time").first(),(e=>(0,o.map)((0,l.values)(e)[0],(e=>new Date(e)))))}},17036:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Migration=void 0;const o=i(77598),l=i(19851),u=i(50213),c=i(7282),d=i(37805),h=i(4867),f=i(51040),m=i(77740),p=i(38835),g=i(8769),y=i(57159),w=i(34102),v=i(73209),b=i(95696),S=i(43899),P=i(18454),_=i(40958),T=i(42659),M=i(41400),E=i(98553),D=i(55835),x=i(34666),k=i(32639),C=i(45648),F=i(94715),A=i(27134);t.Migration=class{constructor(e,t,i){r.add(this),this.schema=e,this.db=t,this.dbFile=i,this.fsMigrations_=(0,l.lazy)((()=>this.migrationsDir.children_((e=>e.isFile&&e.basename.endsWith(".sql"))).catch((e=>this.logger.throw("Failed to read migration directory, "+this.migrationsDir+p.InternalErrorFlag,{error:e}))))),this.ensureMigrationTable_=(0,l.lazy)((()=>{this.db.exec("\nCREATE TABLE IF NOT EXISTS migrations (\n id INTEGER NOT NULL PRIMARY KEY,\n name TEXT NOT NULL,\n migration_time INTEGER NOT NULL\n) STRICT\n")})),this.unknownMigrations_=(0,l.lazy)((()=>this.migrationsInDatabase_().filter((e=>!(0,x.lt)((0,F.migrationNameToDate)(e),d.gitDate))))),this.assertKnownMigrations_=(0,l.lazy)((()=>{const e=this.unknownMigrations_();if((0,_.isNotEmpty)(e)){const t=new y.WrappedError("Please upgrade PhotoStructure to a newer version to open this library: Unknown migrations: "+e.join(","));throw(0,g.onError)(t),t}})),this.logger=(0,u.mkLogger)("db.Migration("+(0,E.stringify)({schema:e,db:i.nativePath})+")"),this.migrationsDir=b.PosixFile.for(S.ProjectPath.Migrations()).join(this.schema)}async pendingMigrationFiles_(){const e=this.migrationsInDatabase_();return(await this.fsMigrations_()).filter((t=>!e.includes(t.name)))}migrationsInDatabase_(){return this.ensureMigrationTable_(),this.db.prepare("SELECT name from migrations").pluck().all()}async apply_(e){return(0,v.withLock_)({file:this.dbFile.sibling("migrate"),timeoutMs:2*T.minuteMs},(()=>a(this,r,"m",s).call(this,e)))}async applyMigration_(e,t){try{const i=Date.now(),s=F.Migrations[e.name.replace(/^[\d_-]+/,"")],o=(0,k.isFunction)(s);return o?await s.bind(F.Migrations)(this.db):await a(this,r,"m",n).call(this,e),this.logger.debug("applyMigration() completed",{elapsedMs:Date.now()-i,codeMigration:o,migration:e.baseWithParent}),t?.run(e.name,Date.now())}finally{(0,w.ee)().emit("clearDbCache")}}},r=new WeakSet,s=async function(e){try{this.ensureMigrationTable_(),(0,c.isProd)()&&this.assertKnownMigrations_();const t=[],i=this.db.prepare("INSERT INTO migrations (name, migration_time) VALUES (?, ?)");for(const r of await this.pendingMigrationFiles_())await P.HealthCheck.traceLater_("Upgrading database ("+r.name+")",(async()=>{if((0,m.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");(0,m.getDevEnvFlag)("PS_SLOMO")&&await(0,M.delay)((0,o.randomInt)(T.secondMs,3*T.secondMs)),await(0,D.map)(e,(e=>e(r))),await(0,h.thenOrTimeoutError)({p:this.applyMigration_(r,i),timeoutMs:T.minuteMs}).catch((e=>{throw new y.WrappedError("Migration "+r.name+" timed out.",{cause:e,fatal:!0,ignorable:!1})}))})),t.push(r.base);return this.logger.info("Migration complete",{appliedMigrations:t}),t}catch(e){const t=new y.WrappedError("Migrating the "+this.schema+" db failed",{cause:e});throw(0,C.addDbSetupError)(t),P.HealthCheck.addError(t),t}},n=async function(e){const t=e.name.includes("_nofk");try{const i=await e.readTextFile(),r=(0,f.splitBatchSql)(i);if((0,_.isEmpty)(r))this.logger.info("No-op migration: "+e);else{t&&this.db.pragma("foreign_keys = OFF");for(const t of r)try{this.db.exec(t)}catch(i){this.logger.throw("Failed to apply SQL",{stmt:t,migration:e.baseWithParent,cause:i,fatal:!0})}t&&(0,A.foreignKeyCheck_)(this.db)}}finally{t&&this.db.pragma("foreign_keys = ON")}}},94715:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Migrations=t.isoToPrecisionMs=t.fix_root_tags=t.tag_path_suffix=t.migrationNameToDate=t.plucklabmodeb6=t.lowercase_psnet_function=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(97352),o=i(68852),l=i(81168),u=i(85810),c=i(42022),d=i(1971),h=i(79842),f=i(89724),m=i(17415),p=i(88600),g=i(20014),y=i(42231),w=i(87001),v=i(40958),b=i(55835),S=i(31586),P=i(97790),_=i(89937),T=i(54993),M=i(7656),E=i(36908),D=(0,s.lazy)((()=>(0,n.mkLogger)("db.Migrations"))),x=new RegExp(`^(${(0,o.escapeRegExp)(_.PS_NETWORK_FILESYSTEM_SCHEME)}://.*?/)(.*)$`);function k(e,t){return(0,a.mapGt0)(e,(()=>(0,b.map)(function(e,t=c.ModeBits){return(0,g.splitBits)(e,t).map((e=>(0,u.unlabhash)(e,t)))}(e,6)[t],(e=>(0,u.toLabhash)(e,c.ModeBits)))))}function C(e){return e.endsWith(y.TagSep)?e:e+y.TagSep}function F(e){for(const t of e.prepare("SELECT id, parentId, _path FROM Tag WHERE id = parentId").iterate())D().warn("fix_root_tags(): broken tag",{broken:t}),(0,l.countChars)(t._path,y.TagSep)<2&&e.prepare("UPDATE Tag set parentId = null where id = ?").run(t.id)}function A(e){return(0,b.map)((0,h.isoToDated)(e),h.datedToPrecisionMs)??-1}t.lowercase_psnet_function=e=>(0,P.opt)(e).filter(l.isString).flatMap((e=>x.exec(e))).map((e=>e[1].toLowerCase()+e[2])).getOrElse((()=>e)),t.plucklabmodeb6=k,t.migrationNameToDate=function(e){const[t,i,r]=[e.slice(0,4),e.slice(4,6),e.slice(6,8)].map((e=>(0,S.toInt)(e)));return(0,p.validYMD)(t,i,r)?new Date(t,i-1,r):void 0},t.tag_path_suffix=C,t.fix_root_tags=F,t.isoToPrecisionMs=A,t.Migrations={fix_root_tags:F,lowercase_psnet_hostname:e=>{e.function("lowercase_psnet_hostname",{deterministic:!0},t.lowercase_psnet_function),e.exec("DROP INDEX IF EXISTS assetfile_uri_udx"),e.exec("UPDATE AssetFile SET uri = lowercase_psnet_hostname(uri)"),e.exec("CREATE UNIQUE INDEX assetfile_uri_udx ON AssetFile(uri)")},numeric_captured_at:e=>{e.function("isoToLocal",{deterministic:!0},f.isoToLocal),e.function("isoToOffsetMinutes",{deterministic:!0},m.isoToOffsetMinutes),e.function("isoToPrecisionMs",{deterministic:!0},A),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtLocal bigint"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtOffset integer"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtPrecisionMs integer"),e.exec("UPDATE AssetFile SET capturedAtLocal = isoToLocal(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtOffset = isoToOffsetMinutes(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtPrecisionMs = isoToPrecisionMs(capturedAtISO)"),e.exec("DROP INDEX asset_captured_at_geohash_idx"),e.exec("DROP INDEX assetfile_exifuid_idx"),e.exec("CREATE INDEX assetfile_capturedAtLocal_idx ON AssetFile(capturedAtLocal)")},spread_modes:e=>{e.function("plucklabmodeb6",{deterministic:!0},k),(0,S.times)(d.ModeCount,(t=>e.exec(`ALTER TABLE AssetFile ADD COLUMN mode${t} integer`))),e.exec("UPDATE AssetFile SET "+(0,S.times)(d.ModeCount,(e=>`mode${e} = plucklabmodeb6(mode8b6, ${e})`)).join(", "))},normalize_asset_file_uris:e=>{e.function("normalizeURI",{deterministic:!0},w.normalizeURI);const t=e.prepare("SELECT normalizeURI(uri) AS nuri, count(*) AS cnt, GROUP_CONCAT(id) AS ids FROM AssetFile GROUP BY nuri HAVING cnt > 1").all(),i=[];for(const s of t){const t=(0,T.toS)(s.ids).split(","),n=e.prepare("SELECT id, shown, version, updatedAt FROM AssetFile WHERE id in ("+t.join(",")+")").all(),a=(0,r.greatestBy)(n,(e=>[e.shown,e.version,e.updatedAt])),o=n.filter((e=>e.id!==a?.id));i.push(...o.map((e=>e.id)))}for(const t of(0,r.batches)(i,256))e.exec("DELETE FROM AssetFile WHERE id in ("+t.join(",")+")");e.exec("UPDATE AssetFile SET uri = normalizeURI(uri)")},dedupe_tag_paths:E.dedupeTags_,suffix_tag_paths:e=>{e.function("tag_path_suffix",{deterministic:!0},C),(0,E.dedupeTags_)(e),e.exec("UPDATE Tag SET _path = tag_path_suffix(_path)")},normalize_tag_paths:e=>{const t=e.prepare("SELECT id, _path FROM Tag WHERE _path LIKE '%' || char(31) || char(31) || '%'").all();D().info("normalize_tag_paths():",{badTags:t});for(const i of t){const t=(0,y.normalizeTagPath)(i._path);(0,E.mergeTags_)(e,(0,v.compact)([i.id,...e.prepare("SELECT id FROM Tag WHERE _path LIKE ?").pluck().all(t)]))}},drop_tc_tables:e=>{const t=/^(ct|taf|tag_counts)_[a-z\d]{6}$/i,i=e.prepare("SELECT name FROM sqlite_master WHERE type='table'").pluck().all(),r=i.filter((e=>null!=t.exec(e)));D().info("drop_tc_tables()",{tables:i,victims:r});for(const t of r)e.exec("DROP TABLE "+t)},rebuild_rotated_heic:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype = 'image/heif' AND rotation <> 0")},rebuild_videos:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%'"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where mimetype LIKE 'video/%')")},copy_asset_duration:e=>{e.exec("CREATE INDEX tmp_af_idx ON AssetFile (assetId, durationMs)"),e.exec("UPDATE Asset SET durationMs = (SELECT durationMs FROM AssetFile WHERE assetId = Asset.id AND durationMs IS NOT NULL LIMIT 1) WHERE durationMs IS NULL"),e.exec("DROP INDEX tmp_af_idx"),e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%' and durationMs IS NULL"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where version = 0)")},rebuild_tag_asset_counts:M.rebuildTagAssetCounts,create_tag_fts:e=>{e.exec("DROP TABLE IF EXISTS tag_fts"),e.exec("CREATE VIRTUAL TABLE tag_fts USING fts5 (root, path, content='', contentless_delete=1, tokenize=\"unicode61\");")}}},27134:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.repairDbFile_=t.checkpoint_=t.verifyDbFile_=t.verifyDb_=t.foreignKeyCheck_=t.integrityCheck_=t.quickCheck_=t.backupDbFile_=t.sqlite=void 0;const r=i(14121),s=i(19851),n=i(50213),a=i(84777),o=i(12959),l=i(5531),u=i(91872),c=i(99315),d=i(76187),h=i(51040),f=i(38835),m=i(57159),p=i(29882),g=i(95696),y=i(89966),w=i(38156),v=i(28874),b=i(63870),S=i(5233),P=i(42659),_=i(41400),T=i(50357),M=i(98553),E=i(56409),D=i(31586),x=i(20214),k=i(51926),C=i(12168),F=i(59455),A=i(54993),I=i(94448),O=i(9508),L=(0,s.lazy)((()=>(0,n.mkLogger)("db.SQLite")));function R({db:e,pragma:t,okResult:i}){L().debug("pragmaOrThrow_()",{db:N(e),db_open:e?.open,pragma:t,okResult:i});const r=(0,k.isString)(i)?e.pragma(t,{simple:!0}):e.pragma(t);(0,T.eql)(r,i)||L().throw(`${t} failed for ${N(e)}: ${(0,M.stringify)({result:r})}`)}function N(e){return(0,p.ellipsizePath)({p:e.name,maxLength:80})}function B(e){return R({db:e,pragma:"quick_check",okResult:"ok"})}function j(e){return R({db:e,pragma:"integrity_check",okResult:"ok"})}function z(e){const t=(0,F.toA)(e.pragma("foreign_key_check"));t.length>v.Settings.dbInvalidFKThreshold.valueOrDefault&&L().throw("foreignKeyCheck_(): too many invalid foreign keys to repair",{dbInvalidForeignKeyThreshold:v.Settings.dbInvalidFKThreshold.valueOrDefault,badRowsCount:t.length,badRows:t});for(const i of t)L().warn("repairDbFile_(): deleting row with invalid foreign key",{row:i}),e.prepare(`DELETE FROM ${(0,h.dbValueToEscapedString)(i.table)} WHERE rowid = ?`).run(i.rowid)}async function V(e){await(0,u.handleDbRetries_)("db.quickCheck",e,B),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.integrityCheck",e,j),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.foreignKeyCheck",e,z)}function W(e){return(0,O.withDbSync)(e,V,(0,b.commandTimeoutMs)())}t.sqlite=async function({dbFile:e,sql:t,args:i}){const s=await(0,y.sqliteNativePath_)(),n=await(0,r.thenElapsed)((0,a.stdout_)(s,[...(0,F.toA)(i),e.nativePath,t],{timeoutMs:1*P.minuteMs}));return L().debug("sqlite("+t+") on "+e+" in "+n.elapsedMs+"ms",n.result),n.result},t.backupDbFile_=function(e,t){return(0,S.retryOnReject_)((()=>async function(e,t){try{await t.parent().mkdirp_(),await t.unlink("trace");const i=await e.size();if(!(0,D.gt0)(i))return void L().warn("backupDbFile_(): "+e+" is empty");await((0,I.modelDb)()?.end()),await(0,O.withDb)(e,(async e=>e.exec("VACUUM INTO "+(0,h.dbValueToEscapedString)(t.nativePath))),2*P.minuteMs),L().info("backupDbFile_(): Finished "+e+" -> "+t)}catch(i){throw new m.WrappedError(`Could not back up db ${e} -> ${t}`,{cause:i})}}(e,t)),{maxRetries:3,retryDelay:P.secondMs,timeoutMs:P.minuteMs,errorIsRetriable:()=>!0})},t.quickCheck_=B,t.integrityCheck_=j,t.foreignKeyCheck_=z,t.verifyDb_=V,t.verifyDbFile_=W,t.checkpoint_=async function e({db:t,retries:i=3,checkpointType:r=v.Settings.dbWalCheckpointType.valueOrDefault}){if((r=l.CheckpointTypes.getCI(r)??l.CheckpointTypes.AUTO)===l.CheckpointTypes.AUTO)return;const s="wal_checkpoint("+r+")",[n]=(0,F.toA)(t.pragma(s));return L().info("checkpoint()",{pragma:s,result:n}),(0,D.gt0)(n?.busy)&&i>0?(await(0,_.delay)(250),e({db:t,retries:i-1})):n};const U=/no such table: sqlite_\w+/i;t.repairDbFile_=async function(e,t=c.RepairModes.dump){const i=g.PosixFile.for(e),r=(await i.parent().join("db-"+t,(0,o.filestamp)()).mkdirp_()).join(i.base);L().info(`repairDbFile_(${i} -> ${r})`);try{const e=await(0,y.sqliteNativePath_)(),s=4*Math.min(20*C.MiB,await(0,d.sqliteSizeBytes)(i)),n=new w.PushProgressObserver({path:(0,A.toS)(i),op:"Repairing your database"},s),o=new E.Latch,l=(0,a.execFile)(e,[i.nativePath,"."+t],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});l.stdout.on("error",(e=>{const i=(0,A.toS)(e);U.test(i)?L().info("repairDbFile_(): ignoring stderr",{err:i}):o.reject(new Error("sqlite "+t+" failed: "+i))}));const u=(0,a.execFile)(e,[r.nativePath],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});u.on("exit",(()=>o.resolve())),l.stdout.on("end",(()=>{u.stdin.end(null)})),l.stdout.on("data",(e=>{const t=e.length;n.incrProgress(t),u.stdin.write(e)})),await o,L().info(`repairDbFile_(): recovered to ${r}.`),await W(r),L().info(`repairDbFile_(): ${r} is valid, finishing repair.`);const c=await(0,x.thenCollect)((0,d.sqliteFiles)(i),(e=>e.renameYMDHMS_({subdir:"needed-repair"})));return await(0,x.thenCollect)((0,d.sqliteFiles)(r),(e=>e.mv_(i.parent()))),c.find((e=>".db"===e.ext||e.ext.startsWith(".sqlite")))}catch(e){return L().throw("failed to recover DB via dump and restore. Please see https://photostructure.com/faq/restore-db-from-backup/ "+f.FatalErrorFlag,{error:e})}}},21074:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqlWhereInClause=t.isQueryBuilder=t.sqlQueryToS=t.toSqlQuery=t.isSqlQuery=void 0;const r=i(48884),s=i(68852),n=i(81168),a=i(12943),o=i(96249),l=i(98553),u=i(31586),c=i(68708),d=i(32639),h=i(54993);function f(e){return null!=e&&(0,n.isString)(e.sql)&&(null==e.bindings||(0,a.isDbValued)(e.bindings))}t.isSqlQuery=f,t.toSqlQuery=function(e){if(null==e)throw new Error("null sql");if(f(e))return e;if((0,n.isString)(e))return{sql:e};if((0,d.isFunction)(e.toSQL))return(0,c.omit)(e.toSQL(),"__knexQueryUid");throw new Error("not queryish: "+(0,l.stringify)(e))},t.sqlQueryToS=function(e){if(null==e.bindings)return e.sql;if(Array.isArray(e.bindings))return(0,o.flatten)((0,r.zip)(e.sql.split("?"),e.bindings.map((e=>(0,l.stringify)(e))))).join("");{let t=e.sql;for(const i of(0,c.keys)(e.bindings))t=t.replace(new RegExp("[@:$]"+(0,s.escapeRegExp)(i),"gi"),(0,h.toS)(e.bindings[i]));return t}},t.isQueryBuilder=function(e){return(0,d.isFunction)(e?.where)&&(0,d.isFunction)(e?.limit)},t.sqlWhereInClause=function(e){return"("+(0,u.times)(e,(()=>"?")).join(",")+")"}},35052:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localTableInfo=t.parseTableInfo=void 0;const r=i(22573),s=i(23838);function n(e){const t=new s.MultiMap;for(const i of e)i.tableName.includes("fts")||i.tableName.includes("sqlite_")||(0,r.blank)(i.name)||(0,r.blank)(i.type)||t.add(i.tableName,{name:i.name,type:i.type.toUpperCase().trim().replace(/\s+/g,""),notnull:1===i.notnull,pk:1===i.pk});return t.entriesArray().map((([e,t])=>({tableName:e,columns:t})))}t.parseTableInfo=n,t.localTableInfo=function(e){return n(e.prepare("SELECT \nm.tbl_name as tableName,\np.*\nFROM sqlite_master AS m\nJOIN pragma_table_info(m.name) AS p\nORDER BY m.tbl_name, p.cid").all())}},9508:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withDb=t.withDbSync=void 0;const r=i(80632),s=i(28874),n=i(30301),a=i(54993);t.withDbSync=function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const o=(0,n.lazy)((()=>(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i})));try{return t((function(){const e=o();return e.open?e:o.refresh()}))}finally{o.prior()?.close()}},t.withDb=async function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const n=(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i});try{return await t(n)}finally{n.close()}}},53493:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(50213),s=i(45608),n=i(69554),a=i(38790),o=i(53978),l=i(95696),u=i(48368),c=i(45200),d=i(40958),h=i(22573),f=i(38639),m=i(98553),p=i(31586),g=i(68708),y=i(5670),w=i(64526),v=i(37158),b=i(31503),S=i(57038),P=i(21074),_=i(43487),T=i(48723),M=i(94710),E=i(23523);!async function(){try{const e=new n.CLI(y.ServiceNames.list).add(b.LogArgs,a.ColorArgs,o.TimingArg);e.add({beforeParse:e=>e.option("--primary",'Only include the primary, or "best" asset file variation found for every asset. See https://phstr.com/dedupe for details.').option("--no-primary","Exclude primary asset file variation for every asset. This is mutually exclusive with the --primary option, and returns all rows that option omits.").option("--limit ","Emit at most LIMIT values.",p.toGt0).option("--query ","Apply the given query and return all matching asset file paths. Must be the last argument. Incompatible with --where.").option("-j, --json",'Emit a JSON object for every asset file with "hidden" and "shown" flags').option("--dump","Emit a JSON object that includes all column values").option("--where ","Apply a SQL WHERE clause to filter the rows returned. If this is omitted, only shown assets are returned: hidden, excluded, deleted, and incomplete assets will be omitted.").option("--orderby ","Apply a SQL ORDER BY clause to filter the rows returned.").option("-0, --print0",'Print each full native path name to standard output, followed by a null character (instead of the newline character).\nThis is suitable for properly handling filenames that include whitespace characters in shell pipelines using commands like xargs, which has a "--null" mode which expects filenames to be separated by the null character.\nThis cannot be used with --json or --dump.').option("--looks-like ","Find images that look like the photo or video specified by FILE. Use a full pathname.").option("--tasks","List the currently enqueued tasks that sync is process(ing). Implies --json. Does not support --print0.").option("--tags","List all tag paths along with their counts. Implies --json. Does not support --print0.")});const t=(await e.parse()).opts(),i=(0,d.mapNotEmpty)(t.query,(e=>e.join(" "))),D=(0,f.isTrue)(t.dump),x=D||(0,f.isTrue)(t.json),k=t.where;if(null!=i&&(0,h.notBlank)(k))throw new Error("--query cannot be used with --where");const C=new v.Service("list");await C.ready;const F=await w.Library.instanceRequired_().modelDb(),A=(0,r.mkLogger)("list");function I(e){for(const i of e)!0===t.print0?process.stdout.write(i+"\0"):console.log(i)}if((0,f.isTrue)(t.tags)){const V=T.Tag.ops().allf((e=>T.Tag.orderBy(e)));return void console.log((0,m.stringifyPretty)(V.map((e=>(0,g.pick)(e,"path","assetCount")))))}if((0,f.isTrue)(t.tasks)){const W=M.Task.ops().allf((e=>M.Task.orderBy(e)));return void(W.length>0?console.log((0,m.stringifyPretty)(W)):console.error("No pending items in any queues."))}let O=_.Asset.query().join("AssetFile","AssetFile.assetId","Asset.id").join("AssetTag","AssetTag.assetId","Asset.id");if(O=O.select({assetId:"AssetFile.assetId",assetFileId:"AssetFile.id",shownFile:"AssetFile.shown",mountpoint:"AssetFile.mountpoint",uri:"AssetFile.uri",hidden:"Asset.hidden",rating:"Asset.rating"}).distinct(),(0,h.notBlank)(t.looksLike)){const U=l.PosixFile.for(t.looksLike);A.info("Calculating image hash for "+U);const q=await U.sha(),H=await(0,u.imageHash)(U);if(null==H)throw new Error("Failed to generate image hash for "+U);A.info("Looking for assets with matching meanHash or SHA",{meanHash:H.meanHash,SHA:q}),O=O.where((e=>e.where("AssetFile.meanHash",H.meanHash).orWhere("AssetFile.sha",q)))}D&&(O=O.select((0,S.knex)().raw("AssetFile.*"),(0,S.knex)().raw("Asset.*"))),O=(0,h.notBlank)(k)?O.andWhere((0,S.knex)().raw(k)):_.Asset.shownUnhidden(O),!0===t.primary&&(O=O.andWhere("AssetFile.shown",1)),!1===t.primary&&(O=O.andWhere("AssetFile.shown",0)),(0,p.gt0)(t.limit)&&(O=O.limit(t.limit));const L=(0,h.toNotBlank)(t.order)??"uri",R=null!=i?(0,E.queryStringToSql_)(i,O).orderByRaw(L):O,N=(0,P.toSqlQuery)(R);A.info("Running SQL query...",{sq:N});const B=Date.now(),j=F.prepare(N.sql).iterate(N.bindings);A.info("query took "+(Date.now()-B)+"ms"),x&&console.log("[");let z=!0;for(const $ of j){A.throwIfAborted_();const G=await(0,c.uri2nativePath)($.uri,$.mountpoint);x?(z||process.stdout.write(","),process.stdout.write((0,m.stringify)({path:G,...(0,g.omit)($,"id")}))):null==G?console.error("Failed to decode URI to native path: ",(0,m.stringify)($)):I([G??$.uri]),z=!1}x&&console.log("]")}catch(J){await(0,s.exit)({error:J})}finally{await(0,s.exit)({status:0})}}()},43487:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Asset=void 0;const u=i(48884),c=i(19851),d=i(50213),h=i(88158),f=i(45393),m=i(56519),p=i(89724),g=i(38835),y=i(74128),w=i(79847),v=i(28874),b=i(47783),S=i(38010),P=i(40958),_=i(76790),T=i(75761),M=i(38639),E=i(11371),D=i(98553),x=i(55835),k=i(31586),C=i(20214),F=i(59455),A=i(64526),I=i(4407),O=i(54017),L=i(48722),R=i(37094),N=i(45295),B=i(39604),j=i(48723),z=i(41507),V=i(72761),W={"Asset.shown":1,"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null};class U extends V.TimestampedModel{constructor(){super(...arguments),r.add(this),this.attrs={},this.assetIdish=(0,c.lazy)((()=>({assetId:this.id,v:this.updateCount,capturedAtLocal:this.capturedAtLocal}))),this.mergedTags=(0,c.lazy)((async()=>{const e=[];for(const t of this.getAssetFiles()){const i=await t.posixFile(),r=await(0,b.readTags)(i),s=await(i?.mtimeMs());null!=i&&null!=r&&null!=s&&e.push({...r,SourceFile:i.nativePath,sourceModifiedTime:s,sourceIsPrimary:(0,M.isTrue)(t.shown)})}const t=R.AssetRevision.ops().allf((e=>e.where({assetId:this.id}))),i=new S.MergedTags("Asset:"+this.id);return i.addTag(...e,...this.assetFiles),i.addRevision(...t),i}))}static shownUnhidden(e){return null==e?s.query().where(W):e.andWhere(W)}static findUnhiddenById(e){return(0,k.gt0)(e)?s.ops().firstf((t=>s.shownUnhidden(t.where({id:e})))):void 0}static shownRemovable(e,t){return(t??s.query()).whereNotNull(e).andWhere({"Asset.shown":1})}static shownCount(){return s.ops().count(s.shownUnhidden().countDistinct("Asset.id"))}static deletePreviews(e){return A.Library.instance().previews().ap(e).deleteAll()}static async remove({assetId:e,blocklistShas:t,unlinkAssetFiles:i}){const r=(0,d.mkLogger)("Asset("+e+").remove()"),n=s.ops().findById(e);if(null==n)return void r.warn("asset not found");const a=n.isActive(),o=n.tagIds();r.info("starting",{unlinkAssetFiles:i});const l=n.getAssetFiles({refresh:!0});if(t){(0,B.upsertToShaBlockslist)(...l.map((e=>e.sha)));for(const e of l)(0,y.syncReport)().onProgress({from:"Asset.remove",path:await e.getNativePath()??e.uri,state:"blocklisted",details:"sha blocklisted (files with the same sha will not be imported)"})}N.AssetTag.dbl.runf((t=>t.delete().where({assetId:e}))),O.AssetFile.dbl.runf((t=>t.delete().where({assetId:e}))),R.AssetRevision.dbl.runf((t=>t.delete().where({assetId:e}))),s.dbl.runf((t=>t.delete().where({id:e}))),a&&j.Tag.deltaAssetCountAndAncestors(o,-1);try{await s.deletePreviews(e)}catch(e){r.error("Failed to delete previews",{error:e})}return{deletedMeta:i?await(0,w.trashOrUnlinkFileUris_)(l):[],assetFileMeta:l}}static nextOutdated(e=h.identity){return this.ops().findOne(e(l(this,s,"m",n).call(this)))}static nextOutdateds(e){return this.ops().all(e(l(this,s,"m",n).call(this)))}static outdatedCount(e=h.identity){return this.dbl.pluckFirst(e(l(this,s,"m",n).call(this)).count())}static findFirstByFile(e){return this.ops().findOne(e(this.query().select("Asset.*").join("AssetFile","AssetFile.assetId","Asset.id")))}static unshownAssetIds(){return this.dbl.pluckAll("\n SELECT DISTINCT af1.assetId\n FROM AssetFile af1\n LEFT JOIN (SELECT DISTINCT assetId FROM AssetFile WHERE shown = 1) AS af2 \n ON af1.assetId = af2.assetId\n WHERE af2.assetId IS NULL")}static archive(e){null!=s.ops().findById(e)&&(N.AssetTag.dbl.runf((t=>t.where({assetId:e}).delete())),O.AssetFile.dbl.runf((t=>t.where({assetId:e}).delete())),s.dbl.runf((t=>t.where({id:e}).delete())))}markUnshownAndUpsert(){this.shown=!1,this.version=f.AssetVersion,this.upsert()}markShownAndUpsert_(e){const t=this.getShown()?.id;if(null!=e){const t=e.shown;this.setShown_(e,{skipUpsert:!0}),!0!==t&&e.upsert()}this.shown=!0,this.version=f.AssetVersion,t!==this.getShown()?.id&&(this.updateCount=(this.updateCount??0)+1),this.upsert()}async updateFromFiles(){const e=await this.mergedTags();(0,x.map)(e.get("rating"),(e=>{this.logger().info("updateFromFiles()",{rating:e}),this.rating=e.value}))}isActive(){return(0,k.gt0)(this.id)&&!0===this.shown&&null==this.excludedAt&&null==this.deletedAt&&(null==this.rating||(0,k.gte)(this.rating,v.Settings.rejectRatingsLessThan.valueOrDefault))}toAssetId(){return(0,L.toAssetId)(this)}renderCaption(e){return(0,x.map)(this.capturedAtLocal,(t=>"Taken "+(0,p.fmtLocalDateShort)(t,e)))}async whenApiTag(){const e=(0,I.dateTag)((0,p.localToDateObject)(this.capturedAtLocal));return null==e?void 0:j.Tag.findOrCreate(e).toApiTag()}findAssetFileByUri(e){return this.getAssetFiles()?.find((t=>t.uri===e))}addAssetFile(e){(0,P.filterInPlace)(e.asset?.assetFiles??[],(t=>!(t.id===e.id||t.uri===e.uri))),e.assetId=this.id,e.asset=this,e.shown=!1,this.getAssetFiles().push(e),this.clear(),this.capturedAtLocal??(this.capturedAtLocal=e.capturedAtLocal),this.rating??(this.rating=e.rating),this.durationMs??(this.durationMs=e.durationMs)}async assetFileForFile_(e,t){const i=await e.uri();if(null==i)return this.logger().throw("assetFileForFile_(): null uri",{f:e});const r=this.getAssetFiles().find((e=>e.uri===i));if(null!=r)return r;const s=new O.AssetFile;return this.addAssetFile(s),!0!==t?.skipUpsert?await s.upsertIfNeeded_(e):await s.setFile_(e),s}static getTags(e){return j.Tag.ops().all(j.Tag.query().select("Tag.*").join("AssetTag","AssetTag.tagId","Tag.id").where("AssetTag.assetId",e).orderByRaw("COALESCE(Tag.ordinal, Tag._path)"))}tagIds(e){return!0===e?.refresh&&(this.tags=void 0),this.tags?.map((e=>e.id))??N.AssetTag.dbl.pluckAllf((e=>e.select("tagId").where({assetId:this.id})))}getTags(e){return!0===e?.refresh&&(this.tags=void 0),this.tags??(this.tags=s.getTags(this.id))}tagPaths(){return this.getTags().map((e=>e.path.join("/"))).sort()}setTagIds(e){const t=this.tagIds({refresh:!0});if((0,u.eqlUnordered)(t,e))return void this.logger().debug("setTagIds(): no-op, tagIds unchanged");const i=e.filter((e=>!t.includes(e))),r=t.filter((t=>!e.includes(t)));return this.applyTagIdDeltas({tagIdsToAdd:i,tagIdsToRemove:r})}applyTagPathDeltas(e){return this.applyTagIdDeltas({tagIdsToAdd:j.Tag.findOrCreateByPathN(e.add??[]).map((e=>e.id)),tagIdsToRemove:j.Tag.findByPathN(e.remove??[]).map((e=>e.id))})}applyTagIdDeltas(e={}){const t=this.tagIds({refresh:!0}),i=(0,P.uniq)((0,F.toA)(e.tagIdsToAdd).filter((e=>(0,k.gt0)(e)&&!t.includes(e)))),r=(0,P.uniq)((0,F.toA)(e.tagIdsToRemove).filter((e=>(0,k.gt0)(e)&&t.includes(e))));if((0,P.isEmpty)(i)&&(0,P.isEmpty)(r))return this.logger().info("applyTagIdDeltas(): no-op, no changes",{currentTagIds:t,...e}),t;this.isActive()&&j.Tag.deltaAssetCountAndAncestors(t,-1),(0,P.isEmpty)(i)||N.AssetTag.dbl.runf((e=>e.insert(i.map((e=>({assetId:this.id,tagId:e})))).onConflict(["assetId","tagId"]).ignore())),(0,P.isEmpty)(r)||N.AssetTag.dbl.runf((e=>e.whereIn("tagId",r).andWhere({assetId:this.id}).delete())),this.tags=void 0;const s=(0,P.uniq)([...t,...i]).filter((e=>!r.includes(e)));return this.isActive()&&j.Tag.deltaAssetCountAndAncestors(s,1),s}getStreams(e){if(null==this.streams){const t=this.getTags();this.logger().info("getStreams(): fetched tags "+t,{limit:e});const i=t.map((t=>t.getAssetStream(this,e)));this.streams=(0,z.coalesceStreams)((0,P.compact)(i));for(const e of this.streams)for(const t of e.tags)t.getAncestors()}return this.streams}getBeforeAfterId(){const e=s.dbl.all(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",this.capturedAtLocal).orderBy("assetId"));this.afterId=e.find((e=>e.assetId>this.id)),this.beforeId=e.reverse().find((e=>e.assetIde.path))}getAssetFiles({refresh:e=!1}={}){return null!=this.id&&(e&&(this.assetFiles=void 0),this.assetFiles??(this.assetFiles=(0,_.sortBy)(O.AssetFile.ops().findBy({assetId:this.id}),(e=>[!(0,M.isTrue)(e.shown),-e.mtime])))),this.assetFiles??[]}setShown_(e,t){e instanceof O.AssetFile&&(this.getAssetFiles(),this.assetFiles?.some(((t,i)=>{const r=t.id===e.id||t.uri===e.uri;return r&&(this.assetFiles[i]=e),r})));const i=e instanceof O.AssetFile?e.id:e;if(this.getShown()?.id===i)return void this.logger().debug("setShown_(): no-op, already set",{afId:i});this.logger().info("setShown_()",{assetId:this.id,assetFileId:i}),(0,k.gt0)(this.id)&&(0,k.gt0)(i)||this.logger().throw("setShown_(): invalid IDs: "+(0,D.stringify)({assetId:this.id,assetFileId:i})+g.InternalErrorFlag);const r=Date.now();O.AssetFile.dbl.runf((e=>e.update({shown:0,updatedAt:r}).where({assetId:this.id}))).changes<=0&&this.logger().warn("setShown_(): all asset files were already unshown",{afId:i});const s=O.AssetFile.dbl.runf((e=>e.update({shown:1,updatedAt:r}).where({id:i})));1!==s.changes&&this.logger().throw("setShown_(): failed to update asset file: unexpected changed rows",{runResult:s});const n=this.assetFiles?.find((e=>e.id===i))??this.getAssetFiles({refresh:!0}).find((e=>e.id===i));if(null!=n){this.capturedAtLocal=n.capturedAtLocal,this.rating=n.rating,this.durationMs=n.durationMs;for(const e of this.assetFiles??[])e.shown=e.id===i;!0!==t?.skipUpsert&&this.upsert()}else this.logger().throw("setShown_(): failed to find shown asset file",{af:e})}getShown(e){return this.getAssetFiles(e)?.find((e=>(0,M.isTrue)(e.shown)))??this.getAssetFiles({refresh:!0})?.find((e=>(0,M.isTrue)(e.shown)))}getShownNativePath(){return this.getShown()?.getNativePath()}async getCapturedAts(){return(0,C.thenCollect)(this.getAssetFiles(),(e=>e.capturedAt()))}link(){return"/asset/"+this.id}sqAttrs(e=!0){return{...(0,T.assetSqImgAttrs)({assetId:this.assetIdish(),lazyLoad:e}),title:this.renderCaption(),...this.attrs}}async getImgAttrs(e,t,i=!1){if(null==this.imgAttrs&&(this.imgAttrs=new Map),null==this.imgAttrs.get(t)){const r=e.ap(this.id);await(0,m.thenMap)(r.readInfo(),(async e=>{e.mimetype.startsWith("video/")&&(this.poster=await r.posterLink())}));const s=!0;this.imgAttrs.set(t,await r.imgAttrs(t,s,i))}return this.imgAttrs.get(t)}async fitAttrs(e){return{...await this.getImgAttrs(e,E.ReducerNames.fit),...this.attrs}}isVideo(){if(null==this.assetFiles)throw new Error(".video called before getFiles()");return this.assetFiles.some((e=>e.isVideo))}videoAttrs(){return{controls:!0,autoplay:!0,poster:this.poster,...this.attrs}}async videoSources(){const e=[];let t;for(const i of this.getAssetFiles())e.some((e=>e.type===i.mimetype))||await i.exists()&&(t??(t=i),e.push({src:(0,T.assetVideoLink)({assetId:this.assetIdish(),assetFileId:i.id}),type:i.mimetype}));return e.some((e=>"video/mp4"===e.type))||null==t||e.unshift({src:(0,T.assetVideoLink)({assetId:this.assetIdish(),assetFileId:t.id})+".mp4",type:"video/mp4"}),e}async getPosixFiles(){return(0,C.thenCollect)(this.getAssetFiles(),(e=>e.posixFile_()))}async getExistingAssetFiles(){return(0,m.filterAsync)({name:"getExistingAssetFiles",arr:this.getAssetFiles(),f:e=>e.exists()})}async findOrCreateByFile(e){const t=await e.uri_();if(null==t)return;const i=(0,F.toA)(O.AssetFile.ops().findBy({assetId:this.id,uri:t}))[0];return(0,x.orElse)(i,(async()=>{const t=new O.AssetFile;return t.asset=this,t.assetId=this.id,await t.setFile_(e),t}))}partialSimpleAsset(){return{assetId:this.id,liked:(0,k.gte)(this.rating,v.Settings.likeRating.valueOrDefault),hidden:(0,M.isTrue)(this.hidden),excluded:null!=this.excludedAt,deleted:null!=this.deletedAt}}clear(){return this.imgAttrs=void 0,this.streams=void 0,this.tags=void 0,this.mergedTags.unset(),this}}t.Asset=U,s=U,r=new WeakSet,n=function(){return s.shownUnhidden().andWhere("version","<",f.AssetVersion)},a=function(){return this.beforeId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal","<",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId",order:"desc"}]))},o=function(){return this.afterId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",">",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"asc"},{column:"assetId",order:"asc"}]))},U.$tableName="Asset",U.$uniqueColumnName="id",U.$booleanFields=["shown","hidden"]},54017:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFile=void 0;const a=i(76760),o=i(19851),l=i(88158),u=i(45393),c=i(68852),d=i(81168),h=i(13991),f=i(54296),m=i(56519),p=i(76490),g=i(89724),y=i(98314),w=i(38835),v=i(8769),b=i(29882),S=i(95696),P=i(62105),_=i(74128),T=i(35721),M=i(69589),E=i(28874),D=i(28544),x=i(16170),k=i(45200),C=i(34238),F=i(87001),A=i(42233),I=i(21404),O=i(40958),L=i(17586),R=i(22573),N=i(38639),B=i(42659),j=i(33374),z=i(50357),V=i(75240),W=i(11371),U=i(55835),q=i(31586),H=i(68708),$=i(34666),G=i(89937),J=i(75020),K=i(64526),Y=i(41844),Z=i(43487),X=i(48723),Q=i(94710),ee=i(72761);class te extends ee.TimestampedModel{constructor(){super(...arguments),r.add(this),this.uriObj=(0,o.lazy)((()=>C.URI.parse(this.uri))),this.whyRejected=(0,o.lazy)((async()=>{const e=await this.posixFile_();return null==e?"invalid URI":!0===await this.isFileDeleted()?"deleted":(0,P.whyRejectFile)(e)})),this.posixFile_=(0,o.lazy)((async()=>S.PosixFile.for(await this.getNativePath())))}static outdatedQuery(e){let t=(e.q??this.query()).where("version","<",u.AssetFileVersion);return null!=e.maxUpdatedAt&&(t=t.andWhere("updatedAt","<",e.maxUpdatedAt)),t.andWhere((t=>{(0,O.isNotEmpty)(e.mountpoints)&&(t=t.whereIn("mountpoint",e.mountpoints));for(const i of e.uris)t=t.orWhereLike("uri",i+"%");return t})).orderBy("id")}static async nextOutdated(e=l.identity){return this.ops().findOne(e(this.outdatedQuery(await(0,A.currentVolumeRoots)())))}static async outdatedCount(e=l.identity){const t=this.outdatedQuery(await(0,A.currentVolumeRoots)());return this.dbl.pluckFirst(e(t.count("id")))}static shownAssetFileId(e){return this.dbl.pluckFirstf((t=>t.where({assetId:e,shown:1}).limit(1)))}static primaryForAssetId(e){return(0,q.gt0)(e)?te.ops().first(Z.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id").select("AssetFile.*").where({assetId:e,"AssetFile.shown":1})):void 0}static shownUnhidden({uriRoot:e}={}){let t=Z.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id");return(0,R.blank)(e)||(t=t.andWhereLike("AssetFile.uri",e+"%")),t}static recentAssetIdsByUriRoot(e,t,i=64){const r=Date.now()-t;return this.dbl.pluckAll(te.shownUnhidden({uriRoot:e}).distinct("AssetFile.assetId").where("AssetFile.updatedAt",">",r).orderBy("AssetFile.updatedAt","desc").limit(i))}static assetFileCountByMimeType(e){const t=te.shownUnhidden({uriRoot:e}).select("mimetype").countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"}).groupBy("mimetype").orderBy("mimetype");return this.dbl.all(t)}static assetFileCountWithMimeType(e,t){let i=te.shownUnhidden({uriRoot:t}).countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"});return i=e.endsWith("/")?i.andWhereLike("mimetype",e+"%"):i.andWhere("mimetype",e),this.dbl.first(i)}static assetFileCountByMimeTypeRoots(e=["image/","video/"],t){return e.map((e=>({mimeTypeRoot:e,assetFileCount:te.assetFileCountWithMimeType(e,t)?.assetFileCount??0})))}static children(e,t){const i=this.query().whereLike("uri",e+"/%").andWhere("uri","regexp",`^${(0,c.escapeRegExp)(e)}/[^/]+$}`);return this.ops().all(null==t?i:t(i))}static async sameShaInLibrary(e){if(null==this.db())return;const t=await e.sha(),i=await e.size();return null!=t&&null!=i?this.ops().allf((e=>e.where({sha:t,fileSize:i}).andWhereLike("uri",G.PS_LIBRARY_PROTOCOL+"%"))):void 0}static sameAssetFileInLibrary(e){return this.ops().allf((t=>t.where((0,H.pick)(e,"sha","fileSize")).andWhere((e=>e.whereLike("uri",G.PS_LIBRARY_PROTOCOL+"%"))).andWhere((t=>t.whereNot({id:e.id})))))}librarySiblings(){return this.getAsset()?.getAssetFiles().filter((e=>e.id!==this.id&&e.uri.startsWith(G.PS_LIBRARY_PROTOCOL)))}capturedAtLocale(e){return(0,g.fmtLocalDateShort)(this.capturedAtLocal,e)}get dominantColors(){return p.DominantColor.fromModeData(this)}set dominantColors(e){(0,H.assignAllFields)(this,p.DominantColor.toModeData(e))}get posixPathFromGrandparent(){return(0,U.map)(this.uriObj()?.fsPath,b.posixPathFromGrandparent)}async whyNotMatchesFile(e){const t=n(this,r,"m",s).call(this);if(null!=t)return t;if(null==this.fileSize||null==this.mtime)return"missing file metadata";if(null!=e){const t=await e.uri();if(null==t)return"file has no URI";if(!await(0,F.uriIsEquivalent)(this.uri,t))return"file URI mismatch"}try{const t=e??await this.posixFile_();if(!await t.exists())return"file is missing";const i=await this.fileFields_(t);return null==i?!0===await(t?.isDeleted())?"file is deleted":"file is unreadable":i.fileSize!==this.fileSize?"file size changed since last sync":(0,q.closeTo)(i.mtime,this.mtime,2*B.secondMs)?void 0:"file mtime changed since last sync"}catch(e){return(0,y.errorToS)(e)}}async matchesFile(e){const t=await this.whyNotMatchesFile(e);return this.logger().tap({level:"info",msg:"matchesFile()",result:null==t,meta:{whyNot:t}})}async whyNotInSyncWithFile(e){return E.Settings.forceSync.valueOrDefault?E.Settings.forceSync.key+"=true":this.version!==u.AssetFileVersion?"AssetFileVersion: "+this.version+" != "+u.AssetFileVersion:this.whyNotMatchesFile(e)}async inSyncWithFile(e){const t=await this.whyNotInSyncWithFile(e);return this.logger().tap({msg:"inSyncWithFile()",result:null==t,meta:{whyNotInSync:t}})}async fileFields_(e){const t=e??await this.posixFile_();return null==t?void 0:await(0,h.assetFileStatFields_)(t)}isInLibrary(){return this.uri.startsWith(G.PS_LIBRARY_PROTOCOL)}async isNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){const t=await this.whyNotNoop(e);return this.logger().tap({msg:"isNoop()",result:null==t,meta:{whyNotNoop:t}})}async whyNotNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){if(!0===e.forceSync)return"forceSync is true";if(!(0,q.gt0)(this.id))return"missing .id";if(!(0,q.gt0)(this.assetId))return"missing .assetId";{const e=await this.whyNotInSyncWithFile();if(null!=e)return e}if(await(0,Y.mayCopyAssetsToLibrary)()){const e=K.Library.instanceRequired_().assetFileRepository(),t=e.whyNotCopyFile(await this.posixFile_());if((0,R.blank)(t)&&null==await e.existingLibraryAssetFile(this))return"need to copy into library"}this.syncState=_.AssetFileSyncStates.noop}isVersionUpToDate(){return(0,$.gte)(this.version,u.AssetFileVersion)}async siblingCount(){return te.dbl.pluckFirstf((e=>e.count().where({assetId:this.assetId}).andWhereNot({id:this.id})))}async upsertIfNeeded_(e,t=(0,M.forceContextOrSetting)()){if(null!=e&&await this.setFile_(e),await this.matchesFile()&&(0,q.gt0)(this.id)&&!t.forceSync)return void(null==this.syncState&&(this.upsert(),this.syncState??(this.syncState=_.AssetFileSyncStates.noop)));const i=await this.isFileDeleted();if(!0===i)return this.syncState=_.AssetFileSyncStates.deleted,this.delete(),!0!==t.skipAssetRepair&&Q.Task.addOne("repairAsset",{assetId:this.assetId}),this;if(!1===i){const i=await this.updateFromFile_(e,t);return this.syncState??(this.syncState=null==i?_.AssetFileSyncStates.noop:_.AssetFileSyncStates.synced),this.upsert()}return this.syncState??(this.syncState=_.AssetFileSyncStates.skipped),this}async updateFileFields_(e){(0,H.assignFields)(this,await this.fileFields_(e))}async updateFromFile_(e,t=(0,M.forceContextOrSetting)()){const i=Date.now(),r=this.logger().addContext(".updateFromFile_()");if(null!=this.id&&!0!==t.forceSync&&await this.matchesFile(e))return void r.info("updateFromFile() no-op: up-to-date version and file stat matches since last update");if(null!=e&&await this.setFile_(e),null==e&&(e=await this.posixFile_()),null==e||await e.clear().notExists())return this.syncState=_.AssetFileSyncStates.deleted,void r.info("no-op, "+e+" is missing");const s=await(0,h.mkAssetFile_)(e);return s.uri!==this.uri&&((0,R.blank)(this.uri)||!0===this.uri?.startsWith("file:"))&&(this.logger().warn("updateFromFile() upgrading uri",{prior:this.uri,new:s.uri}),this.uri=s.uri),(0,H.assignAllFields)(this,(0,H.omit)(s,"uri")),this.version=u.AssetFileVersion,this.syncState=_.SyncFileStates.synced,r.elapsed("finished",Date.now()-i,this.toJSON()),this}async updateFromShaSibling_(e){const t=n(e,r,"m",s).call(e);if(null==t){if(await this.exists())return this.logger().debug("updateFromShaSibling",e),null!=e.sha&&await e.matchesFile()&&this.sha===e.sha?((0,H.assignFields)(this,(0,H.omit)(e,"id","posixFile","uriObj","shown","uri","mtime","fileSize","mountpoint","createdAt","updatedAt","updateCount",...te.$transientFields)),this.updateFileFields_()):this.updateFromFile_();this.logger().warn("updateFromShaSibling(): fail: file is missing")}else this.logger().warn("updateFromShaSibling() sibling is invalid",{whySiblingIsInvalid:t})}getAsset(){return this.asset??(this.asset=(0,q.gt0)(this.assetId)?Z.Asset.ops().findById(this.assetId):void 0)}exists(){return(0,k.uriExists)(this.uri,this.mountpoint)}async isFileDeleted(){return(await this.posixFile_())?.isDeletedUri(this.uri)}async accepted(){return(0,R.blank)(await this.whyRejected())}async setFile_(e){const t=await e.uri_();if(null==t)return this.logger().throw("setFile(): no URI for "+e);const i=await e.mountpoint();if(null!=this.uri&&!await(0,F.uriIsEquivalent)(t,this.uri))return this.logger().throw("setFile(): cannot reassign non-equivalent URI",{prior:this.uri,new:t,file:e.nativePath});const r=await e.uriObject_();return null==r?this.logger().throw("failed to create URI for "+e):(this.uri=t,this.uriObj.set(r),this.mountpoint=i?.nativePath,this.nativePath=e.nativePath,this.posixFile_.set(Promise.resolve(e)),this)}get basename(){return(0,R.blank)(this.uri)?void 0:decodeURIComponent(this.uri.slice(this.uri.lastIndexOf("/")+1))}posixFile(){return this.posixFile_().catch((()=>{}))}async getNativePath(){return(0,R.blank)(this.nativePath)&&(null==this.uri?this.logger().error(".getNativePath() called before .setFile_()"+w.InternalErrorFlag):this.nativePath=await(0,f.getAssetFileNativePath)(this)),this.nativePath}async capturedAt(){return null==this.nativePath&&await this.getNativePath(),D.CapturedAt.fromAssetFile(this)}async originalDownloadable({brief:e=!1}={}){const t=this.basename;if(!0===e)return null==t?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:`Download ${t}`,basename:t,description:"Download original"};const i=await this.posixFile_();return this.logger().tap({msg:"originalDownloadable()",level:"info",result:null==i||await i.isEmpty()?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:e?`Download ${i.base}`:(0,T.mkDownloadableTitle)(i,"original",this.isVideo?"video":"image",{width:this.width,height:this.height}),basename:i.base,description:"Download original",details:`(${(0,j.fmtDim)(this)} ${i.ext})`},meta:{posixFile:i}})}async downloadables(e,t){try{const i=await this.posixFile_();if(null==i)return[];const r=e.ap(this.assetId),s=[];if(await(0,m.thenMap)(this.originalDownloadable(),(e=>s.push(e))),this.isVideo)return s;if(!(0,N.isTrue)(this.shown)&&this.sha!==t)return s;const n=(0,O.compact)(await Promise.all([...await r.previewInfos()].reverse().filter((e=>e.reducer===W.ReducerNames.fit)).map((e=>(0,T.previewToDownloadable)(i.base,e)))));return s.push(...(0,O.uniqBy)(n,(e=>e.size))),s}catch(e){return(0,v.onError)("AssetFile.downloadables failed for "+this.uri,e),[]}}async pathInfo(){try{const e=C.URI.parse(this.uri),t=(0,U.map)((0,I.uriToTagPath)({uri:e,isFile:!0}),(e=>X.Tag.findByPath(e)));return this._pathInfo_(await(t?.toApiPathElements()))}catch(e){return void this.logger().warn("pathInfo(): failed",e)}}async _pathInfo_(e){const t=await this.posixFile_();if(null==t)return this.logger().throw("pathInfo(): no posixFile",{uri:this.uri});const i=t.nativePath,r=C.URI.parse(this.uri),s=await t.exists();if(null==e||(0,O.isEmpty)(e))return this.logger().warn("pathInfo(): failed to find existing Tag. Returning a simple path.",{uri:this.uri,nativePath:i,tagLineage:e}),{nativePath:i,pathElements:[],nativePathSuffix:i,pathSep:a.sep,exists:s};function n(){return(0,L.at)((0,L.at)(e,-1)?.tagPath,-1)}(0,z.eql)(e[0]?.tagPath,[J.TagRoots.fs])&&(e=e.slice(1));const o=r.scheme===G.PS_LIBRARY_SCHEME,l=o?r.path.split("/").slice(1):t.pathnames,u=l.pop(),c=[];for(;l.length>0&&(0,d.equalsIgnoreCase)(n(),(0,L.at)(l,-1));){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("added matching tag",t)}if(o&&n()===J.LibraryTagName){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("pslib: added matching library tag",t)}if(r.scheme===G.PS_LOCAL_FILE_SCHEME){const t=C.URI.parse(this.uri).authority;if(this.logger().debug("psfile: pop last?",{lastTagName:n(),thisVolSha:t}),n()===t){l.pop();const t=e.pop();c.unshift(t)}else this.logger().warn("weird: I expected to be able to include the volsha tag element, but it doesn't seem to match",{thisVolSha:t,tagVolSha:n()})}return this.logger().tap({msg:"pathInfo()",result:{nativePath:i,pathElements:c,nativePathSuffix:u,pathSep:a.sep,exists:s}})}async toApi(e,t){return(0,m.thenMap)(this.pathInfo(),(async i=>(0,H.reqValuedOrElse)({assetId:this.assetId,assetFileId:this.id,...i,mimetype:this.mimetype,shown:(0,N.isTrue)(this.shown),name:this.basename,width:this.width,height:this.height,rotation:this.rotation??0,fileSize:this.fileSize,mtime:this.mtime,downloadables:await this.downloadables(e,t),createdAtLocale:ie(this.createdAt),updatedAtLocale:ie(this.updatedAt)})))}get isVideo(){return(0,x.isVideoMimeType)(this.mimetype)}}function ie(e){return(0,U.map)(e,(e=>(0,V.fmtDuration)(Date.now()-e,1)+" ago"))}t.AssetFile=te,r=new WeakSet,s=function(){if((0,R.blank)(this.uri))return"blank uri";if((0,R.blank)(this.sha))return"blank sha";if(!(0,q.gt0)(this.width))return"missing width";if(!(0,q.gt0)(this.height))return"missing height";if(!(0,q.gt0)(this.capturedAtLocal))return"missing capturedAtLocal";if(!(0,q.gte0)(this.capturedAtPrecisionMs))return"missing capturedAtPrecisionMs";if(E.Settings.useImageHashes.valueOrDefault){const e=[];for(const t of["dctHash","diffHash","meanHash"])(0,R.blank)(this[t])&&e.push(t);if(1===e.length)return"missing image hash: "+e[0];if(e.length>1)return"missing image hashes: "+e.join(", ")}return this.isVersionUpToDate()?void 0:"outdated version"},te.$tableName="AssetFile",te.$uniqueColumnName="uri",te.$booleanFields=["shown"],te.$transientFields=["nativePath","syncState"]},48722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toAssetId=void 0;const r=i(76596),s=i(31586);t.toAssetId=function(e){const t=(0,s.toGt0)(e?.assetId)??(0,s.toGt0)(e?.id);if(null==e||null==t||!(0,s.isNumber)(e?.capturedAtLocal))return;const i=((0,s.toGt0)(e.v)??(0,s.toGt0)(e.updateCount)??(0,s.toGt0)(e.updatedAt)??0)%1e6,n={assetId:t,capturedAtLocal:e.capturedAtLocal,v:i};return(0,s.gt0)(e.durationMs)&&(n.durationHMS=(0,r.durationHMS)(e.durationMs)),n}},37094:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetRevision=void 0;const r=i(98553),s=i(67478),n=i(55046);class a extends n.Model{static insert(...e){return a.ops().insert(e.map((e=>({assetId:e.assetId,createdAt:Date.now(),field:e.field,op:e.op,_priorValueJson:(0,r.stringify)(e.priorValue),_newValueJson:(0,r.stringify)(e.newValue)}))))}get priorValue(){return(0,s.parseJSON)(this._priorValueJson)}get newValue(){return(0,s.parseJSON)(this._newValueJson)}}t.AssetRevision=a,a.$tableName="AssetRevision"},45295:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetTag=void 0;const r=i(55046);class s extends r.Model{$pk(){return this.assetId+":"+this.tagId}}t.AssetTag=s,s.$tableName="AssetTag",s.$uniqueColumnName="assetId,tagId",s.$useCache=!1,s.$pkColumnNames=["assetId","tagId"]},61204:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeMonthTag=t.normalizeDateTags=t.getMonthTags=void 0;const r=i(19851),s=i(50213),n=i(97352),a=i(75020),o=i(4407),l=i(48723),u=`'${a.TagRoots.When}' || char(31) || '%' || char(31) || '%' || char(31)`,c=u+" || '%' || char(31)",d=(0,r.lazy)((()=>(0,s.mkLogger)("model.DateTagNormalizer")));function h(){return l.Tag.ops().allf((e=>e.whereNotNull("ordinal").andWhereRaw("_path LIKE "+u+" AND _path NOT LIKE "+c).limit(2400)))}function f(e){const t=(0,n.mapGt0)(e.ordinal,(e=>(0,o.monthTagRef)((0,o.ordinalToMonth)(e))));null==t?d().warn("failed to fix tag (no monthTagRef)",{t:e}):t.name!==e.name&&(d().info("Fixing month name",{tagRef:t,tag:e}),e.changeName(t.name)),e.maybeUpsertDisplayName(t?.displayName)}t.getMonthTags=h,t.normalizeDateTags=async function(){for(const e of h())f(e)},t.normalizeMonthTag=f},95700:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runMaintenanceTasks=void 0;const r=i(19851),s=i(56038),n=i(28874),a=i(42659),o=i(41400),l=i(69032),u=i(61204),c=i(49796);t.runMaintenanceTasks=async function({force:e}={}){await d(),await(!0===e?h.refresh():h());try{await(!0===e?(0,l.forceRunTagMaintenance)():(0,l.runTagMaintenance)())}catch{}};const d=(0,r.lazy)((()=>(0,s.time)("db.normalizeDateTags",u.normalizeDateTags))),h=(0,r.lazy)((()=>(0,s.time)("db.Progress.vacuum",(()=>c.Progress.vacuum()))),2*a.hourMs);(0,o.later)((()=>{n.Settings.libraryDir.watchLater((()=>{d.unset(),h.unset()}))}))},55046:(e,t,i)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const s=i(57975),n=i(50213),a=i(7282),o=i(65211),l=i(40958),u=i(38639),c=i(45599),d=i(31586),h=i(68708),f=i(34666),m=i(54993),p=i(57038),g=i(94448),y=i(33572),w=i(63872);class v{constructor(){this.$instanceId=(0,a.isTest)()?(0,o.uid)():void 0}static get $ctor(){return this.$schema+"."+this.$tableName}static query(){return(0,p.knex)()(this.$tableName)}static queryBy(e){return this.query().where(e)}static queryOneBy(e){return this.queryBy(e)}static ops(){return this._ops??(this._ops=new w.ModelOps(this,this.db))}static get dbl(){return this.ops().dbl}static rows(){return this.ops().rows()}static truncate(){if((0,a.isProd)())throw new Error("rejecting attempt to truncate in prod");this.dbl.run("DELETE FROM "+this.$tableName)}static ucn(e){const t=this.$uniqueColumnName.split(",").map((t=>e[t]));return t.some((e=>null==e))?void 0:1===t.length?t[0]:t.join(",")}static hasId(e){return this.$pkColumnNames.every((t=>null!=e[t]))}static pickId(e){return(0,h.pick)(e,...this.$pkColumnNames)}$ops(){return this.class().ops()}class(){return this.constructor}$pk(){return(0,m.toS)(this.id)}$ucn(){return this.class().ucn(this)}$tableName(){return this.class().$tableName}$uid(){return`${this.$tableName()}(${this.id??this.$ucn()})${!0===this.shown?"!":""}`}logger(){return(0,n.mkLogger)(this.class().$schema+"."+(0,m.toS)(this.valueOf()))}[s.inspect.custom](){return{...this.$toShallowJSON(),$instanceId:this.$instanceId}}toString(){return this.$uid()}valueOf(){return this.$uid()}static fromJSON(e){return(0,y.fromJSON)(this,e)}static toJSON(e){return this.fromJSON(e).toJSON()}$toShallowJSON(){return this.$_toJSON({encodeBool:u.isTrue})}$toDbJSON(e){return this.$_toJSON({encodeBool:u.boolToInt,includeCtor:!1,includeTransient:!1,colNames:e})}$clone(){return(0,y.fromJSON)(this.class(),this.toJSON())}toJSON(){return this.$_toJSON({encodeBool:u.isTrue})}_get(e,t,i=!0){const r=this[e];return null===r?[e,null]:!(0,f.isPrimitive)(r)||!i&&(0,l.includes)(this.class().$transientFields,e)?void 0:(0,l.includes)(this.class().$booleanFields,e)?[e,t(r)]:[e,r]}$_toJSON({encodeBool:e,includeCtor:t=!0,includeTransient:i=!0,colNames:r}){const s=this.class(),n=(0,l.notEmptyOr)(r,s.ops().columnNames());return(0,h.fromEntries)(n.map((t=>this._get(t,e,i))),t?{$ctor:s.$ctor}:{})}insert(){return this.logger().debug("insert()",{self:this.toJSON()}),this.class().ops().insertOne(this)}update(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("update()",{self:this.toJSON()}),this.class().ops().updateOne(this)}upsert(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("upsert()",{self:this.toJSON(),arg:e}),this.class().ops().upsertOne(this)}$afterInsert(){}$beforeUpsert(){}$afterUpsert(){}reload(){return this.class().ops().reloadOne(this)}delete(){(0,d.gt0)(this.id)&&this.class().ops().delete([this.id])}}t.Model=v,r=v,v.$schema="models",v.$logger=(0,c.defer)((()=>(0,n.mkLogger)(r.$schema+"."+r.$tableName))),v.db=g.modelDb,v.$pkColumnNames=["id"]},94448:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryModelDbFile=t.modelDb=void 0;const r=i(15056),s=i(87290),n=i(19851),a=i(55835);t.modelDb=(0,n.lazy)((()=>{})),t.libraryModelDbFile=function(e){return(0,a.map)((0,s.libraryDataDirPosixFile)(e),(e=>(0,r.pathToDb)(e,"models")))}},33572:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toJSON=t.assignFromJSON=t.fromJSON=t.addModelClass=void 0;const r=i(50213),s=i(40958),n=i(22573),a=i(38639),o=i(97790),l=i(51926),u=new Map;function c(e){u.set(e.$ctor,e)}function d(e,t,i=[]){const r=e.class();for(const[n,o]of Object.entries(t)){if("$ctor"===n)continue;if(void 0===o)continue;const t=(0,l.stripPrefixes)(n,i);e[t]=null==o?o:(0,s.includes)(r.$booleanFields,t)?(0,a.isTrue)(o):o}return e}t.addModelClass=c,t.fromJSON=function(e,t){if(null==t)throw new Error("json is null");if(null!=e&&(0,n.notBlank)(e.$ctor)&&!u.has(e.$ctor)&&c(e),t instanceof e)return t;const i=(0,o.opt)(t.$ctor).flatMap((e=>u.get(e))).getOrElse((()=>e));if(t instanceof i)return t;const r=new i;return null==t?r:d(r,t,(0,s.uniq)([e.$tableName+".",i.$tableName+"."]))},t.assignFromJSON=d,t.toJSON=function e(t,i,s){if(null!=t)return Array.isArray(t)?t.map(((t,r)=>e(t,i,`${s}[${r}]`))):"function"==typeof t.toJSON?t.toJSON():void(0,r.mkLogger)("ModelJSON.toJSON()").warn("Failed",{m:t,key:s,mc:i.$ctor})}},63872:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ModelOps=void 0;const f=i(48884),m=i(19851),p=i(50213),g=i(81168),y=i(48299),w=i(12943),v=i(38835),b=i(34102),S=i(28874),P=i(40958),_=i(76790),T=i(22573),M=i(50357),E=i(96249),D=i(98553),x=i(55835),k=i(31586),C=i(68708),F=i(59455),A=i(86859),I=i(33572);t.ModelOps=class{constructor(e,t){r.add(this),this.model=e,this.db=t,s.set(this,void 0),n.set(this,!0),a.set(this,new y.WeakCache),o.set(this,new Set),this.columnNames=(0,m.lazy)((()=>this.db().tableInfo_().find((e=>(0,g.equalsIgnoreCase)(e.tableName,this.tableName))).columns.map((e=>e.name)))),this.updatableColumnNames=(0,m.lazy)((()=>(0,P.diff)(this.columnNames(),this.immutableColumnNames))),this.ucnFieldNames=(0,m.lazy)((()=>this.ucn.split(","))),d(this,s,(0,p.mkLogger)(`ModelOps(${e.$tableName})`),"f"),(0,I.addModelClass)(e),d(this,n,e.$useCache??!0,"f"),this.dbl=new A.DbRequest(this.db,e.$tableName),(0,b.ee)().on("clearCache",(()=>h(this,a,"f").clear())),(0,b.ee)().on("clearDbCache",(()=>h(this,a,"f").clear()))}clearDbCache(){h(this,a,"f").clear()}get $cache(){return h(this,a,"f")}$cachedByJson(e){if(null==e||!h(this,n,"f"))return;const t=this.$pickModelUcn(e);return(null==t?void 0:h(this,a,"f").get((0,D.stringify)(t)))??this.$cachedById(e.id)}$cachedById(e){return(0,k.gt0)(e)&&h(this,n,"f")?h(this,a,"f").get((0,D.stringify)(e))??h(this,a,"f").findEntry((t=>t.id===e)):void 0}get dbOpen(){return(0,x.mapOr)(this.db(),(e=>e.isOpen),(()=>!1))}get tableName(){return this.model.$tableName}query(){return this.model.query()}toDbValued(e){const t=this.model.fromJSON(e),i=(0,w.toDbValued)(t);return(0,C.pick)(i,...this.columnNames())}run(e){return this.dbl.run(e)}fromJSON(e){if((0,C.isEmptyObj)(e))return;const t=this.model.fromJSON(e);return h(this,r,"m",u).call(this,t)}fromJSONs(e){return(0,P.compact)(e.map((e=>this.fromJSON(e))))}first(e){return this.fromJSON(this.dbl.first(e))}firstf(e){return this.first(e(this.query()))}all(e=this.query()){return this.fromJSONs(this.dbl.all(e))}allf(e){return this.all(e(this.query()))}findOne(e){return this.fromJSON(this.dbl.first(e))}findOneBy(e){return this.findOne(this.model.query().where(e))}findById(e,t){return this.findOneBy({...t,id:e})}findByIds(e){e=(0,F.toA)(e).filter(k.gt0);const t=[],i=[];for(const r of e){const e=this.$cachedById(r);null!=e?t.push(e):i.push(r)}const r=(0,f.batches)(i,S.Settings.dbBatchSelectSize.valueOrDefault).map((e=>this.dbl.all(this.query().whereIn("id",e))));return(0,_.sortBy)([...t,...this.fromJSONs((0,E.flatten)(r))],(t=>e.indexOf(t.id)))}findBy(e){return this.all(this.model.queryBy(e))}findWhereIn(e,t){return this.all(this.model.query().whereIn(e,t))}rows(e){return this.count(e??this.model.query().count())}count(e){return(0,k.toGt0)(this.dbl.pluckFirst(e))??0}countf(e){return this.count(e(this.query()))}insert(e){return(0,F.toA)(e).map((e=>this.insertOne(e)))}upsertOne(e){return this.modelSupportsUpsert?this.upsert([e])[0]:this.insertOrUpdateOne(e)}insertOrUpdateOne(e){return null==e.id?this.insertOne(e):this.updateOne(e)}insertOne(e){if(this.model.hasId(e))throw new Error("insert called for "+(0,D.stringify)(e)+v.NonRetriableErrorFlag);const t=this.fromJSON(e);if(null==t)return h(this,s,"f").throw("insertOne(): fromJSON returned null"+v.InternalErrorFlag,{t:e});t instanceof this.model&&h(this,r,"m",u).call(this,t),t.$beforeUpsert();const i=t.$toDbJSON(this.columnNames()),n=this.dbl.runf((e=>e.insert(i)));return t.id=(0,k.toInt)(n.lastInsertRowid),t.$afterInsert(),t.$afterUpsert(),t}unsetField(e,t){return(0,x.map)(this.$cachedById(e),(e=>{e[t]=null})),this.dbl.runf((i=>i.where({id:e}).update(t,null)))}updateOne(e){if(null==e.id)throw new Error("update called for "+(0,D.stringify)(e)+v.NonRetriableErrorFlag+v.InternalErrorFlag);const t=this.model.fromJSON(e);t.$beforeUpsert();const i=t.$toDbJSON(this.updatableColumnNames());return this.dbl.runf((t=>t.where({id:e.id}).update(i))),t.$afterUpsert(),h(this,r,"m",u).call(this,t)??t}get ucn(){return(0,T.toNotBlank)(this.model.$uniqueColumnName)??"id"}get modelSupportsUpsert(){return null!=this.ucn&&"id"!==this.ucn}get ucnConstraint(){return`(${this.ucn})`}get immutableColumnNames(){return(0,P.uniq)([...this.ucnFieldNames(),"id","createdAt"])}onConflictClause(e){const t=this.immutableColumnNames,i=e.filter((e=>!t.includes(e))).sort().map((e=>`${e}=excluded.${e}`)).join(","),r=["ON CONFLICT",this.ucnConstraint];return(0,T.blank)(i)?r.push("DO NOTHING"):r.push("DO UPDATE SET",i),r.join(" ")}$pickModelUcn(e){const t={};for(const i of this.ucnFieldNames()){const r=e[i];if(null==r)return;t[i]=r}return t}reloadOne(e){if(h(this,o,"f").has(e.id))return;const t=this.$pickModelUcn(e);if(null!=t){const i=h(this,r,"m",u).call(this,e),s=this.findOneBy(t);if(null==s)return;return h(this,r,"m",l).call(this,i,s),i!==e&&h(this,r,"m",l).call(this,e,i),i}h(this,s,"f").warn(".reloadOne(): failed to reload "+(0,D.stringify)(e))}reload(e){const t=[],i=this.allf((i=>{for(const r of e){const e=this.model.hasId(r)?this.model.pickId(r):this.$pickModelUcn(r);null!=e?(t.push([r,e]),i=i.orWhere(e)):h(this,s,"f").warn("reload(): given insufficient partial model",{fragment:r})}return i})),n=[];for(const[e,a]of t){const t=i.find((e=>(0,M.eqlSubset)(a,e)));if(null==t)h(this,s,"f").warn("reload(): failed to find result in db",{prior:e,dbArr:i});else{const i=h(this,r,"m",u).call(this,e);h(this,r,"m",l).call(this,i,t),i!==e&&h(this,r,"m",l).call(this,i,t),n.push(t)}}return n}upsert(e){if(e=(0,P.compact)(e),!this.modelSupportsUpsert)return e.map((e=>this.insertOrUpdateOne(e)));const t=this.columnNames(),i=[];for(const s of(0,f.batches)((0,F.toA)(e),S.Settings.dbBatchUpsertSize.valueOrDefault)){const e=new Map,n=new Set,a=(0,P.compact)(s.map((e=>this.fromJSON(e))));for(const t of a){const i=(0,D.stringify)(this.$pickModelUcn(t));e.set(i,t),this.model.hasId(t)||n.add(i),t.$beforeUpsert()}h(this,r,"m",c).call(this,a.map((e=>e.$toDbJSON(t))));const o=this.reload(a),l=new Map(o.map((e=>[(0,D.stringify)(this.$pickModelUcn(e)),e])));for(const e of a){const t=(0,D.stringify)(this.$pickModelUcn(e)),r=l.get(t)??e;n.has(t)&&r.$afterInsert(),r.$afterUpsert(),i.push(r)}}return i}delete(e){const t=(0,F.toA)(e).filter(k.gt0);for(const e of t)h(this,o,"f").add(e);return h(this,a,"f").deleteValueIf((e=>t.includes(e.id))),this.run(this.model.query().delete().whereIn("id",t))}async batched(e){const t=e.batchSize??S.Settings.dbBatchSelectSize.valueOrDefault;let i,r;do{i=this.allf((i=>(i=e.qb(i),null!=r&&(i=i.andWhere("id",">",r)),i.orderBy("id","asc").limit(t)))),(0,P.isNotEmpty)(i)&&(r=Math.max(...i.map((e=>e.id))),await e.onResults(i))}while((0,P.isNotEmpty)(i))}},s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function(e,t){(0,C.assignFields)(e,t,{omitKeys:["$instanceId"],assignNullish:!0})},u=function(e){if(h(this,n,"f")){const t=this.$cachedByJson(e);if(null!=t)return h(this,r,"m",l).call(this,t,e),t;{const t=this.$pickModelUcn(e)??e.id;null!=t&&h(this,a,"f").set((0,D.stringify)(t),e)}}return e},c=function(e){const t=this.query().insert(e).toSQL(),i=new Set;for(const t of e)for(const e of(0,C.keys)(t))i.add(e);const s={sql:t.sql+" "+this.onConflictClause([...i.values()]),bindings:t.bindings};this.run(s);for(const t of e){const e=this.$cachedByJson(t);null!=e&&h(this,r,"m",l).call(this,e,this.model.fromJSON(t))}}},49796:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Progress=t.defaultMinCreatedAt=t.toPct=void 0;const r=i(48161),s=i(1708),n=i(48884),a=i(50213),o=i(28874),l=i(40958),u=i(42659),c=i(45599),d=i(98553),h=i(55835),f=i(31586),m=i(68708),p=i(67478),g=i(51926),y=i(59455),w=i(54993),v=i(76386),b=i(33572),S=i(55009),P=i(72761),_=(0,c.defer)((()=>(0,a.mkLogger)("model.Progress")));function T(e){return null==e||!(0,f.isNumber)(e)||e<0||e>100?void 0:(0,f.sigFigs)(e,3)}t.toPct=T;const M=(0,g.compressWhitespace)("\nSELECT\n p1.uri,\n p1.id as lastProgressId,\n p1.createdAt as lastStartedAt,\n p1.updatedAt as lastUpdatedAt,\n p3.lastCompletedAt\nFROM\n Progress AS p1\n JOIN (\n SELECT\n uri,\n max(updatedAt) AS lastUpdatedAt\n FROM\n Progress\n GROUP BY\n 1\n ) AS p2 ON p1.uri = p2.uri\n AND p1.updatedAt = p2.lastUpdatedAt\n LEFT JOIN (\n SELECT\n uri,\n max(completedAt) AS lastCompletedAt\n FROM\n Progress\n WHERE\n CAST(completedAt AS int) > 0\n GROUP BY\n 1\n ) AS p3 ON p1.uri = p3.uri\nGROUP BY\n p1.uri");function E(){const e=o.Settings.progressStaleDays.valueOrDefault;return e<=0?0:Date.now()-e*u.dayMs}t.defaultMinCreatedAt=E;class D extends P.TimestampedModel{static vacuum(e=o.Settings.progressRetentionDays.valueOrDefault*u.dayMs){const t=Date.now()-e,i=this.dbl.pluckAllf((e=>e.select("id").where("createdAt","<=",t)));for(const e of(0,n.batches)(i,o.Settings.dbBatchSelectSize.valueOrDefault))S.ProgressMeta.dbl.runf((t=>t.whereIn("progressId",e).delete())),D.dbl.runf((t=>t.whereIn("id",e).delete()))}static countCompletedDirectorySyncs(){return this.dbl.pluckFirstf((e=>e.where({state:"done"}).whereNotNull("completedAt").where("uri","like","ps%")))}static times(){return _().tap({msg:"times()",result:this.dbl.all({sql:M})})}static insertNew(e){const t=(0,h.map)(e.dek,d.stringify);return this.ops().insertOne({...(0,m.omit)(e,"dek"),dekJSON:t})}upsert(e){return null!=e&&this.assignFromPojo(e),super.upsert()}$beforeUpsert(){super.$beforeUpsert(),null==this.id&&(this.pid??(this.pid=s.pid),this.hostname??(this.hostname=(0,r.hostname)())),"done"===this.state&&(this.completedAt??(this.completedAt=Date.now())),this.completePct=T(this.completePct),this.incompletePct=T(this.incompletePct),this.scanningPct=T(this.scanningPct)}$afterUpsert(){super.$afterUpsert(),(0,v.tellWebProgressUpdated)()}toSyncState(){return{id:this.id,uri:this.uri,volume:this.volume,state:this.state,hed:this.hed,dek:this.dek,completePct:this.completePct,incompletePct:this.incompletePct,scanningPct:this.scanningPct}}get dek(){return(0,l.compactBlanks)((0,p.parseJSON)(this.dekJSON))}set dek(e){var t;this.dekJSON=(t=e,(0,d.stringify)((0,l.compactBlanks)((0,y.toA)(t))))}assignFromPojo(e){return(0,b.assignFromJSON)(this,(0,m.omit)(e,"volume","uri"))}getMeta(){return S.ProgressMeta.ops().allf((e=>e.where({progressId:this.id}).orderBy("createdAt")))}getPriorIncomplete(e=E()){return this.logger().tap({msg:"priorIncompleteProgress()",result:D.ops().firstf((t=>t.where({hostname:this.hostname,uri:this.uri,completedAt:null}).andWhere("createdAt",">",e).orderBy("updatedAt","desc")))})}getLastCompletedAt(e=E()){return D.dbl.pluckFirstf((t=>t.max("completedAt").where({uri:this.uri}).andWhere("createdAt",">",e)))}getLastIncompleteStartAt(){return D.dbl.pluckFirstf((e=>e.min("createdAt").where({uri:this.uri}).andWhere("createdAt",">",this.getLastCompletedAt()??0)))}setMeta(e,t){return this.logger().debug("setMeta()",{progressId:this.id,name:e,value:t}),S.ProgressMeta.ops().upsertOne({progressId:this.id,name:e,value:t})}setMetaRecord(e){const t=this.getMeta(),i=(0,l.diff)(t.map((e=>e.name)),Object.keys(e));this.logger().debug("setMetaRecord()",{progressId:this.id,keysToDelete:i,record:e}),S.ProgressMeta.ops().upsert((0,m.entries)(e).map((([e,t])=>({progressId:this.id,name:e,value:(0,w.toS)(t)})))),(0,l.isNotEmpty)(i)&&S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).whereIn("name",i).delete()))}deleteMeta(...e){return this.logger().debug("deleteMeta()",{progressId:this.id,names:e}),S.ProgressMeta.dbl.runf((t=>t.whereIn("name",e).andWhere({progressId:this.id}).delete()))}deleteAllMeta(){return this.logger().debug("deleteAllMeta()",{progressId:this.id}),S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).delete()))}getMetaAsRecord(){return this.logger().tap({msg:"getMetaAsRecord()",result:(0,m.fromEntries)(this.getMeta().map((e=>[e.name,e.value])))??{}})}}t.Progress=D,D.$tableName="Progress",D.$uniqueColumnName="id"},55009:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressMeta=t.ProgressMetaNames=t.DirSyncProgressMetaNames=void 0;const r=i(50989),s=i(72761);t.DirSyncProgressMetaNames=(0,r.strEnum)("lastScannedDirectory","scannedDirectoryCount","completedDirectoryScan","enqueuedStaleFiles","processedImageCount","processedVideoCount","completedDirectorySync"),t.ProgressMetaNames=(0,r.strEnum)(...t.DirSyncProgressMetaNames.values);class n extends s.TimestampedModel{}t.ProgressMeta=n,n.$tableName="ProgressMeta",n.$uniqueColumnName="progressId,name"},39604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.upsertToShaBlockslist=t.upsertFileToShaBlockslist=t.isShaBlockslisted=t.notBlocklistedSha=void 0;const r=i(19851),s=i(50213),n=i(95696),a=i(40958),o=i(22573),l=i(86859),u=i(94448),c=(0,r.lazy)((()=>(0,s.mkLogger)("model.ShaBlocklist"))),d=(0,r.lazy)((()=>new l.DbRequest(u.modelDb,"ShaBlocklist")));function h(e){return null!=(0,u.modelDb)()&&!(0,o.blank)(e)&&c().tap({msg:"isShaBlockslisted",result:null!=d().pluckFirstf((t=>t.where({sha:e}).limit(1))),meta:{sha:e}})}function f(...e){if(null==u.modelDb.prior())return;const t=(0,a.uniq)(e).map((e=>({sha:e})));return(0,a.isEmpty)(t)?void 0:d().upsert((e=>e.insert(t)))}t.notBlocklistedSha=async function(e){if(null==(0,u.modelDb)())return null;const t=h(await n.PosixFile.for(e).sha());return null==t?null:!t},t.isShaBlockslisted=h,t.upsertFileToShaBlockslist=async function(e){if(null==(0,u.modelDb)())return;const t=await n.PosixFile.for(e).sha();return null==t?void 0:f(t)},t.upsertToShaBlockslist=f},48723:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Tag=t.UpdateTagAssetCountTimeName=void 0;const a=i(56038),o=i(34102),l=i(19851),u=i(50213),c=i(36372),d=i(97352),h=i(28874),f=i(81168),m=i(42231),p=i(75020),g=i(40958),y=i(22573),w=i(42659),v=i(41400),b=i(50357),S=i(55835),P=i(31586),_=i(34666),T=i(20214),M=i(51926),E=i(59455),D=i(12168),x=i(6186),k=i(57038),C=i(21074),F=i(7656),A=i(43487),I=i(48722),O=i(45295),L=i(98784),R=i(41507),N=i(72761),B=4*w.secondMs,j=(0,l.lazy)((()=>(0,u.mkLogger)("model.Tag")));(0,v.later)((()=>{(0,o.ee)().on("clearCache",(()=>z.clear())),(0,o.ee)().on("clearDbCache",(()=>z.clear()))})),t.UpdateTagAssetCountTimeName="db.updateTagAssetCountTimeName";class z extends N.TimestampedModel{constructor(){super(...arguments),this.displayPath=(0,l.lazy)((()=>{const e=this.getParent();return(0,g.compactBlanks)([...null==e?[]:e.displayPath(),this.displayName])})),this.ancestorIds=(0,l.lazy)((()=>0===this.parentId||null==this.parentId?[]:r.dbl.pluckAll({sql:(0,M.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.id","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}}))),this.firstNonInterstitialTagId=(0,l.lazy)((()=>{if(!this.isRoot&&0===this.directAssetCount()&&1===this.getChildrenCount()){const e=this.getChildren();if(1===e?.length)return e[0].firstNonInterstitialTagId()}return this.id})),this.directAssetCount=(0,l.lazy)((()=>0===this.id?0:A.Asset.dbl.pluckFirst(A.Asset.shownUnhidden().join("AssetTag","AssetTag.assetId","Asset.id").where("AssetTag.tagId",this.id).countDistinct("Asset.id"))))}static orderBy(e){return e.orderByRaw("COALESCE(ordinal, _path) COLLATE NOCASE")}static clear(){this.root.unset(),this.roots.unset(),this._upsertDefaultRoots.unset(),this.ops().clearDbCache()}static validate_(){return(0,a.timeSync)("Tag.validate_",(()=>{r.clear();for(const e of this.ops().allf((e=>e.whereRaw("id = parentId")))){j().warn(`Tag ${e.id} has itself as parentId. Attempting to fix...`);const t=e.path.slice(0,-1),i=(0,g.isEmpty)(t)?void 0:this.findOrCreate(t);e.update({parentId:i?.id??null})}for(const e of r.roots())e.validate_([])}))}validate_(e){const t=this.path;if(!(0,b.eql)(t.slice(0,-1),e))throw new Error(`Tag:${this.id} path ${t.join("/")} does not match expected parent ${e.join("/")}`);for(const e of this.getChildren())e.validate_(t)}static deltaAssetCountAndAncestors(e,t=1){return r.incrAssetCount(r.selfAndAncestorIds(e),t)}static incrAssetCount(e,t=1){(0,g.isEmpty)(e)||r.dbl.runf((i=>i.whereIn("id",e).andWhereNot({assetCount:null}).update({assetCount:(0,k.knex)().raw("assetCount + "+Math.round(t)),updatedAt:Date.now()})))}static selfAndAncestorIds(e){const t=(0,E.toA)(e).filter(P.gt0);return r.dbl.pluckAll({sql:(0,M.compressWhitespace)("WITH RECURSIVE ancestors(id) AS ("," SELECT id FROM Tag where id in "+(0,C.sqlWhereInClause)(t.length)," UNION ALL"," SELECT Tag.parentId as id"," FROM Tag, ancestors"," WHERE Tag.id = ancestors.id",")","SELECT distinct(id)","FROM ancestors","WHERE id IS NOT NULL"),bindings:t})}static updateAssetCount(e){if((0,P.gt0)(e))return(0,a.timeSync)(t.UpdateTagAssetCountTimeName,(()=>{const t=r.dbl.pluckFirst({sql:F.RecursiveAssetCountForTagQuery,bindings:{tagId:e}});r.dbl.runf((i=>i.update({assetCount:t,updatedAt:Date.now()}).where({id:e}))),j().debug("Updated asset counts for tag ",{tagId:e,assetCount:t})}))}static findByIdOrPath(e,t){return 0===e?r.root():(0,P.gt0)(e)?this.findById(e):this.findByPath(t)}static findById(e){return 0===e?r.root():this.ops().findById(e)}static findByPath(e){if((0,g.isEmpty)(e))return r.root();const t=(0,m.joinTagPath)(e);return this.ops().firstf((e=>e.whereLike("_path",t)))}static findByPathN(e){const t=(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,y.toNotBlank)((0,m.joinTagPath)(e))));return(0,g.compact)(t.map((e=>this.findByPath(e))))}static getPagedAssets(e,t){const i=new r;return i.id=e,i.getPagedAssetIds(t)}static findOrCreate(e){if((0,g.isEmpty)(e))throw new Error("empty tagPath");const t=this.findByPath(e);if(null!=t)return t;const i=n(this,r,"m",s).call(this,e),a=i.depth<=1?void 0:this.findOrCreate(e.slice(0,-1));return(0,S.map)(a,(e=>i.parentId=e.id)),this.ops().upsertOne(i)}static findOrCreateByPathN(e){return(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,m.joinTagPath)(e))).map((e=>this.findOrCreate(e)))}clear(){return this.parent=void 0,this.root=void 0,this.children=void 0,this.ancestors=void 0,this.assets=void 0,this.relatedAssets=void 0,this.ancestorIds.unset(),this}$afterInsert(){L.TagFts.insertFts([this])}siblingPath(e){return(0,m.joinTagPath)([...this.parentPath,e])}changeName(e){return this.changePath(this.siblingPath(e))}maybeUpsertDisplayName(e){return(0,y.blank)(e)||e===this._displayName?void 0:this.upsert({_displayName:e})}changePath(e,t=!0){const i=this._path,s=r.findByPath((0,m.splitTagPath)(e));this.logger().info("changePath(): ",{priorPath:i,newPath:e,existingSibling:s});try{if(null==s)r.dbl.runf((t=>t.whereLike("_path",i+"%").update({updatedAt:Date.now(),_path:(0,k.knex)().raw("REPLACE(_path, ?, ?)",[i,e])}))),this._path=e;else{e=s._path,this.logger().info("changePath(): replacing with sibling",e),O.AssetTag.dbl.upsert((e=>e.where({tagId:this.id}).update({tagId:s.id}))),O.AssetTag.dbl.runf((e=>e.where({tagId:this.id}).delete()));for(const e of this.getChildren())e.changePath((0,m.joinTagPath)([...s.path,e.name]),!1);r.dbl.runf((e=>e.where({parentId:this.id}).update({parentId:s.id}))),this.delete()}}finally{t&&r.clear()}}get name(){const e=this.path;return e[e.length-1]}get path(){return(0,m.splitTagPath)(this._path)}get displayName(){return(0,y.toNotBlank)(this._displayName)??this.name}get isRoot(){return 0===this.id}get depth(){return this.path.length}get parentPath(){return this.path.slice(0,-1)}get sortBy(){return[this.depth,null==this.ordinal?2**51:this.ordinal,this.path.map((e=>e.toLowerCase()))]}$childrenQuery(){return r.orderBy(r.query().where({parentId:this.id}))}$assetsQuery(){return A.Asset.shownUnhidden().columns("Asset.*").join("AssetTag","AssetTag.assetId","Asset.id").where({tagId:this.id})}$selectAssetIdColumns(e){return e.clearSelect().select({assetId:"Asset.id",capturedAtLocal:"Asset.capturedAtLocal",updateCount:"Asset.updateCount",durationMs:"Asset.durationMs"})}$assetIdsQuery(){return this.$selectAssetIdColumns(this.$assetsQuery())}setAncestors(e){this.ancestors=e,this.parent=e[e.length-1],(0,S.map)(this.parent,(t=>t.setAncestors(e.slice(0,-1))))}async toApiPathElements(){return(0,T.thenCollect)(this.getAncestorsAndSelf(),(e=>e.toPathTag()))}toPathTag(){return{tagPath:this.path,displayName:this.displayName}}toApiTag(){return{tagId:this.id,tagPath:this.path,displayPath:this.displayPath(),description:this.description,assetCount:this.assetCount}}toStringId(){return"Tag("+this.path.join("/")+")"}getParent(){if(!this.isRoot)return null!=this.parentId&&null==this.parent?this.parent=r.findById(this.parentId):this.parent}getPagedChildren(e){if(0===this.id){const t=e.offset??0,i=t+(e.limit??this.children.length);return[...this.children].slice(t,i)}const t=this.$childrenQuery();return(0,d.mapGt0)(e.offset,(e=>{t.offset(e)})),(0,d.mapGt0)(e.limit,(e=>{t.limit(e)})),r.ops().all(t)}getChildrenCount(){return null!=this.children?this.children.length:r.dbl.pluckFirstf((e=>(this.isRoot?e.whereNull("parentId"):e.where({parentId:this.id})).count()))}getChildren(){return this.isRoot||(this.children=r.ops().all(this.$childrenQuery()),this.children.forEach((e=>{e.parent=this}))),this.children}link(){return"/tag/"+this.path.map(encodeURIComponent).join("/")}get rootName(){return this.path[0]}get ancestorsAndSelf(){return[...this.ancestors,this]}getAncestors(){return this.ancestors??(this.ancestors=this._getAncestors())}getAncestorsAndSelf(){return[...this.getAncestors(),this]}_getAncestors(){return 0===this.parentId||null==this.parentId?[]:r.ops().all({sql:(0,M.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.*","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}})}getPagedAssetIds(e){let t=this.$assetIdsQuery();return t=t.limit(p.ThumbsPerSample),(0,P.gt0)(e.offset)&&(t=t.offset(e.offset)),t=t.orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId"}]),(0,g.compact)(A.Asset.dbl.all(t).map(I.toAssetId))}getAssets(){const e=this.$assetsQuery().orderBy("capturedAtLocal","desc");return A.Asset.ops().all(e)}async assetCountDesc(e){const t=this.assetCount;return(null==t||null==e||e.length===t||0===e.length?"":(0,D.fmt)(e.length)+" of ")+(0,D.plur)(t,"asset")}getAssetCount(){return 0===this.id?r.dbl.pluckFirst({sql:(0,M.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," Asset","WHERE"," Asset.shown = 1"," AND Asset.excluded = 0"," AND Asset.hidden = 0"," AND Asset.deletedAt IS NULL")}):r.dbl.pluckFirst({sql:F.RecursiveAssetCountForTagQuery,bindings:{tagId:this.id}})}$assetStreamQuery(e,t,i){let r=this.path[0]===p.TagRoots.When?A.Asset.shownUnhidden():this.$assetsQuery();return r=r.distinct().where("capturedAtLocal",i,e.capturedAtLocal).andWhereNot("Asset.id",e.id).limit("="===i?2*t:t),"="===i?r.orderByRaw(`ABS(Asset.id-${e.id})`):r.orderBy([{column:"capturedAtLocal",order:">"===i?"asc":"desc"},"Asset.id"])}getAssetStream(e,t){t=(0,P.gt0)(t)?t:p.BeforeAfterStreamLimit;const[i,r,s]=["<","=",">"].map((i=>(0,g.compact)(A.Asset.ops().all(this.$assetStreamQuery(e,t,i)).map(I.toAssetId))));for(const t of r)t.assetIdA.Asset.shownUnhidden(this.$selectAssetIdColumns(r)).distinct().join("Asset","Asset.id","AssetTag.assetId").join("Tag","Tag.id","AssetTag.tagId").whereLike("_path",this._path+"%").orderByRaw((0,c.prngOrderByClause)(e+(this.id??0),"Asset.id",i)).limit(t))).map(I.toAssetId));return this.logger().debug(this.path+": Found "+r.length+" related assets"),r}get attrs(){return{href:this.link(),title:this.name}}}t.Tag=z,r=z,s=function(e){const t=new r;t._path=(0,m.joinTagPath)(e);const i=e[e.length-1];return"object"==typeof i&&((0,y.mapNotBlank)(i.displayName,(e=>t._displayName=e)),(0,P.mapNumeric)(i.ordinal,(e=>t.ordinal=e)),(0,y.mapNotBlank)(i.description,(e=>t.description=e)),(0,P.mapNumeric)(i.releasedAt,(e=>t.releasedAt=e))),t},z.$tableName="Tag",z.$uniqueColumnName="_path",z.$useCache=!0,z.cmp=(e,t)=>(0,_.cmp)([e.ordinal??Number.MAX_SAFE_INTEGER,...e.path],[t.ordinal??Number.MAX_SAFE_INTEGER,...t.path]),z.root=(0,l.lazy)((()=>{const e=new r;return e.id=0,e._path=m.TagSep,e.parentId=void 0,e.children=r.roots().filter((e=>!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.name)&&!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.description??""))),e.ancestors=[],e.assetCount=A.Asset.shownCount(),e.upsert=()=>{throw new Error("upsert not supported on root")},e}),B),z._upsertDefaultRoots=(0,l.lazy)((()=>r.ops().upsert(x.Roots.map((e=>({_path:(0,m.joinTagPath)([e.name]),ordinal:e.ordinal})))))),z.roots=(0,l.lazy)((()=>{r._upsertDefaultRoots();const e=r.ops().all(r.orderBy(r.query().whereNull("parentId")));for(const t of e)t.parentId=void 0,t.ancestors=[];return e}),B);const V=(0,l.lazy)((()=>A.Asset.dbl.pluckFirstf((e=>e.count()))),w.minuteMs)},98784:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagFts=void 0;const r=i(38156),s=i(3127),n=i(40958),a=i(41400),o=i(94715),l=i(55046),u=i(48723);class c extends l.Model{static insertFts(e){try{const t=e.filter((e=>null!=e.parentId)).map((e=>({rowid:e.id,root:(0,s.tag_fts_root)(e._path),path:(0,s.tag_fts_path)(e._path)})));(0,n.isEmpty)(t)||this.dbl.runf((e=>e.insert(t)))}catch(e){this.$logger().warn("Failed to update tag_fts",{error:e})}}static async rebuild(){const e=new r.PushProgressObserver({op:"Rebuilding tag search index"},u.Tag.dbl.pluckFirstf((e=>e.count("*")))),t=this.dbl.db();o.Migrations.create_tag_fts(t.db),await u.Tag.ops().batched({qb:e=>e,onResults:t=>(this.$logger().throwIfAborted_(),this.insertFts(t),e.incrProgress(t.length),(0,a.delay)(1))}),e.completed()}}t.TagFts=c,c.$tableName="tag_fts",c.$uniqueColumnName="rowid",c.$booleanFields=[]},41507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.coalesceStreams=t.TaggedAssetStream=t.cmpAssetDesc=t.cmpAssetAsc=void 0;const r=i(48884),s=i(50213),n=i(28874),a=i(40958),o=i(76790),l=i(31586),u=i(34666),c=i(20214),d=i(59455);t.cmpAssetAsc=(e,t)=>(0,u.cmp)([e.capturedAtLocal,e.id],[t.capturedAtLocal,t.id]),t.cmpAssetDesc=(e,t)=>(0,u.cmp)([t.capturedAtLocal,t.id],[e.capturedAtLocal,e.id]),t.TaggedAssetStream=class{constructor(e,t,i,r){this.tags=e,this.before=t,this.after=i,this.limit=r,this.logger=()=>(0,s.mkLogger)("model.TaggedAssetStream("+this.toString()+")"),this.logger().info("new",this.toJSON())}vacuum(){(0,o.sortByInPlace)(this.before,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainFirstN)(this.before,this.limit),(0,o.sortByInPlace)(this.after,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainLastN)(this.after,this.limit)}toString(){return this.tags.map((e=>e.path.join("/"))).join(",")}valueOf(){return this.toString()}get length(){return(0,d.toA)(this.before).length+(0,d.toA)(this.after).length}leftPad(e){return[...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+1),capturedAtLocal:-1,v:0}))),...e]}rightPad(e){return[...e,...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+this.limit+1),capturedAtLocal:-1,v:0})))]}toJSON(){return{tags:this.tags.map((e=>e.toString())),assetIdsAfter:this.after,assetIdsBefore:this.before}}mergeWith(e){(0,a.pushUniqBy)(this.tags,e.tags,(e=>e.path)),(0,a.pushUniqBy)(this.before,e.before,(e=>e.assetId)),(0,a.pushUniqBy)(this.after,e.after,(e=>e.assetId)),this.logger().debug("mergeWith() complete",{tas:e.toJSON(),tags:this.tags.map((e=>e.path)),beforeIds:this.before,afterIds:this.after})}async toApi(){return this.vacuum(),this.logger().tap({msg:"toApi()",result:{tags:await(0,c.thenCollect)(this.tags,(e=>e.toApiTag())),assetIdsAfter:this.leftPad(this.after),assetIdsBefore:this.rightPad(this.before)}})}streamCoeff(e){return this.logger().tap({msg:"streamCoeff",meta:{this:this.tags.map((e=>e.path)),tas:e.tags.map((e=>e.path))},result:(0,r.diceCoeff)([...this.before,...this.after],[...e.before,...e.after],(e=>e.assetId))})}},t.coalesceStreams=function(e){const t=n.Settings.minStreamCorrPct.valueOrDefault/100,i=[],s=e.filter((e=>e.length>5));for(const e of s){const s=(0,r.greatestBy)(i,(i=>(0,l.gtOrElse)(i.streamCoeff(e),t)));null==s?i.push(e):s.mergeWith(e)}return i}},94710:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Task=t.StaleTaskError=t.InvalidTaskError=t.TaskNames=t.Tasks=t.testTask=void 0;const c=i(78474),d=i(22454),h=i(23560),f=i(12089),m=i(76740),p=i(22911),g=i(99331),y=i(31562),w=i(38835),v=i(70025),b=i(8769),S=i(74128),P=i(28874),_=i(37692),T=i(40958),M=i(22573),E=i(42659),D=i(45599),x=i(98553),k=i(49769),C=i(68708),F=i(50989),A=i(59455),I=i(58723),O=i(34274),L=i(90901),R=i(61989),N=i(93755),B=i(69032),j=i(55046);t.testTask=(0,f.shim1)({name:"testTask",impl:async e=>{}}),t.Tasks={applyDeleted:I.applyDeleted,applyExcluded:I.applyExcluded,runTagMaintenance:B.runTagMaintenance,repairAsset:async function(e){e.forceSync=!0,e.skipPreviews=!0,e.skipAssetTagging=!0;const t=await(0,R.updateAsset_)(e);return(0,T.isNotEmpty)(t?.assetIdsToUpdate)&&q.add(t?.assetIdsToUpdate.map((t=>({fn:"repairAsset",args:{...e,assetId:t},priority:W.repairAsset+1})))),null!=t&&!0!==t.deleted&&(0,M.blank)((0,A.toA)(t.rejected).join(""))&&(0,M.blank)(t.error)&&q.addOne("assetPostUpsertTasks",(0,C.omit)(e,"skipPreviews","skipAssetTagging")),t},assetPostUpsertTasks:L.assetPostUpsertTasks,updateAssetFile:N.updateAssetFile_,syncFile:O.importFileToResult_,testTask:t.testTask},t.TaskNames=(0,F.strEnum)(...(0,C.keys)(t.Tasks));class z extends Error{}t.InvalidTaskError=z;class V extends Error{}t.StaleTaskError=V;const W={applyDeleted:16,applyExcluded:16,runTagMaintenance:14,repairAsset:12,assetPostUpsertTasks:10,updateAssetFile:8,syncFile:0,testTask:-1},U=["repairAsset"];class q extends j.Model{constructor(){super(...arguments),r.add(this),o.set(this,(0,D.defer)((()=>new m.Abortable)))}static countTaskNames(){const e={};for(const t of s.dbl.allf((e=>e.select("fn").count().groupBy("fn"))))e[t.fn]=t["count(*)"];return e}static orderBy(e){return e.orderBy([{column:"priority",order:"desc"},{column:"retries",order:"desc"},{column:"id",order:"asc"}])}static count(){return s.dbl.pluckFirstf((e=>e.count("id")))}static freeSlots(){return P.Settings.taskListCap.valueOrDefault-s.count()}static countByFn(e){return s.dbl.pluckFirstf((t=>t.where({fn:e}).count("id")))}static nextByFn(e,t=(e=>e)){return s.ops().allf((i=>s.orderBy(t(i.where({fn:e})))))}set args(e){this.argsJSON=(0,x.stringify)(e)}get args(){const e=(0,x.parseJSON)(this.argsJSON);return(0,C.notEmptyObj)(e)&&(e.halt=u(this,o,"f").call(this)),e}get isSerial(){return U.includes(this.fn)}toString(){return`Task#${this.fn}(${this.argsJSON})`}static addOne(e,t){return s.add([{fn:e,args:t}])[0]}static add(e,t=!1){if((0,T.isEmpty)(e))return[];const i=s.ops().upsert(e.map((e=>({fn:e.fn,argsJSON:(0,x.stringify)(e.args)})),t));return s.ee.emit("added",i),(0,h.isTaskListManager)()||(0,_.addStateEvent)("checkTasks"),i}$beforeUpsert(){this.priority??(this.priority=W[this.fn]),this.retries??(this.retries=P.Settings.maxRetries.valueOrDefault)}donePromise(){return(0,h.isTaskListManager)()?(0,k.getOrSet)(u(s,s,"f",n),this.id,(()=>new p.Deferred(this.toString(),{payload:this}))):(0,y.untilTrue)((()=>null==s.ops().findById(this.id)),{intervalMs:E.secondMs})}abort(e){this.logger().warn("aborting task",{reason:e,task:this}),u(this,o,"f").call(this).abort(e),this.delete(),(0,M.blank)(this.args.path)||(0,S.syncReport)().onProgress({path:this.args.path,from:this.fn,state:S.SyncFileStates.failed,details:e})}async _run(){if(this.retries<0)throw this.logger().warn(".run(): too many retries"+w.InternalErrorFlag,{job:this}),this.delete(),new z;if(!u(this,r,"m",l).call(this))throw this.logger().warn(".run(): someone already started this task",{job:this}),new V;try{const e=Date.now(),i=await t.Tasks[this.fn](this.args);return this.logger().throwIfAborted_(u(this,o,"f").prior()),s.taskResolvedCounts.incr(this.fn),s.ee.emit("resolved",this,i,Date.now()-e),this.delete(),u(s,s,"f",n).get(this.id)?.resolve(i),i}catch(e){if((0,g.ending)())throw this.logger().info("task failed, but we're ending. We'll leave it for next time.",{task:this}),e;throw s.taskRejectedCounts.incr(this.fn),(0,v.isRedoableError)(e)?(this.retries++,this.priority--,this.upsert()):!0===(0,v.isRetriableError)(e)&&this.retries>=0?this.logger().warn("run failed, but we can retry it later",{task:this,error:e}):(s.ee.emit("rejected",this,e),this.delete(),u(s,s,"f",n).get(this.id)?.reject(e),(0,b.onError)(this.toString()+" failed",e)),e}finally{u(s,s,"m",a).call(s)}}}t.Task=q,s=q,o=new WeakMap,r=new WeakSet,a=function(){for(const[e,t]of u(this,s,"f",n).entries())t.isSettled&&u(this,s,"f",n).delete(e)},l=function(){const e=this.retries;if(1===s.dbl.runf((t=>t.where({id:this.id,retries:e}).update({retries:e-1}))).changes)return--this.retries,!0;{const e=this.toJSON(),t=this.reload();return this.logger().warn(".#decrRetries(): someone already started this task",{before:e,reloaded:t}),!1}},q.$tableName="Task",q.$uniqueColumnName="fn,argsJSON",q.$useCache=!1,q.taskResolvedCounts=new d.CountingSet,q.taskRejectedCounts=new d.CountingSet,q.ee=new c.EventEmitter,n={value:new Map}},72761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimestampedModel=void 0;const r=i(97352),s=i(40958),n=i(31586),a=i(59455),o=i(55046);class l extends o.Model{static touch(e,t={}){t.updatedAt??(t.updatedAt=Date.now()),delete t.id;const i=(0,a.toA)(e).filter(n.gt0);return(0,s.isEmpty)(i)?void 0:this.dbl.runf((e=>e.whereIn("id",i).update(t)))}get createdAtDate(){return(0,r.mapGt0)(this.createdAt,(e=>new Date(e)))}get updatedAtDate(){return(0,r.mapGt0)(this.updatedAt,(e=>new Date(e)))}touch(e={}){e.updatedAt??(e.updatedAt=Date.now());const t=this.id;null==t?this.upsert():this.class().dbl.runf((i=>i.where({id:t}).update(e)))}$beforeUpsert(){if(super.$beforeUpsert(),this.createdAt??(this.createdAt=Date.now()),this.updatedAt=Date.now(),"updateCount"in this){const e=this,t=e.updateCount;e.updateCount=((0,n.toGt0)(e.updateCount)??0)+1,this.logger().debug("$beforeUpsert(): incr updateCount",{prior:t,now:e.updateCount})}}}t.TimestampedModel=l},58723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyExcluded=t.applyDeleted=void 0;const r=i(50213),s=i(43487),n=(0,r.mkLogger)("ops.ApplyRemovable");async function a(e,t,i){const r=e?"Deleting":"Excluding",a=e?"deletedAt":"excludedAt";await s.Asset.dbl.batched({qb:e=>e.select("id").where("shown",0).andWhere(a,"<=",t),onResults:async t=>{for(const a of t){n.throwIfAborted_(i);try{await s.Asset.remove({assetId:a,blocklistShas:!0,unlinkAssetFiles:e})}catch(e){n.error(r+" failed",{assetId:a,error:e})}}}})}t.applyDeleted=function(e){return a(!0,e.createdAt,e.halt)},t.applyExcluded=function(e){return a(!1,e.createdAt,e.halt)}},76386:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiProgressPatchPath=t.tellWebProgressUpdated=t.ProgressRateMs=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(24540),o=i(28874),l=i(34238),u=i(4988),c=i(15674),d=i(42659),h=(0,i(45599).defer)((()=>(0,s.mkLogger)("progress.Progress")));t.ProgressRateMs=(0,r.lazy)((()=>d.secondMs*((0,a.isRaspberryPi)()||(0,c.maxCpus)()<=3?5:1.5))),t.tellWebProgressUpdated=(0,r.lazy)((async()=>{if((0,n.isWebService)())return;const e=l.URI.from({scheme:"http",authority:"127.0.0.1:"+o.Settings.httpPort.valueOrDefault,path:t.ApiProgressPatchPath}).toString();await(0,u.httpRequest_)({url:e,method:"PATCH"}).catch((e=>h().warn(".tellWebProgressUpdated: failed",{error:e})))}),(0,t.ProgressRateMs)()),t.ApiProgressPatchPath="/api/progress"},44694:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryTermToFuzzyDate=void 0;const r=i(98725),s=(0,i(19851).lazy)((()=>new r.FuzzyDateParser({fuzzyDateParsing:!0,fuzzyYearParsing:!0})));t.queryTermToFuzzyDate=function(e){return s().parse(e)}},43786:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryToString=t.NormieQuerySymbols=t.SetQuerySymbols=t.isTrueTerm=t.flatTerms=t.findTerm=t.hasNsTerm=t.isQuery=t.isClause=t.isAndClause=t.isOrClause=t.isTerm=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(51926),o=i(54993);function l(e){return"object"==typeof e&&(0,s.notBlank)(e.term)&&(null==e.not||"boolean"==typeof e.not&&(null==e.ns||(0,a.isString)(e.ns)))}function u(e){return"object"==typeof e&&Array.isArray(e.queries)}function c(e){return"or"===e?.type&&u(e)}function d(e){return"and"===e?.type&&u(e)}function h(e){return d(e)||c(e)}function f(e,t){if(l(e))return t(e)?e:void 0;for(const i of e.queries){const e=f(i,t);if(null!=e)return e}}t.isTerm=l,t.isOrClause=c,t.isAndClause=d,t.isClause=h,t.isQuery=function(e){return l(e)||h(e)},t.hasNsTerm=function(e,t){return null!=f(e,(e=>e.ns===t))},t.findTerm=f,t.flatTerms=function e(t){return l(t)?[t]:(0,r.flatMap)(t.queries,e)},t.isTrueTerm=function(e){return(0,n.isTrue)(e?.not)?(0,n.isFalse)(e?.term):(0,n.isTrue)(e?.term)},t.SetQuerySymbols={not:"¬",and:"∧",or:"∨"},t.NormieQuerySymbols={not:"-",and:"AND",or:"OR"},t.queryToString=function e(i,r=t.SetQuerySymbols){if(null==i)return"";if(l(i)){let e=i.term;return null==i.term.match(/^[a-z]+$/i)&&(e='"'+e.replace(/"/g,'\\"')+'"'),`${(0,n.isTrue)(i.not)?r.not:""}${null==i.ns?"":i.ns+":"+(0,o.toS)(i.op)}${e}`}return"("+i.queries.map((t=>e(t,r))).join(` ${"or"===i.type?r.or:r.and} `)+")"}},7573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeTerm=t.isAssetTerm=t.AssetTermNs=t.AssetTermDateNs=t.AssetTermBoolNs=t.normalizeQuery=void 0;const r=i(48884),s=i(75020),n=i(40958),a=i(76790),o=i(22573),l=i(38639),u=i(50989),c=i(54993),d=i(44694),h=i(43786);function f(e){return(0,a.sortBy)((0,n.uniqBy)(e,h.queryToString),(e=>[(0,h.isTerm)(e)?0:(0,h.isOrClause)(e)?1:2,(0,h.queryToString)(e).replace(/[¬(]+/g,"")]))}t.normalizeQuery=function e(t){if((0,h.isTerm)(t))return g(t);const i=t.queries.map(e);if(0===i.length)throw new Error("empty query");if(1===i.length)return i[0];const[s,n]=(0,r.partition)(i,h.isTerm),[a,o]=(0,r.partition)(n,(e=>e.type===t.type));for(const e of a)s.push(...e.queries);const l={type:t.type,queries:f([...s,...o])};return l.queries.every((e=>(0,h.isTerm)(e)&&e.not))?e({type:"and"===t.type?"or":"and",queries:f(l.queries.map((e=>({...e,not:!1}))))}):l},t.AssetTermBoolNs=(0,u.strEnum)("deleted","excluded","liked","hidden"),t.AssetTermDateNs=(0,u.strEnum)("date","updated");const m={delete:t.AssetTermBoolNs.deleted,trash:t.AssetTermBoolNs.deleted,trashed:t.AssetTermBoolNs.deleted,exclude:t.AssetTermBoolNs.excluded,remove:t.AssetTermBoolNs.excluded,removed:t.AssetTermBoolNs.excluded,like:t.AssetTermBoolNs.liked,fav:t.AssetTermBoolNs.liked,fave:t.AssetTermBoolNs.liked,faved:t.AssetTermBoolNs.liked,favorite:t.AssetTermBoolNs.liked,favourite:t.AssetTermBoolNs.liked,hide:t.AssetTermBoolNs.hidden,archive:t.AssetTermBoolNs.hidden,archived:t.AssetTermBoolNs.hidden},p={kw:s.TagRoots.Keywords,keyword:s.TagRoots.Keywords,keywords:s.TagRoots.Keywords,dir:s.TagRoots.fs,directory:s.TagRoots.fs,folder:s.TagRoots.fs};function g(e){if((0,o.blank)(e.ns)&&null!=e.term.match(/^\d{4}[-\d]*$/)&&null!=(0,d.queryTermToFuzzyDate)(e.term))return{ns:"date",term:e.term};if("when"===(0,c.toS)(e.ns).toLowerCase())return g({...e,ns:t.AssetTermDateNs.date,term:e.term.replace(/\//g,"-")});let i=(0,o.notBlankOr)(e.ns,e.term).toLowerCase();if(i=m[i]??i,t.AssetTermBoolNs.includes(i)){let t=!(0,l.isFalse)(e.term);return!0===e.not&&(t=!t),{ns:i,term:(0,c.toS)(t)}}if(t.AssetTermNs.includes(i))return{...e,ns:i};if("before"===i||"after"===i){if(null!=e.op)throw new Error(i+": doesn't support operators");const r="after"===i&&!0!==e.not||!0===e.not;return{ns:t.AssetTermDateNs.date,op:r?">":"<",term:e.term}}return i!==e.term.toLowerCase()?{not:e.not,op:e.op,ns:p[i]??i,term:e.term}:e}t.AssetTermNs=(0,u.strEnum)(...t.AssetTermDateNs.values,...t.AssetTermBoolNs.values),t.isAssetTerm=function(e){return(0,h.isTerm)(e)&&t.AssetTermNs.includes(g(e).ns)},t.normalizeTerm=g},33693:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseQuery_=void 0;const s=r(i(31704)),n=i(19851),a=i(50213),o=i(7282),l=i(38835),u=i(31586),c=r(i(70471)),d=(0,n.lazy)((()=>(0,a.mkLogger)("query.QueryParser")));t.parseQuery_=function(e){try{const t=new s.default.Parser(s.default.Grammar.fromCompiled(c.default)).feed(e.trim()).finish();if(t.length>1&&!(0,o.isProd)()&&d().throw("parseQuery(): ambiguous grammar!",{input:e}),null==t[0])throw new Error("invalid query");return d().debug("parseQuery()",{input:e,result:t[0]}),t[0]}catch(t){const i=t.token?.col,r=`Query syntax error${(0,u.gt0)(i)?" around column "+i:""}: "${e}"`;throw d().warn("parseQuery(): bad query",{msg:r,err:t}),new Error(r+l.NonRetriableErrorFlag+l.DoNotSendErrorFlag)}}},23523:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryToSql=t.queryStringToSql_=t.defaultAssetQuery=void 0;const r=i(19851),s=i(50213),n=i(66649),a=i(89724),o=i(70417),l=i(28874),u=i(42231),c=i(22573),d=i(38639),h=i(98553),f=i(54993),m=i(57038),p=i(43487),g=i(44694),y=i(43786),w=i(7573),v=i(33693),b=(0,r.lazy)((()=>(0,s.mkLogger)("query.QueryToSql")));function S(e,t,i){if((0,y.isTerm)(t))return function(e,t,i){return(0,w.isAssetTerm)(t)?function(e,t){switch(t.ns){case w.AssetTermNs.date:case w.AssetTermNs.updated:return function(e,t){const i=t.op??"=",r="date"===t.ns?"Asset.capturedAtLocal":"updated"===t.ns?"Asset.updatedAt":void 0;if(null==r)throw new Error("internal error: unexpected namespace for "+(0,h.stringify)(t));const s="Asset.updatedAt"===r?n.datedToMillis:a.maybeDatedToLocal,l=(0,g.queryTermToFuzzyDate)(t.term),u=s(l),c=l?.following()?.toDateTime(),d=s(c?.minus({second:1})),f=(0,o.max)([u,d]);if(null==l||null==u||null==f)throw new Error((0,y.queryToString)(t,y.NormieQuerySymbols)+" can't be parsed as a date");if("="===i)return e.whereBetween(r,[u,f]);if("<"===i)return e.where(r,i,u);if("<="===i)return e.where(r,i,f);if(">="===i)return e.where(r,i,u);if(">"===i)return e.where(r,i,f);throw new Error("internal error: unexpected op for "+(0,h.stringify)(t))}(e,t);case w.AssetTermNs.hidden:return e.where("Asset.hidden",_(t));case w.AssetTermNs.excluded:return M({qb:e,column:"Asset.excludedAt",whereNull:0===_(t)});case w.AssetTermNs.deleted:return M({qb:e,column:"Asset.deletedAt",whereNull:0===_(t)});case w.AssetTermNs.liked:return e.where("Asset.rating",P(t)?">=":"<",l.Settings.likeRating.valueOrDefault);default:throw new Error("not asset term:"+(0,y.queryToString)(t))}}(e,t):function(e,t,i){const r=t.term.startsWith("/"),s="="===t.op,n=function(e,t){if(null==t||"fs"!==e.ns)return e.term;const i=e.term.split("/"),r=i.findIndex(c.notBlank);if(-1===r)return e.term;const s=i[r];return i[r]=t.get(s)??s,i.join("/")}(t,i);if(r||s)return e.whereIn("Asset.id",(0,m.knex)()("AssetTag").join("Tag","Tag.id","AssetTag.tagId").select("assetId").whereLike("Tag._path",t.ns+(r?"":"%")+n.replace(/\//g,u.TagSep).replace(/\*/g,"%")+u.TagSep+(s?"":"%")));let a=(0,m.knex)()("AssetTag").join("tag_fts","tag_fts.rowid","AssetTag.tagId").select("assetId");const o="path:"+T(n.replace(/\//g," + "));if((0,c.blank)(t.ns)){if((0,d.isTrue)(t.not))throw new Error("Cannot negate without a namespace ("+(0,y.queryToString)(t)+")");a=a.where("tag_fts","MATCH",o)}else a=a.where("tag_fts","MATCH","(root:"+T(t.ns)+((0,d.isTrue)(t.not)?" NOT ":" AND ")+o+")");return e.whereIn("Asset.id",a)}(e,t,i)}(e,t,i);for(const r of t.queries)e=(0,y.isAndClause)(t)?e.andWhere((e=>S(e,r,i))):e.orWhere((e=>S(e,r,i)));return e}function P(e){const t=(0,d.isTrue)(e.term);return!0===e.not?!t:t}function _(e){return P(e)?1:0}function T(e){return e.includes("*")?e.split("*").map(T).join(" * "):`"${(0,f.toS)(e).replace(/"/g,'""')}"`}function M({qb:e,column:t,whereNull:i}){return i?e.whereNull(t):e.whereNotNull(t)}function E(){return p.Asset.ops().query().where("Asset.shown",1).join("AssetTag","AssetTag.assetId","Asset.id")}function D(e,t=E(),i){return e=(0,w.normalizeQuery)(e),(0,y.hasNsTerm)(e,w.AssetTermBoolNs.hidden)||(0,y.hasNsTerm)(e,w.AssetTermBoolNs.excluded)||(0,y.hasNsTerm)(e,w.AssetTermBoolNs.deleted)||(t=t.andWhere({"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null})),t.andWhere((t=>S(t,e,i)))}t.defaultAssetQuery=E,t.queryStringToSql_=function(e,t=E()){const i=(0,v.parseQuery_)(e);return null==i?(b().warn("assetQuery("+e+"): parsed to null"),t):D(i,t)},t.queryToSql=D},70471:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};function s(e){return e[0]}Object.defineProperty(t,"__esModule",{value:!0}),t.parseTerm=void 0;const n=r(i(80265)),a=i(40958),o=i(54993);function l(e){if(null==e[0]&&["and","or"].includes((0,o.toS)(e[1]).toLowerCase()))throw new Error("Unmatched "+e[1]);return{not:null!=e[0]?.[0]?.value,ns:e[0]?.[1]?.value,op:e[0]?.[3]?.value,term:e[1]}}function u(e){return e[0]?.value}t.parseTerm=l;const c=n.default.compile({qstr:[{match:/"(?:[^\\"]|\\.)*?"/,value:e=>e.slice(1,-1).replace(/\\"/g,'"')},{match:/'(?:[^\\']|\\.)*?'/,value:e=>e.slice(1,-1).replace(/\\'/g,"'")}],lp:"(",rp:")",not:/[-¬]/,col:":",op:/<=?|>=?|=/,or:/ +(?:or|OR|Or|∨|\|{1,2}) +/,and:/(?:and|AND|And|∧|\&{1,2}) +/,str:/[^\s:\(\)"'][^\s:\(\)]*/,ws:/ +/}),d={Lexer:c,ParserRules:[{name:"Expression$ebnf$1",symbols:[]},{name:"Expression$ebnf$1$subexpression$1",symbols:[c.has("or")?{type:"or"}:or,"Clause"]},{name:"Expression$ebnf$1",symbols:["Expression$ebnf$1","Expression$ebnf$1$subexpression$1"],postprocess:e=>e[0].concat([e[1]])},{name:"Expression",symbols:["Clause","Expression$ebnf$1"],postprocess:function(e){const t=(0,a.compact)([e[0],...e[1].map((e=>e[1]))]);return 1===t.length?t[0]:{type:"or",queries:t}}},{name:"Clause$ebnf$1",symbols:[]},{name:"Clause$ebnf$1$subexpression$1$ebnf$1",symbols:[c.has("and")?{type:"and"}:and],postprocess:s},{name:"Clause$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"Clause$ebnf$1$subexpression$1",symbols:["__","Clause$ebnf$1$subexpression$1$ebnf$1","Factor"]},{name:"Clause$ebnf$1",symbols:["Clause$ebnf$1","Clause$ebnf$1$subexpression$1"],postprocess:e=>e[0].concat([e[1]])},{name:"Clause",symbols:["Factor","Clause$ebnf$1"],postprocess:function(e){const t=(0,a.compact)([e[0],...e[1].map((e=>e[2]))]);return 1===t.length?t[0]:{type:"and",queries:t}}},{name:"Factor",symbols:["Term"],postprocess:s},{name:"Factor",symbols:[c.has("lp")?{type:"lp"}:lp,"_","Expression","_",c.has("rp")?{type:"rp"}:rp],postprocess:function(e){const t=(0,a.compact)(e[2]);return 1===t.length?t[0]:t}},{name:"Term$ebnf$1$subexpression$1$ebnf$1",symbols:[c.has("not")?{type:"not"}:not],postprocess:s},{name:"Term$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"Term$ebnf$1$subexpression$1$ebnf$2",symbols:[c.has("op")?{type:"op"}:op],postprocess:s},{name:"Term$ebnf$1$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"Term$ebnf$1$subexpression$1",symbols:["Term$ebnf$1$subexpression$1$ebnf$1",c.has("str")?{type:"str"}:str,c.has("col")?{type:"col"}:col,"Term$ebnf$1$subexpression$1$ebnf$2"]},{name:"Term$ebnf$1",symbols:["Term$ebnf$1$subexpression$1"],postprocess:s},{name:"Term$ebnf$1",symbols:[],postprocess:()=>null},{name:"Term",symbols:["Term$ebnf$1","Value"],postprocess:l},{name:"Value",symbols:[c.has("qstr")?{type:"qstr"}:qstr],postprocess:u},{name:"Value",symbols:[c.has("str")?{type:"str"}:str],postprocess:u},{name:"_$ebnf$1",symbols:[c.has("ws")?{type:"ws"}:ws],postprocess:s},{name:"_$ebnf$1",symbols:[],postprocess:()=>null},{name:"_",symbols:["_$ebnf$1"]},{name:"__",symbols:[c.has("ws")?{type:"ws"}:ws]}],ParserStart:"Expression"};t.default=d},3996:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileFinder=t.isFileInSync=void 0;const o=i(19851),l=i(50213),u=i(79781),c=i(56519),d=i(56038),h=i(59189),f=i(38835),m=i(95696),p=i(48368),g=i(181),y=i(69589),w=i(28874),v=i(47783),b=i(87001),S=i(40958),P=i(76790),_=i(22573),T=i(42659),M=i(55835),E=i(31586),D=i(43487),x=i(54017);t.isFileInSync=async function(e){return new C(m.PosixFile.for(e)).alreadySynced()};const k=new h.SerialLaterQueue;class C{constructor(e,t=(0,y.forceContextOrSetting)()){this.file=e,this.ctx=t,r.set(this,void 0),s.set(this,new Set),this.alreadySynced=(0,d.timedLazy)("sync-file.AssetFileFinder.alreadySynced: "+this.file,(async()=>a(this,r,"f").tap({msg:"alreadySynced",result:null!=await this.priorIfSynced()}))),this.newAssetFile_=(0,d.timedLazy)("sync-file.AssetFileFinder.newAssetFile: "+this.file,(async()=>{const e=await(new x.AssetFile).updateFromFile_(this.file);return null==e?a(this,r,"f").throw("AssetFile.updateFromFile returned null",{fatal:!1}):e})),this.tags_=(0,o.lazy)((async()=>{const e=await(0,v.readTags)(this.file);if(null==e)throw new Error(this.file+" doesn't have metadata");return e})),this.imageHash=(0,o.lazy)((()=>w.Settings.useImageHashes.valueOrDefault?(0,p.imageHash)(this.file):void 0)),this.dominantLabhashes=(0,o.lazy)((()=>(0,c.thenMap)(this.imageHash(),(e=>(0,S.uniq)(e.dominantColors.filter((e=>e.pct>5)).map((e=>e.labhash))))))),this.capturedAtLocal=(0,o.lazy)((async()=>{const e=await this.capturedAt_();return a(this,r,"f").tap({msg:"capturedAtLocal",result:e?.local,meta:{capturedAt:e}})})),this.mapSibling=e=>this.newAssetFileForAsset(e?.getAsset()),this.apply_=(0,d.timedLazy)("sync-file.AssetFileFinder: "+this.file,(async()=>{if((0,_.blank)(await this.file.uri_()))throw new Error("Cannot import, file URI is blank for "+this.file);{const e=await this.byExistingAsset_();if(null!=e)return a(this,r,"f").info("Found existing asset for file"),e}const e=await this.newAssetFile_(),t=await k.enqueue((async()=>{const t=await this.byExistingAsset_();if(null!=t?.assetId)return a(this,r,"f").info("Found existing asset for file after acquiring lock",{withExistingAsset:t}),t.assetId;const i=new D.Asset;return i.capturedAtLocal=e.capturedAtLocal,i.addAssetFile(e),i.upsert(),i.id}));return e.assetId=t,e.upsert()})),this.byExistingAsset_=()=>(0,d.time)("sync-file.AssetFileFinder.byExistingAsset: "+this.file,(async()=>{const e=[{name:"byUri",f:()=>this.byUri()},{name:"byNormalizedPathUri",f:()=>this.newAssetFileForAsset(this.assetByNormalizedPathUri())},{name:"bySha",f:()=>this.newAssetFileForAsset(this.assetBySha())},{name:"hasTags",f:async()=>{await this.tags_()}},{name:"validFile",f:async()=>{await(0,g.throwIfInvalidFile_)(this.file)}},{name:"byCapturedAtOrImageHash",f:()=>this.newAssetFileForAsset(this.assetByCapturedAtOrImageHash())}];for(const{name:t,f:i}of e)try{const e=await(0,d.time)("sync-file.assetFileFinder."+t+": "+this.file,i);if(null!=e)return a(this,r,"f").info("apply(): "+t,{assetFileId:e.id,assetId:e.assetId}),e;a(this,r,"f").debug("apply(): "+t+": returned null")}catch(e){throw a(this,r,"f").debug("apply(): "+t+" rejected: "+e),e}})),n(this,r,(0,l.mkLogger)("sync-file.AssetFileFinder("+e.baseWithGrandparent+")"),"f")}async prior(){return this.byUri()}async priorIfSynced(){if(this.ctx.forceSync)return;const e=await this.prior();return!0===await(e?.matchesFile())?e:void 0}async newAssetFileForAsset(e){const t=await e;if(null!=t){if(null!=t.id){const e=await this.newAssetFile_();return t.addAssetFile(e),e.insert(),a(this,r,"f").debug("newAssetFileForAsset() upsert success!",{af:e}),e}a(this,r,"f").throw("newAssetFileForAsset(): given non-persisted Asset")}}async capturedAt_(){return(await this.tags_()).capturedAt}async byUri(e=this.file){const t=await e.uri_();if(null!=t)return x.AssetFile.ops().firstf((e=>e.whereIn("uri",[...(0,b.uriEncodingVariants)(t),this.file.fileuri()])));a(this,r,"f").warn("byUri() uri is null",{file:e})}async assetByNormalizedPathUri(){const e=await this.file.normalize();return e.nativePath===this.file.nativePath?void 0:(await this.byUri(e))?.getAsset()}assetBySha(){return(0,c.thenMap)(this.file.sha(),(e=>D.Asset.findFirstByFile((t=>t.where("AssetFile.sha",e)))))}async assetByCapturedAtOrImageHash(){const e=await this.capturedAt_();if(null==e)return a(this,r,"f").throw("Cannot import, capturedAt is null"+f.InternalErrorFlag);if(w.Settings.strictDeduping.valueOrDefault)return this.firstSimilarAsset(x.AssetFile.ops().allf((t=>t.where({capturedAtLocal:e.local}))));const t=w.Settings.maxContemporaryAdoptionAssets.valueOrDefault,i=()=>{let i=x.AssetFile.query();return(0,E.gt0)(t)&&(i=i.limit(t)),i.orderByRaw(`abs(capturedAtLocal - ${e.local})`)},s=Math.max(T.secondMs,w.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault);return(0,d.time)("sync-file.AssetFileFinder.assetByCapturedAtAndImageHash: "+this.file,(async()=>{{const t=e.localBoundaries({delta:s});if(null==t)a(this,r,"f").warn("Failed to fetch localBoundaries, cannot fetch similar assets by localtime",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("captured-at",i().whereBetween("capturedAtLocal",[t.start,t.end]))??(w.Settings.checkBasenameMatches.valueOrDefault?this.firstSimilarAssetByQuery("basename",i().whereILike("uri","%/"+this.file.name+"%")):void 0);if(null!=e)return e}}const t=await this.imageHash();if(null==t)return void a(this,r,"f").warn("assetByCapturedAtAndImageHash: no imageHash");const n=await this.dominantLabhashes();if((0,S.isNotEmpty)(n)){const t=e.localBoundaries({delta:4*s});if(null==t)a(this,r,"f").error("Failed to fetch localBoundaries, cannot fetch similar assets by wide localtime + image hash",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("wide captured-at and dominant color",i().whereBetween("capturedAtLocal",[t.start,t.end]).andWhere((e=>e.whereIn("mode0",n).orWhereIn("mode1",n).orWhereIn("mode2",n))));if(null!=e)return e}}return this.firstSimilarAssetByQuery("image hash",i().where("meanHash",t.meanHash).orWhere("diffHash",t.diffHash).orWhere("dctHash",t.dctHash))}))}async firstSimilarAssetByQuery(e,t){a(this,s,"f").size>0&&(t=t.whereNotIn("AssetFile.id",Array.from(a(this,s,"f"))));const i=await this.firstSimilarAsset(x.AssetFile.ops().all(t));return null!=i&&a(this,r,"f").info("Found similar asset by "+e,{result:i}),i}async firstSimilarAsset(e){const t=await this.newAssetFile_(),i=await this.capturedAtLocal();if(null==t)throw new Error("Failed to update from "+this.file);const n=(0,P.sortBy)(e.filter((e=>!a(this,s,"f").has(e.id))),(e=>[(0,M.mapOr)(i,(t=>Math.abs(e.capturedAtLocal-t)),-e.capturedAtLocal),e.id]));for(const e of n)if(null!=e){await e.getNativePath();const i=x.AssetFile.ops().findBy({assetId:e.assetId});await Promise.all(i.map((e=>e.getNativePath())));const n=(0,u.whyNotSameAsset)(t,e,i);if(null==n)return a(this,r,"f").info("Found sibling AssetFile",e),D.Asset.ops().findById(e.assetId);a(this,s,"f").add(e.id),a(this,r,"f").debug("Contemporary assetFile not similar: "+n,e?.uri)}}}t.AssetFileFinder=C,r=new WeakMap,s=new WeakMap},34274:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileImporter=t.importFileToResult_=void 0;const u=i(19851),c=i(50213),d=i(73568),h=i(38835),f=i(95696),m=i(62105),p=i(74128),g=i(181),y=i(69589),w=i(28874),v=i(40958),b=i(22573),S=i(38639),P=i(59455),_=i(64526),T=i(19113),M=i(94710),E=i(3996),D=i(90901);t.importFileToResult_=async function(e){const t=_.Library.instanceRequired_();return(0,p.syncReport)().wrap_({path:e.path,from:"AssetFileImporter",fn_:()=>new x(f.PosixFile.for(e.path),t.assetFileRepository(),e).apply_()})};class x{constructor(e,t,i){r.add(this),this.file=e,this.repo=t,this.start=Date.now(),s.set(this,void 0),n.set(this,void 0),this.whyRejected=(0,u.lazy)((async()=>{const e=[],t=await this.file.uri_();if(null==t)e.push("Cannot make URI"+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);else{if(!0===await this.file.isDeletedUri(t))e.push("File was deleted");else if(this.ctx.forceFilters||null==await this.prior()){const t=await(0,m.whyRejectFile)(this.file,(0,T.libraryFileFiltersFor)(this.file));null!=t&&e.push(t)}l(this,s,"f").throwIfAborted_();const i=await this.prior();if((0,v.isNotEmpty)(e)&&null!=i&&(l(this,s,"f").info("Deleting prior AssetFile",{rejected:e,prior:i}),i.delete(),this.ctx.skipAssetRepair?l(this,s,"f").info("Skipping asset repair",{assetId:i.assetId}):(l(this,s,"f").info("Scheduling asset repair",{assetId:i.assetId}),M.Task.addOne("repairAsset",{assetId:i.assetId,forceRebuildPreviews:(0,S.isTrue)(i.shown)}))),null!=i){const t=i.getAsset();null!=t?.deletedAt&&e.push("Asset is marked as deleted"),null!=t?.excludedAt&&e.push("Asset is marked as excluded")}if(l(this,s,"f").throwIfAborted_(),0===e.length&&(null==i||!await i.inSyncWithFile())){const t=await(0,g.whyInvalidFile)(this.file.nativePath);(0,b.blank)(t)||e.push(t)}}return e})),this.assetFile_=(0,u.lazy)((async()=>{const e=await l(this,n,"f").apply_(),t=e.getAsset();return l(this,s,"f").info("assetFileFinder.apply_() result",{asset:t,assetFile:e}),null==t?l(this,s,"f").throw("assetFile.getAsset() was null",{srcAssetFile:e}):null==t.id?l(this,s,"f").throw("repoAssetFile asset has null id",{asset:t}):e})),this.prior=(0,u.lazy)((()=>l(this,n,"f").prior())),this.apply_=(0,u.lazy)((()=>l(this,r,"m",a).call(this))),this.ctx=(0,y.forceContextOrSetting)(i),o(this,s,(0,c.mkLogger)("sync-file."+this.toString()),"f"),o(this,n,new E.AssetFileFinder(e,this.ctx),"f")}toString(){return"AssetFileImporter("+this.file.nativePath+")"}newAssetFile(){return l(this,n,"f").newAssetFile_()}}t.AssetFileImporter=x,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(){l(this,s,"f").throwIfAborted_();const e=await l(this,s,"f").tapAsync_({msg:"whyRejected",result:this.whyRejected(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if((0,v.isNotEmpty)(e)){const t=e.join(", ");return{path:this.file.nativePath,state:p.SyncFileStates.rejected,details:t}}l(this,s,"f").throwIfAborted_();const t=await l(this,s,"f").tapAsync_({msg:"prior()",result:this.prior(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if(null!=t&&await t.isNoop(this.ctx))return{path:this.file.nativePath,state:p.AssetFileSyncStates.noop,assetId:t.assetId,assetFileId:t.id,assetFile:t,asset:t.getAsset(),uri:t.uri};l(this,s,"f").throwIfAborted_();const i=await l(this,s,"f").tapAsync_({msg:"assetFile()",result:this.assetFile_(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if(null==i)return l(this,s,"f").throw("_apply(): unexpected null assetFile");const r=i.id;if(null==r)return l(this,s,"f").throw("_apply(): unexpected null assetFileId");const n=i.uri;if(null==n)return l(this,s,"f").throw("_apply(): unexpected null assetFile.uri");const a=i.getAsset();if(null==a)return l(this,s,"f").throw("_apply(): unexpected null assetFile.getAsset()");let o;await l(this,s,"f").tapAsync_({msg:"assetFile.upsertIfNeeded_()",result:i.upsertIfNeeded_(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault}),l(this,s,"f").throwIfAborted_();try{o=await(0,D.assetPostUpsertTasks_)({asset:a,...this.ctx})}catch(e){e instanceof d.AbortError?l(this,s,"f").warn("aborted (caller/process after me will complete)",{error:e}):l(this,s,"f").throw("Post-upsert tasks failed",{error:e})}return{path:this.file.nativePath,state:i.syncState??p.SyncFileStates.synced,assetId:a.id,assetFileId:r,assetFile:i,asset:a,uri:n,uris:[n,...(0,P.toA)(o?.newAssetFileUris)]}}},41844:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileRepository=t.mayCopyAssetsToLibrary=void 0;const u=i(50213),c=i(74128),d=i(81674),h=i(57902),f=i(4936),m=i(28874),p=i(47783),g=i(67083),y=i(16170),w=i(54979),v=i(98604),b=i(40958),S=i(22573),P=i(98553),_=i(89937),T=i(59455),M=i(54017),E=i(94710);t.mayCopyAssetsToLibrary=async function(){return m.Settings.copyAssetsToLibrary.valueOrDefault&&await(0,d.p)()},t.AssetFileRepository=class{constructor(e){r.add(this),this.originalsDir=e,this.logger=(0,u.mkLogger)("AssetFileRepository")}async shouldCopy(e){const t=await this.whyNotCopyFile(e);return this.logger.tap({level:"info",msg:"shouldCopy()",result:null==t,meta:{file:e?.nativePath,whyNot:t}})}async whyNotCopyFile(e){if(null==e||(0,S.blank)(e.nativePath))return"blank nativePath";if(!0!==m.Settings.copyAssetsToLibrary.value)return"copyAssetsToLibrary !== true";if(await(0,d.l)())return"no active subscription";if(await e.notExists({refresh:!0}))return"file doesn't exist";if(e.isDescendantOf(this.originalsDir))return e+" already contained by "+this.originalsDir;if(e.isDescendantOf(m.Settings.libraryDir.valueOrDefault))return e+" already contained by "+m.Settings.libraryDir.valueOrDefault;const t=await(0,w.readMimeType)(e);return null==t?"readMimeType("+e+") was null":(0,y.isMimeTypeIncluded)(t,m.Settings.copyToLibraryMimeTypes.values)?null:"mimetype "+t+" is not included in copyToLibraryMimeTypes"}async existingLibraryAssetFile(e){if(e.uri.startsWith(_.PS_LIBRARY_PROTOCOL))return e;const t=(0,b.uniqBy)((0,T.toA)(e.librarySiblings()?.filter((t=>t.sha===e.sha))).concat(M.AssetFile.sameAssetFileInLibrary(e)),(e=>e.id));for(const i of t)if(await i.exists()){if(i.assetId!==e.assetId){this.logger.warn("Existing library asset file with a matching SHA is associated to a different asset. Requesting repair of the two impacted assets.",{af:e,prior:i});const t=i.assetId;e.getAsset()?.addAssetFile(i),E.Task.addOne("repairAsset",{assetId:t,forceSync:!0})}return this.logger.info("whyNotCopyAssetFile("+e.uri+"): found existing db record",{af:e,prior:i}),i}return null}async findLibraryFileWithSameContents(e,t){if(await e.matchesContent(t))return t;let i=t.parent();for(;i.isSelfOrDescendantOf(this.originalsDir);){const t=i.childWithSameContents(e);if(null!=t)return t;i=i.parent()}}async importFile_(e){const t=await l(this,r,"m",s).call(this,e);return null!=t&&(await l(this,r,"m",n).call(this,e,t),await l(this,r,"m",o).call(this,e,t)),t}async maybeCopyToLibrary_(e,t){const i=Date.now(),s=await e.posixFile_();null==s&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): posixFile is null",{ignorable:!1,retriable:!1});{const e=await this.whyNotCopyFile(s);if(!(0,S.blank)(e))return this.logger.tap({level:h.LogLevels.info,msg:"maybeCopyToLibrary_(): not copying: "+e,result:void 0})}const a=e.getAsset();null==a&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): null asset");{const u=await this.existingLibraryAssetFile(e);if(null!=u){const e=await u.posixFile_();if(null!=e){const d=await l(this,r,"m",n).call(this,s,e),h=null!=await l(this,r,"m",o).call(this,s,e),f=null!=await u.upsertIfNeeded_(void 0,t);return!h&&(0,b.isEmpty)(d)&&!f||(0,c.syncReport)().onProgress({path:e.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.synced,details:"Found and synced prior replica already in your library "+(0,P.stringify)({src:s.nativePath,upsertNeeded:f,copiedSidecars:d,copiedInferredMetadata:h}),elapsedMs:Date.now()-i,url:(0,v.mkAssetUrl)(a.id)?.toString()}),u}this.logger.warn("existingLibraryAssetFile() returned an assetFile that could not be resolved to a PosixFile",{prior:u})}}const u=await this.importFile_(s);if(null==u)return void this.logger.info("importFile() returned null",{srcAssetFile:e});if(u.nativePath===s.nativePath)return void this.logger.info("importFile() returned the same nativePath as src",{srcAssetFile:e,dest:u});const d=await a.assetFileForFile_(u,{skipUpsert:!0});await d.updateFromShaSibling_(e);const f=d.upsert();return a.addAssetFile(d),(0,c.syncReport)().onProgress({path:u.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.copied,details:"Copied into your library from "+s.nativePath,elapsedMs:Date.now()-i,url:(0,v.mkAssetUrl)(a.id)?.toString()}),f}},r=new WeakSet,s=async function(e){const t=await(0,p.readCapturedAt)(e),i=(0,f.pathToLibraryAsset)(t?.date,e);if(this.logger.debug("importFile("+e+")",{capturedAt:t,assetPath:i}),null==i)throw new Error(e.nativePath+" failed to create a library path");const r=this.originalsDir.join(...i),s=await this.findLibraryFileWithSameContents(e,r);if(null!=s)return this.logger.debug("#importFile_("+e+"): found existing file",{src:e,existing:s}),s;const n=await r.ensureNew_();return this.logger.info("#importFile_("+e+"): copying...",{uniqDest:n,dest:r}),e.copyFile_(n)},n=async function(e,t){const i=await e.existingSidecars(),s=[];for(const e of i)s.push(await l(this,r,"m",a).call(this,e,t));return(0,b.compact)(s)},a=async function(e,t){for(const i of await t.existingSidecars())if(await(0,p.sidecarEql)(e,i))return void this.logger.info("handleSidecar(): metadata already exists.",{srcSidecar:e,destSidecar:i,dest:t});const i=await t.parent().join(t.name+e.ext).ensureNew_({emptyIsNew:!0});return e.copyFile_(i)},o=async function(e,t){if(null==e||null==t||e.eql(t))return;const i=await(0,p.readTags)(e);if(null!=i)return(0,g.ensureInferredHistoryRecords)(e,await t.sidecar(),i.inferred);this.logger.warn("#handleInferred(): Failed to read tags from "+e,{dest:t})}},90901:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetPostUpsertTasks_=t.assetPostUpsertTasks=void 0;const r=i(50213),s=i(92434),n=i(73568),a=i(99331),o=i(39250),l=i(38835),u=i(57159),c=i(48604),d=i(66106),h=i(69589),f=i(40958),m=i(45599),p=i(23838),g=i(31586),y=i(64526),w=i(88224),v=i(43487),b=i(41844),S=i(68640),P=(0,m.defer)((()=>(0,r.mkLogger)("sync-file.AssetPostUpsertTasks"))),_=(0,m.defer)((()=>new o.LastOneInWins("Asset tasks")));async function T(e){const t=e,i=e,r=(0,g.toGt0)(t.asset?.id)??(0,g.toGt0)(i.assetId);if(null==r)throw new Error("assetPostUpsertTasks_(): unexpected null assetId"+l.InternalErrorFlag);const o=(0,h.forceContextOrSetting)(e),m=P().addContext(`.postUpsertAssetTasks_(Asset:${r})`);if(m.abortable=o.halt,o.skipPreviews&&o.skipAssetTagging)return void m.info("skipped (skipPreviews && skipAssetTagging)");const T=t.asset??v.Asset.ops().findById(r);if(null==T)return m.throw("unexpected null asset",{asset:T});try{return await _().enqueue({key:r,abortable:m.abortable,fn:()=>async function(e,t,i){const r=(0,h.forceContextOrSetting)(i),n=t.id,a=t.getAssetFiles({refresh:!0}),o={newAssetFileUris:[],previewsUpdated:!1,tagResult:void 0,transcoded:!1};if(e.throwIfAborted_(),(0,f.isEmpty)(a)&&(await v.Asset.remove({assetId:n,blocklistShas:!1,unlinkAssetFiles:!1}),e.throw(`Asset:${n} had no asset files. Deleted.`)),await(0,b.mayCopyAssetsToLibrary)())for(const[t,i]of(0,p.groupBy)(a,(e=>e.sha)).entries()){e.throwIfAborted_();try{for(const r of i)r.isInLibrary()&&await r.exists()&&e.debug("no-op for file SHA: already in library.",{sha:t,uri:r.uri});for(const e of i)if(await e.exists()){const t=await y.Library.instanceRequired_().assetFileRepository().maybeCopyToLibrary_(e,r);if(null!=t){o.newAssetFileUris.push(t.uri);continue}}}catch(r){e.warn("Failed to copy variation to library, but we'll try to continue",{sha:t,uris:i.map((e=>e.uri)),error:r})}}e.throwIfAborted_();const l=r.skipPreviews?void 0:await(0,S.updateAssetPreviews_)({asset:t,assetFiles:t.getAssetFiles(),...r}),u=await async function(e,t){if((0,g.gt0)(t?.assetFileId)){const i=e.getAssetFiles({refresh:!0}).find((e=>e.id===t?.assetFileId));return null==i?P().throw("AssetPreviewInfo referenced unknown assetFileId",{asset:e,info:t}):i}const i=e.getShown();return null!=i?i:(0,s.bestExistingAssetFile)(e.getAssetFiles())}(t,l);if(null==u)return e.throw("null primaryOrShownAssetFile_()",{asset:t});const m=await u.posixFile_();if(!0!==r.skipPreviews&&t.isVideo()){if(null==m)return e.throw("null primary.posixFile()",{asset:t,assetFiles:t.getAssetFiles()});o.transcoded=null!=await(0,d.transcode_)(m,c.Previews.instance().ap(n).mp4(),{force:r.forceRebuildPreviews,halt:r.halt})}return e.throwIfAborted_(),t.markShownAndUpsert_(u),r.skipAssetTagging?e.info("skipping asset tagging"):o.tagResult=await(0,w.tagAndUpsertAsset_)(t),o}(m,T,{...e,...o})})}catch(e){if(e instanceof n.AbortError)return void m.warn("aborted, next caller will clean up my mess",{error:e});const t=[e];if(!(0,a.ending)()){m.error("failed, marking asset unshown",{error:e});try{T.markUnshownAndUpsert()}catch(e){m.error("failed to mark asset unshown",{upsertError:e}),t.push(e)}}throw new u.WrappedError("Failed to post-process assset "+T.id,{causes:t})}}t.assetPostUpsertTasks=function(e){try{return T(e)}catch(e){if(e instanceof n.AbortError)return void P().warn("aborted, next caller will clean up my mess",{error:e});throw e}},t.assetPostUpsertTasks_=T},61989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAsset_=t.updateAsset=void 0;const r=i(48884),s=i(50213),n=i(45393),a=i(79184),o=i(79781),l=i(92434),u=i(56519),c=i(70417),d=i(69589),h=i(28874),f=i(40958),m=i(22573),p=i(38639),g=i(50357),y=i(43487),w=i(54017),v=i(90901);async function b(e){const t=(0,d.forceContextOrSetting)(e),i=e.assetId,r=(0,s.mkLogger)(`sync-file.UpdateAsset(${i})`);r.abortable=t.halt;const b=y.Asset.ops().findById(i);if(null==b)return r.throw("no such asset");const P=b.getAssetFiles({refresh:!0});if((0,f.isEmpty)(P))return r.warn("No asset files: deleting."),b.delete(),{asset:b,rejected:"Empty asset (no AssetFiles)"};const _=b.$clone(),T=b.getShown()?.$clone();for(const e of P)r.throwIfAborted_(),await e.upsertIfNeeded_(void 0,t);P.some((e=>(0,p.isTrue)(e.deleted)||(0,m.notBlank)(e.rejected)))&&b.clear(),await S(r,P);const M=(0,l.sortAssetFiles)(P),E=M?.[0];if((0,f.isEmpty)(M)||null==E)return r.warn("No existing files. Skipping for now."),b.markUnshownAndUpsert(),{asset:b,rejected:"Empty asset (no AssetFiles after sorting). Un-showing Asset:"+i};if(!E.isVersionUpToDate())return r.warn("Best file needs update, and we already tried to update all files. Skipping this asset.",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, could not be updated. Un-showing Asset:${i}`};const D=await E.capturedAt();if(null==D)return r.warn("Best file failed to extract a captured-at",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, failed to extract a captured-at. Un-showing Asset:${i}`};const x=new Set,[k,C]=await(0,u.partitionAsync)(M,(e=>(0,o.isSimilarAssetFile)(e,E)));if(r.throwIfAborted_(),(0,f.isNotEmpty)(C)){const e=await(0,a.aggregateAssetFiles)(C);for(const t of e){if((0,f.isEmpty)(t))continue;const e=y.Asset.ops().insertOne({capturedAtLocal:t[0].capturedAtLocal,shown:!1,version:0});x.add(e.id);for(const i of t)e.addAssetFile(i);w.AssetFile.dbl.runf((i=>i.update({assetId:e.id,shown:0}).whereIn("id",(0,f.compact)(t.map((e=>e.id)))))),r.info("Pushed rejected asset files into new asset",{rejectAssetId:e.id,rejectCluster:t.map((e=>({id:e.id,uri:e.uri})))})}}function F(e){return(0,f.uniq)(k.map((t=>t[e])))}const A=await Promise.all(k.map((e=>e.capturedAt()))),I=h.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,O=A.map((e=>e?.localBoundaries({delta:I}))),L=(0,c.min)(O.map((e=>e?.start)))??D.localBoundaries({delta:I})?.start,R=(0,c.max)(O.map((e=>e?.end)))??D.localBoundaries({delta:I})?.end,N=w.AssetFile.ops().all(w.AssetFile.query().limit(h.Settings.maxContemporaryAdoptionAssets.valueOrDefault).orderByRaw(`abs(AssetFile.capturedAtLocal - ${E.capturedAtLocal})`).select("AssetFile.*").distinct().join("Asset","Asset.id","AssetFile.assetId").where("AssetFile.assetId","!=",i).andWhere("Asset.version","!=",n.AssetVersion).andWhere((e=>(e=e.whereIn("AssetFile.sha",F("sha")),null==L||null==R?r.warn("external asset file check: unset start or end localtime boundary",{capturedAts:A,startBoundary:L,endBoundary:R}):e=e.orWhereBetween("AssetFile.capturedAtLocal",[L,R]),e.orWhereIn("AssetFile.meanHash",F("meanHash")).orWhereIn("AssetFile.diffHash",F("diffHash")).orWhereIn("AssetFile.dctHash",F("dctHash"))))));r.throwIfAborted_(),r.info("asset file candidates for adoption: ",N.map((e=>e.posixPathFromGrandparent)));const B=[];for(const e of N){r.throwIfAborted_();try{await e.updateFromFile_(),(0,o.isSimilarAssetFile)(e,E)&&(r.info("adopting similar asset file",{af:e}),x.add(e.assetId),e.shown=!1,b.addAssetFile(e),e.upsert(),B.push(e))}catch(t){r.warn("Error updating external asset file. Leaving asset file record as-is.",{af:e,error:t})}}r.info("fetched expansion",{retainAFs:k.map((e=>e.id)),rejectAFs:C.map((e=>e.id)),externalAssetFiles:N.map((e=>e.posixPathFromGrandparent)),similarAssetFiles:B.map((e=>e.posixPathFromGrandparent))}),await S(r,[...k,...B]),t.skipPreviews&&t.skipAssetTagging?(r.info("skipping previews and tagging",t),b.upsert()):await(0,v.assetPostUpsertTasks_)({...t,asset:b});const j=!(0,g.eql)(_,b),z=!(0,g.eql)(T,b.getShown()),V=!(j||z||t.forceRebuildPreviews||t.forceSync);return r.tap({msg:"updateAsset() result",level:"info",result:{asset:b,assetIdsToUpdate:Array.from(x),assetFiles:b.assetFiles,skipped:V},meta:{ctx:t,assetChanged:j,primaryAssetFileChanged:z}})}async function S(e,t){const[i,s]=(0,r.partition)(t,(e=>e.isVersionUpToDate()));for(const t of s){e.throwIfAborted_();const r=i.find((e=>e.sha===t.sha));if(null!=r){e.info("backfilling",{sibling:r,dest:t});const i=await t.updateFromShaSibling_(r);null!=i&&i.upsert()}}}t.updateAsset=async function(e){try{const t=await b(e);return{id:e.assetId,skipped:null==t?.asset,...t}}catch(t){return{id:e.assetId,error:t}}},t.updateAsset_=b},93755:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetFileIfNeeded=t.handleAssetFileUriChange=t.updateAssetFile_=t.updateAssetFile=void 0;const r=i(50213),s=i(92434),n=i(98314),a=i(74128),o=i(69589),l=i(87001),u=i(40958),c=i(22573),d=i(68708),h=i(43487),f=i(54017),m=i(94710);async function p(e){const t=Date.now(),i=e,s=e,n=s.af?.id??i.assetFileId,u=(0,r.mkLogger)(`updateAssetFile(${n})`),d=s.af??f.AssetFile.ops().findById(n);if(null==d)return u.throw("db record not found",{assetFileId:n});const h=await d.posixFile_(),p=(0,o.forceContextOrSetting)(e),w={id:n,assetFileId:n,path:h?.nativePath,uri:d?.uri};if(null==h)return{...w,error:"file for URI not found"};const v=await(h?.isDeletedUri(d.uri));if(null==v)return u.info("no-op: file URI points to an unmounted volume",w),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:"volume is not currently mounted",state:a.SyncFileStates.skipped}),{...w,skipped:!0};const b=e.whyReject??await d.whyRejected();if(v||!(0,c.blank)(b)){const e={...w,rejected:b,deleted:v};return u.warn("file was deleted or rejected. Deleting.",e),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:v?"file no longer exists":"rejected: "+b,state:a.SyncFileStates.deleted}),d.delete(),!0!==p.skipAssetRepair&&m.Task.addOne("repairAsset",{assetId:d.assetId}),e}const S=await h.uri_();if(!await(0,l.uriIsEquivalent)(S,d.uri)){const e=await g(d,S,p);if(null!=e)return{...w,...e}}return!p.forceSync&&await d.matchesFile()?(u.info("no-op: file already matches db record",w),d.touch(),{...w,skipped:!0}):{...w,...await y(d,p)}}async function g(e,t,i){const n=(0,r.mkLogger)(`handleAssetFileUriChange(${e.id})`),a=(0,u.uniq)([...(0,l.uriEncodingVariants)(e.uri),...(0,l.uriEncodingVariants)(t)]);n.warn("URI is changing. Avoiding duplicate keys.",{priorUri:e.uri,variants:a});const o=f.AssetFile.ops().allf((t=>t.whereIn("uri",a).andWhereNot({id:e.id})));if((0,u.isNotEmpty)(o)){n.warn("Found other AssetFiles with equivalent URIs.",{afIds:o.map((e=>e.id))});const t=[e,...o],r=(0,s.sortAssetFiles)(t);if((0,u.isEmpty)(r))return n.warn("sortAssetFiles returned undefined",{arr:t.map((e=>(0,d.pick)(e,"id","uri"))),variants:a}),{error:"sortAssetFiles returned undefined"};const l=t.map((e=>e.id));for(const e of r)if(await e.exists()){f.AssetFile.dbl.runf((t=>t.whereIn("id",l.filter((t=>t!==e.id))).delete()));const r=y(e,i);return h.Asset.dbl.runf((e=>e.update({version:0,updatedAt:Date.now()}).whereIn("id",(0,u.uniq)(t.map((e=>e.assetId)))))),r}}n.info("no-op, no duplicate URIs.")}async function y(e,t){const i=Date.now();return null!=await e.upsertIfNeeded_(void 0,t)&&h.Asset.touch([e.assetId]),(0,a.syncReport)().onProgress({path:await e.getNativePath(),elapsedMs:Date.now()-i,from:"updateAssetFileIfNeeded()",state:e.syncState??a.SyncFileStates.unknown}),{assetFileId:e.id}}t.updateAssetFile=async function(e){try{return await p(e)}catch(t){return{id:e.assetFileId,...e,error:(0,n.errorToS)(t)}}},t.updateAssetFile_=p,t.handleAssetFileUriChange=g,t.updateAssetFileIfNeeded=y},68640:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetPreviews_=void 0;const r=i(99331),s=i(38835),n=i(48604),a=i(50213),o=i(69589),l=i(87001),u=i(40958),c=i(45599),d=i(50357),h=i(31586),f=i(68708),m=i(59455),p=i(43487),g=(0,c.defer)((()=>(0,a.mkLogger)("sync-file.UpdateAssetPreviews")));t.updateAssetPreviews_=async function(e){const t=e.assetId??e.asset?.id??(0,m.toA)(e.assetFiles).find((e=>(0,h.gt0)(e.assetId)))?.assetId,i=(0,o.forceContextOrSetting)(e),a=g().addContext(".Asset:"+t);if(i.skipPreviews)return void a.warn("skipPreviews is true: no-op");if(!(0,h.gt0)(t))return a.throw("invalid assetId",{assetId:t});const c=e.asset??p.Asset.ops().findById(t);if(null==c)return a.throw("Asset:"+t+" not found");a.throwIfAborted_(i.halt);try{const e=await c.getExistingAssetFiles();if((0,u.isEmpty)(e))return void a.warn("no existing assetFiles",{asset:c});const r=n.Previews.instance().ap(t),o=await r.readInfo();a.throwIfAborted_(i.halt);const h=await(0,n.buildAssetPreviews_)({...i,assetId:t,assetFiles:e}),m=e.find((e=>e.id===h?.assetFileId))??e.find((e=>(0,l.uriIsEquivalent)(h?.uri,e.uri)));a.info("buildAssetPreviews_()",{result:h,primaryAssetFile:m});const p=await(m?.posixFile_());if(null==m||null==p||!0!==await(p?.exists()))return a.throw("buildAssetPreviews_() returned invalid assetFileId"+s.InternalErrorFlag,{newInfo:h,assetFiles:e.map((e=>(0,f.pick)(e,"id","uri"))),primaryAssetFile:m,primaryPosixFile:p});const g=(0,d.eql)(o,h),y=null==h||g;return{...h,noop:y}}catch(e){throw(0,r.ending)()||(a.warn("Failed to update previews. Un-showing asset "+t,{error:e}),c.markUnshownAndUpsert()),e}}},7656:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rebuildTagAssetCounts=t.DirectAssetCountForTagQuery=t.RecursiveAssetCountForTagQuery=t.nonLeafTagIds=void 0;const r=i(50213),s=i(56038),n=i(95704),a=i(38156),o=i(42659),l=i(45599),u=i(41400),c=i(31586),d=i(51926),h=(0,l.defer)((()=>(0,r.mkLogger)("tag.TagAssetCounts")));function f(e){return e.prepare((0,d.compressWhitespace)("SELECT"," t1.id,"," count(t2.id) AS cnt","FROM"," Tag t1"," JOIN Tag t2 ON t1.id = t2.parentId","GROUP BY"," 1","HAVING"," cnt > 0")).pluck().all()}async function m(e,i=[]){const r=e.prepare(t.RecursiveAssetCountForTagQuery).pluck(),o=e.prepare(t.DirectAssetCountForTagQuery).pluck(),l=e.prepare("UPDATE Tag SET assetCount = :assetCount, updatedAt = :updatedAt WHERE id = :tagId"),c=new Set(f(e)),d=new a.PushProgressObserver({op:"Rebuilding tag asset counts"},e.prepare("SELECT count(*) FROM Tag").pluck().get());await(0,n.withIdBatches)({db:e,tableName:"Tag",primaryKeyColumnName:"id",whereClauses:i,async fn(e){for(const t of e){const e=!c.has(t);(0,s.timeSync)("db.rebuildTagAssetCounts("+(e?"leaf":"cte")+")",(()=>{const s=(e?o:r).get({tagId:t});l.run({tagId:t,assetCount:s,updatedAt:Date.now()}),d.incrProgress(),h().debug("_rebuildTagAssetCounts()",{isLeaf:e,whereClauses:i,tagId:t,assetCount:s})})),t%10==0&&(h().throwIfAborted_(),await(0,u.delay)(1))}}}),d.completed()}t.nonLeafTagIds=f,t.RecursiveAssetCountForTagQuery=(0,d.compressWhitespace)("WITH RECURSIVE descendants(id) AS ("," VALUES (:tagId)"," UNION"," SELECT Tag.id"," FROM Tag, descendants"," WHERE Tag.parentId = descendants.id",")","SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," descendants"," JOIN AssetTag ON AssetTag.tagId = descendants.id"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL"),t.DirectAssetCountForTagQuery=(0,d.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," AssetTag"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," AssetTag.tagId = :tagId"," AND Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL;"),t.rebuildTagAssetCounts=async function(e,t=o.minuteMs){if(await(0,s.time)("db.rebuildNullTagAssetCounts",(()=>m(e,["assetCount IS NULL"]))),(0,c.gt0)(t)){const i=e.prepare("SELECT min(updatedAt) FROM Tag").pluck().get(),r=Date.now()-i;if(rm(e)))}},69032:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.displayNameForVolsha=t.fixFileRootTag=t.runTagMaintenance=t.forceRunTagMaintenance=t.tagFtsRebuild=void 0;const s=r(i(76760)),n=i(19851),a=i(50213),o=i(7282),l=i(409),u=i(1728),c=i(56038),d=i(34102),h=i(49076),f=i(69589),m=i(28874),p=i(42231),g=i(85087),y=i(98770),w=i(59107),v=i(63870),b=i(7014),S=i(22573),P=i(42659),_=i(41400),T=i(75240),M=i(31586),E=i(34666),D=i(51926),x=i(75020),k=i(54017),C=i(48723),F=i(98784),A=i(7656),I=(0,n.lazy)((()=>(0,a.mkLogger)("tag.TagSql")));t.tagFtsRebuild=(0,n.lazy)((()=>(0,c.time)("db.rebuildTagFts",(()=>F.TagFts.rebuild()))),10*P.minuteMs),t.forceRunTagMaintenance=async function(e={forceSync:!0,recountAllTags:!0}){return I().info("forceRunTagMaintenance()"),await t.runTagMaintenance.force(e)};const O=((0,o.isTest)()?5:30)*P.secondMs;t.runTagMaintenance=(0,l.rateLimited)({name:"runTagMaintenance",minCallDelayMs:O,f:async e=>{const i=(0,f.forceContextOrSetting)(e),r=Date.now(),s=I().addContext(".runTagMaintenance()");s.info("starting",{ctx:i});try{s.info("validating all tags..."),C.Tag.validate_(),s.throwIfAborted_(i?.halt),await L(),i.recountAllTags&&(s.info("rebuilding tag search index..."),await(0,t.tagFtsRebuild)(),s.info("rebuilding tag asset counts..."),await(0,A.rebuildTagAssetCounts)(C.Tag.dbl.db().db,0))}catch(e){I().warn("runTagMaintenance() failed",e)}const n=Date.now()-r,a=(0,M.clamp)(O,15*P.minuteMs,20*n);t.runTagMaintenance.setMinCallDelayMs(a),I().info("runTagMaintenance(): complete.",{newMinCallDelayMs:a,elapsedMs:n})}});const L=(0,y.lazyFsAsync)("updateTagMountpoints",(async()=>{I().info("updating tag mountpoints...");const e=C.Tag.findByPath([x.TagRoots.fs]);if(null!=e){e.maybeUpsertDisplayName(m.Settings.tagDisplayNameFS.valueOrDefault);for(const t of e.getChildren())await N(t)}else(0,a.mkLogger)("updateTagMountpoints()").info("No root filesystem tag (new db, I hope?)")}));function R(){t.tagFtsRebuild.unset(),L.unset()}async function N(e){if(null==e||2!==e.depth||!e._path.startsWith(x.TagRoots.fs+p.TagSep))return;const i=(0,a.mkLogger)("fixFileRootTag("+e+")");if(e.name===x.LibraryTagName)return void(1!==e.ordinal&&(i.info("fixing library ordinal",{id:e.id,path:e.path}),e.upsert({ordinal:1}),C.Tag.clear()));if((0,f.forceContextOrSetting)().forceSync&&(0,S.notBlank)(e.displayName)&&(0,E.gt)(e.updatedAt,Date.now()-(0,v.volumeMetadataTtlMs)()))return void i.info("no-op: tag recently updated",{id:e.id,path:e.path,updated:(0,T.fmtDuration)(Date.now()-e.updatedAt)+" ago"});const r=await(0,t.displayNameForVolsha)(e.name);(0,S.notBlank)(r)?(e.maybeUpsertDisplayName(r),i.info("updated tag",{id:e.id,path:e.path,displayName:r}),C.Tag.clear()):i.debug("cannot update tag: no current volume.",{id:e.id,path:e.path})}(0,_.later)((()=>{(0,d.ee)().on("clearCache",R),m.Settings.libraryDir.watchLater(R)})),t.fixFileRootTag=N,t.displayNameForVolsha=(0,u.memoizeAsync)((async e=>{const t=(0,a.mkLogger)("displayNameForVolsha("+e+")"),i=await(0,b.volumes)();if(null!=i){const r=i.find((t=>(0,g.volsha)(t.uuid)===e));return t.info("find()",{vol:r}),null!=r?m.Settings.tagDisplayNameFSLabels.valueOrDefault&&(0,S.notBlank)(r.label)?r.label.trim():"/"===r.mountpoint?m.Settings.tagDisplayNameFSRoot.valueOrDefault+(m.Settings.tagDisplayNameFSRootWithHostname.valueOrDefault?" on "+(0,h.hostname)():""):(0,S.notBlankOr)((0,D.stripPrefixSuffix)(r.mountpoint,{prefix:s.default.sep,suffix:s.default.sep}),s.default.sep):k.AssetFile.dbl.pluckFirstf((t=>t.select("mountpoint").whereLike("uri","psfile://"+e+"/%").limit(1)))}}),{name:"tag.displayNameForVolsha",maxSize:64,timeoutMs:(0,v.volumeMetadataTtlMs)()}),(0,_.later)((()=>{w.mountpoints.watch((()=>t.displayNameForVolsha.clear()))}))},90858:e=>{"use strict";e.exports=require("@iarna/toml")},53705:e=>{"use strict";e.exports=require("@photostructure/tz-lookup")},16436:e=>{"use strict";e.exports=require("@sentry/node")},64770:e=>{"use strict";e.exports=require("assert")},58587:e=>{"use strict";e.exports=require("batch-cluster")},87550:e=>{"use strict";e.exports=require("better-sqlite3")},6858:e=>{"use strict";e.exports=require("commander")},36507:e=>{"use strict";e.exports=require("croner")},66261:e=>{"use strict";e.exports=require("events")},77988:e=>{"use strict";e.exports=require("exiftool-vendored")},66150:e=>{"use strict";e.exports=require("fast-xml-parser")},68817:e=>{"use strict";e.exports=require("file-type")},44652:e=>{"use strict";e.exports=require("fs-extra")},28787:e=>{"use strict";e.exports=require("he")},31832:e=>{"use strict";e.exports=require("knex")},51168:e=>{"use strict";e.exports=require("luxon")},93973:e=>{"use strict";e.exports=require("ml-kmeans")},80265:e=>{"use strict";e.exports=require("moo")},31704:e=>{"use strict";e.exports=require("nearley")},4927:e=>{"use strict";e.exports=require("papaparse")},83058:e=>{"use strict";e.exports=require("picomatch")},57272:e=>{"use strict";e.exports=require("plist")},85949:e=>{"use strict";e.exports=require("process")},90595:e=>{"use strict";e.exports=require("punycode")},38064:e=>{"use strict";e.exports=require("semver")},9288:e=>{"use strict";e.exports=require("sharp")},49378:e=>{"use strict";e.exports=require("trash")},73872:e=>{"use strict";e.exports=require("type-detect")},92460:e=>{"use strict";e.exports=require("util")},75162:e=>{"use strict";e.exports=require("util/types")},29907:e=>{"use strict";e.exports=require("cluster")},76982:e=>{"use strict";e.exports=require("crypto")},31421:e=>{"use strict";e.exports=require("node:child_process")},77598:e=>{"use strict";e.exports=require("node:crypto")},40610:e=>{"use strict";e.exports=require("node:dns")},78474:e=>{"use strict";e.exports=require("node:events")},73024:e=>{"use strict";e.exports=require("node:fs")},51455:e=>{"use strict";e.exports=require("node:fs/promises")},37067:e=>{"use strict";e.exports=require("node:http")},44708:e=>{"use strict";e.exports=require("node:https")},77030:e=>{"use strict";e.exports=require("node:net")},48161:e=>{"use strict";e.exports=require("node:os")},76760:e=>{"use strict";e.exports=require("node:path")},53916:e=>{"use strict";e.exports=require("node:path/posix")},1708:e=>{"use strict";e.exports=require("node:process")},57075:e=>{"use strict";e.exports=require("node:stream")},46466:e=>{"use strict";e.exports=require("node:stream/promises")},87997:e=>{"use strict";e.exports=require("node:timers")},57975:e=>{"use strict";e.exports=require("node:util")},38522:e=>{"use strict";e.exports=require("node:zlib")},16928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=53493);module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{var __webpack_modules__={60308:e=>{const t={PasetoNotSupported:"ERR_PASETO_NOT_SUPPORTED",PasetoDecryptionFailed:"ERR_PASETO_DECRYPTION_FAILED",PasetoInvalid:"ERR_PASETO_INVALID",PasetoVerificationFailed:"ERR_PASETO_VERIFICATION_FAILED",PasetoClaimInvalid:"ERR_PASETO_CLAIM_INVALID"};class i extends Error{constructor(e){super(e),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}e.exports.PasetoError=i,e.exports.PasetoNotSupported=class extends i{},e.exports.PasetoDecryptionFailed=class extends i{},e.exports.PasetoInvalid=class extends i{},e.exports.PasetoVerificationFailed=class extends i{},e.exports.PasetoClaimInvalid=class extends i{}},78972:(e,t,i)=>{const{PasetoInvalid:r,PasetoNotSupported:s}=i(60308),{decode:n}=i(47859),a=i(40816);e.exports=(e,{parse:t=!0}={})=>{if("string"!=typeof e)throw new TypeError("token must be a string");const{0:i,1:o,2:l,3:u,length:c}=e.split(".");if(3!==c&&4!==c)throw new r("token is not a PASETO formatted value");if("v1"!==i&&"v2"!==i&&"v3"!==i&&"v4"!==i)throw new s("unsupported PASETO version");if("local"!==o&&"public"!==o)throw new s("unsupported PASETO purpose");const d={footer:u?n(u):void 0,payload:void 0,version:i,purpose:o};if("local"===o)return d;const h="v1"===i?256:"v3"===i?96:64;let f;try{f=n(l).subarray(0,-h)}catch{throw new r("token is not a PASETO formatted value")}return d.payload=t?a(f):f,d}},2744:(e,t,i)=>{const r=i(78972);e.exports={decode:r}},67814:(e,t,i)=>{const r=i(85223);e.exports=({audience:e,expiresIn:t,iat:i=!0,issuer:s,jti:n,kid:a,notBefore:o,now:l=new Date,subject:u},c)=>{if(!(l instanceof Date&&l.getTime()))throw new TypeError("options.now must be a valid Date object");const d=l.getTime();if(void 0!==i){if("boolean"!=typeof i)throw new TypeError("options.iat must be a boolean");i&&(c.iat=new Date(d))}if(void 0!==t){if("string"!=typeof t)throw new TypeError("options.expiresIn must be a string");c.exp=new Date(d+r(t))}if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.notBefore must be a string");c.nbf=new Date(d+r(o))}if(void 0!==e){if("string"!=typeof e)throw new TypeError("options.audience must be a string");c.aud=e}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.issuer must be a string");c.iss=s}if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.subject must be a string");c.sub=u}if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.kid must be a string");c.kid=a}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.jti must be a string");c.jti=n}return c}},10968:(e,t,i)=>{const{PasetoClaimInvalid:r}=i(60308),s=i(85223);e.exports=({ignoreExp:e,ignoreNbf:t,ignoreIat:i,maxTokenAge:n,subject:a,issuer:o,clockTolerance:l,audience:u,now:c=new Date},d)=>{if(!(c instanceof Date&&c.getTime()))throw new TypeError("options.now must be a valid Date object");const h=c.getTime();if("iss"in d&&"string"!=typeof d.iss)throw new r("payload.iss must be a string");if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.issuer must be a string");if(d.iss!==o)throw new r("issuer mismatch")}if("sub"in d&&"string"!=typeof d.sub)throw new r("payload.sub must be a string");if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.subject must be a string");if(d.sub!==a)throw new r("subject mismatch")}if("aud"in d&&"string"!=typeof d.aud)throw new r("payload.aud must be a string");if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.audience must be a string");if(d.aud!==u)throw new r("audience mismatch")}if(void 0!==l&&"string"!=typeof l)throw new TypeError("options.clockTolerance must be a string");const f=l?s(l):0;let m;if("iat"in d){if("string"!=typeof d.iat)throw new r("payload.iat must be a string");if(m=new Date(d.iat).getTime(),!m)throw new r("payload.iat must be a valid ISO8601 string");if(!i&&m>h+f)throw new r("token issued in the future")}if("nbf"in d){if("string"!=typeof d.nbf)throw new r("payload.nbf must be a string");const e=new Date(d.nbf).getTime();if(!e)throw new r("payload.nbf must be a valid ISO8601 string");if(!t&&e>h+f)throw new r("token is not active yet")}if("exp"in d){if("string"!=typeof d.exp)throw new r("payload.exp must be a string");const t=new Date(d.exp).getTime();if(!t)throw new r("payload.exp must be a valid ISO8601 string");if(!e&&t<=h-f)throw new r("token is expired")}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.maxTokenAge must be a string");if(!("iat"in d))throw new r("missing iat claim");if(m+s(n){e.exports.encode=e=>e.toString("base64url"),e.exports.decode=e=>Buffer.from(e,"base64")},80608:e=>{e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if("string"!=typeof e)throw new TypeError("options.assertion must be a string, or a Buffer");return Buffer.from(e,"utf8")}},83561:(e,t,i)=>{const r=i(65825);e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if(r(e))return Buffer.from(JSON.stringify(e),"utf8");if("string"!=typeof e)throw new TypeError("options.footer must be a string, Buffer, or a plain object");return Buffer.from(e,"utf8")}},1658:(e,t,i)=>{const r=i(67814),s=i(65825);e.exports=(e,t)=>{if(Buffer.isBuffer(e)){if(0!==Object.keys(t).length)throw new TypeError("options cannot contain claims when payload is a Buffer");return e}if(!s(e))throw new TypeError("payload must be a Buffer or a plain object");return e=(e=>JSON.parse(JSON.stringify(e)))(e),e=r(t,e),Buffer.from(JSON.stringify(e),"utf-8")}},82115:e=>{e.exports=e=>{const{x:t,y:i}=e.export({format:"jwk"}),r=Buffer.from(i,"base64"),s=2+(1&r[r.length-1]);return Buffer.concat([Buffer.alloc(1,s),Buffer.from(t,"base64")])}},88965:(e,t,i)=>{const r=i(64770),{PasetoInvalid:s}=i(60308),n=i(10968),{decode:a}=i(47859),o=i(40816);e.exports={post:function(e,t,i,r,s,a,l){if(t){if(0!==Object.keys(i).length)throw new TypeError("options cannot contain claims when options.buffer is true");return r?{payload:s,footer:a?.length?a:void 0,version:e,purpose:l}:s}const u=o(s);return n(i,u),r?{payload:u,footer:a?.length?a:void 0,version:e,purpose:l}:u},pre:function(e,t){if("string"!=typeof t)throw new TypeError("token must be a string, got: "+typeof t);if(t.slice(0,e.length)!==e)throw new s(`token is not a ${e.slice(0,e.length-1)} PASETO`);let{0:i,1:n="",length:o}=t.slice(e.length).split(".");try{r(o<=2),i=a(i),n=a(n)}catch{throw new s("token is not a PASETO formatted value")}return{raw:i,f:n}}}},56463:(e,t,i)=>{const r=i(76982),s=i(92460),n=i(70761),a=i(29534),{PasetoDecryptionFailed:o}=i(60308),l=i(82682),{webcrypto:{subtle:u}}=r,c=s.promisify(r.hkdf),d=Buffer.from("paseto-encryption-key"),h=Buffer.from("paseto-auth-key-for-aead"),f=Buffer.alloc(0),m=(e,t)=>r.createHmac("sha384",t).update(e).digest(),p=async(e,t,i,r)=>u[e]({name:"AES-CTR",counter:r,length:16},await u.importKey("raw",i,"AES-CTR",!1,[e]),t).then(Buffer.from),g=p.bind(void 0,"encrypt"),y=p.bind(void 0,"decrypt");e.exports={sign:s.promisify(r.sign),verify:s.promisify(r.verify),"v1.local-encrypt":async function(e,t,i){const s="v1.local.",o=m(e,r.randomBytes(32)).subarray(0,32),l=o.subarray(0,16),[u,f]=await Promise.all([c("sha384",i,l,d,32).then(Buffer.from),c("sha384",i,l,h,32).then(Buffer.from)]),p=await g(e,u,o.subarray(16)),y=n(s,o,p,t),w=m(y,f);return a(s,t,o,p,w)},"v1.local-decrypt":async function(e,t,i){const r=e.subarray(0,32),s=e.subarray(-48),a=e.subarray(32,-48),u=r.subarray(0,16),[f,p]=await Promise.all([c("sha384",i,u,d,32).then(Buffer.from),c("sha384",i,u,h,32).then(Buffer.from)]),g=n("v1.local.",r,a,t),w=m(g,p);if(!l(s,w))throw new o("decryption failed");const v=await y(a,f,r.subarray(16));if(!v)throw new o("decryption failed");return v},"v3.local-encrypt":async function(e,t,i,s){const o="v3.local.",l=r.randomBytes(32),[u,p]=await Promise.all([c("sha384",i,f,Buffer.concat([d,l]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,l]),48).then(Buffer.from)]),y=u.subarray(0,32),w=u.subarray(32),v=await g(e,y,w),b=n(o,l,v,t,s),S=m(b,p);return a(o,t,l,v,S)},"v3.local-decrypt":async function(e,t,i,r){const s=e.subarray(0,32),a=e.subarray(-48),u=e.subarray(32,-48),[p,g]=await Promise.all([c("sha384",i,f,Buffer.concat([d,s]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,s]),48).then(Buffer.from)]),w=p.subarray(0,32),v=p.subarray(32),b=n("v3.local.",s,u,t,r),S=m(b,g);if(!l(a,S))throw new o("decryption failed");const P=await y(u,w,v);if(!P)throw new o("decryption failed");return P}}},70981:(e,t,i)=>{const{KeyObject:r}=i(76982);let{isKeyObject:s}=i(75162);s||(s=e=>null!=e&&e instanceof r),e.exports=s},65825:e=>{e.exports=e=>!!e&&e.constructor===Object},41726:(e,t,i)=>{const{PasetoNotSupported:r}=i(60308);e.exports=e=>{if(!Number.isSafeInteger(e))throw new r("message is too long for Node.js to safely process");const t=~~(e/4294967295),i=e%4294967295-t,s=Buffer.allocUnsafe(8);return s.writeUInt32LE(t,4),s.writeUInt32LE(i,0),s}},85223:e=>{const t=36e5,i=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;e.exports=e=>{const r=i.exec(e);if(!r)throw new TypeError(`invalid time period format ("${e}")`);const s=parseFloat(r[1]);switch(r[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(1e3*s);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(6e4*s);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(s*t);case"day":case"days":case"d":return Math.round(864e5*s);case"week":case"weeks":case"w":return Math.round(6048e5*s);case"year":case"years":case"yr":case"yrs":case"y":return Math.round(315576e5*s)}}},29534:(e,t,i)=>{const{encode:r}=i(47859);e.exports=function(e,t,...i){let s=`${e}${r(Buffer.concat(i))}`;return t.byteLength&&(s+=`.${r(t)}`),s}},70761:(e,t,i)=>{const r=i(41726);e.exports=(...e)=>{e=e.filter(Boolean);let t=r(e.length);for(let i of e){i=Buffer.from(i,"utf8");const e=r(Buffer.byteLength(i));t=Buffer.concat([t,e,i])}return t}},40816:(e,t,i)=>{const{PasetoInvalid:r}=i(60308),{strict:s}=i(64770),n=i(65825);e.exports=e=>{try{const t=JSON.parse(e);return s(n(t)),t}catch{throw new r("All PASETO payloads MUST be a JSON object")}}},92366:(e,t,i)=>{const{sign:r}=i(56463),s=i(70761),n=i(29534);e.exports=async function(e,t,i,a,o,l,u){const c=s(u,e,t,i,l),d=await r(a,c,o);return n(e,i,t,d)}},495:(e,t,i)=>{const{createSecretKey:r}=i(76982),s=i(70981);e.exports=function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}`)&&(t=Buffer.from(t.slice(e.length),"base64url")),!s(t))try{t=r(t)}catch{}if(!s(t))throw new TypeError("invalid key provided");if("secret"!==t.type||32!==t.symmetricKeySize)throw new TypeError(`${e} secret key must be 32 bytes long symmetric key`);return t}},82682:(e,t,i)=>{const{timingSafeEqual:r}=i(76982),s=(e,t)=>{if(e.length===t)return e;const i=Buffer.alloc(t);return e.copy(i),i};e.exports=(e,t)=>{const i=Math.max(e.length,t.length);return r(s(e,i),s(t,i))}},49826:(e,t,i)=>{const{PasetoVerificationFailed:r}=i(60308),{verify:s}=i(56463),n=i(70761),{pre:a}=i(88965);e.exports=async function(e,t,i,o,l,u,c){const{raw:d,f:h}=a(e,t),f=d.subarray(0,-o),m=d.subarray(-o),p=n(c,e,f,h,u);if(!await s(i,p,l,m))throw new r("invalid signature");return{m:f,footer:h.length?h:void 0}}},91227:(e,t,i)=>{const r=i(60308),s=i(79665),n=i(56120),a=i(50015),o=i(64230),{decode:l}=i(2744);e.exports={decode:l,V1:s,V2:n,V3:a,V4:o,errors:r}},39324:(e,t,i)=>{const{"v1.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v1.local"),{pre:n,post:a}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:o=!1,...l}={}){const{raw:u,f:c}=n("v1.local.",e),d=(t=s(t)).export(),h=await r(u,c,d);return a("v1",o,l,i,h,c,"local")}},21472:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v1.local"),n=i(1658),{"v1.local-encrypt":a}=i(56463);e.exports=async function(e,t,{footer:i,...o}={}){const l=n(e,o);t=s(t);const u=r(i),c=t.export();return a(l,u,c)}},79665:(e,t,i)=>{const r=i(77868),s=i(77256),n=i(21472),a=i(39324),o=i(70866);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o}},70866:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=s(r.generateKeyPair),o=s(r.generateKey);e.exports=async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await o("aes",{length:256});return"paserk"===t?`k1.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await a("rsa",{modulusLength:2048});return"paserk"===t?{secretKey:`k1.secret.${e.export({format:"der",type:"pkcs1"}).toString("base64url")}`,publicKey:`k1.public.${i.export({format:"der",type:"pkcs1"}).toString("base64url")}`}:e}default:throw new n("unsupported v1 purpose")}}},77868:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPrivateKey:n}=i(76982),a=i(83561),o=i(1658),l=i(92366),u=i(70981);e.exports=async function(e,t,{footer:i,...c}={}){const d=o(e,c),h=a(i);return t=function(e){if("string"==typeof e&&e.startsWith("k1.secret."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!u(e))try{e=n(e)}catch{}if(!u(e))throw new TypeError("invalid key provided");if("private"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public signing key must be a private RSA key with 2048 bit modulus length");return e}(t),l("v1.public.",d,h,"sha384",{key:t,padding:r,saltLength:s})}},77256:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPublicKey:n}=i(76982),a=i(49826),o=i(70981),{post:l}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:u=!1,...c}={}){t=function(e){if("string"==typeof e&&e.startsWith("k1.public."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!o(e)||"private"===e.type)try{e=n(e)}catch{}if(!o(e))throw new TypeError("invalid key provided");if("public"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public verify key must be a public RSA key with 2048 bit modulus length");return e}(t);const{m:d,footer:h}=await a("v1.public.",e,"sha384",256,{key:t,padding:r,saltLength:s});return l("v1",u,c,i,d,h,"public")}},56120:(e,t,i)=>{const r=i(88451),s=i(859),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(62827);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},62827:(e,t,i)=>{const r=i(64770),s=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:a}=i(60308),o=i(70981),l=n(s.generateKeyPair);async function u(e,t,{format:i="keyobject"}={}){if("keyobject"!==i&&"paserk"!==i)throw new TypeError("invalid format");if("public"===t){const{privateKey:t,publicKey:r}=await l("ed25519");return"paserk"===i?{secretKey:`k${e.slice(1)}.secret.${h(t).toString("base64url")}`,publicKey:`k${e.slice(1)}.public.${h(r).toString("base64url")}`}:t}throw new a(`unsupported ${e} purpose`)}function c(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 64:{const t=s.createPrivateKey({key:Buffer.concat([Buffer.from("302e020100300506032b657004220420","hex"),e.subarray(0,32)]),format:"der",type:"pkcs8"});if(!e.subarray(32).equals(Buffer.from(t.export({format:"jwk"}).x,"base64")))throw new TypeError("invalid byte sequence");return t}case 32:return s.createPublicKey({key:Buffer.concat([Buffer.from("302a300506032b6570032100","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 64 bytes (private key), or 32 bytes (public key)")}}function d(e,t){if(!o(t))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public key must be an Ed25519 key`);switch(t.type){case"public":return Buffer.from(t.export({format:"jwk"}).x,"base64");case"private":{const{d:e,x:i}=t.export({format:"jwk"});return Buffer.concat([Buffer.from(e,"base64"),Buffer.from(i,"base64")])}}}function h(...e){return d("v2",...e)}e.exports={_checkPrivateKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.secret.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,64)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t))try{t=s.createPrivateKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("private"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public signing key must be a private ed25519 key`);return t},_checkPublicKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.public.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,32)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t)||"private"===t.type)try{t=s.createPublicKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("public"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public verify key must be a public ed25519 key`);return t},_generateKey:u,_keyObjectToBytes:d,bytesToKeyObject:c,generateKey:async function(...e){return u("v2",...e)},keyObjectToBytes:h}},88451:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(92366),{_checkPrivateKey:a}=i(62827),o=a.bind(void 0,"v2");e.exports=async function(e,t,{footer:i,...a}={}){const l=s(e,a);t=o(t);const u=r(i);return n("v2.public.",l,u,void 0,t)}},859:(e,t,i)=>{const r=i(49826),{_checkPublicKey:s}=i(62827),{post:n}=i(88965),a=s.bind(void 0,"v2");e.exports=async function(e,t,{complete:i=!1,buffer:s=!1,...o}={}){t=a(t);const{m:l,footer:u}=await r("v2.public.",e,void 0,64,t);return n("v2",s,o,i,l,u,"public")}},18582:(e,t,i)=>{const{"v3.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v3.local"),n=i(80608),{pre:a,post:o}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:l=!1,assertion:u,...c}={}){const{raw:d,f:h}=a("v3.local.",e);t=s(t);const f=n(u),m=t.export(),p=await r(d,h,m,f);return o("v3",l,c,i,p,h,"local")}},43406:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v3.local"),n=i(1658),a=i(80608),{"v3.local-encrypt":o}=i(56463);e.exports=async function(e,t,{footer:i,assertion:l,...u}={}){const c=n(e,u);t=s(t);const d=r(i),h=a(l),f=t.export();return o(c,d,f,h)}},50015:(e,t,i)=>{const r=i(42438),s=i(65466),n=i(43406),a=i(18582),{generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}=i(80568);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}},80568:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=i(70981),o=i(82115),l=s(r.generateKeyPair),u=s(r.generateKey);function c(e){if(!a(e))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public key must be an EC P-384 key");switch(e.type){case"public":return o(e);case"private":return Buffer.from(e.export({format:"jwk"}).d,"base64")}}e.exports={generateKey:async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await u("aes",{length:256});return"paserk"===t?`k3.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await l("ec",{namedCurve:"P-384"});return"paserk"===t?{secretKey:`k3.secret.${c(e).toString("base64url")}`,publicKey:`k3.public.${c(i).toString("base64url")}`}:e}default:throw new n("unsupported v3 purpose")}},bytesToKeyObject:function(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 48:return r.createPrivateKey({key:Buffer.concat([Buffer.from("303e0201010430","hex"),e,Buffer.from("a00706052b81040022","hex")]),format:"der",type:"sec1"});case 49:if(2!==e[0]&&3!==e[0])throw new TypeError("invalid compressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3046301006072a8648ce3d020106052b81040022033200","hex"),e]),format:"der",type:"spki"});case 97:if(4!==e[0])throw new TypeError("invalid uncompressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3076301006072a8648ce3d020106052b81040022036200","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 48 bytes (private key), 49 bytes (compressed public key), or 97 bytes (uncompressed public key)")}},keyObjectToBytes:c}},42438:(e,t,i)=>{const{createPrivateKey:r}=i(76982),s=i(83561),n=i(1658),a=i(80608),o=i(92366),l=i(70981),{bytesToKeyObject:u}=i(80568),c=i(82115);e.exports=async function(e,t,{footer:i,assertion:d,...h}={}){const f=n(e,h),m=s(i),p=a(d);return t=function(e){if("string"==typeof e&&e.startsWith("k3.secret."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,48)}catch{}if(Buffer.isBuffer(e))try{e=u(e)}catch{}if(!l(e))try{e=r(e)}catch{}if(!l(e))throw new TypeError("invalid key provided");if("private"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public signing key must be a private EC P-384 key");return e}(t),o("v3.public.",f,m,"sha384",{key:t,dsaEncoding:"ieee-p1363"},p,c(t))}},65466:(e,t,i)=>{const{createPublicKey:r}=i(76982),s=i(80608),n=i(49826),a=i(70981),{bytesToKeyObject:o}=i(80568),l=i(82115),{post:u}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:c=!1,assertion:d,...h}={}){t=function(e){if("string"==typeof e&&e.startsWith("k3.public."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,49)}catch{}if(Buffer.isBuffer(e))try{e=o(e)}catch{}if(!a(e)||"private"===e.type)try{e=r(e)}catch{}if(!a(e))throw new TypeError("invalid key provided");if("public"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public verify key must be a public EC P-384 key");return e}(t);const f=s(d),{m,footer:p}=await n("v3.public.",e,"sha384",96,{key:t,dsaEncoding:"ieee-p1363"},f,l(t));return u("v3",c,h,i,m,p,"public")}},64230:(e,t,i)=>{const r=i(29901),s=i(77933),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(24961);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},24961:(e,t,i)=>{const{_checkPrivateKey:r,_checkPublicKey:s,_generateKey:n,_keyObjectToBytes:a,bytesToKeyObject:o}=i(62827);e.exports={_checkPrivateKey:r,_checkPublicKey:s,bytesToKeyObject:o,generateKey:async function(...e){return n("v4",...e)},keyObjectToBytes:function(...e){return a("v4",...e)}}},29901:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(80608),a=i(92366),{_checkPrivateKey:o}=i(24961),l=o.bind(void 0,"v4");e.exports=async function(e,t,{footer:i,assertion:o,...u}={}){const c=s(e,u),d=n(o);t=l(t);const h=r(i);return a("v4.public.",c,h,void 0,t,d)}},77933:(e,t,i)=>{const r=i(80608),s=i(49826),{_checkPublicKey:n}=i(24961),{post:a}=i(88965),o=n.bind(void 0,"v4");e.exports=async function(e,t,{complete:i=!1,buffer:n=!1,assertion:l,...u}={}){t=o(t);const c=r(l),{m:d,footer:h}=await s("v4.public.",e,void 0,64,t,c);return a("v4",n,u,i,d,h,"public")}},37975:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),s=i(38639),n=i(44198);function a(){return(0,s.toNotBoolean)((0,n.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,n.env)().NO_COLOR)||["dumb","unknown"].includes((0,n.env)().TERM))}t.noColor=a;let o=!a();function l(){return o}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){o=e??!a()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),s=i(7282),n=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,s.isProd)()?"":`-${(0,s.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+n.version))},48884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),s=i(36783),n=i(76790),a=i(22573),o=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const s=new Set(t.map(i));return e.filter((e=>s.has(i(e))))}function w(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...w(e.slice(i+1))]}function v(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function b(e){return P(e,(e=>e.valueOf()))}function S(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function T(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,i){return E(e,t,i).index}function E(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let s,n=-1;for(let r=0;re.slice(i,i+t)))}async function x(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,o.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(a.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,o.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,s.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let s=0;for(const n of e)(t(n,s++)?i:r).push(n);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return w(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=v,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let s=0;se.slice(0,t+1)))},t.min=function(e){return e[b(e)]},t.leastIndex=b,t.max=function(e){return e[S(e)]},t.greatestIndex=S,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=T,t.least=function(e){return T(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const i=E(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=D,t.collectBatched=function(e,t,i){const s=[];for(const n of D((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(i(n)));return s},t.collectBatchedAsync=async function(e,t,i){const s=[];for(const n of D((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(await i(n)));return s},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await x(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+s;if(re+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const o=i(77988),l=a(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),w=i(25764),v=i(38836),b=i(99331),S=i(95937),P=i(98314),_=i(38835),T=i(70025),M=i(8769),E=i(43334),D=i(95402),x=i(28874),k=i(63870);class F extends v.EndableWrapper{constructor(e,t,i=w.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>n(this,r,"m",s).call(this)),i,"worker"===e?(0,k.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const a=t;a.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,D.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),a.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),a.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,S.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),a.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),a.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),a.on("noTaskData",((e,i,r)=>{const s=t.options.streamFlushMillis;s{this.logger.error("observeBatchCluster.endError()",e)})),a.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&D.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof o.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,b.ending)()||!0===(0,T.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=F,r=new WeakSet,s=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(E.isWin?3:1)*c.minuteMs,maxTasksPerProcess:x.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:x.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:x.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:x.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:x.Settings.taskTimeoutMs.valueOrDefault}}},71371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedGreatestSet=void 0;const r=i(92322);t.BoundedGreatestSet=class{constructor(e,t){this.maxLength=e,this.toValue=t,this.sortedArray=new r.SortedSet(t)}toA(){return this.vacuum(),this.sortedArray.toA()}vacuum(){return this.sortedArray.retainLastN(this.maxLength)}add(...e){this.maxLength<=0||(this.sortedArray.addAll(...e),this.sortedArray.length>=2*this.maxLength&&this.vacuum())}}},89788:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(r.add(this),this.maxLength=e,s.set(this,void 0),n.set(this,0),a.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,s,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]=t))}get length(){return u(this,n,"f")}set length(e){l(this,n,(0,d.clamp)(0,u(this,n,"f"),e),"f")}clear(){this.length=0}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,n,"f")),e<0||e>=u(this,n,"f")?void 0:t((e+u(this,a,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,s,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,n,"f"){u(this,s,"f")[e]=c}));return u(this,n,"f")}pop(){return u(this,r,"m",o).call(this,u(this,n,"f")-1,(e=>{var t;return l(this,n,(t=u(this,n,"f"),--t),"f"),u(this,s,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,n,"f"){u(this,s,"f")[e]=c,l(this,a,e,"f")}));return u(this,n,"f")}shift(){return u(this,r,"m",o).call(this,0,(e=>{var t,i;return l(this,a,(t=u(this,a,"f"),++t),"f"),l(this,n,(i=u(this,n,"f"),--i),"f"),u(this,s,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",o).call(this,u(this,n,"f")-1-e,(e=>{const i=u(this,s,"f")[e];u(this,s,"f")[e]=u(this,s,"f")[t],u(this,s,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),s=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function n(e){for(const{bom:t,encoding:i}of s)if(a(e,t))return e.subarray(t.length).toString(i);return e.toString()}function a(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=n,t.bufferToString=function(e){return Buffer.isBuffer(e)?n(e):(0,r.toS)(e)},t.bufferStartsWith=a},9092:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=s},36638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=s},40583:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const a=i(40958),o=i(23838),l=n(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new o.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,a.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,s=-1;for(const[i,n]of this.m.entries()){const a=(0,c.diceCoeff)(i,e);if(a>t&&a>s){const e=this.getFirst(n);null!=e&&(r=e,s=a)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),s=i(31586),n=i(68708),a=i(54993),o=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new o.Average(0);for(const t of this.keys()){if(!(0,s.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,a.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,s.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,n.tap)(new o.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,s]of this.m.entries()){const n=e(r);t.fill(n,i,i+s),i+=s}return t}}t.CountingSet=u},79840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),s=i(72993),n=i(45969),a=i(43334);t.EditionType=(0,r.lazy)((()=>a.isElectron?"Desktops":(0,n.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>s.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),s=i(55835),n=i(68708);var a=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return a.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,s.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.omit)(e,...i),(0,n.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,s.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),s=i(19851),n=i(95696);t.examples=(0,s.lazy)((()=>n.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),s=i(65843),n=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,s.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,n.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(31586),o=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,a.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,a.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,s.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,s.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,n.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,o.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,o.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,o.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,a.isNumber)(e.__uid)&&(0,a.isNumber)(e.__start)}},80049:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),s.set(this,0),n.set(this,0),a.set(this,0),o.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,s,l(this,s,"f")+e.cacheHitsAsync,"f"),u(this,n,l(this,n,"f")+e.cacheMisses,"f"),u(this,a,l(this,a,"f")+e.rejections,"f"),u(this,o,l(this,o,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,s,"f"),cacheMisses:l(this,n,"f"),rejections:l(this,a,"f"),timeouts:l(this,o,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,a,o;if(!this.cache.has(e))return void u(this,n,(t=l(this,n,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,s,(i=l(this,s,"f"),++i),"f"),c.promise):(u(this,r,(a=l(this,r,"f"),++a),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(o=l(this,r,"f"),++o),"f"),c}get(e){var t,i;const s=this.cache.get(e);return null==s||s instanceof m.Deferred&&s.isPending?u(this,n,(t=l(this,n,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),s instanceof m.Deferred?s.value:s}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,s,0,"f"),u(this,n,0,"f"),u(this,a,0,"f"),u(this,o,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,a,(t=l(this,a,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,o,(r=l(this,o,"f"),++r),"f")})),r.promise}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap},54127:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,a.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,s.range)(0,r).filter((e=>this.rows.every((t=>(0,n.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,o.fromEntries)(e))).filter((e=>(0,o.values)(e).some(n.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,o=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(o,r.index);(0,n.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),h=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:h});else{const e=(0,s.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,a.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}o=t.lastIndex}const l=(0,s.last)(i);return null!=l&&((0,n.blank)(this.headerRow.slice(o))?l.rightIdx=(0,a.max_)(...this.rows.map((e=>e.length))):l.rightIdx=o),i}}t.Fixed=m},73168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const r=i(55835),s=i(20014),n=i(55222),a=i(97352),o=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,a.within)(-90,90,e)&&0!==e}function c(e){return(0,a.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function h(e,t,i=o){return(0,r.map)(m(e,t,l(i)),(e=>n.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=o){return h(e?.lat,e?.lon,t)},t.geohash=h,t.geohashNumericShort=function(e,t){return m(e,t,30)};const f=new s.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=o){return d(e,t)?f.zip([t,e],l(i)):void 0}function p(e,t=o){return f.unzip(e,l(t))?.reverse()}function g(e,t=o){const[i,r]=p(e,t);return{lat:i,lon:r}}t.geohashNumeric=m,t.ungeohash=function(e,t=o){return(0,r.map)(n.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,r=t.lat*Math.PI/180,s=(t.lat-e.lat)*Math.PI/180,n=(t.lon-e.lon)*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(r)*Math.sin(n/2)*Math.sin(n/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},66364:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSuspended=void 0;const r=i(19851);t.isSuspended=(0,r.lazy)((()=>!1))},80875:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),s=i(98553);var n=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return n.parseJSON}}),t.mapParsed=function(e,t){const i=(0,s.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,s.parseJSON)((await(0,r.readFile)(e)).toString())}},57206:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDefaultJsonRevivers=void 0;const r=i(77988),s=i(51168),n=i(45599),a=i(98553),o=i(68708),l=i(24689),u=i(21330),c=i(57159),d=i(28544),h=(0,n.defer)((()=>{s.DateTime.prototype.toJSON=function(){return(0,o.compactValues)({_ctor:s.DateTime.name,ts:this.toMillis(),zone:"system"===this.zone?.type?void 0:this.zoneName})}})),f={name:s.DateTime.name,fromJSON:e=>s.DateTime.fromMillis(e.ts,(0,o.compactValues)({zone:e.zone}))};t.addDefaultJsonRevivers=(0,n.defer)((()=>{h(),(0,a.addJsonRevivers)(r.ExifDateTime,r.ExifDate,r.ExifTime,f,d.CapturedAt,l.DateInterval,u.FuzzyDate,r.BinaryField,c.WrappedError)}))},19851:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const a=i(57975),o=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&n(this,r,"m",s).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,o.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,o.mkLogger)("Locale")));function w(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=b(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>S(w()??await(m.isWin?P():m.isMac?T():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(w);const v=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function b(e){if((0,n.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=v.exec(e.trim())?.groups;return null==i?void 0:(0,s.compact)([i.lang,i.country]).join("-")}function S(e){return b(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=S,t.localeWin=P;const _={timeoutMs:10*a.secondMs};async function T(){return b(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return S(w((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=T,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),s=i(1708),n=i(45599),a=i(68708),o=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,n.defer)((()=>{(0,o.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:s.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,a.pick)(s.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:s.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),s=i(32105),n=i(14593);t.rootLoggers=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));const a=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));t.mkLogger=function(e){return new n.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new n.ContextualLogger(e,a)}},56639:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),s=i(55835),n=i(59455),a=i(48884);function o(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,a.concat)(...e.map((e=>t(e)))))},t.compactMap=o,t.toMap=function(e,t){return o((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:o(await Promise.all((0,r.compact)((0,n.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,s.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),s=i(54557);t.memoize=function(e,t){let i=0;const n=new s.FifoCache(t.maxSize,t.ttlMs),a=t=>{if(null!=t)return i++,n.getOrSet((0,r.stringify)(t),(()=>e(t)))};return a.clear=e=>null==e?n.clear():n.delete((0,r.stringify)(e)),a.size=()=>n.size,a.callCount=()=>i,a}},31578:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const r=i(1708),s=i(31586),n=i(12168),a=i(70417);function o(){const e=(0,r.memoryUsage)();return(0,a.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,r.memoryUsage)().rss}t.memoryUsageBytes=o,t.memoryUsageMb=function(){return(0,s.sigFigs)(o()/n.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,s.sigFigs)(l()/n.MB,2)}},7282:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const s=r(i(1708)),n=i(38639),a=i(54993),o=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,o.lazy)((()=>s.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,a.toS)(s.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return s.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,n.isTrue)(s.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){s.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55835),o=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,o.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(o.gt0)},t.firstNonZero=function(...e){for(const t of(0,n.flatten)(e)){const e=(0,o.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,a.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,o.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,o.toInt)(e),s=(0,o.toInt)(t);return null!=r&&r>0&&null!=s&&s>0?i(r,s):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,o.isNumber)(e))return e;if((0,s.blank)(e))return;const t=String(e);return(0,a.map)(f.exec(t),(e=>(0,o.toFloat)(t.substr(e.index))))}function p(e){return(0,o.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,a.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,a.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const s=i*e.length;for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),s=i(42659),n=i(96249),a=i(55835),o=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,s.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,s]of(0,l.entries)(e)){const e=t(r,s);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,a.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(a.defined)},t.firstDefinedField=function(e,...t){return(0,a.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,a.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const s of t)r[s]=i(s,e[s]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let s=0;for(const n of(0,l.keys)(e))if(r[n]=t(n,e[n]),s++,(0,o.gt)(s,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,n.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),s=i(73024),n=i(48161),a=i(19851),o=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),w=i(30933),v=(0,a.lazy)((()=>(0,f.mkLogger)("os")));function b(){return(0,n.platform)()+" "+(0,n.release)()}t.osArch=(0,a.lazy)((()=>`${function(){switch((0,n.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return F();case"win32":return C();default:return b()}}()} on ${(0,n.arch)()}`)),t.osFullName=(0,a.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const S=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function _(){return"ubuntu"===(0,t.osDistributionLinux)()}function T(){return"fedora"===(0,t.osDistributionLinux)()}function M(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,a.lazy)((()=>{if(g.isLinux)for(const e of S)try{const t=(0,s.readFileSync)(e).toString();if((0,o.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){v().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,a.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,o.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),b)})),t.osDistributionLinux=(0,a.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=_,t.hasApt=function(){return P()||_()},t.isFedora=T,t.isAlpine=M;const E={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},D={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function x(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),s=t[i];return(0,c.isString)(s)?s:s?.[r]}const k=(0,a.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function F(e=k()){try{return(0,o.mapNotBlankOr)(function(e=k()){return x(e,E)}(e),(t=>`macOS ${t} (${e})`),b)}catch(e){return v().warn("osNameMac(): unknown release",e),b()}}function C(e=(0,n.release)()){const t=e.startsWith("10.0.22")?"11":x(e,D);return null!=t?`Windows ${t} (${e})`:(v().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=F,t.osNameWin=C,t.CPUs=(0,a.lazy)((()=>(0,h.uniqCount)((0,w.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,a.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(C())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=k();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(_())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(T())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(M())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},45393:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetVersion=t.AssetFileVersion=void 0,t.AssetFileVersion=12,t.AssetVersion=4},12801:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const s=r(i(48161)),n=i(50989);t.PriorityClasses=(0,n.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:s.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:s.default.constants.priority.PRIORITY_NORMAL,BelowNormal:s.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:s.default.constants.priority.PRIORITY_LOW,Low:s.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setProcessTitle=t.setShortProcessNames=void 0;const r=i(72993),s=i(50213),n=i(23560),a=i(43334);let o=!a.isElectron;t.setShortProcessNames=function(e){o=e},t.setProcessTitle=function(){try{const e=[o?r.SimpleShortAppName:r.SimpleAppName];(0,n.isMainService)()&&a.isElectron||e.push((0,n.serviceName)());const t=e.join(a.isElectron?" ":"-");i(85949).title=t}catch(e){(0,s.mkLogger)("ServiceNames").warn("Failed to set friendly process name",e)}}},92782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeRandomUid=t.safeRandomChars=void 0;const r=i(55222),s=i(65713);t.safeRandomChars=function({radix:e=r.TokenRadix,length:t}){return(0,s.decuss)((()=>e.randomChars(t)))},t.safeRandomUid=function(e){return(0,s.decuss)((()=>(e?.radix??r.TokenRadix).randomUid(e?.chars??20,e?.splitEveryN??5,e?.sepChar??"-")))}},409:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),s=i(56409),n=i(31586),a=i(22911),o=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,v(...e)}}async function w(...r){f=!0,m=Date.now()+(0,n.max_)(t,i);const s=d=new a.Deferred(c);(0,n.gt0)(i)&&s.setTimeout(i);try{s.resolve(await e(...r))}catch(e){s.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,o.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return s.promise}const v=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,r.delay)(1).then((()=>t))}return w(...e)};return v.clear=()=>{h=void 0},v.donePromise=()=>{if(!f)return Promise.resolve();const e=new s.Latch;return p.push(e),e},v.force=async(...e)=>(h=void 0,f&&await v.donePromise(),w(...e)),v.isRateLimited=()=>g(),v.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),v.minCallDelayMs=()=>t,v.setMinCallDelayMs=e=>{t=e},v}},68852:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),s=i(54993);function n(e){return e instanceof a?e.source:(0,s.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let s;for(;null!=(s=e.exec(t));)s.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(s,"index","groups"));return i},t.escapeRegExp=n,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(n(t))}const s=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(s,i)};class a{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=a;class o extends a{static from(...e){const t=l(e);return new o("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,o=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof a||t instanceof RegExp?(i+=t.source,r||(r=t.global),o||(o=t.ignoreCase),l||(l=t.multiline)):i+=n((0,s.toS)(t));return new RegExp(i,t??(r?"g":"")+(o?"i":"")+(l?"m":""))}t.RegExpOptional=o,t.concatRegexp=l},79089:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),w=i(34102),v=i(43334),b=i(24399),S=i(28874),P=(0,a.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,w.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,a.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",n.default.basename(S.Settings.ffmpegPath.valueOrDefault)].map((e=>v.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,o.compactBlanks)([n.default.basename(e),...t.map((e=>n.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let T=!0;const M=(0,a.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const i=(0,p.priorityPosixToClass)(t)??S.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),T)try{return s.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;T=!1}try{return await(v.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await b.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const s=r(i(1708)),n=i(19851),a=i(40958),o=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===o.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===o.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===o.ServiceNames.sync}function p(){return(0,t.serviceName)()===o.ServiceNames.test}t.serviceName=(0,n.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,n.lazy)((()=>(0,a.compactBlanks)([t.serviceName.prior(),(0,l.toS)(s.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return o.ServiceNames.indexOf(e)??o.ServiceNames.length+1},t.MainServices=[o.ServiceNames.main,o.ServiceNames.desktop],t.DbServices=[o.ServiceNames.sync,o.ServiceNames.info,o.ServiceNames.web,o.ServiceNames.list,o.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[o.ServiceNames.sync,o.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===o.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===o.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,n.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function s(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=s,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=s(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=s(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),s=i(57150),n=i(7282),a=i(23560),o=i(17181);t.setServiceName=function(e){(0,a.isMainService)(e)&&(e=r.ServiceNames.main);const t=a.serviceName.prior();t!==e&&((0,n.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),a.serviceName.set(e),(0,o.setupLogger)(),(0,s.logStartup)())}},28850:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const o=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends o.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),s.set(this,void 0),n(this,r,e,"f")}_call(){return(0,l.time)(a(this,r,"f")+(null==a(this,s,"f")?"(local)":"(remote)"),null==a(this,s,"f")?this.impl():a(this,s,"f").call(this))}setShim(e){n(this,s,e,"f")}hasShim(){return null!=a(this,s,"f")}clearShim(){n(this,s,void 0,"f")}}r=new WeakMap,s=new WeakMap},12089:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,a){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=a,s.set(this,void 0),n.set(this,void 0),l(this,s,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",o).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",a).call(this,e),(()=>u(this,r,"m",o).call(this,e)))}setShim(e){l(this,n,e,"f")}hasShim(){return null!=u(this,n,"f")}clearShim(){l(this,n,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",a).call(this,e))}}s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},o=function(e){return(0,m.time)(u(this,s,"f")+(null==u(this,n,"f")?"(local)":"(remote)"),null==u(this,n,"f")?this.impl(e):u(this,n,"f").call(this,e))}},45255:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const n=i(76790),a=i(17586);class o{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return s(this,r,"f")[Symbol.iterator]()}get length(){return s(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=s(this,r,"f").length-1;for(;t<=i;){const n=t+Math.floor((i-t)/2),a=this.valueOf(s(this,r,"f")[n]);if(e===a)return{found:!0,index:n};e>a?t=n+1:i=n-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&s(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...s(this,r,"f")];const a=t=>t<0||t>s(this,r,"f").length-1?null:(i??this.diff)(s(this,r,"f")[t],e),o=this.findIndex(e);if(null==o)return;let l=o.index-1,u=a(l),c=o.index,d=a(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return s(this,r,"f").shift()}at(e){return(0,a.at)(s(this,r,"f"),e)}toA(){return[...s(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===s(this,r,"f").length-1){const e=[...s(this,r,"f")];return s(this,r,"f").length=0,e}return s(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return s(this,r,"f").splice(e,t)}retainLastN(e){return e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),s=i(82328),n=i(84542),a=i(95705),o=i(28874);t.consoleLog=function(e,...t){o.Settings.quiet.valueOrDefault||(0,s.stdoutEnded)()||console.log((0,n.crlf)(e),...t)},t.consoleError=function(e){o.Settings.quiet.valueOrDefault||(0,a.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=o.Settings.quiet.envValue;try{return o.Settings.quiet.envValue=!0,await e()}finally{o.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),s=i(95705);t.stdoutEnded=function(){return(0,s.streamEnded)(r.stdout)}},71567:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const s=r(i(1708)),n=i(22573),a=i(98553),o=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:s.default.stdout})}function f({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const s=(0,a.stringify)(e,void 0,(0,o.isInfoService)()||(0,o.isMainService)()?2:void 0);r.write(s+"\n"),(0,o.isWorkerService)()&&null!=i&&(s.includes(u.FailStr)||(0,c.isFatalError)(s)||(0,c.isHealthCheckError)(s)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||s.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:s.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,n.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const w=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const s=t.indexOf(i,r);return-1===s?0:1+e(t,i,s+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,n.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,o.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,h.toS)(e),s=(0,h.toS)(t);return s.length>0&&(0,c.equalsIgnoreCase)(r.slice(-s.length),s,i)?r.slice(0,-s.length):r},t.gist=function(e,t=80,i=80){const r=(0,h.toS)(e),s=r.length-(t+i);return s<=0?r:r.slice(0,t).trim()+" …(+"+s+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const v=/^[A-Z]/;function b(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function S(e){return(0,d.toA)(e).sort(b)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return v.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,n.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=b,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=S,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,a.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=b(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,n.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),s=t.indexOf(r);if(s>=0)return{index:s,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function T(e){return _.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=T;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,n.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(T(e))&&(e=e.slice(1,-1).trim())),e};const E=/^['‘’].*['‘’]$/,D=/^["“”„«»〃].*["“”„«»〃]$/;function x(e,t){const i=k(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function k(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let s,n=0;for(;null!=(s=t.exec(e));)s.index===t.lastIndex?t.lastIndex++:(t.lastIndex=s[0].length+s.index,i.push(e.substring(n,s.index)),r.push(e.substring(s.index,t.lastIndex)),n=t.lastIndex);return n(0,o.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),E.test(e)||D.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>w.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),s=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,a.map)(i[e],(e=>t+=e))));return t},t.splitKeep=x,t.splitUp=k,t.sortNaturalBy=F,t.sortNatural=function(e){return(0,s.sortBy)(e,(e=>F(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=S((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,s.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,n.blank)(e)||(0,n.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,o.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const C=/#.*$/gm;t.stripComments=function(e){return e.replace(C,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,n.blank)(r))for(const e of r.split(t))(0,n.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,n.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),s=e.findIndex((e=>r.test(e))),a=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(s<0)return e;for(let t=s+1;te.trim()))))}},83556:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function s(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=s,t.asObjectKey=function(e){return s(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const s=r(i(77598)),n=i(73913),a=i(55222);function o(e,t=n.HashBits){return s.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=a.Radix58,r=224){return i.encodeBuffer(o(e,r)).substring(0,t)}t.stringShaToBuffer=o,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=a.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(31586),o=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,s="";for(let n=0;n=r&&(r=i.get(n,a),s=(0,l.substr)(e,n-r+1,r)));return s}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),s=t.normalize();return e!==r||t!==s?y(r,s):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function w(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===r?1:void 0),(()=>(0,n.blank)(e)!==(0,n.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=v(i),t=v(r);return 2*b(e,t).length/(e.length+t.length)}))}function v(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function b(e,t){const i=(0,f.intersection)(e,t),s=[];return i.forEach((i=>{const n=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,a.times)(n,(()=>s.push(i)))})),s}function S(e,t,i){const s=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,s))-i((0,l.strslice)(t,s))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,s.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[i,r]=[e,t].map(P).map((e=>(0,n.blank)(e)?"":e));return S(i,r,(e=>(0,a.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(n.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=w,t.bigrams=v,t.nonUniqIntersection=b,t.lnsDiff=_;const T=/[^\da-z]+/gi;function M(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(T,"").toLowerCase()));return S(i,r,(e=>c.RadixAlphaNum.decode(e)))}function E(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const s=(0,a.mapNumericOr)(e.charCodeAt(r),(e=>e),256),n=(0,a.mapNumericOr)(t.charCodeAt(r),(e=>e),256),o=(0,a.clamp)(-256,256,s-n);i=null==i?o:(i+o)/2}return i}t.radixDiff=M,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:w(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=E,t.paddedPositionalDiff=function(e,t,i=8){return E((0,o.leftPad)(e,i," "),(0,o.leftPad)(t,i," "))}},84885:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),s=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,s.sortedKeys)(e))}},75387:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",s.set(this,[]),n.set(this,new Map),a.set(this,void 0),o.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,a,"f")}set ttlMs(e){h(this,a,e,"f"),null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),h(this,o,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,n,"f").clear(),this}delete(e){return d(this,n,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,n,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,n,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,n,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const s=t();return null!=s&&this.set(e,s),s}lastSetOrGetTs(e){return d(this,n,"f").get(e)?.ts}set(e,t){return d(this,n,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,n,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,n,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,f.sortBy)(d(this,n,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,s,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,n,"f").delete(e);for(const i of d(this,s,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,n,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[a]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return o(this,r,"m",n).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>o(this,r,"m",n).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||o(this,r,"m",s).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)o(this,r,"m",s).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!o(this,r,"m",s).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield[t,t])}()}toA(){return o(this,r,"m",n).call(this),[...this.delegate.keys()]}[(r=new WeakSet,a=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,s=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},n=function(){for(const[e,t]of this.delegate)o(this,r,"m",s).call(this,e,t)}},84699:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},65211:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resetUid=t.sortByUid=t.tsFromUid=t.isUID=t.uidForTs=t.uid=t.uidSuffix=void 0;const r=i(19851),s=i(76790),n=i(22573),a=i(54993),o=i(7282),l=i(55222);let u=0;const c=l.GeoRadix;function d(e){return c.encode(e)+(0,t.uidSuffix)()}t.uidSuffix=(0,r.lazy)((()=>"-"+c.randomChars(7))),t.uid=function(){return u=Math.max(Date.now(),u+1),d(u)},t.uidForTs=d;const h=/^[\da-z]{9}-[\da-z]{7}$/i;function f(e){const t=(0,a.toS)(e).replace(/(?<=\S)-.*/,"");return(0,n.blank)(t)?void 0:c.decode(t)}t.isUID=function(e){return h.test((0,a.toS)(e))},t.tsFromUid=f,t.sortByUid=function(e){return(0,s.sortBy)(e,(e=>f(e.uid)))},t.resetUid=function(){if(!(0,o.isTest)())throw new Error("unsupported");t.uidSuffix.unset(),u=0}},94174:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,a.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,a.lazy)((()=>(0,o.uniq)([n.default.geteuid?.(),n.default.getuid?.(),s.default.userInfo().uid]))),t.userid=(0,a.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,a.lazy)((()=>(0,o.uniq)([n.default.getegid?.(),n.default.getgid?.(),s.default.userInfo().gid]))),t.groupid=(0,a.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,a.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,a.lazy)((()=>(0,l.toNotBlank)(s.default.userInfo()?.username))),t.userNameFromWhoami=(0,a.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,a.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,a.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,a.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.1-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=1,t.versionPrerelease=["prealpha"],t.release="2024.3.1-prealpha+20240308150212",t.gitSha="d92384e8659ff46fbae8e6f81fa5867114a4a843",t.gitDate=new Date(1709938932e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48299:function(e,t){"use strict";var i,r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.WeakCache=void 0;class o{constructor(){i.add(this),this[n]="WeakCache",r.set(this,new Map)}clear(){return a(this,r,"f").clear(),this}delete(e){return a(this,r,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of this.entries())e(i,t,this)}findEntry(e){for(const[t,i]of this.entries())if(e(i,t,this))return i}deleteValueIf(e){for(const[t,i]of this.entries())e(i,t,this)&&a(this,r,"f").delete(t)}get(e){const t=a(this,r,"f").get(e),i=t?.deref();return null==i&&null!=t&&a(this,r,"f").delete(e),i}getOrMaybeSet(e,t){const i=a(this,r,"f").get(e)?.deref();if(null!=i)return i;const s=t();return null!=s&&this.set(e,s),s}set(e,t){return a(this,r,"f").set(e,new WeakRef(t)),this}has(e){return null!=a(this,r,"f").get(e)?.deref()}get size(){return a(this,i,"m",s).call(this),a(this,r,"f").size}keys(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries())null==i.deref()?a(e,r,"f").delete(t):yield t}()}values(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield s}}()}entries(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield[t,s]}}()}[(r=new WeakMap,i=new WeakSet,n=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}}t.WeakCache=o,s=function(){for(const[e,t]of a(this,r,"f").entries())null==t.deref()&&a(this,r,"f").delete(e)}},48963:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),s=i(55835),n=i(31586),a=i(97790),o=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,n.toInt)(e)));if(!(0,s.allDefined)(i))return;const[a,o,u,c,d,h,f]=i,m=(0,n.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(a,o-1,u,c,d,h,f/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,a.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(n.toInt).filter((e=>(0,o.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},79184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aggregateAssetFiles=void 0;const r=i(59455),s=i(48884),n=i(22859),a=i(28874),o=i(79781),l=i(92434);t.aggregateAssetFiles=async function(e){const t=(0,r.toA)((0,l.sortAssetFiles)(e)??e);return(a.Settings.assetAggregation.valueOrDefault===n.AggregateTypes.union?s.clusterSome:s.clusterEvery)(t,o.isSimilarAssetFile)}},79781:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotSimilarAssetFile=t.isSimilarAssetFile=t.whyNotSameAsset=t.VideoImageMismatchMsg=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(50357),o=i(55835),l=i(31586),u=i(68708),c=i(12168),d=i(23467),h=i(73168),f=i(50213),m=i(86580),p=i(48368),g=i(80361),y=i(28874),w=i(28544),v=i(75767),b=i(16170),S=(0,r.lazy)((()=>(0,f.mkLogger)("sync-file.AssetFileComparator")));function P(e,t,i,r=((e,t)=>[e,t])){const s=e[i],o=t[i];if((0,n.blank)(s)||(0,n.blank)(o)||(0,a.eql)(s,o))return;const[l,u]=r(s,o);return(0,a.eql)(l,u)||(0,a.eql)(s,u)||(0,a.eql)(l,o)?void 0:`Different ${String(i)}: ${s} ≠ ${o}`}function _(e){return(0,n.mapNotBlank)(e,(e=>e.toLowerCase().trim().normalize()))}function T(e,t){return[_(e),_(t)]}function M(e,t,i){const r=(0,v.findInequalFields)(e[i],t[i]);return null==r?void 0:`Different ${i} (${r.aKey}:${r.aValue} ≠ ${r.aKey}:${r.aValue})`}function E(e,i){if(!(0,u.allKeysDefined)(e,"width","height","mimetype","sha"))return"af1 was missing required fields";if(!(0,u.allKeysDefined)(i,"width","height","mimetype","sha"))return"af2 was missing required fields";if((0,d.definedAndEql)(e.sha,i.sha))return void S().debug("matching SHA",{af1:e,af2:i});const r=(0,b.isVideoMimeType)(e.mimetype),n=(0,b.isVideoMimeType)(i.mimetype);if(r!==n)return S().tap({msg:"whyNotIsSimilar",result:t.VideoImageMismatchMsg,meta:{af1:e.uri,af2:i.uri,af1IsVideo:r,af2IsVideo:n}});const a=w.CapturedAt.fromAssetFile(e),f=w.CapturedAt.fromAssetFile(i);if(null==a)return"af1 missing capturedAt metadata";if(null==f)return"af2 missing capturedAt metadata";const _=a.isFuzzy||f.isFuzzy;if(_&&y.Settings.allowFuzzyDateImageHashMatches.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if((0,g.isSimilarImageHash)(t,r,{rotationsToCheck:(0,m.validRotations)(e,i)}))return void S().info("allowFuzzyDateImageHashMatches mode: image hashes match",{af1:e,af2:i})}if(!a.overlaps(f))return`captured-at ${a.toISOStringWithPrecision()} != ${f.toISOStringWithPrecision()}`;const E=P(e,i,"make",T)??P(e,i,"model",T);if(null!=E)return E;const D=(0,o.map)((0,h.geohashDistanceMeters)(e.geohash,i.geohash),(e=>(0,l.sigFigs)(e,2))),x={cameraId:M(e,i,"cameraId")??null,imageId:M(e,i,"imageId")??null,lensId:M(e,i,"lensId")??null,exposureSettings:(0,v.whyExposureSettingsNotSimilar)(e,i)??null,closeGeoHash:(0,l.gt)(D,y.Settings.gpsErrorMeters.valueOrDefault)?"geohashes are "+(0,c.fmt)(D)+"m different: too far apart":null};S().debug("whyNotSimilar()",{fields:x});const k=(0,s.compact)((0,u.values)(x));if((0,s.isNotEmpty)(k))return k.join(";");if(y.Settings.useImageHashes.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if(null!=t&&null!=r){const e=(0,g.compareImageHashes)(t,r,{capturedAtIsFuzzy:_});return!0===e?.isSimilar?void 0:e?.whyNotSimilar}}return(0,u.keys)(x).filter((e=>null==x[e])).length>=y.Settings.minMatchesWithoutImageHashes.valueOrDefault?void 0:"Insufficient metadata correlation"}t.VideoImageMismatchMsg="Videos ≠ images",t.whyNotSameAsset=function(e,t,i){{const i=E(e,t);if(null!=i)return i}if("intersection"===y.Settings.assetAggregation.valueOrDefault)for(const r of i)if(r.id!==t?.id){const t=E(e,r);if(null!=t)return t}},t.isSimilarAssetFile=function(e,t){return null==E(e,t)},t.whyNotSimilarAssetFile=E},13991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkSortableAssetFile_=t.mkAssetFile_=t.assetFileMetadata_=t.assetFileImageHashFields_=t.imageHashToAssetFileImageHashFields=t.assetFileStatFields_=t.assetFileUriFields_=void 0;const r=i(19851),s=i(55835),n=i(31586),a=i(59455),o=i(73168),l=i(50213),u=i(12089),c=i(76490),d=i(95696),h=i(48368),f=i(70417),m=i(28874),p=i(43207),g=i(47783),y=(0,r.lazy)((()=>(0,l.mkLogger)("asset-file.AssetFileFactory")));async function w(e){try{return{nativePath:e.nativePath,uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath}}catch(t){return y().throw("Failed to build URI for "+e,{error:t})}}async function v(e){const t=await e.stat_(),i=await e.sidecareStats();return{mtime:Math.floor((0,f.max)([t.mtimeMs,...(0,a.toA)(i).map((e=>e.mtimeMs))])),fileSize:t.size}}function b(e){return{...e,...c.DominantColor.toModeData(e.dominantColors)}}async function S(e){if(!m.Settings.useImageHashes.valueOrDefault)return;const t=await(0,h.imageHash_)(e.nativePath);return null==t?y().throw("Failed to extract image hash for "+e):b(t)}async function P(e){const[i,r,s,n]=await Promise.all([w(e),v(e),(0,t.assetFileMetadata_)(e),e.sha_()]);return{...i,...r,...s,sha:n}}t.assetFileUriFields_=w,t.assetFileStatFields_=v,t.imageHashToAssetFileImageHashFields=b,t.assetFileImageHashFields_=S,t.assetFileMetadata_=(0,u.shim1)({name:"asset-file.assetFileMetadata",impl:async function(e){try{const t=d.PosixFile.for(e),i=await(0,g.readTags)(t);if(null==i)throw new Error("Failed to read tags");if(null==i.capturedAt)throw new Error("Failed to read capturedAt");const r=i.capturedAt.toAssetFileFields();return null==r?y().throw("Failed to render assetFileFields from capturedAt",{capturedAt:i.capturedAt}):{...r,...i.exposureSettings,...i.dimensions,mimetype:i.mimetype,rotation:i.rotation,make:i.Make,model:i.Model,rating:i.rating,cameraId:i.cameraId,imageId:i.imageId,lensId:i.lensId,geohash:(0,o.geohashNumericShort)(i.GPSLatitude,i.GPSLongitude),durationMs:(0,p.extractDurationMs)(i),fps:(0,s.map)((0,n.toFloat)(i.VideoFrameRate),Math.floor)}}catch(t){return y().throw("_assetFileMetadata_() failed",{nativePath:e,error:t})}}}),t.mkAssetFile_=async function(e){const[t,i]=await Promise.all([P(e),S(e)]);return{...t,...i}},t.mkSortableAssetFile_=P},92434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestExistingAssetFile=t.assetFileSortCriteria=t.assetFileSortFields=t.assetFileSortCriteriaPojo=t.sortAssetFiles=t.mtime2sort=t.sortScale=t.dim2sort=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(23838),u=i(31586),c=i(68708),d=i(34666),h=i(50989),f=i(89937),m=i(50213),p=i(4001),g=i(29882),y=i(28874),w=i(14036),v=i(45200),b=i(34238),S=(0,r.lazy)((()=>(0,m.mkLogger)("img.AssetFileSorter"))),P=(0,h.strEnum)("file",f.PS_NETWORK_FILESYSTEM_SCHEME,f.PS_LOCAL_FILE_SCHEME,f.PS_LIBRARY_SCHEME);function _(e){return(0,u.map2Numeric)(e?.width,e?.height,((e,t)=>T(e*t)))}function T(e){if((0,u.gt0)(e))return Math.round(Math.pow(e,y.Settings.variantSortCriteriaPower.valueOrDefault))}function M(e){return Math.round(e/(5*o.minuteMs))}t.dim2sort=_,t.sortScale=T,t.mtime2sort=M;const E=["make","model","rating","cameraId","imageId","lensId","geohash"];function D(e){for(const t of(0,l.groupBy)(e,(e=>e.sha)).values())if(t.length>1){const e=Math.max(...(0,s.compact)(t.map((e=>e.mtime))));for(const i of t)i.mtime=e}return(0,n.sortBy)(e,F).reverse()}function x(e){const t=b.URI.parse(e.uri);if((0,a.blank)(t?.scheme)||(0,a.blank)(t?.path))return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI)",{uri_scheme:t?.scheme,uri_path:t?.path,af:e,parsedURI:t});const i=_(e);if(null==i)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid resolution)",{resolution:i,af:e,parsedURI:t});const r=P.indexOf(t.scheme);if(null==r)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI scheme)",{uri_scheme:t.scheme,af:e,parsedURI:t});const s=e.mtime??0,n=(0,g.parsePosixPath)(t.path),l=[];for(const t of E)(0,a.blank)(e[t])||l.push(t);const u={resolution:i,schemeIdx:r,capturedAtPrecision:-(e.capturedAtPrecisionMs??o.weekMs),metadataCoverage:l.length,metadataFields:l.join(","),isBrowserSupported:(0,w.isSupportedByCurrentBrowserExt)(n.ext),mtime:M(s),isEditOrUpdate:/edit|update/i.test(n.base),isCover:/cover/i.test(n.base),count:Math.abs((0,p.copySuffixCountFromName)(n.name)??0),basename:d.CmpReverseFlag+n.base,parentBasename:d.CmpReverseFlag+(0,g.parentBasename)(e.nativePath??t.path),uri:d.CmpReverseFlag+e.uri};return S().tap({msg:"assetFileSortCriteriaPojo()",result:(0,c.toReqValued)(u)})}function k(){return(0,s.uniq)([...y.Settings.variantSortCriteria.values,"uri"])}function F(e){const t=x(e);if(null==t)return;const i=[];for(const e of k())i.push(t[e]);return i}t.sortAssetFiles=D,t.assetFileSortCriteriaPojo=x,t.assetFileSortFields=k,t.assetFileSortCriteria=F,t.bestExistingAssetFile=async function(e){for(const t of D(e))if(await(0,v.uriExists)(t.uri,t.nativePath))return S().tap({msg:"bestExistingAssetFile()",result:t,meta:{files:e.map((e=>e.uri))}});return S().tap({msg:"bestExistingAssetFile(): no existing uris",result:void 0,meta:{files:e.map((e=>e.uri))}})}},54296:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetFileNativePath=void 0;const r=i(45200);t.getAssetFileNativePath=async function(e){return e.nativePath??(e.nativePath=await(0,r.uri2nativePath)(e.uri,e.mountpoint))}},73568:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const o=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),s.set(this,(0,o.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,n(this,s,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return n(this,s,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,n(this,s,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),a(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=n(this,r,"f")&&clearTimeout(n(this,r,"f")),a(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,s=new WeakMap},69591:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const s=r(i(87997)),n=i(31586);t.debounce=function(e,t){let i,r=[];const a=(0,n.gt0)(t)?(...n)=>{r=n,null!=i&&s.default.clearTimeout(i),i=s.default.setTimeout((()=>{e(...r)}),t)}:e;return a.reset=()=>{null!=i&&s.default.clearTimeout(i),i=void 0},a.force=()=>{a.reset(),e()},a.setTimeoutMs=e=>{a.reset(),t=e},a.timeoutMs=()=>t,a}},22911:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const w=y(i(87997)),v=y(i(57975)),b=i(45599),S=i(26905),P=i(55835),_=i(31586),T=i(68708),M=i(20214),E=i(57153),D=i(85556),x=i(50213),k=i(70025),F=i(95937),C="TIMEOUT",A=(0,b.defer)((()=>(0,x.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,_.gt0)(t)?new s(C).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const s=i[r];if(s.isSettled){if(s.name===C)return void A().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield s.value}}if(i.every((e=>e.name===C)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new s(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),a.set(this,void 0),o.set(this,E.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=s,s,(y=p(i,s,"f",n),m=y++,y),"f",n),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,x.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof s&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,o,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,T.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,a,"f")}get elapsedMs(){return(p(this,a,"f")??Date.now())-this.startedAt}get[(a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[v.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(w.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,w.default.setTimeout((()=>{this.isPending&&(this.reject(new D.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,F.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,o,"f")===E.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,o,"f")!==E.PromiseStates.pending}get isResolved(){return p(this,o,"f")===E.PromiseStates.resolved}get isRejected(){return p(this,o,"f")===E.PromiseStates.rejected}get settledMs(){return null==p(this,a,"f")?void 0:p(this,a,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,o,E.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,k.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,S.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,o,E.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,s=I,m=function(e){if(p(this,o,"f")===E.PromiseStates.pending){(0,P.map)(p(this,h,"f"),w.default.clearTimeout),e(),g(this,a,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},n={value:0}},27395:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(23838),o=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new a.MultiMap;(0,m.setUnrefInterval)((()=>v()),10*n.minuteMs);const y=5*n.secondMs;async function w(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,o.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function v(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>w(e))))},t.end=w,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),v();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,s.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>w(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,s.compact)(g.valuesFlat()).map((e=>w(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class w extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",a).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,s.set(this,void 0),n.set(this,void 0),o.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,s,"f")}hasTimeout(){return null!=u(this,n,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",a).call(this);const h=()=>{u(this,r,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,s,(0,d.setInterval)(u(this,o,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,n,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,o,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref()):h(),!0}}t.EndableInterval=w,s=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(){(0,h.map)(u(this,s,"f"),d.clearInterval),c(this,s,void 0,"f"),(0,h.map)(u(this,n,"f"),d.clearTimeout),c(this,n,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const o=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,a){this.endTimeoutMs=a,r.set(this,void 0),this.onEnds=[],s.set(this,(0,o.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),n(this,s,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){a(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return n(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return n(this,s,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,s=new WeakMap},99331:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let s=!1;t.ending=function(){return s},t.setEnding=function(e){s=(0,r.isTest)()?e:e||s}},45608:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const s=r(i(1708)),n=i(22573),a=i(45599),o=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,a.defer)((()=>(0,l.mkLogger)((0,o.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,a.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function w(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,n.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,f.endEndables)(),s.default.exit(e.status))}t.exit=w,t.exitOnStdStream=(0,a.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])s.default[e].on(t,(i=>{w({reason:`${e}:${t}`,status:0,error:i})}))}))},39250:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LastOneInWins=void 0;const n=i(23838),a=i(54993),o=i(15674),l=i(73568),u=i(76740),c=i(99331),d=i(42638);t.LastOneInWins=class{constructor(e,t=o.maxCpus){this.name=e,this.maxConcurrency=t,r.set(this,new n.MultiMap),this.p=new d.Promises(e,t)}vacuum(){return s(this,r,"f").filterInPlace(((e,t)=>t.isPending&&!0!==t.payload?.aborted)),s(this,r,"f").valueCount()}enqueue({key:e,abortable:t,fn:i}){for(const t of s(this,r,"f").get(e)??[])t.payload?.abort("aborted by new work");if(this.vacuum(),(0,c.ending)())throw new l.AbortError("ending");const n=t??new u.Abortable,o=this.p.serial((0,a.toS)(e),(()=>i(n)),n);return s(this,r,"f").add(e,o),o}},r=new WeakMap},60172:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,r)=>{t=e,i=r})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,s.set(this,void 0),n.set(this,0),a.set(this,void 0),o.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,a,"f")}unset(){d(this,n,0,"f"),d(this,s,void 0,"f"),d(this,a,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,o,"f").push(e)}prior(){return this.isStale()?void 0:c(this,a,"f")}lastValue(){return c(this,a,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,n,"f")}isStale(){return null==c(this,s,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,s,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,s,"f")?void 0:Date.now()-c(this,s,"f")}elapsedMs(){return c(this,a,"f")?.settledMs??c(this,a,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,o,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,o,"f"))e.onError(t)}finally{d(this,n,(i=c(this,n,"f"),++i),"f")}},u=function(e){d(this,s,Date.now(),"f");const t=c(this,a,"f");return d(this,a,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,a,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,a,"f")),c(this,a,"f")}},1728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),s=i(80049);t.memoizeAsync=function(e,t){let i=0;const n=new s.FifoCacheAsync(t),a=t=>(i++,n.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return a.clear=e=>{if(null==e)return n.clear();{const t=(0,r.stringify)(e);return n.deleteIf((e=>t===e))}},a.size=()=>n.size,a.callCount=()=>i,a}},22781:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),s.set(this,!1),n.set(this,!1)}_call(){return a(this,s,"f")?(o(this,n,!0,"f"),!0===this.undefinedIfBusy?void 0:a(this,r,"f")):(o(this,s,!0,"f"),o(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{o(this,s,!1,"f"),!0===this.runLaterIfBusy&&a(this,n,"f")&&(o(this,n,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return a(this,s,"f")}prior(){return a(this,r,"f")}async force(){return await a(this,r,"f"),this._call()}}r=new WeakMap,s=new WeakMap,n=new WeakMap},37461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),s=i(76790),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),w=i(15674),v=i(42638);var b=i(20214);async function S(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:i,timeoutMs:s}){const n=[];for(const a of(0,r.compact)(await t))try{const e=await((0,l.gt0)(s)?(0,c.thenOrTimeoutError)(i(a),s):i(a));null!=e&&n.push([e,a])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:a,error:t})}return n}async function T({arr:e,f:t,name:i,maxConcurrent:s,timeoutMs:n,promises:a}){if(null==e)return[];const o=(0,r.compact)(await e);if((0,r.isEmpty)(o))return[];if((s=Math.round(s??(0,w.maxCpus)()))<=1)return _({arr:e,f:t,name:i,timeoutMs:n});const u=a??(o.length<=s?v.PermissivePromises:new v.Promises(i,(()=>s))),d=(0,l.gt0)(n)?e=>(0,c.thenOrTimeoutError)(t(e),n):t,h=await u.enqueueAll(i,o.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return b.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=S,t.thenCollectBatched=async function(e,t,i){const r=[];for(const s of(0,p.batches)((0,f.toA)(await e),t)){const e=await S(s);r.push(...await S(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,o.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=T,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n}){return(await T({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:s,timeoutMs:n}){return(await T({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:s,timeoutMs:n})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await T({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,n.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,n.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*a.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,s=null;try{r=await((0,h.isFunction)(e)?e():e)}catch(e){s=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(s??r)}catch{}if(null!=s)throw s;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,n.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const s=await t;return null!=s?i(r,s):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const s=await t(r);return null==s?i():s},t.thenMap2Or=async function(e,t,i,r){const s=await e;if(null==s)return r();const n=await t;if(null==n)return r();const a=await i(s,n);return null==a?r():a},t.thenAnd=async function(e,t){return null!=e&&(0,n.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await T({name:e,arr:t,f:i});return(0,s.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),w=i(25764),v=i(38836),b=i(73614);function S(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),s=(0,l.clamp)(10*a.secondMs,a.minuteMs,Math.round(this.times.get(e)?.p98??0)),n=(0,b.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),s);try{const s=await(0,c.tot)(t),n=Date.now()-r;return i?.(s,n),this.push(e,n),s}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(n)}}get entriesBySumDesc(){return(0,n.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(S(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,o.getOrSet)(this.times,S(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(S(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/a.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function _(e,t,i){return P.instance().time(e,t,i)}function T(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new v.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,s.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),w.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const i=Date.now(),r=t();return T(e,Date.now()-i),r},t.pushTime=T,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>_(e,t)),i)}},42638:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),w=i(54993),v=i(89788),b=i(82647),S=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,w.toS)(e)};class _{constructor(e,t){r.add(this),this.name=e,this.ee=new f.default.EventEmitter,s.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new b.Average,n.set(this,0),a.set(this,[]),o.set(this,[]),this.lastPushedNames=new v.BoundedList(16),c(this,s,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,S.maxCpus)(),d(this,s,"f")?.call(this)??(0,S.maxCpus)()))}end(){return d(this,o,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,a,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,n,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,a,"f").map((e=>e.name)),pendingNames:d(this,o,"f").map((e=>e.d.name)),totalWorkCount:d(this,n,"f")}}enqueue({name:e,l:t,payload:i,serialId:s}){const n=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:s});return this.laterPop(),n}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,a,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,o,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,o,"f").length,e),i=this.runningSerialIds,s=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,a,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,o,"f").length}hasPending(){return d(this,o,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,o,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,o,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const s=new P.Deferred(e,{payload:i,serialId:r});return d(this,o,"f").push({d:s,l:t}),s},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,n,(t=d(this,n,"f"),++t),"f"),(0,m.remove)(d(this,a,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,a,"f").push(e),e},t.maybeRun=function(e,t){const i=new _(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new _(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},59189:function(e,t){"use strict";var i,r=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},s=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SerialLaterQueue=void 0,t.SerialLaterQueue=class{constructor(){i.set(this,Promise.resolve())}enqueue(e){return s(this,i,r(this,i,"f").catch().then(e),"f")}},i=new WeakMap},4867:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),s=i(34546),n=i(41400),a=i(31586),o=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let o=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>o=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>{if(o)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(o)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>l=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>o.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),s=i(42659),n=i(41400),a=i(32639),o=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,o.clamp)(10*m,l.ShortCommandTimeoutMs,(t??s.minuteMs)/5);await(0,n.delay)(r,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const s=r(i(1708)),n=i(45599),a=i(41400),o=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),w=i(50213),v=i(7282),b=i(88158),S=i(45969),P=i(43334),_=i(28874),T=i(3790);function M(e){return E().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const E=(0,n.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,b.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,a.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const D=["HOME","LANG","USER"],x=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],k=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?D:x),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function F(e){const t={NODE_ENV:(0,v.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,S.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,_.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,o.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(s.default.env,(e=>M(e)||!(0,T.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=F,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:A({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let C=!1;function A({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const s=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...k(),...i?(0,g.childProcLocale)():{},...F(r),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(s);if((0,y.isLogged)("debug")&&!C){C=!0;const e=(0,w.mkLogger)("child.ChildEnv"),t=(0,l.entries)(s).map((([e,t])=>[e,(0,T.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return s}t.childEnv=A},84777:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const s=r(i(31421)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),w=i(79089),v=i(45255),b=i(22911),S=i(4867),P=i(73614),_=i(70025),T=i(57159),M=i(36868),E=i(66184),D=i(45643),x=i(95402),k=i(9727),F=(0,a.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function C(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function A(e,t=30*u.secondMs){if(null==e)return!1;F().debug("endProcess()",C(e));const i=e.pid;if(null==i||i<=0)return F().warn("endProcess(): asked to end invalid pid",C(e)),!1;if(i===n.default.pid)return F().warn("endProcess(): asked to end MY pid",C(e)),!1;if(i===n.default.ppid)return F().warn("endProcess(): asked to end my parent pid",C(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();F().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,x.killPid)(i).catch((e=>{F().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,D.waitForPidExit)(i,t))return F().debug("endProcess(): exitted",C(e)),!0;{x.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");F().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,x.killPid)(i,!0).catch((e=>{F().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,D.waitForPidExit)(i,5e3)}function I(e,i,r,s=0){const a=new Date,o=[];return(0,w.niceable)(i,r)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,w.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(s,u.secondMs)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&A(e)}),s-250)),o.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,x.addPid)({pid:e.pid,cmd:i,timeoutMs:s,ppid:n.default.pid},a)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>o.forEach(clearTimeout))),e}function O(e,t,i,r){const n=(0,k.spawnOptions)(r);return(0,E.isLogged)("trace",F().context)?F().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:n}):F().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(s.default.execFile(e,t,n),e,t,i)}async function L(e,t,i){const r=i.quiet??!1,s=i.ignoreStderr??!1,n=i.ignoreExitCode??!1,a=O(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{a.disconnect?.()}catch{}return{result:"",pid:a.pid}}const u=a.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new b.Deferred(f);a.on("error",(e=>g.push(e))),a.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),a.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(a.stdin);const w=new d.Latch;null==a.stdout?w.resolve():(a.stdout.on("error",(e=>g.push(e))),a.stdout.on("data",(e=>m.push(e))),a.stdout.on("end",(()=>w.resolve())));const P=new d.Latch;null==a.stderr||s?P.resolve():(a.stderr?.on("error",(e=>g.push(e))),a.stderr?.on("data",(e=>p.push(e))),a.stderr?.on("end",(()=>P.resolve()))),F().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,S.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),F().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:w.state(),stderr:P.state()}),await(0,S.thenOrTimeoutError)({p:w.promise,timeoutMs:v.ShortCommandTimeoutMs,halt:i.halt}),await(0,S.thenOrTimeoutError)({p:P.promise,timeoutMs:v.ShortCommandTimeoutMs,halt:i.halt});const E=p.join("");(0,l.notBlank)(E)&&g.push(new Error(E)),!r&&(0,o.isNotEmpty)(g)&&F().warn(f+" resulted in errors:",g);const D=i.isIgnorableError??_.isIgnorableError,x=g.filter((e=>!0!==D(e)));if(x.length>0)throw 1===x.length?x[0]:new T.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:x});if(!n&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:E}}catch(e){throw F().error("stdoutResult_() failed",e),await(0,x.killPid)(a.pid,!0),e}}t.endProcess=A,t.ReniceAfterMs=(0,a.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,a.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const n=(0,k.spawnOptions)(r);return F().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(s.default.spawn(e,t,n),e,t,i)},t.execFile=O,t.stdoutResult_=L,t.stdout_=async function(e,t,i){const r=await L(e,t,i);return F().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},3790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),s=i(41400),n=i(19851),a=i(28874);(0,s.later)((()=>a.Settings.sensitiveEnvRegExp.watchLater((()=>o.unset()))));const o=(0,n.lazy)((()=>{try{return new RegExp(a.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${a.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(a.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&o().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||a.Settings.license.includesEnvKey(e)}},55534:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceExitCommand=void 0,t.ServiceExitCommand="--exit"},85100:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serviceExitTimeoutMs=void 0;const r=i(23560),s=i(28874),n=i(45255);t.serviceExitTimeoutMs=function(e){return(0,r.isSyncService)(e)?s.Settings.syncExitTimeoutMs.valueOrDefault:n.ShortCommandTimeoutMs}},34330:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),w=i(54993),v=i(27395),b=i(25764),S=i(99331),P=i(42638),_=i(38835),T=i(8769),M=i(57159),E=i(66003),D=i(50213),x=i(45643),k=i(28874),F=i(84777);t.mkBasicWatchedChild=function(e){return new C({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,F.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class C{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,D.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),s.set(this,!1),this.onError=(e,t,i)=>{const n=new M.WrappedError(e,{cause:t}),a=!1!==n.ignorable;this.logger().log(a?"warn":"error","onError()",n),u(this,s,"f")||a||(this.lastError=n,(0,T.onError)(n),!0!==n.fatal?(i??this.opts.onError(e,n))&&(this.logger().warn("onError requested restart",{src:e,error:n}),u(this,r,"m",o).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:k.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:b.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,v.addEndable)(this.opts.endableRank,this),u(this,r,"m",o).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,s,"f")}async end(){return c(this,s,!0,"f"),u(this,r,"m",n).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",n).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,s,"f")}),!u(this,s,"f")&&!(0,S.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",n).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=C,s=new WeakMap,r=new WeakSet,n=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,s,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",a).call(this,e)},a=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,x.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,F.endProcess)(e,this.endTimeoutMs)},o=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",n).call(this),!this._stopped&&!u(this,s,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,T.onError)("Can't restart "+this.name+", failure rate is too high."+_.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,s,"f")}),this._stopped||u(this,s,"f")||(0,S.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,E.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,w.toS)(e).includes("Error: Cannot find module")&&(0,T.onError)("Failed to start "+this.name+_.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,s,"f")}),(0,S.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",o).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const a=n(i(53916)),o=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,o.toNativePath_)(e);const i=f.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),s=i.sibling(r);if(s.isSelfOrDescendantOf((0,l.examples)()))return a.join("$examples",s.posixPathFrom((0,l.examples)()));const n=(0,d.originalsDir)();if(s.isSelfOrDescendantOf(n))return a.join("$library",s.posixPathFrom(n));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?a.join("$library",s.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const n=i(6858),a=i(1708),o=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),h=i(43334),f=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return s(this,r,"f").push(...e),this}async parse(e=a.argv,t){let i=(0,m.addHelpFooter)(new n.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of s(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":o.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,a.exit)(0)})),i.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=i.opts();for(const e of s(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),s=i(31586),n=i(51926),a=i(17344),o=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,s.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,n.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,a.EditionName)()+" v"+o.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const r=i(38639),s=i(17181),n=i(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,r.mapBoolean)(e.color,(e=>{n.Settings.logColor.envValue=e,(0,s.setupLogFormatter)()}))}}},83210:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDaemon=void 0;const s=r(i(1708)),n=i(22573),a=i(38639);t.isDaemon=function(e){return(0,a.isTrue)(s.default.env.__is_daemon)||(0,a.isTrue)(e?.daemon)||!(0,n.blank)(e?.pidfile)}},53978:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimingArg=void 0;const r=i(28874),s=i(38639);t.TimingArg={beforeParse:e=>e.option("--timing","On exit, emit timing information to stdout."),afterParse:async e=>{(0,s.isTrue)(e.timing)&&(r.Settings.emitTimingsOnExit.value=!0)}}},94361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),s=i(40958),n=i(55835),a=i(31586),o=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,a.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,s.compactBlanks)([c("user id","PUID",(0,o.userids)()),c("group id","PGID",(0,o.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,n.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},54772:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestLabhashName=t.bestLabName=t.bestRgbName=t.colorToTuple=t.bestRgbTripletName=t.ColorNames=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(31586),o=i(48884),l=i(50213),u=i(81168),c=i(85810),d=i(42079),h=i(91482),f=i(3048),m=i(85409),p=i(16050),g=i(42022),y=i(85042),w=(0,r.lazy)((()=>(0,l.mkLogger)("color.ColorNames")));function v(e){const t=(0,y.normalizeRgbHex)(e.rgb);if(null==t)return void w().warn(`skipping invalid entry (bad rgb): ${e.rgb}`,e);const i=(0,c.rgbhex2Lab)(t);if(null==i)return void w().warn(`skipping invalid entry (failed to convert to L*a*b): ${t}`,e);const r=(0,c.toLabhash)(i,g.ModeBits);return{...e,rgb:t,lab:i,labhash:r,closeLabhashes:[r],closeRgb:[t],name:(0,u.capitalize)(e.name)}}function b(e,i){return null==e?void 0:(0,o.leastBy)(i??(0,t.ColorNames)(),(t=>(0,f.ciede2000_delta_e)(t.lab,e)))}t.ColorNames=(0,r.lazy)((()=>(0,s.compact)([...d.CrayonColors,...d.CrayonSupplements,...h.DarkWikipediaColors,...p.LightWikipediaColors,...m.Greys].map(v)))),t.bestRgbTripletName=function(e,i=(0,t.ColorNames)()){return b((0,c.rgb2lab)(e),i)},t.colorToTuple=v,t.bestRgbName=function(e){return P((0,c.rgbhex2Labhash)(e))},t.bestLabName=b;const S=new Map;function P(e){return(0,a.gte0)(e)?(0,n.getOrSet)(S,e,(()=>{const i=(0,t.ColorNames)().find((t=>t.labhash===e));if(null!=i)return i;const r=(0,c.unlabhash)(e),n=b(r);return null!=r&&null!=n&&((0,s.pushUniq)(n.closeLabhashes,e),(0,s.pushUniq)(n.closeRgb,(0,c.lab2rgbhex)(r))),n})):void 0}t.bestLabhashName=P},85810:(e,t,i)=>{"use strict";e=i.nmd(e),Object.defineProperty(t,"__esModule",{value:!0}),t.hsv2rgb=t.hsl2hsv=t.hsv2hsl=t.hsl2rgb=t.rgb2hsl=t.rgbhex2hsl=t.rgb2hsv=t.closestLab=t.maxLabhash=t.minLabhash=t.unlabhash=t.toLabhash=t.LabBitZip=t.xyz2rgb=t.lab2xyz=t.xyz2lab=t.rgb2xyz=t.clampLab=t.lab2rgb=t.rgb2lab=t.rgb2labArray=t.rgb2labTriplets=t.lab2rgbhex=t.rgbhex2Labhash=t.rgbhex2Lab=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(55835),o=i(31586),l=i(48884),u=i(20014),c=i(75503),d=i(3048),h=i(42022),f=i(85042),m=[[.4124564,.3575761,.1804375],[.2126729,.7151522,.072175],[.0193339,.119192,.9503041]],p=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]];function g(e){return _(v(e))}function y(e){return(0,f.clampRGB)(M(T(e)))}function w(e){return(0,t.LabBitZip)().clampValue(e)}function v(e){const t=(0,f.clampRGB)(e).map((e=>e/255)).map((e=>e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92));return(0,c.matXvec)(m,t)}t.rgbhex2Lab=function(e){return(0,a.map)((0,f.rgbhex2triplet)(e),g)},t.rgbhex2Labhash=function(e,t=h.ModeBits){return(0,a.map)((0,f.rgbhex2triplet)(e),(e=>E(g(e),t)))},t.lab2rgbhex=function(e){return(0,f.rgbTriplet2hex)(y(e))},t.rgb2labTriplets=function(e){return(0,s.stepRange)(0,e.length,3).map((t=>g([e[t],e[t+1],e[t+2]])))},t.rgb2labArray=function(e){const t=[],i=[],r=[];for(let s=0;se>S?Math.pow(e,1/3):(P*e+16)/116));return w([116*i-16,500*(t-i),200*(i-r)])}function T(e){const[t,i,r]=w(e),s=(t+16)/116,n=i/500+s,a=s-r/200,o=n*n*n,l=a*a*a,u=o>S?o:(116*n-16)/P,c=t>8?Math.pow(s,3):t/P,d=l>S?l:(116*a-16)/P;return[u*b.X,c*b.Y,d*b.Z]}function M(e){return(0,c.matXvec)(p,e).map((e=>{const t=e<0?-1:1,i=e*t;return(0,o.round)(255*t*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055))}))}function E(e,i=h.ModeBits){return(0,t.LabBitZip)().zip(e,i)}t.xyz2lab=_,t.lab2xyz=T,t.xyz2rgb=M,t.LabBitZip=(0,r.lazy)((()=>new u.BitZip([{min:0,max:100},{min:-79,max:90},{min:-102,max:89}]))),t.toLabhash=E;const D=new Map;function x(e,i=h.ModeBits){return(0,t.LabBitZip)().unzip(e,i)}function k(e){const[t,i,r]=(0,f.clampRGB)(e),s=Math.max(t,i,r),n=s-Math.min(t,i,r),a=n?s===t?(i-r)/n:s===i?2+(r-t)/n:4+(t-i)/n:0;return[60*(a<0?a+6:a),s?n/s*100:0,s/255*100]}function F(e){return C(k(e))}function C(e){const[t,i,r]=e,s=(200-i)*r/100;return[t,s>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,s/2]}function A(e){const[t,i,r]=e,s=i*(r<50?r:100-r)/100;return[t,s>0?2*s/(r+s)*100:0,r+s]}function I(e){const t=e[0]/360*6,i=e[1]/100,r=e[2]/100,s=Math.floor(t),n=r*(1-i),a=r*(1-(t-s)*i),o=r*(1-(1-t+s)*i),l=s%6;return(0,f.clampRGB)([255*[r,a,n,n,o,r][l],255*[o,r,r,a,n,n][l],255*[n,n,o,r,r,a][l]])}t.unlabhash=function(e,t=h.ModeBits){return t===h.ModeBits?(0,n.getOrSet)(D,e,(()=>x(e,t))):x(e,t)},t.minLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMin(h.ModeBits))),t.maxLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMax(h.ModeBits))),t.closestLab=function(e,t){return(0,l.leastBy)(e,(e=>(0,d.ciede2000_delta_e)(e,t)))},t.rgb2hsv=k,t.rgbhex2hsl=function(e){return F((0,f.rgbhex2triplet)(e))},t.rgb2hsl=F,t.hsl2rgb=function(e){return I(A(e))},t.hsv2hsl=C,t.hsl2hsv=A,t.hsv2rgb=I,i.c[i.s]===e&&console.log(E([0,0,0]))},42079:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CrayonSupplements=t.CrayonColors=void 0,t.CrayonColors=[{name:"Aquamarine",rgb:"#95E0E8"},{name:"Asparagus",rgb:"#7BA05B"},{name:"Blue-green",rgb:"#0095B7"},{name:"Royal blue",rgb:"#273BE2"},{name:"Blush",rgb:"#DB5079"},{name:"Brilliant rose",rgb:"#E667CE"},{name:"Brown",rgb:"#AF593E"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Burnt umber",rgb:"#805533"},{name:"Cadet blue",rgb:"#A9B2C3"},{name:"Canary",rgb:"#FFFF99"},{name:"Carmine",rgb:"#E62E6B"},{name:"Carnation pink",rgb:"#FFA6C9"},{name:"Celestial blue",rgb:"#7070CC"},{name:"Cerise",rgb:"#DA3287"},{name:"Cerulean blue",rgb:"#339ACC"},{name:"Chestnut",rgb:"#B94E48"},{name:"Cobalt blue",rgb:"#8C90C8"},{name:"Copper",rgb:"#DA8A67"},{name:"Cornflower",rgb:"#93CCEA"},{name:"Cotton candy",rgb:"#FFB7D5"},{name:"Denim",rgb:"#1560BD"},{name:"Eggplant",rgb:"#614051"},{name:"Fern",rgb:"#63B76C"},{name:"Fuchsia",rgb:"#C154C1"},{name:"Russet",rgb:"#87421F"},{name:"Green",rgb:"#01A638"},{name:"Green-yellow",rgb:"#F1E788"},{name:"Indigo",rgb:"#4F69C6"},{name:"Jungle green",rgb:"#29AB87"},{name:"Magenta",rgb:"#F653A6"},{name:"Maize",rgb:"#F2C649"},{name:"Maroon",rgb:"#C32148"},{name:"Medium chrome green",rgb:"#6CA67C"},{name:"Medium violet",rgb:"#8F47B3"},{name:"Melon",rgb:"#FEBAAD"},{name:"Middle blue-green",rgb:"#8DD9CC"},{name:"Middle blue-purple",rgb:"#8B72BE"},{name:"Green-yellow",rgb:"#ACBF60"},{name:"Middle purple",rgb:"#D982B5"},{name:"Middle yellow-red",rgb:"#ECAC76"},{name:"Midnight blue",rgb:"#003366"},{name:"Mulberry",rgb:"#C8509B"},{name:"Navy blue",rgb:"#0066CC"},{name:"Olive green",rgb:"#B5B35C"},{name:"Orange",rgb:"#FF8833"},{name:"Orchid",rgb:"#E29CD2"},{name:"Peach",rgb:"#FFCBA4"},{name:"Periwinkle",rgb:"#C3CDE6"},{name:"Pine green",rgb:"#01796F"},{name:"Pink flamingo",rgb:"#FC74FD"},{name:"Plum",rgb:"#8E3179"},{name:"Raw umber",rgb:"#665233"},{name:"Red-orange",rgb:"#FF681F"},{name:"Red",rgb:"#ED0A3F"},{name:"Salmon",rgb:"#FF91A4"},{name:"Vivid scarlet",rgb:"#FD0E35"},{name:"Sea green",rgb:"#93DFB8"},{name:"Sepia",rgb:"#9E5B40"},{name:"Shamrock",rgb:"#33CC99"},{name:"Sky blue",rgb:"#76D7EA"},{name:"Spring green",rgb:"#ECEBBD"},{name:"Sunset orange",rgb:"#FE4C40"},{name:"Tan",rgb:"#FA9D5A"},{name:"Teal blue",rgb:"#008080"},{name:"Thistle",rgb:"#D8BFD8"},{name:"Vivid tangerine",rgb:"#ED3C10"},{name:"Vivid violet",rgb:"#a625c3"},{name:"Wisteria",rgb:"#C9A0DC"},{name:"Yellow-green",rgb:"#C5E17A"},{name:"Yellow-orange",rgb:"#FFAE42"},{name:"Yellow",rgb:"#FBE870"}],t.CrayonSupplements=[{name:"Artichoke",rgb:"#8F9779"},{name:"Aubergine",rgb:"#48213A"},{name:"Brandy rose",rgb:"#B1847F"},{name:"Burgundy",rgb:"#800020"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Crimson red",rgb:"#990000"},{name:"Dark brown",rgb:"#664228"},{name:"Dark coral",rgb:"#CD5B45"},{name:"Dark green",rgb:"#006400"},{name:"Dark raspberry",rgb:"#872657"},{name:"Dark turquoise",rgb:"#610079"},{name:"Deep teal",rgb:"#004040"},{name:"Deep coffee",rgb:"#704241"},{name:"Dusty rasberry",rgb:"#917980"},{name:"Ecru",rgb:"#BCAC7C"},{name:"Evergreen",rgb:"#05472A"},{name:"Eggplant",rgb:"#380835"},{name:"Eggplant purple",rgb:"#430541"},{name:"Emerald green",rgb:"#028F1E"},{name:"Flamingo pink",rgb:"#D67C99"},{name:"Grape",rgb:"#6C3461"},{name:"Kelly green",rgb:"#4CBB17"},{name:"Light forest green",rgb:"#4F9153"},{name:"Medium dark brown",rgb:"#AF7200"},{name:"Medium dark cyan-blue",rgb:"#2D537C"},{name:"Mustard",rgb:"#FAAF18"},{name:"Neon green",rgb:"#39FF14"},{name:"Pear",rgb:"#D1E231"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Phthalo blue",rgb:"#0016C7"},{name:"Pink lace",rgb:"#FFDDF4"},{name:"Raw sienna",rgb:"#884B15"},{name:"Rebecca purple",rgb:"#663399"},{name:"Sap green",rgb:"#536916"},{name:"Blue sapphire",rgb:"#133ECB"},{name:"Sand",rgb:"#B38751"},{name:"Shadow blue",rgb:"#778BA5"},{name:"Shadow green",rgb:"#121E06"},{name:"Swamp green",rgb:"#748500"},{name:"Verdigris",rgb:"#43B3AE"},{name:"Vivid blue-magenta",rgb:"#4817E8"},{name:"Vivid blue-purple",rgb:"#ACACE6"},{name:"Vivid blue",rgb:"#47ABCC"},{name:"Vivid green-yellow",rgb:"#D9E650"},{name:"Vivid green",rgb:"#7BE214"},{name:"Vivid turqoise",rgb:"#06ECD2"},{name:"Vivid lavender",rgb:"#A354FD"},{name:"Vivid mint",rgb:"#00F28C"},{name:"Vivid pink",rgb:"#D752FB"},{name:"Vivid red-purple",rgb:"#C31D7E"},{name:"Vivid red",rgb:"#D92121"},{name:"Vivid yellow-red",rgb:"#F2BA49"},{name:"Vivid yellow",rgb:"#FAFA37"}]},91482:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarkWikipediaColors=void 0,t.DarkWikipediaColors=[{name:"Bistre",rgb:"#3D2B1F"},{name:"Black bean",rgb:"#3D0C02"},{name:"Black pearl",rgb:"#041322"},{name:"Shadow blue",rgb:"#001440"},{name:"Charcoal",rgb:"#36454F"},{name:"Dark indigo",rgb:"#1F0A52"},{name:"Dark magenta",rgb:"#8B008B"},{name:"Dark moss green",rgb:"#4A5D23"},{name:"Dark navy",rgb:"#02075D"},{name:"Dark pastel blue",rgb:"#779ECB"},{name:"Dark purple",rgb:"#580040"},{name:"Dark tan",rgb:"#918151"},{name:"Dark yellow-green",rgb:"#304000"},{name:"Dark yellow",rgb:"#9B870C"},{name:"Deep violet",rgb:"#330066"},{name:"Dusk",rgb:"#4E5481"},{name:"Elderberry",rgb:"#1d1a34"},{name:"Grey jade",rgb:"#757C55"},{name:"Grey magenta",rgb:"#83667F"},{name:"Grey ochre",rgb:"#716659"},{name:"Grey olive",rgb:"#656c5a"},{name:"Grey sage",rgb:"#69724d"},{name:"Taupe",rgb:"#483C32"}]},3048:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciede2000_delta_e=t.diffCIECorr=t.MaxCie=t.MinCie=t.cie94_delta_e=t.cie76_delta_e=void 0;const r=i(31586),s=i(97352);t.cie76_delta_e=function(e,t){return Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2)},t.cie94_delta_e=function(e,t){const[i,r,n]=e,[a,o,l]=t,u=i-a,c=r-o,d=n-l,h=(0,s.sqrt)(r**2+n**2),f=h-(0,s.sqrt)(o**2+l**2),m=(0,s.sqrt)(c**2+d**2-f**2);return(0,s.sqrt)((u/1)**2+(f/(1+.045*h))**2+(m/(1+.015*h))**2)},t.MinCie=2,t.MaxCie=20,t.diffCIECorr=function(e,i){return null==e||null==i?1:(0,r.clamp)(0,t.MaxCie,l(e,i)-t.MinCie)/t.MaxCie};const n=1,a=1,o=1;function l(e,t){const[i,r,l]=e,u=(0,s.sqrt)(r**2+l**2),[c,d,h]=t,f=(u+(0,s.sqrt)(d**2+h**2))/2,m=.5*(1-(0,s.sqrt)(Math.pow(f,7)/(Math.pow(f,7)+Math.pow(25,7)))),p=r*(1+m),g=d*(1+m),y=(0,s.sqrt)(p*p+l*l),w=(0,s.sqrt)(g*g+h*h);let v=Math.abs(p)+Math.abs(l)===0?0:Math.atan2(l,p);v+=2*(v<0?1:0)*Math.PI;let b=Math.abs(g)+Math.abs(h)===0?0:Math.atan2(h,g);b+=2*(b<0?1:0)*Math.PI;const S=c-i,P=w-y;let _=y*w==0?0:b-v;_-=2*(_>Math.PI?1:0)*Math.PI,_+=2*(_<-Math.PI?1:0)*Math.PI;const T=2*(0,s.sqrt)(y*w)*Math.sin(_/2),M=(i+c)/2,E=(y+w)/2;let D;y*w==0?D=v+b:(D=(v+b)/2,D-=(Math.abs(v-b)>Math.PI?1:0)*Math.PI,D+=2*(D<0?1:0)*Math.PI);const x=(M-50)**2,k=1-.17*Math.cos(D-Math.PI/6)+.24*Math.cos(2*D)+.32*Math.cos(3*D+Math.PI/30)-.2*Math.cos(4*D-63*Math.PI/180),F=1+.015*x/(0,s.sqrt)(20+x),C=1+.045*E,A=1+.015*E*k,I=30*Math.PI/180*Math.exp(-1*((180/Math.PI*D-275)/25)**2),O=2*(0,s.sqrt)(Math.pow(E,7)/(Math.pow(E,7)+Math.pow(25,7))),L=-1*Math.sin(2*I)*O;return(0,s.sqrt)(Math.pow(S/(n*F),2)+Math.pow(P/(a*C),2)+Math.pow(T/(o*A),2)+L*P/(a*C)*T/(o*A))}t.ciede2000_delta_e=l},76490:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColor=t.dominantColorsToRgbHex=void 0;const r=i(40958),s=i(31586),n=i(97352),a=i(54772),o=i(85810),l=i(42022),u=i(1971);t.dominantColorsToRgbHex=function(e){return(0,r.compact)(e.map((e=>[e.rgbhex,(0,s.fmtPct)(e.pct)])))};class c{static fromModeData(e){return(0,r.compact)((0,s.times)(u.ModeCount,(t=>c.fromLabhash({labhash:e[`mode${t}`],pct:e[`mode${t}pct`]}))))}static toModeData(e){const t={};return(0,s.times)(u.ModeCount,(i=>{t["mode"+i]=e[i]?.labhash??null,t["mode"+i+"pct"]=e[i]?.pct??null})),t}static fromLabhash({labhash:e,labhashBits:t=l.ModeBits,pct:i}){const r=(0,n.mapGt0)(e,(e=>(0,o.unlabhash)(e,t)));return null!=r&&(0,s.gt0)(i)?new c(r,i,e):void 0}static fromCentroid(e,t){return new c(e.centroid,Math.round(e.size/t*100))}constructor(e,t,i){this.lab=e,this.pct=(0,s.clamp)(0,100,t),this.labhash=i??(0,o.toLabhash)(e,l.ModeBits)}get rgbhex(){return(0,o.lab2rgbhex)(this.lab)}get color(){return(0,a.bestLabhashName)(this.labhash)}toGreyscale(){return new c([this.lab[0],0,0],this.pct)}eql(e){return this.labhash===e.labhash&&(0,s.closeTo)(this.pct,e.pct,5)}}t.DominantColor=c},32848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scaled_delta_e=t.dominantColorCorrelation=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(48884),o=i(31843),l=i(70417),u=i(3048);function c(e,t){const i=(0,s.sum)(e,(e=>(0,n.clamp)(0,100,e.pct))),r=(0,s.sum)(e,(e=>function(e,t){const i=(0,a.leastBy)(t,(t=>(0,u.ciede2000_delta_e)(e.lab,t.lab)));if(null==i)return 0;const r=(0,u.ciede2000_delta_e)(e.lab,i.lab),s=(0,n.clamp)(0,e.pct,(0,l.avg)([e.pct,i.pct])),o=h(r);return(0,n.clamp)(0,100,s)*o}(e,t)));return r/i}t.dominantColorCorrelation=function(e,t){return e=(0,s.compact)(e),t=(0,s.compact)(t),(0,s.isEmpty)(e)||(0,s.isEmpty)(t)?0:(0,l.avg)([c(e,t),c(t,e)])};const d=(0,r.lazy)((()=>[{x:0,y:1},{x:9,y:.8},{x:16,y:.3},{x:20,y:0}]));function h(e){return(0,n.clamp)(0,1,(0,o.lerp2d)(e,...d()))}t.scaled_delta_e=h},40401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeNearCentroids=t.mergeLabhashes=t.dominantColorsFromModes=t.maybeFilterGrey=t.centroidsScore=t.extractDominantColors=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(41400),o=i(98553),l=i(31586),u=i(68708),c=i(48884),d=i(22454),h=i(50213),f=i(56038),m=i(82647),p=i(44983),g=i(70417),y=i(28874),w=i(85810),v=i(3048),b=i(76490),S=i(1971),P=(0,r.lazy)((()=>(0,h.mkLogger)("color.DominantColors")));t.extractDominantColors=function(e,t=S.ModeCount){return(0,f.timeSync)("img.extractDominantColors",(()=>function(e,t=S.ModeCount){const i=Date.now(),r=y.Settings.dominantColorKmeansRuns.valueOrDefault,a=new d.CountingSet;for(const i of E({labs:e,minK:t}))a.incr((0,w.toLabhash)(i));const h=T[y.Settings.dominantColorDeltaE.valueOrDefault]??v.ciede2000_delta_e;const f=a.sortedByKey().valuesToA((e=>(0,w.unlabhash)(e)));let g=(0,l.round)(t+y.Settings.dominantColorMergeThreshold.valueOrDefault);function x(e){const i=t,r=4*t;g=Math.round(Math.max(i,Math.min(r,e)))}const F=f.length<=g?[]:(0,s.compact)(_.slice(0,r).map((e=>{const r=(0,p.kmeans)(f,g,{...M,seed:e}),s=k(r.centroids,f.length);if(s.lengtht&&x(g-1);const n=s.slice(0,t),o=(0,l.sigFigs)(function(e){const t=new m.Average;for(const[i,r]of a.entries()){const s=(0,w.unlabhash)(i),n=(0,c.leastByCtx)(e,(e=>h(e.centroid,s)));null!=n&&(0,l.times)(r,(()=>t.push(n.value)))}return t.p84}(n),2);return{...r,centroids:n,description:{kIn:g,kOut:r.centroids.length,kMerged:s.length,score:o,iterations:r.iterations,uniqColors:a.size,elapsedMs:Date.now()-i},score:o}})));P().trace("extractDominantColors()",{kmeansResults:F.map((e=>(0,u.pick)(e,"description","score")))});const C=(0,c.leastBy)(F,(e=>e.score));if(null==C)return P().info("kmeans failed or was disabled, using dominantColorsFromModes",{runs:r}),D(a,t);const A=(0,o.stringify)({...C?.description,elapsedMs:Date.now()-i}),I=(0,n.sortBy)(C?.centroids,(e=>-e.size)).map((e=>b.DominantColor.fromCentroid(e,f.length)));return P().debug("extractDominantColors() result",{description:A,score:C?.score,totalColors:a.size,totalPixels:f.length,iters:C?.iterations,dominantColors:(0,b.dominantColorsToRgbHex)(I),pixelCount:f.length}),{dominantColors:I,description:A,dominantColorScore:C?.score}}(e,t)))},t.centroidsScore=function(e,t){const i=new m.Average;for(const r of e){const e=(0,c.leastBy)(t,(e=>(0,v.ciede2000_delta_e)(e.centroid,r)));null!=e&&i.push((0,v.ciede2000_delta_e)(e.centroid,r))}return i};const _=[6147062518717073,8176726750919909,5426648081701673,0xce2a345532a3c,0x713f9716da824,6348935463312109,5900323173950995,7358780886584433,5704068712193493,0x51ceeef755892,0xe1557fe94c084,0xd42d7cc96d6b4,0xcbc36dfd76e8a,6738189173486085,8537822851166899,5390086061821835,7712057976331355,0xe9b820db7a8e4,0xb96cebcd6aa40,7036994544380825,5353634786120155,0x99a11417794bc,0xa93d36019aaae,0x74a470887095e,5481147022770415,5347523348244809,0x541d1098e90fc,0xa24d9fb3510c2,0x78aa8e4f692fa,6354921850669697,0x714e1ec1b0a14,8622097963014773,0x6ff5d462d8eb6,0x6782a6b5166b8,7128984079394103,0xe6efba28a3752,5088704486053871,0xc84df40627fae,8018285280412081,4524300326741245,8307147030534695,8135486835878813,7699950603263999,0xb2889592968ae,5903399874280295,7462660765348991,6442509751447017,0xe218d44834db6,7214173935589545,6001326758941961,0x53eb7d39bbb50,0xc3a7ab8add332,0x4e6e81bc443e2,6757635537583321,8501611905255957,0x51840465cc07c,5958243312989149,8928005021308717,5032083390680559,0xb35d70ac51c68,0xfc3826a2dfe7c,0xd155853c61e96,0xda2045ee9be1e,4753952745315177],T={cie76:v.cie76_delta_e,cie94:v.cie94_delta_e,ciede2000:v.ciede2000_delta_e},M=(0,r.lazy)((()=>({maxIterations:50,initialization:"kmeans++",distanceFunction:T[y.Settings.dominantColorDeltaE.valueOrDefault]})));function E({labs:e,minK:t,thresh:i,retries:r=3}){if(r<0)return P().debug("maybeFilterGrey(): exhausted retries: grey filtering disabled."),e;const s=i??y.Settings.dominantColorGreyThreshold.valueOrDefault;if(!(0,l.gt0)(s))return P().debug("maybeFilterGrey(): grey threshold is <= 0: grey filtering disabled."),e;const n=e.filter((e=>Math.abs(e[1])+Math.abs(e[2])>=s));return n.length>=e.length/2?(P().debug("maybeFilterGrey(): sufficient remaining pixels with this threshold.",{greyThreshold:s,minK:t,pixelCount:e.length,filteredCount:n.length}),n):(P().debug("maybeFilterGrey(): insufficient remaining pixels with this threshold. Retrying with smaller threshold.",{greyThreshold:s,minK:t,retries:r,pixelCount:e.length,filteredCount:n.length}),E({labs:e,minK:t,thresh:.75*s,retries:r-1}))}function D(e,t){const i=e.countSum,r=e.size;x(e);const n=e.size,a=(0,s.compact)(e.top(t).map((([e,t])=>b.DominantColor.fromLabhash({labhash:e,pct:Math.round(100*t/i)})))),l=100-(0,g.sumf)(a,(e=>e.pct));return{dominantColors:a,description:"dominantColorsFromModes: "+(0,o.stringify)({uniqColors:r,mergedColors:n,pixelCount:i,pctOmitted:l})}}function x(e,t=y.Settings.dominantColorMergeThreshold.valueOrDefault){const i=[];for(const[r,s]of[...e.entriesByCountDesc()]){const n=(0,w.unlabhash)(r),a=i.find((e=>(0,v.ciede2000_delta_e)(e.lab,n)<=t));null==a?i.push({lab:n,labhash:r}):(e.delete(r),e.incr(a.labhash,s))}return e}function k(e,t,i=y.Settings.dominantColorMergeThreshold.valueOrDefault){if(i<=0)return e;const r=[];for(const t of e){const e=r.find((e=>(0,v.ciede2000_delta_e)(t.centroid,e.centroid)<=i));null==e?r.push(t):e.size+=t.size}const s=t/100;return(0,n.sortBy)(r.filter((e=>e.size>s)),(e=>-e.size))}(0,a.later)((()=>{y.Settings.dominantColorDeltaE.watchLater((()=>{M.unset()}))})),t.maybeFilterGrey=E,t.dominantColorsFromModes=D,t.mergeLabhashes=x,t.mergeNearCentroids=k},85409:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Greys=void 0,t.Greys=[{name:"Black",rgb:"#000000"},{name:"90% black",rgb:"#1b1b1b"},{name:"80% black",rgb:"#303030"},{name:"70% black",rgb:"#474747"},{name:"60% black",rgb:"#5e5e5e"},{name:"Grey",rgb:"#777777"},{name:"60% white",rgb:"#919191"},{name:"70% white",rgb:"#ababab"},{name:"80% white",rgb:"#c6c6c6"},{name:"90% white",rgb:"#e2e2e2"},{name:"White",rgb:"#ffffff"}]},86758:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.labsAreGreyscale=t.isLab=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(82647),o=i(28874),l=i(85810),u=(0,r.lazy)((()=>(0,n.mkLogger)("color.Lab")));t.isLab=function(e){return Array.isArray(e)&&3===e.length&&(0,s.within)(0,100,e[0])&&(0,s.within)(-110,110,e[1])&&(0,s.within)(-110,110,e[2])},t.labsAreGreyscale=function(e){const t=o.Settings.greyscaleColorThreshold.valueOrDefault,i=new a.Average,r=new a.Average;for(const t of e){const e=(0,l.clampLab)(t);i.push(e[1]),r.push(e[2])}const s=(i.stdDev??0)+(r.stdDev??0),n=s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LightWikipediaColors=void 0,t.LightWikipediaColors=[{name:"Beige",rgb:"#F5F5DC"},{name:"Laurel green",rgb:"#A9BA9D"},{name:"Light sage",rgb:"#93A58B"},{name:"Light green-cyan",rgb:"#CFEADE"},{name:"Pastel purple",rgb:"#B39EB5"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Powder blue",rgb:"#B0E0E6"},{name:"Vanilla",rgb:"#F3E5AB"}]},42022:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeBits=void 0,t.ModeBits=12},1971:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeCount=void 0,t.ModeCount=7},85434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitModeData=t.pickModeData=t.ModeDataKeys=t.isModeData=void 0;const r=i(31586),s=i(68708),n=i(50989);t.isModeData=function(e){return(0,r.gt0)(e.mode0)&&(0,r.gt0)(e.mode0pct)},t.ModeDataKeys=(0,n.strEnum)("mode0","mode0pct","mode1","mode1pct","mode2","mode2pct","mode3","mode3pct","mode4","mode4pct","mode5","mode5pct","mode6","mode6pct"),t.pickModeData=function(e){return(0,s.pick)(e,...t.ModeDataKeys.values)},t.omitModeData=function(e){return(0,s.omit)(e,...t.ModeDataKeys.values)}},85042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clampRGB=t.rgbTriplet2hex=t.rgbhex2triplet=t.normalizeRgbHex=void 0;const r=i(31586),s=i(39926),n=i(51926),a=i(54993),o=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;function l(e){return[e[0],e[1],e[2]].map((e=>(0,r.clamp)(0,255,Math.round(e))))}t.normalizeRgbHex=function(e){const t=(0,a.toS)(e).trim();return o.test(t)?(0,n.ensurePrefix)(t,"#").toUpperCase():void 0},t.rgbhex2triplet=function(e){const t=(0,a.toS)(e).trim().match(o);if(null!=t)try{return[t[1],t[2],t[3]].map((e=>(0,r.clamp)(0,255,parseInt(e,16))))}catch{return}},t.rgbTriplet2hex=function(e){return"#"+l(e).map((e=>(0,s.leftPad)(Math.round(e).toString(16).toUpperCase(),2,"0"))).join("")},t.clampRGB=l},76596:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),s=i(19851),n=i(22573),a=i(42659),o=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,s.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,o.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,o.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,a.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const r=i(77988),s=i(19851),n=i(55835),a=i(31586),o=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,s.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),h=["year","month","day","hour","minute","second","millisecond"];class f{static fromISO(e,t){const i=d().exec((0,o.toS)(e).trim()),r=i?.groups;return null==r?void 0:f.for((0,c.parseExifDateTime)(r.start,t),(0,c.parseExifDateTime)(r.end,t),(0,a.toInt)(r.index),(0,a.toInt)(r.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,n.map)(e.start,(e=>r.ExifDateTime.fromJSON(e))),(0,n.map)(e.end,(e=>r.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,r=1){if(null==e||!e.isValid||null==t||!t.isValid)return;r=(0,a.clamp)(1,1e3,(0,a.toInt)(r,{defaultValue:1})),i=(0,a.clamp)(0,r-1,(0,a.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const s=e.toMillis(),n=(t.toMillis()-s)/(r+1)*(i+1),o=e.plus({milliseconds:n});return null==o?void 0:new f(e,o,t,i,r)}constructor(e,t,i,r=0,s=1){this.start=e,this.middle=t,this.end=i,this.index=r,this.splits=s,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=h.map((r=>function({start:e,end:t,middle:i,field:r}){return null!=e[r]&&null!=t[r]?i[r]:void 0}({start:e,middle:t,end:i,field:r})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new f(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=f},79842:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(76790),o=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),h=i(51926),f=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),w=i(21330),v=i(928),b=i(54261),S=i(73389),P=i(51275),_=(0,n.lazy)((()=>(0,f.mkLogger)("date.Dated")));function T(e){return null!=e&&(e instanceof w.FuzzyDate||e instanceof r.ExifDate||e instanceof r.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,S.isDateTime)(e)||(0,m.isDateObject)(e))}function M(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof r.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function E(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof r.ExifDate?e.toMillis(l.dayMs):e instanceof w.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),x(e),((e,t)=>e+t))}function D(e){try{if(null==e||(0,h.isString)(e)||(0,c.isNumber)(e))return;return(0,S.isDateTime)(e)?e:e instanceof r.ExifDateTime||e instanceof w.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?s.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void _().warn("datedToDateTime() failed",{d:e,error:t})}}function x(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,b.hasTime)(e)){if((0,c.gt0)((0,v.getMillisecond)(e)))return 0;if((0,c.gt0)((0,v.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,v.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,v.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,v.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,v.getMonth)(e))?l.monthMs-1:l.yearMs-1}function k(e,t){const i=M(e),r=E(e);if(null!=i&&null!=r)return(0,c.gt0)(t)&&t>r-i?{start:Math.round((i+r)/2-t/2),end:Math.round((i+r)/2+t/2)}:{start:i,end:r}}function F(e,t,i,r){const[s,n]=(0,a.sortBy)([k(e,i),k(t,r)],(e=>e?.start));return null!=s&&null!=n&&null!=s&&null!=n&&(s.start===n.start||s.end>=Math.min(n.start,n.end))}function C(e,t){return(0,o.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??w.FuzzyDate.fromISO(e)}t.isDated=T,t.toDated=function(e){return T(e)?e:void 0},t.mapDated=function(e,t){return T(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=M,t.datedToEndTs=E,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof r.ExifDate?s.DateTime.fromObject(e):D(e)},t.datedToDateTime=D,t.datedToPrecisionMs=x,t.isoToPrecisionMs=function(e){return(0,u.map)(C(e),x)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:r}){if(null==e||null==t)return!1;if(i??(i=x(e)),r??(r=x(t)),F(e,t,i,r))return!0;const s=(0,P.getZoneName)(e),n=(0,P.getZoneName)(t);return null==s&&null!=n&&(e=(0,w.setZone)(e,n)??e),null==n&&null!=s&&(t=(0,w.setZone)(t,s)??t),F(e,t,i,r)},t.isoToDated=C,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof s.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const r=i(31586),s=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,s.isString)(e))return(0,r.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),s=i(31586),n=i(54557),a=i(91655),o=new n.FifoCache(512);function l(e){return(0,s.isNumber)(e)?e:(0,r.blank)(e)?void 0:o.getOrSet(e,(()=>(0,a.parseDuration)(e)))}t.decodeDuration=l;const u=new n.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,a.fmtFullDuration)((0,s.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),s=i(40958),n=i(22573),a=i(42659),o=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,o.isNumber)(e))return;if((0,o.isNumber)(e))return e;if((0,o.isDigits)(e))return(0,o.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,s.compact)(d.map((e=>function(e,t){const i=(0,o.toFloat)(e);if(null!=i){if((0,n.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*a.yearMs;case"weeks":case"week":case"w":return i*a.weekMs;case"days":case"day":case"d":return i*a.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*a.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*a.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*a.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,o.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:a.yearMs,s:"y"},{ms:a.weekMs,s:"w"},{ms:a.dayMs,s:"d"},{ms:a.hourMs,s:"h"},{ms:a.minuteMs,s:"m"},{ms:a.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,o.isNumber)(t))return;if(0===t)return"0";if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},98247:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),h=i(68852),f=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function w(e,t,i){const r=t.exec(e);if(null==r||(0,u.isEmptyObj)(r.groups))return;const{year:s,month:n,day:a,hour:c,minute:h,second:p}=(0,d.mapEntries)(r.groups,((e,t)=>(0,l.toInt)(t)));if(null==s||null==n||null==a)return;if(!f.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==h))return;const g=(0,o.map)((0,l.toFloat)(r.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),w=(0,y.timezoneOffsetFromRegExpMatch)(r);return S({year:s,month:n,day:a,hour:c??0,minute:h??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(w)??i,rawValue:e,tzoffsetMinutes:w})}t.UnsetZone=s.Info.normalizeZone(r.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof r.ExifDate&&t instanceof r.ExifTime))return;const i=new r.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:n}){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromFormat(e,i,{zone:n??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,a.blank)(e)?void 0:r.ExifDateTime.from(e,t)??w(e,b(),t)},t.parseExifDateTimeRe=w;const v=/[-:_\s]?/,b=(0,n.lazy)((()=>(0,h.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,v,p.monthRE,v,p.dayRE,/[T\s]/,p.hourRE,v,p.minuteRE,v,p.secondRE,p.subsecRE,/\s?/,h.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function S(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof r.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=r.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,o.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=S},74417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const r=i(51168),s=i(22573),n=i(42659),a=i(49769),o=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),h=i(66649),f=i(98725),m=i(88600);t.recent=function(e,t=5*n.secondMs){return(0,c.isRecentMs)((0,h.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=r.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,s.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,s.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=r.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,a.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,h.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,o.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*n.secondMs):void 0)??(0,f.parseDateTime)(t)?.toMillis()}},12959:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filestampUTC=t.filestamp=void 0;const r=i(39926);t.filestamp=function(e=new Date){return[e.getFullYear(),(0,r.pad2)(e.getMonth()+1),(0,r.pad2)(e.getDate()),"-",(0,r.pad2)(e.getHours()),(0,r.pad2)(e.getMinutes()),(0,r.pad2)(e.getSeconds())].join("")},t.filestampUTC=function(e=new Date){return[e.getUTCFullYear(),(0,r.pad2)(e.getUTCMonth()+1),(0,r.pad2)(e.getUTCDate()),"-",(0,r.pad2)(e.getUTCHours()),(0,r.pad2)(e.getUTCMinutes()),(0,r.pad2)(e.getUTCSeconds())].join("")}},21330:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const n=i(77988),a=i(51168),o=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(31586),f=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),w=i(79842),v=i(66649),b=i(98247),S=i(98725),P=i(928),_=i(54261),T=i(73389),M=i(89724),E=i(17415),D=i(88600),x=i(51275);function k(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class F{constructor(e,t,i){this.year=e,this.month=t,this.day=i,r.set(this,(0,p.lazy)((()=>(0,D.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(S.ISO_YMD_RE.exec(e)?.groups??S.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,h.toGt0)(e?.year);if(null==e||null==t||tk(e))).join("-")}toLocal(){return(0,M.datedToLocal)(this)}toDateTime(){return a.DateTime.fromObject((0,f.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,f.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,f.pick)(e.plus({month:1}),"year","month"):(0,f.pick)(e.plus({year:1}),"year");return new F(t.year,t.month,t.day)}}function C(e,t){if(e instanceof n.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,_.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,E.zoneToTzOffsetMinutes)((0,v.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(r=>(0,d.map)((0,P.getMonth)(e),(s=>(0,d.map)((0,P.getDay)(e),(n=>(0,d.map)((0,P.getHour)(e),(a=>(0,b.dateObjectToExifDateTime)({year:r,month:s,day:n,hour:a,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=F,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",r=15*(0,h.round)(e/15),s=Math.abs(r),n=Math.floor(s/60),a=Math.floor(Math.abs(s%60));return`${t?"UTC":""}${i}${k(n)}:${k(a)}`},t.toExifDateTime=C,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof n.ExifDateTime?e.tzoffsetMinutes:(0,T.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,_.hasTime)(e)||(i??(0,w.datedToPrecisionMs)(e))>=c.dayMs?O(e):C(e,(0,x.getZoneName)(e))?.toISOString({includeOffset:t})};const A="yyyy:MM:dd HH:mm:ss.SSS",I=A+"ZZ";function O(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>k(e))).join(t)}function L(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new F(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,r]=[e,t].map(v.datedToMillis);return null==i||null==r?void 0:i-r}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,h.isNumber)(t)?a.DateTime.fromMillis(t):(0,w.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,x.hasZone)(t)?I:A):void 0},t.datedToYMD=O,t.toFuzzyDate=L,t.sameDay=function(e,t){return(0,h.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,h.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,r=1){if(null==(0,v.datedToMillis)(e)||null==(0,v.datedToMillis)(t))return;const[s,n]=[e,t].map((e=>(0,v.datedToMillis)(e))).sort(),o=(n-s)/(r+1),l=(0,x.getZoneName)(e),u=l===(0,x.getZoneName)(t)?l:void 0,c=a.DateTime.fromMillis(s+o*i,{zone:u});return[e,t].some((e=>!(0,_.hasTime)(e)))?L(c):c},t.setZone=function(e,t,i){const r={...(0,f.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,x.hasZone)(e)},s=(0,E.normalizeZone)(t);if(null!=e&&null!=s&&(0,_.hasTime)(e))return e instanceof y.DateInterval?e.setZone(s,r):C(e)?.setZone(s,r)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,h.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,w.datedToDateTime)(e);if(null==i)return;const r=(0,x.getZoneName)(e);return null!=r&&"UTC"!==r||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const o=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),h=i(49769),f=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),w=i(68852),v=i(4001),b=i(28874),S=i(24689),P=i(79842),_=i(66649),T=i(98247),M=i(21330),E=i(54261),D=i(73389),x=i(16400),k=i(88600),F=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return F().tap({msg:"extractDateFromPath",result:O.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return O.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return O.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,f.mapNumeric)((0,_.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,w.concatRegexp)([/^/,t.yearRE,w.RegExpOptional.from(/-/,t.monthRE,w.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,w.concatRegexp)([/^/,t.yearishRE,w.RegExpOptional.from(/-/,t.monthishRE,w.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=I({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,D.isDateTime)(i)?i:(0,E.isExifDateTime)(i)?i.toDateTime():void 0};const C=new Map;function A(e,t,i){try{const r=(0,T.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=r)return r;const s=(0,h.getOrSet)(C,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void F().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,T.parseExifDateTimeFormat)({input:s?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void F().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function I({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:r=!0,descPredicate:s=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const n=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(v.stripDSC));if(0!==n.length)for(const{desc:e,f:a}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>S.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,T.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:T.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(b.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(b.Settings.extraDateTimeFormats.values)){const r=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${r})`,f:i=>A(i,r,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>o.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of O.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:r}))if(s(e))for(const e of n){const t=a(e);if(null!=t&&(0,k.isValidDate)(t))return t}}t.parseDated=I;class O{constructor(e={}){r.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&b.Settings.fuzzyDateParsing.watchLater((()=>a(this,r,"m",n).call(this))),null==e.fuzzyYearParsing&&b.Settings.fuzzyYearParsing.watchLater((()=>a(this,r,"m",n).call(this))),a(this,r,"m",n).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??b.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??b.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!b.Settings.usePathsToInferDates.valueOrDefault)return;M.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=I({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=O,r=new WeakSet,s=function(e){const t=new L(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},n=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new w.RegExpEscaped("(?"+(0,x.monthNames)().map(w.escapeRegExp).join("|")+")");a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE]),a(this,r,"m",s).call(this,[e,t.seps,t.yearRE]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,e]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},O.instance=(0,u.lazy)((()=>new O));class L{constructor(e){this.regex=e instanceof RegExp?e:(0,w.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return M.FuzzyDate.for({year:(0,f.toInt)(t.year),month:(0,f.toInt)(t.month)??(0,x.monthName2index)(t.monthname),day:(0,f.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const r=i(55835),s=i(31586),n=i(54261);function a(e){return e instanceof Date?e.getMinutes():e?.minute}function o(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=a,t.getSecond=o,t.getMillisecond=l,t.getCentisecond=function(e){return(0,r.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,n.hasTime)(e)&&((0,s.gt0)(a(e))||(0,s.gt0)(o(e))||(0,s.gt0)(l(e)))},t.getSecMs=function(e){return(0,r.map)(o(e),(t=>{const i=l(e)??0;let r=(t+i/1e3).toString();for(t<10&&(r="0"+r),0===i&&(r+=".");r.length<6;)r+="0";return r}))}},54261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const r=i(77988),s=i(31586),n=i(68708);t.hasTime=function(e){if(!(0,n.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,s.gt0)(t.hour)||(0,s.gt0)(t.minute)||(0,s.gt0)(t.second)||(0,s.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof r.ExifDateTime}},73389:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const r=i(51168);t.isDateTime=function(e){return r.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const r=i(51168),s=i(19851),n=i(42659),a=i(55835),o=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),h=i(74417),f=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,s.lazy)((()=>w(l.Settings.datesBeforeAreEstimated.valueOrDefault)??w(l.Settings.datesBeforeAreEstimated.defaultValue)));function w(e){return(0,a.map)((0,c.isoToDated)(e),v)}function v(e){return(0,o.isNumber)(e)?T(e):100*b(e)+((0,m.getCentisecond)(e)??0)}function b(e){if((0,o.isNumber)(e))return Math.floor(T(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function S(e,t){if(null==e||e<0)return;let i=e;const r=()=>{const e=i%100;return i=Math.floor(i/100),e},s=10*r(),n=r(),a=r(),l=(0,o.toGt0)(r()),u=(0,o.toGt0)(r()),c=(0,o.toGt0)(r());return{year:i,month:c,day:u,hour:l,minute:a,second:n,millisecond:s,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=S(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):f.FuzzyDate.for(i)}function _(e,t){return T(Date.now()-e,t)}function T(e,t){return v(r.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const r=i(19851),s=i(76790),n=i(31586),a=i(9092),o=(0,r.lazy)((()=>{const e=new a.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const r=new Intl.DateTimeFormat(t,{month:i});(0,n.times)(12,(s=>{const n=r.format(new Date(2017,s));e.set(n,s+1),"short"===i&&"en-US"===t&&e.set(n+".",s+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:o().get(e)},t.monthNames=function(){return(0,s.sort)([...o().keys()])}},42499:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLuxon=void 0;const r=i(51168),s=i(19851),n=i(19043),a=i(28874);t.setupLuxon=(0,s.lazy)((async()=>{r.Settings.throwOnInvalid=!1,a.Settings.twoDigitCutoffYear.watch((e=>r.Settings.twoDigitCutoffYear=e)),r.Settings.defaultLocale=await(0,n.locale)()}))},17415:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),h=i(54993),f=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,n.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const r=(0,f.leastBy)(g(),(t=>Math.abs(t-e)));return null!=r&&Math.abs(r-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(r)}t.isUTCZone=function(e){return b(e)||0===S(e)?.offset(Date.now())},t.normalizeZone=S,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,o.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=_,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:_(i)};const T=/\b(?Z|UTC|GMT)\b/,M=/(?[-±+−])/,E=/[-−]/,D=/(?[01]\d)/,x=/(?[01]?\d)/,k=/(?::(?\d\d))/;function F(e){return b(e)?0:C((0,t.TimezoneOffsetRE)().exec(e))}function C(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,a.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=E.test((0,h.toS)(e.groups.tzSign))?-1:1,r=(0,l.toInt)(e.groups.tzMinutes)??0,s=null==t?void 0:i*(60*t+r);return w(s)?s:void 0}t.TimezoneOffsetRE=(0,n.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),T,new m.RegExpEscaped("|"),M,D,m.RegExpOptional.from(k),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=F,t.timezoneOffsetFromRegExpMatch=C;const A=/\b(?(?:Etc\/)?GMT)\b/,I=(0,n.lazy)((()=>(0,m.concatRegexp)([A,M,x,m.RegExpOptional.from(k)])));function O(e){return C(I().exec(e))}t.ianaZoneToOffsetMinutes=O,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,a.blank)(e))return;const i=O(e)??F(e);if(null!=i)return _(i);if(null!=t){const i=S(e);if(null!=i)return _(i.offset(t))}}},88600:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),h=i(28874),f=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),w=(0,s.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),v=(0,s.lazy)((()=>(0,n.compact)(h.Settings.badDates.values.map((e=>(0,f.isoToDated)(e)))))),b=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,p.datedToISO)(e)))))),S=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,y.datedToLocal)(e)))))),P=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,m.datedToMillis)(e))))));function _(e){if(null==e)return!1;const t=M(e);return w().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return _(e)?e:void 0},t.isValidDate=_;const T=String(new Date("bad"));function M(e){try{if(!(0,f.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===T)return T;const t=(0,n.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const s=[];if((0,l.isNumber)(e)||s.push("year is not a number"),(0,l.lt)(e,h.Settings.minValidYear.valueOrDefault)&&s.push("year is less than "+h.Settings.minValidYear.key),(0,u.gt)(e,E())&&s.push("year is in the future"),null==t&&null!=i&&s.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const n=r.DateTime.fromObject({year:e,month:t,day:i});n.isValid||s.push(n.invalidExplanation??"not valid")}return(0,n.compact)(s)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=h.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const r=(0,m.datedToMillis)(e);(0,u.gt)(r,Date.now()+i)&&t.push("date is too far in the future: see "+h.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):S().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):b().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,a.toNotBlank)((0,n.uniq)((0,n.compactBlanks)(t)).join("; "))}catch(t){return w().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=M;const E=(0,s.lazy)((()=>r.DateTime.now().plus({milliseconds:h.Settings.maxValidFutureMs.valueOrDefault}).year),o.dayMs);t.mapValidDate=function(e,t){return _(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==M({year:e,month:t,day:i})}},51275:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const r=i(77988),s=i(31586),n=i(24689),a=i(73389);t.hasZone=function(e){return null!=e&&!(0,s.isNumber)(e)&&(e instanceof n.DateInterval||e instanceof r.ExifDateTime?e.hasZone:!!(0,a.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==r.UnsetZoneName&&e.zone.offset(Date.now())!==r.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,a.isDateTime)(e)?e.zoneName===r.UnsetZoneName?void 0:e.zone?.name:e instanceof r.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},82261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cacheDbDir_=void 0;const r=i(51926),s=i(49776),n=i(38835),a=i(95696),o=i(70854),l=i(73428),u=i(28874),c=i(15056);t.cacheDbDir_=async function(e=u.Settings.libraryDir.valueOrDefault,t=c.Schemas.models){const i=(0,o.libraryUidStore)(e);if(null==i)throw new Error("Library directory is not set"+n.NoLibraryErrorFlag);const d=await i.readUid_(),h=a.PosixFile.for((0,s.cacheDir_)()).join(t+"-live-db",d);await h.mkdirp_();const f=h.join("README.txt");return await(0,l.writeTextfile_)(f.nativePath,...(0,r.wrap)(["This folder is used by PhotoStructure for your library stored in",e,"You will corrupt your library if you remove this directory while PhotoStructure is running.","See https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837 for details."].join("\n\n"))),h}},92407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLiveDbDir_=t.cacheDbFile_=void 0;const r=i(19851),s=i(87290),n=i(50213),a=i(28874),o=i(82261),l=i(15056),u=i(7311),c=i(44955),d=(0,r.lazy)((()=>(0,n.mkLogger)("db.CheckLocalDbReplica")));async function h({libraryDir:e=a.Settings.libraryDir.valueOrDefault,schema:t=l.Schemas.models}={}){return(await(0,o.cacheDbDir_)(e,t)).join(u.SqliteBase)}t.cacheDbFile_=h,t.getLiveDbDir_=async function(e=a.Settings.libraryDir.valueOrDefault){if(!a.Settings.forceLocalDbReplica.valueOrDefault){const t=(0,l.pathToDb)(await(0,s.setupLibraryDataDir_)(e),l.Schemas.models);try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!1}}catch(e){d().info("SQLite cannot directly write to the library: trying to use a local db replica.",{libraryDb:t,error:e})}}const t=await h({libraryDir:e,schema:l.Schemas.models});try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!0}}catch(e){return d().throw("SQLite cannot directly write to the library or the cacheDir.",{cacheDbFile:t,error:e})}}},5531:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},55332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupCold_=void 0;const r=i(19851),s=i(50213),n=i(76187),a=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbBackupCold")));t.dbBackupCold_=async function(e,t){await t.mkdirp_();const i=[];try{for(const r of(0,n.sqliteFiles)(e)){const e=t.join(r.base).wip();i.push(e),await r.copyFile_(e)}return a().tap({msg:"completed",level:"info",result:await Promise.all(i.map((e=>e.unwip_()))),meta:{srcDbFile:e,destDir:t}})}catch(e){throw await Promise.all(i.map((e=>e.unlink()))),e}}},91872:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleDbRetries_=void 0;const r=i(50213),s=i(70025),n=i(28874),a=i(45599),o=i(41400),l=i(30976),u=i(56038),c=(0,a.defer)((()=>(0,r.mkLogger)("db.DbRetries")));t.handleDbRetries_=function(e,t,i,r){const a=Date.now();let d=0;const h=a+n.Settings.dbMaintenanceTimeoutMs.valueOrDefault;return(0,u.time)(e,(async()=>{for(;Date.now()=h)throw c().error(e+": Caught db error. Not retrying.",{error:t}),t;{const i=(0,l.randomInt)(500,1500)*++d;c().warn(e+": Caught db error. Retrying in "+i+"ms.",{name:e,error:t}),r?.(),await(0,o.delay)(i)}}return t().close(),c().throw(e+": handleDbRetries(): timeout after "+n.Settings.dbMaintenanceTimeoutMs.valueOrDefault+"ms")}))}},12943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toDbValued=t.isDbValued=t.isDbValue=void 0;const r=i(79842),s=i(66649),n=i(40958),a=i(68708);function o(e){return null===e||(0,n.includes)(["number","string"],typeof e)}t.isDbValue=o,t.isDbValued=function e(t){return null!=t&&Array.isArray(t)?t.every(e):(0,a.entries)(t).every((([,e])=>o(e)))},t.toDbValued=function(e){return(0,a.mapFields)(e,((e,t)=>{if(!e.startsWith("$"))return"boolean"==typeof t?[e,t?1:0]:o(t)?[e,t]:(0,r.isDated)(t)?[e,(0,s.datedToMillis)(t)]:void 0}))}},65753:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maxBatchPluckSize=void 0;const r=i(19851),s=i(7282),n=i(28874);t.maxBatchPluckSize=(0,r.lazy)((()=>Math.round(n.Settings.dbBatchSelectSize.valueOrDefault*((0,s.isTest)()?.25:5))))},80632:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pageSizeBytes=t.mkdb_=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(54993),u=i(50213),c=i(23560),d=i(65211),h=i(29882),f=i(53265),m=i(66430),p=i(66184),g=i(28874),y=i(15674),w=i(87550);function v(){const e=g.Settings.dbPageSizeBytes.valueOrDefault;return Math.pow(2,(0,a.clamp)(1,28,Math.round(Math.log2(e))))}t.mkdb_=function({nativePath:e,timeoutMs:t=g.Settings.dbBusyTimeoutMs.valueOrDefault,logSql:i=g.Settings.logSql.valueOrDefault}){e=(0,f.resolve)(e),(0,h.mkdirpSync_)((0,r.dirname)(e));const b=(0,h.posixPathFromGrandparent)(e),S=(0,m.nativePathSizeSync)(e),P=(0,u.mkLogger)("db.mkdb("+b+")");if(null!=S){const E=Math.round(S/o.MiB),D=Math.ceil(1.5*E);D>g.Settings.dbCacheSizeMb.valueOrDefault&&(P.info("Dynamically setting dbCacheSize to "+g.Settings.dbCacheSizeMb.value,{db:e,dbFileSizeMb:E}),g.Settings.dbCacheSizeMb.envValue=D);const x=Math.round(1.5*E);x>g.Settings.maxMemoryMb.valueOrDefault&&(P.warn("Large database: setting maxMemoryDb to "+x+"MB",{dbFileSizeMb:E,"Settings.maxMemoryMb":g.Settings.maxMemoryMb.valueOrDefault}),g.Settings.maxMemoryMb.envValue=x)}P.info("Opening "+e+"...");const _={fileMustExist:!1,readonly:!1};if((0,a.gt0)(t)&&(_.timeout=Math.ceil(t)),i){const k=(0,u.mkLogger)("SQLite("+b+")"),F=(0,p.defaultLogLevel)();function C(e,...t){var i;(0,n.blank)(e)||k.log(F,(i=e,(0,l.toS)(i).replace(/\s{2,}/g," ")),{args:t})}_.verbose=C}const T=new w(e,_);P.info("Open. Setting PRAGMAs...");for(const A of(0,s.compact)(['encoding = "UTF-8"',"threads = "+(0,y.maxCpus)(),"foreign_keys = ON","page_size = "+v(),"trusted_schema = 0","cache_size = -"+Math.round(g.Settings.dbCacheSizeMb.valueOrDefault*o.MiB/1024),"locking_mode = NORMAL","journal_mode = WAL",(0,a.gt0)(g.Settings.dbBusyTimeoutMs.valueOrDefault)?"busy_timeout = "+g.Settings.dbBusyTimeoutMs.valueOrDefault:null,"temp_store = MEMORY","synchronous = "+g.Settings.dbSynchronousMode.valueOrDefault,"case_sensitive_like = 0","wal_autocheckpoint = "+((0,c.isDbJanitorService)()?(0,l.toS)(g.Settings.dbWalAutoCheckpoint.valueOrDefault):"0"),"auto_vacuum = "+g.Settings.dbAutoVacuumMode.valueOrDefault]))P.tapThunk({msg:"PRAGMA "+A,result:()=>T.pragma(A)});const M=T;return M.__uid=(0,d.uid)(),M},t.pageSizeBytes=v},99315:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},95704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withIdBatches=void 0;const r=i(40958),s=i(31586),n=i(59455),a=i(65753),o=i(51040);t.withIdBatches=async function(e){const t=(0,s.toGt0)(e.batchSize)??(0,a.maxBatchPluckSize)(),i=(0,o.dbValueToEscapedString)(e.primaryKeyColumnName),l=(0,r.compactBlanks)([i+" > :min",...(0,n.toA)(e.whereClauses)]).join(" AND "),u=e.db.prepare((0,r.compactBlanks)(["SELECT "+i,"FROM "+(0,o.dbValueToEscapedString)(e.tableName),"WHERE "+l,"ORDER BY "+i,"LIMIT :limit"]).join(" "));let c=-1;for(;;){const i=u.pluck().all({min:c,limit:t});if(0===i.length)return;await e.fn(i),c=(0,r.last)(i)}}},76187:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSqliteFile=t.sqliteSizeBytes=t.sqliteFiles=void 0;const r=i(17217),s=i(87391),n=i(7311);t.sqliteFiles=function(e){return[e,...s.SQLiteSuffixes.map((t=>e.sibling(e.base+t)))].filter((e=>e.existsSync({refresh:!0})))},t.sqliteSizeBytes=async function(e){return(await e.size({refresh:!0})??0)+(await e.sibling(e.base+"-wal").size({refresh:!0})??0)};const a=[n.SqliteExt,...[...s.SQLiteSuffixes,"-shm"].map((e=>n.SqliteExt+e))];t.isSqliteFile=function(e){const t=(0,r.basename)(e);for(const e of a)if(t.endsWith(e))return!0;return!1}},51040:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitBatchSql=t.dbValueToEscapedString=void 0;const r=i(40958),s=i(31586),n=i(54993),a=/^\w+$/;t.dbValueToEscapedString=function(e){if((0,s.isNumber)(e))return e.toString();const t=(0,n.toS)(e);return a.test(t)?t:`'${t.replace(/'/g,"''")}'`};const o=/--.+$/gm,l=/\s+/g;t.splitBatchSql=function(e){const t=(0,r.compactBlanks)((0,n.toS)(e).split(/;/).map((e=>e.replace(o,"").replace(l," ").trim()))),i=[];let s;for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertDirSQLiteReadWrite_=t.isDirSQLiteReadWrite=t.firstDirSQLiteReadWrite=void 0;const r=i(19851),s=i(50357),n=i(30976),a=i(50213),o=i(95696),l=i(80632),u=i(76187),c=(0,r.lazy)((()=>(0,a.mkLogger)("db.SQLiteReadWrite")));async function d(e){try{return await h(e),c().info("isDirSQLiteReadWrite(): true",{dirNativePath:e}),!0}catch(t){return c().warn("isDirSQLiteReadWrite(): false",{dirNativePath:e,error:t}),!1}}async function h(e){const t=o.PosixFile.for(e),i=(0,n.randomChars)(8),r=t.child(".test-"+i+".sqlite");let a=null;try{await t.mkdirp_(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3}),a.exec("CREATE TABLE t (s VARCHAR(16) NOT NULL)"),a.exec(`INSERT INTO t (s) VALUES ('${i}')`);{const e=a.prepare("SELECT s FROM t").all();(0,s.eql)(e,[{s:i}])||c().throw("unexpected rows",{rows:e})}a.exec("VACUUM"),a.close(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3});{const e=(0,n.randomChars)(8);a.exec(`INSERT INTO t (s) VALUES ('${e}')`);const t=a.prepare("SELECT s FROM t ORDER BY s").pluck().all();(0,s.eql)(t,[i,e].sort())||c().throw("unexpected rows",{rows:t})}}finally{try{a?.close()}catch{}await Promise.all((0,u.sqliteFiles)(r).map((e=>e.rm())))}}t.firstDirSQLiteReadWrite=async function(...e){for(const t of e)if(null!=t&&await d(t))return t},t.isDirSQLiteReadWrite=d,t.assertDirSQLiteReadWrite_=h},87391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SQLiteSuffixes=void 0,t.SQLiteSuffixes=["-wal","-journal"]},15056:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),s=i(7311);function n(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=n,t.pathToDb=function(e,t){return n(e,t).join(s.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const a=n(i(76760)),o=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),w=i(70698),v=i(64680),b=i(29882),S=i(45969),P=i(43334),_=i(28874),T=i(41692),M=i(32774),E=i(80612),D=i(32551),x=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function k(){if((0,S.isDocker)())return[{dir:"/tmp/.photostructure-cache"+x(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,a.join)(i,".photostructure-cache"+x()),preexistingDir:i});return e}}function F(){if((0,S.isDocker)())return(0,o.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,a.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+x(),preexistingDir:M.DefaultDockerLibraryDir},...k()]);const e=(0,o.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),a.default.resolve((0,D.homeDir)(),"AppData","Local")]:P.isMac?[a.default.resolve((0,D.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,a.join)((0,D.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,a.join)(e,t),preexistingDir:e})));return i.push(...k()),i}t.tmpCacheDirs=k,t.tmpDirs=function(){return(0,E.filterDirs)({dirs:k(),desc:"tmp"})},t.cacheDirs=F,t.defaultCacheDir=(0,d.lazy)((()=>(0,E.firstDir)({dirs:F(),desc:"cache"})));const C=(0,d.lazy)((()=>{(0,T.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(A)}));function A(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{C();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,b.mkdirpSync_)(e),(0,w.writeCachedirTag_)(e).then((()=>(0,v.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=A},46292:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),s=i(45969),n=i(41692),a=i(32774),o=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,n.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,s.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,o.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:a.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:a.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,s.isDocker)()?c:(0,o.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),s=i(45969),n=i(32774);t.defaultLibraryDir=function(){return(0,s.isDocker)()?n.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,s.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const s=r(i(76760)),n=i(40958),a=i(72993),o=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),s.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(s.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,o.env)().XDG_DATA_HOME,(0,o.env)().XDG_CONFIG_HOME,s.default.resolve((0,d.homeDir)(),".config")),(0,n.compactBlanks)(e).map((e=>({dir:s.default.join(e,(0,a.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),s=i(96706),n=i(29882);t.envConfigDir=function(){const e=(0,s.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,n.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),s=i(40958),n=i(22573),a=i(66430);function o({dirs:e,desc:t}){for(const{dir:i,preexistingDir:o}of(0,s.compact)(e))if(!(0,n.blank)(i)){if((0,a.isReadWriteableDirectorySync)(i))return i;if((0,n.blank)(o)||(0,a.isReadWriteableDirectorySync)(o))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=o,t.filterDirs=function({dirs:e,desc:t}){return(0,s.compact)(e.map((e=>o({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),s=i(76760),n=i(1708),a=i(19851),o=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,a.lazy)((()=>{const e=[];u.isWin?e.push(n.env.USERPROFILE):e.push(n.env.HOME);for(const t of(0,o.compactBlanks)(e)){const e=(0,s.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),s=i(49776),n=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[n.libraryDataDir,n.libraryPreviewsDir,s.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},9595:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),s=i(54993),n=i(29882),a=i(28874);function o(e){return(0,r.toNotBlank)((0,s.toS)(e))??a.Settings.libraryDir.valueOrDefault}t.libraryDir=o,t.originalsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,n.resolveMaybe)(o(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),s=i(55835),n=i(37805),a=i(15056),o=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${n.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function w(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+o.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function v(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function b(e){return y(v(e),!1)}function S(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(S(e))}function _(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function T(e){return y(_(e))}async function M(e){return y((0,s.map)(g(e),(e=>(0,a.pathToDbDir)(e,a.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await w(t);return(0,r.uniq)([t,i,await b(t),await P(t),await T(t),await M(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=w,t.libraryOriginalsDirPosixFile=v,t.setupLibraryOriginalsDir_=b,t.libraryPreviewsDirPosixFile=S,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=_,t.setupLibrarySyncReportsDir_=T,t.setupLibraryDbDir_=M},46296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),w=i(80612),v=i(32551);function b(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:s.default.resolve((0,v.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,v.homeDir)()}]:(0,a.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>s.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function S(){return(0,w.firstDir)({dirs:b(),desc:"logs"})}t.defaultLogDirs=b,t.defaultLogDir_=S,t.logDir=(0,n.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,o.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,o.notBlank)(i)?i:S()}catch(e){return console.error("defaultLogDir_() failed",e),s.default.resolve((0,v.homeDir)(),"logs")}}))},55939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(44198),o=i(43334),l=i(24399),u=i(32551);async function c(){return o.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,s.lazy)((async()=>{if(o.isWin){const e=await c();if((0,n.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,s.lazy)((()=>(0,a.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),s=i(7282),n=i(29325),a=i(44198);t.getDevEnvFlag=function(e){return!(0,s.isProd)()&&!(0,n.isPacked)()&&((0,r.toBoolean)((0,a.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,a.env)()[e]=String(t)}},34580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),s=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,s.env)().DO_NOT_TRACK)}},44198:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const s=r(i(73024)),n=i(76760),a=r(i(1708)),o=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),w=i(6012),v=i(96706);t.env=(0,o.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>a.default.env[e])).join(n.delimiter).split(n.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===a.default.env.PS_LICENSE||e.push((0,n.join)((0,f.homeDir)(),".psenv"));const t=(0,v.SensitiveEnvRE)(),i={...a.default.env};for(const r of e)try{const e=(0,d.debom)(s.default.readFileSync((0,p.resolve)(r))),n=(0,w.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(n))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),s=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let n;for(const a of(0,s.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(n=e.exec(a));){if(null==n.groups)continue;const{key:e,val:s}=n.groups;if((0,r.blank)(e)||null==s)continue;const a=s.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=a}}return i}},96706:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const s=r(i(1708)),n=i(19851),a=i(22573),o=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,n.lazy)((()=>(0,a.firstNotBlank)(s.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,s.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,n.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,n.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,o.isTrue)(g(e))}},98314:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),s=i(19851),n=i(40958),a=i(22573),o=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),w=i(70025),v=i(57159);function b(...e){if((0,n.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(o.errorName),...e.map(o.errorCode),...(0,n.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(o.ErrorDelimiter)))];return(0,n.uniqSubstrings)(S((0,l.flatten)(i)))}function S(e){return(0,n.compact)(e).filter((e=>!o.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(a.notBlank)}function P(e,t){const i=(0,n.uniqSubstrings)(S(e)),r=t?.maxLen??400,s=t?.trailingChars??64,a=(0,y.sortErrorFlags)([...t?.flags??[],...(0,w.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,w.stripErrorFlags)(i.join(o.ErrorDelimiter)),r-a.length,s)+a.sort().join("")}function _(e,t){return e instanceof v.WrappedError?e.toString():(0,a.blank)(e)?"":P(b(e),t)}t.StartTs=Date.now(),t.logger=(0,s.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,a.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,a.notBlank)(i))return i}},t.splitErrorMessage=b,t.normalizeErrorMessages=S,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,a.blank)(e)&&(e=t.MissingError),_(e,{maxLen:i})+" at "+(0,o.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),s=i(26905),n=i(55835),a=i(54993),o=i(81168);t.describeError=function(e){const t=(0,o.stripSuffix)((0,a.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,n.map)((0,s.errorErrno)(i),(e=>t.push(u.get(e)))),(0,n.map)((0,s.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),s=i(76790),n=i(50989),a=i(68852);t.ErrorFlags=(0,n.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,s.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(a.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},68301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorStore=t.ExtraEventsForPlease=void 0;const r=i(19851),s=i(42659),n=i(75240),a=i(55835),o=i(31586),l=i(68708),u=i(59455),c=i(54993),d=i(50213),h=i(45255),f=i(37628),m=i(99331),p=i(46292),g=i(38835),y=i(32144),w=i(29882),v=i(95696),b=i(55222),S=i(28874),P=(0,r.lazy)((()=>(0,d.mkLogger)("error.EventStore")));function _(e){return(0,l.omit)(e,"breadcrumbs")}t.ExtraEventsForPlease=7;class T{constructor(e){this.root=e}datedRoot(e=new Date){return this.root.join((0,c.toS)(e.getFullYear()),(0,c.toS)(e.getMonth()+1))}rmrf(){return this.root.rmrf()}msg2file(e){return this.datedRoot(new Date(e.timestamp*s.secondMs)).join((0,f.shortStringSha)(e.message,8,b.GeoRadix)+".json")}async eventsFrom(e=new Date,t=s.dayMs){const i=e.getTime(),r=i-t,a=i+t;return P().tap({msg:"eventsFrom()",result:(0,u.toA)(await this.datedRoot(e).clear().childFiles((async e=>P().tap({msg:"eventsFrom().childFiles() accept "+e.base,result:(0,y.isJsonExt)(e)&&!(0,w.isHiddenBasename)(e.base)&&(0,o.within)(r,a,e.mtimeMs())})))),meta:{when:e,deltaMs:(0,n.fmtDuration)(t)}})}async eventCount(e=new Date){return(await this.eventsFrom(e)).length}async eventQuotaExceeded(e){const i=(0,c.toS)(e).includes(g.PleaseSendErrorFlag)||(0,c.toS)(e.message).includes(g.PleaseSendErrorFlag),r=await this.eventCount(),s=S.Settings.maxErrorsPerDay.valueOrDefault+(i?t.ExtraEventsForPlease:0);return P().tap({msg:"eventQuotaExceeded()",result:r>=s,meta:{event:_(e),recentEventCount:r,maxErrorsPerDay:s,pleaseSend:i}})}async maybeSendEvent(e){if(e.timestamp=Math.floor(e.timestamp),(0,m.ending)())P().error("maybeSendEvent(): REJECT: we're ending.",{event:_(e)});else if(await this.eventQuotaExceeded(e))P().error("maybeSendEvent(): REJECT: too many recent events.",{event:_(e)});else try{const t=await this.writeEvent_(e);return P().tap({msg:"maybeSendEvent(): "+t==null?"REJECT: previously sent this event already this month":"ACCEPT",result:null!=t?e:void 0,meta:{eventFile:t}})}catch(e){return void P().error("maybeSendEvent(): REJECT: failed to write event.",e)}}writeEvent_(e){return this.msg2file(e).applyIfEmpty_({fn_:t=>t.writeJson_(e),minSizeBytes:3,returnUndefinedIfNotEmpty:!0,timeoutMs:h.ShortCommandTimeoutMs})}}t.ErrorStore=T,T.instance=(0,r.lazy)((()=>(0,a.map)((0,p.configDir)(),(e=>new T(v.PosixFile.for(e).join("events"))))))},70025:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),s=i(38639),n=i(26905),a=i(54993),o=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,a.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,a.toS)(e)+(0,r.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,o.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function w(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function v(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function b(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function S(e){return!!((0,s.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||b(e))||void 0}t.isSqliteBusyError=w,t.isSqliteDisconnectedError=v,t.isSqliteConstraintError=b,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===S(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,n.errorCode)(e)||w(e)||v(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=S;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,s.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,s.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},51837:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalError=void 0;const r=i(38835);class s extends Error{constructor(e){super(e+r.InternalErrorFlag)}}t.InternalError=s},8769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),s=i(31586),n=i(68708),a=i(7282),o=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,n.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const s=!0===i.fatal,c=!0===i.ignorable;if(!s&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),s&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!s||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!s||(0,a.isTest)()||(0,o.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),s}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,s.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,o.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,s.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,s.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(26905),o=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,s.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,s.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,a.errorName)(t)??(0,d.first)(this.causes,a.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(a.errorCode)],a.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,a.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,n.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,n.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,n.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,s.blank)(r)||(i=(0,h.dedupeNeedle)(i,r,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,o.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const a=i(49769),o=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),s.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,a.getOrSet)(n(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),a=n(this,r,"f").get(e);return null!=a&&(a.resolve(t),n(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,s=new WeakMap},34102:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),s=i(19851),n=i(15197);t.ee=(0,s.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new n.CapturingEventEmitter(e)}))},64660:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const s=r(i(73024)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,a.lazy)((()=>n.default.geteuid?.())),h=(0,a.lazy)((()=>n.default.getgroups?.()));function f(e,t){try{return!(0,o.blank)(e)&&(s.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,s.default.constants.R_OK|s.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,s.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:s,processGid:n}){if(null==e)return!1;const a=s??d(),o=null!=n?[n]:h()??[],l=0===a,u=l||e.uid===a,f=l||o.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const s=r(i(76760)),n=i(19851),a=i(81168),o=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,n.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,a.equalsIgnoreCase)(e.basename,i.base))return s.default.join(r,e.basename);throw new o.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),s=i(76760);function n(e){return[...a(e)]}function*a(e){for(;e!==(0,s.dirname)(e);)e=(0,s.dirname)(e),yield e}function o(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=o(e);return t.every((e=>i.includes(e)))}t.ancestors=n,t.ancestorG=a,t.selfAndAncestorG=function*(e){yield e,yield*a(e)},t.childrenSync=o,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return n(e).find((e=>l(e,t)))}},83278:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),w=f(i(1708)),v=i(46466),b=f(i(57975)),S=f(i(38522)),P=i(19851),_=i(40958),T=i(5233),M=i(22573),E=i(42659),D=i(50357),x=i(96249),k=i(98553),F=i(55835),C=i(31586),A=i(68708),I=i(97790),O=i(39926),L=i(51926),R=i(59455),N=i(54993),B=i(48884),j=i(22911),z=i(99331),V=i(56519),W=i(56038),U=i(31562),q=i(76850),H=i(70025),$=i(34102),G=i(80875),J=i(50213),K=i(70417),Y=i(43334),Z=i(81168),X=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),se=i(89968),ne=i(20197),ae=i(88561),oe=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),we=i(27794),ve=i(73428),be=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const Se=(0,P.lazy)((()=>new ae.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),s.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),a.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(s=new WeakMap,a=new WeakMap,r=new WeakSet,b.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,B.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,M.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=Se().get(i);if(null!=r)return r;const s=(0,fe.resolve)(i),n=new Pe(s,t);return Se().set(i,n),Se().set(s,n),n}static clear(e){(0,$.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,$.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,s,"f").unset(),h(this,a,void 0,"f"),this}clearThisAndParent(){return(0,$.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,F.map)(this.statSync(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,s,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",n).call(this)??await d(e=this.clearThisAndParent(),r,"m",n).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,R.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,C.gt0)(t))return;const i=await d(this,s,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,D.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,F.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,O.pad2)(t+1),(0,O.pad2)(i))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,x.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,E.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),B.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>=(0,E.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>(0,E.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,F.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*E.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,oe.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,oe.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,G.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,G.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,q.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,be.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,ve.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,ve.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,ve.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,ve.writeFileSync_)(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces),(0,A.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,we.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,we.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,T.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,z.ending)()?1:3,timeoutMs:0,retryDelay:E.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,r,"m",o).call(this,(0,Z.stripSuffix)(this.base,".gz"),S.default.createGunzip())}async gzip(){return d(this,r,"m",o).call(this,this.base+".gz",S.default.createGzip())}async compressBrotli(){return d(this,r,"m",o).call(this,this.base+".br",S.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,ne.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,ne.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(S.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,_.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new j.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,L.newlineRe)(),(r=>{const s=e.exec(r);null!=s&&(t.maybeResolve(s),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,C.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new j.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),_e)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,s)=>{try{const n=await e.f(r,(0,F.denull)(s));t(n)&&i.resolve(n)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,C.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,n=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,B.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,F.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},o=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,v.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*E.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(w.default.execPath).parent()}},19748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const r=i(28874),s=i(88840),n=i(14036),a=i(29882);function o(e){return t=>r.Settings.respectFileExtensions.valueOrDefault?(0,n.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,a.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=o,t.isBrowserExtension=o(s.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=o(s.ExtTypes.Video),t.isAssetFileExtension=o(s.ExtTypes.AssetFile)},84542:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),s=i(96249),n=i(51926),a=i(54993),o=i(43334);function l(...e){return(0,s.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,a.toS)(e).split((0,n.newlineRe)()))))}t.Newline=o.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(a.toS).join("\n");return o.isWin?t.replace((0,n.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),s=i(19851),n=i(50213),a=i(37805),o=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,s.lazy)((()=>(0,n.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,o.mkdirp_)(i),await(0,d.writeTextfile_)((0,o.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+a.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,a.lazy)((()=>[...(0,o.mapNotBlankOr)(n.default.env.SYSTEMROOT,(e=>[e,s.default.join(e,"System32"),s.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const o=n(i(44652)),l=a(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),w=i(14427),v=i(17217),b=i(16287),S=i(68284);class P{constructor(e,t){this.base=e,(0,w.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class T{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new T(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,v.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},s=await o.stat(t);return new T(i,new P(r,s))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return T.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new T(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>T.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new T(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,S.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,b.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await o.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await o.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=T},20197:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const s=r(i(76760)),n=i(39926),a=i(29882),o=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if(await(0,a.mkdirp_)(r.dir),!i.requireNumber&&await(0,o.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,o.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if((0,a.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},92423:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notInHiddenPhotoStructureDir=t.whyExcludedDirectoryRecursive=t.notExcludedDirs=t.isExcludedDirectory=t.whyExcludedDirectory=t.notExcludedDirPredicates=t.isExcludedFile=t.whyExcludedFile=t.notExcludedFilePredicates=t.excludeBundles=t.excludeGlobs=t.defaultFilePredicates=t.defaultDirPredicates=t.formatPathForGlob=void 0;const l=o(i(83058)),u=i(19851),c=i(40958),d=i(76790),h=i(22573),f=i(55835),m=i(51926),p=i(54993),g=i(48884),y=i(9092),w=i(54557),v=i(50213),b=i(88158),S=i(56519),P=i(46292),_=i(32551),T=i(35280),M=i(87290),E=i(96706),D=i(57902),x=i(43334),k=i(78984),F=i(33995),C=i(28874),A=i(21144),I=i(83278),O=i(48313),L=i(85772),R=i(78133),N=i(46356),B=i(17217),j=(0,u.lazy)((()=>(0,v.mkLogger)("fs.ExcludeGlobs"))),z=new w.FifoCache(256),V=/[\\/]$/;function W(e){const t=(0,p.toS)(e),i=z.get(t);if(null!=i)return i;const r=(0,B.isSimpleFile)(e)?e:I.BaseFile.for(e),s=V.test(t)||r.isDirectorySync(),n=(0,R.native2posix)(r.nativePath),a=s?(0,m.ensureSuffix)(n,"/"):n;return z.set(t,a),z.set(a,a),z.set(r.nativePath,a),a}t.formatPathForGlob=W;class U{constructor(e,t,i=!0){if(r.add(this),this.pattern=e,this.desc=t,this.exclude=i,e.includes("\\")){const t=e;e=(0,R.native2posix)(t),j().warn("globToPredicate(): backslash in patterns aren't supported: assuming you meant forward-slash?",{given:t,input:e})}this.reason=(0,c.compactBlanks)([this.exclude?"not":"",t,"("+(0,m.ellipsize)(e,48,12)+")"]).join(" ");try{this.re=l.default.makeRe(this.pattern,{nocase:C.Settings.globsCaseInsensitive.valueOrDefault,dot:!0,posixSlashes:!0}),this.valid=!0}catch(e){this.valid=!1,j().warn("Cannot parse pattern",{glob:this.pattern,error:e})}this.bundle=this.valid&&null!=this.re?(0,b.pairToObject)(this.reason,a(this,r,"m",s).bind(this)):{}}}r=new WeakSet,s=function(e){const t=W(e),i=this.re.test(t)??this.exclude;return j().tap({msg:"apply()",level:i?D.LogLevels.debug:D.LogLevels.trace,result:i?!this.exclude:this.exclude,meta:{desc:this.desc,pattern:this.pattern,exclude:this.exclude,posixPath:t,matched:i}})};class q{constructor(){n.set(this,[])}push(...e){for(const t of e){if(!t.valid){j().warn("Ignoring invalid glob",{glob:t});continue}const e=a(this,n,"f").find((e=>e.pattern===t.pattern));null==e?a(this,n,"f").push(t):j().debug("Ignoring duplicate glob",{glob:t,prior:e})}}pushNativePath(e,t){this.push(new U((0,R.native2posix)(e),t))}toA(){return a(this,n,"f")}}n=new WeakMap;const H=new U("**/.*","hidden file"),$=new U("**/.*/","hidden directory"),G=(0,u.lazy)((()=>{const e=new q;e.push($,H);for(const t of[{s:"bin",desc:"command binary"},{s:"dev",desc:"device file"},{s:"etc",desc:"system configuration file"},{s:"initrd",desc:"initial ramdisk"},{s:"proc",desc:"process metadata"},{s:"sbin",desc:"system binary"},{s:"snap",desc:"snap software"},{s:"sys",desc:"system metadata"},{s:"Dell",desc:"Windows driver"},{s:"Drivers",desc:"Windows driver"},{s:"Intel",desc:"Windows driver"},{s:"Microsoft",desc:"Windows driver"},{s:"NVIDIA",desc:"Windows driver"},{s:"Windows.old",desc:"Windows system"},{s:"Windows",desc:"Windows system"}])e.push(new U((x.isWin?"*":"")+"/"+t.s+"/",t.desc));if(x.isWin)for(const t of["ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemRoot","windir"]){const i=(0,E.getEnv)(t);(0,h.blank)(i)||e.pushNativePath(i,`%${t}%`)}x.isLinux&&e.push(new U(`${(0,_.homeDir)()}/snap/`,"Snap software"));for(const t of[{s:"__MACOSX",desc:"macOS resource fork"},{s:"_includes",desc:"code"},{s:"@eaDir",desc:"Synology thumbnail"},{s:"@Recently-Snapshot",desc:"QNAP snapshot"},{s:"@Recycle",desc:"QNAP trash"},{s:"@SynoResource",desc:"Synology metadata"},{s:"#recycle",desc:"Synology trash"},{s:"#snapshot",desc:"Synology snapshot"},{s:"$Recycle.Bin",desc:"Windows trash"},{s:"$SysReset",desc:"Windows"},{s:"3rdParty",desc:"code"},{s:"Application Data",desc:"Windows apps"},{s:"Application Support",desc:"macOS apps"},{s:"Applications",desc:"macOS apps"},{s:"arangodb",desc:"3rd party"},{s:"cache",desc:"Cache directory"},{s:"CacheClip",desc:"Movie cache directory"},{s:"caches",desc:"Cache directory"},{s:"Chipset_Software",desc:"Windows apps"},{s:"cmake",desc:"code"},{s:"com.apple.TimeMachine.localsnapshots",desc:"macOS"},{s:"cpan",desc:"code"},{s:"DefinitelyTyped",desc:"TypeScript type"},{s:"Desktop DB",desc:"macOS metadata"},{s:"Desktop DF",desc:"macOS metadata"},{s:"Desktop.ini",desc:"macOS metadata"},{s:"DisplayDriver",desc:"Windows driver"},{s:"DLLs",desc:"Windows library"},{s:"dyld",desc:"macOS library"},{s:"ehthumbs.db",desc:"Windows thumbnail"},{s:"i18n",desc:"i18n code"},{s:"iMovie Cache",desc:"Apple iMovie cache"},{s:"iTunes Cache",desc:"Apple iTunes"},{s:"iTunes Media",desc:"Apple iTunes"},{s:"iTunes",desc:"Apple iTunes"},{s:"lib?(32|64|x64|s)",desc:"program library directory"},{s:"lost+found",desc:"fsck recovered directory"},{s:"macOS Install*",desc:"macOS installer"},{s:"Network Trash",desc:"AFP trash"},{s:"node_modules",desc:"Node.js library"},{s:"pkgconfig",desc:"code"},{s:"pkgs",desc:"Python code"},{s:"Program Files (x86)",desc:"Windows apps"},{s:"Program Files",desc:"Windows apps"},{s:"ProgramData",desc:"Windows application support"},{s:"resources/media/face",desc:"face thumbnail"},{s:"rubygems-*",desc:"Ruby code"},{s:"site-packages",desc:"Python code"},{s:"spotifycache",desc:"Spotify cache"},{s:"SteamApps",desc:"Game files"},{s:"System Volume Information",desc:"Windows system metadata"},{s:"System32",desc:"Windows system"},{s:"SystemTemp",desc:"Windows temporary"},{s:"temp",desc:"temporary"},{s:"Temporary Items",desc:"temporary"},{s:"test_suite",desc:"code"},{s:"testutil?(s)",desc:"code"},{s:"third_party",desc:"code"},{s:"Thumbnail?(s)",desc:"thumbnail"},{s:"Thumbs.db",desc:"Windows thumbnail"},{s:"tmp",desc:"temporary"},{s:"Trash",desc:"trash directory"},{s:"Windows",desc:"Windows"},{s:"Windows.old",desc:"Windows"},{s:"Windows10Upgrade",desc:"Windows upgrade"},{s:"Xcode.app",desc:"macOS code"},{s:"*.sparsebundle/bands",desc:"Time Machine backup"},{s:"ImageMagick*",desc:"ImageMagick source"},{s:"Install OS X*",desc:"macOS installer"},{s:"Install macOS*",desc:"macOS installer"},{s:"*.lrdata",desc:"LightRoom data"},{s:"MinGW*",desc:"code"},{s:"msys*",desc:"code"},{s:"vcpkg",desc:"code"}])e.push(new U("**/"+t.s+"/",t.desc));function t(t,i,r){if(!(0,h.blank)(t)){const s=(0,d.sort)((0,c.uniq)((0,c.compactBlanks)(i).map((e=>e.toLowerCase()))));1===s.length&&e.push(new U(`**/${t}/${s[0]}/`,r)),s.length>1&&e.push(new U(`**/${t}/(${s.join("|")})/`,r))}}(0,f.map)((0,P.configDir)(),(t=>e.pushNativePath(t,"PhotoStructure configuration"))),t("nix",["store"],"NixOS package"),e.push(new U("**/*.(photo|photos|ap)library/!(master|masters|modified|original|originals)/","Apple Photos/Aperture library")),e.push(new U("**/facetile*","face thumbnail"));const i=["bin","cygdrive","dev","etc","games","include","lib?(32|64|x64)","local","locale","man","proc","sbin","share","src","tmp","usr","var"];t("usr",i,"FHS system"),t("cygwin?(64)",i,"Cygwin"),t("local",i,"FHS system"),t("Windows",["assembly","Boot","Containers","Cursors","Fonts","Help","Installer","Logs","Microsoft.NET","Servicing","SoftwareDistribution","System32","SystemApps","SysWOW64","Temp","WinSxS"],"Windows"),t("Recovery",["Customizations","OEM"],"Windows"),t("lib",["firmware","modules","systemd","udev","x86_64-linux-gnu"],"Linux system package"),t("opt",["google","x11",...i],"FHS package"),t("lfs",["incomplete","objects"],"Git LFS object");const r=["cache","crash","games","lib","local","lock","log","logs","mail","run","snap","spool","tmp"];t("var",r,"Linux /var"),t("mnt",r,"Linux /mnt"),t("dev",["block","bsg","bus","char","cpu","disk","dri","fd","hugepages","input","lightnvm","mapper","mqueue","net","pts","shm","snd","ubuntu-vg","usb","vfio"],"Linux /dev backup"),t("proc",["acpi","asound","bus","driver","fs","ipmi","irq","net","scsi","self","sys","sysvipc","thread-self","tty"],"Linux /proc backup"),t("library",["Apple","Assistant","Bluetooth","com.apple.iTunesCloud","Containers","CoreAnalytics","Developer","Desktop Pictures","Documentation","Extensions","Finance","Fonts","Frameworks","FrontBoard","Group Containers","HTTPStorages","iTunes","KeyboardServices","Keychains","Logs","Messages","News","Passes","Photos","Preferences","Ruby","Saved Application State","Scripts","User Pictures","Updates","User Template","WebKit","WebServer"],"macOS Library"),t("packages",["*.pkg","*.mpkg"],"macOS package"),t("src/**",["bin","ci","dist","doc?(s)","etc","lib?(s)","main","spec?(s)","src","test?(s)","tools","util"],"code"),t("docs",["admin","content","general","generated","sql"],"code"),t("pkg",["acceptance","ccl","cli","cmd","server","sql","storage","ui","util","workload"],"code"),t("osv",["apps","arch","compiler","external","include","java","modules","musl","tests"],"code"),t("go",["bin","blog","cmd","doc","lib","misc","pkg","src","test","vt"],"code"),t("Perl?(64)",["bin","eg","etc","html","lib","site"],"code"),t("Python*",["dlls","doc?(s)","include","lib?(s)","scripts","tools","tcl"],"code"),t("Ruby*",["bin","include","lib","msys*","packages","share","ssl"],"code"),t("msys*",["clang*","dev","etc","mingw*","tmp","ucrt*","var"],"code"),t("sdk",["build-tools","emulator","extras","patcher","platforms","platform-tools","sources","tools"],"code"),t("test",["fixtures"],"code"),t("data",["$of"],"windows backup"),t("System",["Applications","Developer","DriverKit","Library","iOSSupport"],"macOS System"),t("contents",["frameworks","plugins","resources","sharedsupport"],"macOS application"),t("pg",["pgsql"],"code");for(const e of["local","locallow","roaming"])t("appdata",[e],"Windows default AppData");return t("ps",["cache","config","logs","tmp"],"PhotoStructure docker directory"),e.toA()})),J=()=>{t.excludeGlobs.unset(),t.excludeBundles.unset()},K=()=>{t.notExcludedDirs.unset()},Y=(0,u.lazy)((()=>{C.Settings.excludeGlobsOmitDefaults.watchLater(J),C.Settings.excludeGlobsAdd.watchLater(J),C.Settings.excludeGlobsOmit.watchLater(J),C.Settings.globsCaseInsensitive.watchLater(J),C.Settings.libraryDir.watchLater(K),C.Settings.originalsDir.watchLater(K),C.Settings.scanPaths.watchLater(K),C.Settings.argvScanPaths.watchLater(K)}));t.defaultDirPredicates=(0,u.lazy)((()=>[{notSymlinkLoop:re,notInHiddenPhotoStructureDir:ne,whyNoMedia:L.whyNoMedia,notHidden:se}])),t.defaultFilePredicates=(0,u.lazy)((()=>[{notInHiddenPhotoStructureDir:ne}])),t.excludeGlobs=(0,u.lazy)((()=>{Y();const e=new y.CaseInsensitiveMap;function t(t){if(null!=t&&t.valid){const i=t.pattern.trim();e.has(i)&&j().warn("Duplicate glob:",{glob:t}),e.set(i,t)}}function i(t){const i=t.trim();e.has(i)?e.delete(i):j().warn("Failed to find and remove glob specified in PS_EXCLUDE_GLOBS_OMIT",{glob:t})}if(!C.Settings.excludeGlobsOmitDefaults.valueOrDefault)for(const e of G())t(e);for(const e of C.Settings.excludeGlobsOmit.values)i(e);for(const e of C.Settings.excludeGlobsAdd.values)t(new U(e,"(from PS_EXCLUDED_GLOBS_ADD)"));const r=(0,d.sortBy)(e.values(),(e=>(0,c.compactBlanks)(e.pattern.toLowerCase().split("/")))),[s,n]=(0,g.partition)(r,(e=>e.pattern.endsWith("/")));return{dir:s,file:n}})),t.excludeBundles=(0,u.lazy)((()=>{const e=(0,t.excludeGlobs)();return{dir:[...(0,t.defaultDirPredicates)(),...e.dir.map((e=>e.bundle))],file:[...(0,t.defaultFilePredicates)(),...e.file.map((e=>e.bundle))]}}));const Z=[{disableAllFilters:()=>!0}],X=[{notBlank:()=>!1}];function Q(e){return C.Settings.disableAllFilters.valueOrDefault?Z:(0,h.blank)(e)?X:(0,t.excludeBundles)().file}function ee(e){return F.SyncPredicates.whyRejected(e,...Q(e))}function te(e){return C.Settings.disableAllFilters.valueOrDefault?Z:(0,h.blank)(e)?X:(0,t.excludeBundles)().dir}async function ie(e){return C.Settings.disableAllFilters.valueOrDefault?void 0:k.Predicates.whyRejected(e,...te(e))}function re(e){return!(0,N.seemsLikeSymlinkLoop)(e)}function se(e){return(0,S.thenNot)((0,O.isHidden)(e))}function ne(e){return!(0,T.inHiddenPhotoStructureDir)(e)}t.notExcludedFilePredicates=Q,t.whyExcludedFile=ee,t.isExcludedFile=function(e){return null!=ee(e)},t.notExcludedDirPredicates=te,t.whyExcludedDirectory=ie,t.isExcludedDirectory=async function(e){return null!=await ie(e)},t.notExcludedDirs=(0,u.lazy)((async()=>{const e=(0,c.uniq)((0,c.compactBlanks)([(0,M.libraryDirPosixFile)(),(0,M.libraryOriginalsDirPosixFile)(),...C.Settings.argvScanPaths.values,...C.Settings.scanPaths.values]));return j().tap({msg:"notExcludedDirs() (these directories will never be excluded)",level:"info",result:(0,c.uniq)([...e,...await Promise.all(e.map((e=>(0,A.actualPath)(e))))])})})),t.whyExcludedDirectoryRecursive=async function(e){const i=await(0,t.notExcludedDirs)();for(let t=e;null!=t&&!t.isRoot;t=await(t?.parent())){if(i.includes(t?.nativePath))return;const e=await ie(t);if(null!=e)return e}},t.notInHiddenPhotoStructureDir=ne},88561:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const a=i(40958),o=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class w extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>n(this,r,"m",s).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,a.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=w,r=new WeakSet,s=async function(e){if((0,o.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),s=i(22573),n=i(45599),a=i(96249),o=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,n.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,s.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,a.flatten)((0,o.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),s=i(17217),n=i(16287),a=i(68284);async function o(e){return(0,r.pick)(await(0,n.stat_)((0,s.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=o,t.fileStats=async function(e){try{return await o(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,a.statSync)((0,s.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const r=i(68817),s=i(19851),n=i(22573),a=i(50213),o=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),h=i(95696),f=i(93854),m=i(16287),p=(0,s.lazy)((()=>(0,a.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,f.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,r.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const s=(0,n.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),a=(0,l.normalizeExt)(h.PosixFile.for(e))??(0,c.mimetypeExt)(s);return(0,n.blank)(s)||(0,n.blank)(a)?void 0:{ext:a,mime:s}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new o.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,s.set(this,[]),n.set(this,void 0),a.set(this,void 0),l(this,a,(0,f.fileStatsSync)(e),"f"),l(this,n,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",o).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,s,"f").push(e)}close(){u(this,n,"f").close()}}t.FileWatcher=m,s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,a,"f"),t)){l(this,a,t,"f");for(const t of u(this,s,"f"))t(e,this.nativePath)}}},73209:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,w,v,b=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},S=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const _=i(58587),T=P(i(44652)),M=i(87997),E=i(40958),D=i(17586),x=i(42659),k=i(50357),F=i(75240),C=i(55835),A=i(31586),I=i(30976),O=i(13538),L=i(54993),R=i(7282),N=i(68852),B=i(23560),j=i(25764),z=i(38836),V=i(99331),W=i(22781),U=i(38835),q=i(55222),H=i(63870),$=i(69734),G=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)($.PsLockExt)+"$");class K extends z.EndableWrapper{static newUid(e=process.pid){return S(this,s,Math.max(Date.now(),b(this,s,"f",n)+1),"f",n),(0,E.compactBlanks)([q.TokenRadix.encode(b(this,s,"f",n)),B.serviceName.prior(),(0,L.toS)(e)]).join("-")}static pidFromLockfile(e){return s.pidFromBasename((0,G.basename)(e))}static pidFromBasename(e){return(0,A.toInt)(J.exec((0,L.toS)(e))?.groups?.pid)}static for(e){return b(this,s,"f",o).find((t=>t.opts.file===e.file))??new s(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>b(this,r,"m",v).call(this)),e.endableRank??j.EndableRanks.postdb,(0,H.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,S(t=s,s,(i=b(t,s,"f",a),++i),"f",a)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(b(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,$.fsLockFileBasename)(s.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await b(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,$.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+b(this,l,"f")),this.staleMs=(0,A.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),b(s,s,"f",o).push(this)}get acquired(){return b(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await b(this,r,"m",f).call(this,e)??b(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,D.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,k.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==b(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:x.secondMs);S(this,c,setInterval((()=>b(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=b(this,c,"f")&&(clearInterval(b(this,c,"f")),S(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(b(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),S(this,u,!1,"f"),(0,C.map)(b(this,d,"f"),(e=>(0,M.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?b(this,r,"m",w).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),S(this,d,setTimeout((()=>b(this,r,"m",w).call(this)),(0,A.toGt0)(this.staleMs)??x.secondMs),"f"),b(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(b(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,O.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,s=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,r=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,A.gt0)(this.staleMs)&&Date.now()>b(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await b(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){S(this,h,Date.now(),"f");const e=[],t=await b(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,A.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+x.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,$.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;s.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const n=i[0]===this.lockfile.base;if(n)S(this,u,!0,"f");else if(!0!==t?.vacuum){const t=s.pidFromBasename(i[0]);if((0,A.gt0)(t)&&!(0,_.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),b(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:n,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await b(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},w=async function(){await b(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},v=function(){(0,E.filterInPlace)(b(s,s,"f",o),(e=>b(e,l,"f")!==b(this,l,"f")))},n={value:0},K.internalErrors=0,a={value:0},o={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),s=i(51926),n=i(54993),a=i(17217);function o(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,s.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,s.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,n.toS)(e)))return;const i=(0,a.basename)(e);return o(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&o((0,a.basename)(e))}},4001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),s=i(55835),n=i(31586),a=i(51926),o=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,r.toNotBlank)(e.name)??(0,o.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,n.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:f(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const s=(0,u.parsePosixPath)(i),n=h(s,{aggressive:!1});return[...t,n+s.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,a.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),r=(0,a.stripPrefix)(t.toLowerCase().normalize(),i);return(0,s.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,a.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,s.map)(m.exec(t),(e=>t=e[1].trim())),(0,s.map)(g.exec(t),(e=>t=e[1].trim())),t}},19254:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fileGrep_=t.GrepReader=void 0;const s=r(i(73024)),n=i(57075),a=i(46466),o=i(54993),l=i(33456),u=i(17217),c=i(58722);class d extends n.Transform{constructor(e,t="\n"){super({objectMode:!1,autoDestroy:!0}),this.pattern=e,this.sep=t}_transform(e,t,i){const r=(0,o.toS)(e).match(this.pattern);null!=r&&this.push(r[1]??r[0]+this.sep),i()}}t.GrepReader=d,t.fileGrep_=async function(e,t){const i=new c.WritableToBuffer;return await(0,a.pipeline)([s.default.createReadStream((0,u.toNativePath_)(e)),new l.LineReader,new d(t),i]),(await i.buffer).toString()}},14977:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const s=r(i(44652)),n=r(i(73024)),a=i(46466),o=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,a.pipeline)(n.default.createReadStream(e,{autoClose:!0}),o.default.createGzip(),n.default.createWriteStream(t,{autoClose:!0})),await s.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const s=r(i(77598)),n=r(i(73024)),a=i(46466),o=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),w=i(16287),v=(0,o.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),b=(0,o.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function S(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=b().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return v().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;v().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),b().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await _(n.default.createReadStream(i)),stats:(0,u.pick)(await(0,w.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],i="sha512"){const r=s.default.createHash(i);return await(0,a.pipeline)([e,...t,r]),r.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:b,impl:P}),t.fileShaMeta_=S,t.fileSha_=async function(e){return(await S(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return s.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),s=i(42659),n=i(55835),a=i(31586),o=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,o.stdout_)("chflags",["hidden",t],{timeoutMs:10*s.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,n.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,o.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*s.secondMs}),i=(0,a.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),s=i(54993),n=i(7282),a=i(43334),o=i(69375),l=/^\/dev(?:\/|$)/i,u=a.isMac||(0,n.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=a.isMac||(0,n.isTest)()?/^\/private\//i:void 0,d=a.isMac||(0,n.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=a.isMac||(0,n.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,s.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,o.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},87128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonFileStore=void 0;const r=i(19851),s=i(55835),n=i(57159),a=i(50213);t.JsonFileStore=class{constructor(e,t,i){this.file=e,this.mkObject=t,this.onWrite=i,this.prior=(0,r.lazy)((()=>this.file.readJson("debug")))}async read_(){return await this.prior()??(0,s.map)(await this.mkObject(),(e=>this.write_(e)))}async write_(e){try{return await this.file.writeJson_(e,{spaces:2}),this.prior.set(Promise.resolve(e)),(0,a.mkLogger)("fs.JsonFileStore").info("wrote to "+this.file,e),null!=this.onWrite&&await this.onWrite(this.file,e),e}catch(e){throw new n.WrappedError("Failed to write to "+this.file,{cause:e,path:this.file.nativePath})}}}},33456:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),s=i(51926),n=i(54993);class a extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,n.toS)(e)).split((0,s.newlineRe)()),a=r.pop();this._prior=a??"";let o=!1;for(const e of r)o||(o=!this.push(e));o?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=a},64680:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const s=r(i(76760)),n=i(17217),a=i(73428);t.mkNoMedia_=function(e){return(0,a.writeTextfile_)(s.default.join((0,n.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},61704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nativePathsEql=t.nativePathsEqlSync=void 0;const r=i(21144),s=i(17217);t.nativePathsEqlSync=function(e,t){if(null==e||null==t)return!1;if(e===t)return!0;try{const i=(0,s.toNativePath_)(e),r=(0,s.toNativePath_)(t);return null!=i&&null!=r&&i===r}catch{return!1}},t.nativePathsEql=async function(e,t){try{return null!=e&&null!=t&&await(0,r.actualPath_)((0,s.toNativePath_)(e))===await(0,r.actualPath_)((0,s.toNativePath_)(t))}catch{return!1}}},85772:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const a=n(i(76760)),o=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),w=i(83278),v=i(70698),b=i(88561),S=i(65238),P=i(16287),_=(0,o.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),T="NoMedia",M=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(a.default.sep),"/"]).join("")+"])\\.?"+T+"$","im"),E=Object.freeze(["."+T,T]),D=Object.freeze((0,u.flatten)(E.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function x(e){return null!=M.exec(e)}t.isNoMediaName=x;const k=(0,o.lazy)((()=>new b.FileCache({name:"fs.noMediaDirsCache"})));async function F(e,t){if(null==e)return null;const i=w.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return x(i.base)||await(0,v.isCachedirTagFile)(i)?k().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):F(i.parent());{const e=await k().getOrSetAsync(i.nativePath,(()=>C(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:F(i.parent())}}async function C(e){if(x(e.base))return k().set(e.parent().nativePath,e.nativePath),_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,S.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,r=await Promise.race([A(e.nativePath,i),(0,S.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,v.isCachedirTagDirectory)(e)?_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(v.CACHEDIR_TAG).nativePath)}):null}async function A(e,t){for(const i of g.isCaseSensitiveFs?D:E){if(!0===t?.aborted)return null;const r=a.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return _().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function I(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(x(r.basename))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,a.join)(e,r.basename))});if(r.basename===v.CACHEDIR_TAG){const t=(0,a.join)(e,r.basename);if(await(0,v.isCachedirTagFile)(t))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await F(e,t)},t.whyNoMedia=F,t.whyNoMediaDir=C,t._dirHasNoMediaChild=A},29882:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),w=i(78133),v=i(53265),b=i(17217),S=i(16287),P=i(66430),_=i(5545);function T(e){return((0,b.isSimpleFile)(e)?e.base:n.default.basename(n.default.resolve(e))).startsWith(".")}t.logger=(0,a.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=T,t.containsHiddenPathname=function(e){return F(e).some(T)},t.isNotHiddenPosixPath=function(e){return F(e).every((e=>!T(e)))},t.resolveSimpleFile=function(e){return(0,b.isSimpleFile)(e)?e.nativePath:(0,v.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,v.resolve)(...e)},t.parsePosixPath=function(e){return E((0,w.posix2native)(e))},t.extname=function(e){return E(e).ext},t.dirname=function(e){return n.default.dirname((0,b.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(n.default.parse(e).ext,n.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function E(e){const t=M.exec(e)?.groups,i=t?.ext2??"",r=n.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function D(e){const t=n.default.parse((0,b.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,n.default.sep)}function x(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,b.toNativePath_)(e.ancestor),i=(0,b.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,n.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function k(e,t,i){if(null==t||null==i)return!1;const r=e(t),s=e(i);return null!=r&&null!=s&&(y.isLinux?r===s:(0,p.equalsIgnoreCase)(r,s))}function F(e){return(0,b.isSimpleFile)(e)?e.pathnames:e.split(n.default.sep).filter((e=>null!=e&&""!==e))}function C(e){return(0,u.notBlank)(e)&&F(e).length===(y.isWin?1:0)}function A({p:e,maxLength:t}){const i=(0,b.toNativePath_)(e);if(i.length<=t)return i;const r=F(e),s=[],n=[r.pop()];for(;r.length>0;)if(s.length=t){r.unshift(s.pop());break}}else if(n.unshift(r.pop()),O([...s,...n]).length>=t){r.push(n.shift());break}return r.length>0&&s.push("…"),O([...s,...n])}function I(e){return e.startsWith("\\\\")}function O(e){return(0,h.ensurePrefix)((0,o.compactBlanks)(e).join(n.default.sep),y.isWin?"":n.default.sep)}t.parseNativePath=E,t.parentBasename=D,t.grandParentBasename=function(e){return D(n.default.parse((0,b.toNativePath_)(e)).dir)},t.containedByNativePath=x,t.eqlBasename=function(e,t){return k(b.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return k(b.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return k(b.toNativePath_,e,t)},t.toPathnames=F,t.pathIsRoot=C,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:F(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,b.toNativePath_)(e),r=(0,b.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,w.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,w.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=A,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const s=[];for(const r of e.slice(0,i))s.push(A({p:r,maxLength:t}));return s.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return F(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return F(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=E(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,S.isReadableDirectory)(e))return;if(C(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await s.default.mkdirp(e)}catch(t){if(await(0,S.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;s.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>s.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,b.toNativePath_)(e).split(n.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=O,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:O(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>x({ancestor:t,descendant:e,acceptSelf:!0})?[(0,b.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),w=i(64660),v=i(21144),b=i(16287),S=(0,n.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const i=await(0,b.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,w.isStatRX)(i,e)}function T(){if(y.isWin){const e=(0,o.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,o.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,o.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,s.default.join(e,"System32"),s.default.join(e,"System32","Wbem"),s.default.join(i,"chocolatey","bin"),s.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(s.default.delimiter);return(0,a.uniq)((0,a.compactBlanks)([...e,...T()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,a.uniq)((0,a.compactBlanks)([...M(),...(0,d.toA)(i)]));for(const i of(0,a.uniq)((0,a.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=s.default.join(t,e);if(await _(i))return y.isLinux?i:(0,v.actualPath)(i)}}S().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,w.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){"use strict";var r,s,n,a=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return o(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),w=i(76790),v=i(5233),b=i(22573),S=i(42659),P=i(26905),_=i(75240),T=i(55835),M=i(31586),E=i(68708),D=i(13538),x=i(89937),k=i(12168),F=i(54993),C=i(48884),A=i(50213),I=i(45255),O=i(81168),L=i(56519),R=i(56038),N=i(31562),B=i(84777),j=i(9595),z=i(38835),V=i(70025),W=i(57902),U=i(55222),q=i(43334),H=i(33847),$=i(24399),G=i(28874),J=i(79915),K=i(45200),Y=i(34238),Z=i(87001),X=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),se=i(73209),ne=i(48313),ae=i(29882),oe=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,C.contextFilter)(function(e){return(0,w.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,A.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Y.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,L.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,L.thenMapOr)((0,X.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>q.isMac?(0,B.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,b.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,b.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,O.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,oe.toNativePath_)(e),r=new fe(i,t);return(0,O.isString)(e)&&he().set(e,r),he().set(i,r),r}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,L.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,ae.containedByNativePath)({ancestor:(0,j.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,ae.containedByNativePath)({ancestor:(0,j.originalsDir)(),descendant:this,acceptSelf:!0}))return q.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,T.map)((0,ee.bestMountpoint)(this.nativePath,await(0,X.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,T.map)((0,b.notBlankOr)(e,(()=>this.uri_())),Y.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,F.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===x.PS_LIBRARY_SCHEME?1:t.scheme===x.PS_LOCAL_FILE_SCHEME?2:t.scheme===x.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,O.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(q.isWin||q.isMac)return this.trap("hide",(async()=>(await(0,ne.hide_)(this),this)))}async hidden(){return(0,ne.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,O.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,C.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,T.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,E.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:s,skipWip:n=!1,skipFsLock:a=!1,retries:o=2,dirty:l=!1}){return(0,v.retryOnReject_)((async()=>{const o=await this.clear().isNonEmptyFile(i);if(!o){if(n&&a)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:a,minSizeBytes:i,timeoutMs:s,dirty:l})}return o&&r?void 0:this.utimes()}),{maxRetries:o,timeoutMs:2*s,retryDelay:3*S.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,M.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:s,dirty:n=!1}){return await this.parent().mkdirp_(),(0,se.withLock_)({file:this,skipFsLock:r,timeoutMs:s,dirty:n},(async()=>{const r=this.wip();try{await r.unlink("trace");const n=await(0,D.thenOrTimeoutError)(e(r),s);if(n===t.NoOp)return n;if(await(0,N.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),n;throw new Error(this+"applyWip(): still empty after waiting "+(0,_.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==G.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",s).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",n).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();G.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:S.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,M.clamp)(I.ShortCommandTimeoutMs,10*S.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,b.notBlank)(this.ext)&&(0,b.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,S.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,T.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,L.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,O.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,ae.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,ae.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,Z.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,r=new WeakSet,s=async function(e){let t,i=e;const r=e.wip();try{const s=await this.stat_();if(null==s)return this.pflog().throw("Can't copy missing files"+z.NonRetriableErrorFlag);if(s.size>0){if(G.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+z.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,r.nativePath,h.default.constants.COPYFILE_FICLONE),s.size>5*k.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},s.size,(()=>r.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,M.approximates)(s.size,await r.size({refresh:!0}))),{intervalMs:S.secondMs,timeoutMs:S.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:s.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:s.birthtimeMs,mtimeMs:s.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,s.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${s.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,T.map)(t,(e=>e.end()))}},n=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),s=r?.size;return null==r||null==s?this.pflog().throw("Can't copy missing files"):(s>5*k.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},s,(()=>e.clear().size()))),q.isWin?await $.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,$.pwshQuote)(this.nativePath)} -Destination ${(0,$.pwshQuote)(i.nativePath)}`,(e=>e)):q.isMac?await(0,B.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,B.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+z.DoNotSendErrorFlag,{error:t})}finally{(0,T.map)(t,(e=>e.end()))}}},62105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.acceptFile=t.whyRejectFile=t.expensiveFileFiltersFor=t.acceptParentAndFileAndSimple=t.acceptFileSimple=t.whyRejectFileSimple=t.simpleFileFiltersFor=t.notFileTooBig=t.notFileTooSmall=t.notFileMissing=t.hasBrowserImgMimeType=t.notDimensionsTooSmall=t.requiredTagsFilter=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(54993),o=i(48884),l=i(56519),u=i(78984),c=i(28874),d=i(43207),h=i(47783),f=i(97573),m=i(16170),p=i(54979),g=i(1078),y=i(42231),w=i(83278),v=i(19748),b=i(92423),S=i(16287);function P(e){return async t=>(0,l.thenMapOr)((0,h.readRawTags)(t,!1),e,(()=>!1))}async function _(e){if(!(0,n.gt0)(c.Settings.minVideoDimension.valueOrDefault)&&!(0,n.gt0)(c.Settings.minImageDimension.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);if(null==t||!t.startsWith("image/")&&!t.startsWith("video/"))return!1;const i=t.startsWith("video/")?c.Settings.minVideoDimension.valueOrDefault:c.Settings.minImageDimension.valueOrDefault;return(0,n.gt0)(i)?(0,l.thenMapOr)((0,g.extractSizeInfoFromFile)(e),(e=>(0,n.gte)(e.ImageWidth,i)&&(0,n.gte)(e.ImageHeight,i)),(()=>!1)):null}async function T(e){if(!(0,n.gt0)(c.Settings.minVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.gte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.minVideoDurationSec.valueOrDefault):null)}async function M(e){if(!(0,n.gt0)(c.Settings.maxVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.lte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.maxVideoDurationSec.valueOrDefault):null)}async function E(e){return!(0,s.blank)(await(0,p.readMimeType)(e))}async function D(e){if(-100===c.Settings.rejectRatingsLessThan.valueOrDefault)return null;const t=await(0,h.readTags)(e),i=(0,n.toInt)(t?.Rating);return null==i||i>=c.Settings.rejectRatingsLessThan.valueOrDefault}async function x(e){return 0===c.Settings.keywordBlocklist.values.length?null:(0,f.rawTagKeywords)(await(0,h.readTags)(e)).every((e=>!0!==(0,y.leafIsExcluded)(e,c.Settings.keywordBlocklist.values)))}async function k(e){if(!c.Settings.requireMakeModel.valueOrDefault)return null;const t=await(0,h.readRawTags)(e);return null==t||(0,s.blank)(t.MIMEType)?null:t.MIMEType.startsWith("image/")?null!=t&&(0,s.notBlank)(t.Make)&&(0,s.notBlank)(t.Model):null}async function F(e){return(0,w.isBaseFile)(e)?e.exists():(0,S.exists)(e.nativePath)}async function C(e){const t=c.Settings.minAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.gte)(i,t)}async function A(e){const t=c.Settings.maxAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.lte)(i,t)}function I(e){return[{isSupportedFileExtension:v.isAssetFileExtension},...(0,b.notExcludedFilePredicates)(e),{notFileMissing:F},{notFileTooSmall:C,notFileTooBig:A}]}function O(e){return[...I(e),{notMissingMimeType:E},{supportedMimeType:m.isAssetFileMimeType},{notMissingMakeAndModelTags:k},{notDimensionsTooSmall:_},{notVideoTooShort:T},{notVideoTooLong:M},{notRejectedRating:D},{notExcludedKeyword:x}]}async function L(e,t){return await u.Predicates.whyRejected(e,...t??O(e))??await(0,b.whyExcludedDirectoryRecursive)(e.parent())}t.requiredTagsFilter=function(e){return P((t=>(0,o.allNotBlank)(...e.map((e=>t[e])))))},t.notDimensionsTooSmall=_,t.hasBrowserImgMimeType=P((e=>(0,r.includes)(["image/jpeg","image/png"],(0,a.toS)(e.MIMEType)))),t.notFileMissing=F,t.notFileTooSmall=C,t.notFileTooBig=A,t.simpleFileFiltersFor=I,t.whyRejectFileSimple=function(e){return u.Predicates.whyRejected(e,...I(e))},t.acceptFileSimple=function(e){return u.Predicates.accepted(e,...I(e))},t.acceptParentAndFileAndSimple=async function(e){const t=await e.parent();return null!=t&&!await(0,b.isExcludedDirectory)(t)&&await u.Predicates.accepted(e,...I(e))},t.expensiveFileFiltersFor=O,t.whyRejectFile=L,t.acceptFile=async function(e){return null==await L(e)}},78133:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const s=r(i(76760)),n=i(22573),a=i(81168);t.posix2native=function(e,t){if((0,n.blank)(e))return e;if(s.default.sep===s.default.posix.sep)return e;const i=(0,n.notBlank)(t)?s.default.sep+s.default.sep+t+s.default.sep:"",r=e.split(s.default.posix.sep);return(0,a.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(s.default.sep)},t.native2posix=function(e){return(0,n.blank)(e)||s.default.sep===s.default.posix.sep||s.default.posix.sep===s.default.sep?e:e.split(s.default.sep).join(s.default.posix.sep)}},43899:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,a.lazy)((()=>s.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,a.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(s.default.join((0,p.execDir)(),"resources"),s.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,o.compactBlanks)([(0,p.execDir)(),n.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const r=s.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),s=i(19851),n=i(31586),a=i(50213),o=i(57902),l=i(69428),u=(0,s.lazy)((()=>(0,a.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=o.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,n.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),s=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let n=-1;try{const s=i??(await(0,r.stat)(e)).size-t,a=Buffer.alloc(s);return n=await(0,r.open)(e,"r"),await(0,r.read)(n,a,0,s,t)}finally{(0,s.mapGte0)(n,r.close)}}},69428:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const a=n(i(73024));t.readFileSync=function(e){try{return a.readFileSync(e)}catch{}}},55690:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),s=i(84542);t.readLines_=async function(e){return(0,s.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class s extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=s},65238:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const s=r(i(51455)),n=i(76760),a=i(19851),o=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),w=i(28874),v=i(63870),b=i(88561),S=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,a.lazy)((()=>(0,n.join)(w.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,a.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await s.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const T=(0,a.lazy)((()=>new b.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,v.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||T.prior()?.delete(e)}async function E(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await T().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,S.statTimeoutMs)(),r=D(e),s=await(0,h.thenOrTimeout)(r,(0,d.toGt0)(w.Settings.fsCacheSlowMs.valueOrDefault)??(0,S.statTimeoutMs)());if(s===f.Timeout&&(0,g.onTimeout)({soft:!1}),s!==f.Timeout&&s.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{w.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),T.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,a.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!T().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=T().get(e)},t.childDirectories_=async function(e){return(await E(e)).filter((e=>e.isDirectory)).map((t=>(0,n.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(w.Settings.readdirCacheMs.valueOrDefault)?E(e):D(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=E,t.readdirCached=function(e){return T().get(e)},t.readdirUncached_=D},53265:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const s=i(73024),n=r(i(76760)),a=i(40958),o=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,a.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=n.default.resolve(t,...e);if((0,s.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,o.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(o.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??n.default.resolve(...e))},t.execDir=(0,l.defer)((()=>n.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},46356:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.seemsLikeSymlinkLoop=void 0;const r=i(22454),s=i(28874),n=i(29882);t.seemsLikeSymlinkLoop=function(e){const t=new r.CountingSet;for(const i of(0,n.toPathnames)(e))t.incr(i.toLowerCase().normalize());return t.max()>s.Settings.maxDuplicatePathElements.valueOrDefault}},50274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),s=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,s.isBoolean)(e.isFile)&&(0,s.isBoolean)(e.isDirectory)}},17217:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const s=r(i(73024)),n=r(i(76760)),a=i(22573),o=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,a.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,a.blank)(e.nativePath))throw new Error(`toNativePath(${(0,o.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof s.default.Dirent?e.name:f(e)?e.base:n.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:n.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(n.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function w(e){return(0,o.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(s.default.stat(e),(0,g.statTimeoutMs)(),!0)}function v(e,t=f.LogLevels.debug){return(0,o.blank)(e)?void 0:w(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function b(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function S(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=b(e),r=b(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],s=t[i],n=(0,u.diff)(S(r),S(s));if(null==n||n>1)return"unmatched "+i+": "+r+" ≠ "+s}}t.stat_=w,t.statMaybe=v,t.statToType=b,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await v(e,t)},t.isEmptyFile=async function(e,t){const i=await v(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await v(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await v(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await v(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await v(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await v(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await v(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,a.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const s=r(i(73024)),n=i(22573);function a(e){try{return(0,n.blank)(e)?void 0:s.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function o(e){return null==e||e.isFile()&&0===e.size}t.statSync=a,t.isEmptyStats=o,t.isFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=a(e);return t.emptyIsNew?null==i:o(i)},t.isNonEmptyFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===a(e)?.isDirectory()}},41080:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),s=i(56409);t.onDataChunked=function(e,t,i){const r=new n(t,i,!0);return r.read(e),r.done};class n{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new s.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=n},95705:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const s=r(i(57075)),n=i(41400),a=i(55835),o=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends s.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,n.delay)(50);try{(0,o.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,a.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends s.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const s=r(i(73024)),n=i(76760),a=i(22573),o=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,a.blank)(e))return!1;try{return s.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,o.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,a.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,a.notBlank)(t)){const e=(0,n.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,a.blank)(e)&&d((0,u.posix2native)(e))}},74128:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncReport=t.syncReport=t.recentSyncReports=t.ensureSyncReportReadme=t.syncReportReadme=t.syncReportDir=t.SyncReportHeaders=t.isRejectedState=t.SyncReportStates=t.SyncDirStates=t.FileDoneStates=t.SyncFileStates=t.AssetFileSyncStates=void 0;const p=i(51168),g=i(73024),y=i(4927),w=i(19851),v=i(40958),b=i(22573),S=i(42659),P=i(98553),_=i(31586),T=i(68708),M=i(50989),E=i(51926),D=i(85556),x=i(54993),k=i(89788),F=i(23467),C=i(7282),A=i(23560),I=i(77377),O=i(71567),L=i(73568),R=i(25764),N=i(38836),B=i(99331),j=i(12959),z=i(87290),V=i(46296),W=i(98314),U=i(38835),q=i(5012),H=i(32144),$=i(95696),G=i(36868),J=i(57902),K=i(28874),Y=i(84542),Z=i(73428);t.AssetFileSyncStates=(0,M.strEnum)("noop","deleted","skipped","synced","unknown"),t.SyncFileStates=(0,M.strEnum)(...t.AssetFileSyncStates.values,"canceled","rejected","failed","timeout","enqueued","started","copied","blocklisted","note"),t.FileDoneStates=(0,I.diff)(t.SyncFileStates.values,["enqueued","started","note"]),t.SyncDirStates=(0,M.strEnum)("scanning","canceled","failed","timeout","skipped","scanned"),t.SyncReportStates=(0,M.strEnum)(...t.SyncFileStates.values,...t.SyncDirStates.values),t.isRejectedState=function(e){return null==e||["canceled","deleted","failed","rejected","timeout","unknown"].includes(e)};const X={enqueued:"the file looks promising, and will be attempted to be imported soon.",rejected:"the file did not pass all import filters. The details column will explain why.",started:"the file was dequeued from the work queue, and is now going to be processed.",noop:"the current file metadata already matches your library database, so no operation was needed to sync this file.",deleted:"the file was determined to be deleted (the prior mountpoint exists, but the file doesn't exist anymore)",skipped:"the file lives on a volume that isn't currently mounted.",synced:"the file was imported.",blocklisted:"the file was blocklisted and files with the same SHA will not be imported in the future.",failed:"something went wrong. The details column will explain why.",timeout:"the file wasn't processed in a reasonable amount of time.",copied:'"automatic organization" is enabled (copyAssetsToLibrary=true), and the photo or video was copied into your library originals directory. The details column will contain the source file path.',note:"sidecars will be referenced here. The details column will specify which source file(s) it will be associated with.",canceled:"PhotoStructure was shut down while the file was processed.",unknown:"an internal error occurred during processing."},Q={scanning:"the directory contents are about to be read.",scanned:"the directory contents were completely processed.",skipped:"the directory was excluded. The details column will explain why.",canceled:"PhotoStructure was shut down before the directory was processed.",failed:"reading the directory contents failed.",timeout:"reading the directory contents took too long."};function ee(e){return(0,T.entries)(e).map((([e,t])=>` - "${e}": ${t}`)).join("\n")}const te=new Set([t.AssetFileSyncStates.deleted,t.SyncFileStates.failed,t.SyncFileStates.timeout,t.SyncDirStates.canceled]);function ie(){return(0,z.librarySyncReportsDir)()??$.PosixFile.for((0,V.logDir)()).join("sync-reports")}function re(){return ie().join("README.txt")}t.SyncReportHeaders=(0,M.strEnum)(...(0,T.keys)(new class{constructor(e,t,i,r,s,n,a,o,l={}){this.ts=e,this.at=t,this.path=i,this.state=r,this.from=s,this.elapsedMs=n,this.details=a,this.url=o,this.meta=l}}(0,"","","unknown","",0,"",""))),t.syncReportDir=ie,t.syncReportReadme=re,t.ensureSyncReportReadme=(0,w.lazy)((()=>(0,Z.writeTextfile_)(re().nativePath,(0,E.wrap)(`\n\nHowdy from PhotoStructure!\n\nThis directory contains your recent "sync reports". \n\nThese files are written as your scan paths are examined for photos and videos.\n\nPhotoStructure creates a new file when it restarts and when it completes importing a given scan path directory.\n\nThese CSV files can be opened with most spreadsheet applications, like LibreOffice.\n\n\nColumn descriptions\n===================\n\nThe "ts" column is the timestamp for the row, in millis from 1970-01-01. Most spreadsheet applications don’t know how to parse these values, though, so we also add the at column.\n\nThe "at" column is ts in ISO format with only second resolution, and should be parsable by most spreadsheet software.\n\nThe "path" column is the native path of the directory or file. It will be empty for messages about system state.\n\nThe "state" column explains why that row was added.\n\nThe "from" column specifies which codepath added the sync report row.\n\nThe "elapsedMs" column is only added to rows completing a given path, and records how long that process took.\n\nThe "details" column will include information about the path, like why a given file or folder were rejected.\n\nThe "url" column is only added to rows when a file or directory is imported. You may need to adjust the domain name of the URL to make it work correctly (it defaults to localhost).\n\n\nDirectory state values\n======================\n\nThe "state" column for directories will be\n\n${ee(Q)}\n\n\nFile state values\n=================\n\nThe "state" column for files will be\n\n${ee(X)}\n\n\nSee https://photostructure.com/go/sync-reports\n\n`,{maxLineLen:80}).join("\n")))),t.recentSyncReports=async function(e=S.dayMs){const t=Date.now()-e;return ie().descendants((async e=>(0,H.isCsvExt)(e)&&(0,_.gte)(e.mtimeMs(),t)))},t.syncReport=(0,w.lazy)((()=>new se));class se extends N.EndableWrapper{constructor(){super("fs.SyncReport()",(()=>f(this,r,"m",d).call(this)),R.EndableRanks.predb),r.add(this),s.set(this,void 0),n.set(this,void 0),a.set(this,void 0),o.set(this,0),l.set(this,0),this.outputFiles=new k.BoundedList(64),(0,t.ensureSyncReportReadme)()}get outputNativePath(){return f(this,s,"f")?.nativePath}get rowCount(){return f(this,l,"f")}onProgress(e){if(null==e||(0,b.blank)(e.state))return this.logger.error(".onProgress(): invalid input",{s:e,from:(0,q.stack)()});{this.logger.log(te.has(e.state)?J.LogLevels.warn:J.LogLevels.info,"onProgress()",e);const t=Date.now(),i={path:(0,x.toS)(e.path),state:e.state,details:(0,x.toS)(e.details).trim().replace(/\r?\n/g,"; ")},s={ts:t,at:new Date(t).toISOString(),...i,...(0,T.pick)(e,"from","elapsedMs","url")};(0,T.isEmptyObj)(e.meta)||(s.meta=(0,P.stringify)(e.meta)),(0,C.isTest)()&&process.stdout.write((0,P.stringify)(e)+Y.Newline),f(this,r,"m",u).call(this,s)}}maybeSystemData(e){(0,A.isSyncService)()&&this.onProgress(e)}async wrap_({path:e,from:i,fn_:r}){const s=Date.now();this.onProgress({path:e,from:i,state:t.SyncFileStates.started});try{const n=await r(),a=n.state??(null!=n.error?t.SyncFileStates.failed:t.SyncFileStates.unknown);return a===t.SyncFileStates.unknown&&this.logger.error(i+" returned result with no state!"+U.InternalErrorFlag,{path:e,result:n}),this.onProgress({path:e,from:i,elapsedMs:Date.now()-s,...n,state:a}),n}catch(r){throw this.logger.warn("wrap_() caught error",{error:r}),this.onProgress({path:e,from:i,state:(0,B.ending)()||r instanceof L.AbortError?t.SyncFileStates.canceled:r instanceof D.TimeoutError?t.SyncFileStates.timeout:t.SyncFileStates.failed,details:(0,B.ending)()?void 0:(0,W.errorToS)(r),elapsedMs:Date.now()-s}),r}}get output(){return f(this,n,"f")??f(this,r,"m",h).call(this)}async flushClose(){return f(this,r,"m",u).call(this),this.close()}async close(){this.logger.info("Closing sync report");const e=f(this,n,"f");return m(this,n,void 0,"f"),m(this,l,0,"f"),await(0,G.endStream)(e),null==e?void 0:f(this,s,"f")}}t.SyncReport=se,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,r=new WeakSet,u=function(e){var t;const i=f(this,a,"f");if(m(this,a,e,"f"),null!=e&&(0,F.eqlPicked)(e,i,"path","state","details"))return this.logger.debug("deduping row",e),void m(this,o,(t=f(this,o,"f"),t++,t),"f");null!=i&&(0===f(this,o,"f")?f(this,r,"m",c).call(this,i):(f(this,r,"m",c).call(this,{...i,details:(0,v.compactBlanks)([i.details,`(repeated ${f(this,o,"f")+1} times)`]).join(" ")}),m(this,o,0,"f")))},c=function(e){var i;const r=(0,y.unparse)([e],{header:!1,columns:t.SyncReportHeaders.values});this.output.write(r+Y.Newline,(e=>{null!=e&&this.logger.error("Failed to write",e)})),m(this,l,(i=f(this,l,"f"),++i),"f")>K.Settings.syncReportMaxRows.valueOrDefault&&this.close()},d=function(){return this.logger.info("sync report ended",{rowCount:f(this,l,"f"),outputFiles:this.outputFiles}),this.flushClose()},h=function(){return m(this,s,function(){const e=p.DateTime.now();return ie().join(e.toFormat("y-MM-dd"),(0,j.filestamp)()+"-sync-report.csv")}().ensureNewSync_({emptyIsNew:!1}),"f"),this.outputFiles.push(f(this,s,"f").nativePath),this.logger.info("Opening new report: "+f(this,s,"f")),(0,C.isTest)()&&(0,O.stdoutWrite)({syncReport:f(this,s,"f").nativePath},!1),m(this,n,(0,g.createWriteStream)(f(this,s,"f").nativePath),"f"),f(this,n,"f").write((0,y.unparse)([t.SyncReportHeaders.values],{header:!1})+Y.Newline),f(this,n,"f")}},89966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const s=r(i(48161)),n=i(19851),a=i(55835),o=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),h=i(8103),f=i(43899);function m(){return(0,a.map)(f.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,a.map)(m(),(e=>e.join(c.platformName+"-"+s.default.arch())))}async function g(e){if(c.isWin&&(e=(0,o.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,h.pathIfExists)(m()?.join("bin",e))),(()=>(0,h.pathIfExists)(m()?.join(e))),(()=>(0,h.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,h.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,n.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,n.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,n.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,n.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const s=r(i(44652)),n=i(19851),a=i(22573),o=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,o.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,a.blank)(t.file))throw new Error("can't touch blank path");const r=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const o=(0,n.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await o())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await o())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(s.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(n){if(!i||"ENOENT"!==n.code)throw n;await(0,c.thenOrTimeoutError)(s.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},79847:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.trashOrUnlinkFileUri=t.trashOrUnlinkFileUris_=void 0;const o=n(i(51455)),l=a(i(49378)),u=i(40958),c=i(22573),d=i(13538),h=i(83104),f=i(45255),m=i(31562),p=i(98314),g=i(34102),y=i(28874),w=i(45200),v=i(16287),b=i(74128),S=i(84258),P="fs.Trash";async function _(e){const t=Date.now(),i=y.Settings.commandTimeoutMs.valueOrDefault,r=(0,c.toNotBlank)(e.nativePath)??await(0,d.thenOrTimeout)((0,w.uri2nativePath)(e.uri,e.mountpoint),i);if((0,c.blank)(r)||r===h.Timeout)return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not convert URI to native path",path:e.uri,elapsedMs:Date.now()-t}),{uri:e.uri,unlinked:!1};const s=await(0,v.statMaybe)(r);if(null==s)return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: no such file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(!s.isFile())return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: not a file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(y.Settings.trySoftDeletes.valueOrDefault)try{if(await(0,d.thenOrTimeoutError)((0,l.default)(r,{glob:!1}),i),await function(e){return(0,m.untilTrue)((async()=>null==await(0,v.statMaybe)(e)),{timeoutMs:f.ShortCommandTimeoutMs})}(r))return(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Moved file to trash",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0};(0,S.logger)().warn("soft-delete("+r+") didn't seem to work: the file is still there?")}catch(e){(0,b.syncReport)().onProgress({from:P,state:"note",details:"Failed to soft-delete file to trash: "+(0,p.errorToS)(e),path:r,elapsedMs:Date.now()-t}),(0,S.logger)().warn("Tried to soft-delete, but that failed. We'll try to hard-delete.",{error:e})}try{return await(0,d.thenOrTimeoutError)(o.unlink(r),i),(0,g.ee)().emit("fileChanged",r),(0,S.logger)().info("unlink("+r+") successful"),(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Permanently deleted file",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0}}catch(i){return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not move file to trash or delete: "+(0,p.errorToS)(i),path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!1}}}t.trashOrUnlinkFileUris_=async function(e){const t=[];for(const{uri:i,mountpoint:r}of(0,u.uniqBy)(e,(e=>e.uri)))try{t.push(await _({uri:i,mountpoint:r}))}catch(e){t.push({uri:i,unlinked:!1,error:e})}return t},t.trashOrUnlinkFileUri=_},70854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryUidStore=t.LibraryUIDStore=t.SystemUIDStore=t.UIDStore=t.mkuid=void 0;const r=i(19851),s=i(41400),n=i(55835),a=i(92782),o=i(37805),l=i(46292),u=i(34102),c=i(55222),d=i(28874),h=i(87128),f=i(95696);function m(){return(0,a.safeRandomUid)({radix:c.TokenRadix,chars:24,splitEveryN:4})}t.mkuid=m;class p extends h.JsonFileStore{constructor(e,t){super(e.join("."+t+"-uid.json"),(()=>({uid:m(),version:o.version,type:this.type,createdAt:Date.now()})),(e=>e.hide())),this.rootDir=e,this.type=t,this.readUid_=(0,r.lazy)((async()=>(await this.read_())?.uid))}}function g(e=d.Settings.libraryDir.valueOrDefault){return(0,n.map)(f.PosixFile.forMaybe(e),(e=>new p(e,"library")))}t.UIDStore=p,t.SystemUIDStore=(0,r.lazy)((()=>(0,n.map)((0,l.configDir)(),(e=>new p(f.PosixFile.for(e),"system"))))),t.LibraryUIDStore=(0,r.lazy)(g),t.libraryUidStore=g,(0,s.later)((()=>{(0,u.ee)().on("clearCache",(()=>{t.SystemUIDStore.unset(),t.LibraryUIDStore.unset()})),d.Settings.libraryDir.watchLater((()=>t.LibraryUIDStore.unset()))}))},84258:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const a=n(i(51455)),o=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,o.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const r of(0,l.toA)(e))try{null!=r&&await a.unlink((0,c.toNativePath_)(r))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+r,{error:e})}}},5545:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const s=r(i(76760)),n=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,n.toS)(i.path??s.default.sep)}},70257:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),s=i(45255),n=i(17217);t.WipTimeoutMs=s.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const a=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(a,"")},t.isWip=function(e){return a.test((0,n.basename)(e)??"")}},58722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),s=i(22911);class n extends r.Writable{constructor(e){super(e),this.deferred=new s.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=n},73428:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(51926),o=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=n.default.dirname(e);await(0,c.mkdirp_)(i),await s.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=n.default.dirname(e);(0,c.mkdirpSync_)(i),s.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,a.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))}},13047:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const s=r(i(73024)),n=i(76760),a=i(46466),o=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),w=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function v(e,t){return(await S(e,t)).toString()}async function b(e,t,i){const r=[],n=[s.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?n.push((0,o.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&n.push((0,o.createBrotliDecompress)().on("error",(e=>r.push(e)))),n.push(t),await(0,a.pipeline)(n),(0,u.isNotEmpty)(r))throw new f.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function S(e,t){const i=new y.WritableToBuffer;return await b(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await S(e))}async function _(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,n.parse)(e).dir),await(0,a.pipeline)(new g.ReadableBuffer(i),(0,o.createGzip)(),s.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=v,t.zcat=async function(e,t){try{return v(e,t)}catch(t){return void w().warn("zcat failed to read "+e,t)}},t.zpipe_=b,t.zCopyToBuffer_=S,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void w().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await _(e,t)}catch(t){w().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},87408:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStatusSummary=void 0;const r=i(63870),s=i(18454),n=i(89035),a=i(82638);t.getStatusSummary=async function(e={}){return(0,a.summarizeHealthChecks)({healthChecks:[...s.HealthCheck.allCritical(),(0,n.memoryHealthCheck)()],errors:s.HealthCheck.lastErrors(),timeoutMs:(0,r.commandTimeoutMs)(),skipPending:!0,...e})}},18454:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,w,v,b,S,P,_=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},T=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const M=i(19851),E=i(40958),D=i(76790),x=i(41400),k=i(50357),F=i(26905),C=i(50268),A=i(55835),I=i(68708),O=i(30976),L=i(51926),R=i(13538),N=i(42279),B=i(59455),j=i(54993),z=i(48884),V=i(89788),W=i(22454),U=i(50213),q=i(69591),H=i(22911),$=i(99331),G=i(5916),J=i(42638),K=i(77740),Y=i(98314),Z=i(70025),X=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),re=i(21525),se=i(82638),ne=(0,M.lazy)((()=>(0,U.mkLogger)("health.HealthCheck")));class ae{static traceLater_(e,t){const i=new H.Deferred(e);i.catch((t=>{_(this,s,"f",l).push(e+": failed: "+(0,Y.errorToS)(t)),this.onResultChange()})),_(this,s,"m",o).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return _(this,s,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){_(this,s,"f",l).push((0,L.isString)(e)?e:(0,Y.errorToS)(e)),this.onResultChange()}static lastErrors(){return _(this,s,"f",l).toA()}static addLoadingMsg(e){_(this,s,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,E.compact)((0,B.toA)(e)).map(j.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return ne().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:_(this,s,"f",h).entriesByCountDesc()}),(0,A.map)((0,z.leastBy)(e,(e=>[_(this,s,"f",h).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=_(this,s,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,A.map)(e,(e=>_(this,s,"f",h).incr(e.msg))),ne().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return X.Settings.skipHealthCheckIds.envValue=t,s.reset()}static findById(e){return _(this,s,"f",f).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,C.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=_(this,s,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=s.summary();if(e.pendingCount>0){const t=await Promise.all(s.testResultsCritical());e=s.summaryFromResults(t),ne().info("awaitSettled(): summary result",{summary:e,results:t})}return ne().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){s.summary.unset()}static reset(){if((0,$.ending)())ne().warn("Rejecting reset() when ending()",(0,F.shortStack)());else{this.onResultChange(),_(this,s,"f",l).clear(),_(this,s,"f",d).clear(),_(this,s,"f",h).clear(),_(this,s,"f",c).clear(),this.summary.clear(),T(this,s,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new s(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return _(this,s,"f",f).push(i),this.all.unset(),i}constructor(e,t,i,n,o,l,u,c,d,h,f,m,S,P=Q.commandTimeoutMs){r.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=n,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=h,this.errorLinks=f,this.onReset=m,this.ttlMs=S,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),v.set(this,(0,M.lazy)((async()=>{await _(this,p,"f").prior(),(0,k.eql)(_(this,g,"f"),_(this,r,"m",w).call(this))||(this.onReset?.(),await this.refresh(),_(this,v,"f").unset())}))),this.refresh=(0,M.lazy)((()=>new H.Deferred("refresh").observe((async()=>{await _(this,p,"f").prior();const e=_(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,U.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[C.HealthCheckSections.ordinal(this.section),l??999,this.id],T(this,p,(0,G.lazyAsync)({desc:this.pendingMsg,later:()=>_(s,s,"f",a).enqueue({name:this.id,l:()=>_(this,r,"m",b).call(this,o)}),ttlMs:S}),"f"),this.isCritical&&_(this,p,"f").watchLater({onChange:s.onCriticalResult,onError:s.onCriticalResult});for(const e of this.settings)X.Settings[e].watchLater((()=>_(this,v,"f").call(this)))}isStale(){return _(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return _(this,p,"f").settledCount()}reset(){return _(this,p,"f").unset(),this.onReset?.(),T(this,g,{starting:!0},"f"),this}setTTL(e){_(this,p,"f").setTTL(e)}result(){return _(this,p,"f").call(this)}isSkipped(){return X.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return _(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return _(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??_(this,r,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function oe(e){if((0,E.isEmpty)(e))return{};const[t,i]=(0,z.partition)(e,(e=>"button"===e.type||"POST"===e.method)),r={};return(0,E.isNotEmpty)(i)&&(r.links=(0,E.uniqBy)(i)),(0,E.isNotEmpty)(t)&&(r.buttons=(0,E.uniqBy)(t)),r}t.HealthCheck=ae,s=ae,p=new WeakMap,g=new WeakMap,y=new WeakMap,v=new WeakMap,r=new WeakSet,o=function(){return(0,E.filterInPlace)(_(this,s,"f",n),(e=>!e.isPending)),_(this,s,"f",n)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=ne().tap({level:"warn",msg:"#summary()",result:(0,se.summarizeHealthChecksSync)({errors:_(this,s,"f",l),skipPending:_(this,s,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&T(this,s,!0,"f",u),i.state!==_(this,s,"f",c).last?.state&&_(this,s,"f",c).push({state:i.state,ts:Date.now()}),i},w=function(){return(0,I.fromEntries)(this.settings.map((e=>[e,X.Settings[e].valueOrDefault])))},b=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();ne().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,F.shortStack)()}),T(this,g,_(this,r,"m",w).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,x.delay)((0,O.randomInt)(.3*i,.7*i)),this.isSkipped())return _(this,r,"m",S).call(this,{test:{level:"disabled",msg:["Disabled by "+X.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const s=await(0,R.thenOrTimeoutError)(e(),i);return _(this,r,"m",S).call(this,{test:s,elapsedMs:Date.now()-t})}catch(e){return _(this,r,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},S=function({test:e,src:t="#toResult",elapsedMs:i}){var r,n;const a=s.normalizeMsg(e.msg),o=e.level??((0,j.toS)(a).toLowerCase().includes("error")?"error":(0,j.toS)(a).toLowerCase().includes("warn")?"warn":"ok"),l=(0,E.compact)([...e?.links??("ok"===o||"pending"===o?this.okLinks:"warn"===o?this.warnLinks:"no-library"===o?this.noLibraryLinks:"error"===o?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:o,msg:a,elapsedMs:i,...oe(l)};return u.runCount=(T(this,y,(n=_(this,y,"f"),r=n++,n),"f"),r),(0,$.ending)()?u:this.logger.tap({level:re.HealthCheckLevelToLogLevel[o],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const s=(0,L.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,A.map)(e,Y.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,Z.isFatalError)(e)&&s.toLowerCase().includes("warn")?"warn":"error"),_(this,r,"m",S).call(this,{test:{msg:s,level:t},src:"#toErrorResult",elapsedMs:i})},n={value:[]},a={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},h={value:new W.CountingSet},f={value:[]},ae.all=(0,M.lazy)((()=>Object.freeze((0,D.sortBy)(_(s,s,"f",f),(e=>e.sortBy))))),ae.onCriticalResult=(0,q.debounce)((()=>{ne().info("onCriticalResult()",s.summary.refresh())}),250),ae.summary=(0,M.lazy)((()=>_(s,s,"m",m).call(s))),ae.resetDebounced=(0,q.debounce)((()=>s.reset()),50)},85021:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckCommand=void 0,t.HealthCheckCommand="--health"},33866:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const r=i(82950),s=i(50268),n=i(459),a=i(23560),o=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,a.isPermaService)(t)&&(e===s.HealthCheckLevels.error||(0,a.isLibraryRequiredService)(t)&&e===s.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,o.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,r.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new n.UnreachableCaseError(e)}}},42495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const r=i(40958),s=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,r.compact)([(0,s.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},89035:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const s=r(i(48161)),n=i(19851),a=i(82950),o=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),h=i(23560),f=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:r}){return{level:i,msg:[e+" from "+(0,h.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,a.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(r,2)])]}}function g(){return s.default.totalmem()f.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(f.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*f.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,n.lazy)((()=>"ok"!==g().level),o.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:o.minuteMs,later:async()=>g()})))},82638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const r=i(40958),s=i(42659),n=i(45599),a=i(41400),o=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),h=i(23560),f=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,n.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function w({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:r}){const s=new Map;for(const e of t??[])s.set(e.id,e);if(null!=e)for await(const t of f.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),r))s.set(t.id,t);return[...s.values()]}t.summarizeHealthChecks=async function(e){return b({...e,healthCheckResults:await w(e)})};const v=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:h.serviceName.prior()??process.title}})));function b(e){const t=(0,r.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),n=i.length,a=i.map((e=>e.id)),c=t.length-n,d=0===n,h=(0,r.uniq)((0,r.compactBlanks)(e.errors));if(h.length>0)return{...v(),level:l.HealthCheckLevels.error,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",h.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const s=t.filter((e=>e.level===i));if((0,r.isNotEmpty)(s)){const e=t.filter((e=>!s.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+s.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...v(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:a,pendingCount:n,settledCount:c,linkIds:s.map((e=>e.id)),ts:Date.now(),msg:(0,r.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,o.flatten)([...s,...e].map((e=>e.msg[0])))])},meta:{checks:s.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...v(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,s.fmtDateShort)(Date.now())]}})}(0,a.later)((()=>{m.Settings.libraryDir.watchLater((()=>v.unset()))})),t.summarizeHealthChecksSync=b},95242:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviewBuilder=t.mkPreviewAssetFile_=void 0;const a=i(57975),o=i(40958),l=i(22573),u=i(33374),c=i(98553),d=i(55835),h=i(68708),f=i(48884),m=i(50213),p=i(92434),g=i(54296),y=i(51837),w=i(57159),v=i(83278),b=i(95696),S=i(62105),P=i(84258),_=i(38156),T=i(69589),M=i(28874),E=i(47783),D=i(29990),x=i(16047),k=i(42725),F=i(4192),C=i(32876),A=i(50961),I=i(181);t.mkPreviewAssetFile_=async function(e){const t=await(0,E.readTags)(e);return{nativePath:e.nativePath,fileSize:await e.size(),mtime:await e.thisOrSidecareMaxMtimeMs(),uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath,mimetype:t.mimetype,rotation:t.rotation,...t.dimensions,sha:await e.sha_()}};class O{constructor(e,t,i){r.add(this),this.ap=e,this.assetFiles=t,this.logger=(0,m.mkLogger)("AssetPreviewBuilder("+e.assetId+")"),this.ctx=(0,T.forceContextOrSetting)(i),this.assetFiles=(0,p.sortAssetFiles)(this.assetFiles)}[(r=new WeakSet,a.inspect.custom)](){return{ctor:"AssetPreviewBuilder",assetId:this.ap.assetId,assetFiles:this.assetFiles}}async build_(){this.logger.info("build_(): asset file candidates:",this.assetFiles.map((e=>(0,h.pick)(e,"id","uri"))));const e=[];for(const t of this.assetFiles){const i=b.PosixFile.forMaybe(await(0,g.getAssetFileNativePath)(t));if(null!=i){{const e=await(0,S.whyRejectFile)(i);(0,l.blank)(e)||this.logger.info("skipping: rejected",{pf:i,whyRejected:e})}try{return await n(this,r,"m",s).call(this,i,t)}catch(i){e.push(i),this.logger.warn("Failed to set shown file to ",{best:t,error:i})}finally{this.ap.parent.clear()}}else this.logger.info("skipping: failed to get PosixFile",{af:t}),e.push(new Error("Cannot get path from URI "+(0,c.stringify)((0,h.pick)(t,"uri","mountpoint","nativePath"))))}return this.logger.throw("Cannot build previews: none of the files are valid",{doNotSend:!0,retriable:!1,files:this.assetFiles.map((e=>e.nativePath??e.uri)),causes:e})}async infoForBest_(e,t){await(0,I.throwIfInvalidFile_)(e);const i=await e.size(),r=await e.thisOrSidecareMaxMtimeMs();if(this.logger.debug("_build",{filesize:i,mtime:r,best:t.uri}),null==i||null==r)return this.logger.throw("build(): missing stat info for best file",{ignorable:!0,best:t});const{uri:s,width:n,height:a,sha:l,mimetype:u}=t;if(null==s||null==n||null==a||null==u||null==l)return this.logger.throw("build(): internal error: missing fields for best file "+e,{ignorable:!0,best:t});const c=(0,D.fitSizes)(t,t.mimetype);return{assetId:t.assetId,assetFileId:t.id,uri:s,uris:this.assetFiles.map((e=>e.uri)),path:e.nativePath,mtime:r,filesize:i,width:n,height:a,sha:l,mimetype:u,fitSizes:c.map((([,e])=>e.name)).join(","),sqWidths:(0,o.compact)(k.ImageSize.sq().map((e=>e.outputSize(t)?.width))),fitWidths:c.map((([e])=>e.width))}}async priorIfValid_(e,t){if(this.ctx.forceSync||this.ctx.forceRebuildPreviews)return;const i=await this.ap.readInfo.refresh();if(null!=i){if(i.assetId!==t.assetId)throw new y.InternalError("priorIfValid_(): mismatched asset IDs for "+e+": "+(0,c.stringify)({priorInfo:i,info:t}));const r=i.fitSizes.split(","),s=t.fitSizes.split(",");if(null!=i.sha&&i.sha===t.sha&&i.rotation===t.rotation&&(0,D.equivalentFitSizes)(r,s)){const n=(0,D.fitSizes)(e,e.mimetype),a=(0,o.diff)(r,s);if((0,o.isNotEmpty)(a)){this.logger.info("priorIfValid_(): removing previews that aren't required anymore.",{leftovers:a});for(const e of a){const t=n.find((([,t])=>t.name===e));if(null==t)this.logger.warn("priorIfValid_(): Failed to clean up: missing fit size",{fitsize:t,fits:n});else{const e=this.ap.fileForWidth(t[1].reducer.name,t[0].width);this.logger.debug("priorIfValid_(): unlinking unwanted preview "+e,{fitsize:t}),await e.unlink("warn")}}}return this.logger.debug("priorIfValid_(): SHA and rotation match, and previews exist.",{info:t,priorInfo:i}),await this.ap.writeInfo(t),t}}}}t.AssetPreviewBuilder=O,s=async function(e,t){this.logger.info("_build("+e+")",{uri:t.uri});const i=await this.infoForBest_(e,t),r=await this.priorIfValid_(t,i);if(null!=r)return r;const s=new _.PushProgressObserver({path:e.nativePath,op:"Building previews"},k.ImageSize.sq().length+k.ImageSize.fit().length);if(this.logger.debug("Rebuilding all previews from "+t.uri,{assetId:t.assetId,info:i}),null==await this.ap.parent.mkdirp())throw new Error("build(): Failed to create previews directory, "+this.ap.parent+" for "+t);const n=await this.ap.existingFiles(),a=await(0,A.sharpReadable_)({src:e,minDim:k.ImageSize.largestFit().max});if(null==a)throw new w.WrappedError("AssetPreviewBuilder.build(): "+t.uri+", "+e.nativePath+", is not readable by sharp.",{retriable:!1});const o=(0,A.toSharp)(a);if(t.mimetype.startsWith("image/")&&!(0,x.isHeifMimeType)(t.mimetype)&&null!=t.rotation&&0!==t.rotation&&(o.rotate(t.rotation),this.logger.debug("build(): rotating "+t.rotation+"°")),(0,v.isBaseFile)(a)&&a.desc.toLowerCase().includes("thumbnail"))try{o.trim(1)}catch{}const l=(0,D.fitSizes)(t,t.mimetype),c=[],m=[];let p,g;const y=k.ImageSize.largestSq(),b=(0,f.leastBy)(l,(([e,t])=>(0,d.map)(y.outputSize(e),(()=>t.megapixels()))))?.[1].name,S=(0,h.pick)(t,"width","height");{let e=o.clone(),t=S;for(const[i,r]of l){const n=Date.now(),a=t,o=this.ap.fileForWidth(r.reducer.name,i.width).wip();e=r.resize(i,e),t=i,r.name===b&&(g=e.clone(),p=i),(0,u.dmegapixels)(i)>=1&&r.reducer===C.Fit&&M.Settings.includePreviewTags.valueOrDefault&&m.push(o),await r.toJpeg({path:o.nativePath,sh:e,outputSize:i}),s.onProgress(),this.logger.debug("resize("+r.name+") "+(0,u.fmtDim)(a)+" -> "+(0,u.fmtDim)(i)+" in "+(Date.now()-n)+" ms"),c.push(o)}}{null==g?(this.logger.debug("square resize(): resorting to ",{origDim:S,bestFitNameForSq:b}),g=o,p=S):this.logger.debug("square resize(): using to ",{sqDim:p,bestFitNameForSq:b});let e=!1;for(const t of k.ImageSize.sq()){const i=Date.now(),r=p,n=t.outputSize(p??S);if(null==n){this.logger.debug("skipping square output for "+t.max);continue}e||(n.position=M.Settings.squareThumbStrategy.valueOrDefault,e=!0),this.logger.debug("Applying ",{outputSize:n});const a=this.ap.fileForWidth(t.reducer.name,n.width).wip();t.resize(n,g),p=n,await t.toJpeg({path:a.nativePath,sh:g,outputSize:n}),s.onProgress(),c.push(a),this.logger.debug("resize("+t.name+") "+(0,u.fmtDim)(r)+" -> "+(0,u.fmtDim)(n)+" in "+(Date.now()-i)+" ms")}}try{await(0,F.includePreviewTags_)(e,m).catch((t=>{this.logger.warn("Failed to restore metadata tags into previews for "+e,{error:t})}));const t=new Set(n.map((e=>e.nativePath)));for(const e of c){const i=await e.unwip_();t.delete(i.nativePath)}await(0,P.unlink)(t),await this.ap.writeInfo(i),this.logger.debug("Previews unwipped and info written",{info:i})}catch(t){throw await(0,P.unlink)(c),new w.WrappedError("Failed to create previews from "+e,{cause:t,path:e.nativePath,fatal:!1})}return i}},35721:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkDownloadableTitle=t.previewToDownloadable=t.extractPreviewInfo=void 0;const r=i(75761),s=i(33374),n=i(11371),a=i(55835),o=i(31586),l=i(56519),u=i(29882),c=i(50213),d=i(97352),h=i(81168),f=i(89782),m=(0,c.mkLogger)("extractPreviewInfo");function p(e,t,i,r){return`Download ${t} ${e.ext} ${i} (${(0,s.fmtDim)(r)})`}t.extractPreviewInfo=function(e,t){const i=t.posixPathFrom(e).replace(/\//g,"").split("-"),r=(0,o.toInt)(i[0]),s=n.ReducerNames.getCI(i[1]),a=(0,d.extractInt)(i[2]);return(0,o.gt0)(r)?{file:t,assetId:r,reducer:s,width:a}:void m.warn("Failed to extract preview info",{file:t,previewsRoot:e,arr:i,assetId:r,reducer:s,width:a})},t.previewToDownloadable=async function(e,t){return(0,a.map2)(t.assetId,t.width,((i,a)=>(0,l.thenMap)((0,f.dimensions)(t.file),(o=>{const l=(0,s.dimToSize)(o);return{size:l,basename:`${(0,h.stripSuffix)(e,(0,u.extname)(e))}-${l}${t.file.ext}`,title:p(t.file,l,"image",o),description:`Download ${l}`,details:`(${(0,s.fmtDim)(o)} ${t.file.ext})`,href:(0,r.assetImgLink)({assetId:i,reducer:n.ReducerNames.fit,width:a})}}))))},t.mkDownloadableTitle=p},16524:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviews=void 0;const a=i(19851),o=i(40958),l=i(75761),u=i(11371),c=i(68708),d=i(39926),h=i(58939),f=i(48884),m=i(50213),p=i(81168),g=i(56519),y=i(38835),w=i(70417),v=i(35721);t.AssetPreviews=class{constructor(e,t){r.add(this),this.previewsRoot=e,this.readInfo=(0,a.lazy)((()=>this.infoJson().readJson("debug"))),this.logger=(0,m.mkLogger)("AssetPreviews(assetId:"+(0,h.id2id)(t)+")"),this.assetId=(0,h.id2id)(t);const i=(0,d.leftPad)(this.assetId,8,"0"),s=(0,p.splitEvery)(i,3);this.basename=s.pop()+"-",this.parent=e.join(...s)}parentNotExists(){return this.parent.clear().notExists()}async existingFiles(){return await this.parent.clear().childFiles((e=>e.base.startsWith(this.basename)))??[]}async existingJpgs(){return(await this.existingFiles()).filter((e=>".jpg"===e.ext))}async previewInfos(){return(0,g.sortByAsync)({name:"img.AssetPreviews.previews",arr:n(this,r,"m",s).call(this),f:e=>e?.file.size()})}async deleteAll(){const e=await this.existingFiles();if(e.length>20)throw new Error("deleteAll(): rejected: > 20 existing files?!"+y.InternalErrorFlag);for(const t of e)await t.unlink();return e}fileForSuffix(e){return this.parent.join(this.basename+e)}mp4(){return this.fileForSuffix("video.mp4")}infoJson(){return this.fileForSuffix("info.json")}writeInfo(e){return this.readInfo.unset(),this.infoJson().writeJson((0,c.pick)(e,"assetId","assetFileId","uri","uris","path","mimetype","width","height","mtime","filesize","sha","rotation","fitSizes","fitWidths"))}fileForWidth(e,t){return this.fileForSuffix(e+"-w"+t+".jpg")}async filesForReducer(e){const t=this.basename+e+"-";return this.logger.tap({msg:"filesForReducer("+e+")",result:(await this.existingFiles()).filter((e=>e.base.startsWith(t)))})}async smallestFileForReducer(e){return(0,f.leastBy)(await this.filesForReducer(e),(e=>(0,v.extractPreviewInfo)(this.previewsRoot,e)?.width))}async largestFileForReducer(e){return(0,f.greatestBy)(await this.filesForReducer(e),(e=>(0,v.extractPreviewInfo)(this.previewsRoot,e)?.width))}async widths(e){const t=await this.readInfo(),i=e===u.ReducerNames.sq?"sqWidths":"fitWidths",r=t?.[i];if(!(0,o.isEmpty)(r))return r;const s=(0,o.compact)((await this.previewInfos()).filter((t=>t.reducer===e)).map((e=>e.width)));return null!=t&&(t[i]=s,await this.writeInfo(t)),s}async posterLink(){const e=await this.widths(u.ReducerNames.fit);return(0,l.assetImgLink)({assetId:this.assetId,reducer:u.ReducerNames.fit,width:(0,w.max)(e)})}async imgAttrs(e,t=!1,i=!0){if(t||e!==u.ReducerNames.sq){const t=e===u.ReducerNames.fit?await this.readInfo():void 0;return(0,l.assetImgAttrs)({assetId:this.assetId,reducer:e,widths:await this.widths(e),lazyLoad:i,af:t})}return(0,l.assetSqImgAttrs)({assetId:this.assetId,lazyLoad:i})}},r=new WeakSet,s=async function(){const e=[];for(const t of await this.existingFiles()){const i=(0,v.extractPreviewInfo)(this.previewsRoot,t);null!=i&&e.push(i)}return e}},52086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},33106:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.dctPixels=t.dctHashCIELAB=t.dctHash=void 0;const s=r(i(9288)),n=i(96249),a=i(85810),o=32,l=function(e){const t=new Array(32);for(let e=1;e<32;e++)t[e]=1;return t[0]=1/Math.sqrt(2),t}(),u=function(e){const t=new Array(32);for(let e=0;e<32;e++){t[e]=new Array(32);for(let i=0;i<32;i++)t[e][i]=Math.cos((2*e+1)/64*i*Math.PI)}return t}();function c(e){const t=new Array(o);for(let i=0;is?1:0);return n}t.dctHash=async function(e){return c(await e.greyscale().resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer())},t.dctHashCIELAB=async function(e){const t=await e.resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer(),i=(0,a.rgb2labArray)(t);return(0,n.flatten)(i.map(c))},t.dctPixels=c},86580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(21605),o=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,n.gt0)(e.width)&&(0,n.gt0)(e.height)?(0,n.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,s.dmegapixels)(e.dimensions):(0,n.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,n.lt)(e.width,t.width)&&(0,n.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,n.lte)(e?.width,t?.width)&&(0,n.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,n.lt)(e.width,t.width)||(0,n.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,r.compact)((0,o.toS)(e).split(/[x×]/).map((e=>(0,n.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,r=Math.round(Math.sqrt(t*i));return{width:r,height:Math.round(r/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const r=u(e,i);return null==r?[]:a.Rotations.filter((e=>u(c(t,e),i)===r))}},89782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(56519),o=i(1078),l=i(5733),u=(0,r.lazy)((()=>(0,n.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,s.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,a.thenMap)((0,o.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},29990:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.equivalentFitSizes=t.fitSizes=void 0;const r=i(40958),s=i(33374),n=i(16170),a=i(42725),o=[a.ImageSize.QVGA,a.ImageSize.QQVGA];function l(e){return"qhd"===e?"wvga":"uhd"===e?"uhd4k":e}t.fitSizes=function(e,t){const i=a.ImageSize.fit(),r=[];let l=(0,n.isMimeTypeSupportedByBrowser)(t)?e:void 0;for(let t=0;t3||(0,s.dmegapixels)(a)-(0,s.dmegapixels)(l)>2.5)&&(l=a,r.push([a,n])))}return r},t.equivalentFitSizes=function(e,t){return(0,r.includesAll)((0,r.compactBlanks)(e).map(l),(0,r.compactBlanks)(t).map(l))}},277:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const r=i(22573),s=i(41400),n=i(54993),a=i(19851),o=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),h=i(78330),f=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),w=(0,a.lazy)((()=>(0,o.mkLogger)("img.Heif")));function v(e){return(0,n.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function b(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,a.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,r.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){w().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,r.blank)(e))return void w().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=v(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,r.blank)(i)&&(0,l.hasApt)()){const t=await(0,h.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,r.blank)(i)&&(0,f.hasPacman)()&&(i=(await(0,f.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,r.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void w().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=v,t.isHeifSupported=b,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await b()?(0,g.heif2png_)(e):void w().throw("HEIF support is missing",{src:e.nativePath})},(0,s.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(41400),o=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),h=i(28874),f=i(89782),m=i(13940),p=(0,r.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,s.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,r.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:h.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?n.minuteMs:void 0),e})),(0,a.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,f.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(h.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:h.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(o.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const r=i(22573),s=i(54993),n=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,r.blank)(e)&&n.test((0,s.toS)(e))}},13940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),s=i(19851),n=i(42659),a=i(59455),o=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),w=i(55222),v=i(63870),b=(0,s.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,s.lazy)((()=>(S(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const S=(0,s.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const s=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const n=s.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await n.mkdirp_(),await n.utimes();const a=n.join(i+r);return b().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:a}),a}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,a.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+w.TokenRadix.randomChars(2),w.TokenRadix.randomChars(16)+(0,o.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*n.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const s=await P(e,t,i);return await s.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,v.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),s}catch(r){return b().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},48368:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashDim=t.toImageHash=t.isImageHash=t._imageHash_=t.imageHash_=t.imageHash=t.maxPerBits=void 0;const s=r(i(9288)),n=i(19851),a=i(40958),o=i(22573),l=i(42659),u=i(33374),c=i(56038),d=i(85810),h=i(76490),f=i(40401),m=i(86758),p=i(85434),g=i(96706),y=i(38835),w=i(88561),v=i(95696),b=i(17217),S=i(50213),P=i(23624),_=i(28874),T=i(12089),M=i(16170),E=i(1078),D=i(33106),x=i(86580),k=i(78011),F=i(50961);t.maxPerBits=function(e){return Math.floor(52/e)};const C=(0,n.lazy)((()=>(0,S.mkLogger)("img.ImageHash")));t.imageHash=async function(e){try{return await(0,t.imageHash_)((0,b.toNativePath_)(e))}catch(t){return void C().warn("imageHash() failed for "+e,t)}};const A=(0,n.lazy)((()=>new w.FileCache({name:"img.imageHash",timeoutMs:l.minuteMs})));async function I(e){const t=v.PosixFile.for(e),i=await(0,E.extractSizeInfoFromFile)(t);if(null==i)throw new Error("Failed to read dimensions for "+e+y.NonFatalErrorFlag+y.DoNotSendErrorFlag);const r=(0,x.fitToResolution)(i.dimensions,Math.round(_.Settings.dominantColorPixels.valueOrDefault)),n=await(0,F.sharpReadable_)({src:t,minDim:r});return(0,c.time)("img.imageHash",(()=>async function({file:e,readable:t,sizeInfo:i}){const r=(0,S.mkLogger)("ImageHash("+e+")");if(null==t)return r.throw("Cannot build readable stream");const n=(0,x.fitToResolution)(i.dimensions,_.Settings.dominantColorPixels.valueOrDefault);if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-orig.jpg";await(0,F.toSharp)(t).jpeg().toFile(i),console.log({out:i,readable:t})}let a=(0,F.toSharp)(t).removeAlpha();(0,M.isVideoMimeType)(t.mimetype)||(a=a.rotate(i.rotation)),(0,u.dmegapixels)(i.dimensions)<.1&&(a=a.trim({background:"#000",threshold:0})),a=a.resize({fit:s.default.fit.outside,...n,withoutEnlargement:!0});const{data:o,info:l}=await a.raw().toBuffer({resolveWithObject:!0});if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-"+l.width+"w.jpg";await(0,s.default)(o,{raw:{...l,channels:3}}).jpeg().toFile(i),console.log({out:i,rgbInfo:l,readable:t})}const c=(0,d.rgb2labTriplets)(o),h=(0,f.extractDominantColors)(c),p=(0,m.labsAreGreyscale)(c),y=()=>(0,s.default)(o,{raw:{...l,channels:3}}),w=await(p?k.meanDiffHash:k.meanDiffHashCIELAB)(y()),v=await(p?D.dctHash:D.dctHashCIELAB)(y());return{meanHash:(0,P.b64encodeBits)(w.meanHash),diffHash:(0,P.b64encodeBits)(w.diffHash),dctHash:(0,P.b64encodeBits)(v),dominantColors:h.dominantColors,dominantColorsDescription:h.description,dominantColorScore:h.dominantColorScore,isGreyscale:p,mimetype:(0,M.normalizeMimetype)(t.mimetype),...i.dimensions,rotation:i.rotation??0}}({file:t,readable:n,sizeInfo:i})))}function O(e){return null!=e&&(0,o.notBlank)(e.meanHash)&&(0,o.notBlank)(e.mimetype)&&(0,a.isNotEmpty)(e.dominantColors)}t.imageHash_=(0,T.shim1)({name:"img.imageHash",cache:A,impl:I}),t._imageHash_=I,t.isImageHash=O,t.toImageHash=function(e){if(null!=e){if(O(e))return e;if((0,p.isModeData)(e)){const t={...(0,p.omitModeData)(e),dominantColors:h.DominantColor.fromModeData(e)};if(O(t))return t}}},t.HashDim=8},80361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageHashSimilarity=t.isVerySimilarComparison=t.isVerySimilarImageHash=t.isSimilarImageHash=t.isVerySimilarImage=t.compareImageHashes=t.isSimilarImage=t.hammRatio=t.meanHashVariants=t.isGreyscaleMeanHash=t.labsCorr2=t.isImageHashComparison=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(38639),o=i(33374),l=i(57924),u=i(55835),c=i(31586),d=i(68708),h=i(39926),f=i(21605),m=i(48884),p=i(50213),g=i(97352),y=i(85810),w=i(3048),v=i(32848),b=i(82647),S=i(38812),P=i(70417),_=i(23624),T=i(28874),M=i(86580),E=i(48368),D=i(2090),x=(0,r.lazy)((()=>(0,p.mkLogger)("img.ImageHashComparison")));t.isImageHashComparison=function(e){return null!=e&&(0,E.isImageHash)(e.a)&&(0,E.isImageHash)(e.b)&&[e.imageCorr,e.colorCorr,e.aRotation].every(c.isNumber)},t.labsCorr2=function(e,t){const i=(0,s.sum)(e,(e=>(0,w.diffCIECorr)(e,(0,y.closestLab)(t,e))))+(0,s.sum)(t,(t=>(0,w.diffCIECorr)(t,(0,y.closestLab)(e,t)))),r=Math.max(e.length,t.length,i);return(r-i)/r};const k=/A{20}=?$/;function F(e){return null!=e&&((0,g.within)(7,12,e.length)||null!=e?.match(k))}function C(e,t,i=E.HashDim){const r=(0,_.b64decode)(e).toString(2).split("").map((e=>"1"===e?1:0)),s=i*i;for(;r.length%s!=0;)r.unshift(0);return r.length===s||t?r.slice(0,s):r.slice(0,s).map(((e,t)=>4*e+2*r[t+s]+r[t+2*s]))}function A({a:e,b:t,greyscale:i,dim:r=E.HashDim,rotationsToCheck:a}){if((0,n.blank)(e)||(0,n.blank)(t))return{hammRatio:0,bRotation:0};if(e===t)return{hammRatio:1,bRotation:0};const o=C(e,i,r),l=C(t,i,r);(0,s.isEmpty)(a)&&(a=[0]);const u=a.map((e=>({bRotation:e,hammRatio:(0,c.sigFigs)((0,g.hammRatioIntArrays)(o,(0,S.rotateSquareMatrix)(l,e),i?1:3),2)})));x().debug("hammRatio()",{results:u,rotationsToCheck:a});const d=(0,m.greatestBy)(u,(e=>[(0,c.sigFigs)(e.hammRatio,1),-f.Rotations.indexOf(e.bRotation)]));return{bRotation:d.bRotation,hammRatio:(0,c.sigFigs)(d.hammRatio,2)}}async function I(e,t,i="debug",r={}){return x().tap({msg:`isSimilarImage(${e},${t})`,level:i,result:L(await(0,E.imageHash)(e),await(0,E.imageHash)(t),r)})}function O(e,t,i={}){const r=(0,E.toImageHash)(e),s=(0,E.toImageHash)(t);if(null==r||null==s)return;const n=(0,a.isTrue)(i.capturedAtIsFuzzy),h=!(0,a.isTrue)(i.forceColor)&&((0,a.isTrue)(i.forceGreyscale)||(r.isGreyscale??F(r.meanHash))||(s.isGreyscale??F(s.meanHash))),f=A({a:r.meanHash,b:s.meanHash,greyscale:h,rotationsToCheck:i.rotationsToCheck??(0,M.validRotations)(r,s)}),m=A({a:r.diffHash,b:s.diffHash,greyscale:h,rotationsToCheck:[]}),p=A({a:r.dctHash,b:s.dctHash,greyscale:h,rotationsToCheck:[]}),g=(0,v.dominantColorCorrelation)(r.dominantColors,s.dominantColors);if(null==g)return void x().debug("imageHashCompare(): missing color correlation");const y=r.mimetype===s.mimetype,w=(0,M.aspectRatio)(r),S=(0,M.aspectRatio)((0,o.maybeDimSwap)(s,f.bRotation)),P=null!=w&&null!=S&&!(0,o.isCloseAspectRatio)(w,S);let _=0,k=0;n&&(k+=T.Settings.imageHashFuzzyDateDelta.valueOrDefault,_+=T.Settings.imageHashFuzzyDateDelta.valueOrDefault),y||(k+=T.Settings.imageHashDifferentMimetypesDelta.valueOrDefault,_+=T.Settings.imageHashDifferentMimetypesDelta.valueOrDefault),h&&(_+=T.Settings.imageHashGreyscaleDelta.valueOrDefault,k+=T.Settings.imageHashGreyscaleDelta.valueOrDefault);const C=R((_+(i.minImageCorr??T.Settings.minImageCoeffPct.valueOrDefault))/100),I=R((k+(i.minColorCorr??T.Settings.minColorCoeffPct.valueOrDefault))/100),O=[];P&&O.push(`aspect ratio mismatch (${(0,D.fmtAspectRatio)(w)} vs ${(0,D.fmtAspectRatio)(S)})`);const L=[],N=new b.Average;N.push(f.hammRatio),f.hammRatioN.push(e))),(0,u.map)(p?.hammRatio,(e=>N.push(e))),(0,c.lt)(m?.hammRatio,C)&&L.push("gradient"),(0,c.lt)(p?.hammRatio,C)&&L.push("DCT")),L.length>0&&O.push("different image content ("+(0,l.andList)(L)+")");const j=g>=I,z=j&&N.avg>=C;j||O.push("different dominant colors");const V={meanHashCorr:(0,c.sigFigs)(f.hammRatio,2),diffHashCorr:B?void 0:(0,u.map)(m,(e=>(0,c.sigFigs)(e.hammRatio,2))),dctHashCorr:B?void 0:(0,u.map)(p,(e=>(0,c.sigFigs)(e.hammRatio,2))),hashCorrAvg:N.avg,minImageCorr:C,imageCoeffDelta:_,colorCorr:(0,c.sigFigs)(g,2),minColorCorr:I,colorCoeffDelta:k,isGreyscale:h,bRotation:f.bRotation,aAspectRatio:w,bAspectRatio:S,isSimilar:z,whyNotSimilar:z?void 0:(0,l.andList)(O)};return x().info("compareImageHashes",{a:(0,d.pickCompact)(r,"uri","id","assetId"),b:(0,d.pickCompact)(s,"uri","id","assetId"),...V}),{a:r,b:s,...V}}function L(e,t,i){return O(e,t,i)?.isSimilar??!1}function R(e){return(0,c.sigFigs)((0,c.clamp)(0,1,e),3)}function N(e){return null!=e&&(0,c.gte)(e.meanHashCorr,.9)&&(0,c.gte)(e.colorCorr,.9)}t.isGreyscaleMeanHash=F,t.meanHashVariants=function(e,t=!1,i=E.HashDim){const r=(t=t||null!=e.match(k))?(0,h.padding)("0",2*i*i):"",s=C(e,t,i);return f.Rotations.map((e=>(0,_.b64encode)(BigInt("0b0"+(0,S.rotateSquareMatrix)(s,e).map((e=>e.toString(2))).join("")+r))))},t.hammRatio=A,t.isSimilarImage=I,t.compareImageHashes=O,t.isVerySimilarImage=async function(e,t,i="debug",r={}){return I(e,t,i,{rotationsToCheck:[0],...r,minImageCorr:.92,minColorCorr:.92})},t.isSimilarImageHash=L,t.isVerySimilarImageHash=function(e,t,i={}){return N(O(e,t,i))},t.isVerySimilarComparison=N,t.imageHashSimilarity=function(e,t){return(0,u.map)(O(e,t),(e=>(0,P.avg)([e.meanHashCorr,e.colorCorr])))}},42725:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ImageSize=void 0;const a=i(57975),o=i(19851),l=i(33374),u=i(12168),c=i(48884),d=i(28874),h=i(32876),f=i(5733);class m{static sq(){return n(this,r,"f",s).filter((e=>e.reducer===h.Square))}static largestSq(){return(0,c.greatestBy)(this.sq(),(e=>e.megapixels()))}static fit(){const e=d.Settings.previewResolutions.valueOrDefault;return n(this,r,"f",s).filter((t=>t.reducer===h.Fit&&e.includes(t.name)))}static largestFit(){return(0,c.greatestBy)(this.fit(),(e=>e.megapixels()))}static all(){return[...n(this,r,"f",s)]}constructor(e,t,i,a,l=!0){this.name=e,this.maxWidth=t,this.maxHeight=i,this.reducer=a,this.rotational=l,this.megapixels=(0,o.lazy)((()=>(0,u.megapixels)(this.maxWidth*this.maxHeight))),this.max={width:t,height:i},n(r,r,"f",s).push(this)}[a.inspect.custom](){return{ctor:"ImageSize",name:this.name+" ("+this.reducer.name+")",maxDim:this.maxWidth+"×"+this.maxHeight,maxMP:this.megapixels()}}get aspectRatio(){return this.maxWidth/this.maxHeight}get maxPixels(){return this.maxWidth*this.maxHeight}get minDimension(){return Math.min(this.maxWidth,this.maxHeight)}outputSize(e){return this.reducer.reduce(this.rotational&&(0,l.isPortrait)(e)?(0,l.dimSwap)(this.max):this.max,e)}resize(e,t){return t.resize({...e,fit:this.reducer.fit,withoutEnlargement:!0})}toJpeg({path:e,sh:t,outputSize:i}){return((0,l.dmegapixels)(i)<2||d.Settings.previewSharpen.valueOrDefault)&&(t=t.sharpen()),t.jpeg((0,f.sharpRenderOptions)()).toFile(e)}toString(){return this.name}}t.ImageSize=m,r=m,s={value:[]},m.UHD8k=new r("uhd8k",7680,4320,h.Fit,!1),m.UHD5k=new r("uhd5k",5120,2880,h.Fit,!1),m.UHD=new r("uhd4k",4096,2160,h.Fit),m.QHD=new r("qhd",3120,1440,h.Fit),m.FHD=new r("fhd",1920,1080,h.Fit),m.HD=new r("hd",1280,720,h.Fit),m.WVGA=new r("wvga",720,480,h.Fit),m.QVGA=new r("qvga",320,240,h.Fit),m.QQVGA=new r("qqvga",160,120,h.Fit),m.S480=new r("s480",480,480,h.Square),m.S240=new r("s240",240,240,h.Square),m.S120=new r("s120",120,120,h.Square),m.S60=new r("s60",60,60,h.Square)},4192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includePreviewTags_=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(50213),o=i(56038),l=i(28874),u=i(47783),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.includePreviewTags")));t.includePreviewTags_=async function(e,t){!1===l.Settings.includePreviewTags.valueOrDefault||l.Settings.includedPreviewTags.isEmpty()||(0,s.isEmpty)(t)||(c().info("Re-adding metadata to previews..."),await(0,o.time)("img.includePreviewTags",(async()=>{const i=(0,n.pick)(await(0,u.readTags)(e),...l.Settings.includedPreviewTags.values),r=i?.capturedAt;null!=r&&(delete i.capturedAt,(0,n.assignFields)(i,r.asExifTag()));const s=i?.exposureSettings;null!=s&&(delete i.exposureSettings,i.FocalLength=s.focalLength,i.FNumber=s.aperture,i.ExposureTime=s.shutterSpeed,i.ISO=s.iso),l.Settings.includedPreviewTags.has("Source")&&(i.Source=e.nativePath),(0,n.isEmptyObj)(i)?c().warn("not adding tags to previews: no values for tags in source file",{src:e,includedPreviewTags:l.Settings.includedPreviewTags.values}):(c().info("Overwriting preview tags...",{src:e,writeTags:i}),await Promise.all(t.map((e=>(0,u.overwriteTags_)(e,i)))))})))}},78011:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.meanDiffHashCIELAB=t.meanDiffHash=t.dhash=t.mhash=void 0;const s=r(i(9288)),n=i(96249),a=i(59455),o=i(85810),l=i(70417),u=i(48368);function c(e){const t=(0,l.avg)(e);return null==t?[]:(0,a.toA)(e).map((e=>e>=t?1:0))}function d(e){const t=(0,a.toA)(e),i=Math.round(Math.sqrt(t.length));return t.map(((t,r)=>t>=(0===r?e[i]:r%i==0?e[r-i]:e[r-1])?1:0))}t.mhash=c,t.dhash=d,t.meanDiffHash=async function(e,t=u.HashDim){const i=await e.greyscale().resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer();return{meanHash:c(i),diffHash:d(i)}},t.meanDiffHashCIELAB=async function(e,t=u.HashDim){const i=await e.resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer(),r=(0,o.rgb2labArray)(i);return{meanHash:(0,n.flatten)(r.map(c)),diffHash:(0,n.flatten)(r.map(d))}}},48604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildAssetPreviews_=t.Previews=void 0;const r=i(19851),s=i(55835),n=i(50213),a=i(12089),o=i(87290),l=i(95242),u=i(16524);class c{constructor(e){this.root=e}apb(e,t,i){return new l.AssetPreviewBuilder(this.ap(e),t,i)}ap(e){return new u.AssetPreviews(this.root,e)}}t.Previews=c,c.instance=(0,r.lazy)((()=>((0,n.mkLogger)("Previews").info(".instance()",{libraryPreviewsDir:(0,o.libraryPreviewsDirPosixFile)()}),(0,s.map)((0,o.libraryPreviewsDirPosixFile)(),(e=>new c(e)))))),t.buildAssetPreviews_=(0,a.shim1)({name:"img.buildAssetPreviews",impl:e=>c.instance().apb(e.assetId,e.assetFiles,e).build_()})},2090:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(34666),o=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,n.isNumber)(e)?e:((0,n.toGt0)(e.width)??0)/((0,n.toGt0)(e.height)??0),(e=>(0,o.leastBy)(t.StandardAspectRatios,(t=>{const r=Math.abs(e-t);return r>i?void 0:r}))??e))}function c(e,i,r=t.RatioEpsilon){return(0,a.lt)((0,n.absdiff)(u(e),u(i)),r)}function d(e,i){return(0,o.leastByCtx)(t.Ratios,(t=>{const r=Math.abs(t.i-e);return r[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,s.maybeDimSwap)(e.dimensions,e.rotation),(0,s.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,n.sigFigs)(e,3))}},34943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const r=i(19851),s=i(31586),n=i(80049),a=i(50213),o=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),h=(0,r.lazy)((()=>(0,a.mkLogger)("img.RawInfo"))),f=(0,r.lazy)((()=>new n.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:o.ShortCommandTimeoutMs})));async function m(e){return f().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,r,n,a]=e.split("\t"),o=(0,s.toGt0)(n),l=(0,s.toGt0)(a);return null==o||null==l?h().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):h().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:r,ImageSize:{width:o,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>f.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?f.prior()?.clear():f.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{h().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},32876:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Reducers=t.Fit=t.fitInsideToMaxPixels=t.fitInsideToAspectRatio=t.Square=t.SharpFits=void 0;const r=i(19851),s=i(33374),n=i(4188),a=i(11371),o=i(31586),l=i(68708),u=i(50989),c=i(50213),d=i(86580);var h,f;t.SharpFits=(0,u.strEnum)("cover","contain","fill","inside","outside"),function(e){const i=(0,r.lazy)((()=>(0,c.mkLogger)("img.Reducers.Square")));e.name=a.ReducerNames.sq,e.fit="cover",e.reduce=function(e,r){const s=(0,d.lteBoth)(e,r)?{...e,fit:t.SharpFits.cover}:void 0;return i().tap({msg:"reduce()",result:s,meta:{max:e,input:(0,l.pick)(r,"width","height","nativePath")}})}}(h||(t.Square=h={})),t.fitInsideToAspectRatio=function(e,t){return e.width/e.height>=t?{width:Math.floor(e.height*t),height:e.height}:{width:e.width,height:Math.floor(e.width/t)}},t.fitInsideToMaxPixels=function(e,t){if(null==e||!(0,o.gt0)(e.width)||!(0,o.gt0)(e.height))return;if((0,s.pixels)(e)(0,c.mkLogger)("img.Reducers.Fit")));e.name=a.ReducerNames.fit,e.fit="inside",e.reduce=function(e,i){if(!(0,d.ltBoth)(i,e))return(0,n.fitInside)(i,e);t().trace(`reduce(): input ${(0,s.fmtDim)(i)} is too small for ${(0,s.fmtDim)(e)}`)}}(f||(t.Fit=f={})),t.Reducers=[h,f]},5733:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const s=r(i(9288)),n=i(19851),a=i(41400),o=i(50213),l=i(28874),u=i(15674),c=(0,n.lazy)((()=>(0,o.mkLogger)("img.Sharp")));function d(e,t){return(0,s.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,n.lazy)((()=>{s.default.simd(l.Settings.enableSIMD.valueOrDefault),s.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),s.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,a.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},50961:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractImageForThumbs_=t.sharpReadable_=t.toSharp=t.imgFromExif_=t._imgFromExif_=void 0;const s=i(77988),n=r(i(9288)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(33374),d=i(98553),h=i(31586),f=i(68708),m=i(51926),p=i(41583),g=i(50213),y=i(97352),w=i(56519),v=i(56038),b=i(57159),S=i(95696),P=i(17217),_=i(28874),T=i(47783),M=i(16170),E=i(95141),D=i(54979),x=i(1078),k=i(63870),F=i(86580),C=i(277),A=i(16047),I=i(13940),O=i(5733),L=i(66106),R=i(19350),N=(0,a.lazy)((()=>(0,g.mkLogger)("img.SharpReadable")));async function B(e,t,i){return i?await(0,T.exiftool)().extractBinaryTagToBuffer(t,e.nativePath):(await z(e,t))?.nativePath}async function j(e,t,i,r,a){const o=t?.[i];if(!(o instanceof s.BinaryField))return;const l=o.bytes<_.Settings.maxEmbeddedBuffer.valueOrDefault;try{const t=await B(e,i,l);if(null==t)return;const s=(0,n.default)(t,{failOn:_.Settings.imageFailOn.valueOrDefault}),o=await s.metadata(),u=(0,F.aspectRatio)(o);if(null!=a&&null!=u&&!(0,h.closeTo)(a,u,.2))return void N().info("imgFromExif("+e+", "+i+"): rejecting (aspect ratio mismatch)",{fileAspectRatio:a,renderedAspectRatio:u});const c=(0,F.lteBoth)(r,o);return N().debug("imgFromExif("+e+", "+i+")",{valid:c,minDim:r,useBuffer:l,fileAspectRatio:a,renderedAspectRatio:u,dim:(0,f.pick)(o,"width","height")}),c?{sharp:s,file:(0,m.isString)(t)?S.PosixFile.for(t):void 0}:void 0}catch(t){return void N().info("Failed to read image from EXIF tag "+i,{src:e,error:t})}}async function z(e,t){const i=t.toLowerCase().endsWith("tiff")?".tiff":".jpg";try{const r=await(0,I.tmpImageFile_)({src:e,tag:t,ext:i});return await r.applyIfEmpty_({retries:2,fn_:i=>(0,T.extractBinaryTag)(t,e.nativePath,i.nativePath),timeoutMs:(0,k.commandTimeoutMs)()})}catch(i){return void N().throw("Failed to extract embedded "+t+" from "+e.nativePath,{error:i})}}t._imgFromExif_=B,t.imgFromExif_=j,t.toSharp=function(e){const t=e;if((0,O.isSharp)(t.sharp))return t.sharp;if((0,P.isSimpleFile)(t.file))return(0,n.default)(t.file.nativePath,{failOn:_.Settings.imageFailOn.valueOrDefault});throw new Error("toSharp(): not a Sharp object: "+(0,d.stringify)(e))},t.sharpReadable_=function(e){return(0,v.time)(`img.sharpReadable${e.src.ext.toUpperCase()}`,(()=>async function({src:e,minDim:t,skipEmbedded:i}){const r=N().addParameterContext(e.nativePath);(0,O.setupSharp)();const n=await(0,D.readMimeType)(e);if((0,u.blank)(n))return r.throw(e+" is not supported (missing MIMEType)",{doNotSend:!0});const a=await(0,x.extractSizeInfoFromFile)(e);if(null==a)return void r.warn("Failed to extract size info from "+e);const d=[];function f(e,t){t.desc=e,d.push(t)}const m=a.rotation,g=(0,M.isVideoMimeType)(n),S=(0,M.isLibrawMimeType)(n),P=a.dimensions,k=t??(0,y.map2Gt0)(P.width,P.height,((e,t)=>({width:Math.round(.9*e),height:Math.round(.9*t)})));if(null==k?.width||null==k?.height)return r.throw(e+" is not supported (missing dimensions)",{dim:k,doNotSend:!0,mimetype:n,isRaw:S,isVideo:g});const I=(0,F.aspectRatio)(a.fileDimensions),B=(0,h.lt)(I,1),z=(0,M.isSharpMimeType)(n)&&null==t,V=(0,E.orientationRequiresMirroring)(a.orientation);if(!0===i||g||B||z||V)r.debug("not pulling previews from tags",{isVideo:g,isFilePortrait:B,isSharpMimeAndNoMinDim:z,isMirrorOrientation:V});else{const i=!1,n=await(0,T.readRawTags)(e,i);if(null==n)r.warn("Cannot pull previews from tags: readRawTags() failed");else{const i=[..._.Settings.embeddedPreviews.values];null!=t&&(0,c.dmegapixels)(t)<1&&i.unshift(..._.Settings.embeddedThumbnails.values);const a=k.width*k.height*.2,u=k.width*k.height*.05,d=(0,l.sortBy)(i.filter((e=>n[e]instanceof s.BinaryField)),(e=>{const t=n[e]?.bytes;return(0,h.gt)(t,u)?Math.abs(t-a):void 0}));if(!(0,o.isEmpty)(d)){r.debug("checking previews from tags",{sizeSortedTagNames:d});for(const t of d)f("imgFromExif."+t,(()=>j(e,n,t,k,I)))}}}(0,M.isSharpMimeType)(n)&&f("sharp",(async()=>({file:e}))),(0,A.isHeifMimeType)(n)&&await(0,C.isHeifSupported)()&&f("heif",(()=>(0,w.thenMap)((0,C.heif2img)(e),(e=>({file:e}))))),S&&f("raw2tiff",(()=>(0,w.thenMap)((0,R.raw2tiff_)(e),(e=>({file:e}))))),g&&f("extractVideoFrame",(async()=>{if(await(0,L.isVideoSupported)())try{return await(0,w.thenMap)((0,L.extractVideoFrame_)(e),(e=>({file:e})))}catch(t){throw new b.WrappedError("Failed to extract video frame for "+e,t)}else r.warn("video file, but video support is missing",{src:e.nativePath,mimetype:n,minDim:t})}));const W=[];for(const i of d)try{const s=await(0,v.time)("img.read."+i.desc,i);if(null!=s)return r.debug(i.desc+" strategy succeeded",{src:e,minDim:t,rot:m,img:s.file?.nativePath}),{desc:i.desc,rot:m,mimetype:n,...s};r.debug(i.desc+" returned null",{src:e,minDim:t,rot:m})}catch(e){r.warn(i.desc+" failed",e),W.push((0,p.toErr)(e))}throw new b.WrappedError("Failed to render "+e,{causes:W,path:String(e),fatal:!1,doNotSend:!0,retriable:!1})}(e)))},t.extractImageForThumbs_=z},181:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.whyInvalidFile=t.clearInvalidFileCache=t.throwIfInvalidFile_=t.isValidFile=void 0;const s=r(i(9288)),n=i(19851),a=i(22573),o=i(42659),l=i(98553),u=i(50213),c=i(12089),d=i(81168),h=i(57159),f=i(88561),m=i(95696),p=i(17217),g=i(28874),y=i(16170),w=i(54979),v=i(63870),b=i(5733),S=i(50961),P=i(66106),_=i(51210),T=(0,n.lazy)((()=>(0,u.mkLogger)("img.ValidFile")));t.isValidFile=async function(e){return(0,a.blank)(await(0,t.whyInvalidFile)((0,p.toNativePath_)(e)))},t.throwIfInvalidFile_=async function(e){if(!g.Settings.validateJpegImages.valueOrDefault&&!g.Settings.validateRawImages.valueOrDefault&&!g.Settings.validateVideos.valueOrDefault)return void T().debug("file validation is disabled for "+e,{validateJpegImages:g.Settings.validateJpegImages.valueOrDefault,validateRawImages:g.Settings.validateRawImages.valueOrDefault,validateVideos:g.Settings.validateVideos.valueOrDefault});const i=(0,p.toNativePath_)(e),r=T().tap({msg:"whyInvalidFile("+i+")",result:await(0,t.whyInvalidFile)(i)});(0,a.notBlank)(r)&&T().throw(r,{path:i,retriable:!1,doNotSend:!0,ignorable:!0})};const M=(0,n.lazy)((()=>new f.FileCache({name:"img.validFile",maxSize:256,timeoutMs:Math.max(o.minuteMs,g.Settings.validateVideos.valueOrDefault?5*o.minuteMs:(0,v.commandTimeoutMs)())})));t.clearInvalidFileCache=function(){return M().clear()},t.whyInvalidFile=(0,c.shim1)({name:"img.whyInvalidFile",cache:M,toKey:p.toNativePath_,impl:async e=>{const t=m.PosixFile.for(e);if(!await t.isFile()||!await t.isReadable())return t+" is not a readable file";if(await t.isEmpty())return t+" is empty";try{const e=await(0,w.readMimeType)(t);if(null==e)throw new Error("Cannot validate, no mimetype");if((0,y.isVideoMimeType)(e))g.Settings.validateVideos.valueOrDefault&&(T().debug("validating "+t),await(0,P.validVideo_)(t));else{if(!e.startsWith("image/"))throw new Error("Unsupported mimetype "+(0,l.stringify)(e));if("image/jpeg"===e)g.Settings.validateJpegImages.valueOrDefault&&await(0,_.validJpeg_)(t);else if(g.Settings.validateRawImages.valueOrDefault)if((0,d.includesIgnoreCase)(g.Settings.validateMimetypeSkiplist.values,e))T().info("Skipping validation of "+t+": validateMimetypeSkiplist matches",{mime:e});else{const e=await(0,S.sharpReadable_)({src:t,skipEmbedded:!0}),i=await async function(e,t=g.Settings.imageFailOn.valueOrDefault){const i=e;if((0,p.isSimpleFile)(i.file))return(0,s.default)(i.file.nativePath,{failOn:t});if((0,b.isSharp)(i.sharp)){const{data:e,info:t}=await i.sharp.raw().toBuffer({resolveWithObject:!0});return(0,s.default)(e,{...t,failOnError:!0})}throw new Error("Cannot read input "+e?.desc)}(e);await i.tiff().toBuffer()}}return""}catch(t){return new h.WrappedError("Failed to validate",{cause:t,path:e,doNotSend:!0}).toS()}}})},19769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const r=i(19851),s=i(40958),n=i(41400),a=i(50213),o=i(68852),l=i(98314),u=i(28874),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:h().test(t)||!d().test(t),meta:{err:e,allow:h().test(t),block:d().test(t),validationErrorAllowlist:h().source,validationErrorBlocklist:d().source}})};const d=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),h=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,n.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>h.unset()))}))},66106:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const r=i(19851),s=i(40958),n=i(38639),a=i(42659),o=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),h=i(7282),f=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),w=i(56038),v=i(31562),b=i(34102),S=i(88561),P=i(95696),_=i(17217),T=i(31843),M=i(70417),E=i(33847),D=i(28874),x=i(94678),k=i(43207),F=i(47783),C=i(16170),A=i(95141),I=i(1078),O=i(63870),L=i(89782),R=i(13940),N=i(34592),B=(0,r.lazy)((()=>(0,d.mkLogger)("img.Video")));function j(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function z(e){return(0,h.isProd)()&&(e=void 0),(0,n.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=z,t.isVideoSupported=(0,r.lazy)((async()=>{try{return!0===(await z())?.isSupportedVersion}catch(e){return B().warn("isVideoSupported",{error:e}),!1}})),(0,o.later)((()=>(0,b.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,T.lerp2d)(e,{x:76800,y:D.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:D.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,r.lazy)((()=>new S.FileCache({name:"img.videoFrame",timeoutMs:a.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,_.toNativePath_)(e))):void 0}async function U(e,t){const i=j("extractVideoFrame",e),r=P.PosixFile.for(e);if(!(0,n.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const s=await(0,R.cachedImageFile_)(r,"frame",".jpg");i.debug("extractVideoFrame("+s+")");const o=await r.mtimeMs();if(null==o)return i.throw("null mtime");const l=await(0,F.readRawTags)(r,!1);if(null==l)return i.throw("no tags");const u=(0,A.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,I.extractSizeInfoFromTags)(l,u)?.dimensions,d=await s.stat(),h=null==d?void 0:await(0,L.dimensions)(s);if(null!=d&&d.mtimeMs>o&&null!=h&&(null==c||h.height===c.height&&h.width===c.width))return i.debug("prior dest, "+s+" seems reasonable",{srcDim:c,destDim:h}),s.nativePath;const f=(0,k.extractDurationSec)(l),m=Math.min(f??0,D.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:f}),await s.applyIfEmpty_({fn_:async e=>{const t={src:r,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,v.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*a.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,F.deleteAllTags_)(e,e)},timeoutMs:(0,O.commandTimeoutMs)()}),s.nativePath}async function q(){return D.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function H(e){const t=j("needsTranscoding",e);if(!await q())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,F.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const r=i.MIMEType;if(!(0,C.isVideoMimeType)(r))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:r}});const n=(0,k.extractDurationSec)(i);if(!(0,c.gt)(n,D.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:n}});const a=(0,s.compactBlanks)([i.AudioFormat]),o=a.some((e=>(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,s.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeMimeTypes.values,r);return t.tap({level:"info",msg:"result",result:!(o&&u&&d),meta:{mimetype:r,isSafeMimeType:d,audioCodecs:a,isSafeAudioCodec:o,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>U(e)}),t.__extractVideoFrame_=U,t.isVideoTranscodingSupported=q,t.needsTranscoding=H;const $=new g.TTLMap(a.hourMs);function G(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,r){if(!await q())return;const s=j("transcode",e);{!function(){for(const[e,t]of $.entries())t.isSettled&&$.delete(e)}();const t=$.get(e.nativePath)??$.get(i.nativePath);if(null!=t)return s.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await H(e))return void s.info("no transcoding needed");const n=await e.size();if(!(0,u.gt0)(n))return s.throw("source is empty or cannot read");const a=await(0,F.readTags)(e),o=(0,I.extractSizeInfoFromTags)(a),d=(0,k.extractDurationSec)(a);if(null==a||null==o||null==d)return s.throw("failed: missing video metadata",{sizeInfo:o,durationSec:d});{const e=$.get(i.nativePath);if(null!=e)return s.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const h=new y.Deferred("transcode "+e);$.set(e.nativePath,h),$.set(i.nativePath,h);const m=(0,u.toGt0)(a.VideoFrameRate)??(0,u.toGt0)(a.FrameRate)??30,p=Math.round(o.dimensions.width*o.dimensions.height*(0,M.max)([(0,u.toGt0)(a.FrameCount),(0,u.toGt0)(a.VideoFrameCount),m*d]));if(!0===r?.force)await i.unlink();else if(await async function(e,t){const i=await(0,F.readRawTags)(t),r=await(0,F.readRawTags)(e),s=(0,k.extractDurationSec)(r),n=(0,k.extractDurationSec)(i);return B().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(s,n,1.5),meta:{srcDurationSec:s,destDurationSec:n,src:e.nativePath,dest:t.nativePath}})}(e,i))return s.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const r=j("extractMaxBitrate",e),s=D.Settings.minVideoDimension.valueOrDefault,n=i.ImageWidth;if(null!=n&&!(0,u.gte)(n,s))return r.throw("invalid width: "+n,{ignorable:!0});const a=i.ImageHeight;if(null!=a&&!(0,u.gte)(a,s))return r.throw("invalid height: "+a,{ignorable:!0});const o=(0,x.extractBitrateKbps)(i)??D.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,f.mapGt0)(n,(e=>(0,f.mapGt0)(a,(i=>(0,u.clamp)(0,o,(0,t.bitrateKps)(e*i)))))),c={width:n,height:a,videoBitrateKbps:l};return r.debug("dim()",{src:e,result:c}),c}(e,a);return await h.observe((0,w.time)("video.transcode:"+e,(async()=>{const t=G(n,g.videoBitrateKbps,d);return await i.applyWip_({fn_:n=>async function(n){s.info("starting...",{destWip:n});const o=new E.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:n,fps:m,halt:r.halt,...g},h=D.Settings.transcodeMaxDim.valueOrDefault,f=(0,M.max)([a.dimensions.height,a.dimensions.width]);if((0,u.gt0)(h)&&(0,c.gt)(f,h)){const e=(0,l.fitInside)(a.dimensions,{width:h,height:h});null==e?s.warn("Cannot downsample transcoded video: fitInside() returned null",{input:a.dimensions,maxPixels:h}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),s.info("Downsampling transcoded video",{original:a.dimensions,output:e}))}const p=await o.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&s.throw("transcode failed with code "+p.code)}(n),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&s.info("transcode complete",{src:e,dest:i,elapsedMs:h.elapsedMs,pixels:p}),i},t.guessExpectedSize=G,t.validVideo_=async function(e){return null==await W(e)&&j("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),h=i(56519),f=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),w=i(84258),v=i(28874),b=i(76280),S=i(63870),P=i(19769),_=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function T(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:v.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=T;const M=/ffmpeg version n?(?\S+)/i,E=(0,u.lazy)((async()=>{const e=await T();if(null==e)return void _().info("failed to find ffmpeg in $PATH",{ffmpegPath:v.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,S.commandTimeoutMs)(),ignoreStderr:!0}),i=M.exec(t.result)?.[1];return _().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,b.semverSatisfies)(i,">=3.2")}}));function D(){E.unset(),t.ffmpegVersionDescription.unset()}function x(e){const t=e?.ffmpegHwaccel??v.Settings.ffmpegHwaccel.valueOrDefault;return(0,s.blank)(t)||(0,n.isDisabled)(t)?[]:["-hwaccel",t]}function k(e){const t=[...v.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(v.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),r=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+r),t}function F(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function C(e){const t=v.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,h.thenMapOr)(E(),(e=>"version "+e),(()=>"(not found)")))),(0,o.later)((()=>{(0,g.ee)().on("clearCache",D),(0,g.ee)().on("clearToolCache",D)})),t.ffmpegVersion_=async function(){return await E.prior()??E.refresh()},t.isFFmpegSupported=async function(){return null!=await E()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await T(),(0,r.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:a.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,f.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*a.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=k,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await T(),(0,r.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...k(t),...C(t),...x(t),"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),...F(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){_().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,w.unlink)(t.dest,"debug");const r=(0,p.errorToS)(i,{maxLen:1024});if(!(0,n.isDisabled)(t.ffmpegHwaccel??v.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(r))return _().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return _().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await T(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},51210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotate_=t.rotateInPlace_=t.validJpeg_=t.jpegtranVersion_=void 0;const r=i(19851),s=i(42659),n=i(21605),a=i(50213),o=i(84777),l=i(57159),u=i(95696),c=i(89966),d=i(43334),h=i(63870),f=i(19769),m=d.isWin?"NUL":"/dev/null",p=(0,r.lazy)((()=>(0,a.mkLogger)("img.jpegtran")));async function g(e,t,i){const r=await(0,c.jpegtranNativePath_)();if(!(0,n.isRotation)(i))throw new Error("refusing to rotate("+e+", "+i+")");await(0,o.stdout_)(r,["-copy","all","-trim","-rotate",i.toFixed(0),"-outfile",t.nativePath,e.nativePath],{timeoutMs:s.minuteMs}),t.clear()}t.jpegtranVersion_=async function(){const e=await(0,o.stdoutResult_)(await(0,c.jpegtranNativePath_)(),["-version"],{quiet:!0,timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:()=>!0});return(e.stderr??e.result).replace(/^libjpeg-turbo version/,"").trim()},t.validJpeg_=async function(e){const t=u.PosixFile.for(e),i=await(0,c.jpegtranNativePath_)();try{await(0,o.stdoutResult_)(i,["-outfile",m,t.nativePath],{timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:f.isIgnorableValidationError,ignoreExitCode:!0})}catch(e){throw p().warn("validJpeg caught invalid file",{src:t,cause:e}),new l.WrappedError("Invalid JPEG: "+t,{cause:e,path:t.nativePath,doNotSend:!0,fatal:!1,retriable:!1})}},t.rotateInPlace_=async function(e,t){p().info("rotateInPlace("+e+")",t),await e.applyWip_({fn_:i=>g(e,i,t),skipFsLock:!1,minSizeBytes:512,timeoutMs:s.minuteMs})},t.rotate_=g},19350:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dcraw_emu_=t.raw2tiff_=t.librawSupported=void 0;const r=i(19851),s=i(40958),n=i(33374),a=i(12168),o=i(23541),l=i(54993),u=i(50213),c=i(84777),d=i(98314),h=i(38835),f=i(57159),m=i(89966),p=i(28874),g=i(16170),y=i(54979),w=i(89782),v=i(13940),b=i(42725),S=i(19769),P=(0,r.lazy)((()=>(0,u.mkLogger)("img.libraw")));t.librawSupported=async function(e){try{return(0,g.isLibrawMimeType)(await(0,y.readMimeType)(e.nativePath))}catch(t){return P().warn("librawSupported("+e+"): failed to read filetype",t),!1}},t.raw2tiff_=async function(e){return(0,v.readableToFile_)({src:e,desc:"dcraw",suffix:".tiff",f:t=>D(e,t)})};const _=["-T"],T=["-Z","-"],M=["-o","1"],E=["-t","0","-j"];async function D(e,t){const i=await(0,w.dimensions)(e);if(null==i)return P().throw("Cannot decode RAW "+e+": no EXIF dimensions."+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);const r=b.ImageSize.largestFit().outputSize(i),u=[];null!=r&&4*(0,n.dmegapixels)(r)<(0,n.dmegapixels)(i)&&(P().debug("Large original source: using -h"),u.push("-h"));const g=await(0,m.dcrawEmuNativePath_)(),y=[..._,...T,...M,...u,...E,...p.Settings.dcrawEmuArgs.values,e.nativePath],v={encoding:"buffer",timeout:p.Settings.taskTimeoutMs.valueOrDefault,maxBuffer:250*a.MB};P().debug("dcraw_emu()",{cmd:g,args:y,opts:v});const D=(0,c.execFile)(g,y,void 0,v),x=[];function k(t){const i=(0,o.isError)(t)?(0,d.errorToS)(t):(0,l.toS)(t);if((0,S.isIgnorableValidationError)(i))P().info("dcraw_emu(): warning",{src:e,msg:i});else{P().warn("dcraw_emu(): error",{src:e,msg:i});const r=(0,o.isError)(t)?t:(0,f.toWrappedError)(i,{fatal:!1});x.push(r)}}if(D.on("error",k),D.stderr.on("data",k),await t.writeStream_(D.stdout),(0,s.isNotEmpty)(x))throw new f.WrappedError("Failed to convert RAW image "+e,{causes:x,path:e.nativePath});(0,c.endProcess)(D)}t.dcraw_emu_=D},36192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const r=i(19851),s=i(84777),n=i(8103),a=i(43334),o=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,r.lazy)((async()=>a.isMac?(0,n.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,s.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(o.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},71706:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.j=void 0;const r=i(38522);t.j=function(e){return JSON.parse((0,r.brotliDecompressSync)(Buffer.from(e,"base64")).toString("utf8"))}},42042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEmail=void 0;const r=i(22573),s=i(28874),n=i(81674);t.getEmail=async function(){const e=s.Settings.email.value;if((0,r.notBlank)(e))return e;for(const e of await(0,n.m)())if((0,r.notBlank)(e.l?.sub))return e.l?.sub}},83950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.L=void 0;const r=i(79114),s=i(40958),n=i(42659),a=i(34666),o=i(48884),l=i(97352),u=i(81674),c=i(84194);t.L=class{static for(e){return new this(e.str,e.l,e.sids,e.src)}constructor(e,t,i,r){this.s=e,this._l=t,this._sids=i,this.meta={src:r}}get l(){return this._l}get ok(){if(null==this._l)return!1;const e=(0,o.intersection)(this._sids,this._l.uids),t=(0,s.uniq)(e.map(c.getScheme)),i=(0,s.compact)(t.map((e=>(0,c.prefix2scheme)(e)))),r=i.length>=this._l.mat,a=(0,l.within)(this._l.iat?.getTime(),this._l.exp?.getTime()+n.dayMs,Date.now());return this.meta[(0,u.k)().o]=a,this.meta[(0,u.k)().u]=r,this.meta[(0,u.k)().m]=i,a&&r}cmpVal(){return[this.ok,-(r.S.indexOf(this.l?.[(0,u.k)().T])??0),this.l?.exp?.getTime()??1,this.meta.matchedSchemes]}cmp(e){return(0,a.cmp)(this.cmpVal(),e.cmpVal())}}},81674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p=t.l=t.t=t.b=t.m=t.vok=t.v=t.v_=t.k=void 0;const r=i(76790),s=i(22573),n=i(38639),a=i(45599),o=i(41400),l=i(96249),u=i(55835),c=i(31586),d=i(51926),h=i(79114),f=i(23541),m=i(59455),p=i(54993),g=i(72993),y=i(19851),w=i(50213),v=i(56519),b=i(76596),S=i(46292),P=i(87290),_=i(77740),T=i(34102),M=i(83278),E=i(28874),D=i(37692),x=i(71706),k=i(83950),F=i(72042),C=i(33603),A=i(48132);t.k=(0,y.rolazy)((()=>(0,x.j)("G1UBABwHdkz4hUIkFCfPXW5LlfvrWKSr9W3AIyIhUiw68NDfvLLHVop/bGoNnRxQlnqi2TZp0IJaX+lUHBoi+vMy2LMNpHCv8xVkUGsmQsgB8ldHoDqJeUQzbdybwikWVRs2KSWKjE5LnuqhTNSp3gTLhNfE9EqBLeaXP+UM9YqTGSXcyrcL03rIPMDAVyJplSZC0xoUgguOYJKvrcYFbNArN7BrQsnnsJ4hMtcSxOTxxRdxzETtL93qa3vjDw==")));const I=(0,a.defer)((()=>(0,w.mkLogger)((0,t.k)().l)));async function O(e){const i=await(0,F.V)((0,d.ensurePrefix)((0,p.toS)(e).trim(),(0,t.k)().p)),r=(0,b.utcIsoToTs)(i[(0,t.k)().i]);if(null==r)throw new Error("bad "+(0,t.k)().i+": "+i[(0,t.k)().i]+" ("+e+")");const s=(0,b.utcIsoToTs)(i[(0,t.k)().r]);if(null==s)throw new Error("bad "+(0,t.k)().r+": "+i[(0,t.k)().r]+" ("+e+")");return(0,_.getDevEnvFlag)((0,t.k)().y)&&(i[(0,t.k)().t]=!0),i[(0,t.k)().a]=(0,c.toGte0)(i[(0,t.k)().a])??2,i[(0,t.k)().i]=new Date(r),i[(0,t.k)().r]=new Date(s),i[(0,t.k)().b]=(0,p.toS)(i.uids).split(","),i}async function L(e,i,r,n){try{return(0,s.blank)(e)||e===(0,t.k)().f?void 0:k.L.for({str:e,l:await O(e),sids:null!=n?n:await(0,C.sids)({timeoutMs:r}),src:i})}catch(i){return I().tap({msg:(0,t.k)().v,result:{s:e,ok:!1,meta:{err:i}}})}}async function R(e,t){const i=[],r=await(0,v.sortByAsync)({name:"rawLicenseFromDir("+e+")",arr:e?.childFiles(),f:e=>e.mtimeMs()});for(const e of r.reverse()){const r=await L((0,m.toA)(await e.readLines()).map((e=>e.trim())).join(""),e.nativePath,A.UserTimeoutMs,t);null!=r&&i.push(r)}return i}async function N(){const e=await(0,t.m)();return e[0]?.ok?e[0]:void 0}async function B(){return(await N())?.l?.[(0,t.k)().T]??(0,t.k)().f}t.v_=O,t.v=L,t.vok=async function(e,t,i){if((0,s.blank)(e))return;const r=await L(e,t,i);return(0,n.isTrue)(r?.ok)&&r instanceof k.L?r:void 0},t.m=(0,y.rolazy)((async()=>{if((0,_.getDevEnvFlag)((0,t.k)().x))return[];const e=await(0,C.sids)({timeoutMs:A.UserTimeoutMs}),i=(0,u.map)((0,S.configDir)(),(e=>M.BaseFile.for(e))),s=(n=(0,l.flatten)((await(0,v.someOrTimeout)([()=>function(e){return L(E.Settings[(0,t.k)().L].value,"Settings",A.UserTimeoutMs,e)}(e),()=>R(i?.join((0,t.k)().d),e),()=>R((0,P.libraryDataDirPosixFile)()?.join((0,t.k)().d),e),()=>R(i?.sibling((0,g.AppName)().toLowerCase()).join((0,t.k)().d),e)],{timeoutMs:A.UserTimeoutMs})).filter((e=>!(e instanceof Error)))),(0,r.sortBy)(n.filter((e=>null!=e&&((0,f.isError)(e)&&I().warn((0,t.k)().d+": ",e),null!=e&&!(0,f.isError)(e)&&null!=e?.l))),(e=>[!e.ok,h.S.indexOf(e.l?.[(0,t.k)().T])??h.S.length+1,-(e.l?.exp?.getTime()??1)])));var n;return I().tap({msg:(0,t.k)().d+"()",result:s})})),(0,o.later)((()=>{(0,T.ee)().on("clearCache",(()=>t.m.unset())),(0,T.ee)().on((0,t.k)().c,(()=>t.m.unset())),D.stateEvents.on((0,t.k)().c,(()=>t.m.unset()))})),t.b=N,t.t=B,t.l=async function(){try{return await B()===(0,t.k)().f}catch{return!0}},t.p=async function(){try{return await B()===(0,t.k)().g}catch{return!1}}},72042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.V=t.l=void 0;const r=i(91227),s=i(19851),n=i(22573),a=i(71706);t.l=(0,s.lazy)((()=>(0,a.j)("G54BgBwHzrkukKDR8Ar6KkW29gbXlfrqQX46gTu5Wfq6dELYTjfBokB0d5+E2SAINBtxlmPquWe3PMUoNgaJrD982QMslkNeZ4BEqcBbQT59DVl9RnoTNi50diuT7NQg0YHxkr8SwDwtmFUOf+LwNVDDnPXUrzTOU++M3b+lcyfr7PXZndKHzho8iztNkZgt+/19//aXe+gvmC0HIdnn64wdLeYeLM7S9jmjTp52SzFsvIVbd4D0+rdtdjiz6R4vc2cmY398kuXiKG7fNXWS/I93etxXiVNPd4RXJF+k6JnuMUKk03GWHQQ="))),t.V=function(e){const i=(0,r.decode)(e).payload;if(null==i)throw new Error("Missing payload");const s=(0,n.notBlankOr)(i.k,(0,t.l)().d),a=(0,t.l)().o.find((e=>e.k===s));if(null==a)throw new Error("Unknown key");return r.V2.verify(e,a)}},84194:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SchemeCounts=t.isValidUid=t.toUID=t.UidLength=t.prefix2scheme=t.sortUids=t.getScheme=t.S=void 0;const n=i(40958),a=i(76790),o=i(22573),l=i(45599),u=i(50989),c=i(54993),d=i(22454),h=i(19851),f=i(50213),m=i(37628),p=i(55222),g=i(71706),y=(0,l.defer)((()=>(0,g.j)("GyABAIzUYs0Z7mSuLfVL1SwGefr+3nCwyXBMg6nD0qduA8HycFjUGK1N/ikYqhiqYLGbs7oxTBbzRPxteP9gA3L9DS0EJ2BJ1pYNa/DtEE2aPI2o03hHx3k9MhdE7jAeRUvKQ6tY3Q1fcIPe8GBMZvOeKibTymyo3Cw/7Ua42DKPjpL3wxWv+7TCGA==")));function w(e){const i=e.split(":",1)[0];return t.S.has(i)?i:void 0}t.S=(0,u.strEnum)("cu","lc","lm","lp","lb","mp","ms","wm","cm","bm","nm","li","si","vl"),t.getScheme=w,t.sortUids=function(e){return(0,a.sortBy)((0,n.uniq)(e.filter(S)),(e=>[t.S.indexOf(w(e))??t.S.length+1,e]))},t.prefix2scheme=function(e){return y()[e]};const v=["uninitialized","b08dfa6083e7567a1921a715000001fb"];t.UidLength=15,t.toUID=function(e,i){try{const r=(0,c.toS)(i).replace(/[^a-z\d=/+]+/gi,"");return(0,o.blank)(r)||v.includes(r.toLowerCase())||null!=r.match(/^[\s0:_/-]*$/)?void 0:e+":"+(0,m.shortStringSha)(r,t.UidLength,p.Radix58)}catch(t){return void(0,f.mkLogger)("toUID").warn("failed",{pfx:e,err:t})}};const b=(0,l.defer)((()=>new RegExp(`^(?:${t.S.values.join("|")}):[0-9a-zA-Z]{${t.UidLength}}$`)));function S(e){return null!=e&&null!=b().exec(e)}t.isValidUid=S,t.SchemeCounts=class{constructor(e){r.set(this,new Set),this.schemeCounts=(0,h.lazy)((()=>{const e=new d.CountingSet;for(const t of s(this,r,"f")){const i=w(t);null!=i&&e.incr(i)}return e})),null!=e&&this.addUids(e)}get size(){return s(this,r,"f").size}addUids(e){for(const t of e)null==w(t)||s(this,r,"f").has(t)||(s(this,r,"f").add(t),this.schemeCounts.unset())}count(e){return this.schemeCounts().get(e)}},r=new WeakMap},33603:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearSids=t.addSids=t.sids=t.win_machineGuid_=t.readInfo=t.k=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(45599),o=i(96249),l=i(68708),u=i(51926),c=i(59455),d=i(54993),h=i(50213),f=i(7282),m=i(56519),p=i(84777),g=i(84542),y=i(19254),w=i(45879),v=i(70854),b=i(57902),S=i(72308),P=i(43334),_=i(24399),T=i(7014),M=i(30933),E=i(71706),D=i(84194);t.k=(0,a.defer)((()=>(0,E.j)("G9ABYIzDOIZ8NLQ4t7qW8tNrmrOzz+qFGfAxl8jW4E2tLxwWRZT5TueCnPcwgTzT1DN3veRB+e7EYGlYHg6nhjBDQv7zI6EcYWk35z6QuZC3Q0itjrLCbmgd0iED0BvGiYLBJwRU1O9/3Agbl8IfG6ITVFWDRwyTw3rbUMo/XMyAVW7R23mkwUx0l4/7iA13RV/nmPuJFKp5BvJW7SoXJZoWEfdSNYYhN5UCtkbC7O1AaPIbU3P6uRLmEyb4TaHWzFigvrlmZVUzzp9j/Mz55vqN88ewd1Nrfh7gkVRQ7TtB7Ztz3XJxYC3ogdJHg8HGsG4=")));const x=(0,a.defer)((()=>(0,h.mkLogger)((0,t.k)().n)));async function k(e=(0,t.k)().pc){if(P.isLinux)try{const t=await(0,y.fileGrep_)(e,/^\s*(?:hardware|revision|serial|model)\s*[:=]\s*[a-z\d]{6}.*$/i),i=(0,r.compactBlanks)((0,g.splitLines)(t).map((e=>e.replace(/\s+/g," ")))).sort();return i.some((e=>null!=e.match(/^serial/i)))?i:void 0}catch{return}}t.readInfo=k;const F=(0,a.defer)((()=>(0,m.thenMap)(k(),(e=>(0,D.toUID)(D.S.lc,e.join(",")))))),C=/o\.e\.m\./i;async function A(e){return(0,r.uniq)(await Promise.all((0,t.k)()[e].map((e=>(0,w.readFileMaybe)(e,b.LogLevels.trace))))).map(d.toS).filter((e=>(0,s.notBlank)(e)&&null==e.match(C)))}async function I(){return P.isLinux?(await A("lm")).map((e=>(0,D.toUID)(D.S.lm,e))):void 0}async function O(){return P.isLinux?(await A("lp")).map((e=>(0,D.toUID)(D.S.lp,e))):void 0}async function L(){return P.isLinux?(await A("lb")).map((e=>(0,D.toUID)(D.S.lb,e))):void 0}async function R(){if(P.isMac)try{return(0,l.entries)(await async function(){const e=await(0,p.stdout_)((0,t.k)().i,(0,t.k)().ia,{timeoutMs:5*n.secondMs}),i=e.match(/uuid" = "([a-z\d-]{12,})"/i)?.[1],r=e.match(/SerialNumber" = "([a-z\d-]{10,})"/i)?.[1];return{mp:i,ms:r}}()).map((([e,t])=>(0,D.toUID)(e,t)))}catch(e){return void x().warn((0,t.k)().i+" failed",e)}}async function N(){return(await _.PowerShell.instance().executeJson((0,t.k)().w))?.MachineGuid}async function B(){return P.isWin?(0,D.toUID)(D.S.wm,await N()):void 0}t.win_machineGuid_=N;const j=(0,a.defer)((()=>(0,D.toUID)(D.S.cm,(0,M.cpuInfo)()[0].model)));async function z(){return P.isLinux?(0,D.toUID)(D.S.bm,(0,r.compactBlanks)(await A("bm")).map((e=>e.trim())).join("\n")):[]}async function V(){return(0,D.toUID)(D.S.li,await((0,v.LibraryUIDStore)()?.readUid_()))}async function W(){return(0,D.toUID)(D.S.si,await((0,v.SystemUIDStore)()?.readUid_()))}function U(){return(0,S.networkMacAddresses)().map((e=>(0,D.toUID)(D.S.nm,e)))}async function q(){return(0,c.toA)(await(0,T.volumes)()).map((e=>(0,D.toUID)(D.S.vl,e.uuid)))}const H=new Set;t.sids=async function({timeoutMs:e}){const t=Date.now(),i=[j,F,R,V,W,z,I,O,L,B,U,q],r=(0,o.flatten)(await(0,m.someOrTimeout)(i,{timeoutMs:e})).filter(u.isString);for(const e of r)H.add(e);return x().tap({msg:"sids()",result:(0,D.sortUids)([...H,...r]),meta:{timeoutMs:e,elapsedMs:Date.now()-t}})},t.addSids=function(e){if((0,f.isTest)())for(const t of e)H.add(t)},t.clearSids=function(){(0,f.isTest)()&&H.clear()}},48132:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserTimeoutMs=void 0;const r=i(42659);t.UserTimeoutMs=7*r.secondMs},34474:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allRecentLogEntries=t.recentLogFiles=void 0;const r=i(40958),s=i(42659),n=i(41400),a=i(96249),o=i(68708),l=i(34666),u=i(20214),c=i(71371),d=i(50213),h=i(42638),f=i(31562),m=i(98314),p=i(89968),g=i(28874),y=i(4904),w=i(57902),v=i(89241),b=i(83954);function S(e=10*s.minuteMs){const t=Date.now()-e;return(0,u.thenMap)(p.DirectoryEntry.for(g.Settings.logDir.valueOrDefault),(e=>e.filterDescendantFiles((async e=>[".log",".log.gz"].includes(e.ext)&&(0,l.gte)(e.mtimeMs(),t)))))}t.recentLogFiles=S,t.allRecentLogEntries=async function(e=50){(0,b.writeRecentLogEntries)();const t=(0,o.fromEntries)(w.LogLevels.values.map((t=>[t,new c.BoundedGreatestSet(e,y.logEntrySorter)]))),i=Date.now()-s.hourMs,p=(0,d.mkLogger)("allRecentLogEntries()");return await(0,u.thenMap)(S(),(e=>(0,h.withBoundedConcurrency)({name:"allRecentLogEntries()",laters:e.map((e=>async()=>{try{const a=[],o=new v.LogReader(e,(e=>a.push(e)));for(await(0,f.untilTrue)((()=>o.ready()),{timeoutMs:10*s.secondMs});!o.complete()&&!o.hasErrors();){const e=o.shift();null==e?await(0,n.delay)(5):e.ts>i&&t[e.l]?.add(e)}(0,r.isNotEmpty)(a)&&(p.warn("Read error(s) for "+e,a),a.some((e=>"Z_BUF_ERROR"===e.code||(0,m.errorToS)(e).includes("unexpected end of file")))&&(0,l.lt)(e.mtimeMs(),Date.now()-s.minuteMs)&&(p.warn("Unlinking corrupt logfile "+e),await e.unlink_()))}catch(t){p.warn("Failed to read entries from "+e,t)}}))}))),(0,a.flatten)((0,o.values)(t).map((e=>e.vacuum()))).sort(((e,t)=>(0,l.cmp)(e.ts,t.ts)))}},49794:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),s=i(19851),n=i(40958),a=i(22573),o=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,s.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,a.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,n.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),s=i(23560),n=i(66184),a=i(72210);class o{log(e,t,i,r){this.enabled(e,t)&&(0,a.pushLogEntries)({ts:Date.now(),l:e,from:(0,s.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,n.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=o,o.instance=(0,r.lazy)((()=>new o))},14593:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),s=i(22573),n=i(26905),a=i(55835),o=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,s.toNotBlank)(e)??(0,n.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,o.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),s=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:s}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,a.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,o.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),s=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof s.LogWriter))}},28981:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),s=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new s.PlaintextLogFormatter))},31256:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(41400),o=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function w(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,n.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,a.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,s.uniq)((0,s.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,o.stringify)({...t,...w(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,o.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const n=i(77030),a=i(19851),o=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),w=i(31256),v=i(28538),b=(0,a.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),S=String.fromCharCode(0);t.logBroadcaster=(0,a.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,o.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&b().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new w.GelfLogFormatter,this.logFilter=new v.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,n.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{b().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){b().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),s(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,n){if(this.enabled(e,t))try{const a=this.socket;null==a?s(this,r,"f").call(this):a.write(this.logFormatter.format(e,t,i,n)+S)}catch(r){b().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:n,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),s=i(42659),n=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??n.Settings.logDir.valueOrDefault,(0,s.fmtIsoDate)(t??new Date))}},4904:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),s=i(31586),n=i(51926),a=i(57902);t.isLogEntry=function(e){return null!=e&&(0,s.isNumber)(e?.ts)&&(0,n.isString)(e?.msg)&&a.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),s=i(57902);class n{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,s.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,s.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=n,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new n(s.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>s.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,s.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,s.set(this,[]),n.set(this,(0,l.lazy)((()=>{o(this,s,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:o(this,s,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>o(this,n,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=o(this,r,"m",a).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=o(this,r,"m",a).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){if(null==e||0===o(this,s,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return o(this,s,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),s=i(31586),n=i(50989);t.LogLevels=(0,n.strEnum)("fatal","error","warn","info","debug","trace");const a=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??a},t.levelGte=function(e,i){return(0,s.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const o=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return o.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),s=i(68708),n=i(20214),a=i(51926),o=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,a.isString)(i)||Buffer.isBuffer(i))return(0,a.ellipsize)(i.toString(),256,32);if((0,o.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,n.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const o=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,s.keys)(i),(0,s.keys)(o));return(0,r.isNotEmpty)(c)&&(o["…"]="omitted: "+(0,a.ellipsize)(c.join(", "),128,32)),o}return i}},89241:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogReader=void 0;const d=i(73024),h=i(38522),f=i(4001),m=i(14977),p=i(33456),g=i(92322),y=i(4904),w=i(98192);t.LogReader=class{constructor(e,t){if(r.add(this),this.f=e,this.start=Date.now(),this.lines=new g.SortedSet(y.logEntrySorter),s.set(this,!1),n.set(this,!1),a.set(this,!1),this.from=(0,f.stripCopySuffixFromName)(e.name),this.fileStream=(0,d.createReadStream)(e.nativePath,{autoClose:!0}),!(0,m.isExtOrCompressedExt)(e.ext,".log"))throw new Error(e+" is not a logfile");this.stream=(e.ext.toLowerCase().endsWith(".gz")?this.fileStream.pipe((0,h.createGunzip)()):e.ext.toLowerCase().endsWith(".br")?this.fileStream.pipe((0,h.createBrotliDecompress)()):this.fileStream).pipe(new p.LineReader).on("error",(e=>{t(e),u(this,a,!0,"f")})),this.stream.on("data",c(this,r,"m",o).bind(this)),this.stream.on("close",(()=>{this.fileStream.resume(),u(this,s,!0,"f")})),this.stream.on("end",(()=>{u(this,s,!0,"f")}))}toString(){return"LogReader("+this.f.nativePath+")"}status(){return{hasErrors:c(this,a,"f"),ended:c(this,s,"f"),destroyed:this.stream.destroyed,lines:this.lines.length,paused:c(this,n,"f")}}hasErrors(){return c(this,a,"f")}get ended(){return c(this,s,"f")}ready(){return this.ended||this.lines.length>32}complete(){return this.ended&&0===this.lines.length}peek(){return this.ready()?this.lines.at(0):void 0}shift(){const e=this.lines.shift();return null!=e&&c(this,r,"m",l).call(this),e}shiftLte(e){const t=this.lines.shiftLte(e);return t.length>0&&c(this,r,"m",l).call(this),t}},s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e){if(null===e)u(this,s,!0,"f");else{const t=(0,w.chunkToLogEntry)(e);null!=t&&this.lines.add({...t,from:this.from}),this.lines.length>10240&&!c(this,n,"f")&&(this.fileStream.pause(),u(this,n,!0,"f"))}},l=function(){this.lines.length<1024&&c(this,n,"f")&&(this.fileStream.resume(),u(this,n,!1,"f"))}},24068:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),s=i(76760),n=i(1708),a=i(87997),o=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),w=i(22277),v=i(25764),b=i(38836),S=i(99331),P=i(42638),_=i(76596),T=i(98314),M=i(89968),E=i(29882),D=i(28874),x=i(28981),k=i(20839),F=i(21727),C=i(66184),A=i(57902),I=i(72210),O=i(98192);function L(e){const t=(0,x.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=L;class R extends b.EndableWrapper{constructor(e=void 0,t=L){super("LogTail",(()=>this.close()),v.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new w.TTLSet(5*u.secondMs),this.setup=(0,o.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,D.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,E.mkdirp_)(e),this.root=await M.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=s.sep+(0,p.serviceName)()+"-"+n.pid+"-",n.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,a.setInterval)((()=>this.flush()),k.DefaultLogFlushMs/2),this.scanTimeout=(0,a.setInterval)((()=>this.scan()),u.minuteMs),n.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,S.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,C.ifLog)(A.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,s.join)(e,i))}))}catch(t){return void(0,C.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,T.errorToS)(t))))}}))}async scan(e=!1){if((0,S.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,_.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,S.ending)()||this.ended)return;const t=(0,F.datedLogDir)(this.root.nativePath);try{await(0,E.mkdirp_)(t),this.watchDir(t)}catch(e){(0,C.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,T.errorToS)(e))))}(0,S.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,a.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,a.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await M.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(r,i))return;await(0,f.thenMap)((0,O.readLogEntries)(e,{start:r,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,C.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,T.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,o.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),s=i(82328),n=i(28981),a=i(20839),o=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(o.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,s.stdoutEnded)()||console.log((0,n.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*a.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),w=i(31586),v=i(409),b=i(23560),S=i(81168),P=i(78406),_=i(25764),T=i(20197),M=i(14977),E=i(36868),D=i(28874),x=i(32105),k=i(20839),F=i(21727),C=i(66184),A=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class O extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*k.DefaultLogFlushMs),rank:_.EndableRanks.logger,unref:!0,onEnd:()=>c(this,s,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,s.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:x.ConsoleLogger.instance(),flushEveryMs:k.DefaultLogFlushMs,processName:b.processName,logFilter:C.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,v.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",n).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const s={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(s.meta=(0,A.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(s)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=O,s=new WeakMap,r=new WeakSet,n=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,w.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),s=e.splice(0,i);this._linesSinceRotate+=s.length,t.write(s.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},a=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},o=function(e){return t=>(c(this,r,"m",a).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,S.stripAnsiEsc)(this.logOpts.processName()),t=await(0,T.ensureNewNativePath_)({nativePath:(0,f.join)((0,F.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,r,"m",o).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,E.endStream)(e.stream),D.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,M.gzip_)(e.nativePath))}catch(e){c(this,r,"m",a).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(68708),o=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,a.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,s.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,n.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),s=i(84542),n=i(4001),a=i(13047),o=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,o.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,n.stripCopySuffixFromName)(e.name),r=[],o=await(0,a.zcat)(e.nativePath,t);if(null!=o)for(const e of(0,s.splitLines)(o)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),s=i(76790),n=i(68708),a=i(89788),o=i(57902);t.SentLogLevels=(0,r.lazy)((()=>o.LogLevels.values.filter((e=>e!==o.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,n.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new a.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,n.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,n.values)(l()))e.push(...t.toA());return(0,s.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),s=i(41400),n=i(55835),a=i(37975),o=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),w=i(66184),v=i(28538),b=i(24068),S=i(43705),P=i(51879);function _(){(0,w.logFilter)()instanceof v.LogFilterImpl||w.logFilter.set(new v.LogFilterImpl),T();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new S.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,n.map)((0,y.logBroadcaster)(),(e=>i.push(e))),o.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&b.LogTail.instance()}function T(){const e=h.Settings.logColor.valueOrDefault;(0,a.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=_,t.setupLogFormatter=T,(0,s.later)((()=>{h.Settings.logStdout.watchLater(_),h.Settings.logDir.watchLater(_),h.Settings.tailLogs.watchLater(_),h.Settings.logColor.watchLater(T),h.Settings.logLevel.watchLater((()=>w.defaultLogLevel.unset()))}))},83954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeRecentLogEntries=void 0;const r=i(89179);t.writeRecentLogEntries=function(){return(0,r.currentFileLogger)()?.writeRecentLogEntries()}},82647:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const a=i(57975),o=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,a.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return n(this,r,"m",s).call(this,-1)}get p29(){return n(this,r,"m",s).call(this,-.5)}get p38(){return n(this,r,"m",s).call(this,-.25)}get p69(){return n(this,r,"m",s).call(this,.5)}get p84(){return n(this,r,"m",s).call(this,1)}get p98(){return n(this,r,"m",s).call(this,2)}get p99(){return n(this,r,"m",s).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,o.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,o.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,o.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,s=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),s=i(55835),n=i(31586),a=i(30976),o=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,n.clamp)(0,i,(0,n.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,s.map2)(e,t,((e,t)=>(0,r.sum)((0,o.zip)(u(e,i),u(t,i)),(([e,t])=>(0,n.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,n.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,a.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),s=this.clampValue(e);let n=0;for(let e=0;ea?(n+=1,i[t]=a):r[t]=a}return n}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let s=0;s(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,n.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;in?(t+=1,s.min=n):s.max=n}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},44983:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.kmeans=void 0;const r=i(76790),s=i(93973);t.kmeans=function(e,t,i){const n=s(e,t,i);return{...n,centroids:(0,r.sortBy)(n.centroids.filter((e=>e.size>0)),(e=>-e.size))}}},31843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const r=i(76790);function s(e,t,i=.5){return(1-i)*e+i*t}t.lerp=s,t.lerp2d=function(e,...t){const i=(0,r.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[n,a]=(0,r.sortBy)(i,(e=>e.x)),o=a.x-n.x,l=(e-n.x)/o;return s(n.y,a.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},75503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modeReduce=t.submatrixCollect=t.greatestHalf=t.leastVariantQuarter=t.leastMagQuarter=t.submatrixMode=t.submatrixStdDev=t.submatrixMagnitude=t.submatrixForEach=t.index1D=t.slice=t.matXvec=t.vecXvec=void 0;const r=i(40958),s=i(31586),n=i(48884),a=i(82647),o=i(70417);function l(e,t,i,r){const s=Math.floor(Math.max(0,t.row)),n=Math.ceil(Math.min(e.row,i.row)),a=Math.floor(Math.max(0,t.col)),o=Math.ceil(Math.min(e.col,i.col));for(let t=s;t(0,s.mapFinite)(e[t],(e=>n+=e*e)))),Math.sqrt(n)}function c(e,t,i,r){const n=new a.Average;return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),n.stdDev}function d(e,t,i,r){const n=[];return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),(0,o.mode)(n)}t.vecXvec=function(e,t){return e.map(((e,i)=>e*t[i]))},t.matXvec=function(e,t){return e.map(((e,i)=>{if(e.length!==t.length)throw new Error("misshaped matrix on row "+i);return(0,o.sumf)(e,((e,i)=>e*t[i]))}))},t.slice=function(e,t,i){const s=Math.max(0,t.row),n=Math.min(e.length,i.row),a=Math.max(0,t.col),o=Math.min(e[0].length,i.col);return(0,r.range)(s,n,(t=>e[t].slice(a,o)))},t.index1D=function(e,t,i){return t*e.col+i},t.submatrixForEach=l,t.submatrixMagnitude=u,t.submatrixStdDev=c,t.submatrixMode=d,t.leastMagQuarter=function(e,t){const i=t.col,r=t.row,s=[u(e,t,{col:i/2,row:0},{col:i,row:r/2}),u(e,t,{col:0,row:0},{col:i/2,row:r/2}),u(e,t,{col:0,row:r/2},{col:i/2,row:r}),u(e,t,{col:i/2,row:r/2},{col:i,row:r})];return(0,n.leastIndex)(s)},t.leastVariantQuarter=function(e,t){const i=t.col,r=t.row;return(0,n.leastIndex)([c(e,t,{col:i/2,row:0},{col:i,row:r/2}),c(e,t,{col:0,row:0},{col:i/2,row:r/2}),c(e,t,{col:0,row:r/2},{col:i/2,row:r}),c(e,t,{col:i/2,row:r/2},{col:i,row:r})])},t.greatestHalf=function(e,t){const i=t.col,r=t.row,s=[d(e,t,{col:0,row:0},{col:i,row:r/2}),d(e,t,{col:0,row:0},{col:i/2,row:r}),d(e,t,{col:0,row:r/2},{col:i,row:r}),d(e,t,{col:i/2,row:0},{col:i,row:r})];return(0,n.greatestIndex)(s)},t.submatrixCollect=function(e,t,i){const r=[];return l(e,t,i,(e=>r.push(e))),r},t.modeReduce=function(e,t,i){const o=Math.floor(t.col/i.col),u=Math.floor(t.row/i.row),c=new a.Average(Math.ceil(o*u));return(0,n.concat)(...(0,r.stepRange)(0,t.row,u,(i=>(0,r.stepRange)(0,t.col,o,(r=>(c.clear(),l(t,{col:r,row:i},{col:r+o,row:i+u},(t=>(0,s.mapFinite)(e[t],(e=>c.push(e))))),c.sampleMode))))))}},36372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stableContentShuffle=t.stableIndexShuffle=t.factors=t.primeSeeds=t.primeInt=t.primes=t.prng=t.prngOrderByClause=void 0;const r=i(76790),s=i(42659),n=i(31586),a=i(97238),o=i(50597),l=i(9103),u=i(55222);function c(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e),u=(s*i*i+n*i)%r,c=(a*i+o)%r;return Math.round((u*c+l)%r)}function d(e){return(0,u.encodeDigits)(a.PrimesPerBin,e,a.PrimeBins).map(((e,i)=>t.primes[i][e]))}t.prngOrderByClause=function(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e);return`(((${s}*${i}*${i}+${n}*${i})%${r})*((${a}*${i}+${o})%${r})+${l})%${r}`},t.prng=c,t.primes=[[353868013,472882027,479001599,517294153],[1012573,1230587,1355297,1572751],[756065159,812182027,899809343,989450477],[3959297,4514113,4823201,5133127],[573259391,666101999,694847533,746151647],[2275327,2770513,3073703,3511973],[173313197,182557181,203457869,222230231],[6054613,6189107,7752103,9852103]],t.primeInt=[1012573,1101689,1183811,1196089,1230587,1355297,1419641,1483733,1572751,2275327,2770513,3010349,3073703,3118691,3174823,3511973,3959297,4514113,4690451,4823201,5133127,5375327,6019889,6054613,6189107,7752103,7752103,9852103],t.primeSeeds=d,t.factors=(0,l.memoize)((e=>{const[i,r,s,o,l,u,c,h]=d(e%a.SeedCount),f=[i/r,s/o,l/u,c/h].map((e=>(0,n.sigFigs)(e,7)));return f.push(t.primeInt[e%t.primeInt.length]),f}),{maxSize:128,ttlMs:s.minuteMs}),t.stableIndexShuffle=function(e,t=1){return(0,r.sortBy)(e,((i,r)=>c(t,r,e.length)))},t.stableContentShuffle=function(e,t=1){return(0,r.sortBy)(e,(e=>(0,o.numericSha)(String(e)+t)))}},55222:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),s=i(22573),n=i(55835),a=i(32639),o=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,n.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,s.blank)(e))return;const t="-"===(e=(0,a.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),s=this.normalizeToken(t);return r.length>=i&&r===s}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const r=i(31586),s=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,r.toInt)(e)]??(0,s.toS)(e)}},38812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SquareMatrix=t.rotateSquareMatrix=void 0;const r=i(21605);t.rotateSquareMatrix=function(e,t){return 0===(0,r.normalizeRotation)(t)?e:new s([...e]).rotate(t).m};class s{constructor(e,t=1){if(this.m=e,this.ary=t,this.rows=Math.sqrt(e.length/t),this.rows!==Math.floor(this.rows))throw new Error(`Only square tuple matrices are supported: ${1===this.ary?"":this.ary}(${this.rows}×${this.rows}) != ${e.length}`)}index(e,t){return this.ary*(t+e*this.rows)}swap(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),s=i(65713);function n(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=n,t.safeUUID=function(){return(0,s.decuss)(n)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const o=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function w(e,t){let i=0,r=0;for(const s of e){if(null!=s){const e=t(s,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=w;class v{constructor(){r.set(this,0),s.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(a(this,s,null==n(this,s,"f")?e:n(this,s,"f")*n(this,r,"f")/(n(this,r,"f")+1)+e/(n(this,r,"f")+1),"f"),a(this,r,(t=n(this,r,"f"),++t),"f"))}get mean(){return n(this,s,"f")}}function b(e){const t=new v;for(const i of e)t.push(i);return t.mean}function S(e){const t=b(e);if(null==t)return;let i=0,r=0;for(const s of e)(0,u.isNumber)(s)&&(r++,i+=(s-t)*(s-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function _(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+a*(e-s)/n)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=b(t);if(null!=i){const e=(t.length-1)/2,r=w(t,((t,r)=>(t-i)*(r-e))),s=w(t,(e=>(e-i)**2));return 0===s?0:r/s}},t.variance=S,t.stdDev=function(e){return(0,l.map)(S(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,o.isEmpty)(e)&&(0,o.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},23624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64encodeBits=t.b64hammRatio=t.gz64decodeString=t.d=t.gz64encodeString=t.b64decode=t.b64encode=t.hex2b64=void 0;const r=i(38522),s=i(22573),n=i(97352);function a(e){const t=e.toString(16),i=t.length%2==0?"":"0";return Buffer.from(i+t,"hex").toString("base64")}function o(e){return BigInt("0x0"+Buffer.from(e,"base64").toString("hex"))}function l(e){return(0,r.gunzipSync)(Buffer.from(e,"base64")).toString("utf8")}t.hex2b64=function(e){return Buffer.from(e,"hex").toString("base64")},t.b64encode=a,t.b64decode=o,t.gz64encodeString=function(e){return(0,r.gzipSync)(Buffer.from(e,"utf8")).toString("base64")},t.d=l,t.gz64decodeString=l,t.b64hammRatio=function(e,t){return(0,s.mapNotBlank)(e,(e=>(0,s.mapNotBlank)(t,(t=>(0,n.hammRatioBigInt)(o(e),o(t))))))},t.b64encodeBits=function(e){return a(BigInt("0b0"+e.map((e=>1===e?"1":"0")).join("")))}},49076:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const s=r(i(48161)),n=i(19851),a=i(22573),o=i(41400),l=i(81168),u=i(28874);t.hostname=(0,n.lazy)((()=>u.Settings.hostname.value??s.default.hostname())),(0,o.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,a.blank)(e)&&!(0,a.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??s.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},43205:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemUserAgent=t.simpleUserAgent=t.userAgent=void 0;const r=i(72993),s=i(17344),n=i(96175),a=i(37805),o=i(81674),l=i(28874);function u(){return r.SimpleAppName+a.version}async function c(){return u()+" ("+(0,n.osFullName)()+") "+(0,s.EditionType)().toLowerCase()+"/"+await(0,o.t)()}t.userAgent=async function(){return l.Settings.allowUserAgent.valueOrDefault?c():u()},t.simpleUserAgent=u,t.systemUserAgent=c},72308:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLocalhost=t.isLoopback=t.myExternalIp4Addresses=t.myExternalIpAddresses=t.networkMacAddresses=t.myIpAddresses=void 0;const r=i(48161),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(96249),u=i(31586),c=i(68708),d=i(50213),h=i(81168);function f(){return(0,t.myIpAddresses)().filter((e=>!g(e)))}t.myIpAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.address))))),o.minuteMs),t.networkMacAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.mac)))).filter((e=>"00:00:00:00:00:00"!==e))),o.minuteMs),t.myExternalIpAddresses=f,t.myExternalIp4Addresses=function(){return f().filter((e=>!e.includes(":")))};const m=(0,s.lazy)((()=>(0,d.mkLogger)("net.ip"))),p=[/^(?:::ffff:)?127\.\d{1,3}.\d{1,3}.\d{1,3}$/i,/^::1$/];function g(e){return(0,a.notBlank)(e)&&(127===function(e){const t=e.split(".").map((e=>(0,u.toInt)(e)));return 4!==t.length||t.some((e=>null==e||!(0,u.within)(0,255,e)))?void 0:t}(e)?.[0]||p.some((t=>null!=t.exec(e))))}t.isLoopback=g,t.isLocalhost=function(e){return m().tap({msg:"isLocalhost",level:"info",result:!(0,a.blank)(e)&&((0,t.myIpAddresses)().includes(e)||(0,t.myIpAddresses)().includes((0,h.stripPrefix)(e,"::ffff:"))||g(e)),meta:{address:e}})}},96128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),w=i(34102),v=i(26293),b=new RegExp("^"+v.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==b.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const S=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=S.exec(e)}function _(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=_,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,n.blank)(e)){if(null!=_(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void T().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs});const T=(0,s.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,o.later)((()=>(0,w.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=_(e)?r.promises.reverse(e):r.promises.resolve4(e),5*a.secondMs);if(t===c.Timeout)return T().info("nslookup("+e+"): timeout"),e;const i=t.find(n.notBlank);return null==i?(T().warn("No name found for "+e),e):i}catch(t){return T().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,n.blank)(e)&&!(0,n.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),s=i(42659),n=i(31586),a=i(97790),o=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*s.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,n.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,a.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,o.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs})},78330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const r=i(40958),s=i(22573),n=i(45599),a=i(59455),o=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),h=i(63870),f=(0,n.defer)((()=>(0,o.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,a.toA)(await async function(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return f().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,r.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(f().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),s=i(38639),n=i(19851),a=i(59958),o=i(43334);t.isDocker=(0,n.lazy)((()=>o.isLinux&&((0,s.toBoolean)(process.env[a.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),s=i(19851),n=i(54993);t.isPacked=(0,s.lazy)((()=>!(0,n.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const r=i(45599),s=i(50213),n=i(84777),a=i(68284),o=i(63870),l=i(43334),u=(0,r.defer)((()=>(0,s.mkLogger)("platform.Pacman")));t.hasPacman=(0,r.defer)((()=>l.isLinux&&(0,a.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,n.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,o.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(22573),o=i(38639),l=i(59958),u=s.default.platform();t.inspectFlag=n.default.argv.includes("--inspect")||(0,o.isTrue)(n.default.env.NODE_INSPECT),t.isCI=(0,o.isTrue)(n.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,a.notBlank)(n.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===s.default.arch(),t.isArm=null!=/^arm\b/i.exec(s.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,a.notBlank)(n.default.env.APPIMAGE)||(0,a.notBlank)(n.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,a.notBlank)(n.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=n.default.versions.electron,t.isElectron=t.isMainElectron||(0,o.isTrue)(n.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const s=r(i(73024)),n=i(19851),a=i(43334);function o(e="/proc/cpuinfo"){if(a.isWin||a.isMac)return!1;try{return null!=s.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=o,t.isRaspberryPi=(0,n.lazy)((()=>a.isLinux_arm&&o())),t.procDeviceModel=(0,n.lazy)((()=>{try{return a.isLinux?s.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},94137:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.negateFilterName=void 0;const r=i(22573),s=i(51926),n=i(83556);t.negateFilterName=function(e){if((0,r.blank)(e))return;const t=/\s/.test(e)?e:(0,n.camel2words)(e).replace(/\bphoto structure\b/gi,"PhotoStructure");return t.match(/^not\b/)?t.replace(/^not\b/,"").trim():"not "+(0,s.stripPrefix)(t,"is ")}},78984:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Predicates=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(51926),o=i(50213),l=i(94137),u=(0,r.lazy)((()=>(0,o.mkLogger)("predicates.Predicates")));class c{static async accepted(e,...t){for(const i of t)for(const t of(0,n.values)(i)){const i=await t(e);if(!1===i||(0,a.isString)(i))return!1}return!0}static async rejected(e,...t){return!await c.accepted(e,...t)}static async explain(e,...t){const i=[],r=[],s=[];for(const o of t)for(const[t,l]of(0,n.entries)(o)){const n=await l(e);!0===n?i.push(t):!1===n||(0,a.isString)(n)?r.push(t):s.push(t)}return{accepted:i,rejected:r,notApplicable:s}}static async whyRejected(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))try{const i=await r(e);if(null==i||!0===i)continue;return(0,a.isString)(i)?i:(0,l.negateFilterName)(t)}catch(e){u().warn("whyRejected() caught from "+t,{error:e})}}static async logged({a:e,logger:t,msg:i,predicates:r}){const{accepted:n,rejected:a}=await c.explain(e,...r);return t.tap({msg:i,result:(0,s.isEmpty)(a),meta:{a:e,accepted:n,rejected:a}})}}t.Predicates=c},33995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncPredicates=void 0;const r=i(68708),s=i(94137);class n{static firstFalse(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!1===s(e))return t}static firstTrue(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!0===s(e))return t}static firstDefined(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i)){const i=s(e);if(null!=i)return{name:t,result:i}}}static accepted(e,...t){return null==n.firstFalse(e,...t)}static whyRejected(e,...t){return(0,s.negateFilterName)(n.firstFalse(e,...t))}}t.SyncPredicates=n},45643:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),s=i(59455),n=i(31562);t.existingPids=function(e){return(0,s.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,n.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),w=i(97790),v=i(59455),b=i(54993),S=i(54557),P=i(19851),_=i(50213),T=i(88158),M=i(409),E=i(78406),D=i(25764),x=i(99331),k=i(56519),F=i(46292),C=i(8769),A=i(83278),I=i(32144),O=i(29882),L=i(43334),R=i(24399),N=i(58261),B=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),j=10*p.secondMs;function z(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,O.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,v.toA)(t))B().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{B().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??L.isWin,r=await this.pidfiles(),s=await this.pids(r??[]);if((0,f.isEmpty)(s))return B().info("killOldProcs(): no pidfiles"),[];const n=[],a=[],o=await(0,N.pidInfos)(s);if(null!=o){for(const s of r){const r=await s.readJson();if(null==r){B().warn("killOldProcs(): failed to read pidfile "+s.base),await s.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){B().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+s.base,{json:r,pid:l}),await s.unlink("debug");continue}const u=o.find((e=>e.pid===l));if(null==u||!z(r,u)){B().debug("killOldProcs(): pid no longer present: unlinking "+s.base,{json:r,pidEntry:u}),await s.unlink("debug"),n.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(B().info("killOldProcs(): killing",{reason:d,json:r}),a.push(W(l,i,!1)),n.push({...r,...u}))}return a.length>0&&await Promise.allSettled(a),n}(0,C.onError)("Pids.killOldProcs(): failed to get process information")}}),a.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const a=e.pid;if(!(0,y.gt0)(a))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(a)?(i&&o(this,s,"f").delete(l),o(this,s,"f").getOrSet(l,(async()=>{const i=o(this,r,"m",n).call(this,e.pid),s=(0,w.opt)((0,T.Try)((()=>(0,O.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),a=t.getTime(),l={...e,cmd:s,startTime:a};return await i.writeJson_(l),B().debug("addPid() wrote "+i,l),i}))):(o(this,s,"f").delete(l),void B().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,v.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=o(this,r,"m",n).call(this,e);return(0,k.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{B().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==o(this,a,"f")||o(this,a,"f").ended)&&l(this,a,new E.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:D.EndableRanks.first}),"f"),o(this,a,"f")}cancelInterval(){o(this,a,"f")?.end(),l(this,a,void 0,"f")}}t.Pids=U,s=new WeakMap,a=new WeakMap,r=new WeakSet,n=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,F.configDir)(),(e=>new U(A.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const s=i(31421),n=i(48161),a=r(i(1708)),o=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),w=i(84968),v=i(48963),b=i(56519),S=i(84777),P=i(8103),_=i(45879),T=i(43334),M=i(24399),E=i(45643),D=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function x(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function k(e){if(T.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,_.readFileMaybe)("/proc/"+i+"/stat")));return D().tap({msg:"pidInfoProc",result:(0,o.compact)(t)})}(e);const t=(0,E.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,T.isWin?I:N)).filter((e=>x(e)&&t.includes(e.pid)));return D().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=x,t.pidInfo=async function(e){return(0,b.thenMap)(k([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,o.isEmpty)(e)?[]:(0,b.thenMap)((0,E.existingPids)(e),(t=>{const i=[a.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=k;const F="Get-Process",C="| Select-Object -Property Id,ProcessName,StartTime";function A(e){return(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).join(",")}async function I(e){if(M.PowerShell.instance().ended)return R(e);const t=[F,"-Id",A(e),"-ErrorAction SilentlyContinue",C].join(" ");return(0,b.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,v.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const O={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},L=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,o.isNotEmpty)(e)){const i=(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",L.join(","));const i=await(0,S.stdoutResult_)((0,P.wmic)(),t,O),r=(0,d.onlyReqValued)((0,p.parseFixed)(L,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,v.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return r.find((e=>e.pid===a.default.pid))||r.push({pid:a.default.pid,start:new Date(w.StartTs),cmd:"node "+a.default.title}),r}async function N(e){return t=(await(0,S.stdoutResult_)("ps",["-p",A(e),"-wwwo","pid,lstart,command"],{...O,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const B=(0,g.lazy)((()=>{try{if(T.isLinux)return(0,c.toGt0)((0,s.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){D().warn("clk_tck failed",{error:e})}return 100})),j=(0,g.lazy)((()=>Date.now()-(0,n.uptime)()*u.secondMs)),z=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=z.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,s=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(s)?{pid:i,cmd:r,start:new Date(j()+s/B()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(29882),o=i(97352);t.progressEvtToS=function(e){const t=(0,s.blank)(e.path)?null:(0,a.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,n.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,s.notBlank)(e.op)&&(0,o.within)(0,100,e.pct)}},41944:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),s=i(42659),n=i(31586),a=i(12089),o=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new o.TTLMap(15*s.secondMs))),t.recentDone=(0,r.lazy)((()=>new o.TTLMap(2*s.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,n.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,a.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),s=i(31586),n=i(409),a=i(78406),o=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends a.EndableInterval{constructor(e,t,i,s=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:s,rank:o.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=s,this.start=Date.now(),this.onInterval=(0,n.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,s.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,s.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},38156:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushProgressObserver=void 0;const r=i(31586),s=i(41944);t.PushProgressObserver=class{constructor(e,t){this.context=e,this.total=t,this.start=Date.now()}toJSON(){}incrProgress(e=1){this.onProgress(e+(this.current??0))}onProgress(e){this.current=(e??this.current??0)+1,(0,r.gte)(this.current,this.total)&&(this.done=!0),this.emit()}completed(){this.done=!0,this.current=this.total,this.emit()}emit(){(0,s.emitProgressEvt)({...this.context,pct:(0,r.pct)(this.current,this.total),elapsedMs:Date.now()-this.start,done:this.done})}}},24399:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),w=i(99331),v=i(56519),b=i(31562),S=i(84777),P=i(34102),_=i(43334),T=i(28874),M=i(63870),E="{ready}",D=" | ConvertTo-Json -Compress";function x(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=x,(0,o.later)((()=>(0,P.ee)().on("clearCache",(()=>k.instance.prior()?.clearMockResults()))));class k extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,S.execFile)("powershell",T.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${E}"}`,...(0,n.mapNotBlankOr)(T.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:E,fail:"Error",exitCommand:"exit",maxProcs:T.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:a.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),T.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(T.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,v.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,D),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,w.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,s)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,s)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,D),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,n.blank)(t.stdout)||(0,n.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,v.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+x(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=k,k.instance=(0,s.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new k})),t.checkPowerShell_=async function(){const e=k.instance();if(e.ended||(0,w.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,n.blank)(t)){const t=await(0,b.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),s=i(38639),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toBoolean})}}t.BooleanSetting=a},90536:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).flatMap(parseFloat).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=o},75164:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).filter(r.notBlank).flatMap(s.toInt).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,s.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=o},10546:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),s=i(22573),n=i(45599),a=i(50213),o=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,n.defer)((()=>(0,a.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,o.trimQuotes)(e);return void((0,s.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,s.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),s=i(91655),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,s.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=a;class o extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=o},9945:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.FloatSetting=a},69589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.forceContextOrSetting=t.pickForceContext=void 0;const r=i(38639),s=i(68708),n=i(50989),a=i(76740),o=i(28874),l=(0,n.strEnum)("forceSync","forceFilters","skipPreviews","forceRebuildPreviews","skipAssetTagging","recountAllTags","skipAssetRepair");t.pickForceContext=function(e){return(0,s.pick)(e,...l.values)},t.forceContextOrSetting=function(e){const t={...(0,s.pick)(e??{},"retries","halt","path"),...(0,s.fromEntries)(l.values.map((t=>[t,e?.[t]??(0,r.isTrue)(o.Settings[t]?.valueOrDefault)])))};return t.retries??(t.retries=0),t.halt??(t.halt=new a.Abortable),t}},74589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt})}}t.IntegerSetting=a},86941:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAndArchiveSystemSettingsDir_=t.mergeUserDataDirs_=void 0;const r=i(19851),s=i(59455),n=i(72993),a=i(46292),o=i(95696),l=i(50213),u=i(83179),c=i(28874),d=i(2858),h=i(84438),f=(0,r.lazy)((()=>(0,l.mkLogger)("settings.MergeConfigDirs")));async function m(e,t){let i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+e.baseWithGrandparent+" => "+t.baseWithGrandparent+")");const r=await e.resolve_(),n=await t.resolve_();if(null==r||null==n||n.nativePath===r.nativePath)return void i.info("no-op, missing or same directory",{priorResolvedConfigDir:r?.nativePath,currentResolvedConfigDir:n?.nativePath});if(i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+r.baseWithGrandparent+" => "+n.baseWithGrandparent+")"),!await r.isDirectory())return void i.info("no-op, prior directory doesn't exist");{const e=r.join(h.SettingsToml);if(await e.isNonEmptyFile()){const t=n.join(h.SettingsToml);await(0,d.readSystemSettings)(e),i.info("read prior settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.readSystemSettings)(t),i.info("read current settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.writeSystemSettings_)(t)}}{const e=r.join("licenses"),t=n.join("licenses");for(const r of(0,s.toA)(await e.childFiles())){const e=t.join(r.base);if(await e.notExists())try{await r.copyFile_(e),i.info("Copied license "+r.base)}catch(e){i.warn("Failed to copy license "+r.base,e)}}}const a=n.join("old");try{const e=await r.renameYMDHMS_({subdir:a.nativePath});i.info("merged and archived to "+e)}catch(e){i.warn("Failed to archive to "+a,e)}}t.mergeUserDataDirs_=async function(){const e=(0,a.configDir)();if(null==e)return;const t=o.PosixFile.for(e);for(const e of[t.join((0,n.AppName)()),t.join((0,n.AppName)().toLowerCase()),t.parent().join((0,n.AppName)().toLowerCase())])try{await m(e,t)}catch(i){f().error("Failed to merge "+e+" and "+t,i)}f().info("done")},t.mergeAndArchiveSystemSettingsDir_=m},4175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),s=i(22573),n=i(38639),a=i(42659),o=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function w(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function v(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){_(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&w(),y("strictDeduping",e)&&v(),(y("optOut",e)||y("noNetwork",e))&&T()},t.handleDeprecatedSettings=async function(){if((0,n.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,s.blank)(m.Settings.assetPathnameFormat.value)&&(0,s.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*a.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=w,t.setStrictDeduping=v;const b=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],S={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function _(e){for(const t of b)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:S;for(const[e,i]of(0,o.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function T(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=_,t.disableExternalNetworkRequests=T},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),s=i(53265),n=i(87652);class a extends n.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,s.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=a},23561:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.OptionalFloatSetting=a},69005:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=a},87652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=s},4936:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathToLibraryAsset=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(55835),l=i(51926),u=i(50213),c=i(81168),d=i(79842),h=i(21330),f=i(51275),m=i(29882),p=i(28874),g=(0,s.lazy)((()=>(0,u.mkLogger)("settings.PathToLibraryAsset")));function y(e){return(0,a.blank)(e)?"":"'"+e.replace(/'/g,"′")+"'"}t.pathToLibraryAsset=function(e,t){const i=(0,d.datedToDateTime)(e)??(0,o.map)((0,h.datedToISO)(e),(e=>r.DateTime.fromISO(e)));if(null==i||!i.isValid)return g().tap({msg:"pathToLibraryAsset(): failed to convert to a valid date",result:void 0,meta:{capturedAt:e,src:t,dt:i}});const s=(0,f.hasZone)(e),a=p.Settings.assetPathnameFormat.valueOrDefault,u=(0,c.splitKeep)(a,/((?:GRAND)?PARENT|BASE|NAME|EXT|ISO)/g);for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),s=i(83556);t.nameFromEnv=function(e){return(0,s.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,s.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const a=i(19851),o=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),w=i(40583),v=i(81168),b=i(44198),S=i(96706),P=i(34102),_=i(28283),T=i(81075),M=i(98778),E=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,a.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?n(this,r,"m",s).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?n(this,r,"m",s).call(this,e??t)+": "+i:null==this.fromEnv(e)?n(this,r,"m",s).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,v.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,S.caseInsensitiveEnv)():new w.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,b.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,o.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,o.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,o.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return T.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,b.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&S.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,b.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&S.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new w.CaseInsensitiveValued(e)))??(0,S.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,v.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],E.WrapComments);function i(e,i){(0,o.isEmpty)(i)||t.push(...(0,v.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],E.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,v.wrap)(["",e+": "+r],E.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,s=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),s=i(76760),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),w=i(79840),v=i(7282),b=i(12801),S=i(4328),P=i(70488),_=i(84248),T=i(5531),M=i(99315),E=i(34365),D=i(34580),x=i(96706),k=i(50274),F=i(33866),C=i(52086),A=i(48584),I=i(45969),O=i(43334),L=i(24540),R=i(70379),N=i(71300),B=i(33209),j=i(48987),z=i(68268),V=i(61208),W=i(99023),U=i(30577),q=i(1485),H=i(19861),$=i(55111),G=i(30933),J=i(22859),K=i(71988),Y=i(38483),Z=i(90536),X=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),se=i(9945),ne=i(74589),ae=i(844),oe=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,n.lazy)(v.isProd);const ye=()=>!(0,t.isProd)();function we(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function ve(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new oe.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new ne.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:ve}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new ne.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:ve}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>q.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:q.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>q.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>O.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new ne.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:$.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!O.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>O.isMac?"100ms":O.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>w.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new se.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new ne.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>b.PriorityClasses.BelowNormal,strEnum:b.PriorityClasses}),maxMemoryMb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!we()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!we()}),argon2TimeCost:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:T.CheckpointTypes,defaultValue:T.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:E.SynchronousModes,defaultValue:E.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to apply a migration, vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 2 minutes should be very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"2m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:F.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>O.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new ne.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,D.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new ne.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new ne.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new ne.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,L.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,G.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:k.SidecarExts,defaultValue:k.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new se.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,G.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:C.CropStrategies.attention,strEnum:C.CropStrategies}),videoFrameAtSec:new se.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,a.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new ne.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(O.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>B.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new ne.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new ne.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:A.SharpFailOns.truncated,strEnum:A.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>j.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:ae.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new se.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:z.KeywordReparentingStrategies.move,strEnum:z.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function be(e){const i=((0,l.blank)(e)?"":e).split(s.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,a.uniq)(i).filter(l.notBlank).join(s.delimiter)}function Se(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=be,t.pathWithDefaults=(0,n.lazy)((()=>be((0,x.getEnv)("PATH")))),t.allSettings=(0,n.lazy)((()=>(0,o.sortBy)((0,d.values)(t.Settings),Se))),t.persistedSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,n.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,n.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),s=i(31586),n=i(7282),a=i(49776),o=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),w=i(15674),v=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{v.Settings.configDir.opts.defaultValue=o.configDir,v.Settings.logDir.opts.defaultValue=c.defaultLogDir_,v.Settings.logServerLevel.opts.defaultValue=()=>v.Settings.logLevel.valueOrDefault,v.Settings.cacheDir.opts.defaultValue=a.defaultCacheDir,v.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,v.Settings.libraryDir.opts.exampleValue=()=>(0,n.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,n.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),v.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,v.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,v.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],v.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,w.maxCpus)()/4)),v.Settings.useFsWatch.watch(f.useFsWatch),v.Settings.updateChannel.opts.defaultValue=g.channel,v.Settings.ffmpegThreads.opts.defaultValue=()=>(0,w.maxCpus)()>=12?2:1,v.Settings.minBusyPct.opts.defaultValue=()=>(0,s.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),w=i(54993),v=i(50213),b=i(81168),S=i(83556),P=i(87290),_=i(98314),T=i(34102),M=i(83278),E=i(95696),D=i(60865),x=i(4175),k=i(83179),F=i(81075),C=i(28874),A=i(41692),I=i(84438),O=i(32707),L=i(6707),R=i(98778),N=i(55018),B=i(10357),j=(0,r.lazy)((()=>(0,v.mkLogger)("settings.SettingsIO")));function z(e){return(0,P.libraryDataDirPosixFile)(e)?.join(I.SettingsToml)}async function V(e=(0,O.systemSettingsFile)()){if(null!=e)return X(M.BaseFile.for(e))}async function W(){try{return(0,a.toNotBlank)((await(0,L.readTomlFile_)((0,O.systemSettingsFile)()))?.[C.Settings.libraryDir.name])}catch{return}}function U(e){return(0,L.readTomlFile_)(e).then((e=>e?.version),(()=>{}))}function q(){return U((0,O.systemSettingsFile)())}function H(e){return U(z(e))}function $(){t.libraryHasSettings.refresh()}function G(e){const t=z(e);return j().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:C.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}async function J(e,i){if(null==e)return void j().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),s=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...ie("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","This is the version of PhotoStructure that wrote this file--please don't edit the following line.")),r.push(...(0,R.stringifyToml)({version:(0,t.versionForSettings)()})),r.push("","");let s="";for(const e of i){const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==s&&(s=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,T.ee)().emitDebounced("settingsChanged")}(s,i),j().info("writeToml(): wrote settings",{dest:s,file:e,nonDefaults:(0,k.settingsToObj)(i),wip:r}),r){const t=await(0,L.readTomlFile_)(s),i=await(0,L.readTomlFile_)(e);(0,u.eql)(t,i)?(j().info("Equivalent contents",{dest:s,file:e,a:t,b:i}),await s.unlink()):(j().info("Archiving prior, different contents",{dest:s,file:e}),await e.renameYMDHMS_({subdir:"archive"}),await s.unwip_())}}async function K(e=(0,O.systemSettingsFile)()){const t=E.PosixFile.forMaybe(e);return null!=t&&await J(t,(0,C.persistedSystemSettings)()),t}function Y(e){return X(z(e))}async function Z(e){await(0,P.setupLibraryDataDir_)((0,a.firstNotBlank)(e,C.Settings.libraryDir.value));const i=z(e);return j().info("writeLibrarySettings()",{file:i}),null!=i&&(await J(i,(0,C.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function X(e){if(null==e)return[];const t=j().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await Q(e);return(0,s.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,_.errorToS)(e)),[]}}async function Q(e){const t=j().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,L.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const n=[],a=(0,s.compact)((0,p.entries)(r).map((([e,t])=>{if("version"===e)return;const i=(0,C.getSettingByNameOrKey)(e);if(null==i)n.push(`Failed to import "${e}"${(0,m.mapOr)((0,C.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;n.push(e)}})));return t.info("loaded",{settings:(0,k.settingsToObj)(a),warnings:(0,s.toNotEmpty)(n)}),await(0,x.handleDeprecatedSettings)(),(0,x.handleMetaSettings)(a),{settings:a,warnings:n}}t.librarySettingsFile=z,t.readSettings=(0,r.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await Y()}),o.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return C.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=q,t.librarySettingsVersion=H,t.maybeUpgradeSystemSettings=async function(){(0,t.versionForSettings)()!==await q()&&await K()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&(0,t.versionForSettings)()!==await H()&&await Z()},t.libraryHasSettings=(0,r.lazy)((()=>G())),t.libraryHasSettings.unset=()=>{j().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,T.ee)().on("clearCache",$),(0,T.ee)().on("settingsChanged",$),C.Settings.libraryDir.watchLater($)})),t._libraryHasSettings=G,t.versionForSettings=(0,r.lazy)((()=>(0,D.baseVersion)())),t.writeSystemSettings_=K,t.writeAllSettings_=function(e){return J(E.PosixFile.for(e),(0,C.persistedSettings)())},t.readLibrarySettings=Y,t.writeLibrarySettings_=Z,t._readSettings=X,t.importFileSettings_=Q;const ee=(0,r.lazy)((()=>new Set([C.Settings.noNetwork,C.Settings.httpPort,C.Settings.license,C.Settings.logStdout,C.Settings.logLevel].map((e=>e.key)))));function te(){for(const e of(0,p.values)(C.Settings))ee().has(e.key)||e.unset();(0,T.ee)().emit("settingsChanged")}function ie(...e){return(0,d.flatten)(e.map((e=>(0,b.wrap)(e,B.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),C.Settings.libraryDir.unset(),await K()},t.clearSettings=te,t.nukeSettings=async function(){te(),await(E.PosixFile.forMaybe((0,O.systemSettingsFile)())?.unlink("trace")),await(E.PosixFile.forMaybe(z())?.unlink("trace")),(0,T.ee)().emit("clearCache"),A.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...ie("",`Welcome to PhotoStructure! These are the settings for version ${(0,D.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...ie("","The following settings categories are stored in the system settings.toml:","",...(0,n.sort)([...F.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,n.sort)([...F.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...ie("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...ie("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const n=`${e.key} or ${e.name}`,a={...e.addToJSON()};(0,s.mapNotEmpty)(e.altKeys,(e=>a.aliases=(0,h.orList)(e)));const o=(0,p.entries)(a).map((([e,t])=>`${(0,b.capitalize)((0,S.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,s.isNotEmpty)(o)&&o.push(""),i.push(...ie((0,g.padding)("-",n.length),n,(0,g.padding)("-",n.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...o,`${e.key}=${(0,f.stringify)((0,w.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(98553),o=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,a.stringify)(e)}t._join=c;function d(e){return(0,o.map)(function(e){const t=(0,n.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,s.compact)((0,l.toA)(JSON.parse(t)).map(n.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,s.compactBlankish)(t.split(e));return[t]}}(e),s.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,n.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,s.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,s.isEmpty)(e)||(this.value=this.toValidValues((0,s.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,s.isEmpty)(this.values)}isNotEmpty(){return(0,s.isNotEmpty)(this.values)}toNotEmpty(){return(0,s.toNotEmpty)((0,s.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=s},72564:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),s=i(98553),n=i(55835),a=i(58305);class o extends a.StringArraySetting{constructor(e){super({toEnv:e=>(0,n.map)(e,(e=>(0,s.stringify)((0,r.uniq)(e)))),fromEnv:t=>function(e,t){return(0,r.compact)((0,a.splitStringArray)(e)?.map((e=>t.getCI(e))))}(t,e.strEnum),defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=o},80372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),s=i(81168),n=i(83179);class a extends n.Setting{constructor(e){super({toEnv:o,fromEnv:o,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function o(e){return null==e?void 0:(0,s.trimQuotes)(e)}t.StringSetting=a},32707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),s=i(55835),n=i(46292),a=i(84438);t.systemSettingsFile=function(){return(0,s.map)((0,n.configDir)(),(e=>(0,r.join)(e,a.SettingsToml)))}},80496:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),s=i(44652),n=i(22573),a=i(76850),o=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,a.debom)(e),(0,n.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,n.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,s.readFileSync)(t)):void 0}catch(e){return void(0,o.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,n.mapNotBlank)(e,(async e=>f(await(0,s.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,s.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),s=i(96249),n=i(98553),a=i(68708),o=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const s=e+" = "+(0,n.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[s]:(0,o.wrap)(s.split("\n"),i)}t.stringifyToml=function(e){return(0,s.flatten)((0,a.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,o.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},10357:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const r=i(54993),s=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=a(e[t]);if(null!=i)return i}};const n=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function a(e){const t=(0,s.extractFloat)(e);if(null==t)return;const i=(0,r.toS)(e).toLowerCase();for(const e of n)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),s=i(81168);t.bname=function(e,t=!0){let i=(0,s.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,s.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),h=i(31586),f=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),w=i(81168),v=i(76596),b=i(79842),S=i(66649),P=i(21330),_=i(98725),T=i(928),M=i(54261),E=i(89724),D=i(17415),x=i(88600),k=i(51275),F=i(29882),C=i(17217),A=i(68284),I=i(57902),O=i(28874),L=i(65162),R=i(71300),N=i(14036),B=i(61424),j=(0,s.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function z(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,f.isObject)(e)&&(0,o.notBlank)(e.nativePath)&&(0,b.isDated)(e.date)&&(0,o.notBlank)(e.src)}t.capturedAtSrcFromTags=z,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class U{static fromAssetFile(e){return(0,d.map)((0,E.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>U.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof U?e:W(e)?new U(e):void 0}constructor(e){var t;this.nativePath=(0,C.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,h.toGt0)(e.local)??(0,E.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,b.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(O.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,S.datedToMillis)(e.mtime)??(0,A.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:U.name,...(0,f.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,_.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,D.fmtOffsetMinutes)});return null==t?void 0:new U({...e,date:t})}spread(e){return new U({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,D.fmtOffsetMinutes)(this.offset)}get isFromTags(){return z(this.src)}get isInferred(){return!z(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,E.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,v.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,k.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,M.hasTime)(this.date)}hasMillis(){return(0,h.gt0)((0,T.getMillisecond)(this.date))}toMillis(){return(0,S.datedToMillis)(this.date)}get isValid(){return(0,x.isValidDate)(this.date)}get zoneName(){return(0,r.offsetMinutesToZoneName)(this.offset)??(0,k.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,D.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?O.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,b.datedToStartDateTime)(this.date)??(0,b.datedToDateTime)(this.date);if(null!=i)return{start:(0,E.datedToLocal)(i.minus(t)),end:(0,E.datedToLocal)(i.plus(t))};j().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:O.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),r=Math.max(t,e.fuzzyPrecisionMs());return j().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,b.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:r}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:r}})}}function q(e,t){if(null==e)return;const i=(0,n.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>U.for(e))));for(const r of t){let t=e[r],s=r;if((0,x.isValidDate)(t)){if((0,D.isValidZone)(e.tz)&&(!(0,k.hasZone)(t)||R.OverrideUTCZoneTags.includes(s))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,o.blank)(e.tzSource)?"":" from "+(0,w.stripPrefix)(e.tzSource,"from ");s+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,E.datedToLocalSec)(t),date:t,src:s,precisionMs:(0,b.datedToPrecisionMs)(t),rawValue:e[r]?.rawValue})}}const r=(0,p.leastBy)(i,(e=>(0,b.datedToStartTs)(e.date)));if(null==r)return;const s=i.filter((e=>(0,u.eql)(e.date,r.date)||e.precisionMs<=r.precisionMs&&(0,b.datedOverlap)({a:e.date,b:r.date,aPrecisionMs:e.precisionMs,bPrecisionMs:r.precisionMs}))),a=(0,p.leastBy)(s,(e=>[Math.floor(e.localSec/1e6),(0,k.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return j().debug("capturedAtFromTags()",{least:r,overlapsWithLeast:s,earliest:a}),a}function H(e,t){if(O.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,n.uniq)([(0,L.bname)(e,!0),(0,L.bname)(e,!1)])){const e=(0,_.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,b.datedToPrecisionMs)(e),l.secondMs])}}}function $(e){if(O.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,_.extractDateFromPath)(e.pathsForDateParsing)}}async function G(e){if(O.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=U,t.bestCapturedAt=function(e){const t=(0,a.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const r=await e.mtimeMs();function s(t,i){return W(i)?U.for(i):null!=i&&null!=i.date&&(0,x.isValidDate)(i.date)?U.for({nativePath:e.nativePath,date:i.date,local:(0,E.datedToLocal)(i.date),src:(0,w.uniqPath)([t,i.src]),mtime:r,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const n=function(e,t){return null==e||t||!O.Settings.usePathsToInferDates.valueOrDefault||!O.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,F.containedByNativePath)({ancestor:O.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),a=s("tags",q(t,O.Settings.capturedAtTags.values))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??s("tags",q(t,O.Settings.capturedAtTagsFallback.values))??(n?void 0:s("bname+stat",await(0,B.extractStatBname)(e)))??(n?void 0:s("path+stat",await(0,B.extractStatPathTime)(e)))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??(n?void 0:s("bname",H(e,t)))??(n?void 0:s("path",$(e)))??(O.Settings.useStatToInferDates.valueOrDefault?s("stat",await G(e)):void 0);return j().tap({level:I.LogLevels.debug,msg:"extractCapturedAt()",result:a})},t.capturedAtFromTags=function(e){return q(e,O.Settings.capturedAtTags.values)},t.capturedAtFromBasename=H,t.capturedAtFromPath=$,t.capturedAtFromStat=G},70379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const r=i(31586),s=i(97352),n=i(95696),a=i(47783),o=i(16170);function l(e){if(null!=e&&(0,o.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,r.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,s.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=n.PosixFile.for(e);return l(await(0,a.readRawTags)(t,!1))}},47783:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const s=i(77988),n=r(i(76760)),a=r(i(1708)),o=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(23838),f=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),w=i(12168),v=i(56038),b=i(4867),S=i(36557),P=i(98247),_=i(21330),T=i(98725),M=i(23467),E=i(88561),D=i(95696),x=i(17217),k=i(16287),F=i(50213),C=i(17921),A=i(7282),I=i(88158),O=i(23560),L=i(28874),R=i(12089),N=i(45255),B=i(81168),j=i(63870),z=i(15674),V=i(28544),W=i(43207),U=i(75767),q=i(12788),H=i(80495),$=i(14036),G=i(67083),J=i(3432),K=i(28630),Y=i(15912),Z=i(30748),X=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),re=i(61424),se=i(8791),ne=(0,o.lazy)((()=>(0,F.mkLogger)("exiftool.ExifTool")));let ae=!1;t.addInstanceIdsToTags=function(e){ae=e},t.setExifToolProcs=function(e){return L.Settings.exiftoolProcsPerChild.envValue=e,ue()};const oe=(0,o.lazy)((()=>new S.BatchClusterObserver("ExifTool",new s.ExifTool({useMWG:L.Settings.useMWG.valueOrDefault,backfillTimezones:L.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:L.Settings.defaultVideosToUTC.valueOrDefault,...(0,S.batchClusterOptions)((0,A.isTest)()?8:(0,O.isSyncService)()?L.Settings.exiftoolProcsPerChild.value??(0,z.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=oe();return e.ended?oe.refresh():e}function ue(e=!1){return(0,d.map)(oe.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,b.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(oe.prior(),(e=>e.ended?void 0:(0,b.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,j.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,f.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,x.toNativePath_)(e))}async function he(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function fe(e){const t=[];return L.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*w.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,B.includesIgnoreCase)(L.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return ne().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const r=i??await(0,te.readMimeType)(e),s=await e.sidecar(),n=(0,X.isImageMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,a=(0,X.isVideoMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,o=L.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await s.exists(),l=n||a||o;return ne().tap({msg:"writeTagDest()",result:l?s:e,meta:{src:e,tagName:t,mimetype:r,writeMetadataToSidecarsIfImage:n,writeMetadataToSidecarsIfVideo:a,writeMetadataToSidecarsIfSidecarExists:o}})}async function pe(e,i=!0){const r=D.PosixFile.for(e);if(r.isSidecar()&&(i=!1),!await r.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(r.nativePath),void ne().debug("readRawTags("+r+"): invalid file, returning null.");const s=await(0,t._readRawTags)(r.nativePath);if(null==s||!i)return s;ne().trace("readRawTags()",{pf:r,pickedFileTags:(0,f.pick)(s,"tz","tzSource",...L.Settings.capturedAtTags.values)});const n=[];for(const e of await r.jsonSidecars())n.push([e,(0,K.readJsonSidecar)(e,s.tz)]);for(const e of await r.existingExifSidecars())n.push([e,(0,t._readRawTags)(e.nativePath)]);const a={original:{},MIMEType:(0,u.mapNotBlank)(s.MIMEType,X.normalizeMimetype),...s},o=[];for(const[e,i]of n){if(null==i)continue;const r=await i;if(null==r)continue;const s=(0,f.omit)(r,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,f.values)(s))?((a.sidecars??(a.sidecars=[])).push(e.base),o.push(...(0,g.toA)(r.History)),(0,I.assignNullishFields)(a.original,(0,f.pick)(a,...(0,f.keys)(s))),(0,f.assignFields)(a,s),ne().debug("readRawTags() sidecar had values",{sidecar:e.base})):ne().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return a.inferred=(0,G.getInferredHistoricValues)(o,e),(0,I.assignNullishFields)(a,a.inferred),a.Rotation=(0,Q.orientationToRotation)(a.Rotation),ne().debug("readRawTags() final",{pf:r,inferred:a.inferred,pickedResult:(0,f.pick)(a,"tz","tzSource",...L.Settings.capturedAtTags.values)}),a}async function ge(e,t){return null==t?void 0:(0,v.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,r=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,X.normalizeMimetype);if((0,u.blank)(r))return void ne().debug("No mimetype for "+i);const n={...t.inferred??{},...t};if(n.inferred??(n.inferred={}),n.original??(n.original={}),L.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const t=n[e];if((0,p.isString)(t)){const i=(0,T.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(ne().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),n[e]=i)}}const o=!await(0,re.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,n,o);if(ne().debug("parseTags()",{tzMeta:l,skipSiblingInference:o}),null!=l?.tz){const e=n.tzSource!==s.defaultVideosToUTC&&void 0;for(const t of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const i=n[t];i instanceof s.ExifDateTime&&(n[t]=(0,_.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,f.assignUndefinedFields)(n.original,n,"tz","tzSource"),(0,f.assignFields)(n,l),(0,f.assignFields)(n.inferred,l)}const c=o?(0,Z.extractMakeAndModel)(n):await(0,re.inferMakeAndModel)(e,n);c.Make!==(0,Z.make)(n.Make)&&(n.original.Make=n.Make,n.inferred.Make=c.Make),c.Model!==(0,Z.model)(c.Make,n.Model)&&(n.original.Model=n.Model,n.inferred.Model=c.Model),!(0,u.blank)(L.Settings.defaultCopyright.valueOrDefault)&&(0,q.isExifUnset)(n.Copyright)&&(n.Copyright=L.Settings.defaultCopyright.valueOrDefault);const d=(0,Y.extractLensMakeModel)(n),h=await(0,V.extractCapturedAt)(e,n,o);if(null==h)return void ne().info("No capturedAt for "+e);!o&&h.isInferred&&(n.inferred.capturedAt=h);const m=(0,H.extractExposureSettings)(n),g=await(0,ie.extractSizeInfoFromFile)(e,n);if(null==g)return void ne().info("No size info for "+i);const y={...c,mimetype:r,capturedAt:h,exposureSettings:m,...(0,se.extractTitleDescription)(n),...d,cameraId:(0,U.cameraIdFromTags)(n),imageId:(0,U.imageIdFromTags)(n),lensId:(0,U.lensIdFromLensInfo)({...d,...(0,f.pick)(n,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(n),tz:n.tz,rating:(0,ee.extractRating)(n)};(0,A.isTest)()&&(y.__parsedBy__=a.default.pid);const w={...n,...y};return ne().debug("parsedTags",{nativePath:i,skipInference:o,...y,inferred:n.inferred,original:n.original,pickedResult:(0,f.pick)(w,"capturedAt","tz","tzSource","Make","Model")}),(0,f.definedValues)(w)}catch(e){return void ne().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,f.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,f.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,M.eqlAsync)(e.sha(),t.sha())||await(0,M.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=D.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,x.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,x.toNativePath_)(e),["-"+t]);return(0,I.pluckCaseInsensitive)(i,t)}catch(e){return void ne().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=he,t.overwriteTags_=async function(e,t){try{await(0,v.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await fe(e)),e.clearThisAndParent()}))}catch(i){ne().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,v.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=fe,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,v.time)("exiftool.writeTags:"+e,(async()=>{const r=new h.MultiMap;for(const[s,n]of(0,f.entries)(t)){const t=await me(e,s,i);r.add(t.nativePath,[s,n])}for(const[t,i]of r.entriesArray()){const r=D.PosixFile.for(t),s=(0,f.fromEntries)(i);ne().info("writeTags()",{src:e,dest:t,t:s}),await le().write(r.nativePath,s,await fe(r)),L.Settings.overwriteOriginal.valueOrDefault||await he(r),r.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,k.nativePathIsFile)(e))return ne().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);ne().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...L.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,$.isVideoExt)(n.default.extname(e))?[]:["-fast"]],r=await(0,v.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{ne().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==r)return;ne().debug("_readRawTags()",{nativePath:e,pickedTags:(0,f.pick)(r,"tz","tzSource",...L.Settings.capturedAtTags.values)}),r.MIMEType=(0,u.mapNotBlank)(r.MIMEType,X.normalizeMimetype),r.GPSDateTime??(r.GPSDateTime=(0,P.concatDateTime)(r.GPSDateStamp,r.GPSTimeStamp));for(const e of(0,f.keys)(r)){const t=r[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete r[e])}const s=(0,l.compactBlanks)([r.Error,...r.errors??[],r.Warning].map(y.toS));return(0,l.isNotEmpty)(s)&&(r.problems=s),ae&&(r.__instance=(0,C.safeUUID)()),r}}),t.parseTags=ge},75767:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(98553),o=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),h=i(54993),f=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),w=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const v=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function b(e){const t=null==e?[]:e.filter((([,e])=>!(0,n.blank)(e)));return 0===t.length?void 0:(0,a.stringify)((0,u.fromEntries)(t))}function S(e){return(0,h.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new o.MultiMap,r=[];for(const a of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(s=e[a])||(0,n.blankish)(s)||(0,l.isNumber)(s)&&(0===s||1===s)||null!=t.zeroesRe.exec((0,h.toS)(s)))continue;const o=e[a],u=S(e[a]),c=(0,t.Tag2SynonymGroup)().get(a);if(null!=c){if(i.includes(c,o)||i.includes(c,u))continue;i.add(c,o)}r.push([a,(0,l.gt0)(o)?o:u])}var s;return b(r)}function _(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function T(e){if((0,n.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([_(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(_)):(0,u.compactBlankValues)(t)}function M({a:e,b:t,field:i,desc:r,parser:s}){const n=s(e[i]),a=s(t[i]),o=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==n||null==a||(0,l.approximates)(n,a,o)?void 0:"Different "+r+": "+e[i]+" ≠ "+t[i]}function E(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,n.blank)(e.lensMake)||(0,n.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,r.lazy)((()=>{const e=new Map;for(const t of v){const i=t[0];for(const r of t)e.set(r,i)}return e})),t.Tag2Synonyms=(0,r.lazy)((()=>{const e=new Map;for(const t of v)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=b,t.renderExifUidId=P,t.decodeExifUid=T,t.findInequalFields=function(e,i){const r=T(e),n=T(i);if(null==r||null==n||e===i)return;const a=(0,f.intersection)((0,u.keys)(r),(0,u.keys)(n)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of a){const t=r[e],i=n[e];if(S(t)!==S(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of v){const t=(0,u.pick)(r,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(n,...e);if((0,u.isEmptyObj)(i))continue;const a=(0,u.values)(t).map(h.toS),o=(0,u.values)(i).map(h.toS);if((0,s.includesAny)(a,o))continue;const l=(0,f.least)((0,u.keys)(t)),c=(0,f.least)((0,u.keys)(i));return{aKey:l,aValue:r[l],bKey:c,bValue:n[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>M({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>M({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>M({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>M({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return E({...(0,w.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=E,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const r=i(22573),s=i(54993),n=/undefined|null|none|n\/a|unknown/i;function a(e){return null==e||(0,r.blank)(e)||n.test((0,s.toS)(e))}t.isExifUnset=a,t.toExifDefined=function(e){return a(e)?void 0:e}},80495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const r=i(19851),s=i(22573),n=i(31586),a=i(68708),o=i(54993),l=i(50213),u=i(97352),c=(0,r.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,s.firstNotBlank)((0,o.toS)(e.ExposureTime),(0,o.toS)(e.ShutterSpeed),(0,o.toS)(e.ShutterSpeedValue),(0,o.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,a.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,n.gt0)(e))return e;const[t,i]=(0,o.toS)(e).split("/").map((e=>(0,n.toInt)(e)));return(0,n.gt0)(t)&&(0,n.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,n.toFloat)(e);return(0,n.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),s=i(40958),n=i(96249),a=i(23838),o=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,o.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,o.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new a.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,n.flatten)((0,o.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function w(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=w,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return w(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return w(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return w(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return w(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return w(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return w(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return w(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return w(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),h=i(50989),f=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),w=i(50213),v=i(81168),b=i(66649),S=i(17415),P=i(29882),_=i(95696),T=i(17217),M=i(28874),E=i(47783);function D(e,t){return(0,d.entries)(t??{}).map((([t,i])=>x({action:e,key:t,value:i})))}function x({action:e,key:t,value:i,ts:s}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:r.ExifDateTime.fromMillis(s??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,h.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=D,t.mkHistoryRecord=x,t.InferAction="infer";const k=(0,s.lazy)((()=>(0,w.mkLogger)("tags.History")));function F(e,t){if(null==e||null==e.History||(0,f.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function C(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,o.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function A(e){if(null==e)return;const t={};for(const[i,r]of(0,d.entries)(e))(0,v.isFirstCharAZ)(i)&&(t[i]=r);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,S.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function I(e,i,r){if(null==e||(0,o.blank)(e))return void k().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const s=(0,T.toNativePath_)(e),a=await(0,E._readRawTags)(s),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!F(a,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...r??{}};if((0,n.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void k().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:r,tagsToWrite:c});k().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:r});const h=_.PosixFile.for(e);return await(0,E.overwriteTags_)(h,c),h.clearThisAndParent(),u}t.tagsContainHistory=F,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const s=(0,m.toA)(e);if((0,n.isEmpty)(s))return{};const l=(0,a.sortBy)(s.filter((e=>(0,v.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,b.datedToMillis)((0,o.mapNotBlank)(e.When,(e=>r.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,o.notBlank)(t)){const r=C(e);(0,o.blank)(r.nativePath)||(0,P.eqlNameWithoutExt)(r.nativePath,i)?u[t]=r:k().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=C,t.inferredToTags=A,t.ensureInferredHistoryRecords=async function(e,i,r){const s=D(t.Actions.infer,r),n=(M.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?A(r):void 0)??{};return M.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(n.Source=e.nativePath),k().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:s,additionalTags:n}),I(i,s,n)},t.ensureHistoryRecords=I},3432:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const s=r(i(53705)),n=i(77988),a=i(19851),o=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),h=i(17415),f=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),w=i(61424),v=(0,a.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function b(e,t,i){{const e=S(t);if(null!=e&&(0,h.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,h.isValidZone)(t.tz)||t.tzSource===n.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,o.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof n.ExifDateTime&&(0,h.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,w.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function S(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return v().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,s.default)(t,i),r=(0,h.normalizeZone)(e);return v().tap({msg:"zoneFromLatLon()",result:r,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return v().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,f.isValidDate)(i))for(const r of g.Settings.capturedAtTags.values){const s=(0,u.toDated)(t[r]);if(null==s||(0,f.isValidDate)(s))continue;const n=Math.round(15*i.diff(s,"minutes").as("minutes")/15),a=(0,h.normalizeZoneOffsetMinutes)(n),o=0===a?void 0:(0,h.normalizeZone)(a);if(null!=o)return v().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:o.name,tzSource:"infer:filename (diff with "+r+")"},meta:{dt:(0,c.datedToISO)(s),rawTzoffsetMinutes:n,normalizedOffsetMinutes:a}})}}t.maybeInferTimezone=async function(e,t,i){return v().tap({msg:"maybeInferTimezone()",result:await b(e,t,i)})},t.zoneFromLatLon=S,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const r=i(77988),s=i(40958),n=i(22573),a=i(38639),o=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),h=i(48884),f=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const s=(0,p.normalizeZone)(e?.formatted),n=r.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:s??t??r.UnsetZone});if(!0===n?.isValid)return n}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,n.toNotBlank)(e.title),Description:(0,n.toNotBlank)(e.description),GPSLatitude:(0,h.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,f.validLat)(e)?e:void 0)),GPSLongitude:(0,h.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,f.validLon)(e)?e:void 0)),GPSAltitude:(0,h.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,o.map)(e.favorited,a.isTrue),peopleNames:(0,s.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,s.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},97573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rawTagKeywords=t.parseKeywordStruct=t.isKeywordStruct=t.parseCategories=t.splitKeywords=t.splitKeyword=t.delimRe=t.keywordToPath=void 0;const r=i(77988),s=i(66150),n=i(19851),a=i(40958),o=i(22573),l=i(41400),u=i(96249),c=i(68708),d=i(59455),h=i(48884),f=i(50213),m=i(68852),p=i(81168),g=i(28874),y=(0,n.lazy)((()=>(0,f.mkLogger)("tags.KeywordTags"))),w=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordPathSeparators.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g")))));function v(e){const i=(0,t.delimRe)();return null==i?[e]:(0,a.compactBlanks)(e.split(i))}function b(e){return null==e||e instanceof r.BinaryField?[]:(0,a.compactBlanks)(Array.isArray(e)?(0,u.flatten)(e.map(b)):v(e))}function S(e){return null==e?[]:(0,p.isString)(e)?(0,o.blank)(e)?[]:[[e]]:(0,u.flatten)((0,d.toA)(e.Category).map(S).map((t=>t.map((t=>(0,a.compact)([e._,...t]))))))}(0,l.later)((()=>{g.Settings.keywordPathSeparators.watchLater((()=>w.unset()))})),t.keywordToPath=function(e){const t=w();return(0,a.compactBlanks)(null==t?[e]:e.split(t))},t.delimRe=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g"))))),g.Settings.keywordDelimiters.watchLater((()=>t.delimRe.unset())),t.splitKeyword=v,t.splitKeywords=b;const P=/^\(?none\)?$/i;function _(e){if(!(0,o.blank)(e)&&null==P.exec(e))try{const t=new s.XMLParser({textNodeName:"_"}).parse(e);return(0,u.flatten)((0,d.toA)(t?.Categories?.Category).map(S))}catch(t){return void y().warn("parseCategories() failed:",{err:t,s:e})}}function T(e){return Array.isArray(e)&&e.every(T)||null!=e&&(0,p.isString)(e.Keyword)&&(null==e.Children||Array.isArray(e.Children)&&e.Children.every(T))}function M(e){if(null==e)return[];if(Array.isArray(e)&&e.every(T))return(0,h.flatMap)(e,M);if((0,o.blank)(e.Keyword))return[];const t=(0,d.toA)(e.Children);return(0,a.isEmpty)(t)?[[e.Keyword]]:(0,h.flatMap)(t,M).map((t=>[e.Keyword,...t]))}t.parseCategories=_,t.isKeywordStruct=T,t.parseKeywordStruct=M,t.rawTagKeywords=function(e){const t=[];if(null!=e){const i=[...g.Settings.keywordTags.values];if(i.includes("Categories")){(0,h.remove)(i,"Categories");const r=_(e.Categories);null!=r&&t.push(...r)}for(const r of i){const i=(0,c.pluckDeep)(e,r)?.value;(0,o.blank)(i)||(T(i)?t.push(...M(i)):t.push(...Array.isArray(i)?i:b(i)))}}return y().tap({msg:"rawTagKeywords()",result:(0,a.compactBlankish)((0,a.uniq)(t)),meta:{t:null==e?void 0:(0,c.pick)(e,...g.Settings.keywordTags.values)}})}},15912:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(55835),o=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),h=i(28874),f=i(30748),m=(0,r.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,f.make)(e.LensMake),i=(0,f.make)(e.Make),r=[],o=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],b),u=(0,s.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:o,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&r.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==b(e))continue;(0,n.notBlank)(t)&&r.push({lensMake:t,lensModel:e,lensInfo:o});const a=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))a.includes(t)&&r.push({lensMake:i,lensModel:e,lensInfo:o});for(const i of(0,s.compactBlanks)([t,...h.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&r.push({lensMake:i,lensModel:e,lensInfo:o});a.startsWith("vr ")&&"Nikon"===i&&r.push({lensMake:"Nikon",lensModel:e,lensInfo:o})}for(const e of r){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=S(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,a.map)(e.lensInfo,S)}return(0,c.greatestBy)(r,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const w=/([\d. -]+)\s?mm\b/i,v=/\bf\/?([\d.\-]+)/i;function b(e){if((0,n.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=w.exec(e)?.[1].replace(/\s/g,""),i=v.exec(e)?.[1];return y(t)&&y(i)?S(`${t}mm f/${i}`):void 0}function S(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,a.mapOr)((0,o.toFloat)(e),(e=>String((0,o.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=b,t.cleanBogusPrecision=S,t.normalizeLensModel=function(e){return S(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(68708),o=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function h(e,t,i=""){const r=e.replace(t,i);return r===e?e:h(r,t,i)}const f=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=f.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,r.lazy)((()=>new p)),y=/\bgopro\b/i;function w(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=h(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=w(e.Make)??b(e.Software)??b(e.CreatorTool)??function(e){return y.test((0,o.toS)(e.HandlerDescription))||y.test((0,o.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,a.compactValues)({Make:t,Model:i})??{}},t.make=w;const v={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function b(e){if(!(0,s.blank)(e))for(const[t,i]of(0,a.entries)(v))if(i.test(e))return t}t.makeFromSoftware=b;const S=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=S.exec(i);null!=e&&(i=e[1].trim())}const r=(0,n.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=r)return r[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,n.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=h(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},38010:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MergedTags=t.revisionToResourceEvent=t.resourceEventToRevision=t.isSetRevision=t.isPrimitiveRevision=t.isBaseRevision=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(55835),u=i(31586),c=i(68708),d=i(67478),h=i(59455),f=i(54993),m=i(72993),p=i(50213),g=i(84885),y=i(66649),w=i(98725),v=(0,s.lazy)((()=>(0,p.mkLogger)("tags.MergedTags")));function b(e){return(0,u.isNumber)(e?.createdAt)&&(0,o.notBlank)(e?.field)}function S(e){return null==e?.op&&b(e)}function P(e){return e?.sourceIsPrimary??e?.shown??!1}function _(e){return e?.sourceModifiedTime??e?.mtime??0}t.isBaseRevision=b,t.isPrimitiveRevision=S,t.isSetRevision=function(e){return["add","delete"].includes(e?.op)&&b(e)},t.resourceEventToRevision=function(e){if(null==e||!(0,f.toS)(e.SoftwareAgent).startsWith((0,m.AppName)()))return v().tap({msg:"resourceEventToRevision() invalid",result:void 0,meta:{resourceEvent:e}});const t=e.Changed;if((0,o.blank)(t))return v().tap({msg:"resourceEventToRevision() missing Changed field name",result:void 0,meta:{resourceEvent:e}});const i=(0,c.pick)((0,o.mapNotBlank)(e.Parameters,d.parseJSON)??{},"newValue","priorValue");if((0,c.isEmptyObj)(i))return v().tap({msg:"resourceEventToRevision() missing Parameter fields",result:void 0,meta:{resourceEvent:e}});const r=(0,y.datedToMillis)((0,w.parseDated)({input:e.When}));return null==r?v().tap({msg:"resourceEventToRevision() missing createdAt (When)",result:void 0,meta:{resourceEvent:e}}):(0,o.blank)(e.Action)?v().tap({msg:"resourceEventToRevision() missing op (Action)",result:void 0,meta:{resourceEvent:e}}):v().tap({msg:"resourceEventToRevision()",result:{createdAt:r,field:t,op:"assign"===e.Action?void 0:e.Action,...i},meta:{resourceEvent:e}})},t.revisionToResourceEvent=function(e){return{Action:e.op??"assign",Changed:e.field,InstanceID:(0,l.map)(e.id,f.toS),Parameters:(0,g.stringifySorted)((0,c.pick)(e,"newValue","priorValue")),SoftwareAgent:(0,m.AppNameVersion)(),When:r.ExifDateTime.fromMillis(e.createdAt??Date.now())}},t.MergedTags=class{constructor(e){this.name=e,this.revisions=[],this.tags=[],this.logger=(0,p.mkLogger)(`MergedTags(${e})`)}addRevision(...e){this.revisions.push(...e)}addTag(...e){this.tags.push(...e),(0,a.sortBy)(this.tags,(e=>[!P(e),-_(e)]))}get(e){const t=(0,a.sortBy)(this.revisions.filter((t=>t.field===e)),(e=>e.createdAt)),i=this.tags.find((t=>null!=t[e]));let r=i?.[e];const s=[];var l;null!=r&&(0,o.mapNotBlank)((l=i,l?.SourceFile??l?.uri),(e=>s.push(e)));const u=t.every(S)&&this.tags.every((t=>!Array.isArray(t[e])));if(u){for(const i of t)null!=r&&r!==i.priorValue&&r!==i.newValue?this.logger.info("get("+e+"): skipping revision because expected prior or new value didn't match current value",{revision:i}):(r=i.newValue,s.push(`Revision@${i.createdAt}`));return null==r?void 0:{value:r,source:s}}{const e=(0,h.toA)(r);for(const i of t)if("add"===i.op&&null!=i.newValue)s.push(`Revision@${i.createdAt}`),(0,n.pushUniq)(e,...(0,h.toA)(i.newValue));else if("delete"===i.op&&null!=i.priorValue){s.push(`Revision@${i.createdAt}`);for(const t of(0,h.toA)(i.priorValue))(0,n.remove)(e,t)}return{value:e,source:s}}}}},16170:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const r=i(22573),s=i(54993),n=i(2322),a=i(277),o=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function h(e){return(0,r.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function f(e){const t=(0,s.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,n.isChrome)(t)||(0,n.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,s.toS)(e))},t.isImageMimeType=function(e){return(0,s.toS)(e).startsWith("image/")},t.isVideoMimeType=h,t.normalizeMimetype=f,t.isSharpMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,r.blank)(t)&&(h(t)?await(0,l.isVideoSupported)():(0,o.isHeifMimeType)(t)?await(0,a.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},66039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderNameTag=t.parseName=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(55835),l=i(75020),u=i(59455),c=i(50213),d=i(68852),h=i(81168),f=i(70417),m=i(28874),p=(0,r.lazy)((()=>(0,c.mkLogger)("tags.Names")));function g(e){return(0,d.matchQuotes)((0,d.escapeRegExp)(e))}const y=/(\(\s*\d+\s*-\s*[\d?]{0,4}\s*\)?)/,w=/([,\s]+(?:jr\.?|junior|sr\.?|senior|[iv]+\.?))$/i,v=/\b([A-Z‘’']+[-A-Z‘’']{2})\b/,b=/^[()[\]/.\-_]+$/;function S(e){if((0,a.blank)(e))return;let t=e.replace(/\s+/g," ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").trim();const i=(0,o.map)((0,h.spliceCapture)(t,y),(e=>(t=e.unmatched.trim(),e.captured.replace(/\s+/g,"")))),r=(0,o.map)((0,h.spliceCapture)(t,w),(e=>(t=e.unmatched.trim(),e.captured.trim()))),l=[],c=[],b=[];for(const e of m.Settings.tagNamesGiven.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(l.push(i.captured),t=i.unmatched.trim())}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesGivenSurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`(${(0,d.escapeRegExp)(e.charAt(0))}\\s*[^${(0,d.escapeRegExp)(e.charAt(0))}]+\\s*${(0,d.escapeRegExp)(e.charAt(1))})`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(c.push(i.captured),t=i.unmatched.trim())}while(null!=i)}let S;function _(e){(null==S||S>e.matchedIndex)&&(S=(0,f.min)([S,e.matchedIndex]))}if(m.Settings.tagNamesCapitalizedAsFamily.valueOrDefault){let e;do{e=(0,h.spliceCapture)(t,v),null!=e&&(_(e),b.push(e.captured),t=e.unmatched.trim())}while(null!=e)}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesFamilySurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`${(0,d.escapeRegExp)(e.charAt(0))}\\s*([^${(0,d.escapeRegExp)(e.charAt(0))}]*)\\s*${(0,d.escapeRegExp)(e.charAt(1))}`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}while(null!=i)}if(m.Settings.tagNamesLexical.valueOrDefault){const e=t.indexOf(",");e>=0&&(S=void 0,b.push(t.substring(0,e).trim()),l.push(t.substring(e+1).trim()),t="")}for(const e of m.Settings.tagNamesSurnames.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}for(const e of(0,u.toA)((0,s.mapNotEmpty)((0,s.compactBlanks)(m.Settings.tagNamesSurnamePrefixes.values),(e=>(0,n.sortBy)(e,(e=>-e.length)).map((e=>new RegExp(`\\b(${g(e)}\\s+\\S+)`,"i"))))))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}null!=S&&t.length>S&&(0,s.mapNotEmpty)((0,s.compactBlanks)(t.slice(S).split(/\s+/)),(e=>{b.push(...e),t=t.slice(0,S)}));const T=(0,s.compactBlanks)(t.split(/\s+/)),M=l.length,E=b.length;if(T.length>0)if(0===M&&E>0)l.push(...T);else if(0===E&&M>0&&1===T.length)b.push(...T);else if(1===T.length)l.push(...T);else{const e="western"===m.Settings.tagNamesOrder.valueOrDefault;b.push(e?T.pop():T.shift()),l.push(...T)}return{givenNames:P([...l,...c]),modifier:r,lifespan:i,familyNames:P(b),minFamilyNameIndex:S}}function P(e){return(0,s.uniq)((0,s.compactBlanks)(e).filter((e=>null==b.exec(e))))}function _(e){let t="";for(const i of(0,s.compactBlanks)(e))t+=i.startsWith(",")?i:" "+i;return t.trim()}function T(e,t,i){return _("western"===m.Settings.tagNamesOrder.valueOrDefault?[t,e,i]:[e,t,i])}t.parseName=S,t.renderNameTag=function(e){if((0,a.blank)(e))return[];const t=m.Settings.tagNamesFormatter.valueOrDefault,i="family/given"===t;if("family/fullname"===t||i){const t=S(e);if(null==t)return[];{const e=_([t.modifier,t.lifespan]),r=_(t.givenNames);return(0,s.compactBlanks)((0,s.notEmptyOr)(t.familyNames,[m.Settings.tagNamesDefaultFamily.valueOrDefault])).map((t=>[l.TagRoots.Who,t,i?_([r,e]):T(t,r,e)]))}}return[[l.TagRoots.Who,e.trim()]]}},95141:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const r=i(21605),s=i(54993),n=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,n.isVideoMimeType)(e.MIMEType)?(0,r.normalizeRotation)(e.Rotation):void 0)??o(e.Orientation)};const a=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function o(e){return(0,r.isRotation)(e)?e:null!=e?a.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,s.toS)(e).startsWith("Mirror")},t.orientationToRotation=o;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,r.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,r.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const r=i(55835),s=i(31586),n=i(28874);function a(e){const t=(0,s.toInt)(e);return null==t?void 0:(0,s.clamp)(-1,5,t)}function o(e){return a(e?.Rating)??(0,s.mapNumeric)((0,s.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,r.map)(e?.favorited,(e=>!0===e?n.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=a,t.extractRating=o,t.extractLiked=function(e){const t=o(e);return null==t?void 0:t>=n.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(88561),o=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,r.lazy)((()=>new a.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,s.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,n.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,o.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),s=i(40958),n=i(22573),a=i(81168),o=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,a.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const o=(0,u.isJsonExt)(i.ext),l=o||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=o||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,s.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,s.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return o&&function(e,i){const r=(0,a.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function s(e){return(0,n.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const o=s(e.slice(r.length)),l=s(i.slice(r.length));return o&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,o.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,a.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(33374),o=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),h=i(34943),f=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),w=(0,r.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),v=(0,r.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:n.minuteMs})));async function b(e,t){if(null==e)return;const i=null==t||(0,s.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const r=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return S(i,r,await(0,h.rawInfo)(e));const n=S(i,r);if(null!=n)return n;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await b(await(0,f.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function S(e,t,i){t??(t=(0,y.extractRotation)(e));const r=(0,o.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,a.isDimensions)(e)?e:void 0));if(null==r)return w().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo,fileDimensions:r}});const s=(0,a.maybeDimSwap)(r,t);return w().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:s.height,ImageWidth:s.width,aspectRatio:(0,d.aspectRatio)(s),dimensions:s,rotation:t,fileDimensions:r,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return v().getOrSetAsync(i.nativePath,(()=>b(i,t)))},t.extractSizeInfoFromTags=S},3127:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tag_fts_path=t.tag_fts_root=void 0;const r=i(54993),s=i(42231);t.tag_fts_root=function(e){const t=(0,r.toS)(e).indexOf(s.TagSep);return-1===t?"":e.substring(0,t)},t.tag_fts_path=function(e){return(0,r.toS)(e).split(s.TagSep).filter((e=>null!=e&&""!==e.trim())).join(" ")}},61424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),h=i(48884),f=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),w=i(79842),v=i(21330),b=i(98725),S=i(51275),P=i(35280),_=i(19748),T=i(88561),M=i(95696),E=i(65238),D=i(17217),x=i(57902),k=i(28874),F=i(80496),C=i(65162),A=i(28544),I=i(47783),O=i(88840),L=i(30748),R=i(16170),N=(0,n.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),B=7;async function j(e){return k.Settings.siblingInference.valueOrDefault===F.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+k.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(k.Settings.siblingInference.valueOrDefault===F.TagInferenceSettingValues.auto&&await(0,E.isSlowDir)(e.nativePath)&&!await(0,E.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function z(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of r){const r=(0,L.extractMakeAndModel)(await(0,I.readRawTags)(t));if((0,f.definedAndNotEql)(r.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:r});else if((0,f.definedAndNotEql)(r.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:r});else if(null!=r.Make&&null!=r.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:x.LogLevels.info,result:r,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await j(e.parent()))return;const t=await W(e);return null!=t&&(0,v.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,v.toExifDateTime)(t.before.date,(0,S.getZoneName)(t.before.date)),(0,v.toExifDateTime)(t.after.date,(0,S.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,n.lazy)((()=>new T.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await H(e),i=await z(t?.younger),r=await z(t?.older);return null==i||null==r?void 0:{before:i,after:r,index:i.index,slots:i.index+r.index+1}}))}t.beforeAfterCapturedAt=W;const U=(0,_.extFilter)(O.ExtTypes.AssetFile);function q(e){return null==e?[]:(0,a.compact)((0,h.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function H(e,t=7,i=!0){if(!await j(e.parent()))return;const r=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(U(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==r)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const s=(0,o.sortBy)(r,(e=>(0,C.bname)(e))),n=(0,D.findFileIndex)(e,s);if(n<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),H(e,t,!1)):void 0;const l=k.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[s.slice(n-2*t,n),s.slice(n+1,n+1+2*t)],d=[],h=[];for(;(0,a.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,a.isNotEmpty)(c)&&h.length=l&&h.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:h},meta:{f:e}})}t.nearestSiblings=H,t.nearestSiblingTzOffset=async function(e){if(!await j(e.parent()))return;const t=q(await H(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,B);for(const t of e){const e=await(0,I.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==r.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,a.uniq)([(0,C.bname)(e,!0),(0,C.bname)(e,!1)]),i=(0,b.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const r=await e.stat();if(null!=r){for(const e of["birthtime","atime","mtime","ctime"])if((0,w.datedOverlap)({a:i,b:r[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:r}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:r}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,b.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const r=i[e];if(null!=r&&!0===(0,w.datedOverlap)({a:t,b:r}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:s.DateTime.fromJSDate(r)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),h=i(81168);function f(e){return(0,u.toS)((0,o.isString)(e)?e:e?.name).normalize()}function m(e){return(0,r.compact)((0,l.toA)(e).map(f))}function p(e,i=t.TagSep){return m(e).map((e=>(0,o.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(n.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function w(e){return(0,n.blank)(e)?void 0:Array.isArray(e)?f((0,r.last)(e)):(0,r.last)(g(e))}function v(e,t){if((0,r.isEmpty)(e)||(0,r.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,h.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=f,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,r.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,r.uniqBy)((0,l.toA)(e),(e=>(0,r.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,r.compact)(t).map((e=>y(e))));return(0,r.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=w,t.leafIsExcluded=function(e,t){return(0,a.mapOr)(w(e),(e=>(0,h.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=v,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,s.sortBy)(e.filter(r.isNotEmpty),(e=>-e.length)))t.some((e=>v(i,e)))||t.push(i);return(0,s.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const r=i(40958),s=i(22573),n=i(68708),a=i(54993);t.extractTitleDescription=function(e){const t=(0,r.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,s.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const r of i){const i=(0,a.toS)(e[r]).trim();if((0,s.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,n.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(96249),o=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),w=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function v(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function b(e){const t=await v(e);return(0,s.uniq)((0,a.flatten)(t.map(m.uriEncodingVariants)))}async function S(e,t){if((0,n.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void w().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case o.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case o.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case o.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,n.blank)(e)?w().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=v,t.nativePath2uriVariants=b,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(S(e,t),b))),(0,s.uniq)(i)},t.uri2nativePath=S,t.uriExists=async function(e,t){const i=await S(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),s=i(57975),n=i(90595),a=i(22573),o=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",w=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class v{static isUri(e){return e instanceof v||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,s,n=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,n),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=s??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,n))}get fsPath(){return M(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:s,fragment:n}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===s?s=this.query:null===s&&(s=g),void 0===n?n=this.fragment:null===n&&(n=g),t===this.scheme&&i===this.authority&&r===this.path&&s===this.query&&n===this.fragment?this:new S(t,i,r,s,n)}static parse(e,t=!1){const i=w.exec(e);if(!i)return new S(g,g,g,g,g);const r=i[2]||g,s=k(i[4]||g),n=(i[5]||g).split("/").map(k).join("/"),a="psfile"===r&&n.startsWith("//")?n.slice(1):n,o=(0,u.toURLSearchParams)(i[7]),l=k(i[9]||g);return new S(r,s,a,o,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new S("file",t,e,g,g)}static from(e){return new S(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?v.file(r.win32.join(M(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,o.map)(this.path,(e=>(0,d.findLast)(e.split(y),a.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return E(this,e)}toJSON(){return this}[s.inspect.custom](){return this.toString()}}t.URI=v;const b=h.isWinPortable?1:void 0;class S extends v{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=M(this,!1)),this._fsPath}toString(e=!1){return e?E(this,!0):(null==this._formatted&&(this._formatted=E(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=b),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,a.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function _(e,t){let i,r=-1;for(let s=0;s=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||45===n||46===n||95===n||126===n||t&&47===n)-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),void 0!==i&&(i+=e.charAt(s));else{void 0===i&&(i=e.substr(0,s));const t=P[n];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),i+=t):-1===r&&(r=s)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function T(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function E(e,t){const i=t?T:_;let r="";const{scheme:s,query:n,fragment:o}=e;let{authority:l,path:u}=e;if(s&&(r+=s,r+=":"),(l||"file"===s)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,a.mapNotBlank)(n,(e=>r+="?"+e)),o&&(r+="#",r+=t?o:_(o,!1)),r}function D(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+D(e.substr(3)):e}}t.encodeURIComponentFast=_,t.uriToFsPath=M;const x=/(?:%[\dA-Z][\dA-Z])+/gi;function k(e){return e.startsWith("xn--")?(0,n.toUnicode)(e):e.match(x)?e.replace(x,(e=>D(e))):e}t.percentDecode=k,t.toURI=function(e){return v.isUri(e)?e:v.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),s=i(40958),n=i(50357),a=i(89937),o=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",a.PS_LOCAL_FILE_SCHEME,a.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,o.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&f(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,n.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,s.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),s=i(22573),n=i(51926),a=i(89937),o=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,s.blank)(e))return;if(null==(t=null!=t&&(0,o.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,s.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,n.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:a.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==a.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,s.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,n=(0,s.notBlank)(t)&&!t.includes(i);if(n&&!(0,s.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const o=await(0,c.bestVolumeForVolsha)(e.authority);return null!=o?f(o.mountpoint,e.path):n&&(0,s.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),s=i(22573),n=i(51926),a=i(89937),o=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,s.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,s.blank)(t))return;const i=(0,r.uniq)([t,(0,o.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,n.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==a.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,o.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,n.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const a=n(i(76760)),o=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,o.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,o.notBlank)(t.remoteHost)&&(0,o.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:a.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,o.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,o.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(a.sep)}`;const s=i.slice(1),n=await(0,p.volumes)();for(const t of(0,u.toA)(n))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return a.join(t.mountpoint,...s);return await(0,h.isReadableDirectory)(t)?a.join(t,...s):void 0}},85087:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),s=i(42659),n=i(9103),a=i(37628);t.volsha=(0,n.memoize)((e=>(0,r.mapNotBlank)(e,a.shortStringSha)),{maxSize:128,ttlMs:s.minuteMs})},60865:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),s=i(30577);t.channel=function(){return(0,s.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),s=i(22573),n=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function a(e){if(e instanceof r.SemVer)return e.version;const t=n.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=a,t.semverSatisfies=function(e,t){if((0,s.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const n=a(e);return null!=n&&(0,r.satisfies)(n,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},8540:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),s=i(9595),n=i(29882),a=i(43334),o=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([o.Settings.libraryDir.valueOrDefault,(0,s.originalsDir)(),...o.Settings.scanPaths.values]))if((!a.isPosix||!(0,n.pathIsRoot)(t))&&(0,n.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},42233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentVolumeRoots=void 0;const r=i(45200),s=i(98770),n=i(7014);t.currentVolumeRoots=(0,s.lazyFsAsync)("currentVolumeRoots",(async function(){const e=[],t=[];for(const i of await(0,n.volumes)()){t.push(i.mountpoint);const s=(await(0,r.nativePath2uri)(i.mountpoint,i))?.toString();null!=s&&e.push(s)}return{uris:e,mountpoints:t}}))},1485:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),s=i(22573),n=i(59455),a=i(50213),o=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.DfPosix"))),w=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function v(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),s=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),n=t&&(i||r||s);return y().tap({msg:"acceptPosixVolume()",result:!n,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:s}})}t.acceptPosixVolume=v,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,n.toA)(await w());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,s.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,n.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,o.assignMissingPrimitives)(i,e))}return t.filter(v)}},69108:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,a.toInt)(e,{defaultValue:0})*o.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,s.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const s=m(e.Used)??0,n=m(e.Available)??0;if(0!==s||0!==n)return{filesystem:t,mountpoint:i,size:d.isMac?s+n:r,used:s,available:n};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:s,available:n})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,s.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,n.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const a=p(i);return!0===e&&a.forEach((e=>e.remote=!1)),a},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),w=i(24399),v=i(28874),b=i(24541),S=i(60224),P=i(63870),_=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const T=/([a-z]+)(?::\\)?/i;function M(e){return e?.match(T)?.[1]?.toUpperCase()}function E(e){return(0,l.map)(M(e),(e=>e+":\\"))}function D(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(M(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function x(e){return null!=e&&!(0,a.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,a.notBlank)(e.DisplayRoot),...(0,l.map)((0,S.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function k(e){return`Get-Volume ${(0,f.toS)(M(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=E,t.getPsDriveCommand=D,t.getVolumeCommand=k,t.getLocalVolumesWin_=function(){return w.PowerShell.instance().executeJsonToA(k())};const F=/\{([-a-z\d]{7,})\}/i;function C(e,t){return e=e?.trim(),(0,a.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function A(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void _().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=E(e.DriveLetter);if(null==t)return void _().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,s.compact)([C(e.HealthStatus,"healthy"),C(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,a.notBlank)(e.DriveLetter)&&(0,a.blank)(i);return _().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(n=e.UniqueId,_().tap({msg:"uniqueId2uuid",result:(0,l.map)(F.exec((0,f.toS)(n)),(e=>e[1])),meta:{s:n}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var n}async function I(){const e=(0,s.uniq)((0,h.toA)(await(0,b.mountpointsWin)()).map(E)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>w.PowerShell.instance().executeJsonToA(D(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:v.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,s.compact)((0,o.flatten)(t).map(x)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>w.PowerShell.instance().executeJsonToA(k(e)).catch((t=>(_().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:v.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),a=(0,s.compact)((0,o.flatten)(r).map(A)),l=(0,s.uniq)([...i,...a].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,n.sort)((0,s.uniq)([...i,...a].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));_().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:a,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...a.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=A,t.volumeInfoWin=I},68884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),w=i(83278),v=i(8103),b=i(16287),S=i(45969),P=i(43334),_=i(69108),T=i(98770),M=i(44224),E=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,S.isDocker)()||(0,d.isBillingService)()||null==await(0,v.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,E.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const D=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?D().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,M.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),b.isReadableDirectory),(e=>e.map((e=>w.BaseFile.for(e).clear().childDirectories())))))}):D().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,s.isEmpty)(e)?[]:(D().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,E.mountpointsTtlMs)(),f:async e=>{const t=await(0,_.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void D().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await x(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,E.mountpointsTtlMs)()}))),(0,o.later)((()=>(0,T.setupVolumeTTL)(t.gioVolumes)));const x=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,E.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,n.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(n.notBlank).get()}}catch(t){return void D().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs})},98770:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),s=i(5233),n=i(41400),a=i(56038),o=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,a.time)("volumes."+e,(()=>(0,s.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,o.isRetriableError)(e)&&!1!==(0,o.isIgnorableError)(e)})))),i);return(0,n.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),w=i(98770),v=i(63870),b=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>b().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>b().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const n=(0,c.sortIgnoreCase)((0,s.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),a=[];for(const t of n){const s=e.find((e=>e.mountpoint===t)),n=i?.find((e=>e.mountpoint===t)),o={...s,...n},u=r?.find((e=>e.filesystem===o.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(o,u),null==o.size||null==o.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];b().info("backfilling mountpoint",{info:n,vol:s,df:e}),null!=e&&(0,l.assignMissingPrimitives)(o,e)}a.push(o)}return a};const S=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return S.exec(e)?.[1]?.split(".").map((e=>(0,a.toInt)(e)))})),_=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,a.gte)(t[0],2)&&(0,a.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,w.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await _()],{timeoutMs:(0,v.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,n.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,a.toInt)(e.fsused),r=(0,a.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return b().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,w.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,v.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,n.toNotBlank)(e.PARTLABEL)??(0,n.toNotBlank)(e.LABEL),uuid:(0,n.toNotBlank)(e.PARTUUID)??(0,n.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),s=i(19851),n=i(40958),a=i(22573),o=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),w=(0,s.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,n.uniq)(e.map((e=>e.filesystem?.match(v)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),s=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of s)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,a.blank)(t.MountPoint)||(0,o.isTrue)(t.OSInternal)?w().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){w().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const v=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),w=i(84777),v=i(34330),b=i(8769),S=i(34102),P=i(17217),_=i(16287),T=i(43334),M=i(28874),E=i(8540),D=i(68884),x=i(44224),k=i(24541),F=i(69375),C=i(63870),A=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function O(e=(0,C.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function L(){I()}t.localMountpointSetup=(0,r.lazy)((async()=>{M.Settings.libraryDir.watchLater(I),M.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&M.Settings.scanAllDrives.valueOrDefault?(0,o.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(T.isMac&&(e.info("Setting up Mac diskutil activity watcher"),O((0,C.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),T.isLinux){const i=(0,x.maybeWatchProcMounts)();await(0,D.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),O((0,C.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),O((0,C.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),a.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=M.Settings.mountpoints.values;if((0,s.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",T.isWin?k.mountpointsWin:x.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,s.isEmpty)(e))return A().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,n.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,C.commandTimeoutMs)(),f:async e=>!(!(0,E.mightBeAssetMountpoint)(e)&&(0,F.isExcludedMountpoint)(e)||M.Settings.validateMountpoints.valueOrDefault&&!await(0,_.isReadableDirectory)(e)&&(A().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,b.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(T.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return T.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,o.later)((()=>{(0,S.ee)().on("clearCache",(()=>{D.gioVolumes.unset(),I()})),M.Settings.mountpointsTtlMs.watch(O)}),(0,c.isTest)()?1:a.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>L(),minCallDelayMs:1.5*a.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:D.GioCommand,args:D.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(D.gioVolumes.unset(),L()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const N=(0,r.lazy)((async()=>{if(!T.isLinux)return!1;try{return 0===(await(0,w.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,C.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>L(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(48884),o=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),w=i(28874),v=i(69108),b=i(68884),S=i(59107),P=i(69375),_=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await D()??await(0,c.thenMap)((0,v.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,b.isGioSupported)())try{await(0,c.thenMap)((0,b.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){_().warn("Failed to fetch gio volumes",e)}return e};const T="/proc/mounts";function M(e){return!w.Settings.excludedFilesystemTypes.has(e)}function E(e){return!(0,P.isExcludedMountpoint)(e)&&(!w.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function D(e=T,t=M,i=E){if(y.isLinux)try{const r=await(0,f.readLines_)(e),n=(0,s.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,a.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),o=await(0,c.filterAsync)({name:"mountpoints filter",arr:n,f:async([e,r])=>{const s=t(e),n=await i(r);return _().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:s&&n,meta:{fs:e,mp:r,fsOK:s,mpOK:n}})}});return _().tap({msg:"readProcMounts()",result:o.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void _().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=M,t.readProcMounts=D,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(T)?new h.FileWatcher(T,{recursive:!1,persistent:!1},(()=>{_().info("detected change in "+T),(0,d.setUnrefTimeout)((()=>S.mountpoints.refresh()),n.secondMs)})):void 0))},24541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),s=i(42659),n=i(13538),a=i(50213),o=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,n.thenOrTimeoutError)(f(),o.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*s.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(9103),o=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,n.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,s.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,o.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,o.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,o.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,o.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,s.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,a.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),s=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,n=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function a(e){if((0,r.blank)(e))return;const i=s.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(n,""),remoteShare:i.remoteShare};const a=t.nfsRe.exec(e);if(null!=a){const e=a[1],t=a[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=a(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=a},60224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(55835),o=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),w=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await M()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,a.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const v=["LocalName","RemoteName","Status"],b=["NETUSE","get",v.join(",")],S=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function _(e){if(!(0,s.blank)(e))return(0,o.opt)(e).flatMap((e=>S.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,o.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,s.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,o.opt)(e.pathname).filter(s.notBlank).getOrElse((()=>"/"))}))))).get()}async function T(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,b,{timeoutMs:15*n.secondMs}),i=(0,u.parseFixed)(v,t);return(0,r.compact)(i.map((e=>(0,a.map)(S.exec((0,l.toS)(e.RemoteName)),(t=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=_,t._netInfoWinWmic=T;const M=(0,w.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?T():(0,r.compact)(e.filter((e=>(0,s.notBlank)(e.LocalName))).map((e=>(0,a.map)(_(e.RemoteName),(({host:t,share:i})=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,h.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),s=i(12168),n=i(28874);t.mountpointsTtlMs=function(){return n.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return n.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return n.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=s.MiB/r.secondMs},86848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(38639),o=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),w=i(95696),v=i(45969),b=i(28874),S=i(59107),P=i(63870),_=i(68995),T=(0,s.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),M=(0,s.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function E(e){return(0,a.isTrue)(e.ignorable)||(0,v.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function D(e){if((0,n.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function x(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=D(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function k(e){if(b.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of b.Settings.volumeUuidFilePaths.values){const i=w.PosixFile.for(e.mountpoint).join(t),r=await x(i).catch((e=>T().info("Failed to read "+i,{error:e})));if(null!=r)return T().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,_.volumeUuidSubpath)());if("/"===e.mountpoint)return T().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(b.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return T().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(b.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,_.writeVolumeUuid)(e);if(!(0,n.blank)(t))return T().tap({msg:"readVolumeUUID(): wrote new "+(0,_.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return T().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,o.later)((()=>{(0,m.ee)().on("clearCache",(()=>M.clear())),S.mountpoints.watchLater((()=>M.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(E(e))return;if((0,a.isFalse)(e.ok))return;const t=await M().getOrSetAsync(e.mountpoint,(async()=>k(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>T().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=E,t.toVolumeUUID=D,t.readUuidFile_=x,t.readVolumeUUID=k},7014:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),w=i(59455),v=i(48884),b=i(50213),S=i(7282),P=i(23560),_=i(28850),T=i(45255),M=i(81168),E=i(56519),D=i(4867),x=i(49776),k=i(9595),F=i(77740),C=i(44198),A=i(96706),I=i(8769),O=i(57159),L=(i(34102),i(21144)),R=i(73209),N=i(29882),B=i(95696),j=i(17217),z=i(16287),V=i(49076),W=i(96128),U=i(45969),q=i(43334),H=i(28874),$=i(85087),G=i(50424),J=i(48165),K=i(98770),Y=i(27461),Z=i(66840),X=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,a.lazy)((()=>(0,b.mkLogger)("volumes.Volumes"))),se=s.default.platform(),ne=new Map,ae=new Map,oe=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,$.volsha)(t.uuid),(e=>ae.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,ne),le((0,$.volsha)(e.uuid),e,oe),e}function ce(){return(0,o.compact)([B.PosixFile.forMaybe((0,x.cacheDir)())?.join("volumes"),B.PosixFile.forMaybe((0,k.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),ae))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),ne.clear(),oe.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,E.mapAsync)({name:"readCachedVolumes",arr:(0,E.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,o.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,M.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),s=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:r,os:se}))),n=new Map;for(const e of s)for(const t of(0,o.compactBlanks)([(0,$.volsha)(e.uuid),(0,$.volsha)(e.mountpoint)]))n.set(t,e);const a=ce();for(const e of a)await(0,R.withLock_)({file:e,timeoutMs:T.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of n.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:a,vol_mountpoints:s.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,o.isNotEmpty)(e))return e;const i=(0,w.toA)(await(0,X.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,H.Settings.volumeMetadataTtlMs.valueOrDefault),s=0!==H.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),n=!(0,o.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:s,priorIsMissingMountpoints:n}),s||n?void 0:e}async function me(e,i){const r=(0,m.map)(e,j.toNativePath_);if((0,u.blank)(r))return;const s=await(0,L.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,o.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(s,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:s,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:s}})}async function pe(e,t,i){const r=i.filter((e=>(0,M.equalsIgnoreCase)(t,e.remoteShare)));if((0,o.isEmpty)(r))return;const s=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,M.equalsIgnoreCase)(e,t.remoteHost)));if(null!=s)return s;const n=await(0,W.friendlyname)(e);return(0,E.asyncFind)(r,(async e=>(0,M.equalsIgnoreCase)(n,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,a.lazy)((()=>(0,P.isSyncService)()||(0,S.isTest)())),t.priorWriteVolumesToCacheLatch=(0,a.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,a.lazy)((async()=>{const e=(0,o.compact)(await de()),t=(0,w.toA)(await(0,X.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,o.isNotEmpty)(i)?i:e.filter((e=>se===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,D.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,D.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,o.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,O.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,_.shim0)({name:"fs.volumes",impl:async function(){if((0,S.isTest)()){const e=(0,p.toInt)((0,C.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,F.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,D.thenOrTimeoutError)({p:q.isWin?(0,J.dfWin)():(0,G.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=H.Settings.validateMountpoints.valueOrDefault?(0,o.compact)(await(0,E.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,z.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,D.thenOrTimeoutError)({p:q.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(q.isWin?t:q.isMac?await(0,Z.addLocalVolumeInfoMac)(t):await(0,Y.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await he(r),Object.freeze(r)}}),t.rootPath=(0,a.lazy)((()=>q.isWin?(0,g.opt)((0,A.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,M.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,o.isEmpty)(t)?void 0:(0,v.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,o.commonPrefixLength)(e.split(n.default.sep),t.split(n.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,w.toA)(await i.vols()).find((t=>(0,$.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,E.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return oe.get(e)??(await de())?.find((t=>(0,$.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,$.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(50213),o=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,s.lazy)((()=>(0,a.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,n.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,f());t=(0,n.toNotBlank)(t)??(0,c.safeUUID)();const s=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(s))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+o.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},51140:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpStatusIs=t.HttpStatus=void 0;const r=i(31586);t.HttpStatus=Object.freeze({OK:200,Accepted:202,MovedPermanently:301,Found:302,SeeOther:303,BadRequest:400,Unauthorized:401,Forbidden:403,NotFound:404,EnhanceYourCalm:420,InternalServerError:500,NotImplemented:501,ServiceUnavailable:503}),t.HttpStatusIs=Object.freeze({ok:e=>(0,r.within)(200,299,e),success:e=>(0,r.within)(200,299,e),redirect:e=>(0,r.within)(300,399,e),clientError:e=>(0,r.within)(400,499,e),serverError:e=>(0,r.within)(500,599,e),error:e=>(0,r.within)(400,599,e)})},21404:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToTagPath=void 0;const r=i(75020),s=i(40958),n=i(22573),a=i(89937),o=i(34238);t.uriToTagPath=function({uri:e,isFile:t}){if(null==e)return;const i=(0,o.toURI)(e),l=i.scheme===a.PS_LIBRARY_SCHEME?r.LibraryTagName:i.scheme===a.PS_LOCAL_FILE_SCHEME?i.authority:void 0;if((0,n.blank)(l))return;const u=i.path.split("/");return(0,s.compactBlanks)([r.TagRoots.fs,l,...t?u.slice(0,-1):u])}},98604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkAssetUrl=t.mkFolderUrl=t.myWebUrl=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(27776),o=i(49076),l=i(72308),u=i(28874),c=i(42231),d=i(45200),h=i(34238),f=i(21404);function m(e=u.Settings.httpPort.valueOrDefault){const t=[u.Settings.localhost.valueOrDefault];u.Settings.exposeNetworkWithoutAuth.valueOrDefault&&t.push(...(0,s.compactBlanks)([(0,l.myExternalIp4Addresses)()[0],(0,o.hostname)()]));const i=(0,h.toURI)("http://a");return t.map((t=>i.with({authority:t+":"+e})))}t.default=m,t.myWebUrl=(0,r.lazy)((()=>m()[0])),t.mkFolderUrl=async function(e){const i=await(0,d.nativePath2uri)(e),r=(0,f.uriToTagPath)({uri:i,isFile:!1});if((0,s.isEmpty)(r))return;const n=(0,a.mkTagUri)((0,c.tagPathToStringArray)(r));return(0,t.myWebUrl)()?.with(n)},t.mkAssetUrl=function(e){return(0,n.gt0)(e)?(0,t.myWebUrl)()?.with({path:"/asset/"+e}):void 0}},4988:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.httpRequest_=t.get_=t.HttpMethods=void 0;const a=n(i(37067)),o=n(i(44708)),l=i(22573),u=i(45599),c=i(50989),d=i(51926),h=i(50213),f=i(45255),m=i(22911),p=i(43205),g=i(34238),y=i(51140),w=(0,u.defer)((()=>(0,h.mkLogger)("net.get")));async function v(e,t){return b({...t,url:e})}async function b(e){const t=(0,g.toURI)(e.url),i=new m.Deferred("get "+t.toString()),r="http"===t.scheme?a.request:"https"===t.scheme?o.request:w().throw("unsupported scheme: "+t.scheme),s=e?.maxRedirects??8,n=e?.timeoutMs??f.ShortCommandTimeoutMs,u={...e?.headers,"user-agent":await(0,p.userAgent)()},c=e?.method??"GET",h=e?.agent??!1,b=r(t.toString(),{method:c,headers:u,timeout:n,agent:h},(e=>{let r="";e.setEncoding("utf8").on("data",(e=>r+=e.toString())).resume().on("end",(()=>{const a={url:(0,l.toNotBlank)(e.url)??t.toString(),contentType:e.headers["content-type"],statusCode:e.statusCode??-1,data:r};s>0&&y.HttpStatusIs.redirect(a.statusCode)&&!(0,l.blank)(e.headers.location)?(console.log("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),w().info("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),i.observe(v(e.headers.location,{timeoutMs:n,maxRedirects:s}))):(w().debug("complete",{...a,data:(0,d.ellipsize)(r,64),data_length:r.length}),i.resolve(a))}))})).on("error",(e=>i.reject(e)));return(0,l.blank)(e.body)||b.write(e.body),b.end(),i}t.HttpMethods=(0,c.strEnum)("GET","PUT","POST","PATCH","DELETE"),t.get_=v,t.httpRequest_=b},65713:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),s=i(19851),n=i(23838),a=i(81168),o=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,s.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,s.lazy)((async()=>{const e=(0,o.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,s.lazy)((()=>({trie:new n.MultiMap,small:[]}))),h=3;function f(e){const t=new n.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=s)return s}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),s=i(96249),n=i(23838),a=i(59455),o=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=n.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,a.toA)(u[t])],n=c(e.substring(1));return(0,s.flatten)(n.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,o.stripDiacritics)(e).normalize())}},30933:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const s=r(i(48161)),n=i(19851),a=i(42659),o=i(31586),l=i(50213),u=i(28874),c=(0,n.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,n.lazy)((()=>s.default.cpus()),5*a.minuteMs),t.cpuCount=(0,n.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=s.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,o.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const s=r(i(48161)),n=i(19851),a=i(31586),o=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,n.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,n.lazy)((()=>{const e=s.default.freemem(),t=s.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,a.gt0)(r))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,o.fmtBytes)(i),freemem:(0,o.fmtBytes)(e),totalmem:(0,o.fmtBytes)(t)}})}))},69385:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOnResume=t._setPaused=t.resume=t.pause=t.isPaused=void 0;const r=i(34102),s=i(37692);let n=!1;function a(){return n}function o(e=!0){l(e),(0,s.writeStateFile)({paused:e})}function l(e){e!==n&&(n=e,(0,r.ee)().emit(e?"pause":"resume"))}t.isPaused=a,t.pause=o,t.resume=function(){return o(!1)},t._setPaused=l;const u=Promise.resolve();t.resolveOnResume=function(){return a()?new Promise((e=>{(0,r.ee)().once("resume",e)})):u}},15674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),s=i(42659),n=i(41400),a=i(31586),o=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,n.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const w=(0,r.lazy)((()=>{const e=(0,a.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*o.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/o.MB),worstCaseMemPerProcMb:Math.ceil(e/o.MB)}})}),s.minuteMs);function v(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,a.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function b(){return((0,a.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=v,t.targetCpuLoadPct=b,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(b()*(0,f.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(b()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=v();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const s=Math.min(e,w());return t=(0,a.clamp)(1,s,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:b(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:w()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,a.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,a.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,a.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},37692:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addStateEvent=t.writeStateFile=t.readStateFile=t.stateEvents=t.StateEvents=t.StateEventFns=void 0;const s=r(i(78474)),n=i(40958),a=i(76790),o=i(42659),l=i(45599),u=i(41400),c=i(68708),d=i(50989),h=i(87290),f=i(73787),m=i(19851),p=i(50213),g=i(28874),y=i(69385),w=(0,l.defer)((()=>(0,p.mkLogger)("work.SharedState")));let v;t.StateEventFns={checkTasks(){},reloadLicenses(){}},t.StateEvents=(0,d.strEnum)(...(0,c.keys)(t.StateEventFns)),t.stateEvents=new s.default;let b=0;function S(){const e=(0,h.libraryDataDirPosixFile)()?.join("state.json"),t=Date.now(),i=t-b>o.minuteMs;i&&(b=t);const r=e?.existsSync({refresh:i})??!1;return r&&null!=e&&e.eql(v?.nativePath)||(v?.close(),v=void 0),r&&null!=e&&(v??(v=new f.FileWatcher(e.nativePath,{encoding:"utf8",persistent:!1,recursive:!1},P))),e}(0,u.later)((()=>{g.Settings.libraryDir.watchLater(P)}));const P=(0,m.lazy)((()=>t.readStateFile.refresh()),25);t.readStateFile=(0,m.lazy)((()=>{const e=S()?.readJsonSync();for(const i of e?.events??[])_.get(i.e)!==i.ts&&(w().info("emitting event "+i.e),t.stateEvents.emit(i.e),_.set(i.e,i.ts));return(0,y._setPaused)(e?.paused??!1),e}));const _=new Map;function T(e){const i=S();if(null==i)w().error("overwrite(): failed: no library directory");else{const r=i?.readJsonSync(),s=function(e){const t=Date.now()-10*o.minuteMs;return(0,n.uniqByLast)((0,a.sortBy)((e??[]).filter((e=>e.ts>t)),(e=>e.ts)),(e=>e.e))}([...r?.events??[],...e.events??[]]),l={paused:e.paused??r?.paused??g.Settings.startPaused.valueOrDefault,events:s};(0,y._setPaused)(l.paused),t.readStateFile.set(l),i.writeJsonSync(l)}}t.writeStateFile=T,t.addStateEvent=function(e){const t=Date.now();_.set(e,t),T({events:[{e,ts:t}]})}},22751:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),s=i(87997),n=i(19851),a=i(42659),o=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,n.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,n.lazy)((()=>new r.Rate(5*a.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,n.lazy)((()=>(0,s.setInterval)(g,a.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,o.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),s=i(22573),n=i(50357),a=i(98553),o=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function w(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function b(e){return null==e?[]:w((0,h.toA)(e),(e=>null!=e))}function S(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,o.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const s=[];if(et;n-=i)s.push(r(n));return s}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=w,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),s=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===s[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,n.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const s of t){const t=i(s);r.includes(t)||(e.push(s),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return w(e,(e=>t.every((t=>!(0,n.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return w(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=b,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(s.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=b(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return S(t,(e=>(0,l.isPrimitive)(e)?e:(0,a.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,n.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=b(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=S,t.uniqByLast=function(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of b(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,a.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const s=new Set(i.map(r));return e.filter((e=>!s.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),s=i(36783),n=i(41801),a=i(98553),o=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,s.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const r of e)(0,o.getOrSet)(i,(0,a.stringify)(t(r)),(()=>r));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,s.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,n.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},75761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetImgAttrs=t.assetSqImgAttrs=t.assetVideoLink=t.assetImgActualLink=t.assetImgLink=t.assetLinkAttrs=t.assetUrl=void 0;const r=i(58939),s=i(40958),n=i(22573),a=i(42659),o=i(11371),l=i(73722),u=i(31586),c=i(54993),d=i(29652),h=i(22403),f=i(2322);function m(e,t){return e+" "+t+"w"}function p(e,t){let i=null==t?void 0:(0,d.mergeURLSearchParams)(...t);const r=(0,c.toS)(e.v);return(0,n.blank)(r)||"1"===r||(i??(i=new URLSearchParams)).append("v",r),i}function g({assetId:e,params:t}){return null==e?"":(0,d.assembleFullPath)("/asset/"+(0,r.id2id)(e),p(e,t))}function y({assetId:e,reducer:t,width:i,params:s}){return(0,d.assembleFullPath)(`/img/${(0,r.id2id)(e)}/${t}/${(0,u.toGt0)(i)??320}`,p(e,s))}function w({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/img/${(0,s.compact)([(0,r.id2id)(e),t]).join("/")}/actual`,p(e,i))}function v({assetId:e,params:t,reducer:i,widths:s,lazyLoad:n,af:l}){if(null==(0,r.id2id)(e))return{src:"/images/clear-64.png"};0===(s=(s??[]).filter(u.gt0)).length&&s.push(320);const d=Math.min(...s),p={width:(0,c.toS)(d)},g=(0,a.fmtLocalToShort)(e.capturedAtLocal);null!=g&&(p.title=g);const v=y({assetId:e,params:t,reducer:i,width:d});n??(n=!0);const b=n&&(0,f.isSafari)((0,h.ua)());b?(p.src="/images/clear-64.png",p["data-src"]=v):p.src=v,(0,f.isSafari)((0,h.ua)())||(p.loading=n?"lazy":"eager"),i===o.ReducerNames.sq&&(p.height=(0,c.toS)(d));const S=s.map((r=>m(y({assetId:e,params:t,reducer:i,width:r}),r)));return null!=l&&S.push(m(w({assetId:e,params:t,assetFileId:l.assetFileId}),l.width)),p[(b?"data-":"")+"srcSet"]=S.join(","),p}t.assetUrl=g,t.assetLinkAttrs=function({assetId:e,params:t}){const i=g({assetId:e,params:t});return(0,n.blank)(i)?{}:{href:i}},t.assetImgLink=y,t.assetImgActualLink=w,t.assetVideoLink=function({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/video/${(0,r.id2id)(e)}-${t}`,p(e,i))},t.assetSqImgAttrs=function({assetId:e,params:t,lazyLoad:i,size:r="m"}){return{...v({assetId:e,params:t,reducer:"sq",widths:l.SqWidths,lazyLoad:i}),sizes:("s"===r?80:"m"===r?160:320)*(0,u.numericOr)(globalThis?.window?.devicePixelRatio,1)+"px"}},t.assetImgAttrs=v},5233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),s=i(31586),n=i(13538),a=i(41583);t.retryOnReject_=async function(e,t){const i=(0,s.gt0)(t.timeoutMs)?()=>(0,n.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const o=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,a.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await o(l),u()}};return u()}},17586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55938),o=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,a.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,a.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,s.blank)(e)?"":"```"+(0,o.toS)(e)+"```"},t.b=function(e){return"**"+(0,o.toS)(e)+"**"},t.li=function(...e){return(0,r.compactBlankish)((0,n.flatten)(e)).map((e=>"- "+(0,o.toS)(e))).join("\n")}},22573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),s=i(42279),n=i(54993);function a(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function o(e){return!a(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,n.toS)(e);return o(i)?t(i):void 0}t.blank=a,t.notBlank=o,t.notBlankToS=function(e){return o(e)&&"undefined"!==e?(0,n.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,n.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,s.tot)(t);const i=(0,n.toS)(e).trim();return i.length>0?i:(0,s.tot)(t)},t.notBlankAnd=function(e,t){return!a(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,n.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{"use strict";function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),s=i(22573),n=i(30301),a=i(55835),o=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,a.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,o.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const s=Math.floor(e/t.minuteMs);e-=s*t.minuteMs;const n=Math.floor(e/t.secondMs),a=Math.floor(e-n*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(s)+":"+(0,l.pad2)(n)+(i.includeMs?"."+(0,l.pad3)(a):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function w(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),s=i(),n=i(),a=i(),o=i(),l=i();return new Date(t,l-1,o,a,n,s,r)}function v(){return(new Date).setHours(24,0,0,0)}function b(e,i="ago"){return e<1e3?"just now":(i=(0,s.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const n=Math.floor(e/r.ms);e-=n*r.ms,n>0&&(r.ms>=t.dayMs?i:s).push(n+r.s)}return e>0&&s.push((0,o.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(s)?"":"T"+s.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=w,t.fmtLocalToShort=function(e){return(0,a.map)(w(e),m)},t.nextMidnightTs=v,t.msUntilMidnight=function(){return v()-Date.now()},t.fmtAgo=function(e,t="ago"){return b(Date.now()-e,t)},t.fmtElapsedMs=b},95892:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),s=i(73872);function n(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function a(e,t,i,r){if(null==i||y(e)||y(t))return;let s=i.get(e);null!=s?s.set(t,r):(s=new WeakMap,s.set(t,r),i.set(e,s))}function o(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const s=l(e,t);return null!==s?s:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=n(e,t,u);if(null!==f)return f;const m=n(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return a(e,t,u,i),i;const s=l(e,t);if(null!==s)return s}const y=s(e);if(y!==s(t))return a(e,t,u,!1),!1;a(e,t,u,!0);const w=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return o(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],s=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){s.push([e,t])})),c(r.sort(),s.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return a(e,t,u,w),w}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let s=-1;for(;++s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const s=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return s.prior=()=>t,s.hasPrior=()=>r,s}},41400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),s=i(35556),n=i(31586),a=i(68708);function o(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const n=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&s.isNode&&n.unref?.()}}))}t.delayUntil=function(e){const t=((0,n.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return o(t).then((()=>t))},t.delay=o,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),n=s.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return s.isBrowser||t<=r.secondMs?n:(0,a.maybeCall)(n,"unref")??n}},33374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const r=i(31586),s=i(21605),n=i(12168);function a(e){return{width:e.height,height:e.width}}function o(e){return((0,r.toGt0)(e?.width)??0)*((0,r.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,r.gt0)(e.width)&&(0,r.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,r.gt0)(e)&&(0,r.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,n.pixels2size)(e.width*e.height)},t.dimSwap=a,t.maybeDimSwap=function(e,t){return(0,s.swappableRotation)(t)?a(e):e},t.maybeFlipInPlace=function(e,t){(0,s.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,n.megapixels)(o(e))},t.pixels=o},50357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),s=i(68708),n=i(34666),a=i(32639);function o(e,t){return(0,r.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,a.isFunction)(e)&&(0,a.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=o,t.eqlSubset=function(e,t){if(null==e||null==t||(0,n.isPrimitive)(e)||(0,n.isPrimitive)(t))return e===t;if(!(0,s.isObject)(e)||!(0,s.isObject)(t))return!1;for(const i of(0,s.keys)(e))if(!o(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(31586),o=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,s.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,a.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,n.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,s.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,s.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,s.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(s.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,o.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,o.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,o.assignFields)(new Error,(0,o.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},4188:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),s=i(42659),n=i(55835),a=i(31586),o=i(12168),l=[{ms:s.yearMs,s:"year",p:"years"},{ms:s.yearMs/12,s:"month",p:"months"},{ms:s.weekMs,s:"week",p:"weeks"},{ms:s.dayMs,s:"day",p:"days"},{ms:s.hourMs,s:"hour",p:"hours"},{ms:s.minuteMs,s:"minute",p:"minutes"},{ms:s.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,s){if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,n.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,o.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,n.mapOr)(s,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function s(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=s,t.orList=function(e){return s(e,"or")},t.andList=function(e){return s(e,"and")}},50268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const r=i(22573),s=i(38639),n=i(68708),a=i(62220),o=i(50989);t.HealthCheckSections=(0,o.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,o.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,n.isObject)(e)&&!(0,r.blank)(e.id)&&!(0,r.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,r.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,n.isObject)(e)&&a.RunStates.has(e.state)&&(0,s.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},11371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReducerNames=void 0;const r=i(50989);t.ReducerNames=(0,r.strEnum)("fit","sq")},73722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const s=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,s){if((0,isFunction_1.isFunction)(r))return;let n,a,o,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(n=0;nnew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),s=i(50357),n=i(31586),a=i(65812);t.lazy=function(e,t){let i,o;const l=[];function u(){return u.isStale()&&u.setResult(e()),o}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const n=await e,o=await i;if(!(0,s.eql)(n,o))for(const e of l)e(o);null!=t&&t>0&&void 0!==o&&(0,a.setUnrefTimeout)((()=>u.vacuum()),t)}(o,e),o=e},u.isStale=function(){return null==i||(0,n.gt0)(t)&&i+t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),s=i(54993);function n(e,t){return null==e?void 0:t(e)}function a(e,t,i){return null==e||null==t?void 0:i(e,t)}function o(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=n,t.mapTry=function(e,t){try{return n(e(),t)}catch{return}},t.map2=a,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=o,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return o(a(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,s.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class s extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=s},23838:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),s=i(76790),n=i(50357),a=i(98553),o=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,o.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,o.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,n.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),s=null==i?[]:e(t,i);(0,r.isEmpty)(s)?this.store.delete(t):this.store.set(t,s)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,s]of this.store.entries()){const n=(0,r.findIndexes)(s,(t=>!e(i,t,s)));if(n.length>0){t=!0;for(const e of n.reverse())s.splice(e,1)}0===s.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,a.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,s.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),s=i(22573),n=i(42279),a=i(54993);function o(e){return"number"==typeof e&&isFinite(e)}t.isNumber=o,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,a.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return o(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,a.toS)(e).match(u)&&null!=w(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>o(t)&&o(i)&&e(t,i);function f(e,i,s){return!(null==s||!o(s))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,s)&&(0,t.gte)(i,s))}function m(e){if(!o(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,s.blank)(e))return t.defaultValue;if(o(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function w(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function v(e){return o(e)&&e>0}function b(e){return o(e)&&e>=0}function S(e,t){return o(e)?t(e):void 0}function P(e){return o(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function T(e,t,i){if(e>t||!o(e)||!o(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return o(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return o(e)?e:t},t.diff=function(e,t){return o(e)&&o(t)?e-t:void 0},t.absdiff=function(e,t){return o(e)&&o(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!o(e)||!o(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return f(t-r,t+r,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)o(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=w(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return o(e)&&e<0},t.gt0=v,t.firstGt0=function(...e){for(const t of e){if(v(t))return t;const e=y(t);if(v(e))return e}},t.gtOrElse=function(e,t){return o(e)&&o(t)&&e>t?e:void 0},t.lte0=function(e){return o(e)&&e<=0},t.gte0=b,t.toGte0=function(e){return b(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=w(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return v(t)?String(t):void 0},t.mapNumeric=S,t.map2Numeric=function(e,t,i){return S(e,(e=>S(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return o(e)?t(e):i},t.numericOr=function(e,t){return o(e)?e:(0,n.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return S(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!o(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=T,t.times=function(e,t){if(!v(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return T(0,100,v(t)?P(100*(v(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!o(i))return;t+=i}return t}},68708:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(32639),o=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function w(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function v(e,t,i={}){return y((0,r.compact)((0,s.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function b(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const s={};for(const e of(0,r.uniq)((0,r.flatMap)(i,h)))s[e]=b(...i.map((t=>t[e])));return s}function S(e,t){if(!d(e)||(0,n.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=w(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,s]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==s&&!0!==i?.assignNullish||(e[r]=s));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=w,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,o.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,n.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=v,t.mergeObjectsDeep=b,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,n.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=o.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function s(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:b(i,t)}for(const r of i){const[i,a]=(0,c.splitFirst)(r,"."),o=S(t,i);null!=o?.value&&s(o.key,(0,n.blank)(a)?o.value:e(o.value,a))}for(const r of h(t))((0,l.toInt)(r)??-1)>=0&&s(r,e(t[r],...i));return r},t.pluck=S,t.pluckDeep=function e(t,i){if(null==t||(0,n.blank)(i))return;if(Array.isArray(t)){const s=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(s)?void 0:{key:s[0].key,value:(0,r.flatMap)(s,(e=>e.value))}}const[s,a]=(0,c.splitFirst)(i,"."),o=S(t,s);if(null==o)return;if((0,n.blank)(a))return o;const l=e(o.value,a);return null==l?void 0:{key:o.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,n.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,a.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,n.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=v(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>n(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return s(t)?t:n(t)}filter(e){return n(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return n(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return n(e).flatMap((e=>n(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return n(e).flatMap((e=>n(t).flatMap((t=>n(i).flatMap((i=>r(this.a,e,t,i)))))))}}function s(e){return e instanceof r||e===t.None}function n(e){return s(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=s,t.opt=n},97238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSeed=t.prngSeed=t.SeedCount=t.PrimeBins=t.PrimesPerBin=void 0;const r=i(31586),s=i(30976),n=i(54993);t.PrimesPerBin=4,t.PrimeBins=8,t.SeedCount=t.PrimesPerBin**t.PrimeBins,t.prngSeed=function(){return(0,s.randomInt)(0,t.SeedCount)},t.toSeed=function(e){const i=(0,r.toInt)((0,n.toS)(e));return(0,r.within)(0,t.SeedCount,i)?i:void 0}},39926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),s=i(54993),n={};function a(e,t){if(t<1)return"";if(!(0,r.gte)(n[e]?.length,t)){let i=n[e]??e;for(;i.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var r=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return r.parseJSON}})},46891:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),s=new Map([["child","children"],["photo","photos"],["video","videos"]]),n=/([sxz]|ss|sh|ch)$/,a=/[^aeiou]y$/,o=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=s.get(e);return null!=t?t:null!=e.match(n)?e+"es":null!=e.match(a)?e.replace(/y$/i,"ies"):null!=e.match(o)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),s=i(54993),n=["number","string","boolean"];function a(e){return-1!==n.indexOf(typeof e)}t.isPrimitive=a,t.mapPrimitive=function(e,t){return a(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return a(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(a)};const o=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,n=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==n&&"symbol"!==n)){const r=(0,s.toS)(e),n=(0,s.toS)(i),a=r.localeCompare(n);return r[0]===t.CmpReverseFlag&&n[0]===t.CmpReverseFlag?-a:a}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==n?o.indexOf(r)-o.indexOf(n):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function s(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const s of(0,r.toA)(await e))if(null!=s){const e=await s;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=s,t.isPromise=function(e){return s(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),s=i(31586);function n(e,t){return Math.floor(Math.random()*(t-e))+e}function a(e,t,i){return null==i||0===i.length?n(e,t):o(e,t,1,i)[0]}function o(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const s=t-e,a=new Set(r??[]);if(t===e&&0===s&&0===a.size&&1===i)return[e];const o=s-a.size;if(i>o)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:s,size:i,slotsRemaining:o})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of o(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,s.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let r=e;t.global||(t=new RegExp(t,"g"));let s=null;for(;null!=(s=t.exec(e));)s.index===t.lastIndex&&t.lastIndex++,r=r.slice(0,s.index)+i(s)+r.slice(s.index+s[0].length);return r}},21605:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const r=i(31586);function s(e){if(!(0,r.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,r.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=s,t.swappableRotation=function(e){const t=s(e);return 90===t||270===t}},62220:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const r=i(50989);t.RunStates=(0,r.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),s=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),n={};for(const e of t)n[e]=e;const a=e=>null!=e?i[e]:void 0,o=e=>null!=a(e);return{...n,values:t,length:t.length,has:o,includes:o,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:a,ordinal:e=>a(e)??t.length,validOrElse:(e,t)=>o(e)?e:(0,s.tot)(t),mapValid:(e,t)=>o(e)?t(e):void 0,cmp:(e,t)=>{const i=a(e),r=a(t);return null==i||null==r?void 0:i>r?1:i{const i=a(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),s=i(17586),n=i(22573),a=i(96249),o=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=f();return null!=r?(0,o.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function b(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function S(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),s=(0,c.toS)(t);return r.length===s.length&&(r===s||r.toLowerCase()===s.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?s.normalize():s,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,n.blank)(t)?void 0:e.find((e=>S(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,s.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,o.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=w,t.ensureSuffix=v,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return v(w(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=b,t.wrap=function e(t,i){const r=i?.maxLineLen??80,s=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,a.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,a.flatten)(r.map((t=>e(t,i))))}if((t=w((0,c.toS)(t),s).trim()).length<=r)return[t];const n=b(t," ",r);if(n>s.length)return[m(t,0,n),...e(m(t,n+1),i)];{const r=t.indexOf(" ",s.length+1);return r>0&&r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),s=i(68708),n=i(42279),a=i(83104),o=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let s=!0;const n=setTimeout((()=>{s&&(s=!1,i(a.Timeout))}),t);try{n.unref?.();const t=await e;s&&(s=!1,i(t))}catch(e){s&&(s=!1,r(e))}finally{clearTimeout(n)}}))}async function u(e,t,i=!0){const s=await l(e,t,i);if(s===a.Timeout)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return s}t.toNotTimeout=function(e){return e===a.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?a.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,n)=>{let a=!0;try{const o=setTimeout((async()=>{if(a){a=!1;try{r(await i())}catch(e){n(e)}}}),t);(0,s.maybeCall)(o,"unref");const l=await e;a&&(a=!1,clearTimeout(o),r(l))}catch(e){a&&(a=!1,n(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const s=t-Date.now();if(s<=0)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(s)+")");return u(e,s,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const s=await l(e,t,r);return s===a.Timeout?(0,n.tot)(i):s}},42279:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),s=i(22573),n=i(54993);function a(e){return"URLSearchParams"===e?.constructor?.name}function o(e){return null==e?void 0:a(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(o)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=a,t.toURLSearchParams=o,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,n.toS)(l(...t));return e+((0,s.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,n.toS)(l(...t));return(0,s.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),s=i(30301),n=i(31586),a=i(46891),o=i(50989),l=i(51926),u=(0,s.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,n.isNumber)(r)&&(i+=r/t.MB);return(0,n.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,n.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,n.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),s=Math.pow(10,3*r),a=d[r];return(0,n.sigFigs)(e/s,t)+" "+a}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),s=Math.pow(2,10*r),a=h[r];return(0,n.sigFigs)(e/s,t)+" "+a},t.MP=1e6,t.megapixels=function(e){return(0,n.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,o.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,a.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,a.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},22403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ua=void 0;const r=i(30301),s=i(54993);t.ua=(0,r.lazy)((()=>(0,s.toS)(globalThis?.navigator?.userAgent)))},2322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,r=/\bSafari\b/,s=/\bFirefox\b/,n=/\biPad\b/,a=/\biPhone\b/;function o(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return o(e,i)}function u(e){return o(e,s)}t.isChrome=l,t.isSafari=function(e){return o(e,r)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return o(e,n)},t.isIphone=function(e){return o(e,a)}},58939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.idEql=t.id2id=void 0;const r=i(55835),s=i(31586);function n(e){const t=e;return(0,s.isNumber)(e)?e:(0,s.isNumber)(t.id)?t.id:(0,s.isNumber)(t.assetId)?t.assetId:(0,s.isNumber)(t.tagId)?t.tagId:void 0}t.id2id=n,t.idEql=function(e,t){return(0,r.map2Or)(n(e),n(t),((e,t)=>e===t),(()=>!1))}},79114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.S=void 0;const r=i(50989);t.S=(0,r.strEnum)("plus","lite")},75020:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInfoTag=t.NotInfoPanelTags=t.LibraryTagName=t.TagRoots=t.isTagRef=t.ctxToS=t.TagGalleryProps=t.nextChildTagsUrl=t.nextAssetsUrl=t.BeforeAfterStreamLimit=t.ThumbsPerSample=void 0;const r=i(76790),s=i(22573),n=i(98553),a=i(31586),o=i(50989),l=i(51926),u=i(29652);t.ThumbsPerSample=128,t.BeforeAfterStreamLimit=8,t.nextAssetsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/assets`,i)},t.nextChildTagsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.seed,(e=>i.seed=e.toString())),(0,a.mapNumeric)(t.limit,(e=>i.limit=e.toString())),(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/child-tags`,i)},t.TagGalleryProps=["tagId","tagPath","assetCount","assetIds","nextAssets","childTags","nextChildTags"],t.ctxToS=function(e){return(0,n.stringify)({seed:e.seed,tagIds:(0,r.sort)([...e.tagIds])})},t.isTagRef=function(e){return null!=e&&!(0,l.isString)(e)&&(0,s.notBlank)(e.name)},t.TagRoots=(0,o.strEnum)("When","Who","Where","What","Camera","Lens","Albums","Keywords","Type","fs"),t.LibraryTagName="Library",t.NotInfoPanelTags=[t.TagRoots.When,t.TagRoots.Camera,t.TagRoots.Lens,t.TagRoots.Type,t.TagRoots.fs],t.isInfoTag=function(e){if(null==e)return!1;const i=(0,l.isString)(e)?e:e.tagPath?.[0];return!t.NotInfoPanelTags.includes(i)}},27776:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkTagUri=t.mkTagFullPath=t.mkHomeFullPath=t.urlSeed=void 0;const r=i(40958),s=i(30301),n=i(31586),a=i(97238),o=i(29652);function l(e,i){const r=(0,o.toURLSearchParams)(e);if(i||!(0,n.isDigits)(r?.get("seed"))){const e=(0,t.urlSeed)().toString();return r?.set("seed",e),r??{seed:e}}return r}function u(e,t,i=!1){const r=c(e,t,i);return(0,o.assembleFullPath)(r.path,r.query)}function c(e,t,i=!1){return{path:"/tag/"+((0,r.isEmpty)(e)?"":e.map(encodeURIComponent).join("/")),query:l(t,i)}}t.urlSeed=(0,s.lazy)(a.prngSeed,100),t.mkHomeFullPath=function(e){return u([],e,!0)},t.mkTagFullPath=u,t.mkTagUri=c},23541:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),s=i(51926);function n(e){return Array.isArray(e)?e:null==e?void 0:(0,s.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return n(e)??[]},t.optToA=n},41583:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),s=i(23541),n=i(59455),a=i(54993);function o(e){return null==e?void 0:(0,s.isError)(e)?e:new Error((0,a.toS)(e))}t.toErr=o,t.toErrs=function(...e){return(0,r.compact)((0,n.toA)(e).map(o))}},54993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return n(e,",")};const s={}.toString;function n(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>n(e,t))).join(t):e.toString!==s?e.toString():(0,r.stringify)(e)}}t.toStr=n},64526:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Library=void 0;const l=i(27395),u=i(25764),c=i(38836),d=i(99331),h=i(45608),f=i(15056),m=i(87290),p=i(38835),g=i(57159),y=i(61704),w=i(95696),v=i(18454),b=i(13940),S=i(48604),P=i(19851),_=i(23560),T=i(28874),M=i(2858),E=i(7014),D=i(63870),x=i(15674),k=i(22573),F=i(38639),C=i(42659),A=i(56409),I=i(68708),O=i(25470),L=i(22526),R=i(41844);class N extends c.EndableWrapper{static instance(){const e=T.Settings.libraryDir.valueOrDefault,t=a(this,r,"f",s)?.rootDir.nativePath,i=!0===a(this,r,"f",s)?.isReadySync(),n=!0===a(this,r,"f",s)?.ended;return(0,y.nativePathsEqlSync)(t,e)&&!n?a(this,r,"f",s):(0,_.isSyncService)()&&i?void(0,h.exit)({reason:`Library changed mid-run. Shutting down to pick up new library at ${e}.`,status:0}):((0,l.end)(a(this,r,"f",s)),o(this,r,(0,k.blank)(e)||!(0,M._libraryHasSettings)(e)?void 0:new r(e),"f",s))}static get priorInstance(){return a(this,r,"f",s)}static endPriorInstance(){const e=a(this,r,"f",s);return o(this,r,void 0,"f",s),(0,l.end)(e)}static async instanceReady(){const e=r.instance();return await(e?.ready),e}static instanceRequired_(){const e=r.instance();if(null==e)throw new Error("Library is undefined"+p.FatalErrorFlag);return e}constructor(e){super(`library.Library(${e})`,(()=>this.onEnd()),u.EndableRanks.predb),this.start=Date.now(),this.readyLatch=new A.Latch,n.set(this,(0,P.lazy)((async()=>{try{this.logger.debug("setup() started"),this.logger.throwIfAborted_(),await(0,M.readLibrarySettings)(this.rootDir.nativePath),await(0,m.setupLibraryDirs_)(this.rootDir),await(0,b.imageCacheDir_)(),this.logger.throwIfAborted_();const e=await(0,E.bestVolumeForPath)((0,m.libraryPreviewsDirPosixFile)(this.rootDir));if((0,F.isTrue)(e?.remote)){const e=T.Settings.maxConcurrentImportsWhenRemote.valueOrDefault;T.Settings.maxConcurrentImports.hasValue()||(T.Settings.maxConcurrentImports.tmpValue=e,(0,x.clearMaxWorkCaches)()),this.logger.warn(`Library previews are on a remote volume. Setting maxSyncFileJobsMax to ${e}.`)}this.logger.throwIfAborted_(),(0,_.isDbService)()&&await this.dbModelJanitor(),this.previews(),this.logger.throwIfAborted_(),this.readyLatch.isPending()&&(this.logger.info("Library.setup() finished."),this.readyLatch.resolve())}catch(e){this.ended||(0,d.ending)()||(this.logger.warn("setup() failed:",{error:e}),v.HealthCheck.addError(e),this.readyLatch.reject(new g.WrappedError("Failed to start library",{cause:e})))}}))),this.previews=(0,P.lazy)((()=>(0,I.tap)(new S.Previews((0,m.libraryPreviewsDirPosixFile)(this.rootDir)),(e=>S.Previews.instance.set(e))))),this.originalsDir=(0,P.lazy)((()=>(0,m.libraryOriginalsDirPosixFile)(this.rootDir))),this.assetFileRepository=(0,P.lazy)((()=>new R.AssetFileRepository(this.originalsDir()))),this.libraryDbFile=(0,P.lazy)((()=>(0,f.pathToDb)(this.dataDir,"models"))),this.dbModelSetup_=(0,P.lazy)((async()=>{if((0,_.isDbService)())return(0,L.dbModelSetup_)(this.rootDir);throw new Error("Not a db service")})),this.dbFsLock=(0,P.lazy)((async()=>(await this.dbModelSetup_()).fslock)),this.useReplica=(0,P.lazy)((async()=>(await this.dbModelSetup_()).useReplica)),this.modelDb=(0,P.lazy)((async()=>(await this.dbModelSetup_()).db)),this.dbModelJanitor=(0,P.lazy)((async()=>O.DbModelJanitor.for(await this.dbModelSetup_()))),this.onEnd=(0,P.lazy)((async()=>{if(!(0,d.ending)())for(const{ea:e,t}of[{ea:this.dbModelJanitor.clear(),t:5*C.minuteMs},{ea:this.dbFsLock.clear(),t:(0,D.commandTimeoutMs)()}])await(0,l.end)(e,t);this.logger.info("onEnd(): finished.")})),this.rootDir=w.PosixFile.for(e),this.dataDir=(0,m.libraryDataDirPosixFile)(this.rootDir),this.logger.info("new()"),a(this,n,"f").call(this)}get isPendingSetup(){return this.readyLatch.isPending()}get ready(){return this.readyLatch.promise.then((()=>this))}isReadySync(){return this.readyLatch.isResolved()}async runDbBackup_(){return(await this.dbModelJanitor())?.backup_()}}t.Library=N,r=N,n=new WeakMap,s={value:void 0}},19113:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFileFiltersFor=void 0;const r=i(62105),s=i(181),n=i(94448),a=i(39604);t.libraryFileFiltersFor=function(e,{validateFile:t=!1}={}){const i=(0,r.expensiveFileFiltersFor)(e);return null!=(0,n.modelDb)()&&i.push({notBlocklistedSha:a.notBlocklistedSha}),t&&i.push({isValidFile:s.isValidFile}),i}},18449:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sentryEnabled=void 0;const r=i(7282),s=i(96706),n=i(29325),a=i(28874);t.sentryEnabled=function(){return(0,s.isEnvTrue)("ENABLE_SENTRY")||(0,r.isProd)()&&(0,n.isPacked)()&&!0===a.Settings.reportErrors.value}},95629:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelToSeverity=t.logEntryToBreadcrumb=t.mkBreadcrumbs=t.annotateEvent=t.sentryExceptionToS=t.sentryExceptionsToS=t.extractMessage=t.EventFilter=t.eventFilter=t.sendToSentry=t.installSentry=void 0;const o=n(i(16436)),l=a(i(48161)),u=a(i(1708)),c=i(19851),d=i(19043),h=i(50213),f=i(31578),m=i(7282),p=i(96175),g=i(23560),y=i(84968),w=i(81168),v=i(37805),b=i(25764),S=i(38836),P=i(99331),_=i(85100),T=i(98314),M=i(68301),E=i(70025),D=i(8769),x=i(34102),k=i(34592),F=i(42042),C=i(34474),A=i(20839),I=i(57902),O=i(45969),L=i(43334),R=i(40958),N=i(22573),B=i(42659),j=i(41400),z=i(98553),V=i(55835),W=i(12168),U=i(59455),q=i(54993),H=i(18449),$=(0,c.lazy)((()=>(0,h.mkLogger)("Sentry")));function G(e){(0,H.sentryEnabled)()&&null!=e&&!0!==(0,E.isDoNotSendError)(e)&&o.captureException(e)}t.installSentry=async function(e){try{return!!(0,H.sentryEnabled)()&&(o.init({dsn:L.isElectron?"https://0652cdd351054fe9853ff944b1f54e2c@o130922.ingest.sentry.io/289071":"https://5f52aefec1b3439eaed2e77b2d1210a8@o130922.ingest.sentry.io/1828379",shutdownTimeout:(0,_.serviceExitTimeoutMs)(e.name),release:v.release,environment:(0,m.nodeEnv)(),maxBreadcrumbs:100,integrations:[],beforeSend:(0,t.eventFilter)().beforeSend,onFatalError:e=>(0,D.onError)("sentry.onFatalError",e)}),$().info("Sentry initialized",{isElectron:L.isElectron}),!0)}catch(e){return $().warn("Failed to set up sentry",{error:e}),!1}},t.sendToSentry=G,t.eventFilter=(0,c.lazy)((()=>new J));class J{constructor(){this.beforeSend=async(e,t)=>{if(!(0,H.sentryEnabled)())return $().warn("Sentry.beforeSend(): not sending event",e),null;if(!0===await(M.ErrorStore.instance()?.eventQuotaExceeded(e)))return $().warn("Sentry.beforeSend(): event quota exceeded",e),null;const i=K(e,t);if(!0===(0,E.isDoNotSendError)(i))return $().info("Sentry.beforeSend(): event not sendable. vetoing",{event:e,hint:t,msg:i}),null;(0,N.blank)(e.message)&&(e.message=(0,w.ellipsize)(i,256));const r=await X(e);return await(M.ErrorStore.instance()?.maybeSendEvent(r))??null},(0,x.ee)().on("fatal",G),(0,x.ee)().on("nonFatal",G),new S.EndableWrapper("EventFilter",(()=>this.end()),b.EndableRanks.first)}end(){return(0,V.map)(o.getCurrentHub().getClient(),(e=>e.close(5*B.secondMs)))}}function K(e,t){return(0,R.uniq)((0,R.compactBlankish)([e.message,...(0,U.toA)(Y(e.exception?.values)),(0,T.errorToS)(t?.originalException)])).join(": ")}function Y(e){return(0,R.mapNotEmpty)(e,(e=>(0,R.compactBlanks)(e.map(Z))))}function Z(e){return(0,R.mapNotEmpty)((0,R.compactBlanks)([e?.type,e?.value].filter((e=>"error"!==(0,q.toS)(e).toLowerCase()))),(e=>e.join(": ")))}async function X(e){const t=await(0,F.getEmail)();(0,N.notBlank)(t)&&(null==e.user&&(e.user={}),e.user.email=t),(0,R.isEmpty)(e.breadcrumbs)&&(e.breadcrumbs=await Q());const i=e.extra??{};return i.pid=u.default.pid,i.serviceName=(0,g.serviceName)(),i.serviceEnding=(0,P.ending)(),i.runtimeMs=(0,y.runtimeMs)(),i.version=v.version,i.os=(0,p.osFullName)(),i.isDocker=(0,O.isDocker)(),i.nodeVersion=u.default.versions.node,i.locale=await(0,d.locale)(),i.cpus=(0,p.CPUs)(),i.memoryUsageMb=(0,f.memoryUsageMb)(),i.memoryUsageRssMb=(0,f.memoryUsageRssMb)(),i.systemMemory=(0,W.fmtBytes)(l.default.freemem())+" / "+(0,W.fmtBytes)(l.default.totalmem()),i.ffmpeg=await(0,k.ffmpegVersionDescription)(),i.argv=(0,z.stringify)(u.default.argv),e.extra=i,{timestamp:Date.now()/B.secondMs,...e}}async function Q(){await(0,j.delay)(3*A.DefaultLogFlushMs);const e=await(0,C.allRecentLogEntries)();return(0,R.compact)(e.map(ee))}function ee(e){return(0,V.map)(ie(e.l),(t=>({timestamp:e.ts/B.secondMs,level:t,category:e.from??(0,g.processName)(),message:(0,w.stripAnsiEsc)(e.ctx+": "+e.msg),data:"object"==typeof e.meta?e.meta:{value:(0,w.isString)(e.meta)?(0,w.stripAnsiEsc)(e.meta):e.meta}})))}t.EventFilter=J,t.extractMessage=K,t.sentryExceptionsToS=Y,t.sentryExceptionToS=Z,t.annotateEvent=X,t.mkBreadcrumbs=Q,t.logEntryToBreadcrumb=ee;const te=new Map([[I.LogLevels.fatal,"fatal"],[I.LogLevels.error,"error"],[I.LogLevels.warn,"warning"],[I.LogLevels.info,"info"],[I.LogLevels.debug,"debug"]]);function ie(e){return te.get(e)}t.logLevelToSeverity=ie},37158:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Service=t.setupEventHandlers=void 0;const p=m(i(29907)),g=m(i(1708)),y=i(57206),w=i(19851),v=i(50213),b=i(59880),S=i(23560),P=i(19913),_=i(71567),T=i(37805),M=i(38836),E=i(99331),D=i(45608),x=i(56038),k=i(55534),F=i(42499),C=i(49776),A=i(96706),I=i(98314),O=i(38835),L=i(70025),R=i(8769),N=i(57159),B=i(34102),j=i(33456),z=i(87408),V=i(85021),W=i(17181),U=i(86941),q=i(28874),H=i(41692),$=i(2858),G=i(69385),J=i(22573),K=i(42659),Y=i(41400),Z=i(56409),X=i(55835),Q=i(41583),ee=i(54993),te=i(95629);t.setupEventHandlers=(0,w.lazy)((()=>{(0,B.ee)().on("resume",(()=>(0,G.resume)())),(0,B.ee)().on("pause",(()=>(0,G.pause)()))}));class ie extends M.EndableWrapper{constructor(e){super(e),r.add(this),s.set(this,void 0),n.set(this,new Z.Latch),a.set(this,new Map),this.setup_=(0,w.lazy)((()=>(0,x.time)("Service.setup",(()=>f(this,r,"m",o).call(this))))),u.set(this,(0,w.lazy)((()=>{const e=g.default.stdin.pipe(new j.LineReader);return e.on("data",(e=>f(this,r,"m",d).call(this,(0,ee.toS)(e)))),e}))),(0,S.isBillingService)()||(0,H.setSettingsDefaults)(),h(this,s,(0,v.mkLogger)("Service("+this.name+")"),"f"),f(this,r,"m",c).call(this),this.setup_()}get name(){return super.name}get ready(){return f(this,n,"f").promise}get isReady(){return f(this,n,"f").isResolved()}setInputHandler(e,t){f(this,a,"f").set(e.trim().toLowerCase(),t)}}t.Service=ie,s=new WeakMap,n=new WeakMap,a=new WeakMap,u=new WeakMap,r=new WeakSet,o=async function(){try{(0,J.mapNotBlank)((0,A.getEnv)("PS_FATAL_"+this.name),(e=>{throw new N.WrappedError(e,{fatal:!0})})),(0,J.mapNotBlank)((0,A.getEnv)("PS_CRASH_"+this.name),(e=>{(0,Y.later)((()=>{throw new N.WrappedError(e)}),5*K.secondMs)})),(0,P.setServiceName)(this.name),(0,b.setProcessTitle)(),(0,S.isMainService)()&&await(0,U.mergeUserDataDirs_)(),await(0,$.readSettings)(),await f(this,r,"m",l).call(this),(0,W.setupLogger)(),(0,y.addDefaultJsonRevivers)(),(0,C.cacheDir)(),(0,t.setupEventHandlers)(),f(this,u,"f").call(this),await(0,F.setupLuxon)(),q.Settings.startPaused.valueOrDefault&&(0,G.pause)(),(0,E.ending)()?f(this,n,"f").reject():f(this,n,"f").resolve()}catch(e){console.error((0,I.errorToS)(e)),f(this,n,"f").reject((0,Q.toErr)(e)),(0,D.exit)({reason:(0,L.addErrorFlags)(this.name+" setup failed: "+(0,I.errorToS)(e),O.FatalErrorFlag),status:14})}},l=async function(){(0,S.isPermaService)()||(0,B.ee)().on("fatal",(e=>(0,D.exit)({error:e,status:12}))),g.default.on("unhandledRejection",(e=>(0,X.map)(e,(e=>(0,R.onError)("unhandledRejection",e))))),g.default.on("uncaughtException",(e=>(0,X.map)(e,(e=>(0,R.onError)("uncaughtException",e))))),g.default.on("SIGINT",(()=>(0,D.exit)({reason:"SIGINT",status:0}))),g.default.on("SIGHUP",(()=>(0,D.exit)({reason:"SIGHUP",status:0}))),g.default.on("SIGTERM",(()=>(0,D.exit)({reason:"SIGTERM",status:0}))),p.default.isWorker&&g.default.on("disconnect",(()=>(0,D.exit)({reason:"disconnect",status:0}))),await(0,te.installSentry)(this)},c=function(){this.setInputHandler("--version",(()=>(0,_.stdoutWrite)({version:T.version}))),this.setInputHandler(k.ServiceExitCommand,(()=>(0,Y.later)((()=>(0,D.exit)({reason:k.ServiceExitCommand+" from stdin",status:0}))))),this.setInputHandler("--times",(()=>(0,_.stdoutWrite)(x.PromiseTimer.instance().report()))),this.setInputHandler(V.HealthCheckCommand,(async()=>(0,_.stdoutWrite)(await(0,z.getStatusSummary)({refresh:!0}))))},d=async function(e){if(f(this,s,"f").debug("onLine()",{line:e,ending:this.ended||(0,E.ending)()}),await this.setup_(),e.startsWith("--")){const t=e.split(/\s+/,1)[0],i=f(this,a,"f").get(t);null==i?(f(this,s,"f").error("onLine(): unknown command",{line:e,knownCommands:[...f(this,a,"f").keys()]}),console.warn("unknown command "+e)):await i(e.slice(t.length).trim())}else f(this,s,"f").error("onLine(): failed to process",{line:e})}},31503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogArgs=void 0;const r=i(23560),s=i(83210),n=i(28874),a=i(38639);function o(){return(0,r.isMainService)()||(0,r.isSyncService)()}t.LogArgs={beforeParse:e=>{const t=(o()?', "PS_TAIL_LOGS=true"':"")+' and "PS_LOG_STDOUT=true".';return o()?e.option("-v, --verbose",'Verbose logging from all processes. Shortcut for "--info --tail". Caution: noisy during imports!'):e.option("-v, --verbose","Verbose logging. Equivalent to --info."),e.option("--error",`Emit "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=error"${t}`),e.option("--warn",`Emit "warn" and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=warn"${t}`),e.option("--info",`Emit "info", "warn", and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=info"${t}`),e.option("--debug",`Emit "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY NOISY. Sets "PS_LOG_LEVEL=debug"${t}}`),e.option("--trace",`Emit "trace", "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY VERY NOISY. Sets "PS_LOG_LEVEL=trace"${t}}`),o()&&e.option("--tail",'Emit log messages from both this process and all other concurrently running PhotoStructure processes on this host to stdout. This can be really helpful in seeing how PhotoStructure\'s processes are coordinating work. Caution: very noisy especially during imports. Sets "PS_TAIL_LOGS=true".'),e},afterParse:e=>{const t=(0,a.isTrue)(e.error),i=(0,a.isTrue)(e.warn),r=(0,a.isTrue)(e.info)||(0,a.isTrue)(e.verbose)||(0,a.isTrue)(e.v),l=(0,a.isTrue)(e.debug),u=(0,a.isTrue)(e.trace);u?n.Settings.logLevel.envValue="trace":l?n.Settings.logLevel.envValue="debug":r?n.Settings.logLevel.envValue="info":i?n.Settings.logLevel.envValue="warn":t&&(n.Settings.logLevel.envValue="error"),(0,s.isDaemon)(e)?(n.Settings.tailLogs.envValue=!1,n.Settings.logStdout.envValue=!1):((0,a.isTrue)(e.tail)&&(n.Settings.tailLogs.envValue=!0),(t||i||r||l||u)&&(n.Settings.logStdout.tmpValue=!0,o()&&(n.Settings.tailLogs.tmpValue=!0)),(n.Settings.tailLogs.valueOrDefault||n.Settings.logStdout.valueOrDefault)&&n.Settings.logLevel.isUnset()&&(n.Settings.logLevel.envValue="info"))}}},46628:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.albumsFromTags=t.tagFilesWithAlbums=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(81168),o=i(74417),l=i(28874),u=i(47783),c=i(97573),d=i(42231),h=i(40958),f=i(22573),m=i(68708),p=i(75020),g=i(54993),y=(0,s.lazy)((()=>(0,n.mkLogger)("curators.AlbumTagger")));function w(e){return(0,f.blank)(e)?void 0:l.Settings.tagAlbumTitleHierarchies.valueOrDefault?(0,c.keywordToPath)(e):[e]}function v(e){if(null==e)return[];const t=(0,h.uniq)((0,r.flatMap)(l.Settings.tagAlbumTitle.values,(t=>(0,m.pluckDeep)(e,t)?.value))),i=(0,h.compact)(t.map(w));if((0,h.isEmpty)(i))return[];if(i.length>1)return y().tap({level:"info",msg:"albumFromFile()",result:i.map((e=>[p.TagRoots.Albums,...e]))});const s=i[0],n=(0,r.first)(l.Settings.tagAlbumDescription.values,(t=>(0,m.pluckDeep)(e,t)?.value)),u=(0,h.isEmpty)(s)?"(blank title)":(0,a.firstSubstringIgnoreCase)(l.Settings.tagAlbumsExcluded.values,[...s,(0,g.toS)(n)].join(" ")),c=null==u?[p.TagRoots.Albums,...s]:void 0;if(null!=c){const t={name:c[c.length-1],description:n};for(const i of l.Settings.tagAlbumDate.values){const r=(0,o.parseJsonDateToMillis)((0,m.pluckDeep)(e,i)?.value);if(null!=r){t.releasedAt=r;break}}c[c.length-1]=t}return y().tap({level:"info",msg:"albumFromFile()",result:(0,h.compact)([c]),meta:{titles:i,desc:n,whyExclude:u}})}t.tagFilesWithAlbums=async function(e){const t=[];for(const i of e){t.push(...v(await(0,u.readTags)(i)));for(const e of l.Settings.tagAlbumFilenames.values)t.push(...v(await(0,u.readRawTags)(i.sibling(e),!1)))}return y().tap({msg:"tagFilesWithAlbums()",result:(0,d.uniqTagPaths)(t),meta:{files:e}})},t.albumsFromTags=v},88224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagAsset=t.tagAndUpsertAsset_=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(28874),o=i(42231),l=i(40958),u=i(20214),c=i(43487),d=i(46628),h=i(63175),f=i(4407),m=i(58886),p=i(32646),g=i(48144),y=i(60047),w=i(6186),v=i(42003),b=i(43723),S=(0,r.lazy)((()=>(0,s.mkLogger)("curators.AssetTagger")));async function P({primaryVariation:e,files:t,priorTagPaths:i,capturedAts:r,uris:s}){const u=[];if(t=(0,l.uniqBy)([e,...t],(e=>e.nativePath)),a.Settings.tagCamera.valueOrDefault&&await(0,n.thenMap)((0,h.cameraTagFile)(e),(t=>{S().debug("Camera tag for "+e+":",t),u.push(t)})),a.Settings.tagLens.valueOrDefault&&await(0,n.thenMap)((0,y.lensTagFile)(e),(t=>{S().debug("Lens tag for "+e+":",t),u.push(t)})),a.Settings.tagGeo.valueOrDefault)for(const e of t){const t=await(0,p.geoTagFile)(e);if(null!=t){u.push(t);break}}await(0,n.thenMap)((0,f.dateTagFile)(e,r),(t=>{S().debug("Date tag for "+e+":",t),u.push(t)}));const c=await(0,b.whoTagFiles)(t)??[];S().debug("whoTagFiles for "+e+":",c),u.push(...c),await(0,n.thenMap)((0,g.keywordTagFiles)(t,c),(t=>{S().debug("Keyword tags for "+e+":",t),u.push(...t)})),a.Settings.tagFileType.valueOrDefault&&await(0,n.thenMap)((0,v.typeTagFiles)(t),(t=>{S().debug("MIME type tags for "+e+":",t),u.push(...t)})),await(0,n.thenMap)((0,m.tagAssetPaths)(s),(e=>{S().debug("file paths for uris",{uris:s,arr:e}),u.push(...e)})),await(0,n.thenMap)((0,d.tagFilesWithAlbums)(t),(t=>{S().debug("Album tags for "+e+":",t),u.push(...t)}));const P=(0,o.omitAncestorTags)((0,l.uniqBy)(u.map(w.normalizeTagRoot),o.joinTagPath)),_=await(0,w.tagDeltas)(i,P);return S().info("tagAsset("+e+")",{priorTagPaths:i,after:P,result:_}),_}t.tagAndUpsertAsset_=async function(e){const t=await e.getExistingAssetFiles();S().info("tagAndUpsertAsset()",{asset:e,existing_uris:t.map((e=>e.uri))});const i=t.find((e=>e.shown)),r=await(i?.posixFile_());if(null==i||null==r)return void S().throw("tagAndUpsertAsset(): no existing or primary asset file",{asset:e,existingPrimaryAssetFile:i,primaryVariant:r,doNotSend:!0,fatal:!1});const s=e.getShown();s?.id!==i.id&&(S().warn("Changing primary asset we're using a different variant for tagging.",{newPrimary:i.uri,priorPrimary:s?.uri}),e.setShown_(i));const n=await(0,u.thenCollect)(t,(e=>e.posixFile_())),l=e.getAssetFiles().map((e=>e.uri)),d=e.getTagPaths(),h=await e.getCapturedAts(),f=await P({primaryVariation:r,files:n,priorTagPaths:d,capturedAts:h,uris:l});S().info("tagAndUpsertAsset",f);const m=f.add.find((e=>(0,o.leafIsExcluded)(e,a.Settings.keywordBlocklist.values)));if(null!=m){if(!0!==e.shown)return S().info("this asset has an excluded tag, and it wasn't shown yet, so we're removing it.",{excludedTag:m}),await c.Asset.remove({assetId:e.id,blocklistShas:!1,unlinkAssetFiles:!1}),S().throw("tagAndUpsertAsset(): asset had excluded tag. Removed.",{excludedTag:m,uris:l,files:n.map((e=>e.nativePath))});S().info("this asset has an excluded tag, marking excluded",{excludedTag:m}),e.excludedAt=Date.now()}return e.applyTagPathDeltas(f),await e.updateFromFiles(),f},t.tagAsset=P},63175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cameraTagFile=t.cameraTag=void 0;const r=i(47783),s=i(75020),n=i(40958),a=i(22573);function o(e){return null==e||(0,a.blank)(e.Make)?void 0:(0,n.compactBlankish)([s.TagRoots.Camera,e.Make,e.Model])}t.cameraTag=o,t.cameraTagFile=async function(e){return o(await(0,r.readTags)(e))}},4407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateTagFile=t.dateTag=t.dayTagRef=t.monthTagRef=t.yearTagRef=t.dayToOrdinal=t.ordinalToMonth=t.monthToOrdinal=t.yearToOrdinal=void 0;const r=i(19851),s=i(19043),n=i(97352),a=i(81168),o=i(928),l=i(34102),u=i(28874),c=i(28544),d=i(47783),h=i(40958),f=i(55835),m=i(31586),p=i(75020),g=i(54993),y=(0,r.lazy)((()=>new Intl.DateTimeFormat((0,s.localeSync)(),{month:"short"}))),w=(0,r.lazy)((()=>{const e=y();return(0,h.range)(0,12,(t=>e.format(new Date(2016,t,1)))).map((e=>(0,a.stripSuffix)(e,".")))}));function v(e){return 1e4-e}function b(e){return 13-e}function S(e){return 33-e}function P(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:v(e)})))}function _(e){if((0,m.within)(1,12,e))return(0,f.map)(w()[e-1],(t=>({name:String(e),displayName:t,ordinal:b(e)})))}function T(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:S(e)})))}function M(e){const t=(0,g.toS)(u.Settings.tagYMD.valueOrDefault).toLowerCase();if(null==e||""===t||"off"===t||t.startsWith("disable"))return;const i=[p.TagRoots.When];if(t.startsWith("y")){const t=(0,f.map)((0,o.getYear)(e),P);if(null==t)return;i.push(t)}if(t.startsWith("ym")){const t=(0,f.map)((0,o.getMonth)(e),_);if(null==t)return i;i.push(t)}if(t.startsWith("ymd")){const t=(0,f.map)((0,o.getDay)(e),T);if(null==t)return i;i.push(t)}return i}(0,l.ee)().on("clearCache",(()=>{y.unset(),w.unset()})),t.yearToOrdinal=v,t.monthToOrdinal=b,t.ordinalToMonth=function(e){return 13-e},t.dayToOrdinal=S,t.yearTagRef=P,t.monthTagRef=_,t.dayTagRef=T,t.dateTag=M,t.dateTagFile=async function(e,t){if(""===u.Settings.tagYMD.valueOrDefault)return;const i=[...t];(0,h.isEmpty)(t)&&i.push((await(0,d.readTags)(e))?.capturedAt);const r=(0,c.bestCapturedAt)(i);return null==r||(0,c.capturedAtSrcFromStat)(r.src)&&!u.Settings.tagDateFromStat.valueOrDefault?void 0:M(r.date)}},58886:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addFileUriTagsToAsset=t.addFilesTagsToAsset=t.isFsTag=t.tagAssetPaths=void 0;const r=i(19851),s=i(50213),n=i(42231),a=i(21404),o=i(40958),l=i(89937),u=i(75020),c=i(54017),d=i(94448),h=i(69032),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.FilePathTagger")));function m(e,t){return e.applyTagPathDeltas({add:(0,o.compact)(t.map((e=>(0,a.uriToTagPath)({uri:e,isFile:!0}))))})}t.tagAssetPaths=async function(e){const t=[];for(const i of e)try{const e=(0,a.uriToTagPath)({uri:i,isFile:!0});if(null==e)continue;if(i.startsWith(l.PS_LOCAL_FILE_SCHEME)&&null!=(0,d.modelDb)()){const t=(0,n.tagRefToS)(e[1]);e[1]={name:t,displayName:await(0,h.displayNameForVolsha)(t)},f().info("tagAssetPaths()",{uri:i,tp:e})}t.push(e)}catch(e){f().warn("Failed to parse asset file URI",{uri:i})}return t},t.isFsTag=function(e){return(0,n.tagRefToS)(e[0]).toLowerCase()===u.TagRoots.fs},t.addFilesTagsToAsset=function(e){const t=c.AssetFile.dbl.pluckAllf((t=>t.select("uri").where({asset:e})));return m(e,t)},t.addFileUriTagsToAsset=m},32646:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.geoTagFile=t.geoTag=void 0;const r=i(48884),s=i(56519),n=i(28874),a=i(47783),o=i(75020),l=i(40958);function u(e){const t=(0,r.compactRight)(n.Settings.tagGeoTemplate.valueOrDefault.map((t=>e?.[t])));return 0===t.length||t.some((e=>null==e))?void 0:(0,l.compact)([o.TagRoots.Where,...t])}t.geoTag=u,t.geoTagFile=function(e){return(0,s.thenMap)((0,a.readTags)(e),u)}},48144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.keywordTagFiles=t.processKeywords=t.dedupeKeywordPaths=t.normalizeKeywordPaths=t.extractPathnameTags=t.extractDashDashTags=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(68852),o=i(81168),l=i(96859),u=i(56519),c=i(28874),d=i(47783),h=i(97573),f=i(42231),m=i(40958),p=i(76790),g=i(22573),y=i(41400),w=i(96249),v=i(55835),b=i(75020),S=i(54993),P=i(6186),_=i(43723),T=(0,s.lazy)((()=>(0,n.mkLogger)("curators.KeywordTagger"))),M=(0,s.lazy)((()=>(0,g.mapNotBlank)(c.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[ /${(0,a.escapeRegExp)(e)}]`)))));function E(e){return T().tap({msg:"extractDashDashTags()",result:(0,v.mapOr)((0,S.toS)(e).split("--")[1],(e=>(0,m.compactBlanks)((0,v.mapOr)(M(),(t=>e.split(t)),[e]))),(()=>[])),meta:{s:e}})}function D(e){return[...E(e.parent().posixPath),...E(e.name)]}(0,y.later)((()=>{c.Settings.keywordDelimiters.watchLater((()=>M.unset()))})),t.extractDashDashTags=E,t.extractPathnameTags=D;const x=/\w{2,7}:\/\/\S+/g;function k(e){const t=[],i=[],s=[];for(const t of(0,m.compact)(e))if(Array.isArray(t))s.push(t);else{const e=(0,S.toS)(t).replace(x,(e=>(i.push(e),"")));s.push(...(0,v.mapOr)((0,h.delimRe)(),(t=>e.split(t)),[e]))}const n=s.map((e=>(0,o.isString)(e)?(0,h.keywordToPath)(e):e)).map((e=>Array.isArray(e)&&1===e.length?e[0]:e)),[a,l]=(0,r.partition)(n,Array.isArray),u=a.map((e=>(0,m.compactBlanks)(e.map((e=>e.trim()))))).filter(m.isNotEmpty),d=(0,o.uniqIgnoreCase)((0,w.flatten)(u));t.push(...u);const f=[...l,...i].map((e=>e.trim())).filter((e=>(0,g.notBlank)(e)&&!(0,o.includesIgnoreCase)(d,e))),p="copy"===c.Settings.keywordReparenting.valueOrDefault,y="retain"===c.Settings.keywordReparenting.valueOrDefault,P=c.Settings.rootTagKeywordsAliases.values;for(const e of[...t])(0,o.includesIgnoreCase)(P,e[0])&&(e[0]=b.TagRoots.Keywords),e[0]!==b.TagRoots.Keywords&&(p?t.push([b.TagRoots.Keywords,...e]):y&&e.unshift(b.TagRoots.Keywords));for(const e of f)t.push([b.TagRoots.Keywords,e]);return(0,m.uniq)(t)}function F(e){return(0,m.uniqBy2)((0,p.sortBy)(e.map(P.normalizeTagRoot),(e=>{const t=(0,f.joinTagPath)(e);return[t.normalize().toLowerCase(),-1*(0,l.lcdiff)(t)]})),((e,t)=>(0,o.equalsIgnoreCase)((0,f.joinTagPath)(e),(0,f.joinTagPath)(t))))}function C(e,t){const[i,s]=(0,r.partition)(k(e),_.isWhoTag),n=(0,w.flatten)(i.map(_.nameTag)),a=(0,m.uniq)((0,w.flatten)([...n,...t].map((e=>{const t=(0,P.stripTagRoot)(e);return[t.join(", "),t.join(" "),[...t].reverse().join(" ")]})))),l=F([...s.filter((e=>!(0,o.includesIgnoreCase)(a,(0,P.stripTagRoot)(e).join(" ")))),...n]);return T().tap({msg:"processKeywords()",level:"info",result:l})}t.normalizeKeywordPaths=k,t.dedupeKeywordPaths=F,t.processKeywords=C,t.keywordTagFiles=async function(e,t){return C([...c.Settings.tagKeywordsFromPath.valueOrDefault?(0,w.flatten)(e.map(D)):[],...c.Settings.tagKeywordsFromMetadata.valueOrDefault?(0,w.flatten)(await(0,u.mapAsyncSerial)({name:"keywordTagFiles",arr:e,f:e=>(0,u.thenMap)((0,d.readRawTags)(e),h.rawTagKeywords)})):[]],t)}},60047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lensTagFile=t.lensTag=void 0;const r=i(56519),s=i(28874),n=i(47783),a=i(75020),o=i(40958),l=i(22573),u=i(55835);function c(e){return(0,u.map)(e,(e=>(0,l.mapNotBlank)(e.lensMake,(t=>(0,l.mapNotBlank)((0,o.compactBlanks)(s.Settings.tagFullLensModel.valueOrDefault?[e.lensModel,e.lensInfo]:[e.lensInfo,e.lensModel])[0],(e=>[a.TagRoots.Lens,t,e]))))))}t.lensTag=c,t.lensTagFile=function(e){return(0,r.thenMap)((0,n.readTags)(e),c)}},6186:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagDeltas=t.normalizeTagRoot=t.stripTagRoot=t.hasTagRoot=t.Roots=t.KwRoot=t.WhoRoot=t.AlbumsRoot=t.WhenRoot=void 0;const r=i(50213),s=i(28874),n=i(42231),a=i(75020),o=i(40958),l=i(22573),u=i(45599);t.WhenRoot={name:a.TagRoots.When,ordinal:1},t.AlbumsRoot={name:a.TagRoots.Albums,ordinal:2},t.WhoRoot={name:a.TagRoots.Who,ordinal:4},t.KwRoot={name:a.TagRoots.Keywords,ordinal:7};const c=(0,u.defer)((()=>(0,r.mkLogger)("curators.Taggers")));t.Roots=[t.WhenRoot,t.AlbumsRoot,{name:a.TagRoots.fs,ordinal:3},t.WhoRoot,{name:a.TagRoots.Camera,ordinal:5},{name:a.TagRoots.Lens,ordinal:6},t.KwRoot,{name:a.TagRoots.Type,ordinal:8}];const d=(0,o.uniq)([...a.TagRoots.values,...s.Settings.rootTagKeywordsAliases.values,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function h(e){return d.includes((0,n.tagRefToS)(e[0]).toLowerCase())}t.hasTagRoot=h,t.stripTagRoot=function(e){return h(e)?e.slice(1):e};const f=(0,o.uniq)([a.TagRoots.Albums,...s.Settings.rootTagAlbumsAliases.values].map((e=>e.toLowerCase()))),m=(0,o.uniq)([a.TagRoots.Keywords,...s.Settings.rootTagKeywordsAliases.values].map((e=>e.toLowerCase()))),p=(0,o.uniq)([a.TagRoots.Who,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));t.normalizeTagRoot=function(e){const i=(0,n.tagRefToS)(e[0]).toLowerCase();return(0,l.blank)(i)?e:m.includes(i)||m.includes(i)?[t.KwRoot,...e.slice(1)]:p.includes(i)?[t.WhoRoot,...e.slice(1)]:f.includes(i)?[t.AlbumsRoot,...e.slice(1)]:e},t.tagDeltas=async function(e,t){const i=(0,n.tagDiff)(t,e),r=(0,n.tagDiff)(e,t),a=s.Settings.excludedRootTags.valueOrDefault;return(0,o.filterInPlace)(i,(e=>{const t=a.includes((0,n.tagRefToS)(e[0]).toLowerCase());return t&&!(0,n.tagPathsInclude)(e,r)&&(r.push(e),c().info("tagDeltas(): removing excluded tag",e)),!t})),{add:i,remove:r}}},42003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fixCase=t.friendlySubtype=t.mimeTypeToTag=t.typeTagFiles=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(56519),o=i(54979),l=i(40958),u=i(22573),c=i(55835),d=i(42279),h=i(75020),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.TypeTagger")));t.typeTagFiles=async function(e){const t=(0,l.uniq)(await(0,a.mapAsyncSerial)({name:"typeTagFiles",arr:e,f:o.readMimeType}));return(0,l.compact)(t.map(p))};const m=new Map(["M2TS","JPEG","QuickTime"].map((e=>[e.toLowerCase(),e])));function p(e){const[t,i]=e.split("/");if(!(0,u.blank)(t)&&!(0,u.blank)(i))return f().tap({msg:"mimetypeToTag("+e+")",result:(0,c.map)(y(i,e),(e=>(0,l.compactBlanks)([h.TagRoots.Type,(0,n.capitalize)(t),...e])))})}t.mimeTypeToTag=p;const g=(0,r.lazy)((()=>new Map([["image/x-adobe-dng",["Raw","DNG"]],["image/x-fuji-raf",["Raw","Fujifilm"]],["video/m2ts",["MPEG-2"]],["video/mp2t",["MPEG-2"]],["video/mp4",["MPEG-4"]],["video/quicktime",["QuickTime"]],["video/x-msvideo",["AVI"]]])));function y(e,t){return(0,d.firstDefinedThunk)([()=>g().get(t.trim().toLowerCase()),()=>(0,c.map)(e.match(/^x-(\w{4,})-\w{3}/),(e=>["Raw",(0,n.capitalize)(e[1])])),()=>[w(e.replace(/^(?:x-|vnd\.|prs\.)/i,"").replace(/-/g," "))]])}function w(e){return null!=e.match(/[a-z\d]{3,4}/i)?e.toUpperCase():m.get(e.trim().toLowerCase())??(0,n.capitalize)(e)}t.friendlySubtype=y,t.fixCase=w},43723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nameTag=t.isWhoTag=t.whoTagFiles=void 0;const r=i(19851),s=i(50213),n=i(28874),a=i(47783),o=i(28630),l=i(66039),u=i(42231),c=i(40958),d=i(22573),h=i(96249),f=i(68708),m=i(75020),p=i(59455),g=(0,r.lazy)((()=>(0,s.mkLogger)("curators.WhoTagger")));t.whoTagFiles=async function(e){const t=[];if(n.Settings.tagJsonFaces.valueOrDefault){const i=[];for(const t of e)i.push(...(0,p.toA)(await t.jsonSidecars()));for(const e of i){const i=await(0,o.readJsonSidecar)(e),r=i?.peopleNames;(0,c.isNotEmpty)(r)&&t.push(...r)}}if(n.Settings.tagFaceRegions.valueOrDefault)for(const i of e){const e=await(0,a.readRawTags)(i,!0);if(null!=e)for(const i of(0,f.values)(e)){const e=i?.RegionList;if(Array.isArray(e))for(const i of e)"Face"===i.Type&&t.push(i.Name)}}if((0,c.isNotEmpty)(n.Settings.whoTags.values))for(const i of e){const e=await(0,a.readRawTags)(i,!0);for(const i of n.Settings.whoTags.values)t.push(...(0,p.toA)((0,f.pluckDeep)(e,i)?.value))}const i=(0,c.uniq)((0,h.flatten)((0,c.uniq)(t).map(v)));return g().tap({msg:"whoTagFiles()",level:"info",result:i,meta:{names:t,files:e.map((e=>e.nativePath))}})};const y=(0,c.uniq)([m.TagRoots.Who,...n.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function w(e){return y.includes((0,u.tagRefToS)(e[0]).toLowerCase())}function v(e){if(!(0,d.blank)(e))return Array.isArray(e)?(w(e)&&e.shift(),0===e.length?void 0:1===e.length?(0,l.renderNameTag)(e[0]):[[m.TagRoots.Who,...e]]):(0,l.renderNameTag)(e)}t.isWhoTag=w,t.nameTag=v},98348:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Db=void 0;const c=i(48884),d=i(19851),h=i(23560),f=i(25764),m=i(38836),p=i(99331),g=i(5916),y=i(12959),w=i(55332),v=i(91872),b=i(80632),S=i(51040),P=i(44955),_=i(15056),T=i(70025),M=i(57159),E=i(18454),D=i(28874),x=i(5233),k=i(42659),F=i(31586),C=i(68708),A=i(30976),I=i(17036),O=i(27134),L=i(35052);class R extends m.EndableWrapper{constructor(e,t){super("db.Db("+e+")",(()=>this.closeDb()),f.EndableRanks.db),r.add(this),this.schema=e,this.dbFile=t,s.set(this,0),n.set(this,void 0),this.endTimeoutMs=k.minuteMs,this.onRetry=(0,d.lazy)((()=>this.closeDb()),D.Settings.maxBusyDbMs.valueOrDefault/2),this.maxUpdatedAt=(0,d.lazy)((()=>"models"===this.schema?l(this,r,"m",a).call(this,"Asset","AssetFile","Example"):0),5*k.secondMs),this.migrate_=(0,g.lazyAsync)({desc:"db.migrate",later:async()=>{let e=!1;const t=this.dbFile;if(null==this.dbFile)throw new Error("Cannot migrate database: missing db");let i;if(await this.dbFile.isNonEmptyFile())try{await(0,O.verifyDb_)((()=>this.db))}catch(e){this.logger.warn("verifyDb failed before attempting Migration.",{error:e}),i=e}(null!=i||D.Settings.dbForceRecover.valueOrDefault)&&(E.HealthCheck.addLoadingMsg("Repairing database..."),await this.repair_(),e=!0);const r=new I.Migration(this.schema,this.db,t);return{appliedMigrations:await r.apply_(),migration:r,repaired:e}}}),this.tableInfo_=(0,d.lazy)((()=>(0,L.localTableInfo)(this.db)))}toJSON(){return(0,C.pick)(this,"schema","dbFile")}get isOpen(){return!0===l(this,n,"f")?.open}get inTransaction(){return this.isOpen&&!0===l(this,n,"f")?.inTransaction}prepare(e){return this.db.prepare(e)}pragma(e,t){return this.logger.tapThunk({msg:"PRAGMA "+e,result:()=>this.db.pragma(e,t)})}get db(){var e;const t=null==l(this,n,"f");if(t||!this.isOpen){this.logger.info("setting up new db connection to "+this.dbFile,{priorWasNull:t});try{u(this,n,(0,b.mkdb_)({nativePath:this.dbFile.nativePath}),"f")}catch(e){throw new M.WrappedError("Failed to set up "+this.dbFile,{cause:e,path:this.dbFile.nativePath})}}return(0,h.isSyncService)()&&"INCREMENTAL"===D.Settings.dbAutoVacuumMode.valueOrDefault&&(0,F.gt0)(D.Settings.dbWalAutoCheckpoint.valueOrDefault)&&u(this,s,(e=l(this,s,"f"),++e),"f")%D.Settings.dbWalAutoCheckpoint.valueOrDefault==0&&(this.logger.info("running incremental_vacuum..."),l(this,n,"f")?.pragma("incremental_vacuum")),l(this,n,"f")}async verify_(){await(0,O.verifyDb_)((()=>this.db))}assertHeartbeat_(){const e=(0,A.randomChars)(64),t=Date.now();try{this.db.prepare("INSERT INTO heartbeat (name, createdAt, updatedAt) VALUES (?,?,?)").run(e,t,t);const i=this.db.prepare("SELECT * FROM heartbeat WHERE name = ?").get(e);if(i?.name!==e)throw new Error("heartbeat INSERT/SELECT roundtrip failed")}finally{try{this.db.prepare("DELETE FROM heartbeat WHERE name = ?").run(e)}catch{}}}async closeDb(){try{this.logger.info("closing db",l(this,n,"f")),await(0,x.retryOnReject_)((()=>{!0===l(this,n,"f")?.open&&l(this,n,"f")?.close()}),{timeoutMs:D.Settings.dbBusyTimeoutMs.valueOrDefault,maxRetries:5,errorIsRetriable:T.isSqliteBusyError,retryDelay:k.secondMs})}catch(e){this.logger.warn("closeDb(): .close() failed",e)}u(this,n,void 0,"f")}async vacuum(){try{await(0,v.handleDbRetries_)("db.checkpoint",(()=>this.db),(()=>(0,O.checkpoint_)({db:this.db})),this.onRetry),await(0,v.handleDbRetries_)("db.optimize",(()=>this.db),(()=>this.db.pragma("OPTIMIZE")),this.onRetry),await(0,v.handleDbRetries_)("db.vacuum",(()=>this.db),(()=>this.db.exec("VACUUM")),this.onRetry)}catch(e){throw this.logger.warn("vacuum(): failed",{error:e}),e}}async repair_(){this.logger.warn("repair_(): Attempting restore of "+this.dbFile),await this.closeDb(),await(0,O.repairDbFile_)(this.dbFile),this.logger.info("repair_(): Database restoration was successful!")}localBackupDir(){return(0,_.dbBackupDir)(this.dbFile)}async backup_(e,t){const i=t??await(0,P.isDirSQLiteReadWrite)(e),s=(i?e:this.localBackupDir().join((0,y.filestamp)())).join(this.dbFile.base);return await l(this,r,"m",o).call(this,s),i||await(0,w.dbBackupCold_)(s,e),e.join(this.dbFile.base)}}t.Db=R,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(...e){const t=[];for(const i of e)try{t.push(this.db.prepare("SELECT MAX(updatedAt) FROM "+(0,S.dbValueToEscapedString)(i)).pluck().get())}catch(e){this.logger.warn(`#maxUpdatedAt(): failed to get max updatedAt for ${i}`,e)}return(0,c.max)(t)},o=async function(e){await e.parent().mkdirp_(),await this.db.backup(e.nativePath,{progress:e=>(this.logger.log((0,p.ending)()?"info":"debug","backup() "+(0,F.fmtPct)(100-e.remainingPages/e.totalPages*100)+" completed"),(0,p.ending)()?1e3:100)})}},25470:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.DbModelJanitor=t.Contested=t.NoOp=t.NoWriteLock=void 0;const c=i(66364),d=i(50213),h=i(23560),f=i(78406),m=i(25764),p=i(38836),g=i(99331),y=i(56038),w=i(12959),v=i(55332),b=i(76187),S=i(73209),P=i(28874),_=i(42659),T=i(75240),M=i(95700),E=i(22526),D=i(45648),x=5*_.minuteMs;t.NoWriteLock=Symbol("NoWriteLock"),t.NoOp=Symbol("NoOp"),t.Contested=Symbol("Contested");class k extends f.EndableInterval{static for(e){return new k(e.db,e.fslock,e.libraryDbFile,e.libraryDbBackupDir)}constructor(e,t,i,o){super({name:"db.DbModelJanitor",callback:()=>l(this,r,"m",n).call(this),intervalMs:P.Settings.dbBackupIntervalMs.valueOrDefault,initialDelayMs:_.minuteMs,rank:m.EndableRanks.db,endTimeoutMs:5*_.minuteMs,onEnd:()=>l(this,r,"m",a).call(this)}),r.add(this),this.db=e,this.dbFslock=t,this.libraryDbFile=i,this.libraryDbBackupDir=o,this.logger=(0,d.mkLogger)(this.name),this.fslockRelease=new p.EndableWrapper("db.DbModelJanitor.fslockRelease",(()=>this.dbFslock.release()),m.EndableRanks.postdb,x),s.set(this,0),this.dbFslock.tryAcquire_()}get useReplica(){return!this.db.dbFile.eql(this.libraryDbFile)}forceBackup_(){return this.backup_(!0)}async backup_(e=!1){return await(0,S.withLock_)({file:this.libraryDbBackupDir,timeoutMs:5*_.minuteMs,noopIfContested:!e},(async()=>{if(e&&u(this,s,0,"f"),(0,D.hasDbSetupErrors)())return this.logger.warn("backup_(): db has setup errors, skipping backup",{errors:(0,D.dbSetupErrors)()}),t.NoOp;if(!await this.dbFslock.tryAcquire_())return this.logger.info("backup_(): no-op: someone else has the fslock",{me:this.dbFslock.lockfile?.base,owner:(await this.dbFslock.selfAndSiblingNames_())[0]}),t.NoWriteLock;l(this,r,"m",o).call(this)||await(0,M.runMaintenanceTasks)();const i=this.db.maxUpdatedAt();return null!=i&&i>l(this,s,"f")?(0,y.time)("db.DbModelJanitor.backup_()",(async()=>{l(this,r,"m",o).call(this)?this.logger.info("backup_(): posthaste: skipping vacuum"):await this.db.vacuum(),u(this,s,i,"f");const e=this.libraryDbBackupDir.join((0,w.filestamp)()),t=await this.db.backup_(e,!this.useReplica);return this.useReplica&&await(0,v.dbBackupCold_)(t,this.libraryDbFile.parent()),this.logger.info("backup_(): backup successful",{destDbFile:t}),t})):(this.logger.info("backup_(): no update to the db since last backup",{ago:(0,T.fmtDuration)(Date.now()-l(this,s,"f"))}),t.NoOp)}))??t.Contested}}t.DbModelJanitor=k,s=new WeakMap,r=new WeakSet,n=async function(){try{await this.backup_()}catch(e){this.logger.error("backup_() failed",{error:e})}},a=async function(){const e=S.FsLock.for({file:this.libraryDbFile.sibling("db-teardown"),timeoutMs:x,endableRank:m.EndableRanks.postdb,noopIfContested:!1});(0,h.isDbManager)()&&await e.withLock_((async()=>{if(await this.dbFslock.iAmOnly_({vacuum:!0})){if(this.logger.info("#teardown(): I'm the last one in. Running backup and cleanup."),await this.backup_(),this.useReplica){const e=[(0,E.libraryDbInfoFromDbFile)(this.libraryDbFile),...(0,b.sqliteFiles)(this.db.dbFile)];this.logger.info("#teardown(): Removing replica artifacts",{victims:e});for(const t of e)await t.unlink()}}else this.logger.info("#teardown(): no-op: other processes are still running")})),await this.db.closeDb()},o=function(){return this.ended||(0,g.ending)()||(0,c.isSuspended)()}},22526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelSetup_=t.assertValidDbInfo_=t.libraryDbInfoFromDbFile=t.libraryDbInfoJsonFile=t.fsLockForDb=t.libraryDbObjects_=void 0;const r=i(19851),s=i(50213),n=i(92407),a=i(55332),o=i(44955),l=i(15056),u=i(87290),c=i(98314),d=i(38835),h=i(73209),f=i(95696),m=i(17217),p=i(18454),g=i(57902),y=i(28874),w=i(2858),v=i(40958),b=i(22573),S=i(42659),P=i(94448),_=i(98348),T=i(45648),M=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbModelSetup")));function E(e=y.Settings.libraryDir.valueOrDefault){if((0,b.blank)(e))throw new Error("Library directory is not set"+d.NoLibraryErrorFlag);const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dataDir"+d.NoLibraryErrorFlag);if(!(0,w._libraryHasSettings)(e))throw new Error(`Library at ${e} does not have a settings file`+d.NoLibraryErrorFlag);const i=(0,l.pathToDb)(t,"models");return{dataDir:t,libraryDbFile:i,libraryDbBackupDir:(0,l.dbBackupDir)(i)}}function D(e){return h.FsLock.for({file:e,timeoutMs:0,noopIfContested:!1})}function x(e=y.Settings.libraryDir.valueOrDefault){const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dir"+d.NoLibraryErrorFlag);return k((0,l.pathToDb)(t,"models"))}function k(e){return e.sibling("db-info.json")}async function F(e=x(),t){try{const i=await e.readJson(g.LogLevels.info);if(null==i)throw new Error(e+" is missing"+d.DbSetupErrorFlag);if(null!=t&&!await t.equalsUri_(i.uri))throw new Error(e+" expects the live db to be "+i.uri+" but the live db is "+await t.uri_()+d.DbSetupErrorFlag);const r=await f.PosixFile.forUri(i.uri);if(null==r)throw new Error(e+" expects the live db to be "+i.uri+" but that URI cannot be resolved."+d.DbSetupErrorFlag);try{await(0,o.assertDirSQLiteReadWrite_)(r.parent())}catch(t){throw M().error("assertValidDbInfo_(): failed to assert live dir was r/w",{error:t,liveDbFile:r,infoJsonFile:e}),new Error("Failed to validate that the live database directory, "+r.dir+", was read-writable by SQLite: "+(0,c.errorToS)(t)+d.DbSetupErrorFlag)}return{liveDbFile:r}}catch(e){throw(0,T.addDbSetupError)(e),e}}t.libraryDbObjects_=E,t.fsLockForDb=D,t.libraryDbInfoJsonFile=x,t.libraryDbInfoFromDbFile=k,t.assertValidDbInfo_=F,t.dbModelSetup_=async function(e=y.Settings.libraryDir.valueOrDefault){const{libraryDbFile:t,fslock:i,libraryDbBackupDir:r}=await async function(e=y.Settings.libraryDir.valueOrDefault){const t=E(e);return{...t,fslock:D(t.libraryDbFile)}}((0,b.mapNotBlank)(e,m.toNativePath_));let s,o;await i.tryAcquire_();const u=k(t);try{if(await(0,h.withLock_)({file:u,timeoutMs:5*S.minuteMs},(async()=>{const i=await u.readJson(g.LogLevels.info);if(s=i?.useReplica,null!=i){const{liveDbFile:e}=await F(u,t);o=new _.Db(l.Schemas.models,e)}if(null==s||null==o){const i=await(0,n.getLiveDbDir_)(e),r=await i.db.uri_();s=i.useReplica,s&&await p.HealthCheck.traceLater_("Setting up local replica database",(0,a.dbBackupCold_)(t,i.db.parent())).catch((e=>M().throw("Failed to set up replica db"+d.DbSetupErrorFlag,{src:t,dest:i.db,error:e}))),o=new _.Db(l.Schemas.models,i.db),await u.writeJson_({uri:r,useReplica:s})}})),null==o||null==s)return M().throw("Failed to open model db"+d.DbSetupErrorFlag+d.InternalErrorFlag,{libraryDir:e});if(await i.tryAcquire_()){const e=await o.migrate_();s&&(e.repaired||(0,v.isNotEmpty)(e.appliedMigrations))&&await o.backup_(t.parent(),!s),(0,T.clearDbSetupErrors)()}P.modelDb.set(o)}catch(e){throw M().error("Failed to set up model db",{error:e}),(0,T.addDbSetupError)(e),i.release(),e}return M().tap({msg:"dbModelSetup()",result:{db:o,useReplica:s,libraryDbFile:t,libraryDbBackupDir:r,fslock:i}})}},86859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DbRequest=void 0;const r=i(54557),s=i(50213),n=i(99331),a=i(56038),o=i(65753),l=i(66184),u=i(70417),c=i(28874),d=i(40958),h=i(22573),f=i(45599),m=i(96249),p=i(31586),g=i(51926),y=i(57038),w=i(21074),v=(0,f.defer)((()=>(0,s.mkLogger)("db.DbRequest")));t.DbRequest=class{constructor(e,t){this.db=e,this.tableName=t,this.cachedStatements=new r.FifoCache(256)}qb(){return(0,y.knex)()(this.tableName)}prep(e,t=!1){const i=(0,w.toSqlQuery)(e);try{const r=this.cachedStatements.getOrSet(this.db().db.__uid+":"+(!0===t?"pluck:":"")+i.sql,(()=>{const e=this.db().prepare(i.sql);return!0===t?e.pluck():e}));return r.database.open?{sq:i,stmt:r}:(this.cachedStatements.clear(),this.prep(e,t))}catch(e){return v().throw("prep() failed",{error:e,sqlQuery:i,retriable:!1})}}wrap({q:e,pluck:t,m:i}){try{const{sq:r,stmt:s}=this.prep(e,t);c.Settings.logSql.valueOrDefault&&v().log((0,l.defaultLogLevel)(),i+"(): "+(0,w.sqlQueryToS)(r));const n=s[i].bind(s);return null==r.bindings?n():n(r.bindings)}catch(t){if(!0===t.message?.includes("AdvisoryLock"))throw t;v().throw(t,{method:i,...(0,w.toSqlQuery)(e)})}}run(e){return this.wrap({q:e,m:"run"})}runScript(e,t=""){const i=(0,a.mkElapsed)("db.runScript()");for(const r of e){if((0,h.blank)(r)||r.trim().startsWith("--"))continue;this.run({sql:r});const e=(0,g.replaceAll)((0,g.ellipsize)(r,60),t,"");i.elapsed(e)}}mapRun(e){return e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return null==t.bindings?i.run():i.run(t.bindings)}))}runf(e){return this.wrap({q:e(this.qb()),m:"run"})}upsert(e){const t=(0,w.toSqlQuery)(e(this.qb()));return t.sql=t.sql.replace(/^(?:update|insert)\b/i,(e=>e.toUpperCase()+" OR REPLACE ")),this.wrap({q:t,m:"run"})}first(e){return this.wrap({q:e,m:"get"})}firstf(e){return this.wrap({q:e(this.qb()),m:"get"})}mapAll(e){return(0,m.flatten)(e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return i.all(t.bindings)})))}all(e){return this.wrap({q:e,m:"all"})}allf(e){return this.wrap({q:e(this.qb()),m:"all"})}async batched(e){let t,i=0;do{t=this.wrap({q:e.qb(this.qb(),t).limit((0,o.maxBatchPluckSize)()),m:"all"}),(0,d.isNotEmpty)(t)&&(await e.onResults(t),i+=t.length)}while((0,d.isNotEmpty)(t)&&!(0,n.ending)()&&(null==e.maxResults||e.maxResults>i));return{resultCount:i,done:null==t||t.length<(0,o.maxBatchPluckSize)()}}pluckFirst(e){return this.wrap({q:e,pluck:!0,m:"get"})}pluckFirstf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"get"})}pluckAll(e){return this.wrap({q:e,pluck:!0,m:"all"})}pluckAllf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"all"})}async pluckBatched(e){let t=0;const i=(0,u.min)([e.limit??(0,o.maxBatchPluckSize)(),e.maxResults]);if(i<=0||(0,p.lte0)(e.maxResults))return{done:!1,resultCount:t};let r;for(;null==e.maxResults||e.maxResults<=0||t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDbSetupErrorListener=t.hasDbSetupErrors=t.clearDbSetupErrors=t.addDbSetupError=t.dbSetupErrors=t._dbSetupErrors=void 0;const r=i(98314),s=i(22573),n=i(23541);t._dbSetupErrors=new Set;const a=[];t.dbSetupErrors=function(){return[...t._dbSetupErrors.values()]},t.addDbSetupError=function(e){if((0,n.isError)(e)||!(0,s.blank)(e)){t._dbSetupErrors.add((0,r.errorToS)(e));for(const e of a)e()}},t.clearDbSetupErrors=function({notifyListeners:e=!0}={}){if(t._dbSetupErrors.clear(),e)for(const e of a)e()},t.hasDbSetupErrors=function(){return t._dbSetupErrors.size>0},t.addDbSetupErrorListener=function(e){a.push(e)}},36908:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dedupeTags_=t.mergeTags_=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(42231),o=i(40958),l=i(76790),u=i(23838),c=i(31586),d=i(54993),h=(0,r.lazy)((()=>(0,s.mkLogger)("db.DedupeTags")));function f(e,t){function i(t){return e.prepare(t).run()}(0,o.isEmpty)(t)&&h().warn("mergeTags(): empty tagIds",{tagIds:t}),h().info("mergeTags() starting",{tagIds:t});const r=e.prepare("SELECT id, _path, parentId FROM Tag WHERE id IN ("+t.join(",")+") ORDER BY ID").all(),s=(0,o.compactBlanks)(r.map((e=>(0,a.tagPathLeaf)(e._path))).sort()),n=r[0],l=r.slice(1),u=n?.id;if((0,o.isEmpty)(s)||(0,o.isEmpty)(l)||null==n||!(0,c.gt0)(u))return void h().warn("mergeTags(): missing winner",{winner:n,winnerId:u,leafs:s,losers:l});const d=(0,a.splitTagPath)(n._path).slice(0,-1),f=[...d,s[0]];n._path=(0,a.joinTagPath)(f),n.parentId=0===d.length?null:e.prepare("SELECT id from Tag where _path LIKE ?").pluck().get((0,a.joinTagPath)(d))??n.parentId,h().info("mergeTags()",{winner:n,losers:l,winnerTagPath:f,leafs:s});const m=l.map((e=>e.id)).join(",");i(`UPDATE OR IGNORE AssetTag SET tagId = ${u} WHERE tagId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`DELETE FROM AssetTag WHERE tagId in (${m})`),i(`DELETE FROM Tag WHERE id in (${m})`),e.prepare("UPDATE Tag SET parentId = :parentId, _path = :path WHERE id = :id").run({parentId:n.parentId,path:n._path,id:u});const p=e.prepare("SELECT id, _path FROM Tag WHERE id != :winnerId AND _path LIKE :like COLLATE NOCASE").all({winnerId:u,like:n._path+"%"});for(const t of p){const i=(0,a.splitTagPath)(t._path).slice(f.length),r=(0,a.joinTagPath)([...f,...i]);t._path!==r&&(h().info("mergeTags(): repairing tag path",{ea:t,newPath:r}),e.prepare("UPDATE OR IGNORE Tag SET _path = :path, updatedAt = :updatedAt WHERE id = :id").run({id:t.id,updatedAt:Date.now(),path:r}))}return h().tap({msg:"mergeTags()",level:"info",result:{winner:n,losers:r}})}t.mergeTags_=f,t.dedupeTags_=function(e){const t=new u.MultiMap;for(const{id:i,_path:r}of e.prepare("SELECT id, _path FROM Tag ORDER BY id").iterate())t.add((0,n.stripSuffix)((0,d.toS)(r).trim(),a.TagSep).toLowerCase().normalize(),i);const i=(0,l.sortBy)(t.entriesArray().filter((([,e])=>e.length>1)),(([e])=>[-(0,n.countChars)(e,a.TagSep),-e.length,e]));for(const[,t]of i)f(e,t)}},57038:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstMigratedAt=t.knex=void 0;const s=r(i(31832)),n=i(19851),a=i(56519),o=i(55835),l=i(68708);t.knex=(0,n.lazy)((()=>(0,s.default)({client:"better-sqlite3",useNullAsDefault:!0}))),t.firstMigratedAt=async function(e){return(0,a.thenMap)(e("migrations").min("migration_time").first(),(e=>(0,o.map)((0,l.values)(e)[0],(e=>new Date(e)))))}},17036:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Migration=void 0;const o=i(77598),l=i(19851),u=i(50213),c=i(7282),d=i(37805),h=i(4867),f=i(51040),m=i(77740),p=i(38835),g=i(8769),y=i(57159),w=i(34102),v=i(73209),b=i(95696),S=i(43899),P=i(18454),_=i(28874),T=i(40958),M=i(42659),E=i(41400),D=i(98553),x=i(55835),k=i(34666),F=i(32639),C=i(45648),A=i(94715),I=i(27134);t.Migration=class{constructor(e,t,i){r.add(this),this.schema=e,this.db=t,this.dbFile=i,this.fsMigrations_=(0,l.lazy)((()=>this.migrationsDir.children_((e=>e.isFile&&e.basename.endsWith(".sql"))).catch((e=>this.logger.throw("Failed to read migration directory, "+this.migrationsDir+p.InternalErrorFlag,{error:e}))))),this.ensureMigrationTable_=(0,l.lazy)((()=>{this.db.exec("\nCREATE TABLE IF NOT EXISTS migrations (\n id INTEGER NOT NULL PRIMARY KEY,\n name TEXT NOT NULL,\n migration_time INTEGER NOT NULL\n) STRICT\n")})),this.unknownMigrations_=(0,l.lazy)((()=>this.migrationsInDatabase_().filter((e=>!(0,k.lt)((0,A.migrationNameToDate)(e),d.gitDate))))),this.assertKnownMigrations_=(0,l.lazy)((()=>{const e=this.unknownMigrations_();if((0,T.isNotEmpty)(e)){const t=new y.WrappedError("Please upgrade PhotoStructure to a newer version to open this library: Unknown migrations: "+e.join(","));throw(0,g.onError)(t),t}})),this.logger=(0,u.mkLogger)("db.Migration("+(0,D.stringify)({schema:e,db:i.nativePath})+")"),this.migrationsDir=b.PosixFile.for(S.ProjectPath.Migrations()).join(this.schema)}async pendingMigrationFiles_(){const e=this.migrationsInDatabase_();return(await this.fsMigrations_()).filter((t=>!e.includes(t.name)))}migrationsInDatabase_(){return this.ensureMigrationTable_(),this.db.prepare("SELECT name from migrations").pluck().all()}async apply_(e){return(0,v.withLock_)({file:this.dbFile.sibling("migrate"),timeoutMs:_.Settings.dbMaintenanceTimeoutMs.valueOrDefault},(()=>a(this,r,"m",s).call(this,e)))}async applyMigration_(e,t){try{const i=Date.now(),s=A.Migrations[e.name.replace(/^[\d_-]+/,"")],o=(0,F.isFunction)(s);return o?await s.bind(A.Migrations)(this.db):await a(this,r,"m",n).call(this,e),this.logger.info("applyMigration() completed",{elapsedMs:Date.now()-i,codeMigration:o,migration:e.baseWithParent}),t?.run(e.name,Date.now())}finally{(0,w.ee)().emit("clearDbCache")}}},r=new WeakSet,s=async function(e){try{this.ensureMigrationTable_(),(0,c.isProd)()&&this.assertKnownMigrations_();const t=[],i=this.db.prepare("INSERT INTO migrations (name, migration_time) VALUES (?, ?)");for(const r of await this.pendingMigrationFiles_())await P.HealthCheck.traceLater_("Upgrading database ("+r.name+")",(async()=>{if((0,m.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");(0,m.getDevEnvFlag)("PS_SLOMO")&&await(0,E.delay)((0,o.randomInt)(M.secondMs,3*M.secondMs)),await(0,x.map)(e,(e=>e(r))),await(0,h.thenOrTimeoutError)({p:this.applyMigration_(r,i),timeoutMs:5*_.Settings.dbMaintenanceTimeoutMs.valueOrDefault}).catch((e=>{throw new y.WrappedError("Migration "+r.name+" timed out.",{cause:e,fatal:!0,ignorable:!1})}))})),t.push(r.base);return this.logger.info("Migration complete",{appliedMigrations:t}),t}catch(e){const t=new y.WrappedError("Migrating the "+this.schema+" db failed",{cause:e});throw(0,C.addDbSetupError)(t),P.HealthCheck.addError(t),t}},n=async function(e){const t=e.name.includes("_nofk");try{const i=await e.readTextFile(),r=(0,f.splitBatchSql)(i);if((0,T.isEmpty)(r))this.logger.info("No-op migration: "+e);else{t&&this.db.pragma("foreign_keys = OFF");for(const t of r)try{this.db.exec(t)}catch(i){this.logger.throw("Failed to apply SQL",{stmt:t,migration:e.baseWithParent,cause:i,fatal:!0})}t&&(0,I.foreignKeyCheck_)(this.db)}}finally{t&&this.db.pragma("foreign_keys = ON")}}},94715:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Migrations=t.isoToPrecisionMs=t.fix_root_tags=t.tag_path_suffix=t.migrationNameToDate=t.plucklabmodeb6=t.lowercase_psnet_function=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(97352),o=i(68852),l=i(81168),u=i(85810),c=i(42022),d=i(1971),h=i(79842),f=i(89724),m=i(17415),p=i(88600),g=i(20014),y=i(42231),w=i(87001),v=i(40958),b=i(55835),S=i(31586),P=i(97790),_=i(89937),T=i(54993),M=i(7656),E=i(36908),D=(0,s.lazy)((()=>(0,n.mkLogger)("db.Migrations"))),x=new RegExp(`^(${(0,o.escapeRegExp)(_.PS_NETWORK_FILESYSTEM_SCHEME)}://.*?/)(.*)$`);function k(e,t){return(0,a.mapGt0)(e,(()=>(0,b.map)(function(e,t=c.ModeBits){return(0,g.splitBits)(e,t).map((e=>(0,u.unlabhash)(e,t)))}(e,6)[t],(e=>(0,u.toLabhash)(e,c.ModeBits)))))}function F(e){return e.endsWith(y.TagSep)?e:e+y.TagSep}function C(e){for(const t of e.prepare("SELECT id, parentId, _path FROM Tag WHERE id = parentId").iterate())D().warn("fix_root_tags(): broken tag",{broken:t}),(0,l.countChars)(t._path,y.TagSep)<2&&e.prepare("UPDATE Tag set parentId = null where id = ?").run(t.id)}function A(e){return(0,b.map)((0,h.isoToDated)(e),h.datedToPrecisionMs)??-1}t.lowercase_psnet_function=e=>(0,P.opt)(e).filter(l.isString).flatMap((e=>x.exec(e))).map((e=>e[1].toLowerCase()+e[2])).getOrElse((()=>e)),t.plucklabmodeb6=k,t.migrationNameToDate=function(e){const[t,i,r]=[e.slice(0,4),e.slice(4,6),e.slice(6,8)].map((e=>(0,S.toInt)(e)));return(0,p.validYMD)(t,i,r)?new Date(t,i-1,r):void 0},t.tag_path_suffix=F,t.fix_root_tags=C,t.isoToPrecisionMs=A,t.Migrations={fix_root_tags:C,lowercase_psnet_hostname:e=>{e.function("lowercase_psnet_hostname",{deterministic:!0},t.lowercase_psnet_function),e.exec("DROP INDEX IF EXISTS assetfile_uri_udx"),e.exec("UPDATE AssetFile SET uri = lowercase_psnet_hostname(uri)"),e.exec("CREATE UNIQUE INDEX assetfile_uri_udx ON AssetFile(uri)")},numeric_captured_at:e=>{e.function("isoToLocal",{deterministic:!0},f.isoToLocal),e.function("isoToOffsetMinutes",{deterministic:!0},m.isoToOffsetMinutes),e.function("isoToPrecisionMs",{deterministic:!0},A),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtLocal bigint"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtOffset integer"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtPrecisionMs integer"),e.exec("UPDATE AssetFile SET capturedAtLocal = isoToLocal(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtOffset = isoToOffsetMinutes(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtPrecisionMs = isoToPrecisionMs(capturedAtISO)"),e.exec("DROP INDEX asset_captured_at_geohash_idx"),e.exec("DROP INDEX assetfile_exifuid_idx"),e.exec("CREATE INDEX assetfile_capturedAtLocal_idx ON AssetFile(capturedAtLocal)")},spread_modes:e=>{e.function("plucklabmodeb6",{deterministic:!0},k),(0,S.times)(d.ModeCount,(t=>e.exec(`ALTER TABLE AssetFile ADD COLUMN mode${t} integer`))),e.exec("UPDATE AssetFile SET "+(0,S.times)(d.ModeCount,(e=>`mode${e} = plucklabmodeb6(mode8b6, ${e})`)).join(", "))},normalize_asset_file_uris:e=>{e.function("normalizeURI",{deterministic:!0},w.normalizeURI);const t=e.prepare("SELECT normalizeURI(uri) AS nuri, count(*) AS cnt, GROUP_CONCAT(id) AS ids FROM AssetFile GROUP BY nuri HAVING cnt > 1").all(),i=[];for(const s of t){const t=(0,T.toS)(s.ids).split(","),n=e.prepare("SELECT id, shown, version, updatedAt FROM AssetFile WHERE id in ("+t.join(",")+")").all(),a=(0,r.greatestBy)(n,(e=>[e.shown,e.version,e.updatedAt])),o=n.filter((e=>e.id!==a?.id));i.push(...o.map((e=>e.id)))}for(const t of(0,r.batches)(i,256))e.exec("DELETE FROM AssetFile WHERE id in ("+t.join(",")+")");e.exec("UPDATE AssetFile SET uri = normalizeURI(uri)")},dedupe_tag_paths:E.dedupeTags_,suffix_tag_paths:e=>{e.function("tag_path_suffix",{deterministic:!0},F),(0,E.dedupeTags_)(e),e.exec("UPDATE Tag SET _path = tag_path_suffix(_path)")},normalize_tag_paths:e=>{const t=e.prepare("SELECT id, _path FROM Tag WHERE _path LIKE '%' || char(31) || char(31) || '%'").all();D().info("normalize_tag_paths():",{badTags:t});for(const i of t){const t=(0,y.normalizeTagPath)(i._path);(0,E.mergeTags_)(e,(0,v.compact)([i.id,...e.prepare("SELECT id FROM Tag WHERE _path LIKE ?").pluck().all(t)]))}},drop_tc_tables:e=>{const t=/^(ct|taf|tag_counts)_[a-z\d]{6}$/i,i=e.prepare("SELECT name FROM sqlite_master WHERE type='table'").pluck().all(),r=i.filter((e=>null!=t.exec(e)));D().info("drop_tc_tables()",{tables:i,victims:r});for(const t of r)e.exec("DROP TABLE "+t)},rebuild_rotated_heic:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype = 'image/heif' AND rotation <> 0")},rebuild_videos:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%'"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where mimetype LIKE 'video/%')")},copy_asset_duration:e=>{e.exec("CREATE INDEX tmp_af_idx ON AssetFile (assetId, durationMs)"),e.exec("UPDATE Asset SET durationMs = (SELECT durationMs FROM AssetFile WHERE assetId = Asset.id AND durationMs IS NOT NULL LIMIT 1) WHERE durationMs IS NULL"),e.exec("DROP INDEX tmp_af_idx"),e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%' and durationMs IS NULL"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where version = 0)")},rebuild_tag_asset_counts:M.rebuildTagAssetCounts,create_tag_fts:e=>{e.exec("DROP TABLE IF EXISTS tag_fts"),e.exec("CREATE VIRTUAL TABLE tag_fts USING fts5 (root, path, content='', contentless_delete=1, tokenize=\"unicode61\");")}}},27134:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.repairDbFile_=t.checkpoint_=t.verifyDbFile_=t.verifyDb_=t.foreignKeyCheck_=t.integrityCheck_=t.quickCheck_=t.backupDbFile_=t.sqlite=void 0;const r=i(14121),s=i(19851),n=i(50213),a=i(84777),o=i(12959),l=i(5531),u=i(91872),c=i(99315),d=i(76187),h=i(51040),f=i(38835),m=i(57159),p=i(29882),g=i(95696),y=i(89966),w=i(38156),v=i(28874),b=i(63870),S=i(5233),P=i(42659),_=i(41400),T=i(50357),M=i(98553),E=i(56409),D=i(31586),x=i(20214),k=i(51926),F=i(12168),C=i(59455),A=i(54993),I=i(94448),O=i(9508),L=(0,s.lazy)((()=>(0,n.mkLogger)("db.SQLite")));function R({db:e,pragma:t,okResult:i}){L().debug("pragmaOrThrow_()",{db:N(e),db_open:e?.open,pragma:t,okResult:i});const r=(0,k.isString)(i)?e.pragma(t,{simple:!0}):e.pragma(t);(0,T.eql)(r,i)||L().throw(`${t} failed for ${N(e)}: ${(0,M.stringify)({result:r})}`)}function N(e){return(0,p.ellipsizePath)({p:e.name,maxLength:80})}function B(e){return R({db:e,pragma:"quick_check",okResult:"ok"})}function j(e){return R({db:e,pragma:"integrity_check",okResult:"ok"})}function z(e){const t=(0,C.toA)(e.pragma("foreign_key_check"));t.length>v.Settings.dbInvalidFKThreshold.valueOrDefault&&L().throw("foreignKeyCheck_(): too many invalid foreign keys to repair",{dbInvalidForeignKeyThreshold:v.Settings.dbInvalidFKThreshold.valueOrDefault,badRowsCount:t.length,badRows:t});for(const i of t)L().warn("repairDbFile_(): deleting row with invalid foreign key",{row:i}),e.prepare(`DELETE FROM ${(0,h.dbValueToEscapedString)(i.table)} WHERE rowid = ?`).run(i.rowid)}async function V(e){await(0,u.handleDbRetries_)("db.quickCheck",e,B),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.integrityCheck",e,j),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.foreignKeyCheck",e,z)}function W(e){return(0,O.withDbSync)(e,V,(0,b.commandTimeoutMs)())}t.sqlite=async function({dbFile:e,sql:t,args:i}){const s=await(0,y.sqliteNativePath_)(),n=await(0,r.thenElapsed)((0,a.stdout_)(s,[...(0,C.toA)(i),e.nativePath,t],{timeoutMs:1*P.minuteMs}));return L().debug("sqlite("+t+") on "+e+" in "+n.elapsedMs+"ms",n.result),n.result},t.backupDbFile_=function(e,t){return(0,S.retryOnReject_)((()=>async function(e,t){try{await t.parent().mkdirp_(),await t.unlink("trace");const i=await e.size();if(!(0,D.gt0)(i))return void L().warn("backupDbFile_(): "+e+" is empty");await((0,I.modelDb)()?.end()),await(0,O.withDb)(e,(async e=>e.exec("VACUUM INTO "+(0,h.dbValueToEscapedString)(t.nativePath))),2*P.minuteMs),L().info("backupDbFile_(): Finished "+e+" -> "+t)}catch(i){throw new m.WrappedError(`Could not back up db ${e} -> ${t}`,{cause:i})}}(e,t)),{maxRetries:3,retryDelay:P.secondMs,timeoutMs:P.minuteMs,errorIsRetriable:()=>!0})},t.quickCheck_=B,t.integrityCheck_=j,t.foreignKeyCheck_=z,t.verifyDb_=V,t.verifyDbFile_=W,t.checkpoint_=async function e({db:t,retries:i=3,checkpointType:r=v.Settings.dbWalCheckpointType.valueOrDefault}){if((r=l.CheckpointTypes.getCI(r)??l.CheckpointTypes.AUTO)===l.CheckpointTypes.AUTO)return;const s="wal_checkpoint("+r+")",[n]=(0,C.toA)(t.pragma(s));return L().info("checkpoint()",{pragma:s,result:n}),(0,D.gt0)(n?.busy)&&i>0?(await(0,_.delay)(250),e({db:t,retries:i-1})):n};const U=/no such table: sqlite_\w+/i;t.repairDbFile_=async function(e,t=c.RepairModes.dump){const i=g.PosixFile.for(e),r=(await i.parent().join("db-"+t,(0,o.filestamp)()).mkdirp_()).join(i.base);L().info(`repairDbFile_(${i} -> ${r})`);try{const e=await(0,y.sqliteNativePath_)(),s=4*Math.min(20*F.MiB,await(0,d.sqliteSizeBytes)(i)),n=new w.PushProgressObserver({path:(0,A.toS)(i),op:"Repairing your database"},s),o=new E.Latch,l=(0,a.execFile)(e,[i.nativePath,"."+t],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});l.stdout.on("error",(e=>{const i=(0,A.toS)(e);U.test(i)?L().info("repairDbFile_(): ignoring stderr",{err:i}):o.reject(new Error("sqlite "+t+" failed: "+i))}));const u=(0,a.execFile)(e,[r.nativePath],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});u.on("exit",(()=>o.resolve())),l.stdout.on("end",(()=>{u.stdin.end(null)})),l.stdout.on("data",(e=>{const t=e.length;n.incrProgress(t),u.stdin.write(e)})),await o,L().info(`repairDbFile_(): recovered to ${r}.`),await W(r),L().info(`repairDbFile_(): ${r} is valid, finishing repair.`);const c=await(0,x.thenCollect)((0,d.sqliteFiles)(i),(e=>e.renameYMDHMS_({subdir:"needed-repair"})));return await(0,x.thenCollect)((0,d.sqliteFiles)(r),(e=>e.mv_(i.parent()))),c.find((e=>".db"===e.ext||e.ext.startsWith(".sqlite")))}catch(e){return L().throw("failed to recover DB via dump and restore. Please see https://photostructure.com/faq/restore-db-from-backup/ "+f.FatalErrorFlag,{error:e})}}},21074:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqlWhereInClause=t.isQueryBuilder=t.sqlQueryToS=t.toSqlQuery=t.isSqlQuery=void 0;const r=i(48884),s=i(68852),n=i(81168),a=i(12943),o=i(96249),l=i(98553),u=i(31586),c=i(68708),d=i(32639),h=i(54993);function f(e){return null!=e&&(0,n.isString)(e.sql)&&(null==e.bindings||(0,a.isDbValued)(e.bindings))}t.isSqlQuery=f,t.toSqlQuery=function(e){if(null==e)throw new Error("null sql");if(f(e))return e;if((0,n.isString)(e))return{sql:e};if((0,d.isFunction)(e.toSQL))return(0,c.omit)(e.toSQL(),"__knexQueryUid");throw new Error("not queryish: "+(0,l.stringify)(e))},t.sqlQueryToS=function(e){if(null==e.bindings)return e.sql;if(Array.isArray(e.bindings))return(0,o.flatten)((0,r.zip)(e.sql.split("?"),e.bindings.map((e=>(0,l.stringify)(e))))).join("");{let t=e.sql;for(const i of(0,c.keys)(e.bindings))t=t.replace(new RegExp("[@:$]"+(0,s.escapeRegExp)(i),"gi"),(0,h.toS)(e.bindings[i]));return t}},t.isQueryBuilder=function(e){return(0,d.isFunction)(e?.where)&&(0,d.isFunction)(e?.limit)},t.sqlWhereInClause=function(e){return"("+(0,u.times)(e,(()=>"?")).join(",")+")"}},35052:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localTableInfo=t.parseTableInfo=void 0;const r=i(22573),s=i(23838);function n(e){const t=new s.MultiMap;for(const i of e)i.tableName.includes("fts")||i.tableName.includes("sqlite_")||(0,r.blank)(i.name)||(0,r.blank)(i.type)||t.add(i.tableName,{name:i.name,type:i.type.toUpperCase().trim().replace(/\s+/g,""),notnull:1===i.notnull,pk:1===i.pk});return t.entriesArray().map((([e,t])=>({tableName:e,columns:t})))}t.parseTableInfo=n,t.localTableInfo=function(e){return n(e.prepare("SELECT \nm.tbl_name as tableName,\np.*\nFROM sqlite_master AS m\nJOIN pragma_table_info(m.name) AS p\nORDER BY m.tbl_name, p.cid").all())}},9508:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withDb=t.withDbSync=void 0;const r=i(80632),s=i(28874),n=i(30301),a=i(54993);t.withDbSync=function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const o=(0,n.lazy)((()=>(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i})));try{return t((function(){const e=o();return e.open?e:o.refresh()}))}finally{o.prior()?.close()}},t.withDb=async function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const n=(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i});try{return await t(n)}finally{n.close()}}},53493:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=i(50213),s=i(45608),n=i(69554),a=i(38790),o=i(53978),l=i(95696),u=i(48368),c=i(45200),d=i(40958),h=i(22573),f=i(38639),m=i(98553),p=i(31586),g=i(68708),y=i(5670),w=i(64526),v=i(37158),b=i(31503),S=i(57038),P=i(21074),_=i(43487),T=i(48723),M=i(94710),E=i(23523);!async function(){try{const e=new n.CLI(y.ServiceNames.list).add(b.LogArgs,a.ColorArgs,o.TimingArg);e.add({beforeParse:e=>e.option("--primary",'Only include the primary, or "best" asset file variation found for every asset. See https://phstr.com/dedupe for details.').option("--no-primary","Exclude primary asset file variation for every asset. This is mutually exclusive with the --primary option, and returns all rows that option omits.").option("--limit ","Emit at most LIMIT values.",p.toGt0).option("--query ","Apply the given query and return all matching asset file paths. Must be the last argument. Incompatible with --where.").option("-j, --json",'Emit a JSON object for every asset file with "hidden" and "shown" flags').option("--dump","Emit a JSON object that includes all column values").option("--where ","Apply a SQL WHERE clause to filter the rows returned. If this is omitted, only shown assets are returned: hidden, excluded, deleted, and incomplete assets will be omitted.").option("--orderby ","Apply a SQL ORDER BY clause to filter the rows returned.").option("-0, --print0",'Print each full native path name to standard output, followed by a null character (instead of the newline character).\nThis is suitable for properly handling filenames that include whitespace characters in shell pipelines using commands like xargs, which has a "--null" mode which expects filenames to be separated by the null character.\nThis cannot be used with --json or --dump.').option("--looks-like ","Find images that look like the photo or video specified by FILE. Use a full pathname.").option("--tasks","List the currently enqueued tasks that sync is process(ing). Implies --json. Does not support --print0.").option("--tags","List all tag paths along with their counts. Implies --json. Does not support --print0.")});const t=(await e.parse()).opts(),i=(0,d.mapNotEmpty)(t.query,(e=>e.join(" "))),D=(0,f.isTrue)(t.dump),x=D||(0,f.isTrue)(t.json),k=t.where;if(null!=i&&(0,h.notBlank)(k))throw new Error("--query cannot be used with --where");const F=new v.Service("list");await F.ready;const C=await w.Library.instanceRequired_().modelDb(),A=(0,r.mkLogger)("list");function I(e){for(const i of e)!0===t.print0?process.stdout.write(i+"\0"):console.log(i)}if((0,f.isTrue)(t.tags)){const V=T.Tag.ops().allf((e=>T.Tag.orderBy(e)));return void console.log((0,m.stringifyPretty)(V.map((e=>(0,g.pick)(e,"path","assetCount")))))}if((0,f.isTrue)(t.tasks)){const W=M.Task.ops().allf((e=>M.Task.orderBy(e)));return void(W.length>0?console.log((0,m.stringifyPretty)(W)):console.error("No pending items in any queues."))}let O=_.Asset.query().join("AssetFile","AssetFile.assetId","Asset.id").join("AssetTag","AssetTag.assetId","Asset.id");if(O=O.select({assetId:"AssetFile.assetId",assetFileId:"AssetFile.id",shownFile:"AssetFile.shown",mountpoint:"AssetFile.mountpoint",uri:"AssetFile.uri",hidden:"Asset.hidden",rating:"Asset.rating"}).distinct(),(0,h.notBlank)(t.looksLike)){const U=l.PosixFile.for(t.looksLike);A.info("Calculating image hash for "+U);const q=await U.sha(),H=await(0,u.imageHash)(U);if(null==H)throw new Error("Failed to generate image hash for "+U);A.info("Looking for assets with matching meanHash or SHA",{meanHash:H.meanHash,SHA:q}),O=O.where((e=>e.where("AssetFile.meanHash",H.meanHash).orWhere("AssetFile.sha",q)))}D&&(O=O.select((0,S.knex)().raw("AssetFile.*"),(0,S.knex)().raw("Asset.*"))),O=(0,h.notBlank)(k)?O.andWhere((0,S.knex)().raw(k)):_.Asset.shownUnhidden(O),!0===t.primary&&(O=O.andWhere("AssetFile.shown",1)),!1===t.primary&&(O=O.andWhere("AssetFile.shown",0)),(0,p.gt0)(t.limit)&&(O=O.limit(t.limit));const L=(0,h.toNotBlank)(t.order)??"uri",R=null!=i?(0,E.queryStringToSql_)(i,O).orderByRaw(L):O,N=(0,P.toSqlQuery)(R);A.info("Running SQL query...",{sq:N});const B=Date.now(),j=C.prepare(N.sql).iterate(N.bindings);A.info("query took "+(Date.now()-B)+"ms"),x&&console.log("[");let z=!0;for(const $ of j){A.throwIfAborted_();const G=await(0,c.uri2nativePath)($.uri,$.mountpoint);x?(z||process.stdout.write(","),process.stdout.write((0,m.stringify)({path:G,...(0,g.omit)($,"id")}))):null==G?console.error("Failed to decode URI to native path: ",(0,m.stringify)($)):I([G??$.uri]),z=!1}x&&console.log("]")}catch(J){await(0,s.exit)({error:J})}finally{await(0,s.exit)({status:0})}}()},43487:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Asset=void 0;const u=i(48884),c=i(19851),d=i(50213),h=i(88158),f=i(45393),m=i(56519),p=i(89724),g=i(38835),y=i(74128),w=i(79847),v=i(28874),b=i(47783),S=i(38010),P=i(40958),_=i(76790),T=i(75761),M=i(38639),E=i(11371),D=i(98553),x=i(55835),k=i(31586),F=i(20214),C=i(59455),A=i(64526),I=i(4407),O=i(54017),L=i(48722),R=i(37094),N=i(45295),B=i(39604),j=i(48723),z=i(41507),V=i(72761),W={"Asset.shown":1,"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null};class U extends V.TimestampedModel{constructor(){super(...arguments),r.add(this),this.attrs={},this.assetIdish=(0,c.lazy)((()=>({assetId:this.id,v:this.updateCount,capturedAtLocal:this.capturedAtLocal}))),this.mergedTags=(0,c.lazy)((async()=>{const e=[];for(const t of this.getAssetFiles()){const i=await t.posixFile(),r=await(0,b.readTags)(i),s=await(i?.mtimeMs());null!=i&&null!=r&&null!=s&&e.push({...r,SourceFile:i.nativePath,sourceModifiedTime:s,sourceIsPrimary:(0,M.isTrue)(t.shown)})}const t=R.AssetRevision.ops().allf((e=>e.where({assetId:this.id}))),i=new S.MergedTags("Asset:"+this.id);return i.addTag(...e,...this.assetFiles),i.addRevision(...t),i}))}static shownUnhidden(e){return null==e?s.query().where(W):e.andWhere(W)}static findUnhiddenById(e){return(0,k.gt0)(e)?s.ops().firstf((t=>s.shownUnhidden(t.where({id:e})))):void 0}static shownRemovable(e,t){return(t??s.query()).whereNotNull(e).andWhere({"Asset.shown":1})}static shownCount(){return s.ops().count(s.shownUnhidden().countDistinct("Asset.id"))}static deletePreviews(e){return A.Library.instance().previews().ap(e).deleteAll()}static async remove({assetId:e,blocklistShas:t,unlinkAssetFiles:i}){const r=(0,d.mkLogger)("Asset("+e+").remove()"),n=s.ops().findById(e);if(null==n)return void r.warn("asset not found");const a=n.isActive(),o=n.tagIds();r.info("starting",{unlinkAssetFiles:i});const l=n.getAssetFiles({refresh:!0});if(t){(0,B.upsertToShaBlockslist)(...l.map((e=>e.sha)));for(const e of l)(0,y.syncReport)().onProgress({from:"Asset.remove",path:await e.getNativePath()??e.uri,state:"blocklisted",details:"sha blocklisted (files with the same sha will not be imported)"})}N.AssetTag.dbl.runf((t=>t.delete().where({assetId:e}))),O.AssetFile.dbl.runf((t=>t.delete().where({assetId:e}))),R.AssetRevision.dbl.runf((t=>t.delete().where({assetId:e}))),s.dbl.runf((t=>t.delete().where({id:e}))),a&&j.Tag.deltaAssetCountAndAncestors(o,-1);try{await s.deletePreviews(e)}catch(e){r.error("Failed to delete previews",{error:e})}return{deletedMeta:i?await(0,w.trashOrUnlinkFileUris_)(l):[],assetFileMeta:l}}static nextOutdated(e=h.identity){return this.ops().findOne(e(l(this,s,"m",n).call(this)))}static nextOutdateds(e){return this.ops().all(e(l(this,s,"m",n).call(this)))}static outdatedCount(e=h.identity){return this.dbl.pluckFirst(e(l(this,s,"m",n).call(this)).count())}static findFirstByFile(e){return this.ops().findOne(e(this.query().select("Asset.*").join("AssetFile","AssetFile.assetId","Asset.id")))}static unshownAssetIds(){return this.dbl.pluckAll("\n SELECT DISTINCT af1.assetId\n FROM AssetFile af1\n LEFT JOIN (SELECT DISTINCT assetId FROM AssetFile WHERE shown = 1) AS af2 \n ON af1.assetId = af2.assetId\n WHERE af2.assetId IS NULL")}static archive(e){null!=s.ops().findById(e)&&(N.AssetTag.dbl.runf((t=>t.where({assetId:e}).delete())),O.AssetFile.dbl.runf((t=>t.where({assetId:e}).delete())),s.dbl.runf((t=>t.where({id:e}).delete())))}markUnshownAndUpsert(){this.shown=!1,this.version=f.AssetVersion,this.upsert()}markShownAndUpsert_(e){const t=this.getShown()?.id;if(null!=e){const t=e.shown;this.setShown_(e,{skipUpsert:!0}),!0!==t&&e.upsert()}this.shown=!0,this.version=f.AssetVersion,t!==this.getShown()?.id&&(this.updateCount=(this.updateCount??0)+1),this.upsert()}async updateFromFiles(){const e=await this.mergedTags();(0,x.map)(e.get("rating"),(e=>{this.logger().info("updateFromFiles()",{rating:e}),this.rating=e.value}))}isActive(){return(0,k.gt0)(this.id)&&!0===this.shown&&null==this.excludedAt&&null==this.deletedAt&&(null==this.rating||(0,k.gte)(this.rating,v.Settings.rejectRatingsLessThan.valueOrDefault))}toAssetId(){return(0,L.toAssetId)(this)}renderCaption(e){return(0,x.map)(this.capturedAtLocal,(t=>"Taken "+(0,p.fmtLocalDateShort)(t,e)))}async whenApiTag(){const e=(0,I.dateTag)((0,p.localToDateObject)(this.capturedAtLocal));return null==e?void 0:j.Tag.findOrCreate(e).toApiTag()}findAssetFileByUri(e){return this.getAssetFiles()?.find((t=>t.uri===e))}addAssetFile(e){(0,P.filterInPlace)(e.asset?.assetFiles??[],(t=>!(t.id===e.id||t.uri===e.uri))),e.assetId=this.id,e.asset=this,e.shown=!1,this.getAssetFiles().push(e),this.clear(),this.capturedAtLocal??(this.capturedAtLocal=e.capturedAtLocal),this.rating??(this.rating=e.rating),this.durationMs??(this.durationMs=e.durationMs)}async assetFileForFile_(e,t){const i=await e.uri();if(null==i)return this.logger().throw("assetFileForFile_(): null uri",{f:e});const r=this.getAssetFiles().find((e=>e.uri===i));if(null!=r)return r;const s=new O.AssetFile;return this.addAssetFile(s),!0!==t?.skipUpsert?await s.upsertIfNeeded_(e):await s.setFile_(e),s}static getTags(e){return j.Tag.ops().all(j.Tag.query().select("Tag.*").join("AssetTag","AssetTag.tagId","Tag.id").where("AssetTag.assetId",e).orderByRaw("COALESCE(Tag.ordinal, Tag._path)"))}tagIds(e){return!0===e?.refresh&&(this.tags=void 0),this.tags?.map((e=>e.id))??N.AssetTag.dbl.pluckAllf((e=>e.select("tagId").where({assetId:this.id})))}getTags(e){return!0===e?.refresh&&(this.tags=void 0),this.tags??(this.tags=s.getTags(this.id))}tagPaths(){return this.getTags().map((e=>e.path.join("/"))).sort()}setTagIds(e){const t=this.tagIds({refresh:!0});if((0,u.eqlUnordered)(t,e))return void this.logger().debug("setTagIds(): no-op, tagIds unchanged");const i=e.filter((e=>!t.includes(e))),r=t.filter((t=>!e.includes(t)));return this.applyTagIdDeltas({tagIdsToAdd:i,tagIdsToRemove:r})}applyTagPathDeltas(e){return this.applyTagIdDeltas({tagIdsToAdd:j.Tag.findOrCreateByPathN(e.add??[]).map((e=>e.id)),tagIdsToRemove:j.Tag.findByPathN(e.remove??[]).map((e=>e.id))})}applyTagIdDeltas(e={}){const t=this.tagIds({refresh:!0}),i=(0,P.uniq)((0,C.toA)(e.tagIdsToAdd).filter((e=>(0,k.gt0)(e)&&!t.includes(e)))),r=(0,P.uniq)((0,C.toA)(e.tagIdsToRemove).filter((e=>(0,k.gt0)(e)&&t.includes(e))));if((0,P.isEmpty)(i)&&(0,P.isEmpty)(r))return this.logger().info("applyTagIdDeltas(): no-op, no changes",{currentTagIds:t,...e}),t;this.isActive()&&j.Tag.deltaAssetCountAndAncestors(t,-1),(0,P.isEmpty)(i)||N.AssetTag.dbl.runf((e=>e.insert(i.map((e=>({assetId:this.id,tagId:e})))).onConflict(["assetId","tagId"]).ignore())),(0,P.isEmpty)(r)||N.AssetTag.dbl.runf((e=>e.whereIn("tagId",r).andWhere({assetId:this.id}).delete())),this.tags=void 0;const s=(0,P.uniq)([...t,...i]).filter((e=>!r.includes(e)));return this.isActive()&&j.Tag.deltaAssetCountAndAncestors(s,1),s}getStreams(e){if(null==this.streams){const t=this.getTags();this.logger().info("getStreams(): fetched tags "+t,{limit:e});const i=t.map((t=>t.getAssetStream(this,e)));this.streams=(0,z.coalesceStreams)((0,P.compact)(i));for(const e of this.streams)for(const t of e.tags)t.getAncestors()}return this.streams}getBeforeAfterId(){const e=s.dbl.all(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",this.capturedAtLocal).orderBy("assetId"));this.afterId=e.find((e=>e.assetId>this.id)),this.beforeId=e.reverse().find((e=>e.assetIde.path))}getAssetFiles({refresh:e=!1}={}){return null!=this.id&&(e&&(this.assetFiles=void 0),this.assetFiles??(this.assetFiles=(0,_.sortBy)(O.AssetFile.ops().findBy({assetId:this.id}),(e=>[!(0,M.isTrue)(e.shown),-e.mtime])))),this.assetFiles??[]}setShown_(e,t){e instanceof O.AssetFile&&(this.getAssetFiles(),this.assetFiles?.some(((t,i)=>{const r=t.id===e.id||t.uri===e.uri;return r&&(this.assetFiles[i]=e),r})));const i=e instanceof O.AssetFile?e.id:e;if(this.getShown()?.id===i)return void this.logger().debug("setShown_(): no-op, already set",{afId:i});this.logger().info("setShown_()",{assetId:this.id,assetFileId:i}),(0,k.gt0)(this.id)&&(0,k.gt0)(i)||this.logger().throw("setShown_(): invalid IDs: "+(0,D.stringify)({assetId:this.id,assetFileId:i})+g.InternalErrorFlag);const r=Date.now();O.AssetFile.dbl.runf((e=>e.update({shown:0,updatedAt:r}).where({assetId:this.id}))).changes<=0&&this.logger().warn("setShown_(): all asset files were already unshown",{afId:i});const s=O.AssetFile.dbl.runf((e=>e.update({shown:1,updatedAt:r}).where({id:i})));1!==s.changes&&this.logger().throw("setShown_(): failed to update asset file: unexpected changed rows",{runResult:s});const n=this.assetFiles?.find((e=>e.id===i))??this.getAssetFiles({refresh:!0}).find((e=>e.id===i));if(null!=n){this.capturedAtLocal=n.capturedAtLocal,this.rating=n.rating,this.durationMs=n.durationMs;for(const e of this.assetFiles??[])e.shown=e.id===i;!0!==t?.skipUpsert&&this.upsert()}else this.logger().throw("setShown_(): failed to find shown asset file",{af:e})}getShown(e){return this.getAssetFiles(e)?.find((e=>(0,M.isTrue)(e.shown)))??this.getAssetFiles({refresh:!0})?.find((e=>(0,M.isTrue)(e.shown)))}getShownNativePath(){return this.getShown()?.getNativePath()}async getCapturedAts(){return(0,F.thenCollect)(this.getAssetFiles(),(e=>e.capturedAt()))}link(){return"/asset/"+this.id}sqAttrs(e=!0){return{...(0,T.assetSqImgAttrs)({assetId:this.assetIdish(),lazyLoad:e}),title:this.renderCaption(),...this.attrs}}async getImgAttrs(e,t,i=!1){if(null==this.imgAttrs&&(this.imgAttrs=new Map),null==this.imgAttrs.get(t)){const r=e.ap(this.id);await(0,m.thenMap)(r.readInfo(),(async e=>{e.mimetype.startsWith("video/")&&(this.poster=await r.posterLink())}));const s=!0;this.imgAttrs.set(t,await r.imgAttrs(t,s,i))}return this.imgAttrs.get(t)}async fitAttrs(e){return{...await this.getImgAttrs(e,E.ReducerNames.fit),...this.attrs}}isVideo(){if(null==this.assetFiles)throw new Error(".video called before getFiles()");return this.assetFiles.some((e=>e.isVideo))}videoAttrs(){return{controls:!0,autoplay:!0,poster:this.poster,...this.attrs}}async videoSources(){const e=[];let t;for(const i of this.getAssetFiles())e.some((e=>e.type===i.mimetype))||await i.exists()&&(t??(t=i),e.push({src:(0,T.assetVideoLink)({assetId:this.assetIdish(),assetFileId:i.id}),type:i.mimetype}));return e.some((e=>"video/mp4"===e.type))||null==t||e.unshift({src:(0,T.assetVideoLink)({assetId:this.assetIdish(),assetFileId:t.id})+".mp4",type:"video/mp4"}),e}async getPosixFiles(){return(0,F.thenCollect)(this.getAssetFiles(),(e=>e.posixFile_()))}async getExistingAssetFiles(){return(0,m.filterAsync)({name:"getExistingAssetFiles",arr:this.getAssetFiles(),f:e=>e.exists()})}async findOrCreateByFile(e){const t=await e.uri_();if(null==t)return;const i=(0,C.toA)(O.AssetFile.ops().findBy({assetId:this.id,uri:t}))[0];return(0,x.orElse)(i,(async()=>{const t=new O.AssetFile;return t.asset=this,t.assetId=this.id,await t.setFile_(e),t}))}partialSimpleAsset(){return{assetId:this.id,liked:(0,k.gte)(this.rating,v.Settings.likeRating.valueOrDefault),hidden:(0,M.isTrue)(this.hidden),excluded:null!=this.excludedAt,deleted:null!=this.deletedAt}}clear(){return this.imgAttrs=void 0,this.streams=void 0,this.tags=void 0,this.mergedTags.unset(),this}}t.Asset=U,s=U,r=new WeakSet,n=function(){return s.shownUnhidden().andWhere("version","<",f.AssetVersion)},a=function(){return this.beforeId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal","<",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId",order:"desc"}]))},o=function(){return this.afterId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",">",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"asc"},{column:"assetId",order:"asc"}]))},U.$tableName="Asset",U.$uniqueColumnName="id",U.$booleanFields=["shown","hidden"]},54017:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFile=void 0;const a=i(76760),o=i(19851),l=i(88158),u=i(45393),c=i(68852),d=i(81168),h=i(13991),f=i(54296),m=i(56519),p=i(76490),g=i(89724),y=i(98314),w=i(38835),v=i(8769),b=i(29882),S=i(95696),P=i(62105),_=i(74128),T=i(35721),M=i(69589),E=i(28874),D=i(28544),x=i(16170),k=i(45200),F=i(34238),C=i(87001),A=i(42233),I=i(21404),O=i(40958),L=i(17586),R=i(22573),N=i(38639),B=i(42659),j=i(33374),z=i(50357),V=i(75240),W=i(11371),U=i(55835),q=i(31586),H=i(68708),$=i(34666),G=i(89937),J=i(75020),K=i(64526),Y=i(41844),Z=i(43487),X=i(48723),Q=i(94710),ee=i(72761);class te extends ee.TimestampedModel{constructor(){super(...arguments),r.add(this),this.uriObj=(0,o.lazy)((()=>F.URI.parse(this.uri))),this.whyRejected=(0,o.lazy)((async()=>{const e=await this.posixFile_();return null==e?"invalid URI":!0===await this.isFileDeleted()?"deleted":(0,P.whyRejectFile)(e)})),this.posixFile_=(0,o.lazy)((async()=>S.PosixFile.for(await this.getNativePath())))}static outdatedQuery(e){let t=(e.q??this.query()).where("version","<",u.AssetFileVersion);return null!=e.maxUpdatedAt&&(t=t.andWhere("updatedAt","<",e.maxUpdatedAt)),t.andWhere((t=>{(0,O.isNotEmpty)(e.mountpoints)&&(t=t.whereIn("mountpoint",e.mountpoints));for(const i of e.uris)t=t.orWhereLike("uri",i+"%");return t})).orderBy("id")}static async nextOutdated(e=l.identity){return this.ops().findOne(e(this.outdatedQuery(await(0,A.currentVolumeRoots)())))}static async outdatedCount(e=l.identity){const t=this.outdatedQuery(await(0,A.currentVolumeRoots)());return this.dbl.pluckFirst(e(t.count("id")))}static shownAssetFileId(e){return this.dbl.pluckFirstf((t=>t.where({assetId:e,shown:1}).limit(1)))}static primaryForAssetId(e){return(0,q.gt0)(e)?te.ops().first(Z.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id").select("AssetFile.*").where({assetId:e,"AssetFile.shown":1})):void 0}static shownUnhidden({uriRoot:e}={}){let t=Z.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id");return(0,R.blank)(e)||(t=t.andWhereLike("AssetFile.uri",e+"%")),t}static recentAssetIdsByUriRoot(e,t,i=64){const r=Date.now()-t;return this.dbl.pluckAll(te.shownUnhidden({uriRoot:e}).distinct("AssetFile.assetId").where("AssetFile.updatedAt",">",r).orderBy("AssetFile.updatedAt","desc").limit(i))}static assetFileCountByMimeType(e){const t=te.shownUnhidden({uriRoot:e}).select("mimetype").countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"}).groupBy("mimetype").orderBy("mimetype");return this.dbl.all(t)}static assetFileCountWithMimeType(e,t){let i=te.shownUnhidden({uriRoot:t}).countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"});return i=e.endsWith("/")?i.andWhereLike("mimetype",e+"%"):i.andWhere("mimetype",e),this.dbl.first(i)}static assetFileCountByMimeTypeRoots(e=["image/","video/"],t){return e.map((e=>({mimeTypeRoot:e,assetFileCount:te.assetFileCountWithMimeType(e,t)?.assetFileCount??0})))}static children(e,t){const i=this.query().whereLike("uri",e+"/%").andWhere("uri","regexp",`^${(0,c.escapeRegExp)(e)}/[^/]+$}`);return this.ops().all(null==t?i:t(i))}static async sameShaInLibrary(e){if(null==this.db())return;const t=await e.sha(),i=await e.size();return null!=t&&null!=i?this.ops().allf((e=>e.where({sha:t,fileSize:i}).andWhereLike("uri",G.PS_LIBRARY_PROTOCOL+"%"))):void 0}static sameAssetFileInLibrary(e){return this.ops().allf((t=>t.where((0,H.pick)(e,"sha","fileSize")).andWhere((e=>e.whereLike("uri",G.PS_LIBRARY_PROTOCOL+"%"))).andWhere((t=>t.whereNot({id:e.id})))))}librarySiblings(){return this.getAsset()?.getAssetFiles().filter((e=>e.id!==this.id&&e.uri.startsWith(G.PS_LIBRARY_PROTOCOL)))}capturedAtLocale(e){return(0,g.fmtLocalDateShort)(this.capturedAtLocal,e)}get dominantColors(){return p.DominantColor.fromModeData(this)}set dominantColors(e){(0,H.assignAllFields)(this,p.DominantColor.toModeData(e))}get posixPathFromGrandparent(){return(0,U.map)(this.uriObj()?.fsPath,b.posixPathFromGrandparent)}async whyNotMatchesFile(e){const t=n(this,r,"m",s).call(this);if(null!=t)return t;if(null==this.fileSize||null==this.mtime)return"missing file metadata";if(null!=e){const t=await e.uri();if(null==t)return"file has no URI";if(!await(0,C.uriIsEquivalent)(this.uri,t))return"file URI mismatch"}try{const t=e??await this.posixFile_();if(!await t.exists())return"file is missing";const i=await this.fileFields_(t);return null==i?!0===await(t?.isDeleted())?"file is deleted":"file is unreadable":i.fileSize!==this.fileSize?"file size changed since last sync":(0,q.closeTo)(i.mtime,this.mtime,2*B.secondMs)?void 0:"file mtime changed since last sync"}catch(e){return(0,y.errorToS)(e)}}async matchesFile(e){const t=await this.whyNotMatchesFile(e);return this.logger().tap({level:"info",msg:"matchesFile()",result:null==t,meta:{whyNot:t}})}async whyNotInSyncWithFile(e){return E.Settings.forceSync.valueOrDefault?E.Settings.forceSync.key+"=true":this.version!==u.AssetFileVersion?"AssetFileVersion: "+this.version+" != "+u.AssetFileVersion:this.whyNotMatchesFile(e)}async inSyncWithFile(e){const t=await this.whyNotInSyncWithFile(e);return this.logger().tap({msg:"inSyncWithFile()",result:null==t,meta:{whyNotInSync:t}})}async fileFields_(e){const t=e??await this.posixFile_();return null==t?void 0:await(0,h.assetFileStatFields_)(t)}isInLibrary(){return this.uri.startsWith(G.PS_LIBRARY_PROTOCOL)}async isNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){const t=await this.whyNotNoop(e);return this.logger().tap({msg:"isNoop()",result:null==t,meta:{whyNotNoop:t}})}async whyNotNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){if(!0===e.forceSync)return"forceSync is true";if(!(0,q.gt0)(this.id))return"missing .id";if(!(0,q.gt0)(this.assetId))return"missing .assetId";{const e=await this.whyNotInSyncWithFile();if(null!=e)return e}if(await(0,Y.mayCopyAssetsToLibrary)()){const e=K.Library.instanceRequired_().assetFileRepository(),t=e.whyNotCopyFile(await this.posixFile_());if((0,R.blank)(t)&&null==await e.existingLibraryAssetFile(this))return"need to copy into library"}this.syncState=_.AssetFileSyncStates.noop}isVersionUpToDate(){return(0,$.gte)(this.version,u.AssetFileVersion)}async siblingCount(){return te.dbl.pluckFirstf((e=>e.count().where({assetId:this.assetId}).andWhereNot({id:this.id})))}async upsertIfNeeded_(e,t=(0,M.forceContextOrSetting)()){if(null!=e&&await this.setFile_(e),await this.matchesFile()&&(0,q.gt0)(this.id)&&!t.forceSync)return void(null==this.syncState&&(this.upsert(),this.syncState??(this.syncState=_.AssetFileSyncStates.noop)));const i=await this.isFileDeleted();if(!0===i)return this.syncState=_.AssetFileSyncStates.deleted,this.delete(),!0!==t.skipAssetRepair&&Q.Task.addOne("repairAsset",{assetId:this.assetId}),this;if(!1===i){const i=await this.updateFromFile_(e,t);return this.syncState??(this.syncState=null==i?_.AssetFileSyncStates.noop:_.AssetFileSyncStates.synced),this.upsert()}return this.syncState??(this.syncState=_.AssetFileSyncStates.skipped),this}async updateFileFields_(e){(0,H.assignFields)(this,await this.fileFields_(e))}async updateFromFile_(e,t=(0,M.forceContextOrSetting)()){const i=Date.now(),r=this.logger().addContext(".updateFromFile_()");if(null!=this.id&&!0!==t.forceSync&&await this.matchesFile(e))return void r.info("updateFromFile() no-op: up-to-date version and file stat matches since last update");if(null!=e&&await this.setFile_(e),null==e&&(e=await this.posixFile_()),null==e||await e.clear().notExists())return this.syncState=_.AssetFileSyncStates.deleted,void r.info("no-op, "+e+" is missing");const s=await(0,h.mkAssetFile_)(e);return s.uri!==this.uri&&((0,R.blank)(this.uri)||!0===this.uri?.startsWith("file:"))&&(this.logger().warn("updateFromFile() upgrading uri",{prior:this.uri,new:s.uri}),this.uri=s.uri),(0,H.assignAllFields)(this,(0,H.omit)(s,"uri")),this.version=u.AssetFileVersion,this.syncState=_.SyncFileStates.synced,r.elapsed("finished",Date.now()-i,this.toJSON()),this}async updateFromShaSibling_(e){const t=n(e,r,"m",s).call(e);if(null==t){if(await this.exists())return this.logger().debug("updateFromShaSibling",e),null!=e.sha&&await e.matchesFile()&&this.sha===e.sha?((0,H.assignFields)(this,(0,H.omit)(e,"id","posixFile","uriObj","shown","uri","mtime","fileSize","mountpoint","createdAt","updatedAt","updateCount",...te.$transientFields)),this.updateFileFields_()):this.updateFromFile_();this.logger().warn("updateFromShaSibling(): fail: file is missing")}else this.logger().warn("updateFromShaSibling() sibling is invalid",{whySiblingIsInvalid:t})}getAsset(){return this.asset??(this.asset=(0,q.gt0)(this.assetId)?Z.Asset.ops().findById(this.assetId):void 0)}exists(){return(0,k.uriExists)(this.uri,this.mountpoint)}async isFileDeleted(){return(await this.posixFile_())?.isDeletedUri(this.uri)}async accepted(){return(0,R.blank)(await this.whyRejected())}async setFile_(e){const t=await e.uri_();if(null==t)return this.logger().throw("setFile(): no URI for "+e);const i=await e.mountpoint();if(null!=this.uri&&!await(0,C.uriIsEquivalent)(t,this.uri))return this.logger().throw("setFile(): cannot reassign non-equivalent URI",{prior:this.uri,new:t,file:e.nativePath});const r=await e.uriObject_();return null==r?this.logger().throw("failed to create URI for "+e):(this.uri=t,this.uriObj.set(r),this.mountpoint=i?.nativePath,this.nativePath=e.nativePath,this.posixFile_.set(Promise.resolve(e)),this)}get basename(){return(0,R.blank)(this.uri)?void 0:decodeURIComponent(this.uri.slice(this.uri.lastIndexOf("/")+1))}posixFile(){return this.posixFile_().catch((()=>{}))}async getNativePath(){return(0,R.blank)(this.nativePath)&&(null==this.uri?this.logger().error(".getNativePath() called before .setFile_()"+w.InternalErrorFlag):this.nativePath=await(0,f.getAssetFileNativePath)(this)),this.nativePath}async capturedAt(){return null==this.nativePath&&await this.getNativePath(),D.CapturedAt.fromAssetFile(this)}async originalDownloadable({brief:e=!1}={}){const t=this.basename;if(!0===e)return null==t?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:`Download ${t}`,basename:t,description:"Download original"};const i=await this.posixFile_();return this.logger().tap({msg:"originalDownloadable()",level:"info",result:null==i||await i.isEmpty()?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:e?`Download ${i.base}`:(0,T.mkDownloadableTitle)(i,"original",this.isVideo?"video":"image",{width:this.width,height:this.height}),basename:i.base,description:"Download original",details:`(${(0,j.fmtDim)(this)} ${i.ext})`},meta:{posixFile:i}})}async downloadables(e,t){try{const i=await this.posixFile_();if(null==i)return[];const r=e.ap(this.assetId),s=[];if(await(0,m.thenMap)(this.originalDownloadable(),(e=>s.push(e))),this.isVideo)return s;if(!(0,N.isTrue)(this.shown)&&this.sha!==t)return s;const n=(0,O.compact)(await Promise.all([...await r.previewInfos()].reverse().filter((e=>e.reducer===W.ReducerNames.fit)).map((e=>(0,T.previewToDownloadable)(i.base,e)))));return s.push(...(0,O.uniqBy)(n,(e=>e.size))),s}catch(e){return(0,v.onError)("AssetFile.downloadables failed for "+this.uri,e),[]}}async pathInfo(){try{const e=F.URI.parse(this.uri),t=(0,U.map)((0,I.uriToTagPath)({uri:e,isFile:!0}),(e=>X.Tag.findByPath(e)));return this._pathInfo_(await(t?.toApiPathElements()))}catch(e){return void this.logger().warn("pathInfo(): failed",e)}}async _pathInfo_(e){const t=await this.posixFile_();if(null==t)return this.logger().throw("pathInfo(): no posixFile",{uri:this.uri});const i=t.nativePath,r=F.URI.parse(this.uri),s=await t.exists();if(null==e||(0,O.isEmpty)(e))return this.logger().warn("pathInfo(): failed to find existing Tag. Returning a simple path.",{uri:this.uri,nativePath:i,tagLineage:e}),{nativePath:i,pathElements:[],nativePathSuffix:i,pathSep:a.sep,exists:s};function n(){return(0,L.at)((0,L.at)(e,-1)?.tagPath,-1)}(0,z.eql)(e[0]?.tagPath,[J.TagRoots.fs])&&(e=e.slice(1));const o=r.scheme===G.PS_LIBRARY_SCHEME,l=o?r.path.split("/").slice(1):t.pathnames,u=l.pop(),c=[];for(;l.length>0&&(0,d.equalsIgnoreCase)(n(),(0,L.at)(l,-1));){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("added matching tag",t)}if(o&&n()===J.LibraryTagName){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("pslib: added matching library tag",t)}if(r.scheme===G.PS_LOCAL_FILE_SCHEME){const t=F.URI.parse(this.uri).authority;if(this.logger().debug("psfile: pop last?",{lastTagName:n(),thisVolSha:t}),n()===t){l.pop();const t=e.pop();c.unshift(t)}else this.logger().warn("weird: I expected to be able to include the volsha tag element, but it doesn't seem to match",{thisVolSha:t,tagVolSha:n()})}return this.logger().tap({msg:"pathInfo()",result:{nativePath:i,pathElements:c,nativePathSuffix:u,pathSep:a.sep,exists:s}})}async toApi(e,t){return(0,m.thenMap)(this.pathInfo(),(async i=>(0,H.reqValuedOrElse)({assetId:this.assetId,assetFileId:this.id,...i,mimetype:this.mimetype,shown:(0,N.isTrue)(this.shown),name:this.basename,width:this.width,height:this.height,rotation:this.rotation??0,fileSize:this.fileSize,mtime:this.mtime,downloadables:await this.downloadables(e,t),createdAtLocale:ie(this.createdAt),updatedAtLocale:ie(this.updatedAt)})))}get isVideo(){return(0,x.isVideoMimeType)(this.mimetype)}}function ie(e){return(0,U.map)(e,(e=>(0,V.fmtDuration)(Date.now()-e,1)+" ago"))}t.AssetFile=te,r=new WeakSet,s=function(){if((0,R.blank)(this.uri))return"blank uri";if((0,R.blank)(this.sha))return"blank sha";if(!(0,q.gt0)(this.width))return"missing width";if(!(0,q.gt0)(this.height))return"missing height";if(!(0,q.gt0)(this.capturedAtLocal))return"missing capturedAtLocal";if(!(0,q.gte0)(this.capturedAtPrecisionMs))return"missing capturedAtPrecisionMs";if(E.Settings.useImageHashes.valueOrDefault){const e=[];for(const t of["dctHash","diffHash","meanHash"])(0,R.blank)(this[t])&&e.push(t);if(1===e.length)return"missing image hash: "+e[0];if(e.length>1)return"missing image hashes: "+e.join(", ")}return this.isVersionUpToDate()?void 0:"outdated version"},te.$tableName="AssetFile",te.$uniqueColumnName="uri",te.$booleanFields=["shown"],te.$transientFields=["nativePath","syncState"]},48722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toAssetId=void 0;const r=i(76596),s=i(31586);t.toAssetId=function(e){const t=(0,s.toGt0)(e?.assetId)??(0,s.toGt0)(e?.id);if(null==e||null==t||!(0,s.isNumber)(e?.capturedAtLocal))return;const i=((0,s.toGt0)(e.v)??(0,s.toGt0)(e.updateCount)??(0,s.toGt0)(e.updatedAt)??0)%1e6,n={assetId:t,capturedAtLocal:e.capturedAtLocal,v:i};return(0,s.gt0)(e.durationMs)&&(n.durationHMS=(0,r.durationHMS)(e.durationMs)),n}},37094:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetRevision=void 0;const r=i(98553),s=i(67478),n=i(55046);class a extends n.Model{static insert(...e){return a.ops().insert(e.map((e=>({assetId:e.assetId,createdAt:Date.now(),field:e.field,op:e.op,_priorValueJson:(0,r.stringify)(e.priorValue),_newValueJson:(0,r.stringify)(e.newValue)}))))}get priorValue(){return(0,s.parseJSON)(this._priorValueJson)}get newValue(){return(0,s.parseJSON)(this._newValueJson)}}t.AssetRevision=a,a.$tableName="AssetRevision"},45295:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetTag=void 0;const r=i(55046);class s extends r.Model{$pk(){return this.assetId+":"+this.tagId}}t.AssetTag=s,s.$tableName="AssetTag",s.$uniqueColumnName="assetId,tagId",s.$useCache=!1,s.$pkColumnNames=["assetId","tagId"]},61204:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeMonthTag=t.normalizeDateTags=t.getMonthTags=void 0;const r=i(19851),s=i(50213),n=i(97352),a=i(75020),o=i(4407),l=i(48723),u=`'${a.TagRoots.When}' || char(31) || '%' || char(31) || '%' || char(31)`,c=u+" || '%' || char(31)",d=(0,r.lazy)((()=>(0,s.mkLogger)("model.DateTagNormalizer")));function h(){return l.Tag.ops().allf((e=>e.whereNotNull("ordinal").andWhereRaw("_path LIKE "+u+" AND _path NOT LIKE "+c).limit(2400)))}function f(e){const t=(0,n.mapGt0)(e.ordinal,(e=>(0,o.monthTagRef)((0,o.ordinalToMonth)(e))));null==t?d().warn("failed to fix tag (no monthTagRef)",{t:e}):t.name!==e.name&&(d().info("Fixing month name",{tagRef:t,tag:e}),e.changeName(t.name)),e.maybeUpsertDisplayName(t?.displayName)}t.getMonthTags=h,t.normalizeDateTags=async function(){for(const e of h())f(e)},t.normalizeMonthTag=f},95700:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runMaintenanceTasks=void 0;const r=i(19851),s=i(56038),n=i(28874),a=i(42659),o=i(41400),l=i(69032),u=i(61204),c=i(49796);t.runMaintenanceTasks=async function({force:e}={}){await d(),await(!0===e?h.refresh():h());try{await(!0===e?(0,l.forceRunTagMaintenance)():(0,l.runTagMaintenance)())}catch{}};const d=(0,r.lazy)((()=>(0,s.time)("db.normalizeDateTags",u.normalizeDateTags))),h=(0,r.lazy)((()=>(0,s.time)("db.Progress.vacuum",(()=>c.Progress.vacuum()))),2*a.hourMs);(0,o.later)((()=>{n.Settings.libraryDir.watchLater((()=>{d.unset(),h.unset()}))}))},55046:(e,t,i)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const s=i(57975),n=i(50213),a=i(7282),o=i(65211),l=i(40958),u=i(38639),c=i(45599),d=i(31586),h=i(68708),f=i(34666),m=i(54993),p=i(57038),g=i(94448),y=i(33572),w=i(63872);class v{constructor(){this.$instanceId=(0,a.isTest)()?(0,o.uid)():void 0}static get $ctor(){return this.$schema+"."+this.$tableName}static query(){return(0,p.knex)()(this.$tableName)}static queryBy(e){return this.query().where(e)}static queryOneBy(e){return this.queryBy(e)}static ops(){return this._ops??(this._ops=new w.ModelOps(this,this.db))}static get dbl(){return this.ops().dbl}static rows(){return this.ops().rows()}static truncate(){if((0,a.isProd)())throw new Error("rejecting attempt to truncate in prod");this.dbl.run("DELETE FROM "+this.$tableName)}static ucn(e){const t=this.$uniqueColumnName.split(",").map((t=>e[t]));return t.some((e=>null==e))?void 0:1===t.length?t[0]:t.join(",")}static hasId(e){return this.$pkColumnNames.every((t=>null!=e[t]))}static pickId(e){return(0,h.pick)(e,...this.$pkColumnNames)}$ops(){return this.class().ops()}class(){return this.constructor}$pk(){return(0,m.toS)(this.id)}$ucn(){return this.class().ucn(this)}$tableName(){return this.class().$tableName}$uid(){return`${this.$tableName()}(${this.id??this.$ucn()})${!0===this.shown?"!":""}`}logger(){return(0,n.mkLogger)(this.class().$schema+"."+(0,m.toS)(this.valueOf()))}[s.inspect.custom](){return{...this.$toShallowJSON(),$instanceId:this.$instanceId}}toString(){return this.$uid()}valueOf(){return this.$uid()}static fromJSON(e){return(0,y.fromJSON)(this,e)}static toJSON(e){return this.fromJSON(e).toJSON()}$toShallowJSON(){return this.$_toJSON({encodeBool:u.isTrue})}$toDbJSON(e){return this.$_toJSON({encodeBool:u.boolToInt,includeCtor:!1,includeTransient:!1,colNames:e})}$clone(){return(0,y.fromJSON)(this.class(),this.toJSON())}toJSON(){return this.$_toJSON({encodeBool:u.isTrue})}_get(e,t,i=!0){const r=this[e];return null===r?[e,null]:!(0,f.isPrimitive)(r)||!i&&(0,l.includes)(this.class().$transientFields,e)?void 0:(0,l.includes)(this.class().$booleanFields,e)?[e,t(r)]:[e,r]}$_toJSON({encodeBool:e,includeCtor:t=!0,includeTransient:i=!0,colNames:r}){const s=this.class(),n=(0,l.notEmptyOr)(r,s.ops().columnNames());return(0,h.fromEntries)(n.map((t=>this._get(t,e,i))),t?{$ctor:s.$ctor}:{})}insert(){return this.logger().debug("insert()",{self:this.toJSON()}),this.class().ops().insertOne(this)}update(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("update()",{self:this.toJSON()}),this.class().ops().updateOne(this)}upsert(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("upsert()",{self:this.toJSON(),arg:e}),this.class().ops().upsertOne(this)}$afterInsert(){}$beforeUpsert(){}$afterUpsert(){}reload(){return this.class().ops().reloadOne(this)}delete(){(0,d.gt0)(this.id)&&this.class().ops().delete([this.id])}}t.Model=v,r=v,v.$schema="models",v.$logger=(0,c.defer)((()=>(0,n.mkLogger)(r.$schema+"."+r.$tableName))),v.db=g.modelDb,v.$pkColumnNames=["id"]},94448:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryModelDbFile=t.modelDb=void 0;const r=i(15056),s=i(87290),n=i(19851),a=i(55835);t.modelDb=(0,n.lazy)((()=>{})),t.libraryModelDbFile=function(e){return(0,a.map)((0,s.libraryDataDirPosixFile)(e),(e=>(0,r.pathToDb)(e,"models")))}},33572:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toJSON=t.assignFromJSON=t.fromJSON=t.addModelClass=void 0;const r=i(50213),s=i(40958),n=i(22573),a=i(38639),o=i(97790),l=i(51926),u=new Map;function c(e){u.set(e.$ctor,e)}function d(e,t,i=[]){const r=e.class();for(const[n,o]of Object.entries(t)){if("$ctor"===n)continue;if(void 0===o)continue;const t=(0,l.stripPrefixes)(n,i);e[t]=null==o?o:(0,s.includes)(r.$booleanFields,t)?(0,a.isTrue)(o):o}return e}t.addModelClass=c,t.fromJSON=function(e,t){if(null==t)throw new Error("json is null");if(null!=e&&(0,n.notBlank)(e.$ctor)&&!u.has(e.$ctor)&&c(e),t instanceof e)return t;const i=(0,o.opt)(t.$ctor).flatMap((e=>u.get(e))).getOrElse((()=>e));if(t instanceof i)return t;const r=new i;return null==t?r:d(r,t,(0,s.uniq)([e.$tableName+".",i.$tableName+"."]))},t.assignFromJSON=d,t.toJSON=function e(t,i,s){if(null!=t)return Array.isArray(t)?t.map(((t,r)=>e(t,i,`${s}[${r}]`))):"function"==typeof t.toJSON?t.toJSON():void(0,r.mkLogger)("ModelJSON.toJSON()").warn("Failed",{m:t,key:s,mc:i.$ctor})}},63872:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ModelOps=void 0;const f=i(48884),m=i(19851),p=i(50213),g=i(81168),y=i(48299),w=i(12943),v=i(38835),b=i(34102),S=i(28874),P=i(40958),_=i(76790),T=i(22573),M=i(50357),E=i(96249),D=i(98553),x=i(55835),k=i(31586),F=i(68708),C=i(59455),A=i(86859),I=i(33572);t.ModelOps=class{constructor(e,t){r.add(this),this.model=e,this.db=t,s.set(this,void 0),n.set(this,!0),a.set(this,new y.WeakCache),o.set(this,new Set),this.columnNames=(0,m.lazy)((()=>this.db().tableInfo_().find((e=>(0,g.equalsIgnoreCase)(e.tableName,this.tableName))).columns.map((e=>e.name)))),this.updatableColumnNames=(0,m.lazy)((()=>(0,P.diff)(this.columnNames(),this.immutableColumnNames))),this.ucnFieldNames=(0,m.lazy)((()=>this.ucn.split(","))),d(this,s,(0,p.mkLogger)(`ModelOps(${e.$tableName})`),"f"),(0,I.addModelClass)(e),d(this,n,e.$useCache??!0,"f"),this.dbl=new A.DbRequest(this.db,e.$tableName),(0,b.ee)().on("clearCache",(()=>h(this,a,"f").clear())),(0,b.ee)().on("clearDbCache",(()=>h(this,a,"f").clear()))}clearDbCache(){h(this,a,"f").clear()}get $cache(){return h(this,a,"f")}$cachedByJson(e){if(null==e||!h(this,n,"f"))return;const t=this.$pickModelUcn(e);return(null==t?void 0:h(this,a,"f").get((0,D.stringify)(t)))??this.$cachedById(e.id)}$cachedById(e){return(0,k.gt0)(e)&&h(this,n,"f")?h(this,a,"f").get((0,D.stringify)(e))??h(this,a,"f").findEntry((t=>t.id===e)):void 0}get dbOpen(){return(0,x.mapOr)(this.db(),(e=>e.isOpen),(()=>!1))}get tableName(){return this.model.$tableName}query(){return this.model.query()}toDbValued(e){const t=this.model.fromJSON(e),i=(0,w.toDbValued)(t);return(0,F.pick)(i,...this.columnNames())}run(e){return this.dbl.run(e)}fromJSON(e){if((0,F.isEmptyObj)(e))return;const t=this.model.fromJSON(e);return h(this,r,"m",u).call(this,t)}fromJSONs(e){return(0,P.compact)(e.map((e=>this.fromJSON(e))))}first(e){return this.fromJSON(this.dbl.first(e))}firstf(e){return this.first(e(this.query()))}all(e=this.query()){return this.fromJSONs(this.dbl.all(e))}allf(e){return this.all(e(this.query()))}findOne(e){return this.fromJSON(this.dbl.first(e))}findOneBy(e){return this.findOne(this.model.query().where(e))}findById(e,t){return this.findOneBy({...t,id:e})}findByIds(e){e=(0,C.toA)(e).filter(k.gt0);const t=[],i=[];for(const r of e){const e=this.$cachedById(r);null!=e?t.push(e):i.push(r)}const r=(0,f.batches)(i,S.Settings.dbBatchSelectSize.valueOrDefault).map((e=>this.dbl.all(this.query().whereIn("id",e))));return(0,_.sortBy)([...t,...this.fromJSONs((0,E.flatten)(r))],(t=>e.indexOf(t.id)))}findBy(e){return this.all(this.model.queryBy(e))}findWhereIn(e,t){return this.all(this.model.query().whereIn(e,t))}rows(e){return this.count(e??this.model.query().count())}count(e){return(0,k.toGt0)(this.dbl.pluckFirst(e))??0}countf(e){return this.count(e(this.query()))}insert(e){return(0,C.toA)(e).map((e=>this.insertOne(e)))}upsertOne(e){return this.modelSupportsUpsert?this.upsert([e])[0]:this.insertOrUpdateOne(e)}insertOrUpdateOne(e){return null==e.id?this.insertOne(e):this.updateOne(e)}insertOne(e){if(this.model.hasId(e))throw new Error("insert called for "+(0,D.stringify)(e)+v.NonRetriableErrorFlag);const t=this.fromJSON(e);if(null==t)return h(this,s,"f").throw("insertOne(): fromJSON returned null"+v.InternalErrorFlag,{t:e});t instanceof this.model&&h(this,r,"m",u).call(this,t),t.$beforeUpsert();const i=t.$toDbJSON(this.columnNames()),n=this.dbl.runf((e=>e.insert(i)));return t.id=(0,k.toInt)(n.lastInsertRowid),t.$afterInsert(),t.$afterUpsert(),t}unsetField(e,t){return(0,x.map)(this.$cachedById(e),(e=>{e[t]=null})),this.dbl.runf((i=>i.where({id:e}).update(t,null)))}updateOne(e){if(null==e.id)throw new Error("update called for "+(0,D.stringify)(e)+v.NonRetriableErrorFlag+v.InternalErrorFlag);const t=this.model.fromJSON(e);t.$beforeUpsert();const i=t.$toDbJSON(this.updatableColumnNames());return this.dbl.runf((t=>t.where({id:e.id}).update(i))),t.$afterUpsert(),h(this,r,"m",u).call(this,t)??t}get ucn(){return(0,T.toNotBlank)(this.model.$uniqueColumnName)??"id"}get modelSupportsUpsert(){return null!=this.ucn&&"id"!==this.ucn}get ucnConstraint(){return`(${this.ucn})`}get immutableColumnNames(){return(0,P.uniq)([...this.ucnFieldNames(),"id","createdAt"])}onConflictClause(e){const t=this.immutableColumnNames,i=e.filter((e=>!t.includes(e))).sort().map((e=>`${e}=excluded.${e}`)).join(","),r=["ON CONFLICT",this.ucnConstraint];return(0,T.blank)(i)?r.push("DO NOTHING"):r.push("DO UPDATE SET",i),r.join(" ")}$pickModelUcn(e){const t={};for(const i of this.ucnFieldNames()){const r=e[i];if(null==r)return;t[i]=r}return t}reloadOne(e){if(h(this,o,"f").has(e.id))return;const t=this.$pickModelUcn(e);if(null!=t){const i=h(this,r,"m",u).call(this,e),s=this.findOneBy(t);if(null==s)return;return h(this,r,"m",l).call(this,i,s),i!==e&&h(this,r,"m",l).call(this,e,i),i}h(this,s,"f").warn(".reloadOne(): failed to reload "+(0,D.stringify)(e))}reload(e){const t=[],i=this.allf((i=>{for(const r of e){const e=this.model.hasId(r)?this.model.pickId(r):this.$pickModelUcn(r);null!=e?(t.push([r,e]),i=i.orWhere(e)):h(this,s,"f").warn("reload(): given insufficient partial model",{fragment:r})}return i})),n=[];for(const[e,a]of t){const t=i.find((e=>(0,M.eqlSubset)(a,e)));if(null==t)h(this,s,"f").warn("reload(): failed to find result in db",{prior:e,dbArr:i});else{const i=h(this,r,"m",u).call(this,e);h(this,r,"m",l).call(this,i,t),i!==e&&h(this,r,"m",l).call(this,i,t),n.push(t)}}return n}upsert(e){if(e=(0,P.compact)(e),!this.modelSupportsUpsert)return e.map((e=>this.insertOrUpdateOne(e)));const t=this.columnNames(),i=[];for(const s of(0,f.batches)((0,C.toA)(e),S.Settings.dbBatchUpsertSize.valueOrDefault)){const e=new Map,n=new Set,a=(0,P.compact)(s.map((e=>this.fromJSON(e))));for(const t of a){const i=(0,D.stringify)(this.$pickModelUcn(t));e.set(i,t),this.model.hasId(t)||n.add(i),t.$beforeUpsert()}h(this,r,"m",c).call(this,a.map((e=>e.$toDbJSON(t))));const o=this.reload(a),l=new Map(o.map((e=>[(0,D.stringify)(this.$pickModelUcn(e)),e])));for(const e of a){const t=(0,D.stringify)(this.$pickModelUcn(e)),r=l.get(t)??e;n.has(t)&&r.$afterInsert(),r.$afterUpsert(),i.push(r)}}return i}delete(e){const t=(0,C.toA)(e).filter(k.gt0);for(const e of t)h(this,o,"f").add(e);return h(this,a,"f").deleteValueIf((e=>t.includes(e.id))),this.run(this.model.query().delete().whereIn("id",t))}async batched(e){const t=e.batchSize??S.Settings.dbBatchSelectSize.valueOrDefault;let i,r;do{i=this.allf((i=>(i=e.qb(i),null!=r&&(i=i.andWhere("id",">",r)),i.orderBy("id","asc").limit(t)))),(0,P.isNotEmpty)(i)&&(r=Math.max(...i.map((e=>e.id))),await e.onResults(i))}while((0,P.isNotEmpty)(i))}},s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function(e,t){(0,F.assignFields)(e,t,{omitKeys:["$instanceId"],assignNullish:!0})},u=function(e){if(h(this,n,"f")){const t=this.$cachedByJson(e);if(null!=t)return h(this,r,"m",l).call(this,t,e),t;{const t=this.$pickModelUcn(e)??e.id;null!=t&&h(this,a,"f").set((0,D.stringify)(t),e)}}return e},c=function(e){const t=this.query().insert(e).toSQL(),i=new Set;for(const t of e)for(const e of(0,F.keys)(t))i.add(e);const s={sql:t.sql+" "+this.onConflictClause([...i.values()]),bindings:t.bindings};this.run(s);for(const t of e){const e=this.$cachedByJson(t);null!=e&&h(this,r,"m",l).call(this,e,this.model.fromJSON(t))}}},49796:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Progress=t.defaultMinCreatedAt=t.toPct=void 0;const r=i(48161),s=i(1708),n=i(48884),a=i(50213),o=i(28874),l=i(40958),u=i(42659),c=i(45599),d=i(98553),h=i(55835),f=i(31586),m=i(68708),p=i(67478),g=i(51926),y=i(59455),w=i(54993),v=i(76386),b=i(33572),S=i(55009),P=i(72761),_=(0,c.defer)((()=>(0,a.mkLogger)("model.Progress")));function T(e){return null==e||!(0,f.isNumber)(e)||e<0||e>100?void 0:(0,f.sigFigs)(e,3)}t.toPct=T;const M=(0,g.compressWhitespace)("\nSELECT\n p1.uri,\n p1.id as lastProgressId,\n p1.createdAt as lastStartedAt,\n p1.updatedAt as lastUpdatedAt,\n p3.lastCompletedAt\nFROM\n Progress AS p1\n JOIN (\n SELECT\n uri,\n max(updatedAt) AS lastUpdatedAt\n FROM\n Progress\n GROUP BY\n 1\n ) AS p2 ON p1.uri = p2.uri\n AND p1.updatedAt = p2.lastUpdatedAt\n LEFT JOIN (\n SELECT\n uri,\n max(completedAt) AS lastCompletedAt\n FROM\n Progress\n WHERE\n CAST(completedAt AS int) > 0\n GROUP BY\n 1\n ) AS p3 ON p1.uri = p3.uri\nGROUP BY\n p1.uri");function E(){const e=o.Settings.progressStaleDays.valueOrDefault;return e<=0?0:Date.now()-e*u.dayMs}t.defaultMinCreatedAt=E;class D extends P.TimestampedModel{static vacuum(e=o.Settings.progressRetentionDays.valueOrDefault*u.dayMs){const t=Date.now()-e,i=this.dbl.pluckAllf((e=>e.select("id").where("createdAt","<=",t)));for(const e of(0,n.batches)(i,o.Settings.dbBatchSelectSize.valueOrDefault))S.ProgressMeta.dbl.runf((t=>t.whereIn("progressId",e).delete())),D.dbl.runf((t=>t.whereIn("id",e).delete()))}static countCompletedDirectorySyncs(){return this.dbl.pluckFirstf((e=>e.where({state:"done"}).whereNotNull("completedAt").where("uri","like","ps%")))}static times(){return _().tap({msg:"times()",result:this.dbl.all({sql:M})})}static insertNew(e){const t=(0,h.map)(e.dek,d.stringify);return this.ops().insertOne({...(0,m.omit)(e,"dek"),dekJSON:t})}upsert(e){return null!=e&&this.assignFromPojo(e),super.upsert()}$beforeUpsert(){super.$beforeUpsert(),null==this.id&&(this.pid??(this.pid=s.pid),this.hostname??(this.hostname=(0,r.hostname)())),"done"===this.state&&(this.completedAt??(this.completedAt=Date.now())),this.completePct=T(this.completePct),this.incompletePct=T(this.incompletePct),this.scanningPct=T(this.scanningPct)}$afterUpsert(){super.$afterUpsert(),(0,v.tellWebProgressUpdated)()}toSyncState(){return{id:this.id,uri:this.uri,volume:this.volume,state:this.state,hed:this.hed,dek:this.dek,completePct:this.completePct,incompletePct:this.incompletePct,scanningPct:this.scanningPct}}get dek(){return(0,l.compactBlanks)((0,p.parseJSON)(this.dekJSON))}set dek(e){var t;this.dekJSON=(t=e,(0,d.stringify)((0,l.compactBlanks)((0,y.toA)(t))))}assignFromPojo(e){return(0,b.assignFromJSON)(this,(0,m.omit)(e,"volume","uri"))}getMeta(){return S.ProgressMeta.ops().allf((e=>e.where({progressId:this.id}).orderBy("createdAt")))}getPriorIncomplete(e=E()){return this.logger().tap({msg:"priorIncompleteProgress()",result:D.ops().firstf((t=>t.where({hostname:this.hostname,uri:this.uri,completedAt:null}).andWhere("createdAt",">",e).orderBy("updatedAt","desc")))})}getLastCompletedAt(e=E()){return D.dbl.pluckFirstf((t=>t.max("completedAt").where({uri:this.uri}).andWhere("createdAt",">",e)))}getLastIncompleteStartAt(){return D.dbl.pluckFirstf((e=>e.min("createdAt").where({uri:this.uri}).andWhere("createdAt",">",this.getLastCompletedAt()??0)))}setMeta(e,t){return this.logger().debug("setMeta()",{progressId:this.id,name:e,value:t}),S.ProgressMeta.ops().upsertOne({progressId:this.id,name:e,value:t})}setMetaRecord(e){const t=this.getMeta(),i=(0,l.diff)(t.map((e=>e.name)),Object.keys(e));this.logger().debug("setMetaRecord()",{progressId:this.id,keysToDelete:i,record:e}),S.ProgressMeta.ops().upsert((0,m.entries)(e).map((([e,t])=>({progressId:this.id,name:e,value:(0,w.toS)(t)})))),(0,l.isNotEmpty)(i)&&S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).whereIn("name",i).delete()))}deleteMeta(...e){return this.logger().debug("deleteMeta()",{progressId:this.id,names:e}),S.ProgressMeta.dbl.runf((t=>t.whereIn("name",e).andWhere({progressId:this.id}).delete()))}deleteAllMeta(){return this.logger().debug("deleteAllMeta()",{progressId:this.id}),S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).delete()))}getMetaAsRecord(){return this.logger().tap({msg:"getMetaAsRecord()",result:(0,m.fromEntries)(this.getMeta().map((e=>[e.name,e.value])))??{}})}}t.Progress=D,D.$tableName="Progress",D.$uniqueColumnName="id"},55009:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressMeta=t.ProgressMetaNames=t.DirSyncProgressMetaNames=void 0;const r=i(50989),s=i(72761);t.DirSyncProgressMetaNames=(0,r.strEnum)("lastScannedDirectory","scannedDirectoryCount","completedDirectoryScan","enqueuedStaleFiles","processedImageCount","processedVideoCount","completedDirectorySync"),t.ProgressMetaNames=(0,r.strEnum)(...t.DirSyncProgressMetaNames.values);class n extends s.TimestampedModel{}t.ProgressMeta=n,n.$tableName="ProgressMeta",n.$uniqueColumnName="progressId,name"},39604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.upsertToShaBlockslist=t.upsertFileToShaBlockslist=t.isShaBlockslisted=t.notBlocklistedSha=void 0;const r=i(19851),s=i(50213),n=i(95696),a=i(40958),o=i(22573),l=i(86859),u=i(94448),c=(0,r.lazy)((()=>(0,s.mkLogger)("model.ShaBlocklist"))),d=(0,r.lazy)((()=>new l.DbRequest(u.modelDb,"ShaBlocklist")));function h(e){return null!=(0,u.modelDb)()&&!(0,o.blank)(e)&&c().tap({msg:"isShaBlockslisted",result:null!=d().pluckFirstf((t=>t.where({sha:e}).limit(1))),meta:{sha:e}})}function f(...e){if(null==u.modelDb.prior())return;const t=(0,a.uniq)(e).map((e=>({sha:e})));return(0,a.isEmpty)(t)?void 0:d().upsert((e=>e.insert(t)))}t.notBlocklistedSha=async function(e){if(null==(0,u.modelDb)())return null;const t=h(await n.PosixFile.for(e).sha());return null==t?null:!t},t.isShaBlockslisted=h,t.upsertFileToShaBlockslist=async function(e){if(null==(0,u.modelDb)())return;const t=await n.PosixFile.for(e).sha();return null==t?void 0:f(t)},t.upsertToShaBlockslist=f},48723:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Tag=t.UpdateTagAssetCountTimeName=void 0;const a=i(56038),o=i(34102),l=i(19851),u=i(50213),c=i(36372),d=i(97352),h=i(28874),f=i(81168),m=i(42231),p=i(75020),g=i(40958),y=i(22573),w=i(42659),v=i(41400),b=i(50357),S=i(55835),P=i(31586),_=i(34666),T=i(20214),M=i(51926),E=i(59455),D=i(12168),x=i(6186),k=i(57038),F=i(21074),C=i(7656),A=i(43487),I=i(48722),O=i(45295),L=i(98784),R=i(41507),N=i(72761),B=4*w.secondMs,j=(0,l.lazy)((()=>(0,u.mkLogger)("model.Tag")));(0,v.later)((()=>{(0,o.ee)().on("clearCache",(()=>z.clear())),(0,o.ee)().on("clearDbCache",(()=>z.clear()))})),t.UpdateTagAssetCountTimeName="db.updateTagAssetCountTimeName";class z extends N.TimestampedModel{constructor(){super(...arguments),this.displayPath=(0,l.lazy)((()=>{const e=this.getParent();return(0,g.compactBlanks)([...null==e?[]:e.displayPath(),this.displayName])})),this.ancestorIds=(0,l.lazy)((()=>0===this.parentId||null==this.parentId?[]:r.dbl.pluckAll({sql:(0,M.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.id","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}}))),this.firstNonInterstitialTagId=(0,l.lazy)((()=>{if(!this.isRoot&&0===this.directAssetCount()&&1===this.getChildrenCount()){const e=this.getChildren();if(1===e?.length)return e[0].firstNonInterstitialTagId()}return this.id})),this.directAssetCount=(0,l.lazy)((()=>0===this.id?0:A.Asset.dbl.pluckFirst(A.Asset.shownUnhidden().join("AssetTag","AssetTag.assetId","Asset.id").where("AssetTag.tagId",this.id).countDistinct("Asset.id"))))}static orderBy(e){return e.orderByRaw("COALESCE(ordinal, _path) COLLATE NOCASE")}static clear(){this.root.unset(),this.roots.unset(),this._upsertDefaultRoots.unset(),this.ops().clearDbCache()}static validate_(){return(0,a.timeSync)("Tag.validate_",(()=>{r.clear();for(const e of this.ops().allf((e=>e.whereRaw("id = parentId")))){j().warn(`Tag ${e.id} has itself as parentId. Attempting to fix...`);const t=e.path.slice(0,-1),i=(0,g.isEmpty)(t)?void 0:this.findOrCreate(t);e.update({parentId:i?.id??null})}for(const e of r.roots())e.validate_([])}))}validate_(e){const t=this.path;if(!(0,b.eql)(t.slice(0,-1),e))throw new Error(`Tag:${this.id} path ${t.join("/")} does not match expected parent ${e.join("/")}`);for(const e of this.getChildren())e.validate_(t)}static deltaAssetCountAndAncestors(e,t=1){return r.incrAssetCount(r.selfAndAncestorIds(e),t)}static incrAssetCount(e,t=1){(0,g.isEmpty)(e)||r.dbl.runf((i=>i.whereIn("id",e).andWhereNot({assetCount:null}).update({assetCount:(0,k.knex)().raw("assetCount + "+Math.round(t)),updatedAt:Date.now()})))}static selfAndAncestorIds(e){const t=(0,E.toA)(e).filter(P.gt0);return r.dbl.pluckAll({sql:(0,M.compressWhitespace)("WITH RECURSIVE ancestors(id) AS ("," SELECT id FROM Tag where id in "+(0,F.sqlWhereInClause)(t.length)," UNION ALL"," SELECT Tag.parentId as id"," FROM Tag, ancestors"," WHERE Tag.id = ancestors.id",")","SELECT distinct(id)","FROM ancestors","WHERE id IS NOT NULL"),bindings:t})}static updateAssetCount(e){if((0,P.gt0)(e))return(0,a.timeSync)(t.UpdateTagAssetCountTimeName,(()=>{const t=r.dbl.pluckFirst({sql:C.RecursiveAssetCountForTagQuery,bindings:{tagId:e}});r.dbl.runf((i=>i.update({assetCount:t,updatedAt:Date.now()}).where({id:e}))),j().debug("Updated asset counts for tag ",{tagId:e,assetCount:t})}))}static findByIdOrPath(e,t){return 0===e?r.root():(0,P.gt0)(e)?this.findById(e):this.findByPath(t)}static findById(e){return 0===e?r.root():this.ops().findById(e)}static findByPath(e){if((0,g.isEmpty)(e))return r.root();const t=(0,m.joinTagPath)(e);return this.ops().firstf((e=>e.whereLike("_path",t)))}static findByPathN(e){const t=(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,y.toNotBlank)((0,m.joinTagPath)(e))));return(0,g.compact)(t.map((e=>this.findByPath(e))))}static getPagedAssets(e,t){const i=new r;return i.id=e,i.getPagedAssetIds(t)}static findOrCreate(e){if((0,g.isEmpty)(e))throw new Error("empty tagPath");const t=this.findByPath(e);if(null!=t)return t;const i=n(this,r,"m",s).call(this,e),a=i.depth<=1?void 0:this.findOrCreate(e.slice(0,-1));return(0,S.map)(a,(e=>i.parentId=e.id)),this.ops().upsertOne(i)}static findOrCreateByPathN(e){return(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,m.joinTagPath)(e))).map((e=>this.findOrCreate(e)))}clear(){return this.parent=void 0,this.root=void 0,this.children=void 0,this.ancestors=void 0,this.assets=void 0,this.relatedAssets=void 0,this.ancestorIds.unset(),this}$afterInsert(){L.TagFts.insertFts([this])}siblingPath(e){return(0,m.joinTagPath)([...this.parentPath,e])}changeName(e){return this.changePath(this.siblingPath(e))}maybeUpsertDisplayName(e){return(0,y.blank)(e)||e===this._displayName?void 0:this.upsert({_displayName:e})}changePath(e,t=!0){const i=this._path,s=r.findByPath((0,m.splitTagPath)(e));this.logger().info("changePath(): ",{priorPath:i,newPath:e,existingSibling:s});try{if(null==s)r.dbl.runf((t=>t.whereLike("_path",i+"%").update({updatedAt:Date.now(),_path:(0,k.knex)().raw("REPLACE(_path, ?, ?)",[i,e])}))),this._path=e;else{e=s._path,this.logger().info("changePath(): replacing with sibling",e),O.AssetTag.dbl.upsert((e=>e.where({tagId:this.id}).update({tagId:s.id}))),O.AssetTag.dbl.runf((e=>e.where({tagId:this.id}).delete()));for(const e of this.getChildren())e.changePath((0,m.joinTagPath)([...s.path,e.name]),!1);r.dbl.runf((e=>e.where({parentId:this.id}).update({parentId:s.id}))),this.delete()}}finally{t&&r.clear()}}get name(){const e=this.path;return e[e.length-1]}get path(){return(0,m.splitTagPath)(this._path)}get displayName(){return(0,y.toNotBlank)(this._displayName)??this.name}get isRoot(){return 0===this.id}get depth(){return this.path.length}get parentPath(){return this.path.slice(0,-1)}get sortBy(){return[this.depth,null==this.ordinal?2**51:this.ordinal,this.path.map((e=>e.toLowerCase()))]}$childrenQuery(){return r.orderBy(r.query().where({parentId:this.id}))}$assetsQuery(){return A.Asset.shownUnhidden().columns("Asset.*").join("AssetTag","AssetTag.assetId","Asset.id").where({tagId:this.id})}$selectAssetIdColumns(e){return e.clearSelect().select({assetId:"Asset.id",capturedAtLocal:"Asset.capturedAtLocal",updateCount:"Asset.updateCount",durationMs:"Asset.durationMs"})}$assetIdsQuery(){return this.$selectAssetIdColumns(this.$assetsQuery())}setAncestors(e){this.ancestors=e,this.parent=e[e.length-1],(0,S.map)(this.parent,(t=>t.setAncestors(e.slice(0,-1))))}async toApiPathElements(){return(0,T.thenCollect)(this.getAncestorsAndSelf(),(e=>e.toPathTag()))}toPathTag(){return{tagPath:this.path,displayName:this.displayName}}toApiTag(){return{tagId:this.id,tagPath:this.path,displayPath:this.displayPath(),description:this.description,assetCount:this.assetCount}}toStringId(){return"Tag("+this.path.join("/")+")"}getParent(){if(!this.isRoot)return null!=this.parentId&&null==this.parent?this.parent=r.findById(this.parentId):this.parent}getPagedChildren(e){if(0===this.id){const t=e.offset??0,i=t+(e.limit??this.children.length);return[...this.children].slice(t,i)}const t=this.$childrenQuery();return(0,d.mapGt0)(e.offset,(e=>{t.offset(e)})),(0,d.mapGt0)(e.limit,(e=>{t.limit(e)})),r.ops().all(t)}getChildrenCount(){return null!=this.children?this.children.length:r.dbl.pluckFirstf((e=>(this.isRoot?e.whereNull("parentId"):e.where({parentId:this.id})).count()))}getChildren(){return this.isRoot||(this.children=r.ops().all(this.$childrenQuery()),this.children.forEach((e=>{e.parent=this}))),this.children}link(){return"/tag/"+this.path.map(encodeURIComponent).join("/")}get rootName(){return this.path[0]}get ancestorsAndSelf(){return[...this.ancestors,this]}getAncestors(){return this.ancestors??(this.ancestors=this._getAncestors())}getAncestorsAndSelf(){return[...this.getAncestors(),this]}_getAncestors(){return 0===this.parentId||null==this.parentId?[]:r.ops().all({sql:(0,M.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.*","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}})}getPagedAssetIds(e){let t=this.$assetIdsQuery();return t=t.limit(p.ThumbsPerSample),(0,P.gt0)(e.offset)&&(t=t.offset(e.offset)),t=t.orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId"}]),(0,g.compact)(A.Asset.dbl.all(t).map(I.toAssetId))}getAssets(){const e=this.$assetsQuery().orderBy("capturedAtLocal","desc");return A.Asset.ops().all(e)}async assetCountDesc(e){const t=this.assetCount;return(null==t||null==e||e.length===t||0===e.length?"":(0,D.fmt)(e.length)+" of ")+(0,D.plur)(t,"asset")}getAssetCount(){return 0===this.id?r.dbl.pluckFirst({sql:(0,M.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," Asset","WHERE"," Asset.shown = 1"," AND Asset.excluded = 0"," AND Asset.hidden = 0"," AND Asset.deletedAt IS NULL")}):r.dbl.pluckFirst({sql:C.RecursiveAssetCountForTagQuery,bindings:{tagId:this.id}})}$assetStreamQuery(e,t,i){let r=this.path[0]===p.TagRoots.When?A.Asset.shownUnhidden():this.$assetsQuery();return r=r.distinct().where("capturedAtLocal",i,e.capturedAtLocal).andWhereNot("Asset.id",e.id).limit("="===i?2*t:t),"="===i?r.orderByRaw(`ABS(Asset.id-${e.id})`):r.orderBy([{column:"capturedAtLocal",order:">"===i?"asc":"desc"},"Asset.id"])}getAssetStream(e,t){t=(0,P.gt0)(t)?t:p.BeforeAfterStreamLimit;const[i,r,s]=["<","=",">"].map((i=>(0,g.compact)(A.Asset.ops().all(this.$assetStreamQuery(e,t,i)).map(I.toAssetId))));for(const t of r)t.assetIdA.Asset.shownUnhidden(this.$selectAssetIdColumns(r)).distinct().join("Asset","Asset.id","AssetTag.assetId").join("Tag","Tag.id","AssetTag.tagId").whereLike("_path",this._path+"%").orderByRaw((0,c.prngOrderByClause)(e+(this.id??0),"Asset.id",i)).limit(t))).map(I.toAssetId));return this.logger().debug(this.path+": Found "+r.length+" related assets"),r}get attrs(){return{href:this.link(),title:this.name}}}t.Tag=z,r=z,s=function(e){const t=new r;t._path=(0,m.joinTagPath)(e);const i=e[e.length-1];return"object"==typeof i&&((0,y.mapNotBlank)(i.displayName,(e=>t._displayName=e)),(0,P.mapNumeric)(i.ordinal,(e=>t.ordinal=e)),(0,y.mapNotBlank)(i.description,(e=>t.description=e)),(0,P.mapNumeric)(i.releasedAt,(e=>t.releasedAt=e))),t},z.$tableName="Tag",z.$uniqueColumnName="_path",z.$useCache=!0,z.cmp=(e,t)=>(0,_.cmp)([e.ordinal??Number.MAX_SAFE_INTEGER,...e.path],[t.ordinal??Number.MAX_SAFE_INTEGER,...t.path]),z.root=(0,l.lazy)((()=>{const e=new r;return e.id=0,e._path=m.TagSep,e.parentId=void 0,e.children=r.roots().filter((e=>!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.name)&&!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.description??""))),e.ancestors=[],e.assetCount=A.Asset.shownCount(),e.upsert=()=>{throw new Error("upsert not supported on root")},e}),B),z._upsertDefaultRoots=(0,l.lazy)((()=>r.ops().upsert(x.Roots.map((e=>({_path:(0,m.joinTagPath)([e.name]),ordinal:e.ordinal})))))),z.roots=(0,l.lazy)((()=>{r._upsertDefaultRoots();const e=r.ops().all(r.orderBy(r.query().whereNull("parentId")));for(const t of e)t.parentId=void 0,t.ancestors=[];return e}),B);const V=(0,l.lazy)((()=>A.Asset.dbl.pluckFirstf((e=>e.count()))),w.minuteMs)},98784:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagFts=void 0;const r=i(38156),s=i(3127),n=i(40958),a=i(41400),o=i(94715),l=i(55046),u=i(48723);class c extends l.Model{static insertFts(e){try{const t=e.filter((e=>null!=e.parentId)).map((e=>({rowid:e.id,root:(0,s.tag_fts_root)(e._path),path:(0,s.tag_fts_path)(e._path)})));(0,n.isEmpty)(t)||this.dbl.runf((e=>e.insert(t)))}catch(e){this.$logger().warn("Failed to update tag_fts",{error:e})}}static async rebuild(){const e=new r.PushProgressObserver({op:"Rebuilding tag search index"},u.Tag.dbl.pluckFirstf((e=>e.count("*")))),t=this.dbl.db();o.Migrations.create_tag_fts(t.db),await u.Tag.ops().batched({qb:e=>e,onResults:t=>(this.$logger().throwIfAborted_(),this.insertFts(t),e.incrProgress(t.length),(0,a.delay)(1))}),e.completed()}}t.TagFts=c,c.$tableName="tag_fts",c.$uniqueColumnName="rowid",c.$booleanFields=[]},41507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.coalesceStreams=t.TaggedAssetStream=t.cmpAssetDesc=t.cmpAssetAsc=void 0;const r=i(48884),s=i(50213),n=i(28874),a=i(40958),o=i(76790),l=i(31586),u=i(34666),c=i(20214),d=i(59455);t.cmpAssetAsc=(e,t)=>(0,u.cmp)([e.capturedAtLocal,e.id],[t.capturedAtLocal,t.id]),t.cmpAssetDesc=(e,t)=>(0,u.cmp)([t.capturedAtLocal,t.id],[e.capturedAtLocal,e.id]),t.TaggedAssetStream=class{constructor(e,t,i,r){this.tags=e,this.before=t,this.after=i,this.limit=r,this.logger=()=>(0,s.mkLogger)("model.TaggedAssetStream("+this.toString()+")"),this.logger().info("new",this.toJSON())}vacuum(){(0,o.sortByInPlace)(this.before,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainFirstN)(this.before,this.limit),(0,o.sortByInPlace)(this.after,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainLastN)(this.after,this.limit)}toString(){return this.tags.map((e=>e.path.join("/"))).join(",")}valueOf(){return this.toString()}get length(){return(0,d.toA)(this.before).length+(0,d.toA)(this.after).length}leftPad(e){return[...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+1),capturedAtLocal:-1,v:0}))),...e]}rightPad(e){return[...e,...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+this.limit+1),capturedAtLocal:-1,v:0})))]}toJSON(){return{tags:this.tags.map((e=>e.toString())),assetIdsAfter:this.after,assetIdsBefore:this.before}}mergeWith(e){(0,a.pushUniqBy)(this.tags,e.tags,(e=>e.path)),(0,a.pushUniqBy)(this.before,e.before,(e=>e.assetId)),(0,a.pushUniqBy)(this.after,e.after,(e=>e.assetId)),this.logger().debug("mergeWith() complete",{tas:e.toJSON(),tags:this.tags.map((e=>e.path)),beforeIds:this.before,afterIds:this.after})}async toApi(){return this.vacuum(),this.logger().tap({msg:"toApi()",result:{tags:await(0,c.thenCollect)(this.tags,(e=>e.toApiTag())),assetIdsAfter:this.leftPad(this.after),assetIdsBefore:this.rightPad(this.before)}})}streamCoeff(e){return this.logger().tap({msg:"streamCoeff",meta:{this:this.tags.map((e=>e.path)),tas:e.tags.map((e=>e.path))},result:(0,r.diceCoeff)([...this.before,...this.after],[...e.before,...e.after],(e=>e.assetId))})}},t.coalesceStreams=function(e){const t=n.Settings.minStreamCorrPct.valueOrDefault/100,i=[],s=e.filter((e=>e.length>5));for(const e of s){const s=(0,r.greatestBy)(i,(i=>(0,l.gtOrElse)(i.streamCoeff(e),t)));null==s?i.push(e):s.mergeWith(e)}return i}},94710:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Task=t.StaleTaskError=t.InvalidTaskError=t.TaskNames=t.Tasks=t.testTask=void 0;const c=i(78474),d=i(22454),h=i(23560),f=i(12089),m=i(76740),p=i(22911),g=i(99331),y=i(31562),w=i(38835),v=i(70025),b=i(8769),S=i(74128),P=i(28874),_=i(37692),T=i(40958),M=i(22573),E=i(42659),D=i(45599),x=i(98553),k=i(49769),F=i(68708),C=i(50989),A=i(59455),I=i(58723),O=i(34274),L=i(90901),R=i(61989),N=i(93755),B=i(69032),j=i(55046);t.testTask=(0,f.shim1)({name:"testTask",impl:async e=>{}}),t.Tasks={applyDeleted:I.applyDeleted,applyExcluded:I.applyExcluded,runTagMaintenance:B.runTagMaintenance,repairAsset:async function(e){e.forceSync=!0,e.skipPreviews=!0,e.skipAssetTagging=!0;const t=await(0,R.updateAsset_)(e);return(0,T.isNotEmpty)(t?.assetIdsToUpdate)&&q.add(t?.assetIdsToUpdate.map((t=>({fn:"repairAsset",args:{...e,assetId:t},priority:W.repairAsset+1})))),null!=t&&!0!==t.deleted&&(0,M.blank)((0,A.toA)(t.rejected).join(""))&&(0,M.blank)(t.error)&&q.addOne("assetPostUpsertTasks",(0,F.omit)(e,"skipPreviews","skipAssetTagging")),t},assetPostUpsertTasks:L.assetPostUpsertTasks,updateAssetFile:N.updateAssetFile_,syncFile:O.importFileToResult_,testTask:t.testTask},t.TaskNames=(0,C.strEnum)(...(0,F.keys)(t.Tasks));class z extends Error{}t.InvalidTaskError=z;class V extends Error{}t.StaleTaskError=V;const W={applyDeleted:16,applyExcluded:16,runTagMaintenance:14,repairAsset:12,assetPostUpsertTasks:10,updateAssetFile:8,syncFile:0,testTask:-1},U=["repairAsset"];class q extends j.Model{constructor(){super(...arguments),r.add(this),o.set(this,(0,D.defer)((()=>new m.Abortable)))}static countTaskNames(){const e={};for(const t of s.dbl.allf((e=>e.select("fn").count().groupBy("fn"))))e[t.fn]=t["count(*)"];return e}static orderBy(e){return e.orderBy([{column:"priority",order:"desc"},{column:"retries",order:"desc"},{column:"id",order:"asc"}])}static count(){return s.dbl.pluckFirstf((e=>e.count("id")))}static freeSlots(){return P.Settings.taskListCap.valueOrDefault-s.count()}static countByFn(e){return s.dbl.pluckFirstf((t=>t.where({fn:e}).count("id")))}static nextByFn(e,t=(e=>e)){return s.ops().allf((i=>s.orderBy(t(i.where({fn:e})))))}set args(e){this.argsJSON=(0,x.stringify)(e)}get args(){const e=(0,x.parseJSON)(this.argsJSON);return(0,F.notEmptyObj)(e)&&(e.halt=u(this,o,"f").call(this)),e}get isSerial(){return U.includes(this.fn)}toString(){return`Task#${this.fn}(${this.argsJSON})`}static addOne(e,t){return s.add([{fn:e,args:t}])[0]}static add(e,t=!1){if((0,T.isEmpty)(e))return[];const i=s.ops().upsert(e.map((e=>({fn:e.fn,argsJSON:(0,x.stringify)(e.args)})),t));return s.ee.emit("added",i),(0,h.isTaskListManager)()||(0,_.addStateEvent)("checkTasks"),i}$beforeUpsert(){this.priority??(this.priority=W[this.fn]),this.retries??(this.retries=P.Settings.maxRetries.valueOrDefault)}donePromise(){return(0,h.isTaskListManager)()?(0,k.getOrSet)(u(s,s,"f",n),this.id,(()=>new p.Deferred(this.toString(),{payload:this}))):(0,y.untilTrue)((()=>null==s.ops().findById(this.id)),{intervalMs:E.secondMs})}abort(e){this.logger().warn("aborting task",{reason:e,task:this}),u(this,o,"f").call(this).abort(e),this.delete(),(0,M.blank)(this.args.path)||(0,S.syncReport)().onProgress({path:this.args.path,from:this.fn,state:S.SyncFileStates.failed,details:e})}async _run(){if(this.retries<0)throw this.logger().warn(".run(): too many retries"+w.InternalErrorFlag,{job:this}),this.delete(),new z;if(!u(this,r,"m",l).call(this))throw this.logger().warn(".run(): someone already started this task",{job:this}),new V;try{const e=Date.now(),i=await t.Tasks[this.fn](this.args);return this.logger().throwIfAborted_(u(this,o,"f").prior()),s.taskResolvedCounts.incr(this.fn),s.ee.emit("resolved",this,i,Date.now()-e),this.delete(),u(s,s,"f",n).get(this.id)?.resolve(i),i}catch(e){if((0,g.ending)())throw this.logger().info("task failed, but we're ending. We'll leave it for next time.",{task:this}),e;throw s.taskRejectedCounts.incr(this.fn),(0,v.isRedoableError)(e)?(this.retries++,this.priority--,this.upsert()):!0===(0,v.isRetriableError)(e)&&this.retries>=0?this.logger().warn("run failed, but we can retry it later",{task:this,error:e}):(s.ee.emit("rejected",this,e),this.delete(),u(s,s,"f",n).get(this.id)?.reject(e),(0,b.onError)(this.toString()+" failed",e)),e}finally{u(s,s,"m",a).call(s)}}}t.Task=q,s=q,o=new WeakMap,r=new WeakSet,a=function(){for(const[e,t]of u(this,s,"f",n).entries())t.isSettled&&u(this,s,"f",n).delete(e)},l=function(){const e=this.retries;if(1===s.dbl.runf((t=>t.where({id:this.id,retries:e}).update({retries:e-1}))).changes)return--this.retries,!0;{const e=this.toJSON(),t=this.reload();return this.logger().warn(".#decrRetries(): someone already started this task",{before:e,reloaded:t}),!1}},q.$tableName="Task",q.$uniqueColumnName="fn,argsJSON",q.$useCache=!1,q.taskResolvedCounts=new d.CountingSet,q.taskRejectedCounts=new d.CountingSet,q.ee=new c.EventEmitter,n={value:new Map}},72761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimestampedModel=void 0;const r=i(97352),s=i(40958),n=i(31586),a=i(59455),o=i(55046);class l extends o.Model{static touch(e,t={}){t.updatedAt??(t.updatedAt=Date.now()),delete t.id;const i=(0,a.toA)(e).filter(n.gt0);return(0,s.isEmpty)(i)?void 0:this.dbl.runf((e=>e.whereIn("id",i).update(t)))}get createdAtDate(){return(0,r.mapGt0)(this.createdAt,(e=>new Date(e)))}get updatedAtDate(){return(0,r.mapGt0)(this.updatedAt,(e=>new Date(e)))}touch(e={}){e.updatedAt??(e.updatedAt=Date.now());const t=this.id;null==t?this.upsert():this.class().dbl.runf((i=>i.where({id:t}).update(e)))}$beforeUpsert(){if(super.$beforeUpsert(),this.createdAt??(this.createdAt=Date.now()),this.updatedAt=Date.now(),"updateCount"in this){const e=this,t=e.updateCount;e.updateCount=((0,n.toGt0)(e.updateCount)??0)+1,this.logger().debug("$beforeUpsert(): incr updateCount",{prior:t,now:e.updateCount})}}}t.TimestampedModel=l},58723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyExcluded=t.applyDeleted=void 0;const r=i(50213),s=i(43487),n=(0,r.mkLogger)("ops.ApplyRemovable");async function a(e,t,i){const r=e?"Deleting":"Excluding",a=e?"deletedAt":"excludedAt";await s.Asset.dbl.batched({qb:e=>e.select("id").where("shown",0).andWhere(a,"<=",t),onResults:async t=>{for(const a of t){n.throwIfAborted_(i);try{await s.Asset.remove({assetId:a,blocklistShas:!0,unlinkAssetFiles:e})}catch(e){n.error(r+" failed",{assetId:a,error:e})}}}})}t.applyDeleted=function(e){return a(!0,e.createdAt,e.halt)},t.applyExcluded=function(e){return a(!1,e.createdAt,e.halt)}},76386:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiProgressPatchPath=t.tellWebProgressUpdated=t.ProgressRateMs=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(24540),o=i(28874),l=i(34238),u=i(4988),c=i(15674),d=i(42659),h=(0,i(45599).defer)((()=>(0,s.mkLogger)("progress.Progress")));t.ProgressRateMs=(0,r.lazy)((()=>d.secondMs*((0,a.isRaspberryPi)()||(0,c.maxCpus)()<=3?5:1.5))),t.tellWebProgressUpdated=(0,r.lazy)((async()=>{if((0,n.isWebService)())return;const e=l.URI.from({scheme:"http",authority:"127.0.0.1:"+o.Settings.httpPort.valueOrDefault,path:t.ApiProgressPatchPath}).toString();await(0,u.httpRequest_)({url:e,method:"PATCH"}).catch((e=>h().warn(".tellWebProgressUpdated: failed",{error:e})))}),(0,t.ProgressRateMs)()),t.ApiProgressPatchPath="/api/progress"},44694:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryTermToFuzzyDate=void 0;const r=i(98725),s=(0,i(19851).lazy)((()=>new r.FuzzyDateParser({fuzzyDateParsing:!0,fuzzyYearParsing:!0})));t.queryTermToFuzzyDate=function(e){return s().parse(e)}},43786:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryToString=t.NormieQuerySymbols=t.SetQuerySymbols=t.isTrueTerm=t.flatTerms=t.findTerm=t.hasNsTerm=t.isQuery=t.isClause=t.isAndClause=t.isOrClause=t.isTerm=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(51926),o=i(54993);function l(e){return"object"==typeof e&&(0,s.notBlank)(e.term)&&(null==e.not||"boolean"==typeof e.not&&(null==e.ns||(0,a.isString)(e.ns)))}function u(e){return"object"==typeof e&&Array.isArray(e.queries)}function c(e){return"or"===e?.type&&u(e)}function d(e){return"and"===e?.type&&u(e)}function h(e){return d(e)||c(e)}function f(e,t){if(l(e))return t(e)?e:void 0;for(const i of e.queries){const e=f(i,t);if(null!=e)return e}}t.isTerm=l,t.isOrClause=c,t.isAndClause=d,t.isClause=h,t.isQuery=function(e){return l(e)||h(e)},t.hasNsTerm=function(e,t){return null!=f(e,(e=>e.ns===t))},t.findTerm=f,t.flatTerms=function e(t){return l(t)?[t]:(0,r.flatMap)(t.queries,e)},t.isTrueTerm=function(e){return(0,n.isTrue)(e?.not)?(0,n.isFalse)(e?.term):(0,n.isTrue)(e?.term)},t.SetQuerySymbols={not:"¬",and:"∧",or:"∨"},t.NormieQuerySymbols={not:"-",and:"AND",or:"OR"},t.queryToString=function e(i,r=t.SetQuerySymbols){if(null==i)return"";if(l(i)){let e=i.term;return null==i.term.match(/^[a-z]+$/i)&&(e='"'+e.replace(/"/g,'\\"')+'"'),`${(0,n.isTrue)(i.not)?r.not:""}${null==i.ns?"":i.ns+":"+(0,o.toS)(i.op)}${e}`}return"("+i.queries.map((t=>e(t,r))).join(` ${"or"===i.type?r.or:r.and} `)+")"}},7573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeTerm=t.isAssetTerm=t.AssetTermNs=t.AssetTermDateNs=t.AssetTermBoolNs=t.normalizeQuery=void 0;const r=i(48884),s=i(75020),n=i(40958),a=i(76790),o=i(22573),l=i(38639),u=i(50989),c=i(54993),d=i(44694),h=i(43786);function f(e){return(0,a.sortBy)((0,n.uniqBy)(e,h.queryToString),(e=>[(0,h.isTerm)(e)?0:(0,h.isOrClause)(e)?1:2,(0,h.queryToString)(e).replace(/[¬(]+/g,"")]))}t.normalizeQuery=function e(t){if((0,h.isTerm)(t))return g(t);const i=t.queries.map(e);if(0===i.length)throw new Error("empty query");if(1===i.length)return i[0];const[s,n]=(0,r.partition)(i,h.isTerm),[a,o]=(0,r.partition)(n,(e=>e.type===t.type));for(const e of a)s.push(...e.queries);const l={type:t.type,queries:f([...s,...o])};return l.queries.every((e=>(0,h.isTerm)(e)&&e.not))?e({type:"and"===t.type?"or":"and",queries:f(l.queries.map((e=>({...e,not:!1}))))}):l},t.AssetTermBoolNs=(0,u.strEnum)("deleted","excluded","liked","hidden"),t.AssetTermDateNs=(0,u.strEnum)("date","updated");const m={delete:t.AssetTermBoolNs.deleted,trash:t.AssetTermBoolNs.deleted,trashed:t.AssetTermBoolNs.deleted,exclude:t.AssetTermBoolNs.excluded,remove:t.AssetTermBoolNs.excluded,removed:t.AssetTermBoolNs.excluded,like:t.AssetTermBoolNs.liked,fav:t.AssetTermBoolNs.liked,fave:t.AssetTermBoolNs.liked,faved:t.AssetTermBoolNs.liked,favorite:t.AssetTermBoolNs.liked,favourite:t.AssetTermBoolNs.liked,hide:t.AssetTermBoolNs.hidden,archive:t.AssetTermBoolNs.hidden,archived:t.AssetTermBoolNs.hidden},p={kw:s.TagRoots.Keywords,keyword:s.TagRoots.Keywords,keywords:s.TagRoots.Keywords,dir:s.TagRoots.fs,directory:s.TagRoots.fs,folder:s.TagRoots.fs};function g(e){if((0,o.blank)(e.ns)&&null!=e.term.match(/^\d{4}[-\d]*$/)&&null!=(0,d.queryTermToFuzzyDate)(e.term))return{ns:"date",term:e.term};if("when"===(0,c.toS)(e.ns).toLowerCase())return g({...e,ns:t.AssetTermDateNs.date,term:e.term.replace(/\//g,"-")});let i=(0,o.notBlankOr)(e.ns,e.term).toLowerCase();if(i=m[i]??i,t.AssetTermBoolNs.includes(i)){let t=!(0,l.isFalse)(e.term);return!0===e.not&&(t=!t),{ns:i,term:(0,c.toS)(t)}}if(t.AssetTermNs.includes(i))return{...e,ns:i};if("before"===i||"after"===i){if(null!=e.op)throw new Error(i+": doesn't support operators");const r="after"===i&&!0!==e.not||!0===e.not;return{ns:t.AssetTermDateNs.date,op:r?">":"<",term:e.term}}return i!==e.term.toLowerCase()?{not:e.not,op:e.op,ns:p[i]??i,term:e.term}:e}t.AssetTermNs=(0,u.strEnum)(...t.AssetTermDateNs.values,...t.AssetTermBoolNs.values),t.isAssetTerm=function(e){return(0,h.isTerm)(e)&&t.AssetTermNs.includes(g(e).ns)},t.normalizeTerm=g},33693:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseQuery_=void 0;const s=r(i(31704)),n=i(19851),a=i(50213),o=i(7282),l=i(38835),u=i(31586),c=r(i(70471)),d=(0,n.lazy)((()=>(0,a.mkLogger)("query.QueryParser")));t.parseQuery_=function(e){try{const t=new s.default.Parser(s.default.Grammar.fromCompiled(c.default)).feed(e.trim()).finish();if(t.length>1&&!(0,o.isProd)()&&d().throw("parseQuery(): ambiguous grammar!",{input:e}),null==t[0])throw new Error("invalid query");return d().debug("parseQuery()",{input:e,result:t[0]}),t[0]}catch(t){const i=t.token?.col,r=`Query syntax error${(0,u.gt0)(i)?" around column "+i:""}: "${e}"`;throw d().warn("parseQuery(): bad query",{msg:r,err:t}),new Error(r+l.NonRetriableErrorFlag+l.DoNotSendErrorFlag)}}},23523:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryToSql=t.queryStringToSql_=t.defaultAssetQuery=void 0;const r=i(19851),s=i(50213),n=i(66649),a=i(89724),o=i(70417),l=i(28874),u=i(42231),c=i(22573),d=i(38639),h=i(98553),f=i(54993),m=i(57038),p=i(43487),g=i(44694),y=i(43786),w=i(7573),v=i(33693),b=(0,r.lazy)((()=>(0,s.mkLogger)("query.QueryToSql")));function S(e,t,i){if((0,y.isTerm)(t))return function(e,t,i){return(0,w.isAssetTerm)(t)?function(e,t){switch(t.ns){case w.AssetTermNs.date:case w.AssetTermNs.updated:return function(e,t){const i=t.op??"=",r="date"===t.ns?"Asset.capturedAtLocal":"updated"===t.ns?"Asset.updatedAt":void 0;if(null==r)throw new Error("internal error: unexpected namespace for "+(0,h.stringify)(t));const s="Asset.updatedAt"===r?n.datedToMillis:a.maybeDatedToLocal,l=(0,g.queryTermToFuzzyDate)(t.term),u=s(l),c=l?.following()?.toDateTime(),d=s(c?.minus({second:1})),f=(0,o.max)([u,d]);if(null==l||null==u||null==f)throw new Error((0,y.queryToString)(t,y.NormieQuerySymbols)+" can't be parsed as a date");if("="===i)return e.whereBetween(r,[u,f]);if("<"===i)return e.where(r,i,u);if("<="===i)return e.where(r,i,f);if(">="===i)return e.where(r,i,u);if(">"===i)return e.where(r,i,f);throw new Error("internal error: unexpected op for "+(0,h.stringify)(t))}(e,t);case w.AssetTermNs.hidden:return e.where("Asset.hidden",_(t));case w.AssetTermNs.excluded:return M({qb:e,column:"Asset.excludedAt",whereNull:0===_(t)});case w.AssetTermNs.deleted:return M({qb:e,column:"Asset.deletedAt",whereNull:0===_(t)});case w.AssetTermNs.liked:return e.where("Asset.rating",P(t)?">=":"<",l.Settings.likeRating.valueOrDefault);default:throw new Error("not asset term:"+(0,y.queryToString)(t))}}(e,t):function(e,t,i){const r=t.term.startsWith("/"),s="="===t.op,n=function(e,t){if(null==t||"fs"!==e.ns)return e.term;const i=e.term.split("/"),r=i.findIndex(c.notBlank);if(-1===r)return e.term;const s=i[r];return i[r]=t.get(s)??s,i.join("/")}(t,i);if(r||s)return e.whereIn("Asset.id",(0,m.knex)()("AssetTag").join("Tag","Tag.id","AssetTag.tagId").select("assetId").whereLike("Tag._path",t.ns+(r?"":"%")+n.replace(/\//g,u.TagSep).replace(/\*/g,"%")+u.TagSep+(s?"":"%")));let a=(0,m.knex)()("AssetTag").join("tag_fts","tag_fts.rowid","AssetTag.tagId").select("assetId");const o="path:"+T(n.replace(/\//g," + "));if((0,c.blank)(t.ns)){if((0,d.isTrue)(t.not))throw new Error("Cannot negate without a namespace ("+(0,y.queryToString)(t)+")");a=a.where("tag_fts","MATCH",o)}else a=a.where("tag_fts","MATCH","(root:"+T(t.ns)+((0,d.isTrue)(t.not)?" NOT ":" AND ")+o+")");return e.whereIn("Asset.id",a)}(e,t,i)}(e,t,i);for(const r of t.queries)e=(0,y.isAndClause)(t)?e.andWhere((e=>S(e,r,i))):e.orWhere((e=>S(e,r,i)));return e}function P(e){const t=(0,d.isTrue)(e.term);return!0===e.not?!t:t}function _(e){return P(e)?1:0}function T(e){return e.includes("*")?e.split("*").map(T).join(" * "):`"${(0,f.toS)(e).replace(/"/g,'""')}"`}function M({qb:e,column:t,whereNull:i}){return i?e.whereNull(t):e.whereNotNull(t)}function E(){return p.Asset.ops().query().where("Asset.shown",1).join("AssetTag","AssetTag.assetId","Asset.id")}function D(e,t=E(),i){return e=(0,w.normalizeQuery)(e),(0,y.hasNsTerm)(e,w.AssetTermBoolNs.hidden)||(0,y.hasNsTerm)(e,w.AssetTermBoolNs.excluded)||(0,y.hasNsTerm)(e,w.AssetTermBoolNs.deleted)||(t=t.andWhere({"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null})),t.andWhere((t=>S(t,e,i)))}t.defaultAssetQuery=E,t.queryStringToSql_=function(e,t=E()){const i=(0,v.parseQuery_)(e);return null==i?(b().warn("assetQuery("+e+"): parsed to null"),t):D(i,t)},t.queryToSql=D},70471:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};function s(e){return e[0]}Object.defineProperty(t,"__esModule",{value:!0}),t.parseTerm=void 0;const n=r(i(80265)),a=i(40958),o=i(54993);function l(e){if(null==e[0]&&["and","or"].includes((0,o.toS)(e[1]).toLowerCase()))throw new Error("Unmatched "+e[1]);return{not:null!=e[0]?.[0]?.value,ns:e[0]?.[1]?.value,op:e[0]?.[3]?.value,term:e[1]}}function u(e){return e[0]?.value}t.parseTerm=l;const c=n.default.compile({qstr:[{match:/"(?:[^\\"]|\\.)*?"/,value:e=>e.slice(1,-1).replace(/\\"/g,'"')},{match:/'(?:[^\\']|\\.)*?'/,value:e=>e.slice(1,-1).replace(/\\'/g,"'")}],lp:"(",rp:")",not:/[-¬]/,col:":",op:/<=?|>=?|=/,or:/ +(?:or|OR|Or|∨|\|{1,2}) +/,and:/(?:and|AND|And|∧|\&{1,2}) +/,str:/[^\s:\(\)"'][^\s:\(\)]*/,ws:/ +/}),d={Lexer:c,ParserRules:[{name:"Expression$ebnf$1",symbols:[]},{name:"Expression$ebnf$1$subexpression$1",symbols:[c.has("or")?{type:"or"}:or,"Clause"]},{name:"Expression$ebnf$1",symbols:["Expression$ebnf$1","Expression$ebnf$1$subexpression$1"],postprocess:e=>e[0].concat([e[1]])},{name:"Expression",symbols:["Clause","Expression$ebnf$1"],postprocess:function(e){const t=(0,a.compact)([e[0],...e[1].map((e=>e[1]))]);return 1===t.length?t[0]:{type:"or",queries:t}}},{name:"Clause$ebnf$1",symbols:[]},{name:"Clause$ebnf$1$subexpression$1$ebnf$1",symbols:[c.has("and")?{type:"and"}:and],postprocess:s},{name:"Clause$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"Clause$ebnf$1$subexpression$1",symbols:["__","Clause$ebnf$1$subexpression$1$ebnf$1","Factor"]},{name:"Clause$ebnf$1",symbols:["Clause$ebnf$1","Clause$ebnf$1$subexpression$1"],postprocess:e=>e[0].concat([e[1]])},{name:"Clause",symbols:["Factor","Clause$ebnf$1"],postprocess:function(e){const t=(0,a.compact)([e[0],...e[1].map((e=>e[2]))]);return 1===t.length?t[0]:{type:"and",queries:t}}},{name:"Factor",symbols:["Term"],postprocess:s},{name:"Factor",symbols:[c.has("lp")?{type:"lp"}:lp,"_","Expression","_",c.has("rp")?{type:"rp"}:rp],postprocess:function(e){const t=(0,a.compact)(e[2]);return 1===t.length?t[0]:t}},{name:"Term$ebnf$1$subexpression$1$ebnf$1",symbols:[c.has("not")?{type:"not"}:not],postprocess:s},{name:"Term$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"Term$ebnf$1$subexpression$1$ebnf$2",symbols:[c.has("op")?{type:"op"}:op],postprocess:s},{name:"Term$ebnf$1$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"Term$ebnf$1$subexpression$1",symbols:["Term$ebnf$1$subexpression$1$ebnf$1",c.has("str")?{type:"str"}:str,c.has("col")?{type:"col"}:col,"Term$ebnf$1$subexpression$1$ebnf$2"]},{name:"Term$ebnf$1",symbols:["Term$ebnf$1$subexpression$1"],postprocess:s},{name:"Term$ebnf$1",symbols:[],postprocess:()=>null},{name:"Term",symbols:["Term$ebnf$1","Value"],postprocess:l},{name:"Value",symbols:[c.has("qstr")?{type:"qstr"}:qstr],postprocess:u},{name:"Value",symbols:[c.has("str")?{type:"str"}:str],postprocess:u},{name:"_$ebnf$1",symbols:[c.has("ws")?{type:"ws"}:ws],postprocess:s},{name:"_$ebnf$1",symbols:[],postprocess:()=>null},{name:"_",symbols:["_$ebnf$1"]},{name:"__",symbols:[c.has("ws")?{type:"ws"}:ws]}],ParserStart:"Expression"};t.default=d},3996:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileFinder=t.isFileInSync=void 0;const o=i(19851),l=i(50213),u=i(79781),c=i(56519),d=i(56038),h=i(59189),f=i(38835),m=i(95696),p=i(48368),g=i(181),y=i(69589),w=i(28874),v=i(47783),b=i(87001),S=i(40958),P=i(76790),_=i(22573),T=i(42659),M=i(55835),E=i(31586),D=i(43487),x=i(54017);t.isFileInSync=async function(e){return new F(m.PosixFile.for(e)).alreadySynced()};const k=new h.SerialLaterQueue;class F{constructor(e,t=(0,y.forceContextOrSetting)()){this.file=e,this.ctx=t,r.set(this,void 0),s.set(this,new Set),this.alreadySynced=(0,d.timedLazy)("sync-file.AssetFileFinder.alreadySynced: "+this.file,(async()=>a(this,r,"f").tap({msg:"alreadySynced",result:null!=await this.priorIfSynced()}))),this.newAssetFile_=(0,d.timedLazy)("sync-file.AssetFileFinder.newAssetFile: "+this.file,(async()=>{const e=await(new x.AssetFile).updateFromFile_(this.file);return null==e?a(this,r,"f").throw("AssetFile.updateFromFile returned null",{fatal:!1}):e})),this.tags_=(0,o.lazy)((async()=>{const e=await(0,v.readTags)(this.file);if(null==e)throw new Error(this.file+" doesn't have metadata");return e})),this.imageHash=(0,o.lazy)((()=>w.Settings.useImageHashes.valueOrDefault?(0,p.imageHash)(this.file):void 0)),this.dominantLabhashes=(0,o.lazy)((()=>(0,c.thenMap)(this.imageHash(),(e=>(0,S.uniq)(e.dominantColors.filter((e=>e.pct>5)).map((e=>e.labhash))))))),this.capturedAtLocal=(0,o.lazy)((async()=>{const e=await this.capturedAt_();return a(this,r,"f").tap({msg:"capturedAtLocal",result:e?.local,meta:{capturedAt:e}})})),this.mapSibling=e=>this.newAssetFileForAsset(e?.getAsset()),this.apply_=(0,d.timedLazy)("sync-file.AssetFileFinder: "+this.file,(async()=>{if((0,_.blank)(await this.file.uri_()))throw new Error("Cannot import, file URI is blank for "+this.file);{const e=await this.byExistingAsset_();if(null!=e)return a(this,r,"f").info("Found existing asset for file"),e}const e=await this.newAssetFile_(),t=await k.enqueue((async()=>{const t=await this.byExistingAsset_();if(null!=t?.assetId)return a(this,r,"f").info("Found existing asset for file after acquiring lock",{withExistingAsset:t}),t.assetId;const i=new D.Asset;return i.capturedAtLocal=e.capturedAtLocal,i.addAssetFile(e),i.upsert(),i.id}));return e.assetId=t,e.upsert()})),this.byExistingAsset_=()=>(0,d.time)("sync-file.AssetFileFinder.byExistingAsset: "+this.file,(async()=>{const e=[{name:"byUri",f:()=>this.byUri()},{name:"byNormalizedPathUri",f:()=>this.newAssetFileForAsset(this.assetByNormalizedPathUri())},{name:"bySha",f:()=>this.newAssetFileForAsset(this.assetBySha())},{name:"hasTags",f:async()=>{await this.tags_()}},{name:"validFile",f:async()=>{await(0,g.throwIfInvalidFile_)(this.file)}},{name:"byCapturedAtOrImageHash",f:()=>this.newAssetFileForAsset(this.assetByCapturedAtOrImageHash())}];for(const{name:t,f:i}of e)try{const e=await(0,d.time)("sync-file.assetFileFinder."+t+": "+this.file,i);if(null!=e)return a(this,r,"f").info("apply(): "+t,{assetFileId:e.id,assetId:e.assetId}),e;a(this,r,"f").debug("apply(): "+t+": returned null")}catch(e){throw a(this,r,"f").debug("apply(): "+t+" rejected: "+e),e}})),n(this,r,(0,l.mkLogger)("sync-file.AssetFileFinder("+e.baseWithGrandparent+")"),"f")}async prior(){return this.byUri()}async priorIfSynced(){if(this.ctx.forceSync)return;const e=await this.prior();return!0===await(e?.matchesFile())?e:void 0}async newAssetFileForAsset(e){const t=await e;if(null!=t){if(null!=t.id){const e=await this.newAssetFile_();return t.addAssetFile(e),e.insert(),a(this,r,"f").debug("newAssetFileForAsset() upsert success!",{af:e}),e}a(this,r,"f").throw("newAssetFileForAsset(): given non-persisted Asset")}}async capturedAt_(){return(await this.tags_()).capturedAt}async byUri(e=this.file){const t=await e.uri_();if(null!=t)return x.AssetFile.ops().firstf((e=>e.whereIn("uri",[...(0,b.uriEncodingVariants)(t),this.file.fileuri()])));a(this,r,"f").warn("byUri() uri is null",{file:e})}async assetByNormalizedPathUri(){const e=await this.file.normalize();return e.nativePath===this.file.nativePath?void 0:(await this.byUri(e))?.getAsset()}assetBySha(){return(0,c.thenMap)(this.file.sha(),(e=>D.Asset.findFirstByFile((t=>t.where("AssetFile.sha",e)))))}async assetByCapturedAtOrImageHash(){const e=await this.capturedAt_();if(null==e)return a(this,r,"f").throw("Cannot import, capturedAt is null"+f.InternalErrorFlag);if(w.Settings.strictDeduping.valueOrDefault)return this.firstSimilarAsset(x.AssetFile.ops().allf((t=>t.where({capturedAtLocal:e.local}))));const t=w.Settings.maxContemporaryAdoptionAssets.valueOrDefault,i=()=>{let i=x.AssetFile.query();return(0,E.gt0)(t)&&(i=i.limit(t)),i.orderByRaw(`abs(capturedAtLocal - ${e.local})`)},s=Math.max(T.secondMs,w.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault);return(0,d.time)("sync-file.AssetFileFinder.assetByCapturedAtAndImageHash: "+this.file,(async()=>{{const t=e.localBoundaries({delta:s});if(null==t)a(this,r,"f").warn("Failed to fetch localBoundaries, cannot fetch similar assets by localtime",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("captured-at",i().whereBetween("capturedAtLocal",[t.start,t.end]))??(w.Settings.checkBasenameMatches.valueOrDefault?this.firstSimilarAssetByQuery("basename",i().whereILike("uri","%/"+this.file.name+"%")):void 0);if(null!=e)return e}}const t=await this.imageHash();if(null==t)return void a(this,r,"f").warn("assetByCapturedAtAndImageHash: no imageHash");const n=await this.dominantLabhashes();if((0,S.isNotEmpty)(n)){const t=e.localBoundaries({delta:4*s});if(null==t)a(this,r,"f").error("Failed to fetch localBoundaries, cannot fetch similar assets by wide localtime + image hash",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("wide captured-at and dominant color",i().whereBetween("capturedAtLocal",[t.start,t.end]).andWhere((e=>e.whereIn("mode0",n).orWhereIn("mode1",n).orWhereIn("mode2",n))));if(null!=e)return e}}return this.firstSimilarAssetByQuery("image hash",i().where("meanHash",t.meanHash).orWhere("diffHash",t.diffHash).orWhere("dctHash",t.dctHash))}))}async firstSimilarAssetByQuery(e,t){a(this,s,"f").size>0&&(t=t.whereNotIn("AssetFile.id",Array.from(a(this,s,"f"))));const i=await this.firstSimilarAsset(x.AssetFile.ops().all(t));return null!=i&&a(this,r,"f").info("Found similar asset by "+e,{result:i}),i}async firstSimilarAsset(e){const t=await this.newAssetFile_(),i=await this.capturedAtLocal();if(null==t)throw new Error("Failed to update from "+this.file);const n=(0,P.sortBy)(e.filter((e=>!a(this,s,"f").has(e.id))),(e=>[(0,M.mapOr)(i,(t=>Math.abs(e.capturedAtLocal-t)),-e.capturedAtLocal),e.id]));for(const e of n)if(null!=e){await e.getNativePath();const i=x.AssetFile.ops().findBy({assetId:e.assetId});await Promise.all(i.map((e=>e.getNativePath())));const n=(0,u.whyNotSameAsset)(t,e,i);if(null==n)return a(this,r,"f").info("Found sibling AssetFile",e),D.Asset.ops().findById(e.assetId);a(this,s,"f").add(e.id),a(this,r,"f").debug("Contemporary assetFile not similar: "+n,e?.uri)}}}t.AssetFileFinder=F,r=new WeakMap,s=new WeakMap},34274:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileImporter=t.importFileToResult_=void 0;const u=i(19851),c=i(50213),d=i(73568),h=i(38835),f=i(95696),m=i(62105),p=i(74128),g=i(181),y=i(69589),w=i(28874),v=i(40958),b=i(22573),S=i(38639),P=i(59455),_=i(64526),T=i(19113),M=i(94710),E=i(3996),D=i(90901);t.importFileToResult_=async function(e){const t=_.Library.instanceRequired_();return(0,p.syncReport)().wrap_({path:e.path,from:"AssetFileImporter",fn_:()=>new x(f.PosixFile.for(e.path),t.assetFileRepository(),e).apply_()})};class x{constructor(e,t,i){r.add(this),this.file=e,this.repo=t,this.start=Date.now(),s.set(this,void 0),n.set(this,void 0),this.whyRejected=(0,u.lazy)((async()=>{const e=[],t=await this.file.uri_();if(null==t)e.push("Cannot make URI"+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);else{if(!0===await this.file.isDeletedUri(t))e.push("File was deleted");else if(this.ctx.forceFilters||null==await this.prior()){const t=await(0,m.whyRejectFile)(this.file,(0,T.libraryFileFiltersFor)(this.file));null!=t&&e.push(t)}l(this,s,"f").throwIfAborted_();const i=await this.prior();if((0,v.isNotEmpty)(e)&&null!=i&&(l(this,s,"f").info("Deleting prior AssetFile",{rejected:e,prior:i}),i.delete(),this.ctx.skipAssetRepair?l(this,s,"f").info("Skipping asset repair",{assetId:i.assetId}):(l(this,s,"f").info("Scheduling asset repair",{assetId:i.assetId}),M.Task.addOne("repairAsset",{assetId:i.assetId,forceRebuildPreviews:(0,S.isTrue)(i.shown)}))),null!=i){const t=i.getAsset();null!=t?.deletedAt&&e.push("Asset is marked as deleted"),null!=t?.excludedAt&&e.push("Asset is marked as excluded")}if(l(this,s,"f").throwIfAborted_(),0===e.length&&(null==i||!await i.inSyncWithFile())){const t=await(0,g.whyInvalidFile)(this.file.nativePath);(0,b.blank)(t)||e.push(t)}}return e})),this.assetFile_=(0,u.lazy)((async()=>{const e=await l(this,n,"f").apply_(),t=e.getAsset();return l(this,s,"f").info("assetFileFinder.apply_() result",{asset:t,assetFile:e}),null==t?l(this,s,"f").throw("assetFile.getAsset() was null",{srcAssetFile:e}):null==t.id?l(this,s,"f").throw("repoAssetFile asset has null id",{asset:t}):e})),this.prior=(0,u.lazy)((()=>l(this,n,"f").prior())),this.apply_=(0,u.lazy)((()=>l(this,r,"m",a).call(this))),this.ctx=(0,y.forceContextOrSetting)(i),o(this,s,(0,c.mkLogger)("sync-file."+this.toString()),"f"),o(this,n,new E.AssetFileFinder(e,this.ctx),"f")}toString(){return"AssetFileImporter("+this.file.nativePath+")"}newAssetFile(){return l(this,n,"f").newAssetFile_()}}t.AssetFileImporter=x,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(){l(this,s,"f").throwIfAborted_();const e=await l(this,s,"f").tapAsync_({msg:"whyRejected",result:this.whyRejected(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if((0,v.isNotEmpty)(e)){const t=e.join(", ");return{path:this.file.nativePath,state:p.SyncFileStates.rejected,details:t}}l(this,s,"f").throwIfAborted_();const t=await l(this,s,"f").tapAsync_({msg:"prior()",result:this.prior(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if(null!=t&&await t.isNoop(this.ctx))return{path:this.file.nativePath,state:p.AssetFileSyncStates.noop,assetId:t.assetId,assetFileId:t.id,assetFile:t,asset:t.getAsset(),uri:t.uri};l(this,s,"f").throwIfAborted_();const i=await l(this,s,"f").tapAsync_({msg:"assetFile()",result:this.assetFile_(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if(null==i)return l(this,s,"f").throw("_apply(): unexpected null assetFile");const r=i.id;if(null==r)return l(this,s,"f").throw("_apply(): unexpected null assetFileId");const n=i.uri;if(null==n)return l(this,s,"f").throw("_apply(): unexpected null assetFile.uri");const a=i.getAsset();if(null==a)return l(this,s,"f").throw("_apply(): unexpected null assetFile.getAsset()");let o;await l(this,s,"f").tapAsync_({msg:"assetFile.upsertIfNeeded_()",result:i.upsertIfNeeded_(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault}),l(this,s,"f").throwIfAborted_();try{o=await(0,D.assetPostUpsertTasks_)({asset:a,...this.ctx})}catch(e){e instanceof d.AbortError?l(this,s,"f").warn("aborted (caller/process after me will complete)",{error:e}):l(this,s,"f").throw("Post-upsert tasks failed",{error:e})}return{path:this.file.nativePath,state:i.syncState??p.SyncFileStates.synced,assetId:a.id,assetFileId:r,assetFile:i,asset:a,uri:n,uris:[n,...(0,P.toA)(o?.newAssetFileUris)]}}},41844:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileRepository=t.mayCopyAssetsToLibrary=void 0;const u=i(50213),c=i(74128),d=i(81674),h=i(57902),f=i(4936),m=i(28874),p=i(47783),g=i(67083),y=i(16170),w=i(54979),v=i(98604),b=i(40958),S=i(22573),P=i(98553),_=i(89937),T=i(59455),M=i(54017),E=i(94710);t.mayCopyAssetsToLibrary=async function(){return m.Settings.copyAssetsToLibrary.valueOrDefault&&await(0,d.p)()},t.AssetFileRepository=class{constructor(e){r.add(this),this.originalsDir=e,this.logger=(0,u.mkLogger)("AssetFileRepository")}async shouldCopy(e){const t=await this.whyNotCopyFile(e);return this.logger.tap({level:"info",msg:"shouldCopy()",result:null==t,meta:{file:e?.nativePath,whyNot:t}})}async whyNotCopyFile(e){if(null==e||(0,S.blank)(e.nativePath))return"blank nativePath";if(!0!==m.Settings.copyAssetsToLibrary.value)return"copyAssetsToLibrary !== true";if(await(0,d.l)())return"no active subscription";if(await e.notExists({refresh:!0}))return"file doesn't exist";if(e.isDescendantOf(this.originalsDir))return e+" already contained by "+this.originalsDir;if(e.isDescendantOf(m.Settings.libraryDir.valueOrDefault))return e+" already contained by "+m.Settings.libraryDir.valueOrDefault;const t=await(0,w.readMimeType)(e);return null==t?"readMimeType("+e+") was null":(0,y.isMimeTypeIncluded)(t,m.Settings.copyToLibraryMimeTypes.values)?null:"mimetype "+t+" is not included in copyToLibraryMimeTypes"}async existingLibraryAssetFile(e){if(e.uri.startsWith(_.PS_LIBRARY_PROTOCOL))return e;const t=(0,b.uniqBy)((0,T.toA)(e.librarySiblings()?.filter((t=>t.sha===e.sha))).concat(M.AssetFile.sameAssetFileInLibrary(e)),(e=>e.id));for(const i of t)if(await i.exists()){if(i.assetId!==e.assetId){this.logger.warn("Existing library asset file with a matching SHA is associated to a different asset. Requesting repair of the two impacted assets.",{af:e,prior:i});const t=i.assetId;e.getAsset()?.addAssetFile(i),E.Task.addOne("repairAsset",{assetId:t,forceSync:!0})}return this.logger.info("whyNotCopyAssetFile("+e.uri+"): found existing db record",{af:e,prior:i}),i}return null}async findLibraryFileWithSameContents(e,t){if(await e.matchesContent(t))return t;let i=t.parent();for(;i.isSelfOrDescendantOf(this.originalsDir);){const t=i.childWithSameContents(e);if(null!=t)return t;i=i.parent()}}async importFile_(e){const t=await l(this,r,"m",s).call(this,e);return null!=t&&(await l(this,r,"m",n).call(this,e,t),await l(this,r,"m",o).call(this,e,t)),t}async maybeCopyToLibrary_(e,t){const i=Date.now(),s=await e.posixFile_();null==s&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): posixFile is null",{ignorable:!1,retriable:!1});{const e=await this.whyNotCopyFile(s);if(!(0,S.blank)(e))return this.logger.tap({level:h.LogLevels.info,msg:"maybeCopyToLibrary_(): not copying: "+e,result:void 0})}const a=e.getAsset();null==a&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): null asset");{const u=await this.existingLibraryAssetFile(e);if(null!=u){const e=await u.posixFile_();if(null!=e){const d=await l(this,r,"m",n).call(this,s,e),h=null!=await l(this,r,"m",o).call(this,s,e),f=null!=await u.upsertIfNeeded_(void 0,t);return!h&&(0,b.isEmpty)(d)&&!f||(0,c.syncReport)().onProgress({path:e.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.synced,details:"Found and synced prior replica already in your library "+(0,P.stringify)({src:s.nativePath,upsertNeeded:f,copiedSidecars:d,copiedInferredMetadata:h}),elapsedMs:Date.now()-i,url:(0,v.mkAssetUrl)(a.id)?.toString()}),u}this.logger.warn("existingLibraryAssetFile() returned an assetFile that could not be resolved to a PosixFile",{prior:u})}}const u=await this.importFile_(s);if(null==u)return void this.logger.info("importFile() returned null",{srcAssetFile:e});if(u.nativePath===s.nativePath)return void this.logger.info("importFile() returned the same nativePath as src",{srcAssetFile:e,dest:u});const d=await a.assetFileForFile_(u,{skipUpsert:!0});await d.updateFromShaSibling_(e);const f=d.upsert();return a.addAssetFile(d),(0,c.syncReport)().onProgress({path:u.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.copied,details:"Copied into your library from "+s.nativePath,elapsedMs:Date.now()-i,url:(0,v.mkAssetUrl)(a.id)?.toString()}),f}},r=new WeakSet,s=async function(e){const t=await(0,p.readCapturedAt)(e),i=(0,f.pathToLibraryAsset)(t?.date,e);if(this.logger.debug("importFile("+e+")",{capturedAt:t,assetPath:i}),null==i)throw new Error(e.nativePath+" failed to create a library path");const r=this.originalsDir.join(...i),s=await this.findLibraryFileWithSameContents(e,r);if(null!=s)return this.logger.debug("#importFile_("+e+"): found existing file",{src:e,existing:s}),s;const n=await r.ensureNew_();return this.logger.info("#importFile_("+e+"): copying...",{uniqDest:n,dest:r}),e.copyFile_(n)},n=async function(e,t){const i=await e.existingSidecars(),s=[];for(const e of i)s.push(await l(this,r,"m",a).call(this,e,t));return(0,b.compact)(s)},a=async function(e,t){for(const i of await t.existingSidecars())if(await(0,p.sidecarEql)(e,i))return void this.logger.info("handleSidecar(): metadata already exists.",{srcSidecar:e,destSidecar:i,dest:t});const i=await t.parent().join(t.name+e.ext).ensureNew_({emptyIsNew:!0});return e.copyFile_(i)},o=async function(e,t){if(null==e||null==t||e.eql(t))return;const i=await(0,p.readTags)(e);if(null!=i)return(0,g.ensureInferredHistoryRecords)(e,await t.sidecar(),i.inferred);this.logger.warn("#handleInferred(): Failed to read tags from "+e,{dest:t})}},90901:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetPostUpsertTasks_=t.assetPostUpsertTasks=void 0;const r=i(50213),s=i(92434),n=i(73568),a=i(99331),o=i(39250),l=i(38835),u=i(57159),c=i(48604),d=i(66106),h=i(69589),f=i(40958),m=i(45599),p=i(23838),g=i(31586),y=i(64526),w=i(88224),v=i(43487),b=i(41844),S=i(68640),P=(0,m.defer)((()=>(0,r.mkLogger)("sync-file.AssetPostUpsertTasks"))),_=(0,m.defer)((()=>new o.LastOneInWins("Asset tasks")));async function T(e){const t=e,i=e,r=(0,g.toGt0)(t.asset?.id)??(0,g.toGt0)(i.assetId);if(null==r)throw new Error("assetPostUpsertTasks_(): unexpected null assetId"+l.InternalErrorFlag);const o=(0,h.forceContextOrSetting)(e),m=P().addContext(`.postUpsertAssetTasks_(Asset:${r})`);if(m.abortable=o.halt,o.skipPreviews&&o.skipAssetTagging)return void m.info("skipped (skipPreviews && skipAssetTagging)");const T=t.asset??v.Asset.ops().findById(r);if(null==T)return m.throw("unexpected null asset",{asset:T});try{return await _().enqueue({key:r,abortable:m.abortable,fn:()=>async function(e,t,i){const r=(0,h.forceContextOrSetting)(i),n=t.id,a=t.getAssetFiles({refresh:!0}),o={newAssetFileUris:[],previewsUpdated:!1,tagResult:void 0,transcoded:!1};if(e.throwIfAborted_(),(0,f.isEmpty)(a)&&(await v.Asset.remove({assetId:n,blocklistShas:!1,unlinkAssetFiles:!1}),e.throw(`Asset:${n} had no asset files. Deleted.`)),await(0,b.mayCopyAssetsToLibrary)())for(const[t,i]of(0,p.groupBy)(a,(e=>e.sha)).entries()){e.throwIfAborted_();try{for(const r of i)r.isInLibrary()&&await r.exists()&&e.debug("no-op for file SHA: already in library.",{sha:t,uri:r.uri});for(const e of i)if(await e.exists()){const t=await y.Library.instanceRequired_().assetFileRepository().maybeCopyToLibrary_(e,r);if(null!=t){o.newAssetFileUris.push(t.uri);continue}}}catch(r){e.warn("Failed to copy variation to library, but we'll try to continue",{sha:t,uris:i.map((e=>e.uri)),error:r})}}e.throwIfAborted_();const l=r.skipPreviews?void 0:await(0,S.updateAssetPreviews_)({asset:t,assetFiles:t.getAssetFiles(),...r}),u=await async function(e,t){if((0,g.gt0)(t?.assetFileId)){const i=e.getAssetFiles({refresh:!0}).find((e=>e.id===t?.assetFileId));return null==i?P().throw("AssetPreviewInfo referenced unknown assetFileId",{asset:e,info:t}):i}const i=e.getShown();return null!=i?i:(0,s.bestExistingAssetFile)(e.getAssetFiles())}(t,l);if(null==u)return e.throw("null primaryOrShownAssetFile_()",{asset:t});const m=await u.posixFile_();if(!0!==r.skipPreviews&&t.isVideo()){if(null==m)return e.throw("null primary.posixFile()",{asset:t,assetFiles:t.getAssetFiles()});o.transcoded=null!=await(0,d.transcode_)(m,c.Previews.instance().ap(n).mp4(),{force:r.forceRebuildPreviews,halt:r.halt})}return e.throwIfAborted_(),t.markShownAndUpsert_(u),r.skipAssetTagging?e.info("skipping asset tagging"):o.tagResult=await(0,w.tagAndUpsertAsset_)(t),o}(m,T,{...e,...o})})}catch(e){if(e instanceof n.AbortError)return void m.warn("aborted, next caller will clean up my mess",{error:e});const t=[e];if(!(0,a.ending)()){m.error("failed, marking asset unshown",{error:e});try{T.markUnshownAndUpsert()}catch(e){m.error("failed to mark asset unshown",{upsertError:e}),t.push(e)}}throw new u.WrappedError("Failed to post-process assset "+T.id,{causes:t})}}t.assetPostUpsertTasks=function(e){try{return T(e)}catch(e){if(e instanceof n.AbortError)return void P().warn("aborted, next caller will clean up my mess",{error:e});throw e}},t.assetPostUpsertTasks_=T},61989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAsset_=t.updateAsset=void 0;const r=i(48884),s=i(50213),n=i(45393),a=i(79184),o=i(79781),l=i(92434),u=i(56519),c=i(70417),d=i(69589),h=i(28874),f=i(40958),m=i(22573),p=i(38639),g=i(50357),y=i(43487),w=i(54017),v=i(90901);async function b(e){const t=(0,d.forceContextOrSetting)(e),i=e.assetId,r=(0,s.mkLogger)(`sync-file.UpdateAsset(${i})`);r.abortable=t.halt;const b=y.Asset.ops().findById(i);if(null==b)return r.throw("no such asset");const P=b.getAssetFiles({refresh:!0});if((0,f.isEmpty)(P))return r.warn("No asset files: deleting."),b.delete(),{asset:b,rejected:"Empty asset (no AssetFiles)"};const _=b.$clone(),T=b.getShown()?.$clone();for(const e of P)r.throwIfAborted_(),await e.upsertIfNeeded_(void 0,t);P.some((e=>(0,p.isTrue)(e.deleted)||(0,m.notBlank)(e.rejected)))&&b.clear(),await S(r,P);const M=(0,l.sortAssetFiles)(P),E=M?.[0];if((0,f.isEmpty)(M)||null==E)return r.warn("No existing files. Skipping for now."),b.markUnshownAndUpsert(),{asset:b,rejected:"Empty asset (no AssetFiles after sorting). Un-showing Asset:"+i};if(!E.isVersionUpToDate())return r.warn("Best file needs update, and we already tried to update all files. Skipping this asset.",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, could not be updated. Un-showing Asset:${i}`};const D=await E.capturedAt();if(null==D)return r.warn("Best file failed to extract a captured-at",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, failed to extract a captured-at. Un-showing Asset:${i}`};const x=new Set,[k,F]=await(0,u.partitionAsync)(M,(e=>(0,o.isSimilarAssetFile)(e,E)));if(r.throwIfAborted_(),(0,f.isNotEmpty)(F)){const e=await(0,a.aggregateAssetFiles)(F);for(const t of e){if((0,f.isEmpty)(t))continue;const e=y.Asset.ops().insertOne({capturedAtLocal:t[0].capturedAtLocal,shown:!1,version:0});x.add(e.id);for(const i of t)e.addAssetFile(i);w.AssetFile.dbl.runf((i=>i.update({assetId:e.id,shown:0}).whereIn("id",(0,f.compact)(t.map((e=>e.id)))))),r.info("Pushed rejected asset files into new asset",{rejectAssetId:e.id,rejectCluster:t.map((e=>({id:e.id,uri:e.uri})))})}}function C(e){return(0,f.uniq)(k.map((t=>t[e])))}const A=await Promise.all(k.map((e=>e.capturedAt()))),I=h.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,O=A.map((e=>e?.localBoundaries({delta:I}))),L=(0,c.min)(O.map((e=>e?.start)))??D.localBoundaries({delta:I})?.start,R=(0,c.max)(O.map((e=>e?.end)))??D.localBoundaries({delta:I})?.end,N=w.AssetFile.ops().all(w.AssetFile.query().limit(h.Settings.maxContemporaryAdoptionAssets.valueOrDefault).orderByRaw(`abs(AssetFile.capturedAtLocal - ${E.capturedAtLocal})`).select("AssetFile.*").distinct().join("Asset","Asset.id","AssetFile.assetId").where("AssetFile.assetId","!=",i).andWhere("Asset.version","!=",n.AssetVersion).andWhere((e=>(e=e.whereIn("AssetFile.sha",C("sha")),null==L||null==R?r.warn("external asset file check: unset start or end localtime boundary",{capturedAts:A,startBoundary:L,endBoundary:R}):e=e.orWhereBetween("AssetFile.capturedAtLocal",[L,R]),e.orWhereIn("AssetFile.meanHash",C("meanHash")).orWhereIn("AssetFile.diffHash",C("diffHash")).orWhereIn("AssetFile.dctHash",C("dctHash"))))));r.throwIfAborted_(),r.info("asset file candidates for adoption: ",N.map((e=>e.posixPathFromGrandparent)));const B=[];for(const e of N){r.throwIfAborted_();try{await e.updateFromFile_(),(0,o.isSimilarAssetFile)(e,E)&&(r.info("adopting similar asset file",{af:e}),x.add(e.assetId),e.shown=!1,b.addAssetFile(e),e.upsert(),B.push(e))}catch(t){r.warn("Error updating external asset file. Leaving asset file record as-is.",{af:e,error:t})}}r.info("fetched expansion",{retainAFs:k.map((e=>e.id)),rejectAFs:F.map((e=>e.id)),externalAssetFiles:N.map((e=>e.posixPathFromGrandparent)),similarAssetFiles:B.map((e=>e.posixPathFromGrandparent))}),await S(r,[...k,...B]),t.skipPreviews&&t.skipAssetTagging?(r.info("skipping previews and tagging",t),b.upsert()):await(0,v.assetPostUpsertTasks_)({...t,asset:b});const j=!(0,g.eql)(_,b),z=!(0,g.eql)(T,b.getShown()),V=!(j||z||t.forceRebuildPreviews||t.forceSync);return r.tap({msg:"updateAsset() result",level:"info",result:{asset:b,assetIdsToUpdate:Array.from(x),assetFiles:b.assetFiles,skipped:V},meta:{ctx:t,assetChanged:j,primaryAssetFileChanged:z}})}async function S(e,t){const[i,s]=(0,r.partition)(t,(e=>e.isVersionUpToDate()));for(const t of s){e.throwIfAborted_();const r=i.find((e=>e.sha===t.sha));if(null!=r){e.info("backfilling",{sibling:r,dest:t});const i=await t.updateFromShaSibling_(r);null!=i&&i.upsert()}}}t.updateAsset=async function(e){try{const t=await b(e);return{id:e.assetId,skipped:null==t?.asset,...t}}catch(t){return{id:e.assetId,error:t}}},t.updateAsset_=b},93755:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetFileIfNeeded=t.handleAssetFileUriChange=t.updateAssetFile_=t.updateAssetFile=void 0;const r=i(50213),s=i(92434),n=i(98314),a=i(74128),o=i(69589),l=i(87001),u=i(40958),c=i(22573),d=i(68708),h=i(43487),f=i(54017),m=i(94710);async function p(e){const t=Date.now(),i=e,s=e,n=s.af?.id??i.assetFileId,u=(0,r.mkLogger)(`updateAssetFile(${n})`),d=s.af??f.AssetFile.ops().findById(n);if(null==d)return u.throw("db record not found",{assetFileId:n});const h=await d.posixFile_(),p=(0,o.forceContextOrSetting)(e),w={id:n,assetFileId:n,path:h?.nativePath,uri:d?.uri};if(null==h)return{...w,error:"file for URI not found"};const v=await(h?.isDeletedUri(d.uri));if(null==v)return u.info("no-op: file URI points to an unmounted volume",w),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:"volume is not currently mounted",state:a.SyncFileStates.skipped}),{...w,skipped:!0};const b=e.whyReject??await d.whyRejected();if(v||!(0,c.blank)(b)){const e={...w,rejected:b,deleted:v};return u.warn("file was deleted or rejected. Deleting.",e),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:v?"file no longer exists":"rejected: "+b,state:a.SyncFileStates.deleted}),d.delete(),!0!==p.skipAssetRepair&&m.Task.addOne("repairAsset",{assetId:d.assetId}),e}const S=await h.uri_();if(!await(0,l.uriIsEquivalent)(S,d.uri)){const e=await g(d,S,p);if(null!=e)return{...w,...e}}return!p.forceSync&&await d.matchesFile()?(u.info("no-op: file already matches db record",w),d.touch(),{...w,skipped:!0}):{...w,...await y(d,p)}}async function g(e,t,i){const n=(0,r.mkLogger)(`handleAssetFileUriChange(${e.id})`),a=(0,u.uniq)([...(0,l.uriEncodingVariants)(e.uri),...(0,l.uriEncodingVariants)(t)]);n.warn("URI is changing. Avoiding duplicate keys.",{priorUri:e.uri,variants:a});const o=f.AssetFile.ops().allf((t=>t.whereIn("uri",a).andWhereNot({id:e.id})));if((0,u.isNotEmpty)(o)){n.warn("Found other AssetFiles with equivalent URIs.",{afIds:o.map((e=>e.id))});const t=[e,...o],r=(0,s.sortAssetFiles)(t);if((0,u.isEmpty)(r))return n.warn("sortAssetFiles returned undefined",{arr:t.map((e=>(0,d.pick)(e,"id","uri"))),variants:a}),{error:"sortAssetFiles returned undefined"};const l=t.map((e=>e.id));for(const e of r)if(await e.exists()){f.AssetFile.dbl.runf((t=>t.whereIn("id",l.filter((t=>t!==e.id))).delete()));const r=y(e,i);return h.Asset.dbl.runf((e=>e.update({version:0,updatedAt:Date.now()}).whereIn("id",(0,u.uniq)(t.map((e=>e.assetId)))))),r}}n.info("no-op, no duplicate URIs.")}async function y(e,t){const i=Date.now();return null!=await e.upsertIfNeeded_(void 0,t)&&h.Asset.touch([e.assetId]),(0,a.syncReport)().onProgress({path:await e.getNativePath(),elapsedMs:Date.now()-i,from:"updateAssetFileIfNeeded()",state:e.syncState??a.SyncFileStates.unknown}),{assetFileId:e.id}}t.updateAssetFile=async function(e){try{return await p(e)}catch(t){return{id:e.assetFileId,...e,error:(0,n.errorToS)(t)}}},t.updateAssetFile_=p,t.handleAssetFileUriChange=g,t.updateAssetFileIfNeeded=y},68640:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetPreviews_=void 0;const r=i(99331),s=i(38835),n=i(48604),a=i(50213),o=i(69589),l=i(87001),u=i(40958),c=i(45599),d=i(50357),h=i(31586),f=i(68708),m=i(59455),p=i(43487),g=(0,c.defer)((()=>(0,a.mkLogger)("sync-file.UpdateAssetPreviews")));t.updateAssetPreviews_=async function(e){const t=e.assetId??e.asset?.id??(0,m.toA)(e.assetFiles).find((e=>(0,h.gt0)(e.assetId)))?.assetId,i=(0,o.forceContextOrSetting)(e),a=g().addContext(".Asset:"+t);if(i.skipPreviews)return void a.warn("skipPreviews is true: no-op");if(!(0,h.gt0)(t))return a.throw("invalid assetId",{assetId:t});const c=e.asset??p.Asset.ops().findById(t);if(null==c)return a.throw("Asset:"+t+" not found");a.throwIfAborted_(i.halt);try{const e=await c.getExistingAssetFiles();if((0,u.isEmpty)(e))return void a.warn("no existing assetFiles",{asset:c});const r=n.Previews.instance().ap(t),o=await r.readInfo();a.throwIfAborted_(i.halt);const h=await(0,n.buildAssetPreviews_)({...i,assetId:t,assetFiles:e}),m=e.find((e=>e.id===h?.assetFileId))??e.find((e=>(0,l.uriIsEquivalent)(h?.uri,e.uri)));a.info("buildAssetPreviews_()",{result:h,primaryAssetFile:m});const p=await(m?.posixFile_());if(null==m||null==p||!0!==await(p?.exists()))return a.throw("buildAssetPreviews_() returned invalid assetFileId"+s.InternalErrorFlag,{newInfo:h,assetFiles:e.map((e=>(0,f.pick)(e,"id","uri"))),primaryAssetFile:m,primaryPosixFile:p});const g=(0,d.eql)(o,h),y=null==h||g;return{...h,noop:y}}catch(e){throw(0,r.ending)()||(a.warn("Failed to update previews. Un-showing asset "+t,{error:e}),c.markUnshownAndUpsert()),e}}},7656:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rebuildTagAssetCounts=t.DirectAssetCountForTagQuery=t.RecursiveAssetCountForTagQuery=t.nonLeafTagIds=void 0;const r=i(50213),s=i(56038),n=i(95704),a=i(38156),o=i(42659),l=i(45599),u=i(41400),c=i(31586),d=i(51926),h=(0,l.defer)((()=>(0,r.mkLogger)("tag.TagAssetCounts")));function f(e){return e.prepare((0,d.compressWhitespace)("SELECT"," t1.id,"," count(t2.id) AS cnt","FROM"," Tag t1"," JOIN Tag t2 ON t1.id = t2.parentId","GROUP BY"," 1","HAVING"," cnt > 0")).pluck().all()}async function m(e,i=[]){const r=e.prepare(t.RecursiveAssetCountForTagQuery).pluck(),o=e.prepare(t.DirectAssetCountForTagQuery).pluck(),l=e.prepare("UPDATE Tag SET assetCount = :assetCount, updatedAt = :updatedAt WHERE id = :tagId"),c=new Set(f(e)),d=new a.PushProgressObserver({op:"Rebuilding tag asset counts"},e.prepare("SELECT count(*) FROM Tag").pluck().get());await(0,n.withIdBatches)({db:e,tableName:"Tag",primaryKeyColumnName:"id",whereClauses:i,async fn(e){for(const t of e){const e=!c.has(t);(0,s.timeSync)("db.rebuildTagAssetCounts("+(e?"leaf":"cte")+")",(()=>{const s=(e?o:r).get({tagId:t});l.run({tagId:t,assetCount:s,updatedAt:Date.now()}),d.incrProgress(),h().debug("_rebuildTagAssetCounts()",{isLeaf:e,whereClauses:i,tagId:t,assetCount:s})})),t%10==0&&(h().throwIfAborted_(),await(0,u.delay)(1))}}}),d.completed()}t.nonLeafTagIds=f,t.RecursiveAssetCountForTagQuery=(0,d.compressWhitespace)("WITH RECURSIVE descendants(id) AS ("," VALUES (:tagId)"," UNION"," SELECT Tag.id"," FROM Tag, descendants"," WHERE Tag.parentId = descendants.id",")","SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," descendants"," JOIN AssetTag ON AssetTag.tagId = descendants.id"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL"),t.DirectAssetCountForTagQuery=(0,d.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," AssetTag"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," AssetTag.tagId = :tagId"," AND Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL;"),t.rebuildTagAssetCounts=async function(e,t=o.minuteMs){if(await(0,s.time)("db.rebuildNullTagAssetCounts",(()=>m(e,["assetCount IS NULL"]))),(0,c.gt0)(t)){const i=e.prepare("SELECT min(updatedAt) FROM Tag").pluck().get(),r=Date.now()-i;if(rm(e)))}},69032:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.displayNameForVolsha=t.fixFileRootTag=t.runTagMaintenance=t.forceRunTagMaintenance=t.tagFtsRebuild=void 0;const s=r(i(76760)),n=i(19851),a=i(50213),o=i(7282),l=i(409),u=i(1728),c=i(56038),d=i(34102),h=i(49076),f=i(69589),m=i(28874),p=i(42231),g=i(85087),y=i(98770),w=i(59107),v=i(63870),b=i(7014),S=i(22573),P=i(42659),_=i(41400),T=i(75240),M=i(31586),E=i(34666),D=i(51926),x=i(75020),k=i(54017),F=i(48723),C=i(98784),A=i(7656),I=(0,n.lazy)((()=>(0,a.mkLogger)("tag.TagSql")));t.tagFtsRebuild=(0,n.lazy)((()=>(0,c.time)("db.rebuildTagFts",(()=>C.TagFts.rebuild()))),10*P.minuteMs),t.forceRunTagMaintenance=async function(e={forceSync:!0,recountAllTags:!0}){return I().info("forceRunTagMaintenance()"),await t.runTagMaintenance.force(e)};const O=((0,o.isTest)()?5:30)*P.secondMs;t.runTagMaintenance=(0,l.rateLimited)({name:"runTagMaintenance",minCallDelayMs:O,f:async e=>{const i=(0,f.forceContextOrSetting)(e),r=Date.now(),s=I().addContext(".runTagMaintenance()");s.info("starting",{ctx:i});try{s.info("validating all tags..."),F.Tag.validate_(),s.throwIfAborted_(i?.halt),await L(),i.recountAllTags&&(s.info("rebuilding tag search index..."),await(0,t.tagFtsRebuild)(),s.info("rebuilding tag asset counts..."),await(0,A.rebuildTagAssetCounts)(F.Tag.dbl.db().db,0))}catch(e){I().warn("runTagMaintenance() failed",e)}const n=Date.now()-r,a=(0,M.clamp)(O,15*P.minuteMs,20*n);t.runTagMaintenance.setMinCallDelayMs(a),I().info("runTagMaintenance(): complete.",{newMinCallDelayMs:a,elapsedMs:n})}});const L=(0,y.lazyFsAsync)("updateTagMountpoints",(async()=>{I().info("updating tag mountpoints...");const e=F.Tag.findByPath([x.TagRoots.fs]);if(null!=e){e.maybeUpsertDisplayName(m.Settings.tagDisplayNameFS.valueOrDefault);for(const t of e.getChildren())await N(t)}else(0,a.mkLogger)("updateTagMountpoints()").info("No root filesystem tag (new db, I hope?)")}));function R(){t.tagFtsRebuild.unset(),L.unset()}async function N(e){if(null==e||2!==e.depth||!e._path.startsWith(x.TagRoots.fs+p.TagSep))return;const i=(0,a.mkLogger)("fixFileRootTag("+e+")");if(e.name===x.LibraryTagName)return void(1!==e.ordinal&&(i.info("fixing library ordinal",{id:e.id,path:e.path}),e.upsert({ordinal:1}),F.Tag.clear()));if((0,f.forceContextOrSetting)().forceSync&&(0,S.notBlank)(e.displayName)&&(0,E.gt)(e.updatedAt,Date.now()-(0,v.volumeMetadataTtlMs)()))return void i.info("no-op: tag recently updated",{id:e.id,path:e.path,updated:(0,T.fmtDuration)(Date.now()-e.updatedAt)+" ago"});const r=await(0,t.displayNameForVolsha)(e.name);(0,S.notBlank)(r)?(e.maybeUpsertDisplayName(r),i.info("updated tag",{id:e.id,path:e.path,displayName:r}),F.Tag.clear()):i.debug("cannot update tag: no current volume.",{id:e.id,path:e.path})}(0,_.later)((()=>{(0,d.ee)().on("clearCache",R),m.Settings.libraryDir.watchLater(R)})),t.fixFileRootTag=N,t.displayNameForVolsha=(0,u.memoizeAsync)((async e=>{const t=(0,a.mkLogger)("displayNameForVolsha("+e+")"),i=await(0,b.volumes)();if(null!=i){const r=i.find((t=>(0,g.volsha)(t.uuid)===e));return t.info("find()",{vol:r}),null!=r?m.Settings.tagDisplayNameFSLabels.valueOrDefault&&(0,S.notBlank)(r.label)?r.label.trim():"/"===r.mountpoint?m.Settings.tagDisplayNameFSRoot.valueOrDefault+(m.Settings.tagDisplayNameFSRootWithHostname.valueOrDefault?" on "+(0,h.hostname)():""):(0,S.notBlankOr)((0,D.stripPrefixSuffix)(r.mountpoint,{prefix:s.default.sep,suffix:s.default.sep}),s.default.sep):k.AssetFile.dbl.pluckFirstf((t=>t.select("mountpoint").whereLike("uri","psfile://"+e+"/%").limit(1)))}}),{name:"tag.displayNameForVolsha",maxSize:64,timeoutMs:(0,v.volumeMetadataTtlMs)()}),(0,_.later)((()=>{w.mountpoints.watch((()=>t.displayNameForVolsha.clear()))}))},90858:e=>{"use strict";e.exports=require("@iarna/toml")},53705:e=>{"use strict";e.exports=require("@photostructure/tz-lookup")},16436:e=>{"use strict";e.exports=require("@sentry/node")},64770:e=>{"use strict";e.exports=require("assert")},58587:e=>{"use strict";e.exports=require("batch-cluster")},87550:e=>{"use strict";e.exports=require("better-sqlite3")},6858:e=>{"use strict";e.exports=require("commander")},36507:e=>{"use strict";e.exports=require("croner")},66261:e=>{"use strict";e.exports=require("events")},77988:e=>{"use strict";e.exports=require("exiftool-vendored")},66150:e=>{"use strict";e.exports=require("fast-xml-parser")},68817:e=>{"use strict";e.exports=require("file-type")},44652:e=>{"use strict";e.exports=require("fs-extra")},28787:e=>{"use strict";e.exports=require("he")},31832:e=>{"use strict";e.exports=require("knex")},51168:e=>{"use strict";e.exports=require("luxon")},93973:e=>{"use strict";e.exports=require("ml-kmeans")},80265:e=>{"use strict";e.exports=require("moo")},31704:e=>{"use strict";e.exports=require("nearley")},4927:e=>{"use strict";e.exports=require("papaparse")},83058:e=>{"use strict";e.exports=require("picomatch")},57272:e=>{"use strict";e.exports=require("plist")},85949:e=>{"use strict";e.exports=require("process")},90595:e=>{"use strict";e.exports=require("punycode")},38064:e=>{"use strict";e.exports=require("semver")},9288:e=>{"use strict";e.exports=require("sharp")},49378:e=>{"use strict";e.exports=require("trash")},73872:e=>{"use strict";e.exports=require("type-detect")},92460:e=>{"use strict";e.exports=require("util")},75162:e=>{"use strict";e.exports=require("util/types")},29907:e=>{"use strict";e.exports=require("cluster")},76982:e=>{"use strict";e.exports=require("crypto")},31421:e=>{"use strict";e.exports=require("node:child_process")},77598:e=>{"use strict";e.exports=require("node:crypto")},40610:e=>{"use strict";e.exports=require("node:dns")},78474:e=>{"use strict";e.exports=require("node:events")},73024:e=>{"use strict";e.exports=require("node:fs")},51455:e=>{"use strict";e.exports=require("node:fs/promises")},37067:e=>{"use strict";e.exports=require("node:http")},44708:e=>{"use strict";e.exports=require("node:https")},77030:e=>{"use strict";e.exports=require("node:net")},48161:e=>{"use strict";e.exports=require("node:os")},76760:e=>{"use strict";e.exports=require("node:path")},53916:e=>{"use strict";e.exports=require("node:path/posix")},1708:e=>{"use strict";e.exports=require("node:process")},57075:e=>{"use strict";e.exports=require("node:stream")},46466:e=>{"use strict";e.exports=require("node:stream/promises")},87997:e=>{"use strict";e.exports=require("node:timers")},57975:e=>{"use strict";e.exports=require("node:util")},38522:e=>{"use strict";e.exports=require("node:zlib")},16928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=53493);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/bin/logcat.js b/bin/logcat.js index bef36de..d766cbf 100755 --- a/bin/logcat.js +++ b/bin/logcat.js @@ -6,4 +6,4 @@ * IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THIS SOFTWARE */ -(()=>{"use strict";var __webpack_modules__={37975:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),n=i(38639),s=i(44198);function o(){return(0,n.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=o;let a=!o();function l(){return a}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){a=e??!o()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),n=i(7282),s=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,n.isProd)()?"":`-${(0,n.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),n=i(36783),s=i(76790),o=i(22573),a=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const n=new Set(t.map(i));return e.filter((e=>n.has(i(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...v(e.slice(i+1))]}function w(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function E(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,i){return x(e,t,i).index}function x(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let n,s=-1;for(let r=0;re.slice(i,i+t)))}async function T(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,a.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(o.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,a.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,n.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let n=0;for(const s of e)(t(s,n++)?i:r).push(s);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let n=0;ne.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=E,t.least=function(e){return E(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const i=x(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=C,t.collectBatched=function(e,t,i){const n=[];for(const s of C((0,r.compact)((0,f.toA)(e)),t))n.push(...(0,r.compact)(i(s)));return n},t.collectBatchedAsync=async function(e,t,i){const n=[];for(const s of C((0,r.compact)((0,f.toA)(e)),t))n.push(...(0,r.compact)(await i(s)));return n},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await T(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+n;if(re+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const a=i(77988),l=o(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),v=i(25764),w=i(38836),S=i(99331),b=i(95937),P=i(98314),_=i(38835),E=i(70025),M=i(8769),x=i(43334),C=i(95402),T=i(28874),D=i(63870);class k extends w.EndableWrapper{constructor(e,t,i=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,r,"m",n).call(this)),i,"worker"===e?(0,D.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const o=t;o.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,C.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),o.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),o.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),o.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),o.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),o.on("noTaskData",((e,i,r)=>{const n=t.options.streamFlushMillis;n{this.logger.error("observeBatchCluster.endError()",e)})),o.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&C.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof a.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,E.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=k,r=new WeakSet,n=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(x.isWin?3:1)*c.minuteMs,maxTasksPerProcess:T.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:T.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:T.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:T.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:T.Settings.taskTimeoutMs.valueOrDefault}}},89788:function(e,t,i){var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(r.add(this),this.maxLength=e,n.set(this,void 0),s.set(this,0),o.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,n,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",a).call(this,e,(e=>u(this,n,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",a).call(this,e,(e=>u(this,n,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,o,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,n,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,n,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,r,"m",a).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,n,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,s,"f"){u(this,n,"f")[e]=c,l(this,o,e,"f")}));return u(this,s,"f")}shift(){return u(this,r,"m",a).call(this,0,(e=>{var t,i;return l(this,o,(t=u(this,o,"f"),++t),"f"),l(this,s,(i=u(this,s,"f"),--i),"f"),u(this,n,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",a).call(this,u(this,s,"f")-1-e,(e=>{const i=u(this,n,"f")[e];u(this,n,"f")[e]=u(this,n,"f")[t],u(this,n,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),n=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:i}of n)if(o(e,t))return e.subarray(t.length).toString(i);return e.toString()}function o(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,r.toS)(e)},t.bufferStartsWith=o},9092:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class n{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=n},36638:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class n{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=n},40583:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const o=i(40958),a=i(23838),l=s(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new a.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,o.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,n=-1;for(const[i,s]of this.m.entries()){const o=(0,c.diceCoeff)(i,e);if(o>t&&o>n){const e=this.getFirst(s);null!=e&&(r=e,n=o)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),n=i(31586),s=i(68708),o=i(54993),a=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new a.Average(0);for(const t of this.keys()){if(!(0,n.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,o.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,n.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new a.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,n]of this.m.entries()){const s=e(r);t.fill(s,i,i+n),i+=n}return t}}t.CountingSet=u},79840:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),n=i(72993),s=i(45969),o=i(43334);t.EditionType=(0,r.lazy)((()=>o.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>n.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),n=i(55835),s=i(68708);var o=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return o.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,n.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,s.omit)(e,...i),(0,s.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,n.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),n=i(19851),s=i(95696);t.examples=(0,n.lazy)((()=>s.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),n=i(65843),s=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,n.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,s.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),n=i(40958),s=i(55835),o=i(31586),a=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,o.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,o.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,n.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,n.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,a.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,a.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,a.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,o.isNumber)(e.__uid)&&(0,o.isNumber)(e.__start)}},80049:function(e,t,i){var r,n,s,o,a,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),n.set(this,0),s.set(this,0),o.set(this,0),a.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,n,l(this,n,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,o,l(this,o,"f")+e.rejections,"f"),u(this,a,l(this,a,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,n,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,o,"f"),timeouts:l(this,a,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,o,a;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,n,(i=l(this,n,"f"),++i),"f"),c.promise):(u(this,r,(o=l(this,r,"f"),++o),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(a=l(this,r,"f"),++a),"f"),c}get(e){var t,i;const n=this.cache.get(e);return null==n||n instanceof m.Deferred&&n.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),n instanceof m.Deferred?n.value:n}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,n,0,"f"),u(this,s,0,"f"),u(this,o,0,"f"),u(this,a,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,o,(t=l(this,o,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,a,(r=l(this,a,"f"),++r),"f")})),r.promise}},r=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap},54127:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,o.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,n.range)(0,r).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,a.fromEntries)(e))).filter((e=>(0,a.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,a=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(a,r.index);(0,s.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),h=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:h});else{const e=(0,n.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,o.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}a=t.lastIndex}const l=(0,n.last)(i);return null!=l&&((0,s.blank)(this.headerRow.slice(a))?l.rightIdx=(0,o.max_)(...this.rows.map((e=>e.length))):l.rightIdx=a),i}}t.Fixed=m},73913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),n=i(98553);var s=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const i=(0,n.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,n.parseJSON)((await(0,r.readFile)(e)).toString())}},19851:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const o=i(57975),a=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,r,"m",n).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,a.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(42659),a=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,a.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?E():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=w.exec(e.trim())?.groups;return null==i?void 0:(0,n.compact)([i.lang,i.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const _={timeoutMs:10*o.secondMs};async function E(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return b(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=E,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),n=i(1708),s=i(45599),o=i(68708),a=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,s.defer)((()=>{(0,a.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:n.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,o.pick)(n.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:n.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),n=i(32105),s=i(14593);t.rootLoggers=(0,r.lazy)((()=>[n.ConsoleLogger.instance()]));const o=(0,r.lazy)((()=>[n.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,o)}},56639:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),n=i(55835),s=i(59455),o=i(48884);function a(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,o.concat)(...e.map((e=>t(e)))))},t.compactMap=a,t.toMap=function(e,t){return a((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:a(await Promise.all((0,r.compact)((0,s.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,n.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),n=i(54557);t.memoize=function(e,t){let i=0;const s=new n.FifoCache(t.maxSize,t.ttlMs),o=t=>{if(null!=t)return i++,s.getOrSet((0,r.stringify)(t),(()=>e(t)))};return o.clear=e=>null==e?s.clear():s.delete((0,r.stringify)(e)),o.size=()=>s.size,o.callCount=()=>i,o}},7282:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const n=r(i(1708)),s=i(38639),o=i(54993),a=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,a.lazy)((()=>n.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,o.toS)(n.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return n.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(n.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){n.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),n=i(22573),s=i(96249),o=i(55835),a=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,a.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(a.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,a.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,o.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,a.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,a.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,a.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,a.toInt)(e),n=(0,a.toInt)(t);return null!=r&&r>0&&null!=n&&n>0?i(r,n):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,a.isNumber)(e))return e;if((0,n.blank)(e))return;const t=String(e);return(0,o.map)(f.exec(t),(e=>(0,a.toFloat)(t.substr(e.index))))}function p(e){return(0,a.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,o.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,o.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const n=i*e.length;for(let i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),n=i(42659),s=i(96249),o=i(55835),a=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,n.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,n]of(0,l.entries)(e)){const e=t(r,n);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,o.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(o.defined)},t.firstDefinedField=function(e,...t){return(0,o.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,o.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const n of t)r[n]=i(n,e[n]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let n=0;for(const s of(0,l.keys)(e))if(r[s]=t(s,e[s]),n++,(0,a.gt)(n,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,s.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),n=i(73024),s=i(48161),o=i(19851),a=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),v=i(30933),w=(0,o.lazy)((()=>(0,f.mkLogger)("os")));function S(){return(0,s.platform)()+" "+(0,s.release)()}t.osArch=(0,o.lazy)((()=>`${function(){switch((0,s.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return k();case"win32":return O();default:return S()}}()} on ${(0,s.arch)()}`)),t.osFullName=(0,o.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const b=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function _(){return"ubuntu"===(0,t.osDistributionLinux)()}function E(){return"fedora"===(0,t.osDistributionLinux)()}function M(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,o.lazy)((()=>{if(g.isLinux)for(const e of b)try{const t=(0,n.readFileSync)(e).toString();if((0,a.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,o.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,a.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),S)})),t.osDistributionLinux=(0,o.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=_,t.hasApt=function(){return P()||_()},t.isFedora=E,t.isAlpine=M;const x={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},C={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function T(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),n=t[i];return(0,c.isString)(n)?n:n?.[r]}const D=(0,o.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function k(e=D()){try{return(0,a.mapNotBlankOr)(function(e=D()){return T(e,x)}(e),(t=>`macOS ${t} (${e})`),S)}catch(e){return w().warn("osNameMac(): unknown release",e),S()}}function O(e=(0,s.release)()){const t=e.startsWith("10.0.22")?"11":T(e,C);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=k,t.osNameWin=O,t.CPUs=(0,o.lazy)((()=>(0,h.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,o.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(O())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=D();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(_())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(E())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(M())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},12801:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const n=r(i(48161)),s=i(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:n.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:n.default.constants.priority.PRIORITY_NORMAL,BelowNormal:n.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:n.default.constants.priority.PRIORITY_LOW,Low:n.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),n=i(56409),s=i(31586),o=i(22911),a=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...r){f=!0,m=Date.now()+(0,s.max_)(t,i);const n=d=new o.Deferred(c);(0,s.gt0)(i)&&n.setTimeout(i);try{n.resolve(await e(...r))}catch(e){n.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,a.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return n.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,r.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new n.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),n=i(54993);function s(e){return e instanceof o?e.source:(0,n.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let n;for(;null!=(n=e.exec(t));)n.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(n,"index","groups"));return i},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(s(t))}const n=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(n,i)};class o{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=o;class a extends o{static from(...e){const t=l(e);return new a("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,a=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof o||t instanceof RegExp?(i+=t.source,r||(r=t.global),a||(a=t.ignoreCase),l||(l=t.multiline)):i+=s((0,n.toS)(t));return new RegExp(i,t??(r?"g":"")+(a?"i":"")+(l?"m":""))}t.RegExpOptional=a,t.concatRegexp=l},79089:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const n=r(i(48161)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),v=i(34102),w=i(43334),S=i(24399),b=i(28874),P=(0,o.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,o.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,a.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let E=!0;const M=(0,o.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const i=(0,p.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),E)try{return n.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;E=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const n=r(i(1708)),s=i(19851),o=i(40958),a=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===a.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===a.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===a.ServiceNames.sync}function p(){return(0,t.serviceName)()===a.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,o.compactBlanks)([t.serviceName.prior(),(0,l.toS)(n.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return a.ServiceNames.indexOf(e)??a.ServiceNames.length+1},t.MainServices=[a.ServiceNames.main,a.ServiceNames.desktop],t.DbServices=[a.ServiceNames.sync,a.ServiceNames.info,a.ServiceNames.web,a.ServiceNames.list,a.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[a.ServiceNames.sync,a.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===a.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===a.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,s.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function n(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=n,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=n(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=n(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),n=i(57150),s=i(7282),o=i(23560),a=i(17181);t.setServiceName=function(e){(0,o.isMainService)(e)&&(e=r.ServiceNames.main);const t=o.serviceName.prior();t!==e&&((0,s.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),o.serviceName.set(e),(0,a.setupLogger)(),(0,n.logStartup)())}},28850:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const a=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends a.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),n.set(this,void 0),s(this,r,e,"f")}_call(){return(0,l.time)(o(this,r,"f")+(null==o(this,n,"f")?"(local)":"(remote)"),null==o(this,n,"f")?this.impl():o(this,n,"f").call(this))}setShim(e){s(this,n,e,"f")}hasShim(){return null!=o(this,n,"f")}clearShim(){s(this,n,void 0,"f")}}r=new WeakMap,n=new WeakMap},12089:function(e,t,i){var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,o){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=o,n.set(this,void 0),s.set(this,void 0),l(this,n,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",a).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",o).call(this,e),(()=>u(this,r,"m",a).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",o).call(this,e))}}n=new WeakMap,s=new WeakMap,r=new WeakSet,o=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},a=function(e){return(0,m.time)(u(this,n,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=i(76790),o=i(17586);class a{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return n(this,r,"f")[Symbol.iterator]()}get length(){return n(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=n(this,r,"f").length-1;for(;t<=i;){const s=t+Math.floor((i-t)/2),o=this.valueOf(n(this,r,"f")[s]);if(e===o)return{found:!0,index:s};e>o?t=s+1:i=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&n(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...n(this,r,"f")];const o=t=>t<0||t>n(this,r,"f").length-1?null:(i??this.diff)(n(this,r,"f")[t],e),a=this.findIndex(e);if(null==a)return;let l=a.index-1,u=o(l),c=a.index,d=o(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return n(this,r,"f").shift()}at(e){return(0,o.at)(n(this,r,"f"),e)}toA(){return[...n(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===n(this,r,"f").length-1){const e=[...n(this,r,"f")];return n(this,r,"f").length=0,e}return n(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return n(this,r,"f").splice(e,t)}retainLastN(e){return e{Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),n=i(82328),s=i(84542),o=i(95705),a=i(28874);t.consoleLog=function(e,...t){a.Settings.quiet.valueOrDefault||(0,n.stdoutEnded)()||console.log((0,s.crlf)(e),...t)},t.consoleError=function(e){a.Settings.quiet.valueOrDefault||(0,o.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=a.Settings.quiet.envValue;try{return a.Settings.quiet.envValue=!0,await e()}finally{a.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),n=i(95705);t.stdoutEnded=function(){return(0,n.streamEnded)(r.stdout)}},71567:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const n=r(i(1708)),s=i(22573),o=i(98553),a=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:n.default.stdout})}function f({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const n=(0,o.stringify)(e,void 0,(0,a.isInfoService)()||(0,a.isMainService)()?2:void 0);r.write(n+"\n"),(0,a.isWorkerService)()&&null!=i&&(n.includes(u.FailStr)||(0,c.isFatalError)(n)||(0,c.isHealthCheckError)(n)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||n.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:n.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(55835),a=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const n=t.indexOf(i,r);return-1===n?0:1+e(t,i,n+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,a.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,h.toS)(e),n=(0,h.toS)(t);return n.length>0&&(0,c.equalsIgnoreCase)(r.slice(-n.length),n,i)?r.slice(0,-n.length):r},t.gist=function(e,t=80,i=80){const r=(0,h.toS)(e),n=r.length-(t+i);return n<=0?r:r.slice(0,t).trim()+" …(+"+n+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,o.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=S(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,s.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),n=t.indexOf(r);if(n>=0)return{index:n,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function E(e){return _.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=E;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(E(e))&&(e=e.slice(1,-1).trim())),e};const x=/^['‘’].*['‘’]$/,C=/^["“”„«»〃].*["“”„«»〃]$/;function T(e,t){const i=D(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function D(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let n,s=0;for(;null!=(n=t.exec(e));)n.index===t.lastIndex?t.lastIndex++:(t.lastIndex=n[0].length+n.index,i.push(e.substring(s,n.index)),r.push(e.substring(n.index,t.lastIndex)),s=t.lastIndex);return s(0,a.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),x.test(e)||C.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),n=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,o.map)(i[e],(e=>t+=e))));return t},t.splitKeep=T,t.splitUp=D,t.sortNaturalBy=k,t.sortNatural=function(e){return(0,n.sortBy)(e,(e=>k(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,n.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,a.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const O=/#.*$/gm;t.stripComments=function(e){return e.replace(O,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,s.blank)(r))for(const e of r.split(t))(0,s.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,s.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),n=e.findIndex((e=>r.test(e))),o=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(n<0)return e;for(let t=n+1;te.trim()))))}},83556:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function n(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=n,t.asObjectKey=function(e){return n(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const n=r(i(77598)),s=i(73913),o=i(55222);function a(e,t=s.HashBits){return n.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=o.Radix58,r=224){return i.encodeBuffer(a(e,r)).substring(0,t)}t.stringShaToBuffer=a,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=o.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(31586),a=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,n="";for(let s=0;s=r&&(r=i.get(s,o),n=(0,l.substr)(e,s-r+1,r)));return n}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),n=t.normalize();return e!==r||t!==n?y(r,n):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function v(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===r?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(i),t=w(r);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function S(e,t){const i=(0,f.intersection)(e,t),n=[];return i.forEach((i=>{const s=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,o.times)(s,(()=>n.push(i)))})),n}function b(e,t,i){const n=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,n))-i((0,l.strslice)(t,n))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,n.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[i,r]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(i,r,(e=>(0,o.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=_;const E=/[^\da-z]+/gi;function M(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(E,"").toLowerCase()));return b(i,r,(e=>c.RadixAlphaNum.decode(e)))}function x(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const n=(0,o.mapNumericOr)(e.charCodeAt(r),(e=>e),256),s=(0,o.mapNumericOr)(t.charCodeAt(r),(e=>e),256),a=(0,o.clamp)(-256,256,n-s);i=null==i?a:(i+a)/2}return i}t.radixDiff=M,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=x,t.paddedPositionalDiff=function(e,t,i=8){return x((0,a.leftPad)(e,i," "),(0,a.leftPad)(t,i," "))}},84885:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),n=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,n.sortedKeys)(e))}},75387:function(e,t,i){var r,n,s,o,a,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",n.set(this,[]),s.set(this,new Map),o.set(this,void 0),a.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,o,"f")}set ttlMs(e){h(this,o,e,"f"),null!=d(this,a,"f")&&clearInterval(d(this,a,"f")),h(this,a,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,a,"f")&&clearInterval(d(this,a,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,s,"f").clear(),this}delete(e){return d(this,s,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,s,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,s,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,s,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const n=t();return null!=n&&this.set(e,n),n}lastSetOrGetTs(e){return d(this,s,"f").get(e)?.ts}set(e,t){return d(this,s,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,s,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,s,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,f.sortBy)(d(this,s,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,n,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,s,"f").delete(e);for(const i of d(this,n,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,s,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[o]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return a(this,r,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>a(this,r,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||a(this,r,"m",n).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)a(this,r,"m",n).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!a(this,r,"m",n).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)a(e,r,"m",n).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)a(e,r,"m",n).call(e,t,i)||(yield[t,t])}()}toA(){return a(this,r,"m",s).call(this),[...this.delegate.keys()]}[(r=new WeakSet,o=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,n=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},s=function(){for(const[e,t]of this.delegate)a(this,r,"m",n).call(this,e,t)}},84699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},94174:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const n=r(i(48161)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,o.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,o.lazy)((()=>(0,a.uniq)([s.default.geteuid?.(),s.default.getuid?.(),n.default.userInfo().uid]))),t.userid=(0,o.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,o.lazy)((()=>(0,a.uniq)([s.default.getegid?.(),s.default.getgid?.(),n.default.userInfo().gid]))),t.groupid=(0,o.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,o.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,o.lazy)((()=>(0,l.toNotBlank)(n.default.userInfo()?.username))),t.userNameFromWhoami=(0,o.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,o.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,o.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,o.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.0-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=0,t.versionPrerelease=["prealpha"],t.release="2024.3.0-prealpha+20240308102353",t.gitSha="92cba1b21937cb9ca770f6a339e44b0fbee04bf9",t.gitDate=new Date(1709922233e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),n=i(55835),s=i(31586),o=i(97790),a=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,n.allDefined)(i))return;const[o,a,u,c,d,h,f]=i,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(o,a-1,u,c,d,h,f/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,o.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,a.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},73568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const a=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),n.set(this,(0,a.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,n,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,n,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,n,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),o(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,r,"f")&&clearTimeout(s(this,r,"f")),o(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,n=new WeakMap},22911:function(e,t,i){var r,n,s,o,a,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(i(87997)),w=y(i(57975)),S=i(45599),b=i(26905),P=i(55835),_=i(31586),E=i(68708),M=i(20214),x=i(57153),C=i(85556),T=i(50213),D=i(70025),k=i(95937),O="TIMEOUT",F=(0,S.defer)((()=>(0,T.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,_.gt0)(t)?new n(O).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const n=i[r];if(n.isSettled){if(n.name===O)return void F().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield n.value}}if(i.every((e=>e.name===O)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new n(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),o.set(this,void 0),a.set(this,x.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=n,n,(y=p(i,n,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,T.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof n&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,a,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,E.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,o,"f")}get elapsedMs(){return(p(this,o,"f")??Date.now())-this.startedAt}get[(o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new C.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,k.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,a,"f")===x.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,a,"f")!==x.PromiseStates.pending}get isResolved(){return p(this,a,"f")===x.PromiseStates.resolved}get isRejected(){return p(this,a,"f")===x.PromiseStates.rejected}get settledMs(){return null==p(this,o,"f")?void 0:p(this,o,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,a,x.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,D.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,a,x.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,n=I,m=function(e){if(p(this,a,"f")===x.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,o,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},s={value:0}},27395:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),n=i(40958),s=i(42659),o=i(23838),a=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new o.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,a.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,n.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,n.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){var r,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",o).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,n.set(this,void 0),s.set(this,void 0),a.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,n,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",o).call(this);const h=()=>{u(this,r,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,n,(0,d.setInterval)(u(this,a,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,a,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):h(),!0}}t.EndableInterval=v,n=new WeakMap,s=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(){(0,h.map)(u(this,n,"f"),d.clearInterval),c(this,n,void 0,"f"),(0,h.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const a=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,o){this.endTimeoutMs=o,r.set(this,void 0),this.onEnds=[],n.set(this,(0,a.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,n,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){o(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,n,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,n=new WeakMap},99331:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let n=!1;t.ending=function(){return n},t.setEnding=function(e){n=(0,r.isTest)()?e:e||n}},45608:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const n=r(i(1708)),s=i(22573),o=i(45599),a=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,o.defer)((()=>(0,l.mkLogger)((0,a.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,o.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,s.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,f.endEndables)(),n.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,o.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])n.default[e].on(t,(i=>{v({reason:`${e}:${t}`,status:0,error:i})}))}))},5916:function(e,t,i){var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,n.set(this,void 0),s.set(this,0),o.set(this,void 0),a.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,o,"f")}unset(){d(this,s,0,"f"),d(this,n,void 0,"f"),d(this,o,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,a,"f").push(e)}prior(){return this.isStale()?void 0:c(this,o,"f")}lastValue(){return c(this,o,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,n,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,n,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,n,"f")?void 0:Date.now()-c(this,n,"f")}elapsedMs(){return c(this,o,"f")?.settledMs??c(this,o,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,a,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,a,"f"))e.onError(t)}finally{d(this,s,(i=c(this,s,"f"),++i),"f")}},u=function(e){d(this,n,Date.now(),"f");const t=c(this,o,"f");return d(this,o,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,o,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,o,"f")),c(this,o,"f")}},1728:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),n=i(80049);t.memoizeAsync=function(e,t){let i=0;const s=new n.FifoCacheAsync(t),o=t=>(i++,s.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return o.clear=e=>{if(null==e)return s.clear();{const t=(0,r.stringify)(e);return s.deleteIf((e=>t===e))}},o.size=()=>s.size,o.callCount=()=>i,o}},22781:function(e,t,i){var r,n,s,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),n.set(this,!1),s.set(this,!1)}_call(){return o(this,n,"f")?(a(this,s,!0,"f"),!0===this.undefinedIfBusy?void 0:o(this,r,"f")):(a(this,n,!0,"f"),a(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{a(this,n,!1,"f"),!0===this.runLaterIfBusy&&o(this,s,"f")&&(a(this,s,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return o(this,n,"f")}prior(){return o(this,r,"f")}async force(){return await o(this,r,"f"),this._call()}}r=new WeakMap,n=new WeakMap,s=new WeakMap},37461:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),n=i(76790),s=i(38639),o=i(42659),a=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),v=i(15674),w=i(42638);var S=i(20214);async function b(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:i,timeoutMs:n}){const s=[];for(const o of(0,r.compact)(await t))try{const e=await((0,l.gt0)(n)?(0,c.thenOrTimeoutError)(i(o),n):i(o));null!=e&&s.push([e,o])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:o,error:t})}return s}async function E({arr:e,f:t,name:i,maxConcurrent:n,timeoutMs:s,promises:o}){if(null==e)return[];const a=(0,r.compact)(await e);if((0,r.isEmpty)(a))return[];if((n=Math.round(n??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:i,timeoutMs:s});const u=o??(a.length<=n?w.PermissivePromises:new w.Promises(i,(()=>n))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,h=await u.enqueueAll(i,a.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,i){const r=[];for(const n of(0,p.batches)((0,f.toA)(await e),t)){const e=await b(n);r.push(...await b(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,a.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=E,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:n,promises:s}){return(await E({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:n,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:n,timeoutMs:s}){return(await E({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:n,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await E({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*o.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,n=null;try{r=await((0,h.isFunction)(e)?e():e)}catch(e){n=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(n??r)}catch{}if(null!=n)throw n;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,s.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const n=await t;return null!=n?i(r,n):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const n=await t(r);return null==n?i():n},t.thenMap2Or=async function(e,t,i,r){const n=await e;if(null==n)return r();const s=await t;if(null==s)return r();const o=await i(n,s);return null==o?r():o},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await E({name:e,arr:t,f:i});return(0,n.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(42659),a=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),v=i(25764),w=i(38836),S=i(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),n=(0,l.clamp)(10*o.secondMs,o.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),n);try{const n=await(0,c.tot)(t),s=Date.now()-r;return i?.(n,s),this.push(e,s),n}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,a.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/o.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function _(e,t,i){return P.instance().time(e,t,i)}function E(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,n.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const i=Date.now(),r=t();return E(e,Date.now()-i),r},t.pushTime=E,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>_(e,t)),i)}},42638:function(e,t,i){var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),v=i(54993),w=i(89788),S=i(82647),b=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){r.add(this),this.name=e,this.ee=new f.default.EventEmitter,n.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),o.set(this,[]),a.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,n,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,b.maxCpus)(),d(this,n,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,a,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,o,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,o,"f").map((e=>e.name)),pendingNames:d(this,a,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:i,serialId:n}){const s=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:n});return this.laterPop(),s}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,o,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,a,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,a,"f").length,e),i=this.runningSerialIds,n=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,o,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,a,"f").length}hasPending(){return d(this,a,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,a,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,a,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const n=new P.Deferred(e,{payload:i,serialId:r});return d(this,a,"f").push({d:n,l:t}),n},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,o,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,o,"f").push(e),e},t.maybeRun=function(e,t){const i=new _(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new _(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},4867:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),n=i(34546),s=i(41400),o=i(31586),a=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let a=!0;return Promise.race((0,r.compact)([(0,n.asPromise)(e).finally((()=>a=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>{if(a)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(a)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,n.asPromise)(e).finally((()=>l=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>a.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),n=i(42659),s=i(41400),o=i(32639),a=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,a.clamp)(10*m,l.ShortCommandTimeoutMs,(t??n.minuteMs)/5);await(0,s.delay)(r,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const n=r(i(1708)),s=i(45599),o=i(41400),a=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),v=i(50213),w=i(7282),S=i(88158),b=i(45969),P=i(43334),_=i(28874),E=i(3790);function M(e){return x().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const x=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,o.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const C=["HOME","LANG","USER"],T=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],D=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?C:T),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function k(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,_.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,a.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(n.default.env,(e=>M(e)||!(0,E.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=k,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:F({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let O=!1;function F({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const n=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...D(),...i?(0,g.childProcLocale)():{},...k(r),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(n);if((0,y.isLogged)("debug")&&!O){O=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(n).map((([e,t])=>[e,(0,E.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return n}t.childEnv=F},84777:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const n=r(i(31421)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),v=i(79089),w=i(45255),S=i(22911),b=i(4867),P=i(73614),_=i(70025),E=i(57159),M=i(36868),x=i(66184),C=i(45643),T=i(95402),D=i(9727),k=(0,o.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function O(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function F(e,t=30*u.secondMs){if(null==e)return!1;k().debug("endProcess()",O(e));const i=e.pid;if(null==i||i<=0)return k().warn("endProcess(): asked to end invalid pid",O(e)),!1;if(i===s.default.pid)return k().warn("endProcess(): asked to end MY pid",O(e)),!1;if(i===s.default.ppid)return k().warn("endProcess(): asked to end my parent pid",O(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();k().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,T.killPid)(i).catch((e=>{k().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,C.waitForPidExit)(i,t))return k().debug("endProcess(): exitted",O(e)),!0;{T.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");k().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,T.killPid)(i,!0).catch((e=>{k().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,C.waitForPidExit)(i,5e3)}function I(e,i,r,n=0){const o=new Date,a=[];return(0,v.niceable)(i,r)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(n,u.secondMs)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&F(e)}),n-250)),a.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,T.addPid)({pid:e.pid,cmd:i,timeoutMs:n,ppid:s.default.pid},o)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>a.forEach(clearTimeout))),e}function L(e,t,i,r){const s=(0,D.spawnOptions)(r);return(0,x.isLogged)("trace",k().context)?k().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:s}):k().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(n.default.execFile(e,t,s),e,t,i)}async function A(e,t,i){const r=i.quiet??!1,n=i.ignoreStderr??!1,s=i.ignoreExitCode??!1,o=L(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{o.disconnect?.()}catch{}return{result:"",pid:o.pid}}const u=o.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new S.Deferred(f);o.on("error",(e=>g.push(e))),o.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),o.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(o.stdin);const v=new d.Latch;null==o.stdout?v.resolve():(o.stdout.on("error",(e=>g.push(e))),o.stdout.on("data",(e=>m.push(e))),o.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==o.stderr||n?P.resolve():(o.stderr?.on("error",(e=>g.push(e))),o.stderr?.on("data",(e=>p.push(e))),o.stderr?.on("end",(()=>P.resolve()))),k().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),k().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt});const x=p.join("");(0,l.notBlank)(x)&&g.push(new Error(x)),!r&&(0,a.isNotEmpty)(g)&&k().warn(f+" resulted in errors:",g);const C=i.isIgnorableError??_.isIgnorableError,T=g.filter((e=>!0!==C(e)));if(T.length>0)throw 1===T.length?T[0]:new E.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:T});if(!s&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:x}}catch(e){throw k().error("stdoutResult_() failed",e),await(0,T.killPid)(o.pid,!0),e}}t.endProcess=F,t.ReniceAfterMs=(0,o.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,o.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const s=(0,D.spawnOptions)(r);return k().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(n.default.spawn(e,t,s),e,t,i)},t.execFile=L,t.stdoutResult_=A,t.stdout_=async function(e,t,i){const r=await A(e,t,i);return k().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},3790:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),n=i(41400),s=i(19851),o=i(28874);(0,n.later)((()=>o.Settings.sensitiveEnvRegExp.watchLater((()=>a.unset()))));const a=(0,s.lazy)((()=>{try{return new RegExp(o.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${o.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(o.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&a().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||o.Settings.license.includesEnvKey(e)}},34330:function(e,t,i){var r,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(54993),w=i(27395),S=i(25764),b=i(99331),P=i(42638),_=i(38835),E=i(8769),M=i(57159),x=i(66003),C=i(50213),T=i(45643),D=i(28874),k=i(84777);t.mkBasicWatchedChild=function(e){return new O({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,k.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class O{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,C.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),n.set(this,!1),this.onError=(e,t,i)=>{const s=new M.WrappedError(e,{cause:t}),o=!1!==s.ignorable;this.logger().log(o?"warn":"error","onError()",s),u(this,n,"f")||o||(this.lastError=s,(0,E.onError)(s),!0!==s.fatal?(i??this.opts.onError(e,s))&&(this.logger().warn("onError requested restart",{src:e,error:s}),u(this,r,"m",a).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:D.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:S.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,w.addEndable)(this.opts.endableRank,this),u(this,r,"m",a).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,n,"f")}async end(){return c(this,n,!0,"f"),u(this,r,"m",s).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",s).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,n,"f")}),!u(this,n,"f")&&!(0,b.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,D.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",s).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:D.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,n,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=O,n=new WeakMap,r=new WeakSet,s=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,n,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",o).call(this,e)},o=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,T.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,k.endProcess)(e,this.endTimeoutMs)},a=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,n,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",s).call(this),!this._stopped&&!u(this,n,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,E.onError)("Can't restart "+this.name+", failure rate is too high."+_.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,n,"f")}),this._stopped||u(this,n,"f")||(0,b.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,x.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,v.toS)(e).includes("Error: Cannot find module")&&(0,E.onError)("Failed to start "+this.name+_.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,n,"f")}),(0,b.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",a).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const o=s(i(53916)),a=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,a.toNativePath_)(e);const i=f.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),n=i.sibling(r);if(n.isSelfOrDescendantOf((0,l.examples)()))return o.join("$examples",n.posixPathFrom((0,l.examples)()));const s=(0,d.originalsDir)();if(n.isSelfOrDescendantOf(s))return o.join("$library",n.posixPathFrom(s));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?o.join("$library",n.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const s=i(6858),o=i(1708),a=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),h=i(43334),f=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return n(this,r,"f").push(...e),this}async parse(e=o.argv,t){let i=(0,m.addHelpFooter)(new s.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of n(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":a.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,o.exit)(0)})),i.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=i.opts();for(const e of n(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),n=i(31586),s=i(51926),o=i(17344),a=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,n.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,o.EditionName)()+" v"+a.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const r=i(38639),n=i(17181),s=i(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,r.mapBoolean)(e.color,(e=>{s.Settings.logColor.envValue=e,(0,n.setupLogFormatter)()}))}}},94361:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),n=i(40958),s=i(55835),o=i(31586),a=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,o.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,n.compactBlanks)([c("user id","PUID",(0,a.userids)()),c("group id","PGID",(0,a.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,s.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},76596:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),n=i(19851),s=i(22573),o=i(42659),a=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,n.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,a.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,a.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,o.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),n=i(31586),s=i(54557),o=i(91655),a=new s.FifoCache(512);function l(e){return(0,n.isNumber)(e)?e:(0,r.blank)(e)?void 0:a.getOrSet(e,(()=>(0,o.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,o.fmtFullDuration)((0,n.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),n=i(40958),s=i(22573),o=i(42659),a=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,a.isNumber)(e))return;if((0,a.isNumber)(e))return e;if((0,a.isDigits)(e))return(0,a.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,n.compact)(d.map((e=>function(e,t){const i=(0,a.toFloat)(e);if(null!=i){if((0,s.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*o.yearMs;case"weeks":case"week":case"w":return i*o.weekMs;case"days":case"day":case"d":return i*o.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*o.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*o.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*o.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,a.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:o.yearMs,s:"y"},{ms:o.weekMs,s:"w"},{ms:o.dayMs,s:"d"},{ms:o.hourMs,s:"h"},{ms:o.minuteMs,s:"m"},{ms:o.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,a.isNumber)(t))return;if(0===t)return"0";if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},84248:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},15056:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),n=i(7311);function s(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=s,t.pathToDb=function(e,t){return s(e,t).join(n.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const o=s(i(76760)),a=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),v=i(70698),w=i(64680),S=i(29882),b=i(45969),P=i(43334),_=i(28874),E=i(41692),M=i(32774),x=i(80612),C=i(32551),T=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function D(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+T(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,o.join)(i,".photostructure-cache"+T()),preexistingDir:i});return e}}function k(){if((0,b.isDocker)())return(0,a.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,o.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+T(),preexistingDir:M.DefaultDockerLibraryDir},...D()]);const e=(0,a.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),o.default.resolve((0,C.homeDir)(),"AppData","Local")]:P.isMac?[o.default.resolve((0,C.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,o.join)((0,C.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,o.join)(e,t),preexistingDir:e})));return i.push(...D()),i}t.tmpCacheDirs=D,t.tmpDirs=function(){return(0,x.filterDirs)({dirs:D(),desc:"tmp"})},t.cacheDirs=k,t.defaultCacheDir=(0,d.lazy)((()=>(0,x.firstDir)({dirs:k(),desc:"cache"})));const O=(0,d.lazy)((()=>{(0,E.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(F)}));function F(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{O();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=F},46292:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),n=i(45969),s=i(41692),o=i(32774),a=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,n.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,a.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:o.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:o.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,n.isDocker)()?c:(0,a.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),n=i(45969),s=i(32774);t.defaultLibraryDir=function(){return(0,n.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,n.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const n=r(i(76760)),s=i(40958),o=i(72993),a=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),n.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(n.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,a.env)().XDG_DATA_HOME,(0,a.env)().XDG_CONFIG_HOME,n.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:n.default.join(e,(0,o.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),n=i(96706),s=i(29882);t.envConfigDir=function(){const e=(0,n.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),n=i(40958),s=i(22573),o=i(66430);function a({dirs:e,desc:t}){for(const{dir:i,preexistingDir:a}of(0,n.compact)(e))if(!(0,s.blank)(i)){if((0,o.isReadWriteableDirectorySync)(i))return i;if((0,s.blank)(a)||(0,o.isReadWriteableDirectorySync)(a))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=a,t.filterDirs=function({dirs:e,desc:t}){return(0,n.compact)(e.map((e=>a({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),n=i(76760),s=i(1708),o=i(19851),a=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,o.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,a.compactBlanks)(e)){const e=(0,n.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),n=i(49776),s=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[s.libraryDataDir,s.libraryPreviewsDir,n.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},9595:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),n=i(54993),s=i(29882),o=i(28874);function a(e){return(0,r.toNotBlank)((0,n.toS)(e))??o.Settings.libraryDir.valueOrDefault}t.libraryDir=a,t.originalsDir=function(e){return(0,s.resolveMaybe)(a(e),o.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,s.resolveMaybe)(a(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,s.resolveMaybe)(a(e),o.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),n=i(55835),s=i(37805),o=i(15056),a=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${s.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function v(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+a.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function w(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function S(e){return y(w(e),!1)}function b(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(b(e))}function _(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function E(e){return y(_(e))}async function M(e){return y((0,n.map)(g(e),(e=>(0,o.pathToDbDir)(e,o.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await v(t);return(0,r.uniq)([t,i,await S(t),await P(t),await E(t),await M(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=v,t.libraryOriginalsDirPosixFile=w,t.setupLibraryOriginalsDir_=S,t.libraryPreviewsDirPosixFile=b,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=_,t.setupLibrarySyncReportsDir_=E,t.setupLibraryDbDir_=M},46296:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const n=r(i(76760)),s=i(19851),o=i(40958),a=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),v=i(80612),w=i(32551);function S(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:n.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,o.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>n.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,a.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,a.notBlank)(i)?i:b()}catch(e){return console.error("defaultLogDir_() failed",e),n.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(44198),a=i(43334),l=i(24399),u=i(32551);async function c(){return a.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,n.lazy)((async()=>{if(a.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,n.lazy)((()=>(0,o.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),n=i(7282),s=i(29325),o=i(44198);t.getDevEnvFlag=function(e){return!(0,n.isProd)()&&!(0,s.isPacked)()&&((0,r.toBoolean)((0,o.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,o.env)()[e]=String(t)}},34580:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),n=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,n.env)().DO_NOT_TRACK)}},44198:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const n=r(i(73024)),s=i(76760),o=r(i(1708)),a=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),v=i(6012),w=i(96706);t.env=(0,a.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>o.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===o.default.env.PS_LICENSE||e.push((0,s.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),i={...o.default.env};for(const r of e)try{const e=(0,d.debom)(n.default.readFileSync((0,p.resolve)(r))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(s))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),n=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let s;for(const o of(0,n.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(o));){if(null==s.groups)continue;const{key:e,val:n}=s.groups;if((0,r.blank)(e)||null==n)continue;const o=n.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=o}}return i}},96706:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const n=r(i(1708)),s=i(19851),o=i(22573),a=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,o.firstNotBlank)(n.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,n.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,a.isTrue)(g(e))}},98314:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),n=i(19851),s=i(40958),o=i(22573),a=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),v=i(70025),w=i(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(a.errorName),...e.map(a.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(a.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(i)))}function b(e){return(0,s.compact)(e).filter((e=>!a.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(o.notBlank)}function P(e,t){const i=(0,s.uniqSubstrings)(b(e)),r=t?.maxLen??400,n=t?.trailingChars??64,o=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(i.join(a.ErrorDelimiter)),r-o.length,n)+o.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,o.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,n.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,o.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,o.notBlank)(i))return i}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,o.blank)(e)&&(e=t.MissingError),_(e,{maxLen:i})+" at "+(0,a.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),n=i(26905),s=i(55835),o=i(54993),a=i(81168);t.describeError=function(e){const t=(0,a.stripSuffix)((0,o.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,s.map)((0,n.errorErrno)(i),(e=>t.push(u.get(e)))),(0,s.map)((0,n.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),n=i(76790),s=i(50989),o=i(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,n.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(o.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),n=i(38639),s=i(26905),o=i(54993),a=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,o.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,o.toS)(e)+(0,r.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,a.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,n.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,n.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,n.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},8769:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),n=i(31586),s=i(68708),o=i(7282),a=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const n=!0===i.fatal,c=!0===i.ignorable;if(!n&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),n&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!n||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!n||(0,o.isTest)()||(0,a.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),n}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,n.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,a.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,n.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,n.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),n=i(22573),s=i(38639),o=i(26905),a=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,n.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,n.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,o.errorName)(t)??(0,d.first)(this.causes,o.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(o.errorCode)],o.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,o.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,n.blank)(r)||(i=(0,h.dedupeNeedle)(i,r,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,a.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const o=i(49769),a=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),n.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,o.getOrSet)(s(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),o=s(this,r,"f").get(e);return null!=o&&(o.resolve(t),s(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,n=new WeakMap},34102:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),n=i(19851),s=i(15197);t.ee=(0,n.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const n=r(i(73024)),s=r(i(1708)),o=i(19851),a=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,o.lazy)((()=>s.default.geteuid?.())),h=(0,o.lazy)((()=>s.default.getgroups?.()));function f(e,t){try{return!(0,a.blank)(e)&&(n.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,n.default.constants.R_OK|n.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,n.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:n,processGid:s}){if(null==e)return!1;const o=n??d(),a=null!=s?[s]:h()??[],l=0===o,u=l||e.uid===o,f=l||a.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const n=r(i(76760)),s=i(19851),o=i(81168),a=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,o.equalsIgnoreCase)(e.basename,i.base))return n.default.join(r,e.basename);throw new a.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),n=i(76760);function s(e){return[...o(e)]}function*o(e){for(;e!==(0,n.dirname)(e);)e=(0,n.dirname)(e),yield e}function a(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=a(e);return t.every((e=>i.includes(e)))}t.ancestors=s,t.ancestorG=o,t.selfAndAncestorG=function*(e){yield e,yield*o(e)},t.childrenSync=a,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,i){var r,n,s,o,a,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),v=f(i(1708)),w=i(46466),S=f(i(57975)),b=f(i(38522)),P=i(19851),_=i(40958),E=i(5233),M=i(22573),x=i(42659),C=i(50357),T=i(96249),D=i(98553),k=i(55835),O=i(31586),F=i(68708),I=i(97790),L=i(39926),A=i(51926),N=i(59455),R=i(54993),j=i(48884),B=i(22911),V=i(99331),z=i(56519),W=i(56038),U=i(31562),q=i(76850),H=i(70025),G=i(34102),J=i(80875),$=i(50213),K=i(70417),Y=i(43334),Z=i(81168),X=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),ne=i(89968),se=i(20197),oe=i(88561),ae=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),ve=i(27794),we=i(73428),Se=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new oe.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,$.mkLogger)("fs.BaseFile("+this.nativePath+")"))),n.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),o.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(n=new WeakMap,o=new WeakMap,r=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,j.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,R.toS)(e);if((0,M.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=be().get(i);if(null!=r)return r;const n=(0,fe.resolve)(i),s=new Pe(n,t);return be().set(i,s),be().set(n,s),s}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,n,"f").unset(),h(this,o,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,z.thenMap)(this.stat(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,k.map)(this.statSync(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,n,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,z.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",s).call(this)??await d(e=this.clearThisAndParent(),r,"m",s).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,z.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,N.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,N.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,O.gt0)(t))return;const i=await d(this,n,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,C.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,k.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,R.toS)(e),(0,L.pad2)(t+1),(0,L.pad2)(i))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,T.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,z.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,z.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,z.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,z.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,x.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,z.thenMap)(this.statTimes(),j.max)}maxStatDate(){return(0,z.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,z.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,z.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,z.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,z.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,z.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,z.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,z.thenMap)(this.mtime(),(t=>(0,x.unixtime)(t)>=(0,x.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,z.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,z.thenMap)(this.mtime(),(t=>(0,x.unixtime)(t)>(0,x.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,z.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,k.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*x.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,ae.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,ae.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,J.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,J.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,q.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,z.thenMap)(this.zReadFile_(e),R.toS)))}readLines(e="warn"){return(0,z.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces),(0,F.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,E.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,V.ending)()?1:3,timeoutMs:0,retryDelay:x.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,r,"m",a).call(this,(0,Z.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,r,"m",a).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,r,"m",a).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,_.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new B.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,A.newlineRe)(),(r=>{const n=e.exec(r);null!=n&&(t.maybeResolve(n),i.close())})),t.promise}contemporary(e,t){return(0,z.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,O.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new B.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),_e)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,n)=>{try{const s=await e.f(r,(0,k.denull)(n));t(s)&&i.resolve(s)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,O.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,s=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,j.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,k.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},a=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*x.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},84542:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),n=i(96249),s=i(51926),o=i(54993),a=i(43334);function l(...e){return(0,n.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,o.toS)(e).split((0,s.newlineRe)()))))}t.Newline=a.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(o.toS).join("\n");return a.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),n=i(19851),s=i(50213),o=i(37805),a=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,n.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,a.mkdirp_)(i),await(0,d.writeTextfile_)((0,a.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+o.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const n=r(i(76760)),s=r(i(1708)),o=i(19851),a=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,o.lazy)((()=>[...(0,a.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,n.default.join(e,"System32"),n.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const a=s(i(44652)),l=o(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),v=i(14427),w=i(17217),S=i(16287),b=i(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class E{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new E(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},n=await a.stat(t);return new E(i,new P(r,n))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return E.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new E(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>E.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new E(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await a.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await a.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=E},20197:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const n=r(i(76760)),s=i(39926),o=i(29882),a=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,o.parseNativePath)(i.nativePath);if(await(0,o.mkdirp_)(r.dir),!i.requireNumber&&await(0,a.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=n.default.join(r.dir,`${r.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,a.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,o.parseNativePath)(i.nativePath);if((0,o.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=n.default.join(r.dir,`${r.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},88561:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const o=i(40958),a=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>s(this,r,"m",n).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,o.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,r=new WeakSet,n=async function(e){if((0,a.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),n=i(22573),s=i(45599),o=i(96249),a=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,s.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,n.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,o.flatten)((0,a.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),n=i(17217),s=i(16287),o=i(68284);async function a(e){return(0,r.pick)(await(0,s.stat_)((0,n.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=a,t.fileStats=async function(e){try{return await a(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,o.statSync)((0,n.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},73787:function(e,t,i){var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,n.set(this,[]),s.set(this,void 0),o.set(this,void 0),l(this,o,(0,f.fileStatsSync)(e),"f"),l(this,s,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",a).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,n,"f").push(e)}close(){u(this,s,"f").close()}}t.FileWatcher=m,n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,o,"f"),t)){l(this,o,t,"f");for(const t of u(this,n,"f"))t(e,this.nativePath)}}},73209:function(e,t,i){var r,n,s,o,a,l,u,c,d,h,f,m,p,g,y,v,w,S=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},b=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const _=i(58587),E=P(i(44652)),M=i(87997),x=i(40958),C=i(17586),T=i(42659),D=i(50357),k=i(75240),O=i(55835),F=i(31586),I=i(30976),L=i(13538),A=i(54993),N=i(7282),R=i(68852),j=i(23560),B=i(25764),V=i(38836),z=i(99331),W=i(22781),U=i(38835),q=i(55222),H=i(63870),G=i(69734),J=i(17217),$=new RegExp("-(?\\d+)"+(0,R.escapeRegExp)(G.PsLockExt)+"$");class K extends V.EndableWrapper{static newUid(e=process.pid){return b(this,n,Math.max(Date.now(),S(this,n,"f",s)+1),"f",s),(0,x.compactBlanks)([q.TokenRadix.encode(S(this,n,"f",s)),j.serviceName.prior(),(0,A.toS)(e)]).join("-")}static pidFromLockfile(e){return n.pidFromBasename((0,J.basename)(e))}static pidFromBasename(e){return(0,F.toInt)($.exec((0,A.toS)(e))?.groups?.pid)}static for(e){return S(this,n,"f",a).find((t=>t.opts.file===e.file))??new n(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>S(this,r,"m",w).call(this)),e.endableRank??B.EndableRanks.postdb,(0,H.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,b(t=n,n,(i=S(t,n,"f",o),++i),"f",o)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(S(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,G.fsLockFileBasename)(n.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await S(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,G.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+S(this,l,"f")),this.staleMs=(0,F.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),S(n,n,"f",a).push(this)}get acquired(){return S(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await S(this,r,"m",f).call(this,e)??S(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,C.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,D.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==S(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,N.isTest)()?10:T.secondMs);b(this,c,setInterval((()=>S(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=S(this,c,"f")&&(clearInterval(S(this,c,"f")),b(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(S(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),b(this,u,!1,"f"),(0,O.map)(S(this,d,"f"),(e=>(0,M.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,z.ending)()||this.ended?S(this,r,"m",v).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),b(this,d,setTimeout((()=>S(this,r,"m",v).call(this)),(0,F.toGt0)(this.staleMs)??T.secondMs),"f"),S(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(S(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,L.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,n=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,r=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,F.gt0)(this.staleMs)&&Date.now()>S(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await S(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){b(this,h,Date.now(),"f");const e=[],t=await S(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,F.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+T.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,G.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,N.isTest)())return this.release(),!1;n.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const s=i[0]===this.lockfile.base;if(s)b(this,u,!0,"f");else if(!0!==t?.vacuum){const t=n.pidFromBasename(i[0]);if((0,F.gt0)(t)&&!(0,_.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),S(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:s,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await S(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},v=async function(){await S(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},w=function(){(0,x.filterInPlace)(S(n,n,"f",a),(e=>S(e,l,"f")!==S(this,l,"f")))},s={value:0},K.internalErrors=0,o={value:0},a={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),n=i(51926),s=i(54993),o=i(17217);function a(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,n.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,n.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,s.toS)(e)))return;const i=(0,o.basename)(e);return a(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&a((0,o.basename)(e))}},4001:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),n=i(55835),s=i(31586),o=i(51926),a=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,r.toNotBlank)(e.name)??(0,a.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,s.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:f(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const n=(0,u.parsePosixPath)(i),s=h(n,{aggressive:!1});return[...t,s+n.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,o.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),r=(0,o.stripPrefix)(t.toLowerCase().normalize(),i);return(0,n.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,o.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,n.map)(m.exec(t),(e=>t=e[1].trim())),(0,n.map)(g.exec(t),(e=>t=e[1].trim())),t}},14977:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const n=r(i(44652)),s=r(i(73024)),o=i(46466),a=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,o.pipeline)(s.default.createReadStream(e,{autoClose:!0}),a.default.createGzip(),s.default.createWriteStream(t,{autoClose:!0})),await n.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const n=r(i(77598)),s=r(i(73024)),o=i(46466),a=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),v=i(16287),w=(0,a.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),S=(0,a.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=S().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),S().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await _(s.default.createReadStream(i)),stats:(0,u.pick)(await(0,v.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],i="sha512"){const r=n.default.createHash(i);return await(0,o.pipeline)([e,...t,r]),r.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return n.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),n=i(42659),s=i(55835),o=i(31586),a=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,a.stdout_)("chflags",["hidden",t],{timeoutMs:10*n.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,s.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,a.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*n.secondMs}),i=(0,o.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),n=i(54993),s=i(7282),o=i(43334),a=i(69375),l=/^\/dev(?:\/|$)/i,u=o.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=o.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=o.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=o.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,n.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,a.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},33456:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),n=i(51926),s=i(54993);class o extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,s.toS)(e)).split((0,n.newlineRe)()),o=r.pop();this._prior=o??"";let a=!1;for(const e of r)a||(a=!this.push(e));a?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=o},64680:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const n=r(i(76760)),s=i(17217),o=i(73428);t.mkNoMedia_=function(e){return(0,o.writeTextfile_)(n.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},85772:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const o=s(i(76760)),a=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),v=i(83278),w=i(70698),S=i(88561),b=i(65238),P=i(16287),_=(0,a.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),E="NoMedia",M=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(o.default.sep),"/"]).join("")+"])\\.?"+E+"$","im"),x=Object.freeze(["."+E,E]),C=Object.freeze((0,u.flatten)(x.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function T(e){return null!=M.exec(e)}t.isNoMediaName=T;const D=(0,a.lazy)((()=>new S.FileCache({name:"fs.noMediaDirsCache"})));async function k(e,t){if(null==e)return null;const i=v.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return T(i.base)||await(0,w.isCachedirTagFile)(i)?D().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):k(i.parent());{const e=await D().getOrSetAsync(i.nativePath,(()=>O(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:k(i.parent())}}async function O(e){if(T(e.base))return D().set(e.parent().nativePath,e.nativePath),_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,b.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,r=await Promise.race([F(e.nativePath,i),(0,b.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,w.isCachedirTagDirectory)(e)?_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(w.CACHEDIR_TAG).nativePath)}):null}async function F(e,t){for(const i of g.isCaseSensitiveFs?C:x){if(!0===t?.aborted)return null;const r=o.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return _().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function I(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(T(r.basename))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,o.join)(e,r.basename))});if(r.basename===w.CACHEDIR_TAG){const t=(0,o.join)(e,r.basename);if(await(0,w.isCachedirTagFile)(t))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await k(e,t)},t.whyNoMedia=k,t.whyNoMediaDir=O,t._dirHasNoMediaChild=F},29882:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const n=r(i(44652)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),v=i(78133),w=i(53265),S=i(17217),b=i(16287),P=i(66430),_=i(5545);function E(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,o.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=E,t.containsHiddenPathname=function(e){return k(e).some(E)},t.isNotHiddenPosixPath=function(e){return k(e).every((e=>!E(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return x((0,v.posix2native)(e))},t.extname=function(e){return x(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function x(e){const t=M.exec(e)?.groups,i=t?.ext2??"",r=s.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function C(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,s.default.sep)}function T(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),i=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,s.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function D(e,t,i){if(null==t||null==i)return!1;const r=e(t),n=e(i);return null!=r&&null!=n&&(y.isLinux?r===n:(0,p.equalsIgnoreCase)(r,n))}function k(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function O(e){return(0,u.notBlank)(e)&&k(e).length===(y.isWin?1:0)}function F({p:e,maxLength:t}){const i=(0,S.toNativePath_)(e);if(i.length<=t)return i;const r=k(e),n=[],s=[r.pop()];for(;r.length>0;)if(n.length=t){r.unshift(n.pop());break}}else if(s.unshift(r.pop()),L([...n,...s]).length>=t){r.push(s.shift());break}return r.length>0&&n.push("…"),L([...n,...s])}function I(e){return e.startsWith("\\\\")}function L(e){return(0,h.ensurePrefix)((0,a.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=x,t.parentBasename=C,t.grandParentBasename=function(e){return C(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=T,t.eqlBasename=function(e,t){return D(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return D(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return D(S.toNativePath_,e,t)},t.toPathnames=k,t.pathIsRoot=O,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:k(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,S.toNativePath_)(e),r=(0,S.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,v.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=F,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const n=[];for(const r of e.slice(0,i))n.push(F({p:r,maxLength:t}));return n.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return k(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return k(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=x(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(O(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await n.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;n.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>n.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=L,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:L(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>T({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const n=r(i(76760)),s=i(19851),o=i(40958),a=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),v=i(64660),w=i(21144),S=i(16287),b=(0,s.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const i=await(0,S.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,v.isStatRX)(i,e)}function E(){if(y.isWin){const e=(0,a.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,a.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,a.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,n.default.join(e,"System32"),n.default.join(e,"System32","Wbem"),n.default.join(i,"chocolatey","bin"),n.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(n.default.delimiter);return(0,o.uniq)((0,o.compactBlanks)([...e,...E()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,o.uniq)((0,o.compactBlanks)([...M(),...(0,d.toA)(i)]));for(const i of(0,o.uniq)((0,o.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=n.default.join(t,e);if(await _(i))return y.isLinux?i:(0,w.actualPath)(i)}}b().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){var r,n,s,o=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&o(t,e,i);return a(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),v=i(76790),w=i(5233),S=i(22573),b=i(42659),P=i(26905),_=i(75240),E=i(55835),M=i(31586),x=i(68708),C=i(13538),T=i(89937),D=i(12168),k=i(54993),O=i(48884),F=i(50213),I=i(45255),L=i(81168),A=i(56519),N=i(56038),R=i(31562),j=i(84777),B=i(9595),V=i(38835),z=i(70025),W=i(57902),U=i(55222),q=i(43334),H=i(33847),G=i(24399),J=i(28874),$=i(79915),K=i(45200),Y=i(34238),Z=i(87001),X=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),ne=i(73209),se=i(48313),oe=i(29882),ae=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,O.contextFilter)(function(e){return(0,v.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,F.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Y.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,A.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,A.thenMapOr)((0,X.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,$.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>q.isMac?(0,j.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,S.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,S.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,L.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,ae.toNativePath_)(e),r=new fe(i,t);return(0,L.isString)(e)&&he().set(e,r),he().set(i,r),r}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,A.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,oe.containedByNativePath)({ancestor:(0,B.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,oe.containedByNativePath)({ancestor:(0,B.originalsDir)(),descendant:this,acceptSelf:!0}))return q.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,E.map)((0,ee.bestMountpoint)(this.nativePath,await(0,X.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,E.map)((0,S.notBlankOr)(e,(()=>this.uri_())),Y.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,k.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===T.PS_LIBRARY_SCHEME?1:t.scheme===T.PS_LOCAL_FILE_SCHEME?2:t.scheme===T.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,L.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(q.isWin||q.isMac)return this.trap("hide",(async()=>(await(0,se.hide_)(this),this)))}async hidden(){return(0,se.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,L.equalsIgnoreCase)(e.ext,(0,$.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,$.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,O.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,E.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,x.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:n,skipWip:s=!1,skipFsLock:o=!1,retries:a=2,dirty:l=!1}){return(0,w.retryOnReject_)((async()=>{const a=await this.clear().isNonEmptyFile(i);if(!a){if(s&&o)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:o,minSizeBytes:i,timeoutMs:n,dirty:l})}return a&&r?void 0:this.utimes()}),{maxRetries:a,timeoutMs:2*n,retryDelay:3*b.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,M.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:n,dirty:s=!1}){return await this.parent().mkdirp_(),(0,ne.withLock_)({file:this,skipFsLock:r,timeoutMs:n,dirty:s},(async()=>{const r=this.wip();try{await r.unlink("trace");const s=await(0,C.thenOrTimeoutError)(e(r),n);if(s===t.NoOp)return s;if(await(0,R.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),s;throw new Error(this+"applyWip(): still empty after waiting "+(0,_.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,N.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==J.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",n).call(this,t)}catch(e){if(!0===(0,z.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",s).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();J.Settings.verifyFileCopies.valueOrDefault&&(await(0,R.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:b.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,M.clamp)(I.ShortCommandTimeoutMs,10*b.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,S.notBlank)(this.ext)&&(0,S.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,b.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,E.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,A.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,L.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,oe.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,oe.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,Z.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,r=new WeakSet,n=async function(e){let t,i=e;const r=e.wip();try{const n=await this.stat_();if(null==n)return this.pflog().throw("Can't copy missing files"+V.NonRetriableErrorFlag);if(n.size>0){if(J.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+V.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,r.nativePath,h.default.constants.COPYFILE_FICLONE),n.size>5*D.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},n.size,(()=>r.size({refresh:!0})))),!await(0,R.untilTrue)((async()=>(0,M.approximates)(n.size,await r.size({refresh:!0}))),{intervalMs:b.secondMs,timeoutMs:b.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:n.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:n.birthtimeMs,mtimeMs:n.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,n.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${n.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,E.map)(t,(e=>e.end()))}},s=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),n=r?.size;return null==r||null==n?this.pflog().throw("Can't copy missing files"):(n>5*D.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},n,(()=>e.clear().size()))),q.isWin?await G.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,G.pwshQuote)(this.nativePath)} -Destination ${(0,G.pwshQuote)(i.nativePath)}`,(e=>e)):q.isMac?await(0,j.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,j.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+V.DoNotSendErrorFlag,{error:t})}finally{(0,E.map)(t,(e=>e.end()))}}},78133:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const n=r(i(76760)),s=i(22573),o=i(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(n.default.sep===n.default.posix.sep)return e;const i=(0,s.notBlank)(t)?n.default.sep+n.default.sep+t+n.default.sep:"",r=e.split(n.default.posix.sep);return(0,o.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(n.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||n.default.sep===n.default.posix.sep||n.default.posix.sep===n.default.sep?e:e.split(n.default.sep).join(n.default.posix.sep)}},43899:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const n=r(i(76760)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,o.lazy)((()=>n.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,o.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(n.default.join((0,p.execDir)(),"resources"),n.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,a.compactBlanks)([(0,p.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const r=n.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),n=i(19851),s=i(31586),o=i(50213),a=i(57902),l=i(69428),u=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=a.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),n=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let s=-1;try{const n=i??(await(0,r.stat)(e)).size-t,o=Buffer.alloc(n);return s=await(0,r.open)(e,"r"),await(0,r.read)(s,o,0,n,t)}finally{(0,n.mapGte0)(s,r.close)}}},69428:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const o=s(i(73024));t.readFileSync=function(e){try{return o.readFileSync(e)}catch{}}},55690:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),n=i(84542);t.readLines_=async function(e){return(0,n.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class n extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=n},65238:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const n=r(i(51455)),s=i(76760),o=i(19851),a=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),v=i(28874),w=i(63870),S=i(88561),b=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,o.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,o.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await n.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const E=(0,o.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||E.prior()?.delete(e)}async function x(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await E().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,b.statTimeoutMs)(),r=C(e),n=await(0,h.thenOrTimeout)(r,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(n===f.Timeout&&(0,g.onTimeout)({soft:!1}),n!==f.Timeout&&n.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),E.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,o.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!E().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=E().get(e)},t.childDirectories_=async function(e){return(await x(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?x(e):C(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=x,t.readdirCached=function(e){return E().get(e)},t.readdirUncached_=C},53265:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const n=i(73024),s=r(i(76760)),o=i(40958),a=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,o.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=s.default.resolve(t,...e);if((0,n.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,a.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(a.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},50274:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),n=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,n.isBoolean)(e.isFile)&&(0,n.isBoolean)(e.isDirectory)}},17217:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const n=r(i(73024)),s=r(i(76760)),o=i(22573),a=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,o.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,o.blank)(e.nativePath))throw new Error(`toNativePath(${(0,a.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof n.default.Dirent?e.name:f(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:s.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(s.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,a.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(n.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,a.blank)(e)?void 0:v(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=S(e),r=S(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],n=t[i],s=(0,u.diff)(b(r),b(n));if(null==s||s>1)return"unmatched "+i+": "+r+" ≠ "+n}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const i=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await w(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,o.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const n=r(i(73024)),s=i(22573);function o(e){try{return(0,s.blank)(e)?void 0:n.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function a(e){return null==e||e.isFile()&&0===e.size}t.statSync=o,t.isEmptyStats=a,t.isFileSync=function(e,t=0){const i=o(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=o(e);return t.emptyIsNew?null==i:a(i)},t.isNonEmptyFileSync=function(e,t=0){const i=o(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===o(e)?.isDirectory()}},41080:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),n=i(56409);t.onDataChunked=function(e,t,i){const r=new s(t,i,!0);return r.read(e),r.done};class s{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new n.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const n=r(i(57075)),s=i(41400),o=i(55835),a=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends n.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,a.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,o.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends n.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const n=r(i(73024)),s=i(76760),o=i(22573),a=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,o.blank)(e))return!1;try{return n.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,a.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,o.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,o.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,o.blank)(e)&&d((0,u.posix2native)(e))}},27794:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const n=r(i(44652)),s=i(19851),o=i(22573),a=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,a.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,o.blank)(t.file))throw new Error("can't touch blank path");const r=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const a=(0,s.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await a())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await a())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(n.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!i||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(n.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},5545:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const n=r(i(76760)),s=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,s.toS)(i.path??n.default.sep)}},70257:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),n=i(45255),s=i(17217);t.WipTimeoutMs=n.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const o=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(o,"")},t.isWip=function(e){return o.test((0,s.basename)(e)??"")}},58722:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),n=i(22911);class s extends r.Writable{constructor(e){super(e),this.deferred=new n.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=s},73428:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const n=r(i(44652)),s=r(i(76760)),o=i(51926),a=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=s.default.dirname(e);await(0,c.mkdirp_)(i),await n.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=s.default.dirname(e);(0,c.mkdirpSync_)(i),n.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,o.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))}},13047:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const n=r(i(73024)),s=i(76760),o=i(46466),a=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,i){const r=[],s=[n.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,a.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,a.createBrotliDecompress)().on("error",(e=>r.push(e)))),s.push(t),await(0,o.pipeline)(s),(0,u.isNotEmpty)(r))throw new f.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function b(e,t){const i=new y.WritableToBuffer;return await S(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function _(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,o.pipeline)(new g.ReadableBuffer(i),(0,a.createGzip)(),n.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void v().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await _(e,t)}catch(t){v().log(i,"outputJsonGz("+e+"): failed",t)}}},33866:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},52086:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},13940:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),n=i(19851),s=i(42659),o=i(59455),a=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),v=i(55222),w=i(63870),S=(0,n.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,n.lazy)((()=>(b(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const b=(0,n.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const n=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const s=n.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await s.mkdirp_(),await s.utimes();const o=s.join(i+r);return S().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:o}),o}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,o.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+v.TokenRadix.randomChars(2),v.TokenRadix.randomChars(16)+(0,a.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*s.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const n=await P(e,t,i);return await n.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,w.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),n}catch(r){return S().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},48584:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},49794:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),n=i(19851),s=i(40958),o=i(22573),a=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,n.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,o.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,s.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),n=i(23560),s=i(66184),o=i(72210);class a{log(e,t,i,r){this.enabled(e,t)&&(0,o.pushLogEntries)({ts:Date.now(),l:e,from:(0,n.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=a,a.instance=(0,r.lazy)((()=>new a))},14593:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),n=i(22573),s=i(26905),o=i(55835),a=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,n.toNotBlank)(e)??(0,s.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,a.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),n=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:n}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,o.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,a.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),n=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof n.LogWriter))}},28981:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),n=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new n.PlaintextLogFormatter))},31256:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(41400),a=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,s.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,o.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,n.uniq)((0,n.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,a.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,a.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const s=i(77030),o=i(19851),a=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),v=i(31256),w=i(28538),S=(0,o.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),b=String.fromCharCode(0);t.logBroadcaster=(0,o.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,a.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&S().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,s.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{S().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){S().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),n(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,s){if(this.enabled(e,t))try{const o=this.socket;null==o?n(this,r,"f").call(this):o.write(this.logFormatter.format(e,t,i,s)+b)}catch(r){S().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:s,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),n=i(42659),s=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??s.Settings.logDir.valueOrDefault,(0,n.fmtIsoDate)(t??new Date))}},4904:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),n=i(31586),s=i(51926),o=i(57902);t.isLogEntry=function(e){return null!=e&&(0,n.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&o.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),n=i(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,n.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,n.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new s(n.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>n.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,n.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,n.set(this,[]),s.set(this,(0,l.lazy)((()=>{a(this,n,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:a(this,n,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>a(this,s,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=a(this,r,"m",o).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=a(this,r,"m",o).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},n=new WeakMap,s=new WeakMap,r=new WeakSet,o=function(e){if(null==e||0===a(this,n,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return a(this,n,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),n=i(31586),s=i(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const o=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??o},t.levelGte=function(e,i){return(0,n.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const a=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return a.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),n=i(68708),s=i(20214),o=i(51926),a=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,o.isString)(i)||Buffer.isBuffer(i))return(0,o.ellipsize)(i.toString(),256,32);if((0,a.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,s.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const a=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,n.keys)(i),(0,n.keys)(a));return(0,r.isNotEmpty)(c)&&(a["…"]="omitted: "+(0,o.ellipsize)(c.join(", "),128,32)),a}return i}},89241:function(e,t,i){var r,n,s,o,a,l,u=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogReader=void 0;const d=i(73024),h=i(38522),f=i(4001),m=i(14977),p=i(33456),g=i(92322),y=i(4904),v=i(98192);t.LogReader=class{constructor(e,t){if(r.add(this),this.f=e,this.start=Date.now(),this.lines=new g.SortedSet(y.logEntrySorter),n.set(this,!1),s.set(this,!1),o.set(this,!1),this.from=(0,f.stripCopySuffixFromName)(e.name),this.fileStream=(0,d.createReadStream)(e.nativePath,{autoClose:!0}),!(0,m.isExtOrCompressedExt)(e.ext,".log"))throw new Error(e+" is not a logfile");this.stream=(e.ext.toLowerCase().endsWith(".gz")?this.fileStream.pipe((0,h.createGunzip)()):e.ext.toLowerCase().endsWith(".br")?this.fileStream.pipe((0,h.createBrotliDecompress)()):this.fileStream).pipe(new p.LineReader).on("error",(e=>{t(e),u(this,o,!0,"f")})),this.stream.on("data",c(this,r,"m",a).bind(this)),this.stream.on("close",(()=>{this.fileStream.resume(),u(this,n,!0,"f")})),this.stream.on("end",(()=>{u(this,n,!0,"f")}))}toString(){return"LogReader("+this.f.nativePath+")"}status(){return{hasErrors:c(this,o,"f"),ended:c(this,n,"f"),destroyed:this.stream.destroyed,lines:this.lines.length,paused:c(this,s,"f")}}hasErrors(){return c(this,o,"f")}get ended(){return c(this,n,"f")}ready(){return this.ended||this.lines.length>32}complete(){return this.ended&&0===this.lines.length}peek(){return this.ready()?this.lines.at(0):void 0}shift(){const e=this.lines.shift();return null!=e&&c(this,r,"m",l).call(this),e}shiftLte(e){const t=this.lines.shiftLte(e);return t.length>0&&c(this,r,"m",l).call(this),t}},n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(e){if(null===e)u(this,n,!0,"f");else{const t=(0,v.chunkToLogEntry)(e);null!=t&&this.lines.add({...t,from:this.from}),this.lines.length>10240&&!c(this,s,"f")&&(this.fileStream.pause(),u(this,s,!0,"f"))}},l=function(){this.lines.length<1024&&c(this,s,"f")&&(this.fileStream.resume(),u(this,s,!1,"f"))}},24068:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),n=i(76760),s=i(1708),o=i(87997),a=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),v=i(22277),w=i(25764),S=i(38836),b=i(99331),P=i(42638),_=i(76596),E=i(98314),M=i(89968),x=i(29882),C=i(28874),T=i(28981),D=i(20839),k=i(21727),O=i(66184),F=i(57902),I=i(72210),L=i(98192);function A(e){const t=(0,T.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=A;class N extends S.EndableWrapper{constructor(e=void 0,t=A){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,a.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,C.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,x.mkdirp_)(e),this.root=await M.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=n.sep+(0,p.serviceName)()+"-"+s.pid+"-",s.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,o.setInterval)((()=>this.flush()),D.DefaultLogFlushMs/2),this.scanTimeout=(0,o.setInterval)((()=>this.scan()),u.minuteMs),s.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,b.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,O.ifLog)(F.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,n.join)(e,i))}))}catch(t){return void(0,O.ifLog)(F.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,E.errorToS)(t))))}}))}async scan(e=!1){if((0,b.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,_.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,b.ending)()||this.ended)return;const t=(0,k.datedLogDir)(this.root.nativePath);try{await(0,x.mkdirp_)(t),this.watchDir(t)}catch(e){(0,O.ifLog)(F.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,E.errorToS)(e))))}(0,b.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,o.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,o.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await M.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(r,i))return;await(0,f.thenMap)((0,L.readLogEntries)(e,{start:r,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,O.ifLog)(F.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,E.errorToS)(e))))}}))}}t.LogTail=N,N.instance=(0,a.lazy)((()=>(0,y.stdoutEnded)()?void 0:new N))},72210:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),n=i(82328),s=i(28981),o=i(20839),a=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(a.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,n.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*o.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),v=i(31586),w=i(409),S=i(23560),b=i(81168),P=i(78406),_=i(25764),E=i(20197),M=i(14977),x=i(36868),C=i(28874),T=i(32105),D=i(20839),k=i(21727),O=i(66184),F=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class L extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*D.DefaultLogFlushMs),rank:_.EndableRanks.logger,unref:!0,onEnd:()=>c(this,n,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,n.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:T.ConsoleLogger.instance(),flushEveryMs:D.DefaultLogFlushMs,processName:S.processName,logFilter:O.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",s).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const n={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(n.meta=(0,F.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(n)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=L,n=new WeakMap,r=new WeakSet,s=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),n=e.splice(0,i);this._linesSinceRotate+=n.length,t.write(n.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},o=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},a=function(e){return t=>(c(this,r,"m",o).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,b.stripAnsiEsc)(this.logOpts.processName()),t=await(0,E.ensureNewNativePath_)({nativePath:(0,f.join)((0,k.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,r,"m",a).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,x.endStream)(e.stream),C.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,M.gzip_)(e.nativePath))}catch(e){c(this,r,"m",o).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),n=i(40958),s=i(55835),o=i(68708),a=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,o.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,n.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),n=i(84542),s=i(4001),o=i(13047),a=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,a.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,s.stripCopySuffixFromName)(e.name),r=[],a=await(0,o.zcat)(e.nativePath,t);if(null!=a)for(const e of(0,n.splitLines)(a)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),n=i(76790),s=i(68708),o=i(89788),a=i(57902);t.SentLogLevels=(0,r.lazy)((()=>a.LogLevels.values.filter((e=>e!==a.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,s.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new o.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,s.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,s.values)(l()))e.push(...t.toA());return(0,n.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),n=i(41400),s=i(55835),o=i(37975),a=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),v=i(66184),w=i(28538),S=i(24068),b=i(43705),P=i(51879);function _(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),E();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new b.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,s.map)((0,y.logBroadcaster)(),(e=>i.push(e))),a.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&S.LogTail.instance()}function E(){const e=h.Settings.logColor.valueOrDefault;(0,o.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=_,t.setupLogFormatter=E,(0,n.later)((()=>{h.Settings.logStdout.watchLater(_),h.Settings.logDir.watchLater(_),h.Settings.tailLogs.watchLater(_),h.Settings.logColor.watchLater(E),h.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},75631:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Recent=void 0;const n=r(i(1708)),s=i(57075),o=i(40958),a=i(76790),l=i(42659),u=i(41400),c=i(96249),d=i(55835),h=i(31586),f=i(34666),m=i(5670),p=i(45608),g=i(56519),y=i(69554),v=i(38790),w=i(70488),S=i(83278),b=i(84542),P=i(89968),_=i(14977),E=i(33456),M=i(28981),x=i(4904),C=i(89241),T=i(98192),D=i(97352),k=i(28874),O=i(2858);let F;function I(e){n.default.stdout.write(e+b.Newline)}async function L(e){const t=S.BaseFile.for(e);if(await t.isFile())return[t.nativePath];if(await t.isDirectory()){const e=await t.descendants((e=>e.ext.startsWith(".log")));return e?.map((e=>e.nativePath))}}t.Recent={beforeParse:e=>e.option("--recent [duration]",'Automatically cat recent logs. The optional "duration" argument can either be a number, which will be interpreted in minutes, or an ISO 8601 duration string, like "1d" for 1 day, or "20m" for 20 minutes. Defaults to 1 day.'),afterParse:e=>{null!=e.recent&&(!0===e.recent?F=l.dayMs:(0,D.mapGt0)(e.recent,(e=>F=e*l.minuteMs))??(0,w.decodeDuration)(e.recent))}},async function(){const e=await new y.CLI(m.ServiceNames.logcat,"[FILE_OR_DIR...]","FILE_OR_DIR may be either a logfile or a directory that will be scanned for .log, .log.gz, and .log.bz files.").add(t.Recent,v.ColorArgs).parse();n.default.on("SIGINT",(()=>(0,p.exit)({reason:"SIGINT",status:0}))),n.default.on("SIGTERM",(()=>(0,p.exit)({reason:"SIGTERM",status:0})));const i=(0,o.uniq)((0,c.flatten)(await(0,g.mapAsync)({name:"parseArgs",arr:e.args,f:L})));if((0,h.gt0)(F)){const e=(0,_.matcherForExtOrCompressedExt)(".log");await(0,O.readSystemSettings)();const t=Date.now()-F;await S.BaseFile.for(k.Settings.logDir.valueOrDefault).visitDescendants((async r=>{const n=await r.maxStatMs();e(r.ext)&&await r.isFile()&&(0,f.gt)(n,t)&&i.push(r.nativePath)}))}const r=(0,M.DefaultLogFormatter)();if((0,o.isEmpty)(i))return(0,o.isNotEmpty)(e.args)&&(console.error(r.format("error","logcat","No valid logfiles were provided.")),e.help()),I(r.format("info","logcat","No log files provided: reading from stdin.")),I(r.format("warn","logcat","The output will not be sorted chronologically.")),void await s.promises.pipeline(n.default.stdin,new E.LineReader,new s.Transform({transform(e,t,i){(0,d.map)((0,T.chunkToLogEntry)(e),(e=>I(r.formatLogEntry({from:"",...e})))),i()}}));const l=await(0,g.thenCompact)(i.map((async e=>{const t=await P.DirectoryEntry.for(e);return null!=t&&(0,h.gt0)(t.size())?new C.LogReader(t,console.error):void 0})));function w(){let e;(0,o.filterInPlace)(l,(e=>!e.complete()));for(const t of l){if(!t.ready())return;const i=t.peek();null!=i?.ts&&(null==e||i.tse.f.nativePath))));l.length>0;)try{const e=w();if(null!=e)for(const t of e)I(r.formatLogEntry(t));else await(0,u.delay)(10,!1)}catch(e){console.error("caught error",e)}n.default.stdout.write(b.Newline,(()=>(0,p.exit)({reason:"",status:0})))}()},82647:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const o=i(57975),a=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,o.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,r,"m",n).call(this,-1)}get p29(){return s(this,r,"m",n).call(this,-.5)}get p38(){return s(this,r,"m",n).call(this,-.25)}get p69(){return s(this,r,"m",n).call(this,.5)}get p84(){return s(this,r,"m",n).call(this,1)}get p98(){return s(this,r,"m",n).call(this,2)}get p99(){return s(this,r,"m",n).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,a.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,a.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,a.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,n=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),n=i(55835),s=i(31586),o=i(30976),a=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,s.clamp)(0,i,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,n.map2)(e,t,((e,t)=>(0,r.sum)((0,a.zip)(u(e,i),u(t,i)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,o.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),n=this.clampValue(e);let s=0;for(let e=0;eo?(s+=1,i[t]=o):r[t]=o}return s}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let n=0;n(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;is?(t+=1,n.min=s):n.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},55222:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),n=i(22573),s=i(55835),o=i(32639),a=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,n.blank)(e))return;const t="-"===(e=(0,o.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),n=this.normalizeToken(t);return r.length>=i&&r===n}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},17921:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),n=i(65713);function s(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=s,t.safeUUID=function(){return(0,n.decuss)(s)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const a=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function v(e,t){let i=0,r=0;for(const n of e){if(null!=n){const e=t(n,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=v;class w{constructor(){r.set(this,0),n.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(o(this,n,null==s(this,n,"f")?e:s(this,n,"f")*s(this,r,"f")/(s(this,r,"f")+1)+e/(s(this,r,"f")+1),"f"),o(this,r,(t=s(this,r,"f"),++t),"f"))}get mean(){return s(this,n,"f")}}function S(e){const t=new w;for(const i of e)t.push(i);return t.mean}function b(e){const t=S(e);if(null==t)return;let i=0,r=0;for(const n of e)(0,u.isNumber)(n)&&(r++,i+=(n-t)*(n-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function _(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+o*(e-n)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=S(t);if(null!=i){const e=(t.length-1)/2,r=v(t,((t,r)=>(t-i)*(r-e))),n=v(t,(e=>(e-i)**2));return 0===n?0:r/n}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,a.isEmpty)(e)&&(0,a.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},49076:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const n=r(i(48161)),s=i(19851),o=i(22573),a=i(41400),l=i(81168),u=i(28874);t.hostname=(0,s.lazy)((()=>u.Settings.hostname.value??n.default.hostname())),(0,a.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,o.blank)(e)&&!(0,o.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??n.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},96128:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),n=i(19851),s=i(22573),o=i(42659),a=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),v=i(34102),w=i(26293),S=new RegExp("^"+w.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==S.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const b=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=b.exec(e)}function _(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=_,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,s.blank)(e)){if(null!=_(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void E().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs});const E=(0,n.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,a.later)((()=>(0,v.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=_(e)?r.promises.reverse(e):r.promises.resolve4(e),5*o.secondMs);if(t===c.Timeout)return E().info("nslookup("+e+"): timeout"),e;const i=t.find(s.notBlank);return null==i?(E().warn("No name found for "+e),e):i}catch(t){return E().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,s.blank)(e)&&!(0,s.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),n=i(42659),s=i(31586),o=i(97790),a=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*n.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*n.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,s.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,o.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,a.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*n.minuteMs})},45969:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),n=i(38639),s=i(19851),o=i(59958),a=i(43334);t.isDocker=(0,s.lazy)((()=>a.isLinux&&((0,n.toBoolean)(process.env[o.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),n=i(19851),s=i(54993);t.isPacked=(0,n.lazy)((()=>!(0,s.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},43334:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const n=r(i(48161)),s=r(i(1708)),o=i(22573),a=i(38639),l=i(59958),u=n.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,a.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,a.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,o.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===n.default.arch(),t.isArm=null!=/^arm\b/i.exec(n.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,o.notBlank)(s.default.env.APPIMAGE)||(0,o.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,o.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,a.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const n=r(i(73024)),s=i(19851),o=i(43334);function a(e="/proc/cpuinfo"){if(o.isWin||o.isMac)return!1;try{return null!=n.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=a,t.isRaspberryPi=(0,s.lazy)((()=>o.isLinux_arm&&a())),t.procDeviceModel=(0,s.lazy)((()=>{try{return o.isLinux?n.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},45643:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),n=i(59455),s=i(31562);t.existingPids=function(e){return(0,n.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(97790),w=i(59455),S=i(54993),b=i(54557),P=i(19851),_=i(50213),E=i(88158),M=i(409),x=i(78406),C=i(25764),T=i(99331),D=i(56519),k=i(46292),O=i(8769),F=i(83278),I=i(32144),L=i(29882),A=i(43334),N=i(24399),R=i(58261),j=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),B=10*p.secondMs;function V(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,L.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))j().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{j().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??A.isWin,r=await this.pidfiles(),n=await this.pids(r??[]);if((0,f.isEmpty)(n))return j().info("killOldProcs(): no pidfiles"),[];const s=[],o=[],a=await(0,R.pidInfos)(n);if(null!=a){for(const n of r){const r=await n.readJson();if(null==r){j().warn("killOldProcs(): failed to read pidfile "+n.base),await n.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){j().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+n.base,{json:r,pid:l}),await n.unlink("debug");continue}const u=a.find((e=>e.pid===l));if(null==u||!V(r,u)){j().debug("killOldProcs(): pid no longer present: unlinking "+n.base,{json:r,pidEntry:u}),await n.unlink("debug"),s.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(j().info("killOldProcs(): killing",{reason:d,json:r}),o.push(W(l,i,!1)),s.push({...r,...u}))}return o.length>0&&await Promise.allSettled(o),s}(0,O.onError)("Pids.killOldProcs(): failed to get process information")}}),o.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const o=e.pid;if(!(0,y.gt0)(o))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(o)?(i&&a(this,n,"f").delete(l),a(this,n,"f").getOrSet(l,(async()=>{const i=a(this,r,"m",s).call(this,e.pid),n=(0,v.opt)((0,E.Try)((()=>(0,L.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),o=t.getTime(),l={...e,cmd:n,startTime:o};return await i.writeJson_(l),j().debug("addPid() wrote "+i,l),i}))):(a(this,n,"f").delete(l),void j().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=a(this,r,"m",s).call(this,e);return(0,D.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{j().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==a(this,o,"f")||a(this,o,"f").ended)&&l(this,o,new x.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:C.EndableRanks.first}),"f"),a(this,o,"f")}cancelInterval(){a(this,o,"f")?.end(),l(this,o,void 0,"f")}}t.Pids=U,n=new WeakMap,o=new WeakMap,r=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,k.configDir)(),(e=>new U(F.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const n=i(31421),s=i(48161),o=r(i(1708)),a=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),v=i(84968),w=i(48963),S=i(56519),b=i(84777),P=i(8103),_=i(45879),E=i(43334),M=i(24399),x=i(45643),C=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function T(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function D(e){if(E.isLinux)return async function(e){const t=[];for(const i of e)t.push(z(await(0,_.readFileMaybe)("/proc/"+i+"/stat")));return C().tap({msg:"pidInfoProc",result:(0,a.compact)(t)})}(e);const t=(0,x.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,E.isWin?I:R)).filter((e=>T(e)&&t.includes(e.pid)));return C().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=T,t.pidInfo=async function(e){return(0,S.thenMap)(D([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,a.isEmpty)(e)?[]:(0,S.thenMap)((0,x.existingPids)(e),(t=>{const i=[o.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=D;const k="Get-Process",O="| Select-Object -Property Id,ProcessName,StartTime";function F(e){return(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).join(",")}async function I(e){if(M.PowerShell.instance().ended)return N(e);const t=[k,"-Id",F(e),"-ErrorAction SilentlyContinue",O].join(" ");return(0,S.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const L={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},A=["CommandLine","CreationDate","ProcessId"];async function N(e){const t=["process"];if((0,a.isNotEmpty)(e)){const i=(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",A.join(","));const i=await(0,b.stdoutResult_)((0,P.wmic)(),t,L),r=(0,d.onlyReqValued)((0,p.parseFixed)(A,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return r.find((e=>e.pid===o.default.pid))||r.push({pid:o.default.pid,start:new Date(v.StartTs),cmd:"node "+o.default.title}),r}async function R(e){return t=(await(0,b.stdoutResult_)("ps",["-p",F(e),"-wwwo","pid,lstart,command"],{...L,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=N;const j=(0,g.lazy)((()=>{try{if(E.isLinux)return(0,c.toGt0)((0,n.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){C().warn("clk_tck failed",{error:e})}return 100})),B=(0,g.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),V=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function z(e){const t=V.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,n=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(n)?{pid:i,cmd:r,start:new Date(B()+n/j()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),n=i(22573),s=i(31586),o=i(29882),a=i(97352);t.progressEvtToS=function(e){const t=(0,n.blank)(e.path)?null:(0,o.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,s.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,n.notBlank)(e.op)&&(0,a.within)(0,100,e.pct)}},41944:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),n=i(42659),s=i(31586),o=i(12089),a=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new a.TTLMap(15*n.secondMs))),t.recentDone=(0,r.lazy)((()=>new a.TTLMap(2*n.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,s.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,o.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),n=i(31586),s=i(409),o=i(78406),a=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends o.EndableInterval{constructor(e,t,i,n=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:n,rank:a.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=n,this.start=Date.now(),this.onInterval=(0,s.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,n.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,n.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},24399:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),n=i(19851),s=i(22573),o=i(42659),a=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),v=i(99331),w=i(56519),S=i(31562),b=i(84777),P=i(34102),_=i(43334),E=i(28874),M=i(63870),x="{ready}",C=" | ConvertTo-Json -Compress";function T(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=T,(0,a.later)((()=>(0,P.ee)().on("clearCache",(()=>D.instance.prior()?.clearMockResults()))));class D extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",E.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${x}"}`,...(0,s.mapNotBlankOr)(E.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:x,fail:"Error",exitCommand:"exit",maxProcs:E.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:o.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),E.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(E.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,C),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,n)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,n)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,C),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+T(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=D,D.instance=(0,n.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new D})),t.checkPowerShell_=async function(){const e=D.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),n=i(38639),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toBoolean})}}t.BooleanSetting=o},90536:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),n=i(31586),s=i(97790),o=i(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=a},75164:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(97790),o=i(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(r.notBlank).flatMap(n.toInt).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,n.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=a},10546:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),n=i(22573),s=i(45599),o=i(50213),a=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,s.defer)((()=>(0,o.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,a.trimQuotes)(e);return void((0,n.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,n.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),n=i(91655),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,n.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=o;class a extends s.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=a},9945:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toFloat})}}t.FloatSetting=o},74589:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toInt})}}t.IntegerSetting=o},4175:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),n=i(22573),s=i(38639),o=i(42659),a=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function v(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function w(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){_(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&v(),y("strictDeduping",e)&&w(),(y("optOut",e)||y("noNetwork",e))&&E()},t.handleDeprecatedSettings=async function(){if((0,s.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,n.blank)(m.Settings.assetPathnameFormat.value)&&(0,n.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*o.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=v,t.setStrictDeduping=w;const S=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],b={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function _(e){for(const t of S)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:b;for(const[e,i]of(0,a.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function E(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=_,t.disableExternalNetworkRequests=E},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),n=i(53265),s=i(87652);class o extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,n.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=o},23561:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:n.toFloat})}}t.OptionalFloatSetting=o},69005:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=o},87652:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class n extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=n},28283:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),n=i(83556);t.nameFromEnv=function(e){return(0,n.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,n.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const o=i(19851),a=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),v=i(40583),w=i(81168),S=i(44198),b=i(96706),P=i(34102),_=i(28283),E=i(81075),M=i(98778),x=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,o.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,r,"m",n).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?s(this,r,"m",n).call(this,e??t)+": "+i:null==this.fromEnv(e)?s(this,r,"m",n).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,a.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,a.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,a.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return E.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,S.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&b.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,S.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&b.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],x.WrapComments);function i(e,i){(0,a.isEmpty)(i)||t.push(...(0,w.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],x.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,w.wrap)(["",e+": "+r],x.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:x.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:x.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,n=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),n=i(76760),s=i(19851),o=i(40958),a=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),v=i(79840),w=i(7282),S=i(12801),b=i(4328),P=i(70488),_=i(84248),E=i(5531),M=i(99315),x=i(34365),C=i(34580),T=i(96706),D=i(50274),k=i(33866),O=i(52086),F=i(48584),I=i(45969),L=i(43334),A=i(24540),N=i(70379),R=i(71300),j=i(33209),B=i(48987),V=i(68268),z=i(61208),W=i(99023),U=i(30577),q=i(1485),H=i(19861),G=i(55111),J=i(30933),$=i(22859),K=i(71988),Y=i(38483),Z=i(90536),X=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),ne=i(9945),se=i(74589),oe=i(844),ae=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new ae.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>q.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:q.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>q.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>L.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!L.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>L.isMac?"100ms":L.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new ne.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:E.CheckpointTypes,defaultValue:E.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:x.SynchronousModes,defaultValue:x.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 1 minute is very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"1m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:k.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>L.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,C.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,A.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,J.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:D.SidecarExts,defaultValue:D.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:$.AggregateTypes.intersection,strEnum:$.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new ne.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,J.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:O.CropStrategies.attention,strEnum:O.CropStrategies}),videoFrameAtSec:new ne.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,o.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(L.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>j.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:F.SharpFailOns.truncated,strEnum:F.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>B.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:oe.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new ne.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:N.DateTagFormats.ym,strEnum:N.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:V.KeywordReparentingStrategies.move,strEnum:V.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:z.NameTagFormats["as-is"],strEnum:z.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function Se(e){const i=((0,l.blank)(e)?"":e).split(n.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,o.uniq)(i).filter(l.notBlank).join(n.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,T.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,a.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),n=i(31586),s=i(7282),o=i(49776),a=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),v=i(15674),w=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{w.Settings.configDir.opts.defaultValue=a.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=o.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,n.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(22573),a=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),v=i(54993),w=i(50213),S=i(81168),b=i(83556),P=i(37805),_=i(87290),E=i(98314),M=i(34102),x=i(83278),C=i(95696),T=i(60865),D=i(4175),k=i(83179),O=i(81075),F=i(28874),I=i(41692),L=i(84438),A=i(32707),N=i(6707),R=i(55018),j=i(10357),B=(0,r.lazy)((()=>(0,w.mkLogger)("settings.SettingsIO")));function V(e){return(0,_.libraryDataDirPosixFile)(e)?.join(L.SettingsToml)}async function z(e=(0,A.systemSettingsFile)()){if(null!=e)return Q(x.BaseFile.for(e))}async function W(){try{return(0,o.toNotBlank)((await(0,N.readTomlFile_)((0,A.systemSettingsFile)()))?.[F.Settings.libraryDir.name])}catch{return}}async function U(){return $((0,A.systemSettingsFile)())}async function q(e){return(0,m.map)(V(e),(e=>$(e)))}function H(){t.libraryHasSettings.refresh()}function G(e){const t=V(e);return B().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:F.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}t.librarySettingsFile=V,t.readSettings=(0,r.lazy)((async()=>{await z(),(0,t.libraryHasSettings)()&&await Z()}),a.minuteMs),t.readSystemSettings=z,t.envOrSavedLibraryDir=async function(){return F.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=U,t.librarySettingsVersion=q,t.maybeUpgradeSystemSettings=async function(){P.version!==await U()&&await Y()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&P.version!==await q()&&await X()},t.libraryHasSettings=(0,r.lazy)((()=>G())),t.libraryHasSettings.unset=()=>{B().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,M.ee)().on("clearCache",H),(0,M.ee)().on("settingsChanged",H),F.Settings.libraryDir.watchLater(H)})),t._libraryHasSettings=G;const J=/^# PhotoStructure v(?\d+\.\d+\.\d+(?:-\S+)?)$/i;async function $(e){if((0,o.blank)(e))return;const t=await x.BaseFile.for(e).firstMatchingLine(J);return t?.groups?.version}async function K(e,i){if(null==e)return void B().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),n=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...re("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","-- ","","PhotoStructure v"+(0,t.versionForSettings)())),r.push("","");let n="";for(const e of i){const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==n&&(n=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,M.ee)().emitDebounced("settingsChanged")}(n,i),B().info("writeToml(): wrote settings",{dest:n,file:e,nonDefaults:(0,k.settingsToObj)(i),wip:r}),r){const t=await(0,N.readTomlFile_)(n),i=await(0,N.readTomlFile_)(e);(0,u.eql)(t,i)?(B().info("Equivalent contents",{dest:n,file:e,a:t,b:i}),await n.unlink()):(B().info("Archiving prior, different contents",{dest:n,file:e}),await e.renameYMDHMS_({subdir:"old"}),await n.unwip_())}}async function Y(e=(0,A.systemSettingsFile)()){const t=C.PosixFile.forMaybe(e);return null!=t&&await K(t,(0,F.persistedSystemSettings)()),t}function Z(e){return Q(V(e))}async function X(e){await(0,_.setupLibraryDataDir_)((0,o.firstNotBlank)(e,F.Settings.libraryDir.value));const i=V(e);return B().info("writeLibrarySettings()",{file:i}),null!=i&&(await K(i,(0,F.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function Q(e){if(null==e)return[];const t=B().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await ee(e);return(0,n.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,E.errorToS)(e)),[]}}async function ee(e){const t=B().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,N.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const s=[],o=(0,n.compact)((0,p.entries)(r).map((([e,t])=>{const i=(0,F.getSettingByNameOrKey)(e);if(null==i)s.push(`Failed to import "${e}"${(0,m.mapOr)((0,F.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;s.push(e)}})));return t.info("loaded",{settings:(0,k.settingsToObj)(o),warnings:(0,n.toNotEmpty)(s)}),await(0,D.handleDeprecatedSettings)(),(0,D.handleMetaSettings)(o),{settings:o,warnings:s}}t.versionForSettings=(0,r.lazy)((()=>P.version)),t.writeSystemSettings_=Y,t.writeAllSettings_=function(e){return K(C.PosixFile.for(e),(0,F.persistedSettings)())},t.readLibrarySettings=Z,t.writeLibrarySettings_=X,t._readSettings=Q,t.importFileSettings_=ee;const te=(0,r.lazy)((()=>new Set([F.Settings.noNetwork,F.Settings.httpPort,F.Settings.license,F.Settings.logStdout,F.Settings.logLevel].map((e=>e.key)))));function ie(){for(const e of(0,p.values)(F.Settings))te().has(e.key)||e.unset();(0,M.ee)().emit("settingsChanged")}function re(...e){return(0,d.flatten)(e.map((e=>(0,S.wrap)(e,j.WrapComments))))}t.clearLibraryDirSetting=async function(){await z(),F.Settings.libraryDir.unset(),await Y()},t.clearSettings=ie,t.nukeSettings=async function(){ie(),await(C.PosixFile.forMaybe((0,A.systemSettingsFile)())?.unlink("trace")),await(C.PosixFile.forMaybe(V())?.unlink("trace")),(0,M.ee)().emit("clearCache"),I.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...re("",`Welcome to PhotoStructure! These are the settings for version ${(0,T.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...re("","The following settings categories are stored in the system settings.toml:","",...(0,s.sort)([...O.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,s.sort)([...O.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...re("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...re("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const s=`${e.key} or ${e.name}`,o={...e.addToJSON()};(0,n.mapNotEmpty)(e.altKeys,(e=>o.aliases=(0,h.orList)(e)));const a=(0,p.entries)(o).map((([e,t])=>`${(0,S.capitalize)((0,b.camel2snake)(e)).replace(/_+/g," ")}: ${(0,R.valueToS)(t)}`));(0,n.isNotEmpty)(a)&&a.push(""),i.push(...re((0,g.padding)("-",s.length),s,(0,g.padding)("-",s.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...a,`${e.key}=${(0,f.stringify)((0,v.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),n=i(40958),s=i(22573),o=i(98553),a=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,o.stringify)(e)}t._join=c;function d(e){return(0,a.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,n.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,n.compactBlankish)(t.split(e));return[t]}}(e),n.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,n.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,n.isEmpty)(e)||(this.value=this.toValidValues((0,n.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,n.isEmpty)(this.values)}isNotEmpty(){return(0,n.isNotEmpty)(this.values)}toNotEmpty(){return(0,n.toNotEmpty)((0,n.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class n extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=n},72564:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),n=i(98553),s=i(55835),o=i(58305);class a extends o.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,n.stringify)((0,r.uniq)(e)))),fromEnv:t=>{return i=t,n=e.strEnum,(0,r.compact)((0,o.splitStringArray)(i)?.map((e=>n.getCI(e))));var i,n},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=a},80372:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),n=i(81168),s=i(83179);class o extends s.Setting{constructor(e){super({toEnv:a,fromEnv:a,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function a(e){return null==e?void 0:(0,n.trimQuotes)(e)}t.StringSetting=o},32707:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),n=i(55835),s=i(46292),o=i(84438);t.systemSettingsFile=function(){return(0,n.map)((0,s.configDir)(),(e=>(0,r.join)(e,o.SettingsToml)))}},80496:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),n=i(44652),s=i(22573),o=i(76850),a=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,o.debom)(e),(0,s.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,n.readFileSync)(t)):void 0}catch(e){return void(0,a.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>f(await(0,n.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,n.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),n=i(96249),s=i(98553),o=i(68708),a=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const n=e+" = "+(0,s.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[n]:(0,a.wrap)(n.split("\n"),i)}t.stringifyToml=function(e){return(0,n.flatten)((0,o.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,a.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},10357:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},65162:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),n=i(81168);t.bname=function(e,t=!0){let i=(0,n.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,n.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},70379:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},88840:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),n=i(40958),s=i(96249),o=i(23838),a=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,a.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,a.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,n.uniq)((0,s.flatten)((0,a.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,n.uniq)((0,s.flatten)((0,a.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new o.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,s.flatten)((0,a.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function v(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=v,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return v(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return v(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return v(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return v(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return v(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return v(i,t)?e.slice(0,-(i.length+1)):e}},68268:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},61208:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},79915:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),n=i(40958),s=i(22573),o=i(81168),a=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,o.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const a=(0,u.isJsonExt)(i.ext),l=a||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=a||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,n.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,n.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return a&&function(e,i){const r=(0,o.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function n(e){return(0,s.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const a=n(e.slice(r.length)),l=n(i.slice(r.length));return a&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,a.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,o.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},45200:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(96249),a=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),v=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function w(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function S(e){const t=await w(e);return(0,n.uniq)((0,o.flatten)(t.map(m.uriEncodingVariants)))}async function b(e,t){if((0,s.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void v().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case a.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case a.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case a.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,s.blank)(e)?v().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=w,t.nativePath2uriVariants=S,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(b(e,t),S))),(0,n.uniq)(i)},t.uri2nativePath=b,t.uriExists=async function(e,t){const i=await b(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),n=i(57975),s=i(90595),o=i(22573),a=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",v=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class w{static isUri(e){return e instanceof w||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,n,s=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,s),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=n??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,s))}get fsPath(){return M(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:n,fragment:s}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===n?n=this.query:null===n&&(n=g),void 0===s?s=this.fragment:null===s&&(s=g),t===this.scheme&&i===this.authority&&r===this.path&&n===this.query&&s===this.fragment?this:new b(t,i,r,n,s)}static parse(e,t=!1){const i=v.exec(e);if(!i)return new b(g,g,g,g,g);const r=i[2]||g,n=D(i[4]||g),s=(i[5]||g).split("/").map(D).join("/"),o="psfile"===r&&s.startsWith("//")?s.slice(1):s,a=(0,u.toURLSearchParams)(i[7]),l=D(i[9]||g);return new b(r,n,o,a,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new b("file",t,e,g,g)}static from(e){return new b(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?w.file(r.win32.join(M(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,a.map)(this.path,(e=>(0,d.findLast)(e.split(y),o.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return x(this,e)}toJSON(){return this}[n.inspect.custom](){return this.toString()}}t.URI=w;const S=h.isWinPortable?1:void 0;class b extends w{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=M(this,!1)),this._fsPath}toString(e=!1){return e?x(this,!0):(null==this._formatted&&(this._formatted=x(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=S),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,o.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function _(e,t){let i,r=-1;for(let n=0;n=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57||45===s||46===s||95===s||126===s||t&&47===s)-1!==r&&(i+=encodeURIComponent(e.substring(r,n)),r=-1),void 0!==i&&(i+=e.charAt(n));else{void 0===i&&(i=e.substr(0,n));const t=P[s];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,n)),r=-1),i+=t):-1===r&&(r=n)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function E(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function x(e,t){const i=t?E:_;let r="";const{scheme:n,query:s,fragment:a}=e;let{authority:l,path:u}=e;if(n&&(r+=n,r+=":"),(l||"file"===n)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,o.mapNotBlank)(s,(e=>r+="?"+e)),a&&(r+="#",r+=t?a:_(a,!1)),r}function C(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+C(e.substr(3)):e}}t.encodeURIComponentFast=_,t.uriToFsPath=M;const T=/(?:%[\dA-Z][\dA-Z])+/gi;function D(e){return e.startsWith("xn--")?(0,s.toUnicode)(e):e.match(T)?e.replace(T,(e=>C(e))):e}t.percentDecode=D,t.toURI=function(e){return w.isUri(e)?e:w.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),n=i(40958),s=i(50357),o=i(89937),a=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",o.PS_LOCAL_FILE_SCHEME,o.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,a.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&f(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,s.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,n.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),n=i(22573),s=i(51926),o=i(89937),a=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,n.blank)(e))return;if(null==(t=null!=t&&(0,a.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,n.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,s.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:o.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==o.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,n.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,s=(0,n.notBlank)(t)&&!t.includes(i);if(s&&!(0,n.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const a=await(0,c.bestVolumeForVolsha)(e.authority);return null!=a?f(a.mountpoint,e.path):s&&(0,n.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),n=i(22573),s=i(51926),o=i(89937),a=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:o.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,n.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,n.blank)(t))return;const i=(0,r.uniq)([t,(0,a.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,s.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:o.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==o.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,a.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,s.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const o=s(i(76760)),a=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,a.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,a.notBlank)(t.remoteHost)&&(0,a.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:o.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,a.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,a.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(o.sep)}`;const n=i.slice(1),s=await(0,p.volumes)();for(const t of(0,u.toA)(s))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return o.join(t.mountpoint,...n);return await(0,h.isReadableDirectory)(t)?o.join(t,...n):void 0}},85087:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),n=i(42659),s=i(9103),o=i(37628);t.volsha=(0,s.memoize)((e=>(0,r.mapNotBlank)(e,o.shortStringSha)),{maxSize:128,ttlMs:n.minuteMs})},60865:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),n=i(30577);t.channel=function(){return(0,n.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),n=i(22573),s=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function o(e){if(e instanceof r.SemVer)return e.version;const t=s.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=o,t.semverSatisfies=function(e,t){if((0,n.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const s=o(e);return null!=s&&(0,r.satisfies)(s,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},8540:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),n=i(9595),s=i(29882),o=i(43334),a=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([a.Settings.libraryDir.valueOrDefault,(0,n.originalsDir)(),...a.Settings.scanPaths.values]))if((!o.isPosix||!(0,s.pathIsRoot)(t))&&(0,s.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},1485:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),n=i(22573),s=i(59455),o=i(50213),a=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.DfPosix"))),v=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function w(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),n=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),s=t&&(i||r||n);return y().tap({msg:"acceptPosixVolume()",result:!s,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:n}})}t.acceptPosixVolume=w,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,s.toA)(await v());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,n.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,s.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,a.assignMissingPrimitives)(i,e))}return t.filter(w)}},69108:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,o.toInt)(e,{defaultValue:0})*a.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,n.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const n=m(e.Used)??0,s=m(e.Available)??0;if(0!==n||0!==s)return{filesystem:t,mountpoint:i,size:d.isMac?n+s:r,used:n,available:s};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:n,available:s})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,n.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,s.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const o=p(i);return!0===e&&o.forEach((e=>e.remote=!1)),o},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(22573),a=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),v=i(24399),w=i(28874),S=i(24541),b=i(60224),P=i(63870),_=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const E=/([a-z]+)(?::\\)?/i;function M(e){return e?.match(E)?.[1]?.toUpperCase()}function x(e){return(0,l.map)(M(e),(e=>e+":\\"))}function C(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(M(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function T(e){return null!=e&&!(0,o.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,o.notBlank)(e.DisplayRoot),...(0,l.map)((0,b.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function D(e){return`Get-Volume ${(0,f.toS)(M(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=x,t.getPsDriveCommand=C,t.getVolumeCommand=D,t.getLocalVolumesWin_=function(){return v.PowerShell.instance().executeJsonToA(D())};const k=/\{([-a-z\d]{7,})\}/i;function O(e,t){return e=e?.trim(),(0,o.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function F(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void _().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=x(e.DriveLetter);if(null==t)return void _().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,n.compact)([O(e.HealthStatus,"healthy"),O(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,o.notBlank)(e.DriveLetter)&&(0,o.blank)(i);return _().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(s=e.UniqueId,_().tap({msg:"uniqueId2uuid",result:(0,l.map)(k.exec((0,f.toS)(s)),(e=>e[1])),meta:{s}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var s}async function I(){const e=(0,n.uniq)((0,h.toA)(await(0,S.mountpointsWin)()).map(x)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(C(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,n.compact)((0,a.flatten)(t).map(T)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(D(e)).catch((t=>(_().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),o=(0,n.compact)((0,a.flatten)(r).map(F)),l=(0,n.uniq)([...i,...o].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,s.sort)((0,n.uniq)([...i,...o].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));_().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:o,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...o.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=F,t.volumeInfoWin=I},68884:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(42659),a=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),v=i(83278),w=i(8103),S=i(16287),b=i(45969),P=i(43334),_=i(69108),E=i(98770),M=i(44224),x=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,b.isDocker)()||(0,d.isBillingService)()||null==await(0,w.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,x.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const C=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?C().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,M.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),S.isReadableDirectory),(e=>e.map((e=>v.BaseFile.for(e).clear().childDirectories())))))}):C().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,n.isEmpty)(e)?[]:(C().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,x.mountpointsTtlMs)(),f:async e=>{const t=await(0,_.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void C().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await T(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,x.mountpointsTtlMs)()}))),(0,a.later)((()=>(0,E.setupVolumeTTL)(t.gioVolumes)));const T=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,x.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,s.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(s.notBlank).get()}}catch(t){return void C().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs})},98770:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),n=i(5233),s=i(41400),o=i(56038),a=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,o.time)("volumes."+e,(()=>(0,n.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,a.isRetriableError)(e)&&!1!==(0,a.isIgnorableError)(e)})))),i);return(0,s.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),v=i(98770),w=i(63870),S=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>S().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>S().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const s=(0,c.sortIgnoreCase)((0,n.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),o=[];for(const t of s){const n=e.find((e=>e.mountpoint===t)),s=i?.find((e=>e.mountpoint===t)),a={...n,...s},u=r?.find((e=>e.filesystem===a.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(a,u),null==a.size||null==a.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];S().info("backfilling mountpoint",{info:s,vol:n,df:e}),null!=e&&(0,l.assignMissingPrimitives)(a,e)}o.push(a)}return o};const b=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return b.exec(e)?.[1]?.split(".").map((e=>(0,o.toInt)(e)))})),_=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,o.gte)(t[0],2)&&(0,o.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,v.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await _()],{timeoutMs:(0,w.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,s.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,o.toInt)(e.fsused),r=(0,o.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return S().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,v.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,w.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,s.toNotBlank)(e.PARTLABEL)??(0,s.toNotBlank)(e.LABEL),uuid:(0,s.toNotBlank)(e.PARTUUID)??(0,s.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),n=i(19851),s=i(40958),o=i(22573),a=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),v=(0,n.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,s.uniq)(e.map((e=>e.filesystem?.match(w)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),n=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of n)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,o.blank)(t.MountPoint)||(0,a.isTrue)(t.OSInternal)?v().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){v().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const w=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(42659),a=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),v=i(84777),w=i(34330),S=i(8769),b=i(34102),P=i(17217),_=i(16287),E=i(43334),M=i(28874),x=i(8540),C=i(68884),T=i(44224),D=i(24541),k=i(69375),O=i(63870),F=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function L(e=(0,O.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function A(){I()}t.localMountpointSetup=(0,r.lazy)((async()=>{M.Settings.libraryDir.watchLater(I),M.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&M.Settings.scanAllDrives.valueOrDefault?(0,a.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(E.isMac&&(e.info("Setting up Mac diskutil activity watcher"),L((0,O.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),E.isLinux){const i=(0,T.maybeWatchProcMounts)();await(0,C.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),L((0,O.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await R()&&(e.info("Setting up Linux findmnt mount monitor"),L((0,O.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),o.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const N=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=M.Settings.mountpoints.values;if((0,n.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",E.isWin?D.mountpointsWin:T.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,n.isEmpty)(e))return F().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,s.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,O.commandTimeoutMs)(),f:async e=>!(!(0,x.mightBeAssetMountpoint)(e)&&(0,k.isExcludedMountpoint)(e)||M.Settings.validateMountpoints.valueOrDefault&&!await(0,_.isReadableDirectory)(e)&&(F().warn(`mountpoint ${e} is not readable`),1))}));return N.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,S.onError)("mountpoints() failed",{cause:e}),N()}})),t.isPosixMountpoint=async function(e){if(E.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return E.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,a.later)((()=>{(0,b.ee)().on("clearCache",(()=>{C.gioVolumes.unset(),I()})),M.Settings.mountpointsTtlMs.watch(L)}),(0,c.isTest)()?1:o.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>A(),minCallDelayMs:1.5*o.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:C.GioCommand,args:C.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(C.gioVolumes.unset(),A()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const R=(0,r.lazy)((async()=>{if(!E.isLinux)return!1;try{return 0===(await(0,v.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,O.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>A(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),n=i(40958),s=i(42659),o=i(48884),a=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),v=i(28874),w=i(69108),S=i(68884),b=i(59107),P=i(69375),_=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await C()??await(0,c.thenMap)((0,w.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,S.isGioSupported)())try{await(0,c.thenMap)((0,S.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){_().warn("Failed to fetch gio volumes",e)}return e};const E="/proc/mounts";function M(e){return!v.Settings.excludedFilesystemTypes.has(e)}function x(e){return!(0,P.isExcludedMountpoint)(e)&&(!v.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function C(e=E,t=M,i=x){if(y.isLinux)try{const r=await(0,f.readLines_)(e),s=(0,n.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,o.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),a=await(0,c.filterAsync)({name:"mountpoints filter",arr:s,f:async([e,r])=>{const n=t(e),s=await i(r);return _().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:n&&s,meta:{fs:e,mp:r,fsOK:n,mpOK:s}})}});return _().tap({msg:"readProcMounts()",result:a.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void _().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=M,t.readProcMounts=C,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(E)?new h.FileWatcher(E,{recursive:!1,persistent:!1},(()=>{_().info("detected change in "+E),(0,d.setUnrefTimeout)((()=>b.mountpoints.refresh()),s.secondMs)})):void 0))},24541:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),n=i(42659),s=i(13538),o=i(50213),a=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,s.thenOrTimeoutError)(f(),a.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*n.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),n=i(22573),s=i(50213),o=i(9103),a=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,n.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,a.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,a.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,a.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,a.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,n.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,o.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),n=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,s=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function o(e){if((0,r.blank)(e))return;const i=n.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(s,""),remoteShare:i.remoteShare};const o=t.nfsRe.exec(e);if(null!=o){const e=o[1],t=o[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=o(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=o},60224:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),n=i(22573),s=i(42659),o=i(55835),a=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),v=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await M()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,o.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const w=["LocalName","RemoteName","Status"],S=["NETUSE","get",w.join(",")],b=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function _(e){if(!(0,n.blank)(e))return(0,a.opt)(e).flatMap((e=>b.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,a.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,n.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,a.opt)(e.pathname).filter(n.notBlank).getOrElse((()=>"/"))}))))).get()}async function E(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,S,{timeoutMs:15*s.secondMs}),i=(0,u.parseFixed)(w,t);return(0,r.compact)(i.map((e=>(0,o.map)(b.exec((0,l.toS)(e.RemoteName)),(t=>(0,o.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=_,t._netInfoWinWmic=E;const M=(0,v.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?E():(0,r.compact)(e.filter((e=>(0,n.notBlank)(e.LocalName))).map((e=>(0,o.map)(_(e.RemoteName),(({host:t,share:i})=>(0,o.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,h.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),n=i(12168),s=i(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=n.MiB/r.secondMs},86848:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(38639),a=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),v=i(95696),w=i(45969),S=i(28874),b=i(59107),P=i(63870),_=i(68995),E=(0,n.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),M=(0,n.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function x(e){return(0,o.isTrue)(e.ignorable)||(0,w.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function C(e){if((0,s.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function T(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=C(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function D(e){if(S.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of S.Settings.volumeUuidFilePaths.values){const i=v.PosixFile.for(e.mountpoint).join(t),r=await T(i).catch((e=>E().info("Failed to read "+i,{error:e})));if(null!=r)return E().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,_.volumeUuidSubpath)());if("/"===e.mountpoint)return E().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(S.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return E().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(S.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,_.writeVolumeUuid)(e);if(!(0,s.blank)(t))return E().tap({msg:"readVolumeUUID(): wrote new "+(0,_.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return E().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,a.later)((()=>{(0,m.ee)().on("clearCache",(()=>M.clear())),b.mountpoints.watchLater((()=>M.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(x(e))return;if((0,o.isFalse)(e.ok))return;const t=await M().getOrSetAsync(e.mountpoint,(async()=>D(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>E().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=x,t.toVolumeUUID=C,t.readUuidFile_=T,t.readVolumeUUID=D},7014:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const n=r(i(48161)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),v=i(59455),w=i(48884),S=i(50213),b=i(7282),P=i(23560),_=i(28850),E=i(45255),M=i(81168),x=i(56519),C=i(4867),T=i(49776),D=i(9595),k=i(77740),O=i(44198),F=i(96706),I=i(8769),L=i(57159),A=(i(34102),i(21144)),N=i(73209),R=i(29882),j=i(95696),B=i(17217),V=i(16287),z=i(49076),W=i(96128),U=i(45969),q=i(43334),H=i(28874),G=i(85087),J=i(50424),$=i(48165),K=i(98770),Y=i(27461),Z=i(66840),X=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,o.lazy)((()=>(0,S.mkLogger)("volumes.Volumes"))),ne=n.default.platform(),se=new Map,oe=new Map,ae=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,G.volsha)(t.uuid),(e=>oe.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,se),le((0,G.volsha)(e.uuid),e,ae),e}function ce(){return(0,a.compact)([j.PosixFile.forMaybe((0,T.cacheDir)())?.join("volumes"),j.PosixFile.forMaybe((0,D.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),oe))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),se.clear(),ae.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,x.mapAsync)({name:"readCachedVolumes",arr:(0,x.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,a.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,M.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),n=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,z.cleanHostname)()},updatedAt:r,os:ne}))),s=new Map;for(const e of n)for(const t of(0,a.compactBlanks)([(0,G.volsha)(e.uuid),(0,G.volsha)(e.mountpoint)]))s.set(t,e);const o=ce();for(const e of o)await(0,N.withLock_)({file:e,timeoutMs:E.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of s.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:o,vol_mountpoints:n.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,a.isNotEmpty)(e))return e;const i=(0,v.toA)(await(0,X.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,H.Settings.volumeMetadataTtlMs.valueOrDefault),n=0!==H.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),s=!(0,a.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:n,priorIsMissingMountpoints:s}),n||s?void 0:e}async function me(e,i){const r=(0,m.map)(e,B.toNativePath_);if((0,u.blank)(r))return;const n=await(0,A.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,a.isEmpty)(t))continue;const i=(0,R.bestMountpointForDir)(n,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:n,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:n}})}async function pe(e,t,i){const r=i.filter((e=>(0,M.equalsIgnoreCase)(t,e.remoteShare)));if((0,a.isEmpty)(r))return;const n=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,M.equalsIgnoreCase)(e,t.remoteHost)));if(null!=n)return n;const s=await(0,W.friendlyname)(e);return(0,x.asyncFind)(r,(async e=>(0,M.equalsIgnoreCase)(s,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,o.lazy)((()=>(0,P.isSyncService)()||(0,b.isTest)())),t.priorWriteVolumesToCacheLatch=(0,o.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,o.lazy)((async()=>{const e=(0,a.compact)(await de()),t=(0,v.toA)(await(0,X.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,a.isNotEmpty)(i)?i:e.filter((e=>ne===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,C.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,C.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,a.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,L.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,_.shim0)({name:"fs.volumes",impl:async function(){if((0,b.isTest)()){const e=(0,p.toInt)((0,O.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,k.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,C.thenOrTimeoutError)({p:q.isWin?(0,$.dfWin)():(0,J.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=H.Settings.validateMountpoints.valueOrDefault?(0,a.compact)(await(0,x.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,V.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,C.thenOrTimeoutError)({p:q.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(q.isWin?t:q.isMac?await(0,Z.addLocalVolumeInfoMac)(t):await(0,Y.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await he(r),Object.freeze(r)}}),t.rootPath=(0,o.lazy)((()=>q.isWin?(0,g.opt)((0,F.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,M.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,a.isEmpty)(t)?void 0:(0,w.greatestBy)(t.filter((t=>(0,R.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,a.commonPrefixLength)(e.split(s.default.sep),t.split(s.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,v.toA)(await i.vols()).find((t=>(0,G.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,x.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return ae.get(e)??(await de())?.find((t=>(0,G.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,G.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(50213),a=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,n.lazy)((()=>(0,o.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,s.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,f());t=(0,s.toNotBlank)(t)??(0,c.safeUUID)();const n=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(n))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+a.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},65713:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),n=i(19851),s=i(23838),o=i(81168),a=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,n.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,n.lazy)((async()=>{const e=(0,a.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,n.lazy)((()=>({trie:new s.MultiMap,small:[]}))),h=3;function f(e){const t=new s.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=n)return n}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),n=i(96249),s=i(23838),o=i(59455),a=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=s.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,o.toA)(u[t])],s=c(e.substring(1));return(0,n.flatten)(s.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,a.stripDiacritics)(e).normalize())}},30933:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const n=r(i(48161)),s=i(19851),o=i(42659),a=i(31586),l=i(50213),u=i(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>n.default.cpus()),5*o.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=n.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,a.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const n=r(i(48161)),s=i(19851),o=i(31586),a=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=n.default.freemem(),t=n.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,o.gt0)(r))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,a.fmtBytes)(i),freemem:(0,a.fmtBytes)(e),totalmem:(0,a.fmtBytes)(t)}})}))},15674:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),n=i(42659),s=i(41400),o=i(31586),a=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,r.lazy)((()=>{const e=(0,o.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*a.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/a.MB),worstCaseMemPerProcMb:Math.ceil(e/a.MB)}})}),n.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,o.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,o.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,f.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=w();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const n=Math.min(e,v());return t=(0,o.clamp)(1,n,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,o.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,o.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,o.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},22751:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),n=i(87997),s=i(19851),o=i(42659),a=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new r.Rate(5*o.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,s.lazy)((()=>(0,n.setInterval)(g,o.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,a.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),n=i(22573),s=i(50357),o=i(98553),a=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function v(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function S(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,o.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,a.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const n=[];if(et;s-=i)n.push(r(s));return n}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),n=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===n[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,s.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const n of t){const t=i(n);r.includes(t)||(e.push(n),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(n.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,o.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,s.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,o.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of S(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,o.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const n=new Set(i.map(r));return e.filter((e=>!n.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),n=i(36783),s=i(41801),o=i(98553),a=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,n.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const r of e)(0,a.getOrSet)(i,(0,o.stringify)(t(r)),(()=>r));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,n.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,s.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},5233:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),n=i(31586),s=i(13538),o=i(41583);t.retryOnReject_=async function(e,t){const i=(0,n.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const a=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,o.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await a(l),u()}};return u()}},17586:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},22573:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),n=i(42279),s=i(54993);function o(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function a(e){return!o(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,s.toS)(e);return a(i)?t(i):void 0}t.blank=o,t.notBlank=a,t.notBlankToS=function(e){return a(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,n.tot)(t);const i=(0,s.toS)(e).trim();return i.length>0?i:(0,n.tot)(t)},t.notBlankAnd=function(e,t){return!o(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),n=i(22573),s=i(30301),o=i(55835),a=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,o.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,a.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const n=Math.floor(e/t.minuteMs);e-=n*t.minuteMs;const s=Math.floor(e/t.secondMs),o=Math.floor(e-s*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(n)+":"+(0,l.pad2)(s)+(i.includeMs?"."+(0,l.pad3)(o):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),n=i(),s=i(),o=i(),a=i(),l=i();return new Date(t,l-1,a,o,s,n,r)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,i="ago"){return e<1e3?"just now":(i=(0,n.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const s=Math.floor(e/r.ms);e-=s*r.ms,s>0&&(r.ms>=t.dayMs?i:n).push(s+r.s)}return e>0&&n.push((0,a.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(n)?"":"T"+n.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,o.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),n=i(73872);function s(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function o(e,t,i,r){if(null==i||y(e)||y(t))return;let n=i.get(e);null!=n?n.set(t,r):(n=new WeakMap,n.set(t,r),i.set(e,n))}function a(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const n=l(e,t);return null!==n?n:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=s(e,t,u);if(null!==f)return f;const m=s(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return o(e,t,u,i),i;const n=l(e,t);if(null!==n)return n}const y=n(e);if(y!==n(t))return o(e,t,u,!1),!1;o(e,t,u,!0);const v=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return a(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],n=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){n.push([e,t])})),c(r.sort(),n.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return o(e,t,u,v),v}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let n=-1;for(;++n{Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const n=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return n.prior=()=>t,n.hasPrior=()=>r,n}},41400:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),n=i(35556),s=i(31586),o=i(68708);function a(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const s=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&n.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return a(t).then((()=>t))},t.delay=a,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),s=n.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return n.isBrowser||t<=r.secondMs?s:(0,o.maybeCall)(s,"unref")??s}},50357:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),n=i(68708),s=i(34666),o=i(32639);function a(e,t){return(0,r.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,o.isFunction)(e)&&(0,o.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=a,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return!1;for(const i of(0,n.keys)(e))if(!a(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),n=i(22573),s=i(96249),o=i(31586),a=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,n.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,o.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,s.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,n.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,n.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,n.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(n.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,a.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,a.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,a.assignFields)(new Error,(0,a.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},96249:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),n=i(42659),s=i(55835),o=i(31586),a=i(12168),l=[{ms:n.yearMs,s:"year",p:"years"},{ms:n.yearMs/12,s:"month",p:"months"},{ms:n.weekMs,s:"week",p:"weeks"},{ms:n.dayMs,s:"day",p:"days"},{ms:n.hourMs,s:"hour",p:"hours"},{ms:n.minuteMs,s:"minute",p:"minutes"},{ms:n.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,n){if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,s.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,a.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,s.mapOr)(n,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function n(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=n,t.orList=function(e){return n(e,"or")},t.andList=function(e){return n(e,"and")}},73722:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const n=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,n){if((0,isFunction_1.isFunction)(r))return;let s,o,a,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),n=i(50357),s=i(31586),o=i(65812);t.lazy=function(e,t){let i,a;const l=[];function u(){return u.isStale()&&u.setResult(e()),a}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const s=await e,a=await i;if(!(0,n.eql)(s,a))for(const e of l)e(a);null!=t&&t>0&&void 0!==a&&(0,o.setUnrefTimeout)((()=>u.vacuum()),t)}(a,e),a=e},u.isStale=function(){return null==i||(0,s.gt0)(t)&&i+t{Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),n=i(54993);function s(e,t){return null==e?void 0:t(e)}function o(e,t,i){return null==e||null==t?void 0:i(e,t)}function a(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=o,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=a,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return a(o(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,n.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class n extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=n},23838:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),n=i(76790),s=i(50357),o=i(98553),a=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,a.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,a.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,s.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),n=null==i?[]:e(t,i);(0,r.isEmpty)(n)?this.store.delete(t):this.store.set(t,n)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,n]of this.store.entries()){const s=(0,r.findIndexes)(n,(t=>!e(i,t,n)));if(s.length>0){t=!0;for(const e of s.reverse())n.splice(e,1)}0===n.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,o.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,n.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),n=i(22573),s=i(42279),o=i(54993);function a(e){return"number"==typeof e&&isFinite(e)}t.isNumber=a,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,o.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return a(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,o.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>a(t)&&a(i)&&e(t,i);function f(e,i,n){return!(null==n||!a(n))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,n)&&(0,t.gte)(i,n))}function m(e){if(!a(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,n.blank)(e))return t.defaultValue;if(a(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return a(e)&&e>0}function S(e){return a(e)&&e>=0}function b(e,t){return a(e)?t(e):void 0}function P(e){return a(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function E(e,t,i){if(e>t||!a(e)||!a(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return a(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return a(e)?e:t},t.diff=function(e,t){return a(e)&&a(t)?e-t:void 0},t.absdiff=function(e,t){return a(e)&&a(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!a(e)||!a(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return f(t-r,t+r,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)a(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return a(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return a(e)&&a(t)&&e>t?e:void 0},t.lte0=function(e){return a(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=v(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,i){return b(e,(e=>b(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return a(e)?t(e):i},t.numericOr=function(e,t){return a(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d+\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!a(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=E,t.times=function(e,t){if(!w(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return E(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!a(i))return;t+=i}return t}},68708:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(32639),a=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function w(e,t,i={}){return y((0,r.compact)((0,n.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function S(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const n={};for(const e of(0,r.uniq)((0,r.flatMap)(i,h)))n[e]=S(...i.map((t=>t[e])));return n}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=v(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,n]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==n&&!0!==i?.assignNullish||(e[r]=n));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,a.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,s.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=a.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function n(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:S(i,t)}for(const r of i){const[i,o]=(0,c.splitFirst)(r,"."),a=b(t,i);null!=a?.value&&n(a.key,(0,s.blank)(o)?a.value:e(a.value,o))}for(const r of h(t))((0,l.toInt)(r)??-1)>=0&&n(r,e(t[r],...i));return r},t.pluck=b,t.pluckDeep=function e(t,i){if(null==t||(0,s.blank)(i))return;if(Array.isArray(t)){const n=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(n)?void 0:{key:n[0].key,value:(0,r.flatMap)(n,(e=>e.value))}}const[n,o]=(0,c.splitFirst)(i,"."),a=b(t,n);if(null==a)return;if((0,s.blank)(o))return a;const l=e(a.value,o);return null==l?void 0:{key:a.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,o.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=w(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return n(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return s(e).flatMap((e=>s(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return s(e).flatMap((e=>s(t).flatMap((t=>s(i).flatMap((i=>r(this.a,e,t,i)))))))}}function n(e){return e instanceof r||e===t.None}function s(e){return n(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=n,t.opt=s},39926:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),n=i(54993),s={};function o(e,t){if(t<1)return"";if(!(0,r.gte)(s[e]?.length,t)){let i=s[e]??e;for(;i.length{Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),n=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,o=/[^aeiou]y$/,a=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=n.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(o)?e.replace(/y$/i,"ies"):null!=e.match(a)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),n=i(54993),s=["number","string","boolean"];function o(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=o,t.mapPrimitive=function(e,t){return o(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return o(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(o)};const a=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,s=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==s&&"symbol"!==s)){const r=(0,n.toS)(e),s=(0,n.toS)(i),o=r.localeCompare(s);return r[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-o:o}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==s?a.indexOf(r)-a.indexOf(s):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function n(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const n of(0,r.toA)(await e))if(null!=n){const e=await n;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=n,t.isPromise=function(e){return n(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),n=i(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function o(e,t,i){return null==i||0===i.length?s(e,t):a(e,t,1,i)[0]}function a(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const n=t-e,o=new Set(r??[]);if(t===e&&0===n&&0===o.size&&1===i)return[e];const a=n-o.size;if(i>a)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:n,size:i,slotsRemaining:a})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of a(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,n.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},5670:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),n=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const o=e=>null!=e?i[e]:void 0,a=e=>null!=o(e);return{...s,values:t,length:t.length,has:a,includes:a,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:o,ordinal:e=>o(e)??t.length,validOrElse:(e,t)=>a(e)?e:(0,n.tot)(t),mapValid:(e,t)=>a(e)?t(e):void 0,cmp:(e,t)=>{const i=o(e),r=o(t);return null==i||null==r?void 0:i>r?1:i{const i=o(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),n=i(17586),s=i(22573),o=i(96249),a=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=f();return null!=r?(0,a.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function b(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),n=(0,c.toS)(t);return r.length===n.length&&(r===n||r.toLowerCase()===n.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?n.normalize():n,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,n.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,a.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return w(v(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,i){const r=i?.maxLineLen??80,n=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,o.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,o.flatten)(r.map((t=>e(t,i))))}if((t=v((0,c.toS)(t),n).trim()).length<=r)return[t];const s=S(t," ",r);if(s>n.length)return[m(t,0,s),...e(m(t,s+1),i)];{const r=t.indexOf(" ",n.length+1);return r>0&&r{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),n=i(68708),s=i(42279),o=i(83104),a=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let n=!0;const s=setTimeout((()=>{n&&(n=!1,i(o.Timeout))}),t);try{s.unref?.();const t=await e;n&&(n=!1,i(t))}catch(e){n&&(n=!1,r(e))}finally{clearTimeout(s)}}))}async function u(e,t,i=!0){const n=await l(e,t,i);if(n===o.Timeout)throw new a.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return n}t.toNotTimeout=function(e){return e===o.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?o.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,s)=>{let o=!0;try{const a=setTimeout((async()=>{if(o){o=!1;try{r(await i())}catch(e){s(e)}}}),t);(0,n.maybeCall)(a,"unref");const l=await e;o&&(o=!1,clearTimeout(a),r(l))}catch(e){o&&(o=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const n=t-Date.now();if(n<=0)throw new a.TimeoutError("timeout ("+(0,r.fmtHMS)(n)+")");return u(e,n,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const n=await l(e,t,r);return n===o.Timeout?(0,s.tot)(i):n}},42279:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),n=i(22573),s=i(54993);function o(e){return"URLSearchParams"===e?.constructor?.name}function a(e){return null==e?void 0:o(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(a)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=o,t.toURLSearchParams=a,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,s.toS)(l(...t));return e+((0,n.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,s.toS)(l(...t));return(0,n.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),n=i(30301),s=i(31586),o=i(46891),a=i(50989),l=i(51926),u=(0,n.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,s.isNumber)(r)&&(i+=r/t.MB);return(0,s.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),n=Math.pow(10,3*r),o=d[r];return(0,s.sigFigs)(e/n,t)+" "+o}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),n=Math.pow(2,10*r),o=h[r];return(0,s.sigFigs)(e/n,t)+" "+o},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,a.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,o.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,o.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},65812:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},23541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),n=i(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,n.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),n=i(23541),s=i(59455),o=i(54993);function a(e){return null==e?void 0:(0,n.isError)(e)?e:new Error((0,o.toS)(e))}t.toErr=a,t.toErrs=function(...e){return(0,r.compact)((0,s.toA)(e).map(a))}},54993:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return s(e,",")};const n={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==n?e.toString():(0,r.stringify)(e)}}t.toStr=s},90858:e=>{e.exports=require("@iarna/toml")},58587:e=>{e.exports=require("batch-cluster")},6858:e=>{e.exports=require("commander")},36507:e=>{e.exports=require("croner")},66261:e=>{e.exports=require("events")},77988:e=>{e.exports=require("exiftool-vendored")},44652:e=>{e.exports=require("fs-extra")},28787:e=>{e.exports=require("he")},51168:e=>{e.exports=require("luxon")},57272:e=>{e.exports=require("plist")},90595:e=>{e.exports=require("punycode")},38064:e=>{e.exports=require("semver")},73872:e=>{e.exports=require("type-detect")},92460:e=>{e.exports=require("util")},31421:e=>{e.exports=require("node:child_process")},77598:e=>{e.exports=require("node:crypto")},40610:e=>{e.exports=require("node:dns")},78474:e=>{e.exports=require("node:events")},73024:e=>{e.exports=require("node:fs")},51455:e=>{e.exports=require("node:fs/promises")},77030:e=>{e.exports=require("node:net")},48161:e=>{e.exports=require("node:os")},76760:e=>{e.exports=require("node:path")},53916:e=>{e.exports=require("node:path/posix")},1708:e=>{e.exports=require("node:process")},57075:e=>{e.exports=require("node:stream")},46466:e=>{e.exports=require("node:stream/promises")},87997:e=>{e.exports=require("node:timers")},57975:e=>{e.exports=require("node:util")},38522:e=>{e.exports=require("node:zlib")},16928:e=>{e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.exports}var __webpack_exports__={},exports;exports=__webpack_exports__,Object.defineProperty(exports,"__esModule",{value:!0}),__webpack_require__(75631),module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{"use strict";var __webpack_modules__={37975:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),n=i(38639),s=i(44198);function o(){return(0,n.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=o;let a=!o();function l(){return a}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){a=e??!o()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),n=i(7282),s=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,n.isProd)()?"":`-${(0,n.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),n=i(36783),s=i(76790),o=i(22573),a=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const n=new Set(t.map(i));return e.filter((e=>n.has(i(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...v(e.slice(i+1))]}function w(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function E(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,i){return x(e,t,i).index}function x(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let n,s=-1;for(let r=0;re.slice(i,i+t)))}async function T(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,a.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(o.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,a.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,n.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let n=0;for(const s of e)(t(s,n++)?i:r).push(s);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let n=0;ne.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=E,t.least=function(e){return E(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const i=x(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=C,t.collectBatched=function(e,t,i){const n=[];for(const s of C((0,r.compact)((0,f.toA)(e)),t))n.push(...(0,r.compact)(i(s)));return n},t.collectBatchedAsync=async function(e,t,i){const n=[];for(const s of C((0,r.compact)((0,f.toA)(e)),t))n.push(...(0,r.compact)(await i(s)));return n},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await T(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+n;if(re+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const a=i(77988),l=o(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),v=i(25764),w=i(38836),S=i(99331),b=i(95937),P=i(98314),_=i(38835),E=i(70025),M=i(8769),x=i(43334),C=i(95402),T=i(28874),D=i(63870);class k extends w.EndableWrapper{constructor(e,t,i=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,r,"m",n).call(this)),i,"worker"===e?(0,D.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const o=t;o.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,C.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),o.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),o.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),o.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),o.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),o.on("noTaskData",((e,i,r)=>{const n=t.options.streamFlushMillis;n{this.logger.error("observeBatchCluster.endError()",e)})),o.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&C.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof a.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,E.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=k,r=new WeakSet,n=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(x.isWin?3:1)*c.minuteMs,maxTasksPerProcess:T.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:T.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:T.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:T.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:T.Settings.taskTimeoutMs.valueOrDefault}}},89788:function(e,t,i){var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(r.add(this),this.maxLength=e,n.set(this,void 0),s.set(this,0),o.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,n,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",a).call(this,e,(e=>u(this,n,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",a).call(this,e,(e=>u(this,n,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,o,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,n,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,n,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,r,"m",a).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,n,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,s,"f"){u(this,n,"f")[e]=c,l(this,o,e,"f")}));return u(this,s,"f")}shift(){return u(this,r,"m",a).call(this,0,(e=>{var t,i;return l(this,o,(t=u(this,o,"f"),++t),"f"),l(this,s,(i=u(this,s,"f"),--i),"f"),u(this,n,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",a).call(this,u(this,s,"f")-1-e,(e=>{const i=u(this,n,"f")[e];u(this,n,"f")[e]=u(this,n,"f")[t],u(this,n,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),n=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:i}of n)if(o(e,t))return e.subarray(t.length).toString(i);return e.toString()}function o(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,r.toS)(e)},t.bufferStartsWith=o},9092:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class n{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=n},36638:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class n{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=n},40583:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const o=i(40958),a=i(23838),l=s(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new a.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,o.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,n=-1;for(const[i,s]of this.m.entries()){const o=(0,c.diceCoeff)(i,e);if(o>t&&o>n){const e=this.getFirst(s);null!=e&&(r=e,n=o)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),n=i(31586),s=i(68708),o=i(54993),a=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new a.Average(0);for(const t of this.keys()){if(!(0,n.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,o.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,n.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new a.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,n]of this.m.entries()){const s=e(r);t.fill(s,i,i+n),i+=n}return t}}t.CountingSet=u},79840:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),n=i(72993),s=i(45969),o=i(43334);t.EditionType=(0,r.lazy)((()=>o.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>n.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),n=i(55835),s=i(68708);var o=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return o.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,n.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,s.omit)(e,...i),(0,s.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,n.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),n=i(19851),s=i(95696);t.examples=(0,n.lazy)((()=>s.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),n=i(65843),s=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,n.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,s.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),n=i(40958),s=i(55835),o=i(31586),a=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,o.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,o.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,n.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,n.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,a.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,a.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,a.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,o.isNumber)(e.__uid)&&(0,o.isNumber)(e.__start)}},80049:function(e,t,i){var r,n,s,o,a,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),n.set(this,0),s.set(this,0),o.set(this,0),a.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,n,l(this,n,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,o,l(this,o,"f")+e.rejections,"f"),u(this,a,l(this,a,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,n,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,o,"f"),timeouts:l(this,a,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,o,a;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,n,(i=l(this,n,"f"),++i),"f"),c.promise):(u(this,r,(o=l(this,r,"f"),++o),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(a=l(this,r,"f"),++a),"f"),c}get(e){var t,i;const n=this.cache.get(e);return null==n||n instanceof m.Deferred&&n.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),n instanceof m.Deferred?n.value:n}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,n,0,"f"),u(this,s,0,"f"),u(this,o,0,"f"),u(this,a,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,o,(t=l(this,o,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,a,(r=l(this,a,"f"),++r),"f")})),r.promise}},r=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap},54127:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,o.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,n.range)(0,r).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,a.fromEntries)(e))).filter((e=>(0,a.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,a=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(a,r.index);(0,s.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),h=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:h});else{const e=(0,n.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,o.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}a=t.lastIndex}const l=(0,n.last)(i);return null!=l&&((0,s.blank)(this.headerRow.slice(a))?l.rightIdx=(0,o.max_)(...this.rows.map((e=>e.length))):l.rightIdx=a),i}}t.Fixed=m},73913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),n=i(98553);var s=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const i=(0,n.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,n.parseJSON)((await(0,r.readFile)(e)).toString())}},19851:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const o=i(57975),a=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,r,"m",n).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,a.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(42659),a=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,a.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?E():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=w.exec(e.trim())?.groups;return null==i?void 0:(0,n.compact)([i.lang,i.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const _={timeoutMs:10*o.secondMs};async function E(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return b(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=E,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),n=i(1708),s=i(45599),o=i(68708),a=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,s.defer)((()=>{(0,a.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:n.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,o.pick)(n.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:n.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),n=i(32105),s=i(14593);t.rootLoggers=(0,r.lazy)((()=>[n.ConsoleLogger.instance()]));const o=(0,r.lazy)((()=>[n.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,o)}},56639:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),n=i(55835),s=i(59455),o=i(48884);function a(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,o.concat)(...e.map((e=>t(e)))))},t.compactMap=a,t.toMap=function(e,t){return a((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:a(await Promise.all((0,r.compact)((0,s.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,n.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),n=i(54557);t.memoize=function(e,t){let i=0;const s=new n.FifoCache(t.maxSize,t.ttlMs),o=t=>{if(null!=t)return i++,s.getOrSet((0,r.stringify)(t),(()=>e(t)))};return o.clear=e=>null==e?s.clear():s.delete((0,r.stringify)(e)),o.size=()=>s.size,o.callCount=()=>i,o}},7282:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const n=r(i(1708)),s=i(38639),o=i(54993),a=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,a.lazy)((()=>n.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,o.toS)(n.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return n.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(n.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){n.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),n=i(22573),s=i(96249),o=i(55835),a=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,a.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(a.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,a.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,o.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,a.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,a.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,a.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,a.toInt)(e),n=(0,a.toInt)(t);return null!=r&&r>0&&null!=n&&n>0?i(r,n):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,a.isNumber)(e))return e;if((0,n.blank)(e))return;const t=String(e);return(0,o.map)(f.exec(t),(e=>(0,a.toFloat)(t.substr(e.index))))}function p(e){return(0,a.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,o.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,o.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const n=i*e.length;for(let i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),n=i(42659),s=i(96249),o=i(55835),a=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,n.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,n]of(0,l.entries)(e)){const e=t(r,n);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,o.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(o.defined)},t.firstDefinedField=function(e,...t){return(0,o.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,o.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const n of t)r[n]=i(n,e[n]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let n=0;for(const s of(0,l.keys)(e))if(r[s]=t(s,e[s]),n++,(0,a.gt)(n,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,s.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),n=i(73024),s=i(48161),o=i(19851),a=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),v=i(30933),w=(0,o.lazy)((()=>(0,f.mkLogger)("os")));function S(){return(0,s.platform)()+" "+(0,s.release)()}t.osArch=(0,o.lazy)((()=>`${function(){switch((0,s.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return k();case"win32":return O();default:return S()}}()} on ${(0,s.arch)()}`)),t.osFullName=(0,o.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const b=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function _(){return"ubuntu"===(0,t.osDistributionLinux)()}function E(){return"fedora"===(0,t.osDistributionLinux)()}function M(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,o.lazy)((()=>{if(g.isLinux)for(const e of b)try{const t=(0,n.readFileSync)(e).toString();if((0,a.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,o.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,a.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),S)})),t.osDistributionLinux=(0,o.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=_,t.hasApt=function(){return P()||_()},t.isFedora=E,t.isAlpine=M;const x={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},C={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function T(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),n=t[i];return(0,c.isString)(n)?n:n?.[r]}const D=(0,o.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function k(e=D()){try{return(0,a.mapNotBlankOr)(function(e=D()){return T(e,x)}(e),(t=>`macOS ${t} (${e})`),S)}catch(e){return w().warn("osNameMac(): unknown release",e),S()}}function O(e=(0,s.release)()){const t=e.startsWith("10.0.22")?"11":T(e,C);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=k,t.osNameWin=O,t.CPUs=(0,o.lazy)((()=>(0,h.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,o.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(O())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=D();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(_())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(E())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(M())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},12801:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const n=r(i(48161)),s=i(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:n.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:n.default.constants.priority.PRIORITY_NORMAL,BelowNormal:n.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:n.default.constants.priority.PRIORITY_LOW,Low:n.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),n=i(56409),s=i(31586),o=i(22911),a=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...r){f=!0,m=Date.now()+(0,s.max_)(t,i);const n=d=new o.Deferred(c);(0,s.gt0)(i)&&n.setTimeout(i);try{n.resolve(await e(...r))}catch(e){n.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,a.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return n.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,r.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new n.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),n=i(54993);function s(e){return e instanceof o?e.source:(0,n.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let n;for(;null!=(n=e.exec(t));)n.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(n,"index","groups"));return i},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(s(t))}const n=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(n,i)};class o{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=o;class a extends o{static from(...e){const t=l(e);return new a("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,a=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof o||t instanceof RegExp?(i+=t.source,r||(r=t.global),a||(a=t.ignoreCase),l||(l=t.multiline)):i+=s((0,n.toS)(t));return new RegExp(i,t??(r?"g":"")+(a?"i":"")+(l?"m":""))}t.RegExpOptional=a,t.concatRegexp=l},79089:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const n=r(i(48161)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),v=i(34102),w=i(43334),S=i(24399),b=i(28874),P=(0,o.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,o.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,a.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let E=!0;const M=(0,o.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const i=(0,p.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),E)try{return n.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;E=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const n=r(i(1708)),s=i(19851),o=i(40958),a=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===a.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===a.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===a.ServiceNames.sync}function p(){return(0,t.serviceName)()===a.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,o.compactBlanks)([t.serviceName.prior(),(0,l.toS)(n.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return a.ServiceNames.indexOf(e)??a.ServiceNames.length+1},t.MainServices=[a.ServiceNames.main,a.ServiceNames.desktop],t.DbServices=[a.ServiceNames.sync,a.ServiceNames.info,a.ServiceNames.web,a.ServiceNames.list,a.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[a.ServiceNames.sync,a.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===a.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===a.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,s.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function n(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=n,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=n(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=n(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),n=i(57150),s=i(7282),o=i(23560),a=i(17181);t.setServiceName=function(e){(0,o.isMainService)(e)&&(e=r.ServiceNames.main);const t=o.serviceName.prior();t!==e&&((0,s.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),o.serviceName.set(e),(0,a.setupLogger)(),(0,n.logStartup)())}},28850:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const a=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends a.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),n.set(this,void 0),s(this,r,e,"f")}_call(){return(0,l.time)(o(this,r,"f")+(null==o(this,n,"f")?"(local)":"(remote)"),null==o(this,n,"f")?this.impl():o(this,n,"f").call(this))}setShim(e){s(this,n,e,"f")}hasShim(){return null!=o(this,n,"f")}clearShim(){s(this,n,void 0,"f")}}r=new WeakMap,n=new WeakMap},12089:function(e,t,i){var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,o){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=o,n.set(this,void 0),s.set(this,void 0),l(this,n,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",a).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",o).call(this,e),(()=>u(this,r,"m",a).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",o).call(this,e))}}n=new WeakMap,s=new WeakMap,r=new WeakSet,o=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},a=function(e){return(0,m.time)(u(this,n,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=i(76790),o=i(17586);class a{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return n(this,r,"f")[Symbol.iterator]()}get length(){return n(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=n(this,r,"f").length-1;for(;t<=i;){const s=t+Math.floor((i-t)/2),o=this.valueOf(n(this,r,"f")[s]);if(e===o)return{found:!0,index:s};e>o?t=s+1:i=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&n(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...n(this,r,"f")];const o=t=>t<0||t>n(this,r,"f").length-1?null:(i??this.diff)(n(this,r,"f")[t],e),a=this.findIndex(e);if(null==a)return;let l=a.index-1,u=o(l),c=a.index,d=o(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return n(this,r,"f").shift()}at(e){return(0,o.at)(n(this,r,"f"),e)}toA(){return[...n(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===n(this,r,"f").length-1){const e=[...n(this,r,"f")];return n(this,r,"f").length=0,e}return n(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return n(this,r,"f").splice(e,t)}retainLastN(e){return e{Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),n=i(82328),s=i(84542),o=i(95705),a=i(28874);t.consoleLog=function(e,...t){a.Settings.quiet.valueOrDefault||(0,n.stdoutEnded)()||console.log((0,s.crlf)(e),...t)},t.consoleError=function(e){a.Settings.quiet.valueOrDefault||(0,o.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=a.Settings.quiet.envValue;try{return a.Settings.quiet.envValue=!0,await e()}finally{a.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),n=i(95705);t.stdoutEnded=function(){return(0,n.streamEnded)(r.stdout)}},71567:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const n=r(i(1708)),s=i(22573),o=i(98553),a=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:n.default.stdout})}function f({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const n=(0,o.stringify)(e,void 0,(0,a.isInfoService)()||(0,a.isMainService)()?2:void 0);r.write(n+"\n"),(0,a.isWorkerService)()&&null!=i&&(n.includes(u.FailStr)||(0,c.isFatalError)(n)||(0,c.isHealthCheckError)(n)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||n.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:n.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(55835),a=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const n=t.indexOf(i,r);return-1===n?0:1+e(t,i,n+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,a.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,h.toS)(e),n=(0,h.toS)(t);return n.length>0&&(0,c.equalsIgnoreCase)(r.slice(-n.length),n,i)?r.slice(0,-n.length):r},t.gist=function(e,t=80,i=80){const r=(0,h.toS)(e),n=r.length-(t+i);return n<=0?r:r.slice(0,t).trim()+" …(+"+n+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,o.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=S(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,s.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),n=t.indexOf(r);if(n>=0)return{index:n,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function E(e){return _.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=E;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(E(e))&&(e=e.slice(1,-1).trim())),e};const x=/^['‘’].*['‘’]$/,C=/^["“”„«»〃].*["“”„«»〃]$/;function T(e,t){const i=D(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function D(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let n,s=0;for(;null!=(n=t.exec(e));)n.index===t.lastIndex?t.lastIndex++:(t.lastIndex=n[0].length+n.index,i.push(e.substring(s,n.index)),r.push(e.substring(n.index,t.lastIndex)),s=t.lastIndex);return s(0,a.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),x.test(e)||C.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),n=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,o.map)(i[e],(e=>t+=e))));return t},t.splitKeep=T,t.splitUp=D,t.sortNaturalBy=k,t.sortNatural=function(e){return(0,n.sortBy)(e,(e=>k(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,n.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,a.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const O=/#.*$/gm;t.stripComments=function(e){return e.replace(O,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,s.blank)(r))for(const e of r.split(t))(0,s.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,s.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),n=e.findIndex((e=>r.test(e))),o=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(n<0)return e;for(let t=n+1;te.trim()))))}},83556:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function n(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=n,t.asObjectKey=function(e){return n(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const n=r(i(77598)),s=i(73913),o=i(55222);function a(e,t=s.HashBits){return n.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=o.Radix58,r=224){return i.encodeBuffer(a(e,r)).substring(0,t)}t.stringShaToBuffer=a,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=o.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(31586),a=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,n="";for(let s=0;s=r&&(r=i.get(s,o),n=(0,l.substr)(e,s-r+1,r)));return n}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),n=t.normalize();return e!==r||t!==n?y(r,n):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function v(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===r?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(i),t=w(r);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function S(e,t){const i=(0,f.intersection)(e,t),n=[];return i.forEach((i=>{const s=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,o.times)(s,(()=>n.push(i)))})),n}function b(e,t,i){const n=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,n))-i((0,l.strslice)(t,n))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,n.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[i,r]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(i,r,(e=>(0,o.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=_;const E=/[^\da-z]+/gi;function M(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(E,"").toLowerCase()));return b(i,r,(e=>c.RadixAlphaNum.decode(e)))}function x(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const n=(0,o.mapNumericOr)(e.charCodeAt(r),(e=>e),256),s=(0,o.mapNumericOr)(t.charCodeAt(r),(e=>e),256),a=(0,o.clamp)(-256,256,n-s);i=null==i?a:(i+a)/2}return i}t.radixDiff=M,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=x,t.paddedPositionalDiff=function(e,t,i=8){return x((0,a.leftPad)(e,i," "),(0,a.leftPad)(t,i," "))}},84885:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),n=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,n.sortedKeys)(e))}},75387:function(e,t,i){var r,n,s,o,a,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",n.set(this,[]),s.set(this,new Map),o.set(this,void 0),a.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,o,"f")}set ttlMs(e){h(this,o,e,"f"),null!=d(this,a,"f")&&clearInterval(d(this,a,"f")),h(this,a,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,a,"f")&&clearInterval(d(this,a,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,s,"f").clear(),this}delete(e){return d(this,s,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,s,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,s,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,s,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const n=t();return null!=n&&this.set(e,n),n}lastSetOrGetTs(e){return d(this,s,"f").get(e)?.ts}set(e,t){return d(this,s,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,s,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,s,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,f.sortBy)(d(this,s,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,n,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,s,"f").delete(e);for(const i of d(this,n,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,s,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[o]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return a(this,r,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>a(this,r,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||a(this,r,"m",n).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)a(this,r,"m",n).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!a(this,r,"m",n).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)a(e,r,"m",n).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)a(e,r,"m",n).call(e,t,i)||(yield[t,t])}()}toA(){return a(this,r,"m",s).call(this),[...this.delegate.keys()]}[(r=new WeakSet,o=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,n=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},s=function(){for(const[e,t]of this.delegate)a(this,r,"m",n).call(this,e,t)}},84699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},94174:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const n=r(i(48161)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,o.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,o.lazy)((()=>(0,a.uniq)([s.default.geteuid?.(),s.default.getuid?.(),n.default.userInfo().uid]))),t.userid=(0,o.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,o.lazy)((()=>(0,a.uniq)([s.default.getegid?.(),s.default.getgid?.(),n.default.userInfo().gid]))),t.groupid=(0,o.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,o.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,o.lazy)((()=>(0,l.toNotBlank)(n.default.userInfo()?.username))),t.userNameFromWhoami=(0,o.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,o.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,o.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,o.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.1-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=1,t.versionPrerelease=["prealpha"],t.release="2024.3.1-prealpha+20240308150212",t.gitSha="d92384e8659ff46fbae8e6f81fa5867114a4a843",t.gitDate=new Date(1709938932e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),n=i(55835),s=i(31586),o=i(97790),a=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,n.allDefined)(i))return;const[o,a,u,c,d,h,f]=i,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(o,a-1,u,c,d,h,f/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,o.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,a.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},73568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const a=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),n.set(this,(0,a.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,n,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,n,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,n,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),o(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,r,"f")&&clearTimeout(s(this,r,"f")),o(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,n=new WeakMap},22911:function(e,t,i){var r,n,s,o,a,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(i(87997)),w=y(i(57975)),S=i(45599),b=i(26905),P=i(55835),_=i(31586),E=i(68708),M=i(20214),x=i(57153),C=i(85556),T=i(50213),D=i(70025),k=i(95937),O="TIMEOUT",F=(0,S.defer)((()=>(0,T.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,_.gt0)(t)?new n(O).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const n=i[r];if(n.isSettled){if(n.name===O)return void F().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield n.value}}if(i.every((e=>e.name===O)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new n(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),o.set(this,void 0),a.set(this,x.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=n,n,(y=p(i,n,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,T.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof n&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,a,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,E.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,o,"f")}get elapsedMs(){return(p(this,o,"f")??Date.now())-this.startedAt}get[(o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new C.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,k.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,a,"f")===x.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,a,"f")!==x.PromiseStates.pending}get isResolved(){return p(this,a,"f")===x.PromiseStates.resolved}get isRejected(){return p(this,a,"f")===x.PromiseStates.rejected}get settledMs(){return null==p(this,o,"f")?void 0:p(this,o,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,a,x.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,D.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,a,x.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,n=I,m=function(e){if(p(this,a,"f")===x.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,o,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},s={value:0}},27395:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),n=i(40958),s=i(42659),o=i(23838),a=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new o.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,a.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,n.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,n.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){var r,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",o).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,n.set(this,void 0),s.set(this,void 0),a.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,n,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",o).call(this);const h=()=>{u(this,r,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,n,(0,d.setInterval)(u(this,a,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,a,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):h(),!0}}t.EndableInterval=v,n=new WeakMap,s=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(){(0,h.map)(u(this,n,"f"),d.clearInterval),c(this,n,void 0,"f"),(0,h.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const a=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,o){this.endTimeoutMs=o,r.set(this,void 0),this.onEnds=[],n.set(this,(0,a.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,n,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){o(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,n,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,n=new WeakMap},99331:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let n=!1;t.ending=function(){return n},t.setEnding=function(e){n=(0,r.isTest)()?e:e||n}},45608:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const n=r(i(1708)),s=i(22573),o=i(45599),a=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,o.defer)((()=>(0,l.mkLogger)((0,a.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,o.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,s.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,f.endEndables)(),n.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,o.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])n.default[e].on(t,(i=>{v({reason:`${e}:${t}`,status:0,error:i})}))}))},5916:function(e,t,i){var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,n.set(this,void 0),s.set(this,0),o.set(this,void 0),a.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,o,"f")}unset(){d(this,s,0,"f"),d(this,n,void 0,"f"),d(this,o,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,a,"f").push(e)}prior(){return this.isStale()?void 0:c(this,o,"f")}lastValue(){return c(this,o,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,n,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,n,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,n,"f")?void 0:Date.now()-c(this,n,"f")}elapsedMs(){return c(this,o,"f")?.settledMs??c(this,o,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,a,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,a,"f"))e.onError(t)}finally{d(this,s,(i=c(this,s,"f"),++i),"f")}},u=function(e){d(this,n,Date.now(),"f");const t=c(this,o,"f");return d(this,o,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,o,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,o,"f")),c(this,o,"f")}},1728:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),n=i(80049);t.memoizeAsync=function(e,t){let i=0;const s=new n.FifoCacheAsync(t),o=t=>(i++,s.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return o.clear=e=>{if(null==e)return s.clear();{const t=(0,r.stringify)(e);return s.deleteIf((e=>t===e))}},o.size=()=>s.size,o.callCount=()=>i,o}},22781:function(e,t,i){var r,n,s,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),n.set(this,!1),s.set(this,!1)}_call(){return o(this,n,"f")?(a(this,s,!0,"f"),!0===this.undefinedIfBusy?void 0:o(this,r,"f")):(a(this,n,!0,"f"),a(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{a(this,n,!1,"f"),!0===this.runLaterIfBusy&&o(this,s,"f")&&(a(this,s,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return o(this,n,"f")}prior(){return o(this,r,"f")}async force(){return await o(this,r,"f"),this._call()}}r=new WeakMap,n=new WeakMap,s=new WeakMap},37461:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),n=i(76790),s=i(38639),o=i(42659),a=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),v=i(15674),w=i(42638);var S=i(20214);async function b(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:i,timeoutMs:n}){const s=[];for(const o of(0,r.compact)(await t))try{const e=await((0,l.gt0)(n)?(0,c.thenOrTimeoutError)(i(o),n):i(o));null!=e&&s.push([e,o])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:o,error:t})}return s}async function E({arr:e,f:t,name:i,maxConcurrent:n,timeoutMs:s,promises:o}){if(null==e)return[];const a=(0,r.compact)(await e);if((0,r.isEmpty)(a))return[];if((n=Math.round(n??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:i,timeoutMs:s});const u=o??(a.length<=n?w.PermissivePromises:new w.Promises(i,(()=>n))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,h=await u.enqueueAll(i,a.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,i){const r=[];for(const n of(0,p.batches)((0,f.toA)(await e),t)){const e=await b(n);r.push(...await b(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,a.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=E,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:n,promises:s}){return(await E({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:n,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:n,timeoutMs:s}){return(await E({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:n,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await E({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*o.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,n=null;try{r=await((0,h.isFunction)(e)?e():e)}catch(e){n=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(n??r)}catch{}if(null!=n)throw n;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,s.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const n=await t;return null!=n?i(r,n):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const n=await t(r);return null==n?i():n},t.thenMap2Or=async function(e,t,i,r){const n=await e;if(null==n)return r();const s=await t;if(null==s)return r();const o=await i(n,s);return null==o?r():o},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await E({name:e,arr:t,f:i});return(0,n.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(42659),a=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),v=i(25764),w=i(38836),S=i(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),n=(0,l.clamp)(10*o.secondMs,o.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),n);try{const n=await(0,c.tot)(t),s=Date.now()-r;return i?.(n,s),this.push(e,s),n}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,a.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/o.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function _(e,t,i){return P.instance().time(e,t,i)}function E(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,n.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const i=Date.now(),r=t();return E(e,Date.now()-i),r},t.pushTime=E,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>_(e,t)),i)}},42638:function(e,t,i){var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),v=i(54993),w=i(89788),S=i(82647),b=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){r.add(this),this.name=e,this.ee=new f.default.EventEmitter,n.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),o.set(this,[]),a.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,n,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,b.maxCpus)(),d(this,n,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,a,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,o,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,o,"f").map((e=>e.name)),pendingNames:d(this,a,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:i,serialId:n}){const s=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:n});return this.laterPop(),s}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,o,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,a,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,a,"f").length,e),i=this.runningSerialIds,n=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,o,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,a,"f").length}hasPending(){return d(this,a,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,a,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,a,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const n=new P.Deferred(e,{payload:i,serialId:r});return d(this,a,"f").push({d:n,l:t}),n},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,o,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,o,"f").push(e),e},t.maybeRun=function(e,t){const i=new _(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new _(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},4867:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),n=i(34546),s=i(41400),o=i(31586),a=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let a=!0;return Promise.race((0,r.compact)([(0,n.asPromise)(e).finally((()=>a=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>{if(a)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(a)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,n.asPromise)(e).finally((()=>l=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>a.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),n=i(42659),s=i(41400),o=i(32639),a=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,a.clamp)(10*m,l.ShortCommandTimeoutMs,(t??n.minuteMs)/5);await(0,s.delay)(r,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const n=r(i(1708)),s=i(45599),o=i(41400),a=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),v=i(50213),w=i(7282),S=i(88158),b=i(45969),P=i(43334),_=i(28874),E=i(3790);function M(e){return x().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const x=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,o.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const C=["HOME","LANG","USER"],T=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],D=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?C:T),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function k(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,_.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,a.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(n.default.env,(e=>M(e)||!(0,E.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=k,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:F({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let O=!1;function F({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const n=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...D(),...i?(0,g.childProcLocale)():{},...k(r),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(n);if((0,y.isLogged)("debug")&&!O){O=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(n).map((([e,t])=>[e,(0,E.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return n}t.childEnv=F},84777:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const n=r(i(31421)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),v=i(79089),w=i(45255),S=i(22911),b=i(4867),P=i(73614),_=i(70025),E=i(57159),M=i(36868),x=i(66184),C=i(45643),T=i(95402),D=i(9727),k=(0,o.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function O(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function F(e,t=30*u.secondMs){if(null==e)return!1;k().debug("endProcess()",O(e));const i=e.pid;if(null==i||i<=0)return k().warn("endProcess(): asked to end invalid pid",O(e)),!1;if(i===s.default.pid)return k().warn("endProcess(): asked to end MY pid",O(e)),!1;if(i===s.default.ppid)return k().warn("endProcess(): asked to end my parent pid",O(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();k().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,T.killPid)(i).catch((e=>{k().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,C.waitForPidExit)(i,t))return k().debug("endProcess(): exitted",O(e)),!0;{T.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");k().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,T.killPid)(i,!0).catch((e=>{k().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,C.waitForPidExit)(i,5e3)}function I(e,i,r,n=0){const o=new Date,a=[];return(0,v.niceable)(i,r)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(n,u.secondMs)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&F(e)}),n-250)),a.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,T.addPid)({pid:e.pid,cmd:i,timeoutMs:n,ppid:s.default.pid},o)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>a.forEach(clearTimeout))),e}function L(e,t,i,r){const s=(0,D.spawnOptions)(r);return(0,x.isLogged)("trace",k().context)?k().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:s}):k().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(n.default.execFile(e,t,s),e,t,i)}async function A(e,t,i){const r=i.quiet??!1,n=i.ignoreStderr??!1,s=i.ignoreExitCode??!1,o=L(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{o.disconnect?.()}catch{}return{result:"",pid:o.pid}}const u=o.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new S.Deferred(f);o.on("error",(e=>g.push(e))),o.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),o.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(o.stdin);const v=new d.Latch;null==o.stdout?v.resolve():(o.stdout.on("error",(e=>g.push(e))),o.stdout.on("data",(e=>m.push(e))),o.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==o.stderr||n?P.resolve():(o.stderr?.on("error",(e=>g.push(e))),o.stderr?.on("data",(e=>p.push(e))),o.stderr?.on("end",(()=>P.resolve()))),k().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),k().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt});const x=p.join("");(0,l.notBlank)(x)&&g.push(new Error(x)),!r&&(0,a.isNotEmpty)(g)&&k().warn(f+" resulted in errors:",g);const C=i.isIgnorableError??_.isIgnorableError,T=g.filter((e=>!0!==C(e)));if(T.length>0)throw 1===T.length?T[0]:new E.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:T});if(!s&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:x}}catch(e){throw k().error("stdoutResult_() failed",e),await(0,T.killPid)(o.pid,!0),e}}t.endProcess=F,t.ReniceAfterMs=(0,o.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,o.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const s=(0,D.spawnOptions)(r);return k().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(n.default.spawn(e,t,s),e,t,i)},t.execFile=L,t.stdoutResult_=A,t.stdout_=async function(e,t,i){const r=await A(e,t,i);return k().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},3790:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),n=i(41400),s=i(19851),o=i(28874);(0,n.later)((()=>o.Settings.sensitiveEnvRegExp.watchLater((()=>a.unset()))));const a=(0,s.lazy)((()=>{try{return new RegExp(o.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${o.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(o.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&a().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||o.Settings.license.includesEnvKey(e)}},34330:function(e,t,i){var r,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(54993),w=i(27395),S=i(25764),b=i(99331),P=i(42638),_=i(38835),E=i(8769),M=i(57159),x=i(66003),C=i(50213),T=i(45643),D=i(28874),k=i(84777);t.mkBasicWatchedChild=function(e){return new O({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,k.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class O{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,C.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),n.set(this,!1),this.onError=(e,t,i)=>{const s=new M.WrappedError(e,{cause:t}),o=!1!==s.ignorable;this.logger().log(o?"warn":"error","onError()",s),u(this,n,"f")||o||(this.lastError=s,(0,E.onError)(s),!0!==s.fatal?(i??this.opts.onError(e,s))&&(this.logger().warn("onError requested restart",{src:e,error:s}),u(this,r,"m",a).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:D.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:S.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,w.addEndable)(this.opts.endableRank,this),u(this,r,"m",a).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,n,"f")}async end(){return c(this,n,!0,"f"),u(this,r,"m",s).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",s).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,n,"f")}),!u(this,n,"f")&&!(0,b.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,D.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",s).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:D.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,n,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=O,n=new WeakMap,r=new WeakSet,s=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,n,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",o).call(this,e)},o=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,T.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,k.endProcess)(e,this.endTimeoutMs)},a=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,n,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",s).call(this),!this._stopped&&!u(this,n,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,E.onError)("Can't restart "+this.name+", failure rate is too high."+_.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,n,"f")}),this._stopped||u(this,n,"f")||(0,b.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,x.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,v.toS)(e).includes("Error: Cannot find module")&&(0,E.onError)("Failed to start "+this.name+_.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,n,"f")}),(0,b.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",a).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const o=s(i(53916)),a=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,a.toNativePath_)(e);const i=f.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),n=i.sibling(r);if(n.isSelfOrDescendantOf((0,l.examples)()))return o.join("$examples",n.posixPathFrom((0,l.examples)()));const s=(0,d.originalsDir)();if(n.isSelfOrDescendantOf(s))return o.join("$library",n.posixPathFrom(s));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?o.join("$library",n.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const s=i(6858),o=i(1708),a=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),h=i(43334),f=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return n(this,r,"f").push(...e),this}async parse(e=o.argv,t){let i=(0,m.addHelpFooter)(new s.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of n(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":a.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,o.exit)(0)})),i.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=i.opts();for(const e of n(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),n=i(31586),s=i(51926),o=i(17344),a=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,n.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,o.EditionName)()+" v"+a.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const r=i(38639),n=i(17181),s=i(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,r.mapBoolean)(e.color,(e=>{s.Settings.logColor.envValue=e,(0,n.setupLogFormatter)()}))}}},94361:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),n=i(40958),s=i(55835),o=i(31586),a=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,o.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,n.compactBlanks)([c("user id","PUID",(0,a.userids)()),c("group id","PGID",(0,a.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,s.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},76596:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),n=i(19851),s=i(22573),o=i(42659),a=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,n.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,a.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,a.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,o.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),n=i(31586),s=i(54557),o=i(91655),a=new s.FifoCache(512);function l(e){return(0,n.isNumber)(e)?e:(0,r.blank)(e)?void 0:a.getOrSet(e,(()=>(0,o.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,o.fmtFullDuration)((0,n.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),n=i(40958),s=i(22573),o=i(42659),a=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,a.isNumber)(e))return;if((0,a.isNumber)(e))return e;if((0,a.isDigits)(e))return(0,a.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,n.compact)(d.map((e=>function(e,t){const i=(0,a.toFloat)(e);if(null!=i){if((0,s.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*o.yearMs;case"weeks":case"week":case"w":return i*o.weekMs;case"days":case"day":case"d":return i*o.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*o.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*o.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*o.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,a.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:o.yearMs,s:"y"},{ms:o.weekMs,s:"w"},{ms:o.dayMs,s:"d"},{ms:o.hourMs,s:"h"},{ms:o.minuteMs,s:"m"},{ms:o.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,a.isNumber)(t))return;if(0===t)return"0";if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},84248:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},15056:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),n=i(7311);function s(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=s,t.pathToDb=function(e,t){return s(e,t).join(n.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const o=s(i(76760)),a=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),v=i(70698),w=i(64680),S=i(29882),b=i(45969),P=i(43334),_=i(28874),E=i(41692),M=i(32774),x=i(80612),C=i(32551),T=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function D(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+T(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,o.join)(i,".photostructure-cache"+T()),preexistingDir:i});return e}}function k(){if((0,b.isDocker)())return(0,a.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,o.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+T(),preexistingDir:M.DefaultDockerLibraryDir},...D()]);const e=(0,a.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),o.default.resolve((0,C.homeDir)(),"AppData","Local")]:P.isMac?[o.default.resolve((0,C.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,o.join)((0,C.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,o.join)(e,t),preexistingDir:e})));return i.push(...D()),i}t.tmpCacheDirs=D,t.tmpDirs=function(){return(0,x.filterDirs)({dirs:D(),desc:"tmp"})},t.cacheDirs=k,t.defaultCacheDir=(0,d.lazy)((()=>(0,x.firstDir)({dirs:k(),desc:"cache"})));const O=(0,d.lazy)((()=>{(0,E.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(F)}));function F(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{O();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=F},46292:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),n=i(45969),s=i(41692),o=i(32774),a=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,n.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,a.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:o.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:o.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,n.isDocker)()?c:(0,a.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),n=i(45969),s=i(32774);t.defaultLibraryDir=function(){return(0,n.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,n.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const n=r(i(76760)),s=i(40958),o=i(72993),a=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),n.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(n.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,a.env)().XDG_DATA_HOME,(0,a.env)().XDG_CONFIG_HOME,n.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:n.default.join(e,(0,o.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),n=i(96706),s=i(29882);t.envConfigDir=function(){const e=(0,n.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),n=i(40958),s=i(22573),o=i(66430);function a({dirs:e,desc:t}){for(const{dir:i,preexistingDir:a}of(0,n.compact)(e))if(!(0,s.blank)(i)){if((0,o.isReadWriteableDirectorySync)(i))return i;if((0,s.blank)(a)||(0,o.isReadWriteableDirectorySync)(a))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=a,t.filterDirs=function({dirs:e,desc:t}){return(0,n.compact)(e.map((e=>a({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),n=i(76760),s=i(1708),o=i(19851),a=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,o.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,a.compactBlanks)(e)){const e=(0,n.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),n=i(49776),s=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[s.libraryDataDir,s.libraryPreviewsDir,n.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},9595:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),n=i(54993),s=i(29882),o=i(28874);function a(e){return(0,r.toNotBlank)((0,n.toS)(e))??o.Settings.libraryDir.valueOrDefault}t.libraryDir=a,t.originalsDir=function(e){return(0,s.resolveMaybe)(a(e),o.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,s.resolveMaybe)(a(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,s.resolveMaybe)(a(e),o.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),n=i(55835),s=i(37805),o=i(15056),a=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${s.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function v(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+a.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function w(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function S(e){return y(w(e),!1)}function b(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(b(e))}function _(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function E(e){return y(_(e))}async function M(e){return y((0,n.map)(g(e),(e=>(0,o.pathToDbDir)(e,o.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await v(t);return(0,r.uniq)([t,i,await S(t),await P(t),await E(t),await M(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=v,t.libraryOriginalsDirPosixFile=w,t.setupLibraryOriginalsDir_=S,t.libraryPreviewsDirPosixFile=b,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=_,t.setupLibrarySyncReportsDir_=E,t.setupLibraryDbDir_=M},46296:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const n=r(i(76760)),s=i(19851),o=i(40958),a=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),v=i(80612),w=i(32551);function S(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:n.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,o.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>n.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,a.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,a.notBlank)(i)?i:b()}catch(e){return console.error("defaultLogDir_() failed",e),n.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(44198),a=i(43334),l=i(24399),u=i(32551);async function c(){return a.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,n.lazy)((async()=>{if(a.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,n.lazy)((()=>(0,o.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),n=i(7282),s=i(29325),o=i(44198);t.getDevEnvFlag=function(e){return!(0,n.isProd)()&&!(0,s.isPacked)()&&((0,r.toBoolean)((0,o.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,o.env)()[e]=String(t)}},34580:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),n=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,n.env)().DO_NOT_TRACK)}},44198:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const n=r(i(73024)),s=i(76760),o=r(i(1708)),a=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),v=i(6012),w=i(96706);t.env=(0,a.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>o.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===o.default.env.PS_LICENSE||e.push((0,s.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),i={...o.default.env};for(const r of e)try{const e=(0,d.debom)(n.default.readFileSync((0,p.resolve)(r))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(s))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),n=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let s;for(const o of(0,n.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(o));){if(null==s.groups)continue;const{key:e,val:n}=s.groups;if((0,r.blank)(e)||null==n)continue;const o=n.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=o}}return i}},96706:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const n=r(i(1708)),s=i(19851),o=i(22573),a=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,o.firstNotBlank)(n.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,n.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,a.isTrue)(g(e))}},98314:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),n=i(19851),s=i(40958),o=i(22573),a=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),v=i(70025),w=i(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(a.errorName),...e.map(a.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(a.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(i)))}function b(e){return(0,s.compact)(e).filter((e=>!a.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(o.notBlank)}function P(e,t){const i=(0,s.uniqSubstrings)(b(e)),r=t?.maxLen??400,n=t?.trailingChars??64,o=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(i.join(a.ErrorDelimiter)),r-o.length,n)+o.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,o.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,n.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,o.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,o.notBlank)(i))return i}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,o.blank)(e)&&(e=t.MissingError),_(e,{maxLen:i})+" at "+(0,a.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),n=i(26905),s=i(55835),o=i(54993),a=i(81168);t.describeError=function(e){const t=(0,a.stripSuffix)((0,o.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,s.map)((0,n.errorErrno)(i),(e=>t.push(u.get(e)))),(0,s.map)((0,n.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),n=i(76790),s=i(50989),o=i(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,n.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(o.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),n=i(38639),s=i(26905),o=i(54993),a=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,o.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,o.toS)(e)+(0,r.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,a.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,n.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,n.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,n.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},8769:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),n=i(31586),s=i(68708),o=i(7282),a=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const n=!0===i.fatal,c=!0===i.ignorable;if(!n&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),n&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!n||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!n||(0,o.isTest)()||(0,a.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),n}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,n.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,a.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,n.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,n.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),n=i(22573),s=i(38639),o=i(26905),a=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,n.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,n.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,o.errorName)(t)??(0,d.first)(this.causes,o.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(o.errorCode)],o.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,o.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,n.blank)(r)||(i=(0,h.dedupeNeedle)(i,r,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,a.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const o=i(49769),a=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),n.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,o.getOrSet)(s(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),o=s(this,r,"f").get(e);return null!=o&&(o.resolve(t),s(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,n=new WeakMap},34102:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),n=i(19851),s=i(15197);t.ee=(0,n.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const n=r(i(73024)),s=r(i(1708)),o=i(19851),a=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,o.lazy)((()=>s.default.geteuid?.())),h=(0,o.lazy)((()=>s.default.getgroups?.()));function f(e,t){try{return!(0,a.blank)(e)&&(n.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,n.default.constants.R_OK|n.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,n.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:n,processGid:s}){if(null==e)return!1;const o=n??d(),a=null!=s?[s]:h()??[],l=0===o,u=l||e.uid===o,f=l||a.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const n=r(i(76760)),s=i(19851),o=i(81168),a=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,o.equalsIgnoreCase)(e.basename,i.base))return n.default.join(r,e.basename);throw new a.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),n=i(76760);function s(e){return[...o(e)]}function*o(e){for(;e!==(0,n.dirname)(e);)e=(0,n.dirname)(e),yield e}function a(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=a(e);return t.every((e=>i.includes(e)))}t.ancestors=s,t.ancestorG=o,t.selfAndAncestorG=function*(e){yield e,yield*o(e)},t.childrenSync=a,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,i){var r,n,s,o,a,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),v=f(i(1708)),w=i(46466),S=f(i(57975)),b=f(i(38522)),P=i(19851),_=i(40958),E=i(5233),M=i(22573),x=i(42659),C=i(50357),T=i(96249),D=i(98553),k=i(55835),O=i(31586),F=i(68708),I=i(97790),L=i(39926),A=i(51926),N=i(59455),R=i(54993),j=i(48884),V=i(22911),B=i(99331),z=i(56519),W=i(56038),U=i(31562),q=i(76850),H=i(70025),G=i(34102),J=i(80875),$=i(50213),K=i(70417),Y=i(43334),Z=i(81168),X=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),ne=i(89968),se=i(20197),oe=i(88561),ae=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),ve=i(27794),we=i(73428),Se=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new oe.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,$.mkLogger)("fs.BaseFile("+this.nativePath+")"))),n.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),o.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(n=new WeakMap,o=new WeakMap,r=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,j.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,R.toS)(e);if((0,M.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=be().get(i);if(null!=r)return r;const n=(0,fe.resolve)(i),s=new Pe(n,t);return be().set(i,s),be().set(n,s),s}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,n,"f").unset(),h(this,o,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,z.thenMap)(this.stat(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,k.map)(this.statSync(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,n,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,z.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",s).call(this)??await d(e=this.clearThisAndParent(),r,"m",s).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,z.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,N.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,N.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,O.gt0)(t))return;const i=await d(this,n,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,C.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,k.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,R.toS)(e),(0,L.pad2)(t+1),(0,L.pad2)(i))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,T.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,z.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,z.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,z.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,z.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,x.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,z.thenMap)(this.statTimes(),j.max)}maxStatDate(){return(0,z.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,z.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,z.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,z.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,z.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,z.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,z.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,z.thenMap)(this.mtime(),(t=>(0,x.unixtime)(t)>=(0,x.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,z.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,z.thenMap)(this.mtime(),(t=>(0,x.unixtime)(t)>(0,x.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,z.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,k.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*x.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,ae.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,ae.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,J.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,J.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,q.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,z.thenMap)(this.zReadFile_(e),R.toS)))}readLines(e="warn"){return(0,z.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces),(0,F.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,E.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,B.ending)()?1:3,timeoutMs:0,retryDelay:x.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,r,"m",a).call(this,(0,Z.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,r,"m",a).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,r,"m",a).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,_.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new V.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,A.newlineRe)(),(r=>{const n=e.exec(r);null!=n&&(t.maybeResolve(n),i.close())})),t.promise}contemporary(e,t){return(0,z.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,O.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new V.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),_e)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,n)=>{try{const s=await e.f(r,(0,k.denull)(n));t(s)&&i.resolve(s)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,O.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,s=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,j.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,k.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},a=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*x.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},84542:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),n=i(96249),s=i(51926),o=i(54993),a=i(43334);function l(...e){return(0,n.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,o.toS)(e).split((0,s.newlineRe)()))))}t.Newline=a.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(o.toS).join("\n");return a.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),n=i(19851),s=i(50213),o=i(37805),a=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,n.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,a.mkdirp_)(i),await(0,d.writeTextfile_)((0,a.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+o.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const n=r(i(76760)),s=r(i(1708)),o=i(19851),a=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,o.lazy)((()=>[...(0,a.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,n.default.join(e,"System32"),n.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const a=s(i(44652)),l=o(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),v=i(14427),w=i(17217),S=i(16287),b=i(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class E{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new E(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},n=await a.stat(t);return new E(i,new P(r,n))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return E.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new E(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>E.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new E(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await a.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await a.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=E},20197:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const n=r(i(76760)),s=i(39926),o=i(29882),a=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,o.parseNativePath)(i.nativePath);if(await(0,o.mkdirp_)(r.dir),!i.requireNumber&&await(0,a.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=n.default.join(r.dir,`${r.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,a.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,o.parseNativePath)(i.nativePath);if((0,o.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=n.default.join(r.dir,`${r.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},88561:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const o=i(40958),a=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>s(this,r,"m",n).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,o.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,r=new WeakSet,n=async function(e){if((0,a.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),n=i(22573),s=i(45599),o=i(96249),a=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,s.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,n.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,o.flatten)((0,a.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),n=i(17217),s=i(16287),o=i(68284);async function a(e){return(0,r.pick)(await(0,s.stat_)((0,n.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=a,t.fileStats=async function(e){try{return await a(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,o.statSync)((0,n.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},73787:function(e,t,i){var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,n.set(this,[]),s.set(this,void 0),o.set(this,void 0),l(this,o,(0,f.fileStatsSync)(e),"f"),l(this,s,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",a).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,n,"f").push(e)}close(){u(this,s,"f").close()}}t.FileWatcher=m,n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,o,"f"),t)){l(this,o,t,"f");for(const t of u(this,n,"f"))t(e,this.nativePath)}}},73209:function(e,t,i){var r,n,s,o,a,l,u,c,d,h,f,m,p,g,y,v,w,S=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},b=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const _=i(58587),E=P(i(44652)),M=i(87997),x=i(40958),C=i(17586),T=i(42659),D=i(50357),k=i(75240),O=i(55835),F=i(31586),I=i(30976),L=i(13538),A=i(54993),N=i(7282),R=i(68852),j=i(23560),V=i(25764),B=i(38836),z=i(99331),W=i(22781),U=i(38835),q=i(55222),H=i(63870),G=i(69734),J=i(17217),$=new RegExp("-(?\\d+)"+(0,R.escapeRegExp)(G.PsLockExt)+"$");class K extends B.EndableWrapper{static newUid(e=process.pid){return b(this,n,Math.max(Date.now(),S(this,n,"f",s)+1),"f",s),(0,x.compactBlanks)([q.TokenRadix.encode(S(this,n,"f",s)),j.serviceName.prior(),(0,A.toS)(e)]).join("-")}static pidFromLockfile(e){return n.pidFromBasename((0,J.basename)(e))}static pidFromBasename(e){return(0,F.toInt)($.exec((0,A.toS)(e))?.groups?.pid)}static for(e){return S(this,n,"f",a).find((t=>t.opts.file===e.file))??new n(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>S(this,r,"m",w).call(this)),e.endableRank??V.EndableRanks.postdb,(0,H.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,b(t=n,n,(i=S(t,n,"f",o),++i),"f",o)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(S(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,G.fsLockFileBasename)(n.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await S(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,G.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+S(this,l,"f")),this.staleMs=(0,F.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),S(n,n,"f",a).push(this)}get acquired(){return S(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await S(this,r,"m",f).call(this,e)??S(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,C.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,D.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==S(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,N.isTest)()?10:T.secondMs);b(this,c,setInterval((()=>S(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=S(this,c,"f")&&(clearInterval(S(this,c,"f")),b(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(S(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),b(this,u,!1,"f"),(0,O.map)(S(this,d,"f"),(e=>(0,M.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,z.ending)()||this.ended?S(this,r,"m",v).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),b(this,d,setTimeout((()=>S(this,r,"m",v).call(this)),(0,F.toGt0)(this.staleMs)??T.secondMs),"f"),S(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(S(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,L.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,n=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,r=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,F.gt0)(this.staleMs)&&Date.now()>S(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await S(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){b(this,h,Date.now(),"f");const e=[],t=await S(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,F.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+T.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,G.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,N.isTest)())return this.release(),!1;n.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const s=i[0]===this.lockfile.base;if(s)b(this,u,!0,"f");else if(!0!==t?.vacuum){const t=n.pidFromBasename(i[0]);if((0,F.gt0)(t)&&!(0,_.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),S(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:s,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await S(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},v=async function(){await S(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},w=function(){(0,x.filterInPlace)(S(n,n,"f",a),(e=>S(e,l,"f")!==S(this,l,"f")))},s={value:0},K.internalErrors=0,o={value:0},a={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),n=i(51926),s=i(54993),o=i(17217);function a(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,n.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,n.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,s.toS)(e)))return;const i=(0,o.basename)(e);return a(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&a((0,o.basename)(e))}},4001:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),n=i(55835),s=i(31586),o=i(51926),a=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,r.toNotBlank)(e.name)??(0,a.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,s.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:f(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const n=(0,u.parsePosixPath)(i),s=h(n,{aggressive:!1});return[...t,s+n.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,o.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),r=(0,o.stripPrefix)(t.toLowerCase().normalize(),i);return(0,n.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,o.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,n.map)(m.exec(t),(e=>t=e[1].trim())),(0,n.map)(g.exec(t),(e=>t=e[1].trim())),t}},14977:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const n=r(i(44652)),s=r(i(73024)),o=i(46466),a=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,o.pipeline)(s.default.createReadStream(e,{autoClose:!0}),a.default.createGzip(),s.default.createWriteStream(t,{autoClose:!0})),await n.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const n=r(i(77598)),s=r(i(73024)),o=i(46466),a=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),v=i(16287),w=(0,a.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),S=(0,a.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=S().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),S().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await _(s.default.createReadStream(i)),stats:(0,u.pick)(await(0,v.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],i="sha512"){const r=n.default.createHash(i);return await(0,o.pipeline)([e,...t,r]),r.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return n.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),n=i(42659),s=i(55835),o=i(31586),a=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,a.stdout_)("chflags",["hidden",t],{timeoutMs:10*n.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,s.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,a.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*n.secondMs}),i=(0,o.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),n=i(54993),s=i(7282),o=i(43334),a=i(69375),l=/^\/dev(?:\/|$)/i,u=o.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=o.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=o.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=o.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,n.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,a.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},33456:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),n=i(51926),s=i(54993);class o extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,s.toS)(e)).split((0,n.newlineRe)()),o=r.pop();this._prior=o??"";let a=!1;for(const e of r)a||(a=!this.push(e));a?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=o},64680:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const n=r(i(76760)),s=i(17217),o=i(73428);t.mkNoMedia_=function(e){return(0,o.writeTextfile_)(n.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},85772:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const o=s(i(76760)),a=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),v=i(83278),w=i(70698),S=i(88561),b=i(65238),P=i(16287),_=(0,a.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),E="NoMedia",M=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(o.default.sep),"/"]).join("")+"])\\.?"+E+"$","im"),x=Object.freeze(["."+E,E]),C=Object.freeze((0,u.flatten)(x.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function T(e){return null!=M.exec(e)}t.isNoMediaName=T;const D=(0,a.lazy)((()=>new S.FileCache({name:"fs.noMediaDirsCache"})));async function k(e,t){if(null==e)return null;const i=v.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return T(i.base)||await(0,w.isCachedirTagFile)(i)?D().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):k(i.parent());{const e=await D().getOrSetAsync(i.nativePath,(()=>O(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:k(i.parent())}}async function O(e){if(T(e.base))return D().set(e.parent().nativePath,e.nativePath),_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,b.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,r=await Promise.race([F(e.nativePath,i),(0,b.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,w.isCachedirTagDirectory)(e)?_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(w.CACHEDIR_TAG).nativePath)}):null}async function F(e,t){for(const i of g.isCaseSensitiveFs?C:x){if(!0===t?.aborted)return null;const r=o.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return _().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function I(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(T(r.basename))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,o.join)(e,r.basename))});if(r.basename===w.CACHEDIR_TAG){const t=(0,o.join)(e,r.basename);if(await(0,w.isCachedirTagFile)(t))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await k(e,t)},t.whyNoMedia=k,t.whyNoMediaDir=O,t._dirHasNoMediaChild=F},29882:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const n=r(i(44652)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),v=i(78133),w=i(53265),S=i(17217),b=i(16287),P=i(66430),_=i(5545);function E(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,o.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=E,t.containsHiddenPathname=function(e){return k(e).some(E)},t.isNotHiddenPosixPath=function(e){return k(e).every((e=>!E(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return x((0,v.posix2native)(e))},t.extname=function(e){return x(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function x(e){const t=M.exec(e)?.groups,i=t?.ext2??"",r=s.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function C(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,s.default.sep)}function T(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),i=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,s.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function D(e,t,i){if(null==t||null==i)return!1;const r=e(t),n=e(i);return null!=r&&null!=n&&(y.isLinux?r===n:(0,p.equalsIgnoreCase)(r,n))}function k(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function O(e){return(0,u.notBlank)(e)&&k(e).length===(y.isWin?1:0)}function F({p:e,maxLength:t}){const i=(0,S.toNativePath_)(e);if(i.length<=t)return i;const r=k(e),n=[],s=[r.pop()];for(;r.length>0;)if(n.length=t){r.unshift(n.pop());break}}else if(s.unshift(r.pop()),L([...n,...s]).length>=t){r.push(s.shift());break}return r.length>0&&n.push("…"),L([...n,...s])}function I(e){return e.startsWith("\\\\")}function L(e){return(0,h.ensurePrefix)((0,a.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=x,t.parentBasename=C,t.grandParentBasename=function(e){return C(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=T,t.eqlBasename=function(e,t){return D(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return D(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return D(S.toNativePath_,e,t)},t.toPathnames=k,t.pathIsRoot=O,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:k(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,S.toNativePath_)(e),r=(0,S.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,v.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=F,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const n=[];for(const r of e.slice(0,i))n.push(F({p:r,maxLength:t}));return n.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return k(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return k(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=x(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(O(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await n.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;n.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>n.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=L,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:L(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>T({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const n=r(i(76760)),s=i(19851),o=i(40958),a=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),v=i(64660),w=i(21144),S=i(16287),b=(0,s.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const i=await(0,S.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,v.isStatRX)(i,e)}function E(){if(y.isWin){const e=(0,a.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,a.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,a.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,n.default.join(e,"System32"),n.default.join(e,"System32","Wbem"),n.default.join(i,"chocolatey","bin"),n.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(n.default.delimiter);return(0,o.uniq)((0,o.compactBlanks)([...e,...E()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,o.uniq)((0,o.compactBlanks)([...M(),...(0,d.toA)(i)]));for(const i of(0,o.uniq)((0,o.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=n.default.join(t,e);if(await _(i))return y.isLinux?i:(0,w.actualPath)(i)}}b().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){var r,n,s,o=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&o(t,e,i);return a(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),v=i(76790),w=i(5233),S=i(22573),b=i(42659),P=i(26905),_=i(75240),E=i(55835),M=i(31586),x=i(68708),C=i(13538),T=i(89937),D=i(12168),k=i(54993),O=i(48884),F=i(50213),I=i(45255),L=i(81168),A=i(56519),N=i(56038),R=i(31562),j=i(84777),V=i(9595),B=i(38835),z=i(70025),W=i(57902),U=i(55222),q=i(43334),H=i(33847),G=i(24399),J=i(28874),$=i(79915),K=i(45200),Y=i(34238),Z=i(87001),X=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),ne=i(73209),se=i(48313),oe=i(29882),ae=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,O.contextFilter)(function(e){return(0,v.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,F.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Y.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,A.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,A.thenMapOr)((0,X.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,$.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>q.isMac?(0,j.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,S.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,S.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,L.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,ae.toNativePath_)(e),r=new fe(i,t);return(0,L.isString)(e)&&he().set(e,r),he().set(i,r),r}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,A.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,oe.containedByNativePath)({ancestor:(0,V.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,oe.containedByNativePath)({ancestor:(0,V.originalsDir)(),descendant:this,acceptSelf:!0}))return q.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,E.map)((0,ee.bestMountpoint)(this.nativePath,await(0,X.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,E.map)((0,S.notBlankOr)(e,(()=>this.uri_())),Y.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,k.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===T.PS_LIBRARY_SCHEME?1:t.scheme===T.PS_LOCAL_FILE_SCHEME?2:t.scheme===T.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,L.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(q.isWin||q.isMac)return this.trap("hide",(async()=>(await(0,se.hide_)(this),this)))}async hidden(){return(0,se.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,L.equalsIgnoreCase)(e.ext,(0,$.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,$.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,O.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,E.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,x.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:n,skipWip:s=!1,skipFsLock:o=!1,retries:a=2,dirty:l=!1}){return(0,w.retryOnReject_)((async()=>{const a=await this.clear().isNonEmptyFile(i);if(!a){if(s&&o)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:o,minSizeBytes:i,timeoutMs:n,dirty:l})}return a&&r?void 0:this.utimes()}),{maxRetries:a,timeoutMs:2*n,retryDelay:3*b.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,M.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:n,dirty:s=!1}){return await this.parent().mkdirp_(),(0,ne.withLock_)({file:this,skipFsLock:r,timeoutMs:n,dirty:s},(async()=>{const r=this.wip();try{await r.unlink("trace");const s=await(0,C.thenOrTimeoutError)(e(r),n);if(s===t.NoOp)return s;if(await(0,R.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),s;throw new Error(this+"applyWip(): still empty after waiting "+(0,_.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,N.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==J.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",n).call(this,t)}catch(e){if(!0===(0,z.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",s).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();J.Settings.verifyFileCopies.valueOrDefault&&(await(0,R.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:b.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,M.clamp)(I.ShortCommandTimeoutMs,10*b.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,S.notBlank)(this.ext)&&(0,S.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,b.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,E.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,A.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,L.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,oe.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,oe.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,Z.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,r=new WeakSet,n=async function(e){let t,i=e;const r=e.wip();try{const n=await this.stat_();if(null==n)return this.pflog().throw("Can't copy missing files"+B.NonRetriableErrorFlag);if(n.size>0){if(J.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+B.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,r.nativePath,h.default.constants.COPYFILE_FICLONE),n.size>5*D.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},n.size,(()=>r.size({refresh:!0})))),!await(0,R.untilTrue)((async()=>(0,M.approximates)(n.size,await r.size({refresh:!0}))),{intervalMs:b.secondMs,timeoutMs:b.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:n.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:n.birthtimeMs,mtimeMs:n.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,n.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${n.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,E.map)(t,(e=>e.end()))}},s=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),n=r?.size;return null==r||null==n?this.pflog().throw("Can't copy missing files"):(n>5*D.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},n,(()=>e.clear().size()))),q.isWin?await G.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,G.pwshQuote)(this.nativePath)} -Destination ${(0,G.pwshQuote)(i.nativePath)}`,(e=>e)):q.isMac?await(0,j.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,j.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+B.DoNotSendErrorFlag,{error:t})}finally{(0,E.map)(t,(e=>e.end()))}}},78133:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const n=r(i(76760)),s=i(22573),o=i(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(n.default.sep===n.default.posix.sep)return e;const i=(0,s.notBlank)(t)?n.default.sep+n.default.sep+t+n.default.sep:"",r=e.split(n.default.posix.sep);return(0,o.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(n.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||n.default.sep===n.default.posix.sep||n.default.posix.sep===n.default.sep?e:e.split(n.default.sep).join(n.default.posix.sep)}},43899:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const n=r(i(76760)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,o.lazy)((()=>n.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,o.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(n.default.join((0,p.execDir)(),"resources"),n.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,a.compactBlanks)([(0,p.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const r=n.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),n=i(19851),s=i(31586),o=i(50213),a=i(57902),l=i(69428),u=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=a.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),n=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let s=-1;try{const n=i??(await(0,r.stat)(e)).size-t,o=Buffer.alloc(n);return s=await(0,r.open)(e,"r"),await(0,r.read)(s,o,0,n,t)}finally{(0,n.mapGte0)(s,r.close)}}},69428:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const o=s(i(73024));t.readFileSync=function(e){try{return o.readFileSync(e)}catch{}}},55690:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),n=i(84542);t.readLines_=async function(e){return(0,n.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class n extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=n},65238:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const n=r(i(51455)),s=i(76760),o=i(19851),a=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),v=i(28874),w=i(63870),S=i(88561),b=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,o.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,o.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await n.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const E=(0,o.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||E.prior()?.delete(e)}async function x(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await E().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,b.statTimeoutMs)(),r=C(e),n=await(0,h.thenOrTimeout)(r,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(n===f.Timeout&&(0,g.onTimeout)({soft:!1}),n!==f.Timeout&&n.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),E.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,o.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!E().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=E().get(e)},t.childDirectories_=async function(e){return(await x(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?x(e):C(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=x,t.readdirCached=function(e){return E().get(e)},t.readdirUncached_=C},53265:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const n=i(73024),s=r(i(76760)),o=i(40958),a=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,o.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=s.default.resolve(t,...e);if((0,n.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,a.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(a.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},50274:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),n=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,n.isBoolean)(e.isFile)&&(0,n.isBoolean)(e.isDirectory)}},17217:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const n=r(i(73024)),s=r(i(76760)),o=i(22573),a=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,o.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,o.blank)(e.nativePath))throw new Error(`toNativePath(${(0,a.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof n.default.Dirent?e.name:f(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:s.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(s.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,a.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(n.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,a.blank)(e)?void 0:v(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=S(e),r=S(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],n=t[i],s=(0,u.diff)(b(r),b(n));if(null==s||s>1)return"unmatched "+i+": "+r+" ≠ "+n}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const i=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await w(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,o.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const n=r(i(73024)),s=i(22573);function o(e){try{return(0,s.blank)(e)?void 0:n.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function a(e){return null==e||e.isFile()&&0===e.size}t.statSync=o,t.isEmptyStats=a,t.isFileSync=function(e,t=0){const i=o(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=o(e);return t.emptyIsNew?null==i:a(i)},t.isNonEmptyFileSync=function(e,t=0){const i=o(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===o(e)?.isDirectory()}},41080:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),n=i(56409);t.onDataChunked=function(e,t,i){const r=new s(t,i,!0);return r.read(e),r.done};class s{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new n.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const n=r(i(57075)),s=i(41400),o=i(55835),a=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends n.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,a.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,o.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends n.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const n=r(i(73024)),s=i(76760),o=i(22573),a=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,o.blank)(e))return!1;try{return n.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,a.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,o.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,o.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,o.blank)(e)&&d((0,u.posix2native)(e))}},27794:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const n=r(i(44652)),s=i(19851),o=i(22573),a=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,a.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,o.blank)(t.file))throw new Error("can't touch blank path");const r=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const a=(0,s.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await a())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await a())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(n.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!i||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(n.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},5545:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const n=r(i(76760)),s=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,s.toS)(i.path??n.default.sep)}},70257:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),n=i(45255),s=i(17217);t.WipTimeoutMs=n.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const o=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(o,"")},t.isWip=function(e){return o.test((0,s.basename)(e)??"")}},58722:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),n=i(22911);class s extends r.Writable{constructor(e){super(e),this.deferred=new n.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=s},73428:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const n=r(i(44652)),s=r(i(76760)),o=i(51926),a=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=s.default.dirname(e);await(0,c.mkdirp_)(i),await n.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=s.default.dirname(e);(0,c.mkdirpSync_)(i),n.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,o.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))}},13047:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const n=r(i(73024)),s=i(76760),o=i(46466),a=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,i){const r=[],s=[n.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,a.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,a.createBrotliDecompress)().on("error",(e=>r.push(e)))),s.push(t),await(0,o.pipeline)(s),(0,u.isNotEmpty)(r))throw new f.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function b(e,t){const i=new y.WritableToBuffer;return await S(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function _(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,o.pipeline)(new g.ReadableBuffer(i),(0,a.createGzip)(),n.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void v().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await _(e,t)}catch(t){v().log(i,"outputJsonGz("+e+"): failed",t)}}},33866:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},52086:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},13940:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),n=i(19851),s=i(42659),o=i(59455),a=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),v=i(55222),w=i(63870),S=(0,n.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,n.lazy)((()=>(b(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const b=(0,n.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const n=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const s=n.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await s.mkdirp_(),await s.utimes();const o=s.join(i+r);return S().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:o}),o}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,o.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+v.TokenRadix.randomChars(2),v.TokenRadix.randomChars(16)+(0,a.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*s.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const n=await P(e,t,i);return await n.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,w.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),n}catch(r){return S().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},48584:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},49794:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),n=i(19851),s=i(40958),o=i(22573),a=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,n.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,o.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,s.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),n=i(23560),s=i(66184),o=i(72210);class a{log(e,t,i,r){this.enabled(e,t)&&(0,o.pushLogEntries)({ts:Date.now(),l:e,from:(0,n.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=a,a.instance=(0,r.lazy)((()=>new a))},14593:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),n=i(22573),s=i(26905),o=i(55835),a=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,n.toNotBlank)(e)??(0,s.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,a.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),n=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:n}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,o.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,a.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),n=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof n.LogWriter))}},28981:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),n=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new n.PlaintextLogFormatter))},31256:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(41400),a=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,s.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,o.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,n.uniq)((0,n.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,a.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,a.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const s=i(77030),o=i(19851),a=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),v=i(31256),w=i(28538),S=(0,o.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),b=String.fromCharCode(0);t.logBroadcaster=(0,o.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,a.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&S().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,s.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{S().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){S().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),n(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,s){if(this.enabled(e,t))try{const o=this.socket;null==o?n(this,r,"f").call(this):o.write(this.logFormatter.format(e,t,i,s)+b)}catch(r){S().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:s,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),n=i(42659),s=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??s.Settings.logDir.valueOrDefault,(0,n.fmtIsoDate)(t??new Date))}},4904:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),n=i(31586),s=i(51926),o=i(57902);t.isLogEntry=function(e){return null!=e&&(0,n.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&o.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),n=i(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,n.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,n.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new s(n.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>n.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,n.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,n.set(this,[]),s.set(this,(0,l.lazy)((()=>{a(this,n,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:a(this,n,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>a(this,s,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=a(this,r,"m",o).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=a(this,r,"m",o).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},n=new WeakMap,s=new WeakMap,r=new WeakSet,o=function(e){if(null==e||0===a(this,n,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return a(this,n,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),n=i(31586),s=i(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const o=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??o},t.levelGte=function(e,i){return(0,n.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const a=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return a.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),n=i(68708),s=i(20214),o=i(51926),a=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,o.isString)(i)||Buffer.isBuffer(i))return(0,o.ellipsize)(i.toString(),256,32);if((0,a.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,s.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const a=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,n.keys)(i),(0,n.keys)(a));return(0,r.isNotEmpty)(c)&&(a["…"]="omitted: "+(0,o.ellipsize)(c.join(", "),128,32)),a}return i}},89241:function(e,t,i){var r,n,s,o,a,l,u=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogReader=void 0;const d=i(73024),h=i(38522),f=i(4001),m=i(14977),p=i(33456),g=i(92322),y=i(4904),v=i(98192);t.LogReader=class{constructor(e,t){if(r.add(this),this.f=e,this.start=Date.now(),this.lines=new g.SortedSet(y.logEntrySorter),n.set(this,!1),s.set(this,!1),o.set(this,!1),this.from=(0,f.stripCopySuffixFromName)(e.name),this.fileStream=(0,d.createReadStream)(e.nativePath,{autoClose:!0}),!(0,m.isExtOrCompressedExt)(e.ext,".log"))throw new Error(e+" is not a logfile");this.stream=(e.ext.toLowerCase().endsWith(".gz")?this.fileStream.pipe((0,h.createGunzip)()):e.ext.toLowerCase().endsWith(".br")?this.fileStream.pipe((0,h.createBrotliDecompress)()):this.fileStream).pipe(new p.LineReader).on("error",(e=>{t(e),u(this,o,!0,"f")})),this.stream.on("data",c(this,r,"m",a).bind(this)),this.stream.on("close",(()=>{this.fileStream.resume(),u(this,n,!0,"f")})),this.stream.on("end",(()=>{u(this,n,!0,"f")}))}toString(){return"LogReader("+this.f.nativePath+")"}status(){return{hasErrors:c(this,o,"f"),ended:c(this,n,"f"),destroyed:this.stream.destroyed,lines:this.lines.length,paused:c(this,s,"f")}}hasErrors(){return c(this,o,"f")}get ended(){return c(this,n,"f")}ready(){return this.ended||this.lines.length>32}complete(){return this.ended&&0===this.lines.length}peek(){return this.ready()?this.lines.at(0):void 0}shift(){const e=this.lines.shift();return null!=e&&c(this,r,"m",l).call(this),e}shiftLte(e){const t=this.lines.shiftLte(e);return t.length>0&&c(this,r,"m",l).call(this),t}},n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(e){if(null===e)u(this,n,!0,"f");else{const t=(0,v.chunkToLogEntry)(e);null!=t&&this.lines.add({...t,from:this.from}),this.lines.length>10240&&!c(this,s,"f")&&(this.fileStream.pause(),u(this,s,!0,"f"))}},l=function(){this.lines.length<1024&&c(this,s,"f")&&(this.fileStream.resume(),u(this,s,!1,"f"))}},24068:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),n=i(76760),s=i(1708),o=i(87997),a=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),v=i(22277),w=i(25764),S=i(38836),b=i(99331),P=i(42638),_=i(76596),E=i(98314),M=i(89968),x=i(29882),C=i(28874),T=i(28981),D=i(20839),k=i(21727),O=i(66184),F=i(57902),I=i(72210),L=i(98192);function A(e){const t=(0,T.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=A;class N extends S.EndableWrapper{constructor(e=void 0,t=A){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,a.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,C.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,x.mkdirp_)(e),this.root=await M.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=n.sep+(0,p.serviceName)()+"-"+s.pid+"-",s.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,o.setInterval)((()=>this.flush()),D.DefaultLogFlushMs/2),this.scanTimeout=(0,o.setInterval)((()=>this.scan()),u.minuteMs),s.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,b.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,O.ifLog)(F.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,n.join)(e,i))}))}catch(t){return void(0,O.ifLog)(F.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,E.errorToS)(t))))}}))}async scan(e=!1){if((0,b.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,_.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,b.ending)()||this.ended)return;const t=(0,k.datedLogDir)(this.root.nativePath);try{await(0,x.mkdirp_)(t),this.watchDir(t)}catch(e){(0,O.ifLog)(F.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,E.errorToS)(e))))}(0,b.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,o.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,o.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await M.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(r,i))return;await(0,f.thenMap)((0,L.readLogEntries)(e,{start:r,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,O.ifLog)(F.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,E.errorToS)(e))))}}))}}t.LogTail=N,N.instance=(0,a.lazy)((()=>(0,y.stdoutEnded)()?void 0:new N))},72210:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),n=i(82328),s=i(28981),o=i(20839),a=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(a.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,n.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*o.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),v=i(31586),w=i(409),S=i(23560),b=i(81168),P=i(78406),_=i(25764),E=i(20197),M=i(14977),x=i(36868),C=i(28874),T=i(32105),D=i(20839),k=i(21727),O=i(66184),F=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class L extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*D.DefaultLogFlushMs),rank:_.EndableRanks.logger,unref:!0,onEnd:()=>c(this,n,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,n.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:T.ConsoleLogger.instance(),flushEveryMs:D.DefaultLogFlushMs,processName:S.processName,logFilter:O.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",s).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const n={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(n.meta=(0,F.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(n)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=L,n=new WeakMap,r=new WeakSet,s=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),n=e.splice(0,i);this._linesSinceRotate+=n.length,t.write(n.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},o=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},a=function(e){return t=>(c(this,r,"m",o).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,b.stripAnsiEsc)(this.logOpts.processName()),t=await(0,E.ensureNewNativePath_)({nativePath:(0,f.join)((0,k.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,r,"m",a).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,x.endStream)(e.stream),C.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,M.gzip_)(e.nativePath))}catch(e){c(this,r,"m",o).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),n=i(40958),s=i(55835),o=i(68708),a=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,o.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,n.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),n=i(84542),s=i(4001),o=i(13047),a=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,a.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,s.stripCopySuffixFromName)(e.name),r=[],a=await(0,o.zcat)(e.nativePath,t);if(null!=a)for(const e of(0,n.splitLines)(a)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),n=i(76790),s=i(68708),o=i(89788),a=i(57902);t.SentLogLevels=(0,r.lazy)((()=>a.LogLevels.values.filter((e=>e!==a.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,s.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new o.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,s.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,s.values)(l()))e.push(...t.toA());return(0,n.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),n=i(41400),s=i(55835),o=i(37975),a=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),v=i(66184),w=i(28538),S=i(24068),b=i(43705),P=i(51879);function _(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),E();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new b.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,s.map)((0,y.logBroadcaster)(),(e=>i.push(e))),a.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&S.LogTail.instance()}function E(){const e=h.Settings.logColor.valueOrDefault;(0,o.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=_,t.setupLogFormatter=E,(0,n.later)((()=>{h.Settings.logStdout.watchLater(_),h.Settings.logDir.watchLater(_),h.Settings.tailLogs.watchLater(_),h.Settings.logColor.watchLater(E),h.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},75631:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Recent=void 0;const n=r(i(1708)),s=i(57075),o=i(40958),a=i(76790),l=i(42659),u=i(41400),c=i(96249),d=i(55835),h=i(31586),f=i(34666),m=i(5670),p=i(45608),g=i(56519),y=i(69554),v=i(38790),w=i(70488),S=i(83278),b=i(84542),P=i(89968),_=i(14977),E=i(33456),M=i(28981),x=i(4904),C=i(89241),T=i(98192),D=i(97352),k=i(28874),O=i(2858);let F;function I(e){n.default.stdout.write(e+b.Newline)}async function L(e){const t=S.BaseFile.for(e);if(await t.isFile())return[t.nativePath];if(await t.isDirectory()){const e=await t.descendants((e=>e.ext.startsWith(".log")));return e?.map((e=>e.nativePath))}}t.Recent={beforeParse:e=>e.option("--recent [duration]",'Automatically cat recent logs. The optional "duration" argument can either be a number, which will be interpreted in minutes, or an ISO 8601 duration string, like "1d" for 1 day, or "20m" for 20 minutes. Defaults to 1 day.'),afterParse:e=>{null!=e.recent&&(!0===e.recent?F=l.dayMs:(0,D.mapGt0)(e.recent,(e=>F=e*l.minuteMs))??(0,w.decodeDuration)(e.recent))}},async function(){const e=await new y.CLI(m.ServiceNames.logcat,"[FILE_OR_DIR...]","FILE_OR_DIR may be either a logfile or a directory that will be scanned for .log, .log.gz, and .log.bz files.").add(t.Recent,v.ColorArgs).parse();n.default.on("SIGINT",(()=>(0,p.exit)({reason:"SIGINT",status:0}))),n.default.on("SIGTERM",(()=>(0,p.exit)({reason:"SIGTERM",status:0})));const i=(0,o.uniq)((0,c.flatten)(await(0,g.mapAsync)({name:"parseArgs",arr:e.args,f:L})));if((0,h.gt0)(F)){const e=(0,_.matcherForExtOrCompressedExt)(".log");await(0,O.readSystemSettings)();const t=Date.now()-F;await S.BaseFile.for(k.Settings.logDir.valueOrDefault).visitDescendants((async r=>{const n=await r.maxStatMs();e(r.ext)&&await r.isFile()&&(0,f.gt)(n,t)&&i.push(r.nativePath)}))}const r=(0,M.DefaultLogFormatter)();if((0,o.isEmpty)(i))return(0,o.isNotEmpty)(e.args)&&(console.error(r.format("error","logcat","No valid logfiles were provided.")),e.help()),I(r.format("info","logcat","No log files provided: reading from stdin.")),I(r.format("warn","logcat","The output will not be sorted chronologically.")),void await s.promises.pipeline(n.default.stdin,new E.LineReader,new s.Transform({transform(e,t,i){(0,d.map)((0,T.chunkToLogEntry)(e),(e=>I(r.formatLogEntry({from:"",...e})))),i()}}));const l=await(0,g.thenCompact)(i.map((async e=>{const t=await P.DirectoryEntry.for(e);return null!=t&&(0,h.gt0)(t.size())?new C.LogReader(t,console.error):void 0})));function w(){let e;(0,o.filterInPlace)(l,(e=>!e.complete()));for(const t of l){if(!t.ready())return;const i=t.peek();null!=i?.ts&&(null==e||i.tse.f.nativePath))));l.length>0;)try{const e=w();if(null!=e)for(const t of e)I(r.formatLogEntry(t));else await(0,u.delay)(10,!1)}catch(e){console.error("caught error",e)}n.default.stdout.write(b.Newline,(()=>(0,p.exit)({reason:"",status:0})))}()},82647:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const o=i(57975),a=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,o.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,r,"m",n).call(this,-1)}get p29(){return s(this,r,"m",n).call(this,-.5)}get p38(){return s(this,r,"m",n).call(this,-.25)}get p69(){return s(this,r,"m",n).call(this,.5)}get p84(){return s(this,r,"m",n).call(this,1)}get p98(){return s(this,r,"m",n).call(this,2)}get p99(){return s(this,r,"m",n).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,a.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,a.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,a.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,n=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),n=i(55835),s=i(31586),o=i(30976),a=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,s.clamp)(0,i,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,n.map2)(e,t,((e,t)=>(0,r.sum)((0,a.zip)(u(e,i),u(t,i)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,o.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),n=this.clampValue(e);let s=0;for(let e=0;eo?(s+=1,i[t]=o):r[t]=o}return s}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let n=0;n(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;is?(t+=1,n.min=s):n.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},55222:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),n=i(22573),s=i(55835),o=i(32639),a=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,n.blank)(e))return;const t="-"===(e=(0,o.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),n=this.normalizeToken(t);return r.length>=i&&r===n}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},17921:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),n=i(65713);function s(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=s,t.safeUUID=function(){return(0,n.decuss)(s)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const a=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function v(e,t){let i=0,r=0;for(const n of e){if(null!=n){const e=t(n,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=v;class w{constructor(){r.set(this,0),n.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(o(this,n,null==s(this,n,"f")?e:s(this,n,"f")*s(this,r,"f")/(s(this,r,"f")+1)+e/(s(this,r,"f")+1),"f"),o(this,r,(t=s(this,r,"f"),++t),"f"))}get mean(){return s(this,n,"f")}}function S(e){const t=new w;for(const i of e)t.push(i);return t.mean}function b(e){const t=S(e);if(null==t)return;let i=0,r=0;for(const n of e)(0,u.isNumber)(n)&&(r++,i+=(n-t)*(n-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function _(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+o*(e-n)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=S(t);if(null!=i){const e=(t.length-1)/2,r=v(t,((t,r)=>(t-i)*(r-e))),n=v(t,(e=>(e-i)**2));return 0===n?0:r/n}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,a.isEmpty)(e)&&(0,a.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},49076:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const n=r(i(48161)),s=i(19851),o=i(22573),a=i(41400),l=i(81168),u=i(28874);t.hostname=(0,s.lazy)((()=>u.Settings.hostname.value??n.default.hostname())),(0,a.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,o.blank)(e)&&!(0,o.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??n.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},96128:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),n=i(19851),s=i(22573),o=i(42659),a=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),v=i(34102),w=i(26293),S=new RegExp("^"+w.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==S.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const b=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=b.exec(e)}function _(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=_,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,s.blank)(e)){if(null!=_(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void E().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs});const E=(0,n.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,a.later)((()=>(0,v.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=_(e)?r.promises.reverse(e):r.promises.resolve4(e),5*o.secondMs);if(t===c.Timeout)return E().info("nslookup("+e+"): timeout"),e;const i=t.find(s.notBlank);return null==i?(E().warn("No name found for "+e),e):i}catch(t){return E().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,s.blank)(e)&&!(0,s.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),n=i(42659),s=i(31586),o=i(97790),a=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*n.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*n.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,s.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,o.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,a.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*n.minuteMs})},45969:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),n=i(38639),s=i(19851),o=i(59958),a=i(43334);t.isDocker=(0,s.lazy)((()=>a.isLinux&&((0,n.toBoolean)(process.env[o.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),n=i(19851),s=i(54993);t.isPacked=(0,n.lazy)((()=>!(0,s.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},43334:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const n=r(i(48161)),s=r(i(1708)),o=i(22573),a=i(38639),l=i(59958),u=n.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,a.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,a.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,o.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===n.default.arch(),t.isArm=null!=/^arm\b/i.exec(n.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,o.notBlank)(s.default.env.APPIMAGE)||(0,o.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,o.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,a.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const n=r(i(73024)),s=i(19851),o=i(43334);function a(e="/proc/cpuinfo"){if(o.isWin||o.isMac)return!1;try{return null!=n.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=a,t.isRaspberryPi=(0,s.lazy)((()=>o.isLinux_arm&&a())),t.procDeviceModel=(0,s.lazy)((()=>{try{return o.isLinux?n.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},45643:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),n=i(59455),s=i(31562);t.existingPids=function(e){return(0,n.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(97790),w=i(59455),S=i(54993),b=i(54557),P=i(19851),_=i(50213),E=i(88158),M=i(409),x=i(78406),C=i(25764),T=i(99331),D=i(56519),k=i(46292),O=i(8769),F=i(83278),I=i(32144),L=i(29882),A=i(43334),N=i(24399),R=i(58261),j=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),V=10*p.secondMs;function B(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,L.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))j().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{j().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??A.isWin,r=await this.pidfiles(),n=await this.pids(r??[]);if((0,f.isEmpty)(n))return j().info("killOldProcs(): no pidfiles"),[];const s=[],o=[],a=await(0,R.pidInfos)(n);if(null!=a){for(const n of r){const r=await n.readJson();if(null==r){j().warn("killOldProcs(): failed to read pidfile "+n.base),await n.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){j().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+n.base,{json:r,pid:l}),await n.unlink("debug");continue}const u=a.find((e=>e.pid===l));if(null==u||!B(r,u)){j().debug("killOldProcs(): pid no longer present: unlinking "+n.base,{json:r,pidEntry:u}),await n.unlink("debug"),s.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(j().info("killOldProcs(): killing",{reason:d,json:r}),o.push(W(l,i,!1)),s.push({...r,...u}))}return o.length>0&&await Promise.allSettled(o),s}(0,O.onError)("Pids.killOldProcs(): failed to get process information")}}),o.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const o=e.pid;if(!(0,y.gt0)(o))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(o)?(i&&a(this,n,"f").delete(l),a(this,n,"f").getOrSet(l,(async()=>{const i=a(this,r,"m",s).call(this,e.pid),n=(0,v.opt)((0,E.Try)((()=>(0,L.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),o=t.getTime(),l={...e,cmd:n,startTime:o};return await i.writeJson_(l),j().debug("addPid() wrote "+i,l),i}))):(a(this,n,"f").delete(l),void j().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=a(this,r,"m",s).call(this,e);return(0,D.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{j().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==a(this,o,"f")||a(this,o,"f").ended)&&l(this,o,new x.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:C.EndableRanks.first}),"f"),a(this,o,"f")}cancelInterval(){a(this,o,"f")?.end(),l(this,o,void 0,"f")}}t.Pids=U,n=new WeakMap,o=new WeakMap,r=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,k.configDir)(),(e=>new U(F.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const n=i(31421),s=i(48161),o=r(i(1708)),a=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),v=i(84968),w=i(48963),S=i(56519),b=i(84777),P=i(8103),_=i(45879),E=i(43334),M=i(24399),x=i(45643),C=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function T(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function D(e){if(E.isLinux)return async function(e){const t=[];for(const i of e)t.push(z(await(0,_.readFileMaybe)("/proc/"+i+"/stat")));return C().tap({msg:"pidInfoProc",result:(0,a.compact)(t)})}(e);const t=(0,x.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,E.isWin?I:R)).filter((e=>T(e)&&t.includes(e.pid)));return C().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=T,t.pidInfo=async function(e){return(0,S.thenMap)(D([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,a.isEmpty)(e)?[]:(0,S.thenMap)((0,x.existingPids)(e),(t=>{const i=[o.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=D;const k="Get-Process",O="| Select-Object -Property Id,ProcessName,StartTime";function F(e){return(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).join(",")}async function I(e){if(M.PowerShell.instance().ended)return N(e);const t=[k,"-Id",F(e),"-ErrorAction SilentlyContinue",O].join(" ");return(0,S.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const L={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},A=["CommandLine","CreationDate","ProcessId"];async function N(e){const t=["process"];if((0,a.isNotEmpty)(e)){const i=(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",A.join(","));const i=await(0,b.stdoutResult_)((0,P.wmic)(),t,L),r=(0,d.onlyReqValued)((0,p.parseFixed)(A,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return r.find((e=>e.pid===o.default.pid))||r.push({pid:o.default.pid,start:new Date(v.StartTs),cmd:"node "+o.default.title}),r}async function R(e){return t=(await(0,b.stdoutResult_)("ps",["-p",F(e),"-wwwo","pid,lstart,command"],{...L,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=N;const j=(0,g.lazy)((()=>{try{if(E.isLinux)return(0,c.toGt0)((0,n.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){C().warn("clk_tck failed",{error:e})}return 100})),V=(0,g.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),B=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function z(e){const t=B.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,n=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(n)?{pid:i,cmd:r,start:new Date(V()+n/j()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),n=i(22573),s=i(31586),o=i(29882),a=i(97352);t.progressEvtToS=function(e){const t=(0,n.blank)(e.path)?null:(0,o.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,s.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,n.notBlank)(e.op)&&(0,a.within)(0,100,e.pct)}},41944:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),n=i(42659),s=i(31586),o=i(12089),a=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new a.TTLMap(15*n.secondMs))),t.recentDone=(0,r.lazy)((()=>new a.TTLMap(2*n.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,s.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,o.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),n=i(31586),s=i(409),o=i(78406),a=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends o.EndableInterval{constructor(e,t,i,n=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:n,rank:a.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=n,this.start=Date.now(),this.onInterval=(0,s.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,n.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,n.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},24399:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),n=i(19851),s=i(22573),o=i(42659),a=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),v=i(99331),w=i(56519),S=i(31562),b=i(84777),P=i(34102),_=i(43334),E=i(28874),M=i(63870),x="{ready}",C=" | ConvertTo-Json -Compress";function T(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=T,(0,a.later)((()=>(0,P.ee)().on("clearCache",(()=>D.instance.prior()?.clearMockResults()))));class D extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",E.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${x}"}`,...(0,s.mapNotBlankOr)(E.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:x,fail:"Error",exitCommand:"exit",maxProcs:E.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:o.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),E.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(E.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,C),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,n)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,n)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,C),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+T(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=D,D.instance=(0,n.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new D})),t.checkPowerShell_=async function(){const e=D.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),n=i(38639),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toBoolean})}}t.BooleanSetting=o},90536:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),n=i(31586),s=i(97790),o=i(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=a},75164:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(97790),o=i(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(r.notBlank).flatMap(n.toInt).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,n.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=a},10546:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),n=i(22573),s=i(45599),o=i(50213),a=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,s.defer)((()=>(0,o.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,a.trimQuotes)(e);return void((0,n.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,n.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),n=i(91655),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,n.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=o;class a extends s.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=a},9945:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toFloat})}}t.FloatSetting=o},74589:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toInt})}}t.IntegerSetting=o},4175:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),n=i(22573),s=i(38639),o=i(42659),a=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function v(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function w(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){_(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&v(),y("strictDeduping",e)&&w(),(y("optOut",e)||y("noNetwork",e))&&E()},t.handleDeprecatedSettings=async function(){if((0,s.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,n.blank)(m.Settings.assetPathnameFormat.value)&&(0,n.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*o.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=v,t.setStrictDeduping=w;const S=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],b={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function _(e){for(const t of S)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:b;for(const[e,i]of(0,a.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function E(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=_,t.disableExternalNetworkRequests=E},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),n=i(53265),s=i(87652);class o extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,n.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=o},23561:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:n.toFloat})}}t.OptionalFloatSetting=o},69005:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=o},87652:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class n extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=n},28283:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),n=i(83556);t.nameFromEnv=function(e){return(0,n.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,n.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const o=i(19851),a=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),v=i(40583),w=i(81168),S=i(44198),b=i(96706),P=i(34102),_=i(28283),E=i(81075),M=i(98778),x=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,o.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,r,"m",n).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?s(this,r,"m",n).call(this,e??t)+": "+i:null==this.fromEnv(e)?s(this,r,"m",n).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,a.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,a.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,a.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return E.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,S.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&b.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,S.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&b.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],x.WrapComments);function i(e,i){(0,a.isEmpty)(i)||t.push(...(0,w.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],x.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,w.wrap)(["",e+": "+r],x.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:x.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:x.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,n=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),n=i(76760),s=i(19851),o=i(40958),a=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),v=i(79840),w=i(7282),S=i(12801),b=i(4328),P=i(70488),_=i(84248),E=i(5531),M=i(99315),x=i(34365),C=i(34580),T=i(96706),D=i(50274),k=i(33866),O=i(52086),F=i(48584),I=i(45969),L=i(43334),A=i(24540),N=i(70379),R=i(71300),j=i(33209),V=i(48987),B=i(68268),z=i(61208),W=i(99023),U=i(30577),q=i(1485),H=i(19861),G=i(55111),J=i(30933),$=i(22859),K=i(71988),Y=i(38483),Z=i(90536),X=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),ne=i(9945),se=i(74589),oe=i(844),ae=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new ae.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>q.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:q.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>q.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>L.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!L.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>L.isMac?"100ms":L.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new ne.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:E.CheckpointTypes,defaultValue:E.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:x.SynchronousModes,defaultValue:x.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to apply a migration, vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 2 minutes should be very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"2m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:k.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>L.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,C.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,A.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,J.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:D.SidecarExts,defaultValue:D.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:$.AggregateTypes.intersection,strEnum:$.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new ne.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,J.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:O.CropStrategies.attention,strEnum:O.CropStrategies}),videoFrameAtSec:new ne.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,o.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(L.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>j.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:F.SharpFailOns.truncated,strEnum:F.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>V.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:oe.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new ne.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:N.DateTagFormats.ym,strEnum:N.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:B.KeywordReparentingStrategies.move,strEnum:B.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:z.NameTagFormats["as-is"],strEnum:z.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function Se(e){const i=((0,l.blank)(e)?"":e).split(n.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,o.uniq)(i).filter(l.notBlank).join(n.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,T.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,a.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),n=i(31586),s=i(7282),o=i(49776),a=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),v=i(15674),w=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{w.Settings.configDir.opts.defaultValue=a.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=o.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,n.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(22573),a=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),v=i(54993),w=i(50213),S=i(81168),b=i(83556),P=i(87290),_=i(98314),E=i(34102),M=i(83278),x=i(95696),C=i(60865),T=i(4175),D=i(83179),k=i(81075),O=i(28874),F=i(41692),I=i(84438),L=i(32707),A=i(6707),N=i(98778),R=i(55018),j=i(10357),V=(0,r.lazy)((()=>(0,w.mkLogger)("settings.SettingsIO")));function B(e){return(0,P.libraryDataDirPosixFile)(e)?.join(I.SettingsToml)}async function z(e=(0,L.systemSettingsFile)()){if(null!=e)return X(M.BaseFile.for(e))}async function W(){try{return(0,o.toNotBlank)((await(0,A.readTomlFile_)((0,L.systemSettingsFile)()))?.[O.Settings.libraryDir.name])}catch{return}}function U(e){return(0,A.readTomlFile_)(e).then((e=>e?.version),(()=>{}))}function q(){return U((0,L.systemSettingsFile)())}function H(e){return U(B(e))}function G(){t.libraryHasSettings.refresh()}function J(e){const t=B(e);return V().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:O.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}async function $(e,i){if(null==e)return void V().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),n=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...ie("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","This is the version of PhotoStructure that wrote this file--please don't edit the following line.")),r.push(...(0,N.stringifyToml)({version:(0,t.versionForSettings)()})),r.push("","");let n="";for(const e of i){const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==n&&(n=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,E.ee)().emitDebounced("settingsChanged")}(n,i),V().info("writeToml(): wrote settings",{dest:n,file:e,nonDefaults:(0,D.settingsToObj)(i),wip:r}),r){const t=await(0,A.readTomlFile_)(n),i=await(0,A.readTomlFile_)(e);(0,u.eql)(t,i)?(V().info("Equivalent contents",{dest:n,file:e,a:t,b:i}),await n.unlink()):(V().info("Archiving prior, different contents",{dest:n,file:e}),await e.renameYMDHMS_({subdir:"archive"}),await n.unwip_())}}async function K(e=(0,L.systemSettingsFile)()){const t=x.PosixFile.forMaybe(e);return null!=t&&await $(t,(0,O.persistedSystemSettings)()),t}function Y(e){return X(B(e))}async function Z(e){await(0,P.setupLibraryDataDir_)((0,o.firstNotBlank)(e,O.Settings.libraryDir.value));const i=B(e);return V().info("writeLibrarySettings()",{file:i}),null!=i&&(await $(i,(0,O.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function X(e){if(null==e)return[];const t=V().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await Q(e);return(0,n.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,_.errorToS)(e)),[]}}async function Q(e){const t=V().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,A.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const s=[],o=(0,n.compact)((0,p.entries)(r).map((([e,t])=>{if("version"===e)return;const i=(0,O.getSettingByNameOrKey)(e);if(null==i)s.push(`Failed to import "${e}"${(0,m.mapOr)((0,O.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;s.push(e)}})));return t.info("loaded",{settings:(0,D.settingsToObj)(o),warnings:(0,n.toNotEmpty)(s)}),await(0,T.handleDeprecatedSettings)(),(0,T.handleMetaSettings)(o),{settings:o,warnings:s}}t.librarySettingsFile=B,t.readSettings=(0,r.lazy)((async()=>{await z(),(0,t.libraryHasSettings)()&&await Y()}),a.minuteMs),t.readSystemSettings=z,t.envOrSavedLibraryDir=async function(){return O.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=q,t.librarySettingsVersion=H,t.maybeUpgradeSystemSettings=async function(){(0,t.versionForSettings)()!==await q()&&await K()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&(0,t.versionForSettings)()!==await H()&&await Z()},t.libraryHasSettings=(0,r.lazy)((()=>J())),t.libraryHasSettings.unset=()=>{V().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,E.ee)().on("clearCache",G),(0,E.ee)().on("settingsChanged",G),O.Settings.libraryDir.watchLater(G)})),t._libraryHasSettings=J,t.versionForSettings=(0,r.lazy)((()=>(0,C.baseVersion)())),t.writeSystemSettings_=K,t.writeAllSettings_=function(e){return $(x.PosixFile.for(e),(0,O.persistedSettings)())},t.readLibrarySettings=Y,t.writeLibrarySettings_=Z,t._readSettings=X,t.importFileSettings_=Q;const ee=(0,r.lazy)((()=>new Set([O.Settings.noNetwork,O.Settings.httpPort,O.Settings.license,O.Settings.logStdout,O.Settings.logLevel].map((e=>e.key)))));function te(){for(const e of(0,p.values)(O.Settings))ee().has(e.key)||e.unset();(0,E.ee)().emit("settingsChanged")}function ie(...e){return(0,d.flatten)(e.map((e=>(0,S.wrap)(e,j.WrapComments))))}t.clearLibraryDirSetting=async function(){await z(),O.Settings.libraryDir.unset(),await K()},t.clearSettings=te,t.nukeSettings=async function(){te(),await(x.PosixFile.forMaybe((0,L.systemSettingsFile)())?.unlink("trace")),await(x.PosixFile.forMaybe(B())?.unlink("trace")),(0,E.ee)().emit("clearCache"),F.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...ie("",`Welcome to PhotoStructure! These are the settings for version ${(0,C.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...ie("","The following settings categories are stored in the system settings.toml:","",...(0,s.sort)([...k.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,s.sort)([...k.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...ie("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...ie("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const s=`${e.key} or ${e.name}`,o={...e.addToJSON()};(0,n.mapNotEmpty)(e.altKeys,(e=>o.aliases=(0,h.orList)(e)));const a=(0,p.entries)(o).map((([e,t])=>`${(0,S.capitalize)((0,b.camel2snake)(e)).replace(/_+/g," ")}: ${(0,R.valueToS)(t)}`));(0,n.isNotEmpty)(a)&&a.push(""),i.push(...ie((0,g.padding)("-",s.length),s,(0,g.padding)("-",s.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...a,`${e.key}=${(0,f.stringify)((0,v.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),n=i(40958),s=i(22573),o=i(98553),a=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,o.stringify)(e)}t._join=c;function d(e){return(0,a.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,n.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,n.compactBlankish)(t.split(e));return[t]}}(e),n.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,n.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,n.isEmpty)(e)||(this.value=this.toValidValues((0,n.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,n.isEmpty)(this.values)}isNotEmpty(){return(0,n.isNotEmpty)(this.values)}toNotEmpty(){return(0,n.toNotEmpty)((0,n.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class n extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=n},72564:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),n=i(98553),s=i(55835),o=i(58305);class a extends o.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,n.stringify)((0,r.uniq)(e)))),fromEnv:t=>{return i=t,n=e.strEnum,(0,r.compact)((0,o.splitStringArray)(i)?.map((e=>n.getCI(e))));var i,n},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=a},80372:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),n=i(81168),s=i(83179);class o extends s.Setting{constructor(e){super({toEnv:a,fromEnv:a,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function a(e){return null==e?void 0:(0,n.trimQuotes)(e)}t.StringSetting=o},32707:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),n=i(55835),s=i(46292),o=i(84438);t.systemSettingsFile=function(){return(0,n.map)((0,s.configDir)(),(e=>(0,r.join)(e,o.SettingsToml)))}},80496:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),n=i(44652),s=i(22573),o=i(76850),a=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,o.debom)(e),(0,s.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,n.readFileSync)(t)):void 0}catch(e){return void(0,a.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>f(await(0,n.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,n.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),n=i(96249),s=i(98553),o=i(68708),a=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const n=e+" = "+(0,s.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[n]:(0,a.wrap)(n.split("\n"),i)}t.stringifyToml=function(e){return(0,n.flatten)((0,o.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,a.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},10357:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},65162:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),n=i(81168);t.bname=function(e,t=!0){let i=(0,n.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,n.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},70379:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},88840:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),n=i(40958),s=i(96249),o=i(23838),a=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,a.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,a.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,n.uniq)((0,s.flatten)((0,a.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,n.uniq)((0,s.flatten)((0,a.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new o.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,s.flatten)((0,a.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function v(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=v,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return v(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return v(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return v(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return v(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return v(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return v(i,t)?e.slice(0,-(i.length+1)):e}},68268:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},61208:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},79915:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),n=i(40958),s=i(22573),o=i(81168),a=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,o.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const a=(0,u.isJsonExt)(i.ext),l=a||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=a||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,n.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,n.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return a&&function(e,i){const r=(0,o.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function n(e){return(0,s.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const a=n(e.slice(r.length)),l=n(i.slice(r.length));return a&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,a.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,o.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},45200:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(96249),a=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),v=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function w(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function S(e){const t=await w(e);return(0,n.uniq)((0,o.flatten)(t.map(m.uriEncodingVariants)))}async function b(e,t){if((0,s.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void v().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case a.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case a.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case a.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,s.blank)(e)?v().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=w,t.nativePath2uriVariants=S,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(b(e,t),S))),(0,n.uniq)(i)},t.uri2nativePath=b,t.uriExists=async function(e,t){const i=await b(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),n=i(57975),s=i(90595),o=i(22573),a=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",v=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class w{static isUri(e){return e instanceof w||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,n,s=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,s),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=n??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,s))}get fsPath(){return M(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:n,fragment:s}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===n?n=this.query:null===n&&(n=g),void 0===s?s=this.fragment:null===s&&(s=g),t===this.scheme&&i===this.authority&&r===this.path&&n===this.query&&s===this.fragment?this:new b(t,i,r,n,s)}static parse(e,t=!1){const i=v.exec(e);if(!i)return new b(g,g,g,g,g);const r=i[2]||g,n=D(i[4]||g),s=(i[5]||g).split("/").map(D).join("/"),o="psfile"===r&&s.startsWith("//")?s.slice(1):s,a=(0,u.toURLSearchParams)(i[7]),l=D(i[9]||g);return new b(r,n,o,a,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new b("file",t,e,g,g)}static from(e){return new b(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?w.file(r.win32.join(M(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,a.map)(this.path,(e=>(0,d.findLast)(e.split(y),o.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return x(this,e)}toJSON(){return this}[n.inspect.custom](){return this.toString()}}t.URI=w;const S=h.isWinPortable?1:void 0;class b extends w{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=M(this,!1)),this._fsPath}toString(e=!1){return e?x(this,!0):(null==this._formatted&&(this._formatted=x(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=S),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,o.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function _(e,t){let i,r=-1;for(let n=0;n=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57||45===s||46===s||95===s||126===s||t&&47===s)-1!==r&&(i+=encodeURIComponent(e.substring(r,n)),r=-1),void 0!==i&&(i+=e.charAt(n));else{void 0===i&&(i=e.substr(0,n));const t=P[s];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,n)),r=-1),i+=t):-1===r&&(r=n)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function E(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function x(e,t){const i=t?E:_;let r="";const{scheme:n,query:s,fragment:a}=e;let{authority:l,path:u}=e;if(n&&(r+=n,r+=":"),(l||"file"===n)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,o.mapNotBlank)(s,(e=>r+="?"+e)),a&&(r+="#",r+=t?a:_(a,!1)),r}function C(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+C(e.substr(3)):e}}t.encodeURIComponentFast=_,t.uriToFsPath=M;const T=/(?:%[\dA-Z][\dA-Z])+/gi;function D(e){return e.startsWith("xn--")?(0,s.toUnicode)(e):e.match(T)?e.replace(T,(e=>C(e))):e}t.percentDecode=D,t.toURI=function(e){return w.isUri(e)?e:w.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),n=i(40958),s=i(50357),o=i(89937),a=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",o.PS_LOCAL_FILE_SCHEME,o.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,a.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&f(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,s.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,n.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),n=i(22573),s=i(51926),o=i(89937),a=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,n.blank)(e))return;if(null==(t=null!=t&&(0,a.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,n.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,s.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:o.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==o.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,n.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,s=(0,n.notBlank)(t)&&!t.includes(i);if(s&&!(0,n.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const a=await(0,c.bestVolumeForVolsha)(e.authority);return null!=a?f(a.mountpoint,e.path):s&&(0,n.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),n=i(22573),s=i(51926),o=i(89937),a=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:o.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,n.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,n.blank)(t))return;const i=(0,r.uniq)([t,(0,a.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,s.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:o.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==o.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,a.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,s.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const o=s(i(76760)),a=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,a.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,a.notBlank)(t.remoteHost)&&(0,a.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:o.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,a.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,a.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(o.sep)}`;const n=i.slice(1),s=await(0,p.volumes)();for(const t of(0,u.toA)(s))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return o.join(t.mountpoint,...n);return await(0,h.isReadableDirectory)(t)?o.join(t,...n):void 0}},85087:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),n=i(42659),s=i(9103),o=i(37628);t.volsha=(0,s.memoize)((e=>(0,r.mapNotBlank)(e,o.shortStringSha)),{maxSize:128,ttlMs:n.minuteMs})},60865:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),n=i(30577);t.channel=function(){return(0,n.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),n=i(22573),s=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function o(e){if(e instanceof r.SemVer)return e.version;const t=s.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=o,t.semverSatisfies=function(e,t){if((0,n.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const s=o(e);return null!=s&&(0,r.satisfies)(s,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},8540:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),n=i(9595),s=i(29882),o=i(43334),a=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([a.Settings.libraryDir.valueOrDefault,(0,n.originalsDir)(),...a.Settings.scanPaths.values]))if((!o.isPosix||!(0,s.pathIsRoot)(t))&&(0,s.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},1485:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),n=i(22573),s=i(59455),o=i(50213),a=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.DfPosix"))),v=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function w(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),n=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),s=t&&(i||r||n);return y().tap({msg:"acceptPosixVolume()",result:!s,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:n}})}t.acceptPosixVolume=w,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,s.toA)(await v());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,n.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,s.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,a.assignMissingPrimitives)(i,e))}return t.filter(w)}},69108:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,o.toInt)(e,{defaultValue:0})*a.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,n.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const n=m(e.Used)??0,s=m(e.Available)??0;if(0!==n||0!==s)return{filesystem:t,mountpoint:i,size:d.isMac?n+s:r,used:n,available:s};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:n,available:s})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,n.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,s.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const o=p(i);return!0===e&&o.forEach((e=>e.remote=!1)),o},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(22573),a=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),v=i(24399),w=i(28874),S=i(24541),b=i(60224),P=i(63870),_=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const E=/([a-z]+)(?::\\)?/i;function M(e){return e?.match(E)?.[1]?.toUpperCase()}function x(e){return(0,l.map)(M(e),(e=>e+":\\"))}function C(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(M(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function T(e){return null!=e&&!(0,o.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,o.notBlank)(e.DisplayRoot),...(0,l.map)((0,b.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function D(e){return`Get-Volume ${(0,f.toS)(M(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=x,t.getPsDriveCommand=C,t.getVolumeCommand=D,t.getLocalVolumesWin_=function(){return v.PowerShell.instance().executeJsonToA(D())};const k=/\{([-a-z\d]{7,})\}/i;function O(e,t){return e=e?.trim(),(0,o.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function F(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void _().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=x(e.DriveLetter);if(null==t)return void _().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,n.compact)([O(e.HealthStatus,"healthy"),O(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,o.notBlank)(e.DriveLetter)&&(0,o.blank)(i);return _().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(s=e.UniqueId,_().tap({msg:"uniqueId2uuid",result:(0,l.map)(k.exec((0,f.toS)(s)),(e=>e[1])),meta:{s}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var s}async function I(){const e=(0,n.uniq)((0,h.toA)(await(0,S.mountpointsWin)()).map(x)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(C(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,n.compact)((0,a.flatten)(t).map(T)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(D(e)).catch((t=>(_().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),o=(0,n.compact)((0,a.flatten)(r).map(F)),l=(0,n.uniq)([...i,...o].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,s.sort)((0,n.uniq)([...i,...o].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));_().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:o,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...o.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=F,t.volumeInfoWin=I},68884:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(42659),a=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),v=i(83278),w=i(8103),S=i(16287),b=i(45969),P=i(43334),_=i(69108),E=i(98770),M=i(44224),x=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,b.isDocker)()||(0,d.isBillingService)()||null==await(0,w.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,x.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const C=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?C().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,M.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),S.isReadableDirectory),(e=>e.map((e=>v.BaseFile.for(e).clear().childDirectories())))))}):C().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,n.isEmpty)(e)?[]:(C().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,x.mountpointsTtlMs)(),f:async e=>{const t=await(0,_.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void C().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await T(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,x.mountpointsTtlMs)()}))),(0,a.later)((()=>(0,E.setupVolumeTTL)(t.gioVolumes)));const T=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,x.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,s.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(s.notBlank).get()}}catch(t){return void C().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs})},98770:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),n=i(5233),s=i(41400),o=i(56038),a=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,o.time)("volumes."+e,(()=>(0,n.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,a.isRetriableError)(e)&&!1!==(0,a.isIgnorableError)(e)})))),i);return(0,s.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),v=i(98770),w=i(63870),S=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>S().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>S().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const s=(0,c.sortIgnoreCase)((0,n.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),o=[];for(const t of s){const n=e.find((e=>e.mountpoint===t)),s=i?.find((e=>e.mountpoint===t)),a={...n,...s},u=r?.find((e=>e.filesystem===a.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(a,u),null==a.size||null==a.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];S().info("backfilling mountpoint",{info:s,vol:n,df:e}),null!=e&&(0,l.assignMissingPrimitives)(a,e)}o.push(a)}return o};const b=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return b.exec(e)?.[1]?.split(".").map((e=>(0,o.toInt)(e)))})),_=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,o.gte)(t[0],2)&&(0,o.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,v.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await _()],{timeoutMs:(0,w.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,s.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,o.toInt)(e.fsused),r=(0,o.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return S().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,v.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,w.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,s.toNotBlank)(e.PARTLABEL)??(0,s.toNotBlank)(e.LABEL),uuid:(0,s.toNotBlank)(e.PARTUUID)??(0,s.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),n=i(19851),s=i(40958),o=i(22573),a=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),v=(0,n.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,s.uniq)(e.map((e=>e.filesystem?.match(w)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),n=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of n)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,o.blank)(t.MountPoint)||(0,a.isTrue)(t.OSInternal)?v().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){v().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const w=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(42659),a=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),v=i(84777),w=i(34330),S=i(8769),b=i(34102),P=i(17217),_=i(16287),E=i(43334),M=i(28874),x=i(8540),C=i(68884),T=i(44224),D=i(24541),k=i(69375),O=i(63870),F=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function L(e=(0,O.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function A(){I()}t.localMountpointSetup=(0,r.lazy)((async()=>{M.Settings.libraryDir.watchLater(I),M.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&M.Settings.scanAllDrives.valueOrDefault?(0,a.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(E.isMac&&(e.info("Setting up Mac diskutil activity watcher"),L((0,O.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),E.isLinux){const i=(0,T.maybeWatchProcMounts)();await(0,C.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),L((0,O.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await R()&&(e.info("Setting up Linux findmnt mount monitor"),L((0,O.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),o.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const N=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=M.Settings.mountpoints.values;if((0,n.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",E.isWin?D.mountpointsWin:T.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,n.isEmpty)(e))return F().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,s.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,O.commandTimeoutMs)(),f:async e=>!(!(0,x.mightBeAssetMountpoint)(e)&&(0,k.isExcludedMountpoint)(e)||M.Settings.validateMountpoints.valueOrDefault&&!await(0,_.isReadableDirectory)(e)&&(F().warn(`mountpoint ${e} is not readable`),1))}));return N.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,S.onError)("mountpoints() failed",{cause:e}),N()}})),t.isPosixMountpoint=async function(e){if(E.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return E.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,a.later)((()=>{(0,b.ee)().on("clearCache",(()=>{C.gioVolumes.unset(),I()})),M.Settings.mountpointsTtlMs.watch(L)}),(0,c.isTest)()?1:o.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>A(),minCallDelayMs:1.5*o.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:C.GioCommand,args:C.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(C.gioVolumes.unset(),A()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const R=(0,r.lazy)((async()=>{if(!E.isLinux)return!1;try{return 0===(await(0,v.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,O.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>A(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),n=i(40958),s=i(42659),o=i(48884),a=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),v=i(28874),w=i(69108),S=i(68884),b=i(59107),P=i(69375),_=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await C()??await(0,c.thenMap)((0,w.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,S.isGioSupported)())try{await(0,c.thenMap)((0,S.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){_().warn("Failed to fetch gio volumes",e)}return e};const E="/proc/mounts";function M(e){return!v.Settings.excludedFilesystemTypes.has(e)}function x(e){return!(0,P.isExcludedMountpoint)(e)&&(!v.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function C(e=E,t=M,i=x){if(y.isLinux)try{const r=await(0,f.readLines_)(e),s=(0,n.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,o.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),a=await(0,c.filterAsync)({name:"mountpoints filter",arr:s,f:async([e,r])=>{const n=t(e),s=await i(r);return _().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:n&&s,meta:{fs:e,mp:r,fsOK:n,mpOK:s}})}});return _().tap({msg:"readProcMounts()",result:a.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void _().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=M,t.readProcMounts=C,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(E)?new h.FileWatcher(E,{recursive:!1,persistent:!1},(()=>{_().info("detected change in "+E),(0,d.setUnrefTimeout)((()=>b.mountpoints.refresh()),s.secondMs)})):void 0))},24541:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),n=i(42659),s=i(13538),o=i(50213),a=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,s.thenOrTimeoutError)(f(),a.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*n.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),n=i(22573),s=i(50213),o=i(9103),a=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,n.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,a.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,a.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,a.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,a.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,n.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,o.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),n=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,s=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function o(e){if((0,r.blank)(e))return;const i=n.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(s,""),remoteShare:i.remoteShare};const o=t.nfsRe.exec(e);if(null!=o){const e=o[1],t=o[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=o(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=o},60224:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),n=i(22573),s=i(42659),o=i(55835),a=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),v=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await M()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,o.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const w=["LocalName","RemoteName","Status"],S=["NETUSE","get",w.join(",")],b=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function _(e){if(!(0,n.blank)(e))return(0,a.opt)(e).flatMap((e=>b.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,a.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,n.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,a.opt)(e.pathname).filter(n.notBlank).getOrElse((()=>"/"))}))))).get()}async function E(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,S,{timeoutMs:15*s.secondMs}),i=(0,u.parseFixed)(w,t);return(0,r.compact)(i.map((e=>(0,o.map)(b.exec((0,l.toS)(e.RemoteName)),(t=>(0,o.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=_,t._netInfoWinWmic=E;const M=(0,v.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?E():(0,r.compact)(e.filter((e=>(0,n.notBlank)(e.LocalName))).map((e=>(0,o.map)(_(e.RemoteName),(({host:t,share:i})=>(0,o.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,h.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),n=i(12168),s=i(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=n.MiB/r.secondMs},86848:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(38639),a=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),v=i(95696),w=i(45969),S=i(28874),b=i(59107),P=i(63870),_=i(68995),E=(0,n.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),M=(0,n.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function x(e){return(0,o.isTrue)(e.ignorable)||(0,w.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function C(e){if((0,s.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function T(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=C(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function D(e){if(S.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of S.Settings.volumeUuidFilePaths.values){const i=v.PosixFile.for(e.mountpoint).join(t),r=await T(i).catch((e=>E().info("Failed to read "+i,{error:e})));if(null!=r)return E().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,_.volumeUuidSubpath)());if("/"===e.mountpoint)return E().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(S.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return E().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(S.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,_.writeVolumeUuid)(e);if(!(0,s.blank)(t))return E().tap({msg:"readVolumeUUID(): wrote new "+(0,_.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return E().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,a.later)((()=>{(0,m.ee)().on("clearCache",(()=>M.clear())),b.mountpoints.watchLater((()=>M.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(x(e))return;if((0,o.isFalse)(e.ok))return;const t=await M().getOrSetAsync(e.mountpoint,(async()=>D(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>E().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=x,t.toVolumeUUID=C,t.readUuidFile_=T,t.readVolumeUUID=D},7014:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const n=r(i(48161)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),v=i(59455),w=i(48884),S=i(50213),b=i(7282),P=i(23560),_=i(28850),E=i(45255),M=i(81168),x=i(56519),C=i(4867),T=i(49776),D=i(9595),k=i(77740),O=i(44198),F=i(96706),I=i(8769),L=i(57159),A=(i(34102),i(21144)),N=i(73209),R=i(29882),j=i(95696),V=i(17217),B=i(16287),z=i(49076),W=i(96128),U=i(45969),q=i(43334),H=i(28874),G=i(85087),J=i(50424),$=i(48165),K=i(98770),Y=i(27461),Z=i(66840),X=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,o.lazy)((()=>(0,S.mkLogger)("volumes.Volumes"))),ne=n.default.platform(),se=new Map,oe=new Map,ae=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,G.volsha)(t.uuid),(e=>oe.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,se),le((0,G.volsha)(e.uuid),e,ae),e}function ce(){return(0,a.compact)([j.PosixFile.forMaybe((0,T.cacheDir)())?.join("volumes"),j.PosixFile.forMaybe((0,D.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),oe))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),se.clear(),ae.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,x.mapAsync)({name:"readCachedVolumes",arr:(0,x.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,a.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,M.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),n=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,z.cleanHostname)()},updatedAt:r,os:ne}))),s=new Map;for(const e of n)for(const t of(0,a.compactBlanks)([(0,G.volsha)(e.uuid),(0,G.volsha)(e.mountpoint)]))s.set(t,e);const o=ce();for(const e of o)await(0,N.withLock_)({file:e,timeoutMs:E.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of s.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:o,vol_mountpoints:n.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,a.isNotEmpty)(e))return e;const i=(0,v.toA)(await(0,X.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,H.Settings.volumeMetadataTtlMs.valueOrDefault),n=0!==H.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),s=!(0,a.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:n,priorIsMissingMountpoints:s}),n||s?void 0:e}async function me(e,i){const r=(0,m.map)(e,V.toNativePath_);if((0,u.blank)(r))return;const n=await(0,A.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,a.isEmpty)(t))continue;const i=(0,R.bestMountpointForDir)(n,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:n,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:n}})}async function pe(e,t,i){const r=i.filter((e=>(0,M.equalsIgnoreCase)(t,e.remoteShare)));if((0,a.isEmpty)(r))return;const n=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,M.equalsIgnoreCase)(e,t.remoteHost)));if(null!=n)return n;const s=await(0,W.friendlyname)(e);return(0,x.asyncFind)(r,(async e=>(0,M.equalsIgnoreCase)(s,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,o.lazy)((()=>(0,P.isSyncService)()||(0,b.isTest)())),t.priorWriteVolumesToCacheLatch=(0,o.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,o.lazy)((async()=>{const e=(0,a.compact)(await de()),t=(0,v.toA)(await(0,X.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,a.isNotEmpty)(i)?i:e.filter((e=>ne===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,C.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,C.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,a.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,L.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,_.shim0)({name:"fs.volumes",impl:async function(){if((0,b.isTest)()){const e=(0,p.toInt)((0,O.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,k.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,C.thenOrTimeoutError)({p:q.isWin?(0,$.dfWin)():(0,J.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=H.Settings.validateMountpoints.valueOrDefault?(0,a.compact)(await(0,x.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,B.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,C.thenOrTimeoutError)({p:q.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(q.isWin?t:q.isMac?await(0,Z.addLocalVolumeInfoMac)(t):await(0,Y.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await he(r),Object.freeze(r)}}),t.rootPath=(0,o.lazy)((()=>q.isWin?(0,g.opt)((0,F.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,M.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,a.isEmpty)(t)?void 0:(0,w.greatestBy)(t.filter((t=>(0,R.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,a.commonPrefixLength)(e.split(s.default.sep),t.split(s.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,v.toA)(await i.vols()).find((t=>(0,G.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,x.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return ae.get(e)??(await de())?.find((t=>(0,G.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,G.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(50213),a=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,n.lazy)((()=>(0,o.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,s.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,f());t=(0,s.toNotBlank)(t)??(0,c.safeUUID)();const n=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(n))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+a.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},65713:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),n=i(19851),s=i(23838),o=i(81168),a=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,n.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,n.lazy)((async()=>{const e=(0,a.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,n.lazy)((()=>({trie:new s.MultiMap,small:[]}))),h=3;function f(e){const t=new s.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=n)return n}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),n=i(96249),s=i(23838),o=i(59455),a=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=s.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,o.toA)(u[t])],s=c(e.substring(1));return(0,n.flatten)(s.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,a.stripDiacritics)(e).normalize())}},30933:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const n=r(i(48161)),s=i(19851),o=i(42659),a=i(31586),l=i(50213),u=i(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>n.default.cpus()),5*o.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=n.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,a.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,i){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const n=r(i(48161)),s=i(19851),o=i(31586),a=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=n.default.freemem(),t=n.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,o.gt0)(r))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,a.fmtBytes)(i),freemem:(0,a.fmtBytes)(e),totalmem:(0,a.fmtBytes)(t)}})}))},15674:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),n=i(42659),s=i(41400),o=i(31586),a=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,r.lazy)((()=>{const e=(0,o.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*a.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/a.MB),worstCaseMemPerProcMb:Math.ceil(e/a.MB)}})}),n.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,o.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,o.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,f.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=w();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const n=Math.min(e,v());return t=(0,o.clamp)(1,n,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,o.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,o.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,o.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},22751:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),n=i(87997),s=i(19851),o=i(42659),a=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new r.Rate(5*o.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,s.lazy)((()=>(0,n.setInterval)(g,o.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,a.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),n=i(22573),s=i(50357),o=i(98553),a=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function v(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function S(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,o.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,a.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const n=[];if(et;s-=i)n.push(r(s));return n}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),n=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===n[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,s.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const n of t){const t=i(n);r.includes(t)||(e.push(n),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(n.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,o.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,s.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,o.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of S(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,o.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const n=new Set(i.map(r));return e.filter((e=>!n.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),n=i(36783),s=i(41801),o=i(98553),a=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,n.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const r of e)(0,a.getOrSet)(i,(0,o.stringify)(t(r)),(()=>r));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,n.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,s.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},5233:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),n=i(31586),s=i(13538),o=i(41583);t.retryOnReject_=async function(e,t){const i=(0,n.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const a=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,o.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await a(l),u()}};return u()}},17586:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},22573:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),n=i(42279),s=i(54993);function o(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function a(e){return!o(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,s.toS)(e);return a(i)?t(i):void 0}t.blank=o,t.notBlank=a,t.notBlankToS=function(e){return a(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,n.tot)(t);const i=(0,s.toS)(e).trim();return i.length>0?i:(0,n.tot)(t)},t.notBlankAnd=function(e,t){return!o(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),n=i(22573),s=i(30301),o=i(55835),a=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,o.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,a.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const n=Math.floor(e/t.minuteMs);e-=n*t.minuteMs;const s=Math.floor(e/t.secondMs),o=Math.floor(e-s*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(n)+":"+(0,l.pad2)(s)+(i.includeMs?"."+(0,l.pad3)(o):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),n=i(),s=i(),o=i(),a=i(),l=i();return new Date(t,l-1,a,o,s,n,r)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,i="ago"){return e<1e3?"just now":(i=(0,n.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const s=Math.floor(e/r.ms);e-=s*r.ms,s>0&&(r.ms>=t.dayMs?i:n).push(s+r.s)}return e>0&&n.push((0,a.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(n)?"":"T"+n.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,o.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),n=i(73872);function s(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function o(e,t,i,r){if(null==i||y(e)||y(t))return;let n=i.get(e);null!=n?n.set(t,r):(n=new WeakMap,n.set(t,r),i.set(e,n))}function a(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const n=l(e,t);return null!==n?n:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=s(e,t,u);if(null!==f)return f;const m=s(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return o(e,t,u,i),i;const n=l(e,t);if(null!==n)return n}const y=n(e);if(y!==n(t))return o(e,t,u,!1),!1;o(e,t,u,!0);const v=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return a(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],n=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){n.push([e,t])})),c(r.sort(),n.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return o(e,t,u,v),v}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let n=-1;for(;++n{Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const n=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return n.prior=()=>t,n.hasPrior=()=>r,n}},41400:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),n=i(35556),s=i(31586),o=i(68708);function a(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const s=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&n.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return a(t).then((()=>t))},t.delay=a,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),s=n.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return n.isBrowser||t<=r.secondMs?s:(0,o.maybeCall)(s,"unref")??s}},50357:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),n=i(68708),s=i(34666),o=i(32639);function a(e,t){return(0,r.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,o.isFunction)(e)&&(0,o.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=a,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return!1;for(const i of(0,n.keys)(e))if(!a(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),n=i(22573),s=i(96249),o=i(31586),a=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,n.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,o.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,s.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,n.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,n.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,n.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(n.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,a.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,a.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,a.assignFields)(new Error,(0,a.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},96249:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),n=i(42659),s=i(55835),o=i(31586),a=i(12168),l=[{ms:n.yearMs,s:"year",p:"years"},{ms:n.yearMs/12,s:"month",p:"months"},{ms:n.weekMs,s:"week",p:"weeks"},{ms:n.dayMs,s:"day",p:"days"},{ms:n.hourMs,s:"hour",p:"hours"},{ms:n.minuteMs,s:"minute",p:"minutes"},{ms:n.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,n){if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,s.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,a.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,s.mapOr)(n,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function n(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=n,t.orList=function(e){return n(e,"or")},t.andList=function(e){return n(e,"and")}},73722:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const n=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,n){if((0,isFunction_1.isFunction)(r))return;let s,o,a,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),n=i(50357),s=i(31586),o=i(65812);t.lazy=function(e,t){let i,a;const l=[];function u(){return u.isStale()&&u.setResult(e()),a}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const s=await e,a=await i;if(!(0,n.eql)(s,a))for(const e of l)e(a);null!=t&&t>0&&void 0!==a&&(0,o.setUnrefTimeout)((()=>u.vacuum()),t)}(a,e),a=e},u.isStale=function(){return null==i||(0,s.gt0)(t)&&i+t{Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),n=i(54993);function s(e,t){return null==e?void 0:t(e)}function o(e,t,i){return null==e||null==t?void 0:i(e,t)}function a(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=o,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=a,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return a(o(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,n.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class n extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=n},23838:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),n=i(76790),s=i(50357),o=i(98553),a=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,a.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,a.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,s.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),n=null==i?[]:e(t,i);(0,r.isEmpty)(n)?this.store.delete(t):this.store.set(t,n)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,n]of this.store.entries()){const s=(0,r.findIndexes)(n,(t=>!e(i,t,n)));if(s.length>0){t=!0;for(const e of s.reverse())n.splice(e,1)}0===n.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,o.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,n.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),n=i(22573),s=i(42279),o=i(54993);function a(e){return"number"==typeof e&&isFinite(e)}t.isNumber=a,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,o.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return a(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,o.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>a(t)&&a(i)&&e(t,i);function f(e,i,n){return!(null==n||!a(n))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,n)&&(0,t.gte)(i,n))}function m(e){if(!a(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,n.blank)(e))return t.defaultValue;if(a(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return a(e)&&e>0}function S(e){return a(e)&&e>=0}function b(e,t){return a(e)?t(e):void 0}function P(e){return a(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function E(e,t,i){if(e>t||!a(e)||!a(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return a(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return a(e)?e:t},t.diff=function(e,t){return a(e)&&a(t)?e-t:void 0},t.absdiff=function(e,t){return a(e)&&a(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!a(e)||!a(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return f(t-r,t+r,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)a(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return a(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return a(e)&&a(t)&&e>t?e:void 0},t.lte0=function(e){return a(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=v(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,i){return b(e,(e=>b(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return a(e)?t(e):i},t.numericOr=function(e,t){return a(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!a(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=E,t.times=function(e,t){if(!w(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return E(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!a(i))return;t+=i}return t}},68708:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(32639),a=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function w(e,t,i={}){return y((0,r.compact)((0,n.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function S(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const n={};for(const e of(0,r.uniq)((0,r.flatMap)(i,h)))n[e]=S(...i.map((t=>t[e])));return n}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=v(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,n]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==n&&!0!==i?.assignNullish||(e[r]=n));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,a.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,s.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=a.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function n(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:S(i,t)}for(const r of i){const[i,o]=(0,c.splitFirst)(r,"."),a=b(t,i);null!=a?.value&&n(a.key,(0,s.blank)(o)?a.value:e(a.value,o))}for(const r of h(t))((0,l.toInt)(r)??-1)>=0&&n(r,e(t[r],...i));return r},t.pluck=b,t.pluckDeep=function e(t,i){if(null==t||(0,s.blank)(i))return;if(Array.isArray(t)){const n=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(n)?void 0:{key:n[0].key,value:(0,r.flatMap)(n,(e=>e.value))}}const[n,o]=(0,c.splitFirst)(i,"."),a=b(t,n);if(null==a)return;if((0,s.blank)(o))return a;const l=e(a.value,o);return null==l?void 0:{key:a.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,o.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=w(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return n(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return s(e).flatMap((e=>s(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return s(e).flatMap((e=>s(t).flatMap((t=>s(i).flatMap((i=>r(this.a,e,t,i)))))))}}function n(e){return e instanceof r||e===t.None}function s(e){return n(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=n,t.opt=s},39926:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),n=i(54993),s={};function o(e,t){if(t<1)return"";if(!(0,r.gte)(s[e]?.length,t)){let i=s[e]??e;for(;i.length{Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),n=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,o=/[^aeiou]y$/,a=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=n.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(o)?e.replace(/y$/i,"ies"):null!=e.match(a)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),n=i(54993),s=["number","string","boolean"];function o(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=o,t.mapPrimitive=function(e,t){return o(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return o(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(o)};const a=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,s=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==s&&"symbol"!==s)){const r=(0,n.toS)(e),s=(0,n.toS)(i),o=r.localeCompare(s);return r[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-o:o}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==s?a.indexOf(r)-a.indexOf(s):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function n(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const n of(0,r.toA)(await e))if(null!=n){const e=await n;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=n,t.isPromise=function(e){return n(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),n=i(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function o(e,t,i){return null==i||0===i.length?s(e,t):a(e,t,1,i)[0]}function a(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const n=t-e,o=new Set(r??[]);if(t===e&&0===n&&0===o.size&&1===i)return[e];const a=n-o.size;if(i>a)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:n,size:i,slotsRemaining:a})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of a(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,n.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},5670:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),n=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const o=e=>null!=e?i[e]:void 0,a=e=>null!=o(e);return{...s,values:t,length:t.length,has:a,includes:a,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:o,ordinal:e=>o(e)??t.length,validOrElse:(e,t)=>a(e)?e:(0,n.tot)(t),mapValid:(e,t)=>a(e)?t(e):void 0,cmp:(e,t)=>{const i=o(e),r=o(t);return null==i||null==r?void 0:i>r?1:i{const i=o(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),n=i(17586),s=i(22573),o=i(96249),a=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=f();return null!=r?(0,a.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function b(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),n=(0,c.toS)(t);return r.length===n.length&&(r===n||r.toLowerCase()===n.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?n.normalize():n,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,n.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,a.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return w(v(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,i){const r=i?.maxLineLen??80,n=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,o.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,o.flatten)(r.map((t=>e(t,i))))}if((t=v((0,c.toS)(t),n).trim()).length<=r)return[t];const s=S(t," ",r);if(s>n.length)return[m(t,0,s),...e(m(t,s+1),i)];{const r=t.indexOf(" ",n.length+1);return r>0&&r{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),n=i(68708),s=i(42279),o=i(83104),a=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let n=!0;const s=setTimeout((()=>{n&&(n=!1,i(o.Timeout))}),t);try{s.unref?.();const t=await e;n&&(n=!1,i(t))}catch(e){n&&(n=!1,r(e))}finally{clearTimeout(s)}}))}async function u(e,t,i=!0){const n=await l(e,t,i);if(n===o.Timeout)throw new a.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return n}t.toNotTimeout=function(e){return e===o.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?o.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,s)=>{let o=!0;try{const a=setTimeout((async()=>{if(o){o=!1;try{r(await i())}catch(e){s(e)}}}),t);(0,n.maybeCall)(a,"unref");const l=await e;o&&(o=!1,clearTimeout(a),r(l))}catch(e){o&&(o=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const n=t-Date.now();if(n<=0)throw new a.TimeoutError("timeout ("+(0,r.fmtHMS)(n)+")");return u(e,n,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const n=await l(e,t,r);return n===o.Timeout?(0,s.tot)(i):n}},42279:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),n=i(22573),s=i(54993);function o(e){return"URLSearchParams"===e?.constructor?.name}function a(e){return null==e?void 0:o(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(a)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=o,t.toURLSearchParams=a,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,s.toS)(l(...t));return e+((0,n.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,s.toS)(l(...t));return(0,n.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),n=i(30301),s=i(31586),o=i(46891),a=i(50989),l=i(51926),u=(0,n.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,s.isNumber)(r)&&(i+=r/t.MB);return(0,s.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),n=Math.pow(10,3*r),o=d[r];return(0,s.sigFigs)(e/n,t)+" "+o}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),n=Math.pow(2,10*r),o=h[r];return(0,s.sigFigs)(e/n,t)+" "+o},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,a.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,o.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,o.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},65812:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},23541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),n=i(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,n.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),n=i(23541),s=i(59455),o=i(54993);function a(e){return null==e?void 0:(0,n.isError)(e)?e:new Error((0,o.toS)(e))}t.toErr=a,t.toErrs=function(...e){return(0,r.compact)((0,s.toA)(e).map(a))}},54993:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return s(e,",")};const n={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==n?e.toString():(0,r.stringify)(e)}}t.toStr=s},90858:e=>{e.exports=require("@iarna/toml")},58587:e=>{e.exports=require("batch-cluster")},6858:e=>{e.exports=require("commander")},36507:e=>{e.exports=require("croner")},66261:e=>{e.exports=require("events")},77988:e=>{e.exports=require("exiftool-vendored")},44652:e=>{e.exports=require("fs-extra")},28787:e=>{e.exports=require("he")},51168:e=>{e.exports=require("luxon")},57272:e=>{e.exports=require("plist")},90595:e=>{e.exports=require("punycode")},38064:e=>{e.exports=require("semver")},73872:e=>{e.exports=require("type-detect")},92460:e=>{e.exports=require("util")},31421:e=>{e.exports=require("node:child_process")},77598:e=>{e.exports=require("node:crypto")},40610:e=>{e.exports=require("node:dns")},78474:e=>{e.exports=require("node:events")},73024:e=>{e.exports=require("node:fs")},51455:e=>{e.exports=require("node:fs/promises")},77030:e=>{e.exports=require("node:net")},48161:e=>{e.exports=require("node:os")},76760:e=>{e.exports=require("node:path")},53916:e=>{e.exports=require("node:path/posix")},1708:e=>{e.exports=require("node:process")},57075:e=>{e.exports=require("node:stream")},46466:e=>{e.exports=require("node:stream/promises")},87997:e=>{e.exports=require("node:timers")},57975:e=>{e.exports=require("node:util")},38522:e=>{e.exports=require("node:zlib")},16928:e=>{e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.exports}var __webpack_exports__={},exports;exports=__webpack_exports__,Object.defineProperty(exports,"__esModule",{value:!0}),__webpack_require__(75631),module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/bin/logtail.js b/bin/logtail.js index 47fe535..1fe78de 100755 --- a/bin/logtail.js +++ b/bin/logtail.js @@ -6,4 +6,4 @@ * IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THIS SOFTWARE */ -(()=>{"use strict";var __webpack_modules__={37975:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const i=r(22573),n=r(38639),s=r(44198);function o(){return(0,n.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,i.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=o;let a=!o();function l(){return a}function u(e,t){return function(r){return l()?`[${e}m${r}[${t}m`:r}}t.setColorEnabled=function(e){a=e??!o()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const i=r(19851),n=r(7282),s=r(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,i.lazy)((()=>t.SimpleAppName+((0,n.isProd)()?"":`-${(0,n.nodeEnv)()}`))),t.AppNameVersion=(0,i.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const i=r(40958),n=r(36783),s=r(76790),o=r(22573),a=r(50357),l=r(98553),u=r(55835),c=r(31586),d=r(68708),h=r(34666),f=r(59455),m=r(84885);var g=r(40958);function p(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,r=i.primitiveValueOfOrElse){const n=new Set(t.map(r));return e.filter((e=>n.has(r(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],r=e.lastIndexOf(t);return[{t,count:r+1},...v(e.slice(r+1))]}function w(...e){const t=[],r=Math.max(...e.map((e=>e?.length??0)));for(let i=0;ie?.[i])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function E(e,t){return(0,i.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,r){return C(e,t,r).index}function C(e,t,r){if((0,i.isEmpty)(e))return{index:-1,value:void 0};let n,s=-1;for(let i=0;ie.slice(r,r+t)))}async function x(e,t){return(0,i.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return g.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return g.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return g.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,a.eql)(e,t)))))},t.allDefined=p,t.mapAllDefined=function(e,t){return p(e)?t(e):void 0},t.mapAll=function(e,t){return p(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(o.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const r of(0,f.toA)(e))if(null!=r&&!0===await t(r))return r},t.findLastAsync=async function(e,t){for(let r=(e=(0,f.toA)(e)).length-1;r>=0;r--){const i=e[r];if(null!=i&&!0===await t(i))return i}},t.first=function(e,t){if(null!=e)for(const r of(0,f.toA)(e))if(null!=r){const e=t(r);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null!=i){const e=await t(i,r);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,i.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,r){for(let i=r;i<=e.length-1;i++)if(t(e[i]))return i},t.findLast=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return e[r]},t.findLastIndex=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1},t.concat=function(...e){const t=[];for(const r of e)if(Array.isArray(r))for(const e of r)null!=e&&t.push(e);else null!=r&&t.push(r);return t},t.moveToEnd=function(e,t){return(0,i.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const r=e[t];if(null==r)return e;e.push(r);for(let r=t;r(0,a.eql)(e,t)))},t.removeFirst=function(e,t){const r=e.findIndex(t);return r>=0?e.splice(r,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,n.copyArrayTo)((0,i.uniqBy)(e,t),e)},t.partition=function(e,t){const r=[],i=[];let n=0;for(const s of e)(t(s,n++)?r:i).push(s);return[r,i]},t.isUniq=function(e){return e.every(((t,r)=>e.indexOf(t)===r))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,i.compact)((0,i.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),r=[];return(0,c.times)(t,(t=>e.map((e=>r.push(e?.[t]))))),r},t.unFlatZip=function(e,t){const r=e.length/t;if(r!==Math.round(r))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const i=(0,c.times)(t,(()=>new Array(r)));for(let n=0;ne.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=E,t.least=function(e){return E(e,(e=>e))},t.greatestBy=function(e,t){return(0,i.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const r=C(e??[],t,h.lt);return null==e||null==r||r.index<0||null==r.value?void 0:{result:e[r.index],index:r.index,value:r.value}},t.reverse=function(e){const t=[];for(let r=e.length-1;r>=0;r--)t.push(e[r]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=T,t.collectBatched=function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(r(s)));return n},t.collectBatchedAsync=async function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(await r(s)));return n},t.contextFilter=function(e,t){let r;return e.filter(((e,i)=>(0,d.tap)(t(e,i,r),(t=>{t&&(r=e)}))))},t.clusterSome=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.some((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterEvery=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.every((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterAsync=async function(e,t){const r=[];e:for(const i of e){for(const e of r)if(null!=i&&await x(e,(e=>t(i,e)))){e.push(i);continue e}null!=i&&r.push([i])}return r},t.someAsync=async function(e,t){if(null!=e)for(let r=0;r=0&&!0===(0,u.map)(e[i],(e=>r(e,i))))return i}{const i=t+n;if(ie+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,r){return e.lengthr))),e}},36557:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const a=r(77988),l=o(r(1708)),u=r(19851),c=r(42659),d=r(55835),h=r(31586),f=r(85556),m=r(54993),g=r(50213),p=r(79089),y=r(45255),v=r(25764),w=r(38836),S=r(99331),b=r(95937),P=r(98314),_=r(38835),E=r(70025),M=r(8769),C=r(43334),T=r(95402),x=r(28874),D=r(63870);class k extends w.EndableWrapper{constructor(e,t,r=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,i,"m",n).call(this)),r,"worker"===e?(0,D.commandTimeoutMs)():y.ShortCommandTimeoutMs),i.add(this),this.t=t;const o=t;o.on("childStart",(async r=>{null!=r.pid?(this.logger.info("Started child process",{pid:r.pid}),(0,p.renice)(r.pid).catch((e=>this.onError("renice failed",e))),(0,T.addPid)({pid:r.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),o.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),o.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),o.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),o.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),o.on("noTaskData",((e,r,i)=>{const n=t.options.streamFlushMillis;n{this.logger.error("observeBatchCluster.endError()",e)})),o.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&T.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof a.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,E.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=k,i=new WeakSet,n=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(C.isWin?3:1)*c.minuteMs,maxTasksPerProcess:x.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:x.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:x.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,g.mkLogger)(t))),spawnTimeoutMillis:x.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:x.Settings.taskTimeoutMs.valueOrDefault}}},89788:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=r(92460),d=r(31586);class h{constructor(e){if(i.add(this),this.maxLength=e,n.set(this,void 0),s.set(this,0),o.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,n,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,i=new WeakSet,a=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,o,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,n,"f")[t]))}()}push(...e){var t,r;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,n,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,i,"m",a).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,n,"f")[e]}))}unshift(...e){var t,r;for(const c of e.reverse())u(this,s,"f"){u(this,n,"f")[e]=c,l(this,o,e,"f")}));return u(this,s,"f")}shift(){return u(this,i,"m",a).call(this,0,(e=>{var t,r;return l(this,o,(t=u(this,o,"f"),++t),"f"),l(this,s,(r=u(this,s,"f"),--r),"f"),u(this,n,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,i,"m",a).call(this,u(this,s,"f")-1-e,(e=>{const r=u(this,n,"f")[e];u(this,n,"f")[e]=u(this,n,"f")[t],u(this,n,"f")[t]=r}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const i=r(54993),n=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:r}of n)if(o(e,t))return e.subarray(t.length).toString(r);return e.toString()}function o(e,t){return t.every(((t,r)=>e[r]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,i.toS)(e)},t.bufferStartsWith=o},9092:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,r]of e)this.set(t,r)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const r=this.normalizer(e);return null!=e&&null!=r&&this.store.set(r,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=n},36638:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=n},40583:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const o=r(40958),a=r(23838),l=s(r(68708)),u=r(59455),c=r(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new a.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const r of(0,o.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(r,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const r=this.lookup(e);if(null!=r)return r;let i,n=-1;for(const[r,s]of this.m.entries()){const o=(0,c.diceCoeff)(r,e);if(o>t&&o>n){const e=this.getFirst(s);null!=e&&(i=e,n=o)}}return i}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),r=this.m.get(t);if(null!=r){for(const e of r)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const i=r(76790),n=r(31586),s=r(68708),o=r(54993),a=r(82647),l=r(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const r=this.get(e)+t;return 0===r?this.m.delete(e):this.m.set(e,r),r}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new a.Average(0);for(const t of this.keys()){if(!(0,n.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,r]of this.m.entries())e[(0,o.toS)(t)]=r;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,i.sortBy)([...this.entries()],(([t,r])=>[-r,(0,n.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new a.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,r]of(0,i.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,r);return e}addAll(e){for(const[t,r]of e.entries())this.incr(t,r);return this}get toS(){return(0,i.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let r=0;for(const[i,n]of this.m.entries()){const s=e(i);t.fill(s,r,r+n),r+=n}return t}}t.CountingSet=u},79840:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const i=r(19851),n=r(72993),s=r(45969),o=r(43334);t.EditionType=(0,i.lazy)((()=>o.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,i.lazy)((()=>n.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const i=r(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),r=t-this.ts;this.ts=t,(0,i.map)(this.listener,(t=>t(e,r))),r>2&&this.l.log(r>500?"warn":r>100?"info":"debug",e,{elapsedMs:r})}},t.elapsed=function(e){const t=Date.now(),r=e();return{elapsedMs:Date.now()-t,result:r}},t.thenElapsed=async function(e){const t=Date.now(),r=await e;return{elapsedMs:Date.now()-t,result:r}}},23467:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const i=r(50357),n=r(55835),s=r(68708);var o=r(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return o.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,i.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,i.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,n.map2Or)(await e,await t,i.eql,(()=>!1))},t.eqlPicked=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))},t.eqlOmit=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.omit)(e,...r),(0,s.omit)(t,...r))},t.eqlAsyncPicked=async function(e,t,...r){return(0,n.map2Or)(await e,await t,((e,t)=>(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))),(()=>!1))}},62344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(31586),a=r(54993),l=r(77377),u=r(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,o.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,o.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,n.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const r of this.expireListeners)r(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[i.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const r of this.expireListeners)r(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,n.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const r of this.expireListeners)r(e,t)}const r=this.priorCache[e];if(void 0!==r&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,r)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const r=this.currentCache[t]??this.priorCache[t];null!=r&&e(t,r)}}deleteIf(e){for(const t of this.keys()){const r=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=r&&e(t,r)&&this.delete(t)}}get(e){return e=(0,a.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,a.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,a.toS)(e),this.has(e))return this.get(e);const r=t();return this.set(e,r),r}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,o.isNumber)(e.__uid)&&(0,o.isNumber)(e.__start)}},80049:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=r(31586),d=r(85556),h=r(54993),f=r(54557),m=r(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,i.set(this,0),n.set(this,0),s.set(this,0),o.set(this,0),a.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,i,l(this,i,"f")+e.cacheHitsSync,"f"),u(this,n,l(this,n,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,o,l(this,o,"f")+e.rejections,"f"),u(this,a,l(this,a,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,i,"f"),cacheHitsAsync:l(this,n,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,o,"f"),timeouts:l(this,a,"f")}}has(e){return this.cache.has(e)}get_(e){var t,r,o,a;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,n,(r=l(this,n,"f"),++r),"f"),c.promise):(u(this,i,(o=l(this,i,"f"),++o),"f"),c.value)}if(c instanceof Error)throw c;return u(this,i,(a=l(this,i,"f"),++a),"f"),c}get(e){var t,r;const n=this.cache.get(e);return null==n||n instanceof m.Deferred&&n.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,i,(r=l(this,i,"f"),++r),"f"),n instanceof m.Deferred?n.value:n}clear(){this.cache.clear(),u(this,i,0,"f"),u(this,n,0,"f"),u(this,s,0,"f"),u(this,o,0,"f"),u(this,a,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const r=this.get(e);if(null!=r){if(r instanceof Error)throw r;return r}return this.set(e,t())}getOrSetAsync(e,t){const r=(0,h.toS)(e);{const e=this.get_(r);if(null!=e)return e instanceof m.Deferred?e.promise:e}const i=new m.Deferred(this.opts.name).observe(t());return this.cache.set(r,i),(0,c.gt0)(this.opts.timeoutMs)&&i.setTimeout(this.opts.timeoutMs),i.promise.then((e=>{this.set(r,e)}),(e=>{var t,i;this.cache.set(r,e),u(this,o,(t=l(this,o,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,a,(i=l(this,a,"f"),++i),"f")})),i.promise}},i=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap},54127:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class i{constructor(e){this.maxSize=e,this[r]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(r=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=i},53507:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(31586),a=r(68708),l=r(50213),u=r(68852),c=r(81168),d=r(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,i.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,r=!0){return new m(e,t,r).entries};class m{constructor(e,t,r=!0){this.warnIfMissingHeaders=r,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const i=(0,o.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,n.range)(0,i).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,a.fromEntries)(e))).filter((e=>(0,a.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let r=e;r!==t;t>e?r++:r--)if(this.blankColumns.has(r))return r;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),r=[];let i,a=0;for(;null!=(i=t.exec(this.headerRow));){const l=this.headerRow.substring(a,i.index);(0,s.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:i.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(i.index,t.lastIndex),d=i.index+((0,c.indexOfNonSpace)(u)??0),h=i.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),g=e.find((e=>e.text===m));if(null==g||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:i,left:d,right:h});else{const e=(0,n.last)(r);if(r.push(g),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=g.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,o.max_)(e?.rightIdx,i.index-((0,c.lastIndexOfNonSpace)(l)??l.length));g.leftIdx=g.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),g.rightIdx=h}a=t.lastIndex}const l=(0,n.last)(r);return null!=l&&((0,s.blank)(this.headerRow.slice(a))?l.rightIdx=(0,o.max_)(...this.rows.map((e=>e.length))):l.rightIdx=a),r}}t.Fixed=m},73913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const i=r(51455),n=r(98553);var s=r(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const r=(0,n.parseJSON)(e);return null==r?void 0:t(r)},t.readJson_=async function(e){return(0,n.parseJSON)((await(0,i.readFile)(e)).toString())}},19851:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const o=r(57975),a=r(40958),l=r(50357),u=r(31586),c=r(65812),d=r(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),i.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,i,"m",n).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,a.isEmpty)(this.watchers))return;const r=await e,i=await t;if(!(0,l.eql)(r,i))for(const e of this.watchers)e(i);null!=this.ttlMs&&this.ttlMs>0&&void 0!==i&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(42659),a=r(50213),l=r(81168),u=r(5916),c=r(56519),d=r(84777),h=r(44198),f=r(6012),m=r(43334),g=r(24399),p=r(63870);t.DefaultLocale="en";const y=(0,i.lazy)((()=>(0,a.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?E():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,p.commandTimeoutMs)()}),t.envLocale=(0,i.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const r=w.exec(e.trim())?.groups;return null==r?void 0:(0,n.compact)([r.lang,r.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(g.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const _={timeoutMs:10*o.secondMs};async function E(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return b(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=E,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const i=r(48161),n=r(1708),s=r(45599),o=r(68708),a=r(50213),l=r(88158),u=r(96175),c=r(23560),d=r(84968),h=r(37805),f=r(9727),m=r(3790),g=r(29325),p=r(43334),y=r(28874);t.logStartup=(0,s.defer)((()=>{(0,a.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:n.argv,arch:(0,i.arch)(),platform:(0,i.platform)(),os:(0,u.osFullName)(),isPacked:(0,g.isPacked)(),isElectron:p.isElectron,versions:(0,o.pick)(n.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:n.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const i=r(19851),n=r(32105),s=r(14593);t.rootLoggers=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));const o=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,o)}},9103:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const i=r(98553),n=r(54557);t.memoize=function(e,t){let r=0;const s=new n.FifoCache(t.maxSize,t.ttlMs),o=t=>{if(null!=t)return r++,s.getOrSet((0,i.stringify)(t),(()=>e(t)))};return o.clear=e=>null==e?s.clear():s.delete((0,i.stringify)(e)),o.size=()=>s.size,o.callCount=()=>r,o}},7282:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const n=i(r(1708)),s=r(38639),o=r(54993),a=r(19851),l=r(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,a.lazy)((()=>n.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,o.toS)(n.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return n.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(n.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){n.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(55835),a=r(31586),l=r(39926),u=r(54993),c=r(20014);var d=r(31586);function h(e,t){return(0,a.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(a.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,a.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,r){return(0,o.orElse)(h(e,t),r)},t.mapGte0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>=0?t(r):void 0},t.mapGt0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>0?t(r):void 0},t.mapGt0=function(e,t){const r=(0,a.toInt)(e);return null!=r&&r>0?t(r):void 0},t.map2Gt0=function(e,t,r){const i=(0,a.toInt)(e),n=(0,a.toInt)(t);return null!=i&&i>0&&null!=n&&n>0?r(i,n):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,a.isNumber)(e))return e;if((0,n.blank)(e))return;const t=String(e);return(0,o.map)(f.exec(t),(e=>(0,a.toFloat)(t.substr(e.index))))}function g(e){return(0,a.toInt)(m(e))}function p(e,t){if(null==e||null==t)return;const r=[e,t].map((e=>e.toString(2))),i=Math.max(...r.map((e=>e.length)));return r.map((e=>(0,l.leftPad)(e,i,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let r=0;for(let i=0;ie/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,r){this.store[e*this.columns+t]=r}},t.hammingDistanceBigInt=function(e,t){return(0,o.map)(p(e,t),(([e,t])=>(0,i.count)([...e],((e,r)=>e!==t.charAt(r)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,o.map)(p(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,i.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,r){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let i=0;const n=r*e.length;for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const i=r(40958),n=r(42659),s=r(96249),o=r(55835),a=r(31586),l=r(68708),u=r(34666),c=r(41583),d=r(48884),h=r(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,n.isDate)(e[t]))).map((t=>[t,e[t]]))}function g(e,t){const r={};for(const[i,n]of(0,l.entries)(e)){const e=t(i,n);null!=e&&(r[i]=e)}return r}t.definedThunks=function(...e){return e.every((e=>(0,o.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const r of e){const e=r();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(o.defined)},t.firstDefinedField=function(e,...t){return(0,o.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(r=>t(r,e[r])?e[r]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,r){if(null!=e)return t(e);throw new Error(r)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,o.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,i.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[r,i]of m(t))null==e[r]&&(e[r]=i);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[r,i]of(0,l.entries)(t))null==e[r]&&(e[r]=i);return e},t.pickMap=function(e,t,r){const i={};for(const n of t)i[n]=r(n,e[n]);return i},t.mapEntries=g,t.mapNullEntries=function(e,t,r){const i={};let n=0;for(const s of(0,l.keys)(e))if(i[s]=t(s,e[s]),n++,(0,a.gt)(n,r))break;return i},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const r={};for(const i of(0,h.sortIgnoreCase)((0,l.keys)(t)))r[i]=e(t[i]);return r}return t},t.deepDelete=function e(t,...r){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...r))):g(t,((t,i)=>r.includes(t)?void 0:e(i,...r)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const r of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[r])return e[r]}},t.pairToObject=function(e,t){const r={};return r[e]=t,r},t.zipPojos=function(...e){const t={};for(const r of(0,i.uniq)((0,s.flatten)(e.map(l.keys))))t[r]=e.map((e=>e?.[r]));return t}},96175:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const i=r(31421),n=r(73024),s=r(48161),o=r(19851),a=r(22573),l=r(42659),u=r(55835),c=r(51926),d=r(54993),h=r(48884),f=r(50213),m=r(6012),g=r(45969),p=r(43334),y=r(76280),v=r(30933),w=(0,o.lazy)((()=>(0,f.mkLogger)("os")));function S(){return(0,s.platform)()+" "+(0,s.release)()}t.osArch=(0,o.lazy)((()=>`${function(){switch((0,s.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return k();case"win32":return O();default:return S()}}()} on ${(0,s.arch)()}`)),t.osFullName=(0,o.lazy)((()=>(0,t.osArch)()+((0,g.isDocker)()?" (Docker)":"")));const b=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function _(){return"ubuntu"===(0,t.osDistributionLinux)()}function E(){return"fedora"===(0,t.osDistributionLinux)()}function M(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,o.lazy)((()=>{if(p.isLinux)for(const e of b)try{const t=(0,n.readFileSync)(e).toString();if((0,a.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,o.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,a.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),S)})),t.osDistributionLinux=(0,o.lazy)((()=>p.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=_,t.hasApt=function(){return P()||_()},t.isFedora=E,t.isAlpine=M;const C={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},T={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function x(e,t){const[r,i]=function(e){return e.split(".").slice(0,2)}(e),n=t[r];return(0,c.isString)(n)?n:n?.[i]}const D=(0,o.lazy)((()=>(0,i.execSync)("sw_vers -productVersion").toString().trim()));function k(e=D()){try{return(0,a.mapNotBlankOr)(function(e=D()){return x(e,C)}(e),(t=>`macOS ${t} (${e})`),S)}catch(e){return w().warn("osNameMac(): unknown release",e),S()}}function O(e=(0,s.release)()){const t=e.startsWith("10.0.22")?"11":x(e,T);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=k,t.osNameWin=O,t.CPUs=(0,o.lazy)((()=>(0,h.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,o.lazy)((()=>{if(p.isWin)return/^Windows (?:10|11) /i.test(O())?void 0:"Windows 10 and 11 is supported";if(p.isMac){const e=D();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(p.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(_())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(E())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(M())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},12801:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const n=i(r(48161)),s=r(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:n.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:n.default.constants.priority.PRIORITY_NORMAL,BelowNormal:n.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:n.default.constants.priority.PRIORITY_LOW,Low:n.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const i=r(41400),n=r(56409),s=r(31586),o=r(22911),a=r(73614),l=r(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:r,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const g=[];function p(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...i){f=!0,m=Date.now()+(0,s.max_)(t,r);const n=d=new o.Deferred(c);(0,s.gt0)(r)&&n.setTimeout(r);try{n.resolve(await e(...i))}catch(e){n.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,a.setUnrefTimeout)(y,t+1),g.forEach((e=>e.resolve())),g.length=0}return n.promise}const w=(...e)=>{if(p()){if(!0===u)return null;const t=d?.promise;return h=e,(0,i.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new n.Latch;return g.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>p(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const i=r(68708),n=r(54993);function s(e){return e instanceof o?e.source:(0,n.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const r=[];if(!e.global)throw new Error("must provide global regex");let n;for(;null!=(n=e.exec(t));)n.index===e.lastIndex?e.lastIndex++:r.push((0,i.pick)(n,"index","groups"));return r},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,r){const i=[];for(const t of e)try{i.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{i.push(s(t))}const n=0===i.length?t.NothingRegExp:i.map((e=>"(?:"+e+")")).join("|");return new RegExp(n,r)};class o{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=o;class a extends o{static from(...e){const t=l(e);return new a("(?:"+t.source+")?",t.flags)}}function l(e,t){let r="",i=t?.includes("g")??!1,a=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof o||t instanceof RegExp?(r+=t.source,i||(i=t.global),a||(a=t.ignoreCase),l||(l=t.multiline)):r+=s((0,n.toS)(t));return new RegExp(r,t??(i?"g":"")+(a?"i":"")+(l?"m":""))}t.RegExpOptional=a,t.concatRegexp=l},79089:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const n=i(r(48161)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(42659),u=r(41400),c=r(96249),d=r(31586),h=r(51926),f=r(54993),m=r(50213),g=r(12801),p=r(22277),y=r(84777),v=r(34102),w=r(43334),S=r(24399),b=r(28874),P=(0,o.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,o.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,a.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let E=!0;const M=(0,o.lazy)((()=>new p.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const r=(0,g.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=g.PriorityClassToNode[r]),E)try{return n.default.setPriority(e,t),t}catch(r){const i=-13===r?.errno||"EACCES"===r?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:i,error:r}),i)return;E=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&g.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,r):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,g.PriorityClassToPosix[r]??g.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+r),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const n=i(r(1708)),s=r(19851),o=r(40958),a=r(5670),l=r(54993),u=r(7282),c=r(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===a.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===a.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===a.ServiceNames.sync}function g(){return(0,t.serviceName)()===a.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,o.compactBlanks)([t.serviceName.prior(),(0,l.toS)(n.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return a.ServiceNames.indexOf(e)??a.ServiceNames.length+1},t.MainServices=[a.ServiceNames.main,a.ServiceNames.desktop],t.DbServices=[a.ServiceNames.sync,a.ServiceNames.info,a.ServiceNames.web,a.ServiceNames.list,a.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[a.ServiceNames.sync,a.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===a.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===a.ServiceNames.info},t.isTestService=g,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||g())&&!f()},t.isDbJanitorService=(0,s.lazy)((()=>m()||g())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const i=r(59455);function n(e){return e instanceof Set?e:new Set((0,i.toA)(e))}t.asSet=n,t.setEql=function(e,t){return(0,i.toA)(e.keys()).every((e=>t.has(e)))&&(0,i.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,r){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),r())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const r=n(t);return new Set([...e].filter((e=>r.has(e))))},t.diff=function(e,t){const r=n(t);return new Set([...e].filter((e=>!r.has(e))))}},19913:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const i=r(5670),n=r(57150),s=r(7282),o=r(23560),a=r(17181);t.setServiceName=function(e){(0,o.isMainService)(e)&&(e=i.ServiceNames.main);const t=o.serviceName.prior();t!==e&&((0,s.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),o.serviceName.set(e),(0,a.setupLogger)(),(0,n.logStartup)())}},12089:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=r(98553),d=r(34666),h=r(54993),f=r(62344),m=r(56038);t.shim1=function(e){return new g(e.name,e.impl,e.cache,e.toKey)};class g extends f.ExtensibleFunction{constructor(e,t,r,o){super(),i.add(this),this.impl=t,this.cache=r,this.toKey=o,n.set(this,void 0),s.set(this,void 0),l(this,n,e,"f")}async _call(e){return null==this.cache?u(this,i,"m",a).call(this,e):this.cache().getOrSetAsync(u(this,i,"m",o).call(this,e),(()=>u(this,i,"m",a).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,i,"m",o).call(this,e))}}n=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},a=function(e){return(0,m.time)(u(this,n,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const i=r(42659);t.ShortCommandTimeoutMs=7*i.secondMs},92322:function(e,t,r){var i,n=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=r(76790),o=r(17586);class a{constructor(e,t){this.valueOf=e,this.diff=t,i.set(this,[])}[(i=new WeakMap,Symbol.iterator)](){return n(this,i,"f")[Symbol.iterator]()}get length(){return n(this,i,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,r=n(this,i,"f").length-1;for(;t<=r;){const s=t+Math.floor((r-t)/2),o=this.valueOf(n(this,i,"f")[s]);if(e===o)return{found:!0,index:s};e>o?t=s+1:r=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&n(this,i,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:r}){if(t>=this.length)return[...n(this,i,"f")];const o=t=>t<0||t>n(this,i,"f").length-1?null:(r??this.diff)(n(this,i,"f")[t],e),a=this.findIndex(e);if(null==a)return;let l=a.index-1,u=o(l),c=a.index,d=o(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return n(this,i,"f").shift()}at(e){return(0,o.at)(n(this,i,"f"),e)}toA(){return[...n(this,i,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===n(this,i,"f").length-1){const e=[...n(this,i,"f")];return n(this,i,"f").length=0,e}return n(this,i,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return n(this,i,"f").splice(e,t)}retainLastN(e){return e{Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const i=r(1708),n=r(82328),s=r(84542),o=r(95705),a=r(28874);t.consoleLog=function(e,...t){a.Settings.quiet.valueOrDefault||(0,n.stdoutEnded)()||console.log((0,s.crlf)(e),...t)},t.consoleError=function(e){a.Settings.quiet.valueOrDefault||(0,o.streamEnded)(i.stderr)||i.stderr.write(e)},t.quietly=async function(e){const t=a.Settings.quiet.envValue;try{return a.Settings.quiet.envValue=!0,await e()}finally{a.Settings.quiet.envValue=t}}},82328:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const i=r(1708),n=r(95705);t.stdoutEnded=function(){return(0,n.streamEnded)(i.stdout)}},71567:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const n=i(r(1708)),s=r(22573),o=r(98553),a=r(23560),l=r(82328),u=r(38835),c=r(70025),d=r(95705);function h(e,t){return f({obj:e,ready:t,stream:n.default.stdout})}function f({obj:e,ready:r,stream:i}){if(null==i||(0,d.streamEnded)(i))return;const n=(0,o.stringify)(e,void 0,(0,a.isInfoService)()||(0,a.isMainService)()?2:void 0);i.write(n+"\n"),(0,a.isWorkerService)()&&null!=r&&(n.includes(u.FailStr)||(0,c.isFatalError)(n)||(0,c.isHealthCheckError)(n)?i.write(u.FailStr+"\n"):i.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||n.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:n.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const r of e)r.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(55835),a=r(31586),l=r(39926),u=r(34666),c=r(51926),d=r(59455),h=r(54993),f=r(48884),m=r(68852),g=r(38835);var p=r(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return p.splitFirst}});var y=r(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=r(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,r){if(0===r.length)throw new Error("rightPad() given empty pad");const i=String(e);return i+(0,l.padding)(r,t-i.length)},t.padReplace=function(e,t,r,i){return(0,c.strslice)(e,0,t)+(0,l.padding)(i,r)+(0,c.strslice)(e,t+r)},t.contains=function(e,t,r){return(0,h.toS)(e).indexOf((0,h.toS)(t),r)>-1},t.countChars=function e(t,r,i=0){if(null==r||0===r.length)return 0;const n=t.indexOf(r,i);return-1===n?0:1+e(t,r,n+r.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,r){const i=Math.min(Math.ceil(e.length/t),r??e.length)-1;return i<=0?[e]:[...(0,a.times)(i,(r=>e.slice(r*t,(r+1)*t))),e.slice(i*t)]},t.spliceCapture=function(e,t){const r=t.exec(e);if(null==r||null==r[1])return;const i=r[0].indexOf(r[1])+r.index;return{captured:r[1],uncaptured:e.substring(0,i)+e.substring(i+r[1].length),unmatched:e.substring(0,r.index)+e.substring(r.index+r[0].length),matchedIndex:i}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,r={}){if(null==t)return e;const i=(0,h.toS)(e),n=(0,h.toS)(t);return n.length>0&&(0,c.equalsIgnoreCase)(i.slice(-n.length),n,r)?i.slice(0,-n.length):i},t.gist=function(e,t=80,r=80){const i=(0,h.toS)(e),n=i.length-(t+r);return n<=0?i:i.slice(0,t).trim()+" …(+"+n+" chars)…"+i.slice(-r).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const r=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===r?e.localeCompare(t):r}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,i.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,o.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const r=S(e.cmp[0],t.cmp[0]);return 0!==r?r:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,i.isEmpty)(e)||(0,s.blank)(t))return;for(const r of e)if((0,c.equalsIgnoreCase)(r,t))return{index:0,match:r};for(const r of e){const e=t.indexOf(r);if(e>=0)return{index:e,match:r}}const r=t.normalize();for(const t of e){{const e=r.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=r.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=r.toLowerCase(),i=e.toLowerCase(),n=t.indexOf(i);if(n>=0)return{index:n,match:i}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function E(e){return _.reduce(((e,[t,r])=>e.replace(t,r)),e).normalize()}t.dumbquote=E;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(E(e))&&(e=e.slice(1,-1).trim())),e};const C=/^['‘’].*['‘’]$/,T=/^["“”„«»〃].*["“”„«»〃]$/;function x(e,t){const r=D(e,t);return(0,f.flatZip)(r.nonSeparators,r.separators).filter((e=>null!=e&&e.length>0))}function D(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+g.NonRetriableErrorFlag);const r=[],i=[];let n,s=0;for(;null!=(n=t.exec(e));)n.index===t.lastIndex?t.lastIndex++:(t.lastIndex=n[0].length+n.index,r.push(e.substring(s,n.index)),i.push(e.substring(n.index,t.lastIndex)),s=t.lastIndex);return s(0,a.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),C.test(e)||T.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const r=(0,i.compactBlanks)(e),n=Math.max(...r.map((e=>e.length)));for(let e=0;e(0,o.map)(r[e],(e=>t+=e))));return t},t.splitKeep=x,t.splitUp=D,t.sortNaturalBy=k,t.sortNatural=function(e){return(0,n.sortBy)(e,(e=>k(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,i.compactBlanks)(e)),r=t.filter(((e,r)=>!P(t[r+1],e)));return(0,n.sortBy)(r,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const r=Math.min(e.length,t.length);for(let i=0;i4===e?.length?(0,a.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const O=/#.*$/gm;t.stripComments=function(e){return e.replace(O,"")},t.uniqPath=function(e,t=":"){const r=new Set;for(const i of(0,d.toA)(e))if(null!=i&&!(0,s.blank)(i))for(const e of i.split(t))(0,s.blank)(e)||r.add(e);return[...r].join(t)},t.dedupeNeedle=function(e,t,r){if((0,s.blank)(t))return e;const i=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),n=e.findIndex((e=>i.test(e))),o=new RegExp("("+(0,m.escapeRegExp)(r)+"[,:\\s]*){2,}","gim");if(n<0)return e;for(let t=n+1;te.trim()))))}},83556:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const i=r(54993);function n(e){return(0,i.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>"_"+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>" "+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=n,t.asObjectKey=function(e){return n(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const n=i(r(77598)),s=r(73913),o=r(55222);function a(e,t=s.HashBits){return n.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,r=o.Radix58,i=224){return r.encodeBuffer(a(e,i)).substring(0,t)}t.stringShaToBuffer=a,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,r=o.GeoRadix,i=224){return l(e,t,r,i)}},94863:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const i=r(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,i.toS)(e).toLowerCase().normalize()}},96859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(31586),a=r(39926),l=r(51926),u=r(54993),c=r(55222),d=r(97352),h=r(88158),f=r(77377),m=r(81168);function g(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const r=new d.Array2D(e.length);let i=0,n="";for(let s=0;s=i&&(i=r.get(s,o),n=(0,l.substr)(e,s-i+1,i)));return n}function p(e,t){if(null==e||null==t)return;if(e===t)return 0;const r=y(e,t);if(null!=r)return r;const i=e.normalize(),n=t.normalize();return e!==i||t!==n?y(i,n):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,r,i)=>r===t.charAt(i)?e:e+1),0)}function v(e,t){const r=e.toUpperCase().normalize(),i=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>r===i?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(r),t=w(i);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,r)=>e+t[r+1]))}function S(e,t){const r=(0,f.intersection)(e,t),n=[];return r.forEach((r=>{const s=Math.min((0,i.count)(e,(e=>e===r)),(0,i.count)(t,(e=>e===r)));(0,o.times)(s,(()=>n.push(r)))})),n}function b(e,t,r){const n=(0,i.commonPrefixLength)(e,t);return r((0,l.strslice)(e,n))-r((0,l.strslice)(t,n))}function P(e){const t=(0,i.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,n.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[r,i]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(r,i,(e=>(0,o.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:g(e,t).length/Math.max(e.length,t.length)},t.lcs=g,t.hamming=p,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=_;const E=/[^\da-z]+/gi;function M(e,t){const[r,i]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(E,"").toLowerCase()));return b(r,i,(e=>c.RadixAlphaNum.decode(e)))}function C(e,t){let r;for(let i=Math.max(e.length,t.length);i>=0;i--){const n=(0,o.mapNumericOr)(e.charCodeAt(i),(e=>e),256),s=(0,o.mapNumericOr)(t.charCodeAt(i),(e=>e),256),a=(0,o.clamp)(-256,256,n-s);r=null==r?a:(r+a)/2}return r}t.radixDiff=M,t.str=function(e,t){return{pref:(0,i.commonPrefixLength)(e,t),ham:p(e,t),dice:v(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,i.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=C,t.paddedPositionalDiff=function(e,t,r=8){return C((0,a.leftPad)(e,r," "),(0,a.leftPad)(t,r," "))}},84885:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const i=r(98553),n=r(88158);t.stringifySorted=function(e){return(0,i.stringify)((0,n.sortedKeys)(e))}},22277:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=r(73614);class u{constructor(e,t=!1){i.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[o]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return a(this,i,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>a(this,i,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const r=this.delegate.get(e);return null==r||a(this,i,"m",n).call(this,e,r)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,r]of this.delegate)a(this,i,"m",n).call(this,t,r)||e(t,t,this)}has(e){return null!=e&&!a(this,i,"m",n).call(this,e)}values(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield[t,t])}()}toA(){return a(this,i,"m",s).call(this),[...this.delegate.keys()]}[(i=new WeakSet,o=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,n=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const r=t<=Date.now()-this.ttlMs;if(r){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return r},s=function(){for(const[e,t]of this.delegate)a(this,i,"m",n).call(this,e,t)}},94174:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(38639),c=r(31586),d=r(50213),h=r(45255),f=r(84777),m=r(96706),g=r(43334),p=r(24399),y=(0,o.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,o.lazy)((()=>(0,a.uniq)([s.default.geteuid?.(),s.default.getuid?.(),n.default.userInfo().uid]))),t.userid=(0,o.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,o.lazy)((()=>(0,a.uniq)([s.default.getegid?.(),s.default.getgid?.(),n.default.userInfo().gid]))),t.groupid=(0,o.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,o.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,o.lazy)((()=>(0,l.toNotBlank)(n.default.userInfo()?.username))),t.userNameFromWhoami=(0,o.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,o.lazy)((async()=>g.isWin?p.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,o.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,o.lazy)((async()=>g.isWin?g.isWin?p.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.0-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=0,t.versionPrerelease=["prealpha"],t.release="2024.3.0-prealpha+20240308102353",t.gitSha="92cba1b21937cb9ca770f6a339e44b0fbee04bf9",t.gitDate=new Date(1709922233e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const i=r(42659),n=r(55835),s=r(31586),o=r(97790),a=r(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const r=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,n.allDefined)(r))return;const[o,a,u,c,d,h,f]=r,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(o,a-1,u,c,d,h,f/1e3)-m*i.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,o.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,a.within)(0,Date.now()+i.dayMs,e))).map((e=>new Date(e))).get()}},73568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class r extends Error{}t.AbortError=r},76740:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const a=r(45599),l=r(56409),u=r(73568);t.Abortable=class{constructor(){this._aborted=!1,i.set(this,void 0),n.set(this,(0,a.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,n,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,n,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,n,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),o(this,i,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,i,"f")&&clearTimeout(s(this,i,"f")),o(this,i,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},i=new WeakMap,n=new WeakMap},22911:function(e,t,r){var i,n,s,o,a,l,u,c,d,h,f,m,g=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},p=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(r(87997)),w=y(r(57975)),S=r(45599),b=r(26905),P=r(55835),_=r(31586),E=r(68708),M=r(20214),C=r(57153),T=r(85556),x=r(50213),D=r(70025),k=r(95937),O="TIMEOUT",I=(0,S.defer)((()=>(0,x.mkLogger)("async.Deferred")));class F{static async*toAsyncIterable(e,t){const r=[...e].reverse(),i=(0,_.gt0)(t)?new n(O).setTimeout(t):void 0;for(null!=i&&r.push(i);;){for(let i=r.length-1;i>=0;i--){const n=r[i];if(n.isSettled){if(n.name===O)return void I().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});r.splice(i,1),yield n.value}}if(r.every((e=>e.name===O)))break;try{await Promise.race(r)}catch{}}i?.clearTimeout()}static resolve(e,t){return new n(".resolved()",t).resolve(e)}constructor(e,t){var r,m,y;i.add(this),this.name=e,this.startedAt=Date.now(),o.set(this,void 0),a.set(this,C.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(p(r=n,n,(y=g(r,n,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{p(this,u,e,"f"),p(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return g(this,f,"f")??(0,x.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof n&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:g(this,a,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,E.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return g(this,o,"f")}get elapsedMs(){return(g(this,o,"f")??Date.now())-this.startedAt}get[(o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,i=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=g(this,h,"f")&&(v.default.clearTimeout(g(this,h,"f")),p(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(p(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new T.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,k.onTimeout)())}),e),"f"),g(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return g(this,a,"f")===C.PromiseStates.pending}get value(){return this.isResolved?g(this,l,"f"):void 0}get error(){return g(this,d,"f")}get isSettled(){return g(this,a,"f")!==C.PromiseStates.pending}get isResolved(){return g(this,a,"f")===C.PromiseStates.resolved}get isRejected(){return g(this,a,"f")===C.PromiseStates.rejected}get settledMs(){return null==g(this,o,"f")?void 0:g(this,o,"f")-this.startedAt}resolve(e){return g(this,i,"m",m).call(this,(()=>{p(this,a,C.PromiseStates.resolved,"f"),p(this,l,e,"f"),g(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,D.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return g(this,i,"m",m).call(this,(()=>{p(this,d,t,"f"),p(this,a,C.PromiseStates.rejected,"f"),g(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=F,n=F,m=function(e){if(g(this,a,"f")===C.PromiseStates.pending){(0,P.map)(g(this,h,"f"),v.default.clearTimeout),e(),p(this,o,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:g(this,l,"f")});return this},s={value:0}},27395:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const i=r(19851),n=r(40958),s=r(42659),o=r(23838),a=r(13538),l=r(50213),u=r(7282),c=r(97352),d=r(77740),h=r(25764),f=r(99331),m=r(73614),g=(0,i.lazy)((()=>(0,l.mkLogger)("async.Endable"))),p=new o.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const r=await e;if(null==r||!0===r?.ended)return;const i=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,r.endTimeoutMs,y);g().trace(r.name+" ending...",{timeoutMs:i});try{await(0,a.thenOrTimeoutError)(r.end(),i,(0,u.isTest)())}catch(e){try{g().warn(r.name+".end() failed",e)}catch{}}}function w(){p.filterInPlace(((e,t)=>!0!==t.ended)),g().debug("vacuumEndables()",p.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),p.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,i.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;g().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const r=p.get(t)??[];(0,n.isNotEmpty)(r)&&(g().debug("endEndables(): ending "+t),await Promise.allSettled(r.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,n.compact)(p.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const r=p.get(t)??[];e[t]=r.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,r){var i,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=r(87997),h=r(55835),f=r(31586),m=r(68708),g=r(25764),p=r(38836),y=r(99331);class v extends p.EndableWrapper{constructor(e){super(e.name,(()=>u(this,i,"m",o).call(this)),e.rank??g.EndableRanks.first,e.endTimeoutMs),i.add(this),this.opts=e,n.set(this,void 0),s.set(this,void 0),a.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,n,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,r=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!r&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,i,"m",o).call(this);const h=()=>{u(this,i,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,n,(0,d.setInterval)(u(this,a,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,i,"a",l)&&(u(this,a,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):h(),!0}}t.EndableInterval=v,n=new WeakMap,s=new WeakMap,a=new WeakMap,i=new WeakSet,o=function(){(0,h.map)(u(this,n,"f"),d.clearInterval),c(this,n,void 0,"f"),(0,h.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const i=r(50989);t.EndableRanks=(0,i.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const a=r(19851),l=r(45599),u=r(56409),c=r(50213),d=r(27395),h=r(25764),f=r(99331),m=r(56519);t.EndableWrapper=class{constructor(e,t,r=h.EndableRanks.first,o){this.endTimeoutMs=o,i.set(this,void 0),this.onEnds=[],n.set(this,(0,a.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,n,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(r,this)}setName(e){o(this,i,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,i,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,n,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},i=new WeakMap,n=new WeakMap},99331:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const i=r(7282);let n=!1;t.ending=function(){return n},t.setEnding=function(e){n=(0,i.isTest)()?e:e||n}},45608:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const n=i(r(1708)),s=r(22573),o=r(45599),a=r(37975),l=r(50213),u=r(71567),c=r(57159),d=r(57902),h=r(28874),f=r(27395),m=r(99331),g=r(56038),p=(0,o.defer)((()=>(0,l.mkLogger)((0,a.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,o.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(g.PromiseTimer.instance().report())}));async function v(e){p().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const r=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==r.errno||!0===r.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const i=(0,s.toNotBlank)(e?.reason)??r.toString();for(const e of t.onFatalHandlers)await e(i)}(0,m.ending)()||(await(0,f.endEndables)(),n.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,o.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])n.default[e].on(t,(r=>{v({reason:`${e}:${t}`,status:0,error:r})}))}))},5916:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=r(50357),f=r(31586),m=r(41583),g=r(62344),p=r(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:r,timeoutMs:i}){return new y(e,t,r,i)};class y extends g.ExtensibleFunction{constructor(e,t,r,l){super(),i.add(this),this.later=e,this.desc=t,this.ttlMs=r,this.timeoutMs=l,n.set(this,void 0),s.set(this,0),o.set(this,void 0),a.set(this,[])}_call(){return this.isStale()?c(this,i,"m",u).call(this,this.later()):c(this,o,"f")}unset(){d(this,s,0,"f"),d(this,n,void 0,"f"),d(this,o,void 0,"f")}set(e){return c(this,i,"m",u).call(this,p.Deferred.resolve(e))}refresh(){return c(this,i,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,a,"f").push(e)}prior(){return this.isStale()?void 0:c(this,o,"f")}lastValue(){return c(this,o,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,n,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,n,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,n,"f")?void 0:Date.now()-c(this,n,"f")}elapsedMs(){return c(this,o,"f")?.settledMs??c(this,o,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=async function(e,t){var r;try{const r=await t;if(!(0,h.eql)(e?.value??await(e?.promise),r))for(const e of c(this,a,"f"))await e.onChange(r)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,a,"f"))e.onError(t)}finally{d(this,s,(r=c(this,s,"f"),++r),"f")}},u=function(e){d(this,n,Date.now(),"f");const t=c(this,o,"f");return d(this,o,e instanceof p.Deferred?e:new p.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,o,"f").setTimeout(this.timeoutMs),c(this,i,"m",l).call(this,t,c(this,o,"f")),c(this,o,"f")}},56519:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const i=r(40958),n=r(76790),s=r(38639),o=r(42659),a=r(41400),l=r(31586),u=r(20214),c=r(13538),d=r(42279),h=r(32639),f=r(59455),m=r(41583),g=r(48884),p=r(50213),y=r(88158),v=r(15674),w=r(42638);var S=r(20214);async function b(e){if(null==e)return[];const t=(0,i.compact)(await e);return(0,i.isEmpty)(t)?[]:(0,i.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:r,timeoutMs:n}){const s=[];for(const o of(0,i.compact)(await t))try{const e=await((0,l.gt0)(n)?(0,c.thenOrTimeoutError)(r(o),n):r(o));null!=e&&s.push([e,o])}catch(t){(0,p.mkLogger)(e).warn("failed to apply",{ea:o,error:t})}return s}async function E({arr:e,f:t,name:r,maxConcurrent:n,timeoutMs:s,promises:o}){if(null==e)return[];const a=(0,i.compact)(await e);if((0,i.isEmpty)(a))return[];if((n=Math.round(n??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:r,timeoutMs:s});const u=o??(a.length<=n?w.PermissivePromises:new w.Promises(r,(()=>n))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,h=await u.enqueueAll(r,a.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,p.mkLogger)(r).warn("failed to apply",{ea:e,error:t})}})));return(0,i.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,r){const i=[];for(const n of(0,g.batches)((0,f.toA)(await e),t)){const e=await b(n);i.push(...await b(r(e)))}return i},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,a.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const r of(0,i.compact)(e)){const e=await r();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;if(null!=e)if(Array.isArray(e))for(const r of e){const e=await r;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;null!=e&&t.push(e)}return(0,i.uniq)(t)},t.asyncFind=async function(e,t){for(const r of e)if(await t(r))return r},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=E,t.mapAsync=async function({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s}){return(await E({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:r,maxConcurrent:n,timeoutMs:s}){return(await E({name:e,arr:(0,i.compact)(t),f:r,maxConcurrent:n,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const r=await E({name:"partitionAsync",arr:e,f:t});return[r.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),r.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*o.secondMs,t.tryAll=async function(e,r=(e=>console.error(e)),i=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,i)}catch(e){r((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),r=(()=>{})){let i,n=null;try{i=await((0,h.isFunction)(e)?e():e)}catch(e){n=(0,m.toErr)(e);try{await t(e)}catch{}}try{await r(n??i)}catch{}if(null!=n)throw n;return i},t.thenNot=async function(e,t=!0){if(null==e)return t;const r=await e;return null==r?t:!(0,s.isTrue)(r)},t.thenMap2=async function(e,t,r){const i=await e;if(null==i)return;const n=await t;return null!=n?r(i,n):void 0},t.thenMapOr=async function(e,t,r){const i=await e;if(null==i)return r();const n=await t(i);return null==n?r():n},t.thenMap2Or=async function(e,t,r,i){const n=await e;if(null==n)return i();const s=await t;if(null==s)return i();const o=await r(n,s);return null==o?i():o},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null==i)continue;const e=await t(i,r);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const r of e){const e=await r();if(null!=e){const r=await t(e);if(null!=r)return r}}},t.firstResolvedDefinedPromise=async function(e,t){for(const r of e)try{const e=await r();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const r of t)try{const t=await r();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:r}){const i=await E({name:e,arr:t,f:r});return(0,n.sortBy)(i,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const i=r(19851),n=r(40958),s=r(76790),o=r(42659),a=r(49769),l=r(31586),u=r(68708),c=r(42279),d=r(41583),h=r(22454),f=r(14121),m=r(50213),g=r(7282),p=r(34102),y=r(82647),v=r(25764),w=r(38836),S=r(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,r){const i=Date.now(),n=(0,l.clamp)(10*o.secondMs,o.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-i)+"ms")}),n);try{const n=await(0,c.tot)(t),s=Date.now()-i;return r?.(n,s),this.push(e,s),n}catch(t){throw this.errors.incr(e),r?.((0,d.toErr)(t),Date.now()-i),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),r=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),i=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",r.stats()],...i])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,a.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:r.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:(0,l.mapFinite)(r.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:r.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:{sumSec:(0,l.sigFigs)(r.sum/o.secondMs,3),...(0,u.omit)(r.stats(),"sum")}})),{})}}function _(e,t,r){return P.instance().time(e,t,r)}function E(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,i.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,n.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,g.isTest)()&&(0,p.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const r=Date.now(),i=t();return E(e,Date.now()-r),i},t.pushTime=E,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,r){return(0,i.lazy)((async()=>_(e,t)),r)}},42638:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(r(66261)),m=r(40958),g=r(55835),p=r(31586),y=r(42279),v=r(54993),w=r(89788),S=r(82647),b=r(15674),P=r(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){i.add(this),this.name=e,this.ee=new f.default.EventEmitter,n.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),o.set(this,[]),a.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,n,t,"f")}get maxConcurrency(){return Math.floor((0,p.clamp)(1,(0,b.maxCpus)(),d(this,n,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,a,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,o,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,o,"f").map((e=>e.name)),pendingNames:d(this,a,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:r,serialId:n}){const s=d(this,i,"m",l).call(this,{name:e,l:t,payload:r,serialId:n});return this.laterPop(),s}enqueueAll(e,t){const r=t.map((t=>d(this,i,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(r)}serial(e,t,r){return this.enqueue({name:e,l:t,serialId:e,payload:r})}push(e,t,r){return d(this,i,"m",u).call(this,new P.Deferred(e,{payload:r}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,o,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,a,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,a,"f").length,e),r=this.runningSerialIds,n=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,o,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,a,"f").length}hasPending(){return d(this,a,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,p.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,a,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,a,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=function({name:e,l:t,payload:r,serialId:i}){const n=new P.Deferred(e,{payload:r,serialId:i});return d(this,a,"f").push({d:n,l:t}),n},u=function(e,t){const r=Date.now();return this.lastWorkTs=r,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,o,"f"),e),this.settleMsAvg.push(Date.now()-r),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,o,"f").push(e),e},t.maybeRun=function(e,t){const r=new _(e);return()=>r.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:r}){return new _(e,(0,g.map)(r,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class r extends Error{}t.RedoableError=r},4867:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const i=r(40958),n=r(34546),s=r(41400),o=r(31586),a=r(83104),l=r(85556),u=r(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:r}){let a=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>a=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>{if(a)throw new l.TimeoutError})):void 0,r?.abortPromise_().then((()=>{if(a)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:r}){let l=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>l=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>a.Timeout)):void 0,r?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let r=e=>null;t.setTimeoutHandler=function(e){r=e},t.onTimeout=function({soft:e}={}){r(e)}},73614:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const i=r(87997);t.setUnrefTimeout=function(e,t,...r){return(0,i.setTimeout)(e,Math.round(t),...r).unref()},t.setUnrefInterval=function(e,t,...r){return(0,i.setInterval)(e,Math.round(t),...r).unref()}},31562:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const i=r(38639),n=r(42659),s=r(41400),o=r(32639),a=r(31586),l=r(45255),u=r(95937);async function c(e,{timeoutMs:t,intervalMs:r,acceptable:i,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const i=r??(0,a.clamp)(10*m,l.ShortCommandTimeoutMs,(t??n.minuteMs)/5);await(0,s.delay)(i,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:i.isTrue,timeoutResult:!1})}},9727:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const n=i(r(1708)),s=r(45599),o=r(41400),a=r(50357),l=r(68708),u=r(48884),c=r(36638),d=r(44198),h=r(59958),f=r(96706),m=r(34102),g=r(19851),p=r(19043),y=r(66184),v=r(50213),w=r(7282),S=r(88158),b=r(45969),P=r(43334),_=r(28874),E=r(3790);function M(e){return C().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const C=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const r of t.names)e.add(r);for(const r of t.keys)e.add(r)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,o.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const T=["HOME","LANG","USER"],x=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],D=(0,g.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?T:x),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function k(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const r of(0,_.persistedSettings)()){const i=e?r.value:r.envValue;null==i||(0,a.eql)(i,r.defaultValue)||r.addToEnv(t)}return t}t.sanitizedEnv=(0,g.lazy)((()=>(0,l.filter)(n.default.env,(e=>M(e)||!(0,E.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=k,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:I({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let O=!1;function I({overrides:e,forceCLocale:r=!0,forWorker:i=!1}={}){const n=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...D(),...r?(0,p.childProcLocale)():{},...k(i),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(n);if((0,y.isLogged)("debug")&&!O){O=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(n).map((([e,t])=>[e,(0,E.isHiddenEnvKey)(e)?"(hidden)":t])),[r,i]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(r)),e.debug("non PS env:",(0,l.fromEntries)(i))}return n}t.childEnv=I},84777:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const n=i(r(31421)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(42659),c=r(98553),d=r(56409),h=r(31586),f=r(68708),m=r(51926),g=r(50213),p=r(7282),y=r(88158),v=r(79089),w=r(45255),S=r(22911),b=r(4867),P=r(73614),_=r(70025),E=r(57159),M=r(36868),C=r(66184),T=r(45643),x=r(95402),D=r(9727),k=(0,o.lazy)((()=>(0,g.mkLogger)("child.ChildProcess")));function O(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function I(e,t=30*u.secondMs){if(null==e)return!1;k().debug("endProcess()",O(e));const r=e.pid;if(null==r||r<=0)return k().warn("endProcess(): asked to end invalid pid",O(e)),!1;if(r===s.default.pid)return k().warn("endProcess(): asked to end MY pid",O(e)),!1;if(r===s.default.ppid)return k().warn("endProcess(): asked to end my parent pid",O(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();k().debug("endProcess("+r+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,x.killPid)(r).catch((e=>{k().warn("endProcess(): kill("+r+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,p.isSingleSpecTests)())return!0;if(await(0,T.waitForPidExit)(r,t))return k().debug("endProcess(): exitted",O(e)),!0;{x.Pids.instance()?.onKill(r);const t=e.kill("SIGKILL");k().warn("endProcess("+r+") had to resort to SIGKILL",{killResult:t}),t||await(0,x.killPid)(r,!0).catch((e=>{k().warn("endProcess(): kill("+r+",true) failed: "+e)}))}return(0,T.waitForPidExit)(r,5e3)}function F(e,r,i,n=0){const o=new Date,a=[];return(0,v.niceable)(r,i)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(n,u.secondMs)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&I(e)}),n-250)),a.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,x.addPid)({pid:e.pid,cmd:r,timeoutMs:n,ppid:s.default.pid},o)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>a.forEach(clearTimeout))),e}function L(e,t,r,i){const s=(0,D.spawnOptions)(i);return(0,C.isLogged)("trace",k().context)?k().debug("execFile()",{command:e,args:t,timeoutMs:r,opts:s}):k().debug("execFile()",{command:e,args:t,timeoutMs:r}),F(n.default.execFile(e,t,s),e,t,r)}async function A(e,t,r){const i=r.quiet??!1,n=r.ignoreStderr??!1,s=r.ignoreExitCode??!1,o=L(e,t,r.timeoutMs,(0,f.omit)(r,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===r.disconnect){try{o.disconnect?.()}catch{}return{result:"",pid:o.pid}}const u=o.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],g=[],p=[],y=new S.Deferred(f);o.on("error",(e=>p.push(e))),o.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),o.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(o.stdin);const v=new d.Latch;null==o.stdout?v.resolve():(o.stdout.on("error",(e=>p.push(e))),o.stdout.on("data",(e=>m.push(e))),o.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==o.stderr||n?P.resolve():(o.stderr?.on("error",(e=>p.push(e))),o.stderr?.on("data",(e=>g.push(e))),o.stderr?.on("end",(()=>P.resolve()))),k().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:r.timeoutMs,halt:r.halt}),k().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt});const C=g.join("");(0,l.notBlank)(C)&&p.push(new Error(C)),!i&&(0,a.isNotEmpty)(p)&&k().warn(f+" resulted in errors:",p);const T=r.isIgnorableError??_.isIgnorableError,x=p.filter((e=>!0!==T(e)));if(x.length>0)throw 1===x.length?x[0]:new E.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:x});if(!s&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:C}}catch(e){throw k().error("stdoutResult_() failed",e),await(0,x.killPid)(o.pid,!0),e}}t.endProcess=I,t.ReniceAfterMs=(0,o.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,o.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,r,i){const s=(0,D.spawnOptions)(i);return k().debug("spawn()",{command:e,args:t,maxAgeMs:r}),F(n.default.spawn(e,t,s),e,t,r)},t.execFile=L,t.stdoutResult_=A,t.stdout_=async function(e,t,r){const i=await A(e,t,r);return k().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(i.result),meta:{cmd:e,args:t,opts:r,result:i}})}},3790:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const i=r(22573),n=r(41400),s=r(19851),o=r(28874);(0,n.later)((()=>o.Settings.sensitiveEnvRegExp.watchLater((()=>a.unset()))));const a=(0,s.lazy)((()=>{try{return new RegExp(o.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${o.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(o.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,i.blank)(e)&&a().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||o.Settings.license.includesEnvKey(e)}},69554:function(e,t,r){var i,n=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const s=r(6858),o=r(1708),a=r(37805),l=r(22573),u=r(55835),c=r(7282),d=r(19913),h=r(43334),f=r(41269),m=r(80061),g=r(94361);t.CLI=class{constructor(e,t,r){this.serviceName=e,this.args=t,this.additionalDescription=r,i.set(this,[]),(0,d.setServiceName)(e),(0,g.verifyUidGid)()}add(...e){return n(this,i,"f").push(...e),this}async parse(e=o.argv,t){let r=(0,m.addHelpFooter)(new s.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{r=r.arguments(e)}));for(const e of n(this,i,"f"))r=e.beforeParse(r);r.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":a.version)+")"),r.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,o.exit)(0)})),r.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=r.opts();for(const e of n(this,i,"f"))await(e.afterParse?.(d));return r}},i=new WeakMap},41269:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const i=r(1708),n=r(31586),s=r(51926),o=r(17344),a=r(37805),l=r(84542);function u(e,t){const r=t?.maxLineLen??(0,n.toInt)(i.env.maxLineLen)??i.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:r,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,o.EditionName)()+" v"+a.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const i=r(38639),n=r(17181),s=r(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,i.mapBoolean)(e.color,(e=>{s.Settings.logColor.envValue=e,(0,n.setupLogFormatter)()}))}}},94361:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const i=r(19851),n=r(40958),s=r(55835),o=r(31586),a=r(94174),l=r(44198),u=r(45969);function c(e,t,r){const i=(0,o.toGt0)((0,l.env)()[t]);return null==i||r.includes(i)?void 0:`WARNING: ${e} is running as ${r} but $${t}=${i}`}function d(){const e=(0,n.compactBlanks)([c("user id","PUID",(0,a.userids)()),c("group id","PGID",(0,a.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,i.lazy)((()=>{(0,u.isDocker)()&&(0,s.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},76596:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const i=r(51168),n=r(19851),s=r(22573),o=r(42659),a=r(55835),l=r(31586),u=r(68708),c=r(34666),d=r(50213),h=(0,n.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,r){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=r}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const r=(0,a.mapOr)(e,(e=>e.getTime()),(()=>0)),i=(0,a.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(r,i)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),r=Date.now();return t<=r?0:t-r},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,o.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const i=r(22573),n=r(31586),s=r(54557),o=r(91655),a=new s.FifoCache(512);function l(e){return(0,n.isNumber)(e)?e:(0,i.blank)(e)?void 0:a.getOrSet(e,(()=>(0,o.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,i.blank)(e)?void 0:u.getOrSet(e,(()=>(0,o.fmtFullDuration)((0,n.isNumber)(e)?e:l(e))))}},91655:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const i=r(51168),n=r(40958),s=r(22573),o=r(42659),a=r(31586),l=r(51926),u=r(68852),c=r(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,a.isNumber)(e))return;if((0,a.isNumber)(e))return e;if((0,a.isDigits)(e))return(0,a.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=i.Duration.fromISO(e);if(t.isValid)return t.toMillis();const r=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(r,e);if(0===d.length)return;const h=(0,n.compact)(d.map((e=>function(e,t){const r=(0,a.toFloat)(e);if(null!=r){if((0,s.blank)(t))return r;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*o.yearMs;case"weeks":case"week":case"w":return r*o.weekMs;case"days":case"day":case"d":return r*o.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return r*o.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return r*o.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return r;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,a.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:o.yearMs,s:"y"},{ms:o.weekMs,s:"w"},{ms:o.dayMs,s:"d"},{ms:o.hourMs,s:"h"},{ms:o.minuteMs,s:"m"},{ms:o.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,r=""){if(!(0,a.isNumber)(t))return;if(0===t)return"0";if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const i=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const r=Math.floor(t/e.ms);t-=r*e.ms,r>0&&i.push(r+e.s)}return i.join(r)}},84248:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const i=r(50989);t.AutoVacuumModes=(0,i.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const i=r(50989);t.CheckpointTypes=(0,i.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const i=r(50989);t.RepairModes=(0,i.strEnum)("dump","recover")},34365:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const i=r(50989);t.SynchronousModes=(0,i.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const o=s(r(76760)),a=r(40958),l=r(22573),u=r(55835),c=r(72993),d=r(19851),h=r(97352),f=r(94174),m=r(44198),g=r(96706),p=r(8769),y=r(57159),v=r(70698),w=r(64680),S=r(29882),b=r(45969),P=r(43334),_=r(28874),E=r(41692),M=r(32774),C=r(80612),T=r(32551),x=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function D(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+x(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,g.getEnv)("TEMP"),(0,g.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const r of t)(0,l.blank)(r)||e.push({dir:(0,o.join)(r,".photostructure-cache"+x()),preexistingDir:r});return e}}function k(){if((0,b.isDocker)())return(0,a.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,o.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+x(),preexistingDir:M.DefaultDockerLibraryDir},...D()]);const e=(0,a.compactBlanks)(P.isWin?[(0,g.getEnv)("LOCALAPPDATA"),o.default.resolve((0,T.homeDir)(),"AppData","Local")]:P.isMac?[o.default.resolve((0,T.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,o.join)((0,T.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,r=e.map((e=>({dir:(0,o.join)(e,t),preexistingDir:e})));return r.push(...D()),r}t.tmpCacheDirs=D,t.tmpDirs=function(){return(0,C.filterDirs)({dirs:D(),desc:"tmp"})},t.cacheDirs=k,t.defaultCacheDir=(0,d.lazy)((()=>(0,C.firstDir)({dirs:k(),desc:"cache"})));const O=(0,d.lazy)((()=>{(0,E.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(I)}));function I(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,p.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{O();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=I},46292:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const i=r(19851),n=r(45969),s=r(41692),o=r(32774),a=r(10924),l=r(84373),u=r(80612);t.configDir=(0,i.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,n.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,a.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:o.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:o.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,n.isDocker)()?c:(0,a.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const i=r(66430),n=r(45969),s=r(32774);t.defaultLibraryDir=function(){return(0,n.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,n.isDocker)()&&(0,i.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const n=i(r(76760)),s=r(40958),o=r(72993),a=r(44198),l=r(96706),u=r(43334),c=r(80612),d=r(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),n.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(n.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,a.env)().XDG_DATA_HOME,(0,a.env)().XDG_CONFIG_HOME,n.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:n.default.join(e,(0,o.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const i=r(22573),n=r(96706),s=r(29882);t.envConfigDir=function(){const e=(0,n.getEnv)("PS_CONFIG_DIR");if(!(0,i.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const i=r(44652),n=r(40958),s=r(22573),o=r(66430);function a({dirs:e,desc:t}){for(const{dir:r,preexistingDir:a}of(0,n.compact)(e))if(!(0,s.blank)(r)){if((0,o.isReadWriteableDirectorySync)(r))return r;if((0,s.blank)(a)||(0,o.isReadWriteableDirectorySync)(a))try{return(0,i.mkdirpSync)(r),r}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=a,t.filterDirs=function({dirs:e,desc:t}){return(0,n.compact)(e.map((e=>a({dirs:[e],desc:t}))))}},32551:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const i=r(48161),n=r(76760),s=r(1708),o=r(19851),a=r(40958),l=r(68284),u=r(43334);t.homeDir=(0,o.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,a.compactBlanks)(e)){const e=(0,n.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,i.homedir)()}))},46296:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(55835),u=r(54993),c=r(72993),d=r(96706),h=r(45969),f=r(43334),m=r(32707),g=r(6707),p=r(49776),y=r(32774),v=r(80612),w=r(32551);function S(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:n.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,o.compact)((0,p.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>n.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,a.notBlank)(e))return e;const t=(0,g.readTomlFileSync)((0,m.systemSettingsFile)()),r=(0,u.toS)(t?.logDir);return(0,a.notBlank)(r)?r:b()}catch(e){return console.error("defaultLogDir_() failed",e),n.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const i=r(76760),n=r(19851),s=r(22573),o=r(44198),a=r(43334),l=r(24399),u=r(32551);async function c(){return a.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,n.lazy)((async()=>{if(a.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,n.lazy)((()=>(0,o.env)().XDG_PICTURES_DIR??(0,i.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const i=r(38639),n=r(7282),s=r(29325),o=r(44198);t.getDevEnvFlag=function(e){return!(0,n.isProd)()&&!(0,s.isPacked)()&&((0,i.toBoolean)((0,o.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,o.env)()[e]=String(t)}},34580:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const i=r(38639),n=r(44198);t.doNotTrack=function(){return(0,i.isTrue)((0,n.env)().DO_NOT_TRACK)}},44198:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const n=i(r(73024)),s=r(76760),o=i(r(1708)),a=r(19851),l=r(40958),u=r(41400),c=r(68708),d=r(76850),h=r(7282),f=r(32551),m=r(34102),g=r(53265),p=r(45969),y=r(59958),v=r(6012),w=r(96706);t.env=(0,a.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>o.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,p.isDocker)()||(0,h.isTest)()&&"lite"===o.default.env.PS_LICENSE||e.push((0,s.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),r={...o.default.env};for(const i of e)try{const e=(0,d.debom)(n.default.readFileSync((0,g.resolve)(i))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,i]of(0,c.entries)(s))t.test(e)||(r[e]=i)}catch(e){console.warn("env(): failed to read .env file, "+i,e)}return r})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const i=r(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,i.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const i=r(50989);t.EnvKeys=(0,i.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const i=r(22573),n=r(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const r={};if((0,i.blank)(e))return r;let s;for(const o of(0,n.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(o));){if(null==s.groups)continue;const{key:e,val:n}=s.groups;if((0,i.blank)(e)||null==n)continue;const o=n.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");r[t?e.toLowerCase():e]=o}}return r}},96706:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const n=i(r(1708)),s=r(19851),o=r(22573),a=r(38639),l=r(41400),u=r(40583),c=r(79840),d=r(83556),h=r(34102),f=r(44198),m=r(83373);function g(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function p(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,o.firstNotBlank)(n.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,n.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=g,(0,l.later)((()=>{f.env.watchLater(g),(0,h.ee)().on("clearCache",g)})),t.getEnv=p,t.isEnvTrue=function(e){return(0,a.isTrue)(p(e))}},98314:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const i=r(58587),n=r(19851),s=r(40958),o=r(22573),a=r(26905),l=r(96249),u=r(51926),c=r(23541),d=r(54993),h=r(89788),f=r(50213),m=r(81168),g=r(84542),p=r(41954),y=r(38835),v=r(70025),w=r(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,p.getErrorDescriptions)(e));const r=[...e.filter(c.isError).map(a.errorName),...e.map(a.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,g.splitCompactLines)(e))).flatMap((e=>e.split(a.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(r)))}function b(e){return(0,s.compact)(e).filter((e=>!a.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(o.notBlank)}function P(e,t){const r=(0,s.uniqSubstrings)(b(e)),i=t?.maxLen??400,n=t?.trailingChars??64,o=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(r.join(a.ErrorDelimiter)),i-o.length,n)+o.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,o.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,n.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new i.Rate,t.fatalErrorRate=new i.Rate,t.internalErrorRate=new i.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,o.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const r=(0,d.toS)(t?.[e]);if((0,o.notBlank)(r))return r}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,r=256,i=7){return(0,o.blank)(e)&&(e=t.MissingError),_(e,{maxLen:r})+" at "+(0,a.shortStack)(e?.stack,i).join("; ")}},41954:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const i=r(40958),n=r(26905),s=r(55835),o=r(54993),a=r(81168);t.describeError=function(e){const t=(0,a.stripSuffix)((0,o.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const r of e)(0,s.map)((0,n.errorErrno)(r),(e=>t.push(u.get(e)))),(0,s.map)((0,n.errorCode)(r),(e=>t.push(l[e]?.description)));return(0,i.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const i=r(40958),n=r(76790),s=r(50989),o=r(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,n.sortBy)((0,i.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(o.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const i=r(40958),n=r(38639),s=r(26905),o=r(54993),a=r(68852),l=r(73568),u=r(78656),c=r(98314),d=r(38835);function h(e){return(0,o.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const r=(0,o.toS)(e)+(0,i.compact)(t).join("");return h(r)+f(r).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const g=/Can't write [a-z\d]+ files/i,p=(0,a.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const r=(0,c.errorToS)(e);return!g.test(r)&&(!!p.test(r)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,n.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const r=(0,c.errorToS)(e);return!(!r.includes("EBUSY")&&!r.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const r=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>r.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,n.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,n.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},8769:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const i=r(22573),n=r(31586),s=r(68708),o=r(7282),a=r(23560),l=r(45608),u=r(34102),c=r(28874),d=r(98314),h=r(38835),f=r(70025),m=r(57159),g=r(5012);function p(e,t){try{if((0,i.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,g.stack)()),!1;const r=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const n=!0===r.fatal,c=!0===r.ignorable;if(!n&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),n&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",r));const h=!n||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:r}),!n||(0,o.isTest)()||(0,a.isWebService)()||(0,l.exit)({reason:r.toString(),status:r.errno??13}),n}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,n.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,a.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,n.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,n.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=p,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,r){return p(e+h.InternalErrorFlag,{cause:t,...r})}},57159:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const i=r(40958),n=r(22573),s=r(38639),o=r(26905),a=r(98553),l=r(68708),u=r(59455),c=r(41583),d=r(48884),h=r(81168),f=r(98314),m=r(38835),g=r(70025);t.toWrappedError=function(e,t){const r=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof p&&(null==t||(0,n.blank)(r.message)||e.message.includes(r.message)))return e;const i=(0,n.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,r?.message);return new p(i??"(missing error message)",r)};class p extends Error{constructor(e,t={}){super(e),this.causes=(0,i.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,o.errorName)(t)??(0,d.first)(this.causes,o.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(o.errorCode)],o.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,o.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.path))),this.flags=t?.flags??[];const r=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??r.some(g.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(r.map(g.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(r.map(g.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(r.map(g.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,g.stripErrorFlags)(function(e,t){let r=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const i=t?.path;return(0,n.blank)(i)||(r=(0,h.dedupeNeedle)(r,i,"file")),(0,f.joinErrorMessages)([r[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,a.stringify)(t.meta):void 0,...r.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new p(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=p},5012:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const o=r(49769),a=r(55835),l=r(54993),u=r(22911),c=r(89788),d=r(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,i.set(this,new Map),n.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,o.getOrSet)(s(this,i,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const r=this.target.emit(e,...t),o=s(this,i,"f").get(e);return null!=o&&(o.resolve(t),s(this,i,"f").delete(e)),r}emitDebounced(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},i=new WeakMap,n=new WeakMap},34102:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const i=r(78474),n=r(19851),s=r(15197);t.ee=(0,n.lazy)((()=>{const e=new i.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const n=i(r(73024)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(65843),u=r(16287),c=r(43334),d=(0,o.lazy)((()=>s.default.geteuid?.())),h=(0,o.lazy)((()=>s.default.getgroups?.()));function f(e,t){try{return!(0,a.blank)(e)&&(n.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,n.default.constants.R_OK|n.default.constants.W_OK):p({stat:e,r:!0,w:!0,x:!0})}function g(e,t){return c.isWin?f(t,n.default.constants.R_OK):p({stat:e,r:!0,x:!0})}function p({stat:e,r:t=!1,w:r=!1,x:i=!1,processUid:n,processGid:s}){if(null==e)return!1;const o=n??d(),a=null!=s?[s]:h()??[],l=0===o,u=l||e.uid===o,f=l||a.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(r&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!i||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=g,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const r of(0,l.selfAndAncestorG)(e)){const i=await(0,u.statMaybe)(r);if(null!=i){if(!i.isDirectory())return!1;if(t){if(!g(i,e))return!1}else if(t=!0,!m(i,e))return!1}}return!0},t.access=p},21144:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const n=i(r(76760)),s=r(19851),o=r(81168),a=r(57159),l=r(43334),u=r(88561),c=r(29882),d=r(65238),h=r(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const r=(0,c.parseNativePath)((0,h.resolve)(...e)),i=await m(r.dir);for(const e of await(0,d.readdir_)(i))if((0,o.equalsIgnoreCase)(e.basename,r.base))return n.default.join(i,e.basename);throw new a.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const i=r(73024),n=r(76760);function s(e){return[...o(e)]}function*o(e){for(;e!==(0,n.dirname)(e);)e=(0,n.dirname)(e),yield e}function a(e){try{return(0,i.readdirSync)(e)}catch(e){return[]}}function l(e,t){const r=a(e);return t.every((e=>r.includes(e)))}t.ancestors=s,t.ancestorG=o,t.selfAndAncestorG=function*(e){yield e,yield*o(e)},t.childrenSync=a,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,r){var i,n,s,o,a,l=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&l(t,e,r);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(r(44652)),g=c(r(73024)),p=r(51455),y=f(r(76760)),v=f(r(1708)),w=r(46466),S=f(r(57975)),b=f(r(38522)),P=r(19851),_=r(40958),E=r(5233),M=r(22573),C=r(42659),T=r(50357),x=r(96249),D=r(98553),k=r(55835),O=r(31586),I=r(68708),F=r(97790),L=r(39926),A=r(51926),N=r(59455),R=r(54993),j=r(48884),B=r(22911),V=r(99331),z=r(56519),W=r(56038),q=r(31562),U=r(76850),G=r(70025),H=r(34102),J=r(80875),$=r(50213),K=r(70417),Y=r(43334),Z=r(81168),X=r(96859),Q=r(65162),ee=r(94174),te=r(64660),re=r(21144),ie=r(84542),ne=r(89968),se=r(20197),oe=r(88561),ae=r(50597),le=r(33456),ue=r(29882),ce=r(78133),de=r(43899),he=r(65238),fe=r(53265),me=r(17217),ge=r(16287),pe=r(68284),ye=r(66003),ve=r(27794),we=r(73428),Se=r(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new oe.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(i.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,$.mkLogger)("fs.BaseFile("+this.nativePath+")"))),n.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),o.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(n=new WeakMap,o=new WeakMap,i=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),r=await Promise.all(t.map((e=>e.shaMs())));return t[(0,j.leastIndex)(r)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const r=(0,me.isSimpleFile)(e)?e.nativePath:(0,R.toS)(e);if((0,M.blank)(r))throw new Error("BaseFile.for(): empty nativePathOrFile");const i=be().get(r);if(null!=i)return i;const n=(0,fe.resolve)(r),s=new Pe(n,t);return be().set(r,s),be().set(n,s),s}static clear(e){(0,H.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,H.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,n,"f").unset(),h(this,o,void 0,"f"),this}clearThisAndParent(){return(0,H.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,z.thenMap)(this.stat(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,k.map)(this.statSync(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,n,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const r=[];for(const i of t)!0===await e(i)&&r.push(i);return r}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,z.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,i,"m",s).call(this)??await d(e=this.clearThisAndParent(),i,"m",s).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>g.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>g.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,z.thenMap)(this.children(),(async t=>{for(const r of t)await r.visitDescendants(e),await e(r)}))}async descendants(e){const t=[];t.push(...(0,N.toA)(await this.childFiles(e)));const r=await this.childDirectories();if(null==r)return t;for(const i of r)t.push(...(0,N.toA)(await i.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,O.gt0)(t))return;const r=await d(this,n,"f").call(this)??[];for(const t of r)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const i of r)if(i.isDirectory()){const r=await this._directoryEntryChild(i).someDescendant(e,t-1);if(null!=r)return r}}descendantsSync(e){const t=this.directoryEntrySync(),r=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&r.push(this.forDirectoryEntry(t))})),r}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,re.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,T.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,k.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,r)=>this.join((0,R.toS)(e),(0,L.pad2)(t+1),(0,L.pad2)(r))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,x.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,r="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(r,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,r="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(r,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,r){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(r??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,ge.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??await(0,ge.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??(0,pe.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,z.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,z.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,z.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,z.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,C.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,ge.statTimes)(e)}maxStatMs(){return(0,z.thenMap)(this.statTimes(),j.max)}maxStatDate(){return(0,z.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,z.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,z.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,z.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,z.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,z.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,z.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>=(0,C.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,z.thenMap)(this.mtimeMs(),(r=>Math.abs(r-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>(0,C.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,z.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,k.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,F.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,q.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*C.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,ae.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,ae.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,J.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,J.parseJSON)((0,g.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,g.readFileSync)(this.nativePath)}readFile_(){return(0,p.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,U.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,z.thenMap)(this.zReadFile_(e),R.toS)))}readLines(e="warn"){return(0,z.thenMap)(this.readTextFile(e),ie.splitLines)}readFileSync(){try{return g.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces),(0,I.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,E.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,V.ending)()?1:3,timeoutMs:0,retryDelay:C.secondMs,errorIsRetriable:G.isRetriableError})}async gunzip(){return d(this,i,"m",a).call(this,(0,Z.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,i,"m",a).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,i,"m",a).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return g.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return g.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const r=await this.children((async r=>!r.isNameHidden()&&t===r.size()&&r.nativePath!==e.nativePath));if((0,_.isEmpty)(r))return;const i=await e.sha();if(null!=i)for(const e of r.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===i)return e}))}firstMatchingLine(e){const t=new B.Deferred("firstMatchingLine("+this+")"),r=g.default.createReadStream(this.nativePath,{flags:"r"});return r.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),r.close()):t.maybeReject(e)})),r.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(r,(0,A.newlineRe)(),(i=>{const n=e.exec(i);null!=n&&(t.maybeResolve(n),r.close())})),t.promise}contemporary(e,t){return(0,z.thenMap2Or)(this.statTimes(),e.statTimes(),((e,r)=>{for(const i of e)for(const e of r)if((0,O.closeTo)(i,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),r=new B.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&r.setTimeout(e.timeoutMs),_e)try{const i=(0,g.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(i,n)=>{try{const s=await e.f(i,(0,k.denull)(n));t(s)&&r.resolve(s)}catch(e){r.reject(e)}}));r.finally((()=>{i.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,O.gt0)(e.intervalMs)){const i=setInterval((async()=>{try{const i=await e.f();t(i)&&r.resolve(i)}catch(e){r.reject(e)}}),e.intervalMs);e.persistent||i.unref(),r.finally((()=>{clearInterval(i)}))}return r}}t.BaseFile=Pe,s=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,j.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,k.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},a=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const r=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([g.default.createReadStream(this.nativePath,{autoClose:!0}),t,g.default.createWriteStream(r.nativePath,{autoClose:!0})]),await this.unlink(),r}))},Pe.attrTTL=3*C.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},84542:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const i=r(40958),n=r(96249),s=r(51926),o=r(54993),a=r(43334);function l(...e){return(0,n.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,o.toS)(e).split((0,s.newlineRe)()))))}t.Newline=a.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(o.toS).join("\n");return a.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,i.compactBlanks)(l(...e))}},70698:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const i=r(76760),n=r(19851),s=r(50213),o=r(37805),a=r(29882),l=r(93854),u=r(17217),c=r(16287),d=r(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,n.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const r=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return r===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,i.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const r=(0,u.toNativePath_)(e);await(0,a.mkdirp_)(r),await(0,d.writeTextfile_)((0,a.joinNativePath)([r,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+o.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(45969),u=r(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,o.lazy)((()=>[...(0,a.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,n.default.join(e,"System32"),n.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const a=s(r(44652)),l=o(r(73024)),u=r(76760),c=r(57975),d=r(19851),h=r(59455),f=r(50213),m=r(81168),g=r(34102),p=r(29882),y=r(65238),v=r(14427),w=r(17217),S=r(16287),b=r(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class E{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,p.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new E(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:r,base:i}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,p.parseNativePath)(e)},n=await a.stat(t);return new E(r,new P(i,n))}clear(){return(0,g.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return E.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,p.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,p.parseNativePath)(this.dir);return e.dir===this.dir?this:new E(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>E.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new E(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const r of t)r.isDirectory()&&await r.visitDescendants(e);for(const r of t)r.isFile()&&await e(r);for(const r of t)r.isDirectory()&&await e(r)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const r of t)r.isFile()&&e(r);for(const r of t)r.isDirectory()&&(r.visitDescendantsSync(e),e(r))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async r=>{!0===await e(r)&&t.push(r)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await a.unlink(this.nativePath),(0,g.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await a.rmdir(this.nativePath,e),(0,g.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=E},20197:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const n=i(r(76760)),s=r(39926),o=r(29882),a=r(16287),l=r(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if(await(0,o.mkdirp_)(i.dir),!r.requireNumber&&await(0,a.isEmptyFile)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if(await(0,a.isEmptyFile)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)},t.ensureNewNativePathSync_=function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if((0,o.mkdirpSync_)(i.dir),!r.requireNumber&&(0,l.isEmptyFileSync)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if((0,l.isEmptyFileSync)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)}},88561:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const o=r(40958),a=r(22573),l=r(41400),u=r(68708),c=r(25764),d=r(38836),h=r(34102),f=r(80049),m=r(50213),g=r(88158),p=r(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:p.ShortCommandTimeoutMs,...e}),i.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>s(this,i,"m",n).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,g.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,o.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,i=new WeakSet,n=async function(e){if((0,a.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const i=r(73024),n=r(22573),s=r(45599),o=r(96249),a=r(68708),l=r(54993),u=r(49047),c=r(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,s.defer)((()=>{const e={};for(const[t,...r]of d)for(const i of r)e[i]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof i.Dirent?e.name:(0,l.toS)(e),r=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,n.blank)(r)?void 0:h()[r]??r}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,o.flatten)((0,a.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const r of t)if(r===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const i=r(68708),n=r(17217),s=r(16287),o=r(68284);async function a(e){return(0,i.pick)(await(0,s.stat_)((0,n.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=a,t.fileStats=async function(e){try{return await a(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,o.statSync)((0,n.toNativePath)(e)))?void 0:(0,i.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},4001:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const i=r(22573),n=r(55835),s=r(31586),o=r(51926),a=r(54993),l=r(97352),u=r(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,i.toNotBlank)(e.name)??(0,a.toS)(e),t).normalize()}function f(e,r){if(t.ymdIsoRE.test(e))return e;let i=e;for(const e of r.aggressive?d:c){const t=i.match(e);if((0,s.gt0)(t?.index)){const e=i.slice(0,t.index).trim();e.length>0&&(i=e)}}return e===i?e:f(i,r)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),r=t.pop();if((0,i.blank)(r))return e;const n=(0,u.parsePosixPath)(r),s=h(n,{aggressive:!1});return[...t,s+n.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,o.isString)(e)?e:e.name).toLowerCase().normalize(),r=h(t),i=(0,o.stripPrefix)(t.toLowerCase().normalize(),r);return(0,n.map)((0,l.extractInt)(i),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,g=/(?<=.{6})_cover$/i,p=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,o.isString)(e)?e:e.name).trim().replace(g,"").trim();return(0,n.map)(m.exec(t),(e=>t=e[1].trim())),(0,n.map)(p.exec(t),(e=>t=e[1].trim())),t}},14977:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const n=i(r(44652)),s=i(r(73024)),o=r(46466),a=i(r(38522)),l=r(49769),u=r(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,o.pipeline)(s.default.createReadStream(e,{autoClose:!0}),a.default.createGzip(),s.default.createWriteStream(t,{autoClose:!0})),await n.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const n=i(r(77598)),s=i(r(73024)),o=r(46466),a=r(19851),l=r(98553),u=r(68708),c=r(23467),d=r(80049),h=r(73913),f=r(50213),m=r(12089),g=r(37628),p=r(43624),y=r(17217),v=r(16287),w=(0,a.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),S=(0,a.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:r=!0}={}){const i=(0,y.toNativePath_)(e);if(r){const t=S().get(i);if(null!=t){if((0,c.eql)(t.stats,await(0,p.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:i,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:i,prior:t}),S().delete(i)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),r=(0,y.toNativePath_)(e);return{sha:await _(s.default.createReadStream(r)),stats:(0,u.pick)(await(0,v.stat_)(r),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],r="sha512"){const i=n.default.createHash(r);return await(0,o.pipeline)([e,...t,i]),i.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,g.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return n.default.randomBytes(h.HashBits/8).toString("base64")}},25675:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const i=r(22573),n=r(54993),s=r(7282),o=r(43334),a=r(69375),l=/^\/dev(?:\/|$)/i,u=o.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=o.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=o.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=o.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,n.toS)(e))}function m(e){return(0,i.blank)(e)?"blank":(0,a.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},33456:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const i=r(57075),n=r(51926),s=r(54993);class o extends i.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,r){const i=(this._prior+(0,s.toS)(e)).split((0,n.newlineRe)()),o=i.pop();this._prior=o??"";let a=!1;for(const e of i)a||(a=!this.push(e));a?setTimeout(r,1):r()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=o},64680:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const n=i(r(76760)),s=r(17217),o=r(73428);t.mkNoMedia_=function(e){return(0,o.writeTextfile_)(n.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},29882:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(5233),u=r(22573),c=r(98553),d=r(39426),h=r(51926),f=r(48884),m=r(50213),g=r(81168),p=r(70025),y=r(43334),v=r(78133),w=r(53265),S=r(17217),b=r(16287),P=r(66430),_=r(5545);function E(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,o.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=E,t.containsHiddenPathname=function(e){return k(e).some(E)},t.isNotHiddenPosixPath=function(e){return k(e).every((e=>!E(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return C((0,v.posix2native)(e))},t.extname=function(e){return C(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,g.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function C(e){const t=M.exec(e)?.groups,r=t?.ext2??"",i=s.default.parse(t?.path??e);return{...i,ext:(i.ext??"")+r,base:(i.base??"")+r}}function T(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,s.default.sep)}function x(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),r=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(r))return!1;const i=e.acceptSelf??!1;return t===r?i:r.startsWith((0,g.ensureSuffix)(t,s.default.sep))}catch(r){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:r}),!1}}function D(e,t,r){if(null==t||null==r)return!1;const i=e(t),n=e(r);return null!=i&&null!=n&&(y.isLinux?i===n:(0,g.equalsIgnoreCase)(i,n))}function k(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function O(e){return(0,u.notBlank)(e)&&k(e).length===(y.isWin?1:0)}function I({p:e,maxLength:t}){const r=(0,S.toNativePath_)(e);if(r.length<=t)return r;const i=k(e),n=[],s=[i.pop()];for(;i.length>0;)if(n.length=t){i.unshift(n.pop());break}}else if(s.unshift(i.pop()),L([...n,...s]).length>=t){i.push(s.shift());break}return i.length>0&&n.push("…"),L([...n,...s])}function F(e){return e.startsWith("\\\\")}function L(e){return(0,h.ensurePrefix)((0,a.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=C,t.parentBasename=T,t.grandParentBasename=function(e){return T(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=x,t.eqlBasename=function(e,t){return D(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return D(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return D(S.toNativePath_,e,t)},t.toPathnames=k,t.pathIsRoot=O,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:k(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const r=(0,S.toNativePath_)(e),i=(0,S.toNativePath_)(t);if((0,u.blank)(r)||(0,u.blank)(i))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return r===i?"":(0,g.stripPrefix)((0,v.native2posix)(i).normalize(),(0,g.ensureSuffix)((0,v.native2posix)(r),"/").normalize()).normalize()},t.ellipsizePath=I,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:r=4,arrLength:i=e.length}){const n=[];for(const i of e.slice(0,r))n.push(I({p:i,maxLength:t}));return n.join(", ")+(i>r?`, and ${i-r} more…`:"")},t.posixPathFromParent=function(e){return k(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return k(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const r=C(e);return`${r.base}${t}${r.ext}`},t.isUNC=F,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(F(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(O(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await n.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;n.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>n.default.move(e,t,{overwrite:!0})),{errorIsRetriable:p.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=L,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:L(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>x({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(31586),u=r(51926),c=r(12168),d=r(59455),h=r(54993),f=r(50213),m=r(44198),g=r(96706),p=r(45969),y=r(43334),v=r(64660),w=r(21144),S=r(16287),b=(0,s.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const r=await(0,S.statMaybe)(e,"trace");return null!=r&&r.isFile()&&(0,l.gte)(r.size,t)&&(0,v.isStatRX)(r,e)}function E(){if(y.isWin){const e=(0,a.toNotBlank)((0,g.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,a.toNotBlank)((0,g.getEnv)("SystemDrive"))??"C:",r=(0,a.toNotBlank)((0,g.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,n.default.join(e,"System32"),n.default.join(e,"System32","Wbem"),n.default.join(r,"chocolatey","bin"),n.default.join(t,"cygwin64","bin")]}return[...(0,p.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(n.default.delimiter);return(0,o.uniq)((0,o.compactBlanks)([...e,...E()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:r}){const i=(0,o.uniq)((0,o.compactBlanks)([...M(),...(0,d.toA)(r)]));for(const r of(0,o.uniq)((0,o.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(r,".exe"):r;for(const t of i){const r=n.default.join(t,e);if(await _(r))return y.isLinux?r:(0,w.actualPath)(r)}}b().warn("Failed to find tool",{tool:e,dirs:i})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},78133:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const n=i(r(76760)),s=r(22573),o=r(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(n.default.sep===n.default.posix.sep)return e;const r=(0,s.notBlank)(t)?n.default.sep+n.default.sep+t+n.default.sep:"",i=e.split(n.default.posix.sep);return(0,o.equalsIgnoreCase)(i[0],t)&&i.unshift(),r+i.join(n.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||n.default.sep===n.default.posix.sep||n.default.posix.sep===n.default.sep?e:e.split(n.default.sep).join(n.default.posix.sep)}},43899:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(48884),u=r(50213),c=r(45969),d=r(29325),h=r(43334),f=r(65843),m=r(25675),g=r(53265);function p(...e){return(0,o.lazy)((()=>n.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,o.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(n.default.join((0,g.execDir)(),"resources"),n.default.join((0,g.execDir)(),"..","Resources")),t.push(...(0,a.compactBlanks)([(0,g.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const r of t){if((0,f.hasChildrenSync)(r,e))return r;for(const t of(0,f.ancestors)(r).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const i=n.default.join(r,"node_modules","photostructure");if((0,f.hasChildrenSync)(i,e))return i}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:p("bin"),Data:p("data"),ICC:p("data","icc"),Migrations:p("data","migrations"),Public:p("public"),Tools:p("tools"),Views:p("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const i=r(44652),n=r(19851),s=r(31586),o=r(50213),a=r(57902),l=r(69428),u=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=a.LogLevels.info){try{return await(0,i.readFile)(e)}catch(r){return void u().log(t,".readFileMaybe("+e+")",r)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const i=r(44652),n=r(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:r}){let s=-1;try{const n=r??(await(0,i.stat)(e)).size-t,o=Buffer.alloc(n);return s=await(0,i.open)(e,"r"),await(0,i.read)(s,o,0,n,t)}finally{(0,n.mapGte0)(s,i.close)}}},69428:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const o=s(r(73024));t.readFileSync=function(e){try{return o.readFileSync(e)}catch{}}},32323:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const i=r(57075);class n extends i.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=n},65238:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const n=i(r(51455)),s=r(76760),o=r(19851),a=r(76790),l=r(22573),u=r(42659),c=r(41400),d=r(31586),h=r(13538),f=r(83104),m=r(54127),g=r(50213),p=r(95937),y=r(34102),v=r(28874),w=r(63870),S=r(88561),b=r(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,o.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,o.lazy)((()=>(0,g.mkLogger)("fs.Readdir")));async function _(){try{await n.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const E=(0,o.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||E.prior()?.delete(e)}async function C(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await E().getOrSetAsync(e,(()=>async function(e){const r=Date.now()+2*(0,b.statTimeoutMs)(),i=T(e),n=await(0,h.thenOrTimeout)(i,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(n===f.Timeout&&(0,p.onTimeout)({soft:!1}),n!==f.Timeout&&n.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),E.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,o.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!E().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=E().get(e)},t.childDirectories_=async function(e){return(await C(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?C(e):T(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=C,t.readdirCached=function(e){return E().get(e)},t.readdirUncached_=T},53265:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const n=r(73024),s=i(r(76760)),o=r(40958),a=r(22573),l=r(45599),u=r(50213),c=r(43334),d=r(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,o.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function g(...e){for(const t of m()){const r=s.default.resolve(t,...e);if((0,n.existsSync)(r))return r}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,a.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(a.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?g(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=g},50274:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const i=r(50989);t.SidecarExts=(0,i.strEnum)("xmp","mie","exv")},14427:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const i=r(22573),n=r(38639);t.isSimpleDirent=function(e){return null!=e&&(0,i.notBlank)(e.basename)&&(0,n.isBoolean)(e.isFile)&&(0,n.isBoolean)(e.isDirectory)}},17217:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const n=i(r(73024)),s=i(r(76760)),o=r(22573),a=r(98553),l=r(81168),u=r(43334),c=r(29882),d=r(53265),h=r(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,o.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,o.blank)(e.nativePath))throw new Error(`toNativePath(${(0,a.stringify)(e)})`);return e.nativePath}function g(e){return e instanceof n.default.Dirent?e.name:f(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=g,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(g(e)).name},t.dirname=function(e){return f(e)?e.dir:s.default.dirname(m(e))};const p=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(p)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),r=t.indexOf(s.default.sep);return r>0?t.slice(1,r):void 0}},t.findFileIndex=function(e,t){for(let r=0;r(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,a.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(n.default.stat(e),(0,p.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,a.blank)(e)?void 0:v(e).catch((r=>{y().log(t,"stat() failed",{error:r,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const r=S(e),i=S(t);if(r!==i)return"inconsistent file type: "+r+" ≠ "+i;for(const r of["size","mtime"]){const i=e[r],n=t[r],s=(0,u.diff)(b(i),b(n));if(null==s||s>1)return"unmatched "+r+": "+i+" ≠ "+n}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const r=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=r&&!(t?.emptyIsNew??1))&&(0,g.isEmptyStats)(r)},t.isNonEmptyFile=async function(e,t=0){const r=await w(e);return null!=r&&r.isFile()&&r.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.access)({stat:r,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.isStatRWX)(r,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,o.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const n=i(r(73024)),s=r(22573);function o(e){try{return(0,s.blank)(e)?void 0:n.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function a(e){return null==e||e.isFile()&&0===e.size}t.statSync=o,t.isEmptyStats=a,t.isFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const r=o(e);return t.emptyIsNew?null==r:a(r)},t.isNonEmptyFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isDirectorySync=function(e){return!0===o(e)?.isDirectory()}},41080:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const i=r(28874);t.statTimeoutMs=function(){return i.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const i=r(22573),n=r(56409);t.onDataChunked=function(e,t,r){const i=new s(t,r,!0);return i.read(e),i.done};class s{constructor(e,t,r=!0){this.sep=e,this.onData=t,this.filterBlanks=r,this.incompleteChunk="",this.done=new n.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,i.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,i.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const n=i(r(57075)),s=r(41400),o=r(55835),a=r(68708),l=r(42279),u=r(99331),c=r(70025);class d extends n.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((r,i)=>{!1===e.write(t,(e=>{e&&i(e)}))?e.once("drain",r):r()}))},t.endStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,a.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:r,ea:i}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,o.map)(i,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(r,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends n.default.Transform{constructor(e){super({transform:(e,t,r)=>{this.onProgress(this.bytes+=e.length),r(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const n=i(r(73024)),s=r(76760),o=r(22573),a=r(76596),l=r(64660),u=r(78133),c=r(68284);function d(e){if((0,o.blank)(e))return!1;try{return n.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,a.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,o.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,o.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,o.blank)(e)&&d((0,u.posix2native)(e))}},27794:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const n=i(r(44652)),s=r(19851),o=r(22573),a=r(42659),l=r(31586),u=r(68708),c=r(13538),d=r(29882),h=r(17217),f=r(16287),m=r(41080);function g(e){return null==e?void 0:(0,a.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const r=t.ensureFile??!0;if(null==t.file||(0,o.blank)(t.file))throw new Error("can't touch blank path");const i=(0,h.toNativePath_)(t.file);r&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const a=(0,s.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(g(t.mtimeMs)??(await a())?.mtimeMs??Date.now()),p=Math.round(g(t.atimeMs)??(await a())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(n.default.utimes(i,new Date(p),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!r||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(n.default.ensureFile(i),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},5545:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const n=i(r(76760)),s=r(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const r=t.driveRe.exec(e)?.groups;return null==r?e:r.drive.toUpperCase()+(0,s.toS)(r.path??n.default.sep)}},58722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const i=r(57075),n=r(22911);class s extends i.Writable{constructor(e){super(e),this.deferred=new n.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,r){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),r()}}t.WritableToBuffer=s},73428:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(51926),a=r(54993),l=r(34102),u=r(84542),c=r(29882);async function d(e,t){const r=s.default.dirname(e);await(0,c.mkdirp_)(r),await n.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",r)}function h(e,t){const r=s.default.dirname(e);(0,c.mkdirpSync_)(r),n.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",r)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const r=(0,u.crlf)(...(0,o.wrap)(t));await d(e,r)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))}},13047:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const n=i(r(73024)),s=r(76760),o=r(46466),a=r(38522),l=r(19851),u=r(40958),c=r(98553),d=r(80875),h=r(50213),f=r(57159),m=r(29882),g=r(57902),p=r(32323),y=r(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,r){const i=[],s=[n.default.createReadStream(e,{autoClose:!0,...r}).on("error",(e=>i.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,a.createGunzip)().on("error",(e=>i.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,a.createBrotliDecompress)().on("error",(e=>i.push(e)))),s.push(t),await(0,o.pipeline)(s),(0,u.isNotEmpty)(i))throw new f.WrappedError("zPipe("+e+") failed",{causes:i,path:e})}async function b(e,t){const r=new y.WritableToBuffer;return await S(e,r,t),await r.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function _(e,t){const r=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,o.pipeline)(new p.ReadableBuffer(r),(0,a.createGzip)(),n.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=g.LogLevels.warn){try{return await P(e)}catch(r){return void v().log(t,"readJsonGz("+e+"): failed",r)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,r=g.LogLevels.warn){try{await _(e,t)}catch(t){v().log(r,"outputJsonGz("+e+"): failed",t)}}},33866:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const i=r(50989);t.HealthCheckIds=(0,i.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},52086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const i=r(50989);t.CropStrategies=(0,i.strEnum)("center","entropy","attention")},48584:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const i=r(50989);t.SharpFailOns=(0,i.strEnum)("none","truncated","error","warning")},49794:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const i=r(57975),n=r(19851),s=r(40958),o=r(22573),a=r(54993),l=r(37975),u=r(7282),c=r(23560),d=r(28874),h=r(66184),f=r(93475),m=(0,n.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function g(e){if((0,o.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=g,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=g(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,i.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,s.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:g(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,r,i){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:r,meta:i})}}},32105:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const i=r(19851),n=r(23560),s=r(66184),o=r(72210);class a{log(e,t,r,i){this.enabled(e,t)&&(0,o.pushLogEntries)({ts:Date.now(),l:e,from:(0,n.processName)(),ctx:t,msg:r,meta:i})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=a,a.instance=(0,i.lazy)((()=>new a))},14593:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const i=r(57975),n=r(22573),s=r(26905),o=r(55835),a=r(68708),l=r(13538),u=r(50213),c=r(97352),d=r(45255),h=r(76740),f=r(57159),m=r(57902),g=/logger|lazy/i;class p{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,n.toNotBlank)(e)??(0,s.shortStack)().find((e=>!g.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[i.inspect.custom](){return this.toLogJSON()}addContext(e){return new p(this.context+e,this.loggers)}addParameterContext(e){return new p(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const r=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,a.omit)(t,"error")});throw Error.captureStackTrace?.(r),this.log(!0===r.ignorable?"warn":"error",".throw() "+r.message,{stack:r.stack,...t}),r}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let r;try{r=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const i=e.result(),n=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:i,meta:{...e.meta,elapsedMs:n}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,o.map)(r,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,a.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const r of this.loggers())if(r.enabled(e,t??this.context))return!0;return!1}log(e,t,r){for(const i of this.loggers())i.log(e,this.context,t,r)}elapsed(e,t,r){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...r})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=p},89179:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const i=r(50213),n=r(43705);t.currentFileLogger=function(){return(0,i.rootLoggers)().find((e=>e instanceof n.LogWriter))}},28981:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const i=r(19851),n=r(51879);t.DefaultLogFormatter=(0,i.lazy)((()=>new n.PlaintextLogFormatter))},31256:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(41400),a=r(98553),l=r(55835),u=r(31586),c=r(68708),d=r(72993),h=r(23560),f=r(81168),m=r(98314),g=r(57902),p=r(93475),y=(0,i.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,r]=e.split("-",2);return(0,s.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(r)}}}(0,o.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,g.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,n.uniq)((0,n.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,a.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,p.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,a.stringify)(t)])))})}format(e,t,r,i){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:r,meta:i})}}},51576:function(e,t,r){var i,n=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const s=r(77030),o=r(19851),a=r(22573),l=r(42659),u=r(41400),c=r(98553),d=r(56409),h=r(31586),f=r(25764),m=r(38836),g=r(50213),p=r(409),y=r(28874),v=r(31256),w=r(28538),S=(0,o.lazy)((()=>(0,g.mkConsoleLogger)("log.LogBroadcaster"))),b=String.fromCharCode(0);t.logBroadcaster=(0,o.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),r=(0,h.toInt)(t);return(0,a.blank)(e)||!(0,h.gt0)(r)?void 0:{host:e,port:r}}();return null==e?void(y.Settings.logServer.hasValue()&&S().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),i.set(this,(0,p.rateLimited)({f:async()=>{try{const e=this.socket=(0,s.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{S().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){S().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),n(this,i,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,r,s){if(this.enabled(e,t))try{const o=this.socket;null==o?n(this,i,"f").call(this):o.write(this.logFormatter.format(e,t,r,s)+b)}catch(i){S().warn("Failed to write log entry to socket",{level:e,context:t,msg:r,meta:s,error:i})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}i=new WeakMap},20839:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const i=r(76760),n=r(42659),s=r(28874);t.datedLogDir=function(e,t){return(0,i.join)(e??s.Settings.logDir.valueOrDefault,(0,n.fmtIsoDate)(t??new Date))}},4904:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const i=r(76790),n=r(31586),s=r(51926),o=r(57902);t.isLogEntry=function(e){return null!=e&&(0,n.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&o.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,i.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const i=r(19851),n=r(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,n.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,n.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,i.lazy)((()=>new s(n.LogLevels.warn))),t.defaultLogLevel=(0,i.lazy)((()=>n.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,n.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,r){return(0,t.logFilter)().enabled(e)?r():void 0},t.isLogged=function(e,r){return(0,t.logFilter)().enabled(e,r)}},28538:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=r(19851),u=r(40958),c=r(22573),d=r(54993),h=r(28874),f=r(66184),m=r(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){i.add(this),this.setting=e,this.silent=!1,n.set(this,[]),s.set(this,(0,l.lazy)((()=>{a(this,n,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const r of t){const t=f.LogLevelRe.exec(r.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+r+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),r=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=r:a(this,n,"f").push({prefix:e,levelIndex:r})}}}))),e.watch((()=>a(this,s,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const r=(0,m.levelIndex)(e);if(null!=t){const e=a(this,i,"m",o).call(this,t);if(null!=e)return r<=e.levelIndex}return r<=this.defaultLevelIndex}highlight(e){const t=a(this,i,"m",o).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},n=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(e){if(null==e||0===a(this,n,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return a(this,n,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const i=r(42659),n=r(31586),s=r(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const o=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??o},t.levelGte=function(e,r){return(0,n.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(r))};const a=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return a.get(e)},t.msTolevel=function(e,t=7*i.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const i=r(40958),n=r(68708),s=r(20214),o=r(51926),a=r(23541),l=r(48884),u=r(88158),c=r(98314),d=r(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(r,h=4){if(null==r)return null;if(h<0)return"…";if((0,o.isString)(r)||Buffer.isBuffer(r))return(0,o.ellipsize)(r.toString(),256,32);if((0,a.isError)(r))return(0,c.errorToVerbose)(r);if(Array.isArray(r)){const t=d.Settings.logContextLimit.valueOrDefault,i=Math.floor(t/2);return r.length<=t?r:[...r.slice(0,i).map((t=>e(t,h-1))),`… (${r.length} total entries)`,...r.slice(-i).map((t=>e(t,h-1)))]}if("object"==typeof r||"function"==typeof r){for(const t of["toLogJSON","toJSON"])if("function"==typeof r[t])return e(r[t](),h-1);if((0,s.isPromiseLike)(r))return t.PromisePlaceholder;if("…"in r)return r;const a=(0,u.mapNullEntries)(r,((t,r)=>e(r,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,n.keys)(r),(0,n.keys)(a));return(0,i.isNotEmpty)(c)&&(a["…"]="omitted: "+(0,o.ellipsize)(c.join(", "),128,32)),a}return r}},24068:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const i=r(73024),n=r(76760),s=r(1708),o=r(87997),a=r(19851),l=r(22573),u=r(42659),c=r(49769),d=r(55835),h=r(34666),f=r(20214),m=r(7282),g=r(23560),p=r(54826),y=r(82328),v=r(22277),w=r(25764),S=r(38836),b=r(99331),P=r(42638),_=r(76596),E=r(98314),M=r(89968),C=r(29882),T=r(28874),x=r(28981),D=r(20839),k=r(21727),O=r(66184),I=r(57902),F=r(72210),L=r(98192);function A(e){const t=(0,x.DefaultLogFormatter)();for(const r of e)(0,p.consoleLog)(t.formatLogEntry(r))}t.DefaultLogEntryWriter=A;class N extends S.EndableWrapper{constructor(e=void 0,t=A){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,a.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,T.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,p.consoleLog)("tailing "+e+"..."),await(0,C.mkdirp_)(e),this.root=await M.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=n.sep+(0,g.serviceName)()+"-"+s.pid+"-",s.stdout.writableFinished||((0,F.setLogTailEnabled)(!0),this.flushTimeout=(0,o.setInterval)((()=>this.flush()),D.DefaultLogFlushMs/2),this.scanTimeout=(0,o.setInterval)((()=>this.scan()),u.minuteMs),s.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,F.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,b.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,O.ifLog)(I.LogLevels.debug,(()=>(0,p.consoleLog)("LogTail(): watching "+e)));try{return(0,i.watch)(e,((t,r)=>{(0,l.notBlank)(r)&&this.watchListener(t,(0,n.join)(e,r))}))}catch(t){return void(0,O.ifLog)(I.LogLevels.warn,(()=>(0,p.consoleError)("LogTail(): failed to read "+e+": "+(0,E.errorToS)(t))))}}))}async scan(e=!1){if((0,b.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,_.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,b.ending)()||this.ended)return;const t=(0,k.datedLogDir)(this.root.nativePath);try{await(0,C.mkdirp_)(t),this.watchDir(t)}catch(e){(0,O.ifLog)(I.LogLevels.warn,(()=>(0,p.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,E.errorToS)(e))))}(0,b.ending)()||this.ended||e&&(0,p.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,F.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,o.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,o.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,F.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await M.DirectoryEntry.for(t);if(null==e)return;const r=e.size();if(null==r||r<=0)return;const i=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(i,r))return;await(0,f.thenMap)((0,L.readLogEntries)(e,{start:i,end:r}),(e=>(0,F.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,r)}catch(e){(0,O.ifLog)(I.LogLevels.warn,(()=>(0,p.consoleError)("Failed to read "+t+": "+(0,E.errorToS)(e))))}}))}}t.LogTail=N,N.instance=(0,a.lazy)((()=>(0,y.stdoutEnded)()?void 0:new N))},72210:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const i=r(92322),n=r(82328),s=r(28981),o=r(20839),a=r(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new i.SortedSet(a.logEntrySorter),t.pushLogEntries=function(...e){for(const r of e)l?t.logEntries.add(r):(0,n.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(r))},t.popExpiredLogEntries=function(e=2*o.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(r(73024)),f=r(76760),m=r(19851),g=r(42659),p=r(41400),y=r(98553),v=r(31586),w=r(409),S=r(23560),b=r(81168),P=r(78406),_=r(25764),E=r(20197),M=r(14977),C=r(36868),T=r(28874),x=r(32105),D=r(20839),k=r(21727),O=r(66184),I=r(93475),F=r(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,r,i){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:r,meta:i})}enabled(){return!0}end(){}async flush(){}};class L extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*D.DefaultLogFlushMs),rank:_.EndableRanks.logger,unref:!0,onEnd:()=>c(this,n,"f").call(this)}),i.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,g.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*g.secondMs,n.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,i,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:x.ConsoleLogger.instance(),flushEveryMs:D.DefaultLogFlushMs,processName:S.processName,logFilter:O.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,i,"m",s).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,r,i){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,r,i);else{const n={ts:Date.now(),l:e,ctx:t,msg:r};null!=i&&(n.meta=(0,I.prepMeta)(i)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(n)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,F.recentLogEntries)()),(0,F.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=L,n=new WeakMap,i=new WeakSet,s=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,i,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const r=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),n=e.splice(0,r);this._linesSinceRotate+=n.length,t.write(n.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},o=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},a=function(e){return t=>(c(this,i,"m",o).call(this,e,t),c(this,i,"m",u).call(this))},l=async function(){await c(this,i,"m",u).call(this);const e=(0,b.stripAnsiEsc)(this.logOpts.processName()),t=await(0,E.ensureNewNativePath_)({nativePath:(0,f.join)((0,k.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),r=h.default.createWriteStream(t).on("error",c(this,i,"m",a).call(this,"file write stream"));this._logfile={stream:r,nativePath:t},this._nextForcedRotateTs=(0,g.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,C.endStream)(e.stream),T.Settings.logCompression.valueOrDefault&&(await(0,p.delay)(this.logOpts.flushEveryMs),await(0,M.gzip_)(e.nativePath))}catch(e){c(this,i,"m",o).call(this,"_closeCurrent()",e)}}},51879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(68708),a=r(54993),l=r(23560),u=r(81168),c=r(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,o.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,n.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,i.inspect)(e,this.inspectOptions)))]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,r,i){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:r,meta:i})}}},98192:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const i=r(22573),n=r(84542),s=r(4001),o=r(13047),a=r(4904);function l(e){if(!(0,i.blank)(e))try{const t=JSON.parse(e);return(0,a.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const r=(0,s.stripCopySuffixFromName)(e.name),i=[],a=await(0,o.zcat)(e.nativePath,t);if(null!=a)for(const e of(0,n.splitLines)(a)){const t=l(e);null!=t&&i.push({...t,from:r})}return i},t.chunkToLogEntry=l},22662:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const i=r(19851),n=r(76790),s=r(68708),o=r(89788),a=r(57902);t.SentLogLevels=(0,i.lazy)((()=>a.LogLevels.values.filter((e=>e!==a.LogLevels.trace))));const l=(0,i.lazy)((()=>(0,s.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new o.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,s.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,s.values)(l()))e.push(...t.toA());return(0,n.sortBy)(e,(e=>e.ts))}},17181:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const i=r(76760),n=r(41400),s=r(55835),o=r(37975),a=r(50213),l=r(27395),u=r(46296),c=r(96706),d=r(73428),h=r(28874),f=r(49794),m=r(32105),g=r(89179),p=r(28981),y=r(51576),v=r(66184),w=r(28538),S=r(24068),b=r(43705),P=r(51879);function _(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),E();const e=(0,u.logDir)();let t=(0,g.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,i.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new b.LogWriter(e));const r=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&r.push(m.ConsoleLogger.instance()),(0,s.map)((0,y.logBroadcaster)(),(e=>r.push(e))),a.rootLoggers.set(r),h.Settings.tailLogs.valueOrDefault&&S.LogTail.instance()}function E(){const e=h.Settings.logColor.valueOrDefault;(0,o.setColorEnabled)(e),p.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=_,t.setupLogFormatter=E,(0,n.later)((()=>{h.Settings.logStdout.watchLater(_),h.Settings.logDir.watchLater(_),h.Settings.tailLogs.watchLater(_),h.Settings.logColor.watchLater(E),h.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},36389:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=i(r(1708)),s=r(24068),o=r(40958),a=r(5670),l=r(69554),u=r(38790),c=r(46296);!async function(){const e=(0,c.logDir)(),t=await new l.CLI(a.ServiceNames.logtail,"[LOG_DIR]","Normally logtail watches all files in the default logging directory, "+e+". Specify LOG_DIR or set the PS_LOG_DIR environment variable to override this directory.").add(u.ColorArgs).parse();n.default.on("SIGINT",(()=>n.default.exit(0))),n.default.on("SIGTERM",(()=>n.default.exit(0)));const r=(0,o.compactBlanks)(t.args);new s.LogTail(r[0]??e)}()},82647:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const o=r(57975),a=r(40958),l=r(96249),u=r(55835),c=r(31586),d=r(68708),h=r(59455),f=r(48884),m=r(89788),g=r(22454),p=r(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const r=t.clone();return r.pushAll(e.samples),r}if(t.n<=t.maxSamples){const r=e.clone();return r.pushAll(t.samples),r}{const r=new y(Math.max(e.maxSamples,t.maxSamples));r._n=e.n+t.n,r._min=Math.min(e._min,t._min),r._max=Math.max(e._max,t._max),r._m=e._m*e.n/r.n+t._m*t.n/r.n,r._s=e._s*e.n/r.n+t._s*t.n/r.n;const i=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return r._samples.push(...i),r._weightedTotalAvg=(0,p.weightedAvg)([r._m,...i]),r}}constructor(e=20){i.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(i=new WeakSet,o.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,p.min)([this._min,e.min]),this._max=(0,p.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),r={};return r.k=t(this.n),this.empty||(r.mean=t(this.avg),r.sum=t(this.sum),r.sd=t(this.stdDev),r.max=t(this.max),r.min=t(this.min)),r}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,i,"m",n).call(this,-1)}get p29(){return s(this,i,"m",n).call(this,-.5)}get p38(){return s(this,i,"m",n).call(this,-.25)}get p69(){return s(this,i,"m",n).call(this,.5)}get p84(){return s(this,i,"m",n).call(this,1)}get p98(){return s(this,i,"m",n).call(this,2)}get p99(){return s(this,i,"m",n).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new g.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,a.mapNotEmpty)(this._samples,p.variance)}get sampleStdDev(){return(0,a.mapNotEmpty)(this._samples,p.stdDev)}get sampleAvg(){return(0,a.mapNotEmpty)(this._samples,p.avg)}get sampleSlope(){return(0,p.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,p.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,n=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const i=r(40958),n=r(55835),s=r(31586),o=r(30976),a=r(48884),l=r(70417);function u(e,t){const r=Math.pow(2,t),i=[];for(;e>0;)i.unshift(e%r),e=Math.floor(e/r);return i}t.concatBits=function(e,t){const r=Math.pow(2,t);return e.reduce(((e,t)=>e*r+(0,s.clamp)(0,r,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,r){return(0,n.map2)(e,t,((e,t)=>(0,i.sum)((0,a.zip)(u(e,r),u(t,r)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,o.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max)),n=this.clampValue(e);let s=0;for(let e=0;eo?(s+=1,r[t]=o):i[t]=o}return s}unzip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max));for(let n=0;n(r[e]+i[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,r){return!0!==r&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let r=0;rs?(t+=1,n.min=s):n.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const r=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,i.sum)(e,((r,i)=>t(r,i)?Math.pow(2,e.length-i-1):0))}},55222:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const i=r(77598),n=r(22573),s=r(55835),o=r(32639),a=r(88158),l=r(81168),u=BigInt(0);function c(e,t,r=0){if(!isFinite(t)||e<=1)return[];const i=[];if(0===t)i.unshift(0);else for(;t>0;)i.unshift(t%e),t=Math.floor(t/e);for(;i.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const r=e<0;return r&&(e=Math.abs(e),t--),(r?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],r=BigInt(this.base);let i=e;for(;i>u;)t.push(Number(i%r)),i/=r;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let r of e)for(t.forEach(((e,i)=>{r+=e<<8,t[i]=r%this.base,r=Math.floor(r/this.base)}));r>0;)t.push(r%this.base),r=Math.floor(r/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,n.blank)(e))return;const t="-"===(e=(0,o.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const r=BigInt(this.base);let i=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;i=i*r+BigInt(e)}return t?BigInt(-1)*i:i}randomChars(e){return this.encodeBuffer((0,i.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,r="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(r)}tokenEql(e,t,r){const i=this.normalizeToken(e),n=this.normalizeToken(t);return i.length>=r&&i===n}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const i=r(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,i.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},70417:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const a=r(40958),l=r(55835),u=r(31586),c=r(59455),d=r(22454),h=r(77377),f=r(82647);function m(e){let t;for(const r of e)null!=r&&(null==t||rt)&&(t=r);return t}function y(e,t){const r=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&r.incr(t);return r.topKeys(t)}function v(e,t){let r=0,i=0;for(const n of e){if(null!=n){const e=t(n,r);(0,u.isNumber)(e)&&(i+=e)}r++}return i}t.min=m,t.max=p,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,r)=>e-t[r]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const r of e)(0,u.isNumber)(r)&&(t+=r);return t},t.sumf=v;class w{constructor(){i.set(this,0),n.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(o(this,n,null==s(this,n,"f")?e:s(this,n,"f")*s(this,i,"f")/(s(this,i,"f")+1)+e/(s(this,i,"f")+1),"f"),o(this,i,(t=s(this,i,"f"),++t),"f"))}get mean(){return s(this,n,"f")}}function S(e){const t=new w;for(const r of e)t.push(r);return t.mean}function b(e){const t=S(e);if(null==t)return;let r=0,i=0;for(const n of e)(0,u.isNumber)(n)&&(i++,r+=(n-t)*(n-t));return r/i}function P(e){let t=0;for(const r of e)t+=r*r;return Math.sqrt(t)}function _(e,t){let r=0;for(let i=0;i(1-t)*e+t*(r+o*(e-n)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),r=S(t);if(null!=r){const e=(t.length-1)/2,i=v(t,((t,i)=>(t-r)*(i-e))),n=v(t,(e=>(e-r)**2));return 0===n?0:i/n}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let r;t=(0,u.clamp)(0,1,t);for(const i of e)r=null==r?i:r*t+i*(1-t);return r},t.centroid=function(e){const t=e[0].length,r=[];for(let i=0;ie[i]))));return r},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,a.isEmpty)(e)&&(0,a.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},45969:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const i=r(73024),n=r(38639),s=r(19851),o=r(59958),a=r(43334);t.isDocker=(0,s.lazy)((()=>a.isLinux&&((0,n.toBoolean)(process.env[o.PS_IS_DOCKER])??(0,i.existsSync)("/.running-in-container"))))},29325:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const i=r(76760),n=r(19851),s=r(54993);t.isPacked=(0,n.lazy)((()=>!(0,s.toS)(__filename).includes((0,i.join)("core","platform","IsPacked"))))},43334:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(22573),a=r(38639),l=r(59958),u=n.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,a.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,a.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,o.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===n.default.arch(),t.isArm=null!=/^arm\b/i.exec(n.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,o.notBlank)(s.default.env.APPIMAGE)||(0,o.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,o.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,a.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const n=i(r(73024)),s=r(19851),o=r(43334);function a(e="/proc/cpuinfo"){if(o.isWin||o.isMac)return!1;try{return null!=n.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=a,t.isRaspberryPi=(0,s.lazy)((()=>o.isLinux_arm&&a())),t.procDeviceModel=(0,s.lazy)((()=>{try{return o.isLinux?n.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},45643:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const i=r(58587),n=r(59455),s=r(31562);t.existingPids=function(e){return(0,n.toA)(e).filter(i.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,i.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=r(58587),d=u(r(31421)),h=u(r(1708)),f=r(40958),m=r(22573),g=r(42659),p=r(55835),y=r(31586),v=r(97790),w=r(59455),S=r(54993),b=r(54557),P=r(19851),_=r(50213),E=r(88158),M=r(409),C=r(78406),T=r(25764),x=r(99331),D=r(56519),k=r(46292),O=r(8769),I=r(83278),F=r(32144),L=r(29882),A=r(43334),N=r(24399),R=r(58261),j=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),B=10*g.secondMs;function V(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const r=(0,p.map)(t.start,(e=>e.getTime())),i=e.startTime;return(0,y.gt0)(r)&&(0,y.gt0)(i)&&Math.abs(r-i){const e=Date.now()-2*g.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,F.isJsonExt)(t)&&(0,L.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))j().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:g.minuteMs,f:async(e={})=>{j().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,r=e.force??A.isWin,i=await this.pidfiles(),n=await this.pids(i??[]);if((0,f.isEmpty)(n))return j().info("killOldProcs(): no pidfiles"),[];const s=[],o=[],a=await(0,R.pidInfos)(n);if(null!=a){for(const n of i){const i=await n.readJson();if(null==i){j().warn("killOldProcs(): failed to read pidfile "+n.base),await n.unlink("debug");continue}const l=i.pid;if(!(0,y.gt0)(l)){j().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+n.base,{json:i,pid:l}),await n.unlink("debug");continue}const u=a.find((e=>e.pid===l));if(null==u||!V(i,u)){j().debug("killOldProcs(): pid no longer present: unlinking "+n.base,{json:i,pidEntry:u}),await n.unlink("debug"),s.push(i);continue}const c=(0,y.gt0)(i.timeoutMs)?i.startTime+i.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(i.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(j().info("killOldProcs(): killing",{reason:d,json:i}),o.push(W(l,r,!1)),s.push({...i,...u}))}return o.length>0&&await Promise.allSettled(o),s}(0,O.onError)("Pids.killOldProcs(): failed to get process information")}}),o.set(this,void 0)}async addPid_(e,t,r=!1){if(null==e)throw new Error("undefined info");const o=e.pid;if(!(0,y.gt0)(o))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(o)?(r&&a(this,n,"f").delete(l),a(this,n,"f").getOrSet(l,(async()=>{const r=a(this,i,"m",s).call(this,e.pid),n=(0,v.opt)((0,E.Try)((()=>(0,L.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),o=t.getTime(),l={...e,cmd:n,startTime:o};return await r.writeJson_(l),j().debug("addPid() wrote "+r,l),r}))):(a(this,n,"f").delete(l),void j().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=a(this,i,"m",s).call(this,e);return(0,D.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,g.ago)(g.minuteMs),!0).catch((t=>{j().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==a(this,o,"f")||a(this,o,"f").ended)&&l(this,o,new C.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*g.minuteMs,rank:T.EndableRanks.first}),"f"),a(this,o,"f")}cancelInterval(){a(this,o,"f")?.end(),l(this,o,void 0,"f")}}t.Pids=q,n=new WeakMap,o=new WeakMap,i=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},q.instance=(0,P.lazy)((()=>(0,p.map)((0,k.configDir)(),(e=>new q(I.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return q.instance()?.addPid_(e,t)}},58261:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const n=r(31421),s=r(48161),o=i(r(1708)),a=r(40958),l=r(22573),u=r(42659),c=r(31586),d=r(68708),h=r(59455),f=r(54993),m=r(48884),g=r(53507),p=r(19851),y=r(50213),v=r(84968),w=r(48963),S=r(56519),b=r(84777),P=r(8103),_=r(45879),E=r(43334),M=r(24399),C=r(45643),T=(0,p.lazy)((()=>(0,y.mkLogger)("proc.ps")));function x(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function D(e){if(E.isLinux)return async function(e){const t=[];for(const r of e)t.push(z(await(0,_.readFileMaybe)("/proc/"+r+"/stat")));return T().tap({msg:"pidInfoProc",result:(0,a.compact)(t)})}(e);const t=(0,C.existingPids)(e),r=(await(0,m.collectBatchedAsync)(t,20,E.isWin?F:R)).filter((e=>x(e)&&t.includes(e.pid)));return T().tap({msg:"pidInfos()",result:r,meta:{pids:e}})}t.isProcEntry=x,t.pidInfo=async function(e){return(0,S.thenMap)(D([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,a.isEmpty)(e)?[]:(0,S.thenMap)((0,C.existingPids)(e),(t=>{const r=[o.default.pid,...t];return e.filter((e=>!r.includes(e)))}))},t.pidInfos=D;const k="Get-Process",O="| Select-Object -Property Id,ProcessName,StartTime";function I(e){return(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).join(",")}async function F(e){if(M.PowerShell.instance().ended)return N(e);const t=[k,"-Id",I(e),"-ErrorAction SilentlyContinue",O].join(" ");return(0,S.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const L={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},A=["CommandLine","CreationDate","ProcessId"];async function N(e){const t=["process"];if((0,a.isNotEmpty)(e)){const r=(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",r)}t.push("get",A.join(","));const r=await(0,b.stdoutResult_)((0,P.wmic)(),t,L),i=(0,d.onlyReqValued)((0,g.parseFixed)(A,r.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return i.find((e=>e.pid===o.default.pid))||i.push({pid:o.default.pid,start:new Date(v.StartTs),cmd:"node "+o.default.title}),i}async function R(e){return t=(await(0,b.stdoutResult_)("ps",["-p",I(e),"-wwwo","pid,lstart,command"],{...L,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,g.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=N;const j=(0,p.lazy)((()=>{try{if(E.isLinux)return(0,c.toGt0)((0,n.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){T().warn("clk_tck failed",{error:e})}return 100})),B=(0,p.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),V=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function z(e){const t=V.exec((0,f.toS)(e))?.groups,r=(0,c.toInt)(t?.pid),i=t?.comm,n=(0,c.toInt)(t?.starttime);return(0,c.gt0)(r)&&!(0,l.blank)(i)&&(0,c.gt0)(n)?{pid:r,cmd:i,start:new Date(B()+n/j()*u.secondMs),state:t?.state}:void 0}},24399:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const i=r(58587),n=r(19851),s=r(22573),o=r(42659),a=r(41400),l=r(55835),u=r(13538),c=r(36557),d=r(14121),h=r(50213),f=r(7282),m=r(45255),g=r(81168),p=r(25764),y=r(38836),v=r(99331),w=r(56519),S=r(31562),b=r(84777),P=r(34102),_=r(43334),E=r(28874),M=r(63870),C="{ready}",T=" | ConvertTo-Json -Compress";function x(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=x,(0,a.later)((()=>(0,P.ee)().on("clearCache",(()=>D.instance.prior()?.clearMockResults()))));class D extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),p.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new i.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",E.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${C}"}`,...(0,s.mapNotBlankOr)(E.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:C,fail:"Error",exitCommand:"exit",maxProcs:E.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:o.minuteMs,cleanupChildProcs:!1}),p.EndableRanks.postdb),E.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(E.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,g.ensureSuffix)(e,T),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const r=this.mockResults.get(e);return t(r.stdout,r.stderr,r.passed)}try{const r=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new i.Task(e,((r,i,n)=>t((0,l.map)(r,(t=>(0,g.stripPrefix)(t,e))),i,n)))));return this.logger.tap({msg:"execute()",result:r.result,meta:{elapsedMs:r.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,g.ensureSuffix)(e,T),((e,t,r)=>({stdout:e,stderr:t,passed:r})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const r=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,g.ellipsize)(t.stdout),after:(0,g.ellipsize)(r)}),JSON.parse(r)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+x(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=D,D.instance=(0,n.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new D})),t.checkPowerShell_=async function(){const e=D.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const i=r(50989);t.AggregateTypes=(0,i.strEnum)("union","intersection")},71988:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const i=r(50989);t.AssetFileSortCriteria=(0,i.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const i=r(22573),n=r(38639),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toBoolean})}}t.BooleanSetting=o},90536:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=a},75164:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(i.notBlank).flatMap(n.toInt).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,n.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=a},10546:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const i=r(50989);t.ColorDistanceFunctions=(0,i.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const i=r(36507),n=r(22573),s=r(45599),o=r(50213),a=r(81168),l=r(98314),u=r(8769),c=r(80372),d=(0,s.defer)((()=>(0,o.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,a.trimQuotes)(e);return void((0,n.blank)(t)||(0,i.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,r){try{return(0,n.blank)(t)?void 0:(0,i.Cron)(t,{name:e,unref:!0,protect:!0,catch:r=>(0,u.onError)(r,{name:e,crontab:t}),...r})}catch(r){return void d().warn("invalid cron",{name:e,crontab:t,error:r})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const i=r(70488),n=r(91655),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration})}get valueOrDefault(){return(0,i.decodeDuration)(super.valueOrDefault)}get value(){return(0,i.decodeDuration)(super.value)}set value(e){super.userValue=(0,i.decodeDuration)(e)}get humanValue(){return(0,n.fmtFullDuration)(this.value)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,i.decodeDuration)(e)}}t.DurationSetting=o;class a extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,i.decodeDuration)(this.defaultValue)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=a},9945:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.FloatSetting=o},74589:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt})}}t.IntegerSetting=o},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const i=r(22573),n=r(53265),s=r(87652);class o extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,i.blank)(e)?void 0:(0,n.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=o},23561:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.OptionalFloatSetting=o},69005:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=o},87652:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=n},28283:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const i=r(51926),n=r(83556);t.nameFromEnv=function(e){return(0,n.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,i.ensurePrefix)((0,n.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const o=r(19851),a=r(40958),l=r(79666),u=r(50357),c=r(57924),d=r(98553),h=r(55835),f=r(68708),m=r(39926),g=r(46891),p=r(42279),y=r(59455),v=r(40583),w=r(81168),S=r(44198),b=r(96706),P=r(34102),_=r(28283),E=r(81075),M=r(98778),C=r(10357);t.settingsToObj=function(e){const t={};for(const r of e)r.hasValue()&&(t[r.name]=r.value);return t},t.Setting=class{constructor(e){i.add(this),this.opts=e,this._envValue=(0,o.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,i,"m",n).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const r=this.opts.whyInvalid?.(e);return null!=r?s(this,i,"m",n).call(this,e??t)+": "+r:null==this.fromEnv(e)?s(this,i,"m",n).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const r=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=r)return r}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,a.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const r=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(r)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,a.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,a.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return E.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,p.tot)(this.optsOverrides.defaultValue)??(0,p.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,p.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const r=e??(0,S.env)(),i=t??this.value;return null!=i&&(r[this.key]=this.toEnv(i)),null==e&&b.caseInsensitiveEnv.unset(),r}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const r=e??(0,S.env)(),i=this.toEnvValue(t);return null!=i&&(r[this.key]=i,null==e&&b.caseInsensitiveEnv.unset()),r}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],C.WrapComments);function r(e,r){(0,a.isEmpty)(r)||t.push(...(0,w.wrap)(["",(1===r.length?e:(0,g.pluralize)(e))+": "+(0,c.orList)(r.map((e=>(0,d.stringify)(e))))],C.WrapComments))}r("alias",this.opts.aliases),r("environment alias",this.altKeys);for(const[e,r]of(0,f.entries)(this.addToJSON())){const i=Array.isArray(r)?(0,c.orList)(r.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(r);t.push(...(0,w.wrap)(["",e+": "+i],C.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Example value:"],key:this.name,value:(0,p.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Default value:"],key:this.name,value:(0,p.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,p.tot)(this.fileValue)}),e}},i=new WeakSet,n=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const i=r(50989);t.SettingCategories=(0,i.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const i=r(58587),n=r(76760),s=r(19851),o=r(40958),a=r(76790),l=r(22573),u=r(42659),c=r(73722),d=r(68708),h=r(50989),f=r(12168),m=r(54993),g=r(37975),p=r(9092),y=r(40583),v=r(79840),w=r(7282),S=r(12801),b=r(4328),P=r(70488),_=r(84248),E=r(5531),M=r(99315),C=r(34365),T=r(34580),x=r(96706),D=r(50274),k=r(33866),O=r(52086),I=r(48584),F=r(45969),L=r(43334),A=r(24540),N=r(70379),R=r(71300),j=r(33209),B=r(48987),V=r(68268),z=r(61208),W=r(99023),q=r(30577),U=r(1485),G=r(19861),H=r(55111),J=r(30933),$=r(22859),K=r(71988),Y=r(38483),Z=r(90536),X=r(75164),Q=r(10546),ee=r(90967),te=r(67958),re=r(55948),ie=r(57039),ne=r(9945),se=r(74589),oe=r(844),ae=r(96093),le=r(23561),ue=r(69005),ce=r(87652),de=r(81075),he=r(58305),fe=r(57571),me=r(72564),ge=r(80372),pe=r(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new ae.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new ge.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new ge.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new ge.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new ge.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new ge.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,g.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new ge.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>G.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>U.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:U.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>U.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>L.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new ge.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new ge.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,F.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:H.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!L.isElectron}),commandTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new i.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>L.isMac?"100ms":L.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new ge.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new ne.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:E.CheckpointTypes,defaultValue:E.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:C.SynchronousModes,defaultValue:C.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 1 minute is very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"1m"}),dbBackupIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,F.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:k.HealthCheckIds}),ffmpegHwaccel:new ge.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>L.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new ge.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new ge.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new ge.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new ge.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:q.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,T.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new ge.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,A.isRaspberryPi)()}),taskTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new ge.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new ge.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,J.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:D.SidecarExts,defaultValue:D.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:$.AggregateTypes.intersection,strEnum:$.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new ge.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new ne.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:re.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,J.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:O.CropStrategies.attention,strEnum:O.CropStrategies}),videoFrameAtSec:new ne.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,o.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(L.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>j.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:I.SharpFailOns.truncated,strEnum:I.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>B.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:oe.MinValidYear}),maxValidFutureMs:new ie.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:pe.TagInferenceSettingValues,defaultValue:pe.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new ne.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:N.DateTagFormats.ym,strEnum:N.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:V.KeywordReparentingStrategies.move,strEnum:V.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new ge.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:z.NameTagFormats["as-is"],strEnum:z.NameTagFormats}),tagNamesDefaultFamily:new ge.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new ge.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new ge.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,F.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,r]of(0,d.entries)(t.Settings))r._setName(e);function Se(e){const r=((0,l.blank)(e)?"":e).split(n.delimiter);return(0,F.isDocker)()&&r.unshift("/opt/photostructure/tools/bin"),r.push(...t.Settings.toolPaths.valueOrDefault),(0,o.uniq)(r).filter(l.notBlank).join(n.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,x.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,a.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new p.CaseInsensitiveMap;for(const r of(0,t.persistedSettings)()){for(const t of r.names)e.set(t,r);for(const t of r.keys)e.set(t,r)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const i=r(19851),n=r(31586),s=r(7282),o=r(49776),a=r(46292),l=r(32774),u=r(55086),c=r(46296),d=r(55939),h=r(96706),f=r(83278),m=r(92234),g=r(45969),p=r(60865),y=r(30933),v=r(15674),w=r(28874);t.setSettingsDefaults=(0,i.lazy)((()=>{w.Settings.configDir.opts.defaultValue=a.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=o.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,g.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=p.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,n.sigFigs)(50/(0,y.cpuCount)(),2)}))},84438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const i=r(76760),n=r(40958),s=r(22573),o=r(98553),a=r(55835),l=r(59455),u=r(83179);function c(e){return null==e?void 0:(0,o.stringify)(e)}t._join=c;function d(e){return(0,a.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,n.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",i.delimiter])if(t.includes(e))return(0,n.compactBlankish)(t.split(e));return[t]}}(e),n.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,n.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,n.isEmpty)(e)||(this.value=this.toValidValues((0,n.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,n.isEmpty)(this.values)}isNotEmpty(){return(0,n.isNotEmpty)(this.values)}toNotEmpty(){return(0,n.toNotEmpty)((0,n.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=n},72564:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const i=r(40958),n=r(98553),s=r(55835),o=r(58305);class a extends o.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,n.stringify)((0,i.uniq)(e)))),fromEnv:t=>{return r=t,n=e.strEnum,(0,i.compact)((0,o.splitStringArray)(r)?.map((e=>n.getCI(e))));var r,n},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=a},80372:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const i=r(22573),n=r(81168),s=r(83179);class o extends s.Setting{constructor(e){super({toEnv:a,fromEnv:a,...e})}hasValue(){return(0,i.notBlank)(this.value)}}function a(e){return null==e?void 0:(0,n.trimQuotes)(e)}t.StringSetting=o},32707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const i=r(76760),n=r(55835),s=r(46292),o=r(84438);t.systemSettingsFile=function(){return(0,n.map)((0,s.configDir)(),(e=>(0,i.join)(e,o.SettingsToml)))}},80496:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const i=r(50989);t.TagInferenceSettingValues=(0,i.strEnum)("never","always","auto")},6707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const i=r(90858),n=r(44652),s=r(22573),o=r(76850),a=r(50213),l=r(81168),u=r(84542),c=r(17217),d=r(68284),h=r(98778);function f(e){return t=(0,o.debom)(e),(0,s.blank)(t)?void 0:(0,i.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,n.readFileSync)(t)):void 0}catch(e){return void(0,a.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>f(await(0,n.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,n.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const i=r(22573),n=r(96249),s=r(98553),o=r(68708),a=r(51926);function l(e,t,r){if((0,i.blank)(e))throw new Error("kvToToml(): Blank key");const n=e+" = "+(0,s.stringifyPretty)(t);return(0,i.blank)(r?.prefix)?[n]:(0,a.wrap)(n.split("\n"),r)}t.stringifyToml=function(e){return(0,n.flatten)((0,o.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,i.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,a.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},10357:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},65162:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const i=r(4001),n=r(81168);t.bname=function(e,t=!0){let r=(0,n.isString)(e)?e:e.name;return t&&(r=(0,i.stripCopySuffixFromName)(r)),r=(0,n.trimLeftPadding)((0,i.stripDSC)(r)),r.toLowerCase().normalize()}},70379:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const i=r(50989);t.DateTagFormats=(0,i.strEnum)("y","ym","ymd","")},71300:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},68268:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const i=r(50989);t.KeywordReparentingStrategies=(0,i.strEnum)("move","copy","retain")},61208:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const i=r(50989);t.NameTagFormats=(0,i.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const i=r(50989);t.NameTagOrders=(0,i.strEnum)("western","eastern")},60865:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const i=r(37805),n=r(30577);t.channel=function(){return(0,n.extractUpdateChannel)(i.version)},t.baseVersion=()=>[i.versionMajor,i.versionMinor,i.versionPatch].join("."),t.versionMajorMinor=i.versionMajor+"."+i.versionMinor},76280:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const i=r(38064),n=r(22573),s=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function o(e){if(e instanceof i.SemVer)return e.version;const t=s.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=o,t.semverSatisfies=function(e,t){if((0,n.blank)(e))return!1;const r={loose:!0,includePrerelease:!0};if((0,i.satisfies)(e,t,r))return!0;const s=o(e);return null!=s&&(0,i.satisfies)(s,t,r)},t.toSemver=function(e){try{return e instanceof i.SemVer?e:(0,i.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const i=r(50989);t.UpdateChannels=(0,i.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const r of t.UpdateChannels.values)if(e.includes("-"+r))return r;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},1485:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const i=r(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,i.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},69375:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const i=r(19851),n=r(22573),s=r(50213),o=r(9103),a=r(7282),l=r(29882),u=r(43334),c=r(28874),d=(0,i.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,n.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,a.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,a.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,a.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,g=u.isLinux||(0,a.isTest)()?/^\/var\/lib\//:void 0;function p(e){if((0,n.blank)(e))return"blank";const t=(0,l.toPathnames)(e),r=t[0],i=t[t.length-1];return c.Settings.excludedRootDirectories.has(r)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(i)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===r&&!1===m?.test(e)?"LinuxRunRE":!0===g?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,o.memoize)((e=>{if(u.isWin)return!1;const t=p(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=p},63870:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const i=r(42659),n=r(12168),s=r(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=n.MiB/i.secondMs},55111:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const i=r(50989);t.HelmetPlugins=(0,i.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},30933:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const n=i(r(48161)),s=r(19851),o=r(42659),a=r(31586),l=r(50213),u=r(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>n.default.cpus()),5*o.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=n.default.availableParallelism?.(),r=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,a.clamp)(1,128,Math.ceil(e??r)),meta:{availableParallelism:e,cpuInfoLength:r}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const n=i(r(48161)),s=r(19851),o=r(31586),a=r(12168),l=r(50213),u=r(45879),c=r(70417),d=r(45969),h=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=n.default.freemem(),t=n.default.totalmem(),r=(2*e+t)/3;if((0,d.isDocker)()){const i=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,o.gt0)(i))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([i,r]),meta:{freemem:e,totalmem:t,cgroupMem:i}})}return h().tap({msg:"estimatedFreeMem() ",result:r,meta:{result:(0,a.fmtBytes)(r),freemem:(0,a.fmtBytes)(e),totalmem:(0,a.fmtBytes)(t)}})}))},15674:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const i=r(19851),n=r(42659),s=r(41400),o=r(31586),a=r(12168),l=r(50213),u=r(7282),c=r(34102),d=r(57902),h=r(28874),f=r(30933),m=r(58444),g=r(22751),p=(0,i.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),g.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,i.lazy)((()=>{const e=(0,o.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*a.MB;return p().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/a.MB),worstCaseMemPerProcMb:Math.ceil(e/a.MB)}})}),n.minuteMs);function w(){const e=Math.round(g.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,r=0===e||0===t?1:(0,o.sigFigs)(t/e,2);return p().tap({msg:"timeoutPenalization()",level:r>1?d.LogLevels.warn:d.LogLevels.debug,result:r,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,o.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,f.cpuCount)())<=1},t.maxCpus=(0,i.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,f.cpuCount)())-1);let t=e;const r=g.timeoutRate.prior()?.eventsPerMinute??0,i=w();if(1!==i){const e=t;t*=i,p().warn("Recent timeouts! Throttling down.",{penalization:i,resultBeforePenalization:e,resultAfterPenalization:t})}const n=Math.min(e,v());return t=(0,o.clamp)(1,n,Math.floor(t)),p().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:i,timeoutsPerSecond:r,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,i.lazy)((function(){return(0,o.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,o.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,o.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},22751:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const i=r(58587),n=r(87997),s=r(19851),o=r(42659),a=r(41400),l=r(50213),u=r(7282),c=r(45255),d=r(34102),h=r(976),f=r(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new i.Rate(5*o.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const g=(0,s.lazy)((()=>(0,n.setInterval)(p,o.minuteMs).unref()));function p(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),g()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),p()},(0,a.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const i=r(76790),n=r(22573),s=r(50357),o=r(98553),a=r(49769),l=r(34666),u=r(30976),c=r(42279),d=r(32639),h=r(59455),f=r(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function g(e){return null==e||0===(0,h.toA)(e).length}function p(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,r)=>e===t[r]))}function v(e,t){for(let r=0;r=e.length||r>=e.length)return e;const i=e[t];return e.splice(t,1),e.splice(r,0,i),e}function S(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&(0,a.getOrSet)(r,e,(()=>i))}return[...r.values()]}function P(e,t,r=1,i=(e=>e)){const n=[];if(et;s-=r)n.push(i(s));return n}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=g,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,r){return m(e)?t(e):(0,c.tot)(r)},t.toPrimitive=p,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let r=0;rt.includes(e)))},t.includesAll=function(e,t){if(g(e)||g(t))return!1;for(const r of t)if(!e.includes(r))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const r=(0,i.sortBy)(e,p),n=(0,i.sortBy)(t,p);return r.every(((e,t)=>e===n[t]))},t.pushUniq=function(e,...t){for(const r of t)null==r||e.some((e=>(0,s.eql)(e,r)))||e.push(r);return e},t.pushUniqBy=function(e,t,r){const i=e.map(r);for(const n of t){const t=r(n);i.includes(t)||(e.push(n),i.push(t))}return e},t.insertAt=function(e,t,...r){return e.splice(t,0,...r),e},t.insertUniq=function(e,t,r){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let i=0;i0)return e.splice(i,0,t),e}return e.push(t),e},t.remove=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),r!==e.length},t.removeSame=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>e!==t)))),r!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(n.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,o.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const r of e)null==r||(0,s.eql)(t[t.length-1],r)||t.push(r);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const r=[];for(const e of(0,i.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))r.some((t=>t.includes(e)))||r.push(e);return(0,i.sortBy)(r,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&r.set(e,i)}return[...r.values()]},t.uniqBy2=function(e,t){const r=[];for(const i of e)null!=i&&r.every((e=>!t(i,e)))&&r.push(i);return r},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,r,i)=>e+(t(r,i)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,r,i)=>e+t(r,i)),0)},t.firstMatch=function(e,t){for(const r of S(t)){const t=e.exec(r);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let r=0;for(;e[r]===t[r];)r++;return r},t.anneal=function({array:e,expense:t,allowedDelta:r}){const i=Math.round(r);if(i<2)return e;for(let r=0;re)){return P(e,t,1,r)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,o.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,r,i=t.primitiveValueOfOrElse){const n=new Set(r.map(i));return e.filter((e=>!n.has(i(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const i=r(40958),n=r(36783),s=r(41801),o=r(98553),a=r(49769),l=r(55835),u=r(34666),c=r(59455);function d(e,t){return(0,n.copyArrayTo)(f(e,t),e)}function h(e,t){const r=new Map;for(const i of e)(0,a.getOrSet)(r,(0,o.stringify)(t(i)),(()=>i));return f(r.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,l.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,i.compact)(e),i.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,n.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,r)=>0===r||t>=e[r-1]))},t.sortedBy=function(e,t){return e.every(((r,i)=>0===i||t(r)>=t(e[i-1])))},t.sortBy=f,t.deepSortBy=function e(t,r){return f(t,r).map((t=>(0,s.isIterable)(t)?e(t,r):t))},t.pushSorted=function(e,t,r){const i=e.findIndex((e=>r(t){Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const i=r(32639);t.asPromise=async function(e){const t=await e;return(0,i.isFunction)(t)?t():t}},5233:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const i=r(41400),n=r(31586),s=r(13538),o=r(41583);t.retryOnReject_=async function(e,t){const r=(0,n.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return r();const a=t.onRetryWaitUntil??(e=>(0,i.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await r()}catch(e){const r=(0,o.toErr)(e);if(!1===t.errorIsRetriable?.(r)||l>t.maxRetries)throw r;return l++,await a(l),u()}};return u()}},17586:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},22573:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const i=r(55835),n=r(42279),s=r(54993);function o(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function a(e){return!o(e)}function l(e,t){if(!1===e||null==e||""===e)return;const r=(0,s.toS)(e);return a(r)?t(r):void 0}t.blank=o,t.notBlank=a,t.notBlankToS=function(e){return a(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,n.tot)(t);const r=(0,s.toS)(e).trim();return r.length>0?r:(0,n.tot)(t)},t.notBlankAnd=function(e,t){return!o(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,r){return(0,i.orElse)(l(e,t),r)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{function r(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function i(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const r=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=r,t.toBoolean=function(e){return!!r(e)||!i(e)&&void 0},t.toNotBoolean=function(e){return!r(e)&&(!!i(e)||void 0)},t.boolToInt=function(e){return r(e)?1:0},t.isFalse=i,t.isDisabled=function(e){return i(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>r(e)))},t.and=function(e){return e.every((e=>r(e)))},t.maybeAnd=function(e){let t;for(const r of e){if(!1===r)return!1;!0===r&&(t=!0)}return t},t.mapBoolean=function(e,t){return r(e)?t(!0):i(e)?t(!1):void 0},t.mapTrue=function(e,t){return r(e)?t():void 0}},79666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const i=r(98553);t.clone=function(e){return null==e?e:JSON.parse((0,i.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const i=r(40958),n=r(22573),s=r(30301),o=r(55835),a=r(31586),l=r(39926),u=r(51926),c=r(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function g(e){return e instanceof Date}function p(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,o.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=g,t.thisYear=function(){return(new Date).getFullYear()},t.ago=p,t.hence=function(e,t){return p(-e,t)},t.unixtime=function(e){const r=g(e)?e.getTime():(0,a.isNumber)(e)?e:Date.now();return Math.floor(r/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,r={includeMs:!0}){const i=Math.floor(e/t.hourMs);e-=i*t.hourMs;const n=Math.floor(e/t.minuteMs);e-=n*t.minuteMs;const s=Math.floor(e/t.secondMs),o=Math.floor(e-s*t.secondMs);return(0,l.pad2)(i)+":"+(0,l.pad2)(n)+":"+(0,l.pad2)(s)+(r.includeMs?"."+(0,l.pad3)(o):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const r=()=>{const e=t%100;return t=Math.floor(t/100),e},i=10*r(),n=r(),s=r(),o=r(),a=r(),l=r();return new Date(t,l-1,a,o,s,n,i)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,r="ago"){return e<1e3?"just now":(r=(0,n.blank)(r)?"":(0,u.ensurePrefix)(r," "),et.ms<=e)))){const s=Math.floor(e/i.ms);e-=s*i.ms,s>0&&(i.ms>=t.dayMs?r:n).push(s+i.s)}return e>0&&n.push((0,a.toFixedStr)(e/t.secondMs,3)+"S"),"P"+r.join("")+((0,i.isEmpty)(n)?"":"T"+n.join(""))},t.fmtIsoDate=function(e){const t=g(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,o.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const i=r(38639),n=r(73872);function s(e,t,r){if(null==r||y(e)||y(t))return null;const i=r.get(e)?.get(t);return"boolean"==typeof i?i:null}function o(e,t,r,i){if(null==r||y(e)||y(t))return;let n=r.get(e);null!=n?n.set(t,i):(n=new WeakMap,n.set(t,i),r.set(e,n))}function a(e,t,r,i){if(null!=r?.comparator)return u(e,t,r,i);const n=l(e,t);return null!==n?n:u(e,t,r)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,r,i){r??(r={});const u=!1===r.memoize?void 0:r.memoize??(r.memoize=new WeakMap),d=r?.comparator,f=s(e,t,u);if(null!==f)return f;const m=s(t,e,u);if(null!==m)return m;if(d){const r=d(e,t,i);if(!1===r||!0===r)return o(e,t,u,r),r;const n=l(e,t);if(null!==n)return n}const y=n(e);if(y!==n(t))return o(e,t,u,!1),!1;o(e,t,u,!0);const v=function(e,t,r,i){switch(r){case"String":case"Number":case"Boolean":case"Date":return a(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return g(e,t,["name","message","code"],i);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,i);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,r){return c(h(e),h(t),r)}(e,t,i);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),i);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),i);case"Set":case"Map":return function(e,t,r){if(e.size!==t.size)return!1;if(0===e.size)return!0;const i=[],n=[];return e.forEach((function(e,t){i.push([e,t])})),t.forEach((function(e,t){n.push([e,t])})),c(i.sort(),n.sort(),r)}(e,t,i);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return p(e,t,i)}}(e,t,y,r);return o(e,t,u,v),v}function c(e,t,r){const i=e.length;if(i!==t.length)return!1;if(0===i)return!0;let n=-1;for(;++n{Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,r,i=!1;const n=function(){if(i){if(null!=r)throw r;return t}try{return i=!0,t=e()}catch(e){throw r=e,e}};return n.prior=()=>t,n.hasPrior=()=>i,n}},41400:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const i=r(42659),n=r(35556),s=r(31586),o=r(68708);function a(e,t=!0){return new Promise((r=>{if(e<=0)r();else{const s=setTimeout((()=>r()),Math.ceil(e+.5));e>i.secondMs&&t&&n.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return a(t).then((()=>t))},t.delay=a,t.later=function(e,t=1){const r=Math.max(1,Math.ceil(t)),s=n.isNode&&r<=1?setImmediate(e):setTimeout(e,r);return n.isBrowser||t<=i.secondMs?s:(0,o.maybeCall)(s,"unref")??s}},50357:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const i=r(12487),n=r(68708),s=r(34666),o=r(32639);function a(e,t){return(0,i.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,o.isFunction)(e)&&(0,o.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=a,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return!1;for(const r of(0,n.keys)(e))if(!a(e[r],t[r]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,r){if(null==e||null==t)return e===t;if(null!=r){const i=d.get(r);if(null!=i)return i(e,t)??null}for(const r of c){const i=r(e,t);if(null!=i)return i}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(31586),a=r(68708),l=r(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,n.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,o.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const r=[];for(const t of e)null!=t&&(t instanceof Error?r.push(u(t),c(t),t?.message):r.push((0,l.toS)(t)));return(0,i.uniq)((0,i.compactBlankish)((0,s.flatten)((0,i.compact)(r).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,n.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const r=(0,l.toS)(e).split("\n").filter((e=>!(0,n.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,i.isEmpty)(r)?["(missing stack)"]:r}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,n.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(n.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,a.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,a.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,a.assignFields)(new Error,(0,a.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},96249:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const i=r(59455);t.flatten=function(e,t=[]){for(const r of(0,i.toA)(e))if(null!=r)for(const e of(0,i.toA)(r))null!=e&&t.push(e);return t}},57924:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const i=r(40958);function n(e,t){return null==(e=(0,i.uniq)((0,i.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=n,t.orList=function(e){return n(e,"or")},t.andList=function(e){return n(e,"and")}},73722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const i=r(50989);t.FitSizes=(0,i.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,i.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const i=r(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,r){if((0,i.lt0)(t))return[...e].slice(t,r);const n=e[Symbol.iterator]();if((0,i.gt0)(t))for(let e=0;e{Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,r){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(r))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],r=[];return function e(i,n){if((0,isFunction_1.isFunction)(i))return;let s,o,a,l=toJSON(i);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(i===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let i=0;t.Latch=class{constructor(e=i++){this.id=e,this[r]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},r=Symbol.toStringTag},30301:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const i=r(40958),n=r(50357),s=r(31586),o=r(65812);t.lazy=function(e,t){let r,a;const l=[];function u(){return u.isStale()&&u.setResult(e()),a}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return r=Date.now(),async function(e,r){if((0,i.isEmpty)(l))return;const s=await e,a=await r;if(!(0,n.eql)(s,a))for(const e of l)e(a);null!=t&&t>0&&void 0!==a&&(0,o.setUnrefTimeout)((()=>u.vacuum()),t)}(a,e),a=e},u.isStale=function(){return null==r||(0,s.gt0)(t)&&r+t{Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,r){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const i=r();return null!=i&&e.set(t,i),i}},t.deleteIf=function(e,t){for(const[r,i]of e.entries())t(r,i)&&e.delete(r)}},55835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const i=r(42279),n=r(54993);function s(e,t){return null==e?void 0:t(e)}function o(e,t,r){return null==e||null==t?void 0:r(e,t)}function a(e,t){return null!=e?e:(0,i.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=o,t.map3=function(e,t,r,i){return null==e||null==t||null==r?void 0:i(e,t,r)},t.orElse=a,t.mapOr=function(e,t,r){return null!=e?t(e):(0,i.tot)(r)},t.map2Or=function(e,t,r,i){return a(o(e,t,r),i)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,n.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const i=r(68708);class n extends Error{constructor(e,t){super(e),this.message=e,(0,i.assignFields)(this,t)}}t.MetaError=n},23838:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const i=r(40958),n=r(76790),s=r(50357),o=r(98553),a=r(49769),l=r(55835),u=r(51926),c=r(59455);class d{static fromJSON(e){const t=new d;for(const[r,i]of Object.entries(e))t.add(r,...i);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,i.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const r=(0,a.getOrSet)(this.store,e,(()=>[]));return r.push(...t),r}addUniq(e,...t){return(0,i.pushUniq)((0,a.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const r=this.store.get(e);if(null==r)return!1;{const i=r.filter((e=>!(0,s.eql)(e,t)));return 0===i.length?this.store.delete(e):this.store.set(e,i),r.length!==i.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,i.uniq)(t))){for(const t of this.keys()){const r=this.store.get(t),n=null==r?[]:e(t,r);(0,i.isEmpty)(n)?this.store.delete(t):this.store.set(t,n)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,i.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield[t,r])}()}tuples(){const e=this;return function*(){for(const[t,r]of e.store.entries())for(const e of(0,c.toA)(r))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[r,n]of this.store.entries()){const s=(0,i.findIndexes)(n,(t=>!e(r,t,n)));if(s.length>0){t=!0;for(const e of s.reverse())n.splice(e,1)}0===n.length&&this.store.delete(r)}return t}inverse(){const e=new d;for(const[t,r]of this.store.entries())for(const i of r)e.add(i,t);return e}findKeyByTuple(e){for(const[t,r]of this.tuples())if(e(t,r))return t}filterKeysByTuple(e){const t=[];for(const[r,i]of this.entries())i.some((t=>e(r,t)))&&t.push(r);return t}toJSON(){const e={};for(const[t,r]of this.entries())e[(0,u.isString)(t)?t:(0,o.stringify)(t)]=r;return e}}function h(e,t){const r=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>r.add(t,e))))),r}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const r=h(e,t);return(0,n.sortBy)((0,c.toA)(r.values()),(e=>t(e[0])))}},35556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const r=globalThis;t.isBrowser="object"==typeof r?.window&&"object"==typeof r?.document,t.isNode="string"==typeof r?.process?.versions?.node},31586:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const i=r(76790),n=r(22573),s=r(42279),o=r(54993);function a(e){return"number"==typeof e&&isFinite(e)}t.isNumber=a,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,o.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return a(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,o.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,r)=>a(t)&&a(r)&&e(t,r);function f(e,r,n){return!(null==n||!a(n))&&([e,r]=(0,i.sort)([e,r]),(0,t.lte)(e,n)&&(0,t.gte)(r,n))}function m(e){if(!a(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function g(e){return"function"==typeof e?.toNumber}function p(e,t){if((0,n.blank)(e))return t.defaultValue;if(a(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return p(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return a(e)&&e>0}function S(e){return a(e)&&e>=0}function b(e,t){return a(e)?t(e):void 0}function P(e){return a(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const r=Math.pow(10,t);return P(e*r)/r}function E(e,t,r){if(e>t||!a(e)||!a(t))throw new Error(`invalid clamp(${e}, ${t}, ${r})`);return a(r)?rt?t:r:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return a(e)?e:t},t.diff=function(e,t){return a(e)&&a(t)?e-t:void 0},t.absdiff=function(e,t){return a(e)&&a(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,r=.95){if(!a(e)||!a(t))return!1;if(e===t)return!0;if(r>=1)return!1;const i=(0===t?1e-5:t)*(1-r);return f(t-i,t+i,e)},t.within=f,t.max_=function(...e){let t;for(const r of e)a(r)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return a(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return a(e)&&a(t)&&e>t?e:void 0},t.lte0=function(e){return a(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const r=y(e);return null==r?void 0:t(r)},t.mapFloat=function(e,t){const r=v(e);return null==r?void 0:t(r)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,r){return b(e,(e=>b(t,(t=>r(e,t)))))},t.mapNumericOr=function(e,t,r){return a(e)?t(e):r},t.numericOr=function(e,t){return a(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d+\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!a(e)||0===e||0===t)return 0;const r=t-P(Math.ceil(Math.log10(Math.abs(e)))),i=Math.pow(10,Math.abs(r));return r<0?P(e/i)*i:P(e*i)/i},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=E,t.times=function(e,t){if(!w(e))return[];const r=Math.round(e);return r<=0?[]:[...Array(r)].map(((e,r)=>t(r)))},t.pct=function(e,t){return E(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const r=Math.round(e??-1);return null==t||f(0,t,r)?r+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const r of e){if(!a(r))return;t+=r}return t}},68708:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(32639),a=r(55835),l=r(31586),u=r(34666),c=r(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function g(e){return h(e).map((t=>e[t]))}function p(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const r of e)if(null!=r&&Array.isArray(r)){const[e,i]=r;null!=e&&void 0!==i&&("object"!=typeof t&&(t={}),t[e]=i)}return t}function v(e){if(null==e)return;const t=p(e);if(t.every((([,e])=>null!=e)))return e;const r=t.filter((([,e])=>null!=e));return(0,i.isEmpty)(r)?void 0:y(r)}function w(e,t,r={}){return y((0,i.compact)((0,n.sort)(h(e)).map((r=>t(r,e[r])))).filter((([e,t])=>null!=e&&void 0!==t)),r)}function S(...e){const t=(0,i.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const r=t.filter(d);if(t.length!==r.length)return t;const n={};for(const e of(0,i.uniq)((0,i.flatMap)(r,h)))n[e]=S(...r.map((t=>t[e])));return n}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const r=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(r.test(t))return{key:t,value:e[t]}}function P(e){return g(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const r=v(e);return m(r)?t(r):void 0},t.values=g,t.entries=p,t.fromEntries=y,t.assignFields=function(e,t,r){if(null==t)return e;for(const[i,n]of p(t))!0!==r?.omitKeys?.includes(i)&&(null==n&&!0!==r?.assignNullish||(e[i]=n));return e},t.assignUndefinedFields=function(e,t,...r){if(null==t)return e;for(const i of r){const r=t[i];void 0!==r&&void 0===e[i]&&(e[i]=r)}return e},t.assignAllFields=function(e,t){for(const[r,i]of p(t??{}))e[r]=i;return e},t.definedValues=function(e){if(null==e)return;const t=p(e);if(t.every((([,e])=>void 0!==e)))return e;const r=t.filter((([,e])=>void 0!==e));return(0,i.isEmpty)(r)?void 0:y(r)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,i.compact)(t.map(e));{const r=(0,i.compact)(p(t).map((([t,r])=>(0,a.map)(e(r),(e=>[t,e])))));return 0===r.length?void 0:y(r)}}},t.compactBlankValues=function(e){if(null==e)return;const t=p(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,i.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickCompact=function(e,...t){if(null==e)return;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickNonBlank=function(e,...t){if(null==e)return e;const r={};for(const i of t){const t=e[i];(0,s.notBlank)(t)&&(r[i]=t)}return r},t.pickFirst=function(e,t,r=a.defined){if(null!=e)for(const i of t)if(r(e[i]))return e[i]},t.pickDeep=function e(t,...r){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...r)));const i={};function n(e,t){if(null==t)return;const r=i[e];i[e]=null==r?t:S(r,t)}for(const i of r){const[r,o]=(0,c.splitFirst)(i,"."),a=b(t,r);null!=a?.value&&n(a.key,(0,s.blank)(o)?a.value:e(a.value,o))}for(const i of h(t))((0,l.toInt)(i)??-1)>=0&&n(i,e(t[i],...r));return i},t.pluck=b,t.pluckDeep=function e(t,r){if(null==t||(0,s.blank)(r))return;if(Array.isArray(t)){const n=(0,i.compact)(t.map((t=>e(t,r))));return(0,i.isEmpty)(n)?void 0:{key:n[0].key,value:(0,i.flatMap)(n,(e=>e.value))}}const[n,o]=(0,c.splitFirst)(r,"."),a=b(t,n);if(null==a)return;if((0,s.blank)(o))return a;const l=e(a.value,o);return null==l?void 0:{key:a.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const r=p(e).filter((([e])=>!t.includes(e)));return(0,i.isEmpty)(r)?void 0:y(r)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(p(e).filter((([e,r])=>t(e,r))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,i.uniq)(t)},t.maybeCall=function(e,t,...r){const i=e?.[t];return(0,o.isFunction)(i)?i.bind(e)(...r):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const r=t.toLowerCase().normalize();for(const t of h(e))if(r===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const r=w(t,((t,r)=>[t,e(r)])),i=g(r);return 1===i.length?i[0]:r}},97790:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(r||(r={})),t.None=r;class i{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new i(e(this.a))}flatMap(e){const t=e(this.a);return n(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,r){return s(e).flatMap((e=>s(t).flatMap((t=>r(this.a,e,t)))))}zip3(e,t,r,i){return s(e).flatMap((e=>s(t).flatMap((t=>s(r).flatMap((r=>i(this.a,e,t,r)))))))}}function n(e){return e instanceof i||e===t.None}function s(e){return n(e)?e:null!=e?new i(e):t.None}t.Some=i,t.isOpt=n,t.opt=s},39926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const i=r(31586),n=r(54993),s={};function o(e,t){if(t<1)return"";if(!(0,i.gte)(s[e]?.length,t)){let r=s[e]??e;for(;r.length{Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const i=r(22573),n=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,o=/[^aeiou]y$/,a=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,i.blank)(e))return e;const t=n.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(o)?e.replace(/y$/i,"ies"):null!=e.match(a)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const i=r(40958),n=r(54993),s=["number","string","boolean"];function o(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=o,t.mapPrimitive=function(e,t){return o(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,r){return o(e)?t(e):r()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(o)};const a=["boolean","number","bigint","symbol","string","object","function"];function l(e,r){if(null==e&&null==r)return 0;if(null==e)return-1;if(null==r)return 1;const i=typeof e,s=typeof r;if(!("string"!==i&&"symbol"!==i||"string"!==s&&"symbol"!==s)){const i=(0,n.toS)(e),s=(0,n.toS)(r),o=i.localeCompare(s);return i[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-o:o}return Array.isArray(e)&&Array.isArray(r)?u(e,r):i!==s?a.indexOf(i)-a.indexOf(s):e>r?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const i=r(59455);function n(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const r=await e;return null==r?void 0:t(r)},t.thenCollect=async function(e,t){const r=[];for(const n of(0,i.toA)(await e))if(null!=n){const e=await n;if(null!=e){const i=await t(e);null!=i&&r.push(i)}}return r},t.thenTap=async function(e,t=console.dir.bind(console)){const r=await e;return await t(r),r},t.isPromiseLike=n,t.isPromise=function(e){return n(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:r}){const i=await e;return t(i)?r(i):void 0}},57153:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const i=r(50989);t.PromiseStates=(0,i.strEnum)("pending","resolved","rejected")},30976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const i=r(40958),n=r(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function o(e,t,r){return null==r||0===r.length?s(e,t):a(e,t,1,r)[0]}function a(e,t,r,i){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const n=t-e,o=new Set(i??[]);if(t===e&&0===n&&0===o.size&&1===r)return[e];const a=n-o.size;if(r>a)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:n,size:r,slotsRemaining:a})}`);const l=new Set;for(;l.size0;e--){const r=Math.floor(Math.random()*(e+1));e!==r&&([t[e],t[r]]=[t[r],t[e]])}return t},t.sample=function(e,t){const r=[];for(const i of a(0,e.length,t))r.push(e[i]);return r},t.pickWeightedRandom=function(e){if((0,i.isEmpty)(e))return;const t=e.filter((e=>(0,n.gt0)(e.priority)));let r=l(0,(0,i.sum)(t,(e=>e.priority)));return t.find((e=>(r-=e.priority,r<=0)))}},5670:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const i=r(50989);t.ServiceNames=(0,i.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]}},50989:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const i=r(68708),n=r(42279);t.strEnum=function(...e){const t=Object.freeze(e),r=(0,i.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const o=e=>null!=e?r[e]:void 0,a=e=>null!=o(e);return{...s,values:t,length:t.length,has:a,includes:a,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:o,ordinal:e=>o(e)??t.length,validOrElse:(e,t)=>a(e)?e:(0,n.tot)(t),mapValid:(e,t)=>a(e)?t(e):void 0,cmp:(e,t)=>{const r=o(e),i=o(t);return null==r||null==i?void 0:r>i?1:r{const r=o(e);return null==r?void 0:t[r]}}}},51926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const i=r(40958),n=r(17586),s=r(22573),o=r(96249),a=r(41801),l=r(31586),u=r(59455),c=r(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,r){if(d(e))return t<0&&(t+=e.length),e.slice(t,r);{const i=f();return null!=i?(0,a.sliceIterable)(i.segment(e),t,r).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,r).join("")}}function g(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function p(e,t){const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.startsWith(i)?r.slice(i.length):r}function y(e,t){if(null==t)return e;const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.endsWith(i)?r.slice(0,-i.length):r}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,r){null==r&&(r=e.length);for(let i=r;i>=0;i--)if(m(e,i).startsWith(t))return i;return-1}function b(e,t,{normalize:r=!0}={}){if(null==e||null==t)return!1;const i=(0,c.toS)(e),n=(0,c.toS)(t);return i.length===n.length&&(i===n||i.toLowerCase()===n.toLowerCase()||"function"==typeof i.localeCompare&&0===(r?i.normalize():i).localeCompare(r?n.normalize():n,void 0,{sensitivity:"base"}))}function P(e,t){return(0,i.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,n.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,a.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,r){return d(e)?e.slice(t,null==r?void 0:t+r):m(e,t,null==r?void 0:t+r)},t.charArr=g,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=p,t.stripPrefixes=function e(t,r){if(null==t)return"";const i=(0,c.toS)(t);for(const t of r)if(null!=t&&t.length>0&&i.startsWith(t))return e(i.slice(t.length),r);return i},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:r}){return y(p(e,t),r)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:r}){return w(v(e,t),r)},t.ellipsize=function(e,t=80,r=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),r=(0,l.clamp)(0,t-1,(0,l.round)(r));const i=g(e);return i.length<=t?i.join(""):i.slice(0,t-1-r).join("")+"…"+(r>0?i.slice(-r).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,r){const i=r?.maxLineLen??80,n=r?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const i=(0,o.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,o.flatten)(i.map((t=>e(t,r))))}if((t=v((0,c.toS)(t),n).trim()).length<=i)return[t];const s=S(t," ",i);if(s>n.length)return[m(t,0,s),...e(m(t,s+1),r)];{const i=t.indexOf(" ",n.length+1);return i>0&&i{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const i=r(42659),n=r(68708),s=r(42279),o=r(83104),a=r(85556);async function l(e,t,r=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(r,i)=>{let n=!0;const s=setTimeout((()=>{n&&(n=!1,r(o.Timeout))}),t);try{s.unref?.();const t=await e;n&&(n=!1,r(t))}catch(e){n&&(n=!1,i(e))}finally{clearTimeout(s)}}))}async function u(e,t,r=!0){const n=await l(e,t,r);if(n===o.Timeout)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(t)+")");return n}t.toNotTimeout=function(e){return e===o.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,r=!0){const i=t-Date.now();return i<=0?o.Timeout:l(e,i,r)},t.thenOrOnTimeout=async function(e,t,r){return t<=0?e:new Promise((async(i,s)=>{let o=!0;try{const a=setTimeout((async()=>{if(o){o=!1;try{i(await r())}catch(e){s(e)}}}),t);(0,n.maybeCall)(a,"unref");const l=await e;o&&(o=!1,clearTimeout(a),i(l))}catch(e){o&&(o=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,r=!0){const n=t-Date.now();if(n<=0)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(n)+")");return u(e,n,r)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:r,unref:i=!0}){const n=await l(e,t,i);return n===o.Timeout?(0,s.tot)(r):n}},42279:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const i=r(32639);t.tot=function(e){return(0,i.isFunction)(e)?e():e},t.tol=async function(e){return(0,i.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class r extends Error{}t.TimeoutError=r},12168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const i=r(22573),n=r(30301),s=r(31586),o=r(46891),a=r(50989),l=r(51926),u=(0,n.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let r=0;for(const i of e)(0,s.isNumber)(i)&&(r+=i/t.MB);return(0,s.round)(r)},t.fmt=c,t.fmtToInt=function(e){return(0,i.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const r=Math.floor(Math.log10(e)),i=Math.floor(r/3),n=Math.pow(10,3*i),o=d[i];return(0,s.sigFigs)(e/n,t)+" "+o}t.fmtMB=function(e,r=3){return f(e*t.MB,r)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const r=Math.floor(Math.log2(e)),i=Math.floor(r/10),n=Math.pow(2,10*i),o=h[i];return(0,s.sigFigs)(e/n,t)+" "+o},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,a.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,r){return null==e?"":(0,i.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(r??(0,o.pluralize)(t)).trim())},t.plurMetric=function(e,t,r){return r??(r=(0,o.pluralize)(t)),{count:c(e),desc:1===e?t:r}}},65812:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const i=r(68708);t.setUnrefTimeout=function(e,t){const r=setTimeout(e,t);return(0,i.maybeCall)(r,"unref")??r}},23541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const i=r(41801),n=r(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,n.isString)(e)?[e]:(0,i.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const i=r(40958),n=r(23541),s=r(59455),o=r(54993);function a(e){return null==e?void 0:(0,n.isError)(e)?e:new Error((0,o.toS)(e))}t.toErr=a,t.toErrs=function(...e){return(0,i.compact)((0,s.toA)(e).map(a))}},54993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const i=r(98553);t.toS=function(e){return s(e,",")};const n={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==n?e.toString():(0,i.stringify)(e)}}t.toStr=s},90858:e=>{e.exports=require("@iarna/toml")},58587:e=>{e.exports=require("batch-cluster")},6858:e=>{e.exports=require("commander")},36507:e=>{e.exports=require("croner")},66261:e=>{e.exports=require("events")},77988:e=>{e.exports=require("exiftool-vendored")},44652:e=>{e.exports=require("fs-extra")},28787:e=>{e.exports=require("he")},51168:e=>{e.exports=require("luxon")},38064:e=>{e.exports=require("semver")},73872:e=>{e.exports=require("type-detect")},92460:e=>{e.exports=require("util")},31421:e=>{e.exports=require("node:child_process")},77598:e=>{e.exports=require("node:crypto")},78474:e=>{e.exports=require("node:events")},73024:e=>{e.exports=require("node:fs")},51455:e=>{e.exports=require("node:fs/promises")},77030:e=>{e.exports=require("node:net")},48161:e=>{e.exports=require("node:os")},76760:e=>{e.exports=require("node:path")},1708:e=>{e.exports=require("node:process")},57075:e=>{e.exports=require("node:stream")},46466:e=>{e.exports=require("node:stream/promises")},87997:e=>{e.exports=require("node:timers")},57975:e=>{e.exports=require("node:util")},38522:e=>{e.exports=require("node:zlib")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__={},exports;exports=__webpack_exports__,Object.defineProperty(exports,"__esModule",{value:!0}),__webpack_require__(36389),module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{"use strict";var __webpack_modules__={37975:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const i=r(22573),n=r(38639),s=r(44198);function o(){return(0,n.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,i.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=o;let a=!o();function l(){return a}function u(e,t){return function(r){return l()?`[${e}m${r}[${t}m`:r}}t.setColorEnabled=function(e){a=e??!o()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const i=r(19851),n=r(7282),s=r(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,i.lazy)((()=>t.SimpleAppName+((0,n.isProd)()?"":`-${(0,n.nodeEnv)()}`))),t.AppNameVersion=(0,i.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const i=r(40958),n=r(36783),s=r(76790),o=r(22573),a=r(50357),l=r(98553),u=r(55835),c=r(31586),d=r(68708),h=r(34666),f=r(59455),m=r(84885);var g=r(40958);function p(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,r=i.primitiveValueOfOrElse){const n=new Set(t.map(r));return e.filter((e=>n.has(r(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],r=e.lastIndexOf(t);return[{t,count:r+1},...v(e.slice(r+1))]}function w(...e){const t=[],r=Math.max(...e.map((e=>e?.length??0)));for(let i=0;ie?.[i])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function E(e,t){return(0,i.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,r){return C(e,t,r).index}function C(e,t,r){if((0,i.isEmpty)(e))return{index:-1,value:void 0};let n,s=-1;for(let i=0;ie.slice(r,r+t)))}async function x(e,t){return(0,i.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return g.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return g.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return g.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,a.eql)(e,t)))))},t.allDefined=p,t.mapAllDefined=function(e,t){return p(e)?t(e):void 0},t.mapAll=function(e,t){return p(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(o.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const r of(0,f.toA)(e))if(null!=r&&!0===await t(r))return r},t.findLastAsync=async function(e,t){for(let r=(e=(0,f.toA)(e)).length-1;r>=0;r--){const i=e[r];if(null!=i&&!0===await t(i))return i}},t.first=function(e,t){if(null!=e)for(const r of(0,f.toA)(e))if(null!=r){const e=t(r);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null!=i){const e=await t(i,r);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,i.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,r){for(let i=r;i<=e.length-1;i++)if(t(e[i]))return i},t.findLast=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return e[r]},t.findLastIndex=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1},t.concat=function(...e){const t=[];for(const r of e)if(Array.isArray(r))for(const e of r)null!=e&&t.push(e);else null!=r&&t.push(r);return t},t.moveToEnd=function(e,t){return(0,i.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const r=e[t];if(null==r)return e;e.push(r);for(let r=t;r(0,a.eql)(e,t)))},t.removeFirst=function(e,t){const r=e.findIndex(t);return r>=0?e.splice(r,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,n.copyArrayTo)((0,i.uniqBy)(e,t),e)},t.partition=function(e,t){const r=[],i=[];let n=0;for(const s of e)(t(s,n++)?r:i).push(s);return[r,i]},t.isUniq=function(e){return e.every(((t,r)=>e.indexOf(t)===r))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,i.compact)((0,i.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),r=[];return(0,c.times)(t,(t=>e.map((e=>r.push(e?.[t]))))),r},t.unFlatZip=function(e,t){const r=e.length/t;if(r!==Math.round(r))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const i=(0,c.times)(t,(()=>new Array(r)));for(let n=0;ne.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=E,t.least=function(e){return E(e,(e=>e))},t.greatestBy=function(e,t){return(0,i.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const r=C(e??[],t,h.lt);return null==e||null==r||r.index<0||null==r.value?void 0:{result:e[r.index],index:r.index,value:r.value}},t.reverse=function(e){const t=[];for(let r=e.length-1;r>=0;r--)t.push(e[r]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=T,t.collectBatched=function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(r(s)));return n},t.collectBatchedAsync=async function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(await r(s)));return n},t.contextFilter=function(e,t){let r;return e.filter(((e,i)=>(0,d.tap)(t(e,i,r),(t=>{t&&(r=e)}))))},t.clusterSome=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.some((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterEvery=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.every((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterAsync=async function(e,t){const r=[];e:for(const i of e){for(const e of r)if(null!=i&&await x(e,(e=>t(i,e)))){e.push(i);continue e}null!=i&&r.push([i])}return r},t.someAsync=async function(e,t){if(null!=e)for(let r=0;r=0&&!0===(0,u.map)(e[i],(e=>r(e,i))))return i}{const i=t+n;if(ie+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,r){return e.lengthr))),e}},36557:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const a=r(77988),l=o(r(1708)),u=r(19851),c=r(42659),d=r(55835),h=r(31586),f=r(85556),m=r(54993),g=r(50213),p=r(79089),y=r(45255),v=r(25764),w=r(38836),S=r(99331),b=r(95937),P=r(98314),_=r(38835),E=r(70025),M=r(8769),C=r(43334),T=r(95402),x=r(28874),D=r(63870);class k extends w.EndableWrapper{constructor(e,t,r=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,i,"m",n).call(this)),r,"worker"===e?(0,D.commandTimeoutMs)():y.ShortCommandTimeoutMs),i.add(this),this.t=t;const o=t;o.on("childStart",(async r=>{null!=r.pid?(this.logger.info("Started child process",{pid:r.pid}),(0,p.renice)(r.pid).catch((e=>this.onError("renice failed",e))),(0,T.addPid)({pid:r.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),o.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),o.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),o.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),o.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),o.on("noTaskData",((e,r,i)=>{const n=t.options.streamFlushMillis;n{this.logger.error("observeBatchCluster.endError()",e)})),o.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&T.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof a.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,E.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=k,i=new WeakSet,n=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(C.isWin?3:1)*c.minuteMs,maxTasksPerProcess:x.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:x.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:x.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,g.mkLogger)(t))),spawnTimeoutMillis:x.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:x.Settings.taskTimeoutMs.valueOrDefault}}},89788:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=r(92460),d=r(31586);class h{constructor(e){if(i.add(this),this.maxLength=e,n.set(this,void 0),s.set(this,0),o.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,n,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,i=new WeakSet,a=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,o,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,n,"f")[t]))}()}push(...e){var t,r;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,n,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,i,"m",a).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,n,"f")[e]}))}unshift(...e){var t,r;for(const c of e.reverse())u(this,s,"f"){u(this,n,"f")[e]=c,l(this,o,e,"f")}));return u(this,s,"f")}shift(){return u(this,i,"m",a).call(this,0,(e=>{var t,r;return l(this,o,(t=u(this,o,"f"),++t),"f"),l(this,s,(r=u(this,s,"f"),--r),"f"),u(this,n,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,i,"m",a).call(this,u(this,s,"f")-1-e,(e=>{const r=u(this,n,"f")[e];u(this,n,"f")[e]=u(this,n,"f")[t],u(this,n,"f")[t]=r}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const i=r(54993),n=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:r}of n)if(o(e,t))return e.subarray(t.length).toString(r);return e.toString()}function o(e,t){return t.every(((t,r)=>e[r]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,i.toS)(e)},t.bufferStartsWith=o},9092:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,r]of e)this.set(t,r)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const r=this.normalizer(e);return null!=e&&null!=r&&this.store.set(r,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=n},36638:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=n},40583:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const o=r(40958),a=r(23838),l=s(r(68708)),u=r(59455),c=r(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new a.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const r of(0,o.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(r,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const r=this.lookup(e);if(null!=r)return r;let i,n=-1;for(const[r,s]of this.m.entries()){const o=(0,c.diceCoeff)(r,e);if(o>t&&o>n){const e=this.getFirst(s);null!=e&&(i=e,n=o)}}return i}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),r=this.m.get(t);if(null!=r){for(const e of r)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const i=r(76790),n=r(31586),s=r(68708),o=r(54993),a=r(82647),l=r(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const r=this.get(e)+t;return 0===r?this.m.delete(e):this.m.set(e,r),r}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new a.Average(0);for(const t of this.keys()){if(!(0,n.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,r]of this.m.entries())e[(0,o.toS)(t)]=r;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,i.sortBy)([...this.entries()],(([t,r])=>[-r,(0,n.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new a.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,r]of(0,i.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,r);return e}addAll(e){for(const[t,r]of e.entries())this.incr(t,r);return this}get toS(){return(0,i.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let r=0;for(const[i,n]of this.m.entries()){const s=e(i);t.fill(s,r,r+n),r+=n}return t}}t.CountingSet=u},79840:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const i=r(19851),n=r(72993),s=r(45969),o=r(43334);t.EditionType=(0,i.lazy)((()=>o.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,i.lazy)((()=>n.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const i=r(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),r=t-this.ts;this.ts=t,(0,i.map)(this.listener,(t=>t(e,r))),r>2&&this.l.log(r>500?"warn":r>100?"info":"debug",e,{elapsedMs:r})}},t.elapsed=function(e){const t=Date.now(),r=e();return{elapsedMs:Date.now()-t,result:r}},t.thenElapsed=async function(e){const t=Date.now(),r=await e;return{elapsedMs:Date.now()-t,result:r}}},23467:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const i=r(50357),n=r(55835),s=r(68708);var o=r(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return o.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,i.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,i.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,n.map2Or)(await e,await t,i.eql,(()=>!1))},t.eqlPicked=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))},t.eqlOmit=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.omit)(e,...r),(0,s.omit)(t,...r))},t.eqlAsyncPicked=async function(e,t,...r){return(0,n.map2Or)(await e,await t,((e,t)=>(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))),(()=>!1))}},62344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(31586),a=r(54993),l=r(77377),u=r(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,o.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,o.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,n.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const r of this.expireListeners)r(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[i.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const r of this.expireListeners)r(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,n.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const r of this.expireListeners)r(e,t)}const r=this.priorCache[e];if(void 0!==r&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,r)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const r=this.currentCache[t]??this.priorCache[t];null!=r&&e(t,r)}}deleteIf(e){for(const t of this.keys()){const r=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=r&&e(t,r)&&this.delete(t)}}get(e){return e=(0,a.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,a.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,a.toS)(e),this.has(e))return this.get(e);const r=t();return this.set(e,r),r}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,o.isNumber)(e.__uid)&&(0,o.isNumber)(e.__start)}},80049:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=r(31586),d=r(85556),h=r(54993),f=r(54557),m=r(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,i.set(this,0),n.set(this,0),s.set(this,0),o.set(this,0),a.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,i,l(this,i,"f")+e.cacheHitsSync,"f"),u(this,n,l(this,n,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,o,l(this,o,"f")+e.rejections,"f"),u(this,a,l(this,a,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,i,"f"),cacheHitsAsync:l(this,n,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,o,"f"),timeouts:l(this,a,"f")}}has(e){return this.cache.has(e)}get_(e){var t,r,o,a;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,n,(r=l(this,n,"f"),++r),"f"),c.promise):(u(this,i,(o=l(this,i,"f"),++o),"f"),c.value)}if(c instanceof Error)throw c;return u(this,i,(a=l(this,i,"f"),++a),"f"),c}get(e){var t,r;const n=this.cache.get(e);return null==n||n instanceof m.Deferred&&n.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,i,(r=l(this,i,"f"),++r),"f"),n instanceof m.Deferred?n.value:n}clear(){this.cache.clear(),u(this,i,0,"f"),u(this,n,0,"f"),u(this,s,0,"f"),u(this,o,0,"f"),u(this,a,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const r=this.get(e);if(null!=r){if(r instanceof Error)throw r;return r}return this.set(e,t())}getOrSetAsync(e,t){const r=(0,h.toS)(e);{const e=this.get_(r);if(null!=e)return e instanceof m.Deferred?e.promise:e}const i=new m.Deferred(this.opts.name).observe(t());return this.cache.set(r,i),(0,c.gt0)(this.opts.timeoutMs)&&i.setTimeout(this.opts.timeoutMs),i.promise.then((e=>{this.set(r,e)}),(e=>{var t,i;this.cache.set(r,e),u(this,o,(t=l(this,o,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,a,(i=l(this,a,"f"),++i),"f")})),i.promise}},i=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap},54127:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class i{constructor(e){this.maxSize=e,this[r]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(r=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=i},53507:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(31586),a=r(68708),l=r(50213),u=r(68852),c=r(81168),d=r(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,i.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,r=!0){return new m(e,t,r).entries};class m{constructor(e,t,r=!0){this.warnIfMissingHeaders=r,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const i=(0,o.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,n.range)(0,i).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,a.fromEntries)(e))).filter((e=>(0,a.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let r=e;r!==t;t>e?r++:r--)if(this.blankColumns.has(r))return r;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),r=[];let i,a=0;for(;null!=(i=t.exec(this.headerRow));){const l=this.headerRow.substring(a,i.index);(0,s.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:i.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(i.index,t.lastIndex),d=i.index+((0,c.indexOfNonSpace)(u)??0),h=i.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),g=e.find((e=>e.text===m));if(null==g||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:i,left:d,right:h});else{const e=(0,n.last)(r);if(r.push(g),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=g.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,o.max_)(e?.rightIdx,i.index-((0,c.lastIndexOfNonSpace)(l)??l.length));g.leftIdx=g.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),g.rightIdx=h}a=t.lastIndex}const l=(0,n.last)(r);return null!=l&&((0,s.blank)(this.headerRow.slice(a))?l.rightIdx=(0,o.max_)(...this.rows.map((e=>e.length))):l.rightIdx=a),r}}t.Fixed=m},73913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const i=r(51455),n=r(98553);var s=r(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const r=(0,n.parseJSON)(e);return null==r?void 0:t(r)},t.readJson_=async function(e){return(0,n.parseJSON)((await(0,i.readFile)(e)).toString())}},19851:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const o=r(57975),a=r(40958),l=r(50357),u=r(31586),c=r(65812),d=r(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),i.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,i,"m",n).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,a.isEmpty)(this.watchers))return;const r=await e,i=await t;if(!(0,l.eql)(r,i))for(const e of this.watchers)e(i);null!=this.ttlMs&&this.ttlMs>0&&void 0!==i&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(42659),a=r(50213),l=r(81168),u=r(5916),c=r(56519),d=r(84777),h=r(44198),f=r(6012),m=r(43334),g=r(24399),p=r(63870);t.DefaultLocale="en";const y=(0,i.lazy)((()=>(0,a.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?E():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,p.commandTimeoutMs)()}),t.envLocale=(0,i.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const r=w.exec(e.trim())?.groups;return null==r?void 0:(0,n.compact)([r.lang,r.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(g.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const _={timeoutMs:10*o.secondMs};async function E(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return b(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=E,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const i=r(48161),n=r(1708),s=r(45599),o=r(68708),a=r(50213),l=r(88158),u=r(96175),c=r(23560),d=r(84968),h=r(37805),f=r(9727),m=r(3790),g=r(29325),p=r(43334),y=r(28874);t.logStartup=(0,s.defer)((()=>{(0,a.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:n.argv,arch:(0,i.arch)(),platform:(0,i.platform)(),os:(0,u.osFullName)(),isPacked:(0,g.isPacked)(),isElectron:p.isElectron,versions:(0,o.pick)(n.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:n.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const i=r(19851),n=r(32105),s=r(14593);t.rootLoggers=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));const o=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,o)}},9103:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const i=r(98553),n=r(54557);t.memoize=function(e,t){let r=0;const s=new n.FifoCache(t.maxSize,t.ttlMs),o=t=>{if(null!=t)return r++,s.getOrSet((0,i.stringify)(t),(()=>e(t)))};return o.clear=e=>null==e?s.clear():s.delete((0,i.stringify)(e)),o.size=()=>s.size,o.callCount=()=>r,o}},7282:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const n=i(r(1708)),s=r(38639),o=r(54993),a=r(19851),l=r(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,a.lazy)((()=>n.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,o.toS)(n.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return n.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(n.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){n.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(55835),a=r(31586),l=r(39926),u=r(54993),c=r(20014);var d=r(31586);function h(e,t){return(0,a.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(a.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,a.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,r){return(0,o.orElse)(h(e,t),r)},t.mapGte0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>=0?t(r):void 0},t.mapGt0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>0?t(r):void 0},t.mapGt0=function(e,t){const r=(0,a.toInt)(e);return null!=r&&r>0?t(r):void 0},t.map2Gt0=function(e,t,r){const i=(0,a.toInt)(e),n=(0,a.toInt)(t);return null!=i&&i>0&&null!=n&&n>0?r(i,n):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,a.isNumber)(e))return e;if((0,n.blank)(e))return;const t=String(e);return(0,o.map)(f.exec(t),(e=>(0,a.toFloat)(t.substr(e.index))))}function g(e){return(0,a.toInt)(m(e))}function p(e,t){if(null==e||null==t)return;const r=[e,t].map((e=>e.toString(2))),i=Math.max(...r.map((e=>e.length)));return r.map((e=>(0,l.leftPad)(e,i,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let r=0;for(let i=0;ie/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,r){this.store[e*this.columns+t]=r}},t.hammingDistanceBigInt=function(e,t){return(0,o.map)(p(e,t),(([e,t])=>(0,i.count)([...e],((e,r)=>e!==t.charAt(r)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,o.map)(p(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,i.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,r){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let i=0;const n=r*e.length;for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const i=r(40958),n=r(42659),s=r(96249),o=r(55835),a=r(31586),l=r(68708),u=r(34666),c=r(41583),d=r(48884),h=r(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,n.isDate)(e[t]))).map((t=>[t,e[t]]))}function g(e,t){const r={};for(const[i,n]of(0,l.entries)(e)){const e=t(i,n);null!=e&&(r[i]=e)}return r}t.definedThunks=function(...e){return e.every((e=>(0,o.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const r of e){const e=r();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(o.defined)},t.firstDefinedField=function(e,...t){return(0,o.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(r=>t(r,e[r])?e[r]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,r){if(null!=e)return t(e);throw new Error(r)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,o.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,i.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[r,i]of m(t))null==e[r]&&(e[r]=i);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[r,i]of(0,l.entries)(t))null==e[r]&&(e[r]=i);return e},t.pickMap=function(e,t,r){const i={};for(const n of t)i[n]=r(n,e[n]);return i},t.mapEntries=g,t.mapNullEntries=function(e,t,r){const i={};let n=0;for(const s of(0,l.keys)(e))if(i[s]=t(s,e[s]),n++,(0,a.gt)(n,r))break;return i},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const r={};for(const i of(0,h.sortIgnoreCase)((0,l.keys)(t)))r[i]=e(t[i]);return r}return t},t.deepDelete=function e(t,...r){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...r))):g(t,((t,i)=>r.includes(t)?void 0:e(i,...r)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const r of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[r])return e[r]}},t.pairToObject=function(e,t){const r={};return r[e]=t,r},t.zipPojos=function(...e){const t={};for(const r of(0,i.uniq)((0,s.flatten)(e.map(l.keys))))t[r]=e.map((e=>e?.[r]));return t}},96175:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const i=r(31421),n=r(73024),s=r(48161),o=r(19851),a=r(22573),l=r(42659),u=r(55835),c=r(51926),d=r(54993),h=r(48884),f=r(50213),m=r(6012),g=r(45969),p=r(43334),y=r(76280),v=r(30933),w=(0,o.lazy)((()=>(0,f.mkLogger)("os")));function S(){return(0,s.platform)()+" "+(0,s.release)()}t.osArch=(0,o.lazy)((()=>`${function(){switch((0,s.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return k();case"win32":return O();default:return S()}}()} on ${(0,s.arch)()}`)),t.osFullName=(0,o.lazy)((()=>(0,t.osArch)()+((0,g.isDocker)()?" (Docker)":"")));const b=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function _(){return"ubuntu"===(0,t.osDistributionLinux)()}function E(){return"fedora"===(0,t.osDistributionLinux)()}function M(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,o.lazy)((()=>{if(p.isLinux)for(const e of b)try{const t=(0,n.readFileSync)(e).toString();if((0,a.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,o.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,a.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),S)})),t.osDistributionLinux=(0,o.lazy)((()=>p.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=_,t.hasApt=function(){return P()||_()},t.isFedora=E,t.isAlpine=M;const C={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},T={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function x(e,t){const[r,i]=function(e){return e.split(".").slice(0,2)}(e),n=t[r];return(0,c.isString)(n)?n:n?.[i]}const D=(0,o.lazy)((()=>(0,i.execSync)("sw_vers -productVersion").toString().trim()));function k(e=D()){try{return(0,a.mapNotBlankOr)(function(e=D()){return x(e,C)}(e),(t=>`macOS ${t} (${e})`),S)}catch(e){return w().warn("osNameMac(): unknown release",e),S()}}function O(e=(0,s.release)()){const t=e.startsWith("10.0.22")?"11":x(e,T);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=k,t.osNameWin=O,t.CPUs=(0,o.lazy)((()=>(0,h.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,o.lazy)((()=>{if(p.isWin)return/^Windows (?:10|11) /i.test(O())?void 0:"Windows 10 and 11 is supported";if(p.isMac){const e=D();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(p.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(_())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(E())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(M())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},12801:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const n=i(r(48161)),s=r(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:n.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:n.default.constants.priority.PRIORITY_NORMAL,BelowNormal:n.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:n.default.constants.priority.PRIORITY_LOW,Low:n.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const i=r(41400),n=r(56409),s=r(31586),o=r(22911),a=r(73614),l=r(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:r,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const g=[];function p(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...i){f=!0,m=Date.now()+(0,s.max_)(t,r);const n=d=new o.Deferred(c);(0,s.gt0)(r)&&n.setTimeout(r);try{n.resolve(await e(...i))}catch(e){n.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,a.setUnrefTimeout)(y,t+1),g.forEach((e=>e.resolve())),g.length=0}return n.promise}const w=(...e)=>{if(p()){if(!0===u)return null;const t=d?.promise;return h=e,(0,i.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new n.Latch;return g.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>p(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const i=r(68708),n=r(54993);function s(e){return e instanceof o?e.source:(0,n.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const r=[];if(!e.global)throw new Error("must provide global regex");let n;for(;null!=(n=e.exec(t));)n.index===e.lastIndex?e.lastIndex++:r.push((0,i.pick)(n,"index","groups"));return r},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,r){const i=[];for(const t of e)try{i.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{i.push(s(t))}const n=0===i.length?t.NothingRegExp:i.map((e=>"(?:"+e+")")).join("|");return new RegExp(n,r)};class o{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=o;class a extends o{static from(...e){const t=l(e);return new a("(?:"+t.source+")?",t.flags)}}function l(e,t){let r="",i=t?.includes("g")??!1,a=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof o||t instanceof RegExp?(r+=t.source,i||(i=t.global),a||(a=t.ignoreCase),l||(l=t.multiline)):r+=s((0,n.toS)(t));return new RegExp(r,t??(i?"g":"")+(a?"i":"")+(l?"m":""))}t.RegExpOptional=a,t.concatRegexp=l},79089:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const n=i(r(48161)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(42659),u=r(41400),c=r(96249),d=r(31586),h=r(51926),f=r(54993),m=r(50213),g=r(12801),p=r(22277),y=r(84777),v=r(34102),w=r(43334),S=r(24399),b=r(28874),P=(0,o.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,o.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,a.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let E=!0;const M=(0,o.lazy)((()=>new p.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const r=(0,g.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=g.PriorityClassToNode[r]),E)try{return n.default.setPriority(e,t),t}catch(r){const i=-13===r?.errno||"EACCES"===r?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:i,error:r}),i)return;E=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&g.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,r):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,g.PriorityClassToPosix[r]??g.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+r),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const n=i(r(1708)),s=r(19851),o=r(40958),a=r(5670),l=r(54993),u=r(7282),c=r(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===a.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===a.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===a.ServiceNames.sync}function g(){return(0,t.serviceName)()===a.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,o.compactBlanks)([t.serviceName.prior(),(0,l.toS)(n.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return a.ServiceNames.indexOf(e)??a.ServiceNames.length+1},t.MainServices=[a.ServiceNames.main,a.ServiceNames.desktop],t.DbServices=[a.ServiceNames.sync,a.ServiceNames.info,a.ServiceNames.web,a.ServiceNames.list,a.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[a.ServiceNames.sync,a.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===a.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===a.ServiceNames.info},t.isTestService=g,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||g())&&!f()},t.isDbJanitorService=(0,s.lazy)((()=>m()||g())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const i=r(59455);function n(e){return e instanceof Set?e:new Set((0,i.toA)(e))}t.asSet=n,t.setEql=function(e,t){return(0,i.toA)(e.keys()).every((e=>t.has(e)))&&(0,i.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,r){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),r())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const r=n(t);return new Set([...e].filter((e=>r.has(e))))},t.diff=function(e,t){const r=n(t);return new Set([...e].filter((e=>!r.has(e))))}},19913:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const i=r(5670),n=r(57150),s=r(7282),o=r(23560),a=r(17181);t.setServiceName=function(e){(0,o.isMainService)(e)&&(e=i.ServiceNames.main);const t=o.serviceName.prior();t!==e&&((0,s.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),o.serviceName.set(e),(0,a.setupLogger)(),(0,n.logStartup)())}},12089:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=r(98553),d=r(34666),h=r(54993),f=r(62344),m=r(56038);t.shim1=function(e){return new g(e.name,e.impl,e.cache,e.toKey)};class g extends f.ExtensibleFunction{constructor(e,t,r,o){super(),i.add(this),this.impl=t,this.cache=r,this.toKey=o,n.set(this,void 0),s.set(this,void 0),l(this,n,e,"f")}async _call(e){return null==this.cache?u(this,i,"m",a).call(this,e):this.cache().getOrSetAsync(u(this,i,"m",o).call(this,e),(()=>u(this,i,"m",a).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,i,"m",o).call(this,e))}}n=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},a=function(e){return(0,m.time)(u(this,n,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const i=r(42659);t.ShortCommandTimeoutMs=7*i.secondMs},92322:function(e,t,r){var i,n=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=r(76790),o=r(17586);class a{constructor(e,t){this.valueOf=e,this.diff=t,i.set(this,[])}[(i=new WeakMap,Symbol.iterator)](){return n(this,i,"f")[Symbol.iterator]()}get length(){return n(this,i,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,r=n(this,i,"f").length-1;for(;t<=r;){const s=t+Math.floor((r-t)/2),o=this.valueOf(n(this,i,"f")[s]);if(e===o)return{found:!0,index:s};e>o?t=s+1:r=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&n(this,i,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:r}){if(t>=this.length)return[...n(this,i,"f")];const o=t=>t<0||t>n(this,i,"f").length-1?null:(r??this.diff)(n(this,i,"f")[t],e),a=this.findIndex(e);if(null==a)return;let l=a.index-1,u=o(l),c=a.index,d=o(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return n(this,i,"f").shift()}at(e){return(0,o.at)(n(this,i,"f"),e)}toA(){return[...n(this,i,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===n(this,i,"f").length-1){const e=[...n(this,i,"f")];return n(this,i,"f").length=0,e}return n(this,i,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return n(this,i,"f").splice(e,t)}retainLastN(e){return e{Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const i=r(1708),n=r(82328),s=r(84542),o=r(95705),a=r(28874);t.consoleLog=function(e,...t){a.Settings.quiet.valueOrDefault||(0,n.stdoutEnded)()||console.log((0,s.crlf)(e),...t)},t.consoleError=function(e){a.Settings.quiet.valueOrDefault||(0,o.streamEnded)(i.stderr)||i.stderr.write(e)},t.quietly=async function(e){const t=a.Settings.quiet.envValue;try{return a.Settings.quiet.envValue=!0,await e()}finally{a.Settings.quiet.envValue=t}}},82328:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const i=r(1708),n=r(95705);t.stdoutEnded=function(){return(0,n.streamEnded)(i.stdout)}},71567:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const n=i(r(1708)),s=r(22573),o=r(98553),a=r(23560),l=r(82328),u=r(38835),c=r(70025),d=r(95705);function h(e,t){return f({obj:e,ready:t,stream:n.default.stdout})}function f({obj:e,ready:r,stream:i}){if(null==i||(0,d.streamEnded)(i))return;const n=(0,o.stringify)(e,void 0,(0,a.isInfoService)()||(0,a.isMainService)()?2:void 0);i.write(n+"\n"),(0,a.isWorkerService)()&&null!=r&&(n.includes(u.FailStr)||(0,c.isFatalError)(n)||(0,c.isHealthCheckError)(n)?i.write(u.FailStr+"\n"):i.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||n.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:n.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const r of e)r.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(55835),a=r(31586),l=r(39926),u=r(34666),c=r(51926),d=r(59455),h=r(54993),f=r(48884),m=r(68852),g=r(38835);var p=r(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return p.splitFirst}});var y=r(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=r(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,r){if(0===r.length)throw new Error("rightPad() given empty pad");const i=String(e);return i+(0,l.padding)(r,t-i.length)},t.padReplace=function(e,t,r,i){return(0,c.strslice)(e,0,t)+(0,l.padding)(i,r)+(0,c.strslice)(e,t+r)},t.contains=function(e,t,r){return(0,h.toS)(e).indexOf((0,h.toS)(t),r)>-1},t.countChars=function e(t,r,i=0){if(null==r||0===r.length)return 0;const n=t.indexOf(r,i);return-1===n?0:1+e(t,r,n+r.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,r){const i=Math.min(Math.ceil(e.length/t),r??e.length)-1;return i<=0?[e]:[...(0,a.times)(i,(r=>e.slice(r*t,(r+1)*t))),e.slice(i*t)]},t.spliceCapture=function(e,t){const r=t.exec(e);if(null==r||null==r[1])return;const i=r[0].indexOf(r[1])+r.index;return{captured:r[1],uncaptured:e.substring(0,i)+e.substring(i+r[1].length),unmatched:e.substring(0,r.index)+e.substring(r.index+r[0].length),matchedIndex:i}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,r={}){if(null==t)return e;const i=(0,h.toS)(e),n=(0,h.toS)(t);return n.length>0&&(0,c.equalsIgnoreCase)(i.slice(-n.length),n,r)?i.slice(0,-n.length):i},t.gist=function(e,t=80,r=80){const i=(0,h.toS)(e),n=i.length-(t+r);return n<=0?i:i.slice(0,t).trim()+" …(+"+n+" chars)…"+i.slice(-r).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const r=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===r?e.localeCompare(t):r}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,i.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,o.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const r=S(e.cmp[0],t.cmp[0]);return 0!==r?r:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,i.isEmpty)(e)||(0,s.blank)(t))return;for(const r of e)if((0,c.equalsIgnoreCase)(r,t))return{index:0,match:r};for(const r of e){const e=t.indexOf(r);if(e>=0)return{index:e,match:r}}const r=t.normalize();for(const t of e){{const e=r.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=r.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=r.toLowerCase(),i=e.toLowerCase(),n=t.indexOf(i);if(n>=0)return{index:n,match:i}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function E(e){return _.reduce(((e,[t,r])=>e.replace(t,r)),e).normalize()}t.dumbquote=E;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(E(e))&&(e=e.slice(1,-1).trim())),e};const C=/^['‘’].*['‘’]$/,T=/^["“”„«»〃].*["“”„«»〃]$/;function x(e,t){const r=D(e,t);return(0,f.flatZip)(r.nonSeparators,r.separators).filter((e=>null!=e&&e.length>0))}function D(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+g.NonRetriableErrorFlag);const r=[],i=[];let n,s=0;for(;null!=(n=t.exec(e));)n.index===t.lastIndex?t.lastIndex++:(t.lastIndex=n[0].length+n.index,r.push(e.substring(s,n.index)),i.push(e.substring(n.index,t.lastIndex)),s=t.lastIndex);return s(0,a.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),C.test(e)||T.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const r=(0,i.compactBlanks)(e),n=Math.max(...r.map((e=>e.length)));for(let e=0;e(0,o.map)(r[e],(e=>t+=e))));return t},t.splitKeep=x,t.splitUp=D,t.sortNaturalBy=k,t.sortNatural=function(e){return(0,n.sortBy)(e,(e=>k(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,i.compactBlanks)(e)),r=t.filter(((e,r)=>!P(t[r+1],e)));return(0,n.sortBy)(r,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const r=Math.min(e.length,t.length);for(let i=0;i4===e?.length?(0,a.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const O=/#.*$/gm;t.stripComments=function(e){return e.replace(O,"")},t.uniqPath=function(e,t=":"){const r=new Set;for(const i of(0,d.toA)(e))if(null!=i&&!(0,s.blank)(i))for(const e of i.split(t))(0,s.blank)(e)||r.add(e);return[...r].join(t)},t.dedupeNeedle=function(e,t,r){if((0,s.blank)(t))return e;const i=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),n=e.findIndex((e=>i.test(e))),o=new RegExp("("+(0,m.escapeRegExp)(r)+"[,:\\s]*){2,}","gim");if(n<0)return e;for(let t=n+1;te.trim()))))}},83556:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const i=r(54993);function n(e){return(0,i.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>"_"+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>" "+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=n,t.asObjectKey=function(e){return n(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const n=i(r(77598)),s=r(73913),o=r(55222);function a(e,t=s.HashBits){return n.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,r=o.Radix58,i=224){return r.encodeBuffer(a(e,i)).substring(0,t)}t.stringShaToBuffer=a,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,r=o.GeoRadix,i=224){return l(e,t,r,i)}},94863:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const i=r(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,i.toS)(e).toLowerCase().normalize()}},96859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(31586),a=r(39926),l=r(51926),u=r(54993),c=r(55222),d=r(97352),h=r(88158),f=r(77377),m=r(81168);function g(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const r=new d.Array2D(e.length);let i=0,n="";for(let s=0;s=i&&(i=r.get(s,o),n=(0,l.substr)(e,s-i+1,i)));return n}function p(e,t){if(null==e||null==t)return;if(e===t)return 0;const r=y(e,t);if(null!=r)return r;const i=e.normalize(),n=t.normalize();return e!==i||t!==n?y(i,n):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,r,i)=>r===t.charAt(i)?e:e+1),0)}function v(e,t){const r=e.toUpperCase().normalize(),i=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>r===i?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(r),t=w(i);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,r)=>e+t[r+1]))}function S(e,t){const r=(0,f.intersection)(e,t),n=[];return r.forEach((r=>{const s=Math.min((0,i.count)(e,(e=>e===r)),(0,i.count)(t,(e=>e===r)));(0,o.times)(s,(()=>n.push(r)))})),n}function b(e,t,r){const n=(0,i.commonPrefixLength)(e,t);return r((0,l.strslice)(e,n))-r((0,l.strslice)(t,n))}function P(e){const t=(0,i.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,n.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[r,i]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(r,i,(e=>(0,o.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:g(e,t).length/Math.max(e.length,t.length)},t.lcs=g,t.hamming=p,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=_;const E=/[^\da-z]+/gi;function M(e,t){const[r,i]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(E,"").toLowerCase()));return b(r,i,(e=>c.RadixAlphaNum.decode(e)))}function C(e,t){let r;for(let i=Math.max(e.length,t.length);i>=0;i--){const n=(0,o.mapNumericOr)(e.charCodeAt(i),(e=>e),256),s=(0,o.mapNumericOr)(t.charCodeAt(i),(e=>e),256),a=(0,o.clamp)(-256,256,n-s);r=null==r?a:(r+a)/2}return r}t.radixDiff=M,t.str=function(e,t){return{pref:(0,i.commonPrefixLength)(e,t),ham:p(e,t),dice:v(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,i.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=C,t.paddedPositionalDiff=function(e,t,r=8){return C((0,a.leftPad)(e,r," "),(0,a.leftPad)(t,r," "))}},84885:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const i=r(98553),n=r(88158);t.stringifySorted=function(e){return(0,i.stringify)((0,n.sortedKeys)(e))}},22277:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=r(73614);class u{constructor(e,t=!1){i.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[o]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return a(this,i,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>a(this,i,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const r=this.delegate.get(e);return null==r||a(this,i,"m",n).call(this,e,r)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,r]of this.delegate)a(this,i,"m",n).call(this,t,r)||e(t,t,this)}has(e){return null!=e&&!a(this,i,"m",n).call(this,e)}values(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield[t,t])}()}toA(){return a(this,i,"m",s).call(this),[...this.delegate.keys()]}[(i=new WeakSet,o=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,n=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const r=t<=Date.now()-this.ttlMs;if(r){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return r},s=function(){for(const[e,t]of this.delegate)a(this,i,"m",n).call(this,e,t)}},94174:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(38639),c=r(31586),d=r(50213),h=r(45255),f=r(84777),m=r(96706),g=r(43334),p=r(24399),y=(0,o.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,o.lazy)((()=>(0,a.uniq)([s.default.geteuid?.(),s.default.getuid?.(),n.default.userInfo().uid]))),t.userid=(0,o.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,o.lazy)((()=>(0,a.uniq)([s.default.getegid?.(),s.default.getgid?.(),n.default.userInfo().gid]))),t.groupid=(0,o.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,o.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,o.lazy)((()=>(0,l.toNotBlank)(n.default.userInfo()?.username))),t.userNameFromWhoami=(0,o.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,o.lazy)((async()=>g.isWin?p.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,o.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,o.lazy)((async()=>g.isWin?g.isWin?p.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.1-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=1,t.versionPrerelease=["prealpha"],t.release="2024.3.1-prealpha+20240308150212",t.gitSha="d92384e8659ff46fbae8e6f81fa5867114a4a843",t.gitDate=new Date(1709938932e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const i=r(42659),n=r(55835),s=r(31586),o=r(97790),a=r(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const r=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,n.allDefined)(r))return;const[o,a,u,c,d,h,f]=r,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(o,a-1,u,c,d,h,f/1e3)-m*i.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,o.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,a.within)(0,Date.now()+i.dayMs,e))).map((e=>new Date(e))).get()}},73568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class r extends Error{}t.AbortError=r},76740:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const a=r(45599),l=r(56409),u=r(73568);t.Abortable=class{constructor(){this._aborted=!1,i.set(this,void 0),n.set(this,(0,a.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,n,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,n,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,n,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),o(this,i,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,i,"f")&&clearTimeout(s(this,i,"f")),o(this,i,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},i=new WeakMap,n=new WeakMap},22911:function(e,t,r){var i,n,s,o,a,l,u,c,d,h,f,m,g=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},p=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(r(87997)),w=y(r(57975)),S=r(45599),b=r(26905),P=r(55835),_=r(31586),E=r(68708),M=r(20214),C=r(57153),T=r(85556),x=r(50213),D=r(70025),k=r(95937),O="TIMEOUT",I=(0,S.defer)((()=>(0,x.mkLogger)("async.Deferred")));class F{static async*toAsyncIterable(e,t){const r=[...e].reverse(),i=(0,_.gt0)(t)?new n(O).setTimeout(t):void 0;for(null!=i&&r.push(i);;){for(let i=r.length-1;i>=0;i--){const n=r[i];if(n.isSettled){if(n.name===O)return void I().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});r.splice(i,1),yield n.value}}if(r.every((e=>e.name===O)))break;try{await Promise.race(r)}catch{}}i?.clearTimeout()}static resolve(e,t){return new n(".resolved()",t).resolve(e)}constructor(e,t){var r,m,y;i.add(this),this.name=e,this.startedAt=Date.now(),o.set(this,void 0),a.set(this,C.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(p(r=n,n,(y=g(r,n,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{p(this,u,e,"f"),p(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return g(this,f,"f")??(0,x.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof n&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:g(this,a,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,E.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return g(this,o,"f")}get elapsedMs(){return(g(this,o,"f")??Date.now())-this.startedAt}get[(o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,i=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=g(this,h,"f")&&(v.default.clearTimeout(g(this,h,"f")),p(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(p(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new T.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,k.onTimeout)())}),e),"f"),g(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return g(this,a,"f")===C.PromiseStates.pending}get value(){return this.isResolved?g(this,l,"f"):void 0}get error(){return g(this,d,"f")}get isSettled(){return g(this,a,"f")!==C.PromiseStates.pending}get isResolved(){return g(this,a,"f")===C.PromiseStates.resolved}get isRejected(){return g(this,a,"f")===C.PromiseStates.rejected}get settledMs(){return null==g(this,o,"f")?void 0:g(this,o,"f")-this.startedAt}resolve(e){return g(this,i,"m",m).call(this,(()=>{p(this,a,C.PromiseStates.resolved,"f"),p(this,l,e,"f"),g(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,D.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return g(this,i,"m",m).call(this,(()=>{p(this,d,t,"f"),p(this,a,C.PromiseStates.rejected,"f"),g(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=F,n=F,m=function(e){if(g(this,a,"f")===C.PromiseStates.pending){(0,P.map)(g(this,h,"f"),v.default.clearTimeout),e(),p(this,o,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:g(this,l,"f")});return this},s={value:0}},27395:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const i=r(19851),n=r(40958),s=r(42659),o=r(23838),a=r(13538),l=r(50213),u=r(7282),c=r(97352),d=r(77740),h=r(25764),f=r(99331),m=r(73614),g=(0,i.lazy)((()=>(0,l.mkLogger)("async.Endable"))),p=new o.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const r=await e;if(null==r||!0===r?.ended)return;const i=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,r.endTimeoutMs,y);g().trace(r.name+" ending...",{timeoutMs:i});try{await(0,a.thenOrTimeoutError)(r.end(),i,(0,u.isTest)())}catch(e){try{g().warn(r.name+".end() failed",e)}catch{}}}function w(){p.filterInPlace(((e,t)=>!0!==t.ended)),g().debug("vacuumEndables()",p.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),p.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,i.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;g().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const r=p.get(t)??[];(0,n.isNotEmpty)(r)&&(g().debug("endEndables(): ending "+t),await Promise.allSettled(r.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,n.compact)(p.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const r=p.get(t)??[];e[t]=r.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,r){var i,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=r(87997),h=r(55835),f=r(31586),m=r(68708),g=r(25764),p=r(38836),y=r(99331);class v extends p.EndableWrapper{constructor(e){super(e.name,(()=>u(this,i,"m",o).call(this)),e.rank??g.EndableRanks.first,e.endTimeoutMs),i.add(this),this.opts=e,n.set(this,void 0),s.set(this,void 0),a.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,n,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,r=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!r&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,i,"m",o).call(this);const h=()=>{u(this,i,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,n,(0,d.setInterval)(u(this,a,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,i,"a",l)&&(u(this,a,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):h(),!0}}t.EndableInterval=v,n=new WeakMap,s=new WeakMap,a=new WeakMap,i=new WeakSet,o=function(){(0,h.map)(u(this,n,"f"),d.clearInterval),c(this,n,void 0,"f"),(0,h.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const i=r(50989);t.EndableRanks=(0,i.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const a=r(19851),l=r(45599),u=r(56409),c=r(50213),d=r(27395),h=r(25764),f=r(99331),m=r(56519);t.EndableWrapper=class{constructor(e,t,r=h.EndableRanks.first,o){this.endTimeoutMs=o,i.set(this,void 0),this.onEnds=[],n.set(this,(0,a.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,n,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(r,this)}setName(e){o(this,i,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,i,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,n,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},i=new WeakMap,n=new WeakMap},99331:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const i=r(7282);let n=!1;t.ending=function(){return n},t.setEnding=function(e){n=(0,i.isTest)()?e:e||n}},45608:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const n=i(r(1708)),s=r(22573),o=r(45599),a=r(37975),l=r(50213),u=r(71567),c=r(57159),d=r(57902),h=r(28874),f=r(27395),m=r(99331),g=r(56038),p=(0,o.defer)((()=>(0,l.mkLogger)((0,a.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,o.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(g.PromiseTimer.instance().report())}));async function v(e){p().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const r=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==r.errno||!0===r.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const i=(0,s.toNotBlank)(e?.reason)??r.toString();for(const e of t.onFatalHandlers)await e(i)}(0,m.ending)()||(await(0,f.endEndables)(),n.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,o.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])n.default[e].on(t,(r=>{v({reason:`${e}:${t}`,status:0,error:r})}))}))},5916:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=r(50357),f=r(31586),m=r(41583),g=r(62344),p=r(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:r,timeoutMs:i}){return new y(e,t,r,i)};class y extends g.ExtensibleFunction{constructor(e,t,r,l){super(),i.add(this),this.later=e,this.desc=t,this.ttlMs=r,this.timeoutMs=l,n.set(this,void 0),s.set(this,0),o.set(this,void 0),a.set(this,[])}_call(){return this.isStale()?c(this,i,"m",u).call(this,this.later()):c(this,o,"f")}unset(){d(this,s,0,"f"),d(this,n,void 0,"f"),d(this,o,void 0,"f")}set(e){return c(this,i,"m",u).call(this,p.Deferred.resolve(e))}refresh(){return c(this,i,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,a,"f").push(e)}prior(){return this.isStale()?void 0:c(this,o,"f")}lastValue(){return c(this,o,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,n,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,n,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,n,"f")?void 0:Date.now()-c(this,n,"f")}elapsedMs(){return c(this,o,"f")?.settledMs??c(this,o,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=async function(e,t){var r;try{const r=await t;if(!(0,h.eql)(e?.value??await(e?.promise),r))for(const e of c(this,a,"f"))await e.onChange(r)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,a,"f"))e.onError(t)}finally{d(this,s,(r=c(this,s,"f"),++r),"f")}},u=function(e){d(this,n,Date.now(),"f");const t=c(this,o,"f");return d(this,o,e instanceof p.Deferred?e:new p.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,o,"f").setTimeout(this.timeoutMs),c(this,i,"m",l).call(this,t,c(this,o,"f")),c(this,o,"f")}},56519:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const i=r(40958),n=r(76790),s=r(38639),o=r(42659),a=r(41400),l=r(31586),u=r(20214),c=r(13538),d=r(42279),h=r(32639),f=r(59455),m=r(41583),g=r(48884),p=r(50213),y=r(88158),v=r(15674),w=r(42638);var S=r(20214);async function b(e){if(null==e)return[];const t=(0,i.compact)(await e);return(0,i.isEmpty)(t)?[]:(0,i.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:r,timeoutMs:n}){const s=[];for(const o of(0,i.compact)(await t))try{const e=await((0,l.gt0)(n)?(0,c.thenOrTimeoutError)(r(o),n):r(o));null!=e&&s.push([e,o])}catch(t){(0,p.mkLogger)(e).warn("failed to apply",{ea:o,error:t})}return s}async function E({arr:e,f:t,name:r,maxConcurrent:n,timeoutMs:s,promises:o}){if(null==e)return[];const a=(0,i.compact)(await e);if((0,i.isEmpty)(a))return[];if((n=Math.round(n??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:r,timeoutMs:s});const u=o??(a.length<=n?w.PermissivePromises:new w.Promises(r,(()=>n))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,h=await u.enqueueAll(r,a.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,p.mkLogger)(r).warn("failed to apply",{ea:e,error:t})}})));return(0,i.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,r){const i=[];for(const n of(0,g.batches)((0,f.toA)(await e),t)){const e=await b(n);i.push(...await b(r(e)))}return i},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,a.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const r of(0,i.compact)(e)){const e=await r();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;if(null!=e)if(Array.isArray(e))for(const r of e){const e=await r;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;null!=e&&t.push(e)}return(0,i.uniq)(t)},t.asyncFind=async function(e,t){for(const r of e)if(await t(r))return r},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=E,t.mapAsync=async function({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s}){return(await E({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:r,maxConcurrent:n,timeoutMs:s}){return(await E({name:e,arr:(0,i.compact)(t),f:r,maxConcurrent:n,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const r=await E({name:"partitionAsync",arr:e,f:t});return[r.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),r.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*o.secondMs,t.tryAll=async function(e,r=(e=>console.error(e)),i=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,i)}catch(e){r((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),r=(()=>{})){let i,n=null;try{i=await((0,h.isFunction)(e)?e():e)}catch(e){n=(0,m.toErr)(e);try{await t(e)}catch{}}try{await r(n??i)}catch{}if(null!=n)throw n;return i},t.thenNot=async function(e,t=!0){if(null==e)return t;const r=await e;return null==r?t:!(0,s.isTrue)(r)},t.thenMap2=async function(e,t,r){const i=await e;if(null==i)return;const n=await t;return null!=n?r(i,n):void 0},t.thenMapOr=async function(e,t,r){const i=await e;if(null==i)return r();const n=await t(i);return null==n?r():n},t.thenMap2Or=async function(e,t,r,i){const n=await e;if(null==n)return i();const s=await t;if(null==s)return i();const o=await r(n,s);return null==o?i():o},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null==i)continue;const e=await t(i,r);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const r of e){const e=await r();if(null!=e){const r=await t(e);if(null!=r)return r}}},t.firstResolvedDefinedPromise=async function(e,t){for(const r of e)try{const e=await r();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const r of t)try{const t=await r();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:r}){const i=await E({name:e,arr:t,f:r});return(0,n.sortBy)(i,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const i=r(19851),n=r(40958),s=r(76790),o=r(42659),a=r(49769),l=r(31586),u=r(68708),c=r(42279),d=r(41583),h=r(22454),f=r(14121),m=r(50213),g=r(7282),p=r(34102),y=r(82647),v=r(25764),w=r(38836),S=r(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,r){const i=Date.now(),n=(0,l.clamp)(10*o.secondMs,o.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-i)+"ms")}),n);try{const n=await(0,c.tot)(t),s=Date.now()-i;return r?.(n,s),this.push(e,s),n}catch(t){throw this.errors.incr(e),r?.((0,d.toErr)(t),Date.now()-i),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),r=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),i=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",r.stats()],...i])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,a.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:r.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:(0,l.mapFinite)(r.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:r.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:{sumSec:(0,l.sigFigs)(r.sum/o.secondMs,3),...(0,u.omit)(r.stats(),"sum")}})),{})}}function _(e,t,r){return P.instance().time(e,t,r)}function E(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,i.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,n.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,g.isTest)()&&(0,p.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const r=Date.now(),i=t();return E(e,Date.now()-r),i},t.pushTime=E,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,r){return(0,i.lazy)((async()=>_(e,t)),r)}},42638:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(r(66261)),m=r(40958),g=r(55835),p=r(31586),y=r(42279),v=r(54993),w=r(89788),S=r(82647),b=r(15674),P=r(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){i.add(this),this.name=e,this.ee=new f.default.EventEmitter,n.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),o.set(this,[]),a.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,n,t,"f")}get maxConcurrency(){return Math.floor((0,p.clamp)(1,(0,b.maxCpus)(),d(this,n,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,a,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,o,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,o,"f").map((e=>e.name)),pendingNames:d(this,a,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:r,serialId:n}){const s=d(this,i,"m",l).call(this,{name:e,l:t,payload:r,serialId:n});return this.laterPop(),s}enqueueAll(e,t){const r=t.map((t=>d(this,i,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(r)}serial(e,t,r){return this.enqueue({name:e,l:t,serialId:e,payload:r})}push(e,t,r){return d(this,i,"m",u).call(this,new P.Deferred(e,{payload:r}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,o,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,a,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,a,"f").length,e),r=this.runningSerialIds,n=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,o,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,a,"f").length}hasPending(){return d(this,a,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,p.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,a,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,a,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=function({name:e,l:t,payload:r,serialId:i}){const n=new P.Deferred(e,{payload:r,serialId:i});return d(this,a,"f").push({d:n,l:t}),n},u=function(e,t){const r=Date.now();return this.lastWorkTs=r,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,o,"f"),e),this.settleMsAvg.push(Date.now()-r),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,o,"f").push(e),e},t.maybeRun=function(e,t){const r=new _(e);return()=>r.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:r}){return new _(e,(0,g.map)(r,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class r extends Error{}t.RedoableError=r},4867:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const i=r(40958),n=r(34546),s=r(41400),o=r(31586),a=r(83104),l=r(85556),u=r(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:r}){let a=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>a=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>{if(a)throw new l.TimeoutError})):void 0,r?.abortPromise_().then((()=>{if(a)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:r}){let l=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>l=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>a.Timeout)):void 0,r?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let r=e=>null;t.setTimeoutHandler=function(e){r=e},t.onTimeout=function({soft:e}={}){r(e)}},73614:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const i=r(87997);t.setUnrefTimeout=function(e,t,...r){return(0,i.setTimeout)(e,Math.round(t),...r).unref()},t.setUnrefInterval=function(e,t,...r){return(0,i.setInterval)(e,Math.round(t),...r).unref()}},31562:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const i=r(38639),n=r(42659),s=r(41400),o=r(32639),a=r(31586),l=r(45255),u=r(95937);async function c(e,{timeoutMs:t,intervalMs:r,acceptable:i,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const i=r??(0,a.clamp)(10*m,l.ShortCommandTimeoutMs,(t??n.minuteMs)/5);await(0,s.delay)(i,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:i.isTrue,timeoutResult:!1})}},9727:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const n=i(r(1708)),s=r(45599),o=r(41400),a=r(50357),l=r(68708),u=r(48884),c=r(36638),d=r(44198),h=r(59958),f=r(96706),m=r(34102),g=r(19851),p=r(19043),y=r(66184),v=r(50213),w=r(7282),S=r(88158),b=r(45969),P=r(43334),_=r(28874),E=r(3790);function M(e){return C().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const C=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const r of t.names)e.add(r);for(const r of t.keys)e.add(r)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,o.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const T=["HOME","LANG","USER"],x=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],D=(0,g.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?T:x),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function k(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const r of(0,_.persistedSettings)()){const i=e?r.value:r.envValue;null==i||(0,a.eql)(i,r.defaultValue)||r.addToEnv(t)}return t}t.sanitizedEnv=(0,g.lazy)((()=>(0,l.filter)(n.default.env,(e=>M(e)||!(0,E.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=k,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:I({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let O=!1;function I({overrides:e,forceCLocale:r=!0,forWorker:i=!1}={}){const n=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...D(),...r?(0,p.childProcLocale)():{},...k(i),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(n);if((0,y.isLogged)("debug")&&!O){O=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(n).map((([e,t])=>[e,(0,E.isHiddenEnvKey)(e)?"(hidden)":t])),[r,i]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(r)),e.debug("non PS env:",(0,l.fromEntries)(i))}return n}t.childEnv=I},84777:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const n=i(r(31421)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(42659),c=r(98553),d=r(56409),h=r(31586),f=r(68708),m=r(51926),g=r(50213),p=r(7282),y=r(88158),v=r(79089),w=r(45255),S=r(22911),b=r(4867),P=r(73614),_=r(70025),E=r(57159),M=r(36868),C=r(66184),T=r(45643),x=r(95402),D=r(9727),k=(0,o.lazy)((()=>(0,g.mkLogger)("child.ChildProcess")));function O(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function I(e,t=30*u.secondMs){if(null==e)return!1;k().debug("endProcess()",O(e));const r=e.pid;if(null==r||r<=0)return k().warn("endProcess(): asked to end invalid pid",O(e)),!1;if(r===s.default.pid)return k().warn("endProcess(): asked to end MY pid",O(e)),!1;if(r===s.default.ppid)return k().warn("endProcess(): asked to end my parent pid",O(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();k().debug("endProcess("+r+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,x.killPid)(r).catch((e=>{k().warn("endProcess(): kill("+r+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,p.isSingleSpecTests)())return!0;if(await(0,T.waitForPidExit)(r,t))return k().debug("endProcess(): exitted",O(e)),!0;{x.Pids.instance()?.onKill(r);const t=e.kill("SIGKILL");k().warn("endProcess("+r+") had to resort to SIGKILL",{killResult:t}),t||await(0,x.killPid)(r,!0).catch((e=>{k().warn("endProcess(): kill("+r+",true) failed: "+e)}))}return(0,T.waitForPidExit)(r,5e3)}function F(e,r,i,n=0){const o=new Date,a=[];return(0,v.niceable)(r,i)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(n,u.secondMs)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&I(e)}),n-250)),a.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,x.addPid)({pid:e.pid,cmd:r,timeoutMs:n,ppid:s.default.pid},o)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>a.forEach(clearTimeout))),e}function L(e,t,r,i){const s=(0,D.spawnOptions)(i);return(0,C.isLogged)("trace",k().context)?k().debug("execFile()",{command:e,args:t,timeoutMs:r,opts:s}):k().debug("execFile()",{command:e,args:t,timeoutMs:r}),F(n.default.execFile(e,t,s),e,t,r)}async function A(e,t,r){const i=r.quiet??!1,n=r.ignoreStderr??!1,s=r.ignoreExitCode??!1,o=L(e,t,r.timeoutMs,(0,f.omit)(r,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===r.disconnect){try{o.disconnect?.()}catch{}return{result:"",pid:o.pid}}const u=o.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],g=[],p=[],y=new S.Deferred(f);o.on("error",(e=>p.push(e))),o.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),o.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(o.stdin);const v=new d.Latch;null==o.stdout?v.resolve():(o.stdout.on("error",(e=>p.push(e))),o.stdout.on("data",(e=>m.push(e))),o.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==o.stderr||n?P.resolve():(o.stderr?.on("error",(e=>p.push(e))),o.stderr?.on("data",(e=>g.push(e))),o.stderr?.on("end",(()=>P.resolve()))),k().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:r.timeoutMs,halt:r.halt}),k().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt});const C=g.join("");(0,l.notBlank)(C)&&p.push(new Error(C)),!i&&(0,a.isNotEmpty)(p)&&k().warn(f+" resulted in errors:",p);const T=r.isIgnorableError??_.isIgnorableError,x=p.filter((e=>!0!==T(e)));if(x.length>0)throw 1===x.length?x[0]:new E.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:x});if(!s&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:C}}catch(e){throw k().error("stdoutResult_() failed",e),await(0,x.killPid)(o.pid,!0),e}}t.endProcess=I,t.ReniceAfterMs=(0,o.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,o.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,r,i){const s=(0,D.spawnOptions)(i);return k().debug("spawn()",{command:e,args:t,maxAgeMs:r}),F(n.default.spawn(e,t,s),e,t,r)},t.execFile=L,t.stdoutResult_=A,t.stdout_=async function(e,t,r){const i=await A(e,t,r);return k().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(i.result),meta:{cmd:e,args:t,opts:r,result:i}})}},3790:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const i=r(22573),n=r(41400),s=r(19851),o=r(28874);(0,n.later)((()=>o.Settings.sensitiveEnvRegExp.watchLater((()=>a.unset()))));const a=(0,s.lazy)((()=>{try{return new RegExp(o.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${o.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(o.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,i.blank)(e)&&a().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||o.Settings.license.includesEnvKey(e)}},69554:function(e,t,r){var i,n=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const s=r(6858),o=r(1708),a=r(37805),l=r(22573),u=r(55835),c=r(7282),d=r(19913),h=r(43334),f=r(41269),m=r(80061),g=r(94361);t.CLI=class{constructor(e,t,r){this.serviceName=e,this.args=t,this.additionalDescription=r,i.set(this,[]),(0,d.setServiceName)(e),(0,g.verifyUidGid)()}add(...e){return n(this,i,"f").push(...e),this}async parse(e=o.argv,t){let r=(0,m.addHelpFooter)(new s.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{r=r.arguments(e)}));for(const e of n(this,i,"f"))r=e.beforeParse(r);r.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":a.version)+")"),r.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,o.exit)(0)})),r.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=r.opts();for(const e of n(this,i,"f"))await(e.afterParse?.(d));return r}},i=new WeakMap},41269:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const i=r(1708),n=r(31586),s=r(51926),o=r(17344),a=r(37805),l=r(84542);function u(e,t){const r=t?.maxLineLen??(0,n.toInt)(i.env.maxLineLen)??i.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:r,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,o.EditionName)()+" v"+a.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const i=r(38639),n=r(17181),s=r(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,i.mapBoolean)(e.color,(e=>{s.Settings.logColor.envValue=e,(0,n.setupLogFormatter)()}))}}},94361:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const i=r(19851),n=r(40958),s=r(55835),o=r(31586),a=r(94174),l=r(44198),u=r(45969);function c(e,t,r){const i=(0,o.toGt0)((0,l.env)()[t]);return null==i||r.includes(i)?void 0:`WARNING: ${e} is running as ${r} but $${t}=${i}`}function d(){const e=(0,n.compactBlanks)([c("user id","PUID",(0,a.userids)()),c("group id","PGID",(0,a.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,i.lazy)((()=>{(0,u.isDocker)()&&(0,s.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},76596:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const i=r(51168),n=r(19851),s=r(22573),o=r(42659),a=r(55835),l=r(31586),u=r(68708),c=r(34666),d=r(50213),h=(0,n.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,r){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=r}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const r=(0,a.mapOr)(e,(e=>e.getTime()),(()=>0)),i=(0,a.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(r,i)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),r=Date.now();return t<=r?0:t-r},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,o.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const i=r(22573),n=r(31586),s=r(54557),o=r(91655),a=new s.FifoCache(512);function l(e){return(0,n.isNumber)(e)?e:(0,i.blank)(e)?void 0:a.getOrSet(e,(()=>(0,o.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,i.blank)(e)?void 0:u.getOrSet(e,(()=>(0,o.fmtFullDuration)((0,n.isNumber)(e)?e:l(e))))}},91655:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const i=r(51168),n=r(40958),s=r(22573),o=r(42659),a=r(31586),l=r(51926),u=r(68852),c=r(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,a.isNumber)(e))return;if((0,a.isNumber)(e))return e;if((0,a.isDigits)(e))return(0,a.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=i.Duration.fromISO(e);if(t.isValid)return t.toMillis();const r=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(r,e);if(0===d.length)return;const h=(0,n.compact)(d.map((e=>function(e,t){const r=(0,a.toFloat)(e);if(null!=r){if((0,s.blank)(t))return r;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*o.yearMs;case"weeks":case"week":case"w":return r*o.weekMs;case"days":case"day":case"d":return r*o.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return r*o.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return r*o.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return r;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,a.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:o.yearMs,s:"y"},{ms:o.weekMs,s:"w"},{ms:o.dayMs,s:"d"},{ms:o.hourMs,s:"h"},{ms:o.minuteMs,s:"m"},{ms:o.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,r=""){if(!(0,a.isNumber)(t))return;if(0===t)return"0";if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const i=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const r=Math.floor(t/e.ms);t-=r*e.ms,r>0&&i.push(r+e.s)}return i.join(r)}},84248:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const i=r(50989);t.AutoVacuumModes=(0,i.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const i=r(50989);t.CheckpointTypes=(0,i.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const i=r(50989);t.RepairModes=(0,i.strEnum)("dump","recover")},34365:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const i=r(50989);t.SynchronousModes=(0,i.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const o=s(r(76760)),a=r(40958),l=r(22573),u=r(55835),c=r(72993),d=r(19851),h=r(97352),f=r(94174),m=r(44198),g=r(96706),p=r(8769),y=r(57159),v=r(70698),w=r(64680),S=r(29882),b=r(45969),P=r(43334),_=r(28874),E=r(41692),M=r(32774),C=r(80612),T=r(32551),x=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function D(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+x(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,g.getEnv)("TEMP"),(0,g.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const r of t)(0,l.blank)(r)||e.push({dir:(0,o.join)(r,".photostructure-cache"+x()),preexistingDir:r});return e}}function k(){if((0,b.isDocker)())return(0,a.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,o.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+x(),preexistingDir:M.DefaultDockerLibraryDir},...D()]);const e=(0,a.compactBlanks)(P.isWin?[(0,g.getEnv)("LOCALAPPDATA"),o.default.resolve((0,T.homeDir)(),"AppData","Local")]:P.isMac?[o.default.resolve((0,T.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,o.join)((0,T.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,r=e.map((e=>({dir:(0,o.join)(e,t),preexistingDir:e})));return r.push(...D()),r}t.tmpCacheDirs=D,t.tmpDirs=function(){return(0,C.filterDirs)({dirs:D(),desc:"tmp"})},t.cacheDirs=k,t.defaultCacheDir=(0,d.lazy)((()=>(0,C.firstDir)({dirs:k(),desc:"cache"})));const O=(0,d.lazy)((()=>{(0,E.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(I)}));function I(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,p.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{O();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=I},46292:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const i=r(19851),n=r(45969),s=r(41692),o=r(32774),a=r(10924),l=r(84373),u=r(80612);t.configDir=(0,i.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,n.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,a.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:o.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:o.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,n.isDocker)()?c:(0,a.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const i=r(66430),n=r(45969),s=r(32774);t.defaultLibraryDir=function(){return(0,n.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,n.isDocker)()&&(0,i.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const n=i(r(76760)),s=r(40958),o=r(72993),a=r(44198),l=r(96706),u=r(43334),c=r(80612),d=r(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),n.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(n.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,a.env)().XDG_DATA_HOME,(0,a.env)().XDG_CONFIG_HOME,n.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:n.default.join(e,(0,o.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const i=r(22573),n=r(96706),s=r(29882);t.envConfigDir=function(){const e=(0,n.getEnv)("PS_CONFIG_DIR");if(!(0,i.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const i=r(44652),n=r(40958),s=r(22573),o=r(66430);function a({dirs:e,desc:t}){for(const{dir:r,preexistingDir:a}of(0,n.compact)(e))if(!(0,s.blank)(r)){if((0,o.isReadWriteableDirectorySync)(r))return r;if((0,s.blank)(a)||(0,o.isReadWriteableDirectorySync)(a))try{return(0,i.mkdirpSync)(r),r}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=a,t.filterDirs=function({dirs:e,desc:t}){return(0,n.compact)(e.map((e=>a({dirs:[e],desc:t}))))}},32551:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const i=r(48161),n=r(76760),s=r(1708),o=r(19851),a=r(40958),l=r(68284),u=r(43334);t.homeDir=(0,o.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,a.compactBlanks)(e)){const e=(0,n.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,i.homedir)()}))},46296:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(55835),u=r(54993),c=r(72993),d=r(96706),h=r(45969),f=r(43334),m=r(32707),g=r(6707),p=r(49776),y=r(32774),v=r(80612),w=r(32551);function S(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:n.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,o.compact)((0,p.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>n.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,a.notBlank)(e))return e;const t=(0,g.readTomlFileSync)((0,m.systemSettingsFile)()),r=(0,u.toS)(t?.logDir);return(0,a.notBlank)(r)?r:b()}catch(e){return console.error("defaultLogDir_() failed",e),n.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const i=r(76760),n=r(19851),s=r(22573),o=r(44198),a=r(43334),l=r(24399),u=r(32551);async function c(){return a.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,n.lazy)((async()=>{if(a.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,n.lazy)((()=>(0,o.env)().XDG_PICTURES_DIR??(0,i.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const i=r(38639),n=r(7282),s=r(29325),o=r(44198);t.getDevEnvFlag=function(e){return!(0,n.isProd)()&&!(0,s.isPacked)()&&((0,i.toBoolean)((0,o.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,o.env)()[e]=String(t)}},34580:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const i=r(38639),n=r(44198);t.doNotTrack=function(){return(0,i.isTrue)((0,n.env)().DO_NOT_TRACK)}},44198:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const n=i(r(73024)),s=r(76760),o=i(r(1708)),a=r(19851),l=r(40958),u=r(41400),c=r(68708),d=r(76850),h=r(7282),f=r(32551),m=r(34102),g=r(53265),p=r(45969),y=r(59958),v=r(6012),w=r(96706);t.env=(0,a.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>o.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,p.isDocker)()||(0,h.isTest)()&&"lite"===o.default.env.PS_LICENSE||e.push((0,s.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),r={...o.default.env};for(const i of e)try{const e=(0,d.debom)(n.default.readFileSync((0,g.resolve)(i))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,i]of(0,c.entries)(s))t.test(e)||(r[e]=i)}catch(e){console.warn("env(): failed to read .env file, "+i,e)}return r})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const i=r(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,i.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const i=r(50989);t.EnvKeys=(0,i.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const i=r(22573),n=r(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const r={};if((0,i.blank)(e))return r;let s;for(const o of(0,n.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(o));){if(null==s.groups)continue;const{key:e,val:n}=s.groups;if((0,i.blank)(e)||null==n)continue;const o=n.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");r[t?e.toLowerCase():e]=o}}return r}},96706:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const n=i(r(1708)),s=r(19851),o=r(22573),a=r(38639),l=r(41400),u=r(40583),c=r(79840),d=r(83556),h=r(34102),f=r(44198),m=r(83373);function g(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function p(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,o.firstNotBlank)(n.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,n.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=g,(0,l.later)((()=>{f.env.watchLater(g),(0,h.ee)().on("clearCache",g)})),t.getEnv=p,t.isEnvTrue=function(e){return(0,a.isTrue)(p(e))}},98314:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const i=r(58587),n=r(19851),s=r(40958),o=r(22573),a=r(26905),l=r(96249),u=r(51926),c=r(23541),d=r(54993),h=r(89788),f=r(50213),m=r(81168),g=r(84542),p=r(41954),y=r(38835),v=r(70025),w=r(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,p.getErrorDescriptions)(e));const r=[...e.filter(c.isError).map(a.errorName),...e.map(a.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,g.splitCompactLines)(e))).flatMap((e=>e.split(a.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(r)))}function b(e){return(0,s.compact)(e).filter((e=>!a.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(o.notBlank)}function P(e,t){const r=(0,s.uniqSubstrings)(b(e)),i=t?.maxLen??400,n=t?.trailingChars??64,o=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(r.join(a.ErrorDelimiter)),i-o.length,n)+o.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,o.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,n.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new i.Rate,t.fatalErrorRate=new i.Rate,t.internalErrorRate=new i.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,o.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const r=(0,d.toS)(t?.[e]);if((0,o.notBlank)(r))return r}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,r=256,i=7){return(0,o.blank)(e)&&(e=t.MissingError),_(e,{maxLen:r})+" at "+(0,a.shortStack)(e?.stack,i).join("; ")}},41954:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const i=r(40958),n=r(26905),s=r(55835),o=r(54993),a=r(81168);t.describeError=function(e){const t=(0,a.stripSuffix)((0,o.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const r of e)(0,s.map)((0,n.errorErrno)(r),(e=>t.push(u.get(e)))),(0,s.map)((0,n.errorCode)(r),(e=>t.push(l[e]?.description)));return(0,i.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const i=r(40958),n=r(76790),s=r(50989),o=r(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,n.sortBy)((0,i.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(o.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const i=r(40958),n=r(38639),s=r(26905),o=r(54993),a=r(68852),l=r(73568),u=r(78656),c=r(98314),d=r(38835);function h(e){return(0,o.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const r=(0,o.toS)(e)+(0,i.compact)(t).join("");return h(r)+f(r).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const g=/Can't write [a-z\d]+ files/i,p=(0,a.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const r=(0,c.errorToS)(e);return!g.test(r)&&(!!p.test(r)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,n.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const r=(0,c.errorToS)(e);return!(!r.includes("EBUSY")&&!r.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const r=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>r.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,n.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,n.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},8769:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const i=r(22573),n=r(31586),s=r(68708),o=r(7282),a=r(23560),l=r(45608),u=r(34102),c=r(28874),d=r(98314),h=r(38835),f=r(70025),m=r(57159),g=r(5012);function p(e,t){try{if((0,i.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,g.stack)()),!1;const r=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const n=!0===r.fatal,c=!0===r.ignorable;if(!n&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),n&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",r));const h=!n||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:r}),!n||(0,o.isTest)()||(0,a.isWebService)()||(0,l.exit)({reason:r.toString(),status:r.errno??13}),n}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,n.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,a.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,n.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,n.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=p,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,r){return p(e+h.InternalErrorFlag,{cause:t,...r})}},57159:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const i=r(40958),n=r(22573),s=r(38639),o=r(26905),a=r(98553),l=r(68708),u=r(59455),c=r(41583),d=r(48884),h=r(81168),f=r(98314),m=r(38835),g=r(70025);t.toWrappedError=function(e,t){const r=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof p&&(null==t||(0,n.blank)(r.message)||e.message.includes(r.message)))return e;const i=(0,n.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,r?.message);return new p(i??"(missing error message)",r)};class p extends Error{constructor(e,t={}){super(e),this.causes=(0,i.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,o.errorName)(t)??(0,d.first)(this.causes,o.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(o.errorCode)],o.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,o.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.path))),this.flags=t?.flags??[];const r=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??r.some(g.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(r.map(g.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(r.map(g.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(r.map(g.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,g.stripErrorFlags)(function(e,t){let r=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const i=t?.path;return(0,n.blank)(i)||(r=(0,h.dedupeNeedle)(r,i,"file")),(0,f.joinErrorMessages)([r[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,a.stringify)(t.meta):void 0,...r.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new p(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=p},5012:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const o=r(49769),a=r(55835),l=r(54993),u=r(22911),c=r(89788),d=r(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,i.set(this,new Map),n.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,o.getOrSet)(s(this,i,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const r=this.target.emit(e,...t),o=s(this,i,"f").get(e);return null!=o&&(o.resolve(t),s(this,i,"f").delete(e)),r}emitDebounced(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},i=new WeakMap,n=new WeakMap},34102:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const i=r(78474),n=r(19851),s=r(15197);t.ee=(0,n.lazy)((()=>{const e=new i.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const n=i(r(73024)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(65843),u=r(16287),c=r(43334),d=(0,o.lazy)((()=>s.default.geteuid?.())),h=(0,o.lazy)((()=>s.default.getgroups?.()));function f(e,t){try{return!(0,a.blank)(e)&&(n.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,n.default.constants.R_OK|n.default.constants.W_OK):p({stat:e,r:!0,w:!0,x:!0})}function g(e,t){return c.isWin?f(t,n.default.constants.R_OK):p({stat:e,r:!0,x:!0})}function p({stat:e,r:t=!1,w:r=!1,x:i=!1,processUid:n,processGid:s}){if(null==e)return!1;const o=n??d(),a=null!=s?[s]:h()??[],l=0===o,u=l||e.uid===o,f=l||a.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(r&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!i||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=g,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const r of(0,l.selfAndAncestorG)(e)){const i=await(0,u.statMaybe)(r);if(null!=i){if(!i.isDirectory())return!1;if(t){if(!g(i,e))return!1}else if(t=!0,!m(i,e))return!1}}return!0},t.access=p},21144:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const n=i(r(76760)),s=r(19851),o=r(81168),a=r(57159),l=r(43334),u=r(88561),c=r(29882),d=r(65238),h=r(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const r=(0,c.parseNativePath)((0,h.resolve)(...e)),i=await m(r.dir);for(const e of await(0,d.readdir_)(i))if((0,o.equalsIgnoreCase)(e.basename,r.base))return n.default.join(i,e.basename);throw new a.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const i=r(73024),n=r(76760);function s(e){return[...o(e)]}function*o(e){for(;e!==(0,n.dirname)(e);)e=(0,n.dirname)(e),yield e}function a(e){try{return(0,i.readdirSync)(e)}catch(e){return[]}}function l(e,t){const r=a(e);return t.every((e=>r.includes(e)))}t.ancestors=s,t.ancestorG=o,t.selfAndAncestorG=function*(e){yield e,yield*o(e)},t.childrenSync=a,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,r){var i,n,s,o,a,l=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&l(t,e,r);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(r(44652)),g=c(r(73024)),p=r(51455),y=f(r(76760)),v=f(r(1708)),w=r(46466),S=f(r(57975)),b=f(r(38522)),P=r(19851),_=r(40958),E=r(5233),M=r(22573),C=r(42659),T=r(50357),x=r(96249),D=r(98553),k=r(55835),O=r(31586),I=r(68708),F=r(97790),L=r(39926),A=r(51926),N=r(59455),R=r(54993),j=r(48884),B=r(22911),V=r(99331),z=r(56519),W=r(56038),q=r(31562),U=r(76850),G=r(70025),H=r(34102),J=r(80875),$=r(50213),K=r(70417),Y=r(43334),Z=r(81168),X=r(96859),Q=r(65162),ee=r(94174),te=r(64660),re=r(21144),ie=r(84542),ne=r(89968),se=r(20197),oe=r(88561),ae=r(50597),le=r(33456),ue=r(29882),ce=r(78133),de=r(43899),he=r(65238),fe=r(53265),me=r(17217),ge=r(16287),pe=r(68284),ye=r(66003),ve=r(27794),we=r(73428),Se=r(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new oe.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(i.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,$.mkLogger)("fs.BaseFile("+this.nativePath+")"))),n.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),o.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(n=new WeakMap,o=new WeakMap,i=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),r=await Promise.all(t.map((e=>e.shaMs())));return t[(0,j.leastIndex)(r)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const r=(0,me.isSimpleFile)(e)?e.nativePath:(0,R.toS)(e);if((0,M.blank)(r))throw new Error("BaseFile.for(): empty nativePathOrFile");const i=be().get(r);if(null!=i)return i;const n=(0,fe.resolve)(r),s=new Pe(n,t);return be().set(r,s),be().set(n,s),s}static clear(e){(0,H.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,H.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,n,"f").unset(),h(this,o,void 0,"f"),this}clearThisAndParent(){return(0,H.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,z.thenMap)(this.stat(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,k.map)(this.statSync(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,n,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const r=[];for(const i of t)!0===await e(i)&&r.push(i);return r}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,z.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,i,"m",s).call(this)??await d(e=this.clearThisAndParent(),i,"m",s).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>g.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>g.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,z.thenMap)(this.children(),(async t=>{for(const r of t)await r.visitDescendants(e),await e(r)}))}async descendants(e){const t=[];t.push(...(0,N.toA)(await this.childFiles(e)));const r=await this.childDirectories();if(null==r)return t;for(const i of r)t.push(...(0,N.toA)(await i.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,O.gt0)(t))return;const r=await d(this,n,"f").call(this)??[];for(const t of r)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const i of r)if(i.isDirectory()){const r=await this._directoryEntryChild(i).someDescendant(e,t-1);if(null!=r)return r}}descendantsSync(e){const t=this.directoryEntrySync(),r=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&r.push(this.forDirectoryEntry(t))})),r}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,re.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,T.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,k.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,r)=>this.join((0,R.toS)(e),(0,L.pad2)(t+1),(0,L.pad2)(r))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,x.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,r="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(r,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,r="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(r,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,r){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(r??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,ge.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??await(0,ge.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??(0,pe.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,z.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,z.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,z.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,z.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,C.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,ge.statTimes)(e)}maxStatMs(){return(0,z.thenMap)(this.statTimes(),j.max)}maxStatDate(){return(0,z.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,z.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,z.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,z.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,z.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,z.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,z.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>=(0,C.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,z.thenMap)(this.mtimeMs(),(r=>Math.abs(r-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>(0,C.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,z.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,k.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,F.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,q.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*C.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,ae.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,ae.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,J.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,J.parseJSON)((0,g.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,g.readFileSync)(this.nativePath)}readFile_(){return(0,p.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,U.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,z.thenMap)(this.zReadFile_(e),R.toS)))}readLines(e="warn"){return(0,z.thenMap)(this.readTextFile(e),ie.splitLines)}readFileSync(){try{return g.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces),(0,I.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,E.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,V.ending)()?1:3,timeoutMs:0,retryDelay:C.secondMs,errorIsRetriable:G.isRetriableError})}async gunzip(){return d(this,i,"m",a).call(this,(0,Z.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,i,"m",a).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,i,"m",a).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return g.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return g.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const r=await this.children((async r=>!r.isNameHidden()&&t===r.size()&&r.nativePath!==e.nativePath));if((0,_.isEmpty)(r))return;const i=await e.sha();if(null!=i)for(const e of r.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===i)return e}))}firstMatchingLine(e){const t=new B.Deferred("firstMatchingLine("+this+")"),r=g.default.createReadStream(this.nativePath,{flags:"r"});return r.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),r.close()):t.maybeReject(e)})),r.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(r,(0,A.newlineRe)(),(i=>{const n=e.exec(i);null!=n&&(t.maybeResolve(n),r.close())})),t.promise}contemporary(e,t){return(0,z.thenMap2Or)(this.statTimes(),e.statTimes(),((e,r)=>{for(const i of e)for(const e of r)if((0,O.closeTo)(i,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),r=new B.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&r.setTimeout(e.timeoutMs),_e)try{const i=(0,g.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(i,n)=>{try{const s=await e.f(i,(0,k.denull)(n));t(s)&&r.resolve(s)}catch(e){r.reject(e)}}));r.finally((()=>{i.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,O.gt0)(e.intervalMs)){const i=setInterval((async()=>{try{const i=await e.f();t(i)&&r.resolve(i)}catch(e){r.reject(e)}}),e.intervalMs);e.persistent||i.unref(),r.finally((()=>{clearInterval(i)}))}return r}}t.BaseFile=Pe,s=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,j.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,k.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},a=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const r=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([g.default.createReadStream(this.nativePath,{autoClose:!0}),t,g.default.createWriteStream(r.nativePath,{autoClose:!0})]),await this.unlink(),r}))},Pe.attrTTL=3*C.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},84542:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const i=r(40958),n=r(96249),s=r(51926),o=r(54993),a=r(43334);function l(...e){return(0,n.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,o.toS)(e).split((0,s.newlineRe)()))))}t.Newline=a.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(o.toS).join("\n");return a.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,i.compactBlanks)(l(...e))}},70698:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const i=r(76760),n=r(19851),s=r(50213),o=r(37805),a=r(29882),l=r(93854),u=r(17217),c=r(16287),d=r(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,n.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const r=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return r===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,i.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const r=(0,u.toNativePath_)(e);await(0,a.mkdirp_)(r),await(0,d.writeTextfile_)((0,a.joinNativePath)([r,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+o.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(45969),u=r(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,o.lazy)((()=>[...(0,a.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,n.default.join(e,"System32"),n.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const a=s(r(44652)),l=o(r(73024)),u=r(76760),c=r(57975),d=r(19851),h=r(59455),f=r(50213),m=r(81168),g=r(34102),p=r(29882),y=r(65238),v=r(14427),w=r(17217),S=r(16287),b=r(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class E{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,p.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new E(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:r,base:i}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,p.parseNativePath)(e)},n=await a.stat(t);return new E(r,new P(i,n))}clear(){return(0,g.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return E.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,p.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,p.parseNativePath)(this.dir);return e.dir===this.dir?this:new E(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>E.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new E(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const r of t)r.isDirectory()&&await r.visitDescendants(e);for(const r of t)r.isFile()&&await e(r);for(const r of t)r.isDirectory()&&await e(r)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const r of t)r.isFile()&&e(r);for(const r of t)r.isDirectory()&&(r.visitDescendantsSync(e),e(r))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async r=>{!0===await e(r)&&t.push(r)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await a.unlink(this.nativePath),(0,g.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await a.rmdir(this.nativePath,e),(0,g.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=E},20197:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const n=i(r(76760)),s=r(39926),o=r(29882),a=r(16287),l=r(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if(await(0,o.mkdirp_)(i.dir),!r.requireNumber&&await(0,a.isEmptyFile)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if(await(0,a.isEmptyFile)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)},t.ensureNewNativePathSync_=function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if((0,o.mkdirpSync_)(i.dir),!r.requireNumber&&(0,l.isEmptyFileSync)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if((0,l.isEmptyFileSync)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)}},88561:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const o=r(40958),a=r(22573),l=r(41400),u=r(68708),c=r(25764),d=r(38836),h=r(34102),f=r(80049),m=r(50213),g=r(88158),p=r(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:p.ShortCommandTimeoutMs,...e}),i.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>s(this,i,"m",n).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,g.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,o.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,i=new WeakSet,n=async function(e){if((0,a.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const i=r(73024),n=r(22573),s=r(45599),o=r(96249),a=r(68708),l=r(54993),u=r(49047),c=r(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,s.defer)((()=>{const e={};for(const[t,...r]of d)for(const i of r)e[i]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof i.Dirent?e.name:(0,l.toS)(e),r=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,n.blank)(r)?void 0:h()[r]??r}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,o.flatten)((0,a.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const r of t)if(r===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const i=r(68708),n=r(17217),s=r(16287),o=r(68284);async function a(e){return(0,i.pick)(await(0,s.stat_)((0,n.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=a,t.fileStats=async function(e){try{return await a(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,o.statSync)((0,n.toNativePath)(e)))?void 0:(0,i.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},4001:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const i=r(22573),n=r(55835),s=r(31586),o=r(51926),a=r(54993),l=r(97352),u=r(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,i.toNotBlank)(e.name)??(0,a.toS)(e),t).normalize()}function f(e,r){if(t.ymdIsoRE.test(e))return e;let i=e;for(const e of r.aggressive?d:c){const t=i.match(e);if((0,s.gt0)(t?.index)){const e=i.slice(0,t.index).trim();e.length>0&&(i=e)}}return e===i?e:f(i,r)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),r=t.pop();if((0,i.blank)(r))return e;const n=(0,u.parsePosixPath)(r),s=h(n,{aggressive:!1});return[...t,s+n.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,o.isString)(e)?e:e.name).toLowerCase().normalize(),r=h(t),i=(0,o.stripPrefix)(t.toLowerCase().normalize(),r);return(0,n.map)((0,l.extractInt)(i),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,g=/(?<=.{6})_cover$/i,p=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,o.isString)(e)?e:e.name).trim().replace(g,"").trim();return(0,n.map)(m.exec(t),(e=>t=e[1].trim())),(0,n.map)(p.exec(t),(e=>t=e[1].trim())),t}},14977:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const n=i(r(44652)),s=i(r(73024)),o=r(46466),a=i(r(38522)),l=r(49769),u=r(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,o.pipeline)(s.default.createReadStream(e,{autoClose:!0}),a.default.createGzip(),s.default.createWriteStream(t,{autoClose:!0})),await n.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const n=i(r(77598)),s=i(r(73024)),o=r(46466),a=r(19851),l=r(98553),u=r(68708),c=r(23467),d=r(80049),h=r(73913),f=r(50213),m=r(12089),g=r(37628),p=r(43624),y=r(17217),v=r(16287),w=(0,a.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),S=(0,a.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:r=!0}={}){const i=(0,y.toNativePath_)(e);if(r){const t=S().get(i);if(null!=t){if((0,c.eql)(t.stats,await(0,p.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:i,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:i,prior:t}),S().delete(i)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),r=(0,y.toNativePath_)(e);return{sha:await _(s.default.createReadStream(r)),stats:(0,u.pick)(await(0,v.stat_)(r),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],r="sha512"){const i=n.default.createHash(r);return await(0,o.pipeline)([e,...t,i]),i.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,g.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return n.default.randomBytes(h.HashBits/8).toString("base64")}},25675:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const i=r(22573),n=r(54993),s=r(7282),o=r(43334),a=r(69375),l=/^\/dev(?:\/|$)/i,u=o.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=o.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=o.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=o.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,n.toS)(e))}function m(e){return(0,i.blank)(e)?"blank":(0,a.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},33456:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const i=r(57075),n=r(51926),s=r(54993);class o extends i.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,r){const i=(this._prior+(0,s.toS)(e)).split((0,n.newlineRe)()),o=i.pop();this._prior=o??"";let a=!1;for(const e of i)a||(a=!this.push(e));a?setTimeout(r,1):r()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=o},64680:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const n=i(r(76760)),s=r(17217),o=r(73428);t.mkNoMedia_=function(e){return(0,o.writeTextfile_)(n.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},29882:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(5233),u=r(22573),c=r(98553),d=r(39426),h=r(51926),f=r(48884),m=r(50213),g=r(81168),p=r(70025),y=r(43334),v=r(78133),w=r(53265),S=r(17217),b=r(16287),P=r(66430),_=r(5545);function E(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,o.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=E,t.containsHiddenPathname=function(e){return k(e).some(E)},t.isNotHiddenPosixPath=function(e){return k(e).every((e=>!E(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return C((0,v.posix2native)(e))},t.extname=function(e){return C(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,g.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function C(e){const t=M.exec(e)?.groups,r=t?.ext2??"",i=s.default.parse(t?.path??e);return{...i,ext:(i.ext??"")+r,base:(i.base??"")+r}}function T(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,s.default.sep)}function x(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),r=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(r))return!1;const i=e.acceptSelf??!1;return t===r?i:r.startsWith((0,g.ensureSuffix)(t,s.default.sep))}catch(r){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:r}),!1}}function D(e,t,r){if(null==t||null==r)return!1;const i=e(t),n=e(r);return null!=i&&null!=n&&(y.isLinux?i===n:(0,g.equalsIgnoreCase)(i,n))}function k(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function O(e){return(0,u.notBlank)(e)&&k(e).length===(y.isWin?1:0)}function I({p:e,maxLength:t}){const r=(0,S.toNativePath_)(e);if(r.length<=t)return r;const i=k(e),n=[],s=[i.pop()];for(;i.length>0;)if(n.length=t){i.unshift(n.pop());break}}else if(s.unshift(i.pop()),L([...n,...s]).length>=t){i.push(s.shift());break}return i.length>0&&n.push("…"),L([...n,...s])}function F(e){return e.startsWith("\\\\")}function L(e){return(0,h.ensurePrefix)((0,a.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=C,t.parentBasename=T,t.grandParentBasename=function(e){return T(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=x,t.eqlBasename=function(e,t){return D(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return D(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return D(S.toNativePath_,e,t)},t.toPathnames=k,t.pathIsRoot=O,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:k(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const r=(0,S.toNativePath_)(e),i=(0,S.toNativePath_)(t);if((0,u.blank)(r)||(0,u.blank)(i))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return r===i?"":(0,g.stripPrefix)((0,v.native2posix)(i).normalize(),(0,g.ensureSuffix)((0,v.native2posix)(r),"/").normalize()).normalize()},t.ellipsizePath=I,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:r=4,arrLength:i=e.length}){const n=[];for(const i of e.slice(0,r))n.push(I({p:i,maxLength:t}));return n.join(", ")+(i>r?`, and ${i-r} more…`:"")},t.posixPathFromParent=function(e){return k(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return k(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const r=C(e);return`${r.base}${t}${r.ext}`},t.isUNC=F,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(F(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(O(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await n.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;n.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>n.default.move(e,t,{overwrite:!0})),{errorIsRetriable:p.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=L,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:L(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>x({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(31586),u=r(51926),c=r(12168),d=r(59455),h=r(54993),f=r(50213),m=r(44198),g=r(96706),p=r(45969),y=r(43334),v=r(64660),w=r(21144),S=r(16287),b=(0,s.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const r=await(0,S.statMaybe)(e,"trace");return null!=r&&r.isFile()&&(0,l.gte)(r.size,t)&&(0,v.isStatRX)(r,e)}function E(){if(y.isWin){const e=(0,a.toNotBlank)((0,g.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,a.toNotBlank)((0,g.getEnv)("SystemDrive"))??"C:",r=(0,a.toNotBlank)((0,g.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,n.default.join(e,"System32"),n.default.join(e,"System32","Wbem"),n.default.join(r,"chocolatey","bin"),n.default.join(t,"cygwin64","bin")]}return[...(0,p.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(n.default.delimiter);return(0,o.uniq)((0,o.compactBlanks)([...e,...E()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:r}){const i=(0,o.uniq)((0,o.compactBlanks)([...M(),...(0,d.toA)(r)]));for(const r of(0,o.uniq)((0,o.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(r,".exe"):r;for(const t of i){const r=n.default.join(t,e);if(await _(r))return y.isLinux?r:(0,w.actualPath)(r)}}b().warn("Failed to find tool",{tool:e,dirs:i})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},78133:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const n=i(r(76760)),s=r(22573),o=r(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(n.default.sep===n.default.posix.sep)return e;const r=(0,s.notBlank)(t)?n.default.sep+n.default.sep+t+n.default.sep:"",i=e.split(n.default.posix.sep);return(0,o.equalsIgnoreCase)(i[0],t)&&i.unshift(),r+i.join(n.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||n.default.sep===n.default.posix.sep||n.default.posix.sep===n.default.sep?e:e.split(n.default.sep).join(n.default.posix.sep)}},43899:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(48884),u=r(50213),c=r(45969),d=r(29325),h=r(43334),f=r(65843),m=r(25675),g=r(53265);function p(...e){return(0,o.lazy)((()=>n.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,o.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(n.default.join((0,g.execDir)(),"resources"),n.default.join((0,g.execDir)(),"..","Resources")),t.push(...(0,a.compactBlanks)([(0,g.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const r of t){if((0,f.hasChildrenSync)(r,e))return r;for(const t of(0,f.ancestors)(r).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const i=n.default.join(r,"node_modules","photostructure");if((0,f.hasChildrenSync)(i,e))return i}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:p("bin"),Data:p("data"),ICC:p("data","icc"),Migrations:p("data","migrations"),Public:p("public"),Tools:p("tools"),Views:p("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const i=r(44652),n=r(19851),s=r(31586),o=r(50213),a=r(57902),l=r(69428),u=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=a.LogLevels.info){try{return await(0,i.readFile)(e)}catch(r){return void u().log(t,".readFileMaybe("+e+")",r)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const i=r(44652),n=r(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:r}){let s=-1;try{const n=r??(await(0,i.stat)(e)).size-t,o=Buffer.alloc(n);return s=await(0,i.open)(e,"r"),await(0,i.read)(s,o,0,n,t)}finally{(0,n.mapGte0)(s,i.close)}}},69428:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const o=s(r(73024));t.readFileSync=function(e){try{return o.readFileSync(e)}catch{}}},32323:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const i=r(57075);class n extends i.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=n},65238:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const n=i(r(51455)),s=r(76760),o=r(19851),a=r(76790),l=r(22573),u=r(42659),c=r(41400),d=r(31586),h=r(13538),f=r(83104),m=r(54127),g=r(50213),p=r(95937),y=r(34102),v=r(28874),w=r(63870),S=r(88561),b=r(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,o.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,o.lazy)((()=>(0,g.mkLogger)("fs.Readdir")));async function _(){try{await n.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const E=(0,o.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||E.prior()?.delete(e)}async function C(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await E().getOrSetAsync(e,(()=>async function(e){const r=Date.now()+2*(0,b.statTimeoutMs)(),i=T(e),n=await(0,h.thenOrTimeout)(i,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(n===f.Timeout&&(0,p.onTimeout)({soft:!1}),n!==f.Timeout&&n.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),E.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,o.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!E().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=E().get(e)},t.childDirectories_=async function(e){return(await C(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?C(e):T(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=C,t.readdirCached=function(e){return E().get(e)},t.readdirUncached_=T},53265:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const n=r(73024),s=i(r(76760)),o=r(40958),a=r(22573),l=r(45599),u=r(50213),c=r(43334),d=r(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,o.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function g(...e){for(const t of m()){const r=s.default.resolve(t,...e);if((0,n.existsSync)(r))return r}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,a.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(a.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?g(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=g},50274:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const i=r(50989);t.SidecarExts=(0,i.strEnum)("xmp","mie","exv")},14427:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const i=r(22573),n=r(38639);t.isSimpleDirent=function(e){return null!=e&&(0,i.notBlank)(e.basename)&&(0,n.isBoolean)(e.isFile)&&(0,n.isBoolean)(e.isDirectory)}},17217:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const n=i(r(73024)),s=i(r(76760)),o=r(22573),a=r(98553),l=r(81168),u=r(43334),c=r(29882),d=r(53265),h=r(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,o.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,o.blank)(e.nativePath))throw new Error(`toNativePath(${(0,a.stringify)(e)})`);return e.nativePath}function g(e){return e instanceof n.default.Dirent?e.name:f(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=g,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(g(e)).name},t.dirname=function(e){return f(e)?e.dir:s.default.dirname(m(e))};const p=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(p)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),r=t.indexOf(s.default.sep);return r>0?t.slice(1,r):void 0}},t.findFileIndex=function(e,t){for(let r=0;r(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,a.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(n.default.stat(e),(0,p.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,a.blank)(e)?void 0:v(e).catch((r=>{y().log(t,"stat() failed",{error:r,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const r=S(e),i=S(t);if(r!==i)return"inconsistent file type: "+r+" ≠ "+i;for(const r of["size","mtime"]){const i=e[r],n=t[r],s=(0,u.diff)(b(i),b(n));if(null==s||s>1)return"unmatched "+r+": "+i+" ≠ "+n}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const r=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=r&&!(t?.emptyIsNew??1))&&(0,g.isEmptyStats)(r)},t.isNonEmptyFile=async function(e,t=0){const r=await w(e);return null!=r&&r.isFile()&&r.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.access)({stat:r,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.isStatRWX)(r,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,o.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const n=i(r(73024)),s=r(22573);function o(e){try{return(0,s.blank)(e)?void 0:n.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function a(e){return null==e||e.isFile()&&0===e.size}t.statSync=o,t.isEmptyStats=a,t.isFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const r=o(e);return t.emptyIsNew?null==r:a(r)},t.isNonEmptyFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isDirectorySync=function(e){return!0===o(e)?.isDirectory()}},41080:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const i=r(28874);t.statTimeoutMs=function(){return i.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const i=r(22573),n=r(56409);t.onDataChunked=function(e,t,r){const i=new s(t,r,!0);return i.read(e),i.done};class s{constructor(e,t,r=!0){this.sep=e,this.onData=t,this.filterBlanks=r,this.incompleteChunk="",this.done=new n.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,i.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,i.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const n=i(r(57075)),s=r(41400),o=r(55835),a=r(68708),l=r(42279),u=r(99331),c=r(70025);class d extends n.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((r,i)=>{!1===e.write(t,(e=>{e&&i(e)}))?e.once("drain",r):r()}))},t.endStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,a.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:r,ea:i}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,o.map)(i,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(r,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends n.default.Transform{constructor(e){super({transform:(e,t,r)=>{this.onProgress(this.bytes+=e.length),r(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const n=i(r(73024)),s=r(76760),o=r(22573),a=r(76596),l=r(64660),u=r(78133),c=r(68284);function d(e){if((0,o.blank)(e))return!1;try{return n.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,a.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,o.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,o.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,o.blank)(e)&&d((0,u.posix2native)(e))}},27794:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const n=i(r(44652)),s=r(19851),o=r(22573),a=r(42659),l=r(31586),u=r(68708),c=r(13538),d=r(29882),h=r(17217),f=r(16287),m=r(41080);function g(e){return null==e?void 0:(0,a.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const r=t.ensureFile??!0;if(null==t.file||(0,o.blank)(t.file))throw new Error("can't touch blank path");const i=(0,h.toNativePath_)(t.file);r&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const a=(0,s.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(g(t.mtimeMs)??(await a())?.mtimeMs??Date.now()),p=Math.round(g(t.atimeMs)??(await a())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(n.default.utimes(i,new Date(p),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!r||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(n.default.ensureFile(i),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},5545:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const n=i(r(76760)),s=r(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const r=t.driveRe.exec(e)?.groups;return null==r?e:r.drive.toUpperCase()+(0,s.toS)(r.path??n.default.sep)}},58722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const i=r(57075),n=r(22911);class s extends i.Writable{constructor(e){super(e),this.deferred=new n.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,r){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),r()}}t.WritableToBuffer=s},73428:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(51926),a=r(54993),l=r(34102),u=r(84542),c=r(29882);async function d(e,t){const r=s.default.dirname(e);await(0,c.mkdirp_)(r),await n.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",r)}function h(e,t){const r=s.default.dirname(e);(0,c.mkdirpSync_)(r),n.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",r)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const r=(0,u.crlf)(...(0,o.wrap)(t));await d(e,r)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))}},13047:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const n=i(r(73024)),s=r(76760),o=r(46466),a=r(38522),l=r(19851),u=r(40958),c=r(98553),d=r(80875),h=r(50213),f=r(57159),m=r(29882),g=r(57902),p=r(32323),y=r(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,r){const i=[],s=[n.default.createReadStream(e,{autoClose:!0,...r}).on("error",(e=>i.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,a.createGunzip)().on("error",(e=>i.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,a.createBrotliDecompress)().on("error",(e=>i.push(e)))),s.push(t),await(0,o.pipeline)(s),(0,u.isNotEmpty)(i))throw new f.WrappedError("zPipe("+e+") failed",{causes:i,path:e})}async function b(e,t){const r=new y.WritableToBuffer;return await S(e,r,t),await r.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function _(e,t){const r=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,o.pipeline)(new p.ReadableBuffer(r),(0,a.createGzip)(),n.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=g.LogLevels.warn){try{return await P(e)}catch(r){return void v().log(t,"readJsonGz("+e+"): failed",r)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,r=g.LogLevels.warn){try{await _(e,t)}catch(t){v().log(r,"outputJsonGz("+e+"): failed",t)}}},33866:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const i=r(50989);t.HealthCheckIds=(0,i.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},52086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const i=r(50989);t.CropStrategies=(0,i.strEnum)("center","entropy","attention")},48584:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const i=r(50989);t.SharpFailOns=(0,i.strEnum)("none","truncated","error","warning")},49794:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const i=r(57975),n=r(19851),s=r(40958),o=r(22573),a=r(54993),l=r(37975),u=r(7282),c=r(23560),d=r(28874),h=r(66184),f=r(93475),m=(0,n.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function g(e){if((0,o.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=g,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=g(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,i.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,s.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:g(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,r,i){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:r,meta:i})}}},32105:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const i=r(19851),n=r(23560),s=r(66184),o=r(72210);class a{log(e,t,r,i){this.enabled(e,t)&&(0,o.pushLogEntries)({ts:Date.now(),l:e,from:(0,n.processName)(),ctx:t,msg:r,meta:i})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=a,a.instance=(0,i.lazy)((()=>new a))},14593:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const i=r(57975),n=r(22573),s=r(26905),o=r(55835),a=r(68708),l=r(13538),u=r(50213),c=r(97352),d=r(45255),h=r(76740),f=r(57159),m=r(57902),g=/logger|lazy/i;class p{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,n.toNotBlank)(e)??(0,s.shortStack)().find((e=>!g.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[i.inspect.custom](){return this.toLogJSON()}addContext(e){return new p(this.context+e,this.loggers)}addParameterContext(e){return new p(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const r=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,a.omit)(t,"error")});throw Error.captureStackTrace?.(r),this.log(!0===r.ignorable?"warn":"error",".throw() "+r.message,{stack:r.stack,...t}),r}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let r;try{r=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const i=e.result(),n=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:i,meta:{...e.meta,elapsedMs:n}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,o.map)(r,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,a.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const r of this.loggers())if(r.enabled(e,t??this.context))return!0;return!1}log(e,t,r){for(const i of this.loggers())i.log(e,this.context,t,r)}elapsed(e,t,r){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...r})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=p},89179:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const i=r(50213),n=r(43705);t.currentFileLogger=function(){return(0,i.rootLoggers)().find((e=>e instanceof n.LogWriter))}},28981:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const i=r(19851),n=r(51879);t.DefaultLogFormatter=(0,i.lazy)((()=>new n.PlaintextLogFormatter))},31256:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(41400),a=r(98553),l=r(55835),u=r(31586),c=r(68708),d=r(72993),h=r(23560),f=r(81168),m=r(98314),g=r(57902),p=r(93475),y=(0,i.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,r]=e.split("-",2);return(0,s.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(r)}}}(0,o.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,g.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,n.uniq)((0,n.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,a.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,p.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,a.stringify)(t)])))})}format(e,t,r,i){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:r,meta:i})}}},51576:function(e,t,r){var i,n=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const s=r(77030),o=r(19851),a=r(22573),l=r(42659),u=r(41400),c=r(98553),d=r(56409),h=r(31586),f=r(25764),m=r(38836),g=r(50213),p=r(409),y=r(28874),v=r(31256),w=r(28538),S=(0,o.lazy)((()=>(0,g.mkConsoleLogger)("log.LogBroadcaster"))),b=String.fromCharCode(0);t.logBroadcaster=(0,o.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),r=(0,h.toInt)(t);return(0,a.blank)(e)||!(0,h.gt0)(r)?void 0:{host:e,port:r}}();return null==e?void(y.Settings.logServer.hasValue()&&S().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),i.set(this,(0,p.rateLimited)({f:async()=>{try{const e=this.socket=(0,s.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{S().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){S().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),n(this,i,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,r,s){if(this.enabled(e,t))try{const o=this.socket;null==o?n(this,i,"f").call(this):o.write(this.logFormatter.format(e,t,r,s)+b)}catch(i){S().warn("Failed to write log entry to socket",{level:e,context:t,msg:r,meta:s,error:i})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}i=new WeakMap},20839:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const i=r(76760),n=r(42659),s=r(28874);t.datedLogDir=function(e,t){return(0,i.join)(e??s.Settings.logDir.valueOrDefault,(0,n.fmtIsoDate)(t??new Date))}},4904:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const i=r(76790),n=r(31586),s=r(51926),o=r(57902);t.isLogEntry=function(e){return null!=e&&(0,n.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&o.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,i.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const i=r(19851),n=r(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,n.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,n.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,i.lazy)((()=>new s(n.LogLevels.warn))),t.defaultLogLevel=(0,i.lazy)((()=>n.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,n.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,r){return(0,t.logFilter)().enabled(e)?r():void 0},t.isLogged=function(e,r){return(0,t.logFilter)().enabled(e,r)}},28538:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=r(19851),u=r(40958),c=r(22573),d=r(54993),h=r(28874),f=r(66184),m=r(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){i.add(this),this.setting=e,this.silent=!1,n.set(this,[]),s.set(this,(0,l.lazy)((()=>{a(this,n,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const r of t){const t=f.LogLevelRe.exec(r.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+r+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),r=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=r:a(this,n,"f").push({prefix:e,levelIndex:r})}}}))),e.watch((()=>a(this,s,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const r=(0,m.levelIndex)(e);if(null!=t){const e=a(this,i,"m",o).call(this,t);if(null!=e)return r<=e.levelIndex}return r<=this.defaultLevelIndex}highlight(e){const t=a(this,i,"m",o).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},n=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(e){if(null==e||0===a(this,n,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return a(this,n,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const i=r(42659),n=r(31586),s=r(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const o=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??o},t.levelGte=function(e,r){return(0,n.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(r))};const a=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return a.get(e)},t.msTolevel=function(e,t=7*i.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const i=r(40958),n=r(68708),s=r(20214),o=r(51926),a=r(23541),l=r(48884),u=r(88158),c=r(98314),d=r(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(r,h=4){if(null==r)return null;if(h<0)return"…";if((0,o.isString)(r)||Buffer.isBuffer(r))return(0,o.ellipsize)(r.toString(),256,32);if((0,a.isError)(r))return(0,c.errorToVerbose)(r);if(Array.isArray(r)){const t=d.Settings.logContextLimit.valueOrDefault,i=Math.floor(t/2);return r.length<=t?r:[...r.slice(0,i).map((t=>e(t,h-1))),`… (${r.length} total entries)`,...r.slice(-i).map((t=>e(t,h-1)))]}if("object"==typeof r||"function"==typeof r){for(const t of["toLogJSON","toJSON"])if("function"==typeof r[t])return e(r[t](),h-1);if((0,s.isPromiseLike)(r))return t.PromisePlaceholder;if("…"in r)return r;const a=(0,u.mapNullEntries)(r,((t,r)=>e(r,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,n.keys)(r),(0,n.keys)(a));return(0,i.isNotEmpty)(c)&&(a["…"]="omitted: "+(0,o.ellipsize)(c.join(", "),128,32)),a}return r}},24068:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const i=r(73024),n=r(76760),s=r(1708),o=r(87997),a=r(19851),l=r(22573),u=r(42659),c=r(49769),d=r(55835),h=r(34666),f=r(20214),m=r(7282),g=r(23560),p=r(54826),y=r(82328),v=r(22277),w=r(25764),S=r(38836),b=r(99331),P=r(42638),_=r(76596),E=r(98314),M=r(89968),C=r(29882),T=r(28874),x=r(28981),D=r(20839),k=r(21727),O=r(66184),I=r(57902),F=r(72210),L=r(98192);function A(e){const t=(0,x.DefaultLogFormatter)();for(const r of e)(0,p.consoleLog)(t.formatLogEntry(r))}t.DefaultLogEntryWriter=A;class N extends S.EndableWrapper{constructor(e=void 0,t=A){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,a.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,T.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,p.consoleLog)("tailing "+e+"..."),await(0,C.mkdirp_)(e),this.root=await M.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=n.sep+(0,g.serviceName)()+"-"+s.pid+"-",s.stdout.writableFinished||((0,F.setLogTailEnabled)(!0),this.flushTimeout=(0,o.setInterval)((()=>this.flush()),D.DefaultLogFlushMs/2),this.scanTimeout=(0,o.setInterval)((()=>this.scan()),u.minuteMs),s.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,F.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,b.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,O.ifLog)(I.LogLevels.debug,(()=>(0,p.consoleLog)("LogTail(): watching "+e)));try{return(0,i.watch)(e,((t,r)=>{(0,l.notBlank)(r)&&this.watchListener(t,(0,n.join)(e,r))}))}catch(t){return void(0,O.ifLog)(I.LogLevels.warn,(()=>(0,p.consoleError)("LogTail(): failed to read "+e+": "+(0,E.errorToS)(t))))}}))}async scan(e=!1){if((0,b.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,_.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,b.ending)()||this.ended)return;const t=(0,k.datedLogDir)(this.root.nativePath);try{await(0,C.mkdirp_)(t),this.watchDir(t)}catch(e){(0,O.ifLog)(I.LogLevels.warn,(()=>(0,p.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,E.errorToS)(e))))}(0,b.ending)()||this.ended||e&&(0,p.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,F.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,o.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,o.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,F.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await M.DirectoryEntry.for(t);if(null==e)return;const r=e.size();if(null==r||r<=0)return;const i=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(i,r))return;await(0,f.thenMap)((0,L.readLogEntries)(e,{start:i,end:r}),(e=>(0,F.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,r)}catch(e){(0,O.ifLog)(I.LogLevels.warn,(()=>(0,p.consoleError)("Failed to read "+t+": "+(0,E.errorToS)(e))))}}))}}t.LogTail=N,N.instance=(0,a.lazy)((()=>(0,y.stdoutEnded)()?void 0:new N))},72210:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const i=r(92322),n=r(82328),s=r(28981),o=r(20839),a=r(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new i.SortedSet(a.logEntrySorter),t.pushLogEntries=function(...e){for(const r of e)l?t.logEntries.add(r):(0,n.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(r))},t.popExpiredLogEntries=function(e=2*o.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(r(73024)),f=r(76760),m=r(19851),g=r(42659),p=r(41400),y=r(98553),v=r(31586),w=r(409),S=r(23560),b=r(81168),P=r(78406),_=r(25764),E=r(20197),M=r(14977),C=r(36868),T=r(28874),x=r(32105),D=r(20839),k=r(21727),O=r(66184),I=r(93475),F=r(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,r,i){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:r,meta:i})}enabled(){return!0}end(){}async flush(){}};class L extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*D.DefaultLogFlushMs),rank:_.EndableRanks.logger,unref:!0,onEnd:()=>c(this,n,"f").call(this)}),i.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,g.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*g.secondMs,n.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,i,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:x.ConsoleLogger.instance(),flushEveryMs:D.DefaultLogFlushMs,processName:S.processName,logFilter:O.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,i,"m",s).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,r,i){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,r,i);else{const n={ts:Date.now(),l:e,ctx:t,msg:r};null!=i&&(n.meta=(0,I.prepMeta)(i)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(n)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,F.recentLogEntries)()),(0,F.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=L,n=new WeakMap,i=new WeakSet,s=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,i,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const r=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),n=e.splice(0,r);this._linesSinceRotate+=n.length,t.write(n.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},o=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},a=function(e){return t=>(c(this,i,"m",o).call(this,e,t),c(this,i,"m",u).call(this))},l=async function(){await c(this,i,"m",u).call(this);const e=(0,b.stripAnsiEsc)(this.logOpts.processName()),t=await(0,E.ensureNewNativePath_)({nativePath:(0,f.join)((0,k.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),r=h.default.createWriteStream(t).on("error",c(this,i,"m",a).call(this,"file write stream"));this._logfile={stream:r,nativePath:t},this._nextForcedRotateTs=(0,g.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,C.endStream)(e.stream),T.Settings.logCompression.valueOrDefault&&(await(0,p.delay)(this.logOpts.flushEveryMs),await(0,M.gzip_)(e.nativePath))}catch(e){c(this,i,"m",o).call(this,"_closeCurrent()",e)}}},51879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(68708),a=r(54993),l=r(23560),u=r(81168),c=r(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,o.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,n.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,i.inspect)(e,this.inspectOptions)))]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,r,i){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:r,meta:i})}}},98192:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const i=r(22573),n=r(84542),s=r(4001),o=r(13047),a=r(4904);function l(e){if(!(0,i.blank)(e))try{const t=JSON.parse(e);return(0,a.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const r=(0,s.stripCopySuffixFromName)(e.name),i=[],a=await(0,o.zcat)(e.nativePath,t);if(null!=a)for(const e of(0,n.splitLines)(a)){const t=l(e);null!=t&&i.push({...t,from:r})}return i},t.chunkToLogEntry=l},22662:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const i=r(19851),n=r(76790),s=r(68708),o=r(89788),a=r(57902);t.SentLogLevels=(0,i.lazy)((()=>a.LogLevels.values.filter((e=>e!==a.LogLevels.trace))));const l=(0,i.lazy)((()=>(0,s.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new o.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,s.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,s.values)(l()))e.push(...t.toA());return(0,n.sortBy)(e,(e=>e.ts))}},17181:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const i=r(76760),n=r(41400),s=r(55835),o=r(37975),a=r(50213),l=r(27395),u=r(46296),c=r(96706),d=r(73428),h=r(28874),f=r(49794),m=r(32105),g=r(89179),p=r(28981),y=r(51576),v=r(66184),w=r(28538),S=r(24068),b=r(43705),P=r(51879);function _(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),E();const e=(0,u.logDir)();let t=(0,g.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,i.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new b.LogWriter(e));const r=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&r.push(m.ConsoleLogger.instance()),(0,s.map)((0,y.logBroadcaster)(),(e=>r.push(e))),a.rootLoggers.set(r),h.Settings.tailLogs.valueOrDefault&&S.LogTail.instance()}function E(){const e=h.Settings.logColor.valueOrDefault;(0,o.setColorEnabled)(e),p.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=_,t.setupLogFormatter=E,(0,n.later)((()=>{h.Settings.logStdout.watchLater(_),h.Settings.logDir.watchLater(_),h.Settings.tailLogs.watchLater(_),h.Settings.logColor.watchLater(E),h.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},36389:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=i(r(1708)),s=r(24068),o=r(40958),a=r(5670),l=r(69554),u=r(38790),c=r(46296);!async function(){const e=(0,c.logDir)(),t=await new l.CLI(a.ServiceNames.logtail,"[LOG_DIR]","Normally logtail watches all files in the default logging directory, "+e+". Specify LOG_DIR or set the PS_LOG_DIR environment variable to override this directory.").add(u.ColorArgs).parse();n.default.on("SIGINT",(()=>n.default.exit(0))),n.default.on("SIGTERM",(()=>n.default.exit(0)));const r=(0,o.compactBlanks)(t.args);new s.LogTail(r[0]??e)}()},82647:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const o=r(57975),a=r(40958),l=r(96249),u=r(55835),c=r(31586),d=r(68708),h=r(59455),f=r(48884),m=r(89788),g=r(22454),p=r(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const r=t.clone();return r.pushAll(e.samples),r}if(t.n<=t.maxSamples){const r=e.clone();return r.pushAll(t.samples),r}{const r=new y(Math.max(e.maxSamples,t.maxSamples));r._n=e.n+t.n,r._min=Math.min(e._min,t._min),r._max=Math.max(e._max,t._max),r._m=e._m*e.n/r.n+t._m*t.n/r.n,r._s=e._s*e.n/r.n+t._s*t.n/r.n;const i=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return r._samples.push(...i),r._weightedTotalAvg=(0,p.weightedAvg)([r._m,...i]),r}}constructor(e=20){i.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(i=new WeakSet,o.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,p.min)([this._min,e.min]),this._max=(0,p.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),r={};return r.k=t(this.n),this.empty||(r.mean=t(this.avg),r.sum=t(this.sum),r.sd=t(this.stdDev),r.max=t(this.max),r.min=t(this.min)),r}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,i,"m",n).call(this,-1)}get p29(){return s(this,i,"m",n).call(this,-.5)}get p38(){return s(this,i,"m",n).call(this,-.25)}get p69(){return s(this,i,"m",n).call(this,.5)}get p84(){return s(this,i,"m",n).call(this,1)}get p98(){return s(this,i,"m",n).call(this,2)}get p99(){return s(this,i,"m",n).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new g.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,a.mapNotEmpty)(this._samples,p.variance)}get sampleStdDev(){return(0,a.mapNotEmpty)(this._samples,p.stdDev)}get sampleAvg(){return(0,a.mapNotEmpty)(this._samples,p.avg)}get sampleSlope(){return(0,p.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,p.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,n=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const i=r(40958),n=r(55835),s=r(31586),o=r(30976),a=r(48884),l=r(70417);function u(e,t){const r=Math.pow(2,t),i=[];for(;e>0;)i.unshift(e%r),e=Math.floor(e/r);return i}t.concatBits=function(e,t){const r=Math.pow(2,t);return e.reduce(((e,t)=>e*r+(0,s.clamp)(0,r,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,r){return(0,n.map2)(e,t,((e,t)=>(0,i.sum)((0,a.zip)(u(e,r),u(t,r)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,o.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max)),n=this.clampValue(e);let s=0;for(let e=0;eo?(s+=1,r[t]=o):i[t]=o}return s}unzip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max));for(let n=0;n(r[e]+i[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,r){return!0!==r&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let r=0;rs?(t+=1,n.min=s):n.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const r=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,i.sum)(e,((r,i)=>t(r,i)?Math.pow(2,e.length-i-1):0))}},55222:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const i=r(77598),n=r(22573),s=r(55835),o=r(32639),a=r(88158),l=r(81168),u=BigInt(0);function c(e,t,r=0){if(!isFinite(t)||e<=1)return[];const i=[];if(0===t)i.unshift(0);else for(;t>0;)i.unshift(t%e),t=Math.floor(t/e);for(;i.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const r=e<0;return r&&(e=Math.abs(e),t--),(r?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],r=BigInt(this.base);let i=e;for(;i>u;)t.push(Number(i%r)),i/=r;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let r of e)for(t.forEach(((e,i)=>{r+=e<<8,t[i]=r%this.base,r=Math.floor(r/this.base)}));r>0;)t.push(r%this.base),r=Math.floor(r/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,n.blank)(e))return;const t="-"===(e=(0,o.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const r=BigInt(this.base);let i=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;i=i*r+BigInt(e)}return t?BigInt(-1)*i:i}randomChars(e){return this.encodeBuffer((0,i.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,r="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(r)}tokenEql(e,t,r){const i=this.normalizeToken(e),n=this.normalizeToken(t);return i.length>=r&&i===n}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const i=r(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,i.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},70417:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const a=r(40958),l=r(55835),u=r(31586),c=r(59455),d=r(22454),h=r(77377),f=r(82647);function m(e){let t;for(const r of e)null!=r&&(null==t||rt)&&(t=r);return t}function y(e,t){const r=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&r.incr(t);return r.topKeys(t)}function v(e,t){let r=0,i=0;for(const n of e){if(null!=n){const e=t(n,r);(0,u.isNumber)(e)&&(i+=e)}r++}return i}t.min=m,t.max=p,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,r)=>e-t[r]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const r of e)(0,u.isNumber)(r)&&(t+=r);return t},t.sumf=v;class w{constructor(){i.set(this,0),n.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(o(this,n,null==s(this,n,"f")?e:s(this,n,"f")*s(this,i,"f")/(s(this,i,"f")+1)+e/(s(this,i,"f")+1),"f"),o(this,i,(t=s(this,i,"f"),++t),"f"))}get mean(){return s(this,n,"f")}}function S(e){const t=new w;for(const r of e)t.push(r);return t.mean}function b(e){const t=S(e);if(null==t)return;let r=0,i=0;for(const n of e)(0,u.isNumber)(n)&&(i++,r+=(n-t)*(n-t));return r/i}function P(e){let t=0;for(const r of e)t+=r*r;return Math.sqrt(t)}function _(e,t){let r=0;for(let i=0;i(1-t)*e+t*(r+o*(e-n)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),r=S(t);if(null!=r){const e=(t.length-1)/2,i=v(t,((t,i)=>(t-r)*(i-e))),n=v(t,(e=>(e-r)**2));return 0===n?0:i/n}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let r;t=(0,u.clamp)(0,1,t);for(const i of e)r=null==r?i:r*t+i*(1-t);return r},t.centroid=function(e){const t=e[0].length,r=[];for(let i=0;ie[i]))));return r},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,a.isEmpty)(e)&&(0,a.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},45969:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const i=r(73024),n=r(38639),s=r(19851),o=r(59958),a=r(43334);t.isDocker=(0,s.lazy)((()=>a.isLinux&&((0,n.toBoolean)(process.env[o.PS_IS_DOCKER])??(0,i.existsSync)("/.running-in-container"))))},29325:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const i=r(76760),n=r(19851),s=r(54993);t.isPacked=(0,n.lazy)((()=>!(0,s.toS)(__filename).includes((0,i.join)("core","platform","IsPacked"))))},43334:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(22573),a=r(38639),l=r(59958),u=n.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,a.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,a.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,o.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===n.default.arch(),t.isArm=null!=/^arm\b/i.exec(n.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,o.notBlank)(s.default.env.APPIMAGE)||(0,o.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,o.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,a.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const n=i(r(73024)),s=r(19851),o=r(43334);function a(e="/proc/cpuinfo"){if(o.isWin||o.isMac)return!1;try{return null!=n.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=a,t.isRaspberryPi=(0,s.lazy)((()=>o.isLinux_arm&&a())),t.procDeviceModel=(0,s.lazy)((()=>{try{return o.isLinux?n.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},45643:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const i=r(58587),n=r(59455),s=r(31562);t.existingPids=function(e){return(0,n.toA)(e).filter(i.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,i.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=r(58587),d=u(r(31421)),h=u(r(1708)),f=r(40958),m=r(22573),g=r(42659),p=r(55835),y=r(31586),v=r(97790),w=r(59455),S=r(54993),b=r(54557),P=r(19851),_=r(50213),E=r(88158),M=r(409),C=r(78406),T=r(25764),x=r(99331),D=r(56519),k=r(46292),O=r(8769),I=r(83278),F=r(32144),L=r(29882),A=r(43334),N=r(24399),R=r(58261),j=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),B=10*g.secondMs;function V(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const r=(0,p.map)(t.start,(e=>e.getTime())),i=e.startTime;return(0,y.gt0)(r)&&(0,y.gt0)(i)&&Math.abs(r-i){const e=Date.now()-2*g.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,F.isJsonExt)(t)&&(0,L.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))j().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:g.minuteMs,f:async(e={})=>{j().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,r=e.force??A.isWin,i=await this.pidfiles(),n=await this.pids(i??[]);if((0,f.isEmpty)(n))return j().info("killOldProcs(): no pidfiles"),[];const s=[],o=[],a=await(0,R.pidInfos)(n);if(null!=a){for(const n of i){const i=await n.readJson();if(null==i){j().warn("killOldProcs(): failed to read pidfile "+n.base),await n.unlink("debug");continue}const l=i.pid;if(!(0,y.gt0)(l)){j().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+n.base,{json:i,pid:l}),await n.unlink("debug");continue}const u=a.find((e=>e.pid===l));if(null==u||!V(i,u)){j().debug("killOldProcs(): pid no longer present: unlinking "+n.base,{json:i,pidEntry:u}),await n.unlink("debug"),s.push(i);continue}const c=(0,y.gt0)(i.timeoutMs)?i.startTime+i.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(i.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(j().info("killOldProcs(): killing",{reason:d,json:i}),o.push(W(l,r,!1)),s.push({...i,...u}))}return o.length>0&&await Promise.allSettled(o),s}(0,O.onError)("Pids.killOldProcs(): failed to get process information")}}),o.set(this,void 0)}async addPid_(e,t,r=!1){if(null==e)throw new Error("undefined info");const o=e.pid;if(!(0,y.gt0)(o))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(o)?(r&&a(this,n,"f").delete(l),a(this,n,"f").getOrSet(l,(async()=>{const r=a(this,i,"m",s).call(this,e.pid),n=(0,v.opt)((0,E.Try)((()=>(0,L.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),o=t.getTime(),l={...e,cmd:n,startTime:o};return await r.writeJson_(l),j().debug("addPid() wrote "+r,l),r}))):(a(this,n,"f").delete(l),void j().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=a(this,i,"m",s).call(this,e);return(0,D.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,g.ago)(g.minuteMs),!0).catch((t=>{j().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==a(this,o,"f")||a(this,o,"f").ended)&&l(this,o,new C.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*g.minuteMs,rank:T.EndableRanks.first}),"f"),a(this,o,"f")}cancelInterval(){a(this,o,"f")?.end(),l(this,o,void 0,"f")}}t.Pids=q,n=new WeakMap,o=new WeakMap,i=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},q.instance=(0,P.lazy)((()=>(0,p.map)((0,k.configDir)(),(e=>new q(I.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return q.instance()?.addPid_(e,t)}},58261:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const n=r(31421),s=r(48161),o=i(r(1708)),a=r(40958),l=r(22573),u=r(42659),c=r(31586),d=r(68708),h=r(59455),f=r(54993),m=r(48884),g=r(53507),p=r(19851),y=r(50213),v=r(84968),w=r(48963),S=r(56519),b=r(84777),P=r(8103),_=r(45879),E=r(43334),M=r(24399),C=r(45643),T=(0,p.lazy)((()=>(0,y.mkLogger)("proc.ps")));function x(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function D(e){if(E.isLinux)return async function(e){const t=[];for(const r of e)t.push(z(await(0,_.readFileMaybe)("/proc/"+r+"/stat")));return T().tap({msg:"pidInfoProc",result:(0,a.compact)(t)})}(e);const t=(0,C.existingPids)(e),r=(await(0,m.collectBatchedAsync)(t,20,E.isWin?F:R)).filter((e=>x(e)&&t.includes(e.pid)));return T().tap({msg:"pidInfos()",result:r,meta:{pids:e}})}t.isProcEntry=x,t.pidInfo=async function(e){return(0,S.thenMap)(D([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,a.isEmpty)(e)?[]:(0,S.thenMap)((0,C.existingPids)(e),(t=>{const r=[o.default.pid,...t];return e.filter((e=>!r.includes(e)))}))},t.pidInfos=D;const k="Get-Process",O="| Select-Object -Property Id,ProcessName,StartTime";function I(e){return(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).join(",")}async function F(e){if(M.PowerShell.instance().ended)return N(e);const t=[k,"-Id",I(e),"-ErrorAction SilentlyContinue",O].join(" ");return(0,S.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const L={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},A=["CommandLine","CreationDate","ProcessId"];async function N(e){const t=["process"];if((0,a.isNotEmpty)(e)){const r=(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",r)}t.push("get",A.join(","));const r=await(0,b.stdoutResult_)((0,P.wmic)(),t,L),i=(0,d.onlyReqValued)((0,g.parseFixed)(A,r.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return i.find((e=>e.pid===o.default.pid))||i.push({pid:o.default.pid,start:new Date(v.StartTs),cmd:"node "+o.default.title}),i}async function R(e){return t=(await(0,b.stdoutResult_)("ps",["-p",I(e),"-wwwo","pid,lstart,command"],{...L,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,g.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=N;const j=(0,p.lazy)((()=>{try{if(E.isLinux)return(0,c.toGt0)((0,n.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){T().warn("clk_tck failed",{error:e})}return 100})),B=(0,p.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),V=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function z(e){const t=V.exec((0,f.toS)(e))?.groups,r=(0,c.toInt)(t?.pid),i=t?.comm,n=(0,c.toInt)(t?.starttime);return(0,c.gt0)(r)&&!(0,l.blank)(i)&&(0,c.gt0)(n)?{pid:r,cmd:i,start:new Date(B()+n/j()*u.secondMs),state:t?.state}:void 0}},24399:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const i=r(58587),n=r(19851),s=r(22573),o=r(42659),a=r(41400),l=r(55835),u=r(13538),c=r(36557),d=r(14121),h=r(50213),f=r(7282),m=r(45255),g=r(81168),p=r(25764),y=r(38836),v=r(99331),w=r(56519),S=r(31562),b=r(84777),P=r(34102),_=r(43334),E=r(28874),M=r(63870),C="{ready}",T=" | ConvertTo-Json -Compress";function x(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=x,(0,a.later)((()=>(0,P.ee)().on("clearCache",(()=>D.instance.prior()?.clearMockResults()))));class D extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),p.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new i.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",E.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${C}"}`,...(0,s.mapNotBlankOr)(E.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:C,fail:"Error",exitCommand:"exit",maxProcs:E.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:o.minuteMs,cleanupChildProcs:!1}),p.EndableRanks.postdb),E.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(E.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,g.ensureSuffix)(e,T),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const r=this.mockResults.get(e);return t(r.stdout,r.stderr,r.passed)}try{const r=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new i.Task(e,((r,i,n)=>t((0,l.map)(r,(t=>(0,g.stripPrefix)(t,e))),i,n)))));return this.logger.tap({msg:"execute()",result:r.result,meta:{elapsedMs:r.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,g.ensureSuffix)(e,T),((e,t,r)=>({stdout:e,stderr:t,passed:r})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const r=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,g.ellipsize)(t.stdout),after:(0,g.ellipsize)(r)}),JSON.parse(r)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+x(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=D,D.instance=(0,n.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new D})),t.checkPowerShell_=async function(){const e=D.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const i=r(50989);t.AggregateTypes=(0,i.strEnum)("union","intersection")},71988:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const i=r(50989);t.AssetFileSortCriteria=(0,i.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const i=r(22573),n=r(38639),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toBoolean})}}t.BooleanSetting=o},90536:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=a},75164:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(i.notBlank).flatMap(n.toInt).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,n.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=a},10546:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const i=r(50989);t.ColorDistanceFunctions=(0,i.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const i=r(36507),n=r(22573),s=r(45599),o=r(50213),a=r(81168),l=r(98314),u=r(8769),c=r(80372),d=(0,s.defer)((()=>(0,o.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,a.trimQuotes)(e);return void((0,n.blank)(t)||(0,i.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,r){try{return(0,n.blank)(t)?void 0:(0,i.Cron)(t,{name:e,unref:!0,protect:!0,catch:r=>(0,u.onError)(r,{name:e,crontab:t}),...r})}catch(r){return void d().warn("invalid cron",{name:e,crontab:t,error:r})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const i=r(70488),n=r(91655),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration})}get valueOrDefault(){return(0,i.decodeDuration)(super.valueOrDefault)}get value(){return(0,i.decodeDuration)(super.value)}set value(e){super.userValue=(0,i.decodeDuration)(e)}get humanValue(){return(0,n.fmtFullDuration)(this.value)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,i.decodeDuration)(e)}}t.DurationSetting=o;class a extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,i.decodeDuration)(this.defaultValue)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=a},9945:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.FloatSetting=o},74589:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt})}}t.IntegerSetting=o},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const i=r(22573),n=r(53265),s=r(87652);class o extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,i.blank)(e)?void 0:(0,n.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=o},23561:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.OptionalFloatSetting=o},69005:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=o},87652:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=n},28283:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const i=r(51926),n=r(83556);t.nameFromEnv=function(e){return(0,n.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,i.ensurePrefix)((0,n.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const o=r(19851),a=r(40958),l=r(79666),u=r(50357),c=r(57924),d=r(98553),h=r(55835),f=r(68708),m=r(39926),g=r(46891),p=r(42279),y=r(59455),v=r(40583),w=r(81168),S=r(44198),b=r(96706),P=r(34102),_=r(28283),E=r(81075),M=r(98778),C=r(10357);t.settingsToObj=function(e){const t={};for(const r of e)r.hasValue()&&(t[r.name]=r.value);return t},t.Setting=class{constructor(e){i.add(this),this.opts=e,this._envValue=(0,o.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,i,"m",n).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const r=this.opts.whyInvalid?.(e);return null!=r?s(this,i,"m",n).call(this,e??t)+": "+r:null==this.fromEnv(e)?s(this,i,"m",n).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const r=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=r)return r}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,a.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const r=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(r)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,a.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,a.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return E.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,p.tot)(this.optsOverrides.defaultValue)??(0,p.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,p.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const r=e??(0,S.env)(),i=t??this.value;return null!=i&&(r[this.key]=this.toEnv(i)),null==e&&b.caseInsensitiveEnv.unset(),r}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const r=e??(0,S.env)(),i=this.toEnvValue(t);return null!=i&&(r[this.key]=i,null==e&&b.caseInsensitiveEnv.unset()),r}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],C.WrapComments);function r(e,r){(0,a.isEmpty)(r)||t.push(...(0,w.wrap)(["",(1===r.length?e:(0,g.pluralize)(e))+": "+(0,c.orList)(r.map((e=>(0,d.stringify)(e))))],C.WrapComments))}r("alias",this.opts.aliases),r("environment alias",this.altKeys);for(const[e,r]of(0,f.entries)(this.addToJSON())){const i=Array.isArray(r)?(0,c.orList)(r.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(r);t.push(...(0,w.wrap)(["",e+": "+i],C.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Example value:"],key:this.name,value:(0,p.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Default value:"],key:this.name,value:(0,p.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,p.tot)(this.fileValue)}),e}},i=new WeakSet,n=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const i=r(50989);t.SettingCategories=(0,i.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const i=r(58587),n=r(76760),s=r(19851),o=r(40958),a=r(76790),l=r(22573),u=r(42659),c=r(73722),d=r(68708),h=r(50989),f=r(12168),m=r(54993),g=r(37975),p=r(9092),y=r(40583),v=r(79840),w=r(7282),S=r(12801),b=r(4328),P=r(70488),_=r(84248),E=r(5531),M=r(99315),C=r(34365),T=r(34580),x=r(96706),D=r(50274),k=r(33866),O=r(52086),I=r(48584),F=r(45969),L=r(43334),A=r(24540),N=r(70379),R=r(71300),j=r(33209),B=r(48987),V=r(68268),z=r(61208),W=r(99023),q=r(30577),U=r(1485),G=r(19861),H=r(55111),J=r(30933),$=r(22859),K=r(71988),Y=r(38483),Z=r(90536),X=r(75164),Q=r(10546),ee=r(90967),te=r(67958),re=r(55948),ie=r(57039),ne=r(9945),se=r(74589),oe=r(844),ae=r(96093),le=r(23561),ue=r(69005),ce=r(87652),de=r(81075),he=r(58305),fe=r(57571),me=r(72564),ge=r(80372),pe=r(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new ae.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new ge.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new ge.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new ge.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new ge.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new ge.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,g.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new ge.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>G.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>U.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:U.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>U.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>L.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new ge.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new ge.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,F.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:H.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!L.isElectron}),commandTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new i.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>L.isMac?"100ms":L.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new ge.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new ne.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:E.CheckpointTypes,defaultValue:E.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:C.SynchronousModes,defaultValue:C.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to apply a migration, vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 2 minutes should be very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"2m"}),dbBackupIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,F.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:k.HealthCheckIds}),ffmpegHwaccel:new ge.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>L.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new ge.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new ge.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new ge.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new ge.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:q.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,T.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new ge.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,A.isRaspberryPi)()}),taskTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new ge.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new ge.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,J.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:D.SidecarExts,defaultValue:D.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:$.AggregateTypes.intersection,strEnum:$.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new ge.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new ne.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:re.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,J.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:O.CropStrategies.attention,strEnum:O.CropStrategies}),videoFrameAtSec:new ne.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,o.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(L.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>j.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:I.SharpFailOns.truncated,strEnum:I.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>B.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:oe.MinValidYear}),maxValidFutureMs:new ie.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:pe.TagInferenceSettingValues,defaultValue:pe.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new ne.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:N.DateTagFormats.ym,strEnum:N.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:V.KeywordReparentingStrategies.move,strEnum:V.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new ge.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:z.NameTagFormats["as-is"],strEnum:z.NameTagFormats}),tagNamesDefaultFamily:new ge.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new ge.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new ge.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,F.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,r]of(0,d.entries)(t.Settings))r._setName(e);function Se(e){const r=((0,l.blank)(e)?"":e).split(n.delimiter);return(0,F.isDocker)()&&r.unshift("/opt/photostructure/tools/bin"),r.push(...t.Settings.toolPaths.valueOrDefault),(0,o.uniq)(r).filter(l.notBlank).join(n.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,x.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,a.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new p.CaseInsensitiveMap;for(const r of(0,t.persistedSettings)()){for(const t of r.names)e.set(t,r);for(const t of r.keys)e.set(t,r)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const i=r(19851),n=r(31586),s=r(7282),o=r(49776),a=r(46292),l=r(32774),u=r(55086),c=r(46296),d=r(55939),h=r(96706),f=r(83278),m=r(92234),g=r(45969),p=r(60865),y=r(30933),v=r(15674),w=r(28874);t.setSettingsDefaults=(0,i.lazy)((()=>{w.Settings.configDir.opts.defaultValue=a.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=o.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,g.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=p.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,n.sigFigs)(50/(0,y.cpuCount)(),2)}))},84438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const i=r(76760),n=r(40958),s=r(22573),o=r(98553),a=r(55835),l=r(59455),u=r(83179);function c(e){return null==e?void 0:(0,o.stringify)(e)}t._join=c;function d(e){return(0,a.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,n.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",i.delimiter])if(t.includes(e))return(0,n.compactBlankish)(t.split(e));return[t]}}(e),n.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,n.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,n.isEmpty)(e)||(this.value=this.toValidValues((0,n.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,n.isEmpty)(this.values)}isNotEmpty(){return(0,n.isNotEmpty)(this.values)}toNotEmpty(){return(0,n.toNotEmpty)((0,n.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=n},72564:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const i=r(40958),n=r(98553),s=r(55835),o=r(58305);class a extends o.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,n.stringify)((0,i.uniq)(e)))),fromEnv:t=>{return r=t,n=e.strEnum,(0,i.compact)((0,o.splitStringArray)(r)?.map((e=>n.getCI(e))));var r,n},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=a},80372:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const i=r(22573),n=r(81168),s=r(83179);class o extends s.Setting{constructor(e){super({toEnv:a,fromEnv:a,...e})}hasValue(){return(0,i.notBlank)(this.value)}}function a(e){return null==e?void 0:(0,n.trimQuotes)(e)}t.StringSetting=o},32707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const i=r(76760),n=r(55835),s=r(46292),o=r(84438);t.systemSettingsFile=function(){return(0,n.map)((0,s.configDir)(),(e=>(0,i.join)(e,o.SettingsToml)))}},80496:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const i=r(50989);t.TagInferenceSettingValues=(0,i.strEnum)("never","always","auto")},6707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const i=r(90858),n=r(44652),s=r(22573),o=r(76850),a=r(50213),l=r(81168),u=r(84542),c=r(17217),d=r(68284),h=r(98778);function f(e){return t=(0,o.debom)(e),(0,s.blank)(t)?void 0:(0,i.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,n.readFileSync)(t)):void 0}catch(e){return void(0,a.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>f(await(0,n.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,n.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const i=r(22573),n=r(96249),s=r(98553),o=r(68708),a=r(51926);function l(e,t,r){if((0,i.blank)(e))throw new Error("kvToToml(): Blank key");const n=e+" = "+(0,s.stringifyPretty)(t);return(0,i.blank)(r?.prefix)?[n]:(0,a.wrap)(n.split("\n"),r)}t.stringifyToml=function(e){return(0,n.flatten)((0,o.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,i.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,a.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},10357:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},65162:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const i=r(4001),n=r(81168);t.bname=function(e,t=!0){let r=(0,n.isString)(e)?e:e.name;return t&&(r=(0,i.stripCopySuffixFromName)(r)),r=(0,n.trimLeftPadding)((0,i.stripDSC)(r)),r.toLowerCase().normalize()}},70379:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const i=r(50989);t.DateTagFormats=(0,i.strEnum)("y","ym","ymd","")},71300:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},68268:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const i=r(50989);t.KeywordReparentingStrategies=(0,i.strEnum)("move","copy","retain")},61208:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const i=r(50989);t.NameTagFormats=(0,i.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const i=r(50989);t.NameTagOrders=(0,i.strEnum)("western","eastern")},60865:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const i=r(37805),n=r(30577);t.channel=function(){return(0,n.extractUpdateChannel)(i.version)},t.baseVersion=()=>[i.versionMajor,i.versionMinor,i.versionPatch].join("."),t.versionMajorMinor=i.versionMajor+"."+i.versionMinor},76280:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const i=r(38064),n=r(22573),s=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function o(e){if(e instanceof i.SemVer)return e.version;const t=s.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=o,t.semverSatisfies=function(e,t){if((0,n.blank)(e))return!1;const r={loose:!0,includePrerelease:!0};if((0,i.satisfies)(e,t,r))return!0;const s=o(e);return null!=s&&(0,i.satisfies)(s,t,r)},t.toSemver=function(e){try{return e instanceof i.SemVer?e:(0,i.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const i=r(50989);t.UpdateChannels=(0,i.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const r of t.UpdateChannels.values)if(e.includes("-"+r))return r;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},1485:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const i=r(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,i.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},69375:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const i=r(19851),n=r(22573),s=r(50213),o=r(9103),a=r(7282),l=r(29882),u=r(43334),c=r(28874),d=(0,i.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,n.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,a.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,a.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,a.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,g=u.isLinux||(0,a.isTest)()?/^\/var\/lib\//:void 0;function p(e){if((0,n.blank)(e))return"blank";const t=(0,l.toPathnames)(e),r=t[0],i=t[t.length-1];return c.Settings.excludedRootDirectories.has(r)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(i)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===r&&!1===m?.test(e)?"LinuxRunRE":!0===g?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,o.memoize)((e=>{if(u.isWin)return!1;const t=p(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=p},63870:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const i=r(42659),n=r(12168),s=r(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=n.MiB/i.secondMs},55111:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const i=r(50989);t.HelmetPlugins=(0,i.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},30933:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const n=i(r(48161)),s=r(19851),o=r(42659),a=r(31586),l=r(50213),u=r(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>n.default.cpus()),5*o.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=n.default.availableParallelism?.(),r=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,a.clamp)(1,128,Math.ceil(e??r)),meta:{availableParallelism:e,cpuInfoLength:r}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const n=i(r(48161)),s=r(19851),o=r(31586),a=r(12168),l=r(50213),u=r(45879),c=r(70417),d=r(45969),h=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=n.default.freemem(),t=n.default.totalmem(),r=(2*e+t)/3;if((0,d.isDocker)()){const i=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,o.gt0)(i))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([i,r]),meta:{freemem:e,totalmem:t,cgroupMem:i}})}return h().tap({msg:"estimatedFreeMem() ",result:r,meta:{result:(0,a.fmtBytes)(r),freemem:(0,a.fmtBytes)(e),totalmem:(0,a.fmtBytes)(t)}})}))},15674:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const i=r(19851),n=r(42659),s=r(41400),o=r(31586),a=r(12168),l=r(50213),u=r(7282),c=r(34102),d=r(57902),h=r(28874),f=r(30933),m=r(58444),g=r(22751),p=(0,i.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),g.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,i.lazy)((()=>{const e=(0,o.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*a.MB;return p().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/a.MB),worstCaseMemPerProcMb:Math.ceil(e/a.MB)}})}),n.minuteMs);function w(){const e=Math.round(g.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,r=0===e||0===t?1:(0,o.sigFigs)(t/e,2);return p().tap({msg:"timeoutPenalization()",level:r>1?d.LogLevels.warn:d.LogLevels.debug,result:r,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,o.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,f.cpuCount)())<=1},t.maxCpus=(0,i.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,f.cpuCount)())-1);let t=e;const r=g.timeoutRate.prior()?.eventsPerMinute??0,i=w();if(1!==i){const e=t;t*=i,p().warn("Recent timeouts! Throttling down.",{penalization:i,resultBeforePenalization:e,resultAfterPenalization:t})}const n=Math.min(e,v());return t=(0,o.clamp)(1,n,Math.floor(t)),p().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:i,timeoutsPerSecond:r,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,i.lazy)((function(){return(0,o.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,o.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,o.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},22751:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const i=r(58587),n=r(87997),s=r(19851),o=r(42659),a=r(41400),l=r(50213),u=r(7282),c=r(45255),d=r(34102),h=r(976),f=r(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new i.Rate(5*o.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const g=(0,s.lazy)((()=>(0,n.setInterval)(p,o.minuteMs).unref()));function p(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),g()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),p()},(0,a.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const i=r(76790),n=r(22573),s=r(50357),o=r(98553),a=r(49769),l=r(34666),u=r(30976),c=r(42279),d=r(32639),h=r(59455),f=r(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function g(e){return null==e||0===(0,h.toA)(e).length}function p(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,r)=>e===t[r]))}function v(e,t){for(let r=0;r=e.length||r>=e.length)return e;const i=e[t];return e.splice(t,1),e.splice(r,0,i),e}function S(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&(0,a.getOrSet)(r,e,(()=>i))}return[...r.values()]}function P(e,t,r=1,i=(e=>e)){const n=[];if(et;s-=r)n.push(i(s));return n}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=g,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,r){return m(e)?t(e):(0,c.tot)(r)},t.toPrimitive=p,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let r=0;rt.includes(e)))},t.includesAll=function(e,t){if(g(e)||g(t))return!1;for(const r of t)if(!e.includes(r))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const r=(0,i.sortBy)(e,p),n=(0,i.sortBy)(t,p);return r.every(((e,t)=>e===n[t]))},t.pushUniq=function(e,...t){for(const r of t)null==r||e.some((e=>(0,s.eql)(e,r)))||e.push(r);return e},t.pushUniqBy=function(e,t,r){const i=e.map(r);for(const n of t){const t=r(n);i.includes(t)||(e.push(n),i.push(t))}return e},t.insertAt=function(e,t,...r){return e.splice(t,0,...r),e},t.insertUniq=function(e,t,r){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let i=0;i0)return e.splice(i,0,t),e}return e.push(t),e},t.remove=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),r!==e.length},t.removeSame=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>e!==t)))),r!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(n.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,o.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const r of e)null==r||(0,s.eql)(t[t.length-1],r)||t.push(r);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const r=[];for(const e of(0,i.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))r.some((t=>t.includes(e)))||r.push(e);return(0,i.sortBy)(r,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&r.set(e,i)}return[...r.values()]},t.uniqBy2=function(e,t){const r=[];for(const i of e)null!=i&&r.every((e=>!t(i,e)))&&r.push(i);return r},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,r,i)=>e+(t(r,i)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,r,i)=>e+t(r,i)),0)},t.firstMatch=function(e,t){for(const r of S(t)){const t=e.exec(r);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let r=0;for(;e[r]===t[r];)r++;return r},t.anneal=function({array:e,expense:t,allowedDelta:r}){const i=Math.round(r);if(i<2)return e;for(let r=0;re)){return P(e,t,1,r)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,o.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,r,i=t.primitiveValueOfOrElse){const n=new Set(r.map(i));return e.filter((e=>!n.has(i(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const i=r(40958),n=r(36783),s=r(41801),o=r(98553),a=r(49769),l=r(55835),u=r(34666),c=r(59455);function d(e,t){return(0,n.copyArrayTo)(f(e,t),e)}function h(e,t){const r=new Map;for(const i of e)(0,a.getOrSet)(r,(0,o.stringify)(t(i)),(()=>i));return f(r.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,l.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,i.compact)(e),i.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,n.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,r)=>0===r||t>=e[r-1]))},t.sortedBy=function(e,t){return e.every(((r,i)=>0===i||t(r)>=t(e[i-1])))},t.sortBy=f,t.deepSortBy=function e(t,r){return f(t,r).map((t=>(0,s.isIterable)(t)?e(t,r):t))},t.pushSorted=function(e,t,r){const i=e.findIndex((e=>r(t){Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const i=r(32639);t.asPromise=async function(e){const t=await e;return(0,i.isFunction)(t)?t():t}},5233:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const i=r(41400),n=r(31586),s=r(13538),o=r(41583);t.retryOnReject_=async function(e,t){const r=(0,n.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return r();const a=t.onRetryWaitUntil??(e=>(0,i.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await r()}catch(e){const r=(0,o.toErr)(e);if(!1===t.errorIsRetriable?.(r)||l>t.maxRetries)throw r;return l++,await a(l),u()}};return u()}},17586:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},22573:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const i=r(55835),n=r(42279),s=r(54993);function o(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function a(e){return!o(e)}function l(e,t){if(!1===e||null==e||""===e)return;const r=(0,s.toS)(e);return a(r)?t(r):void 0}t.blank=o,t.notBlank=a,t.notBlankToS=function(e){return a(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,n.tot)(t);const r=(0,s.toS)(e).trim();return r.length>0?r:(0,n.tot)(t)},t.notBlankAnd=function(e,t){return!o(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,r){return(0,i.orElse)(l(e,t),r)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{function r(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function i(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const r=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=r,t.toBoolean=function(e){return!!r(e)||!i(e)&&void 0},t.toNotBoolean=function(e){return!r(e)&&(!!i(e)||void 0)},t.boolToInt=function(e){return r(e)?1:0},t.isFalse=i,t.isDisabled=function(e){return i(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>r(e)))},t.and=function(e){return e.every((e=>r(e)))},t.maybeAnd=function(e){let t;for(const r of e){if(!1===r)return!1;!0===r&&(t=!0)}return t},t.mapBoolean=function(e,t){return r(e)?t(!0):i(e)?t(!1):void 0},t.mapTrue=function(e,t){return r(e)?t():void 0}},79666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const i=r(98553);t.clone=function(e){return null==e?e:JSON.parse((0,i.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const i=r(40958),n=r(22573),s=r(30301),o=r(55835),a=r(31586),l=r(39926),u=r(51926),c=r(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function g(e){return e instanceof Date}function p(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,o.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=g,t.thisYear=function(){return(new Date).getFullYear()},t.ago=p,t.hence=function(e,t){return p(-e,t)},t.unixtime=function(e){const r=g(e)?e.getTime():(0,a.isNumber)(e)?e:Date.now();return Math.floor(r/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,r={includeMs:!0}){const i=Math.floor(e/t.hourMs);e-=i*t.hourMs;const n=Math.floor(e/t.minuteMs);e-=n*t.minuteMs;const s=Math.floor(e/t.secondMs),o=Math.floor(e-s*t.secondMs);return(0,l.pad2)(i)+":"+(0,l.pad2)(n)+":"+(0,l.pad2)(s)+(r.includeMs?"."+(0,l.pad3)(o):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const r=()=>{const e=t%100;return t=Math.floor(t/100),e},i=10*r(),n=r(),s=r(),o=r(),a=r(),l=r();return new Date(t,l-1,a,o,s,n,i)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,r="ago"){return e<1e3?"just now":(r=(0,n.blank)(r)?"":(0,u.ensurePrefix)(r," "),et.ms<=e)))){const s=Math.floor(e/i.ms);e-=s*i.ms,s>0&&(i.ms>=t.dayMs?r:n).push(s+i.s)}return e>0&&n.push((0,a.toFixedStr)(e/t.secondMs,3)+"S"),"P"+r.join("")+((0,i.isEmpty)(n)?"":"T"+n.join(""))},t.fmtIsoDate=function(e){const t=g(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,o.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const i=r(38639),n=r(73872);function s(e,t,r){if(null==r||y(e)||y(t))return null;const i=r.get(e)?.get(t);return"boolean"==typeof i?i:null}function o(e,t,r,i){if(null==r||y(e)||y(t))return;let n=r.get(e);null!=n?n.set(t,i):(n=new WeakMap,n.set(t,i),r.set(e,n))}function a(e,t,r,i){if(null!=r?.comparator)return u(e,t,r,i);const n=l(e,t);return null!==n?n:u(e,t,r)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,r,i){r??(r={});const u=!1===r.memoize?void 0:r.memoize??(r.memoize=new WeakMap),d=r?.comparator,f=s(e,t,u);if(null!==f)return f;const m=s(t,e,u);if(null!==m)return m;if(d){const r=d(e,t,i);if(!1===r||!0===r)return o(e,t,u,r),r;const n=l(e,t);if(null!==n)return n}const y=n(e);if(y!==n(t))return o(e,t,u,!1),!1;o(e,t,u,!0);const v=function(e,t,r,i){switch(r){case"String":case"Number":case"Boolean":case"Date":return a(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return g(e,t,["name","message","code"],i);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,i);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,r){return c(h(e),h(t),r)}(e,t,i);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),i);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),i);case"Set":case"Map":return function(e,t,r){if(e.size!==t.size)return!1;if(0===e.size)return!0;const i=[],n=[];return e.forEach((function(e,t){i.push([e,t])})),t.forEach((function(e,t){n.push([e,t])})),c(i.sort(),n.sort(),r)}(e,t,i);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return p(e,t,i)}}(e,t,y,r);return o(e,t,u,v),v}function c(e,t,r){const i=e.length;if(i!==t.length)return!1;if(0===i)return!0;let n=-1;for(;++n{Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,r,i=!1;const n=function(){if(i){if(null!=r)throw r;return t}try{return i=!0,t=e()}catch(e){throw r=e,e}};return n.prior=()=>t,n.hasPrior=()=>i,n}},41400:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const i=r(42659),n=r(35556),s=r(31586),o=r(68708);function a(e,t=!0){return new Promise((r=>{if(e<=0)r();else{const s=setTimeout((()=>r()),Math.ceil(e+.5));e>i.secondMs&&t&&n.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return a(t).then((()=>t))},t.delay=a,t.later=function(e,t=1){const r=Math.max(1,Math.ceil(t)),s=n.isNode&&r<=1?setImmediate(e):setTimeout(e,r);return n.isBrowser||t<=i.secondMs?s:(0,o.maybeCall)(s,"unref")??s}},50357:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const i=r(12487),n=r(68708),s=r(34666),o=r(32639);function a(e,t){return(0,i.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,o.isFunction)(e)&&(0,o.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=a,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return!1;for(const r of(0,n.keys)(e))if(!a(e[r],t[r]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,r){if(null==e||null==t)return e===t;if(null!=r){const i=d.get(r);if(null!=i)return i(e,t)??null}for(const r of c){const i=r(e,t);if(null!=i)return i}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(31586),a=r(68708),l=r(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,n.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,o.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const r=[];for(const t of e)null!=t&&(t instanceof Error?r.push(u(t),c(t),t?.message):r.push((0,l.toS)(t)));return(0,i.uniq)((0,i.compactBlankish)((0,s.flatten)((0,i.compact)(r).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,n.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const r=(0,l.toS)(e).split("\n").filter((e=>!(0,n.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,i.isEmpty)(r)?["(missing stack)"]:r}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,n.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(n.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,a.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,a.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,a.assignFields)(new Error,(0,a.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},96249:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const i=r(59455);t.flatten=function(e,t=[]){for(const r of(0,i.toA)(e))if(null!=r)for(const e of(0,i.toA)(r))null!=e&&t.push(e);return t}},57924:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const i=r(40958);function n(e,t){return null==(e=(0,i.uniq)((0,i.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=n,t.orList=function(e){return n(e,"or")},t.andList=function(e){return n(e,"and")}},73722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const i=r(50989);t.FitSizes=(0,i.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,i.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const i=r(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,r){if((0,i.lt0)(t))return[...e].slice(t,r);const n=e[Symbol.iterator]();if((0,i.gt0)(t))for(let e=0;e{Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,r){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(r))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],r=[];return function e(i,n){if((0,isFunction_1.isFunction)(i))return;let s,o,a,l=toJSON(i);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(i===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let i=0;t.Latch=class{constructor(e=i++){this.id=e,this[r]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},r=Symbol.toStringTag},30301:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const i=r(40958),n=r(50357),s=r(31586),o=r(65812);t.lazy=function(e,t){let r,a;const l=[];function u(){return u.isStale()&&u.setResult(e()),a}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return r=Date.now(),async function(e,r){if((0,i.isEmpty)(l))return;const s=await e,a=await r;if(!(0,n.eql)(s,a))for(const e of l)e(a);null!=t&&t>0&&void 0!==a&&(0,o.setUnrefTimeout)((()=>u.vacuum()),t)}(a,e),a=e},u.isStale=function(){return null==r||(0,s.gt0)(t)&&r+t{Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,r){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const i=r();return null!=i&&e.set(t,i),i}},t.deleteIf=function(e,t){for(const[r,i]of e.entries())t(r,i)&&e.delete(r)}},55835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const i=r(42279),n=r(54993);function s(e,t){return null==e?void 0:t(e)}function o(e,t,r){return null==e||null==t?void 0:r(e,t)}function a(e,t){return null!=e?e:(0,i.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=o,t.map3=function(e,t,r,i){return null==e||null==t||null==r?void 0:i(e,t,r)},t.orElse=a,t.mapOr=function(e,t,r){return null!=e?t(e):(0,i.tot)(r)},t.map2Or=function(e,t,r,i){return a(o(e,t,r),i)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,n.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const i=r(68708);class n extends Error{constructor(e,t){super(e),this.message=e,(0,i.assignFields)(this,t)}}t.MetaError=n},23838:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const i=r(40958),n=r(76790),s=r(50357),o=r(98553),a=r(49769),l=r(55835),u=r(51926),c=r(59455);class d{static fromJSON(e){const t=new d;for(const[r,i]of Object.entries(e))t.add(r,...i);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,i.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const r=(0,a.getOrSet)(this.store,e,(()=>[]));return r.push(...t),r}addUniq(e,...t){return(0,i.pushUniq)((0,a.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const r=this.store.get(e);if(null==r)return!1;{const i=r.filter((e=>!(0,s.eql)(e,t)));return 0===i.length?this.store.delete(e):this.store.set(e,i),r.length!==i.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,i.uniq)(t))){for(const t of this.keys()){const r=this.store.get(t),n=null==r?[]:e(t,r);(0,i.isEmpty)(n)?this.store.delete(t):this.store.set(t,n)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,i.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield[t,r])}()}tuples(){const e=this;return function*(){for(const[t,r]of e.store.entries())for(const e of(0,c.toA)(r))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[r,n]of this.store.entries()){const s=(0,i.findIndexes)(n,(t=>!e(r,t,n)));if(s.length>0){t=!0;for(const e of s.reverse())n.splice(e,1)}0===n.length&&this.store.delete(r)}return t}inverse(){const e=new d;for(const[t,r]of this.store.entries())for(const i of r)e.add(i,t);return e}findKeyByTuple(e){for(const[t,r]of this.tuples())if(e(t,r))return t}filterKeysByTuple(e){const t=[];for(const[r,i]of this.entries())i.some((t=>e(r,t)))&&t.push(r);return t}toJSON(){const e={};for(const[t,r]of this.entries())e[(0,u.isString)(t)?t:(0,o.stringify)(t)]=r;return e}}function h(e,t){const r=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>r.add(t,e))))),r}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const r=h(e,t);return(0,n.sortBy)((0,c.toA)(r.values()),(e=>t(e[0])))}},35556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const r=globalThis;t.isBrowser="object"==typeof r?.window&&"object"==typeof r?.document,t.isNode="string"==typeof r?.process?.versions?.node},31586:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const i=r(76790),n=r(22573),s=r(42279),o=r(54993);function a(e){return"number"==typeof e&&isFinite(e)}t.isNumber=a,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,o.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return a(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,o.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,r)=>a(t)&&a(r)&&e(t,r);function f(e,r,n){return!(null==n||!a(n))&&([e,r]=(0,i.sort)([e,r]),(0,t.lte)(e,n)&&(0,t.gte)(r,n))}function m(e){if(!a(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function g(e){return"function"==typeof e?.toNumber}function p(e,t){if((0,n.blank)(e))return t.defaultValue;if(a(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return p(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return a(e)&&e>0}function S(e){return a(e)&&e>=0}function b(e,t){return a(e)?t(e):void 0}function P(e){return a(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const r=Math.pow(10,t);return P(e*r)/r}function E(e,t,r){if(e>t||!a(e)||!a(t))throw new Error(`invalid clamp(${e}, ${t}, ${r})`);return a(r)?rt?t:r:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return a(e)?e:t},t.diff=function(e,t){return a(e)&&a(t)?e-t:void 0},t.absdiff=function(e,t){return a(e)&&a(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,r=.95){if(!a(e)||!a(t))return!1;if(e===t)return!0;if(r>=1)return!1;const i=(0===t?1e-5:t)*(1-r);return f(t-i,t+i,e)},t.within=f,t.max_=function(...e){let t;for(const r of e)a(r)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return a(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return a(e)&&a(t)&&e>t?e:void 0},t.lte0=function(e){return a(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const r=y(e);return null==r?void 0:t(r)},t.mapFloat=function(e,t){const r=v(e);return null==r?void 0:t(r)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,r){return b(e,(e=>b(t,(t=>r(e,t)))))},t.mapNumericOr=function(e,t,r){return a(e)?t(e):r},t.numericOr=function(e,t){return a(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!a(e)||0===e||0===t)return 0;const r=t-P(Math.ceil(Math.log10(Math.abs(e)))),i=Math.pow(10,Math.abs(r));return r<0?P(e/i)*i:P(e*i)/i},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=E,t.times=function(e,t){if(!w(e))return[];const r=Math.round(e);return r<=0?[]:[...Array(r)].map(((e,r)=>t(r)))},t.pct=function(e,t){return E(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const r=Math.round(e??-1);return null==t||f(0,t,r)?r+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const r of e){if(!a(r))return;t+=r}return t}},68708:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(32639),a=r(55835),l=r(31586),u=r(34666),c=r(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function g(e){return h(e).map((t=>e[t]))}function p(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const r of e)if(null!=r&&Array.isArray(r)){const[e,i]=r;null!=e&&void 0!==i&&("object"!=typeof t&&(t={}),t[e]=i)}return t}function v(e){if(null==e)return;const t=p(e);if(t.every((([,e])=>null!=e)))return e;const r=t.filter((([,e])=>null!=e));return(0,i.isEmpty)(r)?void 0:y(r)}function w(e,t,r={}){return y((0,i.compact)((0,n.sort)(h(e)).map((r=>t(r,e[r])))).filter((([e,t])=>null!=e&&void 0!==t)),r)}function S(...e){const t=(0,i.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const r=t.filter(d);if(t.length!==r.length)return t;const n={};for(const e of(0,i.uniq)((0,i.flatMap)(r,h)))n[e]=S(...r.map((t=>t[e])));return n}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const r=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(r.test(t))return{key:t,value:e[t]}}function P(e){return g(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const r=v(e);return m(r)?t(r):void 0},t.values=g,t.entries=p,t.fromEntries=y,t.assignFields=function(e,t,r){if(null==t)return e;for(const[i,n]of p(t))!0!==r?.omitKeys?.includes(i)&&(null==n&&!0!==r?.assignNullish||(e[i]=n));return e},t.assignUndefinedFields=function(e,t,...r){if(null==t)return e;for(const i of r){const r=t[i];void 0!==r&&void 0===e[i]&&(e[i]=r)}return e},t.assignAllFields=function(e,t){for(const[r,i]of p(t??{}))e[r]=i;return e},t.definedValues=function(e){if(null==e)return;const t=p(e);if(t.every((([,e])=>void 0!==e)))return e;const r=t.filter((([,e])=>void 0!==e));return(0,i.isEmpty)(r)?void 0:y(r)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,i.compact)(t.map(e));{const r=(0,i.compact)(p(t).map((([t,r])=>(0,a.map)(e(r),(e=>[t,e])))));return 0===r.length?void 0:y(r)}}},t.compactBlankValues=function(e){if(null==e)return;const t=p(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,i.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickCompact=function(e,...t){if(null==e)return;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickNonBlank=function(e,...t){if(null==e)return e;const r={};for(const i of t){const t=e[i];(0,s.notBlank)(t)&&(r[i]=t)}return r},t.pickFirst=function(e,t,r=a.defined){if(null!=e)for(const i of t)if(r(e[i]))return e[i]},t.pickDeep=function e(t,...r){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...r)));const i={};function n(e,t){if(null==t)return;const r=i[e];i[e]=null==r?t:S(r,t)}for(const i of r){const[r,o]=(0,c.splitFirst)(i,"."),a=b(t,r);null!=a?.value&&n(a.key,(0,s.blank)(o)?a.value:e(a.value,o))}for(const i of h(t))((0,l.toInt)(i)??-1)>=0&&n(i,e(t[i],...r));return i},t.pluck=b,t.pluckDeep=function e(t,r){if(null==t||(0,s.blank)(r))return;if(Array.isArray(t)){const n=(0,i.compact)(t.map((t=>e(t,r))));return(0,i.isEmpty)(n)?void 0:{key:n[0].key,value:(0,i.flatMap)(n,(e=>e.value))}}const[n,o]=(0,c.splitFirst)(r,"."),a=b(t,n);if(null==a)return;if((0,s.blank)(o))return a;const l=e(a.value,o);return null==l?void 0:{key:a.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const r=p(e).filter((([e])=>!t.includes(e)));return(0,i.isEmpty)(r)?void 0:y(r)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(p(e).filter((([e,r])=>t(e,r))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,i.uniq)(t)},t.maybeCall=function(e,t,...r){const i=e?.[t];return(0,o.isFunction)(i)?i.bind(e)(...r):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const r=t.toLowerCase().normalize();for(const t of h(e))if(r===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const r=w(t,((t,r)=>[t,e(r)])),i=g(r);return 1===i.length?i[0]:r}},97790:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(r||(r={})),t.None=r;class i{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new i(e(this.a))}flatMap(e){const t=e(this.a);return n(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,r){return s(e).flatMap((e=>s(t).flatMap((t=>r(this.a,e,t)))))}zip3(e,t,r,i){return s(e).flatMap((e=>s(t).flatMap((t=>s(r).flatMap((r=>i(this.a,e,t,r)))))))}}function n(e){return e instanceof i||e===t.None}function s(e){return n(e)?e:null!=e?new i(e):t.None}t.Some=i,t.isOpt=n,t.opt=s},39926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const i=r(31586),n=r(54993),s={};function o(e,t){if(t<1)return"";if(!(0,i.gte)(s[e]?.length,t)){let r=s[e]??e;for(;r.length{Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const i=r(22573),n=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,o=/[^aeiou]y$/,a=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,i.blank)(e))return e;const t=n.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(o)?e.replace(/y$/i,"ies"):null!=e.match(a)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const i=r(40958),n=r(54993),s=["number","string","boolean"];function o(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=o,t.mapPrimitive=function(e,t){return o(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,r){return o(e)?t(e):r()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(o)};const a=["boolean","number","bigint","symbol","string","object","function"];function l(e,r){if(null==e&&null==r)return 0;if(null==e)return-1;if(null==r)return 1;const i=typeof e,s=typeof r;if(!("string"!==i&&"symbol"!==i||"string"!==s&&"symbol"!==s)){const i=(0,n.toS)(e),s=(0,n.toS)(r),o=i.localeCompare(s);return i[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-o:o}return Array.isArray(e)&&Array.isArray(r)?u(e,r):i!==s?a.indexOf(i)-a.indexOf(s):e>r?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const i=r(59455);function n(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const r=await e;return null==r?void 0:t(r)},t.thenCollect=async function(e,t){const r=[];for(const n of(0,i.toA)(await e))if(null!=n){const e=await n;if(null!=e){const i=await t(e);null!=i&&r.push(i)}}return r},t.thenTap=async function(e,t=console.dir.bind(console)){const r=await e;return await t(r),r},t.isPromiseLike=n,t.isPromise=function(e){return n(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:r}){const i=await e;return t(i)?r(i):void 0}},57153:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const i=r(50989);t.PromiseStates=(0,i.strEnum)("pending","resolved","rejected")},30976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const i=r(40958),n=r(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function o(e,t,r){return null==r||0===r.length?s(e,t):a(e,t,1,r)[0]}function a(e,t,r,i){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const n=t-e,o=new Set(i??[]);if(t===e&&0===n&&0===o.size&&1===r)return[e];const a=n-o.size;if(r>a)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:n,size:r,slotsRemaining:a})}`);const l=new Set;for(;l.size0;e--){const r=Math.floor(Math.random()*(e+1));e!==r&&([t[e],t[r]]=[t[r],t[e]])}return t},t.sample=function(e,t){const r=[];for(const i of a(0,e.length,t))r.push(e[i]);return r},t.pickWeightedRandom=function(e){if((0,i.isEmpty)(e))return;const t=e.filter((e=>(0,n.gt0)(e.priority)));let r=l(0,(0,i.sum)(t,(e=>e.priority)));return t.find((e=>(r-=e.priority,r<=0)))}},5670:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const i=r(50989);t.ServiceNames=(0,i.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]}},50989:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const i=r(68708),n=r(42279);t.strEnum=function(...e){const t=Object.freeze(e),r=(0,i.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const o=e=>null!=e?r[e]:void 0,a=e=>null!=o(e);return{...s,values:t,length:t.length,has:a,includes:a,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:o,ordinal:e=>o(e)??t.length,validOrElse:(e,t)=>a(e)?e:(0,n.tot)(t),mapValid:(e,t)=>a(e)?t(e):void 0,cmp:(e,t)=>{const r=o(e),i=o(t);return null==r||null==i?void 0:r>i?1:r{const r=o(e);return null==r?void 0:t[r]}}}},51926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const i=r(40958),n=r(17586),s=r(22573),o=r(96249),a=r(41801),l=r(31586),u=r(59455),c=r(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,r){if(d(e))return t<0&&(t+=e.length),e.slice(t,r);{const i=f();return null!=i?(0,a.sliceIterable)(i.segment(e),t,r).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,r).join("")}}function g(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function p(e,t){const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.startsWith(i)?r.slice(i.length):r}function y(e,t){if(null==t)return e;const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.endsWith(i)?r.slice(0,-i.length):r}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,r){null==r&&(r=e.length);for(let i=r;i>=0;i--)if(m(e,i).startsWith(t))return i;return-1}function b(e,t,{normalize:r=!0}={}){if(null==e||null==t)return!1;const i=(0,c.toS)(e),n=(0,c.toS)(t);return i.length===n.length&&(i===n||i.toLowerCase()===n.toLowerCase()||"function"==typeof i.localeCompare&&0===(r?i.normalize():i).localeCompare(r?n.normalize():n,void 0,{sensitivity:"base"}))}function P(e,t){return(0,i.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,n.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,a.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,r){return d(e)?e.slice(t,null==r?void 0:t+r):m(e,t,null==r?void 0:t+r)},t.charArr=g,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=p,t.stripPrefixes=function e(t,r){if(null==t)return"";const i=(0,c.toS)(t);for(const t of r)if(null!=t&&t.length>0&&i.startsWith(t))return e(i.slice(t.length),r);return i},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:r}){return y(p(e,t),r)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:r}){return w(v(e,t),r)},t.ellipsize=function(e,t=80,r=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),r=(0,l.clamp)(0,t-1,(0,l.round)(r));const i=g(e);return i.length<=t?i.join(""):i.slice(0,t-1-r).join("")+"…"+(r>0?i.slice(-r).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,r){const i=r?.maxLineLen??80,n=r?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const i=(0,o.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,o.flatten)(i.map((t=>e(t,r))))}if((t=v((0,c.toS)(t),n).trim()).length<=i)return[t];const s=S(t," ",i);if(s>n.length)return[m(t,0,s),...e(m(t,s+1),r)];{const i=t.indexOf(" ",n.length+1);return i>0&&i{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const i=r(42659),n=r(68708),s=r(42279),o=r(83104),a=r(85556);async function l(e,t,r=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(r,i)=>{let n=!0;const s=setTimeout((()=>{n&&(n=!1,r(o.Timeout))}),t);try{s.unref?.();const t=await e;n&&(n=!1,r(t))}catch(e){n&&(n=!1,i(e))}finally{clearTimeout(s)}}))}async function u(e,t,r=!0){const n=await l(e,t,r);if(n===o.Timeout)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(t)+")");return n}t.toNotTimeout=function(e){return e===o.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,r=!0){const i=t-Date.now();return i<=0?o.Timeout:l(e,i,r)},t.thenOrOnTimeout=async function(e,t,r){return t<=0?e:new Promise((async(i,s)=>{let o=!0;try{const a=setTimeout((async()=>{if(o){o=!1;try{i(await r())}catch(e){s(e)}}}),t);(0,n.maybeCall)(a,"unref");const l=await e;o&&(o=!1,clearTimeout(a),i(l))}catch(e){o&&(o=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,r=!0){const n=t-Date.now();if(n<=0)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(n)+")");return u(e,n,r)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:r,unref:i=!0}){const n=await l(e,t,i);return n===o.Timeout?(0,s.tot)(r):n}},42279:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const i=r(32639);t.tot=function(e){return(0,i.isFunction)(e)?e():e},t.tol=async function(e){return(0,i.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class r extends Error{}t.TimeoutError=r},12168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const i=r(22573),n=r(30301),s=r(31586),o=r(46891),a=r(50989),l=r(51926),u=(0,n.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let r=0;for(const i of e)(0,s.isNumber)(i)&&(r+=i/t.MB);return(0,s.round)(r)},t.fmt=c,t.fmtToInt=function(e){return(0,i.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const r=Math.floor(Math.log10(e)),i=Math.floor(r/3),n=Math.pow(10,3*i),o=d[i];return(0,s.sigFigs)(e/n,t)+" "+o}t.fmtMB=function(e,r=3){return f(e*t.MB,r)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const r=Math.floor(Math.log2(e)),i=Math.floor(r/10),n=Math.pow(2,10*i),o=h[i];return(0,s.sigFigs)(e/n,t)+" "+o},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,a.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,r){return null==e?"":(0,i.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(r??(0,o.pluralize)(t)).trim())},t.plurMetric=function(e,t,r){return r??(r=(0,o.pluralize)(t)),{count:c(e),desc:1===e?t:r}}},65812:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const i=r(68708);t.setUnrefTimeout=function(e,t){const r=setTimeout(e,t);return(0,i.maybeCall)(r,"unref")??r}},23541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const i=r(41801),n=r(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,n.isString)(e)?[e]:(0,i.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const i=r(40958),n=r(23541),s=r(59455),o=r(54993);function a(e){return null==e?void 0:(0,n.isError)(e)?e:new Error((0,o.toS)(e))}t.toErr=a,t.toErrs=function(...e){return(0,i.compact)((0,s.toA)(e).map(a))}},54993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const i=r(98553);t.toS=function(e){return s(e,",")};const n={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==n?e.toString():(0,i.stringify)(e)}}t.toStr=s},90858:e=>{e.exports=require("@iarna/toml")},58587:e=>{e.exports=require("batch-cluster")},6858:e=>{e.exports=require("commander")},36507:e=>{e.exports=require("croner")},66261:e=>{e.exports=require("events")},77988:e=>{e.exports=require("exiftool-vendored")},44652:e=>{e.exports=require("fs-extra")},28787:e=>{e.exports=require("he")},51168:e=>{e.exports=require("luxon")},38064:e=>{e.exports=require("semver")},73872:e=>{e.exports=require("type-detect")},92460:e=>{e.exports=require("util")},31421:e=>{e.exports=require("node:child_process")},77598:e=>{e.exports=require("node:crypto")},78474:e=>{e.exports=require("node:events")},73024:e=>{e.exports=require("node:fs")},51455:e=>{e.exports=require("node:fs/promises")},77030:e=>{e.exports=require("node:net")},48161:e=>{e.exports=require("node:os")},76760:e=>{e.exports=require("node:path")},1708:e=>{e.exports=require("node:process")},57075:e=>{e.exports=require("node:stream")},46466:e=>{e.exports=require("node:stream/promises")},87997:e=>{e.exports=require("node:timers")},57975:e=>{e.exports=require("node:util")},38522:e=>{e.exports=require("node:zlib")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__={},exports;exports=__webpack_exports__,Object.defineProperty(exports,"__esModule",{value:!0}),__webpack_require__(36389),module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/bin/main.js b/bin/main.js index d49095d..fc19b7d 100755 --- a/bin/main.js +++ b/bin/main.js @@ -6,4 +6,4 @@ * IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THIS SOFTWARE */ -(()=>{var __webpack_modules__={60308:e=>{const t={PasetoNotSupported:"ERR_PASETO_NOT_SUPPORTED",PasetoDecryptionFailed:"ERR_PASETO_DECRYPTION_FAILED",PasetoInvalid:"ERR_PASETO_INVALID",PasetoVerificationFailed:"ERR_PASETO_VERIFICATION_FAILED",PasetoClaimInvalid:"ERR_PASETO_CLAIM_INVALID"};class i extends Error{constructor(e){super(e),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}e.exports.PasetoError=i,e.exports.PasetoNotSupported=class extends i{},e.exports.PasetoDecryptionFailed=class extends i{},e.exports.PasetoInvalid=class extends i{},e.exports.PasetoVerificationFailed=class extends i{},e.exports.PasetoClaimInvalid=class extends i{}},78972:(e,t,i)=>{const{PasetoInvalid:r,PasetoNotSupported:n}=i(60308),{decode:s}=i(47859),o=i(40816);e.exports=(e,{parse:t=!0}={})=>{if("string"!=typeof e)throw new TypeError("token must be a string");const{0:i,1:a,2:l,3:u,length:c}=e.split(".");if(3!==c&&4!==c)throw new r("token is not a PASETO formatted value");if("v1"!==i&&"v2"!==i&&"v3"!==i&&"v4"!==i)throw new n("unsupported PASETO version");if("local"!==a&&"public"!==a)throw new n("unsupported PASETO purpose");const d={footer:u?s(u):void 0,payload:void 0,version:i,purpose:a};if("local"===a)return d;const f="v1"===i?256:"v3"===i?96:64;let h;try{h=s(l).subarray(0,-f)}catch{throw new r("token is not a PASETO formatted value")}return d.payload=t?o(h):h,d}},2744:(e,t,i)=>{const r=i(78972);e.exports={decode:r}},67814:(e,t,i)=>{const r=i(85223);e.exports=({audience:e,expiresIn:t,iat:i=!0,issuer:n,jti:s,kid:o,notBefore:a,now:l=new Date,subject:u},c)=>{if(!(l instanceof Date&&l.getTime()))throw new TypeError("options.now must be a valid Date object");const d=l.getTime();if(void 0!==i){if("boolean"!=typeof i)throw new TypeError("options.iat must be a boolean");i&&(c.iat=new Date(d))}if(void 0!==t){if("string"!=typeof t)throw new TypeError("options.expiresIn must be a string");c.exp=new Date(d+r(t))}if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.notBefore must be a string");c.nbf=new Date(d+r(a))}if(void 0!==e){if("string"!=typeof e)throw new TypeError("options.audience must be a string");c.aud=e}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.issuer must be a string");c.iss=n}if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.subject must be a string");c.sub=u}if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.kid must be a string");c.kid=o}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.jti must be a string");c.jti=s}return c}},10968:(e,t,i)=>{const{PasetoClaimInvalid:r}=i(60308),n=i(85223);e.exports=({ignoreExp:e,ignoreNbf:t,ignoreIat:i,maxTokenAge:s,subject:o,issuer:a,clockTolerance:l,audience:u,now:c=new Date},d)=>{if(!(c instanceof Date&&c.getTime()))throw new TypeError("options.now must be a valid Date object");const f=c.getTime();if("iss"in d&&"string"!=typeof d.iss)throw new r("payload.iss must be a string");if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.issuer must be a string");if(d.iss!==a)throw new r("issuer mismatch")}if("sub"in d&&"string"!=typeof d.sub)throw new r("payload.sub must be a string");if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.subject must be a string");if(d.sub!==o)throw new r("subject mismatch")}if("aud"in d&&"string"!=typeof d.aud)throw new r("payload.aud must be a string");if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.audience must be a string");if(d.aud!==u)throw new r("audience mismatch")}if(void 0!==l&&"string"!=typeof l)throw new TypeError("options.clockTolerance must be a string");const h=l?n(l):0;let m;if("iat"in d){if("string"!=typeof d.iat)throw new r("payload.iat must be a string");if(m=new Date(d.iat).getTime(),!m)throw new r("payload.iat must be a valid ISO8601 string");if(!i&&m>f+h)throw new r("token issued in the future")}if("nbf"in d){if("string"!=typeof d.nbf)throw new r("payload.nbf must be a string");const e=new Date(d.nbf).getTime();if(!e)throw new r("payload.nbf must be a valid ISO8601 string");if(!t&&e>f+h)throw new r("token is not active yet")}if("exp"in d){if("string"!=typeof d.exp)throw new r("payload.exp must be a string");const t=new Date(d.exp).getTime();if(!t)throw new r("payload.exp must be a valid ISO8601 string");if(!e&&t<=f-h)throw new r("token is expired")}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.maxTokenAge must be a string");if(!("iat"in d))throw new r("missing iat claim");if(m+n(s){e.exports.encode=e=>e.toString("base64url"),e.exports.decode=e=>Buffer.from(e,"base64")},80608:e=>{e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if("string"!=typeof e)throw new TypeError("options.assertion must be a string, or a Buffer");return Buffer.from(e,"utf8")}},83561:(e,t,i)=>{const r=i(65825);e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if(r(e))return Buffer.from(JSON.stringify(e),"utf8");if("string"!=typeof e)throw new TypeError("options.footer must be a string, Buffer, or a plain object");return Buffer.from(e,"utf8")}},1658:(e,t,i)=>{const r=i(67814),n=i(65825);e.exports=(e,t)=>{if(Buffer.isBuffer(e)){if(0!==Object.keys(t).length)throw new TypeError("options cannot contain claims when payload is a Buffer");return e}if(!n(e))throw new TypeError("payload must be a Buffer or a plain object");return e=(e=>JSON.parse(JSON.stringify(e)))(e),e=r(t,e),Buffer.from(JSON.stringify(e),"utf-8")}},82115:e=>{e.exports=e=>{const{x:t,y:i}=e.export({format:"jwk"}),r=Buffer.from(i,"base64"),n=2+(1&r[r.length-1]);return Buffer.concat([Buffer.alloc(1,n),Buffer.from(t,"base64")])}},88965:(e,t,i)=>{const r=i(64770),{PasetoInvalid:n}=i(60308),s=i(10968),{decode:o}=i(47859),a=i(40816);e.exports={post:function(e,t,i,r,n,o,l){if(t){if(0!==Object.keys(i).length)throw new TypeError("options cannot contain claims when options.buffer is true");return r?{payload:n,footer:o?.length?o:void 0,version:e,purpose:l}:n}const u=a(n);return s(i,u),r?{payload:u,footer:o?.length?o:void 0,version:e,purpose:l}:u},pre:function(e,t){if("string"!=typeof t)throw new TypeError("token must be a string, got: "+typeof t);if(t.slice(0,e.length)!==e)throw new n(`token is not a ${e.slice(0,e.length-1)} PASETO`);let{0:i,1:s="",length:a}=t.slice(e.length).split(".");try{r(a<=2),i=o(i),s=o(s)}catch{throw new n("token is not a PASETO formatted value")}return{raw:i,f:s}}}},56463:(e,t,i)=>{const r=i(76982),n=i(92460),s=i(70761),o=i(29534),{PasetoDecryptionFailed:a}=i(60308),l=i(82682),{webcrypto:{subtle:u}}=r,c=n.promisify(r.hkdf),d=Buffer.from("paseto-encryption-key"),f=Buffer.from("paseto-auth-key-for-aead"),h=Buffer.alloc(0),m=(e,t)=>r.createHmac("sha384",t).update(e).digest(),p=async(e,t,i,r)=>u[e]({name:"AES-CTR",counter:r,length:16},await u.importKey("raw",i,"AES-CTR",!1,[e]),t).then(Buffer.from),g=p.bind(void 0,"encrypt"),y=p.bind(void 0,"decrypt");e.exports={sign:n.promisify(r.sign),verify:n.promisify(r.verify),"v1.local-encrypt":async function(e,t,i){const n="v1.local.",a=m(e,r.randomBytes(32)).subarray(0,32),l=a.subarray(0,16),[u,h]=await Promise.all([c("sha384",i,l,d,32).then(Buffer.from),c("sha384",i,l,f,32).then(Buffer.from)]),p=await g(e,u,a.subarray(16)),y=s(n,a,p,t),v=m(y,h);return o(n,t,a,p,v)},"v1.local-decrypt":async function(e,t,i){const r=e.subarray(0,32),n=e.subarray(-48),o=e.subarray(32,-48),u=r.subarray(0,16),[h,p]=await Promise.all([c("sha384",i,u,d,32).then(Buffer.from),c("sha384",i,u,f,32).then(Buffer.from)]),g=s("v1.local.",r,o,t),v=m(g,p);if(!l(n,v))throw new a("decryption failed");const w=await y(o,h,r.subarray(16));if(!w)throw new a("decryption failed");return w},"v3.local-encrypt":async function(e,t,i,n){const a="v3.local.",l=r.randomBytes(32),[u,p]=await Promise.all([c("sha384",i,h,Buffer.concat([d,l]),48).then(Buffer.from),c("sha384",i,h,Buffer.concat([f,l]),48).then(Buffer.from)]),y=u.subarray(0,32),v=u.subarray(32),w=await g(e,y,v),S=s(a,l,w,t,n),b=m(S,p);return o(a,t,l,w,b)},"v3.local-decrypt":async function(e,t,i,r){const n=e.subarray(0,32),o=e.subarray(-48),u=e.subarray(32,-48),[p,g]=await Promise.all([c("sha384",i,h,Buffer.concat([d,n]),48).then(Buffer.from),c("sha384",i,h,Buffer.concat([f,n]),48).then(Buffer.from)]),v=p.subarray(0,32),w=p.subarray(32),S=s("v3.local.",n,u,t,r),b=m(S,g);if(!l(o,b))throw new a("decryption failed");const P=await y(u,v,w);if(!P)throw new a("decryption failed");return P}}},70981:(e,t,i)=>{const{KeyObject:r}=i(76982);let{isKeyObject:n}=i(75162);n||(n=e=>null!=e&&e instanceof r),e.exports=n},65825:e=>{e.exports=e=>!!e&&e.constructor===Object},41726:(e,t,i)=>{const{PasetoNotSupported:r}=i(60308);e.exports=e=>{if(!Number.isSafeInteger(e))throw new r("message is too long for Node.js to safely process");const t=~~(e/4294967295),i=e%4294967295-t,n=Buffer.allocUnsafe(8);return n.writeUInt32LE(t,4),n.writeUInt32LE(i,0),n}},85223:e=>{const t=36e5,i=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;e.exports=e=>{const r=i.exec(e);if(!r)throw new TypeError(`invalid time period format ("${e}")`);const n=parseFloat(r[1]);switch(r[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(1e3*n);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(6e4*n);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(n*t);case"day":case"days":case"d":return Math.round(864e5*n);case"week":case"weeks":case"w":return Math.round(6048e5*n);case"year":case"years":case"yr":case"yrs":case"y":return Math.round(315576e5*n)}}},29534:(e,t,i)=>{const{encode:r}=i(47859);e.exports=function(e,t,...i){let n=`${e}${r(Buffer.concat(i))}`;return t.byteLength&&(n+=`.${r(t)}`),n}},70761:(e,t,i)=>{const r=i(41726);e.exports=(...e)=>{e=e.filter(Boolean);let t=r(e.length);for(let i of e){i=Buffer.from(i,"utf8");const e=r(Buffer.byteLength(i));t=Buffer.concat([t,e,i])}return t}},40816:(e,t,i)=>{const{PasetoInvalid:r}=i(60308),{strict:n}=i(64770),s=i(65825);e.exports=e=>{try{const t=JSON.parse(e);return n(s(t)),t}catch{throw new r("All PASETO payloads MUST be a JSON object")}}},92366:(e,t,i)=>{const{sign:r}=i(56463),n=i(70761),s=i(29534);e.exports=async function(e,t,i,o,a,l,u){const c=n(u,e,t,i,l),d=await r(o,c,a);return s(e,i,t,d)}},495:(e,t,i)=>{const{createSecretKey:r}=i(76982),n=i(70981);e.exports=function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}`)&&(t=Buffer.from(t.slice(e.length),"base64url")),!n(t))try{t=r(t)}catch{}if(!n(t))throw new TypeError("invalid key provided");if("secret"!==t.type||32!==t.symmetricKeySize)throw new TypeError(`${e} secret key must be 32 bytes long symmetric key`);return t}},82682:(e,t,i)=>{const{timingSafeEqual:r}=i(76982),n=(e,t)=>{if(e.length===t)return e;const i=Buffer.alloc(t);return e.copy(i),i};e.exports=(e,t)=>{const i=Math.max(e.length,t.length);return r(n(e,i),n(t,i))}},49826:(e,t,i)=>{const{PasetoVerificationFailed:r}=i(60308),{verify:n}=i(56463),s=i(70761),{pre:o}=i(88965);e.exports=async function(e,t,i,a,l,u,c){const{raw:d,f}=o(e,t),h=d.subarray(0,-a),m=d.subarray(-a),p=s(c,e,h,f,u);if(!await n(i,p,l,m))throw new r("invalid signature");return{m:h,footer:f.length?f:void 0}}},91227:(e,t,i)=>{const r=i(60308),n=i(79665),s=i(56120),o=i(50015),a=i(64230),{decode:l}=i(2744);e.exports={decode:l,V1:n,V2:s,V3:o,V4:a,errors:r}},39324:(e,t,i)=>{const{"v1.local-decrypt":r}=i(56463),n=i(495).bind(void 0,"v1.local"),{pre:s,post:o}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:a=!1,...l}={}){const{raw:u,f:c}=s("v1.local.",e),d=(t=n(t)).export(),f=await r(u,c,d);return o("v1",a,l,i,f,c,"local")}},21472:(e,t,i)=>{const r=i(83561),n=i(495).bind(void 0,"v1.local"),s=i(1658),{"v1.local-encrypt":o}=i(56463);e.exports=async function(e,t,{footer:i,...a}={}){const l=s(e,a);t=n(t);const u=r(i),c=t.export();return o(l,u,c)}},79665:(e,t,i)=>{const r=i(77868),n=i(77256),s=i(21472),o=i(39324),a=i(70866);e.exports={sign:r,verify:n,encrypt:s,decrypt:o,generateKey:a}},70866:(e,t,i)=>{const r=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:s}=i(60308),o=n(r.generateKeyPair),a=n(r.generateKey);e.exports=async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await a("aes",{length:256});return"paserk"===t?`k1.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await o("rsa",{modulusLength:2048});return"paserk"===t?{secretKey:`k1.secret.${e.export({format:"der",type:"pkcs1"}).toString("base64url")}`,publicKey:`k1.public.${i.export({format:"der",type:"pkcs1"}).toString("base64url")}`}:e}default:throw new s("unsupported v1 purpose")}}},77868:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:n},createPrivateKey:s}=i(76982),o=i(83561),a=i(1658),l=i(92366),u=i(70981);e.exports=async function(e,t,{footer:i,...c}={}){const d=a(e,c),f=o(i);return t=function(e){if("string"==typeof e&&e.startsWith("k1.secret."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!u(e))try{e=s(e)}catch{}if(!u(e))throw new TypeError("invalid key provided");if("private"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public signing key must be a private RSA key with 2048 bit modulus length");return e}(t),l("v1.public.",d,f,"sha384",{key:t,padding:r,saltLength:n})}},77256:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:n},createPublicKey:s}=i(76982),o=i(49826),a=i(70981),{post:l}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:u=!1,...c}={}){t=function(e){if("string"==typeof e&&e.startsWith("k1.public."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!a(e)||"private"===e.type)try{e=s(e)}catch{}if(!a(e))throw new TypeError("invalid key provided");if("public"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public verify key must be a public RSA key with 2048 bit modulus length");return e}(t);const{m:d,footer:f}=await o("v1.public.",e,"sha384",256,{key:t,padding:r,saltLength:n});return l("v1",u,c,i,d,f,"public")}},56120:(e,t,i)=>{const r=i(88451),n=i(859),{generateKey:s,bytesToKeyObject:o,keyObjectToBytes:a}=i(62827);e.exports={sign:r,verify:n,generateKey:s,bytesToKeyObject:o,keyObjectToBytes:a}},62827:(e,t,i)=>{const r=i(64770),n=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:o}=i(60308),a=i(70981),l=s(n.generateKeyPair);async function u(e,t,{format:i="keyobject"}={}){if("keyobject"!==i&&"paserk"!==i)throw new TypeError("invalid format");if("public"===t){const{privateKey:t,publicKey:r}=await l("ed25519");return"paserk"===i?{secretKey:`k${e.slice(1)}.secret.${f(t).toString("base64url")}`,publicKey:`k${e.slice(1)}.public.${f(r).toString("base64url")}`}:t}throw new o(`unsupported ${e} purpose`)}function c(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 64:{const t=n.createPrivateKey({key:Buffer.concat([Buffer.from("302e020100300506032b657004220420","hex"),e.subarray(0,32)]),format:"der",type:"pkcs8"});if(!e.subarray(32).equals(Buffer.from(t.export({format:"jwk"}).x,"base64")))throw new TypeError("invalid byte sequence");return t}case 32:return n.createPublicKey({key:Buffer.concat([Buffer.from("302a300506032b6570032100","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 64 bytes (private key), or 32 bytes (public key)")}}function d(e,t){if(!a(t))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public key must be an Ed25519 key`);switch(t.type){case"public":return Buffer.from(t.export({format:"jwk"}).x,"base64");case"private":{const{d:e,x:i}=t.export({format:"jwk"});return Buffer.concat([Buffer.from(e,"base64"),Buffer.from(i,"base64")])}}}function f(...e){return d("v2",...e)}e.exports={_checkPrivateKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.secret.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,64)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!a(t))try{t=n.createPrivateKey(t)}catch{}if(!a(t))throw new TypeError("invalid key provided");if("private"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public signing key must be a private ed25519 key`);return t},_checkPublicKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.public.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,32)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!a(t)||"private"===t.type)try{t=n.createPublicKey(t)}catch{}if(!a(t))throw new TypeError("invalid key provided");if("public"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public verify key must be a public ed25519 key`);return t},_generateKey:u,_keyObjectToBytes:d,bytesToKeyObject:c,generateKey:async function(...e){return u("v2",...e)},keyObjectToBytes:f}},88451:(e,t,i)=>{const r=i(83561),n=i(1658),s=i(92366),{_checkPrivateKey:o}=i(62827),a=o.bind(void 0,"v2");e.exports=async function(e,t,{footer:i,...o}={}){const l=n(e,o);t=a(t);const u=r(i);return s("v2.public.",l,u,void 0,t)}},859:(e,t,i)=>{const r=i(49826),{_checkPublicKey:n}=i(62827),{post:s}=i(88965),o=n.bind(void 0,"v2");e.exports=async function(e,t,{complete:i=!1,buffer:n=!1,...a}={}){t=o(t);const{m:l,footer:u}=await r("v2.public.",e,void 0,64,t);return s("v2",n,a,i,l,u,"public")}},18582:(e,t,i)=>{const{"v3.local-decrypt":r}=i(56463),n=i(495).bind(void 0,"v3.local"),s=i(80608),{pre:o,post:a}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:l=!1,assertion:u,...c}={}){const{raw:d,f}=o("v3.local.",e);t=n(t);const h=s(u),m=t.export(),p=await r(d,f,m,h);return a("v3",l,c,i,p,f,"local")}},43406:(e,t,i)=>{const r=i(83561),n=i(495).bind(void 0,"v3.local"),s=i(1658),o=i(80608),{"v3.local-encrypt":a}=i(56463);e.exports=async function(e,t,{footer:i,assertion:l,...u}={}){const c=s(e,u);t=n(t);const d=r(i),f=o(l),h=t.export();return a(c,d,h,f)}},50015:(e,t,i)=>{const r=i(42438),n=i(65466),s=i(43406),o=i(18582),{generateKey:a,bytesToKeyObject:l,keyObjectToBytes:u}=i(80568);e.exports={sign:r,verify:n,encrypt:s,decrypt:o,generateKey:a,bytesToKeyObject:l,keyObjectToBytes:u}},80568:(e,t,i)=>{const r=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:s}=i(60308),o=i(70981),a=i(82115),l=n(r.generateKeyPair),u=n(r.generateKey);function c(e){if(!o(e))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public key must be an EC P-384 key");switch(e.type){case"public":return a(e);case"private":return Buffer.from(e.export({format:"jwk"}).d,"base64")}}e.exports={generateKey:async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await u("aes",{length:256});return"paserk"===t?`k3.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await l("ec",{namedCurve:"P-384"});return"paserk"===t?{secretKey:`k3.secret.${c(e).toString("base64url")}`,publicKey:`k3.public.${c(i).toString("base64url")}`}:e}default:throw new s("unsupported v3 purpose")}},bytesToKeyObject:function(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 48:return r.createPrivateKey({key:Buffer.concat([Buffer.from("303e0201010430","hex"),e,Buffer.from("a00706052b81040022","hex")]),format:"der",type:"sec1"});case 49:if(2!==e[0]&&3!==e[0])throw new TypeError("invalid compressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3046301006072a8648ce3d020106052b81040022033200","hex"),e]),format:"der",type:"spki"});case 97:if(4!==e[0])throw new TypeError("invalid uncompressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3076301006072a8648ce3d020106052b81040022036200","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 48 bytes (private key), 49 bytes (compressed public key), or 97 bytes (uncompressed public key)")}},keyObjectToBytes:c}},42438:(e,t,i)=>{const{createPrivateKey:r}=i(76982),n=i(83561),s=i(1658),o=i(80608),a=i(92366),l=i(70981),{bytesToKeyObject:u}=i(80568),c=i(82115);e.exports=async function(e,t,{footer:i,assertion:d,...f}={}){const h=s(e,f),m=n(i),p=o(d);return t=function(e){if("string"==typeof e&&e.startsWith("k3.secret."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,48)}catch{}if(Buffer.isBuffer(e))try{e=u(e)}catch{}if(!l(e))try{e=r(e)}catch{}if(!l(e))throw new TypeError("invalid key provided");if("private"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public signing key must be a private EC P-384 key");return e}(t),a("v3.public.",h,m,"sha384",{key:t,dsaEncoding:"ieee-p1363"},p,c(t))}},65466:(e,t,i)=>{const{createPublicKey:r}=i(76982),n=i(80608),s=i(49826),o=i(70981),{bytesToKeyObject:a}=i(80568),l=i(82115),{post:u}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:c=!1,assertion:d,...f}={}){t=function(e){if("string"==typeof e&&e.startsWith("k3.public."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,49)}catch{}if(Buffer.isBuffer(e))try{e=a(e)}catch{}if(!o(e)||"private"===e.type)try{e=r(e)}catch{}if(!o(e))throw new TypeError("invalid key provided");if("public"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public verify key must be a public EC P-384 key");return e}(t);const h=n(d),{m,footer:p}=await s("v3.public.",e,"sha384",96,{key:t,dsaEncoding:"ieee-p1363"},h,l(t));return u("v3",c,f,i,m,p,"public")}},64230:(e,t,i)=>{const r=i(29901),n=i(77933),{generateKey:s,bytesToKeyObject:o,keyObjectToBytes:a}=i(24961);e.exports={sign:r,verify:n,generateKey:s,bytesToKeyObject:o,keyObjectToBytes:a}},24961:(e,t,i)=>{const{_checkPrivateKey:r,_checkPublicKey:n,_generateKey:s,_keyObjectToBytes:o,bytesToKeyObject:a}=i(62827);e.exports={_checkPrivateKey:r,_checkPublicKey:n,bytesToKeyObject:a,generateKey:async function(...e){return s("v4",...e)},keyObjectToBytes:function(...e){return o("v4",...e)}}},29901:(e,t,i)=>{const r=i(83561),n=i(1658),s=i(80608),o=i(92366),{_checkPrivateKey:a}=i(24961),l=a.bind(void 0,"v4");e.exports=async function(e,t,{footer:i,assertion:a,...u}={}){const c=n(e,u),d=s(a);t=l(t);const f=r(i);return o("v4.public.",c,f,void 0,t,d)}},77933:(e,t,i)=>{const r=i(80608),n=i(49826),{_checkPublicKey:s}=i(24961),{post:o}=i(88965),a=s.bind(void 0,"v4");e.exports=async function(e,t,{complete:i=!1,buffer:s=!1,assertion:l,...u}={}){t=a(t);const c=r(l),{m:d,footer:f}=await n("v4.public.",e,void 0,64,t,c);return o("v4",s,u,i,d,f,"public")}},37975:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),n=i(38639),s=i(44198);function o(){return(0,n.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=o;let a=!o();function l(){return a}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){a=e??!o()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),n=i(7282),s=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,n.isProd)()?"":`-${(0,n.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),n=i(36783),s=i(76790),o=i(22573),a=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),f=i(34666),h=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const n=new Set(t.map(i));return e.filter((e=>n.has(i(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...v(e.slice(i+1))]}function w(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return M(e,(e=>e.valueOf()))}function P(e,t){return E(e,t,((e,t)=>(0,f.lt)(e,t)))}function M(e,t){return E(e,t,((e,t)=>(0,f.gt)(e,t)))}function _(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function E(e,t,i){return T(e,t,i).index}function T(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let n,s=-1;for(let r=0;re.slice(i,i+t)))}async function D(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,a.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(o.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,h.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,h.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,h.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,a.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,n.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let n=0;for(const s of e)(t(s,n++)?i:r).push(s);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let n=0;ne.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=M,t.leastBy=_,t.least=function(e){return _(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[M(e,t)]},t.leastByCtx=function(e,t){const i=T(e??[],t,f.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=x,t.collectBatched=function(e,t,i){const n=[];for(const s of x((0,r.compact)((0,h.toA)(e)),t))n.push(...(0,r.compact)(i(s)));return n},t.collectBatchedAsync=async function(e,t,i){const n=[];for(const s of x((0,r.compact)((0,h.toA)(e)),t))n.push(...(0,r.compact)(await i(s)));return n},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await D(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+n;if(re+1),1));return(0,h.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const a=i(77988),l=o(i(1708)),u=i(19851),c=i(42659),d=i(55835),f=i(31586),h=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),v=i(25764),w=i(38836),S=i(99331),b=i(95937),P=i(98314),M=i(38835),_=i(70025),E=i(8769),T=i(43334),x=i(95402),D=i(28874),k=i(63870);class C extends w.EndableWrapper{constructor(e,t,i=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,r,"m",n).call(this)),i,"worker"===e?(0,k.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const o=t;o.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,x.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new h.TimeoutError)})),o.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),o.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),o.on("fatalError",(e=>{this.onError("on(fatalError)"+M.FatalErrorFlag,e)})),o.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),o.on("noTaskData",((e,i,r)=>{const n=t.options.streamFlushMillis;n{this.logger.error("observeBatchCluster.endError()",e)})),o.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,f.gt0)(e?.pid)&&x.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof a.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,_.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,E.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=C,r=new WeakSet,n=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(T.isWin?3:1)*c.minuteMs,maxTasksPerProcess:D.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:D.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:D.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:D.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:D.Settings.taskTimeoutMs.valueOrDefault}}},71371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedGreatestSet=void 0;const r=i(92322);t.BoundedGreatestSet=class{constructor(e,t){this.maxLength=e,this.toValue=t,this.sortedArray=new r.SortedSet(t)}toA(){return this.vacuum(),this.sortedArray.toA()}vacuum(){return this.sortedArray.retainLastN(this.maxLength)}add(...e){this.maxLength<=0||(this.sortedArray.addAll(...e),this.sortedArray.length>=2*this.maxLength&&this.vacuum())}}},89788:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class f{constructor(e){if(r.add(this),this.maxLength=e,n.set(this,void 0),s.set(this,0),o.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,n,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",a).call(this,e,(e=>u(this,n,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",a).call(this,e,(e=>u(this,n,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,o,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,n,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,n,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,r,"m",a).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,n,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,s,"f"){u(this,n,"f")[e]=c,l(this,o,e,"f")}));return u(this,s,"f")}shift(){return u(this,r,"m",a).call(this,0,(e=>{var t,i;return l(this,o,(t=u(this,o,"f"),++t),"f"),l(this,s,(i=u(this,s,"f"),--i),"f"),u(this,n,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",a).call(this,u(this,s,"f")-1-e,(e=>{const i=u(this,n,"f")[e];u(this,n,"f")[e]=u(this,n,"f")[t],u(this,n,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=f},76850:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),n=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:i}of n)if(o(e,t))return e.subarray(t.length).toString(i);return e.toString()}function o(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,r.toS)(e)},t.bufferStartsWith=o},9092:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class n{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=n},36638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class n{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=n},40583:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const o=i(40958),a=i(23838),l=s(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new a.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,o.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,n=-1;for(const[i,s]of this.m.entries()){const o=(0,c.diceCoeff)(i,e);if(o>t&&o>n){const e=this.getFirst(s);null!=e&&(r=e,n=o)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),n=i(31586),s=i(68708),o=i(54993),a=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new a.Average(0);for(const t of this.keys()){if(!(0,n.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,o.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,n.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new a.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,n]of this.m.entries()){const s=e(r);t.fill(s,i,i+n),i+=n}return t}}t.CountingSet=u},79840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),n=i(72993),s=i(45969),o=i(43334);t.EditionType=(0,r.lazy)((()=>o.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>n.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),n=i(55835),s=i(68708);var o=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return o.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,n.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,s.omit)(e,...i),(0,s.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,n.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),n=i(19851),s=i(95696);t.examples=(0,n.lazy)((()=>s.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),n=i(65843),s=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,n.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,s.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),n=i(40958),s=i(55835),o=i(31586),a=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,o.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,o.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,n.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,n.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,a.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,a.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,a.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,o.isNumber)(e.__uid)&&(0,o.isNumber)(e.__start)}},80049:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),f=i(54993),h=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),n.set(this,0),s.set(this,0),o.set(this,0),a.set(this,0),this.cache=new h.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,n,l(this,n,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,o,l(this,o,"f")+e.rejections,"f"),u(this,a,l(this,a,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,n,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,o,"f"),timeouts:l(this,a,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,o,a;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,n,(i=l(this,n,"f"),++i),"f"),c.promise):(u(this,r,(o=l(this,r,"f"),++o),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(a=l(this,r,"f"),++a),"f"),c}get(e){var t,i;const n=this.cache.get(e);return null==n||n instanceof m.Deferred&&n.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),n instanceof m.Deferred?n.value:n}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,n,0,"f"),u(this,s,0,"f"),u(this,o,0,"f"),u(this,a,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,f.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,o,(t=l(this,o,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,a,(r=l(this,a,"f"),++r),"f")})),r.promise}},r=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap},54127:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class f{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const h=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,o.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,n.range)(0,r).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new f(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,a.fromEntries)(e))).filter((e=>(0,a.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,a=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(a,r.index);(0,s.blank)(l)||(h().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),f=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==f)this.skippedHeaders.push(m),h().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:f});else{const e=(0,n.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,o.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=f}a=t.lastIndex}const l=(0,n.last)(i);return null!=l&&((0,s.blank)(this.headerRow.slice(a))?l.rightIdx=(0,o.max_)(...this.rows.map((e=>e.length))):l.rightIdx=a),i}}t.Fixed=m},73168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const r=i(55835),n=i(20014),s=i(55222),o=i(97352),a=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,o.within)(-90,90,e)&&0!==e}function c(e){return(0,o.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function f(e,t,i=a){return(0,r.map)(m(e,t,l(i)),(e=>s.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=a){return f(e?.lat,e?.lon,t)},t.geohash=f,t.geohashNumericShort=function(e,t){return m(e,t,30)};const h=new n.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=a){return d(e,t)?h.zip([t,e],l(i)):void 0}function p(e,t=a){return h.unzip(e,l(t))?.reverse()}function g(e,t=a){const[i,r]=p(e,t);return{lat:i,lon:r}}t.geohashNumeric=m,t.ungeohash=function(e,t=a){return(0,r.map)(s.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,r=t.lat*Math.PI/180,n=(t.lat-e.lat)*Math.PI/180,s=(t.lon-e.lon)*Math.PI/180,o=Math.sin(n/2)*Math.sin(n/2)+Math.cos(i)*Math.cos(r)*Math.sin(s/2)*Math.sin(s/2);return 12742e3*Math.atan2(Math.sqrt(o),Math.sqrt(1-o))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),n=i(98553);var s=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const i=(0,n.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,n.parseJSON)((await(0,r.readFile)(e)).toString())}},57206:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDefaultJsonRevivers=void 0;const r=i(77988),n=i(51168),s=i(45599),o=i(98553),a=i(68708),l=i(24689),u=i(21330),c=i(57159),d=i(28544),f=(0,s.defer)((()=>{n.DateTime.prototype.toJSON=function(){return(0,a.compactValues)({_ctor:n.DateTime.name,ts:this.toMillis(),zone:"system"===this.zone?.type?void 0:this.zoneName})}})),h={name:n.DateTime.name,fromJSON:e=>n.DateTime.fromMillis(e.ts,(0,a.compactValues)({zone:e.zone}))};t.addDefaultJsonRevivers=(0,s.defer)((()=>{f(),(0,o.addJsonRevivers)(r.ExifDateTime,r.ExifDate,r.ExifTime,h,d.CapturedAt,l.DateInterval,u.FuzzyDate,r.BinaryField,c.WrappedError)}))},19851:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const o=i(57975),a=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new f(e,t)};class f extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,r,"m",n).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,a.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(42659),a=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),f=i(44198),h=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,a.mkLogger)("Locale")));function v(e=(0,f.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?_():E()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=w.exec(e.trim())?.groups;return null==i?void 0:(0,n.compact)([i.lang,i.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const M={timeoutMs:10*o.secondMs};async function _(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],M))}async function E(){return b(v((0,h.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],M)})))}t.localeMac=_,t.localePosix=E,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),n=i(1708),s=i(45599),o=i(68708),a=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),f=i(37805),h=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,s.defer)((()=>{(0,a.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:f.version,StartTs:d.StartTs,argv:n.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,o.pick)(n.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:n.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,h.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),n=i(32105),s=i(14593);t.rootLoggers=(0,r.lazy)((()=>[n.ConsoleLogger.instance()]));const o=(0,r.lazy)((()=>[n.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,o)}},56639:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),n=i(55835),s=i(59455),o=i(48884);function a(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,o.concat)(...e.map((e=>t(e)))))},t.compactMap=a,t.toMap=function(e,t){return a((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:a(await Promise.all((0,r.compact)((0,s.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,n.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),n=i(54557);t.memoize=function(e,t){let i=0;const s=new n.FifoCache(t.maxSize,t.ttlMs),o=t=>{if(null!=t)return i++,s.getOrSet((0,r.stringify)(t),(()=>e(t)))};return o.clear=e=>null==e?s.clear():s.delete((0,r.stringify)(e)),o.size=()=>s.size,o.callCount=()=>i,o}},31578:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const r=i(1708),n=i(31586),s=i(12168),o=i(70417);function a(){const e=(0,r.memoryUsage)();return(0,o.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,r.memoryUsage)().rss}t.memoryUsageBytes=a,t.memoryUsageMb=function(){return(0,n.sigFigs)(a()/s.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,n.sigFigs)(l()/s.MB,2)}},7282:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const n=r(i(1708)),s=i(38639),o=i(54993),a=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,a.lazy)((()=>n.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,o.toS)(n.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return n.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(n.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){n.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),n=i(22573),s=i(96249),o=i(55835),a=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function f(e,t){return(0,a.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(a.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,a.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=f,t.mapGte0Or=function(e,t,i){return(0,o.orElse)(f(e,t),i)},t.mapGte0f=function(e,t){const i=(0,a.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,a.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,a.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,a.toInt)(e),n=(0,a.toInt)(t);return null!=r&&r>0&&null!=n&&n>0?i(r,n):void 0};const h=/[+-]?[\d,.]+/;function m(e){if((0,a.isNumber)(e))return e;if((0,n.blank)(e))return;const t=String(e);return(0,o.map)(h.exec(t),(e=>(0,a.toFloat)(t.substr(e.index))))}function p(e){return(0,a.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,o.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,o.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const n=i*e.length;for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),n=i(42659),s=i(96249),o=i(55835),a=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),f=i(81168);function h(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,n.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,n]of(0,l.entries)(e)){const e=t(r,n);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,o.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(o.defined)},t.firstDefinedField=function(e,...t){return(0,o.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=h,t.tryEach=function(e,t){[...e].forEach((e=>h((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,o.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const n of t)r[n]=i(n,e[n]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let n=0;for(const s of(0,l.keys)(e))if(r[s]=t(s,e[s]),n++,(0,a.gt)(n,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,f.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,f.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,s.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),n=i(73024),s=i(48161),o=i(19851),a=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),f=i(48884),h=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),v=i(30933),w=(0,o.lazy)((()=>(0,h.mkLogger)("os")));function S(){return(0,s.platform)()+" "+(0,s.release)()}t.osArch=(0,o.lazy)((()=>`${function(){switch((0,s.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return C();case"win32":return O();default:return S()}}()} on ${(0,s.arch)()}`)),t.osFullName=(0,o.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const b=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function M(){return"ubuntu"===(0,t.osDistributionLinux)()}function _(){return"fedora"===(0,t.osDistributionLinux)()}function E(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,o.lazy)((()=>{if(g.isLinux)for(const e of b)try{const t=(0,n.readFileSync)(e).toString();if((0,a.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,o.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,a.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),S)})),t.osDistributionLinux=(0,o.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=M,t.hasApt=function(){return P()||M()},t.isFedora=_,t.isAlpine=E;const T={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},x={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function D(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),n=t[i];return(0,c.isString)(n)?n:n?.[r]}const k=(0,o.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function C(e=k()){try{return(0,a.mapNotBlankOr)(function(e=k()){return D(e,T)}(e),(t=>`macOS ${t} (${e})`),S)}catch(e){return w().warn("osNameMac(): unknown release",e),S()}}function O(e=(0,s.release)()){const t=e.startsWith("10.0.22")?"11":D(e,x);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=C,t.osNameWin=O,t.CPUs=(0,o.lazy)((()=>(0,f.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,o.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(O())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=k();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(M())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(_())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(E())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},12801:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const n=r(i(48161)),s=i(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:n.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:n.default.constants.priority.PRIORITY_NORMAL,BelowNormal:n.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:n.default.constants.priority.PRIORITY_LOW,Low:n.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setProcessTitle=t.setShortProcessNames=void 0;const r=i(72993),n=i(50213),s=i(23560),o=i(43334);let a=!o.isElectron;t.setShortProcessNames=function(e){a=e},t.setProcessTitle=function(){try{const e=[a?r.SimpleShortAppName:r.SimpleAppName];(0,s.isMainService)()&&o.isElectron||e.push((0,s.serviceName)());const t=e.join(o.isElectron?" ":"-");i(85949).title=t}catch(e){(0,n.mkLogger)("ServiceNames").warn("Failed to set friendly process name",e)}}},92782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeRandomUid=t.safeRandomChars=void 0;const r=i(55222),n=i(65713);t.safeRandomChars=function({radix:e=r.TokenRadix,length:t}){return(0,n.decuss)((()=>e.randomChars(t)))},t.safeRandomUid=function(e){return(0,n.decuss)((()=>(e?.radix??r.TokenRadix).randomUid(e?.chars??20,e?.splitEveryN??5,e?.sepChar??"-")))}},409:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),n=i(56409),s=i(31586),o=i(22911),a=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,f,h=!1,m=0;t=Math.ceil(t);const p=[];function g(){return h||m>Date.now()}function y(){if(null!=f){const e=f;f=void 0,w(...e)}}async function v(...r){h=!0,m=Date.now()+(0,s.max_)(t,i);const n=d=new o.Deferred(c);(0,s.gt0)(i)&&n.setTimeout(i);try{n.resolve(await e(...r))}catch(e){n.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{h=!1,m=Date.now()+t,(0,a.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return n.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return f=e,(0,r.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{f=void 0},w.donePromise=()=>{if(!h)return Promise.resolve();const e=new n.Latch;return p.push(e),e},w.force=async(...e)=>(f=void 0,h&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:h,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),n=i(54993);function s(e){return e instanceof o?e.source:(0,n.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let n;for(;null!=(n=e.exec(t));)n.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(n,"index","groups"));return i},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(s(t))}const n=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(n,i)};class o{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=o;class a extends o{static from(...e){const t=l(e);return new a("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,a=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof o||t instanceof RegExp?(i+=t.source,r||(r=t.global),a||(a=t.ignoreCase),l||(l=t.multiline)):i+=s((0,n.toS)(t));return new RegExp(i,t??(r?"g":"")+(a?"i":"")+(l?"m":""))}t.RegExpOptional=a,t.concatRegexp=l},79089:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const n=r(i(48161)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),f=i(51926),h=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),v=i(34102),w=i(43334),S=i(24399),b=i(28874),P=(0,o.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>E.prior()?.clear()))));const M=(0,o.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,f.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,a.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>M().includes(e.toLowerCase())))};let _=!0;const E=(0,o.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||E().has(e))return;E().add(e);const i=(0,p.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),_)try{return n.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;_=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(h.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const n=r(i(1708)),s=i(19851),o=i(40958),a=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function f(e){return(e??(0,t.serviceName)())===a.ServiceNames.web}function h(e){return(e??(0,t.serviceName)())===a.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===a.ServiceNames.sync}function p(){return(0,t.serviceName)()===a.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,o.compactBlanks)([t.serviceName.prior(),(0,l.toS)(n.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return a.ServiceNames.indexOf(e)??a.ServiceNames.length+1},t.MainServices=[a.ServiceNames.main,a.ServiceNames.desktop],t.DbServices=[a.ServiceNames.sync,a.ServiceNames.info,a.ServiceNames.web,a.ServiceNames.list,a.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[a.ServiceNames.sync,a.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||f(e)},t.isMainService=d,t.isWebService=f,t.isBillingService=function(e){return(e??(0,t.serviceName)())===a.ServiceNames.billing},t.isWorkerService=h,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===a.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||f()||((0,u.isTest)()||p())&&!h()},t.isDbJanitorService=(0,s.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!f()&&!d()&&!h()}},77377:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function n(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=n,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=n(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=n(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),n=i(57150),s=i(7282),o=i(23560),a=i(17181);t.setServiceName=function(e){(0,o.isMainService)(e)&&(e=r.ServiceNames.main);const t=o.serviceName.prior();t!==e&&((0,s.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),o.serviceName.set(e),(0,a.setupLogger)(),(0,n.logStartup)())}},28850:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const a=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends a.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),n.set(this,void 0),s(this,r,e,"f")}_call(){return(0,l.time)(o(this,r,"f")+(null==o(this,n,"f")?"(local)":"(remote)"),null==o(this,n,"f")?this.impl():o(this,n,"f").call(this))}setShim(e){s(this,n,e,"f")}hasShim(){return null!=o(this,n,"f")}clearShim(){s(this,n,void 0,"f")}}r=new WeakMap,n=new WeakMap},12089:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),f=i(54993),h=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends h.ExtensibleFunction{constructor(e,t,i,o){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=o,n.set(this,void 0),s.set(this,void 0),l(this,n,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",a).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",o).call(this,e),(()=>u(this,r,"m",a).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",o).call(this,e))}}n=new WeakMap,s=new WeakMap,r=new WeakSet,o=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,f.toS)(e):(0,c.stringify)(e))},a=function(e){return(0,m.time)(u(this,n,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){"use strict";var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=i(76790),o=i(17586);class a{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return n(this,r,"f")[Symbol.iterator]()}get length(){return n(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=n(this,r,"f").length-1;for(;t<=i;){const s=t+Math.floor((i-t)/2),o=this.valueOf(n(this,r,"f")[s]);if(e===o)return{found:!0,index:s};e>o?t=s+1:i=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&n(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...n(this,r,"f")];const o=t=>t<0||t>n(this,r,"f").length-1?null:(i??this.diff)(n(this,r,"f")[t],e),a=this.findIndex(e);if(null==a)return;let l=a.index-1,u=o(l),c=a.index,d=o(c);const f=[];for(;f.lengththis.valueOf(e)))}shift(){return n(this,r,"f").shift()}at(e){return(0,o.at)(n(this,r,"f"),e)}toA(){return[...n(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===n(this,r,"f").length-1){const e=[...n(this,r,"f")];return n(this,r,"f").length=0,e}return n(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return n(this,r,"f").splice(e,t)}retainLastN(e){return e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),n=i(82328),s=i(84542),o=i(95705),a=i(28874);t.consoleLog=function(e,...t){a.Settings.quiet.valueOrDefault||(0,n.stdoutEnded)()||console.log((0,s.crlf)(e),...t)},t.consoleError=function(e){a.Settings.quiet.valueOrDefault||(0,o.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=a.Settings.quiet.envValue;try{return a.Settings.quiet.envValue=!0,await e()}finally{a.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),n=i(95705);t.stdoutEnded=function(){return(0,n.streamEnded)(r.stdout)}},71567:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const n=r(i(1708)),s=i(22573),o=i(98553),a=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function f(e,t){return h({obj:e,ready:t,stream:n.default.stdout})}function h({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const n=(0,o.stringify)(e,void 0,(0,a.isInfoService)()||(0,a.isMainService)()?2:void 0);r.write(n+"\n"),(0,a.isWorkerService)()&&null!=i&&(n.includes(u.FailStr)||(0,c.isFatalError)(n)||(0,c.isHealthCheckError)(n)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||n.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=f,t.stderrWrite=function(e){return h({obj:e,stream:n.default.stdout})},t.writeTTY=h,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);f(t)},t.stdoutWriteMigration=function(e){return f({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>f({shutdownSync:!0}),restartSync:()=>f({restartSync:!0}),forceRestartSync:()=>f({forceRestartSync:!0}),rebuildLibrary:()=>f({rebuildLibrary:!0}),shutdown:()=>f({shutdown:!0})}},81168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(55835),a=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),f=i(54993),h=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,f.toS)(e),t=(0,f.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,f.toS)(e).indexOf((0,f.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const n=t.indexOf(i,r);return-1===n?0:1+e(t,i,n+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(f.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,a.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,f.toS)(e),t=(0,f.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,f.toS)(e),n=(0,f.toS)(t);return n.length>0&&(0,c.equalsIgnoreCase)(r.slice(-n.length),n,i)?r.slice(0,-n.length):r},t.gist=function(e,t=80,i=80){const r=(0,f.toS)(e),n=r.length-(t+i);return n<=0?r:r.slice(0,t).trim()+" …(+"+n+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,f.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,f.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,f.toS)(e))},t.capitalize=function(e){return e=(0,f.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,o.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=S(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,s.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),n=t.indexOf(r);if(n>=0)return{index:n,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,h.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,f.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const M=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function _(e){return M.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=_;const E=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,f.toS)(e).trim(),null!=E.exec(_(e))&&(e=e.slice(1,-1).trim())),e};const T=/^['‘’].*['‘’]$/,x=/^["“”„«»〃].*["“”„«»〃]$/;function D(e,t){const i=k(e,t);return(0,h.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function k(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let n,s=0;for(;null!=(n=t.exec(e));)n.index===t.lastIndex?t.lastIndex++:(t.lastIndex=n[0].length+n.index,i.push(e.substring(s,n.index)),r.push(e.substring(n.index,t.lastIndex)),s=t.lastIndex);return s(0,a.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,f.toS)(e).trim(),T.test(e)||x.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),n=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,o.map)(i[e],(e=>t+=e))));return t},t.splitKeep=D,t.splitUp=k,t.sortNaturalBy=C,t.sortNatural=function(e){return(0,n.sortBy)(e,(e=>C(e)))},t.stripDiacritics=function(e){return(0,f.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,f.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,n.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,a.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(f.toS).join("")};const O=/#.*$/gm;t.stripComments=function(e){return e.replace(O,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,s.blank)(r))for(const e of r.split(t))(0,s.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,s.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),n=e.findIndex((e=>r.test(e))),o=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(n<0)return e;for(let t=n+1;te.trim()))))}},83556:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function n(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=n,t.asObjectKey=function(e){return n(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const n=r(i(77598)),s=i(73913),o=i(55222);function a(e,t=s.HashBits){return n.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=o.Radix58,r=224){return i.encodeBuffer(a(e,r)).substring(0,t)}t.stringShaToBuffer=a,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=o.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(31586),a=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),f=i(88158),h=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,n="";for(let s=0;s=r&&(r=i.get(s,o),n=(0,l.substr)(e,s-r+1,r)));return n}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),n=t.normalize();return e!==r||t!==n?y(r,n):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function v(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,f.firstThunk)((()=>i===r?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(i),t=w(r);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function S(e,t){const i=(0,h.intersection)(e,t),n=[];return i.forEach((i=>{const s=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,o.times)(s,(()=>n.push(i)))})),n}function b(e,t,i){const n=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,n))-i((0,l.strslice)(t,n))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,n.sortBy)(t,(e=>-e.length))[0]}function M(e,t){const[i,r]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(i,r,(e=>(0,o.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=M;const _=/[^\da-z]+/gi;function E(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(_,"").toLowerCase()));return b(i,r,(e=>c.RadixAlphaNum.decode(e)))}function T(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const n=(0,o.mapNumericOr)(e.charCodeAt(r),(e=>e),256),s=(0,o.mapNumericOr)(t.charCodeAt(r),(e=>e),256),a=(0,o.clamp)(-256,256,n-s);i=null==i?a:(i+a)/2}return i}t.radixDiff=E,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:M(e,t),radixDiff:E(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=T,t.paddedPositionalDiff=function(e,t,i=8){return T((0,a.leftPad)(e,i," "),(0,a.leftPad)(t,i," "))}},84885:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),n=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,n.sortedKeys)(e))}},75387:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},f=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const h=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",n.set(this,[]),s.set(this,new Map),o.set(this,void 0),a.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,o,"f")}set ttlMs(e){f(this,o,e,"f"),null!=d(this,a,"f")&&clearInterval(d(this,a,"f")),f(this,a,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,a,"f")&&clearInterval(d(this,a,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,s,"f").clear(),this}delete(e){return d(this,s,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,s,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,s,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,s,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const n=t();return null!=n&&this.set(e,n),n}lastSetOrGetTs(e){return d(this,s,"f").get(e)?.ts}set(e,t){return d(this,s,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,s,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,s,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,h.sortBy)(d(this,s,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,n,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,s,"f").delete(e);for(const i of d(this,n,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,s,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){"use strict";var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[o]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return a(this,r,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>a(this,r,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||a(this,r,"m",n).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)a(this,r,"m",n).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!a(this,r,"m",n).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)a(e,r,"m",n).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)a(e,r,"m",n).call(e,t,i)||(yield[t,t])}()}toA(){return a(this,r,"m",s).call(this),[...this.delegate.keys()]}[(r=new WeakSet,o=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,n=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},s=function(){for(const[e,t]of this.delegate)a(this,r,"m",n).call(this,e,t)}},84699:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},94174:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const n=r(i(48161)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),f=i(45255),h=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,o.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,o.lazy)((()=>(0,a.uniq)([s.default.geteuid?.(),s.default.getuid?.(),n.default.userInfo().uid]))),t.userid=(0,o.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,o.lazy)((()=>(0,a.uniq)([s.default.getegid?.(),s.default.getgid?.(),n.default.userInfo().gid]))),t.groupid=(0,o.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,o.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,o.lazy)((()=>(0,l.toNotBlank)(n.default.userInfo()?.username))),t.userNameFromWhoami=(0,o.lazy)((async()=>(0,h.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:f.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,o.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,o.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,o.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.0-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=0,t.versionPrerelease=["prealpha"],t.release="2024.3.0-prealpha+20240308102353",t.gitSha="92cba1b21937cb9ca770f6a339e44b0fbee04bf9",t.gitDate=new Date(1709922233e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),n=i(55835),s=i(31586),o=i(97790),a=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,n.allDefined)(i))return;const[o,a,u,c,d,f,h]=i,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(o,a-1,u,c,d,f,h/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,o.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,a.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},73568:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const a=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),n.set(this,(0,a.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,n,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,n,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,n,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),o(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,r,"f")&&clearTimeout(s(this,r,"f")),o(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,n=new WeakMap},69591:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const n=r(i(87997)),s=i(31586);t.debounce=function(e,t){let i,r=[];const o=(0,s.gt0)(t)?(...s)=>{r=s,null!=i&&n.default.clearTimeout(i),i=n.default.setTimeout((()=>{e(...r)}),t)}:e;return o.reset=()=>{null!=i&&n.default.clearTimeout(i),i=void 0},o.force=()=>{o.reset(),e()},o.setTimeoutMs=e=>{o.reset(),t=e},o.timeoutMs=()=>t,o}},22911:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c,d,f,h,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(i(87997)),w=y(i(57975)),S=i(45599),b=i(26905),P=i(55835),M=i(31586),_=i(68708),E=i(20214),T=i(57153),x=i(85556),D=i(50213),k=i(70025),C=i(95937),O="TIMEOUT",I=(0,S.defer)((()=>(0,D.mkLogger)("async.Deferred")));class F{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,M.gt0)(t)?new n(O).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const n=i[r];if(n.isSettled){if(n.name===O)return void I().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield n.value}}if(i.every((e=>e.name===O)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new n(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),o.set(this,void 0),a.set(this,T.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),f.set(this,void 0),h.set(this,void 0),this.id=(g(i=n,n,(y=p(i,n,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,h,"f")??(0,D.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof n&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,a,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,_.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,o,"f")}get elapsedMs(){return(p(this,o,"f")??Date.now())-this.startedAt}get[(o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,f=new WeakMap,h=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,E.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,E.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,f,"f")&&(v.default.clearTimeout(p(this,f,"f")),g(this,f,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,M.gt0)(e)&&(g(this,f,v.default.setTimeout((()=>{this.isPending&&(this.reject(new x.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,C.onTimeout)())}),e),"f"),p(this,f,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,a,"f")===T.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,a,"f")!==T.PromiseStates.pending}get isResolved(){return p(this,a,"f")===T.PromiseStates.resolved}get isRejected(){return p(this,a,"f")===T.PromiseStates.rejected}get settledMs(){return null==p(this,o,"f")?void 0:p(this,o,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,a,T.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,k.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,a,T.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=F,n=F,m=function(e){if(p(this,a,"f")===T.PromiseStates.pending){(0,P.map)(p(this,f,"f"),v.default.clearTimeout),e(),g(this,o,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},s={value:0}},27395:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),n=i(40958),s=i(42659),o=i(23838),a=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),f=i(25764),h=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new o.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,a.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return f.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,h.setEnding)(!0),w();for(const t of f.EndableRanks.values){const i=g.get(t)??[];(0,n.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,h.setEnding)(!0),Promise.all((0,n.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of f.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){"use strict";var r,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),f=i(55835),h=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",o).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,n.set(this,void 0),s.set(this,void 0),a.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,n,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,h.toInt)(e)??0,t=(0,h.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",o).call(this);const f=()=>{u(this,r,"a",l)&&(0,h.gt0)(this.opts.intervalMs)&&(c(this,n,(0,d.setInterval)(u(this,a,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref())};return(0,h.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,a,"f").call(this),f())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):f(),!0}}t.EndableInterval=v,n=new WeakMap,s=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(){(0,f.map)(u(this,n,"f"),d.clearInterval),c(this,n,void 0,"f"),(0,f.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const a=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),f=i(25764),h=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=f.EndableRanks.first,o){this.endTimeoutMs=o,r.set(this,void 0),this.onEnds=[],n.set(this,(0,a.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,h.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,n,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){o(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,n,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,n=new WeakMap},99331:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let n=!1;t.ending=function(){return n},t.setEnding=function(e){n=(0,r.isTest)()?e:e||n}},45608:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const n=r(i(1708)),s=i(22573),o=i(45599),a=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),f=i(28874),h=i(27395),m=i(99331),p=i(56038),g=(0,o.defer)((()=>(0,l.mkLogger)((0,a.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,o.defer)((()=>{f.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,s.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,h.endEndables)(),n.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,o.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])n.default[e].on(t,(i=>{v({reason:`${e}:${t}`,status:0,error:i})}))}))},60172:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,r)=>{t=e,i=r})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const f=i(50357),h=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,n.set(this,void 0),s.set(this,0),o.set(this,void 0),a.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,o,"f")}unset(){d(this,s,0,"f"),d(this,n,void 0,"f"),d(this,o,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,h.gt0)(e)?e:void 0}watchLater(e){c(this,a,"f").push(e)}prior(){return this.isStale()?void 0:c(this,o,"f")}lastValue(){return c(this,o,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,n,"f")||(0,h.gt0)(this.ttlMs)&&Date.now()-c(this,n,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,n,"f")?void 0:Date.now()-c(this,n,"f")}elapsedMs(){return c(this,o,"f")?.settledMs??c(this,o,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,f.eql)(e?.value??await(e?.promise),i))for(const e of c(this,a,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,a,"f"))e.onError(t)}finally{d(this,s,(i=c(this,s,"f"),++i),"f")}},u=function(e){d(this,n,Date.now(),"f");const t=c(this,o,"f");return d(this,o,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,h.gt0)(this.timeoutMs)&&c(this,o,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,o,"f")),c(this,o,"f")}},1728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),n=i(80049);t.memoizeAsync=function(e,t){let i=0;const s=new n.FifoCacheAsync(t),o=t=>(i++,s.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return o.clear=e=>{if(null==e)return s.clear();{const t=(0,r.stringify)(e);return s.deleteIf((e=>t===e))}},o.size=()=>s.size,o.callCount=()=>i,o}},22781:function(e,t,i){"use strict";var r,n,s,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),n.set(this,!1),s.set(this,!1)}_call(){return o(this,n,"f")?(a(this,s,!0,"f"),!0===this.undefinedIfBusy?void 0:o(this,r,"f")):(a(this,n,!0,"f"),a(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{a(this,n,!1,"f"),!0===this.runLaterIfBusy&&o(this,s,"f")&&(a(this,s,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return o(this,n,"f")}prior(){return o(this,r,"f")}async force(){return await o(this,r,"f"),this._call()}}r=new WeakMap,n=new WeakMap,s=new WeakMap},37461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),n=i(76790),s=i(38639),o=i(42659),a=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),f=i(32639),h=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),v=i(15674),w=i(42638);var S=i(20214);async function b(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function M({name:e,arr:t,f:i,timeoutMs:n}){const s=[];for(const o of(0,r.compact)(await t))try{const e=await((0,l.gt0)(n)?(0,c.thenOrTimeoutError)(i(o),n):i(o));null!=e&&s.push([e,o])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:o,error:t})}return s}async function _({arr:e,f:t,name:i,maxConcurrent:n,timeoutMs:s,promises:o}){if(null==e)return[];const a=(0,r.compact)(await e);if((0,r.isEmpty)(a))return[];if((n=Math.round(n??(0,v.maxCpus)()))<=1)return M({arr:e,f:t,name:i,timeoutMs:s});const u=o??(a.length<=n?w.PermissivePromises:new w.Promises(i,(()=>n))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,f=await u.enqueueAll(i,a.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(f).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,i){const r=[];for(const n of(0,p.batches)((0,h.toA)(await e),t)){const e=await b(n);r.push(...await b(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,a.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,h.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,h.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,h.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,h.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=M,t.mapAsyncSerial=async function(e){return(await M(e)).map((e=>e[0]))},t.thenCollectParallel=_,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:n,promises:s}){return(await _({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:n,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:n,timeoutMs:s}){return(await _({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:n,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await _({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*o.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,n=null;try{r=await((0,f.isFunction)(e)?e():e)}catch(e){n=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(n??r)}catch{}if(null!=n)throw n;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,s.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const n=await t;return null!=n?i(r,n):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const n=await t(r);return null==n?i():n},t.thenMap2Or=async function(e,t,i,r){const n=await e;if(null==n)return r();const s=await t;if(null==s)return r();const o=await i(n,s);return null==o?r():o},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await _({name:e,arr:t,f:i});return(0,n.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(42659),a=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),f=i(22454),h=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),v=i(25764),w=i(38836),S=i(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new f.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),n=(0,l.clamp)(10*o.secondMs,o.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),n);try{const n=await(0,c.tot)(t),s=Date.now()-r;return i?.(n,s),this.push(e,s),n}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new h.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,a.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/o.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function M(e,t,i){return P.instance().time(e,t,i)}function _(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,n.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=M,t.timeSync=function(e,t){const i=Date.now(),r=t();return _(e,Date.now()-i),r},t.pushTime=_,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>M(e,t)),i)}},42638:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const h=f(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),v=i(54993),w=i(89788),S=i(82647),b=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class M{constructor(e,t){r.add(this),this.name=e,this.ee=new h.default.EventEmitter,n.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),o.set(this,[]),a.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,n,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,b.maxCpus)(),d(this,n,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,a,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,o,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,o,"f").map((e=>e.name)),pendingNames:d(this,a,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:i,serialId:n}){const s=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:n});return this.laterPop(),s}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,o,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,a,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,a,"f").length,e),i=this.runningSerialIds,n=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,o,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,a,"f").length}hasPending(){return d(this,a,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,a,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,a,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=M,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const n=new P.Deferred(e,{payload:i,serialId:r});return d(this,a,"f").push({d:n,l:t}),n},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,o,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,o,"f").push(e),e},t.maybeRun=function(e,t){const i=new M(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new M(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},4867:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),n=i(34546),s=i(41400),o=i(31586),a=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let a=!0;return Promise.race((0,r.compact)([(0,n.asPromise)(e).finally((()=>a=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>{if(a)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(a)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,n.asPromise)(e).finally((()=>l=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>a.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),n=i(42659),s=i(41400),o=i(32639),a=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let f=!1;const h=null==t?void 0:t+Date.now();let m=1;for(;null==h||Date.now()t/2&&!f&&(f=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,a.clamp)(10*m,l.ShortCommandTimeoutMs,(t??n.minuteMs)/5);await(0,s.delay)(r,d),m++}}return f||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const n=r(i(1708)),s=i(45599),o=i(41400),a=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),f=i(59958),h=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),v=i(50213),w=i(7282),S=i(88158),b=i(45969),P=i(43334),M=i(28874),_=i(3790);function E(e){return T().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const T=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(M.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(f.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>E(e))))},(0,o.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,M.allSettings)())t.watchLater(e)}));const x=["HOME","LANG","USER"],D=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],k=(0,p.lazy)((()=>{const e=(0,h.caseInsensitiveEnv)().pick(...P.isPosix?x:D),t=(0,h.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,M.pathWithDefaults)(),e}));function C(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[f.PS_IS_CHILD_PROCESS]="1",t[f.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[f.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,M.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,a.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(n.default.env,(e=>E(e)||!(0,_.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=C,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:I({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let O=!1;function I({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const n=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...k(),...i?(0,g.childProcLocale)():{},...C(r),...e??{}});for(const e of(0,M.transientSettings)())e.deleteFromEnv(n);if((0,y.isLogged)("debug")&&!O){O=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(n).map((([e,t])=>[e,(0,_.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>E(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return n}t.childEnv=I},84777:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const n=r(i(31421)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),f=i(31586),h=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),v=i(79089),w=i(45255),S=i(22911),b=i(4867),P=i(73614),M=i(70025),_=i(57159),E=i(36868),T=i(66184),x=i(45643),D=i(95402),k=i(9727),C=(0,o.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function O(e){return(0,h.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function I(e,t=30*u.secondMs){if(null==e)return!1;C().debug("endProcess()",O(e));const i=e.pid;if(null==i||i<=0)return C().warn("endProcess(): asked to end invalid pid",O(e)),!1;if(i===s.default.pid)return C().warn("endProcess(): asked to end MY pid",O(e)),!1;if(i===s.default.ppid)return C().warn("endProcess(): asked to end my parent pid",O(e)),!1;(0,E.closeStreams)(e);{const t=e.kill();C().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,D.killPid)(i).catch((e=>{C().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,x.waitForPidExit)(i,t))return C().debug("endProcess(): exitted",O(e)),!0;{D.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");C().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,D.killPid)(i,!0).catch((e=>{C().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,x.waitForPidExit)(i,5e3)}function F(e,i,r,n=0){const o=new Date,a=[];return(0,v.niceable)(i,r)&&a.push((0,P.setUnrefTimeout)((()=>{(0,f.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,f.gt)(n,u.secondMs)&&a.push((0,P.setUnrefTimeout)((()=>{(0,f.gt0)(e.pid)&&I(e)}),n-250)),a.push((0,P.setUnrefTimeout)((()=>{if((0,f.gt0)(e.pid))return(0,D.addPid)({pid:e.pid,cmd:i,timeoutMs:n,ppid:s.default.pid},o)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>a.forEach(clearTimeout))),e}function L(e,t,i,r){const s=(0,k.spawnOptions)(r);return(0,T.isLogged)("trace",C().context)?C().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:s}):C().debug("execFile()",{command:e,args:t,timeoutMs:i}),F(n.default.execFile(e,t,s),e,t,i)}async function A(e,t,i){const r=i.quiet??!1,n=i.ignoreStderr??!1,s=i.ignoreExitCode??!1,o=L(e,t,i.timeoutMs,(0,h.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{o.disconnect?.()}catch{}return{result:"",pid:o.pid}}const u=o.pid,h=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new S.Deferred(h);o.on("error",(e=>g.push(e))),o.on("exit",(e=>{(0,f.isNumber)(e)&&y.isPending&&y.resolve(e)})),o.on("close",(e=>{(0,f.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,E.endStream)(o.stdin);const v=new d.Latch;null==o.stdout?v.resolve():(o.stdout.on("error",(e=>g.push(e))),o.stdout.on("data",(e=>m.push(e))),o.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==o.stderr||n?P.resolve():(o.stderr?.on("error",(e=>g.push(e))),o.stderr?.on("data",(e=>p.push(e))),o.stderr?.on("end",(()=>P.resolve()))),C().debug("stdoutResult_() invoked and waiting for completion...",{name:h}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),C().debug("stdoutResult_() exitCode settled...",{name:h,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt});const T=p.join("");(0,l.notBlank)(T)&&g.push(new Error(T)),!r&&(0,a.isNotEmpty)(g)&&C().warn(h+" resulted in errors:",g);const x=i.isIgnorableError??M.isIgnorableError,D=g.filter((e=>!0!==x(e)));if(D.length>0)throw 1===D.length?D[0]:new _.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:D});if(!s&&0!==y.value)throw new Error(h+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:T}}catch(e){throw C().error("stdoutResult_() failed",e),await(0,D.killPid)(o.pid,!0),e}}t.endProcess=I,t.ReniceAfterMs=(0,o.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,o.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const s=(0,k.spawnOptions)(r);return C().debug("spawn()",{command:e,args:t,maxAgeMs:i}),F(n.default.spawn(e,t,s),e,t,i)},t.execFile=L,t.stdoutResult_=A,t.stdout_=async function(e,t,i){const r=await A(e,t,i);return C().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},86335:function(e,t,i){"use strict";var r,n,s,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ChildService=t.ChildServiceNames=t.inspectPort=t.pathToService=void 0;const l=i(77598),u=a(i(1708)),c=i(19851),d=i(40958),f=i(22573),h=i(50268),m=i(68708),p=i(5670),g=i(50989),y=i(12168),v=i(59455),w=i(41583),S=i(54993),b=i(80875),P=i(50213),M=i(81168),_=i(27395),E=i(25764),T=i(59958),x=i(70025),D=i(83278),k=i(85021),C=i(29325),O=i(43334),I=i(28874),F=i(84777),L=i(55534),A=i(85100),R=i(34330),N=(0,c.lazy)((()=>(0,P.mkLogger)("child.ChildService")));async function j(e){const t=(0,M.ensureSuffix)(e,".js"),i=D.BaseFile.projectRoot(),r=D.BaseFile.for(u.default.cwd()),n=(0,C.isPacked)()?[i.join("bin",t),O.isElectron?i.join("app.asar",t):void 0]:[r.join("dist","library",t),r.join("dist","core",t),r.join("lib","library",t)];(0,C.isPacked)()||(O.isElectron?(n.push(r.join("dist","app",t)),n.push(i.join("src","desktop","dist","library",t))):n.push(i.join("src","library","dist","library",t)));for(const e of n)if(null!=e&&!0===await e.isNonEmptyFile((0,C.isPacked)()?y.KB:128))return N().tap({msg:"pathToService()",level:"info",result:e,meta:{cmd:t,isPacked:C.isPacked,paths:n.map(S.toS)}});return N().throw("Failed to find path to "+e,{paths:n,fatal:!0})}t.pathToService=j,t.inspectPort=function(e){switch(e){case"web":return 9223;case"sync":return 9224;default:return(0,l.randomInt)(9225,9600)}},t.ChildServiceNames=(0,g.strEnum)(...p.ServiceNames.pick("web","sync"));class B{static async mk_(e,t={}){const i=t.pathToService??await j(e);if((0,f.blank)(i))throw new Error("Failed to find path to "+e);return t.nodeArgs=(0,v.toA)(t.nodeArgs),new B(e,i,t)}constructor(e,t,i){var a,l;r.add(this),this.serviceName=e,this.cmd=t,this.opts=i,this.restartCount=0,this.name="ChildService("+e+")",this.endTimeoutMs=(0,A.serviceExitTimeoutMs)(e),this.logger=(0,P.mkLogger)(this.name);const c=[...(0,v.toA)(i.nodeArgs),t.nativePath];(0,d.isNotEmpty)(i.args)&&c.push(...i.args),this.spawnOpts=(0,m.pick)(this.opts,"argv0","cwd","detached","env","gid","shell","stdio","timeout","uid","windowsHide","windowsVerbatimArguments","forceCLocale","forWorker"),this.spawnOpts.forceCLocale=!1,(l=(a=this.spawnOpts).env??(a.env={}))[T.UV_THREADPOOL_SIZE]??(l[T.UV_THREADPOOL_SIZE]=(0,S.toS)(("web"===e?I.Settings.webUvThreads:I.Settings.syncUvThreads).valueOrDefault)),this.wc=new R.WatchedChild({name:e,childFactory:async()=>(this.restartCount>0&&await(this.opts.onPreRestart?.()),this.restartCount++,(0,F.spawn)(u.default.execPath,c,-1,this.spawnOpts)),endableRank:E.EndableRanks.service,endTimeoutMs:this.endTimeoutMs,onStdout:o(this,r,"m",s).bind(this),onStderr:o(this,r,"m",n).bind(this),onError:this.opts.onError??(e=>!1===(0,x.isIgnorableError)(e)),ignoreStopErrors:!1,exitCommand:L.ServiceExitCommand,...i}),(0,_.addEndable)(E.EndableRanks.first,this)}get startMs(){return this.wc.startTs}runHealthCheck(){return this.wc.writeStdin(k.HealthCheckCommand+"\n")}start(){return this.wc.start()}stop(){return this.wc.stop()}restart(e){return this.wc.restart(e)}get ended(){return this.wc.ended}async end(){return this.wc.ended||this.write(L.ServiceExitCommand),this.wc.end()}get pid(){return this.wc.pid}running(){return this.wc.running()}notRunning(){return this.wc.notRunning()}write(e,t=2){if(t<0)return this.logger.warn("write(): no more retries",{toStdin:e}),!1;try{const t=this.wc.proc;return!0!==t?.stdin?.writable?(this.logger.warn("write(): childProc isn't open, ignoring",{toStdin:e}),!1):t.stdin.write((0,M.ensureSuffix)(e,"\n"))}catch(i){return this.logger.warn("write(): caught "+i),this.wc.onError("onStdout()",(0,w.toErr)(i)),this.write(e,t-1)}}}t.ChildService=B,r=new WeakSet,n=function(e){const t=(0,b.parseJSON)(e);return this.logger.warn(".onStderr()",t??e),!0===t?.fatal},s=function(e){if(!(0,f.blank)(e))try{const t=(0,b.parseJSON)(e);if(null==t)return void this.logger.info(".onStdout(): non-JSON payload",e);if(!0===t?.fatal)this.wc.onError(this.name+".onStdout()",t);else if((0,h.isHealthCheckSummary)(t)){const e="failed"===t.state||"error"===t.level;this.logger.log(e?"error":"info",".onStdout(): health check summary",t),e&&this.wc.onError(this.name+".onStdout()",t,e)}else null!=this.opts.onData&&this.opts.onData(t)}catch(t){this.logger.warn(".onStdout() failed:",{data:e,error:t})}}},3790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),n=i(41400),s=i(19851),o=i(28874);(0,n.later)((()=>o.Settings.sensitiveEnvRegExp.watchLater((()=>a.unset()))));const a=(0,s.lazy)((()=>{try{return new RegExp(o.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${o.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(o.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&a().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||o.Settings.license.includesEnvKey(e)}},55534:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceExitCommand=void 0,t.ServiceExitCommand="--exit"},85100:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serviceExitTimeoutMs=void 0;const r=i(23560),n=i(28874),s=i(45255);t.serviceExitTimeoutMs=function(e){return(0,r.isSyncService)(e)?n.Settings.syncExitTimeoutMs.valueOrDefault:s.ShortCommandTimeoutMs}},34330:function(e,t,i){"use strict";var r,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),f=i(19851),h=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(54993),w=i(27395),S=i(25764),b=i(99331),P=i(42638),M=i(38835),_=i(8769),E=i(57159),T=i(66003),x=i(50213),D=i(45643),k=i(28874),C=i(84777);t.mkBasicWatchedChild=function(e){return new O({name:(0,h.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,C.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class O{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,f.lazy)((()=>(0,x.mkLogger)("WatchedChild("+(0,h.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),n.set(this,!1),this.onError=(e,t,i)=>{const s=new E.WrappedError(e,{cause:t}),o=!1!==s.ignorable;this.logger().log(o?"warn":"error","onError()",s),u(this,n,"f")||o||(this.lastError=s,(0,_.onError)(s),!0!==s.fatal?(i??this.opts.onError(e,s))&&(this.logger().warn("onError requested restart",{src:e,error:s}),u(this,r,"m",a).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:k.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:S.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,w.addEndable)(this.opts.endableRank,this),u(this,r,"m",a).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,n,"f")}async end(){return c(this,n,!0,"f"),u(this,r,"m",s).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",s).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,n,"f")}),!u(this,n,"f")&&!(0,b.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",s).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,n,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=O,n=new WeakMap,r=new WeakSet,s=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,n,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",o).call(this,e)},o=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,D.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,C.endProcess)(e,this.endTimeoutMs)},a=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,n,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",s).call(this),!this._stopped&&!u(this,n,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,_.onError)("Can't restart "+this.name+", failure rate is too high."+M.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,n,"f")}),this._stopped||u(this,n,"f")||(0,b.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,T.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,v.toS)(e).includes("Error: Cannot find module")&&(0,_.onError)("Failed to start "+this.name+M.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,n,"f")}),(0,b.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",a).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const o=s(i(53916)),a=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),f=i(4001),h=i(95696);function m(e){return(0,f.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,a.toNativePath_)(e);const i=h.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),n=i.sibling(r);if(n.isSelfOrDescendantOf((0,l.examples)()))return o.join("$examples",n.posixPathFrom((0,l.examples)()));const s=(0,d.originalsDir)();if(n.isSelfOrDescendantOf(s))return o.join("$library",n.posixPathFrom(s));const f=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=f?o.join("$library",n.posixPathFrom(f)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){"use strict";var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const s=i(6858),o=i(1708),a=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),f=i(43334),h=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return n(this,r,"f").push(...e),this}async parse(e=o.argv,t){let i=(0,m.addHelpFooter)(new s.Command).description((0,m.cliWrap)(h.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of n(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":a.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,o.exit)(0)})),i.parse(e,t??{from:f.isMainElectron?"electron":"node"});const d=i.opts();for(const e of n(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),n=i(31586),s=i(51926),o=i(17344),a=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,n.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,o.EditionName)()+" v"+a.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},83210:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDaemon=void 0;const n=r(i(1708)),s=i(22573),o=i(38639);t.isDaemon=function(e){return(0,o.isTrue)(n.default.env.__is_daemon)||(0,o.isTrue)(e?.daemon)||!(0,s.blank)(e?.pidfile)}},94361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),n=i(40958),s=i(55835),o=i(31586),a=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,o.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,n.compactBlanks)([c("user id","PUID",(0,a.userids)()),c("group id","PGID",(0,a.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,s.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},43380:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WriteSettingsArg=void 0;const r=i(28874),n=i(2858),s=i(22573),o=i(38639),a=i(46292);t.WriteSettingsArg={beforeParse:e=>e.option("--write-settings","Write (or re-write, if they exist) system and library settings.toml files. See https://phstr.com/settings"),afterParse:async e=>{if((0,o.isTrue)(e.writeSettings)){const e=await(0,n.writeSystemSettings_)();if(null==e?console.info("--write-settings: Failed write system settings: no system configuration directory was found.",{checkedDirectories:(0,a.osConfigDirs)()}):console.info(`--write-settings: Wrote system settings to ${e}`),(0,s.blank)(r.Settings.libraryDir.valueOrDefault))console.error("--write-settings: Failed to write library settings: no PS_LIBRARY_DIR is set.");else{const e=await(0,n.writeLibrarySettings_)();console.info(`--write-settings: Wrote library settings to ${e}`)}}}}},76596:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),n=i(19851),s=i(22573),o=i(42659),a=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),f=(0,n.lazy)((()=>(0,d.mkLogger)("date.Date")));function h(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,a.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,a.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=h,t.nowish=function(e,t=2500){return null!=e&&((0,o.isDate)(e)?h(e,new Date,t):Math.abs(e-Date.now()){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const r=i(77988),n=i(19851),s=i(55835),o=i(31586),a=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,n.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),f=["year","month","day","hour","minute","second","millisecond"];class h{static fromISO(e,t){const i=d().exec((0,a.toS)(e).trim()),r=i?.groups;return null==r?void 0:h.for((0,c.parseExifDateTime)(r.start,t),(0,c.parseExifDateTime)(r.end,t),(0,o.toInt)(r.index),(0,o.toInt)(r.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,s.map)(e.start,(e=>r.ExifDateTime.fromJSON(e))),(0,s.map)(e.end,(e=>r.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,r=1){if(null==e||!e.isValid||null==t||!t.isValid)return;r=(0,o.clamp)(1,1e3,(0,o.toInt)(r,{defaultValue:1})),i=(0,o.clamp)(0,r-1,(0,o.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const n=e.toMillis(),s=(t.toMillis()-n)/(r+1)*(i+1),a=e.plus({milliseconds:s});return null==a?void 0:new h(e,a,t,i,r)}constructor(e,t,i,r=0,n=1){this.start=e,this.middle=t,this.end=i,this.index=r,this.splits=n,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=f.map((r=>function({start:e,end:t,middle:i,field:r}){return null!=e[r]&&null!=t[r]?i[r]:void 0}({start:e,middle:t,end:i,field:r})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new h(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=h},79842:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const r=i(77988),n=i(51168),s=i(19851),o=i(76790),a=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),f=i(51926),h=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),v=i(21330),w=i(928),S=i(54261),b=i(73389),P=i(51275),M=(0,s.lazy)((()=>(0,h.mkLogger)("date.Dated")));function _(e){return null!=e&&(e instanceof v.FuzzyDate||e instanceof r.ExifDate||e instanceof r.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,b.isDateTime)(e)||(0,m.isDateObject)(e))}function E(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof r.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function T(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof r.ExifDate?e.toMillis(l.dayMs):e instanceof v.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),D(e),((e,t)=>e+t))}function x(e){try{if(null==e||(0,f.isString)(e)||(0,c.isNumber)(e))return;return(0,b.isDateTime)(e)?e:e instanceof r.ExifDateTime||e instanceof v.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?n.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void M().warn("datedToDateTime() failed",{d:e,error:t})}}function D(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,S.hasTime)(e)){if((0,c.gt0)((0,w.getMillisecond)(e)))return 0;if((0,c.gt0)((0,w.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,w.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,w.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,w.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,w.getMonth)(e))?l.monthMs-1:l.yearMs-1}function k(e,t){const i=E(e),r=T(e);if(null!=i&&null!=r)return(0,c.gt0)(t)&&t>r-i?{start:Math.round((i+r)/2-t/2),end:Math.round((i+r)/2+t/2)}:{start:i,end:r}}function C(e,t,i,r){const[n,s]=(0,o.sortBy)([k(e,i),k(t,r)],(e=>e?.start));return null!=n&&null!=s&&null!=n&&null!=s&&(n.start===s.start||n.end>=Math.min(s.start,s.end))}function O(e,t){return(0,a.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??v.FuzzyDate.fromISO(e)}t.isDated=_,t.toDated=function(e){return _(e)?e:void 0},t.mapDated=function(e,t){return _(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=E,t.datedToEndTs=T,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof r.ExifDate?n.DateTime.fromObject(e):x(e)},t.datedToDateTime=x,t.datedToPrecisionMs=D,t.isoToPrecisionMs=function(e){return(0,u.map)(O(e),D)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:r}){if(null==e||null==t)return!1;if(i??(i=D(e)),r??(r=D(t)),C(e,t,i,r))return!0;const n=(0,P.getZoneName)(e),s=(0,P.getZoneName)(t);return null==n&&null!=s&&(e=(0,v.setZone)(e,s)??e),null==s&&null!=n&&(t=(0,v.setZone)(t,n)??t),C(e,t,i,r)},t.isoToDated=O,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof n.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const r=i(31586),n=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,n.isString)(e))return(0,r.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),n=i(31586),s=i(54557),o=i(91655),a=new s.FifoCache(512);function l(e){return(0,n.isNumber)(e)?e:(0,r.blank)(e)?void 0:a.getOrSet(e,(()=>(0,o.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,o.fmtFullDuration)((0,n.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),n=i(40958),s=i(22573),o=i(42659),a=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,a.isNumber)(e))return;if((0,a.isNumber)(e))return e;if((0,a.isDigits)(e))return(0,a.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const f=(0,n.compact)(d.map((e=>function(e,t){const i=(0,a.toFloat)(e);if(null!=i){if((0,s.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*o.yearMs;case"weeks":case"week":case"w":return i*o.weekMs;case"days":case"day":case"d":return i*o.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*o.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*o.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*o.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),h=(0,a.lt0)(f[0])?[f[0],...f.slice(1).map((e=>-e))]:f;return(0,c.sum)(h)}catch{return}};const d=[{ms:o.yearMs,s:"y"},{ms:o.weekMs,s:"w"},{ms:o.dayMs,s:"d"},{ms:o.hourMs,s:"h"},{ms:o.minuteMs,s:"m"},{ms:o.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,a.isNumber)(t))return;if(0===t)return"0";if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},98247:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const r=i(77988),n=i(51168),s=i(19851),o=i(22573),a=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),f=i(68852),h=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function v(e,t,i){const r=t.exec(e);if(null==r||(0,u.isEmptyObj)(r.groups))return;const{year:n,month:s,day:o,hour:c,minute:f,second:p}=(0,d.mapEntries)(r.groups,((e,t)=>(0,l.toInt)(t)));if(null==n||null==s||null==o)return;if(!h.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==f))return;const g=(0,a.map)((0,l.toFloat)(r.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),v=(0,y.timezoneOffsetFromRegExpMatch)(r);return b({year:n,month:s,day:o,hour:c??0,minute:f??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(v)??i,rawValue:e,tzoffsetMinutes:v})}t.UnsetZone=n.Info.normalizeZone(r.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof r.ExifDate&&t instanceof r.ExifTime))return;const i=new r.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:s}){return(0,o.blank)(e)?void 0:r.ExifDateTime.fromDateTime(n.DateTime.fromFormat(e,i,{zone:s??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,o.blank)(e)?void 0:r.ExifDateTime.fromDateTime(n.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,o.blank)(e)?void 0:r.ExifDateTime.from(e,t)??v(e,S(),t)},t.parseExifDateTimeRe=v;const w=/[-:_\s]?/,S=(0,s.lazy)((()=>(0,f.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,w,p.monthRE,w,p.dayRE,/[T\s]/,p.hourRE,w,p.minuteRE,w,p.secondRE,p.subsecRE,/\s?/,f.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function b(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof r.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=r.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,a.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=b},74417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const r=i(51168),n=i(22573),s=i(42659),o=i(49769),a=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),f=i(66649),h=i(98725),m=i(88600);t.recent=function(e,t=5*s.secondMs){return(0,c.isRecentMs)((0,f.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=r.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,n.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,n.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=r.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,o.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,f.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,a.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*s.secondMs):void 0)??(0,h.parseDateTime)(t)?.toMillis()}},21330:function(e,t,i){"use strict";var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const s=i(77988),o=i(51168),a=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),f=i(31586),h=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),v=i(79842),w=i(66649),S=i(98247),b=i(98725),P=i(928),M=i(54261),_=i(73389),E=i(89724),T=i(17415),x=i(88600),D=i(51275);function k(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class C{constructor(e,t,i){this.year=e,this.month=t,this.day=i,r.set(this,(0,p.lazy)((()=>(0,x.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(b.ISO_YMD_RE.exec(e)?.groups??b.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,f.toGt0)(e?.year);if(null==e||null==t||tk(e))).join("-")}toLocal(){return(0,E.datedToLocal)(this)}toDateTime(){return o.DateTime.fromObject((0,h.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,h.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,h.pick)(e.plus({month:1}),"year","month"):(0,h.pick)(e.plus({year:1}),"year");return new C(t.year,t.month,t.day)}}function O(e,t){if(e instanceof s.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,M.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,T.zoneToTzOffsetMinutes)((0,w.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(r=>(0,d.map)((0,P.getMonth)(e),(n=>(0,d.map)((0,P.getDay)(e),(s=>(0,d.map)((0,P.getHour)(e),(o=>(0,S.dateObjectToExifDateTime)({year:r,month:n,day:s,hour:o,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=C,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",r=15*(0,f.round)(e/15),n=Math.abs(r),s=Math.floor(n/60),o=Math.floor(Math.abs(n%60));return`${t?"UTC":""}${i}${k(s)}:${k(o)}`},t.toExifDateTime=O,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof s.ExifDateTime?e.tzoffsetMinutes:(0,_.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,M.hasTime)(e)||(i??(0,v.datedToPrecisionMs)(e))>=c.dayMs?L(e):O(e,(0,D.getZoneName)(e))?.toISOString({includeOffset:t})};const I="yyyy:MM:dd HH:mm:ss.SSS",F=I+"ZZ";function L(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>k(e))).join(t)}function A(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new C(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,r]=[e,t].map(w.datedToMillis);return null==i||null==r?void 0:i-r}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,f.isNumber)(t)?o.DateTime.fromMillis(t):(0,v.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,D.hasZone)(t)?F:I):void 0},t.datedToYMD=L,t.toFuzzyDate=A,t.sameDay=function(e,t){return(0,f.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,f.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,r=1){if(null==(0,w.datedToMillis)(e)||null==(0,w.datedToMillis)(t))return;const[n,s]=[e,t].map((e=>(0,w.datedToMillis)(e))).sort(),a=(s-n)/(r+1),l=(0,D.getZoneName)(e),u=l===(0,D.getZoneName)(t)?l:void 0,c=o.DateTime.fromMillis(n+a*i,{zone:u});return[e,t].some((e=>!(0,M.hasTime)(e)))?A(c):c},t.setZone=function(e,t,i){const r={...(0,h.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,D.hasZone)(e)},n=(0,T.normalizeZone)(t);if(null!=e&&null!=n&&(0,M.hasTime)(e))return e instanceof y.DateInterval?e.setZone(n,r):O(e)?.setZone(n,r)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,f.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,v.datedToDateTime)(e);if(null==i)return;const r=(0,D.getZoneName)(e);return null!=r&&"UTC"!==r||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){"use strict";var r,n,s,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const a=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),f=i(49769),h=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),v=i(68852),w=i(4001),S=i(28874),b=i(24689),P=i(79842),M=i(66649),_=i(98247),E=i(21330),T=i(54261),x=i(73389),D=i(16400),k=i(88600),C=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return C().tap({msg:"extractDateFromPath",result:L.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return L.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return L.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,h.mapNumeric)((0,M.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,v.concatRegexp)([/^/,t.yearRE,v.RegExpOptional.from(/-/,t.monthRE,v.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,v.concatRegexp)([/^/,t.yearishRE,v.RegExpOptional.from(/-/,t.monthishRE,v.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=F({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,x.isDateTime)(i)?i:(0,T.isExifDateTime)(i)?i.toDateTime():void 0};const O=new Map;function I(e,t,i){try{const r=(0,_.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=r)return r;const n=(0,f.getOrSet)(O,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void C().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,_.parseExifDateTimeFormat)({input:n?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void C().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function F({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:r=!0,descPredicate:n=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const s=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(w.stripDSC));if(0!==s.length)for(const{desc:e,f:o}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>b.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,_.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:_.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(S.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(S.Settings.extraDateTimeFormats.values)){const r=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${r})`,f:i=>I(i,r,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>a.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of L.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:r}))if(n(e))for(const e of s){const t=o(e);if(null!=t&&(0,k.isValidDate)(t))return t}}t.parseDated=F;class L{constructor(e={}){r.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&S.Settings.fuzzyDateParsing.watchLater((()=>o(this,r,"m",s).call(this))),null==e.fuzzyYearParsing&&S.Settings.fuzzyYearParsing.watchLater((()=>o(this,r,"m",s).call(this))),o(this,r,"m",s).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??S.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??S.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!S.Settings.usePathsToInferDates.valueOrDefault)return;E.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=F({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=L,r=new WeakSet,n=function(e){const t=new A(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},s=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new v.RegExpEscaped("(?"+(0,D.monthNames)().map(v.escapeRegExp).join("|")+")");o(this,r,"m",n).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),o(this,r,"m",n).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),o(this,r,"m",n).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),o(this,r,"m",n).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),o(this,r,"m",n).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),o(this,r,"m",n).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),o(this,r,"m",n).call(this,[t.yearRE,t.seps,t.monthishRE]),o(this,r,"m",n).call(this,[e,t.seps,t.yearRE]),o(this,r,"m",n).call(this,[t.yearRE,t.seps,e]),o(this,r,"m",n).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},L.instance=(0,u.lazy)((()=>new L));class A{constructor(e){this.regex=e instanceof RegExp?e:(0,v.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return E.FuzzyDate.for({year:(0,h.toInt)(t.year),month:(0,h.toInt)(t.month)??(0,D.monthName2index)(t.monthname),day:(0,h.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const r=i(55835),n=i(31586),s=i(54261);function o(e){return e instanceof Date?e.getMinutes():e?.minute}function a(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=o,t.getSecond=a,t.getMillisecond=l,t.getCentisecond=function(e){return(0,r.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,s.hasTime)(e)&&((0,n.gt0)(o(e))||(0,n.gt0)(a(e))||(0,n.gt0)(l(e)))},t.getSecMs=function(e){return(0,r.map)(a(e),(t=>{const i=l(e)??0;let r=(t+i/1e3).toString();for(t<10&&(r="0"+r),0===i&&(r+=".");r.length<6;)r+="0";return r}))}},54261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const r=i(77988),n=i(31586),s=i(68708);t.hasTime=function(e){if(!(0,s.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,n.gt0)(t.hour)||(0,n.gt0)(t.minute)||(0,n.gt0)(t.second)||(0,n.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof r.ExifDateTime}},73389:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const r=i(51168);t.isDateTime=function(e){return r.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const r=i(51168),n=i(19851),s=i(42659),o=i(55835),a=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),f=i(74417),h=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,n.lazy)((()=>v(l.Settings.datesBeforeAreEstimated.valueOrDefault)??v(l.Settings.datesBeforeAreEstimated.defaultValue)));function v(e){return(0,o.map)((0,c.isoToDated)(e),w)}function w(e){return(0,a.isNumber)(e)?_(e):100*S(e)+((0,m.getCentisecond)(e)??0)}function S(e){if((0,a.isNumber)(e))return Math.floor(_(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function b(e,t){if(null==e||e<0)return;let i=e;const r=()=>{const e=i%100;return i=Math.floor(i/100),e},n=10*r(),s=r(),o=r(),l=(0,a.toGt0)(r()),u=(0,a.toGt0)(r()),c=(0,a.toGt0)(r());return{year:i,month:c,day:u,hour:l,minute:o,second:s,millisecond:n,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=b(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):h.FuzzyDate.for(i)}function M(e,t){return _(Date.now()-e,t)}function _(e,t){return w(r.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const r=i(19851),n=i(76790),s=i(31586),o=i(9092),a=(0,r.lazy)((()=>{const e=new o.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const r=new Intl.DateTimeFormat(t,{month:i});(0,s.times)(12,(n=>{const s=r.format(new Date(2017,n));e.set(s,n+1),"short"===i&&"en-US"===t&&e.set(s+".",n+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:a().get(e)},t.monthNames=function(){return(0,n.sort)([...a().keys()])}},42499:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLuxon=void 0;const r=i(51168),n=i(19851),s=i(19043),o=i(28874);t.setupLuxon=(0,n.lazy)((async()=>{r.Settings.throwOnInvalid=!1,o.Settings.twoDigitCutoffYear.watch((e=>r.Settings.twoDigitCutoffYear=e)),r.Settings.defaultLocale=await(0,s.locale)()}))},17415:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const r=i(77988),n=i(51168),s=i(19851),o=i(22573),a=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),f=i(54993),h=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,s.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const r=(0,h.leastBy)(g(),(t=>Math.abs(t-e)));return null!=r&&Math.abs(r-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(r)}t.isUTCZone=function(e){return S(e)||0===b(e)?.offset(Date.now())},t.normalizeZone=b,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,a.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=M,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:M(i)};const _=/\b(?Z|UTC|GMT)\b/,E=/(?[-±+−])/,T=/[-−]/,x=/(?[01]\d)/,D=/(?[01]?\d)/,k=/(?::(?\d\d))/;function C(e){return S(e)?0:O((0,t.TimezoneOffsetRE)().exec(e))}function O(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,o.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=T.test((0,f.toS)(e.groups.tzSign))?-1:1,r=(0,l.toInt)(e.groups.tzMinutes)??0,n=null==t?void 0:i*(60*t+r);return v(n)?n:void 0}t.TimezoneOffsetRE=(0,s.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),_,new m.RegExpEscaped("|"),E,x,m.RegExpOptional.from(k),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=C,t.timezoneOffsetFromRegExpMatch=O;const I=/\b(?(?:Etc\/)?GMT)\b/,F=(0,s.lazy)((()=>(0,m.concatRegexp)([I,E,D,m.RegExpOptional.from(k)])));function L(e){return O(F().exec(e))}t.ianaZoneToOffsetMinutes=L,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,o.blank)(e))return;const i=L(e)??C(e);if(null!=i)return M(i);if(null!=t){const i=b(e);if(null!=i)return M(i.offset(t))}}},88600:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const r=i(51168),n=i(19851),s=i(40958),o=i(22573),a=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),f=i(28874),h=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),v=(0,n.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),w=(0,n.lazy)((()=>(0,s.compact)(f.Settings.badDates.values.map((e=>(0,h.isoToDated)(e)))))),S=(0,n.lazy)((()=>(0,s.compact)(w().map((e=>(0,p.datedToISO)(e)))))),b=(0,n.lazy)((()=>(0,s.compact)(w().map((e=>(0,y.datedToLocal)(e)))))),P=(0,n.lazy)((()=>(0,s.compact)(w().map((e=>(0,m.datedToMillis)(e))))));function M(e){if(null==e)return!1;const t=E(e);return v().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return M(e)?e:void 0},t.isValidDate=M;const _=String(new Date("bad"));function E(e){try{if(!(0,h.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===_)return _;const t=(0,s.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const n=[];if((0,l.isNumber)(e)||n.push("year is not a number"),(0,l.lt)(e,f.Settings.minValidYear.valueOrDefault)&&n.push("year is less than "+f.Settings.minValidYear.key),(0,u.gt)(e,T())&&n.push("year is in the future"),null==t&&null!=i&&n.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&n.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&n.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const s=r.DateTime.fromObject({year:e,month:t,day:i});s.isValid||n.push(s.invalidExplanation??"not valid")}return(0,s.compact)(n)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=f.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const r=(0,m.datedToMillis)(e);(0,u.gt)(r,Date.now()+i)&&t.push("date is too far in the future: see "+f.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):b().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):S().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,o.toNotBlank)((0,s.uniq)((0,s.compactBlanks)(t)).join("; "))}catch(t){return v().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=E;const T=(0,n.lazy)((()=>r.DateTime.now().plus({milliseconds:f.Settings.maxValidFutureMs.valueOrDefault}).year),a.dayMs);t.mapValidDate=function(e,t){return M(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==E({year:e,month:t,day:i})}},51275:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const r=i(77988),n=i(31586),s=i(24689),o=i(73389);t.hasZone=function(e){return null!=e&&!(0,n.isNumber)(e)&&(e instanceof s.DateInterval||e instanceof r.ExifDateTime?e.hasZone:!!(0,o.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==r.UnsetZoneName&&e.zone.offset(Date.now())!==r.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,o.isDateTime)(e)?e.zoneName===r.UnsetZoneName?void 0:e.zone?.name:e instanceof r.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},15056:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),n=i(7311);function s(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=s,t.pathToDb=function(e,t){return s(e,t).join(n.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const o=s(i(76760)),a=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),f=i(97352),h=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),v=i(70698),w=i(64680),S=i(29882),b=i(45969),P=i(43334),M=i(28874),_=i(41692),E=i(32774),T=i(80612),x=i(32551),D=(0,d.lazy)((()=>(0,f.mapGte0)((0,h.userid)(),(e=>"-"+e))??""));function k(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+D(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,o.join)(i,".photostructure-cache"+D()),preexistingDir:i});return e}}function C(){if((0,b.isDocker)())return(0,a.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,o.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:E.DefaultDockerLibraryDir+"/.photostructure/cache"+D(),preexistingDir:E.DefaultDockerLibraryDir},...k()]);const e=(0,a.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),o.default.resolve((0,x.homeDir)(),"AppData","Local")]:P.isMac?[o.default.resolve((0,x.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,o.join)((0,x.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,o.join)(e,t),preexistingDir:e})));return i.push(...k()),i}t.tmpCacheDirs=k,t.tmpDirs=function(){return(0,T.filterDirs)({dirs:k(),desc:"tmp"})},t.cacheDirs=C,t.defaultCacheDir=(0,d.lazy)((()=>(0,T.firstDir)({dirs:C(),desc:"cache"})));const O=(0,d.lazy)((()=>{(0,_.setSettingsDefaults)(),M.Settings.cacheDir.watchLater(I)}));function I(){M.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{O();const e=M.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=I},46292:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),n=i(45969),s=i(41692),o=i(32774),a=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,n.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,a.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:o.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:o.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,n.isDocker)()?c:(0,a.desktopConfigDirs)()).map((e=>e.dir))}},79960:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultApplePhotosLibrary=void 0;const r=i(19851),n=i(22573),s=i(50213),o=i(45255),a=i(84777),l=i(16287),u=i(57902),c=i(43334),d=(0,r.lazy)((()=>(0,s.mkLogger)("dir.DefaultApplePhotosLibrary"))),f=["read","com.apple.photolibraryd","SystemLibraryPath"];t.defaultApplePhotosLibrary=async function(){if(c.isMac)try{const e=await(0,a.stdout_)("defaults",f,{timeoutMs:o.ShortCommandTimeoutMs});if((0,n.blank)(e))return void d().warn(`"defaults ${f.join(" ")}" returned blank (!!)`);{const t=await(0,l.isReadableDirectory)(e);return d().tap({msg:"defaultApplePhotosLibrary()",level:u.LogLevels.info,result:t?e:void 0,meta:{isReadable:t}})}}catch(e){return void d().warn("defaultApplePhotosLibrary()",e)}}},32774:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),n=i(45969),s=i(32774);t.defaultLibraryDir=function(){return(0,n.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,n.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const n=r(i(76760)),s=i(40958),o=i(72993),a=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function f(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),n.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(n.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,a.env)().XDG_DATA_HOME,(0,a.env)().XDG_CONFIG_HOME,n.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:n.default.join(e,(0,o.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:f(),desc:"config"})},t.desktopConfigDirs=f},84373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),n=i(96706),s=i(29882);t.envConfigDir=function(){const e=(0,n.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),n=i(40958),s=i(22573),o=i(66430);function a({dirs:e,desc:t}){for(const{dir:i,preexistingDir:a}of(0,n.compact)(e))if(!(0,s.blank)(i)){if((0,o.isReadWriteableDirectorySync)(i))return i;if((0,s.blank)(a)||(0,o.isReadWriteableDirectorySync)(a))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=a,t.filterDirs=function({dirs:e,desc:t}){return(0,n.compact)(e.map((e=>a({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),n=i(76760),s=i(1708),o=i(19851),a=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,o.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,a.compactBlanks)(e)){const e=(0,n.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),n=i(49776),s=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[s.libraryDataDir,s.libraryPreviewsDir,n.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},9595:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),n=i(54993),s=i(29882),o=i(28874);function a(e){return(0,r.toNotBlank)((0,n.toS)(e))??o.Settings.libraryDir.valueOrDefault}t.libraryDir=a,t.originalsDir=function(e){return(0,s.resolveMaybe)(a(e),o.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,s.resolveMaybe)(a(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,s.resolveMaybe)(a(e),o.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),n=i(55835),s=i(37805),o=i(15056),a=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),f=i(28874),h=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${s.version}\n`;function p(e){return u.PosixFile.forMaybe((0,h.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,h.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function v(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+a.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function w(e){return u.PosixFile.forMaybe((0,h.originalsDir)(e))}async function S(e){return y(w(e),!1)}function b(e){return u.PosixFile.forMaybe((0,h.libraryPreviewsDir)(e))}async function P(e){return y(b(e))}function M(e){return p(e)?.join(f.Settings.syncReportsDir.valueOrDefault)}async function _(e){return y(M(e))}async function E(e){return y((0,n.map)(g(e),(e=>(0,o.pathToDbDir)(e,o.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await v(t);return(0,r.uniq)([t,i,await S(t),await P(t),await _(t),await E(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=v,t.libraryOriginalsDirPosixFile=w,t.setupLibraryOriginalsDir_=S,t.libraryPreviewsDirPosixFile=b,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=M,t.setupLibrarySyncReportsDir_=_,t.setupLibraryDbDir_=E},46296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const n=r(i(76760)),s=i(19851),o=i(40958),a=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),f=i(45969),h=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),v=i(80612),w=i(32551);function S(){return(0,f.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:h.isMac?[{dir:n.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,o.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>n.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,a.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,a.notBlank)(i)?i:b()}catch(e){return console.error("defaultLogDir_() failed",e),n.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(44198),a=i(43334),l=i(24399),u=i(32551);async function c(){return a.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,n.lazy)((async()=>{if(a.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,n.lazy)((()=>(0,o.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),n=i(7282),s=i(29325),o=i(44198);t.getDevEnvFlag=function(e){return!(0,n.isProd)()&&!(0,s.isPacked)()&&((0,r.toBoolean)((0,o.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,o.env)()[e]=String(t)}},34580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),n=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,n.env)().DO_NOT_TRACK)}},44198:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const n=r(i(73024)),s=i(76760),o=r(i(1708)),a=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),f=i(7282),h=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),v=i(6012),w=i(96706);t.env=(0,a.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>o.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,g.isDocker)()||(0,f.isTest)()&&"lite"===o.default.env.PS_LICENSE||e.push((0,s.join)((0,h.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),i={...o.default.env};for(const r of e)try{const e=(0,d.debom)(n.default.readFileSync((0,p.resolve)(r))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(s))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),n=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let s;for(const o of(0,n.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(o));){if(null==s.groups)continue;const{key:e,val:n}=s.groups;if((0,r.blank)(e)||null==n)continue;const o=n.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=o}}return i}},96706:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const n=r(i(1708)),s=i(19851),o=i(22573),a=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),f=i(34102),h=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,o.firstNotBlank)(n.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,n.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,h.env)()))),t.onEnvChange=p,(0,l.later)((()=>{h.env.watchLater(p),(0,f.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,a.isTrue)(g(e))}},98314:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),n=i(19851),s=i(40958),o=i(22573),a=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),f=i(89788),h=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),v=i(70025),w=i(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(a.errorName),...e.map(a.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(a.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(i)))}function b(e){return(0,s.compact)(e).filter((e=>!a.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(o.notBlank)}function P(e,t){const i=(0,s.uniqSubstrings)(b(e)),r=t?.maxLen??400,n=t?.trailingChars??64,o=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(i.join(a.ErrorDelimiter)),r-o.length,n)+o.sort().join("")}function M(e,t){return e instanceof w.WrappedError?e.toString():(0,o.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,n.lazy)((()=>(0,h.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new f.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(M(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,o.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,o.notBlank)(i))return i}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=M,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,o.blank)(e)&&(e=t.MissingError),M(e,{maxLen:i})+" at "+(0,a.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),n=i(26905),s=i(55835),o=i(54993),a=i(81168);t.describeError=function(e){const t=(0,a.stripSuffix)((0,o.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,s.map)((0,n.errorErrno)(i),(e=>t.push(u.get(e)))),(0,s.map)((0,n.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),n=i(76790),s=i(50989),o=i(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,n.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(o.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},68301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorStore=t.ExtraEventsForPlease=void 0;const r=i(19851),n=i(42659),s=i(75240),o=i(55835),a=i(31586),l=i(68708),u=i(59455),c=i(54993),d=i(50213),f=i(45255),h=i(37628),m=i(99331),p=i(46292),g=i(38835),y=i(32144),v=i(29882),w=i(95696),S=i(55222),b=i(28874),P=(0,r.lazy)((()=>(0,d.mkLogger)("error.EventStore")));function M(e){return(0,l.omit)(e,"breadcrumbs")}t.ExtraEventsForPlease=7;class _{constructor(e){this.root=e}datedRoot(e=new Date){return this.root.join((0,c.toS)(e.getFullYear()),(0,c.toS)(e.getMonth()+1))}rmrf(){return this.root.rmrf()}msg2file(e){return this.datedRoot(new Date(e.timestamp*n.secondMs)).join((0,h.shortStringSha)(e.message,8,S.GeoRadix)+".json")}async eventsFrom(e=new Date,t=n.dayMs){const i=e.getTime(),r=i-t,o=i+t;return P().tap({msg:"eventsFrom()",result:(0,u.toA)(await this.datedRoot(e).clear().childFiles((async e=>P().tap({msg:"eventsFrom().childFiles() accept "+e.base,result:(0,y.isJsonExt)(e)&&!(0,v.isHiddenBasename)(e.base)&&(0,a.within)(r,o,e.mtimeMs())})))),meta:{when:e,deltaMs:(0,s.fmtDuration)(t)}})}async eventCount(e=new Date){return(await this.eventsFrom(e)).length}async eventQuotaExceeded(e){const i=(0,c.toS)(e).includes(g.PleaseSendErrorFlag)||(0,c.toS)(e.message).includes(g.PleaseSendErrorFlag),r=await this.eventCount(),n=b.Settings.maxErrorsPerDay.valueOrDefault+(i?t.ExtraEventsForPlease:0);return P().tap({msg:"eventQuotaExceeded()",result:r>=n,meta:{event:M(e),recentEventCount:r,maxErrorsPerDay:n,pleaseSend:i}})}async maybeSendEvent(e){if(e.timestamp=Math.floor(e.timestamp),(0,m.ending)())P().error("maybeSendEvent(): REJECT: we're ending.",{event:M(e)});else if(await this.eventQuotaExceeded(e))P().error("maybeSendEvent(): REJECT: too many recent events.",{event:M(e)});else try{const t=await this.writeEvent_(e);return P().tap({msg:"maybeSendEvent(): "+t==null?"REJECT: previously sent this event already this month":"ACCEPT",result:null!=t?e:void 0,meta:{eventFile:t}})}catch(e){return void P().error("maybeSendEvent(): REJECT: failed to write event.",e)}}writeEvent_(e){return this.msg2file(e).applyIfEmpty_({fn_:t=>t.writeJson_(e),minSizeBytes:3,returnUndefinedIfNotEmpty:!0,timeoutMs:f.ShortCommandTimeoutMs})}}t.ErrorStore=_,_.instance=(0,r.lazy)((()=>(0,o.map)((0,p.configDir)(),(e=>new _(w.PosixFile.for(e).join("events"))))))},70025:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),n=i(38639),s=i(26905),o=i(54993),a=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function f(e){return(0,o.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function h(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,o.toS)(e)+(0,r.compact)(t).join("");return f(i)+h(i).join("")},t.stripErrorFlags=f,t.extractErrorFlags=h,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,a.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,n.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,n.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,n.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},8769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),n=i(31586),s=i(68708),o=i(7282),a=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),f=i(38835),h=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,h.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const n=!0===i.fatal,c=!0===i.ignorable;if(!n&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),n&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const f=!n||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===f?"error":"warn","onError()",{event:f,error:i}),!n||(0,o.isTest)()||(0,a.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),n}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,n.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,a.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,n.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,n.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+f.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),n=i(22573),s=i(38639),o=i(26905),a=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),f=i(81168),h=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,n.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,n.firstNotBlank)((0,f.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,o.errorName)(t)??(0,d.first)(this.causes,o.errorName)??"Error",this.codes=(0,f.splitUniq)([t.code,...this.causes.map(o.errorCode)],o.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,o.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,h.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,n.blank)(r)||(i=(0,f.dedupeNeedle)(i,r,"file")),(0,h.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,a.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,f.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const o=i(49769),a=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),n.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,o.getOrSet)(s(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),o=s(this,r,"f").get(e);return null!=o&&(o.resolve(t),s(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,n=new WeakMap},34102:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),n=i(19851),s=i(15197);t.ee=(0,n.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const n=r(i(73024)),s=r(i(1708)),o=i(19851),a=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,o.lazy)((()=>s.default.geteuid?.())),f=(0,o.lazy)((()=>s.default.getgroups?.()));function h(e,t){try{return!(0,a.blank)(e)&&(n.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?h(t,n.default.constants.R_OK|n.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?h(t,n.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:n,processGid:s}){if(null==e)return!1;const o=n??d(),a=null!=s?[s]:f()??[],l=0===o,u=l||e.uid===o,h=l||a.includes(e.gid);return!(t&&!(((u?256:0)|(h?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(h?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(h?8:0)|1)&e.mode))}t.canAccessSync=h,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const n=r(i(76760)),s=i(19851),o=i(81168),a=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),f=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,f.resolve)(...e)}};const h=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,f.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:h().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,f.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,o.equalsIgnoreCase)(e.basename,i.base))return n.default.join(r,e.basename);throw new a.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),n=i(76760);function s(e){return[...o(e)]}function*o(e){for(;e!==(0,n.dirname)(e);)e=(0,n.dirname)(e),yield e}function a(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=a(e);return t.every((e=>i.includes(e)))}t.ancestors=s,t.ancestorG=o,t.selfAndAncestorG=function*(e){yield e,yield*o(e)},t.childrenSync=a,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},f=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=h(i(76760)),v=h(i(1708)),w=i(46466),S=h(i(57975)),b=h(i(38522)),P=i(19851),M=i(40958),_=i(5233),E=i(22573),T=i(42659),x=i(50357),D=i(96249),k=i(98553),C=i(55835),O=i(31586),I=i(68708),F=i(97790),L=i(39926),A=i(51926),R=i(59455),N=i(54993),j=i(48884),B=i(22911),z=i(99331),V=i(56519),W=i(56038),U=i(31562),H=i(76850),q=i(70025),G=i(34102),$=i(80875),J=i(50213),K=i(70417),Z=i(43334),Y=i(81168),X=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),ne=i(89968),se=i(20197),oe=i(88561),ae=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),fe=i(65238),he=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),ve=i(27794),we=i(73428),Se=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new oe.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),n.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),o.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(n=new WeakMap,o=new WeakMap,r=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,M.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,j.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,E.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=be().get(i);if(null!=r)return r;const n=(0,he.resolve)(i),s=new Pe(n,t);return be().set(i,s),be().set(n,s),s}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,n,"f").unset(),f(this,o,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,he.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Y.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,C.map)(this.statSync(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,n,"f").call(this);if(null==t||null==e||(0,M.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",s).call(this)??await d(e=this.clearThisAndParent(),r,"m",s).call(e)}async children_(e){const t=await(0,fe.readdir_)(this.nativePath);return null!=e&&await(0,M.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,M.isNotEmpty)(e)?(0,M.includesAll)(t,e):(0,M.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,M.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,R.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,O.gt0)(t))return;const i=await d(this,n,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Z.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,M.isEmpty)(e)||(0,x.eql)(["."],e)||e.every(E.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,C.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,L.pad2)(t+1),(0,L.pad2)(i))))}child(...e){if((0,M.isEmpty)(e))return this;const t=(0,D.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&f(this,o,void 0,"f"),f(this,o,d(this,o,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&f(this,o,void 0,"f"),f(this,o,d(this,o,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,T.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),j.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Z.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,M.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,T.unixtime)(t)>=(0,T.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,T.unixtime)(t)>(0,T.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,C.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,F.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*T.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,ae.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,ae.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,$.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,$.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,H.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces),(0,I.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,_.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,z.ending)()?1:3,timeoutMs:0,retryDelay:T.secondMs,errorIsRetriable:q.isRetriableError})}async gunzip(){return d(this,r,"m",a).call(this,(0,Y.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,r,"m",a).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,r,"m",a).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,M.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new B.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,A.newlineRe)(),(r=>{const n=e.exec(r);null!=n&&(t.maybeResolve(n),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,O.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new B.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),Me)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,n)=>{try{const s=await e.f(r,(0,C.denull)(n));t(s)&&i.resolve(s)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,O.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,s=async function(){const e=(await(0,fe.readdir_)(this.dir)).filter((e=>(0,Y.equalsIgnoreCase)(e.basename,this.base))),t=(0,j.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,C.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},a=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*T.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let Me=!0;t.useFsWatch=function(e){Me=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},19748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const r=i(28874),n=i(88840),s=i(14036),o=i(29882);function a(e){return t=>r.Settings.respectFileExtensions.valueOrDefault?(0,s.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,o.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=a,t.isBrowserExtension=a(n.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=a(n.ExtTypes.Video),t.isAssetFileExtension=a(n.ExtTypes.AssetFile)},84542:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),n=i(96249),s=i(51926),o=i(54993),a=i(43334);function l(...e){return(0,n.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,o.toS)(e).split((0,s.newlineRe)()))))}t.Newline=a.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(o.toS).join("\n");return a.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),n=i(19851),s=i(50213),o=i(37805),a=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const f=(0,n.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function h(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return f().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return h((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=h,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,a.mkdirp_)(i),await(0,d.writeTextfile_)((0,a.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+o.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const n=r(i(76760)),s=r(i(1708)),o=i(19851),a=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,o.lazy)((()=>[...(0,a.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,n.default.join(e,"System32"),n.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const a=s(i(44652)),l=o(i(73024)),u=i(76760),c=i(57975),d=i(19851),f=i(59455),h=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),v=i(14427),w=i(17217),S=i(16287),b=i(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const M=(0,d.lazy)((()=>(0,h.mkLogger)("fs.DirectoryEntry")));class _{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new _(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},n=await a.stat(t);return new _(i,new P(r,n))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return _.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new _(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void M().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>_.fromSimpleDirent(this.nativePath,e)))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new _(this.nativePath,new P(e.name,e))))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,f.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,f.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await a.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await a.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=_},20197:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const n=r(i(76760)),s=i(39926),o=i(29882),a=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,o.parseNativePath)(i.nativePath);if(await(0,o.mkdirp_)(r.dir),!i.requireNumber&&await(0,a.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=n.default.join(r.dir,`${r.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,a.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,o.parseNativePath)(i.nativePath);if((0,o.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=n.default.join(r.dir,`${r.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},88561:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const o=i(40958),a=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),f=i(34102),h=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends h.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,f.ee)().on("fileChanged",(e=>s(this,r,"m",n).call(this,e))),(0,f.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,o.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,r=new WeakSet,n=async function(e){if((0,a.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),n=i(22573),s=i(45599),o=i(96249),a=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],f=(0,s.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),h=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=h.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,n.blank)(i)?void 0:f()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,o.flatten)((0,a.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),n=i(17217),s=i(16287),o=i(68284);async function a(e){return(0,r.pick)(await(0,s.stat_)((0,n.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=a,t.fileStats=async function(e){try{return await a(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,o.statSync)((0,n.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const r=i(68817),n=i(19851),s=i(22573),o=i(50213),a=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),f=i(95696),h=i(93854),m=i(16287),p=(0,n.lazy)((()=>(0,o.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,h.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,r.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const n=(0,s.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),o=(0,l.normalizeExt)(f.PosixFile.for(e))??(0,c.mimetypeExt)(n);return(0,s.blank)(n)||(0,s.blank)(o)?void 0:{ext:o,mime:n}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new a.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),f=i(38836),h=i(43624);class m extends f.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,n.set(this,[]),s.set(this,void 0),o.set(this,void 0),l(this,o,(0,h.fileStatsSync)(e),"f"),l(this,s,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",a).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,n,"f").push(e)}close(){u(this,s,"f").close()}}t.FileWatcher=m,n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=async function(e){const t=await(0,h.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,o,"f"),t)){l(this,o,t,"f");for(const t of u(this,n,"f"))t(e,this.nativePath)}}},73209:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c,d,f,h,m,p,g,y,v,w,S=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},b=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const M=i(58587),_=P(i(44652)),E=i(87997),T=i(40958),x=i(17586),D=i(42659),k=i(50357),C=i(75240),O=i(55835),I=i(31586),F=i(30976),L=i(13538),A=i(54993),R=i(7282),N=i(68852),j=i(23560),B=i(25764),z=i(38836),V=i(99331),W=i(22781),U=i(38835),H=i(55222),q=i(63870),G=i(69734),$=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)(G.PsLockExt)+"$");class K extends z.EndableWrapper{static newUid(e=process.pid){return b(this,n,Math.max(Date.now(),S(this,n,"f",s)+1),"f",s),(0,T.compactBlanks)([H.TokenRadix.encode(S(this,n,"f",s)),j.serviceName.prior(),(0,A.toS)(e)]).join("-")}static pidFromLockfile(e){return n.pidFromBasename((0,$.basename)(e))}static pidFromBasename(e){return(0,I.toInt)(J.exec((0,A.toS)(e))?.groups?.pid)}static for(e){return S(this,n,"f",a).find((t=>t.opts.file===e.file))??new n(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>S(this,r,"m",w).call(this)),e.endableRank??B.EndableRanks.postdb,(0,q.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,b(t=n,n,(i=S(t,n,"f",o),++i),"f",o)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),f.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(S(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,G.fsLockFileBasename)(n.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await S(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,G.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+S(this,l,"f")),this.staleMs=(0,I.round)(this.opts.timeoutMs/(0,F.randomFloat)(2,4)),S(n,n,"f",a).push(this)}get acquired(){return S(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await S(this,r,"m",h).call(this,e)??S(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,x.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,k.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==S(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:D.secondMs);b(this,c,setInterval((()=>S(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=S(this,c,"f")&&(clearInterval(S(this,c,"f")),b(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(S(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),b(this,u,!1,"f"),(0,O.map)(S(this,d,"f"),(e=>(0,E.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?S(this,r,"m",v).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),b(this,d,setTimeout((()=>S(this,r,"m",v).call(this)),(0,I.toGt0)(this.staleMs)??D.secondMs),"f"),S(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(S(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,L.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,n=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,f=new WeakMap,r=new WeakSet,h=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,I.gt0)(this.staleMs)&&Date.now()>S(this,f,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await S(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){b(this,f,Date.now(),"f");const e=[],t=await S(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,I.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+D.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,G.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;n.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const s=i[0]===this.lockfile.base;if(s)b(this,u,!0,"f");else if(!0!==t?.vacuum){const t=n.pidFromBasename(i[0]);if((0,I.gt0)(t)&&!(0,M.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),S(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:s,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await S(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},v=async function(){await S(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},w=function(){(0,T.filterInPlace)(S(n,n,"f",a),(e=>S(e,l,"f")!==S(this,l,"f")))},s={value:0},K.internalErrors=0,o={value:0},a={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),n=i(51926),s=i(54993),o=i(17217);function a(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,n.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,n.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,s.toS)(e)))return;const i=(0,o.basename)(e);return a(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&a((0,o.basename)(e))}},4001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),n=i(55835),s=i(31586),o=i(51926),a=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function f(e,t={aggressive:!0}){return h((0,r.toNotBlank)(e.name)??(0,a.toS)(e),t).normalize()}function h(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,s.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:h(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const n=(0,u.parsePosixPath)(i),s=f(n,{aggressive:!1});return[...t,s+n.ext].join("/").normalize()},t.stripCopySuffixFromName=f,t.copySuffixCountFromName=function(e){const t=((0,o.isString)(e)?e:e.name).toLowerCase().normalize(),i=f(t),r=(0,o.stripPrefix)(t.toLowerCase().normalize(),i);return(0,n.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,o.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,n.map)(m.exec(t),(e=>t=e[1].trim())),(0,n.map)(g.exec(t),(e=>t=e[1].trim())),t}},19254:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fileGrep_=t.GrepReader=void 0;const n=r(i(73024)),s=i(57075),o=i(46466),a=i(54993),l=i(33456),u=i(17217),c=i(58722);class d extends s.Transform{constructor(e,t="\n"){super({objectMode:!1,autoDestroy:!0}),this.pattern=e,this.sep=t}_transform(e,t,i){const r=(0,a.toS)(e).match(this.pattern);null!=r&&this.push(r[1]??r[0]+this.sep),i()}}t.GrepReader=d,t.fileGrep_=async function(e,t){const i=new c.WritableToBuffer;return await(0,o.pipeline)([n.default.createReadStream((0,u.toNativePath_)(e)),new l.LineReader,new d(t),i]),(await i.buffer).toString()}},14977:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const n=r(i(44652)),s=r(i(73024)),o=i(46466),a=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,o.pipeline)(s.default.createReadStream(e,{autoClose:!0}),a.default.createGzip(),s.default.createWriteStream(t,{autoClose:!0})),await n.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const n=r(i(77598)),s=r(i(73024)),o=i(46466),a=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),f=i(73913),h=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),v=i(16287),w=(0,a.lazy)((()=>(0,h.mkLogger)("fs.Hash"))),S=(0,a.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=S().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),S().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await M(s.default.createReadStream(i)),stats:(0,u.pick)(await(0,v.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function M(e,t=[],i="sha512"){const r=n.default.createHash(i);return await(0,o.pipeline)([e,...t,r]),r.digest().subarray(0,f.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=M,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return n.default.randomBytes(f.HashBits/8).toString("base64")}},48313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),n=i(42659),s=i(55835),o=i(31586),a=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),f=i(63870),h=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,a.stdout_)("chflags",["hidden",t],{timeoutMs:10*n.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,f.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:h.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,s.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,a.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*n.secondMs}),i=(0,o.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),n=i(54993),s=i(7282),o=i(43334),a=i(69375),l=/^\/dev(?:\/|$)/i,u=o.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=o.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=o.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,f=o.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function h(e){return null!=f?.exec((0,n.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,a.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":h(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=h,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},87128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonFileStore=void 0;const r=i(19851),n=i(55835),s=i(57159),o=i(50213);t.JsonFileStore=class{constructor(e,t,i){this.file=e,this.mkObject=t,this.onWrite=i,this.prior=(0,r.lazy)((()=>this.file.readJson("debug")))}async read_(){return await this.prior()??(0,n.map)(await this.mkObject(),(e=>this.write_(e)))}async write_(e){try{return await this.file.writeJson_(e,{spaces:2}),this.prior.set(Promise.resolve(e)),(0,o.mkLogger)("fs.JsonFileStore").info("wrote to "+this.file,e),null!=this.onWrite&&await this.onWrite(this.file,e),e}catch(e){throw new s.WrappedError("Failed to write to "+this.file,{cause:e,path:this.file.nativePath})}}}},33456:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),n=i(51926),s=i(54993);class o extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,s.toS)(e)).split((0,n.newlineRe)()),o=r.pop();this._prior=o??"";let a=!1;for(const e of r)a||(a=!this.push(e));a?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=o},64680:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const n=r(i(76760)),s=i(17217),o=i(73428);t.mkNoMedia_=function(e){return(0,o.writeTextfile_)(n.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},85772:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const o=s(i(76760)),a=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),f=i(68852),h=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),v=i(83278),w=i(70698),S=i(88561),b=i(65238),P=i(16287),M=(0,a.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),_="NoMedia",E=new RegExp("(?:^|["+(0,l.uniq)([(0,f.escapeRegExp)(o.default.sep),"/"]).join("")+"])\\.?"+_+"$","im"),T=Object.freeze(["."+_,_]),x=Object.freeze((0,u.flatten)(T.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function D(e){return null!=E.exec(e)}t.isNoMediaName=D;const k=(0,a.lazy)((()=>new S.FileCache({name:"fs.noMediaDirsCache"})));async function C(e,t){if(null==e)return null;const i=v.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return D(i.base)||await(0,w.isCachedirTagFile)(i)?k().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):C(i.parent());{const e=await k().getOrSetAsync(i.nativePath,(()=>O(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:C(i.parent())}}async function O(e){if(D(e.base))return k().set(e.parent().nativePath,e.nativePath),M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,b.readdirCached)(e.nativePath);if(null!=t)return F(e.nativePath,t);const i=new h.Abortable,r=await Promise.race([I(e.nativePath,i),(0,b.readdir)(e.nativePath).then((t=>F(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,w.isCachedirTagDirectory)(e)?M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(w.CACHEDIR_TAG).nativePath)}):null}async function I(e,t){for(const i of g.isCaseSensitiveFs?x:T){if(!0===t?.aborted)return null;const r=o.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return M().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function F(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(D(r.basename))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,o.join)(e,r.basename))});if(r.basename===w.CACHEDIR_TAG){const t=(0,o.join)(e,r.basename);if(await(0,w.isCachedirTagFile)(t))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await C(e,t)},t.whyNoMedia=C,t.whyNoMediaDir=O,t._dirHasNoMediaChild=I},29882:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const n=r(i(44652)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),f=i(51926),h=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),v=i(78133),w=i(53265),S=i(17217),b=i(16287),P=i(66430),M=i(5545);function _(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,o.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=_,t.containsHiddenPathname=function(e){return C(e).some(_)},t.isNotHiddenPosixPath=function(e){return C(e).every((e=>!_(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return T((0,v.posix2native)(e))},t.extname=function(e){return T(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const E=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function T(e){const t=E.exec(e)?.groups,i=t?.ext2??"",r=s.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function x(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,f.splitLast)(t.dir,s.default.sep)}function D(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),i=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,s.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function k(e,t,i){if(null==t||null==i)return!1;const r=e(t),n=e(i);return null!=r&&null!=n&&(y.isLinux?r===n:(0,p.equalsIgnoreCase)(r,n))}function C(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function O(e){return(0,u.notBlank)(e)&&C(e).length===(y.isWin?1:0)}function I({p:e,maxLength:t}){const i=(0,S.toNativePath_)(e);if(i.length<=t)return i;const r=C(e),n=[],s=[r.pop()];for(;r.length>0;)if(n.length=t){r.unshift(n.pop());break}}else if(s.unshift(r.pop()),L([...n,...s]).length>=t){r.push(s.shift());break}return r.length>0&&n.push("…"),L([...n,...s])}function F(e){return e.startsWith("\\\\")}function L(e){return(0,f.ensurePrefix)((0,a.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=T,t.parentBasename=x,t.grandParentBasename=function(e){return x(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=D,t.eqlBasename=function(e,t){return k(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return k(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return k(S.toNativePath_,e,t)},t.toPathnames=C,t.pathIsRoot=O,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:C(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,S.toNativePath_)(e),r=(0,S.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,v.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=I,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const n=[];for(const r of e.slice(0,i))n.push(I({p:r,maxLength:t}));return n.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return C(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return C(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=T(e);return`${i.base}${t}${i.ext}`},t.isUNC=F,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(F(e)||null!=e.match(M.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(O(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await n.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;n.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>n.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=L,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:L(e)},t.bestMountpointForDir=function(e,t){return(0,h.greatestBy)(t,(t=>D({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const n=r(i(76760)),s=i(19851),o=i(40958),a=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),f=i(54993),h=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),v=i(64660),w=i(21144),S=i(16287),b=(0,s.lazy)((()=>(0,h.mkLogger)("fs.PathTo"))),P=c.KiB;async function M(e,t=P){const i=await(0,S.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,v.isStatRX)(i,e)}function _(){if(y.isWin){const e=(0,a.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,a.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,a.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,n.default.join(e,"System32"),n.default.join(e,"System32","Wbem"),n.default.join(i,"chocolatey","bin"),n.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function E(){const e=(0,f.toS)((0,m.env)().PATH).split(n.default.delimiter);return(0,o.uniq)((0,o.compactBlanks)([...e,..._()]))}t.isRXFile=M,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,o.uniq)((0,o.compactBlanks)([...E(),...(0,d.toA)(i)]));for(const i of(0,o.uniq)((0,o.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=n.default.join(t,e);if(await M(i))return y.isLinux?i:(0,w.actualPath)(i)}}b().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){"use strict";var r,n,s,o=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&o(t,e,i);return a(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),f=c(i(73024)),h=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),v=i(76790),w=i(5233),S=i(22573),b=i(42659),P=i(26905),M=i(75240),_=i(55835),E=i(31586),T=i(68708),x=i(13538),D=i(89937),k=i(12168),C=i(54993),O=i(48884),I=i(50213),F=i(45255),L=i(81168),A=i(56519),R=i(56038),N=i(31562),j=i(84777),B=i(9595),z=i(38835),V=i(70025),W=i(57902),U=i(55222),H=i(43334),q=i(33847),G=i(24399),$=i(28874),J=i(79915),K=i(45200),Z=i(34238),Y=i(87001),X=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),ne=i(73209),se=i(48313),oe=i(29882),ae=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),fe=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,O.contextFilter)(function(e){return(0,v.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class he extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,I.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Z.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,A.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,A.thenMapOr)((0,X.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>H.isMac?(0,j.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:F.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return he.for(e.nativePath,e)}static forMaybe(e){return(0,S.notBlank)(e)?he.for(e):void 0}static for(e,t){if(e instanceof he)return e;if((0,S.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,L.isString)(e)){const t=fe().get(e);if(null!=t)return t}const i=(0,ae.toNativePath_)(e),r=new he(i,t);return(0,L.isString)(e)&&fe().set(e,r),fe().set(i,r),r}static forPosix(e){return he.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,A.thenMap)((0,K.uri2nativePath)(e,t),(e=>he.for(e)))}for(e,t){return he.for(e,t)}forDirectoryEntry(e){return he.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,oe.containedByNativePath)({ancestor:(0,B.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,oe.containedByNativePath)({ancestor:(0,B.originalsDir)(),descendant:this,acceptSelf:!0}))return H.isWin&&this.nativePath.startsWith("\\\\")?he.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,_.map)((0,ee.bestMountpoint)(this.nativePath,await(0,X.mountpoints)()),(e=>he.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,_.map)((0,S.notBlankOr)(e,(()=>this.uri_())),Z.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,C.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===D.PS_LIBRARY_SCHEME?1:t.scheme===D.PS_LOCAL_FILE_SCHEME?2:t.scheme===D.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,L.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(H.isWin||H.isMac)return this.trap("hide",(async()=>(await(0,se.hide_)(this),this)))}async hidden(){return(0,se.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,L.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,O.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,_.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,T.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:n,skipWip:s=!1,skipFsLock:o=!1,retries:a=2,dirty:l=!1}){return(0,w.retryOnReject_)((async()=>{const a=await this.clear().isNonEmptyFile(i);if(!a){if(s&&o)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:o,minSizeBytes:i,timeoutMs:n,dirty:l})}return a&&r?void 0:this.utimes()}),{maxRetries:a,timeoutMs:2*n,retryDelay:3*b.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,E.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:n,dirty:s=!1}){return await this.parent().mkdirp_(),(0,ne.withLock_)({file:this,skipFsLock:r,timeoutMs:n,dirty:s},(async()=>{const r=this.wip();try{await r.unlink("trace");const s=await(0,x.thenOrTimeoutError)(e(r),n);if(s===t.NoOp)return s;if(await(0,N.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:F.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),s;throw new Error(this+"applyWip(): still empty after waiting "+(0,M.fmtDuration)(F.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==$.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",n).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",s).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();$.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:b.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,f.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,E.clamp)(F.ShortCommandTimeoutMs,10*b.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,S.notBlank)(this.ext)&&(0,S.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,b.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,_.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,A.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,L.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,oe.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,oe.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,Y.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=he,r=new WeakSet,n=async function(e){let t,i=e;const r=e.wip();try{const n=await this.stat_();if(null==n)return this.pflog().throw("Can't copy missing files"+z.NonRetriableErrorFlag);if(n.size>0){if($.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+z.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await h.default.copyFile(this.nativePath,r.nativePath,f.default.constants.COPYFILE_FICLONE),n.size>5*k.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},n.size,(()=>r.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,E.approximates)(n.size,await r.size({refresh:!0}))),{intervalMs:b.secondMs,timeoutMs:b.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:n.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:n.birthtimeMs,mtimeMs:n.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,n.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${n.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,_.map)(t,(e=>e.end()))}},s=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),n=r?.size;return null==r||null==n?this.pflog().throw("Can't copy missing files"):(n>5*k.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},n,(()=>e.clear().size()))),H.isWin?await G.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,G.pwshQuote)(this.nativePath)} -Destination ${(0,G.pwshQuote)(i.nativePath)}`,(e=>e)):H.isMac?await(0,j.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,j.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+z.DoNotSendErrorFlag,{error:t})}finally{(0,_.map)(t,(e=>e.end()))}}},78133:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const n=r(i(76760)),s=i(22573),o=i(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(n.default.sep===n.default.posix.sep)return e;const i=(0,s.notBlank)(t)?n.default.sep+n.default.sep+t+n.default.sep:"",r=e.split(n.default.posix.sep);return(0,o.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(n.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||n.default.sep===n.default.posix.sep||n.default.posix.sep===n.default.sep?e:e.split(n.default.sep).join(n.default.posix.sep)}},43899:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const n=r(i(76760)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),f=i(43334),h=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,o.lazy)((()=>n.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,o.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),f.isElectron&&t.push(n.default.join((0,p.execDir)(),"resources"),n.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,a.compactBlanks)([(0,p.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,h.hasChildrenSync)(i,e))return i;for(const t of(0,h.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,h.hasChildrenSync)(t,e))return t;const r=n.default.join(i,"node_modules","photostructure");if((0,h.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!f.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),n=i(19851),s=i(31586),o=i(50213),a=i(57902),l=i(69428),u=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=a.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),n=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let s=-1;try{const n=i??(await(0,r.stat)(e)).size-t,o=Buffer.alloc(n);return s=await(0,r.open)(e,"r"),await(0,r.read)(s,o,0,n,t)}finally{(0,n.mapGte0)(s,r.close)}}},69428:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const o=s(i(73024));t.readFileSync=function(e){try{return o.readFileSync(e)}catch{}}},55690:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),n=i(84542);t.readLines_=async function(e){return(0,n.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class n extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=n},65238:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const n=r(i(51455)),s=i(76760),o=i(19851),a=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),f=i(13538),h=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),v=i(28874),w=i(63870),S=i(88561),b=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,o.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,o.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function M(){try{await n.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=M;const _=(0,o.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function E(e){(0,l.blank)(e)||_.prior()?.delete(e)}async function T(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await _().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,b.statTimeoutMs)(),r=x(e),n=await(0,f.thenOrTimeout)(r,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(n===h.Timeout&&(0,g.onTimeout)({soft:!1}),n!==h.Timeout&&n.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=E,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),_.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),M()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?M():E(e)))})),t.slowDirs=(0,o.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!_().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){E(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=_().get(e)},t.childDirectories_=async function(e){return(await T(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?T(e):x(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=T,t.readdirCached=function(e){return _().get(e)},t.readdirUncached_=x},53265:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const n=i(73024),s=r(i(76760)),o=i(40958),a=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),f=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),h=c.isWin?/[\\/]/:/\//;function m(){return(0,o.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=s.default.resolve(t,...e);if((0,n.existsSync)(i))return i}f().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,a.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(h).slice(0,2).find(a.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},50274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),n=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,n.isBoolean)(e.isFile)&&(0,n.isBoolean)(e.isDirectory)}},17217:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const n=r(i(73024)),s=r(i(76760)),o=i(22573),a=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),f=i(14427);function h(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,o.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,o.blank)(e.nativePath))throw new Error(`toNativePath(${(0,a.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof n.default.Dirent?e.name:h(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=h,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return h(e)?e.dir:s.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(h(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(s.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,a.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(n.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=h.LogLevels.debug){return(0,a.blank)(e)?void 0:v(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=S(e),r=S(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],n=t[i],s=(0,u.diff)(b(r),b(n));if(null==s||s>1)return"unmatched "+i+": "+r+" ≠ "+n}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=h.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const i=await w(e,t?.logLevel??h.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await w(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=h.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=h.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=h.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,f.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,o.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const n=r(i(73024)),s=i(22573);function o(e){try{return(0,s.blank)(e)?void 0:n.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function a(e){return null==e||e.isFile()&&0===e.size}t.statSync=o,t.isEmptyStats=a,t.isFileSync=function(e,t=0){const i=o(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=o(e);return t.emptyIsNew?null==i:a(i)},t.isNonEmptyFileSync=function(e,t=0){const i=o(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===o(e)?.isDirectory()}},41080:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),n=i(56409);t.onDataChunked=function(e,t,i){const r=new s(t,i,!0);return r.read(e),r.done};class s{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new n.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const n=r(i(57075)),s=i(41400),o=i(55835),a=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends n.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,a.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,o.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class f extends n.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=f},66430:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const n=r(i(73024)),s=i(76760),o=i(22573),a=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,o.blank)(e))return!1;try{return n.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,a.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,o.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,o.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,o.blank)(e)&&d((0,u.posix2native)(e))}},89966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const n=r(i(48161)),s=i(19851),o=i(55835),a=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),f=i(8103),h=i(43899);function m(){return(0,o.map)(h.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,o.map)(m(),(e=>e.join(c.platformName+"-"+n.default.arch())))}async function g(e){if(c.isWin&&(e=(0,a.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,f.pathIfExists)(m()?.join("bin",e))),(()=>(0,f.pathIfExists)(m()?.join(e))),(()=>(0,f.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,f.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,s.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,s.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,s.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,s.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const n=r(i(44652)),s=i(19851),o=i(22573),a=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),f=i(17217),h=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,a.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,o.blank)(t.file))throw new Error("can't touch blank path");const r=(0,f.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,f.dirname)(t.file));const a=(0,s.lazy)((()=>(0,h.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await a())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await a())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(n.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!i||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(n.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},70854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryUidStore=t.LibraryUIDStore=t.SystemUIDStore=t.UIDStore=t.mkuid=void 0;const r=i(19851),n=i(41400),s=i(55835),o=i(92782),a=i(37805),l=i(46292),u=i(34102),c=i(55222),d=i(28874),f=i(87128),h=i(95696);function m(){return(0,o.safeRandomUid)({radix:c.TokenRadix,chars:24,splitEveryN:4})}t.mkuid=m;class p extends f.JsonFileStore{constructor(e,t){super(e.join("."+t+"-uid.json"),(()=>({uid:m(),version:a.version,type:this.type,createdAt:Date.now()})),(e=>e.hide())),this.rootDir=e,this.type=t,this.readUid_=(0,r.lazy)((async()=>(await this.read_())?.uid))}}function g(e=d.Settings.libraryDir.valueOrDefault){return(0,s.map)(h.PosixFile.forMaybe(e),(e=>new p(e,"library")))}t.UIDStore=p,t.SystemUIDStore=(0,r.lazy)((()=>(0,s.map)((0,l.configDir)(),(e=>new p(h.PosixFile.for(e),"system"))))),t.LibraryUIDStore=(0,r.lazy)(g),t.libraryUidStore=g,(0,n.later)((()=>{(0,u.ee)().on("clearCache",(()=>{t.SystemUIDStore.unset(),t.LibraryUIDStore.unset()})),d.Settings.libraryDir.watchLater((()=>t.LibraryUIDStore.unset()))}))},84258:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const o=s(i(51455)),a=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,a.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const r of(0,l.toA)(e))try{null!=r&&await o.unlink((0,c.toNativePath_)(r))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+r,{error:e})}}},5545:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const n=r(i(76760)),s=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,s.toS)(i.path??n.default.sep)}},70257:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),n=i(45255),s=i(17217);t.WipTimeoutMs=n.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const o=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(o,"")},t.isWip=function(e){return o.test((0,s.basename)(e)??"")}},58722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),n=i(22911);class s extends r.Writable{constructor(e){super(e),this.deferred=new n.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=s},73428:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const n=r(i(44652)),s=r(i(76760)),o=i(51926),a=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=s.default.dirname(e);await(0,c.mkdirp_)(i),await n.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function f(e,t){const i=s.default.dirname(e);(0,c.mkdirpSync_)(i),n.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,o.wrap)(t));await d(e,i)},t.writeFileSync_=f,t.writeTextSync_=function(e,...t){return f(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))}},13047:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const n=r(i(73024)),s=i(76760),o=i(46466),a=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),f=i(50213),h=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),v=(0,l.lazy)((()=>(0,f.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,i){const r=[],s=[n.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,a.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,a.createBrotliDecompress)().on("error",(e=>r.push(e)))),s.push(t),await(0,o.pipeline)(s),(0,u.isNotEmpty)(r))throw new h.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function b(e,t){const i=new y.WritableToBuffer;return await S(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function M(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,o.pipeline)(new g.ReadableBuffer(i),(0,a.createGzip)(),n.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void v().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=M,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await M(e,t)}catch(t){v().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},19652:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.externalDirectoryCheck=void 0;const o=i(51455),a=s(i(22915)),l=i(40958),u=i(82950),c=i(22573),d=i(45599),f=i(12168),h=i(50213),m=i(79960),p=i(32551),g=i(98314),y=(0,d.defer)((()=>(0,h.mkLogger)("health.externalDirectoryCheck")));t.externalDirectoryCheck=async function(){const e=(0,l.uniq)([(0,p.homeDir)(),a.getHomeFolder(),a.getPicturesFolder(),a.getVideosFolder(),a.getDesktopFolder(),await(0,m.defaultApplePhotosLibrary)()]).sort(),t=new Map,i=(0,l.uniq)(e.filter(c.notBlank)).sort();for(const e of i)try{await(0,o.readdir)(e,{withFileTypes:!0})}catch(i){if(["ENOTDIR","ENOENT"].includes(i?.code))continue;t.set(e,i)}const r=0===t.size?{level:"ok",msg:["Default media directories are OK","The following directories are readable:",(0,u.li)(i.map(u.tt))]}:{level:"warn",msg:["Error reading "+(0,f.plur)(t.size,"media directory")+":",(0,u.li)([...t.entries()].map((([e,t])=>(0,u.tt)(e)+":"+(0,g.errorToS)(t,{maxLen:80}))))]};return y().tap({msg:"externalDirectoryCheck",result:r})}},87408:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStatusSummary=void 0;const r=i(63870),n=i(18454),s=i(89035),o=i(82638);t.getStatusSummary=async function(e={}){return(0,o.summarizeHealthChecks)({healthChecks:[...n.HealthCheck.allCritical(),(0,s.memoryHealthCheck)()],errors:n.HealthCheck.lastErrors(),timeoutMs:(0,r.commandTimeoutMs)(),skipPending:!0,...e})}},18454:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c,d,f,h,m,p,g,y,v,w,S,b,P,M=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},_=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const E=i(19851),T=i(40958),x=i(76790),D=i(41400),k=i(50357),C=i(26905),O=i(50268),I=i(55835),F=i(68708),L=i(30976),A=i(51926),R=i(13538),N=i(42279),j=i(59455),B=i(54993),z=i(48884),V=i(89788),W=i(22454),U=i(50213),H=i(69591),q=i(22911),G=i(99331),$=i(5916),J=i(42638),K=i(77740),Z=i(98314),Y=i(70025),X=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),re=i(21525),ne=i(82638),se=(0,E.lazy)((()=>(0,U.mkLogger)("health.HealthCheck")));class oe{static traceLater_(e,t){const i=new q.Deferred(e);i.catch((t=>{M(this,n,"f",l).push(e+": failed: "+(0,Z.errorToS)(t)),this.onResultChange()})),M(this,n,"m",a).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return M(this,n,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){M(this,n,"f",l).push((0,A.isString)(e)?e:(0,Z.errorToS)(e)),this.onResultChange()}static lastErrors(){return M(this,n,"f",l).toA()}static addLoadingMsg(e){M(this,n,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,T.compact)((0,j.toA)(e)).map(B.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return se().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:M(this,n,"f",f).entriesByCountDesc()}),(0,I.map)((0,z.leastBy)(e,(e=>[M(this,n,"f",f).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=M(this,n,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,I.map)(e,(e=>M(this,n,"f",f).incr(e.msg))),se().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return X.Settings.skipHealthCheckIds.envValue=t,n.reset()}static findById(e){return M(this,n,"f",h).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,O.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=M(this,n,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=n.summary();if(e.pendingCount>0){const t=await Promise.all(n.testResultsCritical());e=n.summaryFromResults(t),se().info("awaitSettled(): summary result",{summary:e,results:t})}return se().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){n.summary.unset()}static reset(){if((0,G.ending)())se().warn("Rejecting reset() when ending()",(0,C.shortStack)());else{this.onResultChange(),M(this,n,"f",l).clear(),M(this,n,"f",d).clear(),M(this,n,"f",f).clear(),M(this,n,"f",c).clear(),this.summary.clear(),_(this,n,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new n(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return M(this,n,"f",h).push(i),this.all.unset(),i}constructor(e,t,i,s,a,l,u,c,d,f,h,m,b,P=Q.commandTimeoutMs){r.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=s,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=f,this.errorLinks=h,this.onReset=m,this.ttlMs=b,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),w.set(this,(0,E.lazy)((async()=>{await M(this,p,"f").prior(),(0,k.eql)(M(this,g,"f"),M(this,r,"m",v).call(this))||(this.onReset?.(),await this.refresh(),M(this,w,"f").unset())}))),this.refresh=(0,E.lazy)((()=>new q.Deferred("refresh").observe((async()=>{await M(this,p,"f").prior();const e=M(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,U.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[O.HealthCheckSections.ordinal(this.section),l??999,this.id],_(this,p,(0,$.lazyAsync)({desc:this.pendingMsg,later:()=>M(n,n,"f",o).enqueue({name:this.id,l:()=>M(this,r,"m",S).call(this,a)}),ttlMs:b}),"f"),this.isCritical&&M(this,p,"f").watchLater({onChange:n.onCriticalResult,onError:n.onCriticalResult});for(const e of this.settings)X.Settings[e].watchLater((()=>M(this,w,"f").call(this)))}isStale(){return M(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return M(this,p,"f").settledCount()}reset(){return M(this,p,"f").unset(),this.onReset?.(),_(this,g,{starting:!0},"f"),this}setTTL(e){M(this,p,"f").setTTL(e)}result(){return M(this,p,"f").call(this)}isSkipped(){return X.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return M(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return M(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??M(this,r,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function ae(e){if((0,T.isEmpty)(e))return{};const[t,i]=(0,z.partition)(e,(e=>"button"===e.type||"POST"===e.method)),r={};return(0,T.isNotEmpty)(i)&&(r.links=(0,T.uniqBy)(i)),(0,T.isNotEmpty)(t)&&(r.buttons=(0,T.uniqBy)(t)),r}t.HealthCheck=oe,n=oe,p=new WeakMap,g=new WeakMap,y=new WeakMap,w=new WeakMap,r=new WeakSet,a=function(){return(0,T.filterInPlace)(M(this,n,"f",s),(e=>!e.isPending)),M(this,n,"f",s)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=se().tap({level:"warn",msg:"#summary()",result:(0,ne.summarizeHealthChecksSync)({errors:M(this,n,"f",l),skipPending:M(this,n,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&_(this,n,!0,"f",u),i.state!==M(this,n,"f",c).last?.state&&M(this,n,"f",c).push({state:i.state,ts:Date.now()}),i},v=function(){return(0,F.fromEntries)(this.settings.map((e=>[e,X.Settings[e].valueOrDefault])))},S=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();se().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,C.shortStack)()}),_(this,g,M(this,r,"m",v).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,D.delay)((0,L.randomInt)(.3*i,.7*i)),this.isSkipped())return M(this,r,"m",b).call(this,{test:{level:"disabled",msg:["Disabled by "+X.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const n=await(0,R.thenOrTimeoutError)(e(),i);return M(this,r,"m",b).call(this,{test:n,elapsedMs:Date.now()-t})}catch(e){return M(this,r,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},b=function({test:e,src:t="#toResult",elapsedMs:i}){var r,s;const o=n.normalizeMsg(e.msg),a=e.level??((0,B.toS)(o).toLowerCase().includes("error")?"error":(0,B.toS)(o).toLowerCase().includes("warn")?"warn":"ok"),l=(0,T.compact)([...e?.links??("ok"===a||"pending"===a?this.okLinks:"warn"===a?this.warnLinks:"no-library"===a?this.noLibraryLinks:"error"===a?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:a,msg:o,elapsedMs:i,...ae(l)};return u.runCount=(_(this,y,(s=M(this,y,"f"),r=s++,s),"f"),r),(0,G.ending)()?u:this.logger.tap({level:re.HealthCheckLevelToLogLevel[a],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const n=(0,A.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,I.map)(e,Z.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,Y.isFatalError)(e)&&n.toLowerCase().includes("warn")?"warn":"error"),M(this,r,"m",b).call(this,{test:{msg:n,level:t},src:"#toErrorResult",elapsedMs:i})},s={value:[]},o={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},f={value:new W.CountingSet},h={value:[]},oe.all=(0,E.lazy)((()=>Object.freeze((0,x.sortBy)(M(n,n,"f",h),(e=>e.sortBy))))),oe.onCriticalResult=(0,H.debounce)((()=>{se().info("onCriticalResult()",n.summary.refresh())}),250),oe.summary=(0,E.lazy)((()=>M(n,n,"m",m).call(n))),oe.resetDebounced=(0,H.debounce)((()=>n.reset()),50)},85021:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckCommand=void 0,t.HealthCheckCommand="--health"},33866:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const r=i(82950),n=i(50268),s=i(459),o=i(23560),a=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,o.isPermaService)(t)&&(e===n.HealthCheckLevels.error||(0,o.isLibraryRequiredService)(t)&&e===n.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,a.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,r.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new s.UnreachableCaseError(e)}}},42495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const r=i(40958),n=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,r.compact)([(0,n.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},89035:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const n=r(i(48161)),s=i(19851),o=i(82950),a=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),f=i(23560),h=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:r}){return{level:i,msg:[e+" from "+(0,f.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,o.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(r,2)])]}}function g(){return n.default.totalmem()h.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:h.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(h.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*h.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:h.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:h.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,s.lazy)((()=>"ok"!==g().level),a.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:a.minuteMs,later:async()=>g()})))},82638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const r=i(40958),n=i(42659),s=i(45599),o=i(41400),a=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),f=i(23560),h=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,s.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function v({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:r}){const n=new Map;for(const e of t??[])n.set(e.id,e);if(null!=e)for await(const t of h.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),r))n.set(t.id,t);return[...n.values()]}t.summarizeHealthChecks=async function(e){return S({...e,healthCheckResults:await v(e)})};const w=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:f.serviceName.prior()??process.title}})));function S(e){const t=(0,r.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),s=i.length,o=i.map((e=>e.id)),c=t.length-s,d=0===s,f=(0,r.uniq)((0,r.compactBlanks)(e.errors));if(f.length>0)return{...w(),level:l.HealthCheckLevels.error,settled:d,pendingIds:o,pendingCount:s,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",f.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const n=t.filter((e=>e.level===i));if((0,r.isNotEmpty)(n)){const e=t.filter((e=>!n.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+n.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...w(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:o,pendingCount:s,settledCount:c,linkIds:n.map((e=>e.id)),ts:Date.now(),msg:(0,r.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,a.flatten)([...n,...e].map((e=>e.msg[0])))])},meta:{checks:n.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...w(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:o,pendingCount:s,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,n.fmtDateShort)(Date.now())]}})}(0,o.later)((()=>{m.Settings.libraryDir.watchLater((()=>w.unset()))})),t.summarizeHealthChecksSync=S},52086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},86580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const r=i(40958),n=i(33374),s=i(31586),o=i(21605),a=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,s.gt0)(e.width)&&(0,s.gt0)(e.height)?(0,s.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,n.dmegapixels)(e.dimensions):(0,s.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,s.lt)(e.width,t.width)&&(0,s.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,s.lte)(e?.width,t?.width)&&(0,s.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,s.lt)(e.width,t.width)||(0,s.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,r.compact)((0,a.toS)(e).split(/[x×]/).map((e=>(0,s.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,r=Math.round(Math.sqrt(t*i));return{width:r,height:Math.round(r/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const r=u(e,i);return null==r?[]:o.Rotations.filter((e=>u(c(t,e),i)===r))}},89782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const r=i(19851),n=i(31586),s=i(50213),o=i(56519),a=i(1078),l=i(5733),u=(0,r.lazy)((()=>(0,s.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,n.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,o.thenMap)((0,a.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},277:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const r=i(22573),n=i(41400),s=i(54993),o=i(19851),a=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),f=i(78330),h=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),v=(0,o.lazy)((()=>(0,a.mkLogger)("img.Heif")));function w(e){return(0,s.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function S(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,o.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,r.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){v().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,r.blank)(e))return void v().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=w(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,r.blank)(i)&&(0,l.hasApt)()){const t=await(0,f.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,r.blank)(i)&&(0,h.hasPacman)()&&(i=(await(0,h.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,r.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void v().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=w,t.isHeifSupported=S,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await S()?(0,g.heif2png_)(e):void v().throw("HEIF support is missing",{src:e.nativePath})},(0,n.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const r=i(19851),n=i(22573),s=i(42659),o=i(41400),a=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),f=i(28874),h=i(89782),m=i(13940),p=(0,r.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,n.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,r.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:f.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?s.minuteMs:void 0),e})),(0,o.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,h.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(f.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:f.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(a.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const r=i(22573),n=i(54993),s=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,r.blank)(e)&&s.test((0,n.toS)(e))}},13940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),n=i(19851),s=i(42659),o=i(59455),a=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),f=i(46199),h=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),v=i(55222),w=i(63870),S=(0,n.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,n.lazy)((()=>(b(),g.PosixFile.for((0,h.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const b=(0,n.lazy)((()=>{h.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const n=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const s=n.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,f.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await s.mkdirp_(),await s.utimes();const o=s.join(i+r);return S().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:o}),o}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,o.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+v.TokenRadix.randomChars(2),v.TokenRadix.randomChars(16)+(0,a.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*s.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const n=await P(e,t,i);return await n.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,w.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),n}catch(r){return S().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},2090:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const r=i(40958),n=i(33374),s=i(31586),o=i(34666),a=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,s.isNumber)(e)?e:((0,s.toGt0)(e.width)??0)/((0,s.toGt0)(e.height)??0),(e=>(0,a.leastBy)(t.StandardAspectRatios,(t=>{const r=Math.abs(e-t);return r>i?void 0:r}))??e))}function c(e,i,r=t.RatioEpsilon){return(0,o.lt)((0,s.absdiff)(u(e),u(i)),r)}function d(e,i){return(0,a.leastByCtx)(t.Ratios,(t=>{const r=Math.abs(t.i-e);return r[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,n.maybeDimSwap)(e.dimensions,e.rotation),(0,n.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,s.sigFigs)(e,3))}},34943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const r=i(19851),n=i(31586),s=i(80049),o=i(50213),a=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),f=(0,r.lazy)((()=>(0,o.mkLogger)("img.RawInfo"))),h=(0,r.lazy)((()=>new s.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:a.ShortCommandTimeoutMs})));async function m(e){return h().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,r,s,o]=e.split("\t"),a=(0,n.toGt0)(s),l=(0,n.toGt0)(o);return null==a||null==l?f().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):f().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:r,ImageSize:{width:a,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>h.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?h.prior()?.clear():h.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{f().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},5733:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const n=r(i(9288)),s=i(19851),o=i(41400),a=i(50213),l=i(28874),u=i(15674),c=(0,s.lazy)((()=>(0,a.mkLogger)("img.Sharp")));function d(e,t){return(0,n.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,s.lazy)((()=>{n.default.simd(l.Settings.enableSIMD.valueOrDefault),n.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),n.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,o.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},19769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const r=i(19851),n=i(40958),s=i(41400),o=i(50213),a=i(68852),l=i(98314),u=i(28874),c=(0,r.lazy)((()=>(0,o.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:f().test(t)||!d().test(t),meta:{err:e,allow:f().test(t),block:d().test(t),validationErrorAllowlist:f().source,validationErrorBlocklist:d().source}})};const d=(0,r.lazy)((()=>(0,a.orRegExpPatterns)((0,n.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),f=(0,r.lazy)((()=>(0,a.orRegExpPatterns)((0,n.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,s.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>f.unset()))}))},66106:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const r=i(19851),n=i(40958),s=i(38639),o=i(42659),a=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),f=i(7282),h=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),v=i(56038),w=i(31562),S=i(34102),b=i(88561),P=i(95696),M=i(17217),_=i(31843),E=i(70417),T=i(33847),x=i(28874),D=i(94678),k=i(43207),C=i(47783),O=i(16170),I=i(95141),F=i(1078),L=i(63870),A=i(89782),R=i(13940),N=i(34592),j=(0,r.lazy)((()=>(0,d.mkLogger)("img.Video")));function B(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function z(e){return(0,f.isProd)()&&(e=void 0),(0,s.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=z,t.isVideoSupported=(0,r.lazy)((async()=>{try{return!0===(await z())?.isSupportedVersion}catch(e){return j().warn("isVideoSupported",{error:e}),!1}})),(0,a.later)((()=>(0,S.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,_.lerp2d)(e,{x:76800,y:x.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:x.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,r.lazy)((()=>new b.FileCache({name:"img.videoFrame",timeoutMs:o.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,M.toNativePath_)(e))):void 0}async function U(e,t){const i=B("extractVideoFrame",e),r=P.PosixFile.for(e);if(!(0,s.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const n=await(0,R.cachedImageFile_)(r,"frame",".jpg");i.debug("extractVideoFrame("+n+")");const a=await r.mtimeMs();if(null==a)return i.throw("null mtime");const l=await(0,C.readRawTags)(r,!1);if(null==l)return i.throw("no tags");const u=(0,I.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,F.extractSizeInfoFromTags)(l,u)?.dimensions,d=await n.stat(),f=null==d?void 0:await(0,A.dimensions)(n);if(null!=d&&d.mtimeMs>a&&null!=f&&(null==c||f.height===c.height&&f.width===c.width))return i.debug("prior dest, "+n+" seems reasonable",{srcDim:c,destDim:f}),n.nativePath;const h=(0,k.extractDurationSec)(l),m=Math.min(h??0,x.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:h}),await n.applyIfEmpty_({fn_:async e=>{const t={src:r,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,w.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*o.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,C.deleteAllTags_)(e,e)},timeoutMs:(0,L.commandTimeoutMs)()}),n.nativePath}async function H(){return x.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function q(e){const t=B("needsTranscoding",e);if(!await H())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,C.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const r=i.MIMEType;if(!(0,O.isVideoMimeType)(r))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:r}});const s=(0,k.extractDurationSec)(i);if(!(0,c.gt)(s,x.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:s}});const o=(0,n.compactBlanks)([i.AudioFormat]),a=o.some((e=>(0,p.includesIgnoreCase)(x.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,n.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(x.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(x.Settings.doNotTranscodeMimeTypes.values,r);return t.tap({level:"info",msg:"result",result:!(a&&u&&d),meta:{mimetype:r,isSafeMimeType:d,audioCodecs:o,isSafeAudioCodec:a,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>U(e)}),t.__extractVideoFrame_=U,t.isVideoTranscodingSupported=H,t.needsTranscoding=q;const G=new g.TTLMap(o.hourMs);function $(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,r){if(!await H())return;const n=B("transcode",e);{!function(){for(const[e,t]of G.entries())t.isSettled&&G.delete(e)}();const t=G.get(e.nativePath)??G.get(i.nativePath);if(null!=t)return n.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await q(e))return void n.info("no transcoding needed");const s=await e.size();if(!(0,u.gt0)(s))return n.throw("source is empty or cannot read");const o=await(0,C.readTags)(e),a=(0,F.extractSizeInfoFromTags)(o),d=(0,k.extractDurationSec)(o);if(null==o||null==a||null==d)return n.throw("failed: missing video metadata",{sizeInfo:a,durationSec:d});{const e=G.get(i.nativePath);if(null!=e)return n.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const f=new y.Deferred("transcode "+e);G.set(e.nativePath,f),G.set(i.nativePath,f);const m=(0,u.toGt0)(o.VideoFrameRate)??(0,u.toGt0)(o.FrameRate)??30,p=Math.round(a.dimensions.width*a.dimensions.height*(0,E.max)([(0,u.toGt0)(o.FrameCount),(0,u.toGt0)(o.VideoFrameCount),m*d]));if(!0===r?.force)await i.unlink();else if(await async function(e,t){const i=await(0,C.readRawTags)(t),r=await(0,C.readRawTags)(e),n=(0,k.extractDurationSec)(r),s=(0,k.extractDurationSec)(i);return j().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(n,s,1.5),meta:{srcDurationSec:n,destDurationSec:s,src:e.nativePath,dest:t.nativePath}})}(e,i))return n.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const r=B("extractMaxBitrate",e),n=x.Settings.minVideoDimension.valueOrDefault,s=i.ImageWidth;if(null!=s&&!(0,u.gte)(s,n))return r.throw("invalid width: "+s,{ignorable:!0});const o=i.ImageHeight;if(null!=o&&!(0,u.gte)(o,n))return r.throw("invalid height: "+o,{ignorable:!0});const a=(0,D.extractBitrateKbps)(i)??x.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,h.mapGt0)(s,(e=>(0,h.mapGt0)(o,(i=>(0,u.clamp)(0,a,(0,t.bitrateKps)(e*i)))))),c={width:s,height:o,videoBitrateKbps:l};return r.debug("dim()",{src:e,result:c}),c}(e,o);return await f.observe((0,v.time)("video.transcode:"+e,(async()=>{const t=$(s,g.videoBitrateKbps,d);return await i.applyWip_({fn_:s=>async function(s){n.info("starting...",{destWip:s});const a=new T.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:s,fps:m,halt:r.halt,...g},f=x.Settings.transcodeMaxDim.valueOrDefault,h=(0,E.max)([o.dimensions.height,o.dimensions.width]);if((0,u.gt0)(f)&&(0,c.gt)(h,f)){const e=(0,l.fitInside)(o.dimensions,{width:f,height:f});null==e?n.warn("Cannot downsample transcoded video: fitInside() returned null",{input:o.dimensions,maxPixels:f}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),n.info("Downsampling transcoded video",{original:o.dimensions,output:e}))}const p=await a.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&n.throw("transcode failed with code "+p.code)}(s),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&n.info("transcode complete",{src:e,dest:i,elapsedMs:f.elapsedMs,pixels:p}),i},t.guessExpectedSize=$,t.validVideo_=async function(e){return null==await W(e)&&B("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const r=i(40958),n=i(22573),s=i(38639),o=i(42659),a=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),f=i(56519),h=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),v=i(84258),w=i(28874),S=i(76280),b=i(63870),P=i(19769),M=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function _(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:w.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=_;const E=/ffmpeg version n?(?\S+)/i,T=(0,u.lazy)((async()=>{const e=await _();if(null==e)return void M().info("failed to find ffmpeg in $PATH",{ffmpegPath:w.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,b.commandTimeoutMs)(),ignoreStderr:!0}),i=E.exec(t.result)?.[1];return M().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,S.semverSatisfies)(i,">=3.2")}}));function x(){T.unset(),t.ffmpegVersionDescription.unset()}function D(e){const t=e?.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault;return(0,n.blank)(t)||(0,s.isDisabled)(t)?[]:["-hwaccel",t]}function k(e){const t=[...w.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(w.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),r=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+r),t}function C(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function O(e){const t=w.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,f.thenMapOr)(T(),(e=>"version "+e),(()=>"(not found)")))),(0,a.later)((()=>{(0,g.ee)().on("clearCache",x),(0,g.ee)().on("clearToolCache",x)})),t.ffmpegVersion_=async function(){return await T.prior()??T.refresh()},t.isFFmpegSupported=async function(){return null!=await T()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,r.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:o.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,h.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*o.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=k,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,r.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...k(t),...O(t),...D(t),"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...C(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){M().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,v.unlink)(t.dest,"debug");const r=(0,p.errorToS)(i,{maxLen:1024});if(!(0,s.isDisabled)(t.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(r))return M().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return M().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await _(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},36192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const r=i(19851),n=i(84777),s=i(8103),o=i(43334),a=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,r.lazy)((async()=>o.isMac?(0,s.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,n.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(a.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},71706:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.j=void 0;const r=i(38522);t.j=function(e){return JSON.parse((0,r.brotliDecompressSync)(Buffer.from(e,"base64")).toString("utf8"))}},42042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEmail=void 0;const r=i(22573),n=i(28874),s=i(81674);t.getEmail=async function(){const e=n.Settings.email.value;if((0,r.notBlank)(e))return e;for(const e of await(0,s.m)())if((0,r.notBlank)(e.l?.sub))return e.l?.sub}},83950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.L=void 0;const r=i(79114),n=i(40958),s=i(42659),o=i(34666),a=i(48884),l=i(97352),u=i(81674),c=i(84194);t.L=class{static for(e){return new this(e.str,e.l,e.sids,e.src)}constructor(e,t,i,r){this.s=e,this._l=t,this._sids=i,this.meta={src:r}}get l(){return this._l}get ok(){if(null==this._l)return!1;const e=(0,a.intersection)(this._sids,this._l.uids),t=(0,n.uniq)(e.map(c.getScheme)),i=(0,n.compact)(t.map((e=>(0,c.prefix2scheme)(e)))),r=i.length>=this._l.mat,o=(0,l.within)(this._l.iat?.getTime(),this._l.exp?.getTime()+s.dayMs,Date.now());return this.meta[(0,u.k)().o]=o,this.meta[(0,u.k)().u]=r,this.meta[(0,u.k)().m]=i,o&&r}cmpVal(){return[this.ok,-(r.S.indexOf(this.l?.[(0,u.k)().T])??0),this.l?.exp?.getTime()??1,this.meta.matchedSchemes]}cmp(e){return(0,o.cmp)(this.cmpVal(),e.cmpVal())}}},81674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p=t.l=t.t=t.b=t.m=t.vok=t.v=t.v_=t.k=void 0;const r=i(76790),n=i(22573),s=i(38639),o=i(45599),a=i(41400),l=i(96249),u=i(55835),c=i(31586),d=i(51926),f=i(79114),h=i(23541),m=i(59455),p=i(54993),g=i(72993),y=i(19851),v=i(50213),w=i(56519),S=i(76596),b=i(46292),P=i(87290),M=i(77740),_=i(34102),E=i(83278),T=i(28874),x=i(37692),D=i(71706),k=i(83950),C=i(72042),O=i(33603),I=i(48132);t.k=(0,y.rolazy)((()=>(0,D.j)("G1UBABwHdkz4hUIkFCfPXW5LlfvrWKSr9W3AIyIhUiw68NDfvLLHVop/bGoNnRxQlnqi2TZp0IJaX+lUHBoi+vMy2LMNpHCv8xVkUGsmQsgB8ldHoDqJeUQzbdybwikWVRs2KSWKjE5LnuqhTNSp3gTLhNfE9EqBLeaXP+UM9YqTGSXcyrcL03rIPMDAVyJplSZC0xoUgguOYJKvrcYFbNArN7BrQsnnsJ4hMtcSxOTxxRdxzETtL93qa3vjDw==")));const F=(0,o.defer)((()=>(0,v.mkLogger)((0,t.k)().l)));async function L(e){const i=await(0,C.V)((0,d.ensurePrefix)((0,p.toS)(e).trim(),(0,t.k)().p)),r=(0,S.utcIsoToTs)(i[(0,t.k)().i]);if(null==r)throw new Error("bad "+(0,t.k)().i+": "+i[(0,t.k)().i]+" ("+e+")");const n=(0,S.utcIsoToTs)(i[(0,t.k)().r]);if(null==n)throw new Error("bad "+(0,t.k)().r+": "+i[(0,t.k)().r]+" ("+e+")");return(0,M.getDevEnvFlag)((0,t.k)().y)&&(i[(0,t.k)().t]=!0),i[(0,t.k)().a]=(0,c.toGte0)(i[(0,t.k)().a])??2,i[(0,t.k)().i]=new Date(r),i[(0,t.k)().r]=new Date(n),i[(0,t.k)().b]=(0,p.toS)(i.uids).split(","),i}async function A(e,i,r,s){try{return(0,n.blank)(e)||e===(0,t.k)().f?void 0:k.L.for({str:e,l:await L(e),sids:null!=s?s:await(0,O.sids)({timeoutMs:r}),src:i})}catch(i){return F().tap({msg:(0,t.k)().v,result:{s:e,ok:!1,meta:{err:i}}})}}async function R(e,t){const i=[],r=await(0,w.sortByAsync)({name:"rawLicenseFromDir("+e+")",arr:e?.childFiles(),f:e=>e.mtimeMs()});for(const e of r.reverse()){const r=await A((0,m.toA)(await e.readLines()).map((e=>e.trim())).join(""),e.nativePath,I.UserTimeoutMs,t);null!=r&&i.push(r)}return i}async function N(){const e=await(0,t.m)();return e[0]?.ok?e[0]:void 0}async function j(){return(await N())?.l?.[(0,t.k)().T]??(0,t.k)().f}t.v_=L,t.v=A,t.vok=async function(e,t,i){if((0,n.blank)(e))return;const r=await A(e,t,i);return(0,s.isTrue)(r?.ok)&&r instanceof k.L?r:void 0},t.m=(0,y.rolazy)((async()=>{if((0,M.getDevEnvFlag)((0,t.k)().x))return[];const e=await(0,O.sids)({timeoutMs:I.UserTimeoutMs}),i=(0,u.map)((0,b.configDir)(),(e=>E.BaseFile.for(e))),n=(s=(0,l.flatten)((await(0,w.someOrTimeout)([()=>function(e){return A(T.Settings[(0,t.k)().L].value,"Settings",I.UserTimeoutMs,e)}(e),()=>R(i?.join((0,t.k)().d),e),()=>R((0,P.libraryDataDirPosixFile)()?.join((0,t.k)().d),e),()=>R(i?.sibling((0,g.AppName)().toLowerCase()).join((0,t.k)().d),e)],{timeoutMs:I.UserTimeoutMs})).filter((e=>!(e instanceof Error)))),(0,r.sortBy)(s.filter((e=>null!=e&&((0,h.isError)(e)&&F().warn((0,t.k)().d+": ",e),null!=e&&!(0,h.isError)(e)&&null!=e?.l))),(e=>[!e.ok,f.S.indexOf(e.l?.[(0,t.k)().T])??f.S.length+1,-(e.l?.exp?.getTime()??1)])));var s;return F().tap({msg:(0,t.k)().d+"()",result:n})})),(0,a.later)((()=>{(0,_.ee)().on("clearCache",(()=>t.m.unset())),(0,_.ee)().on((0,t.k)().c,(()=>t.m.unset())),x.stateEvents.on((0,t.k)().c,(()=>t.m.unset()))})),t.b=N,t.t=j,t.l=async function(){try{return await j()===(0,t.k)().f}catch{return!0}},t.p=async function(){try{return await j()===(0,t.k)().g}catch{return!1}}},72042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.V=t.l=void 0;const r=i(91227),n=i(19851),s=i(22573),o=i(71706);t.l=(0,n.lazy)((()=>(0,o.j)("G54BgBwHzrkukKDR8Ar6KkW29gbXlfrqQX46gTu5Wfq6dELYTjfBokB0d5+E2SAINBtxlmPquWe3PMUoNgaJrD982QMslkNeZ4BEqcBbQT59DVl9RnoTNi50diuT7NQg0YHxkr8SwDwtmFUOf+LwNVDDnPXUrzTOU++M3b+lcyfr7PXZndKHzho8iztNkZgt+/19//aXe+gvmC0HIdnn64wdLeYeLM7S9jmjTp52SzFsvIVbd4D0+rdtdjiz6R4vc2cmY398kuXiKG7fNXWS/I93etxXiVNPd4RXJF+k6JnuMUKk03GWHQQ="))),t.V=function(e){const i=(0,r.decode)(e).payload;if(null==i)throw new Error("Missing payload");const n=(0,s.notBlankOr)(i.k,(0,t.l)().d),o=(0,t.l)().o.find((e=>e.k===n));if(null==o)throw new Error("Unknown key");return r.V2.verify(e,o)}},84194:function(e,t,i){"use strict";var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SchemeCounts=t.isValidUid=t.toUID=t.UidLength=t.prefix2scheme=t.sortUids=t.getScheme=t.S=void 0;const s=i(40958),o=i(76790),a=i(22573),l=i(45599),u=i(50989),c=i(54993),d=i(22454),f=i(19851),h=i(50213),m=i(37628),p=i(55222),g=i(71706),y=(0,l.defer)((()=>(0,g.j)("GyABAIzUYs0Z7mSuLfVL1SwGefr+3nCwyXBMg6nD0qduA8HycFjUGK1N/ikYqhiqYLGbs7oxTBbzRPxteP9gA3L9DS0EJ2BJ1pYNa/DtEE2aPI2o03hHx3k9MhdE7jAeRUvKQ6tY3Q1fcIPe8GBMZvOeKibTymyo3Cw/7Ua42DKPjpL3wxWv+7TCGA==")));function v(e){const i=e.split(":",1)[0];return t.S.has(i)?i:void 0}t.S=(0,u.strEnum)("cu","lc","lm","lp","lb","mp","ms","wm","cm","bm","nm","li","si","vl"),t.getScheme=v,t.sortUids=function(e){return(0,o.sortBy)((0,s.uniq)(e.filter(b)),(e=>[t.S.indexOf(v(e))??t.S.length+1,e]))},t.prefix2scheme=function(e){return y()[e]};const w=["uninitialized","b08dfa6083e7567a1921a715000001fb"];t.UidLength=15,t.toUID=function(e,i){try{const r=(0,c.toS)(i).replace(/[^a-z\d=/+]+/gi,"");return(0,a.blank)(r)||w.includes(r.toLowerCase())||null!=r.match(/^[\s0:_/-]*$/)?void 0:e+":"+(0,m.shortStringSha)(r,t.UidLength,p.Radix58)}catch(t){return void(0,h.mkLogger)("toUID").warn("failed",{pfx:e,err:t})}};const S=(0,l.defer)((()=>new RegExp(`^(?:${t.S.values.join("|")}):[0-9a-zA-Z]{${t.UidLength}}$`)));function b(e){return null!=e&&null!=S().exec(e)}t.isValidUid=b,t.SchemeCounts=class{constructor(e){r.set(this,new Set),this.schemeCounts=(0,f.lazy)((()=>{const e=new d.CountingSet;for(const t of n(this,r,"f")){const i=v(t);null!=i&&e.incr(i)}return e})),null!=e&&this.addUids(e)}get size(){return n(this,r,"f").size}addUids(e){for(const t of e)null==v(t)||n(this,r,"f").has(t)||(n(this,r,"f").add(t),this.schemeCounts.unset())}count(e){return this.schemeCounts().get(e)}},r=new WeakMap},33603:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearSids=t.addSids=t.sids=t.win_machineGuid_=t.readInfo=t.k=void 0;const r=i(40958),n=i(22573),s=i(42659),o=i(45599),a=i(96249),l=i(68708),u=i(51926),c=i(59455),d=i(54993),f=i(50213),h=i(7282),m=i(56519),p=i(84777),g=i(84542),y=i(19254),v=i(45879),w=i(70854),S=i(57902),b=i(72308),P=i(43334),M=i(24399),_=i(7014),E=i(30933),T=i(71706),x=i(84194);t.k=(0,o.defer)((()=>(0,T.j)("G9ABYIzDOIZ8NLQ4t7qW8tNrmrOzz+qFGfAxl8jW4E2tLxwWRZT5TueCnPcwgTzT1DN3veRB+e7EYGlYHg6nhjBDQv7zI6EcYWk35z6QuZC3Q0itjrLCbmgd0iED0BvGiYLBJwRU1O9/3Agbl8IfG6ITVFWDRwyTw3rbUMo/XMyAVW7R23mkwUx0l4/7iA13RV/nmPuJFKp5BvJW7SoXJZoWEfdSNYYhN5UCtkbC7O1AaPIbU3P6uRLmEyb4TaHWzFigvrlmZVUzzp9j/Mz55vqN88ewd1Nrfh7gkVRQ7TtB7Ztz3XJxYC3ogdJHg8HGsG4=")));const D=(0,o.defer)((()=>(0,f.mkLogger)((0,t.k)().n)));async function k(e=(0,t.k)().pc){if(P.isLinux)try{const t=await(0,y.fileGrep_)(e,/^\s*(?:hardware|revision|serial|model)\s*[:=]\s*[a-z\d]{6}.*$/i),i=(0,r.compactBlanks)((0,g.splitLines)(t).map((e=>e.replace(/\s+/g," ")))).sort();return i.some((e=>null!=e.match(/^serial/i)))?i:void 0}catch{return}}t.readInfo=k;const C=(0,o.defer)((()=>(0,m.thenMap)(k(),(e=>(0,x.toUID)(x.S.lc,e.join(",")))))),O=/o\.e\.m\./i;async function I(e){return(0,r.uniq)(await Promise.all((0,t.k)()[e].map((e=>(0,v.readFileMaybe)(e,S.LogLevels.trace))))).map(d.toS).filter((e=>(0,n.notBlank)(e)&&null==e.match(O)))}async function F(){return P.isLinux?(await I("lm")).map((e=>(0,x.toUID)(x.S.lm,e))):void 0}async function L(){return P.isLinux?(await I("lp")).map((e=>(0,x.toUID)(x.S.lp,e))):void 0}async function A(){return P.isLinux?(await I("lb")).map((e=>(0,x.toUID)(x.S.lb,e))):void 0}async function R(){if(P.isMac)try{return(0,l.entries)(await async function(){const e=await(0,p.stdout_)((0,t.k)().i,(0,t.k)().ia,{timeoutMs:5*s.secondMs}),i=e.match(/uuid" = "([a-z\d-]{12,})"/i)?.[1],r=e.match(/SerialNumber" = "([a-z\d-]{10,})"/i)?.[1];return{mp:i,ms:r}}()).map((([e,t])=>(0,x.toUID)(e,t)))}catch(e){return void D().warn((0,t.k)().i+" failed",e)}}async function N(){return(await M.PowerShell.instance().executeJson((0,t.k)().w))?.MachineGuid}async function j(){return P.isWin?(0,x.toUID)(x.S.wm,await N()):void 0}t.win_machineGuid_=N;const B=(0,o.defer)((()=>(0,x.toUID)(x.S.cm,(0,E.cpuInfo)()[0].model)));async function z(){return P.isLinux?(0,x.toUID)(x.S.bm,(0,r.compactBlanks)(await I("bm")).map((e=>e.trim())).join("\n")):[]}async function V(){return(0,x.toUID)(x.S.li,await((0,w.LibraryUIDStore)()?.readUid_()))}async function W(){return(0,x.toUID)(x.S.si,await((0,w.SystemUIDStore)()?.readUid_()))}function U(){return(0,b.networkMacAddresses)().map((e=>(0,x.toUID)(x.S.nm,e)))}async function H(){return(0,c.toA)(await(0,_.volumes)()).map((e=>(0,x.toUID)(x.S.vl,e.uuid)))}const q=new Set;t.sids=async function({timeoutMs:e}){const t=Date.now(),i=[B,C,R,V,W,z,F,L,A,j,U,H],r=(0,a.flatten)(await(0,m.someOrTimeout)(i,{timeoutMs:e})).filter(u.isString);for(const e of r)q.add(e);return D().tap({msg:"sids()",result:(0,x.sortUids)([...q,...r]),meta:{timeoutMs:e,elapsedMs:Date.now()-t}})},t.addSids=function(e){if((0,h.isTest)())for(const t of e)q.add(t)},t.clearSids=function(){(0,h.isTest)()&&q.clear()}},48132:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserTimeoutMs=void 0;const r=i(42659);t.UserTimeoutMs=7*r.secondMs},34474:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allRecentLogEntries=t.recentLogFiles=void 0;const r=i(40958),n=i(42659),s=i(41400),o=i(96249),a=i(68708),l=i(34666),u=i(20214),c=i(71371),d=i(50213),f=i(42638),h=i(31562),m=i(98314),p=i(89968),g=i(28874),y=i(4904),v=i(57902),w=i(89241),S=i(83954);function b(e=10*n.minuteMs){const t=Date.now()-e;return(0,u.thenMap)(p.DirectoryEntry.for(g.Settings.logDir.valueOrDefault),(e=>e.filterDescendantFiles((async e=>[".log",".log.gz"].includes(e.ext)&&(0,l.gte)(e.mtimeMs(),t)))))}t.recentLogFiles=b,t.allRecentLogEntries=async function(e=50){(0,S.writeRecentLogEntries)();const t=(0,a.fromEntries)(v.LogLevels.values.map((t=>[t,new c.BoundedGreatestSet(e,y.logEntrySorter)]))),i=Date.now()-n.hourMs,p=(0,d.mkLogger)("allRecentLogEntries()");return await(0,u.thenMap)(b(),(e=>(0,f.withBoundedConcurrency)({name:"allRecentLogEntries()",laters:e.map((e=>async()=>{try{const o=[],a=new w.LogReader(e,(e=>o.push(e)));for(await(0,h.untilTrue)((()=>a.ready()),{timeoutMs:10*n.secondMs});!a.complete()&&!a.hasErrors();){const e=a.shift();null==e?await(0,s.delay)(5):e.ts>i&&t[e.l]?.add(e)}(0,r.isNotEmpty)(o)&&(p.warn("Read error(s) for "+e,o),o.some((e=>"Z_BUF_ERROR"===e.code||(0,m.errorToS)(e).includes("unexpected end of file")))&&(0,l.lt)(e.mtimeMs(),Date.now()-n.minuteMs)&&(p.warn("Unlinking corrupt logfile "+e),await e.unlink_()))}catch(t){p.warn("Failed to read entries from "+e,t)}}))}))),(0,o.flatten)((0,a.values)(t).map((e=>e.vacuum()))).sort(((e,t)=>(0,l.cmp)(e.ts,t.ts)))}},49794:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),n=i(19851),s=i(40958),o=i(22573),a=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),f=i(66184),h=i(93475),m=(0,n.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,o.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,h.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,f.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,s.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),n=i(23560),s=i(66184),o=i(72210);class a{log(e,t,i,r){this.enabled(e,t)&&(0,o.pushLogEntries)({ts:Date.now(),l:e,from:(0,n.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=a,a.instance=(0,r.lazy)((()=>new a))},14593:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),n=i(22573),s=i(26905),o=i(55835),a=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),f=i(76740),h=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new f.Abortable,this.context=(0,n.toNotBlank)(e)??(0,s.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,h.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,a.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),n=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:n}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,o.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,a.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),n=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof n.LogWriter))}},28981:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),n=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new n.PlaintextLogFormatter))},31256:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(41400),a=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),f=i(23560),h=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,f.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,s.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,o.later)((()=>f.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,h.stripAnsiEsc)((0,n.uniq)((0,n.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,a.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,a.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){"use strict";var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const s=i(77030),o=i(19851),a=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),f=i(31586),h=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),v=i(31256),w=i(28538),S=(0,o.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),b=String.fromCharCode(0);t.logBroadcaster=(0,o.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,f.toInt)(t);return(0,a.blank)(e)||!(0,f.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&S().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),h.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,s.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{S().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){S().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),n(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,s){if(this.enabled(e,t))try{const o=this.socket;null==o?n(this,r,"f").call(this):o.write(this.logFormatter.format(e,t,i,s)+b)}catch(r){S().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:s,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),n=i(42659),s=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??s.Settings.logDir.valueOrDefault,(0,n.fmtIsoDate)(t??new Date))}},4904:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),n=i(31586),s=i(51926),o=i(57902);t.isLogEntry=function(e){return null!=e&&(0,n.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&o.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),n=i(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,n.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,n.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new s(n.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>n.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,n.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){"use strict";var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),f=i(28874),h=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=f.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,n.set(this,[]),s.set(this,(0,l.lazy)((()=>{a(this,n,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=h.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:a(this,n,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>a(this,s,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=a(this,r,"m",o).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=a(this,r,"m",o).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},n=new WeakMap,s=new WeakMap,r=new WeakSet,o=function(e){if(null==e||0===a(this,n,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return a(this,n,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),n=i(31586),s=i(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const o=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??o},t.levelGte=function(e,i){return(0,n.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const a=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return a.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),n=i(68708),s=i(20214),o=i(51926),a=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,f=4){if(null==i)return null;if(f<0)return"…";if((0,o.isString)(i)||Buffer.isBuffer(i))return(0,o.ellipsize)(i.toString(),256,32);if((0,a.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,f-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,f-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),f-1);if((0,s.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const a=(0,u.mapNullEntries)(i,((t,i)=>e(i,f-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,n.keys)(i),(0,n.keys)(a));return(0,r.isNotEmpty)(c)&&(a["…"]="omitted: "+(0,o.ellipsize)(c.join(", "),128,32)),a}return i}},89241:function(e,t,i){"use strict";var r,n,s,o,a,l,u=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogReader=void 0;const d=i(73024),f=i(38522),h=i(4001),m=i(14977),p=i(33456),g=i(92322),y=i(4904),v=i(98192);t.LogReader=class{constructor(e,t){if(r.add(this),this.f=e,this.start=Date.now(),this.lines=new g.SortedSet(y.logEntrySorter),n.set(this,!1),s.set(this,!1),o.set(this,!1),this.from=(0,h.stripCopySuffixFromName)(e.name),this.fileStream=(0,d.createReadStream)(e.nativePath,{autoClose:!0}),!(0,m.isExtOrCompressedExt)(e.ext,".log"))throw new Error(e+" is not a logfile");this.stream=(e.ext.toLowerCase().endsWith(".gz")?this.fileStream.pipe((0,f.createGunzip)()):e.ext.toLowerCase().endsWith(".br")?this.fileStream.pipe((0,f.createBrotliDecompress)()):this.fileStream).pipe(new p.LineReader).on("error",(e=>{t(e),u(this,o,!0,"f")})),this.stream.on("data",c(this,r,"m",a).bind(this)),this.stream.on("close",(()=>{this.fileStream.resume(),u(this,n,!0,"f")})),this.stream.on("end",(()=>{u(this,n,!0,"f")}))}toString(){return"LogReader("+this.f.nativePath+")"}status(){return{hasErrors:c(this,o,"f"),ended:c(this,n,"f"),destroyed:this.stream.destroyed,lines:this.lines.length,paused:c(this,s,"f")}}hasErrors(){return c(this,o,"f")}get ended(){return c(this,n,"f")}ready(){return this.ended||this.lines.length>32}complete(){return this.ended&&0===this.lines.length}peek(){return this.ready()?this.lines.at(0):void 0}shift(){const e=this.lines.shift();return null!=e&&c(this,r,"m",l).call(this),e}shiftLte(e){const t=this.lines.shiftLte(e);return t.length>0&&c(this,r,"m",l).call(this),t}},n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(e){if(null===e)u(this,n,!0,"f");else{const t=(0,v.chunkToLogEntry)(e);null!=t&&this.lines.add({...t,from:this.from}),this.lines.length>10240&&!c(this,s,"f")&&(this.fileStream.pause(),u(this,s,!0,"f"))}},l=function(){this.lines.length<1024&&c(this,s,"f")&&(this.fileStream.resume(),u(this,s,!1,"f"))}},24068:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),n=i(76760),s=i(1708),o=i(87997),a=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),f=i(34666),h=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),v=i(22277),w=i(25764),S=i(38836),b=i(99331),P=i(42638),M=i(76596),_=i(98314),E=i(89968),T=i(29882),x=i(28874),D=i(28981),k=i(20839),C=i(21727),O=i(66184),I=i(57902),F=i(72210),L=i(98192);function A(e){const t=(0,D.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=A;class R extends S.EndableWrapper{constructor(e=void 0,t=A){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,a.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,x.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,T.mkdirp_)(e),this.root=await E.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=n.sep+(0,p.serviceName)()+"-"+s.pid+"-",s.stdout.writableFinished||((0,F.setLogTailEnabled)(!0),this.flushTimeout=(0,o.setInterval)((()=>this.flush()),k.DefaultLogFlushMs/2),this.scanTimeout=(0,o.setInterval)((()=>this.scan()),u.minuteMs),s.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,F.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,b.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,O.ifLog)(I.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,n.join)(e,i))}))}catch(t){return void(0,O.ifLog)(I.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,_.errorToS)(t))))}}))}async scan(e=!1){if((0,b.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,h.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,M.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,b.ending)()||this.ended)return;const t=(0,C.datedLogDir)(this.root.nativePath);try{await(0,T.mkdirp_)(t),this.watchDir(t)}catch(e){(0,O.ifLog)(I.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,_.errorToS)(e))))}(0,b.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,F.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,o.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,o.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,F.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await E.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,f.gte)(r,i))return;await(0,h.thenMap)((0,L.readLogEntries)(e,{start:r,end:i}),(e=>(0,F.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,O.ifLog)(I.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,_.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,a.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),n=i(82328),s=i(28981),o=i(20839),a=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(a.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,n.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*o.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const f=d(i(73024)),h=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),v=i(31586),w=i(409),S=i(23560),b=i(81168),P=i(78406),M=i(25764),_=i(20197),E=i(14977),T=i(36868),x=i(28874),D=i(32105),k=i(20839),C=i(21727),O=i(66184),I=i(93475),F=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class L extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*k.DefaultLogFlushMs),rank:M.EndableRanks.logger,unref:!0,onEnd:()=>c(this,n,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,n.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:D.ConsoleLogger.instance(),flushEveryMs:k.DefaultLogFlushMs,processName:S.processName,logFilter:O.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",s).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const n={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(n.meta=(0,I.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(n)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,F.recentLogEntries)()),(0,F.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=L,n=new WeakMap,r=new WeakSet,s=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),n=e.splice(0,i);this._linesSinceRotate+=n.length,t.write(n.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},o=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},a=function(e){return t=>(c(this,r,"m",o).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,b.stripAnsiEsc)(this.logOpts.processName()),t=await(0,_.ensureNewNativePath_)({nativePath:(0,h.join)((0,C.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=f.default.createWriteStream(t).on("error",c(this,r,"m",a).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,T.endStream)(e.stream),x.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,E.gzip_)(e.nativePath))}catch(e){c(this,r,"m",o).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),n=i(40958),s=i(55835),o=i(68708),a=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,o.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,n.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),n=i(84542),s=i(4001),o=i(13047),a=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,a.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,s.stripCopySuffixFromName)(e.name),r=[],a=await(0,o.zcat)(e.nativePath,t);if(null!=a)for(const e of(0,n.splitLines)(a)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),n=i(76790),s=i(68708),o=i(89788),a=i(57902);t.SentLogLevels=(0,r.lazy)((()=>a.LogLevels.values.filter((e=>e!==a.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,s.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new o.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,s.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,s.values)(l()))e.push(...t.toA());return(0,n.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),n=i(41400),s=i(55835),o=i(37975),a=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),f=i(28874),h=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),v=i(66184),w=i(28538),S=i(24068),b=i(43705),P=i(51879);function M(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),_();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new b.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||f.Settings.logStdout.valueOrDefault||f.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,s.map)((0,y.logBroadcaster)(),(e=>i.push(e))),a.rootLoggers.set(i),f.Settings.tailLogs.valueOrDefault&&S.LogTail.instance()}function _(){const e=f.Settings.logColor.valueOrDefault;(0,o.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new h.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=M,t.setupLogFormatter=_,(0,n.later)((()=>{f.Settings.logStdout.watchLater(M),f.Settings.logDir.watchLater(M),f.Settings.tailLogs.watchLater(M),f.Settings.logColor.watchLater(_),f.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},83954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeRecentLogEntries=void 0;const r=i(89179);t.writeRecentLogEntries=function(){return(0,r.currentFileLogger)()?.writeRecentLogEntries()}},82647:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const o=i(57975),a=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),f=i(59455),h=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,h.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,o.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,f.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,f.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,r,"m",n).call(this,-1)}get p29(){return s(this,r,"m",n).call(this,-.5)}get p38(){return s(this,r,"m",n).call(this,-.25)}get p69(){return s(this,r,"m",n).call(this,.5)}get p84(){return s(this,r,"m",n).call(this,1)}get p98(){return s(this,r,"m",n).call(this,2)}get p99(){return s(this,r,"m",n).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,a.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,a.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,a.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,n=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),n=i(55835),s=i(31586),o=i(30976),a=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,s.clamp)(0,i,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,n.map2)(e,t,((e,t)=>(0,r.sum)((0,a.zip)(u(e,i),u(t,i)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,o.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),n=this.clampValue(e);let s=0;for(let e=0;eo?(s+=1,i[t]=o):r[t]=o}return s}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let n=0;n(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function f(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;is?(t+=1,n.min=s):n.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=f(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=f,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},31843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const r=i(76790);function n(e,t,i=.5){return(1-i)*e+i*t}t.lerp=n,t.lerp2d=function(e,...t){const i=(0,r.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[s,o]=(0,r.sortBy)(i,(e=>e.x)),a=o.x-s.x,l=(e-s.x)/a;return n(s.y,o.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},55222:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),n=i(22573),s=i(55835),o=i(32639),a=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,n.blank)(e))return;const t="-"===(e=(0,o.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),n=this.normalizeToken(t);return r.length>=i&&r===n}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const r=i(31586),n=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,r.toInt)(e)]??(0,n.toS)(e)}},17921:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),n=i(65713);function s(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=s,t.safeUUID=function(){return(0,n.decuss)(s)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const a=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),f=i(77377),h=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function v(e,t){let i=0,r=0;for(const n of e){if(null!=n){const e=t(n,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=v;class w{constructor(){r.set(this,0),n.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(o(this,n,null==s(this,n,"f")?e:s(this,n,"f")*s(this,r,"f")/(s(this,r,"f")+1)+e/(s(this,r,"f")+1),"f"),o(this,r,(t=s(this,r,"f"),++t),"f"))}get mean(){return s(this,n,"f")}}function S(e){const t=new w;for(const i of e)t.push(i);return t.mean}function b(e){const t=S(e);if(null==t)return;let i=0,r=0;for(const n of e)(0,u.isNumber)(n)&&(r++,i+=(n-t)*(n-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function M(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+o*(e-n)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=S(t);if(null!=i){const e=(t.length-1)/2,r=v(t,((t,r)=>(t-i)*(r-e))),n=v(t,(e=>(e-i)**2));return 0===n?0:r/n}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new h.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=M,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(M(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,a.isEmpty)(e)&&(0,a.isEmpty)(t)?0:(0,u.finiteOrElse)((0,f.intersection)(e,t).size/(0,f.union)(e,t).size,void 0)}},49076:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const n=r(i(48161)),s=i(19851),o=i(22573),a=i(41400),l=i(81168),u=i(28874);t.hostname=(0,s.lazy)((()=>u.Settings.hostname.value??n.default.hostname())),(0,a.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,o.blank)(e)&&!(0,o.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??n.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},43205:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemUserAgent=t.simpleUserAgent=t.userAgent=void 0;const r=i(72993),n=i(17344),s=i(96175),o=i(37805),a=i(81674),l=i(28874);function u(){return r.SimpleAppName+o.version}async function c(){return u()+" ("+(0,s.osFullName)()+") "+(0,n.EditionType)().toLowerCase()+"/"+await(0,a.t)()}t.userAgent=async function(){return l.Settings.allowUserAgent.valueOrDefault?c():u()},t.simpleUserAgent=u,t.systemUserAgent=c},72308:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLocalhost=t.isLoopback=t.myExternalIp4Addresses=t.myExternalIpAddresses=t.networkMacAddresses=t.myIpAddresses=void 0;const r=i(48161),n=i(19851),s=i(40958),o=i(22573),a=i(42659),l=i(96249),u=i(31586),c=i(68708),d=i(50213),f=i(81168);function h(){return(0,t.myIpAddresses)().filter((e=>!g(e)))}t.myIpAddresses=(0,n.lazy)((()=>(0,s.uniq)((0,s.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.address))))),a.minuteMs),t.networkMacAddresses=(0,n.lazy)((()=>(0,s.uniq)((0,s.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.mac)))).filter((e=>"00:00:00:00:00:00"!==e))),a.minuteMs),t.myExternalIpAddresses=h,t.myExternalIp4Addresses=function(){return h().filter((e=>!e.includes(":")))};const m=(0,n.lazy)((()=>(0,d.mkLogger)("net.ip"))),p=[/^(?:::ffff:)?127\.\d{1,3}.\d{1,3}.\d{1,3}$/i,/^::1$/];function g(e){return(0,o.notBlank)(e)&&(127===function(e){const t=e.split(".").map((e=>(0,u.toInt)(e)));return 4!==t.length||t.some((e=>null==e||!(0,u.within)(0,255,e)))?void 0:t}(e)?.[0]||p.some((t=>null!=t.exec(e))))}t.isLoopback=g,t.isLocalhost=function(e){return m().tap({msg:"isLocalhost",level:"info",result:!(0,o.blank)(e)&&((0,t.myIpAddresses)().includes(e)||(0,t.myIpAddresses)().includes((0,f.stripPrefix)(e,"::ffff:"))||g(e)),meta:{address:e}})}},96128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),n=i(19851),s=i(22573),o=i(42659),a=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),f=i(50213),h=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),v=i(34102),w=i(26293),S=new RegExp("^"+w.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==S.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const b=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=b.exec(e)}function M(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,h.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=M,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,s.blank)(e)){if(null!=M(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void _().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs});const _=(0,n.lazy)((()=>(0,f.mkLogger)("net.nslookup")));(0,a.later)((()=>(0,v.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=M(e)?r.promises.reverse(e):r.promises.resolve4(e),5*o.secondMs);if(t===c.Timeout)return _().info("nslookup("+e+"): timeout"),e;const i=t.find(s.notBlank);return null==i?(_().warn("No name found for "+e),e):i}catch(t){return _().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,s.blank)(e)&&!(0,s.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),n=i(42659),s=i(31586),o=i(97790),a=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),f=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*n.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:f.ShortCommandTimeoutMs,clearEveryMs:10*n.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,s.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,o.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,a.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:f.ShortCommandTimeoutMs,clearEveryMs:10*n.minuteMs})},78330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const r=i(40958),n=i(22573),s=i(45599),o=i(59455),a=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),f=i(63870),h=(0,s.defer)((()=>(0,a.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,o.toA)(await async function(e){if(!(0,l.hasApt)()||(0,n.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,f.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return h().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,r.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,n.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,f.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(h().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),n=i(38639),s=i(19851),o=i(59958),a=i(43334);t.isDocker=(0,s.lazy)((()=>a.isLinux&&((0,n.toBoolean)(process.env[o.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),n=i(19851),s=i(54993);t.isPacked=(0,n.lazy)((()=>!(0,s.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const r=i(45599),n=i(50213),s=i(84777),o=i(68284),a=i(63870),l=i(43334),u=(0,r.defer)((()=>(0,n.mkLogger)("platform.Pacman")));t.hasPacman=(0,r.defer)((()=>l.isLinux&&(0,o.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,s.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,a.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const n=r(i(48161)),s=r(i(1708)),o=i(22573),a=i(38639),l=i(59958),u=n.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,a.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,a.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,o.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===n.default.arch(),t.isArm=null!=/^arm\b/i.exec(n.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,o.notBlank)(s.default.env.APPIMAGE)||(0,o.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,o.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,a.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const n=r(i(73024)),s=i(19851),o=i(43334);function a(e="/proc/cpuinfo"){if(o.isWin||o.isMac)return!1;try{return null!=n.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=a,t.isRaspberryPi=(0,s.lazy)((()=>o.isLinux_arm&&a())),t.procDeviceModel=(0,s.lazy)((()=>{try{return o.isLinux?n.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},45643:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),n=i(59455),s=i(31562);t.existingPids=function(e){return(0,n.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){"use strict";var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),f=u(i(1708)),h=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(97790),w=i(59455),S=i(54993),b=i(54557),P=i(19851),M=i(50213),_=i(88158),E=i(409),T=i(78406),x=i(25764),D=i(99331),k=i(56519),C=i(46292),O=i(8769),I=i(83278),F=i(32144),L=i(29882),A=i(43334),R=i(24399),N=i(58261),j=(0,P.lazy)((()=>(0,M.mkLogger)("proc.Pids"))),B=10*p.secondMs;function z(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,F.isJsonExt)(t)&&(0,L.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))j().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,E.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{j().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??A.isWin,r=await this.pidfiles(),n=await this.pids(r??[]);if((0,h.isEmpty)(n))return j().info("killOldProcs(): no pidfiles"),[];const s=[],o=[],a=await(0,N.pidInfos)(n);if(null!=a){for(const n of r){const r=await n.readJson();if(null==r){j().warn("killOldProcs(): failed to read pidfile "+n.base),await n.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){j().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+n.base,{json:r,pid:l}),await n.unlink("debug");continue}const u=a.find((e=>e.pid===l));if(null==u||!z(r,u)){j().debug("killOldProcs(): pid no longer present: unlinking "+n.base,{json:r,pidEntry:u}),await n.unlink("debug"),s.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(j().info("killOldProcs(): killing",{reason:d,json:r}),o.push(W(l,i,!1)),s.push({...r,...u}))}return o.length>0&&await Promise.allSettled(o),s}(0,O.onError)("Pids.killOldProcs(): failed to get process information")}}),o.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const o=e.pid;if(!(0,y.gt0)(o))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(o)?(i&&a(this,n,"f").delete(l),a(this,n,"f").getOrSet(l,(async()=>{const i=a(this,r,"m",s).call(this,e.pid),n=(0,v.opt)((0,_.Try)((()=>(0,L.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),o=t.getTime(),l={...e,cmd:n,startTime:o};return await i.writeJson_(l),j().debug("addPid() wrote "+i,l),i}))):(a(this,n,"f").delete(l),void j().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==f.default.pid}))}async pids(e=this.pidfiles()){return(0,h.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=a(this,r,"m",s).call(this,e);return(0,k.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{j().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==a(this,o,"f")||a(this,o,"f").ended)&&l(this,o,new T.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:x.EndableRanks.first}),"f"),a(this,o,"f")}cancelInterval(){a(this,o,"f")?.end(),l(this,o,void 0,"f")}}t.Pids=U,n=new WeakMap,o=new WeakMap,r=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,C.configDir)(),(e=>new U(I.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const n=i(31421),s=i(48161),o=r(i(1708)),a=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),f=i(59455),h=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),v=i(84968),w=i(48963),S=i(56519),b=i(84777),P=i(8103),M=i(45879),_=i(43334),E=i(24399),T=i(45643),x=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function D(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function k(e){if(_.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,M.readFileMaybe)("/proc/"+i+"/stat")));return x().tap({msg:"pidInfoProc",result:(0,a.compact)(t)})}(e);const t=(0,T.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,_.isWin?F:N)).filter((e=>D(e)&&t.includes(e.pid)));return x().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=D,t.pidInfo=async function(e){return(0,S.thenMap)(k([e]),(t=>(0,f.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,a.isEmpty)(e)?[]:(0,S.thenMap)((0,T.existingPids)(e),(t=>{const i=[o.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=k;const C="Get-Process",O="| Select-Object -Property Id,ProcessName,StartTime";function I(e){return(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).join(",")}async function F(e){if(E.PowerShell.instance().ended)return R(e);const t=[C,"-Id",I(e),"-ErrorAction SilentlyContinue",O].join(" ");return(0,S.thenMap)(E.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const L={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},A=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,a.isNotEmpty)(e)){const i=(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",A.join(","));const i=await(0,b.stdoutResult_)((0,P.wmic)(),t,L),r=(0,d.onlyReqValued)((0,p.parseFixed)(A,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,h.toS)(e.CommandLine)}))));return r.find((e=>e.pid===o.default.pid))||r.push({pid:o.default.pid,start:new Date(v.StartTs),cmd:"node "+o.default.title}),r}async function N(e){return t=(await(0,b.stdoutResult_)("ps",["-p",I(e),"-wwwo","pid,lstart,command"],{...L,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,h.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const j=(0,g.lazy)((()=>{try{if(_.isLinux)return(0,c.toGt0)((0,n.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){x().warn("clk_tck failed",{error:e})}return 100})),B=(0,g.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),z=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=z.exec((0,h.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,n=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(n)?{pid:i,cmd:r,start:new Date(B()+n/j()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),n=i(22573),s=i(31586),o=i(29882),a=i(97352);t.progressEvtToS=function(e){const t=(0,n.blank)(e.path)?null:(0,o.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,s.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,n.notBlank)(e.op)&&(0,a.within)(0,100,e.pct)}},41944:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),n=i(42659),s=i(31586),o=i(12089),a=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new a.TTLMap(15*n.secondMs))),t.recentDone=(0,r.lazy)((()=>new a.TTLMap(2*n.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,s.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,o.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),n=i(31586),s=i(409),o=i(78406),a=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class f extends o.EndableInterval{constructor(e,t,i,n=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:n,rank:a.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=n,this.start=Date.now(),this.onInterval=(0,s.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,n.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,n.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=f},24399:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),n=i(19851),s=i(22573),o=i(42659),a=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),f=i(50213),h=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),v=i(99331),w=i(56519),S=i(31562),b=i(84777),P=i(34102),M=i(43334),_=i(28874),E=i(63870),T="{ready}",x=" | ConvertTo-Json -Compress";function D(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=D,(0,a.later)((()=>(0,P.ee)().on("clearCache",(()=>k.instance.prior()?.clearMockResults()))));class k extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",_.Settings.powerShellArgs.values),logger:()=>(0,f.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${T}"}`,...(0,s.mapNotBlankOr)(_.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:T,fail:"Error",exitCommand:"exit",maxProcs:_.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,E.commandTimeoutMs)(),maxIdleMsPerProcess:o.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),_.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(_.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,x),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,h.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,n)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,n)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,x),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+D(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=k,k.instance=(0,n.lazy)((()=>{if(!M.isWin)throw new Error("PowerShell isn't available on this platform");return new k})),t.checkPowerShell_=async function(){const e=k.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,E.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),n=i(38639),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toBoolean})}}t.BooleanSetting=o},90536:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),n=i(31586),s=i(97790),o=i(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=a},75164:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(97790),o=i(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(r.notBlank).flatMap(n.toInt).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,n.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=a},10546:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),n=i(22573),s=i(45599),o=i(50213),a=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,s.defer)((()=>(0,o.mkLogger)("settings.CronSetting")));function f(e){try{const t=(0,a.trimQuotes)(e);return void((0,n.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function h(e,t,i){try{return(0,n.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:f,...e})}cron(e){return h(this.name,this.value,e)??h(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),n=i(91655),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,n.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=o;class a extends s.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=a},9945:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toFloat})}}t.FloatSetting=o},74589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toInt})}}t.IntegerSetting=o},86941:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAndArchiveSystemSettingsDir_=t.mergeUserDataDirs_=void 0;const r=i(19851),n=i(59455),s=i(72993),o=i(46292),a=i(95696),l=i(50213),u=i(83179),c=i(28874),d=i(2858),f=i(84438),h=(0,r.lazy)((()=>(0,l.mkLogger)("settings.MergeConfigDirs")));async function m(e,t){let i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+e.baseWithGrandparent+" => "+t.baseWithGrandparent+")");const r=await e.resolve_(),s=await t.resolve_();if(null==r||null==s||s.nativePath===r.nativePath)return void i.info("no-op, missing or same directory",{priorResolvedConfigDir:r?.nativePath,currentResolvedConfigDir:s?.nativePath});if(i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+r.baseWithGrandparent+" => "+s.baseWithGrandparent+")"),!await r.isDirectory())return void i.info("no-op, prior directory doesn't exist");{const e=r.join(f.SettingsToml);if(await e.isNonEmptyFile()){const t=s.join(f.SettingsToml);await(0,d.readSystemSettings)(e),i.info("read prior settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.readSystemSettings)(t),i.info("read current settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.writeSystemSettings_)(t)}}{const e=r.join("licenses"),t=s.join("licenses");for(const r of(0,n.toA)(await e.childFiles())){const e=t.join(r.base);if(await e.notExists())try{await r.copyFile_(e),i.info("Copied license "+r.base)}catch(e){i.warn("Failed to copy license "+r.base,e)}}}const o=s.join("old");try{const e=await r.renameYMDHMS_({subdir:o.nativePath});i.info("merged and archived to "+e)}catch(e){i.warn("Failed to archive to "+o,e)}}t.mergeUserDataDirs_=async function(){const e=(0,o.configDir)();if(null==e)return;const t=a.PosixFile.for(e);for(const e of[t.join((0,s.AppName)()),t.join((0,s.AppName)().toLowerCase()),t.parent().join((0,s.AppName)().toLowerCase())])try{await m(e,t)}catch(i){h().error("Failed to merge "+e+" and "+t,i)}h().info("done")},t.mergeAndArchiveSystemSettingsDir_=m},4175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),n=i(22573),s=i(38639),o=i(42659),a=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),f=i(67958),h=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function v(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function w(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){M(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&v(),y("strictDeduping",e)&&w(),(y("optOut",e)||y("noNetwork",e))&&_()},t.handleDeprecatedSettings=async function(){if((0,s.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,n.blank)(m.Settings.assetPathnameFormat.value)&&(0,n.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*o.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=v,t.setStrictDeduping=w;const S=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],b={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function M(e){for(const t of S)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:b;for(const[e,i]of(0,a.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:h.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:f.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function _(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=M,t.disableExternalNetworkRequests=_},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),n=i(53265),s=i(87652);class o extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,n.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=o},23561:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:n.toFloat})}}t.OptionalFloatSetting=o},69005:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=o},87652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class n extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=n},28283:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),n=i(83556);t.nameFromEnv=function(e){return(0,n.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,n.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const o=i(19851),a=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),f=i(55835),h=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),v=i(40583),w=i(81168),S=i(44198),b=i(96706),P=i(34102),M=i(28283),_=i(81075),E=i(98778),T=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,o.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,r,"m",n).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?s(this,r,"m",n).call(this,e??t)+": "+i:null==this.fromEnv(e)?s(this,r,"m",n).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,f.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,a.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,a.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,M.envFromName)(e),this._keys=(0,a.uniq)([...this._names.map(M.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return _.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,f.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,S.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&b.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,S.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&b.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,f.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],T.WrapComments);function i(e,i){(0,a.isEmpty)(i)||t.push(...(0,w.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],T.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,h.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,w.wrap)(["",e+": "+r],T.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,f.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,E.wrapTomlToLines)({lines:e,wrap:T.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,E.wrapTomlToLines)({lines:e,wrap:T.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,E.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,n=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),n=i(76760),s=i(19851),o=i(40958),a=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),f=i(50989),h=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),v=i(79840),w=i(7282),S=i(12801),b=i(4328),P=i(70488),M=i(84248),_=i(5531),E=i(99315),T=i(34365),x=i(34580),D=i(96706),k=i(50274),C=i(33866),O=i(52086),I=i(48584),F=i(45969),L=i(43334),A=i(24540),R=i(70379),N=i(71300),j=i(33209),B=i(48987),z=i(68268),V=i(61208),W=i(99023),U=i(30577),H=i(1485),q=i(19861),G=i(55111),$=i(30933),J=i(22859),K=i(71988),Z=i(38483),Y=i(90536),X=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),ne=i(9945),se=i(74589),oe=i(844),ae=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),fe=i(58305),he=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new ae.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new fe.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new fe.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Z.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new fe.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>q.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new fe.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>H.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new fe.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:H.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new fe.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>H.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new fe.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>L.isWin?"15m":"0"}),remoteFilesystemTypes:new fe.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new fe.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new fe.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Z.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,F.isDocker)()}),cspReportOnly:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Z.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!L.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>L.isMac?"100ms":L.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new ne.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new he.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new he.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:M.AutoVacuumModes,defaultValue:M.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new he.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:_.CheckpointTypes,defaultValue:_.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new he.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:T.SynchronousModes,defaultValue:T.SynchronousModes.NORMAL}),dbRepairMode:new he.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:E.RepairModes,defaultValue:E.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 1 minute is very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"1m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Y.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Z.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Z.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,F.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:C.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new fe.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Z.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new fe.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new fe.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new fe.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>L.isLinux}),showFileInFolderCommand:new fe.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new fe.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new fe.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Z.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new he.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Z.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Z.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Z.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,x.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Z.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new fe.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Z.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Z.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new he.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,f.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,A.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Z.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Z.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new fe.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Z.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Z.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,$.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new he.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:k.SidecarExts,defaultValue:k.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new fe.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new he.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new ne.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new he.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Z.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Z.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,$.cpuCount)()>=4}),dcrawEmuArgs:new fe.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new fe.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new he.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:O.CropStrategies.attention,strEnum:O.CropStrategies}),videoFrameAtSec:new ne.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Z.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,o.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new fe.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new fe.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,h.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(L.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Y.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new fe.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>j.DefaultIncludedPreviewTags}),disableAllFilters:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Z.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*h.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*h.GB}),validateJpegImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new he.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:I.SharpFailOns.truncated,strEnum:I.SharpFailOns}),validateRawImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>B.DefaultLensMakes}),extraDateTimeFormats:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:oe.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new he.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new ne.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new he.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new he.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:z.KeywordReparentingStrategies.move,strEnum:z.KeywordReparentingStrategies}),rootTagAlbumsAliases:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new fe.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Z.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new fe.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new he.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new he.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,F.isDocker)()}),tagDisplayNameFSLabels:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new fe.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function Se(e){const i=((0,l.blank)(e)?"":e).split(n.delimiter);return(0,F.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,o.uniq)(i).filter(l.notBlank).join(n.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,D.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,a.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),n=i(31586),s=i(7282),o=i(49776),a=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),f=i(96706),h=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),v=i(15674),w=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{w.Settings.configDir.opts.defaultValue=a.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=o.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,f.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(h.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,n.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(22573),a=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),f=i(57924),h=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),v=i(54993),w=i(50213),S=i(81168),b=i(83556),P=i(37805),M=i(87290),_=i(98314),E=i(34102),T=i(83278),x=i(95696),D=i(60865),k=i(4175),C=i(83179),O=i(81075),I=i(28874),F=i(41692),L=i(84438),A=i(32707),R=i(6707),N=i(55018),j=i(10357),B=(0,r.lazy)((()=>(0,w.mkLogger)("settings.SettingsIO")));function z(e){return(0,M.libraryDataDirPosixFile)(e)?.join(L.SettingsToml)}async function V(e=(0,A.systemSettingsFile)()){if(null!=e)return Q(T.BaseFile.for(e))}async function W(){try{return(0,o.toNotBlank)((await(0,R.readTomlFile_)((0,A.systemSettingsFile)()))?.[I.Settings.libraryDir.name])}catch{return}}async function U(){return J((0,A.systemSettingsFile)())}async function H(e){return(0,m.map)(z(e),(e=>J(e)))}function q(){t.libraryHasSettings.refresh()}function G(e){const t=z(e);return B().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:I.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}t.librarySettingsFile=z,t.readSettings=(0,r.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await Y()}),a.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return I.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=U,t.librarySettingsVersion=H,t.maybeUpgradeSystemSettings=async function(){P.version!==await U()&&await Z()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&P.version!==await H()&&await X()},t.libraryHasSettings=(0,r.lazy)((()=>G())),t.libraryHasSettings.unset=()=>{B().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,E.ee)().on("clearCache",q),(0,E.ee)().on("settingsChanged",q),I.Settings.libraryDir.watchLater(q)})),t._libraryHasSettings=G;const $=/^# PhotoStructure v(?\d+\.\d+\.\d+(?:-\S+)?)$/i;async function J(e){if((0,o.blank)(e))return;const t=await T.BaseFile.for(e).firstMatchingLine($);return t?.groups?.version}async function K(e,i){if(null==e)return void B().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),n=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...re("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","-- ","","PhotoStructure v"+(0,t.versionForSettings)())),r.push("","");let n="";for(const e of i){const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==n&&(n=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,E.ee)().emitDebounced("settingsChanged")}(n,i),B().info("writeToml(): wrote settings",{dest:n,file:e,nonDefaults:(0,C.settingsToObj)(i),wip:r}),r){const t=await(0,R.readTomlFile_)(n),i=await(0,R.readTomlFile_)(e);(0,u.eql)(t,i)?(B().info("Equivalent contents",{dest:n,file:e,a:t,b:i}),await n.unlink()):(B().info("Archiving prior, different contents",{dest:n,file:e}),await e.renameYMDHMS_({subdir:"old"}),await n.unwip_())}}async function Z(e=(0,A.systemSettingsFile)()){const t=x.PosixFile.forMaybe(e);return null!=t&&await K(t,(0,I.persistedSystemSettings)()),t}function Y(e){return Q(z(e))}async function X(e){await(0,M.setupLibraryDataDir_)((0,o.firstNotBlank)(e,I.Settings.libraryDir.value));const i=z(e);return B().info("writeLibrarySettings()",{file:i}),null!=i&&(await K(i,(0,I.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function Q(e){if(null==e)return[];const t=B().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await ee(e);return(0,n.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,_.errorToS)(e)),[]}}async function ee(e){const t=B().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,R.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const s=[],o=(0,n.compact)((0,p.entries)(r).map((([e,t])=>{const i=(0,I.getSettingByNameOrKey)(e);if(null==i)s.push(`Failed to import "${e}"${(0,m.mapOr)((0,I.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;s.push(e)}})));return t.info("loaded",{settings:(0,C.settingsToObj)(o),warnings:(0,n.toNotEmpty)(s)}),await(0,k.handleDeprecatedSettings)(),(0,k.handleMetaSettings)(o),{settings:o,warnings:s}}t.versionForSettings=(0,r.lazy)((()=>P.version)),t.writeSystemSettings_=Z,t.writeAllSettings_=function(e){return K(x.PosixFile.for(e),(0,I.persistedSettings)())},t.readLibrarySettings=Y,t.writeLibrarySettings_=X,t._readSettings=Q,t.importFileSettings_=ee;const te=(0,r.lazy)((()=>new Set([I.Settings.noNetwork,I.Settings.httpPort,I.Settings.license,I.Settings.logStdout,I.Settings.logLevel].map((e=>e.key)))));function ie(){for(const e of(0,p.values)(I.Settings))te().has(e.key)||e.unset();(0,E.ee)().emit("settingsChanged")}function re(...e){return(0,d.flatten)(e.map((e=>(0,S.wrap)(e,j.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),I.Settings.libraryDir.unset(),await Z()},t.clearSettings=ie,t.nukeSettings=async function(){ie(),await(x.PosixFile.forMaybe((0,A.systemSettingsFile)())?.unlink("trace")),await(x.PosixFile.forMaybe(z())?.unlink("trace")),(0,E.ee)().emit("clearCache"),F.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...re("",`Welcome to PhotoStructure! These are the settings for version ${(0,D.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...re("","The following settings categories are stored in the system settings.toml:","",...(0,s.sort)([...O.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,s.sort)([...O.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...re("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...re("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const s=`${e.key} or ${e.name}`,o={...e.addToJSON()};(0,n.mapNotEmpty)(e.altKeys,(e=>o.aliases=(0,f.orList)(e)));const a=(0,p.entries)(o).map((([e,t])=>`${(0,S.capitalize)((0,b.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,n.isNotEmpty)(a)&&a.push(""),i.push(...re((0,g.padding)("-",s.length),s,(0,g.padding)("-",s.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...a,`${e.key}=${(0,h.stringify)((0,v.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),n=i(40958),s=i(22573),o=i(98553),a=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,o.stringify)(e)}t._join=c;function d(e){return(0,a.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,n.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,n.compactBlankish)(t.split(e));return[t]}}(e),n.compactBlankish)}t.splitStringArray=d;class f extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,n.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,n.isEmpty)(e)||(this.value=this.toValidValues((0,n.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,n.isEmpty)(this.values)}isNotEmpty(){return(0,n.isNotEmpty)(this.values)}toNotEmpty(){return(0,n.toNotEmpty)((0,n.compactBlanks)(this.values))}}t.StringArraySetting=f},57571:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class n extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=n},72564:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),n=i(98553),s=i(55835),o=i(58305);class a extends o.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,n.stringify)((0,r.uniq)(e)))),fromEnv:t=>{return i=t,n=e.strEnum,(0,r.compact)((0,o.splitStringArray)(i)?.map((e=>n.getCI(e))));var i,n},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=a},80372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),n=i(81168),s=i(83179);class o extends s.Setting{constructor(e){super({toEnv:a,fromEnv:a,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function a(e){return null==e?void 0:(0,n.trimQuotes)(e)}t.StringSetting=o},32707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),n=i(55835),s=i(46292),o=i(84438);t.systemSettingsFile=function(){return(0,n.map)((0,s.configDir)(),(e=>(0,r.join)(e,o.SettingsToml)))}},80496:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),n=i(44652),s=i(22573),o=i(76850),a=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),f=i(98778);function h(e){return t=(0,o.debom)(e),(0,s.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?h((0,n.readFileSync)(t)):void 0}catch(e){return void(0,a.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>h(await(0,n.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,n.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,f.stringifyToml)(t)))}},98778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),n=i(96249),s=i(98553),o=i(68708),a=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const n=e+" = "+(0,s.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[n]:(0,a.wrap)(n.split("\n"),i)}t.stringifyToml=function(e){return(0,n.flatten)((0,o.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,a.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},10357:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const r=i(54993),n=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=o(e[t]);if(null!=i)return i}};const s=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function o(e){const t=(0,n.extractFloat)(e);if(null==t)return;const i=(0,r.toS)(e).toLowerCase();for(const e of s)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),n=i(81168);t.bname=function(e,t=!0){let i=(0,n.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,n.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const r=i(77988),n=i(19851),s=i(40958),o=i(76790),a=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),f=i(31586),h=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),v=i(81168),w=i(76596),S=i(79842),b=i(66649),P=i(21330),M=i(98725),_=i(928),E=i(54261),T=i(89724),x=i(17415),D=i(88600),k=i(51275),C=i(29882),O=i(17217),I=i(68284),F=i(57902),L=i(28874),A=i(65162),R=i(71300),N=i(14036),j=i(61424),B=(0,n.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function z(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,h.isObject)(e)&&(0,a.notBlank)(e.nativePath)&&(0,S.isDated)(e.date)&&(0,a.notBlank)(e.src)}t.capturedAtSrcFromTags=z,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class U{static fromAssetFile(e){return(0,d.map)((0,T.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>U.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof U?e:W(e)?new U(e):void 0}constructor(e){var t;this.nativePath=(0,O.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,f.toGt0)(e.local)??(0,T.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,S.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(L.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,b.datedToMillis)(e.mtime)??(0,I.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:U.name,...(0,h.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,M.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,x.fmtOffsetMinutes)});return null==t?void 0:new U({...e,date:t})}spread(e){return new U({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,x.fmtOffsetMinutes)(this.offset)}get isFromTags(){return z(this.src)}get isInferred(){return!z(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,T.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,w.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,k.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,E.hasTime)(this.date)}hasMillis(){return(0,f.gt0)((0,_.getMillisecond)(this.date))}toMillis(){return(0,b.datedToMillis)(this.date)}get isValid(){return(0,D.isValidDate)(this.date)}get zoneName(){return(0,r.offsetMinutesToZoneName)(this.offset)??(0,k.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,x.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?L.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,S.datedToStartDateTime)(this.date)??(0,S.datedToDateTime)(this.date);if(null!=i)return{start:(0,T.datedToLocal)(i.minus(t)),end:(0,T.datedToLocal)(i.plus(t))};B().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:L.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),r=Math.max(t,e.fuzzyPrecisionMs());return B().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,S.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:r}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:r}})}}function H(e,t){if(null==e)return;const i=(0,s.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>U.for(e))));for(const r of t){let t=e[r],n=r;if((0,D.isValidDate)(t)){if((0,x.isValidZone)(e.tz)&&(!(0,k.hasZone)(t)||R.OverrideUTCZoneTags.includes(n))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,a.blank)(e.tzSource)?"":" from "+(0,v.stripPrefix)(e.tzSource,"from ");n+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,T.datedToLocalSec)(t),date:t,src:n,precisionMs:(0,S.datedToPrecisionMs)(t),rawValue:e[r]?.rawValue})}}const r=(0,p.leastBy)(i,(e=>(0,S.datedToStartTs)(e.date)));if(null==r)return;const n=i.filter((e=>(0,u.eql)(e.date,r.date)||e.precisionMs<=r.precisionMs&&(0,S.datedOverlap)({a:e.date,b:r.date,aPrecisionMs:e.precisionMs,bPrecisionMs:r.precisionMs}))),o=(0,p.leastBy)(n,(e=>[Math.floor(e.localSec/1e6),(0,k.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return B().debug("capturedAtFromTags()",{least:r,overlapsWithLeast:n,earliest:o}),o}function q(e,t){if(L.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,s.uniq)([(0,A.bname)(e,!0),(0,A.bname)(e,!1)])){const e=(0,M.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,S.datedToPrecisionMs)(e),l.secondMs])}}}function G(e){if(L.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,M.extractDateFromPath)(e.pathsForDateParsing)}}async function $(e){if(L.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=U,t.bestCapturedAt=function(e){const t=(0,o.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const r=await e.mtimeMs();function n(t,i){return W(i)?U.for(i):null!=i&&null!=i.date&&(0,D.isValidDate)(i.date)?U.for({nativePath:e.nativePath,date:i.date,local:(0,T.datedToLocal)(i.date),src:(0,v.uniqPath)([t,i.src]),mtime:r,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const s=function(e,t){return null==e||t||!L.Settings.usePathsToInferDates.valueOrDefault||!L.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,C.containedByNativePath)({ancestor:L.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),o=n("tags",H(t,L.Settings.capturedAtTags.values))??(i?void 0:n("siblings",await(0,j.inferCapturedAtFromSiblings)(e)))??n("tags",H(t,L.Settings.capturedAtTagsFallback.values))??(s?void 0:n("bname+stat",await(0,j.extractStatBname)(e)))??(s?void 0:n("path+stat",await(0,j.extractStatPathTime)(e)))??(i?void 0:n("siblings",await(0,j.inferCapturedAtFromSiblings)(e)))??(s?void 0:n("bname",q(e,t)))??(s?void 0:n("path",G(e)))??(L.Settings.useStatToInferDates.valueOrDefault?n("stat",await $(e)):void 0);return B().tap({level:F.LogLevels.debug,msg:"extractCapturedAt()",result:o})},t.capturedAtFromTags=function(e){return H(e,L.Settings.capturedAtTags.values)},t.capturedAtFromBasename=q,t.capturedAtFromPath=G,t.capturedAtFromStat=$},70379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const r=i(31586),n=i(97352),s=i(95696),o=i(47783),a=i(16170);function l(e){if(null!=e&&(0,a.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,r.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,n.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=s.PosixFile.for(e);return l(await(0,o.readRawTags)(t,!1))}},47783:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const n=i(77988),s=r(i(76760)),o=r(i(1708)),a=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),f=i(23838),h=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),v=i(12168),w=i(56038),S=i(4867),b=i(36557),P=i(98247),M=i(21330),_=i(98725),E=i(23467),T=i(88561),x=i(95696),D=i(17217),k=i(16287),C=i(50213),O=i(17921),I=i(7282),F=i(88158),L=i(23560),A=i(28874),R=i(12089),N=i(45255),j=i(81168),B=i(63870),z=i(15674),V=i(28544),W=i(43207),U=i(75767),H=i(12788),q=i(80495),G=i(14036),$=i(67083),J=i(3432),K=i(28630),Z=i(15912),Y=i(30748),X=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),re=i(61424),ne=i(8791),se=(0,a.lazy)((()=>(0,C.mkLogger)("exiftool.ExifTool")));let oe=!1;t.addInstanceIdsToTags=function(e){oe=e},t.setExifToolProcs=function(e){return A.Settings.exiftoolProcsPerChild.envValue=e,ue()};const ae=(0,a.lazy)((()=>new b.BatchClusterObserver("ExifTool",new n.ExifTool({useMWG:A.Settings.useMWG.valueOrDefault,backfillTimezones:A.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:A.Settings.defaultVideosToUTC.valueOrDefault,...(0,b.batchClusterOptions)((0,I.isTest)()?8:(0,L.isSyncService)()?A.Settings.exiftoolProcsPerChild.value??(0,z.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=ae();return e.ended?ae.refresh():e}function ue(e=!1){return(0,d.map)(ae.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,S.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(ae.prior(),(e=>e.ended?void 0:(0,S.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,B.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,a.lazy)((()=>new T.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,a.lazy)((()=>new T.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,h.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,D.toNativePath_)(e))}async function fe(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function he(e){const t=[];return A.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*v.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,j.includesIgnoreCase)(A.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return se().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const r=i??await(0,te.readMimeType)(e),n=await e.sidecar(),s=(0,X.isImageMimeType)(r)&&A.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,o=(0,X.isVideoMimeType)(r)&&A.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,a=A.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await n.exists(),l=s||o||a;return se().tap({msg:"writeTagDest()",result:l?n:e,meta:{src:e,tagName:t,mimetype:r,writeMetadataToSidecarsIfImage:s,writeMetadataToSidecarsIfVideo:o,writeMetadataToSidecarsIfSidecarExists:a}})}async function pe(e,i=!0){const r=x.PosixFile.for(e);if(r.isSidecar()&&(i=!1),!await r.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(r.nativePath),void se().debug("readRawTags("+r+"): invalid file, returning null.");const n=await(0,t._readRawTags)(r.nativePath);if(null==n||!i)return n;se().trace("readRawTags()",{pf:r,pickedFileTags:(0,h.pick)(n,"tz","tzSource",...A.Settings.capturedAtTags.values)});const s=[];for(const e of await r.jsonSidecars())s.push([e,(0,K.readJsonSidecar)(e,n.tz)]);for(const e of await r.existingExifSidecars())s.push([e,(0,t._readRawTags)(e.nativePath)]);const o={original:{},MIMEType:(0,u.mapNotBlank)(n.MIMEType,X.normalizeMimetype),...n},a=[];for(const[e,i]of s){if(null==i)continue;const r=await i;if(null==r)continue;const n=(0,h.omit)(r,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,h.values)(n))?((o.sidecars??(o.sidecars=[])).push(e.base),a.push(...(0,g.toA)(r.History)),(0,F.assignNullishFields)(o.original,(0,h.pick)(o,...(0,h.keys)(n))),(0,h.assignFields)(o,n),se().debug("readRawTags() sidecar had values",{sidecar:e.base})):se().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return o.inferred=(0,$.getInferredHistoricValues)(a,e),(0,F.assignNullishFields)(o,o.inferred),o.Rotation=(0,Q.orientationToRotation)(o.Rotation),se().debug("readRawTags() final",{pf:r,inferred:o.inferred,pickedResult:(0,h.pick)(o,"tz","tzSource",...A.Settings.capturedAtTags.values)}),o}async function ge(e,t){return null==t?void 0:(0,w.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,r=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,X.normalizeMimetype);if((0,u.blank)(r))return void se().debug("No mimetype for "+i);const s={...t.inferred??{},...t};if(s.inferred??(s.inferred={}),s.original??(s.original={}),A.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...A.Settings.capturedAtTags.values,...A.Settings.capturedAtTagsFallback.values]){const t=s[e];if((0,p.isString)(t)){const i=(0,_.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(se().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),s[e]=i)}}const a=!await(0,re.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,s,a);if(se().debug("parseTags()",{tzMeta:l,skipSiblingInference:a}),null!=l?.tz){const e=s.tzSource!==n.defaultVideosToUTC&&void 0;for(const t of[...A.Settings.capturedAtTags.values,...A.Settings.capturedAtTagsFallback.values]){const i=s[t];i instanceof n.ExifDateTime&&(s[t]=(0,M.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,h.assignUndefinedFields)(s.original,s,"tz","tzSource"),(0,h.assignFields)(s,l),(0,h.assignFields)(s.inferred,l)}const c=a?(0,Y.extractMakeAndModel)(s):await(0,re.inferMakeAndModel)(e,s);c.Make!==(0,Y.make)(s.Make)&&(s.original.Make=s.Make,s.inferred.Make=c.Make),c.Model!==(0,Y.model)(c.Make,s.Model)&&(s.original.Model=s.Model,s.inferred.Model=c.Model),!(0,u.blank)(A.Settings.defaultCopyright.valueOrDefault)&&(0,H.isExifUnset)(s.Copyright)&&(s.Copyright=A.Settings.defaultCopyright.valueOrDefault);const d=(0,Z.extractLensMakeModel)(s),f=await(0,V.extractCapturedAt)(e,s,a);if(null==f)return void se().info("No capturedAt for "+e);!a&&f.isInferred&&(s.inferred.capturedAt=f);const m=(0,q.extractExposureSettings)(s),g=await(0,ie.extractSizeInfoFromFile)(e,s);if(null==g)return void se().info("No size info for "+i);const y={...c,mimetype:r,capturedAt:f,exposureSettings:m,...(0,ne.extractTitleDescription)(s),...d,cameraId:(0,U.cameraIdFromTags)(s),imageId:(0,U.imageIdFromTags)(s),lensId:(0,U.lensIdFromLensInfo)({...d,...(0,h.pick)(s,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(s),tz:s.tz,rating:(0,ee.extractRating)(s)};(0,I.isTest)()&&(y.__parsedBy__=o.default.pid);const v={...s,...y};return se().debug("parsedTags",{nativePath:i,skipInference:a,...y,inferred:s.inferred,original:s.original,pickedResult:(0,h.pick)(v,"capturedAt","tz","tzSource","Make","Model")}),(0,h.definedValues)(v)}catch(e){return void se().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,h.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,h.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,E.eqlAsync)(e.sha(),t.sha())||await(0,E.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=x.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,D.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,D.toNativePath_)(e),["-"+t]);return(0,F.pluckCaseInsensitive)(i,t)}catch(e){return void se().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=fe,t.overwriteTags_=async function(e,t){try{await(0,w.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await he(e)),e.clearThisAndParent()}))}catch(i){se().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,w.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=he,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,w.time)("exiftool.writeTags:"+e,(async()=>{const r=new f.MultiMap;for(const[n,s]of(0,h.entries)(t)){const t=await me(e,n,i);r.add(t.nativePath,[n,s])}for(const[t,i]of r.entriesArray()){const r=x.PosixFile.for(t),n=(0,h.fromEntries)(i);se().info("writeTags()",{src:e,dest:t,t:n}),await le().write(r.nativePath,n,await he(r)),A.Settings.overwriteOriginal.valueOrDefault||await fe(r),r.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,k.nativePathIsFile)(e))return se().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);se().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...A.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,G.isVideoExt)(s.default.extname(e))?[]:["-fast"]],r=await(0,w.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{se().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==r)return;se().debug("_readRawTags()",{nativePath:e,pickedTags:(0,h.pick)(r,"tz","tzSource",...A.Settings.capturedAtTags.values)}),r.MIMEType=(0,u.mapNotBlank)(r.MIMEType,X.normalizeMimetype),r.GPSDateTime??(r.GPSDateTime=(0,P.concatDateTime)(r.GPSDateStamp,r.GPSTimeStamp));for(const e of(0,h.keys)(r)){const t=r[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete r[e])}const n=(0,l.compactBlanks)([r.Error,...r.errors??[],r.Warning].map(y.toS));return(0,l.isNotEmpty)(n)&&(r.problems=n),oe&&(r.__instance=(0,O.safeUUID)()),r}}),t.parseTags=ge},75767:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(98553),a=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),f=i(54993),h=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),v=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const w=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function S(e){const t=null==e?[]:e.filter((([,e])=>!(0,s.blank)(e)));return 0===t.length?void 0:(0,o.stringify)((0,u.fromEntries)(t))}function b(e){return(0,f.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new a.MultiMap,r=[];for(const o of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(n=e[o])||(0,s.blankish)(n)||(0,l.isNumber)(n)&&(0===n||1===n)||null!=t.zeroesRe.exec((0,f.toS)(n)))continue;const a=e[o],u=b(e[o]),c=(0,t.Tag2SynonymGroup)().get(o);if(null!=c){if(i.includes(c,a)||i.includes(c,u))continue;i.add(c,a)}r.push([o,(0,l.gt0)(a)?a:u])}var n;return S(r)}function M(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function _(e){if((0,s.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([M(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(M)):(0,u.compactBlankValues)(t)}function E({a:e,b:t,field:i,desc:r,parser:n}){const s=n(e[i]),o=n(t[i]),a=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==s||null==o||(0,l.approximates)(s,o,a)?void 0:"Different "+r+": "+e[i]+" ≠ "+t[i]}function T(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,s.blank)(e.lensMake)||(0,s.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,r.lazy)((()=>{const e=new Map;for(const t of w){const i=t[0];for(const r of t)e.set(r,i)}return e})),t.Tag2Synonyms=(0,r.lazy)((()=>{const e=new Map;for(const t of w)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=S,t.renderExifUidId=P,t.decodeExifUid=_,t.findInequalFields=function(e,i){const r=_(e),s=_(i);if(null==r||null==s||e===i)return;const o=(0,h.intersection)((0,u.keys)(r),(0,u.keys)(s)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of o){const t=r[e],i=s[e];if(b(t)!==b(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of w){const t=(0,u.pick)(r,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(s,...e);if((0,u.isEmptyObj)(i))continue;const o=(0,u.values)(t).map(f.toS),a=(0,u.values)(i).map(f.toS);if((0,n.includesAny)(o,a))continue;const l=(0,h.least)((0,u.keys)(t)),c=(0,h.least)((0,u.keys)(i));return{aKey:l,aValue:r[l],bKey:c,bValue:s[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>E({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>E({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>E({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>E({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return T({...(0,v.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=T,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const r=i(22573),n=i(54993),s=/undefined|null|none|n\/a|unknown/i;function o(e){return null==e||(0,r.blank)(e)||s.test((0,n.toS)(e))}t.isExifUnset=o,t.toExifDefined=function(e){return o(e)?void 0:e}},80495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const r=i(19851),n=i(22573),s=i(31586),o=i(68708),a=i(54993),l=i(50213),u=i(97352),c=(0,r.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,n.firstNotBlank)((0,a.toS)(e.ExposureTime),(0,a.toS)(e.ShutterSpeed),(0,a.toS)(e.ShutterSpeedValue),(0,a.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,o.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,s.gt0)(e))return e;const[t,i]=(0,a.toS)(e).split("/").map((e=>(0,s.toInt)(e)));return(0,s.gt0)(t)&&(0,s.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,s.toFloat)(e);return(0,s.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),n=i(40958),s=i(96249),o=i(23838),a=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),f=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const h=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,a.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,a.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,n.uniq)((0,s.flatten)((0,a.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,n.uniq)((0,s.flatten)((0,a.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return h()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new o.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:f.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:f.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:f.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:f.ExtTypes.Video},{exts:c.SidecarFiletypes,type:f.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:f.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:f.ExtTypes.Exif}])for(const t of(0,s.flatten)((0,a.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,f.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,f.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function v(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=v,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(f.ExtTypes.Sharp)||t.includes(f.ExtTypes.RawImage)?"image":t.includes(f.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return v(e,f.ExtTypes.RawImage)},t.isSharpExt=function(e){return v(e,f.ExtTypes.Sharp)},t.isVideoExt=function(e){return v(e,f.ExtTypes.Video)},t.isAssetFileExt=function(e){return v(e,f.ExtTypes.AssetFile)},t.isExifExt=function(e){return v(e,f.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return v(e,f.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return v(e,f.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=f.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return v(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const r=i(77988),n=i(19851),s=i(40958),o=i(76790),a=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),f=i(50989),h=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),v=i(50213),w=i(81168),S=i(66649),b=i(17415),P=i(29882),M=i(95696),_=i(17217),E=i(28874),T=i(47783);function x(e,t){return(0,d.entries)(t??{}).map((([t,i])=>D({action:e,key:t,value:i})))}function D({action:e,key:t,value:i,ts:n}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:r.ExifDateTime.fromMillis(n??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,f.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=x,t.mkHistoryRecord=D,t.InferAction="infer";const k=(0,n.lazy)((()=>(0,v.mkLogger)("tags.History")));function C(e,t){if(null==e||null==e.History||(0,h.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function O(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,a.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function I(e){if(null==e)return;const t={};for(const[i,r]of(0,d.entries)(e))(0,w.isFirstCharAZ)(i)&&(t[i]=r);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,b.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function F(e,i,r){if(null==e||(0,a.blank)(e))return void k().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const n=(0,_.toNativePath_)(e),o=await(0,T._readRawTags)(n),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!C(o,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...r??{}};if((0,s.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void k().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:r,tagsToWrite:c});k().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:r});const f=M.PosixFile.for(e);return await(0,T.overwriteTags_)(f,c),f.clearThisAndParent(),u}t.tagsContainHistory=C,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const n=(0,m.toA)(e);if((0,s.isEmpty)(n))return{};const l=(0,o.sortBy)(n.filter((e=>(0,w.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,S.datedToMillis)((0,a.mapNotBlank)(e.When,(e=>r.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,a.notBlank)(t)){const r=O(e);(0,a.blank)(r.nativePath)||(0,P.eqlNameWithoutExt)(r.nativePath,i)?u[t]=r:k().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=O,t.inferredToTags=I,t.ensureInferredHistoryRecords=async function(e,i,r){const n=x(t.Actions.infer,r),s=(E.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?I(r):void 0)??{};return E.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(s.Source=e.nativePath),k().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:n,additionalTags:s}),F(i,n,s)},t.ensureHistoryRecords=F},3432:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const n=r(i(53705)),s=i(77988),o=i(19851),a=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),f=i(17415),h=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),v=i(61424),w=(0,o.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function S(e,t,i){{const e=b(t);if(null!=e&&(0,f.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,f.isValidZone)(t.tz)||t.tzSource===s.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,a.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof s.ExifDateTime&&(0,f.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,v.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function b(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,n.default)(t,i),r=(0,f.normalizeZone)(e);return w().tap({msg:"zoneFromLatLon()",result:r,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,h.isValidDate)(i))for(const r of g.Settings.capturedAtTags.values){const n=(0,u.toDated)(t[r]);if(null==n||(0,h.isValidDate)(n))continue;const s=Math.round(15*i.diff(n,"minutes").as("minutes")/15),o=(0,f.normalizeZoneOffsetMinutes)(s),a=0===o?void 0:(0,f.normalizeZone)(o);if(null!=a)return w().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:a.name,tzSource:"infer:filename (diff with "+r+")"},meta:{dt:(0,c.datedToISO)(n),rawTzoffsetMinutes:s,normalizedOffsetMinutes:o}})}}t.maybeInferTimezone=async function(e,t,i){return w().tap({msg:"maybeInferTimezone()",result:await S(e,t,i)})},t.zoneFromLatLon=b,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const r=i(77988),n=i(40958),s=i(22573),o=i(38639),a=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),f=i(48884),h=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const n=(0,p.normalizeZone)(e?.formatted),s=r.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:n??t??r.UnsetZone});if(!0===s?.isValid)return s}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,s.toNotBlank)(e.title),Description:(0,s.toNotBlank)(e.description),GPSLatitude:(0,f.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,h.validLat)(e)?e:void 0)),GPSLongitude:(0,f.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,h.validLon)(e)?e:void 0)),GPSAltitude:(0,f.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,a.map)(e.favorited,o.isTrue),peopleNames:(0,n.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,n.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},15912:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(55835),a=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),f=i(28874),h=i(30748),m=(0,r.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,h.make)(e.LensMake),i=(0,h.make)(e.Make),r=[],a=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],S),u=(0,n.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:a,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&r.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==S(e))continue;(0,s.notBlank)(t)&&r.push({lensMake:t,lensModel:e,lensInfo:a});const o=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))o.includes(t)&&r.push({lensMake:i,lensModel:e,lensInfo:a});for(const i of(0,n.compactBlanks)([t,...f.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&r.push({lensMake:i,lensModel:e,lensInfo:a});o.startsWith("vr ")&&"Nikon"===i&&r.push({lensMake:"Nikon",lensModel:e,lensInfo:a})}for(const e of r){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=b(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,o.map)(e.lensInfo,b)}return(0,c.greatestBy)(r,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const v=/([\d. -]+)\s?mm\b/i,w=/\bf\/?([\d.\-]+)/i;function S(e){if((0,s.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=v.exec(e)?.[1].replace(/\s/g,""),i=w.exec(e)?.[1];return y(t)&&y(i)?b(`${t}mm f/${i}`):void 0}function b(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,o.mapOr)((0,a.toFloat)(e),(e=>String((0,a.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=S,t.cleanBogusPrecision=b,t.normalizeLensModel=function(e){return b(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const r=i(19851),n=i(22573),s=i(55835),o=i(68708),a=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function f(e,t,i=""){const r=e.replace(t,i);return r===e?e:f(r,t,i)}const h=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=h.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,r.lazy)((()=>new p)),y=/\bgopro\b/i;function v(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=f(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=v(e.Make)??S(e.Software)??S(e.CreatorTool)??function(e){return y.test((0,a.toS)(e.HandlerDescription))||y.test((0,a.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,o.compactValues)({Make:t,Model:i})??{}},t.make=v;const w={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function S(e){if(!(0,n.blank)(e))for(const[t,i]of(0,o.entries)(w))if(i.test(e))return t}t.makeFromSoftware=S;const b=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=b.exec(i);null!=e&&(i=e[1].trim())}const r=(0,s.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=r)return r[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,s.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=f(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},16170:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const r=i(22573),n=i(54993),s=i(2322),o=i(277),a=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function f(e){return(0,r.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function h(e){const t=(0,n.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,s.isChrome)(t)||(0,s.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,n.toS)(e))},t.isImageMimeType=function(e){return(0,n.toS)(e).startsWith("image/")},t.isVideoMimeType=f,t.normalizeMimetype=h,t.isSharpMimeType=function(e){return!(0,r.blank)(e)&&h(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,r.blank)(e)&&h(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,r.blank)(t)&&(f(t)?await(0,l.isVideoSupported)():(0,a.isHeifMimeType)(t)?await(0,o.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},95141:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const r=i(21605),n=i(54993),s=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,s.isVideoMimeType)(e.MIMEType)?(0,r.normalizeRotation)(e.Rotation):void 0)??a(e.Orientation)};const o=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function a(e){return(0,r.isRotation)(e)?e:null!=e?o.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,n.toS)(e).startsWith("Mirror")},t.orientationToRotation=a;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,r.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,r.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const r=i(55835),n=i(31586),s=i(28874);function o(e){const t=(0,n.toInt)(e);return null==t?void 0:(0,n.clamp)(-1,5,t)}function a(e){return o(e?.Rating)??(0,n.mapNumeric)((0,n.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,r.map)(e?.favorited,(e=>!0===e?s.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=o,t.extractRating=a,t.extractLiked=function(e){const t=a(e);return null==t?void 0:t>=s.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const r=i(19851),n=i(22573),s=i(55835),o=i(88561),a=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,r.lazy)((()=>new o.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,n.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,s.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,a.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),n=i(40958),s=i(22573),o=i(81168),a=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),f=i(14036);function h(e,t,{ignoreCase:i}){return i?(0,o.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const a=(0,u.isJsonExt)(i.ext),l=a||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(h(e.base,i.name,{ignoreCase:l}))return!0;if(h(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(h(e.name,t,{ignoreCase:l}))return!0}const m=a||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,n.uniq)([e.base,e.name,(0,f.stripExt)(e.base)]))for(const e of(0,n.uniq)([i.name,i.name,(0,f.stripExt)(i.name)]))if(h((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return a&&function(e,i){const r=(0,o.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function n(e){return(0,s.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const a=n(e.slice(r.length)),l=n(i.slice(r.length));return a&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,a.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,o.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const r=i(19851),n=i(22573),s=i(42659),o=i(33374),a=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),f=i(34943),h=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),v=(0,r.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),w=(0,r.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:s.minuteMs})));async function S(e,t){if(null==e)return;const i=null==t||(0,n.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const r=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return b(i,r,await(0,f.rawInfo)(e));const s=b(i,r);if(null!=s)return s;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await S(await(0,h.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function b(e,t,i){t??(t=(0,y.extractRotation)(e));const r=(0,a.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,o.isDimensions)(e)?e:void 0));if(null==r)return v().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:f.rawInfo,fileDimensions:r}});const n=(0,o.maybeDimSwap)(r,t);return v().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:n.height,ImageWidth:n.width,aspectRatio:(0,d.aspectRatio)(n),dimensions:n,rotation:t,fileDimensions:r,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:f.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return w().getOrSetAsync(i.nativePath,(()=>S(i,t)))},t.extractSizeInfoFromTags=b},61424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const r=i(77988),n=i(51168),s=i(19851),o=i(40958),a=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),f=i(48884),h=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),v=i(79842),w=i(21330),S=i(98725),b=i(51275),P=i(35280),M=i(19748),_=i(88561),E=i(95696),T=i(65238),x=i(17217),D=i(57902),k=i(28874),C=i(80496),O=i(65162),I=i(28544),F=i(47783),L=i(88840),A=i(30748),R=i(16170),N=(0,s.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),j=7;async function B(e){return k.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+k.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(k.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.auto&&await(0,T.isSlowDir)(e.nativePath)&&!await(0,T.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function z(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of r){const r=(0,A.extractMakeAndModel)(await(0,F.readRawTags)(t));if((0,h.definedAndNotEql)(r.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:r});else if((0,h.definedAndNotEql)(r.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:r});else if(null!=r.Make&&null!=r.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:D.LogLevels.info,result:r,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await B(e.parent()))return;const t=await W(e);return null!=t&&(0,w.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,w.toExifDateTime)(t.before.date,(0,b.getZoneName)(t.before.date)),(0,w.toExifDateTime)(t.after.date,(0,b.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,s.lazy)((()=>new _.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await q(e),i=await z(t?.younger),r=await z(t?.older);return null==i||null==r?void 0:{before:i,after:r,index:i.index,slots:i.index+r.index+1}}))}t.beforeAfterCapturedAt=W;const U=(0,M.extFilter)(L.ExtTypes.AssetFile);function H(e){return null==e?[]:(0,o.compact)((0,f.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function q(e,t=7,i=!0){if(!await B(e.parent()))return;const r=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(U(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==r)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const n=(0,a.sortBy)(r,(e=>(0,O.bname)(e))),s=(0,x.findFileIndex)(e,n);if(s<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),q(e,t,!1)):void 0;const l=k.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[n.slice(s-2*t,s),n.slice(s+1,s+1+2*t)],d=[],f=[];for(;(0,o.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,o.isNotEmpty)(c)&&f.length=l&&f.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:f},meta:{f:e}})}t.nearestSiblings=q,t.nearestSiblingTzOffset=async function(e){if(!await B(e.parent()))return;const t=H(await q(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,j);for(const t of e){const e=await(0,F.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==r.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,o.uniq)([(0,O.bname)(e,!0),(0,O.bname)(e,!1)]),i=(0,S.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const r=await e.stat();if(null!=r){for(const e of["birthtime","atime","mtime","ctime"])if((0,v.datedOverlap)({a:i,b:r[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:r}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:r}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,S.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const r=i[e];if(null!=r&&!0===(0,v.datedOverlap)({a:t,b:r}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:n.DateTime.fromJSDate(r)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(55835),a=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),f=i(81168);function h(e){return(0,u.toS)((0,a.isString)(e)?e:e?.name).normalize()}function m(e){return(0,r.compact)((0,l.toA)(e).map(h))}function p(e,i=t.TagSep){return m(e).map((e=>(0,a.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(s.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function v(e){return(0,s.blank)(e)?void 0:Array.isArray(e)?h((0,r.last)(e)):(0,r.last)(g(e))}function w(e,t){if((0,r.isEmpty)(e)||(0,r.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,f.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=h,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,r.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,r.uniqBy)((0,l.toA)(e),(e=>(0,r.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,r.compact)(t).map((e=>y(e))));return(0,r.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=v,t.leafIsExcluded=function(e,t){return(0,o.mapOr)(v(e),(e=>(0,f.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=w,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,n.sortBy)(e.filter(r.isNotEmpty),(e=>-e.length)))t.some((e=>w(i,e)))||t.push(i);return(0,n.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const r=i(40958),n=i(22573),s=i(68708),o=i(54993);t.extractTitleDescription=function(e){const t=(0,r.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,n.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const r of i){const i=(0,o.toS)(e[r]).trim();if((0,n.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,s.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(96249),a=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),f=i(7014),h=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),v=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function w(e){const t=await(0,f.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),h.URI.file(e)])}async function S(e){const t=await w(e);return(0,n.uniq)((0,o.flatten)(t.map(m.uriEncodingVariants)))}async function b(e,t){if((0,s.blank)(e))return;const i=function(e){try{return h.URI.isUri(e)?e:h.URI.parse(e,!0)}catch(t){return void v().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case a.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case a.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case a.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,s.blank)(e)?v().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??h.URI.file(e)},t.nativePath2uris=w,t.nativePath2uriVariants=S,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(b(e,t),S))),(0,n.uniq)(i)},t.uri2nativePath=b,t.uriExists=async function(e,t){const i=await b(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),n=i(57975),s=i(90595),o=i(22573),a=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),f=i(43334),h=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",v=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class w{static isUri(e){return e instanceof w||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,n,s=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,s),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=n??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!h.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,s))}get fsPath(){return E(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:n,fragment:s}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===n?n=this.query:null===n&&(n=g),void 0===s?s=this.fragment:null===s&&(s=g),t===this.scheme&&i===this.authority&&r===this.path&&n===this.query&&s===this.fragment?this:new b(t,i,r,n,s)}static parse(e,t=!1){const i=v.exec(e);if(!i)return new b(g,g,g,g,g);const r=i[2]||g,n=k(i[4]||g),s=(i[5]||g).split("/").map(k).join("/"),o="psfile"===r&&s.startsWith("//")?s.slice(1):s,a=(0,u.toURLSearchParams)(i[7]),l=k(i[9]||g);return new b(r,n,o,a,l,t)}static file(e){let t=g;if(f.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new b("file",t,e,g,g)}static from(e){return new b(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=f.isWin&&"file"===e.scheme?w.file(r.win32.join(E(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,a.map)(this.path,(e=>(0,d.findLast)(e.split(y),o.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return T(this,e)}toJSON(){return this}[n.inspect.custom](){return this.toString()}}t.URI=w;const S=f.isWinPortable?1:void 0;class b extends w{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=E(this,!1)),this._fsPath}toString(e=!1){return e?T(this,!0):(null==this._formatted&&(this._formatted=T(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=S),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,o.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function M(e,t){let i,r=-1;for(let n=0;n=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57||45===s||46===s||95===s||126===s||t&&47===s)-1!==r&&(i+=encodeURIComponent(e.substring(r,n)),r=-1),void 0!==i&&(i+=e.charAt(n));else{void 0===i&&(i=e.substr(0,n));const t=P[s];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,n)),r=-1),i+=t):-1===r&&(r=n)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function _(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,f.isWin&&(i=i.replace(/\//g,"\\")),i}function T(e,t){const i=t?_:M;let r="";const{scheme:n,query:s,fragment:a}=e;let{authority:l,path:u}=e;if(n&&(r+=n,r+=":"),(l||"file"===n)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,o.mapNotBlank)(s,(e=>r+="?"+e)),a&&(r+="#",r+=t?a:M(a,!1)),r}function x(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+x(e.substr(3)):e}}t.encodeURIComponentFast=M,t.uriToFsPath=E;const D=/(?:%[\dA-Z][\dA-Z])+/gi;function k(e){return e.startsWith("xn--")?(0,s.toUnicode)(e):e.match(D)?e.replace(D,(e=>x(e))):e}t.percentDecode=k,t.toURI=function(e){return w.isUri(e)?e:w.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),n=i(40958),s=i(50357),o=i(89937),a=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",o.PS_LOCAL_FILE_SCHEME,o.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,a.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const f=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function h(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&h(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return f().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,s.eql)(e,t)||m(e,t)||h(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,n.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),n=i(22573),s=i(51926),o=i(89937),a=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),f=i(85087);function h(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,n.blank)(e))return;if(null==(t=null!=t&&(0,a.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,n.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,s.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:o.PS_LOCAL_FILE_SCHEME,authority:(0,f.volsha)(t.uuid),path:u})},t.joinMountpoint=h,t.psfile2nativePath=async function(e,t){if(e.scheme!==o.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,n.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,s=(0,n.notBlank)(t)&&!t.includes(i);if(s&&!(0,n.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,f.volsha)(i.uuid)===e.authority)return h(i.mountpoint,e.path)}const a=await(0,c.bestVolumeForVolsha)(e.authority);return null!=a?h(a.mountpoint,e.path):s&&(0,n.notBlank)(t)?h(t,e.path):void 0}},5696:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),n=i(22573),s=i(51926),o=i(89937),a=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:o.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,n.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,n.blank)(t))return;const i=(0,r.uniq)([t,(0,a.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,s.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:o.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==o.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,a.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,s.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const o=s(i(76760)),a=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),f=i(16287),h=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,a.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,a.notBlank)(t.remoteHost)&&(0,a.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:o.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,a.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,a.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(o.sep)}`;const n=i.slice(1),s=await(0,p.volumes)();for(const t of(0,u.toA)(s))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,h.isEquivalentHost)(e.authority,t.remoteHost))return o.join(t.mountpoint,...n);return await(0,f.isReadableDirectory)(t)?o.join(t,...n):void 0}},85087:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),n=i(42659),s=i(9103),o=i(37628);t.volsha=(0,s.memoize)((e=>(0,r.mapNotBlank)(e,o.shortStringSha)),{maxSize:128,ttlMs:n.minuteMs})},60865:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),n=i(30577);t.channel=function(){return(0,n.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),n=i(22573),s=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function o(e){if(e instanceof r.SemVer)return e.version;const t=s.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=o,t.semverSatisfies=function(e,t){if((0,n.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const s=o(e);return null!=s&&(0,r.satisfies)(s,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},8540:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),n=i(9595),s=i(29882),o=i(43334),a=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([a.Settings.libraryDir.valueOrDefault,(0,n.originalsDir)(),...a.Settings.scanPaths.values]))if((!o.isPosix||!(0,s.pathIsRoot)(t))&&(0,s.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},1485:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),n=i(22573),s=i(59455),o=i(50213),a=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),f=i(69108),h=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.DfPosix"))),v=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,f.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function w(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),n=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),s=t&&(i||r||n);return y().tap({msg:"acceptPosixVolume()",result:!s,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:n}})}t.acceptPosixVolume=w,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,f.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,s.toA)(await v());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,n.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,h.isGioSupported)())for(const e of(0,s.toA)(await(0,h.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,a.assignMissingPrimitives)(i,e))}return t.filter(w)}},69108:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),f=i(63870),h=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,o.toInt)(e,{defaultValue:0})*a.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,n.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void h().info("parseDfVolume(): skipping (size is 0)",{vol:e});const n=m(e.Used)??0,s=m(e.Available)??0;if(0!==n||0!==s)return{filesystem:t,mountpoint:i,size:d.isMac?n+s:r,used:n,available:s};h().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:n,available:s})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,f.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,n.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,f.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,s.blank)(i))return h().warn("empty output",{localsOnly:e,paths:t}),[];h().debug("output",{localsOnly:e,paths:t,output:i});const o=p(i);return!0===e&&o.forEach((e=>e.remote=!1)),o},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(22573),a=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),f=i(59455),h=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),v=i(24399),w=i(28874),S=i(24541),b=i(60224),P=i(63870),M=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await F()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const _=/([a-z]+)(?::\\)?/i;function E(e){return e?.match(_)?.[1]?.toUpperCase()}function T(e){return(0,l.map)(E(e),(e=>e+":\\"))}function x(e){return`Get-PSDrive -PSProvider FileSystem ${(0,h.toS)(E(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function D(e){return null!=e&&!(0,o.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,o.notBlank)(e.DisplayRoot),...(0,l.map)((0,b.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function k(e){return`Get-Volume ${(0,h.toS)(E(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=T,t.getPsDriveCommand=x,t.getVolumeCommand=k,t.getLocalVolumesWin_=function(){return v.PowerShell.instance().executeJsonToA(k())};const C=/\{([-a-z\d]{7,})\}/i;function O(e,t){return e=e?.trim(),(0,o.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function I(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void M().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=T(e.DriveLetter);if(null==t)return void M().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,n.compact)([O(e.HealthStatus,"healthy"),O(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,o.notBlank)(e.DriveLetter)&&(0,o.blank)(i);return M().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(s=e.UniqueId,M().tap({msg:"uniqueId2uuid",result:(0,l.map)(C.exec((0,h.toS)(s)),(e=>e[1])),meta:{s}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var s}async function F(){const e=(0,n.uniq)((0,f.toA)(await(0,S.mountpointsWin)()).map(T)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(x(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,n.compact)((0,a.flatten)(t).map(D)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(k(e)).catch((t=>(M().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),o=(0,n.compact)((0,a.flatten)(r).map(I)),l=(0,n.uniq)([...i,...o].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,s.sort)((0,n.uniq)([...i,...o].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));M().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:o,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...o.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=I,t.volumeInfoWin=F},68884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(42659),a=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),f=i(45255),h=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),v=i(83278),w=i(8103),S=i(16287),b=i(45969),P=i(43334),M=i(69108),_=i(98770),E=i(44224),T=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,b.isDocker)()||(0,d.isBillingService)()||null==await(0,w.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,T.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const x=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?x().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,E.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),S.isReadableDirectory),(e=>e.map((e=>v.BaseFile.for(e).clear().childDirectories())))))}):x().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,n.isEmpty)(e)?[]:(x().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,T.mountpointsTtlMs)(),f:async e=>{const t=await(0,M.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void x().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await D(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,T.mountpointsTtlMs)()}))),(0,a.later)((()=>(0,_.setupVolumeTTL)(t.gioVolumes)));const D=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,T.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,s.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,h.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,h.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,h.stripPrefix)(e,"/"))).flatMap((e=>(0,h.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(s.notBlank).get()}}catch(t){return void x().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:f.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs})},98770:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),n=i(5233),s=i(41400),o=i(56038),a=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function f(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,o.time)("volumes."+e,(()=>(0,n.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,a.isRetriableError)(e)&&!1!==(0,a.isIgnorableError)(e)})))),i);return(0,s.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&f(u)})),u},t.setupVolumeTTL=f},27461:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),f=i(6012),h=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),v=i(98770),w=i(63870),S=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>S().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>S().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const s=(0,c.sortIgnoreCase)((0,n.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),o=[];for(const t of s){const n=e.find((e=>e.mountpoint===t)),s=i?.find((e=>e.mountpoint===t)),a={...n,...s},u=r?.find((e=>e.filesystem===a.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(a,u),null==a.size||null==a.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];S().info("backfilling mountpoint",{info:s,vol:n,df:e}),null!=e&&(0,l.assignMissingPrimitives)(a,e)}o.push(a)}return o};const b=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return b.exec(e)?.[1]?.split(".").map((e=>(0,o.toInt)(e)))})),M=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,o.gte)(t[0],2)&&(0,o.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,v.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await M()],{timeoutMs:(0,w.commandTimeoutMs)()}),t=(0,h.splitLines)(e).map((e=>(0,f.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,s.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,o.toInt)(e.fsused),r=(0,o.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return S().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,v.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,w.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,f.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,s.toNotBlank)(e.PARTLABEL)??(0,s.toNotBlank)(e.LABEL),uuid:(0,s.toNotBlank)(e.PARTUUID)??(0,s.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),n=i(19851),s=i(40958),o=i(22573),a=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),f=i(56519),h=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),v=(0,n.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,s.uniq)(e.map((e=>e.filesystem?.match(w)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),n=await(0,f.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,h.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of n)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,o.blank)(t.MountPoint)||(0,a.isTrue)(t.OSInternal)?v().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){v().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const w=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(42659),a=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),f=i(23560),h=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),v=i(84777),w=i(34330),S=i(8769),b=i(34102),P=i(17217),M=i(16287),_=i(43334),E=i(28874),T=i(8540),x=i(68884),D=i(44224),k=i(24541),C=i(69375),O=i(63870),I=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function F(){t.mountpoints.unset(),t.mountpoints_.unset()}function L(e=(0,O.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function A(){F()}t.localMountpointSetup=(0,r.lazy)((async()=>{E.Settings.libraryDir.watchLater(F),E.Settings.scanPaths.watchLater(F),(0,f.isSyncService)()&&E.Settings.scanAllDrives.valueOrDefault?(0,a.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(_.isMac&&(e.info("Setting up Mac diskutil activity watcher"),L((0,O.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),_.isLinux){const i=(0,D.maybeWatchProcMounts)();await(0,x.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),L((0,O.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),L((0,O.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),o.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=E.Settings.mountpoints.values;if((0,n.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",_.isWin?k.mountpointsWin:D.mountpointsPosix),h.ShortCommandTimeoutMs);if((0,n.isEmpty)(e))return I().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,s.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,O.commandTimeoutMs)(),f:async e=>!(!(0,T.mightBeAssetMountpoint)(e)&&(0,C.isExcludedMountpoint)(e)||E.Settings.validateMountpoints.valueOrDefault&&!await(0,M.isReadableDirectory)(e)&&(I().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,S.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(_.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return _.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,a.later)((()=>{(0,b.ee)().on("clearCache",(()=>{x.gioVolumes.unset(),F()})),E.Settings.mountpointsTtlMs.watch(L)}),(0,c.isTest)()?1:o.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>A(),minCallDelayMs:1.5*o.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:x.GioCommand,args:x.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(x.gioVolumes.unset(),A()),minCallDelayMs:h.ShortCommandTimeoutMs})})));const N=(0,r.lazy)((async()=>{if(!_.isLinux)return!1;try{return 0===(await(0,v.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,O.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>A(),minCallDelayMs:h.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),n=i(40958),s=i(42659),o=i(48884),a=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),f=i(73787),h=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),v=i(28874),w=i(69108),S=i(68884),b=i(59107),P=i(69375),M=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await x()??await(0,c.thenMap)((0,w.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,S.isGioSupported)())try{await(0,c.thenMap)((0,S.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){M().warn("Failed to fetch gio volumes",e)}return e};const _="/proc/mounts";function E(e){return!v.Settings.excludedFilesystemTypes.has(e)}function T(e){return!(0,P.isExcludedMountpoint)(e)&&(!v.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function x(e=_,t=E,i=T){if(y.isLinux)try{const r=await(0,h.readLines_)(e),s=(0,n.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,o.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),a=await(0,c.filterAsync)({name:"mountpoints filter",arr:s,f:async([e,r])=>{const n=t(e),s=await i(r);return M().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:n&&s,meta:{fs:e,mp:r,fsOK:n,mpOK:s}})}});return M().tap({msg:"readProcMounts()",result:a.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void M().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=E,t.readProcMounts=x,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(_)?new f.FileWatcher(_,{recursive:!1,persistent:!1},(()=>{M().info("detected change in "+_),(0,d.setUnrefTimeout)((()=>b.mountpoints.refresh()),s.secondMs)})):void 0))},24541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),n=i(42659),s=i(13538),o=i(50213),a=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),f=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsWin")));async function h(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,s.thenOrTimeoutError)(h(),a.ShortCommandTimeoutMs)}catch(e){return f().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=h;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*n.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),n=i(22573),s=i(50213),o=i(9103),a=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,n.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const f=u.isLinux||(0,a.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,h=u.isLinux||(0,a.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,a.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,a.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,n.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===f?.test(e)?"LinuxDevMapperRE":!0===h?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,o.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),n=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,s=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function o(e){if((0,r.blank)(e))return;const i=n.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(s,""),remoteShare:i.remoteShare};const o=t.nfsRe.exec(e);if(null!=o){const e=o[1],t=o[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=o(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=o},60224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),n=i(22573),s=i(42659),o=i(55835),a=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),f=i(81168),h=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),v=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await E()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,o.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const w=["LocalName","RemoteName","Status"],S=["NETUSE","get",w.join(",")],b=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function M(e){if(!(0,n.blank)(e))return(0,a.opt)(e).flatMap((e=>b.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,a.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,n.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,a.opt)(e.pathname).filter(n.notBlank).getOrElse((()=>"/"))}))))).get()}async function _(){const e=(0,p.wmic)(),t=await(0,h.stdout_)(e,S,{timeoutMs:15*s.secondMs}),i=(0,u.parseFixed)(w,t);return(0,r.compact)(i.map((e=>(0,o.map)(b.exec((0,l.toS)(e.RemoteName)),(t=>(0,o.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,f.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=M,t._netInfoWinWmic=_;const E=(0,v.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?_():(0,r.compact)(e.filter((e=>(0,n.notBlank)(e.LocalName))).map((e=>(0,o.map)(M(e.RemoteName),(({host:t,share:i})=>(0,o.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,f.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),n=i(12168),s=i(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=n.MiB/r.secondMs},86848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(38639),a=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),f=i(81168),h=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),v=i(95696),w=i(45969),S=i(28874),b=i(59107),P=i(63870),M=i(68995),_=(0,n.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),E=(0,n.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function T(e){return(0,o.isTrue)(e.ignorable)||(0,w.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function x(e){if((0,s.blank)(e))return;const t=(0,f.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function D(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=x(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function k(e){if(S.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of S.Settings.volumeUuidFilePaths.values){const i=v.PosixFile.for(e.mountpoint).join(t),r=await D(i).catch((e=>_().info("Failed to read "+i,{error:e})));if(null!=r)return _().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,M.volumeUuidSubpath)());if("/"===e.mountpoint)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(S.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(S.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,M.writeVolumeUuid)(e);if(!(0,s.blank)(t))return _().tap({msg:"readVolumeUUID(): wrote new "+(0,M.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return _().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,a.later)((()=>{(0,m.ee)().on("clearCache",(()=>E.clear())),b.mountpoints.watchLater((()=>E.clear()))})),t.addVolumeUUIDs=async function(e){await(0,h.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(T(e))return;if((0,o.isFalse)(e.ok))return;const t=await E().getOrSetAsync(e.mountpoint,(async()=>k(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>_().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=T,t.toVolumeUUID=x,t.readUuidFile_=D,t.readVolumeUUID=k},7014:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const n=r(i(48161)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),f=i(41400),h=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),v=i(59455),w=i(48884),S=i(50213),b=i(7282),P=i(23560),M=i(28850),_=i(45255),E=i(81168),T=i(56519),x=i(4867),D=i(49776),k=i(9595),C=i(77740),O=i(44198),I=i(96706),F=i(8769),L=i(57159),A=(i(34102),i(21144)),R=i(73209),N=i(29882),j=i(95696),B=i(17217),z=i(16287),V=i(49076),W=i(96128),U=i(45969),H=i(43334),q=i(28874),G=i(85087),$=i(50424),J=i(48165),K=i(98770),Z=i(27461),Y=i(66840),X=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,o.lazy)((()=>(0,S.mkLogger)("volumes.Volumes"))),ne=n.default.platform(),se=new Map,oe=new Map,ae=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,G.volsha)(t.uuid),(e=>oe.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,se),le((0,G.volsha)(e.uuid),e,ae),e}function ce(){return(0,a.compact)([j.PosixFile.forMaybe((0,D.cacheDir)())?.join("volumes"),j.PosixFile.forMaybe((0,k.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),oe))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),se.clear(),ae.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,T.mapAsync)({name:"readCachedVolumes",arr:(0,T.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,a.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,E.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function fe(e){if(null==e)return;const i=new h.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),n=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:r,os:ne}))),s=new Map;for(const e of n)for(const t of(0,a.compactBlanks)([(0,G.volsha)(e.uuid),(0,G.volsha)(e.mountpoint)]))s.set(t,e);const o=ce();for(const e of o)await(0,R.withLock_)({file:e,timeoutMs:_.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of s.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:o,vol_mountpoints:n.map((e=>e.mountpoint))}),i.resolve()}async function he(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,a.isNotEmpty)(e))return e;const i=(0,v.toA)(await(0,X.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,q.Settings.volumeMetadataTtlMs.valueOrDefault),n=0!==q.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),s=!(0,a.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:n,priorIsMissingMountpoints:s}),n||s?void 0:e}async function me(e,i){const r=(0,m.map)(e,B.toNativePath_);if((0,u.blank)(r))return;const n=await(0,A.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,a.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(n,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:n,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:n}})}async function pe(e,t,i){const r=i.filter((e=>(0,E.equalsIgnoreCase)(t,e.remoteShare)));if((0,a.isEmpty)(r))return;const n=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,E.equalsIgnoreCase)(e,t.remoteHost)));if(null!=n)return n;const s=await(0,W.friendlyname)(e);return(0,T.asyncFind)(r,(async e=>(0,E.equalsIgnoreCase)(s,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,o.lazy)((()=>(0,P.isSyncService)()||(0,b.isTest)())),t.priorWriteVolumesToCacheLatch=(0,o.lazy)((()=>{})),t.writeVolumesToCache=fe,t.cachedVolumes=(0,o.lazy)((async()=>{const e=(0,a.compact)(await de()),t=(0,v.toA)(await(0,X.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,a.isNotEmpty)(i)?i:e.filter((e=>ne===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=he,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,x.thenOrTimeoutError)({p:he(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,x.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,a.isNotEmpty)(i))return i}catch(e){(0,F.onError)((0,L.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,M.shim0)({name:"fs.volumes",impl:async function(){if((0,b.isTest)()){const e=(0,p.toInt)((0,O.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,f.delay)(e,!1)),(0,C.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,x.thenOrTimeoutError)({p:H.isWin?(0,J.dfWin)():(0,$.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=q.Settings.validateMountpoints.valueOrDefault?(0,a.compact)(await(0,T.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,z.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,x.thenOrTimeoutError)({p:H.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,F.onError)("Failed to get remote volume info",{error:e})}));const i=(H.isWin?t:H.isMac?await(0,Y.addLocalVolumeInfoMac)(t):await(0,Z.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await fe(r),Object.freeze(r)}}),t.rootPath=(0,o.lazy)((()=>H.isWin?(0,g.opt)((0,I.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,E.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,a.isEmpty)(t)?void 0:(0,w.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,a.commonPrefixLength)(e.split(s.default.sep),t.split(s.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,v.toA)(await i.vols()).find((t=>(0,G.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,T.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return ae.get(e)??(await de())?.find((t=>(0,G.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,G.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(50213),a=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),f=(0,n.lazy)((()=>(0,o.mkLogger)("volumes.WriteVolumeUUID")));function h(){return(0,s.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=h,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,h());t=(0,s.toNotBlank)(t)??(0,c.safeUUID)();const n=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(n))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+a.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),f().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){f().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else f().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},51140:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpStatusIs=t.HttpStatus=void 0;const r=i(31586);t.HttpStatus=Object.freeze({OK:200,Accepted:202,MovedPermanently:301,Found:302,SeeOther:303,BadRequest:400,Unauthorized:401,Forbidden:403,NotFound:404,EnhanceYourCalm:420,InternalServerError:500,NotImplemented:501,ServiceUnavailable:503}),t.HttpStatusIs=Object.freeze({ok:e=>(0,r.within)(200,299,e),success:e=>(0,r.within)(200,299,e),redirect:e=>(0,r.within)(300,399,e),clientError:e=>(0,r.within)(400,499,e),serverError:e=>(0,r.within)(500,599,e),error:e=>(0,r.within)(400,599,e)})},21404:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToTagPath=void 0;const r=i(75020),n=i(40958),s=i(22573),o=i(89937),a=i(34238);t.uriToTagPath=function({uri:e,isFile:t}){if(null==e)return;const i=(0,a.toURI)(e),l=i.scheme===o.PS_LIBRARY_SCHEME?r.LibraryTagName:i.scheme===o.PS_LOCAL_FILE_SCHEME?i.authority:void 0;if((0,s.blank)(l))return;const u=i.path.split("/");return(0,n.compactBlanks)([r.TagRoots.fs,l,...t?u.slice(0,-1):u])}},98604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkAssetUrl=t.mkFolderUrl=t.myWebUrl=void 0;const r=i(19851),n=i(40958),s=i(31586),o=i(27776),a=i(49076),l=i(72308),u=i(28874),c=i(42231),d=i(45200),f=i(34238),h=i(21404);function m(e=u.Settings.httpPort.valueOrDefault){const t=[u.Settings.localhost.valueOrDefault];u.Settings.exposeNetworkWithoutAuth.valueOrDefault&&t.push(...(0,n.compactBlanks)([(0,l.myExternalIp4Addresses)()[0],(0,a.hostname)()]));const i=(0,f.toURI)("http://a");return t.map((t=>i.with({authority:t+":"+e})))}t.default=m,t.myWebUrl=(0,r.lazy)((()=>m()[0])),t.mkFolderUrl=async function(e){const i=await(0,d.nativePath2uri)(e),r=(0,h.uriToTagPath)({uri:i,isFile:!1});if((0,n.isEmpty)(r))return;const s=(0,o.mkTagUri)((0,c.tagPathToStringArray)(r));return(0,t.myWebUrl)()?.with(s)},t.mkAssetUrl=function(e){return(0,s.gt0)(e)?(0,t.myWebUrl)()?.with({path:"/asset/"+e}):void 0}},4988:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.httpRequest_=t.get_=t.HttpMethods=void 0;const o=s(i(37067)),a=s(i(44708)),l=i(22573),u=i(45599),c=i(50989),d=i(51926),f=i(50213),h=i(45255),m=i(22911),p=i(43205),g=i(34238),y=i(51140),v=(0,u.defer)((()=>(0,f.mkLogger)("net.get")));async function w(e,t){return S({...t,url:e})}async function S(e){const t=(0,g.toURI)(e.url),i=new m.Deferred("get "+t.toString()),r="http"===t.scheme?o.request:"https"===t.scheme?a.request:v().throw("unsupported scheme: "+t.scheme),n=e?.maxRedirects??8,s=e?.timeoutMs??h.ShortCommandTimeoutMs,u={...e?.headers,"user-agent":await(0,p.userAgent)()},c=e?.method??"GET",f=e?.agent??!1,S=r(t.toString(),{method:c,headers:u,timeout:s,agent:f},(e=>{let r="";e.setEncoding("utf8").on("data",(e=>r+=e.toString())).resume().on("end",(()=>{const o={url:(0,l.toNotBlank)(e.url)??t.toString(),contentType:e.headers["content-type"],statusCode:e.statusCode??-1,data:r};n>0&&y.HttpStatusIs.redirect(o.statusCode)&&!(0,l.blank)(e.headers.location)?(console.log("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:o.statusCode}),v().info("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:o.statusCode}),i.observe(w(e.headers.location,{timeoutMs:s,maxRedirects:n}))):(v().debug("complete",{...o,data:(0,d.ellipsize)(r,64),data_length:r.length}),i.resolve(o))}))})).on("error",(e=>i.reject(e)));return(0,l.blank)(e.body)||S.write(e.body),S.end(),i}t.HttpMethods=(0,c.strEnum)("GET","PUT","POST","PATCH","DELETE"),t.get_=w,t.httpRequest_=S},78932:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.httping=void 0;const r=i(19851),n=i(50213),s=i(34238),o=i(4988),a=(0,r.lazy)((()=>(0,n.mkLogger)("net.httping")));t.httping=function(e,t,i,r){return(0,o.get_)(s.URI.from({scheme:"http",authority:e+":"+t,path:i}),{timeoutMs:r}).then((e=>e.statusCode??-1),(e=>{a().warn("get() Failed",{error:e})}))}},65713:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),n=i(19851),s=i(23838),o=i(81168),a=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,n.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,n.lazy)((async()=>{const e=(0,a.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(h(e))}));const d=(0,n.lazy)((()=>({trie:new s.MultiMap,small:[]}))),f=3;function h(e){const t=new s.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=n)return n}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),n=i(96249),s=i(23838),o=i(59455),a=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=s.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,o.toA)(u[t])],s=c(e.substring(1));return(0,n.flatten)(s.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,a.stripDiacritics)(e).normalize())}},30933:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const n=r(i(48161)),s=i(19851),o=i(42659),a=i(31586),l=i(50213),u=i(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>n.default.cpus()),5*o.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=n.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,a.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const n=r(i(48161)),s=i(19851),o=i(31586),a=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),f=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=n.default.freemem(),t=n.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,o.gt0)(r))return f().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return f().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,a.fmtBytes)(i),freemem:(0,a.fmtBytes)(e),totalmem:(0,a.fmtBytes)(t)}})}))},69385:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOnResume=t._setPaused=t.resume=t.pause=t.isPaused=void 0;const r=i(34102),n=i(37692);let s=!1;function o(){return s}function a(e=!0){l(e),(0,n.writeStateFile)({paused:e})}function l(e){e!==s&&(s=e,(0,r.ee)().emit(e?"pause":"resume"))}t.isPaused=o,t.pause=a,t.resume=function(){return a(!1)},t._setPaused=l;const u=Promise.resolve();t.resolveOnResume=function(){return o()?new Promise((e=>{(0,r.ee)().once("resume",e)})):u}},15674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),n=i(42659),s=i(41400),o=i(31586),a=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),f=i(28874),h=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),h.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),f.Settings.cpuBusyPercent.watchLater(y),f.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,r.lazy)((()=>{const e=(0,o.clamp)(128,1024,f.Settings.maxMemoryMb.valueOrDefault)*a.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/a.MB),worstCaseMemPerProcMb:Math.ceil(e/a.MB)}})}),n.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=f.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,o.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,o.toGt0)(f.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,h.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(f.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,h.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=w();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const n=Math.min(e,v());return t=(0,o.clamp)(1,n,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,h.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,o.gt0)(f.Settings.maxConcurrentImports.valueOrDefault)?(0,o.clamp)(1,(0,t.maxCpus)(),f.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=f.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,o.clamp)(1,Math.min((0,t.maxCpus)(),f.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},37692:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addStateEvent=t.writeStateFile=t.readStateFile=t.stateEvents=t.StateEvents=t.StateEventFns=void 0;const n=r(i(78474)),s=i(40958),o=i(76790),a=i(42659),l=i(45599),u=i(41400),c=i(68708),d=i(50989),f=i(87290),h=i(73787),m=i(19851),p=i(50213),g=i(28874),y=i(69385),v=(0,l.defer)((()=>(0,p.mkLogger)("work.SharedState")));let w;t.StateEventFns={checkTasks(){},reloadLicenses(){}},t.StateEvents=(0,d.strEnum)(...(0,c.keys)(t.StateEventFns)),t.stateEvents=new n.default;let S=0;function b(){const e=(0,f.libraryDataDirPosixFile)()?.join("state.json"),t=Date.now(),i=t-S>a.minuteMs;i&&(S=t);const r=e?.existsSync({refresh:i})??!1;return r&&null!=e&&e.eql(w?.nativePath)||(w?.close(),w=void 0),r&&null!=e&&(w??(w=new h.FileWatcher(e.nativePath,{encoding:"utf8",persistent:!1,recursive:!1},P))),e}(0,u.later)((()=>{g.Settings.libraryDir.watchLater(P)}));const P=(0,m.lazy)((()=>t.readStateFile.refresh()),25);t.readStateFile=(0,m.lazy)((()=>{const e=b()?.readJsonSync();for(const i of e?.events??[])M.get(i.e)!==i.ts&&(v().info("emitting event "+i.e),t.stateEvents.emit(i.e),M.set(i.e,i.ts));return(0,y._setPaused)(e?.paused??!1),e}));const M=new Map;function _(e){const i=b();if(null==i)v().error("overwrite(): failed: no library directory");else{const r=i?.readJsonSync(),n=function(e){const t=Date.now()-10*a.minuteMs;return(0,s.uniqByLast)((0,o.sortBy)((e??[]).filter((e=>e.ts>t)),(e=>e.ts)),(e=>e.e))}([...r?.events??[],...e.events??[]]),l={paused:e.paused??r?.paused??g.Settings.startPaused.valueOrDefault,events:n};(0,y._setPaused)(l.paused),t.readStateFile.set(l),i.writeJsonSync(l)}}t.writeStateFile=_,t.addStateEvent=function(e){const t=Date.now();M.set(e,t),_({events:[{e,ts:t}]})}},22751:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),n=i(87997),s=i(19851),o=i(42659),a=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),f=i(976),h=i(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new r.Rate(5*o.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,s.lazy)((()=>(0,n.setInterval)(g,o.minuteMs).unref()));function g(){h.maxCpus.refresh(),h.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,f.rateStats)(e)),g()},(0,a.later)((()=>{(0,d.ee)().on("clearCache",(()=>{h.maxCpus.unset(),h.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),n=i(22573),s=i(50357),o=i(98553),a=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),f=i(59455),h=i(54993);function m(e){return null!=e&&(0,f.toA)(e).length>0}function p(e){return null==e||0===(0,f.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function v(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function S(e){return null==e?[]:v((0,f.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,o.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,a.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const n=[];if(et;s-=i)n.push(r(s));return n}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),n=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===n[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,s.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const n of t){const t=i(n);r.includes(t)||(e.push(n),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,f.toA)(e).map((e=>(0,h.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(n.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,o.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,s.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,o.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of S(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,o.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const n=new Set(i.map(r));return e.filter((e=>!n.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),n=i(36783),s=i(41801),o=i(98553),a=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,n.copyArrayTo)(h(e,t),e)}function f(e,t){const i=new Map;for(const r of e)(0,a.getOrSet)(i,(0,o.stringify)(t(r)),(()=>r));return h(i.values(),t)}function h(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=f,t.sortUniq=function(e){return f(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,n.copyArrayTo)(f(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=h,t.deepSortBy=function e(t,i){return h(t,i).map((t=>(0,s.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},5233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),n=i(31586),s=i(13538),o=i(41583);t.retryOnReject_=async function(e,t){const i=(0,n.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const a=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,o.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await a(l),u()}};return u()}},17586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const r=i(40958),n=i(22573),s=i(96249),o=i(55938),a=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,o.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,o.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,n.blank)(e)?"":"```"+(0,a.toS)(e)+"```"},t.b=function(e){return"**"+(0,a.toS)(e)+"**"},t.li=function(...e){return(0,r.compactBlankish)((0,s.flatten)(e)).map((e=>"- "+(0,a.toS)(e))).join("\n")}},22573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),n=i(42279),s=i(54993);function o(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function a(e){return!o(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,s.toS)(e);return a(i)?t(i):void 0}t.blank=o,t.notBlank=a,t.notBlankToS=function(e){return a(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,n.tot)(t);const i=(0,s.toS)(e).trim();return i.length>0?i:(0,n.tot)(t)},t.notBlankAnd=function(e,t){return!o(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{"use strict";function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),n=i(22573),s=i(30301),o=i(55835),a=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),f=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function h(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?f().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=h,t.fmtDateShort=m,t.splitHMS=function(e){return(0,o.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,a.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=h(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const n=Math.floor(e/t.minuteMs);e-=n*t.minuteMs;const s=Math.floor(e/t.secondMs),o=Math.floor(e-s*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(n)+":"+(0,l.pad2)(s)+(i.includeMs?"."+(0,l.pad3)(o):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),n=i(),s=i(),o=i(),a=i(),l=i();return new Date(t,l-1,a,o,s,n,r)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,i="ago"){return e<1e3?"just now":(i=(0,n.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const s=Math.floor(e/r.ms);e-=s*r.ms,s>0&&(r.ms>=t.dayMs?i:n).push(s+r.s)}return e>0&&n.push((0,a.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(n)?"":"T"+n.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,o.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),n=i(73872);function s(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function o(e,t,i,r){if(null==i||y(e)||y(t))return;let n=i.get(e);null!=n?n.set(t,r):(n=new WeakMap,n.set(t,r),i.set(e,n))}function a(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const n=l(e,t);return null!==n?n:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,h=s(e,t,u);if(null!==h)return h;const m=s(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return o(e,t,u,i),i;const n=l(e,t);if(null!==n)return n}const y=n(e);if(y!==n(t))return o(e,t,u,!1),!1;o(e,t,u,!0);const v=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return a(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(f(e),f(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],n=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){n.push([e,t])})),c(r.sort(),n.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return o(e,t,u,v),v}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let n=-1;for(;++n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const n=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return n.prior=()=>t,n.hasPrior=()=>r,n}},41400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),n=i(35556),s=i(31586),o=i(68708);function a(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const s=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&n.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return a(t).then((()=>t))},t.delay=a,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),s=n.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return n.isBrowser||t<=r.secondMs?s:(0,o.maybeCall)(s,"unref")??s}},33374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const r=i(31586),n=i(21605),s=i(12168);function o(e){return{width:e.height,height:e.width}}function a(e){return((0,r.toGt0)(e?.width)??0)*((0,r.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,r.gt0)(e.width)&&(0,r.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,r.gt0)(e)&&(0,r.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,s.pixels2size)(e.width*e.height)},t.dimSwap=o,t.maybeDimSwap=function(e,t){return(0,n.swappableRotation)(t)?o(e):e},t.maybeFlipInPlace=function(e,t){(0,n.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,s.megapixels)(a(e))},t.pixels=a},50357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),n=i(68708),s=i(34666),o=i(32639);function a(e,t){return(0,r.deepEql)(e,t,{comparator:f})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,o.isFunction)(e)&&(0,o.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=a,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return!1;for(const i of(0,n.keys)(e))if(!a(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function f(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),n=i(22573),s=i(96249),o=i(31586),a=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,n.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,o.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const f=/shortStack|errorToVerbose/;function h(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,s.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return h(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,n.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,n.blank)(e)&&e.trim().startsWith("at ")&&null==f.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,n.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(n.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,a.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,a.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,a.assignFields)(new Error,(0,a.omit)(e,"_ctor"))},t.errorToArr=h,t.errorToS=m},4188:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),n=i(42659),s=i(55835),o=i(31586),a=i(12168),l=[{ms:n.yearMs,s:"year",p:"years"},{ms:n.yearMs/12,s:"month",p:"months"},{ms:n.weekMs,s:"week",p:"weeks"},{ms:n.dayMs,s:"day",p:"days"},{ms:n.hourMs,s:"hour",p:"hours"},{ms:n.minuteMs,s:"minute",p:"minutes"},{ms:n.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,n){if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,s.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,a.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,s.mapOr)(n,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function n(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=n,t.orList=function(e){return n(e,"or")},t.andList=function(e){return n(e,"and")}},50268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const r=i(22573),n=i(38639),s=i(68708),o=i(62220),a=i(50989);t.HealthCheckSections=(0,a.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,a.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,s.isObject)(e)&&!(0,r.blank)(e.id)&&!(0,r.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,r.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,s.isObject)(e)&&o.RunStates.has(e.state)&&(0,n.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},73722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const n=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,n){if((0,isFunction_1.isFunction)(r))return;let s,o,a,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),n=i(50357),s=i(31586),o=i(65812);t.lazy=function(e,t){let i,a;const l=[];function u(){return u.isStale()&&u.setResult(e()),a}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const s=await e,a=await i;if(!(0,n.eql)(s,a))for(const e of l)e(a);null!=t&&t>0&&void 0!==a&&(0,o.setUnrefTimeout)((()=>u.vacuum()),t)}(a,e),a=e},u.isStale=function(){return null==i||(0,s.gt0)(t)&&i+t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),n=i(54993);function s(e,t){return null==e?void 0:t(e)}function o(e,t,i){return null==e||null==t?void 0:i(e,t)}function a(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=o,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=a,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return a(o(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,n.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class n extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=n},23838:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),n=i(76790),s=i(50357),o=i(98553),a=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,a.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,a.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,s.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),n=null==i?[]:e(t,i);(0,r.isEmpty)(n)?this.store.delete(t):this.store.set(t,n)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,n]of this.store.entries()){const s=(0,r.findIndexes)(n,(t=>!e(i,t,n)));if(s.length>0){t=!0;for(const e of s.reverse())n.splice(e,1)}0===n.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,o.stringify)(t)]=i;return e}}function f(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=f,t.groupByValues=function(e,t){const i=f(e,t);return(0,n.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),n=i(22573),s=i(42279),o=i(54993);function a(e){return"number"==typeof e&&isFinite(e)}t.isNumber=a,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,o.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return a(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,o.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const f=e=>(t,i)=>a(t)&&a(i)&&e(t,i);function h(e,i,n){return!(null==n||!a(n))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,n)&&(0,t.gte)(i,n))}function m(e){if(!a(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,n.blank)(e))return t.defaultValue;if(a(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return a(e)&&e>0}function S(e){return a(e)&&e>=0}function b(e,t){return a(e)?t(e):void 0}function P(e){return a(e)?e<0?-Math.round(-e):Math.round(e):0}function M(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function _(e,t,i){if(e>t||!a(e)||!a(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return a(i)?it?t:i:(e+t)/2}t.lt=f(((e,t)=>ee<=t)),t.gt=f(((e,t)=>e>t)),t.gte=f(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return a(e)?e:t},t.diff=function(e,t){return a(e)&&a(t)?e-t:void 0},t.absdiff=function(e,t){return a(e)&&a(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!a(e)||!a(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return h(t-r,t+r,e)},t.within=h,t.max_=function(...e){let t;for(const i of e)a(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return a(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return a(e)&&a(t)&&e>t?e:void 0},t.lte0=function(e){return a(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=v(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,i){return b(e,(e=>b(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return a(e)?t(e):i},t.numericOr=function(e,t){return a(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d+\.\d+)0+$/,"")},t.toPrecision=M,t.toPrecisionMaybe=function(e,t){return d(e,(e=>M(e,t)))},t.sigFigs=function(e,t){if(!a(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=_,t.times=function(e,t){if(!w(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return _(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||h(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!a(i))return;t+=i}return t}},68708:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(32639),a=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function f(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function h(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!h(e)}function p(e){return f(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??f(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function w(e,t,i={}){return y((0,r.compact)((0,n.sort)(f(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function S(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const n={};for(const e of(0,r.uniq)((0,r.flatMap)(i,f)))n[e]=S(...i.map((t=>t[e])));return n}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of f(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=f,t.keysWithDefinedValues=function(e){return null==e?[]:f(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=h,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=v(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,n]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==n&&!0!==i?.assignNullish||(e[r]=n));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,a.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,s.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=a.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function n(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:S(i,t)}for(const r of i){const[i,o]=(0,c.splitFirst)(r,"."),a=b(t,i);null!=a?.value&&n(a.key,(0,s.blank)(o)?a.value:e(a.value,o))}for(const r of f(t))((0,l.toInt)(r)??-1)>=0&&n(r,e(t[r],...i));return r},t.pluck=b,t.pluckDeep=function e(t,i){if(null==t||(0,s.blank)(i))return;if(Array.isArray(t)){const n=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(n)?void 0:{key:n[0].key,value:(0,r.flatMap)(n,(e=>e.value))}}const[n,o]=(0,c.splitFirst)(i,"."),a=b(t,n);if(null==a)return;if((0,s.blank)(o))return a;const l=e(a.value,o);return null==l?void 0:{key:a.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=f(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,o.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of f(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=w(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return n(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return s(e).flatMap((e=>s(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return s(e).flatMap((e=>s(t).flatMap((t=>s(i).flatMap((i=>r(this.a,e,t,i)))))))}}function n(e){return e instanceof r||e===t.None}function s(e){return n(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=n,t.opt=s},97238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSeed=t.prngSeed=t.SeedCount=t.PrimeBins=t.PrimesPerBin=void 0;const r=i(31586),n=i(30976),s=i(54993);t.PrimesPerBin=4,t.PrimeBins=8,t.SeedCount=t.PrimesPerBin**t.PrimeBins,t.prngSeed=function(){return(0,n.randomInt)(0,t.SeedCount)},t.toSeed=function(e){const i=(0,r.toInt)((0,s.toS)(e));return(0,r.within)(0,t.SeedCount,i)?i:void 0}},39926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),n=i(54993),s={};function o(e,t){if(t<1)return"";if(!(0,r.gte)(s[e]?.length,t)){let i=s[e]??e;for(;i.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var r=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return r.parseJSON}})},46891:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),n=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,o=/[^aeiou]y$/,a=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=n.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(o)?e.replace(/y$/i,"ies"):null!=e.match(a)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),n=i(54993),s=["number","string","boolean"];function o(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=o,t.mapPrimitive=function(e,t){return o(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return o(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(o)};const a=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,s=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==s&&"symbol"!==s)){const r=(0,n.toS)(e),s=(0,n.toS)(i),o=r.localeCompare(s);return r[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-o:o}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==s?a.indexOf(r)-a.indexOf(s):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function n(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const n of(0,r.toA)(await e))if(null!=n){const e=await n;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=n,t.isPromise=function(e){return n(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),n=i(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function o(e,t,i){return null==i||0===i.length?s(e,t):a(e,t,1,i)[0]}function a(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const n=t-e,o=new Set(r??[]);if(t===e&&0===n&&0===o.size&&1===i)return[e];const a=n-o.size;if(i>a)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:n,size:i,slotsRemaining:a})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of a(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,n.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let r=e;t.global||(t=new RegExp(t,"g"));let n=null;for(;null!=(n=t.exec(e));)n.index===t.lastIndex&&t.lastIndex++,r=r.slice(0,n.index)+i(n)+r.slice(n.index+n[0].length);return r}},21605:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const r=i(31586);function n(e){if(!(0,r.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,r.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=n,t.swappableRotation=function(e){const t=n(e);return 90===t||270===t}},62220:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const r=i(50989);t.RunStates=(0,r.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),n=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const o=e=>null!=e?i[e]:void 0,a=e=>null!=o(e);return{...s,values:t,length:t.length,has:a,includes:a,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:o,ordinal:e=>o(e)??t.length,validOrElse:(e,t)=>a(e)?e:(0,n.tot)(t),mapValid:(e,t)=>a(e)?t(e):void 0,cmp:(e,t)=>{const i=o(e),r=o(t);return null==i||null==r?void 0:i>r?1:i{const i=o(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),n=i(17586),s=i(22573),o=i(96249),a=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let f;function h(){if(void 0===f)try{f=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{f=null}return f??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=h();return null!=r?(0,a.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=h();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function b(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),n=(0,c.toS)(t);return r.length===n.length&&(r===n||r.toLowerCase()===n.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?n.normalize():n,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,n.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=h();return null!=t?(0,a.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return w(v(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,i){const r=i?.maxLineLen??80,n=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,o.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,o.flatten)(r.map((t=>e(t,i))))}if((t=v((0,c.toS)(t),n).trim()).length<=r)return[t];const s=S(t," ",r);if(s>n.length)return[m(t,0,s),...e(m(t,s+1),i)];{const r=t.indexOf(" ",n.length+1);return r>0&&r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),n=i(68708),s=i(42279),o=i(83104),a=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let n=!0;const s=setTimeout((()=>{n&&(n=!1,i(o.Timeout))}),t);try{s.unref?.();const t=await e;n&&(n=!1,i(t))}catch(e){n&&(n=!1,r(e))}finally{clearTimeout(s)}}))}async function u(e,t,i=!0){const n=await l(e,t,i);if(n===o.Timeout)throw new a.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return n}t.toNotTimeout=function(e){return e===o.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?o.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,s)=>{let o=!0;try{const a=setTimeout((async()=>{if(o){o=!1;try{r(await i())}catch(e){s(e)}}}),t);(0,n.maybeCall)(a,"unref");const l=await e;o&&(o=!1,clearTimeout(a),r(l))}catch(e){o&&(o=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const n=t-Date.now();if(n<=0)throw new a.TimeoutError("timeout ("+(0,r.fmtHMS)(n)+")");return u(e,n,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const n=await l(e,t,r);return n===o.Timeout?(0,s.tot)(i):n}},42279:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),n=i(22573),s=i(54993);function o(e){return"URLSearchParams"===e?.constructor?.name}function a(e){return null==e?void 0:o(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(a)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=o,t.toURLSearchParams=a,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,s.toS)(l(...t));return e+((0,n.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,s.toS)(l(...t));return(0,n.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),n=i(30301),s=i(31586),o=i(46891),a=i(50989),l=i(51926),u=(0,n.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,s.isNumber)(r)&&(i+=r/t.MB);return(0,s.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],f=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function h(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),n=Math.pow(10,3*r),o=d[r];return(0,s.sigFigs)(e/n,t)+" "+o}t.fmtMB=function(e,i=3){return h(e*t.MB,i)},t.fmtBytes=h,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),n=Math.pow(2,10*r),o=f[r];return(0,s.sigFigs)(e/n,t)+" "+o},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,a.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,o.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,o.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},2322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,r=/\bSafari\b/,n=/\bFirefox\b/,s=/\biPad\b/,o=/\biPhone\b/;function a(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return a(e,i)}function u(e){return a(e,n)}t.isChrome=l,t.isSafari=function(e){return a(e,r)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return a(e,s)},t.isIphone=function(e){return a(e,o)}},79114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.S=void 0;const r=i(50989);t.S=(0,r.strEnum)("plus","lite")},75020:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInfoTag=t.NotInfoPanelTags=t.LibraryTagName=t.TagRoots=t.isTagRef=t.ctxToS=t.TagGalleryProps=t.nextChildTagsUrl=t.nextAssetsUrl=t.BeforeAfterStreamLimit=t.ThumbsPerSample=void 0;const r=i(76790),n=i(22573),s=i(98553),o=i(31586),a=i(50989),l=i(51926),u=i(29652);t.ThumbsPerSample=128,t.BeforeAfterStreamLimit=8,t.nextAssetsUrl=function(e,t){const i={};return(0,o.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/assets`,i)},t.nextChildTagsUrl=function(e,t){const i={};return(0,o.mapNumeric)(t.seed,(e=>i.seed=e.toString())),(0,o.mapNumeric)(t.limit,(e=>i.limit=e.toString())),(0,o.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/child-tags`,i)},t.TagGalleryProps=["tagId","tagPath","assetCount","assetIds","nextAssets","childTags","nextChildTags"],t.ctxToS=function(e){return(0,s.stringify)({seed:e.seed,tagIds:(0,r.sort)([...e.tagIds])})},t.isTagRef=function(e){return null!=e&&!(0,l.isString)(e)&&(0,n.notBlank)(e.name)},t.TagRoots=(0,a.strEnum)("When","Who","Where","What","Camera","Lens","Albums","Keywords","Type","fs"),t.LibraryTagName="Library",t.NotInfoPanelTags=[t.TagRoots.When,t.TagRoots.Camera,t.TagRoots.Lens,t.TagRoots.Type,t.TagRoots.fs],t.isInfoTag=function(e){if(null==e)return!1;const i=(0,l.isString)(e)?e:e.tagPath?.[0];return!t.NotInfoPanelTags.includes(i)}},27776:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkTagUri=t.mkTagFullPath=t.mkHomeFullPath=t.urlSeed=void 0;const r=i(40958),n=i(30301),s=i(31586),o=i(97238),a=i(29652);function l(e,i){const r=(0,a.toURLSearchParams)(e);if(i||!(0,s.isDigits)(r?.get("seed"))){const e=(0,t.urlSeed)().toString();return r?.set("seed",e),r??{seed:e}}return r}function u(e,t,i=!1){const r=c(e,t,i);return(0,a.assembleFullPath)(r.path,r.query)}function c(e,t,i=!1){return{path:"/tag/"+((0,r.isEmpty)(e)?"":e.map(encodeURIComponent).join("/")),query:l(t,i)}}t.urlSeed=(0,n.lazy)(o.prngSeed,100),t.mkHomeFullPath=function(e){return u([],e,!0)},t.mkTagFullPath=u,t.mkTagUri=c},23541:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),n=i(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,n.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),n=i(23541),s=i(59455),o=i(54993);function a(e){return null==e?void 0:(0,n.isError)(e)?e:new Error((0,o.toS)(e))}t.toErr=a,t.toErrs=function(...e){return(0,r.compact)((0,s.toA)(e).map(a))}},54993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return s(e,",")};const n={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==n?e.toString():(0,r.stringify)(e)}}t.toStr=s},61209:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.MainService=void 0;const d=c(i(1708)),f=i(19851),h=i(50213),m=i(54826),p=i(22911),g=i(27395),y=i(78406),v=i(25764),w=i(38836),S=i(99331),b=i(45608),P=i(73614),M=i(86335),_=i(55534),E=i(38835),T=i(70025),x=i(8769),D=i(83278),k=i(19652),C=i(85021),O=i(28874),I=i(2858),F=i(34238),L=i(51140),A=c(i(98604)),R=i(78932),N=i(69385),j=i(22573),B=i(38639),z=i(42659),V=i(98553),W=i(55835),U=i(31586),H=i(68708),q=i(54993),G=i(37158);class ${constructor(){r.add(this),this.start=Date.now(),n.set(this,(0,f.lazy)((()=>(0,h.mkLogger)("MainService")))),this.httpPort=new p.Deferred("MainService.httpPort"),this.libraryDir=new p.Deferred("MainService.libraryDir"),s.set(this,void 0),o.set(this,void 0),this.setup=(0,f.lazy)((async()=>{l(this,s,await M.ChildService.mk_("web",{onStdout:e=>this.onWebout("stdout",e),onStderr:e=>this.onWebout("stderr",e),onData:e=>this.onWebData(e),onRestartPaused:()=>(0,b.exit)({reason:"Too many web service fatal errors",status:13})}),"f"),await(0,j.mapNotBlank)(O.Settings.pidFile.value,(async e=>{const t=D.BaseFile.for(e);u(this,n,"f").call(this).info("Writing to pidfile "+t,{pid:d.default.pid}),await t.writeText_((0,q.toS)(d.default.pid)),new w.EndableWrapper("remove pidfile",(()=>t.unlink()),v.EndableRanks.postdb)})),await this.service.ready;try{await(0,k.externalDirectoryCheck)()}catch(e){u(this,n,"f").call(this).warn("Failed to check external directory permissions",{error:e})}if(this.service.setInputHandler("--restart-sync",(()=>this.restartSync())),this.service.setInputHandler(C.HealthCheckCommand,(()=>u(this,r,"m",a).call(this))),null==u(this,s,"f"))return(0,x.onError)("Failed to start webservice"+E.FatalErrorFlag);this.httpPort.promise.then((e=>{const t=(0,A.default)(e),i=(1===t.length?" ":"\n - ")+t.map((e=>`${e}`)).join("\n - ");(0,m.consoleLog)(`PhotoStructure is ready:${i}`),O.Settings.exposeNetworkWithoutAuth.valueOrDefault||(0,m.consoleLog)("See https://photostructure.com/faq/remote-access/ to enable non-localhost access.")})),this.libraryDir.promise.then((e=>{(0,m.consoleLog)(`Your library is at <${F.URI.file(e)}>`)})),new w.EndableWrapper("shutdown notice",(()=>(0,m.consoleLog)("\nShutting down PhotoStructure...")),v.EndableRanks.first),(0,U.gt0)(O.Settings.healthCheckIntervalMs.valueOrDefault)&&new y.EndableInterval({name:"webSyncHealthChecks",intervalMs:O.Settings.healthCheckIntervalMs.valueOrDefault,callback:()=>u(this,r,"m",a).call(this)})})),this.service=new G.Service("main"),this.setup(),(0,P.setUnrefTimeout)((()=>{this.httpPort.isPending&&!(0,S.ending)()&&(0,m.consoleLog)("Please wait, setting up...")}),4*z.secondMs)}async webHealthCheck(){const e=this.httpPort.value;if(null!=e)try{const t=await(0,R.httping)("localhost",e,"/ping",3*z.secondMs);return!!L.HttpStatusIs.success(t)||(u(this,n,"f").call(this).warn("webHealthCheck(): web service returned "+t),!1)}catch(e){return u(this,n,"f").call(this).warn("webHealthCheck(): httping error: "+e),!1}else u(this,n,"f").call(this).info("webHealthCheck(): no-op, no http port set (web is starting up still)")}onWebout(e,t){return u(this,n,"f").call(this).info("onWebout",{pipe:e,error:t}),t===_.ServiceExitCommand?(0,b.exit)({reason:"Web service exit command",status:0}):(t??(t=""),/EADDRINUSE/i.test(t)||t.includes(E.WebFatalErrorFlag)||(0,T.isFatalError)(t)?(0,b.exit)({status:1,reason:"Web service error",error:t}):this.onWebData((0,V.parseJSON)(t)))}async onWebData(e){(0,j.blank)(e)||(u(this,n,"f").call(this).info("onWebData",{input:e}),(0,W.map)(e[O.Settings.httpPort.key],(e=>{u(this,n,"f").call(this).info("Got HTTP port number from web service:"+e),O.Settings.httpPort.envValue=e,this.httpPort.maybeResolve(e)})),(0,B.mapBoolean)(e.pause,(e=>e?(0,N.pause)():(0,N.resume)())),await(0,B.mapTrue)(e.shutdown,(()=>(0,b.exit)({reason:"shutdown requested",status:0}))),await(0,B.mapTrue)(e.shutdownSync,(()=>this.shutdownSync())),(0,B.isTrue)(e.forceRestartSync)?await this.forceRestartSync():(0,B.isTrue)(e.restartSync)&&await this.restartSync())}async shutdownSync(){const e=u(this,o,"f");return l(this,o,void 0,"f"),u(this,n,"f").call(this).info("shutdownSync()",{syncWasDefined:null!=e}),(0,g.end)(e)}async forceRestartSync(){return this.restartSync()}async restartSync(){const e=(0,h.mkLogger)("MainService.restartSync()");if((0,S.ending)())return void e.info("ending, no-op");const t=u(this,o,"f");if(e.info("priorSync",(0,W.map)(t,(e=>(0,H.pick)(e,"pid","name")))),await(0,g.end)(t),l(this,o,void 0,"f"),await(0,I.readSystemSettings)(),!I.libraryHasSettings.refresh())return void e.info("restartSync(): no library settings",{libraryDir:O.Settings.libraryDir.value});const i=l(this,o,await M.ChildService.mk_("sync"),"f");e.info("Started sync",(0,W.map)(i,(e=>(0,H.pick)(e,"pid","name"))))}}t.MainService=$,n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=async function(){!1===await this.webHealthCheck()?await u(this,s,"f").restart():u(this,s,"f").runHealthCheck(),u(this,o,"f")?.runHealthCheck()},$.instance=(0,f.lazy)((()=>new $))},18449:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sentryEnabled=void 0;const r=i(7282),n=i(96706),s=i(29325),o=i(28874);t.sentryEnabled=function(){return(0,n.isEnvTrue)("ENABLE_SENTRY")||(0,r.isProd)()&&(0,s.isPacked)()&&!0===o.Settings.reportErrors.value}},95629:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelToSeverity=t.logEntryToBreadcrumb=t.mkBreadcrumbs=t.annotateEvent=t.sentryExceptionToS=t.sentryExceptionsToS=t.extractMessage=t.EventFilter=t.eventFilter=t.sendToSentry=t.installSentry=void 0;const a=s(i(16436)),l=o(i(48161)),u=o(i(1708)),c=i(19851),d=i(19043),f=i(50213),h=i(31578),m=i(7282),p=i(96175),g=i(23560),y=i(84968),v=i(81168),w=i(37805),S=i(25764),b=i(38836),P=i(99331),M=i(85100),_=i(98314),E=i(68301),T=i(70025),x=i(8769),D=i(34102),k=i(34592),C=i(42042),O=i(34474),I=i(20839),F=i(57902),L=i(45969),A=i(43334),R=i(40958),N=i(22573),j=i(42659),B=i(41400),z=i(98553),V=i(55835),W=i(12168),U=i(59455),H=i(54993),q=i(18449),G=(0,c.lazy)((()=>(0,f.mkLogger)("Sentry")));function $(e){(0,q.sentryEnabled)()&&null!=e&&!0!==(0,T.isDoNotSendError)(e)&&a.captureException(e)}t.installSentry=async function(e){try{return!!(0,q.sentryEnabled)()&&(a.init({dsn:A.isElectron?"https://0652cdd351054fe9853ff944b1f54e2c@o130922.ingest.sentry.io/289071":"https://5f52aefec1b3439eaed2e77b2d1210a8@o130922.ingest.sentry.io/1828379",shutdownTimeout:(0,M.serviceExitTimeoutMs)(e.name),release:w.release,environment:(0,m.nodeEnv)(),maxBreadcrumbs:100,integrations:[],beforeSend:(0,t.eventFilter)().beforeSend,onFatalError:e=>(0,x.onError)("sentry.onFatalError",e)}),G().info("Sentry initialized",{isElectron:A.isElectron}),!0)}catch(e){return G().warn("Failed to set up sentry",{error:e}),!1}},t.sendToSentry=$,t.eventFilter=(0,c.lazy)((()=>new J));class J{constructor(){this.beforeSend=async(e,t)=>{if(!(0,q.sentryEnabled)())return G().warn("Sentry.beforeSend(): not sending event",e),null;if(!0===await(E.ErrorStore.instance()?.eventQuotaExceeded(e)))return G().warn("Sentry.beforeSend(): event quota exceeded",e),null;const i=K(e,t);if(!0===(0,T.isDoNotSendError)(i))return G().info("Sentry.beforeSend(): event not sendable. vetoing",{event:e,hint:t,msg:i}),null;(0,N.blank)(e.message)&&(e.message=(0,v.ellipsize)(i,256));const r=await X(e);return await(E.ErrorStore.instance()?.maybeSendEvent(r))??null},(0,D.ee)().on("fatal",$),(0,D.ee)().on("nonFatal",$),new b.EndableWrapper("EventFilter",(()=>this.end()),S.EndableRanks.first)}end(){return(0,V.map)(a.getCurrentHub().getClient(),(e=>e.close(5*j.secondMs)))}}function K(e,t){return(0,R.uniq)((0,R.compactBlankish)([e.message,...(0,U.toA)(Z(e.exception?.values)),(0,_.errorToS)(t?.originalException)])).join(": ")}function Z(e){return(0,R.mapNotEmpty)(e,(e=>(0,R.compactBlanks)(e.map(Y))))}function Y(e){return(0,R.mapNotEmpty)((0,R.compactBlanks)([e?.type,e?.value].filter((e=>"error"!==(0,H.toS)(e).toLowerCase()))),(e=>e.join(": ")))}async function X(e){const t=await(0,C.getEmail)();(0,N.notBlank)(t)&&(null==e.user&&(e.user={}),e.user.email=t),(0,R.isEmpty)(e.breadcrumbs)&&(e.breadcrumbs=await Q());const i=e.extra??{};return i.pid=u.default.pid,i.serviceName=(0,g.serviceName)(),i.serviceEnding=(0,P.ending)(),i.runtimeMs=(0,y.runtimeMs)(),i.version=w.version,i.os=(0,p.osFullName)(),i.isDocker=(0,L.isDocker)(),i.nodeVersion=u.default.versions.node,i.locale=await(0,d.locale)(),i.cpus=(0,p.CPUs)(),i.memoryUsageMb=(0,h.memoryUsageMb)(),i.memoryUsageRssMb=(0,h.memoryUsageRssMb)(),i.systemMemory=(0,W.fmtBytes)(l.default.freemem())+" / "+(0,W.fmtBytes)(l.default.totalmem()),i.ffmpeg=await(0,k.ffmpegVersionDescription)(),i.argv=(0,z.stringify)(u.default.argv),e.extra=i,{timestamp:Date.now()/j.secondMs,...e}}async function Q(){await(0,B.delay)(3*I.DefaultLogFlushMs);const e=await(0,O.allRecentLogEntries)();return(0,R.compact)(e.map(ee))}function ee(e){return(0,V.map)(ie(e.l),(t=>({timestamp:e.ts/j.secondMs,level:t,category:e.from??(0,g.processName)(),message:(0,v.stripAnsiEsc)(e.ctx+": "+e.msg),data:"object"==typeof e.meta?e.meta:{value:(0,v.isString)(e.meta)?(0,v.stripAnsiEsc)(e.meta):e.meta}})))}t.EventFilter=J,t.extractMessage=K,t.sentryExceptionsToS=Z,t.sentryExceptionToS=Y,t.annotateEvent=X,t.mkBreadcrumbs=Q,t.logEntryToBreadcrumb=ee;const te=new Map([[F.LogLevels.fatal,"fatal"],[F.LogLevels.error,"error"],[F.LogLevels.warn,"warning"],[F.LogLevels.info,"info"],[F.LogLevels.debug,"debug"]]);function ie(e){return te.get(e)}t.logLevelToSeverity=ie},37158:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c,d,f=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Service=t.setupEventHandlers=void 0;const p=m(i(29907)),g=m(i(1708)),y=i(57206),v=i(19851),w=i(50213),S=i(59880),b=i(23560),P=i(19913),M=i(71567),_=i(37805),E=i(38836),T=i(99331),x=i(45608),D=i(56038),k=i(55534),C=i(42499),O=i(49776),I=i(96706),F=i(98314),L=i(38835),A=i(70025),R=i(8769),N=i(57159),j=i(34102),B=i(33456),z=i(87408),V=i(85021),W=i(17181),U=i(86941),H=i(28874),q=i(41692),G=i(2858),$=i(69385),J=i(22573),K=i(42659),Z=i(41400),Y=i(56409),X=i(55835),Q=i(41583),ee=i(54993),te=i(95629);t.setupEventHandlers=(0,v.lazy)((()=>{(0,j.ee)().on("resume",(()=>(0,$.resume)())),(0,j.ee)().on("pause",(()=>(0,$.pause)()))}));class ie extends E.EndableWrapper{constructor(e){super(e),r.add(this),n.set(this,void 0),s.set(this,new Y.Latch),o.set(this,new Map),this.setup_=(0,v.lazy)((()=>(0,D.time)("Service.setup",(()=>h(this,r,"m",a).call(this))))),u.set(this,(0,v.lazy)((()=>{const e=g.default.stdin.pipe(new B.LineReader);return e.on("data",(e=>h(this,r,"m",d).call(this,(0,ee.toS)(e)))),e}))),(0,b.isBillingService)()||(0,q.setSettingsDefaults)(),f(this,n,(0,w.mkLogger)("Service("+this.name+")"),"f"),h(this,r,"m",c).call(this),this.setup_()}get name(){return super.name}get ready(){return h(this,s,"f").promise}get isReady(){return h(this,s,"f").isResolved()}setInputHandler(e,t){h(this,o,"f").set(e.trim().toLowerCase(),t)}}t.Service=ie,n=new WeakMap,s=new WeakMap,o=new WeakMap,u=new WeakMap,r=new WeakSet,a=async function(){try{(0,J.mapNotBlank)((0,I.getEnv)("PS_FATAL_"+this.name),(e=>{throw new N.WrappedError(e,{fatal:!0})})),(0,J.mapNotBlank)((0,I.getEnv)("PS_CRASH_"+this.name),(e=>{(0,Z.later)((()=>{throw new N.WrappedError(e)}),5*K.secondMs)})),(0,P.setServiceName)(this.name),(0,S.setProcessTitle)(),(0,b.isMainService)()&&await(0,U.mergeUserDataDirs_)(),await(0,G.readSettings)(),await h(this,r,"m",l).call(this),(0,W.setupLogger)(),(0,y.addDefaultJsonRevivers)(),(0,O.cacheDir)(),(0,t.setupEventHandlers)(),h(this,u,"f").call(this),await(0,C.setupLuxon)(),H.Settings.startPaused.valueOrDefault&&(0,$.pause)(),(0,T.ending)()?h(this,s,"f").reject():h(this,s,"f").resolve()}catch(e){console.error((0,F.errorToS)(e)),h(this,s,"f").reject((0,Q.toErr)(e)),(0,x.exit)({reason:(0,A.addErrorFlags)(this.name+" setup failed: "+(0,F.errorToS)(e),L.FatalErrorFlag),status:14})}},l=async function(){(0,b.isPermaService)()||(0,j.ee)().on("fatal",(e=>(0,x.exit)({error:e,status:12}))),g.default.on("unhandledRejection",(e=>(0,X.map)(e,(e=>(0,R.onError)("unhandledRejection",e))))),g.default.on("uncaughtException",(e=>(0,X.map)(e,(e=>(0,R.onError)("uncaughtException",e))))),g.default.on("SIGINT",(()=>(0,x.exit)({reason:"SIGINT",status:0}))),g.default.on("SIGHUP",(()=>(0,x.exit)({reason:"SIGHUP",status:0}))),g.default.on("SIGTERM",(()=>(0,x.exit)({reason:"SIGTERM",status:0}))),p.default.isWorker&&g.default.on("disconnect",(()=>(0,x.exit)({reason:"disconnect",status:0}))),await(0,te.installSentry)(this)},c=function(){this.setInputHandler("--version",(()=>(0,M.stdoutWrite)({version:_.version}))),this.setInputHandler(k.ServiceExitCommand,(()=>(0,Z.later)((()=>(0,x.exit)({reason:k.ServiceExitCommand+" from stdin",status:0}))))),this.setInputHandler("--times",(()=>(0,M.stdoutWrite)(D.PromiseTimer.instance().report()))),this.setInputHandler(V.HealthCheckCommand,(async()=>(0,M.stdoutWrite)(await(0,z.getStatusSummary)({refresh:!0}))))},d=async function(e){if(h(this,n,"f").debug("onLine()",{line:e,ending:this.ended||(0,T.ending)()}),await this.setup_(),e.startsWith("--")){const t=e.split(/\s+/,1)[0],i=h(this,o,"f").get(t);null==i?(h(this,n,"f").error("onLine(): unknown command",{line:e,knownCommands:[...h(this,o,"f").keys()]}),console.warn("unknown command "+e)):await i(e.slice(t.length).trim())}else h(this,n,"f").error("onLine(): failed to process",{line:e})}},38530:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DaemonArgs=void 0;const n=i(58587),s=i(31421),o=r(i(1708)),a=i(9727),l=i(83278),u=i(95402),c=i(28874),d=i(2858),f=i(22573),h=i(38639),m=i(31586);t.DaemonArgs={beforeParse:e=>e.option("-p, --pidfile PIDFILE","Write a pidfile of the main process.").option("--stop","Shutdown daemonized PhotoStructure. Requires --pidfile").option("-d, --daemon","Run PhotoStructure as a daemon. Enabled by default when --pidfile is provided."),afterParse:async e=>{if((0,f.mapNotBlank)(e.pidfile,(e=>c.Settings.pidFile.envValue=e)),(0,h.isTrue)(e.stop)){if(!c.Settings.pidFile.hasValue()&&(await(0,d.readSystemSettings)(),!c.Settings.pidFile.hasValue()))return console.error("--stop requires --pidfile to be set."),o.default.exit(1);const e=l.BaseFile.for(c.Settings.pidFile.value);if(await e.notExists())return console.error("Pidfile "+e+" does not exist."),o.default.exit(1);const t=(0,m.toInt)(await e.readTextFile());return(0,m.gt0)(t)?(0,n.pidExists)(t)?(await(0,u.killPid)(t),o.default.exit(0)):(console.error("Pid "+t+" does not exist."),o.default.exit(1)):(console.error("Pidfile "+e+" is invalid."),o.default.exit(1))}if(!(0,h.isTrue)(o.default.env.__is_daemon)&&((0,h.isTrue)(e.daemon)||c.Settings.pidFile.hasValue())){const e=o.default.argv.findIndex((e=>!e.includes("npx")&&!e.includes("node"))),t=o.default.argv.slice(-1===e?0:e),i=process.execPath,r={...(0,a.childEnv)(),__is_daemon:"1"},n=(0,s.spawn)(i,t,{env:r,detached:!0,shell:!0});return n.unref(),console.log("Daemonized PhotoStructure.",{pid:n.pid,args:t}),o.default.exit(0)}}}},98392:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExposeArg=void 0;const r=i(28874),n=i(38639);t.ExposeArg={beforeParse:e=>e.option("--expose","The web service is only accessible to the computer running PhotoStructure by default. Providing this option will expose your library to all computers on your network. See https://photostructure.com/faq/remote-access/ ."),afterParse:e=>{(0,n.isTrue)(e.expose)&&(r.Settings.exposeNetworkWithoutAuth.envValue=!0)}}},31503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogArgs=void 0;const r=i(23560),n=i(83210),s=i(28874),o=i(38639);function a(){return(0,r.isMainService)()||(0,r.isSyncService)()}t.LogArgs={beforeParse:e=>{const t=(a()?', "PS_TAIL_LOGS=true"':"")+' and "PS_LOG_STDOUT=true".';return a()?e.option("-v, --verbose",'Verbose logging from all processes. Shortcut for "--info --tail". Caution: noisy during imports!'):e.option("-v, --verbose","Verbose logging. Equivalent to --info."),e.option("--error",`Emit "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=error"${t}`),e.option("--warn",`Emit "warn" and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=warn"${t}`),e.option("--info",`Emit "info", "warn", and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=info"${t}`),e.option("--debug",`Emit "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY NOISY. Sets "PS_LOG_LEVEL=debug"${t}}`),e.option("--trace",`Emit "trace", "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY VERY NOISY. Sets "PS_LOG_LEVEL=trace"${t}}`),a()&&e.option("--tail",'Emit log messages from both this process and all other concurrently running PhotoStructure processes on this host to stdout. This can be really helpful in seeing how PhotoStructure\'s processes are coordinating work. Caution: very noisy especially during imports. Sets "PS_TAIL_LOGS=true".'),e},afterParse:e=>{const t=(0,o.isTrue)(e.error),i=(0,o.isTrue)(e.warn),r=(0,o.isTrue)(e.info)||(0,o.isTrue)(e.verbose)||(0,o.isTrue)(e.v),l=(0,o.isTrue)(e.debug),u=(0,o.isTrue)(e.trace);u?s.Settings.logLevel.envValue="trace":l?s.Settings.logLevel.envValue="debug":r?s.Settings.logLevel.envValue="info":i?s.Settings.logLevel.envValue="warn":t&&(s.Settings.logLevel.envValue="error"),(0,n.isDaemon)(e)?(s.Settings.tailLogs.envValue=!1,s.Settings.logStdout.envValue=!1):((0,o.isTrue)(e.tail)&&(s.Settings.tailLogs.envValue=!0),(t||i||r||l||u)&&(s.Settings.logStdout.tmpValue=!0,a()&&(s.Settings.tailLogs.tmpValue=!0)),(s.Settings.tailLogs.valueOrDefault||s.Settings.logStdout.valueOrDefault)&&s.Settings.logLevel.isUnset()&&(s.Settings.logLevel.envValue="info"))}}},12195:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoFilterArg=void 0;const r=i(4175),n=i(38639);t.NoFilterArg={beforeParse:e=>e.option("--no-filter","Disables import filters. All paths will try to be imported, even if they are too small or are missing tags. See https://photostructure.com/faq/why-is-my-file-missing/ ."),afterParse:async e=>{(0,n.isFalse)(e.filter)&&(0,r.disableAllFilters)()}}},33321:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PauseSyncArg=void 0;const r=i(28874),n=i(38639);t.PauseSyncArg={beforeParse:e=>e.option("--pauseSync","Pause sync processing until manually resumed via the system tray or nav menu."),afterParse:e=>{(0,n.isTrue)(e.pauseSync)&&(r.Settings.startPaused.envValue=!0)}}},51088:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MainArgs=void 0;try{i(93944).install()}catch{}const r=i(69554),n=i(43380),s=i(28874),o=i(38639),a=i(5670),l=i(61209),u=i(38530),c=i(98392),d=i(31503),f=i(12195),h=i(33321);t.MainArgs={beforeParse:e=>e.option("--quiet","Don't emit lifecycle messages to stdout from the main service."),afterParse:e=>{(0,o.isTrue)(e.quiet)&&(s.Settings.quiet.tmpValue=!0)}},async function(){try{await new r.CLI(a.ServiceNames.main).add(t.MainArgs,c.ExposeArg,h.PauseSyncArg,u.DaemonArgs,f.NoFilterArg,n.WriteSettingsArg,d.LogArgs).parse(),new l.MainService}catch(e){console.error("Failed to start:")}}()},90858:e=>{"use strict";e.exports=require("@iarna/toml")},53705:e=>{"use strict";e.exports=require("@photostructure/tz-lookup")},16436:e=>{"use strict";e.exports=require("@sentry/node")},64770:e=>{"use strict";e.exports=require("assert")},58587:e=>{"use strict";e.exports=require("batch-cluster")},6858:e=>{"use strict";e.exports=require("commander")},36507:e=>{"use strict";e.exports=require("croner")},66261:e=>{"use strict";e.exports=require("events")},77988:e=>{"use strict";e.exports=require("exiftool-vendored")},68817:e=>{"use strict";e.exports=require("file-type")},44652:e=>{"use strict";e.exports=require("fs-extra")},28787:e=>{"use strict";e.exports=require("he")},51168:e=>{"use strict";e.exports=require("luxon")},22915:e=>{"use strict";e.exports=require("platform-folders")},57272:e=>{"use strict";e.exports=require("plist")},85949:e=>{"use strict";e.exports=require("process")},90595:e=>{"use strict";e.exports=require("punycode")},38064:e=>{"use strict";e.exports=require("semver")},9288:e=>{"use strict";e.exports=require("sharp")},93944:e=>{"use strict";e.exports=require("source-map-support")},73872:e=>{"use strict";e.exports=require("type-detect")},92460:e=>{"use strict";e.exports=require("util")},75162:e=>{"use strict";e.exports=require("util/types")},29907:e=>{"use strict";e.exports=require("cluster")},76982:e=>{"use strict";e.exports=require("crypto")},31421:e=>{"use strict";e.exports=require("node:child_process")},77598:e=>{"use strict";e.exports=require("node:crypto")},40610:e=>{"use strict";e.exports=require("node:dns")},78474:e=>{"use strict";e.exports=require("node:events")},73024:e=>{"use strict";e.exports=require("node:fs")},51455:e=>{"use strict";e.exports=require("node:fs/promises")},37067:e=>{"use strict";e.exports=require("node:http")},44708:e=>{"use strict";e.exports=require("node:https")},77030:e=>{"use strict";e.exports=require("node:net")},48161:e=>{"use strict";e.exports=require("node:os")},76760:e=>{"use strict";e.exports=require("node:path")},53916:e=>{"use strict";e.exports=require("node:path/posix")},1708:e=>{"use strict";e.exports=require("node:process")},57075:e=>{"use strict";e.exports=require("node:stream")},46466:e=>{"use strict";e.exports=require("node:stream/promises")},87997:e=>{"use strict";e.exports=require("node:timers")},57975:e=>{"use strict";e.exports=require("node:util")},38522:e=>{"use strict";e.exports=require("node:zlib")},16928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.exports}var __webpack_exports__=__webpack_require__(51088);module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{var __webpack_modules__={60308:e=>{const t={PasetoNotSupported:"ERR_PASETO_NOT_SUPPORTED",PasetoDecryptionFailed:"ERR_PASETO_DECRYPTION_FAILED",PasetoInvalid:"ERR_PASETO_INVALID",PasetoVerificationFailed:"ERR_PASETO_VERIFICATION_FAILED",PasetoClaimInvalid:"ERR_PASETO_CLAIM_INVALID"};class i extends Error{constructor(e){super(e),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}e.exports.PasetoError=i,e.exports.PasetoNotSupported=class extends i{},e.exports.PasetoDecryptionFailed=class extends i{},e.exports.PasetoInvalid=class extends i{},e.exports.PasetoVerificationFailed=class extends i{},e.exports.PasetoClaimInvalid=class extends i{}},78972:(e,t,i)=>{const{PasetoInvalid:r,PasetoNotSupported:n}=i(60308),{decode:s}=i(47859),o=i(40816);e.exports=(e,{parse:t=!0}={})=>{if("string"!=typeof e)throw new TypeError("token must be a string");const{0:i,1:a,2:l,3:u,length:c}=e.split(".");if(3!==c&&4!==c)throw new r("token is not a PASETO formatted value");if("v1"!==i&&"v2"!==i&&"v3"!==i&&"v4"!==i)throw new n("unsupported PASETO version");if("local"!==a&&"public"!==a)throw new n("unsupported PASETO purpose");const d={footer:u?s(u):void 0,payload:void 0,version:i,purpose:a};if("local"===a)return d;const f="v1"===i?256:"v3"===i?96:64;let h;try{h=s(l).subarray(0,-f)}catch{throw new r("token is not a PASETO formatted value")}return d.payload=t?o(h):h,d}},2744:(e,t,i)=>{const r=i(78972);e.exports={decode:r}},67814:(e,t,i)=>{const r=i(85223);e.exports=({audience:e,expiresIn:t,iat:i=!0,issuer:n,jti:s,kid:o,notBefore:a,now:l=new Date,subject:u},c)=>{if(!(l instanceof Date&&l.getTime()))throw new TypeError("options.now must be a valid Date object");const d=l.getTime();if(void 0!==i){if("boolean"!=typeof i)throw new TypeError("options.iat must be a boolean");i&&(c.iat=new Date(d))}if(void 0!==t){if("string"!=typeof t)throw new TypeError("options.expiresIn must be a string");c.exp=new Date(d+r(t))}if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.notBefore must be a string");c.nbf=new Date(d+r(a))}if(void 0!==e){if("string"!=typeof e)throw new TypeError("options.audience must be a string");c.aud=e}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.issuer must be a string");c.iss=n}if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.subject must be a string");c.sub=u}if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.kid must be a string");c.kid=o}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.jti must be a string");c.jti=s}return c}},10968:(e,t,i)=>{const{PasetoClaimInvalid:r}=i(60308),n=i(85223);e.exports=({ignoreExp:e,ignoreNbf:t,ignoreIat:i,maxTokenAge:s,subject:o,issuer:a,clockTolerance:l,audience:u,now:c=new Date},d)=>{if(!(c instanceof Date&&c.getTime()))throw new TypeError("options.now must be a valid Date object");const f=c.getTime();if("iss"in d&&"string"!=typeof d.iss)throw new r("payload.iss must be a string");if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.issuer must be a string");if(d.iss!==a)throw new r("issuer mismatch")}if("sub"in d&&"string"!=typeof d.sub)throw new r("payload.sub must be a string");if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.subject must be a string");if(d.sub!==o)throw new r("subject mismatch")}if("aud"in d&&"string"!=typeof d.aud)throw new r("payload.aud must be a string");if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.audience must be a string");if(d.aud!==u)throw new r("audience mismatch")}if(void 0!==l&&"string"!=typeof l)throw new TypeError("options.clockTolerance must be a string");const h=l?n(l):0;let m;if("iat"in d){if("string"!=typeof d.iat)throw new r("payload.iat must be a string");if(m=new Date(d.iat).getTime(),!m)throw new r("payload.iat must be a valid ISO8601 string");if(!i&&m>f+h)throw new r("token issued in the future")}if("nbf"in d){if("string"!=typeof d.nbf)throw new r("payload.nbf must be a string");const e=new Date(d.nbf).getTime();if(!e)throw new r("payload.nbf must be a valid ISO8601 string");if(!t&&e>f+h)throw new r("token is not active yet")}if("exp"in d){if("string"!=typeof d.exp)throw new r("payload.exp must be a string");const t=new Date(d.exp).getTime();if(!t)throw new r("payload.exp must be a valid ISO8601 string");if(!e&&t<=f-h)throw new r("token is expired")}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.maxTokenAge must be a string");if(!("iat"in d))throw new r("missing iat claim");if(m+n(s){e.exports.encode=e=>e.toString("base64url"),e.exports.decode=e=>Buffer.from(e,"base64")},80608:e=>{e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if("string"!=typeof e)throw new TypeError("options.assertion must be a string, or a Buffer");return Buffer.from(e,"utf8")}},83561:(e,t,i)=>{const r=i(65825);e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if(r(e))return Buffer.from(JSON.stringify(e),"utf8");if("string"!=typeof e)throw new TypeError("options.footer must be a string, Buffer, or a plain object");return Buffer.from(e,"utf8")}},1658:(e,t,i)=>{const r=i(67814),n=i(65825);e.exports=(e,t)=>{if(Buffer.isBuffer(e)){if(0!==Object.keys(t).length)throw new TypeError("options cannot contain claims when payload is a Buffer");return e}if(!n(e))throw new TypeError("payload must be a Buffer or a plain object");return e=(e=>JSON.parse(JSON.stringify(e)))(e),e=r(t,e),Buffer.from(JSON.stringify(e),"utf-8")}},82115:e=>{e.exports=e=>{const{x:t,y:i}=e.export({format:"jwk"}),r=Buffer.from(i,"base64"),n=2+(1&r[r.length-1]);return Buffer.concat([Buffer.alloc(1,n),Buffer.from(t,"base64")])}},88965:(e,t,i)=>{const r=i(64770),{PasetoInvalid:n}=i(60308),s=i(10968),{decode:o}=i(47859),a=i(40816);e.exports={post:function(e,t,i,r,n,o,l){if(t){if(0!==Object.keys(i).length)throw new TypeError("options cannot contain claims when options.buffer is true");return r?{payload:n,footer:o?.length?o:void 0,version:e,purpose:l}:n}const u=a(n);return s(i,u),r?{payload:u,footer:o?.length?o:void 0,version:e,purpose:l}:u},pre:function(e,t){if("string"!=typeof t)throw new TypeError("token must be a string, got: "+typeof t);if(t.slice(0,e.length)!==e)throw new n(`token is not a ${e.slice(0,e.length-1)} PASETO`);let{0:i,1:s="",length:a}=t.slice(e.length).split(".");try{r(a<=2),i=o(i),s=o(s)}catch{throw new n("token is not a PASETO formatted value")}return{raw:i,f:s}}}},56463:(e,t,i)=>{const r=i(76982),n=i(92460),s=i(70761),o=i(29534),{PasetoDecryptionFailed:a}=i(60308),l=i(82682),{webcrypto:{subtle:u}}=r,c=n.promisify(r.hkdf),d=Buffer.from("paseto-encryption-key"),f=Buffer.from("paseto-auth-key-for-aead"),h=Buffer.alloc(0),m=(e,t)=>r.createHmac("sha384",t).update(e).digest(),p=async(e,t,i,r)=>u[e]({name:"AES-CTR",counter:r,length:16},await u.importKey("raw",i,"AES-CTR",!1,[e]),t).then(Buffer.from),g=p.bind(void 0,"encrypt"),y=p.bind(void 0,"decrypt");e.exports={sign:n.promisify(r.sign),verify:n.promisify(r.verify),"v1.local-encrypt":async function(e,t,i){const n="v1.local.",a=m(e,r.randomBytes(32)).subarray(0,32),l=a.subarray(0,16),[u,h]=await Promise.all([c("sha384",i,l,d,32).then(Buffer.from),c("sha384",i,l,f,32).then(Buffer.from)]),p=await g(e,u,a.subarray(16)),y=s(n,a,p,t),v=m(y,h);return o(n,t,a,p,v)},"v1.local-decrypt":async function(e,t,i){const r=e.subarray(0,32),n=e.subarray(-48),o=e.subarray(32,-48),u=r.subarray(0,16),[h,p]=await Promise.all([c("sha384",i,u,d,32).then(Buffer.from),c("sha384",i,u,f,32).then(Buffer.from)]),g=s("v1.local.",r,o,t),v=m(g,p);if(!l(n,v))throw new a("decryption failed");const w=await y(o,h,r.subarray(16));if(!w)throw new a("decryption failed");return w},"v3.local-encrypt":async function(e,t,i,n){const a="v3.local.",l=r.randomBytes(32),[u,p]=await Promise.all([c("sha384",i,h,Buffer.concat([d,l]),48).then(Buffer.from),c("sha384",i,h,Buffer.concat([f,l]),48).then(Buffer.from)]),y=u.subarray(0,32),v=u.subarray(32),w=await g(e,y,v),S=s(a,l,w,t,n),b=m(S,p);return o(a,t,l,w,b)},"v3.local-decrypt":async function(e,t,i,r){const n=e.subarray(0,32),o=e.subarray(-48),u=e.subarray(32,-48),[p,g]=await Promise.all([c("sha384",i,h,Buffer.concat([d,n]),48).then(Buffer.from),c("sha384",i,h,Buffer.concat([f,n]),48).then(Buffer.from)]),v=p.subarray(0,32),w=p.subarray(32),S=s("v3.local.",n,u,t,r),b=m(S,g);if(!l(o,b))throw new a("decryption failed");const P=await y(u,v,w);if(!P)throw new a("decryption failed");return P}}},70981:(e,t,i)=>{const{KeyObject:r}=i(76982);let{isKeyObject:n}=i(75162);n||(n=e=>null!=e&&e instanceof r),e.exports=n},65825:e=>{e.exports=e=>!!e&&e.constructor===Object},41726:(e,t,i)=>{const{PasetoNotSupported:r}=i(60308);e.exports=e=>{if(!Number.isSafeInteger(e))throw new r("message is too long for Node.js to safely process");const t=~~(e/4294967295),i=e%4294967295-t,n=Buffer.allocUnsafe(8);return n.writeUInt32LE(t,4),n.writeUInt32LE(i,0),n}},85223:e=>{const t=36e5,i=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;e.exports=e=>{const r=i.exec(e);if(!r)throw new TypeError(`invalid time period format ("${e}")`);const n=parseFloat(r[1]);switch(r[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(1e3*n);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(6e4*n);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(n*t);case"day":case"days":case"d":return Math.round(864e5*n);case"week":case"weeks":case"w":return Math.round(6048e5*n);case"year":case"years":case"yr":case"yrs":case"y":return Math.round(315576e5*n)}}},29534:(e,t,i)=>{const{encode:r}=i(47859);e.exports=function(e,t,...i){let n=`${e}${r(Buffer.concat(i))}`;return t.byteLength&&(n+=`.${r(t)}`),n}},70761:(e,t,i)=>{const r=i(41726);e.exports=(...e)=>{e=e.filter(Boolean);let t=r(e.length);for(let i of e){i=Buffer.from(i,"utf8");const e=r(Buffer.byteLength(i));t=Buffer.concat([t,e,i])}return t}},40816:(e,t,i)=>{const{PasetoInvalid:r}=i(60308),{strict:n}=i(64770),s=i(65825);e.exports=e=>{try{const t=JSON.parse(e);return n(s(t)),t}catch{throw new r("All PASETO payloads MUST be a JSON object")}}},92366:(e,t,i)=>{const{sign:r}=i(56463),n=i(70761),s=i(29534);e.exports=async function(e,t,i,o,a,l,u){const c=n(u,e,t,i,l),d=await r(o,c,a);return s(e,i,t,d)}},495:(e,t,i)=>{const{createSecretKey:r}=i(76982),n=i(70981);e.exports=function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}`)&&(t=Buffer.from(t.slice(e.length),"base64url")),!n(t))try{t=r(t)}catch{}if(!n(t))throw new TypeError("invalid key provided");if("secret"!==t.type||32!==t.symmetricKeySize)throw new TypeError(`${e} secret key must be 32 bytes long symmetric key`);return t}},82682:(e,t,i)=>{const{timingSafeEqual:r}=i(76982),n=(e,t)=>{if(e.length===t)return e;const i=Buffer.alloc(t);return e.copy(i),i};e.exports=(e,t)=>{const i=Math.max(e.length,t.length);return r(n(e,i),n(t,i))}},49826:(e,t,i)=>{const{PasetoVerificationFailed:r}=i(60308),{verify:n}=i(56463),s=i(70761),{pre:o}=i(88965);e.exports=async function(e,t,i,a,l,u,c){const{raw:d,f}=o(e,t),h=d.subarray(0,-a),m=d.subarray(-a),p=s(c,e,h,f,u);if(!await n(i,p,l,m))throw new r("invalid signature");return{m:h,footer:f.length?f:void 0}}},91227:(e,t,i)=>{const r=i(60308),n=i(79665),s=i(56120),o=i(50015),a=i(64230),{decode:l}=i(2744);e.exports={decode:l,V1:n,V2:s,V3:o,V4:a,errors:r}},39324:(e,t,i)=>{const{"v1.local-decrypt":r}=i(56463),n=i(495).bind(void 0,"v1.local"),{pre:s,post:o}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:a=!1,...l}={}){const{raw:u,f:c}=s("v1.local.",e),d=(t=n(t)).export(),f=await r(u,c,d);return o("v1",a,l,i,f,c,"local")}},21472:(e,t,i)=>{const r=i(83561),n=i(495).bind(void 0,"v1.local"),s=i(1658),{"v1.local-encrypt":o}=i(56463);e.exports=async function(e,t,{footer:i,...a}={}){const l=s(e,a);t=n(t);const u=r(i),c=t.export();return o(l,u,c)}},79665:(e,t,i)=>{const r=i(77868),n=i(77256),s=i(21472),o=i(39324),a=i(70866);e.exports={sign:r,verify:n,encrypt:s,decrypt:o,generateKey:a}},70866:(e,t,i)=>{const r=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:s}=i(60308),o=n(r.generateKeyPair),a=n(r.generateKey);e.exports=async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await a("aes",{length:256});return"paserk"===t?`k1.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await o("rsa",{modulusLength:2048});return"paserk"===t?{secretKey:`k1.secret.${e.export({format:"der",type:"pkcs1"}).toString("base64url")}`,publicKey:`k1.public.${i.export({format:"der",type:"pkcs1"}).toString("base64url")}`}:e}default:throw new s("unsupported v1 purpose")}}},77868:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:n},createPrivateKey:s}=i(76982),o=i(83561),a=i(1658),l=i(92366),u=i(70981);e.exports=async function(e,t,{footer:i,...c}={}){const d=a(e,c),f=o(i);return t=function(e){if("string"==typeof e&&e.startsWith("k1.secret."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!u(e))try{e=s(e)}catch{}if(!u(e))throw new TypeError("invalid key provided");if("private"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public signing key must be a private RSA key with 2048 bit modulus length");return e}(t),l("v1.public.",d,f,"sha384",{key:t,padding:r,saltLength:n})}},77256:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:n},createPublicKey:s}=i(76982),o=i(49826),a=i(70981),{post:l}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:u=!1,...c}={}){t=function(e){if("string"==typeof e&&e.startsWith("k1.public."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!a(e)||"private"===e.type)try{e=s(e)}catch{}if(!a(e))throw new TypeError("invalid key provided");if("public"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public verify key must be a public RSA key with 2048 bit modulus length");return e}(t);const{m:d,footer:f}=await o("v1.public.",e,"sha384",256,{key:t,padding:r,saltLength:n});return l("v1",u,c,i,d,f,"public")}},56120:(e,t,i)=>{const r=i(88451),n=i(859),{generateKey:s,bytesToKeyObject:o,keyObjectToBytes:a}=i(62827);e.exports={sign:r,verify:n,generateKey:s,bytesToKeyObject:o,keyObjectToBytes:a}},62827:(e,t,i)=>{const r=i(64770),n=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:o}=i(60308),a=i(70981),l=s(n.generateKeyPair);async function u(e,t,{format:i="keyobject"}={}){if("keyobject"!==i&&"paserk"!==i)throw new TypeError("invalid format");if("public"===t){const{privateKey:t,publicKey:r}=await l("ed25519");return"paserk"===i?{secretKey:`k${e.slice(1)}.secret.${f(t).toString("base64url")}`,publicKey:`k${e.slice(1)}.public.${f(r).toString("base64url")}`}:t}throw new o(`unsupported ${e} purpose`)}function c(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 64:{const t=n.createPrivateKey({key:Buffer.concat([Buffer.from("302e020100300506032b657004220420","hex"),e.subarray(0,32)]),format:"der",type:"pkcs8"});if(!e.subarray(32).equals(Buffer.from(t.export({format:"jwk"}).x,"base64")))throw new TypeError("invalid byte sequence");return t}case 32:return n.createPublicKey({key:Buffer.concat([Buffer.from("302a300506032b6570032100","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 64 bytes (private key), or 32 bytes (public key)")}}function d(e,t){if(!a(t))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public key must be an Ed25519 key`);switch(t.type){case"public":return Buffer.from(t.export({format:"jwk"}).x,"base64");case"private":{const{d:e,x:i}=t.export({format:"jwk"});return Buffer.concat([Buffer.from(e,"base64"),Buffer.from(i,"base64")])}}}function f(...e){return d("v2",...e)}e.exports={_checkPrivateKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.secret.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,64)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!a(t))try{t=n.createPrivateKey(t)}catch{}if(!a(t))throw new TypeError("invalid key provided");if("private"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public signing key must be a private ed25519 key`);return t},_checkPublicKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.public.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,32)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!a(t)||"private"===t.type)try{t=n.createPublicKey(t)}catch{}if(!a(t))throw new TypeError("invalid key provided");if("public"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public verify key must be a public ed25519 key`);return t},_generateKey:u,_keyObjectToBytes:d,bytesToKeyObject:c,generateKey:async function(...e){return u("v2",...e)},keyObjectToBytes:f}},88451:(e,t,i)=>{const r=i(83561),n=i(1658),s=i(92366),{_checkPrivateKey:o}=i(62827),a=o.bind(void 0,"v2");e.exports=async function(e,t,{footer:i,...o}={}){const l=n(e,o);t=a(t);const u=r(i);return s("v2.public.",l,u,void 0,t)}},859:(e,t,i)=>{const r=i(49826),{_checkPublicKey:n}=i(62827),{post:s}=i(88965),o=n.bind(void 0,"v2");e.exports=async function(e,t,{complete:i=!1,buffer:n=!1,...a}={}){t=o(t);const{m:l,footer:u}=await r("v2.public.",e,void 0,64,t);return s("v2",n,a,i,l,u,"public")}},18582:(e,t,i)=>{const{"v3.local-decrypt":r}=i(56463),n=i(495).bind(void 0,"v3.local"),s=i(80608),{pre:o,post:a}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:l=!1,assertion:u,...c}={}){const{raw:d,f}=o("v3.local.",e);t=n(t);const h=s(u),m=t.export(),p=await r(d,f,m,h);return a("v3",l,c,i,p,f,"local")}},43406:(e,t,i)=>{const r=i(83561),n=i(495).bind(void 0,"v3.local"),s=i(1658),o=i(80608),{"v3.local-encrypt":a}=i(56463);e.exports=async function(e,t,{footer:i,assertion:l,...u}={}){const c=s(e,u);t=n(t);const d=r(i),f=o(l),h=t.export();return a(c,d,h,f)}},50015:(e,t,i)=>{const r=i(42438),n=i(65466),s=i(43406),o=i(18582),{generateKey:a,bytesToKeyObject:l,keyObjectToBytes:u}=i(80568);e.exports={sign:r,verify:n,encrypt:s,decrypt:o,generateKey:a,bytesToKeyObject:l,keyObjectToBytes:u}},80568:(e,t,i)=>{const r=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:s}=i(60308),o=i(70981),a=i(82115),l=n(r.generateKeyPair),u=n(r.generateKey);function c(e){if(!o(e))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public key must be an EC P-384 key");switch(e.type){case"public":return a(e);case"private":return Buffer.from(e.export({format:"jwk"}).d,"base64")}}e.exports={generateKey:async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await u("aes",{length:256});return"paserk"===t?`k3.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await l("ec",{namedCurve:"P-384"});return"paserk"===t?{secretKey:`k3.secret.${c(e).toString("base64url")}`,publicKey:`k3.public.${c(i).toString("base64url")}`}:e}default:throw new s("unsupported v3 purpose")}},bytesToKeyObject:function(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 48:return r.createPrivateKey({key:Buffer.concat([Buffer.from("303e0201010430","hex"),e,Buffer.from("a00706052b81040022","hex")]),format:"der",type:"sec1"});case 49:if(2!==e[0]&&3!==e[0])throw new TypeError("invalid compressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3046301006072a8648ce3d020106052b81040022033200","hex"),e]),format:"der",type:"spki"});case 97:if(4!==e[0])throw new TypeError("invalid uncompressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3076301006072a8648ce3d020106052b81040022036200","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 48 bytes (private key), 49 bytes (compressed public key), or 97 bytes (uncompressed public key)")}},keyObjectToBytes:c}},42438:(e,t,i)=>{const{createPrivateKey:r}=i(76982),n=i(83561),s=i(1658),o=i(80608),a=i(92366),l=i(70981),{bytesToKeyObject:u}=i(80568),c=i(82115);e.exports=async function(e,t,{footer:i,assertion:d,...f}={}){const h=s(e,f),m=n(i),p=o(d);return t=function(e){if("string"==typeof e&&e.startsWith("k3.secret."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,48)}catch{}if(Buffer.isBuffer(e))try{e=u(e)}catch{}if(!l(e))try{e=r(e)}catch{}if(!l(e))throw new TypeError("invalid key provided");if("private"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public signing key must be a private EC P-384 key");return e}(t),a("v3.public.",h,m,"sha384",{key:t,dsaEncoding:"ieee-p1363"},p,c(t))}},65466:(e,t,i)=>{const{createPublicKey:r}=i(76982),n=i(80608),s=i(49826),o=i(70981),{bytesToKeyObject:a}=i(80568),l=i(82115),{post:u}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:c=!1,assertion:d,...f}={}){t=function(e){if("string"==typeof e&&e.startsWith("k3.public."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,49)}catch{}if(Buffer.isBuffer(e))try{e=a(e)}catch{}if(!o(e)||"private"===e.type)try{e=r(e)}catch{}if(!o(e))throw new TypeError("invalid key provided");if("public"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public verify key must be a public EC P-384 key");return e}(t);const h=n(d),{m,footer:p}=await s("v3.public.",e,"sha384",96,{key:t,dsaEncoding:"ieee-p1363"},h,l(t));return u("v3",c,f,i,m,p,"public")}},64230:(e,t,i)=>{const r=i(29901),n=i(77933),{generateKey:s,bytesToKeyObject:o,keyObjectToBytes:a}=i(24961);e.exports={sign:r,verify:n,generateKey:s,bytesToKeyObject:o,keyObjectToBytes:a}},24961:(e,t,i)=>{const{_checkPrivateKey:r,_checkPublicKey:n,_generateKey:s,_keyObjectToBytes:o,bytesToKeyObject:a}=i(62827);e.exports={_checkPrivateKey:r,_checkPublicKey:n,bytesToKeyObject:a,generateKey:async function(...e){return s("v4",...e)},keyObjectToBytes:function(...e){return o("v4",...e)}}},29901:(e,t,i)=>{const r=i(83561),n=i(1658),s=i(80608),o=i(92366),{_checkPrivateKey:a}=i(24961),l=a.bind(void 0,"v4");e.exports=async function(e,t,{footer:i,assertion:a,...u}={}){const c=n(e,u),d=s(a);t=l(t);const f=r(i);return o("v4.public.",c,f,void 0,t,d)}},77933:(e,t,i)=>{const r=i(80608),n=i(49826),{_checkPublicKey:s}=i(24961),{post:o}=i(88965),a=s.bind(void 0,"v4");e.exports=async function(e,t,{complete:i=!1,buffer:s=!1,assertion:l,...u}={}){t=a(t);const c=r(l),{m:d,footer:f}=await n("v4.public.",e,void 0,64,t,c);return o("v4",s,u,i,d,f,"public")}},37975:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),n=i(38639),s=i(44198);function o(){return(0,n.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=o;let a=!o();function l(){return a}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){a=e??!o()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),n=i(7282),s=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,n.isProd)()?"":`-${(0,n.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),n=i(36783),s=i(76790),o=i(22573),a=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),f=i(34666),h=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const n=new Set(t.map(i));return e.filter((e=>n.has(i(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...v(e.slice(i+1))]}function w(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return M(e,(e=>e.valueOf()))}function P(e,t){return E(e,t,((e,t)=>(0,f.lt)(e,t)))}function M(e,t){return E(e,t,((e,t)=>(0,f.gt)(e,t)))}function _(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function E(e,t,i){return T(e,t,i).index}function T(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let n,s=-1;for(let r=0;re.slice(i,i+t)))}async function D(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,a.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(o.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,h.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,h.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,h.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,a.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,n.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let n=0;for(const s of e)(t(s,n++)?i:r).push(s);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let n=0;ne.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=M,t.leastBy=_,t.least=function(e){return _(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[M(e,t)]},t.leastByCtx=function(e,t){const i=T(e??[],t,f.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=x,t.collectBatched=function(e,t,i){const n=[];for(const s of x((0,r.compact)((0,h.toA)(e)),t))n.push(...(0,r.compact)(i(s)));return n},t.collectBatchedAsync=async function(e,t,i){const n=[];for(const s of x((0,r.compact)((0,h.toA)(e)),t))n.push(...(0,r.compact)(await i(s)));return n},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await D(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+n;if(re+1),1));return(0,h.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const a=i(77988),l=o(i(1708)),u=i(19851),c=i(42659),d=i(55835),f=i(31586),h=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),v=i(25764),w=i(38836),S=i(99331),b=i(95937),P=i(98314),M=i(38835),_=i(70025),E=i(8769),T=i(43334),x=i(95402),D=i(28874),k=i(63870);class C extends w.EndableWrapper{constructor(e,t,i=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,r,"m",n).call(this)),i,"worker"===e?(0,k.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const o=t;o.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,x.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new h.TimeoutError)})),o.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),o.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),o.on("fatalError",(e=>{this.onError("on(fatalError)"+M.FatalErrorFlag,e)})),o.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),o.on("noTaskData",((e,i,r)=>{const n=t.options.streamFlushMillis;n{this.logger.error("observeBatchCluster.endError()",e)})),o.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,f.gt0)(e?.pid)&&x.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof a.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,_.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,E.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=C,r=new WeakSet,n=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(T.isWin?3:1)*c.minuteMs,maxTasksPerProcess:D.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:D.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:D.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:D.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:D.Settings.taskTimeoutMs.valueOrDefault}}},71371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedGreatestSet=void 0;const r=i(92322);t.BoundedGreatestSet=class{constructor(e,t){this.maxLength=e,this.toValue=t,this.sortedArray=new r.SortedSet(t)}toA(){return this.vacuum(),this.sortedArray.toA()}vacuum(){return this.sortedArray.retainLastN(this.maxLength)}add(...e){this.maxLength<=0||(this.sortedArray.addAll(...e),this.sortedArray.length>=2*this.maxLength&&this.vacuum())}}},89788:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class f{constructor(e){if(r.add(this),this.maxLength=e,n.set(this,void 0),s.set(this,0),o.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,n,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",a).call(this,e,(e=>u(this,n,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",a).call(this,e,(e=>u(this,n,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,o,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,n,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,n,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,r,"m",a).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,n,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,s,"f"){u(this,n,"f")[e]=c,l(this,o,e,"f")}));return u(this,s,"f")}shift(){return u(this,r,"m",a).call(this,0,(e=>{var t,i;return l(this,o,(t=u(this,o,"f"),++t),"f"),l(this,s,(i=u(this,s,"f"),--i),"f"),u(this,n,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",a).call(this,u(this,s,"f")-1-e,(e=>{const i=u(this,n,"f")[e];u(this,n,"f")[e]=u(this,n,"f")[t],u(this,n,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=f},76850:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),n=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:i}of n)if(o(e,t))return e.subarray(t.length).toString(i);return e.toString()}function o(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,r.toS)(e)},t.bufferStartsWith=o},9092:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class n{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=n},36638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class n{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=n},40583:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const o=i(40958),a=i(23838),l=s(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new a.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,o.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,n=-1;for(const[i,s]of this.m.entries()){const o=(0,c.diceCoeff)(i,e);if(o>t&&o>n){const e=this.getFirst(s);null!=e&&(r=e,n=o)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),n=i(31586),s=i(68708),o=i(54993),a=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new a.Average(0);for(const t of this.keys()){if(!(0,n.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,o.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,n.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new a.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,n]of this.m.entries()){const s=e(r);t.fill(s,i,i+n),i+=n}return t}}t.CountingSet=u},79840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),n=i(72993),s=i(45969),o=i(43334);t.EditionType=(0,r.lazy)((()=>o.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>n.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),n=i(55835),s=i(68708);var o=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return o.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,n.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,s.omit)(e,...i),(0,s.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,n.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),n=i(19851),s=i(95696);t.examples=(0,n.lazy)((()=>s.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),n=i(65843),s=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,n.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,s.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),n=i(40958),s=i(55835),o=i(31586),a=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,o.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,o.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,n.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,n.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,a.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,a.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,a.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,o.isNumber)(e.__uid)&&(0,o.isNumber)(e.__start)}},80049:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),f=i(54993),h=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),n.set(this,0),s.set(this,0),o.set(this,0),a.set(this,0),this.cache=new h.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,n,l(this,n,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,o,l(this,o,"f")+e.rejections,"f"),u(this,a,l(this,a,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,n,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,o,"f"),timeouts:l(this,a,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,o,a;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,n,(i=l(this,n,"f"),++i),"f"),c.promise):(u(this,r,(o=l(this,r,"f"),++o),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(a=l(this,r,"f"),++a),"f"),c}get(e){var t,i;const n=this.cache.get(e);return null==n||n instanceof m.Deferred&&n.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),n instanceof m.Deferred?n.value:n}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,n,0,"f"),u(this,s,0,"f"),u(this,o,0,"f"),u(this,a,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,f.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,o,(t=l(this,o,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,a,(r=l(this,a,"f"),++r),"f")})),r.promise}},r=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap},54127:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class f{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const h=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,o.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,n.range)(0,r).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new f(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,a.fromEntries)(e))).filter((e=>(0,a.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,a=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(a,r.index);(0,s.blank)(l)||(h().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),f=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==f)this.skippedHeaders.push(m),h().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:f});else{const e=(0,n.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,o.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=f}a=t.lastIndex}const l=(0,n.last)(i);return null!=l&&((0,s.blank)(this.headerRow.slice(a))?l.rightIdx=(0,o.max_)(...this.rows.map((e=>e.length))):l.rightIdx=a),i}}t.Fixed=m},73168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const r=i(55835),n=i(20014),s=i(55222),o=i(97352),a=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,o.within)(-90,90,e)&&0!==e}function c(e){return(0,o.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function f(e,t,i=a){return(0,r.map)(m(e,t,l(i)),(e=>s.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=a){return f(e?.lat,e?.lon,t)},t.geohash=f,t.geohashNumericShort=function(e,t){return m(e,t,30)};const h=new n.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=a){return d(e,t)?h.zip([t,e],l(i)):void 0}function p(e,t=a){return h.unzip(e,l(t))?.reverse()}function g(e,t=a){const[i,r]=p(e,t);return{lat:i,lon:r}}t.geohashNumeric=m,t.ungeohash=function(e,t=a){return(0,r.map)(s.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,r=t.lat*Math.PI/180,n=(t.lat-e.lat)*Math.PI/180,s=(t.lon-e.lon)*Math.PI/180,o=Math.sin(n/2)*Math.sin(n/2)+Math.cos(i)*Math.cos(r)*Math.sin(s/2)*Math.sin(s/2);return 12742e3*Math.atan2(Math.sqrt(o),Math.sqrt(1-o))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),n=i(98553);var s=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const i=(0,n.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,n.parseJSON)((await(0,r.readFile)(e)).toString())}},57206:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDefaultJsonRevivers=void 0;const r=i(77988),n=i(51168),s=i(45599),o=i(98553),a=i(68708),l=i(24689),u=i(21330),c=i(57159),d=i(28544),f=(0,s.defer)((()=>{n.DateTime.prototype.toJSON=function(){return(0,a.compactValues)({_ctor:n.DateTime.name,ts:this.toMillis(),zone:"system"===this.zone?.type?void 0:this.zoneName})}})),h={name:n.DateTime.name,fromJSON:e=>n.DateTime.fromMillis(e.ts,(0,a.compactValues)({zone:e.zone}))};t.addDefaultJsonRevivers=(0,s.defer)((()=>{f(),(0,o.addJsonRevivers)(r.ExifDateTime,r.ExifDate,r.ExifTime,h,d.CapturedAt,l.DateInterval,u.FuzzyDate,r.BinaryField,c.WrappedError)}))},19851:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const o=i(57975),a=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new f(e,t)};class f extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,r,"m",n).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,a.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(42659),a=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),f=i(44198),h=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,a.mkLogger)("Locale")));function v(e=(0,f.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?_():E()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=w.exec(e.trim())?.groups;return null==i?void 0:(0,n.compact)([i.lang,i.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const M={timeoutMs:10*o.secondMs};async function _(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],M))}async function E(){return b(v((0,h.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],M)})))}t.localeMac=_,t.localePosix=E,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),n=i(1708),s=i(45599),o=i(68708),a=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),f=i(37805),h=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,s.defer)((()=>{(0,a.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:f.version,StartTs:d.StartTs,argv:n.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,o.pick)(n.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:n.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,h.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),n=i(32105),s=i(14593);t.rootLoggers=(0,r.lazy)((()=>[n.ConsoleLogger.instance()]));const o=(0,r.lazy)((()=>[n.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,o)}},56639:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),n=i(55835),s=i(59455),o=i(48884);function a(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,o.concat)(...e.map((e=>t(e)))))},t.compactMap=a,t.toMap=function(e,t){return a((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:a(await Promise.all((0,r.compact)((0,s.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,n.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),n=i(54557);t.memoize=function(e,t){let i=0;const s=new n.FifoCache(t.maxSize,t.ttlMs),o=t=>{if(null!=t)return i++,s.getOrSet((0,r.stringify)(t),(()=>e(t)))};return o.clear=e=>null==e?s.clear():s.delete((0,r.stringify)(e)),o.size=()=>s.size,o.callCount=()=>i,o}},31578:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const r=i(1708),n=i(31586),s=i(12168),o=i(70417);function a(){const e=(0,r.memoryUsage)();return(0,o.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,r.memoryUsage)().rss}t.memoryUsageBytes=a,t.memoryUsageMb=function(){return(0,n.sigFigs)(a()/s.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,n.sigFigs)(l()/s.MB,2)}},7282:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const n=r(i(1708)),s=i(38639),o=i(54993),a=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,a.lazy)((()=>n.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,o.toS)(n.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return n.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(n.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){n.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),n=i(22573),s=i(96249),o=i(55835),a=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function f(e,t){return(0,a.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(a.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,a.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=f,t.mapGte0Or=function(e,t,i){return(0,o.orElse)(f(e,t),i)},t.mapGte0f=function(e,t){const i=(0,a.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,a.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,a.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,a.toInt)(e),n=(0,a.toInt)(t);return null!=r&&r>0&&null!=n&&n>0?i(r,n):void 0};const h=/[+-]?[\d,.]+/;function m(e){if((0,a.isNumber)(e))return e;if((0,n.blank)(e))return;const t=String(e);return(0,o.map)(h.exec(t),(e=>(0,a.toFloat)(t.substr(e.index))))}function p(e){return(0,a.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,o.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,o.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const n=i*e.length;for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),n=i(42659),s=i(96249),o=i(55835),a=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),f=i(81168);function h(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,n.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,n]of(0,l.entries)(e)){const e=t(r,n);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,o.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(o.defined)},t.firstDefinedField=function(e,...t){return(0,o.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=h,t.tryEach=function(e,t){[...e].forEach((e=>h((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,o.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const n of t)r[n]=i(n,e[n]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let n=0;for(const s of(0,l.keys)(e))if(r[s]=t(s,e[s]),n++,(0,a.gt)(n,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,f.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,f.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,s.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),n=i(73024),s=i(48161),o=i(19851),a=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),f=i(48884),h=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),v=i(30933),w=(0,o.lazy)((()=>(0,h.mkLogger)("os")));function S(){return(0,s.platform)()+" "+(0,s.release)()}t.osArch=(0,o.lazy)((()=>`${function(){switch((0,s.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return C();case"win32":return O();default:return S()}}()} on ${(0,s.arch)()}`)),t.osFullName=(0,o.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const b=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function M(){return"ubuntu"===(0,t.osDistributionLinux)()}function _(){return"fedora"===(0,t.osDistributionLinux)()}function E(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,o.lazy)((()=>{if(g.isLinux)for(const e of b)try{const t=(0,n.readFileSync)(e).toString();if((0,a.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,o.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,a.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),S)})),t.osDistributionLinux=(0,o.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=M,t.hasApt=function(){return P()||M()},t.isFedora=_,t.isAlpine=E;const T={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},x={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function D(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),n=t[i];return(0,c.isString)(n)?n:n?.[r]}const k=(0,o.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function C(e=k()){try{return(0,a.mapNotBlankOr)(function(e=k()){return D(e,T)}(e),(t=>`macOS ${t} (${e})`),S)}catch(e){return w().warn("osNameMac(): unknown release",e),S()}}function O(e=(0,s.release)()){const t=e.startsWith("10.0.22")?"11":D(e,x);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=C,t.osNameWin=O,t.CPUs=(0,o.lazy)((()=>(0,f.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,o.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(O())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=k();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(M())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(_())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(E())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},12801:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const n=r(i(48161)),s=i(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:n.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:n.default.constants.priority.PRIORITY_NORMAL,BelowNormal:n.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:n.default.constants.priority.PRIORITY_LOW,Low:n.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setProcessTitle=t.setShortProcessNames=void 0;const r=i(72993),n=i(50213),s=i(23560),o=i(43334);let a=!o.isElectron;t.setShortProcessNames=function(e){a=e},t.setProcessTitle=function(){try{const e=[a?r.SimpleShortAppName:r.SimpleAppName];(0,s.isMainService)()&&o.isElectron||e.push((0,s.serviceName)());const t=e.join(o.isElectron?" ":"-");i(85949).title=t}catch(e){(0,n.mkLogger)("ServiceNames").warn("Failed to set friendly process name",e)}}},92782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeRandomUid=t.safeRandomChars=void 0;const r=i(55222),n=i(65713);t.safeRandomChars=function({radix:e=r.TokenRadix,length:t}){return(0,n.decuss)((()=>e.randomChars(t)))},t.safeRandomUid=function(e){return(0,n.decuss)((()=>(e?.radix??r.TokenRadix).randomUid(e?.chars??20,e?.splitEveryN??5,e?.sepChar??"-")))}},409:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),n=i(56409),s=i(31586),o=i(22911),a=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,f,h=!1,m=0;t=Math.ceil(t);const p=[];function g(){return h||m>Date.now()}function y(){if(null!=f){const e=f;f=void 0,w(...e)}}async function v(...r){h=!0,m=Date.now()+(0,s.max_)(t,i);const n=d=new o.Deferred(c);(0,s.gt0)(i)&&n.setTimeout(i);try{n.resolve(await e(...r))}catch(e){n.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{h=!1,m=Date.now()+t,(0,a.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return n.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return f=e,(0,r.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{f=void 0},w.donePromise=()=>{if(!h)return Promise.resolve();const e=new n.Latch;return p.push(e),e},w.force=async(...e)=>(f=void 0,h&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:h,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),n=i(54993);function s(e){return e instanceof o?e.source:(0,n.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let n;for(;null!=(n=e.exec(t));)n.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(n,"index","groups"));return i},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(s(t))}const n=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(n,i)};class o{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=o;class a extends o{static from(...e){const t=l(e);return new a("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,a=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof o||t instanceof RegExp?(i+=t.source,r||(r=t.global),a||(a=t.ignoreCase),l||(l=t.multiline)):i+=s((0,n.toS)(t));return new RegExp(i,t??(r?"g":"")+(a?"i":"")+(l?"m":""))}t.RegExpOptional=a,t.concatRegexp=l},79089:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const n=r(i(48161)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),f=i(51926),h=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),v=i(34102),w=i(43334),S=i(24399),b=i(28874),P=(0,o.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>E.prior()?.clear()))));const M=(0,o.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,f.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,a.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>M().includes(e.toLowerCase())))};let _=!0;const E=(0,o.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||E().has(e))return;E().add(e);const i=(0,p.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),_)try{return n.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;_=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(h.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const n=r(i(1708)),s=i(19851),o=i(40958),a=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function f(e){return(e??(0,t.serviceName)())===a.ServiceNames.web}function h(e){return(e??(0,t.serviceName)())===a.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===a.ServiceNames.sync}function p(){return(0,t.serviceName)()===a.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,o.compactBlanks)([t.serviceName.prior(),(0,l.toS)(n.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return a.ServiceNames.indexOf(e)??a.ServiceNames.length+1},t.MainServices=[a.ServiceNames.main,a.ServiceNames.desktop],t.DbServices=[a.ServiceNames.sync,a.ServiceNames.info,a.ServiceNames.web,a.ServiceNames.list,a.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[a.ServiceNames.sync,a.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||f(e)},t.isMainService=d,t.isWebService=f,t.isBillingService=function(e){return(e??(0,t.serviceName)())===a.ServiceNames.billing},t.isWorkerService=h,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===a.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||f()||((0,u.isTest)()||p())&&!h()},t.isDbJanitorService=(0,s.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!f()&&!d()&&!h()}},77377:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function n(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=n,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=n(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=n(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),n=i(57150),s=i(7282),o=i(23560),a=i(17181);t.setServiceName=function(e){(0,o.isMainService)(e)&&(e=r.ServiceNames.main);const t=o.serviceName.prior();t!==e&&((0,s.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),o.serviceName.set(e),(0,a.setupLogger)(),(0,n.logStartup)())}},28850:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const a=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends a.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),n.set(this,void 0),s(this,r,e,"f")}_call(){return(0,l.time)(o(this,r,"f")+(null==o(this,n,"f")?"(local)":"(remote)"),null==o(this,n,"f")?this.impl():o(this,n,"f").call(this))}setShim(e){s(this,n,e,"f")}hasShim(){return null!=o(this,n,"f")}clearShim(){s(this,n,void 0,"f")}}r=new WeakMap,n=new WeakMap},12089:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),f=i(54993),h=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends h.ExtensibleFunction{constructor(e,t,i,o){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=o,n.set(this,void 0),s.set(this,void 0),l(this,n,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",a).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",o).call(this,e),(()=>u(this,r,"m",a).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",o).call(this,e))}}n=new WeakMap,s=new WeakMap,r=new WeakSet,o=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,f.toS)(e):(0,c.stringify)(e))},a=function(e){return(0,m.time)(u(this,n,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){"use strict";var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=i(76790),o=i(17586);class a{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return n(this,r,"f")[Symbol.iterator]()}get length(){return n(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=n(this,r,"f").length-1;for(;t<=i;){const s=t+Math.floor((i-t)/2),o=this.valueOf(n(this,r,"f")[s]);if(e===o)return{found:!0,index:s};e>o?t=s+1:i=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&n(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...n(this,r,"f")];const o=t=>t<0||t>n(this,r,"f").length-1?null:(i??this.diff)(n(this,r,"f")[t],e),a=this.findIndex(e);if(null==a)return;let l=a.index-1,u=o(l),c=a.index,d=o(c);const f=[];for(;f.lengththis.valueOf(e)))}shift(){return n(this,r,"f").shift()}at(e){return(0,o.at)(n(this,r,"f"),e)}toA(){return[...n(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===n(this,r,"f").length-1){const e=[...n(this,r,"f")];return n(this,r,"f").length=0,e}return n(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return n(this,r,"f").splice(e,t)}retainLastN(e){return e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),n=i(82328),s=i(84542),o=i(95705),a=i(28874);t.consoleLog=function(e,...t){a.Settings.quiet.valueOrDefault||(0,n.stdoutEnded)()||console.log((0,s.crlf)(e),...t)},t.consoleError=function(e){a.Settings.quiet.valueOrDefault||(0,o.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=a.Settings.quiet.envValue;try{return a.Settings.quiet.envValue=!0,await e()}finally{a.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),n=i(95705);t.stdoutEnded=function(){return(0,n.streamEnded)(r.stdout)}},71567:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const n=r(i(1708)),s=i(22573),o=i(98553),a=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function f(e,t){return h({obj:e,ready:t,stream:n.default.stdout})}function h({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const n=(0,o.stringify)(e,void 0,(0,a.isInfoService)()||(0,a.isMainService)()?2:void 0);r.write(n+"\n"),(0,a.isWorkerService)()&&null!=i&&(n.includes(u.FailStr)||(0,c.isFatalError)(n)||(0,c.isHealthCheckError)(n)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||n.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=f,t.stderrWrite=function(e){return h({obj:e,stream:n.default.stdout})},t.writeTTY=h,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);f(t)},t.stdoutWriteMigration=function(e){return f({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>f({shutdownSync:!0}),restartSync:()=>f({restartSync:!0}),forceRestartSync:()=>f({forceRestartSync:!0}),rebuildLibrary:()=>f({rebuildLibrary:!0}),shutdown:()=>f({shutdown:!0})}},81168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(55835),a=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),f=i(54993),h=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,f.toS)(e),t=(0,f.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,f.toS)(e).indexOf((0,f.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const n=t.indexOf(i,r);return-1===n?0:1+e(t,i,n+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(f.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,a.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,f.toS)(e),t=(0,f.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,f.toS)(e),n=(0,f.toS)(t);return n.length>0&&(0,c.equalsIgnoreCase)(r.slice(-n.length),n,i)?r.slice(0,-n.length):r},t.gist=function(e,t=80,i=80){const r=(0,f.toS)(e),n=r.length-(t+i);return n<=0?r:r.slice(0,t).trim()+" …(+"+n+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,f.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,f.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,f.toS)(e))},t.capitalize=function(e){return e=(0,f.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,o.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=S(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,s.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),n=t.indexOf(r);if(n>=0)return{index:n,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,h.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,f.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const M=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function _(e){return M.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=_;const E=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,f.toS)(e).trim(),null!=E.exec(_(e))&&(e=e.slice(1,-1).trim())),e};const T=/^['‘’].*['‘’]$/,x=/^["“”„«»〃].*["“”„«»〃]$/;function D(e,t){const i=k(e,t);return(0,h.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function k(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let n,s=0;for(;null!=(n=t.exec(e));)n.index===t.lastIndex?t.lastIndex++:(t.lastIndex=n[0].length+n.index,i.push(e.substring(s,n.index)),r.push(e.substring(n.index,t.lastIndex)),s=t.lastIndex);return s(0,a.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,f.toS)(e).trim(),T.test(e)||x.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),n=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,o.map)(i[e],(e=>t+=e))));return t},t.splitKeep=D,t.splitUp=k,t.sortNaturalBy=C,t.sortNatural=function(e){return(0,n.sortBy)(e,(e=>C(e)))},t.stripDiacritics=function(e){return(0,f.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,f.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,n.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,a.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(f.toS).join("")};const O=/#.*$/gm;t.stripComments=function(e){return e.replace(O,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,s.blank)(r))for(const e of r.split(t))(0,s.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,s.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),n=e.findIndex((e=>r.test(e))),o=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(n<0)return e;for(let t=n+1;te.trim()))))}},83556:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function n(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=n,t.asObjectKey=function(e){return n(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const n=r(i(77598)),s=i(73913),o=i(55222);function a(e,t=s.HashBits){return n.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=o.Radix58,r=224){return i.encodeBuffer(a(e,r)).substring(0,t)}t.stringShaToBuffer=a,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=o.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(31586),a=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),f=i(88158),h=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,n="";for(let s=0;s=r&&(r=i.get(s,o),n=(0,l.substr)(e,s-r+1,r)));return n}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),n=t.normalize();return e!==r||t!==n?y(r,n):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function v(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,f.firstThunk)((()=>i===r?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(i),t=w(r);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function S(e,t){const i=(0,h.intersection)(e,t),n=[];return i.forEach((i=>{const s=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,o.times)(s,(()=>n.push(i)))})),n}function b(e,t,i){const n=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,n))-i((0,l.strslice)(t,n))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,n.sortBy)(t,(e=>-e.length))[0]}function M(e,t){const[i,r]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(i,r,(e=>(0,o.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=M;const _=/[^\da-z]+/gi;function E(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(_,"").toLowerCase()));return b(i,r,(e=>c.RadixAlphaNum.decode(e)))}function T(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const n=(0,o.mapNumericOr)(e.charCodeAt(r),(e=>e),256),s=(0,o.mapNumericOr)(t.charCodeAt(r),(e=>e),256),a=(0,o.clamp)(-256,256,n-s);i=null==i?a:(i+a)/2}return i}t.radixDiff=E,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:M(e,t),radixDiff:E(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=T,t.paddedPositionalDiff=function(e,t,i=8){return T((0,a.leftPad)(e,i," "),(0,a.leftPad)(t,i," "))}},84885:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),n=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,n.sortedKeys)(e))}},75387:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},f=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const h=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",n.set(this,[]),s.set(this,new Map),o.set(this,void 0),a.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,o,"f")}set ttlMs(e){f(this,o,e,"f"),null!=d(this,a,"f")&&clearInterval(d(this,a,"f")),f(this,a,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,a,"f")&&clearInterval(d(this,a,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,s,"f").clear(),this}delete(e){return d(this,s,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,s,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,s,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,s,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const n=t();return null!=n&&this.set(e,n),n}lastSetOrGetTs(e){return d(this,s,"f").get(e)?.ts}set(e,t){return d(this,s,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,s,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,s,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,h.sortBy)(d(this,s,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,n,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,s,"f").delete(e);for(const i of d(this,n,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,s,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){"use strict";var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[o]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return a(this,r,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>a(this,r,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||a(this,r,"m",n).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)a(this,r,"m",n).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!a(this,r,"m",n).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)a(e,r,"m",n).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)a(e,r,"m",n).call(e,t,i)||(yield[t,t])}()}toA(){return a(this,r,"m",s).call(this),[...this.delegate.keys()]}[(r=new WeakSet,o=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,n=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},s=function(){for(const[e,t]of this.delegate)a(this,r,"m",n).call(this,e,t)}},84699:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},94174:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const n=r(i(48161)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),f=i(45255),h=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,o.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,o.lazy)((()=>(0,a.uniq)([s.default.geteuid?.(),s.default.getuid?.(),n.default.userInfo().uid]))),t.userid=(0,o.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,o.lazy)((()=>(0,a.uniq)([s.default.getegid?.(),s.default.getgid?.(),n.default.userInfo().gid]))),t.groupid=(0,o.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,o.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,o.lazy)((()=>(0,l.toNotBlank)(n.default.userInfo()?.username))),t.userNameFromWhoami=(0,o.lazy)((async()=>(0,h.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:f.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,o.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,o.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,o.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.1-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=1,t.versionPrerelease=["prealpha"],t.release="2024.3.1-prealpha+20240308150212",t.gitSha="d92384e8659ff46fbae8e6f81fa5867114a4a843",t.gitDate=new Date(1709938932e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),n=i(55835),s=i(31586),o=i(97790),a=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,n.allDefined)(i))return;const[o,a,u,c,d,f,h]=i,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(o,a-1,u,c,d,f,h/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,o.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,a.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},73568:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const a=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),n.set(this,(0,a.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,n,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,n,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,n,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),o(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,r,"f")&&clearTimeout(s(this,r,"f")),o(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,n=new WeakMap},69591:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const n=r(i(87997)),s=i(31586);t.debounce=function(e,t){let i,r=[];const o=(0,s.gt0)(t)?(...s)=>{r=s,null!=i&&n.default.clearTimeout(i),i=n.default.setTimeout((()=>{e(...r)}),t)}:e;return o.reset=()=>{null!=i&&n.default.clearTimeout(i),i=void 0},o.force=()=>{o.reset(),e()},o.setTimeoutMs=e=>{o.reset(),t=e},o.timeoutMs=()=>t,o}},22911:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c,d,f,h,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(i(87997)),w=y(i(57975)),S=i(45599),b=i(26905),P=i(55835),M=i(31586),_=i(68708),E=i(20214),T=i(57153),x=i(85556),D=i(50213),k=i(70025),C=i(95937),O="TIMEOUT",I=(0,S.defer)((()=>(0,D.mkLogger)("async.Deferred")));class F{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,M.gt0)(t)?new n(O).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const n=i[r];if(n.isSettled){if(n.name===O)return void I().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield n.value}}if(i.every((e=>e.name===O)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new n(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),o.set(this,void 0),a.set(this,T.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),f.set(this,void 0),h.set(this,void 0),this.id=(g(i=n,n,(y=p(i,n,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,h,"f")??(0,D.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof n&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,a,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,_.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,o,"f")}get elapsedMs(){return(p(this,o,"f")??Date.now())-this.startedAt}get[(o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,f=new WeakMap,h=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,E.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,E.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,f,"f")&&(v.default.clearTimeout(p(this,f,"f")),g(this,f,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,M.gt0)(e)&&(g(this,f,v.default.setTimeout((()=>{this.isPending&&(this.reject(new x.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,C.onTimeout)())}),e),"f"),p(this,f,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,a,"f")===T.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,a,"f")!==T.PromiseStates.pending}get isResolved(){return p(this,a,"f")===T.PromiseStates.resolved}get isRejected(){return p(this,a,"f")===T.PromiseStates.rejected}get settledMs(){return null==p(this,o,"f")?void 0:p(this,o,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,a,T.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,k.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,a,T.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=F,n=F,m=function(e){if(p(this,a,"f")===T.PromiseStates.pending){(0,P.map)(p(this,f,"f"),v.default.clearTimeout),e(),g(this,o,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},s={value:0}},27395:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),n=i(40958),s=i(42659),o=i(23838),a=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),f=i(25764),h=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new o.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,a.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return f.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,h.setEnding)(!0),w();for(const t of f.EndableRanks.values){const i=g.get(t)??[];(0,n.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,h.setEnding)(!0),Promise.all((0,n.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of f.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){"use strict";var r,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),f=i(55835),h=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",o).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,n.set(this,void 0),s.set(this,void 0),a.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,n,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,h.toInt)(e)??0,t=(0,h.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",o).call(this);const f=()=>{u(this,r,"a",l)&&(0,h.gt0)(this.opts.intervalMs)&&(c(this,n,(0,d.setInterval)(u(this,a,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref())};return(0,h.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,a,"f").call(this),f())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):f(),!0}}t.EndableInterval=v,n=new WeakMap,s=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(){(0,f.map)(u(this,n,"f"),d.clearInterval),c(this,n,void 0,"f"),(0,f.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const a=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),f=i(25764),h=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=f.EndableRanks.first,o){this.endTimeoutMs=o,r.set(this,void 0),this.onEnds=[],n.set(this,(0,a.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,h.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,n,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){o(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,n,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,n=new WeakMap},99331:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let n=!1;t.ending=function(){return n},t.setEnding=function(e){n=(0,r.isTest)()?e:e||n}},45608:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const n=r(i(1708)),s=i(22573),o=i(45599),a=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),f=i(28874),h=i(27395),m=i(99331),p=i(56038),g=(0,o.defer)((()=>(0,l.mkLogger)((0,a.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,o.defer)((()=>{f.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,s.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,h.endEndables)(),n.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,o.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])n.default[e].on(t,(i=>{v({reason:`${e}:${t}`,status:0,error:i})}))}))},60172:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,r)=>{t=e,i=r})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const f=i(50357),h=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,n.set(this,void 0),s.set(this,0),o.set(this,void 0),a.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,o,"f")}unset(){d(this,s,0,"f"),d(this,n,void 0,"f"),d(this,o,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,h.gt0)(e)?e:void 0}watchLater(e){c(this,a,"f").push(e)}prior(){return this.isStale()?void 0:c(this,o,"f")}lastValue(){return c(this,o,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,n,"f")||(0,h.gt0)(this.ttlMs)&&Date.now()-c(this,n,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,n,"f")?void 0:Date.now()-c(this,n,"f")}elapsedMs(){return c(this,o,"f")?.settledMs??c(this,o,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,f.eql)(e?.value??await(e?.promise),i))for(const e of c(this,a,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,a,"f"))e.onError(t)}finally{d(this,s,(i=c(this,s,"f"),++i),"f")}},u=function(e){d(this,n,Date.now(),"f");const t=c(this,o,"f");return d(this,o,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,h.gt0)(this.timeoutMs)&&c(this,o,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,o,"f")),c(this,o,"f")}},1728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),n=i(80049);t.memoizeAsync=function(e,t){let i=0;const s=new n.FifoCacheAsync(t),o=t=>(i++,s.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return o.clear=e=>{if(null==e)return s.clear();{const t=(0,r.stringify)(e);return s.deleteIf((e=>t===e))}},o.size=()=>s.size,o.callCount=()=>i,o}},22781:function(e,t,i){"use strict";var r,n,s,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),n.set(this,!1),s.set(this,!1)}_call(){return o(this,n,"f")?(a(this,s,!0,"f"),!0===this.undefinedIfBusy?void 0:o(this,r,"f")):(a(this,n,!0,"f"),a(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{a(this,n,!1,"f"),!0===this.runLaterIfBusy&&o(this,s,"f")&&(a(this,s,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return o(this,n,"f")}prior(){return o(this,r,"f")}async force(){return await o(this,r,"f"),this._call()}}r=new WeakMap,n=new WeakMap,s=new WeakMap},37461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),n=i(76790),s=i(38639),o=i(42659),a=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),f=i(32639),h=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),v=i(15674),w=i(42638);var S=i(20214);async function b(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function M({name:e,arr:t,f:i,timeoutMs:n}){const s=[];for(const o of(0,r.compact)(await t))try{const e=await((0,l.gt0)(n)?(0,c.thenOrTimeoutError)(i(o),n):i(o));null!=e&&s.push([e,o])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:o,error:t})}return s}async function _({arr:e,f:t,name:i,maxConcurrent:n,timeoutMs:s,promises:o}){if(null==e)return[];const a=(0,r.compact)(await e);if((0,r.isEmpty)(a))return[];if((n=Math.round(n??(0,v.maxCpus)()))<=1)return M({arr:e,f:t,name:i,timeoutMs:s});const u=o??(a.length<=n?w.PermissivePromises:new w.Promises(i,(()=>n))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,f=await u.enqueueAll(i,a.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(f).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,i){const r=[];for(const n of(0,p.batches)((0,h.toA)(await e),t)){const e=await b(n);r.push(...await b(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,a.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,h.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,h.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,h.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,h.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=M,t.mapAsyncSerial=async function(e){return(await M(e)).map((e=>e[0]))},t.thenCollectParallel=_,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:n,promises:s}){return(await _({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:n,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:n,timeoutMs:s}){return(await _({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:n,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await _({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*o.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,n=null;try{r=await((0,f.isFunction)(e)?e():e)}catch(e){n=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(n??r)}catch{}if(null!=n)throw n;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,s.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const n=await t;return null!=n?i(r,n):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const n=await t(r);return null==n?i():n},t.thenMap2Or=async function(e,t,i,r){const n=await e;if(null==n)return r();const s=await t;if(null==s)return r();const o=await i(n,s);return null==o?r():o},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await _({name:e,arr:t,f:i});return(0,n.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(42659),a=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),f=i(22454),h=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),v=i(25764),w=i(38836),S=i(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new f.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),n=(0,l.clamp)(10*o.secondMs,o.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),n);try{const n=await(0,c.tot)(t),s=Date.now()-r;return i?.(n,s),this.push(e,s),n}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new h.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,a.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/o.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function M(e,t,i){return P.instance().time(e,t,i)}function _(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,n.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=M,t.timeSync=function(e,t){const i=Date.now(),r=t();return _(e,Date.now()-i),r},t.pushTime=_,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>M(e,t)),i)}},42638:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const h=f(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),v=i(54993),w=i(89788),S=i(82647),b=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class M{constructor(e,t){r.add(this),this.name=e,this.ee=new h.default.EventEmitter,n.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),o.set(this,[]),a.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,n,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,b.maxCpus)(),d(this,n,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,a,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,o,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,o,"f").map((e=>e.name)),pendingNames:d(this,a,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:i,serialId:n}){const s=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:n});return this.laterPop(),s}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,o,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,a,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,a,"f").length,e),i=this.runningSerialIds,n=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,o,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,a,"f").length}hasPending(){return d(this,a,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,a,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,a,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=M,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const n=new P.Deferred(e,{payload:i,serialId:r});return d(this,a,"f").push({d:n,l:t}),n},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,o,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,o,"f").push(e),e},t.maybeRun=function(e,t){const i=new M(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new M(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},4867:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),n=i(34546),s=i(41400),o=i(31586),a=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let a=!0;return Promise.race((0,r.compact)([(0,n.asPromise)(e).finally((()=>a=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>{if(a)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(a)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,n.asPromise)(e).finally((()=>l=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>a.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),n=i(42659),s=i(41400),o=i(32639),a=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let f=!1;const h=null==t?void 0:t+Date.now();let m=1;for(;null==h||Date.now()t/2&&!f&&(f=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,a.clamp)(10*m,l.ShortCommandTimeoutMs,(t??n.minuteMs)/5);await(0,s.delay)(r,d),m++}}return f||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const n=r(i(1708)),s=i(45599),o=i(41400),a=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),f=i(59958),h=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),v=i(50213),w=i(7282),S=i(88158),b=i(45969),P=i(43334),M=i(28874),_=i(3790);function E(e){return T().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const T=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(M.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(f.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>E(e))))},(0,o.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,M.allSettings)())t.watchLater(e)}));const x=["HOME","LANG","USER"],D=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],k=(0,p.lazy)((()=>{const e=(0,h.caseInsensitiveEnv)().pick(...P.isPosix?x:D),t=(0,h.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,M.pathWithDefaults)(),e}));function C(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[f.PS_IS_CHILD_PROCESS]="1",t[f.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[f.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,M.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,a.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(n.default.env,(e=>E(e)||!(0,_.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=C,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:I({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let O=!1;function I({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const n=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...k(),...i?(0,g.childProcLocale)():{},...C(r),...e??{}});for(const e of(0,M.transientSettings)())e.deleteFromEnv(n);if((0,y.isLogged)("debug")&&!O){O=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(n).map((([e,t])=>[e,(0,_.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>E(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return n}t.childEnv=I},84777:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const n=r(i(31421)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),f=i(31586),h=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),v=i(79089),w=i(45255),S=i(22911),b=i(4867),P=i(73614),M=i(70025),_=i(57159),E=i(36868),T=i(66184),x=i(45643),D=i(95402),k=i(9727),C=(0,o.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function O(e){return(0,h.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function I(e,t=30*u.secondMs){if(null==e)return!1;C().debug("endProcess()",O(e));const i=e.pid;if(null==i||i<=0)return C().warn("endProcess(): asked to end invalid pid",O(e)),!1;if(i===s.default.pid)return C().warn("endProcess(): asked to end MY pid",O(e)),!1;if(i===s.default.ppid)return C().warn("endProcess(): asked to end my parent pid",O(e)),!1;(0,E.closeStreams)(e);{const t=e.kill();C().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,D.killPid)(i).catch((e=>{C().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,x.waitForPidExit)(i,t))return C().debug("endProcess(): exitted",O(e)),!0;{D.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");C().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,D.killPid)(i,!0).catch((e=>{C().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,x.waitForPidExit)(i,5e3)}function F(e,i,r,n=0){const o=new Date,a=[];return(0,v.niceable)(i,r)&&a.push((0,P.setUnrefTimeout)((()=>{(0,f.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,f.gt)(n,u.secondMs)&&a.push((0,P.setUnrefTimeout)((()=>{(0,f.gt0)(e.pid)&&I(e)}),n-250)),a.push((0,P.setUnrefTimeout)((()=>{if((0,f.gt0)(e.pid))return(0,D.addPid)({pid:e.pid,cmd:i,timeoutMs:n,ppid:s.default.pid},o)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>a.forEach(clearTimeout))),e}function L(e,t,i,r){const s=(0,k.spawnOptions)(r);return(0,T.isLogged)("trace",C().context)?C().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:s}):C().debug("execFile()",{command:e,args:t,timeoutMs:i}),F(n.default.execFile(e,t,s),e,t,i)}async function A(e,t,i){const r=i.quiet??!1,n=i.ignoreStderr??!1,s=i.ignoreExitCode??!1,o=L(e,t,i.timeoutMs,(0,h.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{o.disconnect?.()}catch{}return{result:"",pid:o.pid}}const u=o.pid,h=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new S.Deferred(h);o.on("error",(e=>g.push(e))),o.on("exit",(e=>{(0,f.isNumber)(e)&&y.isPending&&y.resolve(e)})),o.on("close",(e=>{(0,f.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,E.endStream)(o.stdin);const v=new d.Latch;null==o.stdout?v.resolve():(o.stdout.on("error",(e=>g.push(e))),o.stdout.on("data",(e=>m.push(e))),o.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==o.stderr||n?P.resolve():(o.stderr?.on("error",(e=>g.push(e))),o.stderr?.on("data",(e=>p.push(e))),o.stderr?.on("end",(()=>P.resolve()))),C().debug("stdoutResult_() invoked and waiting for completion...",{name:h}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),C().debug("stdoutResult_() exitCode settled...",{name:h,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt});const T=p.join("");(0,l.notBlank)(T)&&g.push(new Error(T)),!r&&(0,a.isNotEmpty)(g)&&C().warn(h+" resulted in errors:",g);const x=i.isIgnorableError??M.isIgnorableError,D=g.filter((e=>!0!==x(e)));if(D.length>0)throw 1===D.length?D[0]:new _.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:D});if(!s&&0!==y.value)throw new Error(h+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:T}}catch(e){throw C().error("stdoutResult_() failed",e),await(0,D.killPid)(o.pid,!0),e}}t.endProcess=I,t.ReniceAfterMs=(0,o.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,o.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const s=(0,k.spawnOptions)(r);return C().debug("spawn()",{command:e,args:t,maxAgeMs:i}),F(n.default.spawn(e,t,s),e,t,i)},t.execFile=L,t.stdoutResult_=A,t.stdout_=async function(e,t,i){const r=await A(e,t,i);return C().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},86335:function(e,t,i){"use strict";var r,n,s,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ChildService=t.ChildServiceNames=t.inspectPort=t.pathToService=void 0;const l=i(77598),u=a(i(1708)),c=i(19851),d=i(40958),f=i(22573),h=i(50268),m=i(68708),p=i(5670),g=i(50989),y=i(12168),v=i(59455),w=i(41583),S=i(54993),b=i(80875),P=i(50213),M=i(81168),_=i(27395),E=i(25764),T=i(59958),x=i(70025),D=i(83278),k=i(85021),C=i(29325),O=i(43334),I=i(28874),F=i(84777),L=i(55534),A=i(85100),R=i(34330),N=(0,c.lazy)((()=>(0,P.mkLogger)("child.ChildService")));async function j(e){const t=(0,M.ensureSuffix)(e,".js"),i=D.BaseFile.projectRoot(),r=D.BaseFile.for(u.default.cwd()),n=(0,C.isPacked)()?[i.join("bin",t),O.isElectron?i.join("app.asar",t):void 0]:[r.join("dist","library",t),r.join("dist","core",t),r.join("lib","library",t)];(0,C.isPacked)()||(O.isElectron?(n.push(r.join("dist","app",t)),n.push(i.join("src","desktop","dist","library",t))):n.push(i.join("src","library","dist","library",t)));for(const e of n)if(null!=e&&!0===await e.isNonEmptyFile((0,C.isPacked)()?y.KB:128))return N().tap({msg:"pathToService()",level:"info",result:e,meta:{cmd:t,isPacked:C.isPacked,paths:n.map(S.toS)}});return N().throw("Failed to find path to "+e,{paths:n,fatal:!0})}t.pathToService=j,t.inspectPort=function(e){switch(e){case"web":return 9223;case"sync":return 9224;default:return(0,l.randomInt)(9225,9600)}},t.ChildServiceNames=(0,g.strEnum)(...p.ServiceNames.pick("web","sync"));class B{static async mk_(e,t={}){const i=t.pathToService??await j(e);if((0,f.blank)(i))throw new Error("Failed to find path to "+e);return t.nodeArgs=(0,v.toA)(t.nodeArgs),new B(e,i,t)}constructor(e,t,i){var a,l;r.add(this),this.serviceName=e,this.cmd=t,this.opts=i,this.restartCount=0,this.name="ChildService("+e+")",this.endTimeoutMs=(0,A.serviceExitTimeoutMs)(e),this.logger=(0,P.mkLogger)(this.name);const c=[...(0,v.toA)(i.nodeArgs),t.nativePath];(0,d.isNotEmpty)(i.args)&&c.push(...i.args),this.spawnOpts=(0,m.pick)(this.opts,"argv0","cwd","detached","env","gid","shell","stdio","timeout","uid","windowsHide","windowsVerbatimArguments","forceCLocale","forWorker"),this.spawnOpts.forceCLocale=!1,(l=(a=this.spawnOpts).env??(a.env={}))[T.UV_THREADPOOL_SIZE]??(l[T.UV_THREADPOOL_SIZE]=(0,S.toS)(("web"===e?I.Settings.webUvThreads:I.Settings.syncUvThreads).valueOrDefault)),this.wc=new R.WatchedChild({name:e,childFactory:async()=>(this.restartCount>0&&await(this.opts.onPreRestart?.()),this.restartCount++,(0,F.spawn)(u.default.execPath,c,-1,this.spawnOpts)),endableRank:E.EndableRanks.service,endTimeoutMs:this.endTimeoutMs,onStdout:o(this,r,"m",s).bind(this),onStderr:o(this,r,"m",n).bind(this),onError:this.opts.onError??(e=>!1===(0,x.isIgnorableError)(e)),ignoreStopErrors:!1,exitCommand:L.ServiceExitCommand,...i}),(0,_.addEndable)(E.EndableRanks.first,this)}get startMs(){return this.wc.startTs}runHealthCheck(){return this.wc.writeStdin(k.HealthCheckCommand+"\n")}start(){return this.wc.start()}stop(){return this.wc.stop()}restart(e){return this.wc.restart(e)}get ended(){return this.wc.ended}async end(){return this.wc.ended||this.write(L.ServiceExitCommand),this.wc.end()}get pid(){return this.wc.pid}running(){return this.wc.running()}notRunning(){return this.wc.notRunning()}write(e,t=2){if(t<0)return this.logger.warn("write(): no more retries",{toStdin:e}),!1;try{const t=this.wc.proc;return!0!==t?.stdin?.writable?(this.logger.warn("write(): childProc isn't open, ignoring",{toStdin:e}),!1):t.stdin.write((0,M.ensureSuffix)(e,"\n"))}catch(i){return this.logger.warn("write(): caught "+i),this.wc.onError("onStdout()",(0,w.toErr)(i)),this.write(e,t-1)}}}t.ChildService=B,r=new WeakSet,n=function(e){const t=(0,b.parseJSON)(e);return this.logger.warn(".onStderr()",t??e),!0===t?.fatal},s=function(e){if(!(0,f.blank)(e))try{const t=(0,b.parseJSON)(e);if(null==t)return void this.logger.info(".onStdout(): non-JSON payload",e);if(!0===t?.fatal)this.wc.onError(this.name+".onStdout()",t);else if((0,h.isHealthCheckSummary)(t)){const e="failed"===t.state||"error"===t.level;this.logger.log(e?"error":"info",".onStdout(): health check summary",t),e&&this.wc.onError(this.name+".onStdout()",t,e)}else null!=this.opts.onData&&this.opts.onData(t)}catch(t){this.logger.warn(".onStdout() failed:",{data:e,error:t})}}},3790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),n=i(41400),s=i(19851),o=i(28874);(0,n.later)((()=>o.Settings.sensitiveEnvRegExp.watchLater((()=>a.unset()))));const a=(0,s.lazy)((()=>{try{return new RegExp(o.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${o.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(o.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&a().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||o.Settings.license.includesEnvKey(e)}},55534:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceExitCommand=void 0,t.ServiceExitCommand="--exit"},85100:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serviceExitTimeoutMs=void 0;const r=i(23560),n=i(28874),s=i(45255);t.serviceExitTimeoutMs=function(e){return(0,r.isSyncService)(e)?n.Settings.syncExitTimeoutMs.valueOrDefault:s.ShortCommandTimeoutMs}},34330:function(e,t,i){"use strict";var r,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),f=i(19851),h=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(54993),w=i(27395),S=i(25764),b=i(99331),P=i(42638),M=i(38835),_=i(8769),E=i(57159),T=i(66003),x=i(50213),D=i(45643),k=i(28874),C=i(84777);t.mkBasicWatchedChild=function(e){return new O({name:(0,h.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,C.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class O{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,f.lazy)((()=>(0,x.mkLogger)("WatchedChild("+(0,h.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),n.set(this,!1),this.onError=(e,t,i)=>{const s=new E.WrappedError(e,{cause:t}),o=!1!==s.ignorable;this.logger().log(o?"warn":"error","onError()",s),u(this,n,"f")||o||(this.lastError=s,(0,_.onError)(s),!0!==s.fatal?(i??this.opts.onError(e,s))&&(this.logger().warn("onError requested restart",{src:e,error:s}),u(this,r,"m",a).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:k.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:S.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,w.addEndable)(this.opts.endableRank,this),u(this,r,"m",a).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,n,"f")}async end(){return c(this,n,!0,"f"),u(this,r,"m",s).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",s).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,n,"f")}),!u(this,n,"f")&&!(0,b.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",s).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,n,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=O,n=new WeakMap,r=new WeakSet,s=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,n,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",o).call(this,e)},o=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,D.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,C.endProcess)(e,this.endTimeoutMs)},a=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,n,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",s).call(this),!this._stopped&&!u(this,n,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,_.onError)("Can't restart "+this.name+", failure rate is too high."+M.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,n,"f")}),this._stopped||u(this,n,"f")||(0,b.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,T.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,v.toS)(e).includes("Error: Cannot find module")&&(0,_.onError)("Failed to start "+this.name+M.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,n,"f")}),(0,b.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",a).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const o=s(i(53916)),a=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),f=i(4001),h=i(95696);function m(e){return(0,f.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,a.toNativePath_)(e);const i=h.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),n=i.sibling(r);if(n.isSelfOrDescendantOf((0,l.examples)()))return o.join("$examples",n.posixPathFrom((0,l.examples)()));const s=(0,d.originalsDir)();if(n.isSelfOrDescendantOf(s))return o.join("$library",n.posixPathFrom(s));const f=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=f?o.join("$library",n.posixPathFrom(f)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){"use strict";var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const s=i(6858),o=i(1708),a=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),f=i(43334),h=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return n(this,r,"f").push(...e),this}async parse(e=o.argv,t){let i=(0,m.addHelpFooter)(new s.Command).description((0,m.cliWrap)(h.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of n(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":a.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,o.exit)(0)})),i.parse(e,t??{from:f.isMainElectron?"electron":"node"});const d=i.opts();for(const e of n(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),n=i(31586),s=i(51926),o=i(17344),a=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,n.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,o.EditionName)()+" v"+a.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},83210:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDaemon=void 0;const n=r(i(1708)),s=i(22573),o=i(38639);t.isDaemon=function(e){return(0,o.isTrue)(n.default.env.__is_daemon)||(0,o.isTrue)(e?.daemon)||!(0,s.blank)(e?.pidfile)}},94361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),n=i(40958),s=i(55835),o=i(31586),a=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,o.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,n.compactBlanks)([c("user id","PUID",(0,a.userids)()),c("group id","PGID",(0,a.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,s.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},43380:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WriteSettingsArg=void 0;const r=i(28874),n=i(2858),s=i(22573),o=i(38639),a=i(46292);t.WriteSettingsArg={beforeParse:e=>e.option("--write-settings","Write (or re-write, if they exist) system and library settings.toml files. See https://phstr.com/settings"),afterParse:async e=>{if((0,o.isTrue)(e.writeSettings)){const e=await(0,n.writeSystemSettings_)();if(null==e?console.info("--write-settings: Failed write system settings: no system configuration directory was found.",{checkedDirectories:(0,a.osConfigDirs)()}):console.info(`--write-settings: Wrote system settings to ${e}`),(0,s.blank)(r.Settings.libraryDir.valueOrDefault))console.error("--write-settings: Failed to write library settings: no PS_LIBRARY_DIR is set.");else{const e=await(0,n.writeLibrarySettings_)();console.info(`--write-settings: Wrote library settings to ${e}`)}}}}},76596:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),n=i(19851),s=i(22573),o=i(42659),a=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),f=(0,n.lazy)((()=>(0,d.mkLogger)("date.Date")));function h(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,a.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,a.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=h,t.nowish=function(e,t=2500){return null!=e&&((0,o.isDate)(e)?h(e,new Date,t):Math.abs(e-Date.now()){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const r=i(77988),n=i(19851),s=i(55835),o=i(31586),a=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,n.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),f=["year","month","day","hour","minute","second","millisecond"];class h{static fromISO(e,t){const i=d().exec((0,a.toS)(e).trim()),r=i?.groups;return null==r?void 0:h.for((0,c.parseExifDateTime)(r.start,t),(0,c.parseExifDateTime)(r.end,t),(0,o.toInt)(r.index),(0,o.toInt)(r.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,s.map)(e.start,(e=>r.ExifDateTime.fromJSON(e))),(0,s.map)(e.end,(e=>r.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,r=1){if(null==e||!e.isValid||null==t||!t.isValid)return;r=(0,o.clamp)(1,1e3,(0,o.toInt)(r,{defaultValue:1})),i=(0,o.clamp)(0,r-1,(0,o.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const n=e.toMillis(),s=(t.toMillis()-n)/(r+1)*(i+1),a=e.plus({milliseconds:s});return null==a?void 0:new h(e,a,t,i,r)}constructor(e,t,i,r=0,n=1){this.start=e,this.middle=t,this.end=i,this.index=r,this.splits=n,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=f.map((r=>function({start:e,end:t,middle:i,field:r}){return null!=e[r]&&null!=t[r]?i[r]:void 0}({start:e,middle:t,end:i,field:r})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new h(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=h},79842:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const r=i(77988),n=i(51168),s=i(19851),o=i(76790),a=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),f=i(51926),h=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),v=i(21330),w=i(928),S=i(54261),b=i(73389),P=i(51275),M=(0,s.lazy)((()=>(0,h.mkLogger)("date.Dated")));function _(e){return null!=e&&(e instanceof v.FuzzyDate||e instanceof r.ExifDate||e instanceof r.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,b.isDateTime)(e)||(0,m.isDateObject)(e))}function E(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof r.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function T(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof r.ExifDate?e.toMillis(l.dayMs):e instanceof v.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),D(e),((e,t)=>e+t))}function x(e){try{if(null==e||(0,f.isString)(e)||(0,c.isNumber)(e))return;return(0,b.isDateTime)(e)?e:e instanceof r.ExifDateTime||e instanceof v.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?n.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void M().warn("datedToDateTime() failed",{d:e,error:t})}}function D(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,S.hasTime)(e)){if((0,c.gt0)((0,w.getMillisecond)(e)))return 0;if((0,c.gt0)((0,w.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,w.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,w.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,w.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,w.getMonth)(e))?l.monthMs-1:l.yearMs-1}function k(e,t){const i=E(e),r=T(e);if(null!=i&&null!=r)return(0,c.gt0)(t)&&t>r-i?{start:Math.round((i+r)/2-t/2),end:Math.round((i+r)/2+t/2)}:{start:i,end:r}}function C(e,t,i,r){const[n,s]=(0,o.sortBy)([k(e,i),k(t,r)],(e=>e?.start));return null!=n&&null!=s&&null!=n&&null!=s&&(n.start===s.start||n.end>=Math.min(s.start,s.end))}function O(e,t){return(0,a.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??v.FuzzyDate.fromISO(e)}t.isDated=_,t.toDated=function(e){return _(e)?e:void 0},t.mapDated=function(e,t){return _(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=E,t.datedToEndTs=T,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof r.ExifDate?n.DateTime.fromObject(e):x(e)},t.datedToDateTime=x,t.datedToPrecisionMs=D,t.isoToPrecisionMs=function(e){return(0,u.map)(O(e),D)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:r}){if(null==e||null==t)return!1;if(i??(i=D(e)),r??(r=D(t)),C(e,t,i,r))return!0;const n=(0,P.getZoneName)(e),s=(0,P.getZoneName)(t);return null==n&&null!=s&&(e=(0,v.setZone)(e,s)??e),null==s&&null!=n&&(t=(0,v.setZone)(t,n)??t),C(e,t,i,r)},t.isoToDated=O,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof n.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const r=i(31586),n=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,n.isString)(e))return(0,r.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),n=i(31586),s=i(54557),o=i(91655),a=new s.FifoCache(512);function l(e){return(0,n.isNumber)(e)?e:(0,r.blank)(e)?void 0:a.getOrSet(e,(()=>(0,o.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,o.fmtFullDuration)((0,n.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),n=i(40958),s=i(22573),o=i(42659),a=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,a.isNumber)(e))return;if((0,a.isNumber)(e))return e;if((0,a.isDigits)(e))return(0,a.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const f=(0,n.compact)(d.map((e=>function(e,t){const i=(0,a.toFloat)(e);if(null!=i){if((0,s.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*o.yearMs;case"weeks":case"week":case"w":return i*o.weekMs;case"days":case"day":case"d":return i*o.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*o.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*o.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*o.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),h=(0,a.lt0)(f[0])?[f[0],...f.slice(1).map((e=>-e))]:f;return(0,c.sum)(h)}catch{return}};const d=[{ms:o.yearMs,s:"y"},{ms:o.weekMs,s:"w"},{ms:o.dayMs,s:"d"},{ms:o.hourMs,s:"h"},{ms:o.minuteMs,s:"m"},{ms:o.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,a.isNumber)(t))return;if(0===t)return"0";if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},98247:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const r=i(77988),n=i(51168),s=i(19851),o=i(22573),a=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),f=i(68852),h=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function v(e,t,i){const r=t.exec(e);if(null==r||(0,u.isEmptyObj)(r.groups))return;const{year:n,month:s,day:o,hour:c,minute:f,second:p}=(0,d.mapEntries)(r.groups,((e,t)=>(0,l.toInt)(t)));if(null==n||null==s||null==o)return;if(!h.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==f))return;const g=(0,a.map)((0,l.toFloat)(r.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),v=(0,y.timezoneOffsetFromRegExpMatch)(r);return b({year:n,month:s,day:o,hour:c??0,minute:f??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(v)??i,rawValue:e,tzoffsetMinutes:v})}t.UnsetZone=n.Info.normalizeZone(r.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof r.ExifDate&&t instanceof r.ExifTime))return;const i=new r.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:s}){return(0,o.blank)(e)?void 0:r.ExifDateTime.fromDateTime(n.DateTime.fromFormat(e,i,{zone:s??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,o.blank)(e)?void 0:r.ExifDateTime.fromDateTime(n.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,o.blank)(e)?void 0:r.ExifDateTime.from(e,t)??v(e,S(),t)},t.parseExifDateTimeRe=v;const w=/[-:_\s]?/,S=(0,s.lazy)((()=>(0,f.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,w,p.monthRE,w,p.dayRE,/[T\s]/,p.hourRE,w,p.minuteRE,w,p.secondRE,p.subsecRE,/\s?/,f.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function b(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof r.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=r.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,a.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=b},74417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const r=i(51168),n=i(22573),s=i(42659),o=i(49769),a=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),f=i(66649),h=i(98725),m=i(88600);t.recent=function(e,t=5*s.secondMs){return(0,c.isRecentMs)((0,f.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=r.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,n.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,n.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=r.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,o.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,f.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,a.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*s.secondMs):void 0)??(0,h.parseDateTime)(t)?.toMillis()}},21330:function(e,t,i){"use strict";var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const s=i(77988),o=i(51168),a=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),f=i(31586),h=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),v=i(79842),w=i(66649),S=i(98247),b=i(98725),P=i(928),M=i(54261),_=i(73389),E=i(89724),T=i(17415),x=i(88600),D=i(51275);function k(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class C{constructor(e,t,i){this.year=e,this.month=t,this.day=i,r.set(this,(0,p.lazy)((()=>(0,x.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(b.ISO_YMD_RE.exec(e)?.groups??b.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,f.toGt0)(e?.year);if(null==e||null==t||tk(e))).join("-")}toLocal(){return(0,E.datedToLocal)(this)}toDateTime(){return o.DateTime.fromObject((0,h.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,h.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,h.pick)(e.plus({month:1}),"year","month"):(0,h.pick)(e.plus({year:1}),"year");return new C(t.year,t.month,t.day)}}function O(e,t){if(e instanceof s.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,M.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,T.zoneToTzOffsetMinutes)((0,w.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(r=>(0,d.map)((0,P.getMonth)(e),(n=>(0,d.map)((0,P.getDay)(e),(s=>(0,d.map)((0,P.getHour)(e),(o=>(0,S.dateObjectToExifDateTime)({year:r,month:n,day:s,hour:o,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=C,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",r=15*(0,f.round)(e/15),n=Math.abs(r),s=Math.floor(n/60),o=Math.floor(Math.abs(n%60));return`${t?"UTC":""}${i}${k(s)}:${k(o)}`},t.toExifDateTime=O,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof s.ExifDateTime?e.tzoffsetMinutes:(0,_.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,M.hasTime)(e)||(i??(0,v.datedToPrecisionMs)(e))>=c.dayMs?L(e):O(e,(0,D.getZoneName)(e))?.toISOString({includeOffset:t})};const I="yyyy:MM:dd HH:mm:ss.SSS",F=I+"ZZ";function L(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>k(e))).join(t)}function A(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new C(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,r]=[e,t].map(w.datedToMillis);return null==i||null==r?void 0:i-r}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,f.isNumber)(t)?o.DateTime.fromMillis(t):(0,v.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,D.hasZone)(t)?F:I):void 0},t.datedToYMD=L,t.toFuzzyDate=A,t.sameDay=function(e,t){return(0,f.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,f.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,r=1){if(null==(0,w.datedToMillis)(e)||null==(0,w.datedToMillis)(t))return;const[n,s]=[e,t].map((e=>(0,w.datedToMillis)(e))).sort(),a=(s-n)/(r+1),l=(0,D.getZoneName)(e),u=l===(0,D.getZoneName)(t)?l:void 0,c=o.DateTime.fromMillis(n+a*i,{zone:u});return[e,t].some((e=>!(0,M.hasTime)(e)))?A(c):c},t.setZone=function(e,t,i){const r={...(0,h.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,D.hasZone)(e)},n=(0,T.normalizeZone)(t);if(null!=e&&null!=n&&(0,M.hasTime)(e))return e instanceof y.DateInterval?e.setZone(n,r):O(e)?.setZone(n,r)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,f.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,v.datedToDateTime)(e);if(null==i)return;const r=(0,D.getZoneName)(e);return null!=r&&"UTC"!==r||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){"use strict";var r,n,s,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const a=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),f=i(49769),h=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),v=i(68852),w=i(4001),S=i(28874),b=i(24689),P=i(79842),M=i(66649),_=i(98247),E=i(21330),T=i(54261),x=i(73389),D=i(16400),k=i(88600),C=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return C().tap({msg:"extractDateFromPath",result:L.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return L.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return L.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,h.mapNumeric)((0,M.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,v.concatRegexp)([/^/,t.yearRE,v.RegExpOptional.from(/-/,t.monthRE,v.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,v.concatRegexp)([/^/,t.yearishRE,v.RegExpOptional.from(/-/,t.monthishRE,v.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=F({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,x.isDateTime)(i)?i:(0,T.isExifDateTime)(i)?i.toDateTime():void 0};const O=new Map;function I(e,t,i){try{const r=(0,_.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=r)return r;const n=(0,f.getOrSet)(O,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void C().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,_.parseExifDateTimeFormat)({input:n?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void C().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function F({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:r=!0,descPredicate:n=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const s=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(w.stripDSC));if(0!==s.length)for(const{desc:e,f:o}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>b.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,_.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:_.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(S.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(S.Settings.extraDateTimeFormats.values)){const r=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${r})`,f:i=>I(i,r,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>a.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of L.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:r}))if(n(e))for(const e of s){const t=o(e);if(null!=t&&(0,k.isValidDate)(t))return t}}t.parseDated=F;class L{constructor(e={}){r.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&S.Settings.fuzzyDateParsing.watchLater((()=>o(this,r,"m",s).call(this))),null==e.fuzzyYearParsing&&S.Settings.fuzzyYearParsing.watchLater((()=>o(this,r,"m",s).call(this))),o(this,r,"m",s).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??S.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??S.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!S.Settings.usePathsToInferDates.valueOrDefault)return;E.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=F({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=L,r=new WeakSet,n=function(e){const t=new A(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},s=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new v.RegExpEscaped("(?"+(0,D.monthNames)().map(v.escapeRegExp).join("|")+")");o(this,r,"m",n).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),o(this,r,"m",n).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),o(this,r,"m",n).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),o(this,r,"m",n).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),o(this,r,"m",n).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),o(this,r,"m",n).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),o(this,r,"m",n).call(this,[t.yearRE,t.seps,t.monthishRE]),o(this,r,"m",n).call(this,[e,t.seps,t.yearRE]),o(this,r,"m",n).call(this,[t.yearRE,t.seps,e]),o(this,r,"m",n).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},L.instance=(0,u.lazy)((()=>new L));class A{constructor(e){this.regex=e instanceof RegExp?e:(0,v.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return E.FuzzyDate.for({year:(0,h.toInt)(t.year),month:(0,h.toInt)(t.month)??(0,D.monthName2index)(t.monthname),day:(0,h.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const r=i(55835),n=i(31586),s=i(54261);function o(e){return e instanceof Date?e.getMinutes():e?.minute}function a(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=o,t.getSecond=a,t.getMillisecond=l,t.getCentisecond=function(e){return(0,r.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,s.hasTime)(e)&&((0,n.gt0)(o(e))||(0,n.gt0)(a(e))||(0,n.gt0)(l(e)))},t.getSecMs=function(e){return(0,r.map)(a(e),(t=>{const i=l(e)??0;let r=(t+i/1e3).toString();for(t<10&&(r="0"+r),0===i&&(r+=".");r.length<6;)r+="0";return r}))}},54261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const r=i(77988),n=i(31586),s=i(68708);t.hasTime=function(e){if(!(0,s.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,n.gt0)(t.hour)||(0,n.gt0)(t.minute)||(0,n.gt0)(t.second)||(0,n.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof r.ExifDateTime}},73389:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const r=i(51168);t.isDateTime=function(e){return r.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const r=i(51168),n=i(19851),s=i(42659),o=i(55835),a=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),f=i(74417),h=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,n.lazy)((()=>v(l.Settings.datesBeforeAreEstimated.valueOrDefault)??v(l.Settings.datesBeforeAreEstimated.defaultValue)));function v(e){return(0,o.map)((0,c.isoToDated)(e),w)}function w(e){return(0,a.isNumber)(e)?_(e):100*S(e)+((0,m.getCentisecond)(e)??0)}function S(e){if((0,a.isNumber)(e))return Math.floor(_(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function b(e,t){if(null==e||e<0)return;let i=e;const r=()=>{const e=i%100;return i=Math.floor(i/100),e},n=10*r(),s=r(),o=r(),l=(0,a.toGt0)(r()),u=(0,a.toGt0)(r()),c=(0,a.toGt0)(r());return{year:i,month:c,day:u,hour:l,minute:o,second:s,millisecond:n,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=b(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):h.FuzzyDate.for(i)}function M(e,t){return _(Date.now()-e,t)}function _(e,t){return w(r.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const r=i(19851),n=i(76790),s=i(31586),o=i(9092),a=(0,r.lazy)((()=>{const e=new o.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const r=new Intl.DateTimeFormat(t,{month:i});(0,s.times)(12,(n=>{const s=r.format(new Date(2017,n));e.set(s,n+1),"short"===i&&"en-US"===t&&e.set(s+".",n+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:a().get(e)},t.monthNames=function(){return(0,n.sort)([...a().keys()])}},42499:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLuxon=void 0;const r=i(51168),n=i(19851),s=i(19043),o=i(28874);t.setupLuxon=(0,n.lazy)((async()=>{r.Settings.throwOnInvalid=!1,o.Settings.twoDigitCutoffYear.watch((e=>r.Settings.twoDigitCutoffYear=e)),r.Settings.defaultLocale=await(0,s.locale)()}))},17415:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const r=i(77988),n=i(51168),s=i(19851),o=i(22573),a=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),f=i(54993),h=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,s.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const r=(0,h.leastBy)(g(),(t=>Math.abs(t-e)));return null!=r&&Math.abs(r-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(r)}t.isUTCZone=function(e){return S(e)||0===b(e)?.offset(Date.now())},t.normalizeZone=b,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,a.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=M,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:M(i)};const _=/\b(?Z|UTC|GMT)\b/,E=/(?[-±+−])/,T=/[-−]/,x=/(?[01]\d)/,D=/(?[01]?\d)/,k=/(?::(?\d\d))/;function C(e){return S(e)?0:O((0,t.TimezoneOffsetRE)().exec(e))}function O(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,o.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=T.test((0,f.toS)(e.groups.tzSign))?-1:1,r=(0,l.toInt)(e.groups.tzMinutes)??0,n=null==t?void 0:i*(60*t+r);return v(n)?n:void 0}t.TimezoneOffsetRE=(0,s.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),_,new m.RegExpEscaped("|"),E,x,m.RegExpOptional.from(k),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=C,t.timezoneOffsetFromRegExpMatch=O;const I=/\b(?(?:Etc\/)?GMT)\b/,F=(0,s.lazy)((()=>(0,m.concatRegexp)([I,E,D,m.RegExpOptional.from(k)])));function L(e){return O(F().exec(e))}t.ianaZoneToOffsetMinutes=L,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,o.blank)(e))return;const i=L(e)??C(e);if(null!=i)return M(i);if(null!=t){const i=b(e);if(null!=i)return M(i.offset(t))}}},88600:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const r=i(51168),n=i(19851),s=i(40958),o=i(22573),a=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),f=i(28874),h=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),v=(0,n.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),w=(0,n.lazy)((()=>(0,s.compact)(f.Settings.badDates.values.map((e=>(0,h.isoToDated)(e)))))),S=(0,n.lazy)((()=>(0,s.compact)(w().map((e=>(0,p.datedToISO)(e)))))),b=(0,n.lazy)((()=>(0,s.compact)(w().map((e=>(0,y.datedToLocal)(e)))))),P=(0,n.lazy)((()=>(0,s.compact)(w().map((e=>(0,m.datedToMillis)(e))))));function M(e){if(null==e)return!1;const t=E(e);return v().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return M(e)?e:void 0},t.isValidDate=M;const _=String(new Date("bad"));function E(e){try{if(!(0,h.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===_)return _;const t=(0,s.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const n=[];if((0,l.isNumber)(e)||n.push("year is not a number"),(0,l.lt)(e,f.Settings.minValidYear.valueOrDefault)&&n.push("year is less than "+f.Settings.minValidYear.key),(0,u.gt)(e,T())&&n.push("year is in the future"),null==t&&null!=i&&n.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&n.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&n.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const s=r.DateTime.fromObject({year:e,month:t,day:i});s.isValid||n.push(s.invalidExplanation??"not valid")}return(0,s.compact)(n)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=f.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const r=(0,m.datedToMillis)(e);(0,u.gt)(r,Date.now()+i)&&t.push("date is too far in the future: see "+f.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):b().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):S().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,o.toNotBlank)((0,s.uniq)((0,s.compactBlanks)(t)).join("; "))}catch(t){return v().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=E;const T=(0,n.lazy)((()=>r.DateTime.now().plus({milliseconds:f.Settings.maxValidFutureMs.valueOrDefault}).year),a.dayMs);t.mapValidDate=function(e,t){return M(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==E({year:e,month:t,day:i})}},51275:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const r=i(77988),n=i(31586),s=i(24689),o=i(73389);t.hasZone=function(e){return null!=e&&!(0,n.isNumber)(e)&&(e instanceof s.DateInterval||e instanceof r.ExifDateTime?e.hasZone:!!(0,o.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==r.UnsetZoneName&&e.zone.offset(Date.now())!==r.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,o.isDateTime)(e)?e.zoneName===r.UnsetZoneName?void 0:e.zone?.name:e instanceof r.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},15056:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),n=i(7311);function s(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=s,t.pathToDb=function(e,t){return s(e,t).join(n.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const o=s(i(76760)),a=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),f=i(97352),h=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),v=i(70698),w=i(64680),S=i(29882),b=i(45969),P=i(43334),M=i(28874),_=i(41692),E=i(32774),T=i(80612),x=i(32551),D=(0,d.lazy)((()=>(0,f.mapGte0)((0,h.userid)(),(e=>"-"+e))??""));function k(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+D(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,o.join)(i,".photostructure-cache"+D()),preexistingDir:i});return e}}function C(){if((0,b.isDocker)())return(0,a.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,o.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:E.DefaultDockerLibraryDir+"/.photostructure/cache"+D(),preexistingDir:E.DefaultDockerLibraryDir},...k()]);const e=(0,a.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),o.default.resolve((0,x.homeDir)(),"AppData","Local")]:P.isMac?[o.default.resolve((0,x.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,o.join)((0,x.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,o.join)(e,t),preexistingDir:e})));return i.push(...k()),i}t.tmpCacheDirs=k,t.tmpDirs=function(){return(0,T.filterDirs)({dirs:k(),desc:"tmp"})},t.cacheDirs=C,t.defaultCacheDir=(0,d.lazy)((()=>(0,T.firstDir)({dirs:C(),desc:"cache"})));const O=(0,d.lazy)((()=>{(0,_.setSettingsDefaults)(),M.Settings.cacheDir.watchLater(I)}));function I(){M.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{O();const e=M.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=I},46292:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),n=i(45969),s=i(41692),o=i(32774),a=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,n.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,a.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:o.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:o.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,n.isDocker)()?c:(0,a.desktopConfigDirs)()).map((e=>e.dir))}},79960:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultApplePhotosLibrary=void 0;const r=i(19851),n=i(22573),s=i(50213),o=i(45255),a=i(84777),l=i(16287),u=i(57902),c=i(43334),d=(0,r.lazy)((()=>(0,s.mkLogger)("dir.DefaultApplePhotosLibrary"))),f=["read","com.apple.photolibraryd","SystemLibraryPath"];t.defaultApplePhotosLibrary=async function(){if(c.isMac)try{const e=await(0,a.stdout_)("defaults",f,{timeoutMs:o.ShortCommandTimeoutMs});if((0,n.blank)(e))return void d().warn(`"defaults ${f.join(" ")}" returned blank (!!)`);{const t=await(0,l.isReadableDirectory)(e);return d().tap({msg:"defaultApplePhotosLibrary()",level:u.LogLevels.info,result:t?e:void 0,meta:{isReadable:t}})}}catch(e){return void d().warn("defaultApplePhotosLibrary()",e)}}},32774:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),n=i(45969),s=i(32774);t.defaultLibraryDir=function(){return(0,n.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,n.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const n=r(i(76760)),s=i(40958),o=i(72993),a=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function f(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),n.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(n.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,a.env)().XDG_DATA_HOME,(0,a.env)().XDG_CONFIG_HOME,n.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:n.default.join(e,(0,o.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:f(),desc:"config"})},t.desktopConfigDirs=f},84373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),n=i(96706),s=i(29882);t.envConfigDir=function(){const e=(0,n.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),n=i(40958),s=i(22573),o=i(66430);function a({dirs:e,desc:t}){for(const{dir:i,preexistingDir:a}of(0,n.compact)(e))if(!(0,s.blank)(i)){if((0,o.isReadWriteableDirectorySync)(i))return i;if((0,s.blank)(a)||(0,o.isReadWriteableDirectorySync)(a))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=a,t.filterDirs=function({dirs:e,desc:t}){return(0,n.compact)(e.map((e=>a({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),n=i(76760),s=i(1708),o=i(19851),a=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,o.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,a.compactBlanks)(e)){const e=(0,n.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),n=i(49776),s=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[s.libraryDataDir,s.libraryPreviewsDir,n.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},9595:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),n=i(54993),s=i(29882),o=i(28874);function a(e){return(0,r.toNotBlank)((0,n.toS)(e))??o.Settings.libraryDir.valueOrDefault}t.libraryDir=a,t.originalsDir=function(e){return(0,s.resolveMaybe)(a(e),o.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,s.resolveMaybe)(a(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,s.resolveMaybe)(a(e),o.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),n=i(55835),s=i(37805),o=i(15056),a=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),f=i(28874),h=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${s.version}\n`;function p(e){return u.PosixFile.forMaybe((0,h.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,h.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function v(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+a.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function w(e){return u.PosixFile.forMaybe((0,h.originalsDir)(e))}async function S(e){return y(w(e),!1)}function b(e){return u.PosixFile.forMaybe((0,h.libraryPreviewsDir)(e))}async function P(e){return y(b(e))}function M(e){return p(e)?.join(f.Settings.syncReportsDir.valueOrDefault)}async function _(e){return y(M(e))}async function E(e){return y((0,n.map)(g(e),(e=>(0,o.pathToDbDir)(e,o.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await v(t);return(0,r.uniq)([t,i,await S(t),await P(t),await _(t),await E(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=v,t.libraryOriginalsDirPosixFile=w,t.setupLibraryOriginalsDir_=S,t.libraryPreviewsDirPosixFile=b,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=M,t.setupLibrarySyncReportsDir_=_,t.setupLibraryDbDir_=E},46296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const n=r(i(76760)),s=i(19851),o=i(40958),a=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),f=i(45969),h=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),v=i(80612),w=i(32551);function S(){return(0,f.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:h.isMac?[{dir:n.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,o.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>n.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,a.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,a.notBlank)(i)?i:b()}catch(e){return console.error("defaultLogDir_() failed",e),n.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(44198),a=i(43334),l=i(24399),u=i(32551);async function c(){return a.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,n.lazy)((async()=>{if(a.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,n.lazy)((()=>(0,o.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),n=i(7282),s=i(29325),o=i(44198);t.getDevEnvFlag=function(e){return!(0,n.isProd)()&&!(0,s.isPacked)()&&((0,r.toBoolean)((0,o.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,o.env)()[e]=String(t)}},34580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),n=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,n.env)().DO_NOT_TRACK)}},44198:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const n=r(i(73024)),s=i(76760),o=r(i(1708)),a=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),f=i(7282),h=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),v=i(6012),w=i(96706);t.env=(0,a.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>o.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,g.isDocker)()||(0,f.isTest)()&&"lite"===o.default.env.PS_LICENSE||e.push((0,s.join)((0,h.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),i={...o.default.env};for(const r of e)try{const e=(0,d.debom)(n.default.readFileSync((0,p.resolve)(r))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(s))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),n=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let s;for(const o of(0,n.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(o));){if(null==s.groups)continue;const{key:e,val:n}=s.groups;if((0,r.blank)(e)||null==n)continue;const o=n.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=o}}return i}},96706:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const n=r(i(1708)),s=i(19851),o=i(22573),a=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),f=i(34102),h=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,o.firstNotBlank)(n.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,n.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,h.env)()))),t.onEnvChange=p,(0,l.later)((()=>{h.env.watchLater(p),(0,f.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,a.isTrue)(g(e))}},98314:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),n=i(19851),s=i(40958),o=i(22573),a=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),f=i(89788),h=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),v=i(70025),w=i(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(a.errorName),...e.map(a.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(a.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(i)))}function b(e){return(0,s.compact)(e).filter((e=>!a.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(o.notBlank)}function P(e,t){const i=(0,s.uniqSubstrings)(b(e)),r=t?.maxLen??400,n=t?.trailingChars??64,o=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(i.join(a.ErrorDelimiter)),r-o.length,n)+o.sort().join("")}function M(e,t){return e instanceof w.WrappedError?e.toString():(0,o.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,n.lazy)((()=>(0,h.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new f.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(M(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,o.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,o.notBlank)(i))return i}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=M,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,o.blank)(e)&&(e=t.MissingError),M(e,{maxLen:i})+" at "+(0,a.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),n=i(26905),s=i(55835),o=i(54993),a=i(81168);t.describeError=function(e){const t=(0,a.stripSuffix)((0,o.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,s.map)((0,n.errorErrno)(i),(e=>t.push(u.get(e)))),(0,s.map)((0,n.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),n=i(76790),s=i(50989),o=i(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,n.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(o.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},68301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorStore=t.ExtraEventsForPlease=void 0;const r=i(19851),n=i(42659),s=i(75240),o=i(55835),a=i(31586),l=i(68708),u=i(59455),c=i(54993),d=i(50213),f=i(45255),h=i(37628),m=i(99331),p=i(46292),g=i(38835),y=i(32144),v=i(29882),w=i(95696),S=i(55222),b=i(28874),P=(0,r.lazy)((()=>(0,d.mkLogger)("error.EventStore")));function M(e){return(0,l.omit)(e,"breadcrumbs")}t.ExtraEventsForPlease=7;class _{constructor(e){this.root=e}datedRoot(e=new Date){return this.root.join((0,c.toS)(e.getFullYear()),(0,c.toS)(e.getMonth()+1))}rmrf(){return this.root.rmrf()}msg2file(e){return this.datedRoot(new Date(e.timestamp*n.secondMs)).join((0,h.shortStringSha)(e.message,8,S.GeoRadix)+".json")}async eventsFrom(e=new Date,t=n.dayMs){const i=e.getTime(),r=i-t,o=i+t;return P().tap({msg:"eventsFrom()",result:(0,u.toA)(await this.datedRoot(e).clear().childFiles((async e=>P().tap({msg:"eventsFrom().childFiles() accept "+e.base,result:(0,y.isJsonExt)(e)&&!(0,v.isHiddenBasename)(e.base)&&(0,a.within)(r,o,e.mtimeMs())})))),meta:{when:e,deltaMs:(0,s.fmtDuration)(t)}})}async eventCount(e=new Date){return(await this.eventsFrom(e)).length}async eventQuotaExceeded(e){const i=(0,c.toS)(e).includes(g.PleaseSendErrorFlag)||(0,c.toS)(e.message).includes(g.PleaseSendErrorFlag),r=await this.eventCount(),n=b.Settings.maxErrorsPerDay.valueOrDefault+(i?t.ExtraEventsForPlease:0);return P().tap({msg:"eventQuotaExceeded()",result:r>=n,meta:{event:M(e),recentEventCount:r,maxErrorsPerDay:n,pleaseSend:i}})}async maybeSendEvent(e){if(e.timestamp=Math.floor(e.timestamp),(0,m.ending)())P().error("maybeSendEvent(): REJECT: we're ending.",{event:M(e)});else if(await this.eventQuotaExceeded(e))P().error("maybeSendEvent(): REJECT: too many recent events.",{event:M(e)});else try{const t=await this.writeEvent_(e);return P().tap({msg:"maybeSendEvent(): "+t==null?"REJECT: previously sent this event already this month":"ACCEPT",result:null!=t?e:void 0,meta:{eventFile:t}})}catch(e){return void P().error("maybeSendEvent(): REJECT: failed to write event.",e)}}writeEvent_(e){return this.msg2file(e).applyIfEmpty_({fn_:t=>t.writeJson_(e),minSizeBytes:3,returnUndefinedIfNotEmpty:!0,timeoutMs:f.ShortCommandTimeoutMs})}}t.ErrorStore=_,_.instance=(0,r.lazy)((()=>(0,o.map)((0,p.configDir)(),(e=>new _(w.PosixFile.for(e).join("events"))))))},70025:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),n=i(38639),s=i(26905),o=i(54993),a=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function f(e){return(0,o.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function h(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,o.toS)(e)+(0,r.compact)(t).join("");return f(i)+h(i).join("")},t.stripErrorFlags=f,t.extractErrorFlags=h,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,a.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,n.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,n.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,n.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},8769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),n=i(31586),s=i(68708),o=i(7282),a=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),f=i(38835),h=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,h.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const n=!0===i.fatal,c=!0===i.ignorable;if(!n&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),n&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const f=!n||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===f?"error":"warn","onError()",{event:f,error:i}),!n||(0,o.isTest)()||(0,a.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),n}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,n.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,a.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,n.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,n.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+f.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),n=i(22573),s=i(38639),o=i(26905),a=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),f=i(81168),h=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,n.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,n.firstNotBlank)((0,f.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,o.errorName)(t)??(0,d.first)(this.causes,o.errorName)??"Error",this.codes=(0,f.splitUniq)([t.code,...this.causes.map(o.errorCode)],o.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,o.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,h.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,n.blank)(r)||(i=(0,f.dedupeNeedle)(i,r,"file")),(0,h.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,a.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,f.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const o=i(49769),a=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),n.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,o.getOrSet)(s(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),o=s(this,r,"f").get(e);return null!=o&&(o.resolve(t),s(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,n=new WeakMap},34102:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),n=i(19851),s=i(15197);t.ee=(0,n.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const n=r(i(73024)),s=r(i(1708)),o=i(19851),a=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,o.lazy)((()=>s.default.geteuid?.())),f=(0,o.lazy)((()=>s.default.getgroups?.()));function h(e,t){try{return!(0,a.blank)(e)&&(n.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?h(t,n.default.constants.R_OK|n.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?h(t,n.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:n,processGid:s}){if(null==e)return!1;const o=n??d(),a=null!=s?[s]:f()??[],l=0===o,u=l||e.uid===o,h=l||a.includes(e.gid);return!(t&&!(((u?256:0)|(h?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(h?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(h?8:0)|1)&e.mode))}t.canAccessSync=h,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const n=r(i(76760)),s=i(19851),o=i(81168),a=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),f=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,f.resolve)(...e)}};const h=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,f.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:h().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,f.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,o.equalsIgnoreCase)(e.basename,i.base))return n.default.join(r,e.basename);throw new a.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),n=i(76760);function s(e){return[...o(e)]}function*o(e){for(;e!==(0,n.dirname)(e);)e=(0,n.dirname)(e),yield e}function a(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=a(e);return t.every((e=>i.includes(e)))}t.ancestors=s,t.ancestorG=o,t.selfAndAncestorG=function*(e){yield e,yield*o(e)},t.childrenSync=a,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},f=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=h(i(76760)),v=h(i(1708)),w=i(46466),S=h(i(57975)),b=h(i(38522)),P=i(19851),M=i(40958),_=i(5233),E=i(22573),T=i(42659),x=i(50357),D=i(96249),k=i(98553),C=i(55835),O=i(31586),I=i(68708),F=i(97790),L=i(39926),A=i(51926),R=i(59455),N=i(54993),j=i(48884),B=i(22911),z=i(99331),V=i(56519),W=i(56038),U=i(31562),H=i(76850),q=i(70025),G=i(34102),$=i(80875),J=i(50213),K=i(70417),Z=i(43334),Y=i(81168),X=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),ne=i(89968),se=i(20197),oe=i(88561),ae=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),fe=i(65238),he=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),ve=i(27794),we=i(73428),Se=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new oe.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),n.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),o.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(n=new WeakMap,o=new WeakMap,r=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,M.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,j.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,E.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=be().get(i);if(null!=r)return r;const n=(0,he.resolve)(i),s=new Pe(n,t);return be().set(i,s),be().set(n,s),s}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,n,"f").unset(),f(this,o,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,he.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Y.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,C.map)(this.statSync(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,n,"f").call(this);if(null==t||null==e||(0,M.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",s).call(this)??await d(e=this.clearThisAndParent(),r,"m",s).call(e)}async children_(e){const t=await(0,fe.readdir_)(this.nativePath);return null!=e&&await(0,M.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,M.isNotEmpty)(e)?(0,M.includesAll)(t,e):(0,M.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,M.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,R.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,O.gt0)(t))return;const i=await d(this,n,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Z.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,M.isEmpty)(e)||(0,x.eql)(["."],e)||e.every(E.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,C.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,L.pad2)(t+1),(0,L.pad2)(i))))}child(...e){if((0,M.isEmpty)(e))return this;const t=(0,D.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&f(this,o,void 0,"f"),f(this,o,d(this,o,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&f(this,o,void 0,"f"),f(this,o,d(this,o,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,T.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),j.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Z.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,M.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,T.unixtime)(t)>=(0,T.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,T.unixtime)(t)>(0,T.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,C.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,F.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*T.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,ae.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,ae.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,$.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,$.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,H.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces),(0,I.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,_.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,z.ending)()?1:3,timeoutMs:0,retryDelay:T.secondMs,errorIsRetriable:q.isRetriableError})}async gunzip(){return d(this,r,"m",a).call(this,(0,Y.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,r,"m",a).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,r,"m",a).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,M.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new B.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,A.newlineRe)(),(r=>{const n=e.exec(r);null!=n&&(t.maybeResolve(n),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,O.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new B.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),Me)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,n)=>{try{const s=await e.f(r,(0,C.denull)(n));t(s)&&i.resolve(s)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,O.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,s=async function(){const e=(await(0,fe.readdir_)(this.dir)).filter((e=>(0,Y.equalsIgnoreCase)(e.basename,this.base))),t=(0,j.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,C.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},a=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*T.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let Me=!0;t.useFsWatch=function(e){Me=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},19748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const r=i(28874),n=i(88840),s=i(14036),o=i(29882);function a(e){return t=>r.Settings.respectFileExtensions.valueOrDefault?(0,s.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,o.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=a,t.isBrowserExtension=a(n.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=a(n.ExtTypes.Video),t.isAssetFileExtension=a(n.ExtTypes.AssetFile)},84542:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),n=i(96249),s=i(51926),o=i(54993),a=i(43334);function l(...e){return(0,n.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,o.toS)(e).split((0,s.newlineRe)()))))}t.Newline=a.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(o.toS).join("\n");return a.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),n=i(19851),s=i(50213),o=i(37805),a=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const f=(0,n.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function h(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return f().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return h((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=h,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,a.mkdirp_)(i),await(0,d.writeTextfile_)((0,a.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+o.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const n=r(i(76760)),s=r(i(1708)),o=i(19851),a=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,o.lazy)((()=>[...(0,a.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,n.default.join(e,"System32"),n.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const a=s(i(44652)),l=o(i(73024)),u=i(76760),c=i(57975),d=i(19851),f=i(59455),h=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),v=i(14427),w=i(17217),S=i(16287),b=i(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const M=(0,d.lazy)((()=>(0,h.mkLogger)("fs.DirectoryEntry")));class _{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new _(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},n=await a.stat(t);return new _(i,new P(r,n))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return _.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new _(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void M().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>_.fromSimpleDirent(this.nativePath,e)))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new _(this.nativePath,new P(e.name,e))))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,f.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,f.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await a.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await a.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=_},20197:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const n=r(i(76760)),s=i(39926),o=i(29882),a=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,o.parseNativePath)(i.nativePath);if(await(0,o.mkdirp_)(r.dir),!i.requireNumber&&await(0,a.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=n.default.join(r.dir,`${r.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,a.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,o.parseNativePath)(i.nativePath);if((0,o.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=n.default.join(r.dir,`${r.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},88561:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const o=i(40958),a=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),f=i(34102),h=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends h.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,f.ee)().on("fileChanged",(e=>s(this,r,"m",n).call(this,e))),(0,f.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,o.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,r=new WeakSet,n=async function(e){if((0,a.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),n=i(22573),s=i(45599),o=i(96249),a=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],f=(0,s.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),h=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=h.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,n.blank)(i)?void 0:f()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,o.flatten)((0,a.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),n=i(17217),s=i(16287),o=i(68284);async function a(e){return(0,r.pick)(await(0,s.stat_)((0,n.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=a,t.fileStats=async function(e){try{return await a(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,o.statSync)((0,n.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const r=i(68817),n=i(19851),s=i(22573),o=i(50213),a=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),f=i(95696),h=i(93854),m=i(16287),p=(0,n.lazy)((()=>(0,o.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,h.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,r.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const n=(0,s.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),o=(0,l.normalizeExt)(f.PosixFile.for(e))??(0,c.mimetypeExt)(n);return(0,s.blank)(n)||(0,s.blank)(o)?void 0:{ext:o,mime:n}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new a.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),f=i(38836),h=i(43624);class m extends f.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,n.set(this,[]),s.set(this,void 0),o.set(this,void 0),l(this,o,(0,h.fileStatsSync)(e),"f"),l(this,s,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",a).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,n,"f").push(e)}close(){u(this,s,"f").close()}}t.FileWatcher=m,n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=async function(e){const t=await(0,h.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,o,"f"),t)){l(this,o,t,"f");for(const t of u(this,n,"f"))t(e,this.nativePath)}}},73209:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c,d,f,h,m,p,g,y,v,w,S=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},b=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const M=i(58587),_=P(i(44652)),E=i(87997),T=i(40958),x=i(17586),D=i(42659),k=i(50357),C=i(75240),O=i(55835),I=i(31586),F=i(30976),L=i(13538),A=i(54993),R=i(7282),N=i(68852),j=i(23560),B=i(25764),z=i(38836),V=i(99331),W=i(22781),U=i(38835),H=i(55222),q=i(63870),G=i(69734),$=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)(G.PsLockExt)+"$");class K extends z.EndableWrapper{static newUid(e=process.pid){return b(this,n,Math.max(Date.now(),S(this,n,"f",s)+1),"f",s),(0,T.compactBlanks)([H.TokenRadix.encode(S(this,n,"f",s)),j.serviceName.prior(),(0,A.toS)(e)]).join("-")}static pidFromLockfile(e){return n.pidFromBasename((0,$.basename)(e))}static pidFromBasename(e){return(0,I.toInt)(J.exec((0,A.toS)(e))?.groups?.pid)}static for(e){return S(this,n,"f",a).find((t=>t.opts.file===e.file))??new n(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>S(this,r,"m",w).call(this)),e.endableRank??B.EndableRanks.postdb,(0,q.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,b(t=n,n,(i=S(t,n,"f",o),++i),"f",o)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),f.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(S(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,G.fsLockFileBasename)(n.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await S(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,G.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+S(this,l,"f")),this.staleMs=(0,I.round)(this.opts.timeoutMs/(0,F.randomFloat)(2,4)),S(n,n,"f",a).push(this)}get acquired(){return S(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await S(this,r,"m",h).call(this,e)??S(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,x.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,k.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==S(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:D.secondMs);b(this,c,setInterval((()=>S(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=S(this,c,"f")&&(clearInterval(S(this,c,"f")),b(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(S(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),b(this,u,!1,"f"),(0,O.map)(S(this,d,"f"),(e=>(0,E.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?S(this,r,"m",v).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),b(this,d,setTimeout((()=>S(this,r,"m",v).call(this)),(0,I.toGt0)(this.staleMs)??D.secondMs),"f"),S(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(S(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,L.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,n=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,f=new WeakMap,r=new WeakSet,h=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,I.gt0)(this.staleMs)&&Date.now()>S(this,f,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await S(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){b(this,f,Date.now(),"f");const e=[],t=await S(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,I.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+D.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,G.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;n.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const s=i[0]===this.lockfile.base;if(s)b(this,u,!0,"f");else if(!0!==t?.vacuum){const t=n.pidFromBasename(i[0]);if((0,I.gt0)(t)&&!(0,M.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),S(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:s,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await S(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},v=async function(){await S(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},w=function(){(0,T.filterInPlace)(S(n,n,"f",a),(e=>S(e,l,"f")!==S(this,l,"f")))},s={value:0},K.internalErrors=0,o={value:0},a={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),n=i(51926),s=i(54993),o=i(17217);function a(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,n.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,n.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,s.toS)(e)))return;const i=(0,o.basename)(e);return a(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&a((0,o.basename)(e))}},4001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),n=i(55835),s=i(31586),o=i(51926),a=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function f(e,t={aggressive:!0}){return h((0,r.toNotBlank)(e.name)??(0,a.toS)(e),t).normalize()}function h(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,s.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:h(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const n=(0,u.parsePosixPath)(i),s=f(n,{aggressive:!1});return[...t,s+n.ext].join("/").normalize()},t.stripCopySuffixFromName=f,t.copySuffixCountFromName=function(e){const t=((0,o.isString)(e)?e:e.name).toLowerCase().normalize(),i=f(t),r=(0,o.stripPrefix)(t.toLowerCase().normalize(),i);return(0,n.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,o.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,n.map)(m.exec(t),(e=>t=e[1].trim())),(0,n.map)(g.exec(t),(e=>t=e[1].trim())),t}},19254:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fileGrep_=t.GrepReader=void 0;const n=r(i(73024)),s=i(57075),o=i(46466),a=i(54993),l=i(33456),u=i(17217),c=i(58722);class d extends s.Transform{constructor(e,t="\n"){super({objectMode:!1,autoDestroy:!0}),this.pattern=e,this.sep=t}_transform(e,t,i){const r=(0,a.toS)(e).match(this.pattern);null!=r&&this.push(r[1]??r[0]+this.sep),i()}}t.GrepReader=d,t.fileGrep_=async function(e,t){const i=new c.WritableToBuffer;return await(0,o.pipeline)([n.default.createReadStream((0,u.toNativePath_)(e)),new l.LineReader,new d(t),i]),(await i.buffer).toString()}},14977:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const n=r(i(44652)),s=r(i(73024)),o=i(46466),a=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,o.pipeline)(s.default.createReadStream(e,{autoClose:!0}),a.default.createGzip(),s.default.createWriteStream(t,{autoClose:!0})),await n.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const n=r(i(77598)),s=r(i(73024)),o=i(46466),a=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),f=i(73913),h=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),v=i(16287),w=(0,a.lazy)((()=>(0,h.mkLogger)("fs.Hash"))),S=(0,a.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=S().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),S().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await M(s.default.createReadStream(i)),stats:(0,u.pick)(await(0,v.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function M(e,t=[],i="sha512"){const r=n.default.createHash(i);return await(0,o.pipeline)([e,...t,r]),r.digest().subarray(0,f.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=M,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return n.default.randomBytes(f.HashBits/8).toString("base64")}},48313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),n=i(42659),s=i(55835),o=i(31586),a=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),f=i(63870),h=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,a.stdout_)("chflags",["hidden",t],{timeoutMs:10*n.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,f.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:h.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,s.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,a.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*n.secondMs}),i=(0,o.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),n=i(54993),s=i(7282),o=i(43334),a=i(69375),l=/^\/dev(?:\/|$)/i,u=o.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=o.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=o.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,f=o.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function h(e){return null!=f?.exec((0,n.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,a.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":h(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=h,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},87128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonFileStore=void 0;const r=i(19851),n=i(55835),s=i(57159),o=i(50213);t.JsonFileStore=class{constructor(e,t,i){this.file=e,this.mkObject=t,this.onWrite=i,this.prior=(0,r.lazy)((()=>this.file.readJson("debug")))}async read_(){return await this.prior()??(0,n.map)(await this.mkObject(),(e=>this.write_(e)))}async write_(e){try{return await this.file.writeJson_(e,{spaces:2}),this.prior.set(Promise.resolve(e)),(0,o.mkLogger)("fs.JsonFileStore").info("wrote to "+this.file,e),null!=this.onWrite&&await this.onWrite(this.file,e),e}catch(e){throw new s.WrappedError("Failed to write to "+this.file,{cause:e,path:this.file.nativePath})}}}},33456:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),n=i(51926),s=i(54993);class o extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,s.toS)(e)).split((0,n.newlineRe)()),o=r.pop();this._prior=o??"";let a=!1;for(const e of r)a||(a=!this.push(e));a?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=o},64680:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const n=r(i(76760)),s=i(17217),o=i(73428);t.mkNoMedia_=function(e){return(0,o.writeTextfile_)(n.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},85772:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const o=s(i(76760)),a=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),f=i(68852),h=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),v=i(83278),w=i(70698),S=i(88561),b=i(65238),P=i(16287),M=(0,a.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),_="NoMedia",E=new RegExp("(?:^|["+(0,l.uniq)([(0,f.escapeRegExp)(o.default.sep),"/"]).join("")+"])\\.?"+_+"$","im"),T=Object.freeze(["."+_,_]),x=Object.freeze((0,u.flatten)(T.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function D(e){return null!=E.exec(e)}t.isNoMediaName=D;const k=(0,a.lazy)((()=>new S.FileCache({name:"fs.noMediaDirsCache"})));async function C(e,t){if(null==e)return null;const i=v.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return D(i.base)||await(0,w.isCachedirTagFile)(i)?k().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):C(i.parent());{const e=await k().getOrSetAsync(i.nativePath,(()=>O(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:C(i.parent())}}async function O(e){if(D(e.base))return k().set(e.parent().nativePath,e.nativePath),M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,b.readdirCached)(e.nativePath);if(null!=t)return F(e.nativePath,t);const i=new h.Abortable,r=await Promise.race([I(e.nativePath,i),(0,b.readdir)(e.nativePath).then((t=>F(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,w.isCachedirTagDirectory)(e)?M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(w.CACHEDIR_TAG).nativePath)}):null}async function I(e,t){for(const i of g.isCaseSensitiveFs?x:T){if(!0===t?.aborted)return null;const r=o.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return M().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function F(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(D(r.basename))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,o.join)(e,r.basename))});if(r.basename===w.CACHEDIR_TAG){const t=(0,o.join)(e,r.basename);if(await(0,w.isCachedirTagFile)(t))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await C(e,t)},t.whyNoMedia=C,t.whyNoMediaDir=O,t._dirHasNoMediaChild=I},29882:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const n=r(i(44652)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),f=i(51926),h=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),v=i(78133),w=i(53265),S=i(17217),b=i(16287),P=i(66430),M=i(5545);function _(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,o.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=_,t.containsHiddenPathname=function(e){return C(e).some(_)},t.isNotHiddenPosixPath=function(e){return C(e).every((e=>!_(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return T((0,v.posix2native)(e))},t.extname=function(e){return T(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const E=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function T(e){const t=E.exec(e)?.groups,i=t?.ext2??"",r=s.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function x(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,f.splitLast)(t.dir,s.default.sep)}function D(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),i=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,s.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function k(e,t,i){if(null==t||null==i)return!1;const r=e(t),n=e(i);return null!=r&&null!=n&&(y.isLinux?r===n:(0,p.equalsIgnoreCase)(r,n))}function C(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function O(e){return(0,u.notBlank)(e)&&C(e).length===(y.isWin?1:0)}function I({p:e,maxLength:t}){const i=(0,S.toNativePath_)(e);if(i.length<=t)return i;const r=C(e),n=[],s=[r.pop()];for(;r.length>0;)if(n.length=t){r.unshift(n.pop());break}}else if(s.unshift(r.pop()),L([...n,...s]).length>=t){r.push(s.shift());break}return r.length>0&&n.push("…"),L([...n,...s])}function F(e){return e.startsWith("\\\\")}function L(e){return(0,f.ensurePrefix)((0,a.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=T,t.parentBasename=x,t.grandParentBasename=function(e){return x(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=D,t.eqlBasename=function(e,t){return k(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return k(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return k(S.toNativePath_,e,t)},t.toPathnames=C,t.pathIsRoot=O,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:C(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,S.toNativePath_)(e),r=(0,S.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,v.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=I,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const n=[];for(const r of e.slice(0,i))n.push(I({p:r,maxLength:t}));return n.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return C(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return C(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=T(e);return`${i.base}${t}${i.ext}`},t.isUNC=F,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(F(e)||null!=e.match(M.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(O(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await n.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;n.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>n.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=L,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:L(e)},t.bestMountpointForDir=function(e,t){return(0,h.greatestBy)(t,(t=>D({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const n=r(i(76760)),s=i(19851),o=i(40958),a=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),f=i(54993),h=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),v=i(64660),w=i(21144),S=i(16287),b=(0,s.lazy)((()=>(0,h.mkLogger)("fs.PathTo"))),P=c.KiB;async function M(e,t=P){const i=await(0,S.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,v.isStatRX)(i,e)}function _(){if(y.isWin){const e=(0,a.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,a.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,a.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,n.default.join(e,"System32"),n.default.join(e,"System32","Wbem"),n.default.join(i,"chocolatey","bin"),n.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function E(){const e=(0,f.toS)((0,m.env)().PATH).split(n.default.delimiter);return(0,o.uniq)((0,o.compactBlanks)([...e,..._()]))}t.isRXFile=M,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,o.uniq)((0,o.compactBlanks)([...E(),...(0,d.toA)(i)]));for(const i of(0,o.uniq)((0,o.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=n.default.join(t,e);if(await M(i))return y.isLinux?i:(0,w.actualPath)(i)}}b().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){"use strict";var r,n,s,o=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&o(t,e,i);return a(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),f=c(i(73024)),h=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),v=i(76790),w=i(5233),S=i(22573),b=i(42659),P=i(26905),M=i(75240),_=i(55835),E=i(31586),T=i(68708),x=i(13538),D=i(89937),k=i(12168),C=i(54993),O=i(48884),I=i(50213),F=i(45255),L=i(81168),A=i(56519),R=i(56038),N=i(31562),j=i(84777),B=i(9595),z=i(38835),V=i(70025),W=i(57902),U=i(55222),H=i(43334),q=i(33847),G=i(24399),$=i(28874),J=i(79915),K=i(45200),Z=i(34238),Y=i(87001),X=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),ne=i(73209),se=i(48313),oe=i(29882),ae=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),fe=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,O.contextFilter)(function(e){return(0,v.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class he extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,I.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Z.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,A.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,A.thenMapOr)((0,X.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>H.isMac?(0,j.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:F.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return he.for(e.nativePath,e)}static forMaybe(e){return(0,S.notBlank)(e)?he.for(e):void 0}static for(e,t){if(e instanceof he)return e;if((0,S.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,L.isString)(e)){const t=fe().get(e);if(null!=t)return t}const i=(0,ae.toNativePath_)(e),r=new he(i,t);return(0,L.isString)(e)&&fe().set(e,r),fe().set(i,r),r}static forPosix(e){return he.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,A.thenMap)((0,K.uri2nativePath)(e,t),(e=>he.for(e)))}for(e,t){return he.for(e,t)}forDirectoryEntry(e){return he.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,oe.containedByNativePath)({ancestor:(0,B.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,oe.containedByNativePath)({ancestor:(0,B.originalsDir)(),descendant:this,acceptSelf:!0}))return H.isWin&&this.nativePath.startsWith("\\\\")?he.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,_.map)((0,ee.bestMountpoint)(this.nativePath,await(0,X.mountpoints)()),(e=>he.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,_.map)((0,S.notBlankOr)(e,(()=>this.uri_())),Z.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,C.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===D.PS_LIBRARY_SCHEME?1:t.scheme===D.PS_LOCAL_FILE_SCHEME?2:t.scheme===D.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,L.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(H.isWin||H.isMac)return this.trap("hide",(async()=>(await(0,se.hide_)(this),this)))}async hidden(){return(0,se.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,L.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,O.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,_.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,T.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:n,skipWip:s=!1,skipFsLock:o=!1,retries:a=2,dirty:l=!1}){return(0,w.retryOnReject_)((async()=>{const a=await this.clear().isNonEmptyFile(i);if(!a){if(s&&o)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:o,minSizeBytes:i,timeoutMs:n,dirty:l})}return a&&r?void 0:this.utimes()}),{maxRetries:a,timeoutMs:2*n,retryDelay:3*b.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,E.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:n,dirty:s=!1}){return await this.parent().mkdirp_(),(0,ne.withLock_)({file:this,skipFsLock:r,timeoutMs:n,dirty:s},(async()=>{const r=this.wip();try{await r.unlink("trace");const s=await(0,x.thenOrTimeoutError)(e(r),n);if(s===t.NoOp)return s;if(await(0,N.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:F.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),s;throw new Error(this+"applyWip(): still empty after waiting "+(0,M.fmtDuration)(F.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==$.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",n).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",s).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();$.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:b.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,f.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,E.clamp)(F.ShortCommandTimeoutMs,10*b.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,S.notBlank)(this.ext)&&(0,S.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,b.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,_.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,A.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,L.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,oe.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,oe.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,Y.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=he,r=new WeakSet,n=async function(e){let t,i=e;const r=e.wip();try{const n=await this.stat_();if(null==n)return this.pflog().throw("Can't copy missing files"+z.NonRetriableErrorFlag);if(n.size>0){if($.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+z.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await h.default.copyFile(this.nativePath,r.nativePath,f.default.constants.COPYFILE_FICLONE),n.size>5*k.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},n.size,(()=>r.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,E.approximates)(n.size,await r.size({refresh:!0}))),{intervalMs:b.secondMs,timeoutMs:b.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:n.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:n.birthtimeMs,mtimeMs:n.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,n.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${n.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,_.map)(t,(e=>e.end()))}},s=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),n=r?.size;return null==r||null==n?this.pflog().throw("Can't copy missing files"):(n>5*k.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},n,(()=>e.clear().size()))),H.isWin?await G.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,G.pwshQuote)(this.nativePath)} -Destination ${(0,G.pwshQuote)(i.nativePath)}`,(e=>e)):H.isMac?await(0,j.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,j.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+z.DoNotSendErrorFlag,{error:t})}finally{(0,_.map)(t,(e=>e.end()))}}},78133:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const n=r(i(76760)),s=i(22573),o=i(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(n.default.sep===n.default.posix.sep)return e;const i=(0,s.notBlank)(t)?n.default.sep+n.default.sep+t+n.default.sep:"",r=e.split(n.default.posix.sep);return(0,o.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(n.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||n.default.sep===n.default.posix.sep||n.default.posix.sep===n.default.sep?e:e.split(n.default.sep).join(n.default.posix.sep)}},43899:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const n=r(i(76760)),s=r(i(1708)),o=i(19851),a=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),f=i(43334),h=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,o.lazy)((()=>n.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,o.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),f.isElectron&&t.push(n.default.join((0,p.execDir)(),"resources"),n.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,a.compactBlanks)([(0,p.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,h.hasChildrenSync)(i,e))return i;for(const t of(0,h.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,h.hasChildrenSync)(t,e))return t;const r=n.default.join(i,"node_modules","photostructure");if((0,h.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!f.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),n=i(19851),s=i(31586),o=i(50213),a=i(57902),l=i(69428),u=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=a.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),n=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let s=-1;try{const n=i??(await(0,r.stat)(e)).size-t,o=Buffer.alloc(n);return s=await(0,r.open)(e,"r"),await(0,r.read)(s,o,0,n,t)}finally{(0,n.mapGte0)(s,r.close)}}},69428:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const o=s(i(73024));t.readFileSync=function(e){try{return o.readFileSync(e)}catch{}}},55690:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),n=i(84542);t.readLines_=async function(e){return(0,n.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class n extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=n},65238:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const n=r(i(51455)),s=i(76760),o=i(19851),a=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),f=i(13538),h=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),v=i(28874),w=i(63870),S=i(88561),b=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,o.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,o.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function M(){try{await n.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=M;const _=(0,o.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function E(e){(0,l.blank)(e)||_.prior()?.delete(e)}async function T(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await _().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,b.statTimeoutMs)(),r=x(e),n=await(0,f.thenOrTimeout)(r,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(n===h.Timeout&&(0,g.onTimeout)({soft:!1}),n!==h.Timeout&&n.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=E,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),_.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),M()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?M():E(e)))})),t.slowDirs=(0,o.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!_().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){E(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=_().get(e)},t.childDirectories_=async function(e){return(await T(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?T(e):x(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=T,t.readdirCached=function(e){return _().get(e)},t.readdirUncached_=x},53265:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const n=i(73024),s=r(i(76760)),o=i(40958),a=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),f=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),h=c.isWin?/[\\/]/:/\//;function m(){return(0,o.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=s.default.resolve(t,...e);if((0,n.existsSync)(i))return i}f().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,a.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(h).slice(0,2).find(a.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},50274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),n=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,n.isBoolean)(e.isFile)&&(0,n.isBoolean)(e.isDirectory)}},17217:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const n=r(i(73024)),s=r(i(76760)),o=i(22573),a=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),f=i(14427);function h(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,o.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,o.blank)(e.nativePath))throw new Error(`toNativePath(${(0,a.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof n.default.Dirent?e.name:h(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=h,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return h(e)?e.dir:s.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(h(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(s.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,a.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(n.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=h.LogLevels.debug){return(0,a.blank)(e)?void 0:v(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=S(e),r=S(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],n=t[i],s=(0,u.diff)(b(r),b(n));if(null==s||s>1)return"unmatched "+i+": "+r+" ≠ "+n}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=h.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const i=await w(e,t?.logLevel??h.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await w(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=h.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=h.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=h.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,f.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,o.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const n=r(i(73024)),s=i(22573);function o(e){try{return(0,s.blank)(e)?void 0:n.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function a(e){return null==e||e.isFile()&&0===e.size}t.statSync=o,t.isEmptyStats=a,t.isFileSync=function(e,t=0){const i=o(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=o(e);return t.emptyIsNew?null==i:a(i)},t.isNonEmptyFileSync=function(e,t=0){const i=o(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===o(e)?.isDirectory()}},41080:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),n=i(56409);t.onDataChunked=function(e,t,i){const r=new s(t,i,!0);return r.read(e),r.done};class s{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new n.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const n=r(i(57075)),s=i(41400),o=i(55835),a=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends n.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,a.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,o.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class f extends n.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=f},66430:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const n=r(i(73024)),s=i(76760),o=i(22573),a=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,o.blank)(e))return!1;try{return n.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,a.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,o.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,o.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,o.blank)(e)&&d((0,u.posix2native)(e))}},89966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const n=r(i(48161)),s=i(19851),o=i(55835),a=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),f=i(8103),h=i(43899);function m(){return(0,o.map)(h.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,o.map)(m(),(e=>e.join(c.platformName+"-"+n.default.arch())))}async function g(e){if(c.isWin&&(e=(0,a.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,f.pathIfExists)(m()?.join("bin",e))),(()=>(0,f.pathIfExists)(m()?.join(e))),(()=>(0,f.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,f.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,s.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,s.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,s.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,s.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const n=r(i(44652)),s=i(19851),o=i(22573),a=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),f=i(17217),h=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,a.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,o.blank)(t.file))throw new Error("can't touch blank path");const r=(0,f.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,f.dirname)(t.file));const a=(0,s.lazy)((()=>(0,h.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await a())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await a())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(n.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!i||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(n.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},70854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryUidStore=t.LibraryUIDStore=t.SystemUIDStore=t.UIDStore=t.mkuid=void 0;const r=i(19851),n=i(41400),s=i(55835),o=i(92782),a=i(37805),l=i(46292),u=i(34102),c=i(55222),d=i(28874),f=i(87128),h=i(95696);function m(){return(0,o.safeRandomUid)({radix:c.TokenRadix,chars:24,splitEveryN:4})}t.mkuid=m;class p extends f.JsonFileStore{constructor(e,t){super(e.join("."+t+"-uid.json"),(()=>({uid:m(),version:a.version,type:this.type,createdAt:Date.now()})),(e=>e.hide())),this.rootDir=e,this.type=t,this.readUid_=(0,r.lazy)((async()=>(await this.read_())?.uid))}}function g(e=d.Settings.libraryDir.valueOrDefault){return(0,s.map)(h.PosixFile.forMaybe(e),(e=>new p(e,"library")))}t.UIDStore=p,t.SystemUIDStore=(0,r.lazy)((()=>(0,s.map)((0,l.configDir)(),(e=>new p(h.PosixFile.for(e),"system"))))),t.LibraryUIDStore=(0,r.lazy)(g),t.libraryUidStore=g,(0,n.later)((()=>{(0,u.ee)().on("clearCache",(()=>{t.SystemUIDStore.unset(),t.LibraryUIDStore.unset()})),d.Settings.libraryDir.watchLater((()=>t.LibraryUIDStore.unset()))}))},84258:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const o=s(i(51455)),a=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,a.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const r of(0,l.toA)(e))try{null!=r&&await o.unlink((0,c.toNativePath_)(r))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+r,{error:e})}}},5545:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const n=r(i(76760)),s=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,s.toS)(i.path??n.default.sep)}},70257:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),n=i(45255),s=i(17217);t.WipTimeoutMs=n.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const o=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(o,"")},t.isWip=function(e){return o.test((0,s.basename)(e)??"")}},58722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),n=i(22911);class s extends r.Writable{constructor(e){super(e),this.deferred=new n.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=s},73428:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const n=r(i(44652)),s=r(i(76760)),o=i(51926),a=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=s.default.dirname(e);await(0,c.mkdirp_)(i),await n.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function f(e,t){const i=s.default.dirname(e);(0,c.mkdirpSync_)(i),n.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,o.wrap)(t));await d(e,i)},t.writeFileSync_=f,t.writeTextSync_=function(e,...t){return f(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))}},13047:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const n=r(i(73024)),s=i(76760),o=i(46466),a=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),f=i(50213),h=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),v=(0,l.lazy)((()=>(0,f.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,i){const r=[],s=[n.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,a.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,a.createBrotliDecompress)().on("error",(e=>r.push(e)))),s.push(t),await(0,o.pipeline)(s),(0,u.isNotEmpty)(r))throw new h.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function b(e,t){const i=new y.WritableToBuffer;return await S(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function M(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,o.pipeline)(new g.ReadableBuffer(i),(0,a.createGzip)(),n.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void v().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=M,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await M(e,t)}catch(t){v().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},19652:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.externalDirectoryCheck=void 0;const o=i(51455),a=s(i(22915)),l=i(40958),u=i(82950),c=i(22573),d=i(45599),f=i(12168),h=i(50213),m=i(79960),p=i(32551),g=i(98314),y=(0,d.defer)((()=>(0,h.mkLogger)("health.externalDirectoryCheck")));t.externalDirectoryCheck=async function(){const e=(0,l.uniq)([(0,p.homeDir)(),a.getHomeFolder(),a.getPicturesFolder(),a.getVideosFolder(),a.getDesktopFolder(),await(0,m.defaultApplePhotosLibrary)()]).sort(),t=new Map,i=(0,l.uniq)(e.filter(c.notBlank)).sort();for(const e of i)try{await(0,o.readdir)(e,{withFileTypes:!0})}catch(i){if(["ENOTDIR","ENOENT"].includes(i?.code))continue;t.set(e,i)}const r=0===t.size?{level:"ok",msg:["Default media directories are OK","The following directories are readable:",(0,u.li)(i.map(u.tt))]}:{level:"warn",msg:["Error reading "+(0,f.plur)(t.size,"media directory")+":",(0,u.li)([...t.entries()].map((([e,t])=>(0,u.tt)(e)+":"+(0,g.errorToS)(t,{maxLen:80}))))]};return y().tap({msg:"externalDirectoryCheck",result:r})}},87408:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStatusSummary=void 0;const r=i(63870),n=i(18454),s=i(89035),o=i(82638);t.getStatusSummary=async function(e={}){return(0,o.summarizeHealthChecks)({healthChecks:[...n.HealthCheck.allCritical(),(0,s.memoryHealthCheck)()],errors:n.HealthCheck.lastErrors(),timeoutMs:(0,r.commandTimeoutMs)(),skipPending:!0,...e})}},18454:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c,d,f,h,m,p,g,y,v,w,S,b,P,M=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},_=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const E=i(19851),T=i(40958),x=i(76790),D=i(41400),k=i(50357),C=i(26905),O=i(50268),I=i(55835),F=i(68708),L=i(30976),A=i(51926),R=i(13538),N=i(42279),j=i(59455),B=i(54993),z=i(48884),V=i(89788),W=i(22454),U=i(50213),H=i(69591),q=i(22911),G=i(99331),$=i(5916),J=i(42638),K=i(77740),Z=i(98314),Y=i(70025),X=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),re=i(21525),ne=i(82638),se=(0,E.lazy)((()=>(0,U.mkLogger)("health.HealthCheck")));class oe{static traceLater_(e,t){const i=new q.Deferred(e);i.catch((t=>{M(this,n,"f",l).push(e+": failed: "+(0,Z.errorToS)(t)),this.onResultChange()})),M(this,n,"m",a).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return M(this,n,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){M(this,n,"f",l).push((0,A.isString)(e)?e:(0,Z.errorToS)(e)),this.onResultChange()}static lastErrors(){return M(this,n,"f",l).toA()}static addLoadingMsg(e){M(this,n,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,T.compact)((0,j.toA)(e)).map(B.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return se().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:M(this,n,"f",f).entriesByCountDesc()}),(0,I.map)((0,z.leastBy)(e,(e=>[M(this,n,"f",f).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=M(this,n,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,I.map)(e,(e=>M(this,n,"f",f).incr(e.msg))),se().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return X.Settings.skipHealthCheckIds.envValue=t,n.reset()}static findById(e){return M(this,n,"f",h).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,O.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=M(this,n,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=n.summary();if(e.pendingCount>0){const t=await Promise.all(n.testResultsCritical());e=n.summaryFromResults(t),se().info("awaitSettled(): summary result",{summary:e,results:t})}return se().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){n.summary.unset()}static reset(){if((0,G.ending)())se().warn("Rejecting reset() when ending()",(0,C.shortStack)());else{this.onResultChange(),M(this,n,"f",l).clear(),M(this,n,"f",d).clear(),M(this,n,"f",f).clear(),M(this,n,"f",c).clear(),this.summary.clear(),_(this,n,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new n(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return M(this,n,"f",h).push(i),this.all.unset(),i}constructor(e,t,i,s,a,l,u,c,d,f,h,m,b,P=Q.commandTimeoutMs){r.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=s,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=f,this.errorLinks=h,this.onReset=m,this.ttlMs=b,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),w.set(this,(0,E.lazy)((async()=>{await M(this,p,"f").prior(),(0,k.eql)(M(this,g,"f"),M(this,r,"m",v).call(this))||(this.onReset?.(),await this.refresh(),M(this,w,"f").unset())}))),this.refresh=(0,E.lazy)((()=>new q.Deferred("refresh").observe((async()=>{await M(this,p,"f").prior();const e=M(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,U.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[O.HealthCheckSections.ordinal(this.section),l??999,this.id],_(this,p,(0,$.lazyAsync)({desc:this.pendingMsg,later:()=>M(n,n,"f",o).enqueue({name:this.id,l:()=>M(this,r,"m",S).call(this,a)}),ttlMs:b}),"f"),this.isCritical&&M(this,p,"f").watchLater({onChange:n.onCriticalResult,onError:n.onCriticalResult});for(const e of this.settings)X.Settings[e].watchLater((()=>M(this,w,"f").call(this)))}isStale(){return M(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return M(this,p,"f").settledCount()}reset(){return M(this,p,"f").unset(),this.onReset?.(),_(this,g,{starting:!0},"f"),this}setTTL(e){M(this,p,"f").setTTL(e)}result(){return M(this,p,"f").call(this)}isSkipped(){return X.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return M(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return M(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??M(this,r,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function ae(e){if((0,T.isEmpty)(e))return{};const[t,i]=(0,z.partition)(e,(e=>"button"===e.type||"POST"===e.method)),r={};return(0,T.isNotEmpty)(i)&&(r.links=(0,T.uniqBy)(i)),(0,T.isNotEmpty)(t)&&(r.buttons=(0,T.uniqBy)(t)),r}t.HealthCheck=oe,n=oe,p=new WeakMap,g=new WeakMap,y=new WeakMap,w=new WeakMap,r=new WeakSet,a=function(){return(0,T.filterInPlace)(M(this,n,"f",s),(e=>!e.isPending)),M(this,n,"f",s)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=se().tap({level:"warn",msg:"#summary()",result:(0,ne.summarizeHealthChecksSync)({errors:M(this,n,"f",l),skipPending:M(this,n,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&_(this,n,!0,"f",u),i.state!==M(this,n,"f",c).last?.state&&M(this,n,"f",c).push({state:i.state,ts:Date.now()}),i},v=function(){return(0,F.fromEntries)(this.settings.map((e=>[e,X.Settings[e].valueOrDefault])))},S=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();se().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,C.shortStack)()}),_(this,g,M(this,r,"m",v).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,D.delay)((0,L.randomInt)(.3*i,.7*i)),this.isSkipped())return M(this,r,"m",b).call(this,{test:{level:"disabled",msg:["Disabled by "+X.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const n=await(0,R.thenOrTimeoutError)(e(),i);return M(this,r,"m",b).call(this,{test:n,elapsedMs:Date.now()-t})}catch(e){return M(this,r,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},b=function({test:e,src:t="#toResult",elapsedMs:i}){var r,s;const o=n.normalizeMsg(e.msg),a=e.level??((0,B.toS)(o).toLowerCase().includes("error")?"error":(0,B.toS)(o).toLowerCase().includes("warn")?"warn":"ok"),l=(0,T.compact)([...e?.links??("ok"===a||"pending"===a?this.okLinks:"warn"===a?this.warnLinks:"no-library"===a?this.noLibraryLinks:"error"===a?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:a,msg:o,elapsedMs:i,...ae(l)};return u.runCount=(_(this,y,(s=M(this,y,"f"),r=s++,s),"f"),r),(0,G.ending)()?u:this.logger.tap({level:re.HealthCheckLevelToLogLevel[a],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const n=(0,A.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,I.map)(e,Z.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,Y.isFatalError)(e)&&n.toLowerCase().includes("warn")?"warn":"error"),M(this,r,"m",b).call(this,{test:{msg:n,level:t},src:"#toErrorResult",elapsedMs:i})},s={value:[]},o={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},f={value:new W.CountingSet},h={value:[]},oe.all=(0,E.lazy)((()=>Object.freeze((0,x.sortBy)(M(n,n,"f",h),(e=>e.sortBy))))),oe.onCriticalResult=(0,H.debounce)((()=>{se().info("onCriticalResult()",n.summary.refresh())}),250),oe.summary=(0,E.lazy)((()=>M(n,n,"m",m).call(n))),oe.resetDebounced=(0,H.debounce)((()=>n.reset()),50)},85021:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckCommand=void 0,t.HealthCheckCommand="--health"},33866:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const r=i(82950),n=i(50268),s=i(459),o=i(23560),a=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,o.isPermaService)(t)&&(e===n.HealthCheckLevels.error||(0,o.isLibraryRequiredService)(t)&&e===n.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,a.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,r.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new s.UnreachableCaseError(e)}}},42495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const r=i(40958),n=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,r.compact)([(0,n.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},89035:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const n=r(i(48161)),s=i(19851),o=i(82950),a=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),f=i(23560),h=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:r}){return{level:i,msg:[e+" from "+(0,f.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,o.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(r,2)])]}}function g(){return n.default.totalmem()h.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:h.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(h.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*h.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:h.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:h.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,s.lazy)((()=>"ok"!==g().level),a.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:a.minuteMs,later:async()=>g()})))},82638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const r=i(40958),n=i(42659),s=i(45599),o=i(41400),a=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),f=i(23560),h=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,s.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function v({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:r}){const n=new Map;for(const e of t??[])n.set(e.id,e);if(null!=e)for await(const t of h.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),r))n.set(t.id,t);return[...n.values()]}t.summarizeHealthChecks=async function(e){return S({...e,healthCheckResults:await v(e)})};const w=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:f.serviceName.prior()??process.title}})));function S(e){const t=(0,r.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),s=i.length,o=i.map((e=>e.id)),c=t.length-s,d=0===s,f=(0,r.uniq)((0,r.compactBlanks)(e.errors));if(f.length>0)return{...w(),level:l.HealthCheckLevels.error,settled:d,pendingIds:o,pendingCount:s,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",f.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const n=t.filter((e=>e.level===i));if((0,r.isNotEmpty)(n)){const e=t.filter((e=>!n.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+n.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...w(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:o,pendingCount:s,settledCount:c,linkIds:n.map((e=>e.id)),ts:Date.now(),msg:(0,r.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,a.flatten)([...n,...e].map((e=>e.msg[0])))])},meta:{checks:n.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...w(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:o,pendingCount:s,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,n.fmtDateShort)(Date.now())]}})}(0,o.later)((()=>{m.Settings.libraryDir.watchLater((()=>w.unset()))})),t.summarizeHealthChecksSync=S},52086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},86580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const r=i(40958),n=i(33374),s=i(31586),o=i(21605),a=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,s.gt0)(e.width)&&(0,s.gt0)(e.height)?(0,s.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,n.dmegapixels)(e.dimensions):(0,s.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,s.lt)(e.width,t.width)&&(0,s.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,s.lte)(e?.width,t?.width)&&(0,s.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,s.lt)(e.width,t.width)||(0,s.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,r.compact)((0,a.toS)(e).split(/[x×]/).map((e=>(0,s.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,r=Math.round(Math.sqrt(t*i));return{width:r,height:Math.round(r/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const r=u(e,i);return null==r?[]:o.Rotations.filter((e=>u(c(t,e),i)===r))}},89782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const r=i(19851),n=i(31586),s=i(50213),o=i(56519),a=i(1078),l=i(5733),u=(0,r.lazy)((()=>(0,s.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,n.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,o.thenMap)((0,a.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},277:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const r=i(22573),n=i(41400),s=i(54993),o=i(19851),a=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),f=i(78330),h=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),v=(0,o.lazy)((()=>(0,a.mkLogger)("img.Heif")));function w(e){return(0,s.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function S(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,o.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,r.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){v().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,r.blank)(e))return void v().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=w(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,r.blank)(i)&&(0,l.hasApt)()){const t=await(0,f.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,r.blank)(i)&&(0,h.hasPacman)()&&(i=(await(0,h.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,r.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void v().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=w,t.isHeifSupported=S,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await S()?(0,g.heif2png_)(e):void v().throw("HEIF support is missing",{src:e.nativePath})},(0,n.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const r=i(19851),n=i(22573),s=i(42659),o=i(41400),a=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),f=i(28874),h=i(89782),m=i(13940),p=(0,r.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,n.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,r.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:f.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?s.minuteMs:void 0),e})),(0,o.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,h.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(f.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:f.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(a.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const r=i(22573),n=i(54993),s=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,r.blank)(e)&&s.test((0,n.toS)(e))}},13940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),n=i(19851),s=i(42659),o=i(59455),a=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),f=i(46199),h=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),v=i(55222),w=i(63870),S=(0,n.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,n.lazy)((()=>(b(),g.PosixFile.for((0,h.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const b=(0,n.lazy)((()=>{h.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const n=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const s=n.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,f.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await s.mkdirp_(),await s.utimes();const o=s.join(i+r);return S().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:o}),o}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,o.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+v.TokenRadix.randomChars(2),v.TokenRadix.randomChars(16)+(0,a.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*s.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const n=await P(e,t,i);return await n.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,w.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),n}catch(r){return S().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},2090:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const r=i(40958),n=i(33374),s=i(31586),o=i(34666),a=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,s.isNumber)(e)?e:((0,s.toGt0)(e.width)??0)/((0,s.toGt0)(e.height)??0),(e=>(0,a.leastBy)(t.StandardAspectRatios,(t=>{const r=Math.abs(e-t);return r>i?void 0:r}))??e))}function c(e,i,r=t.RatioEpsilon){return(0,o.lt)((0,s.absdiff)(u(e),u(i)),r)}function d(e,i){return(0,a.leastByCtx)(t.Ratios,(t=>{const r=Math.abs(t.i-e);return r[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,n.maybeDimSwap)(e.dimensions,e.rotation),(0,n.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,s.sigFigs)(e,3))}},34943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const r=i(19851),n=i(31586),s=i(80049),o=i(50213),a=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),f=(0,r.lazy)((()=>(0,o.mkLogger)("img.RawInfo"))),h=(0,r.lazy)((()=>new s.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:a.ShortCommandTimeoutMs})));async function m(e){return h().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,r,s,o]=e.split("\t"),a=(0,n.toGt0)(s),l=(0,n.toGt0)(o);return null==a||null==l?f().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):f().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:r,ImageSize:{width:a,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>h.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?h.prior()?.clear():h.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{f().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},5733:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const n=r(i(9288)),s=i(19851),o=i(41400),a=i(50213),l=i(28874),u=i(15674),c=(0,s.lazy)((()=>(0,a.mkLogger)("img.Sharp")));function d(e,t){return(0,n.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,s.lazy)((()=>{n.default.simd(l.Settings.enableSIMD.valueOrDefault),n.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),n.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,o.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},19769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const r=i(19851),n=i(40958),s=i(41400),o=i(50213),a=i(68852),l=i(98314),u=i(28874),c=(0,r.lazy)((()=>(0,o.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:f().test(t)||!d().test(t),meta:{err:e,allow:f().test(t),block:d().test(t),validationErrorAllowlist:f().source,validationErrorBlocklist:d().source}})};const d=(0,r.lazy)((()=>(0,a.orRegExpPatterns)((0,n.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),f=(0,r.lazy)((()=>(0,a.orRegExpPatterns)((0,n.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,s.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>f.unset()))}))},66106:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const r=i(19851),n=i(40958),s=i(38639),o=i(42659),a=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),f=i(7282),h=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),v=i(56038),w=i(31562),S=i(34102),b=i(88561),P=i(95696),M=i(17217),_=i(31843),E=i(70417),T=i(33847),x=i(28874),D=i(94678),k=i(43207),C=i(47783),O=i(16170),I=i(95141),F=i(1078),L=i(63870),A=i(89782),R=i(13940),N=i(34592),j=(0,r.lazy)((()=>(0,d.mkLogger)("img.Video")));function B(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function z(e){return(0,f.isProd)()&&(e=void 0),(0,s.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=z,t.isVideoSupported=(0,r.lazy)((async()=>{try{return!0===(await z())?.isSupportedVersion}catch(e){return j().warn("isVideoSupported",{error:e}),!1}})),(0,a.later)((()=>(0,S.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,_.lerp2d)(e,{x:76800,y:x.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:x.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,r.lazy)((()=>new b.FileCache({name:"img.videoFrame",timeoutMs:o.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,M.toNativePath_)(e))):void 0}async function U(e,t){const i=B("extractVideoFrame",e),r=P.PosixFile.for(e);if(!(0,s.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const n=await(0,R.cachedImageFile_)(r,"frame",".jpg");i.debug("extractVideoFrame("+n+")");const a=await r.mtimeMs();if(null==a)return i.throw("null mtime");const l=await(0,C.readRawTags)(r,!1);if(null==l)return i.throw("no tags");const u=(0,I.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,F.extractSizeInfoFromTags)(l,u)?.dimensions,d=await n.stat(),f=null==d?void 0:await(0,A.dimensions)(n);if(null!=d&&d.mtimeMs>a&&null!=f&&(null==c||f.height===c.height&&f.width===c.width))return i.debug("prior dest, "+n+" seems reasonable",{srcDim:c,destDim:f}),n.nativePath;const h=(0,k.extractDurationSec)(l),m=Math.min(h??0,x.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:h}),await n.applyIfEmpty_({fn_:async e=>{const t={src:r,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,w.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*o.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,C.deleteAllTags_)(e,e)},timeoutMs:(0,L.commandTimeoutMs)()}),n.nativePath}async function H(){return x.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function q(e){const t=B("needsTranscoding",e);if(!await H())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,C.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const r=i.MIMEType;if(!(0,O.isVideoMimeType)(r))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:r}});const s=(0,k.extractDurationSec)(i);if(!(0,c.gt)(s,x.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:s}});const o=(0,n.compactBlanks)([i.AudioFormat]),a=o.some((e=>(0,p.includesIgnoreCase)(x.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,n.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(x.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(x.Settings.doNotTranscodeMimeTypes.values,r);return t.tap({level:"info",msg:"result",result:!(a&&u&&d),meta:{mimetype:r,isSafeMimeType:d,audioCodecs:o,isSafeAudioCodec:a,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>U(e)}),t.__extractVideoFrame_=U,t.isVideoTranscodingSupported=H,t.needsTranscoding=q;const G=new g.TTLMap(o.hourMs);function $(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,r){if(!await H())return;const n=B("transcode",e);{!function(){for(const[e,t]of G.entries())t.isSettled&&G.delete(e)}();const t=G.get(e.nativePath)??G.get(i.nativePath);if(null!=t)return n.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await q(e))return void n.info("no transcoding needed");const s=await e.size();if(!(0,u.gt0)(s))return n.throw("source is empty or cannot read");const o=await(0,C.readTags)(e),a=(0,F.extractSizeInfoFromTags)(o),d=(0,k.extractDurationSec)(o);if(null==o||null==a||null==d)return n.throw("failed: missing video metadata",{sizeInfo:a,durationSec:d});{const e=G.get(i.nativePath);if(null!=e)return n.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const f=new y.Deferred("transcode "+e);G.set(e.nativePath,f),G.set(i.nativePath,f);const m=(0,u.toGt0)(o.VideoFrameRate)??(0,u.toGt0)(o.FrameRate)??30,p=Math.round(a.dimensions.width*a.dimensions.height*(0,E.max)([(0,u.toGt0)(o.FrameCount),(0,u.toGt0)(o.VideoFrameCount),m*d]));if(!0===r?.force)await i.unlink();else if(await async function(e,t){const i=await(0,C.readRawTags)(t),r=await(0,C.readRawTags)(e),n=(0,k.extractDurationSec)(r),s=(0,k.extractDurationSec)(i);return j().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(n,s,1.5),meta:{srcDurationSec:n,destDurationSec:s,src:e.nativePath,dest:t.nativePath}})}(e,i))return n.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const r=B("extractMaxBitrate",e),n=x.Settings.minVideoDimension.valueOrDefault,s=i.ImageWidth;if(null!=s&&!(0,u.gte)(s,n))return r.throw("invalid width: "+s,{ignorable:!0});const o=i.ImageHeight;if(null!=o&&!(0,u.gte)(o,n))return r.throw("invalid height: "+o,{ignorable:!0});const a=(0,D.extractBitrateKbps)(i)??x.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,h.mapGt0)(s,(e=>(0,h.mapGt0)(o,(i=>(0,u.clamp)(0,a,(0,t.bitrateKps)(e*i)))))),c={width:s,height:o,videoBitrateKbps:l};return r.debug("dim()",{src:e,result:c}),c}(e,o);return await f.observe((0,v.time)("video.transcode:"+e,(async()=>{const t=$(s,g.videoBitrateKbps,d);return await i.applyWip_({fn_:s=>async function(s){n.info("starting...",{destWip:s});const a=new T.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:s,fps:m,halt:r.halt,...g},f=x.Settings.transcodeMaxDim.valueOrDefault,h=(0,E.max)([o.dimensions.height,o.dimensions.width]);if((0,u.gt0)(f)&&(0,c.gt)(h,f)){const e=(0,l.fitInside)(o.dimensions,{width:f,height:f});null==e?n.warn("Cannot downsample transcoded video: fitInside() returned null",{input:o.dimensions,maxPixels:f}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),n.info("Downsampling transcoded video",{original:o.dimensions,output:e}))}const p=await a.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&n.throw("transcode failed with code "+p.code)}(s),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&n.info("transcode complete",{src:e,dest:i,elapsedMs:f.elapsedMs,pixels:p}),i},t.guessExpectedSize=$,t.validVideo_=async function(e){return null==await W(e)&&B("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const r=i(40958),n=i(22573),s=i(38639),o=i(42659),a=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),f=i(56519),h=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),v=i(84258),w=i(28874),S=i(76280),b=i(63870),P=i(19769),M=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function _(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:w.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=_;const E=/ffmpeg version n?(?\S+)/i,T=(0,u.lazy)((async()=>{const e=await _();if(null==e)return void M().info("failed to find ffmpeg in $PATH",{ffmpegPath:w.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,b.commandTimeoutMs)(),ignoreStderr:!0}),i=E.exec(t.result)?.[1];return M().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,S.semverSatisfies)(i,">=3.2")}}));function x(){T.unset(),t.ffmpegVersionDescription.unset()}function D(e){const t=e?.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault;return(0,n.blank)(t)||(0,s.isDisabled)(t)?[]:["-hwaccel",t]}function k(e){const t=[...w.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(w.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),r=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+r),t}function C(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function O(e){const t=w.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,f.thenMapOr)(T(),(e=>"version "+e),(()=>"(not found)")))),(0,a.later)((()=>{(0,g.ee)().on("clearCache",x),(0,g.ee)().on("clearToolCache",x)})),t.ffmpegVersion_=async function(){return await T.prior()??T.refresh()},t.isFFmpegSupported=async function(){return null!=await T()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,r.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:o.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,h.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*o.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=k,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,r.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...k(t),...O(t),...D(t),"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...C(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){M().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,v.unlink)(t.dest,"debug");const r=(0,p.errorToS)(i,{maxLen:1024});if(!(0,s.isDisabled)(t.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(r))return M().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return M().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await _(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},36192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const r=i(19851),n=i(84777),s=i(8103),o=i(43334),a=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,r.lazy)((async()=>o.isMac?(0,s.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,n.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(a.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},71706:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.j=void 0;const r=i(38522);t.j=function(e){return JSON.parse((0,r.brotliDecompressSync)(Buffer.from(e,"base64")).toString("utf8"))}},42042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEmail=void 0;const r=i(22573),n=i(28874),s=i(81674);t.getEmail=async function(){const e=n.Settings.email.value;if((0,r.notBlank)(e))return e;for(const e of await(0,s.m)())if((0,r.notBlank)(e.l?.sub))return e.l?.sub}},83950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.L=void 0;const r=i(79114),n=i(40958),s=i(42659),o=i(34666),a=i(48884),l=i(97352),u=i(81674),c=i(84194);t.L=class{static for(e){return new this(e.str,e.l,e.sids,e.src)}constructor(e,t,i,r){this.s=e,this._l=t,this._sids=i,this.meta={src:r}}get l(){return this._l}get ok(){if(null==this._l)return!1;const e=(0,a.intersection)(this._sids,this._l.uids),t=(0,n.uniq)(e.map(c.getScheme)),i=(0,n.compact)(t.map((e=>(0,c.prefix2scheme)(e)))),r=i.length>=this._l.mat,o=(0,l.within)(this._l.iat?.getTime(),this._l.exp?.getTime()+s.dayMs,Date.now());return this.meta[(0,u.k)().o]=o,this.meta[(0,u.k)().u]=r,this.meta[(0,u.k)().m]=i,o&&r}cmpVal(){return[this.ok,-(r.S.indexOf(this.l?.[(0,u.k)().T])??0),this.l?.exp?.getTime()??1,this.meta.matchedSchemes]}cmp(e){return(0,o.cmp)(this.cmpVal(),e.cmpVal())}}},81674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p=t.l=t.t=t.b=t.m=t.vok=t.v=t.v_=t.k=void 0;const r=i(76790),n=i(22573),s=i(38639),o=i(45599),a=i(41400),l=i(96249),u=i(55835),c=i(31586),d=i(51926),f=i(79114),h=i(23541),m=i(59455),p=i(54993),g=i(72993),y=i(19851),v=i(50213),w=i(56519),S=i(76596),b=i(46292),P=i(87290),M=i(77740),_=i(34102),E=i(83278),T=i(28874),x=i(37692),D=i(71706),k=i(83950),C=i(72042),O=i(33603),I=i(48132);t.k=(0,y.rolazy)((()=>(0,D.j)("G1UBABwHdkz4hUIkFCfPXW5LlfvrWKSr9W3AIyIhUiw68NDfvLLHVop/bGoNnRxQlnqi2TZp0IJaX+lUHBoi+vMy2LMNpHCv8xVkUGsmQsgB8ldHoDqJeUQzbdybwikWVRs2KSWKjE5LnuqhTNSp3gTLhNfE9EqBLeaXP+UM9YqTGSXcyrcL03rIPMDAVyJplSZC0xoUgguOYJKvrcYFbNArN7BrQsnnsJ4hMtcSxOTxxRdxzETtL93qa3vjDw==")));const F=(0,o.defer)((()=>(0,v.mkLogger)((0,t.k)().l)));async function L(e){const i=await(0,C.V)((0,d.ensurePrefix)((0,p.toS)(e).trim(),(0,t.k)().p)),r=(0,S.utcIsoToTs)(i[(0,t.k)().i]);if(null==r)throw new Error("bad "+(0,t.k)().i+": "+i[(0,t.k)().i]+" ("+e+")");const n=(0,S.utcIsoToTs)(i[(0,t.k)().r]);if(null==n)throw new Error("bad "+(0,t.k)().r+": "+i[(0,t.k)().r]+" ("+e+")");return(0,M.getDevEnvFlag)((0,t.k)().y)&&(i[(0,t.k)().t]=!0),i[(0,t.k)().a]=(0,c.toGte0)(i[(0,t.k)().a])??2,i[(0,t.k)().i]=new Date(r),i[(0,t.k)().r]=new Date(n),i[(0,t.k)().b]=(0,p.toS)(i.uids).split(","),i}async function A(e,i,r,s){try{return(0,n.blank)(e)||e===(0,t.k)().f?void 0:k.L.for({str:e,l:await L(e),sids:null!=s?s:await(0,O.sids)({timeoutMs:r}),src:i})}catch(i){return F().tap({msg:(0,t.k)().v,result:{s:e,ok:!1,meta:{err:i}}})}}async function R(e,t){const i=[],r=await(0,w.sortByAsync)({name:"rawLicenseFromDir("+e+")",arr:e?.childFiles(),f:e=>e.mtimeMs()});for(const e of r.reverse()){const r=await A((0,m.toA)(await e.readLines()).map((e=>e.trim())).join(""),e.nativePath,I.UserTimeoutMs,t);null!=r&&i.push(r)}return i}async function N(){const e=await(0,t.m)();return e[0]?.ok?e[0]:void 0}async function j(){return(await N())?.l?.[(0,t.k)().T]??(0,t.k)().f}t.v_=L,t.v=A,t.vok=async function(e,t,i){if((0,n.blank)(e))return;const r=await A(e,t,i);return(0,s.isTrue)(r?.ok)&&r instanceof k.L?r:void 0},t.m=(0,y.rolazy)((async()=>{if((0,M.getDevEnvFlag)((0,t.k)().x))return[];const e=await(0,O.sids)({timeoutMs:I.UserTimeoutMs}),i=(0,u.map)((0,b.configDir)(),(e=>E.BaseFile.for(e))),n=(s=(0,l.flatten)((await(0,w.someOrTimeout)([()=>function(e){return A(T.Settings[(0,t.k)().L].value,"Settings",I.UserTimeoutMs,e)}(e),()=>R(i?.join((0,t.k)().d),e),()=>R((0,P.libraryDataDirPosixFile)()?.join((0,t.k)().d),e),()=>R(i?.sibling((0,g.AppName)().toLowerCase()).join((0,t.k)().d),e)],{timeoutMs:I.UserTimeoutMs})).filter((e=>!(e instanceof Error)))),(0,r.sortBy)(s.filter((e=>null!=e&&((0,h.isError)(e)&&F().warn((0,t.k)().d+": ",e),null!=e&&!(0,h.isError)(e)&&null!=e?.l))),(e=>[!e.ok,f.S.indexOf(e.l?.[(0,t.k)().T])??f.S.length+1,-(e.l?.exp?.getTime()??1)])));var s;return F().tap({msg:(0,t.k)().d+"()",result:n})})),(0,a.later)((()=>{(0,_.ee)().on("clearCache",(()=>t.m.unset())),(0,_.ee)().on((0,t.k)().c,(()=>t.m.unset())),x.stateEvents.on((0,t.k)().c,(()=>t.m.unset()))})),t.b=N,t.t=j,t.l=async function(){try{return await j()===(0,t.k)().f}catch{return!0}},t.p=async function(){try{return await j()===(0,t.k)().g}catch{return!1}}},72042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.V=t.l=void 0;const r=i(91227),n=i(19851),s=i(22573),o=i(71706);t.l=(0,n.lazy)((()=>(0,o.j)("G54BgBwHzrkukKDR8Ar6KkW29gbXlfrqQX46gTu5Wfq6dELYTjfBokB0d5+E2SAINBtxlmPquWe3PMUoNgaJrD982QMslkNeZ4BEqcBbQT59DVl9RnoTNi50diuT7NQg0YHxkr8SwDwtmFUOf+LwNVDDnPXUrzTOU++M3b+lcyfr7PXZndKHzho8iztNkZgt+/19//aXe+gvmC0HIdnn64wdLeYeLM7S9jmjTp52SzFsvIVbd4D0+rdtdjiz6R4vc2cmY398kuXiKG7fNXWS/I93etxXiVNPd4RXJF+k6JnuMUKk03GWHQQ="))),t.V=function(e){const i=(0,r.decode)(e).payload;if(null==i)throw new Error("Missing payload");const n=(0,s.notBlankOr)(i.k,(0,t.l)().d),o=(0,t.l)().o.find((e=>e.k===n));if(null==o)throw new Error("Unknown key");return r.V2.verify(e,o)}},84194:function(e,t,i){"use strict";var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SchemeCounts=t.isValidUid=t.toUID=t.UidLength=t.prefix2scheme=t.sortUids=t.getScheme=t.S=void 0;const s=i(40958),o=i(76790),a=i(22573),l=i(45599),u=i(50989),c=i(54993),d=i(22454),f=i(19851),h=i(50213),m=i(37628),p=i(55222),g=i(71706),y=(0,l.defer)((()=>(0,g.j)("GyABAIzUYs0Z7mSuLfVL1SwGefr+3nCwyXBMg6nD0qduA8HycFjUGK1N/ikYqhiqYLGbs7oxTBbzRPxteP9gA3L9DS0EJ2BJ1pYNa/DtEE2aPI2o03hHx3k9MhdE7jAeRUvKQ6tY3Q1fcIPe8GBMZvOeKibTymyo3Cw/7Ua42DKPjpL3wxWv+7TCGA==")));function v(e){const i=e.split(":",1)[0];return t.S.has(i)?i:void 0}t.S=(0,u.strEnum)("cu","lc","lm","lp","lb","mp","ms","wm","cm","bm","nm","li","si","vl"),t.getScheme=v,t.sortUids=function(e){return(0,o.sortBy)((0,s.uniq)(e.filter(b)),(e=>[t.S.indexOf(v(e))??t.S.length+1,e]))},t.prefix2scheme=function(e){return y()[e]};const w=["uninitialized","b08dfa6083e7567a1921a715000001fb"];t.UidLength=15,t.toUID=function(e,i){try{const r=(0,c.toS)(i).replace(/[^a-z\d=/+]+/gi,"");return(0,a.blank)(r)||w.includes(r.toLowerCase())||null!=r.match(/^[\s0:_/-]*$/)?void 0:e+":"+(0,m.shortStringSha)(r,t.UidLength,p.Radix58)}catch(t){return void(0,h.mkLogger)("toUID").warn("failed",{pfx:e,err:t})}};const S=(0,l.defer)((()=>new RegExp(`^(?:${t.S.values.join("|")}):[0-9a-zA-Z]{${t.UidLength}}$`)));function b(e){return null!=e&&null!=S().exec(e)}t.isValidUid=b,t.SchemeCounts=class{constructor(e){r.set(this,new Set),this.schemeCounts=(0,f.lazy)((()=>{const e=new d.CountingSet;for(const t of n(this,r,"f")){const i=v(t);null!=i&&e.incr(i)}return e})),null!=e&&this.addUids(e)}get size(){return n(this,r,"f").size}addUids(e){for(const t of e)null==v(t)||n(this,r,"f").has(t)||(n(this,r,"f").add(t),this.schemeCounts.unset())}count(e){return this.schemeCounts().get(e)}},r=new WeakMap},33603:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearSids=t.addSids=t.sids=t.win_machineGuid_=t.readInfo=t.k=void 0;const r=i(40958),n=i(22573),s=i(42659),o=i(45599),a=i(96249),l=i(68708),u=i(51926),c=i(59455),d=i(54993),f=i(50213),h=i(7282),m=i(56519),p=i(84777),g=i(84542),y=i(19254),v=i(45879),w=i(70854),S=i(57902),b=i(72308),P=i(43334),M=i(24399),_=i(7014),E=i(30933),T=i(71706),x=i(84194);t.k=(0,o.defer)((()=>(0,T.j)("G9ABYIzDOIZ8NLQ4t7qW8tNrmrOzz+qFGfAxl8jW4E2tLxwWRZT5TueCnPcwgTzT1DN3veRB+e7EYGlYHg6nhjBDQv7zI6EcYWk35z6QuZC3Q0itjrLCbmgd0iED0BvGiYLBJwRU1O9/3Agbl8IfG6ITVFWDRwyTw3rbUMo/XMyAVW7R23mkwUx0l4/7iA13RV/nmPuJFKp5BvJW7SoXJZoWEfdSNYYhN5UCtkbC7O1AaPIbU3P6uRLmEyb4TaHWzFigvrlmZVUzzp9j/Mz55vqN88ewd1Nrfh7gkVRQ7TtB7Ztz3XJxYC3ogdJHg8HGsG4=")));const D=(0,o.defer)((()=>(0,f.mkLogger)((0,t.k)().n)));async function k(e=(0,t.k)().pc){if(P.isLinux)try{const t=await(0,y.fileGrep_)(e,/^\s*(?:hardware|revision|serial|model)\s*[:=]\s*[a-z\d]{6}.*$/i),i=(0,r.compactBlanks)((0,g.splitLines)(t).map((e=>e.replace(/\s+/g," ")))).sort();return i.some((e=>null!=e.match(/^serial/i)))?i:void 0}catch{return}}t.readInfo=k;const C=(0,o.defer)((()=>(0,m.thenMap)(k(),(e=>(0,x.toUID)(x.S.lc,e.join(",")))))),O=/o\.e\.m\./i;async function I(e){return(0,r.uniq)(await Promise.all((0,t.k)()[e].map((e=>(0,v.readFileMaybe)(e,S.LogLevels.trace))))).map(d.toS).filter((e=>(0,n.notBlank)(e)&&null==e.match(O)))}async function F(){return P.isLinux?(await I("lm")).map((e=>(0,x.toUID)(x.S.lm,e))):void 0}async function L(){return P.isLinux?(await I("lp")).map((e=>(0,x.toUID)(x.S.lp,e))):void 0}async function A(){return P.isLinux?(await I("lb")).map((e=>(0,x.toUID)(x.S.lb,e))):void 0}async function R(){if(P.isMac)try{return(0,l.entries)(await async function(){const e=await(0,p.stdout_)((0,t.k)().i,(0,t.k)().ia,{timeoutMs:5*s.secondMs}),i=e.match(/uuid" = "([a-z\d-]{12,})"/i)?.[1],r=e.match(/SerialNumber" = "([a-z\d-]{10,})"/i)?.[1];return{mp:i,ms:r}}()).map((([e,t])=>(0,x.toUID)(e,t)))}catch(e){return void D().warn((0,t.k)().i+" failed",e)}}async function N(){return(await M.PowerShell.instance().executeJson((0,t.k)().w))?.MachineGuid}async function j(){return P.isWin?(0,x.toUID)(x.S.wm,await N()):void 0}t.win_machineGuid_=N;const B=(0,o.defer)((()=>(0,x.toUID)(x.S.cm,(0,E.cpuInfo)()[0].model)));async function z(){return P.isLinux?(0,x.toUID)(x.S.bm,(0,r.compactBlanks)(await I("bm")).map((e=>e.trim())).join("\n")):[]}async function V(){return(0,x.toUID)(x.S.li,await((0,w.LibraryUIDStore)()?.readUid_()))}async function W(){return(0,x.toUID)(x.S.si,await((0,w.SystemUIDStore)()?.readUid_()))}function U(){return(0,b.networkMacAddresses)().map((e=>(0,x.toUID)(x.S.nm,e)))}async function H(){return(0,c.toA)(await(0,_.volumes)()).map((e=>(0,x.toUID)(x.S.vl,e.uuid)))}const q=new Set;t.sids=async function({timeoutMs:e}){const t=Date.now(),i=[B,C,R,V,W,z,F,L,A,j,U,H],r=(0,a.flatten)(await(0,m.someOrTimeout)(i,{timeoutMs:e})).filter(u.isString);for(const e of r)q.add(e);return D().tap({msg:"sids()",result:(0,x.sortUids)([...q,...r]),meta:{timeoutMs:e,elapsedMs:Date.now()-t}})},t.addSids=function(e){if((0,h.isTest)())for(const t of e)q.add(t)},t.clearSids=function(){(0,h.isTest)()&&q.clear()}},48132:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserTimeoutMs=void 0;const r=i(42659);t.UserTimeoutMs=7*r.secondMs},34474:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allRecentLogEntries=t.recentLogFiles=void 0;const r=i(40958),n=i(42659),s=i(41400),o=i(96249),a=i(68708),l=i(34666),u=i(20214),c=i(71371),d=i(50213),f=i(42638),h=i(31562),m=i(98314),p=i(89968),g=i(28874),y=i(4904),v=i(57902),w=i(89241),S=i(83954);function b(e=10*n.minuteMs){const t=Date.now()-e;return(0,u.thenMap)(p.DirectoryEntry.for(g.Settings.logDir.valueOrDefault),(e=>e.filterDescendantFiles((async e=>[".log",".log.gz"].includes(e.ext)&&(0,l.gte)(e.mtimeMs(),t)))))}t.recentLogFiles=b,t.allRecentLogEntries=async function(e=50){(0,S.writeRecentLogEntries)();const t=(0,a.fromEntries)(v.LogLevels.values.map((t=>[t,new c.BoundedGreatestSet(e,y.logEntrySorter)]))),i=Date.now()-n.hourMs,p=(0,d.mkLogger)("allRecentLogEntries()");return await(0,u.thenMap)(b(),(e=>(0,f.withBoundedConcurrency)({name:"allRecentLogEntries()",laters:e.map((e=>async()=>{try{const o=[],a=new w.LogReader(e,(e=>o.push(e)));for(await(0,h.untilTrue)((()=>a.ready()),{timeoutMs:10*n.secondMs});!a.complete()&&!a.hasErrors();){const e=a.shift();null==e?await(0,s.delay)(5):e.ts>i&&t[e.l]?.add(e)}(0,r.isNotEmpty)(o)&&(p.warn("Read error(s) for "+e,o),o.some((e=>"Z_BUF_ERROR"===e.code||(0,m.errorToS)(e).includes("unexpected end of file")))&&(0,l.lt)(e.mtimeMs(),Date.now()-n.minuteMs)&&(p.warn("Unlinking corrupt logfile "+e),await e.unlink_()))}catch(t){p.warn("Failed to read entries from "+e,t)}}))}))),(0,o.flatten)((0,a.values)(t).map((e=>e.vacuum()))).sort(((e,t)=>(0,l.cmp)(e.ts,t.ts)))}},49794:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),n=i(19851),s=i(40958),o=i(22573),a=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),f=i(66184),h=i(93475),m=(0,n.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,o.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,h.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,f.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,s.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),n=i(23560),s=i(66184),o=i(72210);class a{log(e,t,i,r){this.enabled(e,t)&&(0,o.pushLogEntries)({ts:Date.now(),l:e,from:(0,n.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=a,a.instance=(0,r.lazy)((()=>new a))},14593:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),n=i(22573),s=i(26905),o=i(55835),a=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),f=i(76740),h=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new f.Abortable,this.context=(0,n.toNotBlank)(e)??(0,s.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,h.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,a.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),n=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:n}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,o.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,a.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),n=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof n.LogWriter))}},28981:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),n=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new n.PlaintextLogFormatter))},31256:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(41400),a=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),f=i(23560),h=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,f.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,s.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,o.later)((()=>f.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,h.stripAnsiEsc)((0,n.uniq)((0,n.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,a.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,a.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){"use strict";var r,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const s=i(77030),o=i(19851),a=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),f=i(31586),h=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),v=i(31256),w=i(28538),S=(0,o.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),b=String.fromCharCode(0);t.logBroadcaster=(0,o.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,f.toInt)(t);return(0,a.blank)(e)||!(0,f.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&S().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),h.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,s.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{S().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){S().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),n(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,s){if(this.enabled(e,t))try{const o=this.socket;null==o?n(this,r,"f").call(this):o.write(this.logFormatter.format(e,t,i,s)+b)}catch(r){S().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:s,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),n=i(42659),s=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??s.Settings.logDir.valueOrDefault,(0,n.fmtIsoDate)(t??new Date))}},4904:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),n=i(31586),s=i(51926),o=i(57902);t.isLogEntry=function(e){return null!=e&&(0,n.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&o.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),n=i(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,n.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,n.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new s(n.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>n.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,n.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){"use strict";var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),f=i(28874),h=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=f.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,n.set(this,[]),s.set(this,(0,l.lazy)((()=>{a(this,n,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=h.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:a(this,n,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>a(this,s,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=a(this,r,"m",o).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=a(this,r,"m",o).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},n=new WeakMap,s=new WeakMap,r=new WeakSet,o=function(e){if(null==e||0===a(this,n,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return a(this,n,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),n=i(31586),s=i(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const o=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??o},t.levelGte=function(e,i){return(0,n.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const a=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return a.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),n=i(68708),s=i(20214),o=i(51926),a=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,f=4){if(null==i)return null;if(f<0)return"…";if((0,o.isString)(i)||Buffer.isBuffer(i))return(0,o.ellipsize)(i.toString(),256,32);if((0,a.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,f-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,f-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),f-1);if((0,s.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const a=(0,u.mapNullEntries)(i,((t,i)=>e(i,f-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,n.keys)(i),(0,n.keys)(a));return(0,r.isNotEmpty)(c)&&(a["…"]="omitted: "+(0,o.ellipsize)(c.join(", "),128,32)),a}return i}},89241:function(e,t,i){"use strict";var r,n,s,o,a,l,u=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogReader=void 0;const d=i(73024),f=i(38522),h=i(4001),m=i(14977),p=i(33456),g=i(92322),y=i(4904),v=i(98192);t.LogReader=class{constructor(e,t){if(r.add(this),this.f=e,this.start=Date.now(),this.lines=new g.SortedSet(y.logEntrySorter),n.set(this,!1),s.set(this,!1),o.set(this,!1),this.from=(0,h.stripCopySuffixFromName)(e.name),this.fileStream=(0,d.createReadStream)(e.nativePath,{autoClose:!0}),!(0,m.isExtOrCompressedExt)(e.ext,".log"))throw new Error(e+" is not a logfile");this.stream=(e.ext.toLowerCase().endsWith(".gz")?this.fileStream.pipe((0,f.createGunzip)()):e.ext.toLowerCase().endsWith(".br")?this.fileStream.pipe((0,f.createBrotliDecompress)()):this.fileStream).pipe(new p.LineReader).on("error",(e=>{t(e),u(this,o,!0,"f")})),this.stream.on("data",c(this,r,"m",a).bind(this)),this.stream.on("close",(()=>{this.fileStream.resume(),u(this,n,!0,"f")})),this.stream.on("end",(()=>{u(this,n,!0,"f")}))}toString(){return"LogReader("+this.f.nativePath+")"}status(){return{hasErrors:c(this,o,"f"),ended:c(this,n,"f"),destroyed:this.stream.destroyed,lines:this.lines.length,paused:c(this,s,"f")}}hasErrors(){return c(this,o,"f")}get ended(){return c(this,n,"f")}ready(){return this.ended||this.lines.length>32}complete(){return this.ended&&0===this.lines.length}peek(){return this.ready()?this.lines.at(0):void 0}shift(){const e=this.lines.shift();return null!=e&&c(this,r,"m",l).call(this),e}shiftLte(e){const t=this.lines.shiftLte(e);return t.length>0&&c(this,r,"m",l).call(this),t}},n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(e){if(null===e)u(this,n,!0,"f");else{const t=(0,v.chunkToLogEntry)(e);null!=t&&this.lines.add({...t,from:this.from}),this.lines.length>10240&&!c(this,s,"f")&&(this.fileStream.pause(),u(this,s,!0,"f"))}},l=function(){this.lines.length<1024&&c(this,s,"f")&&(this.fileStream.resume(),u(this,s,!1,"f"))}},24068:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),n=i(76760),s=i(1708),o=i(87997),a=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),f=i(34666),h=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),v=i(22277),w=i(25764),S=i(38836),b=i(99331),P=i(42638),M=i(76596),_=i(98314),E=i(89968),T=i(29882),x=i(28874),D=i(28981),k=i(20839),C=i(21727),O=i(66184),I=i(57902),F=i(72210),L=i(98192);function A(e){const t=(0,D.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=A;class R extends S.EndableWrapper{constructor(e=void 0,t=A){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,a.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,x.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,T.mkdirp_)(e),this.root=await E.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=n.sep+(0,p.serviceName)()+"-"+s.pid+"-",s.stdout.writableFinished||((0,F.setLogTailEnabled)(!0),this.flushTimeout=(0,o.setInterval)((()=>this.flush()),k.DefaultLogFlushMs/2),this.scanTimeout=(0,o.setInterval)((()=>this.scan()),u.minuteMs),s.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,F.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,b.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,O.ifLog)(I.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,n.join)(e,i))}))}catch(t){return void(0,O.ifLog)(I.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,_.errorToS)(t))))}}))}async scan(e=!1){if((0,b.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,h.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,M.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,b.ending)()||this.ended)return;const t=(0,C.datedLogDir)(this.root.nativePath);try{await(0,T.mkdirp_)(t),this.watchDir(t)}catch(e){(0,O.ifLog)(I.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,_.errorToS)(e))))}(0,b.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,F.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,o.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,o.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,F.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await E.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,f.gte)(r,i))return;await(0,h.thenMap)((0,L.readLogEntries)(e,{start:r,end:i}),(e=>(0,F.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,O.ifLog)(I.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,_.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,a.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),n=i(82328),s=i(28981),o=i(20839),a=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(a.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,n.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*o.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const f=d(i(73024)),h=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),v=i(31586),w=i(409),S=i(23560),b=i(81168),P=i(78406),M=i(25764),_=i(20197),E=i(14977),T=i(36868),x=i(28874),D=i(32105),k=i(20839),C=i(21727),O=i(66184),I=i(93475),F=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class L extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*k.DefaultLogFlushMs),rank:M.EndableRanks.logger,unref:!0,onEnd:()=>c(this,n,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,n.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:D.ConsoleLogger.instance(),flushEveryMs:k.DefaultLogFlushMs,processName:S.processName,logFilter:O.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",s).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const n={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(n.meta=(0,I.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(n)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,F.recentLogEntries)()),(0,F.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=L,n=new WeakMap,r=new WeakSet,s=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),n=e.splice(0,i);this._linesSinceRotate+=n.length,t.write(n.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},o=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},a=function(e){return t=>(c(this,r,"m",o).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,b.stripAnsiEsc)(this.logOpts.processName()),t=await(0,_.ensureNewNativePath_)({nativePath:(0,h.join)((0,C.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=f.default.createWriteStream(t).on("error",c(this,r,"m",a).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,T.endStream)(e.stream),x.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,E.gzip_)(e.nativePath))}catch(e){c(this,r,"m",o).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),n=i(40958),s=i(55835),o=i(68708),a=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,o.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,n.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),n=i(84542),s=i(4001),o=i(13047),a=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,a.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,s.stripCopySuffixFromName)(e.name),r=[],a=await(0,o.zcat)(e.nativePath,t);if(null!=a)for(const e of(0,n.splitLines)(a)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),n=i(76790),s=i(68708),o=i(89788),a=i(57902);t.SentLogLevels=(0,r.lazy)((()=>a.LogLevels.values.filter((e=>e!==a.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,s.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new o.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,s.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,s.values)(l()))e.push(...t.toA());return(0,n.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),n=i(41400),s=i(55835),o=i(37975),a=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),f=i(28874),h=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),v=i(66184),w=i(28538),S=i(24068),b=i(43705),P=i(51879);function M(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),_();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new b.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||f.Settings.logStdout.valueOrDefault||f.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,s.map)((0,y.logBroadcaster)(),(e=>i.push(e))),a.rootLoggers.set(i),f.Settings.tailLogs.valueOrDefault&&S.LogTail.instance()}function _(){const e=f.Settings.logColor.valueOrDefault;(0,o.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new h.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=M,t.setupLogFormatter=_,(0,n.later)((()=>{f.Settings.logStdout.watchLater(M),f.Settings.logDir.watchLater(M),f.Settings.tailLogs.watchLater(M),f.Settings.logColor.watchLater(_),f.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},83954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeRecentLogEntries=void 0;const r=i(89179);t.writeRecentLogEntries=function(){return(0,r.currentFileLogger)()?.writeRecentLogEntries()}},82647:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const o=i(57975),a=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),f=i(59455),h=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,h.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,o.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,f.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,f.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,r,"m",n).call(this,-1)}get p29(){return s(this,r,"m",n).call(this,-.5)}get p38(){return s(this,r,"m",n).call(this,-.25)}get p69(){return s(this,r,"m",n).call(this,.5)}get p84(){return s(this,r,"m",n).call(this,1)}get p98(){return s(this,r,"m",n).call(this,2)}get p99(){return s(this,r,"m",n).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,a.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,a.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,a.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,n=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),n=i(55835),s=i(31586),o=i(30976),a=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,s.clamp)(0,i,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,n.map2)(e,t,((e,t)=>(0,r.sum)((0,a.zip)(u(e,i),u(t,i)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,o.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),n=this.clampValue(e);let s=0;for(let e=0;eo?(s+=1,i[t]=o):r[t]=o}return s}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let n=0;n(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function f(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;is?(t+=1,n.min=s):n.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=f(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=f,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},31843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const r=i(76790);function n(e,t,i=.5){return(1-i)*e+i*t}t.lerp=n,t.lerp2d=function(e,...t){const i=(0,r.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[s,o]=(0,r.sortBy)(i,(e=>e.x)),a=o.x-s.x,l=(e-s.x)/a;return n(s.y,o.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},55222:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),n=i(22573),s=i(55835),o=i(32639),a=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,n.blank)(e))return;const t="-"===(e=(0,o.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),n=this.normalizeToken(t);return r.length>=i&&r===n}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const r=i(31586),n=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,r.toInt)(e)]??(0,n.toS)(e)}},17921:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),n=i(65713);function s(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=s,t.safeUUID=function(){return(0,n.decuss)(s)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const a=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),f=i(77377),h=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function v(e,t){let i=0,r=0;for(const n of e){if(null!=n){const e=t(n,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=v;class w{constructor(){r.set(this,0),n.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(o(this,n,null==s(this,n,"f")?e:s(this,n,"f")*s(this,r,"f")/(s(this,r,"f")+1)+e/(s(this,r,"f")+1),"f"),o(this,r,(t=s(this,r,"f"),++t),"f"))}get mean(){return s(this,n,"f")}}function S(e){const t=new w;for(const i of e)t.push(i);return t.mean}function b(e){const t=S(e);if(null==t)return;let i=0,r=0;for(const n of e)(0,u.isNumber)(n)&&(r++,i+=(n-t)*(n-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function M(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+o*(e-n)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=S(t);if(null!=i){const e=(t.length-1)/2,r=v(t,((t,r)=>(t-i)*(r-e))),n=v(t,(e=>(e-i)**2));return 0===n?0:r/n}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new h.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=M,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(M(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,a.isEmpty)(e)&&(0,a.isEmpty)(t)?0:(0,u.finiteOrElse)((0,f.intersection)(e,t).size/(0,f.union)(e,t).size,void 0)}},49076:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const n=r(i(48161)),s=i(19851),o=i(22573),a=i(41400),l=i(81168),u=i(28874);t.hostname=(0,s.lazy)((()=>u.Settings.hostname.value??n.default.hostname())),(0,a.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,o.blank)(e)&&!(0,o.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??n.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},43205:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemUserAgent=t.simpleUserAgent=t.userAgent=void 0;const r=i(72993),n=i(17344),s=i(96175),o=i(37805),a=i(81674),l=i(28874);function u(){return r.SimpleAppName+o.version}async function c(){return u()+" ("+(0,s.osFullName)()+") "+(0,n.EditionType)().toLowerCase()+"/"+await(0,a.t)()}t.userAgent=async function(){return l.Settings.allowUserAgent.valueOrDefault?c():u()},t.simpleUserAgent=u,t.systemUserAgent=c},72308:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLocalhost=t.isLoopback=t.myExternalIp4Addresses=t.myExternalIpAddresses=t.networkMacAddresses=t.myIpAddresses=void 0;const r=i(48161),n=i(19851),s=i(40958),o=i(22573),a=i(42659),l=i(96249),u=i(31586),c=i(68708),d=i(50213),f=i(81168);function h(){return(0,t.myIpAddresses)().filter((e=>!g(e)))}t.myIpAddresses=(0,n.lazy)((()=>(0,s.uniq)((0,s.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.address))))),a.minuteMs),t.networkMacAddresses=(0,n.lazy)((()=>(0,s.uniq)((0,s.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.mac)))).filter((e=>"00:00:00:00:00:00"!==e))),a.minuteMs),t.myExternalIpAddresses=h,t.myExternalIp4Addresses=function(){return h().filter((e=>!e.includes(":")))};const m=(0,n.lazy)((()=>(0,d.mkLogger)("net.ip"))),p=[/^(?:::ffff:)?127\.\d{1,3}.\d{1,3}.\d{1,3}$/i,/^::1$/];function g(e){return(0,o.notBlank)(e)&&(127===function(e){const t=e.split(".").map((e=>(0,u.toInt)(e)));return 4!==t.length||t.some((e=>null==e||!(0,u.within)(0,255,e)))?void 0:t}(e)?.[0]||p.some((t=>null!=t.exec(e))))}t.isLoopback=g,t.isLocalhost=function(e){return m().tap({msg:"isLocalhost",level:"info",result:!(0,o.blank)(e)&&((0,t.myIpAddresses)().includes(e)||(0,t.myIpAddresses)().includes((0,f.stripPrefix)(e,"::ffff:"))||g(e)),meta:{address:e}})}},96128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),n=i(19851),s=i(22573),o=i(42659),a=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),f=i(50213),h=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),v=i(34102),w=i(26293),S=new RegExp("^"+w.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==S.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const b=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=b.exec(e)}function M(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,h.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=M,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,s.blank)(e)){if(null!=M(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void _().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs});const _=(0,n.lazy)((()=>(0,f.mkLogger)("net.nslookup")));(0,a.later)((()=>(0,v.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=M(e)?r.promises.reverse(e):r.promises.resolve4(e),5*o.secondMs);if(t===c.Timeout)return _().info("nslookup("+e+"): timeout"),e;const i=t.find(s.notBlank);return null==i?(_().warn("No name found for "+e),e):i}catch(t){return _().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,s.blank)(e)&&!(0,s.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),n=i(42659),s=i(31586),o=i(97790),a=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),f=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*n.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:f.ShortCommandTimeoutMs,clearEveryMs:10*n.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,s.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,o.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,a.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:f.ShortCommandTimeoutMs,clearEveryMs:10*n.minuteMs})},78330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const r=i(40958),n=i(22573),s=i(45599),o=i(59455),a=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),f=i(63870),h=(0,s.defer)((()=>(0,a.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,o.toA)(await async function(e){if(!(0,l.hasApt)()||(0,n.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,f.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return h().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,r.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,n.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,f.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(h().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),n=i(38639),s=i(19851),o=i(59958),a=i(43334);t.isDocker=(0,s.lazy)((()=>a.isLinux&&((0,n.toBoolean)(process.env[o.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),n=i(19851),s=i(54993);t.isPacked=(0,n.lazy)((()=>!(0,s.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const r=i(45599),n=i(50213),s=i(84777),o=i(68284),a=i(63870),l=i(43334),u=(0,r.defer)((()=>(0,n.mkLogger)("platform.Pacman")));t.hasPacman=(0,r.defer)((()=>l.isLinux&&(0,o.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,s.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,a.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const n=r(i(48161)),s=r(i(1708)),o=i(22573),a=i(38639),l=i(59958),u=n.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,a.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,a.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,o.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===n.default.arch(),t.isArm=null!=/^arm\b/i.exec(n.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,o.notBlank)(s.default.env.APPIMAGE)||(0,o.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,o.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,a.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const n=r(i(73024)),s=i(19851),o=i(43334);function a(e="/proc/cpuinfo"){if(o.isWin||o.isMac)return!1;try{return null!=n.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=a,t.isRaspberryPi=(0,s.lazy)((()=>o.isLinux_arm&&a())),t.procDeviceModel=(0,s.lazy)((()=>{try{return o.isLinux?n.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},45643:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),n=i(59455),s=i(31562);t.existingPids=function(e){return(0,n.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){"use strict";var r,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),f=u(i(1708)),h=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(97790),w=i(59455),S=i(54993),b=i(54557),P=i(19851),M=i(50213),_=i(88158),E=i(409),T=i(78406),x=i(25764),D=i(99331),k=i(56519),C=i(46292),O=i(8769),I=i(83278),F=i(32144),L=i(29882),A=i(43334),R=i(24399),N=i(58261),j=(0,P.lazy)((()=>(0,M.mkLogger)("proc.Pids"))),B=10*p.secondMs;function z(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,F.isJsonExt)(t)&&(0,L.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))j().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,E.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{j().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??A.isWin,r=await this.pidfiles(),n=await this.pids(r??[]);if((0,h.isEmpty)(n))return j().info("killOldProcs(): no pidfiles"),[];const s=[],o=[],a=await(0,N.pidInfos)(n);if(null!=a){for(const n of r){const r=await n.readJson();if(null==r){j().warn("killOldProcs(): failed to read pidfile "+n.base),await n.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){j().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+n.base,{json:r,pid:l}),await n.unlink("debug");continue}const u=a.find((e=>e.pid===l));if(null==u||!z(r,u)){j().debug("killOldProcs(): pid no longer present: unlinking "+n.base,{json:r,pidEntry:u}),await n.unlink("debug"),s.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(j().info("killOldProcs(): killing",{reason:d,json:r}),o.push(W(l,i,!1)),s.push({...r,...u}))}return o.length>0&&await Promise.allSettled(o),s}(0,O.onError)("Pids.killOldProcs(): failed to get process information")}}),o.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const o=e.pid;if(!(0,y.gt0)(o))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(o)?(i&&a(this,n,"f").delete(l),a(this,n,"f").getOrSet(l,(async()=>{const i=a(this,r,"m",s).call(this,e.pid),n=(0,v.opt)((0,_.Try)((()=>(0,L.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),o=t.getTime(),l={...e,cmd:n,startTime:o};return await i.writeJson_(l),j().debug("addPid() wrote "+i,l),i}))):(a(this,n,"f").delete(l),void j().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==f.default.pid}))}async pids(e=this.pidfiles()){return(0,h.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=a(this,r,"m",s).call(this,e);return(0,k.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{j().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==a(this,o,"f")||a(this,o,"f").ended)&&l(this,o,new T.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:x.EndableRanks.first}),"f"),a(this,o,"f")}cancelInterval(){a(this,o,"f")?.end(),l(this,o,void 0,"f")}}t.Pids=U,n=new WeakMap,o=new WeakMap,r=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,C.configDir)(),(e=>new U(I.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const n=i(31421),s=i(48161),o=r(i(1708)),a=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),f=i(59455),h=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),v=i(84968),w=i(48963),S=i(56519),b=i(84777),P=i(8103),M=i(45879),_=i(43334),E=i(24399),T=i(45643),x=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function D(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function k(e){if(_.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,M.readFileMaybe)("/proc/"+i+"/stat")));return x().tap({msg:"pidInfoProc",result:(0,a.compact)(t)})}(e);const t=(0,T.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,_.isWin?F:N)).filter((e=>D(e)&&t.includes(e.pid)));return x().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=D,t.pidInfo=async function(e){return(0,S.thenMap)(k([e]),(t=>(0,f.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,a.isEmpty)(e)?[]:(0,S.thenMap)((0,T.existingPids)(e),(t=>{const i=[o.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=k;const C="Get-Process",O="| Select-Object -Property Id,ProcessName,StartTime";function I(e){return(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).join(",")}async function F(e){if(E.PowerShell.instance().ended)return R(e);const t=[C,"-Id",I(e),"-ErrorAction SilentlyContinue",O].join(" ");return(0,S.thenMap)(E.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const L={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},A=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,a.isNotEmpty)(e)){const i=(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",A.join(","));const i=await(0,b.stdoutResult_)((0,P.wmic)(),t,L),r=(0,d.onlyReqValued)((0,p.parseFixed)(A,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,h.toS)(e.CommandLine)}))));return r.find((e=>e.pid===o.default.pid))||r.push({pid:o.default.pid,start:new Date(v.StartTs),cmd:"node "+o.default.title}),r}async function N(e){return t=(await(0,b.stdoutResult_)("ps",["-p",I(e),"-wwwo","pid,lstart,command"],{...L,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,h.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const j=(0,g.lazy)((()=>{try{if(_.isLinux)return(0,c.toGt0)((0,n.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){x().warn("clk_tck failed",{error:e})}return 100})),B=(0,g.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),z=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=z.exec((0,h.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,n=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(n)?{pid:i,cmd:r,start:new Date(B()+n/j()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),n=i(22573),s=i(31586),o=i(29882),a=i(97352);t.progressEvtToS=function(e){const t=(0,n.blank)(e.path)?null:(0,o.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,s.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,n.notBlank)(e.op)&&(0,a.within)(0,100,e.pct)}},41944:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),n=i(42659),s=i(31586),o=i(12089),a=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new a.TTLMap(15*n.secondMs))),t.recentDone=(0,r.lazy)((()=>new a.TTLMap(2*n.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,s.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,o.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),n=i(31586),s=i(409),o=i(78406),a=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class f extends o.EndableInterval{constructor(e,t,i,n=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:n,rank:a.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=n,this.start=Date.now(),this.onInterval=(0,s.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,n.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,n.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=f},24399:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),n=i(19851),s=i(22573),o=i(42659),a=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),f=i(50213),h=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),v=i(99331),w=i(56519),S=i(31562),b=i(84777),P=i(34102),M=i(43334),_=i(28874),E=i(63870),T="{ready}",x=" | ConvertTo-Json -Compress";function D(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=D,(0,a.later)((()=>(0,P.ee)().on("clearCache",(()=>k.instance.prior()?.clearMockResults()))));class k extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",_.Settings.powerShellArgs.values),logger:()=>(0,f.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${T}"}`,...(0,s.mapNotBlankOr)(_.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:T,fail:"Error",exitCommand:"exit",maxProcs:_.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,E.commandTimeoutMs)(),maxIdleMsPerProcess:o.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),_.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(_.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,x),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,h.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,n)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,n)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,x),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+D(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=k,k.instance=(0,n.lazy)((()=>{if(!M.isWin)throw new Error("PowerShell isn't available on this platform");return new k})),t.checkPowerShell_=async function(){const e=k.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,E.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),n=i(38639),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toBoolean})}}t.BooleanSetting=o},90536:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),n=i(31586),s=i(97790),o=i(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=a},75164:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(97790),o=i(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(r.notBlank).flatMap(n.toInt).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,n.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=a},10546:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),n=i(22573),s=i(45599),o=i(50213),a=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,s.defer)((()=>(0,o.mkLogger)("settings.CronSetting")));function f(e){try{const t=(0,a.trimQuotes)(e);return void((0,n.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function h(e,t,i){try{return(0,n.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:f,...e})}cron(e){return h(this.name,this.value,e)??h(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),n=i(91655),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,n.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=o;class a extends s.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=a},9945:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toFloat})}}t.FloatSetting=o},74589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toInt})}}t.IntegerSetting=o},86941:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAndArchiveSystemSettingsDir_=t.mergeUserDataDirs_=void 0;const r=i(19851),n=i(59455),s=i(72993),o=i(46292),a=i(95696),l=i(50213),u=i(83179),c=i(28874),d=i(2858),f=i(84438),h=(0,r.lazy)((()=>(0,l.mkLogger)("settings.MergeConfigDirs")));async function m(e,t){let i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+e.baseWithGrandparent+" => "+t.baseWithGrandparent+")");const r=await e.resolve_(),s=await t.resolve_();if(null==r||null==s||s.nativePath===r.nativePath)return void i.info("no-op, missing or same directory",{priorResolvedConfigDir:r?.nativePath,currentResolvedConfigDir:s?.nativePath});if(i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+r.baseWithGrandparent+" => "+s.baseWithGrandparent+")"),!await r.isDirectory())return void i.info("no-op, prior directory doesn't exist");{const e=r.join(f.SettingsToml);if(await e.isNonEmptyFile()){const t=s.join(f.SettingsToml);await(0,d.readSystemSettings)(e),i.info("read prior settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.readSystemSettings)(t),i.info("read current settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.writeSystemSettings_)(t)}}{const e=r.join("licenses"),t=s.join("licenses");for(const r of(0,n.toA)(await e.childFiles())){const e=t.join(r.base);if(await e.notExists())try{await r.copyFile_(e),i.info("Copied license "+r.base)}catch(e){i.warn("Failed to copy license "+r.base,e)}}}const o=s.join("old");try{const e=await r.renameYMDHMS_({subdir:o.nativePath});i.info("merged and archived to "+e)}catch(e){i.warn("Failed to archive to "+o,e)}}t.mergeUserDataDirs_=async function(){const e=(0,o.configDir)();if(null==e)return;const t=a.PosixFile.for(e);for(const e of[t.join((0,s.AppName)()),t.join((0,s.AppName)().toLowerCase()),t.parent().join((0,s.AppName)().toLowerCase())])try{await m(e,t)}catch(i){h().error("Failed to merge "+e+" and "+t,i)}h().info("done")},t.mergeAndArchiveSystemSettingsDir_=m},4175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),n=i(22573),s=i(38639),o=i(42659),a=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),f=i(67958),h=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function v(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function w(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){M(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&v(),y("strictDeduping",e)&&w(),(y("optOut",e)||y("noNetwork",e))&&_()},t.handleDeprecatedSettings=async function(){if((0,s.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,n.blank)(m.Settings.assetPathnameFormat.value)&&(0,n.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*o.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=v,t.setStrictDeduping=w;const S=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],b={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function M(e){for(const t of S)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:b;for(const[e,i]of(0,a.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:h.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:f.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function _(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=M,t.disableExternalNetworkRequests=_},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),n=i(53265),s=i(87652);class o extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,n.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=o},23561:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:n.toFloat})}}t.OptionalFloatSetting=o},69005:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),n=i(31586),s=i(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:n.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=o},87652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class n extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=n},28283:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),n=i(83556);t.nameFromEnv=function(e){return(0,n.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,n.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){"use strict";var r,n,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const o=i(19851),a=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),f=i(55835),h=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),v=i(40583),w=i(81168),S=i(44198),b=i(96706),P=i(34102),M=i(28283),_=i(81075),E=i(98778),T=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,o.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,r,"m",n).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?s(this,r,"m",n).call(this,e??t)+": "+i:null==this.fromEnv(e)?s(this,r,"m",n).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,f.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,a.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,a.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,M.envFromName)(e),this._keys=(0,a.uniq)([...this._names.map(M.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return _.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,f.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,S.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&b.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,S.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&b.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,f.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],T.WrapComments);function i(e,i){(0,a.isEmpty)(i)||t.push(...(0,w.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],T.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,h.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,w.wrap)(["",e+": "+r],T.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,f.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,E.wrapTomlToLines)({lines:e,wrap:T.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,E.wrapTomlToLines)({lines:e,wrap:T.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,E.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,n=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),n=i(76760),s=i(19851),o=i(40958),a=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),f=i(50989),h=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),v=i(79840),w=i(7282),S=i(12801),b=i(4328),P=i(70488),M=i(84248),_=i(5531),E=i(99315),T=i(34365),x=i(34580),D=i(96706),k=i(50274),C=i(33866),O=i(52086),I=i(48584),F=i(45969),L=i(43334),A=i(24540),R=i(70379),N=i(71300),j=i(33209),B=i(48987),z=i(68268),V=i(61208),W=i(99023),U=i(30577),H=i(1485),q=i(19861),G=i(55111),$=i(30933),J=i(22859),K=i(71988),Z=i(38483),Y=i(90536),X=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),ne=i(9945),se=i(74589),oe=i(844),ae=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),fe=i(58305),he=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new ae.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new fe.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new fe.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Z.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new fe.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>q.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new fe.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>H.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new fe.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:H.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new fe.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>H.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new fe.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>L.isWin?"15m":"0"}),remoteFilesystemTypes:new fe.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new fe.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new fe.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Z.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,F.isDocker)()}),cspReportOnly:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Z.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!L.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>L.isMac?"100ms":L.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new ne.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new he.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new he.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:M.AutoVacuumModes,defaultValue:M.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new he.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:_.CheckpointTypes,defaultValue:_.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new he.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:T.SynchronousModes,defaultValue:T.SynchronousModes.NORMAL}),dbRepairMode:new he.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:E.RepairModes,defaultValue:E.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to apply a migration, vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 2 minutes should be very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"2m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Y.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Z.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Z.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,F.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:C.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new fe.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Z.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new fe.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new fe.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new fe.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>L.isLinux}),showFileInFolderCommand:new fe.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new fe.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new fe.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Z.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new he.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Z.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Z.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Z.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,x.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Z.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new fe.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Z.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Z.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new he.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,f.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,A.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Z.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Z.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new fe.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Z.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Z.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,$.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new he.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:k.SidecarExts,defaultValue:k.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new fe.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new he.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new ne.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new he.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Z.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Z.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,$.cpuCount)()>=4}),dcrawEmuArgs:new fe.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new fe.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new he.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:O.CropStrategies.attention,strEnum:O.CropStrategies}),videoFrameAtSec:new ne.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Z.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,o.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new fe.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new fe.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,h.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(L.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Y.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new fe.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>j.DefaultIncludedPreviewTags}),disableAllFilters:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Z.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*h.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*h.GB}),validateJpegImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new he.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:I.SharpFailOns.truncated,strEnum:I.SharpFailOns}),validateRawImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new fe.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>B.DefaultLensMakes}),extraDateTimeFormats:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new fe.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:oe.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new he.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new ne.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new he.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new he.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:z.KeywordReparentingStrategies.move,strEnum:z.KeywordReparentingStrategies}),rootTagAlbumsAliases:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new fe.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Z.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new fe.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new he.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new he.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,F.isDocker)()}),tagDisplayNameFSLabels:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new fe.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new fe.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function Se(e){const i=((0,l.blank)(e)?"":e).split(n.delimiter);return(0,F.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,o.uniq)(i).filter(l.notBlank).join(n.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,D.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,a.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),n=i(31586),s=i(7282),o=i(49776),a=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),f=i(96706),h=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),v=i(15674),w=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{w.Settings.configDir.opts.defaultValue=a.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=o.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,f.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(h.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,n.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(22573),a=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),f=i(57924),h=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),v=i(54993),w=i(50213),S=i(81168),b=i(83556),P=i(87290),M=i(98314),_=i(34102),E=i(83278),T=i(95696),x=i(60865),D=i(4175),k=i(83179),C=i(81075),O=i(28874),I=i(41692),F=i(84438),L=i(32707),A=i(6707),R=i(98778),N=i(55018),j=i(10357),B=(0,r.lazy)((()=>(0,w.mkLogger)("settings.SettingsIO")));function z(e){return(0,P.libraryDataDirPosixFile)(e)?.join(F.SettingsToml)}async function V(e=(0,L.systemSettingsFile)()){if(null!=e)return X(E.BaseFile.for(e))}async function W(){try{return(0,o.toNotBlank)((await(0,A.readTomlFile_)((0,L.systemSettingsFile)()))?.[O.Settings.libraryDir.name])}catch{return}}function U(e){return(0,A.readTomlFile_)(e).then((e=>e?.version),(()=>{}))}function H(){return U((0,L.systemSettingsFile)())}function q(e){return U(z(e))}function G(){t.libraryHasSettings.refresh()}function $(e){const t=z(e);return B().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:O.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}async function J(e,i){if(null==e)return void B().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),n=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...ie("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","This is the version of PhotoStructure that wrote this file--please don't edit the following line.")),r.push(...(0,R.stringifyToml)({version:(0,t.versionForSettings)()})),r.push("","");let n="";for(const e of i){const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==n&&(n=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,_.ee)().emitDebounced("settingsChanged")}(n,i),B().info("writeToml(): wrote settings",{dest:n,file:e,nonDefaults:(0,k.settingsToObj)(i),wip:r}),r){const t=await(0,A.readTomlFile_)(n),i=await(0,A.readTomlFile_)(e);(0,u.eql)(t,i)?(B().info("Equivalent contents",{dest:n,file:e,a:t,b:i}),await n.unlink()):(B().info("Archiving prior, different contents",{dest:n,file:e}),await e.renameYMDHMS_({subdir:"archive"}),await n.unwip_())}}async function K(e=(0,L.systemSettingsFile)()){const t=T.PosixFile.forMaybe(e);return null!=t&&await J(t,(0,O.persistedSystemSettings)()),t}function Z(e){return X(z(e))}async function Y(e){await(0,P.setupLibraryDataDir_)((0,o.firstNotBlank)(e,O.Settings.libraryDir.value));const i=z(e);return B().info("writeLibrarySettings()",{file:i}),null!=i&&(await J(i,(0,O.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function X(e){if(null==e)return[];const t=B().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await Q(e);return(0,n.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,M.errorToS)(e)),[]}}async function Q(e){const t=B().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,A.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const s=[],o=(0,n.compact)((0,p.entries)(r).map((([e,t])=>{if("version"===e)return;const i=(0,O.getSettingByNameOrKey)(e);if(null==i)s.push(`Failed to import "${e}"${(0,m.mapOr)((0,O.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;s.push(e)}})));return t.info("loaded",{settings:(0,k.settingsToObj)(o),warnings:(0,n.toNotEmpty)(s)}),await(0,D.handleDeprecatedSettings)(),(0,D.handleMetaSettings)(o),{settings:o,warnings:s}}t.librarySettingsFile=z,t.readSettings=(0,r.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await Z()}),a.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return O.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=H,t.librarySettingsVersion=q,t.maybeUpgradeSystemSettings=async function(){(0,t.versionForSettings)()!==await H()&&await K()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&(0,t.versionForSettings)()!==await q()&&await Y()},t.libraryHasSettings=(0,r.lazy)((()=>$())),t.libraryHasSettings.unset=()=>{B().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,_.ee)().on("clearCache",G),(0,_.ee)().on("settingsChanged",G),O.Settings.libraryDir.watchLater(G)})),t._libraryHasSettings=$,t.versionForSettings=(0,r.lazy)((()=>(0,x.baseVersion)())),t.writeSystemSettings_=K,t.writeAllSettings_=function(e){return J(T.PosixFile.for(e),(0,O.persistedSettings)())},t.readLibrarySettings=Z,t.writeLibrarySettings_=Y,t._readSettings=X,t.importFileSettings_=Q;const ee=(0,r.lazy)((()=>new Set([O.Settings.noNetwork,O.Settings.httpPort,O.Settings.license,O.Settings.logStdout,O.Settings.logLevel].map((e=>e.key)))));function te(){for(const e of(0,p.values)(O.Settings))ee().has(e.key)||e.unset();(0,_.ee)().emit("settingsChanged")}function ie(...e){return(0,d.flatten)(e.map((e=>(0,S.wrap)(e,j.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),O.Settings.libraryDir.unset(),await K()},t.clearSettings=te,t.nukeSettings=async function(){te(),await(T.PosixFile.forMaybe((0,L.systemSettingsFile)())?.unlink("trace")),await(T.PosixFile.forMaybe(z())?.unlink("trace")),(0,_.ee)().emit("clearCache"),I.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...ie("",`Welcome to PhotoStructure! These are the settings for version ${(0,x.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...ie("","The following settings categories are stored in the system settings.toml:","",...(0,s.sort)([...C.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,s.sort)([...C.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...ie("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...ie("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const s=`${e.key} or ${e.name}`,o={...e.addToJSON()};(0,n.mapNotEmpty)(e.altKeys,(e=>o.aliases=(0,f.orList)(e)));const a=(0,p.entries)(o).map((([e,t])=>`${(0,S.capitalize)((0,b.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,n.isNotEmpty)(a)&&a.push(""),i.push(...ie((0,g.padding)("-",s.length),s,(0,g.padding)("-",s.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...a,`${e.key}=${(0,h.stringify)((0,v.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),n=i(40958),s=i(22573),o=i(98553),a=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,o.stringify)(e)}t._join=c;function d(e){return(0,a.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,n.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,n.compactBlankish)(t.split(e));return[t]}}(e),n.compactBlankish)}t.splitStringArray=d;class f extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,n.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,n.isEmpty)(e)||(this.value=this.toValidValues((0,n.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,n.isEmpty)(this.values)}isNotEmpty(){return(0,n.isNotEmpty)(this.values)}toNotEmpty(){return(0,n.toNotEmpty)((0,n.compactBlanks)(this.values))}}t.StringArraySetting=f},57571:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class n extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=n},72564:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),n=i(98553),s=i(55835),o=i(58305);class a extends o.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,n.stringify)((0,r.uniq)(e)))),fromEnv:t=>{return i=t,n=e.strEnum,(0,r.compact)((0,o.splitStringArray)(i)?.map((e=>n.getCI(e))));var i,n},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=a},80372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),n=i(81168),s=i(83179);class o extends s.Setting{constructor(e){super({toEnv:a,fromEnv:a,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function a(e){return null==e?void 0:(0,n.trimQuotes)(e)}t.StringSetting=o},32707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),n=i(55835),s=i(46292),o=i(84438);t.systemSettingsFile=function(){return(0,n.map)((0,s.configDir)(),(e=>(0,r.join)(e,o.SettingsToml)))}},80496:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),n=i(44652),s=i(22573),o=i(76850),a=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),f=i(98778);function h(e){return t=(0,o.debom)(e),(0,s.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?h((0,n.readFileSync)(t)):void 0}catch(e){return void(0,a.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>h(await(0,n.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,n.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,f.stringifyToml)(t)))}},98778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),n=i(96249),s=i(98553),o=i(68708),a=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const n=e+" = "+(0,s.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[n]:(0,a.wrap)(n.split("\n"),i)}t.stringifyToml=function(e){return(0,n.flatten)((0,o.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,a.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},10357:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const r=i(54993),n=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=o(e[t]);if(null!=i)return i}};const s=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function o(e){const t=(0,n.extractFloat)(e);if(null==t)return;const i=(0,r.toS)(e).toLowerCase();for(const e of s)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),n=i(81168);t.bname=function(e,t=!0){let i=(0,n.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,n.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const r=i(77988),n=i(19851),s=i(40958),o=i(76790),a=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),f=i(31586),h=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),v=i(81168),w=i(76596),S=i(79842),b=i(66649),P=i(21330),M=i(98725),_=i(928),E=i(54261),T=i(89724),x=i(17415),D=i(88600),k=i(51275),C=i(29882),O=i(17217),I=i(68284),F=i(57902),L=i(28874),A=i(65162),R=i(71300),N=i(14036),j=i(61424),B=(0,n.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function z(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,h.isObject)(e)&&(0,a.notBlank)(e.nativePath)&&(0,S.isDated)(e.date)&&(0,a.notBlank)(e.src)}t.capturedAtSrcFromTags=z,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class U{static fromAssetFile(e){return(0,d.map)((0,T.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>U.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof U?e:W(e)?new U(e):void 0}constructor(e){var t;this.nativePath=(0,O.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,f.toGt0)(e.local)??(0,T.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,S.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(L.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,b.datedToMillis)(e.mtime)??(0,I.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:U.name,...(0,h.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,M.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,x.fmtOffsetMinutes)});return null==t?void 0:new U({...e,date:t})}spread(e){return new U({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,x.fmtOffsetMinutes)(this.offset)}get isFromTags(){return z(this.src)}get isInferred(){return!z(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,T.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,w.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,k.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,E.hasTime)(this.date)}hasMillis(){return(0,f.gt0)((0,_.getMillisecond)(this.date))}toMillis(){return(0,b.datedToMillis)(this.date)}get isValid(){return(0,D.isValidDate)(this.date)}get zoneName(){return(0,r.offsetMinutesToZoneName)(this.offset)??(0,k.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,x.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?L.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,S.datedToStartDateTime)(this.date)??(0,S.datedToDateTime)(this.date);if(null!=i)return{start:(0,T.datedToLocal)(i.minus(t)),end:(0,T.datedToLocal)(i.plus(t))};B().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:L.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),r=Math.max(t,e.fuzzyPrecisionMs());return B().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,S.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:r}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:r}})}}function H(e,t){if(null==e)return;const i=(0,s.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>U.for(e))));for(const r of t){let t=e[r],n=r;if((0,D.isValidDate)(t)){if((0,x.isValidZone)(e.tz)&&(!(0,k.hasZone)(t)||R.OverrideUTCZoneTags.includes(n))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,a.blank)(e.tzSource)?"":" from "+(0,v.stripPrefix)(e.tzSource,"from ");n+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,T.datedToLocalSec)(t),date:t,src:n,precisionMs:(0,S.datedToPrecisionMs)(t),rawValue:e[r]?.rawValue})}}const r=(0,p.leastBy)(i,(e=>(0,S.datedToStartTs)(e.date)));if(null==r)return;const n=i.filter((e=>(0,u.eql)(e.date,r.date)||e.precisionMs<=r.precisionMs&&(0,S.datedOverlap)({a:e.date,b:r.date,aPrecisionMs:e.precisionMs,bPrecisionMs:r.precisionMs}))),o=(0,p.leastBy)(n,(e=>[Math.floor(e.localSec/1e6),(0,k.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return B().debug("capturedAtFromTags()",{least:r,overlapsWithLeast:n,earliest:o}),o}function q(e,t){if(L.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,s.uniq)([(0,A.bname)(e,!0),(0,A.bname)(e,!1)])){const e=(0,M.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,S.datedToPrecisionMs)(e),l.secondMs])}}}function G(e){if(L.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,M.extractDateFromPath)(e.pathsForDateParsing)}}async function $(e){if(L.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=U,t.bestCapturedAt=function(e){const t=(0,o.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const r=await e.mtimeMs();function n(t,i){return W(i)?U.for(i):null!=i&&null!=i.date&&(0,D.isValidDate)(i.date)?U.for({nativePath:e.nativePath,date:i.date,local:(0,T.datedToLocal)(i.date),src:(0,v.uniqPath)([t,i.src]),mtime:r,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const s=function(e,t){return null==e||t||!L.Settings.usePathsToInferDates.valueOrDefault||!L.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,C.containedByNativePath)({ancestor:L.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),o=n("tags",H(t,L.Settings.capturedAtTags.values))??(i?void 0:n("siblings",await(0,j.inferCapturedAtFromSiblings)(e)))??n("tags",H(t,L.Settings.capturedAtTagsFallback.values))??(s?void 0:n("bname+stat",await(0,j.extractStatBname)(e)))??(s?void 0:n("path+stat",await(0,j.extractStatPathTime)(e)))??(i?void 0:n("siblings",await(0,j.inferCapturedAtFromSiblings)(e)))??(s?void 0:n("bname",q(e,t)))??(s?void 0:n("path",G(e)))??(L.Settings.useStatToInferDates.valueOrDefault?n("stat",await $(e)):void 0);return B().tap({level:F.LogLevels.debug,msg:"extractCapturedAt()",result:o})},t.capturedAtFromTags=function(e){return H(e,L.Settings.capturedAtTags.values)},t.capturedAtFromBasename=q,t.capturedAtFromPath=G,t.capturedAtFromStat=$},70379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const r=i(31586),n=i(97352),s=i(95696),o=i(47783),a=i(16170);function l(e){if(null!=e&&(0,a.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,r.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,n.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=s.PosixFile.for(e);return l(await(0,o.readRawTags)(t,!1))}},47783:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const n=i(77988),s=r(i(76760)),o=r(i(1708)),a=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),f=i(23838),h=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),v=i(12168),w=i(56038),S=i(4867),b=i(36557),P=i(98247),M=i(21330),_=i(98725),E=i(23467),T=i(88561),x=i(95696),D=i(17217),k=i(16287),C=i(50213),O=i(17921),I=i(7282),F=i(88158),L=i(23560),A=i(28874),R=i(12089),N=i(45255),j=i(81168),B=i(63870),z=i(15674),V=i(28544),W=i(43207),U=i(75767),H=i(12788),q=i(80495),G=i(14036),$=i(67083),J=i(3432),K=i(28630),Z=i(15912),Y=i(30748),X=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),re=i(61424),ne=i(8791),se=(0,a.lazy)((()=>(0,C.mkLogger)("exiftool.ExifTool")));let oe=!1;t.addInstanceIdsToTags=function(e){oe=e},t.setExifToolProcs=function(e){return A.Settings.exiftoolProcsPerChild.envValue=e,ue()};const ae=(0,a.lazy)((()=>new b.BatchClusterObserver("ExifTool",new n.ExifTool({useMWG:A.Settings.useMWG.valueOrDefault,backfillTimezones:A.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:A.Settings.defaultVideosToUTC.valueOrDefault,...(0,b.batchClusterOptions)((0,I.isTest)()?8:(0,L.isSyncService)()?A.Settings.exiftoolProcsPerChild.value??(0,z.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=ae();return e.ended?ae.refresh():e}function ue(e=!1){return(0,d.map)(ae.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,S.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(ae.prior(),(e=>e.ended?void 0:(0,S.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,B.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,a.lazy)((()=>new T.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,a.lazy)((()=>new T.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,h.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,D.toNativePath_)(e))}async function fe(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function he(e){const t=[];return A.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*v.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,j.includesIgnoreCase)(A.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return se().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const r=i??await(0,te.readMimeType)(e),n=await e.sidecar(),s=(0,X.isImageMimeType)(r)&&A.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,o=(0,X.isVideoMimeType)(r)&&A.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,a=A.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await n.exists(),l=s||o||a;return se().tap({msg:"writeTagDest()",result:l?n:e,meta:{src:e,tagName:t,mimetype:r,writeMetadataToSidecarsIfImage:s,writeMetadataToSidecarsIfVideo:o,writeMetadataToSidecarsIfSidecarExists:a}})}async function pe(e,i=!0){const r=x.PosixFile.for(e);if(r.isSidecar()&&(i=!1),!await r.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(r.nativePath),void se().debug("readRawTags("+r+"): invalid file, returning null.");const n=await(0,t._readRawTags)(r.nativePath);if(null==n||!i)return n;se().trace("readRawTags()",{pf:r,pickedFileTags:(0,h.pick)(n,"tz","tzSource",...A.Settings.capturedAtTags.values)});const s=[];for(const e of await r.jsonSidecars())s.push([e,(0,K.readJsonSidecar)(e,n.tz)]);for(const e of await r.existingExifSidecars())s.push([e,(0,t._readRawTags)(e.nativePath)]);const o={original:{},MIMEType:(0,u.mapNotBlank)(n.MIMEType,X.normalizeMimetype),...n},a=[];for(const[e,i]of s){if(null==i)continue;const r=await i;if(null==r)continue;const n=(0,h.omit)(r,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,h.values)(n))?((o.sidecars??(o.sidecars=[])).push(e.base),a.push(...(0,g.toA)(r.History)),(0,F.assignNullishFields)(o.original,(0,h.pick)(o,...(0,h.keys)(n))),(0,h.assignFields)(o,n),se().debug("readRawTags() sidecar had values",{sidecar:e.base})):se().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return o.inferred=(0,$.getInferredHistoricValues)(a,e),(0,F.assignNullishFields)(o,o.inferred),o.Rotation=(0,Q.orientationToRotation)(o.Rotation),se().debug("readRawTags() final",{pf:r,inferred:o.inferred,pickedResult:(0,h.pick)(o,"tz","tzSource",...A.Settings.capturedAtTags.values)}),o}async function ge(e,t){return null==t?void 0:(0,w.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,r=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,X.normalizeMimetype);if((0,u.blank)(r))return void se().debug("No mimetype for "+i);const s={...t.inferred??{},...t};if(s.inferred??(s.inferred={}),s.original??(s.original={}),A.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...A.Settings.capturedAtTags.values,...A.Settings.capturedAtTagsFallback.values]){const t=s[e];if((0,p.isString)(t)){const i=(0,_.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(se().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),s[e]=i)}}const a=!await(0,re.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,s,a);if(se().debug("parseTags()",{tzMeta:l,skipSiblingInference:a}),null!=l?.tz){const e=s.tzSource!==n.defaultVideosToUTC&&void 0;for(const t of[...A.Settings.capturedAtTags.values,...A.Settings.capturedAtTagsFallback.values]){const i=s[t];i instanceof n.ExifDateTime&&(s[t]=(0,M.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,h.assignUndefinedFields)(s.original,s,"tz","tzSource"),(0,h.assignFields)(s,l),(0,h.assignFields)(s.inferred,l)}const c=a?(0,Y.extractMakeAndModel)(s):await(0,re.inferMakeAndModel)(e,s);c.Make!==(0,Y.make)(s.Make)&&(s.original.Make=s.Make,s.inferred.Make=c.Make),c.Model!==(0,Y.model)(c.Make,s.Model)&&(s.original.Model=s.Model,s.inferred.Model=c.Model),!(0,u.blank)(A.Settings.defaultCopyright.valueOrDefault)&&(0,H.isExifUnset)(s.Copyright)&&(s.Copyright=A.Settings.defaultCopyright.valueOrDefault);const d=(0,Z.extractLensMakeModel)(s),f=await(0,V.extractCapturedAt)(e,s,a);if(null==f)return void se().info("No capturedAt for "+e);!a&&f.isInferred&&(s.inferred.capturedAt=f);const m=(0,q.extractExposureSettings)(s),g=await(0,ie.extractSizeInfoFromFile)(e,s);if(null==g)return void se().info("No size info for "+i);const y={...c,mimetype:r,capturedAt:f,exposureSettings:m,...(0,ne.extractTitleDescription)(s),...d,cameraId:(0,U.cameraIdFromTags)(s),imageId:(0,U.imageIdFromTags)(s),lensId:(0,U.lensIdFromLensInfo)({...d,...(0,h.pick)(s,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(s),tz:s.tz,rating:(0,ee.extractRating)(s)};(0,I.isTest)()&&(y.__parsedBy__=o.default.pid);const v={...s,...y};return se().debug("parsedTags",{nativePath:i,skipInference:a,...y,inferred:s.inferred,original:s.original,pickedResult:(0,h.pick)(v,"capturedAt","tz","tzSource","Make","Model")}),(0,h.definedValues)(v)}catch(e){return void se().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,h.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,h.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,E.eqlAsync)(e.sha(),t.sha())||await(0,E.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=x.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,D.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,D.toNativePath_)(e),["-"+t]);return(0,F.pluckCaseInsensitive)(i,t)}catch(e){return void se().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=fe,t.overwriteTags_=async function(e,t){try{await(0,w.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await he(e)),e.clearThisAndParent()}))}catch(i){se().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,w.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=he,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,w.time)("exiftool.writeTags:"+e,(async()=>{const r=new f.MultiMap;for(const[n,s]of(0,h.entries)(t)){const t=await me(e,n,i);r.add(t.nativePath,[n,s])}for(const[t,i]of r.entriesArray()){const r=x.PosixFile.for(t),n=(0,h.fromEntries)(i);se().info("writeTags()",{src:e,dest:t,t:n}),await le().write(r.nativePath,n,await he(r)),A.Settings.overwriteOriginal.valueOrDefault||await fe(r),r.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,k.nativePathIsFile)(e))return se().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);se().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...A.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,G.isVideoExt)(s.default.extname(e))?[]:["-fast"]],r=await(0,w.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{se().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==r)return;se().debug("_readRawTags()",{nativePath:e,pickedTags:(0,h.pick)(r,"tz","tzSource",...A.Settings.capturedAtTags.values)}),r.MIMEType=(0,u.mapNotBlank)(r.MIMEType,X.normalizeMimetype),r.GPSDateTime??(r.GPSDateTime=(0,P.concatDateTime)(r.GPSDateStamp,r.GPSTimeStamp));for(const e of(0,h.keys)(r)){const t=r[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete r[e])}const n=(0,l.compactBlanks)([r.Error,...r.errors??[],r.Warning].map(y.toS));return(0,l.isNotEmpty)(n)&&(r.problems=n),oe&&(r.__instance=(0,O.safeUUID)()),r}}),t.parseTags=ge},75767:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(98553),a=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),f=i(54993),h=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),v=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const w=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function S(e){const t=null==e?[]:e.filter((([,e])=>!(0,s.blank)(e)));return 0===t.length?void 0:(0,o.stringify)((0,u.fromEntries)(t))}function b(e){return(0,f.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new a.MultiMap,r=[];for(const o of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(n=e[o])||(0,s.blankish)(n)||(0,l.isNumber)(n)&&(0===n||1===n)||null!=t.zeroesRe.exec((0,f.toS)(n)))continue;const a=e[o],u=b(e[o]),c=(0,t.Tag2SynonymGroup)().get(o);if(null!=c){if(i.includes(c,a)||i.includes(c,u))continue;i.add(c,a)}r.push([o,(0,l.gt0)(a)?a:u])}var n;return S(r)}function M(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function _(e){if((0,s.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([M(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(M)):(0,u.compactBlankValues)(t)}function E({a:e,b:t,field:i,desc:r,parser:n}){const s=n(e[i]),o=n(t[i]),a=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==s||null==o||(0,l.approximates)(s,o,a)?void 0:"Different "+r+": "+e[i]+" ≠ "+t[i]}function T(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,s.blank)(e.lensMake)||(0,s.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,r.lazy)((()=>{const e=new Map;for(const t of w){const i=t[0];for(const r of t)e.set(r,i)}return e})),t.Tag2Synonyms=(0,r.lazy)((()=>{const e=new Map;for(const t of w)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=S,t.renderExifUidId=P,t.decodeExifUid=_,t.findInequalFields=function(e,i){const r=_(e),s=_(i);if(null==r||null==s||e===i)return;const o=(0,h.intersection)((0,u.keys)(r),(0,u.keys)(s)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of o){const t=r[e],i=s[e];if(b(t)!==b(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of w){const t=(0,u.pick)(r,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(s,...e);if((0,u.isEmptyObj)(i))continue;const o=(0,u.values)(t).map(f.toS),a=(0,u.values)(i).map(f.toS);if((0,n.includesAny)(o,a))continue;const l=(0,h.least)((0,u.keys)(t)),c=(0,h.least)((0,u.keys)(i));return{aKey:l,aValue:r[l],bKey:c,bValue:s[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>E({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>E({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>E({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>E({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return T({...(0,v.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=T,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const r=i(22573),n=i(54993),s=/undefined|null|none|n\/a|unknown/i;function o(e){return null==e||(0,r.blank)(e)||s.test((0,n.toS)(e))}t.isExifUnset=o,t.toExifDefined=function(e){return o(e)?void 0:e}},80495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const r=i(19851),n=i(22573),s=i(31586),o=i(68708),a=i(54993),l=i(50213),u=i(97352),c=(0,r.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,n.firstNotBlank)((0,a.toS)(e.ExposureTime),(0,a.toS)(e.ShutterSpeed),(0,a.toS)(e.ShutterSpeedValue),(0,a.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,o.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,s.gt0)(e))return e;const[t,i]=(0,a.toS)(e).split("/").map((e=>(0,s.toInt)(e)));return(0,s.gt0)(t)&&(0,s.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,s.toFloat)(e);return(0,s.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),n=i(40958),s=i(96249),o=i(23838),a=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),f=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const h=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,a.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,a.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,n.uniq)((0,s.flatten)((0,a.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,n.uniq)((0,s.flatten)((0,a.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return h()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new o.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:f.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:f.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:f.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:f.ExtTypes.Video},{exts:c.SidecarFiletypes,type:f.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:f.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:f.ExtTypes.Exif}])for(const t of(0,s.flatten)((0,a.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,f.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,f.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function v(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=v,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(f.ExtTypes.Sharp)||t.includes(f.ExtTypes.RawImage)?"image":t.includes(f.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return v(e,f.ExtTypes.RawImage)},t.isSharpExt=function(e){return v(e,f.ExtTypes.Sharp)},t.isVideoExt=function(e){return v(e,f.ExtTypes.Video)},t.isAssetFileExt=function(e){return v(e,f.ExtTypes.AssetFile)},t.isExifExt=function(e){return v(e,f.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return v(e,f.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return v(e,f.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=f.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return v(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const r=i(77988),n=i(19851),s=i(40958),o=i(76790),a=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),f=i(50989),h=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),v=i(50213),w=i(81168),S=i(66649),b=i(17415),P=i(29882),M=i(95696),_=i(17217),E=i(28874),T=i(47783);function x(e,t){return(0,d.entries)(t??{}).map((([t,i])=>D({action:e,key:t,value:i})))}function D({action:e,key:t,value:i,ts:n}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:r.ExifDateTime.fromMillis(n??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,f.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=x,t.mkHistoryRecord=D,t.InferAction="infer";const k=(0,n.lazy)((()=>(0,v.mkLogger)("tags.History")));function C(e,t){if(null==e||null==e.History||(0,h.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function O(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,a.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function I(e){if(null==e)return;const t={};for(const[i,r]of(0,d.entries)(e))(0,w.isFirstCharAZ)(i)&&(t[i]=r);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,b.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function F(e,i,r){if(null==e||(0,a.blank)(e))return void k().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const n=(0,_.toNativePath_)(e),o=await(0,T._readRawTags)(n),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!C(o,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...r??{}};if((0,s.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void k().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:r,tagsToWrite:c});k().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:r});const f=M.PosixFile.for(e);return await(0,T.overwriteTags_)(f,c),f.clearThisAndParent(),u}t.tagsContainHistory=C,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const n=(0,m.toA)(e);if((0,s.isEmpty)(n))return{};const l=(0,o.sortBy)(n.filter((e=>(0,w.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,S.datedToMillis)((0,a.mapNotBlank)(e.When,(e=>r.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,a.notBlank)(t)){const r=O(e);(0,a.blank)(r.nativePath)||(0,P.eqlNameWithoutExt)(r.nativePath,i)?u[t]=r:k().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=O,t.inferredToTags=I,t.ensureInferredHistoryRecords=async function(e,i,r){const n=x(t.Actions.infer,r),s=(E.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?I(r):void 0)??{};return E.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(s.Source=e.nativePath),k().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:n,additionalTags:s}),F(i,n,s)},t.ensureHistoryRecords=F},3432:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const n=r(i(53705)),s=i(77988),o=i(19851),a=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),f=i(17415),h=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),v=i(61424),w=(0,o.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function S(e,t,i){{const e=b(t);if(null!=e&&(0,f.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,f.isValidZone)(t.tz)||t.tzSource===s.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,a.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof s.ExifDateTime&&(0,f.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,v.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function b(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,n.default)(t,i),r=(0,f.normalizeZone)(e);return w().tap({msg:"zoneFromLatLon()",result:r,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,h.isValidDate)(i))for(const r of g.Settings.capturedAtTags.values){const n=(0,u.toDated)(t[r]);if(null==n||(0,h.isValidDate)(n))continue;const s=Math.round(15*i.diff(n,"minutes").as("minutes")/15),o=(0,f.normalizeZoneOffsetMinutes)(s),a=0===o?void 0:(0,f.normalizeZone)(o);if(null!=a)return w().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:a.name,tzSource:"infer:filename (diff with "+r+")"},meta:{dt:(0,c.datedToISO)(n),rawTzoffsetMinutes:s,normalizedOffsetMinutes:o}})}}t.maybeInferTimezone=async function(e,t,i){return w().tap({msg:"maybeInferTimezone()",result:await S(e,t,i)})},t.zoneFromLatLon=b,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const r=i(77988),n=i(40958),s=i(22573),o=i(38639),a=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),f=i(48884),h=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const n=(0,p.normalizeZone)(e?.formatted),s=r.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:n??t??r.UnsetZone});if(!0===s?.isValid)return s}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,s.toNotBlank)(e.title),Description:(0,s.toNotBlank)(e.description),GPSLatitude:(0,f.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,h.validLat)(e)?e:void 0)),GPSLongitude:(0,f.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,h.validLon)(e)?e:void 0)),GPSAltitude:(0,f.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,a.map)(e.favorited,o.isTrue),peopleNames:(0,n.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,n.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},15912:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(55835),a=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),f=i(28874),h=i(30748),m=(0,r.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,h.make)(e.LensMake),i=(0,h.make)(e.Make),r=[],a=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],S),u=(0,n.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:a,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&r.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==S(e))continue;(0,s.notBlank)(t)&&r.push({lensMake:t,lensModel:e,lensInfo:a});const o=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))o.includes(t)&&r.push({lensMake:i,lensModel:e,lensInfo:a});for(const i of(0,n.compactBlanks)([t,...f.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&r.push({lensMake:i,lensModel:e,lensInfo:a});o.startsWith("vr ")&&"Nikon"===i&&r.push({lensMake:"Nikon",lensModel:e,lensInfo:a})}for(const e of r){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=b(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,o.map)(e.lensInfo,b)}return(0,c.greatestBy)(r,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const v=/([\d. -]+)\s?mm\b/i,w=/\bf\/?([\d.\-]+)/i;function S(e){if((0,s.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=v.exec(e)?.[1].replace(/\s/g,""),i=w.exec(e)?.[1];return y(t)&&y(i)?b(`${t}mm f/${i}`):void 0}function b(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,o.mapOr)((0,a.toFloat)(e),(e=>String((0,a.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=S,t.cleanBogusPrecision=b,t.normalizeLensModel=function(e){return b(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const r=i(19851),n=i(22573),s=i(55835),o=i(68708),a=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function f(e,t,i=""){const r=e.replace(t,i);return r===e?e:f(r,t,i)}const h=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=h.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,r.lazy)((()=>new p)),y=/\bgopro\b/i;function v(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=f(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=v(e.Make)??S(e.Software)??S(e.CreatorTool)??function(e){return y.test((0,a.toS)(e.HandlerDescription))||y.test((0,a.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,o.compactValues)({Make:t,Model:i})??{}},t.make=v;const w={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function S(e){if(!(0,n.blank)(e))for(const[t,i]of(0,o.entries)(w))if(i.test(e))return t}t.makeFromSoftware=S;const b=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=b.exec(i);null!=e&&(i=e[1].trim())}const r=(0,s.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=r)return r[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,s.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=f(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},16170:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const r=i(22573),n=i(54993),s=i(2322),o=i(277),a=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function f(e){return(0,r.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function h(e){const t=(0,n.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,s.isChrome)(t)||(0,s.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,n.toS)(e))},t.isImageMimeType=function(e){return(0,n.toS)(e).startsWith("image/")},t.isVideoMimeType=f,t.normalizeMimetype=h,t.isSharpMimeType=function(e){return!(0,r.blank)(e)&&h(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,r.blank)(e)&&h(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,r.blank)(t)&&(f(t)?await(0,l.isVideoSupported)():(0,a.isHeifMimeType)(t)?await(0,o.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},95141:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const r=i(21605),n=i(54993),s=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,s.isVideoMimeType)(e.MIMEType)?(0,r.normalizeRotation)(e.Rotation):void 0)??a(e.Orientation)};const o=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function a(e){return(0,r.isRotation)(e)?e:null!=e?o.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,n.toS)(e).startsWith("Mirror")},t.orientationToRotation=a;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,r.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,r.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const r=i(55835),n=i(31586),s=i(28874);function o(e){const t=(0,n.toInt)(e);return null==t?void 0:(0,n.clamp)(-1,5,t)}function a(e){return o(e?.Rating)??(0,n.mapNumeric)((0,n.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,r.map)(e?.favorited,(e=>!0===e?s.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=o,t.extractRating=a,t.extractLiked=function(e){const t=a(e);return null==t?void 0:t>=s.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const r=i(19851),n=i(22573),s=i(55835),o=i(88561),a=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,r.lazy)((()=>new o.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,n.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,s.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,a.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),n=i(40958),s=i(22573),o=i(81168),a=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),f=i(14036);function h(e,t,{ignoreCase:i}){return i?(0,o.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const a=(0,u.isJsonExt)(i.ext),l=a||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(h(e.base,i.name,{ignoreCase:l}))return!0;if(h(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(h(e.name,t,{ignoreCase:l}))return!0}const m=a||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,n.uniq)([e.base,e.name,(0,f.stripExt)(e.base)]))for(const e of(0,n.uniq)([i.name,i.name,(0,f.stripExt)(i.name)]))if(h((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return a&&function(e,i){const r=(0,o.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function n(e){return(0,s.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const a=n(e.slice(r.length)),l=n(i.slice(r.length));return a&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,a.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,o.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const r=i(19851),n=i(22573),s=i(42659),o=i(33374),a=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),f=i(34943),h=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),v=(0,r.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),w=(0,r.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:s.minuteMs})));async function S(e,t){if(null==e)return;const i=null==t||(0,n.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const r=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return b(i,r,await(0,f.rawInfo)(e));const s=b(i,r);if(null!=s)return s;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await S(await(0,h.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function b(e,t,i){t??(t=(0,y.extractRotation)(e));const r=(0,a.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,o.isDimensions)(e)?e:void 0));if(null==r)return v().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:f.rawInfo,fileDimensions:r}});const n=(0,o.maybeDimSwap)(r,t);return v().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:n.height,ImageWidth:n.width,aspectRatio:(0,d.aspectRatio)(n),dimensions:n,rotation:t,fileDimensions:r,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:f.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return w().getOrSetAsync(i.nativePath,(()=>S(i,t)))},t.extractSizeInfoFromTags=b},61424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const r=i(77988),n=i(51168),s=i(19851),o=i(40958),a=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),f=i(48884),h=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),v=i(79842),w=i(21330),S=i(98725),b=i(51275),P=i(35280),M=i(19748),_=i(88561),E=i(95696),T=i(65238),x=i(17217),D=i(57902),k=i(28874),C=i(80496),O=i(65162),I=i(28544),F=i(47783),L=i(88840),A=i(30748),R=i(16170),N=(0,s.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),j=7;async function B(e){return k.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+k.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(k.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.auto&&await(0,T.isSlowDir)(e.nativePath)&&!await(0,T.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function z(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of r){const r=(0,A.extractMakeAndModel)(await(0,F.readRawTags)(t));if((0,h.definedAndNotEql)(r.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:r});else if((0,h.definedAndNotEql)(r.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:r});else if(null!=r.Make&&null!=r.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:D.LogLevels.info,result:r,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await B(e.parent()))return;const t=await W(e);return null!=t&&(0,w.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,w.toExifDateTime)(t.before.date,(0,b.getZoneName)(t.before.date)),(0,w.toExifDateTime)(t.after.date,(0,b.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,s.lazy)((()=>new _.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await q(e),i=await z(t?.younger),r=await z(t?.older);return null==i||null==r?void 0:{before:i,after:r,index:i.index,slots:i.index+r.index+1}}))}t.beforeAfterCapturedAt=W;const U=(0,M.extFilter)(L.ExtTypes.AssetFile);function H(e){return null==e?[]:(0,o.compact)((0,f.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function q(e,t=7,i=!0){if(!await B(e.parent()))return;const r=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(U(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==r)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const n=(0,a.sortBy)(r,(e=>(0,O.bname)(e))),s=(0,x.findFileIndex)(e,n);if(s<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),q(e,t,!1)):void 0;const l=k.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[n.slice(s-2*t,s),n.slice(s+1,s+1+2*t)],d=[],f=[];for(;(0,o.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,o.isNotEmpty)(c)&&f.length=l&&f.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:f},meta:{f:e}})}t.nearestSiblings=q,t.nearestSiblingTzOffset=async function(e){if(!await B(e.parent()))return;const t=H(await q(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,j);for(const t of e){const e=await(0,F.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==r.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,o.uniq)([(0,O.bname)(e,!0),(0,O.bname)(e,!1)]),i=(0,S.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const r=await e.stat();if(null!=r){for(const e of["birthtime","atime","mtime","ctime"])if((0,v.datedOverlap)({a:i,b:r[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:r}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:r}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,S.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const r=i[e];if(null!=r&&!0===(0,v.datedOverlap)({a:t,b:r}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:n.DateTime.fromJSDate(r)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(55835),a=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),f=i(81168);function h(e){return(0,u.toS)((0,a.isString)(e)?e:e?.name).normalize()}function m(e){return(0,r.compact)((0,l.toA)(e).map(h))}function p(e,i=t.TagSep){return m(e).map((e=>(0,a.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(s.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function v(e){return(0,s.blank)(e)?void 0:Array.isArray(e)?h((0,r.last)(e)):(0,r.last)(g(e))}function w(e,t){if((0,r.isEmpty)(e)||(0,r.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,f.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=h,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,r.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,r.uniqBy)((0,l.toA)(e),(e=>(0,r.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,r.compact)(t).map((e=>y(e))));return(0,r.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=v,t.leafIsExcluded=function(e,t){return(0,o.mapOr)(v(e),(e=>(0,f.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=w,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,n.sortBy)(e.filter(r.isNotEmpty),(e=>-e.length)))t.some((e=>w(i,e)))||t.push(i);return(0,n.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const r=i(40958),n=i(22573),s=i(68708),o=i(54993);t.extractTitleDescription=function(e){const t=(0,r.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,n.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const r of i){const i=(0,o.toS)(e[r]).trim();if((0,n.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,s.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(96249),a=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),f=i(7014),h=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),v=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function w(e){const t=await(0,f.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),h.URI.file(e)])}async function S(e){const t=await w(e);return(0,n.uniq)((0,o.flatten)(t.map(m.uriEncodingVariants)))}async function b(e,t){if((0,s.blank)(e))return;const i=function(e){try{return h.URI.isUri(e)?e:h.URI.parse(e,!0)}catch(t){return void v().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case a.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case a.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case a.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,s.blank)(e)?v().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??h.URI.file(e)},t.nativePath2uris=w,t.nativePath2uriVariants=S,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(b(e,t),S))),(0,n.uniq)(i)},t.uri2nativePath=b,t.uriExists=async function(e,t){const i=await b(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),n=i(57975),s=i(90595),o=i(22573),a=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),f=i(43334),h=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",v=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class w{static isUri(e){return e instanceof w||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,n,s=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,s),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=n??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!h.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,s))}get fsPath(){return E(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:n,fragment:s}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===n?n=this.query:null===n&&(n=g),void 0===s?s=this.fragment:null===s&&(s=g),t===this.scheme&&i===this.authority&&r===this.path&&n===this.query&&s===this.fragment?this:new b(t,i,r,n,s)}static parse(e,t=!1){const i=v.exec(e);if(!i)return new b(g,g,g,g,g);const r=i[2]||g,n=k(i[4]||g),s=(i[5]||g).split("/").map(k).join("/"),o="psfile"===r&&s.startsWith("//")?s.slice(1):s,a=(0,u.toURLSearchParams)(i[7]),l=k(i[9]||g);return new b(r,n,o,a,l,t)}static file(e){let t=g;if(f.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new b("file",t,e,g,g)}static from(e){return new b(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=f.isWin&&"file"===e.scheme?w.file(r.win32.join(E(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,a.map)(this.path,(e=>(0,d.findLast)(e.split(y),o.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return T(this,e)}toJSON(){return this}[n.inspect.custom](){return this.toString()}}t.URI=w;const S=f.isWinPortable?1:void 0;class b extends w{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=E(this,!1)),this._fsPath}toString(e=!1){return e?T(this,!0):(null==this._formatted&&(this._formatted=T(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=S),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,o.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function M(e,t){let i,r=-1;for(let n=0;n=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57||45===s||46===s||95===s||126===s||t&&47===s)-1!==r&&(i+=encodeURIComponent(e.substring(r,n)),r=-1),void 0!==i&&(i+=e.charAt(n));else{void 0===i&&(i=e.substr(0,n));const t=P[s];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,n)),r=-1),i+=t):-1===r&&(r=n)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function _(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,f.isWin&&(i=i.replace(/\//g,"\\")),i}function T(e,t){const i=t?_:M;let r="";const{scheme:n,query:s,fragment:a}=e;let{authority:l,path:u}=e;if(n&&(r+=n,r+=":"),(l||"file"===n)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,o.mapNotBlank)(s,(e=>r+="?"+e)),a&&(r+="#",r+=t?a:M(a,!1)),r}function x(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+x(e.substr(3)):e}}t.encodeURIComponentFast=M,t.uriToFsPath=E;const D=/(?:%[\dA-Z][\dA-Z])+/gi;function k(e){return e.startsWith("xn--")?(0,s.toUnicode)(e):e.match(D)?e.replace(D,(e=>x(e))):e}t.percentDecode=k,t.toURI=function(e){return w.isUri(e)?e:w.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),n=i(40958),s=i(50357),o=i(89937),a=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",o.PS_LOCAL_FILE_SCHEME,o.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,a.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const f=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function h(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&h(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return f().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,s.eql)(e,t)||m(e,t)||h(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,n.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),n=i(22573),s=i(51926),o=i(89937),a=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),f=i(85087);function h(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,n.blank)(e))return;if(null==(t=null!=t&&(0,a.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,n.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,s.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:o.PS_LOCAL_FILE_SCHEME,authority:(0,f.volsha)(t.uuid),path:u})},t.joinMountpoint=h,t.psfile2nativePath=async function(e,t){if(e.scheme!==o.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,n.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,s=(0,n.notBlank)(t)&&!t.includes(i);if(s&&!(0,n.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,f.volsha)(i.uuid)===e.authority)return h(i.mountpoint,e.path)}const a=await(0,c.bestVolumeForVolsha)(e.authority);return null!=a?h(a.mountpoint,e.path):s&&(0,n.notBlank)(t)?h(t,e.path):void 0}},5696:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),n=i(22573),s=i(51926),o=i(89937),a=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:o.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,n.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,n.blank)(t))return;const i=(0,r.uniq)([t,(0,a.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,s.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:o.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==o.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,a.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,s.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const o=s(i(76760)),a=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),f=i(16287),h=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,a.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,a.notBlank)(t.remoteHost)&&(0,a.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:o.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,a.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,a.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(o.sep)}`;const n=i.slice(1),s=await(0,p.volumes)();for(const t of(0,u.toA)(s))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,h.isEquivalentHost)(e.authority,t.remoteHost))return o.join(t.mountpoint,...n);return await(0,f.isReadableDirectory)(t)?o.join(t,...n):void 0}},85087:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),n=i(42659),s=i(9103),o=i(37628);t.volsha=(0,s.memoize)((e=>(0,r.mapNotBlank)(e,o.shortStringSha)),{maxSize:128,ttlMs:n.minuteMs})},60865:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),n=i(30577);t.channel=function(){return(0,n.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),n=i(22573),s=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function o(e){if(e instanceof r.SemVer)return e.version;const t=s.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=o,t.semverSatisfies=function(e,t){if((0,n.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const s=o(e);return null!=s&&(0,r.satisfies)(s,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},8540:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),n=i(9595),s=i(29882),o=i(43334),a=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([a.Settings.libraryDir.valueOrDefault,(0,n.originalsDir)(),...a.Settings.scanPaths.values]))if((!o.isPosix||!(0,s.pathIsRoot)(t))&&(0,s.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},1485:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),n=i(22573),s=i(59455),o=i(50213),a=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),f=i(69108),h=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.DfPosix"))),v=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,f.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function w(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),n=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),s=t&&(i||r||n);return y().tap({msg:"acceptPosixVolume()",result:!s,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:n}})}t.acceptPosixVolume=w,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,f.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,s.toA)(await v());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,n.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,h.isGioSupported)())for(const e of(0,s.toA)(await(0,h.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,a.assignMissingPrimitives)(i,e))}return t.filter(w)}},69108:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),f=i(63870),h=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,o.toInt)(e,{defaultValue:0})*a.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,n.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void h().info("parseDfVolume(): skipping (size is 0)",{vol:e});const n=m(e.Used)??0,s=m(e.Available)??0;if(0!==n||0!==s)return{filesystem:t,mountpoint:i,size:d.isMac?n+s:r,used:n,available:s};h().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:n,available:s})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,f.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,n.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,f.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,s.blank)(i))return h().warn("empty output",{localsOnly:e,paths:t}),[];h().debug("output",{localsOnly:e,paths:t,output:i});const o=p(i);return!0===e&&o.forEach((e=>e.remote=!1)),o},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(22573),a=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),f=i(59455),h=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),v=i(24399),w=i(28874),S=i(24541),b=i(60224),P=i(63870),M=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await F()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const _=/([a-z]+)(?::\\)?/i;function E(e){return e?.match(_)?.[1]?.toUpperCase()}function T(e){return(0,l.map)(E(e),(e=>e+":\\"))}function x(e){return`Get-PSDrive -PSProvider FileSystem ${(0,h.toS)(E(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function D(e){return null!=e&&!(0,o.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,o.notBlank)(e.DisplayRoot),...(0,l.map)((0,b.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function k(e){return`Get-Volume ${(0,h.toS)(E(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=T,t.getPsDriveCommand=x,t.getVolumeCommand=k,t.getLocalVolumesWin_=function(){return v.PowerShell.instance().executeJsonToA(k())};const C=/\{([-a-z\d]{7,})\}/i;function O(e,t){return e=e?.trim(),(0,o.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function I(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void M().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=T(e.DriveLetter);if(null==t)return void M().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,n.compact)([O(e.HealthStatus,"healthy"),O(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,o.notBlank)(e.DriveLetter)&&(0,o.blank)(i);return M().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(s=e.UniqueId,M().tap({msg:"uniqueId2uuid",result:(0,l.map)(C.exec((0,h.toS)(s)),(e=>e[1])),meta:{s}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var s}async function F(){const e=(0,n.uniq)((0,f.toA)(await(0,S.mountpointsWin)()).map(T)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(x(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,n.compact)((0,a.flatten)(t).map(D)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(k(e)).catch((t=>(M().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),o=(0,n.compact)((0,a.flatten)(r).map(I)),l=(0,n.uniq)([...i,...o].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,s.sort)((0,n.uniq)([...i,...o].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));M().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:o,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...o.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=I,t.volumeInfoWin=F},68884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(42659),a=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),f=i(45255),h=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),v=i(83278),w=i(8103),S=i(16287),b=i(45969),P=i(43334),M=i(69108),_=i(98770),E=i(44224),T=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,b.isDocker)()||(0,d.isBillingService)()||null==await(0,w.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,T.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const x=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?x().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,E.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),S.isReadableDirectory),(e=>e.map((e=>v.BaseFile.for(e).clear().childDirectories())))))}):x().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,n.isEmpty)(e)?[]:(x().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,T.mountpointsTtlMs)(),f:async e=>{const t=await(0,M.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void x().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await D(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,T.mountpointsTtlMs)()}))),(0,a.later)((()=>(0,_.setupVolumeTTL)(t.gioVolumes)));const D=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,T.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,s.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,h.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,h.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,h.stripPrefix)(e,"/"))).flatMap((e=>(0,h.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(s.notBlank).get()}}catch(t){return void x().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:f.ShortCommandTimeoutMs,clearEveryMs:10*o.minuteMs})},98770:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),n=i(5233),s=i(41400),o=i(56038),a=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function f(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,o.time)("volumes."+e,(()=>(0,n.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,a.isRetriableError)(e)&&!1!==(0,a.isIgnorableError)(e)})))),i);return(0,s.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&f(u)})),u},t.setupVolumeTTL=f},27461:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),n=i(40958),s=i(22573),o=i(31586),a=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),f=i(6012),h=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),v=i(98770),w=i(63870),S=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>S().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>S().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const s=(0,c.sortIgnoreCase)((0,n.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),o=[];for(const t of s){const n=e.find((e=>e.mountpoint===t)),s=i?.find((e=>e.mountpoint===t)),a={...n,...s},u=r?.find((e=>e.filesystem===a.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(a,u),null==a.size||null==a.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];S().info("backfilling mountpoint",{info:s,vol:n,df:e}),null!=e&&(0,l.assignMissingPrimitives)(a,e)}o.push(a)}return o};const b=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return b.exec(e)?.[1]?.split(".").map((e=>(0,o.toInt)(e)))})),M=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,o.gte)(t[0],2)&&(0,o.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,v.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await M()],{timeoutMs:(0,w.commandTimeoutMs)()}),t=(0,h.splitLines)(e).map((e=>(0,f.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,s.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,o.toInt)(e.fsused),r=(0,o.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return S().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,v.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,w.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,f.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,s.toNotBlank)(e.PARTLABEL)??(0,s.toNotBlank)(e.LABEL),uuid:(0,s.toNotBlank)(e.PARTUUID)??(0,s.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),n=i(19851),s=i(40958),o=i(22573),a=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),f=i(56519),h=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),v=(0,n.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,s.uniq)(e.map((e=>e.filesystem?.match(w)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),n=await(0,f.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,h.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of n)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,o.blank)(t.MountPoint)||(0,a.isTrue)(t.OSInternal)?v().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){v().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const w=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),n=i(40958),s=i(76790),o=i(42659),a=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),f=i(23560),h=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),v=i(84777),w=i(34330),S=i(8769),b=i(34102),P=i(17217),M=i(16287),_=i(43334),E=i(28874),T=i(8540),x=i(68884),D=i(44224),k=i(24541),C=i(69375),O=i(63870),I=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function F(){t.mountpoints.unset(),t.mountpoints_.unset()}function L(e=(0,O.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function A(){F()}t.localMountpointSetup=(0,r.lazy)((async()=>{E.Settings.libraryDir.watchLater(F),E.Settings.scanPaths.watchLater(F),(0,f.isSyncService)()&&E.Settings.scanAllDrives.valueOrDefault?(0,a.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(_.isMac&&(e.info("Setting up Mac diskutil activity watcher"),L((0,O.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),_.isLinux){const i=(0,D.maybeWatchProcMounts)();await(0,x.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),L((0,O.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),L((0,O.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),o.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=E.Settings.mountpoints.values;if((0,n.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",_.isWin?k.mountpointsWin:D.mountpointsPosix),h.ShortCommandTimeoutMs);if((0,n.isEmpty)(e))return I().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,s.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,O.commandTimeoutMs)(),f:async e=>!(!(0,T.mightBeAssetMountpoint)(e)&&(0,C.isExcludedMountpoint)(e)||E.Settings.validateMountpoints.valueOrDefault&&!await(0,M.isReadableDirectory)(e)&&(I().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,S.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(_.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return _.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,a.later)((()=>{(0,b.ee)().on("clearCache",(()=>{x.gioVolumes.unset(),F()})),E.Settings.mountpointsTtlMs.watch(L)}),(0,c.isTest)()?1:o.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>A(),minCallDelayMs:1.5*o.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:x.GioCommand,args:x.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(x.gioVolumes.unset(),A()),minCallDelayMs:h.ShortCommandTimeoutMs})})));const N=(0,r.lazy)((async()=>{if(!_.isLinux)return!1;try{return 0===(await(0,v.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,O.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>A(),minCallDelayMs:h.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),n=i(40958),s=i(42659),o=i(48884),a=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),f=i(73787),h=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),v=i(28874),w=i(69108),S=i(68884),b=i(59107),P=i(69375),M=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await x()??await(0,c.thenMap)((0,w.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,S.isGioSupported)())try{await(0,c.thenMap)((0,S.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){M().warn("Failed to fetch gio volumes",e)}return e};const _="/proc/mounts";function E(e){return!v.Settings.excludedFilesystemTypes.has(e)}function T(e){return!(0,P.isExcludedMountpoint)(e)&&(!v.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function x(e=_,t=E,i=T){if(y.isLinux)try{const r=await(0,h.readLines_)(e),s=(0,n.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,o.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),a=await(0,c.filterAsync)({name:"mountpoints filter",arr:s,f:async([e,r])=>{const n=t(e),s=await i(r);return M().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:n&&s,meta:{fs:e,mp:r,fsOK:n,mpOK:s}})}});return M().tap({msg:"readProcMounts()",result:a.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void M().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=E,t.readProcMounts=x,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(_)?new f.FileWatcher(_,{recursive:!1,persistent:!1},(()=>{M().info("detected change in "+_),(0,d.setUnrefTimeout)((()=>b.mountpoints.refresh()),s.secondMs)})):void 0))},24541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),n=i(42659),s=i(13538),o=i(50213),a=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),f=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsWin")));async function h(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,s.thenOrTimeoutError)(h(),a.ShortCommandTimeoutMs)}catch(e){return f().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=h;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*n.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),n=i(22573),s=i(50213),o=i(9103),a=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,n.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const f=u.isLinux||(0,a.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,h=u.isLinux||(0,a.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,a.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,a.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,n.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===f?.test(e)?"LinuxDevMapperRE":!0===h?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,o.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),n=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,s=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function o(e){if((0,r.blank)(e))return;const i=n.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(s,""),remoteShare:i.remoteShare};const o=t.nfsRe.exec(e);if(null!=o){const e=o[1],t=o[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=o(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=o},60224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),n=i(22573),s=i(42659),o=i(55835),a=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),f=i(81168),h=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),v=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await E()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,o.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const w=["LocalName","RemoteName","Status"],S=["NETUSE","get",w.join(",")],b=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function M(e){if(!(0,n.blank)(e))return(0,a.opt)(e).flatMap((e=>b.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,a.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,n.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,a.opt)(e.pathname).filter(n.notBlank).getOrElse((()=>"/"))}))))).get()}async function _(){const e=(0,p.wmic)(),t=await(0,h.stdout_)(e,S,{timeoutMs:15*s.secondMs}),i=(0,u.parseFixed)(w,t);return(0,r.compact)(i.map((e=>(0,o.map)(b.exec((0,l.toS)(e.RemoteName)),(t=>(0,o.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,f.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=M,t._netInfoWinWmic=_;const E=(0,v.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?_():(0,r.compact)(e.filter((e=>(0,n.notBlank)(e.LocalName))).map((e=>(0,o.map)(M(e.RemoteName),(({host:t,share:i})=>(0,o.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,f.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),n=i(12168),s=i(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=n.MiB/r.secondMs},86848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(38639),a=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),f=i(81168),h=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),v=i(95696),w=i(45969),S=i(28874),b=i(59107),P=i(63870),M=i(68995),_=(0,n.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),E=(0,n.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function T(e){return(0,o.isTrue)(e.ignorable)||(0,w.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function x(e){if((0,s.blank)(e))return;const t=(0,f.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function D(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=x(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function k(e){if(S.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of S.Settings.volumeUuidFilePaths.values){const i=v.PosixFile.for(e.mountpoint).join(t),r=await D(i).catch((e=>_().info("Failed to read "+i,{error:e})));if(null!=r)return _().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,M.volumeUuidSubpath)());if("/"===e.mountpoint)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(S.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(S.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,M.writeVolumeUuid)(e);if(!(0,s.blank)(t))return _().tap({msg:"readVolumeUUID(): wrote new "+(0,M.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return _().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,a.later)((()=>{(0,m.ee)().on("clearCache",(()=>E.clear())),b.mountpoints.watchLater((()=>E.clear()))})),t.addVolumeUUIDs=async function(e){await(0,h.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(T(e))return;if((0,o.isFalse)(e.ok))return;const t=await E().getOrSetAsync(e.mountpoint,(async()=>k(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>_().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=T,t.toVolumeUUID=x,t.readUuidFile_=D,t.readVolumeUUID=k},7014:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const n=r(i(48161)),s=r(i(76760)),o=i(19851),a=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),f=i(41400),h=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),v=i(59455),w=i(48884),S=i(50213),b=i(7282),P=i(23560),M=i(28850),_=i(45255),E=i(81168),T=i(56519),x=i(4867),D=i(49776),k=i(9595),C=i(77740),O=i(44198),I=i(96706),F=i(8769),L=i(57159),A=(i(34102),i(21144)),R=i(73209),N=i(29882),j=i(95696),B=i(17217),z=i(16287),V=i(49076),W=i(96128),U=i(45969),H=i(43334),q=i(28874),G=i(85087),$=i(50424),J=i(48165),K=i(98770),Z=i(27461),Y=i(66840),X=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,o.lazy)((()=>(0,S.mkLogger)("volumes.Volumes"))),ne=n.default.platform(),se=new Map,oe=new Map,ae=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,G.volsha)(t.uuid),(e=>oe.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,se),le((0,G.volsha)(e.uuid),e,ae),e}function ce(){return(0,a.compact)([j.PosixFile.forMaybe((0,D.cacheDir)())?.join("volumes"),j.PosixFile.forMaybe((0,k.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),oe))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),se.clear(),ae.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,T.mapAsync)({name:"readCachedVolumes",arr:(0,T.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,a.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,E.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function fe(e){if(null==e)return;const i=new h.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),n=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:r,os:ne}))),s=new Map;for(const e of n)for(const t of(0,a.compactBlanks)([(0,G.volsha)(e.uuid),(0,G.volsha)(e.mountpoint)]))s.set(t,e);const o=ce();for(const e of o)await(0,R.withLock_)({file:e,timeoutMs:_.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of s.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:o,vol_mountpoints:n.map((e=>e.mountpoint))}),i.resolve()}async function he(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,a.isNotEmpty)(e))return e;const i=(0,v.toA)(await(0,X.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,q.Settings.volumeMetadataTtlMs.valueOrDefault),n=0!==q.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),s=!(0,a.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:n,priorIsMissingMountpoints:s}),n||s?void 0:e}async function me(e,i){const r=(0,m.map)(e,B.toNativePath_);if((0,u.blank)(r))return;const n=await(0,A.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,a.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(n,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:n,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:n}})}async function pe(e,t,i){const r=i.filter((e=>(0,E.equalsIgnoreCase)(t,e.remoteShare)));if((0,a.isEmpty)(r))return;const n=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,E.equalsIgnoreCase)(e,t.remoteHost)));if(null!=n)return n;const s=await(0,W.friendlyname)(e);return(0,T.asyncFind)(r,(async e=>(0,E.equalsIgnoreCase)(s,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,o.lazy)((()=>(0,P.isSyncService)()||(0,b.isTest)())),t.priorWriteVolumesToCacheLatch=(0,o.lazy)((()=>{})),t.writeVolumesToCache=fe,t.cachedVolumes=(0,o.lazy)((async()=>{const e=(0,a.compact)(await de()),t=(0,v.toA)(await(0,X.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,a.isNotEmpty)(i)?i:e.filter((e=>ne===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=he,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,x.thenOrTimeoutError)({p:he(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,x.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,a.isNotEmpty)(i))return i}catch(e){(0,F.onError)((0,L.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,M.shim0)({name:"fs.volumes",impl:async function(){if((0,b.isTest)()){const e=(0,p.toInt)((0,O.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,f.delay)(e,!1)),(0,C.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,x.thenOrTimeoutError)({p:H.isWin?(0,J.dfWin)():(0,$.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=q.Settings.validateMountpoints.valueOrDefault?(0,a.compact)(await(0,T.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,z.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,x.thenOrTimeoutError)({p:H.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,F.onError)("Failed to get remote volume info",{error:e})}));const i=(H.isWin?t:H.isMac?await(0,Y.addLocalVolumeInfoMac)(t):await(0,Z.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await fe(r),Object.freeze(r)}}),t.rootPath=(0,o.lazy)((()=>H.isWin?(0,g.opt)((0,I.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,E.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,a.isEmpty)(t)?void 0:(0,w.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,a.commonPrefixLength)(e.split(s.default.sep),t.split(s.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,v.toA)(await i.vols()).find((t=>(0,G.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,T.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return ae.get(e)??(await de())?.find((t=>(0,G.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,G.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),n=i(19851),s=i(22573),o=i(50213),a=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),f=(0,n.lazy)((()=>(0,o.mkLogger)("volumes.WriteVolumeUUID")));function h(){return(0,s.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=h,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,h());t=(0,s.toNotBlank)(t)??(0,c.safeUUID)();const n=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(n))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+a.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),f().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){f().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else f().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},51140:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpStatusIs=t.HttpStatus=void 0;const r=i(31586);t.HttpStatus=Object.freeze({OK:200,Accepted:202,MovedPermanently:301,Found:302,SeeOther:303,BadRequest:400,Unauthorized:401,Forbidden:403,NotFound:404,EnhanceYourCalm:420,InternalServerError:500,NotImplemented:501,ServiceUnavailable:503}),t.HttpStatusIs=Object.freeze({ok:e=>(0,r.within)(200,299,e),success:e=>(0,r.within)(200,299,e),redirect:e=>(0,r.within)(300,399,e),clientError:e=>(0,r.within)(400,499,e),serverError:e=>(0,r.within)(500,599,e),error:e=>(0,r.within)(400,599,e)})},21404:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToTagPath=void 0;const r=i(75020),n=i(40958),s=i(22573),o=i(89937),a=i(34238);t.uriToTagPath=function({uri:e,isFile:t}){if(null==e)return;const i=(0,a.toURI)(e),l=i.scheme===o.PS_LIBRARY_SCHEME?r.LibraryTagName:i.scheme===o.PS_LOCAL_FILE_SCHEME?i.authority:void 0;if((0,s.blank)(l))return;const u=i.path.split("/");return(0,n.compactBlanks)([r.TagRoots.fs,l,...t?u.slice(0,-1):u])}},98604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkAssetUrl=t.mkFolderUrl=t.myWebUrl=void 0;const r=i(19851),n=i(40958),s=i(31586),o=i(27776),a=i(49076),l=i(72308),u=i(28874),c=i(42231),d=i(45200),f=i(34238),h=i(21404);function m(e=u.Settings.httpPort.valueOrDefault){const t=[u.Settings.localhost.valueOrDefault];u.Settings.exposeNetworkWithoutAuth.valueOrDefault&&t.push(...(0,n.compactBlanks)([(0,l.myExternalIp4Addresses)()[0],(0,a.hostname)()]));const i=(0,f.toURI)("http://a");return t.map((t=>i.with({authority:t+":"+e})))}t.default=m,t.myWebUrl=(0,r.lazy)((()=>m()[0])),t.mkFolderUrl=async function(e){const i=await(0,d.nativePath2uri)(e),r=(0,h.uriToTagPath)({uri:i,isFile:!1});if((0,n.isEmpty)(r))return;const s=(0,o.mkTagUri)((0,c.tagPathToStringArray)(r));return(0,t.myWebUrl)()?.with(s)},t.mkAssetUrl=function(e){return(0,s.gt0)(e)?(0,t.myWebUrl)()?.with({path:"/asset/"+e}):void 0}},4988:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.httpRequest_=t.get_=t.HttpMethods=void 0;const o=s(i(37067)),a=s(i(44708)),l=i(22573),u=i(45599),c=i(50989),d=i(51926),f=i(50213),h=i(45255),m=i(22911),p=i(43205),g=i(34238),y=i(51140),v=(0,u.defer)((()=>(0,f.mkLogger)("net.get")));async function w(e,t){return S({...t,url:e})}async function S(e){const t=(0,g.toURI)(e.url),i=new m.Deferred("get "+t.toString()),r="http"===t.scheme?o.request:"https"===t.scheme?a.request:v().throw("unsupported scheme: "+t.scheme),n=e?.maxRedirects??8,s=e?.timeoutMs??h.ShortCommandTimeoutMs,u={...e?.headers,"user-agent":await(0,p.userAgent)()},c=e?.method??"GET",f=e?.agent??!1,S=r(t.toString(),{method:c,headers:u,timeout:s,agent:f},(e=>{let r="";e.setEncoding("utf8").on("data",(e=>r+=e.toString())).resume().on("end",(()=>{const o={url:(0,l.toNotBlank)(e.url)??t.toString(),contentType:e.headers["content-type"],statusCode:e.statusCode??-1,data:r};n>0&&y.HttpStatusIs.redirect(o.statusCode)&&!(0,l.blank)(e.headers.location)?(console.log("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:o.statusCode}),v().info("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:o.statusCode}),i.observe(w(e.headers.location,{timeoutMs:s,maxRedirects:n}))):(v().debug("complete",{...o,data:(0,d.ellipsize)(r,64),data_length:r.length}),i.resolve(o))}))})).on("error",(e=>i.reject(e)));return(0,l.blank)(e.body)||S.write(e.body),S.end(),i}t.HttpMethods=(0,c.strEnum)("GET","PUT","POST","PATCH","DELETE"),t.get_=w,t.httpRequest_=S},78932:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.httping=void 0;const r=i(19851),n=i(50213),s=i(34238),o=i(4988),a=(0,r.lazy)((()=>(0,n.mkLogger)("net.httping")));t.httping=function(e,t,i,r){return(0,o.get_)(s.URI.from({scheme:"http",authority:e+":"+t,path:i}),{timeoutMs:r}).then((e=>e.statusCode??-1),(e=>{a().warn("get() Failed",{error:e})}))}},65713:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),n=i(19851),s=i(23838),o=i(81168),a=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,n.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,n.lazy)((async()=>{const e=(0,a.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(h(e))}));const d=(0,n.lazy)((()=>({trie:new s.MultiMap,small:[]}))),f=3;function h(e){const t=new s.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=n)return n}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),n=i(96249),s=i(23838),o=i(59455),a=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=s.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,o.toA)(u[t])],s=c(e.substring(1));return(0,n.flatten)(s.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,a.stripDiacritics)(e).normalize())}},30933:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const n=r(i(48161)),s=i(19851),o=i(42659),a=i(31586),l=i(50213),u=i(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>n.default.cpus()),5*o.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=n.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,a.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const n=r(i(48161)),s=i(19851),o=i(31586),a=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),f=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=n.default.freemem(),t=n.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,o.gt0)(r))return f().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return f().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,a.fmtBytes)(i),freemem:(0,a.fmtBytes)(e),totalmem:(0,a.fmtBytes)(t)}})}))},69385:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOnResume=t._setPaused=t.resume=t.pause=t.isPaused=void 0;const r=i(34102),n=i(37692);let s=!1;function o(){return s}function a(e=!0){l(e),(0,n.writeStateFile)({paused:e})}function l(e){e!==s&&(s=e,(0,r.ee)().emit(e?"pause":"resume"))}t.isPaused=o,t.pause=a,t.resume=function(){return a(!1)},t._setPaused=l;const u=Promise.resolve();t.resolveOnResume=function(){return o()?new Promise((e=>{(0,r.ee)().once("resume",e)})):u}},15674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),n=i(42659),s=i(41400),o=i(31586),a=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),f=i(28874),h=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),h.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),f.Settings.cpuBusyPercent.watchLater(y),f.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,r.lazy)((()=>{const e=(0,o.clamp)(128,1024,f.Settings.maxMemoryMb.valueOrDefault)*a.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/a.MB),worstCaseMemPerProcMb:Math.ceil(e/a.MB)}})}),n.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=f.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,o.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,o.toGt0)(f.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,h.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(f.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,h.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=w();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const n=Math.min(e,v());return t=(0,o.clamp)(1,n,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,h.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,o.gt0)(f.Settings.maxConcurrentImports.valueOrDefault)?(0,o.clamp)(1,(0,t.maxCpus)(),f.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=f.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,o.clamp)(1,Math.min((0,t.maxCpus)(),f.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},37692:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addStateEvent=t.writeStateFile=t.readStateFile=t.stateEvents=t.StateEvents=t.StateEventFns=void 0;const n=r(i(78474)),s=i(40958),o=i(76790),a=i(42659),l=i(45599),u=i(41400),c=i(68708),d=i(50989),f=i(87290),h=i(73787),m=i(19851),p=i(50213),g=i(28874),y=i(69385),v=(0,l.defer)((()=>(0,p.mkLogger)("work.SharedState")));let w;t.StateEventFns={checkTasks(){},reloadLicenses(){}},t.StateEvents=(0,d.strEnum)(...(0,c.keys)(t.StateEventFns)),t.stateEvents=new n.default;let S=0;function b(){const e=(0,f.libraryDataDirPosixFile)()?.join("state.json"),t=Date.now(),i=t-S>a.minuteMs;i&&(S=t);const r=e?.existsSync({refresh:i})??!1;return r&&null!=e&&e.eql(w?.nativePath)||(w?.close(),w=void 0),r&&null!=e&&(w??(w=new h.FileWatcher(e.nativePath,{encoding:"utf8",persistent:!1,recursive:!1},P))),e}(0,u.later)((()=>{g.Settings.libraryDir.watchLater(P)}));const P=(0,m.lazy)((()=>t.readStateFile.refresh()),25);t.readStateFile=(0,m.lazy)((()=>{const e=b()?.readJsonSync();for(const i of e?.events??[])M.get(i.e)!==i.ts&&(v().info("emitting event "+i.e),t.stateEvents.emit(i.e),M.set(i.e,i.ts));return(0,y._setPaused)(e?.paused??!1),e}));const M=new Map;function _(e){const i=b();if(null==i)v().error("overwrite(): failed: no library directory");else{const r=i?.readJsonSync(),n=function(e){const t=Date.now()-10*a.minuteMs;return(0,s.uniqByLast)((0,o.sortBy)((e??[]).filter((e=>e.ts>t)),(e=>e.ts)),(e=>e.e))}([...r?.events??[],...e.events??[]]),l={paused:e.paused??r?.paused??g.Settings.startPaused.valueOrDefault,events:n};(0,y._setPaused)(l.paused),t.readStateFile.set(l),i.writeJsonSync(l)}}t.writeStateFile=_,t.addStateEvent=function(e){const t=Date.now();M.set(e,t),_({events:[{e,ts:t}]})}},22751:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),n=i(87997),s=i(19851),o=i(42659),a=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),f=i(976),h=i(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new r.Rate(5*o.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,s.lazy)((()=>(0,n.setInterval)(g,o.minuteMs).unref()));function g(){h.maxCpus.refresh(),h.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,f.rateStats)(e)),g()},(0,a.later)((()=>{(0,d.ee)().on("clearCache",(()=>{h.maxCpus.unset(),h.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),n=i(22573),s=i(50357),o=i(98553),a=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),f=i(59455),h=i(54993);function m(e){return null!=e&&(0,f.toA)(e).length>0}function p(e){return null==e||0===(0,f.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function v(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function S(e){return null==e?[]:v((0,f.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,o.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,a.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const n=[];if(et;s-=i)n.push(r(s));return n}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),n=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===n[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,s.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const n of t){const t=i(n);r.includes(t)||(e.push(n),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,f.toA)(e).map((e=>(0,h.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(n.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,o.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,s.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,o.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of S(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,o.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const n=new Set(i.map(r));return e.filter((e=>!n.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),n=i(36783),s=i(41801),o=i(98553),a=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,n.copyArrayTo)(h(e,t),e)}function f(e,t){const i=new Map;for(const r of e)(0,a.getOrSet)(i,(0,o.stringify)(t(r)),(()=>r));return h(i.values(),t)}function h(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=f,t.sortUniq=function(e){return f(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,n.copyArrayTo)(f(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=h,t.deepSortBy=function e(t,i){return h(t,i).map((t=>(0,s.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},5233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),n=i(31586),s=i(13538),o=i(41583);t.retryOnReject_=async function(e,t){const i=(0,n.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const a=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,o.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await a(l),u()}};return u()}},17586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const r=i(40958),n=i(22573),s=i(96249),o=i(55938),a=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,o.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,o.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,n.blank)(e)?"":"```"+(0,a.toS)(e)+"```"},t.b=function(e){return"**"+(0,a.toS)(e)+"**"},t.li=function(...e){return(0,r.compactBlankish)((0,s.flatten)(e)).map((e=>"- "+(0,a.toS)(e))).join("\n")}},22573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),n=i(42279),s=i(54993);function o(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function a(e){return!o(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,s.toS)(e);return a(i)?t(i):void 0}t.blank=o,t.notBlank=a,t.notBlankToS=function(e){return a(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,n.tot)(t);const i=(0,s.toS)(e).trim();return i.length>0?i:(0,n.tot)(t)},t.notBlankAnd=function(e,t){return!o(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{"use strict";function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),n=i(22573),s=i(30301),o=i(55835),a=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),f=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function h(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?f().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=h,t.fmtDateShort=m,t.splitHMS=function(e){return(0,o.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,a.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=h(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const n=Math.floor(e/t.minuteMs);e-=n*t.minuteMs;const s=Math.floor(e/t.secondMs),o=Math.floor(e-s*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(n)+":"+(0,l.pad2)(s)+(i.includeMs?"."+(0,l.pad3)(o):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),n=i(),s=i(),o=i(),a=i(),l=i();return new Date(t,l-1,a,o,s,n,r)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,i="ago"){return e<1e3?"just now":(i=(0,n.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const s=Math.floor(e/r.ms);e-=s*r.ms,s>0&&(r.ms>=t.dayMs?i:n).push(s+r.s)}return e>0&&n.push((0,a.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(n)?"":"T"+n.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,o.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),n=i(73872);function s(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function o(e,t,i,r){if(null==i||y(e)||y(t))return;let n=i.get(e);null!=n?n.set(t,r):(n=new WeakMap,n.set(t,r),i.set(e,n))}function a(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const n=l(e,t);return null!==n?n:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,h=s(e,t,u);if(null!==h)return h;const m=s(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return o(e,t,u,i),i;const n=l(e,t);if(null!==n)return n}const y=n(e);if(y!==n(t))return o(e,t,u,!1),!1;o(e,t,u,!0);const v=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return a(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(f(e),f(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],n=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){n.push([e,t])})),c(r.sort(),n.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return o(e,t,u,v),v}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let n=-1;for(;++n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const n=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return n.prior=()=>t,n.hasPrior=()=>r,n}},41400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),n=i(35556),s=i(31586),o=i(68708);function a(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const s=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&n.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return a(t).then((()=>t))},t.delay=a,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),s=n.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return n.isBrowser||t<=r.secondMs?s:(0,o.maybeCall)(s,"unref")??s}},33374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const r=i(31586),n=i(21605),s=i(12168);function o(e){return{width:e.height,height:e.width}}function a(e){return((0,r.toGt0)(e?.width)??0)*((0,r.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,r.gt0)(e.width)&&(0,r.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,r.gt0)(e)&&(0,r.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,s.pixels2size)(e.width*e.height)},t.dimSwap=o,t.maybeDimSwap=function(e,t){return(0,n.swappableRotation)(t)?o(e):e},t.maybeFlipInPlace=function(e,t){(0,n.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,s.megapixels)(a(e))},t.pixels=a},50357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),n=i(68708),s=i(34666),o=i(32639);function a(e,t){return(0,r.deepEql)(e,t,{comparator:f})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,o.isFunction)(e)&&(0,o.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=a,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return!1;for(const i of(0,n.keys)(e))if(!a(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function f(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),n=i(22573),s=i(96249),o=i(31586),a=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,n.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,o.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const f=/shortStack|errorToVerbose/;function h(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,s.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return h(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,n.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,n.blank)(e)&&e.trim().startsWith("at ")&&null==f.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,n.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(n.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,a.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,a.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,a.assignFields)(new Error,(0,a.omit)(e,"_ctor"))},t.errorToArr=h,t.errorToS=m},4188:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),n=i(42659),s=i(55835),o=i(31586),a=i(12168),l=[{ms:n.yearMs,s:"year",p:"years"},{ms:n.yearMs/12,s:"month",p:"months"},{ms:n.weekMs,s:"week",p:"weeks"},{ms:n.dayMs,s:"day",p:"days"},{ms:n.hourMs,s:"hour",p:"hours"},{ms:n.minuteMs,s:"minute",p:"minutes"},{ms:n.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,n){if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,s.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,a.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,s.mapOr)(n,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function n(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=n,t.orList=function(e){return n(e,"or")},t.andList=function(e){return n(e,"and")}},50268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const r=i(22573),n=i(38639),s=i(68708),o=i(62220),a=i(50989);t.HealthCheckSections=(0,a.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,a.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,s.isObject)(e)&&!(0,r.blank)(e.id)&&!(0,r.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,r.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,s.isObject)(e)&&o.RunStates.has(e.state)&&(0,n.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},73722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const n=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,n){if((0,isFunction_1.isFunction)(r))return;let s,o,a,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),n=i(50357),s=i(31586),o=i(65812);t.lazy=function(e,t){let i,a;const l=[];function u(){return u.isStale()&&u.setResult(e()),a}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const s=await e,a=await i;if(!(0,n.eql)(s,a))for(const e of l)e(a);null!=t&&t>0&&void 0!==a&&(0,o.setUnrefTimeout)((()=>u.vacuum()),t)}(a,e),a=e},u.isStale=function(){return null==i||(0,s.gt0)(t)&&i+t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),n=i(54993);function s(e,t){return null==e?void 0:t(e)}function o(e,t,i){return null==e||null==t?void 0:i(e,t)}function a(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=o,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=a,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return a(o(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,n.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class n extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=n},23838:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),n=i(76790),s=i(50357),o=i(98553),a=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,a.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,a.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,s.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),n=null==i?[]:e(t,i);(0,r.isEmpty)(n)?this.store.delete(t):this.store.set(t,n)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,n]of this.store.entries()){const s=(0,r.findIndexes)(n,(t=>!e(i,t,n)));if(s.length>0){t=!0;for(const e of s.reverse())n.splice(e,1)}0===n.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,o.stringify)(t)]=i;return e}}function f(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=f,t.groupByValues=function(e,t){const i=f(e,t);return(0,n.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),n=i(22573),s=i(42279),o=i(54993);function a(e){return"number"==typeof e&&isFinite(e)}t.isNumber=a,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,o.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return a(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,o.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const f=e=>(t,i)=>a(t)&&a(i)&&e(t,i);function h(e,i,n){return!(null==n||!a(n))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,n)&&(0,t.gte)(i,n))}function m(e){if(!a(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,n.blank)(e))return t.defaultValue;if(a(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return a(e)&&e>0}function S(e){return a(e)&&e>=0}function b(e,t){return a(e)?t(e):void 0}function P(e){return a(e)?e<0?-Math.round(-e):Math.round(e):0}function M(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function _(e,t,i){if(e>t||!a(e)||!a(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return a(i)?it?t:i:(e+t)/2}t.lt=f(((e,t)=>ee<=t)),t.gt=f(((e,t)=>e>t)),t.gte=f(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return a(e)?e:t},t.diff=function(e,t){return a(e)&&a(t)?e-t:void 0},t.absdiff=function(e,t){return a(e)&&a(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!a(e)||!a(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return h(t-r,t+r,e)},t.within=h,t.max_=function(...e){let t;for(const i of e)a(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return a(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return a(e)&&a(t)&&e>t?e:void 0},t.lte0=function(e){return a(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=v(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,i){return b(e,(e=>b(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return a(e)?t(e):i},t.numericOr=function(e,t){return a(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d\.\d+)0+$/,"")},t.toPrecision=M,t.toPrecisionMaybe=function(e,t){return d(e,(e=>M(e,t)))},t.sigFigs=function(e,t){if(!a(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=_,t.times=function(e,t){if(!w(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return _(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||h(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!a(i))return;t+=i}return t}},68708:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),n=i(76790),s=i(22573),o=i(32639),a=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function f(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function h(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!h(e)}function p(e){return f(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??f(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function w(e,t,i={}){return y((0,r.compact)((0,n.sort)(f(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function S(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const n={};for(const e of(0,r.uniq)((0,r.flatMap)(i,f)))n[e]=S(...i.map((t=>t[e])));return n}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of f(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=f,t.keysWithDefinedValues=function(e){return null==e?[]:f(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=h,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=v(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,n]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==n&&!0!==i?.assignNullish||(e[r]=n));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,a.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,s.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=a.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function n(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:S(i,t)}for(const r of i){const[i,o]=(0,c.splitFirst)(r,"."),a=b(t,i);null!=a?.value&&n(a.key,(0,s.blank)(o)?a.value:e(a.value,o))}for(const r of f(t))((0,l.toInt)(r)??-1)>=0&&n(r,e(t[r],...i));return r},t.pluck=b,t.pluckDeep=function e(t,i){if(null==t||(0,s.blank)(i))return;if(Array.isArray(t)){const n=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(n)?void 0:{key:n[0].key,value:(0,r.flatMap)(n,(e=>e.value))}}const[n,o]=(0,c.splitFirst)(i,"."),a=b(t,n);if(null==a)return;if((0,s.blank)(o))return a;const l=e(a.value,o);return null==l?void 0:{key:a.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=f(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,o.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of f(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=w(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return n(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return s(e).flatMap((e=>s(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return s(e).flatMap((e=>s(t).flatMap((t=>s(i).flatMap((i=>r(this.a,e,t,i)))))))}}function n(e){return e instanceof r||e===t.None}function s(e){return n(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=n,t.opt=s},97238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSeed=t.prngSeed=t.SeedCount=t.PrimeBins=t.PrimesPerBin=void 0;const r=i(31586),n=i(30976),s=i(54993);t.PrimesPerBin=4,t.PrimeBins=8,t.SeedCount=t.PrimesPerBin**t.PrimeBins,t.prngSeed=function(){return(0,n.randomInt)(0,t.SeedCount)},t.toSeed=function(e){const i=(0,r.toInt)((0,s.toS)(e));return(0,r.within)(0,t.SeedCount,i)?i:void 0}},39926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),n=i(54993),s={};function o(e,t){if(t<1)return"";if(!(0,r.gte)(s[e]?.length,t)){let i=s[e]??e;for(;i.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var r=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return r.parseJSON}})},46891:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),n=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,o=/[^aeiou]y$/,a=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=n.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(o)?e.replace(/y$/i,"ies"):null!=e.match(a)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),n=i(54993),s=["number","string","boolean"];function o(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=o,t.mapPrimitive=function(e,t){return o(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return o(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(o)};const a=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,s=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==s&&"symbol"!==s)){const r=(0,n.toS)(e),s=(0,n.toS)(i),o=r.localeCompare(s);return r[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-o:o}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==s?a.indexOf(r)-a.indexOf(s):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function n(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const n of(0,r.toA)(await e))if(null!=n){const e=await n;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=n,t.isPromise=function(e){return n(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),n=i(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function o(e,t,i){return null==i||0===i.length?s(e,t):a(e,t,1,i)[0]}function a(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const n=t-e,o=new Set(r??[]);if(t===e&&0===n&&0===o.size&&1===i)return[e];const a=n-o.size;if(i>a)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:n,size:i,slotsRemaining:a})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of a(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,n.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let r=e;t.global||(t=new RegExp(t,"g"));let n=null;for(;null!=(n=t.exec(e));)n.index===t.lastIndex&&t.lastIndex++,r=r.slice(0,n.index)+i(n)+r.slice(n.index+n[0].length);return r}},21605:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const r=i(31586);function n(e){if(!(0,r.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,r.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=n,t.swappableRotation=function(e){const t=n(e);return 90===t||270===t}},62220:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const r=i(50989);t.RunStates=(0,r.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),n=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const o=e=>null!=e?i[e]:void 0,a=e=>null!=o(e);return{...s,values:t,length:t.length,has:a,includes:a,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:o,ordinal:e=>o(e)??t.length,validOrElse:(e,t)=>a(e)?e:(0,n.tot)(t),mapValid:(e,t)=>a(e)?t(e):void 0,cmp:(e,t)=>{const i=o(e),r=o(t);return null==i||null==r?void 0:i>r?1:i{const i=o(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),n=i(17586),s=i(22573),o=i(96249),a=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let f;function h(){if(void 0===f)try{f=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{f=null}return f??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=h();return null!=r?(0,a.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=h();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function b(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),n=(0,c.toS)(t);return r.length===n.length&&(r===n||r.toLowerCase()===n.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?n.normalize():n,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,n.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=h();return null!=t?(0,a.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return w(v(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,i){const r=i?.maxLineLen??80,n=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,o.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,o.flatten)(r.map((t=>e(t,i))))}if((t=v((0,c.toS)(t),n).trim()).length<=r)return[t];const s=S(t," ",r);if(s>n.length)return[m(t,0,s),...e(m(t,s+1),i)];{const r=t.indexOf(" ",n.length+1);return r>0&&r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),n=i(68708),s=i(42279),o=i(83104),a=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let n=!0;const s=setTimeout((()=>{n&&(n=!1,i(o.Timeout))}),t);try{s.unref?.();const t=await e;n&&(n=!1,i(t))}catch(e){n&&(n=!1,r(e))}finally{clearTimeout(s)}}))}async function u(e,t,i=!0){const n=await l(e,t,i);if(n===o.Timeout)throw new a.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return n}t.toNotTimeout=function(e){return e===o.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?o.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,s)=>{let o=!0;try{const a=setTimeout((async()=>{if(o){o=!1;try{r(await i())}catch(e){s(e)}}}),t);(0,n.maybeCall)(a,"unref");const l=await e;o&&(o=!1,clearTimeout(a),r(l))}catch(e){o&&(o=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const n=t-Date.now();if(n<=0)throw new a.TimeoutError("timeout ("+(0,r.fmtHMS)(n)+")");return u(e,n,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const n=await l(e,t,r);return n===o.Timeout?(0,s.tot)(i):n}},42279:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),n=i(22573),s=i(54993);function o(e){return"URLSearchParams"===e?.constructor?.name}function a(e){return null==e?void 0:o(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(a)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=o,t.toURLSearchParams=a,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,s.toS)(l(...t));return e+((0,n.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,s.toS)(l(...t));return(0,n.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),n=i(30301),s=i(31586),o=i(46891),a=i(50989),l=i(51926),u=(0,n.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,s.isNumber)(r)&&(i+=r/t.MB);return(0,s.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],f=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function h(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),n=Math.pow(10,3*r),o=d[r];return(0,s.sigFigs)(e/n,t)+" "+o}t.fmtMB=function(e,i=3){return h(e*t.MB,i)},t.fmtBytes=h,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),n=Math.pow(2,10*r),o=f[r];return(0,s.sigFigs)(e/n,t)+" "+o},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,a.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,o.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,o.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},2322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,r=/\bSafari\b/,n=/\bFirefox\b/,s=/\biPad\b/,o=/\biPhone\b/;function a(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return a(e,i)}function u(e){return a(e,n)}t.isChrome=l,t.isSafari=function(e){return a(e,r)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return a(e,s)},t.isIphone=function(e){return a(e,o)}},79114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.S=void 0;const r=i(50989);t.S=(0,r.strEnum)("plus","lite")},75020:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInfoTag=t.NotInfoPanelTags=t.LibraryTagName=t.TagRoots=t.isTagRef=t.ctxToS=t.TagGalleryProps=t.nextChildTagsUrl=t.nextAssetsUrl=t.BeforeAfterStreamLimit=t.ThumbsPerSample=void 0;const r=i(76790),n=i(22573),s=i(98553),o=i(31586),a=i(50989),l=i(51926),u=i(29652);t.ThumbsPerSample=128,t.BeforeAfterStreamLimit=8,t.nextAssetsUrl=function(e,t){const i={};return(0,o.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/assets`,i)},t.nextChildTagsUrl=function(e,t){const i={};return(0,o.mapNumeric)(t.seed,(e=>i.seed=e.toString())),(0,o.mapNumeric)(t.limit,(e=>i.limit=e.toString())),(0,o.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/child-tags`,i)},t.TagGalleryProps=["tagId","tagPath","assetCount","assetIds","nextAssets","childTags","nextChildTags"],t.ctxToS=function(e){return(0,s.stringify)({seed:e.seed,tagIds:(0,r.sort)([...e.tagIds])})},t.isTagRef=function(e){return null!=e&&!(0,l.isString)(e)&&(0,n.notBlank)(e.name)},t.TagRoots=(0,a.strEnum)("When","Who","Where","What","Camera","Lens","Albums","Keywords","Type","fs"),t.LibraryTagName="Library",t.NotInfoPanelTags=[t.TagRoots.When,t.TagRoots.Camera,t.TagRoots.Lens,t.TagRoots.Type,t.TagRoots.fs],t.isInfoTag=function(e){if(null==e)return!1;const i=(0,l.isString)(e)?e:e.tagPath?.[0];return!t.NotInfoPanelTags.includes(i)}},27776:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkTagUri=t.mkTagFullPath=t.mkHomeFullPath=t.urlSeed=void 0;const r=i(40958),n=i(30301),s=i(31586),o=i(97238),a=i(29652);function l(e,i){const r=(0,a.toURLSearchParams)(e);if(i||!(0,s.isDigits)(r?.get("seed"))){const e=(0,t.urlSeed)().toString();return r?.set("seed",e),r??{seed:e}}return r}function u(e,t,i=!1){const r=c(e,t,i);return(0,a.assembleFullPath)(r.path,r.query)}function c(e,t,i=!1){return{path:"/tag/"+((0,r.isEmpty)(e)?"":e.map(encodeURIComponent).join("/")),query:l(t,i)}}t.urlSeed=(0,n.lazy)(o.prngSeed,100),t.mkHomeFullPath=function(e){return u([],e,!0)},t.mkTagFullPath=u,t.mkTagUri=c},23541:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),n=i(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,n.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),n=i(23541),s=i(59455),o=i(54993);function a(e){return null==e?void 0:(0,n.isError)(e)?e:new Error((0,o.toS)(e))}t.toErr=a,t.toErrs=function(...e){return(0,r.compact)((0,s.toA)(e).map(a))}},54993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return s(e,",")};const n={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==n?e.toString():(0,r.stringify)(e)}}t.toStr=s},61209:function(e,t,i){"use strict";var r,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.MainService=void 0;const d=c(i(1708)),f=i(19851),h=i(50213),m=i(54826),p=i(22911),g=i(27395),y=i(78406),v=i(25764),w=i(38836),S=i(99331),b=i(45608),P=i(73614),M=i(86335),_=i(55534),E=i(38835),T=i(70025),x=i(8769),D=i(83278),k=i(19652),C=i(85021),O=i(28874),I=i(2858),F=i(34238),L=i(51140),A=c(i(98604)),R=i(78932),N=i(69385),j=i(22573),B=i(38639),z=i(42659),V=i(26905),W=i(98553),U=i(55835),H=i(31586),q=i(68708),G=i(54993),$=i(37158);class J{constructor(){r.add(this),this.start=Date.now(),n.set(this,(0,f.lazy)((()=>(0,h.mkLogger)("MainService")))),this.httpPort=new p.Deferred("MainService.httpPort"),this.libraryDir=new p.Deferred("MainService.libraryDir"),s.set(this,void 0),o.set(this,void 0),this.setup=(0,f.lazy)((async()=>{await this.service.ready.catch((e=>(0,m.consoleError)("MainService.setup() failed: "+(0,V.errorToS)(e)))),l(this,s,await M.ChildService.mk_("web",{onStdout:e=>this.onWebout("stdout",e),onStderr:e=>this.onWebout("stderr",e),onData:e=>this.onWebData(e),onRestartPaused:()=>(0,b.exit)({reason:"Too many web service fatal errors",status:13})}),"f"),await(0,j.mapNotBlank)(O.Settings.pidFile.value,(async e=>{const t=D.BaseFile.for(e);u(this,n,"f").call(this).info("Writing to pidfile "+t,{pid:d.default.pid}),await t.writeText_((0,G.toS)(d.default.pid)),new w.EndableWrapper("remove pidfile",(()=>t.unlink()),v.EndableRanks.postdb)})),await this.service.ready;try{await(0,k.externalDirectoryCheck)()}catch(e){u(this,n,"f").call(this).warn("Failed to check external directory permissions",{error:e})}if(this.service.setInputHandler("--restart-sync",(()=>this.restartSync())),this.service.setInputHandler(C.HealthCheckCommand,(()=>u(this,r,"m",a).call(this))),null==u(this,s,"f"))return(0,x.onError)("Failed to start webservice"+E.FatalErrorFlag);this.httpPort.promise.then((e=>{const t=(0,A.default)(e),i=(1===t.length?" ":"\n - ")+t.map((e=>`${e}`)).join("\n - ");(0,m.consoleLog)(`PhotoStructure is ready:${i}`),O.Settings.exposeNetworkWithoutAuth.valueOrDefault||(0,m.consoleLog)("See https://photostructure.com/faq/remote-access/ to enable non-localhost access.")})),this.libraryDir.promise.then((e=>{(0,m.consoleLog)(`Your library is at <${F.URI.file(e)}>`)})),new w.EndableWrapper("shutdown notice",(()=>(0,m.consoleLog)("\nShutting down PhotoStructure...")),v.EndableRanks.first),(0,H.gt0)(O.Settings.healthCheckIntervalMs.valueOrDefault)&&new y.EndableInterval({name:"webSyncHealthChecks",intervalMs:O.Settings.healthCheckIntervalMs.valueOrDefault,callback:()=>u(this,r,"m",a).call(this)})})),this.service=new $.Service("main"),this.setup(),(0,P.setUnrefTimeout)((()=>{this.httpPort.isPending&&!(0,S.ending)()&&(0,m.consoleLog)("Please wait, setting up...")}),4*z.secondMs)}async webHealthCheck(){const e=this.httpPort.value;if(null!=e)try{const t=await(0,R.httping)("localhost",e,"/ping",3*z.secondMs);return!!L.HttpStatusIs.success(t)||(u(this,n,"f").call(this).warn("webHealthCheck(): web service returned "+t),!1)}catch(e){return u(this,n,"f").call(this).warn("webHealthCheck(): httping error: "+e),!1}else u(this,n,"f").call(this).info("webHealthCheck(): no-op, no http port set (web is starting up still)")}onWebout(e,t){return u(this,n,"f").call(this).info("onWebout",{pipe:e,error:t}),t===_.ServiceExitCommand?(0,b.exit)({reason:"Web service exit command",status:0}):(t??(t=""),/EADDRINUSE/i.test(t)||t.includes(E.WebFatalErrorFlag)||(0,T.isFatalError)(t)?(0,b.exit)({status:1,reason:"Web service error",error:t}):this.onWebData((0,W.parseJSON)(t)))}async onWebData(e){(0,j.blank)(e)||(u(this,n,"f").call(this).info("onWebData",{input:e}),(0,U.map)(e[O.Settings.httpPort.key],(e=>{u(this,n,"f").call(this).info("Got HTTP port number from web service:"+e),O.Settings.httpPort.envValue=e,this.httpPort.maybeResolve(e)})),(0,B.mapBoolean)(e.pause,(e=>e?(0,N.pause)():(0,N.resume)())),await(0,B.mapTrue)(e.shutdown,(()=>(0,b.exit)({reason:"shutdown requested",status:0}))),await(0,B.mapTrue)(e.shutdownSync,(()=>this.shutdownSync())),(0,B.isTrue)(e.forceRestartSync)?await this.forceRestartSync():(0,B.isTrue)(e.restartSync)&&await this.restartSync())}async shutdownSync(){const e=u(this,o,"f");return l(this,o,void 0,"f"),u(this,n,"f").call(this).info("shutdownSync()",{syncWasDefined:null!=e}),(0,g.end)(e)}async forceRestartSync(){return this.restartSync()}async restartSync(){const e=(0,h.mkLogger)("MainService.restartSync()");if((0,S.ending)())return void e.info("ending, no-op");const t=u(this,o,"f");if(e.info("priorSync",(0,U.map)(t,(e=>(0,q.pick)(e,"pid","name")))),await(0,g.end)(t),l(this,o,void 0,"f"),await(0,I.readSystemSettings)(),!I.libraryHasSettings.refresh())return void e.info("restartSync(): no library settings",{libraryDir:O.Settings.libraryDir.value});const i=l(this,o,await M.ChildService.mk_("sync"),"f");e.info("Started sync",(0,U.map)(i,(e=>(0,q.pick)(e,"pid","name"))))}}t.MainService=J,n=new WeakMap,s=new WeakMap,o=new WeakMap,r=new WeakSet,a=async function(){!1===await this.webHealthCheck()?await u(this,s,"f").restart():u(this,s,"f").runHealthCheck(),u(this,o,"f")?.runHealthCheck()},J.instance=(0,f.lazy)((()=>new J))},18449:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sentryEnabled=void 0;const r=i(7282),n=i(96706),s=i(29325),o=i(28874);t.sentryEnabled=function(){return(0,n.isEnvTrue)("ENABLE_SENTRY")||(0,r.isProd)()&&(0,s.isPacked)()&&!0===o.Settings.reportErrors.value}},95629:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var n=Object.getOwnPropertyDescriptor(t,i);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,n)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelToSeverity=t.logEntryToBreadcrumb=t.mkBreadcrumbs=t.annotateEvent=t.sentryExceptionToS=t.sentryExceptionsToS=t.extractMessage=t.EventFilter=t.eventFilter=t.sendToSentry=t.installSentry=void 0;const a=s(i(16436)),l=o(i(48161)),u=o(i(1708)),c=i(19851),d=i(19043),f=i(50213),h=i(31578),m=i(7282),p=i(96175),g=i(23560),y=i(84968),v=i(81168),w=i(37805),S=i(25764),b=i(38836),P=i(99331),M=i(85100),_=i(98314),E=i(68301),T=i(70025),x=i(8769),D=i(34102),k=i(34592),C=i(42042),O=i(34474),I=i(20839),F=i(57902),L=i(45969),A=i(43334),R=i(40958),N=i(22573),j=i(42659),B=i(41400),z=i(98553),V=i(55835),W=i(12168),U=i(59455),H=i(54993),q=i(18449),G=(0,c.lazy)((()=>(0,f.mkLogger)("Sentry")));function $(e){(0,q.sentryEnabled)()&&null!=e&&!0!==(0,T.isDoNotSendError)(e)&&a.captureException(e)}t.installSentry=async function(e){try{return!!(0,q.sentryEnabled)()&&(a.init({dsn:A.isElectron?"https://0652cdd351054fe9853ff944b1f54e2c@o130922.ingest.sentry.io/289071":"https://5f52aefec1b3439eaed2e77b2d1210a8@o130922.ingest.sentry.io/1828379",shutdownTimeout:(0,M.serviceExitTimeoutMs)(e.name),release:w.release,environment:(0,m.nodeEnv)(),maxBreadcrumbs:100,integrations:[],beforeSend:(0,t.eventFilter)().beforeSend,onFatalError:e=>(0,x.onError)("sentry.onFatalError",e)}),G().info("Sentry initialized",{isElectron:A.isElectron}),!0)}catch(e){return G().warn("Failed to set up sentry",{error:e}),!1}},t.sendToSentry=$,t.eventFilter=(0,c.lazy)((()=>new J));class J{constructor(){this.beforeSend=async(e,t)=>{if(!(0,q.sentryEnabled)())return G().warn("Sentry.beforeSend(): not sending event",e),null;if(!0===await(E.ErrorStore.instance()?.eventQuotaExceeded(e)))return G().warn("Sentry.beforeSend(): event quota exceeded",e),null;const i=K(e,t);if(!0===(0,T.isDoNotSendError)(i))return G().info("Sentry.beforeSend(): event not sendable. vetoing",{event:e,hint:t,msg:i}),null;(0,N.blank)(e.message)&&(e.message=(0,v.ellipsize)(i,256));const r=await X(e);return await(E.ErrorStore.instance()?.maybeSendEvent(r))??null},(0,D.ee)().on("fatal",$),(0,D.ee)().on("nonFatal",$),new b.EndableWrapper("EventFilter",(()=>this.end()),S.EndableRanks.first)}end(){return(0,V.map)(a.getCurrentHub().getClient(),(e=>e.close(5*j.secondMs)))}}function K(e,t){return(0,R.uniq)((0,R.compactBlankish)([e.message,...(0,U.toA)(Z(e.exception?.values)),(0,_.errorToS)(t?.originalException)])).join(": ")}function Z(e){return(0,R.mapNotEmpty)(e,(e=>(0,R.compactBlanks)(e.map(Y))))}function Y(e){return(0,R.mapNotEmpty)((0,R.compactBlanks)([e?.type,e?.value].filter((e=>"error"!==(0,H.toS)(e).toLowerCase()))),(e=>e.join(": ")))}async function X(e){const t=await(0,C.getEmail)();(0,N.notBlank)(t)&&(null==e.user&&(e.user={}),e.user.email=t),(0,R.isEmpty)(e.breadcrumbs)&&(e.breadcrumbs=await Q());const i=e.extra??{};return i.pid=u.default.pid,i.serviceName=(0,g.serviceName)(),i.serviceEnding=(0,P.ending)(),i.runtimeMs=(0,y.runtimeMs)(),i.version=w.version,i.os=(0,p.osFullName)(),i.isDocker=(0,L.isDocker)(),i.nodeVersion=u.default.versions.node,i.locale=await(0,d.locale)(),i.cpus=(0,p.CPUs)(),i.memoryUsageMb=(0,h.memoryUsageMb)(),i.memoryUsageRssMb=(0,h.memoryUsageRssMb)(),i.systemMemory=(0,W.fmtBytes)(l.default.freemem())+" / "+(0,W.fmtBytes)(l.default.totalmem()),i.ffmpeg=await(0,k.ffmpegVersionDescription)(),i.argv=(0,z.stringify)(u.default.argv),e.extra=i,{timestamp:Date.now()/j.secondMs,...e}}async function Q(){await(0,B.delay)(3*I.DefaultLogFlushMs);const e=await(0,O.allRecentLogEntries)();return(0,R.compact)(e.map(ee))}function ee(e){return(0,V.map)(ie(e.l),(t=>({timestamp:e.ts/j.secondMs,level:t,category:e.from??(0,g.processName)(),message:(0,v.stripAnsiEsc)(e.ctx+": "+e.msg),data:"object"==typeof e.meta?e.meta:{value:(0,v.isString)(e.meta)?(0,v.stripAnsiEsc)(e.meta):e.meta}})))}t.EventFilter=J,t.extractMessage=K,t.sentryExceptionsToS=Z,t.sentryExceptionToS=Y,t.annotateEvent=X,t.mkBreadcrumbs=Q,t.logEntryToBreadcrumb=ee;const te=new Map([[F.LogLevels.fatal,"fatal"],[F.LogLevels.error,"error"],[F.LogLevels.warn,"warning"],[F.LogLevels.info,"info"],[F.LogLevels.debug,"debug"]]);function ie(e){return te.get(e)}t.logLevelToSeverity=ie},37158:function(e,t,i){"use strict";var r,n,s,o,a,l,u,c,d,f=this&&this.__classPrivateFieldSet||function(e,t,i,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,i):n?n.value=i:t.set(e,i),i},h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Service=t.setupEventHandlers=void 0;const p=m(i(29907)),g=m(i(1708)),y=i(57206),v=i(19851),w=i(50213),S=i(59880),b=i(23560),P=i(19913),M=i(71567),_=i(37805),E=i(38836),T=i(99331),x=i(45608),D=i(56038),k=i(55534),C=i(42499),O=i(49776),I=i(96706),F=i(98314),L=i(38835),A=i(70025),R=i(8769),N=i(57159),j=i(34102),B=i(33456),z=i(87408),V=i(85021),W=i(17181),U=i(86941),H=i(28874),q=i(41692),G=i(2858),$=i(69385),J=i(22573),K=i(42659),Z=i(41400),Y=i(56409),X=i(55835),Q=i(41583),ee=i(54993),te=i(95629);t.setupEventHandlers=(0,v.lazy)((()=>{(0,j.ee)().on("resume",(()=>(0,$.resume)())),(0,j.ee)().on("pause",(()=>(0,$.pause)()))}));class ie extends E.EndableWrapper{constructor(e){super(e),r.add(this),n.set(this,void 0),s.set(this,new Y.Latch),o.set(this,new Map),this.setup_=(0,v.lazy)((()=>(0,D.time)("Service.setup",(()=>h(this,r,"m",a).call(this))))),u.set(this,(0,v.lazy)((()=>{const e=g.default.stdin.pipe(new B.LineReader);return e.on("data",(e=>h(this,r,"m",d).call(this,(0,ee.toS)(e)))),e}))),(0,b.isBillingService)()||(0,q.setSettingsDefaults)(),f(this,n,(0,w.mkLogger)("Service("+this.name+")"),"f"),h(this,r,"m",c).call(this),this.setup_()}get name(){return super.name}get ready(){return h(this,s,"f").promise}get isReady(){return h(this,s,"f").isResolved()}setInputHandler(e,t){h(this,o,"f").set(e.trim().toLowerCase(),t)}}t.Service=ie,n=new WeakMap,s=new WeakMap,o=new WeakMap,u=new WeakMap,r=new WeakSet,a=async function(){try{(0,J.mapNotBlank)((0,I.getEnv)("PS_FATAL_"+this.name),(e=>{throw new N.WrappedError(e,{fatal:!0})})),(0,J.mapNotBlank)((0,I.getEnv)("PS_CRASH_"+this.name),(e=>{(0,Z.later)((()=>{throw new N.WrappedError(e)}),5*K.secondMs)})),(0,P.setServiceName)(this.name),(0,S.setProcessTitle)(),(0,b.isMainService)()&&await(0,U.mergeUserDataDirs_)(),await(0,G.readSettings)(),await h(this,r,"m",l).call(this),(0,W.setupLogger)(),(0,y.addDefaultJsonRevivers)(),(0,O.cacheDir)(),(0,t.setupEventHandlers)(),h(this,u,"f").call(this),await(0,C.setupLuxon)(),H.Settings.startPaused.valueOrDefault&&(0,$.pause)(),(0,T.ending)()?h(this,s,"f").reject():h(this,s,"f").resolve()}catch(e){console.error((0,F.errorToS)(e)),h(this,s,"f").reject((0,Q.toErr)(e)),(0,x.exit)({reason:(0,A.addErrorFlags)(this.name+" setup failed: "+(0,F.errorToS)(e),L.FatalErrorFlag),status:14})}},l=async function(){(0,b.isPermaService)()||(0,j.ee)().on("fatal",(e=>(0,x.exit)({error:e,status:12}))),g.default.on("unhandledRejection",(e=>(0,X.map)(e,(e=>(0,R.onError)("unhandledRejection",e))))),g.default.on("uncaughtException",(e=>(0,X.map)(e,(e=>(0,R.onError)("uncaughtException",e))))),g.default.on("SIGINT",(()=>(0,x.exit)({reason:"SIGINT",status:0}))),g.default.on("SIGHUP",(()=>(0,x.exit)({reason:"SIGHUP",status:0}))),g.default.on("SIGTERM",(()=>(0,x.exit)({reason:"SIGTERM",status:0}))),p.default.isWorker&&g.default.on("disconnect",(()=>(0,x.exit)({reason:"disconnect",status:0}))),await(0,te.installSentry)(this)},c=function(){this.setInputHandler("--version",(()=>(0,M.stdoutWrite)({version:_.version}))),this.setInputHandler(k.ServiceExitCommand,(()=>(0,Z.later)((()=>(0,x.exit)({reason:k.ServiceExitCommand+" from stdin",status:0}))))),this.setInputHandler("--times",(()=>(0,M.stdoutWrite)(D.PromiseTimer.instance().report()))),this.setInputHandler(V.HealthCheckCommand,(async()=>(0,M.stdoutWrite)(await(0,z.getStatusSummary)({refresh:!0}))))},d=async function(e){if(h(this,n,"f").debug("onLine()",{line:e,ending:this.ended||(0,T.ending)()}),await this.setup_(),e.startsWith("--")){const t=e.split(/\s+/,1)[0],i=h(this,o,"f").get(t);null==i?(h(this,n,"f").error("onLine(): unknown command",{line:e,knownCommands:[...h(this,o,"f").keys()]}),console.warn("unknown command "+e)):await i(e.slice(t.length).trim())}else h(this,n,"f").error("onLine(): failed to process",{line:e})}},38530:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DaemonArgs=void 0;const n=i(58587),s=i(31421),o=r(i(1708)),a=i(9727),l=i(83278),u=i(95402),c=i(28874),d=i(2858),f=i(22573),h=i(38639),m=i(31586);t.DaemonArgs={beforeParse:e=>e.option("-p, --pidfile PIDFILE","Write a pidfile of the main process.").option("--stop","Shutdown daemonized PhotoStructure. Requires --pidfile").option("-d, --daemon","Run PhotoStructure as a daemon. Enabled by default when --pidfile is provided."),afterParse:async e=>{if((0,f.mapNotBlank)(e.pidfile,(e=>c.Settings.pidFile.envValue=e)),(0,h.isTrue)(e.stop)){if(!c.Settings.pidFile.hasValue()&&(await(0,d.readSystemSettings)(),!c.Settings.pidFile.hasValue()))return console.error("--stop requires --pidfile to be set."),o.default.exit(1);const e=l.BaseFile.for(c.Settings.pidFile.value);if(await e.notExists())return console.error("Pidfile "+e+" does not exist."),o.default.exit(1);const t=(0,m.toInt)(await e.readTextFile());return(0,m.gt0)(t)?(0,n.pidExists)(t)?(await(0,u.killPid)(t),o.default.exit(0)):(console.error("Pid "+t+" does not exist."),o.default.exit(1)):(console.error("Pidfile "+e+" is invalid."),o.default.exit(1))}if(!(0,h.isTrue)(o.default.env.__is_daemon)&&((0,h.isTrue)(e.daemon)||c.Settings.pidFile.hasValue())){const e=o.default.argv.findIndex((e=>!e.includes("npx")&&!e.includes("node"))),t=o.default.argv.slice(-1===e?0:e),i=process.execPath,r={...(0,a.childEnv)(),__is_daemon:"1"},n=(0,s.spawn)(i,t,{env:r,detached:!0,shell:!0});return n.unref(),console.log("Daemonized PhotoStructure.",{pid:n.pid,args:t}),o.default.exit(0)}}}},98392:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExposeArg=void 0;const r=i(28874),n=i(38639);t.ExposeArg={beforeParse:e=>e.option("--expose","The web service is only accessible to the computer running PhotoStructure by default. Providing this option will expose your library to all computers on your network. See https://photostructure.com/faq/remote-access/ ."),afterParse:e=>{(0,n.isTrue)(e.expose)&&(r.Settings.exposeNetworkWithoutAuth.envValue=!0)}}},31503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogArgs=void 0;const r=i(23560),n=i(83210),s=i(28874),o=i(38639);function a(){return(0,r.isMainService)()||(0,r.isSyncService)()}t.LogArgs={beforeParse:e=>{const t=(a()?', "PS_TAIL_LOGS=true"':"")+' and "PS_LOG_STDOUT=true".';return a()?e.option("-v, --verbose",'Verbose logging from all processes. Shortcut for "--info --tail". Caution: noisy during imports!'):e.option("-v, --verbose","Verbose logging. Equivalent to --info."),e.option("--error",`Emit "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=error"${t}`),e.option("--warn",`Emit "warn" and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=warn"${t}`),e.option("--info",`Emit "info", "warn", and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=info"${t}`),e.option("--debug",`Emit "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY NOISY. Sets "PS_LOG_LEVEL=debug"${t}}`),e.option("--trace",`Emit "trace", "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY VERY NOISY. Sets "PS_LOG_LEVEL=trace"${t}}`),a()&&e.option("--tail",'Emit log messages from both this process and all other concurrently running PhotoStructure processes on this host to stdout. This can be really helpful in seeing how PhotoStructure\'s processes are coordinating work. Caution: very noisy especially during imports. Sets "PS_TAIL_LOGS=true".'),e},afterParse:e=>{const t=(0,o.isTrue)(e.error),i=(0,o.isTrue)(e.warn),r=(0,o.isTrue)(e.info)||(0,o.isTrue)(e.verbose)||(0,o.isTrue)(e.v),l=(0,o.isTrue)(e.debug),u=(0,o.isTrue)(e.trace);u?s.Settings.logLevel.envValue="trace":l?s.Settings.logLevel.envValue="debug":r?s.Settings.logLevel.envValue="info":i?s.Settings.logLevel.envValue="warn":t&&(s.Settings.logLevel.envValue="error"),(0,n.isDaemon)(e)?(s.Settings.tailLogs.envValue=!1,s.Settings.logStdout.envValue=!1):((0,o.isTrue)(e.tail)&&(s.Settings.tailLogs.envValue=!0),(t||i||r||l||u)&&(s.Settings.logStdout.tmpValue=!0,a()&&(s.Settings.tailLogs.tmpValue=!0)),(s.Settings.tailLogs.valueOrDefault||s.Settings.logStdout.valueOrDefault)&&s.Settings.logLevel.isUnset()&&(s.Settings.logLevel.envValue="info"))}}},12195:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoFilterArg=void 0;const r=i(4175),n=i(38639);t.NoFilterArg={beforeParse:e=>e.option("--no-filter","Disables import filters. All paths will try to be imported, even if they are too small or are missing tags. See https://photostructure.com/faq/why-is-my-file-missing/ ."),afterParse:async e=>{(0,n.isFalse)(e.filter)&&(0,r.disableAllFilters)()}}},33321:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PauseSyncArg=void 0;const r=i(28874),n=i(38639);t.PauseSyncArg={beforeParse:e=>e.option("--pauseSync","Pause sync processing until manually resumed via the system tray or nav menu."),afterParse:e=>{(0,n.isTrue)(e.pauseSync)&&(r.Settings.startPaused.envValue=!0)}}},51088:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MainArgs=void 0;try{i(93944).install()}catch{}const r=i(69554),n=i(43380),s=i(28874),o=i(38639),a=i(5670),l=i(61209),u=i(38530),c=i(98392),d=i(31503),f=i(12195),h=i(33321);t.MainArgs={beforeParse:e=>e.option("--quiet","Don't emit lifecycle messages to stdout from the main service."),afterParse:e=>{(0,o.isTrue)(e.quiet)&&(s.Settings.quiet.tmpValue=!0)}},async function(){try{await new r.CLI(a.ServiceNames.main).add(t.MainArgs,c.ExposeArg,h.PauseSyncArg,u.DaemonArgs,f.NoFilterArg,n.WriteSettingsArg,d.LogArgs).parse(),new l.MainService}catch(e){console.error("Failed to start:")}}()},90858:e=>{"use strict";e.exports=require("@iarna/toml")},53705:e=>{"use strict";e.exports=require("@photostructure/tz-lookup")},16436:e=>{"use strict";e.exports=require("@sentry/node")},64770:e=>{"use strict";e.exports=require("assert")},58587:e=>{"use strict";e.exports=require("batch-cluster")},6858:e=>{"use strict";e.exports=require("commander")},36507:e=>{"use strict";e.exports=require("croner")},66261:e=>{"use strict";e.exports=require("events")},77988:e=>{"use strict";e.exports=require("exiftool-vendored")},68817:e=>{"use strict";e.exports=require("file-type")},44652:e=>{"use strict";e.exports=require("fs-extra")},28787:e=>{"use strict";e.exports=require("he")},51168:e=>{"use strict";e.exports=require("luxon")},22915:e=>{"use strict";e.exports=require("platform-folders")},57272:e=>{"use strict";e.exports=require("plist")},85949:e=>{"use strict";e.exports=require("process")},90595:e=>{"use strict";e.exports=require("punycode")},38064:e=>{"use strict";e.exports=require("semver")},9288:e=>{"use strict";e.exports=require("sharp")},93944:e=>{"use strict";e.exports=require("source-map-support")},73872:e=>{"use strict";e.exports=require("type-detect")},92460:e=>{"use strict";e.exports=require("util")},75162:e=>{"use strict";e.exports=require("util/types")},29907:e=>{"use strict";e.exports=require("cluster")},76982:e=>{"use strict";e.exports=require("crypto")},31421:e=>{"use strict";e.exports=require("node:child_process")},77598:e=>{"use strict";e.exports=require("node:crypto")},40610:e=>{"use strict";e.exports=require("node:dns")},78474:e=>{"use strict";e.exports=require("node:events")},73024:e=>{"use strict";e.exports=require("node:fs")},51455:e=>{"use strict";e.exports=require("node:fs/promises")},37067:e=>{"use strict";e.exports=require("node:http")},44708:e=>{"use strict";e.exports=require("node:https")},77030:e=>{"use strict";e.exports=require("node:net")},48161:e=>{"use strict";e.exports=require("node:os")},76760:e=>{"use strict";e.exports=require("node:path")},53916:e=>{"use strict";e.exports=require("node:path/posix")},1708:e=>{"use strict";e.exports=require("node:process")},57075:e=>{"use strict";e.exports=require("node:stream")},46466:e=>{"use strict";e.exports=require("node:stream/promises")},87997:e=>{"use strict";e.exports=require("node:timers")},57975:e=>{"use strict";e.exports=require("node:util")},38522:e=>{"use strict";e.exports=require("node:zlib")},16928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.exports}var __webpack_exports__=__webpack_require__(51088);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/bin/photostructure.js b/bin/photostructure.js index 651b206..2642899 100755 --- a/bin/photostructure.js +++ b/bin/photostructure.js @@ -6,4 +6,4 @@ * IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THIS SOFTWARE */ -(()=>{"use strict";var __webpack_modules__={37975:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const i=r(22573),n=r(38639),s=r(44198);function o(){return(0,n.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,i.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=o;let a=!o();function l(){return a}function u(e,t){return function(r){return l()?`[${e}m${r}[${t}m`:r}}t.setColorEnabled=function(e){a=e??!o()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const i=r(19851),n=r(7282),s=r(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,i.lazy)((()=>t.SimpleAppName+((0,n.isProd)()?"":`-${(0,n.nodeEnv)()}`))),t.AppNameVersion=(0,i.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const i=r(40958),n=r(36783),s=r(76790),o=r(22573),a=r(50357),l=r(98553),u=r(55835),c=r(31586),d=r(68708),h=r(34666),f=r(59455),m=r(84885);var p=r(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,r=i.primitiveValueOfOrElse){const n=new Set(t.map(r));return e.filter((e=>n.has(r(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],r=e.lastIndexOf(t);return[{t,count:r+1},...v(e.slice(r+1))]}function w(...e){const t=[],r=Math.max(...e.map((e=>e?.length??0)));for(let i=0;ie?.[i])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function E(e,t){return(0,i.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,r){return C(e,t,r).index}function C(e,t,r){if((0,i.isEmpty)(e))return{index:-1,value:void 0};let n,s=-1;for(let i=0;ie.slice(r,r+t)))}async function x(e,t){return(0,i.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,a.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(o.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const r of(0,f.toA)(e))if(null!=r&&!0===await t(r))return r},t.findLastAsync=async function(e,t){for(let r=(e=(0,f.toA)(e)).length-1;r>=0;r--){const i=e[r];if(null!=i&&!0===await t(i))return i}},t.first=function(e,t){if(null!=e)for(const r of(0,f.toA)(e))if(null!=r){const e=t(r);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null!=i){const e=await t(i,r);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,i.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,r){for(let i=r;i<=e.length-1;i++)if(t(e[i]))return i},t.findLast=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return e[r]},t.findLastIndex=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1},t.concat=function(...e){const t=[];for(const r of e)if(Array.isArray(r))for(const e of r)null!=e&&t.push(e);else null!=r&&t.push(r);return t},t.moveToEnd=function(e,t){return(0,i.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const r=e[t];if(null==r)return e;e.push(r);for(let r=t;r(0,a.eql)(e,t)))},t.removeFirst=function(e,t){const r=e.findIndex(t);return r>=0?e.splice(r,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,n.copyArrayTo)((0,i.uniqBy)(e,t),e)},t.partition=function(e,t){const r=[],i=[];let n=0;for(const s of e)(t(s,n++)?r:i).push(s);return[r,i]},t.isUniq=function(e){return e.every(((t,r)=>e.indexOf(t)===r))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,i.compact)((0,i.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),r=[];return(0,c.times)(t,(t=>e.map((e=>r.push(e?.[t]))))),r},t.unFlatZip=function(e,t){const r=e.length/t;if(r!==Math.round(r))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const i=(0,c.times)(t,(()=>new Array(r)));for(let n=0;ne.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=E,t.least=function(e){return E(e,(e=>e))},t.greatestBy=function(e,t){return(0,i.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const r=C(e??[],t,h.lt);return null==e||null==r||r.index<0||null==r.value?void 0:{result:e[r.index],index:r.index,value:r.value}},t.reverse=function(e){const t=[];for(let r=e.length-1;r>=0;r--)t.push(e[r]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=T,t.collectBatched=function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(r(s)));return n},t.collectBatchedAsync=async function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(await r(s)));return n},t.contextFilter=function(e,t){let r;return e.filter(((e,i)=>(0,d.tap)(t(e,i,r),(t=>{t&&(r=e)}))))},t.clusterSome=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.some((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterEvery=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.every((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterAsync=async function(e,t){const r=[];e:for(const i of e){for(const e of r)if(null!=i&&await x(e,(e=>t(i,e)))){e.push(i);continue e}null!=i&&r.push([i])}return r},t.someAsync=async function(e,t){if(null!=e)for(let r=0;r=0&&!0===(0,u.map)(e[i],(e=>r(e,i))))return i}{const i=t+n;if(ie+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,r){return e.lengthr))),e}},36557:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const a=r(77988),l=o(r(1708)),u=r(19851),c=r(42659),d=r(55835),h=r(31586),f=r(85556),m=r(54993),p=r(50213),g=r(79089),y=r(45255),v=r(25764),w=r(38836),S=r(99331),b=r(95937),P=r(98314),_=r(38835),E=r(70025),M=r(8769),C=r(43334),T=r(95402),x=r(28874),D=r(63870);class k extends w.EndableWrapper{constructor(e,t,r=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,i,"m",n).call(this)),r,"worker"===e?(0,D.commandTimeoutMs)():y.ShortCommandTimeoutMs),i.add(this),this.t=t;const o=t;o.on("childStart",(async r=>{null!=r.pid?(this.logger.info("Started child process",{pid:r.pid}),(0,g.renice)(r.pid).catch((e=>this.onError("renice failed",e))),(0,T.addPid)({pid:r.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),o.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),o.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),o.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),o.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),o.on("noTaskData",((e,r,i)=>{const n=t.options.streamFlushMillis;n{this.logger.error("observeBatchCluster.endError()",e)})),o.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&T.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof a.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,E.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=k,i=new WeakSet,n=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(C.isWin?3:1)*c.minuteMs,maxTasksPerProcess:x.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:x.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:x.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:x.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:x.Settings.taskTimeoutMs.valueOrDefault}}},89788:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=r(92460),d=r(31586);class h{constructor(e){if(i.add(this),this.maxLength=e,n.set(this,void 0),s.set(this,0),o.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,n,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,i=new WeakSet,a=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,o,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,n,"f")[t]))}()}push(...e){var t,r;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,n,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,i,"m",a).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,n,"f")[e]}))}unshift(...e){var t,r;for(const c of e.reverse())u(this,s,"f"){u(this,n,"f")[e]=c,l(this,o,e,"f")}));return u(this,s,"f")}shift(){return u(this,i,"m",a).call(this,0,(e=>{var t,r;return l(this,o,(t=u(this,o,"f"),++t),"f"),l(this,s,(r=u(this,s,"f"),--r),"f"),u(this,n,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,i,"m",a).call(this,u(this,s,"f")-1-e,(e=>{const r=u(this,n,"f")[e];u(this,n,"f")[e]=u(this,n,"f")[t],u(this,n,"f")[t]=r}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const i=r(54993),n=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:r}of n)if(o(e,t))return e.subarray(t.length).toString(r);return e.toString()}function o(e,t){return t.every(((t,r)=>e[r]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,i.toS)(e)},t.bufferStartsWith=o},9092:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,r]of e)this.set(t,r)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const r=this.normalizer(e);return null!=e&&null!=r&&this.store.set(r,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=n},36638:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=n},40583:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const o=r(40958),a=r(23838),l=s(r(68708)),u=r(59455),c=r(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new a.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const r of(0,o.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(r,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const r=this.lookup(e);if(null!=r)return r;let i,n=-1;for(const[r,s]of this.m.entries()){const o=(0,c.diceCoeff)(r,e);if(o>t&&o>n){const e=this.getFirst(s);null!=e&&(i=e,n=o)}}return i}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),r=this.m.get(t);if(null!=r){for(const e of r)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const i=r(76790),n=r(31586),s=r(68708),o=r(54993),a=r(82647),l=r(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const r=this.get(e)+t;return 0===r?this.m.delete(e):this.m.set(e,r),r}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new a.Average(0);for(const t of this.keys()){if(!(0,n.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,r]of this.m.entries())e[(0,o.toS)(t)]=r;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,i.sortBy)([...this.entries()],(([t,r])=>[-r,(0,n.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new a.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,r]of(0,i.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,r);return e}addAll(e){for(const[t,r]of e.entries())this.incr(t,r);return this}get toS(){return(0,i.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let r=0;for(const[i,n]of this.m.entries()){const s=e(i);t.fill(s,r,r+n),r+=n}return t}}t.CountingSet=u},79840:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const i=r(19851),n=r(72993),s=r(45969),o=r(43334);t.EditionType=(0,i.lazy)((()=>o.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,i.lazy)((()=>n.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const i=r(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),r=t-this.ts;this.ts=t,(0,i.map)(this.listener,(t=>t(e,r))),r>2&&this.l.log(r>500?"warn":r>100?"info":"debug",e,{elapsedMs:r})}},t.elapsed=function(e){const t=Date.now(),r=e();return{elapsedMs:Date.now()-t,result:r}},t.thenElapsed=async function(e){const t=Date.now(),r=await e;return{elapsedMs:Date.now()-t,result:r}}},23467:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const i=r(50357),n=r(55835),s=r(68708);var o=r(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return o.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,i.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,i.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,n.map2Or)(await e,await t,i.eql,(()=>!1))},t.eqlPicked=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))},t.eqlOmit=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.omit)(e,...r),(0,s.omit)(t,...r))},t.eqlAsyncPicked=async function(e,t,...r){return(0,n.map2Or)(await e,await t,((e,t)=>(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))),(()=>!1))}},62344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(31586),a=r(54993),l=r(77377),u=r(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,o.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,o.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,n.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const r of this.expireListeners)r(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[i.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const r of this.expireListeners)r(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,n.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const r of this.expireListeners)r(e,t)}const r=this.priorCache[e];if(void 0!==r&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,r)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const r=this.currentCache[t]??this.priorCache[t];null!=r&&e(t,r)}}deleteIf(e){for(const t of this.keys()){const r=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=r&&e(t,r)&&this.delete(t)}}get(e){return e=(0,a.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,a.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,a.toS)(e),this.has(e))return this.get(e);const r=t();return this.set(e,r),r}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,o.isNumber)(e.__uid)&&(0,o.isNumber)(e.__start)}},80049:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=r(31586),d=r(85556),h=r(54993),f=r(54557),m=r(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,i.set(this,0),n.set(this,0),s.set(this,0),o.set(this,0),a.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,i,l(this,i,"f")+e.cacheHitsSync,"f"),u(this,n,l(this,n,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,o,l(this,o,"f")+e.rejections,"f"),u(this,a,l(this,a,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,i,"f"),cacheHitsAsync:l(this,n,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,o,"f"),timeouts:l(this,a,"f")}}has(e){return this.cache.has(e)}get_(e){var t,r,o,a;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,n,(r=l(this,n,"f"),++r),"f"),c.promise):(u(this,i,(o=l(this,i,"f"),++o),"f"),c.value)}if(c instanceof Error)throw c;return u(this,i,(a=l(this,i,"f"),++a),"f"),c}get(e){var t,r;const n=this.cache.get(e);return null==n||n instanceof m.Deferred&&n.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,i,(r=l(this,i,"f"),++r),"f"),n instanceof m.Deferred?n.value:n}clear(){this.cache.clear(),u(this,i,0,"f"),u(this,n,0,"f"),u(this,s,0,"f"),u(this,o,0,"f"),u(this,a,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const r=this.get(e);if(null!=r){if(r instanceof Error)throw r;return r}return this.set(e,t())}getOrSetAsync(e,t){const r=(0,h.toS)(e);{const e=this.get_(r);if(null!=e)return e instanceof m.Deferred?e.promise:e}const i=new m.Deferred(this.opts.name).observe(t());return this.cache.set(r,i),(0,c.gt0)(this.opts.timeoutMs)&&i.setTimeout(this.opts.timeoutMs),i.promise.then((e=>{this.set(r,e)}),(e=>{var t,i;this.cache.set(r,e),u(this,o,(t=l(this,o,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,a,(i=l(this,a,"f"),++i),"f")})),i.promise}},i=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap},54127:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class i{constructor(e){this.maxSize=e,this[r]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(r=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=i},53507:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(31586),a=r(68708),l=r(50213),u=r(68852),c=r(81168),d=r(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,i.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,r=!0){return new m(e,t,r).entries};class m{constructor(e,t,r=!0){this.warnIfMissingHeaders=r,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const i=(0,o.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,n.range)(0,i).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,a.fromEntries)(e))).filter((e=>(0,a.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let r=e;r!==t;t>e?r++:r--)if(this.blankColumns.has(r))return r;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),r=[];let i,a=0;for(;null!=(i=t.exec(this.headerRow));){const l=this.headerRow.substring(a,i.index);(0,s.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:i.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(i.index,t.lastIndex),d=i.index+((0,c.indexOfNonSpace)(u)??0),h=i.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:i,left:d,right:h});else{const e=(0,n.last)(r);if(r.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,o.max_)(e?.rightIdx,i.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}a=t.lastIndex}const l=(0,n.last)(r);return null!=l&&((0,s.blank)(this.headerRow.slice(a))?l.rightIdx=(0,o.max_)(...this.rows.map((e=>e.length))):l.rightIdx=a),r}}t.Fixed=m},73913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const i=r(51455),n=r(98553);var s=r(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const r=(0,n.parseJSON)(e);return null==r?void 0:t(r)},t.readJson_=async function(e){return(0,n.parseJSON)((await(0,i.readFile)(e)).toString())}},19851:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const o=r(57975),a=r(40958),l=r(50357),u=r(31586),c=r(65812),d=r(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),i.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,i,"m",n).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,a.isEmpty)(this.watchers))return;const r=await e,i=await t;if(!(0,l.eql)(r,i))for(const e of this.watchers)e(i);null!=this.ttlMs&&this.ttlMs>0&&void 0!==i&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(42659),a=r(50213),l=r(81168),u=r(5916),c=r(56519),d=r(84777),h=r(44198),f=r(6012),m=r(43334),p=r(24399),g=r(63870);t.DefaultLocale="en";const y=(0,i.lazy)((()=>(0,a.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?E():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,i.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const r=w.exec(e.trim())?.groups;return null==r?void 0:(0,n.compact)([r.lang,r.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const _={timeoutMs:10*o.secondMs};async function E(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return b(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=E,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},50213:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const i=r(19851),n=r(32105),s=r(14593);t.rootLoggers=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));const o=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,o)}},9103:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const i=r(98553),n=r(54557);t.memoize=function(e,t){let r=0;const s=new n.FifoCache(t.maxSize,t.ttlMs),o=t=>{if(null!=t)return r++,s.getOrSet((0,i.stringify)(t),(()=>e(t)))};return o.clear=e=>null==e?s.clear():s.delete((0,i.stringify)(e)),o.size=()=>s.size,o.callCount=()=>r,o}},7282:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const n=i(r(1708)),s=r(38639),o=r(54993),a=r(19851),l=r(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,a.lazy)((()=>n.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,o.toS)(n.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return n.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(n.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){n.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(55835),a=r(31586),l=r(39926),u=r(54993),c=r(20014);var d=r(31586);function h(e,t){return(0,a.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(a.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,a.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,r){return(0,o.orElse)(h(e,t),r)},t.mapGte0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>=0?t(r):void 0},t.mapGt0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>0?t(r):void 0},t.mapGt0=function(e,t){const r=(0,a.toInt)(e);return null!=r&&r>0?t(r):void 0},t.map2Gt0=function(e,t,r){const i=(0,a.toInt)(e),n=(0,a.toInt)(t);return null!=i&&i>0&&null!=n&&n>0?r(i,n):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,a.isNumber)(e))return e;if((0,n.blank)(e))return;const t=String(e);return(0,o.map)(f.exec(t),(e=>(0,a.toFloat)(t.substr(e.index))))}function p(e){return(0,a.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const r=[e,t].map((e=>e.toString(2))),i=Math.max(...r.map((e=>e.length)));return r.map((e=>(0,l.leftPad)(e,i,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let r=0;for(let i=0;ie/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,r){this.store[e*this.columns+t]=r}},t.hammingDistanceBigInt=function(e,t){return(0,o.map)(g(e,t),(([e,t])=>(0,i.count)([...e],((e,r)=>e!==t.charAt(r)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,o.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,i.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,r){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let i=0;const n=r*e.length;for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const i=r(40958),n=r(42659),s=r(96249),o=r(55835),a=r(31586),l=r(68708),u=r(34666),c=r(41583),d=r(48884),h=r(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,n.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const r={};for(const[i,n]of(0,l.entries)(e)){const e=t(i,n);null!=e&&(r[i]=e)}return r}t.definedThunks=function(...e){return e.every((e=>(0,o.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const r of e){const e=r();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(o.defined)},t.firstDefinedField=function(e,...t){return(0,o.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(r=>t(r,e[r])?e[r]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,r){if(null!=e)return t(e);throw new Error(r)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,o.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,i.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[r,i]of m(t))null==e[r]&&(e[r]=i);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[r,i]of(0,l.entries)(t))null==e[r]&&(e[r]=i);return e},t.pickMap=function(e,t,r){const i={};for(const n of t)i[n]=r(n,e[n]);return i},t.mapEntries=p,t.mapNullEntries=function(e,t,r){const i={};let n=0;for(const s of(0,l.keys)(e))if(i[s]=t(s,e[s]),n++,(0,a.gt)(n,r))break;return i},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const r={};for(const i of(0,h.sortIgnoreCase)((0,l.keys)(t)))r[i]=e(t[i]);return r}return t},t.deepDelete=function e(t,...r){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...r))):p(t,((t,i)=>r.includes(t)?void 0:e(i,...r)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const r of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[r])return e[r]}},t.pairToObject=function(e,t){const r={};return r[e]=t,r},t.zipPojos=function(...e){const t={};for(const r of(0,i.uniq)((0,s.flatten)(e.map(l.keys))))t[r]=e.map((e=>e?.[r]));return t}},12801:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const n=i(r(48161)),s=r(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:n.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:n.default.constants.priority.PRIORITY_NORMAL,BelowNormal:n.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:n.default.constants.priority.PRIORITY_LOW,Low:n.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const i=r(41400),n=r(56409),s=r(31586),o=r(22911),a=r(73614),l=r(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:r,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...i){f=!0,m=Date.now()+(0,s.max_)(t,r);const n=d=new o.Deferred(c);(0,s.gt0)(r)&&n.setTimeout(r);try{n.resolve(await e(...i))}catch(e){n.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,a.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return n.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,i.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new n.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const i=r(68708),n=r(54993);function s(e){return e instanceof o?e.source:(0,n.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const r=[];if(!e.global)throw new Error("must provide global regex");let n;for(;null!=(n=e.exec(t));)n.index===e.lastIndex?e.lastIndex++:r.push((0,i.pick)(n,"index","groups"));return r},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,r){const i=[];for(const t of e)try{i.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{i.push(s(t))}const n=0===i.length?t.NothingRegExp:i.map((e=>"(?:"+e+")")).join("|");return new RegExp(n,r)};class o{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=o;class a extends o{static from(...e){const t=l(e);return new a("(?:"+t.source+")?",t.flags)}}function l(e,t){let r="",i=t?.includes("g")??!1,a=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof o||t instanceof RegExp?(r+=t.source,i||(i=t.global),a||(a=t.ignoreCase),l||(l=t.multiline)):r+=s((0,n.toS)(t));return new RegExp(r,t??(i?"g":"")+(a?"i":"")+(l?"m":""))}t.RegExpOptional=a,t.concatRegexp=l},79089:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const n=i(r(48161)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(42659),u=r(41400),c=r(96249),d=r(31586),h=r(51926),f=r(54993),m=r(50213),p=r(12801),g=r(22277),y=r(84777),v=r(34102),w=r(43334),S=r(24399),b=r(28874),P=(0,o.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,o.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,a.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let E=!0;const M=(0,o.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const r=(0,p.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[r]),E)try{return n.default.setPriority(e,t),t}catch(r){const i=-13===r?.errno||"EACCES"===r?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:i,error:r}),i)return;E=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,r):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[r]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+r),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const n=i(r(1708)),s=r(19851),o=r(40958),a=r(5670),l=r(54993),u=r(7282),c=r(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===a.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===a.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===a.ServiceNames.sync}function p(){return(0,t.serviceName)()===a.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,o.compactBlanks)([t.serviceName.prior(),(0,l.toS)(n.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return a.ServiceNames.indexOf(e)??a.ServiceNames.length+1},t.MainServices=[a.ServiceNames.main,a.ServiceNames.desktop],t.DbServices=[a.ServiceNames.sync,a.ServiceNames.info,a.ServiceNames.web,a.ServiceNames.list,a.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[a.ServiceNames.sync,a.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===a.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===a.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,s.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const i=r(59455);function n(e){return e instanceof Set?e:new Set((0,i.toA)(e))}t.asSet=n,t.setEql=function(e,t){return(0,i.toA)(e.keys()).every((e=>t.has(e)))&&(0,i.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,r){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),r())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const r=n(t);return new Set([...e].filter((e=>r.has(e))))},t.diff=function(e,t){const r=n(t);return new Set([...e].filter((e=>!r.has(e))))}},12089:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=r(98553),d=r(34666),h=r(54993),f=r(62344),m=r(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,r,o){super(),i.add(this),this.impl=t,this.cache=r,this.toKey=o,n.set(this,void 0),s.set(this,void 0),l(this,n,e,"f")}async _call(e){return null==this.cache?u(this,i,"m",a).call(this,e):this.cache().getOrSetAsync(u(this,i,"m",o).call(this,e),(()=>u(this,i,"m",a).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,i,"m",o).call(this,e))}}n=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},a=function(e){return(0,m.time)(u(this,n,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const i=r(42659);t.ShortCommandTimeoutMs=7*i.secondMs},92322:function(e,t,r){var i,n=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=r(76790),o=r(17586);class a{constructor(e,t){this.valueOf=e,this.diff=t,i.set(this,[])}[(i=new WeakMap,Symbol.iterator)](){return n(this,i,"f")[Symbol.iterator]()}get length(){return n(this,i,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,r=n(this,i,"f").length-1;for(;t<=r;){const s=t+Math.floor((r-t)/2),o=this.valueOf(n(this,i,"f")[s]);if(e===o)return{found:!0,index:s};e>o?t=s+1:r=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&n(this,i,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:r}){if(t>=this.length)return[...n(this,i,"f")];const o=t=>t<0||t>n(this,i,"f").length-1?null:(r??this.diff)(n(this,i,"f")[t],e),a=this.findIndex(e);if(null==a)return;let l=a.index-1,u=o(l),c=a.index,d=o(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return n(this,i,"f").shift()}at(e){return(0,o.at)(n(this,i,"f"),e)}toA(){return[...n(this,i,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===n(this,i,"f").length-1){const e=[...n(this,i,"f")];return n(this,i,"f").length=0,e}return n(this,i,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return n(this,i,"f").splice(e,t)}retainLastN(e){return e{Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},82328:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const i=r(1708),n=r(95705);t.stdoutEnded=function(){return(0,n.streamEnded)(i.stdout)}},71567:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const n=i(r(1708)),s=r(22573),o=r(98553),a=r(23560),l=r(82328),u=r(38835),c=r(70025),d=r(95705);function h(e,t){return f({obj:e,ready:t,stream:n.default.stdout})}function f({obj:e,ready:r,stream:i}){if(null==i||(0,d.streamEnded)(i))return;const n=(0,o.stringify)(e,void 0,(0,a.isInfoService)()||(0,a.isMainService)()?2:void 0);i.write(n+"\n"),(0,a.isWorkerService)()&&null!=r&&(n.includes(u.FailStr)||(0,c.isFatalError)(n)||(0,c.isHealthCheckError)(n)?i.write(u.FailStr+"\n"):i.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||n.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:n.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const r of e)r.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(55835),a=r(31586),l=r(39926),u=r(34666),c=r(51926),d=r(59455),h=r(54993),f=r(48884),m=r(68852),p=r(38835);var g=r(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=r(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=r(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,r){if(0===r.length)throw new Error("rightPad() given empty pad");const i=String(e);return i+(0,l.padding)(r,t-i.length)},t.padReplace=function(e,t,r,i){return(0,c.strslice)(e,0,t)+(0,l.padding)(i,r)+(0,c.strslice)(e,t+r)},t.contains=function(e,t,r){return(0,h.toS)(e).indexOf((0,h.toS)(t),r)>-1},t.countChars=function e(t,r,i=0){if(null==r||0===r.length)return 0;const n=t.indexOf(r,i);return-1===n?0:1+e(t,r,n+r.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,r){const i=Math.min(Math.ceil(e.length/t),r??e.length)-1;return i<=0?[e]:[...(0,a.times)(i,(r=>e.slice(r*t,(r+1)*t))),e.slice(i*t)]},t.spliceCapture=function(e,t){const r=t.exec(e);if(null==r||null==r[1])return;const i=r[0].indexOf(r[1])+r.index;return{captured:r[1],uncaptured:e.substring(0,i)+e.substring(i+r[1].length),unmatched:e.substring(0,r.index)+e.substring(r.index+r[0].length),matchedIndex:i}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,r={}){if(null==t)return e;const i=(0,h.toS)(e),n=(0,h.toS)(t);return n.length>0&&(0,c.equalsIgnoreCase)(i.slice(-n.length),n,r)?i.slice(0,-n.length):i},t.gist=function(e,t=80,r=80){const i=(0,h.toS)(e),n=i.length-(t+r);return n<=0?i:i.slice(0,t).trim()+" …(+"+n+" chars)…"+i.slice(-r).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const r=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===r?e.localeCompare(t):r}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,i.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,o.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const r=S(e.cmp[0],t.cmp[0]);return 0!==r?r:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,i.isEmpty)(e)||(0,s.blank)(t))return;for(const r of e)if((0,c.equalsIgnoreCase)(r,t))return{index:0,match:r};for(const r of e){const e=t.indexOf(r);if(e>=0)return{index:e,match:r}}const r=t.normalize();for(const t of e){{const e=r.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=r.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=r.toLowerCase(),i=e.toLowerCase(),n=t.indexOf(i);if(n>=0)return{index:n,match:i}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function E(e){return _.reduce(((e,[t,r])=>e.replace(t,r)),e).normalize()}t.dumbquote=E;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(E(e))&&(e=e.slice(1,-1).trim())),e};const C=/^['‘’].*['‘’]$/,T=/^["“”„«»〃].*["“”„«»〃]$/;function x(e,t){const r=D(e,t);return(0,f.flatZip)(r.nonSeparators,r.separators).filter((e=>null!=e&&e.length>0))}function D(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const r=[],i=[];let n,s=0;for(;null!=(n=t.exec(e));)n.index===t.lastIndex?t.lastIndex++:(t.lastIndex=n[0].length+n.index,r.push(e.substring(s,n.index)),i.push(e.substring(n.index,t.lastIndex)),s=t.lastIndex);return s(0,a.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),C.test(e)||T.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const r=(0,i.compactBlanks)(e),n=Math.max(...r.map((e=>e.length)));for(let e=0;e(0,o.map)(r[e],(e=>t+=e))));return t},t.splitKeep=x,t.splitUp=D,t.sortNaturalBy=k,t.sortNatural=function(e){return(0,n.sortBy)(e,(e=>k(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,i.compactBlanks)(e)),r=t.filter(((e,r)=>!P(t[r+1],e)));return(0,n.sortBy)(r,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const r=Math.min(e.length,t.length);for(let i=0;i4===e?.length?(0,a.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const O=/#.*$/gm;t.stripComments=function(e){return e.replace(O,"")},t.uniqPath=function(e,t=":"){const r=new Set;for(const i of(0,d.toA)(e))if(null!=i&&!(0,s.blank)(i))for(const e of i.split(t))(0,s.blank)(e)||r.add(e);return[...r].join(t)},t.dedupeNeedle=function(e,t,r){if((0,s.blank)(t))return e;const i=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),n=e.findIndex((e=>i.test(e))),o=new RegExp("("+(0,m.escapeRegExp)(r)+"[,:\\s]*){2,}","gim");if(n<0)return e;for(let t=n+1;te.trim()))))}},83556:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const i=r(54993);function n(e){return(0,i.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>"_"+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>" "+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=n,t.asObjectKey=function(e){return n(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const n=i(r(77598)),s=r(73913),o=r(55222);function a(e,t=s.HashBits){return n.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,r=o.Radix58,i=224){return r.encodeBuffer(a(e,i)).substring(0,t)}t.stringShaToBuffer=a,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,r=o.GeoRadix,i=224){return l(e,t,r,i)}},94863:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const i=r(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,i.toS)(e).toLowerCase().normalize()}},96859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(31586),a=r(39926),l=r(51926),u=r(54993),c=r(55222),d=r(97352),h=r(88158),f=r(77377),m=r(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const r=new d.Array2D(e.length);let i=0,n="";for(let s=0;s=i&&(i=r.get(s,o),n=(0,l.substr)(e,s-i+1,i)));return n}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const r=y(e,t);if(null!=r)return r;const i=e.normalize(),n=t.normalize();return e!==i||t!==n?y(i,n):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,r,i)=>r===t.charAt(i)?e:e+1),0)}function v(e,t){const r=e.toUpperCase().normalize(),i=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>r===i?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(r),t=w(i);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,r)=>e+t[r+1]))}function S(e,t){const r=(0,f.intersection)(e,t),n=[];return r.forEach((r=>{const s=Math.min((0,i.count)(e,(e=>e===r)),(0,i.count)(t,(e=>e===r)));(0,o.times)(s,(()=>n.push(r)))})),n}function b(e,t,r){const n=(0,i.commonPrefixLength)(e,t);return r((0,l.strslice)(e,n))-r((0,l.strslice)(t,n))}function P(e){const t=(0,i.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,n.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[r,i]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(r,i,(e=>(0,o.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=_;const E=/[^\da-z]+/gi;function M(e,t){const[r,i]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(E,"").toLowerCase()));return b(r,i,(e=>c.RadixAlphaNum.decode(e)))}function C(e,t){let r;for(let i=Math.max(e.length,t.length);i>=0;i--){const n=(0,o.mapNumericOr)(e.charCodeAt(i),(e=>e),256),s=(0,o.mapNumericOr)(t.charCodeAt(i),(e=>e),256),a=(0,o.clamp)(-256,256,n-s);r=null==r?a:(r+a)/2}return r}t.radixDiff=M,t.str=function(e,t){return{pref:(0,i.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,i.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=C,t.paddedPositionalDiff=function(e,t,r=8){return C((0,a.leftPad)(e,r," "),(0,a.leftPad)(t,r," "))}},84885:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const i=r(98553),n=r(88158);t.stringifySorted=function(e){return(0,i.stringify)((0,n.sortedKeys)(e))}},22277:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=r(73614);class u{constructor(e,t=!1){i.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[o]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return a(this,i,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>a(this,i,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const r=this.delegate.get(e);return null==r||a(this,i,"m",n).call(this,e,r)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,r]of this.delegate)a(this,i,"m",n).call(this,t,r)||e(t,t,this)}has(e){return null!=e&&!a(this,i,"m",n).call(this,e)}values(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield[t,t])}()}toA(){return a(this,i,"m",s).call(this),[...this.delegate.keys()]}[(i=new WeakSet,o=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,n=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const r=t<=Date.now()-this.ttlMs;if(r){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return r},s=function(){for(const[e,t]of this.delegate)a(this,i,"m",n).call(this,e,t)}},94174:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(38639),c=r(31586),d=r(50213),h=r(45255),f=r(84777),m=r(96706),p=r(43334),g=r(24399),y=(0,o.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,o.lazy)((()=>(0,a.uniq)([s.default.geteuid?.(),s.default.getuid?.(),n.default.userInfo().uid]))),t.userid=(0,o.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,o.lazy)((()=>(0,a.uniq)([s.default.getegid?.(),s.default.getgid?.(),n.default.userInfo().gid]))),t.groupid=(0,o.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,o.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,o.lazy)((()=>(0,l.toNotBlank)(n.default.userInfo()?.username))),t.userNameFromWhoami=(0,o.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,o.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,o.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,o.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.0-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=0,t.versionPrerelease=["prealpha"],t.release="2024.3.0-prealpha+20240308102353",t.gitSha="92cba1b21937cb9ca770f6a339e44b0fbee04bf9",t.gitDate=new Date(1709922233e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const i=r(42659),n=r(55835),s=r(31586),o=r(97790),a=r(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const r=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,n.allDefined)(r))return;const[o,a,u,c,d,h,f]=r,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(o,a-1,u,c,d,h,f/1e3)-m*i.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,o.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,a.within)(0,Date.now()+i.dayMs,e))).map((e=>new Date(e))).get()}},73568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class r extends Error{}t.AbortError=r},76740:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const a=r(45599),l=r(56409),u=r(73568);t.Abortable=class{constructor(){this._aborted=!1,i.set(this,void 0),n.set(this,(0,a.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,n,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,n,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,n,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),o(this,i,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,i,"f")&&clearTimeout(s(this,i,"f")),o(this,i,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},i=new WeakMap,n=new WeakMap},22911:function(e,t,r){var i,n,s,o,a,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(r(87997)),w=y(r(57975)),S=r(45599),b=r(26905),P=r(55835),_=r(31586),E=r(68708),M=r(20214),C=r(57153),T=r(85556),x=r(50213),D=r(70025),k=r(95937),O="TIMEOUT",I=(0,S.defer)((()=>(0,x.mkLogger)("async.Deferred")));class F{static async*toAsyncIterable(e,t){const r=[...e].reverse(),i=(0,_.gt0)(t)?new n(O).setTimeout(t):void 0;for(null!=i&&r.push(i);;){for(let i=r.length-1;i>=0;i--){const n=r[i];if(n.isSettled){if(n.name===O)return void I().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});r.splice(i,1),yield n.value}}if(r.every((e=>e.name===O)))break;try{await Promise.race(r)}catch{}}i?.clearTimeout()}static resolve(e,t){return new n(".resolved()",t).resolve(e)}constructor(e,t){var r,m,y;i.add(this),this.name=e,this.startedAt=Date.now(),o.set(this,void 0),a.set(this,C.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(r=n,n,(y=p(r,n,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,x.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof n&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,a,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,E.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,o,"f")}get elapsedMs(){return(p(this,o,"f")??Date.now())-this.startedAt}get[(o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,i=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new T.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,k.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,a,"f")===C.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,a,"f")!==C.PromiseStates.pending}get isResolved(){return p(this,a,"f")===C.PromiseStates.resolved}get isRejected(){return p(this,a,"f")===C.PromiseStates.rejected}get settledMs(){return null==p(this,o,"f")?void 0:p(this,o,"f")-this.startedAt}resolve(e){return p(this,i,"m",m).call(this,(()=>{g(this,a,C.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,D.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return p(this,i,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,a,C.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=F,n=F,m=function(e){if(p(this,a,"f")===C.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,o,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},s={value:0}},27395:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const i=r(19851),n=r(40958),s=r(42659),o=r(23838),a=r(13538),l=r(50213),u=r(7282),c=r(97352),d=r(77740),h=r(25764),f=r(99331),m=r(73614),p=(0,i.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new o.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const r=await e;if(null==r||!0===r?.ended)return;const i=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,r.endTimeoutMs,y);p().trace(r.name+" ending...",{timeoutMs:i});try{await(0,a.thenOrTimeoutError)(r.end(),i,(0,u.isTest)())}catch(e){try{p().warn(r.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,i.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const r=g.get(t)??[];(0,n.isNotEmpty)(r)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(r.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,n.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const r=g.get(t)??[];e[t]=r.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,r){var i,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=r(87997),h=r(55835),f=r(31586),m=r(68708),p=r(25764),g=r(38836),y=r(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,i,"m",o).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),i.add(this),this.opts=e,n.set(this,void 0),s.set(this,void 0),a.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,n,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,r=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!r&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,i,"m",o).call(this);const h=()=>{u(this,i,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,n,(0,d.setInterval)(u(this,a,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,i,"a",l)&&(u(this,a,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):h(),!0}}t.EndableInterval=v,n=new WeakMap,s=new WeakMap,a=new WeakMap,i=new WeakSet,o=function(){(0,h.map)(u(this,n,"f"),d.clearInterval),c(this,n,void 0,"f"),(0,h.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const i=r(50989);t.EndableRanks=(0,i.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const a=r(19851),l=r(45599),u=r(56409),c=r(50213),d=r(27395),h=r(25764),f=r(99331),m=r(56519);t.EndableWrapper=class{constructor(e,t,r=h.EndableRanks.first,o){this.endTimeoutMs=o,i.set(this,void 0),this.onEnds=[],n.set(this,(0,a.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,n,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(r,this)}setName(e){o(this,i,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,i,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,n,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},i=new WeakMap,n=new WeakMap},99331:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const i=r(7282);let n=!1;t.ending=function(){return n},t.setEnding=function(e){n=(0,i.isTest)()?e:e||n}},45608:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const n=i(r(1708)),s=r(22573),o=r(45599),a=r(37975),l=r(50213),u=r(71567),c=r(57159),d=r(57902),h=r(28874),f=r(27395),m=r(99331),p=r(56038),g=(0,o.defer)((()=>(0,l.mkLogger)((0,a.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,o.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const r=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==r.errno||!0===r.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const i=(0,s.toNotBlank)(e?.reason)??r.toString();for(const e of t.onFatalHandlers)await e(i)}(0,m.ending)()||(await(0,f.endEndables)(),n.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,o.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])n.default[e].on(t,(r=>{v({reason:`${e}:${t}`,status:0,error:r})}))}))},5916:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=r(50357),f=r(31586),m=r(41583),p=r(62344),g=r(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:r,timeoutMs:i}){return new y(e,t,r,i)};class y extends p.ExtensibleFunction{constructor(e,t,r,l){super(),i.add(this),this.later=e,this.desc=t,this.ttlMs=r,this.timeoutMs=l,n.set(this,void 0),s.set(this,0),o.set(this,void 0),a.set(this,[])}_call(){return this.isStale()?c(this,i,"m",u).call(this,this.later()):c(this,o,"f")}unset(){d(this,s,0,"f"),d(this,n,void 0,"f"),d(this,o,void 0,"f")}set(e){return c(this,i,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,i,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,a,"f").push(e)}prior(){return this.isStale()?void 0:c(this,o,"f")}lastValue(){return c(this,o,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,n,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,n,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,n,"f")?void 0:Date.now()-c(this,n,"f")}elapsedMs(){return c(this,o,"f")?.settledMs??c(this,o,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=async function(e,t){var r;try{const r=await t;if(!(0,h.eql)(e?.value??await(e?.promise),r))for(const e of c(this,a,"f"))await e.onChange(r)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,a,"f"))e.onError(t)}finally{d(this,s,(r=c(this,s,"f"),++r),"f")}},u=function(e){d(this,n,Date.now(),"f");const t=c(this,o,"f");return d(this,o,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,o,"f").setTimeout(this.timeoutMs),c(this,i,"m",l).call(this,t,c(this,o,"f")),c(this,o,"f")}},56519:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const i=r(40958),n=r(76790),s=r(38639),o=r(42659),a=r(41400),l=r(31586),u=r(20214),c=r(13538),d=r(42279),h=r(32639),f=r(59455),m=r(41583),p=r(48884),g=r(50213),y=r(88158),v=r(15674),w=r(42638);var S=r(20214);async function b(e){if(null==e)return[];const t=(0,i.compact)(await e);return(0,i.isEmpty)(t)?[]:(0,i.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:r,timeoutMs:n}){const s=[];for(const o of(0,i.compact)(await t))try{const e=await((0,l.gt0)(n)?(0,c.thenOrTimeoutError)(r(o),n):r(o));null!=e&&s.push([e,o])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:o,error:t})}return s}async function E({arr:e,f:t,name:r,maxConcurrent:n,timeoutMs:s,promises:o}){if(null==e)return[];const a=(0,i.compact)(await e);if((0,i.isEmpty)(a))return[];if((n=Math.round(n??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:r,timeoutMs:s});const u=o??(a.length<=n?w.PermissivePromises:new w.Promises(r,(()=>n))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,h=await u.enqueueAll(r,a.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(r).warn("failed to apply",{ea:e,error:t})}})));return(0,i.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,r){const i=[];for(const n of(0,p.batches)((0,f.toA)(await e),t)){const e=await b(n);i.push(...await b(r(e)))}return i},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,a.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const r of(0,i.compact)(e)){const e=await r();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;if(null!=e)if(Array.isArray(e))for(const r of e){const e=await r;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;null!=e&&t.push(e)}return(0,i.uniq)(t)},t.asyncFind=async function(e,t){for(const r of e)if(await t(r))return r},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=E,t.mapAsync=async function({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s}){return(await E({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:r,maxConcurrent:n,timeoutMs:s}){return(await E({name:e,arr:(0,i.compact)(t),f:r,maxConcurrent:n,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const r=await E({name:"partitionAsync",arr:e,f:t});return[r.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),r.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*o.secondMs,t.tryAll=async function(e,r=(e=>console.error(e)),i=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,i)}catch(e){r((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),r=(()=>{})){let i,n=null;try{i=await((0,h.isFunction)(e)?e():e)}catch(e){n=(0,m.toErr)(e);try{await t(e)}catch{}}try{await r(n??i)}catch{}if(null!=n)throw n;return i},t.thenNot=async function(e,t=!0){if(null==e)return t;const r=await e;return null==r?t:!(0,s.isTrue)(r)},t.thenMap2=async function(e,t,r){const i=await e;if(null==i)return;const n=await t;return null!=n?r(i,n):void 0},t.thenMapOr=async function(e,t,r){const i=await e;if(null==i)return r();const n=await t(i);return null==n?r():n},t.thenMap2Or=async function(e,t,r,i){const n=await e;if(null==n)return i();const s=await t;if(null==s)return i();const o=await r(n,s);return null==o?i():o},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null==i)continue;const e=await t(i,r);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const r of e){const e=await r();if(null!=e){const r=await t(e);if(null!=r)return r}}},t.firstResolvedDefinedPromise=async function(e,t){for(const r of e)try{const e=await r();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const r of t)try{const t=await r();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:r}){const i=await E({name:e,arr:t,f:r});return(0,n.sortBy)(i,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const i=r(19851),n=r(40958),s=r(76790),o=r(42659),a=r(49769),l=r(31586),u=r(68708),c=r(42279),d=r(41583),h=r(22454),f=r(14121),m=r(50213),p=r(7282),g=r(34102),y=r(82647),v=r(25764),w=r(38836),S=r(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,r){const i=Date.now(),n=(0,l.clamp)(10*o.secondMs,o.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-i)+"ms")}),n);try{const n=await(0,c.tot)(t),s=Date.now()-i;return r?.(n,s),this.push(e,s),n}catch(t){throw this.errors.incr(e),r?.((0,d.toErr)(t),Date.now()-i),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),r=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),i=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",r.stats()],...i])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,a.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:r.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:(0,l.mapFinite)(r.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:r.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:{sumSec:(0,l.sigFigs)(r.sum/o.secondMs,3),...(0,u.omit)(r.stats(),"sum")}})),{})}}function _(e,t,r){return P.instance().time(e,t,r)}function E(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,i.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,n.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const r=Date.now(),i=t();return E(e,Date.now()-r),i},t.pushTime=E,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,r){return(0,i.lazy)((async()=>_(e,t)),r)}},42638:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(r(66261)),m=r(40958),p=r(55835),g=r(31586),y=r(42279),v=r(54993),w=r(89788),S=r(82647),b=r(15674),P=r(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){i.add(this),this.name=e,this.ee=new f.default.EventEmitter,n.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),o.set(this,[]),a.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,n,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,b.maxCpus)(),d(this,n,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,a,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,o,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,o,"f").map((e=>e.name)),pendingNames:d(this,a,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:r,serialId:n}){const s=d(this,i,"m",l).call(this,{name:e,l:t,payload:r,serialId:n});return this.laterPop(),s}enqueueAll(e,t){const r=t.map((t=>d(this,i,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(r)}serial(e,t,r){return this.enqueue({name:e,l:t,serialId:e,payload:r})}push(e,t,r){return d(this,i,"m",u).call(this,new P.Deferred(e,{payload:r}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,o,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,a,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,a,"f").length,e),r=this.runningSerialIds,n=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,o,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,a,"f").length}hasPending(){return d(this,a,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,a,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,a,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=function({name:e,l:t,payload:r,serialId:i}){const n=new P.Deferred(e,{payload:r,serialId:i});return d(this,a,"f").push({d:n,l:t}),n},u=function(e,t){const r=Date.now();return this.lastWorkTs=r,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,o,"f"),e),this.settleMsAvg.push(Date.now()-r),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,o,"f").push(e),e},t.maybeRun=function(e,t){const r=new _(e);return()=>r.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:r}){return new _(e,(0,p.map)(r,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class r extends Error{}t.RedoableError=r},4867:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const i=r(40958),n=r(34546),s=r(41400),o=r(31586),a=r(83104),l=r(85556),u=r(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:r}){let a=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>a=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>{if(a)throw new l.TimeoutError})):void 0,r?.abortPromise_().then((()=>{if(a)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:r}){let l=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>l=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>a.Timeout)):void 0,r?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let r=e=>null;t.setTimeoutHandler=function(e){r=e},t.onTimeout=function({soft:e}={}){r(e)}},73614:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const i=r(87997);t.setUnrefTimeout=function(e,t,...r){return(0,i.setTimeout)(e,Math.round(t),...r).unref()},t.setUnrefInterval=function(e,t,...r){return(0,i.setInterval)(e,Math.round(t),...r).unref()}},31562:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const i=r(38639),n=r(42659),s=r(41400),o=r(32639),a=r(31586),l=r(45255),u=r(95937);async function c(e,{timeoutMs:t,intervalMs:r,acceptable:i,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const i=r??(0,a.clamp)(10*m,l.ShortCommandTimeoutMs,(t??n.minuteMs)/5);await(0,s.delay)(i,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:i.isTrue,timeoutResult:!1})}},9727:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const n=i(r(1708)),s=r(45599),o=r(41400),a=r(50357),l=r(68708),u=r(48884),c=r(36638),d=r(44198),h=r(59958),f=r(96706),m=r(34102),p=r(19851),g=r(19043),y=r(66184),v=r(50213),w=r(7282),S=r(88158),b=r(45969),P=r(43334),_=r(28874),E=r(3790);function M(e){return C().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const C=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const r of t.names)e.add(r);for(const r of t.keys)e.add(r)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,o.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const T=["HOME","LANG","USER"],x=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],D=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?T:x),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function k(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const r of(0,_.persistedSettings)()){const i=e?r.value:r.envValue;null==i||(0,a.eql)(i,r.defaultValue)||r.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(n.default.env,(e=>M(e)||!(0,E.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=k,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:I({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let O=!1;function I({overrides:e,forceCLocale:r=!0,forWorker:i=!1}={}){const n=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...D(),...r?(0,g.childProcLocale)():{},...k(i),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(n);if((0,y.isLogged)("debug")&&!O){O=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(n).map((([e,t])=>[e,(0,E.isHiddenEnvKey)(e)?"(hidden)":t])),[r,i]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(r)),e.debug("non PS env:",(0,l.fromEntries)(i))}return n}t.childEnv=I},84777:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const n=i(r(31421)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(42659),c=r(98553),d=r(56409),h=r(31586),f=r(68708),m=r(51926),p=r(50213),g=r(7282),y=r(88158),v=r(79089),w=r(45255),S=r(22911),b=r(4867),P=r(73614),_=r(70025),E=r(57159),M=r(36868),C=r(66184),T=r(45643),x=r(95402),D=r(9727),k=(0,o.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function O(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function I(e,t=30*u.secondMs){if(null==e)return!1;k().debug("endProcess()",O(e));const r=e.pid;if(null==r||r<=0)return k().warn("endProcess(): asked to end invalid pid",O(e)),!1;if(r===s.default.pid)return k().warn("endProcess(): asked to end MY pid",O(e)),!1;if(r===s.default.ppid)return k().warn("endProcess(): asked to end my parent pid",O(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();k().debug("endProcess("+r+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,x.killPid)(r).catch((e=>{k().warn("endProcess(): kill("+r+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,T.waitForPidExit)(r,t))return k().debug("endProcess(): exitted",O(e)),!0;{x.Pids.instance()?.onKill(r);const t=e.kill("SIGKILL");k().warn("endProcess("+r+") had to resort to SIGKILL",{killResult:t}),t||await(0,x.killPid)(r,!0).catch((e=>{k().warn("endProcess(): kill("+r+",true) failed: "+e)}))}return(0,T.waitForPidExit)(r,5e3)}function F(e,r,i,n=0){const o=new Date,a=[];return(0,v.niceable)(r,i)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(n,u.secondMs)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&I(e)}),n-250)),a.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,x.addPid)({pid:e.pid,cmd:r,timeoutMs:n,ppid:s.default.pid},o)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>a.forEach(clearTimeout))),e}function A(e,t,r,i){const s=(0,D.spawnOptions)(i);return(0,C.isLogged)("trace",k().context)?k().debug("execFile()",{command:e,args:t,timeoutMs:r,opts:s}):k().debug("execFile()",{command:e,args:t,timeoutMs:r}),F(n.default.execFile(e,t,s),e,t,r)}async function N(e,t,r){const i=r.quiet??!1,n=r.ignoreStderr??!1,s=r.ignoreExitCode??!1,o=A(e,t,r.timeoutMs,(0,f.omit)(r,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===r.disconnect){try{o.disconnect?.()}catch{}return{result:"",pid:o.pid}}const u=o.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new S.Deferred(f);o.on("error",(e=>g.push(e))),o.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),o.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(o.stdin);const v=new d.Latch;null==o.stdout?v.resolve():(o.stdout.on("error",(e=>g.push(e))),o.stdout.on("data",(e=>m.push(e))),o.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==o.stderr||n?P.resolve():(o.stderr?.on("error",(e=>g.push(e))),o.stderr?.on("data",(e=>p.push(e))),o.stderr?.on("end",(()=>P.resolve()))),k().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:r.timeoutMs,halt:r.halt}),k().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt});const C=p.join("");(0,l.notBlank)(C)&&g.push(new Error(C)),!i&&(0,a.isNotEmpty)(g)&&k().warn(f+" resulted in errors:",g);const T=r.isIgnorableError??_.isIgnorableError,x=g.filter((e=>!0!==T(e)));if(x.length>0)throw 1===x.length?x[0]:new E.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:x});if(!s&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:C}}catch(e){throw k().error("stdoutResult_() failed",e),await(0,x.killPid)(o.pid,!0),e}}t.endProcess=I,t.ReniceAfterMs=(0,o.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,o.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,r,i){const s=(0,D.spawnOptions)(i);return k().debug("spawn()",{command:e,args:t,maxAgeMs:r}),F(n.default.spawn(e,t,s),e,t,r)},t.execFile=A,t.stdoutResult_=N,t.stdout_=async function(e,t,r){const i=await N(e,t,r);return k().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(i.result),meta:{cmd:e,args:t,opts:r,result:i}})}},3790:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const i=r(22573),n=r(41400),s=r(19851),o=r(28874);(0,n.later)((()=>o.Settings.sensitiveEnvRegExp.watchLater((()=>a.unset()))));const a=(0,s.lazy)((()=>{try{return new RegExp(o.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${o.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(o.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,i.blank)(e)&&a().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||o.Settings.license.includesEnvKey(e)}},41269:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const i=r(1708),n=r(31586),s=r(51926),o=r(17344),a=r(37805),l=r(84542);function u(e,t){const r=t?.maxLineLen??(0,n.toInt)(i.env.maxLineLen)??i.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:r,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,o.EditionName)()+" v"+a.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},94361:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const i=r(19851),n=r(40958),s=r(55835),o=r(31586),a=r(94174),l=r(44198),u=r(45969);function c(e,t,r){const i=(0,o.toGt0)((0,l.env)()[t]);return null==i||r.includes(i)?void 0:`WARNING: ${e} is running as ${r} but $${t}=${i}`}function d(){const e=(0,n.compactBlanks)([c("user id","PUID",(0,a.userids)()),c("group id","PGID",(0,a.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,i.lazy)((()=>{(0,u.isDocker)()&&(0,s.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},76596:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const i=r(51168),n=r(19851),s=r(22573),o=r(42659),a=r(55835),l=r(31586),u=r(68708),c=r(34666),d=r(50213),h=(0,n.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,r){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=r}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const r=(0,a.mapOr)(e,(e=>e.getTime()),(()=>0)),i=(0,a.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(r,i)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),r=Date.now();return t<=r?0:t-r},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,o.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const i=r(22573),n=r(31586),s=r(54557),o=r(91655),a=new s.FifoCache(512);function l(e){return(0,n.isNumber)(e)?e:(0,i.blank)(e)?void 0:a.getOrSet(e,(()=>(0,o.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,i.blank)(e)?void 0:u.getOrSet(e,(()=>(0,o.fmtFullDuration)((0,n.isNumber)(e)?e:l(e))))}},91655:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const i=r(51168),n=r(40958),s=r(22573),o=r(42659),a=r(31586),l=r(51926),u=r(68852),c=r(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,a.isNumber)(e))return;if((0,a.isNumber)(e))return e;if((0,a.isDigits)(e))return(0,a.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=i.Duration.fromISO(e);if(t.isValid)return t.toMillis();const r=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(r,e);if(0===d.length)return;const h=(0,n.compact)(d.map((e=>function(e,t){const r=(0,a.toFloat)(e);if(null!=r){if((0,s.blank)(t))return r;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*o.yearMs;case"weeks":case"week":case"w":return r*o.weekMs;case"days":case"day":case"d":return r*o.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return r*o.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return r*o.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return r;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,a.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:o.yearMs,s:"y"},{ms:o.weekMs,s:"w"},{ms:o.dayMs,s:"d"},{ms:o.hourMs,s:"h"},{ms:o.minuteMs,s:"m"},{ms:o.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,r=""){if(!(0,a.isNumber)(t))return;if(0===t)return"0";if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const i=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const r=Math.floor(t/e.ms);t-=r*e.ms,r>0&&i.push(r+e.s)}return i.join(r)}},84248:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const i=r(50989);t.AutoVacuumModes=(0,i.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const i=r(50989);t.CheckpointTypes=(0,i.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const i=r(50989);t.RepairModes=(0,i.strEnum)("dump","recover")},34365:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const i=r(50989);t.SynchronousModes=(0,i.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const o=s(r(76760)),a=r(40958),l=r(22573),u=r(55835),c=r(72993),d=r(19851),h=r(97352),f=r(94174),m=r(44198),p=r(96706),g=r(8769),y=r(57159),v=r(70698),w=r(64680),S=r(29882),b=r(45969),P=r(43334),_=r(28874),E=r(41692),M=r(32774),C=r(80612),T=r(32551),x=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function D(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+x(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const r of t)(0,l.blank)(r)||e.push({dir:(0,o.join)(r,".photostructure-cache"+x()),preexistingDir:r});return e}}function k(){if((0,b.isDocker)())return(0,a.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,o.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+x(),preexistingDir:M.DefaultDockerLibraryDir},...D()]);const e=(0,a.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),o.default.resolve((0,T.homeDir)(),"AppData","Local")]:P.isMac?[o.default.resolve((0,T.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,o.join)((0,T.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,r=e.map((e=>({dir:(0,o.join)(e,t),preexistingDir:e})));return r.push(...D()),r}t.tmpCacheDirs=D,t.tmpDirs=function(){return(0,C.filterDirs)({dirs:D(),desc:"tmp"})},t.cacheDirs=k,t.defaultCacheDir=(0,d.lazy)((()=>(0,C.firstDir)({dirs:k(),desc:"cache"})));const O=(0,d.lazy)((()=>{(0,E.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(I)}));function I(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{O();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=I},46292:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const i=r(19851),n=r(45969),s=r(41692),o=r(32774),a=r(10924),l=r(84373),u=r(80612);t.configDir=(0,i.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,n.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,a.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:o.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:o.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,n.isDocker)()?c:(0,a.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const i=r(66430),n=r(45969),s=r(32774);t.defaultLibraryDir=function(){return(0,n.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,n.isDocker)()&&(0,i.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const n=i(r(76760)),s=r(40958),o=r(72993),a=r(44198),l=r(96706),u=r(43334),c=r(80612),d=r(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),n.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(n.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,a.env)().XDG_DATA_HOME,(0,a.env)().XDG_CONFIG_HOME,n.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:n.default.join(e,(0,o.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const i=r(22573),n=r(96706),s=r(29882);t.envConfigDir=function(){const e=(0,n.getEnv)("PS_CONFIG_DIR");if(!(0,i.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const i=r(44652),n=r(40958),s=r(22573),o=r(66430);function a({dirs:e,desc:t}){for(const{dir:r,preexistingDir:a}of(0,n.compact)(e))if(!(0,s.blank)(r)){if((0,o.isReadWriteableDirectorySync)(r))return r;if((0,s.blank)(a)||(0,o.isReadWriteableDirectorySync)(a))try{return(0,i.mkdirpSync)(r),r}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=a,t.filterDirs=function({dirs:e,desc:t}){return(0,n.compact)(e.map((e=>a({dirs:[e],desc:t}))))}},32551:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const i=r(48161),n=r(76760),s=r(1708),o=r(19851),a=r(40958),l=r(68284),u=r(43334);t.homeDir=(0,o.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,a.compactBlanks)(e)){const e=(0,n.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,i.homedir)()}))},46296:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(55835),u=r(54993),c=r(72993),d=r(96706),h=r(45969),f=r(43334),m=r(32707),p=r(6707),g=r(49776),y=r(32774),v=r(80612),w=r(32551);function S(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:n.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,o.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>n.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,a.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),r=(0,u.toS)(t?.logDir);return(0,a.notBlank)(r)?r:b()}catch(e){return console.error("defaultLogDir_() failed",e),n.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const i=r(76760),n=r(19851),s=r(22573),o=r(44198),a=r(43334),l=r(24399),u=r(32551);async function c(){return a.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,n.lazy)((async()=>{if(a.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,n.lazy)((()=>(0,o.env)().XDG_PICTURES_DIR??(0,i.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const i=r(38639),n=r(7282),s=r(29325),o=r(44198);t.getDevEnvFlag=function(e){return!(0,n.isProd)()&&!(0,s.isPacked)()&&((0,i.toBoolean)((0,o.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,o.env)()[e]=String(t)}},34580:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const i=r(38639),n=r(44198);t.doNotTrack=function(){return(0,i.isTrue)((0,n.env)().DO_NOT_TRACK)}},44198:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const n=i(r(73024)),s=r(76760),o=i(r(1708)),a=r(19851),l=r(40958),u=r(41400),c=r(68708),d=r(76850),h=r(7282),f=r(32551),m=r(34102),p=r(53265),g=r(45969),y=r(59958),v=r(6012),w=r(96706);t.env=(0,a.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>o.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===o.default.env.PS_LICENSE||e.push((0,s.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),r={...o.default.env};for(const i of e)try{const e=(0,d.debom)(n.default.readFileSync((0,p.resolve)(i))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,i]of(0,c.entries)(s))t.test(e)||(r[e]=i)}catch(e){console.warn("env(): failed to read .env file, "+i,e)}return r})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const i=r(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,i.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const i=r(50989);t.EnvKeys=(0,i.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const i=r(22573),n=r(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const r={};if((0,i.blank)(e))return r;let s;for(const o of(0,n.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(o));){if(null==s.groups)continue;const{key:e,val:n}=s.groups;if((0,i.blank)(e)||null==n)continue;const o=n.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");r[t?e.toLowerCase():e]=o}}return r}},96706:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const n=i(r(1708)),s=r(19851),o=r(22573),a=r(38639),l=r(41400),u=r(40583),c=r(79840),d=r(83556),h=r(34102),f=r(44198),m=r(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,o.firstNotBlank)(n.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,n.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,a.isTrue)(g(e))}},98314:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const i=r(58587),n=r(19851),s=r(40958),o=r(22573),a=r(26905),l=r(96249),u=r(51926),c=r(23541),d=r(54993),h=r(89788),f=r(50213),m=r(81168),p=r(84542),g=r(41954),y=r(38835),v=r(70025),w=r(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const r=[...e.filter(c.isError).map(a.errorName),...e.map(a.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(a.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(r)))}function b(e){return(0,s.compact)(e).filter((e=>!a.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(o.notBlank)}function P(e,t){const r=(0,s.uniqSubstrings)(b(e)),i=t?.maxLen??400,n=t?.trailingChars??64,o=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(r.join(a.ErrorDelimiter)),i-o.length,n)+o.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,o.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,n.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new i.Rate,t.fatalErrorRate=new i.Rate,t.internalErrorRate=new i.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,o.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const r=(0,d.toS)(t?.[e]);if((0,o.notBlank)(r))return r}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,r=256,i=7){return(0,o.blank)(e)&&(e=t.MissingError),_(e,{maxLen:r})+" at "+(0,a.shortStack)(e?.stack,i).join("; ")}},41954:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const i=r(40958),n=r(26905),s=r(55835),o=r(54993),a=r(81168);t.describeError=function(e){const t=(0,a.stripSuffix)((0,o.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const r of e)(0,s.map)((0,n.errorErrno)(r),(e=>t.push(u.get(e)))),(0,s.map)((0,n.errorCode)(r),(e=>t.push(l[e]?.description)));return(0,i.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const i=r(40958),n=r(76790),s=r(50989),o=r(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,n.sortBy)((0,i.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(o.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const i=r(40958),n=r(38639),s=r(26905),o=r(54993),a=r(68852),l=r(73568),u=r(78656),c=r(98314),d=r(38835);function h(e){return(0,o.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const r=(0,o.toS)(e)+(0,i.compact)(t).join("");return h(r)+f(r).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,a.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const r=(0,c.errorToS)(e);return!p.test(r)&&(!!g.test(r)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,n.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const r=(0,c.errorToS)(e);return!(!r.includes("EBUSY")&&!r.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const r=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>r.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,n.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,n.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},8769:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const i=r(22573),n=r(31586),s=r(68708),o=r(7282),a=r(23560),l=r(45608),u=r(34102),c=r(28874),d=r(98314),h=r(38835),f=r(70025),m=r(57159),p=r(5012);function g(e,t){try{if((0,i.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const r=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const n=!0===r.fatal,c=!0===r.ignorable;if(!n&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),n&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",r));const h=!n||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:r}),!n||(0,o.isTest)()||(0,a.isWebService)()||(0,l.exit)({reason:r.toString(),status:r.errno??13}),n}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,n.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,a.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,n.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,n.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,r){return g(e+h.InternalErrorFlag,{cause:t,...r})}},57159:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const i=r(40958),n=r(22573),s=r(38639),o=r(26905),a=r(98553),l=r(68708),u=r(59455),c=r(41583),d=r(48884),h=r(81168),f=r(98314),m=r(38835),p=r(70025);t.toWrappedError=function(e,t){const r=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,n.blank)(r.message)||e.message.includes(r.message)))return e;const i=(0,n.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,r?.message);return new g(i??"(missing error message)",r)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,i.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,o.errorName)(t)??(0,d.first)(this.causes,o.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(o.errorCode)],o.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,o.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.path))),this.flags=t?.flags??[];const r=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??r.some(p.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(r.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(r.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(r.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let r=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const i=t?.path;return(0,n.blank)(i)||(r=(0,h.dedupeNeedle)(r,i,"file")),(0,f.joinErrorMessages)([r[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,a.stringify)(t.meta):void 0,...r.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const o=r(49769),a=r(55835),l=r(54993),u=r(22911),c=r(89788),d=r(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,i.set(this,new Map),n.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,o.getOrSet)(s(this,i,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const r=this.target.emit(e,...t),o=s(this,i,"f").get(e);return null!=o&&(o.resolve(t),s(this,i,"f").delete(e)),r}emitDebounced(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},i=new WeakMap,n=new WeakMap},34102:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const i=r(78474),n=r(19851),s=r(15197);t.ee=(0,n.lazy)((()=>{const e=new i.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const n=i(r(73024)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(65843),u=r(16287),c=r(43334),d=(0,o.lazy)((()=>s.default.geteuid?.())),h=(0,o.lazy)((()=>s.default.getgroups?.()));function f(e,t){try{return!(0,a.blank)(e)&&(n.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,n.default.constants.R_OK|n.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,n.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:r=!1,x:i=!1,processUid:n,processGid:s}){if(null==e)return!1;const o=n??d(),a=null!=s?[s]:h()??[],l=0===o,u=l||e.uid===o,f=l||a.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(r&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!i||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const r of(0,l.selfAndAncestorG)(e)){const i=await(0,u.statMaybe)(r);if(null!=i){if(!i.isDirectory())return!1;if(t){if(!p(i,e))return!1}else if(t=!0,!m(i,e))return!1}}return!0},t.access=g},21144:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const n=i(r(76760)),s=r(19851),o=r(81168),a=r(57159),l=r(43334),u=r(88561),c=r(29882),d=r(65238),h=r(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const r=(0,c.parseNativePath)((0,h.resolve)(...e)),i=await m(r.dir);for(const e of await(0,d.readdir_)(i))if((0,o.equalsIgnoreCase)(e.basename,r.base))return n.default.join(i,e.basename);throw new a.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const i=r(73024),n=r(76760);function s(e){return[...o(e)]}function*o(e){for(;e!==(0,n.dirname)(e);)e=(0,n.dirname)(e),yield e}function a(e){try{return(0,i.readdirSync)(e)}catch(e){return[]}}function l(e,t){const r=a(e);return t.every((e=>r.includes(e)))}t.ancestors=s,t.ancestorG=o,t.selfAndAncestorG=function*(e){yield e,yield*o(e)},t.childrenSync=a,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,r){var i,n,s,o,a,l=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&l(t,e,r);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(r(44652)),p=c(r(73024)),g=r(51455),y=f(r(76760)),v=f(r(1708)),w=r(46466),S=f(r(57975)),b=f(r(38522)),P=r(19851),_=r(40958),E=r(5233),M=r(22573),C=r(42659),T=r(50357),x=r(96249),D=r(98553),k=r(55835),O=r(31586),I=r(68708),F=r(97790),A=r(39926),N=r(51926),L=r(59455),R=r(54993),j=r(48884),B=r(22911),V=r(99331),z=r(56519),W=r(56038),q=r(31562),U=r(76850),H=r(70025),G=r(34102),J=r(80875),K=r(50213),$=r(70417),Y=r(43334),Z=r(81168),X=r(96859),Q=r(65162),ee=r(94174),te=r(64660),re=r(21144),ie=r(84542),ne=r(89968),se=r(20197),oe=r(88561),ae=r(50597),le=r(33456),ue=r(29882),ce=r(78133),de=r(43899),he=r(65238),fe=r(53265),me=r(17217),pe=r(16287),ge=r(68284),ye=r(66003),ve=r(27794),we=r(73428),Se=r(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new oe.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(i.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,K.mkLogger)("fs.BaseFile("+this.nativePath+")"))),n.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),o.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(n=new WeakMap,o=new WeakMap,i=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),r=await Promise.all(t.map((e=>e.shaMs())));return t[(0,j.leastIndex)(r)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const r=(0,me.isSimpleFile)(e)?e.nativePath:(0,R.toS)(e);if((0,M.blank)(r))throw new Error("BaseFile.for(): empty nativePathOrFile");const i=be().get(r);if(null!=i)return i;const n=(0,fe.resolve)(r),s=new Pe(n,t);return be().set(r,s),be().set(n,s),s}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,n,"f").unset(),h(this,o,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,z.thenMap)(this.stat(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,k.map)(this.statSync(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,n,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const r=[];for(const i of t)!0===await e(i)&&r.push(i);return r}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,z.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,i,"m",s).call(this)??await d(e=this.clearThisAndParent(),i,"m",s).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,z.thenMap)(this.children(),(async t=>{for(const r of t)await r.visitDescendants(e),await e(r)}))}async descendants(e){const t=[];t.push(...(0,L.toA)(await this.childFiles(e)));const r=await this.childDirectories();if(null==r)return t;for(const i of r)t.push(...(0,L.toA)(await i.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,O.gt0)(t))return;const r=await d(this,n,"f").call(this)??[];for(const t of r)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const i of r)if(i.isDirectory()){const r=await this._directoryEntryChild(i).someDescendant(e,t-1);if(null!=r)return r}}descendantsSync(e){const t=this.directoryEntrySync(),r=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&r.push(this.forDirectoryEntry(t))})),r}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,re.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,T.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,k.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,r)=>this.join((0,R.toS)(e),(0,A.pad2)(t+1),(0,A.pad2)(r))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,x.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,r="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(r,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,r="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(r,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,r){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(r??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,z.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,z.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,z.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,z.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,C.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,z.thenMap)(this.statTimes(),j.max)}maxStatDate(){return(0,z.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,z.thenMap)(this.statTimes(),$.min)}minStatDate(){return(0,z.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,z.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,z.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,z.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,z.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>=(0,C.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,z.thenMap)(this.mtimeMs(),(r=>Math.abs(r-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>(0,C.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,z.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,k.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,F.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,q.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*C.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,ae.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,ae.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,J.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,J.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,U.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,z.thenMap)(this.zReadFile_(e),R.toS)))}readLines(e="warn"){return(0,z.thenMap)(this.readTextFile(e),ie.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces),(0,I.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,E.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,V.ending)()?1:3,timeoutMs:0,retryDelay:C.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,i,"m",a).call(this,(0,Z.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,i,"m",a).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,i,"m",a).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const r=await this.children((async r=>!r.isNameHidden()&&t===r.size()&&r.nativePath!==e.nativePath));if((0,_.isEmpty)(r))return;const i=await e.sha();if(null!=i)for(const e of r.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===i)return e}))}firstMatchingLine(e){const t=new B.Deferred("firstMatchingLine("+this+")"),r=p.default.createReadStream(this.nativePath,{flags:"r"});return r.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),r.close()):t.maybeReject(e)})),r.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(r,(0,N.newlineRe)(),(i=>{const n=e.exec(i);null!=n&&(t.maybeResolve(n),r.close())})),t.promise}contemporary(e,t){return(0,z.thenMap2Or)(this.statTimes(),e.statTimes(),((e,r)=>{for(const i of e)for(const e of r)if((0,O.closeTo)(i,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),r=new B.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&r.setTimeout(e.timeoutMs),_e)try{const i=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(i,n)=>{try{const s=await e.f(i,(0,k.denull)(n));t(s)&&r.resolve(s)}catch(e){r.reject(e)}}));r.finally((()=>{i.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,O.gt0)(e.intervalMs)){const i=setInterval((async()=>{try{const i=await e.f();t(i)&&r.resolve(i)}catch(e){r.reject(e)}}),e.intervalMs);e.persistent||i.unref(),r.finally((()=>{clearInterval(i)}))}return r}}t.BaseFile=Pe,s=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,j.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,k.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},a=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const r=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(r.nativePath,{autoClose:!0})]),await this.unlink(),r}))},Pe.attrTTL=3*C.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},84542:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const i=r(40958),n=r(96249),s=r(51926),o=r(54993),a=r(43334);function l(...e){return(0,n.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,o.toS)(e).split((0,s.newlineRe)()))))}t.Newline=a.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(o.toS).join("\n");return a.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,i.compactBlanks)(l(...e))}},70698:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const i=r(76760),n=r(19851),s=r(50213),o=r(37805),a=r(29882),l=r(93854),u=r(17217),c=r(16287),d=r(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,n.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const r=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return r===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,i.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const r=(0,u.toNativePath_)(e);await(0,a.mkdirp_)(r),await(0,d.writeTextfile_)((0,a.joinNativePath)([r,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+o.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(45969),u=r(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,o.lazy)((()=>[...(0,a.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,n.default.join(e,"System32"),n.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const a=s(r(44652)),l=o(r(73024)),u=r(76760),c=r(57975),d=r(19851),h=r(59455),f=r(50213),m=r(81168),p=r(34102),g=r(29882),y=r(65238),v=r(14427),w=r(17217),S=r(16287),b=r(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class E{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new E(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:r,base:i}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},n=await a.stat(t);return new E(r,new P(i,n))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return E.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new E(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>E.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new E(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const r of t)r.isDirectory()&&await r.visitDescendants(e);for(const r of t)r.isFile()&&await e(r);for(const r of t)r.isDirectory()&&await e(r)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const r of t)r.isFile()&&e(r);for(const r of t)r.isDirectory()&&(r.visitDescendantsSync(e),e(r))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async r=>{!0===await e(r)&&t.push(r)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await a.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await a.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=E},20197:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const n=i(r(76760)),s=r(39926),o=r(29882),a=r(16287),l=r(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if(await(0,o.mkdirp_)(i.dir),!r.requireNumber&&await(0,a.isEmptyFile)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if(await(0,a.isEmptyFile)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)},t.ensureNewNativePathSync_=function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if((0,o.mkdirpSync_)(i.dir),!r.requireNumber&&(0,l.isEmptyFileSync)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if((0,l.isEmptyFileSync)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)}},88561:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const o=r(40958),a=r(22573),l=r(41400),u=r(68708),c=r(25764),d=r(38836),h=r(34102),f=r(80049),m=r(50213),p=r(88158),g=r(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),i.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>s(this,i,"m",n).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,o.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,i=new WeakSet,n=async function(e){if((0,a.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const i=r(73024),n=r(22573),s=r(45599),o=r(96249),a=r(68708),l=r(54993),u=r(49047),c=r(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,s.defer)((()=>{const e={};for(const[t,...r]of d)for(const i of r)e[i]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof i.Dirent?e.name:(0,l.toS)(e),r=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,n.blank)(r)?void 0:h()[r]??r}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,o.flatten)((0,a.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const r of t)if(r===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const i=r(68708),n=r(17217),s=r(16287),o=r(68284);async function a(e){return(0,i.pick)(await(0,s.stat_)((0,n.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=a,t.fileStats=async function(e){try{return await a(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,o.statSync)((0,n.toNativePath)(e)))?void 0:(0,i.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},4001:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const i=r(22573),n=r(55835),s=r(31586),o=r(51926),a=r(54993),l=r(97352),u=r(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,i.toNotBlank)(e.name)??(0,a.toS)(e),t).normalize()}function f(e,r){if(t.ymdIsoRE.test(e))return e;let i=e;for(const e of r.aggressive?d:c){const t=i.match(e);if((0,s.gt0)(t?.index)){const e=i.slice(0,t.index).trim();e.length>0&&(i=e)}}return e===i?e:f(i,r)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),r=t.pop();if((0,i.blank)(r))return e;const n=(0,u.parsePosixPath)(r),s=h(n,{aggressive:!1});return[...t,s+n.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,o.isString)(e)?e:e.name).toLowerCase().normalize(),r=h(t),i=(0,o.stripPrefix)(t.toLowerCase().normalize(),r);return(0,n.map)((0,l.extractInt)(i),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,o.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,n.map)(m.exec(t),(e=>t=e[1].trim())),(0,n.map)(g.exec(t),(e=>t=e[1].trim())),t}},50597:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const n=i(r(77598)),s=i(r(73024)),o=r(46466),a=r(19851),l=r(98553),u=r(68708),c=r(23467),d=r(80049),h=r(73913),f=r(50213),m=r(12089),p=r(37628),g=r(43624),y=r(17217),v=r(16287),w=(0,a.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),S=(0,a.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:r=!0}={}){const i=(0,y.toNativePath_)(e);if(r){const t=S().get(i);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:i,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:i,prior:t}),S().delete(i)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),r=(0,y.toNativePath_)(e);return{sha:await _(s.default.createReadStream(r)),stats:(0,u.pick)(await(0,v.stat_)(r),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],r="sha512"){const i=n.default.createHash(r);return await(0,o.pipeline)([e,...t,i]),i.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return n.default.randomBytes(h.HashBits/8).toString("base64")}},25675:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const i=r(22573),n=r(54993),s=r(7282),o=r(43334),a=r(69375),l=/^\/dev(?:\/|$)/i,u=o.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=o.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=o.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=o.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,n.toS)(e))}function m(e){return(0,i.blank)(e)?"blank":(0,a.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},33456:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const i=r(57075),n=r(51926),s=r(54993);class o extends i.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,r){const i=(this._prior+(0,s.toS)(e)).split((0,n.newlineRe)()),o=i.pop();this._prior=o??"";let a=!1;for(const e of i)a||(a=!this.push(e));a?setTimeout(r,1):r()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=o},64680:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const n=i(r(76760)),s=r(17217),o=r(73428);t.mkNoMedia_=function(e){return(0,o.writeTextfile_)(n.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},29882:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(5233),u=r(22573),c=r(98553),d=r(39426),h=r(51926),f=r(48884),m=r(50213),p=r(81168),g=r(70025),y=r(43334),v=r(78133),w=r(53265),S=r(17217),b=r(16287),P=r(66430),_=r(5545);function E(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,o.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=E,t.containsHiddenPathname=function(e){return k(e).some(E)},t.isNotHiddenPosixPath=function(e){return k(e).every((e=>!E(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return C((0,v.posix2native)(e))},t.extname=function(e){return C(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function C(e){const t=M.exec(e)?.groups,r=t?.ext2??"",i=s.default.parse(t?.path??e);return{...i,ext:(i.ext??"")+r,base:(i.base??"")+r}}function T(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,s.default.sep)}function x(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),r=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(r))return!1;const i=e.acceptSelf??!1;return t===r?i:r.startsWith((0,p.ensureSuffix)(t,s.default.sep))}catch(r){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:r}),!1}}function D(e,t,r){if(null==t||null==r)return!1;const i=e(t),n=e(r);return null!=i&&null!=n&&(y.isLinux?i===n:(0,p.equalsIgnoreCase)(i,n))}function k(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function O(e){return(0,u.notBlank)(e)&&k(e).length===(y.isWin?1:0)}function I({p:e,maxLength:t}){const r=(0,S.toNativePath_)(e);if(r.length<=t)return r;const i=k(e),n=[],s=[i.pop()];for(;i.length>0;)if(n.length=t){i.unshift(n.pop());break}}else if(s.unshift(i.pop()),A([...n,...s]).length>=t){i.push(s.shift());break}return i.length>0&&n.push("…"),A([...n,...s])}function F(e){return e.startsWith("\\\\")}function A(e){return(0,h.ensurePrefix)((0,a.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=C,t.parentBasename=T,t.grandParentBasename=function(e){return T(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=x,t.eqlBasename=function(e,t){return D(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return D(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return D(S.toNativePath_,e,t)},t.toPathnames=k,t.pathIsRoot=O,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:k(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const r=(0,S.toNativePath_)(e),i=(0,S.toNativePath_)(t);if((0,u.blank)(r)||(0,u.blank)(i))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return r===i?"":(0,p.stripPrefix)((0,v.native2posix)(i).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(r),"/").normalize()).normalize()},t.ellipsizePath=I,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:r=4,arrLength:i=e.length}){const n=[];for(const i of e.slice(0,r))n.push(I({p:i,maxLength:t}));return n.join(", ")+(i>r?`, and ${i-r} more…`:"")},t.posixPathFromParent=function(e){return k(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return k(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const r=C(e);return`${r.base}${t}${r.ext}`},t.isUNC=F,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(F(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(O(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await n.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;n.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>n.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=A,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:A(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>x({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(31586),u=r(51926),c=r(12168),d=r(59455),h=r(54993),f=r(50213),m=r(44198),p=r(96706),g=r(45969),y=r(43334),v=r(64660),w=r(21144),S=r(16287),b=(0,s.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const r=await(0,S.statMaybe)(e,"trace");return null!=r&&r.isFile()&&(0,l.gte)(r.size,t)&&(0,v.isStatRX)(r,e)}function E(){if(y.isWin){const e=(0,a.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,a.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",r=(0,a.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,n.default.join(e,"System32"),n.default.join(e,"System32","Wbem"),n.default.join(r,"chocolatey","bin"),n.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(n.default.delimiter);return(0,o.uniq)((0,o.compactBlanks)([...e,...E()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:r}){const i=(0,o.uniq)((0,o.compactBlanks)([...M(),...(0,d.toA)(r)]));for(const r of(0,o.uniq)((0,o.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(r,".exe"):r;for(const t of i){const r=n.default.join(t,e);if(await _(r))return y.isLinux?r:(0,w.actualPath)(r)}}b().warn("Failed to find tool",{tool:e,dirs:i})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},78133:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const n=i(r(76760)),s=r(22573),o=r(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(n.default.sep===n.default.posix.sep)return e;const r=(0,s.notBlank)(t)?n.default.sep+n.default.sep+t+n.default.sep:"",i=e.split(n.default.posix.sep);return(0,o.equalsIgnoreCase)(i[0],t)&&i.unshift(),r+i.join(n.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||n.default.sep===n.default.posix.sep||n.default.posix.sep===n.default.sep?e:e.split(n.default.sep).join(n.default.posix.sep)}},43899:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(48884),u=r(50213),c=r(45969),d=r(29325),h=r(43334),f=r(65843),m=r(25675),p=r(53265);function g(...e){return(0,o.lazy)((()=>n.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,o.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(n.default.join((0,p.execDir)(),"resources"),n.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,a.compactBlanks)([(0,p.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const r of t){if((0,f.hasChildrenSync)(r,e))return r;for(const t of(0,f.ancestors)(r).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const i=n.default.join(r,"node_modules","photostructure");if((0,f.hasChildrenSync)(i,e))return i}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const i=r(44652),n=r(19851),s=r(31586),o=r(50213),a=r(57902),l=r(69428),u=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=a.LogLevels.info){try{return await(0,i.readFile)(e)}catch(r){return void u().log(t,".readFileMaybe("+e+")",r)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const i=r(44652),n=r(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:r}){let s=-1;try{const n=r??(await(0,i.stat)(e)).size-t,o=Buffer.alloc(n);return s=await(0,i.open)(e,"r"),await(0,i.read)(s,o,0,n,t)}finally{(0,n.mapGte0)(s,i.close)}}},69428:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const o=s(r(73024));t.readFileSync=function(e){try{return o.readFileSync(e)}catch{}}},32323:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const i=r(57075);class n extends i.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=n},65238:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const n=i(r(51455)),s=r(76760),o=r(19851),a=r(76790),l=r(22573),u=r(42659),c=r(41400),d=r(31586),h=r(13538),f=r(83104),m=r(54127),p=r(50213),g=r(95937),y=r(34102),v=r(28874),w=r(63870),S=r(88561),b=r(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,o.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,o.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await n.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const E=(0,o.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||E.prior()?.delete(e)}async function C(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await E().getOrSetAsync(e,(()=>async function(e){const r=Date.now()+2*(0,b.statTimeoutMs)(),i=T(e),n=await(0,h.thenOrTimeout)(i,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(n===f.Timeout&&(0,g.onTimeout)({soft:!1}),n!==f.Timeout&&n.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),E.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,o.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!E().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=E().get(e)},t.childDirectories_=async function(e){return(await C(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?C(e):T(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=C,t.readdirCached=function(e){return E().get(e)},t.readdirUncached_=T},53265:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const n=r(73024),s=i(r(76760)),o=r(40958),a=r(22573),l=r(45599),u=r(50213),c=r(43334),d=r(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,o.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const r=s.default.resolve(t,...e);if((0,n.existsSync)(r))return r}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,a.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(a.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},50274:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const i=r(50989);t.SidecarExts=(0,i.strEnum)("xmp","mie","exv")},14427:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const i=r(22573),n=r(38639);t.isSimpleDirent=function(e){return null!=e&&(0,i.notBlank)(e.basename)&&(0,n.isBoolean)(e.isFile)&&(0,n.isBoolean)(e.isDirectory)}},17217:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const n=i(r(73024)),s=i(r(76760)),o=r(22573),a=r(98553),l=r(81168),u=r(43334),c=r(29882),d=r(53265),h=r(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,o.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,o.blank)(e.nativePath))throw new Error(`toNativePath(${(0,a.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof n.default.Dirent?e.name:f(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:s.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),r=t.indexOf(s.default.sep);return r>0?t.slice(1,r):void 0}},t.findFileIndex=function(e,t){for(let r=0;r(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,a.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(n.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,a.blank)(e)?void 0:v(e).catch((r=>{y().log(t,"stat() failed",{error:r,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const r=S(e),i=S(t);if(r!==i)return"inconsistent file type: "+r+" ≠ "+i;for(const r of["size","mtime"]){const i=e[r],n=t[r],s=(0,u.diff)(b(i),b(n));if(null==s||s>1)return"unmatched "+r+": "+i+" ≠ "+n}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const r=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=r&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(r)},t.isNonEmptyFile=async function(e,t=0){const r=await w(e);return null!=r&&r.isFile()&&r.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.access)({stat:r,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.isStatRWX)(r,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,o.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const n=i(r(73024)),s=r(22573);function o(e){try{return(0,s.blank)(e)?void 0:n.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function a(e){return null==e||e.isFile()&&0===e.size}t.statSync=o,t.isEmptyStats=a,t.isFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const r=o(e);return t.emptyIsNew?null==r:a(r)},t.isNonEmptyFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isDirectorySync=function(e){return!0===o(e)?.isDirectory()}},41080:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const i=r(28874);t.statTimeoutMs=function(){return i.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const i=r(22573),n=r(56409);t.onDataChunked=function(e,t,r){const i=new s(t,r,!0);return i.read(e),i.done};class s{constructor(e,t,r=!0){this.sep=e,this.onData=t,this.filterBlanks=r,this.incompleteChunk="",this.done=new n.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,i.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,i.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const n=i(r(57075)),s=r(41400),o=r(55835),a=r(68708),l=r(42279),u=r(99331),c=r(70025);class d extends n.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((r,i)=>{!1===e.write(t,(e=>{e&&i(e)}))?e.once("drain",r):r()}))},t.endStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,a.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:r,ea:i}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,o.map)(i,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(r,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends n.default.Transform{constructor(e){super({transform:(e,t,r)=>{this.onProgress(this.bytes+=e.length),r(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const n=i(r(73024)),s=r(76760),o=r(22573),a=r(76596),l=r(64660),u=r(78133),c=r(68284);function d(e){if((0,o.blank)(e))return!1;try{return n.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,a.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,o.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,o.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,o.blank)(e)&&d((0,u.posix2native)(e))}},27794:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const n=i(r(44652)),s=r(19851),o=r(22573),a=r(42659),l=r(31586),u=r(68708),c=r(13538),d=r(29882),h=r(17217),f=r(16287),m=r(41080);function p(e){return null==e?void 0:(0,a.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const r=t.ensureFile??!0;if(null==t.file||(0,o.blank)(t.file))throw new Error("can't touch blank path");const i=(0,h.toNativePath_)(t.file);r&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const a=(0,s.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await a())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await a())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(n.default.utimes(i,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!r||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(n.default.ensureFile(i),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},5545:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const n=i(r(76760)),s=r(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const r=t.driveRe.exec(e)?.groups;return null==r?e:r.drive.toUpperCase()+(0,s.toS)(r.path??n.default.sep)}},58722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const i=r(57075),n=r(22911);class s extends i.Writable{constructor(e){super(e),this.deferred=new n.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,r){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),r()}}t.WritableToBuffer=s},73428:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(51926),a=r(54993),l=r(34102),u=r(84542),c=r(29882);async function d(e,t){const r=s.default.dirname(e);await(0,c.mkdirp_)(r),await n.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",r)}function h(e,t){const r=s.default.dirname(e);(0,c.mkdirpSync_)(r),n.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",r)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const r=(0,u.crlf)(...(0,o.wrap)(t));await d(e,r)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))}},13047:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const n=i(r(73024)),s=r(76760),o=r(46466),a=r(38522),l=r(19851),u=r(40958),c=r(98553),d=r(80875),h=r(50213),f=r(57159),m=r(29882),p=r(57902),g=r(32323),y=r(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,r){const i=[],s=[n.default.createReadStream(e,{autoClose:!0,...r}).on("error",(e=>i.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,a.createGunzip)().on("error",(e=>i.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,a.createBrotliDecompress)().on("error",(e=>i.push(e)))),s.push(t),await(0,o.pipeline)(s),(0,u.isNotEmpty)(i))throw new f.WrappedError("zPipe("+e+") failed",{causes:i,path:e})}async function b(e,t){const r=new y.WritableToBuffer;return await S(e,r,t),await r.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function _(e,t){const r=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,o.pipeline)(new g.ReadableBuffer(r),(0,a.createGzip)(),n.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(r){return void v().log(t,"readJsonGz("+e+"): failed",r)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,r=p.LogLevels.warn){try{await _(e,t)}catch(t){v().log(r,"outputJsonGz("+e+"): failed",t)}}},33866:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const i=r(50989);t.HealthCheckIds=(0,i.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},52086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const i=r(50989);t.CropStrategies=(0,i.strEnum)("center","entropy","attention")},48584:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const i=r(50989);t.SharpFailOns=(0,i.strEnum)("none","truncated","error","warning")},32105:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const i=r(19851),n=r(23560),s=r(66184),o=r(72210);class a{log(e,t,r,i){this.enabled(e,t)&&(0,o.pushLogEntries)({ts:Date.now(),l:e,from:(0,n.processName)(),ctx:t,msg:r,meta:i})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=a,a.instance=(0,i.lazy)((()=>new a))},14593:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const i=r(57975),n=r(22573),s=r(26905),o=r(55835),a=r(68708),l=r(13538),u=r(50213),c=r(97352),d=r(45255),h=r(76740),f=r(57159),m=r(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,n.toNotBlank)(e)??(0,s.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[i.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const r=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,a.omit)(t,"error")});throw Error.captureStackTrace?.(r),this.log(!0===r.ignorable?"warn":"error",".throw() "+r.message,{stack:r.stack,...t}),r}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let r;try{r=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const i=e.result(),n=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:i,meta:{...e.meta,elapsedMs:n}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,o.map)(r,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,a.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const r of this.loggers())if(r.enabled(e,t??this.context))return!0;return!1}log(e,t,r){for(const i of this.loggers())i.log(e,this.context,t,r)}elapsed(e,t,r){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...r})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},28981:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const i=r(19851),n=r(51879);t.DefaultLogFormatter=(0,i.lazy)((()=>new n.PlaintextLogFormatter))},20839:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},4904:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const i=r(76790),n=r(31586),s=r(51926),o=r(57902);t.isLogEntry=function(e){return null!=e&&(0,n.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&o.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,i.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const i=r(19851),n=r(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,n.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,n.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,i.lazy)((()=>new s(n.LogLevels.warn))),t.defaultLogLevel=(0,i.lazy)((()=>n.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,n.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,r){return(0,t.logFilter)().enabled(e)?r():void 0},t.isLogged=function(e,r){return(0,t.logFilter)().enabled(e,r)}},57902:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const i=r(42659),n=r(31586),s=r(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const o=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??o},t.levelGte=function(e,r){return(0,n.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(r))};const a=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return a.get(e)},t.msTolevel=function(e,t=7*i.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},72210:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const i=r(92322),n=r(82328),s=r(28981),o=r(20839),a=r(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new i.SortedSet(a.logEntrySorter),t.pushLogEntries=function(...e){for(const r of e)l?t.logEntries.add(r):(0,n.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(r))},t.popExpiredLogEntries=function(e=2*o.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},51879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(68708),a=r(54993),l=r(23560),u=r(81168),c=r(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,o.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,n.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,i.inspect)(e,this.inspectOptions)))]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,r,i){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:r,meta:i})}}},82647:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const o=r(57975),a=r(40958),l=r(96249),u=r(55835),c=r(31586),d=r(68708),h=r(59455),f=r(48884),m=r(89788),p=r(22454),g=r(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const r=t.clone();return r.pushAll(e.samples),r}if(t.n<=t.maxSamples){const r=e.clone();return r.pushAll(t.samples),r}{const r=new y(Math.max(e.maxSamples,t.maxSamples));r._n=e.n+t.n,r._min=Math.min(e._min,t._min),r._max=Math.max(e._max,t._max),r._m=e._m*e.n/r.n+t._m*t.n/r.n,r._s=e._s*e.n/r.n+t._s*t.n/r.n;const i=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return r._samples.push(...i),r._weightedTotalAvg=(0,g.weightedAvg)([r._m,...i]),r}}constructor(e=20){i.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(i=new WeakSet,o.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),r={};return r.k=t(this.n),this.empty||(r.mean=t(this.avg),r.sum=t(this.sum),r.sd=t(this.stdDev),r.max=t(this.max),r.min=t(this.min)),r}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,i,"m",n).call(this,-1)}get p29(){return s(this,i,"m",n).call(this,-.5)}get p38(){return s(this,i,"m",n).call(this,-.25)}get p69(){return s(this,i,"m",n).call(this,.5)}get p84(){return s(this,i,"m",n).call(this,1)}get p98(){return s(this,i,"m",n).call(this,2)}get p99(){return s(this,i,"m",n).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,a.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,a.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,a.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,n=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const i=r(40958),n=r(55835),s=r(31586),o=r(30976),a=r(48884),l=r(70417);function u(e,t){const r=Math.pow(2,t),i=[];for(;e>0;)i.unshift(e%r),e=Math.floor(e/r);return i}t.concatBits=function(e,t){const r=Math.pow(2,t);return e.reduce(((e,t)=>e*r+(0,s.clamp)(0,r,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,r){return(0,n.map2)(e,t,((e,t)=>(0,i.sum)((0,a.zip)(u(e,r),u(t,r)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,o.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max)),n=this.clampValue(e);let s=0;for(let e=0;eo?(s+=1,r[t]=o):i[t]=o}return s}unzip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max));for(let n=0;n(r[e]+i[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,r){return!0!==r&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let r=0;rs?(t+=1,n.min=s):n.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const r=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,i.sum)(e,((r,i)=>t(r,i)?Math.pow(2,e.length-i-1):0))}},55222:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const i=r(77598),n=r(22573),s=r(55835),o=r(32639),a=r(88158),l=r(81168),u=BigInt(0);function c(e,t,r=0){if(!isFinite(t)||e<=1)return[];const i=[];if(0===t)i.unshift(0);else for(;t>0;)i.unshift(t%e),t=Math.floor(t/e);for(;i.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const r=e<0;return r&&(e=Math.abs(e),t--),(r?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],r=BigInt(this.base);let i=e;for(;i>u;)t.push(Number(i%r)),i/=r;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let r of e)for(t.forEach(((e,i)=>{r+=e<<8,t[i]=r%this.base,r=Math.floor(r/this.base)}));r>0;)t.push(r%this.base),r=Math.floor(r/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,n.blank)(e))return;const t="-"===(e=(0,o.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const r=BigInt(this.base);let i=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;i=i*r+BigInt(e)}return t?BigInt(-1)*i:i}randomChars(e){return this.encodeBuffer((0,i.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,r="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(r)}tokenEql(e,t,r){const i=this.normalizeToken(e),n=this.normalizeToken(t);return i.length>=r&&i===n}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const i=r(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,i.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},70417:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const a=r(40958),l=r(55835),u=r(31586),c=r(59455),d=r(22454),h=r(77377),f=r(82647);function m(e){let t;for(const r of e)null!=r&&(null==t||rt)&&(t=r);return t}function y(e,t){const r=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&r.incr(t);return r.topKeys(t)}function v(e,t){let r=0,i=0;for(const n of e){if(null!=n){const e=t(n,r);(0,u.isNumber)(e)&&(i+=e)}r++}return i}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,r)=>e-t[r]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const r of e)(0,u.isNumber)(r)&&(t+=r);return t},t.sumf=v;class w{constructor(){i.set(this,0),n.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(o(this,n,null==s(this,n,"f")?e:s(this,n,"f")*s(this,i,"f")/(s(this,i,"f")+1)+e/(s(this,i,"f")+1),"f"),o(this,i,(t=s(this,i,"f"),++t),"f"))}get mean(){return s(this,n,"f")}}function S(e){const t=new w;for(const r of e)t.push(r);return t.mean}function b(e){const t=S(e);if(null==t)return;let r=0,i=0;for(const n of e)(0,u.isNumber)(n)&&(i++,r+=(n-t)*(n-t));return r/i}function P(e){let t=0;for(const r of e)t+=r*r;return Math.sqrt(t)}function _(e,t){let r=0;for(let i=0;i(1-t)*e+t*(r+o*(e-n)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),r=S(t);if(null!=r){const e=(t.length-1)/2,i=v(t,((t,i)=>(t-r)*(i-e))),n=v(t,(e=>(e-r)**2));return 0===n?0:i/n}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let r;t=(0,u.clamp)(0,1,t);for(const i of e)r=null==r?i:r*t+i*(1-t);return r},t.centroid=function(e){const t=e[0].length,r=[];for(let i=0;ie[i]))));return r},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,a.isEmpty)(e)&&(0,a.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},45969:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const i=r(73024),n=r(38639),s=r(19851),o=r(59958),a=r(43334);t.isDocker=(0,s.lazy)((()=>a.isLinux&&((0,n.toBoolean)(process.env[o.PS_IS_DOCKER])??(0,i.existsSync)("/.running-in-container"))))},29325:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const i=r(76760),n=r(19851),s=r(54993);t.isPacked=(0,n.lazy)((()=>!(0,s.toS)(__filename).includes((0,i.join)("core","platform","IsPacked"))))},43334:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(22573),a=r(38639),l=r(59958),u=n.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,a.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,a.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,o.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===n.default.arch(),t.isArm=null!=/^arm\b/i.exec(n.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,o.notBlank)(s.default.env.APPIMAGE)||(0,o.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,o.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,a.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const n=i(r(73024)),s=r(19851),o=r(43334);function a(e="/proc/cpuinfo"){if(o.isWin||o.isMac)return!1;try{return null!=n.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=a,t.isRaspberryPi=(0,s.lazy)((()=>o.isLinux_arm&&a())),t.procDeviceModel=(0,s.lazy)((()=>{try{return o.isLinux?n.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},45643:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const i=r(58587),n=r(59455),s=r(31562);t.existingPids=function(e){return(0,n.toA)(e).filter(i.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,i.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=r(58587),d=u(r(31421)),h=u(r(1708)),f=r(40958),m=r(22573),p=r(42659),g=r(55835),y=r(31586),v=r(97790),w=r(59455),S=r(54993),b=r(54557),P=r(19851),_=r(50213),E=r(88158),M=r(409),C=r(78406),T=r(25764),x=r(99331),D=r(56519),k=r(46292),O=r(8769),I=r(83278),F=r(32144),A=r(29882),N=r(43334),L=r(24399),R=r(58261),j=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),B=10*p.secondMs;function V(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const r=(0,g.map)(t.start,(e=>e.getTime())),i=e.startTime;return(0,y.gt0)(r)&&(0,y.gt0)(i)&&Math.abs(r-i){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,F.isJsonExt)(t)&&(0,A.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))j().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{j().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,r=e.force??N.isWin,i=await this.pidfiles(),n=await this.pids(i??[]);if((0,f.isEmpty)(n))return j().info("killOldProcs(): no pidfiles"),[];const s=[],o=[],a=await(0,R.pidInfos)(n);if(null!=a){for(const n of i){const i=await n.readJson();if(null==i){j().warn("killOldProcs(): failed to read pidfile "+n.base),await n.unlink("debug");continue}const l=i.pid;if(!(0,y.gt0)(l)){j().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+n.base,{json:i,pid:l}),await n.unlink("debug");continue}const u=a.find((e=>e.pid===l));if(null==u||!V(i,u)){j().debug("killOldProcs(): pid no longer present: unlinking "+n.base,{json:i,pidEntry:u}),await n.unlink("debug"),s.push(i);continue}const c=(0,y.gt0)(i.timeoutMs)?i.startTime+i.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(i.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(j().info("killOldProcs(): killing",{reason:d,json:i}),o.push(W(l,r,!1)),s.push({...i,...u}))}return o.length>0&&await Promise.allSettled(o),s}(0,O.onError)("Pids.killOldProcs(): failed to get process information")}}),o.set(this,void 0)}async addPid_(e,t,r=!1){if(null==e)throw new Error("undefined info");const o=e.pid;if(!(0,y.gt0)(o))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(o)?(r&&a(this,n,"f").delete(l),a(this,n,"f").getOrSet(l,(async()=>{const r=a(this,i,"m",s).call(this,e.pid),n=(0,v.opt)((0,E.Try)((()=>(0,A.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),o=t.getTime(),l={...e,cmd:n,startTime:o};return await r.writeJson_(l),j().debug("addPid() wrote "+r,l),r}))):(a(this,n,"f").delete(l),void j().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=a(this,i,"m",s).call(this,e);return(0,D.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{j().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==a(this,o,"f")||a(this,o,"f").ended)&&l(this,o,new C.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:T.EndableRanks.first}),"f"),a(this,o,"f")}cancelInterval(){a(this,o,"f")?.end(),l(this,o,void 0,"f")}}t.Pids=q,n=new WeakMap,o=new WeakMap,i=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},q.instance=(0,P.lazy)((()=>(0,g.map)((0,k.configDir)(),(e=>new q(I.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return q.instance()?.addPid_(e,t)}},58261:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const n=r(31421),s=r(48161),o=i(r(1708)),a=r(40958),l=r(22573),u=r(42659),c=r(31586),d=r(68708),h=r(59455),f=r(54993),m=r(48884),p=r(53507),g=r(19851),y=r(50213),v=r(84968),w=r(48963),S=r(56519),b=r(84777),P=r(8103),_=r(45879),E=r(43334),M=r(24399),C=r(45643),T=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function x(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function D(e){if(E.isLinux)return async function(e){const t=[];for(const r of e)t.push(z(await(0,_.readFileMaybe)("/proc/"+r+"/stat")));return T().tap({msg:"pidInfoProc",result:(0,a.compact)(t)})}(e);const t=(0,C.existingPids)(e),r=(await(0,m.collectBatchedAsync)(t,20,E.isWin?F:R)).filter((e=>x(e)&&t.includes(e.pid)));return T().tap({msg:"pidInfos()",result:r,meta:{pids:e}})}t.isProcEntry=x,t.pidInfo=async function(e){return(0,S.thenMap)(D([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,a.isEmpty)(e)?[]:(0,S.thenMap)((0,C.existingPids)(e),(t=>{const r=[o.default.pid,...t];return e.filter((e=>!r.includes(e)))}))},t.pidInfos=D;const k="Get-Process",O="| Select-Object -Property Id,ProcessName,StartTime";function I(e){return(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).join(",")}async function F(e){if(M.PowerShell.instance().ended)return L(e);const t=[k,"-Id",I(e),"-ErrorAction SilentlyContinue",O].join(" ");return(0,S.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const A={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},N=["CommandLine","CreationDate","ProcessId"];async function L(e){const t=["process"];if((0,a.isNotEmpty)(e)){const r=(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",r)}t.push("get",N.join(","));const r=await(0,b.stdoutResult_)((0,P.wmic)(),t,A),i=(0,d.onlyReqValued)((0,p.parseFixed)(N,r.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return i.find((e=>e.pid===o.default.pid))||i.push({pid:o.default.pid,start:new Date(v.StartTs),cmd:"node "+o.default.title}),i}async function R(e){return t=(await(0,b.stdoutResult_)("ps",["-p",I(e),"-wwwo","pid,lstart,command"],{...A,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=L;const j=(0,g.lazy)((()=>{try{if(E.isLinux)return(0,c.toGt0)((0,n.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){T().warn("clk_tck failed",{error:e})}return 100})),B=(0,g.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),V=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function z(e){const t=V.exec((0,f.toS)(e))?.groups,r=(0,c.toInt)(t?.pid),i=t?.comm,n=(0,c.toInt)(t?.starttime);return(0,c.gt0)(r)&&!(0,l.blank)(i)&&(0,c.gt0)(n)?{pid:r,cmd:i,start:new Date(B()+n/j()*u.secondMs),state:t?.state}:void 0}},24399:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const i=r(58587),n=r(19851),s=r(22573),o=r(42659),a=r(41400),l=r(55835),u=r(13538),c=r(36557),d=r(14121),h=r(50213),f=r(7282),m=r(45255),p=r(81168),g=r(25764),y=r(38836),v=r(99331),w=r(56519),S=r(31562),b=r(84777),P=r(34102),_=r(43334),E=r(28874),M=r(63870),C="{ready}",T=" | ConvertTo-Json -Compress";function x(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=x,(0,a.later)((()=>(0,P.ee)().on("clearCache",(()=>D.instance.prior()?.clearMockResults()))));class D extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new i.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",E.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${C}"}`,...(0,s.mapNotBlankOr)(E.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:C,fail:"Error",exitCommand:"exit",maxProcs:E.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:o.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),E.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(E.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,T),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const r=this.mockResults.get(e);return t(r.stdout,r.stderr,r.passed)}try{const r=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new i.Task(e,((r,i,n)=>t((0,l.map)(r,(t=>(0,p.stripPrefix)(t,e))),i,n)))));return this.logger.tap({msg:"execute()",result:r.result,meta:{elapsedMs:r.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,T),((e,t,r)=>({stdout:e,stderr:t,passed:r})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const r=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(r)}),JSON.parse(r)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+x(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=D,D.instance=(0,n.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new D})),t.checkPowerShell_=async function(){const e=D.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const i=r(50989);t.AggregateTypes=(0,i.strEnum)("union","intersection")},71988:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const i=r(50989);t.AssetFileSortCriteria=(0,i.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const i=r(22573),n=r(38639),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toBoolean})}}t.BooleanSetting=o},90536:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=a},75164:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(i.notBlank).flatMap(n.toInt).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,n.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=a},10546:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const i=r(50989);t.ColorDistanceFunctions=(0,i.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const i=r(36507),n=r(22573),s=r(45599),o=r(50213),a=r(81168),l=r(98314),u=r(8769),c=r(80372),d=(0,s.defer)((()=>(0,o.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,a.trimQuotes)(e);return void((0,n.blank)(t)||(0,i.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,r){try{return(0,n.blank)(t)?void 0:(0,i.Cron)(t,{name:e,unref:!0,protect:!0,catch:r=>(0,u.onError)(r,{name:e,crontab:t}),...r})}catch(r){return void d().warn("invalid cron",{name:e,crontab:t,error:r})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const i=r(70488),n=r(91655),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration})}get valueOrDefault(){return(0,i.decodeDuration)(super.valueOrDefault)}get value(){return(0,i.decodeDuration)(super.value)}set value(e){super.userValue=(0,i.decodeDuration)(e)}get humanValue(){return(0,n.fmtFullDuration)(this.value)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,i.decodeDuration)(e)}}t.DurationSetting=o;class a extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,i.decodeDuration)(this.defaultValue)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=a},9945:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.FloatSetting=o},74589:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt})}}t.IntegerSetting=o},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const i=r(22573),n=r(53265),s=r(87652);class o extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,i.blank)(e)?void 0:(0,n.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=o},23561:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.OptionalFloatSetting=o},69005:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=o},87652:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=n},28283:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const i=r(51926),n=r(83556);t.nameFromEnv=function(e){return(0,n.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,i.ensurePrefix)((0,n.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const o=r(19851),a=r(40958),l=r(79666),u=r(50357),c=r(57924),d=r(98553),h=r(55835),f=r(68708),m=r(39926),p=r(46891),g=r(42279),y=r(59455),v=r(40583),w=r(81168),S=r(44198),b=r(96706),P=r(34102),_=r(28283),E=r(81075),M=r(98778),C=r(10357);t.settingsToObj=function(e){const t={};for(const r of e)r.hasValue()&&(t[r.name]=r.value);return t},t.Setting=class{constructor(e){i.add(this),this.opts=e,this._envValue=(0,o.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,i,"m",n).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const r=this.opts.whyInvalid?.(e);return null!=r?s(this,i,"m",n).call(this,e??t)+": "+r:null==this.fromEnv(e)?s(this,i,"m",n).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const r=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=r)return r}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,a.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const r=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(r)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,a.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,a.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return E.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const r=e??(0,S.env)(),i=t??this.value;return null!=i&&(r[this.key]=this.toEnv(i)),null==e&&b.caseInsensitiveEnv.unset(),r}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const r=e??(0,S.env)(),i=this.toEnvValue(t);return null!=i&&(r[this.key]=i,null==e&&b.caseInsensitiveEnv.unset()),r}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],C.WrapComments);function r(e,r){(0,a.isEmpty)(r)||t.push(...(0,w.wrap)(["",(1===r.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(r.map((e=>(0,d.stringify)(e))))],C.WrapComments))}r("alias",this.opts.aliases),r("environment alias",this.altKeys);for(const[e,r]of(0,f.entries)(this.addToJSON())){const i=Array.isArray(r)?(0,c.orList)(r.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(r);t.push(...(0,w.wrap)(["",e+": "+i],C.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},i=new WeakSet,n=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const i=r(50989);t.SettingCategories=(0,i.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const i=r(58587),n=r(76760),s=r(19851),o=r(40958),a=r(76790),l=r(22573),u=r(42659),c=r(73722),d=r(68708),h=r(50989),f=r(12168),m=r(54993),p=r(37975),g=r(9092),y=r(40583),v=r(79840),w=r(7282),S=r(12801),b=r(4328),P=r(70488),_=r(84248),E=r(5531),M=r(99315),C=r(34365),T=r(34580),x=r(96706),D=r(50274),k=r(33866),O=r(52086),I=r(48584),F=r(45969),A=r(43334),N=r(24540),L=r(70379),R=r(71300),j=r(33209),B=r(48987),V=r(68268),z=r(61208),W=r(99023),q=r(30577),U=r(1485),H=r(19861),G=r(55111),J=r(30933),K=r(22859),$=r(71988),Y=r(38483),Z=r(90536),X=r(75164),Q=r(10546),ee=r(90967),te=r(67958),re=r(55948),ie=r(57039),ne=r(9945),se=r(74589),oe=r(844),ae=r(96093),le=r(23561),ue=r(69005),ce=r(87652),de=r(81075),he=r(58305),fe=r(57571),me=r(72564),pe=r(80372),ge=r(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new ae.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>U.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:U.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>U.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>A.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,F.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!A.isElectron}),commandTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new i.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>A.isMac?"100ms":A.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new ne.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:E.CheckpointTypes,defaultValue:E.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:C.SynchronousModes,defaultValue:C.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 1 minute is very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"1m"}),dbBackupIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,F.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:k.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>A.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:q.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,T.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,N.isRaspberryPi)()}),taskTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,J.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:D.SidecarExts,defaultValue:D.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:K.AggregateTypes.intersection,strEnum:K.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new ne.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:re.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,J.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:O.CropStrategies.attention,strEnum:O.CropStrategies}),videoFrameAtSec:new ne.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,o.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(A.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:$.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>j.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:I.SharpFailOns.truncated,strEnum:I.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>B.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:oe.MinValidYear}),maxValidFutureMs:new ie.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new ne.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:L.DateTagFormats.ym,strEnum:L.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:V.KeywordReparentingStrategies.move,strEnum:V.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:z.NameTagFormats["as-is"],strEnum:z.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,F.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,r]of(0,d.entries)(t.Settings))r._setName(e);function Se(e){const r=((0,l.blank)(e)?"":e).split(n.delimiter);return(0,F.isDocker)()&&r.unshift("/opt/photostructure/tools/bin"),r.push(...t.Settings.toolPaths.valueOrDefault),(0,o.uniq)(r).filter(l.notBlank).join(n.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,x.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,a.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const r of(0,t.persistedSettings)()){for(const t of r.names)e.set(t,r);for(const t of r.keys)e.set(t,r)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const i=r(19851),n=r(31586),s=r(7282),o=r(49776),a=r(46292),l=r(32774),u=r(55086),c=r(46296),d=r(55939),h=r(96706),f=r(83278),m=r(92234),p=r(45969),g=r(60865),y=r(30933),v=r(15674),w=r(28874);t.setSettingsDefaults=(0,i.lazy)((()=>{w.Settings.configDir.opts.defaultValue=a.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=o.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,n.sigFigs)(50/(0,y.cpuCount)(),2)}))},84438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const i=r(76760),n=r(40958),s=r(22573),o=r(98553),a=r(55835),l=r(59455),u=r(83179);function c(e){return null==e?void 0:(0,o.stringify)(e)}t._join=c;function d(e){return(0,a.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,n.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",i.delimiter])if(t.includes(e))return(0,n.compactBlankish)(t.split(e));return[t]}}(e),n.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,n.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,n.isEmpty)(e)||(this.value=this.toValidValues((0,n.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,n.isEmpty)(this.values)}isNotEmpty(){return(0,n.isNotEmpty)(this.values)}toNotEmpty(){return(0,n.toNotEmpty)((0,n.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=n},72564:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const i=r(40958),n=r(98553),s=r(55835),o=r(58305);class a extends o.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,n.stringify)((0,i.uniq)(e)))),fromEnv:t=>{return r=t,n=e.strEnum,(0,i.compact)((0,o.splitStringArray)(r)?.map((e=>n.getCI(e))));var r,n},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=a},80372:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const i=r(22573),n=r(81168),s=r(83179);class o extends s.Setting{constructor(e){super({toEnv:a,fromEnv:a,...e})}hasValue(){return(0,i.notBlank)(this.value)}}function a(e){return null==e?void 0:(0,n.trimQuotes)(e)}t.StringSetting=o},32707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const i=r(76760),n=r(55835),s=r(46292),o=r(84438);t.systemSettingsFile=function(){return(0,n.map)((0,s.configDir)(),(e=>(0,i.join)(e,o.SettingsToml)))}},80496:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const i=r(50989);t.TagInferenceSettingValues=(0,i.strEnum)("never","always","auto")},6707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const i=r(90858),n=r(44652),s=r(22573),o=r(76850),a=r(50213),l=r(81168),u=r(84542),c=r(17217),d=r(68284),h=r(98778);function f(e){return t=(0,o.debom)(e),(0,s.blank)(t)?void 0:(0,i.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,n.readFileSync)(t)):void 0}catch(e){return void(0,a.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>f(await(0,n.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,n.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const i=r(22573),n=r(96249),s=r(98553),o=r(68708),a=r(51926);function l(e,t,r){if((0,i.blank)(e))throw new Error("kvToToml(): Blank key");const n=e+" = "+(0,s.stringifyPretty)(t);return(0,i.blank)(r?.prefix)?[n]:(0,a.wrap)(n.split("\n"),r)}t.stringifyToml=function(e){return(0,n.flatten)((0,o.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,i.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,a.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},10357:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},65162:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const i=r(4001),n=r(81168);t.bname=function(e,t=!0){let r=(0,n.isString)(e)?e:e.name;return t&&(r=(0,i.stripCopySuffixFromName)(r)),r=(0,n.trimLeftPadding)((0,i.stripDSC)(r)),r.toLowerCase().normalize()}},70379:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const i=r(50989);t.DateTagFormats=(0,i.strEnum)("y","ym","ymd","")},71300:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},68268:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const i=r(50989);t.KeywordReparentingStrategies=(0,i.strEnum)("move","copy","retain")},61208:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const i=r(50989);t.NameTagFormats=(0,i.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const i=r(50989);t.NameTagOrders=(0,i.strEnum)("western","eastern")},60865:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const i=r(37805),n=r(30577);t.channel=function(){return(0,n.extractUpdateChannel)(i.version)},t.baseVersion=()=>[i.versionMajor,i.versionMinor,i.versionPatch].join("."),t.versionMajorMinor=i.versionMajor+"."+i.versionMinor},30577:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const i=r(50989);t.UpdateChannels=(0,i.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const r of t.UpdateChannels.values)if(e.includes("-"+r))return r;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},1485:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const i=r(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,i.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},69375:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const i=r(19851),n=r(22573),s=r(50213),o=r(9103),a=r(7282),l=r(29882),u=r(43334),c=r(28874),d=(0,i.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,n.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,a.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,a.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,a.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,a.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,n.blank)(e))return"blank";const t=(0,l.toPathnames)(e),r=t[0],i=t[t.length-1];return c.Settings.excludedRootDirectories.has(r)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(i)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===r&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,o.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},63870:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const i=r(42659),n=r(12168),s=r(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=n.MiB/i.secondMs},55111:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const i=r(50989);t.HelmetPlugins=(0,i.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},30933:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const n=i(r(48161)),s=r(19851),o=r(42659),a=r(31586),l=r(50213),u=r(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>n.default.cpus()),5*o.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=n.default.availableParallelism?.(),r=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,a.clamp)(1,128,Math.ceil(e??r)),meta:{availableParallelism:e,cpuInfoLength:r}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const n=i(r(48161)),s=r(19851),o=r(31586),a=r(12168),l=r(50213),u=r(45879),c=r(70417),d=r(45969),h=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=n.default.freemem(),t=n.default.totalmem(),r=(2*e+t)/3;if((0,d.isDocker)()){const i=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,o.gt0)(i))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([i,r]),meta:{freemem:e,totalmem:t,cgroupMem:i}})}return h().tap({msg:"estimatedFreeMem() ",result:r,meta:{result:(0,a.fmtBytes)(r),freemem:(0,a.fmtBytes)(e),totalmem:(0,a.fmtBytes)(t)}})}))},15674:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const i=r(19851),n=r(42659),s=r(41400),o=r(31586),a=r(12168),l=r(50213),u=r(7282),c=r(34102),d=r(57902),h=r(28874),f=r(30933),m=r(58444),p=r(22751),g=(0,i.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,i.lazy)((()=>{const e=(0,o.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*a.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/a.MB),worstCaseMemPerProcMb:Math.ceil(e/a.MB)}})}),n.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,r=0===e||0===t?1:(0,o.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:r>1?d.LogLevels.warn:d.LogLevels.debug,result:r,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,o.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,f.cpuCount)())<=1},t.maxCpus=(0,i.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,f.cpuCount)())-1);let t=e;const r=p.timeoutRate.prior()?.eventsPerMinute??0,i=w();if(1!==i){const e=t;t*=i,g().warn("Recent timeouts! Throttling down.",{penalization:i,resultBeforePenalization:e,resultAfterPenalization:t})}const n=Math.min(e,v());return t=(0,o.clamp)(1,n,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:i,timeoutsPerSecond:r,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,i.lazy)((function(){return(0,o.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,o.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,o.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},22751:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const i=r(58587),n=r(87997),s=r(19851),o=r(42659),a=r(41400),l=r(50213),u=r(7282),c=r(45255),d=r(34102),h=r(976),f=r(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new i.Rate(5*o.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,s.lazy)((()=>(0,n.setInterval)(g,o.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,a.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const i=r(76790),n=r(22573),s=r(50357),o=r(98553),a=r(49769),l=r(34666),u=r(30976),c=r(42279),d=r(32639),h=r(59455),f=r(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,r)=>e===t[r]))}function v(e,t){for(let r=0;r=e.length||r>=e.length)return e;const i=e[t];return e.splice(t,1),e.splice(r,0,i),e}function S(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&(0,a.getOrSet)(r,e,(()=>i))}return[...r.values()]}function P(e,t,r=1,i=(e=>e)){const n=[];if(et;s-=r)n.push(i(s));return n}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,r){return m(e)?t(e):(0,c.tot)(r)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let r=0;rt.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const r of t)if(!e.includes(r))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const r=(0,i.sortBy)(e,g),n=(0,i.sortBy)(t,g);return r.every(((e,t)=>e===n[t]))},t.pushUniq=function(e,...t){for(const r of t)null==r||e.some((e=>(0,s.eql)(e,r)))||e.push(r);return e},t.pushUniqBy=function(e,t,r){const i=e.map(r);for(const n of t){const t=r(n);i.includes(t)||(e.push(n),i.push(t))}return e},t.insertAt=function(e,t,...r){return e.splice(t,0,...r),e},t.insertUniq=function(e,t,r){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let i=0;i0)return e.splice(i,0,t),e}return e.push(t),e},t.remove=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),r!==e.length},t.removeSame=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>e!==t)))),r!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(n.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,o.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const r of e)null==r||(0,s.eql)(t[t.length-1],r)||t.push(r);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const r=[];for(const e of(0,i.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))r.some((t=>t.includes(e)))||r.push(e);return(0,i.sortBy)(r,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&r.set(e,i)}return[...r.values()]},t.uniqBy2=function(e,t){const r=[];for(const i of e)null!=i&&r.every((e=>!t(i,e)))&&r.push(i);return r},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,r,i)=>e+(t(r,i)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,r,i)=>e+t(r,i)),0)},t.firstMatch=function(e,t){for(const r of S(t)){const t=e.exec(r);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let r=0;for(;e[r]===t[r];)r++;return r},t.anneal=function({array:e,expense:t,allowedDelta:r}){const i=Math.round(r);if(i<2)return e;for(let r=0;re)){return P(e,t,1,r)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,o.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,r,i=t.primitiveValueOfOrElse){const n=new Set(r.map(i));return e.filter((e=>!n.has(i(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const i=r(40958),n=r(36783),s=r(41801),o=r(98553),a=r(49769),l=r(55835),u=r(34666),c=r(59455);function d(e,t){return(0,n.copyArrayTo)(f(e,t),e)}function h(e,t){const r=new Map;for(const i of e)(0,a.getOrSet)(r,(0,o.stringify)(t(i)),(()=>i));return f(r.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,l.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,i.compact)(e),i.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,n.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,r)=>0===r||t>=e[r-1]))},t.sortedBy=function(e,t){return e.every(((r,i)=>0===i||t(r)>=t(e[i-1])))},t.sortBy=f,t.deepSortBy=function e(t,r){return f(t,r).map((t=>(0,s.isIterable)(t)?e(t,r):t))},t.pushSorted=function(e,t,r){const i=e.findIndex((e=>r(t){Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const i=r(32639);t.asPromise=async function(e){const t=await e;return(0,i.isFunction)(t)?t():t}},5233:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const i=r(41400),n=r(31586),s=r(13538),o=r(41583);t.retryOnReject_=async function(e,t){const r=(0,n.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return r();const a=t.onRetryWaitUntil??(e=>(0,i.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await r()}catch(e){const r=(0,o.toErr)(e);if(!1===t.errorIsRetriable?.(r)||l>t.maxRetries)throw r;return l++,await a(l),u()}};return u()}},17586:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},22573:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const i=r(55835),n=r(42279),s=r(54993);function o(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function a(e){return!o(e)}function l(e,t){if(!1===e||null==e||""===e)return;const r=(0,s.toS)(e);return a(r)?t(r):void 0}t.blank=o,t.notBlank=a,t.notBlankToS=function(e){return a(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,n.tot)(t);const r=(0,s.toS)(e).trim();return r.length>0?r:(0,n.tot)(t)},t.notBlankAnd=function(e,t){return!o(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,r){return(0,i.orElse)(l(e,t),r)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{function r(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function i(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const r=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=r,t.toBoolean=function(e){return!!r(e)||!i(e)&&void 0},t.toNotBoolean=function(e){return!r(e)&&(!!i(e)||void 0)},t.boolToInt=function(e){return r(e)?1:0},t.isFalse=i,t.isDisabled=function(e){return i(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>r(e)))},t.and=function(e){return e.every((e=>r(e)))},t.maybeAnd=function(e){let t;for(const r of e){if(!1===r)return!1;!0===r&&(t=!0)}return t},t.mapBoolean=function(e,t){return r(e)?t(!0):i(e)?t(!1):void 0},t.mapTrue=function(e,t){return r(e)?t():void 0}},79666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const i=r(98553);t.clone=function(e){return null==e?e:JSON.parse((0,i.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const i=r(40958),n=r(22573),s=r(30301),o=r(55835),a=r(31586),l=r(39926),u=r(51926),c=r(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,o.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const r=p(e)?e.getTime():(0,a.isNumber)(e)?e:Date.now();return Math.floor(r/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,r={includeMs:!0}){const i=Math.floor(e/t.hourMs);e-=i*t.hourMs;const n=Math.floor(e/t.minuteMs);e-=n*t.minuteMs;const s=Math.floor(e/t.secondMs),o=Math.floor(e-s*t.secondMs);return(0,l.pad2)(i)+":"+(0,l.pad2)(n)+":"+(0,l.pad2)(s)+(r.includeMs?"."+(0,l.pad3)(o):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const r=()=>{const e=t%100;return t=Math.floor(t/100),e},i=10*r(),n=r(),s=r(),o=r(),a=r(),l=r();return new Date(t,l-1,a,o,s,n,i)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,r="ago"){return e<1e3?"just now":(r=(0,n.blank)(r)?"":(0,u.ensurePrefix)(r," "),et.ms<=e)))){const s=Math.floor(e/i.ms);e-=s*i.ms,s>0&&(i.ms>=t.dayMs?r:n).push(s+i.s)}return e>0&&n.push((0,a.toFixedStr)(e/t.secondMs,3)+"S"),"P"+r.join("")+((0,i.isEmpty)(n)?"":"T"+n.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,o.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const i=r(38639),n=r(73872);function s(e,t,r){if(null==r||y(e)||y(t))return null;const i=r.get(e)?.get(t);return"boolean"==typeof i?i:null}function o(e,t,r,i){if(null==r||y(e)||y(t))return;let n=r.get(e);null!=n?n.set(t,i):(n=new WeakMap,n.set(t,i),r.set(e,n))}function a(e,t,r,i){if(null!=r?.comparator)return u(e,t,r,i);const n=l(e,t);return null!==n?n:u(e,t,r)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,r,i){r??(r={});const u=!1===r.memoize?void 0:r.memoize??(r.memoize=new WeakMap),d=r?.comparator,f=s(e,t,u);if(null!==f)return f;const m=s(t,e,u);if(null!==m)return m;if(d){const r=d(e,t,i);if(!1===r||!0===r)return o(e,t,u,r),r;const n=l(e,t);if(null!==n)return n}const y=n(e);if(y!==n(t))return o(e,t,u,!1),!1;o(e,t,u,!0);const v=function(e,t,r,i){switch(r){case"String":case"Number":case"Boolean":case"Date":return a(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],i);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,i);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,r){return c(h(e),h(t),r)}(e,t,i);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),i);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),i);case"Set":case"Map":return function(e,t,r){if(e.size!==t.size)return!1;if(0===e.size)return!0;const i=[],n=[];return e.forEach((function(e,t){i.push([e,t])})),t.forEach((function(e,t){n.push([e,t])})),c(i.sort(),n.sort(),r)}(e,t,i);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,i)}}(e,t,y,r);return o(e,t,u,v),v}function c(e,t,r){const i=e.length;if(i!==t.length)return!1;if(0===i)return!0;let n=-1;for(;++n{Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,r,i=!1;const n=function(){if(i){if(null!=r)throw r;return t}try{return i=!0,t=e()}catch(e){throw r=e,e}};return n.prior=()=>t,n.hasPrior=()=>i,n}},41400:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const i=r(42659),n=r(35556),s=r(31586),o=r(68708);function a(e,t=!0){return new Promise((r=>{if(e<=0)r();else{const s=setTimeout((()=>r()),Math.ceil(e+.5));e>i.secondMs&&t&&n.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return a(t).then((()=>t))},t.delay=a,t.later=function(e,t=1){const r=Math.max(1,Math.ceil(t)),s=n.isNode&&r<=1?setImmediate(e):setTimeout(e,r);return n.isBrowser||t<=i.secondMs?s:(0,o.maybeCall)(s,"unref")??s}},50357:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const i=r(12487),n=r(68708),s=r(34666),o=r(32639);function a(e,t){return(0,i.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,o.isFunction)(e)&&(0,o.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=a,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return!1;for(const r of(0,n.keys)(e))if(!a(e[r],t[r]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,r){if(null==e||null==t)return e===t;if(null!=r){const i=d.get(r);if(null!=i)return i(e,t)??null}for(const r of c){const i=r(e,t);if(null!=i)return i}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(31586),a=r(68708),l=r(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,n.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,o.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const r=[];for(const t of e)null!=t&&(t instanceof Error?r.push(u(t),c(t),t?.message):r.push((0,l.toS)(t)));return(0,i.uniq)((0,i.compactBlankish)((0,s.flatten)((0,i.compact)(r).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,n.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const r=(0,l.toS)(e).split("\n").filter((e=>!(0,n.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,i.isEmpty)(r)?["(missing stack)"]:r}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,n.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(n.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,a.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,a.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,a.assignFields)(new Error,(0,a.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},96249:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const i=r(59455);t.flatten=function(e,t=[]){for(const r of(0,i.toA)(e))if(null!=r)for(const e of(0,i.toA)(r))null!=e&&t.push(e);return t}},57924:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const i=r(40958);function n(e,t){return null==(e=(0,i.uniq)((0,i.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=n,t.orList=function(e){return n(e,"or")},t.andList=function(e){return n(e,"and")}},73722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const i=r(50989);t.FitSizes=(0,i.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,i.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const i=r(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,r){if((0,i.lt0)(t))return[...e].slice(t,r);const n=e[Symbol.iterator]();if((0,i.gt0)(t))for(let e=0;e{Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,r){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(r))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],r=[];return function e(i,n){if((0,isFunction_1.isFunction)(i))return;let s,o,a,l=toJSON(i);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(i===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let i=0;t.Latch=class{constructor(e=i++){this.id=e,this[r]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},r=Symbol.toStringTag},30301:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const i=r(40958),n=r(50357),s=r(31586),o=r(65812);t.lazy=function(e,t){let r,a;const l=[];function u(){return u.isStale()&&u.setResult(e()),a}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return r=Date.now(),async function(e,r){if((0,i.isEmpty)(l))return;const s=await e,a=await r;if(!(0,n.eql)(s,a))for(const e of l)e(a);null!=t&&t>0&&void 0!==a&&(0,o.setUnrefTimeout)((()=>u.vacuum()),t)}(a,e),a=e},u.isStale=function(){return null==r||(0,s.gt0)(t)&&r+t{Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,r){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const i=r();return null!=i&&e.set(t,i),i}},t.deleteIf=function(e,t){for(const[r,i]of e.entries())t(r,i)&&e.delete(r)}},55835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const i=r(42279),n=r(54993);function s(e,t){return null==e?void 0:t(e)}function o(e,t,r){return null==e||null==t?void 0:r(e,t)}function a(e,t){return null!=e?e:(0,i.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=o,t.map3=function(e,t,r,i){return null==e||null==t||null==r?void 0:i(e,t,r)},t.orElse=a,t.mapOr=function(e,t,r){return null!=e?t(e):(0,i.tot)(r)},t.map2Or=function(e,t,r,i){return a(o(e,t,r),i)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,n.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const i=r(68708);class n extends Error{constructor(e,t){super(e),this.message=e,(0,i.assignFields)(this,t)}}t.MetaError=n},23838:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const i=r(40958),n=r(76790),s=r(50357),o=r(98553),a=r(49769),l=r(55835),u=r(51926),c=r(59455);class d{static fromJSON(e){const t=new d;for(const[r,i]of Object.entries(e))t.add(r,...i);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,i.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const r=(0,a.getOrSet)(this.store,e,(()=>[]));return r.push(...t),r}addUniq(e,...t){return(0,i.pushUniq)((0,a.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const r=this.store.get(e);if(null==r)return!1;{const i=r.filter((e=>!(0,s.eql)(e,t)));return 0===i.length?this.store.delete(e):this.store.set(e,i),r.length!==i.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,i.uniq)(t))){for(const t of this.keys()){const r=this.store.get(t),n=null==r?[]:e(t,r);(0,i.isEmpty)(n)?this.store.delete(t):this.store.set(t,n)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,i.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield[t,r])}()}tuples(){const e=this;return function*(){for(const[t,r]of e.store.entries())for(const e of(0,c.toA)(r))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[r,n]of this.store.entries()){const s=(0,i.findIndexes)(n,(t=>!e(r,t,n)));if(s.length>0){t=!0;for(const e of s.reverse())n.splice(e,1)}0===n.length&&this.store.delete(r)}return t}inverse(){const e=new d;for(const[t,r]of this.store.entries())for(const i of r)e.add(i,t);return e}findKeyByTuple(e){for(const[t,r]of this.tuples())if(e(t,r))return t}filterKeysByTuple(e){const t=[];for(const[r,i]of this.entries())i.some((t=>e(r,t)))&&t.push(r);return t}toJSON(){const e={};for(const[t,r]of this.entries())e[(0,u.isString)(t)?t:(0,o.stringify)(t)]=r;return e}}function h(e,t){const r=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>r.add(t,e))))),r}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const r=h(e,t);return(0,n.sortBy)((0,c.toA)(r.values()),(e=>t(e[0])))}},35556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const r=globalThis;t.isBrowser="object"==typeof r?.window&&"object"==typeof r?.document,t.isNode="string"==typeof r?.process?.versions?.node},31586:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const i=r(76790),n=r(22573),s=r(42279),o=r(54993);function a(e){return"number"==typeof e&&isFinite(e)}t.isNumber=a,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,o.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return a(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,o.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,r)=>a(t)&&a(r)&&e(t,r);function f(e,r,n){return!(null==n||!a(n))&&([e,r]=(0,i.sort)([e,r]),(0,t.lte)(e,n)&&(0,t.gte)(r,n))}function m(e){if(!a(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,n.blank)(e))return t.defaultValue;if(a(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return a(e)&&e>0}function S(e){return a(e)&&e>=0}function b(e,t){return a(e)?t(e):void 0}function P(e){return a(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const r=Math.pow(10,t);return P(e*r)/r}function E(e,t,r){if(e>t||!a(e)||!a(t))throw new Error(`invalid clamp(${e}, ${t}, ${r})`);return a(r)?rt?t:r:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return a(e)?e:t},t.diff=function(e,t){return a(e)&&a(t)?e-t:void 0},t.absdiff=function(e,t){return a(e)&&a(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,r=.95){if(!a(e)||!a(t))return!1;if(e===t)return!0;if(r>=1)return!1;const i=(0===t?1e-5:t)*(1-r);return f(t-i,t+i,e)},t.within=f,t.max_=function(...e){let t;for(const r of e)a(r)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return a(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return a(e)&&a(t)&&e>t?e:void 0},t.lte0=function(e){return a(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const r=y(e);return null==r?void 0:t(r)},t.mapFloat=function(e,t){const r=v(e);return null==r?void 0:t(r)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,r){return b(e,(e=>b(t,(t=>r(e,t)))))},t.mapNumericOr=function(e,t,r){return a(e)?t(e):r},t.numericOr=function(e,t){return a(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d+\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!a(e)||0===e||0===t)return 0;const r=t-P(Math.ceil(Math.log10(Math.abs(e)))),i=Math.pow(10,Math.abs(r));return r<0?P(e/i)*i:P(e*i)/i},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=E,t.times=function(e,t){if(!w(e))return[];const r=Math.round(e);return r<=0?[]:[...Array(r)].map(((e,r)=>t(r)))},t.pct=function(e,t){return E(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const r=Math.round(e??-1);return null==t||f(0,t,r)?r+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const r of e){if(!a(r))return;t+=r}return t}},68708:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(32639),a=r(55835),l=r(31586),u=r(34666),c=r(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const r of e)if(null!=r&&Array.isArray(r)){const[e,i]=r;null!=e&&void 0!==i&&("object"!=typeof t&&(t={}),t[e]=i)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const r=t.filter((([,e])=>null!=e));return(0,i.isEmpty)(r)?void 0:y(r)}function w(e,t,r={}){return y((0,i.compact)((0,n.sort)(h(e)).map((r=>t(r,e[r])))).filter((([e,t])=>null!=e&&void 0!==t)),r)}function S(...e){const t=(0,i.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const r=t.filter(d);if(t.length!==r.length)return t;const n={};for(const e of(0,i.uniq)((0,i.flatMap)(r,h)))n[e]=S(...r.map((t=>t[e])));return n}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const r=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(r.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const r=v(e);return m(r)?t(r):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,r){if(null==t)return e;for(const[i,n]of g(t))!0!==r?.omitKeys?.includes(i)&&(null==n&&!0!==r?.assignNullish||(e[i]=n));return e},t.assignUndefinedFields=function(e,t,...r){if(null==t)return e;for(const i of r){const r=t[i];void 0!==r&&void 0===e[i]&&(e[i]=r)}return e},t.assignAllFields=function(e,t){for(const[r,i]of g(t??{}))e[r]=i;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const r=t.filter((([,e])=>void 0!==e));return(0,i.isEmpty)(r)?void 0:y(r)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,i.compact)(t.map(e));{const r=(0,i.compact)(g(t).map((([t,r])=>(0,a.map)(e(r),(e=>[t,e])))));return 0===r.length?void 0:y(r)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,i.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickCompact=function(e,...t){if(null==e)return;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickNonBlank=function(e,...t){if(null==e)return e;const r={};for(const i of t){const t=e[i];(0,s.notBlank)(t)&&(r[i]=t)}return r},t.pickFirst=function(e,t,r=a.defined){if(null!=e)for(const i of t)if(r(e[i]))return e[i]},t.pickDeep=function e(t,...r){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...r)));const i={};function n(e,t){if(null==t)return;const r=i[e];i[e]=null==r?t:S(r,t)}for(const i of r){const[r,o]=(0,c.splitFirst)(i,"."),a=b(t,r);null!=a?.value&&n(a.key,(0,s.blank)(o)?a.value:e(a.value,o))}for(const i of h(t))((0,l.toInt)(i)??-1)>=0&&n(i,e(t[i],...r));return i},t.pluck=b,t.pluckDeep=function e(t,r){if(null==t||(0,s.blank)(r))return;if(Array.isArray(t)){const n=(0,i.compact)(t.map((t=>e(t,r))));return(0,i.isEmpty)(n)?void 0:{key:n[0].key,value:(0,i.flatMap)(n,(e=>e.value))}}const[n,o]=(0,c.splitFirst)(r,"."),a=b(t,n);if(null==a)return;if((0,s.blank)(o))return a;const l=e(a.value,o);return null==l?void 0:{key:a.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const r=g(e).filter((([e])=>!t.includes(e)));return(0,i.isEmpty)(r)?void 0:y(r)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,r])=>t(e,r))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,i.uniq)(t)},t.maybeCall=function(e,t,...r){const i=e?.[t];return(0,o.isFunction)(i)?i.bind(e)(...r):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const r=t.toLowerCase().normalize();for(const t of h(e))if(r===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const r=w(t,((t,r)=>[t,e(r)])),i=p(r);return 1===i.length?i[0]:r}},97790:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(r||(r={})),t.None=r;class i{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new i(e(this.a))}flatMap(e){const t=e(this.a);return n(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,r){return s(e).flatMap((e=>s(t).flatMap((t=>r(this.a,e,t)))))}zip3(e,t,r,i){return s(e).flatMap((e=>s(t).flatMap((t=>s(r).flatMap((r=>i(this.a,e,t,r)))))))}}function n(e){return e instanceof i||e===t.None}function s(e){return n(e)?e:null!=e?new i(e):t.None}t.Some=i,t.isOpt=n,t.opt=s},39926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const i=r(31586),n=r(54993),s={};function o(e,t){if(t<1)return"";if(!(0,i.gte)(s[e]?.length,t)){let r=s[e]??e;for(;r.length{Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const i=r(22573),n=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,o=/[^aeiou]y$/,a=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,i.blank)(e))return e;const t=n.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(o)?e.replace(/y$/i,"ies"):null!=e.match(a)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const i=r(40958),n=r(54993),s=["number","string","boolean"];function o(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=o,t.mapPrimitive=function(e,t){return o(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,r){return o(e)?t(e):r()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(o)};const a=["boolean","number","bigint","symbol","string","object","function"];function l(e,r){if(null==e&&null==r)return 0;if(null==e)return-1;if(null==r)return 1;const i=typeof e,s=typeof r;if(!("string"!==i&&"symbol"!==i||"string"!==s&&"symbol"!==s)){const i=(0,n.toS)(e),s=(0,n.toS)(r),o=i.localeCompare(s);return i[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-o:o}return Array.isArray(e)&&Array.isArray(r)?u(e,r):i!==s?a.indexOf(i)-a.indexOf(s):e>r?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const i=r(59455);function n(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const r=await e;return null==r?void 0:t(r)},t.thenCollect=async function(e,t){const r=[];for(const n of(0,i.toA)(await e))if(null!=n){const e=await n;if(null!=e){const i=await t(e);null!=i&&r.push(i)}}return r},t.thenTap=async function(e,t=console.dir.bind(console)){const r=await e;return await t(r),r},t.isPromiseLike=n,t.isPromise=function(e){return n(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:r}){const i=await e;return t(i)?r(i):void 0}},57153:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const i=r(50989);t.PromiseStates=(0,i.strEnum)("pending","resolved","rejected")},30976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const i=r(40958),n=r(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function o(e,t,r){return null==r||0===r.length?s(e,t):a(e,t,1,r)[0]}function a(e,t,r,i){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const n=t-e,o=new Set(i??[]);if(t===e&&0===n&&0===o.size&&1===r)return[e];const a=n-o.size;if(r>a)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:n,size:r,slotsRemaining:a})}`);const l=new Set;for(;l.size0;e--){const r=Math.floor(Math.random()*(e+1));e!==r&&([t[e],t[r]]=[t[r],t[e]])}return t},t.sample=function(e,t){const r=[];for(const i of a(0,e.length,t))r.push(e[i]);return r},t.pickWeightedRandom=function(e){if((0,i.isEmpty)(e))return;const t=e.filter((e=>(0,n.gt0)(e.priority)));let r=l(0,(0,i.sum)(t,(e=>e.priority)));return t.find((e=>(r-=e.priority,r<=0)))}},5670:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const i=r(50989);t.ServiceNames=(0,i.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]}},50989:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const i=r(68708),n=r(42279);t.strEnum=function(...e){const t=Object.freeze(e),r=(0,i.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const o=e=>null!=e?r[e]:void 0,a=e=>null!=o(e);return{...s,values:t,length:t.length,has:a,includes:a,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:o,ordinal:e=>o(e)??t.length,validOrElse:(e,t)=>a(e)?e:(0,n.tot)(t),mapValid:(e,t)=>a(e)?t(e):void 0,cmp:(e,t)=>{const r=o(e),i=o(t);return null==r||null==i?void 0:r>i?1:r{const r=o(e);return null==r?void 0:t[r]}}}},51926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const i=r(40958),n=r(17586),s=r(22573),o=r(96249),a=r(41801),l=r(31586),u=r(59455),c=r(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,r){if(d(e))return t<0&&(t+=e.length),e.slice(t,r);{const i=f();return null!=i?(0,a.sliceIterable)(i.segment(e),t,r).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,r).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.startsWith(i)?r.slice(i.length):r}function y(e,t){if(null==t)return e;const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.endsWith(i)?r.slice(0,-i.length):r}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,r){null==r&&(r=e.length);for(let i=r;i>=0;i--)if(m(e,i).startsWith(t))return i;return-1}function b(e,t,{normalize:r=!0}={}){if(null==e||null==t)return!1;const i=(0,c.toS)(e),n=(0,c.toS)(t);return i.length===n.length&&(i===n||i.toLowerCase()===n.toLowerCase()||"function"==typeof i.localeCompare&&0===(r?i.normalize():i).localeCompare(r?n.normalize():n,void 0,{sensitivity:"base"}))}function P(e,t){return(0,i.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,n.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,a.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,r){return d(e)?e.slice(t,null==r?void 0:t+r):m(e,t,null==r?void 0:t+r)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,r){if(null==t)return"";const i=(0,c.toS)(t);for(const t of r)if(null!=t&&t.length>0&&i.startsWith(t))return e(i.slice(t.length),r);return i},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:r}){return y(g(e,t),r)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:r}){return w(v(e,t),r)},t.ellipsize=function(e,t=80,r=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),r=(0,l.clamp)(0,t-1,(0,l.round)(r));const i=p(e);return i.length<=t?i.join(""):i.slice(0,t-1-r).join("")+"…"+(r>0?i.slice(-r).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,r){const i=r?.maxLineLen??80,n=r?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const i=(0,o.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,o.flatten)(i.map((t=>e(t,r))))}if((t=v((0,c.toS)(t),n).trim()).length<=i)return[t];const s=S(t," ",i);if(s>n.length)return[m(t,0,s),...e(m(t,s+1),r)];{const i=t.indexOf(" ",n.length+1);return i>0&&i{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const i=r(42659),n=r(68708),s=r(42279),o=r(83104),a=r(85556);async function l(e,t,r=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(r,i)=>{let n=!0;const s=setTimeout((()=>{n&&(n=!1,r(o.Timeout))}),t);try{s.unref?.();const t=await e;n&&(n=!1,r(t))}catch(e){n&&(n=!1,i(e))}finally{clearTimeout(s)}}))}async function u(e,t,r=!0){const n=await l(e,t,r);if(n===o.Timeout)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(t)+")");return n}t.toNotTimeout=function(e){return e===o.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,r=!0){const i=t-Date.now();return i<=0?o.Timeout:l(e,i,r)},t.thenOrOnTimeout=async function(e,t,r){return t<=0?e:new Promise((async(i,s)=>{let o=!0;try{const a=setTimeout((async()=>{if(o){o=!1;try{i(await r())}catch(e){s(e)}}}),t);(0,n.maybeCall)(a,"unref");const l=await e;o&&(o=!1,clearTimeout(a),i(l))}catch(e){o&&(o=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,r=!0){const n=t-Date.now();if(n<=0)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(n)+")");return u(e,n,r)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:r,unref:i=!0}){const n=await l(e,t,i);return n===o.Timeout?(0,s.tot)(r):n}},42279:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const i=r(32639);t.tot=function(e){return(0,i.isFunction)(e)?e():e},t.tol=async function(e){return(0,i.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class r extends Error{}t.TimeoutError=r},12168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const i=r(22573),n=r(30301),s=r(31586),o=r(46891),a=r(50989),l=r(51926),u=(0,n.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let r=0;for(const i of e)(0,s.isNumber)(i)&&(r+=i/t.MB);return(0,s.round)(r)},t.fmt=c,t.fmtToInt=function(e){return(0,i.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const r=Math.floor(Math.log10(e)),i=Math.floor(r/3),n=Math.pow(10,3*i),o=d[i];return(0,s.sigFigs)(e/n,t)+" "+o}t.fmtMB=function(e,r=3){return f(e*t.MB,r)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const r=Math.floor(Math.log2(e)),i=Math.floor(r/10),n=Math.pow(2,10*i),o=h[i];return(0,s.sigFigs)(e/n,t)+" "+o},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,a.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,r){return null==e?"":(0,i.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(r??(0,o.pluralize)(t)).trim())},t.plurMetric=function(e,t,r){return r??(r=(0,o.pluralize)(t)),{count:c(e),desc:1===e?t:r}}},65812:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const i=r(68708);t.setUnrefTimeout=function(e,t){const r=setTimeout(e,t);return(0,i.maybeCall)(r,"unref")??r}},23541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const i=r(41801),n=r(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,n.isString)(e)?[e]:(0,i.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const i=r(40958),n=r(23541),s=r(59455),o=r(54993);function a(e){return null==e?void 0:(0,n.isError)(e)?e:new Error((0,o.toS)(e))}t.toErr=a,t.toErrs=function(...e){return(0,i.compact)((0,s.toA)(e).map(a))}},54993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const i=r(98553);t.toS=function(e){return s(e,",")};const n={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==n?e.toString():(0,i.stringify)(e)}}t.toStr=s},92636:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(6858),s=i(r(73024)),o=i(r(76760)),a=r(1708),l=r(37805),u=r(41269),c=r(80061),d=r(94361);function h(e){for(const t of["bin",__dirname]){const r=o.default.join(t,e);if(s.default.existsSync(r))return r}return console.error("failed to find command "+e),e}n.program.version(l.version),n.program.description("Welcome to PhotoStructure, your new home for all your photos and videos.\nSee https://photostructure.com/server/tools/ for details about these tools."),(0,d.verifyUidGid)(),(0,c.addHelpFooter)(n.program).command("main",u.CliDesc.main+" (default)",{isDefault:!0,executableFile:h("main.js")}).command("info",u.CliDesc.info,{executableFile:h("info.js")}).command("list",u.CliDesc.list,{executableFile:h("list.js")}).command("logcat",u.CliDesc.logcat,{executableFile:h("logcat.js")}).command("logtail",u.CliDesc.logtail,{executableFile:h("logtail.js")}).command("web",u.CliDesc.web,{executableFile:h("web.js")}).command("sync",u.CliDesc.sync,{executableFile:h("sync.js")}).parse(a.argv)},90858:e=>{e.exports=require("@iarna/toml")},58587:e=>{e.exports=require("batch-cluster")},6858:e=>{e.exports=require("commander")},36507:e=>{e.exports=require("croner")},66261:e=>{e.exports=require("events")},77988:e=>{e.exports=require("exiftool-vendored")},44652:e=>{e.exports=require("fs-extra")},28787:e=>{e.exports=require("he")},51168:e=>{e.exports=require("luxon")},73872:e=>{e.exports=require("type-detect")},92460:e=>{e.exports=require("util")},31421:e=>{e.exports=require("node:child_process")},77598:e=>{e.exports=require("node:crypto")},78474:e=>{e.exports=require("node:events")},73024:e=>{e.exports=require("node:fs")},51455:e=>{e.exports=require("node:fs/promises")},48161:e=>{e.exports=require("node:os")},76760:e=>{e.exports=require("node:path")},1708:e=>{e.exports=require("node:process")},57075:e=>{e.exports=require("node:stream")},46466:e=>{e.exports=require("node:stream/promises")},87997:e=>{e.exports=require("node:timers")},57975:e=>{e.exports=require("node:util")},38522:e=>{e.exports=require("node:zlib")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__=__webpack_require__(92636);module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{"use strict";var __webpack_modules__={37975:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const i=r(22573),n=r(38639),s=r(44198);function o(){return(0,n.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,i.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=o;let a=!o();function l(){return a}function u(e,t){return function(r){return l()?`[${e}m${r}[${t}m`:r}}t.setColorEnabled=function(e){a=e??!o()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const i=r(19851),n=r(7282),s=r(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,i.lazy)((()=>t.SimpleAppName+((0,n.isProd)()?"":`-${(0,n.nodeEnv)()}`))),t.AppNameVersion=(0,i.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const i=r(40958),n=r(36783),s=r(76790),o=r(22573),a=r(50357),l=r(98553),u=r(55835),c=r(31586),d=r(68708),h=r(34666),f=r(59455),m=r(84885);var p=r(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,r=i.primitiveValueOfOrElse){const n=new Set(t.map(r));return e.filter((e=>n.has(r(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],r=e.lastIndexOf(t);return[{t,count:r+1},...v(e.slice(r+1))]}function w(...e){const t=[],r=Math.max(...e.map((e=>e?.length??0)));for(let i=0;ie?.[i])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function E(e,t){return(0,i.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,r){return C(e,t,r).index}function C(e,t,r){if((0,i.isEmpty)(e))return{index:-1,value:void 0};let n,s=-1;for(let i=0;ie.slice(r,r+t)))}async function x(e,t){return(0,i.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,a.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(o.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const r of(0,f.toA)(e))if(null!=r&&!0===await t(r))return r},t.findLastAsync=async function(e,t){for(let r=(e=(0,f.toA)(e)).length-1;r>=0;r--){const i=e[r];if(null!=i&&!0===await t(i))return i}},t.first=function(e,t){if(null!=e)for(const r of(0,f.toA)(e))if(null!=r){const e=t(r);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null!=i){const e=await t(i,r);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,i.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,r){for(let i=r;i<=e.length-1;i++)if(t(e[i]))return i},t.findLast=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return e[r]},t.findLastIndex=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1},t.concat=function(...e){const t=[];for(const r of e)if(Array.isArray(r))for(const e of r)null!=e&&t.push(e);else null!=r&&t.push(r);return t},t.moveToEnd=function(e,t){return(0,i.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const r=e[t];if(null==r)return e;e.push(r);for(let r=t;r(0,a.eql)(e,t)))},t.removeFirst=function(e,t){const r=e.findIndex(t);return r>=0?e.splice(r,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,n.copyArrayTo)((0,i.uniqBy)(e,t),e)},t.partition=function(e,t){const r=[],i=[];let n=0;for(const s of e)(t(s,n++)?r:i).push(s);return[r,i]},t.isUniq=function(e){return e.every(((t,r)=>e.indexOf(t)===r))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,i.compact)((0,i.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),r=[];return(0,c.times)(t,(t=>e.map((e=>r.push(e?.[t]))))),r},t.unFlatZip=function(e,t){const r=e.length/t;if(r!==Math.round(r))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const i=(0,c.times)(t,(()=>new Array(r)));for(let n=0;ne.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=E,t.least=function(e){return E(e,(e=>e))},t.greatestBy=function(e,t){return(0,i.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const r=C(e??[],t,h.lt);return null==e||null==r||r.index<0||null==r.value?void 0:{result:e[r.index],index:r.index,value:r.value}},t.reverse=function(e){const t=[];for(let r=e.length-1;r>=0;r--)t.push(e[r]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=T,t.collectBatched=function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(r(s)));return n},t.collectBatchedAsync=async function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(await r(s)));return n},t.contextFilter=function(e,t){let r;return e.filter(((e,i)=>(0,d.tap)(t(e,i,r),(t=>{t&&(r=e)}))))},t.clusterSome=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.some((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterEvery=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.every((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterAsync=async function(e,t){const r=[];e:for(const i of e){for(const e of r)if(null!=i&&await x(e,(e=>t(i,e)))){e.push(i);continue e}null!=i&&r.push([i])}return r},t.someAsync=async function(e,t){if(null!=e)for(let r=0;r=0&&!0===(0,u.map)(e[i],(e=>r(e,i))))return i}{const i=t+n;if(ie+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,r){return e.lengthr))),e}},36557:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const a=r(77988),l=o(r(1708)),u=r(19851),c=r(42659),d=r(55835),h=r(31586),f=r(85556),m=r(54993),p=r(50213),g=r(79089),y=r(45255),v=r(25764),w=r(38836),S=r(99331),b=r(95937),P=r(98314),_=r(38835),E=r(70025),M=r(8769),C=r(43334),T=r(95402),x=r(28874),D=r(63870);class k extends w.EndableWrapper{constructor(e,t,r=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,i,"m",n).call(this)),r,"worker"===e?(0,D.commandTimeoutMs)():y.ShortCommandTimeoutMs),i.add(this),this.t=t;const o=t;o.on("childStart",(async r=>{null!=r.pid?(this.logger.info("Started child process",{pid:r.pid}),(0,g.renice)(r.pid).catch((e=>this.onError("renice failed",e))),(0,T.addPid)({pid:r.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),o.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),o.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),o.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),o.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),o.on("noTaskData",((e,r,i)=>{const n=t.options.streamFlushMillis;n{this.logger.error("observeBatchCluster.endError()",e)})),o.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&T.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof a.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,E.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=k,i=new WeakSet,n=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(C.isWin?3:1)*c.minuteMs,maxTasksPerProcess:x.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:x.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:x.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:x.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:x.Settings.taskTimeoutMs.valueOrDefault}}},89788:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=r(92460),d=r(31586);class h{constructor(e){if(i.add(this),this.maxLength=e,n.set(this,void 0),s.set(this,0),o.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,n,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,i=new WeakSet,a=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,o,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,n,"f")[t]))}()}push(...e){var t,r;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,n,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,i,"m",a).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,n,"f")[e]}))}unshift(...e){var t,r;for(const c of e.reverse())u(this,s,"f"){u(this,n,"f")[e]=c,l(this,o,e,"f")}));return u(this,s,"f")}shift(){return u(this,i,"m",a).call(this,0,(e=>{var t,r;return l(this,o,(t=u(this,o,"f"),++t),"f"),l(this,s,(r=u(this,s,"f"),--r),"f"),u(this,n,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,i,"m",a).call(this,u(this,s,"f")-1-e,(e=>{const r=u(this,n,"f")[e];u(this,n,"f")[e]=u(this,n,"f")[t],u(this,n,"f")[t]=r}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const i=r(54993),n=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:r}of n)if(o(e,t))return e.subarray(t.length).toString(r);return e.toString()}function o(e,t){return t.every(((t,r)=>e[r]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,i.toS)(e)},t.bufferStartsWith=o},9092:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,r]of e)this.set(t,r)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const r=this.normalizer(e);return null!=e&&null!=r&&this.store.set(r,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=n},36638:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=n},40583:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const o=r(40958),a=r(23838),l=s(r(68708)),u=r(59455),c=r(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new a.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const r of(0,o.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(r,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const r=this.lookup(e);if(null!=r)return r;let i,n=-1;for(const[r,s]of this.m.entries()){const o=(0,c.diceCoeff)(r,e);if(o>t&&o>n){const e=this.getFirst(s);null!=e&&(i=e,n=o)}}return i}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),r=this.m.get(t);if(null!=r){for(const e of r)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const i=r(76790),n=r(31586),s=r(68708),o=r(54993),a=r(82647),l=r(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const r=this.get(e)+t;return 0===r?this.m.delete(e):this.m.set(e,r),r}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new a.Average(0);for(const t of this.keys()){if(!(0,n.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,r]of this.m.entries())e[(0,o.toS)(t)]=r;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,i.sortBy)([...this.entries()],(([t,r])=>[-r,(0,n.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new a.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,r]of(0,i.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,r);return e}addAll(e){for(const[t,r]of e.entries())this.incr(t,r);return this}get toS(){return(0,i.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let r=0;for(const[i,n]of this.m.entries()){const s=e(i);t.fill(s,r,r+n),r+=n}return t}}t.CountingSet=u},79840:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const i=r(19851),n=r(72993),s=r(45969),o=r(43334);t.EditionType=(0,i.lazy)((()=>o.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,i.lazy)((()=>n.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const i=r(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),r=t-this.ts;this.ts=t,(0,i.map)(this.listener,(t=>t(e,r))),r>2&&this.l.log(r>500?"warn":r>100?"info":"debug",e,{elapsedMs:r})}},t.elapsed=function(e){const t=Date.now(),r=e();return{elapsedMs:Date.now()-t,result:r}},t.thenElapsed=async function(e){const t=Date.now(),r=await e;return{elapsedMs:Date.now()-t,result:r}}},23467:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const i=r(50357),n=r(55835),s=r(68708);var o=r(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return o.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,i.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,i.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,n.map2Or)(await e,await t,i.eql,(()=>!1))},t.eqlPicked=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))},t.eqlOmit=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.omit)(e,...r),(0,s.omit)(t,...r))},t.eqlAsyncPicked=async function(e,t,...r){return(0,n.map2Or)(await e,await t,((e,t)=>(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))),(()=>!1))}},62344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(31586),a=r(54993),l=r(77377),u=r(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,o.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,o.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,n.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const r of this.expireListeners)r(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[i.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const r of this.expireListeners)r(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,n.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const r of this.expireListeners)r(e,t)}const r=this.priorCache[e];if(void 0!==r&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,r)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const r=this.currentCache[t]??this.priorCache[t];null!=r&&e(t,r)}}deleteIf(e){for(const t of this.keys()){const r=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=r&&e(t,r)&&this.delete(t)}}get(e){return e=(0,a.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,a.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,a.toS)(e),this.has(e))return this.get(e);const r=t();return this.set(e,r),r}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,o.isNumber)(e.__uid)&&(0,o.isNumber)(e.__start)}},80049:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=r(31586),d=r(85556),h=r(54993),f=r(54557),m=r(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,i.set(this,0),n.set(this,0),s.set(this,0),o.set(this,0),a.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,i,l(this,i,"f")+e.cacheHitsSync,"f"),u(this,n,l(this,n,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,o,l(this,o,"f")+e.rejections,"f"),u(this,a,l(this,a,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,i,"f"),cacheHitsAsync:l(this,n,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,o,"f"),timeouts:l(this,a,"f")}}has(e){return this.cache.has(e)}get_(e){var t,r,o,a;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,n,(r=l(this,n,"f"),++r),"f"),c.promise):(u(this,i,(o=l(this,i,"f"),++o),"f"),c.value)}if(c instanceof Error)throw c;return u(this,i,(a=l(this,i,"f"),++a),"f"),c}get(e){var t,r;const n=this.cache.get(e);return null==n||n instanceof m.Deferred&&n.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,i,(r=l(this,i,"f"),++r),"f"),n instanceof m.Deferred?n.value:n}clear(){this.cache.clear(),u(this,i,0,"f"),u(this,n,0,"f"),u(this,s,0,"f"),u(this,o,0,"f"),u(this,a,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const r=this.get(e);if(null!=r){if(r instanceof Error)throw r;return r}return this.set(e,t())}getOrSetAsync(e,t){const r=(0,h.toS)(e);{const e=this.get_(r);if(null!=e)return e instanceof m.Deferred?e.promise:e}const i=new m.Deferred(this.opts.name).observe(t());return this.cache.set(r,i),(0,c.gt0)(this.opts.timeoutMs)&&i.setTimeout(this.opts.timeoutMs),i.promise.then((e=>{this.set(r,e)}),(e=>{var t,i;this.cache.set(r,e),u(this,o,(t=l(this,o,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,a,(i=l(this,a,"f"),++i),"f")})),i.promise}},i=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap},54127:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class i{constructor(e){this.maxSize=e,this[r]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(r=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=i},53507:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(31586),a=r(68708),l=r(50213),u=r(68852),c=r(81168),d=r(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,i.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,r=!0){return new m(e,t,r).entries};class m{constructor(e,t,r=!0){this.warnIfMissingHeaders=r,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const i=(0,o.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,n.range)(0,i).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,a.fromEntries)(e))).filter((e=>(0,a.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let r=e;r!==t;t>e?r++:r--)if(this.blankColumns.has(r))return r;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),r=[];let i,a=0;for(;null!=(i=t.exec(this.headerRow));){const l=this.headerRow.substring(a,i.index);(0,s.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:i.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(i.index,t.lastIndex),d=i.index+((0,c.indexOfNonSpace)(u)??0),h=i.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:i,left:d,right:h});else{const e=(0,n.last)(r);if(r.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,o.max_)(e?.rightIdx,i.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}a=t.lastIndex}const l=(0,n.last)(r);return null!=l&&((0,s.blank)(this.headerRow.slice(a))?l.rightIdx=(0,o.max_)(...this.rows.map((e=>e.length))):l.rightIdx=a),r}}t.Fixed=m},73913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const i=r(51455),n=r(98553);var s=r(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const r=(0,n.parseJSON)(e);return null==r?void 0:t(r)},t.readJson_=async function(e){return(0,n.parseJSON)((await(0,i.readFile)(e)).toString())}},19851:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const o=r(57975),a=r(40958),l=r(50357),u=r(31586),c=r(65812),d=r(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),i.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,i,"m",n).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,a.isEmpty)(this.watchers))return;const r=await e,i=await t;if(!(0,l.eql)(r,i))for(const e of this.watchers)e(i);null!=this.ttlMs&&this.ttlMs>0&&void 0!==i&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(42659),a=r(50213),l=r(81168),u=r(5916),c=r(56519),d=r(84777),h=r(44198),f=r(6012),m=r(43334),p=r(24399),g=r(63870);t.DefaultLocale="en";const y=(0,i.lazy)((()=>(0,a.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?E():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,i.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const r=w.exec(e.trim())?.groups;return null==r?void 0:(0,n.compact)([r.lang,r.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const _={timeoutMs:10*o.secondMs};async function E(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return b(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=E,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},50213:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const i=r(19851),n=r(32105),s=r(14593);t.rootLoggers=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));const o=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,o)}},9103:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const i=r(98553),n=r(54557);t.memoize=function(e,t){let r=0;const s=new n.FifoCache(t.maxSize,t.ttlMs),o=t=>{if(null!=t)return r++,s.getOrSet((0,i.stringify)(t),(()=>e(t)))};return o.clear=e=>null==e?s.clear():s.delete((0,i.stringify)(e)),o.size=()=>s.size,o.callCount=()=>r,o}},7282:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const n=i(r(1708)),s=r(38639),o=r(54993),a=r(19851),l=r(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,a.lazy)((()=>n.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,o.toS)(n.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return n.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(n.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){n.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(55835),a=r(31586),l=r(39926),u=r(54993),c=r(20014);var d=r(31586);function h(e,t){return(0,a.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(a.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,a.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,r){return(0,o.orElse)(h(e,t),r)},t.mapGte0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>=0?t(r):void 0},t.mapGt0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>0?t(r):void 0},t.mapGt0=function(e,t){const r=(0,a.toInt)(e);return null!=r&&r>0?t(r):void 0},t.map2Gt0=function(e,t,r){const i=(0,a.toInt)(e),n=(0,a.toInt)(t);return null!=i&&i>0&&null!=n&&n>0?r(i,n):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,a.isNumber)(e))return e;if((0,n.blank)(e))return;const t=String(e);return(0,o.map)(f.exec(t),(e=>(0,a.toFloat)(t.substr(e.index))))}function p(e){return(0,a.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const r=[e,t].map((e=>e.toString(2))),i=Math.max(...r.map((e=>e.length)));return r.map((e=>(0,l.leftPad)(e,i,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let r=0;for(let i=0;ie/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,r){this.store[e*this.columns+t]=r}},t.hammingDistanceBigInt=function(e,t){return(0,o.map)(g(e,t),(([e,t])=>(0,i.count)([...e],((e,r)=>e!==t.charAt(r)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,o.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,i.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,r){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let i=0;const n=r*e.length;for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const i=r(40958),n=r(42659),s=r(96249),o=r(55835),a=r(31586),l=r(68708),u=r(34666),c=r(41583),d=r(48884),h=r(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,n.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const r={};for(const[i,n]of(0,l.entries)(e)){const e=t(i,n);null!=e&&(r[i]=e)}return r}t.definedThunks=function(...e){return e.every((e=>(0,o.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const r of e){const e=r();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(o.defined)},t.firstDefinedField=function(e,...t){return(0,o.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(r=>t(r,e[r])?e[r]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,r){if(null!=e)return t(e);throw new Error(r)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,o.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,i.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[r,i]of m(t))null==e[r]&&(e[r]=i);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[r,i]of(0,l.entries)(t))null==e[r]&&(e[r]=i);return e},t.pickMap=function(e,t,r){const i={};for(const n of t)i[n]=r(n,e[n]);return i},t.mapEntries=p,t.mapNullEntries=function(e,t,r){const i={};let n=0;for(const s of(0,l.keys)(e))if(i[s]=t(s,e[s]),n++,(0,a.gt)(n,r))break;return i},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const r={};for(const i of(0,h.sortIgnoreCase)((0,l.keys)(t)))r[i]=e(t[i]);return r}return t},t.deepDelete=function e(t,...r){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...r))):p(t,((t,i)=>r.includes(t)?void 0:e(i,...r)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const r of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[r])return e[r]}},t.pairToObject=function(e,t){const r={};return r[e]=t,r},t.zipPojos=function(...e){const t={};for(const r of(0,i.uniq)((0,s.flatten)(e.map(l.keys))))t[r]=e.map((e=>e?.[r]));return t}},12801:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const n=i(r(48161)),s=r(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:n.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:n.default.constants.priority.PRIORITY_NORMAL,BelowNormal:n.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:n.default.constants.priority.PRIORITY_LOW,Low:n.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const i=r(41400),n=r(56409),s=r(31586),o=r(22911),a=r(73614),l=r(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:r,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...i){f=!0,m=Date.now()+(0,s.max_)(t,r);const n=d=new o.Deferred(c);(0,s.gt0)(r)&&n.setTimeout(r);try{n.resolve(await e(...i))}catch(e){n.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,a.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return n.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,i.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new n.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const i=r(68708),n=r(54993);function s(e){return e instanceof o?e.source:(0,n.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const r=[];if(!e.global)throw new Error("must provide global regex");let n;for(;null!=(n=e.exec(t));)n.index===e.lastIndex?e.lastIndex++:r.push((0,i.pick)(n,"index","groups"));return r},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,r){const i=[];for(const t of e)try{i.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{i.push(s(t))}const n=0===i.length?t.NothingRegExp:i.map((e=>"(?:"+e+")")).join("|");return new RegExp(n,r)};class o{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=o;class a extends o{static from(...e){const t=l(e);return new a("(?:"+t.source+")?",t.flags)}}function l(e,t){let r="",i=t?.includes("g")??!1,a=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof o||t instanceof RegExp?(r+=t.source,i||(i=t.global),a||(a=t.ignoreCase),l||(l=t.multiline)):r+=s((0,n.toS)(t));return new RegExp(r,t??(i?"g":"")+(a?"i":"")+(l?"m":""))}t.RegExpOptional=a,t.concatRegexp=l},79089:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const n=i(r(48161)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(42659),u=r(41400),c=r(96249),d=r(31586),h=r(51926),f=r(54993),m=r(50213),p=r(12801),g=r(22277),y=r(84777),v=r(34102),w=r(43334),S=r(24399),b=r(28874),P=(0,o.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,o.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,a.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let E=!0;const M=(0,o.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const r=(0,p.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[r]),E)try{return n.default.setPriority(e,t),t}catch(r){const i=-13===r?.errno||"EACCES"===r?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:i,error:r}),i)return;E=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,r):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[r]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+r),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const n=i(r(1708)),s=r(19851),o=r(40958),a=r(5670),l=r(54993),u=r(7282),c=r(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===a.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===a.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===a.ServiceNames.sync}function p(){return(0,t.serviceName)()===a.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,o.compactBlanks)([t.serviceName.prior(),(0,l.toS)(n.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return a.ServiceNames.indexOf(e)??a.ServiceNames.length+1},t.MainServices=[a.ServiceNames.main,a.ServiceNames.desktop],t.DbServices=[a.ServiceNames.sync,a.ServiceNames.info,a.ServiceNames.web,a.ServiceNames.list,a.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[a.ServiceNames.sync,a.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===a.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===a.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,s.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const i=r(59455);function n(e){return e instanceof Set?e:new Set((0,i.toA)(e))}t.asSet=n,t.setEql=function(e,t){return(0,i.toA)(e.keys()).every((e=>t.has(e)))&&(0,i.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,r){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),r())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const r=n(t);return new Set([...e].filter((e=>r.has(e))))},t.diff=function(e,t){const r=n(t);return new Set([...e].filter((e=>!r.has(e))))}},12089:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=r(98553),d=r(34666),h=r(54993),f=r(62344),m=r(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,r,o){super(),i.add(this),this.impl=t,this.cache=r,this.toKey=o,n.set(this,void 0),s.set(this,void 0),l(this,n,e,"f")}async _call(e){return null==this.cache?u(this,i,"m",a).call(this,e):this.cache().getOrSetAsync(u(this,i,"m",o).call(this,e),(()=>u(this,i,"m",a).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,i,"m",o).call(this,e))}}n=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},a=function(e){return(0,m.time)(u(this,n,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const i=r(42659);t.ShortCommandTimeoutMs=7*i.secondMs},92322:function(e,t,r){var i,n=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=r(76790),o=r(17586);class a{constructor(e,t){this.valueOf=e,this.diff=t,i.set(this,[])}[(i=new WeakMap,Symbol.iterator)](){return n(this,i,"f")[Symbol.iterator]()}get length(){return n(this,i,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,r=n(this,i,"f").length-1;for(;t<=r;){const s=t+Math.floor((r-t)/2),o=this.valueOf(n(this,i,"f")[s]);if(e===o)return{found:!0,index:s};e>o?t=s+1:r=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&n(this,i,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:r}){if(t>=this.length)return[...n(this,i,"f")];const o=t=>t<0||t>n(this,i,"f").length-1?null:(r??this.diff)(n(this,i,"f")[t],e),a=this.findIndex(e);if(null==a)return;let l=a.index-1,u=o(l),c=a.index,d=o(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return n(this,i,"f").shift()}at(e){return(0,o.at)(n(this,i,"f"),e)}toA(){return[...n(this,i,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===n(this,i,"f").length-1){const e=[...n(this,i,"f")];return n(this,i,"f").length=0,e}return n(this,i,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return n(this,i,"f").splice(e,t)}retainLastN(e){return e{Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},82328:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const i=r(1708),n=r(95705);t.stdoutEnded=function(){return(0,n.streamEnded)(i.stdout)}},71567:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const n=i(r(1708)),s=r(22573),o=r(98553),a=r(23560),l=r(82328),u=r(38835),c=r(70025),d=r(95705);function h(e,t){return f({obj:e,ready:t,stream:n.default.stdout})}function f({obj:e,ready:r,stream:i}){if(null==i||(0,d.streamEnded)(i))return;const n=(0,o.stringify)(e,void 0,(0,a.isInfoService)()||(0,a.isMainService)()?2:void 0);i.write(n+"\n"),(0,a.isWorkerService)()&&null!=r&&(n.includes(u.FailStr)||(0,c.isFatalError)(n)||(0,c.isHealthCheckError)(n)?i.write(u.FailStr+"\n"):i.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||n.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:n.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const r of e)r.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(55835),a=r(31586),l=r(39926),u=r(34666),c=r(51926),d=r(59455),h=r(54993),f=r(48884),m=r(68852),p=r(38835);var g=r(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=r(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=r(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,r){if(0===r.length)throw new Error("rightPad() given empty pad");const i=String(e);return i+(0,l.padding)(r,t-i.length)},t.padReplace=function(e,t,r,i){return(0,c.strslice)(e,0,t)+(0,l.padding)(i,r)+(0,c.strslice)(e,t+r)},t.contains=function(e,t,r){return(0,h.toS)(e).indexOf((0,h.toS)(t),r)>-1},t.countChars=function e(t,r,i=0){if(null==r||0===r.length)return 0;const n=t.indexOf(r,i);return-1===n?0:1+e(t,r,n+r.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,r){const i=Math.min(Math.ceil(e.length/t),r??e.length)-1;return i<=0?[e]:[...(0,a.times)(i,(r=>e.slice(r*t,(r+1)*t))),e.slice(i*t)]},t.spliceCapture=function(e,t){const r=t.exec(e);if(null==r||null==r[1])return;const i=r[0].indexOf(r[1])+r.index;return{captured:r[1],uncaptured:e.substring(0,i)+e.substring(i+r[1].length),unmatched:e.substring(0,r.index)+e.substring(r.index+r[0].length),matchedIndex:i}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,r={}){if(null==t)return e;const i=(0,h.toS)(e),n=(0,h.toS)(t);return n.length>0&&(0,c.equalsIgnoreCase)(i.slice(-n.length),n,r)?i.slice(0,-n.length):i},t.gist=function(e,t=80,r=80){const i=(0,h.toS)(e),n=i.length-(t+r);return n<=0?i:i.slice(0,t).trim()+" …(+"+n+" chars)…"+i.slice(-r).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const r=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===r?e.localeCompare(t):r}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,i.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,o.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const r=S(e.cmp[0],t.cmp[0]);return 0!==r?r:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,i.isEmpty)(e)||(0,s.blank)(t))return;for(const r of e)if((0,c.equalsIgnoreCase)(r,t))return{index:0,match:r};for(const r of e){const e=t.indexOf(r);if(e>=0)return{index:e,match:r}}const r=t.normalize();for(const t of e){{const e=r.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=r.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=r.toLowerCase(),i=e.toLowerCase(),n=t.indexOf(i);if(n>=0)return{index:n,match:i}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function E(e){return _.reduce(((e,[t,r])=>e.replace(t,r)),e).normalize()}t.dumbquote=E;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(E(e))&&(e=e.slice(1,-1).trim())),e};const C=/^['‘’].*['‘’]$/,T=/^["“”„«»〃].*["“”„«»〃]$/;function x(e,t){const r=D(e,t);return(0,f.flatZip)(r.nonSeparators,r.separators).filter((e=>null!=e&&e.length>0))}function D(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const r=[],i=[];let n,s=0;for(;null!=(n=t.exec(e));)n.index===t.lastIndex?t.lastIndex++:(t.lastIndex=n[0].length+n.index,r.push(e.substring(s,n.index)),i.push(e.substring(n.index,t.lastIndex)),s=t.lastIndex);return s(0,a.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),C.test(e)||T.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const r=(0,i.compactBlanks)(e),n=Math.max(...r.map((e=>e.length)));for(let e=0;e(0,o.map)(r[e],(e=>t+=e))));return t},t.splitKeep=x,t.splitUp=D,t.sortNaturalBy=k,t.sortNatural=function(e){return(0,n.sortBy)(e,(e=>k(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,i.compactBlanks)(e)),r=t.filter(((e,r)=>!P(t[r+1],e)));return(0,n.sortBy)(r,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const r=Math.min(e.length,t.length);for(let i=0;i4===e?.length?(0,a.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const O=/#.*$/gm;t.stripComments=function(e){return e.replace(O,"")},t.uniqPath=function(e,t=":"){const r=new Set;for(const i of(0,d.toA)(e))if(null!=i&&!(0,s.blank)(i))for(const e of i.split(t))(0,s.blank)(e)||r.add(e);return[...r].join(t)},t.dedupeNeedle=function(e,t,r){if((0,s.blank)(t))return e;const i=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),n=e.findIndex((e=>i.test(e))),o=new RegExp("("+(0,m.escapeRegExp)(r)+"[,:\\s]*){2,}","gim");if(n<0)return e;for(let t=n+1;te.trim()))))}},83556:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const i=r(54993);function n(e){return(0,i.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>"_"+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>" "+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=n,t.asObjectKey=function(e){return n(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const n=i(r(77598)),s=r(73913),o=r(55222);function a(e,t=s.HashBits){return n.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,r=o.Radix58,i=224){return r.encodeBuffer(a(e,i)).substring(0,t)}t.stringShaToBuffer=a,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,r=o.GeoRadix,i=224){return l(e,t,r,i)}},94863:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const i=r(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,i.toS)(e).toLowerCase().normalize()}},96859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(31586),a=r(39926),l=r(51926),u=r(54993),c=r(55222),d=r(97352),h=r(88158),f=r(77377),m=r(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const r=new d.Array2D(e.length);let i=0,n="";for(let s=0;s=i&&(i=r.get(s,o),n=(0,l.substr)(e,s-i+1,i)));return n}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const r=y(e,t);if(null!=r)return r;const i=e.normalize(),n=t.normalize();return e!==i||t!==n?y(i,n):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,r,i)=>r===t.charAt(i)?e:e+1),0)}function v(e,t){const r=e.toUpperCase().normalize(),i=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>r===i?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(r),t=w(i);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,r)=>e+t[r+1]))}function S(e,t){const r=(0,f.intersection)(e,t),n=[];return r.forEach((r=>{const s=Math.min((0,i.count)(e,(e=>e===r)),(0,i.count)(t,(e=>e===r)));(0,o.times)(s,(()=>n.push(r)))})),n}function b(e,t,r){const n=(0,i.commonPrefixLength)(e,t);return r((0,l.strslice)(e,n))-r((0,l.strslice)(t,n))}function P(e){const t=(0,i.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,n.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[r,i]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(r,i,(e=>(0,o.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=_;const E=/[^\da-z]+/gi;function M(e,t){const[r,i]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(E,"").toLowerCase()));return b(r,i,(e=>c.RadixAlphaNum.decode(e)))}function C(e,t){let r;for(let i=Math.max(e.length,t.length);i>=0;i--){const n=(0,o.mapNumericOr)(e.charCodeAt(i),(e=>e),256),s=(0,o.mapNumericOr)(t.charCodeAt(i),(e=>e),256),a=(0,o.clamp)(-256,256,n-s);r=null==r?a:(r+a)/2}return r}t.radixDiff=M,t.str=function(e,t){return{pref:(0,i.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,i.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=C,t.paddedPositionalDiff=function(e,t,r=8){return C((0,a.leftPad)(e,r," "),(0,a.leftPad)(t,r," "))}},84885:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const i=r(98553),n=r(88158);t.stringifySorted=function(e){return(0,i.stringify)((0,n.sortedKeys)(e))}},22277:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=r(73614);class u{constructor(e,t=!1){i.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[o]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return a(this,i,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>a(this,i,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const r=this.delegate.get(e);return null==r||a(this,i,"m",n).call(this,e,r)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,r]of this.delegate)a(this,i,"m",n).call(this,t,r)||e(t,t,this)}has(e){return null!=e&&!a(this,i,"m",n).call(this,e)}values(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield[t,t])}()}toA(){return a(this,i,"m",s).call(this),[...this.delegate.keys()]}[(i=new WeakSet,o=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,n=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const r=t<=Date.now()-this.ttlMs;if(r){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return r},s=function(){for(const[e,t]of this.delegate)a(this,i,"m",n).call(this,e,t)}},94174:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(38639),c=r(31586),d=r(50213),h=r(45255),f=r(84777),m=r(96706),p=r(43334),g=r(24399),y=(0,o.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,o.lazy)((()=>(0,a.uniq)([s.default.geteuid?.(),s.default.getuid?.(),n.default.userInfo().uid]))),t.userid=(0,o.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,o.lazy)((()=>(0,a.uniq)([s.default.getegid?.(),s.default.getgid?.(),n.default.userInfo().gid]))),t.groupid=(0,o.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,o.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,o.lazy)((()=>(0,l.toNotBlank)(n.default.userInfo()?.username))),t.userNameFromWhoami=(0,o.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,o.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,o.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,o.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.1-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=1,t.versionPrerelease=["prealpha"],t.release="2024.3.1-prealpha+20240308150212",t.gitSha="d92384e8659ff46fbae8e6f81fa5867114a4a843",t.gitDate=new Date(1709938932e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const i=r(42659),n=r(55835),s=r(31586),o=r(97790),a=r(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const r=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,n.allDefined)(r))return;const[o,a,u,c,d,h,f]=r,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(o,a-1,u,c,d,h,f/1e3)-m*i.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,o.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,a.within)(0,Date.now()+i.dayMs,e))).map((e=>new Date(e))).get()}},73568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class r extends Error{}t.AbortError=r},76740:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const a=r(45599),l=r(56409),u=r(73568);t.Abortable=class{constructor(){this._aborted=!1,i.set(this,void 0),n.set(this,(0,a.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,n,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,n,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,n,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),o(this,i,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,i,"f")&&clearTimeout(s(this,i,"f")),o(this,i,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},i=new WeakMap,n=new WeakMap},22911:function(e,t,r){var i,n,s,o,a,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(r(87997)),w=y(r(57975)),S=r(45599),b=r(26905),P=r(55835),_=r(31586),E=r(68708),M=r(20214),C=r(57153),T=r(85556),x=r(50213),D=r(70025),k=r(95937),O="TIMEOUT",I=(0,S.defer)((()=>(0,x.mkLogger)("async.Deferred")));class F{static async*toAsyncIterable(e,t){const r=[...e].reverse(),i=(0,_.gt0)(t)?new n(O).setTimeout(t):void 0;for(null!=i&&r.push(i);;){for(let i=r.length-1;i>=0;i--){const n=r[i];if(n.isSettled){if(n.name===O)return void I().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});r.splice(i,1),yield n.value}}if(r.every((e=>e.name===O)))break;try{await Promise.race(r)}catch{}}i?.clearTimeout()}static resolve(e,t){return new n(".resolved()",t).resolve(e)}constructor(e,t){var r,m,y;i.add(this),this.name=e,this.startedAt=Date.now(),o.set(this,void 0),a.set(this,C.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(r=n,n,(y=p(r,n,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,x.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof n&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,a,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,E.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,o,"f")}get elapsedMs(){return(p(this,o,"f")??Date.now())-this.startedAt}get[(o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,i=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new T.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,k.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,a,"f")===C.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,a,"f")!==C.PromiseStates.pending}get isResolved(){return p(this,a,"f")===C.PromiseStates.resolved}get isRejected(){return p(this,a,"f")===C.PromiseStates.rejected}get settledMs(){return null==p(this,o,"f")?void 0:p(this,o,"f")-this.startedAt}resolve(e){return p(this,i,"m",m).call(this,(()=>{g(this,a,C.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,D.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return p(this,i,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,a,C.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=F,n=F,m=function(e){if(p(this,a,"f")===C.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,o,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},s={value:0}},27395:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const i=r(19851),n=r(40958),s=r(42659),o=r(23838),a=r(13538),l=r(50213),u=r(7282),c=r(97352),d=r(77740),h=r(25764),f=r(99331),m=r(73614),p=(0,i.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new o.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const r=await e;if(null==r||!0===r?.ended)return;const i=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,r.endTimeoutMs,y);p().trace(r.name+" ending...",{timeoutMs:i});try{await(0,a.thenOrTimeoutError)(r.end(),i,(0,u.isTest)())}catch(e){try{p().warn(r.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,i.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const r=g.get(t)??[];(0,n.isNotEmpty)(r)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(r.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,n.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const r=g.get(t)??[];e[t]=r.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,r){var i,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=r(87997),h=r(55835),f=r(31586),m=r(68708),p=r(25764),g=r(38836),y=r(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,i,"m",o).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),i.add(this),this.opts=e,n.set(this,void 0),s.set(this,void 0),a.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,n,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,r=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!r&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,i,"m",o).call(this);const h=()=>{u(this,i,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,n,(0,d.setInterval)(u(this,a,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,i,"a",l)&&(u(this,a,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):h(),!0}}t.EndableInterval=v,n=new WeakMap,s=new WeakMap,a=new WeakMap,i=new WeakSet,o=function(){(0,h.map)(u(this,n,"f"),d.clearInterval),c(this,n,void 0,"f"),(0,h.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const i=r(50989);t.EndableRanks=(0,i.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const a=r(19851),l=r(45599),u=r(56409),c=r(50213),d=r(27395),h=r(25764),f=r(99331),m=r(56519);t.EndableWrapper=class{constructor(e,t,r=h.EndableRanks.first,o){this.endTimeoutMs=o,i.set(this,void 0),this.onEnds=[],n.set(this,(0,a.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,n,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(r,this)}setName(e){o(this,i,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,i,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,n,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},i=new WeakMap,n=new WeakMap},99331:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const i=r(7282);let n=!1;t.ending=function(){return n},t.setEnding=function(e){n=(0,i.isTest)()?e:e||n}},45608:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const n=i(r(1708)),s=r(22573),o=r(45599),a=r(37975),l=r(50213),u=r(71567),c=r(57159),d=r(57902),h=r(28874),f=r(27395),m=r(99331),p=r(56038),g=(0,o.defer)((()=>(0,l.mkLogger)((0,a.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,o.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const r=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==r.errno||!0===r.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const i=(0,s.toNotBlank)(e?.reason)??r.toString();for(const e of t.onFatalHandlers)await e(i)}(0,m.ending)()||(await(0,f.endEndables)(),n.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,o.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])n.default[e].on(t,(r=>{v({reason:`${e}:${t}`,status:0,error:r})}))}))},5916:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=r(50357),f=r(31586),m=r(41583),p=r(62344),g=r(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:r,timeoutMs:i}){return new y(e,t,r,i)};class y extends p.ExtensibleFunction{constructor(e,t,r,l){super(),i.add(this),this.later=e,this.desc=t,this.ttlMs=r,this.timeoutMs=l,n.set(this,void 0),s.set(this,0),o.set(this,void 0),a.set(this,[])}_call(){return this.isStale()?c(this,i,"m",u).call(this,this.later()):c(this,o,"f")}unset(){d(this,s,0,"f"),d(this,n,void 0,"f"),d(this,o,void 0,"f")}set(e){return c(this,i,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,i,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,a,"f").push(e)}prior(){return this.isStale()?void 0:c(this,o,"f")}lastValue(){return c(this,o,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,n,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,n,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,n,"f")?void 0:Date.now()-c(this,n,"f")}elapsedMs(){return c(this,o,"f")?.settledMs??c(this,o,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=async function(e,t){var r;try{const r=await t;if(!(0,h.eql)(e?.value??await(e?.promise),r))for(const e of c(this,a,"f"))await e.onChange(r)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,a,"f"))e.onError(t)}finally{d(this,s,(r=c(this,s,"f"),++r),"f")}},u=function(e){d(this,n,Date.now(),"f");const t=c(this,o,"f");return d(this,o,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,o,"f").setTimeout(this.timeoutMs),c(this,i,"m",l).call(this,t,c(this,o,"f")),c(this,o,"f")}},56519:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const i=r(40958),n=r(76790),s=r(38639),o=r(42659),a=r(41400),l=r(31586),u=r(20214),c=r(13538),d=r(42279),h=r(32639),f=r(59455),m=r(41583),p=r(48884),g=r(50213),y=r(88158),v=r(15674),w=r(42638);var S=r(20214);async function b(e){if(null==e)return[];const t=(0,i.compact)(await e);return(0,i.isEmpty)(t)?[]:(0,i.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:r,timeoutMs:n}){const s=[];for(const o of(0,i.compact)(await t))try{const e=await((0,l.gt0)(n)?(0,c.thenOrTimeoutError)(r(o),n):r(o));null!=e&&s.push([e,o])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:o,error:t})}return s}async function E({arr:e,f:t,name:r,maxConcurrent:n,timeoutMs:s,promises:o}){if(null==e)return[];const a=(0,i.compact)(await e);if((0,i.isEmpty)(a))return[];if((n=Math.round(n??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:r,timeoutMs:s});const u=o??(a.length<=n?w.PermissivePromises:new w.Promises(r,(()=>n))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,h=await u.enqueueAll(r,a.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(r).warn("failed to apply",{ea:e,error:t})}})));return(0,i.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,r){const i=[];for(const n of(0,p.batches)((0,f.toA)(await e),t)){const e=await b(n);i.push(...await b(r(e)))}return i},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,a.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const r of(0,i.compact)(e)){const e=await r();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;if(null!=e)if(Array.isArray(e))for(const r of e){const e=await r;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;null!=e&&t.push(e)}return(0,i.uniq)(t)},t.asyncFind=async function(e,t){for(const r of e)if(await t(r))return r},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=E,t.mapAsync=async function({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s}){return(await E({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:r,maxConcurrent:n,timeoutMs:s}){return(await E({name:e,arr:(0,i.compact)(t),f:r,maxConcurrent:n,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const r=await E({name:"partitionAsync",arr:e,f:t});return[r.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),r.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*o.secondMs,t.tryAll=async function(e,r=(e=>console.error(e)),i=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,i)}catch(e){r((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),r=(()=>{})){let i,n=null;try{i=await((0,h.isFunction)(e)?e():e)}catch(e){n=(0,m.toErr)(e);try{await t(e)}catch{}}try{await r(n??i)}catch{}if(null!=n)throw n;return i},t.thenNot=async function(e,t=!0){if(null==e)return t;const r=await e;return null==r?t:!(0,s.isTrue)(r)},t.thenMap2=async function(e,t,r){const i=await e;if(null==i)return;const n=await t;return null!=n?r(i,n):void 0},t.thenMapOr=async function(e,t,r){const i=await e;if(null==i)return r();const n=await t(i);return null==n?r():n},t.thenMap2Or=async function(e,t,r,i){const n=await e;if(null==n)return i();const s=await t;if(null==s)return i();const o=await r(n,s);return null==o?i():o},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null==i)continue;const e=await t(i,r);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const r of e){const e=await r();if(null!=e){const r=await t(e);if(null!=r)return r}}},t.firstResolvedDefinedPromise=async function(e,t){for(const r of e)try{const e=await r();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const r of t)try{const t=await r();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:r}){const i=await E({name:e,arr:t,f:r});return(0,n.sortBy)(i,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const i=r(19851),n=r(40958),s=r(76790),o=r(42659),a=r(49769),l=r(31586),u=r(68708),c=r(42279),d=r(41583),h=r(22454),f=r(14121),m=r(50213),p=r(7282),g=r(34102),y=r(82647),v=r(25764),w=r(38836),S=r(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,r){const i=Date.now(),n=(0,l.clamp)(10*o.secondMs,o.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-i)+"ms")}),n);try{const n=await(0,c.tot)(t),s=Date.now()-i;return r?.(n,s),this.push(e,s),n}catch(t){throw this.errors.incr(e),r?.((0,d.toErr)(t),Date.now()-i),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),r=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),i=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",r.stats()],...i])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,a.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:r.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:(0,l.mapFinite)(r.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:r.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:{sumSec:(0,l.sigFigs)(r.sum/o.secondMs,3),...(0,u.omit)(r.stats(),"sum")}})),{})}}function _(e,t,r){return P.instance().time(e,t,r)}function E(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,i.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,n.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const r=Date.now(),i=t();return E(e,Date.now()-r),i},t.pushTime=E,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,r){return(0,i.lazy)((async()=>_(e,t)),r)}},42638:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(r(66261)),m=r(40958),p=r(55835),g=r(31586),y=r(42279),v=r(54993),w=r(89788),S=r(82647),b=r(15674),P=r(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){i.add(this),this.name=e,this.ee=new f.default.EventEmitter,n.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),o.set(this,[]),a.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,n,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,b.maxCpus)(),d(this,n,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,a,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,o,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,o,"f").map((e=>e.name)),pendingNames:d(this,a,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:r,serialId:n}){const s=d(this,i,"m",l).call(this,{name:e,l:t,payload:r,serialId:n});return this.laterPop(),s}enqueueAll(e,t){const r=t.map((t=>d(this,i,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(r)}serial(e,t,r){return this.enqueue({name:e,l:t,serialId:e,payload:r})}push(e,t,r){return d(this,i,"m",u).call(this,new P.Deferred(e,{payload:r}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,o,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,a,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,a,"f").length,e),r=this.runningSerialIds,n=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,o,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,a,"f").length}hasPending(){return d(this,a,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,a,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,a,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=function({name:e,l:t,payload:r,serialId:i}){const n=new P.Deferred(e,{payload:r,serialId:i});return d(this,a,"f").push({d:n,l:t}),n},u=function(e,t){const r=Date.now();return this.lastWorkTs=r,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,o,"f"),e),this.settleMsAvg.push(Date.now()-r),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,o,"f").push(e),e},t.maybeRun=function(e,t){const r=new _(e);return()=>r.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:r}){return new _(e,(0,p.map)(r,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class r extends Error{}t.RedoableError=r},4867:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const i=r(40958),n=r(34546),s=r(41400),o=r(31586),a=r(83104),l=r(85556),u=r(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:r}){let a=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>a=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>{if(a)throw new l.TimeoutError})):void 0,r?.abortPromise_().then((()=>{if(a)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:r}){let l=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>l=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>a.Timeout)):void 0,r?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let r=e=>null;t.setTimeoutHandler=function(e){r=e},t.onTimeout=function({soft:e}={}){r(e)}},73614:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const i=r(87997);t.setUnrefTimeout=function(e,t,...r){return(0,i.setTimeout)(e,Math.round(t),...r).unref()},t.setUnrefInterval=function(e,t,...r){return(0,i.setInterval)(e,Math.round(t),...r).unref()}},31562:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const i=r(38639),n=r(42659),s=r(41400),o=r(32639),a=r(31586),l=r(45255),u=r(95937);async function c(e,{timeoutMs:t,intervalMs:r,acceptable:i,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const i=r??(0,a.clamp)(10*m,l.ShortCommandTimeoutMs,(t??n.minuteMs)/5);await(0,s.delay)(i,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:i.isTrue,timeoutResult:!1})}},9727:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const n=i(r(1708)),s=r(45599),o=r(41400),a=r(50357),l=r(68708),u=r(48884),c=r(36638),d=r(44198),h=r(59958),f=r(96706),m=r(34102),p=r(19851),g=r(19043),y=r(66184),v=r(50213),w=r(7282),S=r(88158),b=r(45969),P=r(43334),_=r(28874),E=r(3790);function M(e){return C().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const C=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const r of t.names)e.add(r);for(const r of t.keys)e.add(r)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,o.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const T=["HOME","LANG","USER"],x=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],D=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?T:x),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function k(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const r of(0,_.persistedSettings)()){const i=e?r.value:r.envValue;null==i||(0,a.eql)(i,r.defaultValue)||r.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(n.default.env,(e=>M(e)||!(0,E.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=k,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:I({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let O=!1;function I({overrides:e,forceCLocale:r=!0,forWorker:i=!1}={}){const n=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...D(),...r?(0,g.childProcLocale)():{},...k(i),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(n);if((0,y.isLogged)("debug")&&!O){O=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(n).map((([e,t])=>[e,(0,E.isHiddenEnvKey)(e)?"(hidden)":t])),[r,i]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(r)),e.debug("non PS env:",(0,l.fromEntries)(i))}return n}t.childEnv=I},84777:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const n=i(r(31421)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(42659),c=r(98553),d=r(56409),h=r(31586),f=r(68708),m=r(51926),p=r(50213),g=r(7282),y=r(88158),v=r(79089),w=r(45255),S=r(22911),b=r(4867),P=r(73614),_=r(70025),E=r(57159),M=r(36868),C=r(66184),T=r(45643),x=r(95402),D=r(9727),k=(0,o.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function O(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function I(e,t=30*u.secondMs){if(null==e)return!1;k().debug("endProcess()",O(e));const r=e.pid;if(null==r||r<=0)return k().warn("endProcess(): asked to end invalid pid",O(e)),!1;if(r===s.default.pid)return k().warn("endProcess(): asked to end MY pid",O(e)),!1;if(r===s.default.ppid)return k().warn("endProcess(): asked to end my parent pid",O(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();k().debug("endProcess("+r+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,x.killPid)(r).catch((e=>{k().warn("endProcess(): kill("+r+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,T.waitForPidExit)(r,t))return k().debug("endProcess(): exitted",O(e)),!0;{x.Pids.instance()?.onKill(r);const t=e.kill("SIGKILL");k().warn("endProcess("+r+") had to resort to SIGKILL",{killResult:t}),t||await(0,x.killPid)(r,!0).catch((e=>{k().warn("endProcess(): kill("+r+",true) failed: "+e)}))}return(0,T.waitForPidExit)(r,5e3)}function F(e,r,i,n=0){const o=new Date,a=[];return(0,v.niceable)(r,i)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(n,u.secondMs)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&I(e)}),n-250)),a.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,x.addPid)({pid:e.pid,cmd:r,timeoutMs:n,ppid:s.default.pid},o)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>a.forEach(clearTimeout))),e}function A(e,t,r,i){const s=(0,D.spawnOptions)(i);return(0,C.isLogged)("trace",k().context)?k().debug("execFile()",{command:e,args:t,timeoutMs:r,opts:s}):k().debug("execFile()",{command:e,args:t,timeoutMs:r}),F(n.default.execFile(e,t,s),e,t,r)}async function N(e,t,r){const i=r.quiet??!1,n=r.ignoreStderr??!1,s=r.ignoreExitCode??!1,o=A(e,t,r.timeoutMs,(0,f.omit)(r,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===r.disconnect){try{o.disconnect?.()}catch{}return{result:"",pid:o.pid}}const u=o.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new S.Deferred(f);o.on("error",(e=>g.push(e))),o.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),o.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(o.stdin);const v=new d.Latch;null==o.stdout?v.resolve():(o.stdout.on("error",(e=>g.push(e))),o.stdout.on("data",(e=>m.push(e))),o.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==o.stderr||n?P.resolve():(o.stderr?.on("error",(e=>g.push(e))),o.stderr?.on("data",(e=>p.push(e))),o.stderr?.on("end",(()=>P.resolve()))),k().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:r.timeoutMs,halt:r.halt}),k().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt});const C=p.join("");(0,l.notBlank)(C)&&g.push(new Error(C)),!i&&(0,a.isNotEmpty)(g)&&k().warn(f+" resulted in errors:",g);const T=r.isIgnorableError??_.isIgnorableError,x=g.filter((e=>!0!==T(e)));if(x.length>0)throw 1===x.length?x[0]:new E.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:x});if(!s&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:C}}catch(e){throw k().error("stdoutResult_() failed",e),await(0,x.killPid)(o.pid,!0),e}}t.endProcess=I,t.ReniceAfterMs=(0,o.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,o.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,r,i){const s=(0,D.spawnOptions)(i);return k().debug("spawn()",{command:e,args:t,maxAgeMs:r}),F(n.default.spawn(e,t,s),e,t,r)},t.execFile=A,t.stdoutResult_=N,t.stdout_=async function(e,t,r){const i=await N(e,t,r);return k().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(i.result),meta:{cmd:e,args:t,opts:r,result:i}})}},3790:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const i=r(22573),n=r(41400),s=r(19851),o=r(28874);(0,n.later)((()=>o.Settings.sensitiveEnvRegExp.watchLater((()=>a.unset()))));const a=(0,s.lazy)((()=>{try{return new RegExp(o.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${o.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(o.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,i.blank)(e)&&a().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||o.Settings.license.includesEnvKey(e)}},41269:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const i=r(1708),n=r(31586),s=r(51926),o=r(17344),a=r(37805),l=r(84542);function u(e,t){const r=t?.maxLineLen??(0,n.toInt)(i.env.maxLineLen)??i.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:r,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,o.EditionName)()+" v"+a.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},94361:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const i=r(19851),n=r(40958),s=r(55835),o=r(31586),a=r(94174),l=r(44198),u=r(45969);function c(e,t,r){const i=(0,o.toGt0)((0,l.env)()[t]);return null==i||r.includes(i)?void 0:`WARNING: ${e} is running as ${r} but $${t}=${i}`}function d(){const e=(0,n.compactBlanks)([c("user id","PUID",(0,a.userids)()),c("group id","PGID",(0,a.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,i.lazy)((()=>{(0,u.isDocker)()&&(0,s.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},76596:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const i=r(51168),n=r(19851),s=r(22573),o=r(42659),a=r(55835),l=r(31586),u=r(68708),c=r(34666),d=r(50213),h=(0,n.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,r){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=r}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const r=(0,a.mapOr)(e,(e=>e.getTime()),(()=>0)),i=(0,a.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(r,i)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),r=Date.now();return t<=r?0:t-r},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,o.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const i=r(22573),n=r(31586),s=r(54557),o=r(91655),a=new s.FifoCache(512);function l(e){return(0,n.isNumber)(e)?e:(0,i.blank)(e)?void 0:a.getOrSet(e,(()=>(0,o.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,i.blank)(e)?void 0:u.getOrSet(e,(()=>(0,o.fmtFullDuration)((0,n.isNumber)(e)?e:l(e))))}},91655:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const i=r(51168),n=r(40958),s=r(22573),o=r(42659),a=r(31586),l=r(51926),u=r(68852),c=r(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,a.isNumber)(e))return;if((0,a.isNumber)(e))return e;if((0,a.isDigits)(e))return(0,a.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=i.Duration.fromISO(e);if(t.isValid)return t.toMillis();const r=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(r,e);if(0===d.length)return;const h=(0,n.compact)(d.map((e=>function(e,t){const r=(0,a.toFloat)(e);if(null!=r){if((0,s.blank)(t))return r;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*o.yearMs;case"weeks":case"week":case"w":return r*o.weekMs;case"days":case"day":case"d":return r*o.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return r*o.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return r*o.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return r;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,a.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:o.yearMs,s:"y"},{ms:o.weekMs,s:"w"},{ms:o.dayMs,s:"d"},{ms:o.hourMs,s:"h"},{ms:o.minuteMs,s:"m"},{ms:o.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,r=""){if(!(0,a.isNumber)(t))return;if(0===t)return"0";if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const i=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const r=Math.floor(t/e.ms);t-=r*e.ms,r>0&&i.push(r+e.s)}return i.join(r)}},84248:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const i=r(50989);t.AutoVacuumModes=(0,i.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const i=r(50989);t.CheckpointTypes=(0,i.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const i=r(50989);t.RepairModes=(0,i.strEnum)("dump","recover")},34365:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const i=r(50989);t.SynchronousModes=(0,i.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const o=s(r(76760)),a=r(40958),l=r(22573),u=r(55835),c=r(72993),d=r(19851),h=r(97352),f=r(94174),m=r(44198),p=r(96706),g=r(8769),y=r(57159),v=r(70698),w=r(64680),S=r(29882),b=r(45969),P=r(43334),_=r(28874),E=r(41692),M=r(32774),C=r(80612),T=r(32551),x=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function D(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+x(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const r of t)(0,l.blank)(r)||e.push({dir:(0,o.join)(r,".photostructure-cache"+x()),preexistingDir:r});return e}}function k(){if((0,b.isDocker)())return(0,a.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,o.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+x(),preexistingDir:M.DefaultDockerLibraryDir},...D()]);const e=(0,a.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),o.default.resolve((0,T.homeDir)(),"AppData","Local")]:P.isMac?[o.default.resolve((0,T.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,o.join)((0,T.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,r=e.map((e=>({dir:(0,o.join)(e,t),preexistingDir:e})));return r.push(...D()),r}t.tmpCacheDirs=D,t.tmpDirs=function(){return(0,C.filterDirs)({dirs:D(),desc:"tmp"})},t.cacheDirs=k,t.defaultCacheDir=(0,d.lazy)((()=>(0,C.firstDir)({dirs:k(),desc:"cache"})));const O=(0,d.lazy)((()=>{(0,E.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(I)}));function I(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{O();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=I},46292:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const i=r(19851),n=r(45969),s=r(41692),o=r(32774),a=r(10924),l=r(84373),u=r(80612);t.configDir=(0,i.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,n.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,a.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:o.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:o.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,n.isDocker)()?c:(0,a.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const i=r(66430),n=r(45969),s=r(32774);t.defaultLibraryDir=function(){return(0,n.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,n.isDocker)()&&(0,i.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const n=i(r(76760)),s=r(40958),o=r(72993),a=r(44198),l=r(96706),u=r(43334),c=r(80612),d=r(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),n.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(n.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,a.env)().XDG_DATA_HOME,(0,a.env)().XDG_CONFIG_HOME,n.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:n.default.join(e,(0,o.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const i=r(22573),n=r(96706),s=r(29882);t.envConfigDir=function(){const e=(0,n.getEnv)("PS_CONFIG_DIR");if(!(0,i.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const i=r(44652),n=r(40958),s=r(22573),o=r(66430);function a({dirs:e,desc:t}){for(const{dir:r,preexistingDir:a}of(0,n.compact)(e))if(!(0,s.blank)(r)){if((0,o.isReadWriteableDirectorySync)(r))return r;if((0,s.blank)(a)||(0,o.isReadWriteableDirectorySync)(a))try{return(0,i.mkdirpSync)(r),r}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=a,t.filterDirs=function({dirs:e,desc:t}){return(0,n.compact)(e.map((e=>a({dirs:[e],desc:t}))))}},32551:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const i=r(48161),n=r(76760),s=r(1708),o=r(19851),a=r(40958),l=r(68284),u=r(43334);t.homeDir=(0,o.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,a.compactBlanks)(e)){const e=(0,n.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,i.homedir)()}))},46296:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(55835),u=r(54993),c=r(72993),d=r(96706),h=r(45969),f=r(43334),m=r(32707),p=r(6707),g=r(49776),y=r(32774),v=r(80612),w=r(32551);function S(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:n.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,o.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>n.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,a.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),r=(0,u.toS)(t?.logDir);return(0,a.notBlank)(r)?r:b()}catch(e){return console.error("defaultLogDir_() failed",e),n.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const i=r(76760),n=r(19851),s=r(22573),o=r(44198),a=r(43334),l=r(24399),u=r(32551);async function c(){return a.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,n.lazy)((async()=>{if(a.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,n.lazy)((()=>(0,o.env)().XDG_PICTURES_DIR??(0,i.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const i=r(38639),n=r(7282),s=r(29325),o=r(44198);t.getDevEnvFlag=function(e){return!(0,n.isProd)()&&!(0,s.isPacked)()&&((0,i.toBoolean)((0,o.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,o.env)()[e]=String(t)}},34580:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const i=r(38639),n=r(44198);t.doNotTrack=function(){return(0,i.isTrue)((0,n.env)().DO_NOT_TRACK)}},44198:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const n=i(r(73024)),s=r(76760),o=i(r(1708)),a=r(19851),l=r(40958),u=r(41400),c=r(68708),d=r(76850),h=r(7282),f=r(32551),m=r(34102),p=r(53265),g=r(45969),y=r(59958),v=r(6012),w=r(96706);t.env=(0,a.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>o.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===o.default.env.PS_LICENSE||e.push((0,s.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),r={...o.default.env};for(const i of e)try{const e=(0,d.debom)(n.default.readFileSync((0,p.resolve)(i))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,i]of(0,c.entries)(s))t.test(e)||(r[e]=i)}catch(e){console.warn("env(): failed to read .env file, "+i,e)}return r})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const i=r(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,i.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const i=r(50989);t.EnvKeys=(0,i.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const i=r(22573),n=r(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const r={};if((0,i.blank)(e))return r;let s;for(const o of(0,n.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(o));){if(null==s.groups)continue;const{key:e,val:n}=s.groups;if((0,i.blank)(e)||null==n)continue;const o=n.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");r[t?e.toLowerCase():e]=o}}return r}},96706:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const n=i(r(1708)),s=r(19851),o=r(22573),a=r(38639),l=r(41400),u=r(40583),c=r(79840),d=r(83556),h=r(34102),f=r(44198),m=r(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,o.firstNotBlank)(n.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,n.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,a.isTrue)(g(e))}},98314:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const i=r(58587),n=r(19851),s=r(40958),o=r(22573),a=r(26905),l=r(96249),u=r(51926),c=r(23541),d=r(54993),h=r(89788),f=r(50213),m=r(81168),p=r(84542),g=r(41954),y=r(38835),v=r(70025),w=r(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const r=[...e.filter(c.isError).map(a.errorName),...e.map(a.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(a.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(r)))}function b(e){return(0,s.compact)(e).filter((e=>!a.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(o.notBlank)}function P(e,t){const r=(0,s.uniqSubstrings)(b(e)),i=t?.maxLen??400,n=t?.trailingChars??64,o=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(r.join(a.ErrorDelimiter)),i-o.length,n)+o.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,o.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,n.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new i.Rate,t.fatalErrorRate=new i.Rate,t.internalErrorRate=new i.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,o.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const r=(0,d.toS)(t?.[e]);if((0,o.notBlank)(r))return r}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,r=256,i=7){return(0,o.blank)(e)&&(e=t.MissingError),_(e,{maxLen:r})+" at "+(0,a.shortStack)(e?.stack,i).join("; ")}},41954:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const i=r(40958),n=r(26905),s=r(55835),o=r(54993),a=r(81168);t.describeError=function(e){const t=(0,a.stripSuffix)((0,o.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const r of e)(0,s.map)((0,n.errorErrno)(r),(e=>t.push(u.get(e)))),(0,s.map)((0,n.errorCode)(r),(e=>t.push(l[e]?.description)));return(0,i.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const i=r(40958),n=r(76790),s=r(50989),o=r(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,n.sortBy)((0,i.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(o.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const i=r(40958),n=r(38639),s=r(26905),o=r(54993),a=r(68852),l=r(73568),u=r(78656),c=r(98314),d=r(38835);function h(e){return(0,o.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const r=(0,o.toS)(e)+(0,i.compact)(t).join("");return h(r)+f(r).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,a.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const r=(0,c.errorToS)(e);return!p.test(r)&&(!!g.test(r)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,n.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const r=(0,c.errorToS)(e);return!(!r.includes("EBUSY")&&!r.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const r=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>r.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,n.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,n.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},8769:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const i=r(22573),n=r(31586),s=r(68708),o=r(7282),a=r(23560),l=r(45608),u=r(34102),c=r(28874),d=r(98314),h=r(38835),f=r(70025),m=r(57159),p=r(5012);function g(e,t){try{if((0,i.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const r=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const n=!0===r.fatal,c=!0===r.ignorable;if(!n&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),n&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",r));const h=!n||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:r}),!n||(0,o.isTest)()||(0,a.isWebService)()||(0,l.exit)({reason:r.toString(),status:r.errno??13}),n}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,n.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,a.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,n.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,n.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,r){return g(e+h.InternalErrorFlag,{cause:t,...r})}},57159:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const i=r(40958),n=r(22573),s=r(38639),o=r(26905),a=r(98553),l=r(68708),u=r(59455),c=r(41583),d=r(48884),h=r(81168),f=r(98314),m=r(38835),p=r(70025);t.toWrappedError=function(e,t){const r=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,n.blank)(r.message)||e.message.includes(r.message)))return e;const i=(0,n.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,r?.message);return new g(i??"(missing error message)",r)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,i.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,o.errorName)(t)??(0,d.first)(this.causes,o.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(o.errorCode)],o.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,o.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.path))),this.flags=t?.flags??[];const r=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??r.some(p.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(r.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(r.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(r.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let r=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const i=t?.path;return(0,n.blank)(i)||(r=(0,h.dedupeNeedle)(r,i,"file")),(0,f.joinErrorMessages)([r[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,a.stringify)(t.meta):void 0,...r.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const o=r(49769),a=r(55835),l=r(54993),u=r(22911),c=r(89788),d=r(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,i.set(this,new Map),n.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,o.getOrSet)(s(this,i,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const r=this.target.emit(e,...t),o=s(this,i,"f").get(e);return null!=o&&(o.resolve(t),s(this,i,"f").delete(e)),r}emitDebounced(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},i=new WeakMap,n=new WeakMap},34102:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const i=r(78474),n=r(19851),s=r(15197);t.ee=(0,n.lazy)((()=>{const e=new i.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const n=i(r(73024)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(65843),u=r(16287),c=r(43334),d=(0,o.lazy)((()=>s.default.geteuid?.())),h=(0,o.lazy)((()=>s.default.getgroups?.()));function f(e,t){try{return!(0,a.blank)(e)&&(n.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,n.default.constants.R_OK|n.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,n.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:r=!1,x:i=!1,processUid:n,processGid:s}){if(null==e)return!1;const o=n??d(),a=null!=s?[s]:h()??[],l=0===o,u=l||e.uid===o,f=l||a.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(r&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!i||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const r of(0,l.selfAndAncestorG)(e)){const i=await(0,u.statMaybe)(r);if(null!=i){if(!i.isDirectory())return!1;if(t){if(!p(i,e))return!1}else if(t=!0,!m(i,e))return!1}}return!0},t.access=g},21144:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const n=i(r(76760)),s=r(19851),o=r(81168),a=r(57159),l=r(43334),u=r(88561),c=r(29882),d=r(65238),h=r(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const r=(0,c.parseNativePath)((0,h.resolve)(...e)),i=await m(r.dir);for(const e of await(0,d.readdir_)(i))if((0,o.equalsIgnoreCase)(e.basename,r.base))return n.default.join(i,e.basename);throw new a.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const i=r(73024),n=r(76760);function s(e){return[...o(e)]}function*o(e){for(;e!==(0,n.dirname)(e);)e=(0,n.dirname)(e),yield e}function a(e){try{return(0,i.readdirSync)(e)}catch(e){return[]}}function l(e,t){const r=a(e);return t.every((e=>r.includes(e)))}t.ancestors=s,t.ancestorG=o,t.selfAndAncestorG=function*(e){yield e,yield*o(e)},t.childrenSync=a,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,r){var i,n,s,o,a,l=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&l(t,e,r);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(r(44652)),p=c(r(73024)),g=r(51455),y=f(r(76760)),v=f(r(1708)),w=r(46466),S=f(r(57975)),b=f(r(38522)),P=r(19851),_=r(40958),E=r(5233),M=r(22573),C=r(42659),T=r(50357),x=r(96249),D=r(98553),k=r(55835),O=r(31586),I=r(68708),F=r(97790),A=r(39926),N=r(51926),L=r(59455),R=r(54993),j=r(48884),B=r(22911),V=r(99331),z=r(56519),W=r(56038),q=r(31562),U=r(76850),H=r(70025),G=r(34102),J=r(80875),K=r(50213),$=r(70417),Y=r(43334),Z=r(81168),X=r(96859),Q=r(65162),ee=r(94174),te=r(64660),re=r(21144),ie=r(84542),ne=r(89968),se=r(20197),oe=r(88561),ae=r(50597),le=r(33456),ue=r(29882),ce=r(78133),de=r(43899),he=r(65238),fe=r(53265),me=r(17217),pe=r(16287),ge=r(68284),ye=r(66003),ve=r(27794),we=r(73428),Se=r(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new oe.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(i.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,K.mkLogger)("fs.BaseFile("+this.nativePath+")"))),n.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),o.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(n=new WeakMap,o=new WeakMap,i=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),r=await Promise.all(t.map((e=>e.shaMs())));return t[(0,j.leastIndex)(r)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const r=(0,me.isSimpleFile)(e)?e.nativePath:(0,R.toS)(e);if((0,M.blank)(r))throw new Error("BaseFile.for(): empty nativePathOrFile");const i=be().get(r);if(null!=i)return i;const n=(0,fe.resolve)(r),s=new Pe(n,t);return be().set(r,s),be().set(n,s),s}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,n,"f").unset(),h(this,o,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,z.thenMap)(this.stat(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,k.map)(this.statSync(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,n,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const r=[];for(const i of t)!0===await e(i)&&r.push(i);return r}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,z.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,i,"m",s).call(this)??await d(e=this.clearThisAndParent(),i,"m",s).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,z.thenMap)(this.children(),(async t=>{for(const r of t)await r.visitDescendants(e),await e(r)}))}async descendants(e){const t=[];t.push(...(0,L.toA)(await this.childFiles(e)));const r=await this.childDirectories();if(null==r)return t;for(const i of r)t.push(...(0,L.toA)(await i.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,O.gt0)(t))return;const r=await d(this,n,"f").call(this)??[];for(const t of r)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const i of r)if(i.isDirectory()){const r=await this._directoryEntryChild(i).someDescendant(e,t-1);if(null!=r)return r}}descendantsSync(e){const t=this.directoryEntrySync(),r=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&r.push(this.forDirectoryEntry(t))})),r}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,re.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,T.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,k.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,r)=>this.join((0,R.toS)(e),(0,A.pad2)(t+1),(0,A.pad2)(r))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,x.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,r="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(r,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,r="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(r,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,r){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(r??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,z.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,z.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,z.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,z.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,C.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,z.thenMap)(this.statTimes(),j.max)}maxStatDate(){return(0,z.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,z.thenMap)(this.statTimes(),$.min)}minStatDate(){return(0,z.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,z.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,z.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,z.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,z.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>=(0,C.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,z.thenMap)(this.mtimeMs(),(r=>Math.abs(r-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>(0,C.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,z.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,k.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,F.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,q.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*C.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,ae.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,ae.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,J.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,J.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,U.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,z.thenMap)(this.zReadFile_(e),R.toS)))}readLines(e="warn"){return(0,z.thenMap)(this.readTextFile(e),ie.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces),(0,I.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,E.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,V.ending)()?1:3,timeoutMs:0,retryDelay:C.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,i,"m",a).call(this,(0,Z.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,i,"m",a).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,i,"m",a).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const r=await this.children((async r=>!r.isNameHidden()&&t===r.size()&&r.nativePath!==e.nativePath));if((0,_.isEmpty)(r))return;const i=await e.sha();if(null!=i)for(const e of r.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===i)return e}))}firstMatchingLine(e){const t=new B.Deferred("firstMatchingLine("+this+")"),r=p.default.createReadStream(this.nativePath,{flags:"r"});return r.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),r.close()):t.maybeReject(e)})),r.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(r,(0,N.newlineRe)(),(i=>{const n=e.exec(i);null!=n&&(t.maybeResolve(n),r.close())})),t.promise}contemporary(e,t){return(0,z.thenMap2Or)(this.statTimes(),e.statTimes(),((e,r)=>{for(const i of e)for(const e of r)if((0,O.closeTo)(i,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),r=new B.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&r.setTimeout(e.timeoutMs),_e)try{const i=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(i,n)=>{try{const s=await e.f(i,(0,k.denull)(n));t(s)&&r.resolve(s)}catch(e){r.reject(e)}}));r.finally((()=>{i.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,O.gt0)(e.intervalMs)){const i=setInterval((async()=>{try{const i=await e.f();t(i)&&r.resolve(i)}catch(e){r.reject(e)}}),e.intervalMs);e.persistent||i.unref(),r.finally((()=>{clearInterval(i)}))}return r}}t.BaseFile=Pe,s=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,j.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,k.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},a=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const r=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(r.nativePath,{autoClose:!0})]),await this.unlink(),r}))},Pe.attrTTL=3*C.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},84542:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const i=r(40958),n=r(96249),s=r(51926),o=r(54993),a=r(43334);function l(...e){return(0,n.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,o.toS)(e).split((0,s.newlineRe)()))))}t.Newline=a.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(o.toS).join("\n");return a.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,i.compactBlanks)(l(...e))}},70698:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const i=r(76760),n=r(19851),s=r(50213),o=r(37805),a=r(29882),l=r(93854),u=r(17217),c=r(16287),d=r(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,n.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const r=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return r===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,i.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const r=(0,u.toNativePath_)(e);await(0,a.mkdirp_)(r),await(0,d.writeTextfile_)((0,a.joinNativePath)([r,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+o.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(45969),u=r(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,o.lazy)((()=>[...(0,a.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,n.default.join(e,"System32"),n.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const a=s(r(44652)),l=o(r(73024)),u=r(76760),c=r(57975),d=r(19851),h=r(59455),f=r(50213),m=r(81168),p=r(34102),g=r(29882),y=r(65238),v=r(14427),w=r(17217),S=r(16287),b=r(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class E{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new E(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:r,base:i}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},n=await a.stat(t);return new E(r,new P(i,n))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return E.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new E(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>E.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new E(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const r of t)r.isDirectory()&&await r.visitDescendants(e);for(const r of t)r.isFile()&&await e(r);for(const r of t)r.isDirectory()&&await e(r)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const r of t)r.isFile()&&e(r);for(const r of t)r.isDirectory()&&(r.visitDescendantsSync(e),e(r))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async r=>{!0===await e(r)&&t.push(r)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await a.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await a.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=E},20197:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const n=i(r(76760)),s=r(39926),o=r(29882),a=r(16287),l=r(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if(await(0,o.mkdirp_)(i.dir),!r.requireNumber&&await(0,a.isEmptyFile)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if(await(0,a.isEmptyFile)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)},t.ensureNewNativePathSync_=function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if((0,o.mkdirpSync_)(i.dir),!r.requireNumber&&(0,l.isEmptyFileSync)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if((0,l.isEmptyFileSync)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)}},88561:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const o=r(40958),a=r(22573),l=r(41400),u=r(68708),c=r(25764),d=r(38836),h=r(34102),f=r(80049),m=r(50213),p=r(88158),g=r(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),i.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>s(this,i,"m",n).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,o.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,i=new WeakSet,n=async function(e){if((0,a.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const i=r(73024),n=r(22573),s=r(45599),o=r(96249),a=r(68708),l=r(54993),u=r(49047),c=r(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,s.defer)((()=>{const e={};for(const[t,...r]of d)for(const i of r)e[i]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof i.Dirent?e.name:(0,l.toS)(e),r=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,n.blank)(r)?void 0:h()[r]??r}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,o.flatten)((0,a.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const r of t)if(r===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const i=r(68708),n=r(17217),s=r(16287),o=r(68284);async function a(e){return(0,i.pick)(await(0,s.stat_)((0,n.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=a,t.fileStats=async function(e){try{return await a(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,o.statSync)((0,n.toNativePath)(e)))?void 0:(0,i.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},4001:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const i=r(22573),n=r(55835),s=r(31586),o=r(51926),a=r(54993),l=r(97352),u=r(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,i.toNotBlank)(e.name)??(0,a.toS)(e),t).normalize()}function f(e,r){if(t.ymdIsoRE.test(e))return e;let i=e;for(const e of r.aggressive?d:c){const t=i.match(e);if((0,s.gt0)(t?.index)){const e=i.slice(0,t.index).trim();e.length>0&&(i=e)}}return e===i?e:f(i,r)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),r=t.pop();if((0,i.blank)(r))return e;const n=(0,u.parsePosixPath)(r),s=h(n,{aggressive:!1});return[...t,s+n.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,o.isString)(e)?e:e.name).toLowerCase().normalize(),r=h(t),i=(0,o.stripPrefix)(t.toLowerCase().normalize(),r);return(0,n.map)((0,l.extractInt)(i),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,o.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,n.map)(m.exec(t),(e=>t=e[1].trim())),(0,n.map)(g.exec(t),(e=>t=e[1].trim())),t}},50597:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const n=i(r(77598)),s=i(r(73024)),o=r(46466),a=r(19851),l=r(98553),u=r(68708),c=r(23467),d=r(80049),h=r(73913),f=r(50213),m=r(12089),p=r(37628),g=r(43624),y=r(17217),v=r(16287),w=(0,a.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),S=(0,a.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:r=!0}={}){const i=(0,y.toNativePath_)(e);if(r){const t=S().get(i);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:i,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:i,prior:t}),S().delete(i)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),r=(0,y.toNativePath_)(e);return{sha:await _(s.default.createReadStream(r)),stats:(0,u.pick)(await(0,v.stat_)(r),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],r="sha512"){const i=n.default.createHash(r);return await(0,o.pipeline)([e,...t,i]),i.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return n.default.randomBytes(h.HashBits/8).toString("base64")}},25675:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const i=r(22573),n=r(54993),s=r(7282),o=r(43334),a=r(69375),l=/^\/dev(?:\/|$)/i,u=o.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=o.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=o.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=o.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,n.toS)(e))}function m(e){return(0,i.blank)(e)?"blank":(0,a.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},33456:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const i=r(57075),n=r(51926),s=r(54993);class o extends i.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,r){const i=(this._prior+(0,s.toS)(e)).split((0,n.newlineRe)()),o=i.pop();this._prior=o??"";let a=!1;for(const e of i)a||(a=!this.push(e));a?setTimeout(r,1):r()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=o},64680:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const n=i(r(76760)),s=r(17217),o=r(73428);t.mkNoMedia_=function(e){return(0,o.writeTextfile_)(n.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},29882:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(5233),u=r(22573),c=r(98553),d=r(39426),h=r(51926),f=r(48884),m=r(50213),p=r(81168),g=r(70025),y=r(43334),v=r(78133),w=r(53265),S=r(17217),b=r(16287),P=r(66430),_=r(5545);function E(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,o.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=E,t.containsHiddenPathname=function(e){return k(e).some(E)},t.isNotHiddenPosixPath=function(e){return k(e).every((e=>!E(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return C((0,v.posix2native)(e))},t.extname=function(e){return C(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function C(e){const t=M.exec(e)?.groups,r=t?.ext2??"",i=s.default.parse(t?.path??e);return{...i,ext:(i.ext??"")+r,base:(i.base??"")+r}}function T(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,s.default.sep)}function x(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),r=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(r))return!1;const i=e.acceptSelf??!1;return t===r?i:r.startsWith((0,p.ensureSuffix)(t,s.default.sep))}catch(r){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:r}),!1}}function D(e,t,r){if(null==t||null==r)return!1;const i=e(t),n=e(r);return null!=i&&null!=n&&(y.isLinux?i===n:(0,p.equalsIgnoreCase)(i,n))}function k(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function O(e){return(0,u.notBlank)(e)&&k(e).length===(y.isWin?1:0)}function I({p:e,maxLength:t}){const r=(0,S.toNativePath_)(e);if(r.length<=t)return r;const i=k(e),n=[],s=[i.pop()];for(;i.length>0;)if(n.length=t){i.unshift(n.pop());break}}else if(s.unshift(i.pop()),A([...n,...s]).length>=t){i.push(s.shift());break}return i.length>0&&n.push("…"),A([...n,...s])}function F(e){return e.startsWith("\\\\")}function A(e){return(0,h.ensurePrefix)((0,a.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=C,t.parentBasename=T,t.grandParentBasename=function(e){return T(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=x,t.eqlBasename=function(e,t){return D(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return D(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return D(S.toNativePath_,e,t)},t.toPathnames=k,t.pathIsRoot=O,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:k(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const r=(0,S.toNativePath_)(e),i=(0,S.toNativePath_)(t);if((0,u.blank)(r)||(0,u.blank)(i))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return r===i?"":(0,p.stripPrefix)((0,v.native2posix)(i).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(r),"/").normalize()).normalize()},t.ellipsizePath=I,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:r=4,arrLength:i=e.length}){const n=[];for(const i of e.slice(0,r))n.push(I({p:i,maxLength:t}));return n.join(", ")+(i>r?`, and ${i-r} more…`:"")},t.posixPathFromParent=function(e){return k(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return k(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const r=C(e);return`${r.base}${t}${r.ext}`},t.isUNC=F,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(F(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(O(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await n.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;n.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>n.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=A,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:A(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>x({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(31586),u=r(51926),c=r(12168),d=r(59455),h=r(54993),f=r(50213),m=r(44198),p=r(96706),g=r(45969),y=r(43334),v=r(64660),w=r(21144),S=r(16287),b=(0,s.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const r=await(0,S.statMaybe)(e,"trace");return null!=r&&r.isFile()&&(0,l.gte)(r.size,t)&&(0,v.isStatRX)(r,e)}function E(){if(y.isWin){const e=(0,a.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,a.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",r=(0,a.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,n.default.join(e,"System32"),n.default.join(e,"System32","Wbem"),n.default.join(r,"chocolatey","bin"),n.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(n.default.delimiter);return(0,o.uniq)((0,o.compactBlanks)([...e,...E()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:r}){const i=(0,o.uniq)((0,o.compactBlanks)([...M(),...(0,d.toA)(r)]));for(const r of(0,o.uniq)((0,o.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(r,".exe"):r;for(const t of i){const r=n.default.join(t,e);if(await _(r))return y.isLinux?r:(0,w.actualPath)(r)}}b().warn("Failed to find tool",{tool:e,dirs:i})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},78133:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const n=i(r(76760)),s=r(22573),o=r(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(n.default.sep===n.default.posix.sep)return e;const r=(0,s.notBlank)(t)?n.default.sep+n.default.sep+t+n.default.sep:"",i=e.split(n.default.posix.sep);return(0,o.equalsIgnoreCase)(i[0],t)&&i.unshift(),r+i.join(n.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||n.default.sep===n.default.posix.sep||n.default.posix.sep===n.default.sep?e:e.split(n.default.sep).join(n.default.posix.sep)}},43899:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(48884),u=r(50213),c=r(45969),d=r(29325),h=r(43334),f=r(65843),m=r(25675),p=r(53265);function g(...e){return(0,o.lazy)((()=>n.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,o.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(n.default.join((0,p.execDir)(),"resources"),n.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,a.compactBlanks)([(0,p.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const r of t){if((0,f.hasChildrenSync)(r,e))return r;for(const t of(0,f.ancestors)(r).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const i=n.default.join(r,"node_modules","photostructure");if((0,f.hasChildrenSync)(i,e))return i}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const i=r(44652),n=r(19851),s=r(31586),o=r(50213),a=r(57902),l=r(69428),u=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=a.LogLevels.info){try{return await(0,i.readFile)(e)}catch(r){return void u().log(t,".readFileMaybe("+e+")",r)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const i=r(44652),n=r(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:r}){let s=-1;try{const n=r??(await(0,i.stat)(e)).size-t,o=Buffer.alloc(n);return s=await(0,i.open)(e,"r"),await(0,i.read)(s,o,0,n,t)}finally{(0,n.mapGte0)(s,i.close)}}},69428:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const o=s(r(73024));t.readFileSync=function(e){try{return o.readFileSync(e)}catch{}}},32323:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const i=r(57075);class n extends i.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=n},65238:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const n=i(r(51455)),s=r(76760),o=r(19851),a=r(76790),l=r(22573),u=r(42659),c=r(41400),d=r(31586),h=r(13538),f=r(83104),m=r(54127),p=r(50213),g=r(95937),y=r(34102),v=r(28874),w=r(63870),S=r(88561),b=r(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,o.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,o.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await n.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const E=(0,o.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||E.prior()?.delete(e)}async function C(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await E().getOrSetAsync(e,(()=>async function(e){const r=Date.now()+2*(0,b.statTimeoutMs)(),i=T(e),n=await(0,h.thenOrTimeout)(i,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(n===f.Timeout&&(0,g.onTimeout)({soft:!1}),n!==f.Timeout&&n.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),E.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,o.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!E().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=E().get(e)},t.childDirectories_=async function(e){return(await C(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?C(e):T(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=C,t.readdirCached=function(e){return E().get(e)},t.readdirUncached_=T},53265:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const n=r(73024),s=i(r(76760)),o=r(40958),a=r(22573),l=r(45599),u=r(50213),c=r(43334),d=r(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,o.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const r=s.default.resolve(t,...e);if((0,n.existsSync)(r))return r}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,a.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(a.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},50274:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const i=r(50989);t.SidecarExts=(0,i.strEnum)("xmp","mie","exv")},14427:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const i=r(22573),n=r(38639);t.isSimpleDirent=function(e){return null!=e&&(0,i.notBlank)(e.basename)&&(0,n.isBoolean)(e.isFile)&&(0,n.isBoolean)(e.isDirectory)}},17217:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const n=i(r(73024)),s=i(r(76760)),o=r(22573),a=r(98553),l=r(81168),u=r(43334),c=r(29882),d=r(53265),h=r(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,o.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,o.blank)(e.nativePath))throw new Error(`toNativePath(${(0,a.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof n.default.Dirent?e.name:f(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:s.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),r=t.indexOf(s.default.sep);return r>0?t.slice(1,r):void 0}},t.findFileIndex=function(e,t){for(let r=0;r(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,a.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(n.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,a.blank)(e)?void 0:v(e).catch((r=>{y().log(t,"stat() failed",{error:r,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const r=S(e),i=S(t);if(r!==i)return"inconsistent file type: "+r+" ≠ "+i;for(const r of["size","mtime"]){const i=e[r],n=t[r],s=(0,u.diff)(b(i),b(n));if(null==s||s>1)return"unmatched "+r+": "+i+" ≠ "+n}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const r=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=r&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(r)},t.isNonEmptyFile=async function(e,t=0){const r=await w(e);return null!=r&&r.isFile()&&r.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.access)({stat:r,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.isStatRWX)(r,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,o.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const n=i(r(73024)),s=r(22573);function o(e){try{return(0,s.blank)(e)?void 0:n.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function a(e){return null==e||e.isFile()&&0===e.size}t.statSync=o,t.isEmptyStats=a,t.isFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const r=o(e);return t.emptyIsNew?null==r:a(r)},t.isNonEmptyFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isDirectorySync=function(e){return!0===o(e)?.isDirectory()}},41080:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const i=r(28874);t.statTimeoutMs=function(){return i.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const i=r(22573),n=r(56409);t.onDataChunked=function(e,t,r){const i=new s(t,r,!0);return i.read(e),i.done};class s{constructor(e,t,r=!0){this.sep=e,this.onData=t,this.filterBlanks=r,this.incompleteChunk="",this.done=new n.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,i.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,i.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const n=i(r(57075)),s=r(41400),o=r(55835),a=r(68708),l=r(42279),u=r(99331),c=r(70025);class d extends n.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((r,i)=>{!1===e.write(t,(e=>{e&&i(e)}))?e.once("drain",r):r()}))},t.endStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,a.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:r,ea:i}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,o.map)(i,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(r,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends n.default.Transform{constructor(e){super({transform:(e,t,r)=>{this.onProgress(this.bytes+=e.length),r(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const n=i(r(73024)),s=r(76760),o=r(22573),a=r(76596),l=r(64660),u=r(78133),c=r(68284);function d(e){if((0,o.blank)(e))return!1;try{return n.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,a.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,o.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,o.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,o.blank)(e)&&d((0,u.posix2native)(e))}},27794:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const n=i(r(44652)),s=r(19851),o=r(22573),a=r(42659),l=r(31586),u=r(68708),c=r(13538),d=r(29882),h=r(17217),f=r(16287),m=r(41080);function p(e){return null==e?void 0:(0,a.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const r=t.ensureFile??!0;if(null==t.file||(0,o.blank)(t.file))throw new Error("can't touch blank path");const i=(0,h.toNativePath_)(t.file);r&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const a=(0,s.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await a())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await a())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(n.default.utimes(i,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!r||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(n.default.ensureFile(i),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},5545:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const n=i(r(76760)),s=r(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const r=t.driveRe.exec(e)?.groups;return null==r?e:r.drive.toUpperCase()+(0,s.toS)(r.path??n.default.sep)}},58722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const i=r(57075),n=r(22911);class s extends i.Writable{constructor(e){super(e),this.deferred=new n.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,r){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),r()}}t.WritableToBuffer=s},73428:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(51926),a=r(54993),l=r(34102),u=r(84542),c=r(29882);async function d(e,t){const r=s.default.dirname(e);await(0,c.mkdirp_)(r),await n.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",r)}function h(e,t){const r=s.default.dirname(e);(0,c.mkdirpSync_)(r),n.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",r)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const r=(0,u.crlf)(...(0,o.wrap)(t));await d(e,r)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))}},13047:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const n=i(r(73024)),s=r(76760),o=r(46466),a=r(38522),l=r(19851),u=r(40958),c=r(98553),d=r(80875),h=r(50213),f=r(57159),m=r(29882),p=r(57902),g=r(32323),y=r(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,r){const i=[],s=[n.default.createReadStream(e,{autoClose:!0,...r}).on("error",(e=>i.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,a.createGunzip)().on("error",(e=>i.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,a.createBrotliDecompress)().on("error",(e=>i.push(e)))),s.push(t),await(0,o.pipeline)(s),(0,u.isNotEmpty)(i))throw new f.WrappedError("zPipe("+e+") failed",{causes:i,path:e})}async function b(e,t){const r=new y.WritableToBuffer;return await S(e,r,t),await r.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function _(e,t){const r=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,o.pipeline)(new g.ReadableBuffer(r),(0,a.createGzip)(),n.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(r){return void v().log(t,"readJsonGz("+e+"): failed",r)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,r=p.LogLevels.warn){try{await _(e,t)}catch(t){v().log(r,"outputJsonGz("+e+"): failed",t)}}},33866:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const i=r(50989);t.HealthCheckIds=(0,i.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},52086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const i=r(50989);t.CropStrategies=(0,i.strEnum)("center","entropy","attention")},48584:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const i=r(50989);t.SharpFailOns=(0,i.strEnum)("none","truncated","error","warning")},32105:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const i=r(19851),n=r(23560),s=r(66184),o=r(72210);class a{log(e,t,r,i){this.enabled(e,t)&&(0,o.pushLogEntries)({ts:Date.now(),l:e,from:(0,n.processName)(),ctx:t,msg:r,meta:i})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=a,a.instance=(0,i.lazy)((()=>new a))},14593:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const i=r(57975),n=r(22573),s=r(26905),o=r(55835),a=r(68708),l=r(13538),u=r(50213),c=r(97352),d=r(45255),h=r(76740),f=r(57159),m=r(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,n.toNotBlank)(e)??(0,s.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[i.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const r=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,a.omit)(t,"error")});throw Error.captureStackTrace?.(r),this.log(!0===r.ignorable?"warn":"error",".throw() "+r.message,{stack:r.stack,...t}),r}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let r;try{r=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const i=e.result(),n=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:i,meta:{...e.meta,elapsedMs:n}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,o.map)(r,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,a.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const r of this.loggers())if(r.enabled(e,t??this.context))return!0;return!1}log(e,t,r){for(const i of this.loggers())i.log(e,this.context,t,r)}elapsed(e,t,r){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...r})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},28981:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const i=r(19851),n=r(51879);t.DefaultLogFormatter=(0,i.lazy)((()=>new n.PlaintextLogFormatter))},20839:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},4904:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const i=r(76790),n=r(31586),s=r(51926),o=r(57902);t.isLogEntry=function(e){return null!=e&&(0,n.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&o.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,i.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const i=r(19851),n=r(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,n.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,n.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,i.lazy)((()=>new s(n.LogLevels.warn))),t.defaultLogLevel=(0,i.lazy)((()=>n.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,n.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,r){return(0,t.logFilter)().enabled(e)?r():void 0},t.isLogged=function(e,r){return(0,t.logFilter)().enabled(e,r)}},57902:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const i=r(42659),n=r(31586),s=r(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const o=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??o},t.levelGte=function(e,r){return(0,n.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(r))};const a=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return a.get(e)},t.msTolevel=function(e,t=7*i.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},72210:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const i=r(92322),n=r(82328),s=r(28981),o=r(20839),a=r(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new i.SortedSet(a.logEntrySorter),t.pushLogEntries=function(...e){for(const r of e)l?t.logEntries.add(r):(0,n.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(r))},t.popExpiredLogEntries=function(e=2*o.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},51879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(68708),a=r(54993),l=r(23560),u=r(81168),c=r(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,o.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,n.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,i.inspect)(e,this.inspectOptions)))]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,r,i){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:r,meta:i})}}},82647:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const o=r(57975),a=r(40958),l=r(96249),u=r(55835),c=r(31586),d=r(68708),h=r(59455),f=r(48884),m=r(89788),p=r(22454),g=r(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const r=t.clone();return r.pushAll(e.samples),r}if(t.n<=t.maxSamples){const r=e.clone();return r.pushAll(t.samples),r}{const r=new y(Math.max(e.maxSamples,t.maxSamples));r._n=e.n+t.n,r._min=Math.min(e._min,t._min),r._max=Math.max(e._max,t._max),r._m=e._m*e.n/r.n+t._m*t.n/r.n,r._s=e._s*e.n/r.n+t._s*t.n/r.n;const i=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return r._samples.push(...i),r._weightedTotalAvg=(0,g.weightedAvg)([r._m,...i]),r}}constructor(e=20){i.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(i=new WeakSet,o.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),r={};return r.k=t(this.n),this.empty||(r.mean=t(this.avg),r.sum=t(this.sum),r.sd=t(this.stdDev),r.max=t(this.max),r.min=t(this.min)),r}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,i,"m",n).call(this,-1)}get p29(){return s(this,i,"m",n).call(this,-.5)}get p38(){return s(this,i,"m",n).call(this,-.25)}get p69(){return s(this,i,"m",n).call(this,.5)}get p84(){return s(this,i,"m",n).call(this,1)}get p98(){return s(this,i,"m",n).call(this,2)}get p99(){return s(this,i,"m",n).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,a.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,a.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,a.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,n=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const i=r(40958),n=r(55835),s=r(31586),o=r(30976),a=r(48884),l=r(70417);function u(e,t){const r=Math.pow(2,t),i=[];for(;e>0;)i.unshift(e%r),e=Math.floor(e/r);return i}t.concatBits=function(e,t){const r=Math.pow(2,t);return e.reduce(((e,t)=>e*r+(0,s.clamp)(0,r,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,r){return(0,n.map2)(e,t,((e,t)=>(0,i.sum)((0,a.zip)(u(e,r),u(t,r)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,o.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max)),n=this.clampValue(e);let s=0;for(let e=0;eo?(s+=1,r[t]=o):i[t]=o}return s}unzip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max));for(let n=0;n(r[e]+i[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,r){return!0!==r&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let r=0;rs?(t+=1,n.min=s):n.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const r=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,i.sum)(e,((r,i)=>t(r,i)?Math.pow(2,e.length-i-1):0))}},55222:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const i=r(77598),n=r(22573),s=r(55835),o=r(32639),a=r(88158),l=r(81168),u=BigInt(0);function c(e,t,r=0){if(!isFinite(t)||e<=1)return[];const i=[];if(0===t)i.unshift(0);else for(;t>0;)i.unshift(t%e),t=Math.floor(t/e);for(;i.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const r=e<0;return r&&(e=Math.abs(e),t--),(r?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],r=BigInt(this.base);let i=e;for(;i>u;)t.push(Number(i%r)),i/=r;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let r of e)for(t.forEach(((e,i)=>{r+=e<<8,t[i]=r%this.base,r=Math.floor(r/this.base)}));r>0;)t.push(r%this.base),r=Math.floor(r/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,n.blank)(e))return;const t="-"===(e=(0,o.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const r=BigInt(this.base);let i=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;i=i*r+BigInt(e)}return t?BigInt(-1)*i:i}randomChars(e){return this.encodeBuffer((0,i.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,r="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(r)}tokenEql(e,t,r){const i=this.normalizeToken(e),n=this.normalizeToken(t);return i.length>=r&&i===n}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const i=r(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,i.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},70417:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const a=r(40958),l=r(55835),u=r(31586),c=r(59455),d=r(22454),h=r(77377),f=r(82647);function m(e){let t;for(const r of e)null!=r&&(null==t||rt)&&(t=r);return t}function y(e,t){const r=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&r.incr(t);return r.topKeys(t)}function v(e,t){let r=0,i=0;for(const n of e){if(null!=n){const e=t(n,r);(0,u.isNumber)(e)&&(i+=e)}r++}return i}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,r)=>e-t[r]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const r of e)(0,u.isNumber)(r)&&(t+=r);return t},t.sumf=v;class w{constructor(){i.set(this,0),n.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(o(this,n,null==s(this,n,"f")?e:s(this,n,"f")*s(this,i,"f")/(s(this,i,"f")+1)+e/(s(this,i,"f")+1),"f"),o(this,i,(t=s(this,i,"f"),++t),"f"))}get mean(){return s(this,n,"f")}}function S(e){const t=new w;for(const r of e)t.push(r);return t.mean}function b(e){const t=S(e);if(null==t)return;let r=0,i=0;for(const n of e)(0,u.isNumber)(n)&&(i++,r+=(n-t)*(n-t));return r/i}function P(e){let t=0;for(const r of e)t+=r*r;return Math.sqrt(t)}function _(e,t){let r=0;for(let i=0;i(1-t)*e+t*(r+o*(e-n)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),r=S(t);if(null!=r){const e=(t.length-1)/2,i=v(t,((t,i)=>(t-r)*(i-e))),n=v(t,(e=>(e-r)**2));return 0===n?0:i/n}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let r;t=(0,u.clamp)(0,1,t);for(const i of e)r=null==r?i:r*t+i*(1-t);return r},t.centroid=function(e){const t=e[0].length,r=[];for(let i=0;ie[i]))));return r},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,a.isEmpty)(e)&&(0,a.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},45969:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const i=r(73024),n=r(38639),s=r(19851),o=r(59958),a=r(43334);t.isDocker=(0,s.lazy)((()=>a.isLinux&&((0,n.toBoolean)(process.env[o.PS_IS_DOCKER])??(0,i.existsSync)("/.running-in-container"))))},29325:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const i=r(76760),n=r(19851),s=r(54993);t.isPacked=(0,n.lazy)((()=>!(0,s.toS)(__filename).includes((0,i.join)("core","platform","IsPacked"))))},43334:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(22573),a=r(38639),l=r(59958),u=n.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,a.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,a.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,o.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===n.default.arch(),t.isArm=null!=/^arm\b/i.exec(n.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,o.notBlank)(s.default.env.APPIMAGE)||(0,o.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,o.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,a.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const n=i(r(73024)),s=r(19851),o=r(43334);function a(e="/proc/cpuinfo"){if(o.isWin||o.isMac)return!1;try{return null!=n.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=a,t.isRaspberryPi=(0,s.lazy)((()=>o.isLinux_arm&&a())),t.procDeviceModel=(0,s.lazy)((()=>{try{return o.isLinux?n.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},45643:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const i=r(58587),n=r(59455),s=r(31562);t.existingPids=function(e){return(0,n.toA)(e).filter(i.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,i.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=r(58587),d=u(r(31421)),h=u(r(1708)),f=r(40958),m=r(22573),p=r(42659),g=r(55835),y=r(31586),v=r(97790),w=r(59455),S=r(54993),b=r(54557),P=r(19851),_=r(50213),E=r(88158),M=r(409),C=r(78406),T=r(25764),x=r(99331),D=r(56519),k=r(46292),O=r(8769),I=r(83278),F=r(32144),A=r(29882),N=r(43334),L=r(24399),R=r(58261),j=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),B=10*p.secondMs;function V(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const r=(0,g.map)(t.start,(e=>e.getTime())),i=e.startTime;return(0,y.gt0)(r)&&(0,y.gt0)(i)&&Math.abs(r-i){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,F.isJsonExt)(t)&&(0,A.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))j().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{j().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,r=e.force??N.isWin,i=await this.pidfiles(),n=await this.pids(i??[]);if((0,f.isEmpty)(n))return j().info("killOldProcs(): no pidfiles"),[];const s=[],o=[],a=await(0,R.pidInfos)(n);if(null!=a){for(const n of i){const i=await n.readJson();if(null==i){j().warn("killOldProcs(): failed to read pidfile "+n.base),await n.unlink("debug");continue}const l=i.pid;if(!(0,y.gt0)(l)){j().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+n.base,{json:i,pid:l}),await n.unlink("debug");continue}const u=a.find((e=>e.pid===l));if(null==u||!V(i,u)){j().debug("killOldProcs(): pid no longer present: unlinking "+n.base,{json:i,pidEntry:u}),await n.unlink("debug"),s.push(i);continue}const c=(0,y.gt0)(i.timeoutMs)?i.startTime+i.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(i.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(j().info("killOldProcs(): killing",{reason:d,json:i}),o.push(W(l,r,!1)),s.push({...i,...u}))}return o.length>0&&await Promise.allSettled(o),s}(0,O.onError)("Pids.killOldProcs(): failed to get process information")}}),o.set(this,void 0)}async addPid_(e,t,r=!1){if(null==e)throw new Error("undefined info");const o=e.pid;if(!(0,y.gt0)(o))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(o)?(r&&a(this,n,"f").delete(l),a(this,n,"f").getOrSet(l,(async()=>{const r=a(this,i,"m",s).call(this,e.pid),n=(0,v.opt)((0,E.Try)((()=>(0,A.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),o=t.getTime(),l={...e,cmd:n,startTime:o};return await r.writeJson_(l),j().debug("addPid() wrote "+r,l),r}))):(a(this,n,"f").delete(l),void j().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=a(this,i,"m",s).call(this,e);return(0,D.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{j().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==a(this,o,"f")||a(this,o,"f").ended)&&l(this,o,new C.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:T.EndableRanks.first}),"f"),a(this,o,"f")}cancelInterval(){a(this,o,"f")?.end(),l(this,o,void 0,"f")}}t.Pids=q,n=new WeakMap,o=new WeakMap,i=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},q.instance=(0,P.lazy)((()=>(0,g.map)((0,k.configDir)(),(e=>new q(I.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return q.instance()?.addPid_(e,t)}},58261:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const n=r(31421),s=r(48161),o=i(r(1708)),a=r(40958),l=r(22573),u=r(42659),c=r(31586),d=r(68708),h=r(59455),f=r(54993),m=r(48884),p=r(53507),g=r(19851),y=r(50213),v=r(84968),w=r(48963),S=r(56519),b=r(84777),P=r(8103),_=r(45879),E=r(43334),M=r(24399),C=r(45643),T=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function x(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function D(e){if(E.isLinux)return async function(e){const t=[];for(const r of e)t.push(z(await(0,_.readFileMaybe)("/proc/"+r+"/stat")));return T().tap({msg:"pidInfoProc",result:(0,a.compact)(t)})}(e);const t=(0,C.existingPids)(e),r=(await(0,m.collectBatchedAsync)(t,20,E.isWin?F:R)).filter((e=>x(e)&&t.includes(e.pid)));return T().tap({msg:"pidInfos()",result:r,meta:{pids:e}})}t.isProcEntry=x,t.pidInfo=async function(e){return(0,S.thenMap)(D([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,a.isEmpty)(e)?[]:(0,S.thenMap)((0,C.existingPids)(e),(t=>{const r=[o.default.pid,...t];return e.filter((e=>!r.includes(e)))}))},t.pidInfos=D;const k="Get-Process",O="| Select-Object -Property Id,ProcessName,StartTime";function I(e){return(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).join(",")}async function F(e){if(M.PowerShell.instance().ended)return L(e);const t=[k,"-Id",I(e),"-ErrorAction SilentlyContinue",O].join(" ");return(0,S.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const A={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},N=["CommandLine","CreationDate","ProcessId"];async function L(e){const t=["process"];if((0,a.isNotEmpty)(e)){const r=(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",r)}t.push("get",N.join(","));const r=await(0,b.stdoutResult_)((0,P.wmic)(),t,A),i=(0,d.onlyReqValued)((0,p.parseFixed)(N,r.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return i.find((e=>e.pid===o.default.pid))||i.push({pid:o.default.pid,start:new Date(v.StartTs),cmd:"node "+o.default.title}),i}async function R(e){return t=(await(0,b.stdoutResult_)("ps",["-p",I(e),"-wwwo","pid,lstart,command"],{...A,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=L;const j=(0,g.lazy)((()=>{try{if(E.isLinux)return(0,c.toGt0)((0,n.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){T().warn("clk_tck failed",{error:e})}return 100})),B=(0,g.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),V=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function z(e){const t=V.exec((0,f.toS)(e))?.groups,r=(0,c.toInt)(t?.pid),i=t?.comm,n=(0,c.toInt)(t?.starttime);return(0,c.gt0)(r)&&!(0,l.blank)(i)&&(0,c.gt0)(n)?{pid:r,cmd:i,start:new Date(B()+n/j()*u.secondMs),state:t?.state}:void 0}},24399:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const i=r(58587),n=r(19851),s=r(22573),o=r(42659),a=r(41400),l=r(55835),u=r(13538),c=r(36557),d=r(14121),h=r(50213),f=r(7282),m=r(45255),p=r(81168),g=r(25764),y=r(38836),v=r(99331),w=r(56519),S=r(31562),b=r(84777),P=r(34102),_=r(43334),E=r(28874),M=r(63870),C="{ready}",T=" | ConvertTo-Json -Compress";function x(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=x,(0,a.later)((()=>(0,P.ee)().on("clearCache",(()=>D.instance.prior()?.clearMockResults()))));class D extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new i.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",E.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${C}"}`,...(0,s.mapNotBlankOr)(E.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:C,fail:"Error",exitCommand:"exit",maxProcs:E.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:o.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),E.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(E.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,T),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const r=this.mockResults.get(e);return t(r.stdout,r.stderr,r.passed)}try{const r=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new i.Task(e,((r,i,n)=>t((0,l.map)(r,(t=>(0,p.stripPrefix)(t,e))),i,n)))));return this.logger.tap({msg:"execute()",result:r.result,meta:{elapsedMs:r.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,T),((e,t,r)=>({stdout:e,stderr:t,passed:r})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const r=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(r)}),JSON.parse(r)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+x(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=D,D.instance=(0,n.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new D})),t.checkPowerShell_=async function(){const e=D.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const i=r(50989);t.AggregateTypes=(0,i.strEnum)("union","intersection")},71988:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const i=r(50989);t.AssetFileSortCriteria=(0,i.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const i=r(22573),n=r(38639),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toBoolean})}}t.BooleanSetting=o},90536:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=a},75164:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(i.notBlank).flatMap(n.toInt).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,n.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=a},10546:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const i=r(50989);t.ColorDistanceFunctions=(0,i.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const i=r(36507),n=r(22573),s=r(45599),o=r(50213),a=r(81168),l=r(98314),u=r(8769),c=r(80372),d=(0,s.defer)((()=>(0,o.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,a.trimQuotes)(e);return void((0,n.blank)(t)||(0,i.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,r){try{return(0,n.blank)(t)?void 0:(0,i.Cron)(t,{name:e,unref:!0,protect:!0,catch:r=>(0,u.onError)(r,{name:e,crontab:t}),...r})}catch(r){return void d().warn("invalid cron",{name:e,crontab:t,error:r})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const i=r(70488),n=r(91655),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration})}get valueOrDefault(){return(0,i.decodeDuration)(super.valueOrDefault)}get value(){return(0,i.decodeDuration)(super.value)}set value(e){super.userValue=(0,i.decodeDuration)(e)}get humanValue(){return(0,n.fmtFullDuration)(this.value)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,i.decodeDuration)(e)}}t.DurationSetting=o;class a extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,i.decodeDuration)(this.defaultValue)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=a},9945:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.FloatSetting=o},74589:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt})}}t.IntegerSetting=o},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const i=r(22573),n=r(53265),s=r(87652);class o extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,i.blank)(e)?void 0:(0,n.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=o},23561:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.OptionalFloatSetting=o},69005:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=o},87652:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=n},28283:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const i=r(51926),n=r(83556);t.nameFromEnv=function(e){return(0,n.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,i.ensurePrefix)((0,n.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const o=r(19851),a=r(40958),l=r(79666),u=r(50357),c=r(57924),d=r(98553),h=r(55835),f=r(68708),m=r(39926),p=r(46891),g=r(42279),y=r(59455),v=r(40583),w=r(81168),S=r(44198),b=r(96706),P=r(34102),_=r(28283),E=r(81075),M=r(98778),C=r(10357);t.settingsToObj=function(e){const t={};for(const r of e)r.hasValue()&&(t[r.name]=r.value);return t},t.Setting=class{constructor(e){i.add(this),this.opts=e,this._envValue=(0,o.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,i,"m",n).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const r=this.opts.whyInvalid?.(e);return null!=r?s(this,i,"m",n).call(this,e??t)+": "+r:null==this.fromEnv(e)?s(this,i,"m",n).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const r=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=r)return r}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,a.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const r=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(r)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,a.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,a.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return E.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const r=e??(0,S.env)(),i=t??this.value;return null!=i&&(r[this.key]=this.toEnv(i)),null==e&&b.caseInsensitiveEnv.unset(),r}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const r=e??(0,S.env)(),i=this.toEnvValue(t);return null!=i&&(r[this.key]=i,null==e&&b.caseInsensitiveEnv.unset()),r}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],C.WrapComments);function r(e,r){(0,a.isEmpty)(r)||t.push(...(0,w.wrap)(["",(1===r.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(r.map((e=>(0,d.stringify)(e))))],C.WrapComments))}r("alias",this.opts.aliases),r("environment alias",this.altKeys);for(const[e,r]of(0,f.entries)(this.addToJSON())){const i=Array.isArray(r)?(0,c.orList)(r.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(r);t.push(...(0,w.wrap)(["",e+": "+i],C.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},i=new WeakSet,n=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const i=r(50989);t.SettingCategories=(0,i.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const i=r(58587),n=r(76760),s=r(19851),o=r(40958),a=r(76790),l=r(22573),u=r(42659),c=r(73722),d=r(68708),h=r(50989),f=r(12168),m=r(54993),p=r(37975),g=r(9092),y=r(40583),v=r(79840),w=r(7282),S=r(12801),b=r(4328),P=r(70488),_=r(84248),E=r(5531),M=r(99315),C=r(34365),T=r(34580),x=r(96706),D=r(50274),k=r(33866),O=r(52086),I=r(48584),F=r(45969),A=r(43334),N=r(24540),L=r(70379),R=r(71300),j=r(33209),B=r(48987),V=r(68268),z=r(61208),W=r(99023),q=r(30577),U=r(1485),H=r(19861),G=r(55111),J=r(30933),K=r(22859),$=r(71988),Y=r(38483),Z=r(90536),X=r(75164),Q=r(10546),ee=r(90967),te=r(67958),re=r(55948),ie=r(57039),ne=r(9945),se=r(74589),oe=r(844),ae=r(96093),le=r(23561),ue=r(69005),ce=r(87652),de=r(81075),he=r(58305),fe=r(57571),me=r(72564),pe=r(80372),ge=r(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new ae.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>U.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:U.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>U.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>A.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,F.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!A.isElectron}),commandTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new i.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>A.isMac?"100ms":A.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new ne.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:E.CheckpointTypes,defaultValue:E.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:C.SynchronousModes,defaultValue:C.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to apply a migration, vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 2 minutes should be very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"2m"}),dbBackupIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,F.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:k.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>A.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:q.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,T.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,N.isRaspberryPi)()}),taskTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,J.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:D.SidecarExts,defaultValue:D.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:K.AggregateTypes.intersection,strEnum:K.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new ne.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:re.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,J.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:O.CropStrategies.attention,strEnum:O.CropStrategies}),videoFrameAtSec:new ne.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,o.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(A.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:$.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>j.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:I.SharpFailOns.truncated,strEnum:I.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>B.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:oe.MinValidYear}),maxValidFutureMs:new ie.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new ne.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:L.DateTagFormats.ym,strEnum:L.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:V.KeywordReparentingStrategies.move,strEnum:V.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:z.NameTagFormats["as-is"],strEnum:z.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,F.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,r]of(0,d.entries)(t.Settings))r._setName(e);function Se(e){const r=((0,l.blank)(e)?"":e).split(n.delimiter);return(0,F.isDocker)()&&r.unshift("/opt/photostructure/tools/bin"),r.push(...t.Settings.toolPaths.valueOrDefault),(0,o.uniq)(r).filter(l.notBlank).join(n.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,x.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,a.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const r of(0,t.persistedSettings)()){for(const t of r.names)e.set(t,r);for(const t of r.keys)e.set(t,r)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const i=r(19851),n=r(31586),s=r(7282),o=r(49776),a=r(46292),l=r(32774),u=r(55086),c=r(46296),d=r(55939),h=r(96706),f=r(83278),m=r(92234),p=r(45969),g=r(60865),y=r(30933),v=r(15674),w=r(28874);t.setSettingsDefaults=(0,i.lazy)((()=>{w.Settings.configDir.opts.defaultValue=a.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=o.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,n.sigFigs)(50/(0,y.cpuCount)(),2)}))},84438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const i=r(76760),n=r(40958),s=r(22573),o=r(98553),a=r(55835),l=r(59455),u=r(83179);function c(e){return null==e?void 0:(0,o.stringify)(e)}t._join=c;function d(e){return(0,a.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,n.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",i.delimiter])if(t.includes(e))return(0,n.compactBlankish)(t.split(e));return[t]}}(e),n.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,n.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,n.isEmpty)(e)||(this.value=this.toValidValues((0,n.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,n.isEmpty)(this.values)}isNotEmpty(){return(0,n.isNotEmpty)(this.values)}toNotEmpty(){return(0,n.toNotEmpty)((0,n.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=n},72564:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const i=r(40958),n=r(98553),s=r(55835),o=r(58305);class a extends o.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,n.stringify)((0,i.uniq)(e)))),fromEnv:t=>{return r=t,n=e.strEnum,(0,i.compact)((0,o.splitStringArray)(r)?.map((e=>n.getCI(e))));var r,n},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=a},80372:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const i=r(22573),n=r(81168),s=r(83179);class o extends s.Setting{constructor(e){super({toEnv:a,fromEnv:a,...e})}hasValue(){return(0,i.notBlank)(this.value)}}function a(e){return null==e?void 0:(0,n.trimQuotes)(e)}t.StringSetting=o},32707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const i=r(76760),n=r(55835),s=r(46292),o=r(84438);t.systemSettingsFile=function(){return(0,n.map)((0,s.configDir)(),(e=>(0,i.join)(e,o.SettingsToml)))}},80496:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const i=r(50989);t.TagInferenceSettingValues=(0,i.strEnum)("never","always","auto")},6707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const i=r(90858),n=r(44652),s=r(22573),o=r(76850),a=r(50213),l=r(81168),u=r(84542),c=r(17217),d=r(68284),h=r(98778);function f(e){return t=(0,o.debom)(e),(0,s.blank)(t)?void 0:(0,i.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,n.readFileSync)(t)):void 0}catch(e){return void(0,a.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>f(await(0,n.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,n.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const i=r(22573),n=r(96249),s=r(98553),o=r(68708),a=r(51926);function l(e,t,r){if((0,i.blank)(e))throw new Error("kvToToml(): Blank key");const n=e+" = "+(0,s.stringifyPretty)(t);return(0,i.blank)(r?.prefix)?[n]:(0,a.wrap)(n.split("\n"),r)}t.stringifyToml=function(e){return(0,n.flatten)((0,o.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,i.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,a.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},10357:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},65162:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const i=r(4001),n=r(81168);t.bname=function(e,t=!0){let r=(0,n.isString)(e)?e:e.name;return t&&(r=(0,i.stripCopySuffixFromName)(r)),r=(0,n.trimLeftPadding)((0,i.stripDSC)(r)),r.toLowerCase().normalize()}},70379:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const i=r(50989);t.DateTagFormats=(0,i.strEnum)("y","ym","ymd","")},71300:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},68268:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const i=r(50989);t.KeywordReparentingStrategies=(0,i.strEnum)("move","copy","retain")},61208:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const i=r(50989);t.NameTagFormats=(0,i.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const i=r(50989);t.NameTagOrders=(0,i.strEnum)("western","eastern")},60865:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const i=r(37805),n=r(30577);t.channel=function(){return(0,n.extractUpdateChannel)(i.version)},t.baseVersion=()=>[i.versionMajor,i.versionMinor,i.versionPatch].join("."),t.versionMajorMinor=i.versionMajor+"."+i.versionMinor},30577:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const i=r(50989);t.UpdateChannels=(0,i.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const r of t.UpdateChannels.values)if(e.includes("-"+r))return r;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},1485:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const i=r(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,i.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},69375:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const i=r(19851),n=r(22573),s=r(50213),o=r(9103),a=r(7282),l=r(29882),u=r(43334),c=r(28874),d=(0,i.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,n.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,a.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,a.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,a.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,a.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,n.blank)(e))return"blank";const t=(0,l.toPathnames)(e),r=t[0],i=t[t.length-1];return c.Settings.excludedRootDirectories.has(r)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(i)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===r&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,o.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},63870:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const i=r(42659),n=r(12168),s=r(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=n.MiB/i.secondMs},55111:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const i=r(50989);t.HelmetPlugins=(0,i.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},30933:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const n=i(r(48161)),s=r(19851),o=r(42659),a=r(31586),l=r(50213),u=r(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>n.default.cpus()),5*o.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=n.default.availableParallelism?.(),r=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,a.clamp)(1,128,Math.ceil(e??r)),meta:{availableParallelism:e,cpuInfoLength:r}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const n=i(r(48161)),s=r(19851),o=r(31586),a=r(12168),l=r(50213),u=r(45879),c=r(70417),d=r(45969),h=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=n.default.freemem(),t=n.default.totalmem(),r=(2*e+t)/3;if((0,d.isDocker)()){const i=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,o.gt0)(i))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([i,r]),meta:{freemem:e,totalmem:t,cgroupMem:i}})}return h().tap({msg:"estimatedFreeMem() ",result:r,meta:{result:(0,a.fmtBytes)(r),freemem:(0,a.fmtBytes)(e),totalmem:(0,a.fmtBytes)(t)}})}))},15674:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const i=r(19851),n=r(42659),s=r(41400),o=r(31586),a=r(12168),l=r(50213),u=r(7282),c=r(34102),d=r(57902),h=r(28874),f=r(30933),m=r(58444),p=r(22751),g=(0,i.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,i.lazy)((()=>{const e=(0,o.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*a.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/a.MB),worstCaseMemPerProcMb:Math.ceil(e/a.MB)}})}),n.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,r=0===e||0===t?1:(0,o.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:r>1?d.LogLevels.warn:d.LogLevels.debug,result:r,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,o.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,f.cpuCount)())<=1},t.maxCpus=(0,i.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,f.cpuCount)())-1);let t=e;const r=p.timeoutRate.prior()?.eventsPerMinute??0,i=w();if(1!==i){const e=t;t*=i,g().warn("Recent timeouts! Throttling down.",{penalization:i,resultBeforePenalization:e,resultAfterPenalization:t})}const n=Math.min(e,v());return t=(0,o.clamp)(1,n,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:i,timeoutsPerSecond:r,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,i.lazy)((function(){return(0,o.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,o.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,o.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},22751:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const i=r(58587),n=r(87997),s=r(19851),o=r(42659),a=r(41400),l=r(50213),u=r(7282),c=r(45255),d=r(34102),h=r(976),f=r(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new i.Rate(5*o.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,s.lazy)((()=>(0,n.setInterval)(g,o.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,a.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const i=r(76790),n=r(22573),s=r(50357),o=r(98553),a=r(49769),l=r(34666),u=r(30976),c=r(42279),d=r(32639),h=r(59455),f=r(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,r)=>e===t[r]))}function v(e,t){for(let r=0;r=e.length||r>=e.length)return e;const i=e[t];return e.splice(t,1),e.splice(r,0,i),e}function S(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&(0,a.getOrSet)(r,e,(()=>i))}return[...r.values()]}function P(e,t,r=1,i=(e=>e)){const n=[];if(et;s-=r)n.push(i(s));return n}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,r){return m(e)?t(e):(0,c.tot)(r)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let r=0;rt.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const r of t)if(!e.includes(r))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const r=(0,i.sortBy)(e,g),n=(0,i.sortBy)(t,g);return r.every(((e,t)=>e===n[t]))},t.pushUniq=function(e,...t){for(const r of t)null==r||e.some((e=>(0,s.eql)(e,r)))||e.push(r);return e},t.pushUniqBy=function(e,t,r){const i=e.map(r);for(const n of t){const t=r(n);i.includes(t)||(e.push(n),i.push(t))}return e},t.insertAt=function(e,t,...r){return e.splice(t,0,...r),e},t.insertUniq=function(e,t,r){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let i=0;i0)return e.splice(i,0,t),e}return e.push(t),e},t.remove=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),r!==e.length},t.removeSame=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>e!==t)))),r!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(n.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,o.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const r of e)null==r||(0,s.eql)(t[t.length-1],r)||t.push(r);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const r=[];for(const e of(0,i.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))r.some((t=>t.includes(e)))||r.push(e);return(0,i.sortBy)(r,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&r.set(e,i)}return[...r.values()]},t.uniqBy2=function(e,t){const r=[];for(const i of e)null!=i&&r.every((e=>!t(i,e)))&&r.push(i);return r},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,r,i)=>e+(t(r,i)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,r,i)=>e+t(r,i)),0)},t.firstMatch=function(e,t){for(const r of S(t)){const t=e.exec(r);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let r=0;for(;e[r]===t[r];)r++;return r},t.anneal=function({array:e,expense:t,allowedDelta:r}){const i=Math.round(r);if(i<2)return e;for(let r=0;re)){return P(e,t,1,r)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,o.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,r,i=t.primitiveValueOfOrElse){const n=new Set(r.map(i));return e.filter((e=>!n.has(i(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const i=r(40958),n=r(36783),s=r(41801),o=r(98553),a=r(49769),l=r(55835),u=r(34666),c=r(59455);function d(e,t){return(0,n.copyArrayTo)(f(e,t),e)}function h(e,t){const r=new Map;for(const i of e)(0,a.getOrSet)(r,(0,o.stringify)(t(i)),(()=>i));return f(r.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,l.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,i.compact)(e),i.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,n.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,r)=>0===r||t>=e[r-1]))},t.sortedBy=function(e,t){return e.every(((r,i)=>0===i||t(r)>=t(e[i-1])))},t.sortBy=f,t.deepSortBy=function e(t,r){return f(t,r).map((t=>(0,s.isIterable)(t)?e(t,r):t))},t.pushSorted=function(e,t,r){const i=e.findIndex((e=>r(t){Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const i=r(32639);t.asPromise=async function(e){const t=await e;return(0,i.isFunction)(t)?t():t}},5233:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const i=r(41400),n=r(31586),s=r(13538),o=r(41583);t.retryOnReject_=async function(e,t){const r=(0,n.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return r();const a=t.onRetryWaitUntil??(e=>(0,i.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await r()}catch(e){const r=(0,o.toErr)(e);if(!1===t.errorIsRetriable?.(r)||l>t.maxRetries)throw r;return l++,await a(l),u()}};return u()}},17586:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},22573:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const i=r(55835),n=r(42279),s=r(54993);function o(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function a(e){return!o(e)}function l(e,t){if(!1===e||null==e||""===e)return;const r=(0,s.toS)(e);return a(r)?t(r):void 0}t.blank=o,t.notBlank=a,t.notBlankToS=function(e){return a(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,n.tot)(t);const r=(0,s.toS)(e).trim();return r.length>0?r:(0,n.tot)(t)},t.notBlankAnd=function(e,t){return!o(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,r){return(0,i.orElse)(l(e,t),r)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{function r(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function i(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const r=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=r,t.toBoolean=function(e){return!!r(e)||!i(e)&&void 0},t.toNotBoolean=function(e){return!r(e)&&(!!i(e)||void 0)},t.boolToInt=function(e){return r(e)?1:0},t.isFalse=i,t.isDisabled=function(e){return i(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>r(e)))},t.and=function(e){return e.every((e=>r(e)))},t.maybeAnd=function(e){let t;for(const r of e){if(!1===r)return!1;!0===r&&(t=!0)}return t},t.mapBoolean=function(e,t){return r(e)?t(!0):i(e)?t(!1):void 0},t.mapTrue=function(e,t){return r(e)?t():void 0}},79666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const i=r(98553);t.clone=function(e){return null==e?e:JSON.parse((0,i.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const i=r(40958),n=r(22573),s=r(30301),o=r(55835),a=r(31586),l=r(39926),u=r(51926),c=r(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,o.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const r=p(e)?e.getTime():(0,a.isNumber)(e)?e:Date.now();return Math.floor(r/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,r={includeMs:!0}){const i=Math.floor(e/t.hourMs);e-=i*t.hourMs;const n=Math.floor(e/t.minuteMs);e-=n*t.minuteMs;const s=Math.floor(e/t.secondMs),o=Math.floor(e-s*t.secondMs);return(0,l.pad2)(i)+":"+(0,l.pad2)(n)+":"+(0,l.pad2)(s)+(r.includeMs?"."+(0,l.pad3)(o):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const r=()=>{const e=t%100;return t=Math.floor(t/100),e},i=10*r(),n=r(),s=r(),o=r(),a=r(),l=r();return new Date(t,l-1,a,o,s,n,i)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,r="ago"){return e<1e3?"just now":(r=(0,n.blank)(r)?"":(0,u.ensurePrefix)(r," "),et.ms<=e)))){const s=Math.floor(e/i.ms);e-=s*i.ms,s>0&&(i.ms>=t.dayMs?r:n).push(s+i.s)}return e>0&&n.push((0,a.toFixedStr)(e/t.secondMs,3)+"S"),"P"+r.join("")+((0,i.isEmpty)(n)?"":"T"+n.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,o.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const i=r(38639),n=r(73872);function s(e,t,r){if(null==r||y(e)||y(t))return null;const i=r.get(e)?.get(t);return"boolean"==typeof i?i:null}function o(e,t,r,i){if(null==r||y(e)||y(t))return;let n=r.get(e);null!=n?n.set(t,i):(n=new WeakMap,n.set(t,i),r.set(e,n))}function a(e,t,r,i){if(null!=r?.comparator)return u(e,t,r,i);const n=l(e,t);return null!==n?n:u(e,t,r)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,r,i){r??(r={});const u=!1===r.memoize?void 0:r.memoize??(r.memoize=new WeakMap),d=r?.comparator,f=s(e,t,u);if(null!==f)return f;const m=s(t,e,u);if(null!==m)return m;if(d){const r=d(e,t,i);if(!1===r||!0===r)return o(e,t,u,r),r;const n=l(e,t);if(null!==n)return n}const y=n(e);if(y!==n(t))return o(e,t,u,!1),!1;o(e,t,u,!0);const v=function(e,t,r,i){switch(r){case"String":case"Number":case"Boolean":case"Date":return a(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],i);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,i);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,r){return c(h(e),h(t),r)}(e,t,i);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),i);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),i);case"Set":case"Map":return function(e,t,r){if(e.size!==t.size)return!1;if(0===e.size)return!0;const i=[],n=[];return e.forEach((function(e,t){i.push([e,t])})),t.forEach((function(e,t){n.push([e,t])})),c(i.sort(),n.sort(),r)}(e,t,i);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,i)}}(e,t,y,r);return o(e,t,u,v),v}function c(e,t,r){const i=e.length;if(i!==t.length)return!1;if(0===i)return!0;let n=-1;for(;++n{Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,r,i=!1;const n=function(){if(i){if(null!=r)throw r;return t}try{return i=!0,t=e()}catch(e){throw r=e,e}};return n.prior=()=>t,n.hasPrior=()=>i,n}},41400:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const i=r(42659),n=r(35556),s=r(31586),o=r(68708);function a(e,t=!0){return new Promise((r=>{if(e<=0)r();else{const s=setTimeout((()=>r()),Math.ceil(e+.5));e>i.secondMs&&t&&n.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return a(t).then((()=>t))},t.delay=a,t.later=function(e,t=1){const r=Math.max(1,Math.ceil(t)),s=n.isNode&&r<=1?setImmediate(e):setTimeout(e,r);return n.isBrowser||t<=i.secondMs?s:(0,o.maybeCall)(s,"unref")??s}},50357:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const i=r(12487),n=r(68708),s=r(34666),o=r(32639);function a(e,t){return(0,i.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,o.isFunction)(e)&&(0,o.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=a,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return!1;for(const r of(0,n.keys)(e))if(!a(e[r],t[r]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,r){if(null==e||null==t)return e===t;if(null!=r){const i=d.get(r);if(null!=i)return i(e,t)??null}for(const r of c){const i=r(e,t);if(null!=i)return i}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(31586),a=r(68708),l=r(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,n.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,o.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const r=[];for(const t of e)null!=t&&(t instanceof Error?r.push(u(t),c(t),t?.message):r.push((0,l.toS)(t)));return(0,i.uniq)((0,i.compactBlankish)((0,s.flatten)((0,i.compact)(r).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,n.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const r=(0,l.toS)(e).split("\n").filter((e=>!(0,n.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,i.isEmpty)(r)?["(missing stack)"]:r}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,n.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(n.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,a.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,a.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,a.assignFields)(new Error,(0,a.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},96249:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const i=r(59455);t.flatten=function(e,t=[]){for(const r of(0,i.toA)(e))if(null!=r)for(const e of(0,i.toA)(r))null!=e&&t.push(e);return t}},57924:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const i=r(40958);function n(e,t){return null==(e=(0,i.uniq)((0,i.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=n,t.orList=function(e){return n(e,"or")},t.andList=function(e){return n(e,"and")}},73722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const i=r(50989);t.FitSizes=(0,i.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,i.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const i=r(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,r){if((0,i.lt0)(t))return[...e].slice(t,r);const n=e[Symbol.iterator]();if((0,i.gt0)(t))for(let e=0;e{Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,r){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(r))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],r=[];return function e(i,n){if((0,isFunction_1.isFunction)(i))return;let s,o,a,l=toJSON(i);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(i===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let i=0;t.Latch=class{constructor(e=i++){this.id=e,this[r]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},r=Symbol.toStringTag},30301:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const i=r(40958),n=r(50357),s=r(31586),o=r(65812);t.lazy=function(e,t){let r,a;const l=[];function u(){return u.isStale()&&u.setResult(e()),a}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return r=Date.now(),async function(e,r){if((0,i.isEmpty)(l))return;const s=await e,a=await r;if(!(0,n.eql)(s,a))for(const e of l)e(a);null!=t&&t>0&&void 0!==a&&(0,o.setUnrefTimeout)((()=>u.vacuum()),t)}(a,e),a=e},u.isStale=function(){return null==r||(0,s.gt0)(t)&&r+t{Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,r){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const i=r();return null!=i&&e.set(t,i),i}},t.deleteIf=function(e,t){for(const[r,i]of e.entries())t(r,i)&&e.delete(r)}},55835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const i=r(42279),n=r(54993);function s(e,t){return null==e?void 0:t(e)}function o(e,t,r){return null==e||null==t?void 0:r(e,t)}function a(e,t){return null!=e?e:(0,i.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=o,t.map3=function(e,t,r,i){return null==e||null==t||null==r?void 0:i(e,t,r)},t.orElse=a,t.mapOr=function(e,t,r){return null!=e?t(e):(0,i.tot)(r)},t.map2Or=function(e,t,r,i){return a(o(e,t,r),i)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,n.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const i=r(68708);class n extends Error{constructor(e,t){super(e),this.message=e,(0,i.assignFields)(this,t)}}t.MetaError=n},23838:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const i=r(40958),n=r(76790),s=r(50357),o=r(98553),a=r(49769),l=r(55835),u=r(51926),c=r(59455);class d{static fromJSON(e){const t=new d;for(const[r,i]of Object.entries(e))t.add(r,...i);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,i.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const r=(0,a.getOrSet)(this.store,e,(()=>[]));return r.push(...t),r}addUniq(e,...t){return(0,i.pushUniq)((0,a.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const r=this.store.get(e);if(null==r)return!1;{const i=r.filter((e=>!(0,s.eql)(e,t)));return 0===i.length?this.store.delete(e):this.store.set(e,i),r.length!==i.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,i.uniq)(t))){for(const t of this.keys()){const r=this.store.get(t),n=null==r?[]:e(t,r);(0,i.isEmpty)(n)?this.store.delete(t):this.store.set(t,n)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,i.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield[t,r])}()}tuples(){const e=this;return function*(){for(const[t,r]of e.store.entries())for(const e of(0,c.toA)(r))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[r,n]of this.store.entries()){const s=(0,i.findIndexes)(n,(t=>!e(r,t,n)));if(s.length>0){t=!0;for(const e of s.reverse())n.splice(e,1)}0===n.length&&this.store.delete(r)}return t}inverse(){const e=new d;for(const[t,r]of this.store.entries())for(const i of r)e.add(i,t);return e}findKeyByTuple(e){for(const[t,r]of this.tuples())if(e(t,r))return t}filterKeysByTuple(e){const t=[];for(const[r,i]of this.entries())i.some((t=>e(r,t)))&&t.push(r);return t}toJSON(){const e={};for(const[t,r]of this.entries())e[(0,u.isString)(t)?t:(0,o.stringify)(t)]=r;return e}}function h(e,t){const r=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>r.add(t,e))))),r}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const r=h(e,t);return(0,n.sortBy)((0,c.toA)(r.values()),(e=>t(e[0])))}},35556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const r=globalThis;t.isBrowser="object"==typeof r?.window&&"object"==typeof r?.document,t.isNode="string"==typeof r?.process?.versions?.node},31586:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const i=r(76790),n=r(22573),s=r(42279),o=r(54993);function a(e){return"number"==typeof e&&isFinite(e)}t.isNumber=a,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,o.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return a(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,o.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,r)=>a(t)&&a(r)&&e(t,r);function f(e,r,n){return!(null==n||!a(n))&&([e,r]=(0,i.sort)([e,r]),(0,t.lte)(e,n)&&(0,t.gte)(r,n))}function m(e){if(!a(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,n.blank)(e))return t.defaultValue;if(a(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return a(e)&&e>0}function S(e){return a(e)&&e>=0}function b(e,t){return a(e)?t(e):void 0}function P(e){return a(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const r=Math.pow(10,t);return P(e*r)/r}function E(e,t,r){if(e>t||!a(e)||!a(t))throw new Error(`invalid clamp(${e}, ${t}, ${r})`);return a(r)?rt?t:r:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return a(e)?e:t},t.diff=function(e,t){return a(e)&&a(t)?e-t:void 0},t.absdiff=function(e,t){return a(e)&&a(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,r=.95){if(!a(e)||!a(t))return!1;if(e===t)return!0;if(r>=1)return!1;const i=(0===t?1e-5:t)*(1-r);return f(t-i,t+i,e)},t.within=f,t.max_=function(...e){let t;for(const r of e)a(r)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return a(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return a(e)&&a(t)&&e>t?e:void 0},t.lte0=function(e){return a(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const r=y(e);return null==r?void 0:t(r)},t.mapFloat=function(e,t){const r=v(e);return null==r?void 0:t(r)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,r){return b(e,(e=>b(t,(t=>r(e,t)))))},t.mapNumericOr=function(e,t,r){return a(e)?t(e):r},t.numericOr=function(e,t){return a(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!a(e)||0===e||0===t)return 0;const r=t-P(Math.ceil(Math.log10(Math.abs(e)))),i=Math.pow(10,Math.abs(r));return r<0?P(e/i)*i:P(e*i)/i},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=E,t.times=function(e,t){if(!w(e))return[];const r=Math.round(e);return r<=0?[]:[...Array(r)].map(((e,r)=>t(r)))},t.pct=function(e,t){return E(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const r=Math.round(e??-1);return null==t||f(0,t,r)?r+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const r of e){if(!a(r))return;t+=r}return t}},68708:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(32639),a=r(55835),l=r(31586),u=r(34666),c=r(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const r of e)if(null!=r&&Array.isArray(r)){const[e,i]=r;null!=e&&void 0!==i&&("object"!=typeof t&&(t={}),t[e]=i)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const r=t.filter((([,e])=>null!=e));return(0,i.isEmpty)(r)?void 0:y(r)}function w(e,t,r={}){return y((0,i.compact)((0,n.sort)(h(e)).map((r=>t(r,e[r])))).filter((([e,t])=>null!=e&&void 0!==t)),r)}function S(...e){const t=(0,i.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const r=t.filter(d);if(t.length!==r.length)return t;const n={};for(const e of(0,i.uniq)((0,i.flatMap)(r,h)))n[e]=S(...r.map((t=>t[e])));return n}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const r=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(r.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const r=v(e);return m(r)?t(r):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,r){if(null==t)return e;for(const[i,n]of g(t))!0!==r?.omitKeys?.includes(i)&&(null==n&&!0!==r?.assignNullish||(e[i]=n));return e},t.assignUndefinedFields=function(e,t,...r){if(null==t)return e;for(const i of r){const r=t[i];void 0!==r&&void 0===e[i]&&(e[i]=r)}return e},t.assignAllFields=function(e,t){for(const[r,i]of g(t??{}))e[r]=i;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const r=t.filter((([,e])=>void 0!==e));return(0,i.isEmpty)(r)?void 0:y(r)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,i.compact)(t.map(e));{const r=(0,i.compact)(g(t).map((([t,r])=>(0,a.map)(e(r),(e=>[t,e])))));return 0===r.length?void 0:y(r)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,i.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickCompact=function(e,...t){if(null==e)return;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickNonBlank=function(e,...t){if(null==e)return e;const r={};for(const i of t){const t=e[i];(0,s.notBlank)(t)&&(r[i]=t)}return r},t.pickFirst=function(e,t,r=a.defined){if(null!=e)for(const i of t)if(r(e[i]))return e[i]},t.pickDeep=function e(t,...r){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...r)));const i={};function n(e,t){if(null==t)return;const r=i[e];i[e]=null==r?t:S(r,t)}for(const i of r){const[r,o]=(0,c.splitFirst)(i,"."),a=b(t,r);null!=a?.value&&n(a.key,(0,s.blank)(o)?a.value:e(a.value,o))}for(const i of h(t))((0,l.toInt)(i)??-1)>=0&&n(i,e(t[i],...r));return i},t.pluck=b,t.pluckDeep=function e(t,r){if(null==t||(0,s.blank)(r))return;if(Array.isArray(t)){const n=(0,i.compact)(t.map((t=>e(t,r))));return(0,i.isEmpty)(n)?void 0:{key:n[0].key,value:(0,i.flatMap)(n,(e=>e.value))}}const[n,o]=(0,c.splitFirst)(r,"."),a=b(t,n);if(null==a)return;if((0,s.blank)(o))return a;const l=e(a.value,o);return null==l?void 0:{key:a.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const r=g(e).filter((([e])=>!t.includes(e)));return(0,i.isEmpty)(r)?void 0:y(r)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,r])=>t(e,r))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,i.uniq)(t)},t.maybeCall=function(e,t,...r){const i=e?.[t];return(0,o.isFunction)(i)?i.bind(e)(...r):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const r=t.toLowerCase().normalize();for(const t of h(e))if(r===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const r=w(t,((t,r)=>[t,e(r)])),i=p(r);return 1===i.length?i[0]:r}},97790:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(r||(r={})),t.None=r;class i{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new i(e(this.a))}flatMap(e){const t=e(this.a);return n(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,r){return s(e).flatMap((e=>s(t).flatMap((t=>r(this.a,e,t)))))}zip3(e,t,r,i){return s(e).flatMap((e=>s(t).flatMap((t=>s(r).flatMap((r=>i(this.a,e,t,r)))))))}}function n(e){return e instanceof i||e===t.None}function s(e){return n(e)?e:null!=e?new i(e):t.None}t.Some=i,t.isOpt=n,t.opt=s},39926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const i=r(31586),n=r(54993),s={};function o(e,t){if(t<1)return"";if(!(0,i.gte)(s[e]?.length,t)){let r=s[e]??e;for(;r.length{Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const i=r(22573),n=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,o=/[^aeiou]y$/,a=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,i.blank)(e))return e;const t=n.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(o)?e.replace(/y$/i,"ies"):null!=e.match(a)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const i=r(40958),n=r(54993),s=["number","string","boolean"];function o(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=o,t.mapPrimitive=function(e,t){return o(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,r){return o(e)?t(e):r()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(o)};const a=["boolean","number","bigint","symbol","string","object","function"];function l(e,r){if(null==e&&null==r)return 0;if(null==e)return-1;if(null==r)return 1;const i=typeof e,s=typeof r;if(!("string"!==i&&"symbol"!==i||"string"!==s&&"symbol"!==s)){const i=(0,n.toS)(e),s=(0,n.toS)(r),o=i.localeCompare(s);return i[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-o:o}return Array.isArray(e)&&Array.isArray(r)?u(e,r):i!==s?a.indexOf(i)-a.indexOf(s):e>r?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const i=r(59455);function n(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const r=await e;return null==r?void 0:t(r)},t.thenCollect=async function(e,t){const r=[];for(const n of(0,i.toA)(await e))if(null!=n){const e=await n;if(null!=e){const i=await t(e);null!=i&&r.push(i)}}return r},t.thenTap=async function(e,t=console.dir.bind(console)){const r=await e;return await t(r),r},t.isPromiseLike=n,t.isPromise=function(e){return n(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:r}){const i=await e;return t(i)?r(i):void 0}},57153:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const i=r(50989);t.PromiseStates=(0,i.strEnum)("pending","resolved","rejected")},30976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const i=r(40958),n=r(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function o(e,t,r){return null==r||0===r.length?s(e,t):a(e,t,1,r)[0]}function a(e,t,r,i){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const n=t-e,o=new Set(i??[]);if(t===e&&0===n&&0===o.size&&1===r)return[e];const a=n-o.size;if(r>a)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:n,size:r,slotsRemaining:a})}`);const l=new Set;for(;l.size0;e--){const r=Math.floor(Math.random()*(e+1));e!==r&&([t[e],t[r]]=[t[r],t[e]])}return t},t.sample=function(e,t){const r=[];for(const i of a(0,e.length,t))r.push(e[i]);return r},t.pickWeightedRandom=function(e){if((0,i.isEmpty)(e))return;const t=e.filter((e=>(0,n.gt0)(e.priority)));let r=l(0,(0,i.sum)(t,(e=>e.priority)));return t.find((e=>(r-=e.priority,r<=0)))}},5670:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const i=r(50989);t.ServiceNames=(0,i.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]}},50989:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const i=r(68708),n=r(42279);t.strEnum=function(...e){const t=Object.freeze(e),r=(0,i.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const o=e=>null!=e?r[e]:void 0,a=e=>null!=o(e);return{...s,values:t,length:t.length,has:a,includes:a,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:o,ordinal:e=>o(e)??t.length,validOrElse:(e,t)=>a(e)?e:(0,n.tot)(t),mapValid:(e,t)=>a(e)?t(e):void 0,cmp:(e,t)=>{const r=o(e),i=o(t);return null==r||null==i?void 0:r>i?1:r{const r=o(e);return null==r?void 0:t[r]}}}},51926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const i=r(40958),n=r(17586),s=r(22573),o=r(96249),a=r(41801),l=r(31586),u=r(59455),c=r(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,r){if(d(e))return t<0&&(t+=e.length),e.slice(t,r);{const i=f();return null!=i?(0,a.sliceIterable)(i.segment(e),t,r).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,r).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.startsWith(i)?r.slice(i.length):r}function y(e,t){if(null==t)return e;const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.endsWith(i)?r.slice(0,-i.length):r}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,r){null==r&&(r=e.length);for(let i=r;i>=0;i--)if(m(e,i).startsWith(t))return i;return-1}function b(e,t,{normalize:r=!0}={}){if(null==e||null==t)return!1;const i=(0,c.toS)(e),n=(0,c.toS)(t);return i.length===n.length&&(i===n||i.toLowerCase()===n.toLowerCase()||"function"==typeof i.localeCompare&&0===(r?i.normalize():i).localeCompare(r?n.normalize():n,void 0,{sensitivity:"base"}))}function P(e,t){return(0,i.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,n.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,a.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,r){return d(e)?e.slice(t,null==r?void 0:t+r):m(e,t,null==r?void 0:t+r)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,r){if(null==t)return"";const i=(0,c.toS)(t);for(const t of r)if(null!=t&&t.length>0&&i.startsWith(t))return e(i.slice(t.length),r);return i},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:r}){return y(g(e,t),r)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:r}){return w(v(e,t),r)},t.ellipsize=function(e,t=80,r=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),r=(0,l.clamp)(0,t-1,(0,l.round)(r));const i=p(e);return i.length<=t?i.join(""):i.slice(0,t-1-r).join("")+"…"+(r>0?i.slice(-r).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,r){const i=r?.maxLineLen??80,n=r?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const i=(0,o.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,o.flatten)(i.map((t=>e(t,r))))}if((t=v((0,c.toS)(t),n).trim()).length<=i)return[t];const s=S(t," ",i);if(s>n.length)return[m(t,0,s),...e(m(t,s+1),r)];{const i=t.indexOf(" ",n.length+1);return i>0&&i{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const i=r(42659),n=r(68708),s=r(42279),o=r(83104),a=r(85556);async function l(e,t,r=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(r,i)=>{let n=!0;const s=setTimeout((()=>{n&&(n=!1,r(o.Timeout))}),t);try{s.unref?.();const t=await e;n&&(n=!1,r(t))}catch(e){n&&(n=!1,i(e))}finally{clearTimeout(s)}}))}async function u(e,t,r=!0){const n=await l(e,t,r);if(n===o.Timeout)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(t)+")");return n}t.toNotTimeout=function(e){return e===o.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,r=!0){const i=t-Date.now();return i<=0?o.Timeout:l(e,i,r)},t.thenOrOnTimeout=async function(e,t,r){return t<=0?e:new Promise((async(i,s)=>{let o=!0;try{const a=setTimeout((async()=>{if(o){o=!1;try{i(await r())}catch(e){s(e)}}}),t);(0,n.maybeCall)(a,"unref");const l=await e;o&&(o=!1,clearTimeout(a),i(l))}catch(e){o&&(o=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,r=!0){const n=t-Date.now();if(n<=0)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(n)+")");return u(e,n,r)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:r,unref:i=!0}){const n=await l(e,t,i);return n===o.Timeout?(0,s.tot)(r):n}},42279:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const i=r(32639);t.tot=function(e){return(0,i.isFunction)(e)?e():e},t.tol=async function(e){return(0,i.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class r extends Error{}t.TimeoutError=r},12168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const i=r(22573),n=r(30301),s=r(31586),o=r(46891),a=r(50989),l=r(51926),u=(0,n.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let r=0;for(const i of e)(0,s.isNumber)(i)&&(r+=i/t.MB);return(0,s.round)(r)},t.fmt=c,t.fmtToInt=function(e){return(0,i.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const r=Math.floor(Math.log10(e)),i=Math.floor(r/3),n=Math.pow(10,3*i),o=d[i];return(0,s.sigFigs)(e/n,t)+" "+o}t.fmtMB=function(e,r=3){return f(e*t.MB,r)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const r=Math.floor(Math.log2(e)),i=Math.floor(r/10),n=Math.pow(2,10*i),o=h[i];return(0,s.sigFigs)(e/n,t)+" "+o},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,a.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,r){return null==e?"":(0,i.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(r??(0,o.pluralize)(t)).trim())},t.plurMetric=function(e,t,r){return r??(r=(0,o.pluralize)(t)),{count:c(e),desc:1===e?t:r}}},65812:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const i=r(68708);t.setUnrefTimeout=function(e,t){const r=setTimeout(e,t);return(0,i.maybeCall)(r,"unref")??r}},23541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const i=r(41801),n=r(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,n.isString)(e)?[e]:(0,i.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const i=r(40958),n=r(23541),s=r(59455),o=r(54993);function a(e){return null==e?void 0:(0,n.isError)(e)?e:new Error((0,o.toS)(e))}t.toErr=a,t.toErrs=function(...e){return(0,i.compact)((0,s.toA)(e).map(a))}},54993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const i=r(98553);t.toS=function(e){return s(e,",")};const n={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==n?e.toString():(0,i.stringify)(e)}}t.toStr=s},92636:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(6858),s=i(r(73024)),o=i(r(76760)),a=r(1708),l=r(37805),u=r(41269),c=r(80061),d=r(94361);function h(e){for(const t of["bin",__dirname]){const r=o.default.join(t,e);if(s.default.existsSync(r))return r}return console.error("failed to find command "+e),e}n.program.version(l.version),n.program.description("Welcome to PhotoStructure, your new home for all your photos and videos.\nSee https://photostructure.com/server/tools/ for details about these tools."),(0,d.verifyUidGid)(),(0,c.addHelpFooter)(n.program).command("main",u.CliDesc.main+" (default)",{isDefault:!0,executableFile:h("main.js")}).command("info",u.CliDesc.info,{executableFile:h("info.js")}).command("list",u.CliDesc.list,{executableFile:h("list.js")}).command("logcat",u.CliDesc.logcat,{executableFile:h("logcat.js")}).command("logtail",u.CliDesc.logtail,{executableFile:h("logtail.js")}).command("web",u.CliDesc.web,{executableFile:h("web.js")}).command("sync",u.CliDesc.sync,{executableFile:h("sync.js")}).parse(a.argv)},90858:e=>{e.exports=require("@iarna/toml")},58587:e=>{e.exports=require("batch-cluster")},6858:e=>{e.exports=require("commander")},36507:e=>{e.exports=require("croner")},66261:e=>{e.exports=require("events")},77988:e=>{e.exports=require("exiftool-vendored")},44652:e=>{e.exports=require("fs-extra")},28787:e=>{e.exports=require("he")},51168:e=>{e.exports=require("luxon")},73872:e=>{e.exports=require("type-detect")},92460:e=>{e.exports=require("util")},31421:e=>{e.exports=require("node:child_process")},77598:e=>{e.exports=require("node:crypto")},78474:e=>{e.exports=require("node:events")},73024:e=>{e.exports=require("node:fs")},51455:e=>{e.exports=require("node:fs/promises")},48161:e=>{e.exports=require("node:os")},76760:e=>{e.exports=require("node:path")},1708:e=>{e.exports=require("node:process")},57075:e=>{e.exports=require("node:stream")},46466:e=>{e.exports=require("node:stream/promises")},87997:e=>{e.exports=require("node:timers")},57975:e=>{e.exports=require("node:util")},38522:e=>{e.exports=require("node:zlib")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__=__webpack_require__(92636);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/bin/sync.js b/bin/sync.js index 629d52d..92fde62 100755 --- a/bin/sync.js +++ b/bin/sync.js @@ -6,4 +6,4 @@ * IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THIS SOFTWARE */ -(()=>{var __webpack_modules__={60308:e=>{const t={PasetoNotSupported:"ERR_PASETO_NOT_SUPPORTED",PasetoDecryptionFailed:"ERR_PASETO_DECRYPTION_FAILED",PasetoInvalid:"ERR_PASETO_INVALID",PasetoVerificationFailed:"ERR_PASETO_VERIFICATION_FAILED",PasetoClaimInvalid:"ERR_PASETO_CLAIM_INVALID"};class i extends Error{constructor(e){super(e),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}e.exports.PasetoError=i,e.exports.PasetoNotSupported=class extends i{},e.exports.PasetoDecryptionFailed=class extends i{},e.exports.PasetoInvalid=class extends i{},e.exports.PasetoVerificationFailed=class extends i{},e.exports.PasetoClaimInvalid=class extends i{}},78972:(e,t,i)=>{const{PasetoInvalid:r,PasetoNotSupported:s}=i(60308),{decode:n}=i(47859),a=i(40816);e.exports=(e,{parse:t=!0}={})=>{if("string"!=typeof e)throw new TypeError("token must be a string");const{0:i,1:o,2:l,3:u,length:c}=e.split(".");if(3!==c&&4!==c)throw new r("token is not a PASETO formatted value");if("v1"!==i&&"v2"!==i&&"v3"!==i&&"v4"!==i)throw new s("unsupported PASETO version");if("local"!==o&&"public"!==o)throw new s("unsupported PASETO purpose");const d={footer:u?n(u):void 0,payload:void 0,version:i,purpose:o};if("local"===o)return d;const h="v1"===i?256:"v3"===i?96:64;let f;try{f=n(l).subarray(0,-h)}catch{throw new r("token is not a PASETO formatted value")}return d.payload=t?a(f):f,d}},2744:(e,t,i)=>{const r=i(78972);e.exports={decode:r}},67814:(e,t,i)=>{const r=i(85223);e.exports=({audience:e,expiresIn:t,iat:i=!0,issuer:s,jti:n,kid:a,notBefore:o,now:l=new Date,subject:u},c)=>{if(!(l instanceof Date&&l.getTime()))throw new TypeError("options.now must be a valid Date object");const d=l.getTime();if(void 0!==i){if("boolean"!=typeof i)throw new TypeError("options.iat must be a boolean");i&&(c.iat=new Date(d))}if(void 0!==t){if("string"!=typeof t)throw new TypeError("options.expiresIn must be a string");c.exp=new Date(d+r(t))}if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.notBefore must be a string");c.nbf=new Date(d+r(o))}if(void 0!==e){if("string"!=typeof e)throw new TypeError("options.audience must be a string");c.aud=e}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.issuer must be a string");c.iss=s}if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.subject must be a string");c.sub=u}if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.kid must be a string");c.kid=a}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.jti must be a string");c.jti=n}return c}},10968:(e,t,i)=>{const{PasetoClaimInvalid:r}=i(60308),s=i(85223);e.exports=({ignoreExp:e,ignoreNbf:t,ignoreIat:i,maxTokenAge:n,subject:a,issuer:o,clockTolerance:l,audience:u,now:c=new Date},d)=>{if(!(c instanceof Date&&c.getTime()))throw new TypeError("options.now must be a valid Date object");const h=c.getTime();if("iss"in d&&"string"!=typeof d.iss)throw new r("payload.iss must be a string");if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.issuer must be a string");if(d.iss!==o)throw new r("issuer mismatch")}if("sub"in d&&"string"!=typeof d.sub)throw new r("payload.sub must be a string");if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.subject must be a string");if(d.sub!==a)throw new r("subject mismatch")}if("aud"in d&&"string"!=typeof d.aud)throw new r("payload.aud must be a string");if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.audience must be a string");if(d.aud!==u)throw new r("audience mismatch")}if(void 0!==l&&"string"!=typeof l)throw new TypeError("options.clockTolerance must be a string");const f=l?s(l):0;let m;if("iat"in d){if("string"!=typeof d.iat)throw new r("payload.iat must be a string");if(m=new Date(d.iat).getTime(),!m)throw new r("payload.iat must be a valid ISO8601 string");if(!i&&m>h+f)throw new r("token issued in the future")}if("nbf"in d){if("string"!=typeof d.nbf)throw new r("payload.nbf must be a string");const e=new Date(d.nbf).getTime();if(!e)throw new r("payload.nbf must be a valid ISO8601 string");if(!t&&e>h+f)throw new r("token is not active yet")}if("exp"in d){if("string"!=typeof d.exp)throw new r("payload.exp must be a string");const t=new Date(d.exp).getTime();if(!t)throw new r("payload.exp must be a valid ISO8601 string");if(!e&&t<=h-f)throw new r("token is expired")}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.maxTokenAge must be a string");if(!("iat"in d))throw new r("missing iat claim");if(m+s(n){e.exports.encode=e=>e.toString("base64url"),e.exports.decode=e=>Buffer.from(e,"base64")},80608:e=>{e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if("string"!=typeof e)throw new TypeError("options.assertion must be a string, or a Buffer");return Buffer.from(e,"utf8")}},83561:(e,t,i)=>{const r=i(65825);e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if(r(e))return Buffer.from(JSON.stringify(e),"utf8");if("string"!=typeof e)throw new TypeError("options.footer must be a string, Buffer, or a plain object");return Buffer.from(e,"utf8")}},1658:(e,t,i)=>{const r=i(67814),s=i(65825);e.exports=(e,t)=>{if(Buffer.isBuffer(e)){if(0!==Object.keys(t).length)throw new TypeError("options cannot contain claims when payload is a Buffer");return e}if(!s(e))throw new TypeError("payload must be a Buffer or a plain object");return e=(e=>JSON.parse(JSON.stringify(e)))(e),e=r(t,e),Buffer.from(JSON.stringify(e),"utf-8")}},82115:e=>{e.exports=e=>{const{x:t,y:i}=e.export({format:"jwk"}),r=Buffer.from(i,"base64"),s=2+(1&r[r.length-1]);return Buffer.concat([Buffer.alloc(1,s),Buffer.from(t,"base64")])}},88965:(e,t,i)=>{const r=i(64770),{PasetoInvalid:s}=i(60308),n=i(10968),{decode:a}=i(47859),o=i(40816);e.exports={post:function(e,t,i,r,s,a,l){if(t){if(0!==Object.keys(i).length)throw new TypeError("options cannot contain claims when options.buffer is true");return r?{payload:s,footer:a?.length?a:void 0,version:e,purpose:l}:s}const u=o(s);return n(i,u),r?{payload:u,footer:a?.length?a:void 0,version:e,purpose:l}:u},pre:function(e,t){if("string"!=typeof t)throw new TypeError("token must be a string, got: "+typeof t);if(t.slice(0,e.length)!==e)throw new s(`token is not a ${e.slice(0,e.length-1)} PASETO`);let{0:i,1:n="",length:o}=t.slice(e.length).split(".");try{r(o<=2),i=a(i),n=a(n)}catch{throw new s("token is not a PASETO formatted value")}return{raw:i,f:n}}}},56463:(e,t,i)=>{const r=i(76982),s=i(92460),n=i(70761),a=i(29534),{PasetoDecryptionFailed:o}=i(60308),l=i(82682),{webcrypto:{subtle:u}}=r,c=s.promisify(r.hkdf),d=Buffer.from("paseto-encryption-key"),h=Buffer.from("paseto-auth-key-for-aead"),f=Buffer.alloc(0),m=(e,t)=>r.createHmac("sha384",t).update(e).digest(),p=async(e,t,i,r)=>u[e]({name:"AES-CTR",counter:r,length:16},await u.importKey("raw",i,"AES-CTR",!1,[e]),t).then(Buffer.from),g=p.bind(void 0,"encrypt"),y=p.bind(void 0,"decrypt");e.exports={sign:s.promisify(r.sign),verify:s.promisify(r.verify),"v1.local-encrypt":async function(e,t,i){const s="v1.local.",o=m(e,r.randomBytes(32)).subarray(0,32),l=o.subarray(0,16),[u,f]=await Promise.all([c("sha384",i,l,d,32).then(Buffer.from),c("sha384",i,l,h,32).then(Buffer.from)]),p=await g(e,u,o.subarray(16)),y=n(s,o,p,t),w=m(y,f);return a(s,t,o,p,w)},"v1.local-decrypt":async function(e,t,i){const r=e.subarray(0,32),s=e.subarray(-48),a=e.subarray(32,-48),u=r.subarray(0,16),[f,p]=await Promise.all([c("sha384",i,u,d,32).then(Buffer.from),c("sha384",i,u,h,32).then(Buffer.from)]),g=n("v1.local.",r,a,t),w=m(g,p);if(!l(s,w))throw new o("decryption failed");const v=await y(a,f,r.subarray(16));if(!v)throw new o("decryption failed");return v},"v3.local-encrypt":async function(e,t,i,s){const o="v3.local.",l=r.randomBytes(32),[u,p]=await Promise.all([c("sha384",i,f,Buffer.concat([d,l]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,l]),48).then(Buffer.from)]),y=u.subarray(0,32),w=u.subarray(32),v=await g(e,y,w),b=n(o,l,v,t,s),S=m(b,p);return a(o,t,l,v,S)},"v3.local-decrypt":async function(e,t,i,r){const s=e.subarray(0,32),a=e.subarray(-48),u=e.subarray(32,-48),[p,g]=await Promise.all([c("sha384",i,f,Buffer.concat([d,s]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,s]),48).then(Buffer.from)]),w=p.subarray(0,32),v=p.subarray(32),b=n("v3.local.",s,u,t,r),S=m(b,g);if(!l(a,S))throw new o("decryption failed");const P=await y(u,w,v);if(!P)throw new o("decryption failed");return P}}},70981:(e,t,i)=>{const{KeyObject:r}=i(76982);let{isKeyObject:s}=i(75162);s||(s=e=>null!=e&&e instanceof r),e.exports=s},65825:e=>{e.exports=e=>!!e&&e.constructor===Object},41726:(e,t,i)=>{const{PasetoNotSupported:r}=i(60308);e.exports=e=>{if(!Number.isSafeInteger(e))throw new r("message is too long for Node.js to safely process");const t=~~(e/4294967295),i=e%4294967295-t,s=Buffer.allocUnsafe(8);return s.writeUInt32LE(t,4),s.writeUInt32LE(i,0),s}},85223:e=>{const t=36e5,i=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;e.exports=e=>{const r=i.exec(e);if(!r)throw new TypeError(`invalid time period format ("${e}")`);const s=parseFloat(r[1]);switch(r[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(1e3*s);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(6e4*s);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(s*t);case"day":case"days":case"d":return Math.round(864e5*s);case"week":case"weeks":case"w":return Math.round(6048e5*s);case"year":case"years":case"yr":case"yrs":case"y":return Math.round(315576e5*s)}}},29534:(e,t,i)=>{const{encode:r}=i(47859);e.exports=function(e,t,...i){let s=`${e}${r(Buffer.concat(i))}`;return t.byteLength&&(s+=`.${r(t)}`),s}},70761:(e,t,i)=>{const r=i(41726);e.exports=(...e)=>{e=e.filter(Boolean);let t=r(e.length);for(let i of e){i=Buffer.from(i,"utf8");const e=r(Buffer.byteLength(i));t=Buffer.concat([t,e,i])}return t}},40816:(e,t,i)=>{const{PasetoInvalid:r}=i(60308),{strict:s}=i(64770),n=i(65825);e.exports=e=>{try{const t=JSON.parse(e);return s(n(t)),t}catch{throw new r("All PASETO payloads MUST be a JSON object")}}},92366:(e,t,i)=>{const{sign:r}=i(56463),s=i(70761),n=i(29534);e.exports=async function(e,t,i,a,o,l,u){const c=s(u,e,t,i,l),d=await r(a,c,o);return n(e,i,t,d)}},495:(e,t,i)=>{const{createSecretKey:r}=i(76982),s=i(70981);e.exports=function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}`)&&(t=Buffer.from(t.slice(e.length),"base64url")),!s(t))try{t=r(t)}catch{}if(!s(t))throw new TypeError("invalid key provided");if("secret"!==t.type||32!==t.symmetricKeySize)throw new TypeError(`${e} secret key must be 32 bytes long symmetric key`);return t}},82682:(e,t,i)=>{const{timingSafeEqual:r}=i(76982),s=(e,t)=>{if(e.length===t)return e;const i=Buffer.alloc(t);return e.copy(i),i};e.exports=(e,t)=>{const i=Math.max(e.length,t.length);return r(s(e,i),s(t,i))}},49826:(e,t,i)=>{const{PasetoVerificationFailed:r}=i(60308),{verify:s}=i(56463),n=i(70761),{pre:a}=i(88965);e.exports=async function(e,t,i,o,l,u,c){const{raw:d,f:h}=a(e,t),f=d.subarray(0,-o),m=d.subarray(-o),p=n(c,e,f,h,u);if(!await s(i,p,l,m))throw new r("invalid signature");return{m:f,footer:h.length?h:void 0}}},91227:(e,t,i)=>{const r=i(60308),s=i(79665),n=i(56120),a=i(50015),o=i(64230),{decode:l}=i(2744);e.exports={decode:l,V1:s,V2:n,V3:a,V4:o,errors:r}},39324:(e,t,i)=>{const{"v1.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v1.local"),{pre:n,post:a}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:o=!1,...l}={}){const{raw:u,f:c}=n("v1.local.",e),d=(t=s(t)).export(),h=await r(u,c,d);return a("v1",o,l,i,h,c,"local")}},21472:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v1.local"),n=i(1658),{"v1.local-encrypt":a}=i(56463);e.exports=async function(e,t,{footer:i,...o}={}){const l=n(e,o);t=s(t);const u=r(i),c=t.export();return a(l,u,c)}},79665:(e,t,i)=>{const r=i(77868),s=i(77256),n=i(21472),a=i(39324),o=i(70866);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o}},70866:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=s(r.generateKeyPair),o=s(r.generateKey);e.exports=async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await o("aes",{length:256});return"paserk"===t?`k1.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await a("rsa",{modulusLength:2048});return"paserk"===t?{secretKey:`k1.secret.${e.export({format:"der",type:"pkcs1"}).toString("base64url")}`,publicKey:`k1.public.${i.export({format:"der",type:"pkcs1"}).toString("base64url")}`}:e}default:throw new n("unsupported v1 purpose")}}},77868:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPrivateKey:n}=i(76982),a=i(83561),o=i(1658),l=i(92366),u=i(70981);e.exports=async function(e,t,{footer:i,...c}={}){const d=o(e,c),h=a(i);return t=function(e){if("string"==typeof e&&e.startsWith("k1.secret."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!u(e))try{e=n(e)}catch{}if(!u(e))throw new TypeError("invalid key provided");if("private"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public signing key must be a private RSA key with 2048 bit modulus length");return e}(t),l("v1.public.",d,h,"sha384",{key:t,padding:r,saltLength:s})}},77256:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPublicKey:n}=i(76982),a=i(49826),o=i(70981),{post:l}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:u=!1,...c}={}){t=function(e){if("string"==typeof e&&e.startsWith("k1.public."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!o(e)||"private"===e.type)try{e=n(e)}catch{}if(!o(e))throw new TypeError("invalid key provided");if("public"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public verify key must be a public RSA key with 2048 bit modulus length");return e}(t);const{m:d,footer:h}=await a("v1.public.",e,"sha384",256,{key:t,padding:r,saltLength:s});return l("v1",u,c,i,d,h,"public")}},56120:(e,t,i)=>{const r=i(88451),s=i(859),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(62827);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},62827:(e,t,i)=>{const r=i(64770),s=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:a}=i(60308),o=i(70981),l=n(s.generateKeyPair);async function u(e,t,{format:i="keyobject"}={}){if("keyobject"!==i&&"paserk"!==i)throw new TypeError("invalid format");if("public"===t){const{privateKey:t,publicKey:r}=await l("ed25519");return"paserk"===i?{secretKey:`k${e.slice(1)}.secret.${h(t).toString("base64url")}`,publicKey:`k${e.slice(1)}.public.${h(r).toString("base64url")}`}:t}throw new a(`unsupported ${e} purpose`)}function c(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 64:{const t=s.createPrivateKey({key:Buffer.concat([Buffer.from("302e020100300506032b657004220420","hex"),e.subarray(0,32)]),format:"der",type:"pkcs8"});if(!e.subarray(32).equals(Buffer.from(t.export({format:"jwk"}).x,"base64")))throw new TypeError("invalid byte sequence");return t}case 32:return s.createPublicKey({key:Buffer.concat([Buffer.from("302a300506032b6570032100","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 64 bytes (private key), or 32 bytes (public key)")}}function d(e,t){if(!o(t))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public key must be an Ed25519 key`);switch(t.type){case"public":return Buffer.from(t.export({format:"jwk"}).x,"base64");case"private":{const{d:e,x:i}=t.export({format:"jwk"});return Buffer.concat([Buffer.from(e,"base64"),Buffer.from(i,"base64")])}}}function h(...e){return d("v2",...e)}e.exports={_checkPrivateKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.secret.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,64)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t))try{t=s.createPrivateKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("private"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public signing key must be a private ed25519 key`);return t},_checkPublicKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.public.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,32)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t)||"private"===t.type)try{t=s.createPublicKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("public"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public verify key must be a public ed25519 key`);return t},_generateKey:u,_keyObjectToBytes:d,bytesToKeyObject:c,generateKey:async function(...e){return u("v2",...e)},keyObjectToBytes:h}},88451:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(92366),{_checkPrivateKey:a}=i(62827),o=a.bind(void 0,"v2");e.exports=async function(e,t,{footer:i,...a}={}){const l=s(e,a);t=o(t);const u=r(i);return n("v2.public.",l,u,void 0,t)}},859:(e,t,i)=>{const r=i(49826),{_checkPublicKey:s}=i(62827),{post:n}=i(88965),a=s.bind(void 0,"v2");e.exports=async function(e,t,{complete:i=!1,buffer:s=!1,...o}={}){t=a(t);const{m:l,footer:u}=await r("v2.public.",e,void 0,64,t);return n("v2",s,o,i,l,u,"public")}},18582:(e,t,i)=>{const{"v3.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v3.local"),n=i(80608),{pre:a,post:o}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:l=!1,assertion:u,...c}={}){const{raw:d,f:h}=a("v3.local.",e);t=s(t);const f=n(u),m=t.export(),p=await r(d,h,m,f);return o("v3",l,c,i,p,h,"local")}},43406:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v3.local"),n=i(1658),a=i(80608),{"v3.local-encrypt":o}=i(56463);e.exports=async function(e,t,{footer:i,assertion:l,...u}={}){const c=n(e,u);t=s(t);const d=r(i),h=a(l),f=t.export();return o(c,d,f,h)}},50015:(e,t,i)=>{const r=i(42438),s=i(65466),n=i(43406),a=i(18582),{generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}=i(80568);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}},80568:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=i(70981),o=i(82115),l=s(r.generateKeyPair),u=s(r.generateKey);function c(e){if(!a(e))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public key must be an EC P-384 key");switch(e.type){case"public":return o(e);case"private":return Buffer.from(e.export({format:"jwk"}).d,"base64")}}e.exports={generateKey:async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await u("aes",{length:256});return"paserk"===t?`k3.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await l("ec",{namedCurve:"P-384"});return"paserk"===t?{secretKey:`k3.secret.${c(e).toString("base64url")}`,publicKey:`k3.public.${c(i).toString("base64url")}`}:e}default:throw new n("unsupported v3 purpose")}},bytesToKeyObject:function(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 48:return r.createPrivateKey({key:Buffer.concat([Buffer.from("303e0201010430","hex"),e,Buffer.from("a00706052b81040022","hex")]),format:"der",type:"sec1"});case 49:if(2!==e[0]&&3!==e[0])throw new TypeError("invalid compressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3046301006072a8648ce3d020106052b81040022033200","hex"),e]),format:"der",type:"spki"});case 97:if(4!==e[0])throw new TypeError("invalid uncompressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3076301006072a8648ce3d020106052b81040022036200","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 48 bytes (private key), 49 bytes (compressed public key), or 97 bytes (uncompressed public key)")}},keyObjectToBytes:c}},42438:(e,t,i)=>{const{createPrivateKey:r}=i(76982),s=i(83561),n=i(1658),a=i(80608),o=i(92366),l=i(70981),{bytesToKeyObject:u}=i(80568),c=i(82115);e.exports=async function(e,t,{footer:i,assertion:d,...h}={}){const f=n(e,h),m=s(i),p=a(d);return t=function(e){if("string"==typeof e&&e.startsWith("k3.secret."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,48)}catch{}if(Buffer.isBuffer(e))try{e=u(e)}catch{}if(!l(e))try{e=r(e)}catch{}if(!l(e))throw new TypeError("invalid key provided");if("private"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public signing key must be a private EC P-384 key");return e}(t),o("v3.public.",f,m,"sha384",{key:t,dsaEncoding:"ieee-p1363"},p,c(t))}},65466:(e,t,i)=>{const{createPublicKey:r}=i(76982),s=i(80608),n=i(49826),a=i(70981),{bytesToKeyObject:o}=i(80568),l=i(82115),{post:u}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:c=!1,assertion:d,...h}={}){t=function(e){if("string"==typeof e&&e.startsWith("k3.public."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,49)}catch{}if(Buffer.isBuffer(e))try{e=o(e)}catch{}if(!a(e)||"private"===e.type)try{e=r(e)}catch{}if(!a(e))throw new TypeError("invalid key provided");if("public"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public verify key must be a public EC P-384 key");return e}(t);const f=s(d),{m,footer:p}=await n("v3.public.",e,"sha384",96,{key:t,dsaEncoding:"ieee-p1363"},f,l(t));return u("v3",c,h,i,m,p,"public")}},64230:(e,t,i)=>{const r=i(29901),s=i(77933),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(24961);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},24961:(e,t,i)=>{const{_checkPrivateKey:r,_checkPublicKey:s,_generateKey:n,_keyObjectToBytes:a,bytesToKeyObject:o}=i(62827);e.exports={_checkPrivateKey:r,_checkPublicKey:s,bytesToKeyObject:o,generateKey:async function(...e){return n("v4",...e)},keyObjectToBytes:function(...e){return a("v4",...e)}}},29901:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(80608),a=i(92366),{_checkPrivateKey:o}=i(24961),l=o.bind(void 0,"v4");e.exports=async function(e,t,{footer:i,assertion:o,...u}={}){const c=s(e,u),d=n(o);t=l(t);const h=r(i);return a("v4.public.",c,h,void 0,t,d)}},77933:(e,t,i)=>{const r=i(80608),s=i(49826),{_checkPublicKey:n}=i(24961),{post:a}=i(88965),o=n.bind(void 0,"v4");e.exports=async function(e,t,{complete:i=!1,buffer:n=!1,assertion:l,...u}={}){t=o(t);const c=r(l),{m:d,footer:h}=await s("v4.public.",e,void 0,64,t,c);return a("v4",n,u,i,d,h,"public")}},37975:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),s=i(38639),n=i(44198);function a(){return(0,s.toNotBoolean)((0,n.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,n.env)().NO_COLOR)||["dumb","unknown"].includes((0,n.env)().TERM))}t.noColor=a;let o=!a();function l(){return o}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){o=e??!a()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),s=i(7282),n=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,s.isProd)()?"":`-${(0,s.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+n.version))},48884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),s=i(36783),n=i(76790),a=i(22573),o=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const s=new Set(t.map(i));return e.filter((e=>s.has(i(e))))}function w(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...w(e.slice(i+1))]}function v(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function b(e){return P(e,(e=>e.valueOf()))}function S(e){return M(e,(e=>e.valueOf()))}function P(e,t){return T(e,t,((e,t)=>(0,h.lt)(e,t)))}function M(e,t){return T(e,t,((e,t)=>(0,h.gt)(e,t)))}function _(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function T(e,t,i){return E(e,t,i).index}function E(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let s,n=-1;for(let r=0;re.slice(i,i+t)))}async function k(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,o.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(a.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,o.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,s.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let s=0;for(const n of e)(t(n,s++)?i:r).push(n);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return w(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=v,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let s=0;se.slice(0,t+1)))},t.min=function(e){return e[b(e)]},t.leastIndex=b,t.max=function(e){return e[S(e)]},t.greatestIndex=S,t.leastIndexBy=P,t.greatestIndexBy=M,t.leastBy=_,t.least=function(e){return _(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[M(e,t)]},t.leastByCtx=function(e,t){const i=E(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=D,t.collectBatched=function(e,t,i){const s=[];for(const n of D((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(i(n)));return s},t.collectBatchedAsync=async function(e,t,i){const s=[];for(const n of D((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(await i(n)));return s},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await k(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+s;if(re+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const o=i(77988),l=a(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),w=i(25764),v=i(38836),b=i(99331),S=i(95937),P=i(98314),M=i(38835),_=i(70025),T=i(8769),E=i(43334),D=i(95402),k=i(28874),x=i(63870);class F extends v.EndableWrapper{constructor(e,t,i=w.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>n(this,r,"m",s).call(this)),i,"worker"===e?(0,x.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const a=t;a.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,D.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),a.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),a.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,S.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),a.on("fatalError",(e=>{this.onError("on(fatalError)"+M.FatalErrorFlag,e)})),a.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),a.on("noTaskData",((e,i,r)=>{const s=t.options.streamFlushMillis;s{this.logger.error("observeBatchCluster.endError()",e)})),a.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&D.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof o.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,b.ending)()||!0===(0,_.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,T.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=F,r=new WeakSet,s=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(E.isWin?3:1)*c.minuteMs,maxTasksPerProcess:k.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:k.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:k.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:k.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:k.Settings.taskTimeoutMs.valueOrDefault}}},71371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedGreatestSet=void 0;const r=i(92322);t.BoundedGreatestSet=class{constructor(e,t){this.maxLength=e,this.toValue=t,this.sortedArray=new r.SortedSet(t)}toA(){return this.vacuum(),this.sortedArray.toA()}vacuum(){return this.sortedArray.retainLastN(this.maxLength)}add(...e){this.maxLength<=0||(this.sortedArray.addAll(...e),this.sortedArray.length>=2*this.maxLength&&this.vacuum())}}},89788:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(r.add(this),this.maxLength=e,s.set(this,void 0),n.set(this,0),a.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,s,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]=t))}get length(){return u(this,n,"f")}set length(e){l(this,n,(0,d.clamp)(0,u(this,n,"f"),e),"f")}clear(){this.length=0}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,n,"f")),e<0||e>=u(this,n,"f")?void 0:t((e+u(this,a,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,s,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,n,"f"){u(this,s,"f")[e]=c}));return u(this,n,"f")}pop(){return u(this,r,"m",o).call(this,u(this,n,"f")-1,(e=>{var t;return l(this,n,(t=u(this,n,"f"),--t),"f"),u(this,s,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,n,"f"){u(this,s,"f")[e]=c,l(this,a,e,"f")}));return u(this,n,"f")}shift(){return u(this,r,"m",o).call(this,0,(e=>{var t,i;return l(this,a,(t=u(this,a,"f"),++t),"f"),l(this,n,(i=u(this,n,"f"),--i),"f"),u(this,s,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",o).call(this,u(this,n,"f")-1-e,(e=>{const i=u(this,s,"f")[e];u(this,s,"f")[e]=u(this,s,"f")[t],u(this,s,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),s=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function n(e){for(const{bom:t,encoding:i}of s)if(a(e,t))return e.subarray(t.length).toString(i);return e.toString()}function a(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=n,t.bufferToString=function(e){return Buffer.isBuffer(e)?n(e):(0,r.toS)(e)},t.bufferStartsWith=a},9092:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=s},36638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=s},40583:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const a=i(40958),o=i(23838),l=n(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new o.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,a.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,s=-1;for(const[i,n]of this.m.entries()){const a=(0,c.diceCoeff)(i,e);if(a>t&&a>s){const e=this.getFirst(n);null!=e&&(r=e,s=a)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),s=i(31586),n=i(68708),a=i(54993),o=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new o.Average(0);for(const t of this.keys()){if(!(0,s.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,a.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,s.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,n.tap)(new o.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,s]of this.m.entries()){const n=e(r);t.fill(n,i,i+s),i+=s}return t}}t.CountingSet=u},79840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),s=i(72993),n=i(45969),a=i(43334);t.EditionType=(0,r.lazy)((()=>a.isElectron?"Desktops":(0,n.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>s.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),s=i(55835),n=i(68708);var a=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return a.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,s.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.omit)(e,...i),(0,n.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,s.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),s=i(19851),n=i(95696);t.examples=(0,s.lazy)((()=>n.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),s=i(65843),n=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,s.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,n.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(31586),o=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,a.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,a.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,s.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,s.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,n.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,o.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,o.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,o.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,a.isNumber)(e.__uid)&&(0,a.isNumber)(e.__start)}},80049:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),s.set(this,0),n.set(this,0),a.set(this,0),o.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,s,l(this,s,"f")+e.cacheHitsAsync,"f"),u(this,n,l(this,n,"f")+e.cacheMisses,"f"),u(this,a,l(this,a,"f")+e.rejections,"f"),u(this,o,l(this,o,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,s,"f"),cacheMisses:l(this,n,"f"),rejections:l(this,a,"f"),timeouts:l(this,o,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,a,o;if(!this.cache.has(e))return void u(this,n,(t=l(this,n,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,s,(i=l(this,s,"f"),++i),"f"),c.promise):(u(this,r,(a=l(this,r,"f"),++a),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(o=l(this,r,"f"),++o),"f"),c}get(e){var t,i;const s=this.cache.get(e);return null==s||s instanceof m.Deferred&&s.isPending?u(this,n,(t=l(this,n,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),s instanceof m.Deferred?s.value:s}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,s,0,"f"),u(this,n,0,"f"),u(this,a,0,"f"),u(this,o,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,a,(t=l(this,a,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,o,(r=l(this,o,"f"),++r),"f")})),r.promise}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap},54127:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,a.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,s.range)(0,r).filter((e=>this.rows.every((t=>(0,n.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,o.fromEntries)(e))).filter((e=>(0,o.values)(e).some(n.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,o=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(o,r.index);(0,n.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),h=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:h});else{const e=(0,s.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,a.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}o=t.lastIndex}const l=(0,s.last)(i);return null!=l&&((0,n.blank)(this.headerRow.slice(o))?l.rightIdx=(0,a.max_)(...this.rows.map((e=>e.length))):l.rightIdx=o),i}}t.Fixed=m},73168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const r=i(55835),s=i(20014),n=i(55222),a=i(97352),o=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,a.within)(-90,90,e)&&0!==e}function c(e){return(0,a.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function h(e,t,i=o){return(0,r.map)(m(e,t,l(i)),(e=>n.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=o){return h(e?.lat,e?.lon,t)},t.geohash=h,t.geohashNumericShort=function(e,t){return m(e,t,30)};const f=new s.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=o){return d(e,t)?f.zip([t,e],l(i)):void 0}function p(e,t=o){return f.unzip(e,l(t))?.reverse()}function g(e,t=o){const[i,r]=p(e,t);return{lat:i,lon:r}}t.geohashNumeric=m,t.ungeohash=function(e,t=o){return(0,r.map)(n.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,r=t.lat*Math.PI/180,s=(t.lat-e.lat)*Math.PI/180,n=(t.lon-e.lon)*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(r)*Math.sin(n/2)*Math.sin(n/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},66364:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSuspended=void 0;const r=i(19851);t.isSuspended=(0,r.lazy)((()=>!1))},80875:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),s=i(98553);var n=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return n.parseJSON}}),t.mapParsed=function(e,t){const i=(0,s.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,s.parseJSON)((await(0,r.readFile)(e)).toString())}},57206:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDefaultJsonRevivers=void 0;const r=i(77988),s=i(51168),n=i(45599),a=i(98553),o=i(68708),l=i(24689),u=i(21330),c=i(57159),d=i(28544),h=(0,n.defer)((()=>{s.DateTime.prototype.toJSON=function(){return(0,o.compactValues)({_ctor:s.DateTime.name,ts:this.toMillis(),zone:"system"===this.zone?.type?void 0:this.zoneName})}})),f={name:s.DateTime.name,fromJSON:e=>s.DateTime.fromMillis(e.ts,(0,o.compactValues)({zone:e.zone}))};t.addDefaultJsonRevivers=(0,n.defer)((()=>{h(),(0,a.addJsonRevivers)(r.ExifDateTime,r.ExifDate,r.ExifTime,f,d.CapturedAt,l.DateInterval,u.FuzzyDate,r.BinaryField,c.WrappedError)}))},19851:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const a=i(57975),o=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&n(this,r,"m",s).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,o.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,o.mkLogger)("Locale")));function w(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=b(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>S(w()??await(m.isWin?P():m.isMac?_():T()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(w);const v=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function b(e){if((0,n.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=v.exec(e.trim())?.groups;return null==i?void 0:(0,s.compact)([i.lang,i.country]).join("-")}function S(e){return b(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=S,t.localeWin=P;const M={timeoutMs:10*a.secondMs};async function _(){return b(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],M))}async function T(){return S(w((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],M)})))}t.localeMac=_,t.localePosix=T,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),s=i(1708),n=i(45599),a=i(68708),o=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,n.defer)((()=>{(0,o.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:s.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,a.pick)(s.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:s.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),s=i(32105),n=i(14593);t.rootLoggers=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));const a=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));t.mkLogger=function(e){return new n.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new n.ContextualLogger(e,a)}},56639:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),s=i(55835),n=i(59455),a=i(48884);function o(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,a.concat)(...e.map((e=>t(e)))))},t.compactMap=o,t.toMap=function(e,t){return o((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:o(await Promise.all((0,r.compact)((0,n.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,s.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),s=i(54557);t.memoize=function(e,t){let i=0;const n=new s.FifoCache(t.maxSize,t.ttlMs),a=t=>{if(null!=t)return i++,n.getOrSet((0,r.stringify)(t),(()=>e(t)))};return a.clear=e=>null==e?n.clear():n.delete((0,r.stringify)(e)),a.size=()=>n.size,a.callCount=()=>i,a}},31578:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const r=i(1708),s=i(31586),n=i(12168),a=i(70417);function o(){const e=(0,r.memoryUsage)();return(0,a.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,r.memoryUsage)().rss}t.memoryUsageBytes=o,t.memoryUsageMb=function(){return(0,s.sigFigs)(o()/n.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,s.sigFigs)(l()/n.MB,2)}},7282:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const s=r(i(1708)),n=i(38639),a=i(54993),o=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,o.lazy)((()=>s.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,a.toS)(s.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return s.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,n.isTrue)(s.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){s.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55835),o=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,o.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(o.gt0)},t.firstNonZero=function(...e){for(const t of(0,n.flatten)(e)){const e=(0,o.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,a.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,o.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,o.toInt)(e),s=(0,o.toInt)(t);return null!=r&&r>0&&null!=s&&s>0?i(r,s):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,o.isNumber)(e))return e;if((0,s.blank)(e))return;const t=String(e);return(0,a.map)(f.exec(t),(e=>(0,o.toFloat)(t.substr(e.index))))}function p(e){return(0,o.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,a.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,a.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const s=i*e.length;for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),s=i(42659),n=i(96249),a=i(55835),o=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,s.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,s]of(0,l.entries)(e)){const e=t(r,s);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,a.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(a.defined)},t.firstDefinedField=function(e,...t){return(0,a.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,a.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const s of t)r[s]=i(s,e[s]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let s=0;for(const n of(0,l.keys)(e))if(r[n]=t(n,e[n]),s++,(0,o.gt)(s,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,n.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),s=i(73024),n=i(48161),a=i(19851),o=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),w=i(30933),v=(0,a.lazy)((()=>(0,f.mkLogger)("os")));function b(){return(0,n.platform)()+" "+(0,n.release)()}t.osArch=(0,a.lazy)((()=>`${function(){switch((0,n.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return F();case"win32":return C();default:return b()}}()} on ${(0,n.arch)()}`)),t.osFullName=(0,a.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const S=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function M(){return"ubuntu"===(0,t.osDistributionLinux)()}function _(){return"fedora"===(0,t.osDistributionLinux)()}function T(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,a.lazy)((()=>{if(g.isLinux)for(const e of S)try{const t=(0,s.readFileSync)(e).toString();if((0,o.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){v().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,a.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,o.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),b)})),t.osDistributionLinux=(0,a.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=M,t.hasApt=function(){return P()||M()},t.isFedora=_,t.isAlpine=T;const E={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},D={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function k(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),s=t[i];return(0,c.isString)(s)?s:s?.[r]}const x=(0,a.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function F(e=x()){try{return(0,o.mapNotBlankOr)(function(e=x()){return k(e,E)}(e),(t=>`macOS ${t} (${e})`),b)}catch(e){return v().warn("osNameMac(): unknown release",e),b()}}function C(e=(0,n.release)()){const t=e.startsWith("10.0.22")?"11":k(e,D);return null!=t?`Windows ${t} (${e})`:(v().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=F,t.osNameWin=C,t.CPUs=(0,a.lazy)((()=>(0,h.uniqCount)((0,w.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,a.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(C())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=x();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(M())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(_())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(T())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},45393:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetVersion=t.AssetFileVersion=void 0,t.AssetFileVersion=12,t.AssetVersion=4},12801:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const s=r(i(48161)),n=i(50989);t.PriorityClasses=(0,n.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:s.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:s.default.constants.priority.PRIORITY_NORMAL,BelowNormal:s.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:s.default.constants.priority.PRIORITY_LOW,Low:s.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setProcessTitle=t.setShortProcessNames=void 0;const r=i(72993),s=i(50213),n=i(23560),a=i(43334);let o=!a.isElectron;t.setShortProcessNames=function(e){o=e},t.setProcessTitle=function(){try{const e=[o?r.SimpleShortAppName:r.SimpleAppName];(0,n.isMainService)()&&a.isElectron||e.push((0,n.serviceName)());const t=e.join(a.isElectron?" ":"-");i(85949).title=t}catch(e){(0,s.mkLogger)("ServiceNames").warn("Failed to set friendly process name",e)}}},92782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeRandomUid=t.safeRandomChars=void 0;const r=i(55222),s=i(65713);t.safeRandomChars=function({radix:e=r.TokenRadix,length:t}){return(0,s.decuss)((()=>e.randomChars(t)))},t.safeRandomUid=function(e){return(0,s.decuss)((()=>(e?.radix??r.TokenRadix).randomUid(e?.chars??20,e?.splitEveryN??5,e?.sepChar??"-")))}},409:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),s=i(56409),n=i(31586),a=i(22911),o=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,v(...e)}}async function w(...r){f=!0,m=Date.now()+(0,n.max_)(t,i);const s=d=new a.Deferred(c);(0,n.gt0)(i)&&s.setTimeout(i);try{s.resolve(await e(...r))}catch(e){s.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,o.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return s.promise}const v=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,r.delay)(1).then((()=>t))}return w(...e)};return v.clear=()=>{h=void 0},v.donePromise=()=>{if(!f)return Promise.resolve();const e=new s.Latch;return p.push(e),e},v.force=async(...e)=>(h=void 0,f&&await v.donePromise(),w(...e)),v.isRateLimited=()=>g(),v.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),v.minCallDelayMs=()=>t,v.setMinCallDelayMs=e=>{t=e},v}},68852:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),s=i(54993);function n(e){return e instanceof a?e.source:(0,s.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let s;for(;null!=(s=e.exec(t));)s.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(s,"index","groups"));return i},t.escapeRegExp=n,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(n(t))}const s=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(s,i)};class a{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=a;class o extends a{static from(...e){const t=l(e);return new o("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,o=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof a||t instanceof RegExp?(i+=t.source,r||(r=t.global),o||(o=t.ignoreCase),l||(l=t.multiline)):i+=n((0,s.toS)(t));return new RegExp(i,t??(r?"g":"")+(o?"i":"")+(l?"m":""))}t.RegExpOptional=o,t.concatRegexp=l},79089:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),w=i(34102),v=i(43334),b=i(24399),S=i(28874),P=(0,a.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,w.ee)().on("clearCache",(()=>T.prior()?.clear()))));const M=(0,a.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",n.default.basename(S.Settings.ffmpegPath.valueOrDefault)].map((e=>v.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,o.compactBlanks)([n.default.basename(e),...t.map((e=>n.default.basename(e)))]).some((e=>M().includes(e.toLowerCase())))};let _=!0;const T=(0,a.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||T().has(e))return;T().add(e);const i=(0,p.priorityPosixToClass)(t)??S.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),_)try{return s.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;_=!1}try{return await(v.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await b.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const s=r(i(1708)),n=i(19851),a=i(40958),o=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===o.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===o.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===o.ServiceNames.sync}function p(){return(0,t.serviceName)()===o.ServiceNames.test}t.serviceName=(0,n.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,n.lazy)((()=>(0,a.compactBlanks)([t.serviceName.prior(),(0,l.toS)(s.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return o.ServiceNames.indexOf(e)??o.ServiceNames.length+1},t.MainServices=[o.ServiceNames.main,o.ServiceNames.desktop],t.DbServices=[o.ServiceNames.sync,o.ServiceNames.info,o.ServiceNames.web,o.ServiceNames.list,o.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[o.ServiceNames.sync,o.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===o.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===o.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,n.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function s(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=s,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=s(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=s(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),s=i(57150),n=i(7282),a=i(23560),o=i(17181);t.setServiceName=function(e){(0,a.isMainService)(e)&&(e=r.ServiceNames.main);const t=a.serviceName.prior();t!==e&&((0,n.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),a.serviceName.set(e),(0,o.setupLogger)(),(0,s.logStartup)())}},28850:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const o=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends o.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),s.set(this,void 0),n(this,r,e,"f")}_call(){return(0,l.time)(a(this,r,"f")+(null==a(this,s,"f")?"(local)":"(remote)"),null==a(this,s,"f")?this.impl():a(this,s,"f").call(this))}setShim(e){n(this,s,e,"f")}hasShim(){return null!=a(this,s,"f")}clearShim(){n(this,s,void 0,"f")}}r=new WeakMap,s=new WeakMap},12089:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,a){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=a,s.set(this,void 0),n.set(this,void 0),l(this,s,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",o).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",a).call(this,e),(()=>u(this,r,"m",o).call(this,e)))}setShim(e){l(this,n,e,"f")}hasShim(){return null!=u(this,n,"f")}clearShim(){l(this,n,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",a).call(this,e))}}s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},o=function(e){return(0,m.time)(u(this,s,"f")+(null==u(this,n,"f")?"(local)":"(remote)"),null==u(this,n,"f")?this.impl(e):u(this,n,"f").call(this,e))}},45255:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const n=i(76790),a=i(17586);class o{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return s(this,r,"f")[Symbol.iterator]()}get length(){return s(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=s(this,r,"f").length-1;for(;t<=i;){const n=t+Math.floor((i-t)/2),a=this.valueOf(s(this,r,"f")[n]);if(e===a)return{found:!0,index:n};e>a?t=n+1:i=n-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&s(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...s(this,r,"f")];const a=t=>t<0||t>s(this,r,"f").length-1?null:(i??this.diff)(s(this,r,"f")[t],e),o=this.findIndex(e);if(null==o)return;let l=o.index-1,u=a(l),c=o.index,d=a(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return s(this,r,"f").shift()}at(e){return(0,a.at)(s(this,r,"f"),e)}toA(){return[...s(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===s(this,r,"f").length-1){const e=[...s(this,r,"f")];return s(this,r,"f").length=0,e}return s(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return s(this,r,"f").splice(e,t)}retainLastN(e){return e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),s=i(82328),n=i(84542),a=i(95705),o=i(28874);t.consoleLog=function(e,...t){o.Settings.quiet.valueOrDefault||(0,s.stdoutEnded)()||console.log((0,n.crlf)(e),...t)},t.consoleError=function(e){o.Settings.quiet.valueOrDefault||(0,a.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=o.Settings.quiet.envValue;try{return o.Settings.quiet.envValue=!0,await e()}finally{o.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),s=i(95705);t.stdoutEnded=function(){return(0,s.streamEnded)(r.stdout)}},71567:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const s=r(i(1708)),n=i(22573),a=i(98553),o=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:s.default.stdout})}function f({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const s=(0,a.stringify)(e,void 0,(0,o.isInfoService)()||(0,o.isMainService)()?2:void 0);r.write(s+"\n"),(0,o.isWorkerService)()&&null!=i&&(s.includes(u.FailStr)||(0,c.isFatalError)(s)||(0,c.isHealthCheckError)(s)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||s.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:s.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,n.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const w=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const s=t.indexOf(i,r);return-1===s?0:1+e(t,i,s+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,n.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,o.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,h.toS)(e),s=(0,h.toS)(t);return s.length>0&&(0,c.equalsIgnoreCase)(r.slice(-s.length),s,i)?r.slice(0,-s.length):r},t.gist=function(e,t=80,i=80){const r=(0,h.toS)(e),s=r.length-(t+i);return s<=0?r:r.slice(0,t).trim()+" …(+"+s+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const v=/^[A-Z]/;function b(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function S(e){return(0,d.toA)(e).sort(b)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return v.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,n.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=b,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=S,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,a.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=b(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,n.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),s=t.indexOf(r);if(s>=0)return{index:s,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const M=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function _(e){return M.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=_;const T=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,n.blank)(e)||(e=(0,h.toS)(e).trim(),null!=T.exec(_(e))&&(e=e.slice(1,-1).trim())),e};const E=/^['‘’].*['‘’]$/,D=/^["“”„«»〃].*["“”„«»〃]$/;function k(e,t){const i=x(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function x(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let s,n=0;for(;null!=(s=t.exec(e));)s.index===t.lastIndex?t.lastIndex++:(t.lastIndex=s[0].length+s.index,i.push(e.substring(n,s.index)),r.push(e.substring(s.index,t.lastIndex)),n=t.lastIndex);return n(0,o.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),E.test(e)||D.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>w.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),s=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,a.map)(i[e],(e=>t+=e))));return t},t.splitKeep=k,t.splitUp=x,t.sortNaturalBy=F,t.sortNatural=function(e){return(0,s.sortBy)(e,(e=>F(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=S((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,s.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,n.blank)(e)||(0,n.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,o.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const C=/#.*$/gm;t.stripComments=function(e){return e.replace(C,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,n.blank)(r))for(const e of r.split(t))(0,n.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,n.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),s=e.findIndex((e=>r.test(e))),a=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(s<0)return e;for(let t=s+1;te.trim()))))}},83556:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function s(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=s,t.asObjectKey=function(e){return s(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const s=r(i(77598)),n=i(73913),a=i(55222);function o(e,t=n.HashBits){return s.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=a.Radix58,r=224){return i.encodeBuffer(o(e,r)).substring(0,t)}t.stringShaToBuffer=o,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=a.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(31586),o=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,s="";for(let n=0;n=r&&(r=i.get(n,a),s=(0,l.substr)(e,n-r+1,r)));return s}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),s=t.normalize();return e!==r||t!==s?y(r,s):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function w(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===r?1:void 0),(()=>(0,n.blank)(e)!==(0,n.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=v(i),t=v(r);return 2*b(e,t).length/(e.length+t.length)}))}function v(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function b(e,t){const i=(0,f.intersection)(e,t),s=[];return i.forEach((i=>{const n=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,a.times)(n,(()=>s.push(i)))})),s}function S(e,t,i){const s=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,s))-i((0,l.strslice)(t,s))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,s.sortBy)(t,(e=>-e.length))[0]}function M(e,t){const[i,r]=[e,t].map(P).map((e=>(0,n.blank)(e)?"":e));return S(i,r,(e=>(0,a.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(n.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=w,t.bigrams=v,t.nonUniqIntersection=b,t.lnsDiff=M;const _=/[^\da-z]+/gi;function T(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(_,"").toLowerCase()));return S(i,r,(e=>c.RadixAlphaNum.decode(e)))}function E(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const s=(0,a.mapNumericOr)(e.charCodeAt(r),(e=>e),256),n=(0,a.mapNumericOr)(t.charCodeAt(r),(e=>e),256),o=(0,a.clamp)(-256,256,s-n);i=null==i?o:(i+o)/2}return i}t.radixDiff=T,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:w(e,t),lns:M(e,t),radixDiff:T(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=E,t.paddedPositionalDiff=function(e,t,i=8){return E((0,o.leftPad)(e,i," "),(0,o.leftPad)(t,i," "))}},84885:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),s=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,s.sortedKeys)(e))}},88264:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TTLArray=void 0;const r=i(31586);class s{constructor(e,t){this.ttlMs=e,this.maxLength=t,this.times=[],this.a=[],this.expirationListeners=[]}[Symbol.iterator](){this.vacuum();const e=[...this.a];return function*(){for(const t of e)yield t}()}push(...e){(0,r.times)(e.length,(()=>this.times.push(Date.now()))),this.a.push(...e),null!=this.maxLength&&this.vacuum()}pushUniq(...e){e.forEach((e=>{this.includes(e)||this.push(e)}))}includes(e){return this.vacuum(),this.a.indexOf(e)>=0}find(e){return this.vacuum(),this.a.find(e)}some(e){return this.vacuum(),this.a.some(e)}shift(){return this.vacuum(),this.times.shift(),this.a.shift()}first(){return this.vacuum(),this.a[0]}last(){return this.vacuum(),this.a[this.a.length-1]}shiftOrFirst(){return this.length>1?this.shift():this.first()}pop(){return this.vacuum(),this.times.pop(),this.a.pop()}onExpire(e){this.expirationListeners.push(e)}slice(e,t){return this.vacuum(),this.a.slice(e,t)}get length(){return this.vacuum(),this.a.length}clear(){return this.times.length=0,this.a.length=0,this}get values(){return this.vacuum(),[...this.a]}map(e){return this.vacuum(),this.a.map(e)}oldestEntryAge(){return this.vacuum(),this.times[0]}vacuum(){if(0===this.a.length)return;const e=this.a.length;if(null!=this.maxLength){const e=this.a.length-this.maxLength;this.times.splice(0,e),this.a.splice(0,e)}const t=Date.now()-this.ttlMs,i=this.times.findIndex((e=>e>t));if(-1===i?this.clear():i>0&&(this.times.splice(0,i),this.a.splice(0,i)),e!==this.a.length)for(const e of this.expirationListeners)e()}}t.TTLArray=s},75387:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",s.set(this,[]),n.set(this,new Map),a.set(this,void 0),o.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,a,"f")}set ttlMs(e){h(this,a,e,"f"),null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),h(this,o,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,n,"f").clear(),this}delete(e){return d(this,n,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,n,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,n,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,n,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const s=t();return null!=s&&this.set(e,s),s}lastSetOrGetTs(e){return d(this,n,"f").get(e)?.ts}set(e,t){return d(this,n,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,n,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,n,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,f.sortBy)(d(this,n,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,s,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,n,"f").delete(e);for(const i of d(this,s,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,n,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[a]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return o(this,r,"m",n).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>o(this,r,"m",n).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||o(this,r,"m",s).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)o(this,r,"m",s).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!o(this,r,"m",s).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield[t,t])}()}toA(){return o(this,r,"m",n).call(this),[...this.delegate.keys()]}[(r=new WeakSet,a=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,s=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},n=function(){for(const[e,t]of this.delegate)o(this,r,"m",s).call(this,e,t)}},84699:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},65211:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resetUid=t.sortByUid=t.tsFromUid=t.isUID=t.uidForTs=t.uid=t.uidSuffix=void 0;const r=i(19851),s=i(76790),n=i(22573),a=i(54993),o=i(7282),l=i(55222);let u=0;const c=l.GeoRadix;function d(e){return c.encode(e)+(0,t.uidSuffix)()}t.uidSuffix=(0,r.lazy)((()=>"-"+c.randomChars(7))),t.uid=function(){return u=Math.max(Date.now(),u+1),d(u)},t.uidForTs=d;const h=/^[\da-z]{9}-[\da-z]{7}$/i;function f(e){const t=(0,a.toS)(e).replace(/(?<=\S)-.*/,"");return(0,n.blank)(t)?void 0:c.decode(t)}t.isUID=function(e){return h.test((0,a.toS)(e))},t.tsFromUid=f,t.sortByUid=function(e){return(0,s.sortBy)(e,(e=>f(e.uid)))},t.resetUid=function(){if(!(0,o.isTest)())throw new Error("unsupported");t.uidSuffix.unset(),u=0}},94174:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,a.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,a.lazy)((()=>(0,o.uniq)([n.default.geteuid?.(),n.default.getuid?.(),s.default.userInfo().uid]))),t.userid=(0,a.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,a.lazy)((()=>(0,o.uniq)([n.default.getegid?.(),n.default.getgid?.(),s.default.userInfo().gid]))),t.groupid=(0,a.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,a.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,a.lazy)((()=>(0,l.toNotBlank)(s.default.userInfo()?.username))),t.userNameFromWhoami=(0,a.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,a.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,a.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,a.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.0-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=0,t.versionPrerelease=["prealpha"],t.release="2024.3.0-prealpha+20240308102353",t.gitSha="92cba1b21937cb9ca770f6a339e44b0fbee04bf9",t.gitDate=new Date(1709922233e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48299:function(e,t){"use strict";var i,r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.WeakCache=void 0;class o{constructor(){i.add(this),this[n]="WeakCache",r.set(this,new Map)}clear(){return a(this,r,"f").clear(),this}delete(e){return a(this,r,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of this.entries())e(i,t,this)}findEntry(e){for(const[t,i]of this.entries())if(e(i,t,this))return i}deleteValueIf(e){for(const[t,i]of this.entries())e(i,t,this)&&a(this,r,"f").delete(t)}get(e){const t=a(this,r,"f").get(e),i=t?.deref();return null==i&&null!=t&&a(this,r,"f").delete(e),i}getOrMaybeSet(e,t){const i=a(this,r,"f").get(e)?.deref();if(null!=i)return i;const s=t();return null!=s&&this.set(e,s),s}set(e,t){return a(this,r,"f").set(e,new WeakRef(t)),this}has(e){return null!=a(this,r,"f").get(e)?.deref()}get size(){return a(this,i,"m",s).call(this),a(this,r,"f").size}keys(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries())null==i.deref()?a(e,r,"f").delete(t):yield t}()}values(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield s}}()}entries(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield[t,s]}}()}[(r=new WeakMap,i=new WeakSet,n=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}}t.WeakCache=o,s=function(){for(const[e,t]of a(this,r,"f").entries())null==t.deref()&&a(this,r,"f").delete(e)}},48963:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),s=i(55835),n=i(31586),a=i(97790),o=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,n.toInt)(e)));if(!(0,s.allDefined)(i))return;const[a,o,u,c,d,h,f]=i,m=(0,n.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(a,o-1,u,c,d,h,f/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,a.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(n.toInt).filter((e=>(0,o.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},79184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aggregateAssetFiles=void 0;const r=i(59455),s=i(48884),n=i(22859),a=i(28874),o=i(79781),l=i(92434);t.aggregateAssetFiles=async function(e){const t=(0,r.toA)((0,l.sortAssetFiles)(e)??e);return(a.Settings.assetAggregation.valueOrDefault===n.AggregateTypes.union?s.clusterSome:s.clusterEvery)(t,o.isSimilarAssetFile)}},79781:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotSimilarAssetFile=t.isSimilarAssetFile=t.whyNotSameAsset=t.VideoImageMismatchMsg=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(50357),o=i(55835),l=i(31586),u=i(68708),c=i(12168),d=i(23467),h=i(73168),f=i(50213),m=i(86580),p=i(48368),g=i(80361),y=i(28874),w=i(28544),v=i(75767),b=i(16170),S=(0,r.lazy)((()=>(0,f.mkLogger)("sync-file.AssetFileComparator")));function P(e,t,i,r=((e,t)=>[e,t])){const s=e[i],o=t[i];if((0,n.blank)(s)||(0,n.blank)(o)||(0,a.eql)(s,o))return;const[l,u]=r(s,o);return(0,a.eql)(l,u)||(0,a.eql)(s,u)||(0,a.eql)(l,o)?void 0:`Different ${String(i)}: ${s} ≠ ${o}`}function M(e){return(0,n.mapNotBlank)(e,(e=>e.toLowerCase().trim().normalize()))}function _(e,t){return[M(e),M(t)]}function T(e,t,i){const r=(0,v.findInequalFields)(e[i],t[i]);return null==r?void 0:`Different ${i} (${r.aKey}:${r.aValue} ≠ ${r.aKey}:${r.aValue})`}function E(e,i){if(!(0,u.allKeysDefined)(e,"width","height","mimetype","sha"))return"af1 was missing required fields";if(!(0,u.allKeysDefined)(i,"width","height","mimetype","sha"))return"af2 was missing required fields";if((0,d.definedAndEql)(e.sha,i.sha))return void S().debug("matching SHA",{af1:e,af2:i});const r=(0,b.isVideoMimeType)(e.mimetype),n=(0,b.isVideoMimeType)(i.mimetype);if(r!==n)return S().tap({msg:"whyNotIsSimilar",result:t.VideoImageMismatchMsg,meta:{af1:e.uri,af2:i.uri,af1IsVideo:r,af2IsVideo:n}});const a=w.CapturedAt.fromAssetFile(e),f=w.CapturedAt.fromAssetFile(i);if(null==a)return"af1 missing capturedAt metadata";if(null==f)return"af2 missing capturedAt metadata";const M=a.isFuzzy||f.isFuzzy;if(M&&y.Settings.allowFuzzyDateImageHashMatches.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if((0,g.isSimilarImageHash)(t,r,{rotationsToCheck:(0,m.validRotations)(e,i)}))return void S().info("allowFuzzyDateImageHashMatches mode: image hashes match",{af1:e,af2:i})}if(!a.overlaps(f))return`captured-at ${a.toISOStringWithPrecision()} != ${f.toISOStringWithPrecision()}`;const E=P(e,i,"make",_)??P(e,i,"model",_);if(null!=E)return E;const D=(0,o.map)((0,h.geohashDistanceMeters)(e.geohash,i.geohash),(e=>(0,l.sigFigs)(e,2))),k={cameraId:T(e,i,"cameraId")??null,imageId:T(e,i,"imageId")??null,lensId:T(e,i,"lensId")??null,exposureSettings:(0,v.whyExposureSettingsNotSimilar)(e,i)??null,closeGeoHash:(0,l.gt)(D,y.Settings.gpsErrorMeters.valueOrDefault)?"geohashes are "+(0,c.fmt)(D)+"m different: too far apart":null};S().debug("whyNotSimilar()",{fields:k});const x=(0,s.compact)((0,u.values)(k));if((0,s.isNotEmpty)(x))return x.join(";");if(y.Settings.useImageHashes.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if(null!=t&&null!=r){const e=(0,g.compareImageHashes)(t,r,{capturedAtIsFuzzy:M});return!0===e?.isSimilar?void 0:e?.whyNotSimilar}}return(0,u.keys)(k).filter((e=>null==k[e])).length>=y.Settings.minMatchesWithoutImageHashes.valueOrDefault?void 0:"Insufficient metadata correlation"}t.VideoImageMismatchMsg="Videos ≠ images",t.whyNotSameAsset=function(e,t,i){{const i=E(e,t);if(null!=i)return i}if("intersection"===y.Settings.assetAggregation.valueOrDefault)for(const r of i)if(r.id!==t?.id){const t=E(e,r);if(null!=t)return t}},t.isSimilarAssetFile=function(e,t){return null==E(e,t)},t.whyNotSimilarAssetFile=E},13991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkSortableAssetFile_=t.mkAssetFile_=t.assetFileMetadata_=t.assetFileImageHashFields_=t.imageHashToAssetFileImageHashFields=t.assetFileStatFields_=t.assetFileUriFields_=void 0;const r=i(19851),s=i(55835),n=i(31586),a=i(59455),o=i(73168),l=i(50213),u=i(12089),c=i(76490),d=i(95696),h=i(48368),f=i(70417),m=i(28874),p=i(43207),g=i(47783),y=(0,r.lazy)((()=>(0,l.mkLogger)("asset-file.AssetFileFactory")));async function w(e){try{return{nativePath:e.nativePath,uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath}}catch(t){return y().throw("Failed to build URI for "+e,{error:t})}}async function v(e){const t=await e.stat_(),i=await e.sidecareStats();return{mtime:Math.floor((0,f.max)([t.mtimeMs,...(0,a.toA)(i).map((e=>e.mtimeMs))])),fileSize:t.size}}function b(e){return{...e,...c.DominantColor.toModeData(e.dominantColors)}}async function S(e){if(!m.Settings.useImageHashes.valueOrDefault)return;const t=await(0,h.imageHash_)(e.nativePath);return null==t?y().throw("Failed to extract image hash for "+e):b(t)}async function P(e){const[i,r,s,n]=await Promise.all([w(e),v(e),(0,t.assetFileMetadata_)(e),e.sha_()]);return{...i,...r,...s,sha:n}}t.assetFileUriFields_=w,t.assetFileStatFields_=v,t.imageHashToAssetFileImageHashFields=b,t.assetFileImageHashFields_=S,t.assetFileMetadata_=(0,u.shim1)({name:"asset-file.assetFileMetadata",impl:async function(e){try{const t=d.PosixFile.for(e),i=await(0,g.readTags)(t);if(null==i)throw new Error("Failed to read tags");if(null==i.capturedAt)throw new Error("Failed to read capturedAt");const r=i.capturedAt.toAssetFileFields();return null==r?y().throw("Failed to render assetFileFields from capturedAt",{capturedAt:i.capturedAt}):{...r,...i.exposureSettings,...i.dimensions,mimetype:i.mimetype,rotation:i.rotation,make:i.Make,model:i.Model,rating:i.rating,cameraId:i.cameraId,imageId:i.imageId,lensId:i.lensId,geohash:(0,o.geohashNumericShort)(i.GPSLatitude,i.GPSLongitude),durationMs:(0,p.extractDurationMs)(i),fps:(0,s.map)((0,n.toFloat)(i.VideoFrameRate),Math.floor)}}catch(t){return y().throw("_assetFileMetadata_() failed",{nativePath:e,error:t})}}}),t.mkAssetFile_=async function(e){const[t,i]=await Promise.all([P(e),S(e)]);return{...t,...i}},t.mkSortableAssetFile_=P},92434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestExistingAssetFile=t.assetFileSortCriteria=t.assetFileSortFields=t.assetFileSortCriteriaPojo=t.sortAssetFiles=t.mtime2sort=t.sortScale=t.dim2sort=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(23838),u=i(31586),c=i(68708),d=i(34666),h=i(50989),f=i(89937),m=i(50213),p=i(4001),g=i(29882),y=i(28874),w=i(14036),v=i(45200),b=i(34238),S=(0,r.lazy)((()=>(0,m.mkLogger)("img.AssetFileSorter"))),P=(0,h.strEnum)("file",f.PS_NETWORK_FILESYSTEM_SCHEME,f.PS_LOCAL_FILE_SCHEME,f.PS_LIBRARY_SCHEME);function M(e){return(0,u.map2Numeric)(e?.width,e?.height,((e,t)=>_(e*t)))}function _(e){if((0,u.gt0)(e))return Math.round(Math.pow(e,y.Settings.variantSortCriteriaPower.valueOrDefault))}function T(e){return Math.round(e/(5*o.minuteMs))}t.dim2sort=M,t.sortScale=_,t.mtime2sort=T;const E=["make","model","rating","cameraId","imageId","lensId","geohash"];function D(e){for(const t of(0,l.groupBy)(e,(e=>e.sha)).values())if(t.length>1){const e=Math.max(...(0,s.compact)(t.map((e=>e.mtime))));for(const i of t)i.mtime=e}return(0,n.sortBy)(e,F).reverse()}function k(e){const t=b.URI.parse(e.uri);if((0,a.blank)(t?.scheme)||(0,a.blank)(t?.path))return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI)",{uri_scheme:t?.scheme,uri_path:t?.path,af:e,parsedURI:t});const i=M(e);if(null==i)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid resolution)",{resolution:i,af:e,parsedURI:t});const r=P.indexOf(t.scheme);if(null==r)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI scheme)",{uri_scheme:t.scheme,af:e,parsedURI:t});const s=e.mtime??0,n=(0,g.parsePosixPath)(t.path),l=[];for(const t of E)(0,a.blank)(e[t])||l.push(t);const u={resolution:i,schemeIdx:r,capturedAtPrecision:-(e.capturedAtPrecisionMs??o.weekMs),metadataCoverage:l.length,metadataFields:l.join(","),isBrowserSupported:(0,w.isSupportedByCurrentBrowserExt)(n.ext),mtime:T(s),isEditOrUpdate:/edit|update/i.test(n.base),isCover:/cover/i.test(n.base),count:Math.abs((0,p.copySuffixCountFromName)(n.name)??0),basename:d.CmpReverseFlag+n.base,parentBasename:d.CmpReverseFlag+(0,g.parentBasename)(e.nativePath??t.path),uri:d.CmpReverseFlag+e.uri};return S().tap({msg:"assetFileSortCriteriaPojo()",result:(0,c.toReqValued)(u)})}function x(){return(0,s.uniq)([...y.Settings.variantSortCriteria.values,"uri"])}function F(e){const t=k(e);if(null==t)return;const i=[];for(const e of x())i.push(t[e]);return i}t.sortAssetFiles=D,t.assetFileSortCriteriaPojo=k,t.assetFileSortFields=x,t.assetFileSortCriteria=F,t.bestExistingAssetFile=async function(e){for(const t of D(e))if(await(0,v.uriExists)(t.uri,t.nativePath))return S().tap({msg:"bestExistingAssetFile()",result:t,meta:{files:e.map((e=>e.uri))}});return S().tap({msg:"bestExistingAssetFile(): no existing uris",result:void 0,meta:{files:e.map((e=>e.uri))}})}},54296:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetFileNativePath=void 0;const r=i(45200);t.getAssetFileNativePath=async function(e){return e.nativePath??(e.nativePath=await(0,r.uri2nativePath)(e.uri,e.mountpoint))}},73568:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const o=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),s.set(this,(0,o.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,n(this,s,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return n(this,s,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,n(this,s,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),a(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=n(this,r,"f")&&clearTimeout(n(this,r,"f")),a(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,s=new WeakMap},69591:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const s=r(i(87997)),n=i(31586);t.debounce=function(e,t){let i,r=[];const a=(0,n.gt0)(t)?(...n)=>{r=n,null!=i&&s.default.clearTimeout(i),i=s.default.setTimeout((()=>{e(...r)}),t)}:e;return a.reset=()=>{null!=i&&s.default.clearTimeout(i),i=void 0},a.force=()=>{a.reset(),e()},a.setTimeoutMs=e=>{a.reset(),t=e},a.timeoutMs=()=>t,a}},22911:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const w=y(i(87997)),v=y(i(57975)),b=i(45599),S=i(26905),P=i(55835),M=i(31586),_=i(68708),T=i(20214),E=i(57153),D=i(85556),k=i(50213),x=i(70025),F=i(95937),C="TIMEOUT",A=(0,b.defer)((()=>(0,k.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,M.gt0)(t)?new s(C).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const s=i[r];if(s.isSettled){if(s.name===C)return void A().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield s.value}}if(i.every((e=>e.name===C)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new s(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),a.set(this,void 0),o.set(this,E.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=s,s,(y=p(i,s,"f",n),m=y++,y),"f",n),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,k.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof s&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,o,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,_.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,a,"f")}get elapsedMs(){return(p(this,a,"f")??Date.now())-this.startedAt}get[(a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[v.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,T.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,T.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(w.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,M.gt0)(e)&&(g(this,h,w.default.setTimeout((()=>{this.isPending&&(this.reject(new D.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,F.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,o,"f")===E.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,o,"f")!==E.PromiseStates.pending}get isResolved(){return p(this,o,"f")===E.PromiseStates.resolved}get isRejected(){return p(this,o,"f")===E.PromiseStates.rejected}get settledMs(){return null==p(this,a,"f")?void 0:p(this,a,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,o,E.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,x.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,S.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,o,E.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,s=I,m=function(e){if(p(this,o,"f")===E.PromiseStates.pending){(0,P.map)(p(this,h,"f"),w.default.clearTimeout),e(),g(this,a,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},n={value:0}},83412:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DoneWrapper=void 0;const r=i(56409),s=i(38836);class n extends s.EndableWrapper{constructor(){super(...arguments),this.doneLatch=new r.Latch}isDone(){return this.doneLatch.isSettled()||this.ended}donePromise(){return this.doneLatch.promise}}t.DoneWrapper=n},27395:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(23838),o=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new a.MultiMap;(0,m.setUnrefInterval)((()=>v()),10*n.minuteMs);const y=5*n.secondMs;async function w(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,o.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function v(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>w(e))))},t.end=w,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),v();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,s.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>w(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,s.compact)(g.valuesFlat()).map((e=>w(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class w extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",a).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,s.set(this,void 0),n.set(this,void 0),o.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,s,"f")}hasTimeout(){return null!=u(this,n,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",a).call(this);const h=()=>{u(this,r,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,s,(0,d.setInterval)(u(this,o,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,n,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,o,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref()):h(),!0}}t.EndableInterval=w,s=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(){(0,h.map)(u(this,s,"f"),d.clearInterval),c(this,s,void 0,"f"),(0,h.map)(u(this,n,"f"),d.clearTimeout),c(this,n,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const o=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,a){this.endTimeoutMs=a,r.set(this,void 0),this.onEnds=[],s.set(this,(0,o.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),n(this,s,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){a(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return n(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return n(this,s,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,s=new WeakMap},99331:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let s=!1;t.ending=function(){return s},t.setEnding=function(e){s=(0,r.isTest)()?e:e||s}},45608:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const s=r(i(1708)),n=i(22573),a=i(45599),o=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,a.defer)((()=>(0,l.mkLogger)((0,o.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,a.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function w(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,n.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,f.endEndables)(),s.default.exit(e.status))}t.exit=w,t.exitOnStdStream=(0,a.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])s.default[e].on(t,(i=>{w({reason:`${e}:${t}`,status:0,error:i})}))}))},39250:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LastOneInWins=void 0;const n=i(23838),a=i(54993),o=i(15674),l=i(73568),u=i(76740),c=i(99331),d=i(42638);t.LastOneInWins=class{constructor(e,t=o.maxCpus){this.name=e,this.maxConcurrency=t,r.set(this,new n.MultiMap),this.p=new d.Promises(e,t)}vacuum(){return s(this,r,"f").filterInPlace(((e,t)=>t.isPending&&!0!==t.payload?.aborted)),s(this,r,"f").valueCount()}enqueue({key:e,abortable:t,fn:i}){for(const t of s(this,r,"f").get(e)??[])t.payload?.abort("aborted by new work");if(this.vacuum(),(0,c.ending)())throw new l.AbortError("ending");const n=t??new u.Abortable,o=this.p.serial((0,a.toS)(e),(()=>i(n)),n);return s(this,r,"f").add(e,o),o}},r=new WeakMap},60172:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,r)=>{t=e,i=r})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,s.set(this,void 0),n.set(this,0),a.set(this,void 0),o.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,a,"f")}unset(){d(this,n,0,"f"),d(this,s,void 0,"f"),d(this,a,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,o,"f").push(e)}prior(){return this.isStale()?void 0:c(this,a,"f")}lastValue(){return c(this,a,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,n,"f")}isStale(){return null==c(this,s,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,s,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,s,"f")?void 0:Date.now()-c(this,s,"f")}elapsedMs(){return c(this,a,"f")?.settledMs??c(this,a,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,o,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,o,"f"))e.onError(t)}finally{d(this,n,(i=c(this,n,"f"),++i),"f")}},u=function(e){d(this,s,Date.now(),"f");const t=c(this,a,"f");return d(this,a,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,a,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,a,"f")),c(this,a,"f")}},1728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),s=i(80049);t.memoizeAsync=function(e,t){let i=0;const n=new s.FifoCacheAsync(t),a=t=>(i++,n.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return a.clear=e=>{if(null==e)return n.clear();{const t=(0,r.stringify)(e);return n.deleteIf((e=>t===e))}},a.size=()=>n.size,a.callCount=()=>i,a}},22781:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),s.set(this,!1),n.set(this,!1)}_call(){return a(this,s,"f")?(o(this,n,!0,"f"),!0===this.undefinedIfBusy?void 0:a(this,r,"f")):(o(this,s,!0,"f"),o(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{o(this,s,!1,"f"),!0===this.runLaterIfBusy&&a(this,n,"f")&&(o(this,n,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return a(this,s,"f")}prior(){return a(this,r,"f")}async force(){return await a(this,r,"f"),this._call()}}r=new WeakMap,s=new WeakMap,n=new WeakMap},37461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),s=i(76790),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),w=i(15674),v=i(42638);var b=i(20214);async function S(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function M({name:e,arr:t,f:i,timeoutMs:s}){const n=[];for(const a of(0,r.compact)(await t))try{const e=await((0,l.gt0)(s)?(0,c.thenOrTimeoutError)(i(a),s):i(a));null!=e&&n.push([e,a])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:a,error:t})}return n}async function _({arr:e,f:t,name:i,maxConcurrent:s,timeoutMs:n,promises:a}){if(null==e)return[];const o=(0,r.compact)(await e);if((0,r.isEmpty)(o))return[];if((s=Math.round(s??(0,w.maxCpus)()))<=1)return M({arr:e,f:t,name:i,timeoutMs:n});const u=a??(o.length<=s?v.PermissivePromises:new v.Promises(i,(()=>s))),d=(0,l.gt0)(n)?e=>(0,c.thenOrTimeoutError)(t(e),n):t,h=await u.enqueueAll(i,o.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return b.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=S,t.thenCollectBatched=async function(e,t,i){const r=[];for(const s of(0,p.batches)((0,f.toA)(await e),t)){const e=await S(s);r.push(...await S(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,o.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=M,t.mapAsyncSerial=async function(e){return(await M(e)).map((e=>e[0]))},t.thenCollectParallel=_,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n}){return(await _({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:s,timeoutMs:n}){return(await _({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:s,timeoutMs:n})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await _({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,n.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,n.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*a.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,s=null;try{r=await((0,h.isFunction)(e)?e():e)}catch(e){s=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(s??r)}catch{}if(null!=s)throw s;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,n.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const s=await t;return null!=s?i(r,s):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const s=await t(r);return null==s?i():s},t.thenMap2Or=async function(e,t,i,r){const s=await e;if(null==s)return r();const n=await t;if(null==n)return r();const a=await i(s,n);return null==a?r():a},t.thenAnd=async function(e,t){return null!=e&&(0,n.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await _({name:e,arr:t,f:i});return(0,s.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),w=i(25764),v=i(38836),b=i(73614);function S(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),s=(0,l.clamp)(10*a.secondMs,a.minuteMs,Math.round(this.times.get(e)?.p98??0)),n=(0,b.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),s);try{const s=await(0,c.tot)(t),n=Date.now()-r;return i?.(s,n),this.push(e,n),s}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(n)}}get entriesBySumDesc(){return(0,n.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(S(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,o.getOrSet)(this.times,S(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(S(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/a.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function M(e,t,i){return P.instance().time(e,t,i)}function _(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new v.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,s.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),w.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=M,t.timeSync=function(e,t){const i=Date.now(),r=t();return _(e,Date.now()-i),r},t.pushTime=_,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>M(e,t)),i)}},42638:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),w=i(54993),v=i(89788),b=i(82647),S=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,w.toS)(e)};class M{constructor(e,t){r.add(this),this.name=e,this.ee=new f.default.EventEmitter,s.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new b.Average,n.set(this,0),a.set(this,[]),o.set(this,[]),this.lastPushedNames=new v.BoundedList(16),c(this,s,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,S.maxCpus)(),d(this,s,"f")?.call(this)??(0,S.maxCpus)()))}end(){return d(this,o,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,a,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,n,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,a,"f").map((e=>e.name)),pendingNames:d(this,o,"f").map((e=>e.d.name)),totalWorkCount:d(this,n,"f")}}enqueue({name:e,l:t,payload:i,serialId:s}){const n=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:s});return this.laterPop(),n}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,a,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,o,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,o,"f").length,e),i=this.runningSerialIds,s=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,a,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,o,"f").length}hasPending(){return d(this,o,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,o,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,o,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=M,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const s=new P.Deferred(e,{payload:i,serialId:r});return d(this,o,"f").push({d:s,l:t}),s},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,n,(t=d(this,n,"f"),++t),"f"),(0,m.remove)(d(this,a,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,a,"f").push(e),e},t.maybeRun=function(e,t){const i=new M(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new M(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},59189:function(e,t){"use strict";var i,r=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},s=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SerialLaterQueue=void 0,t.SerialLaterQueue=class{constructor(){i.set(this,Promise.resolve())}enqueue(e){return s(this,i,r(this,i,"f").catch().then(e),"f")}},i=new WeakMap},4867:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),s=i(34546),n=i(41400),a=i(31586),o=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let o=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>o=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>{if(o)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(o)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>l=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>o.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),s=i(42659),n=i(41400),a=i(32639),o=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,o.clamp)(10*m,l.ShortCommandTimeoutMs,(t??s.minuteMs)/5);await(0,n.delay)(r,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const s=r(i(1708)),n=i(45599),a=i(41400),o=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),w=i(50213),v=i(7282),b=i(88158),S=i(45969),P=i(43334),M=i(28874),_=i(3790);function T(e){return E().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const E=(0,n.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(M.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,b.sortedKeys)((0,l.filter)((0,d.env)(),(e=>T(e))))},(0,a.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,M.allSettings)())t.watchLater(e)}));const D=["HOME","LANG","USER"],k=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],x=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?D:k),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,M.pathWithDefaults)(),e}));function F(e){const t={NODE_ENV:(0,v.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,S.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,M.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,o.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(s.default.env,(e=>T(e)||!(0,_.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=F,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:A({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let C=!1;function A({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const s=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...x(),...i?(0,g.childProcLocale)():{},...F(r),...e??{}});for(const e of(0,M.transientSettings)())e.deleteFromEnv(s);if((0,y.isLogged)("debug")&&!C){C=!0;const e=(0,w.mkLogger)("child.ChildEnv"),t=(0,l.entries)(s).map((([e,t])=>[e,(0,_.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>T(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return s}t.childEnv=A},84777:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const s=r(i(31421)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),w=i(79089),v=i(45255),b=i(22911),S=i(4867),P=i(73614),M=i(70025),_=i(57159),T=i(36868),E=i(66184),D=i(45643),k=i(95402),x=i(9727),F=(0,a.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function C(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function A(e,t=30*u.secondMs){if(null==e)return!1;F().debug("endProcess()",C(e));const i=e.pid;if(null==i||i<=0)return F().warn("endProcess(): asked to end invalid pid",C(e)),!1;if(i===n.default.pid)return F().warn("endProcess(): asked to end MY pid",C(e)),!1;if(i===n.default.ppid)return F().warn("endProcess(): asked to end my parent pid",C(e)),!1;(0,T.closeStreams)(e);{const t=e.kill();F().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,k.killPid)(i).catch((e=>{F().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,D.waitForPidExit)(i,t))return F().debug("endProcess(): exitted",C(e)),!0;{k.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");F().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,k.killPid)(i,!0).catch((e=>{F().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,D.waitForPidExit)(i,5e3)}function I(e,i,r,s=0){const a=new Date,o=[];return(0,w.niceable)(i,r)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,w.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(s,u.secondMs)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&A(e)}),s-250)),o.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,k.addPid)({pid:e.pid,cmd:i,timeoutMs:s,ppid:n.default.pid},a)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>o.forEach(clearTimeout))),e}function O(e,t,i,r){const n=(0,x.spawnOptions)(r);return(0,E.isLogged)("trace",F().context)?F().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:n}):F().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(s.default.execFile(e,t,n),e,t,i)}async function L(e,t,i){const r=i.quiet??!1,s=i.ignoreStderr??!1,n=i.ignoreExitCode??!1,a=O(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{a.disconnect?.()}catch{}return{result:"",pid:a.pid}}const u=a.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new b.Deferred(f);a.on("error",(e=>g.push(e))),a.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),a.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,T.endStream)(a.stdin);const w=new d.Latch;null==a.stdout?w.resolve():(a.stdout.on("error",(e=>g.push(e))),a.stdout.on("data",(e=>m.push(e))),a.stdout.on("end",(()=>w.resolve())));const P=new d.Latch;null==a.stderr||s?P.resolve():(a.stderr?.on("error",(e=>g.push(e))),a.stderr?.on("data",(e=>p.push(e))),a.stderr?.on("end",(()=>P.resolve()))),F().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,S.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),F().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:w.state(),stderr:P.state()}),await(0,S.thenOrTimeoutError)({p:w.promise,timeoutMs:v.ShortCommandTimeoutMs,halt:i.halt}),await(0,S.thenOrTimeoutError)({p:P.promise,timeoutMs:v.ShortCommandTimeoutMs,halt:i.halt});const E=p.join("");(0,l.notBlank)(E)&&g.push(new Error(E)),!r&&(0,o.isNotEmpty)(g)&&F().warn(f+" resulted in errors:",g);const D=i.isIgnorableError??M.isIgnorableError,k=g.filter((e=>!0!==D(e)));if(k.length>0)throw 1===k.length?k[0]:new _.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:k});if(!n&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:E}}catch(e){throw F().error("stdoutResult_() failed",e),await(0,k.killPid)(a.pid,!0),e}}t.endProcess=A,t.ReniceAfterMs=(0,a.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,a.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const n=(0,x.spawnOptions)(r);return F().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(s.default.spawn(e,t,n),e,t,i)},t.execFile=O,t.stdoutResult_=L,t.stdout_=async function(e,t,i){const r=await L(e,t,i);return F().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},86335:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ChildService=t.ChildServiceNames=t.inspectPort=t.pathToService=void 0;const l=i(77598),u=o(i(1708)),c=i(19851),d=i(40958),h=i(22573),f=i(50268),m=i(68708),p=i(5670),g=i(50989),y=i(12168),w=i(59455),v=i(41583),b=i(54993),S=i(80875),P=i(50213),M=i(81168),_=i(27395),T=i(25764),E=i(59958),D=i(70025),k=i(83278),x=i(85021),F=i(29325),C=i(43334),A=i(28874),I=i(84777),O=i(55534),L=i(85100),R=i(34330),N=(0,c.lazy)((()=>(0,P.mkLogger)("child.ChildService")));async function B(e){const t=(0,M.ensureSuffix)(e,".js"),i=k.BaseFile.projectRoot(),r=k.BaseFile.for(u.default.cwd()),s=(0,F.isPacked)()?[i.join("bin",t),C.isElectron?i.join("app.asar",t):void 0]:[r.join("dist","library",t),r.join("dist","core",t),r.join("lib","library",t)];(0,F.isPacked)()||(C.isElectron?(s.push(r.join("dist","app",t)),s.push(i.join("src","desktop","dist","library",t))):s.push(i.join("src","library","dist","library",t)));for(const e of s)if(null!=e&&!0===await e.isNonEmptyFile((0,F.isPacked)()?y.KB:128))return N().tap({msg:"pathToService()",level:"info",result:e,meta:{cmd:t,isPacked:F.isPacked,paths:s.map(b.toS)}});return N().throw("Failed to find path to "+e,{paths:s,fatal:!0})}t.pathToService=B,t.inspectPort=function(e){switch(e){case"web":return 9223;case"sync":return 9224;default:return(0,l.randomInt)(9225,9600)}},t.ChildServiceNames=(0,g.strEnum)(...p.ServiceNames.pick("web","sync"));class j{static async mk_(e,t={}){const i=t.pathToService??await B(e);if((0,h.blank)(i))throw new Error("Failed to find path to "+e);return t.nodeArgs=(0,w.toA)(t.nodeArgs),new j(e,i,t)}constructor(e,t,i){var o,l;r.add(this),this.serviceName=e,this.cmd=t,this.opts=i,this.restartCount=0,this.name="ChildService("+e+")",this.endTimeoutMs=(0,L.serviceExitTimeoutMs)(e),this.logger=(0,P.mkLogger)(this.name);const c=[...(0,w.toA)(i.nodeArgs),t.nativePath];(0,d.isNotEmpty)(i.args)&&c.push(...i.args),this.spawnOpts=(0,m.pick)(this.opts,"argv0","cwd","detached","env","gid","shell","stdio","timeout","uid","windowsHide","windowsVerbatimArguments","forceCLocale","forWorker"),this.spawnOpts.forceCLocale=!1,(l=(o=this.spawnOpts).env??(o.env={}))[E.UV_THREADPOOL_SIZE]??(l[E.UV_THREADPOOL_SIZE]=(0,b.toS)(("web"===e?A.Settings.webUvThreads:A.Settings.syncUvThreads).valueOrDefault)),this.wc=new R.WatchedChild({name:e,childFactory:async()=>(this.restartCount>0&&await(this.opts.onPreRestart?.()),this.restartCount++,(0,I.spawn)(u.default.execPath,c,-1,this.spawnOpts)),endableRank:T.EndableRanks.service,endTimeoutMs:this.endTimeoutMs,onStdout:a(this,r,"m",n).bind(this),onStderr:a(this,r,"m",s).bind(this),onError:this.opts.onError??(e=>!1===(0,D.isIgnorableError)(e)),ignoreStopErrors:!1,exitCommand:O.ServiceExitCommand,...i}),(0,_.addEndable)(T.EndableRanks.first,this)}get startMs(){return this.wc.startTs}runHealthCheck(){return this.wc.writeStdin(x.HealthCheckCommand+"\n")}start(){return this.wc.start()}stop(){return this.wc.stop()}restart(e){return this.wc.restart(e)}get ended(){return this.wc.ended}async end(){return this.wc.ended||this.write(O.ServiceExitCommand),this.wc.end()}get pid(){return this.wc.pid}running(){return this.wc.running()}notRunning(){return this.wc.notRunning()}write(e,t=2){if(t<0)return this.logger.warn("write(): no more retries",{toStdin:e}),!1;try{const t=this.wc.proc;return!0!==t?.stdin?.writable?(this.logger.warn("write(): childProc isn't open, ignoring",{toStdin:e}),!1):t.stdin.write((0,M.ensureSuffix)(e,"\n"))}catch(i){return this.logger.warn("write(): caught "+i),this.wc.onError("onStdout()",(0,v.toErr)(i)),this.write(e,t-1)}}}t.ChildService=j,r=new WeakSet,s=function(e){const t=(0,S.parseJSON)(e);return this.logger.warn(".onStderr()",t??e),!0===t?.fatal},n=function(e){if(!(0,h.blank)(e))try{const t=(0,S.parseJSON)(e);if(null==t)return void this.logger.info(".onStdout(): non-JSON payload",e);if(!0===t?.fatal)this.wc.onError(this.name+".onStdout()",t);else if((0,f.isHealthCheckSummary)(t)){const e="failed"===t.state||"error"===t.level;this.logger.log(e?"error":"info",".onStdout(): health check summary",t),e&&this.wc.onError(this.name+".onStdout()",t,e)}else null!=this.opts.onData&&this.opts.onData(t)}catch(t){this.logger.warn(".onStdout() failed:",{data:e,error:t})}}},3790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),s=i(41400),n=i(19851),a=i(28874);(0,s.later)((()=>a.Settings.sensitiveEnvRegExp.watchLater((()=>o.unset()))));const o=(0,n.lazy)((()=>{try{return new RegExp(a.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${a.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(a.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&o().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||a.Settings.license.includesEnvKey(e)}},55534:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceExitCommand=void 0,t.ServiceExitCommand="--exit"},85100:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serviceExitTimeoutMs=void 0;const r=i(23560),s=i(28874),n=i(45255);t.serviceExitTimeoutMs=function(e){return(0,r.isSyncService)(e)?s.Settings.syncExitTimeoutMs.valueOrDefault:n.ShortCommandTimeoutMs}},34330:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),w=i(54993),v=i(27395),b=i(25764),S=i(99331),P=i(42638),M=i(38835),_=i(8769),T=i(57159),E=i(66003),D=i(50213),k=i(45643),x=i(28874),F=i(84777);t.mkBasicWatchedChild=function(e){return new C({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,F.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class C{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,D.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),s.set(this,!1),this.onError=(e,t,i)=>{const n=new T.WrappedError(e,{cause:t}),a=!1!==n.ignorable;this.logger().log(a?"warn":"error","onError()",n),u(this,s,"f")||a||(this.lastError=n,(0,_.onError)(n),!0!==n.fatal?(i??this.opts.onError(e,n))&&(this.logger().warn("onError requested restart",{src:e,error:n}),u(this,r,"m",o).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:x.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:b.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,v.addEndable)(this.opts.endableRank,this),u(this,r,"m",o).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,s,"f")}async end(){return c(this,s,!0,"f"),u(this,r,"m",n).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",n).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,s,"f")}),!u(this,s,"f")&&!(0,S.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",n).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=C,s=new WeakMap,r=new WeakSet,n=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,s,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",a).call(this,e)},a=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,k.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,F.endProcess)(e,this.endTimeoutMs)},o=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",n).call(this),!this._stopped&&!u(this,s,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,_.onError)("Can't restart "+this.name+", failure rate is too high."+M.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,s,"f")}),this._stopped||u(this,s,"f")||(0,S.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,E.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,w.toS)(e).includes("Error: Cannot find module")&&(0,_.onError)("Failed to start "+this.name+M.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,s,"f")}),(0,S.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",o).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const a=n(i(53916)),o=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,o.toNativePath_)(e);const i=f.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),s=i.sibling(r);if(s.isSelfOrDescendantOf((0,l.examples)()))return a.join("$examples",s.posixPathFrom((0,l.examples)()));const n=(0,d.originalsDir)();if(s.isSelfOrDescendantOf(n))return a.join("$library",s.posixPathFrom(n));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?a.join("$library",s.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const n=i(6858),a=i(1708),o=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),h=i(43334),f=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return s(this,r,"f").push(...e),this}async parse(e=a.argv,t){let i=(0,m.addHelpFooter)(new n.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of s(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":o.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,a.exit)(0)})),i.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=i.opts();for(const e of s(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),s=i(31586),n=i(51926),a=i(17344),o=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,s.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,n.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,a.EditionName)()+" v"+o.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const r=i(38639),s=i(17181),n=i(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,r.mapBoolean)(e.color,(e=>{n.Settings.logColor.envValue=e,(0,s.setupLogFormatter)()}))}}},83210:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDaemon=void 0;const s=r(i(1708)),n=i(22573),a=i(38639);t.isDaemon=function(e){return(0,a.isTrue)(s.default.env.__is_daemon)||(0,a.isTrue)(e?.daemon)||!(0,n.blank)(e?.pidfile)}},53978:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimingArg=void 0;const r=i(28874),s=i(38639);t.TimingArg={beforeParse:e=>e.option("--timing","On exit, emit timing information to stdout."),afterParse:async e=>{(0,s.isTrue)(e.timing)&&(r.Settings.emitTimingsOnExit.value=!0)}}},94361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),s=i(40958),n=i(55835),a=i(31586),o=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,a.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,s.compactBlanks)([c("user id","PUID",(0,o.userids)()),c("group id","PGID",(0,o.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,n.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},43380:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WriteSettingsArg=void 0;const r=i(28874),s=i(2858),n=i(22573),a=i(38639),o=i(46292);t.WriteSettingsArg={beforeParse:e=>e.option("--write-settings","Write (or re-write, if they exist) system and library settings.toml files. See https://phstr.com/settings"),afterParse:async e=>{if((0,a.isTrue)(e.writeSettings)){const e=await(0,s.writeSystemSettings_)();if(null==e?console.info("--write-settings: Failed write system settings: no system configuration directory was found.",{checkedDirectories:(0,o.osConfigDirs)()}):console.info(`--write-settings: Wrote system settings to ${e}`),(0,n.blank)(r.Settings.libraryDir.valueOrDefault))console.error("--write-settings: Failed to write library settings: no PS_LIBRARY_DIR is set.");else{const e=await(0,s.writeLibrarySettings_)();console.info(`--write-settings: Wrote library settings to ${e}`)}}}}},54772:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestLabhashName=t.bestLabName=t.bestRgbName=t.colorToTuple=t.bestRgbTripletName=t.ColorNames=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(31586),o=i(48884),l=i(50213),u=i(81168),c=i(85810),d=i(42079),h=i(91482),f=i(3048),m=i(85409),p=i(16050),g=i(42022),y=i(85042),w=(0,r.lazy)((()=>(0,l.mkLogger)("color.ColorNames")));function v(e){const t=(0,y.normalizeRgbHex)(e.rgb);if(null==t)return void w().warn(`skipping invalid entry (bad rgb): ${e.rgb}`,e);const i=(0,c.rgbhex2Lab)(t);if(null==i)return void w().warn(`skipping invalid entry (failed to convert to L*a*b): ${t}`,e);const r=(0,c.toLabhash)(i,g.ModeBits);return{...e,rgb:t,lab:i,labhash:r,closeLabhashes:[r],closeRgb:[t],name:(0,u.capitalize)(e.name)}}function b(e,i){return null==e?void 0:(0,o.leastBy)(i??(0,t.ColorNames)(),(t=>(0,f.ciede2000_delta_e)(t.lab,e)))}t.ColorNames=(0,r.lazy)((()=>(0,s.compact)([...d.CrayonColors,...d.CrayonSupplements,...h.DarkWikipediaColors,...p.LightWikipediaColors,...m.Greys].map(v)))),t.bestRgbTripletName=function(e,i=(0,t.ColorNames)()){return b((0,c.rgb2lab)(e),i)},t.colorToTuple=v,t.bestRgbName=function(e){return P((0,c.rgbhex2Labhash)(e))},t.bestLabName=b;const S=new Map;function P(e){return(0,a.gte0)(e)?(0,n.getOrSet)(S,e,(()=>{const i=(0,t.ColorNames)().find((t=>t.labhash===e));if(null!=i)return i;const r=(0,c.unlabhash)(e),n=b(r);return null!=r&&null!=n&&((0,s.pushUniq)(n.closeLabhashes,e),(0,s.pushUniq)(n.closeRgb,(0,c.lab2rgbhex)(r))),n})):void 0}t.bestLabhashName=P},85810:(e,t,i)=>{"use strict";e=i.nmd(e),Object.defineProperty(t,"__esModule",{value:!0}),t.hsv2rgb=t.hsl2hsv=t.hsv2hsl=t.hsl2rgb=t.rgb2hsl=t.rgbhex2hsl=t.rgb2hsv=t.closestLab=t.maxLabhash=t.minLabhash=t.unlabhash=t.toLabhash=t.LabBitZip=t.xyz2rgb=t.lab2xyz=t.xyz2lab=t.rgb2xyz=t.clampLab=t.lab2rgb=t.rgb2lab=t.rgb2labArray=t.rgb2labTriplets=t.lab2rgbhex=t.rgbhex2Labhash=t.rgbhex2Lab=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(55835),o=i(31586),l=i(48884),u=i(20014),c=i(75503),d=i(3048),h=i(42022),f=i(85042),m=[[.4124564,.3575761,.1804375],[.2126729,.7151522,.072175],[.0193339,.119192,.9503041]],p=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]];function g(e){return M(v(e))}function y(e){return(0,f.clampRGB)(T(_(e)))}function w(e){return(0,t.LabBitZip)().clampValue(e)}function v(e){const t=(0,f.clampRGB)(e).map((e=>e/255)).map((e=>e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92));return(0,c.matXvec)(m,t)}t.rgbhex2Lab=function(e){return(0,a.map)((0,f.rgbhex2triplet)(e),g)},t.rgbhex2Labhash=function(e,t=h.ModeBits){return(0,a.map)((0,f.rgbhex2triplet)(e),(e=>E(g(e),t)))},t.lab2rgbhex=function(e){return(0,f.rgbTriplet2hex)(y(e))},t.rgb2labTriplets=function(e){return(0,s.stepRange)(0,e.length,3).map((t=>g([e[t],e[t+1],e[t+2]])))},t.rgb2labArray=function(e){const t=[],i=[],r=[];for(let s=0;se>S?Math.pow(e,1/3):(P*e+16)/116));return w([116*i-16,500*(t-i),200*(i-r)])}function _(e){const[t,i,r]=w(e),s=(t+16)/116,n=i/500+s,a=s-r/200,o=n*n*n,l=a*a*a,u=o>S?o:(116*n-16)/P,c=t>8?Math.pow(s,3):t/P,d=l>S?l:(116*a-16)/P;return[u*b.X,c*b.Y,d*b.Z]}function T(e){return(0,c.matXvec)(p,e).map((e=>{const t=e<0?-1:1,i=e*t;return(0,o.round)(255*t*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055))}))}function E(e,i=h.ModeBits){return(0,t.LabBitZip)().zip(e,i)}t.xyz2lab=M,t.lab2xyz=_,t.xyz2rgb=T,t.LabBitZip=(0,r.lazy)((()=>new u.BitZip([{min:0,max:100},{min:-79,max:90},{min:-102,max:89}]))),t.toLabhash=E;const D=new Map;function k(e,i=h.ModeBits){return(0,t.LabBitZip)().unzip(e,i)}function x(e){const[t,i,r]=(0,f.clampRGB)(e),s=Math.max(t,i,r),n=s-Math.min(t,i,r),a=n?s===t?(i-r)/n:s===i?2+(r-t)/n:4+(t-i)/n:0;return[60*(a<0?a+6:a),s?n/s*100:0,s/255*100]}function F(e){return C(x(e))}function C(e){const[t,i,r]=e,s=(200-i)*r/100;return[t,s>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,s/2]}function A(e){const[t,i,r]=e,s=i*(r<50?r:100-r)/100;return[t,s>0?2*s/(r+s)*100:0,r+s]}function I(e){const t=e[0]/360*6,i=e[1]/100,r=e[2]/100,s=Math.floor(t),n=r*(1-i),a=r*(1-(t-s)*i),o=r*(1-(1-t+s)*i),l=s%6;return(0,f.clampRGB)([255*[r,a,n,n,o,r][l],255*[o,r,r,a,n,n][l],255*[n,n,o,r,r,a][l]])}t.unlabhash=function(e,t=h.ModeBits){return t===h.ModeBits?(0,n.getOrSet)(D,e,(()=>k(e,t))):k(e,t)},t.minLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMin(h.ModeBits))),t.maxLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMax(h.ModeBits))),t.closestLab=function(e,t){return(0,l.leastBy)(e,(e=>(0,d.ciede2000_delta_e)(e,t)))},t.rgb2hsv=x,t.rgbhex2hsl=function(e){return F((0,f.rgbhex2triplet)(e))},t.rgb2hsl=F,t.hsl2rgb=function(e){return I(A(e))},t.hsv2hsl=C,t.hsl2hsv=A,t.hsv2rgb=I,i.c[i.s]===e&&console.log(E([0,0,0]))},42079:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CrayonSupplements=t.CrayonColors=void 0,t.CrayonColors=[{name:"Aquamarine",rgb:"#95E0E8"},{name:"Asparagus",rgb:"#7BA05B"},{name:"Blue-green",rgb:"#0095B7"},{name:"Royal blue",rgb:"#273BE2"},{name:"Blush",rgb:"#DB5079"},{name:"Brilliant rose",rgb:"#E667CE"},{name:"Brown",rgb:"#AF593E"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Burnt umber",rgb:"#805533"},{name:"Cadet blue",rgb:"#A9B2C3"},{name:"Canary",rgb:"#FFFF99"},{name:"Carmine",rgb:"#E62E6B"},{name:"Carnation pink",rgb:"#FFA6C9"},{name:"Celestial blue",rgb:"#7070CC"},{name:"Cerise",rgb:"#DA3287"},{name:"Cerulean blue",rgb:"#339ACC"},{name:"Chestnut",rgb:"#B94E48"},{name:"Cobalt blue",rgb:"#8C90C8"},{name:"Copper",rgb:"#DA8A67"},{name:"Cornflower",rgb:"#93CCEA"},{name:"Cotton candy",rgb:"#FFB7D5"},{name:"Denim",rgb:"#1560BD"},{name:"Eggplant",rgb:"#614051"},{name:"Fern",rgb:"#63B76C"},{name:"Fuchsia",rgb:"#C154C1"},{name:"Russet",rgb:"#87421F"},{name:"Green",rgb:"#01A638"},{name:"Green-yellow",rgb:"#F1E788"},{name:"Indigo",rgb:"#4F69C6"},{name:"Jungle green",rgb:"#29AB87"},{name:"Magenta",rgb:"#F653A6"},{name:"Maize",rgb:"#F2C649"},{name:"Maroon",rgb:"#C32148"},{name:"Medium chrome green",rgb:"#6CA67C"},{name:"Medium violet",rgb:"#8F47B3"},{name:"Melon",rgb:"#FEBAAD"},{name:"Middle blue-green",rgb:"#8DD9CC"},{name:"Middle blue-purple",rgb:"#8B72BE"},{name:"Green-yellow",rgb:"#ACBF60"},{name:"Middle purple",rgb:"#D982B5"},{name:"Middle yellow-red",rgb:"#ECAC76"},{name:"Midnight blue",rgb:"#003366"},{name:"Mulberry",rgb:"#C8509B"},{name:"Navy blue",rgb:"#0066CC"},{name:"Olive green",rgb:"#B5B35C"},{name:"Orange",rgb:"#FF8833"},{name:"Orchid",rgb:"#E29CD2"},{name:"Peach",rgb:"#FFCBA4"},{name:"Periwinkle",rgb:"#C3CDE6"},{name:"Pine green",rgb:"#01796F"},{name:"Pink flamingo",rgb:"#FC74FD"},{name:"Plum",rgb:"#8E3179"},{name:"Raw umber",rgb:"#665233"},{name:"Red-orange",rgb:"#FF681F"},{name:"Red",rgb:"#ED0A3F"},{name:"Salmon",rgb:"#FF91A4"},{name:"Vivid scarlet",rgb:"#FD0E35"},{name:"Sea green",rgb:"#93DFB8"},{name:"Sepia",rgb:"#9E5B40"},{name:"Shamrock",rgb:"#33CC99"},{name:"Sky blue",rgb:"#76D7EA"},{name:"Spring green",rgb:"#ECEBBD"},{name:"Sunset orange",rgb:"#FE4C40"},{name:"Tan",rgb:"#FA9D5A"},{name:"Teal blue",rgb:"#008080"},{name:"Thistle",rgb:"#D8BFD8"},{name:"Vivid tangerine",rgb:"#ED3C10"},{name:"Vivid violet",rgb:"#a625c3"},{name:"Wisteria",rgb:"#C9A0DC"},{name:"Yellow-green",rgb:"#C5E17A"},{name:"Yellow-orange",rgb:"#FFAE42"},{name:"Yellow",rgb:"#FBE870"}],t.CrayonSupplements=[{name:"Artichoke",rgb:"#8F9779"},{name:"Aubergine",rgb:"#48213A"},{name:"Brandy rose",rgb:"#B1847F"},{name:"Burgundy",rgb:"#800020"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Crimson red",rgb:"#990000"},{name:"Dark brown",rgb:"#664228"},{name:"Dark coral",rgb:"#CD5B45"},{name:"Dark green",rgb:"#006400"},{name:"Dark raspberry",rgb:"#872657"},{name:"Dark turquoise",rgb:"#610079"},{name:"Deep teal",rgb:"#004040"},{name:"Deep coffee",rgb:"#704241"},{name:"Dusty rasberry",rgb:"#917980"},{name:"Ecru",rgb:"#BCAC7C"},{name:"Evergreen",rgb:"#05472A"},{name:"Eggplant",rgb:"#380835"},{name:"Eggplant purple",rgb:"#430541"},{name:"Emerald green",rgb:"#028F1E"},{name:"Flamingo pink",rgb:"#D67C99"},{name:"Grape",rgb:"#6C3461"},{name:"Kelly green",rgb:"#4CBB17"},{name:"Light forest green",rgb:"#4F9153"},{name:"Medium dark brown",rgb:"#AF7200"},{name:"Medium dark cyan-blue",rgb:"#2D537C"},{name:"Mustard",rgb:"#FAAF18"},{name:"Neon green",rgb:"#39FF14"},{name:"Pear",rgb:"#D1E231"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Phthalo blue",rgb:"#0016C7"},{name:"Pink lace",rgb:"#FFDDF4"},{name:"Raw sienna",rgb:"#884B15"},{name:"Rebecca purple",rgb:"#663399"},{name:"Sap green",rgb:"#536916"},{name:"Blue sapphire",rgb:"#133ECB"},{name:"Sand",rgb:"#B38751"},{name:"Shadow blue",rgb:"#778BA5"},{name:"Shadow green",rgb:"#121E06"},{name:"Swamp green",rgb:"#748500"},{name:"Verdigris",rgb:"#43B3AE"},{name:"Vivid blue-magenta",rgb:"#4817E8"},{name:"Vivid blue-purple",rgb:"#ACACE6"},{name:"Vivid blue",rgb:"#47ABCC"},{name:"Vivid green-yellow",rgb:"#D9E650"},{name:"Vivid green",rgb:"#7BE214"},{name:"Vivid turqoise",rgb:"#06ECD2"},{name:"Vivid lavender",rgb:"#A354FD"},{name:"Vivid mint",rgb:"#00F28C"},{name:"Vivid pink",rgb:"#D752FB"},{name:"Vivid red-purple",rgb:"#C31D7E"},{name:"Vivid red",rgb:"#D92121"},{name:"Vivid yellow-red",rgb:"#F2BA49"},{name:"Vivid yellow",rgb:"#FAFA37"}]},91482:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarkWikipediaColors=void 0,t.DarkWikipediaColors=[{name:"Bistre",rgb:"#3D2B1F"},{name:"Black bean",rgb:"#3D0C02"},{name:"Black pearl",rgb:"#041322"},{name:"Shadow blue",rgb:"#001440"},{name:"Charcoal",rgb:"#36454F"},{name:"Dark indigo",rgb:"#1F0A52"},{name:"Dark magenta",rgb:"#8B008B"},{name:"Dark moss green",rgb:"#4A5D23"},{name:"Dark navy",rgb:"#02075D"},{name:"Dark pastel blue",rgb:"#779ECB"},{name:"Dark purple",rgb:"#580040"},{name:"Dark tan",rgb:"#918151"},{name:"Dark yellow-green",rgb:"#304000"},{name:"Dark yellow",rgb:"#9B870C"},{name:"Deep violet",rgb:"#330066"},{name:"Dusk",rgb:"#4E5481"},{name:"Elderberry",rgb:"#1d1a34"},{name:"Grey jade",rgb:"#757C55"},{name:"Grey magenta",rgb:"#83667F"},{name:"Grey ochre",rgb:"#716659"},{name:"Grey olive",rgb:"#656c5a"},{name:"Grey sage",rgb:"#69724d"},{name:"Taupe",rgb:"#483C32"}]},3048:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciede2000_delta_e=t.diffCIECorr=t.MaxCie=t.MinCie=t.cie94_delta_e=t.cie76_delta_e=void 0;const r=i(31586),s=i(97352);t.cie76_delta_e=function(e,t){return Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2)},t.cie94_delta_e=function(e,t){const[i,r,n]=e,[a,o,l]=t,u=i-a,c=r-o,d=n-l,h=(0,s.sqrt)(r**2+n**2),f=h-(0,s.sqrt)(o**2+l**2),m=(0,s.sqrt)(c**2+d**2-f**2);return(0,s.sqrt)((u/1)**2+(f/(1+.045*h))**2+(m/(1+.015*h))**2)},t.MinCie=2,t.MaxCie=20,t.diffCIECorr=function(e,i){return null==e||null==i?1:(0,r.clamp)(0,t.MaxCie,l(e,i)-t.MinCie)/t.MaxCie};const n=1,a=1,o=1;function l(e,t){const[i,r,l]=e,u=(0,s.sqrt)(r**2+l**2),[c,d,h]=t,f=(u+(0,s.sqrt)(d**2+h**2))/2,m=.5*(1-(0,s.sqrt)(Math.pow(f,7)/(Math.pow(f,7)+Math.pow(25,7)))),p=r*(1+m),g=d*(1+m),y=(0,s.sqrt)(p*p+l*l),w=(0,s.sqrt)(g*g+h*h);let v=Math.abs(p)+Math.abs(l)===0?0:Math.atan2(l,p);v+=2*(v<0?1:0)*Math.PI;let b=Math.abs(g)+Math.abs(h)===0?0:Math.atan2(h,g);b+=2*(b<0?1:0)*Math.PI;const S=c-i,P=w-y;let M=y*w==0?0:b-v;M-=2*(M>Math.PI?1:0)*Math.PI,M+=2*(M<-Math.PI?1:0)*Math.PI;const _=2*(0,s.sqrt)(y*w)*Math.sin(M/2),T=(i+c)/2,E=(y+w)/2;let D;y*w==0?D=v+b:(D=(v+b)/2,D-=(Math.abs(v-b)>Math.PI?1:0)*Math.PI,D+=2*(D<0?1:0)*Math.PI);const k=(T-50)**2,x=1-.17*Math.cos(D-Math.PI/6)+.24*Math.cos(2*D)+.32*Math.cos(3*D+Math.PI/30)-.2*Math.cos(4*D-63*Math.PI/180),F=1+.015*k/(0,s.sqrt)(20+k),C=1+.045*E,A=1+.015*E*x,I=30*Math.PI/180*Math.exp(-1*((180/Math.PI*D-275)/25)**2),O=2*(0,s.sqrt)(Math.pow(E,7)/(Math.pow(E,7)+Math.pow(25,7))),L=-1*Math.sin(2*I)*O;return(0,s.sqrt)(Math.pow(S/(n*F),2)+Math.pow(P/(a*C),2)+Math.pow(_/(o*A),2)+L*P/(a*C)*_/(o*A))}t.ciede2000_delta_e=l},76490:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColor=t.dominantColorsToRgbHex=void 0;const r=i(40958),s=i(31586),n=i(97352),a=i(54772),o=i(85810),l=i(42022),u=i(1971);t.dominantColorsToRgbHex=function(e){return(0,r.compact)(e.map((e=>[e.rgbhex,(0,s.fmtPct)(e.pct)])))};class c{static fromModeData(e){return(0,r.compact)((0,s.times)(u.ModeCount,(t=>c.fromLabhash({labhash:e[`mode${t}`],pct:e[`mode${t}pct`]}))))}static toModeData(e){const t={};return(0,s.times)(u.ModeCount,(i=>{t["mode"+i]=e[i]?.labhash??null,t["mode"+i+"pct"]=e[i]?.pct??null})),t}static fromLabhash({labhash:e,labhashBits:t=l.ModeBits,pct:i}){const r=(0,n.mapGt0)(e,(e=>(0,o.unlabhash)(e,t)));return null!=r&&(0,s.gt0)(i)?new c(r,i,e):void 0}static fromCentroid(e,t){return new c(e.centroid,Math.round(e.size/t*100))}constructor(e,t,i){this.lab=e,this.pct=(0,s.clamp)(0,100,t),this.labhash=i??(0,o.toLabhash)(e,l.ModeBits)}get rgbhex(){return(0,o.lab2rgbhex)(this.lab)}get color(){return(0,a.bestLabhashName)(this.labhash)}toGreyscale(){return new c([this.lab[0],0,0],this.pct)}eql(e){return this.labhash===e.labhash&&(0,s.closeTo)(this.pct,e.pct,5)}}t.DominantColor=c},32848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scaled_delta_e=t.dominantColorCorrelation=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(48884),o=i(31843),l=i(70417),u=i(3048);function c(e,t){const i=(0,s.sum)(e,(e=>(0,n.clamp)(0,100,e.pct))),r=(0,s.sum)(e,(e=>function(e,t){const i=(0,a.leastBy)(t,(t=>(0,u.ciede2000_delta_e)(e.lab,t.lab)));if(null==i)return 0;const r=(0,u.ciede2000_delta_e)(e.lab,i.lab),s=(0,n.clamp)(0,e.pct,(0,l.avg)([e.pct,i.pct])),o=h(r);return(0,n.clamp)(0,100,s)*o}(e,t)));return r/i}t.dominantColorCorrelation=function(e,t){return e=(0,s.compact)(e),t=(0,s.compact)(t),(0,s.isEmpty)(e)||(0,s.isEmpty)(t)?0:(0,l.avg)([c(e,t),c(t,e)])};const d=(0,r.lazy)((()=>[{x:0,y:1},{x:9,y:.8},{x:16,y:.3},{x:20,y:0}]));function h(e){return(0,n.clamp)(0,1,(0,o.lerp2d)(e,...d()))}t.scaled_delta_e=h},40401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeNearCentroids=t.mergeLabhashes=t.dominantColorsFromModes=t.maybeFilterGrey=t.centroidsScore=t.extractDominantColors=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(41400),o=i(98553),l=i(31586),u=i(68708),c=i(48884),d=i(22454),h=i(50213),f=i(56038),m=i(82647),p=i(44983),g=i(70417),y=i(28874),w=i(85810),v=i(3048),b=i(76490),S=i(1971),P=(0,r.lazy)((()=>(0,h.mkLogger)("color.DominantColors")));t.extractDominantColors=function(e,t=S.ModeCount){return(0,f.timeSync)("img.extractDominantColors",(()=>function(e,t=S.ModeCount){const i=Date.now(),r=y.Settings.dominantColorKmeansRuns.valueOrDefault,a=new d.CountingSet;for(const i of E({labs:e,minK:t}))a.incr((0,w.toLabhash)(i));const h=_[y.Settings.dominantColorDeltaE.valueOrDefault]??v.ciede2000_delta_e;const f=a.sortedByKey().valuesToA((e=>(0,w.unlabhash)(e)));let g=(0,l.round)(t+y.Settings.dominantColorMergeThreshold.valueOrDefault);function k(e){const i=t,r=4*t;g=Math.round(Math.max(i,Math.min(r,e)))}const F=f.length<=g?[]:(0,s.compact)(M.slice(0,r).map((e=>{const r=(0,p.kmeans)(f,g,{...T,seed:e}),s=x(r.centroids,f.length);if(s.lengtht&&k(g-1);const n=s.slice(0,t),o=(0,l.sigFigs)(function(e){const t=new m.Average;for(const[i,r]of a.entries()){const s=(0,w.unlabhash)(i),n=(0,c.leastByCtx)(e,(e=>h(e.centroid,s)));null!=n&&(0,l.times)(r,(()=>t.push(n.value)))}return t.p84}(n),2);return{...r,centroids:n,description:{kIn:g,kOut:r.centroids.length,kMerged:s.length,score:o,iterations:r.iterations,uniqColors:a.size,elapsedMs:Date.now()-i},score:o}})));P().trace("extractDominantColors()",{kmeansResults:F.map((e=>(0,u.pick)(e,"description","score")))});const C=(0,c.leastBy)(F,(e=>e.score));if(null==C)return P().info("kmeans failed or was disabled, using dominantColorsFromModes",{runs:r}),D(a,t);const A=(0,o.stringify)({...C?.description,elapsedMs:Date.now()-i}),I=(0,n.sortBy)(C?.centroids,(e=>-e.size)).map((e=>b.DominantColor.fromCentroid(e,f.length)));return P().debug("extractDominantColors() result",{description:A,score:C?.score,totalColors:a.size,totalPixels:f.length,iters:C?.iterations,dominantColors:(0,b.dominantColorsToRgbHex)(I),pixelCount:f.length}),{dominantColors:I,description:A,dominantColorScore:C?.score}}(e,t)))},t.centroidsScore=function(e,t){const i=new m.Average;for(const r of e){const e=(0,c.leastBy)(t,(e=>(0,v.ciede2000_delta_e)(e.centroid,r)));null!=e&&i.push((0,v.ciede2000_delta_e)(e.centroid,r))}return i};const M=[6147062518717073,8176726750919909,5426648081701673,0xce2a345532a3c,0x713f9716da824,6348935463312109,5900323173950995,7358780886584433,5704068712193493,0x51ceeef755892,0xe1557fe94c084,0xd42d7cc96d6b4,0xcbc36dfd76e8a,6738189173486085,8537822851166899,5390086061821835,7712057976331355,0xe9b820db7a8e4,0xb96cebcd6aa40,7036994544380825,5353634786120155,0x99a11417794bc,0xa93d36019aaae,0x74a470887095e,5481147022770415,5347523348244809,0x541d1098e90fc,0xa24d9fb3510c2,0x78aa8e4f692fa,6354921850669697,0x714e1ec1b0a14,8622097963014773,0x6ff5d462d8eb6,0x6782a6b5166b8,7128984079394103,0xe6efba28a3752,5088704486053871,0xc84df40627fae,8018285280412081,4524300326741245,8307147030534695,8135486835878813,7699950603263999,0xb2889592968ae,5903399874280295,7462660765348991,6442509751447017,0xe218d44834db6,7214173935589545,6001326758941961,0x53eb7d39bbb50,0xc3a7ab8add332,0x4e6e81bc443e2,6757635537583321,8501611905255957,0x51840465cc07c,5958243312989149,8928005021308717,5032083390680559,0xb35d70ac51c68,0xfc3826a2dfe7c,0xd155853c61e96,0xda2045ee9be1e,4753952745315177],_={cie76:v.cie76_delta_e,cie94:v.cie94_delta_e,ciede2000:v.ciede2000_delta_e},T=(0,r.lazy)((()=>({maxIterations:50,initialization:"kmeans++",distanceFunction:_[y.Settings.dominantColorDeltaE.valueOrDefault]})));function E({labs:e,minK:t,thresh:i,retries:r=3}){if(r<0)return P().debug("maybeFilterGrey(): exhausted retries: grey filtering disabled."),e;const s=i??y.Settings.dominantColorGreyThreshold.valueOrDefault;if(!(0,l.gt0)(s))return P().debug("maybeFilterGrey(): grey threshold is <= 0: grey filtering disabled."),e;const n=e.filter((e=>Math.abs(e[1])+Math.abs(e[2])>=s));return n.length>=e.length/2?(P().debug("maybeFilterGrey(): sufficient remaining pixels with this threshold.",{greyThreshold:s,minK:t,pixelCount:e.length,filteredCount:n.length}),n):(P().debug("maybeFilterGrey(): insufficient remaining pixels with this threshold. Retrying with smaller threshold.",{greyThreshold:s,minK:t,retries:r,pixelCount:e.length,filteredCount:n.length}),E({labs:e,minK:t,thresh:.75*s,retries:r-1}))}function D(e,t){const i=e.countSum,r=e.size;k(e);const n=e.size,a=(0,s.compact)(e.top(t).map((([e,t])=>b.DominantColor.fromLabhash({labhash:e,pct:Math.round(100*t/i)})))),l=100-(0,g.sumf)(a,(e=>e.pct));return{dominantColors:a,description:"dominantColorsFromModes: "+(0,o.stringify)({uniqColors:r,mergedColors:n,pixelCount:i,pctOmitted:l})}}function k(e,t=y.Settings.dominantColorMergeThreshold.valueOrDefault){const i=[];for(const[r,s]of[...e.entriesByCountDesc()]){const n=(0,w.unlabhash)(r),a=i.find((e=>(0,v.ciede2000_delta_e)(e.lab,n)<=t));null==a?i.push({lab:n,labhash:r}):(e.delete(r),e.incr(a.labhash,s))}return e}function x(e,t,i=y.Settings.dominantColorMergeThreshold.valueOrDefault){if(i<=0)return e;const r=[];for(const t of e){const e=r.find((e=>(0,v.ciede2000_delta_e)(t.centroid,e.centroid)<=i));null==e?r.push(t):e.size+=t.size}const s=t/100;return(0,n.sortBy)(r.filter((e=>e.size>s)),(e=>-e.size))}(0,a.later)((()=>{y.Settings.dominantColorDeltaE.watchLater((()=>{T.unset()}))})),t.maybeFilterGrey=E,t.dominantColorsFromModes=D,t.mergeLabhashes=k,t.mergeNearCentroids=x},85409:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Greys=void 0,t.Greys=[{name:"Black",rgb:"#000000"},{name:"90% black",rgb:"#1b1b1b"},{name:"80% black",rgb:"#303030"},{name:"70% black",rgb:"#474747"},{name:"60% black",rgb:"#5e5e5e"},{name:"Grey",rgb:"#777777"},{name:"60% white",rgb:"#919191"},{name:"70% white",rgb:"#ababab"},{name:"80% white",rgb:"#c6c6c6"},{name:"90% white",rgb:"#e2e2e2"},{name:"White",rgb:"#ffffff"}]},86758:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.labsAreGreyscale=t.isLab=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(82647),o=i(28874),l=i(85810),u=(0,r.lazy)((()=>(0,n.mkLogger)("color.Lab")));t.isLab=function(e){return Array.isArray(e)&&3===e.length&&(0,s.within)(0,100,e[0])&&(0,s.within)(-110,110,e[1])&&(0,s.within)(-110,110,e[2])},t.labsAreGreyscale=function(e){const t=o.Settings.greyscaleColorThreshold.valueOrDefault,i=new a.Average,r=new a.Average;for(const t of e){const e=(0,l.clampLab)(t);i.push(e[1]),r.push(e[2])}const s=(i.stdDev??0)+(r.stdDev??0),n=s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LightWikipediaColors=void 0,t.LightWikipediaColors=[{name:"Beige",rgb:"#F5F5DC"},{name:"Laurel green",rgb:"#A9BA9D"},{name:"Light sage",rgb:"#93A58B"},{name:"Light green-cyan",rgb:"#CFEADE"},{name:"Pastel purple",rgb:"#B39EB5"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Powder blue",rgb:"#B0E0E6"},{name:"Vanilla",rgb:"#F3E5AB"}]},42022:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeBits=void 0,t.ModeBits=12},1971:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeCount=void 0,t.ModeCount=7},85434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitModeData=t.pickModeData=t.ModeDataKeys=t.isModeData=void 0;const r=i(31586),s=i(68708),n=i(50989);t.isModeData=function(e){return(0,r.gt0)(e.mode0)&&(0,r.gt0)(e.mode0pct)},t.ModeDataKeys=(0,n.strEnum)("mode0","mode0pct","mode1","mode1pct","mode2","mode2pct","mode3","mode3pct","mode4","mode4pct","mode5","mode5pct","mode6","mode6pct"),t.pickModeData=function(e){return(0,s.pick)(e,...t.ModeDataKeys.values)},t.omitModeData=function(e){return(0,s.omit)(e,...t.ModeDataKeys.values)}},85042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clampRGB=t.rgbTriplet2hex=t.rgbhex2triplet=t.normalizeRgbHex=void 0;const r=i(31586),s=i(39926),n=i(51926),a=i(54993),o=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;function l(e){return[e[0],e[1],e[2]].map((e=>(0,r.clamp)(0,255,Math.round(e))))}t.normalizeRgbHex=function(e){const t=(0,a.toS)(e).trim();return o.test(t)?(0,n.ensurePrefix)(t,"#").toUpperCase():void 0},t.rgbhex2triplet=function(e){const t=(0,a.toS)(e).trim().match(o);if(null!=t)try{return[t[1],t[2],t[3]].map((e=>(0,r.clamp)(0,255,parseInt(e,16))))}catch{return}},t.rgbTriplet2hex=function(e){return"#"+l(e).map((e=>(0,s.leftPad)(Math.round(e).toString(16).toUpperCase(),2,"0"))).join("")},t.clampRGB=l},76596:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),s=i(19851),n=i(22573),a=i(42659),o=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,s.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,o.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,o.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,a.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const r=i(77988),s=i(19851),n=i(55835),a=i(31586),o=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,s.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),h=["year","month","day","hour","minute","second","millisecond"];class f{static fromISO(e,t){const i=d().exec((0,o.toS)(e).trim()),r=i?.groups;return null==r?void 0:f.for((0,c.parseExifDateTime)(r.start,t),(0,c.parseExifDateTime)(r.end,t),(0,a.toInt)(r.index),(0,a.toInt)(r.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,n.map)(e.start,(e=>r.ExifDateTime.fromJSON(e))),(0,n.map)(e.end,(e=>r.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,r=1){if(null==e||!e.isValid||null==t||!t.isValid)return;r=(0,a.clamp)(1,1e3,(0,a.toInt)(r,{defaultValue:1})),i=(0,a.clamp)(0,r-1,(0,a.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const s=e.toMillis(),n=(t.toMillis()-s)/(r+1)*(i+1),o=e.plus({milliseconds:n});return null==o?void 0:new f(e,o,t,i,r)}constructor(e,t,i,r=0,s=1){this.start=e,this.middle=t,this.end=i,this.index=r,this.splits=s,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=h.map((r=>function({start:e,end:t,middle:i,field:r}){return null!=e[r]&&null!=t[r]?i[r]:void 0}({start:e,middle:t,end:i,field:r})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new f(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=f},79842:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(76790),o=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),h=i(51926),f=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),w=i(21330),v=i(928),b=i(54261),S=i(73389),P=i(51275),M=(0,n.lazy)((()=>(0,f.mkLogger)("date.Dated")));function _(e){return null!=e&&(e instanceof w.FuzzyDate||e instanceof r.ExifDate||e instanceof r.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,S.isDateTime)(e)||(0,m.isDateObject)(e))}function T(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof r.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function E(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof r.ExifDate?e.toMillis(l.dayMs):e instanceof w.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),k(e),((e,t)=>e+t))}function D(e){try{if(null==e||(0,h.isString)(e)||(0,c.isNumber)(e))return;return(0,S.isDateTime)(e)?e:e instanceof r.ExifDateTime||e instanceof w.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?s.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void M().warn("datedToDateTime() failed",{d:e,error:t})}}function k(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,b.hasTime)(e)){if((0,c.gt0)((0,v.getMillisecond)(e)))return 0;if((0,c.gt0)((0,v.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,v.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,v.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,v.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,v.getMonth)(e))?l.monthMs-1:l.yearMs-1}function x(e,t){const i=T(e),r=E(e);if(null!=i&&null!=r)return(0,c.gt0)(t)&&t>r-i?{start:Math.round((i+r)/2-t/2),end:Math.round((i+r)/2+t/2)}:{start:i,end:r}}function F(e,t,i,r){const[s,n]=(0,a.sortBy)([x(e,i),x(t,r)],(e=>e?.start));return null!=s&&null!=n&&null!=s&&null!=n&&(s.start===n.start||s.end>=Math.min(n.start,n.end))}function C(e,t){return(0,o.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??w.FuzzyDate.fromISO(e)}t.isDated=_,t.toDated=function(e){return _(e)?e:void 0},t.mapDated=function(e,t){return _(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=T,t.datedToEndTs=E,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof r.ExifDate?s.DateTime.fromObject(e):D(e)},t.datedToDateTime=D,t.datedToPrecisionMs=k,t.isoToPrecisionMs=function(e){return(0,u.map)(C(e),k)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:r}){if(null==e||null==t)return!1;if(i??(i=k(e)),r??(r=k(t)),F(e,t,i,r))return!0;const s=(0,P.getZoneName)(e),n=(0,P.getZoneName)(t);return null==s&&null!=n&&(e=(0,w.setZone)(e,n)??e),null==n&&null!=s&&(t=(0,w.setZone)(t,s)??t),F(e,t,i,r)},t.isoToDated=C,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof s.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const r=i(31586),s=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,s.isString)(e))return(0,r.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),s=i(31586),n=i(54557),a=i(91655),o=new n.FifoCache(512);function l(e){return(0,s.isNumber)(e)?e:(0,r.blank)(e)?void 0:o.getOrSet(e,(()=>(0,a.parseDuration)(e)))}t.decodeDuration=l;const u=new n.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,a.fmtFullDuration)((0,s.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),s=i(40958),n=i(22573),a=i(42659),o=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,o.isNumber)(e))return;if((0,o.isNumber)(e))return e;if((0,o.isDigits)(e))return(0,o.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,s.compact)(d.map((e=>function(e,t){const i=(0,o.toFloat)(e);if(null!=i){if((0,n.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*a.yearMs;case"weeks":case"week":case"w":return i*a.weekMs;case"days":case"day":case"d":return i*a.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*a.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*a.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*a.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,o.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:a.yearMs,s:"y"},{ms:a.weekMs,s:"w"},{ms:a.dayMs,s:"d"},{ms:a.hourMs,s:"h"},{ms:a.minuteMs,s:"m"},{ms:a.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,o.isNumber)(t))return;if(0===t)return"0";if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},98247:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),h=i(68852),f=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function w(e,t,i){const r=t.exec(e);if(null==r||(0,u.isEmptyObj)(r.groups))return;const{year:s,month:n,day:a,hour:c,minute:h,second:p}=(0,d.mapEntries)(r.groups,((e,t)=>(0,l.toInt)(t)));if(null==s||null==n||null==a)return;if(!f.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==h))return;const g=(0,o.map)((0,l.toFloat)(r.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),w=(0,y.timezoneOffsetFromRegExpMatch)(r);return S({year:s,month:n,day:a,hour:c??0,minute:h??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(w)??i,rawValue:e,tzoffsetMinutes:w})}t.UnsetZone=s.Info.normalizeZone(r.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof r.ExifDate&&t instanceof r.ExifTime))return;const i=new r.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:n}){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromFormat(e,i,{zone:n??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,a.blank)(e)?void 0:r.ExifDateTime.from(e,t)??w(e,b(),t)},t.parseExifDateTimeRe=w;const v=/[-:_\s]?/,b=(0,n.lazy)((()=>(0,h.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,v,p.monthRE,v,p.dayRE,/[T\s]/,p.hourRE,v,p.minuteRE,v,p.secondRE,p.subsecRE,/\s?/,h.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function S(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof r.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=r.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,o.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=S},74417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const r=i(51168),s=i(22573),n=i(42659),a=i(49769),o=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),h=i(66649),f=i(98725),m=i(88600);t.recent=function(e,t=5*n.secondMs){return(0,c.isRecentMs)((0,h.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=r.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,s.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,s.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=r.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,a.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,h.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,o.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*n.secondMs):void 0)??(0,f.parseDateTime)(t)?.toMillis()}},12959:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filestampUTC=t.filestamp=void 0;const r=i(39926);t.filestamp=function(e=new Date){return[e.getFullYear(),(0,r.pad2)(e.getMonth()+1),(0,r.pad2)(e.getDate()),"-",(0,r.pad2)(e.getHours()),(0,r.pad2)(e.getMinutes()),(0,r.pad2)(e.getSeconds())].join("")},t.filestampUTC=function(e=new Date){return[e.getUTCFullYear(),(0,r.pad2)(e.getUTCMonth()+1),(0,r.pad2)(e.getUTCDate()),"-",(0,r.pad2)(e.getUTCHours()),(0,r.pad2)(e.getUTCMinutes()),(0,r.pad2)(e.getUTCSeconds())].join("")}},21330:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const n=i(77988),a=i(51168),o=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(31586),f=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),w=i(79842),v=i(66649),b=i(98247),S=i(98725),P=i(928),M=i(54261),_=i(73389),T=i(89724),E=i(17415),D=i(88600),k=i(51275);function x(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class F{constructor(e,t,i){this.year=e,this.month=t,this.day=i,r.set(this,(0,p.lazy)((()=>(0,D.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(S.ISO_YMD_RE.exec(e)?.groups??S.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,h.toGt0)(e?.year);if(null==e||null==t||tx(e))).join("-")}toLocal(){return(0,T.datedToLocal)(this)}toDateTime(){return a.DateTime.fromObject((0,f.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,f.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,f.pick)(e.plus({month:1}),"year","month"):(0,f.pick)(e.plus({year:1}),"year");return new F(t.year,t.month,t.day)}}function C(e,t){if(e instanceof n.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,M.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,E.zoneToTzOffsetMinutes)((0,v.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(r=>(0,d.map)((0,P.getMonth)(e),(s=>(0,d.map)((0,P.getDay)(e),(n=>(0,d.map)((0,P.getHour)(e),(a=>(0,b.dateObjectToExifDateTime)({year:r,month:s,day:n,hour:a,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=F,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",r=15*(0,h.round)(e/15),s=Math.abs(r),n=Math.floor(s/60),a=Math.floor(Math.abs(s%60));return`${t?"UTC":""}${i}${x(n)}:${x(a)}`},t.toExifDateTime=C,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof n.ExifDateTime?e.tzoffsetMinutes:(0,_.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,M.hasTime)(e)||(i??(0,w.datedToPrecisionMs)(e))>=c.dayMs?O(e):C(e,(0,k.getZoneName)(e))?.toISOString({includeOffset:t})};const A="yyyy:MM:dd HH:mm:ss.SSS",I=A+"ZZ";function O(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>x(e))).join(t)}function L(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new F(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,r]=[e,t].map(v.datedToMillis);return null==i||null==r?void 0:i-r}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,h.isNumber)(t)?a.DateTime.fromMillis(t):(0,w.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,k.hasZone)(t)?I:A):void 0},t.datedToYMD=O,t.toFuzzyDate=L,t.sameDay=function(e,t){return(0,h.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,h.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,r=1){if(null==(0,v.datedToMillis)(e)||null==(0,v.datedToMillis)(t))return;const[s,n]=[e,t].map((e=>(0,v.datedToMillis)(e))).sort(),o=(n-s)/(r+1),l=(0,k.getZoneName)(e),u=l===(0,k.getZoneName)(t)?l:void 0,c=a.DateTime.fromMillis(s+o*i,{zone:u});return[e,t].some((e=>!(0,M.hasTime)(e)))?L(c):c},t.setZone=function(e,t,i){const r={...(0,f.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,k.hasZone)(e)},s=(0,E.normalizeZone)(t);if(null!=e&&null!=s&&(0,M.hasTime)(e))return e instanceof y.DateInterval?e.setZone(s,r):C(e)?.setZone(s,r)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,h.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,w.datedToDateTime)(e);if(null==i)return;const r=(0,k.getZoneName)(e);return null!=r&&"UTC"!==r||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const o=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),h=i(49769),f=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),w=i(68852),v=i(4001),b=i(28874),S=i(24689),P=i(79842),M=i(66649),_=i(98247),T=i(21330),E=i(54261),D=i(73389),k=i(16400),x=i(88600),F=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return F().tap({msg:"extractDateFromPath",result:O.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return O.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return O.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,f.mapNumeric)((0,M.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,w.concatRegexp)([/^/,t.yearRE,w.RegExpOptional.from(/-/,t.monthRE,w.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,w.concatRegexp)([/^/,t.yearishRE,w.RegExpOptional.from(/-/,t.monthishRE,w.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=I({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,D.isDateTime)(i)?i:(0,E.isExifDateTime)(i)?i.toDateTime():void 0};const C=new Map;function A(e,t,i){try{const r=(0,_.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=r)return r;const s=(0,h.getOrSet)(C,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void F().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,_.parseExifDateTimeFormat)({input:s?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void F().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function I({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:r=!0,descPredicate:s=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const n=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(v.stripDSC));if(0!==n.length)for(const{desc:e,f:a}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>S.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,_.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:_.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(b.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(b.Settings.extraDateTimeFormats.values)){const r=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${r})`,f:i=>A(i,r,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>o.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of O.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:r}))if(s(e))for(const e of n){const t=a(e);if(null!=t&&(0,x.isValidDate)(t))return t}}t.parseDated=I;class O{constructor(e={}){r.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&b.Settings.fuzzyDateParsing.watchLater((()=>a(this,r,"m",n).call(this))),null==e.fuzzyYearParsing&&b.Settings.fuzzyYearParsing.watchLater((()=>a(this,r,"m",n).call(this))),a(this,r,"m",n).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??b.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??b.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!b.Settings.usePathsToInferDates.valueOrDefault)return;T.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=I({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=O,r=new WeakSet,s=function(e){const t=new L(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},n=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new w.RegExpEscaped("(?"+(0,k.monthNames)().map(w.escapeRegExp).join("|")+")");a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE]),a(this,r,"m",s).call(this,[e,t.seps,t.yearRE]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,e]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},O.instance=(0,u.lazy)((()=>new O));class L{constructor(e){this.regex=e instanceof RegExp?e:(0,w.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return T.FuzzyDate.for({year:(0,f.toInt)(t.year),month:(0,f.toInt)(t.month)??(0,k.monthName2index)(t.monthname),day:(0,f.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const r=i(55835),s=i(31586),n=i(54261);function a(e){return e instanceof Date?e.getMinutes():e?.minute}function o(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=a,t.getSecond=o,t.getMillisecond=l,t.getCentisecond=function(e){return(0,r.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,n.hasTime)(e)&&((0,s.gt0)(a(e))||(0,s.gt0)(o(e))||(0,s.gt0)(l(e)))},t.getSecMs=function(e){return(0,r.map)(o(e),(t=>{const i=l(e)??0;let r=(t+i/1e3).toString();for(t<10&&(r="0"+r),0===i&&(r+=".");r.length<6;)r+="0";return r}))}},54261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const r=i(77988),s=i(31586),n=i(68708);t.hasTime=function(e){if(!(0,n.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,s.gt0)(t.hour)||(0,s.gt0)(t.minute)||(0,s.gt0)(t.second)||(0,s.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof r.ExifDateTime}},73389:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const r=i(51168);t.isDateTime=function(e){return r.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const r=i(51168),s=i(19851),n=i(42659),a=i(55835),o=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),h=i(74417),f=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,s.lazy)((()=>w(l.Settings.datesBeforeAreEstimated.valueOrDefault)??w(l.Settings.datesBeforeAreEstimated.defaultValue)));function w(e){return(0,a.map)((0,c.isoToDated)(e),v)}function v(e){return(0,o.isNumber)(e)?_(e):100*b(e)+((0,m.getCentisecond)(e)??0)}function b(e){if((0,o.isNumber)(e))return Math.floor(_(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function S(e,t){if(null==e||e<0)return;let i=e;const r=()=>{const e=i%100;return i=Math.floor(i/100),e},s=10*r(),n=r(),a=r(),l=(0,o.toGt0)(r()),u=(0,o.toGt0)(r()),c=(0,o.toGt0)(r());return{year:i,month:c,day:u,hour:l,minute:a,second:n,millisecond:s,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=S(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):f.FuzzyDate.for(i)}function M(e,t){return _(Date.now()-e,t)}function _(e,t){return v(r.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const r=i(19851),s=i(76790),n=i(31586),a=i(9092),o=(0,r.lazy)((()=>{const e=new a.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const r=new Intl.DateTimeFormat(t,{month:i});(0,n.times)(12,(s=>{const n=r.format(new Date(2017,s));e.set(n,s+1),"short"===i&&"en-US"===t&&e.set(n+".",s+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:o().get(e)},t.monthNames=function(){return(0,s.sort)([...o().keys()])}},42499:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLuxon=void 0;const r=i(51168),s=i(19851),n=i(19043),a=i(28874);t.setupLuxon=(0,s.lazy)((async()=>{r.Settings.throwOnInvalid=!1,a.Settings.twoDigitCutoffYear.watch((e=>r.Settings.twoDigitCutoffYear=e)),r.Settings.defaultLocale=await(0,n.locale)()}))},17415:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),h=i(54993),f=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,n.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const r=(0,f.leastBy)(g(),(t=>Math.abs(t-e)));return null!=r&&Math.abs(r-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(r)}t.isUTCZone=function(e){return b(e)||0===S(e)?.offset(Date.now())},t.normalizeZone=S,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,o.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=M,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:M(i)};const _=/\b(?Z|UTC|GMT)\b/,T=/(?[-±+−])/,E=/[-−]/,D=/(?[01]\d)/,k=/(?[01]?\d)/,x=/(?::(?\d\d))/;function F(e){return b(e)?0:C((0,t.TimezoneOffsetRE)().exec(e))}function C(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,a.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=E.test((0,h.toS)(e.groups.tzSign))?-1:1,r=(0,l.toInt)(e.groups.tzMinutes)??0,s=null==t?void 0:i*(60*t+r);return w(s)?s:void 0}t.TimezoneOffsetRE=(0,n.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),_,new m.RegExpEscaped("|"),T,D,m.RegExpOptional.from(x),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=F,t.timezoneOffsetFromRegExpMatch=C;const A=/\b(?(?:Etc\/)?GMT)\b/,I=(0,n.lazy)((()=>(0,m.concatRegexp)([A,T,k,m.RegExpOptional.from(x)])));function O(e){return C(I().exec(e))}t.ianaZoneToOffsetMinutes=O,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,a.blank)(e))return;const i=O(e)??F(e);if(null!=i)return M(i);if(null!=t){const i=S(e);if(null!=i)return M(i.offset(t))}}},88600:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),h=i(28874),f=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),w=(0,s.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),v=(0,s.lazy)((()=>(0,n.compact)(h.Settings.badDates.values.map((e=>(0,f.isoToDated)(e)))))),b=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,p.datedToISO)(e)))))),S=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,y.datedToLocal)(e)))))),P=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,m.datedToMillis)(e))))));function M(e){if(null==e)return!1;const t=T(e);return w().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return M(e)?e:void 0},t.isValidDate=M;const _=String(new Date("bad"));function T(e){try{if(!(0,f.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===_)return _;const t=(0,n.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const s=[];if((0,l.isNumber)(e)||s.push("year is not a number"),(0,l.lt)(e,h.Settings.minValidYear.valueOrDefault)&&s.push("year is less than "+h.Settings.minValidYear.key),(0,u.gt)(e,E())&&s.push("year is in the future"),null==t&&null!=i&&s.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const n=r.DateTime.fromObject({year:e,month:t,day:i});n.isValid||s.push(n.invalidExplanation??"not valid")}return(0,n.compact)(s)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=h.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const r=(0,m.datedToMillis)(e);(0,u.gt)(r,Date.now()+i)&&t.push("date is too far in the future: see "+h.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):S().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):b().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,a.toNotBlank)((0,n.uniq)((0,n.compactBlanks)(t)).join("; "))}catch(t){return w().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=T;const E=(0,s.lazy)((()=>r.DateTime.now().plus({milliseconds:h.Settings.maxValidFutureMs.valueOrDefault}).year),o.dayMs);t.mapValidDate=function(e,t){return M(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==T({year:e,month:t,day:i})}},51275:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const r=i(77988),s=i(31586),n=i(24689),a=i(73389);t.hasZone=function(e){return null!=e&&!(0,s.isNumber)(e)&&(e instanceof n.DateInterval||e instanceof r.ExifDateTime?e.hasZone:!!(0,a.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==r.UnsetZoneName&&e.zone.offset(Date.now())!==r.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,a.isDateTime)(e)?e.zoneName===r.UnsetZoneName?void 0:e.zone?.name:e instanceof r.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},82261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cacheDbDir_=void 0;const r=i(51926),s=i(49776),n=i(38835),a=i(95696),o=i(70854),l=i(73428),u=i(28874),c=i(15056);t.cacheDbDir_=async function(e=u.Settings.libraryDir.valueOrDefault,t=c.Schemas.models){const i=(0,o.libraryUidStore)(e);if(null==i)throw new Error("Library directory is not set"+n.NoLibraryErrorFlag);const d=await i.readUid_(),h=a.PosixFile.for((0,s.cacheDir_)()).join(t+"-live-db",d);await h.mkdirp_();const f=h.join("README.txt");return await(0,l.writeTextfile_)(f.nativePath,...(0,r.wrap)(["This folder is used by PhotoStructure for your library stored in",e,"You will corrupt your library if you remove this directory while PhotoStructure is running.","See https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837 for details."].join("\n\n"))),h}},92407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLiveDbDir_=t.cacheDbFile_=void 0;const r=i(19851),s=i(87290),n=i(50213),a=i(28874),o=i(82261),l=i(15056),u=i(7311),c=i(44955),d=(0,r.lazy)((()=>(0,n.mkLogger)("db.CheckLocalDbReplica")));async function h({libraryDir:e=a.Settings.libraryDir.valueOrDefault,schema:t=l.Schemas.models}={}){return(await(0,o.cacheDbDir_)(e,t)).join(u.SqliteBase)}t.cacheDbFile_=h,t.getLiveDbDir_=async function(e=a.Settings.libraryDir.valueOrDefault){if(!a.Settings.forceLocalDbReplica.valueOrDefault){const t=(0,l.pathToDb)(await(0,s.setupLibraryDataDir_)(e),l.Schemas.models);try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!1}}catch(e){d().info("SQLite cannot directly write to the library: trying to use a local db replica.",{libraryDb:t,error:e})}}const t=await h({libraryDir:e,schema:l.Schemas.models});try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!0}}catch(e){return d().throw("SQLite cannot directly write to the library or the cacheDir.",{cacheDbFile:t,error:e})}}},5531:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},55332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupCold_=void 0;const r=i(19851),s=i(50213),n=i(76187),a=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbBackupCold")));t.dbBackupCold_=async function(e,t){await t.mkdirp_();const i=[];try{for(const r of(0,n.sqliteFiles)(e)){const e=t.join(r.base).wip();i.push(e),await r.copyFile_(e)}return a().tap({msg:"completed",level:"info",result:await Promise.all(i.map((e=>e.unwip_()))),meta:{srcDbFile:e,destDir:t}})}catch(e){throw await Promise.all(i.map((e=>e.unlink()))),e}}},91872:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleDbRetries_=void 0;const r=i(50213),s=i(70025),n=i(28874),a=i(45599),o=i(41400),l=i(30976),u=i(56038),c=(0,a.defer)((()=>(0,r.mkLogger)("db.DbRetries")));t.handleDbRetries_=function(e,t,i,r){const a=Date.now();let d=0;const h=a+n.Settings.maxBusyDbMs.valueOrDefault;return(0,u.time)(e,(async()=>{for(;Date.now()=h)throw c().error(e+": Caught db error. Not retrying.",{error:t}),t;{const i=(0,l.randomInt)(500,1500)*++d;c().warn(e+": Caught db error. Retrying in "+i+"ms.",{name:e,error:t}),r?.(),await(0,o.delay)(i)}}return t().close(),c().throw(e+": handleDbRetries(): timeout after "+n.Settings.maxBusyDbMs.valueOrDefault+"ms")}))}},12943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toDbValued=t.isDbValued=t.isDbValue=void 0;const r=i(79842),s=i(66649),n=i(40958),a=i(68708);function o(e){return null===e||(0,n.includes)(["number","string"],typeof e)}t.isDbValue=o,t.isDbValued=function e(t){return null!=t&&Array.isArray(t)?t.every(e):(0,a.entries)(t).every((([,e])=>o(e)))},t.toDbValued=function(e){return(0,a.mapFields)(e,((e,t)=>{if(!e.startsWith("$"))return"boolean"==typeof t?[e,t?1:0]:o(t)?[e,t]:(0,r.isDated)(t)?[e,(0,s.datedToMillis)(t)]:void 0}))}},65753:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maxBatchPluckSize=void 0;const r=i(19851),s=i(7282),n=i(28874);t.maxBatchPluckSize=(0,r.lazy)((()=>Math.round(n.Settings.dbBatchSelectSize.valueOrDefault*((0,s.isTest)()?.25:5))))},80632:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pageSizeBytes=t.mkdb_=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(54993),u=i(50213),c=i(23560),d=i(65211),h=i(29882),f=i(53265),m=i(66430),p=i(66184),g=i(28874),y=i(15674),w=i(87550);function v(){const e=g.Settings.dbPageSizeBytes.valueOrDefault;return Math.pow(2,(0,a.clamp)(1,28,Math.round(Math.log2(e))))}t.mkdb_=function({nativePath:e,timeoutMs:t=g.Settings.dbBusyTimeoutMs.valueOrDefault,logSql:i=g.Settings.logSql.valueOrDefault}){e=(0,f.resolve)(e),(0,h.mkdirpSync_)((0,r.dirname)(e));const b=(0,h.posixPathFromGrandparent)(e),S=(0,m.nativePathSizeSync)(e),P=(0,u.mkLogger)("db.mkdb("+b+")");if(null!=S){const E=Math.round(S/o.MiB),D=Math.ceil(1.5*E);D>g.Settings.dbCacheSizeMb.valueOrDefault&&(P.info("Dynamically setting dbCacheSize to "+g.Settings.dbCacheSizeMb.value,{db:e,dbFileSizeMb:E}),g.Settings.dbCacheSizeMb.envValue=D);const k=Math.round(1.5*E);k>g.Settings.maxMemoryMb.valueOrDefault&&(P.warn("Large database: setting maxMemoryDb to "+k+"MB",{dbFileSizeMb:E,"Settings.maxMemoryMb":g.Settings.maxMemoryMb.valueOrDefault}),g.Settings.maxMemoryMb.envValue=k)}P.info("Opening "+e+"...");const M={fileMustExist:!1,readonly:!1};if((0,a.gt0)(t)&&(M.timeout=Math.ceil(t)),i){const x=(0,u.mkLogger)("SQLite("+b+")"),F=(0,p.defaultLogLevel)();function C(e,...t){var i;(0,n.blank)(e)||x.log(F,(i=e,(0,l.toS)(i).replace(/\s{2,}/g," ")),{args:t})}M.verbose=C}const _=new w(e,M);P.info("Open. Setting PRAGMAs...");for(const A of(0,s.compact)(['encoding = "UTF-8"',"threads = "+(0,y.maxCpus)(),"foreign_keys = ON","page_size = "+v(),"trusted_schema = 0","cache_size = -"+Math.round(g.Settings.dbCacheSizeMb.valueOrDefault*o.MiB/1024),"locking_mode = NORMAL","journal_mode = WAL",(0,a.gt0)(g.Settings.dbBusyTimeoutMs.valueOrDefault)?"busy_timeout = "+g.Settings.dbBusyTimeoutMs.valueOrDefault:null,"temp_store = MEMORY","synchronous = "+g.Settings.dbSynchronousMode.valueOrDefault,"case_sensitive_like = 0","wal_autocheckpoint = "+((0,c.isDbJanitorService)()?(0,l.toS)(g.Settings.dbWalAutoCheckpoint.valueOrDefault):"0"),"auto_vacuum = "+g.Settings.dbAutoVacuumMode.valueOrDefault]))P.tapThunk({msg:"PRAGMA "+A,result:()=>_.pragma(A)});const T=_;return T.__uid=(0,d.uid)(),T},t.pageSizeBytes=v},99315:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},95704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withIdBatches=void 0;const r=i(40958),s=i(31586),n=i(59455),a=i(65753),o=i(51040);t.withIdBatches=async function(e){const t=(0,s.toGt0)(e.batchSize)??(0,a.maxBatchPluckSize)(),i=(0,o.dbValueToEscapedString)(e.primaryKeyColumnName),l=(0,r.compactBlanks)([i+" > :min",...(0,n.toA)(e.whereClauses)]).join(" AND "),u=e.db.prepare((0,r.compactBlanks)(["SELECT "+i,"FROM "+(0,o.dbValueToEscapedString)(e.tableName),"WHERE "+l,"ORDER BY "+i,"LIMIT :limit"]).join(" "));let c=-1;for(;;){const i=u.pluck().all({min:c,limit:t});if(0===i.length)return;await e.fn(i),c=(0,r.last)(i)}}},76187:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSqliteFile=t.sqliteSizeBytes=t.sqliteFiles=void 0;const r=i(17217),s=i(87391),n=i(7311);t.sqliteFiles=function(e){return[e,...s.SQLiteSuffixes.map((t=>e.sibling(e.base+t)))].filter((e=>e.existsSync({refresh:!0})))},t.sqliteSizeBytes=async function(e){return(await e.size({refresh:!0})??0)+(await e.sibling(e.base+"-wal").size({refresh:!0})??0)};const a=[n.SqliteExt,...[...s.SQLiteSuffixes,"-shm"].map((e=>n.SqliteExt+e))];t.isSqliteFile=function(e){const t=(0,r.basename)(e);for(const e of a)if(t.endsWith(e))return!0;return!1}},51040:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitBatchSql=t.dbValueToEscapedString=void 0;const r=i(40958),s=i(31586),n=i(54993),a=/^\w+$/;t.dbValueToEscapedString=function(e){if((0,s.isNumber)(e))return e.toString();const t=(0,n.toS)(e);return a.test(t)?t:`'${t.replace(/'/g,"''")}'`};const o=/--.+$/gm,l=/\s+/g;t.splitBatchSql=function(e){const t=(0,r.compactBlanks)((0,n.toS)(e).split(/;/).map((e=>e.replace(o,"").replace(l," ").trim()))),i=[];let s;for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertDirSQLiteReadWrite_=t.isDirSQLiteReadWrite=t.firstDirSQLiteReadWrite=void 0;const r=i(19851),s=i(50357),n=i(30976),a=i(50213),o=i(95696),l=i(80632),u=i(76187),c=(0,r.lazy)((()=>(0,a.mkLogger)("db.SQLiteReadWrite")));async function d(e){try{return await h(e),c().info("isDirSQLiteReadWrite(): true",{dirNativePath:e}),!0}catch(t){return c().warn("isDirSQLiteReadWrite(): false",{dirNativePath:e,error:t}),!1}}async function h(e){const t=o.PosixFile.for(e),i=(0,n.randomChars)(8),r=t.child(".test-"+i+".sqlite");let a=null;try{await t.mkdirp_(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3}),a.exec("CREATE TABLE t (s VARCHAR(16) NOT NULL)"),a.exec(`INSERT INTO t (s) VALUES ('${i}')`);{const e=a.prepare("SELECT s FROM t").all();(0,s.eql)(e,[{s:i}])||c().throw("unexpected rows",{rows:e})}a.exec("VACUUM"),a.close(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3});{const e=(0,n.randomChars)(8);a.exec(`INSERT INTO t (s) VALUES ('${e}')`);const t=a.prepare("SELECT s FROM t ORDER BY s").pluck().all();(0,s.eql)(t,[i,e].sort())||c().throw("unexpected rows",{rows:t})}}finally{try{a?.close()}catch{}await Promise.all((0,u.sqliteFiles)(r).map((e=>e.rm())))}}t.firstDirSQLiteReadWrite=async function(...e){for(const t of e)if(null!=t&&await d(t))return t},t.isDirSQLiteReadWrite=d,t.assertDirSQLiteReadWrite_=h},87391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SQLiteSuffixes=void 0,t.SQLiteSuffixes=["-wal","-journal"]},15056:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),s=i(7311);function n(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=n,t.pathToDb=function(e,t){return n(e,t).join(s.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const a=n(i(76760)),o=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),w=i(70698),v=i(64680),b=i(29882),S=i(45969),P=i(43334),M=i(28874),_=i(41692),T=i(32774),E=i(80612),D=i(32551),k=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function x(){if((0,S.isDocker)())return[{dir:"/tmp/.photostructure-cache"+k(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,a.join)(i,".photostructure-cache"+k()),preexistingDir:i});return e}}function F(){if((0,S.isDocker)())return(0,o.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,a.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:T.DefaultDockerLibraryDir+"/.photostructure/cache"+k(),preexistingDir:T.DefaultDockerLibraryDir},...x()]);const e=(0,o.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),a.default.resolve((0,D.homeDir)(),"AppData","Local")]:P.isMac?[a.default.resolve((0,D.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,a.join)((0,D.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,a.join)(e,t),preexistingDir:e})));return i.push(...x()),i}t.tmpCacheDirs=x,t.tmpDirs=function(){return(0,E.filterDirs)({dirs:x(),desc:"tmp"})},t.cacheDirs=F,t.defaultCacheDir=(0,d.lazy)((()=>(0,E.firstDir)({dirs:F(),desc:"cache"})));const C=(0,d.lazy)((()=>{(0,_.setSettingsDefaults)(),M.Settings.cacheDir.watchLater(A)}));function A(){M.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{C();const e=M.Settings.cacheDir.valueOrDefault;try{return(0,b.mkdirpSync_)(e),(0,w.writeCachedirTag_)(e).then((()=>(0,v.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=A},46292:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),s=i(45969),n=i(41692),a=i(32774),o=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,n.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,s.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,o.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:a.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:a.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,s.isDocker)()?c:(0,o.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),s=i(45969),n=i(32774);t.defaultLibraryDir=function(){return(0,s.isDocker)()?n.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,s.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const s=r(i(76760)),n=i(40958),a=i(72993),o=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),s.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(s.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,o.env)().XDG_DATA_HOME,(0,o.env)().XDG_CONFIG_HOME,s.default.resolve((0,d.homeDir)(),".config")),(0,n.compactBlanks)(e).map((e=>({dir:s.default.join(e,(0,a.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),s=i(96706),n=i(29882);t.envConfigDir=function(){const e=(0,s.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,n.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),s=i(40958),n=i(22573),a=i(66430);function o({dirs:e,desc:t}){for(const{dir:i,preexistingDir:o}of(0,s.compact)(e))if(!(0,n.blank)(i)){if((0,a.isReadWriteableDirectorySync)(i))return i;if((0,n.blank)(o)||(0,a.isReadWriteableDirectorySync)(o))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=o,t.filterDirs=function({dirs:e,desc:t}){return(0,s.compact)(e.map((e=>o({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),s=i(76760),n=i(1708),a=i(19851),o=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,a.lazy)((()=>{const e=[];u.isWin?e.push(n.env.USERPROFILE):e.push(n.env.HOME);for(const t of(0,o.compactBlanks)(e)){const e=(0,s.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),s=i(49776),n=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[n.libraryDataDir,n.libraryPreviewsDir,s.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},9595:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),s=i(54993),n=i(29882),a=i(28874);function o(e){return(0,r.toNotBlank)((0,s.toS)(e))??a.Settings.libraryDir.valueOrDefault}t.libraryDir=o,t.originalsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,n.resolveMaybe)(o(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),s=i(55835),n=i(37805),a=i(15056),o=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${n.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function w(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+o.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function v(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function b(e){return y(v(e),!1)}function S(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(S(e))}function M(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function _(e){return y(M(e))}async function T(e){return y((0,s.map)(g(e),(e=>(0,a.pathToDbDir)(e,a.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await w(t);return(0,r.uniq)([t,i,await b(t),await P(t),await _(t),await T(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=w,t.libraryOriginalsDirPosixFile=v,t.setupLibraryOriginalsDir_=b,t.libraryPreviewsDirPosixFile=S,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=M,t.setupLibrarySyncReportsDir_=_,t.setupLibraryDbDir_=T},46296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),w=i(80612),v=i(32551);function b(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:s.default.resolve((0,v.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,v.homeDir)()}]:(0,a.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>s.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function S(){return(0,w.firstDir)({dirs:b(),desc:"logs"})}t.defaultLogDirs=b,t.defaultLogDir_=S,t.logDir=(0,n.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,o.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,o.notBlank)(i)?i:S()}catch(e){return console.error("defaultLogDir_() failed",e),s.default.resolve((0,v.homeDir)(),"logs")}}))},55939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(44198),o=i(43334),l=i(24399),u=i(32551);async function c(){return o.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,s.lazy)((async()=>{if(o.isWin){const e=await c();if((0,n.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,s.lazy)((()=>(0,a.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),s=i(7282),n=i(29325),a=i(44198);t.getDevEnvFlag=function(e){return!(0,s.isProd)()&&!(0,n.isPacked)()&&((0,r.toBoolean)((0,a.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,a.env)()[e]=String(t)}},34580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),s=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,s.env)().DO_NOT_TRACK)}},44198:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const s=r(i(73024)),n=i(76760),a=r(i(1708)),o=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),w=i(6012),v=i(96706);t.env=(0,o.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>a.default.env[e])).join(n.delimiter).split(n.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===a.default.env.PS_LICENSE||e.push((0,n.join)((0,f.homeDir)(),".psenv"));const t=(0,v.SensitiveEnvRE)(),i={...a.default.env};for(const r of e)try{const e=(0,d.debom)(s.default.readFileSync((0,p.resolve)(r))),n=(0,w.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(n))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),s=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let n;for(const a of(0,s.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(n=e.exec(a));){if(null==n.groups)continue;const{key:e,val:s}=n.groups;if((0,r.blank)(e)||null==s)continue;const a=s.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=a}}return i}},96706:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const s=r(i(1708)),n=i(19851),a=i(22573),o=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,n.lazy)((()=>(0,a.firstNotBlank)(s.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,s.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,n.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,n.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,o.isTrue)(g(e))}},98314:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),s=i(19851),n=i(40958),a=i(22573),o=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),w=i(70025),v=i(57159);function b(...e){if((0,n.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(o.errorName),...e.map(o.errorCode),...(0,n.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(o.ErrorDelimiter)))];return(0,n.uniqSubstrings)(S((0,l.flatten)(i)))}function S(e){return(0,n.compact)(e).filter((e=>!o.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(a.notBlank)}function P(e,t){const i=(0,n.uniqSubstrings)(S(e)),r=t?.maxLen??400,s=t?.trailingChars??64,a=(0,y.sortErrorFlags)([...t?.flags??[],...(0,w.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,w.stripErrorFlags)(i.join(o.ErrorDelimiter)),r-a.length,s)+a.sort().join("")}function M(e,t){return e instanceof v.WrappedError?e.toString():(0,a.blank)(e)?"":P(b(e),t)}t.StartTs=Date.now(),t.logger=(0,s.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(M(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,a.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,a.notBlank)(i))return i}},t.splitErrorMessage=b,t.normalizeErrorMessages=S,t.joinErrorMessages=P,t.errorToS=M,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,a.blank)(e)&&(e=t.MissingError),M(e,{maxLen:i})+" at "+(0,o.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),s=i(26905),n=i(55835),a=i(54993),o=i(81168);t.describeError=function(e){const t=(0,o.stripSuffix)((0,a.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,n.map)((0,s.errorErrno)(i),(e=>t.push(u.get(e)))),(0,n.map)((0,s.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),s=i(76790),n=i(50989),a=i(68852);t.ErrorFlags=(0,n.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,s.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(a.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},68301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorStore=t.ExtraEventsForPlease=void 0;const r=i(19851),s=i(42659),n=i(75240),a=i(55835),o=i(31586),l=i(68708),u=i(59455),c=i(54993),d=i(50213),h=i(45255),f=i(37628),m=i(99331),p=i(46292),g=i(38835),y=i(32144),w=i(29882),v=i(95696),b=i(55222),S=i(28874),P=(0,r.lazy)((()=>(0,d.mkLogger)("error.EventStore")));function M(e){return(0,l.omit)(e,"breadcrumbs")}t.ExtraEventsForPlease=7;class _{constructor(e){this.root=e}datedRoot(e=new Date){return this.root.join((0,c.toS)(e.getFullYear()),(0,c.toS)(e.getMonth()+1))}rmrf(){return this.root.rmrf()}msg2file(e){return this.datedRoot(new Date(e.timestamp*s.secondMs)).join((0,f.shortStringSha)(e.message,8,b.GeoRadix)+".json")}async eventsFrom(e=new Date,t=s.dayMs){const i=e.getTime(),r=i-t,a=i+t;return P().tap({msg:"eventsFrom()",result:(0,u.toA)(await this.datedRoot(e).clear().childFiles((async e=>P().tap({msg:"eventsFrom().childFiles() accept "+e.base,result:(0,y.isJsonExt)(e)&&!(0,w.isHiddenBasename)(e.base)&&(0,o.within)(r,a,e.mtimeMs())})))),meta:{when:e,deltaMs:(0,n.fmtDuration)(t)}})}async eventCount(e=new Date){return(await this.eventsFrom(e)).length}async eventQuotaExceeded(e){const i=(0,c.toS)(e).includes(g.PleaseSendErrorFlag)||(0,c.toS)(e.message).includes(g.PleaseSendErrorFlag),r=await this.eventCount(),s=S.Settings.maxErrorsPerDay.valueOrDefault+(i?t.ExtraEventsForPlease:0);return P().tap({msg:"eventQuotaExceeded()",result:r>=s,meta:{event:M(e),recentEventCount:r,maxErrorsPerDay:s,pleaseSend:i}})}async maybeSendEvent(e){if(e.timestamp=Math.floor(e.timestamp),(0,m.ending)())P().error("maybeSendEvent(): REJECT: we're ending.",{event:M(e)});else if(await this.eventQuotaExceeded(e))P().error("maybeSendEvent(): REJECT: too many recent events.",{event:M(e)});else try{const t=await this.writeEvent_(e);return P().tap({msg:"maybeSendEvent(): "+t==null?"REJECT: previously sent this event already this month":"ACCEPT",result:null!=t?e:void 0,meta:{eventFile:t}})}catch(e){return void P().error("maybeSendEvent(): REJECT: failed to write event.",e)}}writeEvent_(e){return this.msg2file(e).applyIfEmpty_({fn_:t=>t.writeJson_(e),minSizeBytes:3,returnUndefinedIfNotEmpty:!0,timeoutMs:h.ShortCommandTimeoutMs})}}t.ErrorStore=_,_.instance=(0,r.lazy)((()=>(0,a.map)((0,p.configDir)(),(e=>new _(v.PosixFile.for(e).join("events"))))))},70025:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),s=i(38639),n=i(26905),a=i(54993),o=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,a.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,a.toS)(e)+(0,r.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,o.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function w(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function v(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function b(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function S(e){return!!((0,s.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||b(e))||void 0}t.isSqliteBusyError=w,t.isSqliteDisconnectedError=v,t.isSqliteConstraintError=b,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===S(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,n.errorCode)(e)||w(e)||v(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=S;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,s.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,s.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},51837:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalError=void 0;const r=i(38835);class s extends Error{constructor(e){super(e+r.InternalErrorFlag)}}t.InternalError=s},8769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),s=i(31586),n=i(68708),a=i(7282),o=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,n.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const s=!0===i.fatal,c=!0===i.ignorable;if(!s&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),s&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!s||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!s||(0,a.isTest)()||(0,o.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),s}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,s.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,o.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,s.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,s.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(26905),o=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,s.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,s.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,a.errorName)(t)??(0,d.first)(this.causes,a.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(a.errorCode)],a.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,a.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,n.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,n.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,n.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,s.blank)(r)||(i=(0,h.dedupeNeedle)(i,r,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,o.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const a=i(49769),o=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),s.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,a.getOrSet)(n(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),a=n(this,r,"f").get(e);return null!=a&&(a.resolve(t),n(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,s=new WeakMap},34102:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),s=i(19851),n=i(15197);t.ee=(0,s.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new n.CapturingEventEmitter(e)}))},64660:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const s=r(i(73024)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,a.lazy)((()=>n.default.geteuid?.())),h=(0,a.lazy)((()=>n.default.getgroups?.()));function f(e,t){try{return!(0,o.blank)(e)&&(s.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,s.default.constants.R_OK|s.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,s.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:s,processGid:n}){if(null==e)return!1;const a=s??d(),o=null!=n?[n]:h()??[],l=0===a,u=l||e.uid===a,f=l||o.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const s=r(i(76760)),n=i(19851),a=i(81168),o=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,n.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,a.equalsIgnoreCase)(e.basename,i.base))return s.default.join(r,e.basename);throw new o.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),s=i(76760);function n(e){return[...a(e)]}function*a(e){for(;e!==(0,s.dirname)(e);)e=(0,s.dirname)(e),yield e}function o(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=o(e);return t.every((e=>i.includes(e)))}t.ancestors=n,t.ancestorG=a,t.selfAndAncestorG=function*(e){yield e,yield*a(e)},t.childrenSync=o,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return n(e).find((e=>l(e,t)))}},83278:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),w=f(i(1708)),v=i(46466),b=f(i(57975)),S=f(i(38522)),P=i(19851),M=i(40958),_=i(5233),T=i(22573),E=i(42659),D=i(50357),k=i(96249),x=i(98553),F=i(55835),C=i(31586),A=i(68708),I=i(97790),O=i(39926),L=i(51926),R=i(59455),N=i(54993),B=i(48884),j=i(22911),z=i(99331),V=i(56519),W=i(56038),U=i(31562),q=i(76850),H=i(70025),G=i(34102),$=i(80875),J=i(50213),K=i(70417),Z=i(43334),Y=i(81168),X=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),se=i(89968),ne=i(20197),ae=i(88561),oe=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),we=i(27794),ve=i(73428),be=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const Se=(0,P.lazy)((()=>new ae.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),s.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),a.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(s=new WeakMap,a=new WeakMap,r=new WeakSet,b.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,M.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,B.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,T.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=Se().get(i);if(null!=r)return r;const s=(0,fe.resolve)(i),n=new Pe(s,t);return Se().set(i,n),Se().set(s,n),n}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,s,"f").unset(),h(this,a,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Y.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,F.map)(this.statSync(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,s,"f").call(this);if(null==t||null==e||(0,M.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",n).call(this)??await d(e=this.clearThisAndParent(),r,"m",n).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,M.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,M.isNotEmpty)(e)?(0,M.includesAll)(t,e):(0,M.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,M.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,R.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,C.gt0)(t))return;const i=await d(this,s,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Z.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,M.isEmpty)(e)||(0,D.eql)(["."],e)||e.every(T.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,F.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,O.pad2)(t+1),(0,O.pad2)(i))))}child(...e){if((0,M.isEmpty)(e))return this;const t=(0,k.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,E.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),B.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Z.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,M.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>=(0,E.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>(0,E.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,F.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*E.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,oe.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,oe.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,$.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,$.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,q.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,be.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,ve.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,ve.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,ve.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,ve.writeFileSync_)(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces),(0,A.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,we.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,we.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,_.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,z.ending)()?1:3,timeoutMs:0,retryDelay:E.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,r,"m",o).call(this,(0,Y.stripSuffix)(this.base,".gz"),S.default.createGunzip())}async gzip(){return d(this,r,"m",o).call(this,this.base+".gz",S.default.createGzip())}async compressBrotli(){return d(this,r,"m",o).call(this,this.base+".br",S.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,ne.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,ne.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(S.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,M.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new j.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,L.newlineRe)(),(r=>{const s=e.exec(r);null!=s&&(t.maybeResolve(s),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,C.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new j.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),Me)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,s)=>{try{const n=await e.f(r,(0,F.denull)(s));t(n)&&i.resolve(n)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,C.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,n=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Y.equalsIgnoreCase)(e.basename,this.base))),t=(0,B.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,F.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},o=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,v.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*E.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let Me=!0;t.useFsWatch=function(e){Me=e},t.execDir=function(){return Pe.for(w.default.execPath).parent()}},19748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const r=i(28874),s=i(88840),n=i(14036),a=i(29882);function o(e){return t=>r.Settings.respectFileExtensions.valueOrDefault?(0,n.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,a.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=o,t.isBrowserExtension=o(s.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=o(s.ExtTypes.Video),t.isAssetFileExtension=o(s.ExtTypes.AssetFile)},84542:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),s=i(96249),n=i(51926),a=i(54993),o=i(43334);function l(...e){return(0,s.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,a.toS)(e).split((0,n.newlineRe)()))))}t.Newline=o.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(a.toS).join("\n");return o.isWin?t.replace((0,n.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),s=i(19851),n=i(50213),a=i(37805),o=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,s.lazy)((()=>(0,n.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,o.mkdirp_)(i),await(0,d.writeTextfile_)((0,o.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+a.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,a.lazy)((()=>[...(0,o.mapNotBlankOr)(n.default.env.SYSTEMROOT,(e=>[e,s.default.join(e,"System32"),s.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const o=n(i(44652)),l=a(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),w=i(14427),v=i(17217),b=i(16287),S=i(68284);class P{constructor(e,t){this.base=e,(0,w.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const M=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class _{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new _(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,v.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},s=await o.stat(t);return new _(i,new P(r,s))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return _.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new _(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void M().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>_.fromSimpleDirent(this.nativePath,e)))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new _(this.nativePath,new P(e.name,e))))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,S.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,b.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await o.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await o.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=_},60652:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,w,v,b,S,P,M,_,T=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},E=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryIterator=t.Undone=t.Done=void 0;const D=i(76760),k=i(19851),x=i(40958),F=i(22573),C=i(41400),A=i(57924),I=i(31586),O=i(68708),L=i(34666),R=i(13538),N=i(83104),B=i(12168),j=i(59455),z=i(48884),V=i(45255),W=i(81168),U=i(38836),q=i(98314),H=i(32144),G=i(28874),$=i(79915),J=i(59107),K=i(98604),Z=i(69385),Y=i(92423),X=i(29882),Q=i(62105),ee=i(74128);t.Done={done:!0},t.Undone={done:!1};class te extends U.EndableWrapper{constructor(e,i,s){super("dir.DirectoryIterator("+e+")",(()=>this.cancel({details:"DirectoryIterator was ended"}))),r.add(this),this.dir=e,this.ctx=i,this.parent=s,this.start=Date.now(),n.set(this,[]),a.set(this,[]),o.set(this,[]),l.set(this,[]),u.set(this,void 0),c.set(this,!1),d.set(this,0),h.set(this,0),f.set(this,0),m.set(this,0),p.set(this,0),this.rootDir=(0,k.lazy)((()=>this.parent?.rootDir()??this.dir)),this.pathFromRoot=(0,k.lazy)((()=>(0,X.posixPathFrom)({nativePath:this.rootDir().dir},this.dir))),this.nextTimeout=(0,k.lazy)((()=>G.Settings.statTimeoutMs.valueOrDefault+(0,I.clamp)(0,512,10*(512-this.depth())))),y.set(this,(0,k.lazy)((async()=>{const e=await(0,Y.whyExcludedDirectory)(this.dir)??(!this.isRoot&&await(0,J.isPosixMountpoint)(this.dir)?"nested mountpoint":void 0);if(null!=e)return this.logger.info("skipping ignorable dir, "+this.dir,{details:e}),await(this.ctx.onExcludedDirectory?.(this.dir,e)),this.cancel({state:ee.SyncDirStates.skipped,details:e}),t.Done}))),b.set(this,(0,k.lazy)((async()=>{const[e,t]=(0,z.partition)((0,j.toA)(await this.dir.children()),(e=>T(this,r,"m",v).call(this,e)));for(const t of e)(0,ee.syncReport)().onProgress({path:t.nativePath,from:"DirectoryIterator",state:ee.SyncFileStates.skipped,details:"this was scanned in a prior incomplete sync"});T(this,l,"f").push(...t.filter((e=>e.isDirectory()))),E(this,m,T(this,l,"f").length,"f");const i=t.filter((e=>e.isFile())),[s,a]=(0,z.partition)(i,H.isSidecarExt);T(this,n,"f").push(...a),T(this,o,"f").push(...s),E(this,h,T(this,n,"f").length,"f")}))),(0,ee.syncReport)().onProgress({path:e.nativePath+D.sep,from:"DirectoryIterator",state:ee.SyncDirStates.scanning})}get isRoot(){return null==this.parent}isDone(){return this.ended||T(this,c,"f")}status(){return{root:this.rootDir().nativePath,path:this.pathFromRoot(),isDone:this.isDone()}}cancel(e){return T(this,c,"f")||(E(this,c,!0,"f"),(0,ee.syncReport)().onProgress({path:this.dir.nativePath+D.sep,from:"DirectoryIterator",state:ee.SyncDirStates.canceled,...e,elapsedMs:Date.now()-this.start})),t.Done}depth(){return(0,W.countChars)(this.dir.nativePath,D.sep)}async run(e=V.ShortCommandTimeoutMs){for(;!this.isDone();)await this.next(Date.now()+e),await(0,C.delay)(1)}async next(e){var i;const s=e-Date.now();try{this.logger.trace("next() starting",{runMs:s});const n=await(0,R.thenOrTimeout)(T(this,r,"m",g).call(this,e),this.nextTimeout());return this.logger.trace("next() finished",{result:n}),n===N.Timeout?(E(this,p,(i=T(this,p,"f"),++i),"f"),this.logger.warn(".next() timed out",{runMs:s,timeoutCount:T(this,p,"f")}),T(this,p,"f")>3?(this.logger.warn(".next(): too many timeouts, giving up on this directory."),this.cancel({state:ee.SyncDirStates.timeout,details:"Failed to scan, even after 3 retries"})):t.Undone):(E(this,p,0,"f"),n)}catch(e){return this.logger.warn("next() failed",{error:e}),this.cancel({state:ee.SyncDirStates.failed,details:"Error thrown during scan: "+(0,q.errorToS)(e)})}}}t.DirectoryIterator=te,s=te,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,m=new WeakMap,p=new WeakMap,y=new WeakMap,b=new WeakMap,r=new WeakSet,g=async function(e){return(T(this,c,"f")?t.Done:void 0)??await T(this,y,"f").call(this)??await T(this,b,"f").call(this)??await T(this,r,"m",S).call(this,e)??await T(this,r,"m",P).call(this,e)??await T(this,r,"m",M).call(this,e)??await T(this,r,"m",_).call(this)},w=function(e){return this.ended||!0===this.ctx.ended?.()?this.cancel({details:"DirectoryIterator was ended"}):T(this,c,"f")?t.Done:(0,Z.isPaused)()||Date.now()>e?t.Undone:void 0},v=function(e){return this.logger.tap({msg:"shouldSkipChild()",result:(0,x.isNotEmpty)(this.ctx.startAtNativePath)&&(0,L.cmpArr)((0,X.splitNativePath)(e.nativePath),this.ctx.startAtNativePath,!1)<=0,meta:{child:e.base}})},S=async function(e){var t;const i=[];let s;for(;null==s&&(0,x.isNotEmpty)(T(this,n,"f"))&&this.ctx.hasCapacity();){const a=T(this,n,"f").shift();E(this,d,(t=T(this,d,"f"),++t),"f");const o=await(0,Q.whyRejectFileSimple)(a);null!=o?(this.logger.debug("maybePopChildFile()",{child:a,whyReject:o}),await(this.ctx.onExcludedFile?.(a,o)),(0,ee.syncReport)().onProgress({path:a.nativePath,from:"DirectoryIterator",state:ee.SyncFileStates.rejected,details:o})):i.push(a),s??(s=T(this,r,"m",w).call(this,e)),null!=s&&this.logger.trace("maybePopChildFile() timeout",{timeout:s})}return(0,x.isNotEmpty)(i)&&(this.logger.trace("maybePopChildFile()",{toAdd:i}),await this.ctx.fileHandler(i),T(this,a,"f").push(...i)),s},P=async function(e){for(;(0,x.isNotEmpty)(T(this,o,"f"));){const t=T(this,o,"f").shift();if(G.Settings.tagAlbumFilenames.values.includes(t.base))(0,ee.syncReport)().onProgress({path:t.nativePath,from:"DirectoryIterator",state:ee.SyncFileStates.note,details:"sidecar will be checked for for album metadata"});else{const e=T(this,a,"f").filter((e=>(0,$.isSidecarOf)(e,t)));(0,x.isNotEmpty)(e)?(0,ee.syncReport)().onProgress({path:t.nativePath,from:"DirectoryIterator",state:ee.SyncFileStates.note,details:"sidecar will be processed with "+(0,A.andList)(e.map((e=>e.base.normalize())))}):(0,ee.syncReport)().onProgress({path:t.nativePath,from:"DirectoryIterator",state:ee.SyncFileStates.rejected,details:"sidecar will be ignored (no importable file was found to be relevant to this sidecar's name)"})}const i=T(this,r,"m",w).call(this,e);if(null!=i)return this.logger.trace("handleSidecars() timeout",{timeout:i}),i}},M=async function(e){var t;let i;for(;null==i&&(null!=T(this,u,"f")||(0,x.isNotEmpty)(T(this,l,"f")))&&this.ctx.hasCapacity();){if(null==T(this,u,"f")){const e=T(this,l,"f").shift();null==e||(this.logger.trace("delegating to child dir, "+e),E(this,f,(t=T(this,f,"f"),++t),"f"),E(this,u,new s(e,this.ctx,this),"f"))}if(null!=T(this,u,"f")){const t=await T(this,u,"f").next(e);(t?.done??!0===T(this,u,"f")?.isDone())&&E(this,u,void 0,"f")}i=T(this,r,"m",w).call(this,e)}return i},_=async function(){if((0,x.isNotEmpty)(T(this,n,"f"))||(0,x.isNotEmpty)(T(this,l,"f"))||null!=T(this,u,"f"))return this.logger.error("maybeCompleteResult: not done (?!)",(0,O.pick)(this,"result","pendingChildren","childDelegate","pendingChildDirs")),t.Undone;if(!T(this,c,"f")){E(this,c,!0,"f");const e=await(0,K.mkFolderUrl)(this.dir.nativePath),t=e?.with({query:null}),i=t?.toString(),r=0===T(this,h,"f")?"":`${T(this,d,"f")}/${(0,B.plur)(T(this,h,"f"),"file")}`,s=0===T(this,m,"f")?"":`${T(this,f,"f")}/${(0,B.plur)(T(this,m,"f"),"directory","directories")}`,n=(0,F.mapNotBlank)((0,A.andList)([r,s]),(e=>"Accepted "+e))??"No files or directories found";(0,ee.syncReport)().onProgress({path:this.dir.nativePath+D.sep,state:ee.SyncDirStates.scanned,from:"DirectoryIterator",details:n,url:i,elapsedMs:Date.now()-this.start}),await this.ctx.directoryListener(this.dir)}return t.Done}},20197:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const s=r(i(76760)),n=i(39926),a=i(29882),o=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if(await(0,a.mkdirp_)(r.dir),!i.requireNumber&&await(0,o.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,o.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if((0,a.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},92423:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notInHiddenPhotoStructureDir=t.whyExcludedDirectoryRecursive=t.notExcludedDirs=t.isExcludedDirectory=t.whyExcludedDirectory=t.notExcludedDirPredicates=t.isExcludedFile=t.whyExcludedFile=t.notExcludedFilePredicates=t.excludeBundles=t.excludeGlobs=t.defaultFilePredicates=t.defaultDirPredicates=t.formatPathForGlob=void 0;const l=o(i(83058)),u=i(19851),c=i(40958),d=i(76790),h=i(22573),f=i(55835),m=i(51926),p=i(54993),g=i(48884),y=i(9092),w=i(54557),v=i(50213),b=i(88158),S=i(56519),P=i(46292),M=i(32551),_=i(35280),T=i(87290),E=i(96706),D=i(57902),k=i(43334),x=i(78984),F=i(33995),C=i(28874),A=i(21144),I=i(83278),O=i(48313),L=i(85772),R=i(78133),N=i(46356),B=i(17217),j=(0,u.lazy)((()=>(0,v.mkLogger)("fs.ExcludeGlobs"))),z=new w.FifoCache(256),V=/[\\/]$/;function W(e){const t=(0,p.toS)(e),i=z.get(t);if(null!=i)return i;const r=(0,B.isSimpleFile)(e)?e:I.BaseFile.for(e),s=V.test(t)||r.isDirectorySync(),n=(0,R.native2posix)(r.nativePath),a=s?(0,m.ensureSuffix)(n,"/"):n;return z.set(t,a),z.set(a,a),z.set(r.nativePath,a),a}t.formatPathForGlob=W;class U{constructor(e,t,i=!0){if(r.add(this),this.pattern=e,this.desc=t,this.exclude=i,e.includes("\\")){const t=e;e=(0,R.native2posix)(t),j().warn("globToPredicate(): backslash in patterns aren't supported: assuming you meant forward-slash?",{given:t,input:e})}this.reason=(0,c.compactBlanks)([this.exclude?"not":"",t,"("+(0,m.ellipsize)(e,48,12)+")"]).join(" ");try{this.re=l.default.makeRe(this.pattern,{nocase:C.Settings.globsCaseInsensitive.valueOrDefault,dot:!0,posixSlashes:!0}),this.valid=!0}catch(e){this.valid=!1,j().warn("Cannot parse pattern",{glob:this.pattern,error:e})}this.bundle=this.valid&&null!=this.re?(0,b.pairToObject)(this.reason,a(this,r,"m",s).bind(this)):{}}}r=new WeakSet,s=function(e){const t=W(e),i=this.re.test(t)??this.exclude;return j().tap({msg:"apply()",level:i?D.LogLevels.debug:D.LogLevels.trace,result:i?!this.exclude:this.exclude,meta:{desc:this.desc,pattern:this.pattern,exclude:this.exclude,posixPath:t,matched:i}})};class q{constructor(){n.set(this,[])}push(...e){for(const t of e){if(!t.valid){j().warn("Ignoring invalid glob",{glob:t});continue}const e=a(this,n,"f").find((e=>e.pattern===t.pattern));null==e?a(this,n,"f").push(t):j().debug("Ignoring duplicate glob",{glob:t,prior:e})}}pushNativePath(e,t){this.push(new U((0,R.native2posix)(e),t))}toA(){return a(this,n,"f")}}n=new WeakMap;const H=new U("**/.*","hidden file"),G=new U("**/.*/","hidden directory"),$=(0,u.lazy)((()=>{const e=new q;e.push(G,H);for(const t of[{s:"bin",desc:"command binary"},{s:"dev",desc:"device file"},{s:"etc",desc:"system configuration file"},{s:"initrd",desc:"initial ramdisk"},{s:"proc",desc:"process metadata"},{s:"sbin",desc:"system binary"},{s:"snap",desc:"snap software"},{s:"sys",desc:"system metadata"},{s:"Dell",desc:"Windows driver"},{s:"Drivers",desc:"Windows driver"},{s:"Intel",desc:"Windows driver"},{s:"Microsoft",desc:"Windows driver"},{s:"NVIDIA",desc:"Windows driver"},{s:"Windows.old",desc:"Windows system"},{s:"Windows",desc:"Windows system"}])e.push(new U((k.isWin?"*":"")+"/"+t.s+"/",t.desc));if(k.isWin)for(const t of["ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemRoot","windir"]){const i=(0,E.getEnv)(t);(0,h.blank)(i)||e.pushNativePath(i,`%${t}%`)}k.isLinux&&e.push(new U(`${(0,M.homeDir)()}/snap/`,"Snap software"));for(const t of[{s:"__MACOSX",desc:"macOS resource fork"},{s:"_includes",desc:"code"},{s:"@eaDir",desc:"Synology thumbnail"},{s:"@Recently-Snapshot",desc:"QNAP snapshot"},{s:"@Recycle",desc:"QNAP trash"},{s:"@SynoResource",desc:"Synology metadata"},{s:"#recycle",desc:"Synology trash"},{s:"#snapshot",desc:"Synology snapshot"},{s:"$Recycle.Bin",desc:"Windows trash"},{s:"$SysReset",desc:"Windows"},{s:"3rdParty",desc:"code"},{s:"Application Data",desc:"Windows apps"},{s:"Application Support",desc:"macOS apps"},{s:"Applications",desc:"macOS apps"},{s:"arangodb",desc:"3rd party"},{s:"cache",desc:"Cache directory"},{s:"CacheClip",desc:"Movie cache directory"},{s:"caches",desc:"Cache directory"},{s:"Chipset_Software",desc:"Windows apps"},{s:"cmake",desc:"code"},{s:"com.apple.TimeMachine.localsnapshots",desc:"macOS"},{s:"cpan",desc:"code"},{s:"DefinitelyTyped",desc:"TypeScript type"},{s:"Desktop DB",desc:"macOS metadata"},{s:"Desktop DF",desc:"macOS metadata"},{s:"Desktop.ini",desc:"macOS metadata"},{s:"DisplayDriver",desc:"Windows driver"},{s:"DLLs",desc:"Windows library"},{s:"dyld",desc:"macOS library"},{s:"ehthumbs.db",desc:"Windows thumbnail"},{s:"i18n",desc:"i18n code"},{s:"iMovie Cache",desc:"Apple iMovie cache"},{s:"iTunes Cache",desc:"Apple iTunes"},{s:"iTunes Media",desc:"Apple iTunes"},{s:"iTunes",desc:"Apple iTunes"},{s:"lib?(32|64|x64|s)",desc:"program library directory"},{s:"lost+found",desc:"fsck recovered directory"},{s:"macOS Install*",desc:"macOS installer"},{s:"Network Trash",desc:"AFP trash"},{s:"node_modules",desc:"Node.js library"},{s:"pkgconfig",desc:"code"},{s:"pkgs",desc:"Python code"},{s:"Program Files (x86)",desc:"Windows apps"},{s:"Program Files",desc:"Windows apps"},{s:"ProgramData",desc:"Windows application support"},{s:"resources/media/face",desc:"face thumbnail"},{s:"rubygems-*",desc:"Ruby code"},{s:"site-packages",desc:"Python code"},{s:"spotifycache",desc:"Spotify cache"},{s:"SteamApps",desc:"Game files"},{s:"System Volume Information",desc:"Windows system metadata"},{s:"System32",desc:"Windows system"},{s:"SystemTemp",desc:"Windows temporary"},{s:"temp",desc:"temporary"},{s:"Temporary Items",desc:"temporary"},{s:"test_suite",desc:"code"},{s:"testutil?(s)",desc:"code"},{s:"third_party",desc:"code"},{s:"Thumbnail?(s)",desc:"thumbnail"},{s:"Thumbs.db",desc:"Windows thumbnail"},{s:"tmp",desc:"temporary"},{s:"Trash",desc:"trash directory"},{s:"Windows",desc:"Windows"},{s:"Windows.old",desc:"Windows"},{s:"Windows10Upgrade",desc:"Windows upgrade"},{s:"Xcode.app",desc:"macOS code"},{s:"*.sparsebundle/bands",desc:"Time Machine backup"},{s:"ImageMagick*",desc:"ImageMagick source"},{s:"Install OS X*",desc:"macOS installer"},{s:"Install macOS*",desc:"macOS installer"},{s:"*.lrdata",desc:"LightRoom data"},{s:"MinGW*",desc:"code"},{s:"msys*",desc:"code"},{s:"vcpkg",desc:"code"}])e.push(new U("**/"+t.s+"/",t.desc));function t(t,i,r){if(!(0,h.blank)(t)){const s=(0,d.sort)((0,c.uniq)((0,c.compactBlanks)(i).map((e=>e.toLowerCase()))));1===s.length&&e.push(new U(`**/${t}/${s[0]}/`,r)),s.length>1&&e.push(new U(`**/${t}/(${s.join("|")})/`,r))}}(0,f.map)((0,P.configDir)(),(t=>e.pushNativePath(t,"PhotoStructure configuration"))),t("nix",["store"],"NixOS package"),e.push(new U("**/*.(photo|photos|ap)library/!(master|masters|modified|original|originals)/","Apple Photos/Aperture library")),e.push(new U("**/facetile*","face thumbnail"));const i=["bin","cygdrive","dev","etc","games","include","lib?(32|64|x64)","local","locale","man","proc","sbin","share","src","tmp","usr","var"];t("usr",i,"FHS system"),t("cygwin?(64)",i,"Cygwin"),t("local",i,"FHS system"),t("Windows",["assembly","Boot","Containers","Cursors","Fonts","Help","Installer","Logs","Microsoft.NET","Servicing","SoftwareDistribution","System32","SystemApps","SysWOW64","Temp","WinSxS"],"Windows"),t("Recovery",["Customizations","OEM"],"Windows"),t("lib",["firmware","modules","systemd","udev","x86_64-linux-gnu"],"Linux system package"),t("opt",["google","x11",...i],"FHS package"),t("lfs",["incomplete","objects"],"Git LFS object");const r=["cache","crash","games","lib","local","lock","log","logs","mail","run","snap","spool","tmp"];t("var",r,"Linux /var"),t("mnt",r,"Linux /mnt"),t("dev",["block","bsg","bus","char","cpu","disk","dri","fd","hugepages","input","lightnvm","mapper","mqueue","net","pts","shm","snd","ubuntu-vg","usb","vfio"],"Linux /dev backup"),t("proc",["acpi","asound","bus","driver","fs","ipmi","irq","net","scsi","self","sys","sysvipc","thread-self","tty"],"Linux /proc backup"),t("library",["Apple","Assistant","Bluetooth","com.apple.iTunesCloud","Containers","CoreAnalytics","Developer","Desktop Pictures","Documentation","Extensions","Finance","Fonts","Frameworks","FrontBoard","Group Containers","HTTPStorages","iTunes","KeyboardServices","Keychains","Logs","Messages","News","Passes","Photos","Preferences","Ruby","Saved Application State","Scripts","User Pictures","Updates","User Template","WebKit","WebServer"],"macOS Library"),t("packages",["*.pkg","*.mpkg"],"macOS package"),t("src/**",["bin","ci","dist","doc?(s)","etc","lib?(s)","main","spec?(s)","src","test?(s)","tools","util"],"code"),t("docs",["admin","content","general","generated","sql"],"code"),t("pkg",["acceptance","ccl","cli","cmd","server","sql","storage","ui","util","workload"],"code"),t("osv",["apps","arch","compiler","external","include","java","modules","musl","tests"],"code"),t("go",["bin","blog","cmd","doc","lib","misc","pkg","src","test","vt"],"code"),t("Perl?(64)",["bin","eg","etc","html","lib","site"],"code"),t("Python*",["dlls","doc?(s)","include","lib?(s)","scripts","tools","tcl"],"code"),t("Ruby*",["bin","include","lib","msys*","packages","share","ssl"],"code"),t("msys*",["clang*","dev","etc","mingw*","tmp","ucrt*","var"],"code"),t("sdk",["build-tools","emulator","extras","patcher","platforms","platform-tools","sources","tools"],"code"),t("test",["fixtures"],"code"),t("data",["$of"],"windows backup"),t("System",["Applications","Developer","DriverKit","Library","iOSSupport"],"macOS System"),t("contents",["frameworks","plugins","resources","sharedsupport"],"macOS application"),t("pg",["pgsql"],"code");for(const e of["local","locallow","roaming"])t("appdata",[e],"Windows default AppData");return t("ps",["cache","config","logs","tmp"],"PhotoStructure docker directory"),e.toA()})),J=()=>{t.excludeGlobs.unset(),t.excludeBundles.unset()},K=()=>{t.notExcludedDirs.unset()},Z=(0,u.lazy)((()=>{C.Settings.excludeGlobsOmitDefaults.watchLater(J),C.Settings.excludeGlobsAdd.watchLater(J),C.Settings.excludeGlobsOmit.watchLater(J),C.Settings.globsCaseInsensitive.watchLater(J),C.Settings.libraryDir.watchLater(K),C.Settings.originalsDir.watchLater(K),C.Settings.scanPaths.watchLater(K),C.Settings.argvScanPaths.watchLater(K)}));t.defaultDirPredicates=(0,u.lazy)((()=>[{notSymlinkLoop:re,notInHiddenPhotoStructureDir:ne,whyNoMedia:L.whyNoMedia,notHidden:se}])),t.defaultFilePredicates=(0,u.lazy)((()=>[{notInHiddenPhotoStructureDir:ne}])),t.excludeGlobs=(0,u.lazy)((()=>{Z();const e=new y.CaseInsensitiveMap;function t(t){if(null!=t&&t.valid){const i=t.pattern.trim();e.has(i)&&j().warn("Duplicate glob:",{glob:t}),e.set(i,t)}}function i(t){const i=t.trim();e.has(i)?e.delete(i):j().warn("Failed to find and remove glob specified in PS_EXCLUDE_GLOBS_OMIT",{glob:t})}if(!C.Settings.excludeGlobsOmitDefaults.valueOrDefault)for(const e of $())t(e);for(const e of C.Settings.excludeGlobsOmit.values)i(e);for(const e of C.Settings.excludeGlobsAdd.values)t(new U(e,"(from PS_EXCLUDED_GLOBS_ADD)"));const r=(0,d.sortBy)(e.values(),(e=>(0,c.compactBlanks)(e.pattern.toLowerCase().split("/")))),[s,n]=(0,g.partition)(r,(e=>e.pattern.endsWith("/")));return{dir:s,file:n}})),t.excludeBundles=(0,u.lazy)((()=>{const e=(0,t.excludeGlobs)();return{dir:[...(0,t.defaultDirPredicates)(),...e.dir.map((e=>e.bundle))],file:[...(0,t.defaultFilePredicates)(),...e.file.map((e=>e.bundle))]}}));const Y=[{disableAllFilters:()=>!0}],X=[{notBlank:()=>!1}];function Q(e){return C.Settings.disableAllFilters.valueOrDefault?Y:(0,h.blank)(e)?X:(0,t.excludeBundles)().file}function ee(e){return F.SyncPredicates.whyRejected(e,...Q(e))}function te(e){return C.Settings.disableAllFilters.valueOrDefault?Y:(0,h.blank)(e)?X:(0,t.excludeBundles)().dir}async function ie(e){return C.Settings.disableAllFilters.valueOrDefault?void 0:x.Predicates.whyRejected(e,...te(e))}function re(e){return!(0,N.seemsLikeSymlinkLoop)(e)}function se(e){return(0,S.thenNot)((0,O.isHidden)(e))}function ne(e){return!(0,_.inHiddenPhotoStructureDir)(e)}t.notExcludedFilePredicates=Q,t.whyExcludedFile=ee,t.isExcludedFile=function(e){return null!=ee(e)},t.notExcludedDirPredicates=te,t.whyExcludedDirectory=ie,t.isExcludedDirectory=async function(e){return null!=await ie(e)},t.notExcludedDirs=(0,u.lazy)((async()=>{const e=(0,c.uniq)((0,c.compactBlanks)([(0,T.libraryDirPosixFile)(),(0,T.libraryOriginalsDirPosixFile)(),...C.Settings.argvScanPaths.values,...C.Settings.scanPaths.values]));return j().tap({msg:"notExcludedDirs() (these directories will never be excluded)",level:"info",result:(0,c.uniq)([...e,...await Promise.all(e.map((e=>(0,A.actualPath)(e))))])})})),t.whyExcludedDirectoryRecursive=async function(e){const i=await(0,t.notExcludedDirs)();for(let t=e;null!=t&&!t.isRoot;t=await(t?.parent())){if(i.includes(t?.nativePath))return;const e=await ie(t);if(null!=e)return e}},t.notInHiddenPhotoStructureDir=ne},88561:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const a=i(40958),o=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class w extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>n(this,r,"m",s).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,a.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=w,r=new WeakSet,s=async function(e){if((0,o.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},79267:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCleanup=void 0;const c=i(19851),d=i(40958),h=i(42659),f=i(31586),m=i(71371),p=i(50213),g=i(7282),y=i(409),w=i(78406),v=i(25764),b=i(99331),S=i(91655),P=i(34102),M=i(89968),_=i(85772);class T{static for(e){return new T(e.name,e.rootNativePath,e.staleMs,e.isPrunable,e.minRetained)}constructor(e,t,i,a,d=0){r.add(this),this.name=e,this.rootNativePath=t,this.staleMs=i,this.isPrunable=a,this.minRetained=d,s.set(this,void 0),this.intervalMs=(0,c.lazy)((()=>(0,f.clamp)((0,g.isTest)()?0:5*h.minuteMs,h.dayMs,this.staleMs/2))),n.set(this,void 0),this.cleanup=(0,y.rateLimited)({name:this.name,minCallDelayMs:this.intervalMs()/4,f:()=>u(this,r,"m",o).call(this)}),l(this,s,(0,p.mkLogger)("fs.FileCleanup("+e+")"),"f")}scheduleInterval(){return(null==u(this,n,"f")||u(this,n,"f").ended)&&l(this,n,new w.EndableInterval({name:this.name,callback:()=>this.cleanup(),intervalMs:this.intervalMs(),rank:v.EndableRanks.first}),"f"),u(this,n,"f")}cancelInterval(){u(this,n,"f")?.end(),l(this,n,void 0,"f")}}t.FileCleanup=T,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(e){if(!(0,f.gt0)(this.minRetained))return new Set;const t=new m.BoundedGreatestSet(this.minRetained??0,(e=>e.mtimeMs()));return await e.visitDescendants((e=>{e.isFile()&&t.add(e)})),new Set(t.vacuum().map((e=>e.nativePath)))},o=async function(){try{if((0,b.ending)())return;const e=await this.rootNativePath();if(null==e)return[];const t=await M.DirectoryEntry.for(e);if(null==t)return[];u(this,s,"f").info("cleanup(): starting",{root:t,staleMs:(0,S.fmtFullDuration)(this.staleMs," ")});const i=await u(this,r,"m",a).call(this,t),n=Date.now()-this.staleMs,o=new Set,l=[],c=[];await t.clear().visitDescendants((async e=>{if((e.dir!==t.nativePath||!(0,_.isNoMediaName)(e.base))&&!i.has(e.nativePath)&&(o.has(e.nativePath)||!(0,f.gte)(e.mtimeMs(),n)))if(e.isDirectory())try{await e.rmdir_(),c.push(e.nativePath),o.add(e.dir)}catch(t){"ENOENT"===t.code&&(u(this,s,"f").warn("cleanup(): ENOENT "+e,t),(0,P.ee)().emit("clearCache")),"ENOTEMPTY"!==t.code&&u(this,s,"f").warn("cleanup(): failed to rmdir "+e,t)}else if(!1!==await(this.isPrunable?.(e)))try{await e.unlink_(),l.push(e.nativePath),o.add(e.dir)}catch(t){u(this,s,"f").warn("cleanup(): failed to clean up tmpfile "+e,t)}}));const h=[...l,...c];return(0,d.isNotEmpty)(h)&&t.clear(),u(this,s,"f").info("cleanup(): done",{root:t,pruned_file_count:l.length,pruned_dir_count:c.length}),h}catch(e){return void u(this,s,"f").error("cleanup() failed",{error:e})}}},32144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),s=i(22573),n=i(45599),a=i(96249),o=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,n.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,s.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,a.flatten)((0,o.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),s=i(17217),n=i(16287),a=i(68284);async function o(e){return(0,r.pick)(await(0,n.stat_)((0,s.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=o,t.fileStats=async function(e){try{return await o(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,a.statSync)((0,s.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const r=i(68817),s=i(19851),n=i(22573),a=i(50213),o=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),h=i(95696),f=i(93854),m=i(16287),p=(0,s.lazy)((()=>(0,a.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,f.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,r.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const s=(0,n.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),a=(0,l.normalizeExt)(h.PosixFile.for(e))??(0,c.mimetypeExt)(s);return(0,n.blank)(s)||(0,n.blank)(a)?void 0:{ext:a,mime:s}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new o.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,s.set(this,[]),n.set(this,void 0),a.set(this,void 0),l(this,a,(0,f.fileStatsSync)(e),"f"),l(this,n,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",o).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,s,"f").push(e)}close(){u(this,n,"f").close()}}t.FileWatcher=m,s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,a,"f"),t)){l(this,a,t,"f");for(const t of u(this,s,"f"))t(e,this.nativePath)}}},13829:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withFsAdvisoryLocks_=t.defaultFsAdvisoryLockDir=void 0;const r=i(55835),s=i(13538),n=i(81168),a=i(37628),o=i(46292),l=i(73209),u=i(95696);function c(){return(0,r.map)((0,o.configDir)(),(e=>u.PosixFile.for(e).join("advisory-locks")))}t.defaultFsAdvisoryLockDir=c,t.withFsAdvisoryLocks_=async function({name:e,lockNames:t,f:i,timeoutMs:r,lockDir:o=c()}){if(null==o)return i();await o.mkdirp_();const u=(0,n.sortIgnoreCase)(t).map((e=>l.FsLock.for({name:e,file:o.join((0,a.shortFsStringSha)(e)),timeoutMs:r})));try{for(const t of u)if(!0!==await(0,s.thenOrTimeout)(t.acquire_(),r))throw new Error("Failed to acquire lock for "+e+": "+t.opts.name+" was busy");return await i()}finally{for(const e of u)e.release()}}},73209:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,w,v,b=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},S=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const M=i(58587),_=P(i(44652)),T=i(87997),E=i(40958),D=i(17586),k=i(42659),x=i(50357),F=i(75240),C=i(55835),A=i(31586),I=i(30976),O=i(13538),L=i(54993),R=i(7282),N=i(68852),B=i(23560),j=i(25764),z=i(38836),V=i(99331),W=i(22781),U=i(38835),q=i(55222),H=i(63870),G=i(69734),$=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)(G.PsLockExt)+"$");class K extends z.EndableWrapper{static newUid(e=process.pid){return S(this,s,Math.max(Date.now(),b(this,s,"f",n)+1),"f",n),(0,E.compactBlanks)([q.TokenRadix.encode(b(this,s,"f",n)),B.serviceName.prior(),(0,L.toS)(e)]).join("-")}static pidFromLockfile(e){return s.pidFromBasename((0,$.basename)(e))}static pidFromBasename(e){return(0,A.toInt)(J.exec((0,L.toS)(e))?.groups?.pid)}static for(e){return b(this,s,"f",o).find((t=>t.opts.file===e.file))??new s(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>b(this,r,"m",v).call(this)),e.endableRank??j.EndableRanks.postdb,(0,H.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,S(t=s,s,(i=b(t,s,"f",a),++i),"f",a)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(b(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,G.fsLockFileBasename)(s.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await b(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,G.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+b(this,l,"f")),this.staleMs=(0,A.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),b(s,s,"f",o).push(this)}get acquired(){return b(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await b(this,r,"m",f).call(this,e)??b(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,D.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,x.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==b(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:k.secondMs);S(this,c,setInterval((()=>b(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=b(this,c,"f")&&(clearInterval(b(this,c,"f")),S(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(b(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),S(this,u,!1,"f"),(0,C.map)(b(this,d,"f"),(e=>(0,T.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?b(this,r,"m",w).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),S(this,d,setTimeout((()=>b(this,r,"m",w).call(this)),(0,A.toGt0)(this.staleMs)??k.secondMs),"f"),b(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(b(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,O.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,s=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,r=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,A.gt0)(this.staleMs)&&Date.now()>b(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await b(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){S(this,h,Date.now(),"f");const e=[],t=await b(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,A.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+k.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,G.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;s.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const n=i[0]===this.lockfile.base;if(n)S(this,u,!0,"f");else if(!0!==t?.vacuum){const t=s.pidFromBasename(i[0]);if((0,A.gt0)(t)&&!(0,M.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),b(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:n,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await b(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},w=async function(){await b(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},v=function(){(0,E.filterInPlace)(b(s,s,"f",o),(e=>b(e,l,"f")!==b(this,l,"f")))},n={value:0},K.internalErrors=0,a={value:0},o={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),s=i(51926),n=i(54993),a=i(17217);function o(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,s.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,s.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,n.toS)(e)))return;const i=(0,a.basename)(e);return o(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&o((0,a.basename)(e))}},4001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),s=i(55835),n=i(31586),a=i(51926),o=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,r.toNotBlank)(e.name)??(0,o.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,n.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:f(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const s=(0,u.parsePosixPath)(i),n=h(s,{aggressive:!1});return[...t,n+s.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,a.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),r=(0,a.stripPrefix)(t.toLowerCase().normalize(),i);return(0,s.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,a.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,s.map)(m.exec(t),(e=>t=e[1].trim())),(0,s.map)(g.exec(t),(e=>t=e[1].trim())),t}},19254:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fileGrep_=t.GrepReader=void 0;const s=r(i(73024)),n=i(57075),a=i(46466),o=i(54993),l=i(33456),u=i(17217),c=i(58722);class d extends n.Transform{constructor(e,t="\n"){super({objectMode:!1,autoDestroy:!0}),this.pattern=e,this.sep=t}_transform(e,t,i){const r=(0,o.toS)(e).match(this.pattern);null!=r&&this.push(r[1]??r[0]+this.sep),i()}}t.GrepReader=d,t.fileGrep_=async function(e,t){const i=new c.WritableToBuffer;return await(0,a.pipeline)([s.default.createReadStream((0,u.toNativePath_)(e)),new l.LineReader,new d(t),i]),(await i.buffer).toString()}},14977:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const s=r(i(44652)),n=r(i(73024)),a=i(46466),o=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,a.pipeline)(n.default.createReadStream(e,{autoClose:!0}),o.default.createGzip(),n.default.createWriteStream(t,{autoClose:!0})),await s.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const s=r(i(77598)),n=r(i(73024)),a=i(46466),o=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),w=i(16287),v=(0,o.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),b=(0,o.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function S(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=b().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return v().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;v().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),b().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await M(n.default.createReadStream(i)),stats:(0,u.pick)(await(0,w.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function M(e,t=[],i="sha512"){const r=s.default.createHash(i);return await(0,a.pipeline)([e,...t,r]),r.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:b,impl:P}),t.fileShaMeta_=S,t.fileSha_=async function(e){return(await S(e)).sha},t.uncachedFileSha_=P,t.streamSha_=M,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return s.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),s=i(42659),n=i(55835),a=i(31586),o=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,o.stdout_)("chflags",["hidden",t],{timeoutMs:10*s.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,n.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,o.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*s.secondMs}),i=(0,a.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),s=i(54993),n=i(7282),a=i(43334),o=i(69375),l=/^\/dev(?:\/|$)/i,u=a.isMac||(0,n.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=a.isMac||(0,n.isTest)()?/^\/private\//i:void 0,d=a.isMac||(0,n.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=a.isMac||(0,n.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,s.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,o.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},87128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonFileStore=void 0;const r=i(19851),s=i(55835),n=i(57159),a=i(50213);t.JsonFileStore=class{constructor(e,t,i){this.file=e,this.mkObject=t,this.onWrite=i,this.prior=(0,r.lazy)((()=>this.file.readJson("debug")))}async read_(){return await this.prior()??(0,s.map)(await this.mkObject(),(e=>this.write_(e)))}async write_(e){try{return await this.file.writeJson_(e,{spaces:2}),this.prior.set(Promise.resolve(e)),(0,a.mkLogger)("fs.JsonFileStore").info("wrote to "+this.file,e),null!=this.onWrite&&await this.onWrite(this.file,e),e}catch(e){throw new n.WrappedError("Failed to write to "+this.file,{cause:e,path:this.file.nativePath})}}}},33456:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),s=i(51926),n=i(54993);class a extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,n.toS)(e)).split((0,s.newlineRe)()),a=r.pop();this._prior=a??"";let o=!1;for(const e of r)o||(o=!this.push(e));o?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=a},64680:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const s=r(i(76760)),n=i(17217),a=i(73428);t.mkNoMedia_=function(e){return(0,a.writeTextfile_)(s.default.join((0,n.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},61704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nativePathsEql=t.nativePathsEqlSync=void 0;const r=i(21144),s=i(17217);t.nativePathsEqlSync=function(e,t){if(null==e||null==t)return!1;if(e===t)return!0;try{const i=(0,s.toNativePath_)(e),r=(0,s.toNativePath_)(t);return null!=i&&null!=r&&i===r}catch{return!1}},t.nativePathsEql=async function(e,t){try{return null!=e&&null!=t&&await(0,r.actualPath_)((0,s.toNativePath_)(e))===await(0,r.actualPath_)((0,s.toNativePath_)(t))}catch{return!1}}},85772:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const a=n(i(76760)),o=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),w=i(83278),v=i(70698),b=i(88561),S=i(65238),P=i(16287),M=(0,o.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),_="NoMedia",T=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(a.default.sep),"/"]).join("")+"])\\.?"+_+"$","im"),E=Object.freeze(["."+_,_]),D=Object.freeze((0,u.flatten)(E.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function k(e){return null!=T.exec(e)}t.isNoMediaName=k;const x=(0,o.lazy)((()=>new b.FileCache({name:"fs.noMediaDirsCache"})));async function F(e,t){if(null==e)return null;const i=w.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return k(i.base)||await(0,v.isCachedirTagFile)(i)?x().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):F(i.parent());{const e=await x().getOrSetAsync(i.nativePath,(()=>C(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:F(i.parent())}}async function C(e){if(k(e.base))return x().set(e.parent().nativePath,e.nativePath),M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,S.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,r=await Promise.race([A(e.nativePath,i),(0,S.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,v.isCachedirTagDirectory)(e)?M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(v.CACHEDIR_TAG).nativePath)}):null}async function A(e,t){for(const i of g.isCaseSensitiveFs?D:E){if(!0===t?.aborted)return null;const r=a.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return M().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function I(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(k(r.basename))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,a.join)(e,r.basename))});if(r.basename===v.CACHEDIR_TAG){const t=(0,a.join)(e,r.basename);if(await(0,v.isCachedirTagFile)(t))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await F(e,t)},t.whyNoMedia=F,t.whyNoMediaDir=C,t._dirHasNoMediaChild=A},29882:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),w=i(78133),v=i(53265),b=i(17217),S=i(16287),P=i(66430),M=i(5545);function _(e){return((0,b.isSimpleFile)(e)?e.base:n.default.basename(n.default.resolve(e))).startsWith(".")}t.logger=(0,a.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=_,t.containsHiddenPathname=function(e){return F(e).some(_)},t.isNotHiddenPosixPath=function(e){return F(e).every((e=>!_(e)))},t.resolveSimpleFile=function(e){return(0,b.isSimpleFile)(e)?e.nativePath:(0,v.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,v.resolve)(...e)},t.parsePosixPath=function(e){return E((0,w.posix2native)(e))},t.extname=function(e){return E(e).ext},t.dirname=function(e){return n.default.dirname((0,b.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(n.default.parse(e).ext,n.default.parse(t).ext)};const T=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function E(e){const t=T.exec(e)?.groups,i=t?.ext2??"",r=n.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function D(e){const t=n.default.parse((0,b.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,n.default.sep)}function k(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,b.toNativePath_)(e.ancestor),i=(0,b.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,n.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function x(e,t,i){if(null==t||null==i)return!1;const r=e(t),s=e(i);return null!=r&&null!=s&&(y.isLinux?r===s:(0,p.equalsIgnoreCase)(r,s))}function F(e){return(0,b.isSimpleFile)(e)?e.pathnames:e.split(n.default.sep).filter((e=>null!=e&&""!==e))}function C(e){return(0,u.notBlank)(e)&&F(e).length===(y.isWin?1:0)}function A({p:e,maxLength:t}){const i=(0,b.toNativePath_)(e);if(i.length<=t)return i;const r=F(e),s=[],n=[r.pop()];for(;r.length>0;)if(s.length=t){r.unshift(s.pop());break}}else if(n.unshift(r.pop()),O([...s,...n]).length>=t){r.push(n.shift());break}return r.length>0&&s.push("…"),O([...s,...n])}function I(e){return e.startsWith("\\\\")}function O(e){return(0,h.ensurePrefix)((0,o.compactBlanks)(e).join(n.default.sep),y.isWin?"":n.default.sep)}t.parseNativePath=E,t.parentBasename=D,t.grandParentBasename=function(e){return D(n.default.parse((0,b.toNativePath_)(e)).dir)},t.containedByNativePath=k,t.eqlBasename=function(e,t){return x(b.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return x(b.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return x(b.toNativePath_,e,t)},t.toPathnames=F,t.pathIsRoot=C,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:F(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,b.toNativePath_)(e),r=(0,b.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,w.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,w.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=A,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const s=[];for(const r of e.slice(0,i))s.push(A({p:r,maxLength:t}));return s.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return F(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return F(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=E(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(M.driveRe))},t.mkdirp_=async function(e){try{if(await(0,S.isReadableDirectory)(e))return;if(C(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await s.default.mkdirp(e)}catch(t){if(await(0,S.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;s.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>s.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,b.toNativePath_)(e).split(n.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=O,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:O(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>k({ancestor:t,descendant:e,acceptSelf:!0})?[(0,b.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),w=i(64660),v=i(21144),b=i(16287),S=(0,n.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function M(e,t=P){const i=await(0,b.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,w.isStatRX)(i,e)}function _(){if(y.isWin){const e=(0,o.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,o.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,o.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,s.default.join(e,"System32"),s.default.join(e,"System32","Wbem"),s.default.join(i,"chocolatey","bin"),s.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function T(){const e=(0,h.toS)((0,m.env)().PATH).split(s.default.delimiter);return(0,a.uniq)((0,a.compactBlanks)([...e,..._()]))}t.isRXFile=M,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,a.uniq)((0,a.compactBlanks)([...T(),...(0,d.toA)(i)]));for(const i of(0,a.uniq)((0,a.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=s.default.join(t,e);if(await M(i))return y.isLinux?i:(0,v.actualPath)(i)}}S().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,w.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){"use strict";var r,s,n,a=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return o(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),w=i(76790),v=i(5233),b=i(22573),S=i(42659),P=i(26905),M=i(75240),_=i(55835),T=i(31586),E=i(68708),D=i(13538),k=i(89937),x=i(12168),F=i(54993),C=i(48884),A=i(50213),I=i(45255),O=i(81168),L=i(56519),R=i(56038),N=i(31562),B=i(84777),j=i(9595),z=i(38835),V=i(70025),W=i(57902),U=i(55222),q=i(43334),H=i(33847),G=i(24399),$=i(28874),J=i(79915),K=i(45200),Z=i(34238),Y=i(87001),X=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),se=i(73209),ne=i(48313),ae=i(29882),oe=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,C.contextFilter)(function(e){return(0,w.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,A.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Z.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,L.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,L.thenMapOr)((0,X.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>q.isMac?(0,B.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,b.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,b.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,O.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,oe.toNativePath_)(e),r=new fe(i,t);return(0,O.isString)(e)&&he().set(e,r),he().set(i,r),r}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,L.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,ae.containedByNativePath)({ancestor:(0,j.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,ae.containedByNativePath)({ancestor:(0,j.originalsDir)(),descendant:this,acceptSelf:!0}))return q.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,_.map)((0,ee.bestMountpoint)(this.nativePath,await(0,X.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,_.map)((0,b.notBlankOr)(e,(()=>this.uri_())),Z.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,F.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===k.PS_LIBRARY_SCHEME?1:t.scheme===k.PS_LOCAL_FILE_SCHEME?2:t.scheme===k.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,O.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(q.isWin||q.isMac)return this.trap("hide",(async()=>(await(0,ne.hide_)(this),this)))}async hidden(){return(0,ne.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,O.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,C.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,_.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,E.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:s,skipWip:n=!1,skipFsLock:a=!1,retries:o=2,dirty:l=!1}){return(0,v.retryOnReject_)((async()=>{const o=await this.clear().isNonEmptyFile(i);if(!o){if(n&&a)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:a,minSizeBytes:i,timeoutMs:s,dirty:l})}return o&&r?void 0:this.utimes()}),{maxRetries:o,timeoutMs:2*s,retryDelay:3*S.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,T.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:s,dirty:n=!1}){return await this.parent().mkdirp_(),(0,se.withLock_)({file:this,skipFsLock:r,timeoutMs:s,dirty:n},(async()=>{const r=this.wip();try{await r.unlink("trace");const n=await(0,D.thenOrTimeoutError)(e(r),s);if(n===t.NoOp)return n;if(await(0,N.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),n;throw new Error(this+"applyWip(): still empty after waiting "+(0,M.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==$.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",s).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",n).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();$.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:S.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,T.clamp)(I.ShortCommandTimeoutMs,10*S.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,b.notBlank)(this.ext)&&(0,b.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,S.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,_.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,L.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,O.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,ae.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,ae.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,Y.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,r=new WeakSet,s=async function(e){let t,i=e;const r=e.wip();try{const s=await this.stat_();if(null==s)return this.pflog().throw("Can't copy missing files"+z.NonRetriableErrorFlag);if(s.size>0){if($.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+z.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,r.nativePath,h.default.constants.COPYFILE_FICLONE),s.size>5*x.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},s.size,(()=>r.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,T.approximates)(s.size,await r.size({refresh:!0}))),{intervalMs:S.secondMs,timeoutMs:S.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:s.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:s.birthtimeMs,mtimeMs:s.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,s.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${s.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,_.map)(t,(e=>e.end()))}},n=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),s=r?.size;return null==r||null==s?this.pflog().throw("Can't copy missing files"):(s>5*x.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},s,(()=>e.clear().size()))),q.isWin?await G.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,G.pwshQuote)(this.nativePath)} -Destination ${(0,G.pwshQuote)(i.nativePath)}`,(e=>e)):q.isMac?await(0,B.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,B.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+z.DoNotSendErrorFlag,{error:t})}finally{(0,_.map)(t,(e=>e.end()))}}},62105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.acceptFile=t.whyRejectFile=t.expensiveFileFiltersFor=t.acceptParentAndFileAndSimple=t.acceptFileSimple=t.whyRejectFileSimple=t.simpleFileFiltersFor=t.notFileTooBig=t.notFileTooSmall=t.notFileMissing=t.hasBrowserImgMimeType=t.notDimensionsTooSmall=t.requiredTagsFilter=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(54993),o=i(48884),l=i(56519),u=i(78984),c=i(28874),d=i(43207),h=i(47783),f=i(97573),m=i(16170),p=i(54979),g=i(1078),y=i(42231),w=i(83278),v=i(19748),b=i(92423),S=i(16287);function P(e){return async t=>(0,l.thenMapOr)((0,h.readRawTags)(t,!1),e,(()=>!1))}async function M(e){if(!(0,n.gt0)(c.Settings.minVideoDimension.valueOrDefault)&&!(0,n.gt0)(c.Settings.minImageDimension.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);if(null==t||!t.startsWith("image/")&&!t.startsWith("video/"))return!1;const i=t.startsWith("video/")?c.Settings.minVideoDimension.valueOrDefault:c.Settings.minImageDimension.valueOrDefault;return(0,n.gt0)(i)?(0,l.thenMapOr)((0,g.extractSizeInfoFromFile)(e),(e=>(0,n.gte)(e.ImageWidth,i)&&(0,n.gte)(e.ImageHeight,i)),(()=>!1)):null}async function _(e){if(!(0,n.gt0)(c.Settings.minVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.gte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.minVideoDurationSec.valueOrDefault):null)}async function T(e){if(!(0,n.gt0)(c.Settings.maxVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.lte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.maxVideoDurationSec.valueOrDefault):null)}async function E(e){return!(0,s.blank)(await(0,p.readMimeType)(e))}async function D(e){if(-100===c.Settings.rejectRatingsLessThan.valueOrDefault)return null;const t=await(0,h.readTags)(e),i=(0,n.toInt)(t?.Rating);return null==i||i>=c.Settings.rejectRatingsLessThan.valueOrDefault}async function k(e){return 0===c.Settings.keywordBlocklist.values.length?null:(0,f.rawTagKeywords)(await(0,h.readTags)(e)).every((e=>!0!==(0,y.leafIsExcluded)(e,c.Settings.keywordBlocklist.values)))}async function x(e){if(!c.Settings.requireMakeModel.valueOrDefault)return null;const t=await(0,h.readRawTags)(e);return null==t||(0,s.blank)(t.MIMEType)?null:t.MIMEType.startsWith("image/")?null!=t&&(0,s.notBlank)(t.Make)&&(0,s.notBlank)(t.Model):null}async function F(e){return(0,w.isBaseFile)(e)?e.exists():(0,S.exists)(e.nativePath)}async function C(e){const t=c.Settings.minAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.gte)(i,t)}async function A(e){const t=c.Settings.maxAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.lte)(i,t)}function I(e){return[{isSupportedFileExtension:v.isAssetFileExtension},...(0,b.notExcludedFilePredicates)(e),{notFileMissing:F},{notFileTooSmall:C,notFileTooBig:A}]}function O(e){return[...I(e),{notMissingMimeType:E},{supportedMimeType:m.isAssetFileMimeType},{notMissingMakeAndModelTags:x},{notDimensionsTooSmall:M},{notVideoTooShort:_},{notVideoTooLong:T},{notRejectedRating:D},{notExcludedKeyword:k}]}async function L(e,t){return await u.Predicates.whyRejected(e,...t??O(e))??await(0,b.whyExcludedDirectoryRecursive)(e.parent())}t.requiredTagsFilter=function(e){return P((t=>(0,o.allNotBlank)(...e.map((e=>t[e])))))},t.notDimensionsTooSmall=M,t.hasBrowserImgMimeType=P((e=>(0,r.includes)(["image/jpeg","image/png"],(0,a.toS)(e.MIMEType)))),t.notFileMissing=F,t.notFileTooSmall=C,t.notFileTooBig=A,t.simpleFileFiltersFor=I,t.whyRejectFileSimple=function(e){return u.Predicates.whyRejected(e,...I(e))},t.acceptFileSimple=function(e){return u.Predicates.accepted(e,...I(e))},t.acceptParentAndFileAndSimple=async function(e){const t=await e.parent();return null!=t&&!await(0,b.isExcludedDirectory)(t)&&await u.Predicates.accepted(e,...I(e))},t.expensiveFileFiltersFor=O,t.whyRejectFile=L,t.acceptFile=async function(e){return null==await L(e)}},78133:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const s=r(i(76760)),n=i(22573),a=i(81168);t.posix2native=function(e,t){if((0,n.blank)(e))return e;if(s.default.sep===s.default.posix.sep)return e;const i=(0,n.notBlank)(t)?s.default.sep+s.default.sep+t+s.default.sep:"",r=e.split(s.default.posix.sep);return(0,a.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(s.default.sep)},t.native2posix=function(e){return(0,n.blank)(e)||s.default.sep===s.default.posix.sep||s.default.posix.sep===s.default.sep?e:e.split(s.default.sep).join(s.default.posix.sep)}},43899:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,a.lazy)((()=>s.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,a.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(s.default.join((0,p.execDir)(),"resources"),s.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,o.compactBlanks)([(0,p.execDir)(),n.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const r=s.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),s=i(19851),n=i(31586),a=i(50213),o=i(57902),l=i(69428),u=(0,s.lazy)((()=>(0,a.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=o.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,n.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),s=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let n=-1;try{const s=i??(await(0,r.stat)(e)).size-t,a=Buffer.alloc(s);return n=await(0,r.open)(e,"r"),await(0,r.read)(n,a,0,s,t)}finally{(0,s.mapGte0)(n,r.close)}}},69428:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const a=n(i(73024));t.readFileSync=function(e){try{return a.readFileSync(e)}catch{}}},55690:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),s=i(84542);t.readLines_=async function(e){return(0,s.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class s extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=s},65238:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const s=r(i(51455)),n=i(76760),a=i(19851),o=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),w=i(28874),v=i(63870),b=i(88561),S=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,a.lazy)((()=>(0,n.join)(w.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,a.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function M(){try{await s.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=M;const _=(0,a.lazy)((()=>new b.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,v.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function T(e){(0,l.blank)(e)||_.prior()?.delete(e)}async function E(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await _().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,S.statTimeoutMs)(),r=D(e),s=await(0,h.thenOrTimeout)(r,(0,d.toGt0)(w.Settings.fsCacheSlowMs.valueOrDefault)??(0,S.statTimeoutMs)());if(s===f.Timeout&&(0,g.onTimeout)({soft:!1}),s!==f.Timeout&&s.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=T,(0,c.later)((()=>{w.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),_.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),M()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?M():T(e)))})),t.slowDirs=(0,a.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!_().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){T(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=_().get(e)},t.childDirectories_=async function(e){return(await E(e)).filter((e=>e.isDirectory)).map((t=>(0,n.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(w.Settings.readdirCacheMs.valueOrDefault)?E(e):D(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=E,t.readdirCached=function(e){return _().get(e)},t.readdirUncached_=D},53265:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const s=i(73024),n=r(i(76760)),a=i(40958),o=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,a.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=n.default.resolve(t,...e);if((0,s.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,o.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(o.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??n.default.resolve(...e))},t.execDir=(0,l.defer)((()=>n.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},46356:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.seemsLikeSymlinkLoop=void 0;const r=i(22454),s=i(28874),n=i(29882);t.seemsLikeSymlinkLoop=function(e){const t=new r.CountingSet;for(const i of(0,n.toPathnames)(e))t.incr(i.toLowerCase().normalize());return t.max()>s.Settings.maxDuplicatePathElements.valueOrDefault}},50274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),s=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,s.isBoolean)(e.isFile)&&(0,s.isBoolean)(e.isDirectory)}},17217:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const s=r(i(73024)),n=r(i(76760)),a=i(22573),o=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,a.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,a.blank)(e.nativePath))throw new Error(`toNativePath(${(0,o.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof s.default.Dirent?e.name:f(e)?e.base:n.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:n.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(n.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function w(e){return(0,o.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(s.default.stat(e),(0,g.statTimeoutMs)(),!0)}function v(e,t=f.LogLevels.debug){return(0,o.blank)(e)?void 0:w(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function b(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function S(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=b(e),r=b(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],s=t[i],n=(0,u.diff)(S(r),S(s));if(null==n||n>1)return"unmatched "+i+": "+r+" ≠ "+s}}t.stat_=w,t.statMaybe=v,t.statToType=b,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await v(e,t)},t.isEmptyFile=async function(e,t){const i=await v(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await v(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await v(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await v(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await v(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await v(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await v(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,a.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const s=r(i(73024)),n=i(22573);function a(e){try{return(0,n.blank)(e)?void 0:s.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function o(e){return null==e||e.isFile()&&0===e.size}t.statSync=a,t.isEmptyStats=o,t.isFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=a(e);return t.emptyIsNew?null==i:o(i)},t.isNonEmptyFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===a(e)?.isDirectory()}},41080:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),s=i(56409);t.onDataChunked=function(e,t,i){const r=new n(t,i,!0);return r.read(e),r.done};class n{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new s.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=n},95705:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const s=r(i(57075)),n=i(41400),a=i(55835),o=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends s.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,n.delay)(50);try{(0,o.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,a.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends s.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const s=r(i(73024)),n=i(76760),a=i(22573),o=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,a.blank)(e))return!1;try{return s.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,o.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,a.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,a.notBlank)(t)){const e=(0,n.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,a.blank)(e)&&d((0,u.posix2native)(e))}},74128:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncReport=t.syncReport=t.recentSyncReports=t.ensureSyncReportReadme=t.syncReportReadme=t.syncReportDir=t.SyncReportHeaders=t.isRejectedState=t.SyncReportStates=t.SyncDirStates=t.FileDoneStates=t.SyncFileStates=t.AssetFileSyncStates=void 0;const p=i(51168),g=i(73024),y=i(4927),w=i(19851),v=i(40958),b=i(22573),S=i(42659),P=i(98553),M=i(31586),_=i(68708),T=i(50989),E=i(51926),D=i(85556),k=i(54993),x=i(89788),F=i(23467),C=i(7282),A=i(23560),I=i(77377),O=i(71567),L=i(73568),R=i(25764),N=i(38836),B=i(99331),j=i(12959),z=i(87290),V=i(46296),W=i(98314),U=i(38835),q=i(5012),H=i(32144),G=i(95696),$=i(36868),J=i(57902),K=i(28874),Z=i(84542),Y=i(73428);t.AssetFileSyncStates=(0,T.strEnum)("noop","deleted","skipped","synced","unknown"),t.SyncFileStates=(0,T.strEnum)(...t.AssetFileSyncStates.values,"canceled","rejected","failed","timeout","enqueued","started","copied","blocklisted","note"),t.FileDoneStates=(0,I.diff)(t.SyncFileStates.values,["enqueued","started","note"]),t.SyncDirStates=(0,T.strEnum)("scanning","canceled","failed","timeout","skipped","scanned"),t.SyncReportStates=(0,T.strEnum)(...t.SyncFileStates.values,...t.SyncDirStates.values),t.isRejectedState=function(e){return null==e||["canceled","deleted","failed","rejected","timeout","unknown"].includes(e)};const X={enqueued:"the file looks promising, and will be attempted to be imported soon.",rejected:"the file did not pass all import filters. The details column will explain why.",started:"the file was dequeued from the work queue, and is now going to be processed.",noop:"the current file metadata already matches your library database, so no operation was needed to sync this file.",deleted:"the file was determined to be deleted (the prior mountpoint exists, but the file doesn't exist anymore)",skipped:"the file lives on a volume that isn't currently mounted.",synced:"the file was imported.",blocklisted:"the file was blocklisted and files with the same SHA will not be imported in the future.",failed:"something went wrong. The details column will explain why.",timeout:"the file wasn't processed in a reasonable amount of time.",copied:'"automatic organization" is enabled (copyAssetsToLibrary=true), and the photo or video was copied into your library originals directory. The details column will contain the source file path.',note:"sidecars will be referenced here. The details column will specify which source file(s) it will be associated with.",canceled:"PhotoStructure was shut down while the file was processed.",unknown:"an internal error occurred during processing."},Q={scanning:"the directory contents are about to be read.",scanned:"the directory contents were completely processed.",skipped:"the directory was excluded. The details column will explain why.",canceled:"PhotoStructure was shut down before the directory was processed.",failed:"reading the directory contents failed.",timeout:"reading the directory contents took too long."};function ee(e){return(0,_.entries)(e).map((([e,t])=>` - "${e}": ${t}`)).join("\n")}const te=new Set([t.AssetFileSyncStates.deleted,t.SyncFileStates.failed,t.SyncFileStates.timeout,t.SyncDirStates.canceled]);function ie(){return(0,z.librarySyncReportsDir)()??G.PosixFile.for((0,V.logDir)()).join("sync-reports")}function re(){return ie().join("README.txt")}t.SyncReportHeaders=(0,T.strEnum)(...(0,_.keys)(new class{constructor(e,t,i,r,s,n,a,o,l={}){this.ts=e,this.at=t,this.path=i,this.state=r,this.from=s,this.elapsedMs=n,this.details=a,this.url=o,this.meta=l}}(0,"","","unknown","",0,"",""))),t.syncReportDir=ie,t.syncReportReadme=re,t.ensureSyncReportReadme=(0,w.lazy)((()=>(0,Y.writeTextfile_)(re().nativePath,(0,E.wrap)(`\n\nHowdy from PhotoStructure!\n\nThis directory contains your recent "sync reports". \n\nThese files are written as your scan paths are examined for photos and videos.\n\nPhotoStructure creates a new file when it restarts and when it completes importing a given scan path directory.\n\nThese CSV files can be opened with most spreadsheet applications, like LibreOffice.\n\n\nColumn descriptions\n===================\n\nThe "ts" column is the timestamp for the row, in millis from 1970-01-01. Most spreadsheet applications don’t know how to parse these values, though, so we also add the at column.\n\nThe "at" column is ts in ISO format with only second resolution, and should be parsable by most spreadsheet software.\n\nThe "path" column is the native path of the directory or file. It will be empty for messages about system state.\n\nThe "state" column explains why that row was added.\n\nThe "from" column specifies which codepath added the sync report row.\n\nThe "elapsedMs" column is only added to rows completing a given path, and records how long that process took.\n\nThe "details" column will include information about the path, like why a given file or folder were rejected.\n\nThe "url" column is only added to rows when a file or directory is imported. You may need to adjust the domain name of the URL to make it work correctly (it defaults to localhost).\n\n\nDirectory state values\n======================\n\nThe "state" column for directories will be\n\n${ee(Q)}\n\n\nFile state values\n=================\n\nThe "state" column for files will be\n\n${ee(X)}\n\n\nSee https://photostructure.com/go/sync-reports\n\n`,{maxLineLen:80}).join("\n")))),t.recentSyncReports=async function(e=S.dayMs){const t=Date.now()-e;return ie().descendants((async e=>(0,H.isCsvExt)(e)&&(0,M.gte)(e.mtimeMs(),t)))},t.syncReport=(0,w.lazy)((()=>new se));class se extends N.EndableWrapper{constructor(){super("fs.SyncReport()",(()=>f(this,r,"m",d).call(this)),R.EndableRanks.predb),r.add(this),s.set(this,void 0),n.set(this,void 0),a.set(this,void 0),o.set(this,0),l.set(this,0),this.outputFiles=new x.BoundedList(64),(0,t.ensureSyncReportReadme)()}get outputNativePath(){return f(this,s,"f")?.nativePath}get rowCount(){return f(this,l,"f")}onProgress(e){if(null==e||(0,b.blank)(e.state))return this.logger.error(".onProgress(): invalid input",{s:e,from:(0,q.stack)()});{this.logger.log(te.has(e.state)?J.LogLevels.warn:J.LogLevels.info,"onProgress()",e);const t=Date.now(),i={path:(0,k.toS)(e.path),state:e.state,details:(0,k.toS)(e.details).trim().replace(/\r?\n/g,"; ")},s={ts:t,at:new Date(t).toISOString(),...i,...(0,_.pick)(e,"from","elapsedMs","url")};(0,_.isEmptyObj)(e.meta)||(s.meta=(0,P.stringify)(e.meta)),(0,C.isTest)()&&process.stdout.write((0,P.stringify)(e)+Z.Newline),f(this,r,"m",u).call(this,s)}}maybeSystemData(e){(0,A.isSyncService)()&&this.onProgress(e)}async wrap_({path:e,from:i,fn_:r}){const s=Date.now();this.onProgress({path:e,from:i,state:t.SyncFileStates.started});try{const n=await r(),a=n.state??(null!=n.error?t.SyncFileStates.failed:t.SyncFileStates.unknown);return a===t.SyncFileStates.unknown&&this.logger.error(i+" returned result with no state!"+U.InternalErrorFlag,{path:e,result:n}),this.onProgress({path:e,from:i,elapsedMs:Date.now()-s,...n,state:a}),n}catch(r){throw this.logger.warn("wrap_() caught error",{error:r}),this.onProgress({path:e,from:i,state:(0,B.ending)()||r instanceof L.AbortError?t.SyncFileStates.canceled:r instanceof D.TimeoutError?t.SyncFileStates.timeout:t.SyncFileStates.failed,details:(0,B.ending)()?void 0:(0,W.errorToS)(r),elapsedMs:Date.now()-s}),r}}get output(){return f(this,n,"f")??f(this,r,"m",h).call(this)}async flushClose(){return f(this,r,"m",u).call(this),this.close()}async close(){this.logger.info("Closing sync report");const e=f(this,n,"f");return m(this,n,void 0,"f"),m(this,l,0,"f"),await(0,$.endStream)(e),null==e?void 0:f(this,s,"f")}}t.SyncReport=se,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,r=new WeakSet,u=function(e){var t;const i=f(this,a,"f");if(m(this,a,e,"f"),null!=e&&(0,F.eqlPicked)(e,i,"path","state","details"))return this.logger.debug("deduping row",e),void m(this,o,(t=f(this,o,"f"),t++,t),"f");null!=i&&(0===f(this,o,"f")?f(this,r,"m",c).call(this,i):(f(this,r,"m",c).call(this,{...i,details:(0,v.compactBlanks)([i.details,`(repeated ${f(this,o,"f")+1} times)`]).join(" ")}),m(this,o,0,"f")))},c=function(e){var i;const r=(0,y.unparse)([e],{header:!1,columns:t.SyncReportHeaders.values});this.output.write(r+Z.Newline,(e=>{null!=e&&this.logger.error("Failed to write",e)})),m(this,l,(i=f(this,l,"f"),++i),"f")>K.Settings.syncReportMaxRows.valueOrDefault&&this.close()},d=function(){return this.logger.info("sync report ended",{rowCount:f(this,l,"f"),outputFiles:this.outputFiles}),this.flushClose()},h=function(){return m(this,s,function(){const e=p.DateTime.now();return ie().join(e.toFormat("y-MM-dd"),(0,j.filestamp)()+"-sync-report.csv")}().ensureNewSync_({emptyIsNew:!1}),"f"),this.outputFiles.push(f(this,s,"f").nativePath),this.logger.info("Opening new report: "+f(this,s,"f")),(0,C.isTest)()&&(0,O.stdoutWrite)({syncReport:f(this,s,"f").nativePath},!1),m(this,n,(0,g.createWriteStream)(f(this,s,"f").nativePath),"f"),f(this,n,"f").write((0,y.unparse)([t.SyncReportHeaders.values],{header:!1})+Z.Newline),f(this,n,"f")}},89966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const s=r(i(48161)),n=i(19851),a=i(55835),o=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),h=i(8103),f=i(43899);function m(){return(0,a.map)(f.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,a.map)(m(),(e=>e.join(c.platformName+"-"+s.default.arch())))}async function g(e){if(c.isWin&&(e=(0,o.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,h.pathIfExists)(m()?.join("bin",e))),(()=>(0,h.pathIfExists)(m()?.join(e))),(()=>(0,h.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,h.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,n.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,n.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,n.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,n.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const s=r(i(44652)),n=i(19851),a=i(22573),o=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,o.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,a.blank)(t.file))throw new Error("can't touch blank path");const r=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const o=(0,n.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await o())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await o())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(s.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(n){if(!i||"ENOENT"!==n.code)throw n;await(0,c.thenOrTimeoutError)(s.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},79847:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.trashOrUnlinkFileUri=t.trashOrUnlinkFileUris_=void 0;const o=n(i(51455)),l=a(i(49378)),u=i(40958),c=i(22573),d=i(13538),h=i(83104),f=i(45255),m=i(31562),p=i(98314),g=i(34102),y=i(28874),w=i(45200),v=i(16287),b=i(74128),S=i(84258),P="fs.Trash";async function M(e){const t=Date.now(),i=y.Settings.commandTimeoutMs.valueOrDefault,r=(0,c.toNotBlank)(e.nativePath)??await(0,d.thenOrTimeout)((0,w.uri2nativePath)(e.uri,e.mountpoint),i);if((0,c.blank)(r)||r===h.Timeout)return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not convert URI to native path",path:e.uri,elapsedMs:Date.now()-t}),{uri:e.uri,unlinked:!1};const s=await(0,v.statMaybe)(r);if(null==s)return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: no such file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(!s.isFile())return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: not a file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(y.Settings.trySoftDeletes.valueOrDefault)try{if(await(0,d.thenOrTimeoutError)((0,l.default)(r,{glob:!1}),i),await function(e){return(0,m.untilTrue)((async()=>null==await(0,v.statMaybe)(e)),{timeoutMs:f.ShortCommandTimeoutMs})}(r))return(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Moved file to trash",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0};(0,S.logger)().warn("soft-delete("+r+") didn't seem to work: the file is still there?")}catch(e){(0,b.syncReport)().onProgress({from:P,state:"note",details:"Failed to soft-delete file to trash: "+(0,p.errorToS)(e),path:r,elapsedMs:Date.now()-t}),(0,S.logger)().warn("Tried to soft-delete, but that failed. We'll try to hard-delete.",{error:e})}try{return await(0,d.thenOrTimeoutError)(o.unlink(r),i),(0,g.ee)().emit("fileChanged",r),(0,S.logger)().info("unlink("+r+") successful"),(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Permanently deleted file",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0}}catch(i){return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not move file to trash or delete: "+(0,p.errorToS)(i),path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!1}}}t.trashOrUnlinkFileUris_=async function(e){const t=[];for(const{uri:i,mountpoint:r}of(0,u.uniqBy)(e,(e=>e.uri)))try{t.push(await M({uri:i,mountpoint:r}))}catch(e){t.push({uri:i,unlinked:!1,error:e})}return t},t.trashOrUnlinkFileUri=M},70854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryUidStore=t.LibraryUIDStore=t.SystemUIDStore=t.UIDStore=t.mkuid=void 0;const r=i(19851),s=i(41400),n=i(55835),a=i(92782),o=i(37805),l=i(46292),u=i(34102),c=i(55222),d=i(28874),h=i(87128),f=i(95696);function m(){return(0,a.safeRandomUid)({radix:c.TokenRadix,chars:24,splitEveryN:4})}t.mkuid=m;class p extends h.JsonFileStore{constructor(e,t){super(e.join("."+t+"-uid.json"),(()=>({uid:m(),version:o.version,type:this.type,createdAt:Date.now()})),(e=>e.hide())),this.rootDir=e,this.type=t,this.readUid_=(0,r.lazy)((async()=>(await this.read_())?.uid))}}function g(e=d.Settings.libraryDir.valueOrDefault){return(0,n.map)(f.PosixFile.forMaybe(e),(e=>new p(e,"library")))}t.UIDStore=p,t.SystemUIDStore=(0,r.lazy)((()=>(0,n.map)((0,l.configDir)(),(e=>new p(f.PosixFile.for(e),"system"))))),t.LibraryUIDStore=(0,r.lazy)(g),t.libraryUidStore=g,(0,s.later)((()=>{(0,u.ee)().on("clearCache",(()=>{t.SystemUIDStore.unset(),t.LibraryUIDStore.unset()})),d.Settings.libraryDir.watchLater((()=>t.LibraryUIDStore.unset()))}))},84258:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const a=n(i(51455)),o=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,o.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const r of(0,l.toA)(e))try{null!=r&&await a.unlink((0,c.toNativePath_)(r))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+r,{error:e})}}},5545:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const s=r(i(76760)),n=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,n.toS)(i.path??s.default.sep)}},70257:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),s=i(45255),n=i(17217);t.WipTimeoutMs=s.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const a=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(a,"")},t.isWip=function(e){return a.test((0,n.basename)(e)??"")}},58722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),s=i(22911);class n extends r.Writable{constructor(e){super(e),this.deferred=new s.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=n},73428:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(51926),o=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=n.default.dirname(e);await(0,c.mkdirp_)(i),await s.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=n.default.dirname(e);(0,c.mkdirpSync_)(i),s.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,a.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))}},13047:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const s=r(i(73024)),n=i(76760),a=i(46466),o=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),w=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function v(e,t){return(await S(e,t)).toString()}async function b(e,t,i){const r=[],n=[s.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?n.push((0,o.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&n.push((0,o.createBrotliDecompress)().on("error",(e=>r.push(e)))),n.push(t),await(0,a.pipeline)(n),(0,u.isNotEmpty)(r))throw new f.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function S(e,t){const i=new y.WritableToBuffer;return await b(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await S(e))}async function M(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,n.parse)(e).dir),await(0,a.pipeline)(new g.ReadableBuffer(i),(0,o.createGzip)(),s.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=v,t.zcat=async function(e,t){try{return v(e,t)}catch(t){return void w().warn("zcat failed to read "+e,t)}},t.zpipe_=b,t.zCopyToBuffer_=S,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void w().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=M,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await M(e,t)}catch(t){w().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},63664:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRemoteOrLocalHealthSummarySync=t.getRemoteOrLocalHealthSummary=t.getLocalHealthSummary=t.getRemoteHealthSummary=void 0;const r=i(22573),s=i(45599),n=i(41400),a=i(50268),o=i(98553),l=i(50213),u=i(23560),c=i(45255),d=i(5916),h=i(28874),f=i(34238),m=i(51140),p=i(4988),g=i(18454),y=(0,s.defer)((()=>(0,l.mkLogger)("health.GetHealthSummary")));t.getRemoteHealthSummary=(0,d.lazyAsync)({later:async()=>{try{if((0,u.isWebService)())return;const e=await(0,p.get_)(f.URI.from({scheme:"http",authority:"127.0.0.1:"+h.Settings.httpPort.valueOrDefault,path:"/api/health"}),{timeoutMs:c.ShortCommandTimeoutMs}),t=(0,o.parseJSON_)(e.data);if(m.HttpStatusIs.ok(e.statusCode)&&(0,a.isHealthCheckSummary)(t))return"ready"===t.state&&(0,r.toNotBlank)(t.libraryDir)!==(0,r.toNotBlank)(h.Settings.libraryDir.valueOrDefault)&&(y().error("getHealthSummary(): libraryDir mismatch! Switching to that library directory...",{local:h.Settings.libraryDir.valueOrDefault,remote:t.libraryDir}),h.Settings.libraryDir.value=t.libraryDir),y().debug("getHealthSummary()",{response:e}),t;y().warn("getHealthSummary(): invalid response",{response:e})}catch(e){y().warn("Failed to get health check summary from web service",{error:e})}}}),t.getLocalHealthSummary=(0,d.lazyAsync)({later:()=>g.HealthCheck.awaitSettled()}),(0,n.later)((()=>{h.Settings.healthCheckIntervalMs.watch((e=>{t.getRemoteHealthSummary.setTTL(e),t.getLocalHealthSummary.setTTL(e)}))})),t.getRemoteOrLocalHealthSummary=async function(){return await(0,t.getRemoteHealthSummary)()??await(0,t.getLocalHealthSummary)()},t.getRemoteOrLocalHealthSummarySync=function(){return t.getRemoteHealthSummary.syncValue()??t.getLocalHealthSummary.syncValue()}},87408:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStatusSummary=void 0;const r=i(63870),s=i(18454),n=i(89035),a=i(82638);t.getStatusSummary=async function(e={}){return(0,a.summarizeHealthChecks)({healthChecks:[...s.HealthCheck.allCritical(),(0,n.memoryHealthCheck)()],errors:s.HealthCheck.lastErrors(),timeoutMs:(0,r.commandTimeoutMs)(),skipPending:!0,...e})}},18454:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,w,v,b,S,P,M=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},_=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const T=i(19851),E=i(40958),D=i(76790),k=i(41400),x=i(50357),F=i(26905),C=i(50268),A=i(55835),I=i(68708),O=i(30976),L=i(51926),R=i(13538),N=i(42279),B=i(59455),j=i(54993),z=i(48884),V=i(89788),W=i(22454),U=i(50213),q=i(69591),H=i(22911),G=i(99331),$=i(5916),J=i(42638),K=i(77740),Z=i(98314),Y=i(70025),X=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),re=i(21525),se=i(82638),ne=(0,T.lazy)((()=>(0,U.mkLogger)("health.HealthCheck")));class ae{static traceLater_(e,t){const i=new H.Deferred(e);i.catch((t=>{M(this,s,"f",l).push(e+": failed: "+(0,Z.errorToS)(t)),this.onResultChange()})),M(this,s,"m",o).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return M(this,s,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){M(this,s,"f",l).push((0,L.isString)(e)?e:(0,Z.errorToS)(e)),this.onResultChange()}static lastErrors(){return M(this,s,"f",l).toA()}static addLoadingMsg(e){M(this,s,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,E.compact)((0,B.toA)(e)).map(j.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return ne().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:M(this,s,"f",h).entriesByCountDesc()}),(0,A.map)((0,z.leastBy)(e,(e=>[M(this,s,"f",h).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=M(this,s,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,A.map)(e,(e=>M(this,s,"f",h).incr(e.msg))),ne().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return X.Settings.skipHealthCheckIds.envValue=t,s.reset()}static findById(e){return M(this,s,"f",f).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,C.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=M(this,s,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=s.summary();if(e.pendingCount>0){const t=await Promise.all(s.testResultsCritical());e=s.summaryFromResults(t),ne().info("awaitSettled(): summary result",{summary:e,results:t})}return ne().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){s.summary.unset()}static reset(){if((0,G.ending)())ne().warn("Rejecting reset() when ending()",(0,F.shortStack)());else{this.onResultChange(),M(this,s,"f",l).clear(),M(this,s,"f",d).clear(),M(this,s,"f",h).clear(),M(this,s,"f",c).clear(),this.summary.clear(),_(this,s,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new s(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return M(this,s,"f",f).push(i),this.all.unset(),i}constructor(e,t,i,n,o,l,u,c,d,h,f,m,S,P=Q.commandTimeoutMs){r.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=n,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=h,this.errorLinks=f,this.onReset=m,this.ttlMs=S,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),v.set(this,(0,T.lazy)((async()=>{await M(this,p,"f").prior(),(0,x.eql)(M(this,g,"f"),M(this,r,"m",w).call(this))||(this.onReset?.(),await this.refresh(),M(this,v,"f").unset())}))),this.refresh=(0,T.lazy)((()=>new H.Deferred("refresh").observe((async()=>{await M(this,p,"f").prior();const e=M(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,U.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[C.HealthCheckSections.ordinal(this.section),l??999,this.id],_(this,p,(0,$.lazyAsync)({desc:this.pendingMsg,later:()=>M(s,s,"f",a).enqueue({name:this.id,l:()=>M(this,r,"m",b).call(this,o)}),ttlMs:S}),"f"),this.isCritical&&M(this,p,"f").watchLater({onChange:s.onCriticalResult,onError:s.onCriticalResult});for(const e of this.settings)X.Settings[e].watchLater((()=>M(this,v,"f").call(this)))}isStale(){return M(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return M(this,p,"f").settledCount()}reset(){return M(this,p,"f").unset(),this.onReset?.(),_(this,g,{starting:!0},"f"),this}setTTL(e){M(this,p,"f").setTTL(e)}result(){return M(this,p,"f").call(this)}isSkipped(){return X.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return M(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return M(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??M(this,r,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function oe(e){if((0,E.isEmpty)(e))return{};const[t,i]=(0,z.partition)(e,(e=>"button"===e.type||"POST"===e.method)),r={};return(0,E.isNotEmpty)(i)&&(r.links=(0,E.uniqBy)(i)),(0,E.isNotEmpty)(t)&&(r.buttons=(0,E.uniqBy)(t)),r}t.HealthCheck=ae,s=ae,p=new WeakMap,g=new WeakMap,y=new WeakMap,v=new WeakMap,r=new WeakSet,o=function(){return(0,E.filterInPlace)(M(this,s,"f",n),(e=>!e.isPending)),M(this,s,"f",n)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=ne().tap({level:"warn",msg:"#summary()",result:(0,se.summarizeHealthChecksSync)({errors:M(this,s,"f",l),skipPending:M(this,s,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&_(this,s,!0,"f",u),i.state!==M(this,s,"f",c).last?.state&&M(this,s,"f",c).push({state:i.state,ts:Date.now()}),i},w=function(){return(0,I.fromEntries)(this.settings.map((e=>[e,X.Settings[e].valueOrDefault])))},b=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();ne().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,F.shortStack)()}),_(this,g,M(this,r,"m",w).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,k.delay)((0,O.randomInt)(.3*i,.7*i)),this.isSkipped())return M(this,r,"m",S).call(this,{test:{level:"disabled",msg:["Disabled by "+X.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const s=await(0,R.thenOrTimeoutError)(e(),i);return M(this,r,"m",S).call(this,{test:s,elapsedMs:Date.now()-t})}catch(e){return M(this,r,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},S=function({test:e,src:t="#toResult",elapsedMs:i}){var r,n;const a=s.normalizeMsg(e.msg),o=e.level??((0,j.toS)(a).toLowerCase().includes("error")?"error":(0,j.toS)(a).toLowerCase().includes("warn")?"warn":"ok"),l=(0,E.compact)([...e?.links??("ok"===o||"pending"===o?this.okLinks:"warn"===o?this.warnLinks:"no-library"===o?this.noLibraryLinks:"error"===o?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:o,msg:a,elapsedMs:i,...oe(l)};return u.runCount=(_(this,y,(n=M(this,y,"f"),r=n++,n),"f"),r),(0,G.ending)()?u:this.logger.tap({level:re.HealthCheckLevelToLogLevel[o],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const s=(0,L.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,A.map)(e,Z.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,Y.isFatalError)(e)&&s.toLowerCase().includes("warn")?"warn":"error"),M(this,r,"m",S).call(this,{test:{msg:s,level:t},src:"#toErrorResult",elapsedMs:i})},n={value:[]},a={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},h={value:new W.CountingSet},f={value:[]},ae.all=(0,T.lazy)((()=>Object.freeze((0,D.sortBy)(M(s,s,"f",f),(e=>e.sortBy))))),ae.onCriticalResult=(0,q.debounce)((()=>{ne().info("onCriticalResult()",s.summary.refresh())}),250),ae.summary=(0,T.lazy)((()=>M(s,s,"m",m).call(s))),ae.resetDebounced=(0,q.debounce)((()=>s.reset()),50)},85021:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckCommand=void 0,t.HealthCheckCommand="--health"},33866:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const r=i(82950),s=i(50268),n=i(459),a=i(23560),o=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,a.isPermaService)(t)&&(e===s.HealthCheckLevels.error||(0,a.isLibraryRequiredService)(t)&&e===s.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,o.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,r.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new n.UnreachableCaseError(e)}}},42495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const r=i(40958),s=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,r.compact)([(0,s.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},89035:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const s=r(i(48161)),n=i(19851),a=i(82950),o=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),h=i(23560),f=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:r}){return{level:i,msg:[e+" from "+(0,h.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,a.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(r,2)])]}}function g(){return s.default.totalmem()f.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(f.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*f.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,n.lazy)((()=>"ok"!==g().level),o.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:o.minuteMs,later:async()=>g()})))},82638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const r=i(40958),s=i(42659),n=i(45599),a=i(41400),o=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),h=i(23560),f=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,n.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function w({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:r}){const s=new Map;for(const e of t??[])s.set(e.id,e);if(null!=e)for await(const t of f.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),r))s.set(t.id,t);return[...s.values()]}t.summarizeHealthChecks=async function(e){return b({...e,healthCheckResults:await w(e)})};const v=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:h.serviceName.prior()??process.title}})));function b(e){const t=(0,r.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),n=i.length,a=i.map((e=>e.id)),c=t.length-n,d=0===n,h=(0,r.uniq)((0,r.compactBlanks)(e.errors));if(h.length>0)return{...v(),level:l.HealthCheckLevels.error,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",h.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const s=t.filter((e=>e.level===i));if((0,r.isNotEmpty)(s)){const e=t.filter((e=>!s.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+s.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...v(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:a,pendingCount:n,settledCount:c,linkIds:s.map((e=>e.id)),ts:Date.now(),msg:(0,r.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,o.flatten)([...s,...e].map((e=>e.msg[0])))])},meta:{checks:s.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...v(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,s.fmtDateShort)(Date.now())]}})}(0,a.later)((()=>{m.Settings.libraryDir.watchLater((()=>v.unset()))})),t.summarizeHealthChecksSync=b},95242:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviewBuilder=t.mkPreviewAssetFile_=void 0;const a=i(57975),o=i(40958),l=i(22573),u=i(33374),c=i(98553),d=i(55835),h=i(68708),f=i(48884),m=i(50213),p=i(92434),g=i(54296),y=i(51837),w=i(57159),v=i(83278),b=i(95696),S=i(62105),P=i(84258),M=i(38156),_=i(69589),T=i(28874),E=i(47783),D=i(29990),k=i(16047),x=i(42725),F=i(4192),C=i(32876),A=i(50961),I=i(181);t.mkPreviewAssetFile_=async function(e){const t=await(0,E.readTags)(e);return{nativePath:e.nativePath,fileSize:await e.size(),mtime:await e.thisOrSidecareMaxMtimeMs(),uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath,mimetype:t.mimetype,rotation:t.rotation,...t.dimensions,sha:await e.sha_()}};class O{constructor(e,t,i){r.add(this),this.ap=e,this.assetFiles=t,this.logger=(0,m.mkLogger)("AssetPreviewBuilder("+e.assetId+")"),this.ctx=(0,_.forceContextOrSetting)(i),this.assetFiles=(0,p.sortAssetFiles)(this.assetFiles)}[(r=new WeakSet,a.inspect.custom)](){return{ctor:"AssetPreviewBuilder",assetId:this.ap.assetId,assetFiles:this.assetFiles}}async build_(){this.logger.info("build_(): asset file candidates:",this.assetFiles.map((e=>(0,h.pick)(e,"id","uri"))));const e=[];for(const t of this.assetFiles){const i=b.PosixFile.forMaybe(await(0,g.getAssetFileNativePath)(t));if(null!=i){{const e=await(0,S.whyRejectFile)(i);(0,l.blank)(e)||this.logger.info("skipping: rejected",{pf:i,whyRejected:e})}try{return await n(this,r,"m",s).call(this,i,t)}catch(i){e.push(i),this.logger.warn("Failed to set shown file to ",{best:t,error:i})}finally{this.ap.parent.clear()}}else this.logger.info("skipping: failed to get PosixFile",{af:t}),e.push(new Error("Cannot get path from URI "+(0,c.stringify)((0,h.pick)(t,"uri","mountpoint","nativePath"))))}return this.logger.throw("Cannot build previews: none of the files are valid",{doNotSend:!0,retriable:!1,files:this.assetFiles.map((e=>e.nativePath??e.uri)),causes:e})}async infoForBest_(e,t){await(0,I.throwIfInvalidFile_)(e);const i=await e.size(),r=await e.thisOrSidecareMaxMtimeMs();if(this.logger.debug("_build",{filesize:i,mtime:r,best:t.uri}),null==i||null==r)return this.logger.throw("build(): missing stat info for best file",{ignorable:!0,best:t});const{uri:s,width:n,height:a,sha:l,mimetype:u}=t;if(null==s||null==n||null==a||null==u||null==l)return this.logger.throw("build(): internal error: missing fields for best file "+e,{ignorable:!0,best:t});const c=(0,D.fitSizes)(t,t.mimetype);return{assetId:t.assetId,assetFileId:t.id,uri:s,uris:this.assetFiles.map((e=>e.uri)),path:e.nativePath,mtime:r,filesize:i,width:n,height:a,sha:l,mimetype:u,fitSizes:c.map((([,e])=>e.name)).join(","),sqWidths:(0,o.compact)(x.ImageSize.sq().map((e=>e.outputSize(t)?.width))),fitWidths:c.map((([e])=>e.width))}}async priorIfValid_(e,t){if(this.ctx.forceSync||this.ctx.forceRebuildPreviews)return;const i=await this.ap.readInfo.refresh();if(null!=i){if(i.assetId!==t.assetId)throw new y.InternalError("priorIfValid_(): mismatched asset IDs for "+e+": "+(0,c.stringify)({priorInfo:i,info:t}));const r=i.fitSizes.split(","),s=t.fitSizes.split(",");if(null!=i.sha&&i.sha===t.sha&&i.rotation===t.rotation&&(0,D.equivalentFitSizes)(r,s)){const n=(0,D.fitSizes)(e,e.mimetype),a=(0,o.diff)(r,s);if((0,o.isNotEmpty)(a)){this.logger.info("priorIfValid_(): removing previews that aren't required anymore.",{leftovers:a});for(const e of a){const t=n.find((([,t])=>t.name===e));if(null==t)this.logger.warn("priorIfValid_(): Failed to clean up: missing fit size",{fitsize:t,fits:n});else{const e=this.ap.fileForWidth(t[1].reducer.name,t[0].width);this.logger.debug("priorIfValid_(): unlinking unwanted preview "+e,{fitsize:t}),await e.unlink("warn")}}}return this.logger.debug("priorIfValid_(): SHA and rotation match, and previews exist.",{info:t,priorInfo:i}),await this.ap.writeInfo(t),t}}}}t.AssetPreviewBuilder=O,s=async function(e,t){this.logger.info("_build("+e+")",{uri:t.uri});const i=await this.infoForBest_(e,t),r=await this.priorIfValid_(t,i);if(null!=r)return r;const s=new M.PushProgressObserver({path:e.nativePath,op:"Building previews"},x.ImageSize.sq().length+x.ImageSize.fit().length);if(this.logger.debug("Rebuilding all previews from "+t.uri,{assetId:t.assetId,info:i}),null==await this.ap.parent.mkdirp())throw new Error("build(): Failed to create previews directory, "+this.ap.parent+" for "+t);const n=await this.ap.existingFiles(),a=await(0,A.sharpReadable_)({src:e,minDim:x.ImageSize.largestFit().max});if(null==a)throw new w.WrappedError("AssetPreviewBuilder.build(): "+t.uri+", "+e.nativePath+", is not readable by sharp.",{retriable:!1});const o=(0,A.toSharp)(a);if(t.mimetype.startsWith("image/")&&!(0,k.isHeifMimeType)(t.mimetype)&&null!=t.rotation&&0!==t.rotation&&(o.rotate(t.rotation),this.logger.debug("build(): rotating "+t.rotation+"°")),(0,v.isBaseFile)(a)&&a.desc.toLowerCase().includes("thumbnail"))try{o.trim(1)}catch{}const l=(0,D.fitSizes)(t,t.mimetype),c=[],m=[];let p,g;const y=x.ImageSize.largestSq(),b=(0,f.leastBy)(l,(([e,t])=>(0,d.map)(y.outputSize(e),(()=>t.megapixels()))))?.[1].name,S=(0,h.pick)(t,"width","height");{let e=o.clone(),t=S;for(const[i,r]of l){const n=Date.now(),a=t,o=this.ap.fileForWidth(r.reducer.name,i.width).wip();e=r.resize(i,e),t=i,r.name===b&&(g=e.clone(),p=i),(0,u.dmegapixels)(i)>=1&&r.reducer===C.Fit&&T.Settings.includePreviewTags.valueOrDefault&&m.push(o),await r.toJpeg({path:o.nativePath,sh:e,outputSize:i}),s.onProgress(),this.logger.debug("resize("+r.name+") "+(0,u.fmtDim)(a)+" -> "+(0,u.fmtDim)(i)+" in "+(Date.now()-n)+" ms"),c.push(o)}}{null==g?(this.logger.debug("square resize(): resorting to ",{origDim:S,bestFitNameForSq:b}),g=o,p=S):this.logger.debug("square resize(): using to ",{sqDim:p,bestFitNameForSq:b});let e=!1;for(const t of x.ImageSize.sq()){const i=Date.now(),r=p,n=t.outputSize(p??S);if(null==n){this.logger.debug("skipping square output for "+t.max);continue}e||(n.position=T.Settings.squareThumbStrategy.valueOrDefault,e=!0),this.logger.debug("Applying ",{outputSize:n});const a=this.ap.fileForWidth(t.reducer.name,n.width).wip();t.resize(n,g),p=n,await t.toJpeg({path:a.nativePath,sh:g,outputSize:n}),s.onProgress(),c.push(a),this.logger.debug("resize("+t.name+") "+(0,u.fmtDim)(r)+" -> "+(0,u.fmtDim)(n)+" in "+(Date.now()-i)+" ms")}}try{await(0,F.includePreviewTags_)(e,m).catch((t=>{this.logger.warn("Failed to restore metadata tags into previews for "+e,{error:t})}));const t=new Set(n.map((e=>e.nativePath)));for(const e of c){const i=await e.unwip_();t.delete(i.nativePath)}await(0,P.unlink)(t),await this.ap.writeInfo(i),this.logger.debug("Previews unwipped and info written",{info:i})}catch(t){throw await(0,P.unlink)(c),new w.WrappedError("Failed to create previews from "+e,{cause:t,path:e.nativePath,fatal:!1})}return i}},35721:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkDownloadableTitle=t.previewToDownloadable=t.extractPreviewInfo=void 0;const r=i(75761),s=i(33374),n=i(11371),a=i(55835),o=i(31586),l=i(56519),u=i(29882),c=i(50213),d=i(97352),h=i(81168),f=i(89782),m=(0,c.mkLogger)("extractPreviewInfo");function p(e,t,i,r){return`Download ${t} ${e.ext} ${i} (${(0,s.fmtDim)(r)})`}t.extractPreviewInfo=function(e,t){const i=t.posixPathFrom(e).replace(/\//g,"").split("-"),r=(0,o.toInt)(i[0]),s=n.ReducerNames.getCI(i[1]),a=(0,d.extractInt)(i[2]);return(0,o.gt0)(r)?{file:t,assetId:r,reducer:s,width:a}:void m.warn("Failed to extract preview info",{file:t,previewsRoot:e,arr:i,assetId:r,reducer:s,width:a})},t.previewToDownloadable=async function(e,t){return(0,a.map2)(t.assetId,t.width,((i,a)=>(0,l.thenMap)((0,f.dimensions)(t.file),(o=>{const l=(0,s.dimToSize)(o);return{size:l,basename:`${(0,h.stripSuffix)(e,(0,u.extname)(e))}-${l}${t.file.ext}`,title:p(t.file,l,"image",o),description:`Download ${l}`,details:`(${(0,s.fmtDim)(o)} ${t.file.ext})`,href:(0,r.assetImgLink)({assetId:i,reducer:n.ReducerNames.fit,width:a})}}))))},t.mkDownloadableTitle=p},16524:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviews=void 0;const a=i(19851),o=i(40958),l=i(75761),u=i(11371),c=i(68708),d=i(39926),h=i(58939),f=i(48884),m=i(50213),p=i(81168),g=i(56519),y=i(38835),w=i(70417),v=i(35721);t.AssetPreviews=class{constructor(e,t){r.add(this),this.previewsRoot=e,this.readInfo=(0,a.lazy)((()=>this.infoJson().readJson("debug"))),this.logger=(0,m.mkLogger)("AssetPreviews(assetId:"+(0,h.id2id)(t)+")"),this.assetId=(0,h.id2id)(t);const i=(0,d.leftPad)(this.assetId,8,"0"),s=(0,p.splitEvery)(i,3);this.basename=s.pop()+"-",this.parent=e.join(...s)}parentNotExists(){return this.parent.clear().notExists()}async existingFiles(){return await this.parent.clear().childFiles((e=>e.base.startsWith(this.basename)))??[]}async existingJpgs(){return(await this.existingFiles()).filter((e=>".jpg"===e.ext))}async previewInfos(){return(0,g.sortByAsync)({name:"img.AssetPreviews.previews",arr:n(this,r,"m",s).call(this),f:e=>e?.file.size()})}async deleteAll(){const e=await this.existingFiles();if(e.length>20)throw new Error("deleteAll(): rejected: > 20 existing files?!"+y.InternalErrorFlag);for(const t of e)await t.unlink();return e}fileForSuffix(e){return this.parent.join(this.basename+e)}mp4(){return this.fileForSuffix("video.mp4")}infoJson(){return this.fileForSuffix("info.json")}writeInfo(e){return this.readInfo.unset(),this.infoJson().writeJson((0,c.pick)(e,"assetId","assetFileId","uri","uris","path","mimetype","width","height","mtime","filesize","sha","rotation","fitSizes","fitWidths"))}fileForWidth(e,t){return this.fileForSuffix(e+"-w"+t+".jpg")}async filesForReducer(e){const t=this.basename+e+"-";return this.logger.tap({msg:"filesForReducer("+e+")",result:(await this.existingFiles()).filter((e=>e.base.startsWith(t)))})}async smallestFileForReducer(e){return(0,f.leastBy)(await this.filesForReducer(e),(e=>(0,v.extractPreviewInfo)(this.previewsRoot,e)?.width))}async largestFileForReducer(e){return(0,f.greatestBy)(await this.filesForReducer(e),(e=>(0,v.extractPreviewInfo)(this.previewsRoot,e)?.width))}async widths(e){const t=await this.readInfo(),i=e===u.ReducerNames.sq?"sqWidths":"fitWidths",r=t?.[i];if(!(0,o.isEmpty)(r))return r;const s=(0,o.compact)((await this.previewInfos()).filter((t=>t.reducer===e)).map((e=>e.width)));return null!=t&&(t[i]=s,await this.writeInfo(t)),s}async posterLink(){const e=await this.widths(u.ReducerNames.fit);return(0,l.assetImgLink)({assetId:this.assetId,reducer:u.ReducerNames.fit,width:(0,w.max)(e)})}async imgAttrs(e,t=!1,i=!0){if(t||e!==u.ReducerNames.sq){const t=e===u.ReducerNames.fit?await this.readInfo():void 0;return(0,l.assetImgAttrs)({assetId:this.assetId,reducer:e,widths:await this.widths(e),lazyLoad:i,af:t})}return(0,l.assetSqImgAttrs)({assetId:this.assetId,lazyLoad:i})}},r=new WeakSet,s=async function(){const e=[];for(const t of await this.existingFiles()){const i=(0,v.extractPreviewInfo)(this.previewsRoot,t);null!=i&&e.push(i)}return e}},52086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},33106:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.dctPixels=t.dctHashCIELAB=t.dctHash=void 0;const s=r(i(9288)),n=i(96249),a=i(85810),o=32,l=function(e){const t=new Array(32);for(let e=1;e<32;e++)t[e]=1;return t[0]=1/Math.sqrt(2),t}(),u=function(e){const t=new Array(32);for(let e=0;e<32;e++){t[e]=new Array(32);for(let i=0;i<32;i++)t[e][i]=Math.cos((2*e+1)/64*i*Math.PI)}return t}();function c(e){const t=new Array(o);for(let i=0;is?1:0);return n}t.dctHash=async function(e){return c(await e.greyscale().resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer())},t.dctHashCIELAB=async function(e){const t=await e.resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer(),i=(0,a.rgb2labArray)(t);return(0,n.flatten)(i.map(c))},t.dctPixels=c},86580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(21605),o=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,n.gt0)(e.width)&&(0,n.gt0)(e.height)?(0,n.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,s.dmegapixels)(e.dimensions):(0,n.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,n.lt)(e.width,t.width)&&(0,n.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,n.lte)(e?.width,t?.width)&&(0,n.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,n.lt)(e.width,t.width)||(0,n.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,r.compact)((0,o.toS)(e).split(/[x×]/).map((e=>(0,n.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,r=Math.round(Math.sqrt(t*i));return{width:r,height:Math.round(r/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const r=u(e,i);return null==r?[]:a.Rotations.filter((e=>u(c(t,e),i)===r))}},89782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(56519),o=i(1078),l=i(5733),u=(0,r.lazy)((()=>(0,n.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,s.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,a.thenMap)((0,o.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},29990:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.equivalentFitSizes=t.fitSizes=void 0;const r=i(40958),s=i(33374),n=i(16170),a=i(42725),o=[a.ImageSize.QVGA,a.ImageSize.QQVGA];function l(e){return"qhd"===e?"wvga":"uhd"===e?"uhd4k":e}t.fitSizes=function(e,t){const i=a.ImageSize.fit(),r=[];let l=(0,n.isMimeTypeSupportedByBrowser)(t)?e:void 0;for(let t=0;t3||(0,s.dmegapixels)(a)-(0,s.dmegapixels)(l)>2.5)&&(l=a,r.push([a,n])))}return r},t.equivalentFitSizes=function(e,t){return(0,r.includesAll)((0,r.compactBlanks)(e).map(l),(0,r.compactBlanks)(t).map(l))}},277:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const r=i(22573),s=i(41400),n=i(54993),a=i(19851),o=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),h=i(78330),f=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),w=(0,a.lazy)((()=>(0,o.mkLogger)("img.Heif")));function v(e){return(0,n.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function b(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,a.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,r.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){w().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,r.blank)(e))return void w().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=v(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,r.blank)(i)&&(0,l.hasApt)()){const t=await(0,h.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,r.blank)(i)&&(0,f.hasPacman)()&&(i=(await(0,f.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,r.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void w().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=v,t.isHeifSupported=b,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await b()?(0,g.heif2png_)(e):void w().throw("HEIF support is missing",{src:e.nativePath})},(0,s.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(41400),o=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),h=i(28874),f=i(89782),m=i(13940),p=(0,r.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,s.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,r.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:h.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?n.minuteMs:void 0),e})),(0,a.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,f.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(h.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:h.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(o.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const r=i(22573),s=i(54993),n=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,r.blank)(e)&&n.test((0,s.toS)(e))}},13940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),s=i(19851),n=i(42659),a=i(59455),o=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),w=i(55222),v=i(63870),b=(0,s.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,s.lazy)((()=>(S(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const S=(0,s.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const s=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const n=s.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await n.mkdirp_(),await n.utimes();const a=n.join(i+r);return b().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:a}),a}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,a.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+w.TokenRadix.randomChars(2),w.TokenRadix.randomChars(16)+(0,o.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*n.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const s=await P(e,t,i);return await s.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,v.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),s}catch(r){return b().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},48368:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashDim=t.toImageHash=t.isImageHash=t._imageHash_=t.imageHash_=t.imageHash=t.maxPerBits=void 0;const s=r(i(9288)),n=i(19851),a=i(40958),o=i(22573),l=i(42659),u=i(33374),c=i(56038),d=i(85810),h=i(76490),f=i(40401),m=i(86758),p=i(85434),g=i(96706),y=i(38835),w=i(88561),v=i(95696),b=i(17217),S=i(50213),P=i(23624),M=i(28874),_=i(12089),T=i(16170),E=i(1078),D=i(33106),k=i(86580),x=i(78011),F=i(50961);t.maxPerBits=function(e){return Math.floor(52/e)};const C=(0,n.lazy)((()=>(0,S.mkLogger)("img.ImageHash")));t.imageHash=async function(e){try{return await(0,t.imageHash_)((0,b.toNativePath_)(e))}catch(t){return void C().warn("imageHash() failed for "+e,t)}};const A=(0,n.lazy)((()=>new w.FileCache({name:"img.imageHash",timeoutMs:l.minuteMs})));async function I(e){const t=v.PosixFile.for(e),i=await(0,E.extractSizeInfoFromFile)(t);if(null==i)throw new Error("Failed to read dimensions for "+e+y.NonFatalErrorFlag+y.DoNotSendErrorFlag);const r=(0,k.fitToResolution)(i.dimensions,Math.round(M.Settings.dominantColorPixels.valueOrDefault)),n=await(0,F.sharpReadable_)({src:t,minDim:r});return(0,c.time)("img.imageHash",(()=>async function({file:e,readable:t,sizeInfo:i}){const r=(0,S.mkLogger)("ImageHash("+e+")");if(null==t)return r.throw("Cannot build readable stream");const n=(0,k.fitToResolution)(i.dimensions,M.Settings.dominantColorPixels.valueOrDefault);if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-orig.jpg";await(0,F.toSharp)(t).jpeg().toFile(i),console.log({out:i,readable:t})}let a=(0,F.toSharp)(t).removeAlpha();(0,T.isVideoMimeType)(t.mimetype)||(a=a.rotate(i.rotation)),(0,u.dmegapixels)(i.dimensions)<.1&&(a=a.trim({background:"#000",threshold:0})),a=a.resize({fit:s.default.fit.outside,...n,withoutEnlargement:!0});const{data:o,info:l}=await a.raw().toBuffer({resolveWithObject:!0});if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-"+l.width+"w.jpg";await(0,s.default)(o,{raw:{...l,channels:3}}).jpeg().toFile(i),console.log({out:i,rgbInfo:l,readable:t})}const c=(0,d.rgb2labTriplets)(o),h=(0,f.extractDominantColors)(c),p=(0,m.labsAreGreyscale)(c),y=()=>(0,s.default)(o,{raw:{...l,channels:3}}),w=await(p?x.meanDiffHash:x.meanDiffHashCIELAB)(y()),v=await(p?D.dctHash:D.dctHashCIELAB)(y());return{meanHash:(0,P.b64encodeBits)(w.meanHash),diffHash:(0,P.b64encodeBits)(w.diffHash),dctHash:(0,P.b64encodeBits)(v),dominantColors:h.dominantColors,dominantColorsDescription:h.description,dominantColorScore:h.dominantColorScore,isGreyscale:p,mimetype:(0,T.normalizeMimetype)(t.mimetype),...i.dimensions,rotation:i.rotation??0}}({file:t,readable:n,sizeInfo:i})))}function O(e){return null!=e&&(0,o.notBlank)(e.meanHash)&&(0,o.notBlank)(e.mimetype)&&(0,a.isNotEmpty)(e.dominantColors)}t.imageHash_=(0,_.shim1)({name:"img.imageHash",cache:A,impl:I}),t._imageHash_=I,t.isImageHash=O,t.toImageHash=function(e){if(null!=e){if(O(e))return e;if((0,p.isModeData)(e)){const t={...(0,p.omitModeData)(e),dominantColors:h.DominantColor.fromModeData(e)};if(O(t))return t}}},t.HashDim=8},80361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageHashSimilarity=t.isVerySimilarComparison=t.isVerySimilarImageHash=t.isSimilarImageHash=t.isVerySimilarImage=t.compareImageHashes=t.isSimilarImage=t.hammRatio=t.meanHashVariants=t.isGreyscaleMeanHash=t.labsCorr2=t.isImageHashComparison=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(38639),o=i(33374),l=i(57924),u=i(55835),c=i(31586),d=i(68708),h=i(39926),f=i(21605),m=i(48884),p=i(50213),g=i(97352),y=i(85810),w=i(3048),v=i(32848),b=i(82647),S=i(38812),P=i(70417),M=i(23624),_=i(28874),T=i(86580),E=i(48368),D=i(2090),k=(0,r.lazy)((()=>(0,p.mkLogger)("img.ImageHashComparison")));t.isImageHashComparison=function(e){return null!=e&&(0,E.isImageHash)(e.a)&&(0,E.isImageHash)(e.b)&&[e.imageCorr,e.colorCorr,e.aRotation].every(c.isNumber)},t.labsCorr2=function(e,t){const i=(0,s.sum)(e,(e=>(0,w.diffCIECorr)(e,(0,y.closestLab)(t,e))))+(0,s.sum)(t,(t=>(0,w.diffCIECorr)(t,(0,y.closestLab)(e,t)))),r=Math.max(e.length,t.length,i);return(r-i)/r};const x=/A{20}=?$/;function F(e){return null!=e&&((0,g.within)(7,12,e.length)||null!=e?.match(x))}function C(e,t,i=E.HashDim){const r=(0,M.b64decode)(e).toString(2).split("").map((e=>"1"===e?1:0)),s=i*i;for(;r.length%s!=0;)r.unshift(0);return r.length===s||t?r.slice(0,s):r.slice(0,s).map(((e,t)=>4*e+2*r[t+s]+r[t+2*s]))}function A({a:e,b:t,greyscale:i,dim:r=E.HashDim,rotationsToCheck:a}){if((0,n.blank)(e)||(0,n.blank)(t))return{hammRatio:0,bRotation:0};if(e===t)return{hammRatio:1,bRotation:0};const o=C(e,i,r),l=C(t,i,r);(0,s.isEmpty)(a)&&(a=[0]);const u=a.map((e=>({bRotation:e,hammRatio:(0,c.sigFigs)((0,g.hammRatioIntArrays)(o,(0,S.rotateSquareMatrix)(l,e),i?1:3),2)})));k().debug("hammRatio()",{results:u,rotationsToCheck:a});const d=(0,m.greatestBy)(u,(e=>[(0,c.sigFigs)(e.hammRatio,1),-f.Rotations.indexOf(e.bRotation)]));return{bRotation:d.bRotation,hammRatio:(0,c.sigFigs)(d.hammRatio,2)}}async function I(e,t,i="debug",r={}){return k().tap({msg:`isSimilarImage(${e},${t})`,level:i,result:L(await(0,E.imageHash)(e),await(0,E.imageHash)(t),r)})}function O(e,t,i={}){const r=(0,E.toImageHash)(e),s=(0,E.toImageHash)(t);if(null==r||null==s)return;const n=(0,a.isTrue)(i.capturedAtIsFuzzy),h=!(0,a.isTrue)(i.forceColor)&&((0,a.isTrue)(i.forceGreyscale)||(r.isGreyscale??F(r.meanHash))||(s.isGreyscale??F(s.meanHash))),f=A({a:r.meanHash,b:s.meanHash,greyscale:h,rotationsToCheck:i.rotationsToCheck??(0,T.validRotations)(r,s)}),m=A({a:r.diffHash,b:s.diffHash,greyscale:h,rotationsToCheck:[]}),p=A({a:r.dctHash,b:s.dctHash,greyscale:h,rotationsToCheck:[]}),g=(0,v.dominantColorCorrelation)(r.dominantColors,s.dominantColors);if(null==g)return void k().debug("imageHashCompare(): missing color correlation");const y=r.mimetype===s.mimetype,w=(0,T.aspectRatio)(r),S=(0,T.aspectRatio)((0,o.maybeDimSwap)(s,f.bRotation)),P=null!=w&&null!=S&&!(0,o.isCloseAspectRatio)(w,S);let M=0,x=0;n&&(x+=_.Settings.imageHashFuzzyDateDelta.valueOrDefault,M+=_.Settings.imageHashFuzzyDateDelta.valueOrDefault),y||(x+=_.Settings.imageHashDifferentMimetypesDelta.valueOrDefault,M+=_.Settings.imageHashDifferentMimetypesDelta.valueOrDefault),h&&(M+=_.Settings.imageHashGreyscaleDelta.valueOrDefault,x+=_.Settings.imageHashGreyscaleDelta.valueOrDefault);const C=R((M+(i.minImageCorr??_.Settings.minImageCoeffPct.valueOrDefault))/100),I=R((x+(i.minColorCorr??_.Settings.minColorCoeffPct.valueOrDefault))/100),O=[];P&&O.push(`aspect ratio mismatch (${(0,D.fmtAspectRatio)(w)} vs ${(0,D.fmtAspectRatio)(S)})`);const L=[],N=new b.Average;N.push(f.hammRatio),f.hammRatioN.push(e))),(0,u.map)(p?.hammRatio,(e=>N.push(e))),(0,c.lt)(m?.hammRatio,C)&&L.push("gradient"),(0,c.lt)(p?.hammRatio,C)&&L.push("DCT")),L.length>0&&O.push("different image content ("+(0,l.andList)(L)+")");const j=g>=I,z=j&&N.avg>=C;j||O.push("different dominant colors");const V={meanHashCorr:(0,c.sigFigs)(f.hammRatio,2),diffHashCorr:B?void 0:(0,u.map)(m,(e=>(0,c.sigFigs)(e.hammRatio,2))),dctHashCorr:B?void 0:(0,u.map)(p,(e=>(0,c.sigFigs)(e.hammRatio,2))),hashCorrAvg:N.avg,minImageCorr:C,imageCoeffDelta:M,colorCorr:(0,c.sigFigs)(g,2),minColorCorr:I,colorCoeffDelta:x,isGreyscale:h,bRotation:f.bRotation,aAspectRatio:w,bAspectRatio:S,isSimilar:z,whyNotSimilar:z?void 0:(0,l.andList)(O)};return k().info("compareImageHashes",{a:(0,d.pickCompact)(r,"uri","id","assetId"),b:(0,d.pickCompact)(s,"uri","id","assetId"),...V}),{a:r,b:s,...V}}function L(e,t,i){return O(e,t,i)?.isSimilar??!1}function R(e){return(0,c.sigFigs)((0,c.clamp)(0,1,e),3)}function N(e){return null!=e&&(0,c.gte)(e.meanHashCorr,.9)&&(0,c.gte)(e.colorCorr,.9)}t.isGreyscaleMeanHash=F,t.meanHashVariants=function(e,t=!1,i=E.HashDim){const r=(t=t||null!=e.match(x))?(0,h.padding)("0",2*i*i):"",s=C(e,t,i);return f.Rotations.map((e=>(0,M.b64encode)(BigInt("0b0"+(0,S.rotateSquareMatrix)(s,e).map((e=>e.toString(2))).join("")+r))))},t.hammRatio=A,t.isSimilarImage=I,t.compareImageHashes=O,t.isVerySimilarImage=async function(e,t,i="debug",r={}){return I(e,t,i,{rotationsToCheck:[0],...r,minImageCorr:.92,minColorCorr:.92})},t.isSimilarImageHash=L,t.isVerySimilarImageHash=function(e,t,i={}){return N(O(e,t,i))},t.isVerySimilarComparison=N,t.imageHashSimilarity=function(e,t){return(0,u.map)(O(e,t),(e=>(0,P.avg)([e.meanHashCorr,e.colorCorr])))}},42725:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ImageSize=void 0;const a=i(57975),o=i(19851),l=i(33374),u=i(12168),c=i(48884),d=i(28874),h=i(32876),f=i(5733);class m{static sq(){return n(this,r,"f",s).filter((e=>e.reducer===h.Square))}static largestSq(){return(0,c.greatestBy)(this.sq(),(e=>e.megapixels()))}static fit(){const e=d.Settings.previewResolutions.valueOrDefault;return n(this,r,"f",s).filter((t=>t.reducer===h.Fit&&e.includes(t.name)))}static largestFit(){return(0,c.greatestBy)(this.fit(),(e=>e.megapixels()))}static all(){return[...n(this,r,"f",s)]}constructor(e,t,i,a,l=!0){this.name=e,this.maxWidth=t,this.maxHeight=i,this.reducer=a,this.rotational=l,this.megapixels=(0,o.lazy)((()=>(0,u.megapixels)(this.maxWidth*this.maxHeight))),this.max={width:t,height:i},n(r,r,"f",s).push(this)}[a.inspect.custom](){return{ctor:"ImageSize",name:this.name+" ("+this.reducer.name+")",maxDim:this.maxWidth+"×"+this.maxHeight,maxMP:this.megapixels()}}get aspectRatio(){return this.maxWidth/this.maxHeight}get maxPixels(){return this.maxWidth*this.maxHeight}get minDimension(){return Math.min(this.maxWidth,this.maxHeight)}outputSize(e){return this.reducer.reduce(this.rotational&&(0,l.isPortrait)(e)?(0,l.dimSwap)(this.max):this.max,e)}resize(e,t){return t.resize({...e,fit:this.reducer.fit,withoutEnlargement:!0})}toJpeg({path:e,sh:t,outputSize:i}){return((0,l.dmegapixels)(i)<2||d.Settings.previewSharpen.valueOrDefault)&&(t=t.sharpen()),t.jpeg((0,f.sharpRenderOptions)()).toFile(e)}toString(){return this.name}}t.ImageSize=m,r=m,s={value:[]},m.UHD8k=new r("uhd8k",7680,4320,h.Fit,!1),m.UHD5k=new r("uhd5k",5120,2880,h.Fit,!1),m.UHD=new r("uhd4k",4096,2160,h.Fit),m.QHD=new r("qhd",3120,1440,h.Fit),m.FHD=new r("fhd",1920,1080,h.Fit),m.HD=new r("hd",1280,720,h.Fit),m.WVGA=new r("wvga",720,480,h.Fit),m.QVGA=new r("qvga",320,240,h.Fit),m.QQVGA=new r("qqvga",160,120,h.Fit),m.S480=new r("s480",480,480,h.Square),m.S240=new r("s240",240,240,h.Square),m.S120=new r("s120",120,120,h.Square),m.S60=new r("s60",60,60,h.Square)},4192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includePreviewTags_=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(50213),o=i(56038),l=i(28874),u=i(47783),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.includePreviewTags")));t.includePreviewTags_=async function(e,t){!1===l.Settings.includePreviewTags.valueOrDefault||l.Settings.includedPreviewTags.isEmpty()||(0,s.isEmpty)(t)||(c().info("Re-adding metadata to previews..."),await(0,o.time)("img.includePreviewTags",(async()=>{const i=(0,n.pick)(await(0,u.readTags)(e),...l.Settings.includedPreviewTags.values),r=i?.capturedAt;null!=r&&(delete i.capturedAt,(0,n.assignFields)(i,r.asExifTag()));const s=i?.exposureSettings;null!=s&&(delete i.exposureSettings,i.FocalLength=s.focalLength,i.FNumber=s.aperture,i.ExposureTime=s.shutterSpeed,i.ISO=s.iso),l.Settings.includedPreviewTags.has("Source")&&(i.Source=e.nativePath),(0,n.isEmptyObj)(i)?c().warn("not adding tags to previews: no values for tags in source file",{src:e,includedPreviewTags:l.Settings.includedPreviewTags.values}):(c().info("Overwriting preview tags...",{src:e,writeTags:i}),await Promise.all(t.map((e=>(0,u.overwriteTags_)(e,i)))))})))}},78011:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.meanDiffHashCIELAB=t.meanDiffHash=t.dhash=t.mhash=void 0;const s=r(i(9288)),n=i(96249),a=i(59455),o=i(85810),l=i(70417),u=i(48368);function c(e){const t=(0,l.avg)(e);return null==t?[]:(0,a.toA)(e).map((e=>e>=t?1:0))}function d(e){const t=(0,a.toA)(e),i=Math.round(Math.sqrt(t.length));return t.map(((t,r)=>t>=(0===r?e[i]:r%i==0?e[r-i]:e[r-1])?1:0))}t.mhash=c,t.dhash=d,t.meanDiffHash=async function(e,t=u.HashDim){const i=await e.greyscale().resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer();return{meanHash:c(i),diffHash:d(i)}},t.meanDiffHashCIELAB=async function(e,t=u.HashDim){const i=await e.resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer(),r=(0,o.rgb2labArray)(i);return{meanHash:(0,n.flatten)(r.map(c)),diffHash:(0,n.flatten)(r.map(d))}}},52121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._prepFileForBrowser=t.prepFileForBrowser=void 0;const r=i(19851),s=i(78923),n=i(95696),a=i(50213),o=i(28874),l=i(12089),u=i(16170),c=i(13940),d=i(4192),h=i(5733),f=i(50961),m=(0,r.lazy)((()=>(0,a.mkLogger)("img.PrepareFileForBrowser")));async function p(e){try{const t=n.PosixFile.for(e.nativePath);if(await t.notExists())return;const i=e.mimetype??(await(0,s.readFileType_)(t.nativePath))?.mime;return(0,u.isMimeTypeSupportedByBrowser)(i,e.userAgent)?t.nativePath:(m().info("prepFileForBrowser(): non-browser-supported mimetype",{file:t,info:e}),(await(0,c.withImageCache_)(t,"web",".jpg",(async e=>{const i=await(0,f.sharpReadable_)({src:t});if(null==i)throw new Error("prepFileForBrowser(): can't read "+t.nativePath);await(0,f.toSharp)(i).jpeg((0,h.sharpRenderOptions)()).toFile(e.nativePath),o.Settings.includePreviewTags.valueOrDefault&&await(0,d.includePreviewTags_)(t,[e])})))?.nativePath)}catch(e){return void m().warn("prepFileForBrowser() failed",{error:e})}}t.prepFileForBrowser=(0,l.shim1)({name:"img.prepFileForBrowser",impl:p}),t._prepFileForBrowser=p},48604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildAssetPreviews_=t.Previews=void 0;const r=i(19851),s=i(55835),n=i(50213),a=i(12089),o=i(87290),l=i(95242),u=i(16524);class c{constructor(e){this.root=e}apb(e,t,i){return new l.AssetPreviewBuilder(this.ap(e),t,i)}ap(e){return new u.AssetPreviews(this.root,e)}}t.Previews=c,c.instance=(0,r.lazy)((()=>((0,n.mkLogger)("Previews").info(".instance()",{libraryPreviewsDir:(0,o.libraryPreviewsDirPosixFile)()}),(0,s.map)((0,o.libraryPreviewsDirPosixFile)(),(e=>new c(e)))))),t.buildAssetPreviews_=(0,a.shim1)({name:"img.buildAssetPreviews",impl:e=>c.instance().apb(e.assetId,e.assetFiles,e).build_()})},2090:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(34666),o=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,n.isNumber)(e)?e:((0,n.toGt0)(e.width)??0)/((0,n.toGt0)(e.height)??0),(e=>(0,o.leastBy)(t.StandardAspectRatios,(t=>{const r=Math.abs(e-t);return r>i?void 0:r}))??e))}function c(e,i,r=t.RatioEpsilon){return(0,a.lt)((0,n.absdiff)(u(e),u(i)),r)}function d(e,i){return(0,o.leastByCtx)(t.Ratios,(t=>{const r=Math.abs(t.i-e);return r[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,s.maybeDimSwap)(e.dimensions,e.rotation),(0,s.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,n.sigFigs)(e,3))}},34943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const r=i(19851),s=i(31586),n=i(80049),a=i(50213),o=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),h=(0,r.lazy)((()=>(0,a.mkLogger)("img.RawInfo"))),f=(0,r.lazy)((()=>new n.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:o.ShortCommandTimeoutMs})));async function m(e){return f().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,r,n,a]=e.split("\t"),o=(0,s.toGt0)(n),l=(0,s.toGt0)(a);return null==o||null==l?h().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):h().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:r,ImageSize:{width:o,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>f.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?f.prior()?.clear():f.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{h().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},32876:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Reducers=t.Fit=t.fitInsideToMaxPixels=t.fitInsideToAspectRatio=t.Square=t.SharpFits=void 0;const r=i(19851),s=i(33374),n=i(4188),a=i(11371),o=i(31586),l=i(68708),u=i(50989),c=i(50213),d=i(86580);var h,f;t.SharpFits=(0,u.strEnum)("cover","contain","fill","inside","outside"),function(e){const i=(0,r.lazy)((()=>(0,c.mkLogger)("img.Reducers.Square")));e.name=a.ReducerNames.sq,e.fit="cover",e.reduce=function(e,r){const s=(0,d.lteBoth)(e,r)?{...e,fit:t.SharpFits.cover}:void 0;return i().tap({msg:"reduce()",result:s,meta:{max:e,input:(0,l.pick)(r,"width","height","nativePath")}})}}(h||(t.Square=h={})),t.fitInsideToAspectRatio=function(e,t){return e.width/e.height>=t?{width:Math.floor(e.height*t),height:e.height}:{width:e.width,height:Math.floor(e.width/t)}},t.fitInsideToMaxPixels=function(e,t){if(null==e||!(0,o.gt0)(e.width)||!(0,o.gt0)(e.height))return;if((0,s.pixels)(e)(0,c.mkLogger)("img.Reducers.Fit")));e.name=a.ReducerNames.fit,e.fit="inside",e.reduce=function(e,i){if(!(0,d.ltBoth)(i,e))return(0,n.fitInside)(i,e);t().trace(`reduce(): input ${(0,s.fmtDim)(i)} is too small for ${(0,s.fmtDim)(e)}`)}}(f||(t.Fit=f={})),t.Reducers=[h,f]},5733:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const s=r(i(9288)),n=i(19851),a=i(41400),o=i(50213),l=i(28874),u=i(15674),c=(0,n.lazy)((()=>(0,o.mkLogger)("img.Sharp")));function d(e,t){return(0,s.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,n.lazy)((()=>{s.default.simd(l.Settings.enableSIMD.valueOrDefault),s.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),s.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,a.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},50961:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractImageForThumbs_=t.sharpReadable_=t.toSharp=t.imgFromExif_=t._imgFromExif_=void 0;const s=i(77988),n=r(i(9288)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(33374),d=i(98553),h=i(31586),f=i(68708),m=i(51926),p=i(41583),g=i(50213),y=i(97352),w=i(56519),v=i(56038),b=i(57159),S=i(95696),P=i(17217),M=i(28874),_=i(47783),T=i(16170),E=i(95141),D=i(54979),k=i(1078),x=i(63870),F=i(86580),C=i(277),A=i(16047),I=i(13940),O=i(5733),L=i(66106),R=i(19350),N=(0,a.lazy)((()=>(0,g.mkLogger)("img.SharpReadable")));async function B(e,t,i){return i?await(0,_.exiftool)().extractBinaryTagToBuffer(t,e.nativePath):(await z(e,t))?.nativePath}async function j(e,t,i,r,a){const o=t?.[i];if(!(o instanceof s.BinaryField))return;const l=o.bytes(0,_.extractBinaryTag)(t,e.nativePath,i.nativePath),timeoutMs:(0,x.commandTimeoutMs)()})}catch(i){return void N().throw("Failed to extract embedded "+t+" from "+e.nativePath,{error:i})}}t._imgFromExif_=B,t.imgFromExif_=j,t.toSharp=function(e){const t=e;if((0,O.isSharp)(t.sharp))return t.sharp;if((0,P.isSimpleFile)(t.file))return(0,n.default)(t.file.nativePath,{failOn:M.Settings.imageFailOn.valueOrDefault});throw new Error("toSharp(): not a Sharp object: "+(0,d.stringify)(e))},t.sharpReadable_=function(e){return(0,v.time)(`img.sharpReadable${e.src.ext.toUpperCase()}`,(()=>async function({src:e,minDim:t,skipEmbedded:i}){const r=N().addParameterContext(e.nativePath);(0,O.setupSharp)();const n=await(0,D.readMimeType)(e);if((0,u.blank)(n))return r.throw(e+" is not supported (missing MIMEType)",{doNotSend:!0});const a=await(0,k.extractSizeInfoFromFile)(e);if(null==a)return void r.warn("Failed to extract size info from "+e);const d=[];function f(e,t){t.desc=e,d.push(t)}const m=a.rotation,g=(0,T.isVideoMimeType)(n),S=(0,T.isLibrawMimeType)(n),P=a.dimensions,x=t??(0,y.map2Gt0)(P.width,P.height,((e,t)=>({width:Math.round(.9*e),height:Math.round(.9*t)})));if(null==x?.width||null==x?.height)return r.throw(e+" is not supported (missing dimensions)",{dim:x,doNotSend:!0,mimetype:n,isRaw:S,isVideo:g});const I=(0,F.aspectRatio)(a.fileDimensions),B=(0,h.lt)(I,1),z=(0,T.isSharpMimeType)(n)&&null==t,V=(0,E.orientationRequiresMirroring)(a.orientation);if(!0===i||g||B||z||V)r.debug("not pulling previews from tags",{isVideo:g,isFilePortrait:B,isSharpMimeAndNoMinDim:z,isMirrorOrientation:V});else{const i=!1,n=await(0,_.readRawTags)(e,i);if(null==n)r.warn("Cannot pull previews from tags: readRawTags() failed");else{const i=[...M.Settings.embeddedPreviews.values];null!=t&&(0,c.dmegapixels)(t)<1&&i.unshift(...M.Settings.embeddedThumbnails.values);const a=x.width*x.height*.2,u=x.width*x.height*.05,d=(0,l.sortBy)(i.filter((e=>n[e]instanceof s.BinaryField)),(e=>{const t=n[e]?.bytes;return(0,h.gt)(t,u)?Math.abs(t-a):void 0}));if(!(0,o.isEmpty)(d)){r.debug("checking previews from tags",{sizeSortedTagNames:d});for(const t of d)f("imgFromExif."+t,(()=>j(e,n,t,x,I)))}}}(0,T.isSharpMimeType)(n)&&f("sharp",(async()=>({file:e}))),(0,A.isHeifMimeType)(n)&&await(0,C.isHeifSupported)()&&f("heif",(()=>(0,w.thenMap)((0,C.heif2img)(e),(e=>({file:e}))))),S&&f("raw2tiff",(()=>(0,w.thenMap)((0,R.raw2tiff_)(e),(e=>({file:e}))))),g&&f("extractVideoFrame",(async()=>{if(await(0,L.isVideoSupported)())try{return await(0,w.thenMap)((0,L.extractVideoFrame_)(e),(e=>({file:e})))}catch(t){throw new b.WrappedError("Failed to extract video frame for "+e,t)}else r.warn("video file, but video support is missing",{src:e.nativePath,mimetype:n,minDim:t})}));const W=[];for(const i of d)try{const s=await(0,v.time)("img.read."+i.desc,i);if(null!=s)return r.debug(i.desc+" strategy succeeded",{src:e,minDim:t,rot:m,img:s.file?.nativePath}),{desc:i.desc,rot:m,mimetype:n,...s};r.debug(i.desc+" returned null",{src:e,minDim:t,rot:m})}catch(e){r.warn(i.desc+" failed",e),W.push((0,p.toErr)(e))}throw new b.WrappedError("Failed to render "+e,{causes:W,path:String(e),fatal:!1,doNotSend:!0,retriable:!1})}(e)))},t.extractImageForThumbs_=z},21473:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.testSharp_=void 0;const s=r(i(34589)),n=i(76760),a=r(i(9288)),o=i(50357),l=i(98553),u=i(68708),c=i(23560),d=i(43899),h=i(28874),f=i(5733);t.testSharp_=async function e(t){try{(0,f.setupSharp)();const e=t??(0,n.join)(d.ProjectPath.Public(),"images","logo@5x.png"),i=(0,a.default)(e,{failOn:"error"}),r=await i.resize(24,32,{fit:"cover",position:"attention"}).toFormat("jpeg").toBuffer({resolveWithObject:!0});(0,s.default)((0,o.eql)((0,u.pick)(r.info,"format","width","height","channels"),{format:"jpeg",width:24,height:32,channels:3}),"Unexpected sharp output: "+(0,l.stringify)(r.info))}catch(i){if(!(0,c.isWorkerService)()&&h.Settings.enableSIMD.valueOrDefault)return h.Settings.enableSIMD.envValue=!1,e(t);throw i}}},181:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.whyInvalidFile=t.clearInvalidFileCache=t.throwIfInvalidFile_=t.isValidFile=void 0;const s=r(i(9288)),n=i(19851),a=i(22573),o=i(42659),l=i(98553),u=i(50213),c=i(12089),d=i(81168),h=i(57159),f=i(88561),m=i(95696),p=i(17217),g=i(28874),y=i(16170),w=i(54979),v=i(63870),b=i(5733),S=i(50961),P=i(66106),M=i(51210),_=(0,n.lazy)((()=>(0,u.mkLogger)("img.ValidFile")));t.isValidFile=async function(e){return(0,a.blank)(await(0,t.whyInvalidFile)((0,p.toNativePath_)(e)))},t.throwIfInvalidFile_=async function(e){if(!g.Settings.validateJpegImages.valueOrDefault&&!g.Settings.validateRawImages.valueOrDefault&&!g.Settings.validateVideos.valueOrDefault)return void _().debug("file validation is disabled for "+e,{validateJpegImages:g.Settings.validateJpegImages.valueOrDefault,validateRawImages:g.Settings.validateRawImages.valueOrDefault,validateVideos:g.Settings.validateVideos.valueOrDefault});const i=(0,p.toNativePath_)(e),r=_().tap({msg:"whyInvalidFile("+i+")",result:await(0,t.whyInvalidFile)(i)});(0,a.notBlank)(r)&&_().throw(r,{path:i,retriable:!1,doNotSend:!0,ignorable:!0})};const T=(0,n.lazy)((()=>new f.FileCache({name:"img.validFile",maxSize:256,timeoutMs:Math.max(o.minuteMs,g.Settings.validateVideos.valueOrDefault?5*o.minuteMs:(0,v.commandTimeoutMs)())})));t.clearInvalidFileCache=function(){return T().clear()},t.whyInvalidFile=(0,c.shim1)({name:"img.whyInvalidFile",cache:T,toKey:p.toNativePath_,impl:async e=>{const t=m.PosixFile.for(e);if(!await t.isFile()||!await t.isReadable())return t+" is not a readable file";if(await t.isEmpty())return t+" is empty";try{const e=await(0,w.readMimeType)(t);if(null==e)throw new Error("Cannot validate, no mimetype");if((0,y.isVideoMimeType)(e))g.Settings.validateVideos.valueOrDefault&&(_().debug("validating "+t),await(0,P.validVideo_)(t));else{if(!e.startsWith("image/"))throw new Error("Unsupported mimetype "+(0,l.stringify)(e));if("image/jpeg"===e)g.Settings.validateJpegImages.valueOrDefault&&await(0,M.validJpeg_)(t);else if(g.Settings.validateRawImages.valueOrDefault)if((0,d.includesIgnoreCase)(g.Settings.validateMimetypeSkiplist.values,e))_().info("Skipping validation of "+t+": validateMimetypeSkiplist matches",{mime:e});else{const e=await(0,S.sharpReadable_)({src:t,skipEmbedded:!0}),i=await async function(e,t=g.Settings.imageFailOn.valueOrDefault){const i=e;if((0,p.isSimpleFile)(i.file))return(0,s.default)(i.file.nativePath,{failOn:t});if((0,b.isSharp)(i.sharp)){const{data:e,info:t}=await i.sharp.raw().toBuffer({resolveWithObject:!0});return(0,s.default)(e,{...t,failOnError:!0})}throw new Error("Cannot read input "+e?.desc)}(e);await i.tiff().toBuffer()}}return""}catch(t){return new h.WrappedError("Failed to validate",{cause:t,path:e,doNotSend:!0}).toS()}}})},19769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const r=i(19851),s=i(40958),n=i(41400),a=i(50213),o=i(68852),l=i(98314),u=i(28874),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:h().test(t)||!d().test(t),meta:{err:e,allow:h().test(t),block:d().test(t),validationErrorAllowlist:h().source,validationErrorBlocklist:d().source}})};const d=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),h=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,n.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>h.unset()))}))},66106:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const r=i(19851),s=i(40958),n=i(38639),a=i(42659),o=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),h=i(7282),f=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),w=i(56038),v=i(31562),b=i(34102),S=i(88561),P=i(95696),M=i(17217),_=i(31843),T=i(70417),E=i(33847),D=i(28874),k=i(94678),x=i(43207),F=i(47783),C=i(16170),A=i(95141),I=i(1078),O=i(63870),L=i(89782),R=i(13940),N=i(34592),B=(0,r.lazy)((()=>(0,d.mkLogger)("img.Video")));function j(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function z(e){return(0,h.isProd)()&&(e=void 0),(0,n.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=z,t.isVideoSupported=(0,r.lazy)((async()=>{try{return!0===(await z())?.isSupportedVersion}catch(e){return B().warn("isVideoSupported",{error:e}),!1}})),(0,o.later)((()=>(0,b.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,_.lerp2d)(e,{x:76800,y:D.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:D.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,r.lazy)((()=>new S.FileCache({name:"img.videoFrame",timeoutMs:a.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,M.toNativePath_)(e))):void 0}async function U(e,t){const i=j("extractVideoFrame",e),r=P.PosixFile.for(e);if(!(0,n.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const s=await(0,R.cachedImageFile_)(r,"frame",".jpg");i.debug("extractVideoFrame("+s+")");const o=await r.mtimeMs();if(null==o)return i.throw("null mtime");const l=await(0,F.readRawTags)(r,!1);if(null==l)return i.throw("no tags");const u=(0,A.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,I.extractSizeInfoFromTags)(l,u)?.dimensions,d=await s.stat(),h=null==d?void 0:await(0,L.dimensions)(s);if(null!=d&&d.mtimeMs>o&&null!=h&&(null==c||h.height===c.height&&h.width===c.width))return i.debug("prior dest, "+s+" seems reasonable",{srcDim:c,destDim:h}),s.nativePath;const f=(0,x.extractDurationSec)(l),m=Math.min(f??0,D.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:f}),await s.applyIfEmpty_({fn_:async e=>{const t={src:r,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,v.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*a.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,F.deleteAllTags_)(e,e)},timeoutMs:(0,O.commandTimeoutMs)()}),s.nativePath}async function q(){return D.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function H(e){const t=j("needsTranscoding",e);if(!await q())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,F.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const r=i.MIMEType;if(!(0,C.isVideoMimeType)(r))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:r}});const n=(0,x.extractDurationSec)(i);if(!(0,c.gt)(n,D.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:n}});const a=(0,s.compactBlanks)([i.AudioFormat]),o=a.some((e=>(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,s.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeMimeTypes.values,r);return t.tap({level:"info",msg:"result",result:!(o&&u&&d),meta:{mimetype:r,isSafeMimeType:d,audioCodecs:a,isSafeAudioCodec:o,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>U(e)}),t.__extractVideoFrame_=U,t.isVideoTranscodingSupported=q,t.needsTranscoding=H;const G=new g.TTLMap(a.hourMs);function $(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,r){if(!await q())return;const s=j("transcode",e);{!function(){for(const[e,t]of G.entries())t.isSettled&&G.delete(e)}();const t=G.get(e.nativePath)??G.get(i.nativePath);if(null!=t)return s.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await H(e))return void s.info("no transcoding needed");const n=await e.size();if(!(0,u.gt0)(n))return s.throw("source is empty or cannot read");const a=await(0,F.readTags)(e),o=(0,I.extractSizeInfoFromTags)(a),d=(0,x.extractDurationSec)(a);if(null==a||null==o||null==d)return s.throw("failed: missing video metadata",{sizeInfo:o,durationSec:d});{const e=G.get(i.nativePath);if(null!=e)return s.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const h=new y.Deferred("transcode "+e);G.set(e.nativePath,h),G.set(i.nativePath,h);const m=(0,u.toGt0)(a.VideoFrameRate)??(0,u.toGt0)(a.FrameRate)??30,p=Math.round(o.dimensions.width*o.dimensions.height*(0,T.max)([(0,u.toGt0)(a.FrameCount),(0,u.toGt0)(a.VideoFrameCount),m*d]));if(!0===r?.force)await i.unlink();else if(await async function(e,t){const i=await(0,F.readRawTags)(t),r=await(0,F.readRawTags)(e),s=(0,x.extractDurationSec)(r),n=(0,x.extractDurationSec)(i);return B().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(s,n,1.5),meta:{srcDurationSec:s,destDurationSec:n,src:e.nativePath,dest:t.nativePath}})}(e,i))return s.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const r=j("extractMaxBitrate",e),s=D.Settings.minVideoDimension.valueOrDefault,n=i.ImageWidth;if(null!=n&&!(0,u.gte)(n,s))return r.throw("invalid width: "+n,{ignorable:!0});const a=i.ImageHeight;if(null!=a&&!(0,u.gte)(a,s))return r.throw("invalid height: "+a,{ignorable:!0});const o=(0,k.extractBitrateKbps)(i)??D.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,f.mapGt0)(n,(e=>(0,f.mapGt0)(a,(i=>(0,u.clamp)(0,o,(0,t.bitrateKps)(e*i)))))),c={width:n,height:a,videoBitrateKbps:l};return r.debug("dim()",{src:e,result:c}),c}(e,a);return await h.observe((0,w.time)("video.transcode:"+e,(async()=>{const t=$(n,g.videoBitrateKbps,d);return await i.applyWip_({fn_:n=>async function(n){s.info("starting...",{destWip:n});const o=new E.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:n,fps:m,halt:r.halt,...g},h=D.Settings.transcodeMaxDim.valueOrDefault,f=(0,T.max)([a.dimensions.height,a.dimensions.width]);if((0,u.gt0)(h)&&(0,c.gt)(f,h)){const e=(0,l.fitInside)(a.dimensions,{width:h,height:h});null==e?s.warn("Cannot downsample transcoded video: fitInside() returned null",{input:a.dimensions,maxPixels:h}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),s.info("Downsampling transcoded video",{original:a.dimensions,output:e}))}const p=await o.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&s.throw("transcode failed with code "+p.code)}(n),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&s.info("transcode complete",{src:e,dest:i,elapsedMs:h.elapsedMs,pixels:p}),i},t.guessExpectedSize=$,t.validVideo_=async function(e){return null==await W(e)&&j("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),h=i(56519),f=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),w=i(84258),v=i(28874),b=i(76280),S=i(63870),P=i(19769),M=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function _(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:v.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=_;const T=/ffmpeg version n?(?\S+)/i,E=(0,u.lazy)((async()=>{const e=await _();if(null==e)return void M().info("failed to find ffmpeg in $PATH",{ffmpegPath:v.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,S.commandTimeoutMs)(),ignoreStderr:!0}),i=T.exec(t.result)?.[1];return M().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,b.semverSatisfies)(i,">=3.2")}}));function D(){E.unset(),t.ffmpegVersionDescription.unset()}function k(e){const t=e?.ffmpegHwaccel??v.Settings.ffmpegHwaccel.valueOrDefault;return(0,s.blank)(t)||(0,n.isDisabled)(t)?[]:["-hwaccel",t]}function x(e){const t=[...v.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(v.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),r=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+r),t}function F(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function C(e){const t=v.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,h.thenMapOr)(E(),(e=>"version "+e),(()=>"(not found)")))),(0,o.later)((()=>{(0,g.ee)().on("clearCache",D),(0,g.ee)().on("clearToolCache",D)})),t.ffmpegVersion_=async function(){return await E.prior()??E.refresh()},t.isFFmpegSupported=async function(){return null!=await E()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,r.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:a.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,f.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*a.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=x,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,r.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...x(t),...C(t),...k(t),"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),...F(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){M().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,w.unlink)(t.dest,"debug");const r=(0,p.errorToS)(i,{maxLen:1024});if(!(0,n.isDisabled)(t.ffmpegHwaccel??v.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(r))return M().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return M().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await _(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},51210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotate_=t.rotateInPlace_=t.validJpeg_=t.jpegtranVersion_=void 0;const r=i(19851),s=i(42659),n=i(21605),a=i(50213),o=i(84777),l=i(57159),u=i(95696),c=i(89966),d=i(43334),h=i(63870),f=i(19769),m=d.isWin?"NUL":"/dev/null",p=(0,r.lazy)((()=>(0,a.mkLogger)("img.jpegtran")));async function g(e,t,i){const r=await(0,c.jpegtranNativePath_)();if(!(0,n.isRotation)(i))throw new Error("refusing to rotate("+e+", "+i+")");await(0,o.stdout_)(r,["-copy","all","-trim","-rotate",i.toFixed(0),"-outfile",t.nativePath,e.nativePath],{timeoutMs:s.minuteMs}),t.clear()}t.jpegtranVersion_=async function(){const e=await(0,o.stdoutResult_)(await(0,c.jpegtranNativePath_)(),["-version"],{quiet:!0,timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:()=>!0});return(e.stderr??e.result).replace(/^libjpeg-turbo version/,"").trim()},t.validJpeg_=async function(e){const t=u.PosixFile.for(e),i=await(0,c.jpegtranNativePath_)();try{await(0,o.stdoutResult_)(i,["-outfile",m,t.nativePath],{timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:f.isIgnorableValidationError,ignoreExitCode:!0})}catch(e){throw p().warn("validJpeg caught invalid file",{src:t,cause:e}),new l.WrappedError("Invalid JPEG: "+t,{cause:e,path:t.nativePath,doNotSend:!0,fatal:!1,retriable:!1})}},t.rotateInPlace_=async function(e,t){p().info("rotateInPlace("+e+")",t),await e.applyWip_({fn_:i=>g(e,i,t),skipFsLock:!1,minSizeBytes:512,timeoutMs:s.minuteMs})},t.rotate_=g},19350:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dcraw_emu_=t.raw2tiff_=t.librawSupported=void 0;const r=i(19851),s=i(40958),n=i(33374),a=i(12168),o=i(23541),l=i(54993),u=i(50213),c=i(84777),d=i(98314),h=i(38835),f=i(57159),m=i(89966),p=i(28874),g=i(16170),y=i(54979),w=i(89782),v=i(13940),b=i(42725),S=i(19769),P=(0,r.lazy)((()=>(0,u.mkLogger)("img.libraw")));t.librawSupported=async function(e){try{return(0,g.isLibrawMimeType)(await(0,y.readMimeType)(e.nativePath))}catch(t){return P().warn("librawSupported("+e+"): failed to read filetype",t),!1}},t.raw2tiff_=async function(e){return(0,v.readableToFile_)({src:e,desc:"dcraw",suffix:".tiff",f:t=>D(e,t)})};const M=["-T"],_=["-Z","-"],T=["-o","1"],E=["-t","0","-j"];async function D(e,t){const i=await(0,w.dimensions)(e);if(null==i)return P().throw("Cannot decode RAW "+e+": no EXIF dimensions."+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);const r=b.ImageSize.largestFit().outputSize(i),u=[];null!=r&&4*(0,n.dmegapixels)(r)<(0,n.dmegapixels)(i)&&(P().debug("Large original source: using -h"),u.push("-h"));const g=await(0,m.dcrawEmuNativePath_)(),y=[...M,..._,...T,...u,...E,...p.Settings.dcrawEmuArgs.values,e.nativePath],v={encoding:"buffer",timeout:p.Settings.taskTimeoutMs.valueOrDefault,maxBuffer:250*a.MB};P().debug("dcraw_emu()",{cmd:g,args:y,opts:v});const D=(0,c.execFile)(g,y,void 0,v),k=[];function x(t){const i=(0,o.isError)(t)?(0,d.errorToS)(t):(0,l.toS)(t);if((0,S.isIgnorableValidationError)(i))P().info("dcraw_emu(): warning",{src:e,msg:i});else{P().warn("dcraw_emu(): error",{src:e,msg:i});const r=(0,o.isError)(t)?t:(0,f.toWrappedError)(i,{fatal:!1});k.push(r)}}if(D.on("error",x),D.stderr.on("data",x),await t.writeStream_(D.stdout),(0,s.isNotEmpty)(k))throw new f.WrappedError("Failed to convert RAW image "+e,{causes:k,path:e.nativePath});(0,c.endProcess)(D)}t.dcraw_emu_=D},36192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const r=i(19851),s=i(84777),n=i(8103),a=i(43334),o=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,r.lazy)((async()=>a.isMac?(0,n.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,s.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(o.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},71706:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.j=void 0;const r=i(38522);t.j=function(e){return JSON.parse((0,r.brotliDecompressSync)(Buffer.from(e,"base64")).toString("utf8"))}},42042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEmail=void 0;const r=i(22573),s=i(28874),n=i(81674);t.getEmail=async function(){const e=s.Settings.email.value;if((0,r.notBlank)(e))return e;for(const e of await(0,n.m)())if((0,r.notBlank)(e.l?.sub))return e.l?.sub}},83950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.L=void 0;const r=i(79114),s=i(40958),n=i(42659),a=i(34666),o=i(48884),l=i(97352),u=i(81674),c=i(84194);t.L=class{static for(e){return new this(e.str,e.l,e.sids,e.src)}constructor(e,t,i,r){this.s=e,this._l=t,this._sids=i,this.meta={src:r}}get l(){return this._l}get ok(){if(null==this._l)return!1;const e=(0,o.intersection)(this._sids,this._l.uids),t=(0,s.uniq)(e.map(c.getScheme)),i=(0,s.compact)(t.map((e=>(0,c.prefix2scheme)(e)))),r=i.length>=this._l.mat,a=(0,l.within)(this._l.iat?.getTime(),this._l.exp?.getTime()+n.dayMs,Date.now());return this.meta[(0,u.k)().o]=a,this.meta[(0,u.k)().u]=r,this.meta[(0,u.k)().m]=i,a&&r}cmpVal(){return[this.ok,-(r.S.indexOf(this.l?.[(0,u.k)().T])??0),this.l?.exp?.getTime()??1,this.meta.matchedSchemes]}cmp(e){return(0,a.cmp)(this.cmpVal(),e.cmpVal())}}},81674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p=t.l=t.t=t.b=t.m=t.vok=t.v=t.v_=t.k=void 0;const r=i(76790),s=i(22573),n=i(38639),a=i(45599),o=i(41400),l=i(96249),u=i(55835),c=i(31586),d=i(51926),h=i(79114),f=i(23541),m=i(59455),p=i(54993),g=i(72993),y=i(19851),w=i(50213),v=i(56519),b=i(76596),S=i(46292),P=i(87290),M=i(77740),_=i(34102),T=i(83278),E=i(28874),D=i(37692),k=i(71706),x=i(83950),F=i(72042),C=i(33603),A=i(48132);t.k=(0,y.rolazy)((()=>(0,k.j)("G1UBABwHdkz4hUIkFCfPXW5LlfvrWKSr9W3AIyIhUiw68NDfvLLHVop/bGoNnRxQlnqi2TZp0IJaX+lUHBoi+vMy2LMNpHCv8xVkUGsmQsgB8ldHoDqJeUQzbdybwikWVRs2KSWKjE5LnuqhTNSp3gTLhNfE9EqBLeaXP+UM9YqTGSXcyrcL03rIPMDAVyJplSZC0xoUgguOYJKvrcYFbNArN7BrQsnnsJ4hMtcSxOTxxRdxzETtL93qa3vjDw==")));const I=(0,a.defer)((()=>(0,w.mkLogger)((0,t.k)().l)));async function O(e){const i=await(0,F.V)((0,d.ensurePrefix)((0,p.toS)(e).trim(),(0,t.k)().p)),r=(0,b.utcIsoToTs)(i[(0,t.k)().i]);if(null==r)throw new Error("bad "+(0,t.k)().i+": "+i[(0,t.k)().i]+" ("+e+")");const s=(0,b.utcIsoToTs)(i[(0,t.k)().r]);if(null==s)throw new Error("bad "+(0,t.k)().r+": "+i[(0,t.k)().r]+" ("+e+")");return(0,M.getDevEnvFlag)((0,t.k)().y)&&(i[(0,t.k)().t]=!0),i[(0,t.k)().a]=(0,c.toGte0)(i[(0,t.k)().a])??2,i[(0,t.k)().i]=new Date(r),i[(0,t.k)().r]=new Date(s),i[(0,t.k)().b]=(0,p.toS)(i.uids).split(","),i}async function L(e,i,r,n){try{return(0,s.blank)(e)||e===(0,t.k)().f?void 0:x.L.for({str:e,l:await O(e),sids:null!=n?n:await(0,C.sids)({timeoutMs:r}),src:i})}catch(i){return I().tap({msg:(0,t.k)().v,result:{s:e,ok:!1,meta:{err:i}}})}}async function R(e,t){const i=[],r=await(0,v.sortByAsync)({name:"rawLicenseFromDir("+e+")",arr:e?.childFiles(),f:e=>e.mtimeMs()});for(const e of r.reverse()){const r=await L((0,m.toA)(await e.readLines()).map((e=>e.trim())).join(""),e.nativePath,A.UserTimeoutMs,t);null!=r&&i.push(r)}return i}async function N(){const e=await(0,t.m)();return e[0]?.ok?e[0]:void 0}async function B(){return(await N())?.l?.[(0,t.k)().T]??(0,t.k)().f}t.v_=O,t.v=L,t.vok=async function(e,t,i){if((0,s.blank)(e))return;const r=await L(e,t,i);return(0,n.isTrue)(r?.ok)&&r instanceof x.L?r:void 0},t.m=(0,y.rolazy)((async()=>{if((0,M.getDevEnvFlag)((0,t.k)().x))return[];const e=await(0,C.sids)({timeoutMs:A.UserTimeoutMs}),i=(0,u.map)((0,S.configDir)(),(e=>T.BaseFile.for(e))),s=(n=(0,l.flatten)((await(0,v.someOrTimeout)([()=>function(e){return L(E.Settings[(0,t.k)().L].value,"Settings",A.UserTimeoutMs,e)}(e),()=>R(i?.join((0,t.k)().d),e),()=>R((0,P.libraryDataDirPosixFile)()?.join((0,t.k)().d),e),()=>R(i?.sibling((0,g.AppName)().toLowerCase()).join((0,t.k)().d),e)],{timeoutMs:A.UserTimeoutMs})).filter((e=>!(e instanceof Error)))),(0,r.sortBy)(n.filter((e=>null!=e&&((0,f.isError)(e)&&I().warn((0,t.k)().d+": ",e),null!=e&&!(0,f.isError)(e)&&null!=e?.l))),(e=>[!e.ok,h.S.indexOf(e.l?.[(0,t.k)().T])??h.S.length+1,-(e.l?.exp?.getTime()??1)])));var n;return I().tap({msg:(0,t.k)().d+"()",result:s})})),(0,o.later)((()=>{(0,_.ee)().on("clearCache",(()=>t.m.unset())),(0,_.ee)().on((0,t.k)().c,(()=>t.m.unset())),D.stateEvents.on((0,t.k)().c,(()=>t.m.unset()))})),t.b=N,t.t=B,t.l=async function(){try{return await B()===(0,t.k)().f}catch{return!0}},t.p=async function(){try{return await B()===(0,t.k)().g}catch{return!1}}},72042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.V=t.l=void 0;const r=i(91227),s=i(19851),n=i(22573),a=i(71706);t.l=(0,s.lazy)((()=>(0,a.j)("G54BgBwHzrkukKDR8Ar6KkW29gbXlfrqQX46gTu5Wfq6dELYTjfBokB0d5+E2SAINBtxlmPquWe3PMUoNgaJrD982QMslkNeZ4BEqcBbQT59DVl9RnoTNi50diuT7NQg0YHxkr8SwDwtmFUOf+LwNVDDnPXUrzTOU++M3b+lcyfr7PXZndKHzho8iztNkZgt+/19//aXe+gvmC0HIdnn64wdLeYeLM7S9jmjTp52SzFsvIVbd4D0+rdtdjiz6R4vc2cmY398kuXiKG7fNXWS/I93etxXiVNPd4RXJF+k6JnuMUKk03GWHQQ="))),t.V=function(e){const i=(0,r.decode)(e).payload;if(null==i)throw new Error("Missing payload");const s=(0,n.notBlankOr)(i.k,(0,t.l)().d),a=(0,t.l)().o.find((e=>e.k===s));if(null==a)throw new Error("Unknown key");return r.V2.verify(e,a)}},84194:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SchemeCounts=t.isValidUid=t.toUID=t.UidLength=t.prefix2scheme=t.sortUids=t.getScheme=t.S=void 0;const n=i(40958),a=i(76790),o=i(22573),l=i(45599),u=i(50989),c=i(54993),d=i(22454),h=i(19851),f=i(50213),m=i(37628),p=i(55222),g=i(71706),y=(0,l.defer)((()=>(0,g.j)("GyABAIzUYs0Z7mSuLfVL1SwGefr+3nCwyXBMg6nD0qduA8HycFjUGK1N/ikYqhiqYLGbs7oxTBbzRPxteP9gA3L9DS0EJ2BJ1pYNa/DtEE2aPI2o03hHx3k9MhdE7jAeRUvKQ6tY3Q1fcIPe8GBMZvOeKibTymyo3Cw/7Ua42DKPjpL3wxWv+7TCGA==")));function w(e){const i=e.split(":",1)[0];return t.S.has(i)?i:void 0}t.S=(0,u.strEnum)("cu","lc","lm","lp","lb","mp","ms","wm","cm","bm","nm","li","si","vl"),t.getScheme=w,t.sortUids=function(e){return(0,a.sortBy)((0,n.uniq)(e.filter(S)),(e=>[t.S.indexOf(w(e))??t.S.length+1,e]))},t.prefix2scheme=function(e){return y()[e]};const v=["uninitialized","b08dfa6083e7567a1921a715000001fb"];t.UidLength=15,t.toUID=function(e,i){try{const r=(0,c.toS)(i).replace(/[^a-z\d=/+]+/gi,"");return(0,o.blank)(r)||v.includes(r.toLowerCase())||null!=r.match(/^[\s0:_/-]*$/)?void 0:e+":"+(0,m.shortStringSha)(r,t.UidLength,p.Radix58)}catch(t){return void(0,f.mkLogger)("toUID").warn("failed",{pfx:e,err:t})}};const b=(0,l.defer)((()=>new RegExp(`^(?:${t.S.values.join("|")}):[0-9a-zA-Z]{${t.UidLength}}$`)));function S(e){return null!=e&&null!=b().exec(e)}t.isValidUid=S,t.SchemeCounts=class{constructor(e){r.set(this,new Set),this.schemeCounts=(0,h.lazy)((()=>{const e=new d.CountingSet;for(const t of s(this,r,"f")){const i=w(t);null!=i&&e.incr(i)}return e})),null!=e&&this.addUids(e)}get size(){return s(this,r,"f").size}addUids(e){for(const t of e)null==w(t)||s(this,r,"f").has(t)||(s(this,r,"f").add(t),this.schemeCounts.unset())}count(e){return this.schemeCounts().get(e)}},r=new WeakMap},33603:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearSids=t.addSids=t.sids=t.win_machineGuid_=t.readInfo=t.k=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(45599),o=i(96249),l=i(68708),u=i(51926),c=i(59455),d=i(54993),h=i(50213),f=i(7282),m=i(56519),p=i(84777),g=i(84542),y=i(19254),w=i(45879),v=i(70854),b=i(57902),S=i(72308),P=i(43334),M=i(24399),_=i(7014),T=i(30933),E=i(71706),D=i(84194);t.k=(0,a.defer)((()=>(0,E.j)("G9ABYIzDOIZ8NLQ4t7qW8tNrmrOzz+qFGfAxl8jW4E2tLxwWRZT5TueCnPcwgTzT1DN3veRB+e7EYGlYHg6nhjBDQv7zI6EcYWk35z6QuZC3Q0itjrLCbmgd0iED0BvGiYLBJwRU1O9/3Agbl8IfG6ITVFWDRwyTw3rbUMo/XMyAVW7R23mkwUx0l4/7iA13RV/nmPuJFKp5BvJW7SoXJZoWEfdSNYYhN5UCtkbC7O1AaPIbU3P6uRLmEyb4TaHWzFigvrlmZVUzzp9j/Mz55vqN88ewd1Nrfh7gkVRQ7TtB7Ztz3XJxYC3ogdJHg8HGsG4=")));const k=(0,a.defer)((()=>(0,h.mkLogger)((0,t.k)().n)));async function x(e=(0,t.k)().pc){if(P.isLinux)try{const t=await(0,y.fileGrep_)(e,/^\s*(?:hardware|revision|serial|model)\s*[:=]\s*[a-z\d]{6}.*$/i),i=(0,r.compactBlanks)((0,g.splitLines)(t).map((e=>e.replace(/\s+/g," ")))).sort();return i.some((e=>null!=e.match(/^serial/i)))?i:void 0}catch{return}}t.readInfo=x;const F=(0,a.defer)((()=>(0,m.thenMap)(x(),(e=>(0,D.toUID)(D.S.lc,e.join(",")))))),C=/o\.e\.m\./i;async function A(e){return(0,r.uniq)(await Promise.all((0,t.k)()[e].map((e=>(0,w.readFileMaybe)(e,b.LogLevels.trace))))).map(d.toS).filter((e=>(0,s.notBlank)(e)&&null==e.match(C)))}async function I(){return P.isLinux?(await A("lm")).map((e=>(0,D.toUID)(D.S.lm,e))):void 0}async function O(){return P.isLinux?(await A("lp")).map((e=>(0,D.toUID)(D.S.lp,e))):void 0}async function L(){return P.isLinux?(await A("lb")).map((e=>(0,D.toUID)(D.S.lb,e))):void 0}async function R(){if(P.isMac)try{return(0,l.entries)(await async function(){const e=await(0,p.stdout_)((0,t.k)().i,(0,t.k)().ia,{timeoutMs:5*n.secondMs}),i=e.match(/uuid" = "([a-z\d-]{12,})"/i)?.[1],r=e.match(/SerialNumber" = "([a-z\d-]{10,})"/i)?.[1];return{mp:i,ms:r}}()).map((([e,t])=>(0,D.toUID)(e,t)))}catch(e){return void k().warn((0,t.k)().i+" failed",e)}}async function N(){return(await M.PowerShell.instance().executeJson((0,t.k)().w))?.MachineGuid}async function B(){return P.isWin?(0,D.toUID)(D.S.wm,await N()):void 0}t.win_machineGuid_=N;const j=(0,a.defer)((()=>(0,D.toUID)(D.S.cm,(0,T.cpuInfo)()[0].model)));async function z(){return P.isLinux?(0,D.toUID)(D.S.bm,(0,r.compactBlanks)(await A("bm")).map((e=>e.trim())).join("\n")):[]}async function V(){return(0,D.toUID)(D.S.li,await((0,v.LibraryUIDStore)()?.readUid_()))}async function W(){return(0,D.toUID)(D.S.si,await((0,v.SystemUIDStore)()?.readUid_()))}function U(){return(0,S.networkMacAddresses)().map((e=>(0,D.toUID)(D.S.nm,e)))}async function q(){return(0,c.toA)(await(0,_.volumes)()).map((e=>(0,D.toUID)(D.S.vl,e.uuid)))}const H=new Set;t.sids=async function({timeoutMs:e}){const t=Date.now(),i=[j,F,R,V,W,z,I,O,L,B,U,q],r=(0,o.flatten)(await(0,m.someOrTimeout)(i,{timeoutMs:e})).filter(u.isString);for(const e of r)H.add(e);return k().tap({msg:"sids()",result:(0,D.sortUids)([...H,...r]),meta:{timeoutMs:e,elapsedMs:Date.now()-t}})},t.addSids=function(e){if((0,f.isTest)())for(const t of e)H.add(t)},t.clearSids=function(){(0,f.isTest)()&&H.clear()}},48132:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserTimeoutMs=void 0;const r=i(42659);t.UserTimeoutMs=7*r.secondMs},34474:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allRecentLogEntries=t.recentLogFiles=void 0;const r=i(40958),s=i(42659),n=i(41400),a=i(96249),o=i(68708),l=i(34666),u=i(20214),c=i(71371),d=i(50213),h=i(42638),f=i(31562),m=i(98314),p=i(89968),g=i(28874),y=i(4904),w=i(57902),v=i(89241),b=i(83954);function S(e=10*s.minuteMs){const t=Date.now()-e;return(0,u.thenMap)(p.DirectoryEntry.for(g.Settings.logDir.valueOrDefault),(e=>e.filterDescendantFiles((async e=>[".log",".log.gz"].includes(e.ext)&&(0,l.gte)(e.mtimeMs(),t)))))}t.recentLogFiles=S,t.allRecentLogEntries=async function(e=50){(0,b.writeRecentLogEntries)();const t=(0,o.fromEntries)(w.LogLevels.values.map((t=>[t,new c.BoundedGreatestSet(e,y.logEntrySorter)]))),i=Date.now()-s.hourMs,p=(0,d.mkLogger)("allRecentLogEntries()");return await(0,u.thenMap)(S(),(e=>(0,h.withBoundedConcurrency)({name:"allRecentLogEntries()",laters:e.map((e=>async()=>{try{const a=[],o=new v.LogReader(e,(e=>a.push(e)));for(await(0,f.untilTrue)((()=>o.ready()),{timeoutMs:10*s.secondMs});!o.complete()&&!o.hasErrors();){const e=o.shift();null==e?await(0,n.delay)(5):e.ts>i&&t[e.l]?.add(e)}(0,r.isNotEmpty)(a)&&(p.warn("Read error(s) for "+e,a),a.some((e=>"Z_BUF_ERROR"===e.code||(0,m.errorToS)(e).includes("unexpected end of file")))&&(0,l.lt)(e.mtimeMs(),Date.now()-s.minuteMs)&&(p.warn("Unlinking corrupt logfile "+e),await e.unlink_()))}catch(t){p.warn("Failed to read entries from "+e,t)}}))}))),(0,a.flatten)((0,o.values)(t).map((e=>e.vacuum()))).sort(((e,t)=>(0,l.cmp)(e.ts,t.ts)))}},49794:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),s=i(19851),n=i(40958),a=i(22573),o=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,s.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,a.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,n.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),s=i(23560),n=i(66184),a=i(72210);class o{log(e,t,i,r){this.enabled(e,t)&&(0,a.pushLogEntries)({ts:Date.now(),l:e,from:(0,s.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,n.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=o,o.instance=(0,r.lazy)((()=>new o))},14593:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),s=i(22573),n=i(26905),a=i(55835),o=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,s.toNotBlank)(e)??(0,n.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,o.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),s=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:s}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,a.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,o.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),s=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof s.LogWriter))}},28981:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),s=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new s.PlaintextLogFormatter))},31256:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(41400),o=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function w(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,n.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,a.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,s.uniq)((0,s.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,o.stringify)({...t,...w(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,o.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const n=i(77030),a=i(19851),o=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),w=i(31256),v=i(28538),b=(0,a.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),S=String.fromCharCode(0);t.logBroadcaster=(0,a.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,o.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&b().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new w.GelfLogFormatter,this.logFilter=new v.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,n.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{b().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){b().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),s(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,n){if(this.enabled(e,t))try{const a=this.socket;null==a?s(this,r,"f").call(this):a.write(this.logFormatter.format(e,t,i,n)+S)}catch(r){b().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:n,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),s=i(42659),n=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??n.Settings.logDir.valueOrDefault,(0,s.fmtIsoDate)(t??new Date))}},12495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogDirCleanup=void 0;const r=i(19851),s=i(42659),n=i(23560),a=i(79267),o=i(32144),l=i(28874);t.LogDirCleanup=(0,r.lazy)((()=>(0,n.isBillingService)()?void 0:a.FileCleanup.for({name:"logDirCleanup",rootNativePath:()=>l.Settings.logDir.valueOrDefault,staleMs:s.weekMs,isPrunable:e=>(0,o.isLogExt)(e.ext)})))},4904:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),s=i(31586),n=i(51926),a=i(57902);t.isLogEntry=function(e){return null!=e&&(0,s.isNumber)(e?.ts)&&(0,n.isString)(e?.msg)&&a.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),s=i(57902);class n{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,s.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,s.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=n,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new n(s.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>s.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,s.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,s.set(this,[]),n.set(this,(0,l.lazy)((()=>{o(this,s,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:o(this,s,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>o(this,n,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=o(this,r,"m",a).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=o(this,r,"m",a).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){if(null==e||0===o(this,s,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return o(this,s,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),s=i(31586),n=i(50989);t.LogLevels=(0,n.strEnum)("fatal","error","warn","info","debug","trace");const a=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??a},t.levelGte=function(e,i){return(0,s.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const o=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return o.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),s=i(68708),n=i(20214),a=i(51926),o=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,a.isString)(i)||Buffer.isBuffer(i))return(0,a.ellipsize)(i.toString(),256,32);if((0,o.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,n.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const o=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,s.keys)(i),(0,s.keys)(o));return(0,r.isNotEmpty)(c)&&(o["…"]="omitted: "+(0,a.ellipsize)(c.join(", "),128,32)),o}return i}},89241:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogReader=void 0;const d=i(73024),h=i(38522),f=i(4001),m=i(14977),p=i(33456),g=i(92322),y=i(4904),w=i(98192);t.LogReader=class{constructor(e,t){if(r.add(this),this.f=e,this.start=Date.now(),this.lines=new g.SortedSet(y.logEntrySorter),s.set(this,!1),n.set(this,!1),a.set(this,!1),this.from=(0,f.stripCopySuffixFromName)(e.name),this.fileStream=(0,d.createReadStream)(e.nativePath,{autoClose:!0}),!(0,m.isExtOrCompressedExt)(e.ext,".log"))throw new Error(e+" is not a logfile");this.stream=(e.ext.toLowerCase().endsWith(".gz")?this.fileStream.pipe((0,h.createGunzip)()):e.ext.toLowerCase().endsWith(".br")?this.fileStream.pipe((0,h.createBrotliDecompress)()):this.fileStream).pipe(new p.LineReader).on("error",(e=>{t(e),u(this,a,!0,"f")})),this.stream.on("data",c(this,r,"m",o).bind(this)),this.stream.on("close",(()=>{this.fileStream.resume(),u(this,s,!0,"f")})),this.stream.on("end",(()=>{u(this,s,!0,"f")}))}toString(){return"LogReader("+this.f.nativePath+")"}status(){return{hasErrors:c(this,a,"f"),ended:c(this,s,"f"),destroyed:this.stream.destroyed,lines:this.lines.length,paused:c(this,n,"f")}}hasErrors(){return c(this,a,"f")}get ended(){return c(this,s,"f")}ready(){return this.ended||this.lines.length>32}complete(){return this.ended&&0===this.lines.length}peek(){return this.ready()?this.lines.at(0):void 0}shift(){const e=this.lines.shift();return null!=e&&c(this,r,"m",l).call(this),e}shiftLte(e){const t=this.lines.shiftLte(e);return t.length>0&&c(this,r,"m",l).call(this),t}},s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e){if(null===e)u(this,s,!0,"f");else{const t=(0,w.chunkToLogEntry)(e);null!=t&&this.lines.add({...t,from:this.from}),this.lines.length>10240&&!c(this,n,"f")&&(this.fileStream.pause(),u(this,n,!0,"f"))}},l=function(){this.lines.length<1024&&c(this,n,"f")&&(this.fileStream.resume(),u(this,n,!1,"f"))}},24068:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),s=i(76760),n=i(1708),a=i(87997),o=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),w=i(22277),v=i(25764),b=i(38836),S=i(99331),P=i(42638),M=i(76596),_=i(98314),T=i(89968),E=i(29882),D=i(28874),k=i(28981),x=i(20839),F=i(21727),C=i(66184),A=i(57902),I=i(72210),O=i(98192);function L(e){const t=(0,k.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=L;class R extends b.EndableWrapper{constructor(e=void 0,t=L){super("LogTail",(()=>this.close()),v.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new w.TTLSet(5*u.secondMs),this.setup=(0,o.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,D.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,E.mkdirp_)(e),this.root=await T.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=s.sep+(0,p.serviceName)()+"-"+n.pid+"-",n.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,a.setInterval)((()=>this.flush()),x.DefaultLogFlushMs/2),this.scanTimeout=(0,a.setInterval)((()=>this.scan()),u.minuteMs),n.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,S.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,C.ifLog)(A.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,s.join)(e,i))}))}catch(t){return void(0,C.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,_.errorToS)(t))))}}))}async scan(e=!1){if((0,S.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,M.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,S.ending)()||this.ended)return;const t=(0,F.datedLogDir)(this.root.nativePath);try{await(0,E.mkdirp_)(t),this.watchDir(t)}catch(e){(0,C.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,_.errorToS)(e))))}(0,S.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,a.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,a.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await T.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(r,i))return;await(0,f.thenMap)((0,O.readLogEntries)(e,{start:r,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,C.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,_.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,o.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),s=i(82328),n=i(28981),a=i(20839),o=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(o.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,s.stdoutEnded)()||console.log((0,n.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*a.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),w=i(31586),v=i(409),b=i(23560),S=i(81168),P=i(78406),M=i(25764),_=i(20197),T=i(14977),E=i(36868),D=i(28874),k=i(32105),x=i(20839),F=i(21727),C=i(66184),A=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class O extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*x.DefaultLogFlushMs),rank:M.EndableRanks.logger,unref:!0,onEnd:()=>c(this,s,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,s.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:k.ConsoleLogger.instance(),flushEveryMs:x.DefaultLogFlushMs,processName:b.processName,logFilter:C.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,v.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",n).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const s={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(s.meta=(0,A.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(s)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=O,s=new WeakMap,r=new WeakSet,n=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,w.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),s=e.splice(0,i);this._linesSinceRotate+=s.length,t.write(s.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},a=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},o=function(e){return t=>(c(this,r,"m",a).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,S.stripAnsiEsc)(this.logOpts.processName()),t=await(0,_.ensureNewNativePath_)({nativePath:(0,f.join)((0,F.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,r,"m",o).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,E.endStream)(e.stream),D.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,T.gzip_)(e.nativePath))}catch(e){c(this,r,"m",a).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(68708),o=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,a.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,s.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,n.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),s=i(84542),n=i(4001),a=i(13047),o=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,o.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,n.stripCopySuffixFromName)(e.name),r=[],o=await(0,a.zcat)(e.nativePath,t);if(null!=o)for(const e of(0,s.splitLines)(o)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),s=i(76790),n=i(68708),a=i(89788),o=i(57902);t.SentLogLevels=(0,r.lazy)((()=>o.LogLevels.values.filter((e=>e!==o.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,n.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new a.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,n.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,n.values)(l()))e.push(...t.toA());return(0,s.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),s=i(41400),n=i(55835),a=i(37975),o=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),w=i(66184),v=i(28538),b=i(24068),S=i(43705),P=i(51879);function M(){(0,w.logFilter)()instanceof v.LogFilterImpl||w.logFilter.set(new v.LogFilterImpl),_();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new S.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,n.map)((0,y.logBroadcaster)(),(e=>i.push(e))),o.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&b.LogTail.instance()}function _(){const e=h.Settings.logColor.valueOrDefault;(0,a.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=M,t.setupLogFormatter=_,(0,s.later)((()=>{h.Settings.logStdout.watchLater(M),h.Settings.logDir.watchLater(M),h.Settings.tailLogs.watchLater(M),h.Settings.logColor.watchLater(_),h.Settings.logLevel.watchLater((()=>w.defaultLogLevel.unset()))}))},83954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeRecentLogEntries=void 0;const r=i(89179);t.writeRecentLogEntries=function(){return(0,r.currentFileLogger)()?.writeRecentLogEntries()}},82647:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const a=i(57975),o=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,a.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return n(this,r,"m",s).call(this,-1)}get p29(){return n(this,r,"m",s).call(this,-.5)}get p38(){return n(this,r,"m",s).call(this,-.25)}get p69(){return n(this,r,"m",s).call(this,.5)}get p84(){return n(this,r,"m",s).call(this,1)}get p98(){return n(this,r,"m",s).call(this,2)}get p99(){return n(this,r,"m",s).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,o.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,o.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,o.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,s=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),s=i(55835),n=i(31586),a=i(30976),o=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,n.clamp)(0,i,(0,n.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,s.map2)(e,t,((e,t)=>(0,r.sum)((0,o.zip)(u(e,i),u(t,i)),(([e,t])=>(0,n.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,n.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,a.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),s=this.clampValue(e);let n=0;for(let e=0;ea?(n+=1,i[t]=a):r[t]=a}return n}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let s=0;s(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,n.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;in?(t+=1,s.min=n):s.max=n}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},76752:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtEstimate=t.ETA=void 0;const r=i(42659),s=i(75240),n=i(31586),a=i(97352),o=i(82647);function l(e){return(0,n.gt0)(e)?e<=r.minuteMs?"less than a minute remains":"about "+(0,s.fmtDuration)(e,1,{plural:"remains",singular:"remain"}):void 0}t.ETA=class{constructor(){this.taskMillis=new o.Average(10)}push(e){(0,a.mapGt0)(e,(e=>this.taskMillis.push(e)))}clear(){this.taskMillis.clear()}avg(){return this.taskMillis.p69}etaMs(e){const t=this.avg();if(null==t)return;const i=t*e;return i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.kmeans=void 0;const r=i(76790),s=i(93973);t.kmeans=function(e,t,i){const n=s(e,t,i);return{...n,centroids:(0,r.sortBy)(n.centroids.filter((e=>e.size>0)),(e=>-e.size))}}},31843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const r=i(76790);function s(e,t,i=.5){return(1-i)*e+i*t}t.lerp=s,t.lerp2d=function(e,...t){const i=(0,r.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[n,a]=(0,r.sortBy)(i,(e=>e.x)),o=a.x-n.x,l=(e-n.x)/o;return s(n.y,a.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},75503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modeReduce=t.submatrixCollect=t.greatestHalf=t.leastVariantQuarter=t.leastMagQuarter=t.submatrixMode=t.submatrixStdDev=t.submatrixMagnitude=t.submatrixForEach=t.index1D=t.slice=t.matXvec=t.vecXvec=void 0;const r=i(40958),s=i(31586),n=i(48884),a=i(82647),o=i(70417);function l(e,t,i,r){const s=Math.floor(Math.max(0,t.row)),n=Math.ceil(Math.min(e.row,i.row)),a=Math.floor(Math.max(0,t.col)),o=Math.ceil(Math.min(e.col,i.col));for(let t=s;t(0,s.mapFinite)(e[t],(e=>n+=e*e)))),Math.sqrt(n)}function c(e,t,i,r){const n=new a.Average;return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),n.stdDev}function d(e,t,i,r){const n=[];return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),(0,o.mode)(n)}t.vecXvec=function(e,t){return e.map(((e,i)=>e*t[i]))},t.matXvec=function(e,t){return e.map(((e,i)=>{if(e.length!==t.length)throw new Error("misshaped matrix on row "+i);return(0,o.sumf)(e,((e,i)=>e*t[i]))}))},t.slice=function(e,t,i){const s=Math.max(0,t.row),n=Math.min(e.length,i.row),a=Math.max(0,t.col),o=Math.min(e[0].length,i.col);return(0,r.range)(s,n,(t=>e[t].slice(a,o)))},t.index1D=function(e,t,i){return t*e.col+i},t.submatrixForEach=l,t.submatrixMagnitude=u,t.submatrixStdDev=c,t.submatrixMode=d,t.leastMagQuarter=function(e,t){const i=t.col,r=t.row,s=[u(e,t,{col:i/2,row:0},{col:i,row:r/2}),u(e,t,{col:0,row:0},{col:i/2,row:r/2}),u(e,t,{col:0,row:r/2},{col:i/2,row:r}),u(e,t,{col:i/2,row:r/2},{col:i,row:r})];return(0,n.leastIndex)(s)},t.leastVariantQuarter=function(e,t){const i=t.col,r=t.row;return(0,n.leastIndex)([c(e,t,{col:i/2,row:0},{col:i,row:r/2}),c(e,t,{col:0,row:0},{col:i/2,row:r/2}),c(e,t,{col:0,row:r/2},{col:i/2,row:r}),c(e,t,{col:i/2,row:r/2},{col:i,row:r})])},t.greatestHalf=function(e,t){const i=t.col,r=t.row,s=[d(e,t,{col:0,row:0},{col:i,row:r/2}),d(e,t,{col:0,row:0},{col:i/2,row:r}),d(e,t,{col:0,row:r/2},{col:i,row:r}),d(e,t,{col:i/2,row:0},{col:i,row:r})];return(0,n.greatestIndex)(s)},t.submatrixCollect=function(e,t,i){const r=[];return l(e,t,i,(e=>r.push(e))),r},t.modeReduce=function(e,t,i){const o=Math.floor(t.col/i.col),u=Math.floor(t.row/i.row),c=new a.Average(Math.ceil(o*u));return(0,n.concat)(...(0,r.stepRange)(0,t.row,u,(i=>(0,r.stepRange)(0,t.col,o,(r=>(c.clear(),l(t,{col:r,row:i},{col:r+o,row:i+u},(t=>(0,s.mapFinite)(e[t],(e=>c.push(e))))),c.sampleMode))))))}},36372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stableContentShuffle=t.stableIndexShuffle=t.factors=t.primeSeeds=t.primeInt=t.primes=t.prng=t.prngOrderByClause=void 0;const r=i(76790),s=i(42659),n=i(31586),a=i(97238),o=i(50597),l=i(9103),u=i(55222);function c(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e),u=(s*i*i+n*i)%r,c=(a*i+o)%r;return Math.round((u*c+l)%r)}function d(e){return(0,u.encodeDigits)(a.PrimesPerBin,e,a.PrimeBins).map(((e,i)=>t.primes[i][e]))}t.prngOrderByClause=function(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e);return`(((${s}*${i}*${i}+${n}*${i})%${r})*((${a}*${i}+${o})%${r})+${l})%${r}`},t.prng=c,t.primes=[[353868013,472882027,479001599,517294153],[1012573,1230587,1355297,1572751],[756065159,812182027,899809343,989450477],[3959297,4514113,4823201,5133127],[573259391,666101999,694847533,746151647],[2275327,2770513,3073703,3511973],[173313197,182557181,203457869,222230231],[6054613,6189107,7752103,9852103]],t.primeInt=[1012573,1101689,1183811,1196089,1230587,1355297,1419641,1483733,1572751,2275327,2770513,3010349,3073703,3118691,3174823,3511973,3959297,4514113,4690451,4823201,5133127,5375327,6019889,6054613,6189107,7752103,7752103,9852103],t.primeSeeds=d,t.factors=(0,l.memoize)((e=>{const[i,r,s,o,l,u,c,h]=d(e%a.SeedCount),f=[i/r,s/o,l/u,c/h].map((e=>(0,n.sigFigs)(e,7)));return f.push(t.primeInt[e%t.primeInt.length]),f}),{maxSize:128,ttlMs:s.minuteMs}),t.stableIndexShuffle=function(e,t=1){return(0,r.sortBy)(e,((i,r)=>c(t,r,e.length)))},t.stableContentShuffle=function(e,t=1){return(0,r.sortBy)(e,(e=>(0,o.numericSha)(String(e)+t)))}},55222:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),s=i(22573),n=i(55835),a=i(32639),o=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,n.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,s.blank)(e))return;const t="-"===(e=(0,a.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),s=this.normalizeToken(t);return r.length>=i&&r===s}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const r=i(31586),s=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,r.toInt)(e)]??(0,s.toS)(e)}},38812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SquareMatrix=t.rotateSquareMatrix=void 0;const r=i(21605);t.rotateSquareMatrix=function(e,t){return 0===(0,r.normalizeRotation)(t)?e:new s([...e]).rotate(t).m};class s{constructor(e,t=1){if(this.m=e,this.ary=t,this.rows=Math.sqrt(e.length/t),this.rows!==Math.floor(this.rows))throw new Error(`Only square tuple matrices are supported: ${1===this.ary?"":this.ary}(${this.rows}×${this.rows}) != ${e.length}`)}index(e,t){return this.ary*(t+e*this.rows)}swap(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),s=i(65713);function n(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=n,t.safeUUID=function(){return(0,s.decuss)(n)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const o=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function w(e,t){let i=0,r=0;for(const s of e){if(null!=s){const e=t(s,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=w;class v{constructor(){r.set(this,0),s.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(a(this,s,null==n(this,s,"f")?e:n(this,s,"f")*n(this,r,"f")/(n(this,r,"f")+1)+e/(n(this,r,"f")+1),"f"),a(this,r,(t=n(this,r,"f"),++t),"f"))}get mean(){return n(this,s,"f")}}function b(e){const t=new v;for(const i of e)t.push(i);return t.mean}function S(e){const t=b(e);if(null==t)return;let i=0,r=0;for(const s of e)(0,u.isNumber)(s)&&(r++,i+=(s-t)*(s-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function M(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+a*(e-s)/n)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=b(t);if(null!=i){const e=(t.length-1)/2,r=w(t,((t,r)=>(t-i)*(r-e))),s=w(t,(e=>(e-i)**2));return 0===s?0:r/s}},t.variance=S,t.stdDev=function(e){return(0,l.map)(S(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=M,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(M(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,o.isEmpty)(e)&&(0,o.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},23624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64encodeBits=t.b64hammRatio=t.gz64decodeString=t.d=t.gz64encodeString=t.b64decode=t.b64encode=t.hex2b64=void 0;const r=i(38522),s=i(22573),n=i(97352);function a(e){const t=e.toString(16),i=t.length%2==0?"":"0";return Buffer.from(i+t,"hex").toString("base64")}function o(e){return BigInt("0x0"+Buffer.from(e,"base64").toString("hex"))}function l(e){return(0,r.gunzipSync)(Buffer.from(e,"base64")).toString("utf8")}t.hex2b64=function(e){return Buffer.from(e,"hex").toString("base64")},t.b64encode=a,t.b64decode=o,t.gz64encodeString=function(e){return(0,r.gzipSync)(Buffer.from(e,"utf8")).toString("base64")},t.d=l,t.gz64decodeString=l,t.b64hammRatio=function(e,t){return(0,s.mapNotBlank)(e,(e=>(0,s.mapNotBlank)(t,(t=>(0,n.hammRatioBigInt)(o(e),o(t))))))},t.b64encodeBits=function(e){return a(BigInt("0b0"+e.map((e=>1===e?"1":"0")).join("")))}},49076:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const s=r(i(48161)),n=i(19851),a=i(22573),o=i(41400),l=i(81168),u=i(28874);t.hostname=(0,n.lazy)((()=>u.Settings.hostname.value??s.default.hostname())),(0,o.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,a.blank)(e)&&!(0,a.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??s.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},43205:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemUserAgent=t.simpleUserAgent=t.userAgent=void 0;const r=i(72993),s=i(17344),n=i(96175),a=i(37805),o=i(81674),l=i(28874);function u(){return r.SimpleAppName+a.version}async function c(){return u()+" ("+(0,n.osFullName)()+") "+(0,s.EditionType)().toLowerCase()+"/"+await(0,o.t)()}t.userAgent=async function(){return l.Settings.allowUserAgent.valueOrDefault?c():u()},t.simpleUserAgent=u,t.systemUserAgent=c},72308:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLocalhost=t.isLoopback=t.myExternalIp4Addresses=t.myExternalIpAddresses=t.networkMacAddresses=t.myIpAddresses=void 0;const r=i(48161),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(96249),u=i(31586),c=i(68708),d=i(50213),h=i(81168);function f(){return(0,t.myIpAddresses)().filter((e=>!g(e)))}t.myIpAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.address))))),o.minuteMs),t.networkMacAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.mac)))).filter((e=>"00:00:00:00:00:00"!==e))),o.minuteMs),t.myExternalIpAddresses=f,t.myExternalIp4Addresses=function(){return f().filter((e=>!e.includes(":")))};const m=(0,s.lazy)((()=>(0,d.mkLogger)("net.ip"))),p=[/^(?:::ffff:)?127\.\d{1,3}.\d{1,3}.\d{1,3}$/i,/^::1$/];function g(e){return(0,a.notBlank)(e)&&(127===function(e){const t=e.split(".").map((e=>(0,u.toInt)(e)));return 4!==t.length||t.some((e=>null==e||!(0,u.within)(0,255,e)))?void 0:t}(e)?.[0]||p.some((t=>null!=t.exec(e))))}t.isLoopback=g,t.isLocalhost=function(e){return m().tap({msg:"isLocalhost",level:"info",result:!(0,a.blank)(e)&&((0,t.myIpAddresses)().includes(e)||(0,t.myIpAddresses)().includes((0,h.stripPrefix)(e,"::ffff:"))||g(e)),meta:{address:e}})}},96128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),w=i(34102),v=i(26293),b=new RegExp("^"+v.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==b.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const S=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=S.exec(e)}function M(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=M,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,n.blank)(e)){if(null!=M(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void _().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs});const _=(0,s.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,o.later)((()=>(0,w.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=M(e)?r.promises.reverse(e):r.promises.resolve4(e),5*a.secondMs);if(t===c.Timeout)return _().info("nslookup("+e+"): timeout"),e;const i=t.find(n.notBlank);return null==i?(_().warn("No name found for "+e),e):i}catch(t){return _().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,n.blank)(e)&&!(0,n.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),s=i(42659),n=i(31586),a=i(97790),o=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*s.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,n.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,a.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,o.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs})},78330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const r=i(40958),s=i(22573),n=i(45599),a=i(59455),o=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),h=i(63870),f=(0,n.defer)((()=>(0,o.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,a.toA)(await async function(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return f().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,r.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(f().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),s=i(38639),n=i(19851),a=i(59958),o=i(43334);t.isDocker=(0,n.lazy)((()=>o.isLinux&&((0,s.toBoolean)(process.env[a.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),s=i(19851),n=i(54993);t.isPacked=(0,s.lazy)((()=>!(0,n.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const r=i(45599),s=i(50213),n=i(84777),a=i(68284),o=i(63870),l=i(43334),u=(0,r.defer)((()=>(0,s.mkLogger)("platform.Pacman")));t.hasPacman=(0,r.defer)((()=>l.isLinux&&(0,a.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,n.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,o.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(22573),o=i(38639),l=i(59958),u=s.default.platform();t.inspectFlag=n.default.argv.includes("--inspect")||(0,o.isTrue)(n.default.env.NODE_INSPECT),t.isCI=(0,o.isTrue)(n.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,a.notBlank)(n.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===s.default.arch(),t.isArm=null!=/^arm\b/i.exec(s.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,a.notBlank)(n.default.env.APPIMAGE)||(0,a.notBlank)(n.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,a.notBlank)(n.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=n.default.versions.electron,t.isElectron=t.isMainElectron||(0,o.isTrue)(n.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const s=r(i(73024)),n=i(19851),a=i(43334);function o(e="/proc/cpuinfo"){if(a.isWin||a.isMac)return!1;try{return null!=s.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=o,t.isRaspberryPi=(0,n.lazy)((()=>a.isLinux_arm&&o())),t.procDeviceModel=(0,n.lazy)((()=>{try{return a.isLinux?s.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},94137:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.negateFilterName=void 0;const r=i(22573),s=i(51926),n=i(83556);t.negateFilterName=function(e){if((0,r.blank)(e))return;const t=/\s/.test(e)?e:(0,n.camel2words)(e).replace(/\bphoto structure\b/gi,"PhotoStructure");return t.match(/^not\b/)?t.replace(/^not\b/,"").trim():"not "+(0,s.stripPrefix)(t,"is ")}},78984:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Predicates=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(51926),o=i(50213),l=i(94137),u=(0,r.lazy)((()=>(0,o.mkLogger)("predicates.Predicates")));class c{static async accepted(e,...t){for(const i of t)for(const t of(0,n.values)(i)){const i=await t(e);if(!1===i||(0,a.isString)(i))return!1}return!0}static async rejected(e,...t){return!await c.accepted(e,...t)}static async explain(e,...t){const i=[],r=[],s=[];for(const o of t)for(const[t,l]of(0,n.entries)(o)){const n=await l(e);!0===n?i.push(t):!1===n||(0,a.isString)(n)?r.push(t):s.push(t)}return{accepted:i,rejected:r,notApplicable:s}}static async whyRejected(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))try{const i=await r(e);if(null==i||!0===i)continue;return(0,a.isString)(i)?i:(0,l.negateFilterName)(t)}catch(e){u().warn("whyRejected() caught from "+t,{error:e})}}static async logged({a:e,logger:t,msg:i,predicates:r}){const{accepted:n,rejected:a}=await c.explain(e,...r);return t.tap({msg:i,result:(0,s.isEmpty)(a),meta:{a:e,accepted:n,rejected:a}})}}t.Predicates=c},33995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncPredicates=void 0;const r=i(68708),s=i(94137);class n{static firstFalse(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!1===s(e))return t}static firstTrue(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!0===s(e))return t}static firstDefined(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i)){const i=s(e);if(null!=i)return{name:t,result:i}}}static accepted(e,...t){return null==n.firstFalse(e,...t)}static whyRejected(e,...t){return(0,s.negateFilterName)(n.firstFalse(e,...t))}}t.SyncPredicates=n},45643:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),s=i(59455),n=i(31562);t.existingPids=function(e){return(0,s.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,n.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),w=i(97790),v=i(59455),b=i(54993),S=i(54557),P=i(19851),M=i(50213),_=i(88158),T=i(409),E=i(78406),D=i(25764),k=i(99331),x=i(56519),F=i(46292),C=i(8769),A=i(83278),I=i(32144),O=i(29882),L=i(43334),R=i(24399),N=i(58261),B=(0,P.lazy)((()=>(0,M.mkLogger)("proc.Pids"))),j=10*p.secondMs;function z(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,O.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,v.toA)(t))B().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,T.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{B().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??L.isWin,r=await this.pidfiles(),s=await this.pids(r??[]);if((0,f.isEmpty)(s))return B().info("killOldProcs(): no pidfiles"),[];const n=[],a=[],o=await(0,N.pidInfos)(s);if(null!=o){for(const s of r){const r=await s.readJson();if(null==r){B().warn("killOldProcs(): failed to read pidfile "+s.base),await s.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){B().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+s.base,{json:r,pid:l}),await s.unlink("debug");continue}const u=o.find((e=>e.pid===l));if(null==u||!z(r,u)){B().debug("killOldProcs(): pid no longer present: unlinking "+s.base,{json:r,pidEntry:u}),await s.unlink("debug"),n.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(B().info("killOldProcs(): killing",{reason:d,json:r}),a.push(W(l,i,!1)),n.push({...r,...u}))}return a.length>0&&await Promise.allSettled(a),n}(0,C.onError)("Pids.killOldProcs(): failed to get process information")}}),a.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const a=e.pid;if(!(0,y.gt0)(a))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(a)?(i&&o(this,s,"f").delete(l),o(this,s,"f").getOrSet(l,(async()=>{const i=o(this,r,"m",n).call(this,e.pid),s=(0,w.opt)((0,_.Try)((()=>(0,O.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),a=t.getTime(),l={...e,cmd:s,startTime:a};return await i.writeJson_(l),B().debug("addPid() wrote "+i,l),i}))):(o(this,s,"f").delete(l),void B().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,v.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=o(this,r,"m",n).call(this,e);return(0,x.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{B().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==o(this,a,"f")||o(this,a,"f").ended)&&l(this,a,new E.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:D.EndableRanks.first}),"f"),o(this,a,"f")}cancelInterval(){o(this,a,"f")?.end(),l(this,a,void 0,"f")}}t.Pids=U,s=new WeakMap,a=new WeakMap,r=new WeakSet,n=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,F.configDir)(),(e=>new U(A.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const s=i(31421),n=i(48161),a=r(i(1708)),o=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),w=i(84968),v=i(48963),b=i(56519),S=i(84777),P=i(8103),M=i(45879),_=i(43334),T=i(24399),E=i(45643),D=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function k(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function x(e){if(_.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,M.readFileMaybe)("/proc/"+i+"/stat")));return D().tap({msg:"pidInfoProc",result:(0,o.compact)(t)})}(e);const t=(0,E.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,_.isWin?I:N)).filter((e=>k(e)&&t.includes(e.pid)));return D().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=k,t.pidInfo=async function(e){return(0,b.thenMap)(x([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,o.isEmpty)(e)?[]:(0,b.thenMap)((0,E.existingPids)(e),(t=>{const i=[a.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=x;const F="Get-Process",C="| Select-Object -Property Id,ProcessName,StartTime";function A(e){return(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).join(",")}async function I(e){if(T.PowerShell.instance().ended)return R(e);const t=[F,"-Id",A(e),"-ErrorAction SilentlyContinue",C].join(" ");return(0,b.thenMap)(T.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,v.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const O={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},L=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,o.isNotEmpty)(e)){const i=(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",L.join(","));const i=await(0,S.stdoutResult_)((0,P.wmic)(),t,O),r=(0,d.onlyReqValued)((0,p.parseFixed)(L,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,v.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return r.find((e=>e.pid===a.default.pid))||r.push({pid:a.default.pid,start:new Date(w.StartTs),cmd:"node "+a.default.title}),r}async function N(e){return t=(await(0,S.stdoutResult_)("ps",["-p",A(e),"-wwwo","pid,lstart,command"],{...O,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const B=(0,g.lazy)((()=>{try{if(_.isLinux)return(0,c.toGt0)((0,s.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){D().warn("clk_tck failed",{error:e})}return 100})),j=(0,g.lazy)((()=>Date.now()-(0,n.uptime)()*u.secondMs)),z=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=z.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,s=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(s)?{pid:i,cmd:r,start:new Date(j()+s/B()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(29882),o=i(97352);t.progressEvtToS=function(e){const t=(0,s.blank)(e.path)?null:(0,a.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,n.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,s.notBlank)(e.op)&&(0,o.within)(0,100,e.pct)}},41944:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),s=i(42659),n=i(31586),a=i(12089),o=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new o.TTLMap(15*s.secondMs))),t.recentDone=(0,r.lazy)((()=>new o.TTLMap(2*s.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,n.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,a.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),s=i(31586),n=i(409),a=i(78406),o=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends a.EndableInterval{constructor(e,t,i,s=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:s,rank:o.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=s,this.start=Date.now(),this.onInterval=(0,n.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,s.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,s.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},38156:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushProgressObserver=void 0;const r=i(31586),s=i(41944);t.PushProgressObserver=class{constructor(e,t){this.context=e,this.total=t,this.start=Date.now()}toJSON(){}incrProgress(e=1){this.onProgress(e+(this.current??0))}onProgress(e){this.current=(e??this.current??0)+1,(0,r.gte)(this.current,this.total)&&(this.done=!0),this.emit()}completed(){this.done=!0,this.current=this.total,this.emit()}emit(){(0,s.emitProgressEvt)({...this.context,pct:(0,r.pct)(this.current,this.total),elapsedMs:Date.now()-this.start,done:this.done})}}},24399:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),w=i(99331),v=i(56519),b=i(31562),S=i(84777),P=i(34102),M=i(43334),_=i(28874),T=i(63870),E="{ready}",D=" | ConvertTo-Json -Compress";function k(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=k,(0,o.later)((()=>(0,P.ee)().on("clearCache",(()=>x.instance.prior()?.clearMockResults()))));class x extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,S.execFile)("powershell",_.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${E}"}`,...(0,n.mapNotBlankOr)(_.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:E,fail:"Error",exitCommand:"exit",maxProcs:_.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,T.commandTimeoutMs)(),maxIdleMsPerProcess:a.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),_.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(_.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,v.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,D),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,w.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,s)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,s)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,D),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,n.blank)(t.stdout)||(0,n.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,v.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+k(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=x,x.instance=(0,s.lazy)((()=>{if(!M.isWin)throw new Error("PowerShell isn't available on this platform");return new x})),t.checkPowerShell_=async function(){const e=x.instance();if(e.ended||(0,w.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,T.commandTimeoutMs)());if((0,n.blank)(t)){const t=await(0,b.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),s=i(38639),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toBoolean})}}t.BooleanSetting=a},90536:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).flatMap(parseFloat).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=o},75164:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).filter(r.notBlank).flatMap(s.toInt).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,s.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=o},10546:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),s=i(22573),n=i(45599),a=i(50213),o=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,n.defer)((()=>(0,a.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,o.trimQuotes)(e);return void((0,s.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,s.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),s=i(91655),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,s.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=a;class o extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=o},9945:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.FloatSetting=a},69589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.forceContextOrSetting=t.pickForceContext=void 0;const r=i(38639),s=i(68708),n=i(50989),a=i(76740),o=i(28874),l=(0,n.strEnum)("forceSync","forceFilters","skipPreviews","forceRebuildPreviews","skipAssetTagging","recountAllTags","skipAssetRepair");t.pickForceContext=function(e){return(0,s.pick)(e,...l.values)},t.forceContextOrSetting=function(e){const t={...(0,s.pick)(e??{},"retries","halt","path"),...(0,s.fromEntries)(l.values.map((t=>[t,e?.[t]??(0,r.isTrue)(o.Settings[t]?.valueOrDefault)])))};return t.retries??(t.retries=0),t.halt??(t.halt=new a.Abortable),t}},74589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt})}}t.IntegerSetting=a},86941:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAndArchiveSystemSettingsDir_=t.mergeUserDataDirs_=void 0;const r=i(19851),s=i(59455),n=i(72993),a=i(46292),o=i(95696),l=i(50213),u=i(83179),c=i(28874),d=i(2858),h=i(84438),f=(0,r.lazy)((()=>(0,l.mkLogger)("settings.MergeConfigDirs")));async function m(e,t){let i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+e.baseWithGrandparent+" => "+t.baseWithGrandparent+")");const r=await e.resolve_(),n=await t.resolve_();if(null==r||null==n||n.nativePath===r.nativePath)return void i.info("no-op, missing or same directory",{priorResolvedConfigDir:r?.nativePath,currentResolvedConfigDir:n?.nativePath});if(i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+r.baseWithGrandparent+" => "+n.baseWithGrandparent+")"),!await r.isDirectory())return void i.info("no-op, prior directory doesn't exist");{const e=r.join(h.SettingsToml);if(await e.isNonEmptyFile()){const t=n.join(h.SettingsToml);await(0,d.readSystemSettings)(e),i.info("read prior settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.readSystemSettings)(t),i.info("read current settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.writeSystemSettings_)(t)}}{const e=r.join("licenses"),t=n.join("licenses");for(const r of(0,s.toA)(await e.childFiles())){const e=t.join(r.base);if(await e.notExists())try{await r.copyFile_(e),i.info("Copied license "+r.base)}catch(e){i.warn("Failed to copy license "+r.base,e)}}}const a=n.join("old");try{const e=await r.renameYMDHMS_({subdir:a.nativePath});i.info("merged and archived to "+e)}catch(e){i.warn("Failed to archive to "+a,e)}}t.mergeUserDataDirs_=async function(){const e=(0,a.configDir)();if(null==e)return;const t=o.PosixFile.for(e);for(const e of[t.join((0,n.AppName)()),t.join((0,n.AppName)().toLowerCase()),t.parent().join((0,n.AppName)().toLowerCase())])try{await m(e,t)}catch(i){f().error("Failed to merge "+e+" and "+t,i)}f().info("done")},t.mergeAndArchiveSystemSettingsDir_=m},4175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),s=i(22573),n=i(38639),a=i(42659),o=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function w(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function v(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){M(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&w(),y("strictDeduping",e)&&v(),(y("optOut",e)||y("noNetwork",e))&&_()},t.handleDeprecatedSettings=async function(){if((0,n.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,s.blank)(m.Settings.assetPathnameFormat.value)&&(0,s.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*a.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=w,t.setStrictDeduping=v;const b=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],S={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function M(e){for(const t of b)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:S;for(const[e,i]of(0,o.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function _(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=M,t.disableExternalNetworkRequests=_},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),s=i(53265),n=i(87652);class a extends n.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,s.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=a},23561:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.OptionalFloatSetting=a},69005:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=a},87652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=s},4936:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathToLibraryAsset=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(55835),l=i(51926),u=i(50213),c=i(81168),d=i(79842),h=i(21330),f=i(51275),m=i(29882),p=i(28874),g=(0,s.lazy)((()=>(0,u.mkLogger)("settings.PathToLibraryAsset")));function y(e){return(0,a.blank)(e)?"":"'"+e.replace(/'/g,"′")+"'"}t.pathToLibraryAsset=function(e,t){const i=(0,d.datedToDateTime)(e)??(0,o.map)((0,h.datedToISO)(e),(e=>r.DateTime.fromISO(e)));if(null==i||!i.isValid)return g().tap({msg:"pathToLibraryAsset(): failed to convert to a valid date",result:void 0,meta:{capturedAt:e,src:t,dt:i}});const s=(0,f.hasZone)(e),a=p.Settings.assetPathnameFormat.valueOrDefault,u=(0,c.splitKeep)(a,/((?:GRAND)?PARENT|BASE|NAME|EXT|ISO)/g);for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),s=i(83556);t.nameFromEnv=function(e){return(0,s.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,s.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const a=i(19851),o=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),w=i(40583),v=i(81168),b=i(44198),S=i(96706),P=i(34102),M=i(28283),_=i(81075),T=i(98778),E=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,a.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?n(this,r,"m",s).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?n(this,r,"m",s).call(this,e??t)+": "+i:null==this.fromEnv(e)?n(this,r,"m",s).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,v.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,S.caseInsensitiveEnv)():new w.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,b.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,o.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,o.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,M.envFromName)(e),this._keys=(0,o.uniq)([...this._names.map(M.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return _.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,b.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&S.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,b.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&S.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new w.CaseInsensitiveValued(e)))??(0,S.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,v.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],E.WrapComments);function i(e,i){(0,o.isEmpty)(i)||t.push(...(0,v.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],E.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,v.wrap)(["",e+": "+r],E.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,T.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,T.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,T.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,s=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),s=i(76760),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),w=i(79840),v=i(7282),b=i(12801),S=i(4328),P=i(70488),M=i(84248),_=i(5531),T=i(99315),E=i(34365),D=i(34580),k=i(96706),x=i(50274),F=i(33866),C=i(52086),A=i(48584),I=i(45969),O=i(43334),L=i(24540),R=i(70379),N=i(71300),B=i(33209),j=i(48987),z=i(68268),V=i(61208),W=i(99023),U=i(30577),q=i(1485),H=i(19861),G=i(55111),$=i(30933),J=i(22859),K=i(71988),Z=i(38483),Y=i(90536),X=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),se=i(9945),ne=i(74589),ae=i(844),oe=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,n.lazy)(v.isProd);const ye=()=>!(0,t.isProd)();function we(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function ve(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new oe.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new ne.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:ve}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Z.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new ne.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:ve}),useFsWatch:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>q.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:q.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>q.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>O.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new ne.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Z.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Z.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!O.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>O.isMac?"100ms":O.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>w.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new se.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new ne.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>b.PriorityClasses.BelowNormal,strEnum:b.PriorityClasses}),maxMemoryMb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!we()}),enableRemove:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!we()}),argon2TimeCost:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:M.AutoVacuumModes,defaultValue:M.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:_.CheckpointTypes,defaultValue:_.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:E.SynchronousModes,defaultValue:E.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:T.RepairModes,defaultValue:T.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 1 minute is very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"1m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Y.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Z.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Z.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:F.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Z.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>O.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new ne.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Z.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Z.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Z.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Z.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,D.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Z.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new ne.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new ne.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new ne.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Z.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Z.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,L.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Z.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Z.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Z.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Z.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,$.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:x.SidecarExts,defaultValue:x.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new se.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Z.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Z.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,$.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:C.CropStrategies.attention,strEnum:C.CropStrategies}),videoFrameAtSec:new se.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Z.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,a.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new ne.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(O.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Y.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>B.DefaultIncludedPreviewTags}),disableAllFilters:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Z.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new ne.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new ne.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:A.SharpFailOns.truncated,strEnum:A.SharpFailOns}),validateRawImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>j.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:ae.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new se.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:z.KeywordReparentingStrategies.move,strEnum:z.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Z.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function be(e){const i=((0,l.blank)(e)?"":e).split(s.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,a.uniq)(i).filter(l.notBlank).join(s.delimiter)}function Se(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=be,t.pathWithDefaults=(0,n.lazy)((()=>be((0,k.getEnv)("PATH")))),t.allSettings=(0,n.lazy)((()=>(0,o.sortBy)((0,d.values)(t.Settings),Se))),t.persistedSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,n.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,n.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),s=i(31586),n=i(7282),a=i(49776),o=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),w=i(15674),v=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{v.Settings.configDir.opts.defaultValue=o.configDir,v.Settings.logDir.opts.defaultValue=c.defaultLogDir_,v.Settings.logServerLevel.opts.defaultValue=()=>v.Settings.logLevel.valueOrDefault,v.Settings.cacheDir.opts.defaultValue=a.defaultCacheDir,v.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,v.Settings.libraryDir.opts.exampleValue=()=>(0,n.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,n.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),v.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,v.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,v.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],v.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,w.maxCpus)()/4)),v.Settings.useFsWatch.watch(f.useFsWatch),v.Settings.updateChannel.opts.defaultValue=g.channel,v.Settings.ffmpegThreads.opts.defaultValue=()=>(0,w.maxCpus)()>=12?2:1,v.Settings.minBusyPct.opts.defaultValue=()=>(0,s.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),w=i(54993),v=i(50213),b=i(81168),S=i(83556),P=i(37805),M=i(87290),_=i(98314),T=i(34102),E=i(83278),D=i(95696),k=i(60865),x=i(4175),F=i(83179),C=i(81075),A=i(28874),I=i(41692),O=i(84438),L=i(32707),R=i(6707),N=i(55018),B=i(10357),j=(0,r.lazy)((()=>(0,v.mkLogger)("settings.SettingsIO")));function z(e){return(0,M.libraryDataDirPosixFile)(e)?.join(O.SettingsToml)}async function V(e=(0,L.systemSettingsFile)()){if(null!=e)return Q(E.BaseFile.for(e))}async function W(){try{return(0,a.toNotBlank)((await(0,R.readTomlFile_)((0,L.systemSettingsFile)()))?.[A.Settings.libraryDir.name])}catch{return}}async function U(){return J((0,L.systemSettingsFile)())}async function q(e){return(0,m.map)(z(e),(e=>J(e)))}function H(){t.libraryHasSettings.refresh()}function G(e){const t=z(e);return j().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:A.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}t.librarySettingsFile=z,t.readSettings=(0,r.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await Y()}),o.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return A.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=U,t.librarySettingsVersion=q,t.maybeUpgradeSystemSettings=async function(){P.version!==await U()&&await Z()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&P.version!==await q()&&await X()},t.libraryHasSettings=(0,r.lazy)((()=>G())),t.libraryHasSettings.unset=()=>{j().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,T.ee)().on("clearCache",H),(0,T.ee)().on("settingsChanged",H),A.Settings.libraryDir.watchLater(H)})),t._libraryHasSettings=G;const $=/^# PhotoStructure v(?\d+\.\d+\.\d+(?:-\S+)?)$/i;async function J(e){if((0,a.blank)(e))return;const t=await E.BaseFile.for(e).firstMatchingLine($);return t?.groups?.version}async function K(e,i){if(null==e)return void j().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),s=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...re("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","-- ","","PhotoStructure v"+(0,t.versionForSettings)())),r.push("","");let s="";for(const e of i){const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==s&&(s=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,T.ee)().emitDebounced("settingsChanged")}(s,i),j().info("writeToml(): wrote settings",{dest:s,file:e,nonDefaults:(0,F.settingsToObj)(i),wip:r}),r){const t=await(0,R.readTomlFile_)(s),i=await(0,R.readTomlFile_)(e);(0,u.eql)(t,i)?(j().info("Equivalent contents",{dest:s,file:e,a:t,b:i}),await s.unlink()):(j().info("Archiving prior, different contents",{dest:s,file:e}),await e.renameYMDHMS_({subdir:"old"}),await s.unwip_())}}async function Z(e=(0,L.systemSettingsFile)()){const t=D.PosixFile.forMaybe(e);return null!=t&&await K(t,(0,A.persistedSystemSettings)()),t}function Y(e){return Q(z(e))}async function X(e){await(0,M.setupLibraryDataDir_)((0,a.firstNotBlank)(e,A.Settings.libraryDir.value));const i=z(e);return j().info("writeLibrarySettings()",{file:i}),null!=i&&(await K(i,(0,A.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function Q(e){if(null==e)return[];const t=j().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await ee(e);return(0,s.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,_.errorToS)(e)),[]}}async function ee(e){const t=j().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,R.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const n=[],a=(0,s.compact)((0,p.entries)(r).map((([e,t])=>{const i=(0,A.getSettingByNameOrKey)(e);if(null==i)n.push(`Failed to import "${e}"${(0,m.mapOr)((0,A.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;n.push(e)}})));return t.info("loaded",{settings:(0,F.settingsToObj)(a),warnings:(0,s.toNotEmpty)(n)}),await(0,x.handleDeprecatedSettings)(),(0,x.handleMetaSettings)(a),{settings:a,warnings:n}}t.versionForSettings=(0,r.lazy)((()=>P.version)),t.writeSystemSettings_=Z,t.writeAllSettings_=function(e){return K(D.PosixFile.for(e),(0,A.persistedSettings)())},t.readLibrarySettings=Y,t.writeLibrarySettings_=X,t._readSettings=Q,t.importFileSettings_=ee;const te=(0,r.lazy)((()=>new Set([A.Settings.noNetwork,A.Settings.httpPort,A.Settings.license,A.Settings.logStdout,A.Settings.logLevel].map((e=>e.key)))));function ie(){for(const e of(0,p.values)(A.Settings))te().has(e.key)||e.unset();(0,T.ee)().emit("settingsChanged")}function re(...e){return(0,d.flatten)(e.map((e=>(0,b.wrap)(e,B.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),A.Settings.libraryDir.unset(),await Z()},t.clearSettings=ie,t.nukeSettings=async function(){ie(),await(D.PosixFile.forMaybe((0,L.systemSettingsFile)())?.unlink("trace")),await(D.PosixFile.forMaybe(z())?.unlink("trace")),(0,T.ee)().emit("clearCache"),I.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...re("",`Welcome to PhotoStructure! These are the settings for version ${(0,k.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...re("","The following settings categories are stored in the system settings.toml:","",...(0,n.sort)([...C.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,n.sort)([...C.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...re("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...re("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const n=`${e.key} or ${e.name}`,a={...e.addToJSON()};(0,s.mapNotEmpty)(e.altKeys,(e=>a.aliases=(0,h.orList)(e)));const o=(0,p.entries)(a).map((([e,t])=>`${(0,b.capitalize)((0,S.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,s.isNotEmpty)(o)&&o.push(""),i.push(...re((0,g.padding)("-",n.length),n,(0,g.padding)("-",n.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...o,`${e.key}=${(0,f.stringify)((0,w.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(98553),o=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,a.stringify)(e)}t._join=c;function d(e){return(0,o.map)(function(e){const t=(0,n.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,s.compact)((0,l.toA)(JSON.parse(t)).map(n.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,s.compactBlankish)(t.split(e));return[t]}}(e),s.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,n.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,s.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,s.isEmpty)(e)||(this.value=this.toValidValues((0,s.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,s.isEmpty)(this.values)}isNotEmpty(){return(0,s.isNotEmpty)(this.values)}toNotEmpty(){return(0,s.toNotEmpty)((0,s.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=s},72564:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),s=i(98553),n=i(55835),a=i(58305);class o extends a.StringArraySetting{constructor(e){super({toEnv:e=>(0,n.map)(e,(e=>(0,s.stringify)((0,r.uniq)(e)))),fromEnv:t=>{return i=t,s=e.strEnum,(0,r.compact)((0,a.splitStringArray)(i)?.map((e=>s.getCI(e))));var i,s},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=o},80372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),s=i(81168),n=i(83179);class a extends n.Setting{constructor(e){super({toEnv:o,fromEnv:o,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function o(e){return null==e?void 0:(0,s.trimQuotes)(e)}t.StringSetting=a},32707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),s=i(55835),n=i(46292),a=i(84438);t.systemSettingsFile=function(){return(0,s.map)((0,n.configDir)(),(e=>(0,r.join)(e,a.SettingsToml)))}},80496:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),s=i(44652),n=i(22573),a=i(76850),o=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,a.debom)(e),(0,n.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,n.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,s.readFileSync)(t)):void 0}catch(e){return void(0,o.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,n.mapNotBlank)(e,(async e=>f(await(0,s.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,s.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),s=i(96249),n=i(98553),a=i(68708),o=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const s=e+" = "+(0,n.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[s]:(0,o.wrap)(s.split("\n"),i)}t.stringifyToml=function(e){return(0,s.flatten)((0,a.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,o.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},10357:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const r=i(54993),s=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=a(e[t]);if(null!=i)return i}};const n=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function a(e){const t=(0,s.extractFloat)(e);if(null==t)return;const i=(0,r.toS)(e).toLowerCase();for(const e of n)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),s=i(81168);t.bname=function(e,t=!0){let i=(0,s.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,s.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),h=i(31586),f=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),w=i(81168),v=i(76596),b=i(79842),S=i(66649),P=i(21330),M=i(98725),_=i(928),T=i(54261),E=i(89724),D=i(17415),k=i(88600),x=i(51275),F=i(29882),C=i(17217),A=i(68284),I=i(57902),O=i(28874),L=i(65162),R=i(71300),N=i(14036),B=i(61424),j=(0,s.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function z(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,f.isObject)(e)&&(0,o.notBlank)(e.nativePath)&&(0,b.isDated)(e.date)&&(0,o.notBlank)(e.src)}t.capturedAtSrcFromTags=z,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class U{static fromAssetFile(e){return(0,d.map)((0,E.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>U.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof U?e:W(e)?new U(e):void 0}constructor(e){var t;this.nativePath=(0,C.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,h.toGt0)(e.local)??(0,E.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,b.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(O.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,S.datedToMillis)(e.mtime)??(0,A.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:U.name,...(0,f.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,M.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,D.fmtOffsetMinutes)});return null==t?void 0:new U({...e,date:t})}spread(e){return new U({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,D.fmtOffsetMinutes)(this.offset)}get isFromTags(){return z(this.src)}get isInferred(){return!z(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,E.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,v.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,x.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,T.hasTime)(this.date)}hasMillis(){return(0,h.gt0)((0,_.getMillisecond)(this.date))}toMillis(){return(0,S.datedToMillis)(this.date)}get isValid(){return(0,k.isValidDate)(this.date)}get zoneName(){return(0,r.offsetMinutesToZoneName)(this.offset)??(0,x.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,D.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?O.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,b.datedToStartDateTime)(this.date)??(0,b.datedToDateTime)(this.date);if(null!=i)return{start:(0,E.datedToLocal)(i.minus(t)),end:(0,E.datedToLocal)(i.plus(t))};j().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:O.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),r=Math.max(t,e.fuzzyPrecisionMs());return j().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,b.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:r}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:r}})}}function q(e,t){if(null==e)return;const i=(0,n.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>U.for(e))));for(const r of t){let t=e[r],s=r;if((0,k.isValidDate)(t)){if((0,D.isValidZone)(e.tz)&&(!(0,x.hasZone)(t)||R.OverrideUTCZoneTags.includes(s))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,o.blank)(e.tzSource)?"":" from "+(0,w.stripPrefix)(e.tzSource,"from ");s+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,E.datedToLocalSec)(t),date:t,src:s,precisionMs:(0,b.datedToPrecisionMs)(t),rawValue:e[r]?.rawValue})}}const r=(0,p.leastBy)(i,(e=>(0,b.datedToStartTs)(e.date)));if(null==r)return;const s=i.filter((e=>(0,u.eql)(e.date,r.date)||e.precisionMs<=r.precisionMs&&(0,b.datedOverlap)({a:e.date,b:r.date,aPrecisionMs:e.precisionMs,bPrecisionMs:r.precisionMs}))),a=(0,p.leastBy)(s,(e=>[Math.floor(e.localSec/1e6),(0,x.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return j().debug("capturedAtFromTags()",{least:r,overlapsWithLeast:s,earliest:a}),a}function H(e,t){if(O.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,n.uniq)([(0,L.bname)(e,!0),(0,L.bname)(e,!1)])){const e=(0,M.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,b.datedToPrecisionMs)(e),l.secondMs])}}}function G(e){if(O.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,M.extractDateFromPath)(e.pathsForDateParsing)}}async function $(e){if(O.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=U,t.bestCapturedAt=function(e){const t=(0,a.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const r=await e.mtimeMs();function s(t,i){return W(i)?U.for(i):null!=i&&null!=i.date&&(0,k.isValidDate)(i.date)?U.for({nativePath:e.nativePath,date:i.date,local:(0,E.datedToLocal)(i.date),src:(0,w.uniqPath)([t,i.src]),mtime:r,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const n=function(e,t){return null==e||t||!O.Settings.usePathsToInferDates.valueOrDefault||!O.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,F.containedByNativePath)({ancestor:O.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),a=s("tags",q(t,O.Settings.capturedAtTags.values))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??s("tags",q(t,O.Settings.capturedAtTagsFallback.values))??(n?void 0:s("bname+stat",await(0,B.extractStatBname)(e)))??(n?void 0:s("path+stat",await(0,B.extractStatPathTime)(e)))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??(n?void 0:s("bname",H(e,t)))??(n?void 0:s("path",G(e)))??(O.Settings.useStatToInferDates.valueOrDefault?s("stat",await $(e)):void 0);return j().tap({level:I.LogLevels.debug,msg:"extractCapturedAt()",result:a})},t.capturedAtFromTags=function(e){return q(e,O.Settings.capturedAtTags.values)},t.capturedAtFromBasename=H,t.capturedAtFromPath=G,t.capturedAtFromStat=$},70379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const r=i(31586),s=i(97352),n=i(95696),a=i(47783),o=i(16170);function l(e){if(null!=e&&(0,o.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,r.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,s.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=n.PosixFile.for(e);return l(await(0,a.readRawTags)(t,!1))}},47783:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const s=i(77988),n=r(i(76760)),a=r(i(1708)),o=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(23838),f=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),w=i(12168),v=i(56038),b=i(4867),S=i(36557),P=i(98247),M=i(21330),_=i(98725),T=i(23467),E=i(88561),D=i(95696),k=i(17217),x=i(16287),F=i(50213),C=i(17921),A=i(7282),I=i(88158),O=i(23560),L=i(28874),R=i(12089),N=i(45255),B=i(81168),j=i(63870),z=i(15674),V=i(28544),W=i(43207),U=i(75767),q=i(12788),H=i(80495),G=i(14036),$=i(67083),J=i(3432),K=i(28630),Z=i(15912),Y=i(30748),X=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),re=i(61424),se=i(8791),ne=(0,o.lazy)((()=>(0,F.mkLogger)("exiftool.ExifTool")));let ae=!1;t.addInstanceIdsToTags=function(e){ae=e},t.setExifToolProcs=function(e){return L.Settings.exiftoolProcsPerChild.envValue=e,ue()};const oe=(0,o.lazy)((()=>new S.BatchClusterObserver("ExifTool",new s.ExifTool({useMWG:L.Settings.useMWG.valueOrDefault,backfillTimezones:L.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:L.Settings.defaultVideosToUTC.valueOrDefault,...(0,S.batchClusterOptions)((0,A.isTest)()?8:(0,O.isSyncService)()?L.Settings.exiftoolProcsPerChild.value??(0,z.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=oe();return e.ended?oe.refresh():e}function ue(e=!1){return(0,d.map)(oe.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,b.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(oe.prior(),(e=>e.ended?void 0:(0,b.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,j.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,f.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,k.toNativePath_)(e))}async function he(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function fe(e){const t=[];return L.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*w.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,B.includesIgnoreCase)(L.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return ne().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const r=i??await(0,te.readMimeType)(e),s=await e.sidecar(),n=(0,X.isImageMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,a=(0,X.isVideoMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,o=L.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await s.exists(),l=n||a||o;return ne().tap({msg:"writeTagDest()",result:l?s:e,meta:{src:e,tagName:t,mimetype:r,writeMetadataToSidecarsIfImage:n,writeMetadataToSidecarsIfVideo:a,writeMetadataToSidecarsIfSidecarExists:o}})}async function pe(e,i=!0){const r=D.PosixFile.for(e);if(r.isSidecar()&&(i=!1),!await r.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(r.nativePath),void ne().debug("readRawTags("+r+"): invalid file, returning null.");const s=await(0,t._readRawTags)(r.nativePath);if(null==s||!i)return s;ne().trace("readRawTags()",{pf:r,pickedFileTags:(0,f.pick)(s,"tz","tzSource",...L.Settings.capturedAtTags.values)});const n=[];for(const e of await r.jsonSidecars())n.push([e,(0,K.readJsonSidecar)(e,s.tz)]);for(const e of await r.existingExifSidecars())n.push([e,(0,t._readRawTags)(e.nativePath)]);const a={original:{},MIMEType:(0,u.mapNotBlank)(s.MIMEType,X.normalizeMimetype),...s},o=[];for(const[e,i]of n){if(null==i)continue;const r=await i;if(null==r)continue;const s=(0,f.omit)(r,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,f.values)(s))?((a.sidecars??(a.sidecars=[])).push(e.base),o.push(...(0,g.toA)(r.History)),(0,I.assignNullishFields)(a.original,(0,f.pick)(a,...(0,f.keys)(s))),(0,f.assignFields)(a,s),ne().debug("readRawTags() sidecar had values",{sidecar:e.base})):ne().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return a.inferred=(0,$.getInferredHistoricValues)(o,e),(0,I.assignNullishFields)(a,a.inferred),a.Rotation=(0,Q.orientationToRotation)(a.Rotation),ne().debug("readRawTags() final",{pf:r,inferred:a.inferred,pickedResult:(0,f.pick)(a,"tz","tzSource",...L.Settings.capturedAtTags.values)}),a}async function ge(e,t){return null==t?void 0:(0,v.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,r=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,X.normalizeMimetype);if((0,u.blank)(r))return void ne().debug("No mimetype for "+i);const n={...t.inferred??{},...t};if(n.inferred??(n.inferred={}),n.original??(n.original={}),L.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const t=n[e];if((0,p.isString)(t)){const i=(0,_.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(ne().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),n[e]=i)}}const o=!await(0,re.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,n,o);if(ne().debug("parseTags()",{tzMeta:l,skipSiblingInference:o}),null!=l?.tz){const e=n.tzSource!==s.defaultVideosToUTC&&void 0;for(const t of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const i=n[t];i instanceof s.ExifDateTime&&(n[t]=(0,M.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,f.assignUndefinedFields)(n.original,n,"tz","tzSource"),(0,f.assignFields)(n,l),(0,f.assignFields)(n.inferred,l)}const c=o?(0,Y.extractMakeAndModel)(n):await(0,re.inferMakeAndModel)(e,n);c.Make!==(0,Y.make)(n.Make)&&(n.original.Make=n.Make,n.inferred.Make=c.Make),c.Model!==(0,Y.model)(c.Make,n.Model)&&(n.original.Model=n.Model,n.inferred.Model=c.Model),!(0,u.blank)(L.Settings.defaultCopyright.valueOrDefault)&&(0,q.isExifUnset)(n.Copyright)&&(n.Copyright=L.Settings.defaultCopyright.valueOrDefault);const d=(0,Z.extractLensMakeModel)(n),h=await(0,V.extractCapturedAt)(e,n,o);if(null==h)return void ne().info("No capturedAt for "+e);!o&&h.isInferred&&(n.inferred.capturedAt=h);const m=(0,H.extractExposureSettings)(n),g=await(0,ie.extractSizeInfoFromFile)(e,n);if(null==g)return void ne().info("No size info for "+i);const y={...c,mimetype:r,capturedAt:h,exposureSettings:m,...(0,se.extractTitleDescription)(n),...d,cameraId:(0,U.cameraIdFromTags)(n),imageId:(0,U.imageIdFromTags)(n),lensId:(0,U.lensIdFromLensInfo)({...d,...(0,f.pick)(n,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(n),tz:n.tz,rating:(0,ee.extractRating)(n)};(0,A.isTest)()&&(y.__parsedBy__=a.default.pid);const w={...n,...y};return ne().debug("parsedTags",{nativePath:i,skipInference:o,...y,inferred:n.inferred,original:n.original,pickedResult:(0,f.pick)(w,"capturedAt","tz","tzSource","Make","Model")}),(0,f.definedValues)(w)}catch(e){return void ne().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,f.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,f.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,T.eqlAsync)(e.sha(),t.sha())||await(0,T.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=D.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,k.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,k.toNativePath_)(e),["-"+t]);return(0,I.pluckCaseInsensitive)(i,t)}catch(e){return void ne().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=he,t.overwriteTags_=async function(e,t){try{await(0,v.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await fe(e)),e.clearThisAndParent()}))}catch(i){ne().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,v.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=fe,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,v.time)("exiftool.writeTags:"+e,(async()=>{const r=new h.MultiMap;for(const[s,n]of(0,f.entries)(t)){const t=await me(e,s,i);r.add(t.nativePath,[s,n])}for(const[t,i]of r.entriesArray()){const r=D.PosixFile.for(t),s=(0,f.fromEntries)(i);ne().info("writeTags()",{src:e,dest:t,t:s}),await le().write(r.nativePath,s,await fe(r)),L.Settings.overwriteOriginal.valueOrDefault||await he(r),r.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,x.nativePathIsFile)(e))return ne().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);ne().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...L.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,G.isVideoExt)(n.default.extname(e))?[]:["-fast"]],r=await(0,v.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{ne().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==r)return;ne().debug("_readRawTags()",{nativePath:e,pickedTags:(0,f.pick)(r,"tz","tzSource",...L.Settings.capturedAtTags.values)}),r.MIMEType=(0,u.mapNotBlank)(r.MIMEType,X.normalizeMimetype),r.GPSDateTime??(r.GPSDateTime=(0,P.concatDateTime)(r.GPSDateStamp,r.GPSTimeStamp));for(const e of(0,f.keys)(r)){const t=r[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete r[e])}const s=(0,l.compactBlanks)([r.Error,...r.errors??[],r.Warning].map(y.toS));return(0,l.isNotEmpty)(s)&&(r.problems=s),ae&&(r.__instance=(0,C.safeUUID)()),r}}),t.parseTags=ge},75767:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(98553),o=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),h=i(54993),f=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),w=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const v=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function b(e){const t=null==e?[]:e.filter((([,e])=>!(0,n.blank)(e)));return 0===t.length?void 0:(0,a.stringify)((0,u.fromEntries)(t))}function S(e){return(0,h.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new o.MultiMap,r=[];for(const a of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(s=e[a])||(0,n.blankish)(s)||(0,l.isNumber)(s)&&(0===s||1===s)||null!=t.zeroesRe.exec((0,h.toS)(s)))continue;const o=e[a],u=S(e[a]),c=(0,t.Tag2SynonymGroup)().get(a);if(null!=c){if(i.includes(c,o)||i.includes(c,u))continue;i.add(c,o)}r.push([a,(0,l.gt0)(o)?o:u])}var s;return b(r)}function M(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function _(e){if((0,n.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([M(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(M)):(0,u.compactBlankValues)(t)}function T({a:e,b:t,field:i,desc:r,parser:s}){const n=s(e[i]),a=s(t[i]),o=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==n||null==a||(0,l.approximates)(n,a,o)?void 0:"Different "+r+": "+e[i]+" ≠ "+t[i]}function E(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,n.blank)(e.lensMake)||(0,n.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,r.lazy)((()=>{const e=new Map;for(const t of v){const i=t[0];for(const r of t)e.set(r,i)}return e})),t.Tag2Synonyms=(0,r.lazy)((()=>{const e=new Map;for(const t of v)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=b,t.renderExifUidId=P,t.decodeExifUid=_,t.findInequalFields=function(e,i){const r=_(e),n=_(i);if(null==r||null==n||e===i)return;const a=(0,f.intersection)((0,u.keys)(r),(0,u.keys)(n)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of a){const t=r[e],i=n[e];if(S(t)!==S(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of v){const t=(0,u.pick)(r,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(n,...e);if((0,u.isEmptyObj)(i))continue;const a=(0,u.values)(t).map(h.toS),o=(0,u.values)(i).map(h.toS);if((0,s.includesAny)(a,o))continue;const l=(0,f.least)((0,u.keys)(t)),c=(0,f.least)((0,u.keys)(i));return{aKey:l,aValue:r[l],bKey:c,bValue:n[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>T({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>T({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>T({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>T({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return E({...(0,w.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=E,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const r=i(22573),s=i(54993),n=/undefined|null|none|n\/a|unknown/i;function a(e){return null==e||(0,r.blank)(e)||n.test((0,s.toS)(e))}t.isExifUnset=a,t.toExifDefined=function(e){return a(e)?void 0:e}},80495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const r=i(19851),s=i(22573),n=i(31586),a=i(68708),o=i(54993),l=i(50213),u=i(97352),c=(0,r.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,s.firstNotBlank)((0,o.toS)(e.ExposureTime),(0,o.toS)(e.ShutterSpeed),(0,o.toS)(e.ShutterSpeedValue),(0,o.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,a.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,n.gt0)(e))return e;const[t,i]=(0,o.toS)(e).split("/").map((e=>(0,n.toInt)(e)));return(0,n.gt0)(t)&&(0,n.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,n.toFloat)(e);return(0,n.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),s=i(40958),n=i(96249),a=i(23838),o=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,o.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,o.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new a.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,n.flatten)((0,o.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function w(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=w,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return w(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return w(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return w(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return w(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return w(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return w(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return w(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return w(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),h=i(50989),f=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),w=i(50213),v=i(81168),b=i(66649),S=i(17415),P=i(29882),M=i(95696),_=i(17217),T=i(28874),E=i(47783);function D(e,t){return(0,d.entries)(t??{}).map((([t,i])=>k({action:e,key:t,value:i})))}function k({action:e,key:t,value:i,ts:s}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:r.ExifDateTime.fromMillis(s??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,h.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=D,t.mkHistoryRecord=k,t.InferAction="infer";const x=(0,s.lazy)((()=>(0,w.mkLogger)("tags.History")));function F(e,t){if(null==e||null==e.History||(0,f.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function C(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,o.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function A(e){if(null==e)return;const t={};for(const[i,r]of(0,d.entries)(e))(0,v.isFirstCharAZ)(i)&&(t[i]=r);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,S.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function I(e,i,r){if(null==e||(0,o.blank)(e))return void x().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const s=(0,_.toNativePath_)(e),a=await(0,E._readRawTags)(s),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!F(a,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...r??{}};if((0,n.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void x().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:r,tagsToWrite:c});x().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:r});const h=M.PosixFile.for(e);return await(0,E.overwriteTags_)(h,c),h.clearThisAndParent(),u}t.tagsContainHistory=F,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const s=(0,m.toA)(e);if((0,n.isEmpty)(s))return{};const l=(0,a.sortBy)(s.filter((e=>(0,v.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,b.datedToMillis)((0,o.mapNotBlank)(e.When,(e=>r.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,o.notBlank)(t)){const r=C(e);(0,o.blank)(r.nativePath)||(0,P.eqlNameWithoutExt)(r.nativePath,i)?u[t]=r:x().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=C,t.inferredToTags=A,t.ensureInferredHistoryRecords=async function(e,i,r){const s=D(t.Actions.infer,r),n=(T.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?A(r):void 0)??{};return T.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(n.Source=e.nativePath),x().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:s,additionalTags:n}),I(i,s,n)},t.ensureHistoryRecords=I},3432:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const s=r(i(53705)),n=i(77988),a=i(19851),o=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),h=i(17415),f=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),w=i(61424),v=(0,a.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function b(e,t,i){{const e=S(t);if(null!=e&&(0,h.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,h.isValidZone)(t.tz)||t.tzSource===n.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,o.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof n.ExifDateTime&&(0,h.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,w.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function S(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return v().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,s.default)(t,i),r=(0,h.normalizeZone)(e);return v().tap({msg:"zoneFromLatLon()",result:r,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return v().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,f.isValidDate)(i))for(const r of g.Settings.capturedAtTags.values){const s=(0,u.toDated)(t[r]);if(null==s||(0,f.isValidDate)(s))continue;const n=Math.round(15*i.diff(s,"minutes").as("minutes")/15),a=(0,h.normalizeZoneOffsetMinutes)(n),o=0===a?void 0:(0,h.normalizeZone)(a);if(null!=o)return v().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:o.name,tzSource:"infer:filename (diff with "+r+")"},meta:{dt:(0,c.datedToISO)(s),rawTzoffsetMinutes:n,normalizedOffsetMinutes:a}})}}t.maybeInferTimezone=async function(e,t,i){return v().tap({msg:"maybeInferTimezone()",result:await b(e,t,i)})},t.zoneFromLatLon=S,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const r=i(77988),s=i(40958),n=i(22573),a=i(38639),o=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),h=i(48884),f=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const s=(0,p.normalizeZone)(e?.formatted),n=r.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:s??t??r.UnsetZone});if(!0===n?.isValid)return n}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,n.toNotBlank)(e.title),Description:(0,n.toNotBlank)(e.description),GPSLatitude:(0,h.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,f.validLat)(e)?e:void 0)),GPSLongitude:(0,h.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,f.validLon)(e)?e:void 0)),GPSAltitude:(0,h.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,o.map)(e.favorited,a.isTrue),peopleNames:(0,s.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,s.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},97573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rawTagKeywords=t.parseKeywordStruct=t.isKeywordStruct=t.parseCategories=t.splitKeywords=t.splitKeyword=t.delimRe=t.keywordToPath=void 0;const r=i(77988),s=i(66150),n=i(19851),a=i(40958),o=i(22573),l=i(41400),u=i(96249),c=i(68708),d=i(59455),h=i(48884),f=i(50213),m=i(68852),p=i(81168),g=i(28874),y=(0,n.lazy)((()=>(0,f.mkLogger)("tags.KeywordTags"))),w=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordPathSeparators.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g")))));function v(e){const i=(0,t.delimRe)();return null==i?[e]:(0,a.compactBlanks)(e.split(i))}function b(e){return null==e||e instanceof r.BinaryField?[]:(0,a.compactBlanks)(Array.isArray(e)?(0,u.flatten)(e.map(b)):v(e))}function S(e){return null==e?[]:(0,p.isString)(e)?(0,o.blank)(e)?[]:[[e]]:(0,u.flatten)((0,d.toA)(e.Category).map(S).map((t=>t.map((t=>(0,a.compact)([e._,...t]))))))}(0,l.later)((()=>{g.Settings.keywordPathSeparators.watchLater((()=>w.unset()))})),t.keywordToPath=function(e){const t=w();return(0,a.compactBlanks)(null==t?[e]:e.split(t))},t.delimRe=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g"))))),g.Settings.keywordDelimiters.watchLater((()=>t.delimRe.unset())),t.splitKeyword=v,t.splitKeywords=b;const P=/^\(?none\)?$/i;function M(e){if(!(0,o.blank)(e)&&null==P.exec(e))try{const t=new s.XMLParser({textNodeName:"_"}).parse(e);return(0,u.flatten)((0,d.toA)(t?.Categories?.Category).map(S))}catch(t){return void y().warn("parseCategories() failed:",{err:t,s:e})}}function _(e){return Array.isArray(e)&&e.every(_)||null!=e&&(0,p.isString)(e.Keyword)&&(null==e.Children||Array.isArray(e.Children)&&e.Children.every(_))}function T(e){if(null==e)return[];if(Array.isArray(e)&&e.every(_))return(0,h.flatMap)(e,T);if((0,o.blank)(e.Keyword))return[];const t=(0,d.toA)(e.Children);return(0,a.isEmpty)(t)?[[e.Keyword]]:(0,h.flatMap)(t,T).map((t=>[e.Keyword,...t]))}t.parseCategories=M,t.isKeywordStruct=_,t.parseKeywordStruct=T,t.rawTagKeywords=function(e){const t=[];if(null!=e){const i=[...g.Settings.keywordTags.values];if(i.includes("Categories")){(0,h.remove)(i,"Categories");const r=M(e.Categories);null!=r&&t.push(...r)}for(const r of i){const i=(0,c.pluckDeep)(e,r)?.value;(0,o.blank)(i)||(_(i)?t.push(...T(i)):t.push(...Array.isArray(i)?i:b(i)))}}return y().tap({msg:"rawTagKeywords()",result:(0,a.compactBlankish)((0,a.uniq)(t)),meta:{t:null==e?void 0:(0,c.pick)(e,...g.Settings.keywordTags.values)}})}},15912:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(55835),o=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),h=i(28874),f=i(30748),m=(0,r.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,f.make)(e.LensMake),i=(0,f.make)(e.Make),r=[],o=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],b),u=(0,s.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:o,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&r.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==b(e))continue;(0,n.notBlank)(t)&&r.push({lensMake:t,lensModel:e,lensInfo:o});const a=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))a.includes(t)&&r.push({lensMake:i,lensModel:e,lensInfo:o});for(const i of(0,s.compactBlanks)([t,...h.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&r.push({lensMake:i,lensModel:e,lensInfo:o});a.startsWith("vr ")&&"Nikon"===i&&r.push({lensMake:"Nikon",lensModel:e,lensInfo:o})}for(const e of r){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=S(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,a.map)(e.lensInfo,S)}return(0,c.greatestBy)(r,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const w=/([\d. -]+)\s?mm\b/i,v=/\bf\/?([\d.\-]+)/i;function b(e){if((0,n.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=w.exec(e)?.[1].replace(/\s/g,""),i=v.exec(e)?.[1];return y(t)&&y(i)?S(`${t}mm f/${i}`):void 0}function S(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,a.mapOr)((0,o.toFloat)(e),(e=>String((0,o.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=b,t.cleanBogusPrecision=S,t.normalizeLensModel=function(e){return S(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(68708),o=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function h(e,t,i=""){const r=e.replace(t,i);return r===e?e:h(r,t,i)}const f=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=f.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,r.lazy)((()=>new p)),y=/\bgopro\b/i;function w(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=h(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=w(e.Make)??b(e.Software)??b(e.CreatorTool)??function(e){return y.test((0,o.toS)(e.HandlerDescription))||y.test((0,o.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,a.compactValues)({Make:t,Model:i})??{}},t.make=w;const v={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function b(e){if(!(0,s.blank)(e))for(const[t,i]of(0,a.entries)(v))if(i.test(e))return t}t.makeFromSoftware=b;const S=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=S.exec(i);null!=e&&(i=e[1].trim())}const r=(0,n.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=r)return r[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,n.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=h(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},38010:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MergedTags=t.revisionToResourceEvent=t.resourceEventToRevision=t.isSetRevision=t.isPrimitiveRevision=t.isBaseRevision=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(55835),u=i(31586),c=i(68708),d=i(67478),h=i(59455),f=i(54993),m=i(72993),p=i(50213),g=i(84885),y=i(66649),w=i(98725),v=(0,s.lazy)((()=>(0,p.mkLogger)("tags.MergedTags")));function b(e){return(0,u.isNumber)(e?.createdAt)&&(0,o.notBlank)(e?.field)}function S(e){return null==e?.op&&b(e)}function P(e){return e?.sourceIsPrimary??e?.shown??!1}function M(e){return e?.sourceModifiedTime??e?.mtime??0}t.isBaseRevision=b,t.isPrimitiveRevision=S,t.isSetRevision=function(e){return["add","delete"].includes(e?.op)&&b(e)},t.resourceEventToRevision=function(e){if(null==e||!(0,f.toS)(e.SoftwareAgent).startsWith((0,m.AppName)()))return v().tap({msg:"resourceEventToRevision() invalid",result:void 0,meta:{resourceEvent:e}});const t=e.Changed;if((0,o.blank)(t))return v().tap({msg:"resourceEventToRevision() missing Changed field name",result:void 0,meta:{resourceEvent:e}});const i=(0,c.pick)((0,o.mapNotBlank)(e.Parameters,d.parseJSON)??{},"newValue","priorValue");if((0,c.isEmptyObj)(i))return v().tap({msg:"resourceEventToRevision() missing Parameter fields",result:void 0,meta:{resourceEvent:e}});const r=(0,y.datedToMillis)((0,w.parseDated)({input:e.When}));return null==r?v().tap({msg:"resourceEventToRevision() missing createdAt (When)",result:void 0,meta:{resourceEvent:e}}):(0,o.blank)(e.Action)?v().tap({msg:"resourceEventToRevision() missing op (Action)",result:void 0,meta:{resourceEvent:e}}):v().tap({msg:"resourceEventToRevision()",result:{createdAt:r,field:t,op:"assign"===e.Action?void 0:e.Action,...i},meta:{resourceEvent:e}})},t.revisionToResourceEvent=function(e){return{Action:e.op??"assign",Changed:e.field,InstanceID:(0,l.map)(e.id,f.toS),Parameters:(0,g.stringifySorted)((0,c.pick)(e,"newValue","priorValue")),SoftwareAgent:(0,m.AppNameVersion)(),When:r.ExifDateTime.fromMillis(e.createdAt??Date.now())}},t.MergedTags=class{constructor(e){this.name=e,this.revisions=[],this.tags=[],this.logger=(0,p.mkLogger)(`MergedTags(${e})`)}addRevision(...e){this.revisions.push(...e)}addTag(...e){this.tags.push(...e),(0,a.sortBy)(this.tags,(e=>[!P(e),-M(e)]))}get(e){const t=(0,a.sortBy)(this.revisions.filter((t=>t.field===e)),(e=>e.createdAt)),i=this.tags.find((t=>null!=t[e]));let r=i?.[e];const s=[];var l;null!=r&&(0,o.mapNotBlank)((l=i,l?.SourceFile??l?.uri),(e=>s.push(e)));const u=t.every(S)&&this.tags.every((t=>!Array.isArray(t[e])));if(u){for(const i of t)null!=r&&r!==i.priorValue&&r!==i.newValue?this.logger.info("get("+e+"): skipping revision because expected prior or new value didn't match current value",{revision:i}):(r=i.newValue,s.push(`Revision@${i.createdAt}`));return null==r?void 0:{value:r,source:s}}{const e=(0,h.toA)(r);for(const i of t)if("add"===i.op&&null!=i.newValue)s.push(`Revision@${i.createdAt}`),(0,n.pushUniq)(e,...(0,h.toA)(i.newValue));else if("delete"===i.op&&null!=i.priorValue){s.push(`Revision@${i.createdAt}`);for(const t of(0,h.toA)(i.priorValue))(0,n.remove)(e,t)}return{value:e,source:s}}}}},16170:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const r=i(22573),s=i(54993),n=i(2322),a=i(277),o=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function h(e){return(0,r.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function f(e){const t=(0,s.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,n.isChrome)(t)||(0,n.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,s.toS)(e))},t.isImageMimeType=function(e){return(0,s.toS)(e).startsWith("image/")},t.isVideoMimeType=h,t.normalizeMimetype=f,t.isSharpMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,r.blank)(t)&&(h(t)?await(0,l.isVideoSupported)():(0,o.isHeifMimeType)(t)?await(0,a.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},66039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderNameTag=t.parseName=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(55835),l=i(75020),u=i(59455),c=i(50213),d=i(68852),h=i(81168),f=i(70417),m=i(28874),p=(0,r.lazy)((()=>(0,c.mkLogger)("tags.Names")));function g(e){return(0,d.matchQuotes)((0,d.escapeRegExp)(e))}const y=/(\(\s*\d+\s*-\s*[\d?]{0,4}\s*\)?)/,w=/([,\s]+(?:jr\.?|junior|sr\.?|senior|[iv]+\.?))$/i,v=/\b([A-Z‘’']+[-A-Z‘’']{2})\b/,b=/^[()[\]/.\-_]+$/;function S(e){if((0,a.blank)(e))return;let t=e.replace(/\s+/g," ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").trim();const i=(0,o.map)((0,h.spliceCapture)(t,y),(e=>(t=e.unmatched.trim(),e.captured.replace(/\s+/g,"")))),r=(0,o.map)((0,h.spliceCapture)(t,w),(e=>(t=e.unmatched.trim(),e.captured.trim()))),l=[],c=[],b=[];for(const e of m.Settings.tagNamesGiven.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(l.push(i.captured),t=i.unmatched.trim())}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesGivenSurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`(${(0,d.escapeRegExp)(e.charAt(0))}\\s*[^${(0,d.escapeRegExp)(e.charAt(0))}]+\\s*${(0,d.escapeRegExp)(e.charAt(1))})`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(c.push(i.captured),t=i.unmatched.trim())}while(null!=i)}let S;function M(e){(null==S||S>e.matchedIndex)&&(S=(0,f.min)([S,e.matchedIndex]))}if(m.Settings.tagNamesCapitalizedAsFamily.valueOrDefault){let e;do{e=(0,h.spliceCapture)(t,v),null!=e&&(M(e),b.push(e.captured),t=e.unmatched.trim())}while(null!=e)}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesFamilySurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`${(0,d.escapeRegExp)(e.charAt(0))}\\s*([^${(0,d.escapeRegExp)(e.charAt(0))}]*)\\s*${(0,d.escapeRegExp)(e.charAt(1))}`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(M(i),b.push(i.captured),t=i.unmatched.trim())}while(null!=i)}if(m.Settings.tagNamesLexical.valueOrDefault){const e=t.indexOf(",");e>=0&&(S=void 0,b.push(t.substring(0,e).trim()),l.push(t.substring(e+1).trim()),t="")}for(const e of m.Settings.tagNamesSurnames.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(M(i),b.push(i.captured),t=i.unmatched.trim())}for(const e of(0,u.toA)((0,s.mapNotEmpty)((0,s.compactBlanks)(m.Settings.tagNamesSurnamePrefixes.values),(e=>(0,n.sortBy)(e,(e=>-e.length)).map((e=>new RegExp(`\\b(${g(e)}\\s+\\S+)`,"i"))))))){const i=(0,h.spliceCapture)(t,e);null!=i&&(M(i),b.push(i.captured),t=i.unmatched.trim())}null!=S&&t.length>S&&(0,s.mapNotEmpty)((0,s.compactBlanks)(t.slice(S).split(/\s+/)),(e=>{b.push(...e),t=t.slice(0,S)}));const _=(0,s.compactBlanks)(t.split(/\s+/)),T=l.length,E=b.length;if(_.length>0)if(0===T&&E>0)l.push(..._);else if(0===E&&T>0&&1===_.length)b.push(..._);else if(1===_.length)l.push(..._);else{const e="western"===m.Settings.tagNamesOrder.valueOrDefault;b.push(e?_.pop():_.shift()),l.push(..._)}return{givenNames:P([...l,...c]),modifier:r,lifespan:i,familyNames:P(b),minFamilyNameIndex:S}}function P(e){return(0,s.uniq)((0,s.compactBlanks)(e).filter((e=>null==b.exec(e))))}function M(e){let t="";for(const i of(0,s.compactBlanks)(e))t+=i.startsWith(",")?i:" "+i;return t.trim()}function _(e,t,i){return M("western"===m.Settings.tagNamesOrder.valueOrDefault?[t,e,i]:[e,t,i])}t.parseName=S,t.renderNameTag=function(e){if((0,a.blank)(e))return[];const t=m.Settings.tagNamesFormatter.valueOrDefault,i="family/given"===t;if("family/fullname"===t||i){const t=S(e);if(null==t)return[];{const e=M([t.modifier,t.lifespan]),r=M(t.givenNames);return(0,s.compactBlanks)((0,s.notEmptyOr)(t.familyNames,[m.Settings.tagNamesDefaultFamily.valueOrDefault])).map((t=>[l.TagRoots.Who,t,i?M([r,e]):_(t,r,e)]))}}return[[l.TagRoots.Who,e.trim()]]}},95141:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const r=i(21605),s=i(54993),n=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,n.isVideoMimeType)(e.MIMEType)?(0,r.normalizeRotation)(e.Rotation):void 0)??o(e.Orientation)};const a=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function o(e){return(0,r.isRotation)(e)?e:null!=e?a.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,s.toS)(e).startsWith("Mirror")},t.orientationToRotation=o;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,r.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,r.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const r=i(55835),s=i(31586),n=i(28874);function a(e){const t=(0,s.toInt)(e);return null==t?void 0:(0,s.clamp)(-1,5,t)}function o(e){return a(e?.Rating)??(0,s.mapNumeric)((0,s.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,r.map)(e?.favorited,(e=>!0===e?n.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=a,t.extractRating=o,t.extractLiked=function(e){const t=o(e);return null==t?void 0:t>=n.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(88561),o=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,r.lazy)((()=>new a.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,s.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,n.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,o.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),s=i(40958),n=i(22573),a=i(81168),o=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,a.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const o=(0,u.isJsonExt)(i.ext),l=o||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=o||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,s.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,s.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return o&&function(e,i){const r=(0,a.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function s(e){return(0,n.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const o=s(e.slice(r.length)),l=s(i.slice(r.length));return o&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,o.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,a.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(33374),o=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),h=i(34943),f=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),w=(0,r.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),v=(0,r.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:n.minuteMs})));async function b(e,t){if(null==e)return;const i=null==t||(0,s.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const r=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return S(i,r,await(0,h.rawInfo)(e));const n=S(i,r);if(null!=n)return n;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await b(await(0,f.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function S(e,t,i){t??(t=(0,y.extractRotation)(e));const r=(0,o.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,a.isDimensions)(e)?e:void 0));if(null==r)return w().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo,fileDimensions:r}});const s=(0,a.maybeDimSwap)(r,t);return w().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:s.height,ImageWidth:s.width,aspectRatio:(0,d.aspectRatio)(s),dimensions:s,rotation:t,fileDimensions:r,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return v().getOrSetAsync(i.nativePath,(()=>b(i,t)))},t.extractSizeInfoFromTags=S},3127:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tag_fts_path=t.tag_fts_root=void 0;const r=i(54993),s=i(42231);t.tag_fts_root=function(e){const t=(0,r.toS)(e).indexOf(s.TagSep);return-1===t?"":e.substring(0,t)},t.tag_fts_path=function(e){return(0,r.toS)(e).split(s.TagSep).filter((e=>null!=e&&""!==e.trim())).join(" ")}},61424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),h=i(48884),f=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),w=i(79842),v=i(21330),b=i(98725),S=i(51275),P=i(35280),M=i(19748),_=i(88561),T=i(95696),E=i(65238),D=i(17217),k=i(57902),x=i(28874),F=i(80496),C=i(65162),A=i(28544),I=i(47783),O=i(88840),L=i(30748),R=i(16170),N=(0,n.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),B=7;async function j(e){return x.Settings.siblingInference.valueOrDefault===F.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+x.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(x.Settings.siblingInference.valueOrDefault===F.TagInferenceSettingValues.auto&&await(0,E.isSlowDir)(e.nativePath)&&!await(0,E.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function z(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of r){const r=(0,L.extractMakeAndModel)(await(0,I.readRawTags)(t));if((0,f.definedAndNotEql)(r.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:r});else if((0,f.definedAndNotEql)(r.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:r});else if(null!=r.Make&&null!=r.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:k.LogLevels.info,result:r,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await j(e.parent()))return;const t=await W(e);return null!=t&&(0,v.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,v.toExifDateTime)(t.before.date,(0,S.getZoneName)(t.before.date)),(0,v.toExifDateTime)(t.after.date,(0,S.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,n.lazy)((()=>new _.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await H(e),i=await z(t?.younger),r=await z(t?.older);return null==i||null==r?void 0:{before:i,after:r,index:i.index,slots:i.index+r.index+1}}))}t.beforeAfterCapturedAt=W;const U=(0,M.extFilter)(O.ExtTypes.AssetFile);function q(e){return null==e?[]:(0,a.compact)((0,h.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function H(e,t=7,i=!0){if(!await j(e.parent()))return;const r=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(U(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==r)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const s=(0,o.sortBy)(r,(e=>(0,C.bname)(e))),n=(0,D.findFileIndex)(e,s);if(n<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),H(e,t,!1)):void 0;const l=x.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[s.slice(n-2*t,n),s.slice(n+1,n+1+2*t)],d=[],h=[];for(;(0,a.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,a.isNotEmpty)(c)&&h.length=l&&h.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:h},meta:{f:e}})}t.nearestSiblings=H,t.nearestSiblingTzOffset=async function(e){if(!await j(e.parent()))return;const t=q(await H(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,B);for(const t of e){const e=await(0,I.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==r.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,a.uniq)([(0,C.bname)(e,!0),(0,C.bname)(e,!1)]),i=(0,b.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const r=await e.stat();if(null!=r){for(const e of["birthtime","atime","mtime","ctime"])if((0,w.datedOverlap)({a:i,b:r[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:r}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:r}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,b.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const r=i[e];if(null!=r&&!0===(0,w.datedOverlap)({a:t,b:r}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:s.DateTime.fromJSDate(r)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),h=i(81168);function f(e){return(0,u.toS)((0,o.isString)(e)?e:e?.name).normalize()}function m(e){return(0,r.compact)((0,l.toA)(e).map(f))}function p(e,i=t.TagSep){return m(e).map((e=>(0,o.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(n.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function w(e){return(0,n.blank)(e)?void 0:Array.isArray(e)?f((0,r.last)(e)):(0,r.last)(g(e))}function v(e,t){if((0,r.isEmpty)(e)||(0,r.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,h.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=f,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,r.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,r.uniqBy)((0,l.toA)(e),(e=>(0,r.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,r.compact)(t).map((e=>y(e))));return(0,r.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=w,t.leafIsExcluded=function(e,t){return(0,a.mapOr)(w(e),(e=>(0,h.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=v,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,s.sortBy)(e.filter(r.isNotEmpty),(e=>-e.length)))t.some((e=>v(i,e)))||t.push(i);return(0,s.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const r=i(40958),s=i(22573),n=i(68708),a=i(54993);t.extractTitleDescription=function(e){const t=(0,r.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,s.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const r of i){const i=(0,a.toS)(e[r]).trim();if((0,s.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,n.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(96249),o=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),w=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function v(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function b(e){const t=await v(e);return(0,s.uniq)((0,a.flatten)(t.map(m.uriEncodingVariants)))}async function S(e,t){if((0,n.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void w().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case o.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case o.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case o.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,n.blank)(e)?w().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=v,t.nativePath2uriVariants=b,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(S(e,t),b))),(0,s.uniq)(i)},t.uri2nativePath=S,t.uriExists=async function(e,t){const i=await S(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),s=i(57975),n=i(90595),a=i(22573),o=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",w=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class v{static isUri(e){return e instanceof v||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,s,n=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,n),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=s??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,n))}get fsPath(){return T(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:s,fragment:n}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===s?s=this.query:null===s&&(s=g),void 0===n?n=this.fragment:null===n&&(n=g),t===this.scheme&&i===this.authority&&r===this.path&&s===this.query&&n===this.fragment?this:new S(t,i,r,s,n)}static parse(e,t=!1){const i=w.exec(e);if(!i)return new S(g,g,g,g,g);const r=i[2]||g,s=x(i[4]||g),n=(i[5]||g).split("/").map(x).join("/"),a="psfile"===r&&n.startsWith("//")?n.slice(1):n,o=(0,u.toURLSearchParams)(i[7]),l=x(i[9]||g);return new S(r,s,a,o,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new S("file",t,e,g,g)}static from(e){return new S(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?v.file(r.win32.join(T(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,o.map)(this.path,(e=>(0,d.findLast)(e.split(y),a.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return E(this,e)}toJSON(){return this}[s.inspect.custom](){return this.toString()}}t.URI=v;const b=h.isWinPortable?1:void 0;class S extends v{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=T(this,!1)),this._fsPath}toString(e=!1){return e?E(this,!0):(null==this._formatted&&(this._formatted=E(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=b),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,a.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function M(e,t){let i,r=-1;for(let s=0;s=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||45===n||46===n||95===n||126===n||t&&47===n)-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),void 0!==i&&(i+=e.charAt(s));else{void 0===i&&(i=e.substr(0,s));const t=P[n];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),i+=t):-1===r&&(r=s)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function _(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function E(e,t){const i=t?_:M;let r="";const{scheme:s,query:n,fragment:o}=e;let{authority:l,path:u}=e;if(s&&(r+=s,r+=":"),(l||"file"===s)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,a.mapNotBlank)(n,(e=>r+="?"+e)),o&&(r+="#",r+=t?o:M(o,!1)),r}function D(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+D(e.substr(3)):e}}t.encodeURIComponentFast=M,t.uriToFsPath=T;const k=/(?:%[\dA-Z][\dA-Z])+/gi;function x(e){return e.startsWith("xn--")?(0,n.toUnicode)(e):e.match(k)?e.replace(k,(e=>D(e))):e}t.percentDecode=x,t.toURI=function(e){return v.isUri(e)?e:v.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),s=i(40958),n=i(50357),a=i(89937),o=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",a.PS_LOCAL_FILE_SCHEME,a.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,o.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&f(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,n.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,s.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),s=i(22573),n=i(51926),a=i(89937),o=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,s.blank)(e))return;if(null==(t=null!=t&&(0,o.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,s.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,n.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:a.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==a.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,s.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,n=(0,s.notBlank)(t)&&!t.includes(i);if(n&&!(0,s.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const o=await(0,c.bestVolumeForVolsha)(e.authority);return null!=o?f(o.mountpoint,e.path):n&&(0,s.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),s=i(22573),n=i(51926),a=i(89937),o=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,s.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,s.blank)(t))return;const i=(0,r.uniq)([t,(0,o.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,n.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==a.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,o.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,n.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const a=n(i(76760)),o=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,o.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,o.notBlank)(t.remoteHost)&&(0,o.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:a.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,o.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,o.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(a.sep)}`;const s=i.slice(1),n=await(0,p.volumes)();for(const t of(0,u.toA)(n))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return a.join(t.mountpoint,...s);return await(0,h.isReadableDirectory)(t)?a.join(t,...s):void 0}},85087:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),s=i(42659),n=i(9103),a=i(37628);t.volsha=(0,n.memoize)((e=>(0,r.mapNotBlank)(e,a.shortStringSha)),{maxSize:128,ttlMs:s.minuteMs})},60865:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),s=i(30577);t.channel=function(){return(0,s.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),s=i(22573),n=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function a(e){if(e instanceof r.SemVer)return e.version;const t=n.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=a,t.semverSatisfies=function(e,t){if((0,s.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const n=a(e);return null!=n&&(0,r.satisfies)(n,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},8540:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),s=i(9595),n=i(29882),a=i(43334),o=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([o.Settings.libraryDir.valueOrDefault,(0,s.originalsDir)(),...o.Settings.scanPaths.values]))if((!a.isPosix||!(0,n.pathIsRoot)(t))&&(0,n.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},42233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentVolumeRoots=void 0;const r=i(45200),s=i(98770),n=i(7014);t.currentVolumeRoots=(0,s.lazyFsAsync)("currentVolumeRoots",(async function(){const e=[],t=[];for(const i of await(0,n.volumes)()){t.push(i.mountpoint);const s=(await(0,r.nativePath2uri)(i.mountpoint,i))?.toString();null!=s&&e.push(s)}return{uris:e,mountpoints:t}}))},1485:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),s=i(22573),n=i(59455),a=i(50213),o=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.DfPosix"))),w=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function v(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),s=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),n=t&&(i||r||s);return y().tap({msg:"acceptPosixVolume()",result:!n,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:s}})}t.acceptPosixVolume=v,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,n.toA)(await w());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,s.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,n.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,o.assignMissingPrimitives)(i,e))}return t.filter(v)}},69108:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,a.toInt)(e,{defaultValue:0})*o.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,s.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const s=m(e.Used)??0,n=m(e.Available)??0;if(0!==s||0!==n)return{filesystem:t,mountpoint:i,size:d.isMac?s+n:r,used:s,available:n};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:s,available:n})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,s.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,n.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const a=p(i);return!0===e&&a.forEach((e=>e.remote=!1)),a},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),w=i(24399),v=i(28874),b=i(24541),S=i(60224),P=i(63870),M=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const _=/([a-z]+)(?::\\)?/i;function T(e){return e?.match(_)?.[1]?.toUpperCase()}function E(e){return(0,l.map)(T(e),(e=>e+":\\"))}function D(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(T(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function k(e){return null!=e&&!(0,a.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,a.notBlank)(e.DisplayRoot),...(0,l.map)((0,S.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function x(e){return`Get-Volume ${(0,f.toS)(T(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=E,t.getPsDriveCommand=D,t.getVolumeCommand=x,t.getLocalVolumesWin_=function(){return w.PowerShell.instance().executeJsonToA(x())};const F=/\{([-a-z\d]{7,})\}/i;function C(e,t){return e=e?.trim(),(0,a.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function A(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void M().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=E(e.DriveLetter);if(null==t)return void M().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,s.compact)([C(e.HealthStatus,"healthy"),C(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,a.notBlank)(e.DriveLetter)&&(0,a.blank)(i);return M().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(n=e.UniqueId,M().tap({msg:"uniqueId2uuid",result:(0,l.map)(F.exec((0,f.toS)(n)),(e=>e[1])),meta:{s:n}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var n}async function I(){const e=(0,s.uniq)((0,h.toA)(await(0,b.mountpointsWin)()).map(E)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>w.PowerShell.instance().executeJsonToA(D(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:v.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,s.compact)((0,o.flatten)(t).map(k)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>w.PowerShell.instance().executeJsonToA(x(e)).catch((t=>(M().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:v.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),a=(0,s.compact)((0,o.flatten)(r).map(A)),l=(0,s.uniq)([...i,...a].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,n.sort)((0,s.uniq)([...i,...a].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));M().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:a,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...a.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=A,t.volumeInfoWin=I},68884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),w=i(83278),v=i(8103),b=i(16287),S=i(45969),P=i(43334),M=i(69108),_=i(98770),T=i(44224),E=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,S.isDocker)()||(0,d.isBillingService)()||null==await(0,v.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,E.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const D=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?D().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,T.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),b.isReadableDirectory),(e=>e.map((e=>w.BaseFile.for(e).clear().childDirectories())))))}):D().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,s.isEmpty)(e)?[]:(D().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,E.mountpointsTtlMs)(),f:async e=>{const t=await(0,M.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void D().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await k(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,E.mountpointsTtlMs)()}))),(0,o.later)((()=>(0,_.setupVolumeTTL)(t.gioVolumes)));const k=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,E.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,n.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(n.notBlank).get()}}catch(t){return void D().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs})},98770:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),s=i(5233),n=i(41400),a=i(56038),o=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,a.time)("volumes."+e,(()=>(0,s.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,o.isRetriableError)(e)&&!1!==(0,o.isIgnorableError)(e)})))),i);return(0,n.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),w=i(98770),v=i(63870),b=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>b().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>b().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const n=(0,c.sortIgnoreCase)((0,s.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),a=[];for(const t of n){const s=e.find((e=>e.mountpoint===t)),n=i?.find((e=>e.mountpoint===t)),o={...s,...n},u=r?.find((e=>e.filesystem===o.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(o,u),null==o.size||null==o.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];b().info("backfilling mountpoint",{info:n,vol:s,df:e}),null!=e&&(0,l.assignMissingPrimitives)(o,e)}a.push(o)}return a};const S=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return S.exec(e)?.[1]?.split(".").map((e=>(0,a.toInt)(e)))})),M=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,a.gte)(t[0],2)&&(0,a.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,w.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await M()],{timeoutMs:(0,v.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,n.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,a.toInt)(e.fsused),r=(0,a.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return b().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,w.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,v.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,n.toNotBlank)(e.PARTLABEL)??(0,n.toNotBlank)(e.LABEL),uuid:(0,n.toNotBlank)(e.PARTUUID)??(0,n.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),s=i(19851),n=i(40958),a=i(22573),o=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),w=(0,s.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,n.uniq)(e.map((e=>e.filesystem?.match(v)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),s=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of s)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,a.blank)(t.MountPoint)||(0,o.isTrue)(t.OSInternal)?w().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){w().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const v=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),w=i(84777),v=i(34330),b=i(8769),S=i(34102),P=i(17217),M=i(16287),_=i(43334),T=i(28874),E=i(8540),D=i(68884),k=i(44224),x=i(24541),F=i(69375),C=i(63870),A=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function O(e=(0,C.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function L(){I()}t.localMountpointSetup=(0,r.lazy)((async()=>{T.Settings.libraryDir.watchLater(I),T.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&T.Settings.scanAllDrives.valueOrDefault?(0,o.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(_.isMac&&(e.info("Setting up Mac diskutil activity watcher"),O((0,C.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),_.isLinux){const i=(0,k.maybeWatchProcMounts)();await(0,D.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),O((0,C.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),O((0,C.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),a.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=T.Settings.mountpoints.values;if((0,s.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",_.isWin?x.mountpointsWin:k.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,s.isEmpty)(e))return A().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,n.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,C.commandTimeoutMs)(),f:async e=>!(!(0,E.mightBeAssetMountpoint)(e)&&(0,F.isExcludedMountpoint)(e)||T.Settings.validateMountpoints.valueOrDefault&&!await(0,M.isReadableDirectory)(e)&&(A().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,b.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(_.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return _.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,o.later)((()=>{(0,S.ee)().on("clearCache",(()=>{D.gioVolumes.unset(),I()})),T.Settings.mountpointsTtlMs.watch(O)}),(0,c.isTest)()?1:a.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>L(),minCallDelayMs:1.5*a.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:D.GioCommand,args:D.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(D.gioVolumes.unset(),L()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const N=(0,r.lazy)((async()=>{if(!_.isLinux)return!1;try{return 0===(await(0,w.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,C.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>L(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(48884),o=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),w=i(28874),v=i(69108),b=i(68884),S=i(59107),P=i(69375),M=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await D()??await(0,c.thenMap)((0,v.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,b.isGioSupported)())try{await(0,c.thenMap)((0,b.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){M().warn("Failed to fetch gio volumes",e)}return e};const _="/proc/mounts";function T(e){return!w.Settings.excludedFilesystemTypes.has(e)}function E(e){return!(0,P.isExcludedMountpoint)(e)&&(!w.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function D(e=_,t=T,i=E){if(y.isLinux)try{const r=await(0,f.readLines_)(e),n=(0,s.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,a.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),o=await(0,c.filterAsync)({name:"mountpoints filter",arr:n,f:async([e,r])=>{const s=t(e),n=await i(r);return M().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:s&&n,meta:{fs:e,mp:r,fsOK:s,mpOK:n}})}});return M().tap({msg:"readProcMounts()",result:o.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void M().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=T,t.readProcMounts=D,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(_)?new h.FileWatcher(_,{recursive:!1,persistent:!1},(()=>{M().info("detected change in "+_),(0,d.setUnrefTimeout)((()=>S.mountpoints.refresh()),n.secondMs)})):void 0))},24541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),s=i(42659),n=i(13538),a=i(50213),o=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,n.thenOrTimeoutError)(f(),o.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*s.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(9103),o=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,n.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,s.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,o.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,o.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,o.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,o.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,s.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,a.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),s=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,n=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function a(e){if((0,r.blank)(e))return;const i=s.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(n,""),remoteShare:i.remoteShare};const a=t.nfsRe.exec(e);if(null!=a){const e=a[1],t=a[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=a(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=a},60224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(55835),o=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),w=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await T()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,a.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const v=["LocalName","RemoteName","Status"],b=["NETUSE","get",v.join(",")],S=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function M(e){if(!(0,s.blank)(e))return(0,o.opt)(e).flatMap((e=>S.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,o.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,s.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,o.opt)(e.pathname).filter(s.notBlank).getOrElse((()=>"/"))}))))).get()}async function _(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,b,{timeoutMs:15*n.secondMs}),i=(0,u.parseFixed)(v,t);return(0,r.compact)(i.map((e=>(0,a.map)(S.exec((0,l.toS)(e.RemoteName)),(t=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=M,t._netInfoWinWmic=_;const T=(0,w.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?_():(0,r.compact)(e.filter((e=>(0,s.notBlank)(e.LocalName))).map((e=>(0,a.map)(M(e.RemoteName),(({host:t,share:i})=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,h.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),s=i(12168),n=i(28874);t.mountpointsTtlMs=function(){return n.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return n.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return n.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=s.MiB/r.secondMs},86848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(38639),o=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),w=i(95696),v=i(45969),b=i(28874),S=i(59107),P=i(63870),M=i(68995),_=(0,s.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),T=(0,s.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function E(e){return(0,a.isTrue)(e.ignorable)||(0,v.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function D(e){if((0,n.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function k(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=D(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function x(e){if(b.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of b.Settings.volumeUuidFilePaths.values){const i=w.PosixFile.for(e.mountpoint).join(t),r=await k(i).catch((e=>_().info("Failed to read "+i,{error:e})));if(null!=r)return _().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,M.volumeUuidSubpath)());if("/"===e.mountpoint)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(b.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(b.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,M.writeVolumeUuid)(e);if(!(0,n.blank)(t))return _().tap({msg:"readVolumeUUID(): wrote new "+(0,M.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return _().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,o.later)((()=>{(0,m.ee)().on("clearCache",(()=>T.clear())),S.mountpoints.watchLater((()=>T.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(E(e))return;if((0,a.isFalse)(e.ok))return;const t=await T().getOrSetAsync(e.mountpoint,(async()=>x(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>_().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=E,t.toVolumeUUID=D,t.readUuidFile_=k,t.readVolumeUUID=x},7014:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),w=i(59455),v=i(48884),b=i(50213),S=i(7282),P=i(23560),M=i(28850),_=i(45255),T=i(81168),E=i(56519),D=i(4867),k=i(49776),x=i(9595),F=i(77740),C=i(44198),A=i(96706),I=i(8769),O=i(57159),L=(i(34102),i(21144)),R=i(73209),N=i(29882),B=i(95696),j=i(17217),z=i(16287),V=i(49076),W=i(96128),U=i(45969),q=i(43334),H=i(28874),G=i(85087),$=i(50424),J=i(48165),K=i(98770),Z=i(27461),Y=i(66840),X=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,a.lazy)((()=>(0,b.mkLogger)("volumes.Volumes"))),se=s.default.platform(),ne=new Map,ae=new Map,oe=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,G.volsha)(t.uuid),(e=>ae.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,ne),le((0,G.volsha)(e.uuid),e,oe),e}function ce(){return(0,o.compact)([B.PosixFile.forMaybe((0,k.cacheDir)())?.join("volumes"),B.PosixFile.forMaybe((0,x.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),ae))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),ne.clear(),oe.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,E.mapAsync)({name:"readCachedVolumes",arr:(0,E.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,o.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,T.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),s=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:r,os:se}))),n=new Map;for(const e of s)for(const t of(0,o.compactBlanks)([(0,G.volsha)(e.uuid),(0,G.volsha)(e.mountpoint)]))n.set(t,e);const a=ce();for(const e of a)await(0,R.withLock_)({file:e,timeoutMs:_.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of n.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:a,vol_mountpoints:s.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,o.isNotEmpty)(e))return e;const i=(0,w.toA)(await(0,X.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,H.Settings.volumeMetadataTtlMs.valueOrDefault),s=0!==H.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),n=!(0,o.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:s,priorIsMissingMountpoints:n}),s||n?void 0:e}async function me(e,i){const r=(0,m.map)(e,j.toNativePath_);if((0,u.blank)(r))return;const s=await(0,L.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,o.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(s,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:s,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:s}})}async function pe(e,t,i){const r=i.filter((e=>(0,T.equalsIgnoreCase)(t,e.remoteShare)));if((0,o.isEmpty)(r))return;const s=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,T.equalsIgnoreCase)(e,t.remoteHost)));if(null!=s)return s;const n=await(0,W.friendlyname)(e);return(0,E.asyncFind)(r,(async e=>(0,T.equalsIgnoreCase)(n,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,a.lazy)((()=>(0,P.isSyncService)()||(0,S.isTest)())),t.priorWriteVolumesToCacheLatch=(0,a.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,a.lazy)((async()=>{const e=(0,o.compact)(await de()),t=(0,w.toA)(await(0,X.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,o.isNotEmpty)(i)?i:e.filter((e=>se===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,D.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,D.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,o.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,O.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,M.shim0)({name:"fs.volumes",impl:async function(){if((0,S.isTest)()){const e=(0,p.toInt)((0,C.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,F.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,D.thenOrTimeoutError)({p:q.isWin?(0,J.dfWin)():(0,$.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=H.Settings.validateMountpoints.valueOrDefault?(0,o.compact)(await(0,E.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,z.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,D.thenOrTimeoutError)({p:q.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(q.isWin?t:q.isMac?await(0,Y.addLocalVolumeInfoMac)(t):await(0,Z.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await he(r),Object.freeze(r)}}),t.rootPath=(0,a.lazy)((()=>q.isWin?(0,g.opt)((0,A.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,T.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,o.isEmpty)(t)?void 0:(0,v.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,o.commonPrefixLength)(e.split(n.default.sep),t.split(n.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,w.toA)(await i.vols()).find((t=>(0,G.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,E.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return oe.get(e)??(await de())?.find((t=>(0,G.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,G.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(50213),o=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,s.lazy)((()=>(0,a.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,n.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,f());t=(0,n.toNotBlank)(t)??(0,c.safeUUID)();const s=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(s))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+o.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},51140:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpStatusIs=t.HttpStatus=void 0;const r=i(31586);t.HttpStatus=Object.freeze({OK:200,Accepted:202,MovedPermanently:301,Found:302,SeeOther:303,BadRequest:400,Unauthorized:401,Forbidden:403,NotFound:404,EnhanceYourCalm:420,InternalServerError:500,NotImplemented:501,ServiceUnavailable:503}),t.HttpStatusIs=Object.freeze({ok:e=>(0,r.within)(200,299,e),success:e=>(0,r.within)(200,299,e),redirect:e=>(0,r.within)(300,399,e),clientError:e=>(0,r.within)(400,499,e),serverError:e=>(0,r.within)(500,599,e),error:e=>(0,r.within)(400,599,e)})},21404:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToTagPath=void 0;const r=i(75020),s=i(40958),n=i(22573),a=i(89937),o=i(34238);t.uriToTagPath=function({uri:e,isFile:t}){if(null==e)return;const i=(0,o.toURI)(e),l=i.scheme===a.PS_LIBRARY_SCHEME?r.LibraryTagName:i.scheme===a.PS_LOCAL_FILE_SCHEME?i.authority:void 0;if((0,n.blank)(l))return;const u=i.path.split("/");return(0,s.compactBlanks)([r.TagRoots.fs,l,...t?u.slice(0,-1):u])}},98604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkAssetUrl=t.mkFolderUrl=t.myWebUrl=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(27776),o=i(49076),l=i(72308),u=i(28874),c=i(42231),d=i(45200),h=i(34238),f=i(21404);function m(e=u.Settings.httpPort.valueOrDefault){const t=[u.Settings.localhost.valueOrDefault];u.Settings.exposeNetworkWithoutAuth.valueOrDefault&&t.push(...(0,s.compactBlanks)([(0,l.myExternalIp4Addresses)()[0],(0,o.hostname)()]));const i=(0,h.toURI)("http://a");return t.map((t=>i.with({authority:t+":"+e})))}t.default=m,t.myWebUrl=(0,r.lazy)((()=>m()[0])),t.mkFolderUrl=async function(e){const i=await(0,d.nativePath2uri)(e),r=(0,f.uriToTagPath)({uri:i,isFile:!1});if((0,s.isEmpty)(r))return;const n=(0,a.mkTagUri)((0,c.tagPathToStringArray)(r));return(0,t.myWebUrl)()?.with(n)},t.mkAssetUrl=function(e){return(0,n.gt0)(e)?(0,t.myWebUrl)()?.with({path:"/asset/"+e}):void 0}},4988:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.httpRequest_=t.get_=t.HttpMethods=void 0;const a=n(i(37067)),o=n(i(44708)),l=i(22573),u=i(45599),c=i(50989),d=i(51926),h=i(50213),f=i(45255),m=i(22911),p=i(43205),g=i(34238),y=i(51140),w=(0,u.defer)((()=>(0,h.mkLogger)("net.get")));async function v(e,t){return b({...t,url:e})}async function b(e){const t=(0,g.toURI)(e.url),i=new m.Deferred("get "+t.toString()),r="http"===t.scheme?a.request:"https"===t.scheme?o.request:w().throw("unsupported scheme: "+t.scheme),s=e?.maxRedirects??8,n=e?.timeoutMs??f.ShortCommandTimeoutMs,u={...e?.headers,"user-agent":await(0,p.userAgent)()},c=e?.method??"GET",h=e?.agent??!1,b=r(t.toString(),{method:c,headers:u,timeout:n,agent:h},(e=>{let r="";e.setEncoding("utf8").on("data",(e=>r+=e.toString())).resume().on("end",(()=>{const a={url:(0,l.toNotBlank)(e.url)??t.toString(),contentType:e.headers["content-type"],statusCode:e.statusCode??-1,data:r};s>0&&y.HttpStatusIs.redirect(a.statusCode)&&!(0,l.blank)(e.headers.location)?(console.log("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),w().info("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),i.observe(v(e.headers.location,{timeoutMs:n,maxRedirects:s}))):(w().debug("complete",{...a,data:(0,d.ellipsize)(r,64),data_length:r.length}),i.resolve(a))}))})).on("error",(e=>i.reject(e)));return(0,l.blank)(e.body)||b.write(e.body),b.end(),i}t.HttpMethods=(0,c.strEnum)("GET","PUT","POST","PATCH","DELETE"),t.get_=v,t.httpRequest_=b},65713:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),s=i(19851),n=i(23838),a=i(81168),o=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,s.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,s.lazy)((async()=>{const e=(0,o.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,s.lazy)((()=>({trie:new n.MultiMap,small:[]}))),h=3;function f(e){const t=new n.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=s)return s}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),s=i(96249),n=i(23838),a=i(59455),o=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=n.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,a.toA)(u[t])],n=c(e.substring(1));return(0,s.flatten)(n.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,o.stripDiacritics)(e).normalize())}},30933:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const s=r(i(48161)),n=i(19851),a=i(42659),o=i(31586),l=i(50213),u=i(28874),c=(0,n.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,n.lazy)((()=>s.default.cpus()),5*a.minuteMs),t.cpuCount=(0,n.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=s.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,o.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},14854:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CpuUsage=t.isTooBusy=void 0;const d=c(i(48161)),h=i(42659),f=i(45599),m=i(55835),p=i(31586),g=i(68708),y=i(19851),w=i(50213),v=i(7282),b=i(78406),S=i(25764),P=i(38835),M=i(74128),_=i(82647),T=i(43334),E=i(28874),D=i(30933),k=i(15674),x=(0,y.lazy)((()=>(0,w.mkLogger)("work.CpuUsage"))),F=(0,y.lazy)((()=>{const e=C.instance().busyPct();(0,M.syncReport)().maybeSystemData({from:"cpuUsage",state:"note",details:"Current system load is too high to schedule more work",meta:(0,g.compactValues)({loadCpuPct:I(),cpuBusyPct:e})}),x().warn("Current system load is too high to schedule more work",{cpuBusyPct:e,max:E.Settings.cpuBusyPercent.valueOrDefault})}),((0,v.isTest)()?15:60)*h.secondMs);t.isTooBusy=function(){if(E.Settings.cpuBusyPercent.valueOrDefault<=0)return!1;const e=C.instance().busyPct(),t=(0,p.clamp)(1,150,Math.round(4*E.Settings.cpuBusyPercent.valueOrDefault/3));return(0,p.gte)(e,t)?(F(),!0):(F.unset(),!1)};class C extends b.EndableInterval{constructor(){super({name:"CpuUsage()",callback:()=>l(this,r,"m",o).call(this),intervalMs:((0,k.singleThreadedMode)()?60:T.isWin?20:10)*h.secondMs,rank:S.EndableRanks.first}),r.add(this),s.set(this,new _.Average(5)),n.set(this,new A),(0,p.mapFinite)(I(),(e=>l(this,s,"f").push(e))),l(this,r,"m",o).call(this)}get cpuCount(){return l(this,n,"f").cpuCount}idlePct(){return(0,m.map)(this.busyPct(),(e=>100-e))}busyPct(){return l(this,s,"f").sampleAvg??I()}}t.CpuUsage=C,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){(0,p.gte0)(e)&&l(this,s,"f").push(e)},o=function(){l(this,r,"m",a).call(this,I());const e=new A;l(this,r,"m",a).call(this,e.busyPct(l(this,n,"f"))),u(this,n,e,"f")},C.instance=(0,f.defer)((()=>new C));class A{constructor(e=d.default.cpus()){let t=0,i=0;for(const r of e)t+=r.times.user+r.times.nice+r.times.sys+r.times.irq,i+=r.times.idle;this.busyMs=t,this.idleMs=i,this.cpuCount=e.length}busyPct(e){const t=this.busyMs-e?.busyMs,i=this.idleMs-e?.idleMs,r=t+i;return e?.cpuCount===this.cpuCount&&(0,p.gte0)(t)&&(0,p.gte0)(i)&&(0,p.gt0)(r)?(0,p.sigFigs)(t/r*100,3):void x().warn("busyPct(): Unexpected CpuTimes. If this continues, busyPct() will be incorrect."+P.InternalErrorFlag,{self:this,prior:e,busyMs:t,idleMs:i,totalMs:r})}}function I(){return T.isWin?void 0:(0,p.sigFigs)(d.default.loadavg()[0]/(0,D.cpuInfo)().length*100,3)}},73328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyDoNotRun=t.doNotRun=void 0;const r=i(68708),s=i(99331),n=i(74128),a=i(63664),o=i(14854);t.doNotRun=function(e){return null!=u(e)};const l=["error","no-library","stop-sync"];function u(e){if(!0===e?.ended)return"endable ended";if((0,s.ending)())return"service is ending";if((0,o.isTooBusy)())return"system is too busy";const t=(0,a.getRemoteOrLocalHealthSummarySync)();if(null==t||!l.includes(t.level))return;const i=t.level+": "+t.msg.join("\n");return(0,n.syncReport)().maybeSystemData({from:"whyDoNotRun",state:"note",details:t.level,meta:(0,r.omit)(t,"links","buttons")}),i}t.whyDoNotRun=u},58444:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const s=r(i(48161)),n=i(19851),a=i(31586),o=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,n.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,n.lazy)((()=>{const e=s.default.freemem(),t=s.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,a.gt0)(r))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,o.fmtBytes)(i),freemem:(0,o.fmtBytes)(e),totalmem:(0,o.fmtBytes)(t)}})}))},69385:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOnResume=t._setPaused=t.resume=t.pause=t.isPaused=void 0;const r=i(34102),s=i(37692);let n=!1;function a(){return n}function o(e=!0){l(e),(0,s.writeStateFile)({paused:e})}function l(e){e!==n&&(n=e,(0,r.ee)().emit(e?"pause":"resume"))}t.isPaused=a,t.pause=o,t.resume=function(){return o(!1)},t._setPaused=l;const u=Promise.resolve();t.resolveOnResume=function(){return a()?new Promise((e=>{(0,r.ee)().once("resume",e)})):u}},15674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),s=i(42659),n=i(41400),a=i(31586),o=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,n.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const w=(0,r.lazy)((()=>{const e=(0,a.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*o.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/o.MB),worstCaseMemPerProcMb:Math.ceil(e/o.MB)}})}),s.minuteMs);function v(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,a.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function b(){return((0,a.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=v,t.targetCpuLoadPct=b,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(b()*(0,f.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(b()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=v();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const s=Math.min(e,w());return t=(0,a.clamp)(1,s,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:b(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:w()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,a.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,a.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,a.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},37692:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addStateEvent=t.writeStateFile=t.readStateFile=t.stateEvents=t.StateEvents=t.StateEventFns=void 0;const s=r(i(78474)),n=i(40958),a=i(76790),o=i(42659),l=i(45599),u=i(41400),c=i(68708),d=i(50989),h=i(87290),f=i(73787),m=i(19851),p=i(50213),g=i(28874),y=i(69385),w=(0,l.defer)((()=>(0,p.mkLogger)("work.SharedState")));let v;t.StateEventFns={checkTasks(){},reloadLicenses(){}},t.StateEvents=(0,d.strEnum)(...(0,c.keys)(t.StateEventFns)),t.stateEvents=new s.default;let b=0;function S(){const e=(0,h.libraryDataDirPosixFile)()?.join("state.json"),t=Date.now(),i=t-b>o.minuteMs;i&&(b=t);const r=e?.existsSync({refresh:i})??!1;return r&&null!=e&&e.eql(v?.nativePath)||(v?.close(),v=void 0),r&&null!=e&&(v??(v=new f.FileWatcher(e.nativePath,{encoding:"utf8",persistent:!1,recursive:!1},P))),e}(0,u.later)((()=>{g.Settings.libraryDir.watchLater(P)}));const P=(0,m.lazy)((()=>t.readStateFile.refresh()),25);t.readStateFile=(0,m.lazy)((()=>{const e=S()?.readJsonSync();for(const i of e?.events??[])M.get(i.e)!==i.ts&&(w().info("emitting event "+i.e),t.stateEvents.emit(i.e),M.set(i.e,i.ts));return(0,y._setPaused)(e?.paused??!1),e}));const M=new Map;function _(e){const i=S();if(null==i)w().error("overwrite(): failed: no library directory");else{const r=i?.readJsonSync(),s=function(e){const t=Date.now()-10*o.minuteMs;return(0,n.uniqByLast)((0,a.sortBy)((e??[]).filter((e=>e.ts>t)),(e=>e.ts)),(e=>e.e))}([...r?.events??[],...e.events??[]]),l={paused:e.paused??r?.paused??g.Settings.startPaused.valueOrDefault,events:s};(0,y._setPaused)(l.paused),t.readStateFile.set(l),i.writeJsonSync(l)}}t.writeStateFile=_,t.addStateEvent=function(e){const t=Date.now();M.set(e,t),_({events:[{e,ts:t}]})}},22751:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),s=i(87997),n=i(19851),a=i(42659),o=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,n.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,n.lazy)((()=>new r.Rate(5*a.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,n.lazy)((()=>(0,s.setInterval)(g,a.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,o.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},83600:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.RequestTask=void 0;const a=i(58587),o=i(80875),l=i(19851),u=i(50213),c=i(34102),d=i(84542),h=i(87445),f=i(40958),m=i(26905),p=i(98553),g=i(31586),y=(0,l.lazy)((()=>(0,u.mkLogger)("worker.RequestTask")));class w extends a.Task{constructor(e){super((0,p.stringify)(e),(e=>n(this,r,"m",s).call(this,e))),r.add(this),this.request=e}}t.RequestTask=w,r=new WeakSet,s=function(e){for(const t of(0,f.compactBlanks)((0,d.splitLines)(e))){const e=(0,o.parseJSON)(t);if(null==e)y().warn("ignoring non-json line from worker",{line:t});else{if(null!=e.error)throw y().warn("worker threw error",{response:e}),(0,m.errorFromJson)(e.error);if((0,g.isNumber)(e.id))return e.id!==this.request.id?y().throw(`bad request: #parse given mismatching requests (${e.id} != ${this.request.id})`,{response:e,request:this.request}):e.response;(0,h.isProgressEvt)(e)?(0,c.ee)().emit("progress",e):y().warn("ignoring json line from worker",{response:e})}}return y().throw("bad request: #parse missing valid response")}},93493:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearShims=t.setupShimDelegates=void 0;const r=i(19851),s=i(5233),n=i(68708),a=i(13538),o=i(57206),l=i(50213),u=i(23560),c=i(70025),d=i(28874),h=i(15674),f=i(22751),m=i(83600),p=i(58800),g=i(24817),y=(0,r.lazy)((()=>(0,l.mkLogger)("worker.ShimDelegation")));let w=0;async function v(e,t){const i=d.Settings.taskTimeoutMs.valueOrDefault;return(0,s.retryOnReject_)((async()=>{y().throwIfAborted_();const r={id:w++,fn:e,args:t},s=new m.RequestTask(r),n=await(0,p.workerCluster)(),o=n?.t,l=null==n||null==o?g.WorkerFunctions[e](...t):n.awaitOrAbort(o.enqueueTask(s));return(0,a.thenOrOnTimeout)(l,i/3,(()=>{y().warn("soft timeout servicing work request",{request:r,timeoutMs:i}),(0,f.onTimeout)()})),(0,a.thenOrTimeoutError)(l,i)}),{maxRetries:d.Settings.maxRetries.valueOrDefault,timeoutMs:i,retryDelay:d.Settings.minDelayBetweenRetriesMs.valueOrDefault,errorIsRetriable:e=>!1!==(0,c.isRetriableError)(e)})}function b(){for(const e of(0,n.values)(g.WorkerFunctions))(0,n.maybeCall)(e,"clearShim")}t.setupShimDelegates=async function(){if((0,o.addDefaultJsonRevivers)(),(0,u.isWorkerService)())b(),y().warn("setupShimDelegates(): in worker service, skipping");else if((0,h.singleThreadedMode)())y().warn("setupShimDelegates(): single-threaded mode, clearing shims"),b(),await(0,p.endWorkerCluster)();else for(const[e,t]of(0,n.entries)(g.WorkerFunctions))t.setShim((t=>v(e,t)))},t.clearShims=b},24817:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleWorkRequest_=t.isWorkRequest=t.mkWorkRequest=t.WorkRequestMethods=t.WorkerFunctions=t.AllWorkerFunctionCandidates=void 0;const r=i(98553),s=i(31586),n=i(68708),a=i(50989),o=i(32639),l=i(13991),u=i(50597),c=i(48368),d=i(52121),h=i(48604),f=i(181),m=i(66106),p=i(47783),g=i(83966);t.AllWorkerFunctionCandidates={_extractVideoFrame_:m._extractVideoFrame_,_readRawTags:p._readRawTags,_readTags:p._readTags,assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkerFunctions={assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkRequestMethods=(0,a.strEnum)(...(0,n.keys)(t.WorkerFunctions));let y=0;t.mkWorkRequest=function(e,t){return{id:++y,fn:e,args:t}},t.isWorkRequest=function(e){return"object"==typeof e&&t.WorkRequestMethods.has(e?.method)&&(0,s.isNumber)(e.id)},t.handleWorkRequest_=async function(e){const i=t.WorkerFunctions[e?.fn];if((0,o.isFunction)(i))return i(e?.args);throw new Error("invalid method "+(0,r.stringify)(e))}},58800:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.workerCluster=t.endWorkerCluster=t.workerClusterPriorEnd=void 0;const r=i(58587),s=i(36557),n=i(19851),a=i(50213),o=i(71567),l=i(25764),u=i(84777),c=i(86335),d=i(38835),h=i(84542),f=i(87445),m=i(41944),p=i(15674),g=i(42659),y=i(98553),w=i(31586),v=i(67478),b=i(54993),S=i(27395),P=i(5916),M=i(55534),_=i(29325),T=i(28874),E=i(30933),D=i(41657),k=(0,n.lazy)((()=>(0,a.mkLogger)("worker.cluster")));t.workerClusterPriorEnd=async function(){return(await t.workerCluster.prior())?.t.closeChildProcesses()},t.endWorkerCluster=function(){return(0,S.end)(t.workerCluster.prior())},t.workerCluster=(0,P.lazyAsync)({later:async()=>{const e=await(0,c.pathToService)("worker");if(null==e)return k().throw("Could not find worker.js"+d.FatalErrorFlag);k().info("worker.js found at "+e);const t={id:-1,fn:"ping",args:{}},i=new r.BatchCluster({processFactory:async()=>(k().info("Spawning new worker",{execPath:process.execPath,worker:e.nativePath,maxProcs:(0,p.maxCpus)()}),(0,u.spawn)(process.execPath,[e.nativePath],0,{env:await(0,D.workerEnv)()})),...(0,s.batchClusterOptions)((0,p.maxCpus)(),"worker.BatchCluster"),streamFlushMillis:0,versionCommand:(0,y.stringify)(t),healthCheckCommand:(0,y.stringify)(t),taskTimeoutMillis:T.Settings.taskTimeoutMs.valueOrDefault,maxProcAgeMillis:4*T.Settings.taskTimeoutMs.valueOrDefault,minDelayBetweenSpawnMillis:(0,_.isPacked)()?g.secondMs:1,pass:o.ReadyStr,fail:d.FatalErrorRe,exitCommand:M.ServiceExitCommand});return i.on("taskData",(e=>{for(const t of(0,h.splitLines)((0,b.toS)(e))){const e=(0,v.parseJSON)(t);(0,f.isProgressEvt)(e)&&(0,m.emitProgressEvt)(e)}})),p.maxCpus.watchLater((e=>{const t=(0,w.clamp)(1,(0,E.cpuCount)(),e??(0,p.maxCpus)());return k().warn("maxConcurrentImports changed",{maxProcs:t,newValue:e}),i.setMaxProcs(t)})),new s.BatchClusterObserver("worker",i,l.EndableRanks.first)}})},41657:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.workerEnv=void 0;const r=i(9727),s=i(28874),n=i(59107);t.workerEnv=async function(){const e={};return s.Settings.libraryDir.addToEnv(e),s.Settings.mountpoints.addToEnv(e,await(0,n.mountpoints)()),(0,r.childEnv)({overrides:e,forWorker:!0})}},83966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ping=void 0;const s=r(i(1708)),n=i(41400),a=i(31586),o=i(7282),l=i(12089),u=i(45608),c=i(57159),d=i(89035);t.ping=(0,l.shim1)({name:"worker.ping",async impl(e){if((0,a.gt0)(e?.delay)&&await(0,n.delay)(e.delay),(0,o.isTest)()&&!0===e?.pretendMemUsageIsHigh&&d.memoryUsageIsHigh.set(!0),null!=e?.throw)throw new c.WrappedError(e.throw.message,e.throw);if((0,d.memoryUsageIsHigh)())throw(0,u.exit)({reason:"memory usage is high",status:1}),new c.WrappedError("Memory usage is high",{fatal:!0});return{pid:s.default.pid,input:e?.input??"(no input)"}}})},40958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),s=i(22573),n=i(50357),a=i(98553),o=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function w(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function b(e){return null==e?[]:w((0,h.toA)(e),(e=>null!=e))}function S(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,o.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const s=[];if(et;n-=i)s.push(r(n));return s}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=w,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),s=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===s[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,n.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const s of t){const t=i(s);r.includes(t)||(e.push(s),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return w(e,(e=>t.every((t=>!(0,n.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return w(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=b,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(s.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=b(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return S(t,(e=>(0,l.isPrimitive)(e)?e:(0,a.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,n.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=b(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=S,t.uniqByLast=function(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of b(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,a.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const s=new Set(i.map(r));return e.filter((e=>!s.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),s=i(36783),n=i(41801),a=i(98553),o=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,s.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const r of e)(0,o.getOrSet)(i,(0,a.stringify)(t(r)),(()=>r));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,s.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,n.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},75761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetImgAttrs=t.assetSqImgAttrs=t.assetVideoLink=t.assetImgActualLink=t.assetImgLink=t.assetLinkAttrs=t.assetUrl=void 0;const r=i(58939),s=i(40958),n=i(22573),a=i(42659),o=i(11371),l=i(73722),u=i(31586),c=i(54993),d=i(29652),h=i(22403),f=i(2322);function m(e,t){return e+" "+t+"w"}function p(e,t){let i=null==t?void 0:(0,d.mergeURLSearchParams)(...t);const r=(0,c.toS)(e.v);return(0,n.blank)(r)||"1"===r||(i??(i=new URLSearchParams)).append("v",r),i}function g({assetId:e,params:t}){return null==e?"":(0,d.assembleFullPath)("/asset/"+(0,r.id2id)(e),p(e,t))}function y({assetId:e,reducer:t,width:i,params:s}){return(0,d.assembleFullPath)(`/img/${(0,r.id2id)(e)}/${t}/${(0,u.toGt0)(i)??320}`,p(e,s))}function w({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/img/${(0,s.compact)([(0,r.id2id)(e),t]).join("/")}/actual`,p(e,i))}function v({assetId:e,params:t,reducer:i,widths:s,lazyLoad:n,af:l}){if(null==(0,r.id2id)(e))return{src:"/images/clear-64.png"};0===(s=(s??[]).filter(u.gt0)).length&&s.push(320);const d=Math.min(...s),p={width:(0,c.toS)(d)},g=(0,a.fmtLocalToShort)(e.capturedAtLocal);null!=g&&(p.title=g);const v=y({assetId:e,params:t,reducer:i,width:d});n??(n=!0);const b=n&&(0,f.isSafari)((0,h.ua)());b?(p.src="/images/clear-64.png",p["data-src"]=v):p.src=v,(0,f.isSafari)((0,h.ua)())||(p.loading=n?"lazy":"eager"),i===o.ReducerNames.sq&&(p.height=(0,c.toS)(d));const S=s.map((r=>m(y({assetId:e,params:t,reducer:i,width:r}),r)));return null!=l&&S.push(m(w({assetId:e,params:t,assetFileId:l.assetFileId}),l.width)),p[(b?"data-":"")+"srcSet"]=S.join(","),p}t.assetUrl=g,t.assetLinkAttrs=function({assetId:e,params:t}){const i=g({assetId:e,params:t});return(0,n.blank)(i)?{}:{href:i}},t.assetImgLink=y,t.assetImgActualLink=w,t.assetVideoLink=function({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/video/${(0,r.id2id)(e)}-${t}`,p(e,i))},t.assetSqImgAttrs=function({assetId:e,params:t,lazyLoad:i,size:r="m"}){return{...v({assetId:e,params:t,reducer:"sq",widths:l.SqWidths,lazyLoad:i}),sizes:("s"===r?80:"m"===r?160:320)*(0,u.numericOr)(globalThis?.window?.devicePixelRatio,1)+"px"}},t.assetImgAttrs=v},5233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),s=i(31586),n=i(13538),a=i(41583);t.retryOnReject_=async function(e,t){const i=(0,s.gt0)(t.timeoutMs)?()=>(0,n.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const o=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,a.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await o(l),u()}};return u()}},17586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55938),o=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,a.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,a.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,s.blank)(e)?"":"```"+(0,o.toS)(e)+"```"},t.b=function(e){return"**"+(0,o.toS)(e)+"**"},t.li=function(...e){return(0,r.compactBlankish)((0,n.flatten)(e)).map((e=>"- "+(0,o.toS)(e))).join("\n")}},22573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),s=i(42279),n=i(54993);function a(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function o(e){return!a(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,n.toS)(e);return o(i)?t(i):void 0}t.blank=a,t.notBlank=o,t.notBlankToS=function(e){return o(e)&&"undefined"!==e?(0,n.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,n.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,s.tot)(t);const i=(0,n.toS)(e).trim();return i.length>0?i:(0,s.tot)(t)},t.notBlankAnd=function(e,t){return!a(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,n.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{"use strict";function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),s=i(22573),n=i(30301),a=i(55835),o=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,a.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,o.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const s=Math.floor(e/t.minuteMs);e-=s*t.minuteMs;const n=Math.floor(e/t.secondMs),a=Math.floor(e-n*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(s)+":"+(0,l.pad2)(n)+(i.includeMs?"."+(0,l.pad3)(a):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function w(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),s=i(),n=i(),a=i(),o=i(),l=i();return new Date(t,l-1,o,a,n,s,r)}function v(){return(new Date).setHours(24,0,0,0)}function b(e,i="ago"){return e<1e3?"just now":(i=(0,s.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const n=Math.floor(e/r.ms);e-=n*r.ms,n>0&&(r.ms>=t.dayMs?i:s).push(n+r.s)}return e>0&&s.push((0,o.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(s)?"":"T"+s.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=w,t.fmtLocalToShort=function(e){return(0,a.map)(w(e),m)},t.nextMidnightTs=v,t.msUntilMidnight=function(){return v()-Date.now()},t.fmtAgo=function(e,t="ago"){return b(Date.now()-e,t)},t.fmtElapsedMs=b},95892:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),s=i(73872);function n(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function a(e,t,i,r){if(null==i||y(e)||y(t))return;let s=i.get(e);null!=s?s.set(t,r):(s=new WeakMap,s.set(t,r),i.set(e,s))}function o(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const s=l(e,t);return null!==s?s:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=n(e,t,u);if(null!==f)return f;const m=n(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return a(e,t,u,i),i;const s=l(e,t);if(null!==s)return s}const y=s(e);if(y!==s(t))return a(e,t,u,!1),!1;a(e,t,u,!0);const w=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return o(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],s=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){s.push([e,t])})),c(r.sort(),s.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return a(e,t,u,w),w}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let s=-1;for(;++s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const s=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return s.prior=()=>t,s.hasPrior=()=>r,s}},41400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),s=i(35556),n=i(31586),a=i(68708);function o(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const n=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&s.isNode&&n.unref?.()}}))}t.delayUntil=function(e){const t=((0,n.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return o(t).then((()=>t))},t.delay=o,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),n=s.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return s.isBrowser||t<=r.secondMs?n:(0,a.maybeCall)(n,"unref")??n}},33374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const r=i(31586),s=i(21605),n=i(12168);function a(e){return{width:e.height,height:e.width}}function o(e){return((0,r.toGt0)(e?.width)??0)*((0,r.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,r.gt0)(e.width)&&(0,r.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,r.gt0)(e)&&(0,r.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,n.pixels2size)(e.width*e.height)},t.dimSwap=a,t.maybeDimSwap=function(e,t){return(0,s.swappableRotation)(t)?a(e):e},t.maybeFlipInPlace=function(e,t){(0,s.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,n.megapixels)(o(e))},t.pixels=o},50357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),s=i(68708),n=i(34666),a=i(32639);function o(e,t){return(0,r.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,a.isFunction)(e)&&(0,a.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=o,t.eqlSubset=function(e,t){if(null==e||null==t||(0,n.isPrimitive)(e)||(0,n.isPrimitive)(t))return e===t;if(!(0,s.isObject)(e)||!(0,s.isObject)(t))return!1;for(const i of(0,s.keys)(e))if(!o(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(31586),o=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,s.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,a.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,n.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,s.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,s.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,s.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(s.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,o.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,o.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,o.assignFields)(new Error,(0,o.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},4188:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),s=i(42659),n=i(55835),a=i(31586),o=i(12168),l=[{ms:s.yearMs,s:"year",p:"years"},{ms:s.yearMs/12,s:"month",p:"months"},{ms:s.weekMs,s:"week",p:"weeks"},{ms:s.dayMs,s:"day",p:"days"},{ms:s.hourMs,s:"hour",p:"hours"},{ms:s.minuteMs,s:"minute",p:"minutes"},{ms:s.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,s){if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,n.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,o.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,n.mapOr)(s,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function s(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=s,t.orList=function(e){return s(e,"or")},t.andList=function(e){return s(e,"and")}},50268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const r=i(22573),s=i(38639),n=i(68708),a=i(62220),o=i(50989);t.HealthCheckSections=(0,o.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,o.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,n.isObject)(e)&&!(0,r.blank)(e.id)&&!(0,r.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,r.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,n.isObject)(e)&&a.RunStates.has(e.state)&&(0,s.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},11371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReducerNames=void 0;const r=i(50989);t.ReducerNames=(0,r.strEnum)("fit","sq")},73722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const s=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,s){if((0,isFunction_1.isFunction)(r))return;let n,a,o,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(n=0;nnew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),s=i(50357),n=i(31586),a=i(65812);t.lazy=function(e,t){let i,o;const l=[];function u(){return u.isStale()&&u.setResult(e()),o}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const n=await e,o=await i;if(!(0,s.eql)(n,o))for(const e of l)e(o);null!=t&&t>0&&void 0!==o&&(0,a.setUnrefTimeout)((()=>u.vacuum()),t)}(o,e),o=e},u.isStale=function(){return null==i||(0,n.gt0)(t)&&i+t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),s=i(54993);function n(e,t){return null==e?void 0:t(e)}function a(e,t,i){return null==e||null==t?void 0:i(e,t)}function o(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=n,t.mapTry=function(e,t){try{return n(e(),t)}catch{return}},t.map2=a,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=o,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return o(a(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,s.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class s extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=s},23838:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),s=i(76790),n=i(50357),a=i(98553),o=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,o.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,o.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,n.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),s=null==i?[]:e(t,i);(0,r.isEmpty)(s)?this.store.delete(t):this.store.set(t,s)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,s]of this.store.entries()){const n=(0,r.findIndexes)(s,(t=>!e(i,t,s)));if(n.length>0){t=!0;for(const e of n.reverse())s.splice(e,1)}0===s.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,a.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,s.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),s=i(22573),n=i(42279),a=i(54993);function o(e){return"number"==typeof e&&isFinite(e)}t.isNumber=o,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,a.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return o(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,a.toS)(e).match(u)&&null!=w(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>o(t)&&o(i)&&e(t,i);function f(e,i,s){return!(null==s||!o(s))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,s)&&(0,t.gte)(i,s))}function m(e){if(!o(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,s.blank)(e))return t.defaultValue;if(o(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function w(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function v(e){return o(e)&&e>0}function b(e){return o(e)&&e>=0}function S(e,t){return o(e)?t(e):void 0}function P(e){return o(e)?e<0?-Math.round(-e):Math.round(e):0}function M(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function _(e,t,i){if(e>t||!o(e)||!o(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return o(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return o(e)?e:t},t.diff=function(e,t){return o(e)&&o(t)?e-t:void 0},t.absdiff=function(e,t){return o(e)&&o(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!o(e)||!o(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return f(t-r,t+r,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)o(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=w(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return o(e)&&e<0},t.gt0=v,t.firstGt0=function(...e){for(const t of e){if(v(t))return t;const e=y(t);if(v(e))return e}},t.gtOrElse=function(e,t){return o(e)&&o(t)&&e>t?e:void 0},t.lte0=function(e){return o(e)&&e<=0},t.gte0=b,t.toGte0=function(e){return b(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=w(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return v(t)?String(t):void 0},t.mapNumeric=S,t.map2Numeric=function(e,t,i){return S(e,(e=>S(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return o(e)?t(e):i},t.numericOr=function(e,t){return o(e)?e:(0,n.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return S(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d+\.\d+)0+$/,"")},t.toPrecision=M,t.toPrecisionMaybe=function(e,t){return d(e,(e=>M(e,t)))},t.sigFigs=function(e,t){if(!o(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=_,t.times=function(e,t){if(!v(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return _(0,100,v(t)?P(100*(v(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!o(i))return;t+=i}return t}},68708:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(32639),o=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function w(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function v(e,t,i={}){return y((0,r.compact)((0,s.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function b(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const s={};for(const e of(0,r.uniq)((0,r.flatMap)(i,h)))s[e]=b(...i.map((t=>t[e])));return s}function S(e,t){if(!d(e)||(0,n.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=w(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,s]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==s&&!0!==i?.assignNullish||(e[r]=s));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=w,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,o.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,n.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=v,t.mergeObjectsDeep=b,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,n.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=o.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function s(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:b(i,t)}for(const r of i){const[i,a]=(0,c.splitFirst)(r,"."),o=S(t,i);null!=o?.value&&s(o.key,(0,n.blank)(a)?o.value:e(o.value,a))}for(const r of h(t))((0,l.toInt)(r)??-1)>=0&&s(r,e(t[r],...i));return r},t.pluck=S,t.pluckDeep=function e(t,i){if(null==t||(0,n.blank)(i))return;if(Array.isArray(t)){const s=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(s)?void 0:{key:s[0].key,value:(0,r.flatMap)(s,(e=>e.value))}}const[s,a]=(0,c.splitFirst)(i,"."),o=S(t,s);if(null==o)return;if((0,n.blank)(a))return o;const l=e(o.value,a);return null==l?void 0:{key:o.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,n.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,a.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,n.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=v(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>n(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return s(t)?t:n(t)}filter(e){return n(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return n(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return n(e).flatMap((e=>n(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return n(e).flatMap((e=>n(t).flatMap((t=>n(i).flatMap((i=>r(this.a,e,t,i)))))))}}function s(e){return e instanceof r||e===t.None}function n(e){return s(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=s,t.opt=n},97238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSeed=t.prngSeed=t.SeedCount=t.PrimeBins=t.PrimesPerBin=void 0;const r=i(31586),s=i(30976),n=i(54993);t.PrimesPerBin=4,t.PrimeBins=8,t.SeedCount=t.PrimesPerBin**t.PrimeBins,t.prngSeed=function(){return(0,s.randomInt)(0,t.SeedCount)},t.toSeed=function(e){const i=(0,r.toInt)((0,n.toS)(e));return(0,r.within)(0,t.SeedCount,i)?i:void 0}},39926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),s=i(54993),n={};function a(e,t){if(t<1)return"";if(!(0,r.gte)(n[e]?.length,t)){let i=n[e]??e;for(;i.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var r=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return r.parseJSON}})},46891:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),s=new Map([["child","children"],["photo","photos"],["video","videos"]]),n=/([sxz]|ss|sh|ch)$/,a=/[^aeiou]y$/,o=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=s.get(e);return null!=t?t:null!=e.match(n)?e+"es":null!=e.match(a)?e.replace(/y$/i,"ies"):null!=e.match(o)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),s=i(54993),n=["number","string","boolean"];function a(e){return-1!==n.indexOf(typeof e)}t.isPrimitive=a,t.mapPrimitive=function(e,t){return a(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return a(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(a)};const o=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,n=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==n&&"symbol"!==n)){const r=(0,s.toS)(e),n=(0,s.toS)(i),a=r.localeCompare(n);return r[0]===t.CmpReverseFlag&&n[0]===t.CmpReverseFlag?-a:a}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==n?o.indexOf(r)-o.indexOf(n):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function s(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const s of(0,r.toA)(await e))if(null!=s){const e=await s;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=s,t.isPromise=function(e){return s(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),s=i(31586);function n(e,t){return Math.floor(Math.random()*(t-e))+e}function a(e,t,i){return null==i||0===i.length?n(e,t):o(e,t,1,i)[0]}function o(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const s=t-e,a=new Set(r??[]);if(t===e&&0===s&&0===a.size&&1===i)return[e];const o=s-a.size;if(i>o)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:s,size:i,slotsRemaining:o})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of o(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,s.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let r=e;t.global||(t=new RegExp(t,"g"));let s=null;for(;null!=(s=t.exec(e));)s.index===t.lastIndex&&t.lastIndex++,r=r.slice(0,s.index)+i(s)+r.slice(s.index+s[0].length);return r}},21605:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const r=i(31586);function s(e){if(!(0,r.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,r.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=s,t.swappableRotation=function(e){const t=s(e);return 90===t||270===t}},62220:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const r=i(50989);t.RunStates=(0,r.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),s=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),n={};for(const e of t)n[e]=e;const a=e=>null!=e?i[e]:void 0,o=e=>null!=a(e);return{...n,values:t,length:t.length,has:o,includes:o,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:a,ordinal:e=>a(e)??t.length,validOrElse:(e,t)=>o(e)?e:(0,s.tot)(t),mapValid:(e,t)=>o(e)?t(e):void 0,cmp:(e,t)=>{const i=a(e),r=a(t);return null==i||null==r?void 0:i>r?1:i{const i=a(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),s=i(17586),n=i(22573),a=i(96249),o=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=f();return null!=r?(0,o.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function b(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function S(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),s=(0,c.toS)(t);return r.length===s.length&&(r===s||r.toLowerCase()===s.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?s.normalize():s,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,n.blank)(t)?void 0:e.find((e=>S(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,s.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,o.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=w,t.ensureSuffix=v,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return v(w(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=b,t.wrap=function e(t,i){const r=i?.maxLineLen??80,s=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,a.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,a.flatten)(r.map((t=>e(t,i))))}if((t=w((0,c.toS)(t),s).trim()).length<=r)return[t];const n=b(t," ",r);if(n>s.length)return[m(t,0,n),...e(m(t,n+1),i)];{const r=t.indexOf(" ",s.length+1);return r>0&&r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),s=i(68708),n=i(42279),a=i(83104),o=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let s=!0;const n=setTimeout((()=>{s&&(s=!1,i(a.Timeout))}),t);try{n.unref?.();const t=await e;s&&(s=!1,i(t))}catch(e){s&&(s=!1,r(e))}finally{clearTimeout(n)}}))}async function u(e,t,i=!0){const s=await l(e,t,i);if(s===a.Timeout)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return s}t.toNotTimeout=function(e){return e===a.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?a.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,n)=>{let a=!0;try{const o=setTimeout((async()=>{if(a){a=!1;try{r(await i())}catch(e){n(e)}}}),t);(0,s.maybeCall)(o,"unref");const l=await e;a&&(a=!1,clearTimeout(o),r(l))}catch(e){a&&(a=!1,n(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const s=t-Date.now();if(s<=0)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(s)+")");return u(e,s,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const s=await l(e,t,r);return s===a.Timeout?(0,n.tot)(i):s}},42279:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),s=i(22573),n=i(54993);function a(e){return"URLSearchParams"===e?.constructor?.name}function o(e){return null==e?void 0:a(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(o)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=a,t.toURLSearchParams=o,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,n.toS)(l(...t));return e+((0,s.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,n.toS)(l(...t));return(0,s.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),s=i(30301),n=i(31586),a=i(46891),o=i(50989),l=i(51926),u=(0,s.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,n.isNumber)(r)&&(i+=r/t.MB);return(0,n.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,n.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,n.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),s=Math.pow(10,3*r),a=d[r];return(0,n.sigFigs)(e/s,t)+" "+a}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),s=Math.pow(2,10*r),a=h[r];return(0,n.sigFigs)(e/s,t)+" "+a},t.MP=1e6,t.megapixels=function(e){return(0,n.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,o.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,a.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,a.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},22403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ua=void 0;const r=i(30301),s=i(54993);t.ua=(0,r.lazy)((()=>(0,s.toS)(globalThis?.navigator?.userAgent)))},2322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,r=/\bSafari\b/,s=/\bFirefox\b/,n=/\biPad\b/,a=/\biPhone\b/;function o(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return o(e,i)}function u(e){return o(e,s)}t.isChrome=l,t.isSafari=function(e){return o(e,r)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return o(e,n)},t.isIphone=function(e){return o(e,a)}},58939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.idEql=t.id2id=void 0;const r=i(55835),s=i(31586);function n(e){const t=e;return(0,s.isNumber)(e)?e:(0,s.isNumber)(t.id)?t.id:(0,s.isNumber)(t.assetId)?t.assetId:(0,s.isNumber)(t.tagId)?t.tagId:void 0}t.id2id=n,t.idEql=function(e,t){return(0,r.map2Or)(n(e),n(t),((e,t)=>e===t),(()=>!1))}},12236:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressWithAssetsProps=t.noRecentAssetIdsProgress=t.isRebuildProgress=t.EmptyRemovedURI=t.EmptyDeletedURI=t.RebuildingURI=t.SyncStatuses=void 0;const r=i(50989);t.SyncStatuses=(0,r.strEnum)("processing","paused","done"),t.RebuildingURI="rebuilding://",t.EmptyDeletedURI="emptydeleted://",t.EmptyRemovedURI="emptyremoved://",t.isRebuildProgress=function(e){return t.RebuildingURI===e?.uri},t.noRecentAssetIdsProgress=function(e){return[t.EmptyDeletedURI,t.EmptyRemovedURI].includes(e?.uri)},t.ProgressWithAssetsProps=["uri","volume","state","hed","dek","completePct","incompletePct","scanningPct","recentAssetIds"]},79114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.S=void 0;const r=i(50989);t.S=(0,r.strEnum)("plus","lite")},75020:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInfoTag=t.NotInfoPanelTags=t.LibraryTagName=t.TagRoots=t.isTagRef=t.ctxToS=t.TagGalleryProps=t.nextChildTagsUrl=t.nextAssetsUrl=t.BeforeAfterStreamLimit=t.ThumbsPerSample=void 0;const r=i(76790),s=i(22573),n=i(98553),a=i(31586),o=i(50989),l=i(51926),u=i(29652);t.ThumbsPerSample=128,t.BeforeAfterStreamLimit=8,t.nextAssetsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/assets`,i)},t.nextChildTagsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.seed,(e=>i.seed=e.toString())),(0,a.mapNumeric)(t.limit,(e=>i.limit=e.toString())),(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/child-tags`,i)},t.TagGalleryProps=["tagId","tagPath","assetCount","assetIds","nextAssets","childTags","nextChildTags"],t.ctxToS=function(e){return(0,n.stringify)({seed:e.seed,tagIds:(0,r.sort)([...e.tagIds])})},t.isTagRef=function(e){return null!=e&&!(0,l.isString)(e)&&(0,s.notBlank)(e.name)},t.TagRoots=(0,o.strEnum)("When","Who","Where","What","Camera","Lens","Albums","Keywords","Type","fs"),t.LibraryTagName="Library",t.NotInfoPanelTags=[t.TagRoots.When,t.TagRoots.Camera,t.TagRoots.Lens,t.TagRoots.Type,t.TagRoots.fs],t.isInfoTag=function(e){if(null==e)return!1;const i=(0,l.isString)(e)?e:e.tagPath?.[0];return!t.NotInfoPanelTags.includes(i)}},27776:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkTagUri=t.mkTagFullPath=t.mkHomeFullPath=t.urlSeed=void 0;const r=i(40958),s=i(30301),n=i(31586),a=i(97238),o=i(29652);function l(e,i){const r=(0,o.toURLSearchParams)(e);if(i||!(0,n.isDigits)(r?.get("seed"))){const e=(0,t.urlSeed)().toString();return r?.set("seed",e),r??{seed:e}}return r}function u(e,t,i=!1){const r=c(e,t,i);return(0,o.assembleFullPath)(r.path,r.query)}function c(e,t,i=!1){return{path:"/tag/"+((0,r.isEmpty)(e)?"":e.map(encodeURIComponent).join("/")),query:l(t,i)}}t.urlSeed=(0,s.lazy)(a.prngSeed,100),t.mkHomeFullPath=function(e){return u([],e,!0)},t.mkTagFullPath=u,t.mkTagUri=c},23541:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),s=i(51926);function n(e){return Array.isArray(e)?e:null==e?void 0:(0,s.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return n(e)??[]},t.optToA=n},41583:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),s=i(23541),n=i(59455),a=i(54993);function o(e){return null==e?void 0:(0,s.isError)(e)?e:new Error((0,a.toS)(e))}t.toErr=o,t.toErrs=function(...e){return(0,r.compact)((0,n.toA)(e).map(o))}},54993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return n(e,",")};const s={}.toString;function n(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>n(e,t))).join(t):e.toString!==s?e.toString():(0,r.stringify)(e)}}t.toStr=n},98401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cancelFileAndProcCleanups=t.scheduleFileAndProcCleanups=t.fileCleanups=t.cleanup_=t.maybeCleanup_=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(56519),o=i(76187),l=i(87290),u=i(79267),c=i(32144),d=i(13829),h=i(69734),f=i(95696),m=i(65238),p=i(70257),g=i(13940),y=i(12495),w=i(95402),v=i(28874),b=i(40958),S=i(42659),P=i(31586),M=i(64526),_=i(22526),T=i(69032),E=(0,r.lazy)((()=>(0,s.mkLogger)("library.Cleanup")));async function D(){const e=M.Library.instance();if(null==e)E().info("No library to vacuum.");else{E().info("Running tag and search maintenance...");try{await(0,T.runTagMaintenance)()}catch(e){E().warn("Failed to run tag maintenance",{error:e})}E().info("Vacuuming db..."),await(await e.dbModelSetup_()).db.vacuum(),(0,n.isDbJanitorService)()&&(E().info("Running database maintenance..."),await e.runDbBackup_())}E().info("Cleaning child processes..."),await(w.Pids.instance()?.killOldProcs()),E().info("Cleaning stale and temp files..."),await k(),await(0,a.mapAsync)({name:"fileCleanup",arr:j(),f:e=>e.cleanup()})}t.maybeCleanup_=(0,r.lazy)(D,5*S.minuteMs),t.cleanup_=D;const k=(0,r.lazy)((()=>(0,l.libraryDataDirPosixFile)()?.join("shared-state").rmrf())),x=(0,r.lazy)((()=>u.FileCleanup.for({name:"imageCacheCleanup",rootNativePath:g.imageCacheDir_,staleMs:v.Settings.imageCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(g.ImageCacheName)}))),F=(0,r.lazy)((()=>u.FileCleanup.for({name:"readdirCacheCleanup",rootNativePath:async()=>f.PosixFile.for((0,m.readdirCacheDir)()),staleMs:v.Settings.readdirCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(m.ReadDirCacheName)}))),C=(0,r.lazy)((()=>u.FileCleanup.for({name:"previewWipCleanup",rootNativePath:l.libraryPreviewsDirPosixFile,staleMs:S.hourMs,isPrunable:e=>(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)}))),A=(0,r.lazy)((()=>u.FileCleanup.for({name:"advisoryLockWipCleanup",rootNativePath:d.defaultFsAdvisoryLockDir,staleMs:S.hourMs,isPrunable:h.isPsLockFileOrDir}))),I=(0,r.lazy)((()=>u.FileCleanup.for({name:"syncReportCleanup",rootNativePath:()=>(0,P.gt0)(v.Settings.syncReportRetentionCount.valueOrDefault)?(0,l.librarySyncReportsDir)():void 0,staleMs:S.hourMs,isPrunable:e=>(0,p.isWip)(e)||(0,c.isCsvExt)(e)})));function O(e){return(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)||(0,o.isSqliteFile)(e)}const L=(0,r.lazy)((()=>u.FileCleanup.for({name:"oldLibraryDbBackupCleanup",rootNativePath:()=>(0,_.libraryDbObjects_)().libraryDbBackupDir.sibling("backup"),staleMs:S.hourMs,isPrunable:O}))),R=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryDbBackupCleanup",rootNativePath:()=>(0,_.libraryDbObjects_)().libraryDbBackupDir,staleMs:S.hourMs,minRetained:v.Settings.dbBackupRetentionCount.valueOrDefault,isPrunable:O})));async function N(){const e=await(M.Library.instance()?.dbModelSetup_());return null!=e&&e.useReplica?e.db.localBackupDir():void 0}const B=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryReplicaDbBackupCleanup",rootNativePath:N,staleMs:S.hourMs,minRetained:1,isPrunable:O})));function j(){return(0,b.compact)([x(),F(),C(),A(),(0,y.LogDirCleanup)(),I(),L(),R(),B()])}t.fileCleanups=j,t.scheduleFileAndProcCleanups=(0,r.lazy)((()=>{w.Pids.instance()?.scheduleInterval();for(const e of j())e.scheduleInterval()})),t.cancelFileAndProcCleanups=function(){t.scheduleFileAndProcCleanups.unset(),w.Pids.instance()?.cancelInterval();for(const e of j())e.cancelInterval()}},64526:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Library=void 0;const l=i(27395),u=i(25764),c=i(38836),d=i(99331),h=i(45608),f=i(15056),m=i(87290),p=i(38835),g=i(57159),y=i(61704),w=i(95696),v=i(18454),b=i(13940),S=i(48604),P=i(19851),M=i(23560),_=i(28874),T=i(2858),E=i(7014),D=i(63870),k=i(15674),x=i(22573),F=i(38639),C=i(42659),A=i(56409),I=i(68708),O=i(25470),L=i(22526),R=i(41844);class N extends c.EndableWrapper{static instance(){const e=_.Settings.libraryDir.valueOrDefault,t=a(this,r,"f",s)?.rootDir.nativePath,i=!0===a(this,r,"f",s)?.isReadySync(),n=!0===a(this,r,"f",s)?.ended;return(0,y.nativePathsEqlSync)(t,e)&&!n?a(this,r,"f",s):(0,M.isSyncService)()&&i?void(0,h.exit)({reason:`Library changed mid-run. Shutting down to pick up new library at ${e}.`,status:0}):((0,l.end)(a(this,r,"f",s)),o(this,r,(0,x.blank)(e)||!(0,T._libraryHasSettings)(e)?void 0:new r(e),"f",s))}static get priorInstance(){return a(this,r,"f",s)}static endPriorInstance(){const e=a(this,r,"f",s);return o(this,r,void 0,"f",s),(0,l.end)(e)}static async instanceReady(){const e=r.instance();return await(e?.ready),e}static instanceRequired_(){const e=r.instance();if(null==e)throw new Error("Library is undefined"+p.FatalErrorFlag);return e}constructor(e){super(`library.Library(${e})`,(()=>this.onEnd()),u.EndableRanks.predb),this.start=Date.now(),this.readyLatch=new A.Latch,n.set(this,(0,P.lazy)((async()=>{try{this.logger.debug("setup() started"),this.logger.throwIfAborted_(),await(0,T.readLibrarySettings)(this.rootDir.nativePath),await(0,m.setupLibraryDirs_)(this.rootDir),await(0,b.imageCacheDir_)(),this.logger.throwIfAborted_();const e=await(0,E.bestVolumeForPath)((0,m.libraryPreviewsDirPosixFile)(this.rootDir));if((0,F.isTrue)(e?.remote)){const e=_.Settings.maxConcurrentImportsWhenRemote.valueOrDefault;_.Settings.maxConcurrentImports.hasValue()||(_.Settings.maxConcurrentImports.tmpValue=e,(0,k.clearMaxWorkCaches)()),this.logger.warn(`Library previews are on a remote volume. Setting maxSyncFileJobsMax to ${e}.`)}this.logger.throwIfAborted_(),(0,M.isDbService)()&&await this.dbModelJanitor(),this.previews(),this.logger.throwIfAborted_(),this.readyLatch.isPending()&&(this.logger.info("Library.setup() finished."),this.readyLatch.resolve())}catch(e){this.ended||(0,d.ending)()||(this.logger.warn("setup() failed:",{error:e}),v.HealthCheck.addError(e),this.readyLatch.reject(new g.WrappedError("Failed to start library",{cause:e})))}}))),this.previews=(0,P.lazy)((()=>(0,I.tap)(new S.Previews((0,m.libraryPreviewsDirPosixFile)(this.rootDir)),(e=>S.Previews.instance.set(e))))),this.originalsDir=(0,P.lazy)((()=>(0,m.libraryOriginalsDirPosixFile)(this.rootDir))),this.assetFileRepository=(0,P.lazy)((()=>new R.AssetFileRepository(this.originalsDir()))),this.libraryDbFile=(0,P.lazy)((()=>(0,f.pathToDb)(this.dataDir,"models"))),this.dbModelSetup_=(0,P.lazy)((async()=>{if((0,M.isDbService)())return(0,L.dbModelSetup_)(this.rootDir);throw new Error("Not a db service")})),this.dbFsLock=(0,P.lazy)((async()=>(await this.dbModelSetup_()).fslock)),this.useReplica=(0,P.lazy)((async()=>(await this.dbModelSetup_()).useReplica)),this.modelDb=(0,P.lazy)((async()=>(await this.dbModelSetup_()).db)),this.dbModelJanitor=(0,P.lazy)((async()=>O.DbModelJanitor.for(await this.dbModelSetup_()))),this.onEnd=(0,P.lazy)((async()=>{if(!(0,d.ending)())for(const{ea:e,t}of[{ea:this.dbModelJanitor.clear(),t:5*C.minuteMs},{ea:this.dbFsLock.clear(),t:(0,D.commandTimeoutMs)()}])await(0,l.end)(e,t);this.logger.info("onEnd(): finished.")})),this.rootDir=w.PosixFile.for(e),this.dataDir=(0,m.libraryDataDirPosixFile)(this.rootDir),this.logger.info("new()"),a(this,n,"f").call(this)}get isPendingSetup(){return this.readyLatch.isPending()}get ready(){return this.readyLatch.promise.then((()=>this))}isReadySync(){return this.readyLatch.isResolved()}async runDbBackup_(){return(await this.dbModelJanitor())?.backup_()}}t.Library=N,r=N,n=new WeakMap,s={value:void 0}},19113:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFileFiltersFor=void 0;const r=i(62105),s=i(181),n=i(94448),a=i(39604);t.libraryFileFiltersFor=function(e,{validateFile:t=!1}={}){const i=(0,r.expensiveFileFiltersFor)(e);return null!=(0,n.modelDb)()&&i.push({notBlocklistedSha:a.notBlocklistedSha}),t&&i.push({isValidFile:s.isValidFile}),i}},18449:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sentryEnabled=void 0;const r=i(7282),s=i(96706),n=i(29325),a=i(28874);t.sentryEnabled=function(){return(0,s.isEnvTrue)("ENABLE_SENTRY")||(0,r.isProd)()&&(0,n.isPacked)()&&!0===a.Settings.reportErrors.value}},95629:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelToSeverity=t.logEntryToBreadcrumb=t.mkBreadcrumbs=t.annotateEvent=t.sentryExceptionToS=t.sentryExceptionsToS=t.extractMessage=t.EventFilter=t.eventFilter=t.sendToSentry=t.installSentry=void 0;const o=n(i(16436)),l=a(i(48161)),u=a(i(1708)),c=i(19851),d=i(19043),h=i(50213),f=i(31578),m=i(7282),p=i(96175),g=i(23560),y=i(84968),w=i(81168),v=i(37805),b=i(25764),S=i(38836),P=i(99331),M=i(85100),_=i(98314),T=i(68301),E=i(70025),D=i(8769),k=i(34102),x=i(34592),F=i(42042),C=i(34474),A=i(20839),I=i(57902),O=i(45969),L=i(43334),R=i(40958),N=i(22573),B=i(42659),j=i(41400),z=i(98553),V=i(55835),W=i(12168),U=i(59455),q=i(54993),H=i(18449),G=(0,c.lazy)((()=>(0,h.mkLogger)("Sentry")));function $(e){(0,H.sentryEnabled)()&&null!=e&&!0!==(0,E.isDoNotSendError)(e)&&o.captureException(e)}t.installSentry=async function(e){try{return!!(0,H.sentryEnabled)()&&(o.init({dsn:L.isElectron?"https://0652cdd351054fe9853ff944b1f54e2c@o130922.ingest.sentry.io/289071":"https://5f52aefec1b3439eaed2e77b2d1210a8@o130922.ingest.sentry.io/1828379",shutdownTimeout:(0,M.serviceExitTimeoutMs)(e.name),release:v.release,environment:(0,m.nodeEnv)(),maxBreadcrumbs:100,integrations:[],beforeSend:(0,t.eventFilter)().beforeSend,onFatalError:e=>(0,D.onError)("sentry.onFatalError",e)}),G().info("Sentry initialized",{isElectron:L.isElectron}),!0)}catch(e){return G().warn("Failed to set up sentry",{error:e}),!1}},t.sendToSentry=$,t.eventFilter=(0,c.lazy)((()=>new J));class J{constructor(){this.beforeSend=async(e,t)=>{if(!(0,H.sentryEnabled)())return G().warn("Sentry.beforeSend(): not sending event",e),null;if(!0===await(T.ErrorStore.instance()?.eventQuotaExceeded(e)))return G().warn("Sentry.beforeSend(): event quota exceeded",e),null;const i=K(e,t);if(!0===(0,E.isDoNotSendError)(i))return G().info("Sentry.beforeSend(): event not sendable. vetoing",{event:e,hint:t,msg:i}),null;(0,N.blank)(e.message)&&(e.message=(0,w.ellipsize)(i,256));const r=await X(e);return await(T.ErrorStore.instance()?.maybeSendEvent(r))??null},(0,k.ee)().on("fatal",$),(0,k.ee)().on("nonFatal",$),new S.EndableWrapper("EventFilter",(()=>this.end()),b.EndableRanks.first)}end(){return(0,V.map)(o.getCurrentHub().getClient(),(e=>e.close(5*B.secondMs)))}}function K(e,t){return(0,R.uniq)((0,R.compactBlankish)([e.message,...(0,U.toA)(Z(e.exception?.values)),(0,_.errorToS)(t?.originalException)])).join(": ")}function Z(e){return(0,R.mapNotEmpty)(e,(e=>(0,R.compactBlanks)(e.map(Y))))}function Y(e){return(0,R.mapNotEmpty)((0,R.compactBlanks)([e?.type,e?.value].filter((e=>"error"!==(0,q.toS)(e).toLowerCase()))),(e=>e.join(": ")))}async function X(e){const t=await(0,F.getEmail)();(0,N.notBlank)(t)&&(null==e.user&&(e.user={}),e.user.email=t),(0,R.isEmpty)(e.breadcrumbs)&&(e.breadcrumbs=await Q());const i=e.extra??{};return i.pid=u.default.pid,i.serviceName=(0,g.serviceName)(),i.serviceEnding=(0,P.ending)(),i.runtimeMs=(0,y.runtimeMs)(),i.version=v.version,i.os=(0,p.osFullName)(),i.isDocker=(0,O.isDocker)(),i.nodeVersion=u.default.versions.node,i.locale=await(0,d.locale)(),i.cpus=(0,p.CPUs)(),i.memoryUsageMb=(0,f.memoryUsageMb)(),i.memoryUsageRssMb=(0,f.memoryUsageRssMb)(),i.systemMemory=(0,W.fmtBytes)(l.default.freemem())+" / "+(0,W.fmtBytes)(l.default.totalmem()),i.ffmpeg=await(0,x.ffmpegVersionDescription)(),i.argv=(0,z.stringify)(u.default.argv),e.extra=i,{timestamp:Date.now()/B.secondMs,...e}}async function Q(){await(0,j.delay)(3*A.DefaultLogFlushMs);const e=await(0,C.allRecentLogEntries)();return(0,R.compact)(e.map(ee))}function ee(e){return(0,V.map)(ie(e.l),(t=>({timestamp:e.ts/B.secondMs,level:t,category:e.from??(0,g.processName)(),message:(0,w.stripAnsiEsc)(e.ctx+": "+e.msg),data:"object"==typeof e.meta?e.meta:{value:(0,w.isString)(e.meta)?(0,w.stripAnsiEsc)(e.meta):e.meta}})))}t.EventFilter=J,t.extractMessage=K,t.sentryExceptionsToS=Z,t.sentryExceptionToS=Y,t.annotateEvent=X,t.mkBreadcrumbs=Q,t.logEntryToBreadcrumb=ee;const te=new Map([[I.LogLevels.fatal,"fatal"],[I.LogLevels.error,"error"],[I.LogLevels.warn,"warning"],[I.LogLevels.info,"info"],[I.LogLevels.debug,"debug"]]);function ie(e){return te.get(e)}t.logLevelToSeverity=ie},37158:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Service=t.setupEventHandlers=void 0;const p=m(i(29907)),g=m(i(1708)),y=i(57206),w=i(19851),v=i(50213),b=i(59880),S=i(23560),P=i(19913),M=i(71567),_=i(37805),T=i(38836),E=i(99331),D=i(45608),k=i(56038),x=i(55534),F=i(42499),C=i(49776),A=i(96706),I=i(98314),O=i(38835),L=i(70025),R=i(8769),N=i(57159),B=i(34102),j=i(33456),z=i(87408),V=i(85021),W=i(17181),U=i(86941),q=i(28874),H=i(41692),G=i(2858),$=i(69385),J=i(22573),K=i(42659),Z=i(41400),Y=i(56409),X=i(55835),Q=i(41583),ee=i(54993),te=i(95629);t.setupEventHandlers=(0,w.lazy)((()=>{(0,B.ee)().on("resume",(()=>(0,$.resume)())),(0,B.ee)().on("pause",(()=>(0,$.pause)()))}));class ie extends T.EndableWrapper{constructor(e){super(e),r.add(this),s.set(this,void 0),n.set(this,new Y.Latch),a.set(this,new Map),this.setup_=(0,w.lazy)((()=>(0,k.time)("Service.setup",(()=>f(this,r,"m",o).call(this))))),u.set(this,(0,w.lazy)((()=>{const e=g.default.stdin.pipe(new j.LineReader);return e.on("data",(e=>f(this,r,"m",d).call(this,(0,ee.toS)(e)))),e}))),(0,S.isBillingService)()||(0,H.setSettingsDefaults)(),h(this,s,(0,v.mkLogger)("Service("+this.name+")"),"f"),f(this,r,"m",c).call(this),this.setup_()}get name(){return super.name}get ready(){return f(this,n,"f").promise}get isReady(){return f(this,n,"f").isResolved()}setInputHandler(e,t){f(this,a,"f").set(e.trim().toLowerCase(),t)}}t.Service=ie,s=new WeakMap,n=new WeakMap,a=new WeakMap,u=new WeakMap,r=new WeakSet,o=async function(){try{(0,J.mapNotBlank)((0,A.getEnv)("PS_FATAL_"+this.name),(e=>{throw new N.WrappedError(e,{fatal:!0})})),(0,J.mapNotBlank)((0,A.getEnv)("PS_CRASH_"+this.name),(e=>{(0,Z.later)((()=>{throw new N.WrappedError(e)}),5*K.secondMs)})),(0,P.setServiceName)(this.name),(0,b.setProcessTitle)(),(0,S.isMainService)()&&await(0,U.mergeUserDataDirs_)(),await(0,G.readSettings)(),await f(this,r,"m",l).call(this),(0,W.setupLogger)(),(0,y.addDefaultJsonRevivers)(),(0,C.cacheDir)(),(0,t.setupEventHandlers)(),f(this,u,"f").call(this),await(0,F.setupLuxon)(),q.Settings.startPaused.valueOrDefault&&(0,$.pause)(),(0,E.ending)()?f(this,n,"f").reject():f(this,n,"f").resolve()}catch(e){console.error((0,I.errorToS)(e)),f(this,n,"f").reject((0,Q.toErr)(e)),(0,D.exit)({reason:(0,L.addErrorFlags)(this.name+" setup failed: "+(0,I.errorToS)(e),O.FatalErrorFlag),status:14})}},l=async function(){(0,S.isPermaService)()||(0,B.ee)().on("fatal",(e=>(0,D.exit)({error:e,status:12}))),g.default.on("unhandledRejection",(e=>(0,X.map)(e,(e=>(0,R.onError)("unhandledRejection",e))))),g.default.on("uncaughtException",(e=>(0,X.map)(e,(e=>(0,R.onError)("uncaughtException",e))))),g.default.on("SIGINT",(()=>(0,D.exit)({reason:"SIGINT",status:0}))),g.default.on("SIGHUP",(()=>(0,D.exit)({reason:"SIGHUP",status:0}))),g.default.on("SIGTERM",(()=>(0,D.exit)({reason:"SIGTERM",status:0}))),p.default.isWorker&&g.default.on("disconnect",(()=>(0,D.exit)({reason:"disconnect",status:0}))),await(0,te.installSentry)(this)},c=function(){this.setInputHandler("--version",(()=>(0,M.stdoutWrite)({version:_.version}))),this.setInputHandler(x.ServiceExitCommand,(()=>(0,Z.later)((()=>(0,D.exit)({reason:x.ServiceExitCommand+" from stdin",status:0}))))),this.setInputHandler("--times",(()=>(0,M.stdoutWrite)(k.PromiseTimer.instance().report()))),this.setInputHandler(V.HealthCheckCommand,(async()=>(0,M.stdoutWrite)(await(0,z.getStatusSummary)({refresh:!0}))))},d=async function(e){if(f(this,s,"f").debug("onLine()",{line:e,ending:this.ended||(0,E.ending)()}),await this.setup_(),e.startsWith("--")){const t=e.split(/\s+/,1)[0],i=f(this,a,"f").get(t);null==i?(f(this,s,"f").error("onLine(): unknown command",{line:e,knownCommands:[...f(this,a,"f").keys()]}),console.warn("unknown command "+e)):await i(e.slice(t.length).trim())}else f(this,s,"f").error("onLine(): failed to process",{line:e})}},56992:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.calcVolumesTTL=t.setVolumesTTL=void 0;const r=i(19851),s=i(50213),n=i(76596),a=i(87290),o=i(28874),l=i(2858),u=i(63870),c=i(7014),d=i(42659),h=i(31586),f=i(12168),m=(0,r.lazy)((()=>(0,s.mkLogger)("SetVolumesTTL")));async function p(){if(!(0,l.libraryHasSettings)())return;const e=[],t=await(0,c.volumes)(),i=o.Settings.minDiskFreeGb.defaultValue*f.GB;for(const r of[(0,a.libraryOriginalsDirPosixFile)(),(0,a.libraryPreviewsDirPosixFile)()]){const s=await(0,c.bestVolumeForPath)(r,t);if(null==s)return void m().warn("Can't find volume for "+r+", using default TTL for volumes()");if(s.availablethis.maybeRunChunk(),intervalMs:7*N.secondMs,onEnd:()=>w(this,r,"m",a).call(this),rank:T.EndableRanks.first,endTimeoutMs:C.Settings.taskTimeoutMs.valueOrDefault}),r.add(this),this.recentlyProcessed=new P.TTLArray(N.minuteMs),s.set(this,[]),this.taskCount=(0,v.lazy)((()=>W.Task.count())),d.set(this,(0,v.lazy)((()=>{this.logger.debug("status",this.state())}),((0,b.isTest)()?1:30)*N.secondMs)),f.set(this,(()=>this.maybeRunChunk())),m.set(this,(0,v.lazy)((()=>this.logger.info("runChunk(): no-op",{isPaused:(0,O.isPaused)(),isFull:this.p.isFull(),isTooBusy:(0,A.isTooBusy)(),whyDoNotRun:(0,I.whyDoNotRun)(this),pendingWorkCount:this.pendingWorkCount(),queueItemCount:this.taskCount(),freeSlots:this.p.freeSlots()})),((0,b.isTest)()?1:30)*N.secondMs)),this.maybeRunChunk=(0,v.lazy)((()=>{setTimeout((()=>{this.ended||(0,E.ending)()||(w(this,r,"m",g).call(this),this.maybeRunChunk.unset())}),t.TaskListRunLaterMs)})),p.set(this,(0,v.lazy)((()=>{const e=C.Settings.minBusyPct.valueOrDefault,t=C.Settings.stuckCheckIntervalMs.valueOrDefault;if(e<=0||this.p.isIdle()||t<=0)return;const i=A.CpuUsage.instance().busyPct();if(this.logger.debug("maybeCheckForStuckTasks()",{cpuBusyPct:i,minBusyPct:e,stuckCheckIntervalMs:t}),!(0,V.gte)(i,e))for(const e of this.p.running)if(e.elapsedMs>t){const t=e.payload;this.logger.error("Stuck serial task. Aborting.",{task:t,elapsedMs:e.elapsedMs});const i="stuck after "+e.elapsedMs+"ms";t.abort(i),e.reject(new M.AbortError(i))}}),C.Settings.stuckCheckIntervalMs.valueOrDefault)),this.p=new k.Promises(e,L.maxConcurrentImports),this.p.ee.on("vacancy",this.maybeRunChunk),this.p.ee.on("drain",(()=>w(this,r,"m",l).call(this))),(0,x.ee)().on("resume",w(this,f,"f")),W.Task.ee.on("added",this.maybeRunChunk)}async awaitDrain(e=[],t=0){(0,R.isEmpty)(e)&&(e=W.TaskNames.values);const i=new z.Latch;return w(this,s,"f").push({l:i,taskNames:e,maxRemaining:t,who:(0,j.shortStack)()}),this.maybeRunChunk(),i}isRunnable(){return!this.p.isFull()}currentWorkCount(){return this.p.unsettledCount()}pendingWorkCount(){return this.taskCount()-this.currentWorkCount()}hasCapacity(e=C.Settings.taskListCap.valueOrDefault){return e<=0||this.taskCount()e.payload))}currentTasksByFn(e){return this.currentTasks().filter((t=>t.fn===e))}state(){return{...this.p.stats(),isDone:w(this,r,"m",l).call(this),freeSlots:this.p.freeSlots(),pendingWork:this.taskCount(),next10:w(this,r,"m",h).call(this,10).map((e=>e.toString())),recentlyProcessedLast10:this.recentlyProcessed.slice(-10).map((e=>e.toString())),isRunnable:this.isRunnable()}}doNotStartMoreWork(){return(0,E.ending)()||this.ended||(0,O.isPaused)()||this.p.isFull()||(0,A.isTooBusy)()||(0,I.doNotRun)(this)||0===this.pendingWorkCount()}}t.TaskList=U,s=new WeakMap,d=new WeakMap,f=new WeakMap,m=new WeakMap,p=new WeakMap,r=new WeakSet,n=function(){this.taskCount.unset()},a=async function(){(0,x.ee)().off("resume",w(this,f,"f"));const e=new M.AbortError((0,E.ending)()?"service ending":"TaskList ended");for(const t of w(this,s,"f"))t.l.reject(e);await this.p.awaitAll()},o=function(){(0,R.filterInPlace)(w(this,s,"f"),(e=>e.l.isPending())),W.Task.dbl.runf((e=>e.delete().where("retries","<",0))),w(this,r,"m",n).call(this)},l=function(){if(this.ended)return;if(w(this,r,"m",o).call(this),(0,R.isEmpty)(w(this,s,"f")))return;const e=W.Task.countTaskNames();for(const t of this.p.deferreds){const i=t.name;e[i]=(e[i]??0)+1}for(const t of w(this,s,"f"))(0,F.sum)(t.taskNames.map((t=>e[t]??0)))<=t.maxRemaining&&t.l.resolve()},u=function(){return(0,R.uniq)(this.currentTasks().filter((e=>e.isSerial)).map((e=>e.fn)))},c=function(){return this.currentTasks().map((e=>e.id))},h=function(e){return 0===e?[]:W.Task.ops().allf((t=>(t=W.Task.orderBy(t.distinct().whereNotIn("id",w(this,r,"m",c).call(this)).whereNotIn("fn",w(this,r,"m",u).call(this))),(0,V.gt0)(e)&&(t=t.limit(e)),t)))},g=function(){if(w(this,r,"m",n).call(this),w(this,p,"f").call(this),this.doNotStartMoreWork())w(this,m,"f").call(this);else{w(this,d,"f").call(this);const e=this.p.freeSlots(),t=w(this,r,"m",h).call(this,e);this.logger.debug("runChunk():",{freeSlots:e,next:t});for(const e of t)this.p.enqueue({name:this.name,payload:e,l:()=>w(this,r,"m",y).call(this,e),serialId:e.isSerial?e.fn:void 0})}w(this,r,"m",l).call(this)},y=async function(e){try{await(0,D.time)("task."+e.fn,e._run())}catch(t){this.logger.warn("Failed to run task",{task:e,error:t})}finally{this.maybeRunChunk()}},U.instance=(0,B.defer)((()=>(0,S.isTaskListManager)()?new U:void 0))},44834:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExitWhenDone=void 0,t.ExitWhenDone="--exit-when-done"},21200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExitWhenDoneArg=void 0;const r=i(28874),s=i(38639),n=i(44834);t.ExitWhenDoneArg={beforeParse:e=>e.option(n.ExitWhenDone,"Exit after jobs are completed. Defaults to false unless paths are specified on the command line."),afterParse:e=>{(0,s.isTrue)(e.exitWhenDone)&&(r.Settings.exitWhenDone.envValue=!0)}}},2775:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ForceArg=void 0;const r=i(28874),s=i(38639);t.ForceArg={beforeParse:e=>e.option("--force","Deletes prior cached directory metadata, and forces directory contents to be re-scanned."),afterParse:async e=>{(0,s.isTrue)(e.force)&&(r.Settings.forceSync.envValue=!0)}}},31503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogArgs=void 0;const r=i(23560),s=i(83210),n=i(28874),a=i(38639);function o(){return(0,r.isMainService)()||(0,r.isSyncService)()}t.LogArgs={beforeParse:e=>{const t=(o()?', "PS_TAIL_LOGS=true"':"")+' and "PS_LOG_STDOUT=true".';return o()?e.option("-v, --verbose",'Verbose logging from all processes. Shortcut for "--info --tail". Caution: noisy during imports!'):e.option("-v, --verbose","Verbose logging. Equivalent to --info."),e.option("--error",`Emit "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=error"${t}`),e.option("--warn",`Emit "warn" and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=warn"${t}`),e.option("--info",`Emit "info", "warn", and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=info"${t}`),e.option("--debug",`Emit "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY NOISY. Sets "PS_LOG_LEVEL=debug"${t}}`),e.option("--trace",`Emit "trace", "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY VERY NOISY. Sets "PS_LOG_LEVEL=trace"${t}}`),o()&&e.option("--tail",'Emit log messages from both this process and all other concurrently running PhotoStructure processes on this host to stdout. This can be really helpful in seeing how PhotoStructure\'s processes are coordinating work. Caution: very noisy especially during imports. Sets "PS_TAIL_LOGS=true".'),e},afterParse:e=>{const t=(0,a.isTrue)(e.error),i=(0,a.isTrue)(e.warn),r=(0,a.isTrue)(e.info)||(0,a.isTrue)(e.verbose)||(0,a.isTrue)(e.v),l=(0,a.isTrue)(e.debug),u=(0,a.isTrue)(e.trace);u?n.Settings.logLevel.envValue="trace":l?n.Settings.logLevel.envValue="debug":r?n.Settings.logLevel.envValue="info":i?n.Settings.logLevel.envValue="warn":t&&(n.Settings.logLevel.envValue="error"),(0,s.isDaemon)(e)?(n.Settings.tailLogs.envValue=!1,n.Settings.logStdout.envValue=!1):((0,a.isTrue)(e.tail)&&(n.Settings.tailLogs.envValue=!0),(t||i||r||l||u)&&(n.Settings.logStdout.tmpValue=!0,o()&&(n.Settings.tailLogs.tmpValue=!0)),(n.Settings.tailLogs.valueOrDefault||n.Settings.logStdout.valueOrDefault)&&n.Settings.logLevel.isUnset()&&(n.Settings.logLevel.envValue="info"))}}},12195:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoFilterArg=void 0;const r=i(4175),s=i(38639);t.NoFilterArg={beforeParse:e=>e.option("--no-filter","Disables import filters. All paths will try to be imported, even if they are too small or are missing tags. See https://photostructure.com/faq/why-is-my-file-missing/ ."),afterParse:async e=>{(0,s.isFalse)(e.filter)&&(0,r.disableAllFilters)()}}},52288:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RebuildArg=void 0;const r=i(28874),s=i(38639);t.RebuildArg={beforeParse:e=>e.option("--rebuild","Rebuild your library by re-importing all your photos and videos (slow!) https://photostructure.com/faq/sync-vs-rebuild/"),afterParse:async e=>{(0,s.isTrue)(e.rebuild)&&(r.Settings.forceRebuildLibrary.envValue=!0)}}},46628:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.albumsFromTags=t.tagFilesWithAlbums=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(81168),o=i(74417),l=i(28874),u=i(47783),c=i(97573),d=i(42231),h=i(40958),f=i(22573),m=i(68708),p=i(75020),g=i(54993),y=(0,s.lazy)((()=>(0,n.mkLogger)("curators.AlbumTagger")));function w(e){return(0,f.blank)(e)?void 0:l.Settings.tagAlbumTitleHierarchies.valueOrDefault?(0,c.keywordToPath)(e):[e]}function v(e){if(null==e)return[];const t=(0,h.uniq)((0,r.flatMap)(l.Settings.tagAlbumTitle.values,(t=>(0,m.pluckDeep)(e,t)?.value))),i=(0,h.compact)(t.map(w));if((0,h.isEmpty)(i))return[];if(i.length>1)return y().tap({level:"info",msg:"albumFromFile()",result:i.map((e=>[p.TagRoots.Albums,...e]))});const s=i[0],n=(0,r.first)(l.Settings.tagAlbumDescription.values,(t=>(0,m.pluckDeep)(e,t)?.value)),u=(0,h.isEmpty)(s)?"(blank title)":(0,a.firstSubstringIgnoreCase)(l.Settings.tagAlbumsExcluded.values,[...s,(0,g.toS)(n)].join(" ")),c=null==u?[p.TagRoots.Albums,...s]:void 0;if(null!=c){const t={name:c[c.length-1],description:n};for(const i of l.Settings.tagAlbumDate.values){const r=(0,o.parseJsonDateToMillis)((0,m.pluckDeep)(e,i)?.value);if(null!=r){t.releasedAt=r;break}}c[c.length-1]=t}return y().tap({level:"info",msg:"albumFromFile()",result:(0,h.compact)([c]),meta:{titles:i,desc:n,whyExclude:u}})}t.tagFilesWithAlbums=async function(e){const t=[];for(const i of e){t.push(...v(await(0,u.readTags)(i)));for(const e of l.Settings.tagAlbumFilenames.values)t.push(...v(await(0,u.readRawTags)(i.sibling(e),!1)))}return y().tap({msg:"tagFilesWithAlbums()",result:(0,d.uniqTagPaths)(t),meta:{files:e}})},t.albumsFromTags=v},88224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagAsset=t.tagAndUpsertAsset_=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(28874),o=i(42231),l=i(40958),u=i(20214),c=i(43487),d=i(46628),h=i(63175),f=i(4407),m=i(58886),p=i(32646),g=i(48144),y=i(60047),w=i(6186),v=i(42003),b=i(43723),S=(0,r.lazy)((()=>(0,s.mkLogger)("curators.AssetTagger")));async function P({primaryVariation:e,files:t,priorTagPaths:i,capturedAts:r,uris:s}){const u=[];if(t=(0,l.uniqBy)([e,...t],(e=>e.nativePath)),a.Settings.tagCamera.valueOrDefault&&await(0,n.thenMap)((0,h.cameraTagFile)(e),(t=>{S().debug("Camera tag for "+e+":",t),u.push(t)})),a.Settings.tagLens.valueOrDefault&&await(0,n.thenMap)((0,y.lensTagFile)(e),(t=>{S().debug("Lens tag for "+e+":",t),u.push(t)})),a.Settings.tagGeo.valueOrDefault)for(const e of t){const t=await(0,p.geoTagFile)(e);if(null!=t){u.push(t);break}}await(0,n.thenMap)((0,f.dateTagFile)(e,r),(t=>{S().debug("Date tag for "+e+":",t),u.push(t)}));const c=await(0,b.whoTagFiles)(t)??[];S().debug("whoTagFiles for "+e+":",c),u.push(...c),await(0,n.thenMap)((0,g.keywordTagFiles)(t,c),(t=>{S().debug("Keyword tags for "+e+":",t),u.push(...t)})),a.Settings.tagFileType.valueOrDefault&&await(0,n.thenMap)((0,v.typeTagFiles)(t),(t=>{S().debug("MIME type tags for "+e+":",t),u.push(...t)})),await(0,n.thenMap)((0,m.tagAssetPaths)(s),(e=>{S().debug("file paths for uris",{uris:s,arr:e}),u.push(...e)})),await(0,n.thenMap)((0,d.tagFilesWithAlbums)(t),(t=>{S().debug("Album tags for "+e+":",t),u.push(...t)}));const P=(0,o.omitAncestorTags)((0,l.uniqBy)(u.map(w.normalizeTagRoot),o.joinTagPath)),M=await(0,w.tagDeltas)(i,P);return S().info("tagAsset("+e+")",{priorTagPaths:i,after:P,result:M}),M}t.tagAndUpsertAsset_=async function(e){const t=await e.getExistingAssetFiles();S().info("tagAndUpsertAsset()",{asset:e,existing_uris:t.map((e=>e.uri))});const i=t.find((e=>e.shown)),r=await(i?.posixFile_());if(null==i||null==r)return void S().throw("tagAndUpsertAsset(): no existing or primary asset file",{asset:e,existingPrimaryAssetFile:i,primaryVariant:r,doNotSend:!0,fatal:!1});const s=e.getShown();s?.id!==i.id&&(S().warn("Changing primary asset we're using a different variant for tagging.",{newPrimary:i.uri,priorPrimary:s?.uri}),e.setShown_(i));const n=await(0,u.thenCollect)(t,(e=>e.posixFile_())),l=e.getAssetFiles().map((e=>e.uri)),d=e.getTagPaths(),h=await e.getCapturedAts(),f=await P({primaryVariation:r,files:n,priorTagPaths:d,capturedAts:h,uris:l});S().info("tagAndUpsertAsset",f);const m=f.add.find((e=>(0,o.leafIsExcluded)(e,a.Settings.keywordBlocklist.values)));if(null!=m){if(!0!==e.shown)return S().info("this asset has an excluded tag, and it wasn't shown yet, so we're removing it.",{excludedTag:m}),await c.Asset.remove({assetId:e.id,blocklistShas:!1,unlinkAssetFiles:!1}),S().throw("tagAndUpsertAsset(): asset had excluded tag. Removed.",{excludedTag:m,uris:l,files:n.map((e=>e.nativePath))});S().info("this asset has an excluded tag, marking excluded",{excludedTag:m}),e.excludedAt=Date.now()}return e.applyTagPathDeltas(f),await e.updateFromFiles(),f},t.tagAsset=P},63175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cameraTagFile=t.cameraTag=void 0;const r=i(47783),s=i(75020),n=i(40958),a=i(22573);function o(e){return null==e||(0,a.blank)(e.Make)?void 0:(0,n.compactBlankish)([s.TagRoots.Camera,e.Make,e.Model])}t.cameraTag=o,t.cameraTagFile=async function(e){return o(await(0,r.readTags)(e))}},4407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateTagFile=t.dateTag=t.dayTagRef=t.monthTagRef=t.yearTagRef=t.dayToOrdinal=t.ordinalToMonth=t.monthToOrdinal=t.yearToOrdinal=void 0;const r=i(19851),s=i(19043),n=i(97352),a=i(81168),o=i(928),l=i(34102),u=i(28874),c=i(28544),d=i(47783),h=i(40958),f=i(55835),m=i(31586),p=i(75020),g=i(54993),y=(0,r.lazy)((()=>new Intl.DateTimeFormat((0,s.localeSync)(),{month:"short"}))),w=(0,r.lazy)((()=>{const e=y();return(0,h.range)(0,12,(t=>e.format(new Date(2016,t,1)))).map((e=>(0,a.stripSuffix)(e,".")))}));function v(e){return 1e4-e}function b(e){return 13-e}function S(e){return 33-e}function P(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:v(e)})))}function M(e){if((0,m.within)(1,12,e))return(0,f.map)(w()[e-1],(t=>({name:String(e),displayName:t,ordinal:b(e)})))}function _(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:S(e)})))}function T(e){const t=(0,g.toS)(u.Settings.tagYMD.valueOrDefault).toLowerCase();if(null==e||""===t||"off"===t||t.startsWith("disable"))return;const i=[p.TagRoots.When];if(t.startsWith("y")){const t=(0,f.map)((0,o.getYear)(e),P);if(null==t)return;i.push(t)}if(t.startsWith("ym")){const t=(0,f.map)((0,o.getMonth)(e),M);if(null==t)return i;i.push(t)}if(t.startsWith("ymd")){const t=(0,f.map)((0,o.getDay)(e),_);if(null==t)return i;i.push(t)}return i}(0,l.ee)().on("clearCache",(()=>{y.unset(),w.unset()})),t.yearToOrdinal=v,t.monthToOrdinal=b,t.ordinalToMonth=function(e){return 13-e},t.dayToOrdinal=S,t.yearTagRef=P,t.monthTagRef=M,t.dayTagRef=_,t.dateTag=T,t.dateTagFile=async function(e,t){if(""===u.Settings.tagYMD.valueOrDefault)return;const i=[...t];(0,h.isEmpty)(t)&&i.push((await(0,d.readTags)(e))?.capturedAt);const r=(0,c.bestCapturedAt)(i);return null==r||(0,c.capturedAtSrcFromStat)(r.src)&&!u.Settings.tagDateFromStat.valueOrDefault?void 0:T(r.date)}},58886:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addFileUriTagsToAsset=t.addFilesTagsToAsset=t.isFsTag=t.tagAssetPaths=void 0;const r=i(19851),s=i(50213),n=i(42231),a=i(21404),o=i(40958),l=i(89937),u=i(75020),c=i(54017),d=i(94448),h=i(69032),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.FilePathTagger")));function m(e,t){return e.applyTagPathDeltas({add:(0,o.compact)(t.map((e=>(0,a.uriToTagPath)({uri:e,isFile:!0}))))})}t.tagAssetPaths=async function(e){const t=[];for(const i of e)try{const e=(0,a.uriToTagPath)({uri:i,isFile:!0});if(null==e)continue;if(i.startsWith(l.PS_LOCAL_FILE_SCHEME)&&null!=(0,d.modelDb)()){const t=(0,n.tagRefToS)(e[1]);e[1]={name:t,displayName:await(0,h.displayNameForVolsha)(t)},f().info("tagAssetPaths()",{uri:i,tp:e})}t.push(e)}catch(e){f().warn("Failed to parse asset file URI",{uri:i})}return t},t.isFsTag=function(e){return(0,n.tagRefToS)(e[0]).toLowerCase()===u.TagRoots.fs},t.addFilesTagsToAsset=function(e){const t=c.AssetFile.dbl.pluckAllf((t=>t.select("uri").where({asset:e})));return m(e,t)},t.addFileUriTagsToAsset=m},32646:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.geoTagFile=t.geoTag=void 0;const r=i(48884),s=i(56519),n=i(28874),a=i(47783),o=i(75020),l=i(40958);function u(e){const t=(0,r.compactRight)(n.Settings.tagGeoTemplate.valueOrDefault.map((t=>e?.[t])));return 0===t.length||t.some((e=>null==e))?void 0:(0,l.compact)([o.TagRoots.Where,...t])}t.geoTag=u,t.geoTagFile=function(e){return(0,s.thenMap)((0,a.readTags)(e),u)}},48144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.keywordTagFiles=t.processKeywords=t.dedupeKeywordPaths=t.normalizeKeywordPaths=t.extractPathnameTags=t.extractDashDashTags=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(68852),o=i(81168),l=i(96859),u=i(56519),c=i(28874),d=i(47783),h=i(97573),f=i(42231),m=i(40958),p=i(76790),g=i(22573),y=i(41400),w=i(96249),v=i(55835),b=i(75020),S=i(54993),P=i(6186),M=i(43723),_=(0,s.lazy)((()=>(0,n.mkLogger)("curators.KeywordTagger"))),T=(0,s.lazy)((()=>(0,g.mapNotBlank)(c.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[ /${(0,a.escapeRegExp)(e)}]`)))));function E(e){return _().tap({msg:"extractDashDashTags()",result:(0,v.mapOr)((0,S.toS)(e).split("--")[1],(e=>(0,m.compactBlanks)((0,v.mapOr)(T(),(t=>e.split(t)),[e]))),(()=>[])),meta:{s:e}})}function D(e){return[...E(e.parent().posixPath),...E(e.name)]}(0,y.later)((()=>{c.Settings.keywordDelimiters.watchLater((()=>T.unset()))})),t.extractDashDashTags=E,t.extractPathnameTags=D;const k=/\w{2,7}:\/\/\S+/g;function x(e){const t=[],i=[],s=[];for(const t of(0,m.compact)(e))if(Array.isArray(t))s.push(t);else{const e=(0,S.toS)(t).replace(k,(e=>(i.push(e),"")));s.push(...(0,v.mapOr)((0,h.delimRe)(),(t=>e.split(t)),[e]))}const n=s.map((e=>(0,o.isString)(e)?(0,h.keywordToPath)(e):e)).map((e=>Array.isArray(e)&&1===e.length?e[0]:e)),[a,l]=(0,r.partition)(n,Array.isArray),u=a.map((e=>(0,m.compactBlanks)(e.map((e=>e.trim()))))).filter(m.isNotEmpty),d=(0,o.uniqIgnoreCase)((0,w.flatten)(u));t.push(...u);const f=[...l,...i].map((e=>e.trim())).filter((e=>(0,g.notBlank)(e)&&!(0,o.includesIgnoreCase)(d,e))),p="copy"===c.Settings.keywordReparenting.valueOrDefault,y="retain"===c.Settings.keywordReparenting.valueOrDefault,P=c.Settings.rootTagKeywordsAliases.values;for(const e of[...t])(0,o.includesIgnoreCase)(P,e[0])&&(e[0]=b.TagRoots.Keywords),e[0]!==b.TagRoots.Keywords&&(p?t.push([b.TagRoots.Keywords,...e]):y&&e.unshift(b.TagRoots.Keywords));for(const e of f)t.push([b.TagRoots.Keywords,e]);return(0,m.uniq)(t)}function F(e){return(0,m.uniqBy2)((0,p.sortBy)(e.map(P.normalizeTagRoot),(e=>{const t=(0,f.joinTagPath)(e);return[t.normalize().toLowerCase(),-1*(0,l.lcdiff)(t)]})),((e,t)=>(0,o.equalsIgnoreCase)((0,f.joinTagPath)(e),(0,f.joinTagPath)(t))))}function C(e,t){const[i,s]=(0,r.partition)(x(e),M.isWhoTag),n=(0,w.flatten)(i.map(M.nameTag)),a=(0,m.uniq)((0,w.flatten)([...n,...t].map((e=>{const t=(0,P.stripTagRoot)(e);return[t.join(", "),t.join(" "),[...t].reverse().join(" ")]})))),l=F([...s.filter((e=>!(0,o.includesIgnoreCase)(a,(0,P.stripTagRoot)(e).join(" ")))),...n]);return _().tap({msg:"processKeywords()",level:"info",result:l})}t.normalizeKeywordPaths=x,t.dedupeKeywordPaths=F,t.processKeywords=C,t.keywordTagFiles=async function(e,t){return C([...c.Settings.tagKeywordsFromPath.valueOrDefault?(0,w.flatten)(e.map(D)):[],...c.Settings.tagKeywordsFromMetadata.valueOrDefault?(0,w.flatten)(await(0,u.mapAsyncSerial)({name:"keywordTagFiles",arr:e,f:e=>(0,u.thenMap)((0,d.readRawTags)(e),h.rawTagKeywords)})):[]],t)}},60047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lensTagFile=t.lensTag=void 0;const r=i(56519),s=i(28874),n=i(47783),a=i(75020),o=i(40958),l=i(22573),u=i(55835);function c(e){return(0,u.map)(e,(e=>(0,l.mapNotBlank)(e.lensMake,(t=>(0,l.mapNotBlank)((0,o.compactBlanks)(s.Settings.tagFullLensModel.valueOrDefault?[e.lensModel,e.lensInfo]:[e.lensInfo,e.lensModel])[0],(e=>[a.TagRoots.Lens,t,e]))))))}t.lensTag=c,t.lensTagFile=function(e){return(0,r.thenMap)((0,n.readTags)(e),c)}},6186:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagDeltas=t.normalizeTagRoot=t.stripTagRoot=t.hasTagRoot=t.Roots=t.KwRoot=t.WhoRoot=t.AlbumsRoot=t.WhenRoot=void 0;const r=i(50213),s=i(28874),n=i(42231),a=i(75020),o=i(40958),l=i(22573),u=i(45599);t.WhenRoot={name:a.TagRoots.When,ordinal:1},t.AlbumsRoot={name:a.TagRoots.Albums,ordinal:2},t.WhoRoot={name:a.TagRoots.Who,ordinal:4},t.KwRoot={name:a.TagRoots.Keywords,ordinal:7};const c=(0,u.defer)((()=>(0,r.mkLogger)("curators.Taggers")));t.Roots=[t.WhenRoot,t.AlbumsRoot,{name:a.TagRoots.fs,ordinal:3},t.WhoRoot,{name:a.TagRoots.Camera,ordinal:5},{name:a.TagRoots.Lens,ordinal:6},t.KwRoot,{name:a.TagRoots.Type,ordinal:8}];const d=(0,o.uniq)([...a.TagRoots.values,...s.Settings.rootTagKeywordsAliases.values,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function h(e){return d.includes((0,n.tagRefToS)(e[0]).toLowerCase())}t.hasTagRoot=h,t.stripTagRoot=function(e){return h(e)?e.slice(1):e};const f=(0,o.uniq)([a.TagRoots.Albums,...s.Settings.rootTagAlbumsAliases.values].map((e=>e.toLowerCase()))),m=(0,o.uniq)([a.TagRoots.Keywords,...s.Settings.rootTagKeywordsAliases.values].map((e=>e.toLowerCase()))),p=(0,o.uniq)([a.TagRoots.Who,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));t.normalizeTagRoot=function(e){const i=(0,n.tagRefToS)(e[0]).toLowerCase();return(0,l.blank)(i)?e:m.includes(i)||m.includes(i)?[t.KwRoot,...e.slice(1)]:p.includes(i)?[t.WhoRoot,...e.slice(1)]:f.includes(i)?[t.AlbumsRoot,...e.slice(1)]:e},t.tagDeltas=async function(e,t){const i=(0,n.tagDiff)(t,e),r=(0,n.tagDiff)(e,t),a=s.Settings.excludedRootTags.valueOrDefault;return(0,o.filterInPlace)(i,(e=>{const t=a.includes((0,n.tagRefToS)(e[0]).toLowerCase());return t&&!(0,n.tagPathsInclude)(e,r)&&(r.push(e),c().info("tagDeltas(): removing excluded tag",e)),!t})),{add:i,remove:r}}},42003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fixCase=t.friendlySubtype=t.mimeTypeToTag=t.typeTagFiles=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(56519),o=i(54979),l=i(40958),u=i(22573),c=i(55835),d=i(42279),h=i(75020),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.TypeTagger")));t.typeTagFiles=async function(e){const t=(0,l.uniq)(await(0,a.mapAsyncSerial)({name:"typeTagFiles",arr:e,f:o.readMimeType}));return(0,l.compact)(t.map(p))};const m=new Map(["M2TS","JPEG","QuickTime"].map((e=>[e.toLowerCase(),e])));function p(e){const[t,i]=e.split("/");if(!(0,u.blank)(t)&&!(0,u.blank)(i))return f().tap({msg:"mimetypeToTag("+e+")",result:(0,c.map)(y(i,e),(e=>(0,l.compactBlanks)([h.TagRoots.Type,(0,n.capitalize)(t),...e])))})}t.mimeTypeToTag=p;const g=(0,r.lazy)((()=>new Map([["image/x-adobe-dng",["Raw","DNG"]],["image/x-fuji-raf",["Raw","Fujifilm"]],["video/m2ts",["MPEG-2"]],["video/mp2t",["MPEG-2"]],["video/mp4",["MPEG-4"]],["video/quicktime",["QuickTime"]],["video/x-msvideo",["AVI"]]])));function y(e,t){return(0,d.firstDefinedThunk)([()=>g().get(t.trim().toLowerCase()),()=>(0,c.map)(e.match(/^x-(\w{4,})-\w{3}/),(e=>["Raw",(0,n.capitalize)(e[1])])),()=>[w(e.replace(/^(?:x-|vnd\.|prs\.)/i,"").replace(/-/g," "))]])}function w(e){return null!=e.match(/[a-z\d]{3,4}/i)?e.toUpperCase():m.get(e.trim().toLowerCase())??(0,n.capitalize)(e)}t.friendlySubtype=y,t.fixCase=w},43723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nameTag=t.isWhoTag=t.whoTagFiles=void 0;const r=i(19851),s=i(50213),n=i(28874),a=i(47783),o=i(28630),l=i(66039),u=i(42231),c=i(40958),d=i(22573),h=i(96249),f=i(68708),m=i(75020),p=i(59455),g=(0,r.lazy)((()=>(0,s.mkLogger)("curators.WhoTagger")));t.whoTagFiles=async function(e){const t=[];if(n.Settings.tagJsonFaces.valueOrDefault){const i=[];for(const t of e)i.push(...(0,p.toA)(await t.jsonSidecars()));for(const e of i){const i=await(0,o.readJsonSidecar)(e),r=i?.peopleNames;(0,c.isNotEmpty)(r)&&t.push(...r)}}if(n.Settings.tagFaceRegions.valueOrDefault)for(const i of e){const e=await(0,a.readRawTags)(i,!0);if(null!=e)for(const i of(0,f.values)(e)){const e=i?.RegionList;if(Array.isArray(e))for(const i of e)"Face"===i.Type&&t.push(i.Name)}}if((0,c.isNotEmpty)(n.Settings.whoTags.values))for(const i of e){const e=await(0,a.readRawTags)(i,!0);for(const i of n.Settings.whoTags.values)t.push(...(0,p.toA)((0,f.pluckDeep)(e,i)?.value))}const i=(0,c.uniq)((0,h.flatten)((0,c.uniq)(t).map(v)));return g().tap({msg:"whoTagFiles()",level:"info",result:i,meta:{names:t,files:e.map((e=>e.nativePath))}})};const y=(0,c.uniq)([m.TagRoots.Who,...n.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function w(e){return y.includes((0,u.tagRefToS)(e[0]).toLowerCase())}function v(e){if(!(0,d.blank)(e))return Array.isArray(e)?(w(e)&&e.shift(),0===e.length?void 0:1===e.length?(0,l.renderNameTag)(e[0]):[[m.TagRoots.Who,...e]]):(0,l.renderNameTag)(e)}t.isWhoTag=w,t.nameTag=v},98348:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Db=void 0;const c=i(48884),d=i(19851),h=i(23560),f=i(25764),m=i(38836),p=i(99331),g=i(12959),y=i(55332),w=i(91872),v=i(80632),b=i(51040),S=i(44955),P=i(15056),M=i(70025),_=i(57159),T=i(18454),E=i(28874),D=i(5233),k=i(42659),x=i(31586),F=i(68708),C=i(30976),A=i(17036),I=i(27134),O=i(35052);class L extends m.EndableWrapper{constructor(e,t){super("db.Db("+e+")",(()=>this.closeDb()),f.EndableRanks.db),r.add(this),this.schema=e,this.dbFile=t,s.set(this,0),n.set(this,void 0),this.endTimeoutMs=k.minuteMs,this.onRetry=(0,d.lazy)((()=>this.closeDb()),E.Settings.maxBusyDbMs.valueOrDefault/2),this.maxUpdatedAt=(0,d.lazy)((()=>"models"===this.schema?l(this,r,"m",a).call(this,"Asset","AssetFile","Example"):0),5*k.secondMs),this.migrate_=(0,d.lazy)((async()=>{let e=!1;const t=this.dbFile;if(null==this.dbFile)throw new Error("Cannot migrate database: missing db");let i;if(await this.dbFile.isNonEmptyFile())try{await(0,I.verifyDb_)((()=>this.db))}catch(e){this.logger.warn("verifyDb failed before attempting Migration.",{error:e}),i=e}(null!=i||E.Settings.dbForceRecover.valueOrDefault)&&(T.HealthCheck.addLoadingMsg("Repairing database..."),await this.repair_(),e=!0);const r=new A.Migration(this.schema,this.db,t);return{appliedMigrations:await r.apply_(),migration:r,repaired:e}})),this.tableInfo_=(0,d.lazy)((()=>(0,O.localTableInfo)(this.db)))}toJSON(){return(0,F.pick)(this,"schema","dbFile")}get isOpen(){return!0===l(this,n,"f")?.open}get inTransaction(){return this.isOpen&&!0===l(this,n,"f")?.inTransaction}prepare(e){return this.db.prepare(e)}pragma(e,t){return this.logger.tapThunk({msg:"PRAGMA "+e,result:()=>this.db.pragma(e,t)})}get db(){var e;const t=null==l(this,n,"f");if(t||!this.isOpen){this.logger.info("setting up new db connection to "+this.dbFile,{priorWasNull:t});try{u(this,n,(0,v.mkdb_)({nativePath:this.dbFile.nativePath}),"f")}catch(e){throw new _.WrappedError("Failed to set up "+this.dbFile,{cause:e,path:this.dbFile.nativePath})}}return(0,h.isSyncService)()&&"INCREMENTAL"===E.Settings.dbAutoVacuumMode.valueOrDefault&&(0,x.gt0)(E.Settings.dbWalAutoCheckpoint.valueOrDefault)&&u(this,s,(e=l(this,s,"f"),++e),"f")%E.Settings.dbWalAutoCheckpoint.valueOrDefault==0&&(this.logger.info("running incremental_vacuum..."),l(this,n,"f")?.pragma("incremental_vacuum")),l(this,n,"f")}async verify_(){await(0,I.verifyDb_)((()=>this.db))}assertHeartbeat_(){const e=(0,C.randomChars)(64),t=Date.now();try{this.db.prepare("INSERT INTO heartbeat (name, createdAt, updatedAt) VALUES (?,?,?)").run(e,t,t);const i=this.db.prepare("SELECT * FROM heartbeat WHERE name = ?").get(e);if(i?.name!==e)throw new Error("heartbeat INSERT/SELECT roundtrip failed")}finally{try{this.db.prepare("DELETE FROM heartbeat WHERE name = ?").run(e)}catch{}}}async closeDb(){try{this.logger.info("closing db",l(this,n,"f")),await(0,D.retryOnReject_)((()=>{!0===l(this,n,"f")?.open&&l(this,n,"f")?.close()}),{timeoutMs:E.Settings.dbBusyTimeoutMs.valueOrDefault,maxRetries:5,errorIsRetriable:M.isSqliteBusyError,retryDelay:k.secondMs})}catch(e){this.logger.warn("closeDb(): .close() failed",e)}u(this,n,void 0,"f")}async vacuum(){try{await(0,w.handleDbRetries_)("db.checkpoint",(()=>this.db),(()=>(0,I.checkpoint_)({db:this.db})),this.onRetry),await(0,w.handleDbRetries_)("db.optimize",(()=>this.db),(()=>this.db.pragma("OPTIMIZE")),this.onRetry),await(0,w.handleDbRetries_)("db.vacuum",(()=>this.db),(()=>this.db.exec("VACUUM")),this.onRetry)}catch(e){throw this.logger.warn("vacuum(): failed",{error:e}),e}}async repair_(){this.logger.warn("repair_(): Attempting restore of "+this.dbFile),await this.closeDb(),await(0,I.repairDbFile_)(this.dbFile),this.logger.info("repair_(): Database restoration was successful!")}localBackupDir(){return(0,P.dbBackupDir)(this.dbFile)}async backup_(e,t){const i=t??await(0,S.isDirSQLiteReadWrite)(e),s=(i?e:this.localBackupDir().join((0,g.filestamp)())).join(this.dbFile.base);return await l(this,r,"m",o).call(this,s),i||await(0,y.dbBackupCold_)(s,e),e.join(this.dbFile.base)}}t.Db=L,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(...e){const t=[];for(const i of e)try{t.push(this.db.prepare("SELECT MAX(updatedAt) FROM "+(0,b.dbValueToEscapedString)(i)).pluck().get())}catch(e){this.logger.warn(`#maxUpdatedAt(): failed to get max updatedAt for ${i}`,e)}return(0,c.max)(t)},o=async function(e){await e.parent().mkdirp_(),await this.db.backup(e.nativePath,{progress:e=>(this.logger.log((0,p.ending)()?"info":"debug","backup() "+(0,x.fmtPct)(100-e.remainingPages/e.totalPages*100)+" completed"),(0,p.ending)()?1e3:100)})}},25470:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.DbModelJanitor=t.Contested=t.NoOp=t.NoWriteLock=void 0;const c=i(66364),d=i(50213),h=i(23560),f=i(78406),m=i(25764),p=i(38836),g=i(99331),y=i(56038),w=i(12959),v=i(55332),b=i(76187),S=i(73209),P=i(28874),M=i(42659),_=i(75240),T=i(95700),E=i(22526),D=i(45648),k=5*M.minuteMs;t.NoWriteLock=Symbol("NoWriteLock"),t.NoOp=Symbol("NoOp"),t.Contested=Symbol("Contested");class x extends f.EndableInterval{static for(e){return new x(e.db,e.fslock,e.libraryDbFile,e.libraryDbBackupDir)}constructor(e,t,i,o){super({name:"db.DbModelJanitor",callback:()=>l(this,r,"m",n).call(this),intervalMs:P.Settings.dbBackupIntervalMs.valueOrDefault,initialDelayMs:M.minuteMs,rank:m.EndableRanks.db,endTimeoutMs:5*M.minuteMs,onEnd:()=>l(this,r,"m",a).call(this)}),r.add(this),this.db=e,this.dbFslock=t,this.libraryDbFile=i,this.libraryDbBackupDir=o,this.logger=(0,d.mkLogger)(this.name),this.fslockRelease=new p.EndableWrapper("db.DbModelJanitor.fslockRelease",(()=>this.dbFslock.release()),m.EndableRanks.postdb,k),s.set(this,0),this.dbFslock.tryAcquire_()}get useReplica(){return!this.db.dbFile.eql(this.libraryDbFile)}forceBackup_(){return this.backup_(!0)}async backup_(e=!1){return await(0,S.withLock_)({file:this.libraryDbBackupDir,timeoutMs:5*M.minuteMs,noopIfContested:!e},(async()=>{if(e&&u(this,s,0,"f"),(0,D.hasDbSetupErrors)())return this.logger.warn("backup_(): db has setup errors, skipping backup",{errors:(0,D.dbSetupErrors)()}),t.NoOp;if(!await this.dbFslock.tryAcquire_())return this.logger.info("backup_(): no-op: someone else has the fslock",{me:this.dbFslock.lockfile?.base,owner:(await this.dbFslock.selfAndSiblingNames_())[0]}),t.NoWriteLock;l(this,r,"m",o).call(this)||await(0,T.runMaintenanceTasks)();const i=this.db.maxUpdatedAt();return null!=i&&i>l(this,s,"f")?(0,y.time)("db.DbModelJanitor.backup_()",(async()=>{l(this,r,"m",o).call(this)?this.logger.info("backup_(): posthaste: skipping vacuum"):await this.db.vacuum(),u(this,s,i,"f");const e=this.libraryDbBackupDir.join((0,w.filestamp)()),t=await this.db.backup_(e,!this.useReplica);return this.useReplica&&await(0,v.dbBackupCold_)(t,this.libraryDbFile.parent()),this.logger.info("backup_(): backup successful",{destDbFile:t}),t})):(this.logger.info("backup_(): no update to the db since last backup",{ago:(0,_.fmtDuration)(Date.now()-l(this,s,"f"))}),t.NoOp)}))??t.Contested}}t.DbModelJanitor=x,s=new WeakMap,r=new WeakSet,n=async function(){try{await this.backup_()}catch(e){this.logger.error("backup_() failed",{error:e})}},a=async function(){const e=S.FsLock.for({file:this.libraryDbFile.sibling("db-teardown"),timeoutMs:k,endableRank:m.EndableRanks.postdb,noopIfContested:!1});(0,h.isDbManager)()&&await e.withLock_((async()=>{if(await this.dbFslock.iAmOnly_({vacuum:!0})){if(this.logger.info("#teardown(): I'm the last one in. Running backup and cleanup."),await this.backup_(),this.useReplica){const e=[(0,E.libraryDbInfoFromDbFile)(this.libraryDbFile),...(0,b.sqliteFiles)(this.db.dbFile)];this.logger.info("#teardown(): Removing replica artifacts",{victims:e});for(const t of e)await t.unlink()}}else this.logger.info("#teardown(): no-op: other processes are still running")})),await this.db.closeDb()},o=function(){return this.ended||(0,g.ending)()||(0,c.isSuspended)()}},22526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelSetup_=t.assertValidDbInfo_=t.libraryDbInfoFromDbFile=t.libraryDbInfoJsonFile=t.fsLockForDb=t.libraryDbObjects_=void 0;const r=i(19851),s=i(50213),n=i(92407),a=i(55332),o=i(44955),l=i(15056),u=i(87290),c=i(98314),d=i(38835),h=i(73209),f=i(95696),m=i(17217),p=i(18454),g=i(57902),y=i(28874),w=i(2858),v=i(40958),b=i(22573),S=i(42659),P=i(94448),M=i(98348),_=i(45648),T=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbModelSetup")));function E(e=y.Settings.libraryDir.valueOrDefault){if((0,b.blank)(e))throw new Error("Library directory is not set"+d.NoLibraryErrorFlag);const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dataDir"+d.NoLibraryErrorFlag);if(!(0,w._libraryHasSettings)(e))throw new Error(`Library at ${e} does not have a settings file`+d.NoLibraryErrorFlag);const i=(0,l.pathToDb)(t,"models");return{dataDir:t,libraryDbFile:i,libraryDbBackupDir:(0,l.dbBackupDir)(i)}}function D(e){return h.FsLock.for({file:e,timeoutMs:0,noopIfContested:!1})}function k(e=y.Settings.libraryDir.valueOrDefault){const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dir"+d.NoLibraryErrorFlag);return x((0,l.pathToDb)(t,"models"))}function x(e){return e.sibling("db-info.json")}async function F(e=k(),t){try{const i=await e.readJson(g.LogLevels.info);if(null==i)throw new Error(e+" is missing"+d.DbSetupErrorFlag);if(null!=t&&!await t.equalsUri_(i.uri))throw new Error(e+" expects the live db to be "+i.uri+" but the live db is "+await t.uri_()+d.DbSetupErrorFlag);const r=await f.PosixFile.forUri(i.uri);if(null==r)throw new Error(e+" expects the live db to be "+i.uri+" but that URI cannot be resolved."+d.DbSetupErrorFlag);try{await(0,o.assertDirSQLiteReadWrite_)(r.parent())}catch(t){throw T().error("assertValidDbInfo_(): failed to assert live dir was r/w",{error:t,liveDbFile:r,infoJsonFile:e}),new Error("Failed to validate that the live database directory, "+r.dir+", was read-writable by SQLite: "+(0,c.errorToS)(t)+d.DbSetupErrorFlag)}return{liveDbFile:r}}catch(e){throw(0,_.addDbSetupError)(e),e}}t.libraryDbObjects_=E,t.fsLockForDb=D,t.libraryDbInfoJsonFile=k,t.libraryDbInfoFromDbFile=x,t.assertValidDbInfo_=F,t.dbModelSetup_=async function(e=y.Settings.libraryDir.valueOrDefault){const{libraryDbFile:t,fslock:i,libraryDbBackupDir:r}=await async function(e=y.Settings.libraryDir.valueOrDefault){const t=E(e);return{...t,fslock:D(t.libraryDbFile)}}((0,b.mapNotBlank)(e,m.toNativePath_));let s,o;await i.tryAcquire_();const u=x(t);try{if(await(0,h.withLock_)({file:u,timeoutMs:5*S.minuteMs},(async()=>{const i=await u.readJson(g.LogLevels.info);if(s=i?.useReplica,null!=i){const{liveDbFile:e}=await F(u,t);o=new M.Db(l.Schemas.models,e)}if(null==s||null==o){const i=await(0,n.getLiveDbDir_)(e),r=await i.db.uri_();s=i.useReplica,s&&await p.HealthCheck.traceLater_("Setting up local replica database",(0,a.dbBackupCold_)(t,i.db.parent())).catch((e=>T().throw("Failed to set up replica db"+d.DbSetupErrorFlag,{src:t,dest:i.db,error:e}))),o=new M.Db(l.Schemas.models,i.db),await u.writeJson_({uri:r,useReplica:s})}})),null==o||null==s)return T().throw("Failed to open model db"+d.DbSetupErrorFlag+d.InternalErrorFlag,{libraryDir:e});if(await i.tryAcquire_()){const e=await o.migrate_();s&&(e.repaired||(0,v.isNotEmpty)(e.appliedMigrations))&&await o.backup_(t.parent(),!s),(0,_.clearDbSetupErrors)()}P.modelDb.set(o)}catch(e){throw T().error("Failed to set up model db",{error:e}),(0,_.addDbSetupError)(e),i.release(),e}return T().tap({msg:"dbModelSetup()",result:{db:o,useReplica:s,libraryDbFile:t,libraryDbBackupDir:r,fslock:i}})}},86859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DbRequest=void 0;const r=i(54557),s=i(50213),n=i(99331),a=i(56038),o=i(65753),l=i(66184),u=i(70417),c=i(28874),d=i(40958),h=i(22573),f=i(45599),m=i(96249),p=i(31586),g=i(51926),y=i(57038),w=i(21074),v=(0,f.defer)((()=>(0,s.mkLogger)("db.DbRequest")));t.DbRequest=class{constructor(e,t){this.db=e,this.tableName=t,this.cachedStatements=new r.FifoCache(256)}qb(){return(0,y.knex)()(this.tableName)}prep(e,t=!1){const i=(0,w.toSqlQuery)(e);try{const r=this.cachedStatements.getOrSet(this.db().db.__uid+":"+(!0===t?"pluck:":"")+i.sql,(()=>{const e=this.db().prepare(i.sql);return!0===t?e.pluck():e}));return r.database.open?{sq:i,stmt:r}:(this.cachedStatements.clear(),this.prep(e,t))}catch(e){return v().throw("prep() failed",{error:e,sqlQuery:i,retriable:!1})}}wrap({q:e,pluck:t,m:i}){try{const{sq:r,stmt:s}=this.prep(e,t);c.Settings.logSql.valueOrDefault&&v().log((0,l.defaultLogLevel)(),i+"(): "+(0,w.sqlQueryToS)(r));const n=s[i].bind(s);return null==r.bindings?n():n(r.bindings)}catch(t){if(!0===t.message?.includes("AdvisoryLock"))throw t;v().throw(t,{method:i,...(0,w.toSqlQuery)(e)})}}run(e){return this.wrap({q:e,m:"run"})}runScript(e,t=""){const i=(0,a.mkElapsed)("db.runScript()");for(const r of e){if((0,h.blank)(r)||r.trim().startsWith("--"))continue;this.run({sql:r});const e=(0,g.replaceAll)((0,g.ellipsize)(r,60),t,"");i.elapsed(e)}}mapRun(e){return e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return null==t.bindings?i.run():i.run(t.bindings)}))}runf(e){return this.wrap({q:e(this.qb()),m:"run"})}upsert(e){const t=(0,w.toSqlQuery)(e(this.qb()));return t.sql=t.sql.replace(/^(?:update|insert)\b/i,(e=>e.toUpperCase()+" OR REPLACE ")),this.wrap({q:t,m:"run"})}first(e){return this.wrap({q:e,m:"get"})}firstf(e){return this.wrap({q:e(this.qb()),m:"get"})}mapAll(e){return(0,m.flatten)(e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return i.all(t.bindings)})))}all(e){return this.wrap({q:e,m:"all"})}allf(e){return this.wrap({q:e(this.qb()),m:"all"})}async batched(e){let t,i=0;do{t=this.wrap({q:e.qb(this.qb(),t).limit((0,o.maxBatchPluckSize)()),m:"all"}),(0,d.isNotEmpty)(t)&&(await e.onResults(t),i+=t.length)}while((0,d.isNotEmpty)(t)&&!(0,n.ending)()&&(null==e.maxResults||e.maxResults>i));return{resultCount:i,done:null==t||t.length<(0,o.maxBatchPluckSize)()}}pluckFirst(e){return this.wrap({q:e,pluck:!0,m:"get"})}pluckFirstf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"get"})}pluckAll(e){return this.wrap({q:e,pluck:!0,m:"all"})}pluckAllf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"all"})}async pluckBatched(e){let t=0;const i=(0,u.min)([e.limit??(0,o.maxBatchPluckSize)(),e.maxResults]);if(i<=0||(0,p.lte0)(e.maxResults))return{done:!1,resultCount:t};let r;for(;null==e.maxResults||e.maxResults<=0||t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDbSetupErrorListener=t.hasDbSetupErrors=t.clearDbSetupErrors=t.addDbSetupError=t.dbSetupErrors=t._dbSetupErrors=void 0;const r=i(98314),s=i(22573),n=i(23541);t._dbSetupErrors=new Set;const a=[];t.dbSetupErrors=function(){return[...t._dbSetupErrors.values()]},t.addDbSetupError=function(e){if((0,n.isError)(e)||!(0,s.blank)(e)){t._dbSetupErrors.add((0,r.errorToS)(e));for(const e of a)e()}},t.clearDbSetupErrors=function({notifyListeners:e=!0}={}){if(t._dbSetupErrors.clear(),e)for(const e of a)e()},t.hasDbSetupErrors=function(){return t._dbSetupErrors.size>0},t.addDbSetupErrorListener=function(e){a.push(e)}},36908:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dedupeTags_=t.mergeTags_=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(42231),o=i(40958),l=i(76790),u=i(23838),c=i(31586),d=i(54993),h=(0,r.lazy)((()=>(0,s.mkLogger)("db.DedupeTags")));function f(e,t){function i(t){return e.prepare(t).run()}(0,o.isEmpty)(t)&&h().warn("mergeTags(): empty tagIds",{tagIds:t}),h().info("mergeTags() starting",{tagIds:t});const r=e.prepare("SELECT id, _path, parentId FROM Tag WHERE id IN ("+t.join(",")+") ORDER BY ID").all(),s=(0,o.compactBlanks)(r.map((e=>(0,a.tagPathLeaf)(e._path))).sort()),n=r[0],l=r.slice(1),u=n?.id;if((0,o.isEmpty)(s)||(0,o.isEmpty)(l)||null==n||!(0,c.gt0)(u))return void h().warn("mergeTags(): missing winner",{winner:n,winnerId:u,leafs:s,losers:l});const d=(0,a.splitTagPath)(n._path).slice(0,-1),f=[...d,s[0]];n._path=(0,a.joinTagPath)(f),n.parentId=0===d.length?null:e.prepare("SELECT id from Tag where _path LIKE ?").pluck().get((0,a.joinTagPath)(d))??n.parentId,h().info("mergeTags()",{winner:n,losers:l,winnerTagPath:f,leafs:s});const m=l.map((e=>e.id)).join(",");i(`UPDATE OR IGNORE AssetTag SET tagId = ${u} WHERE tagId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`DELETE FROM AssetTag WHERE tagId in (${m})`),i(`DELETE FROM Tag WHERE id in (${m})`),e.prepare("UPDATE Tag SET parentId = :parentId, _path = :path WHERE id = :id").run({parentId:n.parentId,path:n._path,id:u});const p=e.prepare("SELECT id, _path FROM Tag WHERE id != :winnerId AND _path LIKE :like COLLATE NOCASE").all({winnerId:u,like:n._path+"%"});for(const t of p){const i=(0,a.splitTagPath)(t._path).slice(f.length),r=(0,a.joinTagPath)([...f,...i]);t._path!==r&&(h().info("mergeTags(): repairing tag path",{ea:t,newPath:r}),e.prepare("UPDATE OR IGNORE Tag SET _path = :path, updatedAt = :updatedAt WHERE id = :id").run({id:t.id,updatedAt:Date.now(),path:r}))}return h().tap({msg:"mergeTags()",level:"info",result:{winner:n,losers:r}})}t.mergeTags_=f,t.dedupeTags_=function(e){const t=new u.MultiMap;for(const{id:i,_path:r}of e.prepare("SELECT id, _path FROM Tag ORDER BY id").iterate())t.add((0,n.stripSuffix)((0,d.toS)(r).trim(),a.TagSep).toLowerCase().normalize(),i);const i=(0,l.sortBy)(t.entriesArray().filter((([,e])=>e.length>1)),(([e])=>[-(0,n.countChars)(e,a.TagSep),-e.length,e]));for(const[,t]of i)f(e,t)}},57038:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstMigratedAt=t.knex=void 0;const s=r(i(31832)),n=i(19851),a=i(56519),o=i(55835),l=i(68708);t.knex=(0,n.lazy)((()=>(0,s.default)({client:"better-sqlite3",useNullAsDefault:!0}))),t.firstMigratedAt=async function(e){return(0,a.thenMap)(e("migrations").min("migration_time").first(),(e=>(0,o.map)((0,l.values)(e)[0],(e=>new Date(e)))))}},17036:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Migration=void 0;const o=i(77598),l=i(19851),u=i(50213),c=i(7282),d=i(37805),h=i(4867),f=i(51040),m=i(77740),p=i(38835),g=i(8769),y=i(57159),w=i(34102),v=i(73209),b=i(95696),S=i(43899),P=i(18454),M=i(40958),_=i(42659),T=i(41400),E=i(98553),D=i(55835),k=i(34666),x=i(32639),F=i(45648),C=i(94715),A=i(27134);t.Migration=class{constructor(e,t,i){r.add(this),this.schema=e,this.db=t,this.dbFile=i,this.fsMigrations_=(0,l.lazy)((()=>this.migrationsDir.children_((e=>e.isFile&&e.basename.endsWith(".sql"))).catch((e=>this.logger.throw("Failed to read migration directory, "+this.migrationsDir+p.InternalErrorFlag,{error:e}))))),this.ensureMigrationTable_=(0,l.lazy)((()=>{this.db.exec("\nCREATE TABLE IF NOT EXISTS migrations (\n id INTEGER NOT NULL PRIMARY KEY,\n name TEXT NOT NULL,\n migration_time INTEGER NOT NULL\n) STRICT\n")})),this.unknownMigrations_=(0,l.lazy)((()=>this.migrationsInDatabase_().filter((e=>!(0,k.lt)((0,C.migrationNameToDate)(e),d.gitDate))))),this.assertKnownMigrations_=(0,l.lazy)((()=>{const e=this.unknownMigrations_();if((0,M.isNotEmpty)(e)){const t=new y.WrappedError("Please upgrade PhotoStructure to a newer version to open this library: Unknown migrations: "+e.join(","));throw(0,g.onError)(t),t}})),this.logger=(0,u.mkLogger)("db.Migration("+(0,E.stringify)({schema:e,db:i.nativePath})+")"),this.migrationsDir=b.PosixFile.for(S.ProjectPath.Migrations()).join(this.schema)}async pendingMigrationFiles_(){const e=this.migrationsInDatabase_();return(await this.fsMigrations_()).filter((t=>!e.includes(t.name)))}migrationsInDatabase_(){return this.ensureMigrationTable_(),this.db.prepare("SELECT name from migrations").pluck().all()}async apply_(e){return(0,v.withLock_)({file:this.dbFile.sibling("migrate"),timeoutMs:2*_.minuteMs},(()=>a(this,r,"m",s).call(this,e)))}async applyMigration_(e,t){try{const i=Date.now(),s=C.Migrations[e.name.replace(/^[\d_-]+/,"")],o=(0,x.isFunction)(s);return o?await s.bind(C.Migrations)(this.db):await a(this,r,"m",n).call(this,e),this.logger.debug("applyMigration() completed",{elapsedMs:Date.now()-i,codeMigration:o,migration:e.baseWithParent}),t?.run(e.name,Date.now())}finally{(0,w.ee)().emit("clearDbCache")}}},r=new WeakSet,s=async function(e){try{this.ensureMigrationTable_(),(0,c.isProd)()&&this.assertKnownMigrations_();const t=[],i=this.db.prepare("INSERT INTO migrations (name, migration_time) VALUES (?, ?)");for(const r of await this.pendingMigrationFiles_())await P.HealthCheck.traceLater_("Upgrading database ("+r.name+")",(async()=>{if((0,m.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");(0,m.getDevEnvFlag)("PS_SLOMO")&&await(0,T.delay)((0,o.randomInt)(_.secondMs,3*_.secondMs)),await(0,D.map)(e,(e=>e(r))),await(0,h.thenOrTimeoutError)({p:this.applyMigration_(r,i),timeoutMs:_.minuteMs}).catch((e=>{throw new y.WrappedError("Migration "+r.name+" timed out.",{cause:e,fatal:!0,ignorable:!1})}))})),t.push(r.base);return this.logger.info("Migration complete",{appliedMigrations:t}),t}catch(e){const t=new y.WrappedError("Migrating the "+this.schema+" db failed",{cause:e});throw(0,F.addDbSetupError)(t),P.HealthCheck.addError(t),t}},n=async function(e){const t=e.name.includes("_nofk");try{const i=await e.readTextFile(),r=(0,f.splitBatchSql)(i);if((0,M.isEmpty)(r))this.logger.info("No-op migration: "+e);else{t&&this.db.pragma("foreign_keys = OFF");for(const t of r)try{this.db.exec(t)}catch(i){this.logger.throw("Failed to apply SQL",{stmt:t,migration:e.baseWithParent,cause:i,fatal:!0})}t&&(0,A.foreignKeyCheck_)(this.db)}}finally{t&&this.db.pragma("foreign_keys = ON")}}},94715:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Migrations=t.isoToPrecisionMs=t.fix_root_tags=t.tag_path_suffix=t.migrationNameToDate=t.plucklabmodeb6=t.lowercase_psnet_function=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(97352),o=i(68852),l=i(81168),u=i(85810),c=i(42022),d=i(1971),h=i(79842),f=i(89724),m=i(17415),p=i(88600),g=i(20014),y=i(42231),w=i(87001),v=i(40958),b=i(55835),S=i(31586),P=i(97790),M=i(89937),_=i(54993),T=i(7656),E=i(36908),D=(0,s.lazy)((()=>(0,n.mkLogger)("db.Migrations"))),k=new RegExp(`^(${(0,o.escapeRegExp)(M.PS_NETWORK_FILESYSTEM_SCHEME)}://.*?/)(.*)$`);function x(e,t){return(0,a.mapGt0)(e,(()=>(0,b.map)(function(e,t=c.ModeBits){return(0,g.splitBits)(e,t).map((e=>(0,u.unlabhash)(e,t)))}(e,6)[t],(e=>(0,u.toLabhash)(e,c.ModeBits)))))}function F(e){return e.endsWith(y.TagSep)?e:e+y.TagSep}function C(e){for(const t of e.prepare("SELECT id, parentId, _path FROM Tag WHERE id = parentId").iterate())D().warn("fix_root_tags(): broken tag",{broken:t}),(0,l.countChars)(t._path,y.TagSep)<2&&e.prepare("UPDATE Tag set parentId = null where id = ?").run(t.id)}function A(e){return(0,b.map)((0,h.isoToDated)(e),h.datedToPrecisionMs)??-1}t.lowercase_psnet_function=e=>(0,P.opt)(e).filter(l.isString).flatMap((e=>k.exec(e))).map((e=>e[1].toLowerCase()+e[2])).getOrElse((()=>e)),t.plucklabmodeb6=x,t.migrationNameToDate=function(e){const[t,i,r]=[e.slice(0,4),e.slice(4,6),e.slice(6,8)].map((e=>(0,S.toInt)(e)));return(0,p.validYMD)(t,i,r)?new Date(t,i-1,r):void 0},t.tag_path_suffix=F,t.fix_root_tags=C,t.isoToPrecisionMs=A,t.Migrations={fix_root_tags:C,lowercase_psnet_hostname:e=>{e.function("lowercase_psnet_hostname",{deterministic:!0},t.lowercase_psnet_function),e.exec("DROP INDEX IF EXISTS assetfile_uri_udx"),e.exec("UPDATE AssetFile SET uri = lowercase_psnet_hostname(uri)"),e.exec("CREATE UNIQUE INDEX assetfile_uri_udx ON AssetFile(uri)")},numeric_captured_at:e=>{e.function("isoToLocal",{deterministic:!0},f.isoToLocal),e.function("isoToOffsetMinutes",{deterministic:!0},m.isoToOffsetMinutes),e.function("isoToPrecisionMs",{deterministic:!0},A),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtLocal bigint"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtOffset integer"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtPrecisionMs integer"),e.exec("UPDATE AssetFile SET capturedAtLocal = isoToLocal(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtOffset = isoToOffsetMinutes(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtPrecisionMs = isoToPrecisionMs(capturedAtISO)"),e.exec("DROP INDEX asset_captured_at_geohash_idx"),e.exec("DROP INDEX assetfile_exifuid_idx"),e.exec("CREATE INDEX assetfile_capturedAtLocal_idx ON AssetFile(capturedAtLocal)")},spread_modes:e=>{e.function("plucklabmodeb6",{deterministic:!0},x),(0,S.times)(d.ModeCount,(t=>e.exec(`ALTER TABLE AssetFile ADD COLUMN mode${t} integer`))),e.exec("UPDATE AssetFile SET "+(0,S.times)(d.ModeCount,(e=>`mode${e} = plucklabmodeb6(mode8b6, ${e})`)).join(", "))},normalize_asset_file_uris:e=>{e.function("normalizeURI",{deterministic:!0},w.normalizeURI);const t=e.prepare("SELECT normalizeURI(uri) AS nuri, count(*) AS cnt, GROUP_CONCAT(id) AS ids FROM AssetFile GROUP BY nuri HAVING cnt > 1").all(),i=[];for(const s of t){const t=(0,_.toS)(s.ids).split(","),n=e.prepare("SELECT id, shown, version, updatedAt FROM AssetFile WHERE id in ("+t.join(",")+")").all(),a=(0,r.greatestBy)(n,(e=>[e.shown,e.version,e.updatedAt])),o=n.filter((e=>e.id!==a?.id));i.push(...o.map((e=>e.id)))}for(const t of(0,r.batches)(i,256))e.exec("DELETE FROM AssetFile WHERE id in ("+t.join(",")+")");e.exec("UPDATE AssetFile SET uri = normalizeURI(uri)")},dedupe_tag_paths:E.dedupeTags_,suffix_tag_paths:e=>{e.function("tag_path_suffix",{deterministic:!0},F),(0,E.dedupeTags_)(e),e.exec("UPDATE Tag SET _path = tag_path_suffix(_path)")},normalize_tag_paths:e=>{const t=e.prepare("SELECT id, _path FROM Tag WHERE _path LIKE '%' || char(31) || char(31) || '%'").all();D().info("normalize_tag_paths():",{badTags:t});for(const i of t){const t=(0,y.normalizeTagPath)(i._path);(0,E.mergeTags_)(e,(0,v.compact)([i.id,...e.prepare("SELECT id FROM Tag WHERE _path LIKE ?").pluck().all(t)]))}},drop_tc_tables:e=>{const t=/^(ct|taf|tag_counts)_[a-z\d]{6}$/i,i=e.prepare("SELECT name FROM sqlite_master WHERE type='table'").pluck().all(),r=i.filter((e=>null!=t.exec(e)));D().info("drop_tc_tables()",{tables:i,victims:r});for(const t of r)e.exec("DROP TABLE "+t)},rebuild_rotated_heic:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype = 'image/heif' AND rotation <> 0")},rebuild_videos:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%'"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where mimetype LIKE 'video/%')")},copy_asset_duration:e=>{e.exec("CREATE INDEX tmp_af_idx ON AssetFile (assetId, durationMs)"),e.exec("UPDATE Asset SET durationMs = (SELECT durationMs FROM AssetFile WHERE assetId = Asset.id AND durationMs IS NOT NULL LIMIT 1) WHERE durationMs IS NULL"),e.exec("DROP INDEX tmp_af_idx"),e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%' and durationMs IS NULL"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where version = 0)")},rebuild_tag_asset_counts:T.rebuildTagAssetCounts,create_tag_fts:e=>{e.exec("DROP TABLE IF EXISTS tag_fts"),e.exec("CREATE VIRTUAL TABLE tag_fts USING fts5 (root, path, content='', contentless_delete=1, tokenize=\"unicode61\");")}}},27134:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.repairDbFile_=t.checkpoint_=t.verifyDbFile_=t.verifyDb_=t.foreignKeyCheck_=t.integrityCheck_=t.quickCheck_=t.backupDbFile_=t.sqlite=void 0;const r=i(14121),s=i(19851),n=i(50213),a=i(84777),o=i(12959),l=i(5531),u=i(91872),c=i(99315),d=i(76187),h=i(51040),f=i(38835),m=i(57159),p=i(29882),g=i(95696),y=i(89966),w=i(38156),v=i(28874),b=i(63870),S=i(5233),P=i(42659),M=i(41400),_=i(50357),T=i(98553),E=i(56409),D=i(31586),k=i(20214),x=i(51926),F=i(12168),C=i(59455),A=i(54993),I=i(94448),O=i(9508),L=(0,s.lazy)((()=>(0,n.mkLogger)("db.SQLite")));function R({db:e,pragma:t,okResult:i}){L().debug("pragmaOrThrow_()",{db:N(e),db_open:e?.open,pragma:t,okResult:i});const r=(0,x.isString)(i)?e.pragma(t,{simple:!0}):e.pragma(t);(0,_.eql)(r,i)||L().throw(`${t} failed for ${N(e)}: ${(0,T.stringify)({result:r})}`)}function N(e){return(0,p.ellipsizePath)({p:e.name,maxLength:80})}function B(e){return R({db:e,pragma:"quick_check",okResult:"ok"})}function j(e){return R({db:e,pragma:"integrity_check",okResult:"ok"})}function z(e){const t=(0,C.toA)(e.pragma("foreign_key_check"));t.length>v.Settings.dbInvalidFKThreshold.valueOrDefault&&L().throw("foreignKeyCheck_(): too many invalid foreign keys to repair",{dbInvalidForeignKeyThreshold:v.Settings.dbInvalidFKThreshold.valueOrDefault,badRowsCount:t.length,badRows:t});for(const i of t)L().warn("repairDbFile_(): deleting row with invalid foreign key",{row:i}),e.prepare(`DELETE FROM ${(0,h.dbValueToEscapedString)(i.table)} WHERE rowid = ?`).run(i.rowid)}async function V(e){await(0,u.handleDbRetries_)("db.quickCheck",e,B),await(0,M.delay)(1),await(0,u.handleDbRetries_)("db.integrityCheck",e,j),await(0,M.delay)(1),await(0,u.handleDbRetries_)("db.foreignKeyCheck",e,z)}function W(e){return(0,O.withDbSync)(e,V,(0,b.commandTimeoutMs)())}t.sqlite=async function({dbFile:e,sql:t,args:i}){const s=await(0,y.sqliteNativePath_)(),n=await(0,r.thenElapsed)((0,a.stdout_)(s,[...(0,C.toA)(i),e.nativePath,t],{timeoutMs:1*P.minuteMs}));return L().debug("sqlite("+t+") on "+e+" in "+n.elapsedMs+"ms",n.result),n.result},t.backupDbFile_=function(e,t){return(0,S.retryOnReject_)((()=>async function(e,t){try{await t.parent().mkdirp_(),await t.unlink("trace");const i=await e.size();if(!(0,D.gt0)(i))return void L().warn("backupDbFile_(): "+e+" is empty");await((0,I.modelDb)()?.end()),await(0,O.withDb)(e,(async e=>e.exec("VACUUM INTO "+(0,h.dbValueToEscapedString)(t.nativePath))),2*P.minuteMs),L().info("backupDbFile_(): Finished "+e+" -> "+t)}catch(i){throw new m.WrappedError(`Could not back up db ${e} -> ${t}`,{cause:i})}}(e,t)),{maxRetries:3,retryDelay:P.secondMs,timeoutMs:P.minuteMs,errorIsRetriable:()=>!0})},t.quickCheck_=B,t.integrityCheck_=j,t.foreignKeyCheck_=z,t.verifyDb_=V,t.verifyDbFile_=W,t.checkpoint_=async function e({db:t,retries:i=3,checkpointType:r=v.Settings.dbWalCheckpointType.valueOrDefault}){if((r=l.CheckpointTypes.getCI(r)??l.CheckpointTypes.AUTO)===l.CheckpointTypes.AUTO)return;const s="wal_checkpoint("+r+")",[n]=(0,C.toA)(t.pragma(s));return L().info("checkpoint()",{pragma:s,result:n}),(0,D.gt0)(n?.busy)&&i>0?(await(0,M.delay)(250),e({db:t,retries:i-1})):n};const U=/no such table: sqlite_\w+/i;t.repairDbFile_=async function(e,t=c.RepairModes.dump){const i=g.PosixFile.for(e),r=(await i.parent().join("db-"+t,(0,o.filestamp)()).mkdirp_()).join(i.base);L().info(`repairDbFile_(${i} -> ${r})`);try{const e=await(0,y.sqliteNativePath_)(),s=4*Math.min(20*F.MiB,await(0,d.sqliteSizeBytes)(i)),n=new w.PushProgressObserver({path:(0,A.toS)(i),op:"Repairing your database"},s),o=new E.Latch,l=(0,a.execFile)(e,[i.nativePath,"."+t],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});l.stdout.on("error",(e=>{const i=(0,A.toS)(e);U.test(i)?L().info("repairDbFile_(): ignoring stderr",{err:i}):o.reject(new Error("sqlite "+t+" failed: "+i))}));const u=(0,a.execFile)(e,[r.nativePath],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});u.on("exit",(()=>o.resolve())),l.stdout.on("end",(()=>{u.stdin.end(null)})),l.stdout.on("data",(e=>{const t=e.length;n.incrProgress(t),u.stdin.write(e)})),await o,L().info(`repairDbFile_(): recovered to ${r}.`),await W(r),L().info(`repairDbFile_(): ${r} is valid, finishing repair.`);const c=await(0,k.thenCollect)((0,d.sqliteFiles)(i),(e=>e.renameYMDHMS_({subdir:"needed-repair"})));return await(0,k.thenCollect)((0,d.sqliteFiles)(r),(e=>e.mv_(i.parent()))),c.find((e=>".db"===e.ext||e.ext.startsWith(".sqlite")))}catch(e){return L().throw("failed to recover DB via dump and restore. Please see https://photostructure.com/faq/restore-db-from-backup/ "+f.FatalErrorFlag,{error:e})}}},21074:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqlWhereInClause=t.isQueryBuilder=t.sqlQueryToS=t.toSqlQuery=t.isSqlQuery=void 0;const r=i(48884),s=i(68852),n=i(81168),a=i(12943),o=i(96249),l=i(98553),u=i(31586),c=i(68708),d=i(32639),h=i(54993);function f(e){return null!=e&&(0,n.isString)(e.sql)&&(null==e.bindings||(0,a.isDbValued)(e.bindings))}t.isSqlQuery=f,t.toSqlQuery=function(e){if(null==e)throw new Error("null sql");if(f(e))return e;if((0,n.isString)(e))return{sql:e};if((0,d.isFunction)(e.toSQL))return(0,c.omit)(e.toSQL(),"__knexQueryUid");throw new Error("not queryish: "+(0,l.stringify)(e))},t.sqlQueryToS=function(e){if(null==e.bindings)return e.sql;if(Array.isArray(e.bindings))return(0,o.flatten)((0,r.zip)(e.sql.split("?"),e.bindings.map((e=>(0,l.stringify)(e))))).join("");{let t=e.sql;for(const i of(0,c.keys)(e.bindings))t=t.replace(new RegExp("[@:$]"+(0,s.escapeRegExp)(i),"gi"),(0,h.toS)(e.bindings[i]));return t}},t.isQueryBuilder=function(e){return(0,d.isFunction)(e?.where)&&(0,d.isFunction)(e?.limit)},t.sqlWhereInClause=function(e){return"("+(0,u.times)(e,(()=>"?")).join(",")+")"}},35052:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localTableInfo=t.parseTableInfo=void 0;const r=i(22573),s=i(23838);function n(e){const t=new s.MultiMap;for(const i of e)i.tableName.includes("fts")||i.tableName.includes("sqlite_")||(0,r.blank)(i.name)||(0,r.blank)(i.type)||t.add(i.tableName,{name:i.name,type:i.type.toUpperCase().trim().replace(/\s+/g,""),notnull:1===i.notnull,pk:1===i.pk});return t.entriesArray().map((([e,t])=>({tableName:e,columns:t})))}t.parseTableInfo=n,t.localTableInfo=function(e){return n(e.prepare("SELECT \nm.tbl_name as tableName,\np.*\nFROM sqlite_master AS m\nJOIN pragma_table_info(m.name) AS p\nORDER BY m.tbl_name, p.cid").all())}},9508:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withDb=t.withDbSync=void 0;const r=i(80632),s=i(28874),n=i(30301),a=i(54993);t.withDbSync=function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const o=(0,n.lazy)((()=>(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i})));try{return t((function(){const e=o();return e.open?e:o.refresh()}))}finally{o.prior()?.close()}},t.withDb=async function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const n=(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i});try{return await t(n)}finally{n.close()}}},43487:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Asset=void 0;const u=i(48884),c=i(19851),d=i(50213),h=i(88158),f=i(45393),m=i(56519),p=i(89724),g=i(38835),y=i(74128),w=i(79847),v=i(28874),b=i(47783),S=i(38010),P=i(40958),M=i(76790),_=i(75761),T=i(38639),E=i(11371),D=i(98553),k=i(55835),x=i(31586),F=i(20214),C=i(59455),A=i(64526),I=i(4407),O=i(54017),L=i(48722),R=i(37094),N=i(45295),B=i(39604),j=i(48723),z=i(41507),V=i(72761),W={"Asset.shown":1,"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null};class U extends V.TimestampedModel{constructor(){super(...arguments),r.add(this),this.attrs={},this.assetIdish=(0,c.lazy)((()=>({assetId:this.id,v:this.updateCount,capturedAtLocal:this.capturedAtLocal}))),this.mergedTags=(0,c.lazy)((async()=>{const e=[];for(const t of this.getAssetFiles()){const i=await t.posixFile(),r=await(0,b.readTags)(i),s=await(i?.mtimeMs());null!=i&&null!=r&&null!=s&&e.push({...r,SourceFile:i.nativePath,sourceModifiedTime:s,sourceIsPrimary:(0,T.isTrue)(t.shown)})}const t=R.AssetRevision.ops().allf((e=>e.where({assetId:this.id}))),i=new S.MergedTags("Asset:"+this.id);return i.addTag(...e,...this.assetFiles),i.addRevision(...t),i}))}static shownUnhidden(e){return null==e?s.query().where(W):e.andWhere(W)}static findUnhiddenById(e){return(0,x.gt0)(e)?s.ops().firstf((t=>s.shownUnhidden(t.where({id:e})))):void 0}static shownRemovable(e,t){return(t??s.query()).whereNotNull(e).andWhere({"Asset.shown":1})}static shownCount(){return s.ops().count(s.shownUnhidden().countDistinct("Asset.id"))}static deletePreviews(e){return A.Library.instance().previews().ap(e).deleteAll()}static async remove({assetId:e,blocklistShas:t,unlinkAssetFiles:i}){const r=(0,d.mkLogger)("Asset("+e+").remove()"),n=s.ops().findById(e);if(null==n)return void r.warn("asset not found");const a=n.isActive(),o=n.tagIds();r.info("starting",{unlinkAssetFiles:i});const l=n.getAssetFiles({refresh:!0});if(t){(0,B.upsertToShaBlockslist)(...l.map((e=>e.sha)));for(const e of l)(0,y.syncReport)().onProgress({from:"Asset.remove",path:await e.getNativePath()??e.uri,state:"blocklisted",details:"sha blocklisted (files with the same sha will not be imported)"})}N.AssetTag.dbl.runf((t=>t.delete().where({assetId:e}))),O.AssetFile.dbl.runf((t=>t.delete().where({assetId:e}))),R.AssetRevision.dbl.runf((t=>t.delete().where({assetId:e}))),s.dbl.runf((t=>t.delete().where({id:e}))),a&&j.Tag.deltaAssetCountAndAncestors(o,-1);try{await s.deletePreviews(e)}catch(e){r.error("Failed to delete previews",{error:e})}return{deletedMeta:i?await(0,w.trashOrUnlinkFileUris_)(l):[],assetFileMeta:l}}static nextOutdated(e=h.identity){return this.ops().findOne(e(l(this,s,"m",n).call(this)))}static nextOutdateds(e){return this.ops().all(e(l(this,s,"m",n).call(this)))}static outdatedCount(e=h.identity){return this.dbl.pluckFirst(e(l(this,s,"m",n).call(this)).count())}static findFirstByFile(e){return this.ops().findOne(e(this.query().select("Asset.*").join("AssetFile","AssetFile.assetId","Asset.id")))}static unshownAssetIds(){return this.dbl.pluckAll("\n SELECT DISTINCT af1.assetId\n FROM AssetFile af1\n LEFT JOIN (SELECT DISTINCT assetId FROM AssetFile WHERE shown = 1) AS af2 \n ON af1.assetId = af2.assetId\n WHERE af2.assetId IS NULL")}static archive(e){null!=s.ops().findById(e)&&(N.AssetTag.dbl.runf((t=>t.where({assetId:e}).delete())),O.AssetFile.dbl.runf((t=>t.where({assetId:e}).delete())),s.dbl.runf((t=>t.where({id:e}).delete())))}markUnshownAndUpsert(){this.shown=!1,this.version=f.AssetVersion,this.upsert()}markShownAndUpsert_(e){const t=this.getShown()?.id;if(null!=e){const t=e.shown;this.setShown_(e,{skipUpsert:!0}),!0!==t&&e.upsert()}this.shown=!0,this.version=f.AssetVersion,t!==this.getShown()?.id&&(this.updateCount=(this.updateCount??0)+1),this.upsert()}async updateFromFiles(){const e=await this.mergedTags();(0,k.map)(e.get("rating"),(e=>{this.logger().info("updateFromFiles()",{rating:e}),this.rating=e.value}))}isActive(){return(0,x.gt0)(this.id)&&!0===this.shown&&null==this.excludedAt&&null==this.deletedAt&&(null==this.rating||(0,x.gte)(this.rating,v.Settings.rejectRatingsLessThan.valueOrDefault))}toAssetId(){return(0,L.toAssetId)(this)}renderCaption(e){return(0,k.map)(this.capturedAtLocal,(t=>"Taken "+(0,p.fmtLocalDateShort)(t,e)))}async whenApiTag(){const e=(0,I.dateTag)((0,p.localToDateObject)(this.capturedAtLocal));return null==e?void 0:j.Tag.findOrCreate(e).toApiTag()}findAssetFileByUri(e){return this.getAssetFiles()?.find((t=>t.uri===e))}addAssetFile(e){(0,P.filterInPlace)(e.asset?.assetFiles??[],(t=>!(t.id===e.id||t.uri===e.uri))),e.assetId=this.id,e.asset=this,e.shown=!1,this.getAssetFiles().push(e),this.clear(),this.capturedAtLocal??(this.capturedAtLocal=e.capturedAtLocal),this.rating??(this.rating=e.rating),this.durationMs??(this.durationMs=e.durationMs)}async assetFileForFile_(e,t){const i=await e.uri();if(null==i)return this.logger().throw("assetFileForFile_(): null uri",{f:e});const r=this.getAssetFiles().find((e=>e.uri===i));if(null!=r)return r;const s=new O.AssetFile;return this.addAssetFile(s),!0!==t?.skipUpsert?await s.upsertIfNeeded_(e):await s.setFile_(e),s}static getTags(e){return j.Tag.ops().all(j.Tag.query().select("Tag.*").join("AssetTag","AssetTag.tagId","Tag.id").where("AssetTag.assetId",e).orderByRaw("COALESCE(Tag.ordinal, Tag._path)"))}tagIds(e){return!0===e?.refresh&&(this.tags=void 0),this.tags?.map((e=>e.id))??N.AssetTag.dbl.pluckAllf((e=>e.select("tagId").where({assetId:this.id})))}getTags(e){return!0===e?.refresh&&(this.tags=void 0),this.tags??(this.tags=s.getTags(this.id))}tagPaths(){return this.getTags().map((e=>e.path.join("/"))).sort()}setTagIds(e){const t=this.tagIds({refresh:!0});if((0,u.eqlUnordered)(t,e))return void this.logger().debug("setTagIds(): no-op, tagIds unchanged");const i=e.filter((e=>!t.includes(e))),r=t.filter((t=>!e.includes(t)));return this.applyTagIdDeltas({tagIdsToAdd:i,tagIdsToRemove:r})}applyTagPathDeltas(e){return this.applyTagIdDeltas({tagIdsToAdd:j.Tag.findOrCreateByPathN(e.add??[]).map((e=>e.id)),tagIdsToRemove:j.Tag.findByPathN(e.remove??[]).map((e=>e.id))})}applyTagIdDeltas(e={}){const t=this.tagIds({refresh:!0}),i=(0,P.uniq)((0,C.toA)(e.tagIdsToAdd).filter((e=>(0,x.gt0)(e)&&!t.includes(e)))),r=(0,P.uniq)((0,C.toA)(e.tagIdsToRemove).filter((e=>(0,x.gt0)(e)&&t.includes(e))));if((0,P.isEmpty)(i)&&(0,P.isEmpty)(r))return this.logger().info("applyTagIdDeltas(): no-op, no changes",{currentTagIds:t,...e}),t;this.isActive()&&j.Tag.deltaAssetCountAndAncestors(t,-1),(0,P.isEmpty)(i)||N.AssetTag.dbl.runf((e=>e.insert(i.map((e=>({assetId:this.id,tagId:e})))).onConflict(["assetId","tagId"]).ignore())),(0,P.isEmpty)(r)||N.AssetTag.dbl.runf((e=>e.whereIn("tagId",r).andWhere({assetId:this.id}).delete())),this.tags=void 0;const s=(0,P.uniq)([...t,...i]).filter((e=>!r.includes(e)));return this.isActive()&&j.Tag.deltaAssetCountAndAncestors(s,1),s}getStreams(e){if(null==this.streams){const t=this.getTags();this.logger().info("getStreams(): fetched tags "+t,{limit:e});const i=t.map((t=>t.getAssetStream(this,e)));this.streams=(0,z.coalesceStreams)((0,P.compact)(i));for(const e of this.streams)for(const t of e.tags)t.getAncestors()}return this.streams}getBeforeAfterId(){const e=s.dbl.all(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",this.capturedAtLocal).orderBy("assetId"));this.afterId=e.find((e=>e.assetId>this.id)),this.beforeId=e.reverse().find((e=>e.assetIde.path))}getAssetFiles({refresh:e=!1}={}){return null!=this.id&&(e&&(this.assetFiles=void 0),this.assetFiles??(this.assetFiles=(0,M.sortBy)(O.AssetFile.ops().findBy({assetId:this.id}),(e=>[!(0,T.isTrue)(e.shown),-e.mtime])))),this.assetFiles??[]}setShown_(e,t){e instanceof O.AssetFile&&(this.getAssetFiles(),this.assetFiles?.some(((t,i)=>{const r=t.id===e.id||t.uri===e.uri;return r&&(this.assetFiles[i]=e),r})));const i=e instanceof O.AssetFile?e.id:e;if(this.getShown()?.id===i)return void this.logger().debug("setShown_(): no-op, already set",{afId:i});this.logger().info("setShown_()",{assetId:this.id,assetFileId:i}),(0,x.gt0)(this.id)&&(0,x.gt0)(i)||this.logger().throw("setShown_(): invalid IDs: "+(0,D.stringify)({assetId:this.id,assetFileId:i})+g.InternalErrorFlag);const r=Date.now();O.AssetFile.dbl.runf((e=>e.update({shown:0,updatedAt:r}).where({assetId:this.id}))).changes<=0&&this.logger().warn("setShown_(): all asset files were already unshown",{afId:i});const s=O.AssetFile.dbl.runf((e=>e.update({shown:1,updatedAt:r}).where({id:i})));1!==s.changes&&this.logger().throw("setShown_(): failed to update asset file: unexpected changed rows",{runResult:s});const n=this.assetFiles?.find((e=>e.id===i))??this.getAssetFiles({refresh:!0}).find((e=>e.id===i));if(null!=n){this.capturedAtLocal=n.capturedAtLocal,this.rating=n.rating,this.durationMs=n.durationMs;for(const e of this.assetFiles??[])e.shown=e.id===i;!0!==t?.skipUpsert&&this.upsert()}else this.logger().throw("setShown_(): failed to find shown asset file",{af:e})}getShown(e){return this.getAssetFiles(e)?.find((e=>(0,T.isTrue)(e.shown)))??this.getAssetFiles({refresh:!0})?.find((e=>(0,T.isTrue)(e.shown)))}getShownNativePath(){return this.getShown()?.getNativePath()}async getCapturedAts(){return(0,F.thenCollect)(this.getAssetFiles(),(e=>e.capturedAt()))}link(){return"/asset/"+this.id}sqAttrs(e=!0){return{...(0,_.assetSqImgAttrs)({assetId:this.assetIdish(),lazyLoad:e}),title:this.renderCaption(),...this.attrs}}async getImgAttrs(e,t,i=!1){if(null==this.imgAttrs&&(this.imgAttrs=new Map),null==this.imgAttrs.get(t)){const r=e.ap(this.id);await(0,m.thenMap)(r.readInfo(),(async e=>{e.mimetype.startsWith("video/")&&(this.poster=await r.posterLink())}));const s=!0;this.imgAttrs.set(t,await r.imgAttrs(t,s,i))}return this.imgAttrs.get(t)}async fitAttrs(e){return{...await this.getImgAttrs(e,E.ReducerNames.fit),...this.attrs}}isVideo(){if(null==this.assetFiles)throw new Error(".video called before getFiles()");return this.assetFiles.some((e=>e.isVideo))}videoAttrs(){return{controls:!0,autoplay:!0,poster:this.poster,...this.attrs}}async videoSources(){const e=[];let t;for(const i of this.getAssetFiles())e.some((e=>e.type===i.mimetype))||await i.exists()&&(t??(t=i),e.push({src:(0,_.assetVideoLink)({assetId:this.assetIdish(),assetFileId:i.id}),type:i.mimetype}));return e.some((e=>"video/mp4"===e.type))||null==t||e.unshift({src:(0,_.assetVideoLink)({assetId:this.assetIdish(),assetFileId:t.id})+".mp4",type:"video/mp4"}),e}async getPosixFiles(){return(0,F.thenCollect)(this.getAssetFiles(),(e=>e.posixFile_()))}async getExistingAssetFiles(){return(0,m.filterAsync)({name:"getExistingAssetFiles",arr:this.getAssetFiles(),f:e=>e.exists()})}async findOrCreateByFile(e){const t=await e.uri_();if(null==t)return;const i=(0,C.toA)(O.AssetFile.ops().findBy({assetId:this.id,uri:t}))[0];return(0,k.orElse)(i,(async()=>{const t=new O.AssetFile;return t.asset=this,t.assetId=this.id,await t.setFile_(e),t}))}partialSimpleAsset(){return{assetId:this.id,liked:(0,x.gte)(this.rating,v.Settings.likeRating.valueOrDefault),hidden:(0,T.isTrue)(this.hidden),excluded:null!=this.excludedAt,deleted:null!=this.deletedAt}}clear(){return this.imgAttrs=void 0,this.streams=void 0,this.tags=void 0,this.mergedTags.unset(),this}}t.Asset=U,s=U,r=new WeakSet,n=function(){return s.shownUnhidden().andWhere("version","<",f.AssetVersion)},a=function(){return this.beforeId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal","<",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId",order:"desc"}]))},o=function(){return this.afterId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",">",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"asc"},{column:"assetId",order:"asc"}]))},U.$tableName="Asset",U.$uniqueColumnName="id",U.$booleanFields=["shown","hidden"]},54017:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFile=void 0;const a=i(76760),o=i(19851),l=i(88158),u=i(45393),c=i(68852),d=i(81168),h=i(13991),f=i(54296),m=i(56519),p=i(76490),g=i(89724),y=i(98314),w=i(38835),v=i(8769),b=i(29882),S=i(95696),P=i(62105),M=i(74128),_=i(35721),T=i(69589),E=i(28874),D=i(28544),k=i(16170),x=i(45200),F=i(34238),C=i(87001),A=i(42233),I=i(21404),O=i(40958),L=i(17586),R=i(22573),N=i(38639),B=i(42659),j=i(33374),z=i(50357),V=i(75240),W=i(11371),U=i(55835),q=i(31586),H=i(68708),G=i(34666),$=i(89937),J=i(75020),K=i(64526),Z=i(41844),Y=i(43487),X=i(48723),Q=i(94710),ee=i(72761);class te extends ee.TimestampedModel{constructor(){super(...arguments),r.add(this),this.uriObj=(0,o.lazy)((()=>F.URI.parse(this.uri))),this.whyRejected=(0,o.lazy)((async()=>{const e=await this.posixFile_();return null==e?"invalid URI":!0===await this.isFileDeleted()?"deleted":(0,P.whyRejectFile)(e)})),this.posixFile_=(0,o.lazy)((async()=>S.PosixFile.for(await this.getNativePath())))}static outdatedQuery(e){let t=(e.q??this.query()).where("version","<",u.AssetFileVersion);return null!=e.maxUpdatedAt&&(t=t.andWhere("updatedAt","<",e.maxUpdatedAt)),t.andWhere((t=>{(0,O.isNotEmpty)(e.mountpoints)&&(t=t.whereIn("mountpoint",e.mountpoints));for(const i of e.uris)t=t.orWhereLike("uri",i+"%");return t})).orderBy("id")}static async nextOutdated(e=l.identity){return this.ops().findOne(e(this.outdatedQuery(await(0,A.currentVolumeRoots)())))}static async outdatedCount(e=l.identity){const t=this.outdatedQuery(await(0,A.currentVolumeRoots)());return this.dbl.pluckFirst(e(t.count("id")))}static shownAssetFileId(e){return this.dbl.pluckFirstf((t=>t.where({assetId:e,shown:1}).limit(1)))}static primaryForAssetId(e){return(0,q.gt0)(e)?te.ops().first(Y.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id").select("AssetFile.*").where({assetId:e,"AssetFile.shown":1})):void 0}static shownUnhidden({uriRoot:e}={}){let t=Y.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id");return(0,R.blank)(e)||(t=t.andWhereLike("AssetFile.uri",e+"%")),t}static recentAssetIdsByUriRoot(e,t,i=64){const r=Date.now()-t;return this.dbl.pluckAll(te.shownUnhidden({uriRoot:e}).distinct("AssetFile.assetId").where("AssetFile.updatedAt",">",r).orderBy("AssetFile.updatedAt","desc").limit(i))}static assetFileCountByMimeType(e){const t=te.shownUnhidden({uriRoot:e}).select("mimetype").countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"}).groupBy("mimetype").orderBy("mimetype");return this.dbl.all(t)}static assetFileCountWithMimeType(e,t){let i=te.shownUnhidden({uriRoot:t}).countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"});return i=e.endsWith("/")?i.andWhereLike("mimetype",e+"%"):i.andWhere("mimetype",e),this.dbl.first(i)}static assetFileCountByMimeTypeRoots(e=["image/","video/"],t){return e.map((e=>({mimeTypeRoot:e,assetFileCount:te.assetFileCountWithMimeType(e,t)?.assetFileCount??0})))}static children(e,t){const i=this.query().whereLike("uri",e+"/%").andWhere("uri","regexp",`^${(0,c.escapeRegExp)(e)}/[^/]+$}`);return this.ops().all(null==t?i:t(i))}static async sameShaInLibrary(e){if(null==this.db())return;const t=await e.sha(),i=await e.size();return null!=t&&null!=i?this.ops().allf((e=>e.where({sha:t,fileSize:i}).andWhereLike("uri",$.PS_LIBRARY_PROTOCOL+"%"))):void 0}static sameAssetFileInLibrary(e){return this.ops().allf((t=>t.where((0,H.pick)(e,"sha","fileSize")).andWhere((e=>e.whereLike("uri",$.PS_LIBRARY_PROTOCOL+"%"))).andWhere((t=>t.whereNot({id:e.id})))))}librarySiblings(){return this.getAsset()?.getAssetFiles().filter((e=>e.id!==this.id&&e.uri.startsWith($.PS_LIBRARY_PROTOCOL)))}capturedAtLocale(e){return(0,g.fmtLocalDateShort)(this.capturedAtLocal,e)}get dominantColors(){return p.DominantColor.fromModeData(this)}set dominantColors(e){(0,H.assignAllFields)(this,p.DominantColor.toModeData(e))}get posixPathFromGrandparent(){return(0,U.map)(this.uriObj()?.fsPath,b.posixPathFromGrandparent)}async whyNotMatchesFile(e){const t=n(this,r,"m",s).call(this);if(null!=t)return t;if(null==this.fileSize||null==this.mtime)return"missing file metadata";if(null!=e){const t=await e.uri();if(null==t)return"file has no URI";if(!await(0,C.uriIsEquivalent)(this.uri,t))return"file URI mismatch"}try{const t=e??await this.posixFile_();if(!await t.exists())return"file is missing";const i=await this.fileFields_(t);return null==i?!0===await(t?.isDeleted())?"file is deleted":"file is unreadable":i.fileSize!==this.fileSize?"file size changed since last sync":(0,q.closeTo)(i.mtime,this.mtime,2*B.secondMs)?void 0:"file mtime changed since last sync"}catch(e){return(0,y.errorToS)(e)}}async matchesFile(e){const t=await this.whyNotMatchesFile(e);return this.logger().tap({level:"info",msg:"matchesFile()",result:null==t,meta:{whyNot:t}})}async whyNotInSyncWithFile(e){return E.Settings.forceSync.valueOrDefault?E.Settings.forceSync.key+"=true":this.version!==u.AssetFileVersion?"AssetFileVersion: "+this.version+" != "+u.AssetFileVersion:this.whyNotMatchesFile(e)}async inSyncWithFile(e){const t=await this.whyNotInSyncWithFile(e);return this.logger().tap({msg:"inSyncWithFile()",result:null==t,meta:{whyNotInSync:t}})}async fileFields_(e){const t=e??await this.posixFile_();return null==t?void 0:await(0,h.assetFileStatFields_)(t)}isInLibrary(){return this.uri.startsWith($.PS_LIBRARY_PROTOCOL)}async isNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){const t=await this.whyNotNoop(e);return this.logger().tap({msg:"isNoop()",result:null==t,meta:{whyNotNoop:t}})}async whyNotNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){if(!0===e.forceSync)return"forceSync is true";if(!(0,q.gt0)(this.id))return"missing .id";if(!(0,q.gt0)(this.assetId))return"missing .assetId";{const e=await this.whyNotInSyncWithFile();if(null!=e)return e}if(await(0,Z.mayCopyAssetsToLibrary)()){const e=K.Library.instanceRequired_().assetFileRepository(),t=e.whyNotCopyFile(await this.posixFile_());if((0,R.blank)(t)&&null==await e.existingLibraryAssetFile(this))return"need to copy into library"}this.syncState=M.AssetFileSyncStates.noop}isVersionUpToDate(){return(0,G.gte)(this.version,u.AssetFileVersion)}async siblingCount(){return te.dbl.pluckFirstf((e=>e.count().where({assetId:this.assetId}).andWhereNot({id:this.id})))}async upsertIfNeeded_(e,t=(0,T.forceContextOrSetting)()){if(null!=e&&await this.setFile_(e),await this.matchesFile()&&(0,q.gt0)(this.id)&&!t.forceSync)return void(null==this.syncState&&(this.upsert(),this.syncState??(this.syncState=M.AssetFileSyncStates.noop)));const i=await this.isFileDeleted();if(!0===i)return this.syncState=M.AssetFileSyncStates.deleted,this.delete(),!0!==t.skipAssetRepair&&Q.Task.addOne("repairAsset",{assetId:this.assetId}),this;if(!1===i){const i=await this.updateFromFile_(e,t);return this.syncState??(this.syncState=null==i?M.AssetFileSyncStates.noop:M.AssetFileSyncStates.synced),this.upsert()}return this.syncState??(this.syncState=M.AssetFileSyncStates.skipped),this}async updateFileFields_(e){(0,H.assignFields)(this,await this.fileFields_(e))}async updateFromFile_(e,t=(0,T.forceContextOrSetting)()){const i=Date.now(),r=this.logger().addContext(".updateFromFile_()");if(null!=this.id&&!0!==t.forceSync&&await this.matchesFile(e))return void r.info("updateFromFile() no-op: up-to-date version and file stat matches since last update");if(null!=e&&await this.setFile_(e),null==e&&(e=await this.posixFile_()),null==e||await e.clear().notExists())return this.syncState=M.AssetFileSyncStates.deleted,void r.info("no-op, "+e+" is missing");const s=await(0,h.mkAssetFile_)(e);return s.uri!==this.uri&&((0,R.blank)(this.uri)||!0===this.uri?.startsWith("file:"))&&(this.logger().warn("updateFromFile() upgrading uri",{prior:this.uri,new:s.uri}),this.uri=s.uri),(0,H.assignAllFields)(this,(0,H.omit)(s,"uri")),this.version=u.AssetFileVersion,this.syncState=M.SyncFileStates.synced,r.elapsed("finished",Date.now()-i,this.toJSON()),this}async updateFromShaSibling_(e){const t=n(e,r,"m",s).call(e);if(null==t){if(await this.exists())return this.logger().debug("updateFromShaSibling",e),null!=e.sha&&await e.matchesFile()&&this.sha===e.sha?((0,H.assignFields)(this,(0,H.omit)(e,"id","posixFile","uriObj","shown","uri","mtime","fileSize","mountpoint","createdAt","updatedAt","updateCount",...te.$transientFields)),this.updateFileFields_()):this.updateFromFile_();this.logger().warn("updateFromShaSibling(): fail: file is missing")}else this.logger().warn("updateFromShaSibling() sibling is invalid",{whySiblingIsInvalid:t})}getAsset(){return this.asset??(this.asset=(0,q.gt0)(this.assetId)?Y.Asset.ops().findById(this.assetId):void 0)}exists(){return(0,x.uriExists)(this.uri,this.mountpoint)}async isFileDeleted(){return(await this.posixFile_())?.isDeletedUri(this.uri)}async accepted(){return(0,R.blank)(await this.whyRejected())}async setFile_(e){const t=await e.uri_();if(null==t)return this.logger().throw("setFile(): no URI for "+e);const i=await e.mountpoint();if(null!=this.uri&&!await(0,C.uriIsEquivalent)(t,this.uri))return this.logger().throw("setFile(): cannot reassign non-equivalent URI",{prior:this.uri,new:t,file:e.nativePath});const r=await e.uriObject_();return null==r?this.logger().throw("failed to create URI for "+e):(this.uri=t,this.uriObj.set(r),this.mountpoint=i?.nativePath,this.nativePath=e.nativePath,this.posixFile_.set(Promise.resolve(e)),this)}get basename(){return(0,R.blank)(this.uri)?void 0:decodeURIComponent(this.uri.slice(this.uri.lastIndexOf("/")+1))}posixFile(){return this.posixFile_().catch((()=>{}))}async getNativePath(){return(0,R.blank)(this.nativePath)&&(null==this.uri?this.logger().error(".getNativePath() called before .setFile_()"+w.InternalErrorFlag):this.nativePath=await(0,f.getAssetFileNativePath)(this)),this.nativePath}async capturedAt(){return null==this.nativePath&&await this.getNativePath(),D.CapturedAt.fromAssetFile(this)}async originalDownloadable({brief:e=!1}={}){const t=this.basename;if(!0===e)return null==t?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:`Download ${t}`,basename:t,description:"Download original"};const i=await this.posixFile_();return this.logger().tap({msg:"originalDownloadable()",level:"info",result:null==i||await i.isEmpty()?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:e?`Download ${i.base}`:(0,_.mkDownloadableTitle)(i,"original",this.isVideo?"video":"image",{width:this.width,height:this.height}),basename:i.base,description:"Download original",details:`(${(0,j.fmtDim)(this)} ${i.ext})`},meta:{posixFile:i}})}async downloadables(e,t){try{const i=await this.posixFile_();if(null==i)return[];const r=e.ap(this.assetId),s=[];if(await(0,m.thenMap)(this.originalDownloadable(),(e=>s.push(e))),this.isVideo)return s;if(!(0,N.isTrue)(this.shown)&&this.sha!==t)return s;const n=(0,O.compact)(await Promise.all([...await r.previewInfos()].reverse().filter((e=>e.reducer===W.ReducerNames.fit)).map((e=>(0,_.previewToDownloadable)(i.base,e)))));return s.push(...(0,O.uniqBy)(n,(e=>e.size))),s}catch(e){return(0,v.onError)("AssetFile.downloadables failed for "+this.uri,e),[]}}async pathInfo(){try{const e=F.URI.parse(this.uri),t=(0,U.map)((0,I.uriToTagPath)({uri:e,isFile:!0}),(e=>X.Tag.findByPath(e)));return this._pathInfo_(await(t?.toApiPathElements()))}catch(e){return void this.logger().warn("pathInfo(): failed",e)}}async _pathInfo_(e){const t=await this.posixFile_();if(null==t)return this.logger().throw("pathInfo(): no posixFile",{uri:this.uri});const i=t.nativePath,r=F.URI.parse(this.uri),s=await t.exists();if(null==e||(0,O.isEmpty)(e))return this.logger().warn("pathInfo(): failed to find existing Tag. Returning a simple path.",{uri:this.uri,nativePath:i,tagLineage:e}),{nativePath:i,pathElements:[],nativePathSuffix:i,pathSep:a.sep,exists:s};function n(){return(0,L.at)((0,L.at)(e,-1)?.tagPath,-1)}(0,z.eql)(e[0]?.tagPath,[J.TagRoots.fs])&&(e=e.slice(1));const o=r.scheme===$.PS_LIBRARY_SCHEME,l=o?r.path.split("/").slice(1):t.pathnames,u=l.pop(),c=[];for(;l.length>0&&(0,d.equalsIgnoreCase)(n(),(0,L.at)(l,-1));){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("added matching tag",t)}if(o&&n()===J.LibraryTagName){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("pslib: added matching library tag",t)}if(r.scheme===$.PS_LOCAL_FILE_SCHEME){const t=F.URI.parse(this.uri).authority;if(this.logger().debug("psfile: pop last?",{lastTagName:n(),thisVolSha:t}),n()===t){l.pop();const t=e.pop();c.unshift(t)}else this.logger().warn("weird: I expected to be able to include the volsha tag element, but it doesn't seem to match",{thisVolSha:t,tagVolSha:n()})}return this.logger().tap({msg:"pathInfo()",result:{nativePath:i,pathElements:c,nativePathSuffix:u,pathSep:a.sep,exists:s}})}async toApi(e,t){return(0,m.thenMap)(this.pathInfo(),(async i=>(0,H.reqValuedOrElse)({assetId:this.assetId,assetFileId:this.id,...i,mimetype:this.mimetype,shown:(0,N.isTrue)(this.shown),name:this.basename,width:this.width,height:this.height,rotation:this.rotation??0,fileSize:this.fileSize,mtime:this.mtime,downloadables:await this.downloadables(e,t),createdAtLocale:ie(this.createdAt),updatedAtLocale:ie(this.updatedAt)})))}get isVideo(){return(0,k.isVideoMimeType)(this.mimetype)}}function ie(e){return(0,U.map)(e,(e=>(0,V.fmtDuration)(Date.now()-e,1)+" ago"))}t.AssetFile=te,r=new WeakSet,s=function(){if((0,R.blank)(this.uri))return"blank uri";if((0,R.blank)(this.sha))return"blank sha";if(!(0,q.gt0)(this.width))return"missing width";if(!(0,q.gt0)(this.height))return"missing height";if(!(0,q.gt0)(this.capturedAtLocal))return"missing capturedAtLocal";if(!(0,q.gte0)(this.capturedAtPrecisionMs))return"missing capturedAtPrecisionMs";if(E.Settings.useImageHashes.valueOrDefault){const e=[];for(const t of["dctHash","diffHash","meanHash"])(0,R.blank)(this[t])&&e.push(t);if(1===e.length)return"missing image hash: "+e[0];if(e.length>1)return"missing image hashes: "+e.join(", ")}return this.isVersionUpToDate()?void 0:"outdated version"},te.$tableName="AssetFile",te.$uniqueColumnName="uri",te.$booleanFields=["shown"],te.$transientFields=["nativePath","syncState"]},48722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toAssetId=void 0;const r=i(76596),s=i(31586);t.toAssetId=function(e){const t=(0,s.toGt0)(e?.assetId)??(0,s.toGt0)(e?.id);if(null==e||null==t||!(0,s.isNumber)(e?.capturedAtLocal))return;const i=((0,s.toGt0)(e.v)??(0,s.toGt0)(e.updateCount)??(0,s.toGt0)(e.updatedAt)??0)%1e6,n={assetId:t,capturedAtLocal:e.capturedAtLocal,v:i};return(0,s.gt0)(e.durationMs)&&(n.durationHMS=(0,r.durationHMS)(e.durationMs)),n}},37094:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetRevision=void 0;const r=i(98553),s=i(67478),n=i(55046);class a extends n.Model{static insert(...e){return a.ops().insert(e.map((e=>({assetId:e.assetId,createdAt:Date.now(),field:e.field,op:e.op,_priorValueJson:(0,r.stringify)(e.priorValue),_newValueJson:(0,r.stringify)(e.newValue)}))))}get priorValue(){return(0,s.parseJSON)(this._priorValueJson)}get newValue(){return(0,s.parseJSON)(this._newValueJson)}}t.AssetRevision=a,a.$tableName="AssetRevision"},45295:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetTag=void 0;const r=i(55046);class s extends r.Model{$pk(){return this.assetId+":"+this.tagId}}t.AssetTag=s,s.$tableName="AssetTag",s.$uniqueColumnName="assetId,tagId",s.$useCache=!1,s.$pkColumnNames=["assetId","tagId"]},61204:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeMonthTag=t.normalizeDateTags=t.getMonthTags=void 0;const r=i(19851),s=i(50213),n=i(97352),a=i(75020),o=i(4407),l=i(48723),u=`'${a.TagRoots.When}' || char(31) || '%' || char(31) || '%' || char(31)`,c=u+" || '%' || char(31)",d=(0,r.lazy)((()=>(0,s.mkLogger)("model.DateTagNormalizer")));function h(){return l.Tag.ops().allf((e=>e.whereNotNull("ordinal").andWhereRaw("_path LIKE "+u+" AND _path NOT LIKE "+c).limit(2400)))}function f(e){const t=(0,n.mapGt0)(e.ordinal,(e=>(0,o.monthTagRef)((0,o.ordinalToMonth)(e))));null==t?d().warn("failed to fix tag (no monthTagRef)",{t:e}):t.name!==e.name&&(d().info("Fixing month name",{tagRef:t,tag:e}),e.changeName(t.name)),e.maybeUpsertDisplayName(t?.displayName)}t.getMonthTags=h,t.normalizeDateTags=async function(){for(const e of h())f(e)},t.normalizeMonthTag=f},95700:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runMaintenanceTasks=void 0;const r=i(19851),s=i(56038),n=i(28874),a=i(42659),o=i(41400),l=i(69032),u=i(61204),c=i(49796);t.runMaintenanceTasks=async function({force:e}={}){await d(),await(!0===e?h.refresh():h());try{await(!0===e?(0,l.forceRunTagMaintenance)():(0,l.runTagMaintenance)())}catch{}};const d=(0,r.lazy)((()=>(0,s.time)("db.normalizeDateTags",u.normalizeDateTags))),h=(0,r.lazy)((()=>(0,s.time)("db.Progress.vacuum",(()=>c.Progress.vacuum()))),2*a.hourMs);(0,o.later)((()=>{n.Settings.libraryDir.watchLater((()=>{d.unset(),h.unset()}))}))},55046:(e,t,i)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const s=i(57975),n=i(50213),a=i(7282),o=i(65211),l=i(40958),u=i(38639),c=i(45599),d=i(31586),h=i(68708),f=i(34666),m=i(54993),p=i(57038),g=i(94448),y=i(33572),w=i(63872);class v{constructor(){this.$instanceId=(0,a.isTest)()?(0,o.uid)():void 0}static get $ctor(){return this.$schema+"."+this.$tableName}static query(){return(0,p.knex)()(this.$tableName)}static queryBy(e){return this.query().where(e)}static queryOneBy(e){return this.queryBy(e)}static ops(){return this._ops??(this._ops=new w.ModelOps(this,this.db))}static get dbl(){return this.ops().dbl}static rows(){return this.ops().rows()}static truncate(){if((0,a.isProd)())throw new Error("rejecting attempt to truncate in prod");this.dbl.run("DELETE FROM "+this.$tableName)}static ucn(e){const t=this.$uniqueColumnName.split(",").map((t=>e[t]));return t.some((e=>null==e))?void 0:1===t.length?t[0]:t.join(",")}static hasId(e){return this.$pkColumnNames.every((t=>null!=e[t]))}static pickId(e){return(0,h.pick)(e,...this.$pkColumnNames)}$ops(){return this.class().ops()}class(){return this.constructor}$pk(){return(0,m.toS)(this.id)}$ucn(){return this.class().ucn(this)}$tableName(){return this.class().$tableName}$uid(){return`${this.$tableName()}(${this.id??this.$ucn()})${!0===this.shown?"!":""}`}logger(){return(0,n.mkLogger)(this.class().$schema+"."+(0,m.toS)(this.valueOf()))}[s.inspect.custom](){return{...this.$toShallowJSON(),$instanceId:this.$instanceId}}toString(){return this.$uid()}valueOf(){return this.$uid()}static fromJSON(e){return(0,y.fromJSON)(this,e)}static toJSON(e){return this.fromJSON(e).toJSON()}$toShallowJSON(){return this.$_toJSON({encodeBool:u.isTrue})}$toDbJSON(e){return this.$_toJSON({encodeBool:u.boolToInt,includeCtor:!1,includeTransient:!1,colNames:e})}$clone(){return(0,y.fromJSON)(this.class(),this.toJSON())}toJSON(){return this.$_toJSON({encodeBool:u.isTrue})}_get(e,t,i=!0){const r=this[e];return null===r?[e,null]:!(0,f.isPrimitive)(r)||!i&&(0,l.includes)(this.class().$transientFields,e)?void 0:(0,l.includes)(this.class().$booleanFields,e)?[e,t(r)]:[e,r]}$_toJSON({encodeBool:e,includeCtor:t=!0,includeTransient:i=!0,colNames:r}){const s=this.class(),n=(0,l.notEmptyOr)(r,s.ops().columnNames());return(0,h.fromEntries)(n.map((t=>this._get(t,e,i))),t?{$ctor:s.$ctor}:{})}insert(){return this.logger().debug("insert()",{self:this.toJSON()}),this.class().ops().insertOne(this)}update(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("update()",{self:this.toJSON()}),this.class().ops().updateOne(this)}upsert(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("upsert()",{self:this.toJSON(),arg:e}),this.class().ops().upsertOne(this)}$afterInsert(){}$beforeUpsert(){}$afterUpsert(){}reload(){return this.class().ops().reloadOne(this)}delete(){(0,d.gt0)(this.id)&&this.class().ops().delete([this.id])}}t.Model=v,r=v,v.$schema="models",v.$logger=(0,c.defer)((()=>(0,n.mkLogger)(r.$schema+"."+r.$tableName))),v.db=g.modelDb,v.$pkColumnNames=["id"]},94448:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryModelDbFile=t.modelDb=void 0;const r=i(15056),s=i(87290),n=i(19851),a=i(55835);t.modelDb=(0,n.lazy)((()=>{})),t.libraryModelDbFile=function(e){return(0,a.map)((0,s.libraryDataDirPosixFile)(e),(e=>(0,r.pathToDb)(e,"models")))}},33572:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toJSON=t.assignFromJSON=t.fromJSON=t.addModelClass=void 0;const r=i(50213),s=i(40958),n=i(22573),a=i(38639),o=i(97790),l=i(51926),u=new Map;function c(e){u.set(e.$ctor,e)}function d(e,t,i=[]){const r=e.class();for(const[n,o]of Object.entries(t)){if("$ctor"===n)continue;if(void 0===o)continue;const t=(0,l.stripPrefixes)(n,i);e[t]=null==o?o:(0,s.includes)(r.$booleanFields,t)?(0,a.isTrue)(o):o}return e}t.addModelClass=c,t.fromJSON=function(e,t){if(null==t)throw new Error("json is null");if(null!=e&&(0,n.notBlank)(e.$ctor)&&!u.has(e.$ctor)&&c(e),t instanceof e)return t;const i=(0,o.opt)(t.$ctor).flatMap((e=>u.get(e))).getOrElse((()=>e));if(t instanceof i)return t;const r=new i;return null==t?r:d(r,t,(0,s.uniq)([e.$tableName+".",i.$tableName+"."]))},t.assignFromJSON=d,t.toJSON=function e(t,i,s){if(null!=t)return Array.isArray(t)?t.map(((t,r)=>e(t,i,`${s}[${r}]`))):"function"==typeof t.toJSON?t.toJSON():void(0,r.mkLogger)("ModelJSON.toJSON()").warn("Failed",{m:t,key:s,mc:i.$ctor})}},63872:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ModelOps=void 0;const f=i(48884),m=i(19851),p=i(50213),g=i(81168),y=i(48299),w=i(12943),v=i(38835),b=i(34102),S=i(28874),P=i(40958),M=i(76790),_=i(22573),T=i(50357),E=i(96249),D=i(98553),k=i(55835),x=i(31586),F=i(68708),C=i(59455),A=i(86859),I=i(33572);t.ModelOps=class{constructor(e,t){r.add(this),this.model=e,this.db=t,s.set(this,void 0),n.set(this,!0),a.set(this,new y.WeakCache),o.set(this,new Set),this.columnNames=(0,m.lazy)((()=>this.db().tableInfo_().find((e=>(0,g.equalsIgnoreCase)(e.tableName,this.tableName))).columns.map((e=>e.name)))),this.updatableColumnNames=(0,m.lazy)((()=>(0,P.diff)(this.columnNames(),this.immutableColumnNames))),this.ucnFieldNames=(0,m.lazy)((()=>this.ucn.split(","))),d(this,s,(0,p.mkLogger)(`ModelOps(${e.$tableName})`),"f"),(0,I.addModelClass)(e),d(this,n,e.$useCache??!0,"f"),this.dbl=new A.DbRequest(this.db,e.$tableName),(0,b.ee)().on("clearCache",(()=>h(this,a,"f").clear())),(0,b.ee)().on("clearDbCache",(()=>h(this,a,"f").clear()))}clearDbCache(){h(this,a,"f").clear()}get $cache(){return h(this,a,"f")}$cachedByJson(e){if(null==e||!h(this,n,"f"))return;const t=this.$pickModelUcn(e);return(null==t?void 0:h(this,a,"f").get((0,D.stringify)(t)))??this.$cachedById(e.id)}$cachedById(e){return(0,x.gt0)(e)&&h(this,n,"f")?h(this,a,"f").get((0,D.stringify)(e))??h(this,a,"f").findEntry((t=>t.id===e)):void 0}get dbOpen(){return(0,k.mapOr)(this.db(),(e=>e.isOpen),(()=>!1))}get tableName(){return this.model.$tableName}query(){return this.model.query()}toDbValued(e){const t=this.model.fromJSON(e),i=(0,w.toDbValued)(t);return(0,F.pick)(i,...this.columnNames())}run(e){return this.dbl.run(e)}fromJSON(e){if((0,F.isEmptyObj)(e))return;const t=this.model.fromJSON(e);return h(this,r,"m",u).call(this,t)}fromJSONs(e){return(0,P.compact)(e.map((e=>this.fromJSON(e))))}first(e){return this.fromJSON(this.dbl.first(e))}firstf(e){return this.first(e(this.query()))}all(e=this.query()){return this.fromJSONs(this.dbl.all(e))}allf(e){return this.all(e(this.query()))}findOne(e){return this.fromJSON(this.dbl.first(e))}findOneBy(e){return this.findOne(this.model.query().where(e))}findById(e,t){return this.findOneBy({...t,id:e})}findByIds(e){e=(0,C.toA)(e).filter(x.gt0);const t=[],i=[];for(const r of e){const e=this.$cachedById(r);null!=e?t.push(e):i.push(r)}const r=(0,f.batches)(i,S.Settings.dbBatchSelectSize.valueOrDefault).map((e=>this.dbl.all(this.query().whereIn("id",e))));return(0,M.sortBy)([...t,...this.fromJSONs((0,E.flatten)(r))],(t=>e.indexOf(t.id)))}findBy(e){return this.all(this.model.queryBy(e))}findWhereIn(e,t){return this.all(this.model.query().whereIn(e,t))}rows(e){return this.count(e??this.model.query().count())}count(e){return(0,x.toGt0)(this.dbl.pluckFirst(e))??0}countf(e){return this.count(e(this.query()))}insert(e){return(0,C.toA)(e).map((e=>this.insertOne(e)))}upsertOne(e){return this.modelSupportsUpsert?this.upsert([e])[0]:this.insertOrUpdateOne(e)}insertOrUpdateOne(e){return null==e.id?this.insertOne(e):this.updateOne(e)}insertOne(e){if(this.model.hasId(e))throw new Error("insert called for "+(0,D.stringify)(e)+v.NonRetriableErrorFlag);const t=this.fromJSON(e);if(null==t)return h(this,s,"f").throw("insertOne(): fromJSON returned null"+v.InternalErrorFlag,{t:e});t instanceof this.model&&h(this,r,"m",u).call(this,t),t.$beforeUpsert();const i=t.$toDbJSON(this.columnNames()),n=this.dbl.runf((e=>e.insert(i)));return t.id=(0,x.toInt)(n.lastInsertRowid),t.$afterInsert(),t.$afterUpsert(),t}unsetField(e,t){return(0,k.map)(this.$cachedById(e),(e=>{e[t]=null})),this.dbl.runf((i=>i.where({id:e}).update(t,null)))}updateOne(e){if(null==e.id)throw new Error("update called for "+(0,D.stringify)(e)+v.NonRetriableErrorFlag+v.InternalErrorFlag);const t=this.model.fromJSON(e);t.$beforeUpsert();const i=t.$toDbJSON(this.updatableColumnNames());return this.dbl.runf((t=>t.where({id:e.id}).update(i))),t.$afterUpsert(),h(this,r,"m",u).call(this,t)??t}get ucn(){return(0,_.toNotBlank)(this.model.$uniqueColumnName)??"id"}get modelSupportsUpsert(){return null!=this.ucn&&"id"!==this.ucn}get ucnConstraint(){return`(${this.ucn})`}get immutableColumnNames(){return(0,P.uniq)([...this.ucnFieldNames(),"id","createdAt"])}onConflictClause(e){const t=this.immutableColumnNames,i=e.filter((e=>!t.includes(e))).sort().map((e=>`${e}=excluded.${e}`)).join(","),r=["ON CONFLICT",this.ucnConstraint];return(0,_.blank)(i)?r.push("DO NOTHING"):r.push("DO UPDATE SET",i),r.join(" ")}$pickModelUcn(e){const t={};for(const i of this.ucnFieldNames()){const r=e[i];if(null==r)return;t[i]=r}return t}reloadOne(e){if(h(this,o,"f").has(e.id))return;const t=this.$pickModelUcn(e);if(null!=t){const i=h(this,r,"m",u).call(this,e),s=this.findOneBy(t);if(null==s)return;return h(this,r,"m",l).call(this,i,s),i!==e&&h(this,r,"m",l).call(this,e,i),i}h(this,s,"f").warn(".reloadOne(): failed to reload "+(0,D.stringify)(e))}reload(e){const t=[],i=this.allf((i=>{for(const r of e){const e=this.model.hasId(r)?this.model.pickId(r):this.$pickModelUcn(r);null!=e?(t.push([r,e]),i=i.orWhere(e)):h(this,s,"f").warn("reload(): given insufficient partial model",{fragment:r})}return i})),n=[];for(const[e,a]of t){const t=i.find((e=>(0,T.eqlSubset)(a,e)));if(null==t)h(this,s,"f").warn("reload(): failed to find result in db",{prior:e,dbArr:i});else{const i=h(this,r,"m",u).call(this,e);h(this,r,"m",l).call(this,i,t),i!==e&&h(this,r,"m",l).call(this,i,t),n.push(t)}}return n}upsert(e){if(e=(0,P.compact)(e),!this.modelSupportsUpsert)return e.map((e=>this.insertOrUpdateOne(e)));const t=this.columnNames(),i=[];for(const s of(0,f.batches)((0,C.toA)(e),S.Settings.dbBatchUpsertSize.valueOrDefault)){const e=new Map,n=new Set,a=(0,P.compact)(s.map((e=>this.fromJSON(e))));for(const t of a){const i=(0,D.stringify)(this.$pickModelUcn(t));e.set(i,t),this.model.hasId(t)||n.add(i),t.$beforeUpsert()}h(this,r,"m",c).call(this,a.map((e=>e.$toDbJSON(t))));const o=this.reload(a),l=new Map(o.map((e=>[(0,D.stringify)(this.$pickModelUcn(e)),e])));for(const e of a){const t=(0,D.stringify)(this.$pickModelUcn(e)),r=l.get(t)??e;n.has(t)&&r.$afterInsert(),r.$afterUpsert(),i.push(r)}}return i}delete(e){const t=(0,C.toA)(e).filter(x.gt0);for(const e of t)h(this,o,"f").add(e);return h(this,a,"f").deleteValueIf((e=>t.includes(e.id))),this.run(this.model.query().delete().whereIn("id",t))}async batched(e){const t=e.batchSize??S.Settings.dbBatchSelectSize.valueOrDefault;let i,r;do{i=this.allf((i=>(i=e.qb(i),null!=r&&(i=i.andWhere("id",">",r)),i.orderBy("id","asc").limit(t)))),(0,P.isNotEmpty)(i)&&(r=Math.max(...i.map((e=>e.id))),await e.onResults(i))}while((0,P.isNotEmpty)(i))}},s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function(e,t){(0,F.assignFields)(e,t,{omitKeys:["$instanceId"],assignNullish:!0})},u=function(e){if(h(this,n,"f")){const t=this.$cachedByJson(e);if(null!=t)return h(this,r,"m",l).call(this,t,e),t;{const t=this.$pickModelUcn(e)??e.id;null!=t&&h(this,a,"f").set((0,D.stringify)(t),e)}}return e},c=function(e){const t=this.query().insert(e).toSQL(),i=new Set;for(const t of e)for(const e of(0,F.keys)(t))i.add(e);const s={sql:t.sql+" "+this.onConflictClause([...i.values()]),bindings:t.bindings};this.run(s);for(const t of e){const e=this.$cachedByJson(t);null!=e&&h(this,r,"m",l).call(this,e,this.model.fromJSON(t))}}},20958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Operation=t.OperationNames=void 0;const r=i(19851),s=i(50213),n=i(88158),a=i(99331),o=i(70025),l=i(8769),u=i(22573),c=i(98553),d=i(50989),h=i(72761);t.OperationNames=(0,d.strEnum)("rebuildLibrary","forceRestartSync");const f=(0,r.lazy)((()=>(0,s.mkLogger)("model.Operation")));class m extends h.TimestampedModel{static incomplete(){return this.ops().allf((e=>e.whereIn("id",(e=>e.table(m.$tableName).min("id").whereNull("completedAt")))))}static ensurePendingOp(e){return m.getFirstPendingOp(e)??m.ops().insertOne(e)}static getFirstPendingOp(e){return f().tap({msg:"getFirstPendingOp",level:"info",result:this.ops().firstf((t=>{const i=t.whereNull("completedAt").orderBy("createdAt","asc");return null!=e?i.andWhere(e):i})),meta:{crit:e}})}static markOpCompleted(e,t){return(0,u.blank)(e?.name)?f().throw("markOpCompleted(): bad query",{crit:e}):this.dbl.runf((i=>i.whereNull("completedAt").andWhere(e).update({completedAt:Date.now(),...t})))}static async applyIfPending(e,t){const i=this.ops().firstf((t=>t.whereNull("completedAt").andWhere(e)));return f().info("applyIfPending()",{crit:e,op:i}),null==i?void 0:t(i)}static async applyOnce_(e,t,i=n.identity){const r=this.ops().firstf((t=>i(t.whereNotNull("completedAt").andWhere(e))));if(null!=r)return void f().debug("applyOnce(): already done",{priorCompleted:r});const s=this.ops().insertOne(e);try{const e=await t(s);return(0,a.ending)()||s.markCompleted(),e}catch(t){if((0,o.isRedoableError)(t))return void f().info("applyOnce(): redoable error",{crit:e,error:t});throw(0,l.onError)("Operation.applyOnce(): "+(0,c.stringify)(e),t),t}}markCompleted(){null==this.completedAt&&(this.completedAt=Date.now(),this.upsert())}}t.Operation=m,m.$tableName="Operation",m.$uniqueColumnName="id",m.$useCache=!1},49796:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Progress=t.defaultMinCreatedAt=t.toPct=void 0;const r=i(48161),s=i(1708),n=i(48884),a=i(50213),o=i(28874),l=i(40958),u=i(42659),c=i(45599),d=i(98553),h=i(55835),f=i(31586),m=i(68708),p=i(67478),g=i(51926),y=i(59455),w=i(54993),v=i(76386),b=i(33572),S=i(55009),P=i(72761),M=(0,c.defer)((()=>(0,a.mkLogger)("model.Progress")));function _(e){return null==e||!(0,f.isNumber)(e)||e<0||e>100?void 0:(0,f.sigFigs)(e,3)}t.toPct=_;const T=(0,g.compressWhitespace)("\nSELECT\n p1.uri,\n p1.id as lastProgressId,\n p1.createdAt as lastStartedAt,\n p1.updatedAt as lastUpdatedAt,\n p3.lastCompletedAt\nFROM\n Progress AS p1\n JOIN (\n SELECT\n uri,\n max(updatedAt) AS lastUpdatedAt\n FROM\n Progress\n GROUP BY\n 1\n ) AS p2 ON p1.uri = p2.uri\n AND p1.updatedAt = p2.lastUpdatedAt\n LEFT JOIN (\n SELECT\n uri,\n max(completedAt) AS lastCompletedAt\n FROM\n Progress\n WHERE\n CAST(completedAt AS int) > 0\n GROUP BY\n 1\n ) AS p3 ON p1.uri = p3.uri\nGROUP BY\n p1.uri");function E(){const e=o.Settings.progressStaleDays.valueOrDefault;return e<=0?0:Date.now()-e*u.dayMs}t.defaultMinCreatedAt=E;class D extends P.TimestampedModel{static vacuum(e=o.Settings.progressRetentionDays.valueOrDefault*u.dayMs){const t=Date.now()-e,i=this.dbl.pluckAllf((e=>e.select("id").where("createdAt","<=",t)));for(const e of(0,n.batches)(i,o.Settings.dbBatchSelectSize.valueOrDefault))S.ProgressMeta.dbl.runf((t=>t.whereIn("progressId",e).delete())),D.dbl.runf((t=>t.whereIn("id",e).delete()))}static countCompletedDirectorySyncs(){return this.dbl.pluckFirstf((e=>e.where({state:"done"}).whereNotNull("completedAt").where("uri","like","ps%")))}static times(){return M().tap({msg:"times()",result:this.dbl.all({sql:T})})}static insertNew(e){const t=(0,h.map)(e.dek,d.stringify);return this.ops().insertOne({...(0,m.omit)(e,"dek"),dekJSON:t})}upsert(e){return null!=e&&this.assignFromPojo(e),super.upsert()}$beforeUpsert(){super.$beforeUpsert(),null==this.id&&(this.pid??(this.pid=s.pid),this.hostname??(this.hostname=(0,r.hostname)())),"done"===this.state&&(this.completedAt??(this.completedAt=Date.now())),this.completePct=_(this.completePct),this.incompletePct=_(this.incompletePct),this.scanningPct=_(this.scanningPct)}$afterUpsert(){super.$afterUpsert(),(0,v.tellWebProgressUpdated)()}toSyncState(){return{id:this.id,uri:this.uri,volume:this.volume,state:this.state,hed:this.hed,dek:this.dek,completePct:this.completePct,incompletePct:this.incompletePct,scanningPct:this.scanningPct}}get dek(){return(0,l.compactBlanks)((0,p.parseJSON)(this.dekJSON))}set dek(e){var t;this.dekJSON=(t=e,(0,d.stringify)((0,l.compactBlanks)((0,y.toA)(t))))}assignFromPojo(e){return(0,b.assignFromJSON)(this,(0,m.omit)(e,"volume","uri"))}getMeta(){return S.ProgressMeta.ops().allf((e=>e.where({progressId:this.id}).orderBy("createdAt")))}getPriorIncomplete(e=E()){return this.logger().tap({msg:"priorIncompleteProgress()",result:D.ops().firstf((t=>t.where({hostname:this.hostname,uri:this.uri,completedAt:null}).andWhere("createdAt",">",e).orderBy("updatedAt","desc")))})}getLastCompletedAt(e=E()){return D.dbl.pluckFirstf((t=>t.max("completedAt").where({uri:this.uri}).andWhere("createdAt",">",e)))}getLastIncompleteStartAt(){return D.dbl.pluckFirstf((e=>e.min("createdAt").where({uri:this.uri}).andWhere("createdAt",">",this.getLastCompletedAt()??0)))}setMeta(e,t){return this.logger().debug("setMeta()",{progressId:this.id,name:e,value:t}),S.ProgressMeta.ops().upsertOne({progressId:this.id,name:e,value:t})}setMetaRecord(e){const t=this.getMeta(),i=(0,l.diff)(t.map((e=>e.name)),Object.keys(e));this.logger().debug("setMetaRecord()",{progressId:this.id,keysToDelete:i,record:e}),S.ProgressMeta.ops().upsert((0,m.entries)(e).map((([e,t])=>({progressId:this.id,name:e,value:(0,w.toS)(t)})))),(0,l.isNotEmpty)(i)&&S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).whereIn("name",i).delete()))}deleteMeta(...e){return this.logger().debug("deleteMeta()",{progressId:this.id,names:e}),S.ProgressMeta.dbl.runf((t=>t.whereIn("name",e).andWhere({progressId:this.id}).delete()))}deleteAllMeta(){return this.logger().debug("deleteAllMeta()",{progressId:this.id}),S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).delete()))}getMetaAsRecord(){return this.logger().tap({msg:"getMetaAsRecord()",result:(0,m.fromEntries)(this.getMeta().map((e=>[e.name,e.value])))??{}})}}t.Progress=D,D.$tableName="Progress",D.$uniqueColumnName="id"},55009:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressMeta=t.ProgressMetaNames=t.DirSyncProgressMetaNames=void 0;const r=i(50989),s=i(72761);t.DirSyncProgressMetaNames=(0,r.strEnum)("lastScannedDirectory","scannedDirectoryCount","completedDirectoryScan","enqueuedStaleFiles","processedImageCount","processedVideoCount","completedDirectorySync"),t.ProgressMetaNames=(0,r.strEnum)(...t.DirSyncProgressMetaNames.values);class n extends s.TimestampedModel{}t.ProgressMeta=n,n.$tableName="ProgressMeta",n.$uniqueColumnName="progressId,name"},39604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.upsertToShaBlockslist=t.upsertFileToShaBlockslist=t.isShaBlockslisted=t.notBlocklistedSha=void 0;const r=i(19851),s=i(50213),n=i(95696),a=i(40958),o=i(22573),l=i(86859),u=i(94448),c=(0,r.lazy)((()=>(0,s.mkLogger)("model.ShaBlocklist"))),d=(0,r.lazy)((()=>new l.DbRequest(u.modelDb,"ShaBlocklist")));function h(e){return null!=(0,u.modelDb)()&&!(0,o.blank)(e)&&c().tap({msg:"isShaBlockslisted",result:null!=d().pluckFirstf((t=>t.where({sha:e}).limit(1))),meta:{sha:e}})}function f(...e){if(null==u.modelDb.prior())return;const t=(0,a.uniq)(e).map((e=>({sha:e})));return(0,a.isEmpty)(t)?void 0:d().upsert((e=>e.insert(t)))}t.notBlocklistedSha=async function(e){if(null==(0,u.modelDb)())return null;const t=h(await n.PosixFile.for(e).sha());return null==t?null:!t},t.isShaBlockslisted=h,t.upsertFileToShaBlockslist=async function(e){if(null==(0,u.modelDb)())return;const t=await n.PosixFile.for(e).sha();return null==t?void 0:f(t)},t.upsertToShaBlockslist=f},48723:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Tag=t.UpdateTagAssetCountTimeName=void 0;const a=i(56038),o=i(34102),l=i(19851),u=i(50213),c=i(36372),d=i(97352),h=i(28874),f=i(81168),m=i(42231),p=i(75020),g=i(40958),y=i(22573),w=i(42659),v=i(41400),b=i(50357),S=i(55835),P=i(31586),M=i(34666),_=i(20214),T=i(51926),E=i(59455),D=i(12168),k=i(6186),x=i(57038),F=i(21074),C=i(7656),A=i(43487),I=i(48722),O=i(45295),L=i(98784),R=i(41507),N=i(72761),B=4*w.secondMs,j=(0,l.lazy)((()=>(0,u.mkLogger)("model.Tag")));(0,v.later)((()=>{(0,o.ee)().on("clearCache",(()=>z.clear())),(0,o.ee)().on("clearDbCache",(()=>z.clear()))})),t.UpdateTagAssetCountTimeName="db.updateTagAssetCountTimeName";class z extends N.TimestampedModel{constructor(){super(...arguments),this.displayPath=(0,l.lazy)((()=>{const e=this.getParent();return(0,g.compactBlanks)([...null==e?[]:e.displayPath(),this.displayName])})),this.ancestorIds=(0,l.lazy)((()=>0===this.parentId||null==this.parentId?[]:r.dbl.pluckAll({sql:(0,T.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.id","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}}))),this.firstNonInterstitialTagId=(0,l.lazy)((()=>{if(!this.isRoot&&0===this.directAssetCount()&&1===this.getChildrenCount()){const e=this.getChildren();if(1===e?.length)return e[0].firstNonInterstitialTagId()}return this.id})),this.directAssetCount=(0,l.lazy)((()=>0===this.id?0:A.Asset.dbl.pluckFirst(A.Asset.shownUnhidden().join("AssetTag","AssetTag.assetId","Asset.id").where("AssetTag.tagId",this.id).countDistinct("Asset.id"))))}static orderBy(e){return e.orderByRaw("COALESCE(ordinal, _path) COLLATE NOCASE")}static clear(){this.root.unset(),this.roots.unset(),this._upsertDefaultRoots.unset(),this.ops().clearDbCache()}static validate_(){return(0,a.timeSync)("Tag.validate_",(()=>{r.clear();for(const e of this.ops().allf((e=>e.whereRaw("id = parentId")))){j().warn(`Tag ${e.id} has itself as parentId. Attempting to fix...`);const t=e.path.slice(0,-1),i=(0,g.isEmpty)(t)?void 0:this.findOrCreate(t);e.update({parentId:i?.id??null})}for(const e of r.roots())e.validate_([])}))}validate_(e){const t=this.path;if(!(0,b.eql)(t.slice(0,-1),e))throw new Error(`Tag:${this.id} path ${t.join("/")} does not match expected parent ${e.join("/")}`);for(const e of this.getChildren())e.validate_(t)}static deltaAssetCountAndAncestors(e,t=1){return r.incrAssetCount(r.selfAndAncestorIds(e),t)}static incrAssetCount(e,t=1){(0,g.isEmpty)(e)||r.dbl.runf((i=>i.whereIn("id",e).andWhereNot({assetCount:null}).update({assetCount:(0,x.knex)().raw("assetCount + "+Math.round(t)),updatedAt:Date.now()})))}static selfAndAncestorIds(e){const t=(0,E.toA)(e).filter(P.gt0);return r.dbl.pluckAll({sql:(0,T.compressWhitespace)("WITH RECURSIVE ancestors(id) AS ("," SELECT id FROM Tag where id in "+(0,F.sqlWhereInClause)(t.length)," UNION ALL"," SELECT Tag.parentId as id"," FROM Tag, ancestors"," WHERE Tag.id = ancestors.id",")","SELECT distinct(id)","FROM ancestors","WHERE id IS NOT NULL"),bindings:t})}static updateAssetCount(e){if((0,P.gt0)(e))return(0,a.timeSync)(t.UpdateTagAssetCountTimeName,(()=>{const t=r.dbl.pluckFirst({sql:C.RecursiveAssetCountForTagQuery,bindings:{tagId:e}});r.dbl.runf((i=>i.update({assetCount:t,updatedAt:Date.now()}).where({id:e}))),j().debug("Updated asset counts for tag ",{tagId:e,assetCount:t})}))}static findByIdOrPath(e,t){return 0===e?r.root():(0,P.gt0)(e)?this.findById(e):this.findByPath(t)}static findById(e){return 0===e?r.root():this.ops().findById(e)}static findByPath(e){if((0,g.isEmpty)(e))return r.root();const t=(0,m.joinTagPath)(e);return this.ops().firstf((e=>e.whereLike("_path",t)))}static findByPathN(e){const t=(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,y.toNotBlank)((0,m.joinTagPath)(e))));return(0,g.compact)(t.map((e=>this.findByPath(e))))}static getPagedAssets(e,t){const i=new r;return i.id=e,i.getPagedAssetIds(t)}static findOrCreate(e){if((0,g.isEmpty)(e))throw new Error("empty tagPath");const t=this.findByPath(e);if(null!=t)return t;const i=n(this,r,"m",s).call(this,e),a=i.depth<=1?void 0:this.findOrCreate(e.slice(0,-1));return(0,S.map)(a,(e=>i.parentId=e.id)),this.ops().upsertOne(i)}static findOrCreateByPathN(e){return(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,m.joinTagPath)(e))).map((e=>this.findOrCreate(e)))}clear(){return this.parent=void 0,this.root=void 0,this.children=void 0,this.ancestors=void 0,this.assets=void 0,this.relatedAssets=void 0,this.ancestorIds.unset(),this}$afterInsert(){L.TagFts.insertFts([this])}siblingPath(e){return(0,m.joinTagPath)([...this.parentPath,e])}changeName(e){return this.changePath(this.siblingPath(e))}maybeUpsertDisplayName(e){return(0,y.blank)(e)||e===this._displayName?void 0:this.upsert({_displayName:e})}changePath(e,t=!0){const i=this._path,s=r.findByPath((0,m.splitTagPath)(e));this.logger().info("changePath(): ",{priorPath:i,newPath:e,existingSibling:s});try{if(null==s)r.dbl.runf((t=>t.whereLike("_path",i+"%").update({updatedAt:Date.now(),_path:(0,x.knex)().raw("REPLACE(_path, ?, ?)",[i,e])}))),this._path=e;else{e=s._path,this.logger().info("changePath(): replacing with sibling",e),O.AssetTag.dbl.upsert((e=>e.where({tagId:this.id}).update({tagId:s.id}))),O.AssetTag.dbl.runf((e=>e.where({tagId:this.id}).delete()));for(const e of this.getChildren())e.changePath((0,m.joinTagPath)([...s.path,e.name]),!1);r.dbl.runf((e=>e.where({parentId:this.id}).update({parentId:s.id}))),this.delete()}}finally{t&&r.clear()}}get name(){const e=this.path;return e[e.length-1]}get path(){return(0,m.splitTagPath)(this._path)}get displayName(){return(0,y.toNotBlank)(this._displayName)??this.name}get isRoot(){return 0===this.id}get depth(){return this.path.length}get parentPath(){return this.path.slice(0,-1)}get sortBy(){return[this.depth,null==this.ordinal?2**51:this.ordinal,this.path.map((e=>e.toLowerCase()))]}$childrenQuery(){return r.orderBy(r.query().where({parentId:this.id}))}$assetsQuery(){return A.Asset.shownUnhidden().columns("Asset.*").join("AssetTag","AssetTag.assetId","Asset.id").where({tagId:this.id})}$selectAssetIdColumns(e){return e.clearSelect().select({assetId:"Asset.id",capturedAtLocal:"Asset.capturedAtLocal",updateCount:"Asset.updateCount",durationMs:"Asset.durationMs"})}$assetIdsQuery(){return this.$selectAssetIdColumns(this.$assetsQuery())}setAncestors(e){this.ancestors=e,this.parent=e[e.length-1],(0,S.map)(this.parent,(t=>t.setAncestors(e.slice(0,-1))))}async toApiPathElements(){return(0,_.thenCollect)(this.getAncestorsAndSelf(),(e=>e.toPathTag()))}toPathTag(){return{tagPath:this.path,displayName:this.displayName}}toApiTag(){return{tagId:this.id,tagPath:this.path,displayPath:this.displayPath(),description:this.description,assetCount:this.assetCount}}toStringId(){return"Tag("+this.path.join("/")+")"}getParent(){if(!this.isRoot)return null!=this.parentId&&null==this.parent?this.parent=r.findById(this.parentId):this.parent}getPagedChildren(e){if(0===this.id){const t=e.offset??0,i=t+(e.limit??this.children.length);return[...this.children].slice(t,i)}const t=this.$childrenQuery();return(0,d.mapGt0)(e.offset,(e=>{t.offset(e)})),(0,d.mapGt0)(e.limit,(e=>{t.limit(e)})),r.ops().all(t)}getChildrenCount(){return null!=this.children?this.children.length:r.dbl.pluckFirstf((e=>(this.isRoot?e.whereNull("parentId"):e.where({parentId:this.id})).count()))}getChildren(){return this.isRoot||(this.children=r.ops().all(this.$childrenQuery()),this.children.forEach((e=>{e.parent=this}))),this.children}link(){return"/tag/"+this.path.map(encodeURIComponent).join("/")}get rootName(){return this.path[0]}get ancestorsAndSelf(){return[...this.ancestors,this]}getAncestors(){return this.ancestors??(this.ancestors=this._getAncestors())}getAncestorsAndSelf(){return[...this.getAncestors(),this]}_getAncestors(){return 0===this.parentId||null==this.parentId?[]:r.ops().all({sql:(0,T.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.*","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}})}getPagedAssetIds(e){let t=this.$assetIdsQuery();return t=t.limit(p.ThumbsPerSample),(0,P.gt0)(e.offset)&&(t=t.offset(e.offset)),t=t.orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId"}]),(0,g.compact)(A.Asset.dbl.all(t).map(I.toAssetId))}getAssets(){const e=this.$assetsQuery().orderBy("capturedAtLocal","desc");return A.Asset.ops().all(e)}async assetCountDesc(e){const t=this.assetCount;return(null==t||null==e||e.length===t||0===e.length?"":(0,D.fmt)(e.length)+" of ")+(0,D.plur)(t,"asset")}getAssetCount(){return 0===this.id?r.dbl.pluckFirst({sql:(0,T.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," Asset","WHERE"," Asset.shown = 1"," AND Asset.excluded = 0"," AND Asset.hidden = 0"," AND Asset.deletedAt IS NULL")}):r.dbl.pluckFirst({sql:C.RecursiveAssetCountForTagQuery,bindings:{tagId:this.id}})}$assetStreamQuery(e,t,i){let r=this.path[0]===p.TagRoots.When?A.Asset.shownUnhidden():this.$assetsQuery();return r=r.distinct().where("capturedAtLocal",i,e.capturedAtLocal).andWhereNot("Asset.id",e.id).limit("="===i?2*t:t),"="===i?r.orderByRaw(`ABS(Asset.id-${e.id})`):r.orderBy([{column:"capturedAtLocal",order:">"===i?"asc":"desc"},"Asset.id"])}getAssetStream(e,t){t=(0,P.gt0)(t)?t:p.BeforeAfterStreamLimit;const[i,r,s]=["<","=",">"].map((i=>(0,g.compact)(A.Asset.ops().all(this.$assetStreamQuery(e,t,i)).map(I.toAssetId))));for(const t of r)t.assetIdA.Asset.shownUnhidden(this.$selectAssetIdColumns(r)).distinct().join("Asset","Asset.id","AssetTag.assetId").join("Tag","Tag.id","AssetTag.tagId").whereLike("_path",this._path+"%").orderByRaw((0,c.prngOrderByClause)(e+(this.id??0),"Asset.id",i)).limit(t))).map(I.toAssetId));return this.logger().debug(this.path+": Found "+r.length+" related assets"),r}get attrs(){return{href:this.link(),title:this.name}}}t.Tag=z,r=z,s=function(e){const t=new r;t._path=(0,m.joinTagPath)(e);const i=e[e.length-1];return"object"==typeof i&&((0,y.mapNotBlank)(i.displayName,(e=>t._displayName=e)),(0,P.mapNumeric)(i.ordinal,(e=>t.ordinal=e)),(0,y.mapNotBlank)(i.description,(e=>t.description=e)),(0,P.mapNumeric)(i.releasedAt,(e=>t.releasedAt=e))),t},z.$tableName="Tag",z.$uniqueColumnName="_path",z.$useCache=!0,z.cmp=(e,t)=>(0,M.cmp)([e.ordinal??Number.MAX_SAFE_INTEGER,...e.path],[t.ordinal??Number.MAX_SAFE_INTEGER,...t.path]),z.root=(0,l.lazy)((()=>{const e=new r;return e.id=0,e._path=m.TagSep,e.parentId=void 0,e.children=r.roots().filter((e=>!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.name)&&!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.description??""))),e.ancestors=[],e.assetCount=A.Asset.shownCount(),e.upsert=()=>{throw new Error("upsert not supported on root")},e}),B),z._upsertDefaultRoots=(0,l.lazy)((()=>r.ops().upsert(k.Roots.map((e=>({_path:(0,m.joinTagPath)([e.name]),ordinal:e.ordinal})))))),z.roots=(0,l.lazy)((()=>{r._upsertDefaultRoots();const e=r.ops().all(r.orderBy(r.query().whereNull("parentId")));for(const t of e)t.parentId=void 0,t.ancestors=[];return e}),B);const V=(0,l.lazy)((()=>A.Asset.dbl.pluckFirstf((e=>e.count()))),w.minuteMs)},98784:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagFts=void 0;const r=i(38156),s=i(3127),n=i(40958),a=i(41400),o=i(94715),l=i(55046),u=i(48723);class c extends l.Model{static insertFts(e){try{const t=e.filter((e=>null!=e.parentId)).map((e=>({rowid:e.id,root:(0,s.tag_fts_root)(e._path),path:(0,s.tag_fts_path)(e._path)})));(0,n.isEmpty)(t)||this.dbl.runf((e=>e.insert(t)))}catch(e){this.$logger().warn("Failed to update tag_fts",{error:e})}}static async rebuild(){const e=new r.PushProgressObserver({op:"Rebuilding tag search index"},u.Tag.dbl.pluckFirstf((e=>e.count("*")))),t=this.dbl.db();o.Migrations.create_tag_fts(t.db),await u.Tag.ops().batched({qb:e=>e,onResults:t=>(this.$logger().throwIfAborted_(),this.insertFts(t),e.incrProgress(t.length),(0,a.delay)(1))}),e.completed()}}t.TagFts=c,c.$tableName="tag_fts",c.$uniqueColumnName="rowid",c.$booleanFields=[]},41507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.coalesceStreams=t.TaggedAssetStream=t.cmpAssetDesc=t.cmpAssetAsc=void 0;const r=i(48884),s=i(50213),n=i(28874),a=i(40958),o=i(76790),l=i(31586),u=i(34666),c=i(20214),d=i(59455);t.cmpAssetAsc=(e,t)=>(0,u.cmp)([e.capturedAtLocal,e.id],[t.capturedAtLocal,t.id]),t.cmpAssetDesc=(e,t)=>(0,u.cmp)([t.capturedAtLocal,t.id],[e.capturedAtLocal,e.id]),t.TaggedAssetStream=class{constructor(e,t,i,r){this.tags=e,this.before=t,this.after=i,this.limit=r,this.logger=()=>(0,s.mkLogger)("model.TaggedAssetStream("+this.toString()+")"),this.logger().info("new",this.toJSON())}vacuum(){(0,o.sortByInPlace)(this.before,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainFirstN)(this.before,this.limit),(0,o.sortByInPlace)(this.after,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainLastN)(this.after,this.limit)}toString(){return this.tags.map((e=>e.path.join("/"))).join(",")}valueOf(){return this.toString()}get length(){return(0,d.toA)(this.before).length+(0,d.toA)(this.after).length}leftPad(e){return[...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+1),capturedAtLocal:-1,v:0}))),...e]}rightPad(e){return[...e,...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+this.limit+1),capturedAtLocal:-1,v:0})))]}toJSON(){return{tags:this.tags.map((e=>e.toString())),assetIdsAfter:this.after,assetIdsBefore:this.before}}mergeWith(e){(0,a.pushUniqBy)(this.tags,e.tags,(e=>e.path)),(0,a.pushUniqBy)(this.before,e.before,(e=>e.assetId)),(0,a.pushUniqBy)(this.after,e.after,(e=>e.assetId)),this.logger().debug("mergeWith() complete",{tas:e.toJSON(),tags:this.tags.map((e=>e.path)),beforeIds:this.before,afterIds:this.after})}async toApi(){return this.vacuum(),this.logger().tap({msg:"toApi()",result:{tags:await(0,c.thenCollect)(this.tags,(e=>e.toApiTag())),assetIdsAfter:this.leftPad(this.after),assetIdsBefore:this.rightPad(this.before)}})}streamCoeff(e){return this.logger().tap({msg:"streamCoeff",meta:{this:this.tags.map((e=>e.path)),tas:e.tags.map((e=>e.path))},result:(0,r.diceCoeff)([...this.before,...this.after],[...e.before,...e.after],(e=>e.assetId))})}},t.coalesceStreams=function(e){const t=n.Settings.minStreamCorrPct.valueOrDefault/100,i=[],s=e.filter((e=>e.length>5));for(const e of s){const s=(0,r.greatestBy)(i,(i=>(0,l.gtOrElse)(i.streamCoeff(e),t)));null==s?i.push(e):s.mergeWith(e)}return i}},94710:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Task=t.StaleTaskError=t.InvalidTaskError=t.TaskNames=t.Tasks=t.testTask=void 0;const c=i(78474),d=i(22454),h=i(23560),f=i(12089),m=i(76740),p=i(22911),g=i(99331),y=i(31562),w=i(38835),v=i(70025),b=i(8769),S=i(74128),P=i(28874),M=i(37692),_=i(40958),T=i(22573),E=i(42659),D=i(45599),k=i(98553),x=i(49769),F=i(68708),C=i(50989),A=i(59455),I=i(58723),O=i(34274),L=i(90901),R=i(61989),N=i(93755),B=i(69032),j=i(55046);t.testTask=(0,f.shim1)({name:"testTask",impl:async e=>{}}),t.Tasks={applyDeleted:I.applyDeleted,applyExcluded:I.applyExcluded,runTagMaintenance:B.runTagMaintenance,repairAsset:async function(e){e.forceSync=!0,e.skipPreviews=!0,e.skipAssetTagging=!0;const t=await(0,R.updateAsset_)(e);return(0,_.isNotEmpty)(t?.assetIdsToUpdate)&&q.add(t?.assetIdsToUpdate.map((t=>({fn:"repairAsset",args:{...e,assetId:t},priority:W.repairAsset+1})))),null!=t&&!0!==t.deleted&&(0,T.blank)((0,A.toA)(t.rejected).join(""))&&(0,T.blank)(t.error)&&q.addOne("assetPostUpsertTasks",(0,F.omit)(e,"skipPreviews","skipAssetTagging")),t},assetPostUpsertTasks:L.assetPostUpsertTasks,updateAssetFile:N.updateAssetFile_,syncFile:O.importFileToResult_,testTask:t.testTask},t.TaskNames=(0,C.strEnum)(...(0,F.keys)(t.Tasks));class z extends Error{}t.InvalidTaskError=z;class V extends Error{}t.StaleTaskError=V;const W={applyDeleted:16,applyExcluded:16,runTagMaintenance:14,repairAsset:12,assetPostUpsertTasks:10,updateAssetFile:8,syncFile:0,testTask:-1},U=["repairAsset"];class q extends j.Model{constructor(){super(...arguments),r.add(this),o.set(this,(0,D.defer)((()=>new m.Abortable)))}static countTaskNames(){const e={};for(const t of s.dbl.allf((e=>e.select("fn").count().groupBy("fn"))))e[t.fn]=t["count(*)"];return e}static orderBy(e){return e.orderBy([{column:"priority",order:"desc"},{column:"retries",order:"desc"},{column:"id",order:"asc"}])}static count(){return s.dbl.pluckFirstf((e=>e.count("id")))}static freeSlots(){return P.Settings.taskListCap.valueOrDefault-s.count()}static countByFn(e){return s.dbl.pluckFirstf((t=>t.where({fn:e}).count("id")))}static nextByFn(e,t=(e=>e)){return s.ops().allf((i=>s.orderBy(t(i.where({fn:e})))))}set args(e){this.argsJSON=(0,k.stringify)(e)}get args(){const e=(0,k.parseJSON)(this.argsJSON);return(0,F.notEmptyObj)(e)&&(e.halt=u(this,o,"f").call(this)),e}get isSerial(){return U.includes(this.fn)}toString(){return`Task#${this.fn}(${this.argsJSON})`}static addOne(e,t){return s.add([{fn:e,args:t}])[0]}static add(e,t=!1){if((0,_.isEmpty)(e))return[];const i=s.ops().upsert(e.map((e=>({fn:e.fn,argsJSON:(0,k.stringify)(e.args)})),t));return s.ee.emit("added",i),(0,h.isTaskListManager)()||(0,M.addStateEvent)("checkTasks"),i}$beforeUpsert(){this.priority??(this.priority=W[this.fn]),this.retries??(this.retries=P.Settings.maxRetries.valueOrDefault)}donePromise(){return(0,h.isTaskListManager)()?(0,x.getOrSet)(u(s,s,"f",n),this.id,(()=>new p.Deferred(this.toString(),{payload:this}))):(0,y.untilTrue)((()=>null==s.ops().findById(this.id)),{intervalMs:E.secondMs})}abort(e){this.logger().warn("aborting task",{reason:e,task:this}),u(this,o,"f").call(this).abort(e),this.delete(),(0,T.blank)(this.args.path)||(0,S.syncReport)().onProgress({path:this.args.path,from:this.fn,state:S.SyncFileStates.failed,details:e})}async _run(){if(this.retries<0)throw this.logger().warn(".run(): too many retries"+w.InternalErrorFlag,{job:this}),this.delete(),new z;if(!u(this,r,"m",l).call(this))throw this.logger().warn(".run(): someone already started this task",{job:this}),new V;try{const e=Date.now(),i=await t.Tasks[this.fn](this.args);return this.logger().throwIfAborted_(u(this,o,"f").prior()),s.taskResolvedCounts.incr(this.fn),s.ee.emit("resolved",this,i,Date.now()-e),this.delete(),u(s,s,"f",n).get(this.id)?.resolve(i),i}catch(e){if((0,g.ending)())throw this.logger().info("task failed, but we're ending. We'll leave it for next time.",{task:this}),e;throw s.taskRejectedCounts.incr(this.fn),(0,v.isRedoableError)(e)?(this.retries++,this.priority--,this.upsert()):!0===(0,v.isRetriableError)(e)&&this.retries>=0?this.logger().warn("run failed, but we can retry it later",{task:this,error:e}):(s.ee.emit("rejected",this,e),this.delete(),u(s,s,"f",n).get(this.id)?.reject(e),(0,b.onError)(this.toString()+" failed",e)),e}finally{u(s,s,"m",a).call(s)}}}t.Task=q,s=q,o=new WeakMap,r=new WeakSet,a=function(){for(const[e,t]of u(this,s,"f",n).entries())t.isSettled&&u(this,s,"f",n).delete(e)},l=function(){const e=this.retries;if(1===s.dbl.runf((t=>t.where({id:this.id,retries:e}).update({retries:e-1}))).changes)return--this.retries,!0;{const e=this.toJSON(),t=this.reload();return this.logger().warn(".#decrRetries(): someone already started this task",{before:e,reloaded:t}),!1}},q.$tableName="Task",q.$uniqueColumnName="fn,argsJSON",q.$useCache=!1,q.taskResolvedCounts=new d.CountingSet,q.taskRejectedCounts=new d.CountingSet,q.ee=new c.EventEmitter,n={value:new Map}},72761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimestampedModel=void 0;const r=i(97352),s=i(40958),n=i(31586),a=i(59455),o=i(55046);class l extends o.Model{static touch(e,t={}){t.updatedAt??(t.updatedAt=Date.now()),delete t.id;const i=(0,a.toA)(e).filter(n.gt0);return(0,s.isEmpty)(i)?void 0:this.dbl.runf((e=>e.whereIn("id",i).update(t)))}get createdAtDate(){return(0,r.mapGt0)(this.createdAt,(e=>new Date(e)))}get updatedAtDate(){return(0,r.mapGt0)(this.updatedAt,(e=>new Date(e)))}touch(e={}){e.updatedAt??(e.updatedAt=Date.now());const t=this.id;null==t?this.upsert():this.class().dbl.runf((i=>i.where({id:t}).update(e)))}$beforeUpsert(){if(super.$beforeUpsert(),this.createdAt??(this.createdAt=Date.now()),this.updatedAt=Date.now(),"updateCount"in this){const e=this,t=e.updateCount;e.updateCount=((0,n.toGt0)(e.updateCount)??0)+1,this.logger().debug("$beforeUpsert(): incr updateCount",{prior:t,now:e.updateCount})}}}t.TimestampedModel=l},58723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyExcluded=t.applyDeleted=void 0;const r=i(50213),s=i(43487),n=(0,r.mkLogger)("ops.ApplyRemovable");async function a(e,t,i){const r=e?"Deleting":"Excluding",a=e?"deletedAt":"excludedAt";await s.Asset.dbl.batched({qb:e=>e.select("id").where("shown",0).andWhere(a,"<=",t),onResults:async t=>{for(const a of t){n.throwIfAborted_(i);try{await s.Asset.remove({assetId:a,blocklistShas:!0,unlinkAssetFiles:e})}catch(e){n.error(r+" failed",{assetId:a,error:e})}}}})}t.applyDeleted=function(e){return a(!0,e.createdAt,e.halt)},t.applyExcluded=function(e){return a(!1,e.createdAt,e.halt)}},76386:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiProgressPatchPath=t.tellWebProgressUpdated=t.ProgressRateMs=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(24540),o=i(28874),l=i(34238),u=i(4988),c=i(15674),d=i(42659),h=(0,i(45599).defer)((()=>(0,s.mkLogger)("progress.Progress")));t.ProgressRateMs=(0,r.lazy)((()=>d.secondMs*((0,a.isRaspberryPi)()||(0,c.maxCpus)()<=3?5:1.5))),t.tellWebProgressUpdated=(0,r.lazy)((async()=>{if((0,n.isWebService)())return;const e=l.URI.from({scheme:"http",authority:"127.0.0.1:"+o.Settings.httpPort.valueOrDefault,path:t.ApiProgressPatchPath}).toString();await(0,u.httpRequest_)({url:e,method:"PATCH"}).catch((e=>h().warn(".tellWebProgressUpdated: failed",{error:e})))}),(0,t.ProgressRateMs)()),t.ApiProgressPatchPath="/api/progress"},22968:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeRebuildLibrary=t.forceRebuildLibraryLater=t.rebuildLibraryOperationCrit=void 0;const r=i(45393),s=i(28874),n=i(98553),a=i(43487),o=i(54017),l=i(20958),u=i(33567);function c(){return{name:l.OperationNames.rebuildLibrary,value:(0,n.stringify)({AssetVersion:r.AssetVersion,AssetFileVersion:r.AssetFileVersion})}}t.rebuildLibraryOperationCrit=c,t.forceRebuildLibraryLater=function(){a.Asset.dbl.runf((e=>e.update({version:0}))),o.AssetFile.dbl.runf((e=>e.update({version:0}))),l.Operation.dbl.runf((e=>e.where(c()).delete()))},t.maybeRebuildLibrary=async function(){return s.Settings.skipLibraryRebuild.valueOrDefault?void 0:l.Operation.applyOnce_(c(),(()=>(new u.LibraryRebuild).doneLatch))}},33567:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LibraryRebuild=void 0;const c=i(19851),d=i(83412),h=i(25764),f=i(8769),m=i(76752),p=i(28874),g=i(15674),y=i(22573),w=i(42659),v=i(31586),b=i(12168),S=i(12236),P=i(35580),M=i(49796),_=i(94710),T=i(18209);class E extends d.DoneWrapper{constructor(){super("LibraryRebuild",(()=>u(this,r,"m",a).call(this)),h.EndableRanks.first),r.add(this),this.assetFileEta=new m.ETA,this.assetEta=new m.ETA,this.assetFilesUpdated=0,this.assetsUpdated=0,this.initialAssetFileTodoCount=(0,c.lazy)(T.outdatedAssetFileCount),this.initialAssetTodoCount=(0,c.lazy)(T.outdatedAssetCount),s.set(this,(0,c.lazy)((()=>M.Progress.insertNew({uri:S.RebuildingURI,volume:"🔄",scanningPct:0})))),o.set(this,((e,t,i)=>{"updateAssetFile"===e.fn?(this.assetFilesUpdated++,this.assetFileEta.push(i),u(this,r,"m",n).call(this)):"updateAsset"===e.fn&&(this.assetsUpdated++,this.assetEta.push(i),u(this,r,"m",n).call(this))})),_.Task.ee.on("resolved",u(this,o,"f")),this.doneLatch.observe(u(this,r,"m",l).call(this))}async assetFileTodo(){return await this.initialAssetFileTodoCount()-this.assetFilesUpdated}async assetTodo(){return await this.initialAssetTodoCount()-this.assetsUpdated}}t.LibraryRebuild=E,s=new WeakMap,o=new WeakMap,r=new WeakSet,n=async function({force:e=!1,done:t=!1}={}){const i=u(this,s,"f").call(this);if(e||!(0,v.gt)(i.updatedAt,Date.now()-w.secondMs))if((t??this.isDone())&&"done"!==i.state){const e=[];this.assetFilesUpdated>0&&e.push(`Updated file metadata for ${(0,b.fmt)(this.assetFilesUpdated)} files`),this.assetsUpdated>0&&e.push(`Refreshed ${(0,b.fmt)(this.assetsUpdated)} assets`),i.dek=e,i.upsert({state:"done",hed:"Finished rebuilding your library 🎉",completePct:100,incompletePct:0,scanningPct:0})}else{let e="Rebuilding your library";const t=await this.assetFileTodo(),r=await this.assetTodo(),s=(this.assetFileEta.etaMs(t/(0,g.maxConcurrentImports)())??0)+(this.assetEta.etaMs(r)??0),n=[];t>0&&n.push(`Updating file metadata (${(0,b.fmt)(this.assetFilesUpdated)} processed, ${(0,b.fmt)(t)} remain)`),r>0&&n.push(`Refreshing assets and previews (${(0,b.fmt)(this.assetsUpdated)} processed, ${(0,b.fmt)(r)} remain)`);const a=t+r,o=this.assetFilesUpdated+this.assetsUpdated,l=(0,v.clamp)(0,100,Math.round(o/(a+o)*100)),u=(0,m.fmtEstimate)(s);(0,y.notBlank)(u)&&(e+=", "+u+"…"),i.dek=n,i.upsert({state:"processing",hed:e,completePct:l,incompletePct:100-l,scanningPct:0})}},a=function(){_.Task.ee.off("resolved",u(this,o,"f"))},l=async function(){this.logger.info("Starting library rebuild...");const e=p.Settings.forceFilters.getState();try{p.Settings.forceFilters.envValue=!0;const e=P.TaskList.instance(),t=await this.assetFileTodo(),i=await this.assetTodo();if(this.logger.info(".run()",{assetFileTodo:t,assetTodo:i}),0===t&&0===i)return;let s=!1;for(;!s;)s=(await(0,T.enqueueAssetFileUpdates)()).done,this.logger.info("run(): waiting for asset updates to complete..."),await e.awaitDrain(["updateAssetFile"],s?0:p.Settings.taskListCap.valueOrDefault/2);for(s=!1;!s;)s=(await(0,T.enqueueAssetUpdates)()).done,await e.awaitDrain(["repairAsset","assetPostUpsertTasks"],s?0:p.Settings.taskListCap.valueOrDefault/2);await u(this,r,"m",n).call(this,{done:!0,force:!0}),this.logger.info("rebuild complete!")}catch(e){(0,f.onError)("LibraryUpdater.run() failed",e)}finally{p.Settings.forceFilters.setState(e)}}},18209:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.enqueueAssetUpdates=t.outdatedAssetCount=t.enqueueAssetFileUpdates=t.outdatedAssetFileCount=t.currentUriRoots=void 0;const r=i(50213),s=i(45393),n=i(70417),a=i(45200),o=i(5696),l=i(7014),u=i(40958),c=i(45599),d=i(41400),h=i(20214),f=i(54993),m=i(43487),p=i(54017),g=i(94710),y=(0,c.defer)((()=>(0,r.mkLogger)("sync.UpdateQueue")));async function w(){return[...await(0,h.thenCollect)((0,l.volumes)(),(async e=>(0,a.nativePath2uri)(e.mountpoint,e))),o.PSLIB_ROOT_URI].map(f.toS)}t.currentUriRoots=w,t.outdatedAssetFileCount=async function(){const e=await w();return p.AssetFile.dbl.pluckFirstf((t=>t.count("AssetFile.id").distinct().where("version","!=",s.AssetFileVersion).andWhere((t=>e.forEach((e=>t.orWhereLike("AssetFile.uri",e+"%")))))))},t.enqueueAssetFileUpdates=async function(){const e=[];for(const t of await w())e.push(await p.AssetFile.dbl.batched({maxResults:g.Task.freeSlots(),onResults:async e=>{const t=[];for(const i of e)t.push({fn:"updateAssetFile",args:{assetFileId:i.id,path:await(0,a.uri2nativePath)(i.uri),skipAssetRepair:!0}});g.Task.add(t),y().info("Scheduled updateAssetFile",{tasks:t})},qb:(e,i)=>(e=e.select({id:"AssetFile.id",uri:"AssetFile.uri"}).distinct().orderBy("AssetFile.id","asc").where("AssetFile.version","!=",s.AssetFileVersion).andWhereLike("AssetFile.uri",t+"%"),(0,u.isNotEmpty)(i)&&(e=e.andWhere("AssetFile.id",">",(0,n.max)(i.map((e=>e.id))))),e)}));return y().tap({msg:"enqueueAssetFileUpdates",level:"info",result:{done:e.every((e=>e.done)),tasksAdded:(0,n.sumf)(e,(e=>e.resultCount))}})},t.outdatedAssetCount=async function(){const e=await w();return m.Asset.dbl.pluckFirstf((t=>t.count("Asset.id").distinct().leftJoin("AssetFile","AssetFile.assetId","Asset.id").where("Asset.version","!=",s.AssetVersion).andWhere((t=>e.forEach((e=>t.orWhereLike("AssetFile.uri",e+"%")))))))},t.enqueueAssetUpdates=async function(){const e=[];for(const t of await w())e.push(await m.Asset.dbl.pluckBatched({maxResults:g.Task.freeSlots(),onResults:e=>(g.Task.add(e.map((e=>({fn:"repairAsset",args:{assetId:e}})))),y().info("Scheduled repairAsset for ",{assetIds:e}),(0,d.delay)(1)),qb:(e,i)=>(e=e.select("Asset.id").distinct().leftJoin("AssetFile","AssetFile.assetId","Asset.id").orderBy("Asset.id","asc").where("Asset.version","!=",s.AssetVersion).andWhereLike("AssetFile.uri",t+"%"),(0,u.isNotEmpty)(i)&&(e=e.andWhere("Asset.id",">",(0,n.max)(i))),e)}));return y().tap({msg:"enqueueAssetUpdates",level:"info",result:{done:e.every((e=>e.done)),tasksAdded:(0,n.sumf)(e,(e=>e.resultCount))}})}},3996:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileFinder=t.isFileInSync=void 0;const o=i(19851),l=i(50213),u=i(79781),c=i(56519),d=i(56038),h=i(59189),f=i(38835),m=i(95696),p=i(48368),g=i(181),y=i(69589),w=i(28874),v=i(47783),b=i(87001),S=i(40958),P=i(76790),M=i(22573),_=i(42659),T=i(55835),E=i(31586),D=i(43487),k=i(54017);t.isFileInSync=async function(e){return new F(m.PosixFile.for(e)).alreadySynced()};const x=new h.SerialLaterQueue;class F{constructor(e,t=(0,y.forceContextOrSetting)()){this.file=e,this.ctx=t,r.set(this,void 0),s.set(this,new Set),this.alreadySynced=(0,d.timedLazy)("sync-file.AssetFileFinder.alreadySynced: "+this.file,(async()=>a(this,r,"f").tap({msg:"alreadySynced",result:null!=await this.priorIfSynced()}))),this.newAssetFile_=(0,d.timedLazy)("sync-file.AssetFileFinder.newAssetFile: "+this.file,(async()=>{const e=await(new k.AssetFile).updateFromFile_(this.file);return null==e?a(this,r,"f").throw("AssetFile.updateFromFile returned null",{fatal:!1}):e})),this.tags_=(0,o.lazy)((async()=>{const e=await(0,v.readTags)(this.file);if(null==e)throw new Error(this.file+" doesn't have metadata");return e})),this.imageHash=(0,o.lazy)((()=>w.Settings.useImageHashes.valueOrDefault?(0,p.imageHash)(this.file):void 0)),this.dominantLabhashes=(0,o.lazy)((()=>(0,c.thenMap)(this.imageHash(),(e=>(0,S.uniq)(e.dominantColors.filter((e=>e.pct>5)).map((e=>e.labhash))))))),this.capturedAtLocal=(0,o.lazy)((async()=>{const e=await this.capturedAt_();return a(this,r,"f").tap({msg:"capturedAtLocal",result:e?.local,meta:{capturedAt:e}})})),this.mapSibling=e=>this.newAssetFileForAsset(e?.getAsset()),this.apply_=(0,d.timedLazy)("sync-file.AssetFileFinder: "+this.file,(async()=>{if((0,M.blank)(await this.file.uri_()))throw new Error("Cannot import, file URI is blank for "+this.file);{const e=await this.byExistingAsset_();if(null!=e)return a(this,r,"f").info("Found existing asset for file"),e}const e=await this.newAssetFile_(),t=await x.enqueue((async()=>{const t=await this.byExistingAsset_();if(null!=t?.assetId)return a(this,r,"f").info("Found existing asset for file after acquiring lock",{withExistingAsset:t}),t.assetId;const i=new D.Asset;return i.capturedAtLocal=e.capturedAtLocal,i.addAssetFile(e),i.upsert(),i.id}));return e.assetId=t,e.upsert()})),this.byExistingAsset_=()=>(0,d.time)("sync-file.AssetFileFinder.byExistingAsset: "+this.file,(async()=>{const e=[{name:"byUri",f:()=>this.byUri()},{name:"byNormalizedPathUri",f:()=>this.newAssetFileForAsset(this.assetByNormalizedPathUri())},{name:"bySha",f:()=>this.newAssetFileForAsset(this.assetBySha())},{name:"hasTags",f:async()=>{await this.tags_()}},{name:"validFile",f:async()=>{await(0,g.throwIfInvalidFile_)(this.file)}},{name:"byCapturedAtOrImageHash",f:()=>this.newAssetFileForAsset(this.assetByCapturedAtOrImageHash())}];for(const{name:t,f:i}of e)try{const e=await(0,d.time)("sync-file.assetFileFinder."+t+": "+this.file,i);if(null!=e)return a(this,r,"f").info("apply(): "+t,{assetFileId:e.id,assetId:e.assetId}),e;a(this,r,"f").debug("apply(): "+t+": returned null")}catch(e){throw a(this,r,"f").debug("apply(): "+t+" rejected: "+e),e}})),n(this,r,(0,l.mkLogger)("sync-file.AssetFileFinder("+e.baseWithGrandparent+")"),"f")}async prior(){return this.byUri()}async priorIfSynced(){if(this.ctx.forceSync)return;const e=await this.prior();return!0===await(e?.matchesFile())?e:void 0}async newAssetFileForAsset(e){const t=await e;if(null!=t){if(null!=t.id){const e=await this.newAssetFile_();return t.addAssetFile(e),e.insert(),a(this,r,"f").debug("newAssetFileForAsset() upsert success!",{af:e}),e}a(this,r,"f").throw("newAssetFileForAsset(): given non-persisted Asset")}}async capturedAt_(){return(await this.tags_()).capturedAt}async byUri(e=this.file){const t=await e.uri_();if(null!=t)return k.AssetFile.ops().firstf((e=>e.whereIn("uri",[...(0,b.uriEncodingVariants)(t),this.file.fileuri()])));a(this,r,"f").warn("byUri() uri is null",{file:e})}async assetByNormalizedPathUri(){const e=await this.file.normalize();return e.nativePath===this.file.nativePath?void 0:(await this.byUri(e))?.getAsset()}assetBySha(){return(0,c.thenMap)(this.file.sha(),(e=>D.Asset.findFirstByFile((t=>t.where("AssetFile.sha",e)))))}async assetByCapturedAtOrImageHash(){const e=await this.capturedAt_();if(null==e)return a(this,r,"f").throw("Cannot import, capturedAt is null"+f.InternalErrorFlag);if(w.Settings.strictDeduping.valueOrDefault)return this.firstSimilarAsset(k.AssetFile.ops().allf((t=>t.where({capturedAtLocal:e.local}))));const t=w.Settings.maxContemporaryAdoptionAssets.valueOrDefault,i=()=>{let i=k.AssetFile.query();return(0,E.gt0)(t)&&(i=i.limit(t)),i.orderByRaw(`abs(capturedAtLocal - ${e.local})`)},s=Math.max(_.secondMs,w.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault);return(0,d.time)("sync-file.AssetFileFinder.assetByCapturedAtAndImageHash: "+this.file,(async()=>{{const t=e.localBoundaries({delta:s});if(null==t)a(this,r,"f").warn("Failed to fetch localBoundaries, cannot fetch similar assets by localtime",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("captured-at",i().whereBetween("capturedAtLocal",[t.start,t.end]))??(w.Settings.checkBasenameMatches.valueOrDefault?this.firstSimilarAssetByQuery("basename",i().whereILike("uri","%/"+this.file.name+"%")):void 0);if(null!=e)return e}}const t=await this.imageHash();if(null==t)return void a(this,r,"f").warn("assetByCapturedAtAndImageHash: no imageHash");const n=await this.dominantLabhashes();if((0,S.isNotEmpty)(n)){const t=e.localBoundaries({delta:4*s});if(null==t)a(this,r,"f").error("Failed to fetch localBoundaries, cannot fetch similar assets by wide localtime + image hash",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("wide captured-at and dominant color",i().whereBetween("capturedAtLocal",[t.start,t.end]).andWhere((e=>e.whereIn("mode0",n).orWhereIn("mode1",n).orWhereIn("mode2",n))));if(null!=e)return e}}return this.firstSimilarAssetByQuery("image hash",i().where("meanHash",t.meanHash).orWhere("diffHash",t.diffHash).orWhere("dctHash",t.dctHash))}))}async firstSimilarAssetByQuery(e,t){a(this,s,"f").size>0&&(t=t.whereNotIn("AssetFile.id",Array.from(a(this,s,"f"))));const i=await this.firstSimilarAsset(k.AssetFile.ops().all(t));return null!=i&&a(this,r,"f").info("Found similar asset by "+e,{result:i}),i}async firstSimilarAsset(e){const t=await this.newAssetFile_(),i=await this.capturedAtLocal();if(null==t)throw new Error("Failed to update from "+this.file);const n=(0,P.sortBy)(e.filter((e=>!a(this,s,"f").has(e.id))),(e=>[(0,T.mapOr)(i,(t=>Math.abs(e.capturedAtLocal-t)),-e.capturedAtLocal),e.id]));for(const e of n)if(null!=e){await e.getNativePath();const i=k.AssetFile.ops().findBy({assetId:e.assetId});await Promise.all(i.map((e=>e.getNativePath())));const n=(0,u.whyNotSameAsset)(t,e,i);if(null==n)return a(this,r,"f").info("Found sibling AssetFile",e),D.Asset.ops().findById(e.assetId);a(this,s,"f").add(e.id),a(this,r,"f").debug("Contemporary assetFile not similar: "+n,e?.uri)}}}t.AssetFileFinder=F,r=new WeakMap,s=new WeakMap},34274:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileImporter=t.importFileToResult_=void 0;const u=i(19851),c=i(50213),d=i(73568),h=i(38835),f=i(95696),m=i(62105),p=i(74128),g=i(181),y=i(69589),w=i(28874),v=i(40958),b=i(22573),S=i(38639),P=i(59455),M=i(64526),_=i(19113),T=i(94710),E=i(3996),D=i(90901);t.importFileToResult_=async function(e){const t=M.Library.instanceRequired_();return(0,p.syncReport)().wrap_({path:e.path,from:"AssetFileImporter",fn_:()=>new k(f.PosixFile.for(e.path),t.assetFileRepository(),e).apply_()})};class k{constructor(e,t,i){r.add(this),this.file=e,this.repo=t,this.start=Date.now(),s.set(this,void 0),n.set(this,void 0),this.whyRejected=(0,u.lazy)((async()=>{const e=[],t=await this.file.uri_();if(null==t)e.push("Cannot make URI"+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);else{if(!0===await this.file.isDeletedUri(t))e.push("File was deleted");else if(this.ctx.forceFilters||null==await this.prior()){const t=await(0,m.whyRejectFile)(this.file,(0,_.libraryFileFiltersFor)(this.file));null!=t&&e.push(t)}l(this,s,"f").throwIfAborted_();const i=await this.prior();if((0,v.isNotEmpty)(e)&&null!=i&&(l(this,s,"f").info("Deleting prior AssetFile",{rejected:e,prior:i}),i.delete(),this.ctx.skipAssetRepair?l(this,s,"f").info("Skipping asset repair",{assetId:i.assetId}):(l(this,s,"f").info("Scheduling asset repair",{assetId:i.assetId}),T.Task.addOne("repairAsset",{assetId:i.assetId,forceRebuildPreviews:(0,S.isTrue)(i.shown)}))),null!=i){const t=i.getAsset();null!=t?.deletedAt&&e.push("Asset is marked as deleted"),null!=t?.excludedAt&&e.push("Asset is marked as excluded")}if(l(this,s,"f").throwIfAborted_(),0===e.length&&(null==i||!await i.inSyncWithFile())){const t=await(0,g.whyInvalidFile)(this.file.nativePath);(0,b.blank)(t)||e.push(t)}}return e})),this.assetFile_=(0,u.lazy)((async()=>{const e=await l(this,n,"f").apply_(),t=e.getAsset();return l(this,s,"f").info("assetFileFinder.apply_() result",{asset:t,assetFile:e}),null==t?l(this,s,"f").throw("assetFile.getAsset() was null",{srcAssetFile:e}):null==t.id?l(this,s,"f").throw("repoAssetFile asset has null id",{asset:t}):e})),this.prior=(0,u.lazy)((()=>l(this,n,"f").prior())),this.apply_=(0,u.lazy)((()=>l(this,r,"m",a).call(this))),this.ctx=(0,y.forceContextOrSetting)(i),o(this,s,(0,c.mkLogger)("sync-file."+this.toString()),"f"),o(this,n,new E.AssetFileFinder(e,this.ctx),"f")}toString(){return"AssetFileImporter("+this.file.nativePath+")"}newAssetFile(){return l(this,n,"f").newAssetFile_()}}t.AssetFileImporter=k,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(){l(this,s,"f").throwIfAborted_();const e=await l(this,s,"f").tapAsync_({msg:"whyRejected",result:this.whyRejected(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if((0,v.isNotEmpty)(e)){const t=e.join(", ");return{path:this.file.nativePath,state:p.SyncFileStates.rejected,details:t}}l(this,s,"f").throwIfAborted_();const t=await l(this,s,"f").tapAsync_({msg:"prior()",result:this.prior(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if(null!=t&&await t.isNoop(this.ctx))return{path:this.file.nativePath,state:p.AssetFileSyncStates.noop,assetId:t.assetId,assetFileId:t.id,assetFile:t,asset:t.getAsset(),uri:t.uri};l(this,s,"f").throwIfAborted_();const i=await l(this,s,"f").tapAsync_({msg:"assetFile()",result:this.assetFile_(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if(null==i)return l(this,s,"f").throw("_apply(): unexpected null assetFile");const r=i.id;if(null==r)return l(this,s,"f").throw("_apply(): unexpected null assetFileId");const n=i.uri;if(null==n)return l(this,s,"f").throw("_apply(): unexpected null assetFile.uri");const a=i.getAsset();if(null==a)return l(this,s,"f").throw("_apply(): unexpected null assetFile.getAsset()");let o;await l(this,s,"f").tapAsync_({msg:"assetFile.upsertIfNeeded_()",result:i.upsertIfNeeded_(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault}),l(this,s,"f").throwIfAborted_();try{o=await(0,D.assetPostUpsertTasks_)({asset:a,...this.ctx})}catch(e){e instanceof d.AbortError?l(this,s,"f").warn("aborted (caller/process after me will complete)",{error:e}):l(this,s,"f").throw("Post-upsert tasks failed",{error:e})}return{path:this.file.nativePath,state:i.syncState??p.SyncFileStates.synced,assetId:a.id,assetFileId:r,assetFile:i,asset:a,uri:n,uris:[n,...(0,P.toA)(o?.newAssetFileUris)]}}},41844:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileRepository=t.mayCopyAssetsToLibrary=void 0;const u=i(50213),c=i(74128),d=i(81674),h=i(57902),f=i(4936),m=i(28874),p=i(47783),g=i(67083),y=i(16170),w=i(54979),v=i(98604),b=i(40958),S=i(22573),P=i(98553),M=i(89937),_=i(59455),T=i(54017),E=i(94710);t.mayCopyAssetsToLibrary=async function(){return m.Settings.copyAssetsToLibrary.valueOrDefault&&await(0,d.p)()},t.AssetFileRepository=class{constructor(e){r.add(this),this.originalsDir=e,this.logger=(0,u.mkLogger)("AssetFileRepository")}async shouldCopy(e){const t=await this.whyNotCopyFile(e);return this.logger.tap({level:"info",msg:"shouldCopy()",result:null==t,meta:{file:e?.nativePath,whyNot:t}})}async whyNotCopyFile(e){if(null==e||(0,S.blank)(e.nativePath))return"blank nativePath";if(!0!==m.Settings.copyAssetsToLibrary.value)return"copyAssetsToLibrary !== true";if(await(0,d.l)())return"no active subscription";if(await e.notExists({refresh:!0}))return"file doesn't exist";if(e.isDescendantOf(this.originalsDir))return e+" already contained by "+this.originalsDir;if(e.isDescendantOf(m.Settings.libraryDir.valueOrDefault))return e+" already contained by "+m.Settings.libraryDir.valueOrDefault;const t=await(0,w.readMimeType)(e);return null==t?"readMimeType("+e+") was null":(0,y.isMimeTypeIncluded)(t,m.Settings.copyToLibraryMimeTypes.values)?null:"mimetype "+t+" is not included in copyToLibraryMimeTypes"}async existingLibraryAssetFile(e){if(e.uri.startsWith(M.PS_LIBRARY_PROTOCOL))return e;const t=(0,b.uniqBy)((0,_.toA)(e.librarySiblings()?.filter((t=>t.sha===e.sha))).concat(T.AssetFile.sameAssetFileInLibrary(e)),(e=>e.id));for(const i of t)if(await i.exists()){if(i.assetId!==e.assetId){this.logger.warn("Existing library asset file with a matching SHA is associated to a different asset. Requesting repair of the two impacted assets.",{af:e,prior:i});const t=i.assetId;e.getAsset()?.addAssetFile(i),E.Task.addOne("repairAsset",{assetId:t,forceSync:!0})}return this.logger.info("whyNotCopyAssetFile("+e.uri+"): found existing db record",{af:e,prior:i}),i}return null}async findLibraryFileWithSameContents(e,t){if(await e.matchesContent(t))return t;let i=t.parent();for(;i.isSelfOrDescendantOf(this.originalsDir);){const t=i.childWithSameContents(e);if(null!=t)return t;i=i.parent()}}async importFile_(e){const t=await l(this,r,"m",s).call(this,e);return null!=t&&(await l(this,r,"m",n).call(this,e,t),await l(this,r,"m",o).call(this,e,t)),t}async maybeCopyToLibrary_(e,t){const i=Date.now(),s=await e.posixFile_();null==s&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): posixFile is null",{ignorable:!1,retriable:!1});{const e=await this.whyNotCopyFile(s);if(!(0,S.blank)(e))return this.logger.tap({level:h.LogLevels.info,msg:"maybeCopyToLibrary_(): not copying: "+e,result:void 0})}const a=e.getAsset();null==a&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): null asset");{const u=await this.existingLibraryAssetFile(e);if(null!=u){const e=await u.posixFile_();if(null!=e){const d=await l(this,r,"m",n).call(this,s,e),h=null!=await l(this,r,"m",o).call(this,s,e),f=null!=await u.upsertIfNeeded_(void 0,t);return!h&&(0,b.isEmpty)(d)&&!f||(0,c.syncReport)().onProgress({path:e.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.synced,details:"Found and synced prior replica already in your library "+(0,P.stringify)({src:s.nativePath,upsertNeeded:f,copiedSidecars:d,copiedInferredMetadata:h}),elapsedMs:Date.now()-i,url:(0,v.mkAssetUrl)(a.id)?.toString()}),u}this.logger.warn("existingLibraryAssetFile() returned an assetFile that could not be resolved to a PosixFile",{prior:u})}}const u=await this.importFile_(s);if(null==u)return void this.logger.info("importFile() returned null",{srcAssetFile:e});if(u.nativePath===s.nativePath)return void this.logger.info("importFile() returned the same nativePath as src",{srcAssetFile:e,dest:u});const d=await a.assetFileForFile_(u,{skipUpsert:!0});await d.updateFromShaSibling_(e);const f=d.upsert();return a.addAssetFile(d),(0,c.syncReport)().onProgress({path:u.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.copied,details:"Copied into your library from "+s.nativePath,elapsedMs:Date.now()-i,url:(0,v.mkAssetUrl)(a.id)?.toString()}),f}},r=new WeakSet,s=async function(e){const t=await(0,p.readCapturedAt)(e),i=(0,f.pathToLibraryAsset)(t?.date,e);if(this.logger.debug("importFile("+e+")",{capturedAt:t,assetPath:i}),null==i)throw new Error(e.nativePath+" failed to create a library path");const r=this.originalsDir.join(...i),s=await this.findLibraryFileWithSameContents(e,r);if(null!=s)return this.logger.debug("#importFile_("+e+"): found existing file",{src:e,existing:s}),s;const n=await r.ensureNew_();return this.logger.info("#importFile_("+e+"): copying...",{uniqDest:n,dest:r}),e.copyFile_(n)},n=async function(e,t){const i=await e.existingSidecars(),s=[];for(const e of i)s.push(await l(this,r,"m",a).call(this,e,t));return(0,b.compact)(s)},a=async function(e,t){for(const i of await t.existingSidecars())if(await(0,p.sidecarEql)(e,i))return void this.logger.info("handleSidecar(): metadata already exists.",{srcSidecar:e,destSidecar:i,dest:t});const i=await t.parent().join(t.name+e.ext).ensureNew_({emptyIsNew:!0});return e.copyFile_(i)},o=async function(e,t){if(null==e||null==t||e.eql(t))return;const i=await(0,p.readTags)(e);if(null!=i)return(0,g.ensureInferredHistoryRecords)(e,await t.sidecar(),i.inferred);this.logger.warn("#handleInferred(): Failed to read tags from "+e,{dest:t})}},90901:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetPostUpsertTasks_=t.assetPostUpsertTasks=void 0;const r=i(50213),s=i(92434),n=i(73568),a=i(99331),o=i(39250),l=i(38835),u=i(57159),c=i(48604),d=i(66106),h=i(69589),f=i(40958),m=i(45599),p=i(23838),g=i(31586),y=i(64526),w=i(88224),v=i(43487),b=i(41844),S=i(68640),P=(0,m.defer)((()=>(0,r.mkLogger)("sync-file.AssetPostUpsertTasks"))),M=(0,m.defer)((()=>new o.LastOneInWins("Asset tasks")));async function _(e){const t=e,i=e,r=(0,g.toGt0)(t.asset?.id)??(0,g.toGt0)(i.assetId);if(null==r)throw new Error("assetPostUpsertTasks_(): unexpected null assetId"+l.InternalErrorFlag);const o=(0,h.forceContextOrSetting)(e),m=P().addContext(`.postUpsertAssetTasks_(Asset:${r})`);if(m.abortable=o.halt,o.skipPreviews&&o.skipAssetTagging)return void m.info("skipped (skipPreviews && skipAssetTagging)");const _=t.asset??v.Asset.ops().findById(r);if(null==_)return m.throw("unexpected null asset",{asset:_});try{return await M().enqueue({key:r,abortable:m.abortable,fn:()=>async function(e,t,i){const r=(0,h.forceContextOrSetting)(i),n=t.id,a=t.getAssetFiles({refresh:!0}),o={newAssetFileUris:[],previewsUpdated:!1,tagResult:void 0,transcoded:!1};if(e.throwIfAborted_(),(0,f.isEmpty)(a)&&(await v.Asset.remove({assetId:n,blocklistShas:!1,unlinkAssetFiles:!1}),e.throw(`Asset:${n} had no asset files. Deleted.`)),await(0,b.mayCopyAssetsToLibrary)())for(const[t,i]of(0,p.groupBy)(a,(e=>e.sha)).entries()){e.throwIfAborted_();try{for(const r of i)r.isInLibrary()&&await r.exists()&&e.debug("no-op for file SHA: already in library.",{sha:t,uri:r.uri});for(const e of i)if(await e.exists()){const t=await y.Library.instanceRequired_().assetFileRepository().maybeCopyToLibrary_(e,r);if(null!=t){o.newAssetFileUris.push(t.uri);continue}}}catch(r){e.warn("Failed to copy variation to library, but we'll try to continue",{sha:t,uris:i.map((e=>e.uri)),error:r})}}e.throwIfAborted_();const l=r.skipPreviews?void 0:await(0,S.updateAssetPreviews_)({asset:t,assetFiles:t.getAssetFiles(),...r}),u=await async function(e,t){if((0,g.gt0)(t?.assetFileId)){const i=e.getAssetFiles({refresh:!0}).find((e=>e.id===t?.assetFileId));return null==i?P().throw("AssetPreviewInfo referenced unknown assetFileId",{asset:e,info:t}):i}const i=e.getShown();return null!=i?i:(0,s.bestExistingAssetFile)(e.getAssetFiles())}(t,l);if(null==u)return e.throw("null primaryOrShownAssetFile_()",{asset:t});const m=await u.posixFile_();if(!0!==r.skipPreviews&&t.isVideo()){if(null==m)return e.throw("null primary.posixFile()",{asset:t,assetFiles:t.getAssetFiles()});o.transcoded=null!=await(0,d.transcode_)(m,c.Previews.instance().ap(n).mp4(),{force:r.forceRebuildPreviews,halt:r.halt})}return e.throwIfAborted_(),t.markShownAndUpsert_(u),r.skipAssetTagging?e.info("skipping asset tagging"):o.tagResult=await(0,w.tagAndUpsertAsset_)(t),o}(m,_,{...e,...o})})}catch(e){if(e instanceof n.AbortError)return void m.warn("aborted, next caller will clean up my mess",{error:e});const t=[e];if(!(0,a.ending)()){m.error("failed, marking asset unshown",{error:e});try{_.markUnshownAndUpsert()}catch(e){m.error("failed to mark asset unshown",{upsertError:e}),t.push(e)}}throw new u.WrappedError("Failed to post-process assset "+_.id,{causes:t})}}t.assetPostUpsertTasks=function(e){try{return _(e)}catch(e){if(e instanceof n.AbortError)return void P().warn("aborted, next caller will clean up my mess",{error:e});throw e}},t.assetPostUpsertTasks_=_},61989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAsset_=t.updateAsset=void 0;const r=i(48884),s=i(50213),n=i(45393),a=i(79184),o=i(79781),l=i(92434),u=i(56519),c=i(70417),d=i(69589),h=i(28874),f=i(40958),m=i(22573),p=i(38639),g=i(50357),y=i(43487),w=i(54017),v=i(90901);async function b(e){const t=(0,d.forceContextOrSetting)(e),i=e.assetId,r=(0,s.mkLogger)(`sync-file.UpdateAsset(${i})`);r.abortable=t.halt;const b=y.Asset.ops().findById(i);if(null==b)return r.throw("no such asset");const P=b.getAssetFiles({refresh:!0});if((0,f.isEmpty)(P))return r.warn("No asset files: deleting."),b.delete(),{asset:b,rejected:"Empty asset (no AssetFiles)"};const M=b.$clone(),_=b.getShown()?.$clone();for(const e of P)r.throwIfAborted_(),await e.upsertIfNeeded_(void 0,t);P.some((e=>(0,p.isTrue)(e.deleted)||(0,m.notBlank)(e.rejected)))&&b.clear(),await S(r,P);const T=(0,l.sortAssetFiles)(P),E=T?.[0];if((0,f.isEmpty)(T)||null==E)return r.warn("No existing files. Skipping for now."),b.markUnshownAndUpsert(),{asset:b,rejected:"Empty asset (no AssetFiles after sorting). Un-showing Asset:"+i};if(!E.isVersionUpToDate())return r.warn("Best file needs update, and we already tried to update all files. Skipping this asset.",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, could not be updated. Un-showing Asset:${i}`};const D=await E.capturedAt();if(null==D)return r.warn("Best file failed to extract a captured-at",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, failed to extract a captured-at. Un-showing Asset:${i}`};const k=new Set,[x,F]=await(0,u.partitionAsync)(T,(e=>(0,o.isSimilarAssetFile)(e,E)));if(r.throwIfAborted_(),(0,f.isNotEmpty)(F)){const e=await(0,a.aggregateAssetFiles)(F);for(const t of e){if((0,f.isEmpty)(t))continue;const e=y.Asset.ops().insertOne({capturedAtLocal:t[0].capturedAtLocal,shown:!1,version:0});k.add(e.id);for(const i of t)e.addAssetFile(i);w.AssetFile.dbl.runf((i=>i.update({assetId:e.id,shown:0}).whereIn("id",(0,f.compact)(t.map((e=>e.id)))))),r.info("Pushed rejected asset files into new asset",{rejectAssetId:e.id,rejectCluster:t.map((e=>({id:e.id,uri:e.uri})))})}}function C(e){return(0,f.uniq)(x.map((t=>t[e])))}const A=await Promise.all(x.map((e=>e.capturedAt()))),I=h.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,O=A.map((e=>e?.localBoundaries({delta:I}))),L=(0,c.min)(O.map((e=>e?.start)))??D.localBoundaries({delta:I})?.start,R=(0,c.max)(O.map((e=>e?.end)))??D.localBoundaries({delta:I})?.end,N=w.AssetFile.ops().all(w.AssetFile.query().limit(h.Settings.maxContemporaryAdoptionAssets.valueOrDefault).orderByRaw(`abs(AssetFile.capturedAtLocal - ${E.capturedAtLocal})`).select("AssetFile.*").distinct().join("Asset","Asset.id","AssetFile.assetId").where("AssetFile.assetId","!=",i).andWhere("Asset.version","!=",n.AssetVersion).andWhere((e=>(e=e.whereIn("AssetFile.sha",C("sha")),null==L||null==R?r.warn("external asset file check: unset start or end localtime boundary",{capturedAts:A,startBoundary:L,endBoundary:R}):e=e.orWhereBetween("AssetFile.capturedAtLocal",[L,R]),e.orWhereIn("AssetFile.meanHash",C("meanHash")).orWhereIn("AssetFile.diffHash",C("diffHash")).orWhereIn("AssetFile.dctHash",C("dctHash"))))));r.throwIfAborted_(),r.info("asset file candidates for adoption: ",N.map((e=>e.posixPathFromGrandparent)));const B=[];for(const e of N){r.throwIfAborted_();try{await e.updateFromFile_(),(0,o.isSimilarAssetFile)(e,E)&&(r.info("adopting similar asset file",{af:e}),k.add(e.assetId),e.shown=!1,b.addAssetFile(e),e.upsert(),B.push(e))}catch(t){r.warn("Error updating external asset file. Leaving asset file record as-is.",{af:e,error:t})}}r.info("fetched expansion",{retainAFs:x.map((e=>e.id)),rejectAFs:F.map((e=>e.id)),externalAssetFiles:N.map((e=>e.posixPathFromGrandparent)),similarAssetFiles:B.map((e=>e.posixPathFromGrandparent))}),await S(r,[...x,...B]),t.skipPreviews&&t.skipAssetTagging?(r.info("skipping previews and tagging",t),b.upsert()):await(0,v.assetPostUpsertTasks_)({...t,asset:b});const j=!(0,g.eql)(M,b),z=!(0,g.eql)(_,b.getShown()),V=!(j||z||t.forceRebuildPreviews||t.forceSync);return r.tap({msg:"updateAsset() result",level:"info",result:{asset:b,assetIdsToUpdate:Array.from(k),assetFiles:b.assetFiles,skipped:V},meta:{ctx:t,assetChanged:j,primaryAssetFileChanged:z}})}async function S(e,t){const[i,s]=(0,r.partition)(t,(e=>e.isVersionUpToDate()));for(const t of s){e.throwIfAborted_();const r=i.find((e=>e.sha===t.sha));if(null!=r){e.info("backfilling",{sibling:r,dest:t});const i=await t.updateFromShaSibling_(r);null!=i&&i.upsert()}}}t.updateAsset=async function(e){try{const t=await b(e);return{id:e.assetId,skipped:null==t?.asset,...t}}catch(t){return{id:e.assetId,error:t}}},t.updateAsset_=b},93755:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetFileIfNeeded=t.handleAssetFileUriChange=t.updateAssetFile_=t.updateAssetFile=void 0;const r=i(50213),s=i(92434),n=i(98314),a=i(74128),o=i(69589),l=i(87001),u=i(40958),c=i(22573),d=i(68708),h=i(43487),f=i(54017),m=i(94710);async function p(e){const t=Date.now(),i=e,s=e,n=s.af?.id??i.assetFileId,u=(0,r.mkLogger)(`updateAssetFile(${n})`),d=s.af??f.AssetFile.ops().findById(n);if(null==d)return u.throw("db record not found",{assetFileId:n});const h=await d.posixFile_(),p=(0,o.forceContextOrSetting)(e),w={id:n,assetFileId:n,path:h?.nativePath,uri:d?.uri};if(null==h)return{...w,error:"file for URI not found"};const v=await(h?.isDeletedUri(d.uri));if(null==v)return u.info("no-op: file URI points to an unmounted volume",w),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:"volume is not currently mounted",state:a.SyncFileStates.skipped}),{...w,skipped:!0};const b=e.whyReject??await d.whyRejected();if(v||!(0,c.blank)(b)){const e={...w,rejected:b,deleted:v};return u.warn("file was deleted or rejected. Deleting.",e),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:v?"file no longer exists":"rejected: "+b,state:a.SyncFileStates.deleted}),d.delete(),!0!==p.skipAssetRepair&&m.Task.addOne("repairAsset",{assetId:d.assetId}),e}const S=await h.uri_();if(!await(0,l.uriIsEquivalent)(S,d.uri)){const e=await g(d,S,p);if(null!=e)return{...w,...e}}return!p.forceSync&&await d.matchesFile()?(u.info("no-op: file already matches db record",w),d.touch(),{...w,skipped:!0}):{...w,...await y(d,p)}}async function g(e,t,i){const n=(0,r.mkLogger)(`handleAssetFileUriChange(${e.id})`),a=(0,u.uniq)([...(0,l.uriEncodingVariants)(e.uri),...(0,l.uriEncodingVariants)(t)]);n.warn("URI is changing. Avoiding duplicate keys.",{priorUri:e.uri,variants:a});const o=f.AssetFile.ops().allf((t=>t.whereIn("uri",a).andWhereNot({id:e.id})));if((0,u.isNotEmpty)(o)){n.warn("Found other AssetFiles with equivalent URIs.",{afIds:o.map((e=>e.id))});const t=[e,...o],r=(0,s.sortAssetFiles)(t);if((0,u.isEmpty)(r))return n.warn("sortAssetFiles returned undefined",{arr:t.map((e=>(0,d.pick)(e,"id","uri"))),variants:a}),{error:"sortAssetFiles returned undefined"};const l=t.map((e=>e.id));for(const e of r)if(await e.exists()){f.AssetFile.dbl.runf((t=>t.whereIn("id",l.filter((t=>t!==e.id))).delete()));const r=y(e,i);return h.Asset.dbl.runf((e=>e.update({version:0,updatedAt:Date.now()}).whereIn("id",(0,u.uniq)(t.map((e=>e.assetId)))))),r}}n.info("no-op, no duplicate URIs.")}async function y(e,t){const i=Date.now();return null!=await e.upsertIfNeeded_(void 0,t)&&h.Asset.touch([e.assetId]),(0,a.syncReport)().onProgress({path:await e.getNativePath(),elapsedMs:Date.now()-i,from:"updateAssetFileIfNeeded()",state:e.syncState??a.SyncFileStates.unknown}),{assetFileId:e.id}}t.updateAssetFile=async function(e){try{return await p(e)}catch(t){return{id:e.assetFileId,...e,error:(0,n.errorToS)(t)}}},t.updateAssetFile_=p,t.handleAssetFileUriChange=g,t.updateAssetFileIfNeeded=y},68640:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetPreviews_=void 0;const r=i(99331),s=i(38835),n=i(48604),a=i(50213),o=i(69589),l=i(87001),u=i(40958),c=i(45599),d=i(50357),h=i(31586),f=i(68708),m=i(59455),p=i(43487),g=(0,c.defer)((()=>(0,a.mkLogger)("sync-file.UpdateAssetPreviews")));t.updateAssetPreviews_=async function(e){const t=e.assetId??e.asset?.id??(0,m.toA)(e.assetFiles).find((e=>(0,h.gt0)(e.assetId)))?.assetId,i=(0,o.forceContextOrSetting)(e),a=g().addContext(".Asset:"+t);if(i.skipPreviews)return void a.warn("skipPreviews is true: no-op");if(!(0,h.gt0)(t))return a.throw("invalid assetId",{assetId:t});const c=e.asset??p.Asset.ops().findById(t);if(null==c)return a.throw("Asset:"+t+" not found");a.throwIfAborted_(i.halt);try{const e=await c.getExistingAssetFiles();if((0,u.isEmpty)(e))return void a.warn("no existing assetFiles",{asset:c});const r=n.Previews.instance().ap(t),o=await r.readInfo();a.throwIfAborted_(i.halt);const h=await(0,n.buildAssetPreviews_)({...i,assetId:t,assetFiles:e}),m=e.find((e=>e.id===h?.assetFileId))??e.find((e=>(0,l.uriIsEquivalent)(h?.uri,e.uri)));a.info("buildAssetPreviews_()",{result:h,primaryAssetFile:m});const p=await(m?.posixFile_());if(null==m||null==p||!0!==await(p?.exists()))return a.throw("buildAssetPreviews_() returned invalid assetFileId"+s.InternalErrorFlag,{newInfo:h,assetFiles:e.map((e=>(0,f.pick)(e,"id","uri"))),primaryAssetFile:m,primaryPosixFile:p});const g=(0,d.eql)(o,h),y=null==h||g;return{...h,noop:y}}catch(e){throw(0,r.ending)()||(a.warn("Failed to update previews. Un-showing asset "+t,{error:e}),c.markUnshownAndUpsert()),e}}},34742:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});try{i(93944).install()}catch{}const r=i(69554),s=i(38790),n=i(53978),a=i(43380),o=i(43334),l=i(28874),u=i(5670),c=i(21200),d=i(2775),h=i(31503),f=i(12195),m=i(52288),p=i(53767);!async function(){if(o.isElectron)new p.SyncService;else{const e=await new r.CLI(u.ServiceNames.sync,"[files-or-directories...]","If paths are provided on the command line, they should be fully-qualified.\n\n* Paths to directories will be scanned recursively.\n* Paths to files will be imported if they pass configured filters.\n\nNote that sync will spawn 1 or more `worker` processes to work in parallel.").add(m.RebuildArg,d.ForceArg,n.TimingArg,f.NoFilterArg,c.ExitWhenDoneArg,a.WriteSettingsArg,h.LogArgs,s.ColorArgs).parse();l.Settings.argvScanPaths.envValue=e.args,new p.SyncService}}()},94019:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathsToSync=t.scanPaths=t.logger=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(87290),o=i(34102),l=i(16287),u=i(45969),c=i(43334),d=i(28874),h=i(45200),f=i(69375),m=i(7014),p=i(41400),g=i(31586),y=i(92244),w=i(46832);t.logger=(0,r.lazy)((()=>(0,s.mkLogger)("sync.PathsToSync")));const v=(0,r.lazy)((async()=>{const e=[];for(const t of await(0,m.volumes)()){if(!0===t.ignorable||!1===t.ok||(c.isMac||(0,u.isDocker)())&&"/"===t.mountpoint||(0,f.isExcludedMountpoint)(t.mountpoint)||!(0,g.gt0)(t.size))continue;const i=await(0,w.toUriPath)(t.mountpoint,(0,h.nativePath2uri)(t.mountpoint,t));null!=i&&e.push(i)}return e}));async function b(){const e=[],i=[],r=d.Settings.argvScanPaths.toNotEmpty()??d.Settings.scanPaths.values;for(const s of r)if(await(0,l.isReadableDirectory)(s)){const r=await(0,w.toUriPath)(s);null==r?(e.push(s),(0,t.logger)().warn("Ignoring scanPath element: failed to create URI path",s)):i.push(r)}else(0,t.logger)().warn("Ignoring scanPath element: not readable directory",s);return{result:i,noUriPaths:e}}t.scanPaths=b,(0,p.later)((()=>{(0,o.ee)().on("volumesChanged",(()=>{v.unset()}))})),t.pathsToSync=async function(){const e=[];if(d.Settings.argvScanPaths.isNotEmpty()){for(const i of d.Settings.argvScanPaths.values){const r=await(0,w.toUriPath)(i);null!=r?e.push(r):(0,t.logger)().warn("pathsToSync(): Ignoring scanPath element: failed to create URI path",i)}return e}e.push(...(await b()).result),!0===d.Settings.scanAllDrives.value&&e.push(...await v());const i=await(0,n.thenMapOr)((0,a.libraryOriginalsDirPosixFile)(),w.posixFileToUriPath,(()=>(0,t.logger)().throw("libraryOriginalsDir was null",{libraryDir:d.Settings.libraryDir.valueOrDefault,originalsDir:d.Settings.originalsDir.value})));d.Settings.scanLibraryFirst.valueOrDefault&&e.unshift(i),d.Settings.scanLibraryLast.valueOrDefault&&e.push(i);const r=await(0,n.filterAsync)({name:"pathsToSync",arr:e,f:e=>!y.nativePathBlocklist.has(e.nativePath)&&(0,l.isReadableDirectory)(e.nativePath)});return(0,t.logger)().info("pathsToSync",r),r}},76907:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.precheckFiles=void 0;const r=i(50213),s=i(98314),n=i(74128),a=i(69589),o=i(45200),l=i(98604),u=i(22573),c=i(45599),d=i(54017),h=(0,c.defer)((()=>(0,r.mkLogger)("sync.PrecheckFiles"))),f="AssetFilePrecheck";async function m(e,t){const i=(await(0,o.nativePath2uri)(e.nativePath)).toString(),r=d.AssetFile.ops().firstf((e=>e.where({uri:i})));if(null==r)return(0,n.syncReport)().onProgress({path:e.nativePath,from:f,state:n.SyncFileStates.enqueued,details:"Path is new to the library. Scheduling import."}),!0;const s=await r.whyNotNoop(t);return(0,u.blank)(s)?((0,n.syncReport)().onProgress({path:e.nativePath,from:f,state:n.SyncFileStates.noop,details:"in sync",url:(0,l.mkAssetUrl)(r.assetId)?.toString()}),r.touch(),!1):((0,n.syncReport)().onProgress({path:e.nativePath,from:f,state:n.SyncFileStates.enqueued,details:"update needed: "+s,url:(0,l.mkAssetUrl)(r.assetId)?.toString()}),!0)}t.precheckFiles=async function(e,t=(0,a.forceContextOrSetting)()){const i=[];for(const r of e)try{await m(r,t)&&(h().debug("precheckFiles(): stale path",{nativePath:r.nativePath}),i.push(r))}catch(e){h().info("precheckFiles(): failed to check path",{nativePath:r.nativePath,error:e}),(0,n.syncReport)().onProgress({path:r.nativePath,from:f,state:n.SyncFileStates.rejected,details:(0,s.errorToS)(e)})}return i}},63461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncCompleted=void 0,t.SyncCompleted={syncCompleted:!0}},98622:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runTimeIsStale=t.SyncCron=void 0;const r=i(28874),s=i(41400),n=i(30301),a=i(31586);t.SyncCron=(0,n.lazy)((()=>r.Settings.syncCron.cron({timezone:r.Settings.syncCronTZ.value}))),(0,s.later)((()=>{r.Settings.syncCron.watchLater((()=>t.SyncCron.unset())),r.Settings.syncCronTZ.watchLater((()=>t.SyncCron.unset()))})),t.runTimeIsStale=function(e){return null==e||(0,a.lte)((0,t.SyncCron)().nextRun(new Date(e))?.getTime(),Date.now())}},56179:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},f=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncDirectory=t.DefaultFileHandler=void 0;const m=i(89788),p=i(19851),g=i(50213),y=i(7282),w=i(45255),v=i(81168),b=i(73568),S=i(83412),P=i(99331),M=i(98314),_=i(38835),T=i(60652),E=i(29882),D=i(74128),k=i(76752),x=i(70417),F=i(28874),C=i(14036),A=i(69385),I=i(15674),O=i(22573),L=i(38639),R=i(42659),N=i(45599),B=i(55835),j=i(31586),z=i(68708),V=i(12168),W=i(54993),U=i(35580),q=i(54017),H=i(20958),G=i(49796),$=i(55009),J=i(94710),K=i(76907);async function Z(e){const t=await(0,K.precheckFiles)(e);J.Task.add(t.map((e=>({fn:"syncFile",args:{path:e.nativePath}}))))}t.DefaultFileHandler=Z;class Y extends S.DoneWrapper{static async for({root:e,rootUri:t,fileHandler:i=Z}){const r=await e.directoryEntry();if(null!=r&&r.isDirectory())return new Y(e,r,t,i);(0,g.mkLogger)("sync.DirectorySync").error("Cannot sync "+e+": it's not a directory (or not readable)",{root:e,rootUri:t})}constructor(e,t,i,d){super("sync.DirectorySync("+e+")",(()=>h(this,r,"m",s).call(this))),r.add(this),this.root=e,this.rootDirent=t,this.rootUri=i,this.fileHandler=d,this.start=Date.now(),this.eta=new k.ETA,this.recentlyScannedDirs=new m.BoundedList(10),this.progress=(0,N.defer)((()=>this.logger.tap({msg:".progress()",level:"warn",result:G.Progress.insertNew({uri:this.rootUri,volume:this.root.nativePath})}))),this.forceDirectoryScan=(0,N.defer)((()=>{const e=F.Settings.forceSync.valueOrDefault,t=F.Settings.argvScanPaths.values.some((e=>this.root.eql(e)));return this.logger.tap({msg:"forceDirectoryScan",result:e||t,meta:{forceSync:e,isArgvPath:t}})})),this.initialMeta=(0,N.defer)((()=>this.forceDirectoryScan()?void 0:this.progress().getMetaAsRecord())),this.minPriorCreatedAt=(0,N.defer)((()=>(0,x.max)([H.Operation.getFirstPendingOp({name:"forceRestartSync"})?.createdAt,(0,G.defaultMinCreatedAt)()]))),this.priorMeta=(0,N.defer)((()=>this.progress().getPriorIncomplete(this.minPriorCreatedAt())?.getMetaAsRecord())),this.priorScannedDir=(0,N.defer)((()=>this.priorMeta()?.lastScannedDirectory)),this.priorScannedDirsCount=(0,N.defer)((()=>(0,j.toInt)(this.priorMeta()?.scannedDirectoryCount)??0)),this.priorProcessedImageCount=(0,N.defer)((()=>(0,j.toInt)(this.priorMeta()?.processedImageCount)??0)),this.priorProcessedVideoCount=(0,N.defer)((()=>(0,j.toInt)(this.priorMeta()?.processedVideoCount)??0)),this.scannedDirsCount=0,n.set(this,0),a.set(this,0),this.priorEnqueuedStaleFiles=(0,N.defer)((()=>(0,L.isTrue)(this.priorMeta()?.enqueuedStaleFiles)??!1)),this.enqueuedStaleFiles=!1,this.completed=!1,this.upsertProgressMeta=(0,p.lazy)((()=>{const e=this.progress().getMetaAsRecord(),t={lastScannedDirectory:this.recentlyScannedDirs.at(-1)??this.priorScannedDir()??"",scannedDirectoryCount:(0,W.toS)(this.scannedDirectoryCount()),completedDirectoryScan:(0,W.toS)((0,L.isTrue)(this.priorMeta()?.completedDirectoryScan)||(h(this,o,"f").call(this)?.isDone()??!0)),enqueuedStaleFiles:(0,W.toS)(this.priorEnqueuedStaleFiles()||this.enqueuedStaleFiles),processedImageCount:(0,W.toS)(this.processedImageCount()),processedVideoCount:(0,W.toS)(this.processedVideoCount()),completedDirectorySync:(0,W.toS)((0,L.isTrue)(e.completedDirectorySync)||this.completed)};this.progress().setMetaRecord(t)}),(0,y.isTest)()?100:R.secondMs),this.directoryListener=e=>{null==e||(0,O.blank)(e.nativePath)?this.logger.warn("directoryListener() called with blank dir"+_.InternalErrorFlag,{dir:e}):(this.scannedDirsCount++,this.recentlyScannedDirs.push(e.nativePath),this.logger.debug("directoryListener()",{scannedDirsCount:this.scannedDirsCount,dir:e.nativePath}),this.upsertProgress({force:!0}))},o.set(this,(0,N.defer)((()=>(0,L.isTrue)(this.priorMeta()?.completedDirectoryScan)?void 0:new T.DirectoryIterator(this.rootDirent,this.ctx())))),this.pendingCount=(0,p.lazy)((()=>J.Task.countByFn("syncFile")),R.secondMs),l.set(this,((e,t,i)=>{if("syncFile"===e.fn){const t=e;this.onFileResolved(t.args.path,i)}else this.logger.info("onTaskResolve() non-syncFile task",{task:e,result:t,elapsedMs:i})})),u.set(this,((e,t)=>{this.logger.error("onTaskRejected()",{task:e,error:t})})),this.doneLatch.observe(h(this,r,"m",c).call(this)).catch((t=>{this.logger.error("SyncDirectory failed for "+e,{error:t}),(0,D.syncReport)().onProgress({path:e.nativePath,from:"SyncDirectory",state:t instanceof b.AbortError?"canceled":"failed",details:(0,M.errorToS)(t)})}))}upsertProgress(e){const t=h(this,r,"m",d).call(this,e);if(this.logger.info("upsertProgress()",{update:t}),null!=t){const e=this.progress().upsert(t);return this.upsertProgressMeta(),e}}scannedDirectoryCount(){return this.priorScannedDirsCount()+this.scannedDirsCount}ctx(){return{startAtNativePath:(0,B.map)(this.initialMeta()?.lastScannedDirectory,E.splitNativePath),hasCapacity:()=>U.TaskList.instance().hasCapacity(),fileHandler:this.fileHandler,directoryListener:this.directoryListener,ended:()=>(0,P.ending)()||this.ended}}earliestStartTime(){return this.progress().getLastIncompleteStartAt()??this.start}async maybeEnqueueStaleAssetFiles_(){if(!F.Settings.forceSync.valueOrDefault&&(0,L.isTrue)(this.priorMeta()?.enqueuedStaleFiles))this.logger.info("maybeEnqueueStaleAssetFiles() no-op: prior enqueuedStaleFiles.");else{const e=this.progress(),t=this.earliestStartTime(),i=U.TaskList.instance();this.logger.info("maybeEnqueueStaleAssetFiles() starting",{earliestStartTime:t});const r=Math.min(Math.round(F.Settings.taskListCap.valueOrDefault/4),F.Settings.dbBatchSelectSize.valueOrDefault),s=F.Settings.taskListCap.valueOrDefault-r;let n=0;await q.AssetFile.ops().batched({batchSize:r,onResults:async e=>{this.logger.throwIfAborted_(),await Promise.all(e.map((e=>e.getNativePath()))),J.Task.add(e.map((e=>({fn:"updateAssetFile",args:{path:e.nativePath,assetFileId:e.id,whyReject:"missed by directory sync"}})))),n+=e.length,await i.awaitDrain([],s)},qb:e=>e.select("id").whereLike("uri",this.rootUri+"%").andWhere("updatedAt","<",t)}),this.logger.info("maybeEnqueueStaleAssetFiles() finished enqueue",{assetFileQueuePendingCount:n}),e.setMeta($.ProgressMetaNames.enqueuedStaleFiles,"true")}}processedCount(){return this.processedImageCount()+this.processedVideoCount()}processedVideoCount(){return this.priorProcessedVideoCount()+h(this,a,"f")}processedImageCount(){return this.priorProcessedImageCount()+h(this,n,"f")}onFileResolved(e,t){var i,r;(0,C.isVideoExt)(e)?f(this,a,(i=h(this,a,"f"),++i),"f"):f(this,n,(r=h(this,n,"f"),++r),"f"),this.eta.push(t),this.upsertProgress()}get isScanning(){const e=h(this,o,"f").call(this);return null!=e&&!e.isDone()}estimatedScannedPct(){if(!this.isScanning)return 100;const e=100/-(this.scannedDirsCount/500+1)+100;return(0,j.sigFigs)(e,3)}percents(){if(this.completed||this.isDone())return{completePct:100,incompletePct:0,scanningPct:0};const e=(0,j.round)(this.estimatedScannedPct()),t=100-e,i=this.processedCount(),r=this.pendingCount(),s=0===r&&0===i?0:(0,j.round)(e*(i/(r+i))),n=100-(s+t),a={completePct:s,incompletePct:n,scanningPct:t};return this.logger.debug("percents(): ",{scannedPct:e,processed:i,pending:r,p:a}),100!==(0,x.sum)([a.completePct,a.incompletePct,a.scanningPct])&&this.logger.warn("percents(): BUGGED",{p:a,processed:i,pending:r,scannedPct:e,scanningPct:t,incompletePct:n,completePct:s}),a}}t.SyncDirectory=Y,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,r=new WeakSet,s=function(){J.Task.ee.off("resolved",h(this,l,"f")),J.Task.ee.off("rejected",h(this,u,"f"))},c=async function(){J.Task.ee.on("resolved",h(this,l,"f")),J.Task.ee.on("rejected",h(this,u,"f"));const e=this.initialMeta();this.logger.info("setup()",{meta:e});const t=U.TaskList.instance(),i=h(this,o,"f").call(this);if(null==i)this.logger.info("#run(): already completedDirectoryScan");else{this.logger.info("#run(): starting directory scan...");const e=Math.round(F.Settings.taskListCap.valueOrDefault),r=Math.max(2*(0,I.maxConcurrentImports)(),Math.round(F.Settings.taskListCap.valueOrDefault/2));for(;!i.isDone();)await this.awaitOrAbort((0,A.resolveOnResume)()),await i.next(w.ShortCommandTimeoutMs+Date.now()),t.hasCapacity(.9*e)||await this.awaitOrAbort(t.awaitDrain(["syncFile"],r));(0,D.syncReport)().onProgress({from:"SyncDirectory",state:"note",details:"Directory scan complete",path:this.root.nativePath,elapsedMs:Date.now()-this.start}),this.upsertProgress({force:!0})}await this.awaitOrAbort(t.awaitDrain()),(0,D.syncReport)().onProgress({from:"SyncDirectory",state:"note",details:"File imports complete: "+this.processedImageCount()+" images and "+this.processedVideoCount()+" videos",path:this.root.nativePath,elapsedMs:Date.now()-this.start}),await this.awaitOrAbort(this.maybeEnqueueStaleAssetFiles_()),await this.awaitOrAbort(t.awaitDrain()),this.ended||this.aborted||(this.logger.info("DONE! Marking Progress as complete and updating meta."),this.completed=!0,this.upsertProgress({force:!0,done:!0}))},d=function(e={}){const t=e.prior??{},i={},r=this.isDone()||(e.done??!1)||this.completed;if(!0!==e.force&&(0,j.gt)(t.updatedAt,Date.now()-R.secondMs))return;const s=U.TaskList.instance(),n=(0,A.isPaused)()||(0,P.ending)();i.state=r?"done":n?"paused":"processing";const a=s.pendingWorkCount();{const e=[];if(e.push((0,v.capitalize)(i.state)),!r&&a>0){const t=Math.min((0,I.maxConcurrentImports)(),a),i=this.eta.fmtEstimate(a/t);null!=i&&e.push(i)}i.hed=e.join(", ")}const o=[];this.processedCount()>0&&o.push("Processed "+(0,V.plur)(this.processedImageCount(),"photo")+" and "+(0,V.plur)(this.processedVideoCount(),"video")),!r&&a>0&&o.push((this.isScanning?"At least ":"")+(0,V.fmt)(a)+" remain to be processed"),r||n||!this.isScanning||o.push("Scanning "+(this.recentlyScannedDirs.shiftOrFirst()??this.root.nativePath)),this.scannedDirectoryCount()>0&&o.push("Scanned "+(0,V.plur)(this.scannedDirectoryCount(),"directory"));const l=s.currentTasksByFn("syncFile"),u=J.Task.nextByFn("syncFile",(e=>e.whereNotIn("id",l.map((e=>e.id))).limit(2)));return l.length>0&&o.push("Processing: "+(0,E.ellipsizePaths)({arr:l.map((e=>e.args.path)),maxPathLength:48,sampleSize:2})),u.length>0&&o.push("Queued: "+(0,E.ellipsizePaths)({arr:u.map((e=>e.args.path)),maxPathLength:48,sampleSize:2})),i.dek=o,(0,z.assignFields)(i,this.percents()),r&&(i.completedAt??(i.completedAt=Date.now())),this.logger.tap({msg:"#mkProgressUpdate()",level:"info",result:i})}},88204:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncFile=void 0;const a=i(83412),o=i(98314),l=i(74128),u=i(69385),c=i(49796),d=i(94710),h=i(76907);class f extends a.DoneWrapper{constructor(e){super("SyncFile: "+e),r.add(this),this.src=e,this.doneLatch.observe(n(this,r,"m",s).call(this)).catch((()=>{}))}}t.SyncFile=f,r=new WeakSet,s=async function(){await(0,u.resolveOnResume)();const e=await this.src.uri();if(null==e)return void(0,l.syncReport)().onProgress({path:this.src.nativePath,from:"SyncFile",state:l.SyncFileStates.rejected,details:"failed to build URI"});const t=c.Progress.insertNew({uri:e,volume:this.src.nativePath,state:"processing"});try{const[t]=await(0,h.precheckFiles)([this.src]);if(null!=t){const e=d.Task.addOne("syncFile",{path:this.src.nativePath});await e.donePromise()}else this.logger.info("syncFile: no-op",{uri:e})}catch(e){(0,l.syncReport)().onProgress({path:this.src.nativePath,from:"SyncFile",state:l.SyncFileStates.failed,details:(0,o.errorToS)(e)})}finally{t.upsert({state:"done",completedAt:Date.now()})}}},2387:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncManager=void 0;const a=i(83412),o=i(99331),l=i(98314),u=i(95696),c=i(74128),d=i(28874),h=i(98553),f=i(54993),m=i(98401),p=i(20958),g=i(76386),y=i(69032),w=i(56179),v=i(88204),b=i(92244),S=i(46832);class P extends a.DoneWrapper{constructor(){super("SyncManager"),r.add(this),this.doneLatch.observe(n(this,r,"m",s).call(this))}}t.SyncManager=P,r=new WeakSet,s=async function(){const e=d.Settings.argvScanPaths.toNotEmpty()??(d.Settings.exitWhenDone.valueOrDefault?[]:await(0,b.stalePathsToSync)());this.logger.info("#run starting",{paths:e});for(const t of e){this.logger.throwIfAborted_();const e=await(0,S.toUriPath)(t);try{null==e&&this.logger.throw("Could not convert to URI: "+(0,h.stringify)(t));const i=e.nativePath,r=u.PosixFile.forMaybe(i);null==r||null==e?(0,c.syncReport)().onProgress({path:i,from:"SyncManager",state:c.SyncFileStates.failed,details:"Cannot import: path could not be built."}):await r.isFile_()?(this.sync=new v.SyncFile(r),await this.sync.donePromise()):await r.isDirectory_()&&(this.sync=await w.SyncDirectory.for({root:r,rootUri:e.uri}),await(this.sync?.donePromise()))}catch(i){this.logger.info("Failed to sync path",{ea:t,error:i}),(0,c.syncReport)().onProgress({path:e?.nativePath??(0,f.toS)(t),from:"SyncManager",state:c.SyncFileStates.failed,details:(0,l.errorToS)(i)})}await(0,m.maybeCleanup_)(),await(0,y.runTagMaintenance)(),await g.tellWebProgressUpdated.refresh()}this.logger.info("#run complete",{paths:e}),p.Operation.markOpCompleted({name:"forceRestartSync"}),(0,o.ending)()||await(0,c.syncReport)().flushClose()}},92244:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syncPathsForUI=t.bestStable=t.isStale=t.bestPathToSync=t.stalePathsToSync=t.pathsAndTimesToSync=t.nativePathBlocklist=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(23560),o=i(22277),l=i(87290),u=i(57902),c=i(28874),d=i(40958),h=i(76790),f=i(42659),m=i(75240),p=i(31586),g=i(20958),y=i(49796),w=i(94019),v=i(98622),b=(0,s.lazy)((()=>(0,n.mkLogger)("sync.SyncPaths")));t.nativePathBlocklist=new o.TTLSet(10*f.minuteMs);const S=10*f.minuteMs;async function P(){const e=await(0,w.pathsToSync)(),t=c.Settings.forceSync.valueOrDefault?[]:await y.Progress.times();return b().tap({msg:"pathsAndTimesToSync()",level:u.LogLevels.info,result:e.map((e=>({...e,...t.find((t=>t.uri===e.uri))})))})}function M(e,t){return null==e.lastStartedAt||null==e.lastCompletedAt||(0,p.lte)(e.lastStartedAt,t)||(0,v.runTimeIsStale)(e.lastCompletedAt)}function _(){return g.Operation.getFirstPendingOp({name:g.OperationNames.forceRestartSync})}async function T(e){const t=_(),i=t?.createdAt,s=e.filter((e=>M(e,i)));if((0,d.isEmpty)(s))return(0,a.isSyncService)()&&t?.markCompleted(),b().tap({msg:"bestStable(): No stale paths to sync!",level:"info",result:void 0,meta:{arr:e,forceRestartOp:t}});{const e=(0,r.greatestBy)(s,(e=>e.lastUpdatedAt));if(null!=e&&(0,p.gt)(e.lastUpdatedAt,Date.now()-10*f.minuteMs))return b().tap({msg:"bestStable(): returning most recently updated",level:"info",result:{...e,why:"recently updated"}})}const n=(0,r.leastBy)(s,(e=>[e.lastStartedAt??0,e.lastCompletedAt??0]));return b().tap({msg:"bestStable(): returning least-recently-started or least-recently-completed:",level:"info",result:null==n?void 0:{...n,why:"least recently started or completed"},meta:{stale:s}})}function E(e,t){return null==e.lastStartedAt?"new":null==e.lastCompletedAt?"todo":(0,p.gt)(e.lastUpdatedAt,Date.now()-f.minuteMs)?"syncing":M(e,t)?"stale":"synced"}function D(e){return null==e?void 0:new Date(e).toISOString()}function k(e){if(null==e)return;const t=Date.now()-e;return t<2*f.secondMs?"just now":(0,m.fmtDuration)(t)+" ago"}t.pathsAndTimesToSync=P,t.stalePathsToSync=async function(){const e=await P(),t=_(),i=t?.createdAt,r=e.filter((e=>M(e,i)));return(0,h.sortBy)(r,(e=>[null!=e.lastUpdatedAt&&Date.now()-Se.nativePath)),t=await T(e),i=(0,l.libraryOriginalsDirPosixFile)()?.nativePath,r=_()?.createdAt;return e.map((e=>({path:e.nativePath,library:i===e.nativePath,status:E(e,r),isNext:e.nativePath===t?.nativePath,lastStartedISO:D(e.lastStartedAt),lastStarted:k(e.lastStartedAt),lastCompletedISO:D(e.lastCompletedAt),lastCompleted:k(e.lastCompletedAt)})))}},53767:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncService=void 0;const l=i(50213),u=i(7282),c=i(71567),d=i(78406),h=i(25764),f=i(38836),m=i(99331),p=i(45608),g=i(5916),y=i(73614),w=i(76596),v=i(8769),b=i(57159),S=i(63664),P=i(18454),M=i(21525),_=i(21473),T=i(41944),E=i(28874),D=i(37692),k=i(93493),x=i(42659),F=i(45599),C=i(98553),A=i(98401),I=i(64526),O=i(37158),L=i(56992),R=i(35580),N=i(22968),B=i(63461),j=i(98622),z=i(2387);t.SyncService=class{constructor(){this.logger=(0,l.mkLogger)("SyncService"),r.set(this,void 0),s.set(this,(0,F.defer)((async()=>{await this.service.setup_(),this.logger.info("setup()",{library:E.Settings.libraryDir.valueOrDefault,exitWhenDone:this.exitWhenDone,argvScanPaths:E.Settings.argvScanPaths.values,scanPaths:E.Settings.scanPaths.values,skipLibraryRebuild:E.Settings.skipLibraryRebuild.valueOrDefault,argv:process.argv});const e=I.Library.instanceRequired_();await e.ready;const t=await(0,S.getRemoteOrLocalHealthSummary)();(0,M.isHealthCheckLevelFatal)(t.level)&&await(0,p.exit)({reason:"Health check failed: "+t.msg.join(": "),status:1}),await(0,_.testSharp_)(),await(0,k.setupShimDelegates)(),(0,A.scheduleFileAndProcCleanups)(),R.TaskList.instance(),E.Settings.forceRebuildLibrary.valueOrDefault&&(this.logger.info("setup(): "+E.Settings.forceRebuildLibrary.key+" is true: setting all assets to require updates..."),(0,N.forceRebuildLibraryLater)()),(0,u.isTest)()&&T.onProgressEvt.setShim((async e=>console.log((0,C.stringify)(e)))),D.stateEvents.on("checkTasks",(()=>R.TaskList.instance().maybeRunChunk())),new d.EndableInterval({name:"SyncService.setVolumesTTL()",callback:()=>(0,L.setVolumesTTL)(),intervalMs:x.dayMs/4,initialDelayMs:5*x.minuteMs,rank:h.EndableRanks.first}),new f.EndableWrapper("SyncService end status",(async()=>this.logger.info("end status",await this.status())),h.EndableRanks.first),this.run()}))),n.set(this,(0,g.lazyAsync)({later:async()=>{if(this.logger.info(".run(): starting"),(0,A.scheduleFileAndProcCleanups)(),await(0,N.maybeRebuildLibrary)(),this.logger.info(".run(): finished library rebuild"),await(R.TaskList.instance()?.awaitDrain()),this.logger.info(".run(): finished task list drain"),o(this,r,new z.SyncManager,"f"),await a(this,r,"f").donePromise(),(0,u.isTest)()&&(0,c.stdoutWrite)(B.SyncCompleted),this.exitWhenDone)return(0,p.exit)({reason:"Finished",status:0});this.logger.info("SyncManager completed. Running cleanups..."),await(0,A.cleanup_)(),(0,A.cancelFileAndProcCleanups)();const e=(0,j.SyncCron)().nextRun();this.logger.info("nextRun",{nextRun:e});const t=e.getTime()-Date.now();this.logger.info("Scheduling next sync run for "+e.toISOString()+" ("+(0,w.durationHMS)(t)+" from now)",E.Settings.syncCron.addToEnv({})),(0,y.setUnrefTimeout)((()=>this.run()),t)}})),this.exitWhenDone=E.Settings.exitWhenDone.valueOrDefault||E.Settings.argvScanPaths.isNotEmpty(),this.service=new O.Service("sync"),a(this,s,"f").call(this).catch((e=>(0,v.onError)(new b.WrappedError("SyncService.setup() failed",{cause:e,fatal:!0}))))}async status(){const e=a(this,r,"f");return{libraryDir:E.Settings.libraryDir.value,ending:(0,m.ending)(),sync:e?.sync?.name,summary:P.HealthCheck.summary()}}run(){const e=a(this,n,"f").prior();return this.logger.info("run()",{prior_pending:e?.isPending}),null!=e&&e.isPending?(this.logger.warn(".run(): preventing overrun: prior run is still pending"),e):a(this,n,"f").refresh()}},r=new WeakMap,s=new WeakMap,n=new WeakMap},46832:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.posixFileToUriPath=t.toUriPath=void 0;const r=i(53265),s=i(45200),n=i(22573),a=i(68708),o=i(54993);async function l(e,t){if((0,a.isObject)(e)&&!(0,n.blank)(e.nativePath)&&!(0,n.blank)(e.uri))return e;const i=(0,r.resolve)((0,o.toS)(e)),l=await t??await(0,s.nativePath2uri)(i);return null==l?void 0:{nativePath:i,uri:l.toString()}}t.toUriPath=l,t.posixFileToUriPath=function(e){return l(e.nativePath,e.uriObject_())}},7656:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rebuildTagAssetCounts=t.DirectAssetCountForTagQuery=t.RecursiveAssetCountForTagQuery=t.nonLeafTagIds=void 0;const r=i(50213),s=i(56038),n=i(95704),a=i(38156),o=i(42659),l=i(45599),u=i(41400),c=i(31586),d=i(51926),h=(0,l.defer)((()=>(0,r.mkLogger)("tag.TagAssetCounts")));function f(e){return e.prepare((0,d.compressWhitespace)("SELECT"," t1.id,"," count(t2.id) AS cnt","FROM"," Tag t1"," JOIN Tag t2 ON t1.id = t2.parentId","GROUP BY"," 1","HAVING"," cnt > 0")).pluck().all()}async function m(e,i=[]){const r=e.prepare(t.RecursiveAssetCountForTagQuery).pluck(),o=e.prepare(t.DirectAssetCountForTagQuery).pluck(),l=e.prepare("UPDATE Tag SET assetCount = :assetCount, updatedAt = :updatedAt WHERE id = :tagId"),c=new Set(f(e)),d=new a.PushProgressObserver({op:"Rebuilding tag asset counts"},e.prepare("SELECT count(*) FROM Tag").pluck().get());await(0,n.withIdBatches)({db:e,tableName:"Tag",primaryKeyColumnName:"id",whereClauses:i,async fn(e){for(const t of e){const e=!c.has(t);(0,s.timeSync)("db.rebuildTagAssetCounts("+(e?"leaf":"cte")+")",(()=>{const s=(e?o:r).get({tagId:t});l.run({tagId:t,assetCount:s,updatedAt:Date.now()}),d.incrProgress(),h().debug("_rebuildTagAssetCounts()",{isLeaf:e,whereClauses:i,tagId:t,assetCount:s})})),t%10==0&&(h().throwIfAborted_(),await(0,u.delay)(1))}}}),d.completed()}t.nonLeafTagIds=f,t.RecursiveAssetCountForTagQuery=(0,d.compressWhitespace)("WITH RECURSIVE descendants(id) AS ("," VALUES (:tagId)"," UNION"," SELECT Tag.id"," FROM Tag, descendants"," WHERE Tag.parentId = descendants.id",")","SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," descendants"," JOIN AssetTag ON AssetTag.tagId = descendants.id"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL"),t.DirectAssetCountForTagQuery=(0,d.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," AssetTag"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," AssetTag.tagId = :tagId"," AND Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL;"),t.rebuildTagAssetCounts=async function(e,t=o.minuteMs){if(await(0,s.time)("db.rebuildNullTagAssetCounts",(()=>m(e,["assetCount IS NULL"]))),(0,c.gt0)(t)){const i=e.prepare("SELECT min(updatedAt) FROM Tag").pluck().get(),r=Date.now()-i;if(rm(e)))}},69032:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.displayNameForVolsha=t.fixFileRootTag=t.runTagMaintenance=t.forceRunTagMaintenance=t.tagFtsRebuild=void 0;const s=r(i(76760)),n=i(19851),a=i(50213),o=i(7282),l=i(409),u=i(1728),c=i(56038),d=i(34102),h=i(49076),f=i(69589),m=i(28874),p=i(42231),g=i(85087),y=i(98770),w=i(59107),v=i(63870),b=i(7014),S=i(22573),P=i(42659),M=i(41400),_=i(75240),T=i(31586),E=i(34666),D=i(51926),k=i(75020),x=i(54017),F=i(48723),C=i(98784),A=i(7656),I=(0,n.lazy)((()=>(0,a.mkLogger)("tag.TagSql")));t.tagFtsRebuild=(0,n.lazy)((()=>(0,c.time)("db.rebuildTagFts",(()=>C.TagFts.rebuild()))),10*P.minuteMs),t.forceRunTagMaintenance=async function(e={forceSync:!0,recountAllTags:!0}){return I().info("forceRunTagMaintenance()"),await t.runTagMaintenance.force(e)};const O=((0,o.isTest)()?5:30)*P.secondMs;t.runTagMaintenance=(0,l.rateLimited)({name:"runTagMaintenance",minCallDelayMs:O,f:async e=>{const i=(0,f.forceContextOrSetting)(e),r=Date.now(),s=I().addContext(".runTagMaintenance()");s.info("starting",{ctx:i});try{s.info("validating all tags..."),F.Tag.validate_(),s.throwIfAborted_(i?.halt),await L(),i.recountAllTags&&(s.info("rebuilding tag search index..."),await(0,t.tagFtsRebuild)(),s.info("rebuilding tag asset counts..."),await(0,A.rebuildTagAssetCounts)(F.Tag.dbl.db().db,0))}catch(e){I().warn("runTagMaintenance() failed",e)}const n=Date.now()-r,a=(0,T.clamp)(O,15*P.minuteMs,20*n);t.runTagMaintenance.setMinCallDelayMs(a),I().info("runTagMaintenance(): complete.",{newMinCallDelayMs:a,elapsedMs:n})}});const L=(0,y.lazyFsAsync)("updateTagMountpoints",(async()=>{I().info("updating tag mountpoints...");const e=F.Tag.findByPath([k.TagRoots.fs]);if(null!=e){e.maybeUpsertDisplayName(m.Settings.tagDisplayNameFS.valueOrDefault);for(const t of e.getChildren())await N(t)}else(0,a.mkLogger)("updateTagMountpoints()").info("No root filesystem tag (new db, I hope?)")}));function R(){t.tagFtsRebuild.unset(),L.unset()}async function N(e){if(null==e||2!==e.depth||!e._path.startsWith(k.TagRoots.fs+p.TagSep))return;const i=(0,a.mkLogger)("fixFileRootTag("+e+")");if(e.name===k.LibraryTagName)return void(1!==e.ordinal&&(i.info("fixing library ordinal",{id:e.id,path:e.path}),e.upsert({ordinal:1}),F.Tag.clear()));if((0,f.forceContextOrSetting)().forceSync&&(0,S.notBlank)(e.displayName)&&(0,E.gt)(e.updatedAt,Date.now()-(0,v.volumeMetadataTtlMs)()))return void i.info("no-op: tag recently updated",{id:e.id,path:e.path,updated:(0,_.fmtDuration)(Date.now()-e.updatedAt)+" ago"});const r=await(0,t.displayNameForVolsha)(e.name);(0,S.notBlank)(r)?(e.maybeUpsertDisplayName(r),i.info("updated tag",{id:e.id,path:e.path,displayName:r}),F.Tag.clear()):i.debug("cannot update tag: no current volume.",{id:e.id,path:e.path})}(0,M.later)((()=>{(0,d.ee)().on("clearCache",R),m.Settings.libraryDir.watchLater(R)})),t.fixFileRootTag=N,t.displayNameForVolsha=(0,u.memoizeAsync)((async e=>{const t=(0,a.mkLogger)("displayNameForVolsha("+e+")"),i=await(0,b.volumes)();if(null!=i){const r=i.find((t=>(0,g.volsha)(t.uuid)===e));return t.info("find()",{vol:r}),null!=r?m.Settings.tagDisplayNameFSLabels.valueOrDefault&&(0,S.notBlank)(r.label)?r.label.trim():"/"===r.mountpoint?m.Settings.tagDisplayNameFSRoot.valueOrDefault+(m.Settings.tagDisplayNameFSRootWithHostname.valueOrDefault?" on "+(0,h.hostname)():""):(0,S.notBlankOr)((0,D.stripPrefixSuffix)(r.mountpoint,{prefix:s.default.sep,suffix:s.default.sep}),s.default.sep):x.AssetFile.dbl.pluckFirstf((t=>t.select("mountpoint").whereLike("uri","psfile://"+e+"/%").limit(1)))}}),{name:"tag.displayNameForVolsha",maxSize:64,timeoutMs:(0,v.volumeMetadataTtlMs)()}),(0,M.later)((()=>{w.mountpoints.watch((()=>t.displayNameForVolsha.clear()))}))},90858:e=>{"use strict";e.exports=require("@iarna/toml")},53705:e=>{"use strict";e.exports=require("@photostructure/tz-lookup")},16436:e=>{"use strict";e.exports=require("@sentry/node")},64770:e=>{"use strict";e.exports=require("assert")},58587:e=>{"use strict";e.exports=require("batch-cluster")},87550:e=>{"use strict";e.exports=require("better-sqlite3")},6858:e=>{"use strict";e.exports=require("commander")},36507:e=>{"use strict";e.exports=require("croner")},66261:e=>{"use strict";e.exports=require("events")},77988:e=>{"use strict";e.exports=require("exiftool-vendored")},66150:e=>{"use strict";e.exports=require("fast-xml-parser")},68817:e=>{"use strict";e.exports=require("file-type")},44652:e=>{"use strict";e.exports=require("fs-extra")},28787:e=>{"use strict";e.exports=require("he")},31832:e=>{"use strict";e.exports=require("knex")},51168:e=>{"use strict";e.exports=require("luxon")},93973:e=>{"use strict";e.exports=require("ml-kmeans")},4927:e=>{"use strict";e.exports=require("papaparse")},83058:e=>{"use strict";e.exports=require("picomatch")},57272:e=>{"use strict";e.exports=require("plist")},85949:e=>{"use strict";e.exports=require("process")},90595:e=>{"use strict";e.exports=require("punycode")},38064:e=>{"use strict";e.exports=require("semver")},9288:e=>{"use strict";e.exports=require("sharp")},93944:e=>{"use strict";e.exports=require("source-map-support")},49378:e=>{"use strict";e.exports=require("trash")},73872:e=>{"use strict";e.exports=require("type-detect")},92460:e=>{"use strict";e.exports=require("util")},75162:e=>{"use strict";e.exports=require("util/types")},29907:e=>{"use strict";e.exports=require("cluster")},76982:e=>{"use strict";e.exports=require("crypto")},34589:e=>{"use strict";e.exports=require("node:assert")},31421:e=>{"use strict";e.exports=require("node:child_process")},77598:e=>{"use strict";e.exports=require("node:crypto")},40610:e=>{"use strict";e.exports=require("node:dns")},78474:e=>{"use strict";e.exports=require("node:events")},73024:e=>{"use strict";e.exports=require("node:fs")},51455:e=>{"use strict";e.exports=require("node:fs/promises")},37067:e=>{"use strict";e.exports=require("node:http")},44708:e=>{"use strict";e.exports=require("node:https")},77030:e=>{"use strict";e.exports=require("node:net")},48161:e=>{"use strict";e.exports=require("node:os")},76760:e=>{"use strict";e.exports=require("node:path")},53916:e=>{"use strict";e.exports=require("node:path/posix")},1708:e=>{"use strict";e.exports=require("node:process")},57075:e=>{"use strict";e.exports=require("node:stream")},46466:e=>{"use strict";e.exports=require("node:stream/promises")},87997:e=>{"use strict";e.exports=require("node:timers")},57975:e=>{"use strict";e.exports=require("node:util")},38522:e=>{"use strict";e.exports=require("node:zlib")},16928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=34742);module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{var __webpack_modules__={60308:e=>{const t={PasetoNotSupported:"ERR_PASETO_NOT_SUPPORTED",PasetoDecryptionFailed:"ERR_PASETO_DECRYPTION_FAILED",PasetoInvalid:"ERR_PASETO_INVALID",PasetoVerificationFailed:"ERR_PASETO_VERIFICATION_FAILED",PasetoClaimInvalid:"ERR_PASETO_CLAIM_INVALID"};class i extends Error{constructor(e){super(e),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}e.exports.PasetoError=i,e.exports.PasetoNotSupported=class extends i{},e.exports.PasetoDecryptionFailed=class extends i{},e.exports.PasetoInvalid=class extends i{},e.exports.PasetoVerificationFailed=class extends i{},e.exports.PasetoClaimInvalid=class extends i{}},78972:(e,t,i)=>{const{PasetoInvalid:r,PasetoNotSupported:s}=i(60308),{decode:n}=i(47859),a=i(40816);e.exports=(e,{parse:t=!0}={})=>{if("string"!=typeof e)throw new TypeError("token must be a string");const{0:i,1:o,2:l,3:u,length:c}=e.split(".");if(3!==c&&4!==c)throw new r("token is not a PASETO formatted value");if("v1"!==i&&"v2"!==i&&"v3"!==i&&"v4"!==i)throw new s("unsupported PASETO version");if("local"!==o&&"public"!==o)throw new s("unsupported PASETO purpose");const d={footer:u?n(u):void 0,payload:void 0,version:i,purpose:o};if("local"===o)return d;const h="v1"===i?256:"v3"===i?96:64;let f;try{f=n(l).subarray(0,-h)}catch{throw new r("token is not a PASETO formatted value")}return d.payload=t?a(f):f,d}},2744:(e,t,i)=>{const r=i(78972);e.exports={decode:r}},67814:(e,t,i)=>{const r=i(85223);e.exports=({audience:e,expiresIn:t,iat:i=!0,issuer:s,jti:n,kid:a,notBefore:o,now:l=new Date,subject:u},c)=>{if(!(l instanceof Date&&l.getTime()))throw new TypeError("options.now must be a valid Date object");const d=l.getTime();if(void 0!==i){if("boolean"!=typeof i)throw new TypeError("options.iat must be a boolean");i&&(c.iat=new Date(d))}if(void 0!==t){if("string"!=typeof t)throw new TypeError("options.expiresIn must be a string");c.exp=new Date(d+r(t))}if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.notBefore must be a string");c.nbf=new Date(d+r(o))}if(void 0!==e){if("string"!=typeof e)throw new TypeError("options.audience must be a string");c.aud=e}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.issuer must be a string");c.iss=s}if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.subject must be a string");c.sub=u}if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.kid must be a string");c.kid=a}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.jti must be a string");c.jti=n}return c}},10968:(e,t,i)=>{const{PasetoClaimInvalid:r}=i(60308),s=i(85223);e.exports=({ignoreExp:e,ignoreNbf:t,ignoreIat:i,maxTokenAge:n,subject:a,issuer:o,clockTolerance:l,audience:u,now:c=new Date},d)=>{if(!(c instanceof Date&&c.getTime()))throw new TypeError("options.now must be a valid Date object");const h=c.getTime();if("iss"in d&&"string"!=typeof d.iss)throw new r("payload.iss must be a string");if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.issuer must be a string");if(d.iss!==o)throw new r("issuer mismatch")}if("sub"in d&&"string"!=typeof d.sub)throw new r("payload.sub must be a string");if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.subject must be a string");if(d.sub!==a)throw new r("subject mismatch")}if("aud"in d&&"string"!=typeof d.aud)throw new r("payload.aud must be a string");if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.audience must be a string");if(d.aud!==u)throw new r("audience mismatch")}if(void 0!==l&&"string"!=typeof l)throw new TypeError("options.clockTolerance must be a string");const f=l?s(l):0;let m;if("iat"in d){if("string"!=typeof d.iat)throw new r("payload.iat must be a string");if(m=new Date(d.iat).getTime(),!m)throw new r("payload.iat must be a valid ISO8601 string");if(!i&&m>h+f)throw new r("token issued in the future")}if("nbf"in d){if("string"!=typeof d.nbf)throw new r("payload.nbf must be a string");const e=new Date(d.nbf).getTime();if(!e)throw new r("payload.nbf must be a valid ISO8601 string");if(!t&&e>h+f)throw new r("token is not active yet")}if("exp"in d){if("string"!=typeof d.exp)throw new r("payload.exp must be a string");const t=new Date(d.exp).getTime();if(!t)throw new r("payload.exp must be a valid ISO8601 string");if(!e&&t<=h-f)throw new r("token is expired")}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.maxTokenAge must be a string");if(!("iat"in d))throw new r("missing iat claim");if(m+s(n){e.exports.encode=e=>e.toString("base64url"),e.exports.decode=e=>Buffer.from(e,"base64")},80608:e=>{e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if("string"!=typeof e)throw new TypeError("options.assertion must be a string, or a Buffer");return Buffer.from(e,"utf8")}},83561:(e,t,i)=>{const r=i(65825);e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if(r(e))return Buffer.from(JSON.stringify(e),"utf8");if("string"!=typeof e)throw new TypeError("options.footer must be a string, Buffer, or a plain object");return Buffer.from(e,"utf8")}},1658:(e,t,i)=>{const r=i(67814),s=i(65825);e.exports=(e,t)=>{if(Buffer.isBuffer(e)){if(0!==Object.keys(t).length)throw new TypeError("options cannot contain claims when payload is a Buffer");return e}if(!s(e))throw new TypeError("payload must be a Buffer or a plain object");return e=(e=>JSON.parse(JSON.stringify(e)))(e),e=r(t,e),Buffer.from(JSON.stringify(e),"utf-8")}},82115:e=>{e.exports=e=>{const{x:t,y:i}=e.export({format:"jwk"}),r=Buffer.from(i,"base64"),s=2+(1&r[r.length-1]);return Buffer.concat([Buffer.alloc(1,s),Buffer.from(t,"base64")])}},88965:(e,t,i)=>{const r=i(64770),{PasetoInvalid:s}=i(60308),n=i(10968),{decode:a}=i(47859),o=i(40816);e.exports={post:function(e,t,i,r,s,a,l){if(t){if(0!==Object.keys(i).length)throw new TypeError("options cannot contain claims when options.buffer is true");return r?{payload:s,footer:a?.length?a:void 0,version:e,purpose:l}:s}const u=o(s);return n(i,u),r?{payload:u,footer:a?.length?a:void 0,version:e,purpose:l}:u},pre:function(e,t){if("string"!=typeof t)throw new TypeError("token must be a string, got: "+typeof t);if(t.slice(0,e.length)!==e)throw new s(`token is not a ${e.slice(0,e.length-1)} PASETO`);let{0:i,1:n="",length:o}=t.slice(e.length).split(".");try{r(o<=2),i=a(i),n=a(n)}catch{throw new s("token is not a PASETO formatted value")}return{raw:i,f:n}}}},56463:(e,t,i)=>{const r=i(76982),s=i(92460),n=i(70761),a=i(29534),{PasetoDecryptionFailed:o}=i(60308),l=i(82682),{webcrypto:{subtle:u}}=r,c=s.promisify(r.hkdf),d=Buffer.from("paseto-encryption-key"),h=Buffer.from("paseto-auth-key-for-aead"),f=Buffer.alloc(0),m=(e,t)=>r.createHmac("sha384",t).update(e).digest(),p=async(e,t,i,r)=>u[e]({name:"AES-CTR",counter:r,length:16},await u.importKey("raw",i,"AES-CTR",!1,[e]),t).then(Buffer.from),g=p.bind(void 0,"encrypt"),y=p.bind(void 0,"decrypt");e.exports={sign:s.promisify(r.sign),verify:s.promisify(r.verify),"v1.local-encrypt":async function(e,t,i){const s="v1.local.",o=m(e,r.randomBytes(32)).subarray(0,32),l=o.subarray(0,16),[u,f]=await Promise.all([c("sha384",i,l,d,32).then(Buffer.from),c("sha384",i,l,h,32).then(Buffer.from)]),p=await g(e,u,o.subarray(16)),y=n(s,o,p,t),w=m(y,f);return a(s,t,o,p,w)},"v1.local-decrypt":async function(e,t,i){const r=e.subarray(0,32),s=e.subarray(-48),a=e.subarray(32,-48),u=r.subarray(0,16),[f,p]=await Promise.all([c("sha384",i,u,d,32).then(Buffer.from),c("sha384",i,u,h,32).then(Buffer.from)]),g=n("v1.local.",r,a,t),w=m(g,p);if(!l(s,w))throw new o("decryption failed");const v=await y(a,f,r.subarray(16));if(!v)throw new o("decryption failed");return v},"v3.local-encrypt":async function(e,t,i,s){const o="v3.local.",l=r.randomBytes(32),[u,p]=await Promise.all([c("sha384",i,f,Buffer.concat([d,l]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,l]),48).then(Buffer.from)]),y=u.subarray(0,32),w=u.subarray(32),v=await g(e,y,w),b=n(o,l,v,t,s),S=m(b,p);return a(o,t,l,v,S)},"v3.local-decrypt":async function(e,t,i,r){const s=e.subarray(0,32),a=e.subarray(-48),u=e.subarray(32,-48),[p,g]=await Promise.all([c("sha384",i,f,Buffer.concat([d,s]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,s]),48).then(Buffer.from)]),w=p.subarray(0,32),v=p.subarray(32),b=n("v3.local.",s,u,t,r),S=m(b,g);if(!l(a,S))throw new o("decryption failed");const P=await y(u,w,v);if(!P)throw new o("decryption failed");return P}}},70981:(e,t,i)=>{const{KeyObject:r}=i(76982);let{isKeyObject:s}=i(75162);s||(s=e=>null!=e&&e instanceof r),e.exports=s},65825:e=>{e.exports=e=>!!e&&e.constructor===Object},41726:(e,t,i)=>{const{PasetoNotSupported:r}=i(60308);e.exports=e=>{if(!Number.isSafeInteger(e))throw new r("message is too long for Node.js to safely process");const t=~~(e/4294967295),i=e%4294967295-t,s=Buffer.allocUnsafe(8);return s.writeUInt32LE(t,4),s.writeUInt32LE(i,0),s}},85223:e=>{const t=36e5,i=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;e.exports=e=>{const r=i.exec(e);if(!r)throw new TypeError(`invalid time period format ("${e}")`);const s=parseFloat(r[1]);switch(r[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(1e3*s);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(6e4*s);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(s*t);case"day":case"days":case"d":return Math.round(864e5*s);case"week":case"weeks":case"w":return Math.round(6048e5*s);case"year":case"years":case"yr":case"yrs":case"y":return Math.round(315576e5*s)}}},29534:(e,t,i)=>{const{encode:r}=i(47859);e.exports=function(e,t,...i){let s=`${e}${r(Buffer.concat(i))}`;return t.byteLength&&(s+=`.${r(t)}`),s}},70761:(e,t,i)=>{const r=i(41726);e.exports=(...e)=>{e=e.filter(Boolean);let t=r(e.length);for(let i of e){i=Buffer.from(i,"utf8");const e=r(Buffer.byteLength(i));t=Buffer.concat([t,e,i])}return t}},40816:(e,t,i)=>{const{PasetoInvalid:r}=i(60308),{strict:s}=i(64770),n=i(65825);e.exports=e=>{try{const t=JSON.parse(e);return s(n(t)),t}catch{throw new r("All PASETO payloads MUST be a JSON object")}}},92366:(e,t,i)=>{const{sign:r}=i(56463),s=i(70761),n=i(29534);e.exports=async function(e,t,i,a,o,l,u){const c=s(u,e,t,i,l),d=await r(a,c,o);return n(e,i,t,d)}},495:(e,t,i)=>{const{createSecretKey:r}=i(76982),s=i(70981);e.exports=function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}`)&&(t=Buffer.from(t.slice(e.length),"base64url")),!s(t))try{t=r(t)}catch{}if(!s(t))throw new TypeError("invalid key provided");if("secret"!==t.type||32!==t.symmetricKeySize)throw new TypeError(`${e} secret key must be 32 bytes long symmetric key`);return t}},82682:(e,t,i)=>{const{timingSafeEqual:r}=i(76982),s=(e,t)=>{if(e.length===t)return e;const i=Buffer.alloc(t);return e.copy(i),i};e.exports=(e,t)=>{const i=Math.max(e.length,t.length);return r(s(e,i),s(t,i))}},49826:(e,t,i)=>{const{PasetoVerificationFailed:r}=i(60308),{verify:s}=i(56463),n=i(70761),{pre:a}=i(88965);e.exports=async function(e,t,i,o,l,u,c){const{raw:d,f:h}=a(e,t),f=d.subarray(0,-o),m=d.subarray(-o),p=n(c,e,f,h,u);if(!await s(i,p,l,m))throw new r("invalid signature");return{m:f,footer:h.length?h:void 0}}},91227:(e,t,i)=>{const r=i(60308),s=i(79665),n=i(56120),a=i(50015),o=i(64230),{decode:l}=i(2744);e.exports={decode:l,V1:s,V2:n,V3:a,V4:o,errors:r}},39324:(e,t,i)=>{const{"v1.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v1.local"),{pre:n,post:a}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:o=!1,...l}={}){const{raw:u,f:c}=n("v1.local.",e),d=(t=s(t)).export(),h=await r(u,c,d);return a("v1",o,l,i,h,c,"local")}},21472:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v1.local"),n=i(1658),{"v1.local-encrypt":a}=i(56463);e.exports=async function(e,t,{footer:i,...o}={}){const l=n(e,o);t=s(t);const u=r(i),c=t.export();return a(l,u,c)}},79665:(e,t,i)=>{const r=i(77868),s=i(77256),n=i(21472),a=i(39324),o=i(70866);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o}},70866:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=s(r.generateKeyPair),o=s(r.generateKey);e.exports=async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await o("aes",{length:256});return"paserk"===t?`k1.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await a("rsa",{modulusLength:2048});return"paserk"===t?{secretKey:`k1.secret.${e.export({format:"der",type:"pkcs1"}).toString("base64url")}`,publicKey:`k1.public.${i.export({format:"der",type:"pkcs1"}).toString("base64url")}`}:e}default:throw new n("unsupported v1 purpose")}}},77868:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPrivateKey:n}=i(76982),a=i(83561),o=i(1658),l=i(92366),u=i(70981);e.exports=async function(e,t,{footer:i,...c}={}){const d=o(e,c),h=a(i);return t=function(e){if("string"==typeof e&&e.startsWith("k1.secret."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!u(e))try{e=n(e)}catch{}if(!u(e))throw new TypeError("invalid key provided");if("private"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public signing key must be a private RSA key with 2048 bit modulus length");return e}(t),l("v1.public.",d,h,"sha384",{key:t,padding:r,saltLength:s})}},77256:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPublicKey:n}=i(76982),a=i(49826),o=i(70981),{post:l}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:u=!1,...c}={}){t=function(e){if("string"==typeof e&&e.startsWith("k1.public."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!o(e)||"private"===e.type)try{e=n(e)}catch{}if(!o(e))throw new TypeError("invalid key provided");if("public"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public verify key must be a public RSA key with 2048 bit modulus length");return e}(t);const{m:d,footer:h}=await a("v1.public.",e,"sha384",256,{key:t,padding:r,saltLength:s});return l("v1",u,c,i,d,h,"public")}},56120:(e,t,i)=>{const r=i(88451),s=i(859),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(62827);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},62827:(e,t,i)=>{const r=i(64770),s=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:a}=i(60308),o=i(70981),l=n(s.generateKeyPair);async function u(e,t,{format:i="keyobject"}={}){if("keyobject"!==i&&"paserk"!==i)throw new TypeError("invalid format");if("public"===t){const{privateKey:t,publicKey:r}=await l("ed25519");return"paserk"===i?{secretKey:`k${e.slice(1)}.secret.${h(t).toString("base64url")}`,publicKey:`k${e.slice(1)}.public.${h(r).toString("base64url")}`}:t}throw new a(`unsupported ${e} purpose`)}function c(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 64:{const t=s.createPrivateKey({key:Buffer.concat([Buffer.from("302e020100300506032b657004220420","hex"),e.subarray(0,32)]),format:"der",type:"pkcs8"});if(!e.subarray(32).equals(Buffer.from(t.export({format:"jwk"}).x,"base64")))throw new TypeError("invalid byte sequence");return t}case 32:return s.createPublicKey({key:Buffer.concat([Buffer.from("302a300506032b6570032100","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 64 bytes (private key), or 32 bytes (public key)")}}function d(e,t){if(!o(t))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public key must be an Ed25519 key`);switch(t.type){case"public":return Buffer.from(t.export({format:"jwk"}).x,"base64");case"private":{const{d:e,x:i}=t.export({format:"jwk"});return Buffer.concat([Buffer.from(e,"base64"),Buffer.from(i,"base64")])}}}function h(...e){return d("v2",...e)}e.exports={_checkPrivateKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.secret.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,64)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t))try{t=s.createPrivateKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("private"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public signing key must be a private ed25519 key`);return t},_checkPublicKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.public.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,32)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t)||"private"===t.type)try{t=s.createPublicKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("public"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public verify key must be a public ed25519 key`);return t},_generateKey:u,_keyObjectToBytes:d,bytesToKeyObject:c,generateKey:async function(...e){return u("v2",...e)},keyObjectToBytes:h}},88451:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(92366),{_checkPrivateKey:a}=i(62827),o=a.bind(void 0,"v2");e.exports=async function(e,t,{footer:i,...a}={}){const l=s(e,a);t=o(t);const u=r(i);return n("v2.public.",l,u,void 0,t)}},859:(e,t,i)=>{const r=i(49826),{_checkPublicKey:s}=i(62827),{post:n}=i(88965),a=s.bind(void 0,"v2");e.exports=async function(e,t,{complete:i=!1,buffer:s=!1,...o}={}){t=a(t);const{m:l,footer:u}=await r("v2.public.",e,void 0,64,t);return n("v2",s,o,i,l,u,"public")}},18582:(e,t,i)=>{const{"v3.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v3.local"),n=i(80608),{pre:a,post:o}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:l=!1,assertion:u,...c}={}){const{raw:d,f:h}=a("v3.local.",e);t=s(t);const f=n(u),m=t.export(),p=await r(d,h,m,f);return o("v3",l,c,i,p,h,"local")}},43406:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v3.local"),n=i(1658),a=i(80608),{"v3.local-encrypt":o}=i(56463);e.exports=async function(e,t,{footer:i,assertion:l,...u}={}){const c=n(e,u);t=s(t);const d=r(i),h=a(l),f=t.export();return o(c,d,f,h)}},50015:(e,t,i)=>{const r=i(42438),s=i(65466),n=i(43406),a=i(18582),{generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}=i(80568);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}},80568:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=i(70981),o=i(82115),l=s(r.generateKeyPair),u=s(r.generateKey);function c(e){if(!a(e))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public key must be an EC P-384 key");switch(e.type){case"public":return o(e);case"private":return Buffer.from(e.export({format:"jwk"}).d,"base64")}}e.exports={generateKey:async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await u("aes",{length:256});return"paserk"===t?`k3.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await l("ec",{namedCurve:"P-384"});return"paserk"===t?{secretKey:`k3.secret.${c(e).toString("base64url")}`,publicKey:`k3.public.${c(i).toString("base64url")}`}:e}default:throw new n("unsupported v3 purpose")}},bytesToKeyObject:function(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 48:return r.createPrivateKey({key:Buffer.concat([Buffer.from("303e0201010430","hex"),e,Buffer.from("a00706052b81040022","hex")]),format:"der",type:"sec1"});case 49:if(2!==e[0]&&3!==e[0])throw new TypeError("invalid compressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3046301006072a8648ce3d020106052b81040022033200","hex"),e]),format:"der",type:"spki"});case 97:if(4!==e[0])throw new TypeError("invalid uncompressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3076301006072a8648ce3d020106052b81040022036200","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 48 bytes (private key), 49 bytes (compressed public key), or 97 bytes (uncompressed public key)")}},keyObjectToBytes:c}},42438:(e,t,i)=>{const{createPrivateKey:r}=i(76982),s=i(83561),n=i(1658),a=i(80608),o=i(92366),l=i(70981),{bytesToKeyObject:u}=i(80568),c=i(82115);e.exports=async function(e,t,{footer:i,assertion:d,...h}={}){const f=n(e,h),m=s(i),p=a(d);return t=function(e){if("string"==typeof e&&e.startsWith("k3.secret."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,48)}catch{}if(Buffer.isBuffer(e))try{e=u(e)}catch{}if(!l(e))try{e=r(e)}catch{}if(!l(e))throw new TypeError("invalid key provided");if("private"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public signing key must be a private EC P-384 key");return e}(t),o("v3.public.",f,m,"sha384",{key:t,dsaEncoding:"ieee-p1363"},p,c(t))}},65466:(e,t,i)=>{const{createPublicKey:r}=i(76982),s=i(80608),n=i(49826),a=i(70981),{bytesToKeyObject:o}=i(80568),l=i(82115),{post:u}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:c=!1,assertion:d,...h}={}){t=function(e){if("string"==typeof e&&e.startsWith("k3.public."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,49)}catch{}if(Buffer.isBuffer(e))try{e=o(e)}catch{}if(!a(e)||"private"===e.type)try{e=r(e)}catch{}if(!a(e))throw new TypeError("invalid key provided");if("public"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public verify key must be a public EC P-384 key");return e}(t);const f=s(d),{m,footer:p}=await n("v3.public.",e,"sha384",96,{key:t,dsaEncoding:"ieee-p1363"},f,l(t));return u("v3",c,h,i,m,p,"public")}},64230:(e,t,i)=>{const r=i(29901),s=i(77933),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(24961);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},24961:(e,t,i)=>{const{_checkPrivateKey:r,_checkPublicKey:s,_generateKey:n,_keyObjectToBytes:a,bytesToKeyObject:o}=i(62827);e.exports={_checkPrivateKey:r,_checkPublicKey:s,bytesToKeyObject:o,generateKey:async function(...e){return n("v4",...e)},keyObjectToBytes:function(...e){return a("v4",...e)}}},29901:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(80608),a=i(92366),{_checkPrivateKey:o}=i(24961),l=o.bind(void 0,"v4");e.exports=async function(e,t,{footer:i,assertion:o,...u}={}){const c=s(e,u),d=n(o);t=l(t);const h=r(i);return a("v4.public.",c,h,void 0,t,d)}},77933:(e,t,i)=>{const r=i(80608),s=i(49826),{_checkPublicKey:n}=i(24961),{post:a}=i(88965),o=n.bind(void 0,"v4");e.exports=async function(e,t,{complete:i=!1,buffer:n=!1,assertion:l,...u}={}){t=o(t);const c=r(l),{m:d,footer:h}=await s("v4.public.",e,void 0,64,t,c);return a("v4",n,u,i,d,h,"public")}},37975:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),s=i(38639),n=i(44198);function a(){return(0,s.toNotBoolean)((0,n.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,n.env)().NO_COLOR)||["dumb","unknown"].includes((0,n.env)().TERM))}t.noColor=a;let o=!a();function l(){return o}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){o=e??!a()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),s=i(7282),n=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,s.isProd)()?"":`-${(0,s.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+n.version))},48884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),s=i(36783),n=i(76790),a=i(22573),o=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const s=new Set(t.map(i));return e.filter((e=>s.has(i(e))))}function w(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...w(e.slice(i+1))]}function v(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function b(e){return P(e,(e=>e.valueOf()))}function S(e){return M(e,(e=>e.valueOf()))}function P(e,t){return T(e,t,((e,t)=>(0,h.lt)(e,t)))}function M(e,t){return T(e,t,((e,t)=>(0,h.gt)(e,t)))}function _(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function T(e,t,i){return E(e,t,i).index}function E(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let s,n=-1;for(let r=0;re.slice(i,i+t)))}async function k(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,o.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(a.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,o.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,s.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let s=0;for(const n of e)(t(n,s++)?i:r).push(n);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return w(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=v,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let s=0;se.slice(0,t+1)))},t.min=function(e){return e[b(e)]},t.leastIndex=b,t.max=function(e){return e[S(e)]},t.greatestIndex=S,t.leastIndexBy=P,t.greatestIndexBy=M,t.leastBy=_,t.least=function(e){return _(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[M(e,t)]},t.leastByCtx=function(e,t){const i=E(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=D,t.collectBatched=function(e,t,i){const s=[];for(const n of D((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(i(n)));return s},t.collectBatchedAsync=async function(e,t,i){const s=[];for(const n of D((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(await i(n)));return s},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await k(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+s;if(re+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const o=i(77988),l=a(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),w=i(25764),v=i(38836),b=i(99331),S=i(95937),P=i(98314),M=i(38835),_=i(70025),T=i(8769),E=i(43334),D=i(95402),k=i(28874),x=i(63870);class F extends v.EndableWrapper{constructor(e,t,i=w.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>n(this,r,"m",s).call(this)),i,"worker"===e?(0,x.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const a=t;a.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,D.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),a.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),a.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,S.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),a.on("fatalError",(e=>{this.onError("on(fatalError)"+M.FatalErrorFlag,e)})),a.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),a.on("noTaskData",((e,i,r)=>{const s=t.options.streamFlushMillis;s{this.logger.error("observeBatchCluster.endError()",e)})),a.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&D.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof o.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,b.ending)()||!0===(0,_.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,T.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=F,r=new WeakSet,s=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(E.isWin?3:1)*c.minuteMs,maxTasksPerProcess:k.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:k.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:k.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:k.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:k.Settings.taskTimeoutMs.valueOrDefault}}},71371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedGreatestSet=void 0;const r=i(92322);t.BoundedGreatestSet=class{constructor(e,t){this.maxLength=e,this.toValue=t,this.sortedArray=new r.SortedSet(t)}toA(){return this.vacuum(),this.sortedArray.toA()}vacuum(){return this.sortedArray.retainLastN(this.maxLength)}add(...e){this.maxLength<=0||(this.sortedArray.addAll(...e),this.sortedArray.length>=2*this.maxLength&&this.vacuum())}}},89788:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(r.add(this),this.maxLength=e,s.set(this,void 0),n.set(this,0),a.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,s,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]=t))}get length(){return u(this,n,"f")}set length(e){l(this,n,(0,d.clamp)(0,u(this,n,"f"),e),"f")}clear(){this.length=0}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,n,"f")),e<0||e>=u(this,n,"f")?void 0:t((e+u(this,a,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,s,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,n,"f"){u(this,s,"f")[e]=c}));return u(this,n,"f")}pop(){return u(this,r,"m",o).call(this,u(this,n,"f")-1,(e=>{var t;return l(this,n,(t=u(this,n,"f"),--t),"f"),u(this,s,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,n,"f"){u(this,s,"f")[e]=c,l(this,a,e,"f")}));return u(this,n,"f")}shift(){return u(this,r,"m",o).call(this,0,(e=>{var t,i;return l(this,a,(t=u(this,a,"f"),++t),"f"),l(this,n,(i=u(this,n,"f"),--i),"f"),u(this,s,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",o).call(this,u(this,n,"f")-1-e,(e=>{const i=u(this,s,"f")[e];u(this,s,"f")[e]=u(this,s,"f")[t],u(this,s,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),s=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function n(e){for(const{bom:t,encoding:i}of s)if(a(e,t))return e.subarray(t.length).toString(i);return e.toString()}function a(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=n,t.bufferToString=function(e){return Buffer.isBuffer(e)?n(e):(0,r.toS)(e)},t.bufferStartsWith=a},9092:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=s},36638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=s},40583:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const a=i(40958),o=i(23838),l=n(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new o.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,a.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,s=-1;for(const[i,n]of this.m.entries()){const a=(0,c.diceCoeff)(i,e);if(a>t&&a>s){const e=this.getFirst(n);null!=e&&(r=e,s=a)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),s=i(31586),n=i(68708),a=i(54993),o=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new o.Average(0);for(const t of this.keys()){if(!(0,s.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,a.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,s.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,n.tap)(new o.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,s]of this.m.entries()){const n=e(r);t.fill(n,i,i+s),i+=s}return t}}t.CountingSet=u},79840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),s=i(72993),n=i(45969),a=i(43334);t.EditionType=(0,r.lazy)((()=>a.isElectron?"Desktops":(0,n.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>s.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),s=i(55835),n=i(68708);var a=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return a.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,s.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.omit)(e,...i),(0,n.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,s.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),s=i(19851),n=i(95696);t.examples=(0,s.lazy)((()=>n.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),s=i(65843),n=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,s.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,n.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(31586),o=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,a.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,a.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,s.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,s.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,n.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,o.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,o.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,o.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,a.isNumber)(e.__uid)&&(0,a.isNumber)(e.__start)}},80049:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),s.set(this,0),n.set(this,0),a.set(this,0),o.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,s,l(this,s,"f")+e.cacheHitsAsync,"f"),u(this,n,l(this,n,"f")+e.cacheMisses,"f"),u(this,a,l(this,a,"f")+e.rejections,"f"),u(this,o,l(this,o,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,s,"f"),cacheMisses:l(this,n,"f"),rejections:l(this,a,"f"),timeouts:l(this,o,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,a,o;if(!this.cache.has(e))return void u(this,n,(t=l(this,n,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,s,(i=l(this,s,"f"),++i),"f"),c.promise):(u(this,r,(a=l(this,r,"f"),++a),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(o=l(this,r,"f"),++o),"f"),c}get(e){var t,i;const s=this.cache.get(e);return null==s||s instanceof m.Deferred&&s.isPending?u(this,n,(t=l(this,n,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),s instanceof m.Deferred?s.value:s}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,s,0,"f"),u(this,n,0,"f"),u(this,a,0,"f"),u(this,o,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,a,(t=l(this,a,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,o,(r=l(this,o,"f"),++r),"f")})),r.promise}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap},54127:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,a.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,s.range)(0,r).filter((e=>this.rows.every((t=>(0,n.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,o.fromEntries)(e))).filter((e=>(0,o.values)(e).some(n.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,o=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(o,r.index);(0,n.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),h=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:h});else{const e=(0,s.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,a.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}o=t.lastIndex}const l=(0,s.last)(i);return null!=l&&((0,n.blank)(this.headerRow.slice(o))?l.rightIdx=(0,a.max_)(...this.rows.map((e=>e.length))):l.rightIdx=o),i}}t.Fixed=m},73168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const r=i(55835),s=i(20014),n=i(55222),a=i(97352),o=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,a.within)(-90,90,e)&&0!==e}function c(e){return(0,a.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function h(e,t,i=o){return(0,r.map)(m(e,t,l(i)),(e=>n.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=o){return h(e?.lat,e?.lon,t)},t.geohash=h,t.geohashNumericShort=function(e,t){return m(e,t,30)};const f=new s.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=o){return d(e,t)?f.zip([t,e],l(i)):void 0}function p(e,t=o){return f.unzip(e,l(t))?.reverse()}function g(e,t=o){const[i,r]=p(e,t);return{lat:i,lon:r}}t.geohashNumeric=m,t.ungeohash=function(e,t=o){return(0,r.map)(n.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,r=t.lat*Math.PI/180,s=(t.lat-e.lat)*Math.PI/180,n=(t.lon-e.lon)*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(r)*Math.sin(n/2)*Math.sin(n/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},66364:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSuspended=void 0;const r=i(19851);t.isSuspended=(0,r.lazy)((()=>!1))},80875:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),s=i(98553);var n=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return n.parseJSON}}),t.mapParsed=function(e,t){const i=(0,s.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,s.parseJSON)((await(0,r.readFile)(e)).toString())}},57206:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDefaultJsonRevivers=void 0;const r=i(77988),s=i(51168),n=i(45599),a=i(98553),o=i(68708),l=i(24689),u=i(21330),c=i(57159),d=i(28544),h=(0,n.defer)((()=>{s.DateTime.prototype.toJSON=function(){return(0,o.compactValues)({_ctor:s.DateTime.name,ts:this.toMillis(),zone:"system"===this.zone?.type?void 0:this.zoneName})}})),f={name:s.DateTime.name,fromJSON:e=>s.DateTime.fromMillis(e.ts,(0,o.compactValues)({zone:e.zone}))};t.addDefaultJsonRevivers=(0,n.defer)((()=>{h(),(0,a.addJsonRevivers)(r.ExifDateTime,r.ExifDate,r.ExifTime,f,d.CapturedAt,l.DateInterval,u.FuzzyDate,r.BinaryField,c.WrappedError)}))},19851:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const a=i(57975),o=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&n(this,r,"m",s).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,o.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,o.mkLogger)("Locale")));function w(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=b(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>S(w()??await(m.isWin?P():m.isMac?_():T()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(w);const v=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function b(e){if((0,n.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=v.exec(e.trim())?.groups;return null==i?void 0:(0,s.compact)([i.lang,i.country]).join("-")}function S(e){return b(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=S,t.localeWin=P;const M={timeoutMs:10*a.secondMs};async function _(){return b(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],M))}async function T(){return S(w((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],M)})))}t.localeMac=_,t.localePosix=T,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),s=i(1708),n=i(45599),a=i(68708),o=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,n.defer)((()=>{(0,o.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:s.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,a.pick)(s.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:s.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),s=i(32105),n=i(14593);t.rootLoggers=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));const a=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));t.mkLogger=function(e){return new n.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new n.ContextualLogger(e,a)}},56639:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),s=i(55835),n=i(59455),a=i(48884);function o(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,a.concat)(...e.map((e=>t(e)))))},t.compactMap=o,t.toMap=function(e,t){return o((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:o(await Promise.all((0,r.compact)((0,n.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,s.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),s=i(54557);t.memoize=function(e,t){let i=0;const n=new s.FifoCache(t.maxSize,t.ttlMs),a=t=>{if(null!=t)return i++,n.getOrSet((0,r.stringify)(t),(()=>e(t)))};return a.clear=e=>null==e?n.clear():n.delete((0,r.stringify)(e)),a.size=()=>n.size,a.callCount=()=>i,a}},31578:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const r=i(1708),s=i(31586),n=i(12168),a=i(70417);function o(){const e=(0,r.memoryUsage)();return(0,a.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,r.memoryUsage)().rss}t.memoryUsageBytes=o,t.memoryUsageMb=function(){return(0,s.sigFigs)(o()/n.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,s.sigFigs)(l()/n.MB,2)}},7282:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const s=r(i(1708)),n=i(38639),a=i(54993),o=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,o.lazy)((()=>s.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,a.toS)(s.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return s.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,n.isTrue)(s.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){s.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55835),o=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,o.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(o.gt0)},t.firstNonZero=function(...e){for(const t of(0,n.flatten)(e)){const e=(0,o.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,a.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,o.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,o.toInt)(e),s=(0,o.toInt)(t);return null!=r&&r>0&&null!=s&&s>0?i(r,s):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,o.isNumber)(e))return e;if((0,s.blank)(e))return;const t=String(e);return(0,a.map)(f.exec(t),(e=>(0,o.toFloat)(t.substr(e.index))))}function p(e){return(0,o.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,a.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,a.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const s=i*e.length;for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),s=i(42659),n=i(96249),a=i(55835),o=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,s.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,s]of(0,l.entries)(e)){const e=t(r,s);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,a.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(a.defined)},t.firstDefinedField=function(e,...t){return(0,a.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,a.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const s of t)r[s]=i(s,e[s]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let s=0;for(const n of(0,l.keys)(e))if(r[n]=t(n,e[n]),s++,(0,o.gt)(s,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,n.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),s=i(73024),n=i(48161),a=i(19851),o=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),w=i(30933),v=(0,a.lazy)((()=>(0,f.mkLogger)("os")));function b(){return(0,n.platform)()+" "+(0,n.release)()}t.osArch=(0,a.lazy)((()=>`${function(){switch((0,n.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return F();case"win32":return C();default:return b()}}()} on ${(0,n.arch)()}`)),t.osFullName=(0,a.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const S=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function M(){return"ubuntu"===(0,t.osDistributionLinux)()}function _(){return"fedora"===(0,t.osDistributionLinux)()}function T(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,a.lazy)((()=>{if(g.isLinux)for(const e of S)try{const t=(0,s.readFileSync)(e).toString();if((0,o.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){v().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,a.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,o.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),b)})),t.osDistributionLinux=(0,a.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=M,t.hasApt=function(){return P()||M()},t.isFedora=_,t.isAlpine=T;const E={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},D={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function k(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),s=t[i];return(0,c.isString)(s)?s:s?.[r]}const x=(0,a.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function F(e=x()){try{return(0,o.mapNotBlankOr)(function(e=x()){return k(e,E)}(e),(t=>`macOS ${t} (${e})`),b)}catch(e){return v().warn("osNameMac(): unknown release",e),b()}}function C(e=(0,n.release)()){const t=e.startsWith("10.0.22")?"11":k(e,D);return null!=t?`Windows ${t} (${e})`:(v().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=F,t.osNameWin=C,t.CPUs=(0,a.lazy)((()=>(0,h.uniqCount)((0,w.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,a.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(C())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=x();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(M())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(_())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(T())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},45393:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetVersion=t.AssetFileVersion=void 0,t.AssetFileVersion=12,t.AssetVersion=4},12801:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const s=r(i(48161)),n=i(50989);t.PriorityClasses=(0,n.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:s.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:s.default.constants.priority.PRIORITY_NORMAL,BelowNormal:s.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:s.default.constants.priority.PRIORITY_LOW,Low:s.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setProcessTitle=t.setShortProcessNames=void 0;const r=i(72993),s=i(50213),n=i(23560),a=i(43334);let o=!a.isElectron;t.setShortProcessNames=function(e){o=e},t.setProcessTitle=function(){try{const e=[o?r.SimpleShortAppName:r.SimpleAppName];(0,n.isMainService)()&&a.isElectron||e.push((0,n.serviceName)());const t=e.join(a.isElectron?" ":"-");i(85949).title=t}catch(e){(0,s.mkLogger)("ServiceNames").warn("Failed to set friendly process name",e)}}},92782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeRandomUid=t.safeRandomChars=void 0;const r=i(55222),s=i(65713);t.safeRandomChars=function({radix:e=r.TokenRadix,length:t}){return(0,s.decuss)((()=>e.randomChars(t)))},t.safeRandomUid=function(e){return(0,s.decuss)((()=>(e?.radix??r.TokenRadix).randomUid(e?.chars??20,e?.splitEveryN??5,e?.sepChar??"-")))}},409:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),s=i(56409),n=i(31586),a=i(22911),o=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,v(...e)}}async function w(...r){f=!0,m=Date.now()+(0,n.max_)(t,i);const s=d=new a.Deferred(c);(0,n.gt0)(i)&&s.setTimeout(i);try{s.resolve(await e(...r))}catch(e){s.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,o.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return s.promise}const v=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,r.delay)(1).then((()=>t))}return w(...e)};return v.clear=()=>{h=void 0},v.donePromise=()=>{if(!f)return Promise.resolve();const e=new s.Latch;return p.push(e),e},v.force=async(...e)=>(h=void 0,f&&await v.donePromise(),w(...e)),v.isRateLimited=()=>g(),v.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),v.minCallDelayMs=()=>t,v.setMinCallDelayMs=e=>{t=e},v}},68852:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),s=i(54993);function n(e){return e instanceof a?e.source:(0,s.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let s;for(;null!=(s=e.exec(t));)s.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(s,"index","groups"));return i},t.escapeRegExp=n,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(n(t))}const s=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(s,i)};class a{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=a;class o extends a{static from(...e){const t=l(e);return new o("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,o=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof a||t instanceof RegExp?(i+=t.source,r||(r=t.global),o||(o=t.ignoreCase),l||(l=t.multiline)):i+=n((0,s.toS)(t));return new RegExp(i,t??(r?"g":"")+(o?"i":"")+(l?"m":""))}t.RegExpOptional=o,t.concatRegexp=l},79089:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),w=i(34102),v=i(43334),b=i(24399),S=i(28874),P=(0,a.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,w.ee)().on("clearCache",(()=>T.prior()?.clear()))));const M=(0,a.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",n.default.basename(S.Settings.ffmpegPath.valueOrDefault)].map((e=>v.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,o.compactBlanks)([n.default.basename(e),...t.map((e=>n.default.basename(e)))]).some((e=>M().includes(e.toLowerCase())))};let _=!0;const T=(0,a.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||T().has(e))return;T().add(e);const i=(0,p.priorityPosixToClass)(t)??S.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),_)try{return s.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;_=!1}try{return await(v.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await b.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const s=r(i(1708)),n=i(19851),a=i(40958),o=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===o.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===o.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===o.ServiceNames.sync}function p(){return(0,t.serviceName)()===o.ServiceNames.test}t.serviceName=(0,n.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,n.lazy)((()=>(0,a.compactBlanks)([t.serviceName.prior(),(0,l.toS)(s.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return o.ServiceNames.indexOf(e)??o.ServiceNames.length+1},t.MainServices=[o.ServiceNames.main,o.ServiceNames.desktop],t.DbServices=[o.ServiceNames.sync,o.ServiceNames.info,o.ServiceNames.web,o.ServiceNames.list,o.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[o.ServiceNames.sync,o.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===o.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===o.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,n.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function s(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=s,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=s(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=s(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),s=i(57150),n=i(7282),a=i(23560),o=i(17181);t.setServiceName=function(e){(0,a.isMainService)(e)&&(e=r.ServiceNames.main);const t=a.serviceName.prior();t!==e&&((0,n.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),a.serviceName.set(e),(0,o.setupLogger)(),(0,s.logStartup)())}},28850:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const o=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends o.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),s.set(this,void 0),n(this,r,e,"f")}_call(){return(0,l.time)(a(this,r,"f")+(null==a(this,s,"f")?"(local)":"(remote)"),null==a(this,s,"f")?this.impl():a(this,s,"f").call(this))}setShim(e){n(this,s,e,"f")}hasShim(){return null!=a(this,s,"f")}clearShim(){n(this,s,void 0,"f")}}r=new WeakMap,s=new WeakMap},12089:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,a){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=a,s.set(this,void 0),n.set(this,void 0),l(this,s,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",o).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",a).call(this,e),(()=>u(this,r,"m",o).call(this,e)))}setShim(e){l(this,n,e,"f")}hasShim(){return null!=u(this,n,"f")}clearShim(){l(this,n,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",a).call(this,e))}}s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},o=function(e){return(0,m.time)(u(this,s,"f")+(null==u(this,n,"f")?"(local)":"(remote)"),null==u(this,n,"f")?this.impl(e):u(this,n,"f").call(this,e))}},45255:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const n=i(76790),a=i(17586);class o{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return s(this,r,"f")[Symbol.iterator]()}get length(){return s(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=s(this,r,"f").length-1;for(;t<=i;){const n=t+Math.floor((i-t)/2),a=this.valueOf(s(this,r,"f")[n]);if(e===a)return{found:!0,index:n};e>a?t=n+1:i=n-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&s(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...s(this,r,"f")];const a=t=>t<0||t>s(this,r,"f").length-1?null:(i??this.diff)(s(this,r,"f")[t],e),o=this.findIndex(e);if(null==o)return;let l=o.index-1,u=a(l),c=o.index,d=a(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return s(this,r,"f").shift()}at(e){return(0,a.at)(s(this,r,"f"),e)}toA(){return[...s(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===s(this,r,"f").length-1){const e=[...s(this,r,"f")];return s(this,r,"f").length=0,e}return s(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return s(this,r,"f").splice(e,t)}retainLastN(e){return e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),s=i(82328),n=i(84542),a=i(95705),o=i(28874);t.consoleLog=function(e,...t){o.Settings.quiet.valueOrDefault||(0,s.stdoutEnded)()||console.log((0,n.crlf)(e),...t)},t.consoleError=function(e){o.Settings.quiet.valueOrDefault||(0,a.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=o.Settings.quiet.envValue;try{return o.Settings.quiet.envValue=!0,await e()}finally{o.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),s=i(95705);t.stdoutEnded=function(){return(0,s.streamEnded)(r.stdout)}},71567:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const s=r(i(1708)),n=i(22573),a=i(98553),o=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:s.default.stdout})}function f({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const s=(0,a.stringify)(e,void 0,(0,o.isInfoService)()||(0,o.isMainService)()?2:void 0);r.write(s+"\n"),(0,o.isWorkerService)()&&null!=i&&(s.includes(u.FailStr)||(0,c.isFatalError)(s)||(0,c.isHealthCheckError)(s)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||s.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:s.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,n.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const w=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const s=t.indexOf(i,r);return-1===s?0:1+e(t,i,s+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,n.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,o.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,h.toS)(e),s=(0,h.toS)(t);return s.length>0&&(0,c.equalsIgnoreCase)(r.slice(-s.length),s,i)?r.slice(0,-s.length):r},t.gist=function(e,t=80,i=80){const r=(0,h.toS)(e),s=r.length-(t+i);return s<=0?r:r.slice(0,t).trim()+" …(+"+s+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const v=/^[A-Z]/;function b(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function S(e){return(0,d.toA)(e).sort(b)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return v.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,n.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=b,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=S,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,a.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=b(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,n.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),s=t.indexOf(r);if(s>=0)return{index:s,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const M=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function _(e){return M.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=_;const T=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,n.blank)(e)||(e=(0,h.toS)(e).trim(),null!=T.exec(_(e))&&(e=e.slice(1,-1).trim())),e};const E=/^['‘’].*['‘’]$/,D=/^["“”„«»〃].*["“”„«»〃]$/;function k(e,t){const i=x(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function x(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let s,n=0;for(;null!=(s=t.exec(e));)s.index===t.lastIndex?t.lastIndex++:(t.lastIndex=s[0].length+s.index,i.push(e.substring(n,s.index)),r.push(e.substring(s.index,t.lastIndex)),n=t.lastIndex);return n(0,o.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),E.test(e)||D.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>w.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),s=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,a.map)(i[e],(e=>t+=e))));return t},t.splitKeep=k,t.splitUp=x,t.sortNaturalBy=F,t.sortNatural=function(e){return(0,s.sortBy)(e,(e=>F(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=S((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,s.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,n.blank)(e)||(0,n.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,o.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const C=/#.*$/gm;t.stripComments=function(e){return e.replace(C,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,n.blank)(r))for(const e of r.split(t))(0,n.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,n.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),s=e.findIndex((e=>r.test(e))),a=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(s<0)return e;for(let t=s+1;te.trim()))))}},83556:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function s(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=s,t.asObjectKey=function(e){return s(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const s=r(i(77598)),n=i(73913),a=i(55222);function o(e,t=n.HashBits){return s.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=a.Radix58,r=224){return i.encodeBuffer(o(e,r)).substring(0,t)}t.stringShaToBuffer=o,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=a.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(31586),o=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,s="";for(let n=0;n=r&&(r=i.get(n,a),s=(0,l.substr)(e,n-r+1,r)));return s}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),s=t.normalize();return e!==r||t!==s?y(r,s):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function w(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===r?1:void 0),(()=>(0,n.blank)(e)!==(0,n.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=v(i),t=v(r);return 2*b(e,t).length/(e.length+t.length)}))}function v(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function b(e,t){const i=(0,f.intersection)(e,t),s=[];return i.forEach((i=>{const n=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,a.times)(n,(()=>s.push(i)))})),s}function S(e,t,i){const s=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,s))-i((0,l.strslice)(t,s))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,s.sortBy)(t,(e=>-e.length))[0]}function M(e,t){const[i,r]=[e,t].map(P).map((e=>(0,n.blank)(e)?"":e));return S(i,r,(e=>(0,a.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(n.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=w,t.bigrams=v,t.nonUniqIntersection=b,t.lnsDiff=M;const _=/[^\da-z]+/gi;function T(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(_,"").toLowerCase()));return S(i,r,(e=>c.RadixAlphaNum.decode(e)))}function E(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const s=(0,a.mapNumericOr)(e.charCodeAt(r),(e=>e),256),n=(0,a.mapNumericOr)(t.charCodeAt(r),(e=>e),256),o=(0,a.clamp)(-256,256,s-n);i=null==i?o:(i+o)/2}return i}t.radixDiff=T,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:w(e,t),lns:M(e,t),radixDiff:T(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=E,t.paddedPositionalDiff=function(e,t,i=8){return E((0,o.leftPad)(e,i," "),(0,o.leftPad)(t,i," "))}},84885:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),s=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,s.sortedKeys)(e))}},88264:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TTLArray=void 0;const r=i(31586);class s{constructor(e,t){this.ttlMs=e,this.maxLength=t,this.times=[],this.a=[],this.expirationListeners=[]}[Symbol.iterator](){this.vacuum();const e=[...this.a];return function*(){for(const t of e)yield t}()}push(...e){(0,r.times)(e.length,(()=>this.times.push(Date.now()))),this.a.push(...e),null!=this.maxLength&&this.vacuum()}pushUniq(...e){e.forEach((e=>{this.includes(e)||this.push(e)}))}includes(e){return this.vacuum(),this.a.indexOf(e)>=0}find(e){return this.vacuum(),this.a.find(e)}some(e){return this.vacuum(),this.a.some(e)}shift(){return this.vacuum(),this.times.shift(),this.a.shift()}first(){return this.vacuum(),this.a[0]}last(){return this.vacuum(),this.a[this.a.length-1]}shiftOrFirst(){return this.length>1?this.shift():this.first()}pop(){return this.vacuum(),this.times.pop(),this.a.pop()}onExpire(e){this.expirationListeners.push(e)}slice(e,t){return this.vacuum(),this.a.slice(e,t)}get length(){return this.vacuum(),this.a.length}clear(){return this.times.length=0,this.a.length=0,this}get values(){return this.vacuum(),[...this.a]}map(e){return this.vacuum(),this.a.map(e)}oldestEntryAge(){return this.vacuum(),this.times[0]}vacuum(){if(0===this.a.length)return;const e=this.a.length;if(null!=this.maxLength){const e=this.a.length-this.maxLength;this.times.splice(0,e),this.a.splice(0,e)}const t=Date.now()-this.ttlMs,i=this.times.findIndex((e=>e>t));if(-1===i?this.clear():i>0&&(this.times.splice(0,i),this.a.splice(0,i)),e!==this.a.length)for(const e of this.expirationListeners)e()}}t.TTLArray=s},75387:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",s.set(this,[]),n.set(this,new Map),a.set(this,void 0),o.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,a,"f")}set ttlMs(e){h(this,a,e,"f"),null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),h(this,o,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,n,"f").clear(),this}delete(e){return d(this,n,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,n,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,n,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,n,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const s=t();return null!=s&&this.set(e,s),s}lastSetOrGetTs(e){return d(this,n,"f").get(e)?.ts}set(e,t){return d(this,n,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,n,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,n,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,f.sortBy)(d(this,n,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,s,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,n,"f").delete(e);for(const i of d(this,s,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,n,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[a]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return o(this,r,"m",n).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>o(this,r,"m",n).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||o(this,r,"m",s).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)o(this,r,"m",s).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!o(this,r,"m",s).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield[t,t])}()}toA(){return o(this,r,"m",n).call(this),[...this.delegate.keys()]}[(r=new WeakSet,a=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,s=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},n=function(){for(const[e,t]of this.delegate)o(this,r,"m",s).call(this,e,t)}},84699:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},65211:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resetUid=t.sortByUid=t.tsFromUid=t.isUID=t.uidForTs=t.uid=t.uidSuffix=void 0;const r=i(19851),s=i(76790),n=i(22573),a=i(54993),o=i(7282),l=i(55222);let u=0;const c=l.GeoRadix;function d(e){return c.encode(e)+(0,t.uidSuffix)()}t.uidSuffix=(0,r.lazy)((()=>"-"+c.randomChars(7))),t.uid=function(){return u=Math.max(Date.now(),u+1),d(u)},t.uidForTs=d;const h=/^[\da-z]{9}-[\da-z]{7}$/i;function f(e){const t=(0,a.toS)(e).replace(/(?<=\S)-.*/,"");return(0,n.blank)(t)?void 0:c.decode(t)}t.isUID=function(e){return h.test((0,a.toS)(e))},t.tsFromUid=f,t.sortByUid=function(e){return(0,s.sortBy)(e,(e=>f(e.uid)))},t.resetUid=function(){if(!(0,o.isTest)())throw new Error("unsupported");t.uidSuffix.unset(),u=0}},94174:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,a.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,a.lazy)((()=>(0,o.uniq)([n.default.geteuid?.(),n.default.getuid?.(),s.default.userInfo().uid]))),t.userid=(0,a.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,a.lazy)((()=>(0,o.uniq)([n.default.getegid?.(),n.default.getgid?.(),s.default.userInfo().gid]))),t.groupid=(0,a.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,a.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,a.lazy)((()=>(0,l.toNotBlank)(s.default.userInfo()?.username))),t.userNameFromWhoami=(0,a.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,a.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,a.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,a.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.1-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=1,t.versionPrerelease=["prealpha"],t.release="2024.3.1-prealpha+20240308150212",t.gitSha="d92384e8659ff46fbae8e6f81fa5867114a4a843",t.gitDate=new Date(1709938932e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48299:function(e,t){"use strict";var i,r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.WeakCache=void 0;class o{constructor(){i.add(this),this[n]="WeakCache",r.set(this,new Map)}clear(){return a(this,r,"f").clear(),this}delete(e){return a(this,r,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of this.entries())e(i,t,this)}findEntry(e){for(const[t,i]of this.entries())if(e(i,t,this))return i}deleteValueIf(e){for(const[t,i]of this.entries())e(i,t,this)&&a(this,r,"f").delete(t)}get(e){const t=a(this,r,"f").get(e),i=t?.deref();return null==i&&null!=t&&a(this,r,"f").delete(e),i}getOrMaybeSet(e,t){const i=a(this,r,"f").get(e)?.deref();if(null!=i)return i;const s=t();return null!=s&&this.set(e,s),s}set(e,t){return a(this,r,"f").set(e,new WeakRef(t)),this}has(e){return null!=a(this,r,"f").get(e)?.deref()}get size(){return a(this,i,"m",s).call(this),a(this,r,"f").size}keys(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries())null==i.deref()?a(e,r,"f").delete(t):yield t}()}values(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield s}}()}entries(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield[t,s]}}()}[(r=new WeakMap,i=new WeakSet,n=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}}t.WeakCache=o,s=function(){for(const[e,t]of a(this,r,"f").entries())null==t.deref()&&a(this,r,"f").delete(e)}},48963:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),s=i(55835),n=i(31586),a=i(97790),o=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,n.toInt)(e)));if(!(0,s.allDefined)(i))return;const[a,o,u,c,d,h,f]=i,m=(0,n.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(a,o-1,u,c,d,h,f/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,a.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(n.toInt).filter((e=>(0,o.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},79184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aggregateAssetFiles=void 0;const r=i(59455),s=i(48884),n=i(22859),a=i(28874),o=i(79781),l=i(92434);t.aggregateAssetFiles=async function(e){const t=(0,r.toA)((0,l.sortAssetFiles)(e)??e);return(a.Settings.assetAggregation.valueOrDefault===n.AggregateTypes.union?s.clusterSome:s.clusterEvery)(t,o.isSimilarAssetFile)}},79781:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotSimilarAssetFile=t.isSimilarAssetFile=t.whyNotSameAsset=t.VideoImageMismatchMsg=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(50357),o=i(55835),l=i(31586),u=i(68708),c=i(12168),d=i(23467),h=i(73168),f=i(50213),m=i(86580),p=i(48368),g=i(80361),y=i(28874),w=i(28544),v=i(75767),b=i(16170),S=(0,r.lazy)((()=>(0,f.mkLogger)("sync-file.AssetFileComparator")));function P(e,t,i,r=((e,t)=>[e,t])){const s=e[i],o=t[i];if((0,n.blank)(s)||(0,n.blank)(o)||(0,a.eql)(s,o))return;const[l,u]=r(s,o);return(0,a.eql)(l,u)||(0,a.eql)(s,u)||(0,a.eql)(l,o)?void 0:`Different ${String(i)}: ${s} ≠ ${o}`}function M(e){return(0,n.mapNotBlank)(e,(e=>e.toLowerCase().trim().normalize()))}function _(e,t){return[M(e),M(t)]}function T(e,t,i){const r=(0,v.findInequalFields)(e[i],t[i]);return null==r?void 0:`Different ${i} (${r.aKey}:${r.aValue} ≠ ${r.aKey}:${r.aValue})`}function E(e,i){if(!(0,u.allKeysDefined)(e,"width","height","mimetype","sha"))return"af1 was missing required fields";if(!(0,u.allKeysDefined)(i,"width","height","mimetype","sha"))return"af2 was missing required fields";if((0,d.definedAndEql)(e.sha,i.sha))return void S().debug("matching SHA",{af1:e,af2:i});const r=(0,b.isVideoMimeType)(e.mimetype),n=(0,b.isVideoMimeType)(i.mimetype);if(r!==n)return S().tap({msg:"whyNotIsSimilar",result:t.VideoImageMismatchMsg,meta:{af1:e.uri,af2:i.uri,af1IsVideo:r,af2IsVideo:n}});const a=w.CapturedAt.fromAssetFile(e),f=w.CapturedAt.fromAssetFile(i);if(null==a)return"af1 missing capturedAt metadata";if(null==f)return"af2 missing capturedAt metadata";const M=a.isFuzzy||f.isFuzzy;if(M&&y.Settings.allowFuzzyDateImageHashMatches.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if((0,g.isSimilarImageHash)(t,r,{rotationsToCheck:(0,m.validRotations)(e,i)}))return void S().info("allowFuzzyDateImageHashMatches mode: image hashes match",{af1:e,af2:i})}if(!a.overlaps(f))return`captured-at ${a.toISOStringWithPrecision()} != ${f.toISOStringWithPrecision()}`;const E=P(e,i,"make",_)??P(e,i,"model",_);if(null!=E)return E;const D=(0,o.map)((0,h.geohashDistanceMeters)(e.geohash,i.geohash),(e=>(0,l.sigFigs)(e,2))),k={cameraId:T(e,i,"cameraId")??null,imageId:T(e,i,"imageId")??null,lensId:T(e,i,"lensId")??null,exposureSettings:(0,v.whyExposureSettingsNotSimilar)(e,i)??null,closeGeoHash:(0,l.gt)(D,y.Settings.gpsErrorMeters.valueOrDefault)?"geohashes are "+(0,c.fmt)(D)+"m different: too far apart":null};S().debug("whyNotSimilar()",{fields:k});const x=(0,s.compact)((0,u.values)(k));if((0,s.isNotEmpty)(x))return x.join(";");if(y.Settings.useImageHashes.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if(null!=t&&null!=r){const e=(0,g.compareImageHashes)(t,r,{capturedAtIsFuzzy:M});return!0===e?.isSimilar?void 0:e?.whyNotSimilar}}return(0,u.keys)(k).filter((e=>null==k[e])).length>=y.Settings.minMatchesWithoutImageHashes.valueOrDefault?void 0:"Insufficient metadata correlation"}t.VideoImageMismatchMsg="Videos ≠ images",t.whyNotSameAsset=function(e,t,i){{const i=E(e,t);if(null!=i)return i}if("intersection"===y.Settings.assetAggregation.valueOrDefault)for(const r of i)if(r.id!==t?.id){const t=E(e,r);if(null!=t)return t}},t.isSimilarAssetFile=function(e,t){return null==E(e,t)},t.whyNotSimilarAssetFile=E},13991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkSortableAssetFile_=t.mkAssetFile_=t.assetFileMetadata_=t.assetFileImageHashFields_=t.imageHashToAssetFileImageHashFields=t.assetFileStatFields_=t.assetFileUriFields_=void 0;const r=i(19851),s=i(55835),n=i(31586),a=i(59455),o=i(73168),l=i(50213),u=i(12089),c=i(76490),d=i(95696),h=i(48368),f=i(70417),m=i(28874),p=i(43207),g=i(47783),y=(0,r.lazy)((()=>(0,l.mkLogger)("asset-file.AssetFileFactory")));async function w(e){try{return{nativePath:e.nativePath,uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath}}catch(t){return y().throw("Failed to build URI for "+e,{error:t})}}async function v(e){const t=await e.stat_(),i=await e.sidecareStats();return{mtime:Math.floor((0,f.max)([t.mtimeMs,...(0,a.toA)(i).map((e=>e.mtimeMs))])),fileSize:t.size}}function b(e){return{...e,...c.DominantColor.toModeData(e.dominantColors)}}async function S(e){if(!m.Settings.useImageHashes.valueOrDefault)return;const t=await(0,h.imageHash_)(e.nativePath);return null==t?y().throw("Failed to extract image hash for "+e):b(t)}async function P(e){const[i,r,s,n]=await Promise.all([w(e),v(e),(0,t.assetFileMetadata_)(e),e.sha_()]);return{...i,...r,...s,sha:n}}t.assetFileUriFields_=w,t.assetFileStatFields_=v,t.imageHashToAssetFileImageHashFields=b,t.assetFileImageHashFields_=S,t.assetFileMetadata_=(0,u.shim1)({name:"asset-file.assetFileMetadata",impl:async function(e){try{const t=d.PosixFile.for(e),i=await(0,g.readTags)(t);if(null==i)throw new Error("Failed to read tags");if(null==i.capturedAt)throw new Error("Failed to read capturedAt");const r=i.capturedAt.toAssetFileFields();return null==r?y().throw("Failed to render assetFileFields from capturedAt",{capturedAt:i.capturedAt}):{...r,...i.exposureSettings,...i.dimensions,mimetype:i.mimetype,rotation:i.rotation,make:i.Make,model:i.Model,rating:i.rating,cameraId:i.cameraId,imageId:i.imageId,lensId:i.lensId,geohash:(0,o.geohashNumericShort)(i.GPSLatitude,i.GPSLongitude),durationMs:(0,p.extractDurationMs)(i),fps:(0,s.map)((0,n.toFloat)(i.VideoFrameRate),Math.floor)}}catch(t){return y().throw("_assetFileMetadata_() failed",{nativePath:e,error:t})}}}),t.mkAssetFile_=async function(e){const[t,i]=await Promise.all([P(e),S(e)]);return{...t,...i}},t.mkSortableAssetFile_=P},92434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestExistingAssetFile=t.assetFileSortCriteria=t.assetFileSortFields=t.assetFileSortCriteriaPojo=t.sortAssetFiles=t.mtime2sort=t.sortScale=t.dim2sort=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(23838),u=i(31586),c=i(68708),d=i(34666),h=i(50989),f=i(89937),m=i(50213),p=i(4001),g=i(29882),y=i(28874),w=i(14036),v=i(45200),b=i(34238),S=(0,r.lazy)((()=>(0,m.mkLogger)("img.AssetFileSorter"))),P=(0,h.strEnum)("file",f.PS_NETWORK_FILESYSTEM_SCHEME,f.PS_LOCAL_FILE_SCHEME,f.PS_LIBRARY_SCHEME);function M(e){return(0,u.map2Numeric)(e?.width,e?.height,((e,t)=>_(e*t)))}function _(e){if((0,u.gt0)(e))return Math.round(Math.pow(e,y.Settings.variantSortCriteriaPower.valueOrDefault))}function T(e){return Math.round(e/(5*o.minuteMs))}t.dim2sort=M,t.sortScale=_,t.mtime2sort=T;const E=["make","model","rating","cameraId","imageId","lensId","geohash"];function D(e){for(const t of(0,l.groupBy)(e,(e=>e.sha)).values())if(t.length>1){const e=Math.max(...(0,s.compact)(t.map((e=>e.mtime))));for(const i of t)i.mtime=e}return(0,n.sortBy)(e,F).reverse()}function k(e){const t=b.URI.parse(e.uri);if((0,a.blank)(t?.scheme)||(0,a.blank)(t?.path))return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI)",{uri_scheme:t?.scheme,uri_path:t?.path,af:e,parsedURI:t});const i=M(e);if(null==i)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid resolution)",{resolution:i,af:e,parsedURI:t});const r=P.indexOf(t.scheme);if(null==r)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI scheme)",{uri_scheme:t.scheme,af:e,parsedURI:t});const s=e.mtime??0,n=(0,g.parsePosixPath)(t.path),l=[];for(const t of E)(0,a.blank)(e[t])||l.push(t);const u={resolution:i,schemeIdx:r,capturedAtPrecision:-(e.capturedAtPrecisionMs??o.weekMs),metadataCoverage:l.length,metadataFields:l.join(","),isBrowserSupported:(0,w.isSupportedByCurrentBrowserExt)(n.ext),mtime:T(s),isEditOrUpdate:/edit|update/i.test(n.base),isCover:/cover/i.test(n.base),count:Math.abs((0,p.copySuffixCountFromName)(n.name)??0),basename:d.CmpReverseFlag+n.base,parentBasename:d.CmpReverseFlag+(0,g.parentBasename)(e.nativePath??t.path),uri:d.CmpReverseFlag+e.uri};return S().tap({msg:"assetFileSortCriteriaPojo()",result:(0,c.toReqValued)(u)})}function x(){return(0,s.uniq)([...y.Settings.variantSortCriteria.values,"uri"])}function F(e){const t=k(e);if(null==t)return;const i=[];for(const e of x())i.push(t[e]);return i}t.sortAssetFiles=D,t.assetFileSortCriteriaPojo=k,t.assetFileSortFields=x,t.assetFileSortCriteria=F,t.bestExistingAssetFile=async function(e){for(const t of D(e))if(await(0,v.uriExists)(t.uri,t.nativePath))return S().tap({msg:"bestExistingAssetFile()",result:t,meta:{files:e.map((e=>e.uri))}});return S().tap({msg:"bestExistingAssetFile(): no existing uris",result:void 0,meta:{files:e.map((e=>e.uri))}})}},54296:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetFileNativePath=void 0;const r=i(45200);t.getAssetFileNativePath=async function(e){return e.nativePath??(e.nativePath=await(0,r.uri2nativePath)(e.uri,e.mountpoint))}},73568:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const o=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),s.set(this,(0,o.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,n(this,s,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return n(this,s,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,n(this,s,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),a(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=n(this,r,"f")&&clearTimeout(n(this,r,"f")),a(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,s=new WeakMap},69591:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const s=r(i(87997)),n=i(31586);t.debounce=function(e,t){let i,r=[];const a=(0,n.gt0)(t)?(...n)=>{r=n,null!=i&&s.default.clearTimeout(i),i=s.default.setTimeout((()=>{e(...r)}),t)}:e;return a.reset=()=>{null!=i&&s.default.clearTimeout(i),i=void 0},a.force=()=>{a.reset(),e()},a.setTimeoutMs=e=>{a.reset(),t=e},a.timeoutMs=()=>t,a}},22911:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const w=y(i(87997)),v=y(i(57975)),b=i(45599),S=i(26905),P=i(55835),M=i(31586),_=i(68708),T=i(20214),E=i(57153),D=i(85556),k=i(50213),x=i(70025),F=i(95937),C="TIMEOUT",A=(0,b.defer)((()=>(0,k.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,M.gt0)(t)?new s(C).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const s=i[r];if(s.isSettled){if(s.name===C)return void A().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield s.value}}if(i.every((e=>e.name===C)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new s(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),a.set(this,void 0),o.set(this,E.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=s,s,(y=p(i,s,"f",n),m=y++,y),"f",n),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,k.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof s&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,o,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,_.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,a,"f")}get elapsedMs(){return(p(this,a,"f")??Date.now())-this.startedAt}get[(a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[v.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,T.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,T.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(w.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,M.gt0)(e)&&(g(this,h,w.default.setTimeout((()=>{this.isPending&&(this.reject(new D.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,F.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,o,"f")===E.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,o,"f")!==E.PromiseStates.pending}get isResolved(){return p(this,o,"f")===E.PromiseStates.resolved}get isRejected(){return p(this,o,"f")===E.PromiseStates.rejected}get settledMs(){return null==p(this,a,"f")?void 0:p(this,a,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,o,E.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,x.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,S.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,o,E.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,s=I,m=function(e){if(p(this,o,"f")===E.PromiseStates.pending){(0,P.map)(p(this,h,"f"),w.default.clearTimeout),e(),g(this,a,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},n={value:0}},83412:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DoneWrapper=void 0;const r=i(56409),s=i(38836);class n extends s.EndableWrapper{constructor(){super(...arguments),this.doneLatch=new r.Latch}isDone(){return this.doneLatch.isSettled()||this.ended}donePromise(){return this.doneLatch.promise}}t.DoneWrapper=n},27395:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(23838),o=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new a.MultiMap;(0,m.setUnrefInterval)((()=>v()),10*n.minuteMs);const y=5*n.secondMs;async function w(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,o.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function v(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>w(e))))},t.end=w,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),v();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,s.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>w(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,s.compact)(g.valuesFlat()).map((e=>w(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class w extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",a).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,s.set(this,void 0),n.set(this,void 0),o.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,s,"f")}hasTimeout(){return null!=u(this,n,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",a).call(this);const h=()=>{u(this,r,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,s,(0,d.setInterval)(u(this,o,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,n,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,o,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref()):h(),!0}}t.EndableInterval=w,s=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(){(0,h.map)(u(this,s,"f"),d.clearInterval),c(this,s,void 0,"f"),(0,h.map)(u(this,n,"f"),d.clearTimeout),c(this,n,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const o=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,a){this.endTimeoutMs=a,r.set(this,void 0),this.onEnds=[],s.set(this,(0,o.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),n(this,s,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){a(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return n(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return n(this,s,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,s=new WeakMap},99331:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let s=!1;t.ending=function(){return s},t.setEnding=function(e){s=(0,r.isTest)()?e:e||s}},45608:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const s=r(i(1708)),n=i(22573),a=i(45599),o=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,a.defer)((()=>(0,l.mkLogger)((0,o.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,a.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function w(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,n.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,f.endEndables)(),s.default.exit(e.status))}t.exit=w,t.exitOnStdStream=(0,a.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])s.default[e].on(t,(i=>{w({reason:`${e}:${t}`,status:0,error:i})}))}))},39250:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LastOneInWins=void 0;const n=i(23838),a=i(54993),o=i(15674),l=i(73568),u=i(76740),c=i(99331),d=i(42638);t.LastOneInWins=class{constructor(e,t=o.maxCpus){this.name=e,this.maxConcurrency=t,r.set(this,new n.MultiMap),this.p=new d.Promises(e,t)}vacuum(){return s(this,r,"f").filterInPlace(((e,t)=>t.isPending&&!0!==t.payload?.aborted)),s(this,r,"f").valueCount()}enqueue({key:e,abortable:t,fn:i}){for(const t of s(this,r,"f").get(e)??[])t.payload?.abort("aborted by new work");if(this.vacuum(),(0,c.ending)())throw new l.AbortError("ending");const n=t??new u.Abortable,o=this.p.serial((0,a.toS)(e),(()=>i(n)),n);return s(this,r,"f").add(e,o),o}},r=new WeakMap},60172:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,r)=>{t=e,i=r})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,s.set(this,void 0),n.set(this,0),a.set(this,void 0),o.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,a,"f")}unset(){d(this,n,0,"f"),d(this,s,void 0,"f"),d(this,a,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,o,"f").push(e)}prior(){return this.isStale()?void 0:c(this,a,"f")}lastValue(){return c(this,a,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,n,"f")}isStale(){return null==c(this,s,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,s,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,s,"f")?void 0:Date.now()-c(this,s,"f")}elapsedMs(){return c(this,a,"f")?.settledMs??c(this,a,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,o,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,o,"f"))e.onError(t)}finally{d(this,n,(i=c(this,n,"f"),++i),"f")}},u=function(e){d(this,s,Date.now(),"f");const t=c(this,a,"f");return d(this,a,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,a,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,a,"f")),c(this,a,"f")}},1728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),s=i(80049);t.memoizeAsync=function(e,t){let i=0;const n=new s.FifoCacheAsync(t),a=t=>(i++,n.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return a.clear=e=>{if(null==e)return n.clear();{const t=(0,r.stringify)(e);return n.deleteIf((e=>t===e))}},a.size=()=>n.size,a.callCount=()=>i,a}},22781:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),s.set(this,!1),n.set(this,!1)}_call(){return a(this,s,"f")?(o(this,n,!0,"f"),!0===this.undefinedIfBusy?void 0:a(this,r,"f")):(o(this,s,!0,"f"),o(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{o(this,s,!1,"f"),!0===this.runLaterIfBusy&&a(this,n,"f")&&(o(this,n,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return a(this,s,"f")}prior(){return a(this,r,"f")}async force(){return await a(this,r,"f"),this._call()}}r=new WeakMap,s=new WeakMap,n=new WeakMap},37461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),s=i(76790),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),w=i(15674),v=i(42638);var b=i(20214);async function S(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function M({name:e,arr:t,f:i,timeoutMs:s}){const n=[];for(const a of(0,r.compact)(await t))try{const e=await((0,l.gt0)(s)?(0,c.thenOrTimeoutError)(i(a),s):i(a));null!=e&&n.push([e,a])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:a,error:t})}return n}async function _({arr:e,f:t,name:i,maxConcurrent:s,timeoutMs:n,promises:a}){if(null==e)return[];const o=(0,r.compact)(await e);if((0,r.isEmpty)(o))return[];if((s=Math.round(s??(0,w.maxCpus)()))<=1)return M({arr:e,f:t,name:i,timeoutMs:n});const u=a??(o.length<=s?v.PermissivePromises:new v.Promises(i,(()=>s))),d=(0,l.gt0)(n)?e=>(0,c.thenOrTimeoutError)(t(e),n):t,h=await u.enqueueAll(i,o.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return b.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=S,t.thenCollectBatched=async function(e,t,i){const r=[];for(const s of(0,p.batches)((0,f.toA)(await e),t)){const e=await S(s);r.push(...await S(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,o.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=M,t.mapAsyncSerial=async function(e){return(await M(e)).map((e=>e[0]))},t.thenCollectParallel=_,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n}){return(await _({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:s,timeoutMs:n}){return(await _({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:s,timeoutMs:n})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await _({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,n.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,n.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*a.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,s=null;try{r=await((0,h.isFunction)(e)?e():e)}catch(e){s=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(s??r)}catch{}if(null!=s)throw s;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,n.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const s=await t;return null!=s?i(r,s):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const s=await t(r);return null==s?i():s},t.thenMap2Or=async function(e,t,i,r){const s=await e;if(null==s)return r();const n=await t;if(null==n)return r();const a=await i(s,n);return null==a?r():a},t.thenAnd=async function(e,t){return null!=e&&(0,n.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await _({name:e,arr:t,f:i});return(0,s.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),w=i(25764),v=i(38836),b=i(73614);function S(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),s=(0,l.clamp)(10*a.secondMs,a.minuteMs,Math.round(this.times.get(e)?.p98??0)),n=(0,b.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),s);try{const s=await(0,c.tot)(t),n=Date.now()-r;return i?.(s,n),this.push(e,n),s}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(n)}}get entriesBySumDesc(){return(0,n.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(S(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,o.getOrSet)(this.times,S(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(S(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/a.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function M(e,t,i){return P.instance().time(e,t,i)}function _(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new v.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,s.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),w.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=M,t.timeSync=function(e,t){const i=Date.now(),r=t();return _(e,Date.now()-i),r},t.pushTime=_,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>M(e,t)),i)}},42638:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),w=i(54993),v=i(89788),b=i(82647),S=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,w.toS)(e)};class M{constructor(e,t){r.add(this),this.name=e,this.ee=new f.default.EventEmitter,s.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new b.Average,n.set(this,0),a.set(this,[]),o.set(this,[]),this.lastPushedNames=new v.BoundedList(16),c(this,s,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,S.maxCpus)(),d(this,s,"f")?.call(this)??(0,S.maxCpus)()))}end(){return d(this,o,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,a,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,n,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,a,"f").map((e=>e.name)),pendingNames:d(this,o,"f").map((e=>e.d.name)),totalWorkCount:d(this,n,"f")}}enqueue({name:e,l:t,payload:i,serialId:s}){const n=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:s});return this.laterPop(),n}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,a,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,o,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,o,"f").length,e),i=this.runningSerialIds,s=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,a,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,o,"f").length}hasPending(){return d(this,o,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,o,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,o,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=M,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const s=new P.Deferred(e,{payload:i,serialId:r});return d(this,o,"f").push({d:s,l:t}),s},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,n,(t=d(this,n,"f"),++t),"f"),(0,m.remove)(d(this,a,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,a,"f").push(e),e},t.maybeRun=function(e,t){const i=new M(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new M(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},59189:function(e,t){"use strict";var i,r=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},s=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SerialLaterQueue=void 0,t.SerialLaterQueue=class{constructor(){i.set(this,Promise.resolve())}enqueue(e){return s(this,i,r(this,i,"f").catch().then(e),"f")}},i=new WeakMap},4867:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),s=i(34546),n=i(41400),a=i(31586),o=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let o=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>o=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>{if(o)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(o)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>l=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>o.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),s=i(42659),n=i(41400),a=i(32639),o=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,o.clamp)(10*m,l.ShortCommandTimeoutMs,(t??s.minuteMs)/5);await(0,n.delay)(r,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const s=r(i(1708)),n=i(45599),a=i(41400),o=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),w=i(50213),v=i(7282),b=i(88158),S=i(45969),P=i(43334),M=i(28874),_=i(3790);function T(e){return E().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const E=(0,n.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(M.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,b.sortedKeys)((0,l.filter)((0,d.env)(),(e=>T(e))))},(0,a.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,M.allSettings)())t.watchLater(e)}));const D=["HOME","LANG","USER"],k=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],x=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?D:k),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,M.pathWithDefaults)(),e}));function F(e){const t={NODE_ENV:(0,v.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,S.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,M.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,o.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(s.default.env,(e=>T(e)||!(0,_.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=F,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:A({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let C=!1;function A({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const s=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...x(),...i?(0,g.childProcLocale)():{},...F(r),...e??{}});for(const e of(0,M.transientSettings)())e.deleteFromEnv(s);if((0,y.isLogged)("debug")&&!C){C=!0;const e=(0,w.mkLogger)("child.ChildEnv"),t=(0,l.entries)(s).map((([e,t])=>[e,(0,_.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>T(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return s}t.childEnv=A},84777:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const s=r(i(31421)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),w=i(79089),v=i(45255),b=i(22911),S=i(4867),P=i(73614),M=i(70025),_=i(57159),T=i(36868),E=i(66184),D=i(45643),k=i(95402),x=i(9727),F=(0,a.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function C(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function A(e,t=30*u.secondMs){if(null==e)return!1;F().debug("endProcess()",C(e));const i=e.pid;if(null==i||i<=0)return F().warn("endProcess(): asked to end invalid pid",C(e)),!1;if(i===n.default.pid)return F().warn("endProcess(): asked to end MY pid",C(e)),!1;if(i===n.default.ppid)return F().warn("endProcess(): asked to end my parent pid",C(e)),!1;(0,T.closeStreams)(e);{const t=e.kill();F().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,k.killPid)(i).catch((e=>{F().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,D.waitForPidExit)(i,t))return F().debug("endProcess(): exitted",C(e)),!0;{k.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");F().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,k.killPid)(i,!0).catch((e=>{F().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,D.waitForPidExit)(i,5e3)}function I(e,i,r,s=0){const a=new Date,o=[];return(0,w.niceable)(i,r)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,w.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(s,u.secondMs)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&A(e)}),s-250)),o.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,k.addPid)({pid:e.pid,cmd:i,timeoutMs:s,ppid:n.default.pid},a)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>o.forEach(clearTimeout))),e}function O(e,t,i,r){const n=(0,x.spawnOptions)(r);return(0,E.isLogged)("trace",F().context)?F().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:n}):F().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(s.default.execFile(e,t,n),e,t,i)}async function L(e,t,i){const r=i.quiet??!1,s=i.ignoreStderr??!1,n=i.ignoreExitCode??!1,a=O(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{a.disconnect?.()}catch{}return{result:"",pid:a.pid}}const u=a.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new b.Deferred(f);a.on("error",(e=>g.push(e))),a.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),a.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,T.endStream)(a.stdin);const w=new d.Latch;null==a.stdout?w.resolve():(a.stdout.on("error",(e=>g.push(e))),a.stdout.on("data",(e=>m.push(e))),a.stdout.on("end",(()=>w.resolve())));const P=new d.Latch;null==a.stderr||s?P.resolve():(a.stderr?.on("error",(e=>g.push(e))),a.stderr?.on("data",(e=>p.push(e))),a.stderr?.on("end",(()=>P.resolve()))),F().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,S.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),F().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:w.state(),stderr:P.state()}),await(0,S.thenOrTimeoutError)({p:w.promise,timeoutMs:v.ShortCommandTimeoutMs,halt:i.halt}),await(0,S.thenOrTimeoutError)({p:P.promise,timeoutMs:v.ShortCommandTimeoutMs,halt:i.halt});const E=p.join("");(0,l.notBlank)(E)&&g.push(new Error(E)),!r&&(0,o.isNotEmpty)(g)&&F().warn(f+" resulted in errors:",g);const D=i.isIgnorableError??M.isIgnorableError,k=g.filter((e=>!0!==D(e)));if(k.length>0)throw 1===k.length?k[0]:new _.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:k});if(!n&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:E}}catch(e){throw F().error("stdoutResult_() failed",e),await(0,k.killPid)(a.pid,!0),e}}t.endProcess=A,t.ReniceAfterMs=(0,a.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,a.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const n=(0,x.spawnOptions)(r);return F().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(s.default.spawn(e,t,n),e,t,i)},t.execFile=O,t.stdoutResult_=L,t.stdout_=async function(e,t,i){const r=await L(e,t,i);return F().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},86335:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ChildService=t.ChildServiceNames=t.inspectPort=t.pathToService=void 0;const l=i(77598),u=o(i(1708)),c=i(19851),d=i(40958),h=i(22573),f=i(50268),m=i(68708),p=i(5670),g=i(50989),y=i(12168),w=i(59455),v=i(41583),b=i(54993),S=i(80875),P=i(50213),M=i(81168),_=i(27395),T=i(25764),E=i(59958),D=i(70025),k=i(83278),x=i(85021),F=i(29325),C=i(43334),A=i(28874),I=i(84777),O=i(55534),L=i(85100),R=i(34330),N=(0,c.lazy)((()=>(0,P.mkLogger)("child.ChildService")));async function B(e){const t=(0,M.ensureSuffix)(e,".js"),i=k.BaseFile.projectRoot(),r=k.BaseFile.for(u.default.cwd()),s=(0,F.isPacked)()?[i.join("bin",t),C.isElectron?i.join("app.asar",t):void 0]:[r.join("dist","library",t),r.join("dist","core",t),r.join("lib","library",t)];(0,F.isPacked)()||(C.isElectron?(s.push(r.join("dist","app",t)),s.push(i.join("src","desktop","dist","library",t))):s.push(i.join("src","library","dist","library",t)));for(const e of s)if(null!=e&&!0===await e.isNonEmptyFile((0,F.isPacked)()?y.KB:128))return N().tap({msg:"pathToService()",level:"info",result:e,meta:{cmd:t,isPacked:F.isPacked,paths:s.map(b.toS)}});return N().throw("Failed to find path to "+e,{paths:s,fatal:!0})}t.pathToService=B,t.inspectPort=function(e){switch(e){case"web":return 9223;case"sync":return 9224;default:return(0,l.randomInt)(9225,9600)}},t.ChildServiceNames=(0,g.strEnum)(...p.ServiceNames.pick("web","sync"));class j{static async mk_(e,t={}){const i=t.pathToService??await B(e);if((0,h.blank)(i))throw new Error("Failed to find path to "+e);return t.nodeArgs=(0,w.toA)(t.nodeArgs),new j(e,i,t)}constructor(e,t,i){var o,l;r.add(this),this.serviceName=e,this.cmd=t,this.opts=i,this.restartCount=0,this.name="ChildService("+e+")",this.endTimeoutMs=(0,L.serviceExitTimeoutMs)(e),this.logger=(0,P.mkLogger)(this.name);const c=[...(0,w.toA)(i.nodeArgs),t.nativePath];(0,d.isNotEmpty)(i.args)&&c.push(...i.args),this.spawnOpts=(0,m.pick)(this.opts,"argv0","cwd","detached","env","gid","shell","stdio","timeout","uid","windowsHide","windowsVerbatimArguments","forceCLocale","forWorker"),this.spawnOpts.forceCLocale=!1,(l=(o=this.spawnOpts).env??(o.env={}))[E.UV_THREADPOOL_SIZE]??(l[E.UV_THREADPOOL_SIZE]=(0,b.toS)(("web"===e?A.Settings.webUvThreads:A.Settings.syncUvThreads).valueOrDefault)),this.wc=new R.WatchedChild({name:e,childFactory:async()=>(this.restartCount>0&&await(this.opts.onPreRestart?.()),this.restartCount++,(0,I.spawn)(u.default.execPath,c,-1,this.spawnOpts)),endableRank:T.EndableRanks.service,endTimeoutMs:this.endTimeoutMs,onStdout:a(this,r,"m",n).bind(this),onStderr:a(this,r,"m",s).bind(this),onError:this.opts.onError??(e=>!1===(0,D.isIgnorableError)(e)),ignoreStopErrors:!1,exitCommand:O.ServiceExitCommand,...i}),(0,_.addEndable)(T.EndableRanks.first,this)}get startMs(){return this.wc.startTs}runHealthCheck(){return this.wc.writeStdin(x.HealthCheckCommand+"\n")}start(){return this.wc.start()}stop(){return this.wc.stop()}restart(e){return this.wc.restart(e)}get ended(){return this.wc.ended}async end(){return this.wc.ended||this.write(O.ServiceExitCommand),this.wc.end()}get pid(){return this.wc.pid}running(){return this.wc.running()}notRunning(){return this.wc.notRunning()}write(e,t=2){if(t<0)return this.logger.warn("write(): no more retries",{toStdin:e}),!1;try{const t=this.wc.proc;return!0!==t?.stdin?.writable?(this.logger.warn("write(): childProc isn't open, ignoring",{toStdin:e}),!1):t.stdin.write((0,M.ensureSuffix)(e,"\n"))}catch(i){return this.logger.warn("write(): caught "+i),this.wc.onError("onStdout()",(0,v.toErr)(i)),this.write(e,t-1)}}}t.ChildService=j,r=new WeakSet,s=function(e){const t=(0,S.parseJSON)(e);return this.logger.warn(".onStderr()",t??e),!0===t?.fatal},n=function(e){if(!(0,h.blank)(e))try{const t=(0,S.parseJSON)(e);if(null==t)return void this.logger.info(".onStdout(): non-JSON payload",e);if(!0===t?.fatal)this.wc.onError(this.name+".onStdout()",t);else if((0,f.isHealthCheckSummary)(t)){const e="failed"===t.state||"error"===t.level;this.logger.log(e?"error":"info",".onStdout(): health check summary",t),e&&this.wc.onError(this.name+".onStdout()",t,e)}else null!=this.opts.onData&&this.opts.onData(t)}catch(t){this.logger.warn(".onStdout() failed:",{data:e,error:t})}}},3790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),s=i(41400),n=i(19851),a=i(28874);(0,s.later)((()=>a.Settings.sensitiveEnvRegExp.watchLater((()=>o.unset()))));const o=(0,n.lazy)((()=>{try{return new RegExp(a.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${a.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(a.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&o().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||a.Settings.license.includesEnvKey(e)}},55534:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceExitCommand=void 0,t.ServiceExitCommand="--exit"},85100:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serviceExitTimeoutMs=void 0;const r=i(23560),s=i(28874),n=i(45255);t.serviceExitTimeoutMs=function(e){return(0,r.isSyncService)(e)?s.Settings.syncExitTimeoutMs.valueOrDefault:n.ShortCommandTimeoutMs}},34330:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),w=i(54993),v=i(27395),b=i(25764),S=i(99331),P=i(42638),M=i(38835),_=i(8769),T=i(57159),E=i(66003),D=i(50213),k=i(45643),x=i(28874),F=i(84777);t.mkBasicWatchedChild=function(e){return new C({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,F.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class C{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,D.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),s.set(this,!1),this.onError=(e,t,i)=>{const n=new T.WrappedError(e,{cause:t}),a=!1!==n.ignorable;this.logger().log(a?"warn":"error","onError()",n),u(this,s,"f")||a||(this.lastError=n,(0,_.onError)(n),!0!==n.fatal?(i??this.opts.onError(e,n))&&(this.logger().warn("onError requested restart",{src:e,error:n}),u(this,r,"m",o).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:x.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:b.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,v.addEndable)(this.opts.endableRank,this),u(this,r,"m",o).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,s,"f")}async end(){return c(this,s,!0,"f"),u(this,r,"m",n).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",n).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,s,"f")}),!u(this,s,"f")&&!(0,S.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",n).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=C,s=new WeakMap,r=new WeakSet,n=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,s,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",a).call(this,e)},a=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,k.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,F.endProcess)(e,this.endTimeoutMs)},o=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",n).call(this),!this._stopped&&!u(this,s,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,_.onError)("Can't restart "+this.name+", failure rate is too high."+M.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,s,"f")}),this._stopped||u(this,s,"f")||(0,S.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,E.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,w.toS)(e).includes("Error: Cannot find module")&&(0,_.onError)("Failed to start "+this.name+M.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,s,"f")}),(0,S.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",o).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const a=n(i(53916)),o=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,o.toNativePath_)(e);const i=f.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),s=i.sibling(r);if(s.isSelfOrDescendantOf((0,l.examples)()))return a.join("$examples",s.posixPathFrom((0,l.examples)()));const n=(0,d.originalsDir)();if(s.isSelfOrDescendantOf(n))return a.join("$library",s.posixPathFrom(n));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?a.join("$library",s.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const n=i(6858),a=i(1708),o=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),h=i(43334),f=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return s(this,r,"f").push(...e),this}async parse(e=a.argv,t){let i=(0,m.addHelpFooter)(new n.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of s(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":o.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,a.exit)(0)})),i.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=i.opts();for(const e of s(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),s=i(31586),n=i(51926),a=i(17344),o=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,s.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,n.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,a.EditionName)()+" v"+o.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const r=i(38639),s=i(17181),n=i(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,r.mapBoolean)(e.color,(e=>{n.Settings.logColor.envValue=e,(0,s.setupLogFormatter)()}))}}},83210:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDaemon=void 0;const s=r(i(1708)),n=i(22573),a=i(38639);t.isDaemon=function(e){return(0,a.isTrue)(s.default.env.__is_daemon)||(0,a.isTrue)(e?.daemon)||!(0,n.blank)(e?.pidfile)}},53978:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimingArg=void 0;const r=i(28874),s=i(38639);t.TimingArg={beforeParse:e=>e.option("--timing","On exit, emit timing information to stdout."),afterParse:async e=>{(0,s.isTrue)(e.timing)&&(r.Settings.emitTimingsOnExit.value=!0)}}},94361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),s=i(40958),n=i(55835),a=i(31586),o=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,a.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,s.compactBlanks)([c("user id","PUID",(0,o.userids)()),c("group id","PGID",(0,o.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,n.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},43380:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WriteSettingsArg=void 0;const r=i(28874),s=i(2858),n=i(22573),a=i(38639),o=i(46292);t.WriteSettingsArg={beforeParse:e=>e.option("--write-settings","Write (or re-write, if they exist) system and library settings.toml files. See https://phstr.com/settings"),afterParse:async e=>{if((0,a.isTrue)(e.writeSettings)){const e=await(0,s.writeSystemSettings_)();if(null==e?console.info("--write-settings: Failed write system settings: no system configuration directory was found.",{checkedDirectories:(0,o.osConfigDirs)()}):console.info(`--write-settings: Wrote system settings to ${e}`),(0,n.blank)(r.Settings.libraryDir.valueOrDefault))console.error("--write-settings: Failed to write library settings: no PS_LIBRARY_DIR is set.");else{const e=await(0,s.writeLibrarySettings_)();console.info(`--write-settings: Wrote library settings to ${e}`)}}}}},54772:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestLabhashName=t.bestLabName=t.bestRgbName=t.colorToTuple=t.bestRgbTripletName=t.ColorNames=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(31586),o=i(48884),l=i(50213),u=i(81168),c=i(85810),d=i(42079),h=i(91482),f=i(3048),m=i(85409),p=i(16050),g=i(42022),y=i(85042),w=(0,r.lazy)((()=>(0,l.mkLogger)("color.ColorNames")));function v(e){const t=(0,y.normalizeRgbHex)(e.rgb);if(null==t)return void w().warn(`skipping invalid entry (bad rgb): ${e.rgb}`,e);const i=(0,c.rgbhex2Lab)(t);if(null==i)return void w().warn(`skipping invalid entry (failed to convert to L*a*b): ${t}`,e);const r=(0,c.toLabhash)(i,g.ModeBits);return{...e,rgb:t,lab:i,labhash:r,closeLabhashes:[r],closeRgb:[t],name:(0,u.capitalize)(e.name)}}function b(e,i){return null==e?void 0:(0,o.leastBy)(i??(0,t.ColorNames)(),(t=>(0,f.ciede2000_delta_e)(t.lab,e)))}t.ColorNames=(0,r.lazy)((()=>(0,s.compact)([...d.CrayonColors,...d.CrayonSupplements,...h.DarkWikipediaColors,...p.LightWikipediaColors,...m.Greys].map(v)))),t.bestRgbTripletName=function(e,i=(0,t.ColorNames)()){return b((0,c.rgb2lab)(e),i)},t.colorToTuple=v,t.bestRgbName=function(e){return P((0,c.rgbhex2Labhash)(e))},t.bestLabName=b;const S=new Map;function P(e){return(0,a.gte0)(e)?(0,n.getOrSet)(S,e,(()=>{const i=(0,t.ColorNames)().find((t=>t.labhash===e));if(null!=i)return i;const r=(0,c.unlabhash)(e),n=b(r);return null!=r&&null!=n&&((0,s.pushUniq)(n.closeLabhashes,e),(0,s.pushUniq)(n.closeRgb,(0,c.lab2rgbhex)(r))),n})):void 0}t.bestLabhashName=P},85810:(e,t,i)=>{"use strict";e=i.nmd(e),Object.defineProperty(t,"__esModule",{value:!0}),t.hsv2rgb=t.hsl2hsv=t.hsv2hsl=t.hsl2rgb=t.rgb2hsl=t.rgbhex2hsl=t.rgb2hsv=t.closestLab=t.maxLabhash=t.minLabhash=t.unlabhash=t.toLabhash=t.LabBitZip=t.xyz2rgb=t.lab2xyz=t.xyz2lab=t.rgb2xyz=t.clampLab=t.lab2rgb=t.rgb2lab=t.rgb2labArray=t.rgb2labTriplets=t.lab2rgbhex=t.rgbhex2Labhash=t.rgbhex2Lab=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(55835),o=i(31586),l=i(48884),u=i(20014),c=i(75503),d=i(3048),h=i(42022),f=i(85042),m=[[.4124564,.3575761,.1804375],[.2126729,.7151522,.072175],[.0193339,.119192,.9503041]],p=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]];function g(e){return M(v(e))}function y(e){return(0,f.clampRGB)(T(_(e)))}function w(e){return(0,t.LabBitZip)().clampValue(e)}function v(e){const t=(0,f.clampRGB)(e).map((e=>e/255)).map((e=>e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92));return(0,c.matXvec)(m,t)}t.rgbhex2Lab=function(e){return(0,a.map)((0,f.rgbhex2triplet)(e),g)},t.rgbhex2Labhash=function(e,t=h.ModeBits){return(0,a.map)((0,f.rgbhex2triplet)(e),(e=>E(g(e),t)))},t.lab2rgbhex=function(e){return(0,f.rgbTriplet2hex)(y(e))},t.rgb2labTriplets=function(e){return(0,s.stepRange)(0,e.length,3).map((t=>g([e[t],e[t+1],e[t+2]])))},t.rgb2labArray=function(e){const t=[],i=[],r=[];for(let s=0;se>S?Math.pow(e,1/3):(P*e+16)/116));return w([116*i-16,500*(t-i),200*(i-r)])}function _(e){const[t,i,r]=w(e),s=(t+16)/116,n=i/500+s,a=s-r/200,o=n*n*n,l=a*a*a,u=o>S?o:(116*n-16)/P,c=t>8?Math.pow(s,3):t/P,d=l>S?l:(116*a-16)/P;return[u*b.X,c*b.Y,d*b.Z]}function T(e){return(0,c.matXvec)(p,e).map((e=>{const t=e<0?-1:1,i=e*t;return(0,o.round)(255*t*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055))}))}function E(e,i=h.ModeBits){return(0,t.LabBitZip)().zip(e,i)}t.xyz2lab=M,t.lab2xyz=_,t.xyz2rgb=T,t.LabBitZip=(0,r.lazy)((()=>new u.BitZip([{min:0,max:100},{min:-79,max:90},{min:-102,max:89}]))),t.toLabhash=E;const D=new Map;function k(e,i=h.ModeBits){return(0,t.LabBitZip)().unzip(e,i)}function x(e){const[t,i,r]=(0,f.clampRGB)(e),s=Math.max(t,i,r),n=s-Math.min(t,i,r),a=n?s===t?(i-r)/n:s===i?2+(r-t)/n:4+(t-i)/n:0;return[60*(a<0?a+6:a),s?n/s*100:0,s/255*100]}function F(e){return C(x(e))}function C(e){const[t,i,r]=e,s=(200-i)*r/100;return[t,s>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,s/2]}function A(e){const[t,i,r]=e,s=i*(r<50?r:100-r)/100;return[t,s>0?2*s/(r+s)*100:0,r+s]}function I(e){const t=e[0]/360*6,i=e[1]/100,r=e[2]/100,s=Math.floor(t),n=r*(1-i),a=r*(1-(t-s)*i),o=r*(1-(1-t+s)*i),l=s%6;return(0,f.clampRGB)([255*[r,a,n,n,o,r][l],255*[o,r,r,a,n,n][l],255*[n,n,o,r,r,a][l]])}t.unlabhash=function(e,t=h.ModeBits){return t===h.ModeBits?(0,n.getOrSet)(D,e,(()=>k(e,t))):k(e,t)},t.minLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMin(h.ModeBits))),t.maxLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMax(h.ModeBits))),t.closestLab=function(e,t){return(0,l.leastBy)(e,(e=>(0,d.ciede2000_delta_e)(e,t)))},t.rgb2hsv=x,t.rgbhex2hsl=function(e){return F((0,f.rgbhex2triplet)(e))},t.rgb2hsl=F,t.hsl2rgb=function(e){return I(A(e))},t.hsv2hsl=C,t.hsl2hsv=A,t.hsv2rgb=I,i.c[i.s]===e&&console.log(E([0,0,0]))},42079:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CrayonSupplements=t.CrayonColors=void 0,t.CrayonColors=[{name:"Aquamarine",rgb:"#95E0E8"},{name:"Asparagus",rgb:"#7BA05B"},{name:"Blue-green",rgb:"#0095B7"},{name:"Royal blue",rgb:"#273BE2"},{name:"Blush",rgb:"#DB5079"},{name:"Brilliant rose",rgb:"#E667CE"},{name:"Brown",rgb:"#AF593E"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Burnt umber",rgb:"#805533"},{name:"Cadet blue",rgb:"#A9B2C3"},{name:"Canary",rgb:"#FFFF99"},{name:"Carmine",rgb:"#E62E6B"},{name:"Carnation pink",rgb:"#FFA6C9"},{name:"Celestial blue",rgb:"#7070CC"},{name:"Cerise",rgb:"#DA3287"},{name:"Cerulean blue",rgb:"#339ACC"},{name:"Chestnut",rgb:"#B94E48"},{name:"Cobalt blue",rgb:"#8C90C8"},{name:"Copper",rgb:"#DA8A67"},{name:"Cornflower",rgb:"#93CCEA"},{name:"Cotton candy",rgb:"#FFB7D5"},{name:"Denim",rgb:"#1560BD"},{name:"Eggplant",rgb:"#614051"},{name:"Fern",rgb:"#63B76C"},{name:"Fuchsia",rgb:"#C154C1"},{name:"Russet",rgb:"#87421F"},{name:"Green",rgb:"#01A638"},{name:"Green-yellow",rgb:"#F1E788"},{name:"Indigo",rgb:"#4F69C6"},{name:"Jungle green",rgb:"#29AB87"},{name:"Magenta",rgb:"#F653A6"},{name:"Maize",rgb:"#F2C649"},{name:"Maroon",rgb:"#C32148"},{name:"Medium chrome green",rgb:"#6CA67C"},{name:"Medium violet",rgb:"#8F47B3"},{name:"Melon",rgb:"#FEBAAD"},{name:"Middle blue-green",rgb:"#8DD9CC"},{name:"Middle blue-purple",rgb:"#8B72BE"},{name:"Green-yellow",rgb:"#ACBF60"},{name:"Middle purple",rgb:"#D982B5"},{name:"Middle yellow-red",rgb:"#ECAC76"},{name:"Midnight blue",rgb:"#003366"},{name:"Mulberry",rgb:"#C8509B"},{name:"Navy blue",rgb:"#0066CC"},{name:"Olive green",rgb:"#B5B35C"},{name:"Orange",rgb:"#FF8833"},{name:"Orchid",rgb:"#E29CD2"},{name:"Peach",rgb:"#FFCBA4"},{name:"Periwinkle",rgb:"#C3CDE6"},{name:"Pine green",rgb:"#01796F"},{name:"Pink flamingo",rgb:"#FC74FD"},{name:"Plum",rgb:"#8E3179"},{name:"Raw umber",rgb:"#665233"},{name:"Red-orange",rgb:"#FF681F"},{name:"Red",rgb:"#ED0A3F"},{name:"Salmon",rgb:"#FF91A4"},{name:"Vivid scarlet",rgb:"#FD0E35"},{name:"Sea green",rgb:"#93DFB8"},{name:"Sepia",rgb:"#9E5B40"},{name:"Shamrock",rgb:"#33CC99"},{name:"Sky blue",rgb:"#76D7EA"},{name:"Spring green",rgb:"#ECEBBD"},{name:"Sunset orange",rgb:"#FE4C40"},{name:"Tan",rgb:"#FA9D5A"},{name:"Teal blue",rgb:"#008080"},{name:"Thistle",rgb:"#D8BFD8"},{name:"Vivid tangerine",rgb:"#ED3C10"},{name:"Vivid violet",rgb:"#a625c3"},{name:"Wisteria",rgb:"#C9A0DC"},{name:"Yellow-green",rgb:"#C5E17A"},{name:"Yellow-orange",rgb:"#FFAE42"},{name:"Yellow",rgb:"#FBE870"}],t.CrayonSupplements=[{name:"Artichoke",rgb:"#8F9779"},{name:"Aubergine",rgb:"#48213A"},{name:"Brandy rose",rgb:"#B1847F"},{name:"Burgundy",rgb:"#800020"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Crimson red",rgb:"#990000"},{name:"Dark brown",rgb:"#664228"},{name:"Dark coral",rgb:"#CD5B45"},{name:"Dark green",rgb:"#006400"},{name:"Dark raspberry",rgb:"#872657"},{name:"Dark turquoise",rgb:"#610079"},{name:"Deep teal",rgb:"#004040"},{name:"Deep coffee",rgb:"#704241"},{name:"Dusty rasberry",rgb:"#917980"},{name:"Ecru",rgb:"#BCAC7C"},{name:"Evergreen",rgb:"#05472A"},{name:"Eggplant",rgb:"#380835"},{name:"Eggplant purple",rgb:"#430541"},{name:"Emerald green",rgb:"#028F1E"},{name:"Flamingo pink",rgb:"#D67C99"},{name:"Grape",rgb:"#6C3461"},{name:"Kelly green",rgb:"#4CBB17"},{name:"Light forest green",rgb:"#4F9153"},{name:"Medium dark brown",rgb:"#AF7200"},{name:"Medium dark cyan-blue",rgb:"#2D537C"},{name:"Mustard",rgb:"#FAAF18"},{name:"Neon green",rgb:"#39FF14"},{name:"Pear",rgb:"#D1E231"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Phthalo blue",rgb:"#0016C7"},{name:"Pink lace",rgb:"#FFDDF4"},{name:"Raw sienna",rgb:"#884B15"},{name:"Rebecca purple",rgb:"#663399"},{name:"Sap green",rgb:"#536916"},{name:"Blue sapphire",rgb:"#133ECB"},{name:"Sand",rgb:"#B38751"},{name:"Shadow blue",rgb:"#778BA5"},{name:"Shadow green",rgb:"#121E06"},{name:"Swamp green",rgb:"#748500"},{name:"Verdigris",rgb:"#43B3AE"},{name:"Vivid blue-magenta",rgb:"#4817E8"},{name:"Vivid blue-purple",rgb:"#ACACE6"},{name:"Vivid blue",rgb:"#47ABCC"},{name:"Vivid green-yellow",rgb:"#D9E650"},{name:"Vivid green",rgb:"#7BE214"},{name:"Vivid turqoise",rgb:"#06ECD2"},{name:"Vivid lavender",rgb:"#A354FD"},{name:"Vivid mint",rgb:"#00F28C"},{name:"Vivid pink",rgb:"#D752FB"},{name:"Vivid red-purple",rgb:"#C31D7E"},{name:"Vivid red",rgb:"#D92121"},{name:"Vivid yellow-red",rgb:"#F2BA49"},{name:"Vivid yellow",rgb:"#FAFA37"}]},91482:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarkWikipediaColors=void 0,t.DarkWikipediaColors=[{name:"Bistre",rgb:"#3D2B1F"},{name:"Black bean",rgb:"#3D0C02"},{name:"Black pearl",rgb:"#041322"},{name:"Shadow blue",rgb:"#001440"},{name:"Charcoal",rgb:"#36454F"},{name:"Dark indigo",rgb:"#1F0A52"},{name:"Dark magenta",rgb:"#8B008B"},{name:"Dark moss green",rgb:"#4A5D23"},{name:"Dark navy",rgb:"#02075D"},{name:"Dark pastel blue",rgb:"#779ECB"},{name:"Dark purple",rgb:"#580040"},{name:"Dark tan",rgb:"#918151"},{name:"Dark yellow-green",rgb:"#304000"},{name:"Dark yellow",rgb:"#9B870C"},{name:"Deep violet",rgb:"#330066"},{name:"Dusk",rgb:"#4E5481"},{name:"Elderberry",rgb:"#1d1a34"},{name:"Grey jade",rgb:"#757C55"},{name:"Grey magenta",rgb:"#83667F"},{name:"Grey ochre",rgb:"#716659"},{name:"Grey olive",rgb:"#656c5a"},{name:"Grey sage",rgb:"#69724d"},{name:"Taupe",rgb:"#483C32"}]},3048:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciede2000_delta_e=t.diffCIECorr=t.MaxCie=t.MinCie=t.cie94_delta_e=t.cie76_delta_e=void 0;const r=i(31586),s=i(97352);t.cie76_delta_e=function(e,t){return Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2)},t.cie94_delta_e=function(e,t){const[i,r,n]=e,[a,o,l]=t,u=i-a,c=r-o,d=n-l,h=(0,s.sqrt)(r**2+n**2),f=h-(0,s.sqrt)(o**2+l**2),m=(0,s.sqrt)(c**2+d**2-f**2);return(0,s.sqrt)((u/1)**2+(f/(1+.045*h))**2+(m/(1+.015*h))**2)},t.MinCie=2,t.MaxCie=20,t.diffCIECorr=function(e,i){return null==e||null==i?1:(0,r.clamp)(0,t.MaxCie,l(e,i)-t.MinCie)/t.MaxCie};const n=1,a=1,o=1;function l(e,t){const[i,r,l]=e,u=(0,s.sqrt)(r**2+l**2),[c,d,h]=t,f=(u+(0,s.sqrt)(d**2+h**2))/2,m=.5*(1-(0,s.sqrt)(Math.pow(f,7)/(Math.pow(f,7)+Math.pow(25,7)))),p=r*(1+m),g=d*(1+m),y=(0,s.sqrt)(p*p+l*l),w=(0,s.sqrt)(g*g+h*h);let v=Math.abs(p)+Math.abs(l)===0?0:Math.atan2(l,p);v+=2*(v<0?1:0)*Math.PI;let b=Math.abs(g)+Math.abs(h)===0?0:Math.atan2(h,g);b+=2*(b<0?1:0)*Math.PI;const S=c-i,P=w-y;let M=y*w==0?0:b-v;M-=2*(M>Math.PI?1:0)*Math.PI,M+=2*(M<-Math.PI?1:0)*Math.PI;const _=2*(0,s.sqrt)(y*w)*Math.sin(M/2),T=(i+c)/2,E=(y+w)/2;let D;y*w==0?D=v+b:(D=(v+b)/2,D-=(Math.abs(v-b)>Math.PI?1:0)*Math.PI,D+=2*(D<0?1:0)*Math.PI);const k=(T-50)**2,x=1-.17*Math.cos(D-Math.PI/6)+.24*Math.cos(2*D)+.32*Math.cos(3*D+Math.PI/30)-.2*Math.cos(4*D-63*Math.PI/180),F=1+.015*k/(0,s.sqrt)(20+k),C=1+.045*E,A=1+.015*E*x,I=30*Math.PI/180*Math.exp(-1*((180/Math.PI*D-275)/25)**2),O=2*(0,s.sqrt)(Math.pow(E,7)/(Math.pow(E,7)+Math.pow(25,7))),L=-1*Math.sin(2*I)*O;return(0,s.sqrt)(Math.pow(S/(n*F),2)+Math.pow(P/(a*C),2)+Math.pow(_/(o*A),2)+L*P/(a*C)*_/(o*A))}t.ciede2000_delta_e=l},76490:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColor=t.dominantColorsToRgbHex=void 0;const r=i(40958),s=i(31586),n=i(97352),a=i(54772),o=i(85810),l=i(42022),u=i(1971);t.dominantColorsToRgbHex=function(e){return(0,r.compact)(e.map((e=>[e.rgbhex,(0,s.fmtPct)(e.pct)])))};class c{static fromModeData(e){return(0,r.compact)((0,s.times)(u.ModeCount,(t=>c.fromLabhash({labhash:e[`mode${t}`],pct:e[`mode${t}pct`]}))))}static toModeData(e){const t={};return(0,s.times)(u.ModeCount,(i=>{t["mode"+i]=e[i]?.labhash??null,t["mode"+i+"pct"]=e[i]?.pct??null})),t}static fromLabhash({labhash:e,labhashBits:t=l.ModeBits,pct:i}){const r=(0,n.mapGt0)(e,(e=>(0,o.unlabhash)(e,t)));return null!=r&&(0,s.gt0)(i)?new c(r,i,e):void 0}static fromCentroid(e,t){return new c(e.centroid,Math.round(e.size/t*100))}constructor(e,t,i){this.lab=e,this.pct=(0,s.clamp)(0,100,t),this.labhash=i??(0,o.toLabhash)(e,l.ModeBits)}get rgbhex(){return(0,o.lab2rgbhex)(this.lab)}get color(){return(0,a.bestLabhashName)(this.labhash)}toGreyscale(){return new c([this.lab[0],0,0],this.pct)}eql(e){return this.labhash===e.labhash&&(0,s.closeTo)(this.pct,e.pct,5)}}t.DominantColor=c},32848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scaled_delta_e=t.dominantColorCorrelation=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(48884),o=i(31843),l=i(70417),u=i(3048);function c(e,t){const i=(0,s.sum)(e,(e=>(0,n.clamp)(0,100,e.pct))),r=(0,s.sum)(e,(e=>function(e,t){const i=(0,a.leastBy)(t,(t=>(0,u.ciede2000_delta_e)(e.lab,t.lab)));if(null==i)return 0;const r=(0,u.ciede2000_delta_e)(e.lab,i.lab),s=(0,n.clamp)(0,e.pct,(0,l.avg)([e.pct,i.pct])),o=h(r);return(0,n.clamp)(0,100,s)*o}(e,t)));return r/i}t.dominantColorCorrelation=function(e,t){return e=(0,s.compact)(e),t=(0,s.compact)(t),(0,s.isEmpty)(e)||(0,s.isEmpty)(t)?0:(0,l.avg)([c(e,t),c(t,e)])};const d=(0,r.lazy)((()=>[{x:0,y:1},{x:9,y:.8},{x:16,y:.3},{x:20,y:0}]));function h(e){return(0,n.clamp)(0,1,(0,o.lerp2d)(e,...d()))}t.scaled_delta_e=h},40401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeNearCentroids=t.mergeLabhashes=t.dominantColorsFromModes=t.maybeFilterGrey=t.centroidsScore=t.extractDominantColors=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(41400),o=i(98553),l=i(31586),u=i(68708),c=i(48884),d=i(22454),h=i(50213),f=i(56038),m=i(82647),p=i(44983),g=i(70417),y=i(28874),w=i(85810),v=i(3048),b=i(76490),S=i(1971),P=(0,r.lazy)((()=>(0,h.mkLogger)("color.DominantColors")));t.extractDominantColors=function(e,t=S.ModeCount){return(0,f.timeSync)("img.extractDominantColors",(()=>function(e,t=S.ModeCount){const i=Date.now(),r=y.Settings.dominantColorKmeansRuns.valueOrDefault,a=new d.CountingSet;for(const i of E({labs:e,minK:t}))a.incr((0,w.toLabhash)(i));const h=_[y.Settings.dominantColorDeltaE.valueOrDefault]??v.ciede2000_delta_e;const f=a.sortedByKey().valuesToA((e=>(0,w.unlabhash)(e)));let g=(0,l.round)(t+y.Settings.dominantColorMergeThreshold.valueOrDefault);function k(e){const i=t,r=4*t;g=Math.round(Math.max(i,Math.min(r,e)))}const F=f.length<=g?[]:(0,s.compact)(M.slice(0,r).map((e=>{const r=(0,p.kmeans)(f,g,{...T,seed:e}),s=x(r.centroids,f.length);if(s.lengtht&&k(g-1);const n=s.slice(0,t),o=(0,l.sigFigs)(function(e){const t=new m.Average;for(const[i,r]of a.entries()){const s=(0,w.unlabhash)(i),n=(0,c.leastByCtx)(e,(e=>h(e.centroid,s)));null!=n&&(0,l.times)(r,(()=>t.push(n.value)))}return t.p84}(n),2);return{...r,centroids:n,description:{kIn:g,kOut:r.centroids.length,kMerged:s.length,score:o,iterations:r.iterations,uniqColors:a.size,elapsedMs:Date.now()-i},score:o}})));P().trace("extractDominantColors()",{kmeansResults:F.map((e=>(0,u.pick)(e,"description","score")))});const C=(0,c.leastBy)(F,(e=>e.score));if(null==C)return P().info("kmeans failed or was disabled, using dominantColorsFromModes",{runs:r}),D(a,t);const A=(0,o.stringify)({...C?.description,elapsedMs:Date.now()-i}),I=(0,n.sortBy)(C?.centroids,(e=>-e.size)).map((e=>b.DominantColor.fromCentroid(e,f.length)));return P().debug("extractDominantColors() result",{description:A,score:C?.score,totalColors:a.size,totalPixels:f.length,iters:C?.iterations,dominantColors:(0,b.dominantColorsToRgbHex)(I),pixelCount:f.length}),{dominantColors:I,description:A,dominantColorScore:C?.score}}(e,t)))},t.centroidsScore=function(e,t){const i=new m.Average;for(const r of e){const e=(0,c.leastBy)(t,(e=>(0,v.ciede2000_delta_e)(e.centroid,r)));null!=e&&i.push((0,v.ciede2000_delta_e)(e.centroid,r))}return i};const M=[6147062518717073,8176726750919909,5426648081701673,0xce2a345532a3c,0x713f9716da824,6348935463312109,5900323173950995,7358780886584433,5704068712193493,0x51ceeef755892,0xe1557fe94c084,0xd42d7cc96d6b4,0xcbc36dfd76e8a,6738189173486085,8537822851166899,5390086061821835,7712057976331355,0xe9b820db7a8e4,0xb96cebcd6aa40,7036994544380825,5353634786120155,0x99a11417794bc,0xa93d36019aaae,0x74a470887095e,5481147022770415,5347523348244809,0x541d1098e90fc,0xa24d9fb3510c2,0x78aa8e4f692fa,6354921850669697,0x714e1ec1b0a14,8622097963014773,0x6ff5d462d8eb6,0x6782a6b5166b8,7128984079394103,0xe6efba28a3752,5088704486053871,0xc84df40627fae,8018285280412081,4524300326741245,8307147030534695,8135486835878813,7699950603263999,0xb2889592968ae,5903399874280295,7462660765348991,6442509751447017,0xe218d44834db6,7214173935589545,6001326758941961,0x53eb7d39bbb50,0xc3a7ab8add332,0x4e6e81bc443e2,6757635537583321,8501611905255957,0x51840465cc07c,5958243312989149,8928005021308717,5032083390680559,0xb35d70ac51c68,0xfc3826a2dfe7c,0xd155853c61e96,0xda2045ee9be1e,4753952745315177],_={cie76:v.cie76_delta_e,cie94:v.cie94_delta_e,ciede2000:v.ciede2000_delta_e},T=(0,r.lazy)((()=>({maxIterations:50,initialization:"kmeans++",distanceFunction:_[y.Settings.dominantColorDeltaE.valueOrDefault]})));function E({labs:e,minK:t,thresh:i,retries:r=3}){if(r<0)return P().debug("maybeFilterGrey(): exhausted retries: grey filtering disabled."),e;const s=i??y.Settings.dominantColorGreyThreshold.valueOrDefault;if(!(0,l.gt0)(s))return P().debug("maybeFilterGrey(): grey threshold is <= 0: grey filtering disabled."),e;const n=e.filter((e=>Math.abs(e[1])+Math.abs(e[2])>=s));return n.length>=e.length/2?(P().debug("maybeFilterGrey(): sufficient remaining pixels with this threshold.",{greyThreshold:s,minK:t,pixelCount:e.length,filteredCount:n.length}),n):(P().debug("maybeFilterGrey(): insufficient remaining pixels with this threshold. Retrying with smaller threshold.",{greyThreshold:s,minK:t,retries:r,pixelCount:e.length,filteredCount:n.length}),E({labs:e,minK:t,thresh:.75*s,retries:r-1}))}function D(e,t){const i=e.countSum,r=e.size;k(e);const n=e.size,a=(0,s.compact)(e.top(t).map((([e,t])=>b.DominantColor.fromLabhash({labhash:e,pct:Math.round(100*t/i)})))),l=100-(0,g.sumf)(a,(e=>e.pct));return{dominantColors:a,description:"dominantColorsFromModes: "+(0,o.stringify)({uniqColors:r,mergedColors:n,pixelCount:i,pctOmitted:l})}}function k(e,t=y.Settings.dominantColorMergeThreshold.valueOrDefault){const i=[];for(const[r,s]of[...e.entriesByCountDesc()]){const n=(0,w.unlabhash)(r),a=i.find((e=>(0,v.ciede2000_delta_e)(e.lab,n)<=t));null==a?i.push({lab:n,labhash:r}):(e.delete(r),e.incr(a.labhash,s))}return e}function x(e,t,i=y.Settings.dominantColorMergeThreshold.valueOrDefault){if(i<=0)return e;const r=[];for(const t of e){const e=r.find((e=>(0,v.ciede2000_delta_e)(t.centroid,e.centroid)<=i));null==e?r.push(t):e.size+=t.size}const s=t/100;return(0,n.sortBy)(r.filter((e=>e.size>s)),(e=>-e.size))}(0,a.later)((()=>{y.Settings.dominantColorDeltaE.watchLater((()=>{T.unset()}))})),t.maybeFilterGrey=E,t.dominantColorsFromModes=D,t.mergeLabhashes=k,t.mergeNearCentroids=x},85409:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Greys=void 0,t.Greys=[{name:"Black",rgb:"#000000"},{name:"90% black",rgb:"#1b1b1b"},{name:"80% black",rgb:"#303030"},{name:"70% black",rgb:"#474747"},{name:"60% black",rgb:"#5e5e5e"},{name:"Grey",rgb:"#777777"},{name:"60% white",rgb:"#919191"},{name:"70% white",rgb:"#ababab"},{name:"80% white",rgb:"#c6c6c6"},{name:"90% white",rgb:"#e2e2e2"},{name:"White",rgb:"#ffffff"}]},86758:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.labsAreGreyscale=t.isLab=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(82647),o=i(28874),l=i(85810),u=(0,r.lazy)((()=>(0,n.mkLogger)("color.Lab")));t.isLab=function(e){return Array.isArray(e)&&3===e.length&&(0,s.within)(0,100,e[0])&&(0,s.within)(-110,110,e[1])&&(0,s.within)(-110,110,e[2])},t.labsAreGreyscale=function(e){const t=o.Settings.greyscaleColorThreshold.valueOrDefault,i=new a.Average,r=new a.Average;for(const t of e){const e=(0,l.clampLab)(t);i.push(e[1]),r.push(e[2])}const s=(i.stdDev??0)+(r.stdDev??0),n=s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LightWikipediaColors=void 0,t.LightWikipediaColors=[{name:"Beige",rgb:"#F5F5DC"},{name:"Laurel green",rgb:"#A9BA9D"},{name:"Light sage",rgb:"#93A58B"},{name:"Light green-cyan",rgb:"#CFEADE"},{name:"Pastel purple",rgb:"#B39EB5"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Powder blue",rgb:"#B0E0E6"},{name:"Vanilla",rgb:"#F3E5AB"}]},42022:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeBits=void 0,t.ModeBits=12},1971:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeCount=void 0,t.ModeCount=7},85434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitModeData=t.pickModeData=t.ModeDataKeys=t.isModeData=void 0;const r=i(31586),s=i(68708),n=i(50989);t.isModeData=function(e){return(0,r.gt0)(e.mode0)&&(0,r.gt0)(e.mode0pct)},t.ModeDataKeys=(0,n.strEnum)("mode0","mode0pct","mode1","mode1pct","mode2","mode2pct","mode3","mode3pct","mode4","mode4pct","mode5","mode5pct","mode6","mode6pct"),t.pickModeData=function(e){return(0,s.pick)(e,...t.ModeDataKeys.values)},t.omitModeData=function(e){return(0,s.omit)(e,...t.ModeDataKeys.values)}},85042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clampRGB=t.rgbTriplet2hex=t.rgbhex2triplet=t.normalizeRgbHex=void 0;const r=i(31586),s=i(39926),n=i(51926),a=i(54993),o=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;function l(e){return[e[0],e[1],e[2]].map((e=>(0,r.clamp)(0,255,Math.round(e))))}t.normalizeRgbHex=function(e){const t=(0,a.toS)(e).trim();return o.test(t)?(0,n.ensurePrefix)(t,"#").toUpperCase():void 0},t.rgbhex2triplet=function(e){const t=(0,a.toS)(e).trim().match(o);if(null!=t)try{return[t[1],t[2],t[3]].map((e=>(0,r.clamp)(0,255,parseInt(e,16))))}catch{return}},t.rgbTriplet2hex=function(e){return"#"+l(e).map((e=>(0,s.leftPad)(Math.round(e).toString(16).toUpperCase(),2,"0"))).join("")},t.clampRGB=l},76596:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),s=i(19851),n=i(22573),a=i(42659),o=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,s.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,o.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,o.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,a.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const r=i(77988),s=i(19851),n=i(55835),a=i(31586),o=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,s.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),h=["year","month","day","hour","minute","second","millisecond"];class f{static fromISO(e,t){const i=d().exec((0,o.toS)(e).trim()),r=i?.groups;return null==r?void 0:f.for((0,c.parseExifDateTime)(r.start,t),(0,c.parseExifDateTime)(r.end,t),(0,a.toInt)(r.index),(0,a.toInt)(r.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,n.map)(e.start,(e=>r.ExifDateTime.fromJSON(e))),(0,n.map)(e.end,(e=>r.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,r=1){if(null==e||!e.isValid||null==t||!t.isValid)return;r=(0,a.clamp)(1,1e3,(0,a.toInt)(r,{defaultValue:1})),i=(0,a.clamp)(0,r-1,(0,a.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const s=e.toMillis(),n=(t.toMillis()-s)/(r+1)*(i+1),o=e.plus({milliseconds:n});return null==o?void 0:new f(e,o,t,i,r)}constructor(e,t,i,r=0,s=1){this.start=e,this.middle=t,this.end=i,this.index=r,this.splits=s,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=h.map((r=>function({start:e,end:t,middle:i,field:r}){return null!=e[r]&&null!=t[r]?i[r]:void 0}({start:e,middle:t,end:i,field:r})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new f(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=f},79842:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(76790),o=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),h=i(51926),f=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),w=i(21330),v=i(928),b=i(54261),S=i(73389),P=i(51275),M=(0,n.lazy)((()=>(0,f.mkLogger)("date.Dated")));function _(e){return null!=e&&(e instanceof w.FuzzyDate||e instanceof r.ExifDate||e instanceof r.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,S.isDateTime)(e)||(0,m.isDateObject)(e))}function T(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof r.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function E(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof r.ExifDate?e.toMillis(l.dayMs):e instanceof w.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),k(e),((e,t)=>e+t))}function D(e){try{if(null==e||(0,h.isString)(e)||(0,c.isNumber)(e))return;return(0,S.isDateTime)(e)?e:e instanceof r.ExifDateTime||e instanceof w.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?s.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void M().warn("datedToDateTime() failed",{d:e,error:t})}}function k(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,b.hasTime)(e)){if((0,c.gt0)((0,v.getMillisecond)(e)))return 0;if((0,c.gt0)((0,v.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,v.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,v.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,v.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,v.getMonth)(e))?l.monthMs-1:l.yearMs-1}function x(e,t){const i=T(e),r=E(e);if(null!=i&&null!=r)return(0,c.gt0)(t)&&t>r-i?{start:Math.round((i+r)/2-t/2),end:Math.round((i+r)/2+t/2)}:{start:i,end:r}}function F(e,t,i,r){const[s,n]=(0,a.sortBy)([x(e,i),x(t,r)],(e=>e?.start));return null!=s&&null!=n&&null!=s&&null!=n&&(s.start===n.start||s.end>=Math.min(n.start,n.end))}function C(e,t){return(0,o.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??w.FuzzyDate.fromISO(e)}t.isDated=_,t.toDated=function(e){return _(e)?e:void 0},t.mapDated=function(e,t){return _(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=T,t.datedToEndTs=E,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof r.ExifDate?s.DateTime.fromObject(e):D(e)},t.datedToDateTime=D,t.datedToPrecisionMs=k,t.isoToPrecisionMs=function(e){return(0,u.map)(C(e),k)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:r}){if(null==e||null==t)return!1;if(i??(i=k(e)),r??(r=k(t)),F(e,t,i,r))return!0;const s=(0,P.getZoneName)(e),n=(0,P.getZoneName)(t);return null==s&&null!=n&&(e=(0,w.setZone)(e,n)??e),null==n&&null!=s&&(t=(0,w.setZone)(t,s)??t),F(e,t,i,r)},t.isoToDated=C,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof s.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const r=i(31586),s=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,s.isString)(e))return(0,r.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),s=i(31586),n=i(54557),a=i(91655),o=new n.FifoCache(512);function l(e){return(0,s.isNumber)(e)?e:(0,r.blank)(e)?void 0:o.getOrSet(e,(()=>(0,a.parseDuration)(e)))}t.decodeDuration=l;const u=new n.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,a.fmtFullDuration)((0,s.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),s=i(40958),n=i(22573),a=i(42659),o=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,o.isNumber)(e))return;if((0,o.isNumber)(e))return e;if((0,o.isDigits)(e))return(0,o.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,s.compact)(d.map((e=>function(e,t){const i=(0,o.toFloat)(e);if(null!=i){if((0,n.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*a.yearMs;case"weeks":case"week":case"w":return i*a.weekMs;case"days":case"day":case"d":return i*a.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*a.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*a.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*a.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,o.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:a.yearMs,s:"y"},{ms:a.weekMs,s:"w"},{ms:a.dayMs,s:"d"},{ms:a.hourMs,s:"h"},{ms:a.minuteMs,s:"m"},{ms:a.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,o.isNumber)(t))return;if(0===t)return"0";if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},98247:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),h=i(68852),f=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function w(e,t,i){const r=t.exec(e);if(null==r||(0,u.isEmptyObj)(r.groups))return;const{year:s,month:n,day:a,hour:c,minute:h,second:p}=(0,d.mapEntries)(r.groups,((e,t)=>(0,l.toInt)(t)));if(null==s||null==n||null==a)return;if(!f.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==h))return;const g=(0,o.map)((0,l.toFloat)(r.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),w=(0,y.timezoneOffsetFromRegExpMatch)(r);return S({year:s,month:n,day:a,hour:c??0,minute:h??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(w)??i,rawValue:e,tzoffsetMinutes:w})}t.UnsetZone=s.Info.normalizeZone(r.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof r.ExifDate&&t instanceof r.ExifTime))return;const i=new r.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:n}){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromFormat(e,i,{zone:n??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,a.blank)(e)?void 0:r.ExifDateTime.from(e,t)??w(e,b(),t)},t.parseExifDateTimeRe=w;const v=/[-:_\s]?/,b=(0,n.lazy)((()=>(0,h.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,v,p.monthRE,v,p.dayRE,/[T\s]/,p.hourRE,v,p.minuteRE,v,p.secondRE,p.subsecRE,/\s?/,h.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function S(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof r.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=r.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,o.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=S},74417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const r=i(51168),s=i(22573),n=i(42659),a=i(49769),o=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),h=i(66649),f=i(98725),m=i(88600);t.recent=function(e,t=5*n.secondMs){return(0,c.isRecentMs)((0,h.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=r.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,s.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,s.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=r.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,a.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,h.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,o.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*n.secondMs):void 0)??(0,f.parseDateTime)(t)?.toMillis()}},12959:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filestampUTC=t.filestamp=void 0;const r=i(39926);t.filestamp=function(e=new Date){return[e.getFullYear(),(0,r.pad2)(e.getMonth()+1),(0,r.pad2)(e.getDate()),"-",(0,r.pad2)(e.getHours()),(0,r.pad2)(e.getMinutes()),(0,r.pad2)(e.getSeconds())].join("")},t.filestampUTC=function(e=new Date){return[e.getUTCFullYear(),(0,r.pad2)(e.getUTCMonth()+1),(0,r.pad2)(e.getUTCDate()),"-",(0,r.pad2)(e.getUTCHours()),(0,r.pad2)(e.getUTCMinutes()),(0,r.pad2)(e.getUTCSeconds())].join("")}},21330:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const n=i(77988),a=i(51168),o=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(31586),f=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),w=i(79842),v=i(66649),b=i(98247),S=i(98725),P=i(928),M=i(54261),_=i(73389),T=i(89724),E=i(17415),D=i(88600),k=i(51275);function x(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class F{constructor(e,t,i){this.year=e,this.month=t,this.day=i,r.set(this,(0,p.lazy)((()=>(0,D.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(S.ISO_YMD_RE.exec(e)?.groups??S.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,h.toGt0)(e?.year);if(null==e||null==t||tx(e))).join("-")}toLocal(){return(0,T.datedToLocal)(this)}toDateTime(){return a.DateTime.fromObject((0,f.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,f.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,f.pick)(e.plus({month:1}),"year","month"):(0,f.pick)(e.plus({year:1}),"year");return new F(t.year,t.month,t.day)}}function C(e,t){if(e instanceof n.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,M.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,E.zoneToTzOffsetMinutes)((0,v.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(r=>(0,d.map)((0,P.getMonth)(e),(s=>(0,d.map)((0,P.getDay)(e),(n=>(0,d.map)((0,P.getHour)(e),(a=>(0,b.dateObjectToExifDateTime)({year:r,month:s,day:n,hour:a,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=F,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",r=15*(0,h.round)(e/15),s=Math.abs(r),n=Math.floor(s/60),a=Math.floor(Math.abs(s%60));return`${t?"UTC":""}${i}${x(n)}:${x(a)}`},t.toExifDateTime=C,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof n.ExifDateTime?e.tzoffsetMinutes:(0,_.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,M.hasTime)(e)||(i??(0,w.datedToPrecisionMs)(e))>=c.dayMs?O(e):C(e,(0,k.getZoneName)(e))?.toISOString({includeOffset:t})};const A="yyyy:MM:dd HH:mm:ss.SSS",I=A+"ZZ";function O(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>x(e))).join(t)}function L(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new F(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,r]=[e,t].map(v.datedToMillis);return null==i||null==r?void 0:i-r}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,h.isNumber)(t)?a.DateTime.fromMillis(t):(0,w.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,k.hasZone)(t)?I:A):void 0},t.datedToYMD=O,t.toFuzzyDate=L,t.sameDay=function(e,t){return(0,h.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,h.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,r=1){if(null==(0,v.datedToMillis)(e)||null==(0,v.datedToMillis)(t))return;const[s,n]=[e,t].map((e=>(0,v.datedToMillis)(e))).sort(),o=(n-s)/(r+1),l=(0,k.getZoneName)(e),u=l===(0,k.getZoneName)(t)?l:void 0,c=a.DateTime.fromMillis(s+o*i,{zone:u});return[e,t].some((e=>!(0,M.hasTime)(e)))?L(c):c},t.setZone=function(e,t,i){const r={...(0,f.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,k.hasZone)(e)},s=(0,E.normalizeZone)(t);if(null!=e&&null!=s&&(0,M.hasTime)(e))return e instanceof y.DateInterval?e.setZone(s,r):C(e)?.setZone(s,r)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,h.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,w.datedToDateTime)(e);if(null==i)return;const r=(0,k.getZoneName)(e);return null!=r&&"UTC"!==r||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const o=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),h=i(49769),f=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),w=i(68852),v=i(4001),b=i(28874),S=i(24689),P=i(79842),M=i(66649),_=i(98247),T=i(21330),E=i(54261),D=i(73389),k=i(16400),x=i(88600),F=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return F().tap({msg:"extractDateFromPath",result:O.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return O.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return O.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,f.mapNumeric)((0,M.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,w.concatRegexp)([/^/,t.yearRE,w.RegExpOptional.from(/-/,t.monthRE,w.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,w.concatRegexp)([/^/,t.yearishRE,w.RegExpOptional.from(/-/,t.monthishRE,w.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=I({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,D.isDateTime)(i)?i:(0,E.isExifDateTime)(i)?i.toDateTime():void 0};const C=new Map;function A(e,t,i){try{const r=(0,_.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=r)return r;const s=(0,h.getOrSet)(C,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void F().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,_.parseExifDateTimeFormat)({input:s?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void F().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function I({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:r=!0,descPredicate:s=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const n=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(v.stripDSC));if(0!==n.length)for(const{desc:e,f:a}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>S.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,_.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:_.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(b.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(b.Settings.extraDateTimeFormats.values)){const r=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${r})`,f:i=>A(i,r,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>o.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of O.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:r}))if(s(e))for(const e of n){const t=a(e);if(null!=t&&(0,x.isValidDate)(t))return t}}t.parseDated=I;class O{constructor(e={}){r.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&b.Settings.fuzzyDateParsing.watchLater((()=>a(this,r,"m",n).call(this))),null==e.fuzzyYearParsing&&b.Settings.fuzzyYearParsing.watchLater((()=>a(this,r,"m",n).call(this))),a(this,r,"m",n).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??b.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??b.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!b.Settings.usePathsToInferDates.valueOrDefault)return;T.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=I({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=O,r=new WeakSet,s=function(e){const t=new L(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},n=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new w.RegExpEscaped("(?"+(0,k.monthNames)().map(w.escapeRegExp).join("|")+")");a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE]),a(this,r,"m",s).call(this,[e,t.seps,t.yearRE]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,e]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},O.instance=(0,u.lazy)((()=>new O));class L{constructor(e){this.regex=e instanceof RegExp?e:(0,w.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return T.FuzzyDate.for({year:(0,f.toInt)(t.year),month:(0,f.toInt)(t.month)??(0,k.monthName2index)(t.monthname),day:(0,f.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const r=i(55835),s=i(31586),n=i(54261);function a(e){return e instanceof Date?e.getMinutes():e?.minute}function o(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=a,t.getSecond=o,t.getMillisecond=l,t.getCentisecond=function(e){return(0,r.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,n.hasTime)(e)&&((0,s.gt0)(a(e))||(0,s.gt0)(o(e))||(0,s.gt0)(l(e)))},t.getSecMs=function(e){return(0,r.map)(o(e),(t=>{const i=l(e)??0;let r=(t+i/1e3).toString();for(t<10&&(r="0"+r),0===i&&(r+=".");r.length<6;)r+="0";return r}))}},54261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const r=i(77988),s=i(31586),n=i(68708);t.hasTime=function(e){if(!(0,n.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,s.gt0)(t.hour)||(0,s.gt0)(t.minute)||(0,s.gt0)(t.second)||(0,s.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof r.ExifDateTime}},73389:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const r=i(51168);t.isDateTime=function(e){return r.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const r=i(51168),s=i(19851),n=i(42659),a=i(55835),o=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),h=i(74417),f=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,s.lazy)((()=>w(l.Settings.datesBeforeAreEstimated.valueOrDefault)??w(l.Settings.datesBeforeAreEstimated.defaultValue)));function w(e){return(0,a.map)((0,c.isoToDated)(e),v)}function v(e){return(0,o.isNumber)(e)?_(e):100*b(e)+((0,m.getCentisecond)(e)??0)}function b(e){if((0,o.isNumber)(e))return Math.floor(_(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function S(e,t){if(null==e||e<0)return;let i=e;const r=()=>{const e=i%100;return i=Math.floor(i/100),e},s=10*r(),n=r(),a=r(),l=(0,o.toGt0)(r()),u=(0,o.toGt0)(r()),c=(0,o.toGt0)(r());return{year:i,month:c,day:u,hour:l,minute:a,second:n,millisecond:s,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=S(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):f.FuzzyDate.for(i)}function M(e,t){return _(Date.now()-e,t)}function _(e,t){return v(r.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const r=i(19851),s=i(76790),n=i(31586),a=i(9092),o=(0,r.lazy)((()=>{const e=new a.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const r=new Intl.DateTimeFormat(t,{month:i});(0,n.times)(12,(s=>{const n=r.format(new Date(2017,s));e.set(n,s+1),"short"===i&&"en-US"===t&&e.set(n+".",s+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:o().get(e)},t.monthNames=function(){return(0,s.sort)([...o().keys()])}},42499:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLuxon=void 0;const r=i(51168),s=i(19851),n=i(19043),a=i(28874);t.setupLuxon=(0,s.lazy)((async()=>{r.Settings.throwOnInvalid=!1,a.Settings.twoDigitCutoffYear.watch((e=>r.Settings.twoDigitCutoffYear=e)),r.Settings.defaultLocale=await(0,n.locale)()}))},17415:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),h=i(54993),f=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,n.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const r=(0,f.leastBy)(g(),(t=>Math.abs(t-e)));return null!=r&&Math.abs(r-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(r)}t.isUTCZone=function(e){return b(e)||0===S(e)?.offset(Date.now())},t.normalizeZone=S,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,o.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=M,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:M(i)};const _=/\b(?Z|UTC|GMT)\b/,T=/(?[-±+−])/,E=/[-−]/,D=/(?[01]\d)/,k=/(?[01]?\d)/,x=/(?::(?\d\d))/;function F(e){return b(e)?0:C((0,t.TimezoneOffsetRE)().exec(e))}function C(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,a.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=E.test((0,h.toS)(e.groups.tzSign))?-1:1,r=(0,l.toInt)(e.groups.tzMinutes)??0,s=null==t?void 0:i*(60*t+r);return w(s)?s:void 0}t.TimezoneOffsetRE=(0,n.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),_,new m.RegExpEscaped("|"),T,D,m.RegExpOptional.from(x),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=F,t.timezoneOffsetFromRegExpMatch=C;const A=/\b(?(?:Etc\/)?GMT)\b/,I=(0,n.lazy)((()=>(0,m.concatRegexp)([A,T,k,m.RegExpOptional.from(x)])));function O(e){return C(I().exec(e))}t.ianaZoneToOffsetMinutes=O,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,a.blank)(e))return;const i=O(e)??F(e);if(null!=i)return M(i);if(null!=t){const i=S(e);if(null!=i)return M(i.offset(t))}}},88600:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),h=i(28874),f=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),w=(0,s.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),v=(0,s.lazy)((()=>(0,n.compact)(h.Settings.badDates.values.map((e=>(0,f.isoToDated)(e)))))),b=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,p.datedToISO)(e)))))),S=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,y.datedToLocal)(e)))))),P=(0,s.lazy)((()=>(0,n.compact)(v().map((e=>(0,m.datedToMillis)(e))))));function M(e){if(null==e)return!1;const t=T(e);return w().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return M(e)?e:void 0},t.isValidDate=M;const _=String(new Date("bad"));function T(e){try{if(!(0,f.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===_)return _;const t=(0,n.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const s=[];if((0,l.isNumber)(e)||s.push("year is not a number"),(0,l.lt)(e,h.Settings.minValidYear.valueOrDefault)&&s.push("year is less than "+h.Settings.minValidYear.key),(0,u.gt)(e,E())&&s.push("year is in the future"),null==t&&null!=i&&s.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const n=r.DateTime.fromObject({year:e,month:t,day:i});n.isValid||s.push(n.invalidExplanation??"not valid")}return(0,n.compact)(s)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=h.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const r=(0,m.datedToMillis)(e);(0,u.gt)(r,Date.now()+i)&&t.push("date is too far in the future: see "+h.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):S().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):b().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,a.toNotBlank)((0,n.uniq)((0,n.compactBlanks)(t)).join("; "))}catch(t){return w().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=T;const E=(0,s.lazy)((()=>r.DateTime.now().plus({milliseconds:h.Settings.maxValidFutureMs.valueOrDefault}).year),o.dayMs);t.mapValidDate=function(e,t){return M(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==T({year:e,month:t,day:i})}},51275:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const r=i(77988),s=i(31586),n=i(24689),a=i(73389);t.hasZone=function(e){return null!=e&&!(0,s.isNumber)(e)&&(e instanceof n.DateInterval||e instanceof r.ExifDateTime?e.hasZone:!!(0,a.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==r.UnsetZoneName&&e.zone.offset(Date.now())!==r.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,a.isDateTime)(e)?e.zoneName===r.UnsetZoneName?void 0:e.zone?.name:e instanceof r.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},82261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cacheDbDir_=void 0;const r=i(51926),s=i(49776),n=i(38835),a=i(95696),o=i(70854),l=i(73428),u=i(28874),c=i(15056);t.cacheDbDir_=async function(e=u.Settings.libraryDir.valueOrDefault,t=c.Schemas.models){const i=(0,o.libraryUidStore)(e);if(null==i)throw new Error("Library directory is not set"+n.NoLibraryErrorFlag);const d=await i.readUid_(),h=a.PosixFile.for((0,s.cacheDir_)()).join(t+"-live-db",d);await h.mkdirp_();const f=h.join("README.txt");return await(0,l.writeTextfile_)(f.nativePath,...(0,r.wrap)(["This folder is used by PhotoStructure for your library stored in",e,"You will corrupt your library if you remove this directory while PhotoStructure is running.","See https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837 for details."].join("\n\n"))),h}},92407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLiveDbDir_=t.cacheDbFile_=void 0;const r=i(19851),s=i(87290),n=i(50213),a=i(28874),o=i(82261),l=i(15056),u=i(7311),c=i(44955),d=(0,r.lazy)((()=>(0,n.mkLogger)("db.CheckLocalDbReplica")));async function h({libraryDir:e=a.Settings.libraryDir.valueOrDefault,schema:t=l.Schemas.models}={}){return(await(0,o.cacheDbDir_)(e,t)).join(u.SqliteBase)}t.cacheDbFile_=h,t.getLiveDbDir_=async function(e=a.Settings.libraryDir.valueOrDefault){if(!a.Settings.forceLocalDbReplica.valueOrDefault){const t=(0,l.pathToDb)(await(0,s.setupLibraryDataDir_)(e),l.Schemas.models);try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!1}}catch(e){d().info("SQLite cannot directly write to the library: trying to use a local db replica.",{libraryDb:t,error:e})}}const t=await h({libraryDir:e,schema:l.Schemas.models});try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!0}}catch(e){return d().throw("SQLite cannot directly write to the library or the cacheDir.",{cacheDbFile:t,error:e})}}},5531:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},55332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupCold_=void 0;const r=i(19851),s=i(50213),n=i(76187),a=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbBackupCold")));t.dbBackupCold_=async function(e,t){await t.mkdirp_();const i=[];try{for(const r of(0,n.sqliteFiles)(e)){const e=t.join(r.base).wip();i.push(e),await r.copyFile_(e)}return a().tap({msg:"completed",level:"info",result:await Promise.all(i.map((e=>e.unwip_()))),meta:{srcDbFile:e,destDir:t}})}catch(e){throw await Promise.all(i.map((e=>e.unlink()))),e}}},91872:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleDbRetries_=void 0;const r=i(50213),s=i(70025),n=i(28874),a=i(45599),o=i(41400),l=i(30976),u=i(56038),c=(0,a.defer)((()=>(0,r.mkLogger)("db.DbRetries")));t.handleDbRetries_=function(e,t,i,r){const a=Date.now();let d=0;const h=a+n.Settings.dbMaintenanceTimeoutMs.valueOrDefault;return(0,u.time)(e,(async()=>{for(;Date.now()=h)throw c().error(e+": Caught db error. Not retrying.",{error:t}),t;{const i=(0,l.randomInt)(500,1500)*++d;c().warn(e+": Caught db error. Retrying in "+i+"ms.",{name:e,error:t}),r?.(),await(0,o.delay)(i)}}return t().close(),c().throw(e+": handleDbRetries(): timeout after "+n.Settings.dbMaintenanceTimeoutMs.valueOrDefault+"ms")}))}},12943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toDbValued=t.isDbValued=t.isDbValue=void 0;const r=i(79842),s=i(66649),n=i(40958),a=i(68708);function o(e){return null===e||(0,n.includes)(["number","string"],typeof e)}t.isDbValue=o,t.isDbValued=function e(t){return null!=t&&Array.isArray(t)?t.every(e):(0,a.entries)(t).every((([,e])=>o(e)))},t.toDbValued=function(e){return(0,a.mapFields)(e,((e,t)=>{if(!e.startsWith("$"))return"boolean"==typeof t?[e,t?1:0]:o(t)?[e,t]:(0,r.isDated)(t)?[e,(0,s.datedToMillis)(t)]:void 0}))}},65753:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maxBatchPluckSize=void 0;const r=i(19851),s=i(7282),n=i(28874);t.maxBatchPluckSize=(0,r.lazy)((()=>Math.round(n.Settings.dbBatchSelectSize.valueOrDefault*((0,s.isTest)()?.25:5))))},80632:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pageSizeBytes=t.mkdb_=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(54993),u=i(50213),c=i(23560),d=i(65211),h=i(29882),f=i(53265),m=i(66430),p=i(66184),g=i(28874),y=i(15674),w=i(87550);function v(){const e=g.Settings.dbPageSizeBytes.valueOrDefault;return Math.pow(2,(0,a.clamp)(1,28,Math.round(Math.log2(e))))}t.mkdb_=function({nativePath:e,timeoutMs:t=g.Settings.dbBusyTimeoutMs.valueOrDefault,logSql:i=g.Settings.logSql.valueOrDefault}){e=(0,f.resolve)(e),(0,h.mkdirpSync_)((0,r.dirname)(e));const b=(0,h.posixPathFromGrandparent)(e),S=(0,m.nativePathSizeSync)(e),P=(0,u.mkLogger)("db.mkdb("+b+")");if(null!=S){const E=Math.round(S/o.MiB),D=Math.ceil(1.5*E);D>g.Settings.dbCacheSizeMb.valueOrDefault&&(P.info("Dynamically setting dbCacheSize to "+g.Settings.dbCacheSizeMb.value,{db:e,dbFileSizeMb:E}),g.Settings.dbCacheSizeMb.envValue=D);const k=Math.round(1.5*E);k>g.Settings.maxMemoryMb.valueOrDefault&&(P.warn("Large database: setting maxMemoryDb to "+k+"MB",{dbFileSizeMb:E,"Settings.maxMemoryMb":g.Settings.maxMemoryMb.valueOrDefault}),g.Settings.maxMemoryMb.envValue=k)}P.info("Opening "+e+"...");const M={fileMustExist:!1,readonly:!1};if((0,a.gt0)(t)&&(M.timeout=Math.ceil(t)),i){const x=(0,u.mkLogger)("SQLite("+b+")"),F=(0,p.defaultLogLevel)();function C(e,...t){var i;(0,n.blank)(e)||x.log(F,(i=e,(0,l.toS)(i).replace(/\s{2,}/g," ")),{args:t})}M.verbose=C}const _=new w(e,M);P.info("Open. Setting PRAGMAs...");for(const A of(0,s.compact)(['encoding = "UTF-8"',"threads = "+(0,y.maxCpus)(),"foreign_keys = ON","page_size = "+v(),"trusted_schema = 0","cache_size = -"+Math.round(g.Settings.dbCacheSizeMb.valueOrDefault*o.MiB/1024),"locking_mode = NORMAL","journal_mode = WAL",(0,a.gt0)(g.Settings.dbBusyTimeoutMs.valueOrDefault)?"busy_timeout = "+g.Settings.dbBusyTimeoutMs.valueOrDefault:null,"temp_store = MEMORY","synchronous = "+g.Settings.dbSynchronousMode.valueOrDefault,"case_sensitive_like = 0","wal_autocheckpoint = "+((0,c.isDbJanitorService)()?(0,l.toS)(g.Settings.dbWalAutoCheckpoint.valueOrDefault):"0"),"auto_vacuum = "+g.Settings.dbAutoVacuumMode.valueOrDefault]))P.tapThunk({msg:"PRAGMA "+A,result:()=>_.pragma(A)});const T=_;return T.__uid=(0,d.uid)(),T},t.pageSizeBytes=v},99315:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},95704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withIdBatches=void 0;const r=i(40958),s=i(31586),n=i(59455),a=i(65753),o=i(51040);t.withIdBatches=async function(e){const t=(0,s.toGt0)(e.batchSize)??(0,a.maxBatchPluckSize)(),i=(0,o.dbValueToEscapedString)(e.primaryKeyColumnName),l=(0,r.compactBlanks)([i+" > :min",...(0,n.toA)(e.whereClauses)]).join(" AND "),u=e.db.prepare((0,r.compactBlanks)(["SELECT "+i,"FROM "+(0,o.dbValueToEscapedString)(e.tableName),"WHERE "+l,"ORDER BY "+i,"LIMIT :limit"]).join(" "));let c=-1;for(;;){const i=u.pluck().all({min:c,limit:t});if(0===i.length)return;await e.fn(i),c=(0,r.last)(i)}}},76187:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSqliteFile=t.sqliteSizeBytes=t.sqliteFiles=void 0;const r=i(17217),s=i(87391),n=i(7311);t.sqliteFiles=function(e){return[e,...s.SQLiteSuffixes.map((t=>e.sibling(e.base+t)))].filter((e=>e.existsSync({refresh:!0})))},t.sqliteSizeBytes=async function(e){return(await e.size({refresh:!0})??0)+(await e.sibling(e.base+"-wal").size({refresh:!0})??0)};const a=[n.SqliteExt,...[...s.SQLiteSuffixes,"-shm"].map((e=>n.SqliteExt+e))];t.isSqliteFile=function(e){const t=(0,r.basename)(e);for(const e of a)if(t.endsWith(e))return!0;return!1}},51040:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitBatchSql=t.dbValueToEscapedString=void 0;const r=i(40958),s=i(31586),n=i(54993),a=/^\w+$/;t.dbValueToEscapedString=function(e){if((0,s.isNumber)(e))return e.toString();const t=(0,n.toS)(e);return a.test(t)?t:`'${t.replace(/'/g,"''")}'`};const o=/--.+$/gm,l=/\s+/g;t.splitBatchSql=function(e){const t=(0,r.compactBlanks)((0,n.toS)(e).split(/;/).map((e=>e.replace(o,"").replace(l," ").trim()))),i=[];let s;for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertDirSQLiteReadWrite_=t.isDirSQLiteReadWrite=t.firstDirSQLiteReadWrite=void 0;const r=i(19851),s=i(50357),n=i(30976),a=i(50213),o=i(95696),l=i(80632),u=i(76187),c=(0,r.lazy)((()=>(0,a.mkLogger)("db.SQLiteReadWrite")));async function d(e){try{return await h(e),c().info("isDirSQLiteReadWrite(): true",{dirNativePath:e}),!0}catch(t){return c().warn("isDirSQLiteReadWrite(): false",{dirNativePath:e,error:t}),!1}}async function h(e){const t=o.PosixFile.for(e),i=(0,n.randomChars)(8),r=t.child(".test-"+i+".sqlite");let a=null;try{await t.mkdirp_(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3}),a.exec("CREATE TABLE t (s VARCHAR(16) NOT NULL)"),a.exec(`INSERT INTO t (s) VALUES ('${i}')`);{const e=a.prepare("SELECT s FROM t").all();(0,s.eql)(e,[{s:i}])||c().throw("unexpected rows",{rows:e})}a.exec("VACUUM"),a.close(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3});{const e=(0,n.randomChars)(8);a.exec(`INSERT INTO t (s) VALUES ('${e}')`);const t=a.prepare("SELECT s FROM t ORDER BY s").pluck().all();(0,s.eql)(t,[i,e].sort())||c().throw("unexpected rows",{rows:t})}}finally{try{a?.close()}catch{}await Promise.all((0,u.sqliteFiles)(r).map((e=>e.rm())))}}t.firstDirSQLiteReadWrite=async function(...e){for(const t of e)if(null!=t&&await d(t))return t},t.isDirSQLiteReadWrite=d,t.assertDirSQLiteReadWrite_=h},87391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SQLiteSuffixes=void 0,t.SQLiteSuffixes=["-wal","-journal"]},15056:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),s=i(7311);function n(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=n,t.pathToDb=function(e,t){return n(e,t).join(s.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const a=n(i(76760)),o=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),w=i(70698),v=i(64680),b=i(29882),S=i(45969),P=i(43334),M=i(28874),_=i(41692),T=i(32774),E=i(80612),D=i(32551),k=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function x(){if((0,S.isDocker)())return[{dir:"/tmp/.photostructure-cache"+k(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,a.join)(i,".photostructure-cache"+k()),preexistingDir:i});return e}}function F(){if((0,S.isDocker)())return(0,o.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,a.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:T.DefaultDockerLibraryDir+"/.photostructure/cache"+k(),preexistingDir:T.DefaultDockerLibraryDir},...x()]);const e=(0,o.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),a.default.resolve((0,D.homeDir)(),"AppData","Local")]:P.isMac?[a.default.resolve((0,D.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,a.join)((0,D.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,a.join)(e,t),preexistingDir:e})));return i.push(...x()),i}t.tmpCacheDirs=x,t.tmpDirs=function(){return(0,E.filterDirs)({dirs:x(),desc:"tmp"})},t.cacheDirs=F,t.defaultCacheDir=(0,d.lazy)((()=>(0,E.firstDir)({dirs:F(),desc:"cache"})));const C=(0,d.lazy)((()=>{(0,_.setSettingsDefaults)(),M.Settings.cacheDir.watchLater(A)}));function A(){M.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{C();const e=M.Settings.cacheDir.valueOrDefault;try{return(0,b.mkdirpSync_)(e),(0,w.writeCachedirTag_)(e).then((()=>(0,v.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=A},46292:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),s=i(45969),n=i(41692),a=i(32774),o=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,n.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,s.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,o.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:a.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:a.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,s.isDocker)()?c:(0,o.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),s=i(45969),n=i(32774);t.defaultLibraryDir=function(){return(0,s.isDocker)()?n.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,s.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const s=r(i(76760)),n=i(40958),a=i(72993),o=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),s.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(s.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,o.env)().XDG_DATA_HOME,(0,o.env)().XDG_CONFIG_HOME,s.default.resolve((0,d.homeDir)(),".config")),(0,n.compactBlanks)(e).map((e=>({dir:s.default.join(e,(0,a.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),s=i(96706),n=i(29882);t.envConfigDir=function(){const e=(0,s.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,n.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),s=i(40958),n=i(22573),a=i(66430);function o({dirs:e,desc:t}){for(const{dir:i,preexistingDir:o}of(0,s.compact)(e))if(!(0,n.blank)(i)){if((0,a.isReadWriteableDirectorySync)(i))return i;if((0,n.blank)(o)||(0,a.isReadWriteableDirectorySync)(o))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=o,t.filterDirs=function({dirs:e,desc:t}){return(0,s.compact)(e.map((e=>o({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),s=i(76760),n=i(1708),a=i(19851),o=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,a.lazy)((()=>{const e=[];u.isWin?e.push(n.env.USERPROFILE):e.push(n.env.HOME);for(const t of(0,o.compactBlanks)(e)){const e=(0,s.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),s=i(49776),n=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[n.libraryDataDir,n.libraryPreviewsDir,s.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},9595:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),s=i(54993),n=i(29882),a=i(28874);function o(e){return(0,r.toNotBlank)((0,s.toS)(e))??a.Settings.libraryDir.valueOrDefault}t.libraryDir=o,t.originalsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,n.resolveMaybe)(o(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),s=i(55835),n=i(37805),a=i(15056),o=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${n.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function w(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+o.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function v(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function b(e){return y(v(e),!1)}function S(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(S(e))}function M(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function _(e){return y(M(e))}async function T(e){return y((0,s.map)(g(e),(e=>(0,a.pathToDbDir)(e,a.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await w(t);return(0,r.uniq)([t,i,await b(t),await P(t),await _(t),await T(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=w,t.libraryOriginalsDirPosixFile=v,t.setupLibraryOriginalsDir_=b,t.libraryPreviewsDirPosixFile=S,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=M,t.setupLibrarySyncReportsDir_=_,t.setupLibraryDbDir_=T},46296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),w=i(80612),v=i(32551);function b(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:s.default.resolve((0,v.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,v.homeDir)()}]:(0,a.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>s.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function S(){return(0,w.firstDir)({dirs:b(),desc:"logs"})}t.defaultLogDirs=b,t.defaultLogDir_=S,t.logDir=(0,n.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,o.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,o.notBlank)(i)?i:S()}catch(e){return console.error("defaultLogDir_() failed",e),s.default.resolve((0,v.homeDir)(),"logs")}}))},55939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(44198),o=i(43334),l=i(24399),u=i(32551);async function c(){return o.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,s.lazy)((async()=>{if(o.isWin){const e=await c();if((0,n.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,s.lazy)((()=>(0,a.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),s=i(7282),n=i(29325),a=i(44198);t.getDevEnvFlag=function(e){return!(0,s.isProd)()&&!(0,n.isPacked)()&&((0,r.toBoolean)((0,a.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,a.env)()[e]=String(t)}},34580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),s=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,s.env)().DO_NOT_TRACK)}},44198:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const s=r(i(73024)),n=i(76760),a=r(i(1708)),o=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),w=i(6012),v=i(96706);t.env=(0,o.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>a.default.env[e])).join(n.delimiter).split(n.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===a.default.env.PS_LICENSE||e.push((0,n.join)((0,f.homeDir)(),".psenv"));const t=(0,v.SensitiveEnvRE)(),i={...a.default.env};for(const r of e)try{const e=(0,d.debom)(s.default.readFileSync((0,p.resolve)(r))),n=(0,w.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(n))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),s=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let n;for(const a of(0,s.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(n=e.exec(a));){if(null==n.groups)continue;const{key:e,val:s}=n.groups;if((0,r.blank)(e)||null==s)continue;const a=s.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=a}}return i}},96706:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const s=r(i(1708)),n=i(19851),a=i(22573),o=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,n.lazy)((()=>(0,a.firstNotBlank)(s.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,s.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,n.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,n.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,o.isTrue)(g(e))}},98314:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),s=i(19851),n=i(40958),a=i(22573),o=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),w=i(70025),v=i(57159);function b(...e){if((0,n.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(o.errorName),...e.map(o.errorCode),...(0,n.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(o.ErrorDelimiter)))];return(0,n.uniqSubstrings)(S((0,l.flatten)(i)))}function S(e){return(0,n.compact)(e).filter((e=>!o.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(a.notBlank)}function P(e,t){const i=(0,n.uniqSubstrings)(S(e)),r=t?.maxLen??400,s=t?.trailingChars??64,a=(0,y.sortErrorFlags)([...t?.flags??[],...(0,w.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,w.stripErrorFlags)(i.join(o.ErrorDelimiter)),r-a.length,s)+a.sort().join("")}function M(e,t){return e instanceof v.WrappedError?e.toString():(0,a.blank)(e)?"":P(b(e),t)}t.StartTs=Date.now(),t.logger=(0,s.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(M(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,a.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,a.notBlank)(i))return i}},t.splitErrorMessage=b,t.normalizeErrorMessages=S,t.joinErrorMessages=P,t.errorToS=M,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,a.blank)(e)&&(e=t.MissingError),M(e,{maxLen:i})+" at "+(0,o.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),s=i(26905),n=i(55835),a=i(54993),o=i(81168);t.describeError=function(e){const t=(0,o.stripSuffix)((0,a.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,n.map)((0,s.errorErrno)(i),(e=>t.push(u.get(e)))),(0,n.map)((0,s.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),s=i(76790),n=i(50989),a=i(68852);t.ErrorFlags=(0,n.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,s.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(a.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},68301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorStore=t.ExtraEventsForPlease=void 0;const r=i(19851),s=i(42659),n=i(75240),a=i(55835),o=i(31586),l=i(68708),u=i(59455),c=i(54993),d=i(50213),h=i(45255),f=i(37628),m=i(99331),p=i(46292),g=i(38835),y=i(32144),w=i(29882),v=i(95696),b=i(55222),S=i(28874),P=(0,r.lazy)((()=>(0,d.mkLogger)("error.EventStore")));function M(e){return(0,l.omit)(e,"breadcrumbs")}t.ExtraEventsForPlease=7;class _{constructor(e){this.root=e}datedRoot(e=new Date){return this.root.join((0,c.toS)(e.getFullYear()),(0,c.toS)(e.getMonth()+1))}rmrf(){return this.root.rmrf()}msg2file(e){return this.datedRoot(new Date(e.timestamp*s.secondMs)).join((0,f.shortStringSha)(e.message,8,b.GeoRadix)+".json")}async eventsFrom(e=new Date,t=s.dayMs){const i=e.getTime(),r=i-t,a=i+t;return P().tap({msg:"eventsFrom()",result:(0,u.toA)(await this.datedRoot(e).clear().childFiles((async e=>P().tap({msg:"eventsFrom().childFiles() accept "+e.base,result:(0,y.isJsonExt)(e)&&!(0,w.isHiddenBasename)(e.base)&&(0,o.within)(r,a,e.mtimeMs())})))),meta:{when:e,deltaMs:(0,n.fmtDuration)(t)}})}async eventCount(e=new Date){return(await this.eventsFrom(e)).length}async eventQuotaExceeded(e){const i=(0,c.toS)(e).includes(g.PleaseSendErrorFlag)||(0,c.toS)(e.message).includes(g.PleaseSendErrorFlag),r=await this.eventCount(),s=S.Settings.maxErrorsPerDay.valueOrDefault+(i?t.ExtraEventsForPlease:0);return P().tap({msg:"eventQuotaExceeded()",result:r>=s,meta:{event:M(e),recentEventCount:r,maxErrorsPerDay:s,pleaseSend:i}})}async maybeSendEvent(e){if(e.timestamp=Math.floor(e.timestamp),(0,m.ending)())P().error("maybeSendEvent(): REJECT: we're ending.",{event:M(e)});else if(await this.eventQuotaExceeded(e))P().error("maybeSendEvent(): REJECT: too many recent events.",{event:M(e)});else try{const t=await this.writeEvent_(e);return P().tap({msg:"maybeSendEvent(): "+t==null?"REJECT: previously sent this event already this month":"ACCEPT",result:null!=t?e:void 0,meta:{eventFile:t}})}catch(e){return void P().error("maybeSendEvent(): REJECT: failed to write event.",e)}}writeEvent_(e){return this.msg2file(e).applyIfEmpty_({fn_:t=>t.writeJson_(e),minSizeBytes:3,returnUndefinedIfNotEmpty:!0,timeoutMs:h.ShortCommandTimeoutMs})}}t.ErrorStore=_,_.instance=(0,r.lazy)((()=>(0,a.map)((0,p.configDir)(),(e=>new _(v.PosixFile.for(e).join("events"))))))},70025:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),s=i(38639),n=i(26905),a=i(54993),o=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,a.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,a.toS)(e)+(0,r.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,o.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function w(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function v(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function b(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function S(e){return!!((0,s.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||b(e))||void 0}t.isSqliteBusyError=w,t.isSqliteDisconnectedError=v,t.isSqliteConstraintError=b,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===S(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,n.errorCode)(e)||w(e)||v(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=S;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,s.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,s.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},51837:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalError=void 0;const r=i(38835);class s extends Error{constructor(e){super(e+r.InternalErrorFlag)}}t.InternalError=s},8769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),s=i(31586),n=i(68708),a=i(7282),o=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,n.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const s=!0===i.fatal,c=!0===i.ignorable;if(!s&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),s&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!s||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!s||(0,a.isTest)()||(0,o.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),s}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,s.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,o.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,s.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,s.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(26905),o=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,s.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,s.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,a.errorName)(t)??(0,d.first)(this.causes,a.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(a.errorCode)],a.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,a.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,n.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,n.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,n.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,s.blank)(r)||(i=(0,h.dedupeNeedle)(i,r,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,o.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const a=i(49769),o=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),s.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,a.getOrSet)(n(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),a=n(this,r,"f").get(e);return null!=a&&(a.resolve(t),n(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,s=new WeakMap},34102:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),s=i(19851),n=i(15197);t.ee=(0,s.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new n.CapturingEventEmitter(e)}))},64660:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const s=r(i(73024)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,a.lazy)((()=>n.default.geteuid?.())),h=(0,a.lazy)((()=>n.default.getgroups?.()));function f(e,t){try{return!(0,o.blank)(e)&&(s.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,s.default.constants.R_OK|s.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,s.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:s,processGid:n}){if(null==e)return!1;const a=s??d(),o=null!=n?[n]:h()??[],l=0===a,u=l||e.uid===a,f=l||o.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const s=r(i(76760)),n=i(19851),a=i(81168),o=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,n.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,a.equalsIgnoreCase)(e.basename,i.base))return s.default.join(r,e.basename);throw new o.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),s=i(76760);function n(e){return[...a(e)]}function*a(e){for(;e!==(0,s.dirname)(e);)e=(0,s.dirname)(e),yield e}function o(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=o(e);return t.every((e=>i.includes(e)))}t.ancestors=n,t.ancestorG=a,t.selfAndAncestorG=function*(e){yield e,yield*a(e)},t.childrenSync=o,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return n(e).find((e=>l(e,t)))}},83278:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),w=f(i(1708)),v=i(46466),b=f(i(57975)),S=f(i(38522)),P=i(19851),M=i(40958),_=i(5233),T=i(22573),E=i(42659),D=i(50357),k=i(96249),x=i(98553),F=i(55835),C=i(31586),A=i(68708),I=i(97790),O=i(39926),L=i(51926),R=i(59455),N=i(54993),B=i(48884),j=i(22911),z=i(99331),V=i(56519),W=i(56038),U=i(31562),q=i(76850),H=i(70025),G=i(34102),$=i(80875),J=i(50213),K=i(70417),Z=i(43334),Y=i(81168),X=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),se=i(89968),ne=i(20197),ae=i(88561),oe=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),we=i(27794),ve=i(73428),be=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const Se=(0,P.lazy)((()=>new ae.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),s.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),a.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(s=new WeakMap,a=new WeakMap,r=new WeakSet,b.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,M.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,B.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,T.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=Se().get(i);if(null!=r)return r;const s=(0,fe.resolve)(i),n=new Pe(s,t);return Se().set(i,n),Se().set(s,n),n}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,s,"f").unset(),h(this,a,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Y.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,F.map)(this.statSync(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,s,"f").call(this);if(null==t||null==e||(0,M.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",n).call(this)??await d(e=this.clearThisAndParent(),r,"m",n).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,M.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,M.isNotEmpty)(e)?(0,M.includesAll)(t,e):(0,M.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,M.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,R.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,C.gt0)(t))return;const i=await d(this,s,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Z.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,M.isEmpty)(e)||(0,D.eql)(["."],e)||e.every(T.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,F.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,O.pad2)(t+1),(0,O.pad2)(i))))}child(...e){if((0,M.isEmpty)(e))return this;const t=(0,k.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,E.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),B.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Z.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,M.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>=(0,E.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>(0,E.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,F.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*E.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,oe.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,oe.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,$.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,$.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,q.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,be.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,ve.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,ve.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,ve.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,ve.writeFileSync_)(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces),(0,A.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,we.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,we.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,_.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,z.ending)()?1:3,timeoutMs:0,retryDelay:E.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,r,"m",o).call(this,(0,Y.stripSuffix)(this.base,".gz"),S.default.createGunzip())}async gzip(){return d(this,r,"m",o).call(this,this.base+".gz",S.default.createGzip())}async compressBrotli(){return d(this,r,"m",o).call(this,this.base+".br",S.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,ne.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,ne.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(S.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,M.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new j.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,L.newlineRe)(),(r=>{const s=e.exec(r);null!=s&&(t.maybeResolve(s),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,C.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new j.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),Me)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,s)=>{try{const n=await e.f(r,(0,F.denull)(s));t(n)&&i.resolve(n)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,C.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,n=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Y.equalsIgnoreCase)(e.basename,this.base))),t=(0,B.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,F.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},o=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,v.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*E.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let Me=!0;t.useFsWatch=function(e){Me=e},t.execDir=function(){return Pe.for(w.default.execPath).parent()}},19748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const r=i(28874),s=i(88840),n=i(14036),a=i(29882);function o(e){return t=>r.Settings.respectFileExtensions.valueOrDefault?(0,n.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,a.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=o,t.isBrowserExtension=o(s.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=o(s.ExtTypes.Video),t.isAssetFileExtension=o(s.ExtTypes.AssetFile)},84542:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),s=i(96249),n=i(51926),a=i(54993),o=i(43334);function l(...e){return(0,s.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,a.toS)(e).split((0,n.newlineRe)()))))}t.Newline=o.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(a.toS).join("\n");return o.isWin?t.replace((0,n.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),s=i(19851),n=i(50213),a=i(37805),o=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,s.lazy)((()=>(0,n.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,o.mkdirp_)(i),await(0,d.writeTextfile_)((0,o.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+a.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,a.lazy)((()=>[...(0,o.mapNotBlankOr)(n.default.env.SYSTEMROOT,(e=>[e,s.default.join(e,"System32"),s.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const o=n(i(44652)),l=a(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),w=i(14427),v=i(17217),b=i(16287),S=i(68284);class P{constructor(e,t){this.base=e,(0,w.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const M=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class _{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new _(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,v.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},s=await o.stat(t);return new _(i,new P(r,s))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return _.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new _(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void M().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>_.fromSimpleDirent(this.nativePath,e)))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new _(this.nativePath,new P(e.name,e))))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,S.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,b.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await o.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await o.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=_},60652:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,w,v,b,S,P,M,_,T=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},E=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryIterator=t.Undone=t.Done=void 0;const D=i(76760),k=i(19851),x=i(40958),F=i(22573),C=i(41400),A=i(57924),I=i(31586),O=i(68708),L=i(34666),R=i(13538),N=i(83104),B=i(12168),j=i(59455),z=i(48884),V=i(45255),W=i(81168),U=i(38836),q=i(98314),H=i(32144),G=i(28874),$=i(79915),J=i(59107),K=i(98604),Z=i(69385),Y=i(92423),X=i(29882),Q=i(62105),ee=i(74128);t.Done={done:!0},t.Undone={done:!1};class te extends U.EndableWrapper{constructor(e,i,s){super("dir.DirectoryIterator("+e+")",(()=>this.cancel({details:"DirectoryIterator was ended"}))),r.add(this),this.dir=e,this.ctx=i,this.parent=s,this.start=Date.now(),n.set(this,[]),a.set(this,[]),o.set(this,[]),l.set(this,[]),u.set(this,void 0),c.set(this,!1),d.set(this,0),h.set(this,0),f.set(this,0),m.set(this,0),p.set(this,0),this.rootDir=(0,k.lazy)((()=>this.parent?.rootDir()??this.dir)),this.pathFromRoot=(0,k.lazy)((()=>(0,X.posixPathFrom)({nativePath:this.rootDir().dir},this.dir))),this.nextTimeout=(0,k.lazy)((()=>G.Settings.statTimeoutMs.valueOrDefault+(0,I.clamp)(0,512,10*(512-this.depth())))),y.set(this,(0,k.lazy)((async()=>{const e=await(0,Y.whyExcludedDirectory)(this.dir)??(!this.isRoot&&await(0,J.isPosixMountpoint)(this.dir)?"nested mountpoint":void 0);if(null!=e)return this.logger.info("skipping ignorable dir, "+this.dir,{details:e}),await(this.ctx.onExcludedDirectory?.(this.dir,e)),this.cancel({state:ee.SyncDirStates.skipped,details:e}),t.Done}))),b.set(this,(0,k.lazy)((async()=>{const[e,t]=(0,z.partition)((0,j.toA)(await this.dir.children()),(e=>T(this,r,"m",v).call(this,e)));for(const t of e)(0,ee.syncReport)().onProgress({path:t.nativePath,from:"DirectoryIterator",state:ee.SyncFileStates.skipped,details:"this was scanned in a prior incomplete sync"});T(this,l,"f").push(...t.filter((e=>e.isDirectory()))),E(this,m,T(this,l,"f").length,"f");const i=t.filter((e=>e.isFile())),[s,a]=(0,z.partition)(i,H.isSidecarExt);T(this,n,"f").push(...a),T(this,o,"f").push(...s),E(this,h,T(this,n,"f").length,"f")}))),(0,ee.syncReport)().onProgress({path:e.nativePath+D.sep,from:"DirectoryIterator",state:ee.SyncDirStates.scanning})}get isRoot(){return null==this.parent}isDone(){return this.ended||T(this,c,"f")}status(){return{root:this.rootDir().nativePath,path:this.pathFromRoot(),isDone:this.isDone()}}cancel(e){return T(this,c,"f")||(E(this,c,!0,"f"),(0,ee.syncReport)().onProgress({path:this.dir.nativePath+D.sep,from:"DirectoryIterator",state:ee.SyncDirStates.canceled,...e,elapsedMs:Date.now()-this.start})),t.Done}depth(){return(0,W.countChars)(this.dir.nativePath,D.sep)}async run(e=V.ShortCommandTimeoutMs){for(;!this.isDone();)await this.next(Date.now()+e),await(0,C.delay)(1)}async next(e){var i;const s=e-Date.now();try{this.logger.trace("next() starting",{runMs:s});const n=await(0,R.thenOrTimeout)(T(this,r,"m",g).call(this,e),this.nextTimeout());return this.logger.trace("next() finished",{result:n}),n===N.Timeout?(E(this,p,(i=T(this,p,"f"),++i),"f"),this.logger.warn(".next() timed out",{runMs:s,timeoutCount:T(this,p,"f")}),T(this,p,"f")>3?(this.logger.warn(".next(): too many timeouts, giving up on this directory."),this.cancel({state:ee.SyncDirStates.timeout,details:"Failed to scan, even after 3 retries"})):t.Undone):(E(this,p,0,"f"),n)}catch(e){return this.logger.warn("next() failed",{error:e}),this.cancel({state:ee.SyncDirStates.failed,details:"Error thrown during scan: "+(0,q.errorToS)(e)})}}}t.DirectoryIterator=te,s=te,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,m=new WeakMap,p=new WeakMap,y=new WeakMap,b=new WeakMap,r=new WeakSet,g=async function(e){return(T(this,c,"f")?t.Done:void 0)??await T(this,y,"f").call(this)??await T(this,b,"f").call(this)??await T(this,r,"m",S).call(this,e)??await T(this,r,"m",P).call(this,e)??await T(this,r,"m",M).call(this,e)??await T(this,r,"m",_).call(this)},w=function(e){return this.ended||!0===this.ctx.ended?.()?this.cancel({details:"DirectoryIterator was ended"}):T(this,c,"f")?t.Done:(0,Z.isPaused)()||Date.now()>e?t.Undone:void 0},v=function(e){return this.logger.tap({msg:"shouldSkipChild()",result:(0,x.isNotEmpty)(this.ctx.startAtNativePath)&&(0,L.cmpArr)((0,X.splitNativePath)(e.nativePath),this.ctx.startAtNativePath,!1)<=0,meta:{child:e.base}})},S=async function(e){var t;const i=[];let s;for(;null==s&&(0,x.isNotEmpty)(T(this,n,"f"))&&this.ctx.hasCapacity();){const a=T(this,n,"f").shift();E(this,d,(t=T(this,d,"f"),++t),"f");const o=await(0,Q.whyRejectFileSimple)(a);null!=o?(this.logger.debug("maybePopChildFile()",{child:a,whyReject:o}),await(this.ctx.onExcludedFile?.(a,o)),(0,ee.syncReport)().onProgress({path:a.nativePath,from:"DirectoryIterator",state:ee.SyncFileStates.rejected,details:o})):i.push(a),s??(s=T(this,r,"m",w).call(this,e)),null!=s&&this.logger.trace("maybePopChildFile() timeout",{timeout:s})}return(0,x.isNotEmpty)(i)&&(this.logger.trace("maybePopChildFile()",{toAdd:i}),await this.ctx.fileHandler(i),T(this,a,"f").push(...i)),s},P=async function(e){for(;(0,x.isNotEmpty)(T(this,o,"f"));){const t=T(this,o,"f").shift();if(G.Settings.tagAlbumFilenames.values.includes(t.base))(0,ee.syncReport)().onProgress({path:t.nativePath,from:"DirectoryIterator",state:ee.SyncFileStates.note,details:"sidecar will be checked for for album metadata"});else{const e=T(this,a,"f").filter((e=>(0,$.isSidecarOf)(e,t)));(0,x.isNotEmpty)(e)?(0,ee.syncReport)().onProgress({path:t.nativePath,from:"DirectoryIterator",state:ee.SyncFileStates.note,details:"sidecar will be processed with "+(0,A.andList)(e.map((e=>e.base.normalize())))}):(0,ee.syncReport)().onProgress({path:t.nativePath,from:"DirectoryIterator",state:ee.SyncFileStates.rejected,details:"sidecar will be ignored (no importable file was found to be relevant to this sidecar's name)"})}const i=T(this,r,"m",w).call(this,e);if(null!=i)return this.logger.trace("handleSidecars() timeout",{timeout:i}),i}},M=async function(e){var t;let i;for(;null==i&&(null!=T(this,u,"f")||(0,x.isNotEmpty)(T(this,l,"f")))&&this.ctx.hasCapacity();){if(null==T(this,u,"f")){const e=T(this,l,"f").shift();null==e||(this.logger.trace("delegating to child dir, "+e),E(this,f,(t=T(this,f,"f"),++t),"f"),E(this,u,new s(e,this.ctx,this),"f"))}if(null!=T(this,u,"f")){const t=await T(this,u,"f").next(e);(t?.done??!0===T(this,u,"f")?.isDone())&&E(this,u,void 0,"f")}i=T(this,r,"m",w).call(this,e)}return i},_=async function(){if((0,x.isNotEmpty)(T(this,n,"f"))||(0,x.isNotEmpty)(T(this,l,"f"))||null!=T(this,u,"f"))return this.logger.error("maybeCompleteResult: not done (?!)",(0,O.pick)(this,"result","pendingChildren","childDelegate","pendingChildDirs")),t.Undone;if(!T(this,c,"f")){E(this,c,!0,"f");const e=await(0,K.mkFolderUrl)(this.dir.nativePath),t=e?.with({query:null}),i=t?.toString(),r=0===T(this,h,"f")?"":`${T(this,d,"f")}/${(0,B.plur)(T(this,h,"f"),"file")}`,s=0===T(this,m,"f")?"":`${T(this,f,"f")}/${(0,B.plur)(T(this,m,"f"),"directory","directories")}`,n=(0,F.mapNotBlank)((0,A.andList)([r,s]),(e=>"Accepted "+e))??"No files or directories found";(0,ee.syncReport)().onProgress({path:this.dir.nativePath+D.sep,state:ee.SyncDirStates.scanned,from:"DirectoryIterator",details:n,url:i,elapsedMs:Date.now()-this.start}),await this.ctx.directoryListener(this.dir)}return t.Done}},20197:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const s=r(i(76760)),n=i(39926),a=i(29882),o=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if(await(0,a.mkdirp_)(r.dir),!i.requireNumber&&await(0,o.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,o.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if((0,a.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},92423:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notInHiddenPhotoStructureDir=t.whyExcludedDirectoryRecursive=t.notExcludedDirs=t.isExcludedDirectory=t.whyExcludedDirectory=t.notExcludedDirPredicates=t.isExcludedFile=t.whyExcludedFile=t.notExcludedFilePredicates=t.excludeBundles=t.excludeGlobs=t.defaultFilePredicates=t.defaultDirPredicates=t.formatPathForGlob=void 0;const l=o(i(83058)),u=i(19851),c=i(40958),d=i(76790),h=i(22573),f=i(55835),m=i(51926),p=i(54993),g=i(48884),y=i(9092),w=i(54557),v=i(50213),b=i(88158),S=i(56519),P=i(46292),M=i(32551),_=i(35280),T=i(87290),E=i(96706),D=i(57902),k=i(43334),x=i(78984),F=i(33995),C=i(28874),A=i(21144),I=i(83278),O=i(48313),L=i(85772),R=i(78133),N=i(46356),B=i(17217),j=(0,u.lazy)((()=>(0,v.mkLogger)("fs.ExcludeGlobs"))),z=new w.FifoCache(256),V=/[\\/]$/;function W(e){const t=(0,p.toS)(e),i=z.get(t);if(null!=i)return i;const r=(0,B.isSimpleFile)(e)?e:I.BaseFile.for(e),s=V.test(t)||r.isDirectorySync(),n=(0,R.native2posix)(r.nativePath),a=s?(0,m.ensureSuffix)(n,"/"):n;return z.set(t,a),z.set(a,a),z.set(r.nativePath,a),a}t.formatPathForGlob=W;class U{constructor(e,t,i=!0){if(r.add(this),this.pattern=e,this.desc=t,this.exclude=i,e.includes("\\")){const t=e;e=(0,R.native2posix)(t),j().warn("globToPredicate(): backslash in patterns aren't supported: assuming you meant forward-slash?",{given:t,input:e})}this.reason=(0,c.compactBlanks)([this.exclude?"not":"",t,"("+(0,m.ellipsize)(e,48,12)+")"]).join(" ");try{this.re=l.default.makeRe(this.pattern,{nocase:C.Settings.globsCaseInsensitive.valueOrDefault,dot:!0,posixSlashes:!0}),this.valid=!0}catch(e){this.valid=!1,j().warn("Cannot parse pattern",{glob:this.pattern,error:e})}this.bundle=this.valid&&null!=this.re?(0,b.pairToObject)(this.reason,a(this,r,"m",s).bind(this)):{}}}r=new WeakSet,s=function(e){const t=W(e),i=this.re.test(t)??this.exclude;return j().tap({msg:"apply()",level:i?D.LogLevels.debug:D.LogLevels.trace,result:i?!this.exclude:this.exclude,meta:{desc:this.desc,pattern:this.pattern,exclude:this.exclude,posixPath:t,matched:i}})};class q{constructor(){n.set(this,[])}push(...e){for(const t of e){if(!t.valid){j().warn("Ignoring invalid glob",{glob:t});continue}const e=a(this,n,"f").find((e=>e.pattern===t.pattern));null==e?a(this,n,"f").push(t):j().debug("Ignoring duplicate glob",{glob:t,prior:e})}}pushNativePath(e,t){this.push(new U((0,R.native2posix)(e),t))}toA(){return a(this,n,"f")}}n=new WeakMap;const H=new U("**/.*","hidden file"),G=new U("**/.*/","hidden directory"),$=(0,u.lazy)((()=>{const e=new q;e.push(G,H);for(const t of[{s:"bin",desc:"command binary"},{s:"dev",desc:"device file"},{s:"etc",desc:"system configuration file"},{s:"initrd",desc:"initial ramdisk"},{s:"proc",desc:"process metadata"},{s:"sbin",desc:"system binary"},{s:"snap",desc:"snap software"},{s:"sys",desc:"system metadata"},{s:"Dell",desc:"Windows driver"},{s:"Drivers",desc:"Windows driver"},{s:"Intel",desc:"Windows driver"},{s:"Microsoft",desc:"Windows driver"},{s:"NVIDIA",desc:"Windows driver"},{s:"Windows.old",desc:"Windows system"},{s:"Windows",desc:"Windows system"}])e.push(new U((k.isWin?"*":"")+"/"+t.s+"/",t.desc));if(k.isWin)for(const t of["ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemRoot","windir"]){const i=(0,E.getEnv)(t);(0,h.blank)(i)||e.pushNativePath(i,`%${t}%`)}k.isLinux&&e.push(new U(`${(0,M.homeDir)()}/snap/`,"Snap software"));for(const t of[{s:"__MACOSX",desc:"macOS resource fork"},{s:"_includes",desc:"code"},{s:"@eaDir",desc:"Synology thumbnail"},{s:"@Recently-Snapshot",desc:"QNAP snapshot"},{s:"@Recycle",desc:"QNAP trash"},{s:"@SynoResource",desc:"Synology metadata"},{s:"#recycle",desc:"Synology trash"},{s:"#snapshot",desc:"Synology snapshot"},{s:"$Recycle.Bin",desc:"Windows trash"},{s:"$SysReset",desc:"Windows"},{s:"3rdParty",desc:"code"},{s:"Application Data",desc:"Windows apps"},{s:"Application Support",desc:"macOS apps"},{s:"Applications",desc:"macOS apps"},{s:"arangodb",desc:"3rd party"},{s:"cache",desc:"Cache directory"},{s:"CacheClip",desc:"Movie cache directory"},{s:"caches",desc:"Cache directory"},{s:"Chipset_Software",desc:"Windows apps"},{s:"cmake",desc:"code"},{s:"com.apple.TimeMachine.localsnapshots",desc:"macOS"},{s:"cpan",desc:"code"},{s:"DefinitelyTyped",desc:"TypeScript type"},{s:"Desktop DB",desc:"macOS metadata"},{s:"Desktop DF",desc:"macOS metadata"},{s:"Desktop.ini",desc:"macOS metadata"},{s:"DisplayDriver",desc:"Windows driver"},{s:"DLLs",desc:"Windows library"},{s:"dyld",desc:"macOS library"},{s:"ehthumbs.db",desc:"Windows thumbnail"},{s:"i18n",desc:"i18n code"},{s:"iMovie Cache",desc:"Apple iMovie cache"},{s:"iTunes Cache",desc:"Apple iTunes"},{s:"iTunes Media",desc:"Apple iTunes"},{s:"iTunes",desc:"Apple iTunes"},{s:"lib?(32|64|x64|s)",desc:"program library directory"},{s:"lost+found",desc:"fsck recovered directory"},{s:"macOS Install*",desc:"macOS installer"},{s:"Network Trash",desc:"AFP trash"},{s:"node_modules",desc:"Node.js library"},{s:"pkgconfig",desc:"code"},{s:"pkgs",desc:"Python code"},{s:"Program Files (x86)",desc:"Windows apps"},{s:"Program Files",desc:"Windows apps"},{s:"ProgramData",desc:"Windows application support"},{s:"resources/media/face",desc:"face thumbnail"},{s:"rubygems-*",desc:"Ruby code"},{s:"site-packages",desc:"Python code"},{s:"spotifycache",desc:"Spotify cache"},{s:"SteamApps",desc:"Game files"},{s:"System Volume Information",desc:"Windows system metadata"},{s:"System32",desc:"Windows system"},{s:"SystemTemp",desc:"Windows temporary"},{s:"temp",desc:"temporary"},{s:"Temporary Items",desc:"temporary"},{s:"test_suite",desc:"code"},{s:"testutil?(s)",desc:"code"},{s:"third_party",desc:"code"},{s:"Thumbnail?(s)",desc:"thumbnail"},{s:"Thumbs.db",desc:"Windows thumbnail"},{s:"tmp",desc:"temporary"},{s:"Trash",desc:"trash directory"},{s:"Windows",desc:"Windows"},{s:"Windows.old",desc:"Windows"},{s:"Windows10Upgrade",desc:"Windows upgrade"},{s:"Xcode.app",desc:"macOS code"},{s:"*.sparsebundle/bands",desc:"Time Machine backup"},{s:"ImageMagick*",desc:"ImageMagick source"},{s:"Install OS X*",desc:"macOS installer"},{s:"Install macOS*",desc:"macOS installer"},{s:"*.lrdata",desc:"LightRoom data"},{s:"MinGW*",desc:"code"},{s:"msys*",desc:"code"},{s:"vcpkg",desc:"code"}])e.push(new U("**/"+t.s+"/",t.desc));function t(t,i,r){if(!(0,h.blank)(t)){const s=(0,d.sort)((0,c.uniq)((0,c.compactBlanks)(i).map((e=>e.toLowerCase()))));1===s.length&&e.push(new U(`**/${t}/${s[0]}/`,r)),s.length>1&&e.push(new U(`**/${t}/(${s.join("|")})/`,r))}}(0,f.map)((0,P.configDir)(),(t=>e.pushNativePath(t,"PhotoStructure configuration"))),t("nix",["store"],"NixOS package"),e.push(new U("**/*.(photo|photos|ap)library/!(master|masters|modified|original|originals)/","Apple Photos/Aperture library")),e.push(new U("**/facetile*","face thumbnail"));const i=["bin","cygdrive","dev","etc","games","include","lib?(32|64|x64)","local","locale","man","proc","sbin","share","src","tmp","usr","var"];t("usr",i,"FHS system"),t("cygwin?(64)",i,"Cygwin"),t("local",i,"FHS system"),t("Windows",["assembly","Boot","Containers","Cursors","Fonts","Help","Installer","Logs","Microsoft.NET","Servicing","SoftwareDistribution","System32","SystemApps","SysWOW64","Temp","WinSxS"],"Windows"),t("Recovery",["Customizations","OEM"],"Windows"),t("lib",["firmware","modules","systemd","udev","x86_64-linux-gnu"],"Linux system package"),t("opt",["google","x11",...i],"FHS package"),t("lfs",["incomplete","objects"],"Git LFS object");const r=["cache","crash","games","lib","local","lock","log","logs","mail","run","snap","spool","tmp"];t("var",r,"Linux /var"),t("mnt",r,"Linux /mnt"),t("dev",["block","bsg","bus","char","cpu","disk","dri","fd","hugepages","input","lightnvm","mapper","mqueue","net","pts","shm","snd","ubuntu-vg","usb","vfio"],"Linux /dev backup"),t("proc",["acpi","asound","bus","driver","fs","ipmi","irq","net","scsi","self","sys","sysvipc","thread-self","tty"],"Linux /proc backup"),t("library",["Apple","Assistant","Bluetooth","com.apple.iTunesCloud","Containers","CoreAnalytics","Developer","Desktop Pictures","Documentation","Extensions","Finance","Fonts","Frameworks","FrontBoard","Group Containers","HTTPStorages","iTunes","KeyboardServices","Keychains","Logs","Messages","News","Passes","Photos","Preferences","Ruby","Saved Application State","Scripts","User Pictures","Updates","User Template","WebKit","WebServer"],"macOS Library"),t("packages",["*.pkg","*.mpkg"],"macOS package"),t("src/**",["bin","ci","dist","doc?(s)","etc","lib?(s)","main","spec?(s)","src","test?(s)","tools","util"],"code"),t("docs",["admin","content","general","generated","sql"],"code"),t("pkg",["acceptance","ccl","cli","cmd","server","sql","storage","ui","util","workload"],"code"),t("osv",["apps","arch","compiler","external","include","java","modules","musl","tests"],"code"),t("go",["bin","blog","cmd","doc","lib","misc","pkg","src","test","vt"],"code"),t("Perl?(64)",["bin","eg","etc","html","lib","site"],"code"),t("Python*",["dlls","doc?(s)","include","lib?(s)","scripts","tools","tcl"],"code"),t("Ruby*",["bin","include","lib","msys*","packages","share","ssl"],"code"),t("msys*",["clang*","dev","etc","mingw*","tmp","ucrt*","var"],"code"),t("sdk",["build-tools","emulator","extras","patcher","platforms","platform-tools","sources","tools"],"code"),t("test",["fixtures"],"code"),t("data",["$of"],"windows backup"),t("System",["Applications","Developer","DriverKit","Library","iOSSupport"],"macOS System"),t("contents",["frameworks","plugins","resources","sharedsupport"],"macOS application"),t("pg",["pgsql"],"code");for(const e of["local","locallow","roaming"])t("appdata",[e],"Windows default AppData");return t("ps",["cache","config","logs","tmp"],"PhotoStructure docker directory"),e.toA()})),J=()=>{t.excludeGlobs.unset(),t.excludeBundles.unset()},K=()=>{t.notExcludedDirs.unset()},Z=(0,u.lazy)((()=>{C.Settings.excludeGlobsOmitDefaults.watchLater(J),C.Settings.excludeGlobsAdd.watchLater(J),C.Settings.excludeGlobsOmit.watchLater(J),C.Settings.globsCaseInsensitive.watchLater(J),C.Settings.libraryDir.watchLater(K),C.Settings.originalsDir.watchLater(K),C.Settings.scanPaths.watchLater(K),C.Settings.argvScanPaths.watchLater(K)}));t.defaultDirPredicates=(0,u.lazy)((()=>[{notSymlinkLoop:re,notInHiddenPhotoStructureDir:ne,whyNoMedia:L.whyNoMedia,notHidden:se}])),t.defaultFilePredicates=(0,u.lazy)((()=>[{notInHiddenPhotoStructureDir:ne}])),t.excludeGlobs=(0,u.lazy)((()=>{Z();const e=new y.CaseInsensitiveMap;function t(t){if(null!=t&&t.valid){const i=t.pattern.trim();e.has(i)&&j().warn("Duplicate glob:",{glob:t}),e.set(i,t)}}function i(t){const i=t.trim();e.has(i)?e.delete(i):j().warn("Failed to find and remove glob specified in PS_EXCLUDE_GLOBS_OMIT",{glob:t})}if(!C.Settings.excludeGlobsOmitDefaults.valueOrDefault)for(const e of $())t(e);for(const e of C.Settings.excludeGlobsOmit.values)i(e);for(const e of C.Settings.excludeGlobsAdd.values)t(new U(e,"(from PS_EXCLUDED_GLOBS_ADD)"));const r=(0,d.sortBy)(e.values(),(e=>(0,c.compactBlanks)(e.pattern.toLowerCase().split("/")))),[s,n]=(0,g.partition)(r,(e=>e.pattern.endsWith("/")));return{dir:s,file:n}})),t.excludeBundles=(0,u.lazy)((()=>{const e=(0,t.excludeGlobs)();return{dir:[...(0,t.defaultDirPredicates)(),...e.dir.map((e=>e.bundle))],file:[...(0,t.defaultFilePredicates)(),...e.file.map((e=>e.bundle))]}}));const Y=[{disableAllFilters:()=>!0}],X=[{notBlank:()=>!1}];function Q(e){return C.Settings.disableAllFilters.valueOrDefault?Y:(0,h.blank)(e)?X:(0,t.excludeBundles)().file}function ee(e){return F.SyncPredicates.whyRejected(e,...Q(e))}function te(e){return C.Settings.disableAllFilters.valueOrDefault?Y:(0,h.blank)(e)?X:(0,t.excludeBundles)().dir}async function ie(e){return C.Settings.disableAllFilters.valueOrDefault?void 0:x.Predicates.whyRejected(e,...te(e))}function re(e){return!(0,N.seemsLikeSymlinkLoop)(e)}function se(e){return(0,S.thenNot)((0,O.isHidden)(e))}function ne(e){return!(0,_.inHiddenPhotoStructureDir)(e)}t.notExcludedFilePredicates=Q,t.whyExcludedFile=ee,t.isExcludedFile=function(e){return null!=ee(e)},t.notExcludedDirPredicates=te,t.whyExcludedDirectory=ie,t.isExcludedDirectory=async function(e){return null!=await ie(e)},t.notExcludedDirs=(0,u.lazy)((async()=>{const e=(0,c.uniq)((0,c.compactBlanks)([(0,T.libraryDirPosixFile)(),(0,T.libraryOriginalsDirPosixFile)(),...C.Settings.argvScanPaths.values,...C.Settings.scanPaths.values]));return j().tap({msg:"notExcludedDirs() (these directories will never be excluded)",level:"info",result:(0,c.uniq)([...e,...await Promise.all(e.map((e=>(0,A.actualPath)(e))))])})})),t.whyExcludedDirectoryRecursive=async function(e){const i=await(0,t.notExcludedDirs)();for(let t=e;null!=t&&!t.isRoot;t=await(t?.parent())){if(i.includes(t?.nativePath))return;const e=await ie(t);if(null!=e)return e}},t.notInHiddenPhotoStructureDir=ne},88561:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const a=i(40958),o=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class w extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>n(this,r,"m",s).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,a.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=w,r=new WeakSet,s=async function(e){if((0,o.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},79267:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCleanup=void 0;const c=i(19851),d=i(40958),h=i(42659),f=i(31586),m=i(71371),p=i(50213),g=i(7282),y=i(409),w=i(78406),v=i(25764),b=i(99331),S=i(91655),P=i(34102),M=i(89968),_=i(85772);class T{static for(e){return new T(e.name,e.rootNativePath,e.staleMs,e.isPrunable,e.minRetained)}constructor(e,t,i,a,d=0){r.add(this),this.name=e,this.rootNativePath=t,this.staleMs=i,this.isPrunable=a,this.minRetained=d,s.set(this,void 0),this.intervalMs=(0,c.lazy)((()=>(0,f.clamp)((0,g.isTest)()?0:5*h.minuteMs,h.dayMs,this.staleMs/2))),n.set(this,void 0),this.cleanup=(0,y.rateLimited)({name:this.name,minCallDelayMs:this.intervalMs()/4,f:()=>u(this,r,"m",o).call(this)}),l(this,s,(0,p.mkLogger)("fs.FileCleanup("+e+")"),"f")}scheduleInterval(){return(null==u(this,n,"f")||u(this,n,"f").ended)&&l(this,n,new w.EndableInterval({name:this.name,callback:()=>this.cleanup(),intervalMs:this.intervalMs(),rank:v.EndableRanks.first}),"f"),u(this,n,"f")}cancelInterval(){u(this,n,"f")?.end(),l(this,n,void 0,"f")}}t.FileCleanup=T,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(e){if(!(0,f.gt0)(this.minRetained))return new Set;const t=new m.BoundedGreatestSet(this.minRetained??0,(e=>e.mtimeMs()));return await e.visitDescendants((e=>{e.isFile()&&t.add(e)})),new Set(t.vacuum().map((e=>e.nativePath)))},o=async function(){try{if((0,b.ending)())return;const e=await this.rootNativePath();if(null==e)return[];const t=await M.DirectoryEntry.for(e);if(null==t)return[];u(this,s,"f").info("cleanup(): starting",{root:t,staleMs:(0,S.fmtFullDuration)(this.staleMs," ")});const i=await u(this,r,"m",a).call(this,t),n=Date.now()-this.staleMs,o=new Set,l=[],c=[];await t.clear().visitDescendants((async e=>{if((e.dir!==t.nativePath||!(0,_.isNoMediaName)(e.base))&&!i.has(e.nativePath)&&(o.has(e.nativePath)||!(0,f.gte)(e.mtimeMs(),n)))if(e.isDirectory())try{await e.rmdir_(),c.push(e.nativePath),o.add(e.dir)}catch(t){"ENOENT"===t.code&&(u(this,s,"f").warn("cleanup(): ENOENT "+e,t),(0,P.ee)().emit("clearCache")),"ENOTEMPTY"!==t.code&&u(this,s,"f").warn("cleanup(): failed to rmdir "+e,t)}else if(!1!==await(this.isPrunable?.(e)))try{await e.unlink_(),l.push(e.nativePath),o.add(e.dir)}catch(t){u(this,s,"f").warn("cleanup(): failed to clean up tmpfile "+e,t)}}));const h=[...l,...c];return(0,d.isNotEmpty)(h)&&t.clear(),u(this,s,"f").info("cleanup(): done",{root:t,pruned_file_count:l.length,pruned_dir_count:c.length}),h}catch(e){return void u(this,s,"f").error("cleanup() failed",{error:e})}}},32144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),s=i(22573),n=i(45599),a=i(96249),o=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,n.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,s.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,a.flatten)((0,o.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),s=i(17217),n=i(16287),a=i(68284);async function o(e){return(0,r.pick)(await(0,n.stat_)((0,s.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=o,t.fileStats=async function(e){try{return await o(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,a.statSync)((0,s.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const r=i(68817),s=i(19851),n=i(22573),a=i(50213),o=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),h=i(95696),f=i(93854),m=i(16287),p=(0,s.lazy)((()=>(0,a.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,f.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,r.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const s=(0,n.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),a=(0,l.normalizeExt)(h.PosixFile.for(e))??(0,c.mimetypeExt)(s);return(0,n.blank)(s)||(0,n.blank)(a)?void 0:{ext:a,mime:s}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new o.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,s.set(this,[]),n.set(this,void 0),a.set(this,void 0),l(this,a,(0,f.fileStatsSync)(e),"f"),l(this,n,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",o).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,s,"f").push(e)}close(){u(this,n,"f").close()}}t.FileWatcher=m,s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,a,"f"),t)){l(this,a,t,"f");for(const t of u(this,s,"f"))t(e,this.nativePath)}}},13829:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withFsAdvisoryLocks_=t.defaultFsAdvisoryLockDir=void 0;const r=i(55835),s=i(13538),n=i(81168),a=i(37628),o=i(46292),l=i(73209),u=i(95696);function c(){return(0,r.map)((0,o.configDir)(),(e=>u.PosixFile.for(e).join("advisory-locks")))}t.defaultFsAdvisoryLockDir=c,t.withFsAdvisoryLocks_=async function({name:e,lockNames:t,f:i,timeoutMs:r,lockDir:o=c()}){if(null==o)return i();await o.mkdirp_();const u=(0,n.sortIgnoreCase)(t).map((e=>l.FsLock.for({name:e,file:o.join((0,a.shortFsStringSha)(e)),timeoutMs:r})));try{for(const t of u)if(!0!==await(0,s.thenOrTimeout)(t.acquire_(),r))throw new Error("Failed to acquire lock for "+e+": "+t.opts.name+" was busy");return await i()}finally{for(const e of u)e.release()}}},73209:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,w,v,b=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},S=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const M=i(58587),_=P(i(44652)),T=i(87997),E=i(40958),D=i(17586),k=i(42659),x=i(50357),F=i(75240),C=i(55835),A=i(31586),I=i(30976),O=i(13538),L=i(54993),R=i(7282),N=i(68852),B=i(23560),j=i(25764),z=i(38836),V=i(99331),W=i(22781),U=i(38835),q=i(55222),H=i(63870),G=i(69734),$=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)(G.PsLockExt)+"$");class K extends z.EndableWrapper{static newUid(e=process.pid){return S(this,s,Math.max(Date.now(),b(this,s,"f",n)+1),"f",n),(0,E.compactBlanks)([q.TokenRadix.encode(b(this,s,"f",n)),B.serviceName.prior(),(0,L.toS)(e)]).join("-")}static pidFromLockfile(e){return s.pidFromBasename((0,$.basename)(e))}static pidFromBasename(e){return(0,A.toInt)(J.exec((0,L.toS)(e))?.groups?.pid)}static for(e){return b(this,s,"f",o).find((t=>t.opts.file===e.file))??new s(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>b(this,r,"m",v).call(this)),e.endableRank??j.EndableRanks.postdb,(0,H.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,S(t=s,s,(i=b(t,s,"f",a),++i),"f",a)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(b(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,G.fsLockFileBasename)(s.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await b(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,G.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+b(this,l,"f")),this.staleMs=(0,A.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),b(s,s,"f",o).push(this)}get acquired(){return b(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await b(this,r,"m",f).call(this,e)??b(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,D.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,x.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==b(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:k.secondMs);S(this,c,setInterval((()=>b(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=b(this,c,"f")&&(clearInterval(b(this,c,"f")),S(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(b(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),S(this,u,!1,"f"),(0,C.map)(b(this,d,"f"),(e=>(0,T.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?b(this,r,"m",w).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),S(this,d,setTimeout((()=>b(this,r,"m",w).call(this)),(0,A.toGt0)(this.staleMs)??k.secondMs),"f"),b(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(b(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,O.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,s=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,r=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,A.gt0)(this.staleMs)&&Date.now()>b(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await b(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){S(this,h,Date.now(),"f");const e=[],t=await b(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,A.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+k.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,G.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;s.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const n=i[0]===this.lockfile.base;if(n)S(this,u,!0,"f");else if(!0!==t?.vacuum){const t=s.pidFromBasename(i[0]);if((0,A.gt0)(t)&&!(0,M.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),b(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:n,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await b(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},w=async function(){await b(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},v=function(){(0,E.filterInPlace)(b(s,s,"f",o),(e=>b(e,l,"f")!==b(this,l,"f")))},n={value:0},K.internalErrors=0,a={value:0},o={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),s=i(51926),n=i(54993),a=i(17217);function o(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,s.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,s.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,n.toS)(e)))return;const i=(0,a.basename)(e);return o(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&o((0,a.basename)(e))}},4001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),s=i(55835),n=i(31586),a=i(51926),o=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,r.toNotBlank)(e.name)??(0,o.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,n.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:f(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const s=(0,u.parsePosixPath)(i),n=h(s,{aggressive:!1});return[...t,n+s.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,a.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),r=(0,a.stripPrefix)(t.toLowerCase().normalize(),i);return(0,s.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,a.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,s.map)(m.exec(t),(e=>t=e[1].trim())),(0,s.map)(g.exec(t),(e=>t=e[1].trim())),t}},19254:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fileGrep_=t.GrepReader=void 0;const s=r(i(73024)),n=i(57075),a=i(46466),o=i(54993),l=i(33456),u=i(17217),c=i(58722);class d extends n.Transform{constructor(e,t="\n"){super({objectMode:!1,autoDestroy:!0}),this.pattern=e,this.sep=t}_transform(e,t,i){const r=(0,o.toS)(e).match(this.pattern);null!=r&&this.push(r[1]??r[0]+this.sep),i()}}t.GrepReader=d,t.fileGrep_=async function(e,t){const i=new c.WritableToBuffer;return await(0,a.pipeline)([s.default.createReadStream((0,u.toNativePath_)(e)),new l.LineReader,new d(t),i]),(await i.buffer).toString()}},14977:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const s=r(i(44652)),n=r(i(73024)),a=i(46466),o=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,a.pipeline)(n.default.createReadStream(e,{autoClose:!0}),o.default.createGzip(),n.default.createWriteStream(t,{autoClose:!0})),await s.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const s=r(i(77598)),n=r(i(73024)),a=i(46466),o=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),w=i(16287),v=(0,o.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),b=(0,o.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function S(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=b().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return v().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;v().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),b().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await M(n.default.createReadStream(i)),stats:(0,u.pick)(await(0,w.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function M(e,t=[],i="sha512"){const r=s.default.createHash(i);return await(0,a.pipeline)([e,...t,r]),r.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:b,impl:P}),t.fileShaMeta_=S,t.fileSha_=async function(e){return(await S(e)).sha},t.uncachedFileSha_=P,t.streamSha_=M,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return s.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),s=i(42659),n=i(55835),a=i(31586),o=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,o.stdout_)("chflags",["hidden",t],{timeoutMs:10*s.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,n.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,o.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*s.secondMs}),i=(0,a.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),s=i(54993),n=i(7282),a=i(43334),o=i(69375),l=/^\/dev(?:\/|$)/i,u=a.isMac||(0,n.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=a.isMac||(0,n.isTest)()?/^\/private\//i:void 0,d=a.isMac||(0,n.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=a.isMac||(0,n.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,s.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,o.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},87128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonFileStore=void 0;const r=i(19851),s=i(55835),n=i(57159),a=i(50213);t.JsonFileStore=class{constructor(e,t,i){this.file=e,this.mkObject=t,this.onWrite=i,this.prior=(0,r.lazy)((()=>this.file.readJson("debug")))}async read_(){return await this.prior()??(0,s.map)(await this.mkObject(),(e=>this.write_(e)))}async write_(e){try{return await this.file.writeJson_(e,{spaces:2}),this.prior.set(Promise.resolve(e)),(0,a.mkLogger)("fs.JsonFileStore").info("wrote to "+this.file,e),null!=this.onWrite&&await this.onWrite(this.file,e),e}catch(e){throw new n.WrappedError("Failed to write to "+this.file,{cause:e,path:this.file.nativePath})}}}},33456:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),s=i(51926),n=i(54993);class a extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,n.toS)(e)).split((0,s.newlineRe)()),a=r.pop();this._prior=a??"";let o=!1;for(const e of r)o||(o=!this.push(e));o?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=a},64680:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const s=r(i(76760)),n=i(17217),a=i(73428);t.mkNoMedia_=function(e){return(0,a.writeTextfile_)(s.default.join((0,n.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},61704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nativePathsEql=t.nativePathsEqlSync=void 0;const r=i(21144),s=i(17217);t.nativePathsEqlSync=function(e,t){if(null==e||null==t)return!1;if(e===t)return!0;try{const i=(0,s.toNativePath_)(e),r=(0,s.toNativePath_)(t);return null!=i&&null!=r&&i===r}catch{return!1}},t.nativePathsEql=async function(e,t){try{return null!=e&&null!=t&&await(0,r.actualPath_)((0,s.toNativePath_)(e))===await(0,r.actualPath_)((0,s.toNativePath_)(t))}catch{return!1}}},85772:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const a=n(i(76760)),o=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),w=i(83278),v=i(70698),b=i(88561),S=i(65238),P=i(16287),M=(0,o.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),_="NoMedia",T=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(a.default.sep),"/"]).join("")+"])\\.?"+_+"$","im"),E=Object.freeze(["."+_,_]),D=Object.freeze((0,u.flatten)(E.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function k(e){return null!=T.exec(e)}t.isNoMediaName=k;const x=(0,o.lazy)((()=>new b.FileCache({name:"fs.noMediaDirsCache"})));async function F(e,t){if(null==e)return null;const i=w.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return k(i.base)||await(0,v.isCachedirTagFile)(i)?x().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):F(i.parent());{const e=await x().getOrSetAsync(i.nativePath,(()=>C(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:F(i.parent())}}async function C(e){if(k(e.base))return x().set(e.parent().nativePath,e.nativePath),M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,S.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,r=await Promise.race([A(e.nativePath,i),(0,S.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,v.isCachedirTagDirectory)(e)?M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(v.CACHEDIR_TAG).nativePath)}):null}async function A(e,t){for(const i of g.isCaseSensitiveFs?D:E){if(!0===t?.aborted)return null;const r=a.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return M().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function I(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(k(r.basename))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,a.join)(e,r.basename))});if(r.basename===v.CACHEDIR_TAG){const t=(0,a.join)(e,r.basename);if(await(0,v.isCachedirTagFile)(t))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await F(e,t)},t.whyNoMedia=F,t.whyNoMediaDir=C,t._dirHasNoMediaChild=A},29882:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),w=i(78133),v=i(53265),b=i(17217),S=i(16287),P=i(66430),M=i(5545);function _(e){return((0,b.isSimpleFile)(e)?e.base:n.default.basename(n.default.resolve(e))).startsWith(".")}t.logger=(0,a.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=_,t.containsHiddenPathname=function(e){return F(e).some(_)},t.isNotHiddenPosixPath=function(e){return F(e).every((e=>!_(e)))},t.resolveSimpleFile=function(e){return(0,b.isSimpleFile)(e)?e.nativePath:(0,v.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,v.resolve)(...e)},t.parsePosixPath=function(e){return E((0,w.posix2native)(e))},t.extname=function(e){return E(e).ext},t.dirname=function(e){return n.default.dirname((0,b.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(n.default.parse(e).ext,n.default.parse(t).ext)};const T=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function E(e){const t=T.exec(e)?.groups,i=t?.ext2??"",r=n.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function D(e){const t=n.default.parse((0,b.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,n.default.sep)}function k(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,b.toNativePath_)(e.ancestor),i=(0,b.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,n.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function x(e,t,i){if(null==t||null==i)return!1;const r=e(t),s=e(i);return null!=r&&null!=s&&(y.isLinux?r===s:(0,p.equalsIgnoreCase)(r,s))}function F(e){return(0,b.isSimpleFile)(e)?e.pathnames:e.split(n.default.sep).filter((e=>null!=e&&""!==e))}function C(e){return(0,u.notBlank)(e)&&F(e).length===(y.isWin?1:0)}function A({p:e,maxLength:t}){const i=(0,b.toNativePath_)(e);if(i.length<=t)return i;const r=F(e),s=[],n=[r.pop()];for(;r.length>0;)if(s.length=t){r.unshift(s.pop());break}}else if(n.unshift(r.pop()),O([...s,...n]).length>=t){r.push(n.shift());break}return r.length>0&&s.push("…"),O([...s,...n])}function I(e){return e.startsWith("\\\\")}function O(e){return(0,h.ensurePrefix)((0,o.compactBlanks)(e).join(n.default.sep),y.isWin?"":n.default.sep)}t.parseNativePath=E,t.parentBasename=D,t.grandParentBasename=function(e){return D(n.default.parse((0,b.toNativePath_)(e)).dir)},t.containedByNativePath=k,t.eqlBasename=function(e,t){return x(b.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return x(b.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return x(b.toNativePath_,e,t)},t.toPathnames=F,t.pathIsRoot=C,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:F(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,b.toNativePath_)(e),r=(0,b.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,w.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,w.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=A,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const s=[];for(const r of e.slice(0,i))s.push(A({p:r,maxLength:t}));return s.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return F(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return F(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=E(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(M.driveRe))},t.mkdirp_=async function(e){try{if(await(0,S.isReadableDirectory)(e))return;if(C(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await s.default.mkdirp(e)}catch(t){if(await(0,S.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;s.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>s.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,b.toNativePath_)(e).split(n.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=O,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:O(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>k({ancestor:t,descendant:e,acceptSelf:!0})?[(0,b.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),w=i(64660),v=i(21144),b=i(16287),S=(0,n.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function M(e,t=P){const i=await(0,b.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,w.isStatRX)(i,e)}function _(){if(y.isWin){const e=(0,o.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,o.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,o.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,s.default.join(e,"System32"),s.default.join(e,"System32","Wbem"),s.default.join(i,"chocolatey","bin"),s.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function T(){const e=(0,h.toS)((0,m.env)().PATH).split(s.default.delimiter);return(0,a.uniq)((0,a.compactBlanks)([...e,..._()]))}t.isRXFile=M,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,a.uniq)((0,a.compactBlanks)([...T(),...(0,d.toA)(i)]));for(const i of(0,a.uniq)((0,a.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=s.default.join(t,e);if(await M(i))return y.isLinux?i:(0,v.actualPath)(i)}}S().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,w.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){"use strict";var r,s,n,a=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return o(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),w=i(76790),v=i(5233),b=i(22573),S=i(42659),P=i(26905),M=i(75240),_=i(55835),T=i(31586),E=i(68708),D=i(13538),k=i(89937),x=i(12168),F=i(54993),C=i(48884),A=i(50213),I=i(45255),O=i(81168),L=i(56519),R=i(56038),N=i(31562),B=i(84777),j=i(9595),z=i(38835),V=i(70025),W=i(57902),U=i(55222),q=i(43334),H=i(33847),G=i(24399),$=i(28874),J=i(79915),K=i(45200),Z=i(34238),Y=i(87001),X=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),se=i(73209),ne=i(48313),ae=i(29882),oe=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,C.contextFilter)(function(e){return(0,w.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,A.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Z.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,L.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,L.thenMapOr)((0,X.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>q.isMac?(0,B.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,b.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,b.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,O.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,oe.toNativePath_)(e),r=new fe(i,t);return(0,O.isString)(e)&&he().set(e,r),he().set(i,r),r}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,L.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,ae.containedByNativePath)({ancestor:(0,j.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,ae.containedByNativePath)({ancestor:(0,j.originalsDir)(),descendant:this,acceptSelf:!0}))return q.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,_.map)((0,ee.bestMountpoint)(this.nativePath,await(0,X.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,_.map)((0,b.notBlankOr)(e,(()=>this.uri_())),Z.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,F.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===k.PS_LIBRARY_SCHEME?1:t.scheme===k.PS_LOCAL_FILE_SCHEME?2:t.scheme===k.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,O.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(q.isWin||q.isMac)return this.trap("hide",(async()=>(await(0,ne.hide_)(this),this)))}async hidden(){return(0,ne.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,O.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,C.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,_.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,E.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:s,skipWip:n=!1,skipFsLock:a=!1,retries:o=2,dirty:l=!1}){return(0,v.retryOnReject_)((async()=>{const o=await this.clear().isNonEmptyFile(i);if(!o){if(n&&a)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:a,minSizeBytes:i,timeoutMs:s,dirty:l})}return o&&r?void 0:this.utimes()}),{maxRetries:o,timeoutMs:2*s,retryDelay:3*S.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,T.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:s,dirty:n=!1}){return await this.parent().mkdirp_(),(0,se.withLock_)({file:this,skipFsLock:r,timeoutMs:s,dirty:n},(async()=>{const r=this.wip();try{await r.unlink("trace");const n=await(0,D.thenOrTimeoutError)(e(r),s);if(n===t.NoOp)return n;if(await(0,N.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),n;throw new Error(this+"applyWip(): still empty after waiting "+(0,M.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==$.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",s).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",n).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();$.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:S.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,T.clamp)(I.ShortCommandTimeoutMs,10*S.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,b.notBlank)(this.ext)&&(0,b.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,S.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,_.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,L.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,O.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,ae.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,ae.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,Y.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,r=new WeakSet,s=async function(e){let t,i=e;const r=e.wip();try{const s=await this.stat_();if(null==s)return this.pflog().throw("Can't copy missing files"+z.NonRetriableErrorFlag);if(s.size>0){if($.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+z.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,r.nativePath,h.default.constants.COPYFILE_FICLONE),s.size>5*x.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},s.size,(()=>r.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,T.approximates)(s.size,await r.size({refresh:!0}))),{intervalMs:S.secondMs,timeoutMs:S.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:s.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:s.birthtimeMs,mtimeMs:s.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,s.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${s.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,_.map)(t,(e=>e.end()))}},n=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),s=r?.size;return null==r||null==s?this.pflog().throw("Can't copy missing files"):(s>5*x.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},s,(()=>e.clear().size()))),q.isWin?await G.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,G.pwshQuote)(this.nativePath)} -Destination ${(0,G.pwshQuote)(i.nativePath)}`,(e=>e)):q.isMac?await(0,B.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,B.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+z.DoNotSendErrorFlag,{error:t})}finally{(0,_.map)(t,(e=>e.end()))}}},62105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.acceptFile=t.whyRejectFile=t.expensiveFileFiltersFor=t.acceptParentAndFileAndSimple=t.acceptFileSimple=t.whyRejectFileSimple=t.simpleFileFiltersFor=t.notFileTooBig=t.notFileTooSmall=t.notFileMissing=t.hasBrowserImgMimeType=t.notDimensionsTooSmall=t.requiredTagsFilter=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(54993),o=i(48884),l=i(56519),u=i(78984),c=i(28874),d=i(43207),h=i(47783),f=i(97573),m=i(16170),p=i(54979),g=i(1078),y=i(42231),w=i(83278),v=i(19748),b=i(92423),S=i(16287);function P(e){return async t=>(0,l.thenMapOr)((0,h.readRawTags)(t,!1),e,(()=>!1))}async function M(e){if(!(0,n.gt0)(c.Settings.minVideoDimension.valueOrDefault)&&!(0,n.gt0)(c.Settings.minImageDimension.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);if(null==t||!t.startsWith("image/")&&!t.startsWith("video/"))return!1;const i=t.startsWith("video/")?c.Settings.minVideoDimension.valueOrDefault:c.Settings.minImageDimension.valueOrDefault;return(0,n.gt0)(i)?(0,l.thenMapOr)((0,g.extractSizeInfoFromFile)(e),(e=>(0,n.gte)(e.ImageWidth,i)&&(0,n.gte)(e.ImageHeight,i)),(()=>!1)):null}async function _(e){if(!(0,n.gt0)(c.Settings.minVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.gte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.minVideoDurationSec.valueOrDefault):null)}async function T(e){if(!(0,n.gt0)(c.Settings.maxVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.lte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.maxVideoDurationSec.valueOrDefault):null)}async function E(e){return!(0,s.blank)(await(0,p.readMimeType)(e))}async function D(e){if(-100===c.Settings.rejectRatingsLessThan.valueOrDefault)return null;const t=await(0,h.readTags)(e),i=(0,n.toInt)(t?.Rating);return null==i||i>=c.Settings.rejectRatingsLessThan.valueOrDefault}async function k(e){return 0===c.Settings.keywordBlocklist.values.length?null:(0,f.rawTagKeywords)(await(0,h.readTags)(e)).every((e=>!0!==(0,y.leafIsExcluded)(e,c.Settings.keywordBlocklist.values)))}async function x(e){if(!c.Settings.requireMakeModel.valueOrDefault)return null;const t=await(0,h.readRawTags)(e);return null==t||(0,s.blank)(t.MIMEType)?null:t.MIMEType.startsWith("image/")?null!=t&&(0,s.notBlank)(t.Make)&&(0,s.notBlank)(t.Model):null}async function F(e){return(0,w.isBaseFile)(e)?e.exists():(0,S.exists)(e.nativePath)}async function C(e){const t=c.Settings.minAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.gte)(i,t)}async function A(e){const t=c.Settings.maxAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.lte)(i,t)}function I(e){return[{isSupportedFileExtension:v.isAssetFileExtension},...(0,b.notExcludedFilePredicates)(e),{notFileMissing:F},{notFileTooSmall:C,notFileTooBig:A}]}function O(e){return[...I(e),{notMissingMimeType:E},{supportedMimeType:m.isAssetFileMimeType},{notMissingMakeAndModelTags:x},{notDimensionsTooSmall:M},{notVideoTooShort:_},{notVideoTooLong:T},{notRejectedRating:D},{notExcludedKeyword:k}]}async function L(e,t){return await u.Predicates.whyRejected(e,...t??O(e))??await(0,b.whyExcludedDirectoryRecursive)(e.parent())}t.requiredTagsFilter=function(e){return P((t=>(0,o.allNotBlank)(...e.map((e=>t[e])))))},t.notDimensionsTooSmall=M,t.hasBrowserImgMimeType=P((e=>(0,r.includes)(["image/jpeg","image/png"],(0,a.toS)(e.MIMEType)))),t.notFileMissing=F,t.notFileTooSmall=C,t.notFileTooBig=A,t.simpleFileFiltersFor=I,t.whyRejectFileSimple=function(e){return u.Predicates.whyRejected(e,...I(e))},t.acceptFileSimple=function(e){return u.Predicates.accepted(e,...I(e))},t.acceptParentAndFileAndSimple=async function(e){const t=await e.parent();return null!=t&&!await(0,b.isExcludedDirectory)(t)&&await u.Predicates.accepted(e,...I(e))},t.expensiveFileFiltersFor=O,t.whyRejectFile=L,t.acceptFile=async function(e){return null==await L(e)}},78133:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const s=r(i(76760)),n=i(22573),a=i(81168);t.posix2native=function(e,t){if((0,n.blank)(e))return e;if(s.default.sep===s.default.posix.sep)return e;const i=(0,n.notBlank)(t)?s.default.sep+s.default.sep+t+s.default.sep:"",r=e.split(s.default.posix.sep);return(0,a.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(s.default.sep)},t.native2posix=function(e){return(0,n.blank)(e)||s.default.sep===s.default.posix.sep||s.default.posix.sep===s.default.sep?e:e.split(s.default.sep).join(s.default.posix.sep)}},43899:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,a.lazy)((()=>s.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,a.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(s.default.join((0,p.execDir)(),"resources"),s.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,o.compactBlanks)([(0,p.execDir)(),n.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const r=s.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),s=i(19851),n=i(31586),a=i(50213),o=i(57902),l=i(69428),u=(0,s.lazy)((()=>(0,a.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=o.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,n.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),s=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let n=-1;try{const s=i??(await(0,r.stat)(e)).size-t,a=Buffer.alloc(s);return n=await(0,r.open)(e,"r"),await(0,r.read)(n,a,0,s,t)}finally{(0,s.mapGte0)(n,r.close)}}},69428:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const a=n(i(73024));t.readFileSync=function(e){try{return a.readFileSync(e)}catch{}}},55690:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),s=i(84542);t.readLines_=async function(e){return(0,s.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class s extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=s},65238:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const s=r(i(51455)),n=i(76760),a=i(19851),o=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),w=i(28874),v=i(63870),b=i(88561),S=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,a.lazy)((()=>(0,n.join)(w.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,a.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function M(){try{await s.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=M;const _=(0,a.lazy)((()=>new b.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,v.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function T(e){(0,l.blank)(e)||_.prior()?.delete(e)}async function E(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await _().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,S.statTimeoutMs)(),r=D(e),s=await(0,h.thenOrTimeout)(r,(0,d.toGt0)(w.Settings.fsCacheSlowMs.valueOrDefault)??(0,S.statTimeoutMs)());if(s===f.Timeout&&(0,g.onTimeout)({soft:!1}),s!==f.Timeout&&s.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=T,(0,c.later)((()=>{w.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),_.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),M()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?M():T(e)))})),t.slowDirs=(0,a.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!_().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){T(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=_().get(e)},t.childDirectories_=async function(e){return(await E(e)).filter((e=>e.isDirectory)).map((t=>(0,n.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(w.Settings.readdirCacheMs.valueOrDefault)?E(e):D(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=E,t.readdirCached=function(e){return _().get(e)},t.readdirUncached_=D},53265:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const s=i(73024),n=r(i(76760)),a=i(40958),o=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,a.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=n.default.resolve(t,...e);if((0,s.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,o.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(o.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??n.default.resolve(...e))},t.execDir=(0,l.defer)((()=>n.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},46356:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.seemsLikeSymlinkLoop=void 0;const r=i(22454),s=i(28874),n=i(29882);t.seemsLikeSymlinkLoop=function(e){const t=new r.CountingSet;for(const i of(0,n.toPathnames)(e))t.incr(i.toLowerCase().normalize());return t.max()>s.Settings.maxDuplicatePathElements.valueOrDefault}},50274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),s=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,s.isBoolean)(e.isFile)&&(0,s.isBoolean)(e.isDirectory)}},17217:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const s=r(i(73024)),n=r(i(76760)),a=i(22573),o=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,a.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,a.blank)(e.nativePath))throw new Error(`toNativePath(${(0,o.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof s.default.Dirent?e.name:f(e)?e.base:n.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:n.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(n.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function w(e){return(0,o.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(s.default.stat(e),(0,g.statTimeoutMs)(),!0)}function v(e,t=f.LogLevels.debug){return(0,o.blank)(e)?void 0:w(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function b(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function S(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=b(e),r=b(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],s=t[i],n=(0,u.diff)(S(r),S(s));if(null==n||n>1)return"unmatched "+i+": "+r+" ≠ "+s}}t.stat_=w,t.statMaybe=v,t.statToType=b,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await v(e,t)},t.isEmptyFile=async function(e,t){const i=await v(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await v(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await v(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await v(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await v(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await v(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await v(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,a.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const s=r(i(73024)),n=i(22573);function a(e){try{return(0,n.blank)(e)?void 0:s.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function o(e){return null==e||e.isFile()&&0===e.size}t.statSync=a,t.isEmptyStats=o,t.isFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=a(e);return t.emptyIsNew?null==i:o(i)},t.isNonEmptyFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===a(e)?.isDirectory()}},41080:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),s=i(56409);t.onDataChunked=function(e,t,i){const r=new n(t,i,!0);return r.read(e),r.done};class n{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new s.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=n},95705:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const s=r(i(57075)),n=i(41400),a=i(55835),o=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends s.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,n.delay)(50);try{(0,o.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,a.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends s.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const s=r(i(73024)),n=i(76760),a=i(22573),o=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,a.blank)(e))return!1;try{return s.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,o.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,a.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,a.notBlank)(t)){const e=(0,n.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,a.blank)(e)&&d((0,u.posix2native)(e))}},74128:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncReport=t.syncReport=t.recentSyncReports=t.ensureSyncReportReadme=t.syncReportReadme=t.syncReportDir=t.SyncReportHeaders=t.isRejectedState=t.SyncReportStates=t.SyncDirStates=t.FileDoneStates=t.SyncFileStates=t.AssetFileSyncStates=void 0;const p=i(51168),g=i(73024),y=i(4927),w=i(19851),v=i(40958),b=i(22573),S=i(42659),P=i(98553),M=i(31586),_=i(68708),T=i(50989),E=i(51926),D=i(85556),k=i(54993),x=i(89788),F=i(23467),C=i(7282),A=i(23560),I=i(77377),O=i(71567),L=i(73568),R=i(25764),N=i(38836),B=i(99331),j=i(12959),z=i(87290),V=i(46296),W=i(98314),U=i(38835),q=i(5012),H=i(32144),G=i(95696),$=i(36868),J=i(57902),K=i(28874),Z=i(84542),Y=i(73428);t.AssetFileSyncStates=(0,T.strEnum)("noop","deleted","skipped","synced","unknown"),t.SyncFileStates=(0,T.strEnum)(...t.AssetFileSyncStates.values,"canceled","rejected","failed","timeout","enqueued","started","copied","blocklisted","note"),t.FileDoneStates=(0,I.diff)(t.SyncFileStates.values,["enqueued","started","note"]),t.SyncDirStates=(0,T.strEnum)("scanning","canceled","failed","timeout","skipped","scanned"),t.SyncReportStates=(0,T.strEnum)(...t.SyncFileStates.values,...t.SyncDirStates.values),t.isRejectedState=function(e){return null==e||["canceled","deleted","failed","rejected","timeout","unknown"].includes(e)};const X={enqueued:"the file looks promising, and will be attempted to be imported soon.",rejected:"the file did not pass all import filters. The details column will explain why.",started:"the file was dequeued from the work queue, and is now going to be processed.",noop:"the current file metadata already matches your library database, so no operation was needed to sync this file.",deleted:"the file was determined to be deleted (the prior mountpoint exists, but the file doesn't exist anymore)",skipped:"the file lives on a volume that isn't currently mounted.",synced:"the file was imported.",blocklisted:"the file was blocklisted and files with the same SHA will not be imported in the future.",failed:"something went wrong. The details column will explain why.",timeout:"the file wasn't processed in a reasonable amount of time.",copied:'"automatic organization" is enabled (copyAssetsToLibrary=true), and the photo or video was copied into your library originals directory. The details column will contain the source file path.',note:"sidecars will be referenced here. The details column will specify which source file(s) it will be associated with.",canceled:"PhotoStructure was shut down while the file was processed.",unknown:"an internal error occurred during processing."},Q={scanning:"the directory contents are about to be read.",scanned:"the directory contents were completely processed.",skipped:"the directory was excluded. The details column will explain why.",canceled:"PhotoStructure was shut down before the directory was processed.",failed:"reading the directory contents failed.",timeout:"reading the directory contents took too long."};function ee(e){return(0,_.entries)(e).map((([e,t])=>` - "${e}": ${t}`)).join("\n")}const te=new Set([t.AssetFileSyncStates.deleted,t.SyncFileStates.failed,t.SyncFileStates.timeout,t.SyncDirStates.canceled]);function ie(){return(0,z.librarySyncReportsDir)()??G.PosixFile.for((0,V.logDir)()).join("sync-reports")}function re(){return ie().join("README.txt")}t.SyncReportHeaders=(0,T.strEnum)(...(0,_.keys)(new class{constructor(e,t,i,r,s,n,a,o,l={}){this.ts=e,this.at=t,this.path=i,this.state=r,this.from=s,this.elapsedMs=n,this.details=a,this.url=o,this.meta=l}}(0,"","","unknown","",0,"",""))),t.syncReportDir=ie,t.syncReportReadme=re,t.ensureSyncReportReadme=(0,w.lazy)((()=>(0,Y.writeTextfile_)(re().nativePath,(0,E.wrap)(`\n\nHowdy from PhotoStructure!\n\nThis directory contains your recent "sync reports". \n\nThese files are written as your scan paths are examined for photos and videos.\n\nPhotoStructure creates a new file when it restarts and when it completes importing a given scan path directory.\n\nThese CSV files can be opened with most spreadsheet applications, like LibreOffice.\n\n\nColumn descriptions\n===================\n\nThe "ts" column is the timestamp for the row, in millis from 1970-01-01. Most spreadsheet applications don’t know how to parse these values, though, so we also add the at column.\n\nThe "at" column is ts in ISO format with only second resolution, and should be parsable by most spreadsheet software.\n\nThe "path" column is the native path of the directory or file. It will be empty for messages about system state.\n\nThe "state" column explains why that row was added.\n\nThe "from" column specifies which codepath added the sync report row.\n\nThe "elapsedMs" column is only added to rows completing a given path, and records how long that process took.\n\nThe "details" column will include information about the path, like why a given file or folder were rejected.\n\nThe "url" column is only added to rows when a file or directory is imported. You may need to adjust the domain name of the URL to make it work correctly (it defaults to localhost).\n\n\nDirectory state values\n======================\n\nThe "state" column for directories will be\n\n${ee(Q)}\n\n\nFile state values\n=================\n\nThe "state" column for files will be\n\n${ee(X)}\n\n\nSee https://photostructure.com/go/sync-reports\n\n`,{maxLineLen:80}).join("\n")))),t.recentSyncReports=async function(e=S.dayMs){const t=Date.now()-e;return ie().descendants((async e=>(0,H.isCsvExt)(e)&&(0,M.gte)(e.mtimeMs(),t)))},t.syncReport=(0,w.lazy)((()=>new se));class se extends N.EndableWrapper{constructor(){super("fs.SyncReport()",(()=>f(this,r,"m",d).call(this)),R.EndableRanks.predb),r.add(this),s.set(this,void 0),n.set(this,void 0),a.set(this,void 0),o.set(this,0),l.set(this,0),this.outputFiles=new x.BoundedList(64),(0,t.ensureSyncReportReadme)()}get outputNativePath(){return f(this,s,"f")?.nativePath}get rowCount(){return f(this,l,"f")}onProgress(e){if(null==e||(0,b.blank)(e.state))return this.logger.error(".onProgress(): invalid input",{s:e,from:(0,q.stack)()});{this.logger.log(te.has(e.state)?J.LogLevels.warn:J.LogLevels.info,"onProgress()",e);const t=Date.now(),i={path:(0,k.toS)(e.path),state:e.state,details:(0,k.toS)(e.details).trim().replace(/\r?\n/g,"; ")},s={ts:t,at:new Date(t).toISOString(),...i,...(0,_.pick)(e,"from","elapsedMs","url")};(0,_.isEmptyObj)(e.meta)||(s.meta=(0,P.stringify)(e.meta)),(0,C.isTest)()&&process.stdout.write((0,P.stringify)(e)+Z.Newline),f(this,r,"m",u).call(this,s)}}maybeSystemData(e){(0,A.isSyncService)()&&this.onProgress(e)}async wrap_({path:e,from:i,fn_:r}){const s=Date.now();this.onProgress({path:e,from:i,state:t.SyncFileStates.started});try{const n=await r(),a=n.state??(null!=n.error?t.SyncFileStates.failed:t.SyncFileStates.unknown);return a===t.SyncFileStates.unknown&&this.logger.error(i+" returned result with no state!"+U.InternalErrorFlag,{path:e,result:n}),this.onProgress({path:e,from:i,elapsedMs:Date.now()-s,...n,state:a}),n}catch(r){throw this.logger.warn("wrap_() caught error",{error:r}),this.onProgress({path:e,from:i,state:(0,B.ending)()||r instanceof L.AbortError?t.SyncFileStates.canceled:r instanceof D.TimeoutError?t.SyncFileStates.timeout:t.SyncFileStates.failed,details:(0,B.ending)()?void 0:(0,W.errorToS)(r),elapsedMs:Date.now()-s}),r}}get output(){return f(this,n,"f")??f(this,r,"m",h).call(this)}async flushClose(){return f(this,r,"m",u).call(this),this.close()}async close(){this.logger.info("Closing sync report");const e=f(this,n,"f");return m(this,n,void 0,"f"),m(this,l,0,"f"),await(0,$.endStream)(e),null==e?void 0:f(this,s,"f")}}t.SyncReport=se,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,r=new WeakSet,u=function(e){var t;const i=f(this,a,"f");if(m(this,a,e,"f"),null!=e&&(0,F.eqlPicked)(e,i,"path","state","details"))return this.logger.debug("deduping row",e),void m(this,o,(t=f(this,o,"f"),t++,t),"f");null!=i&&(0===f(this,o,"f")?f(this,r,"m",c).call(this,i):(f(this,r,"m",c).call(this,{...i,details:(0,v.compactBlanks)([i.details,`(repeated ${f(this,o,"f")+1} times)`]).join(" ")}),m(this,o,0,"f")))},c=function(e){var i;const r=(0,y.unparse)([e],{header:!1,columns:t.SyncReportHeaders.values});this.output.write(r+Z.Newline,(e=>{null!=e&&this.logger.error("Failed to write",e)})),m(this,l,(i=f(this,l,"f"),++i),"f")>K.Settings.syncReportMaxRows.valueOrDefault&&this.close()},d=function(){return this.logger.info("sync report ended",{rowCount:f(this,l,"f"),outputFiles:this.outputFiles}),this.flushClose()},h=function(){return m(this,s,function(){const e=p.DateTime.now();return ie().join(e.toFormat("y-MM-dd"),(0,j.filestamp)()+"-sync-report.csv")}().ensureNewSync_({emptyIsNew:!1}),"f"),this.outputFiles.push(f(this,s,"f").nativePath),this.logger.info("Opening new report: "+f(this,s,"f")),(0,C.isTest)()&&(0,O.stdoutWrite)({syncReport:f(this,s,"f").nativePath},!1),m(this,n,(0,g.createWriteStream)(f(this,s,"f").nativePath),"f"),f(this,n,"f").write((0,y.unparse)([t.SyncReportHeaders.values],{header:!1})+Z.Newline),f(this,n,"f")}},89966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const s=r(i(48161)),n=i(19851),a=i(55835),o=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),h=i(8103),f=i(43899);function m(){return(0,a.map)(f.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,a.map)(m(),(e=>e.join(c.platformName+"-"+s.default.arch())))}async function g(e){if(c.isWin&&(e=(0,o.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,h.pathIfExists)(m()?.join("bin",e))),(()=>(0,h.pathIfExists)(m()?.join(e))),(()=>(0,h.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,h.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,n.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,n.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,n.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,n.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const s=r(i(44652)),n=i(19851),a=i(22573),o=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,o.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,a.blank)(t.file))throw new Error("can't touch blank path");const r=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const o=(0,n.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await o())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await o())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(s.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(n){if(!i||"ENOENT"!==n.code)throw n;await(0,c.thenOrTimeoutError)(s.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},79847:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.trashOrUnlinkFileUri=t.trashOrUnlinkFileUris_=void 0;const o=n(i(51455)),l=a(i(49378)),u=i(40958),c=i(22573),d=i(13538),h=i(83104),f=i(45255),m=i(31562),p=i(98314),g=i(34102),y=i(28874),w=i(45200),v=i(16287),b=i(74128),S=i(84258),P="fs.Trash";async function M(e){const t=Date.now(),i=y.Settings.commandTimeoutMs.valueOrDefault,r=(0,c.toNotBlank)(e.nativePath)??await(0,d.thenOrTimeout)((0,w.uri2nativePath)(e.uri,e.mountpoint),i);if((0,c.blank)(r)||r===h.Timeout)return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not convert URI to native path",path:e.uri,elapsedMs:Date.now()-t}),{uri:e.uri,unlinked:!1};const s=await(0,v.statMaybe)(r);if(null==s)return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: no such file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(!s.isFile())return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: not a file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(y.Settings.trySoftDeletes.valueOrDefault)try{if(await(0,d.thenOrTimeoutError)((0,l.default)(r,{glob:!1}),i),await function(e){return(0,m.untilTrue)((async()=>null==await(0,v.statMaybe)(e)),{timeoutMs:f.ShortCommandTimeoutMs})}(r))return(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Moved file to trash",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0};(0,S.logger)().warn("soft-delete("+r+") didn't seem to work: the file is still there?")}catch(e){(0,b.syncReport)().onProgress({from:P,state:"note",details:"Failed to soft-delete file to trash: "+(0,p.errorToS)(e),path:r,elapsedMs:Date.now()-t}),(0,S.logger)().warn("Tried to soft-delete, but that failed. We'll try to hard-delete.",{error:e})}try{return await(0,d.thenOrTimeoutError)(o.unlink(r),i),(0,g.ee)().emit("fileChanged",r),(0,S.logger)().info("unlink("+r+") successful"),(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Permanently deleted file",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0}}catch(i){return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not move file to trash or delete: "+(0,p.errorToS)(i),path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!1}}}t.trashOrUnlinkFileUris_=async function(e){const t=[];for(const{uri:i,mountpoint:r}of(0,u.uniqBy)(e,(e=>e.uri)))try{t.push(await M({uri:i,mountpoint:r}))}catch(e){t.push({uri:i,unlinked:!1,error:e})}return t},t.trashOrUnlinkFileUri=M},70854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryUidStore=t.LibraryUIDStore=t.SystemUIDStore=t.UIDStore=t.mkuid=void 0;const r=i(19851),s=i(41400),n=i(55835),a=i(92782),o=i(37805),l=i(46292),u=i(34102),c=i(55222),d=i(28874),h=i(87128),f=i(95696);function m(){return(0,a.safeRandomUid)({radix:c.TokenRadix,chars:24,splitEveryN:4})}t.mkuid=m;class p extends h.JsonFileStore{constructor(e,t){super(e.join("."+t+"-uid.json"),(()=>({uid:m(),version:o.version,type:this.type,createdAt:Date.now()})),(e=>e.hide())),this.rootDir=e,this.type=t,this.readUid_=(0,r.lazy)((async()=>(await this.read_())?.uid))}}function g(e=d.Settings.libraryDir.valueOrDefault){return(0,n.map)(f.PosixFile.forMaybe(e),(e=>new p(e,"library")))}t.UIDStore=p,t.SystemUIDStore=(0,r.lazy)((()=>(0,n.map)((0,l.configDir)(),(e=>new p(f.PosixFile.for(e),"system"))))),t.LibraryUIDStore=(0,r.lazy)(g),t.libraryUidStore=g,(0,s.later)((()=>{(0,u.ee)().on("clearCache",(()=>{t.SystemUIDStore.unset(),t.LibraryUIDStore.unset()})),d.Settings.libraryDir.watchLater((()=>t.LibraryUIDStore.unset()))}))},84258:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const a=n(i(51455)),o=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,o.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const r of(0,l.toA)(e))try{null!=r&&await a.unlink((0,c.toNativePath_)(r))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+r,{error:e})}}},5545:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const s=r(i(76760)),n=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,n.toS)(i.path??s.default.sep)}},70257:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),s=i(45255),n=i(17217);t.WipTimeoutMs=s.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const a=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(a,"")},t.isWip=function(e){return a.test((0,n.basename)(e)??"")}},58722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),s=i(22911);class n extends r.Writable{constructor(e){super(e),this.deferred=new s.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=n},73428:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(51926),o=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=n.default.dirname(e);await(0,c.mkdirp_)(i),await s.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=n.default.dirname(e);(0,c.mkdirpSync_)(i),s.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,a.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))}},13047:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const s=r(i(73024)),n=i(76760),a=i(46466),o=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),w=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function v(e,t){return(await S(e,t)).toString()}async function b(e,t,i){const r=[],n=[s.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?n.push((0,o.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&n.push((0,o.createBrotliDecompress)().on("error",(e=>r.push(e)))),n.push(t),await(0,a.pipeline)(n),(0,u.isNotEmpty)(r))throw new f.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function S(e,t){const i=new y.WritableToBuffer;return await b(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await S(e))}async function M(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,n.parse)(e).dir),await(0,a.pipeline)(new g.ReadableBuffer(i),(0,o.createGzip)(),s.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=v,t.zcat=async function(e,t){try{return v(e,t)}catch(t){return void w().warn("zcat failed to read "+e,t)}},t.zpipe_=b,t.zCopyToBuffer_=S,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void w().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=M,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await M(e,t)}catch(t){w().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},63664:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRemoteOrLocalHealthSummarySync=t.getRemoteOrLocalHealthSummary=t.getLocalHealthSummary=t.getRemoteHealthSummary=void 0;const r=i(22573),s=i(45599),n=i(41400),a=i(50268),o=i(98553),l=i(50213),u=i(23560),c=i(45255),d=i(5916),h=i(28874),f=i(34238),m=i(51140),p=i(4988),g=i(18454),y=(0,s.defer)((()=>(0,l.mkLogger)("health.GetHealthSummary")));t.getRemoteHealthSummary=(0,d.lazyAsync)({later:async()=>{try{if((0,u.isWebService)())return;const e=await(0,p.get_)(f.URI.from({scheme:"http",authority:"127.0.0.1:"+h.Settings.httpPort.valueOrDefault,path:"/api/health"}),{timeoutMs:c.ShortCommandTimeoutMs}),t=(0,o.parseJSON_)(e.data);if(m.HttpStatusIs.ok(e.statusCode)&&(0,a.isHealthCheckSummary)(t))return"ready"===t.state&&(0,r.toNotBlank)(t.libraryDir)!==(0,r.toNotBlank)(h.Settings.libraryDir.valueOrDefault)&&(y().error("getHealthSummary(): libraryDir mismatch! Switching to that library directory...",{local:h.Settings.libraryDir.valueOrDefault,remote:t.libraryDir}),h.Settings.libraryDir.value=t.libraryDir),y().debug("getHealthSummary()",{response:e}),t;y().warn("getHealthSummary(): invalid response",{response:e})}catch(e){y().warn("Failed to get health check summary from web service",{error:e})}}}),t.getLocalHealthSummary=(0,d.lazyAsync)({later:()=>g.HealthCheck.awaitSettled()}),(0,n.later)((()=>{h.Settings.healthCheckIntervalMs.watch((e=>{t.getRemoteHealthSummary.setTTL(e),t.getLocalHealthSummary.setTTL(e)}))})),t.getRemoteOrLocalHealthSummary=async function(){return await(0,t.getRemoteHealthSummary)()??await(0,t.getLocalHealthSummary)()},t.getRemoteOrLocalHealthSummarySync=function(){return t.getRemoteHealthSummary.syncValue()??t.getLocalHealthSummary.syncValue()}},87408:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStatusSummary=void 0;const r=i(63870),s=i(18454),n=i(89035),a=i(82638);t.getStatusSummary=async function(e={}){return(0,a.summarizeHealthChecks)({healthChecks:[...s.HealthCheck.allCritical(),(0,n.memoryHealthCheck)()],errors:s.HealthCheck.lastErrors(),timeoutMs:(0,r.commandTimeoutMs)(),skipPending:!0,...e})}},18454:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,w,v,b,S,P,M=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},_=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const T=i(19851),E=i(40958),D=i(76790),k=i(41400),x=i(50357),F=i(26905),C=i(50268),A=i(55835),I=i(68708),O=i(30976),L=i(51926),R=i(13538),N=i(42279),B=i(59455),j=i(54993),z=i(48884),V=i(89788),W=i(22454),U=i(50213),q=i(69591),H=i(22911),G=i(99331),$=i(5916),J=i(42638),K=i(77740),Z=i(98314),Y=i(70025),X=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),re=i(21525),se=i(82638),ne=(0,T.lazy)((()=>(0,U.mkLogger)("health.HealthCheck")));class ae{static traceLater_(e,t){const i=new H.Deferred(e);i.catch((t=>{M(this,s,"f",l).push(e+": failed: "+(0,Z.errorToS)(t)),this.onResultChange()})),M(this,s,"m",o).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return M(this,s,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){M(this,s,"f",l).push((0,L.isString)(e)?e:(0,Z.errorToS)(e)),this.onResultChange()}static lastErrors(){return M(this,s,"f",l).toA()}static addLoadingMsg(e){M(this,s,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,E.compact)((0,B.toA)(e)).map(j.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return ne().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:M(this,s,"f",h).entriesByCountDesc()}),(0,A.map)((0,z.leastBy)(e,(e=>[M(this,s,"f",h).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=M(this,s,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,A.map)(e,(e=>M(this,s,"f",h).incr(e.msg))),ne().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return X.Settings.skipHealthCheckIds.envValue=t,s.reset()}static findById(e){return M(this,s,"f",f).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,C.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=M(this,s,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=s.summary();if(e.pendingCount>0){const t=await Promise.all(s.testResultsCritical());e=s.summaryFromResults(t),ne().info("awaitSettled(): summary result",{summary:e,results:t})}return ne().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){s.summary.unset()}static reset(){if((0,G.ending)())ne().warn("Rejecting reset() when ending()",(0,F.shortStack)());else{this.onResultChange(),M(this,s,"f",l).clear(),M(this,s,"f",d).clear(),M(this,s,"f",h).clear(),M(this,s,"f",c).clear(),this.summary.clear(),_(this,s,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new s(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return M(this,s,"f",f).push(i),this.all.unset(),i}constructor(e,t,i,n,o,l,u,c,d,h,f,m,S,P=Q.commandTimeoutMs){r.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=n,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=h,this.errorLinks=f,this.onReset=m,this.ttlMs=S,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),v.set(this,(0,T.lazy)((async()=>{await M(this,p,"f").prior(),(0,x.eql)(M(this,g,"f"),M(this,r,"m",w).call(this))||(this.onReset?.(),await this.refresh(),M(this,v,"f").unset())}))),this.refresh=(0,T.lazy)((()=>new H.Deferred("refresh").observe((async()=>{await M(this,p,"f").prior();const e=M(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,U.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[C.HealthCheckSections.ordinal(this.section),l??999,this.id],_(this,p,(0,$.lazyAsync)({desc:this.pendingMsg,later:()=>M(s,s,"f",a).enqueue({name:this.id,l:()=>M(this,r,"m",b).call(this,o)}),ttlMs:S}),"f"),this.isCritical&&M(this,p,"f").watchLater({onChange:s.onCriticalResult,onError:s.onCriticalResult});for(const e of this.settings)X.Settings[e].watchLater((()=>M(this,v,"f").call(this)))}isStale(){return M(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return M(this,p,"f").settledCount()}reset(){return M(this,p,"f").unset(),this.onReset?.(),_(this,g,{starting:!0},"f"),this}setTTL(e){M(this,p,"f").setTTL(e)}result(){return M(this,p,"f").call(this)}isSkipped(){return X.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return M(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return M(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??M(this,r,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function oe(e){if((0,E.isEmpty)(e))return{};const[t,i]=(0,z.partition)(e,(e=>"button"===e.type||"POST"===e.method)),r={};return(0,E.isNotEmpty)(i)&&(r.links=(0,E.uniqBy)(i)),(0,E.isNotEmpty)(t)&&(r.buttons=(0,E.uniqBy)(t)),r}t.HealthCheck=ae,s=ae,p=new WeakMap,g=new WeakMap,y=new WeakMap,v=new WeakMap,r=new WeakSet,o=function(){return(0,E.filterInPlace)(M(this,s,"f",n),(e=>!e.isPending)),M(this,s,"f",n)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=ne().tap({level:"warn",msg:"#summary()",result:(0,se.summarizeHealthChecksSync)({errors:M(this,s,"f",l),skipPending:M(this,s,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&_(this,s,!0,"f",u),i.state!==M(this,s,"f",c).last?.state&&M(this,s,"f",c).push({state:i.state,ts:Date.now()}),i},w=function(){return(0,I.fromEntries)(this.settings.map((e=>[e,X.Settings[e].valueOrDefault])))},b=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();ne().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,F.shortStack)()}),_(this,g,M(this,r,"m",w).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,k.delay)((0,O.randomInt)(.3*i,.7*i)),this.isSkipped())return M(this,r,"m",S).call(this,{test:{level:"disabled",msg:["Disabled by "+X.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const s=await(0,R.thenOrTimeoutError)(e(),i);return M(this,r,"m",S).call(this,{test:s,elapsedMs:Date.now()-t})}catch(e){return M(this,r,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},S=function({test:e,src:t="#toResult",elapsedMs:i}){var r,n;const a=s.normalizeMsg(e.msg),o=e.level??((0,j.toS)(a).toLowerCase().includes("error")?"error":(0,j.toS)(a).toLowerCase().includes("warn")?"warn":"ok"),l=(0,E.compact)([...e?.links??("ok"===o||"pending"===o?this.okLinks:"warn"===o?this.warnLinks:"no-library"===o?this.noLibraryLinks:"error"===o?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:o,msg:a,elapsedMs:i,...oe(l)};return u.runCount=(_(this,y,(n=M(this,y,"f"),r=n++,n),"f"),r),(0,G.ending)()?u:this.logger.tap({level:re.HealthCheckLevelToLogLevel[o],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const s=(0,L.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,A.map)(e,Z.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,Y.isFatalError)(e)&&s.toLowerCase().includes("warn")?"warn":"error"),M(this,r,"m",S).call(this,{test:{msg:s,level:t},src:"#toErrorResult",elapsedMs:i})},n={value:[]},a={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},h={value:new W.CountingSet},f={value:[]},ae.all=(0,T.lazy)((()=>Object.freeze((0,D.sortBy)(M(s,s,"f",f),(e=>e.sortBy))))),ae.onCriticalResult=(0,q.debounce)((()=>{ne().info("onCriticalResult()",s.summary.refresh())}),250),ae.summary=(0,T.lazy)((()=>M(s,s,"m",m).call(s))),ae.resetDebounced=(0,q.debounce)((()=>s.reset()),50)},85021:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckCommand=void 0,t.HealthCheckCommand="--health"},33866:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const r=i(82950),s=i(50268),n=i(459),a=i(23560),o=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,a.isPermaService)(t)&&(e===s.HealthCheckLevels.error||(0,a.isLibraryRequiredService)(t)&&e===s.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,o.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,r.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new n.UnreachableCaseError(e)}}},42495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const r=i(40958),s=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,r.compact)([(0,s.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},89035:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const s=r(i(48161)),n=i(19851),a=i(82950),o=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),h=i(23560),f=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:r}){return{level:i,msg:[e+" from "+(0,h.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,a.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(r,2)])]}}function g(){return s.default.totalmem()f.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(f.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*f.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,n.lazy)((()=>"ok"!==g().level),o.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:o.minuteMs,later:async()=>g()})))},82638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const r=i(40958),s=i(42659),n=i(45599),a=i(41400),o=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),h=i(23560),f=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,n.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function w({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:r}){const s=new Map;for(const e of t??[])s.set(e.id,e);if(null!=e)for await(const t of f.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),r))s.set(t.id,t);return[...s.values()]}t.summarizeHealthChecks=async function(e){return b({...e,healthCheckResults:await w(e)})};const v=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:h.serviceName.prior()??process.title}})));function b(e){const t=(0,r.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),n=i.length,a=i.map((e=>e.id)),c=t.length-n,d=0===n,h=(0,r.uniq)((0,r.compactBlanks)(e.errors));if(h.length>0)return{...v(),level:l.HealthCheckLevels.error,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",h.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const s=t.filter((e=>e.level===i));if((0,r.isNotEmpty)(s)){const e=t.filter((e=>!s.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+s.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...v(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:a,pendingCount:n,settledCount:c,linkIds:s.map((e=>e.id)),ts:Date.now(),msg:(0,r.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,o.flatten)([...s,...e].map((e=>e.msg[0])))])},meta:{checks:s.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...v(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,s.fmtDateShort)(Date.now())]}})}(0,a.later)((()=>{m.Settings.libraryDir.watchLater((()=>v.unset()))})),t.summarizeHealthChecksSync=b},95242:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviewBuilder=t.mkPreviewAssetFile_=void 0;const a=i(57975),o=i(40958),l=i(22573),u=i(33374),c=i(98553),d=i(55835),h=i(68708),f=i(48884),m=i(50213),p=i(92434),g=i(54296),y=i(51837),w=i(57159),v=i(83278),b=i(95696),S=i(62105),P=i(84258),M=i(38156),_=i(69589),T=i(28874),E=i(47783),D=i(29990),k=i(16047),x=i(42725),F=i(4192),C=i(32876),A=i(50961),I=i(181);t.mkPreviewAssetFile_=async function(e){const t=await(0,E.readTags)(e);return{nativePath:e.nativePath,fileSize:await e.size(),mtime:await e.thisOrSidecareMaxMtimeMs(),uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath,mimetype:t.mimetype,rotation:t.rotation,...t.dimensions,sha:await e.sha_()}};class O{constructor(e,t,i){r.add(this),this.ap=e,this.assetFiles=t,this.logger=(0,m.mkLogger)("AssetPreviewBuilder("+e.assetId+")"),this.ctx=(0,_.forceContextOrSetting)(i),this.assetFiles=(0,p.sortAssetFiles)(this.assetFiles)}[(r=new WeakSet,a.inspect.custom)](){return{ctor:"AssetPreviewBuilder",assetId:this.ap.assetId,assetFiles:this.assetFiles}}async build_(){this.logger.info("build_(): asset file candidates:",this.assetFiles.map((e=>(0,h.pick)(e,"id","uri"))));const e=[];for(const t of this.assetFiles){const i=b.PosixFile.forMaybe(await(0,g.getAssetFileNativePath)(t));if(null!=i){{const e=await(0,S.whyRejectFile)(i);(0,l.blank)(e)||this.logger.info("skipping: rejected",{pf:i,whyRejected:e})}try{return await n(this,r,"m",s).call(this,i,t)}catch(i){e.push(i),this.logger.warn("Failed to set shown file to ",{best:t,error:i})}finally{this.ap.parent.clear()}}else this.logger.info("skipping: failed to get PosixFile",{af:t}),e.push(new Error("Cannot get path from URI "+(0,c.stringify)((0,h.pick)(t,"uri","mountpoint","nativePath"))))}return this.logger.throw("Cannot build previews: none of the files are valid",{doNotSend:!0,retriable:!1,files:this.assetFiles.map((e=>e.nativePath??e.uri)),causes:e})}async infoForBest_(e,t){await(0,I.throwIfInvalidFile_)(e);const i=await e.size(),r=await e.thisOrSidecareMaxMtimeMs();if(this.logger.debug("_build",{filesize:i,mtime:r,best:t.uri}),null==i||null==r)return this.logger.throw("build(): missing stat info for best file",{ignorable:!0,best:t});const{uri:s,width:n,height:a,sha:l,mimetype:u}=t;if(null==s||null==n||null==a||null==u||null==l)return this.logger.throw("build(): internal error: missing fields for best file "+e,{ignorable:!0,best:t});const c=(0,D.fitSizes)(t,t.mimetype);return{assetId:t.assetId,assetFileId:t.id,uri:s,uris:this.assetFiles.map((e=>e.uri)),path:e.nativePath,mtime:r,filesize:i,width:n,height:a,sha:l,mimetype:u,fitSizes:c.map((([,e])=>e.name)).join(","),sqWidths:(0,o.compact)(x.ImageSize.sq().map((e=>e.outputSize(t)?.width))),fitWidths:c.map((([e])=>e.width))}}async priorIfValid_(e,t){if(this.ctx.forceSync||this.ctx.forceRebuildPreviews)return;const i=await this.ap.readInfo.refresh();if(null!=i){if(i.assetId!==t.assetId)throw new y.InternalError("priorIfValid_(): mismatched asset IDs for "+e+": "+(0,c.stringify)({priorInfo:i,info:t}));const r=i.fitSizes.split(","),s=t.fitSizes.split(",");if(null!=i.sha&&i.sha===t.sha&&i.rotation===t.rotation&&(0,D.equivalentFitSizes)(r,s)){const n=(0,D.fitSizes)(e,e.mimetype),a=(0,o.diff)(r,s);if((0,o.isNotEmpty)(a)){this.logger.info("priorIfValid_(): removing previews that aren't required anymore.",{leftovers:a});for(const e of a){const t=n.find((([,t])=>t.name===e));if(null==t)this.logger.warn("priorIfValid_(): Failed to clean up: missing fit size",{fitsize:t,fits:n});else{const e=this.ap.fileForWidth(t[1].reducer.name,t[0].width);this.logger.debug("priorIfValid_(): unlinking unwanted preview "+e,{fitsize:t}),await e.unlink("warn")}}}return this.logger.debug("priorIfValid_(): SHA and rotation match, and previews exist.",{info:t,priorInfo:i}),await this.ap.writeInfo(t),t}}}}t.AssetPreviewBuilder=O,s=async function(e,t){this.logger.info("_build("+e+")",{uri:t.uri});const i=await this.infoForBest_(e,t),r=await this.priorIfValid_(t,i);if(null!=r)return r;const s=new M.PushProgressObserver({path:e.nativePath,op:"Building previews"},x.ImageSize.sq().length+x.ImageSize.fit().length);if(this.logger.debug("Rebuilding all previews from "+t.uri,{assetId:t.assetId,info:i}),null==await this.ap.parent.mkdirp())throw new Error("build(): Failed to create previews directory, "+this.ap.parent+" for "+t);const n=await this.ap.existingFiles(),a=await(0,A.sharpReadable_)({src:e,minDim:x.ImageSize.largestFit().max});if(null==a)throw new w.WrappedError("AssetPreviewBuilder.build(): "+t.uri+", "+e.nativePath+", is not readable by sharp.",{retriable:!1});const o=(0,A.toSharp)(a);if(t.mimetype.startsWith("image/")&&!(0,k.isHeifMimeType)(t.mimetype)&&null!=t.rotation&&0!==t.rotation&&(o.rotate(t.rotation),this.logger.debug("build(): rotating "+t.rotation+"°")),(0,v.isBaseFile)(a)&&a.desc.toLowerCase().includes("thumbnail"))try{o.trim(1)}catch{}const l=(0,D.fitSizes)(t,t.mimetype),c=[],m=[];let p,g;const y=x.ImageSize.largestSq(),b=(0,f.leastBy)(l,(([e,t])=>(0,d.map)(y.outputSize(e),(()=>t.megapixels()))))?.[1].name,S=(0,h.pick)(t,"width","height");{let e=o.clone(),t=S;for(const[i,r]of l){const n=Date.now(),a=t,o=this.ap.fileForWidth(r.reducer.name,i.width).wip();e=r.resize(i,e),t=i,r.name===b&&(g=e.clone(),p=i),(0,u.dmegapixels)(i)>=1&&r.reducer===C.Fit&&T.Settings.includePreviewTags.valueOrDefault&&m.push(o),await r.toJpeg({path:o.nativePath,sh:e,outputSize:i}),s.onProgress(),this.logger.debug("resize("+r.name+") "+(0,u.fmtDim)(a)+" -> "+(0,u.fmtDim)(i)+" in "+(Date.now()-n)+" ms"),c.push(o)}}{null==g?(this.logger.debug("square resize(): resorting to ",{origDim:S,bestFitNameForSq:b}),g=o,p=S):this.logger.debug("square resize(): using to ",{sqDim:p,bestFitNameForSq:b});let e=!1;for(const t of x.ImageSize.sq()){const i=Date.now(),r=p,n=t.outputSize(p??S);if(null==n){this.logger.debug("skipping square output for "+t.max);continue}e||(n.position=T.Settings.squareThumbStrategy.valueOrDefault,e=!0),this.logger.debug("Applying ",{outputSize:n});const a=this.ap.fileForWidth(t.reducer.name,n.width).wip();t.resize(n,g),p=n,await t.toJpeg({path:a.nativePath,sh:g,outputSize:n}),s.onProgress(),c.push(a),this.logger.debug("resize("+t.name+") "+(0,u.fmtDim)(r)+" -> "+(0,u.fmtDim)(n)+" in "+(Date.now()-i)+" ms")}}try{await(0,F.includePreviewTags_)(e,m).catch((t=>{this.logger.warn("Failed to restore metadata tags into previews for "+e,{error:t})}));const t=new Set(n.map((e=>e.nativePath)));for(const e of c){const i=await e.unwip_();t.delete(i.nativePath)}await(0,P.unlink)(t),await this.ap.writeInfo(i),this.logger.debug("Previews unwipped and info written",{info:i})}catch(t){throw await(0,P.unlink)(c),new w.WrappedError("Failed to create previews from "+e,{cause:t,path:e.nativePath,fatal:!1})}return i}},35721:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkDownloadableTitle=t.previewToDownloadable=t.extractPreviewInfo=void 0;const r=i(75761),s=i(33374),n=i(11371),a=i(55835),o=i(31586),l=i(56519),u=i(29882),c=i(50213),d=i(97352),h=i(81168),f=i(89782),m=(0,c.mkLogger)("extractPreviewInfo");function p(e,t,i,r){return`Download ${t} ${e.ext} ${i} (${(0,s.fmtDim)(r)})`}t.extractPreviewInfo=function(e,t){const i=t.posixPathFrom(e).replace(/\//g,"").split("-"),r=(0,o.toInt)(i[0]),s=n.ReducerNames.getCI(i[1]),a=(0,d.extractInt)(i[2]);return(0,o.gt0)(r)?{file:t,assetId:r,reducer:s,width:a}:void m.warn("Failed to extract preview info",{file:t,previewsRoot:e,arr:i,assetId:r,reducer:s,width:a})},t.previewToDownloadable=async function(e,t){return(0,a.map2)(t.assetId,t.width,((i,a)=>(0,l.thenMap)((0,f.dimensions)(t.file),(o=>{const l=(0,s.dimToSize)(o);return{size:l,basename:`${(0,h.stripSuffix)(e,(0,u.extname)(e))}-${l}${t.file.ext}`,title:p(t.file,l,"image",o),description:`Download ${l}`,details:`(${(0,s.fmtDim)(o)} ${t.file.ext})`,href:(0,r.assetImgLink)({assetId:i,reducer:n.ReducerNames.fit,width:a})}}))))},t.mkDownloadableTitle=p},16524:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviews=void 0;const a=i(19851),o=i(40958),l=i(75761),u=i(11371),c=i(68708),d=i(39926),h=i(58939),f=i(48884),m=i(50213),p=i(81168),g=i(56519),y=i(38835),w=i(70417),v=i(35721);t.AssetPreviews=class{constructor(e,t){r.add(this),this.previewsRoot=e,this.readInfo=(0,a.lazy)((()=>this.infoJson().readJson("debug"))),this.logger=(0,m.mkLogger)("AssetPreviews(assetId:"+(0,h.id2id)(t)+")"),this.assetId=(0,h.id2id)(t);const i=(0,d.leftPad)(this.assetId,8,"0"),s=(0,p.splitEvery)(i,3);this.basename=s.pop()+"-",this.parent=e.join(...s)}parentNotExists(){return this.parent.clear().notExists()}async existingFiles(){return await this.parent.clear().childFiles((e=>e.base.startsWith(this.basename)))??[]}async existingJpgs(){return(await this.existingFiles()).filter((e=>".jpg"===e.ext))}async previewInfos(){return(0,g.sortByAsync)({name:"img.AssetPreviews.previews",arr:n(this,r,"m",s).call(this),f:e=>e?.file.size()})}async deleteAll(){const e=await this.existingFiles();if(e.length>20)throw new Error("deleteAll(): rejected: > 20 existing files?!"+y.InternalErrorFlag);for(const t of e)await t.unlink();return e}fileForSuffix(e){return this.parent.join(this.basename+e)}mp4(){return this.fileForSuffix("video.mp4")}infoJson(){return this.fileForSuffix("info.json")}writeInfo(e){return this.readInfo.unset(),this.infoJson().writeJson((0,c.pick)(e,"assetId","assetFileId","uri","uris","path","mimetype","width","height","mtime","filesize","sha","rotation","fitSizes","fitWidths"))}fileForWidth(e,t){return this.fileForSuffix(e+"-w"+t+".jpg")}async filesForReducer(e){const t=this.basename+e+"-";return this.logger.tap({msg:"filesForReducer("+e+")",result:(await this.existingFiles()).filter((e=>e.base.startsWith(t)))})}async smallestFileForReducer(e){return(0,f.leastBy)(await this.filesForReducer(e),(e=>(0,v.extractPreviewInfo)(this.previewsRoot,e)?.width))}async largestFileForReducer(e){return(0,f.greatestBy)(await this.filesForReducer(e),(e=>(0,v.extractPreviewInfo)(this.previewsRoot,e)?.width))}async widths(e){const t=await this.readInfo(),i=e===u.ReducerNames.sq?"sqWidths":"fitWidths",r=t?.[i];if(!(0,o.isEmpty)(r))return r;const s=(0,o.compact)((await this.previewInfos()).filter((t=>t.reducer===e)).map((e=>e.width)));return null!=t&&(t[i]=s,await this.writeInfo(t)),s}async posterLink(){const e=await this.widths(u.ReducerNames.fit);return(0,l.assetImgLink)({assetId:this.assetId,reducer:u.ReducerNames.fit,width:(0,w.max)(e)})}async imgAttrs(e,t=!1,i=!0){if(t||e!==u.ReducerNames.sq){const t=e===u.ReducerNames.fit?await this.readInfo():void 0;return(0,l.assetImgAttrs)({assetId:this.assetId,reducer:e,widths:await this.widths(e),lazyLoad:i,af:t})}return(0,l.assetSqImgAttrs)({assetId:this.assetId,lazyLoad:i})}},r=new WeakSet,s=async function(){const e=[];for(const t of await this.existingFiles()){const i=(0,v.extractPreviewInfo)(this.previewsRoot,t);null!=i&&e.push(i)}return e}},52086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},33106:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.dctPixels=t.dctHashCIELAB=t.dctHash=void 0;const s=r(i(9288)),n=i(96249),a=i(85810),o=32,l=function(e){const t=new Array(32);for(let e=1;e<32;e++)t[e]=1;return t[0]=1/Math.sqrt(2),t}(),u=function(e){const t=new Array(32);for(let e=0;e<32;e++){t[e]=new Array(32);for(let i=0;i<32;i++)t[e][i]=Math.cos((2*e+1)/64*i*Math.PI)}return t}();function c(e){const t=new Array(o);for(let i=0;is?1:0);return n}t.dctHash=async function(e){return c(await e.greyscale().resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer())},t.dctHashCIELAB=async function(e){const t=await e.resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer(),i=(0,a.rgb2labArray)(t);return(0,n.flatten)(i.map(c))},t.dctPixels=c},86580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(21605),o=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,n.gt0)(e.width)&&(0,n.gt0)(e.height)?(0,n.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,s.dmegapixels)(e.dimensions):(0,n.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,n.lt)(e.width,t.width)&&(0,n.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,n.lte)(e?.width,t?.width)&&(0,n.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,n.lt)(e.width,t.width)||(0,n.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,r.compact)((0,o.toS)(e).split(/[x×]/).map((e=>(0,n.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,r=Math.round(Math.sqrt(t*i));return{width:r,height:Math.round(r/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const r=u(e,i);return null==r?[]:a.Rotations.filter((e=>u(c(t,e),i)===r))}},89782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(56519),o=i(1078),l=i(5733),u=(0,r.lazy)((()=>(0,n.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,s.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,a.thenMap)((0,o.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},29990:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.equivalentFitSizes=t.fitSizes=void 0;const r=i(40958),s=i(33374),n=i(16170),a=i(42725),o=[a.ImageSize.QVGA,a.ImageSize.QQVGA];function l(e){return"qhd"===e?"wvga":"uhd"===e?"uhd4k":e}t.fitSizes=function(e,t){const i=a.ImageSize.fit(),r=[];let l=(0,n.isMimeTypeSupportedByBrowser)(t)?e:void 0;for(let t=0;t3||(0,s.dmegapixels)(a)-(0,s.dmegapixels)(l)>2.5)&&(l=a,r.push([a,n])))}return r},t.equivalentFitSizes=function(e,t){return(0,r.includesAll)((0,r.compactBlanks)(e).map(l),(0,r.compactBlanks)(t).map(l))}},277:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const r=i(22573),s=i(41400),n=i(54993),a=i(19851),o=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),h=i(78330),f=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),w=(0,a.lazy)((()=>(0,o.mkLogger)("img.Heif")));function v(e){return(0,n.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function b(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,a.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,r.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){w().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,r.blank)(e))return void w().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=v(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,r.blank)(i)&&(0,l.hasApt)()){const t=await(0,h.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,r.blank)(i)&&(0,f.hasPacman)()&&(i=(await(0,f.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,r.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void w().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=v,t.isHeifSupported=b,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await b()?(0,g.heif2png_)(e):void w().throw("HEIF support is missing",{src:e.nativePath})},(0,s.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(41400),o=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),h=i(28874),f=i(89782),m=i(13940),p=(0,r.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,s.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,r.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:h.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?n.minuteMs:void 0),e})),(0,a.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,f.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(h.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:h.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(o.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const r=i(22573),s=i(54993),n=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,r.blank)(e)&&n.test((0,s.toS)(e))}},13940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),s=i(19851),n=i(42659),a=i(59455),o=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),w=i(55222),v=i(63870),b=(0,s.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,s.lazy)((()=>(S(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const S=(0,s.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const s=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const n=s.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await n.mkdirp_(),await n.utimes();const a=n.join(i+r);return b().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:a}),a}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,a.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+w.TokenRadix.randomChars(2),w.TokenRadix.randomChars(16)+(0,o.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*n.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const s=await P(e,t,i);return await s.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,v.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),s}catch(r){return b().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},48368:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashDim=t.toImageHash=t.isImageHash=t._imageHash_=t.imageHash_=t.imageHash=t.maxPerBits=void 0;const s=r(i(9288)),n=i(19851),a=i(40958),o=i(22573),l=i(42659),u=i(33374),c=i(56038),d=i(85810),h=i(76490),f=i(40401),m=i(86758),p=i(85434),g=i(96706),y=i(38835),w=i(88561),v=i(95696),b=i(17217),S=i(50213),P=i(23624),M=i(28874),_=i(12089),T=i(16170),E=i(1078),D=i(33106),k=i(86580),x=i(78011),F=i(50961);t.maxPerBits=function(e){return Math.floor(52/e)};const C=(0,n.lazy)((()=>(0,S.mkLogger)("img.ImageHash")));t.imageHash=async function(e){try{return await(0,t.imageHash_)((0,b.toNativePath_)(e))}catch(t){return void C().warn("imageHash() failed for "+e,t)}};const A=(0,n.lazy)((()=>new w.FileCache({name:"img.imageHash",timeoutMs:l.minuteMs})));async function I(e){const t=v.PosixFile.for(e),i=await(0,E.extractSizeInfoFromFile)(t);if(null==i)throw new Error("Failed to read dimensions for "+e+y.NonFatalErrorFlag+y.DoNotSendErrorFlag);const r=(0,k.fitToResolution)(i.dimensions,Math.round(M.Settings.dominantColorPixels.valueOrDefault)),n=await(0,F.sharpReadable_)({src:t,minDim:r});return(0,c.time)("img.imageHash",(()=>async function({file:e,readable:t,sizeInfo:i}){const r=(0,S.mkLogger)("ImageHash("+e+")");if(null==t)return r.throw("Cannot build readable stream");const n=(0,k.fitToResolution)(i.dimensions,M.Settings.dominantColorPixels.valueOrDefault);if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-orig.jpg";await(0,F.toSharp)(t).jpeg().toFile(i),console.log({out:i,readable:t})}let a=(0,F.toSharp)(t).removeAlpha();(0,T.isVideoMimeType)(t.mimetype)||(a=a.rotate(i.rotation)),(0,u.dmegapixels)(i.dimensions)<.1&&(a=a.trim({background:"#000",threshold:0})),a=a.resize({fit:s.default.fit.outside,...n,withoutEnlargement:!0});const{data:o,info:l}=await a.raw().toBuffer({resolveWithObject:!0});if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-"+l.width+"w.jpg";await(0,s.default)(o,{raw:{...l,channels:3}}).jpeg().toFile(i),console.log({out:i,rgbInfo:l,readable:t})}const c=(0,d.rgb2labTriplets)(o),h=(0,f.extractDominantColors)(c),p=(0,m.labsAreGreyscale)(c),y=()=>(0,s.default)(o,{raw:{...l,channels:3}}),w=await(p?x.meanDiffHash:x.meanDiffHashCIELAB)(y()),v=await(p?D.dctHash:D.dctHashCIELAB)(y());return{meanHash:(0,P.b64encodeBits)(w.meanHash),diffHash:(0,P.b64encodeBits)(w.diffHash),dctHash:(0,P.b64encodeBits)(v),dominantColors:h.dominantColors,dominantColorsDescription:h.description,dominantColorScore:h.dominantColorScore,isGreyscale:p,mimetype:(0,T.normalizeMimetype)(t.mimetype),...i.dimensions,rotation:i.rotation??0}}({file:t,readable:n,sizeInfo:i})))}function O(e){return null!=e&&(0,o.notBlank)(e.meanHash)&&(0,o.notBlank)(e.mimetype)&&(0,a.isNotEmpty)(e.dominantColors)}t.imageHash_=(0,_.shim1)({name:"img.imageHash",cache:A,impl:I}),t._imageHash_=I,t.isImageHash=O,t.toImageHash=function(e){if(null!=e){if(O(e))return e;if((0,p.isModeData)(e)){const t={...(0,p.omitModeData)(e),dominantColors:h.DominantColor.fromModeData(e)};if(O(t))return t}}},t.HashDim=8},80361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageHashSimilarity=t.isVerySimilarComparison=t.isVerySimilarImageHash=t.isSimilarImageHash=t.isVerySimilarImage=t.compareImageHashes=t.isSimilarImage=t.hammRatio=t.meanHashVariants=t.isGreyscaleMeanHash=t.labsCorr2=t.isImageHashComparison=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(38639),o=i(33374),l=i(57924),u=i(55835),c=i(31586),d=i(68708),h=i(39926),f=i(21605),m=i(48884),p=i(50213),g=i(97352),y=i(85810),w=i(3048),v=i(32848),b=i(82647),S=i(38812),P=i(70417),M=i(23624),_=i(28874),T=i(86580),E=i(48368),D=i(2090),k=(0,r.lazy)((()=>(0,p.mkLogger)("img.ImageHashComparison")));t.isImageHashComparison=function(e){return null!=e&&(0,E.isImageHash)(e.a)&&(0,E.isImageHash)(e.b)&&[e.imageCorr,e.colorCorr,e.aRotation].every(c.isNumber)},t.labsCorr2=function(e,t){const i=(0,s.sum)(e,(e=>(0,w.diffCIECorr)(e,(0,y.closestLab)(t,e))))+(0,s.sum)(t,(t=>(0,w.diffCIECorr)(t,(0,y.closestLab)(e,t)))),r=Math.max(e.length,t.length,i);return(r-i)/r};const x=/A{20}=?$/;function F(e){return null!=e&&((0,g.within)(7,12,e.length)||null!=e?.match(x))}function C(e,t,i=E.HashDim){const r=(0,M.b64decode)(e).toString(2).split("").map((e=>"1"===e?1:0)),s=i*i;for(;r.length%s!=0;)r.unshift(0);return r.length===s||t?r.slice(0,s):r.slice(0,s).map(((e,t)=>4*e+2*r[t+s]+r[t+2*s]))}function A({a:e,b:t,greyscale:i,dim:r=E.HashDim,rotationsToCheck:a}){if((0,n.blank)(e)||(0,n.blank)(t))return{hammRatio:0,bRotation:0};if(e===t)return{hammRatio:1,bRotation:0};const o=C(e,i,r),l=C(t,i,r);(0,s.isEmpty)(a)&&(a=[0]);const u=a.map((e=>({bRotation:e,hammRatio:(0,c.sigFigs)((0,g.hammRatioIntArrays)(o,(0,S.rotateSquareMatrix)(l,e),i?1:3),2)})));k().debug("hammRatio()",{results:u,rotationsToCheck:a});const d=(0,m.greatestBy)(u,(e=>[(0,c.sigFigs)(e.hammRatio,1),-f.Rotations.indexOf(e.bRotation)]));return{bRotation:d.bRotation,hammRatio:(0,c.sigFigs)(d.hammRatio,2)}}async function I(e,t,i="debug",r={}){return k().tap({msg:`isSimilarImage(${e},${t})`,level:i,result:L(await(0,E.imageHash)(e),await(0,E.imageHash)(t),r)})}function O(e,t,i={}){const r=(0,E.toImageHash)(e),s=(0,E.toImageHash)(t);if(null==r||null==s)return;const n=(0,a.isTrue)(i.capturedAtIsFuzzy),h=!(0,a.isTrue)(i.forceColor)&&((0,a.isTrue)(i.forceGreyscale)||(r.isGreyscale??F(r.meanHash))||(s.isGreyscale??F(s.meanHash))),f=A({a:r.meanHash,b:s.meanHash,greyscale:h,rotationsToCheck:i.rotationsToCheck??(0,T.validRotations)(r,s)}),m=A({a:r.diffHash,b:s.diffHash,greyscale:h,rotationsToCheck:[]}),p=A({a:r.dctHash,b:s.dctHash,greyscale:h,rotationsToCheck:[]}),g=(0,v.dominantColorCorrelation)(r.dominantColors,s.dominantColors);if(null==g)return void k().debug("imageHashCompare(): missing color correlation");const y=r.mimetype===s.mimetype,w=(0,T.aspectRatio)(r),S=(0,T.aspectRatio)((0,o.maybeDimSwap)(s,f.bRotation)),P=null!=w&&null!=S&&!(0,o.isCloseAspectRatio)(w,S);let M=0,x=0;n&&(x+=_.Settings.imageHashFuzzyDateDelta.valueOrDefault,M+=_.Settings.imageHashFuzzyDateDelta.valueOrDefault),y||(x+=_.Settings.imageHashDifferentMimetypesDelta.valueOrDefault,M+=_.Settings.imageHashDifferentMimetypesDelta.valueOrDefault),h&&(M+=_.Settings.imageHashGreyscaleDelta.valueOrDefault,x+=_.Settings.imageHashGreyscaleDelta.valueOrDefault);const C=R((M+(i.minImageCorr??_.Settings.minImageCoeffPct.valueOrDefault))/100),I=R((x+(i.minColorCorr??_.Settings.minColorCoeffPct.valueOrDefault))/100),O=[];P&&O.push(`aspect ratio mismatch (${(0,D.fmtAspectRatio)(w)} vs ${(0,D.fmtAspectRatio)(S)})`);const L=[],N=new b.Average;N.push(f.hammRatio),f.hammRatioN.push(e))),(0,u.map)(p?.hammRatio,(e=>N.push(e))),(0,c.lt)(m?.hammRatio,C)&&L.push("gradient"),(0,c.lt)(p?.hammRatio,C)&&L.push("DCT")),L.length>0&&O.push("different image content ("+(0,l.andList)(L)+")");const j=g>=I,z=j&&N.avg>=C;j||O.push("different dominant colors");const V={meanHashCorr:(0,c.sigFigs)(f.hammRatio,2),diffHashCorr:B?void 0:(0,u.map)(m,(e=>(0,c.sigFigs)(e.hammRatio,2))),dctHashCorr:B?void 0:(0,u.map)(p,(e=>(0,c.sigFigs)(e.hammRatio,2))),hashCorrAvg:N.avg,minImageCorr:C,imageCoeffDelta:M,colorCorr:(0,c.sigFigs)(g,2),minColorCorr:I,colorCoeffDelta:x,isGreyscale:h,bRotation:f.bRotation,aAspectRatio:w,bAspectRatio:S,isSimilar:z,whyNotSimilar:z?void 0:(0,l.andList)(O)};return k().info("compareImageHashes",{a:(0,d.pickCompact)(r,"uri","id","assetId"),b:(0,d.pickCompact)(s,"uri","id","assetId"),...V}),{a:r,b:s,...V}}function L(e,t,i){return O(e,t,i)?.isSimilar??!1}function R(e){return(0,c.sigFigs)((0,c.clamp)(0,1,e),3)}function N(e){return null!=e&&(0,c.gte)(e.meanHashCorr,.9)&&(0,c.gte)(e.colorCorr,.9)}t.isGreyscaleMeanHash=F,t.meanHashVariants=function(e,t=!1,i=E.HashDim){const r=(t=t||null!=e.match(x))?(0,h.padding)("0",2*i*i):"",s=C(e,t,i);return f.Rotations.map((e=>(0,M.b64encode)(BigInt("0b0"+(0,S.rotateSquareMatrix)(s,e).map((e=>e.toString(2))).join("")+r))))},t.hammRatio=A,t.isSimilarImage=I,t.compareImageHashes=O,t.isVerySimilarImage=async function(e,t,i="debug",r={}){return I(e,t,i,{rotationsToCheck:[0],...r,minImageCorr:.92,minColorCorr:.92})},t.isSimilarImageHash=L,t.isVerySimilarImageHash=function(e,t,i={}){return N(O(e,t,i))},t.isVerySimilarComparison=N,t.imageHashSimilarity=function(e,t){return(0,u.map)(O(e,t),(e=>(0,P.avg)([e.meanHashCorr,e.colorCorr])))}},42725:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ImageSize=void 0;const a=i(57975),o=i(19851),l=i(33374),u=i(12168),c=i(48884),d=i(28874),h=i(32876),f=i(5733);class m{static sq(){return n(this,r,"f",s).filter((e=>e.reducer===h.Square))}static largestSq(){return(0,c.greatestBy)(this.sq(),(e=>e.megapixels()))}static fit(){const e=d.Settings.previewResolutions.valueOrDefault;return n(this,r,"f",s).filter((t=>t.reducer===h.Fit&&e.includes(t.name)))}static largestFit(){return(0,c.greatestBy)(this.fit(),(e=>e.megapixels()))}static all(){return[...n(this,r,"f",s)]}constructor(e,t,i,a,l=!0){this.name=e,this.maxWidth=t,this.maxHeight=i,this.reducer=a,this.rotational=l,this.megapixels=(0,o.lazy)((()=>(0,u.megapixels)(this.maxWidth*this.maxHeight))),this.max={width:t,height:i},n(r,r,"f",s).push(this)}[a.inspect.custom](){return{ctor:"ImageSize",name:this.name+" ("+this.reducer.name+")",maxDim:this.maxWidth+"×"+this.maxHeight,maxMP:this.megapixels()}}get aspectRatio(){return this.maxWidth/this.maxHeight}get maxPixels(){return this.maxWidth*this.maxHeight}get minDimension(){return Math.min(this.maxWidth,this.maxHeight)}outputSize(e){return this.reducer.reduce(this.rotational&&(0,l.isPortrait)(e)?(0,l.dimSwap)(this.max):this.max,e)}resize(e,t){return t.resize({...e,fit:this.reducer.fit,withoutEnlargement:!0})}toJpeg({path:e,sh:t,outputSize:i}){return((0,l.dmegapixels)(i)<2||d.Settings.previewSharpen.valueOrDefault)&&(t=t.sharpen()),t.jpeg((0,f.sharpRenderOptions)()).toFile(e)}toString(){return this.name}}t.ImageSize=m,r=m,s={value:[]},m.UHD8k=new r("uhd8k",7680,4320,h.Fit,!1),m.UHD5k=new r("uhd5k",5120,2880,h.Fit,!1),m.UHD=new r("uhd4k",4096,2160,h.Fit),m.QHD=new r("qhd",3120,1440,h.Fit),m.FHD=new r("fhd",1920,1080,h.Fit),m.HD=new r("hd",1280,720,h.Fit),m.WVGA=new r("wvga",720,480,h.Fit),m.QVGA=new r("qvga",320,240,h.Fit),m.QQVGA=new r("qqvga",160,120,h.Fit),m.S480=new r("s480",480,480,h.Square),m.S240=new r("s240",240,240,h.Square),m.S120=new r("s120",120,120,h.Square),m.S60=new r("s60",60,60,h.Square)},4192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includePreviewTags_=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(50213),o=i(56038),l=i(28874),u=i(47783),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.includePreviewTags")));t.includePreviewTags_=async function(e,t){!1===l.Settings.includePreviewTags.valueOrDefault||l.Settings.includedPreviewTags.isEmpty()||(0,s.isEmpty)(t)||(c().info("Re-adding metadata to previews..."),await(0,o.time)("img.includePreviewTags",(async()=>{const i=(0,n.pick)(await(0,u.readTags)(e),...l.Settings.includedPreviewTags.values),r=i?.capturedAt;null!=r&&(delete i.capturedAt,(0,n.assignFields)(i,r.asExifTag()));const s=i?.exposureSettings;null!=s&&(delete i.exposureSettings,i.FocalLength=s.focalLength,i.FNumber=s.aperture,i.ExposureTime=s.shutterSpeed,i.ISO=s.iso),l.Settings.includedPreviewTags.has("Source")&&(i.Source=e.nativePath),(0,n.isEmptyObj)(i)?c().warn("not adding tags to previews: no values for tags in source file",{src:e,includedPreviewTags:l.Settings.includedPreviewTags.values}):(c().info("Overwriting preview tags...",{src:e,writeTags:i}),await Promise.all(t.map((e=>(0,u.overwriteTags_)(e,i)))))})))}},78011:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.meanDiffHashCIELAB=t.meanDiffHash=t.dhash=t.mhash=void 0;const s=r(i(9288)),n=i(96249),a=i(59455),o=i(85810),l=i(70417),u=i(48368);function c(e){const t=(0,l.avg)(e);return null==t?[]:(0,a.toA)(e).map((e=>e>=t?1:0))}function d(e){const t=(0,a.toA)(e),i=Math.round(Math.sqrt(t.length));return t.map(((t,r)=>t>=(0===r?e[i]:r%i==0?e[r-i]:e[r-1])?1:0))}t.mhash=c,t.dhash=d,t.meanDiffHash=async function(e,t=u.HashDim){const i=await e.greyscale().resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer();return{meanHash:c(i),diffHash:d(i)}},t.meanDiffHashCIELAB=async function(e,t=u.HashDim){const i=await e.resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer(),r=(0,o.rgb2labArray)(i);return{meanHash:(0,n.flatten)(r.map(c)),diffHash:(0,n.flatten)(r.map(d))}}},52121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._prepFileForBrowser=t.prepFileForBrowser=void 0;const r=i(19851),s=i(78923),n=i(95696),a=i(50213),o=i(28874),l=i(12089),u=i(16170),c=i(13940),d=i(4192),h=i(5733),f=i(50961),m=(0,r.lazy)((()=>(0,a.mkLogger)("img.PrepareFileForBrowser")));async function p(e){try{const t=n.PosixFile.for(e.nativePath);if(await t.notExists())return;const i=e.mimetype??(await(0,s.readFileType_)(t.nativePath))?.mime;return(0,u.isMimeTypeSupportedByBrowser)(i,e.userAgent)?t.nativePath:(m().info("prepFileForBrowser(): non-browser-supported mimetype",{file:t,info:e}),(await(0,c.withImageCache_)(t,"web",".jpg",(async e=>{const i=await(0,f.sharpReadable_)({src:t});if(null==i)throw new Error("prepFileForBrowser(): can't read "+t.nativePath);await(0,f.toSharp)(i).jpeg((0,h.sharpRenderOptions)()).toFile(e.nativePath),o.Settings.includePreviewTags.valueOrDefault&&await(0,d.includePreviewTags_)(t,[e])})))?.nativePath)}catch(e){return void m().warn("prepFileForBrowser() failed",{error:e})}}t.prepFileForBrowser=(0,l.shim1)({name:"img.prepFileForBrowser",impl:p}),t._prepFileForBrowser=p},48604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildAssetPreviews_=t.Previews=void 0;const r=i(19851),s=i(55835),n=i(50213),a=i(12089),o=i(87290),l=i(95242),u=i(16524);class c{constructor(e){this.root=e}apb(e,t,i){return new l.AssetPreviewBuilder(this.ap(e),t,i)}ap(e){return new u.AssetPreviews(this.root,e)}}t.Previews=c,c.instance=(0,r.lazy)((()=>((0,n.mkLogger)("Previews").info(".instance()",{libraryPreviewsDir:(0,o.libraryPreviewsDirPosixFile)()}),(0,s.map)((0,o.libraryPreviewsDirPosixFile)(),(e=>new c(e)))))),t.buildAssetPreviews_=(0,a.shim1)({name:"img.buildAssetPreviews",impl:e=>c.instance().apb(e.assetId,e.assetFiles,e).build_()})},2090:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(34666),o=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,n.isNumber)(e)?e:((0,n.toGt0)(e.width)??0)/((0,n.toGt0)(e.height)??0),(e=>(0,o.leastBy)(t.StandardAspectRatios,(t=>{const r=Math.abs(e-t);return r>i?void 0:r}))??e))}function c(e,i,r=t.RatioEpsilon){return(0,a.lt)((0,n.absdiff)(u(e),u(i)),r)}function d(e,i){return(0,o.leastByCtx)(t.Ratios,(t=>{const r=Math.abs(t.i-e);return r[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,s.maybeDimSwap)(e.dimensions,e.rotation),(0,s.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,n.sigFigs)(e,3))}},34943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const r=i(19851),s=i(31586),n=i(80049),a=i(50213),o=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),h=(0,r.lazy)((()=>(0,a.mkLogger)("img.RawInfo"))),f=(0,r.lazy)((()=>new n.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:o.ShortCommandTimeoutMs})));async function m(e){return f().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,r,n,a]=e.split("\t"),o=(0,s.toGt0)(n),l=(0,s.toGt0)(a);return null==o||null==l?h().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):h().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:r,ImageSize:{width:o,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>f.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?f.prior()?.clear():f.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{h().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},32876:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Reducers=t.Fit=t.fitInsideToMaxPixels=t.fitInsideToAspectRatio=t.Square=t.SharpFits=void 0;const r=i(19851),s=i(33374),n=i(4188),a=i(11371),o=i(31586),l=i(68708),u=i(50989),c=i(50213),d=i(86580);var h,f;t.SharpFits=(0,u.strEnum)("cover","contain","fill","inside","outside"),function(e){const i=(0,r.lazy)((()=>(0,c.mkLogger)("img.Reducers.Square")));e.name=a.ReducerNames.sq,e.fit="cover",e.reduce=function(e,r){const s=(0,d.lteBoth)(e,r)?{...e,fit:t.SharpFits.cover}:void 0;return i().tap({msg:"reduce()",result:s,meta:{max:e,input:(0,l.pick)(r,"width","height","nativePath")}})}}(h||(t.Square=h={})),t.fitInsideToAspectRatio=function(e,t){return e.width/e.height>=t?{width:Math.floor(e.height*t),height:e.height}:{width:e.width,height:Math.floor(e.width/t)}},t.fitInsideToMaxPixels=function(e,t){if(null==e||!(0,o.gt0)(e.width)||!(0,o.gt0)(e.height))return;if((0,s.pixels)(e)(0,c.mkLogger)("img.Reducers.Fit")));e.name=a.ReducerNames.fit,e.fit="inside",e.reduce=function(e,i){if(!(0,d.ltBoth)(i,e))return(0,n.fitInside)(i,e);t().trace(`reduce(): input ${(0,s.fmtDim)(i)} is too small for ${(0,s.fmtDim)(e)}`)}}(f||(t.Fit=f={})),t.Reducers=[h,f]},5733:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const s=r(i(9288)),n=i(19851),a=i(41400),o=i(50213),l=i(28874),u=i(15674),c=(0,n.lazy)((()=>(0,o.mkLogger)("img.Sharp")));function d(e,t){return(0,s.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,n.lazy)((()=>{s.default.simd(l.Settings.enableSIMD.valueOrDefault),s.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),s.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,a.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},50961:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractImageForThumbs_=t.sharpReadable_=t.toSharp=t.imgFromExif_=t._imgFromExif_=void 0;const s=i(77988),n=r(i(9288)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(33374),d=i(98553),h=i(31586),f=i(68708),m=i(51926),p=i(41583),g=i(50213),y=i(97352),w=i(56519),v=i(56038),b=i(57159),S=i(95696),P=i(17217),M=i(28874),_=i(47783),T=i(16170),E=i(95141),D=i(54979),k=i(1078),x=i(63870),F=i(86580),C=i(277),A=i(16047),I=i(13940),O=i(5733),L=i(66106),R=i(19350),N=(0,a.lazy)((()=>(0,g.mkLogger)("img.SharpReadable")));async function B(e,t,i){return i?await(0,_.exiftool)().extractBinaryTagToBuffer(t,e.nativePath):(await z(e,t))?.nativePath}async function j(e,t,i,r,a){const o=t?.[i];if(!(o instanceof s.BinaryField))return;const l=o.bytes(0,_.extractBinaryTag)(t,e.nativePath,i.nativePath),timeoutMs:(0,x.commandTimeoutMs)()})}catch(i){return void N().throw("Failed to extract embedded "+t+" from "+e.nativePath,{error:i})}}t._imgFromExif_=B,t.imgFromExif_=j,t.toSharp=function(e){const t=e;if((0,O.isSharp)(t.sharp))return t.sharp;if((0,P.isSimpleFile)(t.file))return(0,n.default)(t.file.nativePath,{failOn:M.Settings.imageFailOn.valueOrDefault});throw new Error("toSharp(): not a Sharp object: "+(0,d.stringify)(e))},t.sharpReadable_=function(e){return(0,v.time)(`img.sharpReadable${e.src.ext.toUpperCase()}`,(()=>async function({src:e,minDim:t,skipEmbedded:i}){const r=N().addParameterContext(e.nativePath);(0,O.setupSharp)();const n=await(0,D.readMimeType)(e);if((0,u.blank)(n))return r.throw(e+" is not supported (missing MIMEType)",{doNotSend:!0});const a=await(0,k.extractSizeInfoFromFile)(e);if(null==a)return void r.warn("Failed to extract size info from "+e);const d=[];function f(e,t){t.desc=e,d.push(t)}const m=a.rotation,g=(0,T.isVideoMimeType)(n),S=(0,T.isLibrawMimeType)(n),P=a.dimensions,x=t??(0,y.map2Gt0)(P.width,P.height,((e,t)=>({width:Math.round(.9*e),height:Math.round(.9*t)})));if(null==x?.width||null==x?.height)return r.throw(e+" is not supported (missing dimensions)",{dim:x,doNotSend:!0,mimetype:n,isRaw:S,isVideo:g});const I=(0,F.aspectRatio)(a.fileDimensions),B=(0,h.lt)(I,1),z=(0,T.isSharpMimeType)(n)&&null==t,V=(0,E.orientationRequiresMirroring)(a.orientation);if(!0===i||g||B||z||V)r.debug("not pulling previews from tags",{isVideo:g,isFilePortrait:B,isSharpMimeAndNoMinDim:z,isMirrorOrientation:V});else{const i=!1,n=await(0,_.readRawTags)(e,i);if(null==n)r.warn("Cannot pull previews from tags: readRawTags() failed");else{const i=[...M.Settings.embeddedPreviews.values];null!=t&&(0,c.dmegapixels)(t)<1&&i.unshift(...M.Settings.embeddedThumbnails.values);const a=x.width*x.height*.2,u=x.width*x.height*.05,d=(0,l.sortBy)(i.filter((e=>n[e]instanceof s.BinaryField)),(e=>{const t=n[e]?.bytes;return(0,h.gt)(t,u)?Math.abs(t-a):void 0}));if(!(0,o.isEmpty)(d)){r.debug("checking previews from tags",{sizeSortedTagNames:d});for(const t of d)f("imgFromExif."+t,(()=>j(e,n,t,x,I)))}}}(0,T.isSharpMimeType)(n)&&f("sharp",(async()=>({file:e}))),(0,A.isHeifMimeType)(n)&&await(0,C.isHeifSupported)()&&f("heif",(()=>(0,w.thenMap)((0,C.heif2img)(e),(e=>({file:e}))))),S&&f("raw2tiff",(()=>(0,w.thenMap)((0,R.raw2tiff_)(e),(e=>({file:e}))))),g&&f("extractVideoFrame",(async()=>{if(await(0,L.isVideoSupported)())try{return await(0,w.thenMap)((0,L.extractVideoFrame_)(e),(e=>({file:e})))}catch(t){throw new b.WrappedError("Failed to extract video frame for "+e,t)}else r.warn("video file, but video support is missing",{src:e.nativePath,mimetype:n,minDim:t})}));const W=[];for(const i of d)try{const s=await(0,v.time)("img.read."+i.desc,i);if(null!=s)return r.debug(i.desc+" strategy succeeded",{src:e,minDim:t,rot:m,img:s.file?.nativePath}),{desc:i.desc,rot:m,mimetype:n,...s};r.debug(i.desc+" returned null",{src:e,minDim:t,rot:m})}catch(e){r.warn(i.desc+" failed",e),W.push((0,p.toErr)(e))}throw new b.WrappedError("Failed to render "+e,{causes:W,path:String(e),fatal:!1,doNotSend:!0,retriable:!1})}(e)))},t.extractImageForThumbs_=z},21473:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.testSharp_=void 0;const s=r(i(34589)),n=i(76760),a=r(i(9288)),o=i(50357),l=i(98553),u=i(68708),c=i(23560),d=i(43899),h=i(28874),f=i(5733);t.testSharp_=async function e(t){try{(0,f.setupSharp)();const e=t??(0,n.join)(d.ProjectPath.Public(),"images","logo@5x.png"),i=(0,a.default)(e,{failOn:"error"}),r=await i.resize(24,32,{fit:"cover",position:"attention"}).toFormat("jpeg").toBuffer({resolveWithObject:!0});(0,s.default)((0,o.eql)((0,u.pick)(r.info,"format","width","height","channels"),{format:"jpeg",width:24,height:32,channels:3}),"Unexpected sharp output: "+(0,l.stringify)(r.info))}catch(i){if(!(0,c.isWorkerService)()&&h.Settings.enableSIMD.valueOrDefault)return h.Settings.enableSIMD.envValue=!1,e(t);throw i}}},181:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.whyInvalidFile=t.clearInvalidFileCache=t.throwIfInvalidFile_=t.isValidFile=void 0;const s=r(i(9288)),n=i(19851),a=i(22573),o=i(42659),l=i(98553),u=i(50213),c=i(12089),d=i(81168),h=i(57159),f=i(88561),m=i(95696),p=i(17217),g=i(28874),y=i(16170),w=i(54979),v=i(63870),b=i(5733),S=i(50961),P=i(66106),M=i(51210),_=(0,n.lazy)((()=>(0,u.mkLogger)("img.ValidFile")));t.isValidFile=async function(e){return(0,a.blank)(await(0,t.whyInvalidFile)((0,p.toNativePath_)(e)))},t.throwIfInvalidFile_=async function(e){if(!g.Settings.validateJpegImages.valueOrDefault&&!g.Settings.validateRawImages.valueOrDefault&&!g.Settings.validateVideos.valueOrDefault)return void _().debug("file validation is disabled for "+e,{validateJpegImages:g.Settings.validateJpegImages.valueOrDefault,validateRawImages:g.Settings.validateRawImages.valueOrDefault,validateVideos:g.Settings.validateVideos.valueOrDefault});const i=(0,p.toNativePath_)(e),r=_().tap({msg:"whyInvalidFile("+i+")",result:await(0,t.whyInvalidFile)(i)});(0,a.notBlank)(r)&&_().throw(r,{path:i,retriable:!1,doNotSend:!0,ignorable:!0})};const T=(0,n.lazy)((()=>new f.FileCache({name:"img.validFile",maxSize:256,timeoutMs:Math.max(o.minuteMs,g.Settings.validateVideos.valueOrDefault?5*o.minuteMs:(0,v.commandTimeoutMs)())})));t.clearInvalidFileCache=function(){return T().clear()},t.whyInvalidFile=(0,c.shim1)({name:"img.whyInvalidFile",cache:T,toKey:p.toNativePath_,impl:async e=>{const t=m.PosixFile.for(e);if(!await t.isFile()||!await t.isReadable())return t+" is not a readable file";if(await t.isEmpty())return t+" is empty";try{const e=await(0,w.readMimeType)(t);if(null==e)throw new Error("Cannot validate, no mimetype");if((0,y.isVideoMimeType)(e))g.Settings.validateVideos.valueOrDefault&&(_().debug("validating "+t),await(0,P.validVideo_)(t));else{if(!e.startsWith("image/"))throw new Error("Unsupported mimetype "+(0,l.stringify)(e));if("image/jpeg"===e)g.Settings.validateJpegImages.valueOrDefault&&await(0,M.validJpeg_)(t);else if(g.Settings.validateRawImages.valueOrDefault)if((0,d.includesIgnoreCase)(g.Settings.validateMimetypeSkiplist.values,e))_().info("Skipping validation of "+t+": validateMimetypeSkiplist matches",{mime:e});else{const e=await(0,S.sharpReadable_)({src:t,skipEmbedded:!0}),i=await async function(e,t=g.Settings.imageFailOn.valueOrDefault){const i=e;if((0,p.isSimpleFile)(i.file))return(0,s.default)(i.file.nativePath,{failOn:t});if((0,b.isSharp)(i.sharp)){const{data:e,info:t}=await i.sharp.raw().toBuffer({resolveWithObject:!0});return(0,s.default)(e,{...t,failOnError:!0})}throw new Error("Cannot read input "+e?.desc)}(e);await i.tiff().toBuffer()}}return""}catch(t){return new h.WrappedError("Failed to validate",{cause:t,path:e,doNotSend:!0}).toS()}}})},19769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const r=i(19851),s=i(40958),n=i(41400),a=i(50213),o=i(68852),l=i(98314),u=i(28874),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:h().test(t)||!d().test(t),meta:{err:e,allow:h().test(t),block:d().test(t),validationErrorAllowlist:h().source,validationErrorBlocklist:d().source}})};const d=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),h=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,n.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>h.unset()))}))},66106:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const r=i(19851),s=i(40958),n=i(38639),a=i(42659),o=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),h=i(7282),f=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),w=i(56038),v=i(31562),b=i(34102),S=i(88561),P=i(95696),M=i(17217),_=i(31843),T=i(70417),E=i(33847),D=i(28874),k=i(94678),x=i(43207),F=i(47783),C=i(16170),A=i(95141),I=i(1078),O=i(63870),L=i(89782),R=i(13940),N=i(34592),B=(0,r.lazy)((()=>(0,d.mkLogger)("img.Video")));function j(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function z(e){return(0,h.isProd)()&&(e=void 0),(0,n.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=z,t.isVideoSupported=(0,r.lazy)((async()=>{try{return!0===(await z())?.isSupportedVersion}catch(e){return B().warn("isVideoSupported",{error:e}),!1}})),(0,o.later)((()=>(0,b.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,_.lerp2d)(e,{x:76800,y:D.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:D.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,r.lazy)((()=>new S.FileCache({name:"img.videoFrame",timeoutMs:a.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,M.toNativePath_)(e))):void 0}async function U(e,t){const i=j("extractVideoFrame",e),r=P.PosixFile.for(e);if(!(0,n.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const s=await(0,R.cachedImageFile_)(r,"frame",".jpg");i.debug("extractVideoFrame("+s+")");const o=await r.mtimeMs();if(null==o)return i.throw("null mtime");const l=await(0,F.readRawTags)(r,!1);if(null==l)return i.throw("no tags");const u=(0,A.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,I.extractSizeInfoFromTags)(l,u)?.dimensions,d=await s.stat(),h=null==d?void 0:await(0,L.dimensions)(s);if(null!=d&&d.mtimeMs>o&&null!=h&&(null==c||h.height===c.height&&h.width===c.width))return i.debug("prior dest, "+s+" seems reasonable",{srcDim:c,destDim:h}),s.nativePath;const f=(0,x.extractDurationSec)(l),m=Math.min(f??0,D.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:f}),await s.applyIfEmpty_({fn_:async e=>{const t={src:r,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,v.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*a.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,F.deleteAllTags_)(e,e)},timeoutMs:(0,O.commandTimeoutMs)()}),s.nativePath}async function q(){return D.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function H(e){const t=j("needsTranscoding",e);if(!await q())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,F.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const r=i.MIMEType;if(!(0,C.isVideoMimeType)(r))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:r}});const n=(0,x.extractDurationSec)(i);if(!(0,c.gt)(n,D.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:n}});const a=(0,s.compactBlanks)([i.AudioFormat]),o=a.some((e=>(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,s.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(D.Settings.doNotTranscodeMimeTypes.values,r);return t.tap({level:"info",msg:"result",result:!(o&&u&&d),meta:{mimetype:r,isSafeMimeType:d,audioCodecs:a,isSafeAudioCodec:o,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>U(e)}),t.__extractVideoFrame_=U,t.isVideoTranscodingSupported=q,t.needsTranscoding=H;const G=new g.TTLMap(a.hourMs);function $(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,r){if(!await q())return;const s=j("transcode",e);{!function(){for(const[e,t]of G.entries())t.isSettled&&G.delete(e)}();const t=G.get(e.nativePath)??G.get(i.nativePath);if(null!=t)return s.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await H(e))return void s.info("no transcoding needed");const n=await e.size();if(!(0,u.gt0)(n))return s.throw("source is empty or cannot read");const a=await(0,F.readTags)(e),o=(0,I.extractSizeInfoFromTags)(a),d=(0,x.extractDurationSec)(a);if(null==a||null==o||null==d)return s.throw("failed: missing video metadata",{sizeInfo:o,durationSec:d});{const e=G.get(i.nativePath);if(null!=e)return s.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const h=new y.Deferred("transcode "+e);G.set(e.nativePath,h),G.set(i.nativePath,h);const m=(0,u.toGt0)(a.VideoFrameRate)??(0,u.toGt0)(a.FrameRate)??30,p=Math.round(o.dimensions.width*o.dimensions.height*(0,T.max)([(0,u.toGt0)(a.FrameCount),(0,u.toGt0)(a.VideoFrameCount),m*d]));if(!0===r?.force)await i.unlink();else if(await async function(e,t){const i=await(0,F.readRawTags)(t),r=await(0,F.readRawTags)(e),s=(0,x.extractDurationSec)(r),n=(0,x.extractDurationSec)(i);return B().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(s,n,1.5),meta:{srcDurationSec:s,destDurationSec:n,src:e.nativePath,dest:t.nativePath}})}(e,i))return s.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const r=j("extractMaxBitrate",e),s=D.Settings.minVideoDimension.valueOrDefault,n=i.ImageWidth;if(null!=n&&!(0,u.gte)(n,s))return r.throw("invalid width: "+n,{ignorable:!0});const a=i.ImageHeight;if(null!=a&&!(0,u.gte)(a,s))return r.throw("invalid height: "+a,{ignorable:!0});const o=(0,k.extractBitrateKbps)(i)??D.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,f.mapGt0)(n,(e=>(0,f.mapGt0)(a,(i=>(0,u.clamp)(0,o,(0,t.bitrateKps)(e*i)))))),c={width:n,height:a,videoBitrateKbps:l};return r.debug("dim()",{src:e,result:c}),c}(e,a);return await h.observe((0,w.time)("video.transcode:"+e,(async()=>{const t=$(n,g.videoBitrateKbps,d);return await i.applyWip_({fn_:n=>async function(n){s.info("starting...",{destWip:n});const o=new E.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:n,fps:m,halt:r.halt,...g},h=D.Settings.transcodeMaxDim.valueOrDefault,f=(0,T.max)([a.dimensions.height,a.dimensions.width]);if((0,u.gt0)(h)&&(0,c.gt)(f,h)){const e=(0,l.fitInside)(a.dimensions,{width:h,height:h});null==e?s.warn("Cannot downsample transcoded video: fitInside() returned null",{input:a.dimensions,maxPixels:h}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),s.info("Downsampling transcoded video",{original:a.dimensions,output:e}))}const p=await o.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&s.throw("transcode failed with code "+p.code)}(n),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&s.info("transcode complete",{src:e,dest:i,elapsedMs:h.elapsedMs,pixels:p}),i},t.guessExpectedSize=$,t.validVideo_=async function(e){return null==await W(e)&&j("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),h=i(56519),f=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),w=i(84258),v=i(28874),b=i(76280),S=i(63870),P=i(19769),M=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function _(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:v.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=_;const T=/ffmpeg version n?(?\S+)/i,E=(0,u.lazy)((async()=>{const e=await _();if(null==e)return void M().info("failed to find ffmpeg in $PATH",{ffmpegPath:v.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,S.commandTimeoutMs)(),ignoreStderr:!0}),i=T.exec(t.result)?.[1];return M().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,b.semverSatisfies)(i,">=3.2")}}));function D(){E.unset(),t.ffmpegVersionDescription.unset()}function k(e){const t=e?.ffmpegHwaccel??v.Settings.ffmpegHwaccel.valueOrDefault;return(0,s.blank)(t)||(0,n.isDisabled)(t)?[]:["-hwaccel",t]}function x(e){const t=[...v.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(v.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),r=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+r),t}function F(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function C(e){const t=v.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,h.thenMapOr)(E(),(e=>"version "+e),(()=>"(not found)")))),(0,o.later)((()=>{(0,g.ee)().on("clearCache",D),(0,g.ee)().on("clearToolCache",D)})),t.ffmpegVersion_=async function(){return await E.prior()??E.refresh()},t.isFFmpegSupported=async function(){return null!=await E()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,r.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:a.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,f.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*a.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=x,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,r.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...x(t),...C(t),...k(t),"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),...F(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){M().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,w.unlink)(t.dest,"debug");const r=(0,p.errorToS)(i,{maxLen:1024});if(!(0,n.isDisabled)(t.ffmpegHwaccel??v.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(r))return M().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return M().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await _(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(v.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},51210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotate_=t.rotateInPlace_=t.validJpeg_=t.jpegtranVersion_=void 0;const r=i(19851),s=i(42659),n=i(21605),a=i(50213),o=i(84777),l=i(57159),u=i(95696),c=i(89966),d=i(43334),h=i(63870),f=i(19769),m=d.isWin?"NUL":"/dev/null",p=(0,r.lazy)((()=>(0,a.mkLogger)("img.jpegtran")));async function g(e,t,i){const r=await(0,c.jpegtranNativePath_)();if(!(0,n.isRotation)(i))throw new Error("refusing to rotate("+e+", "+i+")");await(0,o.stdout_)(r,["-copy","all","-trim","-rotate",i.toFixed(0),"-outfile",t.nativePath,e.nativePath],{timeoutMs:s.minuteMs}),t.clear()}t.jpegtranVersion_=async function(){const e=await(0,o.stdoutResult_)(await(0,c.jpegtranNativePath_)(),["-version"],{quiet:!0,timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:()=>!0});return(e.stderr??e.result).replace(/^libjpeg-turbo version/,"").trim()},t.validJpeg_=async function(e){const t=u.PosixFile.for(e),i=await(0,c.jpegtranNativePath_)();try{await(0,o.stdoutResult_)(i,["-outfile",m,t.nativePath],{timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:f.isIgnorableValidationError,ignoreExitCode:!0})}catch(e){throw p().warn("validJpeg caught invalid file",{src:t,cause:e}),new l.WrappedError("Invalid JPEG: "+t,{cause:e,path:t.nativePath,doNotSend:!0,fatal:!1,retriable:!1})}},t.rotateInPlace_=async function(e,t){p().info("rotateInPlace("+e+")",t),await e.applyWip_({fn_:i=>g(e,i,t),skipFsLock:!1,minSizeBytes:512,timeoutMs:s.minuteMs})},t.rotate_=g},19350:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dcraw_emu_=t.raw2tiff_=t.librawSupported=void 0;const r=i(19851),s=i(40958),n=i(33374),a=i(12168),o=i(23541),l=i(54993),u=i(50213),c=i(84777),d=i(98314),h=i(38835),f=i(57159),m=i(89966),p=i(28874),g=i(16170),y=i(54979),w=i(89782),v=i(13940),b=i(42725),S=i(19769),P=(0,r.lazy)((()=>(0,u.mkLogger)("img.libraw")));t.librawSupported=async function(e){try{return(0,g.isLibrawMimeType)(await(0,y.readMimeType)(e.nativePath))}catch(t){return P().warn("librawSupported("+e+"): failed to read filetype",t),!1}},t.raw2tiff_=async function(e){return(0,v.readableToFile_)({src:e,desc:"dcraw",suffix:".tiff",f:t=>D(e,t)})};const M=["-T"],_=["-Z","-"],T=["-o","1"],E=["-t","0","-j"];async function D(e,t){const i=await(0,w.dimensions)(e);if(null==i)return P().throw("Cannot decode RAW "+e+": no EXIF dimensions."+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);const r=b.ImageSize.largestFit().outputSize(i),u=[];null!=r&&4*(0,n.dmegapixels)(r)<(0,n.dmegapixels)(i)&&(P().debug("Large original source: using -h"),u.push("-h"));const g=await(0,m.dcrawEmuNativePath_)(),y=[...M,..._,...T,...u,...E,...p.Settings.dcrawEmuArgs.values,e.nativePath],v={encoding:"buffer",timeout:p.Settings.taskTimeoutMs.valueOrDefault,maxBuffer:250*a.MB};P().debug("dcraw_emu()",{cmd:g,args:y,opts:v});const D=(0,c.execFile)(g,y,void 0,v),k=[];function x(t){const i=(0,o.isError)(t)?(0,d.errorToS)(t):(0,l.toS)(t);if((0,S.isIgnorableValidationError)(i))P().info("dcraw_emu(): warning",{src:e,msg:i});else{P().warn("dcraw_emu(): error",{src:e,msg:i});const r=(0,o.isError)(t)?t:(0,f.toWrappedError)(i,{fatal:!1});k.push(r)}}if(D.on("error",x),D.stderr.on("data",x),await t.writeStream_(D.stdout),(0,s.isNotEmpty)(k))throw new f.WrappedError("Failed to convert RAW image "+e,{causes:k,path:e.nativePath});(0,c.endProcess)(D)}t.dcraw_emu_=D},36192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const r=i(19851),s=i(84777),n=i(8103),a=i(43334),o=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,r.lazy)((async()=>a.isMac?(0,n.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,s.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(o.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},71706:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.j=void 0;const r=i(38522);t.j=function(e){return JSON.parse((0,r.brotliDecompressSync)(Buffer.from(e,"base64")).toString("utf8"))}},42042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEmail=void 0;const r=i(22573),s=i(28874),n=i(81674);t.getEmail=async function(){const e=s.Settings.email.value;if((0,r.notBlank)(e))return e;for(const e of await(0,n.m)())if((0,r.notBlank)(e.l?.sub))return e.l?.sub}},83950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.L=void 0;const r=i(79114),s=i(40958),n=i(42659),a=i(34666),o=i(48884),l=i(97352),u=i(81674),c=i(84194);t.L=class{static for(e){return new this(e.str,e.l,e.sids,e.src)}constructor(e,t,i,r){this.s=e,this._l=t,this._sids=i,this.meta={src:r}}get l(){return this._l}get ok(){if(null==this._l)return!1;const e=(0,o.intersection)(this._sids,this._l.uids),t=(0,s.uniq)(e.map(c.getScheme)),i=(0,s.compact)(t.map((e=>(0,c.prefix2scheme)(e)))),r=i.length>=this._l.mat,a=(0,l.within)(this._l.iat?.getTime(),this._l.exp?.getTime()+n.dayMs,Date.now());return this.meta[(0,u.k)().o]=a,this.meta[(0,u.k)().u]=r,this.meta[(0,u.k)().m]=i,a&&r}cmpVal(){return[this.ok,-(r.S.indexOf(this.l?.[(0,u.k)().T])??0),this.l?.exp?.getTime()??1,this.meta.matchedSchemes]}cmp(e){return(0,a.cmp)(this.cmpVal(),e.cmpVal())}}},81674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p=t.l=t.t=t.b=t.m=t.vok=t.v=t.v_=t.k=void 0;const r=i(76790),s=i(22573),n=i(38639),a=i(45599),o=i(41400),l=i(96249),u=i(55835),c=i(31586),d=i(51926),h=i(79114),f=i(23541),m=i(59455),p=i(54993),g=i(72993),y=i(19851),w=i(50213),v=i(56519),b=i(76596),S=i(46292),P=i(87290),M=i(77740),_=i(34102),T=i(83278),E=i(28874),D=i(37692),k=i(71706),x=i(83950),F=i(72042),C=i(33603),A=i(48132);t.k=(0,y.rolazy)((()=>(0,k.j)("G1UBABwHdkz4hUIkFCfPXW5LlfvrWKSr9W3AIyIhUiw68NDfvLLHVop/bGoNnRxQlnqi2TZp0IJaX+lUHBoi+vMy2LMNpHCv8xVkUGsmQsgB8ldHoDqJeUQzbdybwikWVRs2KSWKjE5LnuqhTNSp3gTLhNfE9EqBLeaXP+UM9YqTGSXcyrcL03rIPMDAVyJplSZC0xoUgguOYJKvrcYFbNArN7BrQsnnsJ4hMtcSxOTxxRdxzETtL93qa3vjDw==")));const I=(0,a.defer)((()=>(0,w.mkLogger)((0,t.k)().l)));async function O(e){const i=await(0,F.V)((0,d.ensurePrefix)((0,p.toS)(e).trim(),(0,t.k)().p)),r=(0,b.utcIsoToTs)(i[(0,t.k)().i]);if(null==r)throw new Error("bad "+(0,t.k)().i+": "+i[(0,t.k)().i]+" ("+e+")");const s=(0,b.utcIsoToTs)(i[(0,t.k)().r]);if(null==s)throw new Error("bad "+(0,t.k)().r+": "+i[(0,t.k)().r]+" ("+e+")");return(0,M.getDevEnvFlag)((0,t.k)().y)&&(i[(0,t.k)().t]=!0),i[(0,t.k)().a]=(0,c.toGte0)(i[(0,t.k)().a])??2,i[(0,t.k)().i]=new Date(r),i[(0,t.k)().r]=new Date(s),i[(0,t.k)().b]=(0,p.toS)(i.uids).split(","),i}async function L(e,i,r,n){try{return(0,s.blank)(e)||e===(0,t.k)().f?void 0:x.L.for({str:e,l:await O(e),sids:null!=n?n:await(0,C.sids)({timeoutMs:r}),src:i})}catch(i){return I().tap({msg:(0,t.k)().v,result:{s:e,ok:!1,meta:{err:i}}})}}async function R(e,t){const i=[],r=await(0,v.sortByAsync)({name:"rawLicenseFromDir("+e+")",arr:e?.childFiles(),f:e=>e.mtimeMs()});for(const e of r.reverse()){const r=await L((0,m.toA)(await e.readLines()).map((e=>e.trim())).join(""),e.nativePath,A.UserTimeoutMs,t);null!=r&&i.push(r)}return i}async function N(){const e=await(0,t.m)();return e[0]?.ok?e[0]:void 0}async function B(){return(await N())?.l?.[(0,t.k)().T]??(0,t.k)().f}t.v_=O,t.v=L,t.vok=async function(e,t,i){if((0,s.blank)(e))return;const r=await L(e,t,i);return(0,n.isTrue)(r?.ok)&&r instanceof x.L?r:void 0},t.m=(0,y.rolazy)((async()=>{if((0,M.getDevEnvFlag)((0,t.k)().x))return[];const e=await(0,C.sids)({timeoutMs:A.UserTimeoutMs}),i=(0,u.map)((0,S.configDir)(),(e=>T.BaseFile.for(e))),s=(n=(0,l.flatten)((await(0,v.someOrTimeout)([()=>function(e){return L(E.Settings[(0,t.k)().L].value,"Settings",A.UserTimeoutMs,e)}(e),()=>R(i?.join((0,t.k)().d),e),()=>R((0,P.libraryDataDirPosixFile)()?.join((0,t.k)().d),e),()=>R(i?.sibling((0,g.AppName)().toLowerCase()).join((0,t.k)().d),e)],{timeoutMs:A.UserTimeoutMs})).filter((e=>!(e instanceof Error)))),(0,r.sortBy)(n.filter((e=>null!=e&&((0,f.isError)(e)&&I().warn((0,t.k)().d+": ",e),null!=e&&!(0,f.isError)(e)&&null!=e?.l))),(e=>[!e.ok,h.S.indexOf(e.l?.[(0,t.k)().T])??h.S.length+1,-(e.l?.exp?.getTime()??1)])));var n;return I().tap({msg:(0,t.k)().d+"()",result:s})})),(0,o.later)((()=>{(0,_.ee)().on("clearCache",(()=>t.m.unset())),(0,_.ee)().on((0,t.k)().c,(()=>t.m.unset())),D.stateEvents.on((0,t.k)().c,(()=>t.m.unset()))})),t.b=N,t.t=B,t.l=async function(){try{return await B()===(0,t.k)().f}catch{return!0}},t.p=async function(){try{return await B()===(0,t.k)().g}catch{return!1}}},72042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.V=t.l=void 0;const r=i(91227),s=i(19851),n=i(22573),a=i(71706);t.l=(0,s.lazy)((()=>(0,a.j)("G54BgBwHzrkukKDR8Ar6KkW29gbXlfrqQX46gTu5Wfq6dELYTjfBokB0d5+E2SAINBtxlmPquWe3PMUoNgaJrD982QMslkNeZ4BEqcBbQT59DVl9RnoTNi50diuT7NQg0YHxkr8SwDwtmFUOf+LwNVDDnPXUrzTOU++M3b+lcyfr7PXZndKHzho8iztNkZgt+/19//aXe+gvmC0HIdnn64wdLeYeLM7S9jmjTp52SzFsvIVbd4D0+rdtdjiz6R4vc2cmY398kuXiKG7fNXWS/I93etxXiVNPd4RXJF+k6JnuMUKk03GWHQQ="))),t.V=function(e){const i=(0,r.decode)(e).payload;if(null==i)throw new Error("Missing payload");const s=(0,n.notBlankOr)(i.k,(0,t.l)().d),a=(0,t.l)().o.find((e=>e.k===s));if(null==a)throw new Error("Unknown key");return r.V2.verify(e,a)}},84194:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SchemeCounts=t.isValidUid=t.toUID=t.UidLength=t.prefix2scheme=t.sortUids=t.getScheme=t.S=void 0;const n=i(40958),a=i(76790),o=i(22573),l=i(45599),u=i(50989),c=i(54993),d=i(22454),h=i(19851),f=i(50213),m=i(37628),p=i(55222),g=i(71706),y=(0,l.defer)((()=>(0,g.j)("GyABAIzUYs0Z7mSuLfVL1SwGefr+3nCwyXBMg6nD0qduA8HycFjUGK1N/ikYqhiqYLGbs7oxTBbzRPxteP9gA3L9DS0EJ2BJ1pYNa/DtEE2aPI2o03hHx3k9MhdE7jAeRUvKQ6tY3Q1fcIPe8GBMZvOeKibTymyo3Cw/7Ua42DKPjpL3wxWv+7TCGA==")));function w(e){const i=e.split(":",1)[0];return t.S.has(i)?i:void 0}t.S=(0,u.strEnum)("cu","lc","lm","lp","lb","mp","ms","wm","cm","bm","nm","li","si","vl"),t.getScheme=w,t.sortUids=function(e){return(0,a.sortBy)((0,n.uniq)(e.filter(S)),(e=>[t.S.indexOf(w(e))??t.S.length+1,e]))},t.prefix2scheme=function(e){return y()[e]};const v=["uninitialized","b08dfa6083e7567a1921a715000001fb"];t.UidLength=15,t.toUID=function(e,i){try{const r=(0,c.toS)(i).replace(/[^a-z\d=/+]+/gi,"");return(0,o.blank)(r)||v.includes(r.toLowerCase())||null!=r.match(/^[\s0:_/-]*$/)?void 0:e+":"+(0,m.shortStringSha)(r,t.UidLength,p.Radix58)}catch(t){return void(0,f.mkLogger)("toUID").warn("failed",{pfx:e,err:t})}};const b=(0,l.defer)((()=>new RegExp(`^(?:${t.S.values.join("|")}):[0-9a-zA-Z]{${t.UidLength}}$`)));function S(e){return null!=e&&null!=b().exec(e)}t.isValidUid=S,t.SchemeCounts=class{constructor(e){r.set(this,new Set),this.schemeCounts=(0,h.lazy)((()=>{const e=new d.CountingSet;for(const t of s(this,r,"f")){const i=w(t);null!=i&&e.incr(i)}return e})),null!=e&&this.addUids(e)}get size(){return s(this,r,"f").size}addUids(e){for(const t of e)null==w(t)||s(this,r,"f").has(t)||(s(this,r,"f").add(t),this.schemeCounts.unset())}count(e){return this.schemeCounts().get(e)}},r=new WeakMap},33603:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearSids=t.addSids=t.sids=t.win_machineGuid_=t.readInfo=t.k=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(45599),o=i(96249),l=i(68708),u=i(51926),c=i(59455),d=i(54993),h=i(50213),f=i(7282),m=i(56519),p=i(84777),g=i(84542),y=i(19254),w=i(45879),v=i(70854),b=i(57902),S=i(72308),P=i(43334),M=i(24399),_=i(7014),T=i(30933),E=i(71706),D=i(84194);t.k=(0,a.defer)((()=>(0,E.j)("G9ABYIzDOIZ8NLQ4t7qW8tNrmrOzz+qFGfAxl8jW4E2tLxwWRZT5TueCnPcwgTzT1DN3veRB+e7EYGlYHg6nhjBDQv7zI6EcYWk35z6QuZC3Q0itjrLCbmgd0iED0BvGiYLBJwRU1O9/3Agbl8IfG6ITVFWDRwyTw3rbUMo/XMyAVW7R23mkwUx0l4/7iA13RV/nmPuJFKp5BvJW7SoXJZoWEfdSNYYhN5UCtkbC7O1AaPIbU3P6uRLmEyb4TaHWzFigvrlmZVUzzp9j/Mz55vqN88ewd1Nrfh7gkVRQ7TtB7Ztz3XJxYC3ogdJHg8HGsG4=")));const k=(0,a.defer)((()=>(0,h.mkLogger)((0,t.k)().n)));async function x(e=(0,t.k)().pc){if(P.isLinux)try{const t=await(0,y.fileGrep_)(e,/^\s*(?:hardware|revision|serial|model)\s*[:=]\s*[a-z\d]{6}.*$/i),i=(0,r.compactBlanks)((0,g.splitLines)(t).map((e=>e.replace(/\s+/g," ")))).sort();return i.some((e=>null!=e.match(/^serial/i)))?i:void 0}catch{return}}t.readInfo=x;const F=(0,a.defer)((()=>(0,m.thenMap)(x(),(e=>(0,D.toUID)(D.S.lc,e.join(",")))))),C=/o\.e\.m\./i;async function A(e){return(0,r.uniq)(await Promise.all((0,t.k)()[e].map((e=>(0,w.readFileMaybe)(e,b.LogLevels.trace))))).map(d.toS).filter((e=>(0,s.notBlank)(e)&&null==e.match(C)))}async function I(){return P.isLinux?(await A("lm")).map((e=>(0,D.toUID)(D.S.lm,e))):void 0}async function O(){return P.isLinux?(await A("lp")).map((e=>(0,D.toUID)(D.S.lp,e))):void 0}async function L(){return P.isLinux?(await A("lb")).map((e=>(0,D.toUID)(D.S.lb,e))):void 0}async function R(){if(P.isMac)try{return(0,l.entries)(await async function(){const e=await(0,p.stdout_)((0,t.k)().i,(0,t.k)().ia,{timeoutMs:5*n.secondMs}),i=e.match(/uuid" = "([a-z\d-]{12,})"/i)?.[1],r=e.match(/SerialNumber" = "([a-z\d-]{10,})"/i)?.[1];return{mp:i,ms:r}}()).map((([e,t])=>(0,D.toUID)(e,t)))}catch(e){return void k().warn((0,t.k)().i+" failed",e)}}async function N(){return(await M.PowerShell.instance().executeJson((0,t.k)().w))?.MachineGuid}async function B(){return P.isWin?(0,D.toUID)(D.S.wm,await N()):void 0}t.win_machineGuid_=N;const j=(0,a.defer)((()=>(0,D.toUID)(D.S.cm,(0,T.cpuInfo)()[0].model)));async function z(){return P.isLinux?(0,D.toUID)(D.S.bm,(0,r.compactBlanks)(await A("bm")).map((e=>e.trim())).join("\n")):[]}async function V(){return(0,D.toUID)(D.S.li,await((0,v.LibraryUIDStore)()?.readUid_()))}async function W(){return(0,D.toUID)(D.S.si,await((0,v.SystemUIDStore)()?.readUid_()))}function U(){return(0,S.networkMacAddresses)().map((e=>(0,D.toUID)(D.S.nm,e)))}async function q(){return(0,c.toA)(await(0,_.volumes)()).map((e=>(0,D.toUID)(D.S.vl,e.uuid)))}const H=new Set;t.sids=async function({timeoutMs:e}){const t=Date.now(),i=[j,F,R,V,W,z,I,O,L,B,U,q],r=(0,o.flatten)(await(0,m.someOrTimeout)(i,{timeoutMs:e})).filter(u.isString);for(const e of r)H.add(e);return k().tap({msg:"sids()",result:(0,D.sortUids)([...H,...r]),meta:{timeoutMs:e,elapsedMs:Date.now()-t}})},t.addSids=function(e){if((0,f.isTest)())for(const t of e)H.add(t)},t.clearSids=function(){(0,f.isTest)()&&H.clear()}},48132:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserTimeoutMs=void 0;const r=i(42659);t.UserTimeoutMs=7*r.secondMs},34474:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allRecentLogEntries=t.recentLogFiles=void 0;const r=i(40958),s=i(42659),n=i(41400),a=i(96249),o=i(68708),l=i(34666),u=i(20214),c=i(71371),d=i(50213),h=i(42638),f=i(31562),m=i(98314),p=i(89968),g=i(28874),y=i(4904),w=i(57902),v=i(89241),b=i(83954);function S(e=10*s.minuteMs){const t=Date.now()-e;return(0,u.thenMap)(p.DirectoryEntry.for(g.Settings.logDir.valueOrDefault),(e=>e.filterDescendantFiles((async e=>[".log",".log.gz"].includes(e.ext)&&(0,l.gte)(e.mtimeMs(),t)))))}t.recentLogFiles=S,t.allRecentLogEntries=async function(e=50){(0,b.writeRecentLogEntries)();const t=(0,o.fromEntries)(w.LogLevels.values.map((t=>[t,new c.BoundedGreatestSet(e,y.logEntrySorter)]))),i=Date.now()-s.hourMs,p=(0,d.mkLogger)("allRecentLogEntries()");return await(0,u.thenMap)(S(),(e=>(0,h.withBoundedConcurrency)({name:"allRecentLogEntries()",laters:e.map((e=>async()=>{try{const a=[],o=new v.LogReader(e,(e=>a.push(e)));for(await(0,f.untilTrue)((()=>o.ready()),{timeoutMs:10*s.secondMs});!o.complete()&&!o.hasErrors();){const e=o.shift();null==e?await(0,n.delay)(5):e.ts>i&&t[e.l]?.add(e)}(0,r.isNotEmpty)(a)&&(p.warn("Read error(s) for "+e,a),a.some((e=>"Z_BUF_ERROR"===e.code||(0,m.errorToS)(e).includes("unexpected end of file")))&&(0,l.lt)(e.mtimeMs(),Date.now()-s.minuteMs)&&(p.warn("Unlinking corrupt logfile "+e),await e.unlink_()))}catch(t){p.warn("Failed to read entries from "+e,t)}}))}))),(0,a.flatten)((0,o.values)(t).map((e=>e.vacuum()))).sort(((e,t)=>(0,l.cmp)(e.ts,t.ts)))}},49794:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),s=i(19851),n=i(40958),a=i(22573),o=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,s.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,a.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,n.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),s=i(23560),n=i(66184),a=i(72210);class o{log(e,t,i,r){this.enabled(e,t)&&(0,a.pushLogEntries)({ts:Date.now(),l:e,from:(0,s.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,n.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=o,o.instance=(0,r.lazy)((()=>new o))},14593:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),s=i(22573),n=i(26905),a=i(55835),o=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,s.toNotBlank)(e)??(0,n.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,o.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),s=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:s}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,a.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,o.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),s=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof s.LogWriter))}},28981:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),s=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new s.PlaintextLogFormatter))},31256:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(41400),o=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function w(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,n.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,a.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,s.uniq)((0,s.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,o.stringify)({...t,...w(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,o.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const n=i(77030),a=i(19851),o=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),w=i(31256),v=i(28538),b=(0,a.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),S=String.fromCharCode(0);t.logBroadcaster=(0,a.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,o.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&b().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new w.GelfLogFormatter,this.logFilter=new v.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,n.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{b().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){b().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),s(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,n){if(this.enabled(e,t))try{const a=this.socket;null==a?s(this,r,"f").call(this):a.write(this.logFormatter.format(e,t,i,n)+S)}catch(r){b().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:n,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),s=i(42659),n=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??n.Settings.logDir.valueOrDefault,(0,s.fmtIsoDate)(t??new Date))}},12495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogDirCleanup=void 0;const r=i(19851),s=i(42659),n=i(23560),a=i(79267),o=i(32144),l=i(28874);t.LogDirCleanup=(0,r.lazy)((()=>(0,n.isBillingService)()?void 0:a.FileCleanup.for({name:"logDirCleanup",rootNativePath:()=>l.Settings.logDir.valueOrDefault,staleMs:s.weekMs,isPrunable:e=>(0,o.isLogExt)(e.ext)})))},4904:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),s=i(31586),n=i(51926),a=i(57902);t.isLogEntry=function(e){return null!=e&&(0,s.isNumber)(e?.ts)&&(0,n.isString)(e?.msg)&&a.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),s=i(57902);class n{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,s.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,s.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=n,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new n(s.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>s.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,s.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,s.set(this,[]),n.set(this,(0,l.lazy)((()=>{o(this,s,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:o(this,s,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>o(this,n,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=o(this,r,"m",a).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=o(this,r,"m",a).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){if(null==e||0===o(this,s,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return o(this,s,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),s=i(31586),n=i(50989);t.LogLevels=(0,n.strEnum)("fatal","error","warn","info","debug","trace");const a=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??a},t.levelGte=function(e,i){return(0,s.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const o=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return o.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),s=i(68708),n=i(20214),a=i(51926),o=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,a.isString)(i)||Buffer.isBuffer(i))return(0,a.ellipsize)(i.toString(),256,32);if((0,o.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,n.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const o=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,s.keys)(i),(0,s.keys)(o));return(0,r.isNotEmpty)(c)&&(o["…"]="omitted: "+(0,a.ellipsize)(c.join(", "),128,32)),o}return i}},89241:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogReader=void 0;const d=i(73024),h=i(38522),f=i(4001),m=i(14977),p=i(33456),g=i(92322),y=i(4904),w=i(98192);t.LogReader=class{constructor(e,t){if(r.add(this),this.f=e,this.start=Date.now(),this.lines=new g.SortedSet(y.logEntrySorter),s.set(this,!1),n.set(this,!1),a.set(this,!1),this.from=(0,f.stripCopySuffixFromName)(e.name),this.fileStream=(0,d.createReadStream)(e.nativePath,{autoClose:!0}),!(0,m.isExtOrCompressedExt)(e.ext,".log"))throw new Error(e+" is not a logfile");this.stream=(e.ext.toLowerCase().endsWith(".gz")?this.fileStream.pipe((0,h.createGunzip)()):e.ext.toLowerCase().endsWith(".br")?this.fileStream.pipe((0,h.createBrotliDecompress)()):this.fileStream).pipe(new p.LineReader).on("error",(e=>{t(e),u(this,a,!0,"f")})),this.stream.on("data",c(this,r,"m",o).bind(this)),this.stream.on("close",(()=>{this.fileStream.resume(),u(this,s,!0,"f")})),this.stream.on("end",(()=>{u(this,s,!0,"f")}))}toString(){return"LogReader("+this.f.nativePath+")"}status(){return{hasErrors:c(this,a,"f"),ended:c(this,s,"f"),destroyed:this.stream.destroyed,lines:this.lines.length,paused:c(this,n,"f")}}hasErrors(){return c(this,a,"f")}get ended(){return c(this,s,"f")}ready(){return this.ended||this.lines.length>32}complete(){return this.ended&&0===this.lines.length}peek(){return this.ready()?this.lines.at(0):void 0}shift(){const e=this.lines.shift();return null!=e&&c(this,r,"m",l).call(this),e}shiftLte(e){const t=this.lines.shiftLte(e);return t.length>0&&c(this,r,"m",l).call(this),t}},s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e){if(null===e)u(this,s,!0,"f");else{const t=(0,w.chunkToLogEntry)(e);null!=t&&this.lines.add({...t,from:this.from}),this.lines.length>10240&&!c(this,n,"f")&&(this.fileStream.pause(),u(this,n,!0,"f"))}},l=function(){this.lines.length<1024&&c(this,n,"f")&&(this.fileStream.resume(),u(this,n,!1,"f"))}},24068:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),s=i(76760),n=i(1708),a=i(87997),o=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),w=i(22277),v=i(25764),b=i(38836),S=i(99331),P=i(42638),M=i(76596),_=i(98314),T=i(89968),E=i(29882),D=i(28874),k=i(28981),x=i(20839),F=i(21727),C=i(66184),A=i(57902),I=i(72210),O=i(98192);function L(e){const t=(0,k.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=L;class R extends b.EndableWrapper{constructor(e=void 0,t=L){super("LogTail",(()=>this.close()),v.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new w.TTLSet(5*u.secondMs),this.setup=(0,o.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,D.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,E.mkdirp_)(e),this.root=await T.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=s.sep+(0,p.serviceName)()+"-"+n.pid+"-",n.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,a.setInterval)((()=>this.flush()),x.DefaultLogFlushMs/2),this.scanTimeout=(0,a.setInterval)((()=>this.scan()),u.minuteMs),n.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,S.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,C.ifLog)(A.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,s.join)(e,i))}))}catch(t){return void(0,C.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,_.errorToS)(t))))}}))}async scan(e=!1){if((0,S.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,M.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,S.ending)()||this.ended)return;const t=(0,F.datedLogDir)(this.root.nativePath);try{await(0,E.mkdirp_)(t),this.watchDir(t)}catch(e){(0,C.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,_.errorToS)(e))))}(0,S.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,a.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,a.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await T.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(r,i))return;await(0,f.thenMap)((0,O.readLogEntries)(e,{start:r,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,C.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,_.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,o.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),s=i(82328),n=i(28981),a=i(20839),o=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(o.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,s.stdoutEnded)()||console.log((0,n.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*a.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),w=i(31586),v=i(409),b=i(23560),S=i(81168),P=i(78406),M=i(25764),_=i(20197),T=i(14977),E=i(36868),D=i(28874),k=i(32105),x=i(20839),F=i(21727),C=i(66184),A=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class O extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*x.DefaultLogFlushMs),rank:M.EndableRanks.logger,unref:!0,onEnd:()=>c(this,s,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,s.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:k.ConsoleLogger.instance(),flushEveryMs:x.DefaultLogFlushMs,processName:b.processName,logFilter:C.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,v.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",n).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const s={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(s.meta=(0,A.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(s)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=O,s=new WeakMap,r=new WeakSet,n=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,w.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),s=e.splice(0,i);this._linesSinceRotate+=s.length,t.write(s.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},a=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},o=function(e){return t=>(c(this,r,"m",a).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,S.stripAnsiEsc)(this.logOpts.processName()),t=await(0,_.ensureNewNativePath_)({nativePath:(0,f.join)((0,F.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,r,"m",o).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,E.endStream)(e.stream),D.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,T.gzip_)(e.nativePath))}catch(e){c(this,r,"m",a).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(68708),o=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,a.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,s.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,n.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),s=i(84542),n=i(4001),a=i(13047),o=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,o.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,n.stripCopySuffixFromName)(e.name),r=[],o=await(0,a.zcat)(e.nativePath,t);if(null!=o)for(const e of(0,s.splitLines)(o)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),s=i(76790),n=i(68708),a=i(89788),o=i(57902);t.SentLogLevels=(0,r.lazy)((()=>o.LogLevels.values.filter((e=>e!==o.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,n.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new a.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,n.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,n.values)(l()))e.push(...t.toA());return(0,s.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),s=i(41400),n=i(55835),a=i(37975),o=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),w=i(66184),v=i(28538),b=i(24068),S=i(43705),P=i(51879);function M(){(0,w.logFilter)()instanceof v.LogFilterImpl||w.logFilter.set(new v.LogFilterImpl),_();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new S.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,n.map)((0,y.logBroadcaster)(),(e=>i.push(e))),o.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&b.LogTail.instance()}function _(){const e=h.Settings.logColor.valueOrDefault;(0,a.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=M,t.setupLogFormatter=_,(0,s.later)((()=>{h.Settings.logStdout.watchLater(M),h.Settings.logDir.watchLater(M),h.Settings.tailLogs.watchLater(M),h.Settings.logColor.watchLater(_),h.Settings.logLevel.watchLater((()=>w.defaultLogLevel.unset()))}))},83954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeRecentLogEntries=void 0;const r=i(89179);t.writeRecentLogEntries=function(){return(0,r.currentFileLogger)()?.writeRecentLogEntries()}},82647:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const a=i(57975),o=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,a.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return n(this,r,"m",s).call(this,-1)}get p29(){return n(this,r,"m",s).call(this,-.5)}get p38(){return n(this,r,"m",s).call(this,-.25)}get p69(){return n(this,r,"m",s).call(this,.5)}get p84(){return n(this,r,"m",s).call(this,1)}get p98(){return n(this,r,"m",s).call(this,2)}get p99(){return n(this,r,"m",s).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,o.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,o.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,o.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,s=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),s=i(55835),n=i(31586),a=i(30976),o=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,n.clamp)(0,i,(0,n.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,s.map2)(e,t,((e,t)=>(0,r.sum)((0,o.zip)(u(e,i),u(t,i)),(([e,t])=>(0,n.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,n.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,a.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),s=this.clampValue(e);let n=0;for(let e=0;ea?(n+=1,i[t]=a):r[t]=a}return n}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let s=0;s(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,n.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;in?(t+=1,s.min=n):s.max=n}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},76752:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtEstimate=t.ETA=void 0;const r=i(42659),s=i(75240),n=i(31586),a=i(97352),o=i(82647);function l(e){return(0,n.gt0)(e)?e<=r.minuteMs?"less than a minute remains":"about "+(0,s.fmtDuration)(e,1,{plural:"remains",singular:"remain"}):void 0}t.ETA=class{constructor(){this.taskMillis=new o.Average(10)}push(e){(0,a.mapGt0)(e,(e=>this.taskMillis.push(e)))}clear(){this.taskMillis.clear()}avg(){return this.taskMillis.p69}etaMs(e){const t=this.avg();if(null==t)return;const i=t*e;return i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.kmeans=void 0;const r=i(76790),s=i(93973);t.kmeans=function(e,t,i){const n=s(e,t,i);return{...n,centroids:(0,r.sortBy)(n.centroids.filter((e=>e.size>0)),(e=>-e.size))}}},31843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const r=i(76790);function s(e,t,i=.5){return(1-i)*e+i*t}t.lerp=s,t.lerp2d=function(e,...t){const i=(0,r.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[n,a]=(0,r.sortBy)(i,(e=>e.x)),o=a.x-n.x,l=(e-n.x)/o;return s(n.y,a.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},75503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modeReduce=t.submatrixCollect=t.greatestHalf=t.leastVariantQuarter=t.leastMagQuarter=t.submatrixMode=t.submatrixStdDev=t.submatrixMagnitude=t.submatrixForEach=t.index1D=t.slice=t.matXvec=t.vecXvec=void 0;const r=i(40958),s=i(31586),n=i(48884),a=i(82647),o=i(70417);function l(e,t,i,r){const s=Math.floor(Math.max(0,t.row)),n=Math.ceil(Math.min(e.row,i.row)),a=Math.floor(Math.max(0,t.col)),o=Math.ceil(Math.min(e.col,i.col));for(let t=s;t(0,s.mapFinite)(e[t],(e=>n+=e*e)))),Math.sqrt(n)}function c(e,t,i,r){const n=new a.Average;return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),n.stdDev}function d(e,t,i,r){const n=[];return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),(0,o.mode)(n)}t.vecXvec=function(e,t){return e.map(((e,i)=>e*t[i]))},t.matXvec=function(e,t){return e.map(((e,i)=>{if(e.length!==t.length)throw new Error("misshaped matrix on row "+i);return(0,o.sumf)(e,((e,i)=>e*t[i]))}))},t.slice=function(e,t,i){const s=Math.max(0,t.row),n=Math.min(e.length,i.row),a=Math.max(0,t.col),o=Math.min(e[0].length,i.col);return(0,r.range)(s,n,(t=>e[t].slice(a,o)))},t.index1D=function(e,t,i){return t*e.col+i},t.submatrixForEach=l,t.submatrixMagnitude=u,t.submatrixStdDev=c,t.submatrixMode=d,t.leastMagQuarter=function(e,t){const i=t.col,r=t.row,s=[u(e,t,{col:i/2,row:0},{col:i,row:r/2}),u(e,t,{col:0,row:0},{col:i/2,row:r/2}),u(e,t,{col:0,row:r/2},{col:i/2,row:r}),u(e,t,{col:i/2,row:r/2},{col:i,row:r})];return(0,n.leastIndex)(s)},t.leastVariantQuarter=function(e,t){const i=t.col,r=t.row;return(0,n.leastIndex)([c(e,t,{col:i/2,row:0},{col:i,row:r/2}),c(e,t,{col:0,row:0},{col:i/2,row:r/2}),c(e,t,{col:0,row:r/2},{col:i/2,row:r}),c(e,t,{col:i/2,row:r/2},{col:i,row:r})])},t.greatestHalf=function(e,t){const i=t.col,r=t.row,s=[d(e,t,{col:0,row:0},{col:i,row:r/2}),d(e,t,{col:0,row:0},{col:i/2,row:r}),d(e,t,{col:0,row:r/2},{col:i,row:r}),d(e,t,{col:i/2,row:0},{col:i,row:r})];return(0,n.greatestIndex)(s)},t.submatrixCollect=function(e,t,i){const r=[];return l(e,t,i,(e=>r.push(e))),r},t.modeReduce=function(e,t,i){const o=Math.floor(t.col/i.col),u=Math.floor(t.row/i.row),c=new a.Average(Math.ceil(o*u));return(0,n.concat)(...(0,r.stepRange)(0,t.row,u,(i=>(0,r.stepRange)(0,t.col,o,(r=>(c.clear(),l(t,{col:r,row:i},{col:r+o,row:i+u},(t=>(0,s.mapFinite)(e[t],(e=>c.push(e))))),c.sampleMode))))))}},36372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stableContentShuffle=t.stableIndexShuffle=t.factors=t.primeSeeds=t.primeInt=t.primes=t.prng=t.prngOrderByClause=void 0;const r=i(76790),s=i(42659),n=i(31586),a=i(97238),o=i(50597),l=i(9103),u=i(55222);function c(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e),u=(s*i*i+n*i)%r,c=(a*i+o)%r;return Math.round((u*c+l)%r)}function d(e){return(0,u.encodeDigits)(a.PrimesPerBin,e,a.PrimeBins).map(((e,i)=>t.primes[i][e]))}t.prngOrderByClause=function(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e);return`(((${s}*${i}*${i}+${n}*${i})%${r})*((${a}*${i}+${o})%${r})+${l})%${r}`},t.prng=c,t.primes=[[353868013,472882027,479001599,517294153],[1012573,1230587,1355297,1572751],[756065159,812182027,899809343,989450477],[3959297,4514113,4823201,5133127],[573259391,666101999,694847533,746151647],[2275327,2770513,3073703,3511973],[173313197,182557181,203457869,222230231],[6054613,6189107,7752103,9852103]],t.primeInt=[1012573,1101689,1183811,1196089,1230587,1355297,1419641,1483733,1572751,2275327,2770513,3010349,3073703,3118691,3174823,3511973,3959297,4514113,4690451,4823201,5133127,5375327,6019889,6054613,6189107,7752103,7752103,9852103],t.primeSeeds=d,t.factors=(0,l.memoize)((e=>{const[i,r,s,o,l,u,c,h]=d(e%a.SeedCount),f=[i/r,s/o,l/u,c/h].map((e=>(0,n.sigFigs)(e,7)));return f.push(t.primeInt[e%t.primeInt.length]),f}),{maxSize:128,ttlMs:s.minuteMs}),t.stableIndexShuffle=function(e,t=1){return(0,r.sortBy)(e,((i,r)=>c(t,r,e.length)))},t.stableContentShuffle=function(e,t=1){return(0,r.sortBy)(e,(e=>(0,o.numericSha)(String(e)+t)))}},55222:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),s=i(22573),n=i(55835),a=i(32639),o=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,n.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,s.blank)(e))return;const t="-"===(e=(0,a.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),s=this.normalizeToken(t);return r.length>=i&&r===s}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const r=i(31586),s=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,r.toInt)(e)]??(0,s.toS)(e)}},38812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SquareMatrix=t.rotateSquareMatrix=void 0;const r=i(21605);t.rotateSquareMatrix=function(e,t){return 0===(0,r.normalizeRotation)(t)?e:new s([...e]).rotate(t).m};class s{constructor(e,t=1){if(this.m=e,this.ary=t,this.rows=Math.sqrt(e.length/t),this.rows!==Math.floor(this.rows))throw new Error(`Only square tuple matrices are supported: ${1===this.ary?"":this.ary}(${this.rows}×${this.rows}) != ${e.length}`)}index(e,t){return this.ary*(t+e*this.rows)}swap(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),s=i(65713);function n(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=n,t.safeUUID=function(){return(0,s.decuss)(n)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const o=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function w(e,t){let i=0,r=0;for(const s of e){if(null!=s){const e=t(s,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=w;class v{constructor(){r.set(this,0),s.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(a(this,s,null==n(this,s,"f")?e:n(this,s,"f")*n(this,r,"f")/(n(this,r,"f")+1)+e/(n(this,r,"f")+1),"f"),a(this,r,(t=n(this,r,"f"),++t),"f"))}get mean(){return n(this,s,"f")}}function b(e){const t=new v;for(const i of e)t.push(i);return t.mean}function S(e){const t=b(e);if(null==t)return;let i=0,r=0;for(const s of e)(0,u.isNumber)(s)&&(r++,i+=(s-t)*(s-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function M(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+a*(e-s)/n)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=b(t);if(null!=i){const e=(t.length-1)/2,r=w(t,((t,r)=>(t-i)*(r-e))),s=w(t,(e=>(e-i)**2));return 0===s?0:r/s}},t.variance=S,t.stdDev=function(e){return(0,l.map)(S(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=M,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(M(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,o.isEmpty)(e)&&(0,o.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},23624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64encodeBits=t.b64hammRatio=t.gz64decodeString=t.d=t.gz64encodeString=t.b64decode=t.b64encode=t.hex2b64=void 0;const r=i(38522),s=i(22573),n=i(97352);function a(e){const t=e.toString(16),i=t.length%2==0?"":"0";return Buffer.from(i+t,"hex").toString("base64")}function o(e){return BigInt("0x0"+Buffer.from(e,"base64").toString("hex"))}function l(e){return(0,r.gunzipSync)(Buffer.from(e,"base64")).toString("utf8")}t.hex2b64=function(e){return Buffer.from(e,"hex").toString("base64")},t.b64encode=a,t.b64decode=o,t.gz64encodeString=function(e){return(0,r.gzipSync)(Buffer.from(e,"utf8")).toString("base64")},t.d=l,t.gz64decodeString=l,t.b64hammRatio=function(e,t){return(0,s.mapNotBlank)(e,(e=>(0,s.mapNotBlank)(t,(t=>(0,n.hammRatioBigInt)(o(e),o(t))))))},t.b64encodeBits=function(e){return a(BigInt("0b0"+e.map((e=>1===e?"1":"0")).join("")))}},49076:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const s=r(i(48161)),n=i(19851),a=i(22573),o=i(41400),l=i(81168),u=i(28874);t.hostname=(0,n.lazy)((()=>u.Settings.hostname.value??s.default.hostname())),(0,o.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,a.blank)(e)&&!(0,a.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??s.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},43205:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemUserAgent=t.simpleUserAgent=t.userAgent=void 0;const r=i(72993),s=i(17344),n=i(96175),a=i(37805),o=i(81674),l=i(28874);function u(){return r.SimpleAppName+a.version}async function c(){return u()+" ("+(0,n.osFullName)()+") "+(0,s.EditionType)().toLowerCase()+"/"+await(0,o.t)()}t.userAgent=async function(){return l.Settings.allowUserAgent.valueOrDefault?c():u()},t.simpleUserAgent=u,t.systemUserAgent=c},72308:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLocalhost=t.isLoopback=t.myExternalIp4Addresses=t.myExternalIpAddresses=t.networkMacAddresses=t.myIpAddresses=void 0;const r=i(48161),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(96249),u=i(31586),c=i(68708),d=i(50213),h=i(81168);function f(){return(0,t.myIpAddresses)().filter((e=>!g(e)))}t.myIpAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.address))))),o.minuteMs),t.networkMacAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.mac)))).filter((e=>"00:00:00:00:00:00"!==e))),o.minuteMs),t.myExternalIpAddresses=f,t.myExternalIp4Addresses=function(){return f().filter((e=>!e.includes(":")))};const m=(0,s.lazy)((()=>(0,d.mkLogger)("net.ip"))),p=[/^(?:::ffff:)?127\.\d{1,3}.\d{1,3}.\d{1,3}$/i,/^::1$/];function g(e){return(0,a.notBlank)(e)&&(127===function(e){const t=e.split(".").map((e=>(0,u.toInt)(e)));return 4!==t.length||t.some((e=>null==e||!(0,u.within)(0,255,e)))?void 0:t}(e)?.[0]||p.some((t=>null!=t.exec(e))))}t.isLoopback=g,t.isLocalhost=function(e){return m().tap({msg:"isLocalhost",level:"info",result:!(0,a.blank)(e)&&((0,t.myIpAddresses)().includes(e)||(0,t.myIpAddresses)().includes((0,h.stripPrefix)(e,"::ffff:"))||g(e)),meta:{address:e}})}},96128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),w=i(34102),v=i(26293),b=new RegExp("^"+v.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==b.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const S=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=S.exec(e)}function M(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=M,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,n.blank)(e)){if(null!=M(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void _().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs});const _=(0,s.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,o.later)((()=>(0,w.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=M(e)?r.promises.reverse(e):r.promises.resolve4(e),5*a.secondMs);if(t===c.Timeout)return _().info("nslookup("+e+"): timeout"),e;const i=t.find(n.notBlank);return null==i?(_().warn("No name found for "+e),e):i}catch(t){return _().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,n.blank)(e)&&!(0,n.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),s=i(42659),n=i(31586),a=i(97790),o=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*s.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,n.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,a.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,o.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs})},78330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const r=i(40958),s=i(22573),n=i(45599),a=i(59455),o=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),h=i(63870),f=(0,n.defer)((()=>(0,o.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,a.toA)(await async function(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return f().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,r.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(f().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),s=i(38639),n=i(19851),a=i(59958),o=i(43334);t.isDocker=(0,n.lazy)((()=>o.isLinux&&((0,s.toBoolean)(process.env[a.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),s=i(19851),n=i(54993);t.isPacked=(0,s.lazy)((()=>!(0,n.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const r=i(45599),s=i(50213),n=i(84777),a=i(68284),o=i(63870),l=i(43334),u=(0,r.defer)((()=>(0,s.mkLogger)("platform.Pacman")));t.hasPacman=(0,r.defer)((()=>l.isLinux&&(0,a.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,n.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,o.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(22573),o=i(38639),l=i(59958),u=s.default.platform();t.inspectFlag=n.default.argv.includes("--inspect")||(0,o.isTrue)(n.default.env.NODE_INSPECT),t.isCI=(0,o.isTrue)(n.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,a.notBlank)(n.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===s.default.arch(),t.isArm=null!=/^arm\b/i.exec(s.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,a.notBlank)(n.default.env.APPIMAGE)||(0,a.notBlank)(n.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,a.notBlank)(n.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=n.default.versions.electron,t.isElectron=t.isMainElectron||(0,o.isTrue)(n.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const s=r(i(73024)),n=i(19851),a=i(43334);function o(e="/proc/cpuinfo"){if(a.isWin||a.isMac)return!1;try{return null!=s.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=o,t.isRaspberryPi=(0,n.lazy)((()=>a.isLinux_arm&&o())),t.procDeviceModel=(0,n.lazy)((()=>{try{return a.isLinux?s.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},94137:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.negateFilterName=void 0;const r=i(22573),s=i(51926),n=i(83556);t.negateFilterName=function(e){if((0,r.blank)(e))return;const t=/\s/.test(e)?e:(0,n.camel2words)(e).replace(/\bphoto structure\b/gi,"PhotoStructure");return t.match(/^not\b/)?t.replace(/^not\b/,"").trim():"not "+(0,s.stripPrefix)(t,"is ")}},78984:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Predicates=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(51926),o=i(50213),l=i(94137),u=(0,r.lazy)((()=>(0,o.mkLogger)("predicates.Predicates")));class c{static async accepted(e,...t){for(const i of t)for(const t of(0,n.values)(i)){const i=await t(e);if(!1===i||(0,a.isString)(i))return!1}return!0}static async rejected(e,...t){return!await c.accepted(e,...t)}static async explain(e,...t){const i=[],r=[],s=[];for(const o of t)for(const[t,l]of(0,n.entries)(o)){const n=await l(e);!0===n?i.push(t):!1===n||(0,a.isString)(n)?r.push(t):s.push(t)}return{accepted:i,rejected:r,notApplicable:s}}static async whyRejected(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))try{const i=await r(e);if(null==i||!0===i)continue;return(0,a.isString)(i)?i:(0,l.negateFilterName)(t)}catch(e){u().warn("whyRejected() caught from "+t,{error:e})}}static async logged({a:e,logger:t,msg:i,predicates:r}){const{accepted:n,rejected:a}=await c.explain(e,...r);return t.tap({msg:i,result:(0,s.isEmpty)(a),meta:{a:e,accepted:n,rejected:a}})}}t.Predicates=c},33995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncPredicates=void 0;const r=i(68708),s=i(94137);class n{static firstFalse(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!1===s(e))return t}static firstTrue(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!0===s(e))return t}static firstDefined(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i)){const i=s(e);if(null!=i)return{name:t,result:i}}}static accepted(e,...t){return null==n.firstFalse(e,...t)}static whyRejected(e,...t){return(0,s.negateFilterName)(n.firstFalse(e,...t))}}t.SyncPredicates=n},45643:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),s=i(59455),n=i(31562);t.existingPids=function(e){return(0,s.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,n.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),w=i(97790),v=i(59455),b=i(54993),S=i(54557),P=i(19851),M=i(50213),_=i(88158),T=i(409),E=i(78406),D=i(25764),k=i(99331),x=i(56519),F=i(46292),C=i(8769),A=i(83278),I=i(32144),O=i(29882),L=i(43334),R=i(24399),N=i(58261),B=(0,P.lazy)((()=>(0,M.mkLogger)("proc.Pids"))),j=10*p.secondMs;function z(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,O.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,v.toA)(t))B().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,T.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{B().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??L.isWin,r=await this.pidfiles(),s=await this.pids(r??[]);if((0,f.isEmpty)(s))return B().info("killOldProcs(): no pidfiles"),[];const n=[],a=[],o=await(0,N.pidInfos)(s);if(null!=o){for(const s of r){const r=await s.readJson();if(null==r){B().warn("killOldProcs(): failed to read pidfile "+s.base),await s.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){B().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+s.base,{json:r,pid:l}),await s.unlink("debug");continue}const u=o.find((e=>e.pid===l));if(null==u||!z(r,u)){B().debug("killOldProcs(): pid no longer present: unlinking "+s.base,{json:r,pidEntry:u}),await s.unlink("debug"),n.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(B().info("killOldProcs(): killing",{reason:d,json:r}),a.push(W(l,i,!1)),n.push({...r,...u}))}return a.length>0&&await Promise.allSettled(a),n}(0,C.onError)("Pids.killOldProcs(): failed to get process information")}}),a.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const a=e.pid;if(!(0,y.gt0)(a))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(a)?(i&&o(this,s,"f").delete(l),o(this,s,"f").getOrSet(l,(async()=>{const i=o(this,r,"m",n).call(this,e.pid),s=(0,w.opt)((0,_.Try)((()=>(0,O.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),a=t.getTime(),l={...e,cmd:s,startTime:a};return await i.writeJson_(l),B().debug("addPid() wrote "+i,l),i}))):(o(this,s,"f").delete(l),void B().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,v.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=o(this,r,"m",n).call(this,e);return(0,x.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{B().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==o(this,a,"f")||o(this,a,"f").ended)&&l(this,a,new E.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:D.EndableRanks.first}),"f"),o(this,a,"f")}cancelInterval(){o(this,a,"f")?.end(),l(this,a,void 0,"f")}}t.Pids=U,s=new WeakMap,a=new WeakMap,r=new WeakSet,n=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,F.configDir)(),(e=>new U(A.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const s=i(31421),n=i(48161),a=r(i(1708)),o=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),w=i(84968),v=i(48963),b=i(56519),S=i(84777),P=i(8103),M=i(45879),_=i(43334),T=i(24399),E=i(45643),D=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function k(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function x(e){if(_.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,M.readFileMaybe)("/proc/"+i+"/stat")));return D().tap({msg:"pidInfoProc",result:(0,o.compact)(t)})}(e);const t=(0,E.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,_.isWin?I:N)).filter((e=>k(e)&&t.includes(e.pid)));return D().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=k,t.pidInfo=async function(e){return(0,b.thenMap)(x([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,o.isEmpty)(e)?[]:(0,b.thenMap)((0,E.existingPids)(e),(t=>{const i=[a.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=x;const F="Get-Process",C="| Select-Object -Property Id,ProcessName,StartTime";function A(e){return(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).join(",")}async function I(e){if(T.PowerShell.instance().ended)return R(e);const t=[F,"-Id",A(e),"-ErrorAction SilentlyContinue",C].join(" ");return(0,b.thenMap)(T.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,v.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const O={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},L=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,o.isNotEmpty)(e)){const i=(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",L.join(","));const i=await(0,S.stdoutResult_)((0,P.wmic)(),t,O),r=(0,d.onlyReqValued)((0,p.parseFixed)(L,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,v.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return r.find((e=>e.pid===a.default.pid))||r.push({pid:a.default.pid,start:new Date(w.StartTs),cmd:"node "+a.default.title}),r}async function N(e){return t=(await(0,S.stdoutResult_)("ps",["-p",A(e),"-wwwo","pid,lstart,command"],{...O,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const B=(0,g.lazy)((()=>{try{if(_.isLinux)return(0,c.toGt0)((0,s.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){D().warn("clk_tck failed",{error:e})}return 100})),j=(0,g.lazy)((()=>Date.now()-(0,n.uptime)()*u.secondMs)),z=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=z.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,s=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(s)?{pid:i,cmd:r,start:new Date(j()+s/B()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(29882),o=i(97352);t.progressEvtToS=function(e){const t=(0,s.blank)(e.path)?null:(0,a.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,n.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,s.notBlank)(e.op)&&(0,o.within)(0,100,e.pct)}},41944:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),s=i(42659),n=i(31586),a=i(12089),o=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new o.TTLMap(15*s.secondMs))),t.recentDone=(0,r.lazy)((()=>new o.TTLMap(2*s.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,n.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,a.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),s=i(31586),n=i(409),a=i(78406),o=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends a.EndableInterval{constructor(e,t,i,s=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:s,rank:o.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=s,this.start=Date.now(),this.onInterval=(0,n.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,s.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,s.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},38156:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushProgressObserver=void 0;const r=i(31586),s=i(41944);t.PushProgressObserver=class{constructor(e,t){this.context=e,this.total=t,this.start=Date.now()}toJSON(){}incrProgress(e=1){this.onProgress(e+(this.current??0))}onProgress(e){this.current=(e??this.current??0)+1,(0,r.gte)(this.current,this.total)&&(this.done=!0),this.emit()}completed(){this.done=!0,this.current=this.total,this.emit()}emit(){(0,s.emitProgressEvt)({...this.context,pct:(0,r.pct)(this.current,this.total),elapsedMs:Date.now()-this.start,done:this.done})}}},24399:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),w=i(99331),v=i(56519),b=i(31562),S=i(84777),P=i(34102),M=i(43334),_=i(28874),T=i(63870),E="{ready}",D=" | ConvertTo-Json -Compress";function k(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=k,(0,o.later)((()=>(0,P.ee)().on("clearCache",(()=>x.instance.prior()?.clearMockResults()))));class x extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,S.execFile)("powershell",_.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${E}"}`,...(0,n.mapNotBlankOr)(_.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:E,fail:"Error",exitCommand:"exit",maxProcs:_.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,T.commandTimeoutMs)(),maxIdleMsPerProcess:a.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),_.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(_.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,v.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,D),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,w.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,s)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,s)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,D),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,n.blank)(t.stdout)||(0,n.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,v.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+k(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=x,x.instance=(0,s.lazy)((()=>{if(!M.isWin)throw new Error("PowerShell isn't available on this platform");return new x})),t.checkPowerShell_=async function(){const e=x.instance();if(e.ended||(0,w.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,T.commandTimeoutMs)());if((0,n.blank)(t)){const t=await(0,b.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),s=i(38639),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toBoolean})}}t.BooleanSetting=a},90536:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).flatMap(parseFloat).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=o},75164:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).filter(r.notBlank).flatMap(s.toInt).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,s.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=o},10546:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),s=i(22573),n=i(45599),a=i(50213),o=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,n.defer)((()=>(0,a.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,o.trimQuotes)(e);return void((0,s.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,s.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),s=i(91655),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,s.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=a;class o extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=o},9945:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.FloatSetting=a},69589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.forceContextOrSetting=t.pickForceContext=void 0;const r=i(38639),s=i(68708),n=i(50989),a=i(76740),o=i(28874),l=(0,n.strEnum)("forceSync","forceFilters","skipPreviews","forceRebuildPreviews","skipAssetTagging","recountAllTags","skipAssetRepair");t.pickForceContext=function(e){return(0,s.pick)(e,...l.values)},t.forceContextOrSetting=function(e){const t={...(0,s.pick)(e??{},"retries","halt","path"),...(0,s.fromEntries)(l.values.map((t=>[t,e?.[t]??(0,r.isTrue)(o.Settings[t]?.valueOrDefault)])))};return t.retries??(t.retries=0),t.halt??(t.halt=new a.Abortable),t}},74589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt})}}t.IntegerSetting=a},86941:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAndArchiveSystemSettingsDir_=t.mergeUserDataDirs_=void 0;const r=i(19851),s=i(59455),n=i(72993),a=i(46292),o=i(95696),l=i(50213),u=i(83179),c=i(28874),d=i(2858),h=i(84438),f=(0,r.lazy)((()=>(0,l.mkLogger)("settings.MergeConfigDirs")));async function m(e,t){let i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+e.baseWithGrandparent+" => "+t.baseWithGrandparent+")");const r=await e.resolve_(),n=await t.resolve_();if(null==r||null==n||n.nativePath===r.nativePath)return void i.info("no-op, missing or same directory",{priorResolvedConfigDir:r?.nativePath,currentResolvedConfigDir:n?.nativePath});if(i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+r.baseWithGrandparent+" => "+n.baseWithGrandparent+")"),!await r.isDirectory())return void i.info("no-op, prior directory doesn't exist");{const e=r.join(h.SettingsToml);if(await e.isNonEmptyFile()){const t=n.join(h.SettingsToml);await(0,d.readSystemSettings)(e),i.info("read prior settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.readSystemSettings)(t),i.info("read current settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.writeSystemSettings_)(t)}}{const e=r.join("licenses"),t=n.join("licenses");for(const r of(0,s.toA)(await e.childFiles())){const e=t.join(r.base);if(await e.notExists())try{await r.copyFile_(e),i.info("Copied license "+r.base)}catch(e){i.warn("Failed to copy license "+r.base,e)}}}const a=n.join("old");try{const e=await r.renameYMDHMS_({subdir:a.nativePath});i.info("merged and archived to "+e)}catch(e){i.warn("Failed to archive to "+a,e)}}t.mergeUserDataDirs_=async function(){const e=(0,a.configDir)();if(null==e)return;const t=o.PosixFile.for(e);for(const e of[t.join((0,n.AppName)()),t.join((0,n.AppName)().toLowerCase()),t.parent().join((0,n.AppName)().toLowerCase())])try{await m(e,t)}catch(i){f().error("Failed to merge "+e+" and "+t,i)}f().info("done")},t.mergeAndArchiveSystemSettingsDir_=m},4175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),s=i(22573),n=i(38639),a=i(42659),o=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function w(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function v(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){M(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&w(),y("strictDeduping",e)&&v(),(y("optOut",e)||y("noNetwork",e))&&_()},t.handleDeprecatedSettings=async function(){if((0,n.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,s.blank)(m.Settings.assetPathnameFormat.value)&&(0,s.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*a.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=w,t.setStrictDeduping=v;const b=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],S={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function M(e){for(const t of b)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:S;for(const[e,i]of(0,o.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function _(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=M,t.disableExternalNetworkRequests=_},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),s=i(53265),n=i(87652);class a extends n.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,s.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=a},23561:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.OptionalFloatSetting=a},69005:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=a},87652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=s},4936:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathToLibraryAsset=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(55835),l=i(51926),u=i(50213),c=i(81168),d=i(79842),h=i(21330),f=i(51275),m=i(29882),p=i(28874),g=(0,s.lazy)((()=>(0,u.mkLogger)("settings.PathToLibraryAsset")));function y(e){return(0,a.blank)(e)?"":"'"+e.replace(/'/g,"′")+"'"}t.pathToLibraryAsset=function(e,t){const i=(0,d.datedToDateTime)(e)??(0,o.map)((0,h.datedToISO)(e),(e=>r.DateTime.fromISO(e)));if(null==i||!i.isValid)return g().tap({msg:"pathToLibraryAsset(): failed to convert to a valid date",result:void 0,meta:{capturedAt:e,src:t,dt:i}});const s=(0,f.hasZone)(e),a=p.Settings.assetPathnameFormat.valueOrDefault,u=(0,c.splitKeep)(a,/((?:GRAND)?PARENT|BASE|NAME|EXT|ISO)/g);for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),s=i(83556);t.nameFromEnv=function(e){return(0,s.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,s.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const a=i(19851),o=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),w=i(40583),v=i(81168),b=i(44198),S=i(96706),P=i(34102),M=i(28283),_=i(81075),T=i(98778),E=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,a.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?n(this,r,"m",s).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?n(this,r,"m",s).call(this,e??t)+": "+i:null==this.fromEnv(e)?n(this,r,"m",s).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,v.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,S.caseInsensitiveEnv)():new w.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,b.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,o.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,o.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,M.envFromName)(e),this._keys=(0,o.uniq)([...this._names.map(M.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return _.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,b.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&S.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,b.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&S.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new w.CaseInsensitiveValued(e)))??(0,S.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,v.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],E.WrapComments);function i(e,i){(0,o.isEmpty)(i)||t.push(...(0,v.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],E.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,v.wrap)(["",e+": "+r],E.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,T.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,T.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,T.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,s=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),s=i(76760),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),w=i(79840),v=i(7282),b=i(12801),S=i(4328),P=i(70488),M=i(84248),_=i(5531),T=i(99315),E=i(34365),D=i(34580),k=i(96706),x=i(50274),F=i(33866),C=i(52086),A=i(48584),I=i(45969),O=i(43334),L=i(24540),R=i(70379),N=i(71300),B=i(33209),j=i(48987),z=i(68268),V=i(61208),W=i(99023),U=i(30577),q=i(1485),H=i(19861),G=i(55111),$=i(30933),J=i(22859),K=i(71988),Z=i(38483),Y=i(90536),X=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),se=i(9945),ne=i(74589),ae=i(844),oe=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,n.lazy)(v.isProd);const ye=()=>!(0,t.isProd)();function we(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function ve(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new oe.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new ne.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:ve}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Z.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new ne.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:ve}),useFsWatch:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>q.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:q.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>q.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>O.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new ne.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Z.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Z.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!O.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>O.isMac?"100ms":O.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>w.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new se.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new ne.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>b.PriorityClasses.BelowNormal,strEnum:b.PriorityClasses}),maxMemoryMb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!we()}),enableRemove:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!we()}),argon2TimeCost:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:M.AutoVacuumModes,defaultValue:M.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:_.CheckpointTypes,defaultValue:_.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:E.SynchronousModes,defaultValue:E.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:T.RepairModes,defaultValue:T.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to apply a migration, vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 2 minutes should be very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"2m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Y.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Z.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Z.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:F.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Z.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>O.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new ne.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Z.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Z.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Z.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Z.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,D.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Z.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new ne.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new ne.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new ne.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Z.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Z.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,L.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Z.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Z.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Z.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Z.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,$.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:x.SidecarExts,defaultValue:x.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new se.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Z.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Z.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,$.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:C.CropStrategies.attention,strEnum:C.CropStrategies}),videoFrameAtSec:new se.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Z.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,a.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new ne.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(O.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new Y.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>B.DefaultIncludedPreviewTags}),disableAllFilters:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Z.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new ne.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new ne.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:A.SharpFailOns.truncated,strEnum:A.SharpFailOns}),validateRawImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>j.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:ae.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new se.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:z.KeywordReparentingStrategies.move,strEnum:z.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Z.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function be(e){const i=((0,l.blank)(e)?"":e).split(s.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,a.uniq)(i).filter(l.notBlank).join(s.delimiter)}function Se(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=be,t.pathWithDefaults=(0,n.lazy)((()=>be((0,k.getEnv)("PATH")))),t.allSettings=(0,n.lazy)((()=>(0,o.sortBy)((0,d.values)(t.Settings),Se))),t.persistedSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,n.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,n.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),s=i(31586),n=i(7282),a=i(49776),o=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),w=i(15674),v=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{v.Settings.configDir.opts.defaultValue=o.configDir,v.Settings.logDir.opts.defaultValue=c.defaultLogDir_,v.Settings.logServerLevel.opts.defaultValue=()=>v.Settings.logLevel.valueOrDefault,v.Settings.cacheDir.opts.defaultValue=a.defaultCacheDir,v.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,v.Settings.libraryDir.opts.exampleValue=()=>(0,n.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,n.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),v.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,v.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,v.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],v.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,w.maxCpus)()/4)),v.Settings.useFsWatch.watch(f.useFsWatch),v.Settings.updateChannel.opts.defaultValue=g.channel,v.Settings.ffmpegThreads.opts.defaultValue=()=>(0,w.maxCpus)()>=12?2:1,v.Settings.minBusyPct.opts.defaultValue=()=>(0,s.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),w=i(54993),v=i(50213),b=i(81168),S=i(83556),P=i(87290),M=i(98314),_=i(34102),T=i(83278),E=i(95696),D=i(60865),k=i(4175),x=i(83179),F=i(81075),C=i(28874),A=i(41692),I=i(84438),O=i(32707),L=i(6707),R=i(98778),N=i(55018),B=i(10357),j=(0,r.lazy)((()=>(0,v.mkLogger)("settings.SettingsIO")));function z(e){return(0,P.libraryDataDirPosixFile)(e)?.join(I.SettingsToml)}async function V(e=(0,O.systemSettingsFile)()){if(null!=e)return X(T.BaseFile.for(e))}async function W(){try{return(0,a.toNotBlank)((await(0,L.readTomlFile_)((0,O.systemSettingsFile)()))?.[C.Settings.libraryDir.name])}catch{return}}function U(e){return(0,L.readTomlFile_)(e).then((e=>e?.version),(()=>{}))}function q(){return U((0,O.systemSettingsFile)())}function H(e){return U(z(e))}function G(){t.libraryHasSettings.refresh()}function $(e){const t=z(e);return j().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:C.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}async function J(e,i){if(null==e)return void j().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),s=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...ie("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","This is the version of PhotoStructure that wrote this file--please don't edit the following line.")),r.push(...(0,R.stringifyToml)({version:(0,t.versionForSettings)()})),r.push("","");let s="";for(const e of i){const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==s&&(s=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,_.ee)().emitDebounced("settingsChanged")}(s,i),j().info("writeToml(): wrote settings",{dest:s,file:e,nonDefaults:(0,x.settingsToObj)(i),wip:r}),r){const t=await(0,L.readTomlFile_)(s),i=await(0,L.readTomlFile_)(e);(0,u.eql)(t,i)?(j().info("Equivalent contents",{dest:s,file:e,a:t,b:i}),await s.unlink()):(j().info("Archiving prior, different contents",{dest:s,file:e}),await e.renameYMDHMS_({subdir:"archive"}),await s.unwip_())}}async function K(e=(0,O.systemSettingsFile)()){const t=E.PosixFile.forMaybe(e);return null!=t&&await J(t,(0,C.persistedSystemSettings)()),t}function Z(e){return X(z(e))}async function Y(e){await(0,P.setupLibraryDataDir_)((0,a.firstNotBlank)(e,C.Settings.libraryDir.value));const i=z(e);return j().info("writeLibrarySettings()",{file:i}),null!=i&&(await J(i,(0,C.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function X(e){if(null==e)return[];const t=j().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await Q(e);return(0,s.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,M.errorToS)(e)),[]}}async function Q(e){const t=j().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,L.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const n=[],a=(0,s.compact)((0,p.entries)(r).map((([e,t])=>{if("version"===e)return;const i=(0,C.getSettingByNameOrKey)(e);if(null==i)n.push(`Failed to import "${e}"${(0,m.mapOr)((0,C.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;n.push(e)}})));return t.info("loaded",{settings:(0,x.settingsToObj)(a),warnings:(0,s.toNotEmpty)(n)}),await(0,k.handleDeprecatedSettings)(),(0,k.handleMetaSettings)(a),{settings:a,warnings:n}}t.librarySettingsFile=z,t.readSettings=(0,r.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await Z()}),o.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return C.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=q,t.librarySettingsVersion=H,t.maybeUpgradeSystemSettings=async function(){(0,t.versionForSettings)()!==await q()&&await K()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&(0,t.versionForSettings)()!==await H()&&await Y()},t.libraryHasSettings=(0,r.lazy)((()=>$())),t.libraryHasSettings.unset=()=>{j().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,_.ee)().on("clearCache",G),(0,_.ee)().on("settingsChanged",G),C.Settings.libraryDir.watchLater(G)})),t._libraryHasSettings=$,t.versionForSettings=(0,r.lazy)((()=>(0,D.baseVersion)())),t.writeSystemSettings_=K,t.writeAllSettings_=function(e){return J(E.PosixFile.for(e),(0,C.persistedSettings)())},t.readLibrarySettings=Z,t.writeLibrarySettings_=Y,t._readSettings=X,t.importFileSettings_=Q;const ee=(0,r.lazy)((()=>new Set([C.Settings.noNetwork,C.Settings.httpPort,C.Settings.license,C.Settings.logStdout,C.Settings.logLevel].map((e=>e.key)))));function te(){for(const e of(0,p.values)(C.Settings))ee().has(e.key)||e.unset();(0,_.ee)().emit("settingsChanged")}function ie(...e){return(0,d.flatten)(e.map((e=>(0,b.wrap)(e,B.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),C.Settings.libraryDir.unset(),await K()},t.clearSettings=te,t.nukeSettings=async function(){te(),await(E.PosixFile.forMaybe((0,O.systemSettingsFile)())?.unlink("trace")),await(E.PosixFile.forMaybe(z())?.unlink("trace")),(0,_.ee)().emit("clearCache"),A.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...ie("",`Welcome to PhotoStructure! These are the settings for version ${(0,D.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...ie("","The following settings categories are stored in the system settings.toml:","",...(0,n.sort)([...F.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,n.sort)([...F.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...ie("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...ie("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const n=`${e.key} or ${e.name}`,a={...e.addToJSON()};(0,s.mapNotEmpty)(e.altKeys,(e=>a.aliases=(0,h.orList)(e)));const o=(0,p.entries)(a).map((([e,t])=>`${(0,b.capitalize)((0,S.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,s.isNotEmpty)(o)&&o.push(""),i.push(...ie((0,g.padding)("-",n.length),n,(0,g.padding)("-",n.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...o,`${e.key}=${(0,f.stringify)((0,w.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(98553),o=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,a.stringify)(e)}t._join=c;function d(e){return(0,o.map)(function(e){const t=(0,n.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,s.compact)((0,l.toA)(JSON.parse(t)).map(n.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,s.compactBlankish)(t.split(e));return[t]}}(e),s.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,n.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,s.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,s.isEmpty)(e)||(this.value=this.toValidValues((0,s.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,s.isEmpty)(this.values)}isNotEmpty(){return(0,s.isNotEmpty)(this.values)}toNotEmpty(){return(0,s.toNotEmpty)((0,s.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=s},72564:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),s=i(98553),n=i(55835),a=i(58305);class o extends a.StringArraySetting{constructor(e){super({toEnv:e=>(0,n.map)(e,(e=>(0,s.stringify)((0,r.uniq)(e)))),fromEnv:t=>{return i=t,s=e.strEnum,(0,r.compact)((0,a.splitStringArray)(i)?.map((e=>s.getCI(e))));var i,s},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=o},80372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),s=i(81168),n=i(83179);class a extends n.Setting{constructor(e){super({toEnv:o,fromEnv:o,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function o(e){return null==e?void 0:(0,s.trimQuotes)(e)}t.StringSetting=a},32707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),s=i(55835),n=i(46292),a=i(84438);t.systemSettingsFile=function(){return(0,s.map)((0,n.configDir)(),(e=>(0,r.join)(e,a.SettingsToml)))}},80496:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),s=i(44652),n=i(22573),a=i(76850),o=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,a.debom)(e),(0,n.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,n.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,s.readFileSync)(t)):void 0}catch(e){return void(0,o.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,n.mapNotBlank)(e,(async e=>f(await(0,s.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,s.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),s=i(96249),n=i(98553),a=i(68708),o=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const s=e+" = "+(0,n.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[s]:(0,o.wrap)(s.split("\n"),i)}t.stringifyToml=function(e){return(0,s.flatten)((0,a.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,o.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},10357:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const r=i(54993),s=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=a(e[t]);if(null!=i)return i}};const n=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function a(e){const t=(0,s.extractFloat)(e);if(null==t)return;const i=(0,r.toS)(e).toLowerCase();for(const e of n)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),s=i(81168);t.bname=function(e,t=!0){let i=(0,s.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,s.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),h=i(31586),f=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),w=i(81168),v=i(76596),b=i(79842),S=i(66649),P=i(21330),M=i(98725),_=i(928),T=i(54261),E=i(89724),D=i(17415),k=i(88600),x=i(51275),F=i(29882),C=i(17217),A=i(68284),I=i(57902),O=i(28874),L=i(65162),R=i(71300),N=i(14036),B=i(61424),j=(0,s.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function z(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,f.isObject)(e)&&(0,o.notBlank)(e.nativePath)&&(0,b.isDated)(e.date)&&(0,o.notBlank)(e.src)}t.capturedAtSrcFromTags=z,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class U{static fromAssetFile(e){return(0,d.map)((0,E.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>U.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof U?e:W(e)?new U(e):void 0}constructor(e){var t;this.nativePath=(0,C.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,h.toGt0)(e.local)??(0,E.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,b.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(O.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,S.datedToMillis)(e.mtime)??(0,A.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:U.name,...(0,f.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,M.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,D.fmtOffsetMinutes)});return null==t?void 0:new U({...e,date:t})}spread(e){return new U({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,D.fmtOffsetMinutes)(this.offset)}get isFromTags(){return z(this.src)}get isInferred(){return!z(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,E.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,v.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,x.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,T.hasTime)(this.date)}hasMillis(){return(0,h.gt0)((0,_.getMillisecond)(this.date))}toMillis(){return(0,S.datedToMillis)(this.date)}get isValid(){return(0,k.isValidDate)(this.date)}get zoneName(){return(0,r.offsetMinutesToZoneName)(this.offset)??(0,x.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,D.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?O.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,b.datedToStartDateTime)(this.date)??(0,b.datedToDateTime)(this.date);if(null!=i)return{start:(0,E.datedToLocal)(i.minus(t)),end:(0,E.datedToLocal)(i.plus(t))};j().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:O.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),r=Math.max(t,e.fuzzyPrecisionMs());return j().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,b.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:r}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:r}})}}function q(e,t){if(null==e)return;const i=(0,n.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>U.for(e))));for(const r of t){let t=e[r],s=r;if((0,k.isValidDate)(t)){if((0,D.isValidZone)(e.tz)&&(!(0,x.hasZone)(t)||R.OverrideUTCZoneTags.includes(s))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,o.blank)(e.tzSource)?"":" from "+(0,w.stripPrefix)(e.tzSource,"from ");s+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,E.datedToLocalSec)(t),date:t,src:s,precisionMs:(0,b.datedToPrecisionMs)(t),rawValue:e[r]?.rawValue})}}const r=(0,p.leastBy)(i,(e=>(0,b.datedToStartTs)(e.date)));if(null==r)return;const s=i.filter((e=>(0,u.eql)(e.date,r.date)||e.precisionMs<=r.precisionMs&&(0,b.datedOverlap)({a:e.date,b:r.date,aPrecisionMs:e.precisionMs,bPrecisionMs:r.precisionMs}))),a=(0,p.leastBy)(s,(e=>[Math.floor(e.localSec/1e6),(0,x.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return j().debug("capturedAtFromTags()",{least:r,overlapsWithLeast:s,earliest:a}),a}function H(e,t){if(O.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,n.uniq)([(0,L.bname)(e,!0),(0,L.bname)(e,!1)])){const e=(0,M.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,b.datedToPrecisionMs)(e),l.secondMs])}}}function G(e){if(O.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,M.extractDateFromPath)(e.pathsForDateParsing)}}async function $(e){if(O.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=U,t.bestCapturedAt=function(e){const t=(0,a.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const r=await e.mtimeMs();function s(t,i){return W(i)?U.for(i):null!=i&&null!=i.date&&(0,k.isValidDate)(i.date)?U.for({nativePath:e.nativePath,date:i.date,local:(0,E.datedToLocal)(i.date),src:(0,w.uniqPath)([t,i.src]),mtime:r,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const n=function(e,t){return null==e||t||!O.Settings.usePathsToInferDates.valueOrDefault||!O.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,F.containedByNativePath)({ancestor:O.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),a=s("tags",q(t,O.Settings.capturedAtTags.values))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??s("tags",q(t,O.Settings.capturedAtTagsFallback.values))??(n?void 0:s("bname+stat",await(0,B.extractStatBname)(e)))??(n?void 0:s("path+stat",await(0,B.extractStatPathTime)(e)))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??(n?void 0:s("bname",H(e,t)))??(n?void 0:s("path",G(e)))??(O.Settings.useStatToInferDates.valueOrDefault?s("stat",await $(e)):void 0);return j().tap({level:I.LogLevels.debug,msg:"extractCapturedAt()",result:a})},t.capturedAtFromTags=function(e){return q(e,O.Settings.capturedAtTags.values)},t.capturedAtFromBasename=H,t.capturedAtFromPath=G,t.capturedAtFromStat=$},70379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const r=i(31586),s=i(97352),n=i(95696),a=i(47783),o=i(16170);function l(e){if(null!=e&&(0,o.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,r.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,s.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=n.PosixFile.for(e);return l(await(0,a.readRawTags)(t,!1))}},47783:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const s=i(77988),n=r(i(76760)),a=r(i(1708)),o=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(23838),f=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),w=i(12168),v=i(56038),b=i(4867),S=i(36557),P=i(98247),M=i(21330),_=i(98725),T=i(23467),E=i(88561),D=i(95696),k=i(17217),x=i(16287),F=i(50213),C=i(17921),A=i(7282),I=i(88158),O=i(23560),L=i(28874),R=i(12089),N=i(45255),B=i(81168),j=i(63870),z=i(15674),V=i(28544),W=i(43207),U=i(75767),q=i(12788),H=i(80495),G=i(14036),$=i(67083),J=i(3432),K=i(28630),Z=i(15912),Y=i(30748),X=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),re=i(61424),se=i(8791),ne=(0,o.lazy)((()=>(0,F.mkLogger)("exiftool.ExifTool")));let ae=!1;t.addInstanceIdsToTags=function(e){ae=e},t.setExifToolProcs=function(e){return L.Settings.exiftoolProcsPerChild.envValue=e,ue()};const oe=(0,o.lazy)((()=>new S.BatchClusterObserver("ExifTool",new s.ExifTool({useMWG:L.Settings.useMWG.valueOrDefault,backfillTimezones:L.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:L.Settings.defaultVideosToUTC.valueOrDefault,...(0,S.batchClusterOptions)((0,A.isTest)()?8:(0,O.isSyncService)()?L.Settings.exiftoolProcsPerChild.value??(0,z.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=oe();return e.ended?oe.refresh():e}function ue(e=!1){return(0,d.map)(oe.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,b.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(oe.prior(),(e=>e.ended?void 0:(0,b.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,j.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,f.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,k.toNativePath_)(e))}async function he(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function fe(e){const t=[];return L.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*w.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,B.includesIgnoreCase)(L.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return ne().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const r=i??await(0,te.readMimeType)(e),s=await e.sidecar(),n=(0,X.isImageMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,a=(0,X.isVideoMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,o=L.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await s.exists(),l=n||a||o;return ne().tap({msg:"writeTagDest()",result:l?s:e,meta:{src:e,tagName:t,mimetype:r,writeMetadataToSidecarsIfImage:n,writeMetadataToSidecarsIfVideo:a,writeMetadataToSidecarsIfSidecarExists:o}})}async function pe(e,i=!0){const r=D.PosixFile.for(e);if(r.isSidecar()&&(i=!1),!await r.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(r.nativePath),void ne().debug("readRawTags("+r+"): invalid file, returning null.");const s=await(0,t._readRawTags)(r.nativePath);if(null==s||!i)return s;ne().trace("readRawTags()",{pf:r,pickedFileTags:(0,f.pick)(s,"tz","tzSource",...L.Settings.capturedAtTags.values)});const n=[];for(const e of await r.jsonSidecars())n.push([e,(0,K.readJsonSidecar)(e,s.tz)]);for(const e of await r.existingExifSidecars())n.push([e,(0,t._readRawTags)(e.nativePath)]);const a={original:{},MIMEType:(0,u.mapNotBlank)(s.MIMEType,X.normalizeMimetype),...s},o=[];for(const[e,i]of n){if(null==i)continue;const r=await i;if(null==r)continue;const s=(0,f.omit)(r,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,f.values)(s))?((a.sidecars??(a.sidecars=[])).push(e.base),o.push(...(0,g.toA)(r.History)),(0,I.assignNullishFields)(a.original,(0,f.pick)(a,...(0,f.keys)(s))),(0,f.assignFields)(a,s),ne().debug("readRawTags() sidecar had values",{sidecar:e.base})):ne().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return a.inferred=(0,$.getInferredHistoricValues)(o,e),(0,I.assignNullishFields)(a,a.inferred),a.Rotation=(0,Q.orientationToRotation)(a.Rotation),ne().debug("readRawTags() final",{pf:r,inferred:a.inferred,pickedResult:(0,f.pick)(a,"tz","tzSource",...L.Settings.capturedAtTags.values)}),a}async function ge(e,t){return null==t?void 0:(0,v.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,r=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,X.normalizeMimetype);if((0,u.blank)(r))return void ne().debug("No mimetype for "+i);const n={...t.inferred??{},...t};if(n.inferred??(n.inferred={}),n.original??(n.original={}),L.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const t=n[e];if((0,p.isString)(t)){const i=(0,_.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(ne().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),n[e]=i)}}const o=!await(0,re.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,n,o);if(ne().debug("parseTags()",{tzMeta:l,skipSiblingInference:o}),null!=l?.tz){const e=n.tzSource!==s.defaultVideosToUTC&&void 0;for(const t of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const i=n[t];i instanceof s.ExifDateTime&&(n[t]=(0,M.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,f.assignUndefinedFields)(n.original,n,"tz","tzSource"),(0,f.assignFields)(n,l),(0,f.assignFields)(n.inferred,l)}const c=o?(0,Y.extractMakeAndModel)(n):await(0,re.inferMakeAndModel)(e,n);c.Make!==(0,Y.make)(n.Make)&&(n.original.Make=n.Make,n.inferred.Make=c.Make),c.Model!==(0,Y.model)(c.Make,n.Model)&&(n.original.Model=n.Model,n.inferred.Model=c.Model),!(0,u.blank)(L.Settings.defaultCopyright.valueOrDefault)&&(0,q.isExifUnset)(n.Copyright)&&(n.Copyright=L.Settings.defaultCopyright.valueOrDefault);const d=(0,Z.extractLensMakeModel)(n),h=await(0,V.extractCapturedAt)(e,n,o);if(null==h)return void ne().info("No capturedAt for "+e);!o&&h.isInferred&&(n.inferred.capturedAt=h);const m=(0,H.extractExposureSettings)(n),g=await(0,ie.extractSizeInfoFromFile)(e,n);if(null==g)return void ne().info("No size info for "+i);const y={...c,mimetype:r,capturedAt:h,exposureSettings:m,...(0,se.extractTitleDescription)(n),...d,cameraId:(0,U.cameraIdFromTags)(n),imageId:(0,U.imageIdFromTags)(n),lensId:(0,U.lensIdFromLensInfo)({...d,...(0,f.pick)(n,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(n),tz:n.tz,rating:(0,ee.extractRating)(n)};(0,A.isTest)()&&(y.__parsedBy__=a.default.pid);const w={...n,...y};return ne().debug("parsedTags",{nativePath:i,skipInference:o,...y,inferred:n.inferred,original:n.original,pickedResult:(0,f.pick)(w,"capturedAt","tz","tzSource","Make","Model")}),(0,f.definedValues)(w)}catch(e){return void ne().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,f.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,f.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,T.eqlAsync)(e.sha(),t.sha())||await(0,T.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=D.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,k.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,k.toNativePath_)(e),["-"+t]);return(0,I.pluckCaseInsensitive)(i,t)}catch(e){return void ne().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=he,t.overwriteTags_=async function(e,t){try{await(0,v.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await fe(e)),e.clearThisAndParent()}))}catch(i){ne().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,v.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=fe,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,v.time)("exiftool.writeTags:"+e,(async()=>{const r=new h.MultiMap;for(const[s,n]of(0,f.entries)(t)){const t=await me(e,s,i);r.add(t.nativePath,[s,n])}for(const[t,i]of r.entriesArray()){const r=D.PosixFile.for(t),s=(0,f.fromEntries)(i);ne().info("writeTags()",{src:e,dest:t,t:s}),await le().write(r.nativePath,s,await fe(r)),L.Settings.overwriteOriginal.valueOrDefault||await he(r),r.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,x.nativePathIsFile)(e))return ne().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);ne().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...L.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,G.isVideoExt)(n.default.extname(e))?[]:["-fast"]],r=await(0,v.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{ne().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==r)return;ne().debug("_readRawTags()",{nativePath:e,pickedTags:(0,f.pick)(r,"tz","tzSource",...L.Settings.capturedAtTags.values)}),r.MIMEType=(0,u.mapNotBlank)(r.MIMEType,X.normalizeMimetype),r.GPSDateTime??(r.GPSDateTime=(0,P.concatDateTime)(r.GPSDateStamp,r.GPSTimeStamp));for(const e of(0,f.keys)(r)){const t=r[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete r[e])}const s=(0,l.compactBlanks)([r.Error,...r.errors??[],r.Warning].map(y.toS));return(0,l.isNotEmpty)(s)&&(r.problems=s),ae&&(r.__instance=(0,C.safeUUID)()),r}}),t.parseTags=ge},75767:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(98553),o=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),h=i(54993),f=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),w=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const v=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function b(e){const t=null==e?[]:e.filter((([,e])=>!(0,n.blank)(e)));return 0===t.length?void 0:(0,a.stringify)((0,u.fromEntries)(t))}function S(e){return(0,h.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new o.MultiMap,r=[];for(const a of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(s=e[a])||(0,n.blankish)(s)||(0,l.isNumber)(s)&&(0===s||1===s)||null!=t.zeroesRe.exec((0,h.toS)(s)))continue;const o=e[a],u=S(e[a]),c=(0,t.Tag2SynonymGroup)().get(a);if(null!=c){if(i.includes(c,o)||i.includes(c,u))continue;i.add(c,o)}r.push([a,(0,l.gt0)(o)?o:u])}var s;return b(r)}function M(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function _(e){if((0,n.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([M(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(M)):(0,u.compactBlankValues)(t)}function T({a:e,b:t,field:i,desc:r,parser:s}){const n=s(e[i]),a=s(t[i]),o=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==n||null==a||(0,l.approximates)(n,a,o)?void 0:"Different "+r+": "+e[i]+" ≠ "+t[i]}function E(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,n.blank)(e.lensMake)||(0,n.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,r.lazy)((()=>{const e=new Map;for(const t of v){const i=t[0];for(const r of t)e.set(r,i)}return e})),t.Tag2Synonyms=(0,r.lazy)((()=>{const e=new Map;for(const t of v)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=b,t.renderExifUidId=P,t.decodeExifUid=_,t.findInequalFields=function(e,i){const r=_(e),n=_(i);if(null==r||null==n||e===i)return;const a=(0,f.intersection)((0,u.keys)(r),(0,u.keys)(n)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of a){const t=r[e],i=n[e];if(S(t)!==S(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of v){const t=(0,u.pick)(r,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(n,...e);if((0,u.isEmptyObj)(i))continue;const a=(0,u.values)(t).map(h.toS),o=(0,u.values)(i).map(h.toS);if((0,s.includesAny)(a,o))continue;const l=(0,f.least)((0,u.keys)(t)),c=(0,f.least)((0,u.keys)(i));return{aKey:l,aValue:r[l],bKey:c,bValue:n[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>T({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>T({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>T({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>T({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return E({...(0,w.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=E,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const r=i(22573),s=i(54993),n=/undefined|null|none|n\/a|unknown/i;function a(e){return null==e||(0,r.blank)(e)||n.test((0,s.toS)(e))}t.isExifUnset=a,t.toExifDefined=function(e){return a(e)?void 0:e}},80495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const r=i(19851),s=i(22573),n=i(31586),a=i(68708),o=i(54993),l=i(50213),u=i(97352),c=(0,r.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,s.firstNotBlank)((0,o.toS)(e.ExposureTime),(0,o.toS)(e.ShutterSpeed),(0,o.toS)(e.ShutterSpeedValue),(0,o.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,a.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,n.gt0)(e))return e;const[t,i]=(0,o.toS)(e).split("/").map((e=>(0,n.toInt)(e)));return(0,n.gt0)(t)&&(0,n.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,n.toFloat)(e);return(0,n.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),s=i(40958),n=i(96249),a=i(23838),o=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,o.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,o.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new a.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,n.flatten)((0,o.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function w(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=w,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return w(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return w(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return w(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return w(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return w(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return w(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return w(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return w(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),h=i(50989),f=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),w=i(50213),v=i(81168),b=i(66649),S=i(17415),P=i(29882),M=i(95696),_=i(17217),T=i(28874),E=i(47783);function D(e,t){return(0,d.entries)(t??{}).map((([t,i])=>k({action:e,key:t,value:i})))}function k({action:e,key:t,value:i,ts:s}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:r.ExifDateTime.fromMillis(s??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,h.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=D,t.mkHistoryRecord=k,t.InferAction="infer";const x=(0,s.lazy)((()=>(0,w.mkLogger)("tags.History")));function F(e,t){if(null==e||null==e.History||(0,f.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function C(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,o.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function A(e){if(null==e)return;const t={};for(const[i,r]of(0,d.entries)(e))(0,v.isFirstCharAZ)(i)&&(t[i]=r);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,S.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function I(e,i,r){if(null==e||(0,o.blank)(e))return void x().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const s=(0,_.toNativePath_)(e),a=await(0,E._readRawTags)(s),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!F(a,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...r??{}};if((0,n.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void x().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:r,tagsToWrite:c});x().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:r});const h=M.PosixFile.for(e);return await(0,E.overwriteTags_)(h,c),h.clearThisAndParent(),u}t.tagsContainHistory=F,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const s=(0,m.toA)(e);if((0,n.isEmpty)(s))return{};const l=(0,a.sortBy)(s.filter((e=>(0,v.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,b.datedToMillis)((0,o.mapNotBlank)(e.When,(e=>r.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,o.notBlank)(t)){const r=C(e);(0,o.blank)(r.nativePath)||(0,P.eqlNameWithoutExt)(r.nativePath,i)?u[t]=r:x().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=C,t.inferredToTags=A,t.ensureInferredHistoryRecords=async function(e,i,r){const s=D(t.Actions.infer,r),n=(T.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?A(r):void 0)??{};return T.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(n.Source=e.nativePath),x().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:s,additionalTags:n}),I(i,s,n)},t.ensureHistoryRecords=I},3432:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const s=r(i(53705)),n=i(77988),a=i(19851),o=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),h=i(17415),f=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),w=i(61424),v=(0,a.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function b(e,t,i){{const e=S(t);if(null!=e&&(0,h.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,h.isValidZone)(t.tz)||t.tzSource===n.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,o.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof n.ExifDateTime&&(0,h.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,w.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function S(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return v().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,s.default)(t,i),r=(0,h.normalizeZone)(e);return v().tap({msg:"zoneFromLatLon()",result:r,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return v().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,f.isValidDate)(i))for(const r of g.Settings.capturedAtTags.values){const s=(0,u.toDated)(t[r]);if(null==s||(0,f.isValidDate)(s))continue;const n=Math.round(15*i.diff(s,"minutes").as("minutes")/15),a=(0,h.normalizeZoneOffsetMinutes)(n),o=0===a?void 0:(0,h.normalizeZone)(a);if(null!=o)return v().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:o.name,tzSource:"infer:filename (diff with "+r+")"},meta:{dt:(0,c.datedToISO)(s),rawTzoffsetMinutes:n,normalizedOffsetMinutes:a}})}}t.maybeInferTimezone=async function(e,t,i){return v().tap({msg:"maybeInferTimezone()",result:await b(e,t,i)})},t.zoneFromLatLon=S,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const r=i(77988),s=i(40958),n=i(22573),a=i(38639),o=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),h=i(48884),f=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const s=(0,p.normalizeZone)(e?.formatted),n=r.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:s??t??r.UnsetZone});if(!0===n?.isValid)return n}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,n.toNotBlank)(e.title),Description:(0,n.toNotBlank)(e.description),GPSLatitude:(0,h.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,f.validLat)(e)?e:void 0)),GPSLongitude:(0,h.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,f.validLon)(e)?e:void 0)),GPSAltitude:(0,h.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,o.map)(e.favorited,a.isTrue),peopleNames:(0,s.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,s.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},97573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rawTagKeywords=t.parseKeywordStruct=t.isKeywordStruct=t.parseCategories=t.splitKeywords=t.splitKeyword=t.delimRe=t.keywordToPath=void 0;const r=i(77988),s=i(66150),n=i(19851),a=i(40958),o=i(22573),l=i(41400),u=i(96249),c=i(68708),d=i(59455),h=i(48884),f=i(50213),m=i(68852),p=i(81168),g=i(28874),y=(0,n.lazy)((()=>(0,f.mkLogger)("tags.KeywordTags"))),w=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordPathSeparators.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g")))));function v(e){const i=(0,t.delimRe)();return null==i?[e]:(0,a.compactBlanks)(e.split(i))}function b(e){return null==e||e instanceof r.BinaryField?[]:(0,a.compactBlanks)(Array.isArray(e)?(0,u.flatten)(e.map(b)):v(e))}function S(e){return null==e?[]:(0,p.isString)(e)?(0,o.blank)(e)?[]:[[e]]:(0,u.flatten)((0,d.toA)(e.Category).map(S).map((t=>t.map((t=>(0,a.compact)([e._,...t]))))))}(0,l.later)((()=>{g.Settings.keywordPathSeparators.watchLater((()=>w.unset()))})),t.keywordToPath=function(e){const t=w();return(0,a.compactBlanks)(null==t?[e]:e.split(t))},t.delimRe=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g"))))),g.Settings.keywordDelimiters.watchLater((()=>t.delimRe.unset())),t.splitKeyword=v,t.splitKeywords=b;const P=/^\(?none\)?$/i;function M(e){if(!(0,o.blank)(e)&&null==P.exec(e))try{const t=new s.XMLParser({textNodeName:"_"}).parse(e);return(0,u.flatten)((0,d.toA)(t?.Categories?.Category).map(S))}catch(t){return void y().warn("parseCategories() failed:",{err:t,s:e})}}function _(e){return Array.isArray(e)&&e.every(_)||null!=e&&(0,p.isString)(e.Keyword)&&(null==e.Children||Array.isArray(e.Children)&&e.Children.every(_))}function T(e){if(null==e)return[];if(Array.isArray(e)&&e.every(_))return(0,h.flatMap)(e,T);if((0,o.blank)(e.Keyword))return[];const t=(0,d.toA)(e.Children);return(0,a.isEmpty)(t)?[[e.Keyword]]:(0,h.flatMap)(t,T).map((t=>[e.Keyword,...t]))}t.parseCategories=M,t.isKeywordStruct=_,t.parseKeywordStruct=T,t.rawTagKeywords=function(e){const t=[];if(null!=e){const i=[...g.Settings.keywordTags.values];if(i.includes("Categories")){(0,h.remove)(i,"Categories");const r=M(e.Categories);null!=r&&t.push(...r)}for(const r of i){const i=(0,c.pluckDeep)(e,r)?.value;(0,o.blank)(i)||(_(i)?t.push(...T(i)):t.push(...Array.isArray(i)?i:b(i)))}}return y().tap({msg:"rawTagKeywords()",result:(0,a.compactBlankish)((0,a.uniq)(t)),meta:{t:null==e?void 0:(0,c.pick)(e,...g.Settings.keywordTags.values)}})}},15912:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(55835),o=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),h=i(28874),f=i(30748),m=(0,r.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,f.make)(e.LensMake),i=(0,f.make)(e.Make),r=[],o=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],b),u=(0,s.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:o,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&r.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==b(e))continue;(0,n.notBlank)(t)&&r.push({lensMake:t,lensModel:e,lensInfo:o});const a=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))a.includes(t)&&r.push({lensMake:i,lensModel:e,lensInfo:o});for(const i of(0,s.compactBlanks)([t,...h.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&r.push({lensMake:i,lensModel:e,lensInfo:o});a.startsWith("vr ")&&"Nikon"===i&&r.push({lensMake:"Nikon",lensModel:e,lensInfo:o})}for(const e of r){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=S(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,a.map)(e.lensInfo,S)}return(0,c.greatestBy)(r,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const w=/([\d. -]+)\s?mm\b/i,v=/\bf\/?([\d.\-]+)/i;function b(e){if((0,n.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=w.exec(e)?.[1].replace(/\s/g,""),i=v.exec(e)?.[1];return y(t)&&y(i)?S(`${t}mm f/${i}`):void 0}function S(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,a.mapOr)((0,o.toFloat)(e),(e=>String((0,o.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=b,t.cleanBogusPrecision=S,t.normalizeLensModel=function(e){return S(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(68708),o=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function h(e,t,i=""){const r=e.replace(t,i);return r===e?e:h(r,t,i)}const f=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=f.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,r.lazy)((()=>new p)),y=/\bgopro\b/i;function w(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=h(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=w(e.Make)??b(e.Software)??b(e.CreatorTool)??function(e){return y.test((0,o.toS)(e.HandlerDescription))||y.test((0,o.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,a.compactValues)({Make:t,Model:i})??{}},t.make=w;const v={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function b(e){if(!(0,s.blank)(e))for(const[t,i]of(0,a.entries)(v))if(i.test(e))return t}t.makeFromSoftware=b;const S=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=S.exec(i);null!=e&&(i=e[1].trim())}const r=(0,n.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=r)return r[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,n.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=h(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},38010:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MergedTags=t.revisionToResourceEvent=t.resourceEventToRevision=t.isSetRevision=t.isPrimitiveRevision=t.isBaseRevision=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(55835),u=i(31586),c=i(68708),d=i(67478),h=i(59455),f=i(54993),m=i(72993),p=i(50213),g=i(84885),y=i(66649),w=i(98725),v=(0,s.lazy)((()=>(0,p.mkLogger)("tags.MergedTags")));function b(e){return(0,u.isNumber)(e?.createdAt)&&(0,o.notBlank)(e?.field)}function S(e){return null==e?.op&&b(e)}function P(e){return e?.sourceIsPrimary??e?.shown??!1}function M(e){return e?.sourceModifiedTime??e?.mtime??0}t.isBaseRevision=b,t.isPrimitiveRevision=S,t.isSetRevision=function(e){return["add","delete"].includes(e?.op)&&b(e)},t.resourceEventToRevision=function(e){if(null==e||!(0,f.toS)(e.SoftwareAgent).startsWith((0,m.AppName)()))return v().tap({msg:"resourceEventToRevision() invalid",result:void 0,meta:{resourceEvent:e}});const t=e.Changed;if((0,o.blank)(t))return v().tap({msg:"resourceEventToRevision() missing Changed field name",result:void 0,meta:{resourceEvent:e}});const i=(0,c.pick)((0,o.mapNotBlank)(e.Parameters,d.parseJSON)??{},"newValue","priorValue");if((0,c.isEmptyObj)(i))return v().tap({msg:"resourceEventToRevision() missing Parameter fields",result:void 0,meta:{resourceEvent:e}});const r=(0,y.datedToMillis)((0,w.parseDated)({input:e.When}));return null==r?v().tap({msg:"resourceEventToRevision() missing createdAt (When)",result:void 0,meta:{resourceEvent:e}}):(0,o.blank)(e.Action)?v().tap({msg:"resourceEventToRevision() missing op (Action)",result:void 0,meta:{resourceEvent:e}}):v().tap({msg:"resourceEventToRevision()",result:{createdAt:r,field:t,op:"assign"===e.Action?void 0:e.Action,...i},meta:{resourceEvent:e}})},t.revisionToResourceEvent=function(e){return{Action:e.op??"assign",Changed:e.field,InstanceID:(0,l.map)(e.id,f.toS),Parameters:(0,g.stringifySorted)((0,c.pick)(e,"newValue","priorValue")),SoftwareAgent:(0,m.AppNameVersion)(),When:r.ExifDateTime.fromMillis(e.createdAt??Date.now())}},t.MergedTags=class{constructor(e){this.name=e,this.revisions=[],this.tags=[],this.logger=(0,p.mkLogger)(`MergedTags(${e})`)}addRevision(...e){this.revisions.push(...e)}addTag(...e){this.tags.push(...e),(0,a.sortBy)(this.tags,(e=>[!P(e),-M(e)]))}get(e){const t=(0,a.sortBy)(this.revisions.filter((t=>t.field===e)),(e=>e.createdAt)),i=this.tags.find((t=>null!=t[e]));let r=i?.[e];const s=[];var l;null!=r&&(0,o.mapNotBlank)((l=i,l?.SourceFile??l?.uri),(e=>s.push(e)));const u=t.every(S)&&this.tags.every((t=>!Array.isArray(t[e])));if(u){for(const i of t)null!=r&&r!==i.priorValue&&r!==i.newValue?this.logger.info("get("+e+"): skipping revision because expected prior or new value didn't match current value",{revision:i}):(r=i.newValue,s.push(`Revision@${i.createdAt}`));return null==r?void 0:{value:r,source:s}}{const e=(0,h.toA)(r);for(const i of t)if("add"===i.op&&null!=i.newValue)s.push(`Revision@${i.createdAt}`),(0,n.pushUniq)(e,...(0,h.toA)(i.newValue));else if("delete"===i.op&&null!=i.priorValue){s.push(`Revision@${i.createdAt}`);for(const t of(0,h.toA)(i.priorValue))(0,n.remove)(e,t)}return{value:e,source:s}}}}},16170:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const r=i(22573),s=i(54993),n=i(2322),a=i(277),o=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function h(e){return(0,r.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function f(e){const t=(0,s.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,n.isChrome)(t)||(0,n.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,s.toS)(e))},t.isImageMimeType=function(e){return(0,s.toS)(e).startsWith("image/")},t.isVideoMimeType=h,t.normalizeMimetype=f,t.isSharpMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,r.blank)(t)&&(h(t)?await(0,l.isVideoSupported)():(0,o.isHeifMimeType)(t)?await(0,a.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},66039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderNameTag=t.parseName=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(55835),l=i(75020),u=i(59455),c=i(50213),d=i(68852),h=i(81168),f=i(70417),m=i(28874),p=(0,r.lazy)((()=>(0,c.mkLogger)("tags.Names")));function g(e){return(0,d.matchQuotes)((0,d.escapeRegExp)(e))}const y=/(\(\s*\d+\s*-\s*[\d?]{0,4}\s*\)?)/,w=/([,\s]+(?:jr\.?|junior|sr\.?|senior|[iv]+\.?))$/i,v=/\b([A-Z‘’']+[-A-Z‘’']{2})\b/,b=/^[()[\]/.\-_]+$/;function S(e){if((0,a.blank)(e))return;let t=e.replace(/\s+/g," ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").trim();const i=(0,o.map)((0,h.spliceCapture)(t,y),(e=>(t=e.unmatched.trim(),e.captured.replace(/\s+/g,"")))),r=(0,o.map)((0,h.spliceCapture)(t,w),(e=>(t=e.unmatched.trim(),e.captured.trim()))),l=[],c=[],b=[];for(const e of m.Settings.tagNamesGiven.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(l.push(i.captured),t=i.unmatched.trim())}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesGivenSurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`(${(0,d.escapeRegExp)(e.charAt(0))}\\s*[^${(0,d.escapeRegExp)(e.charAt(0))}]+\\s*${(0,d.escapeRegExp)(e.charAt(1))})`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(c.push(i.captured),t=i.unmatched.trim())}while(null!=i)}let S;function M(e){(null==S||S>e.matchedIndex)&&(S=(0,f.min)([S,e.matchedIndex]))}if(m.Settings.tagNamesCapitalizedAsFamily.valueOrDefault){let e;do{e=(0,h.spliceCapture)(t,v),null!=e&&(M(e),b.push(e.captured),t=e.unmatched.trim())}while(null!=e)}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesFamilySurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`${(0,d.escapeRegExp)(e.charAt(0))}\\s*([^${(0,d.escapeRegExp)(e.charAt(0))}]*)\\s*${(0,d.escapeRegExp)(e.charAt(1))}`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(M(i),b.push(i.captured),t=i.unmatched.trim())}while(null!=i)}if(m.Settings.tagNamesLexical.valueOrDefault){const e=t.indexOf(",");e>=0&&(S=void 0,b.push(t.substring(0,e).trim()),l.push(t.substring(e+1).trim()),t="")}for(const e of m.Settings.tagNamesSurnames.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(M(i),b.push(i.captured),t=i.unmatched.trim())}for(const e of(0,u.toA)((0,s.mapNotEmpty)((0,s.compactBlanks)(m.Settings.tagNamesSurnamePrefixes.values),(e=>(0,n.sortBy)(e,(e=>-e.length)).map((e=>new RegExp(`\\b(${g(e)}\\s+\\S+)`,"i"))))))){const i=(0,h.spliceCapture)(t,e);null!=i&&(M(i),b.push(i.captured),t=i.unmatched.trim())}null!=S&&t.length>S&&(0,s.mapNotEmpty)((0,s.compactBlanks)(t.slice(S).split(/\s+/)),(e=>{b.push(...e),t=t.slice(0,S)}));const _=(0,s.compactBlanks)(t.split(/\s+/)),T=l.length,E=b.length;if(_.length>0)if(0===T&&E>0)l.push(..._);else if(0===E&&T>0&&1===_.length)b.push(..._);else if(1===_.length)l.push(..._);else{const e="western"===m.Settings.tagNamesOrder.valueOrDefault;b.push(e?_.pop():_.shift()),l.push(..._)}return{givenNames:P([...l,...c]),modifier:r,lifespan:i,familyNames:P(b),minFamilyNameIndex:S}}function P(e){return(0,s.uniq)((0,s.compactBlanks)(e).filter((e=>null==b.exec(e))))}function M(e){let t="";for(const i of(0,s.compactBlanks)(e))t+=i.startsWith(",")?i:" "+i;return t.trim()}function _(e,t,i){return M("western"===m.Settings.tagNamesOrder.valueOrDefault?[t,e,i]:[e,t,i])}t.parseName=S,t.renderNameTag=function(e){if((0,a.blank)(e))return[];const t=m.Settings.tagNamesFormatter.valueOrDefault,i="family/given"===t;if("family/fullname"===t||i){const t=S(e);if(null==t)return[];{const e=M([t.modifier,t.lifespan]),r=M(t.givenNames);return(0,s.compactBlanks)((0,s.notEmptyOr)(t.familyNames,[m.Settings.tagNamesDefaultFamily.valueOrDefault])).map((t=>[l.TagRoots.Who,t,i?M([r,e]):_(t,r,e)]))}}return[[l.TagRoots.Who,e.trim()]]}},95141:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const r=i(21605),s=i(54993),n=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,n.isVideoMimeType)(e.MIMEType)?(0,r.normalizeRotation)(e.Rotation):void 0)??o(e.Orientation)};const a=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function o(e){return(0,r.isRotation)(e)?e:null!=e?a.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,s.toS)(e).startsWith("Mirror")},t.orientationToRotation=o;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,r.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,r.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const r=i(55835),s=i(31586),n=i(28874);function a(e){const t=(0,s.toInt)(e);return null==t?void 0:(0,s.clamp)(-1,5,t)}function o(e){return a(e?.Rating)??(0,s.mapNumeric)((0,s.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,r.map)(e?.favorited,(e=>!0===e?n.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=a,t.extractRating=o,t.extractLiked=function(e){const t=o(e);return null==t?void 0:t>=n.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(88561),o=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,r.lazy)((()=>new a.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,s.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,n.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,o.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),s=i(40958),n=i(22573),a=i(81168),o=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,a.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const o=(0,u.isJsonExt)(i.ext),l=o||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=o||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,s.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,s.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return o&&function(e,i){const r=(0,a.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function s(e){return(0,n.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const o=s(e.slice(r.length)),l=s(i.slice(r.length));return o&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,o.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,a.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(33374),o=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),h=i(34943),f=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),w=(0,r.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),v=(0,r.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:n.minuteMs})));async function b(e,t){if(null==e)return;const i=null==t||(0,s.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const r=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return S(i,r,await(0,h.rawInfo)(e));const n=S(i,r);if(null!=n)return n;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await b(await(0,f.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function S(e,t,i){t??(t=(0,y.extractRotation)(e));const r=(0,o.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,a.isDimensions)(e)?e:void 0));if(null==r)return w().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo,fileDimensions:r}});const s=(0,a.maybeDimSwap)(r,t);return w().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:s.height,ImageWidth:s.width,aspectRatio:(0,d.aspectRatio)(s),dimensions:s,rotation:t,fileDimensions:r,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return v().getOrSetAsync(i.nativePath,(()=>b(i,t)))},t.extractSizeInfoFromTags=S},3127:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tag_fts_path=t.tag_fts_root=void 0;const r=i(54993),s=i(42231);t.tag_fts_root=function(e){const t=(0,r.toS)(e).indexOf(s.TagSep);return-1===t?"":e.substring(0,t)},t.tag_fts_path=function(e){return(0,r.toS)(e).split(s.TagSep).filter((e=>null!=e&&""!==e.trim())).join(" ")}},61424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),h=i(48884),f=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),w=i(79842),v=i(21330),b=i(98725),S=i(51275),P=i(35280),M=i(19748),_=i(88561),T=i(95696),E=i(65238),D=i(17217),k=i(57902),x=i(28874),F=i(80496),C=i(65162),A=i(28544),I=i(47783),O=i(88840),L=i(30748),R=i(16170),N=(0,n.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),B=7;async function j(e){return x.Settings.siblingInference.valueOrDefault===F.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+x.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(x.Settings.siblingInference.valueOrDefault===F.TagInferenceSettingValues.auto&&await(0,E.isSlowDir)(e.nativePath)&&!await(0,E.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function z(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of r){const r=(0,L.extractMakeAndModel)(await(0,I.readRawTags)(t));if((0,f.definedAndNotEql)(r.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:r});else if((0,f.definedAndNotEql)(r.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:r});else if(null!=r.Make&&null!=r.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:k.LogLevels.info,result:r,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await j(e.parent()))return;const t=await W(e);return null!=t&&(0,v.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,v.toExifDateTime)(t.before.date,(0,S.getZoneName)(t.before.date)),(0,v.toExifDateTime)(t.after.date,(0,S.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,n.lazy)((()=>new _.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await H(e),i=await z(t?.younger),r=await z(t?.older);return null==i||null==r?void 0:{before:i,after:r,index:i.index,slots:i.index+r.index+1}}))}t.beforeAfterCapturedAt=W;const U=(0,M.extFilter)(O.ExtTypes.AssetFile);function q(e){return null==e?[]:(0,a.compact)((0,h.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function H(e,t=7,i=!0){if(!await j(e.parent()))return;const r=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(U(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==r)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const s=(0,o.sortBy)(r,(e=>(0,C.bname)(e))),n=(0,D.findFileIndex)(e,s);if(n<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),H(e,t,!1)):void 0;const l=x.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[s.slice(n-2*t,n),s.slice(n+1,n+1+2*t)],d=[],h=[];for(;(0,a.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,a.isNotEmpty)(c)&&h.length=l&&h.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:h},meta:{f:e}})}t.nearestSiblings=H,t.nearestSiblingTzOffset=async function(e){if(!await j(e.parent()))return;const t=q(await H(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,B);for(const t of e){const e=await(0,I.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==r.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,a.uniq)([(0,C.bname)(e,!0),(0,C.bname)(e,!1)]),i=(0,b.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const r=await e.stat();if(null!=r){for(const e of["birthtime","atime","mtime","ctime"])if((0,w.datedOverlap)({a:i,b:r[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:r}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:r}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,b.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const r=i[e];if(null!=r&&!0===(0,w.datedOverlap)({a:t,b:r}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:s.DateTime.fromJSDate(r)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),h=i(81168);function f(e){return(0,u.toS)((0,o.isString)(e)?e:e?.name).normalize()}function m(e){return(0,r.compact)((0,l.toA)(e).map(f))}function p(e,i=t.TagSep){return m(e).map((e=>(0,o.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(n.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function w(e){return(0,n.blank)(e)?void 0:Array.isArray(e)?f((0,r.last)(e)):(0,r.last)(g(e))}function v(e,t){if((0,r.isEmpty)(e)||(0,r.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,h.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=f,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,r.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,r.uniqBy)((0,l.toA)(e),(e=>(0,r.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,r.compact)(t).map((e=>y(e))));return(0,r.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=w,t.leafIsExcluded=function(e,t){return(0,a.mapOr)(w(e),(e=>(0,h.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=v,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,s.sortBy)(e.filter(r.isNotEmpty),(e=>-e.length)))t.some((e=>v(i,e)))||t.push(i);return(0,s.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const r=i(40958),s=i(22573),n=i(68708),a=i(54993);t.extractTitleDescription=function(e){const t=(0,r.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,s.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const r of i){const i=(0,a.toS)(e[r]).trim();if((0,s.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,n.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(96249),o=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),w=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function v(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function b(e){const t=await v(e);return(0,s.uniq)((0,a.flatten)(t.map(m.uriEncodingVariants)))}async function S(e,t){if((0,n.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void w().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case o.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case o.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case o.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,n.blank)(e)?w().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=v,t.nativePath2uriVariants=b,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(S(e,t),b))),(0,s.uniq)(i)},t.uri2nativePath=S,t.uriExists=async function(e,t){const i=await S(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),s=i(57975),n=i(90595),a=i(22573),o=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",w=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class v{static isUri(e){return e instanceof v||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,s,n=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,n),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=s??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,n))}get fsPath(){return T(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:s,fragment:n}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===s?s=this.query:null===s&&(s=g),void 0===n?n=this.fragment:null===n&&(n=g),t===this.scheme&&i===this.authority&&r===this.path&&s===this.query&&n===this.fragment?this:new S(t,i,r,s,n)}static parse(e,t=!1){const i=w.exec(e);if(!i)return new S(g,g,g,g,g);const r=i[2]||g,s=x(i[4]||g),n=(i[5]||g).split("/").map(x).join("/"),a="psfile"===r&&n.startsWith("//")?n.slice(1):n,o=(0,u.toURLSearchParams)(i[7]),l=x(i[9]||g);return new S(r,s,a,o,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new S("file",t,e,g,g)}static from(e){return new S(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?v.file(r.win32.join(T(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,o.map)(this.path,(e=>(0,d.findLast)(e.split(y),a.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return E(this,e)}toJSON(){return this}[s.inspect.custom](){return this.toString()}}t.URI=v;const b=h.isWinPortable?1:void 0;class S extends v{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=T(this,!1)),this._fsPath}toString(e=!1){return e?E(this,!0):(null==this._formatted&&(this._formatted=E(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=b),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,a.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function M(e,t){let i,r=-1;for(let s=0;s=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||45===n||46===n||95===n||126===n||t&&47===n)-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),void 0!==i&&(i+=e.charAt(s));else{void 0===i&&(i=e.substr(0,s));const t=P[n];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),i+=t):-1===r&&(r=s)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function _(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function E(e,t){const i=t?_:M;let r="";const{scheme:s,query:n,fragment:o}=e;let{authority:l,path:u}=e;if(s&&(r+=s,r+=":"),(l||"file"===s)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,a.mapNotBlank)(n,(e=>r+="?"+e)),o&&(r+="#",r+=t?o:M(o,!1)),r}function D(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+D(e.substr(3)):e}}t.encodeURIComponentFast=M,t.uriToFsPath=T;const k=/(?:%[\dA-Z][\dA-Z])+/gi;function x(e){return e.startsWith("xn--")?(0,n.toUnicode)(e):e.match(k)?e.replace(k,(e=>D(e))):e}t.percentDecode=x,t.toURI=function(e){return v.isUri(e)?e:v.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),s=i(40958),n=i(50357),a=i(89937),o=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",a.PS_LOCAL_FILE_SCHEME,a.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,o.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&f(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,n.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,s.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),s=i(22573),n=i(51926),a=i(89937),o=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,s.blank)(e))return;if(null==(t=null!=t&&(0,o.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,s.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,n.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:a.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==a.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,s.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,n=(0,s.notBlank)(t)&&!t.includes(i);if(n&&!(0,s.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const o=await(0,c.bestVolumeForVolsha)(e.authority);return null!=o?f(o.mountpoint,e.path):n&&(0,s.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),s=i(22573),n=i(51926),a=i(89937),o=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,s.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,s.blank)(t))return;const i=(0,r.uniq)([t,(0,o.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,n.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==a.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,o.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,n.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const a=n(i(76760)),o=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,o.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,o.notBlank)(t.remoteHost)&&(0,o.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:a.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,o.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,o.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(a.sep)}`;const s=i.slice(1),n=await(0,p.volumes)();for(const t of(0,u.toA)(n))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return a.join(t.mountpoint,...s);return await(0,h.isReadableDirectory)(t)?a.join(t,...s):void 0}},85087:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),s=i(42659),n=i(9103),a=i(37628);t.volsha=(0,n.memoize)((e=>(0,r.mapNotBlank)(e,a.shortStringSha)),{maxSize:128,ttlMs:s.minuteMs})},60865:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),s=i(30577);t.channel=function(){return(0,s.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),s=i(22573),n=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function a(e){if(e instanceof r.SemVer)return e.version;const t=n.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=a,t.semverSatisfies=function(e,t){if((0,s.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const n=a(e);return null!=n&&(0,r.satisfies)(n,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},8540:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),s=i(9595),n=i(29882),a=i(43334),o=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([o.Settings.libraryDir.valueOrDefault,(0,s.originalsDir)(),...o.Settings.scanPaths.values]))if((!a.isPosix||!(0,n.pathIsRoot)(t))&&(0,n.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},42233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentVolumeRoots=void 0;const r=i(45200),s=i(98770),n=i(7014);t.currentVolumeRoots=(0,s.lazyFsAsync)("currentVolumeRoots",(async function(){const e=[],t=[];for(const i of await(0,n.volumes)()){t.push(i.mountpoint);const s=(await(0,r.nativePath2uri)(i.mountpoint,i))?.toString();null!=s&&e.push(s)}return{uris:e,mountpoints:t}}))},1485:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),s=i(22573),n=i(59455),a=i(50213),o=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.DfPosix"))),w=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function v(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),s=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),n=t&&(i||r||s);return y().tap({msg:"acceptPosixVolume()",result:!n,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:s}})}t.acceptPosixVolume=v,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,n.toA)(await w());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,s.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,n.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,o.assignMissingPrimitives)(i,e))}return t.filter(v)}},69108:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,a.toInt)(e,{defaultValue:0})*o.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,s.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const s=m(e.Used)??0,n=m(e.Available)??0;if(0!==s||0!==n)return{filesystem:t,mountpoint:i,size:d.isMac?s+n:r,used:s,available:n};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:s,available:n})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,s.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,n.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const a=p(i);return!0===e&&a.forEach((e=>e.remote=!1)),a},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),w=i(24399),v=i(28874),b=i(24541),S=i(60224),P=i(63870),M=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const _=/([a-z]+)(?::\\)?/i;function T(e){return e?.match(_)?.[1]?.toUpperCase()}function E(e){return(0,l.map)(T(e),(e=>e+":\\"))}function D(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(T(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function k(e){return null!=e&&!(0,a.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,a.notBlank)(e.DisplayRoot),...(0,l.map)((0,S.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function x(e){return`Get-Volume ${(0,f.toS)(T(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=E,t.getPsDriveCommand=D,t.getVolumeCommand=x,t.getLocalVolumesWin_=function(){return w.PowerShell.instance().executeJsonToA(x())};const F=/\{([-a-z\d]{7,})\}/i;function C(e,t){return e=e?.trim(),(0,a.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function A(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void M().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=E(e.DriveLetter);if(null==t)return void M().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,s.compact)([C(e.HealthStatus,"healthy"),C(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,a.notBlank)(e.DriveLetter)&&(0,a.blank)(i);return M().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(n=e.UniqueId,M().tap({msg:"uniqueId2uuid",result:(0,l.map)(F.exec((0,f.toS)(n)),(e=>e[1])),meta:{s:n}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var n}async function I(){const e=(0,s.uniq)((0,h.toA)(await(0,b.mountpointsWin)()).map(E)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>w.PowerShell.instance().executeJsonToA(D(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:v.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,s.compact)((0,o.flatten)(t).map(k)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>w.PowerShell.instance().executeJsonToA(x(e)).catch((t=>(M().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:v.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),a=(0,s.compact)((0,o.flatten)(r).map(A)),l=(0,s.uniq)([...i,...a].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,n.sort)((0,s.uniq)([...i,...a].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));M().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:a,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...a.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=A,t.volumeInfoWin=I},68884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),w=i(83278),v=i(8103),b=i(16287),S=i(45969),P=i(43334),M=i(69108),_=i(98770),T=i(44224),E=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,S.isDocker)()||(0,d.isBillingService)()||null==await(0,v.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,E.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const D=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?D().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,T.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),b.isReadableDirectory),(e=>e.map((e=>w.BaseFile.for(e).clear().childDirectories())))))}):D().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,s.isEmpty)(e)?[]:(D().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,E.mountpointsTtlMs)(),f:async e=>{const t=await(0,M.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void D().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await k(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,E.mountpointsTtlMs)()}))),(0,o.later)((()=>(0,_.setupVolumeTTL)(t.gioVolumes)));const k=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,E.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,n.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(n.notBlank).get()}}catch(t){return void D().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs})},98770:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),s=i(5233),n=i(41400),a=i(56038),o=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,a.time)("volumes."+e,(()=>(0,s.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,o.isRetriableError)(e)&&!1!==(0,o.isIgnorableError)(e)})))),i);return(0,n.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),w=i(98770),v=i(63870),b=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>b().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>b().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const n=(0,c.sortIgnoreCase)((0,s.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),a=[];for(const t of n){const s=e.find((e=>e.mountpoint===t)),n=i?.find((e=>e.mountpoint===t)),o={...s,...n},u=r?.find((e=>e.filesystem===o.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(o,u),null==o.size||null==o.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];b().info("backfilling mountpoint",{info:n,vol:s,df:e}),null!=e&&(0,l.assignMissingPrimitives)(o,e)}a.push(o)}return a};const S=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return S.exec(e)?.[1]?.split(".").map((e=>(0,a.toInt)(e)))})),M=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,a.gte)(t[0],2)&&(0,a.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,w.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await M()],{timeoutMs:(0,v.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,n.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,a.toInt)(e.fsused),r=(0,a.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return b().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,w.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,v.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,n.toNotBlank)(e.PARTLABEL)??(0,n.toNotBlank)(e.LABEL),uuid:(0,n.toNotBlank)(e.PARTUUID)??(0,n.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),s=i(19851),n=i(40958),a=i(22573),o=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),w=(0,s.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,n.uniq)(e.map((e=>e.filesystem?.match(v)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),s=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of s)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,a.blank)(t.MountPoint)||(0,o.isTrue)(t.OSInternal)?w().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){w().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const v=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),w=i(84777),v=i(34330),b=i(8769),S=i(34102),P=i(17217),M=i(16287),_=i(43334),T=i(28874),E=i(8540),D=i(68884),k=i(44224),x=i(24541),F=i(69375),C=i(63870),A=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function O(e=(0,C.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function L(){I()}t.localMountpointSetup=(0,r.lazy)((async()=>{T.Settings.libraryDir.watchLater(I),T.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&T.Settings.scanAllDrives.valueOrDefault?(0,o.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(_.isMac&&(e.info("Setting up Mac diskutil activity watcher"),O((0,C.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),_.isLinux){const i=(0,k.maybeWatchProcMounts)();await(0,D.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),O((0,C.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),O((0,C.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),a.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=T.Settings.mountpoints.values;if((0,s.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",_.isWin?x.mountpointsWin:k.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,s.isEmpty)(e))return A().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,n.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,C.commandTimeoutMs)(),f:async e=>!(!(0,E.mightBeAssetMountpoint)(e)&&(0,F.isExcludedMountpoint)(e)||T.Settings.validateMountpoints.valueOrDefault&&!await(0,M.isReadableDirectory)(e)&&(A().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,b.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(_.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return _.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,o.later)((()=>{(0,S.ee)().on("clearCache",(()=>{D.gioVolumes.unset(),I()})),T.Settings.mountpointsTtlMs.watch(O)}),(0,c.isTest)()?1:a.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>L(),minCallDelayMs:1.5*a.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:D.GioCommand,args:D.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(D.gioVolumes.unset(),L()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const N=(0,r.lazy)((async()=>{if(!_.isLinux)return!1;try{return 0===(await(0,w.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,C.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,v.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>L(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(48884),o=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),w=i(28874),v=i(69108),b=i(68884),S=i(59107),P=i(69375),M=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await D()??await(0,c.thenMap)((0,v.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,b.isGioSupported)())try{await(0,c.thenMap)((0,b.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){M().warn("Failed to fetch gio volumes",e)}return e};const _="/proc/mounts";function T(e){return!w.Settings.excludedFilesystemTypes.has(e)}function E(e){return!(0,P.isExcludedMountpoint)(e)&&(!w.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function D(e=_,t=T,i=E){if(y.isLinux)try{const r=await(0,f.readLines_)(e),n=(0,s.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,a.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),o=await(0,c.filterAsync)({name:"mountpoints filter",arr:n,f:async([e,r])=>{const s=t(e),n=await i(r);return M().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:s&&n,meta:{fs:e,mp:r,fsOK:s,mpOK:n}})}});return M().tap({msg:"readProcMounts()",result:o.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void M().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=T,t.readProcMounts=D,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(_)?new h.FileWatcher(_,{recursive:!1,persistent:!1},(()=>{M().info("detected change in "+_),(0,d.setUnrefTimeout)((()=>S.mountpoints.refresh()),n.secondMs)})):void 0))},24541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),s=i(42659),n=i(13538),a=i(50213),o=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,n.thenOrTimeoutError)(f(),o.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*s.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(9103),o=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,n.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,s.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,o.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,o.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,o.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,o.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,s.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,a.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),s=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,n=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function a(e){if((0,r.blank)(e))return;const i=s.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(n,""),remoteShare:i.remoteShare};const a=t.nfsRe.exec(e);if(null!=a){const e=a[1],t=a[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=a(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=a},60224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(55835),o=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),w=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await T()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,a.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const v=["LocalName","RemoteName","Status"],b=["NETUSE","get",v.join(",")],S=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function M(e){if(!(0,s.blank)(e))return(0,o.opt)(e).flatMap((e=>S.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,o.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,s.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,o.opt)(e.pathname).filter(s.notBlank).getOrElse((()=>"/"))}))))).get()}async function _(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,b,{timeoutMs:15*n.secondMs}),i=(0,u.parseFixed)(v,t);return(0,r.compact)(i.map((e=>(0,a.map)(S.exec((0,l.toS)(e.RemoteName)),(t=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=M,t._netInfoWinWmic=_;const T=(0,w.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?_():(0,r.compact)(e.filter((e=>(0,s.notBlank)(e.LocalName))).map((e=>(0,a.map)(M(e.RemoteName),(({host:t,share:i})=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,h.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),s=i(12168),n=i(28874);t.mountpointsTtlMs=function(){return n.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return n.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return n.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=s.MiB/r.secondMs},86848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(38639),o=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),w=i(95696),v=i(45969),b=i(28874),S=i(59107),P=i(63870),M=i(68995),_=(0,s.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),T=(0,s.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function E(e){return(0,a.isTrue)(e.ignorable)||(0,v.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function D(e){if((0,n.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function k(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=D(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function x(e){if(b.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of b.Settings.volumeUuidFilePaths.values){const i=w.PosixFile.for(e.mountpoint).join(t),r=await k(i).catch((e=>_().info("Failed to read "+i,{error:e})));if(null!=r)return _().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,M.volumeUuidSubpath)());if("/"===e.mountpoint)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(b.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(b.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,M.writeVolumeUuid)(e);if(!(0,n.blank)(t))return _().tap({msg:"readVolumeUUID(): wrote new "+(0,M.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return _().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,o.later)((()=>{(0,m.ee)().on("clearCache",(()=>T.clear())),S.mountpoints.watchLater((()=>T.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(E(e))return;if((0,a.isFalse)(e.ok))return;const t=await T().getOrSetAsync(e.mountpoint,(async()=>x(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>_().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=E,t.toVolumeUUID=D,t.readUuidFile_=k,t.readVolumeUUID=x},7014:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),w=i(59455),v=i(48884),b=i(50213),S=i(7282),P=i(23560),M=i(28850),_=i(45255),T=i(81168),E=i(56519),D=i(4867),k=i(49776),x=i(9595),F=i(77740),C=i(44198),A=i(96706),I=i(8769),O=i(57159),L=(i(34102),i(21144)),R=i(73209),N=i(29882),B=i(95696),j=i(17217),z=i(16287),V=i(49076),W=i(96128),U=i(45969),q=i(43334),H=i(28874),G=i(85087),$=i(50424),J=i(48165),K=i(98770),Z=i(27461),Y=i(66840),X=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,a.lazy)((()=>(0,b.mkLogger)("volumes.Volumes"))),se=s.default.platform(),ne=new Map,ae=new Map,oe=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,G.volsha)(t.uuid),(e=>ae.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,ne),le((0,G.volsha)(e.uuid),e,oe),e}function ce(){return(0,o.compact)([B.PosixFile.forMaybe((0,k.cacheDir)())?.join("volumes"),B.PosixFile.forMaybe((0,x.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),ae))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),ne.clear(),oe.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,E.mapAsync)({name:"readCachedVolumes",arr:(0,E.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,o.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,T.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),s=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:r,os:se}))),n=new Map;for(const e of s)for(const t of(0,o.compactBlanks)([(0,G.volsha)(e.uuid),(0,G.volsha)(e.mountpoint)]))n.set(t,e);const a=ce();for(const e of a)await(0,R.withLock_)({file:e,timeoutMs:_.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of n.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:a,vol_mountpoints:s.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,o.isNotEmpty)(e))return e;const i=(0,w.toA)(await(0,X.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,H.Settings.volumeMetadataTtlMs.valueOrDefault),s=0!==H.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),n=!(0,o.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:s,priorIsMissingMountpoints:n}),s||n?void 0:e}async function me(e,i){const r=(0,m.map)(e,j.toNativePath_);if((0,u.blank)(r))return;const s=await(0,L.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,o.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(s,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:s,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:s}})}async function pe(e,t,i){const r=i.filter((e=>(0,T.equalsIgnoreCase)(t,e.remoteShare)));if((0,o.isEmpty)(r))return;const s=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,T.equalsIgnoreCase)(e,t.remoteHost)));if(null!=s)return s;const n=await(0,W.friendlyname)(e);return(0,E.asyncFind)(r,(async e=>(0,T.equalsIgnoreCase)(n,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,a.lazy)((()=>(0,P.isSyncService)()||(0,S.isTest)())),t.priorWriteVolumesToCacheLatch=(0,a.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,a.lazy)((async()=>{const e=(0,o.compact)(await de()),t=(0,w.toA)(await(0,X.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,o.isNotEmpty)(i)?i:e.filter((e=>se===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,D.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,D.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,o.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,O.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,M.shim0)({name:"fs.volumes",impl:async function(){if((0,S.isTest)()){const e=(0,p.toInt)((0,C.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,F.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,D.thenOrTimeoutError)({p:q.isWin?(0,J.dfWin)():(0,$.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=H.Settings.validateMountpoints.valueOrDefault?(0,o.compact)(await(0,E.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,z.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,D.thenOrTimeoutError)({p:q.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(q.isWin?t:q.isMac?await(0,Y.addLocalVolumeInfoMac)(t):await(0,Z.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await he(r),Object.freeze(r)}}),t.rootPath=(0,a.lazy)((()=>q.isWin?(0,g.opt)((0,A.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,T.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,o.isEmpty)(t)?void 0:(0,v.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,o.commonPrefixLength)(e.split(n.default.sep),t.split(n.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,w.toA)(await i.vols()).find((t=>(0,G.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,E.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return oe.get(e)??(await de())?.find((t=>(0,G.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,G.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(50213),o=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,s.lazy)((()=>(0,a.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,n.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,f());t=(0,n.toNotBlank)(t)??(0,c.safeUUID)();const s=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(s))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+o.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},51140:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpStatusIs=t.HttpStatus=void 0;const r=i(31586);t.HttpStatus=Object.freeze({OK:200,Accepted:202,MovedPermanently:301,Found:302,SeeOther:303,BadRequest:400,Unauthorized:401,Forbidden:403,NotFound:404,EnhanceYourCalm:420,InternalServerError:500,NotImplemented:501,ServiceUnavailable:503}),t.HttpStatusIs=Object.freeze({ok:e=>(0,r.within)(200,299,e),success:e=>(0,r.within)(200,299,e),redirect:e=>(0,r.within)(300,399,e),clientError:e=>(0,r.within)(400,499,e),serverError:e=>(0,r.within)(500,599,e),error:e=>(0,r.within)(400,599,e)})},21404:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToTagPath=void 0;const r=i(75020),s=i(40958),n=i(22573),a=i(89937),o=i(34238);t.uriToTagPath=function({uri:e,isFile:t}){if(null==e)return;const i=(0,o.toURI)(e),l=i.scheme===a.PS_LIBRARY_SCHEME?r.LibraryTagName:i.scheme===a.PS_LOCAL_FILE_SCHEME?i.authority:void 0;if((0,n.blank)(l))return;const u=i.path.split("/");return(0,s.compactBlanks)([r.TagRoots.fs,l,...t?u.slice(0,-1):u])}},98604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkAssetUrl=t.mkFolderUrl=t.myWebUrl=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(27776),o=i(49076),l=i(72308),u=i(28874),c=i(42231),d=i(45200),h=i(34238),f=i(21404);function m(e=u.Settings.httpPort.valueOrDefault){const t=[u.Settings.localhost.valueOrDefault];u.Settings.exposeNetworkWithoutAuth.valueOrDefault&&t.push(...(0,s.compactBlanks)([(0,l.myExternalIp4Addresses)()[0],(0,o.hostname)()]));const i=(0,h.toURI)("http://a");return t.map((t=>i.with({authority:t+":"+e})))}t.default=m,t.myWebUrl=(0,r.lazy)((()=>m()[0])),t.mkFolderUrl=async function(e){const i=await(0,d.nativePath2uri)(e),r=(0,f.uriToTagPath)({uri:i,isFile:!1});if((0,s.isEmpty)(r))return;const n=(0,a.mkTagUri)((0,c.tagPathToStringArray)(r));return(0,t.myWebUrl)()?.with(n)},t.mkAssetUrl=function(e){return(0,n.gt0)(e)?(0,t.myWebUrl)()?.with({path:"/asset/"+e}):void 0}},4988:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.httpRequest_=t.get_=t.HttpMethods=void 0;const a=n(i(37067)),o=n(i(44708)),l=i(22573),u=i(45599),c=i(50989),d=i(51926),h=i(50213),f=i(45255),m=i(22911),p=i(43205),g=i(34238),y=i(51140),w=(0,u.defer)((()=>(0,h.mkLogger)("net.get")));async function v(e,t){return b({...t,url:e})}async function b(e){const t=(0,g.toURI)(e.url),i=new m.Deferred("get "+t.toString()),r="http"===t.scheme?a.request:"https"===t.scheme?o.request:w().throw("unsupported scheme: "+t.scheme),s=e?.maxRedirects??8,n=e?.timeoutMs??f.ShortCommandTimeoutMs,u={...e?.headers,"user-agent":await(0,p.userAgent)()},c=e?.method??"GET",h=e?.agent??!1,b=r(t.toString(),{method:c,headers:u,timeout:n,agent:h},(e=>{let r="";e.setEncoding("utf8").on("data",(e=>r+=e.toString())).resume().on("end",(()=>{const a={url:(0,l.toNotBlank)(e.url)??t.toString(),contentType:e.headers["content-type"],statusCode:e.statusCode??-1,data:r};s>0&&y.HttpStatusIs.redirect(a.statusCode)&&!(0,l.blank)(e.headers.location)?(console.log("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),w().info("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),i.observe(v(e.headers.location,{timeoutMs:n,maxRedirects:s}))):(w().debug("complete",{...a,data:(0,d.ellipsize)(r,64),data_length:r.length}),i.resolve(a))}))})).on("error",(e=>i.reject(e)));return(0,l.blank)(e.body)||b.write(e.body),b.end(),i}t.HttpMethods=(0,c.strEnum)("GET","PUT","POST","PATCH","DELETE"),t.get_=v,t.httpRequest_=b},65713:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),s=i(19851),n=i(23838),a=i(81168),o=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,s.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,s.lazy)((async()=>{const e=(0,o.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,s.lazy)((()=>({trie:new n.MultiMap,small:[]}))),h=3;function f(e){const t=new n.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=s)return s}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),s=i(96249),n=i(23838),a=i(59455),o=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=n.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,a.toA)(u[t])],n=c(e.substring(1));return(0,s.flatten)(n.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,o.stripDiacritics)(e).normalize())}},30933:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const s=r(i(48161)),n=i(19851),a=i(42659),o=i(31586),l=i(50213),u=i(28874),c=(0,n.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,n.lazy)((()=>s.default.cpus()),5*a.minuteMs),t.cpuCount=(0,n.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=s.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,o.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},14854:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CpuUsage=t.isTooBusy=void 0;const d=c(i(48161)),h=i(42659),f=i(45599),m=i(55835),p=i(31586),g=i(68708),y=i(19851),w=i(50213),v=i(7282),b=i(78406),S=i(25764),P=i(38835),M=i(74128),_=i(82647),T=i(43334),E=i(28874),D=i(30933),k=i(15674),x=(0,y.lazy)((()=>(0,w.mkLogger)("work.CpuUsage"))),F=(0,y.lazy)((()=>{const e=C.instance().busyPct();(0,M.syncReport)().maybeSystemData({from:"cpuUsage",state:"note",details:"Current system load is too high to schedule more work",meta:(0,g.compactValues)({loadCpuPct:I(),cpuBusyPct:e})}),x().warn("Current system load is too high to schedule more work",{cpuBusyPct:e,max:E.Settings.cpuBusyPercent.valueOrDefault})}),((0,v.isTest)()?15:60)*h.secondMs);t.isTooBusy=function(){if(E.Settings.cpuBusyPercent.valueOrDefault<=0)return!1;const e=C.instance().busyPct(),t=(0,p.clamp)(1,150,Math.round(4*E.Settings.cpuBusyPercent.valueOrDefault/3));return(0,p.gte)(e,t)?(F(),!0):(F.unset(),!1)};class C extends b.EndableInterval{constructor(){super({name:"CpuUsage()",callback:()=>l(this,r,"m",o).call(this),intervalMs:((0,k.singleThreadedMode)()?60:T.isWin?20:10)*h.secondMs,rank:S.EndableRanks.first}),r.add(this),s.set(this,new _.Average(5)),n.set(this,new A),(0,p.mapFinite)(I(),(e=>l(this,s,"f").push(e))),l(this,r,"m",o).call(this)}get cpuCount(){return l(this,n,"f").cpuCount}idlePct(){return(0,m.map)(this.busyPct(),(e=>100-e))}busyPct(){return l(this,s,"f").sampleAvg??I()}}t.CpuUsage=C,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){(0,p.gte0)(e)&&l(this,s,"f").push(e)},o=function(){l(this,r,"m",a).call(this,I());const e=new A;l(this,r,"m",a).call(this,e.busyPct(l(this,n,"f"))),u(this,n,e,"f")},C.instance=(0,f.defer)((()=>new C));class A{constructor(e=d.default.cpus()){let t=0,i=0;for(const r of e)t+=r.times.user+r.times.nice+r.times.sys+r.times.irq,i+=r.times.idle;this.busyMs=t,this.idleMs=i,this.cpuCount=e.length}busyPct(e){const t=this.busyMs-e?.busyMs,i=this.idleMs-e?.idleMs,r=t+i;return e?.cpuCount===this.cpuCount&&(0,p.gte0)(t)&&(0,p.gte0)(i)&&(0,p.gt0)(r)?(0,p.sigFigs)(t/r*100,3):void x().warn("busyPct(): Unexpected CpuTimes. If this continues, busyPct() will be incorrect."+P.InternalErrorFlag,{self:this,prior:e,busyMs:t,idleMs:i,totalMs:r})}}function I(){return T.isWin?void 0:(0,p.sigFigs)(d.default.loadavg()[0]/(0,D.cpuInfo)().length*100,3)}},73328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyDoNotRun=t.doNotRun=void 0;const r=i(68708),s=i(99331),n=i(74128),a=i(63664),o=i(14854);t.doNotRun=function(e){return null!=u(e)};const l=["error","no-library","stop-sync"];function u(e){if(!0===e?.ended)return"endable ended";if((0,s.ending)())return"service is ending";if((0,o.isTooBusy)())return"system is too busy";const t=(0,a.getRemoteOrLocalHealthSummarySync)();if(null==t||!l.includes(t.level))return;const i=t.level+": "+t.msg.join("\n");return(0,n.syncReport)().maybeSystemData({from:"whyDoNotRun",state:"note",details:t.level,meta:(0,r.omit)(t,"links","buttons")}),i}t.whyDoNotRun=u},58444:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const s=r(i(48161)),n=i(19851),a=i(31586),o=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,n.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,n.lazy)((()=>{const e=s.default.freemem(),t=s.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,a.gt0)(r))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,o.fmtBytes)(i),freemem:(0,o.fmtBytes)(e),totalmem:(0,o.fmtBytes)(t)}})}))},69385:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOnResume=t._setPaused=t.resume=t.pause=t.isPaused=void 0;const r=i(34102),s=i(37692);let n=!1;function a(){return n}function o(e=!0){l(e),(0,s.writeStateFile)({paused:e})}function l(e){e!==n&&(n=e,(0,r.ee)().emit(e?"pause":"resume"))}t.isPaused=a,t.pause=o,t.resume=function(){return o(!1)},t._setPaused=l;const u=Promise.resolve();t.resolveOnResume=function(){return a()?new Promise((e=>{(0,r.ee)().once("resume",e)})):u}},15674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),s=i(42659),n=i(41400),a=i(31586),o=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,n.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const w=(0,r.lazy)((()=>{const e=(0,a.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*o.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/o.MB),worstCaseMemPerProcMb:Math.ceil(e/o.MB)}})}),s.minuteMs);function v(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,a.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function b(){return((0,a.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=v,t.targetCpuLoadPct=b,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(b()*(0,f.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(b()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=v();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const s=Math.min(e,w());return t=(0,a.clamp)(1,s,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:b(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:w()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,a.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,a.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,a.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},37692:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addStateEvent=t.writeStateFile=t.readStateFile=t.stateEvents=t.StateEvents=t.StateEventFns=void 0;const s=r(i(78474)),n=i(40958),a=i(76790),o=i(42659),l=i(45599),u=i(41400),c=i(68708),d=i(50989),h=i(87290),f=i(73787),m=i(19851),p=i(50213),g=i(28874),y=i(69385),w=(0,l.defer)((()=>(0,p.mkLogger)("work.SharedState")));let v;t.StateEventFns={checkTasks(){},reloadLicenses(){}},t.StateEvents=(0,d.strEnum)(...(0,c.keys)(t.StateEventFns)),t.stateEvents=new s.default;let b=0;function S(){const e=(0,h.libraryDataDirPosixFile)()?.join("state.json"),t=Date.now(),i=t-b>o.minuteMs;i&&(b=t);const r=e?.existsSync({refresh:i})??!1;return r&&null!=e&&e.eql(v?.nativePath)||(v?.close(),v=void 0),r&&null!=e&&(v??(v=new f.FileWatcher(e.nativePath,{encoding:"utf8",persistent:!1,recursive:!1},P))),e}(0,u.later)((()=>{g.Settings.libraryDir.watchLater(P)}));const P=(0,m.lazy)((()=>t.readStateFile.refresh()),25);t.readStateFile=(0,m.lazy)((()=>{const e=S()?.readJsonSync();for(const i of e?.events??[])M.get(i.e)!==i.ts&&(w().info("emitting event "+i.e),t.stateEvents.emit(i.e),M.set(i.e,i.ts));return(0,y._setPaused)(e?.paused??!1),e}));const M=new Map;function _(e){const i=S();if(null==i)w().error("overwrite(): failed: no library directory");else{const r=i?.readJsonSync(),s=function(e){const t=Date.now()-10*o.minuteMs;return(0,n.uniqByLast)((0,a.sortBy)((e??[]).filter((e=>e.ts>t)),(e=>e.ts)),(e=>e.e))}([...r?.events??[],...e.events??[]]),l={paused:e.paused??r?.paused??g.Settings.startPaused.valueOrDefault,events:s};(0,y._setPaused)(l.paused),t.readStateFile.set(l),i.writeJsonSync(l)}}t.writeStateFile=_,t.addStateEvent=function(e){const t=Date.now();M.set(e,t),_({events:[{e,ts:t}]})}},22751:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),s=i(87997),n=i(19851),a=i(42659),o=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,n.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,n.lazy)((()=>new r.Rate(5*a.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,n.lazy)((()=>(0,s.setInterval)(g,a.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,o.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},83600:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.RequestTask=void 0;const a=i(58587),o=i(80875),l=i(19851),u=i(50213),c=i(34102),d=i(84542),h=i(87445),f=i(40958),m=i(26905),p=i(98553),g=i(31586),y=(0,l.lazy)((()=>(0,u.mkLogger)("worker.RequestTask")));class w extends a.Task{constructor(e){super((0,p.stringify)(e),(e=>n(this,r,"m",s).call(this,e))),r.add(this),this.request=e}}t.RequestTask=w,r=new WeakSet,s=function(e){for(const t of(0,f.compactBlanks)((0,d.splitLines)(e))){const e=(0,o.parseJSON)(t);if(null==e)y().warn("ignoring non-json line from worker",{line:t});else{if(null!=e.error)throw y().warn("worker threw error",{response:e}),(0,m.errorFromJson)(e.error);if((0,g.isNumber)(e.id))return e.id!==this.request.id?y().throw(`bad request: #parse given mismatching requests (${e.id} != ${this.request.id})`,{response:e,request:this.request}):e.response;(0,h.isProgressEvt)(e)?(0,c.ee)().emit("progress",e):y().warn("ignoring json line from worker",{response:e})}}return y().throw("bad request: #parse missing valid response")}},93493:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearShims=t.setupShimDelegates=void 0;const r=i(19851),s=i(5233),n=i(68708),a=i(13538),o=i(57206),l=i(50213),u=i(23560),c=i(70025),d=i(28874),h=i(15674),f=i(22751),m=i(83600),p=i(58800),g=i(24817),y=(0,r.lazy)((()=>(0,l.mkLogger)("worker.ShimDelegation")));let w=0;async function v(e,t){const i=d.Settings.taskTimeoutMs.valueOrDefault;return(0,s.retryOnReject_)((async()=>{y().throwIfAborted_();const r={id:w++,fn:e,args:t},s=new m.RequestTask(r),n=await(0,p.workerCluster)(),o=n?.t,l=null==n||null==o?g.WorkerFunctions[e](...t):n.awaitOrAbort(o.enqueueTask(s));return(0,a.thenOrOnTimeout)(l,i/3,(()=>{y().warn("soft timeout servicing work request",{request:r,timeoutMs:i}),(0,f.onTimeout)()})),(0,a.thenOrTimeoutError)(l,i)}),{maxRetries:d.Settings.maxRetries.valueOrDefault,timeoutMs:i,retryDelay:d.Settings.minDelayBetweenRetriesMs.valueOrDefault,errorIsRetriable:e=>!1!==(0,c.isRetriableError)(e)})}function b(){for(const e of(0,n.values)(g.WorkerFunctions))(0,n.maybeCall)(e,"clearShim")}t.setupShimDelegates=async function(){if((0,o.addDefaultJsonRevivers)(),(0,u.isWorkerService)())b(),y().warn("setupShimDelegates(): in worker service, skipping");else if((0,h.singleThreadedMode)())y().warn("setupShimDelegates(): single-threaded mode, clearing shims"),b(),await(0,p.endWorkerCluster)();else for(const[e,t]of(0,n.entries)(g.WorkerFunctions))t.setShim((t=>v(e,t)))},t.clearShims=b},24817:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleWorkRequest_=t.isWorkRequest=t.mkWorkRequest=t.WorkRequestMethods=t.WorkerFunctions=t.AllWorkerFunctionCandidates=void 0;const r=i(98553),s=i(31586),n=i(68708),a=i(50989),o=i(32639),l=i(13991),u=i(50597),c=i(48368),d=i(52121),h=i(48604),f=i(181),m=i(66106),p=i(47783),g=i(83966);t.AllWorkerFunctionCandidates={_extractVideoFrame_:m._extractVideoFrame_,_readRawTags:p._readRawTags,_readTags:p._readTags,assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkerFunctions={assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkRequestMethods=(0,a.strEnum)(...(0,n.keys)(t.WorkerFunctions));let y=0;t.mkWorkRequest=function(e,t){return{id:++y,fn:e,args:t}},t.isWorkRequest=function(e){return"object"==typeof e&&t.WorkRequestMethods.has(e?.method)&&(0,s.isNumber)(e.id)},t.handleWorkRequest_=async function(e){const i=t.WorkerFunctions[e?.fn];if((0,o.isFunction)(i))return i(e?.args);throw new Error("invalid method "+(0,r.stringify)(e))}},58800:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.workerCluster=t.endWorkerCluster=t.workerClusterPriorEnd=void 0;const r=i(58587),s=i(36557),n=i(19851),a=i(50213),o=i(71567),l=i(25764),u=i(84777),c=i(86335),d=i(38835),h=i(84542),f=i(87445),m=i(41944),p=i(15674),g=i(42659),y=i(98553),w=i(31586),v=i(67478),b=i(54993),S=i(27395),P=i(5916),M=i(55534),_=i(29325),T=i(28874),E=i(30933),D=i(41657),k=(0,n.lazy)((()=>(0,a.mkLogger)("worker.cluster")));t.workerClusterPriorEnd=async function(){return(await t.workerCluster.prior())?.t.closeChildProcesses()},t.endWorkerCluster=function(){return(0,S.end)(t.workerCluster.prior())},t.workerCluster=(0,P.lazyAsync)({later:async()=>{const e=await(0,c.pathToService)("worker");if(null==e)return k().throw("Could not find worker.js"+d.FatalErrorFlag);k().info("worker.js found at "+e);const t={id:-1,fn:"ping",args:{}},i=new r.BatchCluster({processFactory:async()=>(k().info("Spawning new worker",{execPath:process.execPath,worker:e.nativePath,maxProcs:(0,p.maxCpus)()}),(0,u.spawn)(process.execPath,[e.nativePath],0,{env:await(0,D.workerEnv)()})),...(0,s.batchClusterOptions)((0,p.maxCpus)(),"worker.BatchCluster"),streamFlushMillis:0,versionCommand:(0,y.stringify)(t),healthCheckCommand:(0,y.stringify)(t),taskTimeoutMillis:T.Settings.taskTimeoutMs.valueOrDefault,maxProcAgeMillis:4*T.Settings.taskTimeoutMs.valueOrDefault,minDelayBetweenSpawnMillis:(0,_.isPacked)()?g.secondMs:1,pass:o.ReadyStr,fail:d.FatalErrorRe,exitCommand:M.ServiceExitCommand});return i.on("taskData",(e=>{for(const t of(0,h.splitLines)((0,b.toS)(e))){const e=(0,v.parseJSON)(t);(0,f.isProgressEvt)(e)&&(0,m.emitProgressEvt)(e)}})),p.maxCpus.watchLater((e=>{const t=(0,w.clamp)(1,(0,E.cpuCount)(),e??(0,p.maxCpus)());return k().warn("maxConcurrentImports changed",{maxProcs:t,newValue:e}),i.setMaxProcs(t)})),new s.BatchClusterObserver("worker",i,l.EndableRanks.first)}})},41657:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.workerEnv=void 0;const r=i(9727),s=i(28874),n=i(59107);t.workerEnv=async function(){const e={};return s.Settings.libraryDir.addToEnv(e),s.Settings.mountpoints.addToEnv(e,await(0,n.mountpoints)()),(0,r.childEnv)({overrides:e,forWorker:!0})}},83966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ping=void 0;const s=r(i(1708)),n=i(41400),a=i(31586),o=i(7282),l=i(12089),u=i(45608),c=i(57159),d=i(89035);t.ping=(0,l.shim1)({name:"worker.ping",async impl(e){if((0,a.gt0)(e?.delay)&&await(0,n.delay)(e.delay),(0,o.isTest)()&&!0===e?.pretendMemUsageIsHigh&&d.memoryUsageIsHigh.set(!0),null!=e?.throw)throw new c.WrappedError(e.throw.message,e.throw);if((0,d.memoryUsageIsHigh)())throw(0,u.exit)({reason:"memory usage is high",status:1}),new c.WrappedError("Memory usage is high",{fatal:!0});return{pid:s.default.pid,input:e?.input??"(no input)"}}})},40958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),s=i(22573),n=i(50357),a=i(98553),o=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function w(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function b(e){return null==e?[]:w((0,h.toA)(e),(e=>null!=e))}function S(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,o.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const s=[];if(et;n-=i)s.push(r(n));return s}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=w,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),s=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===s[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,n.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const s of t){const t=i(s);r.includes(t)||(e.push(s),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return w(e,(e=>t.every((t=>!(0,n.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return w(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=b,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(s.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=b(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return S(t,(e=>(0,l.isPrimitive)(e)?e:(0,a.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,n.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=b(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=S,t.uniqByLast=function(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of b(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,a.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const s=new Set(i.map(r));return e.filter((e=>!s.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),s=i(36783),n=i(41801),a=i(98553),o=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,s.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const r of e)(0,o.getOrSet)(i,(0,a.stringify)(t(r)),(()=>r));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,s.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,n.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},75761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetImgAttrs=t.assetSqImgAttrs=t.assetVideoLink=t.assetImgActualLink=t.assetImgLink=t.assetLinkAttrs=t.assetUrl=void 0;const r=i(58939),s=i(40958),n=i(22573),a=i(42659),o=i(11371),l=i(73722),u=i(31586),c=i(54993),d=i(29652),h=i(22403),f=i(2322);function m(e,t){return e+" "+t+"w"}function p(e,t){let i=null==t?void 0:(0,d.mergeURLSearchParams)(...t);const r=(0,c.toS)(e.v);return(0,n.blank)(r)||"1"===r||(i??(i=new URLSearchParams)).append("v",r),i}function g({assetId:e,params:t}){return null==e?"":(0,d.assembleFullPath)("/asset/"+(0,r.id2id)(e),p(e,t))}function y({assetId:e,reducer:t,width:i,params:s}){return(0,d.assembleFullPath)(`/img/${(0,r.id2id)(e)}/${t}/${(0,u.toGt0)(i)??320}`,p(e,s))}function w({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/img/${(0,s.compact)([(0,r.id2id)(e),t]).join("/")}/actual`,p(e,i))}function v({assetId:e,params:t,reducer:i,widths:s,lazyLoad:n,af:l}){if(null==(0,r.id2id)(e))return{src:"/images/clear-64.png"};0===(s=(s??[]).filter(u.gt0)).length&&s.push(320);const d=Math.min(...s),p={width:(0,c.toS)(d)},g=(0,a.fmtLocalToShort)(e.capturedAtLocal);null!=g&&(p.title=g);const v=y({assetId:e,params:t,reducer:i,width:d});n??(n=!0);const b=n&&(0,f.isSafari)((0,h.ua)());b?(p.src="/images/clear-64.png",p["data-src"]=v):p.src=v,(0,f.isSafari)((0,h.ua)())||(p.loading=n?"lazy":"eager"),i===o.ReducerNames.sq&&(p.height=(0,c.toS)(d));const S=s.map((r=>m(y({assetId:e,params:t,reducer:i,width:r}),r)));return null!=l&&S.push(m(w({assetId:e,params:t,assetFileId:l.assetFileId}),l.width)),p[(b?"data-":"")+"srcSet"]=S.join(","),p}t.assetUrl=g,t.assetLinkAttrs=function({assetId:e,params:t}){const i=g({assetId:e,params:t});return(0,n.blank)(i)?{}:{href:i}},t.assetImgLink=y,t.assetImgActualLink=w,t.assetVideoLink=function({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/video/${(0,r.id2id)(e)}-${t}`,p(e,i))},t.assetSqImgAttrs=function({assetId:e,params:t,lazyLoad:i,size:r="m"}){return{...v({assetId:e,params:t,reducer:"sq",widths:l.SqWidths,lazyLoad:i}),sizes:("s"===r?80:"m"===r?160:320)*(0,u.numericOr)(globalThis?.window?.devicePixelRatio,1)+"px"}},t.assetImgAttrs=v},5233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),s=i(31586),n=i(13538),a=i(41583);t.retryOnReject_=async function(e,t){const i=(0,s.gt0)(t.timeoutMs)?()=>(0,n.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const o=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,a.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await o(l),u()}};return u()}},17586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55938),o=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,a.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,a.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,s.blank)(e)?"":"```"+(0,o.toS)(e)+"```"},t.b=function(e){return"**"+(0,o.toS)(e)+"**"},t.li=function(...e){return(0,r.compactBlankish)((0,n.flatten)(e)).map((e=>"- "+(0,o.toS)(e))).join("\n")}},22573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),s=i(42279),n=i(54993);function a(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function o(e){return!a(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,n.toS)(e);return o(i)?t(i):void 0}t.blank=a,t.notBlank=o,t.notBlankToS=function(e){return o(e)&&"undefined"!==e?(0,n.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,n.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,s.tot)(t);const i=(0,n.toS)(e).trim();return i.length>0?i:(0,s.tot)(t)},t.notBlankAnd=function(e,t){return!a(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,n.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{"use strict";function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),s=i(22573),n=i(30301),a=i(55835),o=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,a.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,o.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const s=Math.floor(e/t.minuteMs);e-=s*t.minuteMs;const n=Math.floor(e/t.secondMs),a=Math.floor(e-n*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(s)+":"+(0,l.pad2)(n)+(i.includeMs?"."+(0,l.pad3)(a):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function w(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),s=i(),n=i(),a=i(),o=i(),l=i();return new Date(t,l-1,o,a,n,s,r)}function v(){return(new Date).setHours(24,0,0,0)}function b(e,i="ago"){return e<1e3?"just now":(i=(0,s.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const n=Math.floor(e/r.ms);e-=n*r.ms,n>0&&(r.ms>=t.dayMs?i:s).push(n+r.s)}return e>0&&s.push((0,o.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(s)?"":"T"+s.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=w,t.fmtLocalToShort=function(e){return(0,a.map)(w(e),m)},t.nextMidnightTs=v,t.msUntilMidnight=function(){return v()-Date.now()},t.fmtAgo=function(e,t="ago"){return b(Date.now()-e,t)},t.fmtElapsedMs=b},95892:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),s=i(73872);function n(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function a(e,t,i,r){if(null==i||y(e)||y(t))return;let s=i.get(e);null!=s?s.set(t,r):(s=new WeakMap,s.set(t,r),i.set(e,s))}function o(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const s=l(e,t);return null!==s?s:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=n(e,t,u);if(null!==f)return f;const m=n(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return a(e,t,u,i),i;const s=l(e,t);if(null!==s)return s}const y=s(e);if(y!==s(t))return a(e,t,u,!1),!1;a(e,t,u,!0);const w=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return o(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],s=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){s.push([e,t])})),c(r.sort(),s.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return a(e,t,u,w),w}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let s=-1;for(;++s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const s=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return s.prior=()=>t,s.hasPrior=()=>r,s}},41400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),s=i(35556),n=i(31586),a=i(68708);function o(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const n=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&s.isNode&&n.unref?.()}}))}t.delayUntil=function(e){const t=((0,n.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return o(t).then((()=>t))},t.delay=o,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),n=s.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return s.isBrowser||t<=r.secondMs?n:(0,a.maybeCall)(n,"unref")??n}},33374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const r=i(31586),s=i(21605),n=i(12168);function a(e){return{width:e.height,height:e.width}}function o(e){return((0,r.toGt0)(e?.width)??0)*((0,r.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,r.gt0)(e.width)&&(0,r.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,r.gt0)(e)&&(0,r.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,n.pixels2size)(e.width*e.height)},t.dimSwap=a,t.maybeDimSwap=function(e,t){return(0,s.swappableRotation)(t)?a(e):e},t.maybeFlipInPlace=function(e,t){(0,s.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,n.megapixels)(o(e))},t.pixels=o},50357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),s=i(68708),n=i(34666),a=i(32639);function o(e,t){return(0,r.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,a.isFunction)(e)&&(0,a.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=o,t.eqlSubset=function(e,t){if(null==e||null==t||(0,n.isPrimitive)(e)||(0,n.isPrimitive)(t))return e===t;if(!(0,s.isObject)(e)||!(0,s.isObject)(t))return!1;for(const i of(0,s.keys)(e))if(!o(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(31586),o=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,s.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,a.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,n.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,s.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,s.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,s.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(s.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,o.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,o.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,o.assignFields)(new Error,(0,o.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},4188:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),s=i(42659),n=i(55835),a=i(31586),o=i(12168),l=[{ms:s.yearMs,s:"year",p:"years"},{ms:s.yearMs/12,s:"month",p:"months"},{ms:s.weekMs,s:"week",p:"weeks"},{ms:s.dayMs,s:"day",p:"days"},{ms:s.hourMs,s:"hour",p:"hours"},{ms:s.minuteMs,s:"minute",p:"minutes"},{ms:s.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,s){if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,n.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,o.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,n.mapOr)(s,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function s(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=s,t.orList=function(e){return s(e,"or")},t.andList=function(e){return s(e,"and")}},50268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const r=i(22573),s=i(38639),n=i(68708),a=i(62220),o=i(50989);t.HealthCheckSections=(0,o.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,o.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,n.isObject)(e)&&!(0,r.blank)(e.id)&&!(0,r.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,r.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,n.isObject)(e)&&a.RunStates.has(e.state)&&(0,s.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},11371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReducerNames=void 0;const r=i(50989);t.ReducerNames=(0,r.strEnum)("fit","sq")},73722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const s=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,s){if((0,isFunction_1.isFunction)(r))return;let n,a,o,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(n=0;nnew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),s=i(50357),n=i(31586),a=i(65812);t.lazy=function(e,t){let i,o;const l=[];function u(){return u.isStale()&&u.setResult(e()),o}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const n=await e,o=await i;if(!(0,s.eql)(n,o))for(const e of l)e(o);null!=t&&t>0&&void 0!==o&&(0,a.setUnrefTimeout)((()=>u.vacuum()),t)}(o,e),o=e},u.isStale=function(){return null==i||(0,n.gt0)(t)&&i+t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),s=i(54993);function n(e,t){return null==e?void 0:t(e)}function a(e,t,i){return null==e||null==t?void 0:i(e,t)}function o(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=n,t.mapTry=function(e,t){try{return n(e(),t)}catch{return}},t.map2=a,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=o,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return o(a(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,s.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class s extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=s},23838:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),s=i(76790),n=i(50357),a=i(98553),o=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,o.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,o.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,n.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),s=null==i?[]:e(t,i);(0,r.isEmpty)(s)?this.store.delete(t):this.store.set(t,s)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,s]of this.store.entries()){const n=(0,r.findIndexes)(s,(t=>!e(i,t,s)));if(n.length>0){t=!0;for(const e of n.reverse())s.splice(e,1)}0===s.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,a.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,s.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),s=i(22573),n=i(42279),a=i(54993);function o(e){return"number"==typeof e&&isFinite(e)}t.isNumber=o,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,a.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return o(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,a.toS)(e).match(u)&&null!=w(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>o(t)&&o(i)&&e(t,i);function f(e,i,s){return!(null==s||!o(s))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,s)&&(0,t.gte)(i,s))}function m(e){if(!o(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,s.blank)(e))return t.defaultValue;if(o(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function w(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function v(e){return o(e)&&e>0}function b(e){return o(e)&&e>=0}function S(e,t){return o(e)?t(e):void 0}function P(e){return o(e)?e<0?-Math.round(-e):Math.round(e):0}function M(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function _(e,t,i){if(e>t||!o(e)||!o(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return o(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return o(e)?e:t},t.diff=function(e,t){return o(e)&&o(t)?e-t:void 0},t.absdiff=function(e,t){return o(e)&&o(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!o(e)||!o(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return f(t-r,t+r,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)o(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=w(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return o(e)&&e<0},t.gt0=v,t.firstGt0=function(...e){for(const t of e){if(v(t))return t;const e=y(t);if(v(e))return e}},t.gtOrElse=function(e,t){return o(e)&&o(t)&&e>t?e:void 0},t.lte0=function(e){return o(e)&&e<=0},t.gte0=b,t.toGte0=function(e){return b(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=w(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return v(t)?String(t):void 0},t.mapNumeric=S,t.map2Numeric=function(e,t,i){return S(e,(e=>S(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return o(e)?t(e):i},t.numericOr=function(e,t){return o(e)?e:(0,n.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return S(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d\.\d+)0+$/,"")},t.toPrecision=M,t.toPrecisionMaybe=function(e,t){return d(e,(e=>M(e,t)))},t.sigFigs=function(e,t){if(!o(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=_,t.times=function(e,t){if(!v(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return _(0,100,v(t)?P(100*(v(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!o(i))return;t+=i}return t}},68708:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(32639),o=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function w(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function v(e,t,i={}){return y((0,r.compact)((0,s.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function b(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const s={};for(const e of(0,r.uniq)((0,r.flatMap)(i,h)))s[e]=b(...i.map((t=>t[e])));return s}function S(e,t){if(!d(e)||(0,n.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=w(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,s]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==s&&!0!==i?.assignNullish||(e[r]=s));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=w,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,o.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,n.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=v,t.mergeObjectsDeep=b,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,n.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=o.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function s(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:b(i,t)}for(const r of i){const[i,a]=(0,c.splitFirst)(r,"."),o=S(t,i);null!=o?.value&&s(o.key,(0,n.blank)(a)?o.value:e(o.value,a))}for(const r of h(t))((0,l.toInt)(r)??-1)>=0&&s(r,e(t[r],...i));return r},t.pluck=S,t.pluckDeep=function e(t,i){if(null==t||(0,n.blank)(i))return;if(Array.isArray(t)){const s=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(s)?void 0:{key:s[0].key,value:(0,r.flatMap)(s,(e=>e.value))}}const[s,a]=(0,c.splitFirst)(i,"."),o=S(t,s);if(null==o)return;if((0,n.blank)(a))return o;const l=e(o.value,a);return null==l?void 0:{key:o.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,n.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,a.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,n.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=v(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>n(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return s(t)?t:n(t)}filter(e){return n(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return n(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return n(e).flatMap((e=>n(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return n(e).flatMap((e=>n(t).flatMap((t=>n(i).flatMap((i=>r(this.a,e,t,i)))))))}}function s(e){return e instanceof r||e===t.None}function n(e){return s(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=s,t.opt=n},97238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSeed=t.prngSeed=t.SeedCount=t.PrimeBins=t.PrimesPerBin=void 0;const r=i(31586),s=i(30976),n=i(54993);t.PrimesPerBin=4,t.PrimeBins=8,t.SeedCount=t.PrimesPerBin**t.PrimeBins,t.prngSeed=function(){return(0,s.randomInt)(0,t.SeedCount)},t.toSeed=function(e){const i=(0,r.toInt)((0,n.toS)(e));return(0,r.within)(0,t.SeedCount,i)?i:void 0}},39926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),s=i(54993),n={};function a(e,t){if(t<1)return"";if(!(0,r.gte)(n[e]?.length,t)){let i=n[e]??e;for(;i.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var r=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return r.parseJSON}})},46891:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),s=new Map([["child","children"],["photo","photos"],["video","videos"]]),n=/([sxz]|ss|sh|ch)$/,a=/[^aeiou]y$/,o=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=s.get(e);return null!=t?t:null!=e.match(n)?e+"es":null!=e.match(a)?e.replace(/y$/i,"ies"):null!=e.match(o)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),s=i(54993),n=["number","string","boolean"];function a(e){return-1!==n.indexOf(typeof e)}t.isPrimitive=a,t.mapPrimitive=function(e,t){return a(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return a(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(a)};const o=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,n=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==n&&"symbol"!==n)){const r=(0,s.toS)(e),n=(0,s.toS)(i),a=r.localeCompare(n);return r[0]===t.CmpReverseFlag&&n[0]===t.CmpReverseFlag?-a:a}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==n?o.indexOf(r)-o.indexOf(n):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function s(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const s of(0,r.toA)(await e))if(null!=s){const e=await s;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=s,t.isPromise=function(e){return s(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),s=i(31586);function n(e,t){return Math.floor(Math.random()*(t-e))+e}function a(e,t,i){return null==i||0===i.length?n(e,t):o(e,t,1,i)[0]}function o(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const s=t-e,a=new Set(r??[]);if(t===e&&0===s&&0===a.size&&1===i)return[e];const o=s-a.size;if(i>o)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:s,size:i,slotsRemaining:o})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of o(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,s.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let r=e;t.global||(t=new RegExp(t,"g"));let s=null;for(;null!=(s=t.exec(e));)s.index===t.lastIndex&&t.lastIndex++,r=r.slice(0,s.index)+i(s)+r.slice(s.index+s[0].length);return r}},21605:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const r=i(31586);function s(e){if(!(0,r.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,r.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=s,t.swappableRotation=function(e){const t=s(e);return 90===t||270===t}},62220:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const r=i(50989);t.RunStates=(0,r.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),s=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),n={};for(const e of t)n[e]=e;const a=e=>null!=e?i[e]:void 0,o=e=>null!=a(e);return{...n,values:t,length:t.length,has:o,includes:o,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:a,ordinal:e=>a(e)??t.length,validOrElse:(e,t)=>o(e)?e:(0,s.tot)(t),mapValid:(e,t)=>o(e)?t(e):void 0,cmp:(e,t)=>{const i=a(e),r=a(t);return null==i||null==r?void 0:i>r?1:i{const i=a(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),s=i(17586),n=i(22573),a=i(96249),o=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=f();return null!=r?(0,o.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function b(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function S(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),s=(0,c.toS)(t);return r.length===s.length&&(r===s||r.toLowerCase()===s.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?s.normalize():s,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,n.blank)(t)?void 0:e.find((e=>S(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,s.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,o.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=w,t.ensureSuffix=v,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return v(w(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=b,t.wrap=function e(t,i){const r=i?.maxLineLen??80,s=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,a.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,a.flatten)(r.map((t=>e(t,i))))}if((t=w((0,c.toS)(t),s).trim()).length<=r)return[t];const n=b(t," ",r);if(n>s.length)return[m(t,0,n),...e(m(t,n+1),i)];{const r=t.indexOf(" ",s.length+1);return r>0&&r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),s=i(68708),n=i(42279),a=i(83104),o=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let s=!0;const n=setTimeout((()=>{s&&(s=!1,i(a.Timeout))}),t);try{n.unref?.();const t=await e;s&&(s=!1,i(t))}catch(e){s&&(s=!1,r(e))}finally{clearTimeout(n)}}))}async function u(e,t,i=!0){const s=await l(e,t,i);if(s===a.Timeout)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return s}t.toNotTimeout=function(e){return e===a.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?a.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,n)=>{let a=!0;try{const o=setTimeout((async()=>{if(a){a=!1;try{r(await i())}catch(e){n(e)}}}),t);(0,s.maybeCall)(o,"unref");const l=await e;a&&(a=!1,clearTimeout(o),r(l))}catch(e){a&&(a=!1,n(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const s=t-Date.now();if(s<=0)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(s)+")");return u(e,s,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const s=await l(e,t,r);return s===a.Timeout?(0,n.tot)(i):s}},42279:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),s=i(22573),n=i(54993);function a(e){return"URLSearchParams"===e?.constructor?.name}function o(e){return null==e?void 0:a(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(o)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=a,t.toURLSearchParams=o,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,n.toS)(l(...t));return e+((0,s.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,n.toS)(l(...t));return(0,s.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),s=i(30301),n=i(31586),a=i(46891),o=i(50989),l=i(51926),u=(0,s.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,n.isNumber)(r)&&(i+=r/t.MB);return(0,n.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,n.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,n.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),s=Math.pow(10,3*r),a=d[r];return(0,n.sigFigs)(e/s,t)+" "+a}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),s=Math.pow(2,10*r),a=h[r];return(0,n.sigFigs)(e/s,t)+" "+a},t.MP=1e6,t.megapixels=function(e){return(0,n.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,o.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,a.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,a.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},22403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ua=void 0;const r=i(30301),s=i(54993);t.ua=(0,r.lazy)((()=>(0,s.toS)(globalThis?.navigator?.userAgent)))},2322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,r=/\bSafari\b/,s=/\bFirefox\b/,n=/\biPad\b/,a=/\biPhone\b/;function o(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return o(e,i)}function u(e){return o(e,s)}t.isChrome=l,t.isSafari=function(e){return o(e,r)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return o(e,n)},t.isIphone=function(e){return o(e,a)}},58939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.idEql=t.id2id=void 0;const r=i(55835),s=i(31586);function n(e){const t=e;return(0,s.isNumber)(e)?e:(0,s.isNumber)(t.id)?t.id:(0,s.isNumber)(t.assetId)?t.assetId:(0,s.isNumber)(t.tagId)?t.tagId:void 0}t.id2id=n,t.idEql=function(e,t){return(0,r.map2Or)(n(e),n(t),((e,t)=>e===t),(()=>!1))}},12236:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressWithAssetsProps=t.noRecentAssetIdsProgress=t.isRebuildProgress=t.EmptyRemovedURI=t.EmptyDeletedURI=t.RebuildingURI=t.SyncStatuses=void 0;const r=i(50989);t.SyncStatuses=(0,r.strEnum)("processing","paused","done"),t.RebuildingURI="rebuilding://",t.EmptyDeletedURI="emptydeleted://",t.EmptyRemovedURI="emptyremoved://",t.isRebuildProgress=function(e){return t.RebuildingURI===e?.uri},t.noRecentAssetIdsProgress=function(e){return[t.EmptyDeletedURI,t.EmptyRemovedURI].includes(e?.uri)},t.ProgressWithAssetsProps=["uri","volume","state","hed","dek","completePct","incompletePct","scanningPct","recentAssetIds"]},79114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.S=void 0;const r=i(50989);t.S=(0,r.strEnum)("plus","lite")},75020:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInfoTag=t.NotInfoPanelTags=t.LibraryTagName=t.TagRoots=t.isTagRef=t.ctxToS=t.TagGalleryProps=t.nextChildTagsUrl=t.nextAssetsUrl=t.BeforeAfterStreamLimit=t.ThumbsPerSample=void 0;const r=i(76790),s=i(22573),n=i(98553),a=i(31586),o=i(50989),l=i(51926),u=i(29652);t.ThumbsPerSample=128,t.BeforeAfterStreamLimit=8,t.nextAssetsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/assets`,i)},t.nextChildTagsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.seed,(e=>i.seed=e.toString())),(0,a.mapNumeric)(t.limit,(e=>i.limit=e.toString())),(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/child-tags`,i)},t.TagGalleryProps=["tagId","tagPath","assetCount","assetIds","nextAssets","childTags","nextChildTags"],t.ctxToS=function(e){return(0,n.stringify)({seed:e.seed,tagIds:(0,r.sort)([...e.tagIds])})},t.isTagRef=function(e){return null!=e&&!(0,l.isString)(e)&&(0,s.notBlank)(e.name)},t.TagRoots=(0,o.strEnum)("When","Who","Where","What","Camera","Lens","Albums","Keywords","Type","fs"),t.LibraryTagName="Library",t.NotInfoPanelTags=[t.TagRoots.When,t.TagRoots.Camera,t.TagRoots.Lens,t.TagRoots.Type,t.TagRoots.fs],t.isInfoTag=function(e){if(null==e)return!1;const i=(0,l.isString)(e)?e:e.tagPath?.[0];return!t.NotInfoPanelTags.includes(i)}},27776:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkTagUri=t.mkTagFullPath=t.mkHomeFullPath=t.urlSeed=void 0;const r=i(40958),s=i(30301),n=i(31586),a=i(97238),o=i(29652);function l(e,i){const r=(0,o.toURLSearchParams)(e);if(i||!(0,n.isDigits)(r?.get("seed"))){const e=(0,t.urlSeed)().toString();return r?.set("seed",e),r??{seed:e}}return r}function u(e,t,i=!1){const r=c(e,t,i);return(0,o.assembleFullPath)(r.path,r.query)}function c(e,t,i=!1){return{path:"/tag/"+((0,r.isEmpty)(e)?"":e.map(encodeURIComponent).join("/")),query:l(t,i)}}t.urlSeed=(0,s.lazy)(a.prngSeed,100),t.mkHomeFullPath=function(e){return u([],e,!0)},t.mkTagFullPath=u,t.mkTagUri=c},23541:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),s=i(51926);function n(e){return Array.isArray(e)?e:null==e?void 0:(0,s.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return n(e)??[]},t.optToA=n},41583:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),s=i(23541),n=i(59455),a=i(54993);function o(e){return null==e?void 0:(0,s.isError)(e)?e:new Error((0,a.toS)(e))}t.toErr=o,t.toErrs=function(...e){return(0,r.compact)((0,n.toA)(e).map(o))}},54993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return n(e,",")};const s={}.toString;function n(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>n(e,t))).join(t):e.toString!==s?e.toString():(0,r.stringify)(e)}}t.toStr=n},98401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cancelFileAndProcCleanups=t.scheduleFileAndProcCleanups=t.fileCleanups=t.cleanup_=t.maybeCleanup_=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(56519),o=i(76187),l=i(87290),u=i(79267),c=i(32144),d=i(13829),h=i(69734),f=i(95696),m=i(65238),p=i(70257),g=i(13940),y=i(12495),w=i(95402),v=i(28874),b=i(40958),S=i(42659),P=i(31586),M=i(64526),_=i(22526),T=i(69032),E=(0,r.lazy)((()=>(0,s.mkLogger)("library.Cleanup")));async function D(){const e=M.Library.instance();if(null==e)E().info("No library to vacuum.");else{E().info("Running tag and search maintenance...");try{await(0,T.runTagMaintenance)()}catch(e){E().warn("Failed to run tag maintenance",{error:e})}E().info("Vacuuming db..."),await(await e.dbModelSetup_()).db.vacuum(),(0,n.isDbJanitorService)()&&(E().info("Running database maintenance..."),await e.runDbBackup_())}E().info("Cleaning child processes..."),await(w.Pids.instance()?.killOldProcs()),E().info("Cleaning stale and temp files..."),await k(),await(0,a.mapAsync)({name:"fileCleanup",arr:j(),f:e=>e.cleanup()})}t.maybeCleanup_=(0,r.lazy)(D,5*S.minuteMs),t.cleanup_=D;const k=(0,r.lazy)((()=>(0,l.libraryDataDirPosixFile)()?.join("shared-state").rmrf())),x=(0,r.lazy)((()=>u.FileCleanup.for({name:"imageCacheCleanup",rootNativePath:g.imageCacheDir_,staleMs:v.Settings.imageCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(g.ImageCacheName)}))),F=(0,r.lazy)((()=>u.FileCleanup.for({name:"readdirCacheCleanup",rootNativePath:async()=>f.PosixFile.for((0,m.readdirCacheDir)()),staleMs:v.Settings.readdirCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(m.ReadDirCacheName)}))),C=(0,r.lazy)((()=>u.FileCleanup.for({name:"previewWipCleanup",rootNativePath:l.libraryPreviewsDirPosixFile,staleMs:S.hourMs,isPrunable:e=>(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)}))),A=(0,r.lazy)((()=>u.FileCleanup.for({name:"advisoryLockWipCleanup",rootNativePath:d.defaultFsAdvisoryLockDir,staleMs:S.hourMs,isPrunable:h.isPsLockFileOrDir}))),I=(0,r.lazy)((()=>u.FileCleanup.for({name:"syncReportCleanup",rootNativePath:()=>(0,P.gt0)(v.Settings.syncReportRetentionCount.valueOrDefault)?(0,l.librarySyncReportsDir)():void 0,staleMs:S.hourMs,isPrunable:e=>(0,p.isWip)(e)||(0,c.isCsvExt)(e)})));function O(e){return(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)||(0,o.isSqliteFile)(e)}const L=(0,r.lazy)((()=>u.FileCleanup.for({name:"oldLibraryDbBackupCleanup",rootNativePath:()=>(0,_.libraryDbObjects_)().libraryDbBackupDir.sibling("backup"),staleMs:S.hourMs,isPrunable:O}))),R=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryDbBackupCleanup",rootNativePath:()=>(0,_.libraryDbObjects_)().libraryDbBackupDir,staleMs:S.hourMs,minRetained:v.Settings.dbBackupRetentionCount.valueOrDefault,isPrunable:O})));async function N(){const e=await(M.Library.instance()?.dbModelSetup_());return null!=e&&e.useReplica?e.db.localBackupDir():void 0}const B=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryReplicaDbBackupCleanup",rootNativePath:N,staleMs:S.hourMs,minRetained:1,isPrunable:O})));function j(){return(0,b.compact)([x(),F(),C(),A(),(0,y.LogDirCleanup)(),I(),L(),R(),B()])}t.fileCleanups=j,t.scheduleFileAndProcCleanups=(0,r.lazy)((()=>{w.Pids.instance()?.scheduleInterval();for(const e of j())e.scheduleInterval()})),t.cancelFileAndProcCleanups=function(){t.scheduleFileAndProcCleanups.unset(),w.Pids.instance()?.cancelInterval();for(const e of j())e.cancelInterval()}},64526:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Library=void 0;const l=i(27395),u=i(25764),c=i(38836),d=i(99331),h=i(45608),f=i(15056),m=i(87290),p=i(38835),g=i(57159),y=i(61704),w=i(95696),v=i(18454),b=i(13940),S=i(48604),P=i(19851),M=i(23560),_=i(28874),T=i(2858),E=i(7014),D=i(63870),k=i(15674),x=i(22573),F=i(38639),C=i(42659),A=i(56409),I=i(68708),O=i(25470),L=i(22526),R=i(41844);class N extends c.EndableWrapper{static instance(){const e=_.Settings.libraryDir.valueOrDefault,t=a(this,r,"f",s)?.rootDir.nativePath,i=!0===a(this,r,"f",s)?.isReadySync(),n=!0===a(this,r,"f",s)?.ended;return(0,y.nativePathsEqlSync)(t,e)&&!n?a(this,r,"f",s):(0,M.isSyncService)()&&i?void(0,h.exit)({reason:`Library changed mid-run. Shutting down to pick up new library at ${e}.`,status:0}):((0,l.end)(a(this,r,"f",s)),o(this,r,(0,x.blank)(e)||!(0,T._libraryHasSettings)(e)?void 0:new r(e),"f",s))}static get priorInstance(){return a(this,r,"f",s)}static endPriorInstance(){const e=a(this,r,"f",s);return o(this,r,void 0,"f",s),(0,l.end)(e)}static async instanceReady(){const e=r.instance();return await(e?.ready),e}static instanceRequired_(){const e=r.instance();if(null==e)throw new Error("Library is undefined"+p.FatalErrorFlag);return e}constructor(e){super(`library.Library(${e})`,(()=>this.onEnd()),u.EndableRanks.predb),this.start=Date.now(),this.readyLatch=new A.Latch,n.set(this,(0,P.lazy)((async()=>{try{this.logger.debug("setup() started"),this.logger.throwIfAborted_(),await(0,T.readLibrarySettings)(this.rootDir.nativePath),await(0,m.setupLibraryDirs_)(this.rootDir),await(0,b.imageCacheDir_)(),this.logger.throwIfAborted_();const e=await(0,E.bestVolumeForPath)((0,m.libraryPreviewsDirPosixFile)(this.rootDir));if((0,F.isTrue)(e?.remote)){const e=_.Settings.maxConcurrentImportsWhenRemote.valueOrDefault;_.Settings.maxConcurrentImports.hasValue()||(_.Settings.maxConcurrentImports.tmpValue=e,(0,k.clearMaxWorkCaches)()),this.logger.warn(`Library previews are on a remote volume. Setting maxSyncFileJobsMax to ${e}.`)}this.logger.throwIfAborted_(),(0,M.isDbService)()&&await this.dbModelJanitor(),this.previews(),this.logger.throwIfAborted_(),this.readyLatch.isPending()&&(this.logger.info("Library.setup() finished."),this.readyLatch.resolve())}catch(e){this.ended||(0,d.ending)()||(this.logger.warn("setup() failed:",{error:e}),v.HealthCheck.addError(e),this.readyLatch.reject(new g.WrappedError("Failed to start library",{cause:e})))}}))),this.previews=(0,P.lazy)((()=>(0,I.tap)(new S.Previews((0,m.libraryPreviewsDirPosixFile)(this.rootDir)),(e=>S.Previews.instance.set(e))))),this.originalsDir=(0,P.lazy)((()=>(0,m.libraryOriginalsDirPosixFile)(this.rootDir))),this.assetFileRepository=(0,P.lazy)((()=>new R.AssetFileRepository(this.originalsDir()))),this.libraryDbFile=(0,P.lazy)((()=>(0,f.pathToDb)(this.dataDir,"models"))),this.dbModelSetup_=(0,P.lazy)((async()=>{if((0,M.isDbService)())return(0,L.dbModelSetup_)(this.rootDir);throw new Error("Not a db service")})),this.dbFsLock=(0,P.lazy)((async()=>(await this.dbModelSetup_()).fslock)),this.useReplica=(0,P.lazy)((async()=>(await this.dbModelSetup_()).useReplica)),this.modelDb=(0,P.lazy)((async()=>(await this.dbModelSetup_()).db)),this.dbModelJanitor=(0,P.lazy)((async()=>O.DbModelJanitor.for(await this.dbModelSetup_()))),this.onEnd=(0,P.lazy)((async()=>{if(!(0,d.ending)())for(const{ea:e,t}of[{ea:this.dbModelJanitor.clear(),t:5*C.minuteMs},{ea:this.dbFsLock.clear(),t:(0,D.commandTimeoutMs)()}])await(0,l.end)(e,t);this.logger.info("onEnd(): finished.")})),this.rootDir=w.PosixFile.for(e),this.dataDir=(0,m.libraryDataDirPosixFile)(this.rootDir),this.logger.info("new()"),a(this,n,"f").call(this)}get isPendingSetup(){return this.readyLatch.isPending()}get ready(){return this.readyLatch.promise.then((()=>this))}isReadySync(){return this.readyLatch.isResolved()}async runDbBackup_(){return(await this.dbModelJanitor())?.backup_()}}t.Library=N,r=N,n=new WeakMap,s={value:void 0}},19113:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFileFiltersFor=void 0;const r=i(62105),s=i(181),n=i(94448),a=i(39604);t.libraryFileFiltersFor=function(e,{validateFile:t=!1}={}){const i=(0,r.expensiveFileFiltersFor)(e);return null!=(0,n.modelDb)()&&i.push({notBlocklistedSha:a.notBlocklistedSha}),t&&i.push({isValidFile:s.isValidFile}),i}},18449:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sentryEnabled=void 0;const r=i(7282),s=i(96706),n=i(29325),a=i(28874);t.sentryEnabled=function(){return(0,s.isEnvTrue)("ENABLE_SENTRY")||(0,r.isProd)()&&(0,n.isPacked)()&&!0===a.Settings.reportErrors.value}},95629:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelToSeverity=t.logEntryToBreadcrumb=t.mkBreadcrumbs=t.annotateEvent=t.sentryExceptionToS=t.sentryExceptionsToS=t.extractMessage=t.EventFilter=t.eventFilter=t.sendToSentry=t.installSentry=void 0;const o=n(i(16436)),l=a(i(48161)),u=a(i(1708)),c=i(19851),d=i(19043),h=i(50213),f=i(31578),m=i(7282),p=i(96175),g=i(23560),y=i(84968),w=i(81168),v=i(37805),b=i(25764),S=i(38836),P=i(99331),M=i(85100),_=i(98314),T=i(68301),E=i(70025),D=i(8769),k=i(34102),x=i(34592),F=i(42042),C=i(34474),A=i(20839),I=i(57902),O=i(45969),L=i(43334),R=i(40958),N=i(22573),B=i(42659),j=i(41400),z=i(98553),V=i(55835),W=i(12168),U=i(59455),q=i(54993),H=i(18449),G=(0,c.lazy)((()=>(0,h.mkLogger)("Sentry")));function $(e){(0,H.sentryEnabled)()&&null!=e&&!0!==(0,E.isDoNotSendError)(e)&&o.captureException(e)}t.installSentry=async function(e){try{return!!(0,H.sentryEnabled)()&&(o.init({dsn:L.isElectron?"https://0652cdd351054fe9853ff944b1f54e2c@o130922.ingest.sentry.io/289071":"https://5f52aefec1b3439eaed2e77b2d1210a8@o130922.ingest.sentry.io/1828379",shutdownTimeout:(0,M.serviceExitTimeoutMs)(e.name),release:v.release,environment:(0,m.nodeEnv)(),maxBreadcrumbs:100,integrations:[],beforeSend:(0,t.eventFilter)().beforeSend,onFatalError:e=>(0,D.onError)("sentry.onFatalError",e)}),G().info("Sentry initialized",{isElectron:L.isElectron}),!0)}catch(e){return G().warn("Failed to set up sentry",{error:e}),!1}},t.sendToSentry=$,t.eventFilter=(0,c.lazy)((()=>new J));class J{constructor(){this.beforeSend=async(e,t)=>{if(!(0,H.sentryEnabled)())return G().warn("Sentry.beforeSend(): not sending event",e),null;if(!0===await(T.ErrorStore.instance()?.eventQuotaExceeded(e)))return G().warn("Sentry.beforeSend(): event quota exceeded",e),null;const i=K(e,t);if(!0===(0,E.isDoNotSendError)(i))return G().info("Sentry.beforeSend(): event not sendable. vetoing",{event:e,hint:t,msg:i}),null;(0,N.blank)(e.message)&&(e.message=(0,w.ellipsize)(i,256));const r=await X(e);return await(T.ErrorStore.instance()?.maybeSendEvent(r))??null},(0,k.ee)().on("fatal",$),(0,k.ee)().on("nonFatal",$),new S.EndableWrapper("EventFilter",(()=>this.end()),b.EndableRanks.first)}end(){return(0,V.map)(o.getCurrentHub().getClient(),(e=>e.close(5*B.secondMs)))}}function K(e,t){return(0,R.uniq)((0,R.compactBlankish)([e.message,...(0,U.toA)(Z(e.exception?.values)),(0,_.errorToS)(t?.originalException)])).join(": ")}function Z(e){return(0,R.mapNotEmpty)(e,(e=>(0,R.compactBlanks)(e.map(Y))))}function Y(e){return(0,R.mapNotEmpty)((0,R.compactBlanks)([e?.type,e?.value].filter((e=>"error"!==(0,q.toS)(e).toLowerCase()))),(e=>e.join(": ")))}async function X(e){const t=await(0,F.getEmail)();(0,N.notBlank)(t)&&(null==e.user&&(e.user={}),e.user.email=t),(0,R.isEmpty)(e.breadcrumbs)&&(e.breadcrumbs=await Q());const i=e.extra??{};return i.pid=u.default.pid,i.serviceName=(0,g.serviceName)(),i.serviceEnding=(0,P.ending)(),i.runtimeMs=(0,y.runtimeMs)(),i.version=v.version,i.os=(0,p.osFullName)(),i.isDocker=(0,O.isDocker)(),i.nodeVersion=u.default.versions.node,i.locale=await(0,d.locale)(),i.cpus=(0,p.CPUs)(),i.memoryUsageMb=(0,f.memoryUsageMb)(),i.memoryUsageRssMb=(0,f.memoryUsageRssMb)(),i.systemMemory=(0,W.fmtBytes)(l.default.freemem())+" / "+(0,W.fmtBytes)(l.default.totalmem()),i.ffmpeg=await(0,x.ffmpegVersionDescription)(),i.argv=(0,z.stringify)(u.default.argv),e.extra=i,{timestamp:Date.now()/B.secondMs,...e}}async function Q(){await(0,j.delay)(3*A.DefaultLogFlushMs);const e=await(0,C.allRecentLogEntries)();return(0,R.compact)(e.map(ee))}function ee(e){return(0,V.map)(ie(e.l),(t=>({timestamp:e.ts/B.secondMs,level:t,category:e.from??(0,g.processName)(),message:(0,w.stripAnsiEsc)(e.ctx+": "+e.msg),data:"object"==typeof e.meta?e.meta:{value:(0,w.isString)(e.meta)?(0,w.stripAnsiEsc)(e.meta):e.meta}})))}t.EventFilter=J,t.extractMessage=K,t.sentryExceptionsToS=Z,t.sentryExceptionToS=Y,t.annotateEvent=X,t.mkBreadcrumbs=Q,t.logEntryToBreadcrumb=ee;const te=new Map([[I.LogLevels.fatal,"fatal"],[I.LogLevels.error,"error"],[I.LogLevels.warn,"warning"],[I.LogLevels.info,"info"],[I.LogLevels.debug,"debug"]]);function ie(e){return te.get(e)}t.logLevelToSeverity=ie},37158:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Service=t.setupEventHandlers=void 0;const p=m(i(29907)),g=m(i(1708)),y=i(57206),w=i(19851),v=i(50213),b=i(59880),S=i(23560),P=i(19913),M=i(71567),_=i(37805),T=i(38836),E=i(99331),D=i(45608),k=i(56038),x=i(55534),F=i(42499),C=i(49776),A=i(96706),I=i(98314),O=i(38835),L=i(70025),R=i(8769),N=i(57159),B=i(34102),j=i(33456),z=i(87408),V=i(85021),W=i(17181),U=i(86941),q=i(28874),H=i(41692),G=i(2858),$=i(69385),J=i(22573),K=i(42659),Z=i(41400),Y=i(56409),X=i(55835),Q=i(41583),ee=i(54993),te=i(95629);t.setupEventHandlers=(0,w.lazy)((()=>{(0,B.ee)().on("resume",(()=>(0,$.resume)())),(0,B.ee)().on("pause",(()=>(0,$.pause)()))}));class ie extends T.EndableWrapper{constructor(e){super(e),r.add(this),s.set(this,void 0),n.set(this,new Y.Latch),a.set(this,new Map),this.setup_=(0,w.lazy)((()=>(0,k.time)("Service.setup",(()=>f(this,r,"m",o).call(this))))),u.set(this,(0,w.lazy)((()=>{const e=g.default.stdin.pipe(new j.LineReader);return e.on("data",(e=>f(this,r,"m",d).call(this,(0,ee.toS)(e)))),e}))),(0,S.isBillingService)()||(0,H.setSettingsDefaults)(),h(this,s,(0,v.mkLogger)("Service("+this.name+")"),"f"),f(this,r,"m",c).call(this),this.setup_()}get name(){return super.name}get ready(){return f(this,n,"f").promise}get isReady(){return f(this,n,"f").isResolved()}setInputHandler(e,t){f(this,a,"f").set(e.trim().toLowerCase(),t)}}t.Service=ie,s=new WeakMap,n=new WeakMap,a=new WeakMap,u=new WeakMap,r=new WeakSet,o=async function(){try{(0,J.mapNotBlank)((0,A.getEnv)("PS_FATAL_"+this.name),(e=>{throw new N.WrappedError(e,{fatal:!0})})),(0,J.mapNotBlank)((0,A.getEnv)("PS_CRASH_"+this.name),(e=>{(0,Z.later)((()=>{throw new N.WrappedError(e)}),5*K.secondMs)})),(0,P.setServiceName)(this.name),(0,b.setProcessTitle)(),(0,S.isMainService)()&&await(0,U.mergeUserDataDirs_)(),await(0,G.readSettings)(),await f(this,r,"m",l).call(this),(0,W.setupLogger)(),(0,y.addDefaultJsonRevivers)(),(0,C.cacheDir)(),(0,t.setupEventHandlers)(),f(this,u,"f").call(this),await(0,F.setupLuxon)(),q.Settings.startPaused.valueOrDefault&&(0,$.pause)(),(0,E.ending)()?f(this,n,"f").reject():f(this,n,"f").resolve()}catch(e){console.error((0,I.errorToS)(e)),f(this,n,"f").reject((0,Q.toErr)(e)),(0,D.exit)({reason:(0,L.addErrorFlags)(this.name+" setup failed: "+(0,I.errorToS)(e),O.FatalErrorFlag),status:14})}},l=async function(){(0,S.isPermaService)()||(0,B.ee)().on("fatal",(e=>(0,D.exit)({error:e,status:12}))),g.default.on("unhandledRejection",(e=>(0,X.map)(e,(e=>(0,R.onError)("unhandledRejection",e))))),g.default.on("uncaughtException",(e=>(0,X.map)(e,(e=>(0,R.onError)("uncaughtException",e))))),g.default.on("SIGINT",(()=>(0,D.exit)({reason:"SIGINT",status:0}))),g.default.on("SIGHUP",(()=>(0,D.exit)({reason:"SIGHUP",status:0}))),g.default.on("SIGTERM",(()=>(0,D.exit)({reason:"SIGTERM",status:0}))),p.default.isWorker&&g.default.on("disconnect",(()=>(0,D.exit)({reason:"disconnect",status:0}))),await(0,te.installSentry)(this)},c=function(){this.setInputHandler("--version",(()=>(0,M.stdoutWrite)({version:_.version}))),this.setInputHandler(x.ServiceExitCommand,(()=>(0,Z.later)((()=>(0,D.exit)({reason:x.ServiceExitCommand+" from stdin",status:0}))))),this.setInputHandler("--times",(()=>(0,M.stdoutWrite)(k.PromiseTimer.instance().report()))),this.setInputHandler(V.HealthCheckCommand,(async()=>(0,M.stdoutWrite)(await(0,z.getStatusSummary)({refresh:!0}))))},d=async function(e){if(f(this,s,"f").debug("onLine()",{line:e,ending:this.ended||(0,E.ending)()}),await this.setup_(),e.startsWith("--")){const t=e.split(/\s+/,1)[0],i=f(this,a,"f").get(t);null==i?(f(this,s,"f").error("onLine(): unknown command",{line:e,knownCommands:[...f(this,a,"f").keys()]}),console.warn("unknown command "+e)):await i(e.slice(t.length).trim())}else f(this,s,"f").error("onLine(): failed to process",{line:e})}},56992:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.calcVolumesTTL=t.setVolumesTTL=void 0;const r=i(19851),s=i(50213),n=i(76596),a=i(87290),o=i(28874),l=i(2858),u=i(63870),c=i(7014),d=i(42659),h=i(31586),f=i(12168),m=(0,r.lazy)((()=>(0,s.mkLogger)("SetVolumesTTL")));async function p(){if(!(0,l.libraryHasSettings)())return;const e=[],t=await(0,c.volumes)(),i=o.Settings.minDiskFreeGb.defaultValue*f.GB;for(const r of[(0,a.libraryOriginalsDirPosixFile)(),(0,a.libraryPreviewsDirPosixFile)()]){const s=await(0,c.bestVolumeForPath)(r,t);if(null==s)return void m().warn("Can't find volume for "+r+", using default TTL for volumes()");if(s.availablethis.maybeRunChunk(),intervalMs:7*N.secondMs,onEnd:()=>w(this,r,"m",a).call(this),rank:T.EndableRanks.first,endTimeoutMs:C.Settings.taskTimeoutMs.valueOrDefault}),r.add(this),this.recentlyProcessed=new P.TTLArray(N.minuteMs),s.set(this,[]),this.taskCount=(0,v.lazy)((()=>W.Task.count())),d.set(this,(0,v.lazy)((()=>{this.logger.debug("status",this.state())}),((0,b.isTest)()?1:30)*N.secondMs)),f.set(this,(()=>this.maybeRunChunk())),m.set(this,(0,v.lazy)((()=>this.logger.info("runChunk(): no-op",{isPaused:(0,O.isPaused)(),isFull:this.p.isFull(),isTooBusy:(0,A.isTooBusy)(),whyDoNotRun:(0,I.whyDoNotRun)(this),pendingWorkCount:this.pendingWorkCount(),queueItemCount:this.taskCount(),freeSlots:this.p.freeSlots()})),((0,b.isTest)()?1:30)*N.secondMs)),this.maybeRunChunk=(0,v.lazy)((()=>{setTimeout((()=>{this.ended||(0,E.ending)()||(w(this,r,"m",g).call(this),this.maybeRunChunk.unset())}),t.TaskListRunLaterMs)})),p.set(this,(0,v.lazy)((()=>{const e=C.Settings.minBusyPct.valueOrDefault,t=C.Settings.stuckCheckIntervalMs.valueOrDefault;if(e<=0||this.p.isIdle()||t<=0)return;const i=A.CpuUsage.instance().busyPct();if(this.logger.debug("maybeCheckForStuckTasks()",{cpuBusyPct:i,minBusyPct:e,stuckCheckIntervalMs:t}),!(0,V.gte)(i,e))for(const e of this.p.running)if(e.elapsedMs>t){const t=e.payload;this.logger.error("Stuck serial task. Aborting.",{task:t,elapsedMs:e.elapsedMs});const i="stuck after "+e.elapsedMs+"ms";t.abort(i),e.reject(new M.AbortError(i))}}),C.Settings.stuckCheckIntervalMs.valueOrDefault)),this.p=new k.Promises(e,L.maxConcurrentImports),this.p.ee.on("vacancy",this.maybeRunChunk),this.p.ee.on("drain",(()=>w(this,r,"m",l).call(this))),(0,x.ee)().on("resume",w(this,f,"f")),W.Task.ee.on("added",this.maybeRunChunk)}async awaitDrain(e=[],t=0){(0,R.isEmpty)(e)&&(e=W.TaskNames.values);const i=new z.Latch;return w(this,s,"f").push({l:i,taskNames:e,maxRemaining:t,who:(0,j.shortStack)()}),this.maybeRunChunk(),i}isRunnable(){return!this.p.isFull()}currentWorkCount(){return this.p.unsettledCount()}pendingWorkCount(){return this.taskCount()-this.currentWorkCount()}hasCapacity(e=C.Settings.taskListCap.valueOrDefault){return e<=0||this.taskCount()e.payload))}currentTasksByFn(e){return this.currentTasks().filter((t=>t.fn===e))}state(){return{...this.p.stats(),isDone:w(this,r,"m",l).call(this),freeSlots:this.p.freeSlots(),pendingWork:this.taskCount(),next10:w(this,r,"m",h).call(this,10).map((e=>e.toString())),recentlyProcessedLast10:this.recentlyProcessed.slice(-10).map((e=>e.toString())),isRunnable:this.isRunnable()}}doNotStartMoreWork(){return(0,E.ending)()||this.ended||(0,O.isPaused)()||this.p.isFull()||(0,A.isTooBusy)()||(0,I.doNotRun)(this)||0===this.pendingWorkCount()}}t.TaskList=U,s=new WeakMap,d=new WeakMap,f=new WeakMap,m=new WeakMap,p=new WeakMap,r=new WeakSet,n=function(){this.taskCount.unset()},a=async function(){(0,x.ee)().off("resume",w(this,f,"f"));const e=new M.AbortError((0,E.ending)()?"service ending":"TaskList ended");for(const t of w(this,s,"f"))t.l.reject(e);await this.p.awaitAll()},o=function(){(0,R.filterInPlace)(w(this,s,"f"),(e=>e.l.isPending())),W.Task.dbl.runf((e=>e.delete().where("retries","<",0))),w(this,r,"m",n).call(this)},l=function(){if(this.ended)return;if(w(this,r,"m",o).call(this),(0,R.isEmpty)(w(this,s,"f")))return;const e=W.Task.countTaskNames();for(const t of this.p.deferreds){const i=t.name;e[i]=(e[i]??0)+1}for(const t of w(this,s,"f"))(0,F.sum)(t.taskNames.map((t=>e[t]??0)))<=t.maxRemaining&&t.l.resolve()},u=function(){return(0,R.uniq)(this.currentTasks().filter((e=>e.isSerial)).map((e=>e.fn)))},c=function(){return this.currentTasks().map((e=>e.id))},h=function(e){return 0===e?[]:W.Task.ops().allf((t=>(t=W.Task.orderBy(t.distinct().whereNotIn("id",w(this,r,"m",c).call(this)).whereNotIn("fn",w(this,r,"m",u).call(this))),(0,V.gt0)(e)&&(t=t.limit(e)),t)))},g=function(){if(w(this,r,"m",n).call(this),w(this,p,"f").call(this),this.doNotStartMoreWork())w(this,m,"f").call(this);else{w(this,d,"f").call(this);const e=this.p.freeSlots(),t=w(this,r,"m",h).call(this,e);this.logger.debug("runChunk():",{freeSlots:e,next:t});for(const e of t)this.p.enqueue({name:this.name,payload:e,l:()=>w(this,r,"m",y).call(this,e),serialId:e.isSerial?e.fn:void 0})}w(this,r,"m",l).call(this)},y=async function(e){try{await(0,D.time)("task."+e.fn,e._run())}catch(t){this.logger.warn("Failed to run task",{task:e,error:t})}finally{this.maybeRunChunk()}},U.instance=(0,B.defer)((()=>(0,S.isTaskListManager)()?new U:void 0))},44834:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExitWhenDone=void 0,t.ExitWhenDone="--exit-when-done"},21200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExitWhenDoneArg=void 0;const r=i(28874),s=i(38639),n=i(44834);t.ExitWhenDoneArg={beforeParse:e=>e.option(n.ExitWhenDone,"Exit after jobs are completed. Defaults to false unless paths are specified on the command line."),afterParse:e=>{(0,s.isTrue)(e.exitWhenDone)&&(r.Settings.exitWhenDone.envValue=!0)}}},2775:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ForceArg=void 0;const r=i(28874),s=i(38639);t.ForceArg={beforeParse:e=>e.option("--force","Deletes prior cached directory metadata, and forces directory contents to be re-scanned."),afterParse:async e=>{(0,s.isTrue)(e.force)&&(r.Settings.forceSync.envValue=!0)}}},31503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogArgs=void 0;const r=i(23560),s=i(83210),n=i(28874),a=i(38639);function o(){return(0,r.isMainService)()||(0,r.isSyncService)()}t.LogArgs={beforeParse:e=>{const t=(o()?', "PS_TAIL_LOGS=true"':"")+' and "PS_LOG_STDOUT=true".';return o()?e.option("-v, --verbose",'Verbose logging from all processes. Shortcut for "--info --tail". Caution: noisy during imports!'):e.option("-v, --verbose","Verbose logging. Equivalent to --info."),e.option("--error",`Emit "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=error"${t}`),e.option("--warn",`Emit "warn" and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=warn"${t}`),e.option("--info",`Emit "info", "warn", and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=info"${t}`),e.option("--debug",`Emit "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY NOISY. Sets "PS_LOG_LEVEL=debug"${t}}`),e.option("--trace",`Emit "trace", "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY VERY NOISY. Sets "PS_LOG_LEVEL=trace"${t}}`),o()&&e.option("--tail",'Emit log messages from both this process and all other concurrently running PhotoStructure processes on this host to stdout. This can be really helpful in seeing how PhotoStructure\'s processes are coordinating work. Caution: very noisy especially during imports. Sets "PS_TAIL_LOGS=true".'),e},afterParse:e=>{const t=(0,a.isTrue)(e.error),i=(0,a.isTrue)(e.warn),r=(0,a.isTrue)(e.info)||(0,a.isTrue)(e.verbose)||(0,a.isTrue)(e.v),l=(0,a.isTrue)(e.debug),u=(0,a.isTrue)(e.trace);u?n.Settings.logLevel.envValue="trace":l?n.Settings.logLevel.envValue="debug":r?n.Settings.logLevel.envValue="info":i?n.Settings.logLevel.envValue="warn":t&&(n.Settings.logLevel.envValue="error"),(0,s.isDaemon)(e)?(n.Settings.tailLogs.envValue=!1,n.Settings.logStdout.envValue=!1):((0,a.isTrue)(e.tail)&&(n.Settings.tailLogs.envValue=!0),(t||i||r||l||u)&&(n.Settings.logStdout.tmpValue=!0,o()&&(n.Settings.tailLogs.tmpValue=!0)),(n.Settings.tailLogs.valueOrDefault||n.Settings.logStdout.valueOrDefault)&&n.Settings.logLevel.isUnset()&&(n.Settings.logLevel.envValue="info"))}}},12195:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoFilterArg=void 0;const r=i(4175),s=i(38639);t.NoFilterArg={beforeParse:e=>e.option("--no-filter","Disables import filters. All paths will try to be imported, even if they are too small or are missing tags. See https://photostructure.com/faq/why-is-my-file-missing/ ."),afterParse:async e=>{(0,s.isFalse)(e.filter)&&(0,r.disableAllFilters)()}}},52288:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RebuildArg=void 0;const r=i(28874),s=i(38639);t.RebuildArg={beforeParse:e=>e.option("--rebuild","Rebuild your library by re-importing all your photos and videos (slow!) https://photostructure.com/faq/sync-vs-rebuild/"),afterParse:async e=>{(0,s.isTrue)(e.rebuild)&&(r.Settings.forceRebuildLibrary.envValue=!0)}}},46628:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.albumsFromTags=t.tagFilesWithAlbums=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(81168),o=i(74417),l=i(28874),u=i(47783),c=i(97573),d=i(42231),h=i(40958),f=i(22573),m=i(68708),p=i(75020),g=i(54993),y=(0,s.lazy)((()=>(0,n.mkLogger)("curators.AlbumTagger")));function w(e){return(0,f.blank)(e)?void 0:l.Settings.tagAlbumTitleHierarchies.valueOrDefault?(0,c.keywordToPath)(e):[e]}function v(e){if(null==e)return[];const t=(0,h.uniq)((0,r.flatMap)(l.Settings.tagAlbumTitle.values,(t=>(0,m.pluckDeep)(e,t)?.value))),i=(0,h.compact)(t.map(w));if((0,h.isEmpty)(i))return[];if(i.length>1)return y().tap({level:"info",msg:"albumFromFile()",result:i.map((e=>[p.TagRoots.Albums,...e]))});const s=i[0],n=(0,r.first)(l.Settings.tagAlbumDescription.values,(t=>(0,m.pluckDeep)(e,t)?.value)),u=(0,h.isEmpty)(s)?"(blank title)":(0,a.firstSubstringIgnoreCase)(l.Settings.tagAlbumsExcluded.values,[...s,(0,g.toS)(n)].join(" ")),c=null==u?[p.TagRoots.Albums,...s]:void 0;if(null!=c){const t={name:c[c.length-1],description:n};for(const i of l.Settings.tagAlbumDate.values){const r=(0,o.parseJsonDateToMillis)((0,m.pluckDeep)(e,i)?.value);if(null!=r){t.releasedAt=r;break}}c[c.length-1]=t}return y().tap({level:"info",msg:"albumFromFile()",result:(0,h.compact)([c]),meta:{titles:i,desc:n,whyExclude:u}})}t.tagFilesWithAlbums=async function(e){const t=[];for(const i of e){t.push(...v(await(0,u.readTags)(i)));for(const e of l.Settings.tagAlbumFilenames.values)t.push(...v(await(0,u.readRawTags)(i.sibling(e),!1)))}return y().tap({msg:"tagFilesWithAlbums()",result:(0,d.uniqTagPaths)(t),meta:{files:e}})},t.albumsFromTags=v},88224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagAsset=t.tagAndUpsertAsset_=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(28874),o=i(42231),l=i(40958),u=i(20214),c=i(43487),d=i(46628),h=i(63175),f=i(4407),m=i(58886),p=i(32646),g=i(48144),y=i(60047),w=i(6186),v=i(42003),b=i(43723),S=(0,r.lazy)((()=>(0,s.mkLogger)("curators.AssetTagger")));async function P({primaryVariation:e,files:t,priorTagPaths:i,capturedAts:r,uris:s}){const u=[];if(t=(0,l.uniqBy)([e,...t],(e=>e.nativePath)),a.Settings.tagCamera.valueOrDefault&&await(0,n.thenMap)((0,h.cameraTagFile)(e),(t=>{S().debug("Camera tag for "+e+":",t),u.push(t)})),a.Settings.tagLens.valueOrDefault&&await(0,n.thenMap)((0,y.lensTagFile)(e),(t=>{S().debug("Lens tag for "+e+":",t),u.push(t)})),a.Settings.tagGeo.valueOrDefault)for(const e of t){const t=await(0,p.geoTagFile)(e);if(null!=t){u.push(t);break}}await(0,n.thenMap)((0,f.dateTagFile)(e,r),(t=>{S().debug("Date tag for "+e+":",t),u.push(t)}));const c=await(0,b.whoTagFiles)(t)??[];S().debug("whoTagFiles for "+e+":",c),u.push(...c),await(0,n.thenMap)((0,g.keywordTagFiles)(t,c),(t=>{S().debug("Keyword tags for "+e+":",t),u.push(...t)})),a.Settings.tagFileType.valueOrDefault&&await(0,n.thenMap)((0,v.typeTagFiles)(t),(t=>{S().debug("MIME type tags for "+e+":",t),u.push(...t)})),await(0,n.thenMap)((0,m.tagAssetPaths)(s),(e=>{S().debug("file paths for uris",{uris:s,arr:e}),u.push(...e)})),await(0,n.thenMap)((0,d.tagFilesWithAlbums)(t),(t=>{S().debug("Album tags for "+e+":",t),u.push(...t)}));const P=(0,o.omitAncestorTags)((0,l.uniqBy)(u.map(w.normalizeTagRoot),o.joinTagPath)),M=await(0,w.tagDeltas)(i,P);return S().info("tagAsset("+e+")",{priorTagPaths:i,after:P,result:M}),M}t.tagAndUpsertAsset_=async function(e){const t=await e.getExistingAssetFiles();S().info("tagAndUpsertAsset()",{asset:e,existing_uris:t.map((e=>e.uri))});const i=t.find((e=>e.shown)),r=await(i?.posixFile_());if(null==i||null==r)return void S().throw("tagAndUpsertAsset(): no existing or primary asset file",{asset:e,existingPrimaryAssetFile:i,primaryVariant:r,doNotSend:!0,fatal:!1});const s=e.getShown();s?.id!==i.id&&(S().warn("Changing primary asset we're using a different variant for tagging.",{newPrimary:i.uri,priorPrimary:s?.uri}),e.setShown_(i));const n=await(0,u.thenCollect)(t,(e=>e.posixFile_())),l=e.getAssetFiles().map((e=>e.uri)),d=e.getTagPaths(),h=await e.getCapturedAts(),f=await P({primaryVariation:r,files:n,priorTagPaths:d,capturedAts:h,uris:l});S().info("tagAndUpsertAsset",f);const m=f.add.find((e=>(0,o.leafIsExcluded)(e,a.Settings.keywordBlocklist.values)));if(null!=m){if(!0!==e.shown)return S().info("this asset has an excluded tag, and it wasn't shown yet, so we're removing it.",{excludedTag:m}),await c.Asset.remove({assetId:e.id,blocklistShas:!1,unlinkAssetFiles:!1}),S().throw("tagAndUpsertAsset(): asset had excluded tag. Removed.",{excludedTag:m,uris:l,files:n.map((e=>e.nativePath))});S().info("this asset has an excluded tag, marking excluded",{excludedTag:m}),e.excludedAt=Date.now()}return e.applyTagPathDeltas(f),await e.updateFromFiles(),f},t.tagAsset=P},63175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cameraTagFile=t.cameraTag=void 0;const r=i(47783),s=i(75020),n=i(40958),a=i(22573);function o(e){return null==e||(0,a.blank)(e.Make)?void 0:(0,n.compactBlankish)([s.TagRoots.Camera,e.Make,e.Model])}t.cameraTag=o,t.cameraTagFile=async function(e){return o(await(0,r.readTags)(e))}},4407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateTagFile=t.dateTag=t.dayTagRef=t.monthTagRef=t.yearTagRef=t.dayToOrdinal=t.ordinalToMonth=t.monthToOrdinal=t.yearToOrdinal=void 0;const r=i(19851),s=i(19043),n=i(97352),a=i(81168),o=i(928),l=i(34102),u=i(28874),c=i(28544),d=i(47783),h=i(40958),f=i(55835),m=i(31586),p=i(75020),g=i(54993),y=(0,r.lazy)((()=>new Intl.DateTimeFormat((0,s.localeSync)(),{month:"short"}))),w=(0,r.lazy)((()=>{const e=y();return(0,h.range)(0,12,(t=>e.format(new Date(2016,t,1)))).map((e=>(0,a.stripSuffix)(e,".")))}));function v(e){return 1e4-e}function b(e){return 13-e}function S(e){return 33-e}function P(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:v(e)})))}function M(e){if((0,m.within)(1,12,e))return(0,f.map)(w()[e-1],(t=>({name:String(e),displayName:t,ordinal:b(e)})))}function _(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:S(e)})))}function T(e){const t=(0,g.toS)(u.Settings.tagYMD.valueOrDefault).toLowerCase();if(null==e||""===t||"off"===t||t.startsWith("disable"))return;const i=[p.TagRoots.When];if(t.startsWith("y")){const t=(0,f.map)((0,o.getYear)(e),P);if(null==t)return;i.push(t)}if(t.startsWith("ym")){const t=(0,f.map)((0,o.getMonth)(e),M);if(null==t)return i;i.push(t)}if(t.startsWith("ymd")){const t=(0,f.map)((0,o.getDay)(e),_);if(null==t)return i;i.push(t)}return i}(0,l.ee)().on("clearCache",(()=>{y.unset(),w.unset()})),t.yearToOrdinal=v,t.monthToOrdinal=b,t.ordinalToMonth=function(e){return 13-e},t.dayToOrdinal=S,t.yearTagRef=P,t.monthTagRef=M,t.dayTagRef=_,t.dateTag=T,t.dateTagFile=async function(e,t){if(""===u.Settings.tagYMD.valueOrDefault)return;const i=[...t];(0,h.isEmpty)(t)&&i.push((await(0,d.readTags)(e))?.capturedAt);const r=(0,c.bestCapturedAt)(i);return null==r||(0,c.capturedAtSrcFromStat)(r.src)&&!u.Settings.tagDateFromStat.valueOrDefault?void 0:T(r.date)}},58886:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addFileUriTagsToAsset=t.addFilesTagsToAsset=t.isFsTag=t.tagAssetPaths=void 0;const r=i(19851),s=i(50213),n=i(42231),a=i(21404),o=i(40958),l=i(89937),u=i(75020),c=i(54017),d=i(94448),h=i(69032),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.FilePathTagger")));function m(e,t){return e.applyTagPathDeltas({add:(0,o.compact)(t.map((e=>(0,a.uriToTagPath)({uri:e,isFile:!0}))))})}t.tagAssetPaths=async function(e){const t=[];for(const i of e)try{const e=(0,a.uriToTagPath)({uri:i,isFile:!0});if(null==e)continue;if(i.startsWith(l.PS_LOCAL_FILE_SCHEME)&&null!=(0,d.modelDb)()){const t=(0,n.tagRefToS)(e[1]);e[1]={name:t,displayName:await(0,h.displayNameForVolsha)(t)},f().info("tagAssetPaths()",{uri:i,tp:e})}t.push(e)}catch(e){f().warn("Failed to parse asset file URI",{uri:i})}return t},t.isFsTag=function(e){return(0,n.tagRefToS)(e[0]).toLowerCase()===u.TagRoots.fs},t.addFilesTagsToAsset=function(e){const t=c.AssetFile.dbl.pluckAllf((t=>t.select("uri").where({asset:e})));return m(e,t)},t.addFileUriTagsToAsset=m},32646:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.geoTagFile=t.geoTag=void 0;const r=i(48884),s=i(56519),n=i(28874),a=i(47783),o=i(75020),l=i(40958);function u(e){const t=(0,r.compactRight)(n.Settings.tagGeoTemplate.valueOrDefault.map((t=>e?.[t])));return 0===t.length||t.some((e=>null==e))?void 0:(0,l.compact)([o.TagRoots.Where,...t])}t.geoTag=u,t.geoTagFile=function(e){return(0,s.thenMap)((0,a.readTags)(e),u)}},48144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.keywordTagFiles=t.processKeywords=t.dedupeKeywordPaths=t.normalizeKeywordPaths=t.extractPathnameTags=t.extractDashDashTags=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(68852),o=i(81168),l=i(96859),u=i(56519),c=i(28874),d=i(47783),h=i(97573),f=i(42231),m=i(40958),p=i(76790),g=i(22573),y=i(41400),w=i(96249),v=i(55835),b=i(75020),S=i(54993),P=i(6186),M=i(43723),_=(0,s.lazy)((()=>(0,n.mkLogger)("curators.KeywordTagger"))),T=(0,s.lazy)((()=>(0,g.mapNotBlank)(c.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[ /${(0,a.escapeRegExp)(e)}]`)))));function E(e){return _().tap({msg:"extractDashDashTags()",result:(0,v.mapOr)((0,S.toS)(e).split("--")[1],(e=>(0,m.compactBlanks)((0,v.mapOr)(T(),(t=>e.split(t)),[e]))),(()=>[])),meta:{s:e}})}function D(e){return[...E(e.parent().posixPath),...E(e.name)]}(0,y.later)((()=>{c.Settings.keywordDelimiters.watchLater((()=>T.unset()))})),t.extractDashDashTags=E,t.extractPathnameTags=D;const k=/\w{2,7}:\/\/\S+/g;function x(e){const t=[],i=[],s=[];for(const t of(0,m.compact)(e))if(Array.isArray(t))s.push(t);else{const e=(0,S.toS)(t).replace(k,(e=>(i.push(e),"")));s.push(...(0,v.mapOr)((0,h.delimRe)(),(t=>e.split(t)),[e]))}const n=s.map((e=>(0,o.isString)(e)?(0,h.keywordToPath)(e):e)).map((e=>Array.isArray(e)&&1===e.length?e[0]:e)),[a,l]=(0,r.partition)(n,Array.isArray),u=a.map((e=>(0,m.compactBlanks)(e.map((e=>e.trim()))))).filter(m.isNotEmpty),d=(0,o.uniqIgnoreCase)((0,w.flatten)(u));t.push(...u);const f=[...l,...i].map((e=>e.trim())).filter((e=>(0,g.notBlank)(e)&&!(0,o.includesIgnoreCase)(d,e))),p="copy"===c.Settings.keywordReparenting.valueOrDefault,y="retain"===c.Settings.keywordReparenting.valueOrDefault,P=c.Settings.rootTagKeywordsAliases.values;for(const e of[...t])(0,o.includesIgnoreCase)(P,e[0])&&(e[0]=b.TagRoots.Keywords),e[0]!==b.TagRoots.Keywords&&(p?t.push([b.TagRoots.Keywords,...e]):y&&e.unshift(b.TagRoots.Keywords));for(const e of f)t.push([b.TagRoots.Keywords,e]);return(0,m.uniq)(t)}function F(e){return(0,m.uniqBy2)((0,p.sortBy)(e.map(P.normalizeTagRoot),(e=>{const t=(0,f.joinTagPath)(e);return[t.normalize().toLowerCase(),-1*(0,l.lcdiff)(t)]})),((e,t)=>(0,o.equalsIgnoreCase)((0,f.joinTagPath)(e),(0,f.joinTagPath)(t))))}function C(e,t){const[i,s]=(0,r.partition)(x(e),M.isWhoTag),n=(0,w.flatten)(i.map(M.nameTag)),a=(0,m.uniq)((0,w.flatten)([...n,...t].map((e=>{const t=(0,P.stripTagRoot)(e);return[t.join(", "),t.join(" "),[...t].reverse().join(" ")]})))),l=F([...s.filter((e=>!(0,o.includesIgnoreCase)(a,(0,P.stripTagRoot)(e).join(" ")))),...n]);return _().tap({msg:"processKeywords()",level:"info",result:l})}t.normalizeKeywordPaths=x,t.dedupeKeywordPaths=F,t.processKeywords=C,t.keywordTagFiles=async function(e,t){return C([...c.Settings.tagKeywordsFromPath.valueOrDefault?(0,w.flatten)(e.map(D)):[],...c.Settings.tagKeywordsFromMetadata.valueOrDefault?(0,w.flatten)(await(0,u.mapAsyncSerial)({name:"keywordTagFiles",arr:e,f:e=>(0,u.thenMap)((0,d.readRawTags)(e),h.rawTagKeywords)})):[]],t)}},60047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lensTagFile=t.lensTag=void 0;const r=i(56519),s=i(28874),n=i(47783),a=i(75020),o=i(40958),l=i(22573),u=i(55835);function c(e){return(0,u.map)(e,(e=>(0,l.mapNotBlank)(e.lensMake,(t=>(0,l.mapNotBlank)((0,o.compactBlanks)(s.Settings.tagFullLensModel.valueOrDefault?[e.lensModel,e.lensInfo]:[e.lensInfo,e.lensModel])[0],(e=>[a.TagRoots.Lens,t,e]))))))}t.lensTag=c,t.lensTagFile=function(e){return(0,r.thenMap)((0,n.readTags)(e),c)}},6186:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagDeltas=t.normalizeTagRoot=t.stripTagRoot=t.hasTagRoot=t.Roots=t.KwRoot=t.WhoRoot=t.AlbumsRoot=t.WhenRoot=void 0;const r=i(50213),s=i(28874),n=i(42231),a=i(75020),o=i(40958),l=i(22573),u=i(45599);t.WhenRoot={name:a.TagRoots.When,ordinal:1},t.AlbumsRoot={name:a.TagRoots.Albums,ordinal:2},t.WhoRoot={name:a.TagRoots.Who,ordinal:4},t.KwRoot={name:a.TagRoots.Keywords,ordinal:7};const c=(0,u.defer)((()=>(0,r.mkLogger)("curators.Taggers")));t.Roots=[t.WhenRoot,t.AlbumsRoot,{name:a.TagRoots.fs,ordinal:3},t.WhoRoot,{name:a.TagRoots.Camera,ordinal:5},{name:a.TagRoots.Lens,ordinal:6},t.KwRoot,{name:a.TagRoots.Type,ordinal:8}];const d=(0,o.uniq)([...a.TagRoots.values,...s.Settings.rootTagKeywordsAliases.values,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function h(e){return d.includes((0,n.tagRefToS)(e[0]).toLowerCase())}t.hasTagRoot=h,t.stripTagRoot=function(e){return h(e)?e.slice(1):e};const f=(0,o.uniq)([a.TagRoots.Albums,...s.Settings.rootTagAlbumsAliases.values].map((e=>e.toLowerCase()))),m=(0,o.uniq)([a.TagRoots.Keywords,...s.Settings.rootTagKeywordsAliases.values].map((e=>e.toLowerCase()))),p=(0,o.uniq)([a.TagRoots.Who,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));t.normalizeTagRoot=function(e){const i=(0,n.tagRefToS)(e[0]).toLowerCase();return(0,l.blank)(i)?e:m.includes(i)||m.includes(i)?[t.KwRoot,...e.slice(1)]:p.includes(i)?[t.WhoRoot,...e.slice(1)]:f.includes(i)?[t.AlbumsRoot,...e.slice(1)]:e},t.tagDeltas=async function(e,t){const i=(0,n.tagDiff)(t,e),r=(0,n.tagDiff)(e,t),a=s.Settings.excludedRootTags.valueOrDefault;return(0,o.filterInPlace)(i,(e=>{const t=a.includes((0,n.tagRefToS)(e[0]).toLowerCase());return t&&!(0,n.tagPathsInclude)(e,r)&&(r.push(e),c().info("tagDeltas(): removing excluded tag",e)),!t})),{add:i,remove:r}}},42003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fixCase=t.friendlySubtype=t.mimeTypeToTag=t.typeTagFiles=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(56519),o=i(54979),l=i(40958),u=i(22573),c=i(55835),d=i(42279),h=i(75020),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.TypeTagger")));t.typeTagFiles=async function(e){const t=(0,l.uniq)(await(0,a.mapAsyncSerial)({name:"typeTagFiles",arr:e,f:o.readMimeType}));return(0,l.compact)(t.map(p))};const m=new Map(["M2TS","JPEG","QuickTime"].map((e=>[e.toLowerCase(),e])));function p(e){const[t,i]=e.split("/");if(!(0,u.blank)(t)&&!(0,u.blank)(i))return f().tap({msg:"mimetypeToTag("+e+")",result:(0,c.map)(y(i,e),(e=>(0,l.compactBlanks)([h.TagRoots.Type,(0,n.capitalize)(t),...e])))})}t.mimeTypeToTag=p;const g=(0,r.lazy)((()=>new Map([["image/x-adobe-dng",["Raw","DNG"]],["image/x-fuji-raf",["Raw","Fujifilm"]],["video/m2ts",["MPEG-2"]],["video/mp2t",["MPEG-2"]],["video/mp4",["MPEG-4"]],["video/quicktime",["QuickTime"]],["video/x-msvideo",["AVI"]]])));function y(e,t){return(0,d.firstDefinedThunk)([()=>g().get(t.trim().toLowerCase()),()=>(0,c.map)(e.match(/^x-(\w{4,})-\w{3}/),(e=>["Raw",(0,n.capitalize)(e[1])])),()=>[w(e.replace(/^(?:x-|vnd\.|prs\.)/i,"").replace(/-/g," "))]])}function w(e){return null!=e.match(/[a-z\d]{3,4}/i)?e.toUpperCase():m.get(e.trim().toLowerCase())??(0,n.capitalize)(e)}t.friendlySubtype=y,t.fixCase=w},43723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nameTag=t.isWhoTag=t.whoTagFiles=void 0;const r=i(19851),s=i(50213),n=i(28874),a=i(47783),o=i(28630),l=i(66039),u=i(42231),c=i(40958),d=i(22573),h=i(96249),f=i(68708),m=i(75020),p=i(59455),g=(0,r.lazy)((()=>(0,s.mkLogger)("curators.WhoTagger")));t.whoTagFiles=async function(e){const t=[];if(n.Settings.tagJsonFaces.valueOrDefault){const i=[];for(const t of e)i.push(...(0,p.toA)(await t.jsonSidecars()));for(const e of i){const i=await(0,o.readJsonSidecar)(e),r=i?.peopleNames;(0,c.isNotEmpty)(r)&&t.push(...r)}}if(n.Settings.tagFaceRegions.valueOrDefault)for(const i of e){const e=await(0,a.readRawTags)(i,!0);if(null!=e)for(const i of(0,f.values)(e)){const e=i?.RegionList;if(Array.isArray(e))for(const i of e)"Face"===i.Type&&t.push(i.Name)}}if((0,c.isNotEmpty)(n.Settings.whoTags.values))for(const i of e){const e=await(0,a.readRawTags)(i,!0);for(const i of n.Settings.whoTags.values)t.push(...(0,p.toA)((0,f.pluckDeep)(e,i)?.value))}const i=(0,c.uniq)((0,h.flatten)((0,c.uniq)(t).map(v)));return g().tap({msg:"whoTagFiles()",level:"info",result:i,meta:{names:t,files:e.map((e=>e.nativePath))}})};const y=(0,c.uniq)([m.TagRoots.Who,...n.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function w(e){return y.includes((0,u.tagRefToS)(e[0]).toLowerCase())}function v(e){if(!(0,d.blank)(e))return Array.isArray(e)?(w(e)&&e.shift(),0===e.length?void 0:1===e.length?(0,l.renderNameTag)(e[0]):[[m.TagRoots.Who,...e]]):(0,l.renderNameTag)(e)}t.isWhoTag=w,t.nameTag=v},98348:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Db=void 0;const c=i(48884),d=i(19851),h=i(23560),f=i(25764),m=i(38836),p=i(99331),g=i(5916),y=i(12959),w=i(55332),v=i(91872),b=i(80632),S=i(51040),P=i(44955),M=i(15056),_=i(70025),T=i(57159),E=i(18454),D=i(28874),k=i(5233),x=i(42659),F=i(31586),C=i(68708),A=i(30976),I=i(17036),O=i(27134),L=i(35052);class R extends m.EndableWrapper{constructor(e,t){super("db.Db("+e+")",(()=>this.closeDb()),f.EndableRanks.db),r.add(this),this.schema=e,this.dbFile=t,s.set(this,0),n.set(this,void 0),this.endTimeoutMs=x.minuteMs,this.onRetry=(0,d.lazy)((()=>this.closeDb()),D.Settings.maxBusyDbMs.valueOrDefault/2),this.maxUpdatedAt=(0,d.lazy)((()=>"models"===this.schema?l(this,r,"m",a).call(this,"Asset","AssetFile","Example"):0),5*x.secondMs),this.migrate_=(0,g.lazyAsync)({desc:"db.migrate",later:async()=>{let e=!1;const t=this.dbFile;if(null==this.dbFile)throw new Error("Cannot migrate database: missing db");let i;if(await this.dbFile.isNonEmptyFile())try{await(0,O.verifyDb_)((()=>this.db))}catch(e){this.logger.warn("verifyDb failed before attempting Migration.",{error:e}),i=e}(null!=i||D.Settings.dbForceRecover.valueOrDefault)&&(E.HealthCheck.addLoadingMsg("Repairing database..."),await this.repair_(),e=!0);const r=new I.Migration(this.schema,this.db,t);return{appliedMigrations:await r.apply_(),migration:r,repaired:e}}}),this.tableInfo_=(0,d.lazy)((()=>(0,L.localTableInfo)(this.db)))}toJSON(){return(0,C.pick)(this,"schema","dbFile")}get isOpen(){return!0===l(this,n,"f")?.open}get inTransaction(){return this.isOpen&&!0===l(this,n,"f")?.inTransaction}prepare(e){return this.db.prepare(e)}pragma(e,t){return this.logger.tapThunk({msg:"PRAGMA "+e,result:()=>this.db.pragma(e,t)})}get db(){var e;const t=null==l(this,n,"f");if(t||!this.isOpen){this.logger.info("setting up new db connection to "+this.dbFile,{priorWasNull:t});try{u(this,n,(0,b.mkdb_)({nativePath:this.dbFile.nativePath}),"f")}catch(e){throw new T.WrappedError("Failed to set up "+this.dbFile,{cause:e,path:this.dbFile.nativePath})}}return(0,h.isSyncService)()&&"INCREMENTAL"===D.Settings.dbAutoVacuumMode.valueOrDefault&&(0,F.gt0)(D.Settings.dbWalAutoCheckpoint.valueOrDefault)&&u(this,s,(e=l(this,s,"f"),++e),"f")%D.Settings.dbWalAutoCheckpoint.valueOrDefault==0&&(this.logger.info("running incremental_vacuum..."),l(this,n,"f")?.pragma("incremental_vacuum")),l(this,n,"f")}async verify_(){await(0,O.verifyDb_)((()=>this.db))}assertHeartbeat_(){const e=(0,A.randomChars)(64),t=Date.now();try{this.db.prepare("INSERT INTO heartbeat (name, createdAt, updatedAt) VALUES (?,?,?)").run(e,t,t);const i=this.db.prepare("SELECT * FROM heartbeat WHERE name = ?").get(e);if(i?.name!==e)throw new Error("heartbeat INSERT/SELECT roundtrip failed")}finally{try{this.db.prepare("DELETE FROM heartbeat WHERE name = ?").run(e)}catch{}}}async closeDb(){try{this.logger.info("closing db",l(this,n,"f")),await(0,k.retryOnReject_)((()=>{!0===l(this,n,"f")?.open&&l(this,n,"f")?.close()}),{timeoutMs:D.Settings.dbBusyTimeoutMs.valueOrDefault,maxRetries:5,errorIsRetriable:_.isSqliteBusyError,retryDelay:x.secondMs})}catch(e){this.logger.warn("closeDb(): .close() failed",e)}u(this,n,void 0,"f")}async vacuum(){try{await(0,v.handleDbRetries_)("db.checkpoint",(()=>this.db),(()=>(0,O.checkpoint_)({db:this.db})),this.onRetry),await(0,v.handleDbRetries_)("db.optimize",(()=>this.db),(()=>this.db.pragma("OPTIMIZE")),this.onRetry),await(0,v.handleDbRetries_)("db.vacuum",(()=>this.db),(()=>this.db.exec("VACUUM")),this.onRetry)}catch(e){throw this.logger.warn("vacuum(): failed",{error:e}),e}}async repair_(){this.logger.warn("repair_(): Attempting restore of "+this.dbFile),await this.closeDb(),await(0,O.repairDbFile_)(this.dbFile),this.logger.info("repair_(): Database restoration was successful!")}localBackupDir(){return(0,M.dbBackupDir)(this.dbFile)}async backup_(e,t){const i=t??await(0,P.isDirSQLiteReadWrite)(e),s=(i?e:this.localBackupDir().join((0,y.filestamp)())).join(this.dbFile.base);return await l(this,r,"m",o).call(this,s),i||await(0,w.dbBackupCold_)(s,e),e.join(this.dbFile.base)}}t.Db=R,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(...e){const t=[];for(const i of e)try{t.push(this.db.prepare("SELECT MAX(updatedAt) FROM "+(0,S.dbValueToEscapedString)(i)).pluck().get())}catch(e){this.logger.warn(`#maxUpdatedAt(): failed to get max updatedAt for ${i}`,e)}return(0,c.max)(t)},o=async function(e){await e.parent().mkdirp_(),await this.db.backup(e.nativePath,{progress:e=>(this.logger.log((0,p.ending)()?"info":"debug","backup() "+(0,F.fmtPct)(100-e.remainingPages/e.totalPages*100)+" completed"),(0,p.ending)()?1e3:100)})}},25470:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.DbModelJanitor=t.Contested=t.NoOp=t.NoWriteLock=void 0;const c=i(66364),d=i(50213),h=i(23560),f=i(78406),m=i(25764),p=i(38836),g=i(99331),y=i(56038),w=i(12959),v=i(55332),b=i(76187),S=i(73209),P=i(28874),M=i(42659),_=i(75240),T=i(95700),E=i(22526),D=i(45648),k=5*M.minuteMs;t.NoWriteLock=Symbol("NoWriteLock"),t.NoOp=Symbol("NoOp"),t.Contested=Symbol("Contested");class x extends f.EndableInterval{static for(e){return new x(e.db,e.fslock,e.libraryDbFile,e.libraryDbBackupDir)}constructor(e,t,i,o){super({name:"db.DbModelJanitor",callback:()=>l(this,r,"m",n).call(this),intervalMs:P.Settings.dbBackupIntervalMs.valueOrDefault,initialDelayMs:M.minuteMs,rank:m.EndableRanks.db,endTimeoutMs:5*M.minuteMs,onEnd:()=>l(this,r,"m",a).call(this)}),r.add(this),this.db=e,this.dbFslock=t,this.libraryDbFile=i,this.libraryDbBackupDir=o,this.logger=(0,d.mkLogger)(this.name),this.fslockRelease=new p.EndableWrapper("db.DbModelJanitor.fslockRelease",(()=>this.dbFslock.release()),m.EndableRanks.postdb,k),s.set(this,0),this.dbFslock.tryAcquire_()}get useReplica(){return!this.db.dbFile.eql(this.libraryDbFile)}forceBackup_(){return this.backup_(!0)}async backup_(e=!1){return await(0,S.withLock_)({file:this.libraryDbBackupDir,timeoutMs:5*M.minuteMs,noopIfContested:!e},(async()=>{if(e&&u(this,s,0,"f"),(0,D.hasDbSetupErrors)())return this.logger.warn("backup_(): db has setup errors, skipping backup",{errors:(0,D.dbSetupErrors)()}),t.NoOp;if(!await this.dbFslock.tryAcquire_())return this.logger.info("backup_(): no-op: someone else has the fslock",{me:this.dbFslock.lockfile?.base,owner:(await this.dbFslock.selfAndSiblingNames_())[0]}),t.NoWriteLock;l(this,r,"m",o).call(this)||await(0,T.runMaintenanceTasks)();const i=this.db.maxUpdatedAt();return null!=i&&i>l(this,s,"f")?(0,y.time)("db.DbModelJanitor.backup_()",(async()=>{l(this,r,"m",o).call(this)?this.logger.info("backup_(): posthaste: skipping vacuum"):await this.db.vacuum(),u(this,s,i,"f");const e=this.libraryDbBackupDir.join((0,w.filestamp)()),t=await this.db.backup_(e,!this.useReplica);return this.useReplica&&await(0,v.dbBackupCold_)(t,this.libraryDbFile.parent()),this.logger.info("backup_(): backup successful",{destDbFile:t}),t})):(this.logger.info("backup_(): no update to the db since last backup",{ago:(0,_.fmtDuration)(Date.now()-l(this,s,"f"))}),t.NoOp)}))??t.Contested}}t.DbModelJanitor=x,s=new WeakMap,r=new WeakSet,n=async function(){try{await this.backup_()}catch(e){this.logger.error("backup_() failed",{error:e})}},a=async function(){const e=S.FsLock.for({file:this.libraryDbFile.sibling("db-teardown"),timeoutMs:k,endableRank:m.EndableRanks.postdb,noopIfContested:!1});(0,h.isDbManager)()&&await e.withLock_((async()=>{if(await this.dbFslock.iAmOnly_({vacuum:!0})){if(this.logger.info("#teardown(): I'm the last one in. Running backup and cleanup."),await this.backup_(),this.useReplica){const e=[(0,E.libraryDbInfoFromDbFile)(this.libraryDbFile),...(0,b.sqliteFiles)(this.db.dbFile)];this.logger.info("#teardown(): Removing replica artifacts",{victims:e});for(const t of e)await t.unlink()}}else this.logger.info("#teardown(): no-op: other processes are still running")})),await this.db.closeDb()},o=function(){return this.ended||(0,g.ending)()||(0,c.isSuspended)()}},22526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelSetup_=t.assertValidDbInfo_=t.libraryDbInfoFromDbFile=t.libraryDbInfoJsonFile=t.fsLockForDb=t.libraryDbObjects_=void 0;const r=i(19851),s=i(50213),n=i(92407),a=i(55332),o=i(44955),l=i(15056),u=i(87290),c=i(98314),d=i(38835),h=i(73209),f=i(95696),m=i(17217),p=i(18454),g=i(57902),y=i(28874),w=i(2858),v=i(40958),b=i(22573),S=i(42659),P=i(94448),M=i(98348),_=i(45648),T=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbModelSetup")));function E(e=y.Settings.libraryDir.valueOrDefault){if((0,b.blank)(e))throw new Error("Library directory is not set"+d.NoLibraryErrorFlag);const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dataDir"+d.NoLibraryErrorFlag);if(!(0,w._libraryHasSettings)(e))throw new Error(`Library at ${e} does not have a settings file`+d.NoLibraryErrorFlag);const i=(0,l.pathToDb)(t,"models");return{dataDir:t,libraryDbFile:i,libraryDbBackupDir:(0,l.dbBackupDir)(i)}}function D(e){return h.FsLock.for({file:e,timeoutMs:0,noopIfContested:!1})}function k(e=y.Settings.libraryDir.valueOrDefault){const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dir"+d.NoLibraryErrorFlag);return x((0,l.pathToDb)(t,"models"))}function x(e){return e.sibling("db-info.json")}async function F(e=k(),t){try{const i=await e.readJson(g.LogLevels.info);if(null==i)throw new Error(e+" is missing"+d.DbSetupErrorFlag);if(null!=t&&!await t.equalsUri_(i.uri))throw new Error(e+" expects the live db to be "+i.uri+" but the live db is "+await t.uri_()+d.DbSetupErrorFlag);const r=await f.PosixFile.forUri(i.uri);if(null==r)throw new Error(e+" expects the live db to be "+i.uri+" but that URI cannot be resolved."+d.DbSetupErrorFlag);try{await(0,o.assertDirSQLiteReadWrite_)(r.parent())}catch(t){throw T().error("assertValidDbInfo_(): failed to assert live dir was r/w",{error:t,liveDbFile:r,infoJsonFile:e}),new Error("Failed to validate that the live database directory, "+r.dir+", was read-writable by SQLite: "+(0,c.errorToS)(t)+d.DbSetupErrorFlag)}return{liveDbFile:r}}catch(e){throw(0,_.addDbSetupError)(e),e}}t.libraryDbObjects_=E,t.fsLockForDb=D,t.libraryDbInfoJsonFile=k,t.libraryDbInfoFromDbFile=x,t.assertValidDbInfo_=F,t.dbModelSetup_=async function(e=y.Settings.libraryDir.valueOrDefault){const{libraryDbFile:t,fslock:i,libraryDbBackupDir:r}=await async function(e=y.Settings.libraryDir.valueOrDefault){const t=E(e);return{...t,fslock:D(t.libraryDbFile)}}((0,b.mapNotBlank)(e,m.toNativePath_));let s,o;await i.tryAcquire_();const u=x(t);try{if(await(0,h.withLock_)({file:u,timeoutMs:5*S.minuteMs},(async()=>{const i=await u.readJson(g.LogLevels.info);if(s=i?.useReplica,null!=i){const{liveDbFile:e}=await F(u,t);o=new M.Db(l.Schemas.models,e)}if(null==s||null==o){const i=await(0,n.getLiveDbDir_)(e),r=await i.db.uri_();s=i.useReplica,s&&await p.HealthCheck.traceLater_("Setting up local replica database",(0,a.dbBackupCold_)(t,i.db.parent())).catch((e=>T().throw("Failed to set up replica db"+d.DbSetupErrorFlag,{src:t,dest:i.db,error:e}))),o=new M.Db(l.Schemas.models,i.db),await u.writeJson_({uri:r,useReplica:s})}})),null==o||null==s)return T().throw("Failed to open model db"+d.DbSetupErrorFlag+d.InternalErrorFlag,{libraryDir:e});if(await i.tryAcquire_()){const e=await o.migrate_();s&&(e.repaired||(0,v.isNotEmpty)(e.appliedMigrations))&&await o.backup_(t.parent(),!s),(0,_.clearDbSetupErrors)()}P.modelDb.set(o)}catch(e){throw T().error("Failed to set up model db",{error:e}),(0,_.addDbSetupError)(e),i.release(),e}return T().tap({msg:"dbModelSetup()",result:{db:o,useReplica:s,libraryDbFile:t,libraryDbBackupDir:r,fslock:i}})}},86859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DbRequest=void 0;const r=i(54557),s=i(50213),n=i(99331),a=i(56038),o=i(65753),l=i(66184),u=i(70417),c=i(28874),d=i(40958),h=i(22573),f=i(45599),m=i(96249),p=i(31586),g=i(51926),y=i(57038),w=i(21074),v=(0,f.defer)((()=>(0,s.mkLogger)("db.DbRequest")));t.DbRequest=class{constructor(e,t){this.db=e,this.tableName=t,this.cachedStatements=new r.FifoCache(256)}qb(){return(0,y.knex)()(this.tableName)}prep(e,t=!1){const i=(0,w.toSqlQuery)(e);try{const r=this.cachedStatements.getOrSet(this.db().db.__uid+":"+(!0===t?"pluck:":"")+i.sql,(()=>{const e=this.db().prepare(i.sql);return!0===t?e.pluck():e}));return r.database.open?{sq:i,stmt:r}:(this.cachedStatements.clear(),this.prep(e,t))}catch(e){return v().throw("prep() failed",{error:e,sqlQuery:i,retriable:!1})}}wrap({q:e,pluck:t,m:i}){try{const{sq:r,stmt:s}=this.prep(e,t);c.Settings.logSql.valueOrDefault&&v().log((0,l.defaultLogLevel)(),i+"(): "+(0,w.sqlQueryToS)(r));const n=s[i].bind(s);return null==r.bindings?n():n(r.bindings)}catch(t){if(!0===t.message?.includes("AdvisoryLock"))throw t;v().throw(t,{method:i,...(0,w.toSqlQuery)(e)})}}run(e){return this.wrap({q:e,m:"run"})}runScript(e,t=""){const i=(0,a.mkElapsed)("db.runScript()");for(const r of e){if((0,h.blank)(r)||r.trim().startsWith("--"))continue;this.run({sql:r});const e=(0,g.replaceAll)((0,g.ellipsize)(r,60),t,"");i.elapsed(e)}}mapRun(e){return e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return null==t.bindings?i.run():i.run(t.bindings)}))}runf(e){return this.wrap({q:e(this.qb()),m:"run"})}upsert(e){const t=(0,w.toSqlQuery)(e(this.qb()));return t.sql=t.sql.replace(/^(?:update|insert)\b/i,(e=>e.toUpperCase()+" OR REPLACE ")),this.wrap({q:t,m:"run"})}first(e){return this.wrap({q:e,m:"get"})}firstf(e){return this.wrap({q:e(this.qb()),m:"get"})}mapAll(e){return(0,m.flatten)(e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return i.all(t.bindings)})))}all(e){return this.wrap({q:e,m:"all"})}allf(e){return this.wrap({q:e(this.qb()),m:"all"})}async batched(e){let t,i=0;do{t=this.wrap({q:e.qb(this.qb(),t).limit((0,o.maxBatchPluckSize)()),m:"all"}),(0,d.isNotEmpty)(t)&&(await e.onResults(t),i+=t.length)}while((0,d.isNotEmpty)(t)&&!(0,n.ending)()&&(null==e.maxResults||e.maxResults>i));return{resultCount:i,done:null==t||t.length<(0,o.maxBatchPluckSize)()}}pluckFirst(e){return this.wrap({q:e,pluck:!0,m:"get"})}pluckFirstf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"get"})}pluckAll(e){return this.wrap({q:e,pluck:!0,m:"all"})}pluckAllf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"all"})}async pluckBatched(e){let t=0;const i=(0,u.min)([e.limit??(0,o.maxBatchPluckSize)(),e.maxResults]);if(i<=0||(0,p.lte0)(e.maxResults))return{done:!1,resultCount:t};let r;for(;null==e.maxResults||e.maxResults<=0||t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDbSetupErrorListener=t.hasDbSetupErrors=t.clearDbSetupErrors=t.addDbSetupError=t.dbSetupErrors=t._dbSetupErrors=void 0;const r=i(98314),s=i(22573),n=i(23541);t._dbSetupErrors=new Set;const a=[];t.dbSetupErrors=function(){return[...t._dbSetupErrors.values()]},t.addDbSetupError=function(e){if((0,n.isError)(e)||!(0,s.blank)(e)){t._dbSetupErrors.add((0,r.errorToS)(e));for(const e of a)e()}},t.clearDbSetupErrors=function({notifyListeners:e=!0}={}){if(t._dbSetupErrors.clear(),e)for(const e of a)e()},t.hasDbSetupErrors=function(){return t._dbSetupErrors.size>0},t.addDbSetupErrorListener=function(e){a.push(e)}},36908:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dedupeTags_=t.mergeTags_=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(42231),o=i(40958),l=i(76790),u=i(23838),c=i(31586),d=i(54993),h=(0,r.lazy)((()=>(0,s.mkLogger)("db.DedupeTags")));function f(e,t){function i(t){return e.prepare(t).run()}(0,o.isEmpty)(t)&&h().warn("mergeTags(): empty tagIds",{tagIds:t}),h().info("mergeTags() starting",{tagIds:t});const r=e.prepare("SELECT id, _path, parentId FROM Tag WHERE id IN ("+t.join(",")+") ORDER BY ID").all(),s=(0,o.compactBlanks)(r.map((e=>(0,a.tagPathLeaf)(e._path))).sort()),n=r[0],l=r.slice(1),u=n?.id;if((0,o.isEmpty)(s)||(0,o.isEmpty)(l)||null==n||!(0,c.gt0)(u))return void h().warn("mergeTags(): missing winner",{winner:n,winnerId:u,leafs:s,losers:l});const d=(0,a.splitTagPath)(n._path).slice(0,-1),f=[...d,s[0]];n._path=(0,a.joinTagPath)(f),n.parentId=0===d.length?null:e.prepare("SELECT id from Tag where _path LIKE ?").pluck().get((0,a.joinTagPath)(d))??n.parentId,h().info("mergeTags()",{winner:n,losers:l,winnerTagPath:f,leafs:s});const m=l.map((e=>e.id)).join(",");i(`UPDATE OR IGNORE AssetTag SET tagId = ${u} WHERE tagId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`DELETE FROM AssetTag WHERE tagId in (${m})`),i(`DELETE FROM Tag WHERE id in (${m})`),e.prepare("UPDATE Tag SET parentId = :parentId, _path = :path WHERE id = :id").run({parentId:n.parentId,path:n._path,id:u});const p=e.prepare("SELECT id, _path FROM Tag WHERE id != :winnerId AND _path LIKE :like COLLATE NOCASE").all({winnerId:u,like:n._path+"%"});for(const t of p){const i=(0,a.splitTagPath)(t._path).slice(f.length),r=(0,a.joinTagPath)([...f,...i]);t._path!==r&&(h().info("mergeTags(): repairing tag path",{ea:t,newPath:r}),e.prepare("UPDATE OR IGNORE Tag SET _path = :path, updatedAt = :updatedAt WHERE id = :id").run({id:t.id,updatedAt:Date.now(),path:r}))}return h().tap({msg:"mergeTags()",level:"info",result:{winner:n,losers:r}})}t.mergeTags_=f,t.dedupeTags_=function(e){const t=new u.MultiMap;for(const{id:i,_path:r}of e.prepare("SELECT id, _path FROM Tag ORDER BY id").iterate())t.add((0,n.stripSuffix)((0,d.toS)(r).trim(),a.TagSep).toLowerCase().normalize(),i);const i=(0,l.sortBy)(t.entriesArray().filter((([,e])=>e.length>1)),(([e])=>[-(0,n.countChars)(e,a.TagSep),-e.length,e]));for(const[,t]of i)f(e,t)}},57038:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstMigratedAt=t.knex=void 0;const s=r(i(31832)),n=i(19851),a=i(56519),o=i(55835),l=i(68708);t.knex=(0,n.lazy)((()=>(0,s.default)({client:"better-sqlite3",useNullAsDefault:!0}))),t.firstMigratedAt=async function(e){return(0,a.thenMap)(e("migrations").min("migration_time").first(),(e=>(0,o.map)((0,l.values)(e)[0],(e=>new Date(e)))))}},17036:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Migration=void 0;const o=i(77598),l=i(19851),u=i(50213),c=i(7282),d=i(37805),h=i(4867),f=i(51040),m=i(77740),p=i(38835),g=i(8769),y=i(57159),w=i(34102),v=i(73209),b=i(95696),S=i(43899),P=i(18454),M=i(28874),_=i(40958),T=i(42659),E=i(41400),D=i(98553),k=i(55835),x=i(34666),F=i(32639),C=i(45648),A=i(94715),I=i(27134);t.Migration=class{constructor(e,t,i){r.add(this),this.schema=e,this.db=t,this.dbFile=i,this.fsMigrations_=(0,l.lazy)((()=>this.migrationsDir.children_((e=>e.isFile&&e.basename.endsWith(".sql"))).catch((e=>this.logger.throw("Failed to read migration directory, "+this.migrationsDir+p.InternalErrorFlag,{error:e}))))),this.ensureMigrationTable_=(0,l.lazy)((()=>{this.db.exec("\nCREATE TABLE IF NOT EXISTS migrations (\n id INTEGER NOT NULL PRIMARY KEY,\n name TEXT NOT NULL,\n migration_time INTEGER NOT NULL\n) STRICT\n")})),this.unknownMigrations_=(0,l.lazy)((()=>this.migrationsInDatabase_().filter((e=>!(0,x.lt)((0,A.migrationNameToDate)(e),d.gitDate))))),this.assertKnownMigrations_=(0,l.lazy)((()=>{const e=this.unknownMigrations_();if((0,_.isNotEmpty)(e)){const t=new y.WrappedError("Please upgrade PhotoStructure to a newer version to open this library: Unknown migrations: "+e.join(","));throw(0,g.onError)(t),t}})),this.logger=(0,u.mkLogger)("db.Migration("+(0,D.stringify)({schema:e,db:i.nativePath})+")"),this.migrationsDir=b.PosixFile.for(S.ProjectPath.Migrations()).join(this.schema)}async pendingMigrationFiles_(){const e=this.migrationsInDatabase_();return(await this.fsMigrations_()).filter((t=>!e.includes(t.name)))}migrationsInDatabase_(){return this.ensureMigrationTable_(),this.db.prepare("SELECT name from migrations").pluck().all()}async apply_(e){return(0,v.withLock_)({file:this.dbFile.sibling("migrate"),timeoutMs:M.Settings.dbMaintenanceTimeoutMs.valueOrDefault},(()=>a(this,r,"m",s).call(this,e)))}async applyMigration_(e,t){try{const i=Date.now(),s=A.Migrations[e.name.replace(/^[\d_-]+/,"")],o=(0,F.isFunction)(s);return o?await s.bind(A.Migrations)(this.db):await a(this,r,"m",n).call(this,e),this.logger.info("applyMigration() completed",{elapsedMs:Date.now()-i,codeMigration:o,migration:e.baseWithParent}),t?.run(e.name,Date.now())}finally{(0,w.ee)().emit("clearDbCache")}}},r=new WeakSet,s=async function(e){try{this.ensureMigrationTable_(),(0,c.isProd)()&&this.assertKnownMigrations_();const t=[],i=this.db.prepare("INSERT INTO migrations (name, migration_time) VALUES (?, ?)");for(const r of await this.pendingMigrationFiles_())await P.HealthCheck.traceLater_("Upgrading database ("+r.name+")",(async()=>{if((0,m.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");(0,m.getDevEnvFlag)("PS_SLOMO")&&await(0,E.delay)((0,o.randomInt)(T.secondMs,3*T.secondMs)),await(0,k.map)(e,(e=>e(r))),await(0,h.thenOrTimeoutError)({p:this.applyMigration_(r,i),timeoutMs:5*M.Settings.dbMaintenanceTimeoutMs.valueOrDefault}).catch((e=>{throw new y.WrappedError("Migration "+r.name+" timed out.",{cause:e,fatal:!0,ignorable:!1})}))})),t.push(r.base);return this.logger.info("Migration complete",{appliedMigrations:t}),t}catch(e){const t=new y.WrappedError("Migrating the "+this.schema+" db failed",{cause:e});throw(0,C.addDbSetupError)(t),P.HealthCheck.addError(t),t}},n=async function(e){const t=e.name.includes("_nofk");try{const i=await e.readTextFile(),r=(0,f.splitBatchSql)(i);if((0,_.isEmpty)(r))this.logger.info("No-op migration: "+e);else{t&&this.db.pragma("foreign_keys = OFF");for(const t of r)try{this.db.exec(t)}catch(i){this.logger.throw("Failed to apply SQL",{stmt:t,migration:e.baseWithParent,cause:i,fatal:!0})}t&&(0,I.foreignKeyCheck_)(this.db)}}finally{t&&this.db.pragma("foreign_keys = ON")}}},94715:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Migrations=t.isoToPrecisionMs=t.fix_root_tags=t.tag_path_suffix=t.migrationNameToDate=t.plucklabmodeb6=t.lowercase_psnet_function=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(97352),o=i(68852),l=i(81168),u=i(85810),c=i(42022),d=i(1971),h=i(79842),f=i(89724),m=i(17415),p=i(88600),g=i(20014),y=i(42231),w=i(87001),v=i(40958),b=i(55835),S=i(31586),P=i(97790),M=i(89937),_=i(54993),T=i(7656),E=i(36908),D=(0,s.lazy)((()=>(0,n.mkLogger)("db.Migrations"))),k=new RegExp(`^(${(0,o.escapeRegExp)(M.PS_NETWORK_FILESYSTEM_SCHEME)}://.*?/)(.*)$`);function x(e,t){return(0,a.mapGt0)(e,(()=>(0,b.map)(function(e,t=c.ModeBits){return(0,g.splitBits)(e,t).map((e=>(0,u.unlabhash)(e,t)))}(e,6)[t],(e=>(0,u.toLabhash)(e,c.ModeBits)))))}function F(e){return e.endsWith(y.TagSep)?e:e+y.TagSep}function C(e){for(const t of e.prepare("SELECT id, parentId, _path FROM Tag WHERE id = parentId").iterate())D().warn("fix_root_tags(): broken tag",{broken:t}),(0,l.countChars)(t._path,y.TagSep)<2&&e.prepare("UPDATE Tag set parentId = null where id = ?").run(t.id)}function A(e){return(0,b.map)((0,h.isoToDated)(e),h.datedToPrecisionMs)??-1}t.lowercase_psnet_function=e=>(0,P.opt)(e).filter(l.isString).flatMap((e=>k.exec(e))).map((e=>e[1].toLowerCase()+e[2])).getOrElse((()=>e)),t.plucklabmodeb6=x,t.migrationNameToDate=function(e){const[t,i,r]=[e.slice(0,4),e.slice(4,6),e.slice(6,8)].map((e=>(0,S.toInt)(e)));return(0,p.validYMD)(t,i,r)?new Date(t,i-1,r):void 0},t.tag_path_suffix=F,t.fix_root_tags=C,t.isoToPrecisionMs=A,t.Migrations={fix_root_tags:C,lowercase_psnet_hostname:e=>{e.function("lowercase_psnet_hostname",{deterministic:!0},t.lowercase_psnet_function),e.exec("DROP INDEX IF EXISTS assetfile_uri_udx"),e.exec("UPDATE AssetFile SET uri = lowercase_psnet_hostname(uri)"),e.exec("CREATE UNIQUE INDEX assetfile_uri_udx ON AssetFile(uri)")},numeric_captured_at:e=>{e.function("isoToLocal",{deterministic:!0},f.isoToLocal),e.function("isoToOffsetMinutes",{deterministic:!0},m.isoToOffsetMinutes),e.function("isoToPrecisionMs",{deterministic:!0},A),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtLocal bigint"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtOffset integer"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtPrecisionMs integer"),e.exec("UPDATE AssetFile SET capturedAtLocal = isoToLocal(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtOffset = isoToOffsetMinutes(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtPrecisionMs = isoToPrecisionMs(capturedAtISO)"),e.exec("DROP INDEX asset_captured_at_geohash_idx"),e.exec("DROP INDEX assetfile_exifuid_idx"),e.exec("CREATE INDEX assetfile_capturedAtLocal_idx ON AssetFile(capturedAtLocal)")},spread_modes:e=>{e.function("plucklabmodeb6",{deterministic:!0},x),(0,S.times)(d.ModeCount,(t=>e.exec(`ALTER TABLE AssetFile ADD COLUMN mode${t} integer`))),e.exec("UPDATE AssetFile SET "+(0,S.times)(d.ModeCount,(e=>`mode${e} = plucklabmodeb6(mode8b6, ${e})`)).join(", "))},normalize_asset_file_uris:e=>{e.function("normalizeURI",{deterministic:!0},w.normalizeURI);const t=e.prepare("SELECT normalizeURI(uri) AS nuri, count(*) AS cnt, GROUP_CONCAT(id) AS ids FROM AssetFile GROUP BY nuri HAVING cnt > 1").all(),i=[];for(const s of t){const t=(0,_.toS)(s.ids).split(","),n=e.prepare("SELECT id, shown, version, updatedAt FROM AssetFile WHERE id in ("+t.join(",")+")").all(),a=(0,r.greatestBy)(n,(e=>[e.shown,e.version,e.updatedAt])),o=n.filter((e=>e.id!==a?.id));i.push(...o.map((e=>e.id)))}for(const t of(0,r.batches)(i,256))e.exec("DELETE FROM AssetFile WHERE id in ("+t.join(",")+")");e.exec("UPDATE AssetFile SET uri = normalizeURI(uri)")},dedupe_tag_paths:E.dedupeTags_,suffix_tag_paths:e=>{e.function("tag_path_suffix",{deterministic:!0},F),(0,E.dedupeTags_)(e),e.exec("UPDATE Tag SET _path = tag_path_suffix(_path)")},normalize_tag_paths:e=>{const t=e.prepare("SELECT id, _path FROM Tag WHERE _path LIKE '%' || char(31) || char(31) || '%'").all();D().info("normalize_tag_paths():",{badTags:t});for(const i of t){const t=(0,y.normalizeTagPath)(i._path);(0,E.mergeTags_)(e,(0,v.compact)([i.id,...e.prepare("SELECT id FROM Tag WHERE _path LIKE ?").pluck().all(t)]))}},drop_tc_tables:e=>{const t=/^(ct|taf|tag_counts)_[a-z\d]{6}$/i,i=e.prepare("SELECT name FROM sqlite_master WHERE type='table'").pluck().all(),r=i.filter((e=>null!=t.exec(e)));D().info("drop_tc_tables()",{tables:i,victims:r});for(const t of r)e.exec("DROP TABLE "+t)},rebuild_rotated_heic:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype = 'image/heif' AND rotation <> 0")},rebuild_videos:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%'"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where mimetype LIKE 'video/%')")},copy_asset_duration:e=>{e.exec("CREATE INDEX tmp_af_idx ON AssetFile (assetId, durationMs)"),e.exec("UPDATE Asset SET durationMs = (SELECT durationMs FROM AssetFile WHERE assetId = Asset.id AND durationMs IS NOT NULL LIMIT 1) WHERE durationMs IS NULL"),e.exec("DROP INDEX tmp_af_idx"),e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%' and durationMs IS NULL"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where version = 0)")},rebuild_tag_asset_counts:T.rebuildTagAssetCounts,create_tag_fts:e=>{e.exec("DROP TABLE IF EXISTS tag_fts"),e.exec("CREATE VIRTUAL TABLE tag_fts USING fts5 (root, path, content='', contentless_delete=1, tokenize=\"unicode61\");")}}},27134:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.repairDbFile_=t.checkpoint_=t.verifyDbFile_=t.verifyDb_=t.foreignKeyCheck_=t.integrityCheck_=t.quickCheck_=t.backupDbFile_=t.sqlite=void 0;const r=i(14121),s=i(19851),n=i(50213),a=i(84777),o=i(12959),l=i(5531),u=i(91872),c=i(99315),d=i(76187),h=i(51040),f=i(38835),m=i(57159),p=i(29882),g=i(95696),y=i(89966),w=i(38156),v=i(28874),b=i(63870),S=i(5233),P=i(42659),M=i(41400),_=i(50357),T=i(98553),E=i(56409),D=i(31586),k=i(20214),x=i(51926),F=i(12168),C=i(59455),A=i(54993),I=i(94448),O=i(9508),L=(0,s.lazy)((()=>(0,n.mkLogger)("db.SQLite")));function R({db:e,pragma:t,okResult:i}){L().debug("pragmaOrThrow_()",{db:N(e),db_open:e?.open,pragma:t,okResult:i});const r=(0,x.isString)(i)?e.pragma(t,{simple:!0}):e.pragma(t);(0,_.eql)(r,i)||L().throw(`${t} failed for ${N(e)}: ${(0,T.stringify)({result:r})}`)}function N(e){return(0,p.ellipsizePath)({p:e.name,maxLength:80})}function B(e){return R({db:e,pragma:"quick_check",okResult:"ok"})}function j(e){return R({db:e,pragma:"integrity_check",okResult:"ok"})}function z(e){const t=(0,C.toA)(e.pragma("foreign_key_check"));t.length>v.Settings.dbInvalidFKThreshold.valueOrDefault&&L().throw("foreignKeyCheck_(): too many invalid foreign keys to repair",{dbInvalidForeignKeyThreshold:v.Settings.dbInvalidFKThreshold.valueOrDefault,badRowsCount:t.length,badRows:t});for(const i of t)L().warn("repairDbFile_(): deleting row with invalid foreign key",{row:i}),e.prepare(`DELETE FROM ${(0,h.dbValueToEscapedString)(i.table)} WHERE rowid = ?`).run(i.rowid)}async function V(e){await(0,u.handleDbRetries_)("db.quickCheck",e,B),await(0,M.delay)(1),await(0,u.handleDbRetries_)("db.integrityCheck",e,j),await(0,M.delay)(1),await(0,u.handleDbRetries_)("db.foreignKeyCheck",e,z)}function W(e){return(0,O.withDbSync)(e,V,(0,b.commandTimeoutMs)())}t.sqlite=async function({dbFile:e,sql:t,args:i}){const s=await(0,y.sqliteNativePath_)(),n=await(0,r.thenElapsed)((0,a.stdout_)(s,[...(0,C.toA)(i),e.nativePath,t],{timeoutMs:1*P.minuteMs}));return L().debug("sqlite("+t+") on "+e+" in "+n.elapsedMs+"ms",n.result),n.result},t.backupDbFile_=function(e,t){return(0,S.retryOnReject_)((()=>async function(e,t){try{await t.parent().mkdirp_(),await t.unlink("trace");const i=await e.size();if(!(0,D.gt0)(i))return void L().warn("backupDbFile_(): "+e+" is empty");await((0,I.modelDb)()?.end()),await(0,O.withDb)(e,(async e=>e.exec("VACUUM INTO "+(0,h.dbValueToEscapedString)(t.nativePath))),2*P.minuteMs),L().info("backupDbFile_(): Finished "+e+" -> "+t)}catch(i){throw new m.WrappedError(`Could not back up db ${e} -> ${t}`,{cause:i})}}(e,t)),{maxRetries:3,retryDelay:P.secondMs,timeoutMs:P.minuteMs,errorIsRetriable:()=>!0})},t.quickCheck_=B,t.integrityCheck_=j,t.foreignKeyCheck_=z,t.verifyDb_=V,t.verifyDbFile_=W,t.checkpoint_=async function e({db:t,retries:i=3,checkpointType:r=v.Settings.dbWalCheckpointType.valueOrDefault}){if((r=l.CheckpointTypes.getCI(r)??l.CheckpointTypes.AUTO)===l.CheckpointTypes.AUTO)return;const s="wal_checkpoint("+r+")",[n]=(0,C.toA)(t.pragma(s));return L().info("checkpoint()",{pragma:s,result:n}),(0,D.gt0)(n?.busy)&&i>0?(await(0,M.delay)(250),e({db:t,retries:i-1})):n};const U=/no such table: sqlite_\w+/i;t.repairDbFile_=async function(e,t=c.RepairModes.dump){const i=g.PosixFile.for(e),r=(await i.parent().join("db-"+t,(0,o.filestamp)()).mkdirp_()).join(i.base);L().info(`repairDbFile_(${i} -> ${r})`);try{const e=await(0,y.sqliteNativePath_)(),s=4*Math.min(20*F.MiB,await(0,d.sqliteSizeBytes)(i)),n=new w.PushProgressObserver({path:(0,A.toS)(i),op:"Repairing your database"},s),o=new E.Latch,l=(0,a.execFile)(e,[i.nativePath,"."+t],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});l.stdout.on("error",(e=>{const i=(0,A.toS)(e);U.test(i)?L().info("repairDbFile_(): ignoring stderr",{err:i}):o.reject(new Error("sqlite "+t+" failed: "+i))}));const u=(0,a.execFile)(e,[r.nativePath],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});u.on("exit",(()=>o.resolve())),l.stdout.on("end",(()=>{u.stdin.end(null)})),l.stdout.on("data",(e=>{const t=e.length;n.incrProgress(t),u.stdin.write(e)})),await o,L().info(`repairDbFile_(): recovered to ${r}.`),await W(r),L().info(`repairDbFile_(): ${r} is valid, finishing repair.`);const c=await(0,k.thenCollect)((0,d.sqliteFiles)(i),(e=>e.renameYMDHMS_({subdir:"needed-repair"})));return await(0,k.thenCollect)((0,d.sqliteFiles)(r),(e=>e.mv_(i.parent()))),c.find((e=>".db"===e.ext||e.ext.startsWith(".sqlite")))}catch(e){return L().throw("failed to recover DB via dump and restore. Please see https://photostructure.com/faq/restore-db-from-backup/ "+f.FatalErrorFlag,{error:e})}}},21074:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqlWhereInClause=t.isQueryBuilder=t.sqlQueryToS=t.toSqlQuery=t.isSqlQuery=void 0;const r=i(48884),s=i(68852),n=i(81168),a=i(12943),o=i(96249),l=i(98553),u=i(31586),c=i(68708),d=i(32639),h=i(54993);function f(e){return null!=e&&(0,n.isString)(e.sql)&&(null==e.bindings||(0,a.isDbValued)(e.bindings))}t.isSqlQuery=f,t.toSqlQuery=function(e){if(null==e)throw new Error("null sql");if(f(e))return e;if((0,n.isString)(e))return{sql:e};if((0,d.isFunction)(e.toSQL))return(0,c.omit)(e.toSQL(),"__knexQueryUid");throw new Error("not queryish: "+(0,l.stringify)(e))},t.sqlQueryToS=function(e){if(null==e.bindings)return e.sql;if(Array.isArray(e.bindings))return(0,o.flatten)((0,r.zip)(e.sql.split("?"),e.bindings.map((e=>(0,l.stringify)(e))))).join("");{let t=e.sql;for(const i of(0,c.keys)(e.bindings))t=t.replace(new RegExp("[@:$]"+(0,s.escapeRegExp)(i),"gi"),(0,h.toS)(e.bindings[i]));return t}},t.isQueryBuilder=function(e){return(0,d.isFunction)(e?.where)&&(0,d.isFunction)(e?.limit)},t.sqlWhereInClause=function(e){return"("+(0,u.times)(e,(()=>"?")).join(",")+")"}},35052:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localTableInfo=t.parseTableInfo=void 0;const r=i(22573),s=i(23838);function n(e){const t=new s.MultiMap;for(const i of e)i.tableName.includes("fts")||i.tableName.includes("sqlite_")||(0,r.blank)(i.name)||(0,r.blank)(i.type)||t.add(i.tableName,{name:i.name,type:i.type.toUpperCase().trim().replace(/\s+/g,""),notnull:1===i.notnull,pk:1===i.pk});return t.entriesArray().map((([e,t])=>({tableName:e,columns:t})))}t.parseTableInfo=n,t.localTableInfo=function(e){return n(e.prepare("SELECT \nm.tbl_name as tableName,\np.*\nFROM sqlite_master AS m\nJOIN pragma_table_info(m.name) AS p\nORDER BY m.tbl_name, p.cid").all())}},9508:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withDb=t.withDbSync=void 0;const r=i(80632),s=i(28874),n=i(30301),a=i(54993);t.withDbSync=function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const o=(0,n.lazy)((()=>(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i})));try{return t((function(){const e=o();return e.open?e:o.refresh()}))}finally{o.prior()?.close()}},t.withDb=async function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const n=(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i});try{return await t(n)}finally{n.close()}}},43487:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Asset=void 0;const u=i(48884),c=i(19851),d=i(50213),h=i(88158),f=i(45393),m=i(56519),p=i(89724),g=i(38835),y=i(74128),w=i(79847),v=i(28874),b=i(47783),S=i(38010),P=i(40958),M=i(76790),_=i(75761),T=i(38639),E=i(11371),D=i(98553),k=i(55835),x=i(31586),F=i(20214),C=i(59455),A=i(64526),I=i(4407),O=i(54017),L=i(48722),R=i(37094),N=i(45295),B=i(39604),j=i(48723),z=i(41507),V=i(72761),W={"Asset.shown":1,"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null};class U extends V.TimestampedModel{constructor(){super(...arguments),r.add(this),this.attrs={},this.assetIdish=(0,c.lazy)((()=>({assetId:this.id,v:this.updateCount,capturedAtLocal:this.capturedAtLocal}))),this.mergedTags=(0,c.lazy)((async()=>{const e=[];for(const t of this.getAssetFiles()){const i=await t.posixFile(),r=await(0,b.readTags)(i),s=await(i?.mtimeMs());null!=i&&null!=r&&null!=s&&e.push({...r,SourceFile:i.nativePath,sourceModifiedTime:s,sourceIsPrimary:(0,T.isTrue)(t.shown)})}const t=R.AssetRevision.ops().allf((e=>e.where({assetId:this.id}))),i=new S.MergedTags("Asset:"+this.id);return i.addTag(...e,...this.assetFiles),i.addRevision(...t),i}))}static shownUnhidden(e){return null==e?s.query().where(W):e.andWhere(W)}static findUnhiddenById(e){return(0,x.gt0)(e)?s.ops().firstf((t=>s.shownUnhidden(t.where({id:e})))):void 0}static shownRemovable(e,t){return(t??s.query()).whereNotNull(e).andWhere({"Asset.shown":1})}static shownCount(){return s.ops().count(s.shownUnhidden().countDistinct("Asset.id"))}static deletePreviews(e){return A.Library.instance().previews().ap(e).deleteAll()}static async remove({assetId:e,blocklistShas:t,unlinkAssetFiles:i}){const r=(0,d.mkLogger)("Asset("+e+").remove()"),n=s.ops().findById(e);if(null==n)return void r.warn("asset not found");const a=n.isActive(),o=n.tagIds();r.info("starting",{unlinkAssetFiles:i});const l=n.getAssetFiles({refresh:!0});if(t){(0,B.upsertToShaBlockslist)(...l.map((e=>e.sha)));for(const e of l)(0,y.syncReport)().onProgress({from:"Asset.remove",path:await e.getNativePath()??e.uri,state:"blocklisted",details:"sha blocklisted (files with the same sha will not be imported)"})}N.AssetTag.dbl.runf((t=>t.delete().where({assetId:e}))),O.AssetFile.dbl.runf((t=>t.delete().where({assetId:e}))),R.AssetRevision.dbl.runf((t=>t.delete().where({assetId:e}))),s.dbl.runf((t=>t.delete().where({id:e}))),a&&j.Tag.deltaAssetCountAndAncestors(o,-1);try{await s.deletePreviews(e)}catch(e){r.error("Failed to delete previews",{error:e})}return{deletedMeta:i?await(0,w.trashOrUnlinkFileUris_)(l):[],assetFileMeta:l}}static nextOutdated(e=h.identity){return this.ops().findOne(e(l(this,s,"m",n).call(this)))}static nextOutdateds(e){return this.ops().all(e(l(this,s,"m",n).call(this)))}static outdatedCount(e=h.identity){return this.dbl.pluckFirst(e(l(this,s,"m",n).call(this)).count())}static findFirstByFile(e){return this.ops().findOne(e(this.query().select("Asset.*").join("AssetFile","AssetFile.assetId","Asset.id")))}static unshownAssetIds(){return this.dbl.pluckAll("\n SELECT DISTINCT af1.assetId\n FROM AssetFile af1\n LEFT JOIN (SELECT DISTINCT assetId FROM AssetFile WHERE shown = 1) AS af2 \n ON af1.assetId = af2.assetId\n WHERE af2.assetId IS NULL")}static archive(e){null!=s.ops().findById(e)&&(N.AssetTag.dbl.runf((t=>t.where({assetId:e}).delete())),O.AssetFile.dbl.runf((t=>t.where({assetId:e}).delete())),s.dbl.runf((t=>t.where({id:e}).delete())))}markUnshownAndUpsert(){this.shown=!1,this.version=f.AssetVersion,this.upsert()}markShownAndUpsert_(e){const t=this.getShown()?.id;if(null!=e){const t=e.shown;this.setShown_(e,{skipUpsert:!0}),!0!==t&&e.upsert()}this.shown=!0,this.version=f.AssetVersion,t!==this.getShown()?.id&&(this.updateCount=(this.updateCount??0)+1),this.upsert()}async updateFromFiles(){const e=await this.mergedTags();(0,k.map)(e.get("rating"),(e=>{this.logger().info("updateFromFiles()",{rating:e}),this.rating=e.value}))}isActive(){return(0,x.gt0)(this.id)&&!0===this.shown&&null==this.excludedAt&&null==this.deletedAt&&(null==this.rating||(0,x.gte)(this.rating,v.Settings.rejectRatingsLessThan.valueOrDefault))}toAssetId(){return(0,L.toAssetId)(this)}renderCaption(e){return(0,k.map)(this.capturedAtLocal,(t=>"Taken "+(0,p.fmtLocalDateShort)(t,e)))}async whenApiTag(){const e=(0,I.dateTag)((0,p.localToDateObject)(this.capturedAtLocal));return null==e?void 0:j.Tag.findOrCreate(e).toApiTag()}findAssetFileByUri(e){return this.getAssetFiles()?.find((t=>t.uri===e))}addAssetFile(e){(0,P.filterInPlace)(e.asset?.assetFiles??[],(t=>!(t.id===e.id||t.uri===e.uri))),e.assetId=this.id,e.asset=this,e.shown=!1,this.getAssetFiles().push(e),this.clear(),this.capturedAtLocal??(this.capturedAtLocal=e.capturedAtLocal),this.rating??(this.rating=e.rating),this.durationMs??(this.durationMs=e.durationMs)}async assetFileForFile_(e,t){const i=await e.uri();if(null==i)return this.logger().throw("assetFileForFile_(): null uri",{f:e});const r=this.getAssetFiles().find((e=>e.uri===i));if(null!=r)return r;const s=new O.AssetFile;return this.addAssetFile(s),!0!==t?.skipUpsert?await s.upsertIfNeeded_(e):await s.setFile_(e),s}static getTags(e){return j.Tag.ops().all(j.Tag.query().select("Tag.*").join("AssetTag","AssetTag.tagId","Tag.id").where("AssetTag.assetId",e).orderByRaw("COALESCE(Tag.ordinal, Tag._path)"))}tagIds(e){return!0===e?.refresh&&(this.tags=void 0),this.tags?.map((e=>e.id))??N.AssetTag.dbl.pluckAllf((e=>e.select("tagId").where({assetId:this.id})))}getTags(e){return!0===e?.refresh&&(this.tags=void 0),this.tags??(this.tags=s.getTags(this.id))}tagPaths(){return this.getTags().map((e=>e.path.join("/"))).sort()}setTagIds(e){const t=this.tagIds({refresh:!0});if((0,u.eqlUnordered)(t,e))return void this.logger().debug("setTagIds(): no-op, tagIds unchanged");const i=e.filter((e=>!t.includes(e))),r=t.filter((t=>!e.includes(t)));return this.applyTagIdDeltas({tagIdsToAdd:i,tagIdsToRemove:r})}applyTagPathDeltas(e){return this.applyTagIdDeltas({tagIdsToAdd:j.Tag.findOrCreateByPathN(e.add??[]).map((e=>e.id)),tagIdsToRemove:j.Tag.findByPathN(e.remove??[]).map((e=>e.id))})}applyTagIdDeltas(e={}){const t=this.tagIds({refresh:!0}),i=(0,P.uniq)((0,C.toA)(e.tagIdsToAdd).filter((e=>(0,x.gt0)(e)&&!t.includes(e)))),r=(0,P.uniq)((0,C.toA)(e.tagIdsToRemove).filter((e=>(0,x.gt0)(e)&&t.includes(e))));if((0,P.isEmpty)(i)&&(0,P.isEmpty)(r))return this.logger().info("applyTagIdDeltas(): no-op, no changes",{currentTagIds:t,...e}),t;this.isActive()&&j.Tag.deltaAssetCountAndAncestors(t,-1),(0,P.isEmpty)(i)||N.AssetTag.dbl.runf((e=>e.insert(i.map((e=>({assetId:this.id,tagId:e})))).onConflict(["assetId","tagId"]).ignore())),(0,P.isEmpty)(r)||N.AssetTag.dbl.runf((e=>e.whereIn("tagId",r).andWhere({assetId:this.id}).delete())),this.tags=void 0;const s=(0,P.uniq)([...t,...i]).filter((e=>!r.includes(e)));return this.isActive()&&j.Tag.deltaAssetCountAndAncestors(s,1),s}getStreams(e){if(null==this.streams){const t=this.getTags();this.logger().info("getStreams(): fetched tags "+t,{limit:e});const i=t.map((t=>t.getAssetStream(this,e)));this.streams=(0,z.coalesceStreams)((0,P.compact)(i));for(const e of this.streams)for(const t of e.tags)t.getAncestors()}return this.streams}getBeforeAfterId(){const e=s.dbl.all(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",this.capturedAtLocal).orderBy("assetId"));this.afterId=e.find((e=>e.assetId>this.id)),this.beforeId=e.reverse().find((e=>e.assetIde.path))}getAssetFiles({refresh:e=!1}={}){return null!=this.id&&(e&&(this.assetFiles=void 0),this.assetFiles??(this.assetFiles=(0,M.sortBy)(O.AssetFile.ops().findBy({assetId:this.id}),(e=>[!(0,T.isTrue)(e.shown),-e.mtime])))),this.assetFiles??[]}setShown_(e,t){e instanceof O.AssetFile&&(this.getAssetFiles(),this.assetFiles?.some(((t,i)=>{const r=t.id===e.id||t.uri===e.uri;return r&&(this.assetFiles[i]=e),r})));const i=e instanceof O.AssetFile?e.id:e;if(this.getShown()?.id===i)return void this.logger().debug("setShown_(): no-op, already set",{afId:i});this.logger().info("setShown_()",{assetId:this.id,assetFileId:i}),(0,x.gt0)(this.id)&&(0,x.gt0)(i)||this.logger().throw("setShown_(): invalid IDs: "+(0,D.stringify)({assetId:this.id,assetFileId:i})+g.InternalErrorFlag);const r=Date.now();O.AssetFile.dbl.runf((e=>e.update({shown:0,updatedAt:r}).where({assetId:this.id}))).changes<=0&&this.logger().warn("setShown_(): all asset files were already unshown",{afId:i});const s=O.AssetFile.dbl.runf((e=>e.update({shown:1,updatedAt:r}).where({id:i})));1!==s.changes&&this.logger().throw("setShown_(): failed to update asset file: unexpected changed rows",{runResult:s});const n=this.assetFiles?.find((e=>e.id===i))??this.getAssetFiles({refresh:!0}).find((e=>e.id===i));if(null!=n){this.capturedAtLocal=n.capturedAtLocal,this.rating=n.rating,this.durationMs=n.durationMs;for(const e of this.assetFiles??[])e.shown=e.id===i;!0!==t?.skipUpsert&&this.upsert()}else this.logger().throw("setShown_(): failed to find shown asset file",{af:e})}getShown(e){return this.getAssetFiles(e)?.find((e=>(0,T.isTrue)(e.shown)))??this.getAssetFiles({refresh:!0})?.find((e=>(0,T.isTrue)(e.shown)))}getShownNativePath(){return this.getShown()?.getNativePath()}async getCapturedAts(){return(0,F.thenCollect)(this.getAssetFiles(),(e=>e.capturedAt()))}link(){return"/asset/"+this.id}sqAttrs(e=!0){return{...(0,_.assetSqImgAttrs)({assetId:this.assetIdish(),lazyLoad:e}),title:this.renderCaption(),...this.attrs}}async getImgAttrs(e,t,i=!1){if(null==this.imgAttrs&&(this.imgAttrs=new Map),null==this.imgAttrs.get(t)){const r=e.ap(this.id);await(0,m.thenMap)(r.readInfo(),(async e=>{e.mimetype.startsWith("video/")&&(this.poster=await r.posterLink())}));const s=!0;this.imgAttrs.set(t,await r.imgAttrs(t,s,i))}return this.imgAttrs.get(t)}async fitAttrs(e){return{...await this.getImgAttrs(e,E.ReducerNames.fit),...this.attrs}}isVideo(){if(null==this.assetFiles)throw new Error(".video called before getFiles()");return this.assetFiles.some((e=>e.isVideo))}videoAttrs(){return{controls:!0,autoplay:!0,poster:this.poster,...this.attrs}}async videoSources(){const e=[];let t;for(const i of this.getAssetFiles())e.some((e=>e.type===i.mimetype))||await i.exists()&&(t??(t=i),e.push({src:(0,_.assetVideoLink)({assetId:this.assetIdish(),assetFileId:i.id}),type:i.mimetype}));return e.some((e=>"video/mp4"===e.type))||null==t||e.unshift({src:(0,_.assetVideoLink)({assetId:this.assetIdish(),assetFileId:t.id})+".mp4",type:"video/mp4"}),e}async getPosixFiles(){return(0,F.thenCollect)(this.getAssetFiles(),(e=>e.posixFile_()))}async getExistingAssetFiles(){return(0,m.filterAsync)({name:"getExistingAssetFiles",arr:this.getAssetFiles(),f:e=>e.exists()})}async findOrCreateByFile(e){const t=await e.uri_();if(null==t)return;const i=(0,C.toA)(O.AssetFile.ops().findBy({assetId:this.id,uri:t}))[0];return(0,k.orElse)(i,(async()=>{const t=new O.AssetFile;return t.asset=this,t.assetId=this.id,await t.setFile_(e),t}))}partialSimpleAsset(){return{assetId:this.id,liked:(0,x.gte)(this.rating,v.Settings.likeRating.valueOrDefault),hidden:(0,T.isTrue)(this.hidden),excluded:null!=this.excludedAt,deleted:null!=this.deletedAt}}clear(){return this.imgAttrs=void 0,this.streams=void 0,this.tags=void 0,this.mergedTags.unset(),this}}t.Asset=U,s=U,r=new WeakSet,n=function(){return s.shownUnhidden().andWhere("version","<",f.AssetVersion)},a=function(){return this.beforeId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal","<",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId",order:"desc"}]))},o=function(){return this.afterId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",">",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"asc"},{column:"assetId",order:"asc"}]))},U.$tableName="Asset",U.$uniqueColumnName="id",U.$booleanFields=["shown","hidden"]},54017:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFile=void 0;const a=i(76760),o=i(19851),l=i(88158),u=i(45393),c=i(68852),d=i(81168),h=i(13991),f=i(54296),m=i(56519),p=i(76490),g=i(89724),y=i(98314),w=i(38835),v=i(8769),b=i(29882),S=i(95696),P=i(62105),M=i(74128),_=i(35721),T=i(69589),E=i(28874),D=i(28544),k=i(16170),x=i(45200),F=i(34238),C=i(87001),A=i(42233),I=i(21404),O=i(40958),L=i(17586),R=i(22573),N=i(38639),B=i(42659),j=i(33374),z=i(50357),V=i(75240),W=i(11371),U=i(55835),q=i(31586),H=i(68708),G=i(34666),$=i(89937),J=i(75020),K=i(64526),Z=i(41844),Y=i(43487),X=i(48723),Q=i(94710),ee=i(72761);class te extends ee.TimestampedModel{constructor(){super(...arguments),r.add(this),this.uriObj=(0,o.lazy)((()=>F.URI.parse(this.uri))),this.whyRejected=(0,o.lazy)((async()=>{const e=await this.posixFile_();return null==e?"invalid URI":!0===await this.isFileDeleted()?"deleted":(0,P.whyRejectFile)(e)})),this.posixFile_=(0,o.lazy)((async()=>S.PosixFile.for(await this.getNativePath())))}static outdatedQuery(e){let t=(e.q??this.query()).where("version","<",u.AssetFileVersion);return null!=e.maxUpdatedAt&&(t=t.andWhere("updatedAt","<",e.maxUpdatedAt)),t.andWhere((t=>{(0,O.isNotEmpty)(e.mountpoints)&&(t=t.whereIn("mountpoint",e.mountpoints));for(const i of e.uris)t=t.orWhereLike("uri",i+"%");return t})).orderBy("id")}static async nextOutdated(e=l.identity){return this.ops().findOne(e(this.outdatedQuery(await(0,A.currentVolumeRoots)())))}static async outdatedCount(e=l.identity){const t=this.outdatedQuery(await(0,A.currentVolumeRoots)());return this.dbl.pluckFirst(e(t.count("id")))}static shownAssetFileId(e){return this.dbl.pluckFirstf((t=>t.where({assetId:e,shown:1}).limit(1)))}static primaryForAssetId(e){return(0,q.gt0)(e)?te.ops().first(Y.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id").select("AssetFile.*").where({assetId:e,"AssetFile.shown":1})):void 0}static shownUnhidden({uriRoot:e}={}){let t=Y.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id");return(0,R.blank)(e)||(t=t.andWhereLike("AssetFile.uri",e+"%")),t}static recentAssetIdsByUriRoot(e,t,i=64){const r=Date.now()-t;return this.dbl.pluckAll(te.shownUnhidden({uriRoot:e}).distinct("AssetFile.assetId").where("AssetFile.updatedAt",">",r).orderBy("AssetFile.updatedAt","desc").limit(i))}static assetFileCountByMimeType(e){const t=te.shownUnhidden({uriRoot:e}).select("mimetype").countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"}).groupBy("mimetype").orderBy("mimetype");return this.dbl.all(t)}static assetFileCountWithMimeType(e,t){let i=te.shownUnhidden({uriRoot:t}).countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"});return i=e.endsWith("/")?i.andWhereLike("mimetype",e+"%"):i.andWhere("mimetype",e),this.dbl.first(i)}static assetFileCountByMimeTypeRoots(e=["image/","video/"],t){return e.map((e=>({mimeTypeRoot:e,assetFileCount:te.assetFileCountWithMimeType(e,t)?.assetFileCount??0})))}static children(e,t){const i=this.query().whereLike("uri",e+"/%").andWhere("uri","regexp",`^${(0,c.escapeRegExp)(e)}/[^/]+$}`);return this.ops().all(null==t?i:t(i))}static async sameShaInLibrary(e){if(null==this.db())return;const t=await e.sha(),i=await e.size();return null!=t&&null!=i?this.ops().allf((e=>e.where({sha:t,fileSize:i}).andWhereLike("uri",$.PS_LIBRARY_PROTOCOL+"%"))):void 0}static sameAssetFileInLibrary(e){return this.ops().allf((t=>t.where((0,H.pick)(e,"sha","fileSize")).andWhere((e=>e.whereLike("uri",$.PS_LIBRARY_PROTOCOL+"%"))).andWhere((t=>t.whereNot({id:e.id})))))}librarySiblings(){return this.getAsset()?.getAssetFiles().filter((e=>e.id!==this.id&&e.uri.startsWith($.PS_LIBRARY_PROTOCOL)))}capturedAtLocale(e){return(0,g.fmtLocalDateShort)(this.capturedAtLocal,e)}get dominantColors(){return p.DominantColor.fromModeData(this)}set dominantColors(e){(0,H.assignAllFields)(this,p.DominantColor.toModeData(e))}get posixPathFromGrandparent(){return(0,U.map)(this.uriObj()?.fsPath,b.posixPathFromGrandparent)}async whyNotMatchesFile(e){const t=n(this,r,"m",s).call(this);if(null!=t)return t;if(null==this.fileSize||null==this.mtime)return"missing file metadata";if(null!=e){const t=await e.uri();if(null==t)return"file has no URI";if(!await(0,C.uriIsEquivalent)(this.uri,t))return"file URI mismatch"}try{const t=e??await this.posixFile_();if(!await t.exists())return"file is missing";const i=await this.fileFields_(t);return null==i?!0===await(t?.isDeleted())?"file is deleted":"file is unreadable":i.fileSize!==this.fileSize?"file size changed since last sync":(0,q.closeTo)(i.mtime,this.mtime,2*B.secondMs)?void 0:"file mtime changed since last sync"}catch(e){return(0,y.errorToS)(e)}}async matchesFile(e){const t=await this.whyNotMatchesFile(e);return this.logger().tap({level:"info",msg:"matchesFile()",result:null==t,meta:{whyNot:t}})}async whyNotInSyncWithFile(e){return E.Settings.forceSync.valueOrDefault?E.Settings.forceSync.key+"=true":this.version!==u.AssetFileVersion?"AssetFileVersion: "+this.version+" != "+u.AssetFileVersion:this.whyNotMatchesFile(e)}async inSyncWithFile(e){const t=await this.whyNotInSyncWithFile(e);return this.logger().tap({msg:"inSyncWithFile()",result:null==t,meta:{whyNotInSync:t}})}async fileFields_(e){const t=e??await this.posixFile_();return null==t?void 0:await(0,h.assetFileStatFields_)(t)}isInLibrary(){return this.uri.startsWith($.PS_LIBRARY_PROTOCOL)}async isNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){const t=await this.whyNotNoop(e);return this.logger().tap({msg:"isNoop()",result:null==t,meta:{whyNotNoop:t}})}async whyNotNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){if(!0===e.forceSync)return"forceSync is true";if(!(0,q.gt0)(this.id))return"missing .id";if(!(0,q.gt0)(this.assetId))return"missing .assetId";{const e=await this.whyNotInSyncWithFile();if(null!=e)return e}if(await(0,Z.mayCopyAssetsToLibrary)()){const e=K.Library.instanceRequired_().assetFileRepository(),t=e.whyNotCopyFile(await this.posixFile_());if((0,R.blank)(t)&&null==await e.existingLibraryAssetFile(this))return"need to copy into library"}this.syncState=M.AssetFileSyncStates.noop}isVersionUpToDate(){return(0,G.gte)(this.version,u.AssetFileVersion)}async siblingCount(){return te.dbl.pluckFirstf((e=>e.count().where({assetId:this.assetId}).andWhereNot({id:this.id})))}async upsertIfNeeded_(e,t=(0,T.forceContextOrSetting)()){if(null!=e&&await this.setFile_(e),await this.matchesFile()&&(0,q.gt0)(this.id)&&!t.forceSync)return void(null==this.syncState&&(this.upsert(),this.syncState??(this.syncState=M.AssetFileSyncStates.noop)));const i=await this.isFileDeleted();if(!0===i)return this.syncState=M.AssetFileSyncStates.deleted,this.delete(),!0!==t.skipAssetRepair&&Q.Task.addOne("repairAsset",{assetId:this.assetId}),this;if(!1===i){const i=await this.updateFromFile_(e,t);return this.syncState??(this.syncState=null==i?M.AssetFileSyncStates.noop:M.AssetFileSyncStates.synced),this.upsert()}return this.syncState??(this.syncState=M.AssetFileSyncStates.skipped),this}async updateFileFields_(e){(0,H.assignFields)(this,await this.fileFields_(e))}async updateFromFile_(e,t=(0,T.forceContextOrSetting)()){const i=Date.now(),r=this.logger().addContext(".updateFromFile_()");if(null!=this.id&&!0!==t.forceSync&&await this.matchesFile(e))return void r.info("updateFromFile() no-op: up-to-date version and file stat matches since last update");if(null!=e&&await this.setFile_(e),null==e&&(e=await this.posixFile_()),null==e||await e.clear().notExists())return this.syncState=M.AssetFileSyncStates.deleted,void r.info("no-op, "+e+" is missing");const s=await(0,h.mkAssetFile_)(e);return s.uri!==this.uri&&((0,R.blank)(this.uri)||!0===this.uri?.startsWith("file:"))&&(this.logger().warn("updateFromFile() upgrading uri",{prior:this.uri,new:s.uri}),this.uri=s.uri),(0,H.assignAllFields)(this,(0,H.omit)(s,"uri")),this.version=u.AssetFileVersion,this.syncState=M.SyncFileStates.synced,r.elapsed("finished",Date.now()-i,this.toJSON()),this}async updateFromShaSibling_(e){const t=n(e,r,"m",s).call(e);if(null==t){if(await this.exists())return this.logger().debug("updateFromShaSibling",e),null!=e.sha&&await e.matchesFile()&&this.sha===e.sha?((0,H.assignFields)(this,(0,H.omit)(e,"id","posixFile","uriObj","shown","uri","mtime","fileSize","mountpoint","createdAt","updatedAt","updateCount",...te.$transientFields)),this.updateFileFields_()):this.updateFromFile_();this.logger().warn("updateFromShaSibling(): fail: file is missing")}else this.logger().warn("updateFromShaSibling() sibling is invalid",{whySiblingIsInvalid:t})}getAsset(){return this.asset??(this.asset=(0,q.gt0)(this.assetId)?Y.Asset.ops().findById(this.assetId):void 0)}exists(){return(0,x.uriExists)(this.uri,this.mountpoint)}async isFileDeleted(){return(await this.posixFile_())?.isDeletedUri(this.uri)}async accepted(){return(0,R.blank)(await this.whyRejected())}async setFile_(e){const t=await e.uri_();if(null==t)return this.logger().throw("setFile(): no URI for "+e);const i=await e.mountpoint();if(null!=this.uri&&!await(0,C.uriIsEquivalent)(t,this.uri))return this.logger().throw("setFile(): cannot reassign non-equivalent URI",{prior:this.uri,new:t,file:e.nativePath});const r=await e.uriObject_();return null==r?this.logger().throw("failed to create URI for "+e):(this.uri=t,this.uriObj.set(r),this.mountpoint=i?.nativePath,this.nativePath=e.nativePath,this.posixFile_.set(Promise.resolve(e)),this)}get basename(){return(0,R.blank)(this.uri)?void 0:decodeURIComponent(this.uri.slice(this.uri.lastIndexOf("/")+1))}posixFile(){return this.posixFile_().catch((()=>{}))}async getNativePath(){return(0,R.blank)(this.nativePath)&&(null==this.uri?this.logger().error(".getNativePath() called before .setFile_()"+w.InternalErrorFlag):this.nativePath=await(0,f.getAssetFileNativePath)(this)),this.nativePath}async capturedAt(){return null==this.nativePath&&await this.getNativePath(),D.CapturedAt.fromAssetFile(this)}async originalDownloadable({brief:e=!1}={}){const t=this.basename;if(!0===e)return null==t?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:`Download ${t}`,basename:t,description:"Download original"};const i=await this.posixFile_();return this.logger().tap({msg:"originalDownloadable()",level:"info",result:null==i||await i.isEmpty()?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:e?`Download ${i.base}`:(0,_.mkDownloadableTitle)(i,"original",this.isVideo?"video":"image",{width:this.width,height:this.height}),basename:i.base,description:"Download original",details:`(${(0,j.fmtDim)(this)} ${i.ext})`},meta:{posixFile:i}})}async downloadables(e,t){try{const i=await this.posixFile_();if(null==i)return[];const r=e.ap(this.assetId),s=[];if(await(0,m.thenMap)(this.originalDownloadable(),(e=>s.push(e))),this.isVideo)return s;if(!(0,N.isTrue)(this.shown)&&this.sha!==t)return s;const n=(0,O.compact)(await Promise.all([...await r.previewInfos()].reverse().filter((e=>e.reducer===W.ReducerNames.fit)).map((e=>(0,_.previewToDownloadable)(i.base,e)))));return s.push(...(0,O.uniqBy)(n,(e=>e.size))),s}catch(e){return(0,v.onError)("AssetFile.downloadables failed for "+this.uri,e),[]}}async pathInfo(){try{const e=F.URI.parse(this.uri),t=(0,U.map)((0,I.uriToTagPath)({uri:e,isFile:!0}),(e=>X.Tag.findByPath(e)));return this._pathInfo_(await(t?.toApiPathElements()))}catch(e){return void this.logger().warn("pathInfo(): failed",e)}}async _pathInfo_(e){const t=await this.posixFile_();if(null==t)return this.logger().throw("pathInfo(): no posixFile",{uri:this.uri});const i=t.nativePath,r=F.URI.parse(this.uri),s=await t.exists();if(null==e||(0,O.isEmpty)(e))return this.logger().warn("pathInfo(): failed to find existing Tag. Returning a simple path.",{uri:this.uri,nativePath:i,tagLineage:e}),{nativePath:i,pathElements:[],nativePathSuffix:i,pathSep:a.sep,exists:s};function n(){return(0,L.at)((0,L.at)(e,-1)?.tagPath,-1)}(0,z.eql)(e[0]?.tagPath,[J.TagRoots.fs])&&(e=e.slice(1));const o=r.scheme===$.PS_LIBRARY_SCHEME,l=o?r.path.split("/").slice(1):t.pathnames,u=l.pop(),c=[];for(;l.length>0&&(0,d.equalsIgnoreCase)(n(),(0,L.at)(l,-1));){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("added matching tag",t)}if(o&&n()===J.LibraryTagName){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("pslib: added matching library tag",t)}if(r.scheme===$.PS_LOCAL_FILE_SCHEME){const t=F.URI.parse(this.uri).authority;if(this.logger().debug("psfile: pop last?",{lastTagName:n(),thisVolSha:t}),n()===t){l.pop();const t=e.pop();c.unshift(t)}else this.logger().warn("weird: I expected to be able to include the volsha tag element, but it doesn't seem to match",{thisVolSha:t,tagVolSha:n()})}return this.logger().tap({msg:"pathInfo()",result:{nativePath:i,pathElements:c,nativePathSuffix:u,pathSep:a.sep,exists:s}})}async toApi(e,t){return(0,m.thenMap)(this.pathInfo(),(async i=>(0,H.reqValuedOrElse)({assetId:this.assetId,assetFileId:this.id,...i,mimetype:this.mimetype,shown:(0,N.isTrue)(this.shown),name:this.basename,width:this.width,height:this.height,rotation:this.rotation??0,fileSize:this.fileSize,mtime:this.mtime,downloadables:await this.downloadables(e,t),createdAtLocale:ie(this.createdAt),updatedAtLocale:ie(this.updatedAt)})))}get isVideo(){return(0,k.isVideoMimeType)(this.mimetype)}}function ie(e){return(0,U.map)(e,(e=>(0,V.fmtDuration)(Date.now()-e,1)+" ago"))}t.AssetFile=te,r=new WeakSet,s=function(){if((0,R.blank)(this.uri))return"blank uri";if((0,R.blank)(this.sha))return"blank sha";if(!(0,q.gt0)(this.width))return"missing width";if(!(0,q.gt0)(this.height))return"missing height";if(!(0,q.gt0)(this.capturedAtLocal))return"missing capturedAtLocal";if(!(0,q.gte0)(this.capturedAtPrecisionMs))return"missing capturedAtPrecisionMs";if(E.Settings.useImageHashes.valueOrDefault){const e=[];for(const t of["dctHash","diffHash","meanHash"])(0,R.blank)(this[t])&&e.push(t);if(1===e.length)return"missing image hash: "+e[0];if(e.length>1)return"missing image hashes: "+e.join(", ")}return this.isVersionUpToDate()?void 0:"outdated version"},te.$tableName="AssetFile",te.$uniqueColumnName="uri",te.$booleanFields=["shown"],te.$transientFields=["nativePath","syncState"]},48722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toAssetId=void 0;const r=i(76596),s=i(31586);t.toAssetId=function(e){const t=(0,s.toGt0)(e?.assetId)??(0,s.toGt0)(e?.id);if(null==e||null==t||!(0,s.isNumber)(e?.capturedAtLocal))return;const i=((0,s.toGt0)(e.v)??(0,s.toGt0)(e.updateCount)??(0,s.toGt0)(e.updatedAt)??0)%1e6,n={assetId:t,capturedAtLocal:e.capturedAtLocal,v:i};return(0,s.gt0)(e.durationMs)&&(n.durationHMS=(0,r.durationHMS)(e.durationMs)),n}},37094:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetRevision=void 0;const r=i(98553),s=i(67478),n=i(55046);class a extends n.Model{static insert(...e){return a.ops().insert(e.map((e=>({assetId:e.assetId,createdAt:Date.now(),field:e.field,op:e.op,_priorValueJson:(0,r.stringify)(e.priorValue),_newValueJson:(0,r.stringify)(e.newValue)}))))}get priorValue(){return(0,s.parseJSON)(this._priorValueJson)}get newValue(){return(0,s.parseJSON)(this._newValueJson)}}t.AssetRevision=a,a.$tableName="AssetRevision"},45295:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetTag=void 0;const r=i(55046);class s extends r.Model{$pk(){return this.assetId+":"+this.tagId}}t.AssetTag=s,s.$tableName="AssetTag",s.$uniqueColumnName="assetId,tagId",s.$useCache=!1,s.$pkColumnNames=["assetId","tagId"]},61204:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeMonthTag=t.normalizeDateTags=t.getMonthTags=void 0;const r=i(19851),s=i(50213),n=i(97352),a=i(75020),o=i(4407),l=i(48723),u=`'${a.TagRoots.When}' || char(31) || '%' || char(31) || '%' || char(31)`,c=u+" || '%' || char(31)",d=(0,r.lazy)((()=>(0,s.mkLogger)("model.DateTagNormalizer")));function h(){return l.Tag.ops().allf((e=>e.whereNotNull("ordinal").andWhereRaw("_path LIKE "+u+" AND _path NOT LIKE "+c).limit(2400)))}function f(e){const t=(0,n.mapGt0)(e.ordinal,(e=>(0,o.monthTagRef)((0,o.ordinalToMonth)(e))));null==t?d().warn("failed to fix tag (no monthTagRef)",{t:e}):t.name!==e.name&&(d().info("Fixing month name",{tagRef:t,tag:e}),e.changeName(t.name)),e.maybeUpsertDisplayName(t?.displayName)}t.getMonthTags=h,t.normalizeDateTags=async function(){for(const e of h())f(e)},t.normalizeMonthTag=f},95700:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runMaintenanceTasks=void 0;const r=i(19851),s=i(56038),n=i(28874),a=i(42659),o=i(41400),l=i(69032),u=i(61204),c=i(49796);t.runMaintenanceTasks=async function({force:e}={}){await d(),await(!0===e?h.refresh():h());try{await(!0===e?(0,l.forceRunTagMaintenance)():(0,l.runTagMaintenance)())}catch{}};const d=(0,r.lazy)((()=>(0,s.time)("db.normalizeDateTags",u.normalizeDateTags))),h=(0,r.lazy)((()=>(0,s.time)("db.Progress.vacuum",(()=>c.Progress.vacuum()))),2*a.hourMs);(0,o.later)((()=>{n.Settings.libraryDir.watchLater((()=>{d.unset(),h.unset()}))}))},55046:(e,t,i)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const s=i(57975),n=i(50213),a=i(7282),o=i(65211),l=i(40958),u=i(38639),c=i(45599),d=i(31586),h=i(68708),f=i(34666),m=i(54993),p=i(57038),g=i(94448),y=i(33572),w=i(63872);class v{constructor(){this.$instanceId=(0,a.isTest)()?(0,o.uid)():void 0}static get $ctor(){return this.$schema+"."+this.$tableName}static query(){return(0,p.knex)()(this.$tableName)}static queryBy(e){return this.query().where(e)}static queryOneBy(e){return this.queryBy(e)}static ops(){return this._ops??(this._ops=new w.ModelOps(this,this.db))}static get dbl(){return this.ops().dbl}static rows(){return this.ops().rows()}static truncate(){if((0,a.isProd)())throw new Error("rejecting attempt to truncate in prod");this.dbl.run("DELETE FROM "+this.$tableName)}static ucn(e){const t=this.$uniqueColumnName.split(",").map((t=>e[t]));return t.some((e=>null==e))?void 0:1===t.length?t[0]:t.join(",")}static hasId(e){return this.$pkColumnNames.every((t=>null!=e[t]))}static pickId(e){return(0,h.pick)(e,...this.$pkColumnNames)}$ops(){return this.class().ops()}class(){return this.constructor}$pk(){return(0,m.toS)(this.id)}$ucn(){return this.class().ucn(this)}$tableName(){return this.class().$tableName}$uid(){return`${this.$tableName()}(${this.id??this.$ucn()})${!0===this.shown?"!":""}`}logger(){return(0,n.mkLogger)(this.class().$schema+"."+(0,m.toS)(this.valueOf()))}[s.inspect.custom](){return{...this.$toShallowJSON(),$instanceId:this.$instanceId}}toString(){return this.$uid()}valueOf(){return this.$uid()}static fromJSON(e){return(0,y.fromJSON)(this,e)}static toJSON(e){return this.fromJSON(e).toJSON()}$toShallowJSON(){return this.$_toJSON({encodeBool:u.isTrue})}$toDbJSON(e){return this.$_toJSON({encodeBool:u.boolToInt,includeCtor:!1,includeTransient:!1,colNames:e})}$clone(){return(0,y.fromJSON)(this.class(),this.toJSON())}toJSON(){return this.$_toJSON({encodeBool:u.isTrue})}_get(e,t,i=!0){const r=this[e];return null===r?[e,null]:!(0,f.isPrimitive)(r)||!i&&(0,l.includes)(this.class().$transientFields,e)?void 0:(0,l.includes)(this.class().$booleanFields,e)?[e,t(r)]:[e,r]}$_toJSON({encodeBool:e,includeCtor:t=!0,includeTransient:i=!0,colNames:r}){const s=this.class(),n=(0,l.notEmptyOr)(r,s.ops().columnNames());return(0,h.fromEntries)(n.map((t=>this._get(t,e,i))),t?{$ctor:s.$ctor}:{})}insert(){return this.logger().debug("insert()",{self:this.toJSON()}),this.class().ops().insertOne(this)}update(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("update()",{self:this.toJSON()}),this.class().ops().updateOne(this)}upsert(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("upsert()",{self:this.toJSON(),arg:e}),this.class().ops().upsertOne(this)}$afterInsert(){}$beforeUpsert(){}$afterUpsert(){}reload(){return this.class().ops().reloadOne(this)}delete(){(0,d.gt0)(this.id)&&this.class().ops().delete([this.id])}}t.Model=v,r=v,v.$schema="models",v.$logger=(0,c.defer)((()=>(0,n.mkLogger)(r.$schema+"."+r.$tableName))),v.db=g.modelDb,v.$pkColumnNames=["id"]},94448:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryModelDbFile=t.modelDb=void 0;const r=i(15056),s=i(87290),n=i(19851),a=i(55835);t.modelDb=(0,n.lazy)((()=>{})),t.libraryModelDbFile=function(e){return(0,a.map)((0,s.libraryDataDirPosixFile)(e),(e=>(0,r.pathToDb)(e,"models")))}},33572:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toJSON=t.assignFromJSON=t.fromJSON=t.addModelClass=void 0;const r=i(50213),s=i(40958),n=i(22573),a=i(38639),o=i(97790),l=i(51926),u=new Map;function c(e){u.set(e.$ctor,e)}function d(e,t,i=[]){const r=e.class();for(const[n,o]of Object.entries(t)){if("$ctor"===n)continue;if(void 0===o)continue;const t=(0,l.stripPrefixes)(n,i);e[t]=null==o?o:(0,s.includes)(r.$booleanFields,t)?(0,a.isTrue)(o):o}return e}t.addModelClass=c,t.fromJSON=function(e,t){if(null==t)throw new Error("json is null");if(null!=e&&(0,n.notBlank)(e.$ctor)&&!u.has(e.$ctor)&&c(e),t instanceof e)return t;const i=(0,o.opt)(t.$ctor).flatMap((e=>u.get(e))).getOrElse((()=>e));if(t instanceof i)return t;const r=new i;return null==t?r:d(r,t,(0,s.uniq)([e.$tableName+".",i.$tableName+"."]))},t.assignFromJSON=d,t.toJSON=function e(t,i,s){if(null!=t)return Array.isArray(t)?t.map(((t,r)=>e(t,i,`${s}[${r}]`))):"function"==typeof t.toJSON?t.toJSON():void(0,r.mkLogger)("ModelJSON.toJSON()").warn("Failed",{m:t,key:s,mc:i.$ctor})}},63872:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ModelOps=void 0;const f=i(48884),m=i(19851),p=i(50213),g=i(81168),y=i(48299),w=i(12943),v=i(38835),b=i(34102),S=i(28874),P=i(40958),M=i(76790),_=i(22573),T=i(50357),E=i(96249),D=i(98553),k=i(55835),x=i(31586),F=i(68708),C=i(59455),A=i(86859),I=i(33572);t.ModelOps=class{constructor(e,t){r.add(this),this.model=e,this.db=t,s.set(this,void 0),n.set(this,!0),a.set(this,new y.WeakCache),o.set(this,new Set),this.columnNames=(0,m.lazy)((()=>this.db().tableInfo_().find((e=>(0,g.equalsIgnoreCase)(e.tableName,this.tableName))).columns.map((e=>e.name)))),this.updatableColumnNames=(0,m.lazy)((()=>(0,P.diff)(this.columnNames(),this.immutableColumnNames))),this.ucnFieldNames=(0,m.lazy)((()=>this.ucn.split(","))),d(this,s,(0,p.mkLogger)(`ModelOps(${e.$tableName})`),"f"),(0,I.addModelClass)(e),d(this,n,e.$useCache??!0,"f"),this.dbl=new A.DbRequest(this.db,e.$tableName),(0,b.ee)().on("clearCache",(()=>h(this,a,"f").clear())),(0,b.ee)().on("clearDbCache",(()=>h(this,a,"f").clear()))}clearDbCache(){h(this,a,"f").clear()}get $cache(){return h(this,a,"f")}$cachedByJson(e){if(null==e||!h(this,n,"f"))return;const t=this.$pickModelUcn(e);return(null==t?void 0:h(this,a,"f").get((0,D.stringify)(t)))??this.$cachedById(e.id)}$cachedById(e){return(0,x.gt0)(e)&&h(this,n,"f")?h(this,a,"f").get((0,D.stringify)(e))??h(this,a,"f").findEntry((t=>t.id===e)):void 0}get dbOpen(){return(0,k.mapOr)(this.db(),(e=>e.isOpen),(()=>!1))}get tableName(){return this.model.$tableName}query(){return this.model.query()}toDbValued(e){const t=this.model.fromJSON(e),i=(0,w.toDbValued)(t);return(0,F.pick)(i,...this.columnNames())}run(e){return this.dbl.run(e)}fromJSON(e){if((0,F.isEmptyObj)(e))return;const t=this.model.fromJSON(e);return h(this,r,"m",u).call(this,t)}fromJSONs(e){return(0,P.compact)(e.map((e=>this.fromJSON(e))))}first(e){return this.fromJSON(this.dbl.first(e))}firstf(e){return this.first(e(this.query()))}all(e=this.query()){return this.fromJSONs(this.dbl.all(e))}allf(e){return this.all(e(this.query()))}findOne(e){return this.fromJSON(this.dbl.first(e))}findOneBy(e){return this.findOne(this.model.query().where(e))}findById(e,t){return this.findOneBy({...t,id:e})}findByIds(e){e=(0,C.toA)(e).filter(x.gt0);const t=[],i=[];for(const r of e){const e=this.$cachedById(r);null!=e?t.push(e):i.push(r)}const r=(0,f.batches)(i,S.Settings.dbBatchSelectSize.valueOrDefault).map((e=>this.dbl.all(this.query().whereIn("id",e))));return(0,M.sortBy)([...t,...this.fromJSONs((0,E.flatten)(r))],(t=>e.indexOf(t.id)))}findBy(e){return this.all(this.model.queryBy(e))}findWhereIn(e,t){return this.all(this.model.query().whereIn(e,t))}rows(e){return this.count(e??this.model.query().count())}count(e){return(0,x.toGt0)(this.dbl.pluckFirst(e))??0}countf(e){return this.count(e(this.query()))}insert(e){return(0,C.toA)(e).map((e=>this.insertOne(e)))}upsertOne(e){return this.modelSupportsUpsert?this.upsert([e])[0]:this.insertOrUpdateOne(e)}insertOrUpdateOne(e){return null==e.id?this.insertOne(e):this.updateOne(e)}insertOne(e){if(this.model.hasId(e))throw new Error("insert called for "+(0,D.stringify)(e)+v.NonRetriableErrorFlag);const t=this.fromJSON(e);if(null==t)return h(this,s,"f").throw("insertOne(): fromJSON returned null"+v.InternalErrorFlag,{t:e});t instanceof this.model&&h(this,r,"m",u).call(this,t),t.$beforeUpsert();const i=t.$toDbJSON(this.columnNames()),n=this.dbl.runf((e=>e.insert(i)));return t.id=(0,x.toInt)(n.lastInsertRowid),t.$afterInsert(),t.$afterUpsert(),t}unsetField(e,t){return(0,k.map)(this.$cachedById(e),(e=>{e[t]=null})),this.dbl.runf((i=>i.where({id:e}).update(t,null)))}updateOne(e){if(null==e.id)throw new Error("update called for "+(0,D.stringify)(e)+v.NonRetriableErrorFlag+v.InternalErrorFlag);const t=this.model.fromJSON(e);t.$beforeUpsert();const i=t.$toDbJSON(this.updatableColumnNames());return this.dbl.runf((t=>t.where({id:e.id}).update(i))),t.$afterUpsert(),h(this,r,"m",u).call(this,t)??t}get ucn(){return(0,_.toNotBlank)(this.model.$uniqueColumnName)??"id"}get modelSupportsUpsert(){return null!=this.ucn&&"id"!==this.ucn}get ucnConstraint(){return`(${this.ucn})`}get immutableColumnNames(){return(0,P.uniq)([...this.ucnFieldNames(),"id","createdAt"])}onConflictClause(e){const t=this.immutableColumnNames,i=e.filter((e=>!t.includes(e))).sort().map((e=>`${e}=excluded.${e}`)).join(","),r=["ON CONFLICT",this.ucnConstraint];return(0,_.blank)(i)?r.push("DO NOTHING"):r.push("DO UPDATE SET",i),r.join(" ")}$pickModelUcn(e){const t={};for(const i of this.ucnFieldNames()){const r=e[i];if(null==r)return;t[i]=r}return t}reloadOne(e){if(h(this,o,"f").has(e.id))return;const t=this.$pickModelUcn(e);if(null!=t){const i=h(this,r,"m",u).call(this,e),s=this.findOneBy(t);if(null==s)return;return h(this,r,"m",l).call(this,i,s),i!==e&&h(this,r,"m",l).call(this,e,i),i}h(this,s,"f").warn(".reloadOne(): failed to reload "+(0,D.stringify)(e))}reload(e){const t=[],i=this.allf((i=>{for(const r of e){const e=this.model.hasId(r)?this.model.pickId(r):this.$pickModelUcn(r);null!=e?(t.push([r,e]),i=i.orWhere(e)):h(this,s,"f").warn("reload(): given insufficient partial model",{fragment:r})}return i})),n=[];for(const[e,a]of t){const t=i.find((e=>(0,T.eqlSubset)(a,e)));if(null==t)h(this,s,"f").warn("reload(): failed to find result in db",{prior:e,dbArr:i});else{const i=h(this,r,"m",u).call(this,e);h(this,r,"m",l).call(this,i,t),i!==e&&h(this,r,"m",l).call(this,i,t),n.push(t)}}return n}upsert(e){if(e=(0,P.compact)(e),!this.modelSupportsUpsert)return e.map((e=>this.insertOrUpdateOne(e)));const t=this.columnNames(),i=[];for(const s of(0,f.batches)((0,C.toA)(e),S.Settings.dbBatchUpsertSize.valueOrDefault)){const e=new Map,n=new Set,a=(0,P.compact)(s.map((e=>this.fromJSON(e))));for(const t of a){const i=(0,D.stringify)(this.$pickModelUcn(t));e.set(i,t),this.model.hasId(t)||n.add(i),t.$beforeUpsert()}h(this,r,"m",c).call(this,a.map((e=>e.$toDbJSON(t))));const o=this.reload(a),l=new Map(o.map((e=>[(0,D.stringify)(this.$pickModelUcn(e)),e])));for(const e of a){const t=(0,D.stringify)(this.$pickModelUcn(e)),r=l.get(t)??e;n.has(t)&&r.$afterInsert(),r.$afterUpsert(),i.push(r)}}return i}delete(e){const t=(0,C.toA)(e).filter(x.gt0);for(const e of t)h(this,o,"f").add(e);return h(this,a,"f").deleteValueIf((e=>t.includes(e.id))),this.run(this.model.query().delete().whereIn("id",t))}async batched(e){const t=e.batchSize??S.Settings.dbBatchSelectSize.valueOrDefault;let i,r;do{i=this.allf((i=>(i=e.qb(i),null!=r&&(i=i.andWhere("id",">",r)),i.orderBy("id","asc").limit(t)))),(0,P.isNotEmpty)(i)&&(r=Math.max(...i.map((e=>e.id))),await e.onResults(i))}while((0,P.isNotEmpty)(i))}},s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function(e,t){(0,F.assignFields)(e,t,{omitKeys:["$instanceId"],assignNullish:!0})},u=function(e){if(h(this,n,"f")){const t=this.$cachedByJson(e);if(null!=t)return h(this,r,"m",l).call(this,t,e),t;{const t=this.$pickModelUcn(e)??e.id;null!=t&&h(this,a,"f").set((0,D.stringify)(t),e)}}return e},c=function(e){const t=this.query().insert(e).toSQL(),i=new Set;for(const t of e)for(const e of(0,F.keys)(t))i.add(e);const s={sql:t.sql+" "+this.onConflictClause([...i.values()]),bindings:t.bindings};this.run(s);for(const t of e){const e=this.$cachedByJson(t);null!=e&&h(this,r,"m",l).call(this,e,this.model.fromJSON(t))}}},20958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Operation=t.OperationNames=void 0;const r=i(19851),s=i(50213),n=i(88158),a=i(99331),o=i(70025),l=i(8769),u=i(22573),c=i(98553),d=i(50989),h=i(72761);t.OperationNames=(0,d.strEnum)("rebuildLibrary","forceRestartSync");const f=(0,r.lazy)((()=>(0,s.mkLogger)("model.Operation")));class m extends h.TimestampedModel{static incomplete(){return this.ops().allf((e=>e.whereIn("id",(e=>e.table(m.$tableName).min("id").whereNull("completedAt")))))}static ensurePendingOp(e){return m.getFirstPendingOp(e)??m.ops().insertOne(e)}static getFirstPendingOp(e){return f().tap({msg:"getFirstPendingOp",level:"info",result:this.ops().firstf((t=>{const i=t.whereNull("completedAt").orderBy("createdAt","asc");return null!=e?i.andWhere(e):i})),meta:{crit:e}})}static markOpCompleted(e,t){return(0,u.blank)(e?.name)?f().throw("markOpCompleted(): bad query",{crit:e}):this.dbl.runf((i=>i.whereNull("completedAt").andWhere(e).update({completedAt:Date.now(),...t})))}static async applyIfPending(e,t){const i=this.ops().firstf((t=>t.whereNull("completedAt").andWhere(e)));return f().info("applyIfPending()",{crit:e,op:i}),null==i?void 0:t(i)}static async applyOnce_(e,t,i=n.identity){const r=this.ops().firstf((t=>i(t.whereNotNull("completedAt").andWhere(e))));if(null!=r)return void f().debug("applyOnce(): already done",{priorCompleted:r});const s=this.ops().insertOne(e);try{const e=await t(s);return(0,a.ending)()||s.markCompleted(),e}catch(t){if((0,o.isRedoableError)(t))return void f().info("applyOnce(): redoable error",{crit:e,error:t});throw(0,l.onError)("Operation.applyOnce(): "+(0,c.stringify)(e),t),t}}markCompleted(){null==this.completedAt&&(this.completedAt=Date.now(),this.upsert())}}t.Operation=m,m.$tableName="Operation",m.$uniqueColumnName="id",m.$useCache=!1},49796:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Progress=t.defaultMinCreatedAt=t.toPct=void 0;const r=i(48161),s=i(1708),n=i(48884),a=i(50213),o=i(28874),l=i(40958),u=i(42659),c=i(45599),d=i(98553),h=i(55835),f=i(31586),m=i(68708),p=i(67478),g=i(51926),y=i(59455),w=i(54993),v=i(76386),b=i(33572),S=i(55009),P=i(72761),M=(0,c.defer)((()=>(0,a.mkLogger)("model.Progress")));function _(e){return null==e||!(0,f.isNumber)(e)||e<0||e>100?void 0:(0,f.sigFigs)(e,3)}t.toPct=_;const T=(0,g.compressWhitespace)("\nSELECT\n p1.uri,\n p1.id as lastProgressId,\n p1.createdAt as lastStartedAt,\n p1.updatedAt as lastUpdatedAt,\n p3.lastCompletedAt\nFROM\n Progress AS p1\n JOIN (\n SELECT\n uri,\n max(updatedAt) AS lastUpdatedAt\n FROM\n Progress\n GROUP BY\n 1\n ) AS p2 ON p1.uri = p2.uri\n AND p1.updatedAt = p2.lastUpdatedAt\n LEFT JOIN (\n SELECT\n uri,\n max(completedAt) AS lastCompletedAt\n FROM\n Progress\n WHERE\n CAST(completedAt AS int) > 0\n GROUP BY\n 1\n ) AS p3 ON p1.uri = p3.uri\nGROUP BY\n p1.uri");function E(){const e=o.Settings.progressStaleDays.valueOrDefault;return e<=0?0:Date.now()-e*u.dayMs}t.defaultMinCreatedAt=E;class D extends P.TimestampedModel{static vacuum(e=o.Settings.progressRetentionDays.valueOrDefault*u.dayMs){const t=Date.now()-e,i=this.dbl.pluckAllf((e=>e.select("id").where("createdAt","<=",t)));for(const e of(0,n.batches)(i,o.Settings.dbBatchSelectSize.valueOrDefault))S.ProgressMeta.dbl.runf((t=>t.whereIn("progressId",e).delete())),D.dbl.runf((t=>t.whereIn("id",e).delete()))}static countCompletedDirectorySyncs(){return this.dbl.pluckFirstf((e=>e.where({state:"done"}).whereNotNull("completedAt").where("uri","like","ps%")))}static times(){return M().tap({msg:"times()",result:this.dbl.all({sql:T})})}static insertNew(e){const t=(0,h.map)(e.dek,d.stringify);return this.ops().insertOne({...(0,m.omit)(e,"dek"),dekJSON:t})}upsert(e){return null!=e&&this.assignFromPojo(e),super.upsert()}$beforeUpsert(){super.$beforeUpsert(),null==this.id&&(this.pid??(this.pid=s.pid),this.hostname??(this.hostname=(0,r.hostname)())),"done"===this.state&&(this.completedAt??(this.completedAt=Date.now())),this.completePct=_(this.completePct),this.incompletePct=_(this.incompletePct),this.scanningPct=_(this.scanningPct)}$afterUpsert(){super.$afterUpsert(),(0,v.tellWebProgressUpdated)()}toSyncState(){return{id:this.id,uri:this.uri,volume:this.volume,state:this.state,hed:this.hed,dek:this.dek,completePct:this.completePct,incompletePct:this.incompletePct,scanningPct:this.scanningPct}}get dek(){return(0,l.compactBlanks)((0,p.parseJSON)(this.dekJSON))}set dek(e){var t;this.dekJSON=(t=e,(0,d.stringify)((0,l.compactBlanks)((0,y.toA)(t))))}assignFromPojo(e){return(0,b.assignFromJSON)(this,(0,m.omit)(e,"volume","uri"))}getMeta(){return S.ProgressMeta.ops().allf((e=>e.where({progressId:this.id}).orderBy("createdAt")))}getPriorIncomplete(e=E()){return this.logger().tap({msg:"priorIncompleteProgress()",result:D.ops().firstf((t=>t.where({hostname:this.hostname,uri:this.uri,completedAt:null}).andWhere("createdAt",">",e).orderBy("updatedAt","desc")))})}getLastCompletedAt(e=E()){return D.dbl.pluckFirstf((t=>t.max("completedAt").where({uri:this.uri}).andWhere("createdAt",">",e)))}getLastIncompleteStartAt(){return D.dbl.pluckFirstf((e=>e.min("createdAt").where({uri:this.uri}).andWhere("createdAt",">",this.getLastCompletedAt()??0)))}setMeta(e,t){return this.logger().debug("setMeta()",{progressId:this.id,name:e,value:t}),S.ProgressMeta.ops().upsertOne({progressId:this.id,name:e,value:t})}setMetaRecord(e){const t=this.getMeta(),i=(0,l.diff)(t.map((e=>e.name)),Object.keys(e));this.logger().debug("setMetaRecord()",{progressId:this.id,keysToDelete:i,record:e}),S.ProgressMeta.ops().upsert((0,m.entries)(e).map((([e,t])=>({progressId:this.id,name:e,value:(0,w.toS)(t)})))),(0,l.isNotEmpty)(i)&&S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).whereIn("name",i).delete()))}deleteMeta(...e){return this.logger().debug("deleteMeta()",{progressId:this.id,names:e}),S.ProgressMeta.dbl.runf((t=>t.whereIn("name",e).andWhere({progressId:this.id}).delete()))}deleteAllMeta(){return this.logger().debug("deleteAllMeta()",{progressId:this.id}),S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).delete()))}getMetaAsRecord(){return this.logger().tap({msg:"getMetaAsRecord()",result:(0,m.fromEntries)(this.getMeta().map((e=>[e.name,e.value])))??{}})}}t.Progress=D,D.$tableName="Progress",D.$uniqueColumnName="id"},55009:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressMeta=t.ProgressMetaNames=t.DirSyncProgressMetaNames=void 0;const r=i(50989),s=i(72761);t.DirSyncProgressMetaNames=(0,r.strEnum)("lastScannedDirectory","scannedDirectoryCount","completedDirectoryScan","enqueuedStaleFiles","processedImageCount","processedVideoCount","completedDirectorySync"),t.ProgressMetaNames=(0,r.strEnum)(...t.DirSyncProgressMetaNames.values);class n extends s.TimestampedModel{}t.ProgressMeta=n,n.$tableName="ProgressMeta",n.$uniqueColumnName="progressId,name"},39604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.upsertToShaBlockslist=t.upsertFileToShaBlockslist=t.isShaBlockslisted=t.notBlocklistedSha=void 0;const r=i(19851),s=i(50213),n=i(95696),a=i(40958),o=i(22573),l=i(86859),u=i(94448),c=(0,r.lazy)((()=>(0,s.mkLogger)("model.ShaBlocklist"))),d=(0,r.lazy)((()=>new l.DbRequest(u.modelDb,"ShaBlocklist")));function h(e){return null!=(0,u.modelDb)()&&!(0,o.blank)(e)&&c().tap({msg:"isShaBlockslisted",result:null!=d().pluckFirstf((t=>t.where({sha:e}).limit(1))),meta:{sha:e}})}function f(...e){if(null==u.modelDb.prior())return;const t=(0,a.uniq)(e).map((e=>({sha:e})));return(0,a.isEmpty)(t)?void 0:d().upsert((e=>e.insert(t)))}t.notBlocklistedSha=async function(e){if(null==(0,u.modelDb)())return null;const t=h(await n.PosixFile.for(e).sha());return null==t?null:!t},t.isShaBlockslisted=h,t.upsertFileToShaBlockslist=async function(e){if(null==(0,u.modelDb)())return;const t=await n.PosixFile.for(e).sha();return null==t?void 0:f(t)},t.upsertToShaBlockslist=f},48723:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Tag=t.UpdateTagAssetCountTimeName=void 0;const a=i(56038),o=i(34102),l=i(19851),u=i(50213),c=i(36372),d=i(97352),h=i(28874),f=i(81168),m=i(42231),p=i(75020),g=i(40958),y=i(22573),w=i(42659),v=i(41400),b=i(50357),S=i(55835),P=i(31586),M=i(34666),_=i(20214),T=i(51926),E=i(59455),D=i(12168),k=i(6186),x=i(57038),F=i(21074),C=i(7656),A=i(43487),I=i(48722),O=i(45295),L=i(98784),R=i(41507),N=i(72761),B=4*w.secondMs,j=(0,l.lazy)((()=>(0,u.mkLogger)("model.Tag")));(0,v.later)((()=>{(0,o.ee)().on("clearCache",(()=>z.clear())),(0,o.ee)().on("clearDbCache",(()=>z.clear()))})),t.UpdateTagAssetCountTimeName="db.updateTagAssetCountTimeName";class z extends N.TimestampedModel{constructor(){super(...arguments),this.displayPath=(0,l.lazy)((()=>{const e=this.getParent();return(0,g.compactBlanks)([...null==e?[]:e.displayPath(),this.displayName])})),this.ancestorIds=(0,l.lazy)((()=>0===this.parentId||null==this.parentId?[]:r.dbl.pluckAll({sql:(0,T.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.id","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}}))),this.firstNonInterstitialTagId=(0,l.lazy)((()=>{if(!this.isRoot&&0===this.directAssetCount()&&1===this.getChildrenCount()){const e=this.getChildren();if(1===e?.length)return e[0].firstNonInterstitialTagId()}return this.id})),this.directAssetCount=(0,l.lazy)((()=>0===this.id?0:A.Asset.dbl.pluckFirst(A.Asset.shownUnhidden().join("AssetTag","AssetTag.assetId","Asset.id").where("AssetTag.tagId",this.id).countDistinct("Asset.id"))))}static orderBy(e){return e.orderByRaw("COALESCE(ordinal, _path) COLLATE NOCASE")}static clear(){this.root.unset(),this.roots.unset(),this._upsertDefaultRoots.unset(),this.ops().clearDbCache()}static validate_(){return(0,a.timeSync)("Tag.validate_",(()=>{r.clear();for(const e of this.ops().allf((e=>e.whereRaw("id = parentId")))){j().warn(`Tag ${e.id} has itself as parentId. Attempting to fix...`);const t=e.path.slice(0,-1),i=(0,g.isEmpty)(t)?void 0:this.findOrCreate(t);e.update({parentId:i?.id??null})}for(const e of r.roots())e.validate_([])}))}validate_(e){const t=this.path;if(!(0,b.eql)(t.slice(0,-1),e))throw new Error(`Tag:${this.id} path ${t.join("/")} does not match expected parent ${e.join("/")}`);for(const e of this.getChildren())e.validate_(t)}static deltaAssetCountAndAncestors(e,t=1){return r.incrAssetCount(r.selfAndAncestorIds(e),t)}static incrAssetCount(e,t=1){(0,g.isEmpty)(e)||r.dbl.runf((i=>i.whereIn("id",e).andWhereNot({assetCount:null}).update({assetCount:(0,x.knex)().raw("assetCount + "+Math.round(t)),updatedAt:Date.now()})))}static selfAndAncestorIds(e){const t=(0,E.toA)(e).filter(P.gt0);return r.dbl.pluckAll({sql:(0,T.compressWhitespace)("WITH RECURSIVE ancestors(id) AS ("," SELECT id FROM Tag where id in "+(0,F.sqlWhereInClause)(t.length)," UNION ALL"," SELECT Tag.parentId as id"," FROM Tag, ancestors"," WHERE Tag.id = ancestors.id",")","SELECT distinct(id)","FROM ancestors","WHERE id IS NOT NULL"),bindings:t})}static updateAssetCount(e){if((0,P.gt0)(e))return(0,a.timeSync)(t.UpdateTagAssetCountTimeName,(()=>{const t=r.dbl.pluckFirst({sql:C.RecursiveAssetCountForTagQuery,bindings:{tagId:e}});r.dbl.runf((i=>i.update({assetCount:t,updatedAt:Date.now()}).where({id:e}))),j().debug("Updated asset counts for tag ",{tagId:e,assetCount:t})}))}static findByIdOrPath(e,t){return 0===e?r.root():(0,P.gt0)(e)?this.findById(e):this.findByPath(t)}static findById(e){return 0===e?r.root():this.ops().findById(e)}static findByPath(e){if((0,g.isEmpty)(e))return r.root();const t=(0,m.joinTagPath)(e);return this.ops().firstf((e=>e.whereLike("_path",t)))}static findByPathN(e){const t=(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,y.toNotBlank)((0,m.joinTagPath)(e))));return(0,g.compact)(t.map((e=>this.findByPath(e))))}static getPagedAssets(e,t){const i=new r;return i.id=e,i.getPagedAssetIds(t)}static findOrCreate(e){if((0,g.isEmpty)(e))throw new Error("empty tagPath");const t=this.findByPath(e);if(null!=t)return t;const i=n(this,r,"m",s).call(this,e),a=i.depth<=1?void 0:this.findOrCreate(e.slice(0,-1));return(0,S.map)(a,(e=>i.parentId=e.id)),this.ops().upsertOne(i)}static findOrCreateByPathN(e){return(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,m.joinTagPath)(e))).map((e=>this.findOrCreate(e)))}clear(){return this.parent=void 0,this.root=void 0,this.children=void 0,this.ancestors=void 0,this.assets=void 0,this.relatedAssets=void 0,this.ancestorIds.unset(),this}$afterInsert(){L.TagFts.insertFts([this])}siblingPath(e){return(0,m.joinTagPath)([...this.parentPath,e])}changeName(e){return this.changePath(this.siblingPath(e))}maybeUpsertDisplayName(e){return(0,y.blank)(e)||e===this._displayName?void 0:this.upsert({_displayName:e})}changePath(e,t=!0){const i=this._path,s=r.findByPath((0,m.splitTagPath)(e));this.logger().info("changePath(): ",{priorPath:i,newPath:e,existingSibling:s});try{if(null==s)r.dbl.runf((t=>t.whereLike("_path",i+"%").update({updatedAt:Date.now(),_path:(0,x.knex)().raw("REPLACE(_path, ?, ?)",[i,e])}))),this._path=e;else{e=s._path,this.logger().info("changePath(): replacing with sibling",e),O.AssetTag.dbl.upsert((e=>e.where({tagId:this.id}).update({tagId:s.id}))),O.AssetTag.dbl.runf((e=>e.where({tagId:this.id}).delete()));for(const e of this.getChildren())e.changePath((0,m.joinTagPath)([...s.path,e.name]),!1);r.dbl.runf((e=>e.where({parentId:this.id}).update({parentId:s.id}))),this.delete()}}finally{t&&r.clear()}}get name(){const e=this.path;return e[e.length-1]}get path(){return(0,m.splitTagPath)(this._path)}get displayName(){return(0,y.toNotBlank)(this._displayName)??this.name}get isRoot(){return 0===this.id}get depth(){return this.path.length}get parentPath(){return this.path.slice(0,-1)}get sortBy(){return[this.depth,null==this.ordinal?2**51:this.ordinal,this.path.map((e=>e.toLowerCase()))]}$childrenQuery(){return r.orderBy(r.query().where({parentId:this.id}))}$assetsQuery(){return A.Asset.shownUnhidden().columns("Asset.*").join("AssetTag","AssetTag.assetId","Asset.id").where({tagId:this.id})}$selectAssetIdColumns(e){return e.clearSelect().select({assetId:"Asset.id",capturedAtLocal:"Asset.capturedAtLocal",updateCount:"Asset.updateCount",durationMs:"Asset.durationMs"})}$assetIdsQuery(){return this.$selectAssetIdColumns(this.$assetsQuery())}setAncestors(e){this.ancestors=e,this.parent=e[e.length-1],(0,S.map)(this.parent,(t=>t.setAncestors(e.slice(0,-1))))}async toApiPathElements(){return(0,_.thenCollect)(this.getAncestorsAndSelf(),(e=>e.toPathTag()))}toPathTag(){return{tagPath:this.path,displayName:this.displayName}}toApiTag(){return{tagId:this.id,tagPath:this.path,displayPath:this.displayPath(),description:this.description,assetCount:this.assetCount}}toStringId(){return"Tag("+this.path.join("/")+")"}getParent(){if(!this.isRoot)return null!=this.parentId&&null==this.parent?this.parent=r.findById(this.parentId):this.parent}getPagedChildren(e){if(0===this.id){const t=e.offset??0,i=t+(e.limit??this.children.length);return[...this.children].slice(t,i)}const t=this.$childrenQuery();return(0,d.mapGt0)(e.offset,(e=>{t.offset(e)})),(0,d.mapGt0)(e.limit,(e=>{t.limit(e)})),r.ops().all(t)}getChildrenCount(){return null!=this.children?this.children.length:r.dbl.pluckFirstf((e=>(this.isRoot?e.whereNull("parentId"):e.where({parentId:this.id})).count()))}getChildren(){return this.isRoot||(this.children=r.ops().all(this.$childrenQuery()),this.children.forEach((e=>{e.parent=this}))),this.children}link(){return"/tag/"+this.path.map(encodeURIComponent).join("/")}get rootName(){return this.path[0]}get ancestorsAndSelf(){return[...this.ancestors,this]}getAncestors(){return this.ancestors??(this.ancestors=this._getAncestors())}getAncestorsAndSelf(){return[...this.getAncestors(),this]}_getAncestors(){return 0===this.parentId||null==this.parentId?[]:r.ops().all({sql:(0,T.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.*","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}})}getPagedAssetIds(e){let t=this.$assetIdsQuery();return t=t.limit(p.ThumbsPerSample),(0,P.gt0)(e.offset)&&(t=t.offset(e.offset)),t=t.orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId"}]),(0,g.compact)(A.Asset.dbl.all(t).map(I.toAssetId))}getAssets(){const e=this.$assetsQuery().orderBy("capturedAtLocal","desc");return A.Asset.ops().all(e)}async assetCountDesc(e){const t=this.assetCount;return(null==t||null==e||e.length===t||0===e.length?"":(0,D.fmt)(e.length)+" of ")+(0,D.plur)(t,"asset")}getAssetCount(){return 0===this.id?r.dbl.pluckFirst({sql:(0,T.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," Asset","WHERE"," Asset.shown = 1"," AND Asset.excluded = 0"," AND Asset.hidden = 0"," AND Asset.deletedAt IS NULL")}):r.dbl.pluckFirst({sql:C.RecursiveAssetCountForTagQuery,bindings:{tagId:this.id}})}$assetStreamQuery(e,t,i){let r=this.path[0]===p.TagRoots.When?A.Asset.shownUnhidden():this.$assetsQuery();return r=r.distinct().where("capturedAtLocal",i,e.capturedAtLocal).andWhereNot("Asset.id",e.id).limit("="===i?2*t:t),"="===i?r.orderByRaw(`ABS(Asset.id-${e.id})`):r.orderBy([{column:"capturedAtLocal",order:">"===i?"asc":"desc"},"Asset.id"])}getAssetStream(e,t){t=(0,P.gt0)(t)?t:p.BeforeAfterStreamLimit;const[i,r,s]=["<","=",">"].map((i=>(0,g.compact)(A.Asset.ops().all(this.$assetStreamQuery(e,t,i)).map(I.toAssetId))));for(const t of r)t.assetIdA.Asset.shownUnhidden(this.$selectAssetIdColumns(r)).distinct().join("Asset","Asset.id","AssetTag.assetId").join("Tag","Tag.id","AssetTag.tagId").whereLike("_path",this._path+"%").orderByRaw((0,c.prngOrderByClause)(e+(this.id??0),"Asset.id",i)).limit(t))).map(I.toAssetId));return this.logger().debug(this.path+": Found "+r.length+" related assets"),r}get attrs(){return{href:this.link(),title:this.name}}}t.Tag=z,r=z,s=function(e){const t=new r;t._path=(0,m.joinTagPath)(e);const i=e[e.length-1];return"object"==typeof i&&((0,y.mapNotBlank)(i.displayName,(e=>t._displayName=e)),(0,P.mapNumeric)(i.ordinal,(e=>t.ordinal=e)),(0,y.mapNotBlank)(i.description,(e=>t.description=e)),(0,P.mapNumeric)(i.releasedAt,(e=>t.releasedAt=e))),t},z.$tableName="Tag",z.$uniqueColumnName="_path",z.$useCache=!0,z.cmp=(e,t)=>(0,M.cmp)([e.ordinal??Number.MAX_SAFE_INTEGER,...e.path],[t.ordinal??Number.MAX_SAFE_INTEGER,...t.path]),z.root=(0,l.lazy)((()=>{const e=new r;return e.id=0,e._path=m.TagSep,e.parentId=void 0,e.children=r.roots().filter((e=>!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.name)&&!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.description??""))),e.ancestors=[],e.assetCount=A.Asset.shownCount(),e.upsert=()=>{throw new Error("upsert not supported on root")},e}),B),z._upsertDefaultRoots=(0,l.lazy)((()=>r.ops().upsert(k.Roots.map((e=>({_path:(0,m.joinTagPath)([e.name]),ordinal:e.ordinal})))))),z.roots=(0,l.lazy)((()=>{r._upsertDefaultRoots();const e=r.ops().all(r.orderBy(r.query().whereNull("parentId")));for(const t of e)t.parentId=void 0,t.ancestors=[];return e}),B);const V=(0,l.lazy)((()=>A.Asset.dbl.pluckFirstf((e=>e.count()))),w.minuteMs)},98784:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagFts=void 0;const r=i(38156),s=i(3127),n=i(40958),a=i(41400),o=i(94715),l=i(55046),u=i(48723);class c extends l.Model{static insertFts(e){try{const t=e.filter((e=>null!=e.parentId)).map((e=>({rowid:e.id,root:(0,s.tag_fts_root)(e._path),path:(0,s.tag_fts_path)(e._path)})));(0,n.isEmpty)(t)||this.dbl.runf((e=>e.insert(t)))}catch(e){this.$logger().warn("Failed to update tag_fts",{error:e})}}static async rebuild(){const e=new r.PushProgressObserver({op:"Rebuilding tag search index"},u.Tag.dbl.pluckFirstf((e=>e.count("*")))),t=this.dbl.db();o.Migrations.create_tag_fts(t.db),await u.Tag.ops().batched({qb:e=>e,onResults:t=>(this.$logger().throwIfAborted_(),this.insertFts(t),e.incrProgress(t.length),(0,a.delay)(1))}),e.completed()}}t.TagFts=c,c.$tableName="tag_fts",c.$uniqueColumnName="rowid",c.$booleanFields=[]},41507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.coalesceStreams=t.TaggedAssetStream=t.cmpAssetDesc=t.cmpAssetAsc=void 0;const r=i(48884),s=i(50213),n=i(28874),a=i(40958),o=i(76790),l=i(31586),u=i(34666),c=i(20214),d=i(59455);t.cmpAssetAsc=(e,t)=>(0,u.cmp)([e.capturedAtLocal,e.id],[t.capturedAtLocal,t.id]),t.cmpAssetDesc=(e,t)=>(0,u.cmp)([t.capturedAtLocal,t.id],[e.capturedAtLocal,e.id]),t.TaggedAssetStream=class{constructor(e,t,i,r){this.tags=e,this.before=t,this.after=i,this.limit=r,this.logger=()=>(0,s.mkLogger)("model.TaggedAssetStream("+this.toString()+")"),this.logger().info("new",this.toJSON())}vacuum(){(0,o.sortByInPlace)(this.before,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainFirstN)(this.before,this.limit),(0,o.sortByInPlace)(this.after,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainLastN)(this.after,this.limit)}toString(){return this.tags.map((e=>e.path.join("/"))).join(",")}valueOf(){return this.toString()}get length(){return(0,d.toA)(this.before).length+(0,d.toA)(this.after).length}leftPad(e){return[...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+1),capturedAtLocal:-1,v:0}))),...e]}rightPad(e){return[...e,...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+this.limit+1),capturedAtLocal:-1,v:0})))]}toJSON(){return{tags:this.tags.map((e=>e.toString())),assetIdsAfter:this.after,assetIdsBefore:this.before}}mergeWith(e){(0,a.pushUniqBy)(this.tags,e.tags,(e=>e.path)),(0,a.pushUniqBy)(this.before,e.before,(e=>e.assetId)),(0,a.pushUniqBy)(this.after,e.after,(e=>e.assetId)),this.logger().debug("mergeWith() complete",{tas:e.toJSON(),tags:this.tags.map((e=>e.path)),beforeIds:this.before,afterIds:this.after})}async toApi(){return this.vacuum(),this.logger().tap({msg:"toApi()",result:{tags:await(0,c.thenCollect)(this.tags,(e=>e.toApiTag())),assetIdsAfter:this.leftPad(this.after),assetIdsBefore:this.rightPad(this.before)}})}streamCoeff(e){return this.logger().tap({msg:"streamCoeff",meta:{this:this.tags.map((e=>e.path)),tas:e.tags.map((e=>e.path))},result:(0,r.diceCoeff)([...this.before,...this.after],[...e.before,...e.after],(e=>e.assetId))})}},t.coalesceStreams=function(e){const t=n.Settings.minStreamCorrPct.valueOrDefault/100,i=[],s=e.filter((e=>e.length>5));for(const e of s){const s=(0,r.greatestBy)(i,(i=>(0,l.gtOrElse)(i.streamCoeff(e),t)));null==s?i.push(e):s.mergeWith(e)}return i}},94710:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Task=t.StaleTaskError=t.InvalidTaskError=t.TaskNames=t.Tasks=t.testTask=void 0;const c=i(78474),d=i(22454),h=i(23560),f=i(12089),m=i(76740),p=i(22911),g=i(99331),y=i(31562),w=i(38835),v=i(70025),b=i(8769),S=i(74128),P=i(28874),M=i(37692),_=i(40958),T=i(22573),E=i(42659),D=i(45599),k=i(98553),x=i(49769),F=i(68708),C=i(50989),A=i(59455),I=i(58723),O=i(34274),L=i(90901),R=i(61989),N=i(93755),B=i(69032),j=i(55046);t.testTask=(0,f.shim1)({name:"testTask",impl:async e=>{}}),t.Tasks={applyDeleted:I.applyDeleted,applyExcluded:I.applyExcluded,runTagMaintenance:B.runTagMaintenance,repairAsset:async function(e){e.forceSync=!0,e.skipPreviews=!0,e.skipAssetTagging=!0;const t=await(0,R.updateAsset_)(e);return(0,_.isNotEmpty)(t?.assetIdsToUpdate)&&q.add(t?.assetIdsToUpdate.map((t=>({fn:"repairAsset",args:{...e,assetId:t},priority:W.repairAsset+1})))),null!=t&&!0!==t.deleted&&(0,T.blank)((0,A.toA)(t.rejected).join(""))&&(0,T.blank)(t.error)&&q.addOne("assetPostUpsertTasks",(0,F.omit)(e,"skipPreviews","skipAssetTagging")),t},assetPostUpsertTasks:L.assetPostUpsertTasks,updateAssetFile:N.updateAssetFile_,syncFile:O.importFileToResult_,testTask:t.testTask},t.TaskNames=(0,C.strEnum)(...(0,F.keys)(t.Tasks));class z extends Error{}t.InvalidTaskError=z;class V extends Error{}t.StaleTaskError=V;const W={applyDeleted:16,applyExcluded:16,runTagMaintenance:14,repairAsset:12,assetPostUpsertTasks:10,updateAssetFile:8,syncFile:0,testTask:-1},U=["repairAsset"];class q extends j.Model{constructor(){super(...arguments),r.add(this),o.set(this,(0,D.defer)((()=>new m.Abortable)))}static countTaskNames(){const e={};for(const t of s.dbl.allf((e=>e.select("fn").count().groupBy("fn"))))e[t.fn]=t["count(*)"];return e}static orderBy(e){return e.orderBy([{column:"priority",order:"desc"},{column:"retries",order:"desc"},{column:"id",order:"asc"}])}static count(){return s.dbl.pluckFirstf((e=>e.count("id")))}static freeSlots(){return P.Settings.taskListCap.valueOrDefault-s.count()}static countByFn(e){return s.dbl.pluckFirstf((t=>t.where({fn:e}).count("id")))}static nextByFn(e,t=(e=>e)){return s.ops().allf((i=>s.orderBy(t(i.where({fn:e})))))}set args(e){this.argsJSON=(0,k.stringify)(e)}get args(){const e=(0,k.parseJSON)(this.argsJSON);return(0,F.notEmptyObj)(e)&&(e.halt=u(this,o,"f").call(this)),e}get isSerial(){return U.includes(this.fn)}toString(){return`Task#${this.fn}(${this.argsJSON})`}static addOne(e,t){return s.add([{fn:e,args:t}])[0]}static add(e,t=!1){if((0,_.isEmpty)(e))return[];const i=s.ops().upsert(e.map((e=>({fn:e.fn,argsJSON:(0,k.stringify)(e.args)})),t));return s.ee.emit("added",i),(0,h.isTaskListManager)()||(0,M.addStateEvent)("checkTasks"),i}$beforeUpsert(){this.priority??(this.priority=W[this.fn]),this.retries??(this.retries=P.Settings.maxRetries.valueOrDefault)}donePromise(){return(0,h.isTaskListManager)()?(0,x.getOrSet)(u(s,s,"f",n),this.id,(()=>new p.Deferred(this.toString(),{payload:this}))):(0,y.untilTrue)((()=>null==s.ops().findById(this.id)),{intervalMs:E.secondMs})}abort(e){this.logger().warn("aborting task",{reason:e,task:this}),u(this,o,"f").call(this).abort(e),this.delete(),(0,T.blank)(this.args.path)||(0,S.syncReport)().onProgress({path:this.args.path,from:this.fn,state:S.SyncFileStates.failed,details:e})}async _run(){if(this.retries<0)throw this.logger().warn(".run(): too many retries"+w.InternalErrorFlag,{job:this}),this.delete(),new z;if(!u(this,r,"m",l).call(this))throw this.logger().warn(".run(): someone already started this task",{job:this}),new V;try{const e=Date.now(),i=await t.Tasks[this.fn](this.args);return this.logger().throwIfAborted_(u(this,o,"f").prior()),s.taskResolvedCounts.incr(this.fn),s.ee.emit("resolved",this,i,Date.now()-e),this.delete(),u(s,s,"f",n).get(this.id)?.resolve(i),i}catch(e){if((0,g.ending)())throw this.logger().info("task failed, but we're ending. We'll leave it for next time.",{task:this}),e;throw s.taskRejectedCounts.incr(this.fn),(0,v.isRedoableError)(e)?(this.retries++,this.priority--,this.upsert()):!0===(0,v.isRetriableError)(e)&&this.retries>=0?this.logger().warn("run failed, but we can retry it later",{task:this,error:e}):(s.ee.emit("rejected",this,e),this.delete(),u(s,s,"f",n).get(this.id)?.reject(e),(0,b.onError)(this.toString()+" failed",e)),e}finally{u(s,s,"m",a).call(s)}}}t.Task=q,s=q,o=new WeakMap,r=new WeakSet,a=function(){for(const[e,t]of u(this,s,"f",n).entries())t.isSettled&&u(this,s,"f",n).delete(e)},l=function(){const e=this.retries;if(1===s.dbl.runf((t=>t.where({id:this.id,retries:e}).update({retries:e-1}))).changes)return--this.retries,!0;{const e=this.toJSON(),t=this.reload();return this.logger().warn(".#decrRetries(): someone already started this task",{before:e,reloaded:t}),!1}},q.$tableName="Task",q.$uniqueColumnName="fn,argsJSON",q.$useCache=!1,q.taskResolvedCounts=new d.CountingSet,q.taskRejectedCounts=new d.CountingSet,q.ee=new c.EventEmitter,n={value:new Map}},72761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimestampedModel=void 0;const r=i(97352),s=i(40958),n=i(31586),a=i(59455),o=i(55046);class l extends o.Model{static touch(e,t={}){t.updatedAt??(t.updatedAt=Date.now()),delete t.id;const i=(0,a.toA)(e).filter(n.gt0);return(0,s.isEmpty)(i)?void 0:this.dbl.runf((e=>e.whereIn("id",i).update(t)))}get createdAtDate(){return(0,r.mapGt0)(this.createdAt,(e=>new Date(e)))}get updatedAtDate(){return(0,r.mapGt0)(this.updatedAt,(e=>new Date(e)))}touch(e={}){e.updatedAt??(e.updatedAt=Date.now());const t=this.id;null==t?this.upsert():this.class().dbl.runf((i=>i.where({id:t}).update(e)))}$beforeUpsert(){if(super.$beforeUpsert(),this.createdAt??(this.createdAt=Date.now()),this.updatedAt=Date.now(),"updateCount"in this){const e=this,t=e.updateCount;e.updateCount=((0,n.toGt0)(e.updateCount)??0)+1,this.logger().debug("$beforeUpsert(): incr updateCount",{prior:t,now:e.updateCount})}}}t.TimestampedModel=l},58723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyExcluded=t.applyDeleted=void 0;const r=i(50213),s=i(43487),n=(0,r.mkLogger)("ops.ApplyRemovable");async function a(e,t,i){const r=e?"Deleting":"Excluding",a=e?"deletedAt":"excludedAt";await s.Asset.dbl.batched({qb:e=>e.select("id").where("shown",0).andWhere(a,"<=",t),onResults:async t=>{for(const a of t){n.throwIfAborted_(i);try{await s.Asset.remove({assetId:a,blocklistShas:!0,unlinkAssetFiles:e})}catch(e){n.error(r+" failed",{assetId:a,error:e})}}}})}t.applyDeleted=function(e){return a(!0,e.createdAt,e.halt)},t.applyExcluded=function(e){return a(!1,e.createdAt,e.halt)}},76386:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiProgressPatchPath=t.tellWebProgressUpdated=t.ProgressRateMs=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(24540),o=i(28874),l=i(34238),u=i(4988),c=i(15674),d=i(42659),h=(0,i(45599).defer)((()=>(0,s.mkLogger)("progress.Progress")));t.ProgressRateMs=(0,r.lazy)((()=>d.secondMs*((0,a.isRaspberryPi)()||(0,c.maxCpus)()<=3?5:1.5))),t.tellWebProgressUpdated=(0,r.lazy)((async()=>{if((0,n.isWebService)())return;const e=l.URI.from({scheme:"http",authority:"127.0.0.1:"+o.Settings.httpPort.valueOrDefault,path:t.ApiProgressPatchPath}).toString();await(0,u.httpRequest_)({url:e,method:"PATCH"}).catch((e=>h().warn(".tellWebProgressUpdated: failed",{error:e})))}),(0,t.ProgressRateMs)()),t.ApiProgressPatchPath="/api/progress"},22968:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeRebuildLibrary=t.forceRebuildLibraryLater=t.rebuildLibraryOperationCrit=void 0;const r=i(45393),s=i(28874),n=i(98553),a=i(43487),o=i(54017),l=i(20958),u=i(33567);function c(){return{name:l.OperationNames.rebuildLibrary,value:(0,n.stringify)({AssetVersion:r.AssetVersion,AssetFileVersion:r.AssetFileVersion})}}t.rebuildLibraryOperationCrit=c,t.forceRebuildLibraryLater=function(){a.Asset.dbl.runf((e=>e.update({version:0}))),o.AssetFile.dbl.runf((e=>e.update({version:0}))),l.Operation.dbl.runf((e=>e.where(c()).delete()))},t.maybeRebuildLibrary=async function(){return s.Settings.skipLibraryRebuild.valueOrDefault?void 0:l.Operation.applyOnce_(c(),(()=>(new u.LibraryRebuild).doneLatch))}},33567:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LibraryRebuild=void 0;const c=i(19851),d=i(83412),h=i(25764),f=i(8769),m=i(76752),p=i(28874),g=i(15674),y=i(22573),w=i(42659),v=i(31586),b=i(12168),S=i(12236),P=i(35580),M=i(49796),_=i(94710),T=i(18209);class E extends d.DoneWrapper{constructor(){super("LibraryRebuild",(()=>u(this,r,"m",a).call(this)),h.EndableRanks.first),r.add(this),this.assetFileEta=new m.ETA,this.assetEta=new m.ETA,this.assetFilesUpdated=0,this.assetsUpdated=0,this.initialAssetFileTodoCount=(0,c.lazy)(T.outdatedAssetFileCount),this.initialAssetTodoCount=(0,c.lazy)(T.outdatedAssetCount),s.set(this,(0,c.lazy)((()=>M.Progress.insertNew({uri:S.RebuildingURI,volume:"🔄",scanningPct:0})))),o.set(this,((e,t,i)=>{"updateAssetFile"===e.fn?(this.assetFilesUpdated++,this.assetFileEta.push(i),u(this,r,"m",n).call(this)):"updateAsset"===e.fn&&(this.assetsUpdated++,this.assetEta.push(i),u(this,r,"m",n).call(this))})),_.Task.ee.on("resolved",u(this,o,"f")),this.doneLatch.observe(u(this,r,"m",l).call(this))}async assetFileTodo(){return await this.initialAssetFileTodoCount()-this.assetFilesUpdated}async assetTodo(){return await this.initialAssetTodoCount()-this.assetsUpdated}}t.LibraryRebuild=E,s=new WeakMap,o=new WeakMap,r=new WeakSet,n=async function({force:e=!1,done:t=!1}={}){const i=u(this,s,"f").call(this);if(e||!(0,v.gt)(i.updatedAt,Date.now()-w.secondMs))if((t??this.isDone())&&"done"!==i.state){const e=[];this.assetFilesUpdated>0&&e.push(`Updated file metadata for ${(0,b.fmt)(this.assetFilesUpdated)} files`),this.assetsUpdated>0&&e.push(`Refreshed ${(0,b.fmt)(this.assetsUpdated)} assets`),i.dek=e,i.upsert({state:"done",hed:"Finished rebuilding your library 🎉",completePct:100,incompletePct:0,scanningPct:0})}else{let e="Rebuilding your library";const t=await this.assetFileTodo(),r=await this.assetTodo(),s=(this.assetFileEta.etaMs(t/(0,g.maxConcurrentImports)())??0)+(this.assetEta.etaMs(r)??0),n=[];t>0&&n.push(`Updating file metadata (${(0,b.fmt)(this.assetFilesUpdated)} processed, ${(0,b.fmt)(t)} remain)`),r>0&&n.push(`Refreshing assets and previews (${(0,b.fmt)(this.assetsUpdated)} processed, ${(0,b.fmt)(r)} remain)`);const a=t+r,o=this.assetFilesUpdated+this.assetsUpdated,l=(0,v.clamp)(0,100,Math.round(o/(a+o)*100)),u=(0,m.fmtEstimate)(s);(0,y.notBlank)(u)&&(e+=", "+u+"…"),i.dek=n,i.upsert({state:"processing",hed:e,completePct:l,incompletePct:100-l,scanningPct:0})}},a=function(){_.Task.ee.off("resolved",u(this,o,"f"))},l=async function(){this.logger.info("Starting library rebuild...");const e=p.Settings.forceFilters.getState();try{p.Settings.forceFilters.envValue=!0;const e=P.TaskList.instance(),t=await this.assetFileTodo(),i=await this.assetTodo();if(this.logger.info(".run()",{assetFileTodo:t,assetTodo:i}),0===t&&0===i)return;let s=!1;for(;!s;)s=(await(0,T.enqueueAssetFileUpdates)()).done,this.logger.info("run(): waiting for asset updates to complete..."),await e.awaitDrain(["updateAssetFile"],s?0:p.Settings.taskListCap.valueOrDefault/2);for(s=!1;!s;)s=(await(0,T.enqueueAssetUpdates)()).done,await e.awaitDrain(["repairAsset","assetPostUpsertTasks"],s?0:p.Settings.taskListCap.valueOrDefault/2);await u(this,r,"m",n).call(this,{done:!0,force:!0}),this.logger.info("rebuild complete!")}catch(e){(0,f.onError)("LibraryUpdater.run() failed",e)}finally{p.Settings.forceFilters.setState(e)}}},18209:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.enqueueAssetUpdates=t.outdatedAssetCount=t.enqueueAssetFileUpdates=t.outdatedAssetFileCount=t.currentUriRoots=void 0;const r=i(50213),s=i(45393),n=i(70417),a=i(45200),o=i(5696),l=i(7014),u=i(40958),c=i(45599),d=i(41400),h=i(20214),f=i(54993),m=i(43487),p=i(54017),g=i(94710),y=(0,c.defer)((()=>(0,r.mkLogger)("sync.UpdateQueue")));async function w(){return[...await(0,h.thenCollect)((0,l.volumes)(),(async e=>(0,a.nativePath2uri)(e.mountpoint,e))),o.PSLIB_ROOT_URI].map(f.toS)}t.currentUriRoots=w,t.outdatedAssetFileCount=async function(){const e=await w();return p.AssetFile.dbl.pluckFirstf((t=>t.count("AssetFile.id").distinct().where("version","!=",s.AssetFileVersion).andWhere((t=>e.forEach((e=>t.orWhereLike("AssetFile.uri",e+"%")))))))},t.enqueueAssetFileUpdates=async function(){const e=[];for(const t of await w())e.push(await p.AssetFile.dbl.batched({maxResults:g.Task.freeSlots(),onResults:async e=>{const t=[];for(const i of e)t.push({fn:"updateAssetFile",args:{assetFileId:i.id,path:await(0,a.uri2nativePath)(i.uri),skipAssetRepair:!0}});g.Task.add(t),y().info("Scheduled updateAssetFile",{tasks:t})},qb:(e,i)=>(e=e.select({id:"AssetFile.id",uri:"AssetFile.uri"}).distinct().orderBy("AssetFile.id","asc").where("AssetFile.version","!=",s.AssetFileVersion).andWhereLike("AssetFile.uri",t+"%"),(0,u.isNotEmpty)(i)&&(e=e.andWhere("AssetFile.id",">",(0,n.max)(i.map((e=>e.id))))),e)}));return y().tap({msg:"enqueueAssetFileUpdates",level:"info",result:{done:e.every((e=>e.done)),tasksAdded:(0,n.sumf)(e,(e=>e.resultCount))}})},t.outdatedAssetCount=async function(){const e=await w();return m.Asset.dbl.pluckFirstf((t=>t.count("Asset.id").distinct().leftJoin("AssetFile","AssetFile.assetId","Asset.id").where("Asset.version","!=",s.AssetVersion).andWhere((t=>e.forEach((e=>t.orWhereLike("AssetFile.uri",e+"%")))))))},t.enqueueAssetUpdates=async function(){const e=[];for(const t of await w())e.push(await m.Asset.dbl.pluckBatched({maxResults:g.Task.freeSlots(),onResults:e=>(g.Task.add(e.map((e=>({fn:"repairAsset",args:{assetId:e}})))),y().info("Scheduled repairAsset for ",{assetIds:e}),(0,d.delay)(1)),qb:(e,i)=>(e=e.select("Asset.id").distinct().leftJoin("AssetFile","AssetFile.assetId","Asset.id").orderBy("Asset.id","asc").where("Asset.version","!=",s.AssetVersion).andWhereLike("AssetFile.uri",t+"%"),(0,u.isNotEmpty)(i)&&(e=e.andWhere("Asset.id",">",(0,n.max)(i))),e)}));return y().tap({msg:"enqueueAssetUpdates",level:"info",result:{done:e.every((e=>e.done)),tasksAdded:(0,n.sumf)(e,(e=>e.resultCount))}})}},3996:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileFinder=t.isFileInSync=void 0;const o=i(19851),l=i(50213),u=i(79781),c=i(56519),d=i(56038),h=i(59189),f=i(38835),m=i(95696),p=i(48368),g=i(181),y=i(69589),w=i(28874),v=i(47783),b=i(87001),S=i(40958),P=i(76790),M=i(22573),_=i(42659),T=i(55835),E=i(31586),D=i(43487),k=i(54017);t.isFileInSync=async function(e){return new F(m.PosixFile.for(e)).alreadySynced()};const x=new h.SerialLaterQueue;class F{constructor(e,t=(0,y.forceContextOrSetting)()){this.file=e,this.ctx=t,r.set(this,void 0),s.set(this,new Set),this.alreadySynced=(0,d.timedLazy)("sync-file.AssetFileFinder.alreadySynced: "+this.file,(async()=>a(this,r,"f").tap({msg:"alreadySynced",result:null!=await this.priorIfSynced()}))),this.newAssetFile_=(0,d.timedLazy)("sync-file.AssetFileFinder.newAssetFile: "+this.file,(async()=>{const e=await(new k.AssetFile).updateFromFile_(this.file);return null==e?a(this,r,"f").throw("AssetFile.updateFromFile returned null",{fatal:!1}):e})),this.tags_=(0,o.lazy)((async()=>{const e=await(0,v.readTags)(this.file);if(null==e)throw new Error(this.file+" doesn't have metadata");return e})),this.imageHash=(0,o.lazy)((()=>w.Settings.useImageHashes.valueOrDefault?(0,p.imageHash)(this.file):void 0)),this.dominantLabhashes=(0,o.lazy)((()=>(0,c.thenMap)(this.imageHash(),(e=>(0,S.uniq)(e.dominantColors.filter((e=>e.pct>5)).map((e=>e.labhash))))))),this.capturedAtLocal=(0,o.lazy)((async()=>{const e=await this.capturedAt_();return a(this,r,"f").tap({msg:"capturedAtLocal",result:e?.local,meta:{capturedAt:e}})})),this.mapSibling=e=>this.newAssetFileForAsset(e?.getAsset()),this.apply_=(0,d.timedLazy)("sync-file.AssetFileFinder: "+this.file,(async()=>{if((0,M.blank)(await this.file.uri_()))throw new Error("Cannot import, file URI is blank for "+this.file);{const e=await this.byExistingAsset_();if(null!=e)return a(this,r,"f").info("Found existing asset for file"),e}const e=await this.newAssetFile_(),t=await x.enqueue((async()=>{const t=await this.byExistingAsset_();if(null!=t?.assetId)return a(this,r,"f").info("Found existing asset for file after acquiring lock",{withExistingAsset:t}),t.assetId;const i=new D.Asset;return i.capturedAtLocal=e.capturedAtLocal,i.addAssetFile(e),i.upsert(),i.id}));return e.assetId=t,e.upsert()})),this.byExistingAsset_=()=>(0,d.time)("sync-file.AssetFileFinder.byExistingAsset: "+this.file,(async()=>{const e=[{name:"byUri",f:()=>this.byUri()},{name:"byNormalizedPathUri",f:()=>this.newAssetFileForAsset(this.assetByNormalizedPathUri())},{name:"bySha",f:()=>this.newAssetFileForAsset(this.assetBySha())},{name:"hasTags",f:async()=>{await this.tags_()}},{name:"validFile",f:async()=>{await(0,g.throwIfInvalidFile_)(this.file)}},{name:"byCapturedAtOrImageHash",f:()=>this.newAssetFileForAsset(this.assetByCapturedAtOrImageHash())}];for(const{name:t,f:i}of e)try{const e=await(0,d.time)("sync-file.assetFileFinder."+t+": "+this.file,i);if(null!=e)return a(this,r,"f").info("apply(): "+t,{assetFileId:e.id,assetId:e.assetId}),e;a(this,r,"f").debug("apply(): "+t+": returned null")}catch(e){throw a(this,r,"f").debug("apply(): "+t+" rejected: "+e),e}})),n(this,r,(0,l.mkLogger)("sync-file.AssetFileFinder("+e.baseWithGrandparent+")"),"f")}async prior(){return this.byUri()}async priorIfSynced(){if(this.ctx.forceSync)return;const e=await this.prior();return!0===await(e?.matchesFile())?e:void 0}async newAssetFileForAsset(e){const t=await e;if(null!=t){if(null!=t.id){const e=await this.newAssetFile_();return t.addAssetFile(e),e.insert(),a(this,r,"f").debug("newAssetFileForAsset() upsert success!",{af:e}),e}a(this,r,"f").throw("newAssetFileForAsset(): given non-persisted Asset")}}async capturedAt_(){return(await this.tags_()).capturedAt}async byUri(e=this.file){const t=await e.uri_();if(null!=t)return k.AssetFile.ops().firstf((e=>e.whereIn("uri",[...(0,b.uriEncodingVariants)(t),this.file.fileuri()])));a(this,r,"f").warn("byUri() uri is null",{file:e})}async assetByNormalizedPathUri(){const e=await this.file.normalize();return e.nativePath===this.file.nativePath?void 0:(await this.byUri(e))?.getAsset()}assetBySha(){return(0,c.thenMap)(this.file.sha(),(e=>D.Asset.findFirstByFile((t=>t.where("AssetFile.sha",e)))))}async assetByCapturedAtOrImageHash(){const e=await this.capturedAt_();if(null==e)return a(this,r,"f").throw("Cannot import, capturedAt is null"+f.InternalErrorFlag);if(w.Settings.strictDeduping.valueOrDefault)return this.firstSimilarAsset(k.AssetFile.ops().allf((t=>t.where({capturedAtLocal:e.local}))));const t=w.Settings.maxContemporaryAdoptionAssets.valueOrDefault,i=()=>{let i=k.AssetFile.query();return(0,E.gt0)(t)&&(i=i.limit(t)),i.orderByRaw(`abs(capturedAtLocal - ${e.local})`)},s=Math.max(_.secondMs,w.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault);return(0,d.time)("sync-file.AssetFileFinder.assetByCapturedAtAndImageHash: "+this.file,(async()=>{{const t=e.localBoundaries({delta:s});if(null==t)a(this,r,"f").warn("Failed to fetch localBoundaries, cannot fetch similar assets by localtime",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("captured-at",i().whereBetween("capturedAtLocal",[t.start,t.end]))??(w.Settings.checkBasenameMatches.valueOrDefault?this.firstSimilarAssetByQuery("basename",i().whereILike("uri","%/"+this.file.name+"%")):void 0);if(null!=e)return e}}const t=await this.imageHash();if(null==t)return void a(this,r,"f").warn("assetByCapturedAtAndImageHash: no imageHash");const n=await this.dominantLabhashes();if((0,S.isNotEmpty)(n)){const t=e.localBoundaries({delta:4*s});if(null==t)a(this,r,"f").error("Failed to fetch localBoundaries, cannot fetch similar assets by wide localtime + image hash",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("wide captured-at and dominant color",i().whereBetween("capturedAtLocal",[t.start,t.end]).andWhere((e=>e.whereIn("mode0",n).orWhereIn("mode1",n).orWhereIn("mode2",n))));if(null!=e)return e}}return this.firstSimilarAssetByQuery("image hash",i().where("meanHash",t.meanHash).orWhere("diffHash",t.diffHash).orWhere("dctHash",t.dctHash))}))}async firstSimilarAssetByQuery(e,t){a(this,s,"f").size>0&&(t=t.whereNotIn("AssetFile.id",Array.from(a(this,s,"f"))));const i=await this.firstSimilarAsset(k.AssetFile.ops().all(t));return null!=i&&a(this,r,"f").info("Found similar asset by "+e,{result:i}),i}async firstSimilarAsset(e){const t=await this.newAssetFile_(),i=await this.capturedAtLocal();if(null==t)throw new Error("Failed to update from "+this.file);const n=(0,P.sortBy)(e.filter((e=>!a(this,s,"f").has(e.id))),(e=>[(0,T.mapOr)(i,(t=>Math.abs(e.capturedAtLocal-t)),-e.capturedAtLocal),e.id]));for(const e of n)if(null!=e){await e.getNativePath();const i=k.AssetFile.ops().findBy({assetId:e.assetId});await Promise.all(i.map((e=>e.getNativePath())));const n=(0,u.whyNotSameAsset)(t,e,i);if(null==n)return a(this,r,"f").info("Found sibling AssetFile",e),D.Asset.ops().findById(e.assetId);a(this,s,"f").add(e.id),a(this,r,"f").debug("Contemporary assetFile not similar: "+n,e?.uri)}}}t.AssetFileFinder=F,r=new WeakMap,s=new WeakMap},34274:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileImporter=t.importFileToResult_=void 0;const u=i(19851),c=i(50213),d=i(73568),h=i(38835),f=i(95696),m=i(62105),p=i(74128),g=i(181),y=i(69589),w=i(28874),v=i(40958),b=i(22573),S=i(38639),P=i(59455),M=i(64526),_=i(19113),T=i(94710),E=i(3996),D=i(90901);t.importFileToResult_=async function(e){const t=M.Library.instanceRequired_();return(0,p.syncReport)().wrap_({path:e.path,from:"AssetFileImporter",fn_:()=>new k(f.PosixFile.for(e.path),t.assetFileRepository(),e).apply_()})};class k{constructor(e,t,i){r.add(this),this.file=e,this.repo=t,this.start=Date.now(),s.set(this,void 0),n.set(this,void 0),this.whyRejected=(0,u.lazy)((async()=>{const e=[],t=await this.file.uri_();if(null==t)e.push("Cannot make URI"+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);else{if(!0===await this.file.isDeletedUri(t))e.push("File was deleted");else if(this.ctx.forceFilters||null==await this.prior()){const t=await(0,m.whyRejectFile)(this.file,(0,_.libraryFileFiltersFor)(this.file));null!=t&&e.push(t)}l(this,s,"f").throwIfAborted_();const i=await this.prior();if((0,v.isNotEmpty)(e)&&null!=i&&(l(this,s,"f").info("Deleting prior AssetFile",{rejected:e,prior:i}),i.delete(),this.ctx.skipAssetRepair?l(this,s,"f").info("Skipping asset repair",{assetId:i.assetId}):(l(this,s,"f").info("Scheduling asset repair",{assetId:i.assetId}),T.Task.addOne("repairAsset",{assetId:i.assetId,forceRebuildPreviews:(0,S.isTrue)(i.shown)}))),null!=i){const t=i.getAsset();null!=t?.deletedAt&&e.push("Asset is marked as deleted"),null!=t?.excludedAt&&e.push("Asset is marked as excluded")}if(l(this,s,"f").throwIfAborted_(),0===e.length&&(null==i||!await i.inSyncWithFile())){const t=await(0,g.whyInvalidFile)(this.file.nativePath);(0,b.blank)(t)||e.push(t)}}return e})),this.assetFile_=(0,u.lazy)((async()=>{const e=await l(this,n,"f").apply_(),t=e.getAsset();return l(this,s,"f").info("assetFileFinder.apply_() result",{asset:t,assetFile:e}),null==t?l(this,s,"f").throw("assetFile.getAsset() was null",{srcAssetFile:e}):null==t.id?l(this,s,"f").throw("repoAssetFile asset has null id",{asset:t}):e})),this.prior=(0,u.lazy)((()=>l(this,n,"f").prior())),this.apply_=(0,u.lazy)((()=>l(this,r,"m",a).call(this))),this.ctx=(0,y.forceContextOrSetting)(i),o(this,s,(0,c.mkLogger)("sync-file."+this.toString()),"f"),o(this,n,new E.AssetFileFinder(e,this.ctx),"f")}toString(){return"AssetFileImporter("+this.file.nativePath+")"}newAssetFile(){return l(this,n,"f").newAssetFile_()}}t.AssetFileImporter=k,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(){l(this,s,"f").throwIfAborted_();const e=await l(this,s,"f").tapAsync_({msg:"whyRejected",result:this.whyRejected(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if((0,v.isNotEmpty)(e)){const t=e.join(", ");return{path:this.file.nativePath,state:p.SyncFileStates.rejected,details:t}}l(this,s,"f").throwIfAborted_();const t=await l(this,s,"f").tapAsync_({msg:"prior()",result:this.prior(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if(null!=t&&await t.isNoop(this.ctx))return{path:this.file.nativePath,state:p.AssetFileSyncStates.noop,assetId:t.assetId,assetFileId:t.id,assetFile:t,asset:t.getAsset(),uri:t.uri};l(this,s,"f").throwIfAborted_();const i=await l(this,s,"f").tapAsync_({msg:"assetFile()",result:this.assetFile_(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault});if(null==i)return l(this,s,"f").throw("_apply(): unexpected null assetFile");const r=i.id;if(null==r)return l(this,s,"f").throw("_apply(): unexpected null assetFileId");const n=i.uri;if(null==n)return l(this,s,"f").throw("_apply(): unexpected null assetFile.uri");const a=i.getAsset();if(null==a)return l(this,s,"f").throw("_apply(): unexpected null assetFile.getAsset()");let o;await l(this,s,"f").tapAsync_({msg:"assetFile.upsertIfNeeded_()",result:i.upsertIfNeeded_(),timeoutMs:w.Settings.taskTimeoutMs.valueOrDefault}),l(this,s,"f").throwIfAborted_();try{o=await(0,D.assetPostUpsertTasks_)({asset:a,...this.ctx})}catch(e){e instanceof d.AbortError?l(this,s,"f").warn("aborted (caller/process after me will complete)",{error:e}):l(this,s,"f").throw("Post-upsert tasks failed",{error:e})}return{path:this.file.nativePath,state:i.syncState??p.SyncFileStates.synced,assetId:a.id,assetFileId:r,assetFile:i,asset:a,uri:n,uris:[n,...(0,P.toA)(o?.newAssetFileUris)]}}},41844:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileRepository=t.mayCopyAssetsToLibrary=void 0;const u=i(50213),c=i(74128),d=i(81674),h=i(57902),f=i(4936),m=i(28874),p=i(47783),g=i(67083),y=i(16170),w=i(54979),v=i(98604),b=i(40958),S=i(22573),P=i(98553),M=i(89937),_=i(59455),T=i(54017),E=i(94710);t.mayCopyAssetsToLibrary=async function(){return m.Settings.copyAssetsToLibrary.valueOrDefault&&await(0,d.p)()},t.AssetFileRepository=class{constructor(e){r.add(this),this.originalsDir=e,this.logger=(0,u.mkLogger)("AssetFileRepository")}async shouldCopy(e){const t=await this.whyNotCopyFile(e);return this.logger.tap({level:"info",msg:"shouldCopy()",result:null==t,meta:{file:e?.nativePath,whyNot:t}})}async whyNotCopyFile(e){if(null==e||(0,S.blank)(e.nativePath))return"blank nativePath";if(!0!==m.Settings.copyAssetsToLibrary.value)return"copyAssetsToLibrary !== true";if(await(0,d.l)())return"no active subscription";if(await e.notExists({refresh:!0}))return"file doesn't exist";if(e.isDescendantOf(this.originalsDir))return e+" already contained by "+this.originalsDir;if(e.isDescendantOf(m.Settings.libraryDir.valueOrDefault))return e+" already contained by "+m.Settings.libraryDir.valueOrDefault;const t=await(0,w.readMimeType)(e);return null==t?"readMimeType("+e+") was null":(0,y.isMimeTypeIncluded)(t,m.Settings.copyToLibraryMimeTypes.values)?null:"mimetype "+t+" is not included in copyToLibraryMimeTypes"}async existingLibraryAssetFile(e){if(e.uri.startsWith(M.PS_LIBRARY_PROTOCOL))return e;const t=(0,b.uniqBy)((0,_.toA)(e.librarySiblings()?.filter((t=>t.sha===e.sha))).concat(T.AssetFile.sameAssetFileInLibrary(e)),(e=>e.id));for(const i of t)if(await i.exists()){if(i.assetId!==e.assetId){this.logger.warn("Existing library asset file with a matching SHA is associated to a different asset. Requesting repair of the two impacted assets.",{af:e,prior:i});const t=i.assetId;e.getAsset()?.addAssetFile(i),E.Task.addOne("repairAsset",{assetId:t,forceSync:!0})}return this.logger.info("whyNotCopyAssetFile("+e.uri+"): found existing db record",{af:e,prior:i}),i}return null}async findLibraryFileWithSameContents(e,t){if(await e.matchesContent(t))return t;let i=t.parent();for(;i.isSelfOrDescendantOf(this.originalsDir);){const t=i.childWithSameContents(e);if(null!=t)return t;i=i.parent()}}async importFile_(e){const t=await l(this,r,"m",s).call(this,e);return null!=t&&(await l(this,r,"m",n).call(this,e,t),await l(this,r,"m",o).call(this,e,t)),t}async maybeCopyToLibrary_(e,t){const i=Date.now(),s=await e.posixFile_();null==s&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): posixFile is null",{ignorable:!1,retriable:!1});{const e=await this.whyNotCopyFile(s);if(!(0,S.blank)(e))return this.logger.tap({level:h.LogLevels.info,msg:"maybeCopyToLibrary_(): not copying: "+e,result:void 0})}const a=e.getAsset();null==a&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): null asset");{const u=await this.existingLibraryAssetFile(e);if(null!=u){const e=await u.posixFile_();if(null!=e){const d=await l(this,r,"m",n).call(this,s,e),h=null!=await l(this,r,"m",o).call(this,s,e),f=null!=await u.upsertIfNeeded_(void 0,t);return!h&&(0,b.isEmpty)(d)&&!f||(0,c.syncReport)().onProgress({path:e.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.synced,details:"Found and synced prior replica already in your library "+(0,P.stringify)({src:s.nativePath,upsertNeeded:f,copiedSidecars:d,copiedInferredMetadata:h}),elapsedMs:Date.now()-i,url:(0,v.mkAssetUrl)(a.id)?.toString()}),u}this.logger.warn("existingLibraryAssetFile() returned an assetFile that could not be resolved to a PosixFile",{prior:u})}}const u=await this.importFile_(s);if(null==u)return void this.logger.info("importFile() returned null",{srcAssetFile:e});if(u.nativePath===s.nativePath)return void this.logger.info("importFile() returned the same nativePath as src",{srcAssetFile:e,dest:u});const d=await a.assetFileForFile_(u,{skipUpsert:!0});await d.updateFromShaSibling_(e);const f=d.upsert();return a.addAssetFile(d),(0,c.syncReport)().onProgress({path:u.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.copied,details:"Copied into your library from "+s.nativePath,elapsedMs:Date.now()-i,url:(0,v.mkAssetUrl)(a.id)?.toString()}),f}},r=new WeakSet,s=async function(e){const t=await(0,p.readCapturedAt)(e),i=(0,f.pathToLibraryAsset)(t?.date,e);if(this.logger.debug("importFile("+e+")",{capturedAt:t,assetPath:i}),null==i)throw new Error(e.nativePath+" failed to create a library path");const r=this.originalsDir.join(...i),s=await this.findLibraryFileWithSameContents(e,r);if(null!=s)return this.logger.debug("#importFile_("+e+"): found existing file",{src:e,existing:s}),s;const n=await r.ensureNew_();return this.logger.info("#importFile_("+e+"): copying...",{uniqDest:n,dest:r}),e.copyFile_(n)},n=async function(e,t){const i=await e.existingSidecars(),s=[];for(const e of i)s.push(await l(this,r,"m",a).call(this,e,t));return(0,b.compact)(s)},a=async function(e,t){for(const i of await t.existingSidecars())if(await(0,p.sidecarEql)(e,i))return void this.logger.info("handleSidecar(): metadata already exists.",{srcSidecar:e,destSidecar:i,dest:t});const i=await t.parent().join(t.name+e.ext).ensureNew_({emptyIsNew:!0});return e.copyFile_(i)},o=async function(e,t){if(null==e||null==t||e.eql(t))return;const i=await(0,p.readTags)(e);if(null!=i)return(0,g.ensureInferredHistoryRecords)(e,await t.sidecar(),i.inferred);this.logger.warn("#handleInferred(): Failed to read tags from "+e,{dest:t})}},90901:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetPostUpsertTasks_=t.assetPostUpsertTasks=void 0;const r=i(50213),s=i(92434),n=i(73568),a=i(99331),o=i(39250),l=i(38835),u=i(57159),c=i(48604),d=i(66106),h=i(69589),f=i(40958),m=i(45599),p=i(23838),g=i(31586),y=i(64526),w=i(88224),v=i(43487),b=i(41844),S=i(68640),P=(0,m.defer)((()=>(0,r.mkLogger)("sync-file.AssetPostUpsertTasks"))),M=(0,m.defer)((()=>new o.LastOneInWins("Asset tasks")));async function _(e){const t=e,i=e,r=(0,g.toGt0)(t.asset?.id)??(0,g.toGt0)(i.assetId);if(null==r)throw new Error("assetPostUpsertTasks_(): unexpected null assetId"+l.InternalErrorFlag);const o=(0,h.forceContextOrSetting)(e),m=P().addContext(`.postUpsertAssetTasks_(Asset:${r})`);if(m.abortable=o.halt,o.skipPreviews&&o.skipAssetTagging)return void m.info("skipped (skipPreviews && skipAssetTagging)");const _=t.asset??v.Asset.ops().findById(r);if(null==_)return m.throw("unexpected null asset",{asset:_});try{return await M().enqueue({key:r,abortable:m.abortable,fn:()=>async function(e,t,i){const r=(0,h.forceContextOrSetting)(i),n=t.id,a=t.getAssetFiles({refresh:!0}),o={newAssetFileUris:[],previewsUpdated:!1,tagResult:void 0,transcoded:!1};if(e.throwIfAborted_(),(0,f.isEmpty)(a)&&(await v.Asset.remove({assetId:n,blocklistShas:!1,unlinkAssetFiles:!1}),e.throw(`Asset:${n} had no asset files. Deleted.`)),await(0,b.mayCopyAssetsToLibrary)())for(const[t,i]of(0,p.groupBy)(a,(e=>e.sha)).entries()){e.throwIfAborted_();try{for(const r of i)r.isInLibrary()&&await r.exists()&&e.debug("no-op for file SHA: already in library.",{sha:t,uri:r.uri});for(const e of i)if(await e.exists()){const t=await y.Library.instanceRequired_().assetFileRepository().maybeCopyToLibrary_(e,r);if(null!=t){o.newAssetFileUris.push(t.uri);continue}}}catch(r){e.warn("Failed to copy variation to library, but we'll try to continue",{sha:t,uris:i.map((e=>e.uri)),error:r})}}e.throwIfAborted_();const l=r.skipPreviews?void 0:await(0,S.updateAssetPreviews_)({asset:t,assetFiles:t.getAssetFiles(),...r}),u=await async function(e,t){if((0,g.gt0)(t?.assetFileId)){const i=e.getAssetFiles({refresh:!0}).find((e=>e.id===t?.assetFileId));return null==i?P().throw("AssetPreviewInfo referenced unknown assetFileId",{asset:e,info:t}):i}const i=e.getShown();return null!=i?i:(0,s.bestExistingAssetFile)(e.getAssetFiles())}(t,l);if(null==u)return e.throw("null primaryOrShownAssetFile_()",{asset:t});const m=await u.posixFile_();if(!0!==r.skipPreviews&&t.isVideo()){if(null==m)return e.throw("null primary.posixFile()",{asset:t,assetFiles:t.getAssetFiles()});o.transcoded=null!=await(0,d.transcode_)(m,c.Previews.instance().ap(n).mp4(),{force:r.forceRebuildPreviews,halt:r.halt})}return e.throwIfAborted_(),t.markShownAndUpsert_(u),r.skipAssetTagging?e.info("skipping asset tagging"):o.tagResult=await(0,w.tagAndUpsertAsset_)(t),o}(m,_,{...e,...o})})}catch(e){if(e instanceof n.AbortError)return void m.warn("aborted, next caller will clean up my mess",{error:e});const t=[e];if(!(0,a.ending)()){m.error("failed, marking asset unshown",{error:e});try{_.markUnshownAndUpsert()}catch(e){m.error("failed to mark asset unshown",{upsertError:e}),t.push(e)}}throw new u.WrappedError("Failed to post-process assset "+_.id,{causes:t})}}t.assetPostUpsertTasks=function(e){try{return _(e)}catch(e){if(e instanceof n.AbortError)return void P().warn("aborted, next caller will clean up my mess",{error:e});throw e}},t.assetPostUpsertTasks_=_},61989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAsset_=t.updateAsset=void 0;const r=i(48884),s=i(50213),n=i(45393),a=i(79184),o=i(79781),l=i(92434),u=i(56519),c=i(70417),d=i(69589),h=i(28874),f=i(40958),m=i(22573),p=i(38639),g=i(50357),y=i(43487),w=i(54017),v=i(90901);async function b(e){const t=(0,d.forceContextOrSetting)(e),i=e.assetId,r=(0,s.mkLogger)(`sync-file.UpdateAsset(${i})`);r.abortable=t.halt;const b=y.Asset.ops().findById(i);if(null==b)return r.throw("no such asset");const P=b.getAssetFiles({refresh:!0});if((0,f.isEmpty)(P))return r.warn("No asset files: deleting."),b.delete(),{asset:b,rejected:"Empty asset (no AssetFiles)"};const M=b.$clone(),_=b.getShown()?.$clone();for(const e of P)r.throwIfAborted_(),await e.upsertIfNeeded_(void 0,t);P.some((e=>(0,p.isTrue)(e.deleted)||(0,m.notBlank)(e.rejected)))&&b.clear(),await S(r,P);const T=(0,l.sortAssetFiles)(P),E=T?.[0];if((0,f.isEmpty)(T)||null==E)return r.warn("No existing files. Skipping for now."),b.markUnshownAndUpsert(),{asset:b,rejected:"Empty asset (no AssetFiles after sorting). Un-showing Asset:"+i};if(!E.isVersionUpToDate())return r.warn("Best file needs update, and we already tried to update all files. Skipping this asset.",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, could not be updated. Un-showing Asset:${i}`};const D=await E.capturedAt();if(null==D)return r.warn("Best file failed to extract a captured-at",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, failed to extract a captured-at. Un-showing Asset:${i}`};const k=new Set,[x,F]=await(0,u.partitionAsync)(T,(e=>(0,o.isSimilarAssetFile)(e,E)));if(r.throwIfAborted_(),(0,f.isNotEmpty)(F)){const e=await(0,a.aggregateAssetFiles)(F);for(const t of e){if((0,f.isEmpty)(t))continue;const e=y.Asset.ops().insertOne({capturedAtLocal:t[0].capturedAtLocal,shown:!1,version:0});k.add(e.id);for(const i of t)e.addAssetFile(i);w.AssetFile.dbl.runf((i=>i.update({assetId:e.id,shown:0}).whereIn("id",(0,f.compact)(t.map((e=>e.id)))))),r.info("Pushed rejected asset files into new asset",{rejectAssetId:e.id,rejectCluster:t.map((e=>({id:e.id,uri:e.uri})))})}}function C(e){return(0,f.uniq)(x.map((t=>t[e])))}const A=await Promise.all(x.map((e=>e.capturedAt()))),I=h.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,O=A.map((e=>e?.localBoundaries({delta:I}))),L=(0,c.min)(O.map((e=>e?.start)))??D.localBoundaries({delta:I})?.start,R=(0,c.max)(O.map((e=>e?.end)))??D.localBoundaries({delta:I})?.end,N=w.AssetFile.ops().all(w.AssetFile.query().limit(h.Settings.maxContemporaryAdoptionAssets.valueOrDefault).orderByRaw(`abs(AssetFile.capturedAtLocal - ${E.capturedAtLocal})`).select("AssetFile.*").distinct().join("Asset","Asset.id","AssetFile.assetId").where("AssetFile.assetId","!=",i).andWhere("Asset.version","!=",n.AssetVersion).andWhere((e=>(e=e.whereIn("AssetFile.sha",C("sha")),null==L||null==R?r.warn("external asset file check: unset start or end localtime boundary",{capturedAts:A,startBoundary:L,endBoundary:R}):e=e.orWhereBetween("AssetFile.capturedAtLocal",[L,R]),e.orWhereIn("AssetFile.meanHash",C("meanHash")).orWhereIn("AssetFile.diffHash",C("diffHash")).orWhereIn("AssetFile.dctHash",C("dctHash"))))));r.throwIfAborted_(),r.info("asset file candidates for adoption: ",N.map((e=>e.posixPathFromGrandparent)));const B=[];for(const e of N){r.throwIfAborted_();try{await e.updateFromFile_(),(0,o.isSimilarAssetFile)(e,E)&&(r.info("adopting similar asset file",{af:e}),k.add(e.assetId),e.shown=!1,b.addAssetFile(e),e.upsert(),B.push(e))}catch(t){r.warn("Error updating external asset file. Leaving asset file record as-is.",{af:e,error:t})}}r.info("fetched expansion",{retainAFs:x.map((e=>e.id)),rejectAFs:F.map((e=>e.id)),externalAssetFiles:N.map((e=>e.posixPathFromGrandparent)),similarAssetFiles:B.map((e=>e.posixPathFromGrandparent))}),await S(r,[...x,...B]),t.skipPreviews&&t.skipAssetTagging?(r.info("skipping previews and tagging",t),b.upsert()):await(0,v.assetPostUpsertTasks_)({...t,asset:b});const j=!(0,g.eql)(M,b),z=!(0,g.eql)(_,b.getShown()),V=!(j||z||t.forceRebuildPreviews||t.forceSync);return r.tap({msg:"updateAsset() result",level:"info",result:{asset:b,assetIdsToUpdate:Array.from(k),assetFiles:b.assetFiles,skipped:V},meta:{ctx:t,assetChanged:j,primaryAssetFileChanged:z}})}async function S(e,t){const[i,s]=(0,r.partition)(t,(e=>e.isVersionUpToDate()));for(const t of s){e.throwIfAborted_();const r=i.find((e=>e.sha===t.sha));if(null!=r){e.info("backfilling",{sibling:r,dest:t});const i=await t.updateFromShaSibling_(r);null!=i&&i.upsert()}}}t.updateAsset=async function(e){try{const t=await b(e);return{id:e.assetId,skipped:null==t?.asset,...t}}catch(t){return{id:e.assetId,error:t}}},t.updateAsset_=b},93755:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetFileIfNeeded=t.handleAssetFileUriChange=t.updateAssetFile_=t.updateAssetFile=void 0;const r=i(50213),s=i(92434),n=i(98314),a=i(74128),o=i(69589),l=i(87001),u=i(40958),c=i(22573),d=i(68708),h=i(43487),f=i(54017),m=i(94710);async function p(e){const t=Date.now(),i=e,s=e,n=s.af?.id??i.assetFileId,u=(0,r.mkLogger)(`updateAssetFile(${n})`),d=s.af??f.AssetFile.ops().findById(n);if(null==d)return u.throw("db record not found",{assetFileId:n});const h=await d.posixFile_(),p=(0,o.forceContextOrSetting)(e),w={id:n,assetFileId:n,path:h?.nativePath,uri:d?.uri};if(null==h)return{...w,error:"file for URI not found"};const v=await(h?.isDeletedUri(d.uri));if(null==v)return u.info("no-op: file URI points to an unmounted volume",w),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:"volume is not currently mounted",state:a.SyncFileStates.skipped}),{...w,skipped:!0};const b=e.whyReject??await d.whyRejected();if(v||!(0,c.blank)(b)){const e={...w,rejected:b,deleted:v};return u.warn("file was deleted or rejected. Deleting.",e),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:v?"file no longer exists":"rejected: "+b,state:a.SyncFileStates.deleted}),d.delete(),!0!==p.skipAssetRepair&&m.Task.addOne("repairAsset",{assetId:d.assetId}),e}const S=await h.uri_();if(!await(0,l.uriIsEquivalent)(S,d.uri)){const e=await g(d,S,p);if(null!=e)return{...w,...e}}return!p.forceSync&&await d.matchesFile()?(u.info("no-op: file already matches db record",w),d.touch(),{...w,skipped:!0}):{...w,...await y(d,p)}}async function g(e,t,i){const n=(0,r.mkLogger)(`handleAssetFileUriChange(${e.id})`),a=(0,u.uniq)([...(0,l.uriEncodingVariants)(e.uri),...(0,l.uriEncodingVariants)(t)]);n.warn("URI is changing. Avoiding duplicate keys.",{priorUri:e.uri,variants:a});const o=f.AssetFile.ops().allf((t=>t.whereIn("uri",a).andWhereNot({id:e.id})));if((0,u.isNotEmpty)(o)){n.warn("Found other AssetFiles with equivalent URIs.",{afIds:o.map((e=>e.id))});const t=[e,...o],r=(0,s.sortAssetFiles)(t);if((0,u.isEmpty)(r))return n.warn("sortAssetFiles returned undefined",{arr:t.map((e=>(0,d.pick)(e,"id","uri"))),variants:a}),{error:"sortAssetFiles returned undefined"};const l=t.map((e=>e.id));for(const e of r)if(await e.exists()){f.AssetFile.dbl.runf((t=>t.whereIn("id",l.filter((t=>t!==e.id))).delete()));const r=y(e,i);return h.Asset.dbl.runf((e=>e.update({version:0,updatedAt:Date.now()}).whereIn("id",(0,u.uniq)(t.map((e=>e.assetId)))))),r}}n.info("no-op, no duplicate URIs.")}async function y(e,t){const i=Date.now();return null!=await e.upsertIfNeeded_(void 0,t)&&h.Asset.touch([e.assetId]),(0,a.syncReport)().onProgress({path:await e.getNativePath(),elapsedMs:Date.now()-i,from:"updateAssetFileIfNeeded()",state:e.syncState??a.SyncFileStates.unknown}),{assetFileId:e.id}}t.updateAssetFile=async function(e){try{return await p(e)}catch(t){return{id:e.assetFileId,...e,error:(0,n.errorToS)(t)}}},t.updateAssetFile_=p,t.handleAssetFileUriChange=g,t.updateAssetFileIfNeeded=y},68640:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetPreviews_=void 0;const r=i(99331),s=i(38835),n=i(48604),a=i(50213),o=i(69589),l=i(87001),u=i(40958),c=i(45599),d=i(50357),h=i(31586),f=i(68708),m=i(59455),p=i(43487),g=(0,c.defer)((()=>(0,a.mkLogger)("sync-file.UpdateAssetPreviews")));t.updateAssetPreviews_=async function(e){const t=e.assetId??e.asset?.id??(0,m.toA)(e.assetFiles).find((e=>(0,h.gt0)(e.assetId)))?.assetId,i=(0,o.forceContextOrSetting)(e),a=g().addContext(".Asset:"+t);if(i.skipPreviews)return void a.warn("skipPreviews is true: no-op");if(!(0,h.gt0)(t))return a.throw("invalid assetId",{assetId:t});const c=e.asset??p.Asset.ops().findById(t);if(null==c)return a.throw("Asset:"+t+" not found");a.throwIfAborted_(i.halt);try{const e=await c.getExistingAssetFiles();if((0,u.isEmpty)(e))return void a.warn("no existing assetFiles",{asset:c});const r=n.Previews.instance().ap(t),o=await r.readInfo();a.throwIfAborted_(i.halt);const h=await(0,n.buildAssetPreviews_)({...i,assetId:t,assetFiles:e}),m=e.find((e=>e.id===h?.assetFileId))??e.find((e=>(0,l.uriIsEquivalent)(h?.uri,e.uri)));a.info("buildAssetPreviews_()",{result:h,primaryAssetFile:m});const p=await(m?.posixFile_());if(null==m||null==p||!0!==await(p?.exists()))return a.throw("buildAssetPreviews_() returned invalid assetFileId"+s.InternalErrorFlag,{newInfo:h,assetFiles:e.map((e=>(0,f.pick)(e,"id","uri"))),primaryAssetFile:m,primaryPosixFile:p});const g=(0,d.eql)(o,h),y=null==h||g;return{...h,noop:y}}catch(e){throw(0,r.ending)()||(a.warn("Failed to update previews. Un-showing asset "+t,{error:e}),c.markUnshownAndUpsert()),e}}},34742:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});try{i(93944).install()}catch{}const r=i(69554),s=i(38790),n=i(53978),a=i(43380),o=i(43334),l=i(28874),u=i(5670),c=i(21200),d=i(2775),h=i(31503),f=i(12195),m=i(52288),p=i(53767);!async function(){if(o.isElectron)new p.SyncService;else{const e=await new r.CLI(u.ServiceNames.sync,"[files-or-directories...]","If paths are provided on the command line, they should be fully-qualified.\n\n* Paths to directories will be scanned recursively.\n* Paths to files will be imported if they pass configured filters.\n\nNote that sync will spawn 1 or more `worker` processes to work in parallel.").add(m.RebuildArg,d.ForceArg,n.TimingArg,f.NoFilterArg,c.ExitWhenDoneArg,a.WriteSettingsArg,h.LogArgs,s.ColorArgs).parse();l.Settings.argvScanPaths.envValue=e.args,new p.SyncService}}()},94019:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathsToSync=t.scanPaths=t.logger=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(87290),o=i(34102),l=i(16287),u=i(45969),c=i(43334),d=i(28874),h=i(45200),f=i(69375),m=i(7014),p=i(41400),g=i(31586),y=i(92244),w=i(46832);t.logger=(0,r.lazy)((()=>(0,s.mkLogger)("sync.PathsToSync")));const v=(0,r.lazy)((async()=>{const e=[];for(const t of await(0,m.volumes)()){if(!0===t.ignorable||!1===t.ok||(c.isMac||(0,u.isDocker)())&&"/"===t.mountpoint||(0,f.isExcludedMountpoint)(t.mountpoint)||!(0,g.gt0)(t.size))continue;const i=await(0,w.toUriPath)(t.mountpoint,(0,h.nativePath2uri)(t.mountpoint,t));null!=i&&e.push(i)}return e}));async function b(){const e=[],i=[],r=d.Settings.argvScanPaths.toNotEmpty()??d.Settings.scanPaths.values;for(const s of r)if(await(0,l.isReadableDirectory)(s)){const r=await(0,w.toUriPath)(s);null==r?(e.push(s),(0,t.logger)().warn("Ignoring scanPath element: failed to create URI path",s)):i.push(r)}else(0,t.logger)().warn("Ignoring scanPath element: not readable directory",s);return{result:i,noUriPaths:e}}t.scanPaths=b,(0,p.later)((()=>{(0,o.ee)().on("volumesChanged",(()=>{v.unset()}))})),t.pathsToSync=async function(){const e=[];if(d.Settings.argvScanPaths.isNotEmpty()){for(const i of d.Settings.argvScanPaths.values){const r=await(0,w.toUriPath)(i);null!=r?e.push(r):(0,t.logger)().warn("pathsToSync(): Ignoring scanPath element: failed to create URI path",i)}return e}e.push(...(await b()).result),!0===d.Settings.scanAllDrives.value&&e.push(...await v());const i=await(0,n.thenMapOr)((0,a.libraryOriginalsDirPosixFile)(),w.posixFileToUriPath,(()=>(0,t.logger)().throw("libraryOriginalsDir was null",{libraryDir:d.Settings.libraryDir.valueOrDefault,originalsDir:d.Settings.originalsDir.value})));d.Settings.scanLibraryFirst.valueOrDefault&&e.unshift(i),d.Settings.scanLibraryLast.valueOrDefault&&e.push(i);const r=await(0,n.filterAsync)({name:"pathsToSync",arr:e,f:e=>!y.nativePathBlocklist.has(e.nativePath)&&(0,l.isReadableDirectory)(e.nativePath)});return(0,t.logger)().info("pathsToSync",r),r}},76907:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.precheckFiles=void 0;const r=i(50213),s=i(98314),n=i(74128),a=i(69589),o=i(45200),l=i(98604),u=i(22573),c=i(45599),d=i(54017),h=(0,c.defer)((()=>(0,r.mkLogger)("sync.PrecheckFiles"))),f="AssetFilePrecheck";async function m(e,t){const i=(await(0,o.nativePath2uri)(e.nativePath)).toString(),r=d.AssetFile.ops().firstf((e=>e.where({uri:i})));if(null==r)return(0,n.syncReport)().onProgress({path:e.nativePath,from:f,state:n.SyncFileStates.enqueued,details:"Path is new to the library. Scheduling import."}),!0;const s=await r.whyNotNoop(t);return(0,u.blank)(s)?((0,n.syncReport)().onProgress({path:e.nativePath,from:f,state:n.SyncFileStates.noop,details:"in sync",url:(0,l.mkAssetUrl)(r.assetId)?.toString()}),r.touch(),!1):((0,n.syncReport)().onProgress({path:e.nativePath,from:f,state:n.SyncFileStates.enqueued,details:"update needed: "+s,url:(0,l.mkAssetUrl)(r.assetId)?.toString()}),!0)}t.precheckFiles=async function(e,t=(0,a.forceContextOrSetting)()){const i=[];for(const r of e)try{await m(r,t)&&(h().debug("precheckFiles(): stale path",{nativePath:r.nativePath}),i.push(r))}catch(e){h().info("precheckFiles(): failed to check path",{nativePath:r.nativePath,error:e}),(0,n.syncReport)().onProgress({path:r.nativePath,from:f,state:n.SyncFileStates.rejected,details:(0,s.errorToS)(e)})}return i}},63461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncCompleted=void 0,t.SyncCompleted={syncCompleted:!0}},98622:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runTimeIsStale=t.SyncCron=void 0;const r=i(28874),s=i(41400),n=i(30301),a=i(31586);t.SyncCron=(0,n.lazy)((()=>r.Settings.syncCron.cron({timezone:r.Settings.syncCronTZ.value}))),(0,s.later)((()=>{r.Settings.syncCron.watchLater((()=>t.SyncCron.unset())),r.Settings.syncCronTZ.watchLater((()=>t.SyncCron.unset()))})),t.runTimeIsStale=function(e){return null==e||(0,a.lte)((0,t.SyncCron)().nextRun(new Date(e))?.getTime(),Date.now())}},56179:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},f=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncDirectory=t.DefaultFileHandler=void 0;const m=i(89788),p=i(19851),g=i(50213),y=i(7282),w=i(45255),v=i(81168),b=i(73568),S=i(83412),P=i(99331),M=i(98314),_=i(38835),T=i(60652),E=i(29882),D=i(74128),k=i(76752),x=i(70417),F=i(28874),C=i(14036),A=i(69385),I=i(15674),O=i(22573),L=i(38639),R=i(42659),N=i(45599),B=i(55835),j=i(31586),z=i(68708),V=i(12168),W=i(54993),U=i(35580),q=i(54017),H=i(20958),G=i(49796),$=i(55009),J=i(94710),K=i(76907);async function Z(e){const t=await(0,K.precheckFiles)(e);J.Task.add(t.map((e=>({fn:"syncFile",args:{path:e.nativePath}}))))}t.DefaultFileHandler=Z;class Y extends S.DoneWrapper{static async for({root:e,rootUri:t,fileHandler:i=Z}){const r=await e.directoryEntry();if(null!=r&&r.isDirectory())return new Y(e,r,t,i);(0,g.mkLogger)("sync.DirectorySync").error("Cannot sync "+e+": it's not a directory (or not readable)",{root:e,rootUri:t})}constructor(e,t,i,d){super("sync.DirectorySync("+e+")",(()=>h(this,r,"m",s).call(this))),r.add(this),this.root=e,this.rootDirent=t,this.rootUri=i,this.fileHandler=d,this.start=Date.now(),this.eta=new k.ETA,this.recentlyScannedDirs=new m.BoundedList(10),this.progress=(0,N.defer)((()=>this.logger.tap({msg:".progress()",level:"warn",result:G.Progress.insertNew({uri:this.rootUri,volume:this.root.nativePath})}))),this.forceDirectoryScan=(0,N.defer)((()=>{const e=F.Settings.forceSync.valueOrDefault,t=F.Settings.argvScanPaths.values.some((e=>this.root.eql(e)));return this.logger.tap({msg:"forceDirectoryScan",result:e||t,meta:{forceSync:e,isArgvPath:t}})})),this.initialMeta=(0,N.defer)((()=>this.forceDirectoryScan()?void 0:this.progress().getMetaAsRecord())),this.minPriorCreatedAt=(0,N.defer)((()=>(0,x.max)([H.Operation.getFirstPendingOp({name:"forceRestartSync"})?.createdAt,(0,G.defaultMinCreatedAt)()]))),this.priorMeta=(0,N.defer)((()=>this.progress().getPriorIncomplete(this.minPriorCreatedAt())?.getMetaAsRecord())),this.priorScannedDir=(0,N.defer)((()=>this.priorMeta()?.lastScannedDirectory)),this.priorScannedDirsCount=(0,N.defer)((()=>(0,j.toInt)(this.priorMeta()?.scannedDirectoryCount)??0)),this.priorProcessedImageCount=(0,N.defer)((()=>(0,j.toInt)(this.priorMeta()?.processedImageCount)??0)),this.priorProcessedVideoCount=(0,N.defer)((()=>(0,j.toInt)(this.priorMeta()?.processedVideoCount)??0)),this.scannedDirsCount=0,n.set(this,0),a.set(this,0),this.priorEnqueuedStaleFiles=(0,N.defer)((()=>(0,L.isTrue)(this.priorMeta()?.enqueuedStaleFiles)??!1)),this.enqueuedStaleFiles=!1,this.completed=!1,this.upsertProgressMeta=(0,p.lazy)((()=>{const e=this.progress().getMetaAsRecord(),t={lastScannedDirectory:this.recentlyScannedDirs.at(-1)??this.priorScannedDir()??"",scannedDirectoryCount:(0,W.toS)(this.scannedDirectoryCount()),completedDirectoryScan:(0,W.toS)((0,L.isTrue)(this.priorMeta()?.completedDirectoryScan)||(h(this,o,"f").call(this)?.isDone()??!0)),enqueuedStaleFiles:(0,W.toS)(this.priorEnqueuedStaleFiles()||this.enqueuedStaleFiles),processedImageCount:(0,W.toS)(this.processedImageCount()),processedVideoCount:(0,W.toS)(this.processedVideoCount()),completedDirectorySync:(0,W.toS)((0,L.isTrue)(e.completedDirectorySync)||this.completed)};this.progress().setMetaRecord(t)}),(0,y.isTest)()?100:R.secondMs),this.directoryListener=e=>{null==e||(0,O.blank)(e.nativePath)?this.logger.warn("directoryListener() called with blank dir"+_.InternalErrorFlag,{dir:e}):(this.scannedDirsCount++,this.recentlyScannedDirs.push(e.nativePath),this.logger.debug("directoryListener()",{scannedDirsCount:this.scannedDirsCount,dir:e.nativePath}),this.upsertProgress({force:!0}))},o.set(this,(0,N.defer)((()=>(0,L.isTrue)(this.priorMeta()?.completedDirectoryScan)?void 0:new T.DirectoryIterator(this.rootDirent,this.ctx())))),this.pendingCount=(0,p.lazy)((()=>J.Task.countByFn("syncFile")),R.secondMs),l.set(this,((e,t,i)=>{if("syncFile"===e.fn){const t=e;this.onFileResolved(t.args.path,i)}else this.logger.info("onTaskResolve() non-syncFile task",{task:e,result:t,elapsedMs:i})})),u.set(this,((e,t)=>{this.logger.error("onTaskRejected()",{task:e,error:t})})),this.doneLatch.observe(h(this,r,"m",c).call(this)).catch((t=>{this.logger.error("SyncDirectory failed for "+e,{error:t}),(0,D.syncReport)().onProgress({path:e.nativePath,from:"SyncDirectory",state:t instanceof b.AbortError?"canceled":"failed",details:(0,M.errorToS)(t)})}))}upsertProgress(e){const t=h(this,r,"m",d).call(this,e);if(this.logger.info("upsertProgress()",{update:t}),null!=t){const e=this.progress().upsert(t);return this.upsertProgressMeta(),e}}scannedDirectoryCount(){return this.priorScannedDirsCount()+this.scannedDirsCount}ctx(){return{startAtNativePath:(0,B.map)(this.initialMeta()?.lastScannedDirectory,E.splitNativePath),hasCapacity:()=>U.TaskList.instance().hasCapacity(),fileHandler:this.fileHandler,directoryListener:this.directoryListener,ended:()=>(0,P.ending)()||this.ended}}earliestStartTime(){return this.progress().getLastIncompleteStartAt()??this.start}async maybeEnqueueStaleAssetFiles_(){if(!F.Settings.forceSync.valueOrDefault&&(0,L.isTrue)(this.priorMeta()?.enqueuedStaleFiles))this.logger.info("maybeEnqueueStaleAssetFiles() no-op: prior enqueuedStaleFiles.");else{const e=this.progress(),t=this.earliestStartTime(),i=U.TaskList.instance();this.logger.info("maybeEnqueueStaleAssetFiles() starting",{earliestStartTime:t});const r=Math.min(Math.round(F.Settings.taskListCap.valueOrDefault/4),F.Settings.dbBatchSelectSize.valueOrDefault),s=F.Settings.taskListCap.valueOrDefault-r;let n=0;await q.AssetFile.ops().batched({batchSize:r,onResults:async e=>{this.logger.throwIfAborted_(),await Promise.all(e.map((e=>e.getNativePath()))),J.Task.add(e.map((e=>({fn:"updateAssetFile",args:{path:e.nativePath,assetFileId:e.id,whyReject:"missed by directory sync"}})))),n+=e.length,await i.awaitDrain([],s)},qb:e=>e.select("id").whereLike("uri",this.rootUri+"%").andWhere("updatedAt","<",t)}),this.logger.info("maybeEnqueueStaleAssetFiles() finished enqueue",{assetFileQueuePendingCount:n}),e.setMeta($.ProgressMetaNames.enqueuedStaleFiles,"true")}}processedCount(){return this.processedImageCount()+this.processedVideoCount()}processedVideoCount(){return this.priorProcessedVideoCount()+h(this,a,"f")}processedImageCount(){return this.priorProcessedImageCount()+h(this,n,"f")}onFileResolved(e,t){var i,r;(0,C.isVideoExt)(e)?f(this,a,(i=h(this,a,"f"),++i),"f"):f(this,n,(r=h(this,n,"f"),++r),"f"),this.eta.push(t),this.upsertProgress()}get isScanning(){const e=h(this,o,"f").call(this);return null!=e&&!e.isDone()}estimatedScannedPct(){if(!this.isScanning)return 100;const e=100/-(this.scannedDirsCount/500+1)+100;return(0,j.sigFigs)(e,3)}percents(){if(this.completed||this.isDone())return{completePct:100,incompletePct:0,scanningPct:0};const e=(0,j.round)(this.estimatedScannedPct()),t=100-e,i=this.processedCount(),r=this.pendingCount(),s=0===r&&0===i?0:(0,j.round)(e*(i/(r+i))),n=100-(s+t),a={completePct:s,incompletePct:n,scanningPct:t};return this.logger.debug("percents(): ",{scannedPct:e,processed:i,pending:r,p:a}),100!==(0,x.sum)([a.completePct,a.incompletePct,a.scanningPct])&&this.logger.warn("percents(): BUGGED",{p:a,processed:i,pending:r,scannedPct:e,scanningPct:t,incompletePct:n,completePct:s}),a}}t.SyncDirectory=Y,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,r=new WeakSet,s=function(){J.Task.ee.off("resolved",h(this,l,"f")),J.Task.ee.off("rejected",h(this,u,"f"))},c=async function(){J.Task.ee.on("resolved",h(this,l,"f")),J.Task.ee.on("rejected",h(this,u,"f"));const e=this.initialMeta();this.logger.info("setup()",{meta:e});const t=U.TaskList.instance(),i=h(this,o,"f").call(this);if(null==i)this.logger.info("#run(): already completedDirectoryScan");else{this.logger.info("#run(): starting directory scan...");const e=Math.round(F.Settings.taskListCap.valueOrDefault),r=Math.max(2*(0,I.maxConcurrentImports)(),Math.round(F.Settings.taskListCap.valueOrDefault/2));for(;!i.isDone();)await this.awaitOrAbort((0,A.resolveOnResume)()),await i.next(w.ShortCommandTimeoutMs+Date.now()),t.hasCapacity(.9*e)||await this.awaitOrAbort(t.awaitDrain(["syncFile"],r));(0,D.syncReport)().onProgress({from:"SyncDirectory",state:"note",details:"Directory scan complete",path:this.root.nativePath,elapsedMs:Date.now()-this.start}),this.upsertProgress({force:!0})}await this.awaitOrAbort(t.awaitDrain()),(0,D.syncReport)().onProgress({from:"SyncDirectory",state:"note",details:"File imports complete: "+this.processedImageCount()+" images and "+this.processedVideoCount()+" videos",path:this.root.nativePath,elapsedMs:Date.now()-this.start}),await this.awaitOrAbort(this.maybeEnqueueStaleAssetFiles_()),await this.awaitOrAbort(t.awaitDrain()),this.ended||this.aborted||(this.logger.info("DONE! Marking Progress as complete and updating meta."),this.completed=!0,this.upsertProgress({force:!0,done:!0}))},d=function(e={}){const t=e.prior??{},i={},r=this.isDone()||(e.done??!1)||this.completed;if(!0!==e.force&&(0,j.gt)(t.updatedAt,Date.now()-R.secondMs))return;const s=U.TaskList.instance(),n=(0,A.isPaused)()||(0,P.ending)();i.state=r?"done":n?"paused":"processing";const a=s.pendingWorkCount();{const e=[];if(e.push((0,v.capitalize)(i.state)),!r&&a>0){const t=Math.min((0,I.maxConcurrentImports)(),a),i=this.eta.fmtEstimate(a/t);null!=i&&e.push(i)}i.hed=e.join(", ")}const o=[];this.processedCount()>0&&o.push("Processed "+(0,V.plur)(this.processedImageCount(),"photo")+" and "+(0,V.plur)(this.processedVideoCount(),"video")),!r&&a>0&&o.push((this.isScanning?"At least ":"")+(0,V.fmt)(a)+" remain to be processed"),r||n||!this.isScanning||o.push("Scanning "+(this.recentlyScannedDirs.shiftOrFirst()??this.root.nativePath)),this.scannedDirectoryCount()>0&&o.push("Scanned "+(0,V.plur)(this.scannedDirectoryCount(),"directory"));const l=s.currentTasksByFn("syncFile"),u=J.Task.nextByFn("syncFile",(e=>e.whereNotIn("id",l.map((e=>e.id))).limit(2)));return l.length>0&&o.push("Processing: "+(0,E.ellipsizePaths)({arr:l.map((e=>e.args.path)),maxPathLength:48,sampleSize:2})),u.length>0&&o.push("Queued: "+(0,E.ellipsizePaths)({arr:u.map((e=>e.args.path)),maxPathLength:48,sampleSize:2})),i.dek=o,(0,z.assignFields)(i,this.percents()),r&&(i.completedAt??(i.completedAt=Date.now())),this.logger.tap({msg:"#mkProgressUpdate()",level:"info",result:i})}},88204:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncFile=void 0;const a=i(83412),o=i(98314),l=i(74128),u=i(69385),c=i(49796),d=i(94710),h=i(76907);class f extends a.DoneWrapper{constructor(e){super("SyncFile: "+e),r.add(this),this.src=e,this.doneLatch.observe(n(this,r,"m",s).call(this)).catch((()=>{}))}}t.SyncFile=f,r=new WeakSet,s=async function(){await(0,u.resolveOnResume)();const e=await this.src.uri();if(null==e)return void(0,l.syncReport)().onProgress({path:this.src.nativePath,from:"SyncFile",state:l.SyncFileStates.rejected,details:"failed to build URI"});const t=c.Progress.insertNew({uri:e,volume:this.src.nativePath,state:"processing"});try{const[t]=await(0,h.precheckFiles)([this.src]);if(null!=t){const e=d.Task.addOne("syncFile",{path:this.src.nativePath});await e.donePromise()}else this.logger.info("syncFile: no-op",{uri:e})}catch(e){(0,l.syncReport)().onProgress({path:this.src.nativePath,from:"SyncFile",state:l.SyncFileStates.failed,details:(0,o.errorToS)(e)})}finally{t.upsert({state:"done",completedAt:Date.now()})}}},2387:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncManager=void 0;const a=i(83412),o=i(99331),l=i(98314),u=i(95696),c=i(74128),d=i(28874),h=i(98553),f=i(54993),m=i(98401),p=i(20958),g=i(76386),y=i(69032),w=i(56179),v=i(88204),b=i(92244),S=i(46832);class P extends a.DoneWrapper{constructor(){super("SyncManager"),r.add(this),this.doneLatch.observe(n(this,r,"m",s).call(this))}}t.SyncManager=P,r=new WeakSet,s=async function(){const e=d.Settings.argvScanPaths.toNotEmpty()??(d.Settings.exitWhenDone.valueOrDefault?[]:await(0,b.stalePathsToSync)());this.logger.info("#run starting",{paths:e});for(const t of e){this.logger.throwIfAborted_();const e=await(0,S.toUriPath)(t);try{null==e&&this.logger.throw("Could not convert to URI: "+(0,h.stringify)(t));const i=e.nativePath,r=u.PosixFile.forMaybe(i);null==r||null==e?(0,c.syncReport)().onProgress({path:i,from:"SyncManager",state:c.SyncFileStates.failed,details:"Cannot import: path could not be built."}):await r.isFile_()?(this.sync=new v.SyncFile(r),await this.sync.donePromise()):await r.isDirectory_()&&(this.sync=await w.SyncDirectory.for({root:r,rootUri:e.uri}),await(this.sync?.donePromise()))}catch(i){this.logger.info("Failed to sync path",{ea:t,error:i}),(0,c.syncReport)().onProgress({path:e?.nativePath??(0,f.toS)(t),from:"SyncManager",state:c.SyncFileStates.failed,details:(0,l.errorToS)(i)})}await(0,m.maybeCleanup_)(),await(0,y.runTagMaintenance)(),await g.tellWebProgressUpdated.refresh()}this.logger.info("#run complete",{paths:e}),p.Operation.markOpCompleted({name:"forceRestartSync"}),(0,o.ending)()||await(0,c.syncReport)().flushClose()}},92244:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syncPathsForUI=t.bestStable=t.isStale=t.bestPathToSync=t.stalePathsToSync=t.pathsAndTimesToSync=t.nativePathBlocklist=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(23560),o=i(22277),l=i(87290),u=i(57902),c=i(28874),d=i(40958),h=i(76790),f=i(42659),m=i(75240),p=i(31586),g=i(20958),y=i(49796),w=i(94019),v=i(98622),b=(0,s.lazy)((()=>(0,n.mkLogger)("sync.SyncPaths")));t.nativePathBlocklist=new o.TTLSet(10*f.minuteMs);const S=10*f.minuteMs;async function P(){const e=await(0,w.pathsToSync)(),t=c.Settings.forceSync.valueOrDefault?[]:await y.Progress.times();return b().tap({msg:"pathsAndTimesToSync()",level:u.LogLevels.info,result:e.map((e=>({...e,...t.find((t=>t.uri===e.uri))})))})}function M(e,t){return null==e.lastStartedAt||null==e.lastCompletedAt||(0,p.lte)(e.lastStartedAt,t)||(0,v.runTimeIsStale)(e.lastCompletedAt)}function _(){return g.Operation.getFirstPendingOp({name:g.OperationNames.forceRestartSync})}async function T(e){const t=_(),i=t?.createdAt,s=e.filter((e=>M(e,i)));if((0,d.isEmpty)(s))return(0,a.isSyncService)()&&t?.markCompleted(),b().tap({msg:"bestStable(): No stale paths to sync!",level:"info",result:void 0,meta:{arr:e,forceRestartOp:t}});{const e=(0,r.greatestBy)(s,(e=>e.lastUpdatedAt));if(null!=e&&(0,p.gt)(e.lastUpdatedAt,Date.now()-10*f.minuteMs))return b().tap({msg:"bestStable(): returning most recently updated",level:"info",result:{...e,why:"recently updated"}})}const n=(0,r.leastBy)(s,(e=>[e.lastStartedAt??0,e.lastCompletedAt??0]));return b().tap({msg:"bestStable(): returning least-recently-started or least-recently-completed:",level:"info",result:null==n?void 0:{...n,why:"least recently started or completed"},meta:{stale:s}})}function E(e,t){return null==e.lastStartedAt?"new":null==e.lastCompletedAt?"todo":(0,p.gt)(e.lastUpdatedAt,Date.now()-f.minuteMs)?"syncing":M(e,t)?"stale":"synced"}function D(e){return null==e?void 0:new Date(e).toISOString()}function k(e){if(null==e)return;const t=Date.now()-e;return t<2*f.secondMs?"just now":(0,m.fmtDuration)(t)+" ago"}t.pathsAndTimesToSync=P,t.stalePathsToSync=async function(){const e=await P(),t=_(),i=t?.createdAt,r=e.filter((e=>M(e,i)));return(0,h.sortBy)(r,(e=>[null!=e.lastUpdatedAt&&Date.now()-Se.nativePath)),t=await T(e),i=(0,l.libraryOriginalsDirPosixFile)()?.nativePath,r=_()?.createdAt;return e.map((e=>({path:e.nativePath,library:i===e.nativePath,status:E(e,r),isNext:e.nativePath===t?.nativePath,lastStartedISO:D(e.lastStartedAt),lastStarted:k(e.lastStartedAt),lastCompletedISO:D(e.lastCompletedAt),lastCompleted:k(e.lastCompletedAt)})))}},53767:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncService=void 0;const l=i(50213),u=i(7282),c=i(71567),d=i(78406),h=i(25764),f=i(38836),m=i(99331),p=i(45608),g=i(5916),y=i(73614),w=i(76596),v=i(8769),b=i(57159),S=i(63664),P=i(18454),M=i(21525),_=i(21473),T=i(41944),E=i(28874),D=i(2858),k=i(37692),x=i(93493),F=i(42659),C=i(45599),A=i(98553),I=i(98401),O=i(64526),L=i(37158),R=i(56992),N=i(35580),B=i(22968),j=i(63461),z=i(98622),V=i(2387);t.SyncService=class{constructor(){this.logger=(0,l.mkLogger)("SyncService"),r.set(this,void 0),s.set(this,(0,C.defer)((async()=>{await this.service.setup_(),this.logger.info("setup()",{library:E.Settings.libraryDir.valueOrDefault,exitWhenDone:this.exitWhenDone,argvScanPaths:E.Settings.argvScanPaths.values,scanPaths:E.Settings.scanPaths.values,skipLibraryRebuild:E.Settings.skipLibraryRebuild.valueOrDefault,argv:process.argv});const e=O.Library.instanceRequired_();await e.ready;const t=await(0,S.getRemoteOrLocalHealthSummary)();(0,M.isHealthCheckLevelFatal)(t.level)&&await(0,p.exit)({reason:"Health check failed: "+t.msg.join(": "),status:1}),await(0,D.maybeUpgradeSystemSettings)(),await(0,D.maybeUpgradeLibrarySettings)(),await(0,_.testSharp_)(),await(0,x.setupShimDelegates)(),(0,I.scheduleFileAndProcCleanups)(),N.TaskList.instance(),E.Settings.forceRebuildLibrary.valueOrDefault&&(this.logger.info("setup(): "+E.Settings.forceRebuildLibrary.key+" is true: setting all assets to require updates..."),(0,B.forceRebuildLibraryLater)()),(0,u.isTest)()&&T.onProgressEvt.setShim((async e=>console.log((0,A.stringify)(e)))),k.stateEvents.on("checkTasks",(()=>N.TaskList.instance().maybeRunChunk())),new d.EndableInterval({name:"SyncService.setVolumesTTL()",callback:()=>(0,R.setVolumesTTL)(),intervalMs:F.dayMs/4,initialDelayMs:5*F.minuteMs,rank:h.EndableRanks.first}),new f.EndableWrapper("SyncService end status",(async()=>this.logger.info("end status",await this.status())),h.EndableRanks.first),this.run()}))),n.set(this,(0,g.lazyAsync)({later:async()=>{if(this.logger.info(".run(): starting"),(0,I.scheduleFileAndProcCleanups)(),await(0,B.maybeRebuildLibrary)(),this.logger.info(".run(): finished library rebuild"),await(N.TaskList.instance()?.awaitDrain()),this.logger.info(".run(): finished task list drain"),o(this,r,new V.SyncManager,"f"),await a(this,r,"f").donePromise(),(0,u.isTest)()&&(0,c.stdoutWrite)(j.SyncCompleted),this.exitWhenDone)return(0,p.exit)({reason:"Finished",status:0});this.logger.info("SyncManager completed. Running cleanups..."),await(0,I.cleanup_)(),(0,I.cancelFileAndProcCleanups)();const e=(0,z.SyncCron)().nextRun();this.logger.info("nextRun",{nextRun:e});const t=e.getTime()-Date.now();this.logger.info("Scheduling next sync run for "+e.toISOString()+" ("+(0,w.durationHMS)(t)+" from now)",E.Settings.syncCron.addToEnv({})),(0,y.setUnrefTimeout)((()=>this.run()),t)}})),this.exitWhenDone=E.Settings.exitWhenDone.valueOrDefault||E.Settings.argvScanPaths.isNotEmpty(),this.service=new L.Service("sync"),a(this,s,"f").call(this).catch((e=>(0,v.onError)(new b.WrappedError("SyncService.setup() failed",{cause:e,fatal:!0}))))}async status(){const e=a(this,r,"f");return{libraryDir:E.Settings.libraryDir.value,ending:(0,m.ending)(),sync:e?.sync?.name,summary:P.HealthCheck.summary()}}run(){const e=a(this,n,"f").prior();return this.logger.info("run()",{prior_pending:e?.isPending}),null!=e&&e.isPending?(this.logger.warn(".run(): preventing overrun: prior run is still pending"),e):a(this,n,"f").refresh()}},r=new WeakMap,s=new WeakMap,n=new WeakMap},46832:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.posixFileToUriPath=t.toUriPath=void 0;const r=i(53265),s=i(45200),n=i(22573),a=i(68708),o=i(54993);async function l(e,t){if((0,a.isObject)(e)&&!(0,n.blank)(e.nativePath)&&!(0,n.blank)(e.uri))return e;const i=(0,r.resolve)((0,o.toS)(e)),l=await t??await(0,s.nativePath2uri)(i);return null==l?void 0:{nativePath:i,uri:l.toString()}}t.toUriPath=l,t.posixFileToUriPath=function(e){return l(e.nativePath,e.uriObject_())}},7656:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rebuildTagAssetCounts=t.DirectAssetCountForTagQuery=t.RecursiveAssetCountForTagQuery=t.nonLeafTagIds=void 0;const r=i(50213),s=i(56038),n=i(95704),a=i(38156),o=i(42659),l=i(45599),u=i(41400),c=i(31586),d=i(51926),h=(0,l.defer)((()=>(0,r.mkLogger)("tag.TagAssetCounts")));function f(e){return e.prepare((0,d.compressWhitespace)("SELECT"," t1.id,"," count(t2.id) AS cnt","FROM"," Tag t1"," JOIN Tag t2 ON t1.id = t2.parentId","GROUP BY"," 1","HAVING"," cnt > 0")).pluck().all()}async function m(e,i=[]){const r=e.prepare(t.RecursiveAssetCountForTagQuery).pluck(),o=e.prepare(t.DirectAssetCountForTagQuery).pluck(),l=e.prepare("UPDATE Tag SET assetCount = :assetCount, updatedAt = :updatedAt WHERE id = :tagId"),c=new Set(f(e)),d=new a.PushProgressObserver({op:"Rebuilding tag asset counts"},e.prepare("SELECT count(*) FROM Tag").pluck().get());await(0,n.withIdBatches)({db:e,tableName:"Tag",primaryKeyColumnName:"id",whereClauses:i,async fn(e){for(const t of e){const e=!c.has(t);(0,s.timeSync)("db.rebuildTagAssetCounts("+(e?"leaf":"cte")+")",(()=>{const s=(e?o:r).get({tagId:t});l.run({tagId:t,assetCount:s,updatedAt:Date.now()}),d.incrProgress(),h().debug("_rebuildTagAssetCounts()",{isLeaf:e,whereClauses:i,tagId:t,assetCount:s})})),t%10==0&&(h().throwIfAborted_(),await(0,u.delay)(1))}}}),d.completed()}t.nonLeafTagIds=f,t.RecursiveAssetCountForTagQuery=(0,d.compressWhitespace)("WITH RECURSIVE descendants(id) AS ("," VALUES (:tagId)"," UNION"," SELECT Tag.id"," FROM Tag, descendants"," WHERE Tag.parentId = descendants.id",")","SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," descendants"," JOIN AssetTag ON AssetTag.tagId = descendants.id"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL"),t.DirectAssetCountForTagQuery=(0,d.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," AssetTag"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," AssetTag.tagId = :tagId"," AND Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL;"),t.rebuildTagAssetCounts=async function(e,t=o.minuteMs){if(await(0,s.time)("db.rebuildNullTagAssetCounts",(()=>m(e,["assetCount IS NULL"]))),(0,c.gt0)(t)){const i=e.prepare("SELECT min(updatedAt) FROM Tag").pluck().get(),r=Date.now()-i;if(rm(e)))}},69032:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.displayNameForVolsha=t.fixFileRootTag=t.runTagMaintenance=t.forceRunTagMaintenance=t.tagFtsRebuild=void 0;const s=r(i(76760)),n=i(19851),a=i(50213),o=i(7282),l=i(409),u=i(1728),c=i(56038),d=i(34102),h=i(49076),f=i(69589),m=i(28874),p=i(42231),g=i(85087),y=i(98770),w=i(59107),v=i(63870),b=i(7014),S=i(22573),P=i(42659),M=i(41400),_=i(75240),T=i(31586),E=i(34666),D=i(51926),k=i(75020),x=i(54017),F=i(48723),C=i(98784),A=i(7656),I=(0,n.lazy)((()=>(0,a.mkLogger)("tag.TagSql")));t.tagFtsRebuild=(0,n.lazy)((()=>(0,c.time)("db.rebuildTagFts",(()=>C.TagFts.rebuild()))),10*P.minuteMs),t.forceRunTagMaintenance=async function(e={forceSync:!0,recountAllTags:!0}){return I().info("forceRunTagMaintenance()"),await t.runTagMaintenance.force(e)};const O=((0,o.isTest)()?5:30)*P.secondMs;t.runTagMaintenance=(0,l.rateLimited)({name:"runTagMaintenance",minCallDelayMs:O,f:async e=>{const i=(0,f.forceContextOrSetting)(e),r=Date.now(),s=I().addContext(".runTagMaintenance()");s.info("starting",{ctx:i});try{s.info("validating all tags..."),F.Tag.validate_(),s.throwIfAborted_(i?.halt),await L(),i.recountAllTags&&(s.info("rebuilding tag search index..."),await(0,t.tagFtsRebuild)(),s.info("rebuilding tag asset counts..."),await(0,A.rebuildTagAssetCounts)(F.Tag.dbl.db().db,0))}catch(e){I().warn("runTagMaintenance() failed",e)}const n=Date.now()-r,a=(0,T.clamp)(O,15*P.minuteMs,20*n);t.runTagMaintenance.setMinCallDelayMs(a),I().info("runTagMaintenance(): complete.",{newMinCallDelayMs:a,elapsedMs:n})}});const L=(0,y.lazyFsAsync)("updateTagMountpoints",(async()=>{I().info("updating tag mountpoints...");const e=F.Tag.findByPath([k.TagRoots.fs]);if(null!=e){e.maybeUpsertDisplayName(m.Settings.tagDisplayNameFS.valueOrDefault);for(const t of e.getChildren())await N(t)}else(0,a.mkLogger)("updateTagMountpoints()").info("No root filesystem tag (new db, I hope?)")}));function R(){t.tagFtsRebuild.unset(),L.unset()}async function N(e){if(null==e||2!==e.depth||!e._path.startsWith(k.TagRoots.fs+p.TagSep))return;const i=(0,a.mkLogger)("fixFileRootTag("+e+")");if(e.name===k.LibraryTagName)return void(1!==e.ordinal&&(i.info("fixing library ordinal",{id:e.id,path:e.path}),e.upsert({ordinal:1}),F.Tag.clear()));if((0,f.forceContextOrSetting)().forceSync&&(0,S.notBlank)(e.displayName)&&(0,E.gt)(e.updatedAt,Date.now()-(0,v.volumeMetadataTtlMs)()))return void i.info("no-op: tag recently updated",{id:e.id,path:e.path,updated:(0,_.fmtDuration)(Date.now()-e.updatedAt)+" ago"});const r=await(0,t.displayNameForVolsha)(e.name);(0,S.notBlank)(r)?(e.maybeUpsertDisplayName(r),i.info("updated tag",{id:e.id,path:e.path,displayName:r}),F.Tag.clear()):i.debug("cannot update tag: no current volume.",{id:e.id,path:e.path})}(0,M.later)((()=>{(0,d.ee)().on("clearCache",R),m.Settings.libraryDir.watchLater(R)})),t.fixFileRootTag=N,t.displayNameForVolsha=(0,u.memoizeAsync)((async e=>{const t=(0,a.mkLogger)("displayNameForVolsha("+e+")"),i=await(0,b.volumes)();if(null!=i){const r=i.find((t=>(0,g.volsha)(t.uuid)===e));return t.info("find()",{vol:r}),null!=r?m.Settings.tagDisplayNameFSLabels.valueOrDefault&&(0,S.notBlank)(r.label)?r.label.trim():"/"===r.mountpoint?m.Settings.tagDisplayNameFSRoot.valueOrDefault+(m.Settings.tagDisplayNameFSRootWithHostname.valueOrDefault?" on "+(0,h.hostname)():""):(0,S.notBlankOr)((0,D.stripPrefixSuffix)(r.mountpoint,{prefix:s.default.sep,suffix:s.default.sep}),s.default.sep):x.AssetFile.dbl.pluckFirstf((t=>t.select("mountpoint").whereLike("uri","psfile://"+e+"/%").limit(1)))}}),{name:"tag.displayNameForVolsha",maxSize:64,timeoutMs:(0,v.volumeMetadataTtlMs)()}),(0,M.later)((()=>{w.mountpoints.watch((()=>t.displayNameForVolsha.clear()))}))},90858:e=>{"use strict";e.exports=require("@iarna/toml")},53705:e=>{"use strict";e.exports=require("@photostructure/tz-lookup")},16436:e=>{"use strict";e.exports=require("@sentry/node")},64770:e=>{"use strict";e.exports=require("assert")},58587:e=>{"use strict";e.exports=require("batch-cluster")},87550:e=>{"use strict";e.exports=require("better-sqlite3")},6858:e=>{"use strict";e.exports=require("commander")},36507:e=>{"use strict";e.exports=require("croner")},66261:e=>{"use strict";e.exports=require("events")},77988:e=>{"use strict";e.exports=require("exiftool-vendored")},66150:e=>{"use strict";e.exports=require("fast-xml-parser")},68817:e=>{"use strict";e.exports=require("file-type")},44652:e=>{"use strict";e.exports=require("fs-extra")},28787:e=>{"use strict";e.exports=require("he")},31832:e=>{"use strict";e.exports=require("knex")},51168:e=>{"use strict";e.exports=require("luxon")},93973:e=>{"use strict";e.exports=require("ml-kmeans")},4927:e=>{"use strict";e.exports=require("papaparse")},83058:e=>{"use strict";e.exports=require("picomatch")},57272:e=>{"use strict";e.exports=require("plist")},85949:e=>{"use strict";e.exports=require("process")},90595:e=>{"use strict";e.exports=require("punycode")},38064:e=>{"use strict";e.exports=require("semver")},9288:e=>{"use strict";e.exports=require("sharp")},93944:e=>{"use strict";e.exports=require("source-map-support")},49378:e=>{"use strict";e.exports=require("trash")},73872:e=>{"use strict";e.exports=require("type-detect")},92460:e=>{"use strict";e.exports=require("util")},75162:e=>{"use strict";e.exports=require("util/types")},29907:e=>{"use strict";e.exports=require("cluster")},76982:e=>{"use strict";e.exports=require("crypto")},34589:e=>{"use strict";e.exports=require("node:assert")},31421:e=>{"use strict";e.exports=require("node:child_process")},77598:e=>{"use strict";e.exports=require("node:crypto")},40610:e=>{"use strict";e.exports=require("node:dns")},78474:e=>{"use strict";e.exports=require("node:events")},73024:e=>{"use strict";e.exports=require("node:fs")},51455:e=>{"use strict";e.exports=require("node:fs/promises")},37067:e=>{"use strict";e.exports=require("node:http")},44708:e=>{"use strict";e.exports=require("node:https")},77030:e=>{"use strict";e.exports=require("node:net")},48161:e=>{"use strict";e.exports=require("node:os")},76760:e=>{"use strict";e.exports=require("node:path")},53916:e=>{"use strict";e.exports=require("node:path/posix")},1708:e=>{"use strict";e.exports=require("node:process")},57075:e=>{"use strict";e.exports=require("node:stream")},46466:e=>{"use strict";e.exports=require("node:stream/promises")},87997:e=>{"use strict";e.exports=require("node:timers")},57975:e=>{"use strict";e.exports=require("node:util")},38522:e=>{"use strict";e.exports=require("node:zlib")},16928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=34742);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/bin/web.js b/bin/web.js index e5372bd..594114d 100755 --- a/bin/web.js +++ b/bin/web.js @@ -6,4 +6,4 @@ * IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THIS SOFTWARE */ -(()=>{var __webpack_modules__={60308:e=>{const t={PasetoNotSupported:"ERR_PASETO_NOT_SUPPORTED",PasetoDecryptionFailed:"ERR_PASETO_DECRYPTION_FAILED",PasetoInvalid:"ERR_PASETO_INVALID",PasetoVerificationFailed:"ERR_PASETO_VERIFICATION_FAILED",PasetoClaimInvalid:"ERR_PASETO_CLAIM_INVALID"};class i extends Error{constructor(e){super(e),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}e.exports.PasetoError=i,e.exports.PasetoNotSupported=class extends i{},e.exports.PasetoDecryptionFailed=class extends i{},e.exports.PasetoInvalid=class extends i{},e.exports.PasetoVerificationFailed=class extends i{},e.exports.PasetoClaimInvalid=class extends i{}},78972:(e,t,i)=>{const{PasetoInvalid:r,PasetoNotSupported:s}=i(60308),{decode:n}=i(47859),a=i(40816);e.exports=(e,{parse:t=!0}={})=>{if("string"!=typeof e)throw new TypeError("token must be a string");const{0:i,1:o,2:l,3:u,length:c}=e.split(".");if(3!==c&&4!==c)throw new r("token is not a PASETO formatted value");if("v1"!==i&&"v2"!==i&&"v3"!==i&&"v4"!==i)throw new s("unsupported PASETO version");if("local"!==o&&"public"!==o)throw new s("unsupported PASETO purpose");const d={footer:u?n(u):void 0,payload:void 0,version:i,purpose:o};if("local"===o)return d;const h="v1"===i?256:"v3"===i?96:64;let f;try{f=n(l).subarray(0,-h)}catch{throw new r("token is not a PASETO formatted value")}return d.payload=t?a(f):f,d}},2744:(e,t,i)=>{const r=i(78972);e.exports={decode:r}},67814:(e,t,i)=>{const r=i(85223);e.exports=({audience:e,expiresIn:t,iat:i=!0,issuer:s,jti:n,kid:a,notBefore:o,now:l=new Date,subject:u},c)=>{if(!(l instanceof Date&&l.getTime()))throw new TypeError("options.now must be a valid Date object");const d=l.getTime();if(void 0!==i){if("boolean"!=typeof i)throw new TypeError("options.iat must be a boolean");i&&(c.iat=new Date(d))}if(void 0!==t){if("string"!=typeof t)throw new TypeError("options.expiresIn must be a string");c.exp=new Date(d+r(t))}if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.notBefore must be a string");c.nbf=new Date(d+r(o))}if(void 0!==e){if("string"!=typeof e)throw new TypeError("options.audience must be a string");c.aud=e}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.issuer must be a string");c.iss=s}if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.subject must be a string");c.sub=u}if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.kid must be a string");c.kid=a}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.jti must be a string");c.jti=n}return c}},10968:(e,t,i)=>{const{PasetoClaimInvalid:r}=i(60308),s=i(85223);e.exports=({ignoreExp:e,ignoreNbf:t,ignoreIat:i,maxTokenAge:n,subject:a,issuer:o,clockTolerance:l,audience:u,now:c=new Date},d)=>{if(!(c instanceof Date&&c.getTime()))throw new TypeError("options.now must be a valid Date object");const h=c.getTime();if("iss"in d&&"string"!=typeof d.iss)throw new r("payload.iss must be a string");if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.issuer must be a string");if(d.iss!==o)throw new r("issuer mismatch")}if("sub"in d&&"string"!=typeof d.sub)throw new r("payload.sub must be a string");if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.subject must be a string");if(d.sub!==a)throw new r("subject mismatch")}if("aud"in d&&"string"!=typeof d.aud)throw new r("payload.aud must be a string");if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.audience must be a string");if(d.aud!==u)throw new r("audience mismatch")}if(void 0!==l&&"string"!=typeof l)throw new TypeError("options.clockTolerance must be a string");const f=l?s(l):0;let m;if("iat"in d){if("string"!=typeof d.iat)throw new r("payload.iat must be a string");if(m=new Date(d.iat).getTime(),!m)throw new r("payload.iat must be a valid ISO8601 string");if(!i&&m>h+f)throw new r("token issued in the future")}if("nbf"in d){if("string"!=typeof d.nbf)throw new r("payload.nbf must be a string");const e=new Date(d.nbf).getTime();if(!e)throw new r("payload.nbf must be a valid ISO8601 string");if(!t&&e>h+f)throw new r("token is not active yet")}if("exp"in d){if("string"!=typeof d.exp)throw new r("payload.exp must be a string");const t=new Date(d.exp).getTime();if(!t)throw new r("payload.exp must be a valid ISO8601 string");if(!e&&t<=h-f)throw new r("token is expired")}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.maxTokenAge must be a string");if(!("iat"in d))throw new r("missing iat claim");if(m+s(n){e.exports.encode=e=>e.toString("base64url"),e.exports.decode=e=>Buffer.from(e,"base64")},80608:e=>{e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if("string"!=typeof e)throw new TypeError("options.assertion must be a string, or a Buffer");return Buffer.from(e,"utf8")}},83561:(e,t,i)=>{const r=i(65825);e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if(r(e))return Buffer.from(JSON.stringify(e),"utf8");if("string"!=typeof e)throw new TypeError("options.footer must be a string, Buffer, or a plain object");return Buffer.from(e,"utf8")}},1658:(e,t,i)=>{const r=i(67814),s=i(65825);e.exports=(e,t)=>{if(Buffer.isBuffer(e)){if(0!==Object.keys(t).length)throw new TypeError("options cannot contain claims when payload is a Buffer");return e}if(!s(e))throw new TypeError("payload must be a Buffer or a plain object");return e=(e=>JSON.parse(JSON.stringify(e)))(e),e=r(t,e),Buffer.from(JSON.stringify(e),"utf-8")}},82115:e=>{e.exports=e=>{const{x:t,y:i}=e.export({format:"jwk"}),r=Buffer.from(i,"base64"),s=2+(1&r[r.length-1]);return Buffer.concat([Buffer.alloc(1,s),Buffer.from(t,"base64")])}},88965:(e,t,i)=>{const r=i(64770),{PasetoInvalid:s}=i(60308),n=i(10968),{decode:a}=i(47859),o=i(40816);e.exports={post:function(e,t,i,r,s,a,l){if(t){if(0!==Object.keys(i).length)throw new TypeError("options cannot contain claims when options.buffer is true");return r?{payload:s,footer:a?.length?a:void 0,version:e,purpose:l}:s}const u=o(s);return n(i,u),r?{payload:u,footer:a?.length?a:void 0,version:e,purpose:l}:u},pre:function(e,t){if("string"!=typeof t)throw new TypeError("token must be a string, got: "+typeof t);if(t.slice(0,e.length)!==e)throw new s(`token is not a ${e.slice(0,e.length-1)} PASETO`);let{0:i,1:n="",length:o}=t.slice(e.length).split(".");try{r(o<=2),i=a(i),n=a(n)}catch{throw new s("token is not a PASETO formatted value")}return{raw:i,f:n}}}},56463:(e,t,i)=>{const r=i(76982),s=i(92460),n=i(70761),a=i(29534),{PasetoDecryptionFailed:o}=i(60308),l=i(82682),{webcrypto:{subtle:u}}=r,c=s.promisify(r.hkdf),d=Buffer.from("paseto-encryption-key"),h=Buffer.from("paseto-auth-key-for-aead"),f=Buffer.alloc(0),m=(e,t)=>r.createHmac("sha384",t).update(e).digest(),p=async(e,t,i,r)=>u[e]({name:"AES-CTR",counter:r,length:16},await u.importKey("raw",i,"AES-CTR",!1,[e]),t).then(Buffer.from),g=p.bind(void 0,"encrypt"),y=p.bind(void 0,"decrypt");e.exports={sign:s.promisify(r.sign),verify:s.promisify(r.verify),"v1.local-encrypt":async function(e,t,i){const s="v1.local.",o=m(e,r.randomBytes(32)).subarray(0,32),l=o.subarray(0,16),[u,f]=await Promise.all([c("sha384",i,l,d,32).then(Buffer.from),c("sha384",i,l,h,32).then(Buffer.from)]),p=await g(e,u,o.subarray(16)),y=n(s,o,p,t),v=m(y,f);return a(s,t,o,p,v)},"v1.local-decrypt":async function(e,t,i){const r=e.subarray(0,32),s=e.subarray(-48),a=e.subarray(32,-48),u=r.subarray(0,16),[f,p]=await Promise.all([c("sha384",i,u,d,32).then(Buffer.from),c("sha384",i,u,h,32).then(Buffer.from)]),g=n("v1.local.",r,a,t),v=m(g,p);if(!l(s,v))throw new o("decryption failed");const w=await y(a,f,r.subarray(16));if(!w)throw new o("decryption failed");return w},"v3.local-encrypt":async function(e,t,i,s){const o="v3.local.",l=r.randomBytes(32),[u,p]=await Promise.all([c("sha384",i,f,Buffer.concat([d,l]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,l]),48).then(Buffer.from)]),y=u.subarray(0,32),v=u.subarray(32),w=await g(e,y,v),b=n(o,l,w,t,s),S=m(b,p);return a(o,t,l,w,S)},"v3.local-decrypt":async function(e,t,i,r){const s=e.subarray(0,32),a=e.subarray(-48),u=e.subarray(32,-48),[p,g]=await Promise.all([c("sha384",i,f,Buffer.concat([d,s]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,s]),48).then(Buffer.from)]),v=p.subarray(0,32),w=p.subarray(32),b=n("v3.local.",s,u,t,r),S=m(b,g);if(!l(a,S))throw new o("decryption failed");const P=await y(u,v,w);if(!P)throw new o("decryption failed");return P}}},70981:(e,t,i)=>{const{KeyObject:r}=i(76982);let{isKeyObject:s}=i(75162);s||(s=e=>null!=e&&e instanceof r),e.exports=s},65825:e=>{e.exports=e=>!!e&&e.constructor===Object},41726:(e,t,i)=>{const{PasetoNotSupported:r}=i(60308);e.exports=e=>{if(!Number.isSafeInteger(e))throw new r("message is too long for Node.js to safely process");const t=~~(e/4294967295),i=e%4294967295-t,s=Buffer.allocUnsafe(8);return s.writeUInt32LE(t,4),s.writeUInt32LE(i,0),s}},85223:e=>{const t=36e5,i=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;e.exports=e=>{const r=i.exec(e);if(!r)throw new TypeError(`invalid time period format ("${e}")`);const s=parseFloat(r[1]);switch(r[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(1e3*s);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(6e4*s);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(s*t);case"day":case"days":case"d":return Math.round(864e5*s);case"week":case"weeks":case"w":return Math.round(6048e5*s);case"year":case"years":case"yr":case"yrs":case"y":return Math.round(315576e5*s)}}},29534:(e,t,i)=>{const{encode:r}=i(47859);e.exports=function(e,t,...i){let s=`${e}${r(Buffer.concat(i))}`;return t.byteLength&&(s+=`.${r(t)}`),s}},70761:(e,t,i)=>{const r=i(41726);e.exports=(...e)=>{e=e.filter(Boolean);let t=r(e.length);for(let i of e){i=Buffer.from(i,"utf8");const e=r(Buffer.byteLength(i));t=Buffer.concat([t,e,i])}return t}},40816:(e,t,i)=>{const{PasetoInvalid:r}=i(60308),{strict:s}=i(64770),n=i(65825);e.exports=e=>{try{const t=JSON.parse(e);return s(n(t)),t}catch{throw new r("All PASETO payloads MUST be a JSON object")}}},92366:(e,t,i)=>{const{sign:r}=i(56463),s=i(70761),n=i(29534);e.exports=async function(e,t,i,a,o,l,u){const c=s(u,e,t,i,l),d=await r(a,c,o);return n(e,i,t,d)}},495:(e,t,i)=>{const{createSecretKey:r}=i(76982),s=i(70981);e.exports=function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}`)&&(t=Buffer.from(t.slice(e.length),"base64url")),!s(t))try{t=r(t)}catch{}if(!s(t))throw new TypeError("invalid key provided");if("secret"!==t.type||32!==t.symmetricKeySize)throw new TypeError(`${e} secret key must be 32 bytes long symmetric key`);return t}},82682:(e,t,i)=>{const{timingSafeEqual:r}=i(76982),s=(e,t)=>{if(e.length===t)return e;const i=Buffer.alloc(t);return e.copy(i),i};e.exports=(e,t)=>{const i=Math.max(e.length,t.length);return r(s(e,i),s(t,i))}},49826:(e,t,i)=>{const{PasetoVerificationFailed:r}=i(60308),{verify:s}=i(56463),n=i(70761),{pre:a}=i(88965);e.exports=async function(e,t,i,o,l,u,c){const{raw:d,f:h}=a(e,t),f=d.subarray(0,-o),m=d.subarray(-o),p=n(c,e,f,h,u);if(!await s(i,p,l,m))throw new r("invalid signature");return{m:f,footer:h.length?h:void 0}}},91227:(e,t,i)=>{const r=i(60308),s=i(79665),n=i(56120),a=i(50015),o=i(64230),{decode:l}=i(2744);e.exports={decode:l,V1:s,V2:n,V3:a,V4:o,errors:r}},39324:(e,t,i)=>{const{"v1.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v1.local"),{pre:n,post:a}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:o=!1,...l}={}){const{raw:u,f:c}=n("v1.local.",e),d=(t=s(t)).export(),h=await r(u,c,d);return a("v1",o,l,i,h,c,"local")}},21472:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v1.local"),n=i(1658),{"v1.local-encrypt":a}=i(56463);e.exports=async function(e,t,{footer:i,...o}={}){const l=n(e,o);t=s(t);const u=r(i),c=t.export();return a(l,u,c)}},79665:(e,t,i)=>{const r=i(77868),s=i(77256),n=i(21472),a=i(39324),o=i(70866);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o}},70866:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=s(r.generateKeyPair),o=s(r.generateKey);e.exports=async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await o("aes",{length:256});return"paserk"===t?`k1.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await a("rsa",{modulusLength:2048});return"paserk"===t?{secretKey:`k1.secret.${e.export({format:"der",type:"pkcs1"}).toString("base64url")}`,publicKey:`k1.public.${i.export({format:"der",type:"pkcs1"}).toString("base64url")}`}:e}default:throw new n("unsupported v1 purpose")}}},77868:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPrivateKey:n}=i(76982),a=i(83561),o=i(1658),l=i(92366),u=i(70981);e.exports=async function(e,t,{footer:i,...c}={}){const d=o(e,c),h=a(i);return t=function(e){if("string"==typeof e&&e.startsWith("k1.secret."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!u(e))try{e=n(e)}catch{}if(!u(e))throw new TypeError("invalid key provided");if("private"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public signing key must be a private RSA key with 2048 bit modulus length");return e}(t),l("v1.public.",d,h,"sha384",{key:t,padding:r,saltLength:s})}},77256:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPublicKey:n}=i(76982),a=i(49826),o=i(70981),{post:l}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:u=!1,...c}={}){t=function(e){if("string"==typeof e&&e.startsWith("k1.public."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!o(e)||"private"===e.type)try{e=n(e)}catch{}if(!o(e))throw new TypeError("invalid key provided");if("public"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public verify key must be a public RSA key with 2048 bit modulus length");return e}(t);const{m:d,footer:h}=await a("v1.public.",e,"sha384",256,{key:t,padding:r,saltLength:s});return l("v1",u,c,i,d,h,"public")}},56120:(e,t,i)=>{const r=i(88451),s=i(859),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(62827);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},62827:(e,t,i)=>{const r=i(64770),s=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:a}=i(60308),o=i(70981),l=n(s.generateKeyPair);async function u(e,t,{format:i="keyobject"}={}){if("keyobject"!==i&&"paserk"!==i)throw new TypeError("invalid format");if("public"===t){const{privateKey:t,publicKey:r}=await l("ed25519");return"paserk"===i?{secretKey:`k${e.slice(1)}.secret.${h(t).toString("base64url")}`,publicKey:`k${e.slice(1)}.public.${h(r).toString("base64url")}`}:t}throw new a(`unsupported ${e} purpose`)}function c(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 64:{const t=s.createPrivateKey({key:Buffer.concat([Buffer.from("302e020100300506032b657004220420","hex"),e.subarray(0,32)]),format:"der",type:"pkcs8"});if(!e.subarray(32).equals(Buffer.from(t.export({format:"jwk"}).x,"base64")))throw new TypeError("invalid byte sequence");return t}case 32:return s.createPublicKey({key:Buffer.concat([Buffer.from("302a300506032b6570032100","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 64 bytes (private key), or 32 bytes (public key)")}}function d(e,t){if(!o(t))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public key must be an Ed25519 key`);switch(t.type){case"public":return Buffer.from(t.export({format:"jwk"}).x,"base64");case"private":{const{d:e,x:i}=t.export({format:"jwk"});return Buffer.concat([Buffer.from(e,"base64"),Buffer.from(i,"base64")])}}}function h(...e){return d("v2",...e)}e.exports={_checkPrivateKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.secret.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,64)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t))try{t=s.createPrivateKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("private"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public signing key must be a private ed25519 key`);return t},_checkPublicKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.public.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,32)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t)||"private"===t.type)try{t=s.createPublicKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("public"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public verify key must be a public ed25519 key`);return t},_generateKey:u,_keyObjectToBytes:d,bytesToKeyObject:c,generateKey:async function(...e){return u("v2",...e)},keyObjectToBytes:h}},88451:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(92366),{_checkPrivateKey:a}=i(62827),o=a.bind(void 0,"v2");e.exports=async function(e,t,{footer:i,...a}={}){const l=s(e,a);t=o(t);const u=r(i);return n("v2.public.",l,u,void 0,t)}},859:(e,t,i)=>{const r=i(49826),{_checkPublicKey:s}=i(62827),{post:n}=i(88965),a=s.bind(void 0,"v2");e.exports=async function(e,t,{complete:i=!1,buffer:s=!1,...o}={}){t=a(t);const{m:l,footer:u}=await r("v2.public.",e,void 0,64,t);return n("v2",s,o,i,l,u,"public")}},18582:(e,t,i)=>{const{"v3.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v3.local"),n=i(80608),{pre:a,post:o}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:l=!1,assertion:u,...c}={}){const{raw:d,f:h}=a("v3.local.",e);t=s(t);const f=n(u),m=t.export(),p=await r(d,h,m,f);return o("v3",l,c,i,p,h,"local")}},43406:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v3.local"),n=i(1658),a=i(80608),{"v3.local-encrypt":o}=i(56463);e.exports=async function(e,t,{footer:i,assertion:l,...u}={}){const c=n(e,u);t=s(t);const d=r(i),h=a(l),f=t.export();return o(c,d,f,h)}},50015:(e,t,i)=>{const r=i(42438),s=i(65466),n=i(43406),a=i(18582),{generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}=i(80568);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}},80568:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=i(70981),o=i(82115),l=s(r.generateKeyPair),u=s(r.generateKey);function c(e){if(!a(e))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public key must be an EC P-384 key");switch(e.type){case"public":return o(e);case"private":return Buffer.from(e.export({format:"jwk"}).d,"base64")}}e.exports={generateKey:async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await u("aes",{length:256});return"paserk"===t?`k3.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await l("ec",{namedCurve:"P-384"});return"paserk"===t?{secretKey:`k3.secret.${c(e).toString("base64url")}`,publicKey:`k3.public.${c(i).toString("base64url")}`}:e}default:throw new n("unsupported v3 purpose")}},bytesToKeyObject:function(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 48:return r.createPrivateKey({key:Buffer.concat([Buffer.from("303e0201010430","hex"),e,Buffer.from("a00706052b81040022","hex")]),format:"der",type:"sec1"});case 49:if(2!==e[0]&&3!==e[0])throw new TypeError("invalid compressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3046301006072a8648ce3d020106052b81040022033200","hex"),e]),format:"der",type:"spki"});case 97:if(4!==e[0])throw new TypeError("invalid uncompressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3076301006072a8648ce3d020106052b81040022036200","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 48 bytes (private key), 49 bytes (compressed public key), or 97 bytes (uncompressed public key)")}},keyObjectToBytes:c}},42438:(e,t,i)=>{const{createPrivateKey:r}=i(76982),s=i(83561),n=i(1658),a=i(80608),o=i(92366),l=i(70981),{bytesToKeyObject:u}=i(80568),c=i(82115);e.exports=async function(e,t,{footer:i,assertion:d,...h}={}){const f=n(e,h),m=s(i),p=a(d);return t=function(e){if("string"==typeof e&&e.startsWith("k3.secret."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,48)}catch{}if(Buffer.isBuffer(e))try{e=u(e)}catch{}if(!l(e))try{e=r(e)}catch{}if(!l(e))throw new TypeError("invalid key provided");if("private"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public signing key must be a private EC P-384 key");return e}(t),o("v3.public.",f,m,"sha384",{key:t,dsaEncoding:"ieee-p1363"},p,c(t))}},65466:(e,t,i)=>{const{createPublicKey:r}=i(76982),s=i(80608),n=i(49826),a=i(70981),{bytesToKeyObject:o}=i(80568),l=i(82115),{post:u}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:c=!1,assertion:d,...h}={}){t=function(e){if("string"==typeof e&&e.startsWith("k3.public."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,49)}catch{}if(Buffer.isBuffer(e))try{e=o(e)}catch{}if(!a(e)||"private"===e.type)try{e=r(e)}catch{}if(!a(e))throw new TypeError("invalid key provided");if("public"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public verify key must be a public EC P-384 key");return e}(t);const f=s(d),{m,footer:p}=await n("v3.public.",e,"sha384",96,{key:t,dsaEncoding:"ieee-p1363"},f,l(t));return u("v3",c,h,i,m,p,"public")}},64230:(e,t,i)=>{const r=i(29901),s=i(77933),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(24961);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},24961:(e,t,i)=>{const{_checkPrivateKey:r,_checkPublicKey:s,_generateKey:n,_keyObjectToBytes:a,bytesToKeyObject:o}=i(62827);e.exports={_checkPrivateKey:r,_checkPublicKey:s,bytesToKeyObject:o,generateKey:async function(...e){return n("v4",...e)},keyObjectToBytes:function(...e){return a("v4",...e)}}},29901:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(80608),a=i(92366),{_checkPrivateKey:o}=i(24961),l=o.bind(void 0,"v4");e.exports=async function(e,t,{footer:i,assertion:o,...u}={}){const c=s(e,u),d=n(o);t=l(t);const h=r(i);return a("v4.public.",c,h,void 0,t,d)}},77933:(e,t,i)=>{const r=i(80608),s=i(49826),{_checkPublicKey:n}=i(24961),{post:a}=i(88965),o=n.bind(void 0,"v4");e.exports=async function(e,t,{complete:i=!1,buffer:n=!1,assertion:l,...u}={}){t=o(t);const c=r(l),{m:d,footer:h}=await s("v4.public.",e,void 0,64,t,c);return a("v4",n,u,i,d,h,"public")}},37975:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),s=i(38639),n=i(44198);function a(){return(0,s.toNotBoolean)((0,n.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,n.env)().NO_COLOR)||["dumb","unknown"].includes((0,n.env)().TERM))}t.noColor=a;let o=!a();function l(){return o}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){o=e??!a()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),s=i(7282),n=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,s.isProd)()?"":`-${(0,s.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+n.version))},48884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),s=i(36783),n=i(76790),a=i(22573),o=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const s=new Set(t.map(i));return e.filter((e=>s.has(i(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...v(e.slice(i+1))]}function w(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function b(e){return P(e,(e=>e.valueOf()))}function S(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function T(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,i){return E(e,t,i).index}function E(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let s,n=-1;for(let r=0;re.slice(i,i+t)))}async function D(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,o.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(a.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,o.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,s.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let s=0;for(const n of e)(t(n,s++)?i:r).push(n);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let s=0;se.slice(0,t+1)))},t.min=function(e){return e[b(e)]},t.leastIndex=b,t.max=function(e){return e[S(e)]},t.greatestIndex=S,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=T,t.least=function(e){return T(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const i=E(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=k,t.collectBatched=function(e,t,i){const s=[];for(const n of k((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(i(n)));return s},t.collectBatchedAsync=async function(e,t,i){const s=[];for(const n of k((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(await i(n)));return s},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await D(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+s;if(re+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const o=i(77988),l=a(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),v=i(25764),w=i(38836),b=i(99331),S=i(95937),P=i(98314),_=i(38835),T=i(70025),M=i(8769),E=i(43334),k=i(95402),D=i(28874),x=i(63870);class C extends w.EndableWrapper{constructor(e,t,i=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>n(this,r,"m",s).call(this)),i,"worker"===e?(0,x.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const a=t;a.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,k.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),a.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),a.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,S.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),a.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),a.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),a.on("noTaskData",((e,i,r)=>{const s=t.options.streamFlushMillis;s{this.logger.error("observeBatchCluster.endError()",e)})),a.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&k.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof o.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,b.ending)()||!0===(0,T.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=C,r=new WeakSet,s=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(E.isWin?3:1)*c.minuteMs,maxTasksPerProcess:D.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:D.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:D.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:D.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:D.Settings.taskTimeoutMs.valueOrDefault}}},71371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedGreatestSet=void 0;const r=i(92322);t.BoundedGreatestSet=class{constructor(e,t){this.maxLength=e,this.toValue=t,this.sortedArray=new r.SortedSet(t)}toA(){return this.vacuum(),this.sortedArray.toA()}vacuum(){return this.sortedArray.retainLastN(this.maxLength)}add(...e){this.maxLength<=0||(this.sortedArray.addAll(...e),this.sortedArray.length>=2*this.maxLength&&this.vacuum())}}},89788:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(r.add(this),this.maxLength=e,s.set(this,void 0),n.set(this,0),a.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,s,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]=t))}get length(){return u(this,n,"f")}set length(e){l(this,n,(0,d.clamp)(0,u(this,n,"f"),e),"f")}clear(){this.length=0}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,n,"f")),e<0||e>=u(this,n,"f")?void 0:t((e+u(this,a,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,s,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,n,"f"){u(this,s,"f")[e]=c}));return u(this,n,"f")}pop(){return u(this,r,"m",o).call(this,u(this,n,"f")-1,(e=>{var t;return l(this,n,(t=u(this,n,"f"),--t),"f"),u(this,s,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,n,"f"){u(this,s,"f")[e]=c,l(this,a,e,"f")}));return u(this,n,"f")}shift(){return u(this,r,"m",o).call(this,0,(e=>{var t,i;return l(this,a,(t=u(this,a,"f"),++t),"f"),l(this,n,(i=u(this,n,"f"),--i),"f"),u(this,s,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",o).call(this,u(this,n,"f")-1-e,(e=>{const i=u(this,s,"f")[e];u(this,s,"f")[e]=u(this,s,"f")[t],u(this,s,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),s=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function n(e){for(const{bom:t,encoding:i}of s)if(a(e,t))return e.subarray(t.length).toString(i);return e.toString()}function a(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=n,t.bufferToString=function(e){return Buffer.isBuffer(e)?n(e):(0,r.toS)(e)},t.bufferStartsWith=a},9092:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=s},36638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=s},40583:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const a=i(40958),o=i(23838),l=n(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new o.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,a.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,s=-1;for(const[i,n]of this.m.entries()){const a=(0,c.diceCoeff)(i,e);if(a>t&&a>s){const e=this.getFirst(n);null!=e&&(r=e,s=a)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),s=i(31586),n=i(68708),a=i(54993),o=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new o.Average(0);for(const t of this.keys()){if(!(0,s.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,a.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,s.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,n.tap)(new o.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,s]of this.m.entries()){const n=e(r);t.fill(n,i,i+s),i+=s}return t}}t.CountingSet=u},79840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),s=i(72993),n=i(45969),a=i(43334);t.EditionType=(0,r.lazy)((()=>a.isElectron?"Desktops":(0,n.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>s.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),s=i(55835),n=i(68708);var a=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return a.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,s.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.omit)(e,...i),(0,n.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,s.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),s=i(19851),n=i(95696);t.examples=(0,s.lazy)((()=>n.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),s=i(65843),n=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,s.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,n.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(31586),o=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,a.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,a.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,s.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,s.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,n.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,o.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,o.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,o.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,a.isNumber)(e.__uid)&&(0,a.isNumber)(e.__start)}},80049:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),s.set(this,0),n.set(this,0),a.set(this,0),o.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,s,l(this,s,"f")+e.cacheHitsAsync,"f"),u(this,n,l(this,n,"f")+e.cacheMisses,"f"),u(this,a,l(this,a,"f")+e.rejections,"f"),u(this,o,l(this,o,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,s,"f"),cacheMisses:l(this,n,"f"),rejections:l(this,a,"f"),timeouts:l(this,o,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,a,o;if(!this.cache.has(e))return void u(this,n,(t=l(this,n,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,s,(i=l(this,s,"f"),++i),"f"),c.promise):(u(this,r,(a=l(this,r,"f"),++a),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(o=l(this,r,"f"),++o),"f"),c}get(e){var t,i;const s=this.cache.get(e);return null==s||s instanceof m.Deferred&&s.isPending?u(this,n,(t=l(this,n,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),s instanceof m.Deferred?s.value:s}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,s,0,"f"),u(this,n,0,"f"),u(this,a,0,"f"),u(this,o,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,a,(t=l(this,a,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,o,(r=l(this,o,"f"),++r),"f")})),r.promise}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap},54127:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,a.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,s.range)(0,r).filter((e=>this.rows.every((t=>(0,n.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,o.fromEntries)(e))).filter((e=>(0,o.values)(e).some(n.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,o=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(o,r.index);(0,n.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),h=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:h});else{const e=(0,s.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,a.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}o=t.lastIndex}const l=(0,s.last)(i);return null!=l&&((0,n.blank)(this.headerRow.slice(o))?l.rightIdx=(0,a.max_)(...this.rows.map((e=>e.length))):l.rightIdx=o),i}}t.Fixed=m},73168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const r=i(55835),s=i(20014),n=i(55222),a=i(97352),o=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,a.within)(-90,90,e)&&0!==e}function c(e){return(0,a.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function h(e,t,i=o){return(0,r.map)(m(e,t,l(i)),(e=>n.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=o){return h(e?.lat,e?.lon,t)},t.geohash=h,t.geohashNumericShort=function(e,t){return m(e,t,30)};const f=new s.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=o){return d(e,t)?f.zip([t,e],l(i)):void 0}function p(e,t=o){return f.unzip(e,l(t))?.reverse()}function g(e,t=o){const[i,r]=p(e,t);return{lat:i,lon:r}}t.geohashNumeric=m,t.ungeohash=function(e,t=o){return(0,r.map)(n.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,r=t.lat*Math.PI/180,s=(t.lat-e.lat)*Math.PI/180,n=(t.lon-e.lon)*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(r)*Math.sin(n/2)*Math.sin(n/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},66364:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSuspended=void 0;const r=i(19851);t.isSuspended=(0,r.lazy)((()=>!1))},80875:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),s=i(98553);var n=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return n.parseJSON}}),t.mapParsed=function(e,t){const i=(0,s.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,s.parseJSON)((await(0,r.readFile)(e)).toString())}},57206:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDefaultJsonRevivers=void 0;const r=i(77988),s=i(51168),n=i(45599),a=i(98553),o=i(68708),l=i(24689),u=i(21330),c=i(57159),d=i(28544),h=(0,n.defer)((()=>{s.DateTime.prototype.toJSON=function(){return(0,o.compactValues)({_ctor:s.DateTime.name,ts:this.toMillis(),zone:"system"===this.zone?.type?void 0:this.zoneName})}})),f={name:s.DateTime.name,fromJSON:e=>s.DateTime.fromMillis(e.ts,(0,o.compactValues)({zone:e.zone}))};t.addDefaultJsonRevivers=(0,n.defer)((()=>{h(),(0,a.addJsonRevivers)(r.ExifDateTime,r.ExifDate,r.ExifTime,f,d.CapturedAt,l.DateInterval,u.FuzzyDate,r.BinaryField,c.WrappedError)}))},19851:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const a=i(57975),o=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&n(this,r,"m",s).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,o.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,o.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=b(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>S(v()??await(m.isWin?P():m.isMac?T():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function b(e){if((0,n.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=w.exec(e.trim())?.groups;return null==i?void 0:(0,s.compact)([i.lang,i.country]).join("-")}function S(e){return b(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=S,t.localeWin=P;const _={timeoutMs:10*a.secondMs};async function T(){return b(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return S(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=T,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),s=i(1708),n=i(45599),a=i(68708),o=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,n.defer)((()=>{(0,o.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:s.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,a.pick)(s.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:s.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),s=i(32105),n=i(14593);t.rootLoggers=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));const a=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));t.mkLogger=function(e){return new n.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new n.ContextualLogger(e,a)}},56639:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),s=i(55835),n=i(59455),a=i(48884);function o(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,a.concat)(...e.map((e=>t(e)))))},t.compactMap=o,t.toMap=function(e,t){return o((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:o(await Promise.all((0,r.compact)((0,n.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,s.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),s=i(54557);t.memoize=function(e,t){let i=0;const n=new s.FifoCache(t.maxSize,t.ttlMs),a=t=>{if(null!=t)return i++,n.getOrSet((0,r.stringify)(t),(()=>e(t)))};return a.clear=e=>null==e?n.clear():n.delete((0,r.stringify)(e)),a.size=()=>n.size,a.callCount=()=>i,a}},31578:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const r=i(1708),s=i(31586),n=i(12168),a=i(70417);function o(){const e=(0,r.memoryUsage)();return(0,a.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,r.memoryUsage)().rss}t.memoryUsageBytes=o,t.memoryUsageMb=function(){return(0,s.sigFigs)(o()/n.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,s.sigFigs)(l()/n.MB,2)}},7282:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const s=r(i(1708)),n=i(38639),a=i(54993),o=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,o.lazy)((()=>s.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,a.toS)(s.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return s.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,n.isTrue)(s.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){s.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},26033:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._isSupportedNode=t.RequiredNodeRange=t.isSupportedNode=void 0;const r=i(45599),s=i(76280);function n(e=process.versions.node){return(0,s.semverSatisfies)(e,t.RequiredNodeRange)}t.isSupportedNode=(0,r.defer)(n),t.RequiredNodeRange="18||20||21",t._isSupportedNode=n},97352:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55835),o=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,o.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(o.gt0)},t.firstNonZero=function(...e){for(const t of(0,n.flatten)(e)){const e=(0,o.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,a.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,o.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,o.toInt)(e),s=(0,o.toInt)(t);return null!=r&&r>0&&null!=s&&s>0?i(r,s):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,o.isNumber)(e))return e;if((0,s.blank)(e))return;const t=String(e);return(0,a.map)(f.exec(t),(e=>(0,o.toFloat)(t.substr(e.index))))}function p(e){return(0,o.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,a.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,a.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const s=i*e.length;for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),s=i(42659),n=i(96249),a=i(55835),o=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,s.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,s]of(0,l.entries)(e)){const e=t(r,s);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,a.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(a.defined)},t.firstDefinedField=function(e,...t){return(0,a.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,a.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const s of t)r[s]=i(s,e[s]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let s=0;for(const n of(0,l.keys)(e))if(r[n]=t(n,e[n]),s++,(0,o.gt)(s,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,n.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),s=i(73024),n=i(48161),a=i(19851),o=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),v=i(30933),w=(0,a.lazy)((()=>(0,f.mkLogger)("os")));function b(){return(0,n.platform)()+" "+(0,n.release)()}t.osArch=(0,a.lazy)((()=>`${function(){switch((0,n.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return C();case"win32":return F();default:return b()}}()} on ${(0,n.arch)()}`)),t.osFullName=(0,a.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const S=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function _(){return"ubuntu"===(0,t.osDistributionLinux)()}function T(){return"fedora"===(0,t.osDistributionLinux)()}function M(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,a.lazy)((()=>{if(g.isLinux)for(const e of S)try{const t=(0,s.readFileSync)(e).toString();if((0,o.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,a.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,o.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),b)})),t.osDistributionLinux=(0,a.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=_,t.hasApt=function(){return P()||_()},t.isFedora=T,t.isAlpine=M;const E={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},k={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function D(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),s=t[i];return(0,c.isString)(s)?s:s?.[r]}const x=(0,a.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function C(e=x()){try{return(0,o.mapNotBlankOr)(function(e=x()){return D(e,E)}(e),(t=>`macOS ${t} (${e})`),b)}catch(e){return w().warn("osNameMac(): unknown release",e),b()}}function F(e=(0,n.release)()){const t=e.startsWith("10.0.22")?"11":D(e,k);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=C,t.osNameWin=F,t.CPUs=(0,a.lazy)((()=>(0,h.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,a.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(F())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=x();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(_())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(T())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(M())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},45393:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetVersion=t.AssetFileVersion=void 0,t.AssetFileVersion=12,t.AssetVersion=4},12801:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const s=r(i(48161)),n=i(50989);t.PriorityClasses=(0,n.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:s.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:s.default.constants.priority.PRIORITY_NORMAL,BelowNormal:s.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:s.default.constants.priority.PRIORITY_LOW,Low:s.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setProcessTitle=t.setShortProcessNames=void 0;const r=i(72993),s=i(50213),n=i(23560),a=i(43334);let o=!a.isElectron;t.setShortProcessNames=function(e){o=e},t.setProcessTitle=function(){try{const e=[o?r.SimpleShortAppName:r.SimpleAppName];(0,n.isMainService)()&&a.isElectron||e.push((0,n.serviceName)());const t=e.join(a.isElectron?" ":"-");i(85949).title=t}catch(e){(0,s.mkLogger)("ServiceNames").warn("Failed to set friendly process name",e)}}},92782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeRandomUid=t.safeRandomChars=void 0;const r=i(55222),s=i(65713);t.safeRandomChars=function({radix:e=r.TokenRadix,length:t}){return(0,s.decuss)((()=>e.randomChars(t)))},t.safeRandomUid=function(e){return(0,s.decuss)((()=>(e?.radix??r.TokenRadix).randomUid(e?.chars??20,e?.splitEveryN??5,e?.sepChar??"-")))}},409:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),s=i(56409),n=i(31586),a=i(22911),o=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...r){f=!0,m=Date.now()+(0,n.max_)(t,i);const s=d=new a.Deferred(c);(0,n.gt0)(i)&&s.setTimeout(i);try{s.resolve(await e(...r))}catch(e){s.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,o.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return s.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,r.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new s.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),s=i(54993);function n(e){return e instanceof a?e.source:(0,s.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let s;for(;null!=(s=e.exec(t));)s.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(s,"index","groups"));return i},t.escapeRegExp=n,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(n(t))}const s=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(s,i)};class a{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=a;class o extends a{static from(...e){const t=l(e);return new o("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,o=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof a||t instanceof RegExp?(i+=t.source,r||(r=t.global),o||(o=t.ignoreCase),l||(l=t.multiline)):i+=n((0,s.toS)(t));return new RegExp(i,t??(r?"g":"")+(o?"i":"")+(l?"m":""))}t.RegExpOptional=o,t.concatRegexp=l},79089:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),v=i(34102),w=i(43334),b=i(24399),S=i(28874),P=(0,a.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,a.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",n.default.basename(S.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,o.compactBlanks)([n.default.basename(e),...t.map((e=>n.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let T=!0;const M=(0,a.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const i=(0,p.priorityPosixToClass)(t)??S.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),T)try{return s.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;T=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await b.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const s=r(i(1708)),n=i(19851),a=i(40958),o=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===o.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===o.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===o.ServiceNames.sync}function p(){return(0,t.serviceName)()===o.ServiceNames.test}t.serviceName=(0,n.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,n.lazy)((()=>(0,a.compactBlanks)([t.serviceName.prior(),(0,l.toS)(s.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return o.ServiceNames.indexOf(e)??o.ServiceNames.length+1},t.MainServices=[o.ServiceNames.main,o.ServiceNames.desktop],t.DbServices=[o.ServiceNames.sync,o.ServiceNames.info,o.ServiceNames.web,o.ServiceNames.list,o.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[o.ServiceNames.sync,o.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===o.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===o.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,n.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function s(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=s,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=s(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=s(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),s=i(57150),n=i(7282),a=i(23560),o=i(17181);t.setServiceName=function(e){(0,a.isMainService)(e)&&(e=r.ServiceNames.main);const t=a.serviceName.prior();t!==e&&((0,n.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),a.serviceName.set(e),(0,o.setupLogger)(),(0,s.logStartup)())}},28850:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const o=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends o.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),s.set(this,void 0),n(this,r,e,"f")}_call(){return(0,l.time)(a(this,r,"f")+(null==a(this,s,"f")?"(local)":"(remote)"),null==a(this,s,"f")?this.impl():a(this,s,"f").call(this))}setShim(e){n(this,s,e,"f")}hasShim(){return null!=a(this,s,"f")}clearShim(){n(this,s,void 0,"f")}}r=new WeakMap,s=new WeakMap},12089:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,a){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=a,s.set(this,void 0),n.set(this,void 0),l(this,s,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",o).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",a).call(this,e),(()=>u(this,r,"m",o).call(this,e)))}setShim(e){l(this,n,e,"f")}hasShim(){return null!=u(this,n,"f")}clearShim(){l(this,n,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",a).call(this,e))}}s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},o=function(e){return(0,m.time)(u(this,s,"f")+(null==u(this,n,"f")?"(local)":"(remote)"),null==u(this,n,"f")?this.impl(e):u(this,n,"f").call(this,e))}},45255:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const n=i(76790),a=i(17586);class o{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return s(this,r,"f")[Symbol.iterator]()}get length(){return s(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=s(this,r,"f").length-1;for(;t<=i;){const n=t+Math.floor((i-t)/2),a=this.valueOf(s(this,r,"f")[n]);if(e===a)return{found:!0,index:n};e>a?t=n+1:i=n-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&s(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...s(this,r,"f")];const a=t=>t<0||t>s(this,r,"f").length-1?null:(i??this.diff)(s(this,r,"f")[t],e),o=this.findIndex(e);if(null==o)return;let l=o.index-1,u=a(l),c=o.index,d=a(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return s(this,r,"f").shift()}at(e){return(0,a.at)(s(this,r,"f"),e)}toA(){return[...s(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===s(this,r,"f").length-1){const e=[...s(this,r,"f")];return s(this,r,"f").length=0,e}return s(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return s(this,r,"f").splice(e,t)}retainLastN(e){return e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),s=i(82328),n=i(84542),a=i(95705),o=i(28874);t.consoleLog=function(e,...t){o.Settings.quiet.valueOrDefault||(0,s.stdoutEnded)()||console.log((0,n.crlf)(e),...t)},t.consoleError=function(e){o.Settings.quiet.valueOrDefault||(0,a.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=o.Settings.quiet.envValue;try{return o.Settings.quiet.envValue=!0,await e()}finally{o.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),s=i(95705);t.stdoutEnded=function(){return(0,s.streamEnded)(r.stdout)}},71567:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const s=r(i(1708)),n=i(22573),a=i(98553),o=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:s.default.stdout})}function f({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const s=(0,a.stringify)(e,void 0,(0,o.isInfoService)()||(0,o.isMainService)()?2:void 0);r.write(s+"\n"),(0,o.isWorkerService)()&&null!=i&&(s.includes(u.FailStr)||(0,c.isFatalError)(s)||(0,c.isHealthCheckError)(s)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||s.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:s.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,n.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const s=t.indexOf(i,r);return-1===s?0:1+e(t,i,s+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,n.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,o.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,h.toS)(e),s=(0,h.toS)(t);return s.length>0&&(0,c.equalsIgnoreCase)(r.slice(-s.length),s,i)?r.slice(0,-s.length):r},t.gist=function(e,t=80,i=80){const r=(0,h.toS)(e),s=r.length-(t+i);return s<=0?r:r.slice(0,t).trim()+" …(+"+s+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function b(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function S(e){return(0,d.toA)(e).sort(b)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,n.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=b,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=S,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,a.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=b(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,n.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),s=t.indexOf(r);if(s>=0)return{index:s,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function T(e){return _.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=T;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,n.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(T(e))&&(e=e.slice(1,-1).trim())),e};const E=/^['‘’].*['‘’]$/,k=/^["“”„«»〃].*["“”„«»〃]$/;function D(e,t){const i=x(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function x(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let s,n=0;for(;null!=(s=t.exec(e));)s.index===t.lastIndex?t.lastIndex++:(t.lastIndex=s[0].length+s.index,i.push(e.substring(n,s.index)),r.push(e.substring(s.index,t.lastIndex)),n=t.lastIndex);return n(0,o.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),E.test(e)||k.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),s=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,a.map)(i[e],(e=>t+=e))));return t},t.splitKeep=D,t.splitUp=x,t.sortNaturalBy=C,t.sortNatural=function(e){return(0,s.sortBy)(e,(e=>C(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=S((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,s.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,n.blank)(e)||(0,n.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,o.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const F=/#.*$/gm;t.stripComments=function(e){return e.replace(F,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,n.blank)(r))for(const e of r.split(t))(0,n.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,n.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),s=e.findIndex((e=>r.test(e))),a=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(s<0)return e;for(let t=s+1;te.trim()))))}},83556:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function s(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=s,t.asObjectKey=function(e){return s(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const s=r(i(77598)),n=i(73913),a=i(55222);function o(e,t=n.HashBits){return s.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=a.Radix58,r=224){return i.encodeBuffer(o(e,r)).substring(0,t)}t.stringShaToBuffer=o,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=a.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(31586),o=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,s="";for(let n=0;n=r&&(r=i.get(n,a),s=(0,l.substr)(e,n-r+1,r)));return s}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),s=t.normalize();return e!==r||t!==s?y(r,s):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function v(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===r?1:void 0),(()=>(0,n.blank)(e)!==(0,n.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(i),t=w(r);return 2*b(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function b(e,t){const i=(0,f.intersection)(e,t),s=[];return i.forEach((i=>{const n=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,a.times)(n,(()=>s.push(i)))})),s}function S(e,t,i){const s=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,s))-i((0,l.strslice)(t,s))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,s.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[i,r]=[e,t].map(P).map((e=>(0,n.blank)(e)?"":e));return S(i,r,(e=>(0,a.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(n.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=b,t.lnsDiff=_;const T=/[^\da-z]+/gi;function M(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(T,"").toLowerCase()));return S(i,r,(e=>c.RadixAlphaNum.decode(e)))}function E(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const s=(0,a.mapNumericOr)(e.charCodeAt(r),(e=>e),256),n=(0,a.mapNumericOr)(t.charCodeAt(r),(e=>e),256),o=(0,a.clamp)(-256,256,s-n);i=null==i?o:(i+o)/2}return i}t.radixDiff=M,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=E,t.paddedPositionalDiff=function(e,t,i=8){return E((0,o.leftPad)(e,i," "),(0,o.leftPad)(t,i," "))}},84885:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),s=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,s.sortedKeys)(e))}},88264:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TTLArray=void 0;const r=i(31586);class s{constructor(e,t){this.ttlMs=e,this.maxLength=t,this.times=[],this.a=[],this.expirationListeners=[]}[Symbol.iterator](){this.vacuum();const e=[...this.a];return function*(){for(const t of e)yield t}()}push(...e){(0,r.times)(e.length,(()=>this.times.push(Date.now()))),this.a.push(...e),null!=this.maxLength&&this.vacuum()}pushUniq(...e){e.forEach((e=>{this.includes(e)||this.push(e)}))}includes(e){return this.vacuum(),this.a.indexOf(e)>=0}find(e){return this.vacuum(),this.a.find(e)}some(e){return this.vacuum(),this.a.some(e)}shift(){return this.vacuum(),this.times.shift(),this.a.shift()}first(){return this.vacuum(),this.a[0]}last(){return this.vacuum(),this.a[this.a.length-1]}shiftOrFirst(){return this.length>1?this.shift():this.first()}pop(){return this.vacuum(),this.times.pop(),this.a.pop()}onExpire(e){this.expirationListeners.push(e)}slice(e,t){return this.vacuum(),this.a.slice(e,t)}get length(){return this.vacuum(),this.a.length}clear(){return this.times.length=0,this.a.length=0,this}get values(){return this.vacuum(),[...this.a]}map(e){return this.vacuum(),this.a.map(e)}oldestEntryAge(){return this.vacuum(),this.times[0]}vacuum(){if(0===this.a.length)return;const e=this.a.length;if(null!=this.maxLength){const e=this.a.length-this.maxLength;this.times.splice(0,e),this.a.splice(0,e)}const t=Date.now()-this.ttlMs,i=this.times.findIndex((e=>e>t));if(-1===i?this.clear():i>0&&(this.times.splice(0,i),this.a.splice(0,i)),e!==this.a.length)for(const e of this.expirationListeners)e()}}t.TTLArray=s},75387:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",s.set(this,[]),n.set(this,new Map),a.set(this,void 0),o.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,a,"f")}set ttlMs(e){h(this,a,e,"f"),null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),h(this,o,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,n,"f").clear(),this}delete(e){return d(this,n,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,n,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,n,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,n,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const s=t();return null!=s&&this.set(e,s),s}lastSetOrGetTs(e){return d(this,n,"f").get(e)?.ts}set(e,t){return d(this,n,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,n,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,n,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,f.sortBy)(d(this,n,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,s,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,n,"f").delete(e);for(const i of d(this,s,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,n,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[a]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return o(this,r,"m",n).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>o(this,r,"m",n).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||o(this,r,"m",s).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)o(this,r,"m",s).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!o(this,r,"m",s).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield[t,t])}()}toA(){return o(this,r,"m",n).call(this),[...this.delegate.keys()]}[(r=new WeakSet,a=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,s=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},n=function(){for(const[e,t]of this.delegate)o(this,r,"m",s).call(this,e,t)}},84699:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},65211:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resetUid=t.sortByUid=t.tsFromUid=t.isUID=t.uidForTs=t.uid=t.uidSuffix=void 0;const r=i(19851),s=i(76790),n=i(22573),a=i(54993),o=i(7282),l=i(55222);let u=0;const c=l.GeoRadix;function d(e){return c.encode(e)+(0,t.uidSuffix)()}t.uidSuffix=(0,r.lazy)((()=>"-"+c.randomChars(7))),t.uid=function(){return u=Math.max(Date.now(),u+1),d(u)},t.uidForTs=d;const h=/^[\da-z]{9}-[\da-z]{7}$/i;function f(e){const t=(0,a.toS)(e).replace(/(?<=\S)-.*/,"");return(0,n.blank)(t)?void 0:c.decode(t)}t.isUID=function(e){return h.test((0,a.toS)(e))},t.tsFromUid=f,t.sortByUid=function(e){return(0,s.sortBy)(e,(e=>f(e.uid)))},t.resetUid=function(){if(!(0,o.isTest)())throw new Error("unsupported");t.uidSuffix.unset(),u=0}},94174:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,a.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,a.lazy)((()=>(0,o.uniq)([n.default.geteuid?.(),n.default.getuid?.(),s.default.userInfo().uid]))),t.userid=(0,a.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,a.lazy)((()=>(0,o.uniq)([n.default.getegid?.(),n.default.getgid?.(),s.default.userInfo().gid]))),t.groupid=(0,a.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,a.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,a.lazy)((()=>(0,l.toNotBlank)(s.default.userInfo()?.username))),t.userNameFromWhoami=(0,a.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,a.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,a.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,a.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.0-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=0,t.versionPrerelease=["prealpha"],t.release="2024.3.0-prealpha+20240308102353",t.gitSha="92cba1b21937cb9ca770f6a339e44b0fbee04bf9",t.gitDate=new Date(1709922233e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48299:function(e,t){"use strict";var i,r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.WeakCache=void 0;class o{constructor(){i.add(this),this[n]="WeakCache",r.set(this,new Map)}clear(){return a(this,r,"f").clear(),this}delete(e){return a(this,r,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of this.entries())e(i,t,this)}findEntry(e){for(const[t,i]of this.entries())if(e(i,t,this))return i}deleteValueIf(e){for(const[t,i]of this.entries())e(i,t,this)&&a(this,r,"f").delete(t)}get(e){const t=a(this,r,"f").get(e),i=t?.deref();return null==i&&null!=t&&a(this,r,"f").delete(e),i}getOrMaybeSet(e,t){const i=a(this,r,"f").get(e)?.deref();if(null!=i)return i;const s=t();return null!=s&&this.set(e,s),s}set(e,t){return a(this,r,"f").set(e,new WeakRef(t)),this}has(e){return null!=a(this,r,"f").get(e)?.deref()}get size(){return a(this,i,"m",s).call(this),a(this,r,"f").size}keys(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries())null==i.deref()?a(e,r,"f").delete(t):yield t}()}values(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield s}}()}entries(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield[t,s]}}()}[(r=new WeakMap,i=new WeakSet,n=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}}t.WeakCache=o,s=function(){for(const[e,t]of a(this,r,"f").entries())null==t.deref()&&a(this,r,"f").delete(e)}},48963:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),s=i(55835),n=i(31586),a=i(97790),o=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,n.toInt)(e)));if(!(0,s.allDefined)(i))return;const[a,o,u,c,d,h,f]=i,m=(0,n.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(a,o-1,u,c,d,h,f/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,a.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(n.toInt).filter((e=>(0,o.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},79184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aggregateAssetFiles=void 0;const r=i(59455),s=i(48884),n=i(22859),a=i(28874),o=i(79781),l=i(92434);t.aggregateAssetFiles=async function(e){const t=(0,r.toA)((0,l.sortAssetFiles)(e)??e);return(a.Settings.assetAggregation.valueOrDefault===n.AggregateTypes.union?s.clusterSome:s.clusterEvery)(t,o.isSimilarAssetFile)}},79781:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotSimilarAssetFile=t.isSimilarAssetFile=t.whyNotSameAsset=t.VideoImageMismatchMsg=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(50357),o=i(55835),l=i(31586),u=i(68708),c=i(12168),d=i(23467),h=i(73168),f=i(50213),m=i(86580),p=i(48368),g=i(80361),y=i(28874),v=i(28544),w=i(75767),b=i(16170),S=(0,r.lazy)((()=>(0,f.mkLogger)("sync-file.AssetFileComparator")));function P(e,t,i,r=((e,t)=>[e,t])){const s=e[i],o=t[i];if((0,n.blank)(s)||(0,n.blank)(o)||(0,a.eql)(s,o))return;const[l,u]=r(s,o);return(0,a.eql)(l,u)||(0,a.eql)(s,u)||(0,a.eql)(l,o)?void 0:`Different ${String(i)}: ${s} ≠ ${o}`}function _(e){return(0,n.mapNotBlank)(e,(e=>e.toLowerCase().trim().normalize()))}function T(e,t){return[_(e),_(t)]}function M(e,t,i){const r=(0,w.findInequalFields)(e[i],t[i]);return null==r?void 0:`Different ${i} (${r.aKey}:${r.aValue} ≠ ${r.aKey}:${r.aValue})`}function E(e,i){if(!(0,u.allKeysDefined)(e,"width","height","mimetype","sha"))return"af1 was missing required fields";if(!(0,u.allKeysDefined)(i,"width","height","mimetype","sha"))return"af2 was missing required fields";if((0,d.definedAndEql)(e.sha,i.sha))return void S().debug("matching SHA",{af1:e,af2:i});const r=(0,b.isVideoMimeType)(e.mimetype),n=(0,b.isVideoMimeType)(i.mimetype);if(r!==n)return S().tap({msg:"whyNotIsSimilar",result:t.VideoImageMismatchMsg,meta:{af1:e.uri,af2:i.uri,af1IsVideo:r,af2IsVideo:n}});const a=v.CapturedAt.fromAssetFile(e),f=v.CapturedAt.fromAssetFile(i);if(null==a)return"af1 missing capturedAt metadata";if(null==f)return"af2 missing capturedAt metadata";const _=a.isFuzzy||f.isFuzzy;if(_&&y.Settings.allowFuzzyDateImageHashMatches.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if((0,g.isSimilarImageHash)(t,r,{rotationsToCheck:(0,m.validRotations)(e,i)}))return void S().info("allowFuzzyDateImageHashMatches mode: image hashes match",{af1:e,af2:i})}if(!a.overlaps(f))return`captured-at ${a.toISOStringWithPrecision()} != ${f.toISOStringWithPrecision()}`;const E=P(e,i,"make",T)??P(e,i,"model",T);if(null!=E)return E;const k=(0,o.map)((0,h.geohashDistanceMeters)(e.geohash,i.geohash),(e=>(0,l.sigFigs)(e,2))),D={cameraId:M(e,i,"cameraId")??null,imageId:M(e,i,"imageId")??null,lensId:M(e,i,"lensId")??null,exposureSettings:(0,w.whyExposureSettingsNotSimilar)(e,i)??null,closeGeoHash:(0,l.gt)(k,y.Settings.gpsErrorMeters.valueOrDefault)?"geohashes are "+(0,c.fmt)(k)+"m different: too far apart":null};S().debug("whyNotSimilar()",{fields:D});const x=(0,s.compact)((0,u.values)(D));if((0,s.isNotEmpty)(x))return x.join(";");if(y.Settings.useImageHashes.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if(null!=t&&null!=r){const e=(0,g.compareImageHashes)(t,r,{capturedAtIsFuzzy:_});return!0===e?.isSimilar?void 0:e?.whyNotSimilar}}return(0,u.keys)(D).filter((e=>null==D[e])).length>=y.Settings.minMatchesWithoutImageHashes.valueOrDefault?void 0:"Insufficient metadata correlation"}t.VideoImageMismatchMsg="Videos ≠ images",t.whyNotSameAsset=function(e,t,i){{const i=E(e,t);if(null!=i)return i}if("intersection"===y.Settings.assetAggregation.valueOrDefault)for(const r of i)if(r.id!==t?.id){const t=E(e,r);if(null!=t)return t}},t.isSimilarAssetFile=function(e,t){return null==E(e,t)},t.whyNotSimilarAssetFile=E},13991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkSortableAssetFile_=t.mkAssetFile_=t.assetFileMetadata_=t.assetFileImageHashFields_=t.imageHashToAssetFileImageHashFields=t.assetFileStatFields_=t.assetFileUriFields_=void 0;const r=i(19851),s=i(55835),n=i(31586),a=i(59455),o=i(73168),l=i(50213),u=i(12089),c=i(76490),d=i(95696),h=i(48368),f=i(70417),m=i(28874),p=i(43207),g=i(47783),y=(0,r.lazy)((()=>(0,l.mkLogger)("asset-file.AssetFileFactory")));async function v(e){try{return{nativePath:e.nativePath,uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath}}catch(t){return y().throw("Failed to build URI for "+e,{error:t})}}async function w(e){const t=await e.stat_(),i=await e.sidecareStats();return{mtime:Math.floor((0,f.max)([t.mtimeMs,...(0,a.toA)(i).map((e=>e.mtimeMs))])),fileSize:t.size}}function b(e){return{...e,...c.DominantColor.toModeData(e.dominantColors)}}async function S(e){if(!m.Settings.useImageHashes.valueOrDefault)return;const t=await(0,h.imageHash_)(e.nativePath);return null==t?y().throw("Failed to extract image hash for "+e):b(t)}async function P(e){const[i,r,s,n]=await Promise.all([v(e),w(e),(0,t.assetFileMetadata_)(e),e.sha_()]);return{...i,...r,...s,sha:n}}t.assetFileUriFields_=v,t.assetFileStatFields_=w,t.imageHashToAssetFileImageHashFields=b,t.assetFileImageHashFields_=S,t.assetFileMetadata_=(0,u.shim1)({name:"asset-file.assetFileMetadata",impl:async function(e){try{const t=d.PosixFile.for(e),i=await(0,g.readTags)(t);if(null==i)throw new Error("Failed to read tags");if(null==i.capturedAt)throw new Error("Failed to read capturedAt");const r=i.capturedAt.toAssetFileFields();return null==r?y().throw("Failed to render assetFileFields from capturedAt",{capturedAt:i.capturedAt}):{...r,...i.exposureSettings,...i.dimensions,mimetype:i.mimetype,rotation:i.rotation,make:i.Make,model:i.Model,rating:i.rating,cameraId:i.cameraId,imageId:i.imageId,lensId:i.lensId,geohash:(0,o.geohashNumericShort)(i.GPSLatitude,i.GPSLongitude),durationMs:(0,p.extractDurationMs)(i),fps:(0,s.map)((0,n.toFloat)(i.VideoFrameRate),Math.floor)}}catch(t){return y().throw("_assetFileMetadata_() failed",{nativePath:e,error:t})}}}),t.mkAssetFile_=async function(e){const[t,i]=await Promise.all([P(e),S(e)]);return{...t,...i}},t.mkSortableAssetFile_=P},92434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestExistingAssetFile=t.assetFileSortCriteria=t.assetFileSortFields=t.assetFileSortCriteriaPojo=t.sortAssetFiles=t.mtime2sort=t.sortScale=t.dim2sort=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(23838),u=i(31586),c=i(68708),d=i(34666),h=i(50989),f=i(89937),m=i(50213),p=i(4001),g=i(29882),y=i(28874),v=i(14036),w=i(45200),b=i(34238),S=(0,r.lazy)((()=>(0,m.mkLogger)("img.AssetFileSorter"))),P=(0,h.strEnum)("file",f.PS_NETWORK_FILESYSTEM_SCHEME,f.PS_LOCAL_FILE_SCHEME,f.PS_LIBRARY_SCHEME);function _(e){return(0,u.map2Numeric)(e?.width,e?.height,((e,t)=>T(e*t)))}function T(e){if((0,u.gt0)(e))return Math.round(Math.pow(e,y.Settings.variantSortCriteriaPower.valueOrDefault))}function M(e){return Math.round(e/(5*o.minuteMs))}t.dim2sort=_,t.sortScale=T,t.mtime2sort=M;const E=["make","model","rating","cameraId","imageId","lensId","geohash"];function k(e){for(const t of(0,l.groupBy)(e,(e=>e.sha)).values())if(t.length>1){const e=Math.max(...(0,s.compact)(t.map((e=>e.mtime))));for(const i of t)i.mtime=e}return(0,n.sortBy)(e,C).reverse()}function D(e){const t=b.URI.parse(e.uri);if((0,a.blank)(t?.scheme)||(0,a.blank)(t?.path))return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI)",{uri_scheme:t?.scheme,uri_path:t?.path,af:e,parsedURI:t});const i=_(e);if(null==i)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid resolution)",{resolution:i,af:e,parsedURI:t});const r=P.indexOf(t.scheme);if(null==r)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI scheme)",{uri_scheme:t.scheme,af:e,parsedURI:t});const s=e.mtime??0,n=(0,g.parsePosixPath)(t.path),l=[];for(const t of E)(0,a.blank)(e[t])||l.push(t);const u={resolution:i,schemeIdx:r,capturedAtPrecision:-(e.capturedAtPrecisionMs??o.weekMs),metadataCoverage:l.length,metadataFields:l.join(","),isBrowserSupported:(0,v.isSupportedByCurrentBrowserExt)(n.ext),mtime:M(s),isEditOrUpdate:/edit|update/i.test(n.base),isCover:/cover/i.test(n.base),count:Math.abs((0,p.copySuffixCountFromName)(n.name)??0),basename:d.CmpReverseFlag+n.base,parentBasename:d.CmpReverseFlag+(0,g.parentBasename)(e.nativePath??t.path),uri:d.CmpReverseFlag+e.uri};return S().tap({msg:"assetFileSortCriteriaPojo()",result:(0,c.toReqValued)(u)})}function x(){return(0,s.uniq)([...y.Settings.variantSortCriteria.values,"uri"])}function C(e){const t=D(e);if(null==t)return;const i=[];for(const e of x())i.push(t[e]);return i}t.sortAssetFiles=k,t.assetFileSortCriteriaPojo=D,t.assetFileSortFields=x,t.assetFileSortCriteria=C,t.bestExistingAssetFile=async function(e){for(const t of k(e))if(await(0,w.uriExists)(t.uri,t.nativePath))return S().tap({msg:"bestExistingAssetFile()",result:t,meta:{files:e.map((e=>e.uri))}});return S().tap({msg:"bestExistingAssetFile(): no existing uris",result:void 0,meta:{files:e.map((e=>e.uri))}})}},54296:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetFileNativePath=void 0;const r=i(45200);t.getAssetFileNativePath=async function(e){return e.nativePath??(e.nativePath=await(0,r.uri2nativePath)(e.uri,e.mountpoint))}},73568:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const o=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),s.set(this,(0,o.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,n(this,s,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return n(this,s,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,n(this,s,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),a(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=n(this,r,"f")&&clearTimeout(n(this,r,"f")),a(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,s=new WeakMap},69591:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const s=r(i(87997)),n=i(31586);t.debounce=function(e,t){let i,r=[];const a=(0,n.gt0)(t)?(...n)=>{r=n,null!=i&&s.default.clearTimeout(i),i=s.default.setTimeout((()=>{e(...r)}),t)}:e;return a.reset=()=>{null!=i&&s.default.clearTimeout(i),i=void 0},a.force=()=>{a.reset(),e()},a.setTimeoutMs=e=>{a.reset(),t=e},a.timeoutMs=()=>t,a}},22911:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(i(87997)),w=y(i(57975)),b=i(45599),S=i(26905),P=i(55835),_=i(31586),T=i(68708),M=i(20214),E=i(57153),k=i(85556),D=i(50213),x=i(70025),C=i(95937),F="TIMEOUT",A=(0,b.defer)((()=>(0,D.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,_.gt0)(t)?new s(F).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const s=i[r];if(s.isSettled){if(s.name===F)return void A().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield s.value}}if(i.every((e=>e.name===F)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new s(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),a.set(this,void 0),o.set(this,E.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=s,s,(y=p(i,s,"f",n),m=y++,y),"f",n),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,D.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof s&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,o,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,T.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,a,"f")}get elapsedMs(){return(p(this,a,"f")??Date.now())-this.startedAt}get[(a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new k.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,C.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,o,"f")===E.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,o,"f")!==E.PromiseStates.pending}get isResolved(){return p(this,o,"f")===E.PromiseStates.resolved}get isRejected(){return p(this,o,"f")===E.PromiseStates.rejected}get settledMs(){return null==p(this,a,"f")?void 0:p(this,a,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,o,E.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,x.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,S.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,o,E.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,s=I,m=function(e){if(p(this,o,"f")===E.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,a,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},n={value:0}},83412:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DoneWrapper=void 0;const r=i(56409),s=i(38836);class n extends s.EndableWrapper{constructor(){super(...arguments),this.doneLatch=new r.Latch}isDone(){return this.doneLatch.isSettled()||this.ended}donePromise(){return this.doneLatch.promise}}t.DoneWrapper=n},27395:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(23838),o=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new a.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*n.minuteMs);const y=5*n.secondMs;async function v(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,o.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,s.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,s.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",a).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,s.set(this,void 0),n.set(this,void 0),o.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,s,"f")}hasTimeout(){return null!=u(this,n,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",a).call(this);const h=()=>{u(this,r,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,s,(0,d.setInterval)(u(this,o,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,n,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,o,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref()):h(),!0}}t.EndableInterval=v,s=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(){(0,h.map)(u(this,s,"f"),d.clearInterval),c(this,s,void 0,"f"),(0,h.map)(u(this,n,"f"),d.clearTimeout),c(this,n,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const o=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,a){this.endTimeoutMs=a,r.set(this,void 0),this.onEnds=[],s.set(this,(0,o.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),n(this,s,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){a(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return n(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return n(this,s,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,s=new WeakMap},99331:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let s=!1;t.ending=function(){return s},t.setEnding=function(e){s=(0,r.isTest)()?e:e||s}},45608:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const s=r(i(1708)),n=i(22573),a=i(45599),o=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,a.defer)((()=>(0,l.mkLogger)((0,o.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,a.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,n.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,f.endEndables)(),s.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,a.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])s.default[e].on(t,(i=>{v({reason:`${e}:${t}`,status:0,error:i})}))}))},39250:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LastOneInWins=void 0;const n=i(23838),a=i(54993),o=i(15674),l=i(73568),u=i(76740),c=i(99331),d=i(42638);t.LastOneInWins=class{constructor(e,t=o.maxCpus){this.name=e,this.maxConcurrency=t,r.set(this,new n.MultiMap),this.p=new d.Promises(e,t)}vacuum(){return s(this,r,"f").filterInPlace(((e,t)=>t.isPending&&!0!==t.payload?.aborted)),s(this,r,"f").valueCount()}enqueue({key:e,abortable:t,fn:i}){for(const t of s(this,r,"f").get(e)??[])t.payload?.abort("aborted by new work");if(this.vacuum(),(0,c.ending)())throw new l.AbortError("ending");const n=t??new u.Abortable,o=this.p.serial((0,a.toS)(e),(()=>i(n)),n);return s(this,r,"f").add(e,o),o}},r=new WeakMap},60172:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,r)=>{t=e,i=r})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,s.set(this,void 0),n.set(this,0),a.set(this,void 0),o.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,a,"f")}unset(){d(this,n,0,"f"),d(this,s,void 0,"f"),d(this,a,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,o,"f").push(e)}prior(){return this.isStale()?void 0:c(this,a,"f")}lastValue(){return c(this,a,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,n,"f")}isStale(){return null==c(this,s,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,s,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,s,"f")?void 0:Date.now()-c(this,s,"f")}elapsedMs(){return c(this,a,"f")?.settledMs??c(this,a,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,o,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,o,"f"))e.onError(t)}finally{d(this,n,(i=c(this,n,"f"),++i),"f")}},u=function(e){d(this,s,Date.now(),"f");const t=c(this,a,"f");return d(this,a,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,a,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,a,"f")),c(this,a,"f")}},1728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),s=i(80049);t.memoizeAsync=function(e,t){let i=0;const n=new s.FifoCacheAsync(t),a=t=>(i++,n.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return a.clear=e=>{if(null==e)return n.clear();{const t=(0,r.stringify)(e);return n.deleteIf((e=>t===e))}},a.size=()=>n.size,a.callCount=()=>i,a}},22781:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),s.set(this,!1),n.set(this,!1)}_call(){return a(this,s,"f")?(o(this,n,!0,"f"),!0===this.undefinedIfBusy?void 0:a(this,r,"f")):(o(this,s,!0,"f"),o(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{o(this,s,!1,"f"),!0===this.runLaterIfBusy&&a(this,n,"f")&&(o(this,n,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return a(this,s,"f")}prior(){return a(this,r,"f")}async force(){return await a(this,r,"f"),this._call()}}r=new WeakMap,s=new WeakMap,n=new WeakMap},37461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),s=i(76790),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),v=i(15674),w=i(42638);var b=i(20214);async function S(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:i,timeoutMs:s}){const n=[];for(const a of(0,r.compact)(await t))try{const e=await((0,l.gt0)(s)?(0,c.thenOrTimeoutError)(i(a),s):i(a));null!=e&&n.push([e,a])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:a,error:t})}return n}async function T({arr:e,f:t,name:i,maxConcurrent:s,timeoutMs:n,promises:a}){if(null==e)return[];const o=(0,r.compact)(await e);if((0,r.isEmpty)(o))return[];if((s=Math.round(s??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:i,timeoutMs:n});const u=a??(o.length<=s?w.PermissivePromises:new w.Promises(i,(()=>s))),d=(0,l.gt0)(n)?e=>(0,c.thenOrTimeoutError)(t(e),n):t,h=await u.enqueueAll(i,o.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return b.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=S,t.thenCollectBatched=async function(e,t,i){const r=[];for(const s of(0,p.batches)((0,f.toA)(await e),t)){const e=await S(s);r.push(...await S(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,o.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=T,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n}){return(await T({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:s,timeoutMs:n}){return(await T({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:s,timeoutMs:n})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await T({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,n.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,n.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*a.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,s=null;try{r=await((0,h.isFunction)(e)?e():e)}catch(e){s=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(s??r)}catch{}if(null!=s)throw s;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,n.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const s=await t;return null!=s?i(r,s):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const s=await t(r);return null==s?i():s},t.thenMap2Or=async function(e,t,i,r){const s=await e;if(null==s)return r();const n=await t;if(null==n)return r();const a=await i(s,n);return null==a?r():a},t.thenAnd=async function(e,t){return null!=e&&(0,n.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await T({name:e,arr:t,f:i});return(0,s.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),v=i(25764),w=i(38836),b=i(73614);function S(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),s=(0,l.clamp)(10*a.secondMs,a.minuteMs,Math.round(this.times.get(e)?.p98??0)),n=(0,b.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),s);try{const s=await(0,c.tot)(t),n=Date.now()-r;return i?.(s,n),this.push(e,n),s}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(n)}}get entriesBySumDesc(){return(0,n.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(S(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,o.getOrSet)(this.times,S(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(S(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/a.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function _(e,t,i){return P.instance().time(e,t,i)}function T(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,s.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const i=Date.now(),r=t();return T(e,Date.now()-i),r},t.pushTime=T,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>_(e,t)),i)}},42638:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),v=i(54993),w=i(89788),b=i(82647),S=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){r.add(this),this.name=e,this.ee=new f.default.EventEmitter,s.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new b.Average,n.set(this,0),a.set(this,[]),o.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,s,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,S.maxCpus)(),d(this,s,"f")?.call(this)??(0,S.maxCpus)()))}end(){return d(this,o,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,a,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,n,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,a,"f").map((e=>e.name)),pendingNames:d(this,o,"f").map((e=>e.d.name)),totalWorkCount:d(this,n,"f")}}enqueue({name:e,l:t,payload:i,serialId:s}){const n=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:s});return this.laterPop(),n}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,a,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,o,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,o,"f").length,e),i=this.runningSerialIds,s=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,a,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,o,"f").length}hasPending(){return d(this,o,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,o,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,o,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const s=new P.Deferred(e,{payload:i,serialId:r});return d(this,o,"f").push({d:s,l:t}),s},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,n,(t=d(this,n,"f"),++t),"f"),(0,m.remove)(d(this,a,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,a,"f").push(e),e},t.maybeRun=function(e,t){const i=new _(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new _(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},59189:function(e,t){"use strict";var i,r=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},s=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SerialLaterQueue=void 0,t.SerialLaterQueue=class{constructor(){i.set(this,Promise.resolve())}enqueue(e){return s(this,i,r(this,i,"f").catch().then(e),"f")}},i=new WeakMap},4867:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),s=i(34546),n=i(41400),a=i(31586),o=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let o=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>o=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>{if(o)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(o)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>l=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>o.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),s=i(42659),n=i(41400),a=i(32639),o=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,o.clamp)(10*m,l.ShortCommandTimeoutMs,(t??s.minuteMs)/5);await(0,n.delay)(r,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const s=r(i(1708)),n=i(45599),a=i(41400),o=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),v=i(50213),w=i(7282),b=i(88158),S=i(45969),P=i(43334),_=i(28874),T=i(3790);function M(e){return E().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const E=(0,n.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,b.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,a.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const k=["HOME","LANG","USER"],D=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],x=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?k:D),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function C(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,S.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,_.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,o.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(s.default.env,(e=>M(e)||!(0,T.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=C,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:A({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let F=!1;function A({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const s=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...x(),...i?(0,g.childProcLocale)():{},...C(r),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(s);if((0,y.isLogged)("debug")&&!F){F=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(s).map((([e,t])=>[e,(0,T.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return s}t.childEnv=A},84777:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const s=r(i(31421)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),v=i(79089),w=i(45255),b=i(22911),S=i(4867),P=i(73614),_=i(70025),T=i(57159),M=i(36868),E=i(66184),k=i(45643),D=i(95402),x=i(9727),C=(0,a.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function F(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function A(e,t=30*u.secondMs){if(null==e)return!1;C().debug("endProcess()",F(e));const i=e.pid;if(null==i||i<=0)return C().warn("endProcess(): asked to end invalid pid",F(e)),!1;if(i===n.default.pid)return C().warn("endProcess(): asked to end MY pid",F(e)),!1;if(i===n.default.ppid)return C().warn("endProcess(): asked to end my parent pid",F(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();C().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,D.killPid)(i).catch((e=>{C().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,k.waitForPidExit)(i,t))return C().debug("endProcess(): exitted",F(e)),!0;{D.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");C().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,D.killPid)(i,!0).catch((e=>{C().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,k.waitForPidExit)(i,5e3)}function I(e,i,r,s=0){const a=new Date,o=[];return(0,v.niceable)(i,r)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(s,u.secondMs)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&A(e)}),s-250)),o.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,D.addPid)({pid:e.pid,cmd:i,timeoutMs:s,ppid:n.default.pid},a)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>o.forEach(clearTimeout))),e}function O(e,t,i,r){const n=(0,x.spawnOptions)(r);return(0,E.isLogged)("trace",C().context)?C().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:n}):C().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(s.default.execFile(e,t,n),e,t,i)}async function L(e,t,i){const r=i.quiet??!1,s=i.ignoreStderr??!1,n=i.ignoreExitCode??!1,a=O(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{a.disconnect?.()}catch{}return{result:"",pid:a.pid}}const u=a.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new b.Deferred(f);a.on("error",(e=>g.push(e))),a.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),a.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(a.stdin);const v=new d.Latch;null==a.stdout?v.resolve():(a.stdout.on("error",(e=>g.push(e))),a.stdout.on("data",(e=>m.push(e))),a.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==a.stderr||s?P.resolve():(a.stderr?.on("error",(e=>g.push(e))),a.stderr?.on("data",(e=>p.push(e))),a.stderr?.on("end",(()=>P.resolve()))),C().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,S.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),C().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,S.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt}),await(0,S.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt});const E=p.join("");(0,l.notBlank)(E)&&g.push(new Error(E)),!r&&(0,o.isNotEmpty)(g)&&C().warn(f+" resulted in errors:",g);const k=i.isIgnorableError??_.isIgnorableError,D=g.filter((e=>!0!==k(e)));if(D.length>0)throw 1===D.length?D[0]:new T.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:D});if(!n&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:E}}catch(e){throw C().error("stdoutResult_() failed",e),await(0,D.killPid)(a.pid,!0),e}}t.endProcess=A,t.ReniceAfterMs=(0,a.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,a.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const n=(0,x.spawnOptions)(r);return C().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(s.default.spawn(e,t,n),e,t,i)},t.execFile=O,t.stdoutResult_=L,t.stdout_=async function(e,t,i){const r=await L(e,t,i);return C().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},86335:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ChildService=t.ChildServiceNames=t.inspectPort=t.pathToService=void 0;const l=i(77598),u=o(i(1708)),c=i(19851),d=i(40958),h=i(22573),f=i(50268),m=i(68708),p=i(5670),g=i(50989),y=i(12168),v=i(59455),w=i(41583),b=i(54993),S=i(80875),P=i(50213),_=i(81168),T=i(27395),M=i(25764),E=i(59958),k=i(70025),D=i(83278),x=i(85021),C=i(29325),F=i(43334),A=i(28874),I=i(84777),O=i(55534),L=i(85100),R=i(34330),N=(0,c.lazy)((()=>(0,P.mkLogger)("child.ChildService")));async function B(e){const t=(0,_.ensureSuffix)(e,".js"),i=D.BaseFile.projectRoot(),r=D.BaseFile.for(u.default.cwd()),s=(0,C.isPacked)()?[i.join("bin",t),F.isElectron?i.join("app.asar",t):void 0]:[r.join("dist","library",t),r.join("dist","core",t),r.join("lib","library",t)];(0,C.isPacked)()||(F.isElectron?(s.push(r.join("dist","app",t)),s.push(i.join("src","desktop","dist","library",t))):s.push(i.join("src","library","dist","library",t)));for(const e of s)if(null!=e&&!0===await e.isNonEmptyFile((0,C.isPacked)()?y.KB:128))return N().tap({msg:"pathToService()",level:"info",result:e,meta:{cmd:t,isPacked:C.isPacked,paths:s.map(b.toS)}});return N().throw("Failed to find path to "+e,{paths:s,fatal:!0})}t.pathToService=B,t.inspectPort=function(e){switch(e){case"web":return 9223;case"sync":return 9224;default:return(0,l.randomInt)(9225,9600)}},t.ChildServiceNames=(0,g.strEnum)(...p.ServiceNames.pick("web","sync"));class j{static async mk_(e,t={}){const i=t.pathToService??await B(e);if((0,h.blank)(i))throw new Error("Failed to find path to "+e);return t.nodeArgs=(0,v.toA)(t.nodeArgs),new j(e,i,t)}constructor(e,t,i){var o,l;r.add(this),this.serviceName=e,this.cmd=t,this.opts=i,this.restartCount=0,this.name="ChildService("+e+")",this.endTimeoutMs=(0,L.serviceExitTimeoutMs)(e),this.logger=(0,P.mkLogger)(this.name);const c=[...(0,v.toA)(i.nodeArgs),t.nativePath];(0,d.isNotEmpty)(i.args)&&c.push(...i.args),this.spawnOpts=(0,m.pick)(this.opts,"argv0","cwd","detached","env","gid","shell","stdio","timeout","uid","windowsHide","windowsVerbatimArguments","forceCLocale","forWorker"),this.spawnOpts.forceCLocale=!1,(l=(o=this.spawnOpts).env??(o.env={}))[E.UV_THREADPOOL_SIZE]??(l[E.UV_THREADPOOL_SIZE]=(0,b.toS)(("web"===e?A.Settings.webUvThreads:A.Settings.syncUvThreads).valueOrDefault)),this.wc=new R.WatchedChild({name:e,childFactory:async()=>(this.restartCount>0&&await(this.opts.onPreRestart?.()),this.restartCount++,(0,I.spawn)(u.default.execPath,c,-1,this.spawnOpts)),endableRank:M.EndableRanks.service,endTimeoutMs:this.endTimeoutMs,onStdout:a(this,r,"m",n).bind(this),onStderr:a(this,r,"m",s).bind(this),onError:this.opts.onError??(e=>!1===(0,k.isIgnorableError)(e)),ignoreStopErrors:!1,exitCommand:O.ServiceExitCommand,...i}),(0,T.addEndable)(M.EndableRanks.first,this)}get startMs(){return this.wc.startTs}runHealthCheck(){return this.wc.writeStdin(x.HealthCheckCommand+"\n")}start(){return this.wc.start()}stop(){return this.wc.stop()}restart(e){return this.wc.restart(e)}get ended(){return this.wc.ended}async end(){return this.wc.ended||this.write(O.ServiceExitCommand),this.wc.end()}get pid(){return this.wc.pid}running(){return this.wc.running()}notRunning(){return this.wc.notRunning()}write(e,t=2){if(t<0)return this.logger.warn("write(): no more retries",{toStdin:e}),!1;try{const t=this.wc.proc;return!0!==t?.stdin?.writable?(this.logger.warn("write(): childProc isn't open, ignoring",{toStdin:e}),!1):t.stdin.write((0,_.ensureSuffix)(e,"\n"))}catch(i){return this.logger.warn("write(): caught "+i),this.wc.onError("onStdout()",(0,w.toErr)(i)),this.write(e,t-1)}}}t.ChildService=j,r=new WeakSet,s=function(e){const t=(0,S.parseJSON)(e);return this.logger.warn(".onStderr()",t??e),!0===t?.fatal},n=function(e){if(!(0,h.blank)(e))try{const t=(0,S.parseJSON)(e);if(null==t)return void this.logger.info(".onStdout(): non-JSON payload",e);if(!0===t?.fatal)this.wc.onError(this.name+".onStdout()",t);else if((0,f.isHealthCheckSummary)(t)){const e="failed"===t.state||"error"===t.level;this.logger.log(e?"error":"info",".onStdout(): health check summary",t),e&&this.wc.onError(this.name+".onStdout()",t,e)}else null!=this.opts.onData&&this.opts.onData(t)}catch(t){this.logger.warn(".onStdout() failed:",{data:e,error:t})}}},3790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),s=i(41400),n=i(19851),a=i(28874);(0,s.later)((()=>a.Settings.sensitiveEnvRegExp.watchLater((()=>o.unset()))));const o=(0,n.lazy)((()=>{try{return new RegExp(a.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${a.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(a.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&o().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||a.Settings.license.includesEnvKey(e)}},55534:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceExitCommand=void 0,t.ServiceExitCommand="--exit"},85100:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serviceExitTimeoutMs=void 0;const r=i(23560),s=i(28874),n=i(45255);t.serviceExitTimeoutMs=function(e){return(0,r.isSyncService)(e)?s.Settings.syncExitTimeoutMs.valueOrDefault:n.ShortCommandTimeoutMs}},34330:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(54993),w=i(27395),b=i(25764),S=i(99331),P=i(42638),_=i(38835),T=i(8769),M=i(57159),E=i(66003),k=i(50213),D=i(45643),x=i(28874),C=i(84777);t.mkBasicWatchedChild=function(e){return new F({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,C.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class F{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,k.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),s.set(this,!1),this.onError=(e,t,i)=>{const n=new M.WrappedError(e,{cause:t}),a=!1!==n.ignorable;this.logger().log(a?"warn":"error","onError()",n),u(this,s,"f")||a||(this.lastError=n,(0,T.onError)(n),!0!==n.fatal?(i??this.opts.onError(e,n))&&(this.logger().warn("onError requested restart",{src:e,error:n}),u(this,r,"m",o).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:x.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:b.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,w.addEndable)(this.opts.endableRank,this),u(this,r,"m",o).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,s,"f")}async end(){return c(this,s,!0,"f"),u(this,r,"m",n).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",n).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,s,"f")}),!u(this,s,"f")&&!(0,S.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",n).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=F,s=new WeakMap,r=new WeakSet,n=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,s,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",a).call(this,e)},a=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,D.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,C.endProcess)(e,this.endTimeoutMs)},o=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",n).call(this),!this._stopped&&!u(this,s,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,T.onError)("Can't restart "+this.name+", failure rate is too high."+_.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,s,"f")}),this._stopped||u(this,s,"f")||(0,S.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,E.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,v.toS)(e).includes("Error: Cannot find module")&&(0,T.onError)("Failed to start "+this.name+_.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,s,"f")}),(0,S.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",o).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const a=n(i(53916)),o=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,o.toNativePath_)(e);const i=f.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),s=i.sibling(r);if(s.isSelfOrDescendantOf((0,l.examples)()))return a.join("$examples",s.posixPathFrom((0,l.examples)()));const n=(0,d.originalsDir)();if(s.isSelfOrDescendantOf(n))return a.join("$library",s.posixPathFrom(n));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?a.join("$library",s.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const n=i(6858),a=i(1708),o=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),h=i(43334),f=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return s(this,r,"f").push(...e),this}async parse(e=a.argv,t){let i=(0,m.addHelpFooter)(new n.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of s(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":o.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,a.exit)(0)})),i.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=i.opts();for(const e of s(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),s=i(31586),n=i(51926),a=i(17344),o=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,s.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,n.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,a.EditionName)()+" v"+o.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const r=i(38639),s=i(17181),n=i(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,r.mapBoolean)(e.color,(e=>{n.Settings.logColor.envValue=e,(0,s.setupLogFormatter)()}))}}},83210:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDaemon=void 0;const s=r(i(1708)),n=i(22573),a=i(38639);t.isDaemon=function(e){return(0,a.isTrue)(s.default.env.__is_daemon)||(0,a.isTrue)(e?.daemon)||!(0,n.blank)(e?.pidfile)}},53978:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimingArg=void 0;const r=i(28874),s=i(38639);t.TimingArg={beforeParse:e=>e.option("--timing","On exit, emit timing information to stdout."),afterParse:async e=>{(0,s.isTrue)(e.timing)&&(r.Settings.emitTimingsOnExit.value=!0)}}},94361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),s=i(40958),n=i(55835),a=i(31586),o=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,a.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,s.compactBlanks)([c("user id","PUID",(0,o.userids)()),c("group id","PGID",(0,o.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,n.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},43380:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WriteSettingsArg=void 0;const r=i(28874),s=i(2858),n=i(22573),a=i(38639),o=i(46292);t.WriteSettingsArg={beforeParse:e=>e.option("--write-settings","Write (or re-write, if they exist) system and library settings.toml files. See https://phstr.com/settings"),afterParse:async e=>{if((0,a.isTrue)(e.writeSettings)){const e=await(0,s.writeSystemSettings_)();if(null==e?console.info("--write-settings: Failed write system settings: no system configuration directory was found.",{checkedDirectories:(0,o.osConfigDirs)()}):console.info(`--write-settings: Wrote system settings to ${e}`),(0,n.blank)(r.Settings.libraryDir.valueOrDefault))console.error("--write-settings: Failed to write library settings: no PS_LIBRARY_DIR is set.");else{const e=await(0,s.writeLibrarySettings_)();console.info(`--write-settings: Wrote library settings to ${e}`)}}}}},54772:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestLabhashName=t.bestLabName=t.bestRgbName=t.colorToTuple=t.bestRgbTripletName=t.ColorNames=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(31586),o=i(48884),l=i(50213),u=i(81168),c=i(85810),d=i(42079),h=i(91482),f=i(3048),m=i(85409),p=i(16050),g=i(42022),y=i(85042),v=(0,r.lazy)((()=>(0,l.mkLogger)("color.ColorNames")));function w(e){const t=(0,y.normalizeRgbHex)(e.rgb);if(null==t)return void v().warn(`skipping invalid entry (bad rgb): ${e.rgb}`,e);const i=(0,c.rgbhex2Lab)(t);if(null==i)return void v().warn(`skipping invalid entry (failed to convert to L*a*b): ${t}`,e);const r=(0,c.toLabhash)(i,g.ModeBits);return{...e,rgb:t,lab:i,labhash:r,closeLabhashes:[r],closeRgb:[t],name:(0,u.capitalize)(e.name)}}function b(e,i){return null==e?void 0:(0,o.leastBy)(i??(0,t.ColorNames)(),(t=>(0,f.ciede2000_delta_e)(t.lab,e)))}t.ColorNames=(0,r.lazy)((()=>(0,s.compact)([...d.CrayonColors,...d.CrayonSupplements,...h.DarkWikipediaColors,...p.LightWikipediaColors,...m.Greys].map(w)))),t.bestRgbTripletName=function(e,i=(0,t.ColorNames)()){return b((0,c.rgb2lab)(e),i)},t.colorToTuple=w,t.bestRgbName=function(e){return P((0,c.rgbhex2Labhash)(e))},t.bestLabName=b;const S=new Map;function P(e){return(0,a.gte0)(e)?(0,n.getOrSet)(S,e,(()=>{const i=(0,t.ColorNames)().find((t=>t.labhash===e));if(null!=i)return i;const r=(0,c.unlabhash)(e),n=b(r);return null!=r&&null!=n&&((0,s.pushUniq)(n.closeLabhashes,e),(0,s.pushUniq)(n.closeRgb,(0,c.lab2rgbhex)(r))),n})):void 0}t.bestLabhashName=P},85810:(e,t,i)=>{"use strict";e=i.nmd(e),Object.defineProperty(t,"__esModule",{value:!0}),t.hsv2rgb=t.hsl2hsv=t.hsv2hsl=t.hsl2rgb=t.rgb2hsl=t.rgbhex2hsl=t.rgb2hsv=t.closestLab=t.maxLabhash=t.minLabhash=t.unlabhash=t.toLabhash=t.LabBitZip=t.xyz2rgb=t.lab2xyz=t.xyz2lab=t.rgb2xyz=t.clampLab=t.lab2rgb=t.rgb2lab=t.rgb2labArray=t.rgb2labTriplets=t.lab2rgbhex=t.rgbhex2Labhash=t.rgbhex2Lab=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(55835),o=i(31586),l=i(48884),u=i(20014),c=i(75503),d=i(3048),h=i(42022),f=i(85042),m=[[.4124564,.3575761,.1804375],[.2126729,.7151522,.072175],[.0193339,.119192,.9503041]],p=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]];function g(e){return _(w(e))}function y(e){return(0,f.clampRGB)(M(T(e)))}function v(e){return(0,t.LabBitZip)().clampValue(e)}function w(e){const t=(0,f.clampRGB)(e).map((e=>e/255)).map((e=>e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92));return(0,c.matXvec)(m,t)}t.rgbhex2Lab=function(e){return(0,a.map)((0,f.rgbhex2triplet)(e),g)},t.rgbhex2Labhash=function(e,t=h.ModeBits){return(0,a.map)((0,f.rgbhex2triplet)(e),(e=>E(g(e),t)))},t.lab2rgbhex=function(e){return(0,f.rgbTriplet2hex)(y(e))},t.rgb2labTriplets=function(e){return(0,s.stepRange)(0,e.length,3).map((t=>g([e[t],e[t+1],e[t+2]])))},t.rgb2labArray=function(e){const t=[],i=[],r=[];for(let s=0;se>S?Math.pow(e,1/3):(P*e+16)/116));return v([116*i-16,500*(t-i),200*(i-r)])}function T(e){const[t,i,r]=v(e),s=(t+16)/116,n=i/500+s,a=s-r/200,o=n*n*n,l=a*a*a,u=o>S?o:(116*n-16)/P,c=t>8?Math.pow(s,3):t/P,d=l>S?l:(116*a-16)/P;return[u*b.X,c*b.Y,d*b.Z]}function M(e){return(0,c.matXvec)(p,e).map((e=>{const t=e<0?-1:1,i=e*t;return(0,o.round)(255*t*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055))}))}function E(e,i=h.ModeBits){return(0,t.LabBitZip)().zip(e,i)}t.xyz2lab=_,t.lab2xyz=T,t.xyz2rgb=M,t.LabBitZip=(0,r.lazy)((()=>new u.BitZip([{min:0,max:100},{min:-79,max:90},{min:-102,max:89}]))),t.toLabhash=E;const k=new Map;function D(e,i=h.ModeBits){return(0,t.LabBitZip)().unzip(e,i)}function x(e){const[t,i,r]=(0,f.clampRGB)(e),s=Math.max(t,i,r),n=s-Math.min(t,i,r),a=n?s===t?(i-r)/n:s===i?2+(r-t)/n:4+(t-i)/n:0;return[60*(a<0?a+6:a),s?n/s*100:0,s/255*100]}function C(e){return F(x(e))}function F(e){const[t,i,r]=e,s=(200-i)*r/100;return[t,s>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,s/2]}function A(e){const[t,i,r]=e,s=i*(r<50?r:100-r)/100;return[t,s>0?2*s/(r+s)*100:0,r+s]}function I(e){const t=e[0]/360*6,i=e[1]/100,r=e[2]/100,s=Math.floor(t),n=r*(1-i),a=r*(1-(t-s)*i),o=r*(1-(1-t+s)*i),l=s%6;return(0,f.clampRGB)([255*[r,a,n,n,o,r][l],255*[o,r,r,a,n,n][l],255*[n,n,o,r,r,a][l]])}t.unlabhash=function(e,t=h.ModeBits){return t===h.ModeBits?(0,n.getOrSet)(k,e,(()=>D(e,t))):D(e,t)},t.minLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMin(h.ModeBits))),t.maxLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMax(h.ModeBits))),t.closestLab=function(e,t){return(0,l.leastBy)(e,(e=>(0,d.ciede2000_delta_e)(e,t)))},t.rgb2hsv=x,t.rgbhex2hsl=function(e){return C((0,f.rgbhex2triplet)(e))},t.rgb2hsl=C,t.hsl2rgb=function(e){return I(A(e))},t.hsv2hsl=F,t.hsl2hsv=A,t.hsv2rgb=I,i.c[i.s]===e&&console.log(E([0,0,0]))},42079:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CrayonSupplements=t.CrayonColors=void 0,t.CrayonColors=[{name:"Aquamarine",rgb:"#95E0E8"},{name:"Asparagus",rgb:"#7BA05B"},{name:"Blue-green",rgb:"#0095B7"},{name:"Royal blue",rgb:"#273BE2"},{name:"Blush",rgb:"#DB5079"},{name:"Brilliant rose",rgb:"#E667CE"},{name:"Brown",rgb:"#AF593E"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Burnt umber",rgb:"#805533"},{name:"Cadet blue",rgb:"#A9B2C3"},{name:"Canary",rgb:"#FFFF99"},{name:"Carmine",rgb:"#E62E6B"},{name:"Carnation pink",rgb:"#FFA6C9"},{name:"Celestial blue",rgb:"#7070CC"},{name:"Cerise",rgb:"#DA3287"},{name:"Cerulean blue",rgb:"#339ACC"},{name:"Chestnut",rgb:"#B94E48"},{name:"Cobalt blue",rgb:"#8C90C8"},{name:"Copper",rgb:"#DA8A67"},{name:"Cornflower",rgb:"#93CCEA"},{name:"Cotton candy",rgb:"#FFB7D5"},{name:"Denim",rgb:"#1560BD"},{name:"Eggplant",rgb:"#614051"},{name:"Fern",rgb:"#63B76C"},{name:"Fuchsia",rgb:"#C154C1"},{name:"Russet",rgb:"#87421F"},{name:"Green",rgb:"#01A638"},{name:"Green-yellow",rgb:"#F1E788"},{name:"Indigo",rgb:"#4F69C6"},{name:"Jungle green",rgb:"#29AB87"},{name:"Magenta",rgb:"#F653A6"},{name:"Maize",rgb:"#F2C649"},{name:"Maroon",rgb:"#C32148"},{name:"Medium chrome green",rgb:"#6CA67C"},{name:"Medium violet",rgb:"#8F47B3"},{name:"Melon",rgb:"#FEBAAD"},{name:"Middle blue-green",rgb:"#8DD9CC"},{name:"Middle blue-purple",rgb:"#8B72BE"},{name:"Green-yellow",rgb:"#ACBF60"},{name:"Middle purple",rgb:"#D982B5"},{name:"Middle yellow-red",rgb:"#ECAC76"},{name:"Midnight blue",rgb:"#003366"},{name:"Mulberry",rgb:"#C8509B"},{name:"Navy blue",rgb:"#0066CC"},{name:"Olive green",rgb:"#B5B35C"},{name:"Orange",rgb:"#FF8833"},{name:"Orchid",rgb:"#E29CD2"},{name:"Peach",rgb:"#FFCBA4"},{name:"Periwinkle",rgb:"#C3CDE6"},{name:"Pine green",rgb:"#01796F"},{name:"Pink flamingo",rgb:"#FC74FD"},{name:"Plum",rgb:"#8E3179"},{name:"Raw umber",rgb:"#665233"},{name:"Red-orange",rgb:"#FF681F"},{name:"Red",rgb:"#ED0A3F"},{name:"Salmon",rgb:"#FF91A4"},{name:"Vivid scarlet",rgb:"#FD0E35"},{name:"Sea green",rgb:"#93DFB8"},{name:"Sepia",rgb:"#9E5B40"},{name:"Shamrock",rgb:"#33CC99"},{name:"Sky blue",rgb:"#76D7EA"},{name:"Spring green",rgb:"#ECEBBD"},{name:"Sunset orange",rgb:"#FE4C40"},{name:"Tan",rgb:"#FA9D5A"},{name:"Teal blue",rgb:"#008080"},{name:"Thistle",rgb:"#D8BFD8"},{name:"Vivid tangerine",rgb:"#ED3C10"},{name:"Vivid violet",rgb:"#a625c3"},{name:"Wisteria",rgb:"#C9A0DC"},{name:"Yellow-green",rgb:"#C5E17A"},{name:"Yellow-orange",rgb:"#FFAE42"},{name:"Yellow",rgb:"#FBE870"}],t.CrayonSupplements=[{name:"Artichoke",rgb:"#8F9779"},{name:"Aubergine",rgb:"#48213A"},{name:"Brandy rose",rgb:"#B1847F"},{name:"Burgundy",rgb:"#800020"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Crimson red",rgb:"#990000"},{name:"Dark brown",rgb:"#664228"},{name:"Dark coral",rgb:"#CD5B45"},{name:"Dark green",rgb:"#006400"},{name:"Dark raspberry",rgb:"#872657"},{name:"Dark turquoise",rgb:"#610079"},{name:"Deep teal",rgb:"#004040"},{name:"Deep coffee",rgb:"#704241"},{name:"Dusty rasberry",rgb:"#917980"},{name:"Ecru",rgb:"#BCAC7C"},{name:"Evergreen",rgb:"#05472A"},{name:"Eggplant",rgb:"#380835"},{name:"Eggplant purple",rgb:"#430541"},{name:"Emerald green",rgb:"#028F1E"},{name:"Flamingo pink",rgb:"#D67C99"},{name:"Grape",rgb:"#6C3461"},{name:"Kelly green",rgb:"#4CBB17"},{name:"Light forest green",rgb:"#4F9153"},{name:"Medium dark brown",rgb:"#AF7200"},{name:"Medium dark cyan-blue",rgb:"#2D537C"},{name:"Mustard",rgb:"#FAAF18"},{name:"Neon green",rgb:"#39FF14"},{name:"Pear",rgb:"#D1E231"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Phthalo blue",rgb:"#0016C7"},{name:"Pink lace",rgb:"#FFDDF4"},{name:"Raw sienna",rgb:"#884B15"},{name:"Rebecca purple",rgb:"#663399"},{name:"Sap green",rgb:"#536916"},{name:"Blue sapphire",rgb:"#133ECB"},{name:"Sand",rgb:"#B38751"},{name:"Shadow blue",rgb:"#778BA5"},{name:"Shadow green",rgb:"#121E06"},{name:"Swamp green",rgb:"#748500"},{name:"Verdigris",rgb:"#43B3AE"},{name:"Vivid blue-magenta",rgb:"#4817E8"},{name:"Vivid blue-purple",rgb:"#ACACE6"},{name:"Vivid blue",rgb:"#47ABCC"},{name:"Vivid green-yellow",rgb:"#D9E650"},{name:"Vivid green",rgb:"#7BE214"},{name:"Vivid turqoise",rgb:"#06ECD2"},{name:"Vivid lavender",rgb:"#A354FD"},{name:"Vivid mint",rgb:"#00F28C"},{name:"Vivid pink",rgb:"#D752FB"},{name:"Vivid red-purple",rgb:"#C31D7E"},{name:"Vivid red",rgb:"#D92121"},{name:"Vivid yellow-red",rgb:"#F2BA49"},{name:"Vivid yellow",rgb:"#FAFA37"}]},91482:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarkWikipediaColors=void 0,t.DarkWikipediaColors=[{name:"Bistre",rgb:"#3D2B1F"},{name:"Black bean",rgb:"#3D0C02"},{name:"Black pearl",rgb:"#041322"},{name:"Shadow blue",rgb:"#001440"},{name:"Charcoal",rgb:"#36454F"},{name:"Dark indigo",rgb:"#1F0A52"},{name:"Dark magenta",rgb:"#8B008B"},{name:"Dark moss green",rgb:"#4A5D23"},{name:"Dark navy",rgb:"#02075D"},{name:"Dark pastel blue",rgb:"#779ECB"},{name:"Dark purple",rgb:"#580040"},{name:"Dark tan",rgb:"#918151"},{name:"Dark yellow-green",rgb:"#304000"},{name:"Dark yellow",rgb:"#9B870C"},{name:"Deep violet",rgb:"#330066"},{name:"Dusk",rgb:"#4E5481"},{name:"Elderberry",rgb:"#1d1a34"},{name:"Grey jade",rgb:"#757C55"},{name:"Grey magenta",rgb:"#83667F"},{name:"Grey ochre",rgb:"#716659"},{name:"Grey olive",rgb:"#656c5a"},{name:"Grey sage",rgb:"#69724d"},{name:"Taupe",rgb:"#483C32"}]},3048:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciede2000_delta_e=t.diffCIECorr=t.MaxCie=t.MinCie=t.cie94_delta_e=t.cie76_delta_e=void 0;const r=i(31586),s=i(97352);t.cie76_delta_e=function(e,t){return Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2)},t.cie94_delta_e=function(e,t){const[i,r,n]=e,[a,o,l]=t,u=i-a,c=r-o,d=n-l,h=(0,s.sqrt)(r**2+n**2),f=h-(0,s.sqrt)(o**2+l**2),m=(0,s.sqrt)(c**2+d**2-f**2);return(0,s.sqrt)((u/1)**2+(f/(1+.045*h))**2+(m/(1+.015*h))**2)},t.MinCie=2,t.MaxCie=20,t.diffCIECorr=function(e,i){return null==e||null==i?1:(0,r.clamp)(0,t.MaxCie,l(e,i)-t.MinCie)/t.MaxCie};const n=1,a=1,o=1;function l(e,t){const[i,r,l]=e,u=(0,s.sqrt)(r**2+l**2),[c,d,h]=t,f=(u+(0,s.sqrt)(d**2+h**2))/2,m=.5*(1-(0,s.sqrt)(Math.pow(f,7)/(Math.pow(f,7)+Math.pow(25,7)))),p=r*(1+m),g=d*(1+m),y=(0,s.sqrt)(p*p+l*l),v=(0,s.sqrt)(g*g+h*h);let w=Math.abs(p)+Math.abs(l)===0?0:Math.atan2(l,p);w+=2*(w<0?1:0)*Math.PI;let b=Math.abs(g)+Math.abs(h)===0?0:Math.atan2(h,g);b+=2*(b<0?1:0)*Math.PI;const S=c-i,P=v-y;let _=y*v==0?0:b-w;_-=2*(_>Math.PI?1:0)*Math.PI,_+=2*(_<-Math.PI?1:0)*Math.PI;const T=2*(0,s.sqrt)(y*v)*Math.sin(_/2),M=(i+c)/2,E=(y+v)/2;let k;y*v==0?k=w+b:(k=(w+b)/2,k-=(Math.abs(w-b)>Math.PI?1:0)*Math.PI,k+=2*(k<0?1:0)*Math.PI);const D=(M-50)**2,x=1-.17*Math.cos(k-Math.PI/6)+.24*Math.cos(2*k)+.32*Math.cos(3*k+Math.PI/30)-.2*Math.cos(4*k-63*Math.PI/180),C=1+.015*D/(0,s.sqrt)(20+D),F=1+.045*E,A=1+.015*E*x,I=30*Math.PI/180*Math.exp(-1*((180/Math.PI*k-275)/25)**2),O=2*(0,s.sqrt)(Math.pow(E,7)/(Math.pow(E,7)+Math.pow(25,7))),L=-1*Math.sin(2*I)*O;return(0,s.sqrt)(Math.pow(S/(n*C),2)+Math.pow(P/(a*F),2)+Math.pow(T/(o*A),2)+L*P/(a*F)*T/(o*A))}t.ciede2000_delta_e=l},76490:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColor=t.dominantColorsToRgbHex=void 0;const r=i(40958),s=i(31586),n=i(97352),a=i(54772),o=i(85810),l=i(42022),u=i(1971);t.dominantColorsToRgbHex=function(e){return(0,r.compact)(e.map((e=>[e.rgbhex,(0,s.fmtPct)(e.pct)])))};class c{static fromModeData(e){return(0,r.compact)((0,s.times)(u.ModeCount,(t=>c.fromLabhash({labhash:e[`mode${t}`],pct:e[`mode${t}pct`]}))))}static toModeData(e){const t={};return(0,s.times)(u.ModeCount,(i=>{t["mode"+i]=e[i]?.labhash??null,t["mode"+i+"pct"]=e[i]?.pct??null})),t}static fromLabhash({labhash:e,labhashBits:t=l.ModeBits,pct:i}){const r=(0,n.mapGt0)(e,(e=>(0,o.unlabhash)(e,t)));return null!=r&&(0,s.gt0)(i)?new c(r,i,e):void 0}static fromCentroid(e,t){return new c(e.centroid,Math.round(e.size/t*100))}constructor(e,t,i){this.lab=e,this.pct=(0,s.clamp)(0,100,t),this.labhash=i??(0,o.toLabhash)(e,l.ModeBits)}get rgbhex(){return(0,o.lab2rgbhex)(this.lab)}get color(){return(0,a.bestLabhashName)(this.labhash)}toGreyscale(){return new c([this.lab[0],0,0],this.pct)}eql(e){return this.labhash===e.labhash&&(0,s.closeTo)(this.pct,e.pct,5)}}t.DominantColor=c},32848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scaled_delta_e=t.dominantColorCorrelation=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(48884),o=i(31843),l=i(70417),u=i(3048);function c(e,t){const i=(0,s.sum)(e,(e=>(0,n.clamp)(0,100,e.pct))),r=(0,s.sum)(e,(e=>function(e,t){const i=(0,a.leastBy)(t,(t=>(0,u.ciede2000_delta_e)(e.lab,t.lab)));if(null==i)return 0;const r=(0,u.ciede2000_delta_e)(e.lab,i.lab),s=(0,n.clamp)(0,e.pct,(0,l.avg)([e.pct,i.pct])),o=h(r);return(0,n.clamp)(0,100,s)*o}(e,t)));return r/i}t.dominantColorCorrelation=function(e,t){return e=(0,s.compact)(e),t=(0,s.compact)(t),(0,s.isEmpty)(e)||(0,s.isEmpty)(t)?0:(0,l.avg)([c(e,t),c(t,e)])};const d=(0,r.lazy)((()=>[{x:0,y:1},{x:9,y:.8},{x:16,y:.3},{x:20,y:0}]));function h(e){return(0,n.clamp)(0,1,(0,o.lerp2d)(e,...d()))}t.scaled_delta_e=h},40401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeNearCentroids=t.mergeLabhashes=t.dominantColorsFromModes=t.maybeFilterGrey=t.centroidsScore=t.extractDominantColors=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(41400),o=i(98553),l=i(31586),u=i(68708),c=i(48884),d=i(22454),h=i(50213),f=i(56038),m=i(82647),p=i(44983),g=i(70417),y=i(28874),v=i(85810),w=i(3048),b=i(76490),S=i(1971),P=(0,r.lazy)((()=>(0,h.mkLogger)("color.DominantColors")));t.extractDominantColors=function(e,t=S.ModeCount){return(0,f.timeSync)("img.extractDominantColors",(()=>function(e,t=S.ModeCount){const i=Date.now(),r=y.Settings.dominantColorKmeansRuns.valueOrDefault,a=new d.CountingSet;for(const i of E({labs:e,minK:t}))a.incr((0,v.toLabhash)(i));const h=T[y.Settings.dominantColorDeltaE.valueOrDefault]??w.ciede2000_delta_e;const f=a.sortedByKey().valuesToA((e=>(0,v.unlabhash)(e)));let g=(0,l.round)(t+y.Settings.dominantColorMergeThreshold.valueOrDefault);function D(e){const i=t,r=4*t;g=Math.round(Math.max(i,Math.min(r,e)))}const C=f.length<=g?[]:(0,s.compact)(_.slice(0,r).map((e=>{const r=(0,p.kmeans)(f,g,{...M,seed:e}),s=x(r.centroids,f.length);if(s.lengtht&&D(g-1);const n=s.slice(0,t),o=(0,l.sigFigs)(function(e){const t=new m.Average;for(const[i,r]of a.entries()){const s=(0,v.unlabhash)(i),n=(0,c.leastByCtx)(e,(e=>h(e.centroid,s)));null!=n&&(0,l.times)(r,(()=>t.push(n.value)))}return t.p84}(n),2);return{...r,centroids:n,description:{kIn:g,kOut:r.centroids.length,kMerged:s.length,score:o,iterations:r.iterations,uniqColors:a.size,elapsedMs:Date.now()-i},score:o}})));P().trace("extractDominantColors()",{kmeansResults:C.map((e=>(0,u.pick)(e,"description","score")))});const F=(0,c.leastBy)(C,(e=>e.score));if(null==F)return P().info("kmeans failed or was disabled, using dominantColorsFromModes",{runs:r}),k(a,t);const A=(0,o.stringify)({...F?.description,elapsedMs:Date.now()-i}),I=(0,n.sortBy)(F?.centroids,(e=>-e.size)).map((e=>b.DominantColor.fromCentroid(e,f.length)));return P().debug("extractDominantColors() result",{description:A,score:F?.score,totalColors:a.size,totalPixels:f.length,iters:F?.iterations,dominantColors:(0,b.dominantColorsToRgbHex)(I),pixelCount:f.length}),{dominantColors:I,description:A,dominantColorScore:F?.score}}(e,t)))},t.centroidsScore=function(e,t){const i=new m.Average;for(const r of e){const e=(0,c.leastBy)(t,(e=>(0,w.ciede2000_delta_e)(e.centroid,r)));null!=e&&i.push((0,w.ciede2000_delta_e)(e.centroid,r))}return i};const _=[6147062518717073,8176726750919909,5426648081701673,0xce2a345532a3c,0x713f9716da824,6348935463312109,5900323173950995,7358780886584433,5704068712193493,0x51ceeef755892,0xe1557fe94c084,0xd42d7cc96d6b4,0xcbc36dfd76e8a,6738189173486085,8537822851166899,5390086061821835,7712057976331355,0xe9b820db7a8e4,0xb96cebcd6aa40,7036994544380825,5353634786120155,0x99a11417794bc,0xa93d36019aaae,0x74a470887095e,5481147022770415,5347523348244809,0x541d1098e90fc,0xa24d9fb3510c2,0x78aa8e4f692fa,6354921850669697,0x714e1ec1b0a14,8622097963014773,0x6ff5d462d8eb6,0x6782a6b5166b8,7128984079394103,0xe6efba28a3752,5088704486053871,0xc84df40627fae,8018285280412081,4524300326741245,8307147030534695,8135486835878813,7699950603263999,0xb2889592968ae,5903399874280295,7462660765348991,6442509751447017,0xe218d44834db6,7214173935589545,6001326758941961,0x53eb7d39bbb50,0xc3a7ab8add332,0x4e6e81bc443e2,6757635537583321,8501611905255957,0x51840465cc07c,5958243312989149,8928005021308717,5032083390680559,0xb35d70ac51c68,0xfc3826a2dfe7c,0xd155853c61e96,0xda2045ee9be1e,4753952745315177],T={cie76:w.cie76_delta_e,cie94:w.cie94_delta_e,ciede2000:w.ciede2000_delta_e},M=(0,r.lazy)((()=>({maxIterations:50,initialization:"kmeans++",distanceFunction:T[y.Settings.dominantColorDeltaE.valueOrDefault]})));function E({labs:e,minK:t,thresh:i,retries:r=3}){if(r<0)return P().debug("maybeFilterGrey(): exhausted retries: grey filtering disabled."),e;const s=i??y.Settings.dominantColorGreyThreshold.valueOrDefault;if(!(0,l.gt0)(s))return P().debug("maybeFilterGrey(): grey threshold is <= 0: grey filtering disabled."),e;const n=e.filter((e=>Math.abs(e[1])+Math.abs(e[2])>=s));return n.length>=e.length/2?(P().debug("maybeFilterGrey(): sufficient remaining pixels with this threshold.",{greyThreshold:s,minK:t,pixelCount:e.length,filteredCount:n.length}),n):(P().debug("maybeFilterGrey(): insufficient remaining pixels with this threshold. Retrying with smaller threshold.",{greyThreshold:s,minK:t,retries:r,pixelCount:e.length,filteredCount:n.length}),E({labs:e,minK:t,thresh:.75*s,retries:r-1}))}function k(e,t){const i=e.countSum,r=e.size;D(e);const n=e.size,a=(0,s.compact)(e.top(t).map((([e,t])=>b.DominantColor.fromLabhash({labhash:e,pct:Math.round(100*t/i)})))),l=100-(0,g.sumf)(a,(e=>e.pct));return{dominantColors:a,description:"dominantColorsFromModes: "+(0,o.stringify)({uniqColors:r,mergedColors:n,pixelCount:i,pctOmitted:l})}}function D(e,t=y.Settings.dominantColorMergeThreshold.valueOrDefault){const i=[];for(const[r,s]of[...e.entriesByCountDesc()]){const n=(0,v.unlabhash)(r),a=i.find((e=>(0,w.ciede2000_delta_e)(e.lab,n)<=t));null==a?i.push({lab:n,labhash:r}):(e.delete(r),e.incr(a.labhash,s))}return e}function x(e,t,i=y.Settings.dominantColorMergeThreshold.valueOrDefault){if(i<=0)return e;const r=[];for(const t of e){const e=r.find((e=>(0,w.ciede2000_delta_e)(t.centroid,e.centroid)<=i));null==e?r.push(t):e.size+=t.size}const s=t/100;return(0,n.sortBy)(r.filter((e=>e.size>s)),(e=>-e.size))}(0,a.later)((()=>{y.Settings.dominantColorDeltaE.watchLater((()=>{M.unset()}))})),t.maybeFilterGrey=E,t.dominantColorsFromModes=k,t.mergeLabhashes=D,t.mergeNearCentroids=x},85409:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Greys=void 0,t.Greys=[{name:"Black",rgb:"#000000"},{name:"90% black",rgb:"#1b1b1b"},{name:"80% black",rgb:"#303030"},{name:"70% black",rgb:"#474747"},{name:"60% black",rgb:"#5e5e5e"},{name:"Grey",rgb:"#777777"},{name:"60% white",rgb:"#919191"},{name:"70% white",rgb:"#ababab"},{name:"80% white",rgb:"#c6c6c6"},{name:"90% white",rgb:"#e2e2e2"},{name:"White",rgb:"#ffffff"}]},86758:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.labsAreGreyscale=t.isLab=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(82647),o=i(28874),l=i(85810),u=(0,r.lazy)((()=>(0,n.mkLogger)("color.Lab")));t.isLab=function(e){return Array.isArray(e)&&3===e.length&&(0,s.within)(0,100,e[0])&&(0,s.within)(-110,110,e[1])&&(0,s.within)(-110,110,e[2])},t.labsAreGreyscale=function(e){const t=o.Settings.greyscaleColorThreshold.valueOrDefault,i=new a.Average,r=new a.Average;for(const t of e){const e=(0,l.clampLab)(t);i.push(e[1]),r.push(e[2])}const s=(i.stdDev??0)+(r.stdDev??0),n=s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LightWikipediaColors=void 0,t.LightWikipediaColors=[{name:"Beige",rgb:"#F5F5DC"},{name:"Laurel green",rgb:"#A9BA9D"},{name:"Light sage",rgb:"#93A58B"},{name:"Light green-cyan",rgb:"#CFEADE"},{name:"Pastel purple",rgb:"#B39EB5"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Powder blue",rgb:"#B0E0E6"},{name:"Vanilla",rgb:"#F3E5AB"}]},42022:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeBits=void 0,t.ModeBits=12},1971:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeCount=void 0,t.ModeCount=7},85434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitModeData=t.pickModeData=t.ModeDataKeys=t.isModeData=void 0;const r=i(31586),s=i(68708),n=i(50989);t.isModeData=function(e){return(0,r.gt0)(e.mode0)&&(0,r.gt0)(e.mode0pct)},t.ModeDataKeys=(0,n.strEnum)("mode0","mode0pct","mode1","mode1pct","mode2","mode2pct","mode3","mode3pct","mode4","mode4pct","mode5","mode5pct","mode6","mode6pct"),t.pickModeData=function(e){return(0,s.pick)(e,...t.ModeDataKeys.values)},t.omitModeData=function(e){return(0,s.omit)(e,...t.ModeDataKeys.values)}},85042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clampRGB=t.rgbTriplet2hex=t.rgbhex2triplet=t.normalizeRgbHex=void 0;const r=i(31586),s=i(39926),n=i(51926),a=i(54993),o=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;function l(e){return[e[0],e[1],e[2]].map((e=>(0,r.clamp)(0,255,Math.round(e))))}t.normalizeRgbHex=function(e){const t=(0,a.toS)(e).trim();return o.test(t)?(0,n.ensurePrefix)(t,"#").toUpperCase():void 0},t.rgbhex2triplet=function(e){const t=(0,a.toS)(e).trim().match(o);if(null!=t)try{return[t[1],t[2],t[3]].map((e=>(0,r.clamp)(0,255,parseInt(e,16))))}catch{return}},t.rgbTriplet2hex=function(e){return"#"+l(e).map((e=>(0,s.leftPad)(Math.round(e).toString(16).toUpperCase(),2,"0"))).join("")},t.clampRGB=l},76596:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),s=i(19851),n=i(22573),a=i(42659),o=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,s.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,o.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,o.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,a.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const r=i(77988),s=i(19851),n=i(55835),a=i(31586),o=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,s.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),h=["year","month","day","hour","minute","second","millisecond"];class f{static fromISO(e,t){const i=d().exec((0,o.toS)(e).trim()),r=i?.groups;return null==r?void 0:f.for((0,c.parseExifDateTime)(r.start,t),(0,c.parseExifDateTime)(r.end,t),(0,a.toInt)(r.index),(0,a.toInt)(r.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,n.map)(e.start,(e=>r.ExifDateTime.fromJSON(e))),(0,n.map)(e.end,(e=>r.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,r=1){if(null==e||!e.isValid||null==t||!t.isValid)return;r=(0,a.clamp)(1,1e3,(0,a.toInt)(r,{defaultValue:1})),i=(0,a.clamp)(0,r-1,(0,a.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const s=e.toMillis(),n=(t.toMillis()-s)/(r+1)*(i+1),o=e.plus({milliseconds:n});return null==o?void 0:new f(e,o,t,i,r)}constructor(e,t,i,r=0,s=1){this.start=e,this.middle=t,this.end=i,this.index=r,this.splits=s,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=h.map((r=>function({start:e,end:t,middle:i,field:r}){return null!=e[r]&&null!=t[r]?i[r]:void 0}({start:e,middle:t,end:i,field:r})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new f(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=f},79842:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(76790),o=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),h=i(51926),f=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),v=i(21330),w=i(928),b=i(54261),S=i(73389),P=i(51275),_=(0,n.lazy)((()=>(0,f.mkLogger)("date.Dated")));function T(e){return null!=e&&(e instanceof v.FuzzyDate||e instanceof r.ExifDate||e instanceof r.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,S.isDateTime)(e)||(0,m.isDateObject)(e))}function M(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof r.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function E(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof r.ExifDate?e.toMillis(l.dayMs):e instanceof v.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),D(e),((e,t)=>e+t))}function k(e){try{if(null==e||(0,h.isString)(e)||(0,c.isNumber)(e))return;return(0,S.isDateTime)(e)?e:e instanceof r.ExifDateTime||e instanceof v.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?s.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void _().warn("datedToDateTime() failed",{d:e,error:t})}}function D(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,b.hasTime)(e)){if((0,c.gt0)((0,w.getMillisecond)(e)))return 0;if((0,c.gt0)((0,w.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,w.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,w.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,w.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,w.getMonth)(e))?l.monthMs-1:l.yearMs-1}function x(e,t){const i=M(e),r=E(e);if(null!=i&&null!=r)return(0,c.gt0)(t)&&t>r-i?{start:Math.round((i+r)/2-t/2),end:Math.round((i+r)/2+t/2)}:{start:i,end:r}}function C(e,t,i,r){const[s,n]=(0,a.sortBy)([x(e,i),x(t,r)],(e=>e?.start));return null!=s&&null!=n&&null!=s&&null!=n&&(s.start===n.start||s.end>=Math.min(n.start,n.end))}function F(e,t){return(0,o.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??v.FuzzyDate.fromISO(e)}t.isDated=T,t.toDated=function(e){return T(e)?e:void 0},t.mapDated=function(e,t){return T(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=M,t.datedToEndTs=E,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof r.ExifDate?s.DateTime.fromObject(e):k(e)},t.datedToDateTime=k,t.datedToPrecisionMs=D,t.isoToPrecisionMs=function(e){return(0,u.map)(F(e),D)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:r}){if(null==e||null==t)return!1;if(i??(i=D(e)),r??(r=D(t)),C(e,t,i,r))return!0;const s=(0,P.getZoneName)(e),n=(0,P.getZoneName)(t);return null==s&&null!=n&&(e=(0,v.setZone)(e,n)??e),null==n&&null!=s&&(t=(0,v.setZone)(t,s)??t),C(e,t,i,r)},t.isoToDated=F,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof s.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const r=i(31586),s=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,s.isString)(e))return(0,r.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),s=i(31586),n=i(54557),a=i(91655),o=new n.FifoCache(512);function l(e){return(0,s.isNumber)(e)?e:(0,r.blank)(e)?void 0:o.getOrSet(e,(()=>(0,a.parseDuration)(e)))}t.decodeDuration=l;const u=new n.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,a.fmtFullDuration)((0,s.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),s=i(40958),n=i(22573),a=i(42659),o=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,o.isNumber)(e))return;if((0,o.isNumber)(e))return e;if((0,o.isDigits)(e))return(0,o.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,s.compact)(d.map((e=>function(e,t){const i=(0,o.toFloat)(e);if(null!=i){if((0,n.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*a.yearMs;case"weeks":case"week":case"w":return i*a.weekMs;case"days":case"day":case"d":return i*a.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*a.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*a.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*a.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,o.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:a.yearMs,s:"y"},{ms:a.weekMs,s:"w"},{ms:a.dayMs,s:"d"},{ms:a.hourMs,s:"h"},{ms:a.minuteMs,s:"m"},{ms:a.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,o.isNumber)(t))return;if(0===t)return"0";if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},98247:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),h=i(68852),f=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function v(e,t,i){const r=t.exec(e);if(null==r||(0,u.isEmptyObj)(r.groups))return;const{year:s,month:n,day:a,hour:c,minute:h,second:p}=(0,d.mapEntries)(r.groups,((e,t)=>(0,l.toInt)(t)));if(null==s||null==n||null==a)return;if(!f.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==h))return;const g=(0,o.map)((0,l.toFloat)(r.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),v=(0,y.timezoneOffsetFromRegExpMatch)(r);return S({year:s,month:n,day:a,hour:c??0,minute:h??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(v)??i,rawValue:e,tzoffsetMinutes:v})}t.UnsetZone=s.Info.normalizeZone(r.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof r.ExifDate&&t instanceof r.ExifTime))return;const i=new r.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:n}){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromFormat(e,i,{zone:n??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,a.blank)(e)?void 0:r.ExifDateTime.from(e,t)??v(e,b(),t)},t.parseExifDateTimeRe=v;const w=/[-:_\s]?/,b=(0,n.lazy)((()=>(0,h.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,w,p.monthRE,w,p.dayRE,/[T\s]/,p.hourRE,w,p.minuteRE,w,p.secondRE,p.subsecRE,/\s?/,h.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function S(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof r.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=r.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,o.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=S},74417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const r=i(51168),s=i(22573),n=i(42659),a=i(49769),o=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),h=i(66649),f=i(98725),m=i(88600);t.recent=function(e,t=5*n.secondMs){return(0,c.isRecentMs)((0,h.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=r.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,s.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,s.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=r.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,a.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,h.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,o.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*n.secondMs):void 0)??(0,f.parseDateTime)(t)?.toMillis()}},12959:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filestampUTC=t.filestamp=void 0;const r=i(39926);t.filestamp=function(e=new Date){return[e.getFullYear(),(0,r.pad2)(e.getMonth()+1),(0,r.pad2)(e.getDate()),"-",(0,r.pad2)(e.getHours()),(0,r.pad2)(e.getMinutes()),(0,r.pad2)(e.getSeconds())].join("")},t.filestampUTC=function(e=new Date){return[e.getUTCFullYear(),(0,r.pad2)(e.getUTCMonth()+1),(0,r.pad2)(e.getUTCDate()),"-",(0,r.pad2)(e.getUTCHours()),(0,r.pad2)(e.getUTCMinutes()),(0,r.pad2)(e.getUTCSeconds())].join("")}},21330:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const n=i(77988),a=i(51168),o=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(31586),f=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),v=i(79842),w=i(66649),b=i(98247),S=i(98725),P=i(928),_=i(54261),T=i(73389),M=i(89724),E=i(17415),k=i(88600),D=i(51275);function x(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class C{constructor(e,t,i){this.year=e,this.month=t,this.day=i,r.set(this,(0,p.lazy)((()=>(0,k.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(S.ISO_YMD_RE.exec(e)?.groups??S.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,h.toGt0)(e?.year);if(null==e||null==t||tx(e))).join("-")}toLocal(){return(0,M.datedToLocal)(this)}toDateTime(){return a.DateTime.fromObject((0,f.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,f.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,f.pick)(e.plus({month:1}),"year","month"):(0,f.pick)(e.plus({year:1}),"year");return new C(t.year,t.month,t.day)}}function F(e,t){if(e instanceof n.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,_.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,E.zoneToTzOffsetMinutes)((0,w.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(r=>(0,d.map)((0,P.getMonth)(e),(s=>(0,d.map)((0,P.getDay)(e),(n=>(0,d.map)((0,P.getHour)(e),(a=>(0,b.dateObjectToExifDateTime)({year:r,month:s,day:n,hour:a,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=C,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",r=15*(0,h.round)(e/15),s=Math.abs(r),n=Math.floor(s/60),a=Math.floor(Math.abs(s%60));return`${t?"UTC":""}${i}${x(n)}:${x(a)}`},t.toExifDateTime=F,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof n.ExifDateTime?e.tzoffsetMinutes:(0,T.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,_.hasTime)(e)||(i??(0,v.datedToPrecisionMs)(e))>=c.dayMs?O(e):F(e,(0,D.getZoneName)(e))?.toISOString({includeOffset:t})};const A="yyyy:MM:dd HH:mm:ss.SSS",I=A+"ZZ";function O(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>x(e))).join(t)}function L(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new C(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,r]=[e,t].map(w.datedToMillis);return null==i||null==r?void 0:i-r}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,h.isNumber)(t)?a.DateTime.fromMillis(t):(0,v.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,D.hasZone)(t)?I:A):void 0},t.datedToYMD=O,t.toFuzzyDate=L,t.sameDay=function(e,t){return(0,h.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,h.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,r=1){if(null==(0,w.datedToMillis)(e)||null==(0,w.datedToMillis)(t))return;const[s,n]=[e,t].map((e=>(0,w.datedToMillis)(e))).sort(),o=(n-s)/(r+1),l=(0,D.getZoneName)(e),u=l===(0,D.getZoneName)(t)?l:void 0,c=a.DateTime.fromMillis(s+o*i,{zone:u});return[e,t].some((e=>!(0,_.hasTime)(e)))?L(c):c},t.setZone=function(e,t,i){const r={...(0,f.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,D.hasZone)(e)},s=(0,E.normalizeZone)(t);if(null!=e&&null!=s&&(0,_.hasTime)(e))return e instanceof y.DateInterval?e.setZone(s,r):F(e)?.setZone(s,r)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,h.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,v.datedToDateTime)(e);if(null==i)return;const r=(0,D.getZoneName)(e);return null!=r&&"UTC"!==r||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const o=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),h=i(49769),f=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),v=i(68852),w=i(4001),b=i(28874),S=i(24689),P=i(79842),_=i(66649),T=i(98247),M=i(21330),E=i(54261),k=i(73389),D=i(16400),x=i(88600),C=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return C().tap({msg:"extractDateFromPath",result:O.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return O.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return O.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,f.mapNumeric)((0,_.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,v.concatRegexp)([/^/,t.yearRE,v.RegExpOptional.from(/-/,t.monthRE,v.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,v.concatRegexp)([/^/,t.yearishRE,v.RegExpOptional.from(/-/,t.monthishRE,v.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=I({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,k.isDateTime)(i)?i:(0,E.isExifDateTime)(i)?i.toDateTime():void 0};const F=new Map;function A(e,t,i){try{const r=(0,T.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=r)return r;const s=(0,h.getOrSet)(F,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void C().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,T.parseExifDateTimeFormat)({input:s?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void C().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function I({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:r=!0,descPredicate:s=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const n=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(w.stripDSC));if(0!==n.length)for(const{desc:e,f:a}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>S.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,T.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:T.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(b.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(b.Settings.extraDateTimeFormats.values)){const r=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${r})`,f:i=>A(i,r,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>o.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of O.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:r}))if(s(e))for(const e of n){const t=a(e);if(null!=t&&(0,x.isValidDate)(t))return t}}t.parseDated=I;class O{constructor(e={}){r.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&b.Settings.fuzzyDateParsing.watchLater((()=>a(this,r,"m",n).call(this))),null==e.fuzzyYearParsing&&b.Settings.fuzzyYearParsing.watchLater((()=>a(this,r,"m",n).call(this))),a(this,r,"m",n).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??b.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??b.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!b.Settings.usePathsToInferDates.valueOrDefault)return;M.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=I({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=O,r=new WeakSet,s=function(e){const t=new L(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},n=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new v.RegExpEscaped("(?"+(0,D.monthNames)().map(v.escapeRegExp).join("|")+")");a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE]),a(this,r,"m",s).call(this,[e,t.seps,t.yearRE]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,e]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},O.instance=(0,u.lazy)((()=>new O));class L{constructor(e){this.regex=e instanceof RegExp?e:(0,v.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return M.FuzzyDate.for({year:(0,f.toInt)(t.year),month:(0,f.toInt)(t.month)??(0,D.monthName2index)(t.monthname),day:(0,f.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const r=i(55835),s=i(31586),n=i(54261);function a(e){return e instanceof Date?e.getMinutes():e?.minute}function o(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=a,t.getSecond=o,t.getMillisecond=l,t.getCentisecond=function(e){return(0,r.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,n.hasTime)(e)&&((0,s.gt0)(a(e))||(0,s.gt0)(o(e))||(0,s.gt0)(l(e)))},t.getSecMs=function(e){return(0,r.map)(o(e),(t=>{const i=l(e)??0;let r=(t+i/1e3).toString();for(t<10&&(r="0"+r),0===i&&(r+=".");r.length<6;)r+="0";return r}))}},54261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const r=i(77988),s=i(31586),n=i(68708);t.hasTime=function(e){if(!(0,n.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,s.gt0)(t.hour)||(0,s.gt0)(t.minute)||(0,s.gt0)(t.second)||(0,s.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof r.ExifDateTime}},73389:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const r=i(51168);t.isDateTime=function(e){return r.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const r=i(51168),s=i(19851),n=i(42659),a=i(55835),o=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),h=i(74417),f=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,s.lazy)((()=>v(l.Settings.datesBeforeAreEstimated.valueOrDefault)??v(l.Settings.datesBeforeAreEstimated.defaultValue)));function v(e){return(0,a.map)((0,c.isoToDated)(e),w)}function w(e){return(0,o.isNumber)(e)?T(e):100*b(e)+((0,m.getCentisecond)(e)??0)}function b(e){if((0,o.isNumber)(e))return Math.floor(T(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function S(e,t){if(null==e||e<0)return;let i=e;const r=()=>{const e=i%100;return i=Math.floor(i/100),e},s=10*r(),n=r(),a=r(),l=(0,o.toGt0)(r()),u=(0,o.toGt0)(r()),c=(0,o.toGt0)(r());return{year:i,month:c,day:u,hour:l,minute:a,second:n,millisecond:s,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=S(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):f.FuzzyDate.for(i)}function _(e,t){return T(Date.now()-e,t)}function T(e,t){return w(r.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const r=i(19851),s=i(76790),n=i(31586),a=i(9092),o=(0,r.lazy)((()=>{const e=new a.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const r=new Intl.DateTimeFormat(t,{month:i});(0,n.times)(12,(s=>{const n=r.format(new Date(2017,s));e.set(n,s+1),"short"===i&&"en-US"===t&&e.set(n+".",s+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:o().get(e)},t.monthNames=function(){return(0,s.sort)([...o().keys()])}},42499:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLuxon=void 0;const r=i(51168),s=i(19851),n=i(19043),a=i(28874);t.setupLuxon=(0,s.lazy)((async()=>{r.Settings.throwOnInvalid=!1,a.Settings.twoDigitCutoffYear.watch((e=>r.Settings.twoDigitCutoffYear=e)),r.Settings.defaultLocale=await(0,n.locale)()}))},17415:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),h=i(54993),f=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,n.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const r=(0,f.leastBy)(g(),(t=>Math.abs(t-e)));return null!=r&&Math.abs(r-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(r)}t.isUTCZone=function(e){return b(e)||0===S(e)?.offset(Date.now())},t.normalizeZone=S,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,o.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=_,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:_(i)};const T=/\b(?Z|UTC|GMT)\b/,M=/(?[-±+−])/,E=/[-−]/,k=/(?[01]\d)/,D=/(?[01]?\d)/,x=/(?::(?\d\d))/;function C(e){return b(e)?0:F((0,t.TimezoneOffsetRE)().exec(e))}function F(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,a.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=E.test((0,h.toS)(e.groups.tzSign))?-1:1,r=(0,l.toInt)(e.groups.tzMinutes)??0,s=null==t?void 0:i*(60*t+r);return v(s)?s:void 0}t.TimezoneOffsetRE=(0,n.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),T,new m.RegExpEscaped("|"),M,k,m.RegExpOptional.from(x),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=C,t.timezoneOffsetFromRegExpMatch=F;const A=/\b(?(?:Etc\/)?GMT)\b/,I=(0,n.lazy)((()=>(0,m.concatRegexp)([A,M,D,m.RegExpOptional.from(x)])));function O(e){return F(I().exec(e))}t.ianaZoneToOffsetMinutes=O,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,a.blank)(e))return;const i=O(e)??C(e);if(null!=i)return _(i);if(null!=t){const i=S(e);if(null!=i)return _(i.offset(t))}}},88600:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),h=i(28874),f=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),v=(0,s.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),w=(0,s.lazy)((()=>(0,n.compact)(h.Settings.badDates.values.map((e=>(0,f.isoToDated)(e)))))),b=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,p.datedToISO)(e)))))),S=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,y.datedToLocal)(e)))))),P=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,m.datedToMillis)(e))))));function _(e){if(null==e)return!1;const t=M(e);return v().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return _(e)?e:void 0},t.isValidDate=_;const T=String(new Date("bad"));function M(e){try{if(!(0,f.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===T)return T;const t=(0,n.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const s=[];if((0,l.isNumber)(e)||s.push("year is not a number"),(0,l.lt)(e,h.Settings.minValidYear.valueOrDefault)&&s.push("year is less than "+h.Settings.minValidYear.key),(0,u.gt)(e,E())&&s.push("year is in the future"),null==t&&null!=i&&s.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const n=r.DateTime.fromObject({year:e,month:t,day:i});n.isValid||s.push(n.invalidExplanation??"not valid")}return(0,n.compact)(s)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=h.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const r=(0,m.datedToMillis)(e);(0,u.gt)(r,Date.now()+i)&&t.push("date is too far in the future: see "+h.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):S().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):b().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,a.toNotBlank)((0,n.uniq)((0,n.compactBlanks)(t)).join("; "))}catch(t){return v().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=M;const E=(0,s.lazy)((()=>r.DateTime.now().plus({milliseconds:h.Settings.maxValidFutureMs.valueOrDefault}).year),o.dayMs);t.mapValidDate=function(e,t){return _(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==M({year:e,month:t,day:i})}},51275:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const r=i(77988),s=i(31586),n=i(24689),a=i(73389);t.hasZone=function(e){return null!=e&&!(0,s.isNumber)(e)&&(e instanceof n.DateInterval||e instanceof r.ExifDateTime?e.hasZone:!!(0,a.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==r.UnsetZoneName&&e.zone.offset(Date.now())!==r.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,a.isDateTime)(e)?e.zoneName===r.UnsetZoneName?void 0:e.zone?.name:e instanceof r.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},82261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cacheDbDir_=void 0;const r=i(51926),s=i(49776),n=i(38835),a=i(95696),o=i(70854),l=i(73428),u=i(28874),c=i(15056);t.cacheDbDir_=async function(e=u.Settings.libraryDir.valueOrDefault,t=c.Schemas.models){const i=(0,o.libraryUidStore)(e);if(null==i)throw new Error("Library directory is not set"+n.NoLibraryErrorFlag);const d=await i.readUid_(),h=a.PosixFile.for((0,s.cacheDir_)()).join(t+"-live-db",d);await h.mkdirp_();const f=h.join("README.txt");return await(0,l.writeTextfile_)(f.nativePath,...(0,r.wrap)(["This folder is used by PhotoStructure for your library stored in",e,"You will corrupt your library if you remove this directory while PhotoStructure is running.","See https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837 for details."].join("\n\n"))),h}},92407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLiveDbDir_=t.cacheDbFile_=void 0;const r=i(19851),s=i(87290),n=i(50213),a=i(28874),o=i(82261),l=i(15056),u=i(7311),c=i(44955),d=(0,r.lazy)((()=>(0,n.mkLogger)("db.CheckLocalDbReplica")));async function h({libraryDir:e=a.Settings.libraryDir.valueOrDefault,schema:t=l.Schemas.models}={}){return(await(0,o.cacheDbDir_)(e,t)).join(u.SqliteBase)}t.cacheDbFile_=h,t.getLiveDbDir_=async function(e=a.Settings.libraryDir.valueOrDefault){if(!a.Settings.forceLocalDbReplica.valueOrDefault){const t=(0,l.pathToDb)(await(0,s.setupLibraryDataDir_)(e),l.Schemas.models);try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!1}}catch(e){d().info("SQLite cannot directly write to the library: trying to use a local db replica.",{libraryDb:t,error:e})}}const t=await h({libraryDir:e,schema:l.Schemas.models});try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!0}}catch(e){return d().throw("SQLite cannot directly write to the library or the cacheDir.",{cacheDbFile:t,error:e})}}},5531:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},55332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupCold_=void 0;const r=i(19851),s=i(50213),n=i(76187),a=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbBackupCold")));t.dbBackupCold_=async function(e,t){await t.mkdirp_();const i=[];try{for(const r of(0,n.sqliteFiles)(e)){const e=t.join(r.base).wip();i.push(e),await r.copyFile_(e)}return a().tap({msg:"completed",level:"info",result:await Promise.all(i.map((e=>e.unwip_()))),meta:{srcDbFile:e,destDir:t}})}catch(e){throw await Promise.all(i.map((e=>e.unlink()))),e}}},91872:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleDbRetries_=void 0;const r=i(50213),s=i(70025),n=i(28874),a=i(45599),o=i(41400),l=i(30976),u=i(56038),c=(0,a.defer)((()=>(0,r.mkLogger)("db.DbRetries")));t.handleDbRetries_=function(e,t,i,r){const a=Date.now();let d=0;const h=a+n.Settings.maxBusyDbMs.valueOrDefault;return(0,u.time)(e,(async()=>{for(;Date.now()=h)throw c().error(e+": Caught db error. Not retrying.",{error:t}),t;{const i=(0,l.randomInt)(500,1500)*++d;c().warn(e+": Caught db error. Retrying in "+i+"ms.",{name:e,error:t}),r?.(),await(0,o.delay)(i)}}return t().close(),c().throw(e+": handleDbRetries(): timeout after "+n.Settings.maxBusyDbMs.valueOrDefault+"ms")}))}},12943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toDbValued=t.isDbValued=t.isDbValue=void 0;const r=i(79842),s=i(66649),n=i(40958),a=i(68708);function o(e){return null===e||(0,n.includes)(["number","string"],typeof e)}t.isDbValue=o,t.isDbValued=function e(t){return null!=t&&Array.isArray(t)?t.every(e):(0,a.entries)(t).every((([,e])=>o(e)))},t.toDbValued=function(e){return(0,a.mapFields)(e,((e,t)=>{if(!e.startsWith("$"))return"boolean"==typeof t?[e,t?1:0]:o(t)?[e,t]:(0,r.isDated)(t)?[e,(0,s.datedToMillis)(t)]:void 0}))}},65753:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maxBatchPluckSize=void 0;const r=i(19851),s=i(7282),n=i(28874);t.maxBatchPluckSize=(0,r.lazy)((()=>Math.round(n.Settings.dbBatchSelectSize.valueOrDefault*((0,s.isTest)()?.25:5))))},80632:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pageSizeBytes=t.mkdb_=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(54993),u=i(50213),c=i(23560),d=i(65211),h=i(29882),f=i(53265),m=i(66430),p=i(66184),g=i(28874),y=i(15674),v=i(87550);function w(){const e=g.Settings.dbPageSizeBytes.valueOrDefault;return Math.pow(2,(0,a.clamp)(1,28,Math.round(Math.log2(e))))}t.mkdb_=function({nativePath:e,timeoutMs:t=g.Settings.dbBusyTimeoutMs.valueOrDefault,logSql:i=g.Settings.logSql.valueOrDefault}){e=(0,f.resolve)(e),(0,h.mkdirpSync_)((0,r.dirname)(e));const b=(0,h.posixPathFromGrandparent)(e),S=(0,m.nativePathSizeSync)(e),P=(0,u.mkLogger)("db.mkdb("+b+")");if(null!=S){const E=Math.round(S/o.MiB),k=Math.ceil(1.5*E);k>g.Settings.dbCacheSizeMb.valueOrDefault&&(P.info("Dynamically setting dbCacheSize to "+g.Settings.dbCacheSizeMb.value,{db:e,dbFileSizeMb:E}),g.Settings.dbCacheSizeMb.envValue=k);const D=Math.round(1.5*E);D>g.Settings.maxMemoryMb.valueOrDefault&&(P.warn("Large database: setting maxMemoryDb to "+D+"MB",{dbFileSizeMb:E,"Settings.maxMemoryMb":g.Settings.maxMemoryMb.valueOrDefault}),g.Settings.maxMemoryMb.envValue=D)}P.info("Opening "+e+"...");const _={fileMustExist:!1,readonly:!1};if((0,a.gt0)(t)&&(_.timeout=Math.ceil(t)),i){const x=(0,u.mkLogger)("SQLite("+b+")"),C=(0,p.defaultLogLevel)();function F(e,...t){var i;(0,n.blank)(e)||x.log(C,(i=e,(0,l.toS)(i).replace(/\s{2,}/g," ")),{args:t})}_.verbose=F}const T=new v(e,_);P.info("Open. Setting PRAGMAs...");for(const A of(0,s.compact)(['encoding = "UTF-8"',"threads = "+(0,y.maxCpus)(),"foreign_keys = ON","page_size = "+w(),"trusted_schema = 0","cache_size = -"+Math.round(g.Settings.dbCacheSizeMb.valueOrDefault*o.MiB/1024),"locking_mode = NORMAL","journal_mode = WAL",(0,a.gt0)(g.Settings.dbBusyTimeoutMs.valueOrDefault)?"busy_timeout = "+g.Settings.dbBusyTimeoutMs.valueOrDefault:null,"temp_store = MEMORY","synchronous = "+g.Settings.dbSynchronousMode.valueOrDefault,"case_sensitive_like = 0","wal_autocheckpoint = "+((0,c.isDbJanitorService)()?(0,l.toS)(g.Settings.dbWalAutoCheckpoint.valueOrDefault):"0"),"auto_vacuum = "+g.Settings.dbAutoVacuumMode.valueOrDefault]))P.tapThunk({msg:"PRAGMA "+A,result:()=>T.pragma(A)});const M=T;return M.__uid=(0,d.uid)(),M},t.pageSizeBytes=w},99315:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},95704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withIdBatches=void 0;const r=i(40958),s=i(31586),n=i(59455),a=i(65753),o=i(51040);t.withIdBatches=async function(e){const t=(0,s.toGt0)(e.batchSize)??(0,a.maxBatchPluckSize)(),i=(0,o.dbValueToEscapedString)(e.primaryKeyColumnName),l=(0,r.compactBlanks)([i+" > :min",...(0,n.toA)(e.whereClauses)]).join(" AND "),u=e.db.prepare((0,r.compactBlanks)(["SELECT "+i,"FROM "+(0,o.dbValueToEscapedString)(e.tableName),"WHERE "+l,"ORDER BY "+i,"LIMIT :limit"]).join(" "));let c=-1;for(;;){const i=u.pluck().all({min:c,limit:t});if(0===i.length)return;await e.fn(i),c=(0,r.last)(i)}}},76187:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSqliteFile=t.sqliteSizeBytes=t.sqliteFiles=void 0;const r=i(17217),s=i(87391),n=i(7311);t.sqliteFiles=function(e){return[e,...s.SQLiteSuffixes.map((t=>e.sibling(e.base+t)))].filter((e=>e.existsSync({refresh:!0})))},t.sqliteSizeBytes=async function(e){return(await e.size({refresh:!0})??0)+(await e.sibling(e.base+"-wal").size({refresh:!0})??0)};const a=[n.SqliteExt,...[...s.SQLiteSuffixes,"-shm"].map((e=>n.SqliteExt+e))];t.isSqliteFile=function(e){const t=(0,r.basename)(e);for(const e of a)if(t.endsWith(e))return!0;return!1}},51040:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitBatchSql=t.dbValueToEscapedString=void 0;const r=i(40958),s=i(31586),n=i(54993),a=/^\w+$/;t.dbValueToEscapedString=function(e){if((0,s.isNumber)(e))return e.toString();const t=(0,n.toS)(e);return a.test(t)?t:`'${t.replace(/'/g,"''")}'`};const o=/--.+$/gm,l=/\s+/g;t.splitBatchSql=function(e){const t=(0,r.compactBlanks)((0,n.toS)(e).split(/;/).map((e=>e.replace(o,"").replace(l," ").trim()))),i=[];let s;for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertDirSQLiteReadWrite_=t.isDirSQLiteReadWrite=t.firstDirSQLiteReadWrite=void 0;const r=i(19851),s=i(50357),n=i(30976),a=i(50213),o=i(95696),l=i(80632),u=i(76187),c=(0,r.lazy)((()=>(0,a.mkLogger)("db.SQLiteReadWrite")));async function d(e){try{return await h(e),c().info("isDirSQLiteReadWrite(): true",{dirNativePath:e}),!0}catch(t){return c().warn("isDirSQLiteReadWrite(): false",{dirNativePath:e,error:t}),!1}}async function h(e){const t=o.PosixFile.for(e),i=(0,n.randomChars)(8),r=t.child(".test-"+i+".sqlite");let a=null;try{await t.mkdirp_(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3}),a.exec("CREATE TABLE t (s VARCHAR(16) NOT NULL)"),a.exec(`INSERT INTO t (s) VALUES ('${i}')`);{const e=a.prepare("SELECT s FROM t").all();(0,s.eql)(e,[{s:i}])||c().throw("unexpected rows",{rows:e})}a.exec("VACUUM"),a.close(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3});{const e=(0,n.randomChars)(8);a.exec(`INSERT INTO t (s) VALUES ('${e}')`);const t=a.prepare("SELECT s FROM t ORDER BY s").pluck().all();(0,s.eql)(t,[i,e].sort())||c().throw("unexpected rows",{rows:t})}}finally{try{a?.close()}catch{}await Promise.all((0,u.sqliteFiles)(r).map((e=>e.rm())))}}t.firstDirSQLiteReadWrite=async function(...e){for(const t of e)if(null!=t&&await d(t))return t},t.isDirSQLiteReadWrite=d,t.assertDirSQLiteReadWrite_=h},87391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SQLiteSuffixes=void 0,t.SQLiteSuffixes=["-wal","-journal"]},27180:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteVersion_=void 0;const r=i(5916),s=i(84777),n=i(89966),a=i(63870),o=i(87550);t.sqliteVersion_=(0,r.lazyAsync)({later:async function(){let e;try{e=new o(":memory:");const t=e.prepare("select sqlite_version()").pluck().get(),i=await(0,n.sqliteNativePath_)(),r=(await(0,s.stdout_)(i,["-version"],{timeoutMs:(0,a.commandTimeoutMs)()})).trim();return{libraryVersion:t,toolVersion:r.split(/\s+/,1)[0],fullToolVersion:r,sqliteNativePath:i}}finally{e?.close()}},timeoutMs:(0,a.commandTimeoutMs)()})},15056:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),s=i(7311);function n(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=n,t.pathToDb=function(e,t){return n(e,t).join(s.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const a=n(i(76760)),o=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),v=i(70698),w=i(64680),b=i(29882),S=i(45969),P=i(43334),_=i(28874),T=i(41692),M=i(32774),E=i(80612),k=i(32551),D=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function x(){if((0,S.isDocker)())return[{dir:"/tmp/.photostructure-cache"+D(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,a.join)(i,".photostructure-cache"+D()),preexistingDir:i});return e}}function C(){if((0,S.isDocker)())return(0,o.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,a.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+D(),preexistingDir:M.DefaultDockerLibraryDir},...x()]);const e=(0,o.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),a.default.resolve((0,k.homeDir)(),"AppData","Local")]:P.isMac?[a.default.resolve((0,k.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,a.join)((0,k.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,a.join)(e,t),preexistingDir:e})));return i.push(...x()),i}t.tmpCacheDirs=x,t.tmpDirs=function(){return(0,E.filterDirs)({dirs:x(),desc:"tmp"})},t.cacheDirs=C,t.defaultCacheDir=(0,d.lazy)((()=>(0,E.firstDir)({dirs:C(),desc:"cache"})));const F=(0,d.lazy)((()=>{(0,T.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(A)}));function A(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{F();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,b.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=A},46292:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),s=i(45969),n=i(41692),a=i(32774),o=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,n.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,s.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,o.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:a.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:a.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,s.isDocker)()?c:(0,o.desktopConfigDirs)()).map((e=>e.dir))}},79960:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultApplePhotosLibrary=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(45255),o=i(84777),l=i(16287),u=i(57902),c=i(43334),d=(0,r.lazy)((()=>(0,n.mkLogger)("dir.DefaultApplePhotosLibrary"))),h=["read","com.apple.photolibraryd","SystemLibraryPath"];t.defaultApplePhotosLibrary=async function(){if(c.isMac)try{const e=await(0,o.stdout_)("defaults",h,{timeoutMs:a.ShortCommandTimeoutMs});if((0,s.blank)(e))return void d().warn(`"defaults ${h.join(" ")}" returned blank (!!)`);{const t=await(0,l.isReadableDirectory)(e);return d().tap({msg:"defaultApplePhotosLibrary()",level:u.LogLevels.info,result:t?e:void 0,meta:{isReadable:t}})}}catch(e){return void d().warn("defaultApplePhotosLibrary()",e)}}},32774:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),s=i(45969),n=i(32774);t.defaultLibraryDir=function(){return(0,s.isDocker)()?n.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,s.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const s=r(i(76760)),n=i(40958),a=i(72993),o=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),s.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(s.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,o.env)().XDG_DATA_HOME,(0,o.env)().XDG_CONFIG_HOME,s.default.resolve((0,d.homeDir)(),".config")),(0,n.compactBlanks)(e).map((e=>({dir:s.default.join(e,(0,a.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),s=i(96706),n=i(29882);t.envConfigDir=function(){const e=(0,s.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,n.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),s=i(40958),n=i(22573),a=i(66430);function o({dirs:e,desc:t}){for(const{dir:i,preexistingDir:o}of(0,s.compact)(e))if(!(0,n.blank)(i)){if((0,a.isReadWriteableDirectorySync)(i))return i;if((0,n.blank)(o)||(0,a.isReadWriteableDirectorySync)(o))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=o,t.filterDirs=function({dirs:e,desc:t}){return(0,s.compact)(e.map((e=>o({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),s=i(76760),n=i(1708),a=i(19851),o=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,a.lazy)((()=>{const e=[];u.isWin?e.push(n.env.USERPROFILE):e.push(n.env.HOME);for(const t of(0,o.compactBlanks)(e)){const e=(0,s.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),s=i(49776),n=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[n.libraryDataDir,n.libraryPreviewsDir,s.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},48195:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotLibraryDir=t.isLibraryDir=void 0;const r=i(19851),s=i(22573),n=i(98553),a=i(12168),o=i(50213),l=i(15056),u=i(98314),c=i(17217),d=i(16287),h=i(2858),f=i(87290),m=(0,r.lazy)((()=>(0,o.mkLogger)("dir.IsLibraryDir")));function p(e){return null==e?"(null)":(0,n.stringify)((0,c.toNativePath_)(e))}async function g(e){return m().tap({msg:"whyNotLibraryDir("+e+")",result:await y(e)})}async function y(e){if((0,s.blank)(e))return"blank path";const t=(0,c.toNativePath_)(e);try{const e=await(0,d.stat_)(t);if(null==e||!e.isDirectory())return"not a directory"}catch(e){return"cannot read: "+(0,u.errorToS)(e)}const i=(0,f.libraryDataDirPosixFile)(t);if(!0!==await(i?.isDirectory({refresh:!0,logLevel:"trace"})))return"library data directory, "+p(i)+", is not a directory";const r=(0,h.librarySettingsFile)(t)?.clear();if(null==r||!await r.isNonEmptyFile())return"library settings, "+p(r)+", is empty or missing";const n=(0,l.pathToDb)(i,"models")?.clear();if(null==n||!await(n?.isNonEmptyFile(a.KB)))return"library database, "+p(n)+", is empty or missing";const o=(0,f.libraryPreviewsDirPosixFile)(t);return!0!==await(o?.isDirectory({refresh:!0,logLevel:"trace"}))?"library previews, "+p(o)+", is empty or missing":void 0}t.isLibraryDir=async function(e){return null==await g(e)},t.whyNotLibraryDir=g},9595:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),s=i(54993),n=i(29882),a=i(28874);function o(e){return(0,r.toNotBlank)((0,s.toS)(e))??a.Settings.libraryDir.valueOrDefault}t.libraryDir=o,t.originalsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,n.resolveMaybe)(o(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),s=i(55835),n=i(37805),a=i(15056),o=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${n.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function v(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+o.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function w(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function b(e){return y(w(e),!1)}function S(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(S(e))}function _(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function T(e){return y(_(e))}async function M(e){return y((0,s.map)(g(e),(e=>(0,a.pathToDbDir)(e,a.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await v(t);return(0,r.uniq)([t,i,await b(t),await P(t),await T(t),await M(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=v,t.libraryOriginalsDirPosixFile=w,t.setupLibraryOriginalsDir_=b,t.libraryPreviewsDirPosixFile=S,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=_,t.setupLibrarySyncReportsDir_=T,t.setupLibraryDbDir_=M},46296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),v=i(80612),w=i(32551);function b(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:s.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,a.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>s.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function S(){return(0,v.firstDir)({dirs:b(),desc:"logs"})}t.defaultLogDirs=b,t.defaultLogDir_=S,t.logDir=(0,n.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,o.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,o.notBlank)(i)?i:S()}catch(e){return console.error("defaultLogDir_() failed",e),s.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(44198),o=i(43334),l=i(24399),u=i(32551);async function c(){return o.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,s.lazy)((async()=>{if(o.isWin){const e=await c();if((0,n.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,s.lazy)((()=>(0,a.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),s=i(7282),n=i(29325),a=i(44198);t.getDevEnvFlag=function(e){return!(0,s.isProd)()&&!(0,n.isPacked)()&&((0,r.toBoolean)((0,a.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,a.env)()[e]=String(t)}},34580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),s=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,s.env)().DO_NOT_TRACK)}},44198:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const s=r(i(73024)),n=i(76760),a=r(i(1708)),o=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),v=i(6012),w=i(96706);t.env=(0,o.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>a.default.env[e])).join(n.delimiter).split(n.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===a.default.env.PS_LICENSE||e.push((0,n.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),i={...a.default.env};for(const r of e)try{const e=(0,d.debom)(s.default.readFileSync((0,p.resolve)(r))),n=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(n))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),s=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let n;for(const a of(0,s.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(n=e.exec(a));){if(null==n.groups)continue;const{key:e,val:s}=n.groups;if((0,r.blank)(e)||null==s)continue;const a=s.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=a}}return i}},96706:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const s=r(i(1708)),n=i(19851),a=i(22573),o=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,n.lazy)((()=>(0,a.firstNotBlank)(s.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,s.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,n.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,n.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,o.isTrue)(g(e))}},98314:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),s=i(19851),n=i(40958),a=i(22573),o=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),v=i(70025),w=i(57159);function b(...e){if((0,n.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(o.errorName),...e.map(o.errorCode),...(0,n.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(o.ErrorDelimiter)))];return(0,n.uniqSubstrings)(S((0,l.flatten)(i)))}function S(e){return(0,n.compact)(e).filter((e=>!o.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(a.notBlank)}function P(e,t){const i=(0,n.uniqSubstrings)(S(e)),r=t?.maxLen??400,s=t?.trailingChars??64,a=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(i.join(o.ErrorDelimiter)),r-a.length,s)+a.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,a.blank)(e)?"":P(b(e),t)}t.StartTs=Date.now(),t.logger=(0,s.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,a.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,a.notBlank)(i))return i}},t.splitErrorMessage=b,t.normalizeErrorMessages=S,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,a.blank)(e)&&(e=t.MissingError),_(e,{maxLen:i})+" at "+(0,o.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),s=i(26905),n=i(55835),a=i(54993),o=i(81168);t.describeError=function(e){const t=(0,o.stripSuffix)((0,a.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,n.map)((0,s.errorErrno)(i),(e=>t.push(u.get(e)))),(0,n.map)((0,s.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),s=i(76790),n=i(50989),a=i(68852);t.ErrorFlags=(0,n.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,s.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(a.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},68301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorStore=t.ExtraEventsForPlease=void 0;const r=i(19851),s=i(42659),n=i(75240),a=i(55835),o=i(31586),l=i(68708),u=i(59455),c=i(54993),d=i(50213),h=i(45255),f=i(37628),m=i(99331),p=i(46292),g=i(38835),y=i(32144),v=i(29882),w=i(95696),b=i(55222),S=i(28874),P=(0,r.lazy)((()=>(0,d.mkLogger)("error.EventStore")));function _(e){return(0,l.omit)(e,"breadcrumbs")}t.ExtraEventsForPlease=7;class T{constructor(e){this.root=e}datedRoot(e=new Date){return this.root.join((0,c.toS)(e.getFullYear()),(0,c.toS)(e.getMonth()+1))}rmrf(){return this.root.rmrf()}msg2file(e){return this.datedRoot(new Date(e.timestamp*s.secondMs)).join((0,f.shortStringSha)(e.message,8,b.GeoRadix)+".json")}async eventsFrom(e=new Date,t=s.dayMs){const i=e.getTime(),r=i-t,a=i+t;return P().tap({msg:"eventsFrom()",result:(0,u.toA)(await this.datedRoot(e).clear().childFiles((async e=>P().tap({msg:"eventsFrom().childFiles() accept "+e.base,result:(0,y.isJsonExt)(e)&&!(0,v.isHiddenBasename)(e.base)&&(0,o.within)(r,a,e.mtimeMs())})))),meta:{when:e,deltaMs:(0,n.fmtDuration)(t)}})}async eventCount(e=new Date){return(await this.eventsFrom(e)).length}async eventQuotaExceeded(e){const i=(0,c.toS)(e).includes(g.PleaseSendErrorFlag)||(0,c.toS)(e.message).includes(g.PleaseSendErrorFlag),r=await this.eventCount(),s=S.Settings.maxErrorsPerDay.valueOrDefault+(i?t.ExtraEventsForPlease:0);return P().tap({msg:"eventQuotaExceeded()",result:r>=s,meta:{event:_(e),recentEventCount:r,maxErrorsPerDay:s,pleaseSend:i}})}async maybeSendEvent(e){if(e.timestamp=Math.floor(e.timestamp),(0,m.ending)())P().error("maybeSendEvent(): REJECT: we're ending.",{event:_(e)});else if(await this.eventQuotaExceeded(e))P().error("maybeSendEvent(): REJECT: too many recent events.",{event:_(e)});else try{const t=await this.writeEvent_(e);return P().tap({msg:"maybeSendEvent(): "+t==null?"REJECT: previously sent this event already this month":"ACCEPT",result:null!=t?e:void 0,meta:{eventFile:t}})}catch(e){return void P().error("maybeSendEvent(): REJECT: failed to write event.",e)}}writeEvent_(e){return this.msg2file(e).applyIfEmpty_({fn_:t=>t.writeJson_(e),minSizeBytes:3,returnUndefinedIfNotEmpty:!0,timeoutMs:h.ShortCommandTimeoutMs})}}t.ErrorStore=T,T.instance=(0,r.lazy)((()=>(0,a.map)((0,p.configDir)(),(e=>new T(w.PosixFile.for(e).join("events"))))))},70025:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),s=i(38639),n=i(26905),a=i(54993),o=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,a.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,a.toS)(e)+(0,r.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,o.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function b(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function S(e){return!!((0,s.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||b(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=b,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===S(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,n.errorCode)(e)||v(e)||w(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=S;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,s.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,s.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},51837:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalError=void 0;const r=i(38835);class s extends Error{constructor(e){super(e+r.InternalErrorFlag)}}t.InternalError=s},8769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),s=i(31586),n=i(68708),a=i(7282),o=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,n.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const s=!0===i.fatal,c=!0===i.ignorable;if(!s&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),s&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!s||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!s||(0,a.isTest)()||(0,o.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),s}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,s.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,o.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,s.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,s.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(26905),o=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,s.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,s.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,a.errorName)(t)??(0,d.first)(this.causes,a.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(a.errorCode)],a.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,a.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,n.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,n.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,n.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,s.blank)(r)||(i=(0,h.dedupeNeedle)(i,r,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,o.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const a=i(49769),o=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),s.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,a.getOrSet)(n(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),a=n(this,r,"f").get(e);return null!=a&&(a.resolve(t),n(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,s=new WeakMap},34102:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),s=i(19851),n=i(15197);t.ee=(0,s.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new n.CapturingEventEmitter(e)}))},41293:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiHealthRouter=void 0;const s=r(i(7252)),n=i(45599),a=i(18454),o=i(51773);t.ApiHealthRouter=class{constructor(e="/api/health"){this.mountpoint=e,this.router=(0,n.defer)((()=>s.default.Router().get(this.mountpoint,(0,o.wrap)(this.constructor.name+".health",this.health)))),this.health=async(e,t)=>{t.json(await a.HealthCheck.awaitSettled())}}}},51773:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableCache=t.truthyQuery=t.extractLang=t.requestLang=t.extractTagPath=t.jsonOrRedirect=t.getSeedOrRedirect=t.getFit=t.getSeed=t.wrap=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(38639),o=i(55835),l=i(97790),u=i(97238),c=i(99036),d=i(41942),h=i(54993),f=i(48884),m=i(50213),p=i(97352),g=i(56038),y=i(38835),v=i(57159),w=i(51140),b=i(68178),S=i(62327),P=(0,r.lazy)((()=>(0,m.mkLogger)("express.Handlers")));function _(e){return(0,l.opt)(e).filter(n.notBlank).map(h.toS).map((e=>e.split(","))).map(s.compactBlanks).map((e=>e.map((e=>e.split(";").map((e=>e.trim())))))).flatMap((e=>(0,f.greatestBy)(e,(([,e])=>(0,p.firstGt0)((0,p.extractFloat)(e),1))))).map((([e])=>e)).get()}t.wrap=function(e,t){return async(i,r,s)=>(0,g.time)(e,(()=>(0,S.wrapWithToast)({f:()=>t(i,r,s),response:r})))},t.getSeed=function(e){return(0,u.toSeed)(e.query.seed)},t.getFit=function(e){return c.ThumbFits.validOrElse((0,h.toS)(e.query.fit),c.ThumbFits.square)},t.getSeedOrRedirect=function(e,t){const i=(0,u.toSeed)(e.query.seed);if(null==i){let i=(0,b.requestedUri)(e);"/tag/"===i.path&&(i=i.with({path:"/tag"})),i.query.append("seed",(0,h.toS)((0,u.prngSeed)())),t.redirect(i.toString())}return i},t.jsonOrRedirect=function(e,t){if(null==e)return(0,S.sendErrorToast)(new v.WrappedError("Internal error: jsonOrRedirect(null)"+y.InternalErrorFlag,{fatal:!1,doNotSend:!0}),t,404);for(const i of[d.XLocationRedirect,d.XLocationReplace]){const r=e[i];(0,n.notBlank)(r)&&(P().debug("jsonOrRedirect(): "+i,r),t.setHeader(i,r),t.status(w.HttpStatus.SeeOther))}return t.json(e)},t.extractTagPath=function(e){const t=e.replace(/^(?:\/api)?\/tag\/?/,""),i=t.split("/").map(decodeURIComponent),r=(0,n.blank)(t)?[]:i;return P().info("extractTagPath()",{path:e,result:r,trimmed:t,tagPath:i}),r},t.requestLang=function(e){const t=e.headers["accept-language"];return _(Array.isArray(t)?t.join(","):t)},t.extractLang=_,t.truthyQuery=function(e,t){return(0,o.mapOr)(e.query[t],(e=>!(0,a.isFalse)(e)),(()=>!1))},t.disableCache=function(e){e.setHeader("Cache-Control","no-store, max-age=0"),e.setHeader("Pragma","no-cache"),e.setHeader("Expires","Fri, 01 Jan 1990 00:00:00 GMT")}},68259:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onFinished=void 0,t.onFinished=function(e,t){let i=!1;e.on("error",(r=>{i||(i=!0,t(r,e))}));const r=()=>{i||(i=!0,t(null,e))};for(const t of["end","finish","close"])e.on(t,r);return e}},27821:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.redirectRouter=void 0;const s=r(i(7252)),n=i(49586),a=i(51140),o=i(62327);t.redirectRouter=function(e){return s.default.Router().use(((t,i)=>(0,n.isAjaxRequest)(t.headers)?(0,o.sendRedirectionToast)({response:i,redirectOrReplace:"redirect",url:"/splash"}):i.redirect(a.HttpStatus.Found,e)))}},40749:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.referrer=t.isXhr=void 0;const r=i(54993),s=/^XMLHttpRequest$/i;t.isXhr=function(e){return e.xhr||null!=s.exec((0,r.toS)(e.header("X-Requested-With")))},t.referrer=function(e){return e.header("Referer")}},78147:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RequestLogger=void 0;const r=i(7252),s=i(19851),n=i(22573),a=i(42659),o=i(55835),l=i(50213),u=i(8769),c=i(18454),d=i(51576),h=i(43705),f=i(82647),m=i(28874),p=i(51140),g=i(68259),y=i(68178);t.RequestLogger=class{constructor(){this.logger=(0,l.mkLogger)("web.RequestLogger"),this.responseTimes=new f.Average,this.accessLogger=m.Settings.logWebRequests.valueOrDefault?new h.LogWriter((0,n.firstNotBlank)(m.Settings.logWebDir.valueOrDefault,m.Settings.logDir.valueOrDefault),{processName:(0,s.lazy)((()=>"webrequest"))}):void 0,this.router=(0,r.Router)().use(((e,t,i)=>{const r=Date.now(),s=e.method,n=`${e.protocol?.toUpperCase()}/${e.httpVersion}`,l=`${s} ${(0,y.requestedUri)(e)} ${n}`,h=e.path.startsWith("/sse/")||"/updates"===e.path||"/api/splash"===e.path||"/api/status"===e.path?void 0:setTimeout((()=>this.logger.warn("Request is still processing: "+l,{elapsedMs:Date.now()-r})),4*(this.responseTimes.p84??a.secondMs));(0,g.onFinished)(t,(i=>{(0,o.map)(h,clearTimeout),null!=i&&(0,u.onError)(l,{error:i});const a=p.HttpStatusIs.success(t.statusCode)||p.HttpStatusIs.redirect(t.statusCode),f=Date.now()-r,m={from_ip:e.ip,protocol:n,method:s,statusCode:t.statusCode,ok:a,elapsedMs:f,runState:c.HealthCheck.runState(),userAgent:e.headers["user-agent"]};null!=i&&(m.error=i),this.responseTimes.push(f),(0,d.logBroadcaster)()?.log(a?"info":"warn","HttpRequestLogger",l,m),this.accessLogger?.log("info","",l,m),null==d.logBroadcaster.prior()&&null==this.accessLogger&&this.logger.log(null==i&&a?"debug":"warn",l,m)})),i()}))}}},68178:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addXSettingsHandler=t.requestedUri=void 0;const r=i(19851),s=i(41400),n=i(98553),a=i(37805),o=i(89724),l=i(34102),u=i(81674),c=i(28874),d=i(34238),h=i(69385),f=(0,r.lazy)((()=>({protocol:"http",host:c.Settings.hostname.valueOrDefault??"localhost",url:"/"})));t.requestedUri=function(e,t){const i={...f(),...t};return d.URI.parse((e?.protocol??i.protocol)+"://"+(e?.headers?.host??i.host)+(e?.originalUrl??i.url))};const m=(0,r.lazy)((()=>"lite"));async function p(){m.set(await(0,u.t)()),y.unset()}const g=(0,r.lazy)((()=>(0,c.isProd)()?"":"+"+(0,o.nowLocal)())),y=(0,r.lazy)((()=>{const e={ver:a.version+g(),paused:(0,h.isPaused)(),ll_vh:c.Settings.lazyLoadExtraVh.valueOrDefault,tier:m()};return Buffer.from((0,n.stringify)(e)).toString("base64")}));(0,s.later)((()=>{(0,l.ee)().on("settingsChanged",(()=>y.unset())),(0,l.ee)().on("reloadLicenses",p),u.m.watch(p),(0,l.ee)().on("pause",(()=>y.unset())),(0,l.ee)().on("resume",(()=>y.unset()))})),t.addXSettingsHandler=function(e,t,i){t.setHeader("X-Settings",y()),i()}},43394:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serveStaticGz=void 0;const r=i(22573),s=i(54993),n=i(50213),a=i(56639),o=i(81168),l=i(38835),u=i(83278),c=i(14036),d=i(51773),h=/\.asar\/?/i;t.serveStaticGz=async function(e){const t=(0,n.mkLogger)("serveStaticGz"),i=u.BaseFile.for(e),f=await i.descendants((e=>e.ext.endsWith(".gz"))),m=(0,a.toMap)(f,(e=>(0,r.mapNotBlank)((0,c.extMimetype)((0,o.stripSuffix)(e.ext,".gz")),(t=>["/"+(0,o.stripSuffix)(e.posixPathFrom(i),".gz"),{contentType:t,nativePath:e.nativePath}]))));return t.debug("ready to serve",[...m.keys()]),0===m.size&&t.error("Can't read "+i+". Please visit https://forum.photostructure.com/ for help."+l.FatalErrorFlag),(0,d.wrap)("serveStaticGz",(async(e,i,r)=>{if(null!=e.path.match(h))return i.sendStatus(404);const n=m.get((0,s.toS)(e.path));return null==n?r():(t.debug("get",{path:e.path,result:n}),i.set("Content-Encoding","gzip"),i.set("Content-Type",n.contentType),i.sendFile(n.nativePath))}))}},18405:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ServerSentEventsRouter=void 0;const s=r(i(7252)),n=i(40958),a=i(22573),o=i(25764),l=i(38836),u=i(36868),c=i(72901),d=i(51773);class h extends l.EndableWrapper{constructor(e){super("SSERouter("+e+")",(()=>this.close()),o.EndableRanks.first),this.path=e,this.streams=[]}router(){return s.default.Router().get(this.path,(0,d.wrap)(this.name,this.updates.bind(this)))}async close(){await Promise.all(this.streams.map(u.endStream)),this.streams.length=0}async updates(e,t){if(this.ended)return void t.sendStatus(503);this.logger.info("Sending updates to "+(e.ip??e.ips));const i=(0,u.remoteDesc)(e.socket);t.writeHead(200,{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-cache",Connection:"keep-alive","X-Accel-Buffering":"no"}),this.streams.push(t),t.once("error",(e=>{(0,n.removeSame)(this.streams,t),this.logger.warn("onError("+i+")",{error:e})})),t.once("close",(()=>{(0,n.removeSame)(this.streams,t),this.logger.debug("stream to "+i+" closed. ("+this.streams.length+" remain)")}));const r=(0,n.compact)(this.firstEvents(e,t));(0,n.isNotEmpty)(r)&&(this.logger.info("firstEvents",{firstEvents:r}),t.write((0,c.mkEventStream)(...r)))}endStream(e){(0,u.endStream)(e).catch((()=>{})),(0,n.removeSame)(this.streams,e)}writeToStreams(...e){const t=(0,c.mkEventStream)(...e);if(this.logger.info("writeToStreams",{events:e,payload:t}),!(0,a.blank)(t))for(const e of this.streams)if(!0===e?.closed||null==e?.socket)this.endStream(e);else try{e.write(t)}catch(t){null==e.socket||e.closed?this.endStream(e):this.logger.warn("writeToStreams failed to write to stream",{stream:(0,u.remoteDesc)(e.socket),error:t})}}}t.ServerSentEventsRouter=h},62327:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapWithToast=t.expressErrorHandlerWithToast=t.sendErrorToast=t.send404Toast=t.sendWarningServerToast=t.sendRedirectionToast=t.sendServerToast=t.requireEnabled=t.requirePlus=void 0;const r=i(19851),s=i(55835),n=i(41942),a=i(71050),o=i(27776),l=i(41583),u=i(50213),c=i(98314),d=i(70025),h=i(81674),f=i(49586),m=i(51140),p=i(68178),g=(0,r.lazy)((()=>(0,u.mkLogger)("express.ServerToastHelpers")));function y({response:e,toast:t,httpStatusCode:i,reload:r}){return(0,s.map)(i,(t=>e.status(t))),g().warn("sendServerToast()",{requestedURI:(0,p.requestedUri)(e.req),toast:t,httpStatusCode:i}),e.json({toast:t,reload:r})}function v(e,t,i){g().warn("sendErrorToast",e);const r=(0,d.stripErrorFlags)((0,c.errorToS)(e));y({response:t,toast:{text:404===i?"Not found":"Well, darn, that didn't work",uuid:r,details:r,type:(0,d.isFatalError)(e)?"error":"warning",button1Text:"Return home",button1Url:"/"+a.DismissAnchor,button1Class:"info",onClickUrl:a.DismissAnchor},httpStatusCode:i??m.HttpStatus.ServiceUnavailable})}t.requirePlus=async function(e,t,i){if(await(0,h.l)()){const e={toastPlusOnly:!0};return t.status(m.HttpStatus.Forbidden),t.json(e)}return i()},t.requireEnabled=function(e){return(t,i,r)=>e.valueOrDefault?r():y({response:i,toast:{text:"This has been disabled by your administrator.",details:`(see setting "${e.name}")`,type:"warning"},httpStatusCode:m.HttpStatus.Forbidden})},t.sendServerToast=y,t.sendRedirectionToast=function({response:e,toast:t,url:i,redirectOrReplace:r}){if((0,f.isAjaxRequest)(e.req.headers)){const s="replace"===r?n.XLocationReplace:n.XLocationRedirect;return e.setHeader(s,i),g().warn("sendRedirectionToast()",{requestedURI:(0,p.requestedUri)(e.req),toast:t,key:s,url:i}),e.json({toast:t})}return e.redirect(i)},t.sendWarningServerToast=function({response:e,toast:t,httpStatusCode:i,reload:r}){return t.type??(t.type="warning"),y({response:e,toast:t,httpStatusCode:i,reload:r})},t.send404Toast=function({text:e,details:t,response:i,httpStatusCode:r=404}){return y({response:i,toast:{text:e,details:t,type:"warning",button1Text:"Go home",button1Url:(0,o.mkHomeFullPath)()+a.DismissAnchor,button1Class:"info",onClickUrl:a.DismissAnchor,timeout:!1},httpStatusCode:r})},t.sendErrorToast=v,t.expressErrorHandlerWithToast=function(e,t,i,r){null==e?r():v(e,i)},t.wrapWithToast=async function({f:e,response:t}){try{await e()}catch(e){(0,s.map)((0,l.toErr)(e),(e=>v(e,t)))}}},30576:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.viewRouter=void 0;const s=r(i(7252)),n=i(51773);t.viewRouter=function({path:e,view:t,modeler:i}){return s.default.Router().get(e,(0,n.wrap)(t+"Router",(async(e,r)=>{const s=await(i?.(e,r))??{};return s.nonce=r.locals?.cspNonce,r.render(t,s)})))}},64660:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const s=r(i(73024)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,a.lazy)((()=>n.default.geteuid?.())),h=(0,a.lazy)((()=>n.default.getgroups?.()));function f(e,t){try{return!(0,o.blank)(e)&&(s.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,s.default.constants.R_OK|s.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,s.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:s,processGid:n}){if(null==e)return!1;const a=s??d(),o=null!=n?[n]:h()??[],l=0===a,u=l||e.uid===a,f=l||o.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const s=r(i(76760)),n=i(19851),a=i(81168),o=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,n.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,a.equalsIgnoreCase)(e.basename,i.base))return s.default.join(r,e.basename);throw new o.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),s=i(76760);function n(e){return[...a(e)]}function*a(e){for(;e!==(0,s.dirname)(e);)e=(0,s.dirname)(e),yield e}function o(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=o(e);return t.every((e=>i.includes(e)))}t.ancestors=n,t.ancestorG=a,t.selfAndAncestorG=function*(e){yield e,yield*a(e)},t.childrenSync=o,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return n(e).find((e=>l(e,t)))}},83278:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),v=f(i(1708)),w=i(46466),b=f(i(57975)),S=f(i(38522)),P=i(19851),_=i(40958),T=i(5233),M=i(22573),E=i(42659),k=i(50357),D=i(96249),x=i(98553),C=i(55835),F=i(31586),A=i(68708),I=i(97790),O=i(39926),L=i(51926),R=i(59455),N=i(54993),B=i(48884),j=i(22911),z=i(99331),V=i(56519),W=i(56038),U=i(31562),q=i(76850),H=i(70025),$=i(34102),G=i(80875),J=i(50213),K=i(70417),Y=i(43334),X=i(81168),Z=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),se=i(89968),ne=i(20197),ae=i(88561),oe=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),ve=i(27794),we=i(73428),be=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const Se=(0,P.lazy)((()=>new ae.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),s.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),a.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(s=new WeakMap,a=new WeakMap,r=new WeakSet,b.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,B.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,M.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=Se().get(i);if(null!=r)return r;const s=(0,fe.resolve)(i),n=new Pe(s,t);return Se().set(i,n),Se().set(s,n),n}static clear(e){(0,$.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,$.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,s,"f").unset(),h(this,a,void 0,"f"),this}clearThisAndParent(){return(0,$.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,X.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,C.map)(this.statSync(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,s,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",n).call(this)??await d(e=this.clearThisAndParent(),r,"m",n).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,R.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,F.gt0)(t))return;const i=await d(this,s,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,k.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,C.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,O.pad2)(t+1),(0,O.pad2)(i))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,D.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,E.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),B.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>=(0,E.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>(0,E.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,C.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*E.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,oe.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,oe.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,G.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,G.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,q.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,be.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces),(0,A.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,T.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,z.ending)()?1:3,timeoutMs:0,retryDelay:E.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,r,"m",o).call(this,(0,X.stripSuffix)(this.base,".gz"),S.default.createGunzip())}async gzip(){return d(this,r,"m",o).call(this,this.base+".gz",S.default.createGzip())}async compressBrotli(){return d(this,r,"m",o).call(this,this.base+".br",S.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,ne.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,ne.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(S.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,_.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,Z.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new j.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,L.newlineRe)(),(r=>{const s=e.exec(r);null!=s&&(t.maybeResolve(s),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,F.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new j.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),_e)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,s)=>{try{const n=await e.f(r,(0,C.denull)(s));t(n)&&i.resolve(n)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,F.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,n=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,X.equalsIgnoreCase)(e.basename,this.base))),t=(0,B.leastBy)(e,(e=>(0,Z.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,C.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},o=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*E.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},19748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const r=i(28874),s=i(88840),n=i(14036),a=i(29882);function o(e){return t=>r.Settings.respectFileExtensions.valueOrDefault?(0,n.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,a.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=o,t.isBrowserExtension=o(s.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=o(s.ExtTypes.Video),t.isAssetFileExtension=o(s.ExtTypes.AssetFile)},84542:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),s=i(96249),n=i(51926),a=i(54993),o=i(43334);function l(...e){return(0,s.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,a.toS)(e).split((0,n.newlineRe)()))))}t.Newline=o.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(a.toS).join("\n");return o.isWin?t.replace((0,n.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),s=i(19851),n=i(50213),a=i(37805),o=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,s.lazy)((()=>(0,n.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,o.mkdirp_)(i),await(0,d.writeTextfile_)((0,o.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+a.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,a.lazy)((()=>[...(0,o.mapNotBlankOr)(n.default.env.SYSTEMROOT,(e=>[e,s.default.join(e,"System32"),s.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const o=n(i(44652)),l=a(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),v=i(14427),w=i(17217),b=i(16287),S=i(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class T{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new T(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},s=await o.stat(t);return new T(i,new P(r,s))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return T.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new T(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>T.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new T(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,S.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,b.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await o.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await o.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=T},20197:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const s=r(i(76760)),n=i(39926),a=i(29882),o=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if(await(0,a.mkdirp_)(r.dir),!i.requireNumber&&await(0,o.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,o.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if((0,a.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},92423:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notInHiddenPhotoStructureDir=t.whyExcludedDirectoryRecursive=t.notExcludedDirs=t.isExcludedDirectory=t.whyExcludedDirectory=t.notExcludedDirPredicates=t.isExcludedFile=t.whyExcludedFile=t.notExcludedFilePredicates=t.excludeBundles=t.excludeGlobs=t.defaultFilePredicates=t.defaultDirPredicates=t.formatPathForGlob=void 0;const l=o(i(83058)),u=i(19851),c=i(40958),d=i(76790),h=i(22573),f=i(55835),m=i(51926),p=i(54993),g=i(48884),y=i(9092),v=i(54557),w=i(50213),b=i(88158),S=i(56519),P=i(46292),_=i(32551),T=i(35280),M=i(87290),E=i(96706),k=i(57902),D=i(43334),x=i(78984),C=i(33995),F=i(28874),A=i(21144),I=i(83278),O=i(48313),L=i(85772),R=i(78133),N=i(46356),B=i(17217),j=(0,u.lazy)((()=>(0,w.mkLogger)("fs.ExcludeGlobs"))),z=new v.FifoCache(256),V=/[\\/]$/;function W(e){const t=(0,p.toS)(e),i=z.get(t);if(null!=i)return i;const r=(0,B.isSimpleFile)(e)?e:I.BaseFile.for(e),s=V.test(t)||r.isDirectorySync(),n=(0,R.native2posix)(r.nativePath),a=s?(0,m.ensureSuffix)(n,"/"):n;return z.set(t,a),z.set(a,a),z.set(r.nativePath,a),a}t.formatPathForGlob=W;class U{constructor(e,t,i=!0){if(r.add(this),this.pattern=e,this.desc=t,this.exclude=i,e.includes("\\")){const t=e;e=(0,R.native2posix)(t),j().warn("globToPredicate(): backslash in patterns aren't supported: assuming you meant forward-slash?",{given:t,input:e})}this.reason=(0,c.compactBlanks)([this.exclude?"not":"",t,"("+(0,m.ellipsize)(e,48,12)+")"]).join(" ");try{this.re=l.default.makeRe(this.pattern,{nocase:F.Settings.globsCaseInsensitive.valueOrDefault,dot:!0,posixSlashes:!0}),this.valid=!0}catch(e){this.valid=!1,j().warn("Cannot parse pattern",{glob:this.pattern,error:e})}this.bundle=this.valid&&null!=this.re?(0,b.pairToObject)(this.reason,a(this,r,"m",s).bind(this)):{}}}r=new WeakSet,s=function(e){const t=W(e),i=this.re.test(t)??this.exclude;return j().tap({msg:"apply()",level:i?k.LogLevels.debug:k.LogLevels.trace,result:i?!this.exclude:this.exclude,meta:{desc:this.desc,pattern:this.pattern,exclude:this.exclude,posixPath:t,matched:i}})};class q{constructor(){n.set(this,[])}push(...e){for(const t of e){if(!t.valid){j().warn("Ignoring invalid glob",{glob:t});continue}const e=a(this,n,"f").find((e=>e.pattern===t.pattern));null==e?a(this,n,"f").push(t):j().debug("Ignoring duplicate glob",{glob:t,prior:e})}}pushNativePath(e,t){this.push(new U((0,R.native2posix)(e),t))}toA(){return a(this,n,"f")}}n=new WeakMap;const H=new U("**/.*","hidden file"),$=new U("**/.*/","hidden directory"),G=(0,u.lazy)((()=>{const e=new q;e.push($,H);for(const t of[{s:"bin",desc:"command binary"},{s:"dev",desc:"device file"},{s:"etc",desc:"system configuration file"},{s:"initrd",desc:"initial ramdisk"},{s:"proc",desc:"process metadata"},{s:"sbin",desc:"system binary"},{s:"snap",desc:"snap software"},{s:"sys",desc:"system metadata"},{s:"Dell",desc:"Windows driver"},{s:"Drivers",desc:"Windows driver"},{s:"Intel",desc:"Windows driver"},{s:"Microsoft",desc:"Windows driver"},{s:"NVIDIA",desc:"Windows driver"},{s:"Windows.old",desc:"Windows system"},{s:"Windows",desc:"Windows system"}])e.push(new U((D.isWin?"*":"")+"/"+t.s+"/",t.desc));if(D.isWin)for(const t of["ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemRoot","windir"]){const i=(0,E.getEnv)(t);(0,h.blank)(i)||e.pushNativePath(i,`%${t}%`)}D.isLinux&&e.push(new U(`${(0,_.homeDir)()}/snap/`,"Snap software"));for(const t of[{s:"__MACOSX",desc:"macOS resource fork"},{s:"_includes",desc:"code"},{s:"@eaDir",desc:"Synology thumbnail"},{s:"@Recently-Snapshot",desc:"QNAP snapshot"},{s:"@Recycle",desc:"QNAP trash"},{s:"@SynoResource",desc:"Synology metadata"},{s:"#recycle",desc:"Synology trash"},{s:"#snapshot",desc:"Synology snapshot"},{s:"$Recycle.Bin",desc:"Windows trash"},{s:"$SysReset",desc:"Windows"},{s:"3rdParty",desc:"code"},{s:"Application Data",desc:"Windows apps"},{s:"Application Support",desc:"macOS apps"},{s:"Applications",desc:"macOS apps"},{s:"arangodb",desc:"3rd party"},{s:"cache",desc:"Cache directory"},{s:"CacheClip",desc:"Movie cache directory"},{s:"caches",desc:"Cache directory"},{s:"Chipset_Software",desc:"Windows apps"},{s:"cmake",desc:"code"},{s:"com.apple.TimeMachine.localsnapshots",desc:"macOS"},{s:"cpan",desc:"code"},{s:"DefinitelyTyped",desc:"TypeScript type"},{s:"Desktop DB",desc:"macOS metadata"},{s:"Desktop DF",desc:"macOS metadata"},{s:"Desktop.ini",desc:"macOS metadata"},{s:"DisplayDriver",desc:"Windows driver"},{s:"DLLs",desc:"Windows library"},{s:"dyld",desc:"macOS library"},{s:"ehthumbs.db",desc:"Windows thumbnail"},{s:"i18n",desc:"i18n code"},{s:"iMovie Cache",desc:"Apple iMovie cache"},{s:"iTunes Cache",desc:"Apple iTunes"},{s:"iTunes Media",desc:"Apple iTunes"},{s:"iTunes",desc:"Apple iTunes"},{s:"lib?(32|64|x64|s)",desc:"program library directory"},{s:"lost+found",desc:"fsck recovered directory"},{s:"macOS Install*",desc:"macOS installer"},{s:"Network Trash",desc:"AFP trash"},{s:"node_modules",desc:"Node.js library"},{s:"pkgconfig",desc:"code"},{s:"pkgs",desc:"Python code"},{s:"Program Files (x86)",desc:"Windows apps"},{s:"Program Files",desc:"Windows apps"},{s:"ProgramData",desc:"Windows application support"},{s:"resources/media/face",desc:"face thumbnail"},{s:"rubygems-*",desc:"Ruby code"},{s:"site-packages",desc:"Python code"},{s:"spotifycache",desc:"Spotify cache"},{s:"SteamApps",desc:"Game files"},{s:"System Volume Information",desc:"Windows system metadata"},{s:"System32",desc:"Windows system"},{s:"SystemTemp",desc:"Windows temporary"},{s:"temp",desc:"temporary"},{s:"Temporary Items",desc:"temporary"},{s:"test_suite",desc:"code"},{s:"testutil?(s)",desc:"code"},{s:"third_party",desc:"code"},{s:"Thumbnail?(s)",desc:"thumbnail"},{s:"Thumbs.db",desc:"Windows thumbnail"},{s:"tmp",desc:"temporary"},{s:"Trash",desc:"trash directory"},{s:"Windows",desc:"Windows"},{s:"Windows.old",desc:"Windows"},{s:"Windows10Upgrade",desc:"Windows upgrade"},{s:"Xcode.app",desc:"macOS code"},{s:"*.sparsebundle/bands",desc:"Time Machine backup"},{s:"ImageMagick*",desc:"ImageMagick source"},{s:"Install OS X*",desc:"macOS installer"},{s:"Install macOS*",desc:"macOS installer"},{s:"*.lrdata",desc:"LightRoom data"},{s:"MinGW*",desc:"code"},{s:"msys*",desc:"code"},{s:"vcpkg",desc:"code"}])e.push(new U("**/"+t.s+"/",t.desc));function t(t,i,r){if(!(0,h.blank)(t)){const s=(0,d.sort)((0,c.uniq)((0,c.compactBlanks)(i).map((e=>e.toLowerCase()))));1===s.length&&e.push(new U(`**/${t}/${s[0]}/`,r)),s.length>1&&e.push(new U(`**/${t}/(${s.join("|")})/`,r))}}(0,f.map)((0,P.configDir)(),(t=>e.pushNativePath(t,"PhotoStructure configuration"))),t("nix",["store"],"NixOS package"),e.push(new U("**/*.(photo|photos|ap)library/!(master|masters|modified|original|originals)/","Apple Photos/Aperture library")),e.push(new U("**/facetile*","face thumbnail"));const i=["bin","cygdrive","dev","etc","games","include","lib?(32|64|x64)","local","locale","man","proc","sbin","share","src","tmp","usr","var"];t("usr",i,"FHS system"),t("cygwin?(64)",i,"Cygwin"),t("local",i,"FHS system"),t("Windows",["assembly","Boot","Containers","Cursors","Fonts","Help","Installer","Logs","Microsoft.NET","Servicing","SoftwareDistribution","System32","SystemApps","SysWOW64","Temp","WinSxS"],"Windows"),t("Recovery",["Customizations","OEM"],"Windows"),t("lib",["firmware","modules","systemd","udev","x86_64-linux-gnu"],"Linux system package"),t("opt",["google","x11",...i],"FHS package"),t("lfs",["incomplete","objects"],"Git LFS object");const r=["cache","crash","games","lib","local","lock","log","logs","mail","run","snap","spool","tmp"];t("var",r,"Linux /var"),t("mnt",r,"Linux /mnt"),t("dev",["block","bsg","bus","char","cpu","disk","dri","fd","hugepages","input","lightnvm","mapper","mqueue","net","pts","shm","snd","ubuntu-vg","usb","vfio"],"Linux /dev backup"),t("proc",["acpi","asound","bus","driver","fs","ipmi","irq","net","scsi","self","sys","sysvipc","thread-self","tty"],"Linux /proc backup"),t("library",["Apple","Assistant","Bluetooth","com.apple.iTunesCloud","Containers","CoreAnalytics","Developer","Desktop Pictures","Documentation","Extensions","Finance","Fonts","Frameworks","FrontBoard","Group Containers","HTTPStorages","iTunes","KeyboardServices","Keychains","Logs","Messages","News","Passes","Photos","Preferences","Ruby","Saved Application State","Scripts","User Pictures","Updates","User Template","WebKit","WebServer"],"macOS Library"),t("packages",["*.pkg","*.mpkg"],"macOS package"),t("src/**",["bin","ci","dist","doc?(s)","etc","lib?(s)","main","spec?(s)","src","test?(s)","tools","util"],"code"),t("docs",["admin","content","general","generated","sql"],"code"),t("pkg",["acceptance","ccl","cli","cmd","server","sql","storage","ui","util","workload"],"code"),t("osv",["apps","arch","compiler","external","include","java","modules","musl","tests"],"code"),t("go",["bin","blog","cmd","doc","lib","misc","pkg","src","test","vt"],"code"),t("Perl?(64)",["bin","eg","etc","html","lib","site"],"code"),t("Python*",["dlls","doc?(s)","include","lib?(s)","scripts","tools","tcl"],"code"),t("Ruby*",["bin","include","lib","msys*","packages","share","ssl"],"code"),t("msys*",["clang*","dev","etc","mingw*","tmp","ucrt*","var"],"code"),t("sdk",["build-tools","emulator","extras","patcher","platforms","platform-tools","sources","tools"],"code"),t("test",["fixtures"],"code"),t("data",["$of"],"windows backup"),t("System",["Applications","Developer","DriverKit","Library","iOSSupport"],"macOS System"),t("contents",["frameworks","plugins","resources","sharedsupport"],"macOS application"),t("pg",["pgsql"],"code");for(const e of["local","locallow","roaming"])t("appdata",[e],"Windows default AppData");return t("ps",["cache","config","logs","tmp"],"PhotoStructure docker directory"),e.toA()})),J=()=>{t.excludeGlobs.unset(),t.excludeBundles.unset()},K=()=>{t.notExcludedDirs.unset()},Y=(0,u.lazy)((()=>{F.Settings.excludeGlobsOmitDefaults.watchLater(J),F.Settings.excludeGlobsAdd.watchLater(J),F.Settings.excludeGlobsOmit.watchLater(J),F.Settings.globsCaseInsensitive.watchLater(J),F.Settings.libraryDir.watchLater(K),F.Settings.originalsDir.watchLater(K),F.Settings.scanPaths.watchLater(K),F.Settings.argvScanPaths.watchLater(K)}));t.defaultDirPredicates=(0,u.lazy)((()=>[{notSymlinkLoop:re,notInHiddenPhotoStructureDir:ne,whyNoMedia:L.whyNoMedia,notHidden:se}])),t.defaultFilePredicates=(0,u.lazy)((()=>[{notInHiddenPhotoStructureDir:ne}])),t.excludeGlobs=(0,u.lazy)((()=>{Y();const e=new y.CaseInsensitiveMap;function t(t){if(null!=t&&t.valid){const i=t.pattern.trim();e.has(i)&&j().warn("Duplicate glob:",{glob:t}),e.set(i,t)}}function i(t){const i=t.trim();e.has(i)?e.delete(i):j().warn("Failed to find and remove glob specified in PS_EXCLUDE_GLOBS_OMIT",{glob:t})}if(!F.Settings.excludeGlobsOmitDefaults.valueOrDefault)for(const e of G())t(e);for(const e of F.Settings.excludeGlobsOmit.values)i(e);for(const e of F.Settings.excludeGlobsAdd.values)t(new U(e,"(from PS_EXCLUDED_GLOBS_ADD)"));const r=(0,d.sortBy)(e.values(),(e=>(0,c.compactBlanks)(e.pattern.toLowerCase().split("/")))),[s,n]=(0,g.partition)(r,(e=>e.pattern.endsWith("/")));return{dir:s,file:n}})),t.excludeBundles=(0,u.lazy)((()=>{const e=(0,t.excludeGlobs)();return{dir:[...(0,t.defaultDirPredicates)(),...e.dir.map((e=>e.bundle))],file:[...(0,t.defaultFilePredicates)(),...e.file.map((e=>e.bundle))]}}));const X=[{disableAllFilters:()=>!0}],Z=[{notBlank:()=>!1}];function Q(e){return F.Settings.disableAllFilters.valueOrDefault?X:(0,h.blank)(e)?Z:(0,t.excludeBundles)().file}function ee(e){return C.SyncPredicates.whyRejected(e,...Q(e))}function te(e){return F.Settings.disableAllFilters.valueOrDefault?X:(0,h.blank)(e)?Z:(0,t.excludeBundles)().dir}async function ie(e){return F.Settings.disableAllFilters.valueOrDefault?void 0:x.Predicates.whyRejected(e,...te(e))}function re(e){return!(0,N.seemsLikeSymlinkLoop)(e)}function se(e){return(0,S.thenNot)((0,O.isHidden)(e))}function ne(e){return!(0,T.inHiddenPhotoStructureDir)(e)}t.notExcludedFilePredicates=Q,t.whyExcludedFile=ee,t.isExcludedFile=function(e){return null!=ee(e)},t.notExcludedDirPredicates=te,t.whyExcludedDirectory=ie,t.isExcludedDirectory=async function(e){return null!=await ie(e)},t.notExcludedDirs=(0,u.lazy)((async()=>{const e=(0,c.uniq)((0,c.compactBlanks)([(0,M.libraryDirPosixFile)(),(0,M.libraryOriginalsDirPosixFile)(),...F.Settings.argvScanPaths.values,...F.Settings.scanPaths.values]));return j().tap({msg:"notExcludedDirs() (these directories will never be excluded)",level:"info",result:(0,c.uniq)([...e,...await Promise.all(e.map((e=>(0,A.actualPath)(e))))])})})),t.whyExcludedDirectoryRecursive=async function(e){const i=await(0,t.notExcludedDirs)();for(let t=e;null!=t&&!t.isRoot;t=await(t?.parent())){if(i.includes(t?.nativePath))return;const e=await ie(t);if(null!=e)return e}},t.notInHiddenPhotoStructureDir=ne},88561:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const a=i(40958),o=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>n(this,r,"m",s).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,a.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,r=new WeakSet,s=async function(e){if((0,o.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},79267:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCleanup=void 0;const c=i(19851),d=i(40958),h=i(42659),f=i(31586),m=i(71371),p=i(50213),g=i(7282),y=i(409),v=i(78406),w=i(25764),b=i(99331),S=i(91655),P=i(34102),_=i(89968),T=i(85772);class M{static for(e){return new M(e.name,e.rootNativePath,e.staleMs,e.isPrunable,e.minRetained)}constructor(e,t,i,a,d=0){r.add(this),this.name=e,this.rootNativePath=t,this.staleMs=i,this.isPrunable=a,this.minRetained=d,s.set(this,void 0),this.intervalMs=(0,c.lazy)((()=>(0,f.clamp)((0,g.isTest)()?0:5*h.minuteMs,h.dayMs,this.staleMs/2))),n.set(this,void 0),this.cleanup=(0,y.rateLimited)({name:this.name,minCallDelayMs:this.intervalMs()/4,f:()=>u(this,r,"m",o).call(this)}),l(this,s,(0,p.mkLogger)("fs.FileCleanup("+e+")"),"f")}scheduleInterval(){return(null==u(this,n,"f")||u(this,n,"f").ended)&&l(this,n,new v.EndableInterval({name:this.name,callback:()=>this.cleanup(),intervalMs:this.intervalMs(),rank:w.EndableRanks.first}),"f"),u(this,n,"f")}cancelInterval(){u(this,n,"f")?.end(),l(this,n,void 0,"f")}}t.FileCleanup=M,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(e){if(!(0,f.gt0)(this.minRetained))return new Set;const t=new m.BoundedGreatestSet(this.minRetained??0,(e=>e.mtimeMs()));return await e.visitDescendants((e=>{e.isFile()&&t.add(e)})),new Set(t.vacuum().map((e=>e.nativePath)))},o=async function(){try{if((0,b.ending)())return;const e=await this.rootNativePath();if(null==e)return[];const t=await _.DirectoryEntry.for(e);if(null==t)return[];u(this,s,"f").info("cleanup(): starting",{root:t,staleMs:(0,S.fmtFullDuration)(this.staleMs," ")});const i=await u(this,r,"m",a).call(this,t),n=Date.now()-this.staleMs,o=new Set,l=[],c=[];await t.clear().visitDescendants((async e=>{if((e.dir!==t.nativePath||!(0,T.isNoMediaName)(e.base))&&!i.has(e.nativePath)&&(o.has(e.nativePath)||!(0,f.gte)(e.mtimeMs(),n)))if(e.isDirectory())try{await e.rmdir_(),c.push(e.nativePath),o.add(e.dir)}catch(t){"ENOENT"===t.code&&(u(this,s,"f").warn("cleanup(): ENOENT "+e,t),(0,P.ee)().emit("clearCache")),"ENOTEMPTY"!==t.code&&u(this,s,"f").warn("cleanup(): failed to rmdir "+e,t)}else if(!1!==await(this.isPrunable?.(e)))try{await e.unlink_(),l.push(e.nativePath),o.add(e.dir)}catch(t){u(this,s,"f").warn("cleanup(): failed to clean up tmpfile "+e,t)}}));const h=[...l,...c];return(0,d.isNotEmpty)(h)&&t.clear(),u(this,s,"f").info("cleanup(): done",{root:t,pruned_file_count:l.length,pruned_dir_count:c.length}),h}catch(e){return void u(this,s,"f").error("cleanup() failed",{error:e})}}},32144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),s=i(22573),n=i(45599),a=i(96249),o=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,n.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,s.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,a.flatten)((0,o.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),s=i(17217),n=i(16287),a=i(68284);async function o(e){return(0,r.pick)(await(0,n.stat_)((0,s.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=o,t.fileStats=async function(e){try{return await o(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,a.statSync)((0,s.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const r=i(68817),s=i(19851),n=i(22573),a=i(50213),o=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),h=i(95696),f=i(93854),m=i(16287),p=(0,s.lazy)((()=>(0,a.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,f.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,r.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const s=(0,n.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),a=(0,l.normalizeExt)(h.PosixFile.for(e))??(0,c.mimetypeExt)(s);return(0,n.blank)(s)||(0,n.blank)(a)?void 0:{ext:a,mime:s}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new o.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,s.set(this,[]),n.set(this,void 0),a.set(this,void 0),l(this,a,(0,f.fileStatsSync)(e),"f"),l(this,n,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",o).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,s,"f").push(e)}close(){u(this,n,"f").close()}}t.FileWatcher=m,s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,a,"f"),t)){l(this,a,t,"f");for(const t of u(this,s,"f"))t(e,this.nativePath)}}},13829:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withFsAdvisoryLocks_=t.defaultFsAdvisoryLockDir=void 0;const r=i(55835),s=i(13538),n=i(81168),a=i(37628),o=i(46292),l=i(73209),u=i(95696);function c(){return(0,r.map)((0,o.configDir)(),(e=>u.PosixFile.for(e).join("advisory-locks")))}t.defaultFsAdvisoryLockDir=c,t.withFsAdvisoryLocks_=async function({name:e,lockNames:t,f:i,timeoutMs:r,lockDir:o=c()}){if(null==o)return i();await o.mkdirp_();const u=(0,n.sortIgnoreCase)(t).map((e=>l.FsLock.for({name:e,file:o.join((0,a.shortFsStringSha)(e)),timeoutMs:r})));try{for(const t of u)if(!0!==await(0,s.thenOrTimeout)(t.acquire_(),r))throw new Error("Failed to acquire lock for "+e+": "+t.opts.name+" was busy");return await i()}finally{for(const e of u)e.release()}}},73209:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,v,w,b=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},S=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const _=i(58587),T=P(i(44652)),M=i(87997),E=i(40958),k=i(17586),D=i(42659),x=i(50357),C=i(75240),F=i(55835),A=i(31586),I=i(30976),O=i(13538),L=i(54993),R=i(7282),N=i(68852),B=i(23560),j=i(25764),z=i(38836),V=i(99331),W=i(22781),U=i(38835),q=i(55222),H=i(63870),$=i(69734),G=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)($.PsLockExt)+"$");class K extends z.EndableWrapper{static newUid(e=process.pid){return S(this,s,Math.max(Date.now(),b(this,s,"f",n)+1),"f",n),(0,E.compactBlanks)([q.TokenRadix.encode(b(this,s,"f",n)),B.serviceName.prior(),(0,L.toS)(e)]).join("-")}static pidFromLockfile(e){return s.pidFromBasename((0,G.basename)(e))}static pidFromBasename(e){return(0,A.toInt)(J.exec((0,L.toS)(e))?.groups?.pid)}static for(e){return b(this,s,"f",o).find((t=>t.opts.file===e.file))??new s(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>b(this,r,"m",w).call(this)),e.endableRank??j.EndableRanks.postdb,(0,H.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,S(t=s,s,(i=b(t,s,"f",a),++i),"f",a)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(b(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,$.fsLockFileBasename)(s.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await b(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,$.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+b(this,l,"f")),this.staleMs=(0,A.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),b(s,s,"f",o).push(this)}get acquired(){return b(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await b(this,r,"m",f).call(this,e)??b(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,k.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,x.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==b(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:D.secondMs);S(this,c,setInterval((()=>b(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=b(this,c,"f")&&(clearInterval(b(this,c,"f")),S(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(b(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),S(this,u,!1,"f"),(0,F.map)(b(this,d,"f"),(e=>(0,M.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?b(this,r,"m",v).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),S(this,d,setTimeout((()=>b(this,r,"m",v).call(this)),(0,A.toGt0)(this.staleMs)??D.secondMs),"f"),b(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(b(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,O.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,s=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,r=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,A.gt0)(this.staleMs)&&Date.now()>b(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await b(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){S(this,h,Date.now(),"f");const e=[],t=await b(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,A.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+D.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,$.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;s.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const n=i[0]===this.lockfile.base;if(n)S(this,u,!0,"f");else if(!0!==t?.vacuum){const t=s.pidFromBasename(i[0]);if((0,A.gt0)(t)&&!(0,_.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),b(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:n,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await b(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},v=async function(){await b(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},w=function(){(0,E.filterInPlace)(b(s,s,"f",o),(e=>b(e,l,"f")!==b(this,l,"f")))},n={value:0},K.internalErrors=0,a={value:0},o={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),s=i(51926),n=i(54993),a=i(17217);function o(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,s.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,s.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,n.toS)(e)))return;const i=(0,a.basename)(e);return o(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&o((0,a.basename)(e))}},4001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),s=i(55835),n=i(31586),a=i(51926),o=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,r.toNotBlank)(e.name)??(0,o.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,n.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:f(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const s=(0,u.parsePosixPath)(i),n=h(s,{aggressive:!1});return[...t,n+s.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,a.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),r=(0,a.stripPrefix)(t.toLowerCase().normalize(),i);return(0,s.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,a.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,s.map)(m.exec(t),(e=>t=e[1].trim())),(0,s.map)(g.exec(t),(e=>t=e[1].trim())),t}},19254:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fileGrep_=t.GrepReader=void 0;const s=r(i(73024)),n=i(57075),a=i(46466),o=i(54993),l=i(33456),u=i(17217),c=i(58722);class d extends n.Transform{constructor(e,t="\n"){super({objectMode:!1,autoDestroy:!0}),this.pattern=e,this.sep=t}_transform(e,t,i){const r=(0,o.toS)(e).match(this.pattern);null!=r&&this.push(r[1]??r[0]+this.sep),i()}}t.GrepReader=d,t.fileGrep_=async function(e,t){const i=new c.WritableToBuffer;return await(0,a.pipeline)([s.default.createReadStream((0,u.toNativePath_)(e)),new l.LineReader,new d(t),i]),(await i.buffer).toString()}},14977:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const s=r(i(44652)),n=r(i(73024)),a=i(46466),o=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,a.pipeline)(n.default.createReadStream(e,{autoClose:!0}),o.default.createGzip(),n.default.createWriteStream(t,{autoClose:!0})),await s.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const s=r(i(77598)),n=r(i(73024)),a=i(46466),o=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),v=i(16287),w=(0,o.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),b=(0,o.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function S(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=b().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),b().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await _(n.default.createReadStream(i)),stats:(0,u.pick)(await(0,v.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],i="sha512"){const r=s.default.createHash(i);return await(0,a.pipeline)([e,...t,r]),r.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:b,impl:P}),t.fileShaMeta_=S,t.fileSha_=async function(e){return(await S(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return s.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),s=i(42659),n=i(55835),a=i(31586),o=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,o.stdout_)("chflags",["hidden",t],{timeoutMs:10*s.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,n.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,o.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*s.secondMs}),i=(0,a.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),s=i(54993),n=i(7282),a=i(43334),o=i(69375),l=/^\/dev(?:\/|$)/i,u=a.isMac||(0,n.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=a.isMac||(0,n.isTest)()?/^\/private\//i:void 0,d=a.isMac||(0,n.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=a.isMac||(0,n.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,s.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,o.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},87128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonFileStore=void 0;const r=i(19851),s=i(55835),n=i(57159),a=i(50213);t.JsonFileStore=class{constructor(e,t,i){this.file=e,this.mkObject=t,this.onWrite=i,this.prior=(0,r.lazy)((()=>this.file.readJson("debug")))}async read_(){return await this.prior()??(0,s.map)(await this.mkObject(),(e=>this.write_(e)))}async write_(e){try{return await this.file.writeJson_(e,{spaces:2}),this.prior.set(Promise.resolve(e)),(0,a.mkLogger)("fs.JsonFileStore").info("wrote to "+this.file,e),null!=this.onWrite&&await this.onWrite(this.file,e),e}catch(e){throw new n.WrappedError("Failed to write to "+this.file,{cause:e,path:this.file.nativePath})}}}},33456:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),s=i(51926),n=i(54993);class a extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,n.toS)(e)).split((0,s.newlineRe)()),a=r.pop();this._prior=a??"";let o=!1;for(const e of r)o||(o=!this.push(e));o?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=a},64680:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const s=r(i(76760)),n=i(17217),a=i(73428);t.mkNoMedia_=function(e){return(0,a.writeTextfile_)(s.default.join((0,n.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},61704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nativePathsEql=t.nativePathsEqlSync=void 0;const r=i(21144),s=i(17217);t.nativePathsEqlSync=function(e,t){if(null==e||null==t)return!1;if(e===t)return!0;try{const i=(0,s.toNativePath_)(e),r=(0,s.toNativePath_)(t);return null!=i&&null!=r&&i===r}catch{return!1}},t.nativePathsEql=async function(e,t){try{return null!=e&&null!=t&&await(0,r.actualPath_)((0,s.toNativePath_)(e))===await(0,r.actualPath_)((0,s.toNativePath_)(t))}catch{return!1}}},85772:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const a=n(i(76760)),o=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),v=i(83278),w=i(70698),b=i(88561),S=i(65238),P=i(16287),_=(0,o.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),T="NoMedia",M=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(a.default.sep),"/"]).join("")+"])\\.?"+T+"$","im"),E=Object.freeze(["."+T,T]),k=Object.freeze((0,u.flatten)(E.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function D(e){return null!=M.exec(e)}t.isNoMediaName=D;const x=(0,o.lazy)((()=>new b.FileCache({name:"fs.noMediaDirsCache"})));async function C(e,t){if(null==e)return null;const i=v.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return D(i.base)||await(0,w.isCachedirTagFile)(i)?x().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):C(i.parent());{const e=await x().getOrSetAsync(i.nativePath,(()=>F(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:C(i.parent())}}async function F(e){if(D(e.base))return x().set(e.parent().nativePath,e.nativePath),_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,S.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,r=await Promise.race([A(e.nativePath,i),(0,S.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,w.isCachedirTagDirectory)(e)?_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(w.CACHEDIR_TAG).nativePath)}):null}async function A(e,t){for(const i of g.isCaseSensitiveFs?k:E){if(!0===t?.aborted)return null;const r=a.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return _().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function I(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(D(r.basename))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,a.join)(e,r.basename))});if(r.basename===w.CACHEDIR_TAG){const t=(0,a.join)(e,r.basename);if(await(0,w.isCachedirTagFile)(t))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await C(e,t)},t.whyNoMedia=C,t.whyNoMediaDir=F,t._dirHasNoMediaChild=A},29882:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),v=i(78133),w=i(53265),b=i(17217),S=i(16287),P=i(66430),_=i(5545);function T(e){return((0,b.isSimpleFile)(e)?e.base:n.default.basename(n.default.resolve(e))).startsWith(".")}t.logger=(0,a.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=T,t.containsHiddenPathname=function(e){return C(e).some(T)},t.isNotHiddenPosixPath=function(e){return C(e).every((e=>!T(e)))},t.resolveSimpleFile=function(e){return(0,b.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return E((0,v.posix2native)(e))},t.extname=function(e){return E(e).ext},t.dirname=function(e){return n.default.dirname((0,b.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(n.default.parse(e).ext,n.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function E(e){const t=M.exec(e)?.groups,i=t?.ext2??"",r=n.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function k(e){const t=n.default.parse((0,b.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,n.default.sep)}function D(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,b.toNativePath_)(e.ancestor),i=(0,b.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,n.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function x(e,t,i){if(null==t||null==i)return!1;const r=e(t),s=e(i);return null!=r&&null!=s&&(y.isLinux?r===s:(0,p.equalsIgnoreCase)(r,s))}function C(e){return(0,b.isSimpleFile)(e)?e.pathnames:e.split(n.default.sep).filter((e=>null!=e&&""!==e))}function F(e){return(0,u.notBlank)(e)&&C(e).length===(y.isWin?1:0)}function A({p:e,maxLength:t}){const i=(0,b.toNativePath_)(e);if(i.length<=t)return i;const r=C(e),s=[],n=[r.pop()];for(;r.length>0;)if(s.length=t){r.unshift(s.pop());break}}else if(n.unshift(r.pop()),O([...s,...n]).length>=t){r.push(n.shift());break}return r.length>0&&s.push("…"),O([...s,...n])}function I(e){return e.startsWith("\\\\")}function O(e){return(0,h.ensurePrefix)((0,o.compactBlanks)(e).join(n.default.sep),y.isWin?"":n.default.sep)}t.parseNativePath=E,t.parentBasename=k,t.grandParentBasename=function(e){return k(n.default.parse((0,b.toNativePath_)(e)).dir)},t.containedByNativePath=D,t.eqlBasename=function(e,t){return x(b.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return x(b.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return x(b.toNativePath_,e,t)},t.toPathnames=C,t.pathIsRoot=F,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:C(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,b.toNativePath_)(e),r=(0,b.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,v.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=A,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const s=[];for(const r of e.slice(0,i))s.push(A({p:r,maxLength:t}));return s.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return C(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return C(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=E(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,S.isReadableDirectory)(e))return;if(F(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await s.default.mkdirp(e)}catch(t){if(await(0,S.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;s.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>s.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,b.toNativePath_)(e).split(n.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=O,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:O(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>D({ancestor:t,descendant:e,acceptSelf:!0})?[(0,b.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),v=i(64660),w=i(21144),b=i(16287),S=(0,n.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const i=await(0,b.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,v.isStatRX)(i,e)}function T(){if(y.isWin){const e=(0,o.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,o.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,o.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,s.default.join(e,"System32"),s.default.join(e,"System32","Wbem"),s.default.join(i,"chocolatey","bin"),s.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(s.default.delimiter);return(0,a.uniq)((0,a.compactBlanks)([...e,...T()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,a.uniq)((0,a.compactBlanks)([...M(),...(0,d.toA)(i)]));for(const i of(0,a.uniq)((0,a.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=s.default.join(t,e);if(await _(i))return y.isLinux?i:(0,w.actualPath)(i)}}S().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){"use strict";var r,s,n,a=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return o(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),v=i(76790),w=i(5233),b=i(22573),S=i(42659),P=i(26905),_=i(75240),T=i(55835),M=i(31586),E=i(68708),k=i(13538),D=i(89937),x=i(12168),C=i(54993),F=i(48884),A=i(50213),I=i(45255),O=i(81168),L=i(56519),R=i(56038),N=i(31562),B=i(84777),j=i(9595),z=i(38835),V=i(70025),W=i(57902),U=i(55222),q=i(43334),H=i(33847),$=i(24399),G=i(28874),J=i(79915),K=i(45200),Y=i(34238),X=i(87001),Z=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),se=i(73209),ne=i(48313),ae=i(29882),oe=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,F.contextFilter)(function(e){return(0,v.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,A.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Y.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,L.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,L.thenMapOr)((0,Z.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>q.isMac?(0,B.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,b.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,b.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,O.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,oe.toNativePath_)(e),r=new fe(i,t);return(0,O.isString)(e)&&he().set(e,r),he().set(i,r),r}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,L.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,ae.containedByNativePath)({ancestor:(0,j.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,ae.containedByNativePath)({ancestor:(0,j.originalsDir)(),descendant:this,acceptSelf:!0}))return q.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,T.map)((0,ee.bestMountpoint)(this.nativePath,await(0,Z.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,T.map)((0,b.notBlankOr)(e,(()=>this.uri_())),Y.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,C.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===D.PS_LIBRARY_SCHEME?1:t.scheme===D.PS_LOCAL_FILE_SCHEME?2:t.scheme===D.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,O.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(q.isWin||q.isMac)return this.trap("hide",(async()=>(await(0,ne.hide_)(this),this)))}async hidden(){return(0,ne.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,O.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,F.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,T.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,E.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:s,skipWip:n=!1,skipFsLock:a=!1,retries:o=2,dirty:l=!1}){return(0,w.retryOnReject_)((async()=>{const o=await this.clear().isNonEmptyFile(i);if(!o){if(n&&a)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:a,minSizeBytes:i,timeoutMs:s,dirty:l})}return o&&r?void 0:this.utimes()}),{maxRetries:o,timeoutMs:2*s,retryDelay:3*S.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,M.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:s,dirty:n=!1}){return await this.parent().mkdirp_(),(0,se.withLock_)({file:this,skipFsLock:r,timeoutMs:s,dirty:n},(async()=>{const r=this.wip();try{await r.unlink("trace");const n=await(0,k.thenOrTimeoutError)(e(r),s);if(n===t.NoOp)return n;if(await(0,N.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),n;throw new Error(this+"applyWip(): still empty after waiting "+(0,_.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==G.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",s).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",n).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();G.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:S.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,M.clamp)(I.ShortCommandTimeoutMs,10*S.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,b.notBlank)(this.ext)&&(0,b.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,S.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,T.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,L.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,O.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,ae.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,ae.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,X.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,r=new WeakSet,s=async function(e){let t,i=e;const r=e.wip();try{const s=await this.stat_();if(null==s)return this.pflog().throw("Can't copy missing files"+z.NonRetriableErrorFlag);if(s.size>0){if(G.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+z.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,r.nativePath,h.default.constants.COPYFILE_FICLONE),s.size>5*x.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},s.size,(()=>r.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,M.approximates)(s.size,await r.size({refresh:!0}))),{intervalMs:S.secondMs,timeoutMs:S.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:s.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:s.birthtimeMs,mtimeMs:s.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,s.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${s.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,T.map)(t,(e=>e.end()))}},n=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),s=r?.size;return null==r||null==s?this.pflog().throw("Can't copy missing files"):(s>5*x.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},s,(()=>e.clear().size()))),q.isWin?await $.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,$.pwshQuote)(this.nativePath)} -Destination ${(0,$.pwshQuote)(i.nativePath)}`,(e=>e)):q.isMac?await(0,B.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,B.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+z.DoNotSendErrorFlag,{error:t})}finally{(0,T.map)(t,(e=>e.end()))}}},62105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.acceptFile=t.whyRejectFile=t.expensiveFileFiltersFor=t.acceptParentAndFileAndSimple=t.acceptFileSimple=t.whyRejectFileSimple=t.simpleFileFiltersFor=t.notFileTooBig=t.notFileTooSmall=t.notFileMissing=t.hasBrowserImgMimeType=t.notDimensionsTooSmall=t.requiredTagsFilter=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(54993),o=i(48884),l=i(56519),u=i(78984),c=i(28874),d=i(43207),h=i(47783),f=i(97573),m=i(16170),p=i(54979),g=i(1078),y=i(42231),v=i(83278),w=i(19748),b=i(92423),S=i(16287);function P(e){return async t=>(0,l.thenMapOr)((0,h.readRawTags)(t,!1),e,(()=>!1))}async function _(e){if(!(0,n.gt0)(c.Settings.minVideoDimension.valueOrDefault)&&!(0,n.gt0)(c.Settings.minImageDimension.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);if(null==t||!t.startsWith("image/")&&!t.startsWith("video/"))return!1;const i=t.startsWith("video/")?c.Settings.minVideoDimension.valueOrDefault:c.Settings.minImageDimension.valueOrDefault;return(0,n.gt0)(i)?(0,l.thenMapOr)((0,g.extractSizeInfoFromFile)(e),(e=>(0,n.gte)(e.ImageWidth,i)&&(0,n.gte)(e.ImageHeight,i)),(()=>!1)):null}async function T(e){if(!(0,n.gt0)(c.Settings.minVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.gte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.minVideoDurationSec.valueOrDefault):null)}async function M(e){if(!(0,n.gt0)(c.Settings.maxVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.lte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.maxVideoDurationSec.valueOrDefault):null)}async function E(e){return!(0,s.blank)(await(0,p.readMimeType)(e))}async function k(e){if(-100===c.Settings.rejectRatingsLessThan.valueOrDefault)return null;const t=await(0,h.readTags)(e),i=(0,n.toInt)(t?.Rating);return null==i||i>=c.Settings.rejectRatingsLessThan.valueOrDefault}async function D(e){return 0===c.Settings.keywordBlocklist.values.length?null:(0,f.rawTagKeywords)(await(0,h.readTags)(e)).every((e=>!0!==(0,y.leafIsExcluded)(e,c.Settings.keywordBlocklist.values)))}async function x(e){if(!c.Settings.requireMakeModel.valueOrDefault)return null;const t=await(0,h.readRawTags)(e);return null==t||(0,s.blank)(t.MIMEType)?null:t.MIMEType.startsWith("image/")?null!=t&&(0,s.notBlank)(t.Make)&&(0,s.notBlank)(t.Model):null}async function C(e){return(0,v.isBaseFile)(e)?e.exists():(0,S.exists)(e.nativePath)}async function F(e){const t=c.Settings.minAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.gte)(i,t)}async function A(e){const t=c.Settings.maxAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.lte)(i,t)}function I(e){return[{isSupportedFileExtension:w.isAssetFileExtension},...(0,b.notExcludedFilePredicates)(e),{notFileMissing:C},{notFileTooSmall:F,notFileTooBig:A}]}function O(e){return[...I(e),{notMissingMimeType:E},{supportedMimeType:m.isAssetFileMimeType},{notMissingMakeAndModelTags:x},{notDimensionsTooSmall:_},{notVideoTooShort:T},{notVideoTooLong:M},{notRejectedRating:k},{notExcludedKeyword:D}]}async function L(e,t){return await u.Predicates.whyRejected(e,...t??O(e))??await(0,b.whyExcludedDirectoryRecursive)(e.parent())}t.requiredTagsFilter=function(e){return P((t=>(0,o.allNotBlank)(...e.map((e=>t[e])))))},t.notDimensionsTooSmall=_,t.hasBrowserImgMimeType=P((e=>(0,r.includes)(["image/jpeg","image/png"],(0,a.toS)(e.MIMEType)))),t.notFileMissing=C,t.notFileTooSmall=F,t.notFileTooBig=A,t.simpleFileFiltersFor=I,t.whyRejectFileSimple=function(e){return u.Predicates.whyRejected(e,...I(e))},t.acceptFileSimple=function(e){return u.Predicates.accepted(e,...I(e))},t.acceptParentAndFileAndSimple=async function(e){const t=await e.parent();return null!=t&&!await(0,b.isExcludedDirectory)(t)&&await u.Predicates.accepted(e,...I(e))},t.expensiveFileFiltersFor=O,t.whyRejectFile=L,t.acceptFile=async function(e){return null==await L(e)}},78133:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const s=r(i(76760)),n=i(22573),a=i(81168);t.posix2native=function(e,t){if((0,n.blank)(e))return e;if(s.default.sep===s.default.posix.sep)return e;const i=(0,n.notBlank)(t)?s.default.sep+s.default.sep+t+s.default.sep:"",r=e.split(s.default.posix.sep);return(0,a.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(s.default.sep)},t.native2posix=function(e){return(0,n.blank)(e)||s.default.sep===s.default.posix.sep||s.default.posix.sep===s.default.sep?e:e.split(s.default.sep).join(s.default.posix.sep)}},43899:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,a.lazy)((()=>s.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,a.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(s.default.join((0,p.execDir)(),"resources"),s.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,o.compactBlanks)([(0,p.execDir)(),n.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const r=s.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),s=i(19851),n=i(31586),a=i(50213),o=i(57902),l=i(69428),u=(0,s.lazy)((()=>(0,a.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=o.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,n.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),s=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let n=-1;try{const s=i??(await(0,r.stat)(e)).size-t,a=Buffer.alloc(s);return n=await(0,r.open)(e,"r"),await(0,r.read)(n,a,0,s,t)}finally{(0,s.mapGte0)(n,r.close)}}},69428:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const a=n(i(73024));t.readFileSync=function(e){try{return a.readFileSync(e)}catch{}}},55690:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),s=i(84542);t.readLines_=async function(e){return(0,s.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class s extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=s},65238:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const s=r(i(51455)),n=i(76760),a=i(19851),o=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),v=i(28874),w=i(63870),b=i(88561),S=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,a.lazy)((()=>(0,n.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,a.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await s.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const T=(0,a.lazy)((()=>new b.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||T.prior()?.delete(e)}async function E(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await T().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,S.statTimeoutMs)(),r=k(e),s=await(0,h.thenOrTimeout)(r,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,S.statTimeoutMs)());if(s===f.Timeout&&(0,g.onTimeout)({soft:!1}),s!==f.Timeout&&s.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),T.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,a.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!T().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=T().get(e)},t.childDirectories_=async function(e){return(await E(e)).filter((e=>e.isDirectory)).map((t=>(0,n.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?E(e):k(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=E,t.readdirCached=function(e){return T().get(e)},t.readdirUncached_=k},53265:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const s=i(73024),n=r(i(76760)),a=i(40958),o=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,a.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=n.default.resolve(t,...e);if((0,s.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,o.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(o.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??n.default.resolve(...e))},t.execDir=(0,l.defer)((()=>n.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},46356:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.seemsLikeSymlinkLoop=void 0;const r=i(22454),s=i(28874),n=i(29882);t.seemsLikeSymlinkLoop=function(e){const t=new r.CountingSet;for(const i of(0,n.toPathnames)(e))t.incr(i.toLowerCase().normalize());return t.max()>s.Settings.maxDuplicatePathElements.valueOrDefault}},8797:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.showFileInFolder=void 0;const r=i(58587),s=i(31421),n=i(19851),a=i(40958),o=i(50213),l=i(43334),u=i(24399),c=i(28874),d=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ShowFileInFolder")));async function h(e,t){try{(0,s.spawn)(e,t,{detached:!0,stdio:"ignore"}).unref()}catch(i){d().warn("spawn() failed",{err:i,cmd:e,args:t})}}t.showFileInFolder=async function(e){if(await e.isEmpty())return!1;if(c.Settings.showFileInFolderUsesThunar.valueOrDefault&&l.isLinux)return async function(e){return h("dbus-send",["--type=method_call","--dest=org.xfce.Thunar","/org/xfce/FileManager org.xfce.FileManager.DisplayFolderAndSelect",`string:"${e.dir}"`,`string:"${e.base}"`,'string:""','string:""'])}(e);if((0,a.isNotEmpty)(c.Settings.showFileInFolderCommand.values)){const t=c.Settings.showFileInFolderUsesFileUri.valueOrDefault?e.fileuri():e.nativePath,i=[...c.Settings.showFileInFolderCommand.values,t],r=i.shift();return d().info("custom showFileInFolderCommand: running",{cmd:r,args:i}),h(r,i)}return l.isLinux?async function(e){return h("nautilus",["-s",e.fileuri()])}(e):l.isWin?async function(e){const t=e.nativePath.replace(/"/g,"").replace(/'/g,"''");try{return await u.PowerShell.instance().execute(`start explorer.exe -ArgumentList '/select,"${t}"'`,r.SimpleParser),!0}catch(t){return d().warn("explorerSelect("+e+") failed",t),!1}}(e):!!l.isMac&&async function(e){return h("open",["-R",e.nativePath])}(e)}},50274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),s=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,s.isBoolean)(e.isFile)&&(0,s.isBoolean)(e.isDirectory)}},17217:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const s=r(i(73024)),n=r(i(76760)),a=i(22573),o=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,a.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,a.blank)(e.nativePath))throw new Error(`toNativePath(${(0,o.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof s.default.Dirent?e.name:f(e)?e.base:n.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:n.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(n.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,o.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(s.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,o.blank)(e)?void 0:v(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function b(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function S(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=b(e),r=b(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],s=t[i],n=(0,u.diff)(S(r),S(s));if(null==n||n>1)return"unmatched "+i+": "+r+" ≠ "+s}}t.stat_=v,t.statMaybe=w,t.statToType=b,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const i=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await w(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,a.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const s=r(i(73024)),n=i(22573);function a(e){try{return(0,n.blank)(e)?void 0:s.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function o(e){return null==e||e.isFile()&&0===e.size}t.statSync=a,t.isEmptyStats=o,t.isFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=a(e);return t.emptyIsNew?null==i:o(i)},t.isNonEmptyFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===a(e)?.isDirectory()}},41080:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),s=i(56409);t.onDataChunked=function(e,t,i){const r=new n(t,i,!0);return r.read(e),r.done};class n{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new s.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=n},95705:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const s=r(i(57075)),n=i(41400),a=i(55835),o=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends s.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,n.delay)(50);try{(0,o.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,a.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends s.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const s=r(i(73024)),n=i(76760),a=i(22573),o=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,a.blank)(e))return!1;try{return s.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,o.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,a.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,a.notBlank)(t)){const e=(0,n.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,a.blank)(e)&&d((0,u.posix2native)(e))}},74128:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncReport=t.syncReport=t.recentSyncReports=t.ensureSyncReportReadme=t.syncReportReadme=t.syncReportDir=t.SyncReportHeaders=t.isRejectedState=t.SyncReportStates=t.SyncDirStates=t.FileDoneStates=t.SyncFileStates=t.AssetFileSyncStates=void 0;const p=i(51168),g=i(73024),y=i(4927),v=i(19851),w=i(40958),b=i(22573),S=i(42659),P=i(98553),_=i(31586),T=i(68708),M=i(50989),E=i(51926),k=i(85556),D=i(54993),x=i(89788),C=i(23467),F=i(7282),A=i(23560),I=i(77377),O=i(71567),L=i(73568),R=i(25764),N=i(38836),B=i(99331),j=i(12959),z=i(87290),V=i(46296),W=i(98314),U=i(38835),q=i(5012),H=i(32144),$=i(95696),G=i(36868),J=i(57902),K=i(28874),Y=i(84542),X=i(73428);t.AssetFileSyncStates=(0,M.strEnum)("noop","deleted","skipped","synced","unknown"),t.SyncFileStates=(0,M.strEnum)(...t.AssetFileSyncStates.values,"canceled","rejected","failed","timeout","enqueued","started","copied","blocklisted","note"),t.FileDoneStates=(0,I.diff)(t.SyncFileStates.values,["enqueued","started","note"]),t.SyncDirStates=(0,M.strEnum)("scanning","canceled","failed","timeout","skipped","scanned"),t.SyncReportStates=(0,M.strEnum)(...t.SyncFileStates.values,...t.SyncDirStates.values),t.isRejectedState=function(e){return null==e||["canceled","deleted","failed","rejected","timeout","unknown"].includes(e)};const Z={enqueued:"the file looks promising, and will be attempted to be imported soon.",rejected:"the file did not pass all import filters. The details column will explain why.",started:"the file was dequeued from the work queue, and is now going to be processed.",noop:"the current file metadata already matches your library database, so no operation was needed to sync this file.",deleted:"the file was determined to be deleted (the prior mountpoint exists, but the file doesn't exist anymore)",skipped:"the file lives on a volume that isn't currently mounted.",synced:"the file was imported.",blocklisted:"the file was blocklisted and files with the same SHA will not be imported in the future.",failed:"something went wrong. The details column will explain why.",timeout:"the file wasn't processed in a reasonable amount of time.",copied:'"automatic organization" is enabled (copyAssetsToLibrary=true), and the photo or video was copied into your library originals directory. The details column will contain the source file path.',note:"sidecars will be referenced here. The details column will specify which source file(s) it will be associated with.",canceled:"PhotoStructure was shut down while the file was processed.",unknown:"an internal error occurred during processing."},Q={scanning:"the directory contents are about to be read.",scanned:"the directory contents were completely processed.",skipped:"the directory was excluded. The details column will explain why.",canceled:"PhotoStructure was shut down before the directory was processed.",failed:"reading the directory contents failed.",timeout:"reading the directory contents took too long."};function ee(e){return(0,T.entries)(e).map((([e,t])=>` - "${e}": ${t}`)).join("\n")}const te=new Set([t.AssetFileSyncStates.deleted,t.SyncFileStates.failed,t.SyncFileStates.timeout,t.SyncDirStates.canceled]);function ie(){return(0,z.librarySyncReportsDir)()??$.PosixFile.for((0,V.logDir)()).join("sync-reports")}function re(){return ie().join("README.txt")}t.SyncReportHeaders=(0,M.strEnum)(...(0,T.keys)(new class{constructor(e,t,i,r,s,n,a,o,l={}){this.ts=e,this.at=t,this.path=i,this.state=r,this.from=s,this.elapsedMs=n,this.details=a,this.url=o,this.meta=l}}(0,"","","unknown","",0,"",""))),t.syncReportDir=ie,t.syncReportReadme=re,t.ensureSyncReportReadme=(0,v.lazy)((()=>(0,X.writeTextfile_)(re().nativePath,(0,E.wrap)(`\n\nHowdy from PhotoStructure!\n\nThis directory contains your recent "sync reports". \n\nThese files are written as your scan paths are examined for photos and videos.\n\nPhotoStructure creates a new file when it restarts and when it completes importing a given scan path directory.\n\nThese CSV files can be opened with most spreadsheet applications, like LibreOffice.\n\n\nColumn descriptions\n===================\n\nThe "ts" column is the timestamp for the row, in millis from 1970-01-01. Most spreadsheet applications don’t know how to parse these values, though, so we also add the at column.\n\nThe "at" column is ts in ISO format with only second resolution, and should be parsable by most spreadsheet software.\n\nThe "path" column is the native path of the directory or file. It will be empty for messages about system state.\n\nThe "state" column explains why that row was added.\n\nThe "from" column specifies which codepath added the sync report row.\n\nThe "elapsedMs" column is only added to rows completing a given path, and records how long that process took.\n\nThe "details" column will include information about the path, like why a given file or folder were rejected.\n\nThe "url" column is only added to rows when a file or directory is imported. You may need to adjust the domain name of the URL to make it work correctly (it defaults to localhost).\n\n\nDirectory state values\n======================\n\nThe "state" column for directories will be\n\n${ee(Q)}\n\n\nFile state values\n=================\n\nThe "state" column for files will be\n\n${ee(Z)}\n\n\nSee https://photostructure.com/go/sync-reports\n\n`,{maxLineLen:80}).join("\n")))),t.recentSyncReports=async function(e=S.dayMs){const t=Date.now()-e;return ie().descendants((async e=>(0,H.isCsvExt)(e)&&(0,_.gte)(e.mtimeMs(),t)))},t.syncReport=(0,v.lazy)((()=>new se));class se extends N.EndableWrapper{constructor(){super("fs.SyncReport()",(()=>f(this,r,"m",d).call(this)),R.EndableRanks.predb),r.add(this),s.set(this,void 0),n.set(this,void 0),a.set(this,void 0),o.set(this,0),l.set(this,0),this.outputFiles=new x.BoundedList(64),(0,t.ensureSyncReportReadme)()}get outputNativePath(){return f(this,s,"f")?.nativePath}get rowCount(){return f(this,l,"f")}onProgress(e){if(null==e||(0,b.blank)(e.state))return this.logger.error(".onProgress(): invalid input",{s:e,from:(0,q.stack)()});{this.logger.log(te.has(e.state)?J.LogLevels.warn:J.LogLevels.info,"onProgress()",e);const t=Date.now(),i={path:(0,D.toS)(e.path),state:e.state,details:(0,D.toS)(e.details).trim().replace(/\r?\n/g,"; ")},s={ts:t,at:new Date(t).toISOString(),...i,...(0,T.pick)(e,"from","elapsedMs","url")};(0,T.isEmptyObj)(e.meta)||(s.meta=(0,P.stringify)(e.meta)),(0,F.isTest)()&&process.stdout.write((0,P.stringify)(e)+Y.Newline),f(this,r,"m",u).call(this,s)}}maybeSystemData(e){(0,A.isSyncService)()&&this.onProgress(e)}async wrap_({path:e,from:i,fn_:r}){const s=Date.now();this.onProgress({path:e,from:i,state:t.SyncFileStates.started});try{const n=await r(),a=n.state??(null!=n.error?t.SyncFileStates.failed:t.SyncFileStates.unknown);return a===t.SyncFileStates.unknown&&this.logger.error(i+" returned result with no state!"+U.InternalErrorFlag,{path:e,result:n}),this.onProgress({path:e,from:i,elapsedMs:Date.now()-s,...n,state:a}),n}catch(r){throw this.logger.warn("wrap_() caught error",{error:r}),this.onProgress({path:e,from:i,state:(0,B.ending)()||r instanceof L.AbortError?t.SyncFileStates.canceled:r instanceof k.TimeoutError?t.SyncFileStates.timeout:t.SyncFileStates.failed,details:(0,B.ending)()?void 0:(0,W.errorToS)(r),elapsedMs:Date.now()-s}),r}}get output(){return f(this,n,"f")??f(this,r,"m",h).call(this)}async flushClose(){return f(this,r,"m",u).call(this),this.close()}async close(){this.logger.info("Closing sync report");const e=f(this,n,"f");return m(this,n,void 0,"f"),m(this,l,0,"f"),await(0,G.endStream)(e),null==e?void 0:f(this,s,"f")}}t.SyncReport=se,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,r=new WeakSet,u=function(e){var t;const i=f(this,a,"f");if(m(this,a,e,"f"),null!=e&&(0,C.eqlPicked)(e,i,"path","state","details"))return this.logger.debug("deduping row",e),void m(this,o,(t=f(this,o,"f"),t++,t),"f");null!=i&&(0===f(this,o,"f")?f(this,r,"m",c).call(this,i):(f(this,r,"m",c).call(this,{...i,details:(0,w.compactBlanks)([i.details,`(repeated ${f(this,o,"f")+1} times)`]).join(" ")}),m(this,o,0,"f")))},c=function(e){var i;const r=(0,y.unparse)([e],{header:!1,columns:t.SyncReportHeaders.values});this.output.write(r+Y.Newline,(e=>{null!=e&&this.logger.error("Failed to write",e)})),m(this,l,(i=f(this,l,"f"),++i),"f")>K.Settings.syncReportMaxRows.valueOrDefault&&this.close()},d=function(){return this.logger.info("sync report ended",{rowCount:f(this,l,"f"),outputFiles:this.outputFiles}),this.flushClose()},h=function(){return m(this,s,function(){const e=p.DateTime.now();return ie().join(e.toFormat("y-MM-dd"),(0,j.filestamp)()+"-sync-report.csv")}().ensureNewSync_({emptyIsNew:!1}),"f"),this.outputFiles.push(f(this,s,"f").nativePath),this.logger.info("Opening new report: "+f(this,s,"f")),(0,F.isTest)()&&(0,O.stdoutWrite)({syncReport:f(this,s,"f").nativePath},!1),m(this,n,(0,g.createWriteStream)(f(this,s,"f").nativePath),"f"),f(this,n,"f").write((0,y.unparse)([t.SyncReportHeaders.values],{header:!1})+Y.Newline),f(this,n,"f")}},89966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const s=r(i(48161)),n=i(19851),a=i(55835),o=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),h=i(8103),f=i(43899);function m(){return(0,a.map)(f.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,a.map)(m(),(e=>e.join(c.platformName+"-"+s.default.arch())))}async function g(e){if(c.isWin&&(e=(0,o.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,h.pathIfExists)(m()?.join("bin",e))),(()=>(0,h.pathIfExists)(m()?.join(e))),(()=>(0,h.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,h.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,n.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,n.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,n.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,n.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const s=r(i(44652)),n=i(19851),a=i(22573),o=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,o.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,a.blank)(t.file))throw new Error("can't touch blank path");const r=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const o=(0,n.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await o())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await o())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(s.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(n){if(!i||"ENOENT"!==n.code)throw n;await(0,c.thenOrTimeoutError)(s.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},79847:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.trashOrUnlinkFileUri=t.trashOrUnlinkFileUris_=void 0;const o=n(i(51455)),l=a(i(49378)),u=i(40958),c=i(22573),d=i(13538),h=i(83104),f=i(45255),m=i(31562),p=i(98314),g=i(34102),y=i(28874),v=i(45200),w=i(16287),b=i(74128),S=i(84258),P="fs.Trash";async function _(e){const t=Date.now(),i=y.Settings.commandTimeoutMs.valueOrDefault,r=(0,c.toNotBlank)(e.nativePath)??await(0,d.thenOrTimeout)((0,v.uri2nativePath)(e.uri,e.mountpoint),i);if((0,c.blank)(r)||r===h.Timeout)return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not convert URI to native path",path:e.uri,elapsedMs:Date.now()-t}),{uri:e.uri,unlinked:!1};const s=await(0,w.statMaybe)(r);if(null==s)return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: no such file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(!s.isFile())return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: not a file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(y.Settings.trySoftDeletes.valueOrDefault)try{if(await(0,d.thenOrTimeoutError)((0,l.default)(r,{glob:!1}),i),await function(e){return(0,m.untilTrue)((async()=>null==await(0,w.statMaybe)(e)),{timeoutMs:f.ShortCommandTimeoutMs})}(r))return(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Moved file to trash",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0};(0,S.logger)().warn("soft-delete("+r+") didn't seem to work: the file is still there?")}catch(e){(0,b.syncReport)().onProgress({from:P,state:"note",details:"Failed to soft-delete file to trash: "+(0,p.errorToS)(e),path:r,elapsedMs:Date.now()-t}),(0,S.logger)().warn("Tried to soft-delete, but that failed. We'll try to hard-delete.",{error:e})}try{return await(0,d.thenOrTimeoutError)(o.unlink(r),i),(0,g.ee)().emit("fileChanged",r),(0,S.logger)().info("unlink("+r+") successful"),(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Permanently deleted file",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0}}catch(i){return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not move file to trash or delete: "+(0,p.errorToS)(i),path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!1}}}t.trashOrUnlinkFileUris_=async function(e){const t=[];for(const{uri:i,mountpoint:r}of(0,u.uniqBy)(e,(e=>e.uri)))try{t.push(await _({uri:i,mountpoint:r}))}catch(e){t.push({uri:i,unlinked:!1,error:e})}return t},t.trashOrUnlinkFileUri=_},70854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryUidStore=t.LibraryUIDStore=t.SystemUIDStore=t.UIDStore=t.mkuid=void 0;const r=i(19851),s=i(41400),n=i(55835),a=i(92782),o=i(37805),l=i(46292),u=i(34102),c=i(55222),d=i(28874),h=i(87128),f=i(95696);function m(){return(0,a.safeRandomUid)({radix:c.TokenRadix,chars:24,splitEveryN:4})}t.mkuid=m;class p extends h.JsonFileStore{constructor(e,t){super(e.join("."+t+"-uid.json"),(()=>({uid:m(),version:o.version,type:this.type,createdAt:Date.now()})),(e=>e.hide())),this.rootDir=e,this.type=t,this.readUid_=(0,r.lazy)((async()=>(await this.read_())?.uid))}}function g(e=d.Settings.libraryDir.valueOrDefault){return(0,n.map)(f.PosixFile.forMaybe(e),(e=>new p(e,"library")))}t.UIDStore=p,t.SystemUIDStore=(0,r.lazy)((()=>(0,n.map)((0,l.configDir)(),(e=>new p(f.PosixFile.for(e),"system"))))),t.LibraryUIDStore=(0,r.lazy)(g),t.libraryUidStore=g,(0,s.later)((()=>{(0,u.ee)().on("clearCache",(()=>{t.SystemUIDStore.unset(),t.LibraryUIDStore.unset()})),d.Settings.libraryDir.watchLater((()=>t.LibraryUIDStore.unset()))}))},84258:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const a=n(i(51455)),o=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,o.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const r of(0,l.toA)(e))try{null!=r&&await a.unlink((0,c.toNativePath_)(r))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+r,{error:e})}}},5545:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const s=r(i(76760)),n=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,n.toS)(i.path??s.default.sep)}},70257:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),s=i(45255),n=i(17217);t.WipTimeoutMs=s.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const a=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(a,"")},t.isWip=function(e){return a.test((0,n.basename)(e)??"")}},58722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),s=i(22911);class n extends r.Writable{constructor(e){super(e),this.deferred=new s.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=n},73428:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(51926),o=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=n.default.dirname(e);await(0,c.mkdirp_)(i),await s.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=n.default.dirname(e);(0,c.mkdirpSync_)(i),s.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,a.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))}},13047:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const s=r(i(73024)),n=i(76760),a=i(46466),o=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await S(e,t)).toString()}async function b(e,t,i){const r=[],n=[s.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?n.push((0,o.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&n.push((0,o.createBrotliDecompress)().on("error",(e=>r.push(e)))),n.push(t),await(0,a.pipeline)(n),(0,u.isNotEmpty)(r))throw new f.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function S(e,t){const i=new y.WritableToBuffer;return await b(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await S(e))}async function _(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,n.parse)(e).dir),await(0,a.pipeline)(new g.ReadableBuffer(i),(0,o.createGzip)(),s.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=b,t.zCopyToBuffer_=S,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void v().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await _(e,t)}catch(t){v().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},60526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.exiftoolHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(98314),a=i(47783),o=i(63335),l=i(18454);t.exiftoolHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Tools",id:"tools-exiftool",ordinal:1,pendingMsg:"Checking ExifTool…",settings:[],later:async()=>{try{const e=await(0,a.exiftoolVersion_)();return{level:"ok",msg:["ExifTool is OK","ExifTool "+(0,o.ver)(e),(0,r.tt)((0,a.exiftool)().options.exiftoolPath)],meta:{exiftoolVersion:e}}}catch(e){return{level:"error",msg:"Something's amiss with ExifTool: "+(0,n.errorToS)(e)}}}})))},19652:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.externalDirectoryCheck=void 0;const a=i(51455),o=n(i(22915)),l=i(40958),u=i(82950),c=i(22573),d=i(45599),h=i(12168),f=i(50213),m=i(79960),p=i(32551),g=i(98314),y=(0,d.defer)((()=>(0,f.mkLogger)("health.externalDirectoryCheck")));t.externalDirectoryCheck=async function(){const e=(0,l.uniq)([(0,p.homeDir)(),o.getHomeFolder(),o.getPicturesFolder(),o.getVideosFolder(),o.getDesktopFolder(),await(0,m.defaultApplePhotosLibrary)()]).sort(),t=new Map,i=(0,l.uniq)(e.filter(c.notBlank)).sort();for(const e of i)try{await(0,a.readdir)(e,{withFileTypes:!0})}catch(i){if(["ENOTDIR","ENOENT"].includes(i?.code))continue;t.set(e,i)}const r=0===t.size?{level:"ok",msg:["Default media directories are OK","The following directories are readable:",(0,u.li)(i.map(u.tt))]}:{level:"warn",msg:["Error reading "+(0,h.plur)(t.size,"media directory")+":",(0,u.li)([...t.entries()].map((([e,t])=>(0,u.tt)(e)+":"+(0,g.errorToS)(t,{maxLen:80}))))]};return y().tap({msg:"externalDirectoryCheck",result:r})}},79483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.externalDirsHealthCheck=void 0;const r=i(45599),s=i(45969),n=i(19652),a=i(18454);t.externalDirsHealthCheck=(0,r.defer)((()=>(0,s.isDocker)()?void 0:a.HealthCheck.for({section:"System",id:"media-directories",pendingMsg:"Checking default photo directories…",settings:[],later:n.externalDirectoryCheck})))},63664:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRemoteOrLocalHealthSummarySync=t.getRemoteOrLocalHealthSummary=t.getLocalHealthSummary=t.getRemoteHealthSummary=void 0;const r=i(22573),s=i(45599),n=i(41400),a=i(50268),o=i(98553),l=i(50213),u=i(23560),c=i(45255),d=i(5916),h=i(28874),f=i(34238),m=i(51140),p=i(4988),g=i(18454),y=(0,s.defer)((()=>(0,l.mkLogger)("health.GetHealthSummary")));t.getRemoteHealthSummary=(0,d.lazyAsync)({later:async()=>{try{if((0,u.isWebService)())return;const e=await(0,p.get_)(f.URI.from({scheme:"http",authority:"127.0.0.1:"+h.Settings.httpPort.valueOrDefault,path:"/api/health"}),{timeoutMs:c.ShortCommandTimeoutMs}),t=(0,o.parseJSON_)(e.data);if(m.HttpStatusIs.ok(e.statusCode)&&(0,a.isHealthCheckSummary)(t))return"ready"===t.state&&(0,r.toNotBlank)(t.libraryDir)!==(0,r.toNotBlank)(h.Settings.libraryDir.valueOrDefault)&&(y().error("getHealthSummary(): libraryDir mismatch! Switching to that library directory...",{local:h.Settings.libraryDir.valueOrDefault,remote:t.libraryDir}),h.Settings.libraryDir.value=t.libraryDir),y().debug("getHealthSummary()",{response:e}),t;y().warn("getHealthSummary(): invalid response",{response:e})}catch(e){y().warn("Failed to get health check summary from web service",{error:e})}}}),t.getLocalHealthSummary=(0,d.lazyAsync)({later:()=>g.HealthCheck.awaitSettled()}),(0,n.later)((()=>{h.Settings.healthCheckIntervalMs.watch((e=>{t.getRemoteHealthSummary.setTTL(e),t.getLocalHealthSummary.setTTL(e)}))})),t.getRemoteOrLocalHealthSummary=async function(){return await(0,t.getRemoteHealthSummary)()??await(0,t.getLocalHealthSummary)()},t.getRemoteOrLocalHealthSummarySync=function(){return t.getRemoteHealthSummary.syncValue()??t.getLocalHealthSummary.syncValue()}},87408:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStatusSummary=void 0;const r=i(63870),s=i(18454),n=i(89035),a=i(82638);t.getStatusSummary=async function(e={}){return(0,a.summarizeHealthChecks)({healthChecks:[...s.HealthCheck.allCritical(),(0,n.memoryHealthCheck)()],errors:s.HealthCheck.lastErrors(),timeoutMs:(0,r.commandTimeoutMs)(),skipPending:!0,...e})}},18454:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,v,w,b,S,P,_=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},T=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const M=i(19851),E=i(40958),k=i(76790),D=i(41400),x=i(50357),C=i(26905),F=i(50268),A=i(55835),I=i(68708),O=i(30976),L=i(51926),R=i(13538),N=i(42279),B=i(59455),j=i(54993),z=i(48884),V=i(89788),W=i(22454),U=i(50213),q=i(69591),H=i(22911),$=i(99331),G=i(5916),J=i(42638),K=i(77740),Y=i(98314),X=i(70025),Z=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),re=i(21525),se=i(82638),ne=(0,M.lazy)((()=>(0,U.mkLogger)("health.HealthCheck")));class ae{static traceLater_(e,t){const i=new H.Deferred(e);i.catch((t=>{_(this,s,"f",l).push(e+": failed: "+(0,Y.errorToS)(t)),this.onResultChange()})),_(this,s,"m",o).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return _(this,s,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){_(this,s,"f",l).push((0,L.isString)(e)?e:(0,Y.errorToS)(e)),this.onResultChange()}static lastErrors(){return _(this,s,"f",l).toA()}static addLoadingMsg(e){_(this,s,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,E.compact)((0,B.toA)(e)).map(j.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return ne().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:_(this,s,"f",h).entriesByCountDesc()}),(0,A.map)((0,z.leastBy)(e,(e=>[_(this,s,"f",h).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=_(this,s,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,A.map)(e,(e=>_(this,s,"f",h).incr(e.msg))),ne().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return Z.Settings.skipHealthCheckIds.envValue=t,s.reset()}static findById(e){return _(this,s,"f",f).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,F.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=_(this,s,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=s.summary();if(e.pendingCount>0){const t=await Promise.all(s.testResultsCritical());e=s.summaryFromResults(t),ne().info("awaitSettled(): summary result",{summary:e,results:t})}return ne().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){s.summary.unset()}static reset(){if((0,$.ending)())ne().warn("Rejecting reset() when ending()",(0,C.shortStack)());else{this.onResultChange(),_(this,s,"f",l).clear(),_(this,s,"f",d).clear(),_(this,s,"f",h).clear(),_(this,s,"f",c).clear(),this.summary.clear(),T(this,s,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new s(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return _(this,s,"f",f).push(i),this.all.unset(),i}constructor(e,t,i,n,o,l,u,c,d,h,f,m,S,P=Q.commandTimeoutMs){r.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=n,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=h,this.errorLinks=f,this.onReset=m,this.ttlMs=S,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),w.set(this,(0,M.lazy)((async()=>{await _(this,p,"f").prior(),(0,x.eql)(_(this,g,"f"),_(this,r,"m",v).call(this))||(this.onReset?.(),await this.refresh(),_(this,w,"f").unset())}))),this.refresh=(0,M.lazy)((()=>new H.Deferred("refresh").observe((async()=>{await _(this,p,"f").prior();const e=_(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,U.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[F.HealthCheckSections.ordinal(this.section),l??999,this.id],T(this,p,(0,G.lazyAsync)({desc:this.pendingMsg,later:()=>_(s,s,"f",a).enqueue({name:this.id,l:()=>_(this,r,"m",b).call(this,o)}),ttlMs:S}),"f"),this.isCritical&&_(this,p,"f").watchLater({onChange:s.onCriticalResult,onError:s.onCriticalResult});for(const e of this.settings)Z.Settings[e].watchLater((()=>_(this,w,"f").call(this)))}isStale(){return _(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return _(this,p,"f").settledCount()}reset(){return _(this,p,"f").unset(),this.onReset?.(),T(this,g,{starting:!0},"f"),this}setTTL(e){_(this,p,"f").setTTL(e)}result(){return _(this,p,"f").call(this)}isSkipped(){return Z.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return _(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return _(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??_(this,r,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function oe(e){if((0,E.isEmpty)(e))return{};const[t,i]=(0,z.partition)(e,(e=>"button"===e.type||"POST"===e.method)),r={};return(0,E.isNotEmpty)(i)&&(r.links=(0,E.uniqBy)(i)),(0,E.isNotEmpty)(t)&&(r.buttons=(0,E.uniqBy)(t)),r}t.HealthCheck=ae,s=ae,p=new WeakMap,g=new WeakMap,y=new WeakMap,w=new WeakMap,r=new WeakSet,o=function(){return(0,E.filterInPlace)(_(this,s,"f",n),(e=>!e.isPending)),_(this,s,"f",n)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=ne().tap({level:"warn",msg:"#summary()",result:(0,se.summarizeHealthChecksSync)({errors:_(this,s,"f",l),skipPending:_(this,s,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&T(this,s,!0,"f",u),i.state!==_(this,s,"f",c).last?.state&&_(this,s,"f",c).push({state:i.state,ts:Date.now()}),i},v=function(){return(0,I.fromEntries)(this.settings.map((e=>[e,Z.Settings[e].valueOrDefault])))},b=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();ne().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,C.shortStack)()}),T(this,g,_(this,r,"m",v).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,D.delay)((0,O.randomInt)(.3*i,.7*i)),this.isSkipped())return _(this,r,"m",S).call(this,{test:{level:"disabled",msg:["Disabled by "+Z.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const s=await(0,R.thenOrTimeoutError)(e(),i);return _(this,r,"m",S).call(this,{test:s,elapsedMs:Date.now()-t})}catch(e){return _(this,r,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},S=function({test:e,src:t="#toResult",elapsedMs:i}){var r,n;const a=s.normalizeMsg(e.msg),o=e.level??((0,j.toS)(a).toLowerCase().includes("error")?"error":(0,j.toS)(a).toLowerCase().includes("warn")?"warn":"ok"),l=(0,E.compact)([...e?.links??("ok"===o||"pending"===o?this.okLinks:"warn"===o?this.warnLinks:"no-library"===o?this.noLibraryLinks:"error"===o?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:o,msg:a,elapsedMs:i,...oe(l)};return u.runCount=(T(this,y,(n=_(this,y,"f"),r=n++,n),"f"),r),(0,$.ending)()?u:this.logger.tap({level:re.HealthCheckLevelToLogLevel[o],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const s=(0,L.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,A.map)(e,Y.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,X.isFatalError)(e)&&s.toLowerCase().includes("warn")?"warn":"error"),_(this,r,"m",S).call(this,{test:{msg:s,level:t},src:"#toErrorResult",elapsedMs:i})},n={value:[]},a={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},h={value:new W.CountingSet},f={value:[]},ae.all=(0,M.lazy)((()=>Object.freeze((0,k.sortBy)(_(s,s,"f",f),(e=>e.sortBy))))),ae.onCriticalResult=(0,q.debounce)((()=>{ne().info("onCriticalResult()",s.summary.refresh())}),250),ae.summary=(0,M.lazy)((()=>_(s,s,"m",m).call(s))),ae.resetDebounced=(0,q.debounce)((()=>s.reset()),50)},85021:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckCommand=void 0,t.HealthCheckCommand="--health"},33866:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const r=i(82950),s=i(50268),n=i(459),a=i(23560),o=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,a.isPermaService)(t)&&(e===s.HealthCheckLevels.error||(0,a.isLibraryRequiredService)(t)&&e===s.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,o.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,r.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new n.UnreachableCaseError(e)}}},88625:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.healthCheckSetup=t.testHealthCheck=void 0;const r=i(19851),s=i(82950),n=i(45599),a=i(50268),o=i(50213),l=i(7282),u=i(44198),c=i(34102),d=i(2858),h=i(60526),f=i(79483),m=i(18454),p=i(39214),g=i(86403),y=i(42482),v=i(35675),w=i(89035),b=i(31974),S=i(20752),P=i(85200),_=i(37301),T=i(65756),M=i(15024),E=i(3956),k=i(29332),D=i(61274),x=i(38372),C=i(49913),F=i(84728),A=i(7245),I=i(16264),O=(0,n.defer)((()=>(0,o.mkLogger)("health.HealthCheckSetup")));t.testHealthCheck=(0,n.defer)((()=>m.HealthCheck.for({section:"System",id:"test-health-check",ordinal:0,settings:[],pendingMsg:"Test check…",later:async()=>{const e=a.HealthCheckLevels.validOrElse((0,u.env)().PS_TEST_HEALTH_CHECK_LEVEL,a.HealthCheckLevels.ok);return{level:e,msg:[`Test health check: ${e.toUpperCase()}`,`These are ${(0,s.b)("details")}:`,(0,s.li)("alpha",(0,s.tt)("bravo"),"charlie")]}}}))),t.healthCheckSetup=(0,r.lazy)((()=>{(0,h.exiftoolHealthCheck)(),(0,p.heifHealthCheck)(),(0,y.libraryDirectoriesCheck)(),(0,v.libraryFreeSpaceCheck)(),(0,E.settingsEnvHealthCheck)(),(0,D.settingsSystemHealthCheck)(),(0,k.settingsLibraryHealthCheck)(),(0,f.externalDirsHealthCheck)(),(0,w.memoryHealthCheck)(),(0,b.nodejsHealthCheck)(),(0,S.notInDMGHealthCheck)(),(0,P.osHealthCheck)(),(0,_.powershellHealthCheck)(),(0,x.sharpHealthCheck)(),(0,g.jpegtranHealthCheck)(),(0,M.securityHealthCheck)(),(0,T.sqliteHealthCheck)(),(0,C.systemLoadHealthCheck)(),(0,A.videoHealthCheck)(),(0,I.volumeHealthCheck)(),(0,F.versionHealthCheck)(),(0,l.isProd)()||(0,t.testHealthCheck)();let e=(0,d.libraryHasSettings)();d.libraryHasSettings.watchLater((t=>{null!=t&&e!==t&&(O().info("libraryHasSettings changed. Resetting health checks.",{newValue:t}),e=t,m.HealthCheck.resetDebounced())}));for(const e of["volumesChanged","mountpointsChanged","error"])(0,c.ee)().on(e,(()=>{O().debug("Clearing health check cache",{event:e}),m.HealthCheck.resetDebounced()}));(0,c.ee)().on("fatal",(e=>m.HealthCheck.addError(e)))}))},39214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heifHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(41400),a=i(55835),o=i(34102),l=i(277),u=i(45969),c=i(63335),d=i(18454);t.heifHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-heif",pendingMsg:"Checking HEIF/HEIC tooling…",settings:["heifConvertPath"],links:[{text:"Read how to set up HEIF support with PhotoStructure",url:"https://photostructure.com/getting-started/heif-support/",icon:"docs"}],warnLinks:(0,u.isDocker)()?[]:[{text:"Re-check for HEIF tooling",icon:"refresh",method:"POST",type:"button",url:"/admin/recheck-tools"}],later:async()=>{const e=await(0,l.getHeifSupportDetails)();return null!=e&&!1!==e.isSupportedVersion?{level:"ok",msg:["HEIF images will be imported",(0,a.map)(e.version,c.ver),(0,a.map)(e.path,r.tt)]}:{level:"warn",msg:["HEIF images will not be imported","No HEIF tooling was found."]}}}))),(0,n.later)((()=>{(0,o.ee)().on("clearToolCache",(()=>t.heifHealthCheck.prior()?.reset()))}))},86403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.testJpegtran_=t.jpegtranHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(55835),a=i(98314),o=i(89966),l=i(51210),u=i(76280),c=i(63335),d=i(18454);async function h(){const e=await(0,o.jpegtranNativePath_)(),t=await(0,l.jpegtranVersion_)();return{nativePath:e,version:t,satisfies:(0,u.semverSatisfies)(t,">=1.5")}}t.jpegtranHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-jpegtran",ordinal:2,pendingMsg:"Checking "+(0,r.tt)("jpegtran")+"…",settings:[],later:async()=>{try{const e=await h();return{level:"ok",msg:["jpegtran is OK",(0,n.map)(e.version,c.ver),(0,n.map)(e.nativePath,r.tt)]}}catch(e){return{level:"error",msg:["Something's amiss with jpegtran",(0,a.errorToS)(e)]}}}}))),t.testJpegtran_=h},42495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const r=i(40958),s=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,r.compact)([(0,s.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},42482:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryDirectoriesCheck=void 0;const r=i(82950),s=i(42659),n=i(45599),a=i(98553),o=i(31586),l=i(94174),u=i(87290),c=i(98314),d=i(29882),h=i(45969),f=i(43334),m=i(28874),p=i(2858),g=i(59107),y=i(18454),v=i(42495);async function w(){const e=await(0,u.setupLibraryDirs_)();return(0,p.libraryHasSettings)()?{level:"ok",msg:["Library directories are OK","Verified directory permissions for the following directories:",(0,r.li)(...e.map((e=>(0,r.tt)(e))))]}:{level:"no-library",msg:["Your PhotoStructure library hasn't been set up yet"]}}t.libraryDirectoriesCheck=(0,n.defer)((()=>y.HealthCheck.for({section:"Library",id:"library-directories",ordinal:0,pendingMsg:"Checking library directories…",settings:["libraryDir","originalsDir","previewsDir","cacheDir"],ttlMs:s.minuteMs,links:[{text:'What\'s a "PhotoStructure library?"',icon:"docs",url:"https://photostructure.com/faq/library/"},...(0,h.isDocker)()?[{text:"Read how to setup up Docker",icon:"docs",url:"https://photostructure.com/server/photostructure-for-docker/"}]:[]],okLinks:[{type:"button",text:"Run library maintenance jobs",url:"/admin/run-maintenance",method:"POST",icon:"handyman"}],later:async()=>(await(0,p.readSettings)(),(0,h.isDocker)()?async function(){const e=(0,u.libraryDirPosixFile)();if(null==e)return{level:"error",msg:[`Something's amiss: ${(0,r.tt)("PS_LIBRARY_DIR")} is blank`,`The default is ${(0,r.tt)(m.Settings.libraryDir.toEnvLine(m.Settings.libraryDir.defaultValue))}`]};const t=await(0,g.mountpoints_)(),i=(0,d.bestMountpointForDir)(e,t);if(null==i||"/"===i)return{level:"warn",msg:[e.nativePath+" is not a bind-mount",`Your library directory, ${(0,r.tt)(e)}, does not seem to be a bind mount.`,"Your library contents will disappear when you shut down this container."],links:[v.DockerVolumeLink]};try{if(!await e.isReadWriteExecutable_()){const t=await e.stat(),i=[`Your library directory, ${(0,r.tt)(e)}, is not read/write${f.isWin?"":"/execute"} by ${await(0,l.userDesc)()}`];return null!=t&&(0,o.gte0)(t.uid)&&i.push("The owner of this directory is userid "+(0,r.tt)(t.uid)+", groupid "+(0,r.tt)(t.gid)),{level:"error",msg:[...i,"Please fix the permissions for this bind mount and restart the container."],links:[v.DockerVolumeLink]}}return await w()}catch(t){return{level:"error",msg:[`Your library directory, ${(0,r.tt)(e)}, can't be set up for ${await(0,l.userDesc)()}.`,(0,c.errorToS)(t,{maxLen:80}),"Please fix the permissions for this bind mount and restart the container."],links:[v.DockerVolumeLink]}}}():async function(){const e=(0,u.libraryDirPosixFile)();if(null==e)return{level:"no-library",msg:["No PhotoStructure library is open",(0,a.stringify)(m.Settings.libraryDir.getState())]};if(!(0,p.libraryHasSettings)())return{level:"no-library",msg:["No PhotoStructure library is open",m.Settings.libraryDir.hasValue()?(0,r.tt)(m.Settings.libraryDir.toEnvLine()):void 0]};try{return await e.isReadWriteExecutable_()?await w():{level:"no-library",msg:[`Your library directory, ${(0,r.tt)(e)}, is not read/write${f.isWin?"":"/execute"} by ${await(0,l.userDesc)()}`,"Please fix the permissions or pick a new library directory."]}}catch(t){return{level:"no-library",msg:[`Your library directory, ${(0,r.tt)(e)}, can't be set up for ${await(0,l.userDesc)()}`,(0,c.errorToS)(t,{maxLen:80}),"Please fix the permissions for this bind mount and restart the container."]}}}())})))},35675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFreeSpaceCheck=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(31586),l=i(68708),u=i(12168),c=i(87290),d=i(77740),h=i(28874),f=i(7014),m=i(18454);t.libraryFreeSpaceCheck=(0,a.defer)((()=>(0,l.tap)(m.HealthCheck.for({section:"Library",id:"library-free-space",settings:["libraryDir","minDiskFreeGb","originalsDir","previewsDir","cacheDir"],pendingMsg:"Checking free space on library volume(s)…",ttlMs:n.dayMs,later:async()=>{if(!(0,o.gt0)(h.Settings.minDiskFreeGb.valueOrDefault))return{level:"disabled",msg:`Library disk free test disabled: ${(0,s.tt)(h.Settings.minDiskFreeGb.key+"=0")}`};const e=(0,c.libraryDirPosixFile)();if(null==e)return{level:"disabled",msg:"Library disk free test disabled: no library is open"};if(!0!==await e.isDirectory())return{level:"disabled",msg:`Library disk free test disabled: ${(0,s.tt)(e)} is not a directory`};const t=[];for(const e of await(0,c.setupLibraryDirs_)()){const i=await(0,f.bestVolumeForPath)(e);if(null==i)return{level:"warn",msg:`Could not check for minimum disk free: no volume found for library path ${(0,s.tt)(e)}`};let r=t.find((e=>e.vol.mountpoint===i.mountpoint));null==r&&(r={vol:i,paths:[]},t.push(r)),r.paths.push(e.nativePath)}const i=h.Settings.minDiskFreeGb.valueOrDefault*u.GB,n=[];for(const{vol:e,paths:a}of t){const t=(0,s.b)(`Volume ${(0,s.tt)(e.mountpoint)} has ${(0,u.fmtBytes)(e.available)} free.`)+`\nThis volume is used for these PhotoStructure directories:\n${(0,s.li)((0,r.uniq)(a).sort().map(s.tt))}`;if(e.available{for(const t of["minDiskFreeGb","libraryDir","originalsDir","configDir"])h.Settings[t].watchLater((()=>e.reset()))}))))},89035:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const s=r(i(48161)),n=i(19851),a=i(82950),o=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),h=i(23560),f=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:r}){return{level:i,msg:[e+" from "+(0,h.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,a.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(r,2)])]}}function g(){return s.default.totalmem()f.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(f.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*f.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,n.lazy)((()=>"ok"!==g().level),o.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:o.minuteMs,later:async()=>g()})))},31974:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.nodejsHealthCheck=void 0;const s=r(i(1708)),n=i(82950),a=i(45599),o=i(26033),l=i(63335),u=i(18454);t.nodejsHealthCheck=(0,a.defer)((()=>u.HealthCheck.for({section:"Tools",id:"nodejs-version",ordinal:4,pendingMsg:"Checking Node.js…",settings:[],links:[{text:"Read about PhotoStructure NodeJS support",icon:"docs",url:"https://photostructure.com/server/photostructure-for-node/#prerequisites"}],later:async()=>{const e="You're running Node.js "+(0,l.ver)(s.default.versions.node)+".\nPhotoStructure requires "+(0,n.tt)(o.RequiredNodeRange)+".";return(0,o.isSupportedNode)()?{level:"ok",msg:["Node.js is OK",e]}:{level:"warn",msg:["Node.js is not a supported version",e]}}})))},20752:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notInDMGHealthCheck=void 0;const r=i(45599),s=i(43899),n=i(43334),a=i(18454);t.notInDMGHealthCheck=(0,r.defer)((()=>n.isMac&&n.isElectron?a.HealthCheck.for({section:"System",id:"proc-not-in-dmg",pendingMsg:"Checking PhotoStructure installation directory…",settings:[],later:async()=>s.ProjectPath.isInDMG()?{level:"error",msg:"PhotoStructure cannot run directly from a DMG disk image. Please drag and drop the PhotoStructure icon onto your Applications folder to install.",checkboxLabel:"Open https://photostructure.com/getting-started/installation/ in your browser"}:{level:"ok",msg:"PhotoStructure isn't running directly from a DMG disk image"}}):void 0))},85200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osHealthCheck=void 0;const r=i(45599),s=i(96175),n=i(18454);t.osHealthCheck=(0,r.defer)((()=>n.HealthCheck.for({section:"System",id:"system-version",pendingMsg:"Checking operating system…",settings:[],links:[{text:"What do I need to run PhotoStructure?",icon:"docs",url:"https://forum.photostructure.com/t/what-do-i-need-to-run-photostructure/44"}],later:async()=>{const e=(0,s.whyOsNotSupported)();return null==e?{level:"ok",msg:["Operating system is OK","PhotoStructure supports "+(0,s.osFullName)()]}:{level:"warn",msg:["Operating system is not supported",(0,s.osFullName)()+" was detected, but only "+e+"."]}}})))},37301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.powershellHealthCheck=void 0;const r=i(42659),s=i(45599),n=i(98314),a=i(43334),o=i(24399),l=i(63335),u=i(18454);t.powershellHealthCheck=(0,s.defer)((()=>a.isWin?u.HealthCheck.for({section:"Tools",id:"tools-powershell",pendingMsg:"Checking PowerShell…",settings:["powerShellArgs"],ttlMs:r.minuteMs,links:[{text:"How to fix PowerShell issues",url:"https://photostructure.com/fix-pwsh/"}],later:async()=>{try{const e=await(0,o.checkPowerShell_)();return{level:"ok",msg:["PowerShell is OK",(0,l.ver)(e)],meta:{version:e}}}catch(e){return{level:"error",msg:"PowerShell failed: "+(0,n.errorToS)(e)}}}}):void 0))},65756:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(27180),a=i(98314),o=i(63335),l=i(18454);t.sqliteHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Tools",id:"tools-sqlite-version",ordinal:0,pendingMsg:"Checking SQLite…",settings:[],links:[{text:"Read about PhotoStructure SQLite support",url:"https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837",icon:"docs"}],async later(){try{const e=await n.sqliteVersion_.refresh();return null==e?{level:"error",msg:"SQLite version could not be found"}:{level:"ok",msg:["SQLite is OK",(0,r.li)(["embedded: "+(0,o.ver)(e.libraryVersion),(0,r.tt)(e.sqliteNativePath)+": "+(0,o.ver)(e.toolVersion)])]}}catch(e){return{level:"error",msg:"Something's amiss with SQLite: "+(0,a.errorToS)(e)}}}})))},15024:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.securityHealthCheck=void 0;const r=i(40958),s=i(82950),n=i(45599),a=i(31586),o=i(94174),l=i(77740),u=i(44198),c=i(59958),d=i(43334),h=i(18454);t.securityHealthCheck=(0,n.defer)((()=>{const e=d.isWin?"an administrator":"root";return h.HealthCheck.for({section:"System",id:"proc-not-superuser",pendingMsg:"Checking user permission level…",settings:[],later:async()=>{if("0"===(0,u.env)().PUID)return{level:"disabled",msg:`Admin health check is disabled (${(0,s.tt)("PUID=0")}).`};const t=(0,r.compact)([(0,a.gte0)((0,o.userid)())?"Current user id: "+(0,s.b)((0,s.tt)((0,o.userid)())):void 0,(0,a.gte0)((0,o.groupid)())?"Current group id: "+(0,s.b)((0,s.tt)((0,o.groupid)())):void 0,"Current user name: "+(0,s.b)((0,s.tt)(await(0,o.username)()??"(unknown)"))]);return!0===await(0,o.isRootUser)()||(0,l.getDevEnvFlag)(c.DevEnvFlags.PS_FAIL_SECURITY_HEALTH_CHECK)?{level:"warn",msg:["PhotoStructure should not be run as "+e,...t],links:[{text:"Read why PhotoStructure should not be run as "+e,url:"https://photostructure.com/server/photostructure-for-docker/#why-not-run-as-root"}]}:{msg:["PhotoStructure is not running as "+e,...t],level:"ok"}}})}))},3956:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsEnvHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(12168),a=i(28874),o=i(63225),l=i(18454);t.settingsEnvHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Library",id:"settings-env",pendingMsg:"Checking environment settings…",settings:[],links:[{text:"Read about PhotoStructure environment settings",url:"https://photostructure.com/faq/environment-variables/",icon:"docs"}],later:async()=>{const e=[];for(const t of(0,a.allSettings)())if(t.hasValue()&&null!=t._envValue()){const i=!0===t.opts.sensitive?"********":t.toEnvValue(t._envValue());null!=i&&e.push((0,r.tt)(t.key+"="+i))}const t=[(0,n.plur)(e.length,"environment setting"),(0,r.li)(e)],i=(0,o.verifyPsEnvSettings)();return i.length>0?{level:"warn",msg:["Some environment settings may be misconfigured:",(0,r.li)(i.map((e=>(0,r.tt)(e.envKey)+": "+e.msg))),"---",...t]}:{level:"ok",msg:t}}})))},29332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsLibraryHealthCheck=void 0;const r=i(45599),s=i(2858),n=i(18454),a=i(61274);t.settingsLibraryHealthCheck=(0,r.defer)((()=>n.HealthCheck.for({section:"Library",id:"settings-library",pendingMsg:"Checking library settings…",settings:["libraryDir"],links:[{text:"Read about PhotoStructure library settings",url:"https://photostructure.com/getting-started/advanced-settings/#library-settings",icon:"docs"}],later:()=>(0,a.validateSettingsToml)((0,s.librarySettingsFile)(),"library")})))},61274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsSystemHealthCheck=t.validateSettingsToml=void 0;const r=i(40958),s=i(82950),n=i(45599),a=i(12168),o=i(81168),l=i(98314),u=i(95696),c=i(2858),d=i(32707),h=i(18454);async function f(e,t){try{if(null==e)return{level:"disabled",msg:"No "+t+" settings is set."};if(await e.notExists())return{level:"disabled",msg:(0,o.capitalize)(t)+" settings file "+(0,s.tt)(e)+" does not exist."};const i=await(0,c.importFileSettings_)(e);return(0,r.isNotEmpty)(i.warnings)?{level:"warn",msg:(0,s.tt)(e)+": "+i.warnings.join(", ")}:{level:"ok",msg:[(0,a.plur)(i.settings.length,t+" setting override"),(0,s.b)("Source:"),(0,s.tt)(e),(0,s.b)("Settings:"),(0,s.li)(i.settings.map((e=>(0,s.tt)(e.key+"="+e.toEnvValue(e.value)))))]}}catch(t){return{level:"error",msg:"Failed to parse "+e+":\n"+(0,l.errorToS)(t)}}}t.validateSettingsToml=f,t.settingsSystemHealthCheck=(0,n.defer)((()=>h.HealthCheck.for({section:"Library",id:"settings-system",pendingMsg:"Checking system settings…",settings:[],links:[{text:"Read about PhotoStructure system settings",url:"https://photostructure.com/getting-started/advanced-settings/#system-settings",icon:"docs"}],later:()=>f(u.PosixFile.forMaybe((0,d.systemSettingsFile)()),"system")})))},38372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpHealthCheck=void 0;const r=i(45599),s=i(98314),n=i(21473),a=i(18454);t.sharpHealthCheck=(0,r.defer)((()=>a.HealthCheck.for({section:"Tools",id:"tools-sharp",ordinal:2,pendingMsg:"Checking Sharp…",settings:[],later:async()=>{try{return await(0,n.testSharp_)(),{level:"ok",msg:["Sharp is OK","Image processing is working as expected."]}}catch(e){return{level:"error",msg:["Something's amiss with Sharp",(0,s.errorToS)(e)]}}}})))},82638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const r=i(40958),s=i(42659),n=i(45599),a=i(41400),o=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),h=i(23560),f=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,n.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function v({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:r}){const s=new Map;for(const e of t??[])s.set(e.id,e);if(null!=e)for await(const t of f.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),r))s.set(t.id,t);return[...s.values()]}t.summarizeHealthChecks=async function(e){return b({...e,healthCheckResults:await v(e)})};const w=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:h.serviceName.prior()??process.title}})));function b(e){const t=(0,r.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),n=i.length,a=i.map((e=>e.id)),c=t.length-n,d=0===n,h=(0,r.uniq)((0,r.compactBlanks)(e.errors));if(h.length>0)return{...w(),level:l.HealthCheckLevels.error,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",h.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const s=t.filter((e=>e.level===i));if((0,r.isNotEmpty)(s)){const e=t.filter((e=>!s.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+s.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...w(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:a,pendingCount:n,settledCount:c,linkIds:s.map((e=>e.id)),ts:Date.now(),msg:(0,r.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,o.flatten)([...s,...e].map((e=>e.msg[0])))])},meta:{checks:s.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...w(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,s.fmtDateShort)(Date.now())]}})}(0,a.later)((()=>{m.Settings.libraryDir.watchLater((()=>w.unset()))})),t.summarizeHealthChecksSync=b},49913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemLoadHealthCheck=void 0;const r=i(82950),s=i(42659),n=i(45599),a=i(31586),o=i(28874),l=i(14854),u=i(18454);t.systemLoadHealthCheck=(0,n.defer)((()=>u.HealthCheck.for({section:"System",id:"system-load",pendingMsg:"Checking system load…",settings:["cpuBusyPercent"],ttlMs:s.minuteMs,later:async()=>{if(o.Settings.cpuBusyPercent.valueOrDefault<=0)return{level:"ok",msg:["CPU utilization is not monitored",(0,r.tt)(o.Settings.cpuBusyPercent.key)+" is set to <= 0"]};const e=l.CpuUsage.instance().busyPct(),i=(0,l.isTooBusy)();return(0,t.systemLoadHealthCheck)().setTTL((i?6:60)*s.secondMs),{level:i?"stop-sync":"ok",msg:"CPU utilization is "+(0,a.fmtPct)(e)+"\n"+(i?"PhotoStructure sync is paused until CPU utilization drops below":"PhotoStructure sync will pause if CPU utilization exceeds")+" "+(0,r.tt)(o.Settings.cpuBusyPercent.key)+": "+(0,a.fmtPct)(o.Settings.cpuBusyPercent.valueOrDefault)}}})))},84728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionHealthCheck=void 0;const r=i(42659),s=i(45599),n=i(40044),a=i(18454);t.versionHealthCheck=(0,s.defer)((()=>a.HealthCheck.for({section:"System",id:"ps-version",pendingMsg:"Checking PhotoStructure version…",settings:["autoUpdateCheck","configDir","libraryDir","optOut"],ttlMs:r.hourMs,links:[{text:"Change auto-update setting",icon:"settings",url:"/settings#update-check-section"},{text:"What's new?",icon:"docs",url:"https://photostructure.com/whats-new/"},{text:"Update checking & privacy",icon:"docs",url:"https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956"}],later:n.checkVersion_})))},7245:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.videoHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(41400),a=i(55835),o=i(34102),l=i(66106),u=i(45969),c=i(63335),d=i(18454);t.videoHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-video",pendingMsg:"Checking video tooling…",settings:["ffmpegPath"],links:[{text:"Read how to set up video support with PhotoStructure",url:"https://photostructure.com/getting-started/video-support/",icon:"docs"}],warnLinks:(0,u.isDocker)()?[]:[{text:"Re-check for video tooling",icon:"refresh",method:"POST",type:"button",url:"/admin/recheck-tools"}],later:async()=>{const e=await(0,l.getVideoToolDetails_)();return null!=e&&!1!==e.isSupportedVersion?{level:"ok",msg:["Videos will be imported",(0,a.map)(e.version,c.ver),(0,a.map)(e.path,r.tt)]}:{level:"warn",msg:["Videos will not be imported","No video tooling was found."]}}}))),(0,n.later)((()=>{(0,o.ee)().on("clearToolCache",(()=>t.videoHealthCheck.prior()?.reset()))}))},16264:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeHealthCheck=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(13538),l=i(83104),u=i(12168),c=i(48884),d=i(45255),h=i(43334),f=i(69108),m=i(48165),p=i(63870),g=i(7014),y=i(18454);t.volumeHealthCheck=(0,a.defer)((()=>y.HealthCheck.for({section:"System",id:"system-volumes",ordinal:0,pendingMsg:"Checking volumes…",settings:[],links:[{text:"What's a “volume”?",url:"https://photostructure.com/faq/what-is-a-volume/",icon:"docs"}],warnLinks:h.isWin?[{text:"Check this page for troubleshooting tips",url:"https://photostructure.com/faq/windows-troubleshooting/#unhealthy-network-shares"}]:void 0,later:async()=>{const e=Date.now(),i=await(0,o.thenOrTimeout)((0,g.volumes)(),(0,p.commandTimeoutMs)());if(i===l.Timeout){const i=await(0,o.thenOrTimeout)(h.isWin?(0,m.getLocalVolumesWin_)():(0,f.dfPosixRawLocal_)(),d.ShortCommandTimeoutMs);return(0,t.volumeHealthCheck)().logger.warn("volumes() timed out, retrying in 5m"),setTimeout((()=>(0,t.volumeHealthCheck)().refresh()),5*n.minuteMs),{level:"warn",msg:[i===l.Timeout?"Something seems wrong with your computer's volumes":"Something seems wrong with one or more remote filesystem mounts","Gathering volume metadata took longer than "+(0,n.fmtAgo)(e,"")+"."]}}const a=i.filter((e=>!1===e.ok));if((0,r.isNotEmpty)(a))return{level:"warn",msg:["One or more volumes are not healthy","Check the following:",(0,s.li)(a.map((e=>(0,s.tt)(e.mountpoint))))]};const[y,v]=(0,c.partition)(i,(e=>!0===e.remote)),w=["Storage volumes are OK"];return(0,r.isNotEmpty)(v)&&w.push((0,s.b)((0,u.plur)(v.length,"local volume")+":"),(0,s.li)(...v.map((e=>(0,s.tt)(e.mountpoint))))),(0,r.isNotEmpty)(y)&&w.push((0,s.b)((0,u.plur)(y.length,"remote volume")+":"),(0,s.li)(...y.map((e=>(0,s.tt)(e.mountpoint))))),{level:"ok",msg:w}}})))},95242:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviewBuilder=t.mkPreviewAssetFile_=void 0;const a=i(57975),o=i(40958),l=i(22573),u=i(33374),c=i(98553),d=i(55835),h=i(68708),f=i(48884),m=i(50213),p=i(92434),g=i(54296),y=i(51837),v=i(57159),w=i(83278),b=i(95696),S=i(62105),P=i(84258),_=i(38156),T=i(69589),M=i(28874),E=i(47783),k=i(29990),D=i(16047),x=i(42725),C=i(4192),F=i(32876),A=i(50961),I=i(181);t.mkPreviewAssetFile_=async function(e){const t=await(0,E.readTags)(e);return{nativePath:e.nativePath,fileSize:await e.size(),mtime:await e.thisOrSidecareMaxMtimeMs(),uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath,mimetype:t.mimetype,rotation:t.rotation,...t.dimensions,sha:await e.sha_()}};class O{constructor(e,t,i){r.add(this),this.ap=e,this.assetFiles=t,this.logger=(0,m.mkLogger)("AssetPreviewBuilder("+e.assetId+")"),this.ctx=(0,T.forceContextOrSetting)(i),this.assetFiles=(0,p.sortAssetFiles)(this.assetFiles)}[(r=new WeakSet,a.inspect.custom)](){return{ctor:"AssetPreviewBuilder",assetId:this.ap.assetId,assetFiles:this.assetFiles}}async build_(){this.logger.info("build_(): asset file candidates:",this.assetFiles.map((e=>(0,h.pick)(e,"id","uri"))));const e=[];for(const t of this.assetFiles){const i=b.PosixFile.forMaybe(await(0,g.getAssetFileNativePath)(t));if(null!=i){{const e=await(0,S.whyRejectFile)(i);(0,l.blank)(e)||this.logger.info("skipping: rejected",{pf:i,whyRejected:e})}try{return await n(this,r,"m",s).call(this,i,t)}catch(i){e.push(i),this.logger.warn("Failed to set shown file to ",{best:t,error:i})}finally{this.ap.parent.clear()}}else this.logger.info("skipping: failed to get PosixFile",{af:t}),e.push(new Error("Cannot get path from URI "+(0,c.stringify)((0,h.pick)(t,"uri","mountpoint","nativePath"))))}return this.logger.throw("Cannot build previews: none of the files are valid",{doNotSend:!0,retriable:!1,files:this.assetFiles.map((e=>e.nativePath??e.uri)),causes:e})}async infoForBest_(e,t){await(0,I.throwIfInvalidFile_)(e);const i=await e.size(),r=await e.thisOrSidecareMaxMtimeMs();if(this.logger.debug("_build",{filesize:i,mtime:r,best:t.uri}),null==i||null==r)return this.logger.throw("build(): missing stat info for best file",{ignorable:!0,best:t});const{uri:s,width:n,height:a,sha:l,mimetype:u}=t;if(null==s||null==n||null==a||null==u||null==l)return this.logger.throw("build(): internal error: missing fields for best file "+e,{ignorable:!0,best:t});const c=(0,k.fitSizes)(t,t.mimetype);return{assetId:t.assetId,assetFileId:t.id,uri:s,uris:this.assetFiles.map((e=>e.uri)),path:e.nativePath,mtime:r,filesize:i,width:n,height:a,sha:l,mimetype:u,fitSizes:c.map((([,e])=>e.name)).join(","),sqWidths:(0,o.compact)(x.ImageSize.sq().map((e=>e.outputSize(t)?.width))),fitWidths:c.map((([e])=>e.width))}}async priorIfValid_(e,t){if(this.ctx.forceSync||this.ctx.forceRebuildPreviews)return;const i=await this.ap.readInfo.refresh();if(null!=i){if(i.assetId!==t.assetId)throw new y.InternalError("priorIfValid_(): mismatched asset IDs for "+e+": "+(0,c.stringify)({priorInfo:i,info:t}));const r=i.fitSizes.split(","),s=t.fitSizes.split(",");if(null!=i.sha&&i.sha===t.sha&&i.rotation===t.rotation&&(0,k.equivalentFitSizes)(r,s)){const n=(0,k.fitSizes)(e,e.mimetype),a=(0,o.diff)(r,s);if((0,o.isNotEmpty)(a)){this.logger.info("priorIfValid_(): removing previews that aren't required anymore.",{leftovers:a});for(const e of a){const t=n.find((([,t])=>t.name===e));if(null==t)this.logger.warn("priorIfValid_(): Failed to clean up: missing fit size",{fitsize:t,fits:n});else{const e=this.ap.fileForWidth(t[1].reducer.name,t[0].width);this.logger.debug("priorIfValid_(): unlinking unwanted preview "+e,{fitsize:t}),await e.unlink("warn")}}}return this.logger.debug("priorIfValid_(): SHA and rotation match, and previews exist.",{info:t,priorInfo:i}),await this.ap.writeInfo(t),t}}}}t.AssetPreviewBuilder=O,s=async function(e,t){this.logger.info("_build("+e+")",{uri:t.uri});const i=await this.infoForBest_(e,t),r=await this.priorIfValid_(t,i);if(null!=r)return r;const s=new _.PushProgressObserver({path:e.nativePath,op:"Building previews"},x.ImageSize.sq().length+x.ImageSize.fit().length);if(this.logger.debug("Rebuilding all previews from "+t.uri,{assetId:t.assetId,info:i}),null==await this.ap.parent.mkdirp())throw new Error("build(): Failed to create previews directory, "+this.ap.parent+" for "+t);const n=await this.ap.existingFiles(),a=await(0,A.sharpReadable_)({src:e,minDim:x.ImageSize.largestFit().max});if(null==a)throw new v.WrappedError("AssetPreviewBuilder.build(): "+t.uri+", "+e.nativePath+", is not readable by sharp.",{retriable:!1});const o=(0,A.toSharp)(a);if(t.mimetype.startsWith("image/")&&!(0,D.isHeifMimeType)(t.mimetype)&&null!=t.rotation&&0!==t.rotation&&(o.rotate(t.rotation),this.logger.debug("build(): rotating "+t.rotation+"°")),(0,w.isBaseFile)(a)&&a.desc.toLowerCase().includes("thumbnail"))try{o.trim(1)}catch{}const l=(0,k.fitSizes)(t,t.mimetype),c=[],m=[];let p,g;const y=x.ImageSize.largestSq(),b=(0,f.leastBy)(l,(([e,t])=>(0,d.map)(y.outputSize(e),(()=>t.megapixels()))))?.[1].name,S=(0,h.pick)(t,"width","height");{let e=o.clone(),t=S;for(const[i,r]of l){const n=Date.now(),a=t,o=this.ap.fileForWidth(r.reducer.name,i.width).wip();e=r.resize(i,e),t=i,r.name===b&&(g=e.clone(),p=i),(0,u.dmegapixels)(i)>=1&&r.reducer===F.Fit&&M.Settings.includePreviewTags.valueOrDefault&&m.push(o),await r.toJpeg({path:o.nativePath,sh:e,outputSize:i}),s.onProgress(),this.logger.debug("resize("+r.name+") "+(0,u.fmtDim)(a)+" -> "+(0,u.fmtDim)(i)+" in "+(Date.now()-n)+" ms"),c.push(o)}}{null==g?(this.logger.debug("square resize(): resorting to ",{origDim:S,bestFitNameForSq:b}),g=o,p=S):this.logger.debug("square resize(): using to ",{sqDim:p,bestFitNameForSq:b});let e=!1;for(const t of x.ImageSize.sq()){const i=Date.now(),r=p,n=t.outputSize(p??S);if(null==n){this.logger.debug("skipping square output for "+t.max);continue}e||(n.position=M.Settings.squareThumbStrategy.valueOrDefault,e=!0),this.logger.debug("Applying ",{outputSize:n});const a=this.ap.fileForWidth(t.reducer.name,n.width).wip();t.resize(n,g),p=n,await t.toJpeg({path:a.nativePath,sh:g,outputSize:n}),s.onProgress(),c.push(a),this.logger.debug("resize("+t.name+") "+(0,u.fmtDim)(r)+" -> "+(0,u.fmtDim)(n)+" in "+(Date.now()-i)+" ms")}}try{await(0,C.includePreviewTags_)(e,m).catch((t=>{this.logger.warn("Failed to restore metadata tags into previews for "+e,{error:t})}));const t=new Set(n.map((e=>e.nativePath)));for(const e of c){const i=await e.unwip_();t.delete(i.nativePath)}await(0,P.unlink)(t),await this.ap.writeInfo(i),this.logger.debug("Previews unwipped and info written",{info:i})}catch(t){throw await(0,P.unlink)(c),new v.WrappedError("Failed to create previews from "+e,{cause:t,path:e.nativePath,fatal:!1})}return i}},35721:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkDownloadableTitle=t.previewToDownloadable=t.extractPreviewInfo=void 0;const r=i(75761),s=i(33374),n=i(11371),a=i(55835),o=i(31586),l=i(56519),u=i(29882),c=i(50213),d=i(97352),h=i(81168),f=i(89782),m=(0,c.mkLogger)("extractPreviewInfo");function p(e,t,i,r){return`Download ${t} ${e.ext} ${i} (${(0,s.fmtDim)(r)})`}t.extractPreviewInfo=function(e,t){const i=t.posixPathFrom(e).replace(/\//g,"").split("-"),r=(0,o.toInt)(i[0]),s=n.ReducerNames.getCI(i[1]),a=(0,d.extractInt)(i[2]);return(0,o.gt0)(r)?{file:t,assetId:r,reducer:s,width:a}:void m.warn("Failed to extract preview info",{file:t,previewsRoot:e,arr:i,assetId:r,reducer:s,width:a})},t.previewToDownloadable=async function(e,t){return(0,a.map2)(t.assetId,t.width,((i,a)=>(0,l.thenMap)((0,f.dimensions)(t.file),(o=>{const l=(0,s.dimToSize)(o);return{size:l,basename:`${(0,h.stripSuffix)(e,(0,u.extname)(e))}-${l}${t.file.ext}`,title:p(t.file,l,"image",o),description:`Download ${l}`,details:`(${(0,s.fmtDim)(o)} ${t.file.ext})`,href:(0,r.assetImgLink)({assetId:i,reducer:n.ReducerNames.fit,width:a})}}))))},t.mkDownloadableTitle=p},16524:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviews=void 0;const a=i(19851),o=i(40958),l=i(75761),u=i(11371),c=i(68708),d=i(39926),h=i(58939),f=i(48884),m=i(50213),p=i(81168),g=i(56519),y=i(38835),v=i(70417),w=i(35721);t.AssetPreviews=class{constructor(e,t){r.add(this),this.previewsRoot=e,this.readInfo=(0,a.lazy)((()=>this.infoJson().readJson("debug"))),this.logger=(0,m.mkLogger)("AssetPreviews(assetId:"+(0,h.id2id)(t)+")"),this.assetId=(0,h.id2id)(t);const i=(0,d.leftPad)(this.assetId,8,"0"),s=(0,p.splitEvery)(i,3);this.basename=s.pop()+"-",this.parent=e.join(...s)}parentNotExists(){return this.parent.clear().notExists()}async existingFiles(){return await this.parent.clear().childFiles((e=>e.base.startsWith(this.basename)))??[]}async existingJpgs(){return(await this.existingFiles()).filter((e=>".jpg"===e.ext))}async previewInfos(){return(0,g.sortByAsync)({name:"img.AssetPreviews.previews",arr:n(this,r,"m",s).call(this),f:e=>e?.file.size()})}async deleteAll(){const e=await this.existingFiles();if(e.length>20)throw new Error("deleteAll(): rejected: > 20 existing files?!"+y.InternalErrorFlag);for(const t of e)await t.unlink();return e}fileForSuffix(e){return this.parent.join(this.basename+e)}mp4(){return this.fileForSuffix("video.mp4")}infoJson(){return this.fileForSuffix("info.json")}writeInfo(e){return this.readInfo.unset(),this.infoJson().writeJson((0,c.pick)(e,"assetId","assetFileId","uri","uris","path","mimetype","width","height","mtime","filesize","sha","rotation","fitSizes","fitWidths"))}fileForWidth(e,t){return this.fileForSuffix(e+"-w"+t+".jpg")}async filesForReducer(e){const t=this.basename+e+"-";return this.logger.tap({msg:"filesForReducer("+e+")",result:(await this.existingFiles()).filter((e=>e.base.startsWith(t)))})}async smallestFileForReducer(e){return(0,f.leastBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async largestFileForReducer(e){return(0,f.greatestBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async widths(e){const t=await this.readInfo(),i=e===u.ReducerNames.sq?"sqWidths":"fitWidths",r=t?.[i];if(!(0,o.isEmpty)(r))return r;const s=(0,o.compact)((await this.previewInfos()).filter((t=>t.reducer===e)).map((e=>e.width)));return null!=t&&(t[i]=s,await this.writeInfo(t)),s}async posterLink(){const e=await this.widths(u.ReducerNames.fit);return(0,l.assetImgLink)({assetId:this.assetId,reducer:u.ReducerNames.fit,width:(0,v.max)(e)})}async imgAttrs(e,t=!1,i=!0){if(t||e!==u.ReducerNames.sq){const t=e===u.ReducerNames.fit?await this.readInfo():void 0;return(0,l.assetImgAttrs)({assetId:this.assetId,reducer:e,widths:await this.widths(e),lazyLoad:i,af:t})}return(0,l.assetSqImgAttrs)({assetId:this.assetId,lazyLoad:i})}},r=new WeakSet,s=async function(){const e=[];for(const t of await this.existingFiles()){const i=(0,w.extractPreviewInfo)(this.previewsRoot,t);null!=i&&e.push(i)}return e}},52086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},33106:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.dctPixels=t.dctHashCIELAB=t.dctHash=void 0;const s=r(i(9288)),n=i(96249),a=i(85810),o=32,l=function(e){const t=new Array(32);for(let e=1;e<32;e++)t[e]=1;return t[0]=1/Math.sqrt(2),t}(),u=function(e){const t=new Array(32);for(let e=0;e<32;e++){t[e]=new Array(32);for(let i=0;i<32;i++)t[e][i]=Math.cos((2*e+1)/64*i*Math.PI)}return t}();function c(e){const t=new Array(o);for(let i=0;is?1:0);return n}t.dctHash=async function(e){return c(await e.greyscale().resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer())},t.dctHashCIELAB=async function(e){const t=await e.resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer(),i=(0,a.rgb2labArray)(t);return(0,n.flatten)(i.map(c))},t.dctPixels=c},86580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(21605),o=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,n.gt0)(e.width)&&(0,n.gt0)(e.height)?(0,n.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,s.dmegapixels)(e.dimensions):(0,n.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,n.lt)(e.width,t.width)&&(0,n.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,n.lte)(e?.width,t?.width)&&(0,n.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,n.lt)(e.width,t.width)||(0,n.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,r.compact)((0,o.toS)(e).split(/[x×]/).map((e=>(0,n.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,r=Math.round(Math.sqrt(t*i));return{width:r,height:Math.round(r/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const r=u(e,i);return null==r?[]:a.Rotations.filter((e=>u(c(t,e),i)===r))}},89782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(56519),o=i(1078),l=i(5733),u=(0,r.lazy)((()=>(0,n.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,s.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,a.thenMap)((0,o.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},29990:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.equivalentFitSizes=t.fitSizes=void 0;const r=i(40958),s=i(33374),n=i(16170),a=i(42725),o=[a.ImageSize.QVGA,a.ImageSize.QQVGA];function l(e){return"qhd"===e?"wvga":"uhd"===e?"uhd4k":e}t.fitSizes=function(e,t){const i=a.ImageSize.fit(),r=[];let l=(0,n.isMimeTypeSupportedByBrowser)(t)?e:void 0;for(let t=0;t3||(0,s.dmegapixels)(a)-(0,s.dmegapixels)(l)>2.5)&&(l=a,r.push([a,n])))}return r},t.equivalentFitSizes=function(e,t){return(0,r.includesAll)((0,r.compactBlanks)(e).map(l),(0,r.compactBlanks)(t).map(l))}},277:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const r=i(22573),s=i(41400),n=i(54993),a=i(19851),o=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),h=i(78330),f=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),v=(0,a.lazy)((()=>(0,o.mkLogger)("img.Heif")));function w(e){return(0,n.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function b(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,a.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,r.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){v().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,r.blank)(e))return void v().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=w(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,r.blank)(i)&&(0,l.hasApt)()){const t=await(0,h.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,r.blank)(i)&&(0,f.hasPacman)()&&(i=(await(0,f.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,r.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void v().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=w,t.isHeifSupported=b,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await b()?(0,g.heif2png_)(e):void v().throw("HEIF support is missing",{src:e.nativePath})},(0,s.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(41400),o=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),h=i(28874),f=i(89782),m=i(13940),p=(0,r.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,s.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,r.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:h.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?n.minuteMs:void 0),e})),(0,a.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,f.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(h.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:h.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(o.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const r=i(22573),s=i(54993),n=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,r.blank)(e)&&n.test((0,s.toS)(e))}},13940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),s=i(19851),n=i(42659),a=i(59455),o=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),v=i(55222),w=i(63870),b=(0,s.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,s.lazy)((()=>(S(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const S=(0,s.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const s=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const n=s.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await n.mkdirp_(),await n.utimes();const a=n.join(i+r);return b().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:a}),a}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,a.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+v.TokenRadix.randomChars(2),v.TokenRadix.randomChars(16)+(0,o.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*n.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const s=await P(e,t,i);return await s.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,w.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),s}catch(r){return b().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},48368:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashDim=t.toImageHash=t.isImageHash=t._imageHash_=t.imageHash_=t.imageHash=t.maxPerBits=void 0;const s=r(i(9288)),n=i(19851),a=i(40958),o=i(22573),l=i(42659),u=i(33374),c=i(56038),d=i(85810),h=i(76490),f=i(40401),m=i(86758),p=i(85434),g=i(96706),y=i(38835),v=i(88561),w=i(95696),b=i(17217),S=i(50213),P=i(23624),_=i(28874),T=i(12089),M=i(16170),E=i(1078),k=i(33106),D=i(86580),x=i(78011),C=i(50961);t.maxPerBits=function(e){return Math.floor(52/e)};const F=(0,n.lazy)((()=>(0,S.mkLogger)("img.ImageHash")));t.imageHash=async function(e){try{return await(0,t.imageHash_)((0,b.toNativePath_)(e))}catch(t){return void F().warn("imageHash() failed for "+e,t)}};const A=(0,n.lazy)((()=>new v.FileCache({name:"img.imageHash",timeoutMs:l.minuteMs})));async function I(e){const t=w.PosixFile.for(e),i=await(0,E.extractSizeInfoFromFile)(t);if(null==i)throw new Error("Failed to read dimensions for "+e+y.NonFatalErrorFlag+y.DoNotSendErrorFlag);const r=(0,D.fitToResolution)(i.dimensions,Math.round(_.Settings.dominantColorPixels.valueOrDefault)),n=await(0,C.sharpReadable_)({src:t,minDim:r});return(0,c.time)("img.imageHash",(()=>async function({file:e,readable:t,sizeInfo:i}){const r=(0,S.mkLogger)("ImageHash("+e+")");if(null==t)return r.throw("Cannot build readable stream");const n=(0,D.fitToResolution)(i.dimensions,_.Settings.dominantColorPixels.valueOrDefault);if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-orig.jpg";await(0,C.toSharp)(t).jpeg().toFile(i),console.log({out:i,readable:t})}let a=(0,C.toSharp)(t).removeAlpha();(0,M.isVideoMimeType)(t.mimetype)||(a=a.rotate(i.rotation)),(0,u.dmegapixels)(i.dimensions)<.1&&(a=a.trim({background:"#000",threshold:0})),a=a.resize({fit:s.default.fit.outside,...n,withoutEnlargement:!0});const{data:o,info:l}=await a.raw().toBuffer({resolveWithObject:!0});if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-"+l.width+"w.jpg";await(0,s.default)(o,{raw:{...l,channels:3}}).jpeg().toFile(i),console.log({out:i,rgbInfo:l,readable:t})}const c=(0,d.rgb2labTriplets)(o),h=(0,f.extractDominantColors)(c),p=(0,m.labsAreGreyscale)(c),y=()=>(0,s.default)(o,{raw:{...l,channels:3}}),v=await(p?x.meanDiffHash:x.meanDiffHashCIELAB)(y()),w=await(p?k.dctHash:k.dctHashCIELAB)(y());return{meanHash:(0,P.b64encodeBits)(v.meanHash),diffHash:(0,P.b64encodeBits)(v.diffHash),dctHash:(0,P.b64encodeBits)(w),dominantColors:h.dominantColors,dominantColorsDescription:h.description,dominantColorScore:h.dominantColorScore,isGreyscale:p,mimetype:(0,M.normalizeMimetype)(t.mimetype),...i.dimensions,rotation:i.rotation??0}}({file:t,readable:n,sizeInfo:i})))}function O(e){return null!=e&&(0,o.notBlank)(e.meanHash)&&(0,o.notBlank)(e.mimetype)&&(0,a.isNotEmpty)(e.dominantColors)}t.imageHash_=(0,T.shim1)({name:"img.imageHash",cache:A,impl:I}),t._imageHash_=I,t.isImageHash=O,t.toImageHash=function(e){if(null!=e){if(O(e))return e;if((0,p.isModeData)(e)){const t={...(0,p.omitModeData)(e),dominantColors:h.DominantColor.fromModeData(e)};if(O(t))return t}}},t.HashDim=8},80361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageHashSimilarity=t.isVerySimilarComparison=t.isVerySimilarImageHash=t.isSimilarImageHash=t.isVerySimilarImage=t.compareImageHashes=t.isSimilarImage=t.hammRatio=t.meanHashVariants=t.isGreyscaleMeanHash=t.labsCorr2=t.isImageHashComparison=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(38639),o=i(33374),l=i(57924),u=i(55835),c=i(31586),d=i(68708),h=i(39926),f=i(21605),m=i(48884),p=i(50213),g=i(97352),y=i(85810),v=i(3048),w=i(32848),b=i(82647),S=i(38812),P=i(70417),_=i(23624),T=i(28874),M=i(86580),E=i(48368),k=i(2090),D=(0,r.lazy)((()=>(0,p.mkLogger)("img.ImageHashComparison")));t.isImageHashComparison=function(e){return null!=e&&(0,E.isImageHash)(e.a)&&(0,E.isImageHash)(e.b)&&[e.imageCorr,e.colorCorr,e.aRotation].every(c.isNumber)},t.labsCorr2=function(e,t){const i=(0,s.sum)(e,(e=>(0,v.diffCIECorr)(e,(0,y.closestLab)(t,e))))+(0,s.sum)(t,(t=>(0,v.diffCIECorr)(t,(0,y.closestLab)(e,t)))),r=Math.max(e.length,t.length,i);return(r-i)/r};const x=/A{20}=?$/;function C(e){return null!=e&&((0,g.within)(7,12,e.length)||null!=e?.match(x))}function F(e,t,i=E.HashDim){const r=(0,_.b64decode)(e).toString(2).split("").map((e=>"1"===e?1:0)),s=i*i;for(;r.length%s!=0;)r.unshift(0);return r.length===s||t?r.slice(0,s):r.slice(0,s).map(((e,t)=>4*e+2*r[t+s]+r[t+2*s]))}function A({a:e,b:t,greyscale:i,dim:r=E.HashDim,rotationsToCheck:a}){if((0,n.blank)(e)||(0,n.blank)(t))return{hammRatio:0,bRotation:0};if(e===t)return{hammRatio:1,bRotation:0};const o=F(e,i,r),l=F(t,i,r);(0,s.isEmpty)(a)&&(a=[0]);const u=a.map((e=>({bRotation:e,hammRatio:(0,c.sigFigs)((0,g.hammRatioIntArrays)(o,(0,S.rotateSquareMatrix)(l,e),i?1:3),2)})));D().debug("hammRatio()",{results:u,rotationsToCheck:a});const d=(0,m.greatestBy)(u,(e=>[(0,c.sigFigs)(e.hammRatio,1),-f.Rotations.indexOf(e.bRotation)]));return{bRotation:d.bRotation,hammRatio:(0,c.sigFigs)(d.hammRatio,2)}}async function I(e,t,i="debug",r={}){return D().tap({msg:`isSimilarImage(${e},${t})`,level:i,result:L(await(0,E.imageHash)(e),await(0,E.imageHash)(t),r)})}function O(e,t,i={}){const r=(0,E.toImageHash)(e),s=(0,E.toImageHash)(t);if(null==r||null==s)return;const n=(0,a.isTrue)(i.capturedAtIsFuzzy),h=!(0,a.isTrue)(i.forceColor)&&((0,a.isTrue)(i.forceGreyscale)||(r.isGreyscale??C(r.meanHash))||(s.isGreyscale??C(s.meanHash))),f=A({a:r.meanHash,b:s.meanHash,greyscale:h,rotationsToCheck:i.rotationsToCheck??(0,M.validRotations)(r,s)}),m=A({a:r.diffHash,b:s.diffHash,greyscale:h,rotationsToCheck:[]}),p=A({a:r.dctHash,b:s.dctHash,greyscale:h,rotationsToCheck:[]}),g=(0,w.dominantColorCorrelation)(r.dominantColors,s.dominantColors);if(null==g)return void D().debug("imageHashCompare(): missing color correlation");const y=r.mimetype===s.mimetype,v=(0,M.aspectRatio)(r),S=(0,M.aspectRatio)((0,o.maybeDimSwap)(s,f.bRotation)),P=null!=v&&null!=S&&!(0,o.isCloseAspectRatio)(v,S);let _=0,x=0;n&&(x+=T.Settings.imageHashFuzzyDateDelta.valueOrDefault,_+=T.Settings.imageHashFuzzyDateDelta.valueOrDefault),y||(x+=T.Settings.imageHashDifferentMimetypesDelta.valueOrDefault,_+=T.Settings.imageHashDifferentMimetypesDelta.valueOrDefault),h&&(_+=T.Settings.imageHashGreyscaleDelta.valueOrDefault,x+=T.Settings.imageHashGreyscaleDelta.valueOrDefault);const F=R((_+(i.minImageCorr??T.Settings.minImageCoeffPct.valueOrDefault))/100),I=R((x+(i.minColorCorr??T.Settings.minColorCoeffPct.valueOrDefault))/100),O=[];P&&O.push(`aspect ratio mismatch (${(0,k.fmtAspectRatio)(v)} vs ${(0,k.fmtAspectRatio)(S)})`);const L=[],N=new b.Average;N.push(f.hammRatio),f.hammRatioN.push(e))),(0,u.map)(p?.hammRatio,(e=>N.push(e))),(0,c.lt)(m?.hammRatio,F)&&L.push("gradient"),(0,c.lt)(p?.hammRatio,F)&&L.push("DCT")),L.length>0&&O.push("different image content ("+(0,l.andList)(L)+")");const j=g>=I,z=j&&N.avg>=F;j||O.push("different dominant colors");const V={meanHashCorr:(0,c.sigFigs)(f.hammRatio,2),diffHashCorr:B?void 0:(0,u.map)(m,(e=>(0,c.sigFigs)(e.hammRatio,2))),dctHashCorr:B?void 0:(0,u.map)(p,(e=>(0,c.sigFigs)(e.hammRatio,2))),hashCorrAvg:N.avg,minImageCorr:F,imageCoeffDelta:_,colorCorr:(0,c.sigFigs)(g,2),minColorCorr:I,colorCoeffDelta:x,isGreyscale:h,bRotation:f.bRotation,aAspectRatio:v,bAspectRatio:S,isSimilar:z,whyNotSimilar:z?void 0:(0,l.andList)(O)};return D().info("compareImageHashes",{a:(0,d.pickCompact)(r,"uri","id","assetId"),b:(0,d.pickCompact)(s,"uri","id","assetId"),...V}),{a:r,b:s,...V}}function L(e,t,i){return O(e,t,i)?.isSimilar??!1}function R(e){return(0,c.sigFigs)((0,c.clamp)(0,1,e),3)}function N(e){return null!=e&&(0,c.gte)(e.meanHashCorr,.9)&&(0,c.gte)(e.colorCorr,.9)}t.isGreyscaleMeanHash=C,t.meanHashVariants=function(e,t=!1,i=E.HashDim){const r=(t=t||null!=e.match(x))?(0,h.padding)("0",2*i*i):"",s=F(e,t,i);return f.Rotations.map((e=>(0,_.b64encode)(BigInt("0b0"+(0,S.rotateSquareMatrix)(s,e).map((e=>e.toString(2))).join("")+r))))},t.hammRatio=A,t.isSimilarImage=I,t.compareImageHashes=O,t.isVerySimilarImage=async function(e,t,i="debug",r={}){return I(e,t,i,{rotationsToCheck:[0],...r,minImageCorr:.92,minColorCorr:.92})},t.isSimilarImageHash=L,t.isVerySimilarImageHash=function(e,t,i={}){return N(O(e,t,i))},t.isVerySimilarComparison=N,t.imageHashSimilarity=function(e,t){return(0,u.map)(O(e,t),(e=>(0,P.avg)([e.meanHashCorr,e.colorCorr])))}},42725:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ImageSize=void 0;const a=i(57975),o=i(19851),l=i(33374),u=i(12168),c=i(48884),d=i(28874),h=i(32876),f=i(5733);class m{static sq(){return n(this,r,"f",s).filter((e=>e.reducer===h.Square))}static largestSq(){return(0,c.greatestBy)(this.sq(),(e=>e.megapixels()))}static fit(){const e=d.Settings.previewResolutions.valueOrDefault;return n(this,r,"f",s).filter((t=>t.reducer===h.Fit&&e.includes(t.name)))}static largestFit(){return(0,c.greatestBy)(this.fit(),(e=>e.megapixels()))}static all(){return[...n(this,r,"f",s)]}constructor(e,t,i,a,l=!0){this.name=e,this.maxWidth=t,this.maxHeight=i,this.reducer=a,this.rotational=l,this.megapixels=(0,o.lazy)((()=>(0,u.megapixels)(this.maxWidth*this.maxHeight))),this.max={width:t,height:i},n(r,r,"f",s).push(this)}[a.inspect.custom](){return{ctor:"ImageSize",name:this.name+" ("+this.reducer.name+")",maxDim:this.maxWidth+"×"+this.maxHeight,maxMP:this.megapixels()}}get aspectRatio(){return this.maxWidth/this.maxHeight}get maxPixels(){return this.maxWidth*this.maxHeight}get minDimension(){return Math.min(this.maxWidth,this.maxHeight)}outputSize(e){return this.reducer.reduce(this.rotational&&(0,l.isPortrait)(e)?(0,l.dimSwap)(this.max):this.max,e)}resize(e,t){return t.resize({...e,fit:this.reducer.fit,withoutEnlargement:!0})}toJpeg({path:e,sh:t,outputSize:i}){return((0,l.dmegapixels)(i)<2||d.Settings.previewSharpen.valueOrDefault)&&(t=t.sharpen()),t.jpeg((0,f.sharpRenderOptions)()).toFile(e)}toString(){return this.name}}t.ImageSize=m,r=m,s={value:[]},m.UHD8k=new r("uhd8k",7680,4320,h.Fit,!1),m.UHD5k=new r("uhd5k",5120,2880,h.Fit,!1),m.UHD=new r("uhd4k",4096,2160,h.Fit),m.QHD=new r("qhd",3120,1440,h.Fit),m.FHD=new r("fhd",1920,1080,h.Fit),m.HD=new r("hd",1280,720,h.Fit),m.WVGA=new r("wvga",720,480,h.Fit),m.QVGA=new r("qvga",320,240,h.Fit),m.QQVGA=new r("qqvga",160,120,h.Fit),m.S480=new r("s480",480,480,h.Square),m.S240=new r("s240",240,240,h.Square),m.S120=new r("s120",120,120,h.Square),m.S60=new r("s60",60,60,h.Square)},4192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includePreviewTags_=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(50213),o=i(56038),l=i(28874),u=i(47783),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.includePreviewTags")));t.includePreviewTags_=async function(e,t){!1===l.Settings.includePreviewTags.valueOrDefault||l.Settings.includedPreviewTags.isEmpty()||(0,s.isEmpty)(t)||(c().info("Re-adding metadata to previews..."),await(0,o.time)("img.includePreviewTags",(async()=>{const i=(0,n.pick)(await(0,u.readTags)(e),...l.Settings.includedPreviewTags.values),r=i?.capturedAt;null!=r&&(delete i.capturedAt,(0,n.assignFields)(i,r.asExifTag()));const s=i?.exposureSettings;null!=s&&(delete i.exposureSettings,i.FocalLength=s.focalLength,i.FNumber=s.aperture,i.ExposureTime=s.shutterSpeed,i.ISO=s.iso),l.Settings.includedPreviewTags.has("Source")&&(i.Source=e.nativePath),(0,n.isEmptyObj)(i)?c().warn("not adding tags to previews: no values for tags in source file",{src:e,includedPreviewTags:l.Settings.includedPreviewTags.values}):(c().info("Overwriting preview tags...",{src:e,writeTags:i}),await Promise.all(t.map((e=>(0,u.overwriteTags_)(e,i)))))})))}},66778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.matchAndWriteRotation_=t.matchRotation=void 0;const r=i(19851),s=i(68708),n=i(21605),a=i(50213),o=i(56038),l=i(47783),u=i(67083),c=i(95141),d=i(48368),h=i(80361),f=(0,r.lazy)((()=>(0,a.mkLogger)("img.MatchRotation")));async function m(e,t){return(0,o.time)("img.matchRotation",(async()=>{const i=await(0,d.imageHash)(e),r=await(0,d.imageHash)(t),s=(0,h.compareImageHashes)(i,r);if(null!=i&&null!=r&&null!=s)return f().tap({level:"info",msg:"matchRotation()",result:{rotation:s.bRotation,exemplarImageHash:i,destImageHash:r,imageHashComparison:s},meta:{src:e,dest:t}});f().warn("failed to compute image hashes",{a:e,b:t})}))}t.matchRotation=m,t.matchAndWriteRotation_=async function(e,t,i=0){const r=await m(e,t);if(null==r)return;const a=(0,n.normalizeRotation)(r.destImageHash.rotation+r.rotation+i);if(f().info("matchRotation() computed newRotation",{currentRotation:r.destImageHash.rotation,additionalRotation:i,rotationToMatch:r.rotation,newRotation:a}),null==a)return void f().warn("Can't compute final orientation",{newRotation:a,file:t.nativePath,r});const o=(0,c.rotationToWriteTag)(a);if((0,s.isEmptyObj)(o))return void f().warn("rotationToWriteTag() returned null",{newRotation:a,mimetype:r.destImageHash.mimetype,file:t.nativePath});const d=await(0,u.ensureHistoryRecords)(await t.sidecar(),(0,u.mkHistoryRecords)(u.Actions.set,o));return await(0,l.writeTags_)(t,o),f().tap({level:"info",msg:"matchAndWriteRotation_()",result:{...r,writtenTags:o,rotation:a,historyRecords:d},meta:{exemplar:e,dest:t}})}},78011:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.meanDiffHashCIELAB=t.meanDiffHash=t.dhash=t.mhash=void 0;const s=r(i(9288)),n=i(96249),a=i(59455),o=i(85810),l=i(70417),u=i(48368);function c(e){const t=(0,l.avg)(e);return null==t?[]:(0,a.toA)(e).map((e=>e>=t?1:0))}function d(e){const t=(0,a.toA)(e),i=Math.round(Math.sqrt(t.length));return t.map(((t,r)=>t>=(0===r?e[i]:r%i==0?e[r-i]:e[r-1])?1:0))}t.mhash=c,t.dhash=d,t.meanDiffHash=async function(e,t=u.HashDim){const i=await e.greyscale().resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer();return{meanHash:c(i),diffHash:d(i)}},t.meanDiffHashCIELAB=async function(e,t=u.HashDim){const i=await e.resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer(),r=(0,o.rgb2labArray)(i);return{meanHash:(0,n.flatten)(r.map(c)),diffHash:(0,n.flatten)(r.map(d))}}},52121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._prepFileForBrowser=t.prepFileForBrowser=void 0;const r=i(19851),s=i(78923),n=i(95696),a=i(50213),o=i(28874),l=i(12089),u=i(16170),c=i(13940),d=i(4192),h=i(5733),f=i(50961),m=(0,r.lazy)((()=>(0,a.mkLogger)("img.PrepareFileForBrowser")));async function p(e){try{const t=n.PosixFile.for(e.nativePath);if(await t.notExists())return;const i=e.mimetype??(await(0,s.readFileType_)(t.nativePath))?.mime;return(0,u.isMimeTypeSupportedByBrowser)(i,e.userAgent)?t.nativePath:(m().info("prepFileForBrowser(): non-browser-supported mimetype",{file:t,info:e}),(await(0,c.withImageCache_)(t,"web",".jpg",(async e=>{const i=await(0,f.sharpReadable_)({src:t});if(null==i)throw new Error("prepFileForBrowser(): can't read "+t.nativePath);await(0,f.toSharp)(i).jpeg((0,h.sharpRenderOptions)()).toFile(e.nativePath),o.Settings.includePreviewTags.valueOrDefault&&await(0,d.includePreviewTags_)(t,[e])})))?.nativePath)}catch(e){return void m().warn("prepFileForBrowser() failed",{error:e})}}t.prepFileForBrowser=(0,l.shim1)({name:"img.prepFileForBrowser",impl:p}),t._prepFileForBrowser=p},48604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildAssetPreviews_=t.Previews=void 0;const r=i(19851),s=i(55835),n=i(50213),a=i(12089),o=i(87290),l=i(95242),u=i(16524);class c{constructor(e){this.root=e}apb(e,t,i){return new l.AssetPreviewBuilder(this.ap(e),t,i)}ap(e){return new u.AssetPreviews(this.root,e)}}t.Previews=c,c.instance=(0,r.lazy)((()=>((0,n.mkLogger)("Previews").info(".instance()",{libraryPreviewsDir:(0,o.libraryPreviewsDirPosixFile)()}),(0,s.map)((0,o.libraryPreviewsDirPosixFile)(),(e=>new c(e)))))),t.buildAssetPreviews_=(0,a.shim1)({name:"img.buildAssetPreviews",impl:e=>c.instance().apb(e.assetId,e.assetFiles,e).build_()})},2090:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(34666),o=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,n.isNumber)(e)?e:((0,n.toGt0)(e.width)??0)/((0,n.toGt0)(e.height)??0),(e=>(0,o.leastBy)(t.StandardAspectRatios,(t=>{const r=Math.abs(e-t);return r>i?void 0:r}))??e))}function c(e,i,r=t.RatioEpsilon){return(0,a.lt)((0,n.absdiff)(u(e),u(i)),r)}function d(e,i){return(0,o.leastByCtx)(t.Ratios,(t=>{const r=Math.abs(t.i-e);return r[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,s.maybeDimSwap)(e.dimensions,e.rotation),(0,s.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,n.sigFigs)(e,3))}},34943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const r=i(19851),s=i(31586),n=i(80049),a=i(50213),o=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),h=(0,r.lazy)((()=>(0,a.mkLogger)("img.RawInfo"))),f=(0,r.lazy)((()=>new n.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:o.ShortCommandTimeoutMs})));async function m(e){return f().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,r,n,a]=e.split("\t"),o=(0,s.toGt0)(n),l=(0,s.toGt0)(a);return null==o||null==l?h().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):h().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:r,ImageSize:{width:o,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>f.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?f.prior()?.clear():f.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{h().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},32876:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Reducers=t.Fit=t.fitInsideToMaxPixels=t.fitInsideToAspectRatio=t.Square=t.SharpFits=void 0;const r=i(19851),s=i(33374),n=i(4188),a=i(11371),o=i(31586),l=i(68708),u=i(50989),c=i(50213),d=i(86580);var h,f;t.SharpFits=(0,u.strEnum)("cover","contain","fill","inside","outside"),function(e){const i=(0,r.lazy)((()=>(0,c.mkLogger)("img.Reducers.Square")));e.name=a.ReducerNames.sq,e.fit="cover",e.reduce=function(e,r){const s=(0,d.lteBoth)(e,r)?{...e,fit:t.SharpFits.cover}:void 0;return i().tap({msg:"reduce()",result:s,meta:{max:e,input:(0,l.pick)(r,"width","height","nativePath")}})}}(h||(t.Square=h={})),t.fitInsideToAspectRatio=function(e,t){return e.width/e.height>=t?{width:Math.floor(e.height*t),height:e.height}:{width:e.width,height:Math.floor(e.width/t)}},t.fitInsideToMaxPixels=function(e,t){if(null==e||!(0,o.gt0)(e.width)||!(0,o.gt0)(e.height))return;if((0,s.pixels)(e)(0,c.mkLogger)("img.Reducers.Fit")));e.name=a.ReducerNames.fit,e.fit="inside",e.reduce=function(e,i){if(!(0,d.ltBoth)(i,e))return(0,n.fitInside)(i,e);t().trace(`reduce(): input ${(0,s.fmtDim)(i)} is too small for ${(0,s.fmtDim)(e)}`)}}(f||(t.Fit=f={})),t.Reducers=[h,f]},5733:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const s=r(i(9288)),n=i(19851),a=i(41400),o=i(50213),l=i(28874),u=i(15674),c=(0,n.lazy)((()=>(0,o.mkLogger)("img.Sharp")));function d(e,t){return(0,s.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,n.lazy)((()=>{s.default.simd(l.Settings.enableSIMD.valueOrDefault),s.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),s.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,a.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},50961:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractImageForThumbs_=t.sharpReadable_=t.toSharp=t.imgFromExif_=t._imgFromExif_=void 0;const s=i(77988),n=r(i(9288)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(33374),d=i(98553),h=i(31586),f=i(68708),m=i(51926),p=i(41583),g=i(50213),y=i(97352),v=i(56519),w=i(56038),b=i(57159),S=i(95696),P=i(17217),_=i(28874),T=i(47783),M=i(16170),E=i(95141),k=i(54979),D=i(1078),x=i(63870),C=i(86580),F=i(277),A=i(16047),I=i(13940),O=i(5733),L=i(66106),R=i(19350),N=(0,a.lazy)((()=>(0,g.mkLogger)("img.SharpReadable")));async function B(e,t,i){return i?await(0,T.exiftool)().extractBinaryTagToBuffer(t,e.nativePath):(await z(e,t))?.nativePath}async function j(e,t,i,r,a){const o=t?.[i];if(!(o instanceof s.BinaryField))return;const l=o.bytes<_.Settings.maxEmbeddedBuffer.valueOrDefault;try{const t=await B(e,i,l);if(null==t)return;const s=(0,n.default)(t,{failOn:_.Settings.imageFailOn.valueOrDefault}),o=await s.metadata(),u=(0,C.aspectRatio)(o);if(null!=a&&null!=u&&!(0,h.closeTo)(a,u,.2))return void N().info("imgFromExif("+e+", "+i+"): rejecting (aspect ratio mismatch)",{fileAspectRatio:a,renderedAspectRatio:u});const c=(0,C.lteBoth)(r,o);return N().debug("imgFromExif("+e+", "+i+")",{valid:c,minDim:r,useBuffer:l,fileAspectRatio:a,renderedAspectRatio:u,dim:(0,f.pick)(o,"width","height")}),c?{sharp:s,file:(0,m.isString)(t)?S.PosixFile.for(t):void 0}:void 0}catch(t){return void N().info("Failed to read image from EXIF tag "+i,{src:e,error:t})}}async function z(e,t){const i=t.toLowerCase().endsWith("tiff")?".tiff":".jpg";try{const r=await(0,I.tmpImageFile_)({src:e,tag:t,ext:i});return await r.applyIfEmpty_({retries:2,fn_:i=>(0,T.extractBinaryTag)(t,e.nativePath,i.nativePath),timeoutMs:(0,x.commandTimeoutMs)()})}catch(i){return void N().throw("Failed to extract embedded "+t+" from "+e.nativePath,{error:i})}}t._imgFromExif_=B,t.imgFromExif_=j,t.toSharp=function(e){const t=e;if((0,O.isSharp)(t.sharp))return t.sharp;if((0,P.isSimpleFile)(t.file))return(0,n.default)(t.file.nativePath,{failOn:_.Settings.imageFailOn.valueOrDefault});throw new Error("toSharp(): not a Sharp object: "+(0,d.stringify)(e))},t.sharpReadable_=function(e){return(0,w.time)(`img.sharpReadable${e.src.ext.toUpperCase()}`,(()=>async function({src:e,minDim:t,skipEmbedded:i}){const r=N().addParameterContext(e.nativePath);(0,O.setupSharp)();const n=await(0,k.readMimeType)(e);if((0,u.blank)(n))return r.throw(e+" is not supported (missing MIMEType)",{doNotSend:!0});const a=await(0,D.extractSizeInfoFromFile)(e);if(null==a)return void r.warn("Failed to extract size info from "+e);const d=[];function f(e,t){t.desc=e,d.push(t)}const m=a.rotation,g=(0,M.isVideoMimeType)(n),S=(0,M.isLibrawMimeType)(n),P=a.dimensions,x=t??(0,y.map2Gt0)(P.width,P.height,((e,t)=>({width:Math.round(.9*e),height:Math.round(.9*t)})));if(null==x?.width||null==x?.height)return r.throw(e+" is not supported (missing dimensions)",{dim:x,doNotSend:!0,mimetype:n,isRaw:S,isVideo:g});const I=(0,C.aspectRatio)(a.fileDimensions),B=(0,h.lt)(I,1),z=(0,M.isSharpMimeType)(n)&&null==t,V=(0,E.orientationRequiresMirroring)(a.orientation);if(!0===i||g||B||z||V)r.debug("not pulling previews from tags",{isVideo:g,isFilePortrait:B,isSharpMimeAndNoMinDim:z,isMirrorOrientation:V});else{const i=!1,n=await(0,T.readRawTags)(e,i);if(null==n)r.warn("Cannot pull previews from tags: readRawTags() failed");else{const i=[..._.Settings.embeddedPreviews.values];null!=t&&(0,c.dmegapixels)(t)<1&&i.unshift(..._.Settings.embeddedThumbnails.values);const a=x.width*x.height*.2,u=x.width*x.height*.05,d=(0,l.sortBy)(i.filter((e=>n[e]instanceof s.BinaryField)),(e=>{const t=n[e]?.bytes;return(0,h.gt)(t,u)?Math.abs(t-a):void 0}));if(!(0,o.isEmpty)(d)){r.debug("checking previews from tags",{sizeSortedTagNames:d});for(const t of d)f("imgFromExif."+t,(()=>j(e,n,t,x,I)))}}}(0,M.isSharpMimeType)(n)&&f("sharp",(async()=>({file:e}))),(0,A.isHeifMimeType)(n)&&await(0,F.isHeifSupported)()&&f("heif",(()=>(0,v.thenMap)((0,F.heif2img)(e),(e=>({file:e}))))),S&&f("raw2tiff",(()=>(0,v.thenMap)((0,R.raw2tiff_)(e),(e=>({file:e}))))),g&&f("extractVideoFrame",(async()=>{if(await(0,L.isVideoSupported)())try{return await(0,v.thenMap)((0,L.extractVideoFrame_)(e),(e=>({file:e})))}catch(t){throw new b.WrappedError("Failed to extract video frame for "+e,t)}else r.warn("video file, but video support is missing",{src:e.nativePath,mimetype:n,minDim:t})}));const W=[];for(const i of d)try{const s=await(0,w.time)("img.read."+i.desc,i);if(null!=s)return r.debug(i.desc+" strategy succeeded",{src:e,minDim:t,rot:m,img:s.file?.nativePath}),{desc:i.desc,rot:m,mimetype:n,...s};r.debug(i.desc+" returned null",{src:e,minDim:t,rot:m})}catch(e){r.warn(i.desc+" failed",e),W.push((0,p.toErr)(e))}throw new b.WrappedError("Failed to render "+e,{causes:W,path:String(e),fatal:!1,doNotSend:!0,retriable:!1})}(e)))},t.extractImageForThumbs_=z},21473:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.testSharp_=void 0;const s=r(i(34589)),n=i(76760),a=r(i(9288)),o=i(50357),l=i(98553),u=i(68708),c=i(23560),d=i(43899),h=i(28874),f=i(5733);t.testSharp_=async function e(t){try{(0,f.setupSharp)();const e=t??(0,n.join)(d.ProjectPath.Public(),"images","logo@5x.png"),i=(0,a.default)(e,{failOn:"error"}),r=await i.resize(24,32,{fit:"cover",position:"attention"}).toFormat("jpeg").toBuffer({resolveWithObject:!0});(0,s.default)((0,o.eql)((0,u.pick)(r.info,"format","width","height","channels"),{format:"jpeg",width:24,height:32,channels:3}),"Unexpected sharp output: "+(0,l.stringify)(r.info))}catch(i){if(!(0,c.isWorkerService)()&&h.Settings.enableSIMD.valueOrDefault)return h.Settings.enableSIMD.envValue=!1,e(t);throw i}}},181:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.whyInvalidFile=t.clearInvalidFileCache=t.throwIfInvalidFile_=t.isValidFile=void 0;const s=r(i(9288)),n=i(19851),a=i(22573),o=i(42659),l=i(98553),u=i(50213),c=i(12089),d=i(81168),h=i(57159),f=i(88561),m=i(95696),p=i(17217),g=i(28874),y=i(16170),v=i(54979),w=i(63870),b=i(5733),S=i(50961),P=i(66106),_=i(51210),T=(0,n.lazy)((()=>(0,u.mkLogger)("img.ValidFile")));t.isValidFile=async function(e){return(0,a.blank)(await(0,t.whyInvalidFile)((0,p.toNativePath_)(e)))},t.throwIfInvalidFile_=async function(e){if(!g.Settings.validateJpegImages.valueOrDefault&&!g.Settings.validateRawImages.valueOrDefault&&!g.Settings.validateVideos.valueOrDefault)return void T().debug("file validation is disabled for "+e,{validateJpegImages:g.Settings.validateJpegImages.valueOrDefault,validateRawImages:g.Settings.validateRawImages.valueOrDefault,validateVideos:g.Settings.validateVideos.valueOrDefault});const i=(0,p.toNativePath_)(e),r=T().tap({msg:"whyInvalidFile("+i+")",result:await(0,t.whyInvalidFile)(i)});(0,a.notBlank)(r)&&T().throw(r,{path:i,retriable:!1,doNotSend:!0,ignorable:!0})};const M=(0,n.lazy)((()=>new f.FileCache({name:"img.validFile",maxSize:256,timeoutMs:Math.max(o.minuteMs,g.Settings.validateVideos.valueOrDefault?5*o.minuteMs:(0,w.commandTimeoutMs)())})));t.clearInvalidFileCache=function(){return M().clear()},t.whyInvalidFile=(0,c.shim1)({name:"img.whyInvalidFile",cache:M,toKey:p.toNativePath_,impl:async e=>{const t=m.PosixFile.for(e);if(!await t.isFile()||!await t.isReadable())return t+" is not a readable file";if(await t.isEmpty())return t+" is empty";try{const e=await(0,v.readMimeType)(t);if(null==e)throw new Error("Cannot validate, no mimetype");if((0,y.isVideoMimeType)(e))g.Settings.validateVideos.valueOrDefault&&(T().debug("validating "+t),await(0,P.validVideo_)(t));else{if(!e.startsWith("image/"))throw new Error("Unsupported mimetype "+(0,l.stringify)(e));if("image/jpeg"===e)g.Settings.validateJpegImages.valueOrDefault&&await(0,_.validJpeg_)(t);else if(g.Settings.validateRawImages.valueOrDefault)if((0,d.includesIgnoreCase)(g.Settings.validateMimetypeSkiplist.values,e))T().info("Skipping validation of "+t+": validateMimetypeSkiplist matches",{mime:e});else{const e=await(0,S.sharpReadable_)({src:t,skipEmbedded:!0}),i=await async function(e,t=g.Settings.imageFailOn.valueOrDefault){const i=e;if((0,p.isSimpleFile)(i.file))return(0,s.default)(i.file.nativePath,{failOn:t});if((0,b.isSharp)(i.sharp)){const{data:e,info:t}=await i.sharp.raw().toBuffer({resolveWithObject:!0});return(0,s.default)(e,{...t,failOnError:!0})}throw new Error("Cannot read input "+e?.desc)}(e);await i.tiff().toBuffer()}}return""}catch(t){return new h.WrappedError("Failed to validate",{cause:t,path:e,doNotSend:!0}).toS()}}})},19769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const r=i(19851),s=i(40958),n=i(41400),a=i(50213),o=i(68852),l=i(98314),u=i(28874),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:h().test(t)||!d().test(t),meta:{err:e,allow:h().test(t),block:d().test(t),validationErrorAllowlist:h().source,validationErrorBlocklist:d().source}})};const d=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),h=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,n.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>h.unset()))}))},66106:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const r=i(19851),s=i(40958),n=i(38639),a=i(42659),o=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),h=i(7282),f=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),v=i(56038),w=i(31562),b=i(34102),S=i(88561),P=i(95696),_=i(17217),T=i(31843),M=i(70417),E=i(33847),k=i(28874),D=i(94678),x=i(43207),C=i(47783),F=i(16170),A=i(95141),I=i(1078),O=i(63870),L=i(89782),R=i(13940),N=i(34592),B=(0,r.lazy)((()=>(0,d.mkLogger)("img.Video")));function j(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function z(e){return(0,h.isProd)()&&(e=void 0),(0,n.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=z,t.isVideoSupported=(0,r.lazy)((async()=>{try{return!0===(await z())?.isSupportedVersion}catch(e){return B().warn("isVideoSupported",{error:e}),!1}})),(0,o.later)((()=>(0,b.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,T.lerp2d)(e,{x:76800,y:k.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:k.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,r.lazy)((()=>new S.FileCache({name:"img.videoFrame",timeoutMs:a.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,_.toNativePath_)(e))):void 0}async function U(e,t){const i=j("extractVideoFrame",e),r=P.PosixFile.for(e);if(!(0,n.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const s=await(0,R.cachedImageFile_)(r,"frame",".jpg");i.debug("extractVideoFrame("+s+")");const o=await r.mtimeMs();if(null==o)return i.throw("null mtime");const l=await(0,C.readRawTags)(r,!1);if(null==l)return i.throw("no tags");const u=(0,A.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,I.extractSizeInfoFromTags)(l,u)?.dimensions,d=await s.stat(),h=null==d?void 0:await(0,L.dimensions)(s);if(null!=d&&d.mtimeMs>o&&null!=h&&(null==c||h.height===c.height&&h.width===c.width))return i.debug("prior dest, "+s+" seems reasonable",{srcDim:c,destDim:h}),s.nativePath;const f=(0,x.extractDurationSec)(l),m=Math.min(f??0,k.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:f}),await s.applyIfEmpty_({fn_:async e=>{const t={src:r,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,w.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*a.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,C.deleteAllTags_)(e,e)},timeoutMs:(0,O.commandTimeoutMs)()}),s.nativePath}async function q(){return k.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function H(e){const t=j("needsTranscoding",e);if(!await q())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,C.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const r=i.MIMEType;if(!(0,F.isVideoMimeType)(r))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:r}});const n=(0,x.extractDurationSec)(i);if(!(0,c.gt)(n,k.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:n}});const a=(0,s.compactBlanks)([i.AudioFormat]),o=a.some((e=>(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,s.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeMimeTypes.values,r);return t.tap({level:"info",msg:"result",result:!(o&&u&&d),meta:{mimetype:r,isSafeMimeType:d,audioCodecs:a,isSafeAudioCodec:o,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>U(e)}),t.__extractVideoFrame_=U,t.isVideoTranscodingSupported=q,t.needsTranscoding=H;const $=new g.TTLMap(a.hourMs);function G(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,r){if(!await q())return;const s=j("transcode",e);{!function(){for(const[e,t]of $.entries())t.isSettled&&$.delete(e)}();const t=$.get(e.nativePath)??$.get(i.nativePath);if(null!=t)return s.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await H(e))return void s.info("no transcoding needed");const n=await e.size();if(!(0,u.gt0)(n))return s.throw("source is empty or cannot read");const a=await(0,C.readTags)(e),o=(0,I.extractSizeInfoFromTags)(a),d=(0,x.extractDurationSec)(a);if(null==a||null==o||null==d)return s.throw("failed: missing video metadata",{sizeInfo:o,durationSec:d});{const e=$.get(i.nativePath);if(null!=e)return s.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const h=new y.Deferred("transcode "+e);$.set(e.nativePath,h),$.set(i.nativePath,h);const m=(0,u.toGt0)(a.VideoFrameRate)??(0,u.toGt0)(a.FrameRate)??30,p=Math.round(o.dimensions.width*o.dimensions.height*(0,M.max)([(0,u.toGt0)(a.FrameCount),(0,u.toGt0)(a.VideoFrameCount),m*d]));if(!0===r?.force)await i.unlink();else if(await async function(e,t){const i=await(0,C.readRawTags)(t),r=await(0,C.readRawTags)(e),s=(0,x.extractDurationSec)(r),n=(0,x.extractDurationSec)(i);return B().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(s,n,1.5),meta:{srcDurationSec:s,destDurationSec:n,src:e.nativePath,dest:t.nativePath}})}(e,i))return s.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const r=j("extractMaxBitrate",e),s=k.Settings.minVideoDimension.valueOrDefault,n=i.ImageWidth;if(null!=n&&!(0,u.gte)(n,s))return r.throw("invalid width: "+n,{ignorable:!0});const a=i.ImageHeight;if(null!=a&&!(0,u.gte)(a,s))return r.throw("invalid height: "+a,{ignorable:!0});const o=(0,D.extractBitrateKbps)(i)??k.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,f.mapGt0)(n,(e=>(0,f.mapGt0)(a,(i=>(0,u.clamp)(0,o,(0,t.bitrateKps)(e*i)))))),c={width:n,height:a,videoBitrateKbps:l};return r.debug("dim()",{src:e,result:c}),c}(e,a);return await h.observe((0,v.time)("video.transcode:"+e,(async()=>{const t=G(n,g.videoBitrateKbps,d);return await i.applyWip_({fn_:n=>async function(n){s.info("starting...",{destWip:n});const o=new E.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:n,fps:m,halt:r.halt,...g},h=k.Settings.transcodeMaxDim.valueOrDefault,f=(0,M.max)([a.dimensions.height,a.dimensions.width]);if((0,u.gt0)(h)&&(0,c.gt)(f,h)){const e=(0,l.fitInside)(a.dimensions,{width:h,height:h});null==e?s.warn("Cannot downsample transcoded video: fitInside() returned null",{input:a.dimensions,maxPixels:h}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),s.info("Downsampling transcoded video",{original:a.dimensions,output:e}))}const p=await o.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&s.throw("transcode failed with code "+p.code)}(n),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&s.info("transcode complete",{src:e,dest:i,elapsedMs:h.elapsedMs,pixels:p}),i},t.guessExpectedSize=G,t.validVideo_=async function(e){return null==await W(e)&&j("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),h=i(56519),f=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),v=i(84258),w=i(28874),b=i(76280),S=i(63870),P=i(19769),_=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function T(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:w.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=T;const M=/ffmpeg version n?(?\S+)/i,E=(0,u.lazy)((async()=>{const e=await T();if(null==e)return void _().info("failed to find ffmpeg in $PATH",{ffmpegPath:w.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,S.commandTimeoutMs)(),ignoreStderr:!0}),i=M.exec(t.result)?.[1];return _().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,b.semverSatisfies)(i,">=3.2")}}));function k(){E.unset(),t.ffmpegVersionDescription.unset()}function D(e){const t=e?.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault;return(0,s.blank)(t)||(0,n.isDisabled)(t)?[]:["-hwaccel",t]}function x(e){const t=[...w.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(w.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),r=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+r),t}function C(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function F(e){const t=w.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,h.thenMapOr)(E(),(e=>"version "+e),(()=>"(not found)")))),(0,o.later)((()=>{(0,g.ee)().on("clearCache",k),(0,g.ee)().on("clearToolCache",k)})),t.ffmpegVersion_=async function(){return await E.prior()??E.refresh()},t.isFFmpegSupported=async function(){return null!=await E()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await T(),(0,r.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:a.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,f.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*a.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=x,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await T(),(0,r.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...x(t),...F(t),...D(t),"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...C(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){_().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,v.unlink)(t.dest,"debug");const r=(0,p.errorToS)(i,{maxLen:1024});if(!(0,n.isDisabled)(t.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(r))return _().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return _().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await T(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},51210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotate_=t.rotateInPlace_=t.validJpeg_=t.jpegtranVersion_=void 0;const r=i(19851),s=i(42659),n=i(21605),a=i(50213),o=i(84777),l=i(57159),u=i(95696),c=i(89966),d=i(43334),h=i(63870),f=i(19769),m=d.isWin?"NUL":"/dev/null",p=(0,r.lazy)((()=>(0,a.mkLogger)("img.jpegtran")));async function g(e,t,i){const r=await(0,c.jpegtranNativePath_)();if(!(0,n.isRotation)(i))throw new Error("refusing to rotate("+e+", "+i+")");await(0,o.stdout_)(r,["-copy","all","-trim","-rotate",i.toFixed(0),"-outfile",t.nativePath,e.nativePath],{timeoutMs:s.minuteMs}),t.clear()}t.jpegtranVersion_=async function(){const e=await(0,o.stdoutResult_)(await(0,c.jpegtranNativePath_)(),["-version"],{quiet:!0,timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:()=>!0});return(e.stderr??e.result).replace(/^libjpeg-turbo version/,"").trim()},t.validJpeg_=async function(e){const t=u.PosixFile.for(e),i=await(0,c.jpegtranNativePath_)();try{await(0,o.stdoutResult_)(i,["-outfile",m,t.nativePath],{timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:f.isIgnorableValidationError,ignoreExitCode:!0})}catch(e){throw p().warn("validJpeg caught invalid file",{src:t,cause:e}),new l.WrappedError("Invalid JPEG: "+t,{cause:e,path:t.nativePath,doNotSend:!0,fatal:!1,retriable:!1})}},t.rotateInPlace_=async function(e,t){p().info("rotateInPlace("+e+")",t),await e.applyWip_({fn_:i=>g(e,i,t),skipFsLock:!1,minSizeBytes:512,timeoutMs:s.minuteMs})},t.rotate_=g},19350:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dcraw_emu_=t.raw2tiff_=t.librawSupported=void 0;const r=i(19851),s=i(40958),n=i(33374),a=i(12168),o=i(23541),l=i(54993),u=i(50213),c=i(84777),d=i(98314),h=i(38835),f=i(57159),m=i(89966),p=i(28874),g=i(16170),y=i(54979),v=i(89782),w=i(13940),b=i(42725),S=i(19769),P=(0,r.lazy)((()=>(0,u.mkLogger)("img.libraw")));t.librawSupported=async function(e){try{return(0,g.isLibrawMimeType)(await(0,y.readMimeType)(e.nativePath))}catch(t){return P().warn("librawSupported("+e+"): failed to read filetype",t),!1}},t.raw2tiff_=async function(e){return(0,w.readableToFile_)({src:e,desc:"dcraw",suffix:".tiff",f:t=>k(e,t)})};const _=["-T"],T=["-Z","-"],M=["-o","1"],E=["-t","0","-j"];async function k(e,t){const i=await(0,v.dimensions)(e);if(null==i)return P().throw("Cannot decode RAW "+e+": no EXIF dimensions."+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);const r=b.ImageSize.largestFit().outputSize(i),u=[];null!=r&&4*(0,n.dmegapixels)(r)<(0,n.dmegapixels)(i)&&(P().debug("Large original source: using -h"),u.push("-h"));const g=await(0,m.dcrawEmuNativePath_)(),y=[..._,...T,...M,...u,...E,...p.Settings.dcrawEmuArgs.values,e.nativePath],w={encoding:"buffer",timeout:p.Settings.taskTimeoutMs.valueOrDefault,maxBuffer:250*a.MB};P().debug("dcraw_emu()",{cmd:g,args:y,opts:w});const k=(0,c.execFile)(g,y,void 0,w),D=[];function x(t){const i=(0,o.isError)(t)?(0,d.errorToS)(t):(0,l.toS)(t);if((0,S.isIgnorableValidationError)(i))P().info("dcraw_emu(): warning",{src:e,msg:i});else{P().warn("dcraw_emu(): error",{src:e,msg:i});const r=(0,o.isError)(t)?t:(0,f.toWrappedError)(i,{fatal:!1});D.push(r)}}if(k.on("error",x),k.stderr.on("data",x),await t.writeStream_(k.stdout),(0,s.isNotEmpty)(D))throw new f.WrappedError("Failed to convert RAW image "+e,{causes:D,path:e.nativePath});(0,c.endProcess)(k)}t.dcraw_emu_=k},36192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const r=i(19851),s=i(84777),n=i(8103),a=i(43334),o=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,r.lazy)((async()=>a.isMac?(0,n.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,s.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(o.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},45657:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.r=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(45599),l=i(98553),u=i(55835),c=i(34666),d=i(50213),h=i(37628),f=i(37805),m=i(46292),p=i(95696),g=i(93756),y=i(28874),v=i(63870),w=i(71706),b=i(81674),S=i(33603),P=i(70114),_=(0,o.defer)((()=>(0,d.mkLogger)(T().l))),T=(0,r.rolazy)((()=>(0,w.j)("G8oAKIzTFfOihHWPgG6m/h0h65IqCWu72UHSOixdfW12GgbIbSdJW2sLEmvLsqcHfOPXk00SqojDRomicXUE+MuLfPaoTzFWZPq8AdmWyQVUWERkBLoYBhqafaAvY27+LDra0blcQ4Vnjn/ukQh/C4o0cd0B")));async function M(e){const t=await(0,S.sids)({timeoutMs:(0,v.commandTimeoutMs)()});if((0,s.isEmpty)(t))return _().warn("no-op: empty sids");const i=(0,l.stringify)({uids:[...t,e],coupon:y.Settings.coupon.valueOrDefault,version:f.version}),r={...T().r,body:i},n=await(0,g.request)(T().u,r);_().info(T().u,{req:r,response:n}),n.ok?await(0,P.writeLicense)(JSON.parse(n.body)?.[T().a],(0,v.commandTimeoutMs)()):_().warn(T().u,{req:r,response:n})}t.r=(0,r.rolazy)((async()=>{const e=T().s+": ";try{if(!y.Settings[T().s].valueOrDefault)return _().debug(e+"no-op (settings disabled)");const t=(await(0,b.m)()).filter((e=>null!=e.l&&(0,n.notBlank)(e.s))),i=new Date,r=t.find((e=>e.ok&&(0,c.gt)(i,e.l?.exp)));if(null!=r)return _().debug(e+"no-op: ",{current:r});const s=await(0,u.map)((0,m.configDir)(),(e=>p.PosixFile.for(e).join(T().s+"-v"+f.version).mkdirp_()));for(const r of t){if((0,n.blank)(r.s)||null==r.l||ie.startsWith("cu:")));if(null!=t){if(await(s?.join((0,h.shortFsStringSha)(r.s,14)+".txt").applyIfEmpty_({fn_:async i=>{await M(t),await i.writeJson_({l:r.l,at:Date.now()}),_().warn(e+"requested",r)},timeoutMs:(0,v.commandTimeoutMs)()})),await(0,b.p)())break}else _().debug(e+"skipping (no cu)",r)}}catch(t){_().warn(e+"failed",t)}}),15*a.minuteMs)},71706:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.j=void 0;const r=i(38522);t.j=function(e){return JSON.parse((0,r.brotliDecompressSync)(Buffer.from(e,"base64")).toString("utf8"))}},42042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEmail=void 0;const r=i(22573),s=i(28874),n=i(81674);t.getEmail=async function(){const e=s.Settings.email.value;if((0,r.notBlank)(e))return e;for(const e of await(0,n.m)())if((0,r.notBlank)(e.l?.sub))return e.l?.sub}},83950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.L=void 0;const r=i(79114),s=i(40958),n=i(42659),a=i(34666),o=i(48884),l=i(97352),u=i(81674),c=i(84194);t.L=class{static for(e){return new this(e.str,e.l,e.sids,e.src)}constructor(e,t,i,r){this.s=e,this._l=t,this._sids=i,this.meta={src:r}}get l(){return this._l}get ok(){if(null==this._l)return!1;const e=(0,o.intersection)(this._sids,this._l.uids),t=(0,s.uniq)(e.map(c.getScheme)),i=(0,s.compact)(t.map((e=>(0,c.prefix2scheme)(e)))),r=i.length>=this._l.mat,a=(0,l.within)(this._l.iat?.getTime(),this._l.exp?.getTime()+n.dayMs,Date.now());return this.meta[(0,u.k)().o]=a,this.meta[(0,u.k)().u]=r,this.meta[(0,u.k)().m]=i,a&&r}cmpVal(){return[this.ok,-(r.S.indexOf(this.l?.[(0,u.k)().T])??0),this.l?.exp?.getTime()??1,this.meta.matchedSchemes]}cmp(e){return(0,a.cmp)(this.cmpVal(),e.cmpVal())}}},81674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p=t.l=t.t=t.b=t.m=t.vok=t.v=t.v_=t.k=void 0;const r=i(76790),s=i(22573),n=i(38639),a=i(45599),o=i(41400),l=i(96249),u=i(55835),c=i(31586),d=i(51926),h=i(79114),f=i(23541),m=i(59455),p=i(54993),g=i(72993),y=i(19851),v=i(50213),w=i(56519),b=i(76596),S=i(46292),P=i(87290),_=i(77740),T=i(34102),M=i(83278),E=i(28874),k=i(37692),D=i(71706),x=i(83950),C=i(72042),F=i(33603),A=i(48132);t.k=(0,y.rolazy)((()=>(0,D.j)("G1UBABwHdkz4hUIkFCfPXW5LlfvrWKSr9W3AIyIhUiw68NDfvLLHVop/bGoNnRxQlnqi2TZp0IJaX+lUHBoi+vMy2LMNpHCv8xVkUGsmQsgB8ldHoDqJeUQzbdybwikWVRs2KSWKjE5LnuqhTNSp3gTLhNfE9EqBLeaXP+UM9YqTGSXcyrcL03rIPMDAVyJplSZC0xoUgguOYJKvrcYFbNArN7BrQsnnsJ4hMtcSxOTxxRdxzETtL93qa3vjDw==")));const I=(0,a.defer)((()=>(0,v.mkLogger)((0,t.k)().l)));async function O(e){const i=await(0,C.V)((0,d.ensurePrefix)((0,p.toS)(e).trim(),(0,t.k)().p)),r=(0,b.utcIsoToTs)(i[(0,t.k)().i]);if(null==r)throw new Error("bad "+(0,t.k)().i+": "+i[(0,t.k)().i]+" ("+e+")");const s=(0,b.utcIsoToTs)(i[(0,t.k)().r]);if(null==s)throw new Error("bad "+(0,t.k)().r+": "+i[(0,t.k)().r]+" ("+e+")");return(0,_.getDevEnvFlag)((0,t.k)().y)&&(i[(0,t.k)().t]=!0),i[(0,t.k)().a]=(0,c.toGte0)(i[(0,t.k)().a])??2,i[(0,t.k)().i]=new Date(r),i[(0,t.k)().r]=new Date(s),i[(0,t.k)().b]=(0,p.toS)(i.uids).split(","),i}async function L(e,i,r,n){try{return(0,s.blank)(e)||e===(0,t.k)().f?void 0:x.L.for({str:e,l:await O(e),sids:null!=n?n:await(0,F.sids)({timeoutMs:r}),src:i})}catch(i){return I().tap({msg:(0,t.k)().v,result:{s:e,ok:!1,meta:{err:i}}})}}async function R(e,t){const i=[],r=await(0,w.sortByAsync)({name:"rawLicenseFromDir("+e+")",arr:e?.childFiles(),f:e=>e.mtimeMs()});for(const e of r.reverse()){const r=await L((0,m.toA)(await e.readLines()).map((e=>e.trim())).join(""),e.nativePath,A.UserTimeoutMs,t);null!=r&&i.push(r)}return i}async function N(){const e=await(0,t.m)();return e[0]?.ok?e[0]:void 0}async function B(){return(await N())?.l?.[(0,t.k)().T]??(0,t.k)().f}t.v_=O,t.v=L,t.vok=async function(e,t,i){if((0,s.blank)(e))return;const r=await L(e,t,i);return(0,n.isTrue)(r?.ok)&&r instanceof x.L?r:void 0},t.m=(0,y.rolazy)((async()=>{if((0,_.getDevEnvFlag)((0,t.k)().x))return[];const e=await(0,F.sids)({timeoutMs:A.UserTimeoutMs}),i=(0,u.map)((0,S.configDir)(),(e=>M.BaseFile.for(e))),s=(n=(0,l.flatten)((await(0,w.someOrTimeout)([()=>function(e){return L(E.Settings[(0,t.k)().L].value,"Settings",A.UserTimeoutMs,e)}(e),()=>R(i?.join((0,t.k)().d),e),()=>R((0,P.libraryDataDirPosixFile)()?.join((0,t.k)().d),e),()=>R(i?.sibling((0,g.AppName)().toLowerCase()).join((0,t.k)().d),e)],{timeoutMs:A.UserTimeoutMs})).filter((e=>!(e instanceof Error)))),(0,r.sortBy)(n.filter((e=>null!=e&&((0,f.isError)(e)&&I().warn((0,t.k)().d+": ",e),null!=e&&!(0,f.isError)(e)&&null!=e?.l))),(e=>[!e.ok,h.S.indexOf(e.l?.[(0,t.k)().T])??h.S.length+1,-(e.l?.exp?.getTime()??1)])));var n;return I().tap({msg:(0,t.k)().d+"()",result:s})})),(0,o.later)((()=>{(0,T.ee)().on("clearCache",(()=>t.m.unset())),(0,T.ee)().on((0,t.k)().c,(()=>t.m.unset())),k.stateEvents.on((0,t.k)().c,(()=>t.m.unset()))})),t.b=N,t.t=B,t.l=async function(){try{return await B()===(0,t.k)().f}catch{return!0}},t.p=async function(){try{return await B()===(0,t.k)().g}catch{return!1}}},72042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.V=t.l=void 0;const r=i(91227),s=i(19851),n=i(22573),a=i(71706);t.l=(0,s.lazy)((()=>(0,a.j)("G54BgBwHzrkukKDR8Ar6KkW29gbXlfrqQX46gTu5Wfq6dELYTjfBokB0d5+E2SAINBtxlmPquWe3PMUoNgaJrD982QMslkNeZ4BEqcBbQT59DVl9RnoTNi50diuT7NQg0YHxkr8SwDwtmFUOf+LwNVDDnPXUrzTOU++M3b+lcyfr7PXZndKHzho8iztNkZgt+/19//aXe+gvmC0HIdnn64wdLeYeLM7S9jmjTp52SzFsvIVbd4D0+rdtdjiz6R4vc2cmY398kuXiKG7fNXWS/I93etxXiVNPd4RXJF+k6JnuMUKk03GWHQQ="))),t.V=function(e){const i=(0,r.decode)(e).payload;if(null==i)throw new Error("Missing payload");const s=(0,n.notBlankOr)(i.k,(0,t.l)().d),a=(0,t.l)().o.find((e=>e.k===s));if(null==a)throw new Error("Unknown key");return r.V2.verify(e,a)}},84194:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SchemeCounts=t.isValidUid=t.toUID=t.UidLength=t.prefix2scheme=t.sortUids=t.getScheme=t.S=void 0;const n=i(40958),a=i(76790),o=i(22573),l=i(45599),u=i(50989),c=i(54993),d=i(22454),h=i(19851),f=i(50213),m=i(37628),p=i(55222),g=i(71706),y=(0,l.defer)((()=>(0,g.j)("GyABAIzUYs0Z7mSuLfVL1SwGefr+3nCwyXBMg6nD0qduA8HycFjUGK1N/ikYqhiqYLGbs7oxTBbzRPxteP9gA3L9DS0EJ2BJ1pYNa/DtEE2aPI2o03hHx3k9MhdE7jAeRUvKQ6tY3Q1fcIPe8GBMZvOeKibTymyo3Cw/7Ua42DKPjpL3wxWv+7TCGA==")));function v(e){const i=e.split(":",1)[0];return t.S.has(i)?i:void 0}t.S=(0,u.strEnum)("cu","lc","lm","lp","lb","mp","ms","wm","cm","bm","nm","li","si","vl"),t.getScheme=v,t.sortUids=function(e){return(0,a.sortBy)((0,n.uniq)(e.filter(S)),(e=>[t.S.indexOf(v(e))??t.S.length+1,e]))},t.prefix2scheme=function(e){return y()[e]};const w=["uninitialized","b08dfa6083e7567a1921a715000001fb"];t.UidLength=15,t.toUID=function(e,i){try{const r=(0,c.toS)(i).replace(/[^a-z\d=/+]+/gi,"");return(0,o.blank)(r)||w.includes(r.toLowerCase())||null!=r.match(/^[\s0:_/-]*$/)?void 0:e+":"+(0,m.shortStringSha)(r,t.UidLength,p.Radix58)}catch(t){return void(0,f.mkLogger)("toUID").warn("failed",{pfx:e,err:t})}};const b=(0,l.defer)((()=>new RegExp(`^(?:${t.S.values.join("|")}):[0-9a-zA-Z]{${t.UidLength}}$`)));function S(e){return null!=e&&null!=b().exec(e)}t.isValidUid=S,t.SchemeCounts=class{constructor(e){r.set(this,new Set),this.schemeCounts=(0,h.lazy)((()=>{const e=new d.CountingSet;for(const t of s(this,r,"f")){const i=v(t);null!=i&&e.incr(i)}return e})),null!=e&&this.addUids(e)}get size(){return s(this,r,"f").size}addUids(e){for(const t of e)null==v(t)||s(this,r,"f").has(t)||(s(this,r,"f").add(t),this.schemeCounts.unset())}count(e){return this.schemeCounts().get(e)}},r=new WeakMap},33603:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearSids=t.addSids=t.sids=t.win_machineGuid_=t.readInfo=t.k=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(45599),o=i(96249),l=i(68708),u=i(51926),c=i(59455),d=i(54993),h=i(50213),f=i(7282),m=i(56519),p=i(84777),g=i(84542),y=i(19254),v=i(45879),w=i(70854),b=i(57902),S=i(72308),P=i(43334),_=i(24399),T=i(7014),M=i(30933),E=i(71706),k=i(84194);t.k=(0,a.defer)((()=>(0,E.j)("G9ABYIzDOIZ8NLQ4t7qW8tNrmrOzz+qFGfAxl8jW4E2tLxwWRZT5TueCnPcwgTzT1DN3veRB+e7EYGlYHg6nhjBDQv7zI6EcYWk35z6QuZC3Q0itjrLCbmgd0iED0BvGiYLBJwRU1O9/3Agbl8IfG6ITVFWDRwyTw3rbUMo/XMyAVW7R23mkwUx0l4/7iA13RV/nmPuJFKp5BvJW7SoXJZoWEfdSNYYhN5UCtkbC7O1AaPIbU3P6uRLmEyb4TaHWzFigvrlmZVUzzp9j/Mz55vqN88ewd1Nrfh7gkVRQ7TtB7Ztz3XJxYC3ogdJHg8HGsG4=")));const D=(0,a.defer)((()=>(0,h.mkLogger)((0,t.k)().n)));async function x(e=(0,t.k)().pc){if(P.isLinux)try{const t=await(0,y.fileGrep_)(e,/^\s*(?:hardware|revision|serial|model)\s*[:=]\s*[a-z\d]{6}.*$/i),i=(0,r.compactBlanks)((0,g.splitLines)(t).map((e=>e.replace(/\s+/g," ")))).sort();return i.some((e=>null!=e.match(/^serial/i)))?i:void 0}catch{return}}t.readInfo=x;const C=(0,a.defer)((()=>(0,m.thenMap)(x(),(e=>(0,k.toUID)(k.S.lc,e.join(",")))))),F=/o\.e\.m\./i;async function A(e){return(0,r.uniq)(await Promise.all((0,t.k)()[e].map((e=>(0,v.readFileMaybe)(e,b.LogLevels.trace))))).map(d.toS).filter((e=>(0,s.notBlank)(e)&&null==e.match(F)))}async function I(){return P.isLinux?(await A("lm")).map((e=>(0,k.toUID)(k.S.lm,e))):void 0}async function O(){return P.isLinux?(await A("lp")).map((e=>(0,k.toUID)(k.S.lp,e))):void 0}async function L(){return P.isLinux?(await A("lb")).map((e=>(0,k.toUID)(k.S.lb,e))):void 0}async function R(){if(P.isMac)try{return(0,l.entries)(await async function(){const e=await(0,p.stdout_)((0,t.k)().i,(0,t.k)().ia,{timeoutMs:5*n.secondMs}),i=e.match(/uuid" = "([a-z\d-]{12,})"/i)?.[1],r=e.match(/SerialNumber" = "([a-z\d-]{10,})"/i)?.[1];return{mp:i,ms:r}}()).map((([e,t])=>(0,k.toUID)(e,t)))}catch(e){return void D().warn((0,t.k)().i+" failed",e)}}async function N(){return(await _.PowerShell.instance().executeJson((0,t.k)().w))?.MachineGuid}async function B(){return P.isWin?(0,k.toUID)(k.S.wm,await N()):void 0}t.win_machineGuid_=N;const j=(0,a.defer)((()=>(0,k.toUID)(k.S.cm,(0,M.cpuInfo)()[0].model)));async function z(){return P.isLinux?(0,k.toUID)(k.S.bm,(0,r.compactBlanks)(await A("bm")).map((e=>e.trim())).join("\n")):[]}async function V(){return(0,k.toUID)(k.S.li,await((0,w.LibraryUIDStore)()?.readUid_()))}async function W(){return(0,k.toUID)(k.S.si,await((0,w.SystemUIDStore)()?.readUid_()))}function U(){return(0,S.networkMacAddresses)().map((e=>(0,k.toUID)(k.S.nm,e)))}async function q(){return(0,c.toA)(await(0,T.volumes)()).map((e=>(0,k.toUID)(k.S.vl,e.uuid)))}const H=new Set;t.sids=async function({timeoutMs:e}){const t=Date.now(),i=[j,C,R,V,W,z,I,O,L,B,U,q],r=(0,o.flatten)(await(0,m.someOrTimeout)(i,{timeoutMs:e})).filter(u.isString);for(const e of r)H.add(e);return D().tap({msg:"sids()",result:(0,k.sortUids)([...H,...r]),meta:{timeoutMs:e,elapsedMs:Date.now()-t}})},t.addSids=function(e){if((0,f.isTest)())for(const t of e)H.add(t)},t.clearSids=function(){(0,f.isTest)()&&H.clear()}},48132:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserTimeoutMs=void 0;const r=i(42659);t.UserTimeoutMs=7*r.secondMs},70114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.saveIfBetter=t.licensesInDirectory=t.writeLicense=void 0;const r=i(45599),s=i(55835),n=i(50213),a=i(23560),o=i(37628),l=i(56519),u=i(46292),c=i(87290),d=i(34102),h=i(83278),f=i(37692),m=i(83950),p=i(81674),g=(0,r.defer)((()=>(0,n.mkLogger)("writeLicense")));async function y(e,t){return(await(0,l.mapAsyncSerial)({name:"read",arr:e.childFiles(),f:async e=>(0,p.vok)(await e.readTextFile(),e.nativePath,t)})).filter((e=>e.ok&&e instanceof m.L))}async function v(e,t,i){if(null!=t)if((await y(t,i)).some((t=>t.cmp(e)>=0)))g().info("saveIfBetter(): no-op for "+t);else{const i=t.join((0,o.shortFsStringSha)(e.s)+".txt");try{return await i.writeFile_(e.s),(0,d.ee)().emit("reloadLicenses"),(0,a.isWebService)()&&(0,f.addStateEvent)("reloadLicenses"),g().info("saveIfBetter(): wrote to "+i),i}catch(e){return void g().error("saveIfBetter(): failed to save license to "+t,e)}}}t.writeLicense=async function(e,t){const i=await(0,p.vok)(e,"candidate",t);if(null==i)return g().error("!ok",e);await v(i,(0,c.libraryDataDirPosixFile)()?.join((0,p.k)().d),t),await v(i,(0,s.map)((0,u.configDir)(),(e=>h.BaseFile.for(e).join((0,p.k)().d))),t),await p.m.refresh()},t.licensesInDirectory=y,t.saveIfBetter=v},34474:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allRecentLogEntries=t.recentLogFiles=void 0;const r=i(40958),s=i(42659),n=i(41400),a=i(96249),o=i(68708),l=i(34666),u=i(20214),c=i(71371),d=i(50213),h=i(42638),f=i(31562),m=i(98314),p=i(89968),g=i(28874),y=i(4904),v=i(57902),w=i(89241),b=i(83954);function S(e=10*s.minuteMs){const t=Date.now()-e;return(0,u.thenMap)(p.DirectoryEntry.for(g.Settings.logDir.valueOrDefault),(e=>e.filterDescendantFiles((async e=>[".log",".log.gz"].includes(e.ext)&&(0,l.gte)(e.mtimeMs(),t)))))}t.recentLogFiles=S,t.allRecentLogEntries=async function(e=50){(0,b.writeRecentLogEntries)();const t=(0,o.fromEntries)(v.LogLevels.values.map((t=>[t,new c.BoundedGreatestSet(e,y.logEntrySorter)]))),i=Date.now()-s.hourMs,p=(0,d.mkLogger)("allRecentLogEntries()");return await(0,u.thenMap)(S(),(e=>(0,h.withBoundedConcurrency)({name:"allRecentLogEntries()",laters:e.map((e=>async()=>{try{const a=[],o=new w.LogReader(e,(e=>a.push(e)));for(await(0,f.untilTrue)((()=>o.ready()),{timeoutMs:10*s.secondMs});!o.complete()&&!o.hasErrors();){const e=o.shift();null==e?await(0,n.delay)(5):e.ts>i&&t[e.l]?.add(e)}(0,r.isNotEmpty)(a)&&(p.warn("Read error(s) for "+e,a),a.some((e=>"Z_BUF_ERROR"===e.code||(0,m.errorToS)(e).includes("unexpected end of file")))&&(0,l.lt)(e.mtimeMs(),Date.now()-s.minuteMs)&&(p.warn("Unlinking corrupt logfile "+e),await e.unlink_()))}catch(t){p.warn("Failed to read entries from "+e,t)}}))}))),(0,a.flatten)((0,o.values)(t).map((e=>e.vacuum()))).sort(((e,t)=>(0,l.cmp)(e.ts,t.ts)))}},49794:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),s=i(19851),n=i(40958),a=i(22573),o=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,s.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,a.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,n.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),s=i(23560),n=i(66184),a=i(72210);class o{log(e,t,i,r){this.enabled(e,t)&&(0,a.pushLogEntries)({ts:Date.now(),l:e,from:(0,s.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,n.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=o,o.instance=(0,r.lazy)((()=>new o))},14593:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),s=i(22573),n=i(26905),a=i(55835),o=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,s.toNotBlank)(e)??(0,n.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,o.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),s=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:s}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,a.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,o.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),s=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof s.LogWriter))}},28981:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),s=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new s.PlaintextLogFormatter))},31256:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(41400),o=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,n.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,a.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,s.uniq)((0,s.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,o.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,o.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const n=i(77030),a=i(19851),o=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),v=i(31256),w=i(28538),b=(0,a.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),S=String.fromCharCode(0);t.logBroadcaster=(0,a.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,o.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&b().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,n.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{b().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){b().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),s(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,n){if(this.enabled(e,t))try{const a=this.socket;null==a?s(this,r,"f").call(this):a.write(this.logFormatter.format(e,t,i,n)+S)}catch(r){b().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:n,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),s=i(42659),n=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??n.Settings.logDir.valueOrDefault,(0,s.fmtIsoDate)(t??new Date))}},12495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogDirCleanup=void 0;const r=i(19851),s=i(42659),n=i(23560),a=i(79267),o=i(32144),l=i(28874);t.LogDirCleanup=(0,r.lazy)((()=>(0,n.isBillingService)()?void 0:a.FileCleanup.for({name:"logDirCleanup",rootNativePath:()=>l.Settings.logDir.valueOrDefault,staleMs:s.weekMs,isPrunable:e=>(0,o.isLogExt)(e.ext)})))},4904:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),s=i(31586),n=i(51926),a=i(57902);t.isLogEntry=function(e){return null!=e&&(0,s.isNumber)(e?.ts)&&(0,n.isString)(e?.msg)&&a.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),s=i(57902);class n{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,s.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,s.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=n,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new n(s.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>s.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,s.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,s.set(this,[]),n.set(this,(0,l.lazy)((()=>{o(this,s,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:o(this,s,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>o(this,n,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=o(this,r,"m",a).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=o(this,r,"m",a).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){if(null==e||0===o(this,s,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return o(this,s,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),s=i(31586),n=i(50989);t.LogLevels=(0,n.strEnum)("fatal","error","warn","info","debug","trace");const a=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??a},t.levelGte=function(e,i){return(0,s.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const o=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return o.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),s=i(68708),n=i(20214),a=i(51926),o=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,a.isString)(i)||Buffer.isBuffer(i))return(0,a.ellipsize)(i.toString(),256,32);if((0,o.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,n.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const o=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,s.keys)(i),(0,s.keys)(o));return(0,r.isNotEmpty)(c)&&(o["…"]="omitted: "+(0,a.ellipsize)(c.join(", "),128,32)),o}return i}},89241:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogReader=void 0;const d=i(73024),h=i(38522),f=i(4001),m=i(14977),p=i(33456),g=i(92322),y=i(4904),v=i(98192);t.LogReader=class{constructor(e,t){if(r.add(this),this.f=e,this.start=Date.now(),this.lines=new g.SortedSet(y.logEntrySorter),s.set(this,!1),n.set(this,!1),a.set(this,!1),this.from=(0,f.stripCopySuffixFromName)(e.name),this.fileStream=(0,d.createReadStream)(e.nativePath,{autoClose:!0}),!(0,m.isExtOrCompressedExt)(e.ext,".log"))throw new Error(e+" is not a logfile");this.stream=(e.ext.toLowerCase().endsWith(".gz")?this.fileStream.pipe((0,h.createGunzip)()):e.ext.toLowerCase().endsWith(".br")?this.fileStream.pipe((0,h.createBrotliDecompress)()):this.fileStream).pipe(new p.LineReader).on("error",(e=>{t(e),u(this,a,!0,"f")})),this.stream.on("data",c(this,r,"m",o).bind(this)),this.stream.on("close",(()=>{this.fileStream.resume(),u(this,s,!0,"f")})),this.stream.on("end",(()=>{u(this,s,!0,"f")}))}toString(){return"LogReader("+this.f.nativePath+")"}status(){return{hasErrors:c(this,a,"f"),ended:c(this,s,"f"),destroyed:this.stream.destroyed,lines:this.lines.length,paused:c(this,n,"f")}}hasErrors(){return c(this,a,"f")}get ended(){return c(this,s,"f")}ready(){return this.ended||this.lines.length>32}complete(){return this.ended&&0===this.lines.length}peek(){return this.ready()?this.lines.at(0):void 0}shift(){const e=this.lines.shift();return null!=e&&c(this,r,"m",l).call(this),e}shiftLte(e){const t=this.lines.shiftLte(e);return t.length>0&&c(this,r,"m",l).call(this),t}},s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e){if(null===e)u(this,s,!0,"f");else{const t=(0,v.chunkToLogEntry)(e);null!=t&&this.lines.add({...t,from:this.from}),this.lines.length>10240&&!c(this,n,"f")&&(this.fileStream.pause(),u(this,n,!0,"f"))}},l=function(){this.lines.length<1024&&c(this,n,"f")&&(this.fileStream.resume(),u(this,n,!1,"f"))}},24068:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),s=i(76760),n=i(1708),a=i(87997),o=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),v=i(22277),w=i(25764),b=i(38836),S=i(99331),P=i(42638),_=i(76596),T=i(98314),M=i(89968),E=i(29882),k=i(28874),D=i(28981),x=i(20839),C=i(21727),F=i(66184),A=i(57902),I=i(72210),O=i(98192);function L(e){const t=(0,D.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=L;class R extends b.EndableWrapper{constructor(e=void 0,t=L){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,o.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,k.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,E.mkdirp_)(e),this.root=await M.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=s.sep+(0,p.serviceName)()+"-"+n.pid+"-",n.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,a.setInterval)((()=>this.flush()),x.DefaultLogFlushMs/2),this.scanTimeout=(0,a.setInterval)((()=>this.scan()),u.minuteMs),n.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,S.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,F.ifLog)(A.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,s.join)(e,i))}))}catch(t){return void(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,T.errorToS)(t))))}}))}async scan(e=!1){if((0,S.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,_.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,S.ending)()||this.ended)return;const t=(0,C.datedLogDir)(this.root.nativePath);try{await(0,E.mkdirp_)(t),this.watchDir(t)}catch(e){(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,T.errorToS)(e))))}(0,S.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,a.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,a.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await M.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(r,i))return;await(0,f.thenMap)((0,O.readLogEntries)(e,{start:r,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,T.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,o.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),s=i(82328),n=i(28981),a=i(20839),o=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(o.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,s.stdoutEnded)()||console.log((0,n.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*a.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),v=i(31586),w=i(409),b=i(23560),S=i(81168),P=i(78406),_=i(25764),T=i(20197),M=i(14977),E=i(36868),k=i(28874),D=i(32105),x=i(20839),C=i(21727),F=i(66184),A=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class O extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*x.DefaultLogFlushMs),rank:_.EndableRanks.logger,unref:!0,onEnd:()=>c(this,s,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,s.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:D.ConsoleLogger.instance(),flushEveryMs:x.DefaultLogFlushMs,processName:b.processName,logFilter:F.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",n).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const s={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(s.meta=(0,A.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(s)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=O,s=new WeakMap,r=new WeakSet,n=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),s=e.splice(0,i);this._linesSinceRotate+=s.length,t.write(s.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},a=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},o=function(e){return t=>(c(this,r,"m",a).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,S.stripAnsiEsc)(this.logOpts.processName()),t=await(0,T.ensureNewNativePath_)({nativePath:(0,f.join)((0,C.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,r,"m",o).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,E.endStream)(e.stream),k.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,M.gzip_)(e.nativePath))}catch(e){c(this,r,"m",a).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(68708),o=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,a.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,s.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,n.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),s=i(84542),n=i(4001),a=i(13047),o=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,o.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,n.stripCopySuffixFromName)(e.name),r=[],o=await(0,a.zcat)(e.nativePath,t);if(null!=o)for(const e of(0,s.splitLines)(o)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),s=i(76790),n=i(68708),a=i(89788),o=i(57902);t.SentLogLevels=(0,r.lazy)((()=>o.LogLevels.values.filter((e=>e!==o.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,n.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new a.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,n.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,n.values)(l()))e.push(...t.toA());return(0,s.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),s=i(41400),n=i(55835),a=i(37975),o=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),v=i(66184),w=i(28538),b=i(24068),S=i(43705),P=i(51879);function _(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),T();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new S.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,n.map)((0,y.logBroadcaster)(),(e=>i.push(e))),o.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&b.LogTail.instance()}function T(){const e=h.Settings.logColor.valueOrDefault;(0,a.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=_,t.setupLogFormatter=T,(0,s.later)((()=>{h.Settings.logStdout.watchLater(_),h.Settings.logDir.watchLater(_),h.Settings.tailLogs.watchLater(_),h.Settings.logColor.watchLater(T),h.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},83954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeRecentLogEntries=void 0;const r=i(89179);t.writeRecentLogEntries=function(){return(0,r.currentFileLogger)()?.writeRecentLogEntries()}},82647:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const a=i(57975),o=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,a.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return n(this,r,"m",s).call(this,-1)}get p29(){return n(this,r,"m",s).call(this,-.5)}get p38(){return n(this,r,"m",s).call(this,-.25)}get p69(){return n(this,r,"m",s).call(this,.5)}get p84(){return n(this,r,"m",s).call(this,1)}get p98(){return n(this,r,"m",s).call(this,2)}get p99(){return n(this,r,"m",s).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,o.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,o.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,o.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,s=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),s=i(55835),n=i(31586),a=i(30976),o=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,n.clamp)(0,i,(0,n.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,s.map2)(e,t,((e,t)=>(0,r.sum)((0,o.zip)(u(e,i),u(t,i)),(([e,t])=>(0,n.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,n.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,a.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),s=this.clampValue(e);let n=0;for(let e=0;ea?(n+=1,i[t]=a):r[t]=a}return n}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let s=0;s(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,n.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;in?(t+=1,s.min=n):s.max=n}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},76752:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtEstimate=t.ETA=void 0;const r=i(42659),s=i(75240),n=i(31586),a=i(97352),o=i(82647);function l(e){return(0,n.gt0)(e)?e<=r.minuteMs?"less than a minute remains":"about "+(0,s.fmtDuration)(e,1,{plural:"remains",singular:"remain"}):void 0}t.ETA=class{constructor(){this.taskMillis=new o.Average(10)}push(e){(0,a.mapGt0)(e,(e=>this.taskMillis.push(e)))}clear(){this.taskMillis.clear()}avg(){return this.taskMillis.p69}etaMs(e){const t=this.avg();if(null==t)return;const i=t*e;return i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.kmeans=void 0;const r=i(76790),s=i(93973);t.kmeans=function(e,t,i){const n=s(e,t,i);return{...n,centroids:(0,r.sortBy)(n.centroids.filter((e=>e.size>0)),(e=>-e.size))}}},31843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const r=i(76790);function s(e,t,i=.5){return(1-i)*e+i*t}t.lerp=s,t.lerp2d=function(e,...t){const i=(0,r.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[n,a]=(0,r.sortBy)(i,(e=>e.x)),o=a.x-n.x,l=(e-n.x)/o;return s(n.y,a.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},75503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modeReduce=t.submatrixCollect=t.greatestHalf=t.leastVariantQuarter=t.leastMagQuarter=t.submatrixMode=t.submatrixStdDev=t.submatrixMagnitude=t.submatrixForEach=t.index1D=t.slice=t.matXvec=t.vecXvec=void 0;const r=i(40958),s=i(31586),n=i(48884),a=i(82647),o=i(70417);function l(e,t,i,r){const s=Math.floor(Math.max(0,t.row)),n=Math.ceil(Math.min(e.row,i.row)),a=Math.floor(Math.max(0,t.col)),o=Math.ceil(Math.min(e.col,i.col));for(let t=s;t(0,s.mapFinite)(e[t],(e=>n+=e*e)))),Math.sqrt(n)}function c(e,t,i,r){const n=new a.Average;return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),n.stdDev}function d(e,t,i,r){const n=[];return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),(0,o.mode)(n)}t.vecXvec=function(e,t){return e.map(((e,i)=>e*t[i]))},t.matXvec=function(e,t){return e.map(((e,i)=>{if(e.length!==t.length)throw new Error("misshaped matrix on row "+i);return(0,o.sumf)(e,((e,i)=>e*t[i]))}))},t.slice=function(e,t,i){const s=Math.max(0,t.row),n=Math.min(e.length,i.row),a=Math.max(0,t.col),o=Math.min(e[0].length,i.col);return(0,r.range)(s,n,(t=>e[t].slice(a,o)))},t.index1D=function(e,t,i){return t*e.col+i},t.submatrixForEach=l,t.submatrixMagnitude=u,t.submatrixStdDev=c,t.submatrixMode=d,t.leastMagQuarter=function(e,t){const i=t.col,r=t.row,s=[u(e,t,{col:i/2,row:0},{col:i,row:r/2}),u(e,t,{col:0,row:0},{col:i/2,row:r/2}),u(e,t,{col:0,row:r/2},{col:i/2,row:r}),u(e,t,{col:i/2,row:r/2},{col:i,row:r})];return(0,n.leastIndex)(s)},t.leastVariantQuarter=function(e,t){const i=t.col,r=t.row;return(0,n.leastIndex)([c(e,t,{col:i/2,row:0},{col:i,row:r/2}),c(e,t,{col:0,row:0},{col:i/2,row:r/2}),c(e,t,{col:0,row:r/2},{col:i/2,row:r}),c(e,t,{col:i/2,row:r/2},{col:i,row:r})])},t.greatestHalf=function(e,t){const i=t.col,r=t.row,s=[d(e,t,{col:0,row:0},{col:i,row:r/2}),d(e,t,{col:0,row:0},{col:i/2,row:r}),d(e,t,{col:0,row:r/2},{col:i,row:r}),d(e,t,{col:i/2,row:0},{col:i,row:r})];return(0,n.greatestIndex)(s)},t.submatrixCollect=function(e,t,i){const r=[];return l(e,t,i,(e=>r.push(e))),r},t.modeReduce=function(e,t,i){const o=Math.floor(t.col/i.col),u=Math.floor(t.row/i.row),c=new a.Average(Math.ceil(o*u));return(0,n.concat)(...(0,r.stepRange)(0,t.row,u,(i=>(0,r.stepRange)(0,t.col,o,(r=>(c.clear(),l(t,{col:r,row:i},{col:r+o,row:i+u},(t=>(0,s.mapFinite)(e[t],(e=>c.push(e))))),c.sampleMode))))))}},36372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stableContentShuffle=t.stableIndexShuffle=t.factors=t.primeSeeds=t.primeInt=t.primes=t.prng=t.prngOrderByClause=void 0;const r=i(76790),s=i(42659),n=i(31586),a=i(97238),o=i(50597),l=i(9103),u=i(55222);function c(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e),u=(s*i*i+n*i)%r,c=(a*i+o)%r;return Math.round((u*c+l)%r)}function d(e){return(0,u.encodeDigits)(a.PrimesPerBin,e,a.PrimeBins).map(((e,i)=>t.primes[i][e]))}t.prngOrderByClause=function(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e);return`(((${s}*${i}*${i}+${n}*${i})%${r})*((${a}*${i}+${o})%${r})+${l})%${r}`},t.prng=c,t.primes=[[353868013,472882027,479001599,517294153],[1012573,1230587,1355297,1572751],[756065159,812182027,899809343,989450477],[3959297,4514113,4823201,5133127],[573259391,666101999,694847533,746151647],[2275327,2770513,3073703,3511973],[173313197,182557181,203457869,222230231],[6054613,6189107,7752103,9852103]],t.primeInt=[1012573,1101689,1183811,1196089,1230587,1355297,1419641,1483733,1572751,2275327,2770513,3010349,3073703,3118691,3174823,3511973,3959297,4514113,4690451,4823201,5133127,5375327,6019889,6054613,6189107,7752103,7752103,9852103],t.primeSeeds=d,t.factors=(0,l.memoize)((e=>{const[i,r,s,o,l,u,c,h]=d(e%a.SeedCount),f=[i/r,s/o,l/u,c/h].map((e=>(0,n.sigFigs)(e,7)));return f.push(t.primeInt[e%t.primeInt.length]),f}),{maxSize:128,ttlMs:s.minuteMs}),t.stableIndexShuffle=function(e,t=1){return(0,r.sortBy)(e,((i,r)=>c(t,r,e.length)))},t.stableContentShuffle=function(e,t=1){return(0,r.sortBy)(e,(e=>(0,o.numericSha)(String(e)+t)))}},55222:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),s=i(22573),n=i(55835),a=i(32639),o=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,n.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,s.blank)(e))return;const t="-"===(e=(0,a.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),s=this.normalizeToken(t);return r.length>=i&&r===s}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const r=i(31586),s=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,r.toInt)(e)]??(0,s.toS)(e)}},38812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SquareMatrix=t.rotateSquareMatrix=void 0;const r=i(21605);t.rotateSquareMatrix=function(e,t){return 0===(0,r.normalizeRotation)(t)?e:new s([...e]).rotate(t).m};class s{constructor(e,t=1){if(this.m=e,this.ary=t,this.rows=Math.sqrt(e.length/t),this.rows!==Math.floor(this.rows))throw new Error(`Only square tuple matrices are supported: ${1===this.ary?"":this.ary}(${this.rows}×${this.rows}) != ${e.length}`)}index(e,t){return this.ary*(t+e*this.rows)}swap(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),s=i(65713);function n(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=n,t.safeUUID=function(){return(0,s.decuss)(n)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const o=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function v(e,t){let i=0,r=0;for(const s of e){if(null!=s){const e=t(s,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=v;class w{constructor(){r.set(this,0),s.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(a(this,s,null==n(this,s,"f")?e:n(this,s,"f")*n(this,r,"f")/(n(this,r,"f")+1)+e/(n(this,r,"f")+1),"f"),a(this,r,(t=n(this,r,"f"),++t),"f"))}get mean(){return n(this,s,"f")}}function b(e){const t=new w;for(const i of e)t.push(i);return t.mean}function S(e){const t=b(e);if(null==t)return;let i=0,r=0;for(const s of e)(0,u.isNumber)(s)&&(r++,i+=(s-t)*(s-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function _(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+a*(e-s)/n)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=b(t);if(null!=i){const e=(t.length-1)/2,r=v(t,((t,r)=>(t-i)*(r-e))),s=v(t,(e=>(e-i)**2));return 0===s?0:r/s}},t.variance=S,t.stdDev=function(e){return(0,l.map)(S(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,o.isEmpty)(e)&&(0,o.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},23624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64encodeBits=t.b64hammRatio=t.gz64decodeString=t.d=t.gz64encodeString=t.b64decode=t.b64encode=t.hex2b64=void 0;const r=i(38522),s=i(22573),n=i(97352);function a(e){const t=e.toString(16),i=t.length%2==0?"":"0";return Buffer.from(i+t,"hex").toString("base64")}function o(e){return BigInt("0x0"+Buffer.from(e,"base64").toString("hex"))}function l(e){return(0,r.gunzipSync)(Buffer.from(e,"base64")).toString("utf8")}t.hex2b64=function(e){return Buffer.from(e,"hex").toString("base64")},t.b64encode=a,t.b64decode=o,t.gz64encodeString=function(e){return(0,r.gzipSync)(Buffer.from(e,"utf8")).toString("base64")},t.d=l,t.gz64decodeString=l,t.b64hammRatio=function(e,t){return(0,s.mapNotBlank)(e,(e=>(0,s.mapNotBlank)(t,(t=>(0,n.hammRatioBigInt)(o(e),o(t))))))},t.b64encodeBits=function(e){return a(BigInt("0b0"+e.map((e=>1===e?"1":"0")).join("")))}},39471:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableServer=void 0;const r=i(27395),s=i(25764),n=i(36868);t.EndableServer=class{constructor(e,t){this.name=e,this.server=t,this._ended=!1,(0,r.addEndable)(s.EndableRanks.service,this)}get ended(){return this._ended}end(){return this._ended=!0,(0,n.closeStream)(this.server)}}},49076:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const s=r(i(48161)),n=i(19851),a=i(22573),o=i(41400),l=i(81168),u=i(28874);t.hostname=(0,n.lazy)((()=>u.Settings.hostname.value??s.default.hostname())),(0,o.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,a.blank)(e)&&!(0,a.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??s.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},93756:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.request=void 0;const s=r(i(44708)),n=i(22573),a=i(55835),o=i(97352),l=i(57159),u=i(63870),c=i(43205);t.request=async function(e,t={}){return null==t.headers&&(t.headers={}),(0,n.blank)(t.headers["user-agent"])&&(t.headers["user-agent"]=await(0,c.userAgent)()),new Promise(((i,r)=>{const n=s.default.request(e.toString(),t);n.setTimeout((0,a.orElse)(t.timeout,(0,u.commandTimeoutMs)()),(()=>{r(new l.WrappedError("Timeout fetching <"+e+">",{doNotSend:!0,retriable:!0}))})),n.on("response",(e=>{const t=[];e.setEncoding("utf8"),e.on("data",(e=>t.push(e))),e.on("end",(()=>{i({ok:(0,o.within)(200,399,e.statusCode),headers:e.headers,body:t.join(""),statusCode:e.statusCode,statusMessage:e.statusMessage})}))})).on("error",(e=>{r(e)})),(0,a.map)(t.body,(e=>n.write(e))),n.end()}))}},43205:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemUserAgent=t.simpleUserAgent=t.userAgent=void 0;const r=i(72993),s=i(17344),n=i(96175),a=i(37805),o=i(81674),l=i(28874);function u(){return r.SimpleAppName+a.version}async function c(){return u()+" ("+(0,n.osFullName)()+") "+(0,s.EditionType)().toLowerCase()+"/"+await(0,o.t)()}t.userAgent=async function(){return l.Settings.allowUserAgent.valueOrDefault?c():u()},t.simpleUserAgent=u,t.systemUserAgent=c},72308:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLocalhost=t.isLoopback=t.myExternalIp4Addresses=t.myExternalIpAddresses=t.networkMacAddresses=t.myIpAddresses=void 0;const r=i(48161),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(96249),u=i(31586),c=i(68708),d=i(50213),h=i(81168);function f(){return(0,t.myIpAddresses)().filter((e=>!g(e)))}t.myIpAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.address))))),o.minuteMs),t.networkMacAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.mac)))).filter((e=>"00:00:00:00:00:00"!==e))),o.minuteMs),t.myExternalIpAddresses=f,t.myExternalIp4Addresses=function(){return f().filter((e=>!e.includes(":")))};const m=(0,s.lazy)((()=>(0,d.mkLogger)("net.ip"))),p=[/^(?:::ffff:)?127\.\d{1,3}.\d{1,3}.\d{1,3}$/i,/^::1$/];function g(e){return(0,a.notBlank)(e)&&(127===function(e){const t=e.split(".").map((e=>(0,u.toInt)(e)));return 4!==t.length||t.some((e=>null==e||!(0,u.within)(0,255,e)))?void 0:t}(e)?.[0]||p.some((t=>null!=t.exec(e))))}t.isLoopback=g,t.isLocalhost=function(e){return m().tap({msg:"isLocalhost",level:"info",result:!(0,a.blank)(e)&&((0,t.myIpAddresses)().includes(e)||(0,t.myIpAddresses)().includes((0,h.stripPrefix)(e,"::ffff:"))||g(e)),meta:{address:e}})}},96128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),v=i(34102),w=i(26293),b=new RegExp("^"+w.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==b.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const S=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=S.exec(e)}function _(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=_,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,n.blank)(e)){if(null!=_(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void T().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs});const T=(0,s.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,o.later)((()=>(0,v.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=_(e)?r.promises.reverse(e):r.promises.resolve4(e),5*a.secondMs);if(t===c.Timeout)return T().info("nslookup("+e+"): timeout"),e;const i=t.find(n.notBlank);return null==i?(T().warn("No name found for "+e),e):i}catch(t){return T().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,n.blank)(e)&&!(0,n.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),s=i(42659),n=i(31586),a=i(97790),o=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*s.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,n.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,a.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,o.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs})},78330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const r=i(40958),s=i(22573),n=i(45599),a=i(59455),o=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),h=i(63870),f=(0,n.defer)((()=>(0,o.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,a.toA)(await async function(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return f().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,r.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(f().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),s=i(38639),n=i(19851),a=i(59958),o=i(43334);t.isDocker=(0,n.lazy)((()=>o.isLinux&&((0,s.toBoolean)(process.env[a.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),s=i(19851),n=i(54993);t.isPacked=(0,s.lazy)((()=>!(0,n.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const r=i(45599),s=i(50213),n=i(84777),a=i(68284),o=i(63870),l=i(43334),u=(0,r.defer)((()=>(0,s.mkLogger)("platform.Pacman")));t.hasPacman=(0,r.defer)((()=>l.isLinux&&(0,a.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,n.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,o.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(22573),o=i(38639),l=i(59958),u=s.default.platform();t.inspectFlag=n.default.argv.includes("--inspect")||(0,o.isTrue)(n.default.env.NODE_INSPECT),t.isCI=(0,o.isTrue)(n.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,a.notBlank)(n.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===s.default.arch(),t.isArm=null!=/^arm\b/i.exec(s.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,a.notBlank)(n.default.env.APPIMAGE)||(0,a.notBlank)(n.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,a.notBlank)(n.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=n.default.versions.electron,t.isElectron=t.isMainElectron||(0,o.isTrue)(n.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const s=r(i(73024)),n=i(19851),a=i(43334);function o(e="/proc/cpuinfo"){if(a.isWin||a.isMac)return!1;try{return null!=s.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=o,t.isRaspberryPi=(0,n.lazy)((()=>a.isLinux_arm&&o())),t.procDeviceModel=(0,n.lazy)((()=>{try{return a.isLinux?s.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},94137:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.negateFilterName=void 0;const r=i(22573),s=i(51926),n=i(83556);t.negateFilterName=function(e){if((0,r.blank)(e))return;const t=/\s/.test(e)?e:(0,n.camel2words)(e).replace(/\bphoto structure\b/gi,"PhotoStructure");return t.match(/^not\b/)?t.replace(/^not\b/,"").trim():"not "+(0,s.stripPrefix)(t,"is ")}},78984:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Predicates=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(51926),o=i(50213),l=i(94137),u=(0,r.lazy)((()=>(0,o.mkLogger)("predicates.Predicates")));class c{static async accepted(e,...t){for(const i of t)for(const t of(0,n.values)(i)){const i=await t(e);if(!1===i||(0,a.isString)(i))return!1}return!0}static async rejected(e,...t){return!await c.accepted(e,...t)}static async explain(e,...t){const i=[],r=[],s=[];for(const o of t)for(const[t,l]of(0,n.entries)(o)){const n=await l(e);!0===n?i.push(t):!1===n||(0,a.isString)(n)?r.push(t):s.push(t)}return{accepted:i,rejected:r,notApplicable:s}}static async whyRejected(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))try{const i=await r(e);if(null==i||!0===i)continue;return(0,a.isString)(i)?i:(0,l.negateFilterName)(t)}catch(e){u().warn("whyRejected() caught from "+t,{error:e})}}static async logged({a:e,logger:t,msg:i,predicates:r}){const{accepted:n,rejected:a}=await c.explain(e,...r);return t.tap({msg:i,result:(0,s.isEmpty)(a),meta:{a:e,accepted:n,rejected:a}})}}t.Predicates=c},33995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncPredicates=void 0;const r=i(68708),s=i(94137);class n{static firstFalse(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!1===s(e))return t}static firstTrue(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!0===s(e))return t}static firstDefined(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i)){const i=s(e);if(null!=i)return{name:t,result:i}}}static accepted(e,...t){return null==n.firstFalse(e,...t)}static whyRejected(e,...t){return(0,s.negateFilterName)(n.firstFalse(e,...t))}}t.SyncPredicates=n},45643:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),s=i(59455),n=i(31562);t.existingPids=function(e){return(0,s.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,n.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(97790),w=i(59455),b=i(54993),S=i(54557),P=i(19851),_=i(50213),T=i(88158),M=i(409),E=i(78406),k=i(25764),D=i(99331),x=i(56519),C=i(46292),F=i(8769),A=i(83278),I=i(32144),O=i(29882),L=i(43334),R=i(24399),N=i(58261),B=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),j=10*p.secondMs;function z(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,O.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))B().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{B().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??L.isWin,r=await this.pidfiles(),s=await this.pids(r??[]);if((0,f.isEmpty)(s))return B().info("killOldProcs(): no pidfiles"),[];const n=[],a=[],o=await(0,N.pidInfos)(s);if(null!=o){for(const s of r){const r=await s.readJson();if(null==r){B().warn("killOldProcs(): failed to read pidfile "+s.base),await s.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){B().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+s.base,{json:r,pid:l}),await s.unlink("debug");continue}const u=o.find((e=>e.pid===l));if(null==u||!z(r,u)){B().debug("killOldProcs(): pid no longer present: unlinking "+s.base,{json:r,pidEntry:u}),await s.unlink("debug"),n.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(B().info("killOldProcs(): killing",{reason:d,json:r}),a.push(W(l,i,!1)),n.push({...r,...u}))}return a.length>0&&await Promise.allSettled(a),n}(0,F.onError)("Pids.killOldProcs(): failed to get process information")}}),a.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const a=e.pid;if(!(0,y.gt0)(a))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(a)?(i&&o(this,s,"f").delete(l),o(this,s,"f").getOrSet(l,(async()=>{const i=o(this,r,"m",n).call(this,e.pid),s=(0,v.opt)((0,T.Try)((()=>(0,O.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),a=t.getTime(),l={...e,cmd:s,startTime:a};return await i.writeJson_(l),B().debug("addPid() wrote "+i,l),i}))):(o(this,s,"f").delete(l),void B().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=o(this,r,"m",n).call(this,e);return(0,x.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{B().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==o(this,a,"f")||o(this,a,"f").ended)&&l(this,a,new E.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:k.EndableRanks.first}),"f"),o(this,a,"f")}cancelInterval(){o(this,a,"f")?.end(),l(this,a,void 0,"f")}}t.Pids=U,s=new WeakMap,a=new WeakMap,r=new WeakSet,n=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,C.configDir)(),(e=>new U(A.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const s=i(31421),n=i(48161),a=r(i(1708)),o=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),v=i(84968),w=i(48963),b=i(56519),S=i(84777),P=i(8103),_=i(45879),T=i(43334),M=i(24399),E=i(45643),k=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function D(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function x(e){if(T.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,_.readFileMaybe)("/proc/"+i+"/stat")));return k().tap({msg:"pidInfoProc",result:(0,o.compact)(t)})}(e);const t=(0,E.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,T.isWin?I:N)).filter((e=>D(e)&&t.includes(e.pid)));return k().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=D,t.pidInfo=async function(e){return(0,b.thenMap)(x([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,o.isEmpty)(e)?[]:(0,b.thenMap)((0,E.existingPids)(e),(t=>{const i=[a.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=x;const C="Get-Process",F="| Select-Object -Property Id,ProcessName,StartTime";function A(e){return(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).join(",")}async function I(e){if(M.PowerShell.instance().ended)return R(e);const t=[C,"-Id",A(e),"-ErrorAction SilentlyContinue",F].join(" ");return(0,b.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const O={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},L=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,o.isNotEmpty)(e)){const i=(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",L.join(","));const i=await(0,S.stdoutResult_)((0,P.wmic)(),t,O),r=(0,d.onlyReqValued)((0,p.parseFixed)(L,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return r.find((e=>e.pid===a.default.pid))||r.push({pid:a.default.pid,start:new Date(v.StartTs),cmd:"node "+a.default.title}),r}async function N(e){return t=(await(0,S.stdoutResult_)("ps",["-p",A(e),"-wwwo","pid,lstart,command"],{...O,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const B=(0,g.lazy)((()=>{try{if(T.isLinux)return(0,c.toGt0)((0,s.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){k().warn("clk_tck failed",{error:e})}return 100})),j=(0,g.lazy)((()=>Date.now()-(0,n.uptime)()*u.secondMs)),z=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=z.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,s=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(s)?{pid:i,cmd:r,start:new Date(j()+s/B()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(29882),o=i(97352);t.progressEvtToS=function(e){const t=(0,s.blank)(e.path)?null:(0,a.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,n.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,s.notBlank)(e.op)&&(0,o.within)(0,100,e.pct)}},41944:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),s=i(42659),n=i(31586),a=i(12089),o=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new o.TTLMap(15*s.secondMs))),t.recentDone=(0,r.lazy)((()=>new o.TTLMap(2*s.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,n.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,a.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),s=i(31586),n=i(409),a=i(78406),o=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends a.EndableInterval{constructor(e,t,i,s=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:s,rank:o.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=s,this.start=Date.now(),this.onInterval=(0,n.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,s.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,s.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},38156:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushProgressObserver=void 0;const r=i(31586),s=i(41944);t.PushProgressObserver=class{constructor(e,t){this.context=e,this.total=t,this.start=Date.now()}toJSON(){}incrProgress(e=1){this.onProgress(e+(this.current??0))}onProgress(e){this.current=(e??this.current??0)+1,(0,r.gte)(this.current,this.total)&&(this.done=!0),this.emit()}completed(){this.done=!0,this.current=this.total,this.emit()}emit(){(0,s.emitProgressEvt)({...this.context,pct:(0,r.pct)(this.current,this.total),elapsedMs:Date.now()-this.start,done:this.done})}}},24399:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),v=i(99331),w=i(56519),b=i(31562),S=i(84777),P=i(34102),_=i(43334),T=i(28874),M=i(63870),E="{ready}",k=" | ConvertTo-Json -Compress";function D(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=D,(0,o.later)((()=>(0,P.ee)().on("clearCache",(()=>x.instance.prior()?.clearMockResults()))));class x extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,S.execFile)("powershell",T.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${E}"}`,...(0,n.mapNotBlankOr)(T.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:E,fail:"Error",exitCommand:"exit",maxProcs:T.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:a.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),T.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(T.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,k),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,s)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,s)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,k),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,n.blank)(t.stdout)||(0,n.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+D(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=x,x.instance=(0,s.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new x})),t.checkPowerShell_=async function(){const e=x.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,n.blank)(t)){const t=await(0,b.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),s=i(38639),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toBoolean})}}t.BooleanSetting=a},90536:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).flatMap(parseFloat).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=o},75164:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).filter(r.notBlank).flatMap(s.toInt).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,s.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=o},10546:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),s=i(22573),n=i(45599),a=i(50213),o=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,n.defer)((()=>(0,a.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,o.trimQuotes)(e);return void((0,s.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,s.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),s=i(91655),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,s.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=a;class o extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=o},9945:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.FloatSetting=a},69589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.forceContextOrSetting=t.pickForceContext=void 0;const r=i(38639),s=i(68708),n=i(50989),a=i(76740),o=i(28874),l=(0,n.strEnum)("forceSync","forceFilters","skipPreviews","forceRebuildPreviews","skipAssetTagging","recountAllTags","skipAssetRepair");t.pickForceContext=function(e){return(0,s.pick)(e,...l.values)},t.forceContextOrSetting=function(e){const t={...(0,s.pick)(e??{},"retries","halt","path"),...(0,s.fromEntries)(l.values.map((t=>[t,e?.[t]??(0,r.isTrue)(o.Settings[t]?.valueOrDefault)])))};return t.retries??(t.retries=0),t.halt??(t.halt=new a.Abortable),t}},74589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt})}}t.IntegerSetting=a},86941:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAndArchiveSystemSettingsDir_=t.mergeUserDataDirs_=void 0;const r=i(19851),s=i(59455),n=i(72993),a=i(46292),o=i(95696),l=i(50213),u=i(83179),c=i(28874),d=i(2858),h=i(84438),f=(0,r.lazy)((()=>(0,l.mkLogger)("settings.MergeConfigDirs")));async function m(e,t){let i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+e.baseWithGrandparent+" => "+t.baseWithGrandparent+")");const r=await e.resolve_(),n=await t.resolve_();if(null==r||null==n||n.nativePath===r.nativePath)return void i.info("no-op, missing or same directory",{priorResolvedConfigDir:r?.nativePath,currentResolvedConfigDir:n?.nativePath});if(i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+r.baseWithGrandparent+" => "+n.baseWithGrandparent+")"),!await r.isDirectory())return void i.info("no-op, prior directory doesn't exist");{const e=r.join(h.SettingsToml);if(await e.isNonEmptyFile()){const t=n.join(h.SettingsToml);await(0,d.readSystemSettings)(e),i.info("read prior settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.readSystemSettings)(t),i.info("read current settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.writeSystemSettings_)(t)}}{const e=r.join("licenses"),t=n.join("licenses");for(const r of(0,s.toA)(await e.childFiles())){const e=t.join(r.base);if(await e.notExists())try{await r.copyFile_(e),i.info("Copied license "+r.base)}catch(e){i.warn("Failed to copy license "+r.base,e)}}}const a=n.join("old");try{const e=await r.renameYMDHMS_({subdir:a.nativePath});i.info("merged and archived to "+e)}catch(e){i.warn("Failed to archive to "+a,e)}}t.mergeUserDataDirs_=async function(){const e=(0,a.configDir)();if(null==e)return;const t=o.PosixFile.for(e);for(const e of[t.join((0,n.AppName)()),t.join((0,n.AppName)().toLowerCase()),t.parent().join((0,n.AppName)().toLowerCase())])try{await m(e,t)}catch(i){f().error("Failed to merge "+e+" and "+t,i)}f().info("done")},t.mergeAndArchiveSystemSettingsDir_=m},4175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),s=i(22573),n=i(38639),a=i(42659),o=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function v(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function w(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){_(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&v(),y("strictDeduping",e)&&w(),(y("optOut",e)||y("noNetwork",e))&&T()},t.handleDeprecatedSettings=async function(){if((0,n.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,s.blank)(m.Settings.assetPathnameFormat.value)&&(0,s.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*a.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=v,t.setStrictDeduping=w;const b=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],S={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function _(e){for(const t of b)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:S;for(const[e,i]of(0,o.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function T(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=_,t.disableExternalNetworkRequests=T},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),s=i(53265),n=i(87652);class a extends n.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,s.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=a},23561:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.OptionalFloatSetting=a},69005:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=a},87652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=s},4936:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathToLibraryAsset=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(55835),l=i(51926),u=i(50213),c=i(81168),d=i(79842),h=i(21330),f=i(51275),m=i(29882),p=i(28874),g=(0,s.lazy)((()=>(0,u.mkLogger)("settings.PathToLibraryAsset")));function y(e){return(0,a.blank)(e)?"":"'"+e.replace(/'/g,"′")+"'"}t.pathToLibraryAsset=function(e,t){const i=(0,d.datedToDateTime)(e)??(0,o.map)((0,h.datedToISO)(e),(e=>r.DateTime.fromISO(e)));if(null==i||!i.isValid)return g().tap({msg:"pathToLibraryAsset(): failed to convert to a valid date",result:void 0,meta:{capturedAt:e,src:t,dt:i}});const s=(0,f.hasZone)(e),a=p.Settings.assetPathnameFormat.valueOrDefault,u=(0,c.splitKeep)(a,/((?:GRAND)?PARENT|BASE|NAME|EXT|ISO)/g);for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),s=i(83556);t.nameFromEnv=function(e){return(0,s.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,s.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const a=i(19851),o=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),v=i(40583),w=i(81168),b=i(44198),S=i(96706),P=i(34102),_=i(28283),T=i(81075),M=i(98778),E=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,a.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?n(this,r,"m",s).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?n(this,r,"m",s).call(this,e??t)+": "+i:null==this.fromEnv(e)?n(this,r,"m",s).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,S.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,b.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,o.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,o.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,o.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return T.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,b.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&S.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,b.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&S.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,S.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],E.WrapComments);function i(e,i){(0,o.isEmpty)(i)||t.push(...(0,w.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],E.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,w.wrap)(["",e+": "+r],E.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,s=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),s=i(76760),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),v=i(79840),w=i(7282),b=i(12801),S=i(4328),P=i(70488),_=i(84248),T=i(5531),M=i(99315),E=i(34365),k=i(34580),D=i(96706),x=i(50274),C=i(33866),F=i(52086),A=i(48584),I=i(45969),O=i(43334),L=i(24540),R=i(70379),N=i(71300),B=i(33209),j=i(48987),z=i(68268),V=i(61208),W=i(99023),U=i(30577),q=i(1485),H=i(19861),$=i(55111),G=i(30933),J=i(22859),K=i(71988),Y=i(38483),X=i(90536),Z=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),se=i(9945),ne=i(74589),ae=i(844),oe=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,n.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new oe.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new ne.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new ne.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>q.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:q.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>q.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>O.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new ne.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:$.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!O.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>O.isMac?"100ms":O.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new Z.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new se.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new ne.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new Z.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>b.PriorityClasses.BelowNormal,strEnum:b.PriorityClasses}),maxMemoryMb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new Z.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new Z.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:T.CheckpointTypes,defaultValue:T.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:E.SynchronousModes,defaultValue:E.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 1 minute is very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"1m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new X.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new Z.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new Z.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:C.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>O.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new ne.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,k.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new ne.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new Z.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new Z.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new ne.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new ne.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new Z.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,L.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,G.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new Z.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:x.SidecarExts,defaultValue:x.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new se.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new Z.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new Z.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new Z.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new Z.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new Z.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,G.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:F.CropStrategies.attention,strEnum:F.CropStrategies}),videoFrameAtSec:new se.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,a.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new ne.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(O.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new X.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>B.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new ne.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new ne.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:A.SharpFailOns.truncated,strEnum:A.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>j.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:ae.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new se.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new Z.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:z.KeywordReparentingStrategies.move,strEnum:z.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function be(e){const i=((0,l.blank)(e)?"":e).split(s.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,a.uniq)(i).filter(l.notBlank).join(s.delimiter)}function Se(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=be,t.pathWithDefaults=(0,n.lazy)((()=>be((0,D.getEnv)("PATH")))),t.allSettings=(0,n.lazy)((()=>(0,o.sortBy)((0,d.values)(t.Settings),Se))),t.persistedSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,n.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,n.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),s=i(31586),n=i(7282),a=i(49776),o=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),v=i(15674),w=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{w.Settings.configDir.opts.defaultValue=o.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=a.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,n.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,n.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,s.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),v=i(54993),w=i(50213),b=i(81168),S=i(83556),P=i(37805),_=i(87290),T=i(98314),M=i(34102),E=i(83278),k=i(95696),D=i(60865),x=i(4175),C=i(83179),F=i(81075),A=i(28874),I=i(41692),O=i(84438),L=i(32707),R=i(6707),N=i(55018),B=i(10357),j=(0,r.lazy)((()=>(0,w.mkLogger)("settings.SettingsIO")));function z(e){return(0,_.libraryDataDirPosixFile)(e)?.join(O.SettingsToml)}async function V(e=(0,L.systemSettingsFile)()){if(null!=e)return Q(E.BaseFile.for(e))}async function W(){try{return(0,a.toNotBlank)((await(0,R.readTomlFile_)((0,L.systemSettingsFile)()))?.[A.Settings.libraryDir.name])}catch{return}}async function U(){return J((0,L.systemSettingsFile)())}async function q(e){return(0,m.map)(z(e),(e=>J(e)))}function H(){t.libraryHasSettings.refresh()}function $(e){const t=z(e);return j().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:A.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}t.librarySettingsFile=z,t.readSettings=(0,r.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await X()}),o.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return A.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=U,t.librarySettingsVersion=q,t.maybeUpgradeSystemSettings=async function(){P.version!==await U()&&await Y()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&P.version!==await q()&&await Z()},t.libraryHasSettings=(0,r.lazy)((()=>$())),t.libraryHasSettings.unset=()=>{j().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,M.ee)().on("clearCache",H),(0,M.ee)().on("settingsChanged",H),A.Settings.libraryDir.watchLater(H)})),t._libraryHasSettings=$;const G=/^# PhotoStructure v(?\d+\.\d+\.\d+(?:-\S+)?)$/i;async function J(e){if((0,a.blank)(e))return;const t=await E.BaseFile.for(e).firstMatchingLine(G);return t?.groups?.version}async function K(e,i){if(null==e)return void j().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),s=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...re("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","-- ","","PhotoStructure v"+(0,t.versionForSettings)())),r.push("","");let s="";for(const e of i){const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==s&&(s=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,M.ee)().emitDebounced("settingsChanged")}(s,i),j().info("writeToml(): wrote settings",{dest:s,file:e,nonDefaults:(0,C.settingsToObj)(i),wip:r}),r){const t=await(0,R.readTomlFile_)(s),i=await(0,R.readTomlFile_)(e);(0,u.eql)(t,i)?(j().info("Equivalent contents",{dest:s,file:e,a:t,b:i}),await s.unlink()):(j().info("Archiving prior, different contents",{dest:s,file:e}),await e.renameYMDHMS_({subdir:"old"}),await s.unwip_())}}async function Y(e=(0,L.systemSettingsFile)()){const t=k.PosixFile.forMaybe(e);return null!=t&&await K(t,(0,A.persistedSystemSettings)()),t}function X(e){return Q(z(e))}async function Z(e){await(0,_.setupLibraryDataDir_)((0,a.firstNotBlank)(e,A.Settings.libraryDir.value));const i=z(e);return j().info("writeLibrarySettings()",{file:i}),null!=i&&(await K(i,(0,A.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function Q(e){if(null==e)return[];const t=j().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await ee(e);return(0,s.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,T.errorToS)(e)),[]}}async function ee(e){const t=j().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,R.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const n=[],a=(0,s.compact)((0,p.entries)(r).map((([e,t])=>{const i=(0,A.getSettingByNameOrKey)(e);if(null==i)n.push(`Failed to import "${e}"${(0,m.mapOr)((0,A.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;n.push(e)}})));return t.info("loaded",{settings:(0,C.settingsToObj)(a),warnings:(0,s.toNotEmpty)(n)}),await(0,x.handleDeprecatedSettings)(),(0,x.handleMetaSettings)(a),{settings:a,warnings:n}}t.versionForSettings=(0,r.lazy)((()=>P.version)),t.writeSystemSettings_=Y,t.writeAllSettings_=function(e){return K(k.PosixFile.for(e),(0,A.persistedSettings)())},t.readLibrarySettings=X,t.writeLibrarySettings_=Z,t._readSettings=Q,t.importFileSettings_=ee;const te=(0,r.lazy)((()=>new Set([A.Settings.noNetwork,A.Settings.httpPort,A.Settings.license,A.Settings.logStdout,A.Settings.logLevel].map((e=>e.key)))));function ie(){for(const e of(0,p.values)(A.Settings))te().has(e.key)||e.unset();(0,M.ee)().emit("settingsChanged")}function re(...e){return(0,d.flatten)(e.map((e=>(0,b.wrap)(e,B.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),A.Settings.libraryDir.unset(),await Y()},t.clearSettings=ie,t.nukeSettings=async function(){ie(),await(k.PosixFile.forMaybe((0,L.systemSettingsFile)())?.unlink("trace")),await(k.PosixFile.forMaybe(z())?.unlink("trace")),(0,M.ee)().emit("clearCache"),I.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...re("",`Welcome to PhotoStructure! These are the settings for version ${(0,D.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...re("","The following settings categories are stored in the system settings.toml:","",...(0,n.sort)([...F.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,n.sort)([...F.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...re("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...re("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const n=`${e.key} or ${e.name}`,a={...e.addToJSON()};(0,s.mapNotEmpty)(e.altKeys,(e=>a.aliases=(0,h.orList)(e)));const o=(0,p.entries)(a).map((([e,t])=>`${(0,b.capitalize)((0,S.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,s.isNotEmpty)(o)&&o.push(""),i.push(...re((0,g.padding)("-",n.length),n,(0,g.padding)("-",n.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...o,`${e.key}=${(0,f.stringify)((0,v.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(98553),o=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,a.stringify)(e)}t._join=c;function d(e){return(0,o.map)(function(e){const t=(0,n.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,s.compact)((0,l.toA)(JSON.parse(t)).map(n.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,s.compactBlankish)(t.split(e));return[t]}}(e),s.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,n.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,s.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,s.isEmpty)(e)||(this.value=this.toValidValues((0,s.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,s.isEmpty)(this.values)}isNotEmpty(){return(0,s.isNotEmpty)(this.values)}toNotEmpty(){return(0,s.toNotEmpty)((0,s.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=s},72564:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),s=i(98553),n=i(55835),a=i(58305);class o extends a.StringArraySetting{constructor(e){super({toEnv:e=>(0,n.map)(e,(e=>(0,s.stringify)((0,r.uniq)(e)))),fromEnv:t=>function(e,t){return(0,r.compact)((0,a.splitStringArray)(e)?.map((e=>t.getCI(e))))}(t,e.strEnum),defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=o},80372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),s=i(81168),n=i(83179);class a extends n.Setting{constructor(e){super({toEnv:o,fromEnv:o,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function o(e){return null==e?void 0:(0,s.trimQuotes)(e)}t.StringSetting=a},32707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),s=i(55835),n=i(46292),a=i(84438);t.systemSettingsFile=function(){return(0,s.map)((0,n.configDir)(),(e=>(0,r.join)(e,a.SettingsToml)))}},80496:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),s=i(44652),n=i(22573),a=i(76850),o=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,a.debom)(e),(0,n.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,n.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,s.readFileSync)(t)):void 0}catch(e){return void(0,o.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,n.mapNotBlank)(e,(async e=>f(await(0,s.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,s.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),s=i(96249),n=i(98553),a=i(68708),o=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const s=e+" = "+(0,n.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[s]:(0,o.wrap)(s.split("\n"),i)}t.stringifyToml=function(e){return(0,s.flatten)((0,a.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,o.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},63225:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyPsEnvSettings=void 0;const r=i(68708),s=i(81168),n=i(44198),a=i(59958),o=i(28874);t.verifyPsEnvSettings=function(e=(0,n.env)(),t=.25){const i=[];for(const n of(0,r.keys)(e).filter((e=>{const t=e.toUpperCase();return t.startsWith("PS_")&&!a.IgnorableEnvKeys.includes(t)}))){const r=e[n],a=(0,o.ciSettings)().lookup(n);if(null!=a){const e=a.value.whyInvalidEnvValue(r);null!=e&&i.push({envKey:n,msg:e})}else{const e=(0,o.ciSettings)().lookupNearest(n,t);null==e?i.push({envKey:n,msg:`No setting was found like "${n}"`}):(0,s.equalsIgnoreCase)(e.key,n)||i.push({envKey:n,msg:`Did you mean setting "${e.value.key}"?`})}}return i}},10357:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const r=i(54993),s=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=a(e[t]);if(null!=i)return i}};const n=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function a(e){const t=(0,s.extractFloat)(e);if(null==t)return;const i=(0,r.toS)(e).toLowerCase();for(const e of n)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),s=i(81168);t.bname=function(e,t=!0){let i=(0,s.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,s.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),h=i(31586),f=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),v=i(81168),w=i(76596),b=i(79842),S=i(66649),P=i(21330),_=i(98725),T=i(928),M=i(54261),E=i(89724),k=i(17415),D=i(88600),x=i(51275),C=i(29882),F=i(17217),A=i(68284),I=i(57902),O=i(28874),L=i(65162),R=i(71300),N=i(14036),B=i(61424),j=(0,s.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function z(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,f.isObject)(e)&&(0,o.notBlank)(e.nativePath)&&(0,b.isDated)(e.date)&&(0,o.notBlank)(e.src)}t.capturedAtSrcFromTags=z,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class U{static fromAssetFile(e){return(0,d.map)((0,E.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>U.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof U?e:W(e)?new U(e):void 0}constructor(e){var t;this.nativePath=(0,F.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,h.toGt0)(e.local)??(0,E.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,b.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(O.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,S.datedToMillis)(e.mtime)??(0,A.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:U.name,...(0,f.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,_.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,k.fmtOffsetMinutes)});return null==t?void 0:new U({...e,date:t})}spread(e){return new U({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,k.fmtOffsetMinutes)(this.offset)}get isFromTags(){return z(this.src)}get isInferred(){return!z(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,E.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,w.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,x.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,M.hasTime)(this.date)}hasMillis(){return(0,h.gt0)((0,T.getMillisecond)(this.date))}toMillis(){return(0,S.datedToMillis)(this.date)}get isValid(){return(0,D.isValidDate)(this.date)}get zoneName(){return(0,r.offsetMinutesToZoneName)(this.offset)??(0,x.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,k.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?O.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,b.datedToStartDateTime)(this.date)??(0,b.datedToDateTime)(this.date);if(null!=i)return{start:(0,E.datedToLocal)(i.minus(t)),end:(0,E.datedToLocal)(i.plus(t))};j().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:O.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),r=Math.max(t,e.fuzzyPrecisionMs());return j().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,b.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:r}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:r}})}}function q(e,t){if(null==e)return;const i=(0,n.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>U.for(e))));for(const r of t){let t=e[r],s=r;if((0,D.isValidDate)(t)){if((0,k.isValidZone)(e.tz)&&(!(0,x.hasZone)(t)||R.OverrideUTCZoneTags.includes(s))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,o.blank)(e.tzSource)?"":" from "+(0,v.stripPrefix)(e.tzSource,"from ");s+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,E.datedToLocalSec)(t),date:t,src:s,precisionMs:(0,b.datedToPrecisionMs)(t),rawValue:e[r]?.rawValue})}}const r=(0,p.leastBy)(i,(e=>(0,b.datedToStartTs)(e.date)));if(null==r)return;const s=i.filter((e=>(0,u.eql)(e.date,r.date)||e.precisionMs<=r.precisionMs&&(0,b.datedOverlap)({a:e.date,b:r.date,aPrecisionMs:e.precisionMs,bPrecisionMs:r.precisionMs}))),a=(0,p.leastBy)(s,(e=>[Math.floor(e.localSec/1e6),(0,x.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return j().debug("capturedAtFromTags()",{least:r,overlapsWithLeast:s,earliest:a}),a}function H(e,t){if(O.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,n.uniq)([(0,L.bname)(e,!0),(0,L.bname)(e,!1)])){const e=(0,_.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,b.datedToPrecisionMs)(e),l.secondMs])}}}function $(e){if(O.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,_.extractDateFromPath)(e.pathsForDateParsing)}}async function G(e){if(O.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=U,t.bestCapturedAt=function(e){const t=(0,a.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const r=await e.mtimeMs();function s(t,i){return W(i)?U.for(i):null!=i&&null!=i.date&&(0,D.isValidDate)(i.date)?U.for({nativePath:e.nativePath,date:i.date,local:(0,E.datedToLocal)(i.date),src:(0,v.uniqPath)([t,i.src]),mtime:r,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const n=function(e,t){return null==e||t||!O.Settings.usePathsToInferDates.valueOrDefault||!O.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,C.containedByNativePath)({ancestor:O.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),a=s("tags",q(t,O.Settings.capturedAtTags.values))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??s("tags",q(t,O.Settings.capturedAtTagsFallback.values))??(n?void 0:s("bname+stat",await(0,B.extractStatBname)(e)))??(n?void 0:s("path+stat",await(0,B.extractStatPathTime)(e)))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??(n?void 0:s("bname",H(e,t)))??(n?void 0:s("path",$(e)))??(O.Settings.useStatToInferDates.valueOrDefault?s("stat",await G(e)):void 0);return j().tap({level:I.LogLevels.debug,msg:"extractCapturedAt()",result:a})},t.capturedAtFromTags=function(e){return q(e,O.Settings.capturedAtTags.values)},t.capturedAtFromBasename=H,t.capturedAtFromPath=$,t.capturedAtFromStat=G},70379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const r=i(31586),s=i(97352),n=i(95696),a=i(47783),o=i(16170);function l(e){if(null!=e&&(0,o.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,r.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,s.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=n.PosixFile.for(e);return l(await(0,a.readRawTags)(t,!1))}},47783:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const s=i(77988),n=r(i(76760)),a=r(i(1708)),o=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(23838),f=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),v=i(12168),w=i(56038),b=i(4867),S=i(36557),P=i(98247),_=i(21330),T=i(98725),M=i(23467),E=i(88561),k=i(95696),D=i(17217),x=i(16287),C=i(50213),F=i(17921),A=i(7282),I=i(88158),O=i(23560),L=i(28874),R=i(12089),N=i(45255),B=i(81168),j=i(63870),z=i(15674),V=i(28544),W=i(43207),U=i(75767),q=i(12788),H=i(80495),$=i(14036),G=i(67083),J=i(3432),K=i(28630),Y=i(15912),X=i(30748),Z=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),re=i(61424),se=i(8791),ne=(0,o.lazy)((()=>(0,C.mkLogger)("exiftool.ExifTool")));let ae=!1;t.addInstanceIdsToTags=function(e){ae=e},t.setExifToolProcs=function(e){return L.Settings.exiftoolProcsPerChild.envValue=e,ue()};const oe=(0,o.lazy)((()=>new S.BatchClusterObserver("ExifTool",new s.ExifTool({useMWG:L.Settings.useMWG.valueOrDefault,backfillTimezones:L.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:L.Settings.defaultVideosToUTC.valueOrDefault,...(0,S.batchClusterOptions)((0,A.isTest)()?8:(0,O.isSyncService)()?L.Settings.exiftoolProcsPerChild.value??(0,z.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=oe();return e.ended?oe.refresh():e}function ue(e=!1){return(0,d.map)(oe.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,b.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(oe.prior(),(e=>e.ended?void 0:(0,b.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,j.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,f.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,D.toNativePath_)(e))}async function he(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function fe(e){const t=[];return L.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*v.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,B.includesIgnoreCase)(L.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return ne().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const r=i??await(0,te.readMimeType)(e),s=await e.sidecar(),n=(0,Z.isImageMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,a=(0,Z.isVideoMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,o=L.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await s.exists(),l=n||a||o;return ne().tap({msg:"writeTagDest()",result:l?s:e,meta:{src:e,tagName:t,mimetype:r,writeMetadataToSidecarsIfImage:n,writeMetadataToSidecarsIfVideo:a,writeMetadataToSidecarsIfSidecarExists:o}})}async function pe(e,i=!0){const r=k.PosixFile.for(e);if(r.isSidecar()&&(i=!1),!await r.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(r.nativePath),void ne().debug("readRawTags("+r+"): invalid file, returning null.");const s=await(0,t._readRawTags)(r.nativePath);if(null==s||!i)return s;ne().trace("readRawTags()",{pf:r,pickedFileTags:(0,f.pick)(s,"tz","tzSource",...L.Settings.capturedAtTags.values)});const n=[];for(const e of await r.jsonSidecars())n.push([e,(0,K.readJsonSidecar)(e,s.tz)]);for(const e of await r.existingExifSidecars())n.push([e,(0,t._readRawTags)(e.nativePath)]);const a={original:{},MIMEType:(0,u.mapNotBlank)(s.MIMEType,Z.normalizeMimetype),...s},o=[];for(const[e,i]of n){if(null==i)continue;const r=await i;if(null==r)continue;const s=(0,f.omit)(r,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,f.values)(s))?((a.sidecars??(a.sidecars=[])).push(e.base),o.push(...(0,g.toA)(r.History)),(0,I.assignNullishFields)(a.original,(0,f.pick)(a,...(0,f.keys)(s))),(0,f.assignFields)(a,s),ne().debug("readRawTags() sidecar had values",{sidecar:e.base})):ne().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return a.inferred=(0,G.getInferredHistoricValues)(o,e),(0,I.assignNullishFields)(a,a.inferred),a.Rotation=(0,Q.orientationToRotation)(a.Rotation),ne().debug("readRawTags() final",{pf:r,inferred:a.inferred,pickedResult:(0,f.pick)(a,"tz","tzSource",...L.Settings.capturedAtTags.values)}),a}async function ge(e,t){return null==t?void 0:(0,w.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,r=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,Z.normalizeMimetype);if((0,u.blank)(r))return void ne().debug("No mimetype for "+i);const n={...t.inferred??{},...t};if(n.inferred??(n.inferred={}),n.original??(n.original={}),L.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const t=n[e];if((0,p.isString)(t)){const i=(0,T.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(ne().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),n[e]=i)}}const o=!await(0,re.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,n,o);if(ne().debug("parseTags()",{tzMeta:l,skipSiblingInference:o}),null!=l?.tz){const e=n.tzSource!==s.defaultVideosToUTC&&void 0;for(const t of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const i=n[t];i instanceof s.ExifDateTime&&(n[t]=(0,_.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,f.assignUndefinedFields)(n.original,n,"tz","tzSource"),(0,f.assignFields)(n,l),(0,f.assignFields)(n.inferred,l)}const c=o?(0,X.extractMakeAndModel)(n):await(0,re.inferMakeAndModel)(e,n);c.Make!==(0,X.make)(n.Make)&&(n.original.Make=n.Make,n.inferred.Make=c.Make),c.Model!==(0,X.model)(c.Make,n.Model)&&(n.original.Model=n.Model,n.inferred.Model=c.Model),!(0,u.blank)(L.Settings.defaultCopyright.valueOrDefault)&&(0,q.isExifUnset)(n.Copyright)&&(n.Copyright=L.Settings.defaultCopyright.valueOrDefault);const d=(0,Y.extractLensMakeModel)(n),h=await(0,V.extractCapturedAt)(e,n,o);if(null==h)return void ne().info("No capturedAt for "+e);!o&&h.isInferred&&(n.inferred.capturedAt=h);const m=(0,H.extractExposureSettings)(n),g=await(0,ie.extractSizeInfoFromFile)(e,n);if(null==g)return void ne().info("No size info for "+i);const y={...c,mimetype:r,capturedAt:h,exposureSettings:m,...(0,se.extractTitleDescription)(n),...d,cameraId:(0,U.cameraIdFromTags)(n),imageId:(0,U.imageIdFromTags)(n),lensId:(0,U.lensIdFromLensInfo)({...d,...(0,f.pick)(n,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(n),tz:n.tz,rating:(0,ee.extractRating)(n)};(0,A.isTest)()&&(y.__parsedBy__=a.default.pid);const v={...n,...y};return ne().debug("parsedTags",{nativePath:i,skipInference:o,...y,inferred:n.inferred,original:n.original,pickedResult:(0,f.pick)(v,"capturedAt","tz","tzSource","Make","Model")}),(0,f.definedValues)(v)}catch(e){return void ne().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,f.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,f.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,M.eqlAsync)(e.sha(),t.sha())||await(0,M.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=k.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,D.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,D.toNativePath_)(e),["-"+t]);return(0,I.pluckCaseInsensitive)(i,t)}catch(e){return void ne().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=he,t.overwriteTags_=async function(e,t){try{await(0,w.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await fe(e)),e.clearThisAndParent()}))}catch(i){ne().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,w.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=fe,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,w.time)("exiftool.writeTags:"+e,(async()=>{const r=new h.MultiMap;for(const[s,n]of(0,f.entries)(t)){const t=await me(e,s,i);r.add(t.nativePath,[s,n])}for(const[t,i]of r.entriesArray()){const r=k.PosixFile.for(t),s=(0,f.fromEntries)(i);ne().info("writeTags()",{src:e,dest:t,t:s}),await le().write(r.nativePath,s,await fe(r)),L.Settings.overwriteOriginal.valueOrDefault||await he(r),r.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,x.nativePathIsFile)(e))return ne().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);ne().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...L.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,$.isVideoExt)(n.default.extname(e))?[]:["-fast"]],r=await(0,w.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{ne().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==r)return;ne().debug("_readRawTags()",{nativePath:e,pickedTags:(0,f.pick)(r,"tz","tzSource",...L.Settings.capturedAtTags.values)}),r.MIMEType=(0,u.mapNotBlank)(r.MIMEType,Z.normalizeMimetype),r.GPSDateTime??(r.GPSDateTime=(0,P.concatDateTime)(r.GPSDateStamp,r.GPSTimeStamp));for(const e of(0,f.keys)(r)){const t=r[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete r[e])}const s=(0,l.compactBlanks)([r.Error,...r.errors??[],r.Warning].map(y.toS));return(0,l.isNotEmpty)(s)&&(r.problems=s),ae&&(r.__instance=(0,F.safeUUID)()),r}}),t.parseTags=ge},75767:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(98553),o=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),h=i(54993),f=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),v=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const w=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function b(e){const t=null==e?[]:e.filter((([,e])=>!(0,n.blank)(e)));return 0===t.length?void 0:(0,a.stringify)((0,u.fromEntries)(t))}function S(e){return(0,h.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new o.MultiMap,r=[];for(const a of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(s=e[a])||(0,n.blankish)(s)||(0,l.isNumber)(s)&&(0===s||1===s)||null!=t.zeroesRe.exec((0,h.toS)(s)))continue;const o=e[a],u=S(e[a]),c=(0,t.Tag2SynonymGroup)().get(a);if(null!=c){if(i.includes(c,o)||i.includes(c,u))continue;i.add(c,o)}r.push([a,(0,l.gt0)(o)?o:u])}var s;return b(r)}function _(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function T(e){if((0,n.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([_(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(_)):(0,u.compactBlankValues)(t)}function M({a:e,b:t,field:i,desc:r,parser:s}){const n=s(e[i]),a=s(t[i]),o=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==n||null==a||(0,l.approximates)(n,a,o)?void 0:"Different "+r+": "+e[i]+" ≠ "+t[i]}function E(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,n.blank)(e.lensMake)||(0,n.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,r.lazy)((()=>{const e=new Map;for(const t of w){const i=t[0];for(const r of t)e.set(r,i)}return e})),t.Tag2Synonyms=(0,r.lazy)((()=>{const e=new Map;for(const t of w)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=b,t.renderExifUidId=P,t.decodeExifUid=T,t.findInequalFields=function(e,i){const r=T(e),n=T(i);if(null==r||null==n||e===i)return;const a=(0,f.intersection)((0,u.keys)(r),(0,u.keys)(n)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of a){const t=r[e],i=n[e];if(S(t)!==S(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of w){const t=(0,u.pick)(r,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(n,...e);if((0,u.isEmptyObj)(i))continue;const a=(0,u.values)(t).map(h.toS),o=(0,u.values)(i).map(h.toS);if((0,s.includesAny)(a,o))continue;const l=(0,f.least)((0,u.keys)(t)),c=(0,f.least)((0,u.keys)(i));return{aKey:l,aValue:r[l],bKey:c,bValue:n[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>M({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>M({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>M({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>M({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return E({...(0,v.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=E,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const r=i(22573),s=i(54993),n=/undefined|null|none|n\/a|unknown/i;function a(e){return null==e||(0,r.blank)(e)||n.test((0,s.toS)(e))}t.isExifUnset=a,t.toExifDefined=function(e){return a(e)?void 0:e}},80495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const r=i(19851),s=i(22573),n=i(31586),a=i(68708),o=i(54993),l=i(50213),u=i(97352),c=(0,r.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,s.firstNotBlank)((0,o.toS)(e.ExposureTime),(0,o.toS)(e.ShutterSpeed),(0,o.toS)(e.ShutterSpeedValue),(0,o.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,a.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,n.gt0)(e))return e;const[t,i]=(0,o.toS)(e).split("/").map((e=>(0,n.toInt)(e)));return(0,n.gt0)(t)&&(0,n.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,n.toFloat)(e);return(0,n.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),s=i(40958),n=i(96249),a=i(23838),o=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,o.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,o.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new a.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,n.flatten)((0,o.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function v(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=v,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return v(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return v(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return v(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return v(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return v(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return v(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),h=i(50989),f=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),v=i(50213),w=i(81168),b=i(66649),S=i(17415),P=i(29882),_=i(95696),T=i(17217),M=i(28874),E=i(47783);function k(e,t){return(0,d.entries)(t??{}).map((([t,i])=>D({action:e,key:t,value:i})))}function D({action:e,key:t,value:i,ts:s}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:r.ExifDateTime.fromMillis(s??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,h.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=k,t.mkHistoryRecord=D,t.InferAction="infer";const x=(0,s.lazy)((()=>(0,v.mkLogger)("tags.History")));function C(e,t){if(null==e||null==e.History||(0,f.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function F(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,o.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function A(e){if(null==e)return;const t={};for(const[i,r]of(0,d.entries)(e))(0,w.isFirstCharAZ)(i)&&(t[i]=r);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,S.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function I(e,i,r){if(null==e||(0,o.blank)(e))return void x().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const s=(0,T.toNativePath_)(e),a=await(0,E._readRawTags)(s),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!C(a,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...r??{}};if((0,n.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void x().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:r,tagsToWrite:c});x().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:r});const h=_.PosixFile.for(e);return await(0,E.overwriteTags_)(h,c),h.clearThisAndParent(),u}t.tagsContainHistory=C,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const s=(0,m.toA)(e);if((0,n.isEmpty)(s))return{};const l=(0,a.sortBy)(s.filter((e=>(0,w.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,b.datedToMillis)((0,o.mapNotBlank)(e.When,(e=>r.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,o.notBlank)(t)){const r=F(e);(0,o.blank)(r.nativePath)||(0,P.eqlNameWithoutExt)(r.nativePath,i)?u[t]=r:x().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=F,t.inferredToTags=A,t.ensureInferredHistoryRecords=async function(e,i,r){const s=k(t.Actions.infer,r),n=(M.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?A(r):void 0)??{};return M.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(n.Source=e.nativePath),x().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:s,additionalTags:n}),I(i,s,n)},t.ensureHistoryRecords=I},3432:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const s=r(i(53705)),n=i(77988),a=i(19851),o=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),h=i(17415),f=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),v=i(61424),w=(0,a.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function b(e,t,i){{const e=S(t);if(null!=e&&(0,h.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,h.isValidZone)(t.tz)||t.tzSource===n.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,o.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof n.ExifDateTime&&(0,h.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,v.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function S(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,s.default)(t,i),r=(0,h.normalizeZone)(e);return w().tap({msg:"zoneFromLatLon()",result:r,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,f.isValidDate)(i))for(const r of g.Settings.capturedAtTags.values){const s=(0,u.toDated)(t[r]);if(null==s||(0,f.isValidDate)(s))continue;const n=Math.round(15*i.diff(s,"minutes").as("minutes")/15),a=(0,h.normalizeZoneOffsetMinutes)(n),o=0===a?void 0:(0,h.normalizeZone)(a);if(null!=o)return w().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:o.name,tzSource:"infer:filename (diff with "+r+")"},meta:{dt:(0,c.datedToISO)(s),rawTzoffsetMinutes:n,normalizedOffsetMinutes:a}})}}t.maybeInferTimezone=async function(e,t,i){return w().tap({msg:"maybeInferTimezone()",result:await b(e,t,i)})},t.zoneFromLatLon=S,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const r=i(77988),s=i(40958),n=i(22573),a=i(38639),o=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),h=i(48884),f=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const s=(0,p.normalizeZone)(e?.formatted),n=r.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:s??t??r.UnsetZone});if(!0===n?.isValid)return n}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,n.toNotBlank)(e.title),Description:(0,n.toNotBlank)(e.description),GPSLatitude:(0,h.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,f.validLat)(e)?e:void 0)),GPSLongitude:(0,h.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,f.validLon)(e)?e:void 0)),GPSAltitude:(0,h.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,o.map)(e.favorited,a.isTrue),peopleNames:(0,s.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,s.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},97573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rawTagKeywords=t.parseKeywordStruct=t.isKeywordStruct=t.parseCategories=t.splitKeywords=t.splitKeyword=t.delimRe=t.keywordToPath=void 0;const r=i(77988),s=i(66150),n=i(19851),a=i(40958),o=i(22573),l=i(41400),u=i(96249),c=i(68708),d=i(59455),h=i(48884),f=i(50213),m=i(68852),p=i(81168),g=i(28874),y=(0,n.lazy)((()=>(0,f.mkLogger)("tags.KeywordTags"))),v=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordPathSeparators.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g")))));function w(e){const i=(0,t.delimRe)();return null==i?[e]:(0,a.compactBlanks)(e.split(i))}function b(e){return null==e||e instanceof r.BinaryField?[]:(0,a.compactBlanks)(Array.isArray(e)?(0,u.flatten)(e.map(b)):w(e))}function S(e){return null==e?[]:(0,p.isString)(e)?(0,o.blank)(e)?[]:[[e]]:(0,u.flatten)((0,d.toA)(e.Category).map(S).map((t=>t.map((t=>(0,a.compact)([e._,...t]))))))}(0,l.later)((()=>{g.Settings.keywordPathSeparators.watchLater((()=>v.unset()))})),t.keywordToPath=function(e){const t=v();return(0,a.compactBlanks)(null==t?[e]:e.split(t))},t.delimRe=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g"))))),g.Settings.keywordDelimiters.watchLater((()=>t.delimRe.unset())),t.splitKeyword=w,t.splitKeywords=b;const P=/^\(?none\)?$/i;function _(e){if(!(0,o.blank)(e)&&null==P.exec(e))try{const t=new s.XMLParser({textNodeName:"_"}).parse(e);return(0,u.flatten)((0,d.toA)(t?.Categories?.Category).map(S))}catch(t){return void y().warn("parseCategories() failed:",{err:t,s:e})}}function T(e){return Array.isArray(e)&&e.every(T)||null!=e&&(0,p.isString)(e.Keyword)&&(null==e.Children||Array.isArray(e.Children)&&e.Children.every(T))}function M(e){if(null==e)return[];if(Array.isArray(e)&&e.every(T))return(0,h.flatMap)(e,M);if((0,o.blank)(e.Keyword))return[];const t=(0,d.toA)(e.Children);return(0,a.isEmpty)(t)?[[e.Keyword]]:(0,h.flatMap)(t,M).map((t=>[e.Keyword,...t]))}t.parseCategories=_,t.isKeywordStruct=T,t.parseKeywordStruct=M,t.rawTagKeywords=function(e){const t=[];if(null!=e){const i=[...g.Settings.keywordTags.values];if(i.includes("Categories")){(0,h.remove)(i,"Categories");const r=_(e.Categories);null!=r&&t.push(...r)}for(const r of i){const i=(0,c.pluckDeep)(e,r)?.value;(0,o.blank)(i)||(T(i)?t.push(...M(i)):t.push(...Array.isArray(i)?i:b(i)))}}return y().tap({msg:"rawTagKeywords()",result:(0,a.compactBlankish)((0,a.uniq)(t)),meta:{t:null==e?void 0:(0,c.pick)(e,...g.Settings.keywordTags.values)}})}},15912:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(55835),o=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),h=i(28874),f=i(30748),m=(0,r.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,f.make)(e.LensMake),i=(0,f.make)(e.Make),r=[],o=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],b),u=(0,s.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:o,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&r.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==b(e))continue;(0,n.notBlank)(t)&&r.push({lensMake:t,lensModel:e,lensInfo:o});const a=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))a.includes(t)&&r.push({lensMake:i,lensModel:e,lensInfo:o});for(const i of(0,s.compactBlanks)([t,...h.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&r.push({lensMake:i,lensModel:e,lensInfo:o});a.startsWith("vr ")&&"Nikon"===i&&r.push({lensMake:"Nikon",lensModel:e,lensInfo:o})}for(const e of r){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=S(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,a.map)(e.lensInfo,S)}return(0,c.greatestBy)(r,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const v=/([\d. -]+)\s?mm\b/i,w=/\bf\/?([\d.\-]+)/i;function b(e){if((0,n.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=v.exec(e)?.[1].replace(/\s/g,""),i=w.exec(e)?.[1];return y(t)&&y(i)?S(`${t}mm f/${i}`):void 0}function S(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,a.mapOr)((0,o.toFloat)(e),(e=>String((0,o.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=b,t.cleanBogusPrecision=S,t.normalizeLensModel=function(e){return S(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(68708),o=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function h(e,t,i=""){const r=e.replace(t,i);return r===e?e:h(r,t,i)}const f=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=f.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,r.lazy)((()=>new p)),y=/\bgopro\b/i;function v(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=h(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=v(e.Make)??b(e.Software)??b(e.CreatorTool)??function(e){return y.test((0,o.toS)(e.HandlerDescription))||y.test((0,o.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,a.compactValues)({Make:t,Model:i})??{}},t.make=v;const w={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function b(e){if(!(0,s.blank)(e))for(const[t,i]of(0,a.entries)(w))if(i.test(e))return t}t.makeFromSoftware=b;const S=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=S.exec(i);null!=e&&(i=e[1].trim())}const r=(0,n.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=r)return r[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,n.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=h(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},38010:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MergedTags=t.revisionToResourceEvent=t.resourceEventToRevision=t.isSetRevision=t.isPrimitiveRevision=t.isBaseRevision=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(55835),u=i(31586),c=i(68708),d=i(67478),h=i(59455),f=i(54993),m=i(72993),p=i(50213),g=i(84885),y=i(66649),v=i(98725),w=(0,s.lazy)((()=>(0,p.mkLogger)("tags.MergedTags")));function b(e){return(0,u.isNumber)(e?.createdAt)&&(0,o.notBlank)(e?.field)}function S(e){return null==e?.op&&b(e)}function P(e){return e?.sourceIsPrimary??e?.shown??!1}function _(e){return e?.sourceModifiedTime??e?.mtime??0}t.isBaseRevision=b,t.isPrimitiveRevision=S,t.isSetRevision=function(e){return["add","delete"].includes(e?.op)&&b(e)},t.resourceEventToRevision=function(e){if(null==e||!(0,f.toS)(e.SoftwareAgent).startsWith((0,m.AppName)()))return w().tap({msg:"resourceEventToRevision() invalid",result:void 0,meta:{resourceEvent:e}});const t=e.Changed;if((0,o.blank)(t))return w().tap({msg:"resourceEventToRevision() missing Changed field name",result:void 0,meta:{resourceEvent:e}});const i=(0,c.pick)((0,o.mapNotBlank)(e.Parameters,d.parseJSON)??{},"newValue","priorValue");if((0,c.isEmptyObj)(i))return w().tap({msg:"resourceEventToRevision() missing Parameter fields",result:void 0,meta:{resourceEvent:e}});const r=(0,y.datedToMillis)((0,v.parseDated)({input:e.When}));return null==r?w().tap({msg:"resourceEventToRevision() missing createdAt (When)",result:void 0,meta:{resourceEvent:e}}):(0,o.blank)(e.Action)?w().tap({msg:"resourceEventToRevision() missing op (Action)",result:void 0,meta:{resourceEvent:e}}):w().tap({msg:"resourceEventToRevision()",result:{createdAt:r,field:t,op:"assign"===e.Action?void 0:e.Action,...i},meta:{resourceEvent:e}})},t.revisionToResourceEvent=function(e){return{Action:e.op??"assign",Changed:e.field,InstanceID:(0,l.map)(e.id,f.toS),Parameters:(0,g.stringifySorted)((0,c.pick)(e,"newValue","priorValue")),SoftwareAgent:(0,m.AppNameVersion)(),When:r.ExifDateTime.fromMillis(e.createdAt??Date.now())}},t.MergedTags=class{constructor(e){this.name=e,this.revisions=[],this.tags=[],this.logger=(0,p.mkLogger)(`MergedTags(${e})`)}addRevision(...e){this.revisions.push(...e)}addTag(...e){this.tags.push(...e),(0,a.sortBy)(this.tags,(e=>[!P(e),-_(e)]))}get(e){const t=(0,a.sortBy)(this.revisions.filter((t=>t.field===e)),(e=>e.createdAt)),i=this.tags.find((t=>null!=t[e]));let r=i?.[e];const s=[];var l;null!=r&&(0,o.mapNotBlank)((l=i,l?.SourceFile??l?.uri),(e=>s.push(e)));const u=t.every(S)&&this.tags.every((t=>!Array.isArray(t[e])));if(u){for(const i of t)null!=r&&r!==i.priorValue&&r!==i.newValue?this.logger.info("get("+e+"): skipping revision because expected prior or new value didn't match current value",{revision:i}):(r=i.newValue,s.push(`Revision@${i.createdAt}`));return null==r?void 0:{value:r,source:s}}{const e=(0,h.toA)(r);for(const i of t)if("add"===i.op&&null!=i.newValue)s.push(`Revision@${i.createdAt}`),(0,n.pushUniq)(e,...(0,h.toA)(i.newValue));else if("delete"===i.op&&null!=i.priorValue){s.push(`Revision@${i.createdAt}`);for(const t of(0,h.toA)(i.priorValue))(0,n.remove)(e,t)}return{value:e,source:s}}}}},16170:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const r=i(22573),s=i(54993),n=i(2322),a=i(277),o=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function h(e){return(0,r.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function f(e){const t=(0,s.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,n.isChrome)(t)||(0,n.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,s.toS)(e))},t.isImageMimeType=function(e){return(0,s.toS)(e).startsWith("image/")},t.isVideoMimeType=h,t.normalizeMimetype=f,t.isSharpMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,r.blank)(t)&&(h(t)?await(0,l.isVideoSupported)():(0,o.isHeifMimeType)(t)?await(0,a.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},66039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderNameTag=t.parseName=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(55835),l=i(75020),u=i(59455),c=i(50213),d=i(68852),h=i(81168),f=i(70417),m=i(28874),p=(0,r.lazy)((()=>(0,c.mkLogger)("tags.Names")));function g(e){return(0,d.matchQuotes)((0,d.escapeRegExp)(e))}const y=/(\(\s*\d+\s*-\s*[\d?]{0,4}\s*\)?)/,v=/([,\s]+(?:jr\.?|junior|sr\.?|senior|[iv]+\.?))$/i,w=/\b([A-Z‘’']+[-A-Z‘’']{2})\b/,b=/^[()[\]/.\-_]+$/;function S(e){if((0,a.blank)(e))return;let t=e.replace(/\s+/g," ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").trim();const i=(0,o.map)((0,h.spliceCapture)(t,y),(e=>(t=e.unmatched.trim(),e.captured.replace(/\s+/g,"")))),r=(0,o.map)((0,h.spliceCapture)(t,v),(e=>(t=e.unmatched.trim(),e.captured.trim()))),l=[],c=[],b=[];for(const e of m.Settings.tagNamesGiven.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(l.push(i.captured),t=i.unmatched.trim())}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesGivenSurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`(${(0,d.escapeRegExp)(e.charAt(0))}\\s*[^${(0,d.escapeRegExp)(e.charAt(0))}]+\\s*${(0,d.escapeRegExp)(e.charAt(1))})`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(c.push(i.captured),t=i.unmatched.trim())}while(null!=i)}let S;function _(e){(null==S||S>e.matchedIndex)&&(S=(0,f.min)([S,e.matchedIndex]))}if(m.Settings.tagNamesCapitalizedAsFamily.valueOrDefault){let e;do{e=(0,h.spliceCapture)(t,w),null!=e&&(_(e),b.push(e.captured),t=e.unmatched.trim())}while(null!=e)}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesFamilySurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`${(0,d.escapeRegExp)(e.charAt(0))}\\s*([^${(0,d.escapeRegExp)(e.charAt(0))}]*)\\s*${(0,d.escapeRegExp)(e.charAt(1))}`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}while(null!=i)}if(m.Settings.tagNamesLexical.valueOrDefault){const e=t.indexOf(",");e>=0&&(S=void 0,b.push(t.substring(0,e).trim()),l.push(t.substring(e+1).trim()),t="")}for(const e of m.Settings.tagNamesSurnames.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}for(const e of(0,u.toA)((0,s.mapNotEmpty)((0,s.compactBlanks)(m.Settings.tagNamesSurnamePrefixes.values),(e=>(0,n.sortBy)(e,(e=>-e.length)).map((e=>new RegExp(`\\b(${g(e)}\\s+\\S+)`,"i"))))))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}null!=S&&t.length>S&&(0,s.mapNotEmpty)((0,s.compactBlanks)(t.slice(S).split(/\s+/)),(e=>{b.push(...e),t=t.slice(0,S)}));const T=(0,s.compactBlanks)(t.split(/\s+/)),M=l.length,E=b.length;if(T.length>0)if(0===M&&E>0)l.push(...T);else if(0===E&&M>0&&1===T.length)b.push(...T);else if(1===T.length)l.push(...T);else{const e="western"===m.Settings.tagNamesOrder.valueOrDefault;b.push(e?T.pop():T.shift()),l.push(...T)}return{givenNames:P([...l,...c]),modifier:r,lifespan:i,familyNames:P(b),minFamilyNameIndex:S}}function P(e){return(0,s.uniq)((0,s.compactBlanks)(e).filter((e=>null==b.exec(e))))}function _(e){let t="";for(const i of(0,s.compactBlanks)(e))t+=i.startsWith(",")?i:" "+i;return t.trim()}function T(e,t,i){return _("western"===m.Settings.tagNamesOrder.valueOrDefault?[t,e,i]:[e,t,i])}t.parseName=S,t.renderNameTag=function(e){if((0,a.blank)(e))return[];const t=m.Settings.tagNamesFormatter.valueOrDefault,i="family/given"===t;if("family/fullname"===t||i){const t=S(e);if(null==t)return[];{const e=_([t.modifier,t.lifespan]),r=_(t.givenNames);return(0,s.compactBlanks)((0,s.notEmptyOr)(t.familyNames,[m.Settings.tagNamesDefaultFamily.valueOrDefault])).map((t=>[l.TagRoots.Who,t,i?_([r,e]):T(t,r,e)]))}}return[[l.TagRoots.Who,e.trim()]]}},95141:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const r=i(21605),s=i(54993),n=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,n.isVideoMimeType)(e.MIMEType)?(0,r.normalizeRotation)(e.Rotation):void 0)??o(e.Orientation)};const a=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function o(e){return(0,r.isRotation)(e)?e:null!=e?a.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,s.toS)(e).startsWith("Mirror")},t.orientationToRotation=o;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,r.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,r.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const r=i(55835),s=i(31586),n=i(28874);function a(e){const t=(0,s.toInt)(e);return null==t?void 0:(0,s.clamp)(-1,5,t)}function o(e){return a(e?.Rating)??(0,s.mapNumeric)((0,s.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,r.map)(e?.favorited,(e=>!0===e?n.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=a,t.extractRating=o,t.extractLiked=function(e){const t=o(e);return null==t?void 0:t>=n.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(88561),o=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,r.lazy)((()=>new a.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,s.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,n.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,o.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),s=i(40958),n=i(22573),a=i(81168),o=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,a.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const o=(0,u.isJsonExt)(i.ext),l=o||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=o||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,s.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,s.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return o&&function(e,i){const r=(0,a.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function s(e){return(0,n.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const o=s(e.slice(r.length)),l=s(i.slice(r.length));return o&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,o.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,a.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(33374),o=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),h=i(34943),f=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),v=(0,r.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),w=(0,r.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:n.minuteMs})));async function b(e,t){if(null==e)return;const i=null==t||(0,s.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const r=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return S(i,r,await(0,h.rawInfo)(e));const n=S(i,r);if(null!=n)return n;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await b(await(0,f.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function S(e,t,i){t??(t=(0,y.extractRotation)(e));const r=(0,o.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,a.isDimensions)(e)?e:void 0));if(null==r)return v().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo,fileDimensions:r}});const s=(0,a.maybeDimSwap)(r,t);return v().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:s.height,ImageWidth:s.width,aspectRatio:(0,d.aspectRatio)(s),dimensions:s,rotation:t,fileDimensions:r,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return w().getOrSetAsync(i.nativePath,(()=>b(i,t)))},t.extractSizeInfoFromTags=S},3127:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tag_fts_path=t.tag_fts_root=void 0;const r=i(54993),s=i(42231);t.tag_fts_root=function(e){const t=(0,r.toS)(e).indexOf(s.TagSep);return-1===t?"":e.substring(0,t)},t.tag_fts_path=function(e){return(0,r.toS)(e).split(s.TagSep).filter((e=>null!=e&&""!==e.trim())).join(" ")}},61424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),h=i(48884),f=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),v=i(79842),w=i(21330),b=i(98725),S=i(51275),P=i(35280),_=i(19748),T=i(88561),M=i(95696),E=i(65238),k=i(17217),D=i(57902),x=i(28874),C=i(80496),F=i(65162),A=i(28544),I=i(47783),O=i(88840),L=i(30748),R=i(16170),N=(0,n.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),B=7;async function j(e){return x.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+x.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(x.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.auto&&await(0,E.isSlowDir)(e.nativePath)&&!await(0,E.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function z(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of r){const r=(0,L.extractMakeAndModel)(await(0,I.readRawTags)(t));if((0,f.definedAndNotEql)(r.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:r});else if((0,f.definedAndNotEql)(r.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:r});else if(null!=r.Make&&null!=r.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:D.LogLevels.info,result:r,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await j(e.parent()))return;const t=await W(e);return null!=t&&(0,w.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,w.toExifDateTime)(t.before.date,(0,S.getZoneName)(t.before.date)),(0,w.toExifDateTime)(t.after.date,(0,S.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,n.lazy)((()=>new T.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await H(e),i=await z(t?.younger),r=await z(t?.older);return null==i||null==r?void 0:{before:i,after:r,index:i.index,slots:i.index+r.index+1}}))}t.beforeAfterCapturedAt=W;const U=(0,_.extFilter)(O.ExtTypes.AssetFile);function q(e){return null==e?[]:(0,a.compact)((0,h.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function H(e,t=7,i=!0){if(!await j(e.parent()))return;const r=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(U(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==r)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const s=(0,o.sortBy)(r,(e=>(0,F.bname)(e))),n=(0,k.findFileIndex)(e,s);if(n<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),H(e,t,!1)):void 0;const l=x.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[s.slice(n-2*t,n),s.slice(n+1,n+1+2*t)],d=[],h=[];for(;(0,a.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,a.isNotEmpty)(c)&&h.length=l&&h.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:h},meta:{f:e}})}t.nearestSiblings=H,t.nearestSiblingTzOffset=async function(e){if(!await j(e.parent()))return;const t=q(await H(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,B);for(const t of e){const e=await(0,I.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==r.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,a.uniq)([(0,F.bname)(e,!0),(0,F.bname)(e,!1)]),i=(0,b.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const r=await e.stat();if(null!=r){for(const e of["birthtime","atime","mtime","ctime"])if((0,v.datedOverlap)({a:i,b:r[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:r}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:r}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,b.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const r=i[e];if(null!=r&&!0===(0,v.datedOverlap)({a:t,b:r}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:s.DateTime.fromJSDate(r)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),h=i(81168);function f(e){return(0,u.toS)((0,o.isString)(e)?e:e?.name).normalize()}function m(e){return(0,r.compact)((0,l.toA)(e).map(f))}function p(e,i=t.TagSep){return m(e).map((e=>(0,o.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(n.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function v(e){return(0,n.blank)(e)?void 0:Array.isArray(e)?f((0,r.last)(e)):(0,r.last)(g(e))}function w(e,t){if((0,r.isEmpty)(e)||(0,r.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,h.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=f,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,r.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,r.uniqBy)((0,l.toA)(e),(e=>(0,r.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,r.compact)(t).map((e=>y(e))));return(0,r.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=v,t.leafIsExcluded=function(e,t){return(0,a.mapOr)(v(e),(e=>(0,h.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=w,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,s.sortBy)(e.filter(r.isNotEmpty),(e=>-e.length)))t.some((e=>w(i,e)))||t.push(i);return(0,s.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const r=i(40958),s=i(22573),n=i(68708),a=i(54993);t.extractTitleDescription=function(e){const t=(0,r.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,s.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const r of i){const i=(0,a.toS)(e[r]).trim();if((0,s.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,n.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(96249),o=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),v=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function w(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function b(e){const t=await w(e);return(0,s.uniq)((0,a.flatten)(t.map(m.uriEncodingVariants)))}async function S(e,t){if((0,n.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void v().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case o.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case o.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case o.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,n.blank)(e)?v().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=w,t.nativePath2uriVariants=b,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(S(e,t),b))),(0,s.uniq)(i)},t.uri2nativePath=S,t.uriExists=async function(e,t){const i=await S(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),s=i(57975),n=i(90595),a=i(22573),o=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",v=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class w{static isUri(e){return e instanceof w||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,s,n=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,n),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=s??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,n))}get fsPath(){return M(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:s,fragment:n}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===s?s=this.query:null===s&&(s=g),void 0===n?n=this.fragment:null===n&&(n=g),t===this.scheme&&i===this.authority&&r===this.path&&s===this.query&&n===this.fragment?this:new S(t,i,r,s,n)}static parse(e,t=!1){const i=v.exec(e);if(!i)return new S(g,g,g,g,g);const r=i[2]||g,s=x(i[4]||g),n=(i[5]||g).split("/").map(x).join("/"),a="psfile"===r&&n.startsWith("//")?n.slice(1):n,o=(0,u.toURLSearchParams)(i[7]),l=x(i[9]||g);return new S(r,s,a,o,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new S("file",t,e,g,g)}static from(e){return new S(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?w.file(r.win32.join(M(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,o.map)(this.path,(e=>(0,d.findLast)(e.split(y),a.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return E(this,e)}toJSON(){return this}[s.inspect.custom](){return this.toString()}}t.URI=w;const b=h.isWinPortable?1:void 0;class S extends w{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=M(this,!1)),this._fsPath}toString(e=!1){return e?E(this,!0):(null==this._formatted&&(this._formatted=E(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=b),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,a.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function _(e,t){let i,r=-1;for(let s=0;s=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||45===n||46===n||95===n||126===n||t&&47===n)-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),void 0!==i&&(i+=e.charAt(s));else{void 0===i&&(i=e.substr(0,s));const t=P[n];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),i+=t):-1===r&&(r=s)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function T(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function E(e,t){const i=t?T:_;let r="";const{scheme:s,query:n,fragment:o}=e;let{authority:l,path:u}=e;if(s&&(r+=s,r+=":"),(l||"file"===s)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,a.mapNotBlank)(n,(e=>r+="?"+e)),o&&(r+="#",r+=t?o:_(o,!1)),r}function k(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+k(e.substr(3)):e}}t.encodeURIComponentFast=_,t.uriToFsPath=M;const D=/(?:%[\dA-Z][\dA-Z])+/gi;function x(e){return e.startsWith("xn--")?(0,n.toUnicode)(e):e.match(D)?e.replace(D,(e=>k(e))):e}t.percentDecode=x,t.toURI=function(e){return w.isUri(e)?e:w.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),s=i(40958),n=i(50357),a=i(89937),o=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",a.PS_LOCAL_FILE_SCHEME,a.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,o.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&f(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,n.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,s.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),s=i(22573),n=i(51926),a=i(89937),o=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,s.blank)(e))return;if(null==(t=null!=t&&(0,o.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,s.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,n.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:a.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==a.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,s.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,n=(0,s.notBlank)(t)&&!t.includes(i);if(n&&!(0,s.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const o=await(0,c.bestVolumeForVolsha)(e.authority);return null!=o?f(o.mountpoint,e.path):n&&(0,s.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),s=i(22573),n=i(51926),a=i(89937),o=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,s.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,s.blank)(t))return;const i=(0,r.uniq)([t,(0,o.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,n.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==a.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,o.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,n.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const a=n(i(76760)),o=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,o.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,o.notBlank)(t.remoteHost)&&(0,o.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:a.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,o.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,o.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(a.sep)}`;const s=i.slice(1),n=await(0,p.volumes)();for(const t of(0,u.toA)(n))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return a.join(t.mountpoint,...s);return await(0,h.isReadableDirectory)(t)?a.join(t,...s):void 0}},85087:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),s=i(42659),n=i(9103),a=i(37628);t.volsha=(0,n.memoize)((e=>(0,r.mapNotBlank)(e,a.shortStringSha)),{maxSize:128,ttlMs:s.minuteMs})},50036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.channelVersionsCache=void 0;const r=i(46292),s=i(95696);t.channelVersionsCache=function(){return s.PosixFile.forMaybe((0,r.configDir)())?.join("channel-versions.json")}},60865:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),s=i(30577);t.channel=function(){return(0,s.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),s=i(22573),n=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function a(e){if(e instanceof r.SemVer)return e.version;const t=n.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=a,t.semverSatisfies=function(e,t){if((0,s.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const n=a(e);return null!=n&&(0,r.satisfies)(n,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},27274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.semverGte=t.semverLatest=void 0;const r=i(54993),s=i(48884),n=i(76280),a=i(30577);function o(e){const t=(0,n.toSemver)(e),i=a.UpdateChannels.ordinal((0,a.extractUpdateChannel)((0,r.toS)(e)));return null==t?void 0:[t.major,t.minor,t.patch,i,...t.prerelease.slice(1)]}function l(...e){return(0,s.greatestBy)(e,o)}t.semverLatest=l,t.semverGte=function(e,t){return l(e,t)===e}},38244:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isUpdateChannelVersion=void 0;const r=i(68708),s=i(51926),n=i(30577);t.isUpdateChannelVersion=function(e){return(0,r.isObject)(e)&&n.UpdateChannels.has(e.channel)&&(0,s.isString)(e.version)}},30577:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},63335:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ver=void 0;const r=i(22573);t.ver=function(e){return(0,r.blank)(e)?"(missing version)":e.replace(/^(?:v|ver|version)?\s*/,"version ")}},40044:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getChannelVersions_=t.checkVersion_=t.currentChannel=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(75240),l=i(17344),u=i(50213),c=i(37805),d=i(5916),h=i(46292),f=i(16287),m=i(43205),p=i(28874),g=i(63870),y=i(89372),v=i(50036),w=i(60865),b=i(27274),S=i(38244),P=i(30577),_=i(63335),T=(0,a.defer)((()=>(0,u.mkLogger)("VersionCheck")));t.currentChannel=function(){const e=[p.Settings.updateChannel.valueOrDefault,(0,w.channel)()].map((e=>P.UpdateChannels.ordinal(e))).sort()[0];return P.UpdateChannels.values[e]??p.Settings.updateChannel.valueOrDefault},t.checkVersion_=async function(e){if(p.Settings.noNetwork.valueOrDefault)return{level:"disabled",msg:["PhotoStructure version checking is disabled","Set "+(0,s.tt)(p.Settings.noNetwork.toEnvLine(!1))+" to enable."]};if(!p.Settings.autoUpdateCheck.valueOrDefault){const e=["PhotoStructure version checking is disabled"];return!0===p.Settings.optOut.value?e.push("Set "+(0,s.tt)(p.Settings.optOut.toEnvLine(!1))+" to enable."):!1===p.Settings.autoUpdateCheck.value?e.push("Set "+(0,s.tt)(p.Settings.autoUpdateCheck.toEnvLine(!0))+" to enable."):e.push("Finish setup, or set "+(0,s.tt)(p.Settings.autoUpdateCheck.toEnvLine(!0))+" to enable."),{level:"disabled",msg:e}}const i=(0,h.configDir)();if(null==i||!await(0,f.isDirectory)(i))return{level:"warn",msg:["PhotoStructure version checking is disabled","No suitable configuration directory exists."]};const a=await(0,t.getChannelVersions_)();if(null==a)return{level:"warn",msg:["Failed to fetch PhotoStructure version information"]};const u=e?.installedVersion??c.version,d=(0,P.extractUpdateChannel)(u),m=(0,P.eligibleForChannel)(d),g=a.versions.filter((e=>m.includes(e.channel))).map((e=>e.version)),y=e?.latestVersion??(0,b.semverLatest)(...g);if(null==y)return{level:"warn",msg:["PhotoStructure version checking failed","No suitable version was found for "+p.Settings.updateChannel.toEnvLine()]};const v=(0,P.extractUpdateChannel)(y),w="You are running "+(0,l.EditionName)()+" "+(0,_.ver)(u),S="The latest published "+(0,s.tt)(v)+" build is "+(0,_.ver)(y),T=v===d?void 0:"You should consider switching to the "+(0,s.tt)(v)+" channel.",M=Date.now()-a.updatedAt,E="Last checked "+(M{const e=(0,v.channelVersionsCache)(),i=await(0,y.httpGetJson_)({url:"https://photostructure.com/channel-versions.json",headers:{"User-Agent":await(0,m.userAgent)()},cache:e,ttlMs:n.dayMs,preCacheTransform:e=>({versions:e,updatedAt:Date.now(),updatedByVersion:c.version})}),r=i.data;if(null==r||!Array.isArray(r.versions)||0===r.versions.length||r.versions.some((e=>!(0,S.isUpdateChannelVersion)(e)))||r.updatedByVersion!==c.version){if(i.fromCache)return T().info("getChannelVersions_(): Invalid or stale cached response. Retrying after wiping cache",{result:r,cache:e}),await e.unlink_(),t.getChannelVersions_.refresh();T().throw("getChannelVersions_(): Invalid response",{result:r})}return T().tap({msg:"getChannelVersions_()",result:r})}})},8540:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),s=i(9595),n=i(29882),a=i(43334),o=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([o.Settings.libraryDir.valueOrDefault,(0,s.originalsDir)(),...o.Settings.scanPaths.values]))if((!a.isPosix||!(0,n.pathIsRoot)(t))&&(0,n.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},42233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentVolumeRoots=void 0;const r=i(45200),s=i(98770),n=i(7014);t.currentVolumeRoots=(0,s.lazyFsAsync)("currentVolumeRoots",(async function(){const e=[],t=[];for(const i of await(0,n.volumes)()){t.push(i.mountpoint);const s=(await(0,r.nativePath2uri)(i.mountpoint,i))?.toString();null!=s&&e.push(s)}return{uris:e,mountpoints:t}}))},1485:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),s=i(22573),n=i(59455),a=i(50213),o=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.DfPosix"))),v=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function w(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),s=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),n=t&&(i||r||s);return y().tap({msg:"acceptPosixVolume()",result:!n,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:s}})}t.acceptPosixVolume=w,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,n.toA)(await v());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,s.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,n.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,o.assignMissingPrimitives)(i,e))}return t.filter(w)}},69108:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,a.toInt)(e,{defaultValue:0})*o.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,s.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const s=m(e.Used)??0,n=m(e.Available)??0;if(0!==s||0!==n)return{filesystem:t,mountpoint:i,size:d.isMac?s+n:r,used:s,available:n};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:s,available:n})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,s.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,n.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const a=p(i);return!0===e&&a.forEach((e=>e.remote=!1)),a},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),v=i(24399),w=i(28874),b=i(24541),S=i(60224),P=i(63870),_=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const T=/([a-z]+)(?::\\)?/i;function M(e){return e?.match(T)?.[1]?.toUpperCase()}function E(e){return(0,l.map)(M(e),(e=>e+":\\"))}function k(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(M(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function D(e){return null!=e&&!(0,a.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,a.notBlank)(e.DisplayRoot),...(0,l.map)((0,S.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function x(e){return`Get-Volume ${(0,f.toS)(M(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=E,t.getPsDriveCommand=k,t.getVolumeCommand=x,t.getLocalVolumesWin_=function(){return v.PowerShell.instance().executeJsonToA(x())};const C=/\{([-a-z\d]{7,})\}/i;function F(e,t){return e=e?.trim(),(0,a.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function A(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void _().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=E(e.DriveLetter);if(null==t)return void _().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,s.compact)([F(e.HealthStatus,"healthy"),F(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,a.notBlank)(e.DriveLetter)&&(0,a.blank)(i);return _().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(n=e.UniqueId,_().tap({msg:"uniqueId2uuid",result:(0,l.map)(C.exec((0,f.toS)(n)),(e=>e[1])),meta:{s:n}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var n}async function I(){const e=(0,s.uniq)((0,h.toA)(await(0,b.mountpointsWin)()).map(E)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(k(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,s.compact)((0,o.flatten)(t).map(D)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(x(e)).catch((t=>(_().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),a=(0,s.compact)((0,o.flatten)(r).map(A)),l=(0,s.uniq)([...i,...a].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,n.sort)((0,s.uniq)([...i,...a].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));_().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:a,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...a.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=A,t.volumeInfoWin=I},68884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),v=i(83278),w=i(8103),b=i(16287),S=i(45969),P=i(43334),_=i(69108),T=i(98770),M=i(44224),E=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,S.isDocker)()||(0,d.isBillingService)()||null==await(0,w.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,E.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const k=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?k().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,M.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),b.isReadableDirectory),(e=>e.map((e=>v.BaseFile.for(e).clear().childDirectories())))))}):k().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,s.isEmpty)(e)?[]:(k().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,E.mountpointsTtlMs)(),f:async e=>{const t=await(0,_.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void k().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await D(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,E.mountpointsTtlMs)()}))),(0,o.later)((()=>(0,T.setupVolumeTTL)(t.gioVolumes)));const D=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,E.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,n.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(n.notBlank).get()}}catch(t){return void k().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs})},98770:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),s=i(5233),n=i(41400),a=i(56038),o=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,a.time)("volumes."+e,(()=>(0,s.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,o.isRetriableError)(e)&&!1!==(0,o.isIgnorableError)(e)})))),i);return(0,n.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),v=i(98770),w=i(63870),b=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>b().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>b().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const n=(0,c.sortIgnoreCase)((0,s.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),a=[];for(const t of n){const s=e.find((e=>e.mountpoint===t)),n=i?.find((e=>e.mountpoint===t)),o={...s,...n},u=r?.find((e=>e.filesystem===o.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(o,u),null==o.size||null==o.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];b().info("backfilling mountpoint",{info:n,vol:s,df:e}),null!=e&&(0,l.assignMissingPrimitives)(o,e)}a.push(o)}return a};const S=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return S.exec(e)?.[1]?.split(".").map((e=>(0,a.toInt)(e)))})),_=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,a.gte)(t[0],2)&&(0,a.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,v.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await _()],{timeoutMs:(0,w.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,n.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,a.toInt)(e.fsused),r=(0,a.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return b().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,v.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,w.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,n.toNotBlank)(e.PARTLABEL)??(0,n.toNotBlank)(e.LABEL),uuid:(0,n.toNotBlank)(e.PARTUUID)??(0,n.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),s=i(19851),n=i(40958),a=i(22573),o=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),v=(0,s.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,n.uniq)(e.map((e=>e.filesystem?.match(w)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),s=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of s)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,a.blank)(t.MountPoint)||(0,o.isTrue)(t.OSInternal)?v().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){v().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const w=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),v=i(84777),w=i(34330),b=i(8769),S=i(34102),P=i(17217),_=i(16287),T=i(43334),M=i(28874),E=i(8540),k=i(68884),D=i(44224),x=i(24541),C=i(69375),F=i(63870),A=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function O(e=(0,F.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function L(){I()}t.localMountpointSetup=(0,r.lazy)((async()=>{M.Settings.libraryDir.watchLater(I),M.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&M.Settings.scanAllDrives.valueOrDefault?(0,o.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(T.isMac&&(e.info("Setting up Mac diskutil activity watcher"),O((0,F.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),T.isLinux){const i=(0,D.maybeWatchProcMounts)();await(0,k.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),O((0,F.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),O((0,F.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),a.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=M.Settings.mountpoints.values;if((0,s.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",T.isWin?x.mountpointsWin:D.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,s.isEmpty)(e))return A().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,n.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,F.commandTimeoutMs)(),f:async e=>!(!(0,E.mightBeAssetMountpoint)(e)&&(0,C.isExcludedMountpoint)(e)||M.Settings.validateMountpoints.valueOrDefault&&!await(0,_.isReadableDirectory)(e)&&(A().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,b.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(T.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return T.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,o.later)((()=>{(0,S.ee)().on("clearCache",(()=>{k.gioVolumes.unset(),I()})),M.Settings.mountpointsTtlMs.watch(O)}),(0,c.isTest)()?1:a.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>L(),minCallDelayMs:1.5*a.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:k.GioCommand,args:k.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(k.gioVolumes.unset(),L()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const N=(0,r.lazy)((async()=>{if(!T.isLinux)return!1;try{return 0===(await(0,v.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,F.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>L(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(48884),o=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),v=i(28874),w=i(69108),b=i(68884),S=i(59107),P=i(69375),_=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await k()??await(0,c.thenMap)((0,w.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,b.isGioSupported)())try{await(0,c.thenMap)((0,b.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){_().warn("Failed to fetch gio volumes",e)}return e};const T="/proc/mounts";function M(e){return!v.Settings.excludedFilesystemTypes.has(e)}function E(e){return!(0,P.isExcludedMountpoint)(e)&&(!v.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function k(e=T,t=M,i=E){if(y.isLinux)try{const r=await(0,f.readLines_)(e),n=(0,s.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,a.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),o=await(0,c.filterAsync)({name:"mountpoints filter",arr:n,f:async([e,r])=>{const s=t(e),n=await i(r);return _().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:s&&n,meta:{fs:e,mp:r,fsOK:s,mpOK:n}})}});return _().tap({msg:"readProcMounts()",result:o.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void _().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=M,t.readProcMounts=k,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(T)?new h.FileWatcher(T,{recursive:!1,persistent:!1},(()=>{_().info("detected change in "+T),(0,d.setUnrefTimeout)((()=>S.mountpoints.refresh()),n.secondMs)})):void 0))},24541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),s=i(42659),n=i(13538),a=i(50213),o=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,n.thenOrTimeoutError)(f(),o.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*s.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(9103),o=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,n.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,s.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,o.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,o.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,o.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,o.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,s.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,a.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),s=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,n=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function a(e){if((0,r.blank)(e))return;const i=s.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(n,""),remoteShare:i.remoteShare};const a=t.nfsRe.exec(e);if(null!=a){const e=a[1],t=a[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=a(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=a},60224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(55835),o=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),v=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await M()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,a.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const w=["LocalName","RemoteName","Status"],b=["NETUSE","get",w.join(",")],S=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function _(e){if(!(0,s.blank)(e))return(0,o.opt)(e).flatMap((e=>S.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,o.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,s.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,o.opt)(e.pathname).filter(s.notBlank).getOrElse((()=>"/"))}))))).get()}async function T(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,b,{timeoutMs:15*n.secondMs}),i=(0,u.parseFixed)(w,t);return(0,r.compact)(i.map((e=>(0,a.map)(S.exec((0,l.toS)(e.RemoteName)),(t=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=_,t._netInfoWinWmic=T;const M=(0,v.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?T():(0,r.compact)(e.filter((e=>(0,s.notBlank)(e.LocalName))).map((e=>(0,a.map)(_(e.RemoteName),(({host:t,share:i})=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,h.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),s=i(12168),n=i(28874);t.mountpointsTtlMs=function(){return n.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return n.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return n.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=s.MiB/r.secondMs},86848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(38639),o=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),v=i(95696),w=i(45969),b=i(28874),S=i(59107),P=i(63870),_=i(68995),T=(0,s.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),M=(0,s.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function E(e){return(0,a.isTrue)(e.ignorable)||(0,w.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function k(e){if((0,n.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function D(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=k(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function x(e){if(b.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of b.Settings.volumeUuidFilePaths.values){const i=v.PosixFile.for(e.mountpoint).join(t),r=await D(i).catch((e=>T().info("Failed to read "+i,{error:e})));if(null!=r)return T().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,_.volumeUuidSubpath)());if("/"===e.mountpoint)return T().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(b.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return T().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(b.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,_.writeVolumeUuid)(e);if(!(0,n.blank)(t))return T().tap({msg:"readVolumeUUID(): wrote new "+(0,_.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return T().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,o.later)((()=>{(0,m.ee)().on("clearCache",(()=>M.clear())),S.mountpoints.watchLater((()=>M.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(E(e))return;if((0,a.isFalse)(e.ok))return;const t=await M().getOrSetAsync(e.mountpoint,(async()=>x(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>T().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=E,t.toVolumeUUID=k,t.readUuidFile_=D,t.readVolumeUUID=x},7014:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),v=i(59455),w=i(48884),b=i(50213),S=i(7282),P=i(23560),_=i(28850),T=i(45255),M=i(81168),E=i(56519),k=i(4867),D=i(49776),x=i(9595),C=i(77740),F=i(44198),A=i(96706),I=i(8769),O=i(57159),L=(i(34102),i(21144)),R=i(73209),N=i(29882),B=i(95696),j=i(17217),z=i(16287),V=i(49076),W=i(96128),U=i(45969),q=i(43334),H=i(28874),$=i(85087),G=i(50424),J=i(48165),K=i(98770),Y=i(27461),X=i(66840),Z=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,a.lazy)((()=>(0,b.mkLogger)("volumes.Volumes"))),se=s.default.platform(),ne=new Map,ae=new Map,oe=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,$.volsha)(t.uuid),(e=>ae.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,ne),le((0,$.volsha)(e.uuid),e,oe),e}function ce(){return(0,o.compact)([B.PosixFile.forMaybe((0,D.cacheDir)())?.join("volumes"),B.PosixFile.forMaybe((0,x.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),ae))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),ne.clear(),oe.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,E.mapAsync)({name:"readCachedVolumes",arr:(0,E.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,o.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,M.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),s=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:r,os:se}))),n=new Map;for(const e of s)for(const t of(0,o.compactBlanks)([(0,$.volsha)(e.uuid),(0,$.volsha)(e.mountpoint)]))n.set(t,e);const a=ce();for(const e of a)await(0,R.withLock_)({file:e,timeoutMs:T.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of n.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:a,vol_mountpoints:s.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,o.isNotEmpty)(e))return e;const i=(0,v.toA)(await(0,Z.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,H.Settings.volumeMetadataTtlMs.valueOrDefault),s=0!==H.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),n=!(0,o.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:s,priorIsMissingMountpoints:n}),s||n?void 0:e}async function me(e,i){const r=(0,m.map)(e,j.toNativePath_);if((0,u.blank)(r))return;const s=await(0,L.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,o.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(s,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:s,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:s}})}async function pe(e,t,i){const r=i.filter((e=>(0,M.equalsIgnoreCase)(t,e.remoteShare)));if((0,o.isEmpty)(r))return;const s=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,M.equalsIgnoreCase)(e,t.remoteHost)));if(null!=s)return s;const n=await(0,W.friendlyname)(e);return(0,E.asyncFind)(r,(async e=>(0,M.equalsIgnoreCase)(n,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,a.lazy)((()=>(0,P.isSyncService)()||(0,S.isTest)())),t.priorWriteVolumesToCacheLatch=(0,a.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,a.lazy)((async()=>{const e=(0,o.compact)(await de()),t=(0,v.toA)(await(0,Z.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,o.isNotEmpty)(i)?i:e.filter((e=>se===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,k.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,k.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,o.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,O.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,_.shim0)({name:"fs.volumes",impl:async function(){if((0,S.isTest)()){const e=(0,p.toInt)((0,F.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,C.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,k.thenOrTimeoutError)({p:q.isWin?(0,J.dfWin)():(0,G.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=H.Settings.validateMountpoints.valueOrDefault?(0,o.compact)(await(0,E.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,z.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,k.thenOrTimeoutError)({p:q.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(q.isWin?t:q.isMac?await(0,X.addLocalVolumeInfoMac)(t):await(0,Y.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await he(r),Object.freeze(r)}}),t.rootPath=(0,a.lazy)((()=>q.isWin?(0,g.opt)((0,A.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,M.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,o.isEmpty)(t)?void 0:(0,w.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,o.commonPrefixLength)(e.split(n.default.sep),t.split(n.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,v.toA)(await i.vols()).find((t=>(0,$.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,E.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return oe.get(e)??(await de())?.find((t=>(0,$.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,$.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(50213),o=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,s.lazy)((()=>(0,a.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,n.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,f());t=(0,n.toNotBlank)(t)??(0,c.safeUUID)();const s=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(s))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+o.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},72901:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkEventStream=void 0;const r=i(22573),s=i(98553),n=i(65211);t.mkEventStream=function(...e){let t="";for(const i of e)null!=i&&((0,r.blank)(i.event)||(t+="event: "+i.event+"\n"),t+="id: "+(i.id??(0,n.uid)())+"\n",t+="data: "+(0,s.stringify)(i.data)+"\n",t+="\n");return t}},55111:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},89372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.httpGetJson_=void 0;const r=i(45599),s=i(98553),n=i(31586),a=i(50213),o=i(51140),l=i(4988),u=(0,r.defer)((()=>(0,a.mkLogger)("web.HttpGet")));t.httpGetJson_=async function(e){const t=e.cache,i=await t.mtimeMs();if(null!=i&&(0,n.gt0)(await t.size())&&(0,n.gte)(i,Date.now()-e.ttlMs))return{data:await t.readJson_(),updatedAt:i,fromCache:!0};const r=await(0,l.get_)(e.url,{headers:e.headers});o.HttpStatusIs.success(r.statusCode)||u().throw("Failed",{url:e.url,response:r});const a=(0,s.parseJSON_)(r.data),c=e.preCacheTransform?.(a)??a;return u().info("Fetch success. Caching",{args:e,json:c,cache:t}),await t.writeJson_(c),{data:c,updatedAt:Date.now(),fromCache:!1}}},49586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAjaxRequest=t.isHttpsRequest=t.parseForwarded=void 0;const r=i(22573),s=i(59455),n=i(81168),a=i(28874);function o(e){if((0,r.blank)(e))return{};let t=(0,s.toA)(e).join(";").trim().replace(/^[,;]/,"").replace(/[,;]$/,"");const i={};for(;t.length>0;){const e=t.indexOf("=");if(e<0)break;const r=(0,n.stripQuotes)(t.slice(0,e).trim().toLowerCase());if(t=t.slice(e+1).trim(),/^["']/.test(t)){const e=/['"]\s*(?:[;,]|$)/.exec(t.slice(1))?.index;if(null==e)break;const s=(0,n.stripQuotes)(t.slice(0,e+2).trim());i[r]=s,console.log("quoted",{k:r,v:s,s:t,vIdx:e}),t=t.slice(e+3).trim()}else{const e=/[;,]|$/.exec(t)?.index;if(null==e)break;const s=t.slice(0,e).trim();i[r]=s,console.log("unquoted",{k:r,v:s,s:t,vIdx:e}),t=t.slice(e+2).trim()}}return i}function l(e){return(0,r.blank)(e)||function(e){return Array.isArray(e)&&0===e.length}(e)?void 0:(0,s.toA)(e).join(";")}t.parseForwarded=o,t.isHttpsRequest=function(e){return null!=e&&"false"!==a.Settings.trustProxy.valueOrDefault&&((0,n.equalsIgnoreCase)("https",o(e.forwarded).proto??l(e["x-forwarded-protocol"])??l(e["x-url-scheme"]))||"on"===l(e["front-end-https"])||"on"===l(e["x-forwarded-ssl"]))},t.isAjaxRequest=function(e){return"application/json"===e?.["content-type"]}},51140:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpStatusIs=t.HttpStatus=void 0;const r=i(31586);t.HttpStatus=Object.freeze({OK:200,Accepted:202,MovedPermanently:301,Found:302,SeeOther:303,BadRequest:400,Unauthorized:401,Forbidden:403,NotFound:404,EnhanceYourCalm:420,InternalServerError:500,NotImplemented:501,ServiceUnavailable:503}),t.HttpStatusIs=Object.freeze({ok:e=>(0,r.within)(200,299,e),success:e=>(0,r.within)(200,299,e),redirect:e=>(0,r.within)(300,399,e),clientError:e=>(0,r.within)(400,499,e),serverError:e=>(0,r.within)(500,599,e),error:e=>(0,r.within)(400,599,e)})},21404:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToTagPath=void 0;const r=i(75020),s=i(40958),n=i(22573),a=i(89937),o=i(34238);t.uriToTagPath=function({uri:e,isFile:t}){if(null==e)return;const i=(0,o.toURI)(e),l=i.scheme===a.PS_LIBRARY_SCHEME?r.LibraryTagName:i.scheme===a.PS_LOCAL_FILE_SCHEME?i.authority:void 0;if((0,n.blank)(l))return;const u=i.path.split("/");return(0,s.compactBlanks)([r.TagRoots.fs,l,...t?u.slice(0,-1):u])}},98604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkAssetUrl=t.mkFolderUrl=t.myWebUrl=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(27776),o=i(49076),l=i(72308),u=i(28874),c=i(42231),d=i(45200),h=i(34238),f=i(21404);function m(e=u.Settings.httpPort.valueOrDefault){const t=[u.Settings.localhost.valueOrDefault];u.Settings.exposeNetworkWithoutAuth.valueOrDefault&&t.push(...(0,s.compactBlanks)([(0,l.myExternalIp4Addresses)()[0],(0,o.hostname)()]));const i=(0,h.toURI)("http://a");return t.map((t=>i.with({authority:t+":"+e})))}t.default=m,t.myWebUrl=(0,r.lazy)((()=>m()[0])),t.mkFolderUrl=async function(e){const i=await(0,d.nativePath2uri)(e),r=(0,f.uriToTagPath)({uri:i,isFile:!1});if((0,s.isEmpty)(r))return;const n=(0,a.mkTagUri)((0,c.tagPathToStringArray)(r));return(0,t.myWebUrl)()?.with(n)},t.mkAssetUrl=function(e){return(0,n.gt0)(e)?(0,t.myWebUrl)()?.with({path:"/asset/"+e}):void 0}},4988:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.httpRequest_=t.get_=t.HttpMethods=void 0;const a=n(i(37067)),o=n(i(44708)),l=i(22573),u=i(45599),c=i(50989),d=i(51926),h=i(50213),f=i(45255),m=i(22911),p=i(43205),g=i(34238),y=i(51140),v=(0,u.defer)((()=>(0,h.mkLogger)("net.get")));async function w(e,t){return b({...t,url:e})}async function b(e){const t=(0,g.toURI)(e.url),i=new m.Deferred("get "+t.toString()),r="http"===t.scheme?a.request:"https"===t.scheme?o.request:v().throw("unsupported scheme: "+t.scheme),s=e?.maxRedirects??8,n=e?.timeoutMs??f.ShortCommandTimeoutMs,u={...e?.headers,"user-agent":await(0,p.userAgent)()},c=e?.method??"GET",h=e?.agent??!1,b=r(t.toString(),{method:c,headers:u,timeout:n,agent:h},(e=>{let r="";e.setEncoding("utf8").on("data",(e=>r+=e.toString())).resume().on("end",(()=>{const a={url:(0,l.toNotBlank)(e.url)??t.toString(),contentType:e.headers["content-type"],statusCode:e.statusCode??-1,data:r};s>0&&y.HttpStatusIs.redirect(a.statusCode)&&!(0,l.blank)(e.headers.location)?(console.log("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),v().info("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),i.observe(w(e.headers.location,{timeoutMs:n,maxRedirects:s}))):(v().debug("complete",{...a,data:(0,d.ellipsize)(r,64),data_length:r.length}),i.resolve(a))}))})).on("error",(e=>i.reject(e)));return(0,l.blank)(e.body)||b.write(e.body),b.end(),i}t.HttpMethods=(0,c.strEnum)("GET","PUT","POST","PATCH","DELETE"),t.get_=w,t.httpRequest_=b},65713:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),s=i(19851),n=i(23838),a=i(81168),o=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,s.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,s.lazy)((async()=>{const e=(0,o.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,s.lazy)((()=>({trie:new n.MultiMap,small:[]}))),h=3;function f(e){const t=new n.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=s)return s}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),s=i(96249),n=i(23838),a=i(59455),o=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=n.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,a.toA)(u[t])],n=c(e.substring(1));return(0,s.flatten)(n.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,o.stripDiacritics)(e).normalize())}},30933:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const s=r(i(48161)),n=i(19851),a=i(42659),o=i(31586),l=i(50213),u=i(28874),c=(0,n.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,n.lazy)((()=>s.default.cpus()),5*a.minuteMs),t.cpuCount=(0,n.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=s.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,o.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},14854:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CpuUsage=t.isTooBusy=void 0;const d=c(i(48161)),h=i(42659),f=i(45599),m=i(55835),p=i(31586),g=i(68708),y=i(19851),v=i(50213),w=i(7282),b=i(78406),S=i(25764),P=i(38835),_=i(74128),T=i(82647),M=i(43334),E=i(28874),k=i(30933),D=i(15674),x=(0,y.lazy)((()=>(0,v.mkLogger)("work.CpuUsage"))),C=(0,y.lazy)((()=>{const e=F.instance().busyPct();(0,_.syncReport)().maybeSystemData({from:"cpuUsage",state:"note",details:"Current system load is too high to schedule more work",meta:(0,g.compactValues)({loadCpuPct:I(),cpuBusyPct:e})}),x().warn("Current system load is too high to schedule more work",{cpuBusyPct:e,max:E.Settings.cpuBusyPercent.valueOrDefault})}),((0,w.isTest)()?15:60)*h.secondMs);t.isTooBusy=function(){if(E.Settings.cpuBusyPercent.valueOrDefault<=0)return!1;const e=F.instance().busyPct(),t=(0,p.clamp)(1,150,Math.round(4*E.Settings.cpuBusyPercent.valueOrDefault/3));return(0,p.gte)(e,t)?(C(),!0):(C.unset(),!1)};class F extends b.EndableInterval{constructor(){super({name:"CpuUsage()",callback:()=>l(this,r,"m",o).call(this),intervalMs:((0,D.singleThreadedMode)()?60:M.isWin?20:10)*h.secondMs,rank:S.EndableRanks.first}),r.add(this),s.set(this,new T.Average(5)),n.set(this,new A),(0,p.mapFinite)(I(),(e=>l(this,s,"f").push(e))),l(this,r,"m",o).call(this)}get cpuCount(){return l(this,n,"f").cpuCount}idlePct(){return(0,m.map)(this.busyPct(),(e=>100-e))}busyPct(){return l(this,s,"f").sampleAvg??I()}}t.CpuUsage=F,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){(0,p.gte0)(e)&&l(this,s,"f").push(e)},o=function(){l(this,r,"m",a).call(this,I());const e=new A;l(this,r,"m",a).call(this,e.busyPct(l(this,n,"f"))),u(this,n,e,"f")},F.instance=(0,f.defer)((()=>new F));class A{constructor(e=d.default.cpus()){let t=0,i=0;for(const r of e)t+=r.times.user+r.times.nice+r.times.sys+r.times.irq,i+=r.times.idle;this.busyMs=t,this.idleMs=i,this.cpuCount=e.length}busyPct(e){const t=this.busyMs-e?.busyMs,i=this.idleMs-e?.idleMs,r=t+i;return e?.cpuCount===this.cpuCount&&(0,p.gte0)(t)&&(0,p.gte0)(i)&&(0,p.gt0)(r)?(0,p.sigFigs)(t/r*100,3):void x().warn("busyPct(): Unexpected CpuTimes. If this continues, busyPct() will be incorrect."+P.InternalErrorFlag,{self:this,prior:e,busyMs:t,idleMs:i,totalMs:r})}}function I(){return M.isWin?void 0:(0,p.sigFigs)(d.default.loadavg()[0]/(0,k.cpuInfo)().length*100,3)}},73328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyDoNotRun=t.doNotRun=void 0;const r=i(68708),s=i(99331),n=i(74128),a=i(63664),o=i(14854);t.doNotRun=function(e){return null!=u(e)};const l=["error","no-library","stop-sync"];function u(e){if(!0===e?.ended)return"endable ended";if((0,s.ending)())return"service is ending";if((0,o.isTooBusy)())return"system is too busy";const t=(0,a.getRemoteOrLocalHealthSummarySync)();if(null==t||!l.includes(t.level))return;const i=t.level+": "+t.msg.join("\n");return(0,n.syncReport)().maybeSystemData({from:"whyDoNotRun",state:"note",details:t.level,meta:(0,r.omit)(t,"links","buttons")}),i}t.whyDoNotRun=u},58444:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const s=r(i(48161)),n=i(19851),a=i(31586),o=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,n.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,n.lazy)((()=>{const e=s.default.freemem(),t=s.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,a.gt0)(r))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,o.fmtBytes)(i),freemem:(0,o.fmtBytes)(e),totalmem:(0,o.fmtBytes)(t)}})}))},69385:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOnResume=t._setPaused=t.resume=t.pause=t.isPaused=void 0;const r=i(34102),s=i(37692);let n=!1;function a(){return n}function o(e=!0){l(e),(0,s.writeStateFile)({paused:e})}function l(e){e!==n&&(n=e,(0,r.ee)().emit(e?"pause":"resume"))}t.isPaused=a,t.pause=o,t.resume=function(){return o(!1)},t._setPaused=l;const u=Promise.resolve();t.resolveOnResume=function(){return a()?new Promise((e=>{(0,r.ee)().once("resume",e)})):u}},15674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),s=i(42659),n=i(41400),a=i(31586),o=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,n.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,r.lazy)((()=>{const e=(0,a.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*o.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/o.MB),worstCaseMemPerProcMb:Math.ceil(e/o.MB)}})}),s.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,a.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function b(){return((0,a.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=b,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(b()*(0,f.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(b()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=w();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const s=Math.min(e,v());return t=(0,a.clamp)(1,s,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:b(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,a.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,a.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,a.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},37692:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addStateEvent=t.writeStateFile=t.readStateFile=t.stateEvents=t.StateEvents=t.StateEventFns=void 0;const s=r(i(78474)),n=i(40958),a=i(76790),o=i(42659),l=i(45599),u=i(41400),c=i(68708),d=i(50989),h=i(87290),f=i(73787),m=i(19851),p=i(50213),g=i(28874),y=i(69385),v=(0,l.defer)((()=>(0,p.mkLogger)("work.SharedState")));let w;t.StateEventFns={checkTasks(){},reloadLicenses(){}},t.StateEvents=(0,d.strEnum)(...(0,c.keys)(t.StateEventFns)),t.stateEvents=new s.default;let b=0;function S(){const e=(0,h.libraryDataDirPosixFile)()?.join("state.json"),t=Date.now(),i=t-b>o.minuteMs;i&&(b=t);const r=e?.existsSync({refresh:i})??!1;return r&&null!=e&&e.eql(w?.nativePath)||(w?.close(),w=void 0),r&&null!=e&&(w??(w=new f.FileWatcher(e.nativePath,{encoding:"utf8",persistent:!1,recursive:!1},P))),e}(0,u.later)((()=>{g.Settings.libraryDir.watchLater(P)}));const P=(0,m.lazy)((()=>t.readStateFile.refresh()),25);t.readStateFile=(0,m.lazy)((()=>{const e=S()?.readJsonSync();for(const i of e?.events??[])_.get(i.e)!==i.ts&&(v().info("emitting event "+i.e),t.stateEvents.emit(i.e),_.set(i.e,i.ts));return(0,y._setPaused)(e?.paused??!1),e}));const _=new Map;function T(e){const i=S();if(null==i)v().error("overwrite(): failed: no library directory");else{const r=i?.readJsonSync(),s=function(e){const t=Date.now()-10*o.minuteMs;return(0,n.uniqByLast)((0,a.sortBy)((e??[]).filter((e=>e.ts>t)),(e=>e.ts)),(e=>e.e))}([...r?.events??[],...e.events??[]]),l={paused:e.paused??r?.paused??g.Settings.startPaused.valueOrDefault,events:s};(0,y._setPaused)(l.paused),t.readStateFile.set(l),i.writeJsonSync(l)}}t.writeStateFile=T,t.addStateEvent=function(e){const t=Date.now();_.set(e,t),T({events:[{e,ts:t}]})}},22751:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),s=i(87997),n=i(19851),a=i(42659),o=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,n.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,n.lazy)((()=>new r.Rate(5*a.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,n.lazy)((()=>(0,s.setInterval)(g,a.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,o.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},83600:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.RequestTask=void 0;const a=i(58587),o=i(80875),l=i(19851),u=i(50213),c=i(34102),d=i(84542),h=i(87445),f=i(40958),m=i(26905),p=i(98553),g=i(31586),y=(0,l.lazy)((()=>(0,u.mkLogger)("worker.RequestTask")));class v extends a.Task{constructor(e){super((0,p.stringify)(e),(e=>n(this,r,"m",s).call(this,e))),r.add(this),this.request=e}}t.RequestTask=v,r=new WeakSet,s=function(e){for(const t of(0,f.compactBlanks)((0,d.splitLines)(e))){const e=(0,o.parseJSON)(t);if(null==e)y().warn("ignoring non-json line from worker",{line:t});else{if(null!=e.error)throw y().warn("worker threw error",{response:e}),(0,m.errorFromJson)(e.error);if((0,g.isNumber)(e.id))return e.id!==this.request.id?y().throw(`bad request: #parse given mismatching requests (${e.id} != ${this.request.id})`,{response:e,request:this.request}):e.response;(0,h.isProgressEvt)(e)?(0,c.ee)().emit("progress",e):y().warn("ignoring json line from worker",{response:e})}}return y().throw("bad request: #parse missing valid response")}},93493:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearShims=t.setupShimDelegates=void 0;const r=i(19851),s=i(5233),n=i(68708),a=i(13538),o=i(57206),l=i(50213),u=i(23560),c=i(70025),d=i(28874),h=i(15674),f=i(22751),m=i(83600),p=i(58800),g=i(24817),y=(0,r.lazy)((()=>(0,l.mkLogger)("worker.ShimDelegation")));let v=0;async function w(e,t){const i=d.Settings.taskTimeoutMs.valueOrDefault;return(0,s.retryOnReject_)((async()=>{y().throwIfAborted_();const r={id:v++,fn:e,args:t},s=new m.RequestTask(r),n=await(0,p.workerCluster)(),o=n?.t,l=null==n||null==o?g.WorkerFunctions[e](...t):n.awaitOrAbort(o.enqueueTask(s));return(0,a.thenOrOnTimeout)(l,i/3,(()=>{y().warn("soft timeout servicing work request",{request:r,timeoutMs:i}),(0,f.onTimeout)()})),(0,a.thenOrTimeoutError)(l,i)}),{maxRetries:d.Settings.maxRetries.valueOrDefault,timeoutMs:i,retryDelay:d.Settings.minDelayBetweenRetriesMs.valueOrDefault,errorIsRetriable:e=>!1!==(0,c.isRetriableError)(e)})}function b(){for(const e of(0,n.values)(g.WorkerFunctions))(0,n.maybeCall)(e,"clearShim")}t.setupShimDelegates=async function(){if((0,o.addDefaultJsonRevivers)(),(0,u.isWorkerService)())b(),y().warn("setupShimDelegates(): in worker service, skipping");else if((0,h.singleThreadedMode)())y().warn("setupShimDelegates(): single-threaded mode, clearing shims"),b(),await(0,p.endWorkerCluster)();else for(const[e,t]of(0,n.entries)(g.WorkerFunctions))t.setShim((t=>w(e,t)))},t.clearShims=b},24817:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleWorkRequest_=t.isWorkRequest=t.mkWorkRequest=t.WorkRequestMethods=t.WorkerFunctions=t.AllWorkerFunctionCandidates=void 0;const r=i(98553),s=i(31586),n=i(68708),a=i(50989),o=i(32639),l=i(13991),u=i(50597),c=i(48368),d=i(52121),h=i(48604),f=i(181),m=i(66106),p=i(47783),g=i(83966);t.AllWorkerFunctionCandidates={_extractVideoFrame_:m._extractVideoFrame_,_readRawTags:p._readRawTags,_readTags:p._readTags,assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkerFunctions={assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkRequestMethods=(0,a.strEnum)(...(0,n.keys)(t.WorkerFunctions));let y=0;t.mkWorkRequest=function(e,t){return{id:++y,fn:e,args:t}},t.isWorkRequest=function(e){return"object"==typeof e&&t.WorkRequestMethods.has(e?.method)&&(0,s.isNumber)(e.id)},t.handleWorkRequest_=async function(e){const i=t.WorkerFunctions[e?.fn];if((0,o.isFunction)(i))return i(e?.args);throw new Error("invalid method "+(0,r.stringify)(e))}},58800:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.workerCluster=t.endWorkerCluster=t.workerClusterPriorEnd=void 0;const r=i(58587),s=i(36557),n=i(19851),a=i(50213),o=i(71567),l=i(25764),u=i(84777),c=i(86335),d=i(38835),h=i(84542),f=i(87445),m=i(41944),p=i(15674),g=i(42659),y=i(98553),v=i(31586),w=i(67478),b=i(54993),S=i(27395),P=i(5916),_=i(55534),T=i(29325),M=i(28874),E=i(30933),k=i(41657),D=(0,n.lazy)((()=>(0,a.mkLogger)("worker.cluster")));t.workerClusterPriorEnd=async function(){return(await t.workerCluster.prior())?.t.closeChildProcesses()},t.endWorkerCluster=function(){return(0,S.end)(t.workerCluster.prior())},t.workerCluster=(0,P.lazyAsync)({later:async()=>{const e=await(0,c.pathToService)("worker");if(null==e)return D().throw("Could not find worker.js"+d.FatalErrorFlag);D().info("worker.js found at "+e);const t={id:-1,fn:"ping",args:{}},i=new r.BatchCluster({processFactory:async()=>(D().info("Spawning new worker",{execPath:process.execPath,worker:e.nativePath,maxProcs:(0,p.maxCpus)()}),(0,u.spawn)(process.execPath,[e.nativePath],0,{env:await(0,k.workerEnv)()})),...(0,s.batchClusterOptions)((0,p.maxCpus)(),"worker.BatchCluster"),streamFlushMillis:0,versionCommand:(0,y.stringify)(t),healthCheckCommand:(0,y.stringify)(t),taskTimeoutMillis:M.Settings.taskTimeoutMs.valueOrDefault,maxProcAgeMillis:4*M.Settings.taskTimeoutMs.valueOrDefault,minDelayBetweenSpawnMillis:(0,T.isPacked)()?g.secondMs:1,pass:o.ReadyStr,fail:d.FatalErrorRe,exitCommand:_.ServiceExitCommand});return i.on("taskData",(e=>{for(const t of(0,h.splitLines)((0,b.toS)(e))){const e=(0,w.parseJSON)(t);(0,f.isProgressEvt)(e)&&(0,m.emitProgressEvt)(e)}})),p.maxCpus.watchLater((e=>{const t=(0,v.clamp)(1,(0,E.cpuCount)(),e??(0,p.maxCpus)());return D().warn("maxConcurrentImports changed",{maxProcs:t,newValue:e}),i.setMaxProcs(t)})),new s.BatchClusterObserver("worker",i,l.EndableRanks.first)}})},41657:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.workerEnv=void 0;const r=i(9727),s=i(28874),n=i(59107);t.workerEnv=async function(){const e={};return s.Settings.libraryDir.addToEnv(e),s.Settings.mountpoints.addToEnv(e,await(0,n.mountpoints)()),(0,r.childEnv)({overrides:e,forWorker:!0})}},83966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ping=void 0;const s=r(i(1708)),n=i(41400),a=i(31586),o=i(7282),l=i(12089),u=i(45608),c=i(57159),d=i(89035);t.ping=(0,l.shim1)({name:"worker.ping",async impl(e){if((0,a.gt0)(e?.delay)&&await(0,n.delay)(e.delay),(0,o.isTest)()&&!0===e?.pretendMemUsageIsHigh&&d.memoryUsageIsHigh.set(!0),null!=e?.throw)throw new c.WrappedError(e.throw.message,e.throw);if((0,d.memoryUsageIsHigh)())throw(0,u.exit)({reason:"memory usage is high",status:1}),new c.WrappedError("Memory usage is high",{fatal:!0});return{pid:s.default.pid,input:e?.input??"(no input)"}}})},40958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),s=i(22573),n=i(50357),a=i(98553),o=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function v(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function b(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function S(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,o.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const s=[];if(et;n-=i)s.push(r(n));return s}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),s=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===s[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,n.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const s of t){const t=i(s);r.includes(t)||(e.push(s),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>!(0,n.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=b,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(s.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=b(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return S(t,(e=>(0,l.isPrimitive)(e)?e:(0,a.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,n.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=b(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=S,t.uniqByLast=function(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of b(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,a.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const s=new Set(i.map(r));return e.filter((e=>!s.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),s=i(36783),n=i(41801),a=i(98553),o=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,s.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const r of e)(0,o.getOrSet)(i,(0,a.stringify)(t(r)),(()=>r));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,s.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,n.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},75761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetImgAttrs=t.assetSqImgAttrs=t.assetVideoLink=t.assetImgActualLink=t.assetImgLink=t.assetLinkAttrs=t.assetUrl=void 0;const r=i(58939),s=i(40958),n=i(22573),a=i(42659),o=i(11371),l=i(73722),u=i(31586),c=i(54993),d=i(29652),h=i(22403),f=i(2322);function m(e,t){return e+" "+t+"w"}function p(e,t){let i=null==t?void 0:(0,d.mergeURLSearchParams)(...t);const r=(0,c.toS)(e.v);return(0,n.blank)(r)||"1"===r||(i??(i=new URLSearchParams)).append("v",r),i}function g({assetId:e,params:t}){return null==e?"":(0,d.assembleFullPath)("/asset/"+(0,r.id2id)(e),p(e,t))}function y({assetId:e,reducer:t,width:i,params:s}){return(0,d.assembleFullPath)(`/img/${(0,r.id2id)(e)}/${t}/${(0,u.toGt0)(i)??320}`,p(e,s))}function v({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/img/${(0,s.compact)([(0,r.id2id)(e),t]).join("/")}/actual`,p(e,i))}function w({assetId:e,params:t,reducer:i,widths:s,lazyLoad:n,af:l}){if(null==(0,r.id2id)(e))return{src:"/images/clear-64.png"};0===(s=(s??[]).filter(u.gt0)).length&&s.push(320);const d=Math.min(...s),p={width:(0,c.toS)(d)},g=(0,a.fmtLocalToShort)(e.capturedAtLocal);null!=g&&(p.title=g);const w=y({assetId:e,params:t,reducer:i,width:d});n??(n=!0);const b=n&&(0,f.isSafari)((0,h.ua)());b?(p.src="/images/clear-64.png",p["data-src"]=w):p.src=w,(0,f.isSafari)((0,h.ua)())||(p.loading=n?"lazy":"eager"),i===o.ReducerNames.sq&&(p.height=(0,c.toS)(d));const S=s.map((r=>m(y({assetId:e,params:t,reducer:i,width:r}),r)));return null!=l&&S.push(m(v({assetId:e,params:t,assetFileId:l.assetFileId}),l.width)),p[(b?"data-":"")+"srcSet"]=S.join(","),p}t.assetUrl=g,t.assetLinkAttrs=function({assetId:e,params:t}){const i=g({assetId:e,params:t});return(0,n.blank)(i)?{}:{href:i}},t.assetImgLink=y,t.assetImgActualLink=v,t.assetVideoLink=function({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/video/${(0,r.id2id)(e)}-${t}`,p(e,i))},t.assetSqImgAttrs=function({assetId:e,params:t,lazyLoad:i,size:r="m"}){return{...w({assetId:e,params:t,reducer:"sq",widths:l.SqWidths,lazyLoad:i}),sizes:("s"===r?80:"m"===r?160:320)*(0,u.numericOr)(globalThis?.window?.devicePixelRatio,1)+"px"}},t.assetImgAttrs=w},5233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),s=i(31586),n=i(13538),a=i(41583);t.retryOnReject_=async function(e,t){const i=(0,s.gt0)(t.timeoutMs)?()=>(0,n.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const o=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,a.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await o(l),u()}};return u()}},17586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55938),o=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,a.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,a.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,s.blank)(e)?"":"```"+(0,o.toS)(e)+"```"},t.b=function(e){return"**"+(0,o.toS)(e)+"**"},t.li=function(...e){return(0,r.compactBlankish)((0,n.flatten)(e)).map((e=>"- "+(0,o.toS)(e))).join("\n")}},22573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),s=i(42279),n=i(54993);function a(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function o(e){return!a(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,n.toS)(e);return o(i)?t(i):void 0}t.blank=a,t.notBlank=o,t.notBlankToS=function(e){return o(e)&&"undefined"!==e?(0,n.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,n.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,s.tot)(t);const i=(0,n.toS)(e).trim();return i.length>0?i:(0,s.tot)(t)},t.notBlankAnd=function(e,t){return!a(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,n.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{"use strict";function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),s=i(22573),n=i(30301),a=i(55835),o=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,a.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,o.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const s=Math.floor(e/t.minuteMs);e-=s*t.minuteMs;const n=Math.floor(e/t.secondMs),a=Math.floor(e-n*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(s)+":"+(0,l.pad2)(n)+(i.includeMs?"."+(0,l.pad3)(a):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),s=i(),n=i(),a=i(),o=i(),l=i();return new Date(t,l-1,o,a,n,s,r)}function w(){return(new Date).setHours(24,0,0,0)}function b(e,i="ago"){return e<1e3?"just now":(i=(0,s.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const n=Math.floor(e/r.ms);e-=n*r.ms,n>0&&(r.ms>=t.dayMs?i:s).push(n+r.s)}return e>0&&s.push((0,o.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(s)?"":"T"+s.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,a.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return b(Date.now()-e,t)},t.fmtElapsedMs=b},95892:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),s=i(73872);function n(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function a(e,t,i,r){if(null==i||y(e)||y(t))return;let s=i.get(e);null!=s?s.set(t,r):(s=new WeakMap,s.set(t,r),i.set(e,s))}function o(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const s=l(e,t);return null!==s?s:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=n(e,t,u);if(null!==f)return f;const m=n(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return a(e,t,u,i),i;const s=l(e,t);if(null!==s)return s}const y=s(e);if(y!==s(t))return a(e,t,u,!1),!1;a(e,t,u,!0);const v=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return o(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],s=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){s.push([e,t])})),c(r.sort(),s.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return a(e,t,u,v),v}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let s=-1;for(;++s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const s=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return s.prior=()=>t,s.hasPrior=()=>r,s}},41400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),s=i(35556),n=i(31586),a=i(68708);function o(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const n=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&s.isNode&&n.unref?.()}}))}t.delayUntil=function(e){const t=((0,n.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return o(t).then((()=>t))},t.delay=o,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),n=s.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return s.isBrowser||t<=r.secondMs?n:(0,a.maybeCall)(n,"unref")??n}},33374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const r=i(31586),s=i(21605),n=i(12168);function a(e){return{width:e.height,height:e.width}}function o(e){return((0,r.toGt0)(e?.width)??0)*((0,r.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,r.gt0)(e.width)&&(0,r.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,r.gt0)(e)&&(0,r.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,n.pixels2size)(e.width*e.height)},t.dimSwap=a,t.maybeDimSwap=function(e,t){return(0,s.swappableRotation)(t)?a(e):e},t.maybeFlipInPlace=function(e,t){(0,s.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,n.megapixels)(o(e))},t.pixels=o},87562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExampleDomain=void 0;const r=i(40958),s=i(51926),n=["example.com","example.net","example.org","example.edu",".example",".local"].map((e=>(0,s.stripPrefix)(e,".").split(".")));t.isExampleDomain=function(e){const t=e.toLowerCase().split(".");return n.some((e=>(0,r.arrayEndsWith)(t,e)))}},25763:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEmail=t.isEmailMaybe=void 0;const r=i(22573),s=i(87562),n=i(54993);t.isEmailMaybe=function(e){return null!=o(e)};const a=/^(?.+)@(?.[^@\n\r.\u2028\u2029]*\..+)$/;function o(e){const t=a.exec((0,n.toS)(e).trim());if(null==t?.groups)return;const{local:i,domain:o}=t.groups;return(0,r.blank)(i)||(0,r.blank)(o)||(0,s.isExampleDomain)(o)?void 0:{local:i,domain:o}}t.parseEmail=o},50357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),s=i(68708),n=i(34666),a=i(32639);function o(e,t){return(0,r.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,a.isFunction)(e)&&(0,a.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=o,t.eqlSubset=function(e,t){if(null==e||null==t||(0,n.isPrimitive)(e)||(0,n.isPrimitive)(t))return e===t;if(!(0,s.isObject)(e)||!(0,s.isObject)(t))return!1;for(const i of(0,s.keys)(e))if(!o(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(31586),o=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,s.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,a.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,n.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,s.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,s.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,s.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(s.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,o.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,o.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,o.assignFields)(new Error,(0,o.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},4188:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),s=i(42659),n=i(55835),a=i(31586),o=i(12168),l=[{ms:s.yearMs,s:"year",p:"years"},{ms:s.yearMs/12,s:"month",p:"months"},{ms:s.weekMs,s:"week",p:"weeks"},{ms:s.dayMs,s:"day",p:"days"},{ms:s.hourMs,s:"hour",p:"hours"},{ms:s.minuteMs,s:"minute",p:"minutes"},{ms:s.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,s){if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,n.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,o.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,n.mapOr)(s,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function s(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=s,t.orList=function(e){return s(e,"or")},t.andList=function(e){return s(e,"and")}},50268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const r=i(22573),s=i(38639),n=i(68708),a=i(62220),o=i(50989);t.HealthCheckSections=(0,o.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,o.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,n.isObject)(e)&&!(0,r.blank)(e.id)&&!(0,r.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,r.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,n.isObject)(e)&&a.RunStates.has(e.state)&&(0,s.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},11371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReducerNames=void 0;const r=i(50989);t.ReducerNames=(0,r.strEnum)("fit","sq")},73722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const s=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,s){if((0,isFunction_1.isFunction)(r))return;let n,a,o,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(n=0;nnew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),s=i(50357),n=i(31586),a=i(65812);t.lazy=function(e,t){let i,o;const l=[];function u(){return u.isStale()&&u.setResult(e()),o}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const n=await e,o=await i;if(!(0,s.eql)(n,o))for(const e of l)e(o);null!=t&&t>0&&void 0!==o&&(0,a.setUnrefTimeout)((()=>u.vacuum()),t)}(o,e),o=e},u.isStale=function(){return null==i||(0,n.gt0)(t)&&i+t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),s=i(54993);function n(e,t){return null==e?void 0:t(e)}function a(e,t,i){return null==e||null==t?void 0:i(e,t)}function o(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=n,t.mapTry=function(e,t){try{return n(e(),t)}catch{return}},t.map2=a,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=o,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return o(a(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,s.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class s extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=s},23838:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),s=i(76790),n=i(50357),a=i(98553),o=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,o.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,o.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,n.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),s=null==i?[]:e(t,i);(0,r.isEmpty)(s)?this.store.delete(t):this.store.set(t,s)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,s]of this.store.entries()){const n=(0,r.findIndexes)(s,(t=>!e(i,t,s)));if(n.length>0){t=!0;for(const e of n.reverse())s.splice(e,1)}0===s.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,a.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,s.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),s=i(22573),n=i(42279),a=i(54993);function o(e){return"number"==typeof e&&isFinite(e)}t.isNumber=o,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,a.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return o(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,a.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>o(t)&&o(i)&&e(t,i);function f(e,i,s){return!(null==s||!o(s))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,s)&&(0,t.gte)(i,s))}function m(e){if(!o(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,s.blank)(e))return t.defaultValue;if(o(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return o(e)&&e>0}function b(e){return o(e)&&e>=0}function S(e,t){return o(e)?t(e):void 0}function P(e){return o(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function T(e,t,i){if(e>t||!o(e)||!o(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return o(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return o(e)?e:t},t.diff=function(e,t){return o(e)&&o(t)?e-t:void 0},t.absdiff=function(e,t){return o(e)&&o(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!o(e)||!o(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return f(t-r,t+r,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)o(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return o(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return o(e)&&o(t)&&e>t?e:void 0},t.lte0=function(e){return o(e)&&e<=0},t.gte0=b,t.toGte0=function(e){return b(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=v(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=S,t.map2Numeric=function(e,t,i){return S(e,(e=>S(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return o(e)?t(e):i},t.numericOr=function(e,t){return o(e)?e:(0,n.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return S(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d+\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!o(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=T,t.times=function(e,t){if(!w(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return T(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!o(i))return;t+=i}return t}},68708:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(32639),o=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function w(e,t,i={}){return y((0,r.compact)((0,s.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function b(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const s={};for(const e of(0,r.uniq)((0,r.flatMap)(i,h)))s[e]=b(...i.map((t=>t[e])));return s}function S(e,t){if(!d(e)||(0,n.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=v(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,s]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==s&&!0!==i?.assignNullish||(e[r]=s));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,o.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,n.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=b,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,n.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=o.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function s(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:b(i,t)}for(const r of i){const[i,a]=(0,c.splitFirst)(r,"."),o=S(t,i);null!=o?.value&&s(o.key,(0,n.blank)(a)?o.value:e(o.value,a))}for(const r of h(t))((0,l.toInt)(r)??-1)>=0&&s(r,e(t[r],...i));return r},t.pluck=S,t.pluckDeep=function e(t,i){if(null==t||(0,n.blank)(i))return;if(Array.isArray(t)){const s=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(s)?void 0:{key:s[0].key,value:(0,r.flatMap)(s,(e=>e.value))}}const[s,a]=(0,c.splitFirst)(i,"."),o=S(t,s);if(null==o)return;if((0,n.blank)(a))return o;const l=e(o.value,a);return null==l?void 0:{key:o.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,n.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,a.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,n.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=w(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>n(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return s(t)?t:n(t)}filter(e){return n(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return n(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return n(e).flatMap((e=>n(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return n(e).flatMap((e=>n(t).flatMap((t=>n(i).flatMap((i=>r(this.a,e,t,i)))))))}}function s(e){return e instanceof r||e===t.None}function n(e){return s(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=s,t.opt=n},97238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSeed=t.prngSeed=t.SeedCount=t.PrimeBins=t.PrimesPerBin=void 0;const r=i(31586),s=i(30976),n=i(54993);t.PrimesPerBin=4,t.PrimeBins=8,t.SeedCount=t.PrimesPerBin**t.PrimeBins,t.prngSeed=function(){return(0,s.randomInt)(0,t.SeedCount)},t.toSeed=function(e){const i=(0,r.toInt)((0,n.toS)(e));return(0,r.within)(0,t.SeedCount,i)?i:void 0}},39926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),s=i(54993),n={};function a(e,t){if(t<1)return"";if(!(0,r.gte)(n[e]?.length,t)){let i=n[e]??e;for(;i.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var r=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return r.parseJSON}})},46891:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),s=new Map([["child","children"],["photo","photos"],["video","videos"]]),n=/([sxz]|ss|sh|ch)$/,a=/[^aeiou]y$/,o=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=s.get(e);return null!=t?t:null!=e.match(n)?e+"es":null!=e.match(a)?e.replace(/y$/i,"ies"):null!=e.match(o)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),s=i(54993),n=["number","string","boolean"];function a(e){return-1!==n.indexOf(typeof e)}t.isPrimitive=a,t.mapPrimitive=function(e,t){return a(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return a(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(a)};const o=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,n=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==n&&"symbol"!==n)){const r=(0,s.toS)(e),n=(0,s.toS)(i),a=r.localeCompare(n);return r[0]===t.CmpReverseFlag&&n[0]===t.CmpReverseFlag?-a:a}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==n?o.indexOf(r)-o.indexOf(n):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function s(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const s of(0,r.toA)(await e))if(null!=s){const e=await s;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=s,t.isPromise=function(e){return s(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),s=i(31586);function n(e,t){return Math.floor(Math.random()*(t-e))+e}function a(e,t,i){return null==i||0===i.length?n(e,t):o(e,t,1,i)[0]}function o(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const s=t-e,a=new Set(r??[]);if(t===e&&0===s&&0===a.size&&1===i)return[e];const o=s-a.size;if(i>o)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:s,size:i,slotsRemaining:o})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of o(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,s.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let r=e;t.global||(t=new RegExp(t,"g"));let s=null;for(;null!=(s=t.exec(e));)s.index===t.lastIndex&&t.lastIndex++,r=r.slice(0,s.index)+i(s)+r.slice(s.index+s[0].length);return r}},21605:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const r=i(31586);function s(e){if(!(0,r.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,r.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=s,t.swappableRotation=function(e){const t=s(e);return 90===t||270===t}},62220:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const r=i(50989);t.RunStates=(0,r.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),s=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),n={};for(const e of t)n[e]=e;const a=e=>null!=e?i[e]:void 0,o=e=>null!=a(e);return{...n,values:t,length:t.length,has:o,includes:o,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:a,ordinal:e=>a(e)??t.length,validOrElse:(e,t)=>o(e)?e:(0,s.tot)(t),mapValid:(e,t)=>o(e)?t(e):void 0,cmp:(e,t)=>{const i=a(e),r=a(t);return null==i||null==r?void 0:i>r?1:i{const i=a(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),s=i(17586),n=i(22573),a=i(96249),o=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=f();return null!=r?(0,o.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function b(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function S(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),s=(0,c.toS)(t);return r.length===s.length&&(r===s||r.toLowerCase()===s.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?s.normalize():s,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,n.blank)(t)?void 0:e.find((e=>S(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,s.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,o.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return w(v(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=b,t.wrap=function e(t,i){const r=i?.maxLineLen??80,s=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,a.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,a.flatten)(r.map((t=>e(t,i))))}if((t=v((0,c.toS)(t),s).trim()).length<=r)return[t];const n=b(t," ",r);if(n>s.length)return[m(t,0,n),...e(m(t,n+1),i)];{const r=t.indexOf(" ",s.length+1);return r>0&&r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),s=i(68708),n=i(42279),a=i(83104),o=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let s=!0;const n=setTimeout((()=>{s&&(s=!1,i(a.Timeout))}),t);try{n.unref?.();const t=await e;s&&(s=!1,i(t))}catch(e){s&&(s=!1,r(e))}finally{clearTimeout(n)}}))}async function u(e,t,i=!0){const s=await l(e,t,i);if(s===a.Timeout)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return s}t.toNotTimeout=function(e){return e===a.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?a.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,n)=>{let a=!0;try{const o=setTimeout((async()=>{if(a){a=!1;try{r(await i())}catch(e){n(e)}}}),t);(0,s.maybeCall)(o,"unref");const l=await e;a&&(a=!1,clearTimeout(o),r(l))}catch(e){a&&(a=!1,n(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const s=t-Date.now();if(s<=0)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(s)+")");return u(e,s,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const s=await l(e,t,r);return s===a.Timeout?(0,n.tot)(i):s}},99036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbFits=void 0;const r=i(50989);t.ThumbFits=(0,r.strEnum)("aspect","square")},42279:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),s=i(22573),n=i(54993);function a(e){return"URLSearchParams"===e?.constructor?.name}function o(e){return null==e?void 0:a(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(o)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=a,t.toURLSearchParams=o,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,n.toS)(l(...t));return e+((0,s.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,n.toS)(l(...t));return(0,s.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),s=i(30301),n=i(31586),a=i(46891),o=i(50989),l=i(51926),u=(0,s.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,n.isNumber)(r)&&(i+=r/t.MB);return(0,n.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,n.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,n.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),s=Math.pow(10,3*r),a=d[r];return(0,n.sigFigs)(e/s,t)+" "+a}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),s=Math.pow(2,10*r),a=h[r];return(0,n.sigFigs)(e/s,t)+" "+a},t.MP=1e6,t.megapixels=function(e){return(0,n.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,o.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,a.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,a.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},22403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ua=void 0;const r=i(30301),s=i(54993);t.ua=(0,r.lazy)((()=>(0,s.toS)(globalThis?.navigator?.userAgent)))},2322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,r=/\bSafari\b/,s=/\bFirefox\b/,n=/\biPad\b/,a=/\biPhone\b/;function o(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return o(e,i)}function u(e){return o(e,s)}t.isChrome=l,t.isSafari=function(e){return o(e,r)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return o(e,n)},t.isIphone=function(e){return o(e,a)}},32790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeQuote=t.AssetQueryOrderByColumns=void 0;const r=i(50989),s=i(54993);t.AssetQueryOrderByColumns=(0,r.strEnum)("capturedAt","updatedAt"),t.maybeQuote=function(e){return null!=(e=(0,s.toS)(e).trim()).match(/\s/)?`"${e}"`:e}},58939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.idEql=t.id2id=void 0;const r=i(55835),s=i(31586);function n(e){const t=e;return(0,s.isNumber)(e)?e:(0,s.isNumber)(t.id)?t.id:(0,s.isNumber)(t.assetId)?t.assetId:(0,s.isNumber)(t.tagId)?t.tagId:void 0}t.id2id=n,t.idEql=function(e,t){return(0,r.map2Or)(n(e),n(t),((e,t)=>e===t),(()=>!1))}},12236:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressWithAssetsProps=t.noRecentAssetIdsProgress=t.isRebuildProgress=t.EmptyRemovedURI=t.EmptyDeletedURI=t.RebuildingURI=t.SyncStatuses=void 0;const r=i(50989);t.SyncStatuses=(0,r.strEnum)("processing","paused","done"),t.RebuildingURI="rebuilding://",t.EmptyDeletedURI="emptydeleted://",t.EmptyRemovedURI="emptyremoved://",t.isRebuildProgress=function(e){return t.RebuildingURI===e?.uri},t.noRecentAssetIdsProgress=function(e){return[t.EmptyDeletedURI,t.EmptyRemovedURI].includes(e?.uri)},t.ProgressWithAssetsProps=["uri","volume","state","hed","dek","completePct","incompletePct","scanningPct","recentAssetIds"]},41942:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkReplace=t.XLocationReplace=t.mkRedirect=t.XLocationRedirect=void 0,t.XLocationRedirect="X-Location-Redirect",t.mkRedirect=function(e,i){return{[t.XLocationRedirect]:e,toast:i}},t.XLocationReplace="X-Location-Replace",t.mkReplace=function(e,i){return{[t.XLocationReplace]:e,toast:i}}},71050:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isServerToast=t.DismissAnchor=t.isToastPlusOnly=void 0;const r=i(22573);t.isToastPlusOnly=function(e){return!0===e?.toastPlusOnly},t.DismissAnchor="#dismiss",t.isServerToast=function(e){return(0,r.notBlank)(e?.text)}},79114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.S=void 0;const r=i(50989);t.S=(0,r.strEnum)("plus","lite")},75020:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInfoTag=t.NotInfoPanelTags=t.LibraryTagName=t.TagRoots=t.isTagRef=t.ctxToS=t.TagGalleryProps=t.nextChildTagsUrl=t.nextAssetsUrl=t.BeforeAfterStreamLimit=t.ThumbsPerSample=void 0;const r=i(76790),s=i(22573),n=i(98553),a=i(31586),o=i(50989),l=i(51926),u=i(29652);t.ThumbsPerSample=128,t.BeforeAfterStreamLimit=8,t.nextAssetsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/assets`,i)},t.nextChildTagsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.seed,(e=>i.seed=e.toString())),(0,a.mapNumeric)(t.limit,(e=>i.limit=e.toString())),(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/child-tags`,i)},t.TagGalleryProps=["tagId","tagPath","assetCount","assetIds","nextAssets","childTags","nextChildTags"],t.ctxToS=function(e){return(0,n.stringify)({seed:e.seed,tagIds:(0,r.sort)([...e.tagIds])})},t.isTagRef=function(e){return null!=e&&!(0,l.isString)(e)&&(0,s.notBlank)(e.name)},t.TagRoots=(0,o.strEnum)("When","Who","Where","What","Camera","Lens","Albums","Keywords","Type","fs"),t.LibraryTagName="Library",t.NotInfoPanelTags=[t.TagRoots.When,t.TagRoots.Camera,t.TagRoots.Lens,t.TagRoots.Type,t.TagRoots.fs],t.isInfoTag=function(e){if(null==e)return!1;const i=(0,l.isString)(e)?e:e.tagPath?.[0];return!t.NotInfoPanelTags.includes(i)}},94383:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiProgressPath=void 0,t.ApiProgressPath="/sse/progress"},27776:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkTagUri=t.mkTagFullPath=t.mkHomeFullPath=t.urlSeed=void 0;const r=i(40958),s=i(30301),n=i(31586),a=i(97238),o=i(29652);function l(e,i){const r=(0,o.toURLSearchParams)(e);if(i||!(0,n.isDigits)(r?.get("seed"))){const e=(0,t.urlSeed)().toString();return r?.set("seed",e),r??{seed:e}}return r}function u(e,t,i=!1){const r=c(e,t,i);return(0,o.assembleFullPath)(r.path,r.query)}function c(e,t,i=!1){return{path:"/tag/"+((0,r.isEmpty)(e)?"":e.map(encodeURIComponent).join("/")),query:l(t,i)}}t.urlSeed=(0,s.lazy)(a.prngSeed,100),t.mkHomeFullPath=function(e){return u([],e,!0)},t.mkTagFullPath=u,t.mkTagUri=c},23541:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),s=i(51926);function n(e){return Array.isArray(e)?e:null==e?void 0:(0,s.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return n(e)??[]},t.optToA=n},41583:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),s=i(23541),n=i(59455),a=i(54993);function o(e){return null==e?void 0:(0,s.isError)(e)?e:new Error((0,a.toS)(e))}t.toErr=o,t.toErrs=function(...e){return(0,r.compact)((0,n.toA)(e).map(o))}},54993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return n(e,",")};const s={}.toString;function n(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>n(e,t))).join(t):e.toString!==s?e.toString():(0,r.stringify)(e)}}t.toStr=n},98401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cancelFileAndProcCleanups=t.scheduleFileAndProcCleanups=t.fileCleanups=t.cleanup_=t.maybeCleanup_=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(56519),o=i(76187),l=i(87290),u=i(79267),c=i(32144),d=i(13829),h=i(69734),f=i(95696),m=i(65238),p=i(70257),g=i(13940),y=i(12495),v=i(95402),w=i(28874),b=i(40958),S=i(42659),P=i(31586),_=i(64526),T=i(22526),M=i(69032),E=(0,r.lazy)((()=>(0,s.mkLogger)("library.Cleanup")));async function k(){const e=_.Library.instance();if(null==e)E().info("No library to vacuum.");else{E().info("Running tag and search maintenance...");try{await(0,M.runTagMaintenance)()}catch(e){E().warn("Failed to run tag maintenance",{error:e})}E().info("Vacuuming db..."),await(await e.dbModelSetup_()).db.vacuum(),(0,n.isDbJanitorService)()&&(E().info("Running database maintenance..."),await e.runDbBackup_())}E().info("Cleaning child processes..."),await(v.Pids.instance()?.killOldProcs()),E().info("Cleaning stale and temp files..."),await D(),await(0,a.mapAsync)({name:"fileCleanup",arr:j(),f:e=>e.cleanup()})}t.maybeCleanup_=(0,r.lazy)(k,5*S.minuteMs),t.cleanup_=k;const D=(0,r.lazy)((()=>(0,l.libraryDataDirPosixFile)()?.join("shared-state").rmrf())),x=(0,r.lazy)((()=>u.FileCleanup.for({name:"imageCacheCleanup",rootNativePath:g.imageCacheDir_,staleMs:w.Settings.imageCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(g.ImageCacheName)}))),C=(0,r.lazy)((()=>u.FileCleanup.for({name:"readdirCacheCleanup",rootNativePath:async()=>f.PosixFile.for((0,m.readdirCacheDir)()),staleMs:w.Settings.readdirCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(m.ReadDirCacheName)}))),F=(0,r.lazy)((()=>u.FileCleanup.for({name:"previewWipCleanup",rootNativePath:l.libraryPreviewsDirPosixFile,staleMs:S.hourMs,isPrunable:e=>(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)}))),A=(0,r.lazy)((()=>u.FileCleanup.for({name:"advisoryLockWipCleanup",rootNativePath:d.defaultFsAdvisoryLockDir,staleMs:S.hourMs,isPrunable:h.isPsLockFileOrDir}))),I=(0,r.lazy)((()=>u.FileCleanup.for({name:"syncReportCleanup",rootNativePath:()=>(0,P.gt0)(w.Settings.syncReportRetentionCount.valueOrDefault)?(0,l.librarySyncReportsDir)():void 0,staleMs:S.hourMs,isPrunable:e=>(0,p.isWip)(e)||(0,c.isCsvExt)(e)})));function O(e){return(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)||(0,o.isSqliteFile)(e)}const L=(0,r.lazy)((()=>u.FileCleanup.for({name:"oldLibraryDbBackupCleanup",rootNativePath:()=>(0,T.libraryDbObjects_)().libraryDbBackupDir.sibling("backup"),staleMs:S.hourMs,isPrunable:O}))),R=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryDbBackupCleanup",rootNativePath:()=>(0,T.libraryDbObjects_)().libraryDbBackupDir,staleMs:S.hourMs,minRetained:w.Settings.dbBackupRetentionCount.valueOrDefault,isPrunable:O})));async function N(){const e=await(_.Library.instance()?.dbModelSetup_());return null!=e&&e.useReplica?e.db.localBackupDir():void 0}const B=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryReplicaDbBackupCleanup",rootNativePath:N,staleMs:S.hourMs,minRetained:1,isPrunable:O})));function j(){return(0,b.compact)([x(),C(),F(),A(),(0,y.LogDirCleanup)(),I(),L(),R(),B()])}t.fileCleanups=j,t.scheduleFileAndProcCleanups=(0,r.lazy)((()=>{v.Pids.instance()?.scheduleInterval();for(const e of j())e.scheduleInterval()})),t.cancelFileAndProcCleanups=function(){t.scheduleFileAndProcCleanups.unset(),v.Pids.instance()?.cancelInterval();for(const e of j())e.cancelInterval()}},64526:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Library=void 0;const l=i(27395),u=i(25764),c=i(38836),d=i(99331),h=i(45608),f=i(15056),m=i(87290),p=i(38835),g=i(57159),y=i(61704),v=i(95696),w=i(18454),b=i(13940),S=i(48604),P=i(19851),_=i(23560),T=i(28874),M=i(2858),E=i(7014),k=i(63870),D=i(15674),x=i(22573),C=i(38639),F=i(42659),A=i(56409),I=i(68708),O=i(25470),L=i(22526),R=i(41844);class N extends c.EndableWrapper{static instance(){const e=T.Settings.libraryDir.valueOrDefault,t=a(this,r,"f",s)?.rootDir.nativePath,i=!0===a(this,r,"f",s)?.isReadySync(),n=!0===a(this,r,"f",s)?.ended;return(0,y.nativePathsEqlSync)(t,e)&&!n?a(this,r,"f",s):(0,_.isSyncService)()&&i?void(0,h.exit)({reason:`Library changed mid-run. Shutting down to pick up new library at ${e}.`,status:0}):((0,l.end)(a(this,r,"f",s)),o(this,r,(0,x.blank)(e)||!(0,M._libraryHasSettings)(e)?void 0:new r(e),"f",s))}static get priorInstance(){return a(this,r,"f",s)}static endPriorInstance(){const e=a(this,r,"f",s);return o(this,r,void 0,"f",s),(0,l.end)(e)}static async instanceReady(){const e=r.instance();return await(e?.ready),e}static instanceRequired_(){const e=r.instance();if(null==e)throw new Error("Library is undefined"+p.FatalErrorFlag);return e}constructor(e){super(`library.Library(${e})`,(()=>this.onEnd()),u.EndableRanks.predb),this.start=Date.now(),this.readyLatch=new A.Latch,n.set(this,(0,P.lazy)((async()=>{try{this.logger.debug("setup() started"),this.logger.throwIfAborted_(),await(0,M.readLibrarySettings)(this.rootDir.nativePath),await(0,m.setupLibraryDirs_)(this.rootDir),await(0,b.imageCacheDir_)(),this.logger.throwIfAborted_();const e=await(0,E.bestVolumeForPath)((0,m.libraryPreviewsDirPosixFile)(this.rootDir));if((0,C.isTrue)(e?.remote)){const e=T.Settings.maxConcurrentImportsWhenRemote.valueOrDefault;T.Settings.maxConcurrentImports.hasValue()||(T.Settings.maxConcurrentImports.tmpValue=e,(0,D.clearMaxWorkCaches)()),this.logger.warn(`Library previews are on a remote volume. Setting maxSyncFileJobsMax to ${e}.`)}this.logger.throwIfAborted_(),(0,_.isDbService)()&&await this.dbModelJanitor(),this.previews(),this.logger.throwIfAborted_(),this.readyLatch.isPending()&&(this.logger.info("Library.setup() finished."),this.readyLatch.resolve())}catch(e){this.ended||(0,d.ending)()||(this.logger.warn("setup() failed:",{error:e}),w.HealthCheck.addError(e),this.readyLatch.reject(new g.WrappedError("Failed to start library",{cause:e})))}}))),this.previews=(0,P.lazy)((()=>(0,I.tap)(new S.Previews((0,m.libraryPreviewsDirPosixFile)(this.rootDir)),(e=>S.Previews.instance.set(e))))),this.originalsDir=(0,P.lazy)((()=>(0,m.libraryOriginalsDirPosixFile)(this.rootDir))),this.assetFileRepository=(0,P.lazy)((()=>new R.AssetFileRepository(this.originalsDir()))),this.libraryDbFile=(0,P.lazy)((()=>(0,f.pathToDb)(this.dataDir,"models"))),this.dbModelSetup_=(0,P.lazy)((async()=>{if((0,_.isDbService)())return(0,L.dbModelSetup_)(this.rootDir);throw new Error("Not a db service")})),this.dbFsLock=(0,P.lazy)((async()=>(await this.dbModelSetup_()).fslock)),this.useReplica=(0,P.lazy)((async()=>(await this.dbModelSetup_()).useReplica)),this.modelDb=(0,P.lazy)((async()=>(await this.dbModelSetup_()).db)),this.dbModelJanitor=(0,P.lazy)((async()=>O.DbModelJanitor.for(await this.dbModelSetup_()))),this.onEnd=(0,P.lazy)((async()=>{if(!(0,d.ending)())for(const{ea:e,t}of[{ea:this.dbModelJanitor.clear(),t:5*F.minuteMs},{ea:this.dbFsLock.clear(),t:(0,k.commandTimeoutMs)()}])await(0,l.end)(e,t);this.logger.info("onEnd(): finished.")})),this.rootDir=v.PosixFile.for(e),this.dataDir=(0,m.libraryDataDirPosixFile)(this.rootDir),this.logger.info("new()"),a(this,n,"f").call(this)}get isPendingSetup(){return this.readyLatch.isPending()}get ready(){return this.readyLatch.promise.then((()=>this))}isReadySync(){return this.readyLatch.isResolved()}async runDbBackup_(){return(await this.dbModelJanitor())?.backup_()}}t.Library=N,r=N,n=new WeakMap,s={value:void 0}},19113:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFileFiltersFor=void 0;const r=i(62105),s=i(181),n=i(94448),a=i(39604);t.libraryFileFiltersFor=function(e,{validateFile:t=!1}={}){const i=(0,r.expensiveFileFiltersFor)(e);return null!=(0,n.modelDb)()&&i.push({notBlocklistedSha:a.notBlocklistedSha}),t&&i.push({isValidFile:s.isValidFile}),i}},78339:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.saveLibrarySettings=t.importSettings=t.librarySettings=void 0;const r=i(19851),s=i(50213),n=i(71567),a=i(87290),o=i(98314),l=i(95696),u=i(28874),c=i(2858),d=i(32707),h=i(22573),f=i(50357),m=i(54993),p=i(14611),g=(0,s.mkLogger)("LibrarySettings");function y(e={}){return g.tap({msg:"librarySettings",level:"info",result:{scanAllDrives:u.Settings.scanAllDrives.valueOrDefault,scanPath:u.Settings.scanPaths.values,copyAssets:u.Settings.copyAssetsToLibrary.valueOrDefault,autoUpdateCheck:u.Settings.autoUpdateCheck.value,allowUserAgent:u.Settings.allowUserAgent.value,reportErrors:u.Settings.reportErrors.value,...e}})}function v(e){u.Settings.scanAllDrives.setValueIfDefined(e.scanAllDrives),u.Settings.scanPaths.setValueIfDefined(e.scanPath),u.Settings.copyAssetsToLibrary.setValueIfDefined(e.copyAssets),u.Settings.autoUpdateCheck.setValueIfDefined(e.autoUpdateCheck),u.Settings.allowUserAgent.setValueIfDefined(e.allowUserAgent),u.Settings.reportErrors.setValueIfDefined(e.reportErrors)}t.librarySettings=y,t.importSettings=v,t.saveLibrarySettings=async function(e,t){const i=l.PosixFile.forMaybe((0,m.toS)(e).trim())?.resolve(),s=y(),w=u.Settings.libraryDir.valueOrDefault,b=i??l.PosixFile.forMaybe(w);let S=Promise.resolve();const P=(0,r.lazy)((()=>{S=S.then((async()=>{try{v(s),u.Settings.libraryDir.value=w,await(0,c.writeSystemSettings_)(),(0,h.blank)(w)||await(0,c.writeLibrarySettings_)(w),await(0,p.restartLibrary_)()}catch(e){g.warn("Failed to roll back to prior settings",{priorSettings:s,priorLibraryDirValue:w,error:e})}}))}));if(null==b)return{error:"Please choose a directory for your library.",ready:S};const _=b?.nativePath!==w;if(_){try{await(0,a.setupLibraryDirs_)(b)}catch(e){return{error:"Failed to set up "+b+". Please choose a different directory for your library. "+(0,o.errorToS)(e)}}g.info("Library directory changed, asking sync to shut down",{prior:w,new:i?.nativePath}),n.StdoutWrite.shutdownSync()}try{v(t);const e=!(0,f.eql)(s,y());if(null==await(0,c.writeLibrarySettings_)(b.nativePath))return P(),{error:"Cannot write to "+b.nativePath+". Please choose a different directory for your library.",ready:S};u.Settings.libraryDir.value=b.nativePath;try{await(0,c.writeSystemSettings_)()}catch(e){return P(),g.warn("Failed to write system settings",e),{error:"Couldn't write your system settings to "+(0,d.systemSettingsFile)()+": "+(0,o.errorToS)(e),ready:S}}return g.info("saveLibrarySettings()",{libraryDirChanged:_,librarySettingsChanged:e,settings:t,priorSettings:s,currentSettings:y()}),(_||e)&&(S=S.then((()=>(0,p.restartLibrary_)({readSettings:!1})))),{msg:"Saved",ready:S}}catch(e){return P(),g.error("Failed to save settings",{error:e}),{error:"Failed to save settings: "+(0,o.errorToS)(e),ready:S}}}},14611:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartLibrary_=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(71567),o=i(34102),l=i(18454),u=i(28874),c=i(2858),d=i(64526),h=(0,r.lazy)((()=>(0,s.mkLogger)("library.RestartLibrary")));t.restartLibrary_=async function(e){if((0,n.isWebService)()&&a.StdoutWrite.shutdownSync(),e?.readSettings??1){for(const e of(0,u.persistedSettings)())e.unsetFileValue();await c.readSettings.refresh()}let t=Promise.resolve();h().warn("Shutting down prior library...");try{t=d.Library.endPriorInstance()}catch(e){h().warn("ending prior library failed:",{error:e})}(0,o.ee)().emit("clearCache"),null!=e?.libraryDir&&e.libraryDir!==u.Settings.libraryDir.valueOrDefault?u.Settings.libraryDir.value=e.libraryDir:u.Settings.libraryDir.broadcastChange(),l.HealthCheck.reset();const i=d.Library.instance();return t=t.then((()=>i?.ready)).then((()=>{})),(0,n.isWebService)()&&(t=t.then((async()=>{const e=await l.HealthCheck.awaitSettled();"ready"===e.state?a.StdoutWrite.restartSync():h().error("Restarted library, but health check summary was not ready",{summary:e})}))),{ready:t}}},18449:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sentryEnabled=void 0;const r=i(7282),s=i(96706),n=i(29325),a=i(28874);t.sentryEnabled=function(){return(0,s.isEnvTrue)("ENABLE_SENTRY")||(0,r.isProd)()&&(0,n.isPacked)()&&!0===a.Settings.reportErrors.value}},95629:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelToSeverity=t.logEntryToBreadcrumb=t.mkBreadcrumbs=t.annotateEvent=t.sentryExceptionToS=t.sentryExceptionsToS=t.extractMessage=t.EventFilter=t.eventFilter=t.sendToSentry=t.installSentry=void 0;const o=n(i(16436)),l=a(i(48161)),u=a(i(1708)),c=i(19851),d=i(19043),h=i(50213),f=i(31578),m=i(7282),p=i(96175),g=i(23560),y=i(84968),v=i(81168),w=i(37805),b=i(25764),S=i(38836),P=i(99331),_=i(85100),T=i(98314),M=i(68301),E=i(70025),k=i(8769),D=i(34102),x=i(34592),C=i(42042),F=i(34474),A=i(20839),I=i(57902),O=i(45969),L=i(43334),R=i(40958),N=i(22573),B=i(42659),j=i(41400),z=i(98553),V=i(55835),W=i(12168),U=i(59455),q=i(54993),H=i(18449),$=(0,c.lazy)((()=>(0,h.mkLogger)("Sentry")));function G(e){(0,H.sentryEnabled)()&&null!=e&&!0!==(0,E.isDoNotSendError)(e)&&o.captureException(e)}t.installSentry=async function(e){try{return!!(0,H.sentryEnabled)()&&(o.init({dsn:L.isElectron?"https://0652cdd351054fe9853ff944b1f54e2c@o130922.ingest.sentry.io/289071":"https://5f52aefec1b3439eaed2e77b2d1210a8@o130922.ingest.sentry.io/1828379",shutdownTimeout:(0,_.serviceExitTimeoutMs)(e.name),release:w.release,environment:(0,m.nodeEnv)(),maxBreadcrumbs:100,integrations:[],beforeSend:(0,t.eventFilter)().beforeSend,onFatalError:e=>(0,k.onError)("sentry.onFatalError",e)}),$().info("Sentry initialized",{isElectron:L.isElectron}),!0)}catch(e){return $().warn("Failed to set up sentry",{error:e}),!1}},t.sendToSentry=G,t.eventFilter=(0,c.lazy)((()=>new J));class J{constructor(){this.beforeSend=async(e,t)=>{if(!(0,H.sentryEnabled)())return $().warn("Sentry.beforeSend(): not sending event",e),null;if(!0===await(M.ErrorStore.instance()?.eventQuotaExceeded(e)))return $().warn("Sentry.beforeSend(): event quota exceeded",e),null;const i=K(e,t);if(!0===(0,E.isDoNotSendError)(i))return $().info("Sentry.beforeSend(): event not sendable. vetoing",{event:e,hint:t,msg:i}),null;(0,N.blank)(e.message)&&(e.message=(0,v.ellipsize)(i,256));const r=await Z(e);return await(M.ErrorStore.instance()?.maybeSendEvent(r))??null},(0,D.ee)().on("fatal",G),(0,D.ee)().on("nonFatal",G),new S.EndableWrapper("EventFilter",(()=>this.end()),b.EndableRanks.first)}end(){return(0,V.map)(o.getCurrentHub().getClient(),(e=>e.close(5*B.secondMs)))}}function K(e,t){return(0,R.uniq)((0,R.compactBlankish)([e.message,...(0,U.toA)(Y(e.exception?.values)),(0,T.errorToS)(t?.originalException)])).join(": ")}function Y(e){return(0,R.mapNotEmpty)(e,(e=>(0,R.compactBlanks)(e.map(X))))}function X(e){return(0,R.mapNotEmpty)((0,R.compactBlanks)([e?.type,e?.value].filter((e=>"error"!==(0,q.toS)(e).toLowerCase()))),(e=>e.join(": ")))}async function Z(e){const t=await(0,C.getEmail)();(0,N.notBlank)(t)&&(null==e.user&&(e.user={}),e.user.email=t),(0,R.isEmpty)(e.breadcrumbs)&&(e.breadcrumbs=await Q());const i=e.extra??{};return i.pid=u.default.pid,i.serviceName=(0,g.serviceName)(),i.serviceEnding=(0,P.ending)(),i.runtimeMs=(0,y.runtimeMs)(),i.version=w.version,i.os=(0,p.osFullName)(),i.isDocker=(0,O.isDocker)(),i.nodeVersion=u.default.versions.node,i.locale=await(0,d.locale)(),i.cpus=(0,p.CPUs)(),i.memoryUsageMb=(0,f.memoryUsageMb)(),i.memoryUsageRssMb=(0,f.memoryUsageRssMb)(),i.systemMemory=(0,W.fmtBytes)(l.default.freemem())+" / "+(0,W.fmtBytes)(l.default.totalmem()),i.ffmpeg=await(0,x.ffmpegVersionDescription)(),i.argv=(0,z.stringify)(u.default.argv),e.extra=i,{timestamp:Date.now()/B.secondMs,...e}}async function Q(){await(0,j.delay)(3*A.DefaultLogFlushMs);const e=await(0,F.allRecentLogEntries)();return(0,R.compact)(e.map(ee))}function ee(e){return(0,V.map)(ie(e.l),(t=>({timestamp:e.ts/B.secondMs,level:t,category:e.from??(0,g.processName)(),message:(0,v.stripAnsiEsc)(e.ctx+": "+e.msg),data:"object"==typeof e.meta?e.meta:{value:(0,v.isString)(e.meta)?(0,v.stripAnsiEsc)(e.meta):e.meta}})))}t.EventFilter=J,t.extractMessage=K,t.sentryExceptionsToS=Y,t.sentryExceptionToS=X,t.annotateEvent=Z,t.mkBreadcrumbs=Q,t.logEntryToBreadcrumb=ee;const te=new Map([[I.LogLevels.fatal,"fatal"],[I.LogLevels.error,"error"],[I.LogLevels.warn,"warning"],[I.LogLevels.info,"info"],[I.LogLevels.debug,"debug"]]);function ie(e){return te.get(e)}t.logLevelToSeverity=ie},37158:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Service=t.setupEventHandlers=void 0;const p=m(i(29907)),g=m(i(1708)),y=i(57206),v=i(19851),w=i(50213),b=i(59880),S=i(23560),P=i(19913),_=i(71567),T=i(37805),M=i(38836),E=i(99331),k=i(45608),D=i(56038),x=i(55534),C=i(42499),F=i(49776),A=i(96706),I=i(98314),O=i(38835),L=i(70025),R=i(8769),N=i(57159),B=i(34102),j=i(33456),z=i(87408),V=i(85021),W=i(17181),U=i(86941),q=i(28874),H=i(41692),$=i(2858),G=i(69385),J=i(22573),K=i(42659),Y=i(41400),X=i(56409),Z=i(55835),Q=i(41583),ee=i(54993),te=i(95629);t.setupEventHandlers=(0,v.lazy)((()=>{(0,B.ee)().on("resume",(()=>(0,G.resume)())),(0,B.ee)().on("pause",(()=>(0,G.pause)()))}));class ie extends M.EndableWrapper{constructor(e){super(e),r.add(this),s.set(this,void 0),n.set(this,new X.Latch),a.set(this,new Map),this.setup_=(0,v.lazy)((()=>(0,D.time)("Service.setup",(()=>f(this,r,"m",o).call(this))))),u.set(this,(0,v.lazy)((()=>{const e=g.default.stdin.pipe(new j.LineReader);return e.on("data",(e=>f(this,r,"m",d).call(this,(0,ee.toS)(e)))),e}))),(0,S.isBillingService)()||(0,H.setSettingsDefaults)(),h(this,s,(0,w.mkLogger)("Service("+this.name+")"),"f"),f(this,r,"m",c).call(this),this.setup_()}get name(){return super.name}get ready(){return f(this,n,"f").promise}get isReady(){return f(this,n,"f").isResolved()}setInputHandler(e,t){f(this,a,"f").set(e.trim().toLowerCase(),t)}}t.Service=ie,s=new WeakMap,n=new WeakMap,a=new WeakMap,u=new WeakMap,r=new WeakSet,o=async function(){try{(0,J.mapNotBlank)((0,A.getEnv)("PS_FATAL_"+this.name),(e=>{throw new N.WrappedError(e,{fatal:!0})})),(0,J.mapNotBlank)((0,A.getEnv)("PS_CRASH_"+this.name),(e=>{(0,Y.later)((()=>{throw new N.WrappedError(e)}),5*K.secondMs)})),(0,P.setServiceName)(this.name),(0,b.setProcessTitle)(),(0,S.isMainService)()&&await(0,U.mergeUserDataDirs_)(),await(0,$.readSettings)(),await f(this,r,"m",l).call(this),(0,W.setupLogger)(),(0,y.addDefaultJsonRevivers)(),(0,F.cacheDir)(),(0,t.setupEventHandlers)(),f(this,u,"f").call(this),await(0,C.setupLuxon)(),q.Settings.startPaused.valueOrDefault&&(0,G.pause)(),(0,E.ending)()?f(this,n,"f").reject():f(this,n,"f").resolve()}catch(e){console.error((0,I.errorToS)(e)),f(this,n,"f").reject((0,Q.toErr)(e)),(0,k.exit)({reason:(0,L.addErrorFlags)(this.name+" setup failed: "+(0,I.errorToS)(e),O.FatalErrorFlag),status:14})}},l=async function(){(0,S.isPermaService)()||(0,B.ee)().on("fatal",(e=>(0,k.exit)({error:e,status:12}))),g.default.on("unhandledRejection",(e=>(0,Z.map)(e,(e=>(0,R.onError)("unhandledRejection",e))))),g.default.on("uncaughtException",(e=>(0,Z.map)(e,(e=>(0,R.onError)("uncaughtException",e))))),g.default.on("SIGINT",(()=>(0,k.exit)({reason:"SIGINT",status:0}))),g.default.on("SIGHUP",(()=>(0,k.exit)({reason:"SIGHUP",status:0}))),g.default.on("SIGTERM",(()=>(0,k.exit)({reason:"SIGTERM",status:0}))),p.default.isWorker&&g.default.on("disconnect",(()=>(0,k.exit)({reason:"disconnect",status:0}))),await(0,te.installSentry)(this)},c=function(){this.setInputHandler("--version",(()=>(0,_.stdoutWrite)({version:T.version}))),this.setInputHandler(x.ServiceExitCommand,(()=>(0,Y.later)((()=>(0,k.exit)({reason:x.ServiceExitCommand+" from stdin",status:0}))))),this.setInputHandler("--times",(()=>(0,_.stdoutWrite)(D.PromiseTimer.instance().report()))),this.setInputHandler(V.HealthCheckCommand,(async()=>(0,_.stdoutWrite)(await(0,z.getStatusSummary)({refresh:!0}))))},d=async function(e){if(f(this,s,"f").debug("onLine()",{line:e,ending:this.ended||(0,E.ending)()}),await this.setup_(),e.startsWith("--")){const t=e.split(/\s+/,1)[0],i=f(this,a,"f").get(t);null==i?(f(this,s,"f").error("onLine(): unknown command",{line:e,knownCommands:[...f(this,a,"f").keys()]}),console.warn("unknown command "+e)):await i(e.slice(t.length).trim())}else f(this,s,"f").error("onLine(): failed to process",{line:e})}},53791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shutdown=void 0;const r=i(19851),s=i(50213),n=i(71567),a=i(99331),o=i(45608),l=i(65812);let u="unspecified";t.shutdown=function(e){return(0,s.mkLogger)("Shutdown").warn("shutdown()",{reason:e}),u=e,c()};const c=(0,r.lazy)((async()=>{n.StdoutWrite.shutdown(),(0,l.setUnrefTimeout)((()=>(0,a.ending)()?void 0:(0,o.exit)({reason:u,status:0})),3e3)}))},57064:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t._suggestedLibraryDirs=t.suggestedLibraryDirs=t.SuggestedLibraryDir=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(72993),o=i(19851),l=i(50213),u=i(7282),c=i(45255),d=i(81168),h=i(56519),f=i(32551),m=i(48195),p=i(55939),g=i(44198),y=i(64660),v=i(83278),w=i(92423),b=i(29882),S=i(65238),P=i(16287),_=i(45969),T=i(28874),M=i(7014),E=i(40958),k=i(76790),D=i(22573),x=i(31586),C=i(12168),F=(0,o.lazy)((()=>(0,l.mkLogger)("library.SuggestedLibraryDir")));class A{static async for(e,t){if((0,D.blank)(e))return;const i=await(0,M.bestVolumeForPath)(e,t);if(null==i)return void F().warn("Skipping library directory suggestion: failed to find mountpoint volume",{nativePath:e});const r=await(0,m.isLibraryDir)(e);return new A(e,r,i)}constructor(e,t,i){this.nativePath=e,this.isLibrary=t,this.vol=i,this.isCurrentLibrary=T.Settings.libraryDir.value===this.nativePath}async whyExcluded(e=T.Settings.minDiskFreeGb.valueOrDefault*C.GB){if(this.isLibrary)return;const t=await(0,P.statMaybe)(this.nativePath,"trace"),i={msg:"whyExcluded()",meta:{nativePath:this.nativePath,stat:t,availableBytes:this.availableBytes,minAvailableBytes:e}};if((0,b.containsHiddenPathname)(this.nativePath))return F().tap({...i,result:"contains hidden path"});{const e=await(0,w.whyExcludedDirectoryRecursive)(v.BaseFile.for(this.nativePath));if(null!=e)return F().tap({...i,result:e})}return null==t||t.isDirectory()?await(0,y.canRWXFirstExistingAncestor)(this.nativePath)?(0,x.gt0)(e)&&this.availableBytesnew A(e,!1,{mountpoint:"/test",available:C.GB})))});const l=[],d=[],y=await i??await(0,M.volumes)();if(null==y||(0,E.isEmpty)(y))return F().warn("volumes() is empty: they don't get any suggestions."),[];async function v(t){const i=await A.for(t,y);if(null!=i)return i.isLibrary||i.isCurrentLibrary?(F().info("addSuggestion(): path is a library",i),void l.push(i)):void(null==await i.whyExcluded(e)&&d.push(i))}if(await v(T.Settings.libraryDir.value),(0,_.isDocker)())return[...l,...d];await v(await(0,p.picturesDir)());const w=[n.default.cwd(),...await(0,S.childDirectories_)(n.default.cwd())];(0,_.isDocker)()||w.push(...await(0,S.childDirectories_)((0,f.homeDir)())),(0,E.filterInPlace)(w,(e=>(0,b.isNotHiddenPosixPath)(e)));for(const e of w)await(0,m.isLibraryDir)(e)&&(F().info("current working dir is a library",e),await v(e));function P(){return Date.now()-r>c.ShortCommandTimeoutMs-500&&(F().debug("...ran out of time, stopping."),!0)}(0,_.isDocker)()||await v(s.default.join((0,f.homeDir)(),(0,a.AppName)())),await(0,h.mapAsync)({name:"suggestedLibraryDirs.addVolume",arr:y,f:e=>async function(e){try{if(await(0,m.isLibraryDir)(e.mountpoint))return F().info("addVolume(): vol.mountpoint is a library",e.mountpoint),void await v(e.mountpoint);for(const t of await(0,S.childDirectories_)(e.mountpoint)){if(P())break;if(await(0,m.isLibraryDir)(t))F().info("addVolume(): dir is a library",t),await v(e.mountpoint);else for(const i of await(0,S.childDirectories_)(t)){if(P())break;await(0,m.isLibraryDir)(i)&&(F().info("addVolume(): dir is a library",t),await v(e.mountpoint))}}const t=s.default.join(e.mountpoint,(0,a.AppName)());F().info("addVolume(): adding default suggestion",t),await v(t)}catch(t){F().warn("addVolume(): Failed to add suggestion",{err:t,vol:e})}}(e),timeoutMs:c.ShortCommandTimeoutMs}),F().debug("Finished gathering suggestions. Filtering...",{priorLibraries:l,suggestions:d});const D=l;for(const e of(0,k.sortBy)(d,(e=>[-e.availableBytes,-e.nativePath.length]))){if(D.length>=t)break;D.some((t=>t.nativePath===e.nativePath||t.mountpoint===e.mountpoint))||(F().debug("adding new path",e),D.push(e))}return(0,E.uniqBy)((0,k.sortBy)(D,(e=>[!e.isCurrentLibrary,!e.isLibrary,-e.free,e.nativePath])),(e=>e.nativePath))}t.SuggestedLibraryDir=A,t.suggestedLibraryDirs=(0,o.lazy)((()=>I())),t._suggestedLibraryDirs=I},77948:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemInformation=t.libraryMetrics=void 0;const r=i(21330),s=i(46296),n=i(17344),a=i(18454),o=i(81674),l=i(66184),u=i(96175),c=i(24540),d=i(23560),h=i(28874),f=i(2858),m=i(84968),p=i(94174),g=i(37805),y=i(14854),v=i(15674),w=i(40958),b=i(22573),S=i(38639),P=i(75240),_=i(55835),T=i(31586),M=i(20214),E=i(51926),k=i(12168),D=i(43487),x=i(54017),C=i(48723);async function F(){if(null==D.Asset.db())return;const e=[];e.push((0,k.plurMetric)(D.Asset.shownCount(),"asset"));const t=x.AssetFile.assetFileCountByMimeTypeRoots();for(const i of t){const t=(0,E.stripSuffix)(i.mimeTypeRoot,"/");e.push((0,k.plurMetric)(i.assetFileCount,t+" file"))}return e.push((0,k.plurMetric)(C.Tag.rows(),"tag")),e}t.libraryMetrics=F;const A={pending:"pending",ok:"ok","no-library":"warn",warn:"warn","stop-sync":"warn",error:"fail",disabled:"ok"};t.systemInformation=async function(){const e=await(0,o.b)(),t=e?.l?.tier??"lite",i=a.HealthCheck.summary();return(0,w.compact)([{term:"Version",defn:g.version},{term:"Edition",defn:(0,n.EditionName)()},{term:"Health checks",defnClass:A[i.level],defnTitle:"Click to see all health checks",termURL:"/health",defn:i.msg[0]},{term:"Subscription",defnClass:t,defn:t,termURL:"/plans/billing?then=/about",defnTitle:"Click to manage your PhotoStructure subscription"},...(0,S.isTrue)(e?.ok)?[{term:"Licensed to",defn:e?.l?.sub},{term:"Expires or renews",defn:(0,_.mapOr)(e?.l?.exp,(e=>(0,r.toIsoDate)(e)),"--"),termURL:"/plans/billing?then=/about",defnTitle:"Click to manage your PhotoStructure subscription"}]:[],{term:"OS",defn:(0,u.osFullName)()},{term:"CPUs",defn:(0,u.CPUs)()},{term:"System load",defn:(0,_.map)(y.CpuUsage.instance().busyPct(),(e=>(0,T.fmtPct)(e)+" busy"))??"(unavailable)"},{term:"Concurrency",defn:`Target system use: ${Math.round(h.Settings.cpuBusyPercent.valueOrDefault)}% (${(0,v.maxConcurrentImports)()} concurrent imports, ${(0,v.sharpThreadsPerProcess)()} gfx/process)`},(0,d.isWebService)()?{term:"Web uptime",defn:(0,P.fmtDuration)((0,m.runtimeMs)())}:void 0,(0,b.mapNotBlank)((0,c.procDeviceModel)(),(e=>({term:"Device",defn:e}))),{term:"Current user",defn:await(0,p.username)()+((0,T.gte0)((0,p.userid)())?"":" (userid: "+(0,p.userid)()+", groupid: "+(0,p.groupid)()+")")},(0,f.libraryHasSettings)()?{term:"Library path",defn:h.Settings.libraryDir.valueOrDefault,defnClass:"library"}:void 0,await(0,M.thenMap)(F(),(e=>({term:"Library metrics",termURL:"https://photostructure.com/faq/metrics/",defn:e}))),{term:"Log directory",defn:(0,s.logDir)()},{term:"Log level",termURL:"https://photostructure.com/faq/error-reports/#log-levels",defn:(0,l.defaultLogLevel)()}]).filter((({term:e,defn:t})=>(0,b.notBlank)(e)&&(0,b.notBlank)(t)))}},35580:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,v=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TaskList=t.TaskListRunLaterMs=void 0;const w=i(19851),b=i(7282),S=i(23560),P=i(88264),_=i(73568),T=i(78406),M=i(25764),E=i(99331),k=i(56038),D=i(42638),x=i(34102),C=i(70417),F=i(28874),A=i(14854),I=i(73328),O=i(69385),L=i(15674),R=i(40958),N=i(42659),B=i(45599),j=i(26905),z=i(56409),V=i(31586),W=i(94710);t.TaskListRunLaterMs=8;class U extends T.EndableInterval{constructor(){const e="TaskList()";super({name:e,callback:()=>this.maybeRunChunk(),intervalMs:7*N.secondMs,onEnd:()=>v(this,r,"m",a).call(this),rank:M.EndableRanks.first,endTimeoutMs:F.Settings.taskTimeoutMs.valueOrDefault}),r.add(this),this.recentlyProcessed=new P.TTLArray(N.minuteMs),s.set(this,[]),this.taskCount=(0,w.lazy)((()=>W.Task.count())),d.set(this,(0,w.lazy)((()=>{this.logger.debug("status",this.state())}),((0,b.isTest)()?1:30)*N.secondMs)),f.set(this,(()=>this.maybeRunChunk())),m.set(this,(0,w.lazy)((()=>this.logger.info("runChunk(): no-op",{isPaused:(0,O.isPaused)(),isFull:this.p.isFull(),isTooBusy:(0,A.isTooBusy)(),whyDoNotRun:(0,I.whyDoNotRun)(this),pendingWorkCount:this.pendingWorkCount(),queueItemCount:this.taskCount(),freeSlots:this.p.freeSlots()})),((0,b.isTest)()?1:30)*N.secondMs)),this.maybeRunChunk=(0,w.lazy)((()=>{setTimeout((()=>{this.ended||(0,E.ending)()||(v(this,r,"m",g).call(this),this.maybeRunChunk.unset())}),t.TaskListRunLaterMs)})),p.set(this,(0,w.lazy)((()=>{const e=F.Settings.minBusyPct.valueOrDefault,t=F.Settings.stuckCheckIntervalMs.valueOrDefault;if(e<=0||this.p.isIdle()||t<=0)return;const i=A.CpuUsage.instance().busyPct();if(this.logger.debug("maybeCheckForStuckTasks()",{cpuBusyPct:i,minBusyPct:e,stuckCheckIntervalMs:t}),!(0,V.gte)(i,e))for(const e of this.p.running)if(e.elapsedMs>t){const t=e.payload;this.logger.error("Stuck serial task. Aborting.",{task:t,elapsedMs:e.elapsedMs});const i="stuck after "+e.elapsedMs+"ms";t.abort(i),e.reject(new _.AbortError(i))}}),F.Settings.stuckCheckIntervalMs.valueOrDefault)),this.p=new D.Promises(e,L.maxConcurrentImports),this.p.ee.on("vacancy",this.maybeRunChunk),this.p.ee.on("drain",(()=>v(this,r,"m",l).call(this))),(0,x.ee)().on("resume",v(this,f,"f")),W.Task.ee.on("added",this.maybeRunChunk)}async awaitDrain(e=[],t=0){(0,R.isEmpty)(e)&&(e=W.TaskNames.values);const i=new z.Latch;return v(this,s,"f").push({l:i,taskNames:e,maxRemaining:t,who:(0,j.shortStack)()}),this.maybeRunChunk(),i}isRunnable(){return!this.p.isFull()}currentWorkCount(){return this.p.unsettledCount()}pendingWorkCount(){return this.taskCount()-this.currentWorkCount()}hasCapacity(e=F.Settings.taskListCap.valueOrDefault){return e<=0||this.taskCount()e.payload))}currentTasksByFn(e){return this.currentTasks().filter((t=>t.fn===e))}state(){return{...this.p.stats(),isDone:v(this,r,"m",l).call(this),freeSlots:this.p.freeSlots(),pendingWork:this.taskCount(),next10:v(this,r,"m",h).call(this,10).map((e=>e.toString())),recentlyProcessedLast10:this.recentlyProcessed.slice(-10).map((e=>e.toString())),isRunnable:this.isRunnable()}}doNotStartMoreWork(){return(0,E.ending)()||this.ended||(0,O.isPaused)()||this.p.isFull()||(0,A.isTooBusy)()||(0,I.doNotRun)(this)||0===this.pendingWorkCount()}}t.TaskList=U,s=new WeakMap,d=new WeakMap,f=new WeakMap,m=new WeakMap,p=new WeakMap,r=new WeakSet,n=function(){this.taskCount.unset()},a=async function(){(0,x.ee)().off("resume",v(this,f,"f"));const e=new _.AbortError((0,E.ending)()?"service ending":"TaskList ended");for(const t of v(this,s,"f"))t.l.reject(e);await this.p.awaitAll()},o=function(){(0,R.filterInPlace)(v(this,s,"f"),(e=>e.l.isPending())),W.Task.dbl.runf((e=>e.delete().where("retries","<",0))),v(this,r,"m",n).call(this)},l=function(){if(this.ended)return;if(v(this,r,"m",o).call(this),(0,R.isEmpty)(v(this,s,"f")))return;const e=W.Task.countTaskNames();for(const t of this.p.deferreds){const i=t.name;e[i]=(e[i]??0)+1}for(const t of v(this,s,"f"))(0,C.sum)(t.taskNames.map((t=>e[t]??0)))<=t.maxRemaining&&t.l.resolve()},u=function(){return(0,R.uniq)(this.currentTasks().filter((e=>e.isSerial)).map((e=>e.fn)))},c=function(){return this.currentTasks().map((e=>e.id))},h=function(e){return 0===e?[]:W.Task.ops().allf((t=>(t=W.Task.orderBy(t.distinct().whereNotIn("id",v(this,r,"m",c).call(this)).whereNotIn("fn",v(this,r,"m",u).call(this))),(0,V.gt0)(e)&&(t=t.limit(e)),t)))},g=function(){if(v(this,r,"m",n).call(this),v(this,p,"f").call(this),this.doNotStartMoreWork())v(this,m,"f").call(this);else{v(this,d,"f").call(this);const e=this.p.freeSlots(),t=v(this,r,"m",h).call(this,e);this.logger.debug("runChunk():",{freeSlots:e,next:t});for(const e of t)this.p.enqueue({name:this.name,payload:e,l:()=>v(this,r,"m",y).call(this,e),serialId:e.isSerial?e.fn:void 0})}v(this,r,"m",l).call(this)},y=async function(e){try{await(0,k.time)("task."+e.fn,e._run())}catch(t){this.logger.warn("Failed to run task",{task:e,error:t})}finally{this.maybeRunChunk()}},U.instance=(0,B.defer)((()=>(0,S.isTaskListManager)()?new U:void 0))},98392:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExposeArg=void 0;const r=i(28874),s=i(38639);t.ExposeArg={beforeParse:e=>e.option("--expose","The web service is only accessible to the computer running PhotoStructure by default. Providing this option will expose your library to all computers on your network. See https://photostructure.com/faq/remote-access/ ."),afterParse:e=>{(0,s.isTrue)(e.expose)&&(r.Settings.exposeNetworkWithoutAuth.envValue=!0)}}},31503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogArgs=void 0;const r=i(23560),s=i(83210),n=i(28874),a=i(38639);function o(){return(0,r.isMainService)()||(0,r.isSyncService)()}t.LogArgs={beforeParse:e=>{const t=(o()?', "PS_TAIL_LOGS=true"':"")+' and "PS_LOG_STDOUT=true".';return o()?e.option("-v, --verbose",'Verbose logging from all processes. Shortcut for "--info --tail". Caution: noisy during imports!'):e.option("-v, --verbose","Verbose logging. Equivalent to --info."),e.option("--error",`Emit "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=error"${t}`),e.option("--warn",`Emit "warn" and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=warn"${t}`),e.option("--info",`Emit "info", "warn", and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=info"${t}`),e.option("--debug",`Emit "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY NOISY. Sets "PS_LOG_LEVEL=debug"${t}}`),e.option("--trace",`Emit "trace", "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY VERY NOISY. Sets "PS_LOG_LEVEL=trace"${t}}`),o()&&e.option("--tail",'Emit log messages from both this process and all other concurrently running PhotoStructure processes on this host to stdout. This can be really helpful in seeing how PhotoStructure\'s processes are coordinating work. Caution: very noisy especially during imports. Sets "PS_TAIL_LOGS=true".'),e},afterParse:e=>{const t=(0,a.isTrue)(e.error),i=(0,a.isTrue)(e.warn),r=(0,a.isTrue)(e.info)||(0,a.isTrue)(e.verbose)||(0,a.isTrue)(e.v),l=(0,a.isTrue)(e.debug),u=(0,a.isTrue)(e.trace);u?n.Settings.logLevel.envValue="trace":l?n.Settings.logLevel.envValue="debug":r?n.Settings.logLevel.envValue="info":i?n.Settings.logLevel.envValue="warn":t&&(n.Settings.logLevel.envValue="error"),(0,s.isDaemon)(e)?(n.Settings.tailLogs.envValue=!1,n.Settings.logStdout.envValue=!1):((0,a.isTrue)(e.tail)&&(n.Settings.tailLogs.envValue=!0),(t||i||r||l||u)&&(n.Settings.logStdout.tmpValue=!0,o()&&(n.Settings.tailLogs.tmpValue=!0)),(n.Settings.tailLogs.valueOrDefault||n.Settings.logStdout.valueOrDefault)&&n.Settings.logLevel.isUnset()&&(n.Settings.logLevel.envValue="info"))}}},46628:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.albumsFromTags=t.tagFilesWithAlbums=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(81168),o=i(74417),l=i(28874),u=i(47783),c=i(97573),d=i(42231),h=i(40958),f=i(22573),m=i(68708),p=i(75020),g=i(54993),y=(0,s.lazy)((()=>(0,n.mkLogger)("curators.AlbumTagger")));function v(e){return(0,f.blank)(e)?void 0:l.Settings.tagAlbumTitleHierarchies.valueOrDefault?(0,c.keywordToPath)(e):[e]}function w(e){if(null==e)return[];const t=(0,h.uniq)((0,r.flatMap)(l.Settings.tagAlbumTitle.values,(t=>(0,m.pluckDeep)(e,t)?.value))),i=(0,h.compact)(t.map(v));if((0,h.isEmpty)(i))return[];if(i.length>1)return y().tap({level:"info",msg:"albumFromFile()",result:i.map((e=>[p.TagRoots.Albums,...e]))});const s=i[0],n=(0,r.first)(l.Settings.tagAlbumDescription.values,(t=>(0,m.pluckDeep)(e,t)?.value)),u=(0,h.isEmpty)(s)?"(blank title)":(0,a.firstSubstringIgnoreCase)(l.Settings.tagAlbumsExcluded.values,[...s,(0,g.toS)(n)].join(" ")),c=null==u?[p.TagRoots.Albums,...s]:void 0;if(null!=c){const t={name:c[c.length-1],description:n};for(const i of l.Settings.tagAlbumDate.values){const r=(0,o.parseJsonDateToMillis)((0,m.pluckDeep)(e,i)?.value);if(null!=r){t.releasedAt=r;break}}c[c.length-1]=t}return y().tap({level:"info",msg:"albumFromFile()",result:(0,h.compact)([c]),meta:{titles:i,desc:n,whyExclude:u}})}t.tagFilesWithAlbums=async function(e){const t=[];for(const i of e){t.push(...w(await(0,u.readTags)(i)));for(const e of l.Settings.tagAlbumFilenames.values)t.push(...w(await(0,u.readRawTags)(i.sibling(e),!1)))}return y().tap({msg:"tagFilesWithAlbums()",result:(0,d.uniqTagPaths)(t),meta:{files:e}})},t.albumsFromTags=w},88224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagAsset=t.tagAndUpsertAsset_=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(28874),o=i(42231),l=i(40958),u=i(20214),c=i(43487),d=i(46628),h=i(63175),f=i(4407),m=i(58886),p=i(32646),g=i(48144),y=i(60047),v=i(6186),w=i(42003),b=i(43723),S=(0,r.lazy)((()=>(0,s.mkLogger)("curators.AssetTagger")));async function P({primaryVariation:e,files:t,priorTagPaths:i,capturedAts:r,uris:s}){const u=[];if(t=(0,l.uniqBy)([e,...t],(e=>e.nativePath)),a.Settings.tagCamera.valueOrDefault&&await(0,n.thenMap)((0,h.cameraTagFile)(e),(t=>{S().debug("Camera tag for "+e+":",t),u.push(t)})),a.Settings.tagLens.valueOrDefault&&await(0,n.thenMap)((0,y.lensTagFile)(e),(t=>{S().debug("Lens tag for "+e+":",t),u.push(t)})),a.Settings.tagGeo.valueOrDefault)for(const e of t){const t=await(0,p.geoTagFile)(e);if(null!=t){u.push(t);break}}await(0,n.thenMap)((0,f.dateTagFile)(e,r),(t=>{S().debug("Date tag for "+e+":",t),u.push(t)}));const c=await(0,b.whoTagFiles)(t)??[];S().debug("whoTagFiles for "+e+":",c),u.push(...c),await(0,n.thenMap)((0,g.keywordTagFiles)(t,c),(t=>{S().debug("Keyword tags for "+e+":",t),u.push(...t)})),a.Settings.tagFileType.valueOrDefault&&await(0,n.thenMap)((0,w.typeTagFiles)(t),(t=>{S().debug("MIME type tags for "+e+":",t),u.push(...t)})),await(0,n.thenMap)((0,m.tagAssetPaths)(s),(e=>{S().debug("file paths for uris",{uris:s,arr:e}),u.push(...e)})),await(0,n.thenMap)((0,d.tagFilesWithAlbums)(t),(t=>{S().debug("Album tags for "+e+":",t),u.push(...t)}));const P=(0,o.omitAncestorTags)((0,l.uniqBy)(u.map(v.normalizeTagRoot),o.joinTagPath)),_=await(0,v.tagDeltas)(i,P);return S().info("tagAsset("+e+")",{priorTagPaths:i,after:P,result:_}),_}t.tagAndUpsertAsset_=async function(e){const t=await e.getExistingAssetFiles();S().info("tagAndUpsertAsset()",{asset:e,existing_uris:t.map((e=>e.uri))});const i=t.find((e=>e.shown)),r=await(i?.posixFile_());if(null==i||null==r)return void S().throw("tagAndUpsertAsset(): no existing or primary asset file",{asset:e,existingPrimaryAssetFile:i,primaryVariant:r,doNotSend:!0,fatal:!1});const s=e.getShown();s?.id!==i.id&&(S().warn("Changing primary asset we're using a different variant for tagging.",{newPrimary:i.uri,priorPrimary:s?.uri}),e.setShown_(i));const n=await(0,u.thenCollect)(t,(e=>e.posixFile_())),l=e.getAssetFiles().map((e=>e.uri)),d=e.getTagPaths(),h=await e.getCapturedAts(),f=await P({primaryVariation:r,files:n,priorTagPaths:d,capturedAts:h,uris:l});S().info("tagAndUpsertAsset",f);const m=f.add.find((e=>(0,o.leafIsExcluded)(e,a.Settings.keywordBlocklist.values)));if(null!=m){if(!0!==e.shown)return S().info("this asset has an excluded tag, and it wasn't shown yet, so we're removing it.",{excludedTag:m}),await c.Asset.remove({assetId:e.id,blocklistShas:!1,unlinkAssetFiles:!1}),S().throw("tagAndUpsertAsset(): asset had excluded tag. Removed.",{excludedTag:m,uris:l,files:n.map((e=>e.nativePath))});S().info("this asset has an excluded tag, marking excluded",{excludedTag:m}),e.excludedAt=Date.now()}return e.applyTagPathDeltas(f),await e.updateFromFiles(),f},t.tagAsset=P},63175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cameraTagFile=t.cameraTag=void 0;const r=i(47783),s=i(75020),n=i(40958),a=i(22573);function o(e){return null==e||(0,a.blank)(e.Make)?void 0:(0,n.compactBlankish)([s.TagRoots.Camera,e.Make,e.Model])}t.cameraTag=o,t.cameraTagFile=async function(e){return o(await(0,r.readTags)(e))}},4407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateTagFile=t.dateTag=t.dayTagRef=t.monthTagRef=t.yearTagRef=t.dayToOrdinal=t.ordinalToMonth=t.monthToOrdinal=t.yearToOrdinal=void 0;const r=i(19851),s=i(19043),n=i(97352),a=i(81168),o=i(928),l=i(34102),u=i(28874),c=i(28544),d=i(47783),h=i(40958),f=i(55835),m=i(31586),p=i(75020),g=i(54993),y=(0,r.lazy)((()=>new Intl.DateTimeFormat((0,s.localeSync)(),{month:"short"}))),v=(0,r.lazy)((()=>{const e=y();return(0,h.range)(0,12,(t=>e.format(new Date(2016,t,1)))).map((e=>(0,a.stripSuffix)(e,".")))}));function w(e){return 1e4-e}function b(e){return 13-e}function S(e){return 33-e}function P(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:w(e)})))}function _(e){if((0,m.within)(1,12,e))return(0,f.map)(v()[e-1],(t=>({name:String(e),displayName:t,ordinal:b(e)})))}function T(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:S(e)})))}function M(e){const t=(0,g.toS)(u.Settings.tagYMD.valueOrDefault).toLowerCase();if(null==e||""===t||"off"===t||t.startsWith("disable"))return;const i=[p.TagRoots.When];if(t.startsWith("y")){const t=(0,f.map)((0,o.getYear)(e),P);if(null==t)return;i.push(t)}if(t.startsWith("ym")){const t=(0,f.map)((0,o.getMonth)(e),_);if(null==t)return i;i.push(t)}if(t.startsWith("ymd")){const t=(0,f.map)((0,o.getDay)(e),T);if(null==t)return i;i.push(t)}return i}(0,l.ee)().on("clearCache",(()=>{y.unset(),v.unset()})),t.yearToOrdinal=w,t.monthToOrdinal=b,t.ordinalToMonth=function(e){return 13-e},t.dayToOrdinal=S,t.yearTagRef=P,t.monthTagRef=_,t.dayTagRef=T,t.dateTag=M,t.dateTagFile=async function(e,t){if(""===u.Settings.tagYMD.valueOrDefault)return;const i=[...t];(0,h.isEmpty)(t)&&i.push((await(0,d.readTags)(e))?.capturedAt);const r=(0,c.bestCapturedAt)(i);return null==r||(0,c.capturedAtSrcFromStat)(r.src)&&!u.Settings.tagDateFromStat.valueOrDefault?void 0:M(r.date)}},58886:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addFileUriTagsToAsset=t.addFilesTagsToAsset=t.isFsTag=t.tagAssetPaths=void 0;const r=i(19851),s=i(50213),n=i(42231),a=i(21404),o=i(40958),l=i(89937),u=i(75020),c=i(54017),d=i(94448),h=i(69032),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.FilePathTagger")));function m(e,t){return e.applyTagPathDeltas({add:(0,o.compact)(t.map((e=>(0,a.uriToTagPath)({uri:e,isFile:!0}))))})}t.tagAssetPaths=async function(e){const t=[];for(const i of e)try{const e=(0,a.uriToTagPath)({uri:i,isFile:!0});if(null==e)continue;if(i.startsWith(l.PS_LOCAL_FILE_SCHEME)&&null!=(0,d.modelDb)()){const t=(0,n.tagRefToS)(e[1]);e[1]={name:t,displayName:await(0,h.displayNameForVolsha)(t)},f().info("tagAssetPaths()",{uri:i,tp:e})}t.push(e)}catch(e){f().warn("Failed to parse asset file URI",{uri:i})}return t},t.isFsTag=function(e){return(0,n.tagRefToS)(e[0]).toLowerCase()===u.TagRoots.fs},t.addFilesTagsToAsset=function(e){const t=c.AssetFile.dbl.pluckAllf((t=>t.select("uri").where({asset:e})));return m(e,t)},t.addFileUriTagsToAsset=m},32646:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.geoTagFile=t.geoTag=void 0;const r=i(48884),s=i(56519),n=i(28874),a=i(47783),o=i(75020),l=i(40958);function u(e){const t=(0,r.compactRight)(n.Settings.tagGeoTemplate.valueOrDefault.map((t=>e?.[t])));return 0===t.length||t.some((e=>null==e))?void 0:(0,l.compact)([o.TagRoots.Where,...t])}t.geoTag=u,t.geoTagFile=function(e){return(0,s.thenMap)((0,a.readTags)(e),u)}},48144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.keywordTagFiles=t.processKeywords=t.dedupeKeywordPaths=t.normalizeKeywordPaths=t.extractPathnameTags=t.extractDashDashTags=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(68852),o=i(81168),l=i(96859),u=i(56519),c=i(28874),d=i(47783),h=i(97573),f=i(42231),m=i(40958),p=i(76790),g=i(22573),y=i(41400),v=i(96249),w=i(55835),b=i(75020),S=i(54993),P=i(6186),_=i(43723),T=(0,s.lazy)((()=>(0,n.mkLogger)("curators.KeywordTagger"))),M=(0,s.lazy)((()=>(0,g.mapNotBlank)(c.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[ /${(0,a.escapeRegExp)(e)}]`)))));function E(e){return T().tap({msg:"extractDashDashTags()",result:(0,w.mapOr)((0,S.toS)(e).split("--")[1],(e=>(0,m.compactBlanks)((0,w.mapOr)(M(),(t=>e.split(t)),[e]))),(()=>[])),meta:{s:e}})}function k(e){return[...E(e.parent().posixPath),...E(e.name)]}(0,y.later)((()=>{c.Settings.keywordDelimiters.watchLater((()=>M.unset()))})),t.extractDashDashTags=E,t.extractPathnameTags=k;const D=/\w{2,7}:\/\/\S+/g;function x(e){const t=[],i=[],s=[];for(const t of(0,m.compact)(e))if(Array.isArray(t))s.push(t);else{const e=(0,S.toS)(t).replace(D,(e=>(i.push(e),"")));s.push(...(0,w.mapOr)((0,h.delimRe)(),(t=>e.split(t)),[e]))}const n=s.map((e=>(0,o.isString)(e)?(0,h.keywordToPath)(e):e)).map((e=>Array.isArray(e)&&1===e.length?e[0]:e)),[a,l]=(0,r.partition)(n,Array.isArray),u=a.map((e=>(0,m.compactBlanks)(e.map((e=>e.trim()))))).filter(m.isNotEmpty),d=(0,o.uniqIgnoreCase)((0,v.flatten)(u));t.push(...u);const f=[...l,...i].map((e=>e.trim())).filter((e=>(0,g.notBlank)(e)&&!(0,o.includesIgnoreCase)(d,e))),p="copy"===c.Settings.keywordReparenting.valueOrDefault,y="retain"===c.Settings.keywordReparenting.valueOrDefault,P=c.Settings.rootTagKeywordsAliases.values;for(const e of[...t])(0,o.includesIgnoreCase)(P,e[0])&&(e[0]=b.TagRoots.Keywords),e[0]!==b.TagRoots.Keywords&&(p?t.push([b.TagRoots.Keywords,...e]):y&&e.unshift(b.TagRoots.Keywords));for(const e of f)t.push([b.TagRoots.Keywords,e]);return(0,m.uniq)(t)}function C(e){return(0,m.uniqBy2)((0,p.sortBy)(e.map(P.normalizeTagRoot),(e=>{const t=(0,f.joinTagPath)(e);return[t.normalize().toLowerCase(),-1*(0,l.lcdiff)(t)]})),((e,t)=>(0,o.equalsIgnoreCase)((0,f.joinTagPath)(e),(0,f.joinTagPath)(t))))}function F(e,t){const[i,s]=(0,r.partition)(x(e),_.isWhoTag),n=(0,v.flatten)(i.map(_.nameTag)),a=(0,m.uniq)((0,v.flatten)([...n,...t].map((e=>{const t=(0,P.stripTagRoot)(e);return[t.join(", "),t.join(" "),[...t].reverse().join(" ")]})))),l=C([...s.filter((e=>!(0,o.includesIgnoreCase)(a,(0,P.stripTagRoot)(e).join(" ")))),...n]);return T().tap({msg:"processKeywords()",level:"info",result:l})}t.normalizeKeywordPaths=x,t.dedupeKeywordPaths=C,t.processKeywords=F,t.keywordTagFiles=async function(e,t){return F([...c.Settings.tagKeywordsFromPath.valueOrDefault?(0,v.flatten)(e.map(k)):[],...c.Settings.tagKeywordsFromMetadata.valueOrDefault?(0,v.flatten)(await(0,u.mapAsyncSerial)({name:"keywordTagFiles",arr:e,f:e=>(0,u.thenMap)((0,d.readRawTags)(e),h.rawTagKeywords)})):[]],t)}},60047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lensTagFile=t.lensTag=void 0;const r=i(56519),s=i(28874),n=i(47783),a=i(75020),o=i(40958),l=i(22573),u=i(55835);function c(e){return(0,u.map)(e,(e=>(0,l.mapNotBlank)(e.lensMake,(t=>(0,l.mapNotBlank)((0,o.compactBlanks)(s.Settings.tagFullLensModel.valueOrDefault?[e.lensModel,e.lensInfo]:[e.lensInfo,e.lensModel])[0],(e=>[a.TagRoots.Lens,t,e]))))))}t.lensTag=c,t.lensTagFile=function(e){return(0,r.thenMap)((0,n.readTags)(e),c)}},6186:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagDeltas=t.normalizeTagRoot=t.stripTagRoot=t.hasTagRoot=t.Roots=t.KwRoot=t.WhoRoot=t.AlbumsRoot=t.WhenRoot=void 0;const r=i(50213),s=i(28874),n=i(42231),a=i(75020),o=i(40958),l=i(22573),u=i(45599);t.WhenRoot={name:a.TagRoots.When,ordinal:1},t.AlbumsRoot={name:a.TagRoots.Albums,ordinal:2},t.WhoRoot={name:a.TagRoots.Who,ordinal:4},t.KwRoot={name:a.TagRoots.Keywords,ordinal:7};const c=(0,u.defer)((()=>(0,r.mkLogger)("curators.Taggers")));t.Roots=[t.WhenRoot,t.AlbumsRoot,{name:a.TagRoots.fs,ordinal:3},t.WhoRoot,{name:a.TagRoots.Camera,ordinal:5},{name:a.TagRoots.Lens,ordinal:6},t.KwRoot,{name:a.TagRoots.Type,ordinal:8}];const d=(0,o.uniq)([...a.TagRoots.values,...s.Settings.rootTagKeywordsAliases.values,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function h(e){return d.includes((0,n.tagRefToS)(e[0]).toLowerCase())}t.hasTagRoot=h,t.stripTagRoot=function(e){return h(e)?e.slice(1):e};const f=(0,o.uniq)([a.TagRoots.Albums,...s.Settings.rootTagAlbumsAliases.values].map((e=>e.toLowerCase()))),m=(0,o.uniq)([a.TagRoots.Keywords,...s.Settings.rootTagKeywordsAliases.values].map((e=>e.toLowerCase()))),p=(0,o.uniq)([a.TagRoots.Who,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));t.normalizeTagRoot=function(e){const i=(0,n.tagRefToS)(e[0]).toLowerCase();return(0,l.blank)(i)?e:m.includes(i)||m.includes(i)?[t.KwRoot,...e.slice(1)]:p.includes(i)?[t.WhoRoot,...e.slice(1)]:f.includes(i)?[t.AlbumsRoot,...e.slice(1)]:e},t.tagDeltas=async function(e,t){const i=(0,n.tagDiff)(t,e),r=(0,n.tagDiff)(e,t),a=s.Settings.excludedRootTags.valueOrDefault;return(0,o.filterInPlace)(i,(e=>{const t=a.includes((0,n.tagRefToS)(e[0]).toLowerCase());return t&&!(0,n.tagPathsInclude)(e,r)&&(r.push(e),c().info("tagDeltas(): removing excluded tag",e)),!t})),{add:i,remove:r}}},42003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fixCase=t.friendlySubtype=t.mimeTypeToTag=t.typeTagFiles=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(56519),o=i(54979),l=i(40958),u=i(22573),c=i(55835),d=i(42279),h=i(75020),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.TypeTagger")));t.typeTagFiles=async function(e){const t=(0,l.uniq)(await(0,a.mapAsyncSerial)({name:"typeTagFiles",arr:e,f:o.readMimeType}));return(0,l.compact)(t.map(p))};const m=new Map(["M2TS","JPEG","QuickTime"].map((e=>[e.toLowerCase(),e])));function p(e){const[t,i]=e.split("/");if(!(0,u.blank)(t)&&!(0,u.blank)(i))return f().tap({msg:"mimetypeToTag("+e+")",result:(0,c.map)(y(i,e),(e=>(0,l.compactBlanks)([h.TagRoots.Type,(0,n.capitalize)(t),...e])))})}t.mimeTypeToTag=p;const g=(0,r.lazy)((()=>new Map([["image/x-adobe-dng",["Raw","DNG"]],["image/x-fuji-raf",["Raw","Fujifilm"]],["video/m2ts",["MPEG-2"]],["video/mp2t",["MPEG-2"]],["video/mp4",["MPEG-4"]],["video/quicktime",["QuickTime"]],["video/x-msvideo",["AVI"]]])));function y(e,t){return(0,d.firstDefinedThunk)([()=>g().get(t.trim().toLowerCase()),()=>(0,c.map)(e.match(/^x-(\w{4,})-\w{3}/),(e=>["Raw",(0,n.capitalize)(e[1])])),()=>[v(e.replace(/^(?:x-|vnd\.|prs\.)/i,"").replace(/-/g," "))]])}function v(e){return null!=e.match(/[a-z\d]{3,4}/i)?e.toUpperCase():m.get(e.trim().toLowerCase())??(0,n.capitalize)(e)}t.friendlySubtype=y,t.fixCase=v},43723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nameTag=t.isWhoTag=t.whoTagFiles=void 0;const r=i(19851),s=i(50213),n=i(28874),a=i(47783),o=i(28630),l=i(66039),u=i(42231),c=i(40958),d=i(22573),h=i(96249),f=i(68708),m=i(75020),p=i(59455),g=(0,r.lazy)((()=>(0,s.mkLogger)("curators.WhoTagger")));t.whoTagFiles=async function(e){const t=[];if(n.Settings.tagJsonFaces.valueOrDefault){const i=[];for(const t of e)i.push(...(0,p.toA)(await t.jsonSidecars()));for(const e of i){const i=await(0,o.readJsonSidecar)(e),r=i?.peopleNames;(0,c.isNotEmpty)(r)&&t.push(...r)}}if(n.Settings.tagFaceRegions.valueOrDefault)for(const i of e){const e=await(0,a.readRawTags)(i,!0);if(null!=e)for(const i of(0,f.values)(e)){const e=i?.RegionList;if(Array.isArray(e))for(const i of e)"Face"===i.Type&&t.push(i.Name)}}if((0,c.isNotEmpty)(n.Settings.whoTags.values))for(const i of e){const e=await(0,a.readRawTags)(i,!0);for(const i of n.Settings.whoTags.values)t.push(...(0,p.toA)((0,f.pluckDeep)(e,i)?.value))}const i=(0,c.uniq)((0,h.flatten)((0,c.uniq)(t).map(w)));return g().tap({msg:"whoTagFiles()",level:"info",result:i,meta:{names:t,files:e.map((e=>e.nativePath))}})};const y=(0,c.uniq)([m.TagRoots.Who,...n.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function v(e){return y.includes((0,u.tagRefToS)(e[0]).toLowerCase())}function w(e){if(!(0,d.blank)(e))return Array.isArray(e)?(v(e)&&e.shift(),0===e.length?void 0:1===e.length?(0,l.renderNameTag)(e[0]):[[m.TagRoots.Who,...e]]):(0,l.renderNameTag)(e)}t.isWhoTag=v,t.nameTag=w},98348:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Db=void 0;const c=i(48884),d=i(19851),h=i(23560),f=i(25764),m=i(38836),p=i(99331),g=i(12959),y=i(55332),v=i(91872),w=i(80632),b=i(51040),S=i(44955),P=i(15056),_=i(70025),T=i(57159),M=i(18454),E=i(28874),k=i(5233),D=i(42659),x=i(31586),C=i(68708),F=i(30976),A=i(17036),I=i(27134),O=i(35052);class L extends m.EndableWrapper{constructor(e,t){super("db.Db("+e+")",(()=>this.closeDb()),f.EndableRanks.db),r.add(this),this.schema=e,this.dbFile=t,s.set(this,0),n.set(this,void 0),this.endTimeoutMs=D.minuteMs,this.onRetry=(0,d.lazy)((()=>this.closeDb()),E.Settings.maxBusyDbMs.valueOrDefault/2),this.maxUpdatedAt=(0,d.lazy)((()=>"models"===this.schema?l(this,r,"m",a).call(this,"Asset","AssetFile","Example"):0),5*D.secondMs),this.migrate_=(0,d.lazy)((async()=>{let e=!1;const t=this.dbFile;if(null==this.dbFile)throw new Error("Cannot migrate database: missing db");let i;if(await this.dbFile.isNonEmptyFile())try{await(0,I.verifyDb_)((()=>this.db))}catch(e){this.logger.warn("verifyDb failed before attempting Migration.",{error:e}),i=e}(null!=i||E.Settings.dbForceRecover.valueOrDefault)&&(M.HealthCheck.addLoadingMsg("Repairing database..."),await this.repair_(),e=!0);const r=new A.Migration(this.schema,this.db,t);return{appliedMigrations:await r.apply_(),migration:r,repaired:e}})),this.tableInfo_=(0,d.lazy)((()=>(0,O.localTableInfo)(this.db)))}toJSON(){return(0,C.pick)(this,"schema","dbFile")}get isOpen(){return!0===l(this,n,"f")?.open}get inTransaction(){return this.isOpen&&!0===l(this,n,"f")?.inTransaction}prepare(e){return this.db.prepare(e)}pragma(e,t){return this.logger.tapThunk({msg:"PRAGMA "+e,result:()=>this.db.pragma(e,t)})}get db(){var e;const t=null==l(this,n,"f");if(t||!this.isOpen){this.logger.info("setting up new db connection to "+this.dbFile,{priorWasNull:t});try{u(this,n,(0,w.mkdb_)({nativePath:this.dbFile.nativePath}),"f")}catch(e){throw new T.WrappedError("Failed to set up "+this.dbFile,{cause:e,path:this.dbFile.nativePath})}}return(0,h.isSyncService)()&&"INCREMENTAL"===E.Settings.dbAutoVacuumMode.valueOrDefault&&(0,x.gt0)(E.Settings.dbWalAutoCheckpoint.valueOrDefault)&&u(this,s,(e=l(this,s,"f"),++e),"f")%E.Settings.dbWalAutoCheckpoint.valueOrDefault==0&&(this.logger.info("running incremental_vacuum..."),l(this,n,"f")?.pragma("incremental_vacuum")),l(this,n,"f")}async verify_(){await(0,I.verifyDb_)((()=>this.db))}assertHeartbeat_(){const e=(0,F.randomChars)(64),t=Date.now();try{this.db.prepare("INSERT INTO heartbeat (name, createdAt, updatedAt) VALUES (?,?,?)").run(e,t,t);const i=this.db.prepare("SELECT * FROM heartbeat WHERE name = ?").get(e);if(i?.name!==e)throw new Error("heartbeat INSERT/SELECT roundtrip failed")}finally{try{this.db.prepare("DELETE FROM heartbeat WHERE name = ?").run(e)}catch{}}}async closeDb(){try{this.logger.info("closing db",l(this,n,"f")),await(0,k.retryOnReject_)((()=>{!0===l(this,n,"f")?.open&&l(this,n,"f")?.close()}),{timeoutMs:E.Settings.dbBusyTimeoutMs.valueOrDefault,maxRetries:5,errorIsRetriable:_.isSqliteBusyError,retryDelay:D.secondMs})}catch(e){this.logger.warn("closeDb(): .close() failed",e)}u(this,n,void 0,"f")}async vacuum(){try{await(0,v.handleDbRetries_)("db.checkpoint",(()=>this.db),(()=>(0,I.checkpoint_)({db:this.db})),this.onRetry),await(0,v.handleDbRetries_)("db.optimize",(()=>this.db),(()=>this.db.pragma("OPTIMIZE")),this.onRetry),await(0,v.handleDbRetries_)("db.vacuum",(()=>this.db),(()=>this.db.exec("VACUUM")),this.onRetry)}catch(e){throw this.logger.warn("vacuum(): failed",{error:e}),e}}async repair_(){this.logger.warn("repair_(): Attempting restore of "+this.dbFile),await this.closeDb(),await(0,I.repairDbFile_)(this.dbFile),this.logger.info("repair_(): Database restoration was successful!")}localBackupDir(){return(0,P.dbBackupDir)(this.dbFile)}async backup_(e,t){const i=t??await(0,S.isDirSQLiteReadWrite)(e),s=(i?e:this.localBackupDir().join((0,g.filestamp)())).join(this.dbFile.base);return await l(this,r,"m",o).call(this,s),i||await(0,y.dbBackupCold_)(s,e),e.join(this.dbFile.base)}}t.Db=L,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(...e){const t=[];for(const i of e)try{t.push(this.db.prepare("SELECT MAX(updatedAt) FROM "+(0,b.dbValueToEscapedString)(i)).pluck().get())}catch(e){this.logger.warn(`#maxUpdatedAt(): failed to get max updatedAt for ${i}`,e)}return(0,c.max)(t)},o=async function(e){await e.parent().mkdirp_(),await this.db.backup(e.nativePath,{progress:e=>(this.logger.log((0,p.ending)()?"info":"debug","backup() "+(0,x.fmtPct)(100-e.remainingPages/e.totalPages*100)+" completed"),(0,p.ending)()?1e3:100)})}},25470:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.DbModelJanitor=t.Contested=t.NoOp=t.NoWriteLock=void 0;const c=i(66364),d=i(50213),h=i(23560),f=i(78406),m=i(25764),p=i(38836),g=i(99331),y=i(56038),v=i(12959),w=i(55332),b=i(76187),S=i(73209),P=i(28874),_=i(42659),T=i(75240),M=i(95700),E=i(22526),k=i(45648),D=5*_.minuteMs;t.NoWriteLock=Symbol("NoWriteLock"),t.NoOp=Symbol("NoOp"),t.Contested=Symbol("Contested");class x extends f.EndableInterval{static for(e){return new x(e.db,e.fslock,e.libraryDbFile,e.libraryDbBackupDir)}constructor(e,t,i,o){super({name:"db.DbModelJanitor",callback:()=>l(this,r,"m",n).call(this),intervalMs:P.Settings.dbBackupIntervalMs.valueOrDefault,initialDelayMs:_.minuteMs,rank:m.EndableRanks.db,endTimeoutMs:5*_.minuteMs,onEnd:()=>l(this,r,"m",a).call(this)}),r.add(this),this.db=e,this.dbFslock=t,this.libraryDbFile=i,this.libraryDbBackupDir=o,this.logger=(0,d.mkLogger)(this.name),this.fslockRelease=new p.EndableWrapper("db.DbModelJanitor.fslockRelease",(()=>this.dbFslock.release()),m.EndableRanks.postdb,D),s.set(this,0),this.dbFslock.tryAcquire_()}get useReplica(){return!this.db.dbFile.eql(this.libraryDbFile)}forceBackup_(){return this.backup_(!0)}async backup_(e=!1){return await(0,S.withLock_)({file:this.libraryDbBackupDir,timeoutMs:5*_.minuteMs,noopIfContested:!e},(async()=>{if(e&&u(this,s,0,"f"),(0,k.hasDbSetupErrors)())return this.logger.warn("backup_(): db has setup errors, skipping backup",{errors:(0,k.dbSetupErrors)()}),t.NoOp;if(!await this.dbFslock.tryAcquire_())return this.logger.info("backup_(): no-op: someone else has the fslock",{me:this.dbFslock.lockfile?.base,owner:(await this.dbFslock.selfAndSiblingNames_())[0]}),t.NoWriteLock;l(this,r,"m",o).call(this)||await(0,M.runMaintenanceTasks)();const i=this.db.maxUpdatedAt();return null!=i&&i>l(this,s,"f")?(0,y.time)("db.DbModelJanitor.backup_()",(async()=>{l(this,r,"m",o).call(this)?this.logger.info("backup_(): posthaste: skipping vacuum"):await this.db.vacuum(),u(this,s,i,"f");const e=this.libraryDbBackupDir.join((0,v.filestamp)()),t=await this.db.backup_(e,!this.useReplica);return this.useReplica&&await(0,w.dbBackupCold_)(t,this.libraryDbFile.parent()),this.logger.info("backup_(): backup successful",{destDbFile:t}),t})):(this.logger.info("backup_(): no update to the db since last backup",{ago:(0,T.fmtDuration)(Date.now()-l(this,s,"f"))}),t.NoOp)}))??t.Contested}}t.DbModelJanitor=x,s=new WeakMap,r=new WeakSet,n=async function(){try{await this.backup_()}catch(e){this.logger.error("backup_() failed",{error:e})}},a=async function(){const e=S.FsLock.for({file:this.libraryDbFile.sibling("db-teardown"),timeoutMs:D,endableRank:m.EndableRanks.postdb,noopIfContested:!1});(0,h.isDbManager)()&&await e.withLock_((async()=>{if(await this.dbFslock.iAmOnly_({vacuum:!0})){if(this.logger.info("#teardown(): I'm the last one in. Running backup and cleanup."),await this.backup_(),this.useReplica){const e=[(0,E.libraryDbInfoFromDbFile)(this.libraryDbFile),...(0,b.sqliteFiles)(this.db.dbFile)];this.logger.info("#teardown(): Removing replica artifacts",{victims:e});for(const t of e)await t.unlink()}}else this.logger.info("#teardown(): no-op: other processes are still running")})),await this.db.closeDb()},o=function(){return this.ended||(0,g.ending)()||(0,c.isSuspended)()}},35758:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelRepair=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(71567),o=i(98314),l=i(38835),u=i(18454),c=i(28874),d=i(63870),h=i(64526),f=i(14611),m=i(74085),p=i(22526),g=i(45648),y=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbModelRepair")));t.dbModelRepair=async function(){return{...await async function(){const e=h.Library.instance();if(null==e)throw new Error("No library set."+l.NoLibraryErrorFlag);const t=await e.dbModelJanitor();if(null==t)throw new Error("No library set (missing dbModelJanitor)."+l.NoLibraryErrorFlag);(0,g.clearDbSetupErrors)();const i=await(0,m.dbModelHealthCheck)().refresh();if(y().info("dbModelRepair: health check result: ",i),c.Settings.dbForceRecover.valueOrDefault)u.HealthCheck.addLoadingMsg("PS_DB_FORCE_REPAIR was set. Trying to repair.");else if("ok"!==i.level)u.HealthCheck.addLoadingMsg(`Database health check failed: ${i.msg}. Trying to repair.`),c.Settings.dbForceRecover.envValue=!0;else try{return u.HealthCheck.addLoadingMsg("Backing up the library database..."),await t.forceBackup_(),u.HealthCheck.addLoadingMsg("Validating the library database..."),await t.db.verify_(),u.HealthCheck.addLoadingMsg("No repair needed: maintenance tasks, backup, and integrity tests ran without error."),y().tap({msg:"dbModelRepair()",level:"info",result:{noop:!0,op:"validated"}})}catch(e){u.HealthCheck.addLoadingMsg(`Maintenance, backup, or integrity tasks failed: ${(0,o.errorToS)(e)}. Trying to repair.`),c.Settings.dbForceRecover.envValue=!0}(0,n.isWebService)()&&a.StdoutWrite.shutdownSync();const r=await e.dbFsLock();if(!await r.acquire_({timeoutMs:2*(0,d.commandTimeoutMs)(),releaseOnFailure:!1}))return y().throw("Failed to acquire exclusive lock on the library database. Shut down other processes before retrying.");try{await(0,p.assertValidDbInfo_)()}catch(e){u.HealthCheck.addLoadingMsg(`Library database setup was invalid: ${(0,o.errorToS)(e)}. Resetting and restarting.`),await(0,p.libraryDbInfoJsonFile)().unlink(),c.Settings.dbForceRecover.envValue=!0}await(0,f.restartLibrary_)();const s=c.Settings.dbForceRecover.valueOrDefault;return c.Settings.dbForceRecover.unset(),y().tap({msg:"dbModelRepair()",level:"info",result:{op:s?"repaired":"restarted",noop:!1}})}(),state:(await u.HealthCheck.rerunSetup()).state}}},22526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelSetup_=t.assertValidDbInfo_=t.libraryDbInfoFromDbFile=t.libraryDbInfoJsonFile=t.fsLockForDb=t.libraryDbObjects_=void 0;const r=i(19851),s=i(50213),n=i(92407),a=i(55332),o=i(44955),l=i(15056),u=i(87290),c=i(98314),d=i(38835),h=i(73209),f=i(95696),m=i(17217),p=i(18454),g=i(57902),y=i(28874),v=i(2858),w=i(40958),b=i(22573),S=i(42659),P=i(94448),_=i(98348),T=i(45648),M=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbModelSetup")));function E(e=y.Settings.libraryDir.valueOrDefault){if((0,b.blank)(e))throw new Error("Library directory is not set"+d.NoLibraryErrorFlag);const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dataDir"+d.NoLibraryErrorFlag);if(!(0,v._libraryHasSettings)(e))throw new Error(`Library at ${e} does not have a settings file`+d.NoLibraryErrorFlag);const i=(0,l.pathToDb)(t,"models");return{dataDir:t,libraryDbFile:i,libraryDbBackupDir:(0,l.dbBackupDir)(i)}}function k(e){return h.FsLock.for({file:e,timeoutMs:0,noopIfContested:!1})}function D(e=y.Settings.libraryDir.valueOrDefault){const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dir"+d.NoLibraryErrorFlag);return x((0,l.pathToDb)(t,"models"))}function x(e){return e.sibling("db-info.json")}async function C(e=D(),t){try{const i=await e.readJson(g.LogLevels.info);if(null==i)throw new Error(e+" is missing"+d.DbSetupErrorFlag);if(null!=t&&!await t.equalsUri_(i.uri))throw new Error(e+" expects the live db to be "+i.uri+" but the live db is "+await t.uri_()+d.DbSetupErrorFlag);const r=await f.PosixFile.forUri(i.uri);if(null==r)throw new Error(e+" expects the live db to be "+i.uri+" but that URI cannot be resolved."+d.DbSetupErrorFlag);try{await(0,o.assertDirSQLiteReadWrite_)(r.parent())}catch(t){throw M().error("assertValidDbInfo_(): failed to assert live dir was r/w",{error:t,liveDbFile:r,infoJsonFile:e}),new Error("Failed to validate that the live database directory, "+r.dir+", was read-writable by SQLite: "+(0,c.errorToS)(t)+d.DbSetupErrorFlag)}return{liveDbFile:r}}catch(e){throw(0,T.addDbSetupError)(e),e}}t.libraryDbObjects_=E,t.fsLockForDb=k,t.libraryDbInfoJsonFile=D,t.libraryDbInfoFromDbFile=x,t.assertValidDbInfo_=C,t.dbModelSetup_=async function(e=y.Settings.libraryDir.valueOrDefault){const{libraryDbFile:t,fslock:i,libraryDbBackupDir:r}=await async function(e=y.Settings.libraryDir.valueOrDefault){const t=E(e);return{...t,fslock:k(t.libraryDbFile)}}((0,b.mapNotBlank)(e,m.toNativePath_));let s,o;await i.tryAcquire_();const u=x(t);try{if(await(0,h.withLock_)({file:u,timeoutMs:5*S.minuteMs},(async()=>{const i=await u.readJson(g.LogLevels.info);if(s=i?.useReplica,null!=i){const{liveDbFile:e}=await C(u,t);o=new _.Db(l.Schemas.models,e)}if(null==s||null==o){const i=await(0,n.getLiveDbDir_)(e),r=await i.db.uri_();s=i.useReplica,s&&await p.HealthCheck.traceLater_("Setting up local replica database",(0,a.dbBackupCold_)(t,i.db.parent())).catch((e=>M().throw("Failed to set up replica db"+d.DbSetupErrorFlag,{src:t,dest:i.db,error:e}))),o=new _.Db(l.Schemas.models,i.db),await u.writeJson_({uri:r,useReplica:s})}})),null==o||null==s)return M().throw("Failed to open model db"+d.DbSetupErrorFlag+d.InternalErrorFlag,{libraryDir:e});if(await i.tryAcquire_()){const e=await o.migrate_();s&&(e.repaired||(0,w.isNotEmpty)(e.appliedMigrations))&&await o.backup_(t.parent(),!s),(0,T.clearDbSetupErrors)()}P.modelDb.set(o)}catch(e){throw M().error("Failed to set up model db",{error:e}),(0,T.addDbSetupError)(e),i.release(),e}return M().tap({msg:"dbModelSetup()",result:{db:o,useReplica:s,libraryDbFile:t,libraryDbBackupDir:r,fslock:i}})}},86859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DbRequest=void 0;const r=i(54557),s=i(50213),n=i(99331),a=i(56038),o=i(65753),l=i(66184),u=i(70417),c=i(28874),d=i(40958),h=i(22573),f=i(45599),m=i(96249),p=i(31586),g=i(51926),y=i(57038),v=i(21074),w=(0,f.defer)((()=>(0,s.mkLogger)("db.DbRequest")));t.DbRequest=class{constructor(e,t){this.db=e,this.tableName=t,this.cachedStatements=new r.FifoCache(256)}qb(){return(0,y.knex)()(this.tableName)}prep(e,t=!1){const i=(0,v.toSqlQuery)(e);try{const r=this.cachedStatements.getOrSet(this.db().db.__uid+":"+(!0===t?"pluck:":"")+i.sql,(()=>{const e=this.db().prepare(i.sql);return!0===t?e.pluck():e}));return r.database.open?{sq:i,stmt:r}:(this.cachedStatements.clear(),this.prep(e,t))}catch(e){return w().throw("prep() failed",{error:e,sqlQuery:i,retriable:!1})}}wrap({q:e,pluck:t,m:i}){try{const{sq:r,stmt:s}=this.prep(e,t);c.Settings.logSql.valueOrDefault&&w().log((0,l.defaultLogLevel)(),i+"(): "+(0,v.sqlQueryToS)(r));const n=s[i].bind(s);return null==r.bindings?n():n(r.bindings)}catch(t){if(!0===t.message?.includes("AdvisoryLock"))throw t;w().throw(t,{method:i,...(0,v.toSqlQuery)(e)})}}run(e){return this.wrap({q:e,m:"run"})}runScript(e,t=""){const i=(0,a.mkElapsed)("db.runScript()");for(const r of e){if((0,h.blank)(r)||r.trim().startsWith("--"))continue;this.run({sql:r});const e=(0,g.replaceAll)((0,g.ellipsize)(r,60),t,"");i.elapsed(e)}}mapRun(e){return e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return null==t.bindings?i.run():i.run(t.bindings)}))}runf(e){return this.wrap({q:e(this.qb()),m:"run"})}upsert(e){const t=(0,v.toSqlQuery)(e(this.qb()));return t.sql=t.sql.replace(/^(?:update|insert)\b/i,(e=>e.toUpperCase()+" OR REPLACE ")),this.wrap({q:t,m:"run"})}first(e){return this.wrap({q:e,m:"get"})}firstf(e){return this.wrap({q:e(this.qb()),m:"get"})}mapAll(e){return(0,m.flatten)(e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return i.all(t.bindings)})))}all(e){return this.wrap({q:e,m:"all"})}allf(e){return this.wrap({q:e(this.qb()),m:"all"})}async batched(e){let t,i=0;do{t=this.wrap({q:e.qb(this.qb(),t).limit((0,o.maxBatchPluckSize)()),m:"all"}),(0,d.isNotEmpty)(t)&&(await e.onResults(t),i+=t.length)}while((0,d.isNotEmpty)(t)&&!(0,n.ending)()&&(null==e.maxResults||e.maxResults>i));return{resultCount:i,done:null==t||t.length<(0,o.maxBatchPluckSize)()}}pluckFirst(e){return this.wrap({q:e,pluck:!0,m:"get"})}pluckFirstf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"get"})}pluckAll(e){return this.wrap({q:e,pluck:!0,m:"all"})}pluckAllf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"all"})}async pluckBatched(e){let t=0;const i=(0,u.min)([e.limit??(0,o.maxBatchPluckSize)(),e.maxResults]);if(i<=0||(0,p.lte0)(e.maxResults))return{done:!1,resultCount:t};let r;for(;null==e.maxResults||e.maxResults<=0||t(0,o.mkLogger)("db.DbSchemaValid")));function y(e){return l.PosixFile.for(s.default.join(u.ProjectPath.Data(),e+"-schema.json"))}t.schemaJsonFile=y,t.assertValidDbSchema_=async function(e){try{await e.migrate_();const t=(0,p.localTableInfo)(e.db),i=t.map((e=>e.tableName)),r=(await y(e.schema).readJson_()).tableInfo;{const e=r.map((e=>e.tableName)),t=(0,c.diff)(e,i);(0,c.isNotEmpty)(t)&&g().throw("Db is missing "+(0,f.plur)(t.length,"table")+" : "+(0,h.andList)(t))}for(const e of t){const t=r.find((t=>t.tableName===e.tableName));if(null==t)g().warn("Unexpected table in db",e);else{const i=(0,n.diffEql)(t.columns,e.columns);(0,c.isNotEmpty)(i)&&g().throw("Db is missing "+(0,f.plur)(i.length,"column")+" from table "+e.tableName+" : "+(0,h.andList)(i.map((e=>e.name))))}}g().info("Validated schema.",{from:(0,d.shortStack)()})}catch(e){throw(0,m.dbModelHealthCheck)().reset(),e}},t.writeSchemaJsonFile_=function(e,t){return y(e).writeJson_({info:"This is used in validating PhotoStructure library databases after repair and restore operations.",tableInfo:(0,p.localTableInfo)(t)},{spaces:2})}},45648:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDbSetupErrorListener=t.hasDbSetupErrors=t.clearDbSetupErrors=t.addDbSetupError=t.dbSetupErrors=t._dbSetupErrors=void 0;const r=i(98314),s=i(22573),n=i(23541);t._dbSetupErrors=new Set;const a=[];t.dbSetupErrors=function(){return[...t._dbSetupErrors.values()]},t.addDbSetupError=function(e){if((0,n.isError)(e)||!(0,s.blank)(e)){t._dbSetupErrors.add((0,r.errorToS)(e));for(const e of a)e()}},t.clearDbSetupErrors=function({notifyListeners:e=!0}={}){if(t._dbSetupErrors.clear(),e)for(const e of a)e()},t.hasDbSetupErrors=function(){return t._dbSetupErrors.size>0},t.addDbSetupErrorListener=function(e){a.push(e)}},36908:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dedupeTags_=t.mergeTags_=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(42231),o=i(40958),l=i(76790),u=i(23838),c=i(31586),d=i(54993),h=(0,r.lazy)((()=>(0,s.mkLogger)("db.DedupeTags")));function f(e,t){function i(t){return e.prepare(t).run()}(0,o.isEmpty)(t)&&h().warn("mergeTags(): empty tagIds",{tagIds:t}),h().info("mergeTags() starting",{tagIds:t});const r=e.prepare("SELECT id, _path, parentId FROM Tag WHERE id IN ("+t.join(",")+") ORDER BY ID").all(),s=(0,o.compactBlanks)(r.map((e=>(0,a.tagPathLeaf)(e._path))).sort()),n=r[0],l=r.slice(1),u=n?.id;if((0,o.isEmpty)(s)||(0,o.isEmpty)(l)||null==n||!(0,c.gt0)(u))return void h().warn("mergeTags(): missing winner",{winner:n,winnerId:u,leafs:s,losers:l});const d=(0,a.splitTagPath)(n._path).slice(0,-1),f=[...d,s[0]];n._path=(0,a.joinTagPath)(f),n.parentId=0===d.length?null:e.prepare("SELECT id from Tag where _path LIKE ?").pluck().get((0,a.joinTagPath)(d))??n.parentId,h().info("mergeTags()",{winner:n,losers:l,winnerTagPath:f,leafs:s});const m=l.map((e=>e.id)).join(",");i(`UPDATE OR IGNORE AssetTag SET tagId = ${u} WHERE tagId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`DELETE FROM AssetTag WHERE tagId in (${m})`),i(`DELETE FROM Tag WHERE id in (${m})`),e.prepare("UPDATE Tag SET parentId = :parentId, _path = :path WHERE id = :id").run({parentId:n.parentId,path:n._path,id:u});const p=e.prepare("SELECT id, _path FROM Tag WHERE id != :winnerId AND _path LIKE :like COLLATE NOCASE").all({winnerId:u,like:n._path+"%"});for(const t of p){const i=(0,a.splitTagPath)(t._path).slice(f.length),r=(0,a.joinTagPath)([...f,...i]);t._path!==r&&(h().info("mergeTags(): repairing tag path",{ea:t,newPath:r}),e.prepare("UPDATE OR IGNORE Tag SET _path = :path, updatedAt = :updatedAt WHERE id = :id").run({id:t.id,updatedAt:Date.now(),path:r}))}return h().tap({msg:"mergeTags()",level:"info",result:{winner:n,losers:r}})}t.mergeTags_=f,t.dedupeTags_=function(e){const t=new u.MultiMap;for(const{id:i,_path:r}of e.prepare("SELECT id, _path FROM Tag ORDER BY id").iterate())t.add((0,n.stripSuffix)((0,d.toS)(r).trim(),a.TagSep).toLowerCase().normalize(),i);const i=(0,l.sortBy)(t.entriesArray().filter((([,e])=>e.length>1)),(([e])=>[-(0,n.countChars)(e,a.TagSep),-e.length,e]));for(const[,t]of i)f(e,t)}},57038:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstMigratedAt=t.knex=void 0;const s=r(i(31832)),n=i(19851),a=i(56519),o=i(55835),l=i(68708);t.knex=(0,n.lazy)((()=>(0,s.default)({client:"better-sqlite3",useNullAsDefault:!0}))),t.firstMigratedAt=async function(e){return(0,a.thenMap)(e("migrations").min("migration_time").first(),(e=>(0,o.map)((0,l.values)(e)[0],(e=>new Date(e)))))}},17036:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Migration=void 0;const o=i(77598),l=i(19851),u=i(50213),c=i(7282),d=i(37805),h=i(4867),f=i(51040),m=i(77740),p=i(38835),g=i(8769),y=i(57159),v=i(34102),w=i(73209),b=i(95696),S=i(43899),P=i(18454),_=i(40958),T=i(42659),M=i(41400),E=i(98553),k=i(55835),D=i(34666),x=i(32639),C=i(45648),F=i(94715),A=i(27134);t.Migration=class{constructor(e,t,i){r.add(this),this.schema=e,this.db=t,this.dbFile=i,this.fsMigrations_=(0,l.lazy)((()=>this.migrationsDir.children_((e=>e.isFile&&e.basename.endsWith(".sql"))).catch((e=>this.logger.throw("Failed to read migration directory, "+this.migrationsDir+p.InternalErrorFlag,{error:e}))))),this.ensureMigrationTable_=(0,l.lazy)((()=>{this.db.exec("\nCREATE TABLE IF NOT EXISTS migrations (\n id INTEGER NOT NULL PRIMARY KEY,\n name TEXT NOT NULL,\n migration_time INTEGER NOT NULL\n) STRICT\n")})),this.unknownMigrations_=(0,l.lazy)((()=>this.migrationsInDatabase_().filter((e=>!(0,D.lt)((0,F.migrationNameToDate)(e),d.gitDate))))),this.assertKnownMigrations_=(0,l.lazy)((()=>{const e=this.unknownMigrations_();if((0,_.isNotEmpty)(e)){const t=new y.WrappedError("Please upgrade PhotoStructure to a newer version to open this library: Unknown migrations: "+e.join(","));throw(0,g.onError)(t),t}})),this.logger=(0,u.mkLogger)("db.Migration("+(0,E.stringify)({schema:e,db:i.nativePath})+")"),this.migrationsDir=b.PosixFile.for(S.ProjectPath.Migrations()).join(this.schema)}async pendingMigrationFiles_(){const e=this.migrationsInDatabase_();return(await this.fsMigrations_()).filter((t=>!e.includes(t.name)))}migrationsInDatabase_(){return this.ensureMigrationTable_(),this.db.prepare("SELECT name from migrations").pluck().all()}async apply_(e){return(0,w.withLock_)({file:this.dbFile.sibling("migrate"),timeoutMs:2*T.minuteMs},(()=>a(this,r,"m",s).call(this,e)))}async applyMigration_(e,t){try{const i=Date.now(),s=F.Migrations[e.name.replace(/^[\d_-]+/,"")],o=(0,x.isFunction)(s);return o?await s.bind(F.Migrations)(this.db):await a(this,r,"m",n).call(this,e),this.logger.debug("applyMigration() completed",{elapsedMs:Date.now()-i,codeMigration:o,migration:e.baseWithParent}),t?.run(e.name,Date.now())}finally{(0,v.ee)().emit("clearDbCache")}}},r=new WeakSet,s=async function(e){try{this.ensureMigrationTable_(),(0,c.isProd)()&&this.assertKnownMigrations_();const t=[],i=this.db.prepare("INSERT INTO migrations (name, migration_time) VALUES (?, ?)");for(const r of await this.pendingMigrationFiles_())await P.HealthCheck.traceLater_("Upgrading database ("+r.name+")",(async()=>{if((0,m.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");(0,m.getDevEnvFlag)("PS_SLOMO")&&await(0,M.delay)((0,o.randomInt)(T.secondMs,3*T.secondMs)),await(0,k.map)(e,(e=>e(r))),await(0,h.thenOrTimeoutError)({p:this.applyMigration_(r,i),timeoutMs:T.minuteMs}).catch((e=>{throw new y.WrappedError("Migration "+r.name+" timed out.",{cause:e,fatal:!0,ignorable:!1})}))})),t.push(r.base);return this.logger.info("Migration complete",{appliedMigrations:t}),t}catch(e){const t=new y.WrappedError("Migrating the "+this.schema+" db failed",{cause:e});throw(0,C.addDbSetupError)(t),P.HealthCheck.addError(t),t}},n=async function(e){const t=e.name.includes("_nofk");try{const i=await e.readTextFile(),r=(0,f.splitBatchSql)(i);if((0,_.isEmpty)(r))this.logger.info("No-op migration: "+e);else{t&&this.db.pragma("foreign_keys = OFF");for(const t of r)try{this.db.exec(t)}catch(i){this.logger.throw("Failed to apply SQL",{stmt:t,migration:e.baseWithParent,cause:i,fatal:!0})}t&&(0,A.foreignKeyCheck_)(this.db)}}finally{t&&this.db.pragma("foreign_keys = ON")}}},94715:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Migrations=t.isoToPrecisionMs=t.fix_root_tags=t.tag_path_suffix=t.migrationNameToDate=t.plucklabmodeb6=t.lowercase_psnet_function=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(97352),o=i(68852),l=i(81168),u=i(85810),c=i(42022),d=i(1971),h=i(79842),f=i(89724),m=i(17415),p=i(88600),g=i(20014),y=i(42231),v=i(87001),w=i(40958),b=i(55835),S=i(31586),P=i(97790),_=i(89937),T=i(54993),M=i(7656),E=i(36908),k=(0,s.lazy)((()=>(0,n.mkLogger)("db.Migrations"))),D=new RegExp(`^(${(0,o.escapeRegExp)(_.PS_NETWORK_FILESYSTEM_SCHEME)}://.*?/)(.*)$`);function x(e,t){return(0,a.mapGt0)(e,(()=>(0,b.map)(function(e,t=c.ModeBits){return(0,g.splitBits)(e,t).map((e=>(0,u.unlabhash)(e,t)))}(e,6)[t],(e=>(0,u.toLabhash)(e,c.ModeBits)))))}function C(e){return e.endsWith(y.TagSep)?e:e+y.TagSep}function F(e){for(const t of e.prepare("SELECT id, parentId, _path FROM Tag WHERE id = parentId").iterate())k().warn("fix_root_tags(): broken tag",{broken:t}),(0,l.countChars)(t._path,y.TagSep)<2&&e.prepare("UPDATE Tag set parentId = null where id = ?").run(t.id)}function A(e){return(0,b.map)((0,h.isoToDated)(e),h.datedToPrecisionMs)??-1}t.lowercase_psnet_function=e=>(0,P.opt)(e).filter(l.isString).flatMap((e=>D.exec(e))).map((e=>e[1].toLowerCase()+e[2])).getOrElse((()=>e)),t.plucklabmodeb6=x,t.migrationNameToDate=function(e){const[t,i,r]=[e.slice(0,4),e.slice(4,6),e.slice(6,8)].map((e=>(0,S.toInt)(e)));return(0,p.validYMD)(t,i,r)?new Date(t,i-1,r):void 0},t.tag_path_suffix=C,t.fix_root_tags=F,t.isoToPrecisionMs=A,t.Migrations={fix_root_tags:F,lowercase_psnet_hostname:e=>{e.function("lowercase_psnet_hostname",{deterministic:!0},t.lowercase_psnet_function),e.exec("DROP INDEX IF EXISTS assetfile_uri_udx"),e.exec("UPDATE AssetFile SET uri = lowercase_psnet_hostname(uri)"),e.exec("CREATE UNIQUE INDEX assetfile_uri_udx ON AssetFile(uri)")},numeric_captured_at:e=>{e.function("isoToLocal",{deterministic:!0},f.isoToLocal),e.function("isoToOffsetMinutes",{deterministic:!0},m.isoToOffsetMinutes),e.function("isoToPrecisionMs",{deterministic:!0},A),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtLocal bigint"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtOffset integer"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtPrecisionMs integer"),e.exec("UPDATE AssetFile SET capturedAtLocal = isoToLocal(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtOffset = isoToOffsetMinutes(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtPrecisionMs = isoToPrecisionMs(capturedAtISO)"),e.exec("DROP INDEX asset_captured_at_geohash_idx"),e.exec("DROP INDEX assetfile_exifuid_idx"),e.exec("CREATE INDEX assetfile_capturedAtLocal_idx ON AssetFile(capturedAtLocal)")},spread_modes:e=>{e.function("plucklabmodeb6",{deterministic:!0},x),(0,S.times)(d.ModeCount,(t=>e.exec(`ALTER TABLE AssetFile ADD COLUMN mode${t} integer`))),e.exec("UPDATE AssetFile SET "+(0,S.times)(d.ModeCount,(e=>`mode${e} = plucklabmodeb6(mode8b6, ${e})`)).join(", "))},normalize_asset_file_uris:e=>{e.function("normalizeURI",{deterministic:!0},v.normalizeURI);const t=e.prepare("SELECT normalizeURI(uri) AS nuri, count(*) AS cnt, GROUP_CONCAT(id) AS ids FROM AssetFile GROUP BY nuri HAVING cnt > 1").all(),i=[];for(const s of t){const t=(0,T.toS)(s.ids).split(","),n=e.prepare("SELECT id, shown, version, updatedAt FROM AssetFile WHERE id in ("+t.join(",")+")").all(),a=(0,r.greatestBy)(n,(e=>[e.shown,e.version,e.updatedAt])),o=n.filter((e=>e.id!==a?.id));i.push(...o.map((e=>e.id)))}for(const t of(0,r.batches)(i,256))e.exec("DELETE FROM AssetFile WHERE id in ("+t.join(",")+")");e.exec("UPDATE AssetFile SET uri = normalizeURI(uri)")},dedupe_tag_paths:E.dedupeTags_,suffix_tag_paths:e=>{e.function("tag_path_suffix",{deterministic:!0},C),(0,E.dedupeTags_)(e),e.exec("UPDATE Tag SET _path = tag_path_suffix(_path)")},normalize_tag_paths:e=>{const t=e.prepare("SELECT id, _path FROM Tag WHERE _path LIKE '%' || char(31) || char(31) || '%'").all();k().info("normalize_tag_paths():",{badTags:t});for(const i of t){const t=(0,y.normalizeTagPath)(i._path);(0,E.mergeTags_)(e,(0,w.compact)([i.id,...e.prepare("SELECT id FROM Tag WHERE _path LIKE ?").pluck().all(t)]))}},drop_tc_tables:e=>{const t=/^(ct|taf|tag_counts)_[a-z\d]{6}$/i,i=e.prepare("SELECT name FROM sqlite_master WHERE type='table'").pluck().all(),r=i.filter((e=>null!=t.exec(e)));k().info("drop_tc_tables()",{tables:i,victims:r});for(const t of r)e.exec("DROP TABLE "+t)},rebuild_rotated_heic:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype = 'image/heif' AND rotation <> 0")},rebuild_videos:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%'"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where mimetype LIKE 'video/%')")},copy_asset_duration:e=>{e.exec("CREATE INDEX tmp_af_idx ON AssetFile (assetId, durationMs)"),e.exec("UPDATE Asset SET durationMs = (SELECT durationMs FROM AssetFile WHERE assetId = Asset.id AND durationMs IS NOT NULL LIMIT 1) WHERE durationMs IS NULL"),e.exec("DROP INDEX tmp_af_idx"),e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%' and durationMs IS NULL"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where version = 0)")},rebuild_tag_asset_counts:M.rebuildTagAssetCounts,create_tag_fts:e=>{e.exec("DROP TABLE IF EXISTS tag_fts"),e.exec("CREATE VIRTUAL TABLE tag_fts USING fts5 (root, path, content='', contentless_delete=1, tokenize=\"unicode61\");")}}},27134:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.repairDbFile_=t.checkpoint_=t.verifyDbFile_=t.verifyDb_=t.foreignKeyCheck_=t.integrityCheck_=t.quickCheck_=t.backupDbFile_=t.sqlite=void 0;const r=i(14121),s=i(19851),n=i(50213),a=i(84777),o=i(12959),l=i(5531),u=i(91872),c=i(99315),d=i(76187),h=i(51040),f=i(38835),m=i(57159),p=i(29882),g=i(95696),y=i(89966),v=i(38156),w=i(28874),b=i(63870),S=i(5233),P=i(42659),_=i(41400),T=i(50357),M=i(98553),E=i(56409),k=i(31586),D=i(20214),x=i(51926),C=i(12168),F=i(59455),A=i(54993),I=i(94448),O=i(9508),L=(0,s.lazy)((()=>(0,n.mkLogger)("db.SQLite")));function R({db:e,pragma:t,okResult:i}){L().debug("pragmaOrThrow_()",{db:N(e),db_open:e?.open,pragma:t,okResult:i});const r=(0,x.isString)(i)?e.pragma(t,{simple:!0}):e.pragma(t);(0,T.eql)(r,i)||L().throw(`${t} failed for ${N(e)}: ${(0,M.stringify)({result:r})}`)}function N(e){return(0,p.ellipsizePath)({p:e.name,maxLength:80})}function B(e){return R({db:e,pragma:"quick_check",okResult:"ok"})}function j(e){return R({db:e,pragma:"integrity_check",okResult:"ok"})}function z(e){const t=(0,F.toA)(e.pragma("foreign_key_check"));t.length>w.Settings.dbInvalidFKThreshold.valueOrDefault&&L().throw("foreignKeyCheck_(): too many invalid foreign keys to repair",{dbInvalidForeignKeyThreshold:w.Settings.dbInvalidFKThreshold.valueOrDefault,badRowsCount:t.length,badRows:t});for(const i of t)L().warn("repairDbFile_(): deleting row with invalid foreign key",{row:i}),e.prepare(`DELETE FROM ${(0,h.dbValueToEscapedString)(i.table)} WHERE rowid = ?`).run(i.rowid)}async function V(e){await(0,u.handleDbRetries_)("db.quickCheck",e,B),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.integrityCheck",e,j),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.foreignKeyCheck",e,z)}function W(e){return(0,O.withDbSync)(e,V,(0,b.commandTimeoutMs)())}t.sqlite=async function({dbFile:e,sql:t,args:i}){const s=await(0,y.sqliteNativePath_)(),n=await(0,r.thenElapsed)((0,a.stdout_)(s,[...(0,F.toA)(i),e.nativePath,t],{timeoutMs:1*P.minuteMs}));return L().debug("sqlite("+t+") on "+e+" in "+n.elapsedMs+"ms",n.result),n.result},t.backupDbFile_=function(e,t){return(0,S.retryOnReject_)((()=>async function(e,t){try{await t.parent().mkdirp_(),await t.unlink("trace");const i=await e.size();if(!(0,k.gt0)(i))return void L().warn("backupDbFile_(): "+e+" is empty");await((0,I.modelDb)()?.end()),await(0,O.withDb)(e,(async e=>e.exec("VACUUM INTO "+(0,h.dbValueToEscapedString)(t.nativePath))),2*P.minuteMs),L().info("backupDbFile_(): Finished "+e+" -> "+t)}catch(i){throw new m.WrappedError(`Could not back up db ${e} -> ${t}`,{cause:i})}}(e,t)),{maxRetries:3,retryDelay:P.secondMs,timeoutMs:P.minuteMs,errorIsRetriable:()=>!0})},t.quickCheck_=B,t.integrityCheck_=j,t.foreignKeyCheck_=z,t.verifyDb_=V,t.verifyDbFile_=W,t.checkpoint_=async function e({db:t,retries:i=3,checkpointType:r=w.Settings.dbWalCheckpointType.valueOrDefault}){if((r=l.CheckpointTypes.getCI(r)??l.CheckpointTypes.AUTO)===l.CheckpointTypes.AUTO)return;const s="wal_checkpoint("+r+")",[n]=(0,F.toA)(t.pragma(s));return L().info("checkpoint()",{pragma:s,result:n}),(0,k.gt0)(n?.busy)&&i>0?(await(0,_.delay)(250),e({db:t,retries:i-1})):n};const U=/no such table: sqlite_\w+/i;t.repairDbFile_=async function(e,t=c.RepairModes.dump){const i=g.PosixFile.for(e),r=(await i.parent().join("db-"+t,(0,o.filestamp)()).mkdirp_()).join(i.base);L().info(`repairDbFile_(${i} -> ${r})`);try{const e=await(0,y.sqliteNativePath_)(),s=4*Math.min(20*C.MiB,await(0,d.sqliteSizeBytes)(i)),n=new v.PushProgressObserver({path:(0,A.toS)(i),op:"Repairing your database"},s),o=new E.Latch,l=(0,a.execFile)(e,[i.nativePath,"."+t],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});l.stdout.on("error",(e=>{const i=(0,A.toS)(e);U.test(i)?L().info("repairDbFile_(): ignoring stderr",{err:i}):o.reject(new Error("sqlite "+t+" failed: "+i))}));const u=(0,a.execFile)(e,[r.nativePath],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});u.on("exit",(()=>o.resolve())),l.stdout.on("end",(()=>{u.stdin.end(null)})),l.stdout.on("data",(e=>{const t=e.length;n.incrProgress(t),u.stdin.write(e)})),await o,L().info(`repairDbFile_(): recovered to ${r}.`),await W(r),L().info(`repairDbFile_(): ${r} is valid, finishing repair.`);const c=await(0,D.thenCollect)((0,d.sqliteFiles)(i),(e=>e.renameYMDHMS_({subdir:"needed-repair"})));return await(0,D.thenCollect)((0,d.sqliteFiles)(r),(e=>e.mv_(i.parent()))),c.find((e=>".db"===e.ext||e.ext.startsWith(".sqlite")))}catch(e){return L().throw("failed to recover DB via dump and restore. Please see https://photostructure.com/faq/restore-db-from-backup/ "+f.FatalErrorFlag,{error:e})}}},21074:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqlWhereInClause=t.isQueryBuilder=t.sqlQueryToS=t.toSqlQuery=t.isSqlQuery=void 0;const r=i(48884),s=i(68852),n=i(81168),a=i(12943),o=i(96249),l=i(98553),u=i(31586),c=i(68708),d=i(32639),h=i(54993);function f(e){return null!=e&&(0,n.isString)(e.sql)&&(null==e.bindings||(0,a.isDbValued)(e.bindings))}t.isSqlQuery=f,t.toSqlQuery=function(e){if(null==e)throw new Error("null sql");if(f(e))return e;if((0,n.isString)(e))return{sql:e};if((0,d.isFunction)(e.toSQL))return(0,c.omit)(e.toSQL(),"__knexQueryUid");throw new Error("not queryish: "+(0,l.stringify)(e))},t.sqlQueryToS=function(e){if(null==e.bindings)return e.sql;if(Array.isArray(e.bindings))return(0,o.flatten)((0,r.zip)(e.sql.split("?"),e.bindings.map((e=>(0,l.stringify)(e))))).join("");{let t=e.sql;for(const i of(0,c.keys)(e.bindings))t=t.replace(new RegExp("[@:$]"+(0,s.escapeRegExp)(i),"gi"),(0,h.toS)(e.bindings[i]));return t}},t.isQueryBuilder=function(e){return(0,d.isFunction)(e?.where)&&(0,d.isFunction)(e?.limit)},t.sqlWhereInClause=function(e){return"("+(0,u.times)(e,(()=>"?")).join(",")+")"}},35052:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localTableInfo=t.parseTableInfo=void 0;const r=i(22573),s=i(23838);function n(e){const t=new s.MultiMap;for(const i of e)i.tableName.includes("fts")||i.tableName.includes("sqlite_")||(0,r.blank)(i.name)||(0,r.blank)(i.type)||t.add(i.tableName,{name:i.name,type:i.type.toUpperCase().trim().replace(/\s+/g,""),notnull:1===i.notnull,pk:1===i.pk});return t.entriesArray().map((([e,t])=>({tableName:e,columns:t})))}t.parseTableInfo=n,t.localTableInfo=function(e){return n(e.prepare("SELECT \nm.tbl_name as tableName,\np.*\nFROM sqlite_master AS m\nJOIN pragma_table_info(m.name) AS p\nORDER BY m.tbl_name, p.cid").all())}},9508:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withDb=t.withDbSync=void 0;const r=i(80632),s=i(28874),n=i(30301),a=i(54993);t.withDbSync=function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const o=(0,n.lazy)((()=>(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i})));try{return t((function(){const e=o();return e.open?e:o.refresh()}))}finally{o.prior()?.close()}},t.withDb=async function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const n=(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i});try{return await t(n)}finally{n.close()}}},74085:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelHealthCheck=void 0;const r=i(77740),s=i(98314),n=i(18454),a=i(28874),o=i(82950),l=i(42659),u=i(45599),c=i(64526),d=i(16185),h=i(45648),f=i(31687),m={text:"Attempt database repair",title:"Run a dump and reload of your library database to try to repair it",type:"button",method:"POST",url:"/admin/repair-db",icon:"database"};t.dbModelHealthCheck=(0,u.defer)((()=>{const e=n.HealthCheck.for({section:"Library",id:"library-db",ordinal:1,pendingMsg:"Checking library database…",settings:["libraryDir","forceLocalDbReplica"],timeoutMs:()=>10*a.Settings.dbMaintenanceTimeoutMs.valueOrDefault,ttlMs:l.minuteMs,onReset:()=>(0,h.clearDbSetupErrors)({notifyListeners:!1}),links:[{text:"Read about PhotoStructure and SQLite",icon:"docs",url:"https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837"}],later:async()=>{const e=await(c.Library.instance()?.ready);if(null==e)return{level:"disabled",msg:["Library database tests disabled: no library is open"]};let t,i=!1;try{const s=Date.now();if(i=!1,(0,h.hasDbSetupErrors)())return{level:"error",msg:["Something is wrong with your library database.",(0,o.li)((0,h.dbSetupErrors)())],links:[m]};if(t=await e.modelDb(),(0,r.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");await(0,d.assertValidDbSchema_)(t),i=!0,await t.verify_(),await t.vacuum(),f.Heartbeat.assertPing_();const n=await e.dbModelSetup_();return{level:"ok",msg:["Library database is OK",(0,o.li)(["Schema validation, vacuum, optimize, and upsert round-trip took "+(Date.now()-s)+"ms","Live db is "+(0,o.tt)(t.dbFile.nativePath),"Local replica mode is "+(0,o.tt)(n.useReplica),n.useReplica?"Cold library db is "+(0,o.tt)(n.libraryDbFile):void 0])]}}catch(r){return{level:"error",msg:["Library database validation failed",(i?"":"Unrecoverable: ")+(0,s.errorToS)(r),null==t?void 0:"Live db is "+(0,o.tt)(t.dbFile.nativePath),null==e?void 0:"Local replica mode is "+(0,o.tt)(await e.useReplica())],links:i?[m]:void 0}}}});return(0,h.addDbSetupErrorListener)((()=>e.refresh())),e}))},8400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryHealthCheckSetup=void 0;const r=i(19851),s=i(88625),n=i(2858),a=i(74085),o=i(1991),l=i(40549);t.libraryHealthCheckSetup=(0,r.lazy)((async()=>{await(0,n.readSettings)(),(0,s.healthCheckSetup)(),(0,o.syncHealthCheck)(),(0,a.dbModelHealthCheck)(),(0,l.volumeUuidHealthCheck)()}))},1991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syncHealthCheck=void 0;const r=i(48884),s=i(50213),n=i(95696),a=i(62105),o=i(18454),l=i(2858),u=i(40958),c=i(82950),d=i(45599),h=i(94019),f=(0,d.defer)((()=>(0,s.mkLogger)("health.SyncHealthCheck")));t.syncHealthCheck=(0,d.defer)((()=>o.HealthCheck.for({section:"Library",id:"library-nothing-to-sync",ordinal:99,settings:["scanAllDrives","scanPaths","scanLibraryFirst","scanLibraryLast"],pendingMsg:"Checking synced directories…",later:async()=>{if(!(0,l.libraryHasSettings)())return{level:"disabled",msg:"Library sync paths test disabled: no library is open"};const e=(await(0,h.pathsToSync)()).map((e=>e.nativePath));if((0,u.isEmpty)(e))return{level:"warn",msg:"No paths are configured to scan\n"+(0,c.li)([(0,c.tt)("PS_SCAN_ALL_DRIVES")+" is false",(0,c.tt)("PS_SCAN_PATHS")+" is empty","both "+(0,c.tt)("PS_SCAN_LIBRARY_FIRST")+" and "+(0,c.tt)("PS_SCAN_LIBRARY_LAST")+" are false"]),links:[{text:"Read more",url:"https://photostructure.com/go/nothing-to-scan"}]};{const t=e.map((e=>n.PosixFile.for(e)));return f().info("Checking if any paths are empty",{posixFiles:t}),null==await(0,r.findAsync)(t,(async e=>null!=await e.someDescendant((e=>e.isDirectorySync()||(0,a.acceptParentAndFileAndSimple)(e)),1)))?{level:"warn",msg:["No eligible files found in scanned paths","Checked paths:",(0,c.li)(e.map(c.tt))],links:[{text:"Read more",url:"https://photostructure.com/go/nothing-to-scan"}]}:{level:"ok",msg:["At least one directory with eligible files is configured to be synced","Checked paths:",(0,c.li)(e.map(c.tt))]}}}})))},40549:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeUuidHealthCheck=void 0;const r=i(50213),s=i(56519),n=i(18454),a=i(28874),o=i(2858),l=i(85087),u=i(63870),c=i(86848),d=i(7014),h=i(40958),f=i(82950),m=i(45599),p=i(57924),g=i(23838),y=i(68708),v=i(94019),w=(0,m.defer)((()=>(0,r.mkLogger)("health.VolumeUUIDHealthCheck")));t.volumeUuidHealthCheck=(0,m.defer)((()=>n.HealthCheck.for({section:"Library",id:"volume-uuids",pendingMsg:"Checking volumes…",settings:["scanAllDrives"],links:[{text:"What's a “volume”?",url:"https://photostructure.com/faq/what-is-a-volume/",icon:"docs"}],later:async()=>{if(!(0,o.libraryHasSettings)())return{level:"disabled",msg:"Volume UUID test disabled: no library is open"};const e=[],t=[];if(a.Settings.scanAllDrives.valueOrDefault)e.push(...await(0,d.volumes)());else{const i=await(0,v.scanPaths)(),r=await(0,s.mapAsyncSerial)({name:"scannedVolumes",arr:i.result.map((e=>e.nativePath)),f:e=>(0,d.bestVolumeForPath)(e),timeoutMs:(0,u.commandTimeoutMs)()});e.push(...(0,h.uniqBy)(r,(e=>e.mountpoint))),t.push(...i.noUriPaths)}const i=[...(0,g.groupBy)(e,(e=>e.uuid)).values()].filter((e=>e.length>1)),r=e.filter((e=>null==e.uuid&&!(0,c.volumeUuidNotExpected)(e))).map((e=>e.mountpoint)),n=(await(0,d.volumes)()).filter((e=>!1===e.ok)).map((e=>(0,h.compactBlanks)([e.mountpoint,e.status]).join(": ")));if(w().debug("volumeHealthCheck result",{missingUUIDs:r,noUriPaths:t,unhealthyVolumes:n,scannedVolumes:e.map((e=>(0,y.pick)(e,"uuid","mountpoint")))}),(0,h.isEmpty)(r)&&(0,h.isEmpty)(i)&&(0,h.isEmpty)(t)&&(0,h.isEmpty)(n))return(0,h.isEmpty)(e)?{msg:["No volumes need UUIDs",(0,f.tt)(a.Settings.scanAllDrives.key)+" is false, and no volumes other than the library are configured to be scanned."],level:"ok"}:{msg:["All scanned volume UUIDs are OK",(0,f.li)(e.map((e=>(0,f.tt)((0,l.volsha)(e.uuid)+" → "+e.mountpoint))))],level:"ok"};{const e=[];return(0,h.isEmpty)(n)||e.push("Some volumes are unhealthy",(0,f.li)(n.map((e=>(0,f.tt)(e))))+"PhotoStructure may crash or hang when accessing unhealthy volumes."),(0,h.isEmpty)(r)||e.push("Some volumes are missing UUIDs",(0,f.li)(r.map((e=>(0,f.tt)(e)))),"This can cause problems with deduplication and library portability."),(0,h.isEmpty)(i)||e.push("Some volumes have duplicate UUIDs",i.map((e=>(0,f.li)((0,p.andList)(e.map((e=>(0,f.tt)(e.mountpoint))))+" share UUID "+(0,f.tt)(e[0].uuid)))).join("\n---\n"),"This can cause problems with deduplication and library portability."),(0,h.isEmpty)(t)||e.push("Some paths failed to have URIs generated",(0,f.li)(t.map((e=>(0,f.tt)(e)))),"This will prevent these paths from being imported."),{level:"warn",msg:e.join("\n---\n"),links:[{text:"How to manually add a UUID",icon:"handyman",url:"https://photostructure.com/faq/what-is-a-volume/#add-uuid"},{text:"Rescan volumes",type:"button",method:"POST",url:"/admin/clear-caches",icon:"refresh"}]}}}})))},43487:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Asset=void 0;const u=i(48884),c=i(19851),d=i(50213),h=i(88158),f=i(45393),m=i(56519),p=i(89724),g=i(38835),y=i(74128),v=i(79847),w=i(28874),b=i(47783),S=i(38010),P=i(40958),_=i(76790),T=i(75761),M=i(38639),E=i(11371),k=i(98553),D=i(55835),x=i(31586),C=i(20214),F=i(59455),A=i(64526),I=i(4407),O=i(54017),L=i(48722),R=i(37094),N=i(45295),B=i(39604),j=i(48723),z=i(41507),V=i(72761),W={"Asset.shown":1,"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null};class U extends V.TimestampedModel{constructor(){super(...arguments),r.add(this),this.attrs={},this.assetIdish=(0,c.lazy)((()=>({assetId:this.id,v:this.updateCount,capturedAtLocal:this.capturedAtLocal}))),this.mergedTags=(0,c.lazy)((async()=>{const e=[];for(const t of this.getAssetFiles()){const i=await t.posixFile(),r=await(0,b.readTags)(i),s=await(i?.mtimeMs());null!=i&&null!=r&&null!=s&&e.push({...r,SourceFile:i.nativePath,sourceModifiedTime:s,sourceIsPrimary:(0,M.isTrue)(t.shown)})}const t=R.AssetRevision.ops().allf((e=>e.where({assetId:this.id}))),i=new S.MergedTags("Asset:"+this.id);return i.addTag(...e,...this.assetFiles),i.addRevision(...t),i}))}static shownUnhidden(e){return null==e?s.query().where(W):e.andWhere(W)}static findUnhiddenById(e){return(0,x.gt0)(e)?s.ops().firstf((t=>s.shownUnhidden(t.where({id:e})))):void 0}static shownRemovable(e,t){return(t??s.query()).whereNotNull(e).andWhere({"Asset.shown":1})}static shownCount(){return s.ops().count(s.shownUnhidden().countDistinct("Asset.id"))}static deletePreviews(e){return A.Library.instance().previews().ap(e).deleteAll()}static async remove({assetId:e,blocklistShas:t,unlinkAssetFiles:i}){const r=(0,d.mkLogger)("Asset("+e+").remove()"),n=s.ops().findById(e);if(null==n)return void r.warn("asset not found");const a=n.isActive(),o=n.tagIds();r.info("starting",{unlinkAssetFiles:i});const l=n.getAssetFiles({refresh:!0});if(t){(0,B.upsertToShaBlockslist)(...l.map((e=>e.sha)));for(const e of l)(0,y.syncReport)().onProgress({from:"Asset.remove",path:await e.getNativePath()??e.uri,state:"blocklisted",details:"sha blocklisted (files with the same sha will not be imported)"})}N.AssetTag.dbl.runf((t=>t.delete().where({assetId:e}))),O.AssetFile.dbl.runf((t=>t.delete().where({assetId:e}))),R.AssetRevision.dbl.runf((t=>t.delete().where({assetId:e}))),s.dbl.runf((t=>t.delete().where({id:e}))),a&&j.Tag.deltaAssetCountAndAncestors(o,-1);try{await s.deletePreviews(e)}catch(e){r.error("Failed to delete previews",{error:e})}return{deletedMeta:i?await(0,v.trashOrUnlinkFileUris_)(l):[],assetFileMeta:l}}static nextOutdated(e=h.identity){return this.ops().findOne(e(l(this,s,"m",n).call(this)))}static nextOutdateds(e){return this.ops().all(e(l(this,s,"m",n).call(this)))}static outdatedCount(e=h.identity){return this.dbl.pluckFirst(e(l(this,s,"m",n).call(this)).count())}static findFirstByFile(e){return this.ops().findOne(e(this.query().select("Asset.*").join("AssetFile","AssetFile.assetId","Asset.id")))}static unshownAssetIds(){return this.dbl.pluckAll("\n SELECT DISTINCT af1.assetId\n FROM AssetFile af1\n LEFT JOIN (SELECT DISTINCT assetId FROM AssetFile WHERE shown = 1) AS af2 \n ON af1.assetId = af2.assetId\n WHERE af2.assetId IS NULL")}static archive(e){null!=s.ops().findById(e)&&(N.AssetTag.dbl.runf((t=>t.where({assetId:e}).delete())),O.AssetFile.dbl.runf((t=>t.where({assetId:e}).delete())),s.dbl.runf((t=>t.where({id:e}).delete())))}markUnshownAndUpsert(){this.shown=!1,this.version=f.AssetVersion,this.upsert()}markShownAndUpsert_(e){const t=this.getShown()?.id;if(null!=e){const t=e.shown;this.setShown_(e,{skipUpsert:!0}),!0!==t&&e.upsert()}this.shown=!0,this.version=f.AssetVersion,t!==this.getShown()?.id&&(this.updateCount=(this.updateCount??0)+1),this.upsert()}async updateFromFiles(){const e=await this.mergedTags();(0,D.map)(e.get("rating"),(e=>{this.logger().info("updateFromFiles()",{rating:e}),this.rating=e.value}))}isActive(){return(0,x.gt0)(this.id)&&!0===this.shown&&null==this.excludedAt&&null==this.deletedAt&&(null==this.rating||(0,x.gte)(this.rating,w.Settings.rejectRatingsLessThan.valueOrDefault))}toAssetId(){return(0,L.toAssetId)(this)}renderCaption(e){return(0,D.map)(this.capturedAtLocal,(t=>"Taken "+(0,p.fmtLocalDateShort)(t,e)))}async whenApiTag(){const e=(0,I.dateTag)((0,p.localToDateObject)(this.capturedAtLocal));return null==e?void 0:j.Tag.findOrCreate(e).toApiTag()}findAssetFileByUri(e){return this.getAssetFiles()?.find((t=>t.uri===e))}addAssetFile(e){(0,P.filterInPlace)(e.asset?.assetFiles??[],(t=>!(t.id===e.id||t.uri===e.uri))),e.assetId=this.id,e.asset=this,e.shown=!1,this.getAssetFiles().push(e),this.clear(),this.capturedAtLocal??(this.capturedAtLocal=e.capturedAtLocal),this.rating??(this.rating=e.rating),this.durationMs??(this.durationMs=e.durationMs)}async assetFileForFile_(e,t){const i=await e.uri();if(null==i)return this.logger().throw("assetFileForFile_(): null uri",{f:e});const r=this.getAssetFiles().find((e=>e.uri===i));if(null!=r)return r;const s=new O.AssetFile;return this.addAssetFile(s),!0!==t?.skipUpsert?await s.upsertIfNeeded_(e):await s.setFile_(e),s}static getTags(e){return j.Tag.ops().all(j.Tag.query().select("Tag.*").join("AssetTag","AssetTag.tagId","Tag.id").where("AssetTag.assetId",e).orderByRaw("COALESCE(Tag.ordinal, Tag._path)"))}tagIds(e){return!0===e?.refresh&&(this.tags=void 0),this.tags?.map((e=>e.id))??N.AssetTag.dbl.pluckAllf((e=>e.select("tagId").where({assetId:this.id})))}getTags(e){return!0===e?.refresh&&(this.tags=void 0),this.tags??(this.tags=s.getTags(this.id))}tagPaths(){return this.getTags().map((e=>e.path.join("/"))).sort()}setTagIds(e){const t=this.tagIds({refresh:!0});if((0,u.eqlUnordered)(t,e))return void this.logger().debug("setTagIds(): no-op, tagIds unchanged");const i=e.filter((e=>!t.includes(e))),r=t.filter((t=>!e.includes(t)));return this.applyTagIdDeltas({tagIdsToAdd:i,tagIdsToRemove:r})}applyTagPathDeltas(e){return this.applyTagIdDeltas({tagIdsToAdd:j.Tag.findOrCreateByPathN(e.add??[]).map((e=>e.id)),tagIdsToRemove:j.Tag.findByPathN(e.remove??[]).map((e=>e.id))})}applyTagIdDeltas(e={}){const t=this.tagIds({refresh:!0}),i=(0,P.uniq)((0,F.toA)(e.tagIdsToAdd).filter((e=>(0,x.gt0)(e)&&!t.includes(e)))),r=(0,P.uniq)((0,F.toA)(e.tagIdsToRemove).filter((e=>(0,x.gt0)(e)&&t.includes(e))));if((0,P.isEmpty)(i)&&(0,P.isEmpty)(r))return this.logger().info("applyTagIdDeltas(): no-op, no changes",{currentTagIds:t,...e}),t;this.isActive()&&j.Tag.deltaAssetCountAndAncestors(t,-1),(0,P.isEmpty)(i)||N.AssetTag.dbl.runf((e=>e.insert(i.map((e=>({assetId:this.id,tagId:e})))).onConflict(["assetId","tagId"]).ignore())),(0,P.isEmpty)(r)||N.AssetTag.dbl.runf((e=>e.whereIn("tagId",r).andWhere({assetId:this.id}).delete())),this.tags=void 0;const s=(0,P.uniq)([...t,...i]).filter((e=>!r.includes(e)));return this.isActive()&&j.Tag.deltaAssetCountAndAncestors(s,1),s}getStreams(e){if(null==this.streams){const t=this.getTags();this.logger().info("getStreams(): fetched tags "+t,{limit:e});const i=t.map((t=>t.getAssetStream(this,e)));this.streams=(0,z.coalesceStreams)((0,P.compact)(i));for(const e of this.streams)for(const t of e.tags)t.getAncestors()}return this.streams}getBeforeAfterId(){const e=s.dbl.all(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",this.capturedAtLocal).orderBy("assetId"));this.afterId=e.find((e=>e.assetId>this.id)),this.beforeId=e.reverse().find((e=>e.assetIde.path))}getAssetFiles({refresh:e=!1}={}){return null!=this.id&&(e&&(this.assetFiles=void 0),this.assetFiles??(this.assetFiles=(0,_.sortBy)(O.AssetFile.ops().findBy({assetId:this.id}),(e=>[!(0,M.isTrue)(e.shown),-e.mtime])))),this.assetFiles??[]}setShown_(e,t){e instanceof O.AssetFile&&(this.getAssetFiles(),this.assetFiles?.some(((t,i)=>{const r=t.id===e.id||t.uri===e.uri;return r&&(this.assetFiles[i]=e),r})));const i=e instanceof O.AssetFile?e.id:e;if(this.getShown()?.id===i)return void this.logger().debug("setShown_(): no-op, already set",{afId:i});this.logger().info("setShown_()",{assetId:this.id,assetFileId:i}),(0,x.gt0)(this.id)&&(0,x.gt0)(i)||this.logger().throw("setShown_(): invalid IDs: "+(0,k.stringify)({assetId:this.id,assetFileId:i})+g.InternalErrorFlag);const r=Date.now();O.AssetFile.dbl.runf((e=>e.update({shown:0,updatedAt:r}).where({assetId:this.id}))).changes<=0&&this.logger().warn("setShown_(): all asset files were already unshown",{afId:i});const s=O.AssetFile.dbl.runf((e=>e.update({shown:1,updatedAt:r}).where({id:i})));1!==s.changes&&this.logger().throw("setShown_(): failed to update asset file: unexpected changed rows",{runResult:s});const n=this.assetFiles?.find((e=>e.id===i))??this.getAssetFiles({refresh:!0}).find((e=>e.id===i));if(null!=n){this.capturedAtLocal=n.capturedAtLocal,this.rating=n.rating,this.durationMs=n.durationMs;for(const e of this.assetFiles??[])e.shown=e.id===i;!0!==t?.skipUpsert&&this.upsert()}else this.logger().throw("setShown_(): failed to find shown asset file",{af:e})}getShown(e){return this.getAssetFiles(e)?.find((e=>(0,M.isTrue)(e.shown)))??this.getAssetFiles({refresh:!0})?.find((e=>(0,M.isTrue)(e.shown)))}getShownNativePath(){return this.getShown()?.getNativePath()}async getCapturedAts(){return(0,C.thenCollect)(this.getAssetFiles(),(e=>e.capturedAt()))}link(){return"/asset/"+this.id}sqAttrs(e=!0){return{...(0,T.assetSqImgAttrs)({assetId:this.assetIdish(),lazyLoad:e}),title:this.renderCaption(),...this.attrs}}async getImgAttrs(e,t,i=!1){if(null==this.imgAttrs&&(this.imgAttrs=new Map),null==this.imgAttrs.get(t)){const r=e.ap(this.id);await(0,m.thenMap)(r.readInfo(),(async e=>{e.mimetype.startsWith("video/")&&(this.poster=await r.posterLink())}));const s=!0;this.imgAttrs.set(t,await r.imgAttrs(t,s,i))}return this.imgAttrs.get(t)}async fitAttrs(e){return{...await this.getImgAttrs(e,E.ReducerNames.fit),...this.attrs}}isVideo(){if(null==this.assetFiles)throw new Error(".video called before getFiles()");return this.assetFiles.some((e=>e.isVideo))}videoAttrs(){return{controls:!0,autoplay:!0,poster:this.poster,...this.attrs}}async videoSources(){const e=[];let t;for(const i of this.getAssetFiles())e.some((e=>e.type===i.mimetype))||await i.exists()&&(t??(t=i),e.push({src:(0,T.assetVideoLink)({assetId:this.assetIdish(),assetFileId:i.id}),type:i.mimetype}));return e.some((e=>"video/mp4"===e.type))||null==t||e.unshift({src:(0,T.assetVideoLink)({assetId:this.assetIdish(),assetFileId:t.id})+".mp4",type:"video/mp4"}),e}async getPosixFiles(){return(0,C.thenCollect)(this.getAssetFiles(),(e=>e.posixFile_()))}async getExistingAssetFiles(){return(0,m.filterAsync)({name:"getExistingAssetFiles",arr:this.getAssetFiles(),f:e=>e.exists()})}async findOrCreateByFile(e){const t=await e.uri_();if(null==t)return;const i=(0,F.toA)(O.AssetFile.ops().findBy({assetId:this.id,uri:t}))[0];return(0,D.orElse)(i,(async()=>{const t=new O.AssetFile;return t.asset=this,t.assetId=this.id,await t.setFile_(e),t}))}partialSimpleAsset(){return{assetId:this.id,liked:(0,x.gte)(this.rating,w.Settings.likeRating.valueOrDefault),hidden:(0,M.isTrue)(this.hidden),excluded:null!=this.excludedAt,deleted:null!=this.deletedAt}}clear(){return this.imgAttrs=void 0,this.streams=void 0,this.tags=void 0,this.mergedTags.unset(),this}}t.Asset=U,s=U,r=new WeakSet,n=function(){return s.shownUnhidden().andWhere("version","<",f.AssetVersion)},a=function(){return this.beforeId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal","<",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId",order:"desc"}]))},o=function(){return this.afterId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",">",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"asc"},{column:"assetId",order:"asc"}]))},U.$tableName="Asset",U.$uniqueColumnName="id",U.$booleanFields=["shown","hidden"]},54017:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFile=void 0;const a=i(76760),o=i(19851),l=i(88158),u=i(45393),c=i(68852),d=i(81168),h=i(13991),f=i(54296),m=i(56519),p=i(76490),g=i(89724),y=i(98314),v=i(38835),w=i(8769),b=i(29882),S=i(95696),P=i(62105),_=i(74128),T=i(35721),M=i(69589),E=i(28874),k=i(28544),D=i(16170),x=i(45200),C=i(34238),F=i(87001),A=i(42233),I=i(21404),O=i(40958),L=i(17586),R=i(22573),N=i(38639),B=i(42659),j=i(33374),z=i(50357),V=i(75240),W=i(11371),U=i(55835),q=i(31586),H=i(68708),$=i(34666),G=i(89937),J=i(75020),K=i(64526),Y=i(41844),X=i(43487),Z=i(48723),Q=i(94710),ee=i(72761);class te extends ee.TimestampedModel{constructor(){super(...arguments),r.add(this),this.uriObj=(0,o.lazy)((()=>C.URI.parse(this.uri))),this.whyRejected=(0,o.lazy)((async()=>{const e=await this.posixFile_();return null==e?"invalid URI":!0===await this.isFileDeleted()?"deleted":(0,P.whyRejectFile)(e)})),this.posixFile_=(0,o.lazy)((async()=>S.PosixFile.for(await this.getNativePath())))}static outdatedQuery(e){let t=(e.q??this.query()).where("version","<",u.AssetFileVersion);return null!=e.maxUpdatedAt&&(t=t.andWhere("updatedAt","<",e.maxUpdatedAt)),t.andWhere((t=>{(0,O.isNotEmpty)(e.mountpoints)&&(t=t.whereIn("mountpoint",e.mountpoints));for(const i of e.uris)t=t.orWhereLike("uri",i+"%");return t})).orderBy("id")}static async nextOutdated(e=l.identity){return this.ops().findOne(e(this.outdatedQuery(await(0,A.currentVolumeRoots)())))}static async outdatedCount(e=l.identity){const t=this.outdatedQuery(await(0,A.currentVolumeRoots)());return this.dbl.pluckFirst(e(t.count("id")))}static shownAssetFileId(e){return this.dbl.pluckFirstf((t=>t.where({assetId:e,shown:1}).limit(1)))}static primaryForAssetId(e){return(0,q.gt0)(e)?te.ops().first(X.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id").select("AssetFile.*").where({assetId:e,"AssetFile.shown":1})):void 0}static shownUnhidden({uriRoot:e}={}){let t=X.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id");return(0,R.blank)(e)||(t=t.andWhereLike("AssetFile.uri",e+"%")),t}static recentAssetIdsByUriRoot(e,t,i=64){const r=Date.now()-t;return this.dbl.pluckAll(te.shownUnhidden({uriRoot:e}).distinct("AssetFile.assetId").where("AssetFile.updatedAt",">",r).orderBy("AssetFile.updatedAt","desc").limit(i))}static assetFileCountByMimeType(e){const t=te.shownUnhidden({uriRoot:e}).select("mimetype").countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"}).groupBy("mimetype").orderBy("mimetype");return this.dbl.all(t)}static assetFileCountWithMimeType(e,t){let i=te.shownUnhidden({uriRoot:t}).countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"});return i=e.endsWith("/")?i.andWhereLike("mimetype",e+"%"):i.andWhere("mimetype",e),this.dbl.first(i)}static assetFileCountByMimeTypeRoots(e=["image/","video/"],t){return e.map((e=>({mimeTypeRoot:e,assetFileCount:te.assetFileCountWithMimeType(e,t)?.assetFileCount??0})))}static children(e,t){const i=this.query().whereLike("uri",e+"/%").andWhere("uri","regexp",`^${(0,c.escapeRegExp)(e)}/[^/]+$}`);return this.ops().all(null==t?i:t(i))}static async sameShaInLibrary(e){if(null==this.db())return;const t=await e.sha(),i=await e.size();return null!=t&&null!=i?this.ops().allf((e=>e.where({sha:t,fileSize:i}).andWhereLike("uri",G.PS_LIBRARY_PROTOCOL+"%"))):void 0}static sameAssetFileInLibrary(e){return this.ops().allf((t=>t.where((0,H.pick)(e,"sha","fileSize")).andWhere((e=>e.whereLike("uri",G.PS_LIBRARY_PROTOCOL+"%"))).andWhere((t=>t.whereNot({id:e.id})))))}librarySiblings(){return this.getAsset()?.getAssetFiles().filter((e=>e.id!==this.id&&e.uri.startsWith(G.PS_LIBRARY_PROTOCOL)))}capturedAtLocale(e){return(0,g.fmtLocalDateShort)(this.capturedAtLocal,e)}get dominantColors(){return p.DominantColor.fromModeData(this)}set dominantColors(e){(0,H.assignAllFields)(this,p.DominantColor.toModeData(e))}get posixPathFromGrandparent(){return(0,U.map)(this.uriObj()?.fsPath,b.posixPathFromGrandparent)}async whyNotMatchesFile(e){const t=n(this,r,"m",s).call(this);if(null!=t)return t;if(null==this.fileSize||null==this.mtime)return"missing file metadata";if(null!=e){const t=await e.uri();if(null==t)return"file has no URI";if(!await(0,F.uriIsEquivalent)(this.uri,t))return"file URI mismatch"}try{const t=e??await this.posixFile_();if(!await t.exists())return"file is missing";const i=await this.fileFields_(t);return null==i?!0===await(t?.isDeleted())?"file is deleted":"file is unreadable":i.fileSize!==this.fileSize?"file size changed since last sync":(0,q.closeTo)(i.mtime,this.mtime,2*B.secondMs)?void 0:"file mtime changed since last sync"}catch(e){return(0,y.errorToS)(e)}}async matchesFile(e){const t=await this.whyNotMatchesFile(e);return this.logger().tap({level:"info",msg:"matchesFile()",result:null==t,meta:{whyNot:t}})}async whyNotInSyncWithFile(e){return E.Settings.forceSync.valueOrDefault?E.Settings.forceSync.key+"=true":this.version!==u.AssetFileVersion?"AssetFileVersion: "+this.version+" != "+u.AssetFileVersion:this.whyNotMatchesFile(e)}async inSyncWithFile(e){const t=await this.whyNotInSyncWithFile(e);return this.logger().tap({msg:"inSyncWithFile()",result:null==t,meta:{whyNotInSync:t}})}async fileFields_(e){const t=e??await this.posixFile_();return null==t?void 0:await(0,h.assetFileStatFields_)(t)}isInLibrary(){return this.uri.startsWith(G.PS_LIBRARY_PROTOCOL)}async isNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){const t=await this.whyNotNoop(e);return this.logger().tap({msg:"isNoop()",result:null==t,meta:{whyNotNoop:t}})}async whyNotNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){if(!0===e.forceSync)return"forceSync is true";if(!(0,q.gt0)(this.id))return"missing .id";if(!(0,q.gt0)(this.assetId))return"missing .assetId";{const e=await this.whyNotInSyncWithFile();if(null!=e)return e}if(await(0,Y.mayCopyAssetsToLibrary)()){const e=K.Library.instanceRequired_().assetFileRepository(),t=e.whyNotCopyFile(await this.posixFile_());if((0,R.blank)(t)&&null==await e.existingLibraryAssetFile(this))return"need to copy into library"}this.syncState=_.AssetFileSyncStates.noop}isVersionUpToDate(){return(0,$.gte)(this.version,u.AssetFileVersion)}async siblingCount(){return te.dbl.pluckFirstf((e=>e.count().where({assetId:this.assetId}).andWhereNot({id:this.id})))}async upsertIfNeeded_(e,t=(0,M.forceContextOrSetting)()){if(null!=e&&await this.setFile_(e),await this.matchesFile()&&(0,q.gt0)(this.id)&&!t.forceSync)return void(null==this.syncState&&(this.upsert(),this.syncState??(this.syncState=_.AssetFileSyncStates.noop)));const i=await this.isFileDeleted();if(!0===i)return this.syncState=_.AssetFileSyncStates.deleted,this.delete(),!0!==t.skipAssetRepair&&Q.Task.addOne("repairAsset",{assetId:this.assetId}),this;if(!1===i){const i=await this.updateFromFile_(e,t);return this.syncState??(this.syncState=null==i?_.AssetFileSyncStates.noop:_.AssetFileSyncStates.synced),this.upsert()}return this.syncState??(this.syncState=_.AssetFileSyncStates.skipped),this}async updateFileFields_(e){(0,H.assignFields)(this,await this.fileFields_(e))}async updateFromFile_(e,t=(0,M.forceContextOrSetting)()){const i=Date.now(),r=this.logger().addContext(".updateFromFile_()");if(null!=this.id&&!0!==t.forceSync&&await this.matchesFile(e))return void r.info("updateFromFile() no-op: up-to-date version and file stat matches since last update");if(null!=e&&await this.setFile_(e),null==e&&(e=await this.posixFile_()),null==e||await e.clear().notExists())return this.syncState=_.AssetFileSyncStates.deleted,void r.info("no-op, "+e+" is missing");const s=await(0,h.mkAssetFile_)(e);return s.uri!==this.uri&&((0,R.blank)(this.uri)||!0===this.uri?.startsWith("file:"))&&(this.logger().warn("updateFromFile() upgrading uri",{prior:this.uri,new:s.uri}),this.uri=s.uri),(0,H.assignAllFields)(this,(0,H.omit)(s,"uri")),this.version=u.AssetFileVersion,this.syncState=_.SyncFileStates.synced,r.elapsed("finished",Date.now()-i,this.toJSON()),this}async updateFromShaSibling_(e){const t=n(e,r,"m",s).call(e);if(null==t){if(await this.exists())return this.logger().debug("updateFromShaSibling",e),null!=e.sha&&await e.matchesFile()&&this.sha===e.sha?((0,H.assignFields)(this,(0,H.omit)(e,"id","posixFile","uriObj","shown","uri","mtime","fileSize","mountpoint","createdAt","updatedAt","updateCount",...te.$transientFields)),this.updateFileFields_()):this.updateFromFile_();this.logger().warn("updateFromShaSibling(): fail: file is missing")}else this.logger().warn("updateFromShaSibling() sibling is invalid",{whySiblingIsInvalid:t})}getAsset(){return this.asset??(this.asset=(0,q.gt0)(this.assetId)?X.Asset.ops().findById(this.assetId):void 0)}exists(){return(0,x.uriExists)(this.uri,this.mountpoint)}async isFileDeleted(){return(await this.posixFile_())?.isDeletedUri(this.uri)}async accepted(){return(0,R.blank)(await this.whyRejected())}async setFile_(e){const t=await e.uri_();if(null==t)return this.logger().throw("setFile(): no URI for "+e);const i=await e.mountpoint();if(null!=this.uri&&!await(0,F.uriIsEquivalent)(t,this.uri))return this.logger().throw("setFile(): cannot reassign non-equivalent URI",{prior:this.uri,new:t,file:e.nativePath});const r=await e.uriObject_();return null==r?this.logger().throw("failed to create URI for "+e):(this.uri=t,this.uriObj.set(r),this.mountpoint=i?.nativePath,this.nativePath=e.nativePath,this.posixFile_.set(Promise.resolve(e)),this)}get basename(){return(0,R.blank)(this.uri)?void 0:decodeURIComponent(this.uri.slice(this.uri.lastIndexOf("/")+1))}posixFile(){return this.posixFile_().catch((()=>{}))}async getNativePath(){return(0,R.blank)(this.nativePath)&&(null==this.uri?this.logger().error(".getNativePath() called before .setFile_()"+v.InternalErrorFlag):this.nativePath=await(0,f.getAssetFileNativePath)(this)),this.nativePath}async capturedAt(){return null==this.nativePath&&await this.getNativePath(),k.CapturedAt.fromAssetFile(this)}async originalDownloadable({brief:e=!1}={}){const t=this.basename;if(!0===e)return null==t?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:`Download ${t}`,basename:t,description:"Download original"};const i=await this.posixFile_();return this.logger().tap({msg:"originalDownloadable()",level:"info",result:null==i||await i.isEmpty()?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:e?`Download ${i.base}`:(0,T.mkDownloadableTitle)(i,"original",this.isVideo?"video":"image",{width:this.width,height:this.height}),basename:i.base,description:"Download original",details:`(${(0,j.fmtDim)(this)} ${i.ext})`},meta:{posixFile:i}})}async downloadables(e,t){try{const i=await this.posixFile_();if(null==i)return[];const r=e.ap(this.assetId),s=[];if(await(0,m.thenMap)(this.originalDownloadable(),(e=>s.push(e))),this.isVideo)return s;if(!(0,N.isTrue)(this.shown)&&this.sha!==t)return s;const n=(0,O.compact)(await Promise.all([...await r.previewInfos()].reverse().filter((e=>e.reducer===W.ReducerNames.fit)).map((e=>(0,T.previewToDownloadable)(i.base,e)))));return s.push(...(0,O.uniqBy)(n,(e=>e.size))),s}catch(e){return(0,w.onError)("AssetFile.downloadables failed for "+this.uri,e),[]}}async pathInfo(){try{const e=C.URI.parse(this.uri),t=(0,U.map)((0,I.uriToTagPath)({uri:e,isFile:!0}),(e=>Z.Tag.findByPath(e)));return this._pathInfo_(await(t?.toApiPathElements()))}catch(e){return void this.logger().warn("pathInfo(): failed",e)}}async _pathInfo_(e){const t=await this.posixFile_();if(null==t)return this.logger().throw("pathInfo(): no posixFile",{uri:this.uri});const i=t.nativePath,r=C.URI.parse(this.uri),s=await t.exists();if(null==e||(0,O.isEmpty)(e))return this.logger().warn("pathInfo(): failed to find existing Tag. Returning a simple path.",{uri:this.uri,nativePath:i,tagLineage:e}),{nativePath:i,pathElements:[],nativePathSuffix:i,pathSep:a.sep,exists:s};function n(){return(0,L.at)((0,L.at)(e,-1)?.tagPath,-1)}(0,z.eql)(e[0]?.tagPath,[J.TagRoots.fs])&&(e=e.slice(1));const o=r.scheme===G.PS_LIBRARY_SCHEME,l=o?r.path.split("/").slice(1):t.pathnames,u=l.pop(),c=[];for(;l.length>0&&(0,d.equalsIgnoreCase)(n(),(0,L.at)(l,-1));){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("added matching tag",t)}if(o&&n()===J.LibraryTagName){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("pslib: added matching library tag",t)}if(r.scheme===G.PS_LOCAL_FILE_SCHEME){const t=C.URI.parse(this.uri).authority;if(this.logger().debug("psfile: pop last?",{lastTagName:n(),thisVolSha:t}),n()===t){l.pop();const t=e.pop();c.unshift(t)}else this.logger().warn("weird: I expected to be able to include the volsha tag element, but it doesn't seem to match",{thisVolSha:t,tagVolSha:n()})}return this.logger().tap({msg:"pathInfo()",result:{nativePath:i,pathElements:c,nativePathSuffix:u,pathSep:a.sep,exists:s}})}async toApi(e,t){return(0,m.thenMap)(this.pathInfo(),(async i=>(0,H.reqValuedOrElse)({assetId:this.assetId,assetFileId:this.id,...i,mimetype:this.mimetype,shown:(0,N.isTrue)(this.shown),name:this.basename,width:this.width,height:this.height,rotation:this.rotation??0,fileSize:this.fileSize,mtime:this.mtime,downloadables:await this.downloadables(e,t),createdAtLocale:ie(this.createdAt),updatedAtLocale:ie(this.updatedAt)})))}get isVideo(){return(0,D.isVideoMimeType)(this.mimetype)}}function ie(e){return(0,U.map)(e,(e=>(0,V.fmtDuration)(Date.now()-e,1)+" ago"))}t.AssetFile=te,r=new WeakSet,s=function(){if((0,R.blank)(this.uri))return"blank uri";if((0,R.blank)(this.sha))return"blank sha";if(!(0,q.gt0)(this.width))return"missing width";if(!(0,q.gt0)(this.height))return"missing height";if(!(0,q.gt0)(this.capturedAtLocal))return"missing capturedAtLocal";if(!(0,q.gte0)(this.capturedAtPrecisionMs))return"missing capturedAtPrecisionMs";if(E.Settings.useImageHashes.valueOrDefault){const e=[];for(const t of["dctHash","diffHash","meanHash"])(0,R.blank)(this[t])&&e.push(t);if(1===e.length)return"missing image hash: "+e[0];if(e.length>1)return"missing image hashes: "+e.join(", ")}return this.isVersionUpToDate()?void 0:"outdated version"},te.$tableName="AssetFile",te.$uniqueColumnName="uri",te.$booleanFields=["shown"],te.$transientFields=["nativePath","syncState"]},48722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toAssetId=void 0;const r=i(76596),s=i(31586);t.toAssetId=function(e){const t=(0,s.toGt0)(e?.assetId)??(0,s.toGt0)(e?.id);if(null==e||null==t||!(0,s.isNumber)(e?.capturedAtLocal))return;const i=((0,s.toGt0)(e.v)??(0,s.toGt0)(e.updateCount)??(0,s.toGt0)(e.updatedAt)??0)%1e6,n={assetId:t,capturedAtLocal:e.capturedAtLocal,v:i};return(0,s.gt0)(e.durationMs)&&(n.durationHMS=(0,r.durationHMS)(e.durationMs)),n}},37094:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetRevision=void 0;const r=i(98553),s=i(67478),n=i(55046);class a extends n.Model{static insert(...e){return a.ops().insert(e.map((e=>({assetId:e.assetId,createdAt:Date.now(),field:e.field,op:e.op,_priorValueJson:(0,r.stringify)(e.priorValue),_newValueJson:(0,r.stringify)(e.newValue)}))))}get priorValue(){return(0,s.parseJSON)(this._priorValueJson)}get newValue(){return(0,s.parseJSON)(this._newValueJson)}}t.AssetRevision=a,a.$tableName="AssetRevision"},69853:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setAssetRotation_=void 0;const r=i(50213),s=i(39250),n=i(66778),a=i(69589),o=i(40958),l=i(45599),u=i(98553),c=i(31586),d=i(21605),h=i(43487),f=i(94710),m=(0,l.defer)((()=>new s.LastOneInWins("Asset")));t.setAssetRotation_=async function(e,t,i){if(!(0,c.gt0)(e))throw new Error("invalid asset "+(0,u.stringify)(e));if(!(0,d.isRotation)(t))throw new Error("setRotation("+t+"): invalid rotation "+(0,u.stringify)(t));return m().enqueue({key:e,fn:s=>async function(e,t,i,s){const c=Date.now(),d=(0,r.mkLogger)("setAssetRotation("+(0,u.stringify)({assetId:e,rotation:t})+")"),m=h.Asset.ops().findById(e);if(null==m)return d.throw("Unknown assetId:"+e);const p=(0,l.defer)((()=>{f.Task.addOne("repairAsset",{assetId:e})}));d.throwIfAborted_(s);const g=m.getAssetFiles();if(null==m.getShown())return p(),d.throw("No primary asset file for Asset "+e+". Trying to repair.",{doNotSend:!0,fatal:!1,retriable:!1});const y=await i.ap(e).smallestFileForReducer("fit");if(null==y)return p(),d.throw("Missing previews for Asset "+e+". Trying to repair.",{doNotSend:!0,fatal:!1,retriable:!1});const v=[];for(const e of g)try{const i=await e.posixFile();if(null==i||await i.notExists()){d.info("cannot rotate variation: file is missing",{f:i,af:e});continue}if(d.throwIfAborted_(s),null==await(0,n.matchAndWriteRotation_)(y,i,t)){d.info("cannot rotate variation: matchRotation() failed",{f:i,af:e});continue}v.push(await e.upsertIfNeeded_(i.clear(),(0,a.forceContextOrSetting)({forceSync:!0})))}catch(t){d.warn("failed to update asset file",{af:e,error:t})}return(0,o.compact)(v),(0,o.isNotEmpty)(v)&&await i.apb(e,g,{forceRebuildPreviews:!0}).build_(),d.info("setRotation("+t+"): completed.",{elapsedMs:Date.now()-c,updatedAssetFiles:v}),v}(e,t,i,s)})}},45295:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetTag=void 0;const r=i(55046);class s extends r.Model{$pk(){return this.assetId+":"+this.tagId}}t.AssetTag=s,s.$tableName="AssetTag",s.$uniqueColumnName="assetId,tagId",s.$useCache=!1,s.$pkColumnNames=["assetId","tagId"]},61204:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeMonthTag=t.normalizeDateTags=t.getMonthTags=void 0;const r=i(19851),s=i(50213),n=i(97352),a=i(75020),o=i(4407),l=i(48723),u=`'${a.TagRoots.When}' || char(31) || '%' || char(31) || '%' || char(31)`,c=u+" || '%' || char(31)",d=(0,r.lazy)((()=>(0,s.mkLogger)("model.DateTagNormalizer")));function h(){return l.Tag.ops().allf((e=>e.whereNotNull("ordinal").andWhereRaw("_path LIKE "+u+" AND _path NOT LIKE "+c).limit(2400)))}function f(e){const t=(0,n.mapGt0)(e.ordinal,(e=>(0,o.monthTagRef)((0,o.ordinalToMonth)(e))));null==t?d().warn("failed to fix tag (no monthTagRef)",{t:e}):t.name!==e.name&&(d().info("Fixing month name",{tagRef:t,tag:e}),e.changeName(t.name)),e.maybeUpsertDisplayName(t?.displayName)}t.getMonthTags=h,t.normalizeDateTags=async function(){for(const e of h())f(e)},t.normalizeMonthTag=f},31687:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Heartbeat=void 0;const r=i(38835),s=i(42659),n=i(31586),a=i(72761);class o extends a.TimestampedModel{static ping(e){return o.ops().upsertOne({name:e})}static assertPing_(e="ping-"+Date.now()){if(null==o.db())throw new Error("no library is open"+r.NoLibraryErrorFlag);try{o.ping(e);const t=o.ops().findOneBy({name:e});if(null==t||t.name!==e||(0,n.lt)(t.updatedAt,Date.now()-20*s.secondMs))throw new Error("Heartbeat row wasn't inserted")}finally{try{o.dbl.runf((t=>t.delete().where({name:e})))}catch{}}}}t.Heartbeat=o,o.$tableName="Heartbeat",o.$uniqueColumnName="name",o.$useCache=!1},95700:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runMaintenanceTasks=void 0;const r=i(19851),s=i(56038),n=i(28874),a=i(42659),o=i(41400),l=i(69032),u=i(61204),c=i(49796);t.runMaintenanceTasks=async function({force:e}={}){await d(),await(!0===e?h.refresh():h());try{await(!0===e?(0,l.forceRunTagMaintenance)():(0,l.runTagMaintenance)())}catch{}};const d=(0,r.lazy)((()=>(0,s.time)("db.normalizeDateTags",u.normalizeDateTags))),h=(0,r.lazy)((()=>(0,s.time)("db.Progress.vacuum",(()=>c.Progress.vacuum()))),2*a.hourMs);(0,o.later)((()=>{n.Settings.libraryDir.watchLater((()=>{d.unset(),h.unset()}))}))},55046:(e,t,i)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const s=i(57975),n=i(50213),a=i(7282),o=i(65211),l=i(40958),u=i(38639),c=i(45599),d=i(31586),h=i(68708),f=i(34666),m=i(54993),p=i(57038),g=i(94448),y=i(33572),v=i(63872);class w{constructor(){this.$instanceId=(0,a.isTest)()?(0,o.uid)():void 0}static get $ctor(){return this.$schema+"."+this.$tableName}static query(){return(0,p.knex)()(this.$tableName)}static queryBy(e){return this.query().where(e)}static queryOneBy(e){return this.queryBy(e)}static ops(){return this._ops??(this._ops=new v.ModelOps(this,this.db))}static get dbl(){return this.ops().dbl}static rows(){return this.ops().rows()}static truncate(){if((0,a.isProd)())throw new Error("rejecting attempt to truncate in prod");this.dbl.run("DELETE FROM "+this.$tableName)}static ucn(e){const t=this.$uniqueColumnName.split(",").map((t=>e[t]));return t.some((e=>null==e))?void 0:1===t.length?t[0]:t.join(",")}static hasId(e){return this.$pkColumnNames.every((t=>null!=e[t]))}static pickId(e){return(0,h.pick)(e,...this.$pkColumnNames)}$ops(){return this.class().ops()}class(){return this.constructor}$pk(){return(0,m.toS)(this.id)}$ucn(){return this.class().ucn(this)}$tableName(){return this.class().$tableName}$uid(){return`${this.$tableName()}(${this.id??this.$ucn()})${!0===this.shown?"!":""}`}logger(){return(0,n.mkLogger)(this.class().$schema+"."+(0,m.toS)(this.valueOf()))}[s.inspect.custom](){return{...this.$toShallowJSON(),$instanceId:this.$instanceId}}toString(){return this.$uid()}valueOf(){return this.$uid()}static fromJSON(e){return(0,y.fromJSON)(this,e)}static toJSON(e){return this.fromJSON(e).toJSON()}$toShallowJSON(){return this.$_toJSON({encodeBool:u.isTrue})}$toDbJSON(e){return this.$_toJSON({encodeBool:u.boolToInt,includeCtor:!1,includeTransient:!1,colNames:e})}$clone(){return(0,y.fromJSON)(this.class(),this.toJSON())}toJSON(){return this.$_toJSON({encodeBool:u.isTrue})}_get(e,t,i=!0){const r=this[e];return null===r?[e,null]:!(0,f.isPrimitive)(r)||!i&&(0,l.includes)(this.class().$transientFields,e)?void 0:(0,l.includes)(this.class().$booleanFields,e)?[e,t(r)]:[e,r]}$_toJSON({encodeBool:e,includeCtor:t=!0,includeTransient:i=!0,colNames:r}){const s=this.class(),n=(0,l.notEmptyOr)(r,s.ops().columnNames());return(0,h.fromEntries)(n.map((t=>this._get(t,e,i))),t?{$ctor:s.$ctor}:{})}insert(){return this.logger().debug("insert()",{self:this.toJSON()}),this.class().ops().insertOne(this)}update(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("update()",{self:this.toJSON()}),this.class().ops().updateOne(this)}upsert(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("upsert()",{self:this.toJSON(),arg:e}),this.class().ops().upsertOne(this)}$afterInsert(){}$beforeUpsert(){}$afterUpsert(){}reload(){return this.class().ops().reloadOne(this)}delete(){(0,d.gt0)(this.id)&&this.class().ops().delete([this.id])}}t.Model=w,r=w,w.$schema="models",w.$logger=(0,c.defer)((()=>(0,n.mkLogger)(r.$schema+"."+r.$tableName))),w.db=g.modelDb,w.$pkColumnNames=["id"]},94448:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryModelDbFile=t.modelDb=void 0;const r=i(15056),s=i(87290),n=i(19851),a=i(55835);t.modelDb=(0,n.lazy)((()=>{})),t.libraryModelDbFile=function(e){return(0,a.map)((0,s.libraryDataDirPosixFile)(e),(e=>(0,r.pathToDb)(e,"models")))}},33572:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toJSON=t.assignFromJSON=t.fromJSON=t.addModelClass=void 0;const r=i(50213),s=i(40958),n=i(22573),a=i(38639),o=i(97790),l=i(51926),u=new Map;function c(e){u.set(e.$ctor,e)}function d(e,t,i=[]){const r=e.class();for(const[n,o]of Object.entries(t)){if("$ctor"===n)continue;if(void 0===o)continue;const t=(0,l.stripPrefixes)(n,i);e[t]=null==o?o:(0,s.includes)(r.$booleanFields,t)?(0,a.isTrue)(o):o}return e}t.addModelClass=c,t.fromJSON=function(e,t){if(null==t)throw new Error("json is null");if(null!=e&&(0,n.notBlank)(e.$ctor)&&!u.has(e.$ctor)&&c(e),t instanceof e)return t;const i=(0,o.opt)(t.$ctor).flatMap((e=>u.get(e))).getOrElse((()=>e));if(t instanceof i)return t;const r=new i;return null==t?r:d(r,t,(0,s.uniq)([e.$tableName+".",i.$tableName+"."]))},t.assignFromJSON=d,t.toJSON=function e(t,i,s){if(null!=t)return Array.isArray(t)?t.map(((t,r)=>e(t,i,`${s}[${r}]`))):"function"==typeof t.toJSON?t.toJSON():void(0,r.mkLogger)("ModelJSON.toJSON()").warn("Failed",{m:t,key:s,mc:i.$ctor})}},63872:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ModelOps=void 0;const f=i(48884),m=i(19851),p=i(50213),g=i(81168),y=i(48299),v=i(12943),w=i(38835),b=i(34102),S=i(28874),P=i(40958),_=i(76790),T=i(22573),M=i(50357),E=i(96249),k=i(98553),D=i(55835),x=i(31586),C=i(68708),F=i(59455),A=i(86859),I=i(33572);t.ModelOps=class{constructor(e,t){r.add(this),this.model=e,this.db=t,s.set(this,void 0),n.set(this,!0),a.set(this,new y.WeakCache),o.set(this,new Set),this.columnNames=(0,m.lazy)((()=>this.db().tableInfo_().find((e=>(0,g.equalsIgnoreCase)(e.tableName,this.tableName))).columns.map((e=>e.name)))),this.updatableColumnNames=(0,m.lazy)((()=>(0,P.diff)(this.columnNames(),this.immutableColumnNames))),this.ucnFieldNames=(0,m.lazy)((()=>this.ucn.split(","))),d(this,s,(0,p.mkLogger)(`ModelOps(${e.$tableName})`),"f"),(0,I.addModelClass)(e),d(this,n,e.$useCache??!0,"f"),this.dbl=new A.DbRequest(this.db,e.$tableName),(0,b.ee)().on("clearCache",(()=>h(this,a,"f").clear())),(0,b.ee)().on("clearDbCache",(()=>h(this,a,"f").clear()))}clearDbCache(){h(this,a,"f").clear()}get $cache(){return h(this,a,"f")}$cachedByJson(e){if(null==e||!h(this,n,"f"))return;const t=this.$pickModelUcn(e);return(null==t?void 0:h(this,a,"f").get((0,k.stringify)(t)))??this.$cachedById(e.id)}$cachedById(e){return(0,x.gt0)(e)&&h(this,n,"f")?h(this,a,"f").get((0,k.stringify)(e))??h(this,a,"f").findEntry((t=>t.id===e)):void 0}get dbOpen(){return(0,D.mapOr)(this.db(),(e=>e.isOpen),(()=>!1))}get tableName(){return this.model.$tableName}query(){return this.model.query()}toDbValued(e){const t=this.model.fromJSON(e),i=(0,v.toDbValued)(t);return(0,C.pick)(i,...this.columnNames())}run(e){return this.dbl.run(e)}fromJSON(e){if((0,C.isEmptyObj)(e))return;const t=this.model.fromJSON(e);return h(this,r,"m",u).call(this,t)}fromJSONs(e){return(0,P.compact)(e.map((e=>this.fromJSON(e))))}first(e){return this.fromJSON(this.dbl.first(e))}firstf(e){return this.first(e(this.query()))}all(e=this.query()){return this.fromJSONs(this.dbl.all(e))}allf(e){return this.all(e(this.query()))}findOne(e){return this.fromJSON(this.dbl.first(e))}findOneBy(e){return this.findOne(this.model.query().where(e))}findById(e,t){return this.findOneBy({...t,id:e})}findByIds(e){e=(0,F.toA)(e).filter(x.gt0);const t=[],i=[];for(const r of e){const e=this.$cachedById(r);null!=e?t.push(e):i.push(r)}const r=(0,f.batches)(i,S.Settings.dbBatchSelectSize.valueOrDefault).map((e=>this.dbl.all(this.query().whereIn("id",e))));return(0,_.sortBy)([...t,...this.fromJSONs((0,E.flatten)(r))],(t=>e.indexOf(t.id)))}findBy(e){return this.all(this.model.queryBy(e))}findWhereIn(e,t){return this.all(this.model.query().whereIn(e,t))}rows(e){return this.count(e??this.model.query().count())}count(e){return(0,x.toGt0)(this.dbl.pluckFirst(e))??0}countf(e){return this.count(e(this.query()))}insert(e){return(0,F.toA)(e).map((e=>this.insertOne(e)))}upsertOne(e){return this.modelSupportsUpsert?this.upsert([e])[0]:this.insertOrUpdateOne(e)}insertOrUpdateOne(e){return null==e.id?this.insertOne(e):this.updateOne(e)}insertOne(e){if(this.model.hasId(e))throw new Error("insert called for "+(0,k.stringify)(e)+w.NonRetriableErrorFlag);const t=this.fromJSON(e);if(null==t)return h(this,s,"f").throw("insertOne(): fromJSON returned null"+w.InternalErrorFlag,{t:e});t instanceof this.model&&h(this,r,"m",u).call(this,t),t.$beforeUpsert();const i=t.$toDbJSON(this.columnNames()),n=this.dbl.runf((e=>e.insert(i)));return t.id=(0,x.toInt)(n.lastInsertRowid),t.$afterInsert(),t.$afterUpsert(),t}unsetField(e,t){return(0,D.map)(this.$cachedById(e),(e=>{e[t]=null})),this.dbl.runf((i=>i.where({id:e}).update(t,null)))}updateOne(e){if(null==e.id)throw new Error("update called for "+(0,k.stringify)(e)+w.NonRetriableErrorFlag+w.InternalErrorFlag);const t=this.model.fromJSON(e);t.$beforeUpsert();const i=t.$toDbJSON(this.updatableColumnNames());return this.dbl.runf((t=>t.where({id:e.id}).update(i))),t.$afterUpsert(),h(this,r,"m",u).call(this,t)??t}get ucn(){return(0,T.toNotBlank)(this.model.$uniqueColumnName)??"id"}get modelSupportsUpsert(){return null!=this.ucn&&"id"!==this.ucn}get ucnConstraint(){return`(${this.ucn})`}get immutableColumnNames(){return(0,P.uniq)([...this.ucnFieldNames(),"id","createdAt"])}onConflictClause(e){const t=this.immutableColumnNames,i=e.filter((e=>!t.includes(e))).sort().map((e=>`${e}=excluded.${e}`)).join(","),r=["ON CONFLICT",this.ucnConstraint];return(0,T.blank)(i)?r.push("DO NOTHING"):r.push("DO UPDATE SET",i),r.join(" ")}$pickModelUcn(e){const t={};for(const i of this.ucnFieldNames()){const r=e[i];if(null==r)return;t[i]=r}return t}reloadOne(e){if(h(this,o,"f").has(e.id))return;const t=this.$pickModelUcn(e);if(null!=t){const i=h(this,r,"m",u).call(this,e),s=this.findOneBy(t);if(null==s)return;return h(this,r,"m",l).call(this,i,s),i!==e&&h(this,r,"m",l).call(this,e,i),i}h(this,s,"f").warn(".reloadOne(): failed to reload "+(0,k.stringify)(e))}reload(e){const t=[],i=this.allf((i=>{for(const r of e){const e=this.model.hasId(r)?this.model.pickId(r):this.$pickModelUcn(r);null!=e?(t.push([r,e]),i=i.orWhere(e)):h(this,s,"f").warn("reload(): given insufficient partial model",{fragment:r})}return i})),n=[];for(const[e,a]of t){const t=i.find((e=>(0,M.eqlSubset)(a,e)));if(null==t)h(this,s,"f").warn("reload(): failed to find result in db",{prior:e,dbArr:i});else{const i=h(this,r,"m",u).call(this,e);h(this,r,"m",l).call(this,i,t),i!==e&&h(this,r,"m",l).call(this,i,t),n.push(t)}}return n}upsert(e){if(e=(0,P.compact)(e),!this.modelSupportsUpsert)return e.map((e=>this.insertOrUpdateOne(e)));const t=this.columnNames(),i=[];for(const s of(0,f.batches)((0,F.toA)(e),S.Settings.dbBatchUpsertSize.valueOrDefault)){const e=new Map,n=new Set,a=(0,P.compact)(s.map((e=>this.fromJSON(e))));for(const t of a){const i=(0,k.stringify)(this.$pickModelUcn(t));e.set(i,t),this.model.hasId(t)||n.add(i),t.$beforeUpsert()}h(this,r,"m",c).call(this,a.map((e=>e.$toDbJSON(t))));const o=this.reload(a),l=new Map(o.map((e=>[(0,k.stringify)(this.$pickModelUcn(e)),e])));for(const e of a){const t=(0,k.stringify)(this.$pickModelUcn(e)),r=l.get(t)??e;n.has(t)&&r.$afterInsert(),r.$afterUpsert(),i.push(r)}}return i}delete(e){const t=(0,F.toA)(e).filter(x.gt0);for(const e of t)h(this,o,"f").add(e);return h(this,a,"f").deleteValueIf((e=>t.includes(e.id))),this.run(this.model.query().delete().whereIn("id",t))}async batched(e){const t=e.batchSize??S.Settings.dbBatchSelectSize.valueOrDefault;let i,r;do{i=this.allf((i=>(i=e.qb(i),null!=r&&(i=i.andWhere("id",">",r)),i.orderBy("id","asc").limit(t)))),(0,P.isNotEmpty)(i)&&(r=Math.max(...i.map((e=>e.id))),await e.onResults(i))}while((0,P.isNotEmpty)(i))}},s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function(e,t){(0,C.assignFields)(e,t,{omitKeys:["$instanceId"],assignNullish:!0})},u=function(e){if(h(this,n,"f")){const t=this.$cachedByJson(e);if(null!=t)return h(this,r,"m",l).call(this,t,e),t;{const t=this.$pickModelUcn(e)??e.id;null!=t&&h(this,a,"f").set((0,k.stringify)(t),e)}}return e},c=function(e){const t=this.query().insert(e).toSQL(),i=new Set;for(const t of e)for(const e of(0,C.keys)(t))i.add(e);const s={sql:t.sql+" "+this.onConflictClause([...i.values()]),bindings:t.bindings};this.run(s);for(const t of e){const e=this.$cachedByJson(t);null!=e&&h(this,r,"m",l).call(this,e,this.model.fromJSON(t))}}},20958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Operation=t.OperationNames=void 0;const r=i(19851),s=i(50213),n=i(88158),a=i(99331),o=i(70025),l=i(8769),u=i(22573),c=i(98553),d=i(50989),h=i(72761);t.OperationNames=(0,d.strEnum)("rebuildLibrary","forceRestartSync");const f=(0,r.lazy)((()=>(0,s.mkLogger)("model.Operation")));class m extends h.TimestampedModel{static incomplete(){return this.ops().allf((e=>e.whereIn("id",(e=>e.table(m.$tableName).min("id").whereNull("completedAt")))))}static ensurePendingOp(e){return m.getFirstPendingOp(e)??m.ops().insertOne(e)}static getFirstPendingOp(e){return f().tap({msg:"getFirstPendingOp",level:"info",result:this.ops().firstf((t=>{const i=t.whereNull("completedAt").orderBy("createdAt","asc");return null!=e?i.andWhere(e):i})),meta:{crit:e}})}static markOpCompleted(e,t){return(0,u.blank)(e?.name)?f().throw("markOpCompleted(): bad query",{crit:e}):this.dbl.runf((i=>i.whereNull("completedAt").andWhere(e).update({completedAt:Date.now(),...t})))}static async applyIfPending(e,t){const i=this.ops().firstf((t=>t.whereNull("completedAt").andWhere(e)));return f().info("applyIfPending()",{crit:e,op:i}),null==i?void 0:t(i)}static async applyOnce_(e,t,i=n.identity){const r=this.ops().firstf((t=>i(t.whereNotNull("completedAt").andWhere(e))));if(null!=r)return void f().debug("applyOnce(): already done",{priorCompleted:r});const s=this.ops().insertOne(e);try{const e=await t(s);return(0,a.ending)()||s.markCompleted(),e}catch(t){if((0,o.isRedoableError)(t))return void f().info("applyOnce(): redoable error",{crit:e,error:t});throw(0,l.onError)("Operation.applyOnce(): "+(0,c.stringify)(e),t),t}}markCompleted(){null==this.completedAt&&(this.completedAt=Date.now(),this.upsert())}}t.Operation=m,m.$tableName="Operation",m.$uniqueColumnName="id",m.$useCache=!1},49796:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Progress=t.defaultMinCreatedAt=t.toPct=void 0;const r=i(48161),s=i(1708),n=i(48884),a=i(50213),o=i(28874),l=i(40958),u=i(42659),c=i(45599),d=i(98553),h=i(55835),f=i(31586),m=i(68708),p=i(67478),g=i(51926),y=i(59455),v=i(54993),w=i(76386),b=i(33572),S=i(55009),P=i(72761),_=(0,c.defer)((()=>(0,a.mkLogger)("model.Progress")));function T(e){return null==e||!(0,f.isNumber)(e)||e<0||e>100?void 0:(0,f.sigFigs)(e,3)}t.toPct=T;const M=(0,g.compressWhitespace)("\nSELECT\n p1.uri,\n p1.id as lastProgressId,\n p1.createdAt as lastStartedAt,\n p1.updatedAt as lastUpdatedAt,\n p3.lastCompletedAt\nFROM\n Progress AS p1\n JOIN (\n SELECT\n uri,\n max(updatedAt) AS lastUpdatedAt\n FROM\n Progress\n GROUP BY\n 1\n ) AS p2 ON p1.uri = p2.uri\n AND p1.updatedAt = p2.lastUpdatedAt\n LEFT JOIN (\n SELECT\n uri,\n max(completedAt) AS lastCompletedAt\n FROM\n Progress\n WHERE\n CAST(completedAt AS int) > 0\n GROUP BY\n 1\n ) AS p3 ON p1.uri = p3.uri\nGROUP BY\n p1.uri");function E(){const e=o.Settings.progressStaleDays.valueOrDefault;return e<=0?0:Date.now()-e*u.dayMs}t.defaultMinCreatedAt=E;class k extends P.TimestampedModel{static vacuum(e=o.Settings.progressRetentionDays.valueOrDefault*u.dayMs){const t=Date.now()-e,i=this.dbl.pluckAllf((e=>e.select("id").where("createdAt","<=",t)));for(const e of(0,n.batches)(i,o.Settings.dbBatchSelectSize.valueOrDefault))S.ProgressMeta.dbl.runf((t=>t.whereIn("progressId",e).delete())),k.dbl.runf((t=>t.whereIn("id",e).delete()))}static countCompletedDirectorySyncs(){return this.dbl.pluckFirstf((e=>e.where({state:"done"}).whereNotNull("completedAt").where("uri","like","ps%")))}static times(){return _().tap({msg:"times()",result:this.dbl.all({sql:M})})}static insertNew(e){const t=(0,h.map)(e.dek,d.stringify);return this.ops().insertOne({...(0,m.omit)(e,"dek"),dekJSON:t})}upsert(e){return null!=e&&this.assignFromPojo(e),super.upsert()}$beforeUpsert(){super.$beforeUpsert(),null==this.id&&(this.pid??(this.pid=s.pid),this.hostname??(this.hostname=(0,r.hostname)())),"done"===this.state&&(this.completedAt??(this.completedAt=Date.now())),this.completePct=T(this.completePct),this.incompletePct=T(this.incompletePct),this.scanningPct=T(this.scanningPct)}$afterUpsert(){super.$afterUpsert(),(0,w.tellWebProgressUpdated)()}toSyncState(){return{id:this.id,uri:this.uri,volume:this.volume,state:this.state,hed:this.hed,dek:this.dek,completePct:this.completePct,incompletePct:this.incompletePct,scanningPct:this.scanningPct}}get dek(){return(0,l.compactBlanks)((0,p.parseJSON)(this.dekJSON))}set dek(e){var t;this.dekJSON=(t=e,(0,d.stringify)((0,l.compactBlanks)((0,y.toA)(t))))}assignFromPojo(e){return(0,b.assignFromJSON)(this,(0,m.omit)(e,"volume","uri"))}getMeta(){return S.ProgressMeta.ops().allf((e=>e.where({progressId:this.id}).orderBy("createdAt")))}getPriorIncomplete(e=E()){return this.logger().tap({msg:"priorIncompleteProgress()",result:k.ops().firstf((t=>t.where({hostname:this.hostname,uri:this.uri,completedAt:null}).andWhere("createdAt",">",e).orderBy("updatedAt","desc")))})}getLastCompletedAt(e=E()){return k.dbl.pluckFirstf((t=>t.max("completedAt").where({uri:this.uri}).andWhere("createdAt",">",e)))}getLastIncompleteStartAt(){return k.dbl.pluckFirstf((e=>e.min("createdAt").where({uri:this.uri}).andWhere("createdAt",">",this.getLastCompletedAt()??0)))}setMeta(e,t){return this.logger().debug("setMeta()",{progressId:this.id,name:e,value:t}),S.ProgressMeta.ops().upsertOne({progressId:this.id,name:e,value:t})}setMetaRecord(e){const t=this.getMeta(),i=(0,l.diff)(t.map((e=>e.name)),Object.keys(e));this.logger().debug("setMetaRecord()",{progressId:this.id,keysToDelete:i,record:e}),S.ProgressMeta.ops().upsert((0,m.entries)(e).map((([e,t])=>({progressId:this.id,name:e,value:(0,v.toS)(t)})))),(0,l.isNotEmpty)(i)&&S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).whereIn("name",i).delete()))}deleteMeta(...e){return this.logger().debug("deleteMeta()",{progressId:this.id,names:e}),S.ProgressMeta.dbl.runf((t=>t.whereIn("name",e).andWhere({progressId:this.id}).delete()))}deleteAllMeta(){return this.logger().debug("deleteAllMeta()",{progressId:this.id}),S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).delete()))}getMetaAsRecord(){return this.logger().tap({msg:"getMetaAsRecord()",result:(0,m.fromEntries)(this.getMeta().map((e=>[e.name,e.value])))??{}})}}t.Progress=k,k.$tableName="Progress",k.$uniqueColumnName="id"},55009:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressMeta=t.ProgressMetaNames=t.DirSyncProgressMetaNames=void 0;const r=i(50989),s=i(72761);t.DirSyncProgressMetaNames=(0,r.strEnum)("lastScannedDirectory","scannedDirectoryCount","completedDirectoryScan","enqueuedStaleFiles","processedImageCount","processedVideoCount","completedDirectorySync"),t.ProgressMetaNames=(0,r.strEnum)(...t.DirSyncProgressMetaNames.values);class n extends s.TimestampedModel{}t.ProgressMeta=n,n.$tableName="ProgressMeta",n.$uniqueColumnName="progressId,name"},39604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.upsertToShaBlockslist=t.upsertFileToShaBlockslist=t.isShaBlockslisted=t.notBlocklistedSha=void 0;const r=i(19851),s=i(50213),n=i(95696),a=i(40958),o=i(22573),l=i(86859),u=i(94448),c=(0,r.lazy)((()=>(0,s.mkLogger)("model.ShaBlocklist"))),d=(0,r.lazy)((()=>new l.DbRequest(u.modelDb,"ShaBlocklist")));function h(e){return null!=(0,u.modelDb)()&&!(0,o.blank)(e)&&c().tap({msg:"isShaBlockslisted",result:null!=d().pluckFirstf((t=>t.where({sha:e}).limit(1))),meta:{sha:e}})}function f(...e){if(null==u.modelDb.prior())return;const t=(0,a.uniq)(e).map((e=>({sha:e})));return(0,a.isEmpty)(t)?void 0:d().upsert((e=>e.insert(t)))}t.notBlocklistedSha=async function(e){if(null==(0,u.modelDb)())return null;const t=h(await n.PosixFile.for(e).sha());return null==t?null:!t},t.isShaBlockslisted=h,t.upsertFileToShaBlockslist=async function(e){if(null==(0,u.modelDb)())return;const t=await n.PosixFile.for(e).sha();return null==t?void 0:f(t)},t.upsertToShaBlockslist=f},48723:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Tag=t.UpdateTagAssetCountTimeName=void 0;const a=i(56038),o=i(34102),l=i(19851),u=i(50213),c=i(36372),d=i(97352),h=i(28874),f=i(81168),m=i(42231),p=i(75020),g=i(40958),y=i(22573),v=i(42659),w=i(41400),b=i(50357),S=i(55835),P=i(31586),_=i(34666),T=i(20214),M=i(51926),E=i(59455),k=i(12168),D=i(6186),x=i(57038),C=i(21074),F=i(7656),A=i(43487),I=i(48722),O=i(45295),L=i(98784),R=i(41507),N=i(72761),B=4*v.secondMs,j=(0,l.lazy)((()=>(0,u.mkLogger)("model.Tag")));(0,w.later)((()=>{(0,o.ee)().on("clearCache",(()=>z.clear())),(0,o.ee)().on("clearDbCache",(()=>z.clear()))})),t.UpdateTagAssetCountTimeName="db.updateTagAssetCountTimeName";class z extends N.TimestampedModel{constructor(){super(...arguments),this.displayPath=(0,l.lazy)((()=>{const e=this.getParent();return(0,g.compactBlanks)([...null==e?[]:e.displayPath(),this.displayName])})),this.ancestorIds=(0,l.lazy)((()=>0===this.parentId||null==this.parentId?[]:r.dbl.pluckAll({sql:(0,M.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.id","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}}))),this.firstNonInterstitialTagId=(0,l.lazy)((()=>{if(!this.isRoot&&0===this.directAssetCount()&&1===this.getChildrenCount()){const e=this.getChildren();if(1===e?.length)return e[0].firstNonInterstitialTagId()}return this.id})),this.directAssetCount=(0,l.lazy)((()=>0===this.id?0:A.Asset.dbl.pluckFirst(A.Asset.shownUnhidden().join("AssetTag","AssetTag.assetId","Asset.id").where("AssetTag.tagId",this.id).countDistinct("Asset.id"))))}static orderBy(e){return e.orderByRaw("COALESCE(ordinal, _path) COLLATE NOCASE")}static clear(){this.root.unset(),this.roots.unset(),this._upsertDefaultRoots.unset(),this.ops().clearDbCache()}static validate_(){return(0,a.timeSync)("Tag.validate_",(()=>{r.clear();for(const e of this.ops().allf((e=>e.whereRaw("id = parentId")))){j().warn(`Tag ${e.id} has itself as parentId. Attempting to fix...`);const t=e.path.slice(0,-1),i=(0,g.isEmpty)(t)?void 0:this.findOrCreate(t);e.update({parentId:i?.id??null})}for(const e of r.roots())e.validate_([])}))}validate_(e){const t=this.path;if(!(0,b.eql)(t.slice(0,-1),e))throw new Error(`Tag:${this.id} path ${t.join("/")} does not match expected parent ${e.join("/")}`);for(const e of this.getChildren())e.validate_(t)}static deltaAssetCountAndAncestors(e,t=1){return r.incrAssetCount(r.selfAndAncestorIds(e),t)}static incrAssetCount(e,t=1){(0,g.isEmpty)(e)||r.dbl.runf((i=>i.whereIn("id",e).andWhereNot({assetCount:null}).update({assetCount:(0,x.knex)().raw("assetCount + "+Math.round(t)),updatedAt:Date.now()})))}static selfAndAncestorIds(e){const t=(0,E.toA)(e).filter(P.gt0);return r.dbl.pluckAll({sql:(0,M.compressWhitespace)("WITH RECURSIVE ancestors(id) AS ("," SELECT id FROM Tag where id in "+(0,C.sqlWhereInClause)(t.length)," UNION ALL"," SELECT Tag.parentId as id"," FROM Tag, ancestors"," WHERE Tag.id = ancestors.id",")","SELECT distinct(id)","FROM ancestors","WHERE id IS NOT NULL"),bindings:t})}static updateAssetCount(e){if((0,P.gt0)(e))return(0,a.timeSync)(t.UpdateTagAssetCountTimeName,(()=>{const t=r.dbl.pluckFirst({sql:F.RecursiveAssetCountForTagQuery,bindings:{tagId:e}});r.dbl.runf((i=>i.update({assetCount:t,updatedAt:Date.now()}).where({id:e}))),j().debug("Updated asset counts for tag ",{tagId:e,assetCount:t})}))}static findByIdOrPath(e,t){return 0===e?r.root():(0,P.gt0)(e)?this.findById(e):this.findByPath(t)}static findById(e){return 0===e?r.root():this.ops().findById(e)}static findByPath(e){if((0,g.isEmpty)(e))return r.root();const t=(0,m.joinTagPath)(e);return this.ops().firstf((e=>e.whereLike("_path",t)))}static findByPathN(e){const t=(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,y.toNotBlank)((0,m.joinTagPath)(e))));return(0,g.compact)(t.map((e=>this.findByPath(e))))}static getPagedAssets(e,t){const i=new r;return i.id=e,i.getPagedAssetIds(t)}static findOrCreate(e){if((0,g.isEmpty)(e))throw new Error("empty tagPath");const t=this.findByPath(e);if(null!=t)return t;const i=n(this,r,"m",s).call(this,e),a=i.depth<=1?void 0:this.findOrCreate(e.slice(0,-1));return(0,S.map)(a,(e=>i.parentId=e.id)),this.ops().upsertOne(i)}static findOrCreateByPathN(e){return(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,m.joinTagPath)(e))).map((e=>this.findOrCreate(e)))}clear(){return this.parent=void 0,this.root=void 0,this.children=void 0,this.ancestors=void 0,this.assets=void 0,this.relatedAssets=void 0,this.ancestorIds.unset(),this}$afterInsert(){L.TagFts.insertFts([this])}siblingPath(e){return(0,m.joinTagPath)([...this.parentPath,e])}changeName(e){return this.changePath(this.siblingPath(e))}maybeUpsertDisplayName(e){return(0,y.blank)(e)||e===this._displayName?void 0:this.upsert({_displayName:e})}changePath(e,t=!0){const i=this._path,s=r.findByPath((0,m.splitTagPath)(e));this.logger().info("changePath(): ",{priorPath:i,newPath:e,existingSibling:s});try{if(null==s)r.dbl.runf((t=>t.whereLike("_path",i+"%").update({updatedAt:Date.now(),_path:(0,x.knex)().raw("REPLACE(_path, ?, ?)",[i,e])}))),this._path=e;else{e=s._path,this.logger().info("changePath(): replacing with sibling",e),O.AssetTag.dbl.upsert((e=>e.where({tagId:this.id}).update({tagId:s.id}))),O.AssetTag.dbl.runf((e=>e.where({tagId:this.id}).delete()));for(const e of this.getChildren())e.changePath((0,m.joinTagPath)([...s.path,e.name]),!1);r.dbl.runf((e=>e.where({parentId:this.id}).update({parentId:s.id}))),this.delete()}}finally{t&&r.clear()}}get name(){const e=this.path;return e[e.length-1]}get path(){return(0,m.splitTagPath)(this._path)}get displayName(){return(0,y.toNotBlank)(this._displayName)??this.name}get isRoot(){return 0===this.id}get depth(){return this.path.length}get parentPath(){return this.path.slice(0,-1)}get sortBy(){return[this.depth,null==this.ordinal?2**51:this.ordinal,this.path.map((e=>e.toLowerCase()))]}$childrenQuery(){return r.orderBy(r.query().where({parentId:this.id}))}$assetsQuery(){return A.Asset.shownUnhidden().columns("Asset.*").join("AssetTag","AssetTag.assetId","Asset.id").where({tagId:this.id})}$selectAssetIdColumns(e){return e.clearSelect().select({assetId:"Asset.id",capturedAtLocal:"Asset.capturedAtLocal",updateCount:"Asset.updateCount",durationMs:"Asset.durationMs"})}$assetIdsQuery(){return this.$selectAssetIdColumns(this.$assetsQuery())}setAncestors(e){this.ancestors=e,this.parent=e[e.length-1],(0,S.map)(this.parent,(t=>t.setAncestors(e.slice(0,-1))))}async toApiPathElements(){return(0,T.thenCollect)(this.getAncestorsAndSelf(),(e=>e.toPathTag()))}toPathTag(){return{tagPath:this.path,displayName:this.displayName}}toApiTag(){return{tagId:this.id,tagPath:this.path,displayPath:this.displayPath(),description:this.description,assetCount:this.assetCount}}toStringId(){return"Tag("+this.path.join("/")+")"}getParent(){if(!this.isRoot)return null!=this.parentId&&null==this.parent?this.parent=r.findById(this.parentId):this.parent}getPagedChildren(e){if(0===this.id){const t=e.offset??0,i=t+(e.limit??this.children.length);return[...this.children].slice(t,i)}const t=this.$childrenQuery();return(0,d.mapGt0)(e.offset,(e=>{t.offset(e)})),(0,d.mapGt0)(e.limit,(e=>{t.limit(e)})),r.ops().all(t)}getChildrenCount(){return null!=this.children?this.children.length:r.dbl.pluckFirstf((e=>(this.isRoot?e.whereNull("parentId"):e.where({parentId:this.id})).count()))}getChildren(){return this.isRoot||(this.children=r.ops().all(this.$childrenQuery()),this.children.forEach((e=>{e.parent=this}))),this.children}link(){return"/tag/"+this.path.map(encodeURIComponent).join("/")}get rootName(){return this.path[0]}get ancestorsAndSelf(){return[...this.ancestors,this]}getAncestors(){return this.ancestors??(this.ancestors=this._getAncestors())}getAncestorsAndSelf(){return[...this.getAncestors(),this]}_getAncestors(){return 0===this.parentId||null==this.parentId?[]:r.ops().all({sql:(0,M.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.*","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}})}getPagedAssetIds(e){let t=this.$assetIdsQuery();return t=t.limit(p.ThumbsPerSample),(0,P.gt0)(e.offset)&&(t=t.offset(e.offset)),t=t.orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId"}]),(0,g.compact)(A.Asset.dbl.all(t).map(I.toAssetId))}getAssets(){const e=this.$assetsQuery().orderBy("capturedAtLocal","desc");return A.Asset.ops().all(e)}async assetCountDesc(e){const t=this.assetCount;return(null==t||null==e||e.length===t||0===e.length?"":(0,k.fmt)(e.length)+" of ")+(0,k.plur)(t,"asset")}getAssetCount(){return 0===this.id?r.dbl.pluckFirst({sql:(0,M.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," Asset","WHERE"," Asset.shown = 1"," AND Asset.excluded = 0"," AND Asset.hidden = 0"," AND Asset.deletedAt IS NULL")}):r.dbl.pluckFirst({sql:F.RecursiveAssetCountForTagQuery,bindings:{tagId:this.id}})}$assetStreamQuery(e,t,i){let r=this.path[0]===p.TagRoots.When?A.Asset.shownUnhidden():this.$assetsQuery();return r=r.distinct().where("capturedAtLocal",i,e.capturedAtLocal).andWhereNot("Asset.id",e.id).limit("="===i?2*t:t),"="===i?r.orderByRaw(`ABS(Asset.id-${e.id})`):r.orderBy([{column:"capturedAtLocal",order:">"===i?"asc":"desc"},"Asset.id"])}getAssetStream(e,t){t=(0,P.gt0)(t)?t:p.BeforeAfterStreamLimit;const[i,r,s]=["<","=",">"].map((i=>(0,g.compact)(A.Asset.ops().all(this.$assetStreamQuery(e,t,i)).map(I.toAssetId))));for(const t of r)t.assetIdA.Asset.shownUnhidden(this.$selectAssetIdColumns(r)).distinct().join("Asset","Asset.id","AssetTag.assetId").join("Tag","Tag.id","AssetTag.tagId").whereLike("_path",this._path+"%").orderByRaw((0,c.prngOrderByClause)(e+(this.id??0),"Asset.id",i)).limit(t))).map(I.toAssetId));return this.logger().debug(this.path+": Found "+r.length+" related assets"),r}get attrs(){return{href:this.link(),title:this.name}}}t.Tag=z,r=z,s=function(e){const t=new r;t._path=(0,m.joinTagPath)(e);const i=e[e.length-1];return"object"==typeof i&&((0,y.mapNotBlank)(i.displayName,(e=>t._displayName=e)),(0,P.mapNumeric)(i.ordinal,(e=>t.ordinal=e)),(0,y.mapNotBlank)(i.description,(e=>t.description=e)),(0,P.mapNumeric)(i.releasedAt,(e=>t.releasedAt=e))),t},z.$tableName="Tag",z.$uniqueColumnName="_path",z.$useCache=!0,z.cmp=(e,t)=>(0,_.cmp)([e.ordinal??Number.MAX_SAFE_INTEGER,...e.path],[t.ordinal??Number.MAX_SAFE_INTEGER,...t.path]),z.root=(0,l.lazy)((()=>{const e=new r;return e.id=0,e._path=m.TagSep,e.parentId=void 0,e.children=r.roots().filter((e=>!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.name)&&!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.description??""))),e.ancestors=[],e.assetCount=A.Asset.shownCount(),e.upsert=()=>{throw new Error("upsert not supported on root")},e}),B),z._upsertDefaultRoots=(0,l.lazy)((()=>r.ops().upsert(D.Roots.map((e=>({_path:(0,m.joinTagPath)([e.name]),ordinal:e.ordinal})))))),z.roots=(0,l.lazy)((()=>{r._upsertDefaultRoots();const e=r.ops().all(r.orderBy(r.query().whereNull("parentId")));for(const t of e)t.parentId=void 0,t.ancestors=[];return e}),B);const V=(0,l.lazy)((()=>A.Asset.dbl.pluckFirstf((e=>e.count()))),v.minuteMs)},98784:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagFts=void 0;const r=i(38156),s=i(3127),n=i(40958),a=i(41400),o=i(94715),l=i(55046),u=i(48723);class c extends l.Model{static insertFts(e){try{const t=e.filter((e=>null!=e.parentId)).map((e=>({rowid:e.id,root:(0,s.tag_fts_root)(e._path),path:(0,s.tag_fts_path)(e._path)})));(0,n.isEmpty)(t)||this.dbl.runf((e=>e.insert(t)))}catch(e){this.$logger().warn("Failed to update tag_fts",{error:e})}}static async rebuild(){const e=new r.PushProgressObserver({op:"Rebuilding tag search index"},u.Tag.dbl.pluckFirstf((e=>e.count("*")))),t=this.dbl.db();o.Migrations.create_tag_fts(t.db),await u.Tag.ops().batched({qb:e=>e,onResults:t=>(this.$logger().throwIfAborted_(),this.insertFts(t),e.incrProgress(t.length),(0,a.delay)(1))}),e.completed()}}t.TagFts=c,c.$tableName="tag_fts",c.$uniqueColumnName="rowid",c.$booleanFields=[]},41507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.coalesceStreams=t.TaggedAssetStream=t.cmpAssetDesc=t.cmpAssetAsc=void 0;const r=i(48884),s=i(50213),n=i(28874),a=i(40958),o=i(76790),l=i(31586),u=i(34666),c=i(20214),d=i(59455);t.cmpAssetAsc=(e,t)=>(0,u.cmp)([e.capturedAtLocal,e.id],[t.capturedAtLocal,t.id]),t.cmpAssetDesc=(e,t)=>(0,u.cmp)([t.capturedAtLocal,t.id],[e.capturedAtLocal,e.id]),t.TaggedAssetStream=class{constructor(e,t,i,r){this.tags=e,this.before=t,this.after=i,this.limit=r,this.logger=()=>(0,s.mkLogger)("model.TaggedAssetStream("+this.toString()+")"),this.logger().info("new",this.toJSON())}vacuum(){(0,o.sortByInPlace)(this.before,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainFirstN)(this.before,this.limit),(0,o.sortByInPlace)(this.after,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainLastN)(this.after,this.limit)}toString(){return this.tags.map((e=>e.path.join("/"))).join(",")}valueOf(){return this.toString()}get length(){return(0,d.toA)(this.before).length+(0,d.toA)(this.after).length}leftPad(e){return[...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+1),capturedAtLocal:-1,v:0}))),...e]}rightPad(e){return[...e,...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+this.limit+1),capturedAtLocal:-1,v:0})))]}toJSON(){return{tags:this.tags.map((e=>e.toString())),assetIdsAfter:this.after,assetIdsBefore:this.before}}mergeWith(e){(0,a.pushUniqBy)(this.tags,e.tags,(e=>e.path)),(0,a.pushUniqBy)(this.before,e.before,(e=>e.assetId)),(0,a.pushUniqBy)(this.after,e.after,(e=>e.assetId)),this.logger().debug("mergeWith() complete",{tas:e.toJSON(),tags:this.tags.map((e=>e.path)),beforeIds:this.before,afterIds:this.after})}async toApi(){return this.vacuum(),this.logger().tap({msg:"toApi()",result:{tags:await(0,c.thenCollect)(this.tags,(e=>e.toApiTag())),assetIdsAfter:this.leftPad(this.after),assetIdsBefore:this.rightPad(this.before)}})}streamCoeff(e){return this.logger().tap({msg:"streamCoeff",meta:{this:this.tags.map((e=>e.path)),tas:e.tags.map((e=>e.path))},result:(0,r.diceCoeff)([...this.before,...this.after],[...e.before,...e.after],(e=>e.assetId))})}},t.coalesceStreams=function(e){const t=n.Settings.minStreamCorrPct.valueOrDefault/100,i=[],s=e.filter((e=>e.length>5));for(const e of s){const s=(0,r.greatestBy)(i,(i=>(0,l.gtOrElse)(i.streamCoeff(e),t)));null==s?i.push(e):s.mergeWith(e)}return i}},94710:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Task=t.StaleTaskError=t.InvalidTaskError=t.TaskNames=t.Tasks=t.testTask=void 0;const c=i(78474),d=i(22454),h=i(23560),f=i(12089),m=i(76740),p=i(22911),g=i(99331),y=i(31562),v=i(38835),w=i(70025),b=i(8769),S=i(74128),P=i(28874),_=i(37692),T=i(40958),M=i(22573),E=i(42659),k=i(45599),D=i(98553),x=i(49769),C=i(68708),F=i(50989),A=i(59455),I=i(58723),O=i(34274),L=i(90901),R=i(61989),N=i(93755),B=i(69032),j=i(55046);t.testTask=(0,f.shim1)({name:"testTask",impl:async e=>{}}),t.Tasks={applyDeleted:I.applyDeleted,applyExcluded:I.applyExcluded,runTagMaintenance:B.runTagMaintenance,repairAsset:async function(e){e.forceSync=!0,e.skipPreviews=!0,e.skipAssetTagging=!0;const t=await(0,R.updateAsset_)(e);return(0,T.isNotEmpty)(t?.assetIdsToUpdate)&&q.add(t?.assetIdsToUpdate.map((t=>({fn:"repairAsset",args:{...e,assetId:t},priority:W.repairAsset+1})))),null!=t&&!0!==t.deleted&&(0,M.blank)((0,A.toA)(t.rejected).join(""))&&(0,M.blank)(t.error)&&q.addOne("assetPostUpsertTasks",(0,C.omit)(e,"skipPreviews","skipAssetTagging")),t},assetPostUpsertTasks:L.assetPostUpsertTasks,updateAssetFile:N.updateAssetFile_,syncFile:O.importFileToResult_,testTask:t.testTask},t.TaskNames=(0,F.strEnum)(...(0,C.keys)(t.Tasks));class z extends Error{}t.InvalidTaskError=z;class V extends Error{}t.StaleTaskError=V;const W={applyDeleted:16,applyExcluded:16,runTagMaintenance:14,repairAsset:12,assetPostUpsertTasks:10,updateAssetFile:8,syncFile:0,testTask:-1},U=["repairAsset"];class q extends j.Model{constructor(){super(...arguments),r.add(this),o.set(this,(0,k.defer)((()=>new m.Abortable)))}static countTaskNames(){const e={};for(const t of s.dbl.allf((e=>e.select("fn").count().groupBy("fn"))))e[t.fn]=t["count(*)"];return e}static orderBy(e){return e.orderBy([{column:"priority",order:"desc"},{column:"retries",order:"desc"},{column:"id",order:"asc"}])}static count(){return s.dbl.pluckFirstf((e=>e.count("id")))}static freeSlots(){return P.Settings.taskListCap.valueOrDefault-s.count()}static countByFn(e){return s.dbl.pluckFirstf((t=>t.where({fn:e}).count("id")))}static nextByFn(e,t=(e=>e)){return s.ops().allf((i=>s.orderBy(t(i.where({fn:e})))))}set args(e){this.argsJSON=(0,D.stringify)(e)}get args(){const e=(0,D.parseJSON)(this.argsJSON);return(0,C.notEmptyObj)(e)&&(e.halt=u(this,o,"f").call(this)),e}get isSerial(){return U.includes(this.fn)}toString(){return`Task#${this.fn}(${this.argsJSON})`}static addOne(e,t){return s.add([{fn:e,args:t}])[0]}static add(e,t=!1){if((0,T.isEmpty)(e))return[];const i=s.ops().upsert(e.map((e=>({fn:e.fn,argsJSON:(0,D.stringify)(e.args)})),t));return s.ee.emit("added",i),(0,h.isTaskListManager)()||(0,_.addStateEvent)("checkTasks"),i}$beforeUpsert(){this.priority??(this.priority=W[this.fn]),this.retries??(this.retries=P.Settings.maxRetries.valueOrDefault)}donePromise(){return(0,h.isTaskListManager)()?(0,x.getOrSet)(u(s,s,"f",n),this.id,(()=>new p.Deferred(this.toString(),{payload:this}))):(0,y.untilTrue)((()=>null==s.ops().findById(this.id)),{intervalMs:E.secondMs})}abort(e){this.logger().warn("aborting task",{reason:e,task:this}),u(this,o,"f").call(this).abort(e),this.delete(),(0,M.blank)(this.args.path)||(0,S.syncReport)().onProgress({path:this.args.path,from:this.fn,state:S.SyncFileStates.failed,details:e})}async _run(){if(this.retries<0)throw this.logger().warn(".run(): too many retries"+v.InternalErrorFlag,{job:this}),this.delete(),new z;if(!u(this,r,"m",l).call(this))throw this.logger().warn(".run(): someone already started this task",{job:this}),new V;try{const e=Date.now(),i=await t.Tasks[this.fn](this.args);return this.logger().throwIfAborted_(u(this,o,"f").prior()),s.taskResolvedCounts.incr(this.fn),s.ee.emit("resolved",this,i,Date.now()-e),this.delete(),u(s,s,"f",n).get(this.id)?.resolve(i),i}catch(e){if((0,g.ending)())throw this.logger().info("task failed, but we're ending. We'll leave it for next time.",{task:this}),e;throw s.taskRejectedCounts.incr(this.fn),(0,w.isRedoableError)(e)?(this.retries++,this.priority--,this.upsert()):!0===(0,w.isRetriableError)(e)&&this.retries>=0?this.logger().warn("run failed, but we can retry it later",{task:this,error:e}):(s.ee.emit("rejected",this,e),this.delete(),u(s,s,"f",n).get(this.id)?.reject(e),(0,b.onError)(this.toString()+" failed",e)),e}finally{u(s,s,"m",a).call(s)}}}t.Task=q,s=q,o=new WeakMap,r=new WeakSet,a=function(){for(const[e,t]of u(this,s,"f",n).entries())t.isSettled&&u(this,s,"f",n).delete(e)},l=function(){const e=this.retries;if(1===s.dbl.runf((t=>t.where({id:this.id,retries:e}).update({retries:e-1}))).changes)return--this.retries,!0;{const e=this.toJSON(),t=this.reload();return this.logger().warn(".#decrRetries(): someone already started this task",{before:e,reloaded:t}),!1}},q.$tableName="Task",q.$uniqueColumnName="fn,argsJSON",q.$useCache=!1,q.taskResolvedCounts=new d.CountingSet,q.taskRejectedCounts=new d.CountingSet,q.ee=new c.EventEmitter,n={value:new Map}},72761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimestampedModel=void 0;const r=i(97352),s=i(40958),n=i(31586),a=i(59455),o=i(55046);class l extends o.Model{static touch(e,t={}){t.updatedAt??(t.updatedAt=Date.now()),delete t.id;const i=(0,a.toA)(e).filter(n.gt0);return(0,s.isEmpty)(i)?void 0:this.dbl.runf((e=>e.whereIn("id",i).update(t)))}get createdAtDate(){return(0,r.mapGt0)(this.createdAt,(e=>new Date(e)))}get updatedAtDate(){return(0,r.mapGt0)(this.updatedAt,(e=>new Date(e)))}touch(e={}){e.updatedAt??(e.updatedAt=Date.now());const t=this.id;null==t?this.upsert():this.class().dbl.runf((i=>i.where({id:t}).update(e)))}$beforeUpsert(){if(super.$beforeUpsert(),this.createdAt??(this.createdAt=Date.now()),this.updatedAt=Date.now(),"updateCount"in this){const e=this,t=e.updateCount;e.updateCount=((0,n.toGt0)(e.updateCount)??0)+1,this.logger().debug("$beforeUpsert(): incr updateCount",{prior:t,now:e.updateCount})}}}t.TimestampedModel=l},73407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeAssetTags_=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(47783),o=i(54017),l=(0,r.lazy)((()=>(0,s.mkLogger)("model.WriteAssetTags")));t.writeAssetTags_=async function(e,t){const i=o.AssetFile.ops().findBy({assetId:e});return(0,n.mapAsync)({name:"writeAssetTags",arr:i,f:e=>async function(e,t){const i=await e.posixFile_();if(null!=i&&!0===await(i?.exists()))return(0,a.writeTags_)(i,t,e.mimetype);l().info("Skipping AssetFile:"+e.id+" (file is missing)",{writeTags:t})}(e,t)})}},58723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyExcluded=t.applyDeleted=void 0;const r=i(50213),s=i(43487),n=(0,r.mkLogger)("ops.ApplyRemovable");async function a(e,t,i){const r=e?"Deleting":"Excluding",a=e?"deletedAt":"excludedAt";await s.Asset.dbl.batched({qb:e=>e.select("id").where("shown",0).andWhere(a,"<=",t),onResults:async t=>{for(const a of t){n.throwIfAborted_(i);try{await s.Asset.remove({assetId:a,blocklistShas:!0,unlinkAssetFiles:e})}catch(e){n.error(r+" failed",{assetId:a,error:e})}}}})}t.applyDeleted=function(e){return a(!0,e.createdAt,e.halt)},t.applyExcluded=function(e){return a(!1,e.createdAt,e.halt)}},76386:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiProgressPatchPath=t.tellWebProgressUpdated=t.ProgressRateMs=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(24540),o=i(28874),l=i(34238),u=i(4988),c=i(15674),d=i(42659),h=(0,i(45599).defer)((()=>(0,s.mkLogger)("progress.Progress")));t.ProgressRateMs=(0,r.lazy)((()=>d.secondMs*((0,a.isRaspberryPi)()||(0,c.maxCpus)()<=3?5:1.5))),t.tellWebProgressUpdated=(0,r.lazy)((async()=>{if((0,n.isWebService)())return;const e=l.URI.from({scheme:"http",authority:"127.0.0.1:"+o.Settings.httpPort.valueOrDefault,path:t.ApiProgressPatchPath}).toString();await(0,u.httpRequest_)({url:e,method:"PATCH"}).catch((e=>h().warn(".tellWebProgressUpdated: failed",{error:e})))}),(0,t.ProgressRateMs)()),t.ApiProgressPatchPath="/api/progress"},44694:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryTermToFuzzyDate=void 0;const r=i(98725),s=(0,i(19851).lazy)((()=>new r.FuzzyDateParser({fuzzyDateParsing:!0,fuzzyYearParsing:!0})));t.queryTermToFuzzyDate=function(e){return s().parse(e)}},43786:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryToString=t.NormieQuerySymbols=t.SetQuerySymbols=t.isTrueTerm=t.flatTerms=t.findTerm=t.hasNsTerm=t.isQuery=t.isClause=t.isAndClause=t.isOrClause=t.isTerm=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(51926),o=i(54993);function l(e){return"object"==typeof e&&(0,s.notBlank)(e.term)&&(null==e.not||"boolean"==typeof e.not&&(null==e.ns||(0,a.isString)(e.ns)))}function u(e){return"object"==typeof e&&Array.isArray(e.queries)}function c(e){return"or"===e?.type&&u(e)}function d(e){return"and"===e?.type&&u(e)}function h(e){return d(e)||c(e)}function f(e,t){if(l(e))return t(e)?e:void 0;for(const i of e.queries){const e=f(i,t);if(null!=e)return e}}t.isTerm=l,t.isOrClause=c,t.isAndClause=d,t.isClause=h,t.isQuery=function(e){return l(e)||h(e)},t.hasNsTerm=function(e,t){return null!=f(e,(e=>e.ns===t))},t.findTerm=f,t.flatTerms=function e(t){return l(t)?[t]:(0,r.flatMap)(t.queries,e)},t.isTrueTerm=function(e){return(0,n.isTrue)(e?.not)?(0,n.isFalse)(e?.term):(0,n.isTrue)(e?.term)},t.SetQuerySymbols={not:"¬",and:"∧",or:"∨"},t.NormieQuerySymbols={not:"-",and:"AND",or:"OR"},t.queryToString=function e(i,r=t.SetQuerySymbols){if(null==i)return"";if(l(i)){let e=i.term;return null==i.term.match(/^[a-z]+$/i)&&(e='"'+e.replace(/"/g,'\\"')+'"'),`${(0,n.isTrue)(i.not)?r.not:""}${null==i.ns?"":i.ns+":"+(0,o.toS)(i.op)}${e}`}return"("+i.queries.map((t=>e(t,r))).join(` ${"or"===i.type?r.or:r.and} `)+")"}},7573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeTerm=t.isAssetTerm=t.AssetTermNs=t.AssetTermDateNs=t.AssetTermBoolNs=t.normalizeQuery=void 0;const r=i(48884),s=i(75020),n=i(40958),a=i(76790),o=i(22573),l=i(38639),u=i(50989),c=i(54993),d=i(44694),h=i(43786);function f(e){return(0,a.sortBy)((0,n.uniqBy)(e,h.queryToString),(e=>[(0,h.isTerm)(e)?0:(0,h.isOrClause)(e)?1:2,(0,h.queryToString)(e).replace(/[¬(]+/g,"")]))}t.normalizeQuery=function e(t){if((0,h.isTerm)(t))return g(t);const i=t.queries.map(e);if(0===i.length)throw new Error("empty query");if(1===i.length)return i[0];const[s,n]=(0,r.partition)(i,h.isTerm),[a,o]=(0,r.partition)(n,(e=>e.type===t.type));for(const e of a)s.push(...e.queries);const l={type:t.type,queries:f([...s,...o])};return l.queries.every((e=>(0,h.isTerm)(e)&&e.not))?e({type:"and"===t.type?"or":"and",queries:f(l.queries.map((e=>({...e,not:!1}))))}):l},t.AssetTermBoolNs=(0,u.strEnum)("deleted","excluded","liked","hidden"),t.AssetTermDateNs=(0,u.strEnum)("date","updated");const m={delete:t.AssetTermBoolNs.deleted,trash:t.AssetTermBoolNs.deleted,trashed:t.AssetTermBoolNs.deleted,exclude:t.AssetTermBoolNs.excluded,remove:t.AssetTermBoolNs.excluded,removed:t.AssetTermBoolNs.excluded,like:t.AssetTermBoolNs.liked,fav:t.AssetTermBoolNs.liked,fave:t.AssetTermBoolNs.liked,faved:t.AssetTermBoolNs.liked,favorite:t.AssetTermBoolNs.liked,favourite:t.AssetTermBoolNs.liked,hide:t.AssetTermBoolNs.hidden,archive:t.AssetTermBoolNs.hidden,archived:t.AssetTermBoolNs.hidden},p={kw:s.TagRoots.Keywords,keyword:s.TagRoots.Keywords,keywords:s.TagRoots.Keywords,dir:s.TagRoots.fs,directory:s.TagRoots.fs,folder:s.TagRoots.fs};function g(e){if((0,o.blank)(e.ns)&&null!=e.term.match(/^\d{4}[-\d]*$/)&&null!=(0,d.queryTermToFuzzyDate)(e.term))return{ns:"date",term:e.term};if("when"===(0,c.toS)(e.ns).toLowerCase())return g({...e,ns:t.AssetTermDateNs.date,term:e.term.replace(/\//g,"-")});let i=(0,o.notBlankOr)(e.ns,e.term).toLowerCase();if(i=m[i]??i,t.AssetTermBoolNs.includes(i)){let t=!(0,l.isFalse)(e.term);return!0===e.not&&(t=!t),{ns:i,term:(0,c.toS)(t)}}if(t.AssetTermNs.includes(i))return{...e,ns:i};if("before"===i||"after"===i){if(null!=e.op)throw new Error(i+": doesn't support operators");const r="after"===i&&!0!==e.not||!0===e.not;return{ns:t.AssetTermDateNs.date,op:r?">":"<",term:e.term}}return i!==e.term.toLowerCase()?{not:e.not,op:e.op,ns:p[i]??i,term:e.term}:e}t.AssetTermNs=(0,u.strEnum)(...t.AssetTermDateNs.values,...t.AssetTermBoolNs.values),t.isAssetTerm=function(e){return(0,h.isTerm)(e)&&t.AssetTermNs.includes(g(e).ns)},t.normalizeTerm=g},33693:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseQuery_=void 0;const s=r(i(31704)),n=i(19851),a=i(50213),o=i(7282),l=i(38835),u=i(31586),c=r(i(70471)),d=(0,n.lazy)((()=>(0,a.mkLogger)("query.QueryParser")));t.parseQuery_=function(e){try{const t=new s.default.Parser(s.default.Grammar.fromCompiled(c.default)).feed(e.trim()).finish();if(t.length>1&&!(0,o.isProd)()&&d().throw("parseQuery(): ambiguous grammar!",{input:e}),null==t[0])throw new Error("invalid query");return d().debug("parseQuery()",{input:e,result:t[0]}),t[0]}catch(t){const i=t.token?.col,r=`Query syntax error${(0,u.gt0)(i)?" around column "+i:""}: "${e}"`;throw d().warn("parseQuery(): bad query",{msg:r,err:t}),new Error(r+l.NonRetriableErrorFlag+l.DoNotSendErrorFlag)}}},23523:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryToSql=t.queryStringToSql_=t.defaultAssetQuery=void 0;const r=i(19851),s=i(50213),n=i(66649),a=i(89724),o=i(70417),l=i(28874),u=i(42231),c=i(22573),d=i(38639),h=i(98553),f=i(54993),m=i(57038),p=i(43487),g=i(44694),y=i(43786),v=i(7573),w=i(33693),b=(0,r.lazy)((()=>(0,s.mkLogger)("query.QueryToSql")));function S(e,t,i){if((0,y.isTerm)(t))return function(e,t,i){return(0,v.isAssetTerm)(t)?function(e,t){switch(t.ns){case v.AssetTermNs.date:case v.AssetTermNs.updated:return function(e,t){const i=t.op??"=",r="date"===t.ns?"Asset.capturedAtLocal":"updated"===t.ns?"Asset.updatedAt":void 0;if(null==r)throw new Error("internal error: unexpected namespace for "+(0,h.stringify)(t));const s="Asset.updatedAt"===r?n.datedToMillis:a.maybeDatedToLocal,l=(0,g.queryTermToFuzzyDate)(t.term),u=s(l),c=l?.following()?.toDateTime(),d=s(c?.minus({second:1})),f=(0,o.max)([u,d]);if(null==l||null==u||null==f)throw new Error((0,y.queryToString)(t,y.NormieQuerySymbols)+" can't be parsed as a date");if("="===i)return e.whereBetween(r,[u,f]);if("<"===i)return e.where(r,i,u);if("<="===i)return e.where(r,i,f);if(">="===i)return e.where(r,i,u);if(">"===i)return e.where(r,i,f);throw new Error("internal error: unexpected op for "+(0,h.stringify)(t))}(e,t);case v.AssetTermNs.hidden:return e.where("Asset.hidden",_(t));case v.AssetTermNs.excluded:return M({qb:e,column:"Asset.excludedAt",whereNull:0===_(t)});case v.AssetTermNs.deleted:return M({qb:e,column:"Asset.deletedAt",whereNull:0===_(t)});case v.AssetTermNs.liked:return e.where("Asset.rating",P(t)?">=":"<",l.Settings.likeRating.valueOrDefault);default:throw new Error("not asset term:"+(0,y.queryToString)(t))}}(e,t):function(e,t,i){const r=t.term.startsWith("/"),s="="===t.op,n=function(e,t){if(null==t||"fs"!==e.ns)return e.term;const i=e.term.split("/"),r=i.findIndex(c.notBlank);if(-1===r)return e.term;const s=i[r];return i[r]=t.get(s)??s,i.join("/")}(t,i);if(r||s)return e.whereIn("Asset.id",(0,m.knex)()("AssetTag").join("Tag","Tag.id","AssetTag.tagId").select("assetId").whereLike("Tag._path",t.ns+(r?"":"%")+n.replace(/\//g,u.TagSep).replace(/\*/g,"%")+u.TagSep+(s?"":"%")));let a=(0,m.knex)()("AssetTag").join("tag_fts","tag_fts.rowid","AssetTag.tagId").select("assetId");const o="path:"+T(n.replace(/\//g," + "));if((0,c.blank)(t.ns)){if((0,d.isTrue)(t.not))throw new Error("Cannot negate without a namespace ("+(0,y.queryToString)(t)+")");a=a.where("tag_fts","MATCH",o)}else a=a.where("tag_fts","MATCH","(root:"+T(t.ns)+((0,d.isTrue)(t.not)?" NOT ":" AND ")+o+")");return e.whereIn("Asset.id",a)}(e,t,i)}(e,t,i);for(const r of t.queries)e=(0,y.isAndClause)(t)?e.andWhere((e=>S(e,r,i))):e.orWhere((e=>S(e,r,i)));return e}function P(e){const t=(0,d.isTrue)(e.term);return!0===e.not?!t:t}function _(e){return P(e)?1:0}function T(e){return e.includes("*")?e.split("*").map(T).join(" * "):`"${(0,f.toS)(e).replace(/"/g,'""')}"`}function M({qb:e,column:t,whereNull:i}){return i?e.whereNull(t):e.whereNotNull(t)}function E(){return p.Asset.ops().query().where("Asset.shown",1).join("AssetTag","AssetTag.assetId","Asset.id")}function k(e,t=E(),i){return e=(0,v.normalizeQuery)(e),(0,y.hasNsTerm)(e,v.AssetTermBoolNs.hidden)||(0,y.hasNsTerm)(e,v.AssetTermBoolNs.excluded)||(0,y.hasNsTerm)(e,v.AssetTermBoolNs.deleted)||(t=t.andWhere({"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null})),t.andWhere((t=>S(t,e,i)))}t.defaultAssetQuery=E,t.queryStringToSql_=function(e,t=E()){const i=(0,w.parseQuery_)(e);return null==i?(b().warn("assetQuery("+e+"): parsed to null"),t):k(i,t)},t.queryToSql=k},70471:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};function s(e){return e[0]}Object.defineProperty(t,"__esModule",{value:!0}),t.parseTerm=void 0;const n=r(i(80265)),a=i(40958),o=i(54993);function l(e){if(null==e[0]&&["and","or"].includes((0,o.toS)(e[1]).toLowerCase()))throw new Error("Unmatched "+e[1]);return{not:null!=e[0]?.[0]?.value,ns:e[0]?.[1]?.value,op:e[0]?.[3]?.value,term:e[1]}}function u(e){return e[0]?.value}t.parseTerm=l;const c=n.default.compile({qstr:[{match:/"(?:[^\\"]|\\.)*?"/,value:e=>e.slice(1,-1).replace(/\\"/g,'"')},{match:/'(?:[^\\']|\\.)*?'/,value:e=>e.slice(1,-1).replace(/\\'/g,"'")}],lp:"(",rp:")",not:/[-¬]/,col:":",op:/<=?|>=?|=/,or:/ +(?:or|OR|Or|∨|\|{1,2}) +/,and:/(?:and|AND|And|∧|\&{1,2}) +/,str:/[^\s:\(\)"'][^\s:\(\)]*/,ws:/ +/}),d={Lexer:c,ParserRules:[{name:"Expression$ebnf$1",symbols:[]},{name:"Expression$ebnf$1$subexpression$1",symbols:[c.has("or")?{type:"or"}:or,"Clause"]},{name:"Expression$ebnf$1",symbols:["Expression$ebnf$1","Expression$ebnf$1$subexpression$1"],postprocess:e=>e[0].concat([e[1]])},{name:"Expression",symbols:["Clause","Expression$ebnf$1"],postprocess:function(e){const t=(0,a.compact)([e[0],...e[1].map((e=>e[1]))]);return 1===t.length?t[0]:{type:"or",queries:t}}},{name:"Clause$ebnf$1",symbols:[]},{name:"Clause$ebnf$1$subexpression$1$ebnf$1",symbols:[c.has("and")?{type:"and"}:and],postprocess:s},{name:"Clause$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"Clause$ebnf$1$subexpression$1",symbols:["__","Clause$ebnf$1$subexpression$1$ebnf$1","Factor"]},{name:"Clause$ebnf$1",symbols:["Clause$ebnf$1","Clause$ebnf$1$subexpression$1"],postprocess:e=>e[0].concat([e[1]])},{name:"Clause",symbols:["Factor","Clause$ebnf$1"],postprocess:function(e){const t=(0,a.compact)([e[0],...e[1].map((e=>e[2]))]);return 1===t.length?t[0]:{type:"and",queries:t}}},{name:"Factor",symbols:["Term"],postprocess:s},{name:"Factor",symbols:[c.has("lp")?{type:"lp"}:lp,"_","Expression","_",c.has("rp")?{type:"rp"}:rp],postprocess:function(e){const t=(0,a.compact)(e[2]);return 1===t.length?t[0]:t}},{name:"Term$ebnf$1$subexpression$1$ebnf$1",symbols:[c.has("not")?{type:"not"}:not],postprocess:s},{name:"Term$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"Term$ebnf$1$subexpression$1$ebnf$2",symbols:[c.has("op")?{type:"op"}:op],postprocess:s},{name:"Term$ebnf$1$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"Term$ebnf$1$subexpression$1",symbols:["Term$ebnf$1$subexpression$1$ebnf$1",c.has("str")?{type:"str"}:str,c.has("col")?{type:"col"}:col,"Term$ebnf$1$subexpression$1$ebnf$2"]},{name:"Term$ebnf$1",symbols:["Term$ebnf$1$subexpression$1"],postprocess:s},{name:"Term$ebnf$1",symbols:[],postprocess:()=>null},{name:"Term",symbols:["Term$ebnf$1","Value"],postprocess:l},{name:"Value",symbols:[c.has("qstr")?{type:"qstr"}:qstr],postprocess:u},{name:"Value",symbols:[c.has("str")?{type:"str"}:str],postprocess:u},{name:"_$ebnf$1",symbols:[c.has("ws")?{type:"ws"}:ws],postprocess:s},{name:"_$ebnf$1",symbols:[],postprocess:()=>null},{name:"_",symbols:["_$ebnf$1"]},{name:"__",symbols:[c.has("ws")?{type:"ws"}:ws]}],ParserStart:"Expression"};t.default=d},22968:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeRebuildLibrary=t.forceRebuildLibraryLater=t.rebuildLibraryOperationCrit=void 0;const r=i(45393),s=i(28874),n=i(98553),a=i(43487),o=i(54017),l=i(20958),u=i(33567);function c(){return{name:l.OperationNames.rebuildLibrary,value:(0,n.stringify)({AssetVersion:r.AssetVersion,AssetFileVersion:r.AssetFileVersion})}}t.rebuildLibraryOperationCrit=c,t.forceRebuildLibraryLater=function(){a.Asset.dbl.runf((e=>e.update({version:0}))),o.AssetFile.dbl.runf((e=>e.update({version:0}))),l.Operation.dbl.runf((e=>e.where(c()).delete()))},t.maybeRebuildLibrary=async function(){return s.Settings.skipLibraryRebuild.valueOrDefault?void 0:l.Operation.applyOnce_(c(),(()=>(new u.LibraryRebuild).doneLatch))}},33567:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LibraryRebuild=void 0;const c=i(19851),d=i(83412),h=i(25764),f=i(8769),m=i(76752),p=i(28874),g=i(15674),y=i(22573),v=i(42659),w=i(31586),b=i(12168),S=i(12236),P=i(35580),_=i(49796),T=i(94710),M=i(18209);class E extends d.DoneWrapper{constructor(){super("LibraryRebuild",(()=>u(this,r,"m",a).call(this)),h.EndableRanks.first),r.add(this),this.assetFileEta=new m.ETA,this.assetEta=new m.ETA,this.assetFilesUpdated=0,this.assetsUpdated=0,this.initialAssetFileTodoCount=(0,c.lazy)(M.outdatedAssetFileCount),this.initialAssetTodoCount=(0,c.lazy)(M.outdatedAssetCount),s.set(this,(0,c.lazy)((()=>_.Progress.insertNew({uri:S.RebuildingURI,volume:"🔄",scanningPct:0})))),o.set(this,((e,t,i)=>{"updateAssetFile"===e.fn?(this.assetFilesUpdated++,this.assetFileEta.push(i),u(this,r,"m",n).call(this)):"updateAsset"===e.fn&&(this.assetsUpdated++,this.assetEta.push(i),u(this,r,"m",n).call(this))})),T.Task.ee.on("resolved",u(this,o,"f")),this.doneLatch.observe(u(this,r,"m",l).call(this))}async assetFileTodo(){return await this.initialAssetFileTodoCount()-this.assetFilesUpdated}async assetTodo(){return await this.initialAssetTodoCount()-this.assetsUpdated}}t.LibraryRebuild=E,s=new WeakMap,o=new WeakMap,r=new WeakSet,n=async function({force:e=!1,done:t=!1}={}){const i=u(this,s,"f").call(this);if(e||!(0,w.gt)(i.updatedAt,Date.now()-v.secondMs))if((t??this.isDone())&&"done"!==i.state){const e=[];this.assetFilesUpdated>0&&e.push(`Updated file metadata for ${(0,b.fmt)(this.assetFilesUpdated)} files`),this.assetsUpdated>0&&e.push(`Refreshed ${(0,b.fmt)(this.assetsUpdated)} assets`),i.dek=e,i.upsert({state:"done",hed:"Finished rebuilding your library 🎉",completePct:100,incompletePct:0,scanningPct:0})}else{let e="Rebuilding your library";const t=await this.assetFileTodo(),r=await this.assetTodo(),s=(this.assetFileEta.etaMs(t/(0,g.maxConcurrentImports)())??0)+(this.assetEta.etaMs(r)??0),n=[];t>0&&n.push(`Updating file metadata (${(0,b.fmt)(this.assetFilesUpdated)} processed, ${(0,b.fmt)(t)} remain)`),r>0&&n.push(`Refreshing assets and previews (${(0,b.fmt)(this.assetsUpdated)} processed, ${(0,b.fmt)(r)} remain)`);const a=t+r,o=this.assetFilesUpdated+this.assetsUpdated,l=(0,w.clamp)(0,100,Math.round(o/(a+o)*100)),u=(0,m.fmtEstimate)(s);(0,y.notBlank)(u)&&(e+=", "+u+"…"),i.dek=n,i.upsert({state:"processing",hed:e,completePct:l,incompletePct:100-l,scanningPct:0})}},a=function(){T.Task.ee.off("resolved",u(this,o,"f"))},l=async function(){this.logger.info("Starting library rebuild...");const e=p.Settings.forceFilters.getState();try{p.Settings.forceFilters.envValue=!0;const e=P.TaskList.instance(),t=await this.assetFileTodo(),i=await this.assetTodo();if(this.logger.info(".run()",{assetFileTodo:t,assetTodo:i}),0===t&&0===i)return;let s=!1;for(;!s;)s=(await(0,M.enqueueAssetFileUpdates)()).done,this.logger.info("run(): waiting for asset updates to complete..."),await e.awaitDrain(["updateAssetFile"],s?0:p.Settings.taskListCap.valueOrDefault/2);for(s=!1;!s;)s=(await(0,M.enqueueAssetUpdates)()).done,await e.awaitDrain(["repairAsset","assetPostUpsertTasks"],s?0:p.Settings.taskListCap.valueOrDefault/2);await u(this,r,"m",n).call(this,{done:!0,force:!0}),this.logger.info("rebuild complete!")}catch(e){(0,f.onError)("LibraryUpdater.run() failed",e)}finally{p.Settings.forceFilters.setState(e)}}},18209:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.enqueueAssetUpdates=t.outdatedAssetCount=t.enqueueAssetFileUpdates=t.outdatedAssetFileCount=t.currentUriRoots=void 0;const r=i(50213),s=i(45393),n=i(70417),a=i(45200),o=i(5696),l=i(7014),u=i(40958),c=i(45599),d=i(41400),h=i(20214),f=i(54993),m=i(43487),p=i(54017),g=i(94710),y=(0,c.defer)((()=>(0,r.mkLogger)("sync.UpdateQueue")));async function v(){return[...await(0,h.thenCollect)((0,l.volumes)(),(async e=>(0,a.nativePath2uri)(e.mountpoint,e))),o.PSLIB_ROOT_URI].map(f.toS)}t.currentUriRoots=v,t.outdatedAssetFileCount=async function(){const e=await v();return p.AssetFile.dbl.pluckFirstf((t=>t.count("AssetFile.id").distinct().where("version","!=",s.AssetFileVersion).andWhere((t=>e.forEach((e=>t.orWhereLike("AssetFile.uri",e+"%")))))))},t.enqueueAssetFileUpdates=async function(){const e=[];for(const t of await v())e.push(await p.AssetFile.dbl.batched({maxResults:g.Task.freeSlots(),onResults:async e=>{const t=[];for(const i of e)t.push({fn:"updateAssetFile",args:{assetFileId:i.id,path:await(0,a.uri2nativePath)(i.uri),skipAssetRepair:!0}});g.Task.add(t),y().info("Scheduled updateAssetFile",{tasks:t})},qb:(e,i)=>(e=e.select({id:"AssetFile.id",uri:"AssetFile.uri"}).distinct().orderBy("AssetFile.id","asc").where("AssetFile.version","!=",s.AssetFileVersion).andWhereLike("AssetFile.uri",t+"%"),(0,u.isNotEmpty)(i)&&(e=e.andWhere("AssetFile.id",">",(0,n.max)(i.map((e=>e.id))))),e)}));return y().tap({msg:"enqueueAssetFileUpdates",level:"info",result:{done:e.every((e=>e.done)),tasksAdded:(0,n.sumf)(e,(e=>e.resultCount))}})},t.outdatedAssetCount=async function(){const e=await v();return m.Asset.dbl.pluckFirstf((t=>t.count("Asset.id").distinct().leftJoin("AssetFile","AssetFile.assetId","Asset.id").where("Asset.version","!=",s.AssetVersion).andWhere((t=>e.forEach((e=>t.orWhereLike("AssetFile.uri",e+"%")))))))},t.enqueueAssetUpdates=async function(){const e=[];for(const t of await v())e.push(await m.Asset.dbl.pluckBatched({maxResults:g.Task.freeSlots(),onResults:e=>(g.Task.add(e.map((e=>({fn:"repairAsset",args:{assetId:e}})))),y().info("Scheduled repairAsset for ",{assetIds:e}),(0,d.delay)(1)),qb:(e,i)=>(e=e.select("Asset.id").distinct().leftJoin("AssetFile","AssetFile.assetId","Asset.id").orderBy("Asset.id","asc").where("Asset.version","!=",s.AssetVersion).andWhereLike("AssetFile.uri",t+"%"),(0,u.isNotEmpty)(i)&&(e=e.andWhere("Asset.id",">",(0,n.max)(i))),e)}));return y().tap({msg:"enqueueAssetUpdates",level:"info",result:{done:e.every((e=>e.done)),tasksAdded:(0,n.sumf)(e,(e=>e.resultCount))}})}},3996:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileFinder=t.isFileInSync=void 0;const o=i(19851),l=i(50213),u=i(79781),c=i(56519),d=i(56038),h=i(59189),f=i(38835),m=i(95696),p=i(48368),g=i(181),y=i(69589),v=i(28874),w=i(47783),b=i(87001),S=i(40958),P=i(76790),_=i(22573),T=i(42659),M=i(55835),E=i(31586),k=i(43487),D=i(54017);t.isFileInSync=async function(e){return new C(m.PosixFile.for(e)).alreadySynced()};const x=new h.SerialLaterQueue;class C{constructor(e,t=(0,y.forceContextOrSetting)()){this.file=e,this.ctx=t,r.set(this,void 0),s.set(this,new Set),this.alreadySynced=(0,d.timedLazy)("sync-file.AssetFileFinder.alreadySynced: "+this.file,(async()=>a(this,r,"f").tap({msg:"alreadySynced",result:null!=await this.priorIfSynced()}))),this.newAssetFile_=(0,d.timedLazy)("sync-file.AssetFileFinder.newAssetFile: "+this.file,(async()=>{const e=await(new D.AssetFile).updateFromFile_(this.file);return null==e?a(this,r,"f").throw("AssetFile.updateFromFile returned null",{fatal:!1}):e})),this.tags_=(0,o.lazy)((async()=>{const e=await(0,w.readTags)(this.file);if(null==e)throw new Error(this.file+" doesn't have metadata");return e})),this.imageHash=(0,o.lazy)((()=>v.Settings.useImageHashes.valueOrDefault?(0,p.imageHash)(this.file):void 0)),this.dominantLabhashes=(0,o.lazy)((()=>(0,c.thenMap)(this.imageHash(),(e=>(0,S.uniq)(e.dominantColors.filter((e=>e.pct>5)).map((e=>e.labhash))))))),this.capturedAtLocal=(0,o.lazy)((async()=>{const e=await this.capturedAt_();return a(this,r,"f").tap({msg:"capturedAtLocal",result:e?.local,meta:{capturedAt:e}})})),this.mapSibling=e=>this.newAssetFileForAsset(e?.getAsset()),this.apply_=(0,d.timedLazy)("sync-file.AssetFileFinder: "+this.file,(async()=>{if((0,_.blank)(await this.file.uri_()))throw new Error("Cannot import, file URI is blank for "+this.file);{const e=await this.byExistingAsset_();if(null!=e)return a(this,r,"f").info("Found existing asset for file"),e}const e=await this.newAssetFile_(),t=await x.enqueue((async()=>{const t=await this.byExistingAsset_();if(null!=t?.assetId)return a(this,r,"f").info("Found existing asset for file after acquiring lock",{withExistingAsset:t}),t.assetId;const i=new k.Asset;return i.capturedAtLocal=e.capturedAtLocal,i.addAssetFile(e),i.upsert(),i.id}));return e.assetId=t,e.upsert()})),this.byExistingAsset_=()=>(0,d.time)("sync-file.AssetFileFinder.byExistingAsset: "+this.file,(async()=>{const e=[{name:"byUri",f:()=>this.byUri()},{name:"byNormalizedPathUri",f:()=>this.newAssetFileForAsset(this.assetByNormalizedPathUri())},{name:"bySha",f:()=>this.newAssetFileForAsset(this.assetBySha())},{name:"hasTags",f:async()=>{await this.tags_()}},{name:"validFile",f:async()=>{await(0,g.throwIfInvalidFile_)(this.file)}},{name:"byCapturedAtOrImageHash",f:()=>this.newAssetFileForAsset(this.assetByCapturedAtOrImageHash())}];for(const{name:t,f:i}of e)try{const e=await(0,d.time)("sync-file.assetFileFinder."+t+": "+this.file,i);if(null!=e)return a(this,r,"f").info("apply(): "+t,{assetFileId:e.id,assetId:e.assetId}),e;a(this,r,"f").debug("apply(): "+t+": returned null")}catch(e){throw a(this,r,"f").debug("apply(): "+t+" rejected: "+e),e}})),n(this,r,(0,l.mkLogger)("sync-file.AssetFileFinder("+e.baseWithGrandparent+")"),"f")}async prior(){return this.byUri()}async priorIfSynced(){if(this.ctx.forceSync)return;const e=await this.prior();return!0===await(e?.matchesFile())?e:void 0}async newAssetFileForAsset(e){const t=await e;if(null!=t){if(null!=t.id){const e=await this.newAssetFile_();return t.addAssetFile(e),e.insert(),a(this,r,"f").debug("newAssetFileForAsset() upsert success!",{af:e}),e}a(this,r,"f").throw("newAssetFileForAsset(): given non-persisted Asset")}}async capturedAt_(){return(await this.tags_()).capturedAt}async byUri(e=this.file){const t=await e.uri_();if(null!=t)return D.AssetFile.ops().firstf((e=>e.whereIn("uri",[...(0,b.uriEncodingVariants)(t),this.file.fileuri()])));a(this,r,"f").warn("byUri() uri is null",{file:e})}async assetByNormalizedPathUri(){const e=await this.file.normalize();return e.nativePath===this.file.nativePath?void 0:(await this.byUri(e))?.getAsset()}assetBySha(){return(0,c.thenMap)(this.file.sha(),(e=>k.Asset.findFirstByFile((t=>t.where("AssetFile.sha",e)))))}async assetByCapturedAtOrImageHash(){const e=await this.capturedAt_();if(null==e)return a(this,r,"f").throw("Cannot import, capturedAt is null"+f.InternalErrorFlag);if(v.Settings.strictDeduping.valueOrDefault)return this.firstSimilarAsset(D.AssetFile.ops().allf((t=>t.where({capturedAtLocal:e.local}))));const t=v.Settings.maxContemporaryAdoptionAssets.valueOrDefault,i=()=>{let i=D.AssetFile.query();return(0,E.gt0)(t)&&(i=i.limit(t)),i.orderByRaw(`abs(capturedAtLocal - ${e.local})`)},s=Math.max(T.secondMs,v.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault);return(0,d.time)("sync-file.AssetFileFinder.assetByCapturedAtAndImageHash: "+this.file,(async()=>{{const t=e.localBoundaries({delta:s});if(null==t)a(this,r,"f").warn("Failed to fetch localBoundaries, cannot fetch similar assets by localtime",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("captured-at",i().whereBetween("capturedAtLocal",[t.start,t.end]))??(v.Settings.checkBasenameMatches.valueOrDefault?this.firstSimilarAssetByQuery("basename",i().whereILike("uri","%/"+this.file.name+"%")):void 0);if(null!=e)return e}}const t=await this.imageHash();if(null==t)return void a(this,r,"f").warn("assetByCapturedAtAndImageHash: no imageHash");const n=await this.dominantLabhashes();if((0,S.isNotEmpty)(n)){const t=e.localBoundaries({delta:4*s});if(null==t)a(this,r,"f").error("Failed to fetch localBoundaries, cannot fetch similar assets by wide localtime + image hash",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("wide captured-at and dominant color",i().whereBetween("capturedAtLocal",[t.start,t.end]).andWhere((e=>e.whereIn("mode0",n).orWhereIn("mode1",n).orWhereIn("mode2",n))));if(null!=e)return e}}return this.firstSimilarAssetByQuery("image hash",i().where("meanHash",t.meanHash).orWhere("diffHash",t.diffHash).orWhere("dctHash",t.dctHash))}))}async firstSimilarAssetByQuery(e,t){a(this,s,"f").size>0&&(t=t.whereNotIn("AssetFile.id",Array.from(a(this,s,"f"))));const i=await this.firstSimilarAsset(D.AssetFile.ops().all(t));return null!=i&&a(this,r,"f").info("Found similar asset by "+e,{result:i}),i}async firstSimilarAsset(e){const t=await this.newAssetFile_(),i=await this.capturedAtLocal();if(null==t)throw new Error("Failed to update from "+this.file);const n=(0,P.sortBy)(e.filter((e=>!a(this,s,"f").has(e.id))),(e=>[(0,M.mapOr)(i,(t=>Math.abs(e.capturedAtLocal-t)),-e.capturedAtLocal),e.id]));for(const e of n)if(null!=e){await e.getNativePath();const i=D.AssetFile.ops().findBy({assetId:e.assetId});await Promise.all(i.map((e=>e.getNativePath())));const n=(0,u.whyNotSameAsset)(t,e,i);if(null==n)return a(this,r,"f").info("Found sibling AssetFile",e),k.Asset.ops().findById(e.assetId);a(this,s,"f").add(e.id),a(this,r,"f").debug("Contemporary assetFile not similar: "+n,e?.uri)}}}t.AssetFileFinder=C,r=new WeakMap,s=new WeakMap},34274:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileImporter=t.importFileToResult_=void 0;const u=i(19851),c=i(50213),d=i(73568),h=i(38835),f=i(95696),m=i(62105),p=i(74128),g=i(181),y=i(69589),v=i(28874),w=i(40958),b=i(22573),S=i(38639),P=i(59455),_=i(64526),T=i(19113),M=i(94710),E=i(3996),k=i(90901);t.importFileToResult_=async function(e){const t=_.Library.instanceRequired_();return(0,p.syncReport)().wrap_({path:e.path,from:"AssetFileImporter",fn_:()=>new D(f.PosixFile.for(e.path),t.assetFileRepository(),e).apply_()})};class D{constructor(e,t,i){r.add(this),this.file=e,this.repo=t,this.start=Date.now(),s.set(this,void 0),n.set(this,void 0),this.whyRejected=(0,u.lazy)((async()=>{const e=[],t=await this.file.uri_();if(null==t)e.push("Cannot make URI"+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);else{if(!0===await this.file.isDeletedUri(t))e.push("File was deleted");else if(this.ctx.forceFilters||null==await this.prior()){const t=await(0,m.whyRejectFile)(this.file,(0,T.libraryFileFiltersFor)(this.file));null!=t&&e.push(t)}l(this,s,"f").throwIfAborted_();const i=await this.prior();if((0,w.isNotEmpty)(e)&&null!=i&&(l(this,s,"f").info("Deleting prior AssetFile",{rejected:e,prior:i}),i.delete(),this.ctx.skipAssetRepair?l(this,s,"f").info("Skipping asset repair",{assetId:i.assetId}):(l(this,s,"f").info("Scheduling asset repair",{assetId:i.assetId}),M.Task.addOne("repairAsset",{assetId:i.assetId,forceRebuildPreviews:(0,S.isTrue)(i.shown)}))),null!=i){const t=i.getAsset();null!=t?.deletedAt&&e.push("Asset is marked as deleted"),null!=t?.excludedAt&&e.push("Asset is marked as excluded")}if(l(this,s,"f").throwIfAborted_(),0===e.length&&(null==i||!await i.inSyncWithFile())){const t=await(0,g.whyInvalidFile)(this.file.nativePath);(0,b.blank)(t)||e.push(t)}}return e})),this.assetFile_=(0,u.lazy)((async()=>{const e=await l(this,n,"f").apply_(),t=e.getAsset();return l(this,s,"f").info("assetFileFinder.apply_() result",{asset:t,assetFile:e}),null==t?l(this,s,"f").throw("assetFile.getAsset() was null",{srcAssetFile:e}):null==t.id?l(this,s,"f").throw("repoAssetFile asset has null id",{asset:t}):e})),this.prior=(0,u.lazy)((()=>l(this,n,"f").prior())),this.apply_=(0,u.lazy)((()=>l(this,r,"m",a).call(this))),this.ctx=(0,y.forceContextOrSetting)(i),o(this,s,(0,c.mkLogger)("sync-file."+this.toString()),"f"),o(this,n,new E.AssetFileFinder(e,this.ctx),"f")}toString(){return"AssetFileImporter("+this.file.nativePath+")"}newAssetFile(){return l(this,n,"f").newAssetFile_()}}t.AssetFileImporter=D,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(){l(this,s,"f").throwIfAborted_();const e=await l(this,s,"f").tapAsync_({msg:"whyRejected",result:this.whyRejected(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if((0,w.isNotEmpty)(e)){const t=e.join(", ");return{path:this.file.nativePath,state:p.SyncFileStates.rejected,details:t}}l(this,s,"f").throwIfAborted_();const t=await l(this,s,"f").tapAsync_({msg:"prior()",result:this.prior(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if(null!=t&&await t.isNoop(this.ctx))return{path:this.file.nativePath,state:p.AssetFileSyncStates.noop,assetId:t.assetId,assetFileId:t.id,assetFile:t,asset:t.getAsset(),uri:t.uri};l(this,s,"f").throwIfAborted_();const i=await l(this,s,"f").tapAsync_({msg:"assetFile()",result:this.assetFile_(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if(null==i)return l(this,s,"f").throw("_apply(): unexpected null assetFile");const r=i.id;if(null==r)return l(this,s,"f").throw("_apply(): unexpected null assetFileId");const n=i.uri;if(null==n)return l(this,s,"f").throw("_apply(): unexpected null assetFile.uri");const a=i.getAsset();if(null==a)return l(this,s,"f").throw("_apply(): unexpected null assetFile.getAsset()");let o;await l(this,s,"f").tapAsync_({msg:"assetFile.upsertIfNeeded_()",result:i.upsertIfNeeded_(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault}),l(this,s,"f").throwIfAborted_();try{o=await(0,k.assetPostUpsertTasks_)({asset:a,...this.ctx})}catch(e){e instanceof d.AbortError?l(this,s,"f").warn("aborted (caller/process after me will complete)",{error:e}):l(this,s,"f").throw("Post-upsert tasks failed",{error:e})}return{path:this.file.nativePath,state:i.syncState??p.SyncFileStates.synced,assetId:a.id,assetFileId:r,assetFile:i,asset:a,uri:n,uris:[n,...(0,P.toA)(o?.newAssetFileUris)]}}},41844:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileRepository=t.mayCopyAssetsToLibrary=void 0;const u=i(50213),c=i(74128),d=i(81674),h=i(57902),f=i(4936),m=i(28874),p=i(47783),g=i(67083),y=i(16170),v=i(54979),w=i(98604),b=i(40958),S=i(22573),P=i(98553),_=i(89937),T=i(59455),M=i(54017),E=i(94710);t.mayCopyAssetsToLibrary=async function(){return m.Settings.copyAssetsToLibrary.valueOrDefault&&await(0,d.p)()},t.AssetFileRepository=class{constructor(e){r.add(this),this.originalsDir=e,this.logger=(0,u.mkLogger)("AssetFileRepository")}async shouldCopy(e){const t=await this.whyNotCopyFile(e);return this.logger.tap({level:"info",msg:"shouldCopy()",result:null==t,meta:{file:e?.nativePath,whyNot:t}})}async whyNotCopyFile(e){if(null==e||(0,S.blank)(e.nativePath))return"blank nativePath";if(!0!==m.Settings.copyAssetsToLibrary.value)return"copyAssetsToLibrary !== true";if(await(0,d.l)())return"no active subscription";if(await e.notExists({refresh:!0}))return"file doesn't exist";if(e.isDescendantOf(this.originalsDir))return e+" already contained by "+this.originalsDir;if(e.isDescendantOf(m.Settings.libraryDir.valueOrDefault))return e+" already contained by "+m.Settings.libraryDir.valueOrDefault;const t=await(0,v.readMimeType)(e);return null==t?"readMimeType("+e+") was null":(0,y.isMimeTypeIncluded)(t,m.Settings.copyToLibraryMimeTypes.values)?null:"mimetype "+t+" is not included in copyToLibraryMimeTypes"}async existingLibraryAssetFile(e){if(e.uri.startsWith(_.PS_LIBRARY_PROTOCOL))return e;const t=(0,b.uniqBy)((0,T.toA)(e.librarySiblings()?.filter((t=>t.sha===e.sha))).concat(M.AssetFile.sameAssetFileInLibrary(e)),(e=>e.id));for(const i of t)if(await i.exists()){if(i.assetId!==e.assetId){this.logger.warn("Existing library asset file with a matching SHA is associated to a different asset. Requesting repair of the two impacted assets.",{af:e,prior:i});const t=i.assetId;e.getAsset()?.addAssetFile(i),E.Task.addOne("repairAsset",{assetId:t,forceSync:!0})}return this.logger.info("whyNotCopyAssetFile("+e.uri+"): found existing db record",{af:e,prior:i}),i}return null}async findLibraryFileWithSameContents(e,t){if(await e.matchesContent(t))return t;let i=t.parent();for(;i.isSelfOrDescendantOf(this.originalsDir);){const t=i.childWithSameContents(e);if(null!=t)return t;i=i.parent()}}async importFile_(e){const t=await l(this,r,"m",s).call(this,e);return null!=t&&(await l(this,r,"m",n).call(this,e,t),await l(this,r,"m",o).call(this,e,t)),t}async maybeCopyToLibrary_(e,t){const i=Date.now(),s=await e.posixFile_();null==s&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): posixFile is null",{ignorable:!1,retriable:!1});{const e=await this.whyNotCopyFile(s);if(!(0,S.blank)(e))return this.logger.tap({level:h.LogLevels.info,msg:"maybeCopyToLibrary_(): not copying: "+e,result:void 0})}const a=e.getAsset();null==a&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): null asset");{const u=await this.existingLibraryAssetFile(e);if(null!=u){const e=await u.posixFile_();if(null!=e){const d=await l(this,r,"m",n).call(this,s,e),h=null!=await l(this,r,"m",o).call(this,s,e),f=null!=await u.upsertIfNeeded_(void 0,t);return!h&&(0,b.isEmpty)(d)&&!f||(0,c.syncReport)().onProgress({path:e.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.synced,details:"Found and synced prior replica already in your library "+(0,P.stringify)({src:s.nativePath,upsertNeeded:f,copiedSidecars:d,copiedInferredMetadata:h}),elapsedMs:Date.now()-i,url:(0,w.mkAssetUrl)(a.id)?.toString()}),u}this.logger.warn("existingLibraryAssetFile() returned an assetFile that could not be resolved to a PosixFile",{prior:u})}}const u=await this.importFile_(s);if(null==u)return void this.logger.info("importFile() returned null",{srcAssetFile:e});if(u.nativePath===s.nativePath)return void this.logger.info("importFile() returned the same nativePath as src",{srcAssetFile:e,dest:u});const d=await a.assetFileForFile_(u,{skipUpsert:!0});await d.updateFromShaSibling_(e);const f=d.upsert();return a.addAssetFile(d),(0,c.syncReport)().onProgress({path:u.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.copied,details:"Copied into your library from "+s.nativePath,elapsedMs:Date.now()-i,url:(0,w.mkAssetUrl)(a.id)?.toString()}),f}},r=new WeakSet,s=async function(e){const t=await(0,p.readCapturedAt)(e),i=(0,f.pathToLibraryAsset)(t?.date,e);if(this.logger.debug("importFile("+e+")",{capturedAt:t,assetPath:i}),null==i)throw new Error(e.nativePath+" failed to create a library path");const r=this.originalsDir.join(...i),s=await this.findLibraryFileWithSameContents(e,r);if(null!=s)return this.logger.debug("#importFile_("+e+"): found existing file",{src:e,existing:s}),s;const n=await r.ensureNew_();return this.logger.info("#importFile_("+e+"): copying...",{uniqDest:n,dest:r}),e.copyFile_(n)},n=async function(e,t){const i=await e.existingSidecars(),s=[];for(const e of i)s.push(await l(this,r,"m",a).call(this,e,t));return(0,b.compact)(s)},a=async function(e,t){for(const i of await t.existingSidecars())if(await(0,p.sidecarEql)(e,i))return void this.logger.info("handleSidecar(): metadata already exists.",{srcSidecar:e,destSidecar:i,dest:t});const i=await t.parent().join(t.name+e.ext).ensureNew_({emptyIsNew:!0});return e.copyFile_(i)},o=async function(e,t){if(null==e||null==t||e.eql(t))return;const i=await(0,p.readTags)(e);if(null!=i)return(0,g.ensureInferredHistoryRecords)(e,await t.sidecar(),i.inferred);this.logger.warn("#handleInferred(): Failed to read tags from "+e,{dest:t})}},90901:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetPostUpsertTasks_=t.assetPostUpsertTasks=void 0;const r=i(50213),s=i(92434),n=i(73568),a=i(99331),o=i(39250),l=i(38835),u=i(57159),c=i(48604),d=i(66106),h=i(69589),f=i(40958),m=i(45599),p=i(23838),g=i(31586),y=i(64526),v=i(88224),w=i(43487),b=i(41844),S=i(68640),P=(0,m.defer)((()=>(0,r.mkLogger)("sync-file.AssetPostUpsertTasks"))),_=(0,m.defer)((()=>new o.LastOneInWins("Asset tasks")));async function T(e){const t=e,i=e,r=(0,g.toGt0)(t.asset?.id)??(0,g.toGt0)(i.assetId);if(null==r)throw new Error("assetPostUpsertTasks_(): unexpected null assetId"+l.InternalErrorFlag);const o=(0,h.forceContextOrSetting)(e),m=P().addContext(`.postUpsertAssetTasks_(Asset:${r})`);if(m.abortable=o.halt,o.skipPreviews&&o.skipAssetTagging)return void m.info("skipped (skipPreviews && skipAssetTagging)");const T=t.asset??w.Asset.ops().findById(r);if(null==T)return m.throw("unexpected null asset",{asset:T});try{return await _().enqueue({key:r,abortable:m.abortable,fn:()=>async function(e,t,i){const r=(0,h.forceContextOrSetting)(i),n=t.id,a=t.getAssetFiles({refresh:!0}),o={newAssetFileUris:[],previewsUpdated:!1,tagResult:void 0,transcoded:!1};if(e.throwIfAborted_(),(0,f.isEmpty)(a)&&(await w.Asset.remove({assetId:n,blocklistShas:!1,unlinkAssetFiles:!1}),e.throw(`Asset:${n} had no asset files. Deleted.`)),await(0,b.mayCopyAssetsToLibrary)())for(const[t,i]of(0,p.groupBy)(a,(e=>e.sha)).entries()){e.throwIfAborted_();try{for(const r of i)r.isInLibrary()&&await r.exists()&&e.debug("no-op for file SHA: already in library.",{sha:t,uri:r.uri});for(const e of i)if(await e.exists()){const t=await y.Library.instanceRequired_().assetFileRepository().maybeCopyToLibrary_(e,r);if(null!=t){o.newAssetFileUris.push(t.uri);continue}}}catch(r){e.warn("Failed to copy variation to library, but we'll try to continue",{sha:t,uris:i.map((e=>e.uri)),error:r})}}e.throwIfAborted_();const l=r.skipPreviews?void 0:await(0,S.updateAssetPreviews_)({asset:t,assetFiles:t.getAssetFiles(),...r}),u=await async function(e,t){if((0,g.gt0)(t?.assetFileId)){const i=e.getAssetFiles({refresh:!0}).find((e=>e.id===t?.assetFileId));return null==i?P().throw("AssetPreviewInfo referenced unknown assetFileId",{asset:e,info:t}):i}const i=e.getShown();return null!=i?i:(0,s.bestExistingAssetFile)(e.getAssetFiles())}(t,l);if(null==u)return e.throw("null primaryOrShownAssetFile_()",{asset:t});const m=await u.posixFile_();if(!0!==r.skipPreviews&&t.isVideo()){if(null==m)return e.throw("null primary.posixFile()",{asset:t,assetFiles:t.getAssetFiles()});o.transcoded=null!=await(0,d.transcode_)(m,c.Previews.instance().ap(n).mp4(),{force:r.forceRebuildPreviews,halt:r.halt})}return e.throwIfAborted_(),t.markShownAndUpsert_(u),r.skipAssetTagging?e.info("skipping asset tagging"):o.tagResult=await(0,v.tagAndUpsertAsset_)(t),o}(m,T,{...e,...o})})}catch(e){if(e instanceof n.AbortError)return void m.warn("aborted, next caller will clean up my mess",{error:e});const t=[e];if(!(0,a.ending)()){m.error("failed, marking asset unshown",{error:e});try{T.markUnshownAndUpsert()}catch(e){m.error("failed to mark asset unshown",{upsertError:e}),t.push(e)}}throw new u.WrappedError("Failed to post-process assset "+T.id,{causes:t})}}t.assetPostUpsertTasks=function(e){try{return T(e)}catch(e){if(e instanceof n.AbortError)return void P().warn("aborted, next caller will clean up my mess",{error:e});throw e}},t.assetPostUpsertTasks_=T},61989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAsset_=t.updateAsset=void 0;const r=i(48884),s=i(50213),n=i(45393),a=i(79184),o=i(79781),l=i(92434),u=i(56519),c=i(70417),d=i(69589),h=i(28874),f=i(40958),m=i(22573),p=i(38639),g=i(50357),y=i(43487),v=i(54017),w=i(90901);async function b(e){const t=(0,d.forceContextOrSetting)(e),i=e.assetId,r=(0,s.mkLogger)(`sync-file.UpdateAsset(${i})`);r.abortable=t.halt;const b=y.Asset.ops().findById(i);if(null==b)return r.throw("no such asset");const P=b.getAssetFiles({refresh:!0});if((0,f.isEmpty)(P))return r.warn("No asset files: deleting."),b.delete(),{asset:b,rejected:"Empty asset (no AssetFiles)"};const _=b.$clone(),T=b.getShown()?.$clone();for(const e of P)r.throwIfAborted_(),await e.upsertIfNeeded_(void 0,t);P.some((e=>(0,p.isTrue)(e.deleted)||(0,m.notBlank)(e.rejected)))&&b.clear(),await S(r,P);const M=(0,l.sortAssetFiles)(P),E=M?.[0];if((0,f.isEmpty)(M)||null==E)return r.warn("No existing files. Skipping for now."),b.markUnshownAndUpsert(),{asset:b,rejected:"Empty asset (no AssetFiles after sorting). Un-showing Asset:"+i};if(!E.isVersionUpToDate())return r.warn("Best file needs update, and we already tried to update all files. Skipping this asset.",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, could not be updated. Un-showing Asset:${i}`};const k=await E.capturedAt();if(null==k)return r.warn("Best file failed to extract a captured-at",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, failed to extract a captured-at. Un-showing Asset:${i}`};const D=new Set,[x,C]=await(0,u.partitionAsync)(M,(e=>(0,o.isSimilarAssetFile)(e,E)));if(r.throwIfAborted_(),(0,f.isNotEmpty)(C)){const e=await(0,a.aggregateAssetFiles)(C);for(const t of e){if((0,f.isEmpty)(t))continue;const e=y.Asset.ops().insertOne({capturedAtLocal:t[0].capturedAtLocal,shown:!1,version:0});D.add(e.id);for(const i of t)e.addAssetFile(i);v.AssetFile.dbl.runf((i=>i.update({assetId:e.id,shown:0}).whereIn("id",(0,f.compact)(t.map((e=>e.id)))))),r.info("Pushed rejected asset files into new asset",{rejectAssetId:e.id,rejectCluster:t.map((e=>({id:e.id,uri:e.uri})))})}}function F(e){return(0,f.uniq)(x.map((t=>t[e])))}const A=await Promise.all(x.map((e=>e.capturedAt()))),I=h.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,O=A.map((e=>e?.localBoundaries({delta:I}))),L=(0,c.min)(O.map((e=>e?.start)))??k.localBoundaries({delta:I})?.start,R=(0,c.max)(O.map((e=>e?.end)))??k.localBoundaries({delta:I})?.end,N=v.AssetFile.ops().all(v.AssetFile.query().limit(h.Settings.maxContemporaryAdoptionAssets.valueOrDefault).orderByRaw(`abs(AssetFile.capturedAtLocal - ${E.capturedAtLocal})`).select("AssetFile.*").distinct().join("Asset","Asset.id","AssetFile.assetId").where("AssetFile.assetId","!=",i).andWhere("Asset.version","!=",n.AssetVersion).andWhere((e=>(e=e.whereIn("AssetFile.sha",F("sha")),null==L||null==R?r.warn("external asset file check: unset start or end localtime boundary",{capturedAts:A,startBoundary:L,endBoundary:R}):e=e.orWhereBetween("AssetFile.capturedAtLocal",[L,R]),e.orWhereIn("AssetFile.meanHash",F("meanHash")).orWhereIn("AssetFile.diffHash",F("diffHash")).orWhereIn("AssetFile.dctHash",F("dctHash"))))));r.throwIfAborted_(),r.info("asset file candidates for adoption: ",N.map((e=>e.posixPathFromGrandparent)));const B=[];for(const e of N){r.throwIfAborted_();try{await e.updateFromFile_(),(0,o.isSimilarAssetFile)(e,E)&&(r.info("adopting similar asset file",{af:e}),D.add(e.assetId),e.shown=!1,b.addAssetFile(e),e.upsert(),B.push(e))}catch(t){r.warn("Error updating external asset file. Leaving asset file record as-is.",{af:e,error:t})}}r.info("fetched expansion",{retainAFs:x.map((e=>e.id)),rejectAFs:C.map((e=>e.id)),externalAssetFiles:N.map((e=>e.posixPathFromGrandparent)),similarAssetFiles:B.map((e=>e.posixPathFromGrandparent))}),await S(r,[...x,...B]),t.skipPreviews&&t.skipAssetTagging?(r.info("skipping previews and tagging",t),b.upsert()):await(0,w.assetPostUpsertTasks_)({...t,asset:b});const j=!(0,g.eql)(_,b),z=!(0,g.eql)(T,b.getShown()),V=!(j||z||t.forceRebuildPreviews||t.forceSync);return r.tap({msg:"updateAsset() result",level:"info",result:{asset:b,assetIdsToUpdate:Array.from(D),assetFiles:b.assetFiles,skipped:V},meta:{ctx:t,assetChanged:j,primaryAssetFileChanged:z}})}async function S(e,t){const[i,s]=(0,r.partition)(t,(e=>e.isVersionUpToDate()));for(const t of s){e.throwIfAborted_();const r=i.find((e=>e.sha===t.sha));if(null!=r){e.info("backfilling",{sibling:r,dest:t});const i=await t.updateFromShaSibling_(r);null!=i&&i.upsert()}}}t.updateAsset=async function(e){try{const t=await b(e);return{id:e.assetId,skipped:null==t?.asset,...t}}catch(t){return{id:e.assetId,error:t}}},t.updateAsset_=b},93755:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetFileIfNeeded=t.handleAssetFileUriChange=t.updateAssetFile_=t.updateAssetFile=void 0;const r=i(50213),s=i(92434),n=i(98314),a=i(74128),o=i(69589),l=i(87001),u=i(40958),c=i(22573),d=i(68708),h=i(43487),f=i(54017),m=i(94710);async function p(e){const t=Date.now(),i=e,s=e,n=s.af?.id??i.assetFileId,u=(0,r.mkLogger)(`updateAssetFile(${n})`),d=s.af??f.AssetFile.ops().findById(n);if(null==d)return u.throw("db record not found",{assetFileId:n});const h=await d.posixFile_(),p=(0,o.forceContextOrSetting)(e),v={id:n,assetFileId:n,path:h?.nativePath,uri:d?.uri};if(null==h)return{...v,error:"file for URI not found"};const w=await(h?.isDeletedUri(d.uri));if(null==w)return u.info("no-op: file URI points to an unmounted volume",v),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:"volume is not currently mounted",state:a.SyncFileStates.skipped}),{...v,skipped:!0};const b=e.whyReject??await d.whyRejected();if(w||!(0,c.blank)(b)){const e={...v,rejected:b,deleted:w};return u.warn("file was deleted or rejected. Deleting.",e),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:w?"file no longer exists":"rejected: "+b,state:a.SyncFileStates.deleted}),d.delete(),!0!==p.skipAssetRepair&&m.Task.addOne("repairAsset",{assetId:d.assetId}),e}const S=await h.uri_();if(!await(0,l.uriIsEquivalent)(S,d.uri)){const e=await g(d,S,p);if(null!=e)return{...v,...e}}return!p.forceSync&&await d.matchesFile()?(u.info("no-op: file already matches db record",v),d.touch(),{...v,skipped:!0}):{...v,...await y(d,p)}}async function g(e,t,i){const n=(0,r.mkLogger)(`handleAssetFileUriChange(${e.id})`),a=(0,u.uniq)([...(0,l.uriEncodingVariants)(e.uri),...(0,l.uriEncodingVariants)(t)]);n.warn("URI is changing. Avoiding duplicate keys.",{priorUri:e.uri,variants:a});const o=f.AssetFile.ops().allf((t=>t.whereIn("uri",a).andWhereNot({id:e.id})));if((0,u.isNotEmpty)(o)){n.warn("Found other AssetFiles with equivalent URIs.",{afIds:o.map((e=>e.id))});const t=[e,...o],r=(0,s.sortAssetFiles)(t);if((0,u.isEmpty)(r))return n.warn("sortAssetFiles returned undefined",{arr:t.map((e=>(0,d.pick)(e,"id","uri"))),variants:a}),{error:"sortAssetFiles returned undefined"};const l=t.map((e=>e.id));for(const e of r)if(await e.exists()){f.AssetFile.dbl.runf((t=>t.whereIn("id",l.filter((t=>t!==e.id))).delete()));const r=y(e,i);return h.Asset.dbl.runf((e=>e.update({version:0,updatedAt:Date.now()}).whereIn("id",(0,u.uniq)(t.map((e=>e.assetId)))))),r}}n.info("no-op, no duplicate URIs.")}async function y(e,t){const i=Date.now();return null!=await e.upsertIfNeeded_(void 0,t)&&h.Asset.touch([e.assetId]),(0,a.syncReport)().onProgress({path:await e.getNativePath(),elapsedMs:Date.now()-i,from:"updateAssetFileIfNeeded()",state:e.syncState??a.SyncFileStates.unknown}),{assetFileId:e.id}}t.updateAssetFile=async function(e){try{return await p(e)}catch(t){return{id:e.assetFileId,...e,error:(0,n.errorToS)(t)}}},t.updateAssetFile_=p,t.handleAssetFileUriChange=g,t.updateAssetFileIfNeeded=y},68640:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetPreviews_=void 0;const r=i(99331),s=i(38835),n=i(48604),a=i(50213),o=i(69589),l=i(87001),u=i(40958),c=i(45599),d=i(50357),h=i(31586),f=i(68708),m=i(59455),p=i(43487),g=(0,c.defer)((()=>(0,a.mkLogger)("sync-file.UpdateAssetPreviews")));t.updateAssetPreviews_=async function(e){const t=e.assetId??e.asset?.id??(0,m.toA)(e.assetFiles).find((e=>(0,h.gt0)(e.assetId)))?.assetId,i=(0,o.forceContextOrSetting)(e),a=g().addContext(".Asset:"+t);if(i.skipPreviews)return void a.warn("skipPreviews is true: no-op");if(!(0,h.gt0)(t))return a.throw("invalid assetId",{assetId:t});const c=e.asset??p.Asset.ops().findById(t);if(null==c)return a.throw("Asset:"+t+" not found");a.throwIfAborted_(i.halt);try{const e=await c.getExistingAssetFiles();if((0,u.isEmpty)(e))return void a.warn("no existing assetFiles",{asset:c});const r=n.Previews.instance().ap(t),o=await r.readInfo();a.throwIfAborted_(i.halt);const h=await(0,n.buildAssetPreviews_)({...i,assetId:t,assetFiles:e}),m=e.find((e=>e.id===h?.assetFileId))??e.find((e=>(0,l.uriIsEquivalent)(h?.uri,e.uri)));a.info("buildAssetPreviews_()",{result:h,primaryAssetFile:m});const p=await(m?.posixFile_());if(null==m||null==p||!0!==await(p?.exists()))return a.throw("buildAssetPreviews_() returned invalid assetFileId"+s.InternalErrorFlag,{newInfo:h,assetFiles:e.map((e=>(0,f.pick)(e,"id","uri"))),primaryAssetFile:m,primaryPosixFile:p});const g=(0,d.eql)(o,h),y=null==h||g;return{...h,noop:y}}catch(e){throw(0,r.ending)()||(a.warn("Failed to update previews. Un-showing asset "+t,{error:e}),c.markUnshownAndUpsert()),e}}},94019:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathsToSync=t.scanPaths=t.logger=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(87290),o=i(34102),l=i(16287),u=i(45969),c=i(43334),d=i(28874),h=i(45200),f=i(69375),m=i(7014),p=i(41400),g=i(31586),y=i(92244),v=i(46832);t.logger=(0,r.lazy)((()=>(0,s.mkLogger)("sync.PathsToSync")));const w=(0,r.lazy)((async()=>{const e=[];for(const t of await(0,m.volumes)()){if(!0===t.ignorable||!1===t.ok||(c.isMac||(0,u.isDocker)())&&"/"===t.mountpoint||(0,f.isExcludedMountpoint)(t.mountpoint)||!(0,g.gt0)(t.size))continue;const i=await(0,v.toUriPath)(t.mountpoint,(0,h.nativePath2uri)(t.mountpoint,t));null!=i&&e.push(i)}return e}));async function b(){const e=[],i=[],r=d.Settings.argvScanPaths.toNotEmpty()??d.Settings.scanPaths.values;for(const s of r)if(await(0,l.isReadableDirectory)(s)){const r=await(0,v.toUriPath)(s);null==r?(e.push(s),(0,t.logger)().warn("Ignoring scanPath element: failed to create URI path",s)):i.push(r)}else(0,t.logger)().warn("Ignoring scanPath element: not readable directory",s);return{result:i,noUriPaths:e}}t.scanPaths=b,(0,p.later)((()=>{(0,o.ee)().on("volumesChanged",(()=>{w.unset()}))})),t.pathsToSync=async function(){const e=[];if(d.Settings.argvScanPaths.isNotEmpty()){for(const i of d.Settings.argvScanPaths.values){const r=await(0,v.toUriPath)(i);null!=r?e.push(r):(0,t.logger)().warn("pathsToSync(): Ignoring scanPath element: failed to create URI path",i)}return e}e.push(...(await b()).result),!0===d.Settings.scanAllDrives.value&&e.push(...await w());const i=await(0,n.thenMapOr)((0,a.libraryOriginalsDirPosixFile)(),v.posixFileToUriPath,(()=>(0,t.logger)().throw("libraryOriginalsDir was null",{libraryDir:d.Settings.libraryDir.valueOrDefault,originalsDir:d.Settings.originalsDir.value})));d.Settings.scanLibraryFirst.valueOrDefault&&e.unshift(i),d.Settings.scanLibraryLast.valueOrDefault&&e.push(i);const r=await(0,n.filterAsync)({name:"pathsToSync",arr:e,f:e=>!y.nativePathBlocklist.has(e.nativePath)&&(0,l.isReadableDirectory)(e.nativePath)});return(0,t.logger)().info("pathsToSync",r),r}},98622:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runTimeIsStale=t.SyncCron=void 0;const r=i(28874),s=i(41400),n=i(30301),a=i(31586);t.SyncCron=(0,n.lazy)((()=>r.Settings.syncCron.cron({timezone:r.Settings.syncCronTZ.value}))),(0,s.later)((()=>{r.Settings.syncCron.watchLater((()=>t.SyncCron.unset())),r.Settings.syncCronTZ.watchLater((()=>t.SyncCron.unset()))})),t.runTimeIsStale=function(e){return null==e||(0,a.lte)((0,t.SyncCron)().nextRun(new Date(e))?.getTime(),Date.now())}},92244:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syncPathsForUI=t.bestStable=t.isStale=t.bestPathToSync=t.stalePathsToSync=t.pathsAndTimesToSync=t.nativePathBlocklist=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(23560),o=i(22277),l=i(87290),u=i(57902),c=i(28874),d=i(40958),h=i(76790),f=i(42659),m=i(75240),p=i(31586),g=i(20958),y=i(49796),v=i(94019),w=i(98622),b=(0,s.lazy)((()=>(0,n.mkLogger)("sync.SyncPaths")));t.nativePathBlocklist=new o.TTLSet(10*f.minuteMs);const S=10*f.minuteMs;async function P(){const e=await(0,v.pathsToSync)(),t=c.Settings.forceSync.valueOrDefault?[]:await y.Progress.times();return b().tap({msg:"pathsAndTimesToSync()",level:u.LogLevels.info,result:e.map((e=>({...e,...t.find((t=>t.uri===e.uri))})))})}function _(e,t){return null==e.lastStartedAt||null==e.lastCompletedAt||(0,p.lte)(e.lastStartedAt,t)||(0,w.runTimeIsStale)(e.lastCompletedAt)}function T(){return g.Operation.getFirstPendingOp({name:g.OperationNames.forceRestartSync})}async function M(e){const t=T(),i=t?.createdAt,s=e.filter((e=>_(e,i)));if((0,d.isEmpty)(s))return(0,a.isSyncService)()&&t?.markCompleted(),b().tap({msg:"bestStable(): No stale paths to sync!",level:"info",result:void 0,meta:{arr:e,forceRestartOp:t}});{const e=(0,r.greatestBy)(s,(e=>e.lastUpdatedAt));if(null!=e&&(0,p.gt)(e.lastUpdatedAt,Date.now()-10*f.minuteMs))return b().tap({msg:"bestStable(): returning most recently updated",level:"info",result:{...e,why:"recently updated"}})}const n=(0,r.leastBy)(s,(e=>[e.lastStartedAt??0,e.lastCompletedAt??0]));return b().tap({msg:"bestStable(): returning least-recently-started or least-recently-completed:",level:"info",result:null==n?void 0:{...n,why:"least recently started or completed"},meta:{stale:s}})}function E(e,t){return null==e.lastStartedAt?"new":null==e.lastCompletedAt?"todo":(0,p.gt)(e.lastUpdatedAt,Date.now()-f.minuteMs)?"syncing":_(e,t)?"stale":"synced"}function k(e){return null==e?void 0:new Date(e).toISOString()}function D(e){if(null==e)return;const t=Date.now()-e;return t<2*f.secondMs?"just now":(0,m.fmtDuration)(t)+" ago"}t.pathsAndTimesToSync=P,t.stalePathsToSync=async function(){const e=await P(),t=T(),i=t?.createdAt,r=e.filter((e=>_(e,i)));return(0,h.sortBy)(r,(e=>[null!=e.lastUpdatedAt&&Date.now()-Se.nativePath)),t=await M(e),i=(0,l.libraryOriginalsDirPosixFile)()?.nativePath,r=T()?.createdAt;return e.map((e=>({path:e.nativePath,library:i===e.nativePath,status:E(e,r),isNext:e.nativePath===t?.nativePath,lastStartedISO:k(e.lastStartedAt),lastStarted:D(e.lastStartedAt),lastCompletedISO:k(e.lastCompletedAt),lastCompleted:D(e.lastCompletedAt)})))}},46832:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.posixFileToUriPath=t.toUriPath=void 0;const r=i(53265),s=i(45200),n=i(22573),a=i(68708),o=i(54993);async function l(e,t){if((0,a.isObject)(e)&&!(0,n.blank)(e.nativePath)&&!(0,n.blank)(e.uri))return e;const i=(0,r.resolve)((0,o.toS)(e)),l=await t??await(0,s.nativePath2uri)(i);return null==l?void 0:{nativePath:i,uri:l.toString()}}t.toUriPath=l,t.posixFileToUriPath=function(e){return l(e.nativePath,e.uriObject_())}},7656:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rebuildTagAssetCounts=t.DirectAssetCountForTagQuery=t.RecursiveAssetCountForTagQuery=t.nonLeafTagIds=void 0;const r=i(50213),s=i(56038),n=i(95704),a=i(38156),o=i(42659),l=i(45599),u=i(41400),c=i(31586),d=i(51926),h=(0,l.defer)((()=>(0,r.mkLogger)("tag.TagAssetCounts")));function f(e){return e.prepare((0,d.compressWhitespace)("SELECT"," t1.id,"," count(t2.id) AS cnt","FROM"," Tag t1"," JOIN Tag t2 ON t1.id = t2.parentId","GROUP BY"," 1","HAVING"," cnt > 0")).pluck().all()}async function m(e,i=[]){const r=e.prepare(t.RecursiveAssetCountForTagQuery).pluck(),o=e.prepare(t.DirectAssetCountForTagQuery).pluck(),l=e.prepare("UPDATE Tag SET assetCount = :assetCount, updatedAt = :updatedAt WHERE id = :tagId"),c=new Set(f(e)),d=new a.PushProgressObserver({op:"Rebuilding tag asset counts"},e.prepare("SELECT count(*) FROM Tag").pluck().get());await(0,n.withIdBatches)({db:e,tableName:"Tag",primaryKeyColumnName:"id",whereClauses:i,async fn(e){for(const t of e){const e=!c.has(t);(0,s.timeSync)("db.rebuildTagAssetCounts("+(e?"leaf":"cte")+")",(()=>{const s=(e?o:r).get({tagId:t});l.run({tagId:t,assetCount:s,updatedAt:Date.now()}),d.incrProgress(),h().debug("_rebuildTagAssetCounts()",{isLeaf:e,whereClauses:i,tagId:t,assetCount:s})})),t%10==0&&(h().throwIfAborted_(),await(0,u.delay)(1))}}}),d.completed()}t.nonLeafTagIds=f,t.RecursiveAssetCountForTagQuery=(0,d.compressWhitespace)("WITH RECURSIVE descendants(id) AS ("," VALUES (:tagId)"," UNION"," SELECT Tag.id"," FROM Tag, descendants"," WHERE Tag.parentId = descendants.id",")","SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," descendants"," JOIN AssetTag ON AssetTag.tagId = descendants.id"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL"),t.DirectAssetCountForTagQuery=(0,d.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," AssetTag"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," AssetTag.tagId = :tagId"," AND Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL;"),t.rebuildTagAssetCounts=async function(e,t=o.minuteMs){if(await(0,s.time)("db.rebuildNullTagAssetCounts",(()=>m(e,["assetCount IS NULL"]))),(0,c.gt0)(t)){const i=e.prepare("SELECT min(updatedAt) FROM Tag").pluck().get(),r=Date.now()-i;if(rm(e)))}},69032:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.displayNameForVolsha=t.fixFileRootTag=t.runTagMaintenance=t.forceRunTagMaintenance=t.tagFtsRebuild=void 0;const s=r(i(76760)),n=i(19851),a=i(50213),o=i(7282),l=i(409),u=i(1728),c=i(56038),d=i(34102),h=i(49076),f=i(69589),m=i(28874),p=i(42231),g=i(85087),y=i(98770),v=i(59107),w=i(63870),b=i(7014),S=i(22573),P=i(42659),_=i(41400),T=i(75240),M=i(31586),E=i(34666),k=i(51926),D=i(75020),x=i(54017),C=i(48723),F=i(98784),A=i(7656),I=(0,n.lazy)((()=>(0,a.mkLogger)("tag.TagSql")));t.tagFtsRebuild=(0,n.lazy)((()=>(0,c.time)("db.rebuildTagFts",(()=>F.TagFts.rebuild()))),10*P.minuteMs),t.forceRunTagMaintenance=async function(e={forceSync:!0,recountAllTags:!0}){return I().info("forceRunTagMaintenance()"),await t.runTagMaintenance.force(e)};const O=((0,o.isTest)()?5:30)*P.secondMs;t.runTagMaintenance=(0,l.rateLimited)({name:"runTagMaintenance",minCallDelayMs:O,f:async e=>{const i=(0,f.forceContextOrSetting)(e),r=Date.now(),s=I().addContext(".runTagMaintenance()");s.info("starting",{ctx:i});try{s.info("validating all tags..."),C.Tag.validate_(),s.throwIfAborted_(i?.halt),await L(),i.recountAllTags&&(s.info("rebuilding tag search index..."),await(0,t.tagFtsRebuild)(),s.info("rebuilding tag asset counts..."),await(0,A.rebuildTagAssetCounts)(C.Tag.dbl.db().db,0))}catch(e){I().warn("runTagMaintenance() failed",e)}const n=Date.now()-r,a=(0,M.clamp)(O,15*P.minuteMs,20*n);t.runTagMaintenance.setMinCallDelayMs(a),I().info("runTagMaintenance(): complete.",{newMinCallDelayMs:a,elapsedMs:n})}});const L=(0,y.lazyFsAsync)("updateTagMountpoints",(async()=>{I().info("updating tag mountpoints...");const e=C.Tag.findByPath([D.TagRoots.fs]);if(null!=e){e.maybeUpsertDisplayName(m.Settings.tagDisplayNameFS.valueOrDefault);for(const t of e.getChildren())await N(t)}else(0,a.mkLogger)("updateTagMountpoints()").info("No root filesystem tag (new db, I hope?)")}));function R(){t.tagFtsRebuild.unset(),L.unset()}async function N(e){if(null==e||2!==e.depth||!e._path.startsWith(D.TagRoots.fs+p.TagSep))return;const i=(0,a.mkLogger)("fixFileRootTag("+e+")");if(e.name===D.LibraryTagName)return void(1!==e.ordinal&&(i.info("fixing library ordinal",{id:e.id,path:e.path}),e.upsert({ordinal:1}),C.Tag.clear()));if((0,f.forceContextOrSetting)().forceSync&&(0,S.notBlank)(e.displayName)&&(0,E.gt)(e.updatedAt,Date.now()-(0,w.volumeMetadataTtlMs)()))return void i.info("no-op: tag recently updated",{id:e.id,path:e.path,updated:(0,T.fmtDuration)(Date.now()-e.updatedAt)+" ago"});const r=await(0,t.displayNameForVolsha)(e.name);(0,S.notBlank)(r)?(e.maybeUpsertDisplayName(r),i.info("updated tag",{id:e.id,path:e.path,displayName:r}),C.Tag.clear()):i.debug("cannot update tag: no current volume.",{id:e.id,path:e.path})}(0,_.later)((()=>{(0,d.ee)().on("clearCache",R),m.Settings.libraryDir.watchLater(R)})),t.fixFileRootTag=N,t.displayNameForVolsha=(0,u.memoizeAsync)((async e=>{const t=(0,a.mkLogger)("displayNameForVolsha("+e+")"),i=await(0,b.volumes)();if(null!=i){const r=i.find((t=>(0,g.volsha)(t.uuid)===e));return t.info("find()",{vol:r}),null!=r?m.Settings.tagDisplayNameFSLabels.valueOrDefault&&(0,S.notBlank)(r.label)?r.label.trim():"/"===r.mountpoint?m.Settings.tagDisplayNameFSRoot.valueOrDefault+(m.Settings.tagDisplayNameFSRootWithHostname.valueOrDefault?" on "+(0,h.hostname)():""):(0,S.notBlankOr)((0,k.stripPrefixSuffix)(r.mountpoint,{prefix:s.default.sep,suffix:s.default.sep}),s.default.sep):x.AssetFile.dbl.pluckFirstf((t=>t.select("mountpoint").whereLike("uri","psfile://"+e+"/%").limit(1)))}}),{name:"tag.displayNameForVolsha",maxSize:64,timeoutMs:(0,w.volumeMetadataTtlMs)()}),(0,_.later)((()=>{v.mountpoints.watch((()=>t.displayNameForVolsha.clear()))}))},5379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});try{i(93944).install()}catch{}const r=i(69554),s=i(38790),n=i(53978),a=i(43380),o=i(5670),l=i(98392),u=i(31503),c=i(1739);!async function(){await new r.CLI(o.ServiceNames.web).add(l.ExposeArg,u.LogArgs,n.TimingArg,a.WriteSettingsArg,s.ColorArgs).parse(),new c.WebService}()},13808:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AboutRouter=void 0;const s=r(i(7252)),n=i(45255),a=i(81168),o=i(76596),l=i(51773),u=i(81674),c=i(28874),d=i(85087),h=i(7014),f=i(38639),m=i(42659),p=i(75240),g=i(55835),y=i(31586),v=i(20214),w=i(13538),b=i(83104),S=i(12168),P=i(77948),_=i(49796),T=i(92244),M=i(8283);t.AboutRouter=class{router(){return s.default.Router().get("/about",(0,l.wrap)("AboutRouter",this.about.bind(this)))}async about(e,t,i){const r=n.ShortCommandTimeoutMs+m.secondMs,s=await(0,w.thenOrTimeoutAs)({f:(0,P.systemInformation)(),timeoutMs:r,as:[{term:"System information",defn:"Failed to fetch system information: timeout after "+(0,o.fmtMs)(r),defnClass:"fail"}]}),l=await(0,w.thenOrTimeout)((0,v.thenMap)((0,h.volumes)(),(e=>e.map((e=>({ignorable:e.ignorable,mountpoint:e.mountpoint,uuid:e.uuid,volsha:(0,g.map)(e.uuid,d.volsha),size:(0,S.fmtBytes)(e.size,2),free:(0,S.fmtBytes)(e.available,2),full:(0,y.gt0)(c.Settings.minDiskFreeGb.valueOrDefault)&&(0,y.lt)(e.available,c.Settings.minDiskFreeGb.valueOrDefault*S.GB),label:e.label,remote:!0===e.remote?{remote:e.remote,host:e.remoteHost,share:e.remoteShare}:void 0}))).filter((e=>!0!==e.ignorable)))),r);l===b.Timeout&&s.push({term:"volumes() timeout",defn:"Failed to fetch volume metadata: timeout after "+(0,o.fmtMs)(r),defnClass:"fail"});const E=null==_.Progress.db()?void 0:await(0,w.thenOrTimeout)((0,T.syncPathsForUI)(),n.ShortCommandTimeoutMs);E===b.Timeout&&s.push({term:"sync paths timeout",defn:"Failed to fetch sync path metadata: timeout after "+(0,o.fmtMs)(n.ShortCommandTimeoutMs),defnClass:"fail"});const k=await(0,u.b)();return(0,M.render)(e,t,"about",{title:"About PhotoStructure",systemInfo:s,volumes:Array.isArray(l)?l.map((e=>({...e,mountpoint:(0,a.wbrPath)(e.mountpoint)}))):void 0,syncPaths:Array.isArray(E)?E:void 0,subTier:await(0,u.t)(),subTrial:(0,f.isTrue)(k?.l?.trial),subEmail:k?.l?.sub,subExpiresInDuration:(0,g.map)(k?.l?.exp,(e=>(0,p.fmtDuration)(e.getTime()-Date.now(),1))),subExpiresAt:(0,g.map)(k?.l?.exp,m.fmtIsoDate)})}}},76020:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AdminPostRouter=void 0;const s=r(i(7252)),n=i(45608),a=i(34102),o=i(51773),l=i(40749),u=i(62327),c=i(65238),d=i(18454),h=i(2858),f=i(7014),m=i(42659),p=i(41400),g=i(98553),y=i(98401),v=i(14611),w=i(53791),b=i(35758),S=2*m.secondMs;t.AdminPostRouter=class{router(){return s.default.Router().post("/admin/restart",(0,o.wrap)("AdminHealthRouter:restart",this.restart.bind(this))).post("/admin/bounce",(0,o.wrap)("AdminHealthRouter:bounce",this.bounce.bind(this))).post("/admin/refresh/:id",(0,o.wrap)("AdminHealthRouter:refresh",this.refresh.bind(this))).post("/admin/clear-library",(0,o.wrap)("AdminHealthRouter:clear-library",this.clearLibrary.bind(this))).post("/admin/clear-caches",(0,o.wrap)("AdminHealthRouter:clear-caches",this.clearCaches.bind(this))).post("/admin/recheck-tools",(0,o.wrap)("AdminHealthRouter:recheck-tools",this.recheckTools.bind(this))).post("/admin/repair-db",(0,o.wrap)("AdminHealthRouter:repair-db",this.repairDb_.bind(this))).post("/admin/run-maintenance",(0,o.wrap)("AdminHealthRouter:repair-db",this.maintenance_.bind(this))).post("/admin/shutdown",(0,o.wrap)("AdminHealthRouter:shutdown",this.shutdown.bind(this)))}async restart(e,t,i){await(0,v.restartLibrary_)(),(0,u.sendRedirectionToast)({response:t,toast:{text:"Restarted library...",timeout:S},url:"/splash"})}async refresh(e,t,i){const r=e.params.id,s=d.HealthCheck.findById(r);if(null==s)throw new Error("No health check found with id="+(0,g.stringify)(r));const n=await s.refresh();(0,u.sendRedirectionToast)({response:t,toast:{text:"Health check "+r+": "+n.level,timeout:S},url:"/health"})}async bounce(e,t,i){(0,p.delay)(m.secondMs).then((()=>(0,n.exit)({reason:"/bounce requested by "+e.ip,status:0}))),(0,u.sendRedirectionToast)({response:t,toast:{text:"Restarting webserver...",timeout:15*m.secondMs},url:"/splash"})}async clearLibrary(e,t,i){await(0,h.clearLibraryDirSetting)(),(0,v.restartLibrary_)(),(0,u.sendRedirectionToast)({response:t,toast:{text:"Prior library was unset. Restarting...",timeout:S},url:"/splash"})}async clearCaches(e,t,i){await(0,f.clearVolumesCache)({deleteFileCache:!0}),await(0,c.clearReaddirCaches)(),(0,a.ee)().emit("clearCache"),"/health"===(0,l.referrer)(e)?(0,u.sendRedirectionToast)({response:t,toast:{text:"Cleared caches.",timeout:S},url:"/health"}):(0,u.sendServerToast)({response:t,toast:{text:"Cleared caches."},reload:!0})}async recheckTools(e,t,i){(0,a.ee)().emit("clearToolCache"),(0,u.sendRedirectionToast)({response:t,toast:{text:"Cleared tool caches.",timeout:S},url:"/health"})}async repairDb_(e,t,i){(0,b.dbModelRepair)(),(0,u.sendRedirectionToast)({response:t,toast:{text:"Started library database repair...",timeout:S},url:"/splash"})}async maintenance_(e,t,i){(0,y.cleanup_)(),(0,u.sendRedirectionToast)({response:t,toast:{text:"Started library maintenance jobs...",timeout:S},url:"/"})}async shutdown(e,t,i){(0,p.delay)(S).then((()=>(0,w.shutdown)("requested by "+e.ip))),(0,u.sendServerToast)({response:t,toast:{text:"Shutdown initiated."}})}}},13831:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiAssetRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(97352),o=i(56519),l=i(4867),u=i(76596),c=i(57159),d=i(51773),h=i(62327),f=i(86580),m=i(81674),p=i(72308),g=i(45969),y=i(28874),v=i(40958),w=i(76790),b=i(75761),S=i(38639),P=i(55835),_=i(31586),T=i(68708),M=i(21605),E=i(41942),k=i(75020),D=i(54993),x=i(43487),C=i(37094),F=i(69853),A=i(48723),I=i(94710),O=i(73407),L=(0,n.mkLogger)("web.ApiAssetRouter"),R=["hidden","excludedAt","deletedAt"];t.ApiAssetRouter=class{constructor(e){this.previews=e}wrapApi(e,t){return(i,r,s)=>(0,h.wrapWithToast)({response:r,f:async()=>{const s=(0,_.toGt0)(i.params.assetId);if(null==s)return r.sendStatus(400);const n=await(0,o.thenMapOr)(x.Asset.ops().findById(s,{shown:1}),(e=>t(i,s,e)),(()=>this.onMissingAsset(i,s)));if(L.debug(e,{result:n}),null!=n)return(0,d.jsonOrRedirect)(n,r);throw new c.WrappedError("Asset "+s+" wasn't found",{retriable:!1,doNotSend:!0,fatal:!1})}})}router(){return s.default.Router().get("/api/asset/:assetId/info",this.wrapApi("ApiAssetRouter.assetInfo",this.assetInfo.bind(this))).get("/api/asset/:assetId/streams",this.wrapApi("ApiAssetRouter.assetInfo",this.assetStreams.bind(this))).get("/api/asset/:assetId",this.wrapApi("ApiAssetRouter.asset",this.asset.bind(this))).put("/api/asset/:assetId",this.wrapApi("ApiAssetRouter.save",this.save.bind(this))).put("/api/asset/:assetId/resync",this.wrapApi("ApiAssetRouter.resync",this.resync.bind(this)))}async assetInfo(e,t,i){const r=i.getAssetFiles(),s=i.getShown(),n=(0,P.map)(s,(e=>e.getNativePath())),a=(0,p.isLocalhost)(e.ip)&&!(0,g.isDocker)();if(y.Settings.resyncAssetOnVisit.valueOrDefault&&I.Task.addOne("repairAsset",{assetId:t,forceSync:!1,forceRebuildPreviews:!1}),null==s||null==n)return void L.error("no shown AssetFile found for "+t,{asset:i,shown:s,shownPathP:n});L.debug("assetInfo()",{assetId:t,shown:s,shownPathP:n,ip:e.ip,showOpenFile:a});const l=i.getTags(),c=await(0,o.mapAsync)({name:"api.assetInfo.tags",arr:l,f:e=>e.toApiTag()}),h=await(0,o.mapAsync)({name:"api.assetInfo.files",arr:r,f:e=>e.toApi(this.previews,s.sha)});return(0,w.sortByInPlace)(h,(e=>[!e.shown,!e.exists,e.nativePath])),{assetId:t,capturedAtLocale:s.capturedAtLocale((0,d.requestLang)(e)),...(0,T.pick)(s,"mimetype","focalLength","iso","aperture","shutterSpeed"),durationHMS:(0,P.map)(s.durationMs,u.durationHMS),fps:s.fps,files:h,tags:c,showOpenFile:a}}async onMissingAsset(e,t,i){const r="next"===e.query.from;L.info("onMissingAsset()",{query:(0,T.entries)(e.query),params:(0,T.entries)(e.params),assetId:t});const s=(0,_.toInt)(String(e.query.priorAssetId)),n=(0,P.mapOr)(i,(e=>e.id),(()=>s));if(null==n)return void L.warn("onMissingAsset(): no context asset available");const l=await(0,o.thenMapOr)(i,(e=>e.capturedAtLocal),(()=>x.Asset.dbl.pluckFirstf((e=>e.select("capturedAtLocal").where({id:n})))));let u=x.Asset.shownUnhidden(x.Asset.query().select("id").limit(1).whereNotIn("id",(0,v.compact)([t,s])));u=r?u.andWhere("capturedAtLocal","<",l).orderBy("capturedAtLocal","desc"):u.andWhere("capturedAtLocal",">",l).orderBy("capturedAtLocal","asc");const c=x.Asset.dbl.pluckFirst(u);return L.warn("Asset redirect",{fromAssetId:n,priorAssetId:s,fromTime:l,toAsset:c}),(0,a.mapGt0)(c,(t=>(0,E.mkReplace)((0,b.assetUrl)({assetId:t,params:[e.query,e.params]}),{text:`Asset ${n} is no longer available.`,type:"info"})))}async asset(e,t,i){const r=i.getShown();if(null==r)return L.error("no shown AssetFile found for "+t+", disabling (for now)."),i.upsert({shown:!1}),L.error("Asset un-shown."),I.Task.addOne("repairAsset",{assetId:t,forceSync:!0,forceRebuildPreviews:!0}),this.onMissingAsset(e,t,i);i.getBeforeAfterId();const s={...i.partialSimpleAsset(),name:r.basename,width:r.width,height:r.height,rotation:r.rotation??0,capturedAtLocale:r.capturedAtLocale((0,d.requestLang)(e)),aspectRatio:(0,f.aspectRatio)(r),durationHMS:(0,P.map)(r.durationMs,u.durationHMS),downloadable:await r.originalDownloadable({brief:!0}),contextTag:await i.whenApiTag(),beforeAssetId:i.beforeId,afterAssetId:i.afterId};if(r.isVideo){const r=await i.videoSources();return await i.getExistingAssetFiles(),(0,v.isEmpty)(r)?(L.warn("no existing files for "+t+", trying to repair, but redirecting user now."),I.Task.addOne("repairAsset",{assetId:t,forceSync:!0,forceRebuildPreviews:!0}),this.onMissingAsset(e,t,i)):{...s,videoAttrs:i.videoAttrs(),videoSources:r}}return{...s,imgAttrs:await i.fitAttrs(this.previews)}}async assetStreams(e,t,i){const r=(0,_.toInt)((0,D.toS)(e.query.limit),{defaultValue:k.BeforeAfterStreamLimit}),s=i.getStreams(r);return L.tap({msg:"assetStreams",result:{assetId:t,assetStreams:await(0,o.mapAsync)({name:"assetStreams",arr:s,f:e=>e.toApi()})}})}async save(e,t,i){if(await(0,m.l)())return L.warn("save(): disabled"),{showTryPlusToast:!0};const r=i.isActive(),s={hidden:(0,S.toBoolean)(e.body.hidden),excludedAt:(0,P.map)((0,S.toBoolean)(e.body.excluded),(e=>e?Date.now():null)),deletedAt:(0,P.map)((0,S.toBoolean)(e.body.deleted),(e=>e?Date.now():null)),rating:(0,P.map)((0,S.toBoolean)(e.body.liked),(e=>e?y.Settings.likeRating.valueOrDefault:null))};if(!(0,v.isEmpty)((0,T.keys)(s))){L.info("save()",{obj:s,body:e.body}),C.AssetRevision.insert(...(0,T.entries)((0,T.omit)(s,...R)).map((([e,r])=>({assetId:t,field:e,priorValue:i?.[e],newValue:r}))));const n=null===s.deleted?null:null!=s.deleted?-1:s.rating;void 0!==n&&await(0,O.writeAssetTags_)(t,{Rating:n}),i.upsert(s),i.isActive()!==r&&A.Tag.deltaAssetCountAndAncestors(i.tagIds(),i.isActive()?1:-1)}const n=i.partialSimpleAsset(),a=(0,M.normalizeRotation)((0,_.toInt)(e.body.rotation));return null!=a&&0!==a&&(await(0,F.setAssetRotation_)(t,a,this.previews),n.rotation=a),n}async resync(e,t){return x.Asset.dbl.runf((e=>e.where({id:t}).update({version:0}))),await(0,l.thenOrTimeoutError)({p:I.Task.addOne("repairAsset",{assetId:t,forceSync:!0,forceRebuildPreviews:!0}).donePromise(),timeoutMs:y.Settings.taskTimeoutMs.valueOrDefault}),{v:x.Asset.dbl.pluckFirstf((e=>e.where({id:t}).select("updateCount")))}}}},53881:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiSearchRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(51773),o=i(68178),l=i(28874),u=i(7014),c=i(40958),d=i(22573),h=i(38639),f=i(31586),m=i(12168),p=i(32790),g=i(54993),y=i(43487),v=i(48722),w=i(43786),b=i(7573),S=i(33693),P=i(23523),_=(0,n.mkLogger)("web.ApiSearchRouter");t.ApiSearchRouter=class{router(){return s.default.Router().get("/api/search",(0,a.wrap)("ApiSearchRouter.get",this.get.bind(this)))}async get(e,t){const i=(0,g.toStr)(e.query.q," "),r=p.AssetQueryOrderByColumns.validOrElse((0,g.toStr)(e.query.orderby,","),p.AssetQueryOrderByColumns.capturedAt),s=(0,h.isTrue)(e.query.asc),n={column:r===p.AssetQueryOrderByColumns.capturedAt?"Asset.capturedAtLocal":"Asset.updatedAt",order:s?"asc":"desc"},a=(0,f.toGt0)((0,g.toStr)(e.query.offset));if(_.debug("get()",{q:i,orderBy:n,offset:a}),(0,d.blank)(i))return t.json({});const T=(0,b.normalizeQuery)((0,S.parseQuery_)(i));let M=(0,P.defaultAssetQuery)().select({id:"Asset.id",capturedAtLocal:"Asset.capturedAtLocal",updateCount:"Asset.updateCount",durationMs:"Asset.durationMs"}).orderBy([n,"Asset.id"]).limit(512);const E=(0,w.findTerm)(T,(e=>"fs"===e.ns))?await(0,u.mountpointToVolsha)():void 0;null!=a&&(M=M.offset(a));const k=null==a?await async function(e,t,i){const r=await function(e,t){return y.Asset.dbl.pluckFirst((0,P.queryToSql)(e,(0,P.defaultAssetQuery)().countDistinct("Asset.id"),t))}(t,i),{emptyTrashQuery:s,removeAssetsQuery:n}=function(e){const t=1===(0,w.flatTerms)(e).length,i=t&&(0,w.isTrueTerm)((0,w.findTerm)(e,(e=>e.ns===b.AssetTermBoolNs.deleted)));return{emptyTrashQuery:i,removeAssetsQuery:!i&&t&&(0,w.isTrueTerm)((0,w.findTerm)(e,(e=>e.ns===b.AssetTermBoolNs.excluded)))}}(t);if(0===r)return{description:s?"No assets are marked for trash.":n?"No assets are marked for removal.":"No matching assets."};const a="Found "+(0,m.plur)(r,"asset");if(!s&&!n)return{description:a};const u=await function(e,t){return y.Asset.dbl.pluckFirst((0,P.queryToSql)(e,(0,P.defaultAssetQuery)().join("AssetFile","AssetFile.assetId","Asset.id").countDistinct("AssetFile.id"),t))}(t,i),c=a+" ("+(0,m.plur)(u,"file")+")",d={expectedAssetFileCount:String(u)};if(s){const t="Empty trash";return{description:c,buttonText:t,buttonIcon:"trash_forever",promptTitle:t,refreshOnActivation:!0,...l.Settings.enableEmptyTrash.valueOrDefault?{buttonClass:"error",buttonTitle:null,prompt:[`

    Are you sure you want to permanently delete ${(0,m.plur)(u,"file")} comprising ${(0,m.plur)(r,"asset")}?

    `,"","

    To proceed, please enter the number of files that will be deleted:

    "].join("\n"),formAction:(0,o.requestedUri)(e).with({path:"/api/system/empty-trash",query:d}).toString()}:{buttonClass:"disabled",buttonTitle:'This is disabled. See the "enableEmptyTrash" setting.',prompt:null,formAction:null}}}if(n){const t="Remove assets";return{description:c,buttonText:t,buttonIcon:"warning",promptTitle:t,refreshOnActivation:!0,...l.Settings.enableRemoveAssets.valueOrDefault?{buttonClass:"warning",buttonTitle:null,prompt:["

    Are you sure you want to remove "+(0,m.plur)(r,"asset")+" (comprised of "+(0,m.plur)(u,"file")+") from your library?

    ","","

    To proceed, please enter the number of files that will be removed:

    "].join("\n"),formAction:(0,o.requestedUri)(e).with({path:"/api/system/remove-assets",query:d}).toString()}:{buttonClass:"disabled",buttonTitle:'This is disabled. See the "enableRemoveAssets" setting.',prompt:null,formAction:null}}}throw new Error("internal error (mkBanner)")}(e,T,E):void 0;M=(0,P.queryToSql)(T,M,E).distinct();const D=(0,c.compact)(y.Asset.dbl.all(M).map(v.toAssetId)),x={query:{q:i,normalized:(0,w.queryToString)(T,w.NormieQuerySymbols),orderBy:r,asc:s,offset:a??0,nextOffset:D.length<512?void 0:D.length+(a??0)},banner:k,assetIds:D};return _.debug(".get("+(0,w.queryToString)(T)+") result",x),t.json(x)}validatePostRequest(e,t){return _.debug("validatePostRequest",{req_query:e.query,req_body:e.body}),this.validatePost((0,g.toStr)(e.query.expectedAssetFileCount," "),e.body.answer,t)}async validatePost(e,t,i){_.debug("validatePost",{expectedAssetFileCount:e,answer:t});const r=(0,f.toInt)((0,g.toS)(e));if(null==r)return"Canceled: the expected number of files was missing from the request.";const s=(0,f.toInt)(t);if(null==s)return"Canceled: missing user input.";const n=await y.Asset.dbl.pluckFirst(i().join("AssetFile","Asset.id","AssetFile.assetId").countDistinct("AssetFile.id"));return r!==n?`Canceled: the number of files has changed from ${(0,m.fmt)(r)} to ${(0,m.fmt)(n)}. Reload this page and try again.`:s!==r?`Canceled: you entered "${t??""}" and we expected "${r}".`:{assetFileCount:n}}}},21598:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiSplashRouter=void 0;const a=i(18405),o=i(18454),l=i(37805),u=i(42659),c=i(62220),d={loading:"⏳ Loading...",welcome:"👋 Welcome!",ready:"✅ Ready",failed:"⚠️ Something's not right. Gathering details..."};class h extends a.ServerSentEventsRouter{constructor(){super("/sse/splash"),r.set(this,null)}runStateEvent(e=o.HealthCheck.runState()){const t=e===c.RunStates.loading;return t&&this.streams.length>0?n(this,r,s(this,r,"f")??setInterval((()=>{this.writeToStreams(this.runStateEvent())}),u.secondMs),"f"):null!=s(this,r,"f")&&(clearInterval(s(this,r,"f")),n(this,r,null,"f")),this.logger.tap({msg:"runStateEvent()",level:"warn",result:t?{event:"msg",data:o.HealthCheck.loadingMsg()??d[e]}:{event:"settled",data:d[e]},meta:{state:e}})}firstEvents(){return[{event:"version",data:l.version},this.runStateEvent()]}}t.ApiSplashRouter=h,r=new WeakMap},49296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiSystemRouter=void 0;const s=r(i(7252)),n=i(19851),a=i(50213),o=i(97352),l=i(71567),u=i(51773),c=i(62327),d=i(74128),h=i(28874),f=i(69385),m=i(40958),p=i(38639),g=i(25763),y=i(31586),v=i(12168),w=i(54993),b=i(53791),S=i(43487),P=i(20958),_=i(94710),T=i(22968),M=(0,n.lazy)((()=>(0,a.mkLogger)("web.ApiSystemRouter")));function E(e){return async(t,i,r)=>{const s=(0,w.toStr)(t.query.expectedAssetFileCount," "),n=(0,o.extractInt)(t.body.answer);M().debug("validatePostCounts",{expectedAssetFileCount:s,answer:n});const a=(0,y.toInt)((0,w.toS)(s));if(null==a)return(0,c.sendWarningServerToast)({response:i,toast:{text:"Canceled",details:"The expected number of files was missing from the request"}});const l=(0,y.toInt)(n);if(null==l)return(0,c.sendWarningServerToast)({response:i,toast:{text:"Canceled",details:"User answer was missing"}});const u=await async function(e,t){var i,r;return M().tap({msg:`countAssetFiles(${t})`,result:(i=e.locals)[r="countAssetFiles-"+t]??(i[r]=await S.Asset.dbl.pluckFirst(S.Asset.shownRemovable(t).join("AssetFile","Asset.id","AssetFile.assetId").countDistinct("AssetFile.id")))})}(i,e);return a!==u?(0,c.sendWarningServerToast)({response:i,toast:{text:"Canceled",details:`The number of files has changed from ${(0,v.fmt)(a)} to ${(0,v.fmt)(u)}. Reload this page and try again.`}}):l!==a?(0,c.sendWarningServerToast)({response:i,toast:{text:"Canceled",details:`You entered "${n??""}" and we expected "${a}".`}}):r()}}async function k(e){M().warn("setting "+e+" to unshown...");const t=Date.now(),i={shown:0,updatedAt:t};i[e]=t;const r=S.Asset.dbl.run(S.Asset.shownRemovable(e).update(i)),s=_.Task.addOne(function(e){if("deletedAt"===e)return _.TaskNames.applyDeleted;if("excludedAt"===e)return _.TaskNames.applyExcluded;throw new Error("invalid RemovableColumn "+e)}(e),{createdAt:t});M().warn("updated assets and scheduled task",{result:r,obj:i,task:s})}async function D(e,t){return await k("deletedAt"),(0,c.sendServerToast)({response:t,reload:!0,toast:{text:"Emptied trash",details:"Assets have been removed from your library and files will be deleted in the background.",type:"success"}})}async function x(e,t){return await k("excludedAt"),(0,c.sendServerToast)({response:t,reload:!0,toast:{text:"Assets have been removed from your library.",type:"success"}})}t.ApiSystemRouter=class{constructor(e){this.openFileService=e,this.getState=(e,t)=>{const i={paused:(0,f.isPaused)()};return t.json(i)},this.getHasEmail=(e,t)=>{t.json({hasEmail:(0,g.isEmailMaybe)(h.Settings.email.value)})},this.postSystem=async(e,t)=>{const i=e.body,r=[];M().info("post()",{body:e.body}),(0,p.mapTrue)(i.pause,(()=>{(0,f.pause)(!0),r.push("Sync was paused")})),(0,p.mapTrue)(i.resume,(()=>{(0,f.pause)(!1),r.push("Sync was resumed")})),await(0,p.mapTrue)(i.restartSync,(async()=>{l.StdoutWrite.restartSync(),r.push("Sync restart was requested")})),await(0,p.mapTrue)(i.forceRestartSync,(async()=>{P.Operation.markOpCompleted({name:"forceRestartSync"},{value:"canceled (force-restarted)"}),P.Operation.ensurePendingOp({name:"forceRestartSync"}),l.StdoutWrite.restartSync(),r.push("Sync force-restart was requested")})),await(0,p.mapTrue)(i.rebuildLibrary,(async()=>{(0,T.forceRebuildLibraryLater)(),l.StdoutWrite.restartSync(),r.push("Library rebuild was requested")})),(0,p.mapTrue)(i.showSyncReports,(()=>{this.openFileService((0,d.syncReportReadme)()),r.push("Opened your sync reports directory")})),(0,p.mapTrue)(i.shutdown,(async()=>{const t="requested by "+e.ip;(0,b.shutdown)(t),r.push("Shutdown "+t)})),(0,m.isNotEmpty)(r)?(0,c.sendServerToast)({response:t,toast:{type:"info",text:r.join(". ")}}):(t.status(400),(0,c.sendServerToast)({response:t,toast:{text:"Nothing requested.",type:"warning"}}))}}router(){return s.default.Router().get("/api/system/state",(0,u.wrap)("state",this.getState)).get("/api/system/hasEmail",(0,u.wrap)("hasEmail",this.getHasEmail)).post("/api/system",((e,t)=>(0,c.wrapWithToast)({response:t,f:()=>this.postSystem(e,t)}))).post("/api/system/empty-trash",c.requirePlus,(0,c.requireEnabled)(h.Settings.enableEmptyTrash),E("deletedAt"),D).post("/api/system/remove-assets",c.requirePlus,(0,c.requireEnabled)(h.Settings.enableRemoveAssets),E("excludedAt"),x)}}},19583:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiTagRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(97352),o=i(45255),l=i(76596),u=i(51773),c=i(62327),d=i(28874),h=i(34238),f=i(40958),m=i(31586),p=i(41942),g=i(75020),y=i(27776),v=i(54993),w=i(64526),b=i(43487),S=i(48723),P=(0,n.mkLogger)("ApiTagRouter");function _({name:e,f:t}){return(0,u.wrap)(e,(async(i,r)=>{const s=(0,m.toInt)(i.params.tagId),n=(0,u.extractTagPath)(i.path).map(h.percentDecode),a=(0,u.getSeed)(i),o=(0,u.getFit)(i),l=(0,f.mapNotEmptyOr)(n,(e=>S.Tag.findByIdOrPath(s,e)),(()=>S.Tag.root())),d=null==l?void 0:t(i,l,{tagId:l.id,tagPath:l.path,seed:a,fit:o});return P.debug(e,{result:d,tagPath:n,seed:a,url:i.url}),null==l||null==d?(0,c.send404Toast)({text:"Failed to find tag "+s??n.join("/"),response:r}):(0,u.jsonOrRedirect)(d,r)}))}t.ApiTagRouter=class{router(){return s.default.Router().get("/api/tag*",_({name:"ApiTagRouter.tagGallery",f:this.tagGallery.bind(this)})).get((0,g.nextAssetsUrl)(":tagId",{}),_({name:"ApiTagRouter.tagAssets",f:this.tagAssets.bind(this)})).get((0,g.nextChildTagsUrl)(":tagId",{}),_({name:"ApiTagRouter.childTags",f:this.childTags.bind(this)}))}tagGallery(e,t,i){if(P.debug("tagGallery()",{tag:t}),null==i.seed)return P.debug("tagGallery(): no seed, redirecting..."),(0,p.mkReplace)((0,y.mkTagFullPath)(t.path,e.query));if(d.Settings.fastForwardEmptyTags.valueOrDefault){const i=t.firstNonInterstitialTagId();if(i!==t.id){const t=S.Tag.findById(i);if(null!=t)return(0,p.mkReplace)((0,y.mkTagFullPath)(t.path,e.query),{text:"Skipping to first non-empty child tag…",uuid:"redirect-to-tag",onlyShowUuidOnce:!0,type:"info"})}}const r={fullPath:e.originalUrl,fit:i.fit,...t.toApiTag(),...this.childTags(e,t,i),...this.tagAssets(e,t)};return 0===t.id&&0===b.Asset.shownCount()&&((0,l.isRecentMs)(w.Library.instance()?.start,o.ShortCommandTimeoutMs)?r.startingUp=!0:r.emptyLibrary=!0),r}childTags(e,t,i){const r=(0,m.toInt)((0,v.toS)(e.query.offset))??0,s=(0,m.toInt)((0,v.toS)(e.query.limit))??4;P.debug("childTags() got ",{thisOffset:r,limit:s,query:e.query});const n={tagId:t.id,offset:r,limit:s,seed:i.seed};n.limit=(0,a.firstGt0)(n.limit,4);const o=t.getChildrenCount(),l=0===o?[]:t.getPagedChildren(n);P.debug("childTags()",{crit:n,childTagCount:o,children:l});const u=l.length+r,c=u{const t=e.getRelatedAssetIds({seed:i.seed+e.id,limit:g.ThumbsPerSample});return(0,f.isNotEmpty)(t)?{...e.toApiTag(),assetIds:t}:void 0})));return P.tap({msg:"childTags result",result:{tagId:t.id,childTags:d,childTagCount:o,nextChildTags:c},meta:{nextOffset:u}})}tagAssets(e,t){const i={offset:(0,m.toInt)((0,v.toS)(e.query.offset),{defaultValue:0})},r=t.getPagedAssetIds(i),s=r.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetOpenGraph=void 0;const r=i(48884),s=i(48604),n=i(28874),a=i(16170),o=i(31586);t.getAssetOpenGraph=async function(e,t){if(null==(t=(0,o.toGt0)(t))||!(0,o.gt0)(n.Settings.openGraphTargetWidth.valueOrDefault))return;const i=s.Previews.instance()?.ap(t);if(null==i)return;const l=await i.readInfo();if(null==l)return;const u=[];if((0,a.isVideoMimeType)(l.mimetype)){u.push({property:"og:video",content:e.with({path:"/video/"+t}).toString()});const r=await i.mp4().exists()?"video/mp4":l.mimetype;u.push({property:"og:video:type",content:r},{property:"og:video:width",content:l.width.toString()},{property:"og:video:height",content:l.height.toString()})}else{const s=(await i.widths("fit")??[]).map((e=>({width:e,path:"/img/"+t+"/fit/"+e})));"image/jpeg"===l.mimetype&&s.push({width:l.width,path:"/img/"+t+"/actual"});const a=(0,r.leastBy)(s,(e=>Math.abs(e.width-n.Settings.openGraphTargetWidth.valueOrDefault)));if(null!=a){u.push({property:"og:image",content:e.with({path:a.path}).toString()},{property:"og:image:type",content:"image/jpeg"},{property:"og:image:width",content:a.width.toString()});const t=a.width/(l.width/l.height);(0,o.gt0)(t)&&u.push({property:"og:image:height",content:Math.round(t).toString()})}}return u}},18848:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cspHandler=void 0;const s=r(i(2525)),n=i(19851),a=i(50213),o=i(28874),l=i(49586),u=i(40958),c=(0,n.lazy)((()=>(0,a.mkLogger)("web.WebSecurity")));t.cspHandler=function(e,t,i){(e.secure||(0,l.isHttpsRequest)(e.headers))&&null==o.Settings.upgradeInsecureRequests.value&&(c().warn('Secure https request detected: setting "upgradeInsecureRequests" to true.'),o.Settings.upgradeInsecureRequests.tmpValue=!0);const r=(0,u.compactBlanks)(["'self'",o.Settings.cspDirective.valueOrDefault]),n=(0,u.compactBlanks)(["'self'","'strict-dynamic'",`'nonce-${t.locals.cspNonce}'`,o.Settings.cspDirective.valueOrDefault]);s.default.contentSecurityPolicy({directives:{defaultSrc:["'self'"],scriptSrc:n,styleSrc:r,baseUri:r,formAction:["'self'","https://account.photostructure.com"],objectSrc:["'none'"],upgradeInsecureRequests:o.Settings.upgradeInsecureRequests.valueOrDefault?[]:null},reportOnly:o.Settings.cspReportOnly.valueOrDefault})(e,t,i)}},81100:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.requestAssetRepair=t.ImgActualRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(51773),o=i(62327),l=i(52121),u=i(55835),c=i(31586),d=i(68708),h=i(43487),f=i(54017),m=i(94710),p=(0,n.mkLogger)("web.ImgActualRouter");function g(e){return m.Task.addOne("repairAsset",{assetId:e,forceSync:!0,forceRebuildPreviews:!0})}t.ImgActualRouter=class{constructor(e){this.previews=e}router(){return s.default.Router().get("/img/:assetId/:assetFileId/actual(.*)?",(0,a.wrap)("ImgActualRouter.assetImg",this.assetFileImg.bind(this))).get("/img/:assetId/actual(.*)?",(0,a.wrap)("ImgActualRouter.assetImg",this.assetImg.bind(this))).get("/dl/:assetId/:assetFileId",(0,a.wrap)("ImgActualRouter.assetFileImg",this.assetFileImg.bind(this)))}async assetImg(e,t){const i=(0,c.toInt)(e.params.assetId);if(!(0,c.gt0)(i))return(0,o.sendServerToast)({response:t,toast:{text:"Missing assetId in request",type:"warning"},httpStatusCode:400});const r=f.AssetFile.ops().findOneBy({assetId:i,shown:1});return null==r?(p.info("Unknown assetId",e.originalUrl),this.repairAssetLaterAndSendPreview(i,e,t)):this.sendAssetFile(e,t,r)}async assetFileImg(e,t){const i=(0,c.toInt)(e.params.assetId);if(!(0,c.gt0)(i))return(0,o.send404Toast)({response:t,text:'Request was missing "assetId"',httpStatusCode:400});const r=(0,c.toInt)(e.params.assetFileId);if(!(0,c.gt0)(r))return(0,o.send404Toast)({response:t,text:'Request was missing "assetFileId"',httpStatusCode:400});const s=f.AssetFile.ops().findOneBy({id:r,assetId:i});return null==s?(0,o.send404Toast)({response:t,text:"Bad request: no such asset file "+r}):this.sendAssetFile(e,t,s)}async sendAssetFile(e,t,i){const r=i.assetId,s=await i.posixFile_(),n=e.path.split("/").includes("dl")||(0,a.truthyQuery)(e,"dl");if(null==s||await s.isEmpty())return n?(0,o.send404Toast)({response:t,text:"Asset file "+i.uri+" was missing"}):this.repairAssetLaterAndSendPreview(r,e,t);if(n)return p.info("Sending download",{assetId:r,af:i,nativePath:s.nativePath}),t.download(s.nativePath,s.base);const c=e.headers["user-agent"],h=await(0,l.prepFileForBrowser)({nativePath:s.nativePath,userAgent:c,...(0,d.pick)(i,"width","height","sha","mimetype","rotation","mimetype")});return null==h?(p.warn("cannot send file (null result from prepFileForBrowser)",{assetId:r,af:i}),g(r),(0,o.send404Toast)({response:t,text:`Failed to get browser-friendly preview for Asset ${r}.`,details:"I'll try to fix it."})):(p.info("sendAssetFile(): sending supported file: "+h),t.sendFile(h,(e=>(0,u.map)(e,(e=>p.warn("failed to send file",{error:e,assetId:r,af:i}))))))}async repairAssetLaterAndSendPreview(e,t,i){g(e);const r=await this.previews.ap(e).largestFileForReducer("fit");null!=r?i.sendFile(r.nativePath):(h.Asset.ops().upsertOne({id:e,shown:!1}),(0,o.send404Toast)({response:i,text:`Asset ${e} is missing preview images.`,details:"I'll try to fix it, but it will be hidden for now."}))}},t.requestAssetRepair=g},4950:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ImgRouter=void 0;const s=r(i(7252)),n=i(76760),a=r(i(9288)),o=i(48884),l=i(50213),u=i(45255),c=i(81168),d=i(37628),h=i(51773),f=i(13940),m=i(28874),p=i(16170),g=i(34238),y=i(51140),v=i(11371),w=i(55835),b=i(31586),S=i(54993),P=i(54017),_=(0,l.mkLogger)("web.ImgRouter");t.ImgRouter=class{constructor(e){this.previews=e}router(){const e=(0,h.wrap)("ImgRouter",this.streamImage.bind(this));return s.default.Router().get("/img/:assetId/:reducer/:width",e)}async streamImage(e,t,i){const r=await this.getFileFromRequest(e,t);if(null!=r){if("setHeader"in t&&(0,b.gt)(r.width,500)){const e=P.AssetFile.dbl.pluckFirstf((e=>e.where({assetId:r.assetId,shown:1}).select("uri")))??"/asset-"+r.assetId+"."+r.file.ext,i=(0,w.map)(e,g.uriToBasename);if(_.debug("streamImage(): AssetFile URI",{shownUri:e,basename:i}),null!=i)try{t.setHeader("X-basename",(0,c.ensureSuffixIgnoreCase)(i,"."+r.file.ext))}catch(e){_.warn("streamImage(): setHeader error",{error:e})}else _.warn("streamImage(): failed to extract basename",{result:r})}return t.sendFile(r.file.nativePath)}}async getFileFromRequest(e,t){const i=e.params,r=(0,b.toInt)(i.assetId),s=v.ReducerNames.getCI(i.reducer)??"fit",l=(0,b.toInt)(i.width);if(null==r||null==s&&null==l)return _.warn("getFileFromRequest(): bad request",{assetId:r,reducer:s,width:l}),void t.sendStatus(y.HttpStatus.BadRequest);const h=this.previews.ap(r),g=h.fileForWidth(s,l);if(await g.exists())return{assetId:r,width:l,file:g};if(m.Settings.placeholderThumbs.valueOrDefault){const e=(0,d.stringShaToBuffer)((0,S.toS)(r)).toString("hex").slice(0,6),t=await(0,f.imageCacheDir_)();if(null==t)return;const i=t.join((0,c.splitEvery)(e,3).join(n.sep)+"-8w.png");return await i.applyIfEmpty_({fn_:t=>(0,a.default)({create:{width:8,height:8,channels:3,background:"#"+e}}).png().toFile(t.nativePath),timeoutMs:u.ShortCommandTimeoutMs}),{assetId:r,width:8,file:i}}const w=await h.widths(s)??[],P=await h.readInfo(),T=(0,p.isImageMimeType)(P?.mimetype)&&(0,p.isMimeTypeSupportedByBrowser)(P?.mimetype)?P?.width:void 0,M=(0,o.leastBy)([...w,T],(e=>(0,b.gt0)(e)&&Math.abs(l-e)));return null==M||M===l?(_.warn("Missing file, and no other widths found",{path:g.nativePath,assetId:r,reducer:s,requestedwidth:l,existingWidth:M}),void t.sendStatus(y.HttpStatus.NotFound)):M===T?(_.debug("redirecting to image actual",{assetId:r,reducer:s,width:l,f:g,existingWidth:M}),void t.redirect(["/img",r,"actual"].join("/"))):(_.debug("replacing requested width",{assetId:r,reducer:s,width:l,f:g,existingWidth:M}),void t.redirect(["/img",r,s,M].join("/")))}}},76018:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.siteManifest=t.ManifestRouter=void 0;const s=r(i(7252)),n=i(19851),a=i(50213),o=i(51773),l=i(68178),u=i(70854),c=i(28874),d=(0,n.lazy)((()=>(0,a.mkLogger)("web.ManifestRouter")));async function h({requestUri:e,id:t}){return{id:t??"com.photostructure",name:"PhotoStructure",start_url:e.with({path:c.Settings.defaultHomepagePath.valueOrDefault,query:null,fragment:null}).toString(),display:"fullscreen",icons:[{src:"/192.png",sizes:"192x192",type:"image/png"},{src:"/512.png",sizes:"512x512",type:"image/png"},{src:"/images/logo-gradient.svg",sizes:"any",type:"image/svg+xml"}],theme_color:"#845BAC",background_color:"#845BAC"}}t.ManifestRouter=class{router(){return s.default.Router().get("/site.webmanifest",(0,o.wrap)("SiteManifest",this.siteManifest.bind(this)))}async siteManifest(e,t,i){const r=await((0,u.LibraryUIDStore)()?.readUid_().catch((()=>{}))),s=(0,l.requestedUri)(e,{protocol:"http",host:c.Settings.hostname.value}),n=await h({id:r,requestUri:s});d().debug("siteManifest",n),t.type("application/manifest+json").json(n)}},t.siteManifest=h},16271:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.OpenAssetFileRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(51773),o=i(72308),l=i(31586),u=i(54017),c=(0,n.mkLogger)("web.OpenAssetFileRouter");t.OpenAssetFileRouter=class{constructor(e){this.openFileService=e}router(){return s.default.Router().get("/api/openAssetFile/:assetFileId",(0,a.wrap)("OpenAssetFileRouter.assetFile",this.assetFile.bind(this)))}async assetFile(e,t){if(c.info("assetFile(): got request",{url:e.originalUrl,ip:e.ip}),!(0,o.isLocalhost)(e.ip))return c.info("Non-localhost request",{url:e.originalUrl,ip:e.ip}),t.sendStatus(400);const i=(0,l.toInt)(e.params.assetFileId);if(!(0,l.gt0)(i))return c.info("Missing assetFileId",e.originalUrl),t.sendStatus(400);const r=u.AssetFile.ops().findOneBy({id:i});if(null==r)return c.info("Invalid assetFileId",e.originalUrl),t.sendStatus(400);const s=await r.posixFile_();return null==s||await s.clear().notExists()?(c.info("File not found",{url:e.originalUrl,af:r,file:s}),t.sendStatus(400)):(c.info("Requesting openFileService("+s.nativePath+")...",{url:e.originalUrl,ip:e.ip}),this.openFileService(s.nativePath),t.sendStatus(204))}}},24255:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PingRouter=void 0;const s=r(i(7252)),n=i(99331),a=i(51140);t.PingRouter=class{router(){return s.default.Router().get("/ping",((e,t)=>t.sendStatus((0,n.ending)()?a.HttpStatus.ServiceUnavailable:a.HttpStatus.OK)))}}},39761:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getPlansLicense=t.getPlansBilling=t.getPlansActivate=t.getPlansPick=t.PlansRouter=void 0;const s=r(i(7252)),n=i(19851),a=i(50213),o=i(88158),l=i(37805),u=i(51773),c=i(68178),d=i(33603),h=i(70114),f=i(28874),m=i(22573),p=i(42659),g=i(59455),y=(0,n.lazy)((()=>(0,a.mkLogger)("web.PlansRouter")));async function v(e,t){return await S({req:e,res:t,remotePath:"/plans/pick"})}async function w(e,t){return await S({req:e,res:t,remotePath:"/",params:{skipIndex:!0}})}async function b(e,t){return await S({req:e,res:t,remotePath:"/"})}async function S({req:e,res:t,remotePath:i,params:r={}}){const s=(0,c.requestedUri)(e).with({path:"/plans/license"}),n=await(0,d.sids)({timeoutMs:4*p.secondMs}),a=new URL("https://account.photostructure.com"+i);return a.searchParams.append("version",l.version),a.searchParams.append("uids",n.join(",")),(0,m.mapNotBlank)(f.Settings.coupon.value,(e=>a.searchParams.append("coupon",e))),a.searchParams.append("redirectToLibraryUrl",s.toString()),(0,o.mapEntries)(r,((e,t)=>a.searchParams.append(e,t))),y().info("GET /plans/pick",{redirectToLibraryUrl:s.toString()}),t.redirect(a.toString())}async function P(e,t){try{(0,m.mapNotBlankOr)(e.query.license,(async e=>{await(0,h.writeLicense)(e,3*p.secondMs),y().info("getPlansLicense(): Saved new license",e)}),(()=>{y().info("getPlansLicense(): no license in request",e.originalUrl)}))}catch(t){y().error("getPlansLicense(): Failed to save license",{err:t,url:e.originalUrl})}const i=(0,m.notBlankOr)((0,g.toA)(e.query.then)[0],"/settings");y().info("getPlansLicense(): redirecting to "+i),t.redirect(i)}t.PlansRouter=class{router(){return s.default.Router().get("/plans/pick",(0,u.wrap)("GET /plans/pick",v)).get("/plans/activate",(0,u.wrap)("GET /plans/activate",w)).get("/plans/billing",(0,u.wrap)("GET /plans/billing",b)).get("/plans/license",(0,u.wrap)("GET /plans/license",P))}},t.getPlansPick=v,t.getPlansActivate=w,t.getPlansBilling=b,t.getPlansLicense=P},37380:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressProvider=void 0;const r=i(58587),s=i(1708),n=i(89788),a=i(54557),o=i(19851),l=i(50213),u=i(56519),c=i(18454),d=i(43334),h=i(69385),f=i(40958),m=i(38639),p=i(42659),g=i(96249),y=i(49769),v=i(12236),w=i(54993),b=i(43487),S=i(54017),P=i(49796),_=(0,o.lazy)((()=>(0,l.mkLogger)("web.ProgressWithAssets")));t.ProgressProvider=class{constructor(e=10){this.maxLen=e,this.priorRecentAssets=new a.FifoCache(15,15*p.secondMs),this.testProgressStatesByVolume=new Map}async updates(){return(0,u.thenMap)(this.states(),(e=>({states:e})))}async states(){if((0,h.isPaused)())return[{volume:"⏸",state:"paused",hed:"Paused",dek:["Processing is paused. Resume via the navigation menu"+(d.isElectron?" or the system tray menu":"")+"."],recentAssetIds:[]}];const e=await c.HealthCheck.errorResults();if((0,f.isNotEmpty)(e))return _().warn("health check is failing",{errors:e}),[{volume:"⚠️",state:"paused",hed:"Health checks failed. Click for details.",dek:(0,f.uniq)((0,g.flatten)(e.map((e=>e.msg)))),recentAssetIds:[]}];const t=this.recentProgress();return _().debug("recentProgressWithAssets()",t),(0,f.isEmpty)(t)&&(0,m.isTrue)(s.env.TEST_PROGRESS)?this.testProgress():t}recentProgress(){const e=P.Progress.ops().allf((e=>e.where("updatedAt",">",Date.now()-p.minuteMs).whereNotNull("state").orderBy("volume")));(0,f.filterInPlace)(e,(e=>!(!(0,r.pidExists)(e.pid)&&"done"!==e.state&&(_().warn("Incomplete progress is from a dead process",{progress:e}),e.upsert({state:null}),1))));const t=[],i=new Set;for(const r of e){const e="done"===r.state,s=r.toSyncState(),n=this.priorRecentAssets.get((0,w.toS)(r.id))??[];if(!e){const e=((0,v.noRecentAssetIdsProgress)(s)?[]:S.AssetFile.recentAssetIdsByUriRoot((0,v.isRebuildProgress)(s)?void 0:s.uri,p.minuteMs,this.maxLen+i.size)).filter((e=>!i.has(e)&&!n.includes(e)));(0,f.isNotEmpty)(n)&&e.length>=this.maxLen&&e.splice(0,this.maxLen-1),n.unshift(...e),n.length=this.maxLen,this.priorRecentAssets.set((0,w.toS)(r.id),n);for(const e of n)i.add(e)}t.push({...s,recentAssetIds:n})}return t}async testAssetIds(e){const t=(0,y.getOrSet)(this.testProgressStatesByVolume,e,(()=>new n.BoundedList(this.maxLen))),i=b.Asset.dbl.pluckFirstf((e=>b.Asset.shownUnhidden(e).select("id").orderByRaw("random()").first()));return null!=i&&t.push(i),t.toA()}async testProgress(){const e=Math.round(Date.now()/(30*p.secondMs))%3,t=(d.isWin?["C:","D:","E:"]:["/","/home/bob/pictures","/mnt/nas"])[e];return[{volume:t,state:"processing",hed:"Processing, about 32 minutes remaining",dek:["Processing C:\\Users\\mrm\\Pictures\\20161214-pixel\\DCIM\\Camera\\IMG_20160903_090736.jpg","Processed 445 images and videos. 1,386 remain to be processed."],completePct:40,incompletePct:25,scanningPct:35,recentAssetIds:await this.testAssetIds(t)}]}}},8283:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.render=void 0;const r=i(72993),s=i(19851),n=i(50213),a=i(7282),o=i(81674),l=i(72308),u=i(45969),c=i(43334),d=i(28874),h=i(69385),f=i(38639),m=i(13538),p=i(2322),g=i(48723),y=(0,s.lazy)((()=>(0,n.mkLogger)("web.PugHelpers")));t.render=async function(e,t,i,s={}){const n=e.headers["user-agent"];t.setHeader("Feature-Policy","autoplay 'self'");const v=[],w=!0===n?.toLowerCase().includes("electron")&&(0,l.isLocalhost)(e.ip)||(0,f.isTrue)(e.query.electron);w&&(v.push("electron"),c.isMac?v.push("mac"):c.isWin?v.push("win"):c.isLinux&&v.push("linux")),(0,a.isDev)()&&v.push("is-dev"),(0,p.isChrome)(n)?v.push("chrome"):(0,p.isSafari)(n)?v.push("safari"):(0,p.isFirefox)(n)&&v.push("firefox"),(0,p.isIphone)(n)?v.push("iphone"):(0,p.isIpad)(n)&&v.push("ipad"),(0,h.isPaused)()&&v.push("is-paused"),(0,l.isLocalhost)(e.ip)&&!(0,u.isDocker)()&&v.push("is-localhost");try{!0===await(0,m.thenOrTimeout)((0,o.p)(),250)&&v.push("is-plus")}catch{}d.Settings.enableArchive.valueOrDefault&&v.push("enable-archive"),d.Settings.enableDelete.valueOrDefault&&v.push("enable-delete"),d.Settings.enableRemove.valueOrDefault&&v.push("enable-remove");const b={bodyClass:v.join(" "),isDocker:(0,u.isDocker)(),isElectron:w,isDev:a.isDev,nonce:t.locals.cspNonce,hasEmail:d.Settings.email.hasValue(),...s};y().debug("render()",{ua:n,template:i,options:b,headers:e.headers}),t.render(i,{rootTags:null==g.Tag.db()?void 0:g.Tag.roots(),title:(0,r.AppName)(),...b})}},8446:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SSEHealthRouter=void 0;const r=i(22911),s=i(18405),n=i(18454),a=i(72901),o={event:"done",data:{done:!0}};function l(e){return null==e?void 0:{event:"result",data:e}}class u extends s.ServerSentEventsRouter{constructor(){super("/sse/health")}firstEvents(e,t){return this.sendResults(t),[]}async sendResults(e){const t=[],i=[];i.push(n.HealthCheck.summary());for(const e of n.HealthCheck.all()){const r=e.toResultSync();i.push(r),("pending"===r.level||e.isStale())&&t.push(e)}e.write((0,a.mkEventStream)(...i.map(l))),this.logger.debug("sendResults (sync)",{pending:t.map((e=>e.id)),resolved:i.map((e=>e.id))});for await(const i of r.Deferred.toAsyncIterable(t.map((e=>e.result())))){const t=(0,a.mkEventStream)(l(i),l(n.HealthCheck.summary()));this.logger.debug("sendResults (async)",{result:i,chunk:t}),e.write(t)}e.write((0,a.mkEventStream)(l(n.HealthCheck.summary()),o),(()=>this.endStream(e)))}}t.SSEHealthRouter=u},44143:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SSEProgressRouter=void 0;const a=i(18405),o=i(72901),l=i(51140),u=i(40958),c=i(94383),d=i(76386);class h extends a.ServerSentEventsRouter{constructor(e){super(c.ApiProgressPath),r.add(this),this.updatesProvider=e}firstEvents(){return setTimeout((()=>n(this,r,"m",s).call(this)),250),[]}router(){return super.router().patch(d.ApiProgressPatchPath,this.onSendUpdates.bind(this))}async onSendUpdates(e,t){try{return this.logger.debug("Received PATCH, sending updates.",{remotePort:e.socket?.remotePort}),await n(this,r,"m",s).call(this),t.sendStatus(l.HttpStatus.OK)}catch(e){return this.logger.warn("onSendUpdates(): Failed to send updates",{error:e}),t.sendStatus(l.HttpStatus.InternalServerError)}}}t.SSEProgressRouter=h,r=new WeakSet,s=async function(){if(!this.ended&&!(0,u.isEmpty)(this.streams))try{const e=await this.updatesProvider.updates();if(null==e)return void this.logger.warn("Failed to fetch updates");if(this.ended)return;const t=(0,o.mkEventStream)({data:e});(0,u.filterInPlace)(this.streams,(e=>!e.destroyed));for(const e of this.streams)try{e.write(t)}catch{}}catch(e){this.logger.warn("Failed to send updates",e)}}},59898:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsRouter=void 0;const s=r(i(7252)),n=i(51168),a=i(76760),o=i(50213),l=i(7282),u=i(71567),c=i(87290),d=i(55939),h=i(34102),f=i(51773),m=i(83278),p=i(66106),g=i(81674),y=i(43205),v=i(45969),w=i(43334),b=i(4936),S=i(28874),P=i(2858),_=i(40958),T=i(22573),M=i(38639),E=i(42659),k=i(75240),D=i(98553),x=i(55835),C=i(68708),F=i(13538),A=i(12168),I=i(59455),O=i(54993),L=i(78339),R=i(57064),N=i(8283),B=(0,o.mkLogger)("web.SettingsRouter");t.SettingsRouter=class{constructor(e=c.libraryDirPosixFile,t=L.librarySettings,i=R.suggestedLibraryDirs){this.libraryDir=e,this.settings=t,this.libraryDirSuggester=i}router(){return s.default.Router().get("/setting",((e,t)=>t.redirect("/settings"))).get("/settings",(0,f.wrap)("GET /settings",this.get.bind(this))).post("/settings",(0,f.wrap)("POST /settings",this.post.bind(this)))}async get(e,t){const{err:i,libraryDir:r}=e.body;try{await(0,P.readSettings)();const s=await(0,F.thenOrTimeoutError)(this.requestSettings(e),1e3);return await(0,F.thenOrTimeoutError)(this.renderSettings(e,t,s,r,i),1e3)}catch(e){return B.warn("requestSettings() took too long. Redirecting to the health check page.",e),t.redirect("/health")}}async renderSettings(e,t,i,r,s){(0,h.ee)().emit("clearCache");let o=await this.libraryDirSuggester();if(null==(0,O.toS)(s).match(/choose a different directory/i)){const e=await R.SuggestedLibraryDir.for(r);null!=e&&o.unshift(e)}(0,_.isEmpty)(o)&&(o=void 0);const u=this.libraryDir();(0,T.blank)(s)&&(0,v.isDocker)()&&(null==u||await u.isNotDirectory())&&(s=`PS_LIBRARY_DIR, ${u?.nativePath??"/ps/library"}, doesn't exist: please add it as a bind mount.`);const c=await(0,p.getVideoToolDetails_)((0,l.isProd)()?void 0:e.query),C=await(0,d.picturesDir)(),F=await(0,g.b)(),I={err:s,...i,autoUpdateCheck:i.autoUpdateCheck??!0,allowUserAgent:i.allowUserAgent??!0,reportErrors:i.reportErrors??!0,welcome:(0,x.mapOr)((0,l.isProd)()?void 0:e.query.welcome,M.isTrue,(()=>!(0,P.libraryHasSettings)())),title:null==u?"Welcome!":"Settings",videoToolDetails:c,picturesPath:C,jsonScanPaths:(0,x.map)(S.Settings.scanPaths.value,D.stringify),delimiter:a.delimiter,exampleScanPath:[C,w.isWin?"D:\\PHOTOS":w.isMac?"/Volumes/External HD/Pictures":"/mnt/nas/homes/photos"].join(a.delimiter),currentLibraryDir:(0,x.map)(u,(e=>e.nativePath)),minFreeAvailable:(0,A.fmtBytes)(S.Settings.minDiskFreeGb.valueOrDefault*A.GB),suggestedLibraryDirs:o,samplePath:(0,b.pathToLibraryAsset)(n.DateTime.now(),m.BaseFile.for("photo.jpg")).join(a.sep),subTier:await(0,g.t)(),subTrial:(0,M.isTrue)(F?.l?.trial),subEmail:F?.l?.sub,subExpiresInDuration:(0,x.map)(F?.l?.exp,(e=>(0,k.fmtDuration)(e.getTime()-Date.now(),1))),subExpiresAt:(0,x.map)(F?.l?.exp,E.fmtIsoDate),userAgent:await(0,y.systemUserAgent)()};B.info("rendering settings",I),(0,f.disableCache)(t),await(0,N.render)(e,t,"settings",I)}async post(e,t){const i=e.body,r=(0,T.toNotBlank)("libraryDirCustom"===i.libraryDirRadio?i.libraryDir:i.libraryDirRadio),s=i=>this.renderSettings(e,t,c,r,i),n=r??S.Settings.libraryDir.valueOrDefault;if((0,T.blank)(n))return s("Please choose a directory for your library.");const o=(0,a.resolve)(n),c=await this.requestSettings(e);B.info("POST",{libraryDir:o,settings:c,body:i}),(0,l.isTest)()&&(0,u.stdoutWrite)({post:i,settings:c,method:e.method,libraryDir:o});try{const e=await(0,L.saveLibrarySettings)(o,c);if("error"in e)return B.info("error saving library settings",{result:e}),s(e.error);B.info("saved library settings. Waiting for bookkeeping to finish...",e),await e.ready,B.info("ready. Redirecting to /splash...",e)}catch(e){return s(e)}return t.redirect("/splash")}async requestSettings(e){const{scan:t,scanPath:i,copyAssets:r,autoUpdateCheck:s,allowUserAgent:n,reportErrors:a}=e.body,o=this.settings();return(0,T.notBlank)(t)&&(o.scanAllDrives="scanAllDrives"===t,o.scanPath=(0,_.compactBlanks)((0,I.toA)(i))),(0,T.notBlank)(r)&&(o.copyAssets="copyEnabled"===r),o.allowUserAgent=(0,M.toBoolean)(n),o.autoUpdateCheck=(0,M.toBoolean)(s),o.reportErrors=(0,M.toBoolean)(a),B.info("requestSettings()",{req_body:(0,C.pick)(e.body,"scan","scanPath","copyAssets","autoUpdateCheck","allowUserAgent","reportErrors"),result:o}),(0,L.librarySettings)(o)}}},77203:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SpaRouter=void 0;const s=r(i(7252)),n=i(51773),a=i(68178),o=i(75710),l=i(8283);t.SpaRouter=class{router(){const e=(0,n.wrap)("SpaRouter",this.get.bind(this));return s.default.Router().get("/tag*",e).get("/asset/:assetId",(0,n.wrap)("SpaRouter.Asset",this.getAsset.bind(this))).get("/search",e)}async getAsset(e,t,i){const r=await(0,o.getAssetOpenGraph)((0,a.requestedUri)(e),e.params.assetId);return(0,l.render)(e,t,"app",null==r?{}:{meta:r})}get(e,t,i){if(!e.path?.startsWith("/tag")||null!=(0,n.getSeedOrRedirect)(e,t))return(0,l.render)(e,t,"app",{})}}},2314:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VideoRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(51773),o=i(40958),l=i(55835),u=i(31586),c=i(54017),d=(0,n.mkLogger)("web.VideoRouter");t.VideoRouter=class{constructor(e){this.previews=e}router(){return s.default.Router().get("/video/:assetId",(0,a.wrap)("VideoRouter",this.videoImage.bind(this)))}async videoImage(e,t,i){const r=e.params,s=(0,u.toInt)(r.assetId);if(!(0,u.gt0)(s))return d.warn("Malformed request (missing assetId)",{params:e.params}),t.sendStatus(400);const n=this.previews.ap(s).mp4();if(await n.exists())return d.info("streaming transcoded video",n),t.sendFile(n.nativePath);const a=c.AssetFile.ops().findBy({assetId:s,shown:1});if((0,o.isEmpty)(a))return d.warn("Malformed request (bad assetId)",{params:e.params}),t.sendStatus(400);const h=a[0],f=await(0,l.map)(h,(e=>e.posixFile_()));return null!=f&&h.isVideo&&await f.exists()?t.sendFile(f.nativePath):(d.warn("Shown assetFile isn't a video",h),t.sendStatus(400))}}},1739:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebService=void 0;const s=r(i(7252)),n=r(i(2525)),a=r(i(77598)),o=r(i(1708)),l=i(19851),u=i(50213),c=i(97352),d=i(71567),h=i(99331),f=i(45608),m=i(56519),p=i(38835),g=i(57159),y=i(41293),v=i(27821),w=i(78147),b=i(68178),S=i(43394),P=i(62327),_=i(30576),T=i(95696),M=i(43899),E=i(8797),k=i(18454),D=i(45657),x=i(33603),C=i(39471),F=i(29325),A=i(28874),I=i(2858),O=i(63870),L=i(7014),R=i(55111),N=i(51140),B=i(93493),j=i(41400),z=i(55835),V=i(62220),W=i(13538),U=i(459),q=i(27776),H=i(64526),$=i(18449),G=i(95629),J=i(37158),K=i(8400),Y=i(13808),X=i(76020),Z=i(13831),Q=i(53881),ee=i(21598),te=i(49296),ie=i(19583),re=i(18848),se=i(81100),ne=i(4950),ae=i(76018),oe=i(16271),le=i(24255),ue=i(39761),ce=i(37380),de=i(8446),he=i(44143),fe=i(59898),me=i(77203),pe=i(2314),ge=i(98949),ye=i(43268);function ve(e,t){t.endsWith(".js")&&e.setHeader("Content-Type","application/javascript")}const we=(0,u.mkLogger)("web.WebService"),be=e=>(0,E.showFileInFolder)(T.PosixFile.for(e));t.WebService=class{constructor(){this.setup=(0,l.lazy)((async()=>{if(we.debug("setup(): started"),o.default.on("SIGPIPE",(()=>{})),A.Settings.libraryDir.watchLater((()=>Me.unset())),await(0,m.rejected)(this.service.ready))return void we.error("setup(): failed, service.ready was rejected");await(0,B.setupShimDelegates)();const e=this.app;if(e.use((new w.RequestLogger).router),e.use(((e,t,i)=>{t.locals.cspNonce=a.default.randomBytes(16).toString("hex"),i()})),A.Settings.trustProxy.hasValue()){const t=A.Settings.trustProxy.value,i="true"===t||"false"!==t&&(0,c.mapGte0Or)(t,(e=>e),t);e.set("trust proxy",i),we.info("trust proxy set",{value:i})}if(e.use(P.expressErrorHandlerWithToast),(0,$.sentryEnabled)())try{e.use(i(16436).Handlers.requestHandler())}catch(e){we.warn("Failed to initialize Sentry requestHandler",{error:e})}if(A.Settings.disabledHelmetMiddleware.valueOrDefault.includes(R.HelmetPlugins.all))we.warn("DANGER: disabledHelmetMiddleware includes 'all': not enabling any Helmet middleware.");else{A.Settings.disabledHelmetMiddleware.valueOrDefault.includes(R.HelmetPlugins.contentSecurityPolicy)||e.use(re.cspHandler);const t={contentSecurityPolicy:!1};for(const e of A.Settings.disabledHelmetMiddleware.valueOrDefault.filter((e=>e!==R.HelmetPlugins.all)))t[e]=!1;e.use((0,n.default)(t))}e.use(b.addXSettingsHandler),e.use(ye.json()),e.use(ye.urlencoded({extended:!1}));const t=M.ProjectPath.Public(),r=M.ProjectPath.Views();if(we.info("setup()",{libraryDir:A.Settings.libraryDir.valueOrDefault,publicRoot:t,viewsRoot:r}),I.libraryHasSettings.watch((()=>e.set("etag",(0,I.libraryHasSettings)()))),e.set("views",r),e.set("view engine","pug"),e.use((new le.PingRouter).router()),e.use((new y.ApiHealthRouter).router()),e.use((0,_.viewRouter)({path:"/splash",view:"splash"})),e.use((new ee.ApiSplashRouter).router()),e.use((0,_.viewRouter)({path:"/health",view:"health"})),e.use((new de.SSEHealthRouter).router()),e.use((new X.AdminPostRouter).router()),e.get("/status",((e,t)=>t.redirect("/health"))),e.use(await(0,S.serveStaticGz)(t)),e.use(s.default.static(t,{setHeaders:ve})),e.use((new Y.AboutRouter).router()),e.use((new ge.WelcomeRouter).router()),e.use((new ue.PlansRouter).router()),e.use(Te()),(0,F.isPacked)()||(e.use("/die",((e,t)=>{we.info("/die was requested",{url:e.originalUrl}),t.sendStatus(N.HttpStatus.Accepted),(0,f.exit)({reason:"/die",status:1})})),e.use("/test-sentry",((e,t)=>{(0,G.sendToSentry)(new g.WrappedError("test message sent to sentry at "+new Date)),t.sendStatus(N.HttpStatus.Accepted)}))),e.use(((e,t,i)=>(0,h.ending)()?(we.info("ending(): returning 500",{requestUri:(0,b.requestedUri)(e)}),t.sendStatus(500)):function(){const e=k.HealthCheck.runState();switch(e){case V.RunStates.loading:return Se();case V.RunStates.welcome:return _e();case V.RunStates.ready:return Me()??Me.refresh()??Pe();case V.RunStates.failed:return Pe();default:throw new U.UnreachableCaseError(e)}}()(e,t,i))),(0,$.sentryEnabled)())try{e.use(i(16436).Handlers.errorHandler())}catch(e){we.warn("Failed to initialize Sentry error handling",{error:e})}const l=A.Settings.httpPort.valueOrDefault,u=A.Settings.exposeNetworkWithoutAuth.valueOrDefault,v=H.Library.instance();null!=v?k.HealthCheck.addLoadingMsg("Loading library..."):k.HealthCheck.addLoadingMsg("Starting...");const T=async()=>{we.info("setup(): http server callback",{httpPort:l,expose:u});const e=[A.Settings.httpPort];null!=v&&e.push(A.Settings.libraryDir),(0,d.stdoutWriteSettings)(...e),null==v?((0,x.sids)((0,O.commandTimeoutMs)()).catch((e=>we.warn("failed to prefetch sids",e))),(0,L.volumes)().catch((e=>we.warn("failed to prefetch volumes",e)))):(await v.ready,Me.unset()),await(0,K.libraryHealthCheckSetup)(),await k.HealthCheck.awaitSettled(),await(0,W.thenOrTimeout)((0,D.r)(),(0,O.commandTimeoutMs)()),null!=v&&d.StdoutWrite.restartSync()},E=u?e.listen(l,T):e.listen(l,A.Settings.localhost.valueOrDefault,T);return E.on("error",(e=>{we.warn("http.server.onError()",e),"EADDRINUSE"===e.code&&(0,f.exit)({reason:"Port "+l+" is already in use: is PhotoStructure already running?"+p.FatalErrorFlag+p.DoNotSendErrorFlag+p.WebFatalErrorFlag,error:e,status:3})})),new C.EndableServer("http.WebService",E)})),this.app=(0,s.default)(),this.service=new J.Service("web"),this.setup()}};const Se=(0,l.lazy)((()=>(0,v.redirectRouter)("/splash"))),Pe=(0,l.lazy)((()=>(0,v.redirectRouter)("/health"))),_e=(0,l.lazy)((()=>(0,v.redirectRouter)("/welcome"))),Te=(0,l.lazy)((()=>(new fe.SettingsRouter).router())),Me=(0,l.lazy)((()=>{const e=H.Library.instance();if(null==e)return we.warn("libraryRouter invoked before library is set up."),void setImmediate((()=>Me.unset()));we.info("Setting up library router for "+(0,z.map)(e,(e=>e.rootDir)));const t=e.previews(),i=new ce.ProgressProvider,r=s.default.Router();return r.use((new ae.ManifestRouter).router()),r.use(new te.ApiSystemRouter(be).router()),r.use((new ie.ApiTagRouter).router()),r.use(new Z.ApiAssetRouter(t).router()),r.use((new Q.ApiSearchRouter).router()),r.use((new me.SpaRouter).router()),r.use(new oe.OpenAssetFileRouter(be).router()),r.use(new se.ImgActualRouter(t).router()),r.use(new ne.ImgRouter(t).router()),r.use(new pe.VideoRouter(t).router()),r.use(new he.SSEProgressRouter(i).router()),r.use("/",((e,t)=>{we.debug("in root route",{res_headersSent:t.headersSent,res_headers:t.getHeaders()}),t.redirect(302,(0,q.mkHomeFullPath)(e.query))})),r}));(0,j.later)((()=>{A.Settings.libraryDir.watchLater((()=>Me.unset()))}))},98949:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WelcomeRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(51773),o=i(18454),l=i(81674),u=i(28874),c=i(51140),d=i(57064),h=i(39761),f=i(8283);t.WelcomeRouter=class{constructor(){this.logger=(0,n.mkLogger)("WelcomeRouter")}router(){return s.default.Router().get("/welcome",(0,a.wrap)("GET /welcome",this.get.bind(this))).post("/welcome",(0,a.wrap)("POST /welcome",this.post.bind(this)))}async get(e,t){return"welcome"!==o.HealthCheck.runState()?t.redirect(c.HttpStatus.Found,"/"):((0,d.suggestedLibraryDirs)(),(0,f.render)(e,t,"welcome",{}))}async post(e,t){return!u.Settings.pickPlanOnWelcome.valueOrDefault||await(0,l.p)()?t.redirect("/settings"):(0,h.getPlansPick)(e,t)}}},90858:e=>{"use strict";e.exports=require("@iarna/toml")},53705:e=>{"use strict";e.exports=require("@photostructure/tz-lookup")},16436:e=>{"use strict";e.exports=require("@sentry/node")},64770:e=>{"use strict";e.exports=require("assert")},58587:e=>{"use strict";e.exports=require("batch-cluster")},87550:e=>{"use strict";e.exports=require("better-sqlite3")},43268:e=>{"use strict";e.exports=require("body-parser")},6858:e=>{"use strict";e.exports=require("commander")},36507:e=>{"use strict";e.exports=require("croner")},66261:e=>{"use strict";e.exports=require("events")},77988:e=>{"use strict";e.exports=require("exiftool-vendored")},7252:e=>{"use strict";e.exports=require("express")},66150:e=>{"use strict";e.exports=require("fast-xml-parser")},68817:e=>{"use strict";e.exports=require("file-type")},44652:e=>{"use strict";e.exports=require("fs-extra")},28787:e=>{"use strict";e.exports=require("he")},2525:e=>{"use strict";e.exports=require("helmet")},31832:e=>{"use strict";e.exports=require("knex")},51168:e=>{"use strict";e.exports=require("luxon")},93973:e=>{"use strict";e.exports=require("ml-kmeans")},80265:e=>{"use strict";e.exports=require("moo")},31704:e=>{"use strict";e.exports=require("nearley")},4927:e=>{"use strict";e.exports=require("papaparse")},83058:e=>{"use strict";e.exports=require("picomatch")},22915:e=>{"use strict";e.exports=require("platform-folders")},57272:e=>{"use strict";e.exports=require("plist")},85949:e=>{"use strict";e.exports=require("process")},90595:e=>{"use strict";e.exports=require("punycode")},38064:e=>{"use strict";e.exports=require("semver")},9288:e=>{"use strict";e.exports=require("sharp")},93944:e=>{"use strict";e.exports=require("source-map-support")},49378:e=>{"use strict";e.exports=require("trash")},73872:e=>{"use strict";e.exports=require("type-detect")},92460:e=>{"use strict";e.exports=require("util")},75162:e=>{"use strict";e.exports=require("util/types")},29907:e=>{"use strict";e.exports=require("cluster")},76982:e=>{"use strict";e.exports=require("crypto")},34589:e=>{"use strict";e.exports=require("node:assert")},31421:e=>{"use strict";e.exports=require("node:child_process")},77598:e=>{"use strict";e.exports=require("node:crypto")},40610:e=>{"use strict";e.exports=require("node:dns")},78474:e=>{"use strict";e.exports=require("node:events")},73024:e=>{"use strict";e.exports=require("node:fs")},51455:e=>{"use strict";e.exports=require("node:fs/promises")},37067:e=>{"use strict";e.exports=require("node:http")},44708:e=>{"use strict";e.exports=require("node:https")},77030:e=>{"use strict";e.exports=require("node:net")},48161:e=>{"use strict";e.exports=require("node:os")},76760:e=>{"use strict";e.exports=require("node:path")},53916:e=>{"use strict";e.exports=require("node:path/posix")},1708:e=>{"use strict";e.exports=require("node:process")},57075:e=>{"use strict";e.exports=require("node:stream")},46466:e=>{"use strict";e.exports=require("node:stream/promises")},87997:e=>{"use strict";e.exports=require("node:timers")},57975:e=>{"use strict";e.exports=require("node:util")},38522:e=>{"use strict";e.exports=require("node:zlib")},16928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=5379);module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{var __webpack_modules__={60308:e=>{const t={PasetoNotSupported:"ERR_PASETO_NOT_SUPPORTED",PasetoDecryptionFailed:"ERR_PASETO_DECRYPTION_FAILED",PasetoInvalid:"ERR_PASETO_INVALID",PasetoVerificationFailed:"ERR_PASETO_VERIFICATION_FAILED",PasetoClaimInvalid:"ERR_PASETO_CLAIM_INVALID"};class i extends Error{constructor(e){super(e),this.name=this.constructor.name,this.code=t[this.constructor.name],Error.captureStackTrace(this,this.constructor)}}e.exports.PasetoError=i,e.exports.PasetoNotSupported=class extends i{},e.exports.PasetoDecryptionFailed=class extends i{},e.exports.PasetoInvalid=class extends i{},e.exports.PasetoVerificationFailed=class extends i{},e.exports.PasetoClaimInvalid=class extends i{}},78972:(e,t,i)=>{const{PasetoInvalid:r,PasetoNotSupported:s}=i(60308),{decode:n}=i(47859),a=i(40816);e.exports=(e,{parse:t=!0}={})=>{if("string"!=typeof e)throw new TypeError("token must be a string");const{0:i,1:o,2:l,3:u,length:c}=e.split(".");if(3!==c&&4!==c)throw new r("token is not a PASETO formatted value");if("v1"!==i&&"v2"!==i&&"v3"!==i&&"v4"!==i)throw new s("unsupported PASETO version");if("local"!==o&&"public"!==o)throw new s("unsupported PASETO purpose");const d={footer:u?n(u):void 0,payload:void 0,version:i,purpose:o};if("local"===o)return d;const h="v1"===i?256:"v3"===i?96:64;let f;try{f=n(l).subarray(0,-h)}catch{throw new r("token is not a PASETO formatted value")}return d.payload=t?a(f):f,d}},2744:(e,t,i)=>{const r=i(78972);e.exports={decode:r}},67814:(e,t,i)=>{const r=i(85223);e.exports=({audience:e,expiresIn:t,iat:i=!0,issuer:s,jti:n,kid:a,notBefore:o,now:l=new Date,subject:u},c)=>{if(!(l instanceof Date&&l.getTime()))throw new TypeError("options.now must be a valid Date object");const d=l.getTime();if(void 0!==i){if("boolean"!=typeof i)throw new TypeError("options.iat must be a boolean");i&&(c.iat=new Date(d))}if(void 0!==t){if("string"!=typeof t)throw new TypeError("options.expiresIn must be a string");c.exp=new Date(d+r(t))}if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.notBefore must be a string");c.nbf=new Date(d+r(o))}if(void 0!==e){if("string"!=typeof e)throw new TypeError("options.audience must be a string");c.aud=e}if(void 0!==s){if("string"!=typeof s)throw new TypeError("options.issuer must be a string");c.iss=s}if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.subject must be a string");c.sub=u}if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.kid must be a string");c.kid=a}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.jti must be a string");c.jti=n}return c}},10968:(e,t,i)=>{const{PasetoClaimInvalid:r}=i(60308),s=i(85223);e.exports=({ignoreExp:e,ignoreNbf:t,ignoreIat:i,maxTokenAge:n,subject:a,issuer:o,clockTolerance:l,audience:u,now:c=new Date},d)=>{if(!(c instanceof Date&&c.getTime()))throw new TypeError("options.now must be a valid Date object");const h=c.getTime();if("iss"in d&&"string"!=typeof d.iss)throw new r("payload.iss must be a string");if(void 0!==o){if("string"!=typeof o)throw new TypeError("options.issuer must be a string");if(d.iss!==o)throw new r("issuer mismatch")}if("sub"in d&&"string"!=typeof d.sub)throw new r("payload.sub must be a string");if(void 0!==a){if("string"!=typeof a)throw new TypeError("options.subject must be a string");if(d.sub!==a)throw new r("subject mismatch")}if("aud"in d&&"string"!=typeof d.aud)throw new r("payload.aud must be a string");if(void 0!==u){if("string"!=typeof u)throw new TypeError("options.audience must be a string");if(d.aud!==u)throw new r("audience mismatch")}if(void 0!==l&&"string"!=typeof l)throw new TypeError("options.clockTolerance must be a string");const f=l?s(l):0;let m;if("iat"in d){if("string"!=typeof d.iat)throw new r("payload.iat must be a string");if(m=new Date(d.iat).getTime(),!m)throw new r("payload.iat must be a valid ISO8601 string");if(!i&&m>h+f)throw new r("token issued in the future")}if("nbf"in d){if("string"!=typeof d.nbf)throw new r("payload.nbf must be a string");const e=new Date(d.nbf).getTime();if(!e)throw new r("payload.nbf must be a valid ISO8601 string");if(!t&&e>h+f)throw new r("token is not active yet")}if("exp"in d){if("string"!=typeof d.exp)throw new r("payload.exp must be a string");const t=new Date(d.exp).getTime();if(!t)throw new r("payload.exp must be a valid ISO8601 string");if(!e&&t<=h-f)throw new r("token is expired")}if(void 0!==n){if("string"!=typeof n)throw new TypeError("options.maxTokenAge must be a string");if(!("iat"in d))throw new r("missing iat claim");if(m+s(n){e.exports.encode=e=>e.toString("base64url"),e.exports.decode=e=>Buffer.from(e,"base64")},80608:e=>{e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if("string"!=typeof e)throw new TypeError("options.assertion must be a string, or a Buffer");return Buffer.from(e,"utf8")}},83561:(e,t,i)=>{const r=i(65825);e.exports=function(e){if(void 0===e)return Buffer.from("");if(Buffer.isBuffer(e))return e;if(r(e))return Buffer.from(JSON.stringify(e),"utf8");if("string"!=typeof e)throw new TypeError("options.footer must be a string, Buffer, or a plain object");return Buffer.from(e,"utf8")}},1658:(e,t,i)=>{const r=i(67814),s=i(65825);e.exports=(e,t)=>{if(Buffer.isBuffer(e)){if(0!==Object.keys(t).length)throw new TypeError("options cannot contain claims when payload is a Buffer");return e}if(!s(e))throw new TypeError("payload must be a Buffer or a plain object");return e=(e=>JSON.parse(JSON.stringify(e)))(e),e=r(t,e),Buffer.from(JSON.stringify(e),"utf-8")}},82115:e=>{e.exports=e=>{const{x:t,y:i}=e.export({format:"jwk"}),r=Buffer.from(i,"base64"),s=2+(1&r[r.length-1]);return Buffer.concat([Buffer.alloc(1,s),Buffer.from(t,"base64")])}},88965:(e,t,i)=>{const r=i(64770),{PasetoInvalid:s}=i(60308),n=i(10968),{decode:a}=i(47859),o=i(40816);e.exports={post:function(e,t,i,r,s,a,l){if(t){if(0!==Object.keys(i).length)throw new TypeError("options cannot contain claims when options.buffer is true");return r?{payload:s,footer:a?.length?a:void 0,version:e,purpose:l}:s}const u=o(s);return n(i,u),r?{payload:u,footer:a?.length?a:void 0,version:e,purpose:l}:u},pre:function(e,t){if("string"!=typeof t)throw new TypeError("token must be a string, got: "+typeof t);if(t.slice(0,e.length)!==e)throw new s(`token is not a ${e.slice(0,e.length-1)} PASETO`);let{0:i,1:n="",length:o}=t.slice(e.length).split(".");try{r(o<=2),i=a(i),n=a(n)}catch{throw new s("token is not a PASETO formatted value")}return{raw:i,f:n}}}},56463:(e,t,i)=>{const r=i(76982),s=i(92460),n=i(70761),a=i(29534),{PasetoDecryptionFailed:o}=i(60308),l=i(82682),{webcrypto:{subtle:u}}=r,c=s.promisify(r.hkdf),d=Buffer.from("paseto-encryption-key"),h=Buffer.from("paseto-auth-key-for-aead"),f=Buffer.alloc(0),m=(e,t)=>r.createHmac("sha384",t).update(e).digest(),p=async(e,t,i,r)=>u[e]({name:"AES-CTR",counter:r,length:16},await u.importKey("raw",i,"AES-CTR",!1,[e]),t).then(Buffer.from),g=p.bind(void 0,"encrypt"),y=p.bind(void 0,"decrypt");e.exports={sign:s.promisify(r.sign),verify:s.promisify(r.verify),"v1.local-encrypt":async function(e,t,i){const s="v1.local.",o=m(e,r.randomBytes(32)).subarray(0,32),l=o.subarray(0,16),[u,f]=await Promise.all([c("sha384",i,l,d,32).then(Buffer.from),c("sha384",i,l,h,32).then(Buffer.from)]),p=await g(e,u,o.subarray(16)),y=n(s,o,p,t),v=m(y,f);return a(s,t,o,p,v)},"v1.local-decrypt":async function(e,t,i){const r=e.subarray(0,32),s=e.subarray(-48),a=e.subarray(32,-48),u=r.subarray(0,16),[f,p]=await Promise.all([c("sha384",i,u,d,32).then(Buffer.from),c("sha384",i,u,h,32).then(Buffer.from)]),g=n("v1.local.",r,a,t),v=m(g,p);if(!l(s,v))throw new o("decryption failed");const w=await y(a,f,r.subarray(16));if(!w)throw new o("decryption failed");return w},"v3.local-encrypt":async function(e,t,i,s){const o="v3.local.",l=r.randomBytes(32),[u,p]=await Promise.all([c("sha384",i,f,Buffer.concat([d,l]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,l]),48).then(Buffer.from)]),y=u.subarray(0,32),v=u.subarray(32),w=await g(e,y,v),b=n(o,l,w,t,s),S=m(b,p);return a(o,t,l,w,S)},"v3.local-decrypt":async function(e,t,i,r){const s=e.subarray(0,32),a=e.subarray(-48),u=e.subarray(32,-48),[p,g]=await Promise.all([c("sha384",i,f,Buffer.concat([d,s]),48).then(Buffer.from),c("sha384",i,f,Buffer.concat([h,s]),48).then(Buffer.from)]),v=p.subarray(0,32),w=p.subarray(32),b=n("v3.local.",s,u,t,r),S=m(b,g);if(!l(a,S))throw new o("decryption failed");const P=await y(u,v,w);if(!P)throw new o("decryption failed");return P}}},70981:(e,t,i)=>{const{KeyObject:r}=i(76982);let{isKeyObject:s}=i(75162);s||(s=e=>null!=e&&e instanceof r),e.exports=s},65825:e=>{e.exports=e=>!!e&&e.constructor===Object},41726:(e,t,i)=>{const{PasetoNotSupported:r}=i(60308);e.exports=e=>{if(!Number.isSafeInteger(e))throw new r("message is too long for Node.js to safely process");const t=~~(e/4294967295),i=e%4294967295-t,s=Buffer.allocUnsafe(8);return s.writeUInt32LE(t,4),s.writeUInt32LE(i,0),s}},85223:e=>{const t=36e5,i=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i;e.exports=e=>{const r=i.exec(e);if(!r)throw new TypeError(`invalid time period format ("${e}")`);const s=parseFloat(r[1]);switch(r[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(1e3*s);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(6e4*s);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(s*t);case"day":case"days":case"d":return Math.round(864e5*s);case"week":case"weeks":case"w":return Math.round(6048e5*s);case"year":case"years":case"yr":case"yrs":case"y":return Math.round(315576e5*s)}}},29534:(e,t,i)=>{const{encode:r}=i(47859);e.exports=function(e,t,...i){let s=`${e}${r(Buffer.concat(i))}`;return t.byteLength&&(s+=`.${r(t)}`),s}},70761:(e,t,i)=>{const r=i(41726);e.exports=(...e)=>{e=e.filter(Boolean);let t=r(e.length);for(let i of e){i=Buffer.from(i,"utf8");const e=r(Buffer.byteLength(i));t=Buffer.concat([t,e,i])}return t}},40816:(e,t,i)=>{const{PasetoInvalid:r}=i(60308),{strict:s}=i(64770),n=i(65825);e.exports=e=>{try{const t=JSON.parse(e);return s(n(t)),t}catch{throw new r("All PASETO payloads MUST be a JSON object")}}},92366:(e,t,i)=>{const{sign:r}=i(56463),s=i(70761),n=i(29534);e.exports=async function(e,t,i,a,o,l,u){const c=s(u,e,t,i,l),d=await r(a,c,o);return n(e,i,t,d)}},495:(e,t,i)=>{const{createSecretKey:r}=i(76982),s=i(70981);e.exports=function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}`)&&(t=Buffer.from(t.slice(e.length),"base64url")),!s(t))try{t=r(t)}catch{}if(!s(t))throw new TypeError("invalid key provided");if("secret"!==t.type||32!==t.symmetricKeySize)throw new TypeError(`${e} secret key must be 32 bytes long symmetric key`);return t}},82682:(e,t,i)=>{const{timingSafeEqual:r}=i(76982),s=(e,t)=>{if(e.length===t)return e;const i=Buffer.alloc(t);return e.copy(i),i};e.exports=(e,t)=>{const i=Math.max(e.length,t.length);return r(s(e,i),s(t,i))}},49826:(e,t,i)=>{const{PasetoVerificationFailed:r}=i(60308),{verify:s}=i(56463),n=i(70761),{pre:a}=i(88965);e.exports=async function(e,t,i,o,l,u,c){const{raw:d,f:h}=a(e,t),f=d.subarray(0,-o),m=d.subarray(-o),p=n(c,e,f,h,u);if(!await s(i,p,l,m))throw new r("invalid signature");return{m:f,footer:h.length?h:void 0}}},91227:(e,t,i)=>{const r=i(60308),s=i(79665),n=i(56120),a=i(50015),o=i(64230),{decode:l}=i(2744);e.exports={decode:l,V1:s,V2:n,V3:a,V4:o,errors:r}},39324:(e,t,i)=>{const{"v1.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v1.local"),{pre:n,post:a}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:o=!1,...l}={}){const{raw:u,f:c}=n("v1.local.",e),d=(t=s(t)).export(),h=await r(u,c,d);return a("v1",o,l,i,h,c,"local")}},21472:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v1.local"),n=i(1658),{"v1.local-encrypt":a}=i(56463);e.exports=async function(e,t,{footer:i,...o}={}){const l=n(e,o);t=s(t);const u=r(i),c=t.export();return a(l,u,c)}},79665:(e,t,i)=>{const r=i(77868),s=i(77256),n=i(21472),a=i(39324),o=i(70866);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o}},70866:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=s(r.generateKeyPair),o=s(r.generateKey);e.exports=async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await o("aes",{length:256});return"paserk"===t?`k1.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await a("rsa",{modulusLength:2048});return"paserk"===t?{secretKey:`k1.secret.${e.export({format:"der",type:"pkcs1"}).toString("base64url")}`,publicKey:`k1.public.${i.export({format:"der",type:"pkcs1"}).toString("base64url")}`}:e}default:throw new n("unsupported v1 purpose")}}},77868:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPrivateKey:n}=i(76982),a=i(83561),o=i(1658),l=i(92366),u=i(70981);e.exports=async function(e,t,{footer:i,...c}={}){const d=o(e,c),h=a(i);return t=function(e){if("string"==typeof e&&e.startsWith("k1.secret."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!u(e))try{e=n(e)}catch{}if(!u(e))throw new TypeError("invalid key provided");if("private"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public signing key must be a private RSA key with 2048 bit modulus length");return e}(t),l("v1.public.",d,h,"sha384",{key:t,padding:r,saltLength:s})}},77256:(e,t,i)=>{const{constants:{RSA_PKCS1_PSS_PADDING:r,RSA_PSS_SALTLEN_DIGEST:s},createPublicKey:n}=i(76982),a=i(49826),o=i(70981),{post:l}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:u=!1,...c}={}){t=function(e){if("string"==typeof e&&e.startsWith("k1.public."))try{const t=Buffer.from(e.slice(10),"base64url");e={key:t,format:"der",type:"pkcs1"}}catch{}if(!o(e)||"private"===e.type)try{e=n(e)}catch{}if(!o(e))throw new TypeError("invalid key provided");if("public"!==e.type||"rsa"!==e.asymmetricKeyType||2048!==e.asymmetricKeyDetails.modulusLength)throw new TypeError("v1.public verify key must be a public RSA key with 2048 bit modulus length");return e}(t);const{m:d,footer:h}=await a("v1.public.",e,"sha384",256,{key:t,padding:r,saltLength:s});return l("v1",u,c,i,d,h,"public")}},56120:(e,t,i)=>{const r=i(88451),s=i(859),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(62827);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},62827:(e,t,i)=>{const r=i(64770),s=i(76982),{promisify:n}=i(92460),{PasetoNotSupported:a}=i(60308),o=i(70981),l=n(s.generateKeyPair);async function u(e,t,{format:i="keyobject"}={}){if("keyobject"!==i&&"paserk"!==i)throw new TypeError("invalid format");if("public"===t){const{privateKey:t,publicKey:r}=await l("ed25519");return"paserk"===i?{secretKey:`k${e.slice(1)}.secret.${h(t).toString("base64url")}`,publicKey:`k${e.slice(1)}.public.${h(r).toString("base64url")}`}:t}throw new a(`unsupported ${e} purpose`)}function c(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 64:{const t=s.createPrivateKey({key:Buffer.concat([Buffer.from("302e020100300506032b657004220420","hex"),e.subarray(0,32)]),format:"der",type:"pkcs8"});if(!e.subarray(32).equals(Buffer.from(t.export({format:"jwk"}).x,"base64")))throw new TypeError("invalid byte sequence");return t}case 32:return s.createPublicKey({key:Buffer.concat([Buffer.from("302a300506032b6570032100","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 64 bytes (private key), or 32 bytes (public key)")}}function d(e,t){if(!o(t))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public key must be an Ed25519 key`);switch(t.type){case"public":return Buffer.from(t.export({format:"jwk"}).x,"base64");case"private":{const{d:e,x:i}=t.export({format:"jwk"});return Buffer.concat([Buffer.from(e,"base64"),Buffer.from(i,"base64")])}}}function h(...e){return d("v2",...e)}e.exports={_checkPrivateKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.secret.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,64)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t))try{t=s.createPrivateKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("private"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public signing key must be a private ed25519 key`);return t},_checkPublicKey:function(e,t){if("string"==typeof t&&t.startsWith(`k${e.slice(1)}.public.`))try{t=Buffer.from(t.slice(10),"base64url"),r.strictEqual(t.byteLength,32)}catch{}if(Buffer.isBuffer(t))try{t=c(t)}catch{}if(!o(t)||"private"===t.type)try{t=s.createPublicKey(t)}catch{}if(!o(t))throw new TypeError("invalid key provided");if("public"!==t.type||"ed25519"!==t.asymmetricKeyType)throw new TypeError(`${e}.public verify key must be a public ed25519 key`);return t},_generateKey:u,_keyObjectToBytes:d,bytesToKeyObject:c,generateKey:async function(...e){return u("v2",...e)},keyObjectToBytes:h}},88451:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(92366),{_checkPrivateKey:a}=i(62827),o=a.bind(void 0,"v2");e.exports=async function(e,t,{footer:i,...a}={}){const l=s(e,a);t=o(t);const u=r(i);return n("v2.public.",l,u,void 0,t)}},859:(e,t,i)=>{const r=i(49826),{_checkPublicKey:s}=i(62827),{post:n}=i(88965),a=s.bind(void 0,"v2");e.exports=async function(e,t,{complete:i=!1,buffer:s=!1,...o}={}){t=a(t);const{m:l,footer:u}=await r("v2.public.",e,void 0,64,t);return n("v2",s,o,i,l,u,"public")}},18582:(e,t,i)=>{const{"v3.local-decrypt":r}=i(56463),s=i(495).bind(void 0,"v3.local"),n=i(80608),{pre:a,post:o}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:l=!1,assertion:u,...c}={}){const{raw:d,f:h}=a("v3.local.",e);t=s(t);const f=n(u),m=t.export(),p=await r(d,h,m,f);return o("v3",l,c,i,p,h,"local")}},43406:(e,t,i)=>{const r=i(83561),s=i(495).bind(void 0,"v3.local"),n=i(1658),a=i(80608),{"v3.local-encrypt":o}=i(56463);e.exports=async function(e,t,{footer:i,assertion:l,...u}={}){const c=n(e,u);t=s(t);const d=r(i),h=a(l),f=t.export();return o(c,d,f,h)}},50015:(e,t,i)=>{const r=i(42438),s=i(65466),n=i(43406),a=i(18582),{generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}=i(80568);e.exports={sign:r,verify:s,encrypt:n,decrypt:a,generateKey:o,bytesToKeyObject:l,keyObjectToBytes:u}},80568:(e,t,i)=>{const r=i(76982),{promisify:s}=i(92460),{PasetoNotSupported:n}=i(60308),a=i(70981),o=i(82115),l=s(r.generateKeyPair),u=s(r.generateKey);function c(e){if(!a(e))throw new TypeError("keyObject must be a KeyObject instance");if("secret"===e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public key must be an EC P-384 key");switch(e.type){case"public":return o(e);case"private":return Buffer.from(e.export({format:"jwk"}).d,"base64")}}e.exports={generateKey:async function(e,{format:t="keyobject"}={}){if("keyobject"!==t&&"paserk"!==t)throw new TypeError("invalid format");switch(e){case"local":{const e=await u("aes",{length:256});return"paserk"===t?`k3.local.${e.export().toString("base64url")}`:e}case"public":{const{privateKey:e,publicKey:i}=await l("ec",{namedCurve:"P-384"});return"paserk"===t?{secretKey:`k3.secret.${c(e).toString("base64url")}`,publicKey:`k3.public.${c(i).toString("base64url")}`}:e}default:throw new n("unsupported v3 purpose")}},bytesToKeyObject:function(e){if(!Buffer.isBuffer(e))throw new TypeError("bytes must be a Buffer");switch(e.byteLength){case 48:return r.createPrivateKey({key:Buffer.concat([Buffer.from("303e0201010430","hex"),e,Buffer.from("a00706052b81040022","hex")]),format:"der",type:"sec1"});case 49:if(2!==e[0]&&3!==e[0])throw new TypeError("invalid compressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3046301006072a8648ce3d020106052b81040022033200","hex"),e]),format:"der",type:"spki"});case 97:if(4!==e[0])throw new TypeError("invalid uncompressed public key");return r.createPublicKey({key:Buffer.concat([Buffer.from("3076301006072a8648ce3d020106052b81040022036200","hex"),e]),format:"der",type:"spki"});default:throw new TypeError("bytes must be 48 bytes (private key), 49 bytes (compressed public key), or 97 bytes (uncompressed public key)")}},keyObjectToBytes:c}},42438:(e,t,i)=>{const{createPrivateKey:r}=i(76982),s=i(83561),n=i(1658),a=i(80608),o=i(92366),l=i(70981),{bytesToKeyObject:u}=i(80568),c=i(82115);e.exports=async function(e,t,{footer:i,assertion:d,...h}={}){const f=n(e,h),m=s(i),p=a(d);return t=function(e){if("string"==typeof e&&e.startsWith("k3.secret."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,48)}catch{}if(Buffer.isBuffer(e))try{e=u(e)}catch{}if(!l(e))try{e=r(e)}catch{}if(!l(e))throw new TypeError("invalid key provided");if("private"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public signing key must be a private EC P-384 key");return e}(t),o("v3.public.",f,m,"sha384",{key:t,dsaEncoding:"ieee-p1363"},p,c(t))}},65466:(e,t,i)=>{const{createPublicKey:r}=i(76982),s=i(80608),n=i(49826),a=i(70981),{bytesToKeyObject:o}=i(80568),l=i(82115),{post:u}=i(88965);e.exports=async function(e,t,{complete:i=!1,buffer:c=!1,assertion:d,...h}={}){t=function(e){if("string"==typeof e&&e.startsWith("k3.public."))try{e=Buffer.from(e.slice(10),"base64url"),assert.strictEqual(e.byteLength,49)}catch{}if(Buffer.isBuffer(e))try{e=o(e)}catch{}if(!a(e)||"private"===e.type)try{e=r(e)}catch{}if(!a(e))throw new TypeError("invalid key provided");if("public"!==e.type||"ec"!==e.asymmetricKeyType||"secp384r1"!==e.asymmetricKeyDetails.namedCurve)throw new TypeError("v3.public verify key must be a public EC P-384 key");return e}(t);const f=s(d),{m,footer:p}=await n("v3.public.",e,"sha384",96,{key:t,dsaEncoding:"ieee-p1363"},f,l(t));return u("v3",c,h,i,m,p,"public")}},64230:(e,t,i)=>{const r=i(29901),s=i(77933),{generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}=i(24961);e.exports={sign:r,verify:s,generateKey:n,bytesToKeyObject:a,keyObjectToBytes:o}},24961:(e,t,i)=>{const{_checkPrivateKey:r,_checkPublicKey:s,_generateKey:n,_keyObjectToBytes:a,bytesToKeyObject:o}=i(62827);e.exports={_checkPrivateKey:r,_checkPublicKey:s,bytesToKeyObject:o,generateKey:async function(...e){return n("v4",...e)},keyObjectToBytes:function(...e){return a("v4",...e)}}},29901:(e,t,i)=>{const r=i(83561),s=i(1658),n=i(80608),a=i(92366),{_checkPrivateKey:o}=i(24961),l=o.bind(void 0,"v4");e.exports=async function(e,t,{footer:i,assertion:o,...u}={}){const c=s(e,u),d=n(o);t=l(t);const h=r(i);return a("v4.public.",c,h,void 0,t,d)}},77933:(e,t,i)=>{const r=i(80608),s=i(49826),{_checkPublicKey:n}=i(24961),{post:a}=i(88965),o=n.bind(void 0,"v4");e.exports=async function(e,t,{complete:i=!1,buffer:n=!1,assertion:l,...u}={}){t=o(t);const c=r(l),{m:d,footer:h}=await s("v4.public.",e,void 0,64,t,c);return a("v4",n,u,i,d,h,"public")}},37975:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const r=i(22573),s=i(38639),n=i(44198);function a(){return(0,s.toNotBoolean)((0,n.env)().PS_LOG_COLOR)??(!(0,r.blank)((0,n.env)().NO_COLOR)||["dumb","unknown"].includes((0,n.env)().TERM))}t.noColor=a;let o=!a();function l(){return o}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){o=e??!a()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const r=i(19851),s=i(7282),n=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,r.lazy)((()=>t.SimpleAppName+((0,s.isProd)()?"":`-${(0,s.nodeEnv)()}`))),t.AppNameVersion=(0,r.lazy)((()=>(0,t.AppName)()+" "+n.version))},48884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const r=i(40958),s=i(36783),n=i(76790),a=i(22573),o=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=r.primitiveValueOfOrElse){const s=new Set(t.map(i));return e.filter((e=>s.has(i(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...v(e.slice(i+1))]}function w(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let r=0;re?.[r])));return t}function b(e){return P(e,(e=>e.valueOf()))}function S(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function T(e,t){return(0,r.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,i){return E(e,t,i).index}function E(e,t,i){if((0,r.isEmpty)(e))return{index:-1,value:void 0};let s,n=-1;for(let r=0;re.slice(i,i+t)))}async function D(e,t){return(0,r.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,o.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(a.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const r=e[i];if(null!=r&&!0===await t(r))return r}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null!=r){const e=await t(r,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,r.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let r=i;r<=e.length-1;r++)if(t(e[r]))return r},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,r.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,o.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,s.copyArrayTo)((0,r.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],r=[];let s=0;for(const n of e)(t(n,s++)?i:r).push(n);return[i,r]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,r.compact)((0,r.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const r=(0,c.times)(t,(()=>new Array(i)));for(let s=0;se.slice(0,t+1)))},t.min=function(e){return e[b(e)]},t.leastIndex=b,t.max=function(e){return e[S(e)]},t.greatestIndex=S,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=T,t.least=function(e){return T(e,(e=>e))},t.greatestBy=function(e,t){return(0,r.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const i=E(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=k,t.collectBatched=function(e,t,i){const s=[];for(const n of k((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(i(n)));return s},t.collectBatchedAsync=async function(e,t,i){const s=[];for(const n of k((0,r.compact)((0,f.toA)(e)),t))s.push(...(0,r.compact)(await i(n)));return s},t.contextFilter=function(e,t){let i;return e.filter(((e,r)=>(0,d.tap)(t(e,r,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.some((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterEvery=function(e,t){const i=[];for(const r of e){const e=i.find((e=>e.every((e=>t(r,e)))));e?e.push(r):i.push([r])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const r of e){for(const e of i)if(null!=r&&await D(e,(e=>t(r,e)))){e.push(r);continue e}null!=r&&i.push([r])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[r],(e=>i(e,r))))return r}{const r=t+s;if(re+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const o=i(77988),l=a(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),v=i(25764),w=i(38836),b=i(99331),S=i(95937),P=i(98314),_=i(38835),T=i(70025),M=i(8769),E=i(43334),k=i(95402),D=i(28874),x=i(63870);class C extends w.EndableWrapper{constructor(e,t,i=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>n(this,r,"m",s).call(this)),i,"worker"===e?(0,x.commandTimeoutMs)():y.ShortCommandTimeoutMs),r.add(this),this.t=t;const a=t;a.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,k.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),a.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),a.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,S.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),a.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),a.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),a.on("noTaskData",((e,i,r)=>{const s=t.options.streamFlushMillis;s{this.logger.error("observeBatchCluster.endError()",e)})),a.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&k.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof o.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,b.ending)()||!0===(0,T.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=C,r=new WeakSet,s=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(E.isWin?3:1)*c.minuteMs,maxTasksPerProcess:D.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:D.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:D.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:D.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:D.Settings.taskTimeoutMs.valueOrDefault}}},71371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedGreatestSet=void 0;const r=i(92322);t.BoundedGreatestSet=class{constructor(e,t){this.maxLength=e,this.toValue=t,this.sortedArray=new r.SortedSet(t)}toA(){return this.vacuum(),this.sortedArray.toA()}vacuum(){return this.sortedArray.retainLastN(this.maxLength)}add(...e){this.maxLength<=0||(this.sortedArray.addAll(...e),this.sortedArray.length>=2*this.maxLength&&this.vacuum())}}},89788:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(r.add(this),this.maxLength=e,s.set(this,void 0),n.set(this,0),a.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,s,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,r,"m",o).call(this,e,(e=>u(this,s,"f")[e]=t))}get length(){return u(this,n,"f")}set length(e){l(this,n,(0,d.clamp)(0,u(this,n,"f"),e),"f")}clear(){this.length=0}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,n,"f")),e<0||e>=u(this,n,"f")?void 0:t((e+u(this,a,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,s,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,n,"f"){u(this,s,"f")[e]=c}));return u(this,n,"f")}pop(){return u(this,r,"m",o).call(this,u(this,n,"f")-1,(e=>{var t;return l(this,n,(t=u(this,n,"f"),--t),"f"),u(this,s,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,n,"f"){u(this,s,"f")[e]=c,l(this,a,e,"f")}));return u(this,n,"f")}shift(){return u(this,r,"m",o).call(this,0,(e=>{var t,i;return l(this,a,(t=u(this,a,"f"),++t),"f"),l(this,n,(i=u(this,n,"f"),--i),"f"),u(this,s,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,r,"m",o).call(this,u(this,n,"f")-1-e,(e=>{const i=u(this,s,"f")[e];u(this,s,"f")[e]=u(this,s,"f")[t],u(this,s,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const r=i(54993),s=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function n(e){for(const{bom:t,encoding:i}of s)if(a(e,t))return e.subarray(t.length).toString(i);return e.toString()}function a(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=n,t.bufferToString=function(e){return Buffer.isBuffer(e)?n(e):(0,r.toS)(e)},t.bufferStartsWith=a},9092:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=s},36638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const r=i(94863);class s{constructor(e=[],t=r.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=s},40583:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const a=i(40958),o=i(23838),l=n(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new o.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,a.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let r,s=-1;for(const[i,n]of this.m.entries()){const a=(0,c.diceCoeff)(i,e);if(a>t&&a>s){const e=this.getFirst(n);null!=e&&(r=e,s=a)}}return r}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const r=i(76790),s=i(31586),n=i(68708),a=i(54993),o=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new o.Average(0);for(const t of this.keys()){if(!(0,s.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,a.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,r.sortBy)([...this.entries()],(([t,i])=>[-i,(0,s.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,n.tap)(new o.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,r.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,r.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[r,s]of this.m.entries()){const n=e(r);t.fill(n,i,i+s),i+=s}return t}}t.CountingSet=u},79840:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const r=i(19851),s=i(72993),n=i(45969),a=i(43334);t.EditionType=(0,r.lazy)((()=>a.isElectron?"Desktops":(0,n.isDocker)()?"Docker":"Servers")),t.EditionName=(0,r.lazy)((()=>s.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const r=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,r.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const r=i(50357),s=i(55835),n=i(68708);var a=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return a.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,r.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,r.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,s.map2Or)(await e,await t,r.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,r.eql)((0,n.omit)(e,...i),(0,n.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,s.map2Or)(await e,await t,((e,t)=>(0,r.eql)((0,n.pick)(e,...i),(0,n.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const r=i(31658),s=i(19851),n=i(95696);t.examples=(0,s.lazy)((()=>n.PosixFile.for((0,r.examplesNativePath_)())))},31658:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const r=i(19851),s=i(65843),n=i(29882);t.examplesNativePath_=(0,r.lazy)((()=>{const e=(0,s.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,n.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(31586),o=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,a.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,a.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,s.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[r.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,s.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,n.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,o.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,o.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,o.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,a.isNumber)(e.__uid)&&(0,a.isNumber)(e.__start)}},80049:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,r.set(this,0),s.set(this,0),n.set(this,0),a.set(this,0),o.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,r,l(this,r,"f")+e.cacheHitsSync,"f"),u(this,s,l(this,s,"f")+e.cacheHitsAsync,"f"),u(this,n,l(this,n,"f")+e.cacheMisses,"f"),u(this,a,l(this,a,"f")+e.rejections,"f"),u(this,o,l(this,o,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,r,"f"),cacheHitsAsync:l(this,s,"f"),cacheMisses:l(this,n,"f"),rejections:l(this,a,"f"),timeouts:l(this,o,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,a,o;if(!this.cache.has(e))return void u(this,n,(t=l(this,n,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,s,(i=l(this,s,"f"),++i),"f"),c.promise):(u(this,r,(a=l(this,r,"f"),++a),"f"),c.value)}if(c instanceof Error)throw c;return u(this,r,(o=l(this,r,"f"),++o),"f"),c}get(e){var t,i;const s=this.cache.get(e);return null==s||s instanceof m.Deferred&&s.isPending?u(this,n,(t=l(this,n,"f"),++t),"f"):u(this,r,(i=l(this,r,"f"),++i),"f"),s instanceof m.Deferred?s.value:s}clear(){this.cache.clear(),u(this,r,0,"f"),u(this,s,0,"f"),u(this,n,0,"f"),u(this,a,0,"f"),u(this,o,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const r=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,r),(0,c.gt0)(this.opts.timeoutMs)&&r.setTimeout(this.opts.timeoutMs),r.promise.then((e=>{this.set(i,e)}),(e=>{var t,r;this.cache.set(i,e),u(this,a,(t=l(this,a,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,o,(r=l(this,o,"f"),++r),"f")})),r.promise}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap},54127:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class r{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=r},53507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,r.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const r=(0,a.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,s.range)(0,r).filter((e=>this.rows.every((t=>(0,n.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,o.fromEntries)(e))).filter((e=>(0,o.values)(e).some(n.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let r,o=0;for(;null!=(r=t.exec(this.headerRow));){const l=this.headerRow.substring(o,r.index);(0,n.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:r.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(r.index,t.lastIndex),d=r.index+((0,c.indexOfNonSpace)(u)??0),h=r.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:r,left:d,right:h});else{const e=(0,s.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,a.max_)(e?.rightIdx,r.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}o=t.lastIndex}const l=(0,s.last)(i);return null!=l&&((0,n.blank)(this.headerRow.slice(o))?l.rightIdx=(0,a.max_)(...this.rows.map((e=>e.length))):l.rightIdx=o),i}}t.Fixed=m},73168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const r=i(55835),s=i(20014),n=i(55222),a=i(97352),o=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,a.within)(-90,90,e)&&0!==e}function c(e){return(0,a.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function h(e,t,i=o){return(0,r.map)(m(e,t,l(i)),(e=>n.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=o){return h(e?.lat,e?.lon,t)},t.geohash=h,t.geohashNumericShort=function(e,t){return m(e,t,30)};const f=new s.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=o){return d(e,t)?f.zip([t,e],l(i)):void 0}function p(e,t=o){return f.unzip(e,l(t))?.reverse()}function g(e,t=o){const[i,r]=p(e,t);return{lat:i,lon:r}}t.geohashNumeric=m,t.ungeohash=function(e,t=o){return(0,r.map)(n.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,r=t.lat*Math.PI/180,s=(t.lat-e.lat)*Math.PI/180,n=(t.lon-e.lon)*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(r)*Math.sin(n/2)*Math.sin(n/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},66364:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSuspended=void 0;const r=i(19851);t.isSuspended=(0,r.lazy)((()=>!1))},80875:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const r=i(51455),s=i(98553);var n=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return n.parseJSON}}),t.mapParsed=function(e,t){const i=(0,s.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,s.parseJSON)((await(0,r.readFile)(e)).toString())}},57206:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDefaultJsonRevivers=void 0;const r=i(77988),s=i(51168),n=i(45599),a=i(98553),o=i(68708),l=i(24689),u=i(21330),c=i(57159),d=i(28544),h=(0,n.defer)((()=>{s.DateTime.prototype.toJSON=function(){return(0,o.compactValues)({_ctor:s.DateTime.name,ts:this.toMillis(),zone:"system"===this.zone?.type?void 0:this.zoneName})}})),f={name:s.DateTime.name,fromJSON:e=>s.DateTime.fromMillis(e.ts,(0,o.compactValues)({zone:e.zone}))};t.addDefaultJsonRevivers=(0,n.defer)((()=>{h(),(0,a.addJsonRevivers)(r.ExifDateTime,r.ExifDate,r.ExifTime,f,d.CapturedAt,l.DateInterval,u.FuzzyDate,r.BinaryField,c.WrappedError)}))},19851:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const a=i(57975),o=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),r.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&n(this,r,"m",s).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,o.isEmpty)(this.watchers))return;const i=await e,r=await t;if(!(0,l.eql)(i,r))for(const e of this.watchers)e(r);null!=this.ttlMs&&this.ttlMs>0&&void 0!==r&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,r.lazy)((()=>(0,o.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=b(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>S(v()??await(m.isWin?P():m.isMac?T():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,r.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function b(e){if((0,n.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=w.exec(e.trim())?.groups;return null==i?void 0:(0,s.compact)([i.lang,i.country]).join("-")}function S(e){return b(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=S,t.localeWin=P;const _={timeoutMs:10*a.secondMs};async function T(){return b(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return S(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=T,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const r=i(48161),s=i(1708),n=i(45599),a=i(68708),o=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,n.defer)((()=>{(0,o.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:s.argv,arch:(0,r.arch)(),platform:(0,r.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,a.pick)(s.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:s.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const r=i(19851),s=i(32105),n=i(14593);t.rootLoggers=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));const a=(0,r.lazy)((()=>[s.ConsoleLogger.instance()]));t.mkLogger=function(e){return new n.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new n.ContextualLogger(e,a)}},56639:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const r=i(40958),s=i(55835),n=i(59455),a=i(48884);function o(e){const t=(0,r.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,a.concat)(...e.map((e=>t(e)))))},t.compactMap=o,t.toMap=function(e,t){return o((0,r.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:o(await Promise.all((0,r.compact)((0,n.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,r]of e)t[i]=r;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,r])=>t(i,r)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,s.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const r=i(98553),s=i(54557);t.memoize=function(e,t){let i=0;const n=new s.FifoCache(t.maxSize,t.ttlMs),a=t=>{if(null!=t)return i++,n.getOrSet((0,r.stringify)(t),(()=>e(t)))};return a.clear=e=>null==e?n.clear():n.delete((0,r.stringify)(e)),a.size=()=>n.size,a.callCount=()=>i,a}},31578:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const r=i(1708),s=i(31586),n=i(12168),a=i(70417);function o(){const e=(0,r.memoryUsage)();return(0,a.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,r.memoryUsage)().rss}t.memoryUsageBytes=o,t.memoryUsageMb=function(){return(0,s.sigFigs)(o()/n.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,s.sigFigs)(l()/n.MB,2)}},7282:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const s=r(i(1708)),n=i(38639),a=i(54993),o=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,o.lazy)((()=>s.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,a.toS)(s.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return s.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,n.isTrue)(s.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){s.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},26033:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._isSupportedNode=t.RequiredNodeRange=t.isSupportedNode=void 0;const r=i(45599),s=i(76280);function n(e=process.versions.node){return(0,s.semverSatisfies)(e,t.RequiredNodeRange)}t.isSupportedNode=(0,r.defer)(n),t.RequiredNodeRange="18||20||21",t._isSupportedNode=n},97352:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55835),o=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,o.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(o.gt0)},t.firstNonZero=function(...e){for(const t of(0,n.flatten)(e)){const e=(0,o.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,a.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,o.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const r=(0,o.toInt)(e),s=(0,o.toInt)(t);return null!=r&&r>0&&null!=s&&s>0?i(r,s):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,o.isNumber)(e))return e;if((0,s.blank)(e))return;const t=String(e);return(0,a.map)(f.exec(t),(e=>(0,o.toFloat)(t.substr(e.index))))}function p(e){return(0,o.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),r=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,r,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let r=0;re/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,a.map)(g(e,t),(([e,t])=>(0,r.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,a.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,r.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let r=0;const s=i*e.length;for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const r=i(40958),s=i(42659),n=i(96249),a=i(55835),o=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,s.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[r,s]of(0,l.entries)(e)){const e=t(r,s);null!=e&&(i[r]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,a.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(a.defined)},t.firstDefinedField=function(e,...t){return(0,a.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,a.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,r.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,r]of m(t))null==e[i]&&(e[i]=r);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,r]of(0,l.entries)(t))null==e[i]&&(e[i]=r);return e},t.pickMap=function(e,t,i){const r={};for(const s of t)r[s]=i(s,e[s]);return r},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const r={};let s=0;for(const n of(0,l.keys)(e))if(r[n]=t(n,e[n]),s++,(0,o.gt)(s,i))break;return r},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const r of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[r]=e(t[r]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,r)=>i.includes(t)?void 0:e(r,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,r.uniq)((0,n.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const r=i(31421),s=i(73024),n=i(48161),a=i(19851),o=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),v=i(30933),w=(0,a.lazy)((()=>(0,f.mkLogger)("os")));function b(){return(0,n.platform)()+" "+(0,n.release)()}t.osArch=(0,a.lazy)((()=>`${function(){switch((0,n.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return C();case"win32":return F();default:return b()}}()} on ${(0,n.arch)()}`)),t.osFullName=(0,a.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const S=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function _(){return"ubuntu"===(0,t.osDistributionLinux)()}function T(){return"fedora"===(0,t.osDistributionLinux)()}function M(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,a.lazy)((()=>{if(g.isLinux)for(const e of S)try{const t=(0,s.readFileSync)(e).toString();if((0,o.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,a.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,o.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),b)})),t.osDistributionLinux=(0,a.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=_,t.hasApt=function(){return P()||_()},t.isFedora=T,t.isAlpine=M;const E={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},k={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function D(e,t){const[i,r]=function(e){return e.split(".").slice(0,2)}(e),s=t[i];return(0,c.isString)(s)?s:s?.[r]}const x=(0,a.lazy)((()=>(0,r.execSync)("sw_vers -productVersion").toString().trim()));function C(e=x()){try{return(0,o.mapNotBlankOr)(function(e=x()){return D(e,E)}(e),(t=>`macOS ${t} (${e})`),b)}catch(e){return w().warn("osNameMac(): unknown release",e),b()}}function F(e=(0,n.release)()){const t=e.startsWith("10.0.22")?"11":D(e,k);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=C,t.osNameWin=F,t.CPUs=(0,a.lazy)((()=>(0,h.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,a.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(F())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=x();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(_())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(T())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(M())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},45393:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetVersion=t.AssetFileVersion=void 0,t.AssetFileVersion=12,t.AssetVersion=4},12801:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const s=r(i(48161)),n=i(50989);t.PriorityClasses=(0,n.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:s.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:s.default.constants.priority.PRIORITY_NORMAL,BelowNormal:s.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:s.default.constants.priority.PRIORITY_LOW,Low:s.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setProcessTitle=t.setShortProcessNames=void 0;const r=i(72993),s=i(50213),n=i(23560),a=i(43334);let o=!a.isElectron;t.setShortProcessNames=function(e){o=e},t.setProcessTitle=function(){try{const e=[o?r.SimpleShortAppName:r.SimpleAppName];(0,n.isMainService)()&&a.isElectron||e.push((0,n.serviceName)());const t=e.join(a.isElectron?" ":"-");i(85949).title=t}catch(e){(0,s.mkLogger)("ServiceNames").warn("Failed to set friendly process name",e)}}},92782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.safeRandomUid=t.safeRandomChars=void 0;const r=i(55222),s=i(65713);t.safeRandomChars=function({radix:e=r.TokenRadix,length:t}){return(0,s.decuss)((()=>e.randomChars(t)))},t.safeRandomUid=function(e){return(0,s.decuss)((()=>(e?.radix??r.TokenRadix).randomUid(e?.chars??20,e?.splitEveryN??5,e?.sepChar??"-")))}},409:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const r=i(41400),s=i(56409),n=i(31586),a=i(22911),o=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...r){f=!0,m=Date.now()+(0,n.max_)(t,i);const s=d=new a.Deferred(c);(0,n.gt0)(i)&&s.setTimeout(i);try{s.resolve(await e(...r))}catch(e){s.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,o.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return s.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,r.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new s.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const r=i(68708),s=i(54993);function n(e){return e instanceof a?e.source:(0,s.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let s;for(;null!=(s=e.exec(t));)s.index===e.lastIndex?e.lastIndex++:i.push((0,r.pick)(s,"index","groups"));return i},t.escapeRegExp=n,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const r=[];for(const t of e)try{r.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{r.push(n(t))}const s=0===r.length?t.NothingRegExp:r.map((e=>"(?:"+e+")")).join("|");return new RegExp(s,i)};class a{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=a;class o extends a{static from(...e){const t=l(e);return new o("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",r=t?.includes("g")??!1,o=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof a||t instanceof RegExp?(i+=t.source,r||(r=t.global),o||(o=t.ignoreCase),l||(l=t.multiline)):i+=n((0,s.toS)(t));return new RegExp(i,t??(r?"g":"")+(o?"i":"")+(l?"m":""))}t.RegExpOptional=o,t.concatRegexp=l},79089:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),v=i(34102),w=i(43334),b=i(24399),S=i(28874),P=(0,a.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,a.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",n.default.basename(S.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,o.compactBlanks)([n.default.basename(e),...t.map((e=>n.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let T=!0;const M=(0,a.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const i=(0,p.priorityPosixToClass)(t)??S.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),T)try{return s.default.setPriority(e,t),t}catch(i){const r=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:r,error:i}),r)return;T=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await b.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const s=r(i(1708)),n=i(19851),a=i(40958),o=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===o.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===o.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===o.ServiceNames.sync}function p(){return(0,t.serviceName)()===o.ServiceNames.test}t.serviceName=(0,n.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,n.lazy)((()=>(0,a.compactBlanks)([t.serviceName.prior(),(0,l.toS)(s.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return o.ServiceNames.indexOf(e)??o.ServiceNames.length+1},t.MainServices=[o.ServiceNames.main,o.ServiceNames.desktop],t.DbServices=[o.ServiceNames.sync,o.ServiceNames.info,o.ServiceNames.web,o.ServiceNames.list,o.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[o.ServiceNames.sync,o.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===o.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===o.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,n.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const r=i(59455);function s(e){return e instanceof Set?e:new Set((0,r.toA)(e))}t.asSet=s,t.setEql=function(e,t){return(0,r.toA)(e.keys()).every((e=>t.has(e)))&&(0,r.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=s(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=s(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const r=i(5670),s=i(57150),n=i(7282),a=i(23560),o=i(17181);t.setServiceName=function(e){(0,a.isMainService)(e)&&(e=r.ServiceNames.main);const t=a.serviceName.prior();t!==e&&((0,n.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),a.serviceName.set(e),(0,o.setupLogger)(),(0,s.logStartup)())}},28850:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const o=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends o.ExtensibleFunction{constructor(e,t){super(),this.impl=t,r.set(this,void 0),s.set(this,void 0),n(this,r,e,"f")}_call(){return(0,l.time)(a(this,r,"f")+(null==a(this,s,"f")?"(local)":"(remote)"),null==a(this,s,"f")?this.impl():a(this,s,"f").call(this))}setShim(e){n(this,s,e,"f")}hasShim(){return null!=a(this,s,"f")}clearShim(){n(this,s,void 0,"f")}}r=new WeakMap,s=new WeakMap},12089:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,a){super(),r.add(this),this.impl=t,this.cache=i,this.toKey=a,s.set(this,void 0),n.set(this,void 0),l(this,s,e,"f")}async _call(e){return null==this.cache?u(this,r,"m",o).call(this,e):this.cache().getOrSetAsync(u(this,r,"m",a).call(this,e),(()=>u(this,r,"m",o).call(this,e)))}setShim(e){l(this,n,e,"f")}hasShim(){return null!=u(this,n,"f")}clearShim(){l(this,n,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,r,"m",a).call(this,e))}}s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},o=function(e){return(0,m.time)(u(this,s,"f")+(null==u(this,n,"f")?"(local)":"(remote)"),null==u(this,n,"f")?this.impl(e):u(this,n,"f").call(this,e))}},45255:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const r=i(42659);t.ShortCommandTimeoutMs=7*r.secondMs},92322:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const n=i(76790),a=i(17586);class o{constructor(e,t){this.valueOf=e,this.diff=t,r.set(this,[])}[(r=new WeakMap,Symbol.iterator)](){return s(this,r,"f")[Symbol.iterator]()}get length(){return s(this,r,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=s(this,r,"f").length-1;for(;t<=i;){const n=t+Math.floor((i-t)/2),a=this.valueOf(s(this,r,"f")[n]);if(e===a)return{found:!0,index:n};e>a?t=n+1:i=n-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&s(this,r,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...s(this,r,"f")];const a=t=>t<0||t>s(this,r,"f").length-1?null:(i??this.diff)(s(this,r,"f")[t],e),o=this.findIndex(e);if(null==o)return;let l=o.index-1,u=a(l),c=o.index,d=a(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return s(this,r,"f").shift()}at(e){return(0,a.at)(s(this,r,"f"),e)}toA(){return[...s(this,r,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===s(this,r,"f").length-1){const e=[...s(this,r,"f")];return s(this,r,"f").length=0,e}return s(this,r,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return s(this,r,"f").splice(e,t)}retainLastN(e){return e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const r=i(1708),s=i(82328),n=i(84542),a=i(95705),o=i(28874);t.consoleLog=function(e,...t){o.Settings.quiet.valueOrDefault||(0,s.stdoutEnded)()||console.log((0,n.crlf)(e),...t)},t.consoleError=function(e){o.Settings.quiet.valueOrDefault||(0,a.streamEnded)(r.stderr)||r.stderr.write(e)},t.quietly=async function(e){const t=o.Settings.quiet.envValue;try{return o.Settings.quiet.envValue=!0,await e()}finally{o.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const r=i(1708),s=i(95705);t.stdoutEnded=function(){return(0,s.streamEnded)(r.stdout)}},71567:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const s=r(i(1708)),n=i(22573),a=i(98553),o=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:s.default.stdout})}function f({obj:e,ready:i,stream:r}){if(null==r||(0,d.streamEnded)(r))return;const s=(0,a.stringify)(e,void 0,(0,o.isInfoService)()||(0,o.isMainService)()?2:void 0);r.write(s+"\n"),(0,o.isWorkerService)()&&null!=i&&(s.includes(u.FailStr)||(0,c.isFatalError)(s)||(0,c.isHealthCheckError)(s)?r.write(u.FailStr+"\n"):r.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||s.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:s.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,n.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const r=String(e);return r+(0,l.padding)(i,t-r.length)},t.padReplace=function(e,t,i,r){return(0,c.strslice)(e,0,t)+(0,l.padding)(r,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,r=0){if(null==i||0===i.length)return 0;const s=t.indexOf(i,r);return-1===s?0:1+e(t,i,s+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,n.notBlank)(e)))},t.splitEvery=function(e,t,i){const r=Math.min(Math.ceil(e.length/t),i??e.length)-1;return r<=0?[e]:[...(0,o.times)(r,(i=>e.slice(i*t,(i+1)*t))),e.slice(r*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const r=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,r)+e.substring(r+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:r}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const r=(0,h.toS)(e),s=(0,h.toS)(t);return s.length>0&&(0,c.equalsIgnoreCase)(r.slice(-s.length),s,i)?r.slice(0,-s.length):r},t.gist=function(e,t=80,i=80){const r=(0,h.toS)(e),s=r.length-(t+i);return s<=0?r:r.slice(0,t).trim()+" …(+"+s+" chars)…"+r.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function b(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function S(e){return(0,d.toA)(e).sort(b)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,n.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=b,t.uniqIgnoreCase=function(e){return(0,r.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=S,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,a.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=b(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,r.isEmpty)(e)||(0,n.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),r=e.toLowerCase(),s=t.indexOf(r);if(s>=0)return{index:s,match:r}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function T(e){return _.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=T;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,n.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(T(e))&&(e=e.slice(1,-1).trim())),e};const E=/^['‘’].*['‘’]$/,k=/^["“”„«»〃].*["“”„«»〃]$/;function D(e,t){const i=x(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function x(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],r=[];let s,n=0;for(;null!=(s=t.exec(e));)s.index===t.lastIndex?t.lastIndex++:(t.lastIndex=s[0].length+s.index,i.push(e.substring(n,s.index)),r.push(e.substring(s.index,t.lastIndex)),n=t.lastIndex);return n(0,o.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),E.test(e)||k.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,r.compactBlanks)(e),s=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,a.map)(i[e],(e=>t+=e))));return t},t.splitKeep=D,t.splitUp=x,t.sortNaturalBy=C,t.sortNatural=function(e){return(0,s.sortBy)(e,(e=>C(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=S((0,r.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,s.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,n.blank)(e)||(0,n.blank)(t))return"";const i=Math.min(e.length,t.length);for(let r=0;r4===e?.length?(0,o.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const F=/#.*$/gm;t.stripComments=function(e){return e.replace(F,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const r of(0,d.toA)(e))if(null!=r&&!(0,n.blank)(r))for(const e of r.split(t))(0,n.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,n.blank)(t))return e;const r=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),s=e.findIndex((e=>r.test(e))),a=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(s<0)return e;for(let t=s+1;te.trim()))))}},83556:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const r=i(54993);function s(e){return(0,r.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,r.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=s,t.asObjectKey=function(e){return s(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const s=r(i(77598)),n=i(73913),a=i(55222);function o(e,t=n.HashBits){return s.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=a.Radix58,r=224){return i.encodeBuffer(o(e,r)).substring(0,t)}t.stringShaToBuffer=o,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=a.GeoRadix,r=224){return l(e,t,i,r)}},94863:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const r=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,r.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(31586),o=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let r=0,s="";for(let n=0;n=r&&(r=i.get(n,a),s=(0,l.substr)(e,n-r+1,r)));return s}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const r=e.normalize(),s=t.normalize();return e!==r||t!==s?y(r,s):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,r)=>i===t.charAt(r)?e:e+1),0)}function v(e,t){const i=e.toUpperCase().normalize(),r=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===r?1:void 0),(()=>(0,n.blank)(e)!==(0,n.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(i),t=w(r);return 2*b(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function b(e,t){const i=(0,f.intersection)(e,t),s=[];return i.forEach((i=>{const n=Math.min((0,r.count)(e,(e=>e===i)),(0,r.count)(t,(e=>e===i)));(0,a.times)(n,(()=>s.push(i)))})),s}function S(e,t,i){const s=(0,r.commonPrefixLength)(e,t);return i((0,l.strslice)(e,s))-i((0,l.strslice)(t,s))}function P(e){const t=(0,r.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,s.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[i,r]=[e,t].map(P).map((e=>(0,n.blank)(e)?"":e));return S(i,r,(e=>(0,a.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(n.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=b,t.lnsDiff=_;const T=/[^\da-z]+/gi;function M(e,t){const[i,r]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(T,"").toLowerCase()));return S(i,r,(e=>c.RadixAlphaNum.decode(e)))}function E(e,t){let i;for(let r=Math.max(e.length,t.length);r>=0;r--){const s=(0,a.mapNumericOr)(e.charCodeAt(r),(e=>e),256),n=(0,a.mapNumericOr)(t.charCodeAt(r),(e=>e),256),o=(0,a.clamp)(-256,256,s-n);i=null==i?o:(i+o)/2}return i}t.radixDiff=M,t.str=function(e,t){return{pref:(0,r.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,r.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=E,t.paddedPositionalDiff=function(e,t,i=8){return E((0,o.leftPad)(e,i," "),(0,o.leftPad)(t,i," "))}},84885:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const r=i(98553),s=i(88158);t.stringifySorted=function(e){return(0,r.stringify)((0,s.sortedKeys)(e))}},88264:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TTLArray=void 0;const r=i(31586);class s{constructor(e,t){this.ttlMs=e,this.maxLength=t,this.times=[],this.a=[],this.expirationListeners=[]}[Symbol.iterator](){this.vacuum();const e=[...this.a];return function*(){for(const t of e)yield t}()}push(...e){(0,r.times)(e.length,(()=>this.times.push(Date.now()))),this.a.push(...e),null!=this.maxLength&&this.vacuum()}pushUniq(...e){e.forEach((e=>{this.includes(e)||this.push(e)}))}includes(e){return this.vacuum(),this.a.indexOf(e)>=0}find(e){return this.vacuum(),this.a.find(e)}some(e){return this.vacuum(),this.a.some(e)}shift(){return this.vacuum(),this.times.shift(),this.a.shift()}first(){return this.vacuum(),this.a[0]}last(){return this.vacuum(),this.a[this.a.length-1]}shiftOrFirst(){return this.length>1?this.shift():this.first()}pop(){return this.vacuum(),this.times.pop(),this.a.pop()}onExpire(e){this.expirationListeners.push(e)}slice(e,t){return this.vacuum(),this.a.slice(e,t)}get length(){return this.vacuum(),this.a.length}clear(){return this.times.length=0,this.a.length=0,this}get values(){return this.vacuum(),[...this.a]}map(e){return this.vacuum(),this.a.map(e)}oldestEntryAge(){return this.vacuum(),this.times[0]}vacuum(){if(0===this.a.length)return;const e=this.a.length;if(null!=this.maxLength){const e=this.a.length-this.maxLength;this.times.splice(0,e),this.a.splice(0,e)}const t=Date.now()-this.ttlMs,i=this.times.findIndex((e=>e>t));if(-1===i?this.clear():i>0&&(this.times.splice(0,i),this.a.splice(0,i)),e!==this.a.length)for(const e of this.expirationListeners)e()}}t.TTLArray=s},75387:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){r.add(this),this[c]="TTLMap",s.set(this,[]),n.set(this,new Map),a.set(this,void 0),o.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,a,"f")}set ttlMs(e){h(this,a,e,"f"),null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),h(this,o,(0,p.setUnrefInterval)((()=>d(this,r,"m",u).call(this)),e),"f"),d(this,r,"m",u).call(this)}destroy(){null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),this.ttlMs=-m.dayMs,d(this,r,"m",u).call(this)}clear(){return d(this,n,"f").clear(),this}delete(e){return d(this,n,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,n,"f").entries())d(this,r,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,n,"f").get(e);return d(this,r,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,n,"f").get(e);if(d(this,r,"m",l).call(this,e,i))return i.v;const s=t();return null!=s&&this.set(e,s),s}lastSetOrGetTs(e){return d(this,n,"f").get(e)?.ts}set(e,t){return d(this,n,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,r,"m",l).call(this,e,d(this,n,"f").get(e))}get size(){return d(this,r,"m",u).call(this),d(this,n,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,r,"m",u).call(this),(0,f.sortBy)(d(this,n,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,n,"f").entries())d(e,r,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,s,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,n,"f").delete(e);for(const i of d(this,s,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,n,"f").entries())d(this,r,"m",l).call(this,e,t)}},22277:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){r.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[a]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return o(this,r,"m",n).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>o(this,r,"m",n).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||o(this,r,"m",s).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)o(this,r,"m",s).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!o(this,r,"m",s).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,r,"m",s).call(e,t,i)||(yield[t,t])}()}toA(){return o(this,r,"m",n).call(this),[...this.delegate.keys()]}[(r=new WeakSet,a=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,s=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},n=function(){for(const[e,t]of this.delegate)o(this,r,"m",s).call(this,e,t)}},84699:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},65211:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resetUid=t.sortByUid=t.tsFromUid=t.isUID=t.uidForTs=t.uid=t.uidSuffix=void 0;const r=i(19851),s=i(76790),n=i(22573),a=i(54993),o=i(7282),l=i(55222);let u=0;const c=l.GeoRadix;function d(e){return c.encode(e)+(0,t.uidSuffix)()}t.uidSuffix=(0,r.lazy)((()=>"-"+c.randomChars(7))),t.uid=function(){return u=Math.max(Date.now(),u+1),d(u)},t.uidForTs=d;const h=/^[\da-z]{9}-[\da-z]{7}$/i;function f(e){const t=(0,a.toS)(e).replace(/(?<=\S)-.*/,"");return(0,n.blank)(t)?void 0:c.decode(t)}t.isUID=function(e){return h.test((0,a.toS)(e))},t.tsFromUid=f,t.sortByUid=function(e){return(0,s.sortBy)(e,(e=>f(e.uid)))},t.resetUid=function(){if(!(0,o.isTest)())throw new Error("unsupported");t.uidSuffix.unset(),u=0}},94174:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,a.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,a.lazy)((()=>(0,o.uniq)([n.default.geteuid?.(),n.default.getuid?.(),s.default.userInfo().uid]))),t.userid=(0,a.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,a.lazy)((()=>(0,o.uniq)([n.default.getegid?.(),n.default.getgid?.(),s.default.userInfo().gid]))),t.groupid=(0,a.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,a.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,a.lazy)((()=>(0,l.toNotBlank)(s.default.userInfo()?.username))),t.userNameFromWhoami=(0,a.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,a.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,a.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,a.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.1-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=1,t.versionPrerelease=["prealpha"],t.release="2024.3.1-prealpha+20240308150212",t.gitSha="d92384e8659ff46fbae8e6f81fa5867114a4a843",t.gitDate=new Date(1709938932e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48299:function(e,t){"use strict";var i,r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.WeakCache=void 0;class o{constructor(){i.add(this),this[n]="WeakCache",r.set(this,new Map)}clear(){return a(this,r,"f").clear(),this}delete(e){return a(this,r,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of this.entries())e(i,t,this)}findEntry(e){for(const[t,i]of this.entries())if(e(i,t,this))return i}deleteValueIf(e){for(const[t,i]of this.entries())e(i,t,this)&&a(this,r,"f").delete(t)}get(e){const t=a(this,r,"f").get(e),i=t?.deref();return null==i&&null!=t&&a(this,r,"f").delete(e),i}getOrMaybeSet(e,t){const i=a(this,r,"f").get(e)?.deref();if(null!=i)return i;const s=t();return null!=s&&this.set(e,s),s}set(e,t){return a(this,r,"f").set(e,new WeakRef(t)),this}has(e){return null!=a(this,r,"f").get(e)?.deref()}get size(){return a(this,i,"m",s).call(this),a(this,r,"f").size}keys(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries())null==i.deref()?a(e,r,"f").delete(t):yield t}()}values(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield s}}()}entries(){const e=this;return function*(){for(const[t,i]of a(e,r,"f").entries()){const s=i.deref();null==s?a(e,r,"f").delete(t):yield[t,s]}}()}[(r=new WeakMap,i=new WeakSet,n=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}}t.WeakCache=o,s=function(){for(const[e,t]of a(this,r,"f").entries())null==t.deref()&&a(this,r,"f").delete(e)}},48963:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const r=i(42659),s=i(55835),n=i(31586),a=i(97790),o=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,n.toInt)(e)));if(!(0,s.allDefined)(i))return;const[a,o,u,c,d,h,f]=i,m=(0,n.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(a,o-1,u,c,d,h,f/1e3)-m*r.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,a.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(n.toInt).filter((e=>(0,o.within)(0,Date.now()+r.dayMs,e))).map((e=>new Date(e))).get()}},79184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aggregateAssetFiles=void 0;const r=i(59455),s=i(48884),n=i(22859),a=i(28874),o=i(79781),l=i(92434);t.aggregateAssetFiles=async function(e){const t=(0,r.toA)((0,l.sortAssetFiles)(e)??e);return(a.Settings.assetAggregation.valueOrDefault===n.AggregateTypes.union?s.clusterSome:s.clusterEvery)(t,o.isSimilarAssetFile)}},79781:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotSimilarAssetFile=t.isSimilarAssetFile=t.whyNotSameAsset=t.VideoImageMismatchMsg=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(50357),o=i(55835),l=i(31586),u=i(68708),c=i(12168),d=i(23467),h=i(73168),f=i(50213),m=i(86580),p=i(48368),g=i(80361),y=i(28874),v=i(28544),w=i(75767),b=i(16170),S=(0,r.lazy)((()=>(0,f.mkLogger)("sync-file.AssetFileComparator")));function P(e,t,i,r=((e,t)=>[e,t])){const s=e[i],o=t[i];if((0,n.blank)(s)||(0,n.blank)(o)||(0,a.eql)(s,o))return;const[l,u]=r(s,o);return(0,a.eql)(l,u)||(0,a.eql)(s,u)||(0,a.eql)(l,o)?void 0:`Different ${String(i)}: ${s} ≠ ${o}`}function _(e){return(0,n.mapNotBlank)(e,(e=>e.toLowerCase().trim().normalize()))}function T(e,t){return[_(e),_(t)]}function M(e,t,i){const r=(0,w.findInequalFields)(e[i],t[i]);return null==r?void 0:`Different ${i} (${r.aKey}:${r.aValue} ≠ ${r.aKey}:${r.aValue})`}function E(e,i){if(!(0,u.allKeysDefined)(e,"width","height","mimetype","sha"))return"af1 was missing required fields";if(!(0,u.allKeysDefined)(i,"width","height","mimetype","sha"))return"af2 was missing required fields";if((0,d.definedAndEql)(e.sha,i.sha))return void S().debug("matching SHA",{af1:e,af2:i});const r=(0,b.isVideoMimeType)(e.mimetype),n=(0,b.isVideoMimeType)(i.mimetype);if(r!==n)return S().tap({msg:"whyNotIsSimilar",result:t.VideoImageMismatchMsg,meta:{af1:e.uri,af2:i.uri,af1IsVideo:r,af2IsVideo:n}});const a=v.CapturedAt.fromAssetFile(e),f=v.CapturedAt.fromAssetFile(i);if(null==a)return"af1 missing capturedAt metadata";if(null==f)return"af2 missing capturedAt metadata";const _=a.isFuzzy||f.isFuzzy;if(_&&y.Settings.allowFuzzyDateImageHashMatches.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if((0,g.isSimilarImageHash)(t,r,{rotationsToCheck:(0,m.validRotations)(e,i)}))return void S().info("allowFuzzyDateImageHashMatches mode: image hashes match",{af1:e,af2:i})}if(!a.overlaps(f))return`captured-at ${a.toISOStringWithPrecision()} != ${f.toISOStringWithPrecision()}`;const E=P(e,i,"make",T)??P(e,i,"model",T);if(null!=E)return E;const k=(0,o.map)((0,h.geohashDistanceMeters)(e.geohash,i.geohash),(e=>(0,l.sigFigs)(e,2))),D={cameraId:M(e,i,"cameraId")??null,imageId:M(e,i,"imageId")??null,lensId:M(e,i,"lensId")??null,exposureSettings:(0,w.whyExposureSettingsNotSimilar)(e,i)??null,closeGeoHash:(0,l.gt)(k,y.Settings.gpsErrorMeters.valueOrDefault)?"geohashes are "+(0,c.fmt)(k)+"m different: too far apart":null};S().debug("whyNotSimilar()",{fields:D});const x=(0,s.compact)((0,u.values)(D));if((0,s.isNotEmpty)(x))return x.join(";");if(y.Settings.useImageHashes.valueOrDefault){const t=(0,p.toImageHash)(e),r=(0,p.toImageHash)(i);if(null!=t&&null!=r){const e=(0,g.compareImageHashes)(t,r,{capturedAtIsFuzzy:_});return!0===e?.isSimilar?void 0:e?.whyNotSimilar}}return(0,u.keys)(D).filter((e=>null==D[e])).length>=y.Settings.minMatchesWithoutImageHashes.valueOrDefault?void 0:"Insufficient metadata correlation"}t.VideoImageMismatchMsg="Videos ≠ images",t.whyNotSameAsset=function(e,t,i){{const i=E(e,t);if(null!=i)return i}if("intersection"===y.Settings.assetAggregation.valueOrDefault)for(const r of i)if(r.id!==t?.id){const t=E(e,r);if(null!=t)return t}},t.isSimilarAssetFile=function(e,t){return null==E(e,t)},t.whyNotSimilarAssetFile=E},13991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkSortableAssetFile_=t.mkAssetFile_=t.assetFileMetadata_=t.assetFileImageHashFields_=t.imageHashToAssetFileImageHashFields=t.assetFileStatFields_=t.assetFileUriFields_=void 0;const r=i(19851),s=i(55835),n=i(31586),a=i(59455),o=i(73168),l=i(50213),u=i(12089),c=i(76490),d=i(95696),h=i(48368),f=i(70417),m=i(28874),p=i(43207),g=i(47783),y=(0,r.lazy)((()=>(0,l.mkLogger)("asset-file.AssetFileFactory")));async function v(e){try{return{nativePath:e.nativePath,uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath}}catch(t){return y().throw("Failed to build URI for "+e,{error:t})}}async function w(e){const t=await e.stat_(),i=await e.sidecareStats();return{mtime:Math.floor((0,f.max)([t.mtimeMs,...(0,a.toA)(i).map((e=>e.mtimeMs))])),fileSize:t.size}}function b(e){return{...e,...c.DominantColor.toModeData(e.dominantColors)}}async function S(e){if(!m.Settings.useImageHashes.valueOrDefault)return;const t=await(0,h.imageHash_)(e.nativePath);return null==t?y().throw("Failed to extract image hash for "+e):b(t)}async function P(e){const[i,r,s,n]=await Promise.all([v(e),w(e),(0,t.assetFileMetadata_)(e),e.sha_()]);return{...i,...r,...s,sha:n}}t.assetFileUriFields_=v,t.assetFileStatFields_=w,t.imageHashToAssetFileImageHashFields=b,t.assetFileImageHashFields_=S,t.assetFileMetadata_=(0,u.shim1)({name:"asset-file.assetFileMetadata",impl:async function(e){try{const t=d.PosixFile.for(e),i=await(0,g.readTags)(t);if(null==i)throw new Error("Failed to read tags");if(null==i.capturedAt)throw new Error("Failed to read capturedAt");const r=i.capturedAt.toAssetFileFields();return null==r?y().throw("Failed to render assetFileFields from capturedAt",{capturedAt:i.capturedAt}):{...r,...i.exposureSettings,...i.dimensions,mimetype:i.mimetype,rotation:i.rotation,make:i.Make,model:i.Model,rating:i.rating,cameraId:i.cameraId,imageId:i.imageId,lensId:i.lensId,geohash:(0,o.geohashNumericShort)(i.GPSLatitude,i.GPSLongitude),durationMs:(0,p.extractDurationMs)(i),fps:(0,s.map)((0,n.toFloat)(i.VideoFrameRate),Math.floor)}}catch(t){return y().throw("_assetFileMetadata_() failed",{nativePath:e,error:t})}}}),t.mkAssetFile_=async function(e){const[t,i]=await Promise.all([P(e),S(e)]);return{...t,...i}},t.mkSortableAssetFile_=P},92434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestExistingAssetFile=t.assetFileSortCriteria=t.assetFileSortFields=t.assetFileSortCriteriaPojo=t.sortAssetFiles=t.mtime2sort=t.sortScale=t.dim2sort=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(23838),u=i(31586),c=i(68708),d=i(34666),h=i(50989),f=i(89937),m=i(50213),p=i(4001),g=i(29882),y=i(28874),v=i(14036),w=i(45200),b=i(34238),S=(0,r.lazy)((()=>(0,m.mkLogger)("img.AssetFileSorter"))),P=(0,h.strEnum)("file",f.PS_NETWORK_FILESYSTEM_SCHEME,f.PS_LOCAL_FILE_SCHEME,f.PS_LIBRARY_SCHEME);function _(e){return(0,u.map2Numeric)(e?.width,e?.height,((e,t)=>T(e*t)))}function T(e){if((0,u.gt0)(e))return Math.round(Math.pow(e,y.Settings.variantSortCriteriaPower.valueOrDefault))}function M(e){return Math.round(e/(5*o.minuteMs))}t.dim2sort=_,t.sortScale=T,t.mtime2sort=M;const E=["make","model","rating","cameraId","imageId","lensId","geohash"];function k(e){for(const t of(0,l.groupBy)(e,(e=>e.sha)).values())if(t.length>1){const e=Math.max(...(0,s.compact)(t.map((e=>e.mtime))));for(const i of t)i.mtime=e}return(0,n.sortBy)(e,C).reverse()}function D(e){const t=b.URI.parse(e.uri);if((0,a.blank)(t?.scheme)||(0,a.blank)(t?.path))return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI)",{uri_scheme:t?.scheme,uri_path:t?.path,af:e,parsedURI:t});const i=_(e);if(null==i)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid resolution)",{resolution:i,af:e,parsedURI:t});const r=P.indexOf(t.scheme);if(null==r)return void S().warn("assetFileSortCriteriaPojo(): skipping (invalid URI scheme)",{uri_scheme:t.scheme,af:e,parsedURI:t});const s=e.mtime??0,n=(0,g.parsePosixPath)(t.path),l=[];for(const t of E)(0,a.blank)(e[t])||l.push(t);const u={resolution:i,schemeIdx:r,capturedAtPrecision:-(e.capturedAtPrecisionMs??o.weekMs),metadataCoverage:l.length,metadataFields:l.join(","),isBrowserSupported:(0,v.isSupportedByCurrentBrowserExt)(n.ext),mtime:M(s),isEditOrUpdate:/edit|update/i.test(n.base),isCover:/cover/i.test(n.base),count:Math.abs((0,p.copySuffixCountFromName)(n.name)??0),basename:d.CmpReverseFlag+n.base,parentBasename:d.CmpReverseFlag+(0,g.parentBasename)(e.nativePath??t.path),uri:d.CmpReverseFlag+e.uri};return S().tap({msg:"assetFileSortCriteriaPojo()",result:(0,c.toReqValued)(u)})}function x(){return(0,s.uniq)([...y.Settings.variantSortCriteria.values,"uri"])}function C(e){const t=D(e);if(null==t)return;const i=[];for(const e of x())i.push(t[e]);return i}t.sortAssetFiles=k,t.assetFileSortCriteriaPojo=D,t.assetFileSortFields=x,t.assetFileSortCriteria=C,t.bestExistingAssetFile=async function(e){for(const t of k(e))if(await(0,w.uriExists)(t.uri,t.nativePath))return S().tap({msg:"bestExistingAssetFile()",result:t,meta:{files:e.map((e=>e.uri))}});return S().tap({msg:"bestExistingAssetFile(): no existing uris",result:void 0,meta:{files:e.map((e=>e.uri))}})}},54296:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetFileNativePath=void 0;const r=i(45200);t.getAssetFileNativePath=async function(e){return e.nativePath??(e.nativePath=await(0,r.uri2nativePath)(e.uri,e.mountpoint))}},73568:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const o=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,r.set(this,void 0),s.set(this,(0,o.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,n(this,s,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return n(this,s,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,n(this,s,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),a(this,r,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=n(this,r,"f")&&clearTimeout(n(this,r,"f")),a(this,r,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},r=new WeakMap,s=new WeakMap},69591:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const s=r(i(87997)),n=i(31586);t.debounce=function(e,t){let i,r=[];const a=(0,n.gt0)(t)?(...n)=>{r=n,null!=i&&s.default.clearTimeout(i),i=s.default.setTimeout((()=>{e(...r)}),t)}:e;return a.reset=()=>{null!=i&&s.default.clearTimeout(i),i=void 0},a.force=()=>{a.reset(),e()},a.setTimeoutMs=e=>{a.reset(),t=e},a.timeoutMs=()=>t,a}},22911:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(i(87997)),w=y(i(57975)),b=i(45599),S=i(26905),P=i(55835),_=i(31586),T=i(68708),M=i(20214),E=i(57153),k=i(85556),D=i(50213),x=i(70025),C=i(95937),F="TIMEOUT",A=(0,b.defer)((()=>(0,D.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),r=(0,_.gt0)(t)?new s(F).setTimeout(t):void 0;for(null!=r&&i.push(r);;){for(let r=i.length-1;r>=0;r--){const s=i[r];if(s.isSettled){if(s.name===F)return void A().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(r,1),yield s.value}}if(i.every((e=>e.name===F)))break;try{await Promise.race(i)}catch{}}r?.clearTimeout()}static resolve(e,t){return new s(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;r.add(this),this.name=e,this.startedAt=Date.now(),a.set(this,void 0),o.set(this,E.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=s,s,(y=p(i,s,"f",n),m=y++,y),"f",n),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,D.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof s&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,o,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,T.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,a,"f")}get elapsedMs(){return(p(this,a,"f")??Date.now())-this.startedAt}get[(a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,r=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new k.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,C.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,o,"f")===E.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,o,"f")!==E.PromiseStates.pending}get isResolved(){return p(this,o,"f")===E.PromiseStates.resolved}get isRejected(){return p(this,o,"f")===E.PromiseStates.rejected}get settledMs(){return null==p(this,a,"f")?void 0:p(this,a,"f")-this.startedAt}resolve(e){return p(this,r,"m",m).call(this,(()=>{g(this,o,E.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,x.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,S.asError)(e);return p(this,r,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,o,E.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,s=I,m=function(e){if(p(this,o,"f")===E.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,a,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},n={value:0}},83412:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DoneWrapper=void 0;const r=i(56409),s=i(38836);class n extends s.EndableWrapper{constructor(){super(...arguments),this.doneLatch=new r.Latch}isDone(){return this.doneLatch.isSettled()||this.ended}donePromise(){return this.doneLatch.promise}}t.DoneWrapper=n},27395:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(23838),o=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,r.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new a.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*n.minuteMs);const y=5*n.secondMs;async function v(e,t){const i=await e;if(null==i||!0===i?.ended)return;const r=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:r});try{await(0,o.thenOrTimeoutError)(i.end(),r,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,r.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,s.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,s.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,r,"m",a).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),r.add(this),this.opts=e,s.set(this,void 0),n.set(this,void 0),o.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,s,"f")}hasTimeout(){return null!=u(this,n,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,r,"m",a).call(this);const h=()=>{u(this,r,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,s,(0,d.setInterval)(u(this,o,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,n,(0,d.setTimeout)((()=>{u(this,r,"a",l)&&(u(this,o,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref()):h(),!0}}t.EndableInterval=v,s=new WeakMap,n=new WeakMap,o=new WeakMap,r=new WeakSet,a=function(){(0,h.map)(u(this,s,"f"),d.clearInterval),c(this,s,void 0,"f"),(0,h.map)(u(this,n,"f"),d.clearTimeout),c(this,n,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const r=i(50989);t.EndableRanks=(0,r.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const o=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,a){this.endTimeoutMs=a,r.set(this,void 0),this.onEnds=[],s.set(this,(0,o.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),n(this,s,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){a(this,r,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return n(this,r,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return n(this,s,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},r=new WeakMap,s=new WeakMap},99331:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const r=i(7282);let s=!1;t.ending=function(){return s},t.setEnding=function(e){s=(0,r.isTest)()?e:e||s}},45608:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const s=r(i(1708)),n=i(22573),a=i(45599),o=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,a.defer)((()=>(0,l.mkLogger)((0,o.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,a.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const r=(0,n.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(r)}(0,m.ending)()||(await(0,f.endEndables)(),s.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,a.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])s.default[e].on(t,(i=>{v({reason:`${e}:${t}`,status:0,error:i})}))}))},39250:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LastOneInWins=void 0;const n=i(23838),a=i(54993),o=i(15674),l=i(73568),u=i(76740),c=i(99331),d=i(42638);t.LastOneInWins=class{constructor(e,t=o.maxCpus){this.name=e,this.maxConcurrency=t,r.set(this,new n.MultiMap),this.p=new d.Promises(e,t)}vacuum(){return s(this,r,"f").filterInPlace(((e,t)=>t.isPending&&!0!==t.payload?.aborted)),s(this,r,"f").valueCount()}enqueue({key:e,abortable:t,fn:i}){for(const t of s(this,r,"f").get(e)??[])t.payload?.abort("aborted by new work");if(this.vacuum(),(0,c.ending)())throw new l.AbortError("ending");const n=t??new u.Abortable,o=this.p.serial((0,a.toS)(e),(()=>i(n)),n);return s(this,r,"f").add(e,o),o}},r=new WeakMap},60172:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,r)=>{t=e,i=r})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:r}){return new y(e,t,i,r)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),r.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,s.set(this,void 0),n.set(this,0),a.set(this,void 0),o.set(this,[])}_call(){return this.isStale()?c(this,r,"m",u).call(this,this.later()):c(this,a,"f")}unset(){d(this,n,0,"f"),d(this,s,void 0,"f"),d(this,a,void 0,"f")}set(e){return c(this,r,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,r,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,o,"f").push(e)}prior(){return this.isStale()?void 0:c(this,a,"f")}lastValue(){return c(this,a,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,n,"f")}isStale(){return null==c(this,s,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,s,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,s,"f")?void 0:Date.now()-c(this,s,"f")}elapsedMs(){return c(this,a,"f")?.settledMs??c(this,a,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,o,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,o,"f"))e.onError(t)}finally{d(this,n,(i=c(this,n,"f"),++i),"f")}},u=function(e){d(this,s,Date.now(),"f");const t=c(this,a,"f");return d(this,a,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,a,"f").setTimeout(this.timeoutMs),c(this,r,"m",l).call(this,t,c(this,a,"f")),c(this,a,"f")}},1728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const r=i(98553),s=i(80049);t.memoizeAsync=function(e,t){let i=0;const n=new s.FifoCacheAsync(t),a=t=>(i++,n.getOrSetAsync((0,r.stringify)(t),(async()=>e(t))));return a.clear=e=>{if(null==e)return n.clear();{const t=(0,r.stringify)(e);return n.deleteIf((e=>t===e))}},a.size=()=>n.size,a.callCount=()=>i,a}},22781:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,r.set(this,void 0),s.set(this,!1),n.set(this,!1)}_call(){return a(this,s,"f")?(o(this,n,!0,"f"),!0===this.undefinedIfBusy?void 0:a(this,r,"f")):(o(this,s,!0,"f"),o(this,r,(0,u.postrun)({fn:this.fn,postrun:()=>{o(this,s,!1,"f"),!0===this.runLaterIfBusy&&a(this,n,"f")&&(o(this,n,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return a(this,s,"f")}prior(){return a(this,r,"f")}async force(){return await a(this,r,"f"),this._call()}}r=new WeakMap,s=new WeakMap,n=new WeakMap},37461:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const r=i(40958),s=i(76790),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),v=i(15674),w=i(42638);var b=i(20214);async function S(e){if(null==e)return[];const t=(0,r.compact)(await e);return(0,r.isEmpty)(t)?[]:(0,r.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:i,timeoutMs:s}){const n=[];for(const a of(0,r.compact)(await t))try{const e=await((0,l.gt0)(s)?(0,c.thenOrTimeoutError)(i(a),s):i(a));null!=e&&n.push([e,a])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:a,error:t})}return n}async function T({arr:e,f:t,name:i,maxConcurrent:s,timeoutMs:n,promises:a}){if(null==e)return[];const o=(0,r.compact)(await e);if((0,r.isEmpty)(o))return[];if((s=Math.round(s??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:i,timeoutMs:n});const u=a??(o.length<=s?w.PermissivePromises:new w.Promises(i,(()=>s))),d=(0,l.gt0)(n)?e=>(0,c.thenOrTimeoutError)(t(e),n):t,h=await u.enqueueAll(i,o.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,r.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return b.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=S,t.thenCollectBatched=async function(e,t,i){const r=[];for(const s of(0,p.batches)((0,f.toA)(await e),t)){const e=await S(s);r.push(...await S(i(e)))}return r},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,o.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,r.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,r.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=T,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n}){return(await T({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:n})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:s,timeoutMs:n}){return(await T({name:e,arr:(0,r.compact)(t),f:i,maxConcurrent:s,timeoutMs:n})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await T({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,n.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,n.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*a.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),r=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,r)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let r,s=null;try{r=await((0,h.isFunction)(e)?e():e)}catch(e){s=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(s??r)}catch{}if(null!=s)throw s;return r},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,n.isTrue)(i)},t.thenMap2=async function(e,t,i){const r=await e;if(null==r)return;const s=await t;return null!=s?i(r,s):void 0},t.thenMapOr=async function(e,t,i){const r=await e;if(null==r)return i();const s=await t(r);return null==s?i():s},t.thenMap2Or=async function(e,t,i,r){const s=await e;if(null==s)return r();const n=await t;if(null==n)return r();const a=await i(s,n);return null==a?r():a},t.thenAnd=async function(e,t){return null!=e&&(0,n.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const r of e){i++;try{if(null==r)continue;const e=await t(r,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const r=await T({name:e,arr:t,f:i});return(0,s.sortBy)(r,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),v=i(25764),w=i(38836),b=i(73614);function S(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const r=Date.now(),s=(0,l.clamp)(10*a.secondMs,a.minuteMs,Math.round(this.times.get(e)?.p98??0)),n=(0,b.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-r)+"ms")}),s);try{const s=await(0,c.tot)(t),n=Date.now()-r;return i?.(s,n),this.push(e,n),s}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-r),t}finally{clearTimeout(n)}}get entriesBySumDesc(){return(0,n.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(S(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),r=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...r])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,o.getOrSet)(this.times,S(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(S(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/a.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function _(e,t,i){return P.instance().time(e,t,i)}function T(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,r.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,s.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const i=Date.now(),r=t();return T(e,Date.now()-i),r},t.pushTime=T,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,r.lazy)((async()=>_(e,t)),i)}},42638:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),v=i(54993),w=i(89788),b=i(82647),S=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){r.add(this),this.name=e,this.ee=new f.default.EventEmitter,s.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new b.Average,n.set(this,0),a.set(this,[]),o.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,s,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,S.maxCpus)(),d(this,s,"f")?.call(this)??(0,S.maxCpus)()))}end(){return d(this,o,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,a,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,n,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,a,"f").map((e=>e.name)),pendingNames:d(this,o,"f").map((e=>e.d.name)),totalWorkCount:d(this,n,"f")}}enqueue({name:e,l:t,payload:i,serialId:s}){const n=d(this,r,"m",l).call(this,{name:e,l:t,payload:i,serialId:s});return this.laterPop(),n}enqueueAll(e,t){const i=t.map((t=>d(this,r,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,r,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,a,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,o,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,o,"f").length,e),i=this.runningSerialIds,s=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,a,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,o,"f").length}hasPending(){return d(this,o,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,o,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,o,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function({name:e,l:t,payload:i,serialId:r}){const s=new P.Deferred(e,{payload:i,serialId:r});return d(this,o,"f").push({d:s,l:t}),s},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,n,(t=d(this,n,"f"),++t),"f"),(0,m.remove)(d(this,a,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,a,"f").push(e),e},t.maybeRun=function(e,t){const i=new _(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new _(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},59189:function(e,t){"use strict";var i,r=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},s=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SerialLaterQueue=void 0,t.SerialLaterQueue=class{constructor(){i.set(this,Promise.resolve())}enqueue(e){return s(this,i,r(this,i,"f").catch().then(e),"f")}},i=new WeakMap},4867:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const r=i(40958),s=i(34546),n=i(41400),a=i(31586),o=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let o=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>o=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>{if(o)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(o)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,r.compact)([(0,s.asPromise)(e).finally((()=>l=!1)),(0,a.gt0)(t)?(0,n.delay)(t).then((()=>o.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const r=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,r.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,r.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const r=i(38639),s=i(42659),n=i(41400),a=i(32639),o=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:r,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const r=i??(0,o.clamp)(10*m,l.ShortCommandTimeoutMs,(t??s.minuteMs)/5);await(0,n.delay)(r,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:r.isTrue,timeoutResult:!1})}},9727:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const s=r(i(1708)),n=i(45599),a=i(41400),o=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),v=i(50213),w=i(7282),b=i(88158),S=i(45969),P=i(43334),_=i(28874),T=i(3790);function M(e){return E().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const E=(0,n.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,b.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,a.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const k=["HOME","LANG","USER"],D=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],x=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?k:D),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function C(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,S.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,_.persistedSettings)()){const r=e?i.value:i.envValue;null==r||(0,o.eql)(r,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(s.default.env,(e=>M(e)||!(0,T.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=C,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:A({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let F=!1;function A({overrides:e,forceCLocale:i=!0,forWorker:r=!1}={}){const s=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...x(),...i?(0,g.childProcLocale)():{},...C(r),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(s);if((0,y.isLogged)("debug")&&!F){F=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(s).map((([e,t])=>[e,(0,T.isHiddenEnvKey)(e)?"(hidden)":t])),[i,r]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(r))}return s}t.childEnv=A},84777:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const s=r(i(31421)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),v=i(79089),w=i(45255),b=i(22911),S=i(4867),P=i(73614),_=i(70025),T=i(57159),M=i(36868),E=i(66184),k=i(45643),D=i(95402),x=i(9727),C=(0,a.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function F(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function A(e,t=30*u.secondMs){if(null==e)return!1;C().debug("endProcess()",F(e));const i=e.pid;if(null==i||i<=0)return C().warn("endProcess(): asked to end invalid pid",F(e)),!1;if(i===n.default.pid)return C().warn("endProcess(): asked to end MY pid",F(e)),!1;if(i===n.default.ppid)return C().warn("endProcess(): asked to end my parent pid",F(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();C().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,D.killPid)(i).catch((e=>{C().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,k.waitForPidExit)(i,t))return C().debug("endProcess(): exitted",F(e)),!0;{D.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");C().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,D.killPid)(i,!0).catch((e=>{C().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,k.waitForPidExit)(i,5e3)}function I(e,i,r,s=0){const a=new Date,o=[];return(0,v.niceable)(i,r)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(s,u.secondMs)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&A(e)}),s-250)),o.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,D.addPid)({pid:e.pid,cmd:i,timeoutMs:s,ppid:n.default.pid},a)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>o.forEach(clearTimeout))),e}function O(e,t,i,r){const n=(0,x.spawnOptions)(r);return(0,E.isLogged)("trace",C().context)?C().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:n}):C().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(s.default.execFile(e,t,n),e,t,i)}async function L(e,t,i){const r=i.quiet??!1,s=i.ignoreStderr??!1,n=i.ignoreExitCode??!1,a=O(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{a.disconnect?.()}catch{}return{result:"",pid:a.pid}}const u=a.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new b.Deferred(f);a.on("error",(e=>g.push(e))),a.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),a.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(a.stdin);const v=new d.Latch;null==a.stdout?v.resolve():(a.stdout.on("error",(e=>g.push(e))),a.stdout.on("data",(e=>m.push(e))),a.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==a.stderr||s?P.resolve():(a.stderr?.on("error",(e=>g.push(e))),a.stderr?.on("data",(e=>p.push(e))),a.stderr?.on("end",(()=>P.resolve()))),C().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,S.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),C().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,S.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt}),await(0,S.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt});const E=p.join("");(0,l.notBlank)(E)&&g.push(new Error(E)),!r&&(0,o.isNotEmpty)(g)&&C().warn(f+" resulted in errors:",g);const k=i.isIgnorableError??_.isIgnorableError,D=g.filter((e=>!0!==k(e)));if(D.length>0)throw 1===D.length?D[0]:new T.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:D});if(!n&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:E}}catch(e){throw C().error("stdoutResult_() failed",e),await(0,D.killPid)(a.pid,!0),e}}t.endProcess=A,t.ReniceAfterMs=(0,a.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,a.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,r){const n=(0,x.spawnOptions)(r);return C().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(s.default.spawn(e,t,n),e,t,i)},t.execFile=O,t.stdoutResult_=L,t.stdout_=async function(e,t,i){const r=await L(e,t,i);return C().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(r.result),meta:{cmd:e,args:t,opts:i,result:r}})}},86335:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ChildService=t.ChildServiceNames=t.inspectPort=t.pathToService=void 0;const l=i(77598),u=o(i(1708)),c=i(19851),d=i(40958),h=i(22573),f=i(50268),m=i(68708),p=i(5670),g=i(50989),y=i(12168),v=i(59455),w=i(41583),b=i(54993),S=i(80875),P=i(50213),_=i(81168),T=i(27395),M=i(25764),E=i(59958),k=i(70025),D=i(83278),x=i(85021),C=i(29325),F=i(43334),A=i(28874),I=i(84777),O=i(55534),L=i(85100),R=i(34330),N=(0,c.lazy)((()=>(0,P.mkLogger)("child.ChildService")));async function B(e){const t=(0,_.ensureSuffix)(e,".js"),i=D.BaseFile.projectRoot(),r=D.BaseFile.for(u.default.cwd()),s=(0,C.isPacked)()?[i.join("bin",t),F.isElectron?i.join("app.asar",t):void 0]:[r.join("dist","library",t),r.join("dist","core",t),r.join("lib","library",t)];(0,C.isPacked)()||(F.isElectron?(s.push(r.join("dist","app",t)),s.push(i.join("src","desktop","dist","library",t))):s.push(i.join("src","library","dist","library",t)));for(const e of s)if(null!=e&&!0===await e.isNonEmptyFile((0,C.isPacked)()?y.KB:128))return N().tap({msg:"pathToService()",level:"info",result:e,meta:{cmd:t,isPacked:C.isPacked,paths:s.map(b.toS)}});return N().throw("Failed to find path to "+e,{paths:s,fatal:!0})}t.pathToService=B,t.inspectPort=function(e){switch(e){case"web":return 9223;case"sync":return 9224;default:return(0,l.randomInt)(9225,9600)}},t.ChildServiceNames=(0,g.strEnum)(...p.ServiceNames.pick("web","sync"));class j{static async mk_(e,t={}){const i=t.pathToService??await B(e);if((0,h.blank)(i))throw new Error("Failed to find path to "+e);return t.nodeArgs=(0,v.toA)(t.nodeArgs),new j(e,i,t)}constructor(e,t,i){var o,l;r.add(this),this.serviceName=e,this.cmd=t,this.opts=i,this.restartCount=0,this.name="ChildService("+e+")",this.endTimeoutMs=(0,L.serviceExitTimeoutMs)(e),this.logger=(0,P.mkLogger)(this.name);const c=[...(0,v.toA)(i.nodeArgs),t.nativePath];(0,d.isNotEmpty)(i.args)&&c.push(...i.args),this.spawnOpts=(0,m.pick)(this.opts,"argv0","cwd","detached","env","gid","shell","stdio","timeout","uid","windowsHide","windowsVerbatimArguments","forceCLocale","forWorker"),this.spawnOpts.forceCLocale=!1,(l=(o=this.spawnOpts).env??(o.env={}))[E.UV_THREADPOOL_SIZE]??(l[E.UV_THREADPOOL_SIZE]=(0,b.toS)(("web"===e?A.Settings.webUvThreads:A.Settings.syncUvThreads).valueOrDefault)),this.wc=new R.WatchedChild({name:e,childFactory:async()=>(this.restartCount>0&&await(this.opts.onPreRestart?.()),this.restartCount++,(0,I.spawn)(u.default.execPath,c,-1,this.spawnOpts)),endableRank:M.EndableRanks.service,endTimeoutMs:this.endTimeoutMs,onStdout:a(this,r,"m",n).bind(this),onStderr:a(this,r,"m",s).bind(this),onError:this.opts.onError??(e=>!1===(0,k.isIgnorableError)(e)),ignoreStopErrors:!1,exitCommand:O.ServiceExitCommand,...i}),(0,T.addEndable)(M.EndableRanks.first,this)}get startMs(){return this.wc.startTs}runHealthCheck(){return this.wc.writeStdin(x.HealthCheckCommand+"\n")}start(){return this.wc.start()}stop(){return this.wc.stop()}restart(e){return this.wc.restart(e)}get ended(){return this.wc.ended}async end(){return this.wc.ended||this.write(O.ServiceExitCommand),this.wc.end()}get pid(){return this.wc.pid}running(){return this.wc.running()}notRunning(){return this.wc.notRunning()}write(e,t=2){if(t<0)return this.logger.warn("write(): no more retries",{toStdin:e}),!1;try{const t=this.wc.proc;return!0!==t?.stdin?.writable?(this.logger.warn("write(): childProc isn't open, ignoring",{toStdin:e}),!1):t.stdin.write((0,_.ensureSuffix)(e,"\n"))}catch(i){return this.logger.warn("write(): caught "+i),this.wc.onError("onStdout()",(0,w.toErr)(i)),this.write(e,t-1)}}}t.ChildService=j,r=new WeakSet,s=function(e){const t=(0,S.parseJSON)(e);return this.logger.warn(".onStderr()",t??e),!0===t?.fatal},n=function(e){if(!(0,h.blank)(e))try{const t=(0,S.parseJSON)(e);if(null==t)return void this.logger.info(".onStdout(): non-JSON payload",e);if(!0===t?.fatal)this.wc.onError(this.name+".onStdout()",t);else if((0,f.isHealthCheckSummary)(t)){const e="failed"===t.state||"error"===t.level;this.logger.log(e?"error":"info",".onStdout(): health check summary",t),e&&this.wc.onError(this.name+".onStdout()",t,e)}else null!=this.opts.onData&&this.opts.onData(t)}catch(t){this.logger.warn(".onStdout() failed:",{data:e,error:t})}}},3790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const r=i(22573),s=i(41400),n=i(19851),a=i(28874);(0,s.later)((()=>a.Settings.sensitiveEnvRegExp.watchLater((()=>o.unset()))));const o=(0,n.lazy)((()=>{try{return new RegExp(a.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${a.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(a.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,r.blank)(e)&&o().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||a.Settings.license.includesEnvKey(e)}},55534:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceExitCommand=void 0,t.ServiceExitCommand="--exit"},85100:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serviceExitTimeoutMs=void 0;const r=i(23560),s=i(28874),n=i(45255);t.serviceExitTimeoutMs=function(e){return(0,r.isSyncService)(e)?s.Settings.syncExitTimeoutMs.valueOrDefault:n.ShortCommandTimeoutMs}},34330:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(54993),w=i(27395),b=i(25764),S=i(99331),P=i(42638),_=i(38835),T=i(8769),M=i(57159),E=i(66003),k=i(50213),D=i(45643),x=i(28874),C=i(84777);t.mkBasicWatchedChild=function(e){return new F({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,C.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class F{constructor(e){r.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,k.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),s.set(this,!1),this.onError=(e,t,i)=>{const n=new M.WrappedError(e,{cause:t}),a=!1!==n.ignorable;this.logger().log(a?"warn":"error","onError()",n),u(this,s,"f")||a||(this.lastError=n,(0,T.onError)(n),!0!==n.fatal?(i??this.opts.onError(e,n))&&(this.logger().warn("onError requested restart",{src:e,error:n}),u(this,r,"m",o).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:x.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:b.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,w.addEndable)(this.opts.endableRank,this),u(this,r,"m",o).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,s,"f")}async end(){return c(this,s,!0,"f"),u(this,r,"m",n).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,r,"m",n).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,s,"f")}),!u(this,s,"f")&&!(0,S.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,r,"m",n).call(this),this._stopped=!1,u(this,r,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:x.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,r,"m",l).call(this))))}}t.WatchedChild=F,s=new WeakMap,r=new WeakSet,n=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,s,"f")});const e=this.cp;return this.cp=void 0,u(this,r,"m",a).call(this,e)},a=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,D.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,C.endProcess)(e,this.endTimeoutMs)},o=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,s,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,r,"m",n).call(this),!this._stopped&&!u(this,s,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,T.onError)("Can't restart "+this.name+", failure rate is too high."+_.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,r,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,s,"f")}),this._stopped||u(this,s,"f")||(0,S.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,E.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,v.toS)(e).includes("Error: Cannot find module")&&(0,T.onError)("Failed to start "+this.name+_.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,s,"f")}),(0,S.ending)()||(this.opts.restartOnExit?(await u(this,r,"m",o).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const a=n(i(53916)),o=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,o.toNativePath_)(e);const i=f.PosixFile.for(e),r=t?.stableBasename??1?m(i):i.base.normalize(),s=i.sibling(r);if(s.isSelfOrDescendantOf((0,l.examples)()))return a.join("$examples",s.posixPathFrom((0,l.examples)()));const n=(0,d.originalsDir)();if(s.isSelfOrDescendantOf(n))return a.join("$library",s.posixPathFrom(n));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?a.join("$library",s.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},69554:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CLI=void 0;const n=i(6858),a=i(1708),o=i(37805),l=i(22573),u=i(55835),c=i(7282),d=i(19913),h=i(43334),f=i(41269),m=i(80061),p=i(94361);t.CLI=class{constructor(e,t,i){this.serviceName=e,this.args=t,this.additionalDescription=i,r.set(this,[]),(0,d.setServiceName)(e),(0,p.verifyUidGid)()}add(...e){return s(this,r,"f").push(...e),this}async parse(e=a.argv,t){let i=(0,m.addHelpFooter)(new n.Command).description((0,m.cliWrap)(f.CliDesc[this.serviceName]+(0,l.mapNotBlankOr)(this.additionalDescription,(e=>"\n\n"+e),(()=>""))).join("\n"));(0,u.map)(this.args,(e=>{i=i.arguments(e)}));for(const e of s(this,r,"f"))i=e.beforeParse(i);i.option("-V, --version","Output version information (spoiler: it's "+((0,c.isTest)()?"1.2.3-test":o.version)+")"),i.on("option:version",(()=>{console.log((0,m.cliWrapVersion)()),(0,a.exit)(0)})),i.parse(e,t??{from:h.isMainElectron?"electron":"node"});const d=i.opts();for(const e of s(this,r,"f"))await(e.afterParse?.(d));return i}},r=new WeakMap},41269:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const r=i(1708),s=i(31586),n=i(51926),a=i(17344),o=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,s.toInt)(r.env.maxLineLen)??r.stdout.columns??75;return(0,n.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,a.EditionName)()+" v"+o.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},38790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorArgs=void 0;const r=i(38639),s=i(17181),n=i(28874);t.ColorArgs={beforeParse:e=>e.option("--color","Enable ASCII terminal colors. This overrides NO_COLOR, if set.").option("--no-color","Disable ASCII terminal colors. See https://no-color.org/"),afterParse:e=>{(0,r.mapBoolean)(e.color,(e=>{n.Settings.logColor.envValue=e,(0,s.setupLogFormatter)()}))}}},83210:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDaemon=void 0;const s=r(i(1708)),n=i(22573),a=i(38639);t.isDaemon=function(e){return(0,a.isTrue)(s.default.env.__is_daemon)||(0,a.isTrue)(e?.daemon)||!(0,n.blank)(e?.pidfile)}},53978:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimingArg=void 0;const r=i(28874),s=i(38639);t.TimingArg={beforeParse:e=>e.option("--timing","On exit, emit timing information to stdout."),afterParse:async e=>{(0,s.isTrue)(e.timing)&&(r.Settings.emitTimingsOnExit.value=!0)}}},94361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const r=i(19851),s=i(40958),n=i(55835),a=i(31586),o=i(94174),l=i(44198),u=i(45969);function c(e,t,i){const r=(0,a.toGt0)((0,l.env)()[t]);return null==r||i.includes(r)?void 0:`WARNING: ${e} is running as ${i} but $${t}=${r}`}function d(){const e=(0,s.compactBlanks)([c("user id","PUID",(0,o.userids)()),c("group id","PGID",(0,o.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,r.lazy)((()=>{(0,u.isDocker)()&&(0,n.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},43380:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WriteSettingsArg=void 0;const r=i(28874),s=i(2858),n=i(22573),a=i(38639),o=i(46292);t.WriteSettingsArg={beforeParse:e=>e.option("--write-settings","Write (or re-write, if they exist) system and library settings.toml files. See https://phstr.com/settings"),afterParse:async e=>{if((0,a.isTrue)(e.writeSettings)){const e=await(0,s.writeSystemSettings_)();if(null==e?console.info("--write-settings: Failed write system settings: no system configuration directory was found.",{checkedDirectories:(0,o.osConfigDirs)()}):console.info(`--write-settings: Wrote system settings to ${e}`),(0,n.blank)(r.Settings.libraryDir.valueOrDefault))console.error("--write-settings: Failed to write library settings: no PS_LIBRARY_DIR is set.");else{const e=await(0,s.writeLibrarySettings_)();console.info(`--write-settings: Wrote library settings to ${e}`)}}}}},54772:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bestLabhashName=t.bestLabName=t.bestRgbName=t.colorToTuple=t.bestRgbTripletName=t.ColorNames=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(31586),o=i(48884),l=i(50213),u=i(81168),c=i(85810),d=i(42079),h=i(91482),f=i(3048),m=i(85409),p=i(16050),g=i(42022),y=i(85042),v=(0,r.lazy)((()=>(0,l.mkLogger)("color.ColorNames")));function w(e){const t=(0,y.normalizeRgbHex)(e.rgb);if(null==t)return void v().warn(`skipping invalid entry (bad rgb): ${e.rgb}`,e);const i=(0,c.rgbhex2Lab)(t);if(null==i)return void v().warn(`skipping invalid entry (failed to convert to L*a*b): ${t}`,e);const r=(0,c.toLabhash)(i,g.ModeBits);return{...e,rgb:t,lab:i,labhash:r,closeLabhashes:[r],closeRgb:[t],name:(0,u.capitalize)(e.name)}}function b(e,i){return null==e?void 0:(0,o.leastBy)(i??(0,t.ColorNames)(),(t=>(0,f.ciede2000_delta_e)(t.lab,e)))}t.ColorNames=(0,r.lazy)((()=>(0,s.compact)([...d.CrayonColors,...d.CrayonSupplements,...h.DarkWikipediaColors,...p.LightWikipediaColors,...m.Greys].map(w)))),t.bestRgbTripletName=function(e,i=(0,t.ColorNames)()){return b((0,c.rgb2lab)(e),i)},t.colorToTuple=w,t.bestRgbName=function(e){return P((0,c.rgbhex2Labhash)(e))},t.bestLabName=b;const S=new Map;function P(e){return(0,a.gte0)(e)?(0,n.getOrSet)(S,e,(()=>{const i=(0,t.ColorNames)().find((t=>t.labhash===e));if(null!=i)return i;const r=(0,c.unlabhash)(e),n=b(r);return null!=r&&null!=n&&((0,s.pushUniq)(n.closeLabhashes,e),(0,s.pushUniq)(n.closeRgb,(0,c.lab2rgbhex)(r))),n})):void 0}t.bestLabhashName=P},85810:(e,t,i)=>{"use strict";e=i.nmd(e),Object.defineProperty(t,"__esModule",{value:!0}),t.hsv2rgb=t.hsl2hsv=t.hsv2hsl=t.hsl2rgb=t.rgb2hsl=t.rgbhex2hsl=t.rgb2hsv=t.closestLab=t.maxLabhash=t.minLabhash=t.unlabhash=t.toLabhash=t.LabBitZip=t.xyz2rgb=t.lab2xyz=t.xyz2lab=t.rgb2xyz=t.clampLab=t.lab2rgb=t.rgb2lab=t.rgb2labArray=t.rgb2labTriplets=t.lab2rgbhex=t.rgbhex2Labhash=t.rgbhex2Lab=void 0;const r=i(19851),s=i(40958),n=i(49769),a=i(55835),o=i(31586),l=i(48884),u=i(20014),c=i(75503),d=i(3048),h=i(42022),f=i(85042),m=[[.4124564,.3575761,.1804375],[.2126729,.7151522,.072175],[.0193339,.119192,.9503041]],p=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]];function g(e){return _(w(e))}function y(e){return(0,f.clampRGB)(M(T(e)))}function v(e){return(0,t.LabBitZip)().clampValue(e)}function w(e){const t=(0,f.clampRGB)(e).map((e=>e/255)).map((e=>e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92));return(0,c.matXvec)(m,t)}t.rgbhex2Lab=function(e){return(0,a.map)((0,f.rgbhex2triplet)(e),g)},t.rgbhex2Labhash=function(e,t=h.ModeBits){return(0,a.map)((0,f.rgbhex2triplet)(e),(e=>E(g(e),t)))},t.lab2rgbhex=function(e){return(0,f.rgbTriplet2hex)(y(e))},t.rgb2labTriplets=function(e){return(0,s.stepRange)(0,e.length,3).map((t=>g([e[t],e[t+1],e[t+2]])))},t.rgb2labArray=function(e){const t=[],i=[],r=[];for(let s=0;se>S?Math.pow(e,1/3):(P*e+16)/116));return v([116*i-16,500*(t-i),200*(i-r)])}function T(e){const[t,i,r]=v(e),s=(t+16)/116,n=i/500+s,a=s-r/200,o=n*n*n,l=a*a*a,u=o>S?o:(116*n-16)/P,c=t>8?Math.pow(s,3):t/P,d=l>S?l:(116*a-16)/P;return[u*b.X,c*b.Y,d*b.Z]}function M(e){return(0,c.matXvec)(p,e).map((e=>{const t=e<0?-1:1,i=e*t;return(0,o.round)(255*t*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055))}))}function E(e,i=h.ModeBits){return(0,t.LabBitZip)().zip(e,i)}t.xyz2lab=_,t.lab2xyz=T,t.xyz2rgb=M,t.LabBitZip=(0,r.lazy)((()=>new u.BitZip([{min:0,max:100},{min:-79,max:90},{min:-102,max:89}]))),t.toLabhash=E;const k=new Map;function D(e,i=h.ModeBits){return(0,t.LabBitZip)().unzip(e,i)}function x(e){const[t,i,r]=(0,f.clampRGB)(e),s=Math.max(t,i,r),n=s-Math.min(t,i,r),a=n?s===t?(i-r)/n:s===i?2+(r-t)/n:4+(t-i)/n:0;return[60*(a<0?a+6:a),s?n/s*100:0,s/255*100]}function C(e){return F(x(e))}function F(e){const[t,i,r]=e,s=(200-i)*r/100;return[t,s>0&&s<200?i*r/100/(s<=100?s:200-s)*100:0,s/2]}function A(e){const[t,i,r]=e,s=i*(r<50?r:100-r)/100;return[t,s>0?2*s/(r+s)*100:0,r+s]}function I(e){const t=e[0]/360*6,i=e[1]/100,r=e[2]/100,s=Math.floor(t),n=r*(1-i),a=r*(1-(t-s)*i),o=r*(1-(1-t+s)*i),l=s%6;return(0,f.clampRGB)([255*[r,a,n,n,o,r][l],255*[o,r,r,a,n,n][l],255*[n,n,o,r,r,a][l]])}t.unlabhash=function(e,t=h.ModeBits){return t===h.ModeBits?(0,n.getOrSet)(k,e,(()=>D(e,t))):D(e,t)},t.minLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMin(h.ModeBits))),t.maxLabhash=(0,r.lazy)((()=>(0,t.LabBitZip)().zipMax(h.ModeBits))),t.closestLab=function(e,t){return(0,l.leastBy)(e,(e=>(0,d.ciede2000_delta_e)(e,t)))},t.rgb2hsv=x,t.rgbhex2hsl=function(e){return C((0,f.rgbhex2triplet)(e))},t.rgb2hsl=C,t.hsl2rgb=function(e){return I(A(e))},t.hsv2hsl=F,t.hsl2hsv=A,t.hsv2rgb=I,i.c[i.s]===e&&console.log(E([0,0,0]))},42079:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CrayonSupplements=t.CrayonColors=void 0,t.CrayonColors=[{name:"Aquamarine",rgb:"#95E0E8"},{name:"Asparagus",rgb:"#7BA05B"},{name:"Blue-green",rgb:"#0095B7"},{name:"Royal blue",rgb:"#273BE2"},{name:"Blush",rgb:"#DB5079"},{name:"Brilliant rose",rgb:"#E667CE"},{name:"Brown",rgb:"#AF593E"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Burnt umber",rgb:"#805533"},{name:"Cadet blue",rgb:"#A9B2C3"},{name:"Canary",rgb:"#FFFF99"},{name:"Carmine",rgb:"#E62E6B"},{name:"Carnation pink",rgb:"#FFA6C9"},{name:"Celestial blue",rgb:"#7070CC"},{name:"Cerise",rgb:"#DA3287"},{name:"Cerulean blue",rgb:"#339ACC"},{name:"Chestnut",rgb:"#B94E48"},{name:"Cobalt blue",rgb:"#8C90C8"},{name:"Copper",rgb:"#DA8A67"},{name:"Cornflower",rgb:"#93CCEA"},{name:"Cotton candy",rgb:"#FFB7D5"},{name:"Denim",rgb:"#1560BD"},{name:"Eggplant",rgb:"#614051"},{name:"Fern",rgb:"#63B76C"},{name:"Fuchsia",rgb:"#C154C1"},{name:"Russet",rgb:"#87421F"},{name:"Green",rgb:"#01A638"},{name:"Green-yellow",rgb:"#F1E788"},{name:"Indigo",rgb:"#4F69C6"},{name:"Jungle green",rgb:"#29AB87"},{name:"Magenta",rgb:"#F653A6"},{name:"Maize",rgb:"#F2C649"},{name:"Maroon",rgb:"#C32148"},{name:"Medium chrome green",rgb:"#6CA67C"},{name:"Medium violet",rgb:"#8F47B3"},{name:"Melon",rgb:"#FEBAAD"},{name:"Middle blue-green",rgb:"#8DD9CC"},{name:"Middle blue-purple",rgb:"#8B72BE"},{name:"Green-yellow",rgb:"#ACBF60"},{name:"Middle purple",rgb:"#D982B5"},{name:"Middle yellow-red",rgb:"#ECAC76"},{name:"Midnight blue",rgb:"#003366"},{name:"Mulberry",rgb:"#C8509B"},{name:"Navy blue",rgb:"#0066CC"},{name:"Olive green",rgb:"#B5B35C"},{name:"Orange",rgb:"#FF8833"},{name:"Orchid",rgb:"#E29CD2"},{name:"Peach",rgb:"#FFCBA4"},{name:"Periwinkle",rgb:"#C3CDE6"},{name:"Pine green",rgb:"#01796F"},{name:"Pink flamingo",rgb:"#FC74FD"},{name:"Plum",rgb:"#8E3179"},{name:"Raw umber",rgb:"#665233"},{name:"Red-orange",rgb:"#FF681F"},{name:"Red",rgb:"#ED0A3F"},{name:"Salmon",rgb:"#FF91A4"},{name:"Vivid scarlet",rgb:"#FD0E35"},{name:"Sea green",rgb:"#93DFB8"},{name:"Sepia",rgb:"#9E5B40"},{name:"Shamrock",rgb:"#33CC99"},{name:"Sky blue",rgb:"#76D7EA"},{name:"Spring green",rgb:"#ECEBBD"},{name:"Sunset orange",rgb:"#FE4C40"},{name:"Tan",rgb:"#FA9D5A"},{name:"Teal blue",rgb:"#008080"},{name:"Thistle",rgb:"#D8BFD8"},{name:"Vivid tangerine",rgb:"#ED3C10"},{name:"Vivid violet",rgb:"#a625c3"},{name:"Wisteria",rgb:"#C9A0DC"},{name:"Yellow-green",rgb:"#C5E17A"},{name:"Yellow-orange",rgb:"#FFAE42"},{name:"Yellow",rgb:"#FBE870"}],t.CrayonSupplements=[{name:"Artichoke",rgb:"#8F9779"},{name:"Aubergine",rgb:"#48213A"},{name:"Brandy rose",rgb:"#B1847F"},{name:"Burgundy",rgb:"#800020"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Crimson red",rgb:"#990000"},{name:"Dark brown",rgb:"#664228"},{name:"Dark coral",rgb:"#CD5B45"},{name:"Dark green",rgb:"#006400"},{name:"Dark raspberry",rgb:"#872657"},{name:"Dark turquoise",rgb:"#610079"},{name:"Deep teal",rgb:"#004040"},{name:"Deep coffee",rgb:"#704241"},{name:"Dusty rasberry",rgb:"#917980"},{name:"Ecru",rgb:"#BCAC7C"},{name:"Evergreen",rgb:"#05472A"},{name:"Eggplant",rgb:"#380835"},{name:"Eggplant purple",rgb:"#430541"},{name:"Emerald green",rgb:"#028F1E"},{name:"Flamingo pink",rgb:"#D67C99"},{name:"Grape",rgb:"#6C3461"},{name:"Kelly green",rgb:"#4CBB17"},{name:"Light forest green",rgb:"#4F9153"},{name:"Medium dark brown",rgb:"#AF7200"},{name:"Medium dark cyan-blue",rgb:"#2D537C"},{name:"Mustard",rgb:"#FAAF18"},{name:"Neon green",rgb:"#39FF14"},{name:"Pear",rgb:"#D1E231"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Phthalo blue",rgb:"#0016C7"},{name:"Pink lace",rgb:"#FFDDF4"},{name:"Raw sienna",rgb:"#884B15"},{name:"Rebecca purple",rgb:"#663399"},{name:"Sap green",rgb:"#536916"},{name:"Blue sapphire",rgb:"#133ECB"},{name:"Sand",rgb:"#B38751"},{name:"Shadow blue",rgb:"#778BA5"},{name:"Shadow green",rgb:"#121E06"},{name:"Swamp green",rgb:"#748500"},{name:"Verdigris",rgb:"#43B3AE"},{name:"Vivid blue-magenta",rgb:"#4817E8"},{name:"Vivid blue-purple",rgb:"#ACACE6"},{name:"Vivid blue",rgb:"#47ABCC"},{name:"Vivid green-yellow",rgb:"#D9E650"},{name:"Vivid green",rgb:"#7BE214"},{name:"Vivid turqoise",rgb:"#06ECD2"},{name:"Vivid lavender",rgb:"#A354FD"},{name:"Vivid mint",rgb:"#00F28C"},{name:"Vivid pink",rgb:"#D752FB"},{name:"Vivid red-purple",rgb:"#C31D7E"},{name:"Vivid red",rgb:"#D92121"},{name:"Vivid yellow-red",rgb:"#F2BA49"},{name:"Vivid yellow",rgb:"#FAFA37"}]},91482:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DarkWikipediaColors=void 0,t.DarkWikipediaColors=[{name:"Bistre",rgb:"#3D2B1F"},{name:"Black bean",rgb:"#3D0C02"},{name:"Black pearl",rgb:"#041322"},{name:"Shadow blue",rgb:"#001440"},{name:"Charcoal",rgb:"#36454F"},{name:"Dark indigo",rgb:"#1F0A52"},{name:"Dark magenta",rgb:"#8B008B"},{name:"Dark moss green",rgb:"#4A5D23"},{name:"Dark navy",rgb:"#02075D"},{name:"Dark pastel blue",rgb:"#779ECB"},{name:"Dark purple",rgb:"#580040"},{name:"Dark tan",rgb:"#918151"},{name:"Dark yellow-green",rgb:"#304000"},{name:"Dark yellow",rgb:"#9B870C"},{name:"Deep violet",rgb:"#330066"},{name:"Dusk",rgb:"#4E5481"},{name:"Elderberry",rgb:"#1d1a34"},{name:"Grey jade",rgb:"#757C55"},{name:"Grey magenta",rgb:"#83667F"},{name:"Grey ochre",rgb:"#716659"},{name:"Grey olive",rgb:"#656c5a"},{name:"Grey sage",rgb:"#69724d"},{name:"Taupe",rgb:"#483C32"}]},3048:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciede2000_delta_e=t.diffCIECorr=t.MaxCie=t.MinCie=t.cie94_delta_e=t.cie76_delta_e=void 0;const r=i(31586),s=i(97352);t.cie76_delta_e=function(e,t){return Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2)},t.cie94_delta_e=function(e,t){const[i,r,n]=e,[a,o,l]=t,u=i-a,c=r-o,d=n-l,h=(0,s.sqrt)(r**2+n**2),f=h-(0,s.sqrt)(o**2+l**2),m=(0,s.sqrt)(c**2+d**2-f**2);return(0,s.sqrt)((u/1)**2+(f/(1+.045*h))**2+(m/(1+.015*h))**2)},t.MinCie=2,t.MaxCie=20,t.diffCIECorr=function(e,i){return null==e||null==i?1:(0,r.clamp)(0,t.MaxCie,l(e,i)-t.MinCie)/t.MaxCie};const n=1,a=1,o=1;function l(e,t){const[i,r,l]=e,u=(0,s.sqrt)(r**2+l**2),[c,d,h]=t,f=(u+(0,s.sqrt)(d**2+h**2))/2,m=.5*(1-(0,s.sqrt)(Math.pow(f,7)/(Math.pow(f,7)+Math.pow(25,7)))),p=r*(1+m),g=d*(1+m),y=(0,s.sqrt)(p*p+l*l),v=(0,s.sqrt)(g*g+h*h);let w=Math.abs(p)+Math.abs(l)===0?0:Math.atan2(l,p);w+=2*(w<0?1:0)*Math.PI;let b=Math.abs(g)+Math.abs(h)===0?0:Math.atan2(h,g);b+=2*(b<0?1:0)*Math.PI;const S=c-i,P=v-y;let _=y*v==0?0:b-w;_-=2*(_>Math.PI?1:0)*Math.PI,_+=2*(_<-Math.PI?1:0)*Math.PI;const T=2*(0,s.sqrt)(y*v)*Math.sin(_/2),M=(i+c)/2,E=(y+v)/2;let k;y*v==0?k=w+b:(k=(w+b)/2,k-=(Math.abs(w-b)>Math.PI?1:0)*Math.PI,k+=2*(k<0?1:0)*Math.PI);const D=(M-50)**2,x=1-.17*Math.cos(k-Math.PI/6)+.24*Math.cos(2*k)+.32*Math.cos(3*k+Math.PI/30)-.2*Math.cos(4*k-63*Math.PI/180),C=1+.015*D/(0,s.sqrt)(20+D),F=1+.045*E,A=1+.015*E*x,I=30*Math.PI/180*Math.exp(-1*((180/Math.PI*k-275)/25)**2),O=2*(0,s.sqrt)(Math.pow(E,7)/(Math.pow(E,7)+Math.pow(25,7))),L=-1*Math.sin(2*I)*O;return(0,s.sqrt)(Math.pow(S/(n*C),2)+Math.pow(P/(a*F),2)+Math.pow(T/(o*A),2)+L*P/(a*F)*T/(o*A))}t.ciede2000_delta_e=l},76490:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColor=t.dominantColorsToRgbHex=void 0;const r=i(40958),s=i(31586),n=i(97352),a=i(54772),o=i(85810),l=i(42022),u=i(1971);t.dominantColorsToRgbHex=function(e){return(0,r.compact)(e.map((e=>[e.rgbhex,(0,s.fmtPct)(e.pct)])))};class c{static fromModeData(e){return(0,r.compact)((0,s.times)(u.ModeCount,(t=>c.fromLabhash({labhash:e[`mode${t}`],pct:e[`mode${t}pct`]}))))}static toModeData(e){const t={};return(0,s.times)(u.ModeCount,(i=>{t["mode"+i]=e[i]?.labhash??null,t["mode"+i+"pct"]=e[i]?.pct??null})),t}static fromLabhash({labhash:e,labhashBits:t=l.ModeBits,pct:i}){const r=(0,n.mapGt0)(e,(e=>(0,o.unlabhash)(e,t)));return null!=r&&(0,s.gt0)(i)?new c(r,i,e):void 0}static fromCentroid(e,t){return new c(e.centroid,Math.round(e.size/t*100))}constructor(e,t,i){this.lab=e,this.pct=(0,s.clamp)(0,100,t),this.labhash=i??(0,o.toLabhash)(e,l.ModeBits)}get rgbhex(){return(0,o.lab2rgbhex)(this.lab)}get color(){return(0,a.bestLabhashName)(this.labhash)}toGreyscale(){return new c([this.lab[0],0,0],this.pct)}eql(e){return this.labhash===e.labhash&&(0,s.closeTo)(this.pct,e.pct,5)}}t.DominantColor=c},32848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scaled_delta_e=t.dominantColorCorrelation=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(48884),o=i(31843),l=i(70417),u=i(3048);function c(e,t){const i=(0,s.sum)(e,(e=>(0,n.clamp)(0,100,e.pct))),r=(0,s.sum)(e,(e=>function(e,t){const i=(0,a.leastBy)(t,(t=>(0,u.ciede2000_delta_e)(e.lab,t.lab)));if(null==i)return 0;const r=(0,u.ciede2000_delta_e)(e.lab,i.lab),s=(0,n.clamp)(0,e.pct,(0,l.avg)([e.pct,i.pct])),o=h(r);return(0,n.clamp)(0,100,s)*o}(e,t)));return r/i}t.dominantColorCorrelation=function(e,t){return e=(0,s.compact)(e),t=(0,s.compact)(t),(0,s.isEmpty)(e)||(0,s.isEmpty)(t)?0:(0,l.avg)([c(e,t),c(t,e)])};const d=(0,r.lazy)((()=>[{x:0,y:1},{x:9,y:.8},{x:16,y:.3},{x:20,y:0}]));function h(e){return(0,n.clamp)(0,1,(0,o.lerp2d)(e,...d()))}t.scaled_delta_e=h},40401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeNearCentroids=t.mergeLabhashes=t.dominantColorsFromModes=t.maybeFilterGrey=t.centroidsScore=t.extractDominantColors=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(41400),o=i(98553),l=i(31586),u=i(68708),c=i(48884),d=i(22454),h=i(50213),f=i(56038),m=i(82647),p=i(44983),g=i(70417),y=i(28874),v=i(85810),w=i(3048),b=i(76490),S=i(1971),P=(0,r.lazy)((()=>(0,h.mkLogger)("color.DominantColors")));t.extractDominantColors=function(e,t=S.ModeCount){return(0,f.timeSync)("img.extractDominantColors",(()=>function(e,t=S.ModeCount){const i=Date.now(),r=y.Settings.dominantColorKmeansRuns.valueOrDefault,a=new d.CountingSet;for(const i of E({labs:e,minK:t}))a.incr((0,v.toLabhash)(i));const h=T[y.Settings.dominantColorDeltaE.valueOrDefault]??w.ciede2000_delta_e;const f=a.sortedByKey().valuesToA((e=>(0,v.unlabhash)(e)));let g=(0,l.round)(t+y.Settings.dominantColorMergeThreshold.valueOrDefault);function D(e){const i=t,r=4*t;g=Math.round(Math.max(i,Math.min(r,e)))}const C=f.length<=g?[]:(0,s.compact)(_.slice(0,r).map((e=>{const r=(0,p.kmeans)(f,g,{...M,seed:e}),s=x(r.centroids,f.length);if(s.lengtht&&D(g-1);const n=s.slice(0,t),o=(0,l.sigFigs)(function(e){const t=new m.Average;for(const[i,r]of a.entries()){const s=(0,v.unlabhash)(i),n=(0,c.leastByCtx)(e,(e=>h(e.centroid,s)));null!=n&&(0,l.times)(r,(()=>t.push(n.value)))}return t.p84}(n),2);return{...r,centroids:n,description:{kIn:g,kOut:r.centroids.length,kMerged:s.length,score:o,iterations:r.iterations,uniqColors:a.size,elapsedMs:Date.now()-i},score:o}})));P().trace("extractDominantColors()",{kmeansResults:C.map((e=>(0,u.pick)(e,"description","score")))});const F=(0,c.leastBy)(C,(e=>e.score));if(null==F)return P().info("kmeans failed or was disabled, using dominantColorsFromModes",{runs:r}),k(a,t);const A=(0,o.stringify)({...F?.description,elapsedMs:Date.now()-i}),I=(0,n.sortBy)(F?.centroids,(e=>-e.size)).map((e=>b.DominantColor.fromCentroid(e,f.length)));return P().debug("extractDominantColors() result",{description:A,score:F?.score,totalColors:a.size,totalPixels:f.length,iters:F?.iterations,dominantColors:(0,b.dominantColorsToRgbHex)(I),pixelCount:f.length}),{dominantColors:I,description:A,dominantColorScore:F?.score}}(e,t)))},t.centroidsScore=function(e,t){const i=new m.Average;for(const r of e){const e=(0,c.leastBy)(t,(e=>(0,w.ciede2000_delta_e)(e.centroid,r)));null!=e&&i.push((0,w.ciede2000_delta_e)(e.centroid,r))}return i};const _=[6147062518717073,8176726750919909,5426648081701673,0xce2a345532a3c,0x713f9716da824,6348935463312109,5900323173950995,7358780886584433,5704068712193493,0x51ceeef755892,0xe1557fe94c084,0xd42d7cc96d6b4,0xcbc36dfd76e8a,6738189173486085,8537822851166899,5390086061821835,7712057976331355,0xe9b820db7a8e4,0xb96cebcd6aa40,7036994544380825,5353634786120155,0x99a11417794bc,0xa93d36019aaae,0x74a470887095e,5481147022770415,5347523348244809,0x541d1098e90fc,0xa24d9fb3510c2,0x78aa8e4f692fa,6354921850669697,0x714e1ec1b0a14,8622097963014773,0x6ff5d462d8eb6,0x6782a6b5166b8,7128984079394103,0xe6efba28a3752,5088704486053871,0xc84df40627fae,8018285280412081,4524300326741245,8307147030534695,8135486835878813,7699950603263999,0xb2889592968ae,5903399874280295,7462660765348991,6442509751447017,0xe218d44834db6,7214173935589545,6001326758941961,0x53eb7d39bbb50,0xc3a7ab8add332,0x4e6e81bc443e2,6757635537583321,8501611905255957,0x51840465cc07c,5958243312989149,8928005021308717,5032083390680559,0xb35d70ac51c68,0xfc3826a2dfe7c,0xd155853c61e96,0xda2045ee9be1e,4753952745315177],T={cie76:w.cie76_delta_e,cie94:w.cie94_delta_e,ciede2000:w.ciede2000_delta_e},M=(0,r.lazy)((()=>({maxIterations:50,initialization:"kmeans++",distanceFunction:T[y.Settings.dominantColorDeltaE.valueOrDefault]})));function E({labs:e,minK:t,thresh:i,retries:r=3}){if(r<0)return P().debug("maybeFilterGrey(): exhausted retries: grey filtering disabled."),e;const s=i??y.Settings.dominantColorGreyThreshold.valueOrDefault;if(!(0,l.gt0)(s))return P().debug("maybeFilterGrey(): grey threshold is <= 0: grey filtering disabled."),e;const n=e.filter((e=>Math.abs(e[1])+Math.abs(e[2])>=s));return n.length>=e.length/2?(P().debug("maybeFilterGrey(): sufficient remaining pixels with this threshold.",{greyThreshold:s,minK:t,pixelCount:e.length,filteredCount:n.length}),n):(P().debug("maybeFilterGrey(): insufficient remaining pixels with this threshold. Retrying with smaller threshold.",{greyThreshold:s,minK:t,retries:r,pixelCount:e.length,filteredCount:n.length}),E({labs:e,minK:t,thresh:.75*s,retries:r-1}))}function k(e,t){const i=e.countSum,r=e.size;D(e);const n=e.size,a=(0,s.compact)(e.top(t).map((([e,t])=>b.DominantColor.fromLabhash({labhash:e,pct:Math.round(100*t/i)})))),l=100-(0,g.sumf)(a,(e=>e.pct));return{dominantColors:a,description:"dominantColorsFromModes: "+(0,o.stringify)({uniqColors:r,mergedColors:n,pixelCount:i,pctOmitted:l})}}function D(e,t=y.Settings.dominantColorMergeThreshold.valueOrDefault){const i=[];for(const[r,s]of[...e.entriesByCountDesc()]){const n=(0,v.unlabhash)(r),a=i.find((e=>(0,w.ciede2000_delta_e)(e.lab,n)<=t));null==a?i.push({lab:n,labhash:r}):(e.delete(r),e.incr(a.labhash,s))}return e}function x(e,t,i=y.Settings.dominantColorMergeThreshold.valueOrDefault){if(i<=0)return e;const r=[];for(const t of e){const e=r.find((e=>(0,w.ciede2000_delta_e)(t.centroid,e.centroid)<=i));null==e?r.push(t):e.size+=t.size}const s=t/100;return(0,n.sortBy)(r.filter((e=>e.size>s)),(e=>-e.size))}(0,a.later)((()=>{y.Settings.dominantColorDeltaE.watchLater((()=>{M.unset()}))})),t.maybeFilterGrey=E,t.dominantColorsFromModes=k,t.mergeLabhashes=D,t.mergeNearCentroids=x},85409:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Greys=void 0,t.Greys=[{name:"Black",rgb:"#000000"},{name:"90% black",rgb:"#1b1b1b"},{name:"80% black",rgb:"#303030"},{name:"70% black",rgb:"#474747"},{name:"60% black",rgb:"#5e5e5e"},{name:"Grey",rgb:"#777777"},{name:"60% white",rgb:"#919191"},{name:"70% white",rgb:"#ababab"},{name:"80% white",rgb:"#c6c6c6"},{name:"90% white",rgb:"#e2e2e2"},{name:"White",rgb:"#ffffff"}]},86758:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.labsAreGreyscale=t.isLab=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(82647),o=i(28874),l=i(85810),u=(0,r.lazy)((()=>(0,n.mkLogger)("color.Lab")));t.isLab=function(e){return Array.isArray(e)&&3===e.length&&(0,s.within)(0,100,e[0])&&(0,s.within)(-110,110,e[1])&&(0,s.within)(-110,110,e[2])},t.labsAreGreyscale=function(e){const t=o.Settings.greyscaleColorThreshold.valueOrDefault,i=new a.Average,r=new a.Average;for(const t of e){const e=(0,l.clampLab)(t);i.push(e[1]),r.push(e[2])}const s=(i.stdDev??0)+(r.stdDev??0),n=s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LightWikipediaColors=void 0,t.LightWikipediaColors=[{name:"Beige",rgb:"#F5F5DC"},{name:"Laurel green",rgb:"#A9BA9D"},{name:"Light sage",rgb:"#93A58B"},{name:"Light green-cyan",rgb:"#CFEADE"},{name:"Pastel purple",rgb:"#B39EB5"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Powder blue",rgb:"#B0E0E6"},{name:"Vanilla",rgb:"#F3E5AB"}]},42022:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeBits=void 0,t.ModeBits=12},1971:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ModeCount=void 0,t.ModeCount=7},85434:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitModeData=t.pickModeData=t.ModeDataKeys=t.isModeData=void 0;const r=i(31586),s=i(68708),n=i(50989);t.isModeData=function(e){return(0,r.gt0)(e.mode0)&&(0,r.gt0)(e.mode0pct)},t.ModeDataKeys=(0,n.strEnum)("mode0","mode0pct","mode1","mode1pct","mode2","mode2pct","mode3","mode3pct","mode4","mode4pct","mode5","mode5pct","mode6","mode6pct"),t.pickModeData=function(e){return(0,s.pick)(e,...t.ModeDataKeys.values)},t.omitModeData=function(e){return(0,s.omit)(e,...t.ModeDataKeys.values)}},85042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clampRGB=t.rgbTriplet2hex=t.rgbhex2triplet=t.normalizeRgbHex=void 0;const r=i(31586),s=i(39926),n=i(51926),a=i(54993),o=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;function l(e){return[e[0],e[1],e[2]].map((e=>(0,r.clamp)(0,255,Math.round(e))))}t.normalizeRgbHex=function(e){const t=(0,a.toS)(e).trim();return o.test(t)?(0,n.ensurePrefix)(t,"#").toUpperCase():void 0},t.rgbhex2triplet=function(e){const t=(0,a.toS)(e).trim().match(o);if(null!=t)try{return[t[1],t[2],t[3]].map((e=>(0,r.clamp)(0,255,parseInt(e,16))))}catch{return}},t.rgbTriplet2hex=function(e){return"#"+l(e).map((e=>(0,s.leftPad)(Math.round(e).toString(16).toUpperCase(),2,"0"))).join("")},t.clampRGB=l},76596:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const r=i(51168),s=i(19851),n=i(22573),a=i(42659),o=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,s.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,o.mapOr)(e,(e=>e.getTime()),(()=>0)),r=(0,o.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,r)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,a.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const r=i(77988),s=i(19851),n=i(55835),a=i(31586),o=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,s.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),h=["year","month","day","hour","minute","second","millisecond"];class f{static fromISO(e,t){const i=d().exec((0,o.toS)(e).trim()),r=i?.groups;return null==r?void 0:f.for((0,c.parseExifDateTime)(r.start,t),(0,c.parseExifDateTime)(r.end,t),(0,a.toInt)(r.index),(0,a.toInt)(r.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,n.map)(e.start,(e=>r.ExifDateTime.fromJSON(e))),(0,n.map)(e.end,(e=>r.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,r=1){if(null==e||!e.isValid||null==t||!t.isValid)return;r=(0,a.clamp)(1,1e3,(0,a.toInt)(r,{defaultValue:1})),i=(0,a.clamp)(0,r-1,(0,a.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const s=e.toMillis(),n=(t.toMillis()-s)/(r+1)*(i+1),o=e.plus({milliseconds:n});return null==o?void 0:new f(e,o,t,i,r)}constructor(e,t,i,r=0,s=1){this.start=e,this.middle=t,this.end=i,this.index=r,this.splits=s,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=h.map((r=>function({start:e,end:t,middle:i,field:r}){return null!=e[r]&&null!=t[r]?i[r]:void 0}({start:e,middle:t,end:i,field:r})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new f(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=f},79842:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(76790),o=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),h=i(51926),f=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),v=i(21330),w=i(928),b=i(54261),S=i(73389),P=i(51275),_=(0,n.lazy)((()=>(0,f.mkLogger)("date.Dated")));function T(e){return null!=e&&(e instanceof v.FuzzyDate||e instanceof r.ExifDate||e instanceof r.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,S.isDateTime)(e)||(0,m.isDateObject)(e))}function M(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof r.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function E(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof r.ExifDate?e.toMillis(l.dayMs):e instanceof v.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),D(e),((e,t)=>e+t))}function k(e){try{if(null==e||(0,h.isString)(e)||(0,c.isNumber)(e))return;return(0,S.isDateTime)(e)?e:e instanceof r.ExifDateTime||e instanceof v.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?s.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void _().warn("datedToDateTime() failed",{d:e,error:t})}}function D(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,b.hasTime)(e)){if((0,c.gt0)((0,w.getMillisecond)(e)))return 0;if((0,c.gt0)((0,w.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,w.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,w.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,w.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,w.getMonth)(e))?l.monthMs-1:l.yearMs-1}function x(e,t){const i=M(e),r=E(e);if(null!=i&&null!=r)return(0,c.gt0)(t)&&t>r-i?{start:Math.round((i+r)/2-t/2),end:Math.round((i+r)/2+t/2)}:{start:i,end:r}}function C(e,t,i,r){const[s,n]=(0,a.sortBy)([x(e,i),x(t,r)],(e=>e?.start));return null!=s&&null!=n&&null!=s&&null!=n&&(s.start===n.start||s.end>=Math.min(n.start,n.end))}function F(e,t){return(0,o.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??v.FuzzyDate.fromISO(e)}t.isDated=T,t.toDated=function(e){return T(e)?e:void 0},t.mapDated=function(e,t){return T(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=M,t.datedToEndTs=E,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof r.ExifDate?s.DateTime.fromObject(e):k(e)},t.datedToDateTime=k,t.datedToPrecisionMs=D,t.isoToPrecisionMs=function(e){return(0,u.map)(F(e),D)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:r}){if(null==e||null==t)return!1;if(i??(i=D(e)),r??(r=D(t)),C(e,t,i,r))return!0;const s=(0,P.getZoneName)(e),n=(0,P.getZoneName)(t);return null==s&&null!=n&&(e=(0,v.setZone)(e,n)??e),null==n&&null!=s&&(t=(0,v.setZone)(t,s)??t),C(e,t,i,r)},t.isoToDated=F,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof s.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const r=i(31586),s=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,s.isString)(e))return(0,r.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const r=i(22573),s=i(31586),n=i(54557),a=i(91655),o=new n.FifoCache(512);function l(e){return(0,s.isNumber)(e)?e:(0,r.blank)(e)?void 0:o.getOrSet(e,(()=>(0,a.parseDuration)(e)))}t.decodeDuration=l;const u=new n.FifoCache(512);t.encodeDuration=function(e){return(0,r.blank)(e)?void 0:u.getOrSet(e,(()=>(0,a.fmtFullDuration)((0,s.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const r=i(51168),s=i(40958),n=i(22573),a=i(42659),o=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,o.isNumber)(e))return;if((0,o.isNumber)(e))return e;if((0,o.isDigits)(e))return(0,o.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=r.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,s.compact)(d.map((e=>function(e,t){const i=(0,o.toFloat)(e);if(null!=i){if((0,n.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*a.yearMs;case"weeks":case"week":case"w":return i*a.weekMs;case"days":case"day":case"d":return i*a.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*a.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*a.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*a.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,o.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:a.yearMs,s:"y"},{ms:a.weekMs,s:"w"},{ms:a.dayMs,s:"d"},{ms:a.hourMs,s:"h"},{ms:a.minuteMs,s:"m"},{ms:a.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,o.isNumber)(t))return;if(0===t)return"0";if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const r=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&r.push(i+e.s)}return r.join(i)}},98247:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),h=i(68852),f=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function v(e,t,i){const r=t.exec(e);if(null==r||(0,u.isEmptyObj)(r.groups))return;const{year:s,month:n,day:a,hour:c,minute:h,second:p}=(0,d.mapEntries)(r.groups,((e,t)=>(0,l.toInt)(t)));if(null==s||null==n||null==a)return;if(!f.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==h))return;const g=(0,o.map)((0,l.toFloat)(r.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),v=(0,y.timezoneOffsetFromRegExpMatch)(r);return S({year:s,month:n,day:a,hour:c??0,minute:h??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(v)??i,rawValue:e,tzoffsetMinutes:v})}t.UnsetZone=s.Info.normalizeZone(r.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof r.ExifDate&&t instanceof r.ExifTime))return;const i=new r.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:n}){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromFormat(e,i,{zone:n??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,a.blank)(e)?void 0:r.ExifDateTime.fromDateTime(s.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,a.blank)(e)?void 0:r.ExifDateTime.from(e,t)??v(e,b(),t)},t.parseExifDateTimeRe=v;const w=/[-:_\s]?/,b=(0,n.lazy)((()=>(0,h.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,w,p.monthRE,w,p.dayRE,/[T\s]/,p.hourRE,w,p.minuteRE,w,p.secondRE,p.subsecRE,/\s?/,h.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function S(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof r.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=r.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,o.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=S},74417:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const r=i(51168),s=i(22573),n=i(42659),a=i(49769),o=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),h=i(66649),f=i(98725),m=i(88600);t.recent=function(e,t=5*n.secondMs){return(0,c.isRecentMs)((0,h.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=r.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,s.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,s.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=r.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,a.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,h.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,o.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*n.secondMs):void 0)??(0,f.parseDateTime)(t)?.toMillis()}},12959:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filestampUTC=t.filestamp=void 0;const r=i(39926);t.filestamp=function(e=new Date){return[e.getFullYear(),(0,r.pad2)(e.getMonth()+1),(0,r.pad2)(e.getDate()),"-",(0,r.pad2)(e.getHours()),(0,r.pad2)(e.getMinutes()),(0,r.pad2)(e.getSeconds())].join("")},t.filestampUTC=function(e=new Date){return[e.getUTCFullYear(),(0,r.pad2)(e.getUTCMonth()+1),(0,r.pad2)(e.getUTCDate()),"-",(0,r.pad2)(e.getUTCHours()),(0,r.pad2)(e.getUTCMinutes()),(0,r.pad2)(e.getUTCSeconds())].join("")}},21330:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const n=i(77988),a=i(51168),o=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(31586),f=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),v=i(79842),w=i(66649),b=i(98247),S=i(98725),P=i(928),_=i(54261),T=i(73389),M=i(89724),E=i(17415),k=i(88600),D=i(51275);function x(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class C{constructor(e,t,i){this.year=e,this.month=t,this.day=i,r.set(this,(0,p.lazy)((()=>(0,k.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(S.ISO_YMD_RE.exec(e)?.groups??S.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,h.toGt0)(e?.year);if(null==e||null==t||tx(e))).join("-")}toLocal(){return(0,M.datedToLocal)(this)}toDateTime(){return a.DateTime.fromObject((0,f.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,f.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,f.pick)(e.plus({month:1}),"year","month"):(0,f.pick)(e.plus({year:1}),"year");return new C(t.year,t.month,t.day)}}function F(e,t){if(e instanceof n.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,_.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,E.zoneToTzOffsetMinutes)((0,w.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(r=>(0,d.map)((0,P.getMonth)(e),(s=>(0,d.map)((0,P.getDay)(e),(n=>(0,d.map)((0,P.getHour)(e),(a=>(0,b.dateObjectToExifDateTime)({year:r,month:s,day:n,hour:a,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=C,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",r=15*(0,h.round)(e/15),s=Math.abs(r),n=Math.floor(s/60),a=Math.floor(Math.abs(s%60));return`${t?"UTC":""}${i}${x(n)}:${x(a)}`},t.toExifDateTime=F,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof n.ExifDateTime?e.tzoffsetMinutes:(0,T.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,_.hasTime)(e)||(i??(0,v.datedToPrecisionMs)(e))>=c.dayMs?O(e):F(e,(0,D.getZoneName)(e))?.toISOString({includeOffset:t})};const A="yyyy:MM:dd HH:mm:ss.SSS",I=A+"ZZ";function O(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>x(e))).join(t)}function L(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new C(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,r]=[e,t].map(w.datedToMillis);return null==i||null==r?void 0:i-r}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,h.isNumber)(t)?a.DateTime.fromMillis(t):(0,v.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,D.hasZone)(t)?I:A):void 0},t.datedToYMD=O,t.toFuzzyDate=L,t.sameDay=function(e,t){return(0,h.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,h.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,r=1){if(null==(0,w.datedToMillis)(e)||null==(0,w.datedToMillis)(t))return;const[s,n]=[e,t].map((e=>(0,w.datedToMillis)(e))).sort(),o=(n-s)/(r+1),l=(0,D.getZoneName)(e),u=l===(0,D.getZoneName)(t)?l:void 0,c=a.DateTime.fromMillis(s+o*i,{zone:u});return[e,t].some((e=>!(0,_.hasTime)(e)))?L(c):c},t.setZone=function(e,t,i){const r={...(0,f.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,D.hasZone)(e)},s=(0,E.normalizeZone)(t);if(null!=e&&null!=s&&(0,_.hasTime)(e))return e instanceof y.DateInterval?e.setZone(s,r):F(e)?.setZone(s,r)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,h.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,v.datedToDateTime)(e);if(null==i)return;const r=(0,D.getZoneName)(e);return null!=r&&"UTC"!==r||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const o=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),h=i(49769),f=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),v=i(68852),w=i(4001),b=i(28874),S=i(24689),P=i(79842),_=i(66649),T=i(98247),M=i(21330),E=i(54261),k=i(73389),D=i(16400),x=i(88600),C=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return C().tap({msg:"extractDateFromPath",result:O.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return O.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return O.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,f.mapNumeric)((0,_.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,v.concatRegexp)([/^/,t.yearRE,v.RegExpOptional.from(/-/,t.monthRE,v.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,v.concatRegexp)([/^/,t.yearishRE,v.RegExpOptional.from(/-/,t.monthishRE,v.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=I({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,k.isDateTime)(i)?i:(0,E.isExifDateTime)(i)?i.toDateTime():void 0};const F=new Map;function A(e,t,i){try{const r=(0,T.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=r)return r;const s=(0,h.getOrSet)(F,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void C().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,T.parseExifDateTimeFormat)({input:s?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void C().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function I({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:r=!0,descPredicate:s=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const n=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(w.stripDSC));if(0!==n.length)for(const{desc:e,f:a}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>S.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,T.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:T.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(b.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(b.Settings.extraDateTimeFormats.values)){const r=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${r})`,f:i=>A(i,r,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>o.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of O.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:r}))if(s(e))for(const e of n){const t=a(e);if(null!=t&&(0,x.isValidDate)(t))return t}}t.parseDated=I;class O{constructor(e={}){r.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&b.Settings.fuzzyDateParsing.watchLater((()=>a(this,r,"m",n).call(this))),null==e.fuzzyYearParsing&&b.Settings.fuzzyYearParsing.watchLater((()=>a(this,r,"m",n).call(this))),a(this,r,"m",n).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??b.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??b.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!b.Settings.usePathsToInferDates.valueOrDefault)return;M.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=I({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=O,r=new WeakSet,s=function(e){const t=new L(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},n=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new v.RegExpEscaped("(?"+(0,D.monthNames)().map(v.escapeRegExp).join("|")+")");a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),a(this,r,"m",s).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),a(this,r,"m",s).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),a(this,r,"m",s).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,t.monthishRE]),a(this,r,"m",s).call(this,[e,t.seps,t.yearRE]),a(this,r,"m",s).call(this,[t.yearRE,t.seps,e]),a(this,r,"m",s).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},O.instance=(0,u.lazy)((()=>new O));class L{constructor(e){this.regex=e instanceof RegExp?e:(0,v.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return M.FuzzyDate.for({year:(0,f.toInt)(t.year),month:(0,f.toInt)(t.month)??(0,D.monthName2index)(t.monthname),day:(0,f.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const r=i(55835),s=i(31586),n=i(54261);function a(e){return e instanceof Date?e.getMinutes():e?.minute}function o(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=a,t.getSecond=o,t.getMillisecond=l,t.getCentisecond=function(e){return(0,r.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,n.hasTime)(e)&&((0,s.gt0)(a(e))||(0,s.gt0)(o(e))||(0,s.gt0)(l(e)))},t.getSecMs=function(e){return(0,r.map)(o(e),(t=>{const i=l(e)??0;let r=(t+i/1e3).toString();for(t<10&&(r="0"+r),0===i&&(r+=".");r.length<6;)r+="0";return r}))}},54261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const r=i(77988),s=i(31586),n=i(68708);t.hasTime=function(e){if(!(0,n.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,s.gt0)(t.hour)||(0,s.gt0)(t.minute)||(0,s.gt0)(t.second)||(0,s.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof r.ExifDateTime}},73389:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const r=i(51168);t.isDateTime=function(e){return r.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const r=i(51168),s=i(19851),n=i(42659),a=i(55835),o=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),h=i(74417),f=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,s.lazy)((()=>v(l.Settings.datesBeforeAreEstimated.valueOrDefault)??v(l.Settings.datesBeforeAreEstimated.defaultValue)));function v(e){return(0,a.map)((0,c.isoToDated)(e),w)}function w(e){return(0,o.isNumber)(e)?T(e):100*b(e)+((0,m.getCentisecond)(e)??0)}function b(e){if((0,o.isNumber)(e))return Math.floor(T(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function S(e,t){if(null==e||e<0)return;let i=e;const r=()=>{const e=i%100;return i=Math.floor(i/100),e},s=10*r(),n=r(),a=r(),l=(0,o.toGt0)(r()),u=(0,o.toGt0)(r()),c=(0,o.toGt0)(r());return{year:i,month:c,day:u,hour:l,minute:a,second:n,millisecond:s,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=S(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):f.FuzzyDate.for(i)}function _(e,t){return T(Date.now()-e,t)}function T(e,t){return w(r.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const r=i(19851),s=i(76790),n=i(31586),a=i(9092),o=(0,r.lazy)((()=>{const e=new a.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const r=new Intl.DateTimeFormat(t,{month:i});(0,n.times)(12,(s=>{const n=r.format(new Date(2017,s));e.set(n,s+1),"short"===i&&"en-US"===t&&e.set(n+".",s+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:o().get(e)},t.monthNames=function(){return(0,s.sort)([...o().keys()])}},42499:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLuxon=void 0;const r=i(51168),s=i(19851),n=i(19043),a=i(28874);t.setupLuxon=(0,s.lazy)((async()=>{r.Settings.throwOnInvalid=!1,a.Settings.twoDigitCutoffYear.watch((e=>r.Settings.twoDigitCutoffYear=e)),r.Settings.defaultLocale=await(0,n.locale)()}))},17415:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),h=i(54993),f=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,n.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const r=(0,f.leastBy)(g(),(t=>Math.abs(t-e)));return null!=r&&Math.abs(r-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(r)}t.isUTCZone=function(e){return b(e)||0===S(e)?.offset(Date.now())},t.normalizeZone=S,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,o.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=_,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:_(i)};const T=/\b(?Z|UTC|GMT)\b/,M=/(?[-±+−])/,E=/[-−]/,k=/(?[01]\d)/,D=/(?[01]?\d)/,x=/(?::(?\d\d))/;function C(e){return b(e)?0:F((0,t.TimezoneOffsetRE)().exec(e))}function F(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,a.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=E.test((0,h.toS)(e.groups.tzSign))?-1:1,r=(0,l.toInt)(e.groups.tzMinutes)??0,s=null==t?void 0:i*(60*t+r);return v(s)?s:void 0}t.TimezoneOffsetRE=(0,n.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),T,new m.RegExpEscaped("|"),M,k,m.RegExpOptional.from(x),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=C,t.timezoneOffsetFromRegExpMatch=F;const A=/\b(?(?:Etc\/)?GMT)\b/,I=(0,n.lazy)((()=>(0,m.concatRegexp)([A,M,D,m.RegExpOptional.from(x)])));function O(e){return F(I().exec(e))}t.ianaZoneToOffsetMinutes=O,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,a.blank)(e))return;const i=O(e)??C(e);if(null!=i)return _(i);if(null!=t){const i=S(e);if(null!=i)return _(i.offset(t))}}},88600:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),h=i(28874),f=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),v=(0,s.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),w=(0,s.lazy)((()=>(0,n.compact)(h.Settings.badDates.values.map((e=>(0,f.isoToDated)(e)))))),b=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,p.datedToISO)(e)))))),S=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,y.datedToLocal)(e)))))),P=(0,s.lazy)((()=>(0,n.compact)(w().map((e=>(0,m.datedToMillis)(e))))));function _(e){if(null==e)return!1;const t=M(e);return v().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return _(e)?e:void 0},t.isValidDate=_;const T=String(new Date("bad"));function M(e){try{if(!(0,f.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===T)return T;const t=(0,n.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const s=[];if((0,l.isNumber)(e)||s.push("year is not a number"),(0,l.lt)(e,h.Settings.minValidYear.valueOrDefault)&&s.push("year is less than "+h.Settings.minValidYear.key),(0,u.gt)(e,E())&&s.push("year is in the future"),null==t&&null!=i&&s.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&s.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const n=r.DateTime.fromObject({year:e,month:t,day:i});n.isValid||s.push(n.invalidExplanation??"not valid")}return(0,n.compact)(s)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=h.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const r=(0,m.datedToMillis)(e);(0,u.gt)(r,Date.now()+i)&&t.push("date is too far in the future: see "+h.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):S().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):b().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,a.toNotBlank)((0,n.uniq)((0,n.compactBlanks)(t)).join("; "))}catch(t){return v().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=M;const E=(0,s.lazy)((()=>r.DateTime.now().plus({milliseconds:h.Settings.maxValidFutureMs.valueOrDefault}).year),o.dayMs);t.mapValidDate=function(e,t){return _(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==M({year:e,month:t,day:i})}},51275:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const r=i(77988),s=i(31586),n=i(24689),a=i(73389);t.hasZone=function(e){return null!=e&&!(0,s.isNumber)(e)&&(e instanceof n.DateInterval||e instanceof r.ExifDateTime?e.hasZone:!!(0,a.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==r.UnsetZoneName&&e.zone.offset(Date.now())!==r.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,a.isDateTime)(e)?e.zoneName===r.UnsetZoneName?void 0:e.zone?.name:e instanceof r.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const r=i(50989);t.AutoVacuumModes=(0,r.strEnum)("NONE","FULL","INCREMENTAL")},82261:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cacheDbDir_=void 0;const r=i(51926),s=i(49776),n=i(38835),a=i(95696),o=i(70854),l=i(73428),u=i(28874),c=i(15056);t.cacheDbDir_=async function(e=u.Settings.libraryDir.valueOrDefault,t=c.Schemas.models){const i=(0,o.libraryUidStore)(e);if(null==i)throw new Error("Library directory is not set"+n.NoLibraryErrorFlag);const d=await i.readUid_(),h=a.PosixFile.for((0,s.cacheDir_)()).join(t+"-live-db",d);await h.mkdirp_();const f=h.join("README.txt");return await(0,l.writeTextfile_)(f.nativePath,...(0,r.wrap)(["This folder is used by PhotoStructure for your library stored in",e,"You will corrupt your library if you remove this directory while PhotoStructure is running.","See https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837 for details."].join("\n\n"))),h}},92407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLiveDbDir_=t.cacheDbFile_=void 0;const r=i(19851),s=i(87290),n=i(50213),a=i(28874),o=i(82261),l=i(15056),u=i(7311),c=i(44955),d=(0,r.lazy)((()=>(0,n.mkLogger)("db.CheckLocalDbReplica")));async function h({libraryDir:e=a.Settings.libraryDir.valueOrDefault,schema:t=l.Schemas.models}={}){return(await(0,o.cacheDbDir_)(e,t)).join(u.SqliteBase)}t.cacheDbFile_=h,t.getLiveDbDir_=async function(e=a.Settings.libraryDir.valueOrDefault){if(!a.Settings.forceLocalDbReplica.valueOrDefault){const t=(0,l.pathToDb)(await(0,s.setupLibraryDataDir_)(e),l.Schemas.models);try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!1}}catch(e){d().info("SQLite cannot directly write to the library: trying to use a local db replica.",{libraryDb:t,error:e})}}const t=await h({libraryDir:e,schema:l.Schemas.models});try{return await(0,c.assertDirSQLiteReadWrite_)(t.parent()),{db:t,useReplica:!0}}catch(e){return d().throw("SQLite cannot directly write to the library or the cacheDir.",{cacheDbFile:t,error:e})}}},5531:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const r=i(50989);t.CheckpointTypes=(0,r.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},55332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupCold_=void 0;const r=i(19851),s=i(50213),n=i(76187),a=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbBackupCold")));t.dbBackupCold_=async function(e,t){await t.mkdirp_();const i=[];try{for(const r of(0,n.sqliteFiles)(e)){const e=t.join(r.base).wip();i.push(e),await r.copyFile_(e)}return a().tap({msg:"completed",level:"info",result:await Promise.all(i.map((e=>e.unwip_()))),meta:{srcDbFile:e,destDir:t}})}catch(e){throw await Promise.all(i.map((e=>e.unlink()))),e}}},91872:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleDbRetries_=void 0;const r=i(50213),s=i(70025),n=i(28874),a=i(45599),o=i(41400),l=i(30976),u=i(56038),c=(0,a.defer)((()=>(0,r.mkLogger)("db.DbRetries")));t.handleDbRetries_=function(e,t,i,r){const a=Date.now();let d=0;const h=a+n.Settings.dbMaintenanceTimeoutMs.valueOrDefault;return(0,u.time)(e,(async()=>{for(;Date.now()=h)throw c().error(e+": Caught db error. Not retrying.",{error:t}),t;{const i=(0,l.randomInt)(500,1500)*++d;c().warn(e+": Caught db error. Retrying in "+i+"ms.",{name:e,error:t}),r?.(),await(0,o.delay)(i)}}return t().close(),c().throw(e+": handleDbRetries(): timeout after "+n.Settings.dbMaintenanceTimeoutMs.valueOrDefault+"ms")}))}},12943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toDbValued=t.isDbValued=t.isDbValue=void 0;const r=i(79842),s=i(66649),n=i(40958),a=i(68708);function o(e){return null===e||(0,n.includes)(["number","string"],typeof e)}t.isDbValue=o,t.isDbValued=function e(t){return null!=t&&Array.isArray(t)?t.every(e):(0,a.entries)(t).every((([,e])=>o(e)))},t.toDbValued=function(e){return(0,a.mapFields)(e,((e,t)=>{if(!e.startsWith("$"))return"boolean"==typeof t?[e,t?1:0]:o(t)?[e,t]:(0,r.isDated)(t)?[e,(0,s.datedToMillis)(t)]:void 0}))}},65753:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maxBatchPluckSize=void 0;const r=i(19851),s=i(7282),n=i(28874);t.maxBatchPluckSize=(0,r.lazy)((()=>Math.round(n.Settings.dbBatchSelectSize.valueOrDefault*((0,s.isTest)()?.25:5))))},80632:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pageSizeBytes=t.mkdb_=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(54993),u=i(50213),c=i(23560),d=i(65211),h=i(29882),f=i(53265),m=i(66430),p=i(66184),g=i(28874),y=i(15674),v=i(87550);function w(){const e=g.Settings.dbPageSizeBytes.valueOrDefault;return Math.pow(2,(0,a.clamp)(1,28,Math.round(Math.log2(e))))}t.mkdb_=function({nativePath:e,timeoutMs:t=g.Settings.dbBusyTimeoutMs.valueOrDefault,logSql:i=g.Settings.logSql.valueOrDefault}){e=(0,f.resolve)(e),(0,h.mkdirpSync_)((0,r.dirname)(e));const b=(0,h.posixPathFromGrandparent)(e),S=(0,m.nativePathSizeSync)(e),P=(0,u.mkLogger)("db.mkdb("+b+")");if(null!=S){const E=Math.round(S/o.MiB),k=Math.ceil(1.5*E);k>g.Settings.dbCacheSizeMb.valueOrDefault&&(P.info("Dynamically setting dbCacheSize to "+g.Settings.dbCacheSizeMb.value,{db:e,dbFileSizeMb:E}),g.Settings.dbCacheSizeMb.envValue=k);const D=Math.round(1.5*E);D>g.Settings.maxMemoryMb.valueOrDefault&&(P.warn("Large database: setting maxMemoryDb to "+D+"MB",{dbFileSizeMb:E,"Settings.maxMemoryMb":g.Settings.maxMemoryMb.valueOrDefault}),g.Settings.maxMemoryMb.envValue=D)}P.info("Opening "+e+"...");const _={fileMustExist:!1,readonly:!1};if((0,a.gt0)(t)&&(_.timeout=Math.ceil(t)),i){const x=(0,u.mkLogger)("SQLite("+b+")"),C=(0,p.defaultLogLevel)();function F(e,...t){var i;(0,n.blank)(e)||x.log(C,(i=e,(0,l.toS)(i).replace(/\s{2,}/g," ")),{args:t})}_.verbose=F}const T=new v(e,_);P.info("Open. Setting PRAGMAs...");for(const A of(0,s.compact)(['encoding = "UTF-8"',"threads = "+(0,y.maxCpus)(),"foreign_keys = ON","page_size = "+w(),"trusted_schema = 0","cache_size = -"+Math.round(g.Settings.dbCacheSizeMb.valueOrDefault*o.MiB/1024),"locking_mode = NORMAL","journal_mode = WAL",(0,a.gt0)(g.Settings.dbBusyTimeoutMs.valueOrDefault)?"busy_timeout = "+g.Settings.dbBusyTimeoutMs.valueOrDefault:null,"temp_store = MEMORY","synchronous = "+g.Settings.dbSynchronousMode.valueOrDefault,"case_sensitive_like = 0","wal_autocheckpoint = "+((0,c.isDbJanitorService)()?(0,l.toS)(g.Settings.dbWalAutoCheckpoint.valueOrDefault):"0"),"auto_vacuum = "+g.Settings.dbAutoVacuumMode.valueOrDefault]))P.tapThunk({msg:"PRAGMA "+A,result:()=>T.pragma(A)});const M=T;return M.__uid=(0,d.uid)(),M},t.pageSizeBytes=w},99315:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const r=i(50989);t.RepairModes=(0,r.strEnum)("dump","recover")},95704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withIdBatches=void 0;const r=i(40958),s=i(31586),n=i(59455),a=i(65753),o=i(51040);t.withIdBatches=async function(e){const t=(0,s.toGt0)(e.batchSize)??(0,a.maxBatchPluckSize)(),i=(0,o.dbValueToEscapedString)(e.primaryKeyColumnName),l=(0,r.compactBlanks)([i+" > :min",...(0,n.toA)(e.whereClauses)]).join(" AND "),u=e.db.prepare((0,r.compactBlanks)(["SELECT "+i,"FROM "+(0,o.dbValueToEscapedString)(e.tableName),"WHERE "+l,"ORDER BY "+i,"LIMIT :limit"]).join(" "));let c=-1;for(;;){const i=u.pluck().all({min:c,limit:t});if(0===i.length)return;await e.fn(i),c=(0,r.last)(i)}}},76187:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSqliteFile=t.sqliteSizeBytes=t.sqliteFiles=void 0;const r=i(17217),s=i(87391),n=i(7311);t.sqliteFiles=function(e){return[e,...s.SQLiteSuffixes.map((t=>e.sibling(e.base+t)))].filter((e=>e.existsSync({refresh:!0})))},t.sqliteSizeBytes=async function(e){return(await e.size({refresh:!0})??0)+(await e.sibling(e.base+"-wal").size({refresh:!0})??0)};const a=[n.SqliteExt,...[...s.SQLiteSuffixes,"-shm"].map((e=>n.SqliteExt+e))];t.isSqliteFile=function(e){const t=(0,r.basename)(e);for(const e of a)if(t.endsWith(e))return!0;return!1}},51040:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitBatchSql=t.dbValueToEscapedString=void 0;const r=i(40958),s=i(31586),n=i(54993),a=/^\w+$/;t.dbValueToEscapedString=function(e){if((0,s.isNumber)(e))return e.toString();const t=(0,n.toS)(e);return a.test(t)?t:`'${t.replace(/'/g,"''")}'`};const o=/--.+$/gm,l=/\s+/g;t.splitBatchSql=function(e){const t=(0,r.compactBlanks)((0,n.toS)(e).split(/;/).map((e=>e.replace(o,"").replace(l," ").trim()))),i=[];let s;for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertDirSQLiteReadWrite_=t.isDirSQLiteReadWrite=t.firstDirSQLiteReadWrite=void 0;const r=i(19851),s=i(50357),n=i(30976),a=i(50213),o=i(95696),l=i(80632),u=i(76187),c=(0,r.lazy)((()=>(0,a.mkLogger)("db.SQLiteReadWrite")));async function d(e){try{return await h(e),c().info("isDirSQLiteReadWrite(): true",{dirNativePath:e}),!0}catch(t){return c().warn("isDirSQLiteReadWrite(): false",{dirNativePath:e,error:t}),!1}}async function h(e){const t=o.PosixFile.for(e),i=(0,n.randomChars)(8),r=t.child(".test-"+i+".sqlite");let a=null;try{await t.mkdirp_(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3}),a.exec("CREATE TABLE t (s VARCHAR(16) NOT NULL)"),a.exec(`INSERT INTO t (s) VALUES ('${i}')`);{const e=a.prepare("SELECT s FROM t").all();(0,s.eql)(e,[{s:i}])||c().throw("unexpected rows",{rows:e})}a.exec("VACUUM"),a.close(),a=(0,l.mkdb_)({nativePath:r.nativePath,timeoutMs:1e3});{const e=(0,n.randomChars)(8);a.exec(`INSERT INTO t (s) VALUES ('${e}')`);const t=a.prepare("SELECT s FROM t ORDER BY s").pluck().all();(0,s.eql)(t,[i,e].sort())||c().throw("unexpected rows",{rows:t})}}finally{try{a?.close()}catch{}await Promise.all((0,u.sqliteFiles)(r).map((e=>e.rm())))}}t.firstDirSQLiteReadWrite=async function(...e){for(const t of e)if(null!=t&&await d(t))return t},t.isDirSQLiteReadWrite=d,t.assertDirSQLiteReadWrite_=h},87391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SQLiteSuffixes=void 0,t.SQLiteSuffixes=["-wal","-journal"]},27180:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteVersion_=void 0;const r=i(5916),s=i(84777),n=i(89966),a=i(63870),o=i(87550);t.sqliteVersion_=(0,r.lazyAsync)({later:async function(){let e;try{e=new o(":memory:");const t=e.prepare("select sqlite_version()").pluck().get(),i=await(0,n.sqliteNativePath_)(),r=(await(0,s.stdout_)(i,["-version"],{timeoutMs:(0,a.commandTimeoutMs)()})).trim();return{libraryVersion:t,toolVersion:r.split(/\s+/,1)[0],fullToolVersion:r,sqliteNativePath:i}}finally{e?.close()}},timeoutMs:(0,a.commandTimeoutMs)()})},15056:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const r=i(50989),s=i(7311);function n(e,t){return e.join(t)}t.Schemas=(0,r.strEnum)("models"),t.pathToDbDir=n,t.pathToDb=function(e,t){return n(e,t).join(s.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const r=i(50989);t.SynchronousModes=(0,r.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const a=n(i(76760)),o=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),v=i(70698),w=i(64680),b=i(29882),S=i(45969),P=i(43334),_=i(28874),T=i(41692),M=i(32774),E=i(80612),k=i(32551),D=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function x(){if((0,S.isDocker)())return[{dir:"/tmp/.photostructure-cache"+D(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,a.join)(i,".photostructure-cache"+D()),preexistingDir:i});return e}}function C(){if((0,S.isDocker)())return(0,o.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,a.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+D(),preexistingDir:M.DefaultDockerLibraryDir},...x()]);const e=(0,o.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),a.default.resolve((0,k.homeDir)(),"AppData","Local")]:P.isMac?[a.default.resolve((0,k.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,a.join)((0,k.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,a.join)(e,t),preexistingDir:e})));return i.push(...x()),i}t.tmpCacheDirs=x,t.tmpDirs=function(){return(0,E.filterDirs)({dirs:x(),desc:"tmp"})},t.cacheDirs=C,t.defaultCacheDir=(0,d.lazy)((()=>(0,E.firstDir)({dirs:C(),desc:"cache"})));const F=(0,d.lazy)((()=>{(0,T.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(A)}));function A(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{F();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,b.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=A},46292:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const r=i(19851),s=i(45969),n=i(41692),a=i(32774),o=i(10924),l=i(84373),u=i(80612);t.configDir=(0,r.lazy)((()=>((0,n.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,s.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,o.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:a.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:a.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,s.isDocker)()?c:(0,o.desktopConfigDirs)()).map((e=>e.dir))}},79960:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultApplePhotosLibrary=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(45255),o=i(84777),l=i(16287),u=i(57902),c=i(43334),d=(0,r.lazy)((()=>(0,n.mkLogger)("dir.DefaultApplePhotosLibrary"))),h=["read","com.apple.photolibraryd","SystemLibraryPath"];t.defaultApplePhotosLibrary=async function(){if(c.isMac)try{const e=await(0,o.stdout_)("defaults",h,{timeoutMs:a.ShortCommandTimeoutMs});if((0,s.blank)(e))return void d().warn(`"defaults ${h.join(" ")}" returned blank (!!)`);{const t=await(0,l.isReadableDirectory)(e);return d().tap({msg:"defaultApplePhotosLibrary()",level:u.LogLevels.info,result:t?e:void 0,meta:{isReadable:t}})}}catch(e){return void d().warn("defaultApplePhotosLibrary()",e)}}},32774:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const r=i(66430),s=i(45969),n=i(32774);t.defaultLibraryDir=function(){return(0,s.isDocker)()?n.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,s.isDocker)()&&(0,r.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const s=r(i(76760)),n=i(40958),a=i(72993),o=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),s.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(s.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,o.env)().XDG_DATA_HOME,(0,o.env)().XDG_CONFIG_HOME,s.default.resolve((0,d.homeDir)(),".config")),(0,n.compactBlanks)(e).map((e=>({dir:s.default.join(e,(0,a.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const r=i(22573),s=i(96706),n=i(29882);t.envConfigDir=function(){const e=(0,s.getEnv)("PS_CONFIG_DIR");if(!(0,r.blank)(e))try{return(0,n.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const r=i(44652),s=i(40958),n=i(22573),a=i(66430);function o({dirs:e,desc:t}){for(const{dir:i,preexistingDir:o}of(0,s.compact)(e))if(!(0,n.blank)(i)){if((0,a.isReadWriteableDirectorySync)(i))return i;if((0,n.blank)(o)||(0,a.isReadWriteableDirectorySync)(o))try{return(0,r.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=o,t.filterDirs=function({dirs:e,desc:t}){return(0,s.compact)(e.map((e=>o({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const r=i(48161),s=i(76760),n=i(1708),a=i(19851),o=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,a.lazy)((()=>{const e=[];u.isWin?e.push(n.env.USERPROFILE):e.push(n.env.HOME);for(const t of(0,o.compactBlanks)(e)){const e=(0,s.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,r.homedir)()}))},35280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const r=i(29882),s=i(49776),n=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,r.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[n.libraryDataDir,n.libraryPreviewsDir,s.cacheDir])if((0,r.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},48195:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyNotLibraryDir=t.isLibraryDir=void 0;const r=i(19851),s=i(22573),n=i(98553),a=i(12168),o=i(50213),l=i(15056),u=i(98314),c=i(17217),d=i(16287),h=i(2858),f=i(87290),m=(0,r.lazy)((()=>(0,o.mkLogger)("dir.IsLibraryDir")));function p(e){return null==e?"(null)":(0,n.stringify)((0,c.toNativePath_)(e))}async function g(e){return m().tap({msg:"whyNotLibraryDir("+e+")",result:await y(e)})}async function y(e){if((0,s.blank)(e))return"blank path";const t=(0,c.toNativePath_)(e);try{const e=await(0,d.stat_)(t);if(null==e||!e.isDirectory())return"not a directory"}catch(e){return"cannot read: "+(0,u.errorToS)(e)}const i=(0,f.libraryDataDirPosixFile)(t);if(!0!==await(i?.isDirectory({refresh:!0,logLevel:"trace"})))return"library data directory, "+p(i)+", is not a directory";const r=(0,h.librarySettingsFile)(t)?.clear();if(null==r||!await r.isNonEmptyFile())return"library settings, "+p(r)+", is empty or missing";const n=(0,l.pathToDb)(i,"models")?.clear();if(null==n||!await(n?.isNonEmptyFile(a.KB)))return"library database, "+p(n)+", is empty or missing";const o=(0,f.libraryPreviewsDirPosixFile)(t);return!0!==await(o?.isDirectory({refresh:!0,logLevel:"trace"}))?"library previews, "+p(o)+", is empty or missing":void 0}t.isLibraryDir=async function(e){return null==await g(e)},t.whyNotLibraryDir=g},9595:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const r=i(22573),s=i(54993),n=i(29882),a=i(28874);function o(e){return(0,r.toNotBlank)((0,s.toS)(e))??a.Settings.libraryDir.valueOrDefault}t.libraryDir=o,t.originalsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,n.resolveMaybe)(o(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,n.resolveMaybe)(o(e),a.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const r=i(40958),s=i(55835),n=i(37805),a=i(15056),o=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${n.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function v(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+o.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function w(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function b(e){return y(w(e),!1)}function S(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(S(e))}function _(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function T(e){return y(_(e))}async function M(e){return y((0,s.map)(g(e),(e=>(0,a.pathToDbDir)(e,a.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await v(t);return(0,r.uniq)([t,i,await b(t),await P(t),await T(t),await M(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=v,t.libraryOriginalsDirPosixFile=w,t.setupLibraryOriginalsDir_=b,t.libraryPreviewsDirPosixFile=S,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=_,t.setupLibrarySyncReportsDir_=T,t.setupLibraryDbDir_=M},46296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),v=i(80612),w=i(32551);function b(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:s.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,a.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>s.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function S(){return(0,v.firstDir)({dirs:b(),desc:"logs"})}t.defaultLogDirs=b,t.defaultLogDir_=S,t.logDir=(0,n.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,o.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,o.notBlank)(i)?i:S()}catch(e){return console.error("defaultLogDir_() failed",e),s.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(44198),o=i(43334),l=i(24399),u=i(32551);async function c(){return o.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,s.lazy)((async()=>{if(o.isWin){const e=await c();if((0,n.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,s.lazy)((()=>(0,a.env)().XDG_PICTURES_DIR??(0,r.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const r=i(38639),s=i(7282),n=i(29325),a=i(44198);t.getDevEnvFlag=function(e){return!(0,s.isProd)()&&!(0,n.isPacked)()&&((0,r.toBoolean)((0,a.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,a.env)()[e]=String(t)}},34580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const r=i(38639),s=i(44198);t.doNotTrack=function(){return(0,r.isTrue)((0,s.env)().DO_NOT_TRACK)}},44198:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const s=r(i(73024)),n=i(76760),a=r(i(1708)),o=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),v=i(6012),w=i(96706);t.env=(0,o.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>a.default.env[e])).join(n.delimiter).split(n.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===a.default.env.PS_LICENSE||e.push((0,n.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),i={...a.default.env};for(const r of e)try{const e=(0,d.debom)(s.default.readFileSync((0,p.resolve)(r))),n=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,r]of(0,c.entries)(n))t.test(e)||(i[e]=r)}catch(e){console.warn("env(): failed to read .env file, "+r,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const r=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,r.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const r=i(50989);t.EnvKeys=(0,r.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const r=i(22573),s=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,r.blank)(e))return i;let n;for(const a of(0,s.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(n=e.exec(a));){if(null==n.groups)continue;const{key:e,val:s}=n.groups;if((0,r.blank)(e)||null==s)continue;const a=s.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=a}}return i}},96706:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const s=r(i(1708)),n=i(19851),a=i(22573),o=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,n.lazy)((()=>(0,a.firstNotBlank)(s.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,s.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,n.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,n.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,o.isTrue)(g(e))}},98314:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const r=i(58587),s=i(19851),n=i(40958),a=i(22573),o=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),v=i(70025),w=i(57159);function b(...e){if((0,n.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(o.errorName),...e.map(o.errorCode),...(0,n.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(o.ErrorDelimiter)))];return(0,n.uniqSubstrings)(S((0,l.flatten)(i)))}function S(e){return(0,n.compact)(e).filter((e=>!o.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(a.notBlank)}function P(e,t){const i=(0,n.uniqSubstrings)(S(e)),r=t?.maxLen??400,s=t?.trailingChars??64,a=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(i.join(o.ErrorDelimiter)),r-a.length,s)+a.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,a.blank)(e)?"":P(b(e),t)}t.StartTs=Date.now(),t.logger=(0,s.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new r.Rate,t.fatalErrorRate=new r.Rate,t.internalErrorRate=new r.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,a.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,a.notBlank)(i))return i}},t.splitErrorMessage=b,t.normalizeErrorMessages=S,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,r=7){return(0,a.blank)(e)&&(e=t.MissingError),_(e,{maxLen:i})+" at "+(0,o.shortStack)(e?.stack,r).join("; ")}},41954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const r=i(40958),s=i(26905),n=i(55835),a=i(54993),o=i(81168);t.describeError=function(e){const t=(0,o.stripSuffix)((0,a.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,n.map)((0,s.errorErrno)(i),(e=>t.push(u.get(e)))),(0,n.map)((0,s.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,r.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const r=i(40958),s=i(76790),n=i(50989),a=i(68852);t.ErrorFlags=(0,n.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,s.sortBy)((0,r.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(a.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},68301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorStore=t.ExtraEventsForPlease=void 0;const r=i(19851),s=i(42659),n=i(75240),a=i(55835),o=i(31586),l=i(68708),u=i(59455),c=i(54993),d=i(50213),h=i(45255),f=i(37628),m=i(99331),p=i(46292),g=i(38835),y=i(32144),v=i(29882),w=i(95696),b=i(55222),S=i(28874),P=(0,r.lazy)((()=>(0,d.mkLogger)("error.EventStore")));function _(e){return(0,l.omit)(e,"breadcrumbs")}t.ExtraEventsForPlease=7;class T{constructor(e){this.root=e}datedRoot(e=new Date){return this.root.join((0,c.toS)(e.getFullYear()),(0,c.toS)(e.getMonth()+1))}rmrf(){return this.root.rmrf()}msg2file(e){return this.datedRoot(new Date(e.timestamp*s.secondMs)).join((0,f.shortStringSha)(e.message,8,b.GeoRadix)+".json")}async eventsFrom(e=new Date,t=s.dayMs){const i=e.getTime(),r=i-t,a=i+t;return P().tap({msg:"eventsFrom()",result:(0,u.toA)(await this.datedRoot(e).clear().childFiles((async e=>P().tap({msg:"eventsFrom().childFiles() accept "+e.base,result:(0,y.isJsonExt)(e)&&!(0,v.isHiddenBasename)(e.base)&&(0,o.within)(r,a,e.mtimeMs())})))),meta:{when:e,deltaMs:(0,n.fmtDuration)(t)}})}async eventCount(e=new Date){return(await this.eventsFrom(e)).length}async eventQuotaExceeded(e){const i=(0,c.toS)(e).includes(g.PleaseSendErrorFlag)||(0,c.toS)(e.message).includes(g.PleaseSendErrorFlag),r=await this.eventCount(),s=S.Settings.maxErrorsPerDay.valueOrDefault+(i?t.ExtraEventsForPlease:0);return P().tap({msg:"eventQuotaExceeded()",result:r>=s,meta:{event:_(e),recentEventCount:r,maxErrorsPerDay:s,pleaseSend:i}})}async maybeSendEvent(e){if(e.timestamp=Math.floor(e.timestamp),(0,m.ending)())P().error("maybeSendEvent(): REJECT: we're ending.",{event:_(e)});else if(await this.eventQuotaExceeded(e))P().error("maybeSendEvent(): REJECT: too many recent events.",{event:_(e)});else try{const t=await this.writeEvent_(e);return P().tap({msg:"maybeSendEvent(): "+t==null?"REJECT: previously sent this event already this month":"ACCEPT",result:null!=t?e:void 0,meta:{eventFile:t}})}catch(e){return void P().error("maybeSendEvent(): REJECT: failed to write event.",e)}}writeEvent_(e){return this.msg2file(e).applyIfEmpty_({fn_:t=>t.writeJson_(e),minSizeBytes:3,returnUndefinedIfNotEmpty:!0,timeoutMs:h.ShortCommandTimeoutMs})}}t.ErrorStore=T,T.instance=(0,r.lazy)((()=>(0,a.map)((0,p.configDir)(),(e=>new T(w.PosixFile.for(e).join("events"))))))},70025:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const r=i(40958),s=i(38639),n=i(26905),a=i(54993),o=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,a.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,a.toS)(e)+(0,r.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,o.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function b(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function S(e){return!!((0,s.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||b(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=b,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===S(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,n.errorCode)(e)||v(e)||w(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=S;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,s.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,s.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},51837:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.InternalError=void 0;const r=i(38835);class s extends Error{constructor(e){super(e+r.InternalErrorFlag)}}t.InternalError=s},8769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const r=i(22573),s=i(31586),n=i(68708),a=i(7282),o=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,r.blank)(e)&&(0,n.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const s=!0===i.fatal,c=!0===i.ignorable;if(!s&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),s&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!s||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!s||(0,a.isTest)()||(0,o.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),s}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,s.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,o.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,s.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,s.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(26905),o=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,s.blank)(i.message)||e.message.includes(i.message)))return e;const r=(0,s.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(r??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,r.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,a.errorName)(t)??(0,d.first)(this.causes,a.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(a.errorCode)],a.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,a.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,s.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,n.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,n.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,n.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const r=t?.path;return(0,s.blank)(r)||(i=(0,h.dedupeNeedle)(i,r,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,o.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const a=i(49769),o=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,r.set(this,new Map),s.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,a.getOrSet)(n(this,r,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),a=n(this,r,"f").get(e);return null!=a&&(a.resolve(t),n(this,r,"f").delete(e)),i}emitDebounced(e,...t){(0,o.map)(n(this,s,"f").get(e),clearTimeout),n(this,s,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},r=new WeakMap,s=new WeakMap},34102:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const r=i(78474),s=i(19851),n=i(15197);t.ee=(0,s.lazy)((()=>{const e=new r.EventEmitter;return e.setMaxListeners(70),new n.CapturingEventEmitter(e)}))},41293:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiHealthRouter=void 0;const s=r(i(7252)),n=i(45599),a=i(18454),o=i(51773);t.ApiHealthRouter=class{constructor(e="/api/health"){this.mountpoint=e,this.router=(0,n.defer)((()=>s.default.Router().get(this.mountpoint,(0,o.wrap)(this.constructor.name+".health",this.health)))),this.health=async(e,t)=>{t.json(await a.HealthCheck.awaitSettled())}}}},51773:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableCache=t.truthyQuery=t.extractLang=t.requestLang=t.extractTagPath=t.jsonOrRedirect=t.getSeedOrRedirect=t.getFit=t.getSeed=t.wrap=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(38639),o=i(55835),l=i(97790),u=i(97238),c=i(99036),d=i(41942),h=i(54993),f=i(48884),m=i(50213),p=i(97352),g=i(56038),y=i(38835),v=i(57159),w=i(51140),b=i(68178),S=i(62327),P=(0,r.lazy)((()=>(0,m.mkLogger)("express.Handlers")));function _(e){return(0,l.opt)(e).filter(n.notBlank).map(h.toS).map((e=>e.split(","))).map(s.compactBlanks).map((e=>e.map((e=>e.split(";").map((e=>e.trim())))))).flatMap((e=>(0,f.greatestBy)(e,(([,e])=>(0,p.firstGt0)((0,p.extractFloat)(e),1))))).map((([e])=>e)).get()}t.wrap=function(e,t){return async(i,r,s)=>(0,g.time)(e,(()=>(0,S.wrapWithToast)({f:()=>t(i,r,s),response:r})))},t.getSeed=function(e){return(0,u.toSeed)(e.query.seed)},t.getFit=function(e){return c.ThumbFits.validOrElse((0,h.toS)(e.query.fit),c.ThumbFits.square)},t.getSeedOrRedirect=function(e,t){const i=(0,u.toSeed)(e.query.seed);if(null==i){let i=(0,b.requestedUri)(e);"/tag/"===i.path&&(i=i.with({path:"/tag"})),i.query.append("seed",(0,h.toS)((0,u.prngSeed)())),t.redirect(i.toString())}return i},t.jsonOrRedirect=function(e,t){if(null==e)return(0,S.sendErrorToast)(new v.WrappedError("Internal error: jsonOrRedirect(null)"+y.InternalErrorFlag,{fatal:!1,doNotSend:!0}),t,404);for(const i of[d.XLocationRedirect,d.XLocationReplace]){const r=e[i];(0,n.notBlank)(r)&&(P().debug("jsonOrRedirect(): "+i,r),t.setHeader(i,r),t.status(w.HttpStatus.SeeOther))}return t.json(e)},t.extractTagPath=function(e){const t=e.replace(/^(?:\/api)?\/tag\/?/,""),i=t.split("/").map(decodeURIComponent),r=(0,n.blank)(t)?[]:i;return P().info("extractTagPath()",{path:e,result:r,trimmed:t,tagPath:i}),r},t.requestLang=function(e){const t=e.headers["accept-language"];return _(Array.isArray(t)?t.join(","):t)},t.extractLang=_,t.truthyQuery=function(e,t){return(0,o.mapOr)(e.query[t],(e=>!(0,a.isFalse)(e)),(()=>!1))},t.disableCache=function(e){e.setHeader("Cache-Control","no-store, max-age=0"),e.setHeader("Pragma","no-cache"),e.setHeader("Expires","Fri, 01 Jan 1990 00:00:00 GMT")}},68259:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onFinished=void 0,t.onFinished=function(e,t){let i=!1;e.on("error",(r=>{i||(i=!0,t(r,e))}));const r=()=>{i||(i=!0,t(null,e))};for(const t of["end","finish","close"])e.on(t,r);return e}},27821:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.redirectRouter=void 0;const s=r(i(7252)),n=i(49586),a=i(51140),o=i(62327);t.redirectRouter=function(e){return s.default.Router().use(((t,i)=>(0,n.isAjaxRequest)(t.headers)?(0,o.sendRedirectionToast)({response:i,redirectOrReplace:"redirect",url:"/splash"}):i.redirect(a.HttpStatus.Found,e)))}},40749:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.referrer=t.isXhr=void 0;const r=i(54993),s=/^XMLHttpRequest$/i;t.isXhr=function(e){return e.xhr||null!=s.exec((0,r.toS)(e.header("X-Requested-With")))},t.referrer=function(e){return e.header("Referer")}},78147:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RequestLogger=void 0;const r=i(7252),s=i(19851),n=i(22573),a=i(42659),o=i(55835),l=i(50213),u=i(8769),c=i(18454),d=i(51576),h=i(43705),f=i(82647),m=i(28874),p=i(51140),g=i(68259),y=i(68178);t.RequestLogger=class{constructor(){this.logger=(0,l.mkLogger)("web.RequestLogger"),this.responseTimes=new f.Average,this.accessLogger=m.Settings.logWebRequests.valueOrDefault?new h.LogWriter((0,n.firstNotBlank)(m.Settings.logWebDir.valueOrDefault,m.Settings.logDir.valueOrDefault),{processName:(0,s.lazy)((()=>"webrequest"))}):void 0,this.router=(0,r.Router)().use(((e,t,i)=>{const r=Date.now(),s=e.method,n=`${e.protocol?.toUpperCase()}/${e.httpVersion}`,l=`${s} ${(0,y.requestedUri)(e)} ${n}`,h=e.path.startsWith("/sse/")||"/updates"===e.path||"/api/splash"===e.path||"/api/status"===e.path?void 0:setTimeout((()=>this.logger.warn("Request is still processing: "+l,{elapsedMs:Date.now()-r})),4*(this.responseTimes.p84??a.secondMs));(0,g.onFinished)(t,(i=>{(0,o.map)(h,clearTimeout),null!=i&&(0,u.onError)(l,{error:i});const a=p.HttpStatusIs.success(t.statusCode)||p.HttpStatusIs.redirect(t.statusCode),f=Date.now()-r,m={from_ip:e.ip,protocol:n,method:s,statusCode:t.statusCode,ok:a,elapsedMs:f,runState:c.HealthCheck.runState(),userAgent:e.headers["user-agent"]};null!=i&&(m.error=i),this.responseTimes.push(f),(0,d.logBroadcaster)()?.log(a?"info":"warn","HttpRequestLogger",l,m),this.accessLogger?.log("info","",l,m),null==d.logBroadcaster.prior()&&null==this.accessLogger&&this.logger.log(null==i&&a?"debug":"warn",l,m)})),i()}))}}},68178:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addXSettingsHandler=t.requestedUri=void 0;const r=i(19851),s=i(41400),n=i(98553),a=i(37805),o=i(89724),l=i(34102),u=i(81674),c=i(28874),d=i(34238),h=i(69385),f=(0,r.lazy)((()=>({protocol:"http",host:c.Settings.hostname.valueOrDefault??"localhost",url:"/"})));t.requestedUri=function(e,t){const i={...f(),...t};return d.URI.parse((e?.protocol??i.protocol)+"://"+(e?.headers?.host??i.host)+(e?.originalUrl??i.url))};const m=(0,r.lazy)((()=>"lite"));async function p(){m.set(await(0,u.t)()),y.unset()}const g=(0,r.lazy)((()=>(0,c.isProd)()?"":"+"+(0,o.nowLocal)())),y=(0,r.lazy)((()=>{const e={ver:a.version+g(),paused:(0,h.isPaused)(),ll_vh:c.Settings.lazyLoadExtraVh.valueOrDefault,tier:m()};return Buffer.from((0,n.stringify)(e)).toString("base64")}));(0,s.later)((()=>{(0,l.ee)().on("settingsChanged",(()=>y.unset())),(0,l.ee)().on("reloadLicenses",p),u.m.watch(p),(0,l.ee)().on("pause",(()=>y.unset())),(0,l.ee)().on("resume",(()=>y.unset()))})),t.addXSettingsHandler=function(e,t,i){t.setHeader("X-Settings",y()),i()}},43394:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.serveStaticGz=void 0;const r=i(22573),s=i(54993),n=i(50213),a=i(56639),o=i(81168),l=i(38835),u=i(83278),c=i(14036),d=i(51773),h=/\.asar\/?/i;t.serveStaticGz=async function(e){const t=(0,n.mkLogger)("serveStaticGz"),i=u.BaseFile.for(e),f=await i.descendants((e=>e.ext.endsWith(".gz"))),m=(0,a.toMap)(f,(e=>(0,r.mapNotBlank)((0,c.extMimetype)((0,o.stripSuffix)(e.ext,".gz")),(t=>["/"+(0,o.stripSuffix)(e.posixPathFrom(i),".gz"),{contentType:t,nativePath:e.nativePath}]))));return t.debug("ready to serve",[...m.keys()]),0===m.size&&t.error("Can't read "+i+". Please visit https://forum.photostructure.com/ for help."+l.FatalErrorFlag),(0,d.wrap)("serveStaticGz",(async(e,i,r)=>{if(null!=e.path.match(h))return i.sendStatus(404);const n=m.get((0,s.toS)(e.path));return null==n?r():(t.debug("get",{path:e.path,result:n}),i.set("Content-Encoding","gzip"),i.set("Content-Type",n.contentType),i.sendFile(n.nativePath))}))}},18405:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ServerSentEventsRouter=void 0;const s=r(i(7252)),n=i(40958),a=i(22573),o=i(25764),l=i(38836),u=i(36868),c=i(72901),d=i(51773);class h extends l.EndableWrapper{constructor(e){super("SSERouter("+e+")",(()=>this.close()),o.EndableRanks.first),this.path=e,this.streams=[]}router(){return s.default.Router().get(this.path,(0,d.wrap)(this.name,this.updates.bind(this)))}async close(){await Promise.all(this.streams.map(u.endStream)),this.streams.length=0}async updates(e,t){if(this.ended)return void t.sendStatus(503);this.logger.info("Sending updates to "+(e.ip??e.ips));const i=(0,u.remoteDesc)(e.socket);t.writeHead(200,{"Content-Type":"text/event-stream; charset=utf-8","Cache-Control":"no-cache",Connection:"keep-alive","X-Accel-Buffering":"no"}),this.streams.push(t),t.once("error",(e=>{(0,n.removeSame)(this.streams,t),this.logger.warn("onError("+i+")",{error:e})})),t.once("close",(()=>{(0,n.removeSame)(this.streams,t),this.logger.debug("stream to "+i+" closed. ("+this.streams.length+" remain)")}));const r=(0,n.compact)(this.firstEvents(e,t));(0,n.isNotEmpty)(r)&&(this.logger.info("firstEvents",{firstEvents:r}),t.write((0,c.mkEventStream)(...r)))}endStream(e){(0,u.endStream)(e).catch((()=>{})),(0,n.removeSame)(this.streams,e)}writeToStreams(...e){const t=(0,c.mkEventStream)(...e);if(this.logger.info("writeToStreams",{events:e,payload:t}),!(0,a.blank)(t))for(const e of this.streams)if(!0===e?.closed||null==e?.socket)this.endStream(e);else try{e.write(t)}catch(t){null==e.socket||e.closed?this.endStream(e):this.logger.warn("writeToStreams failed to write to stream",{stream:(0,u.remoteDesc)(e.socket),error:t})}}}t.ServerSentEventsRouter=h},62327:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapWithToast=t.expressErrorHandlerWithToast=t.sendErrorToast=t.send404Toast=t.sendWarningServerToast=t.sendRedirectionToast=t.sendServerToast=t.requireEnabled=t.requirePlus=void 0;const r=i(19851),s=i(55835),n=i(41942),a=i(71050),o=i(27776),l=i(41583),u=i(50213),c=i(98314),d=i(70025),h=i(81674),f=i(49586),m=i(51140),p=i(68178),g=(0,r.lazy)((()=>(0,u.mkLogger)("express.ServerToastHelpers")));function y({response:e,toast:t,httpStatusCode:i,reload:r}){return(0,s.map)(i,(t=>e.status(t))),g().warn("sendServerToast()",{requestedURI:(0,p.requestedUri)(e.req),toast:t,httpStatusCode:i}),e.json({toast:t,reload:r})}function v(e,t,i){g().warn("sendErrorToast",e);const r=(0,d.stripErrorFlags)((0,c.errorToS)(e));y({response:t,toast:{text:404===i?"Not found":"Well, darn, that didn't work",uuid:r,details:r,type:(0,d.isFatalError)(e)?"error":"warning",button1Text:"Return home",button1Url:"/"+a.DismissAnchor,button1Class:"info",onClickUrl:a.DismissAnchor},httpStatusCode:i??m.HttpStatus.ServiceUnavailable})}t.requirePlus=async function(e,t,i){if(await(0,h.l)()){const e={toastPlusOnly:!0};return t.status(m.HttpStatus.Forbidden),t.json(e)}return i()},t.requireEnabled=function(e){return(t,i,r)=>e.valueOrDefault?r():y({response:i,toast:{text:"This has been disabled by your administrator.",details:`(see setting "${e.name}")`,type:"warning"},httpStatusCode:m.HttpStatus.Forbidden})},t.sendServerToast=y,t.sendRedirectionToast=function({response:e,toast:t,url:i,redirectOrReplace:r}){if((0,f.isAjaxRequest)(e.req.headers)){const s="replace"===r?n.XLocationReplace:n.XLocationRedirect;return e.setHeader(s,i),g().warn("sendRedirectionToast()",{requestedURI:(0,p.requestedUri)(e.req),toast:t,key:s,url:i}),e.json({toast:t})}return e.redirect(i)},t.sendWarningServerToast=function({response:e,toast:t,httpStatusCode:i,reload:r}){return t.type??(t.type="warning"),y({response:e,toast:t,httpStatusCode:i,reload:r})},t.send404Toast=function({text:e,details:t,response:i,httpStatusCode:r=404}){return y({response:i,toast:{text:e,details:t,type:"warning",button1Text:"Go home",button1Url:(0,o.mkHomeFullPath)()+a.DismissAnchor,button1Class:"info",onClickUrl:a.DismissAnchor,timeout:!1},httpStatusCode:r})},t.sendErrorToast=v,t.expressErrorHandlerWithToast=function(e,t,i,r){null==e?r():v(e,i)},t.wrapWithToast=async function({f:e,response:t}){try{await e()}catch(e){(0,s.map)((0,l.toErr)(e),(e=>v(e,t)))}}},30576:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.viewRouter=void 0;const s=r(i(7252)),n=i(51773);t.viewRouter=function({path:e,view:t,modeler:i}){return s.default.Router().get(e,(0,n.wrap)(t+"Router",(async(e,r)=>{const s=await(i?.(e,r))??{};return s.nonce=r.locals?.cspNonce,r.render(t,s)})))}},64660:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const s=r(i(73024)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,a.lazy)((()=>n.default.geteuid?.())),h=(0,a.lazy)((()=>n.default.getgroups?.()));function f(e,t){try{return!(0,o.blank)(e)&&(s.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,s.default.constants.R_OK|s.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,s.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:r=!1,processUid:s,processGid:n}){if(null==e)return!1;const a=s??d(),o=null!=n?[n]:h()??[],l=0===a,u=l||e.uid===a,f=l||o.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!r||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const r=await(0,u.statMaybe)(i);if(null!=r){if(!r.isDirectory())return!1;if(t){if(!p(r,e))return!1}else if(t=!0,!m(r,e))return!1}}return!0},t.access=g},21144:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const s=r(i(76760)),n=i(19851),a=i(81168),o=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,n.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),r=await m(i.dir);for(const e of await(0,d.readdir_)(r))if((0,a.equalsIgnoreCase)(e.basename,i.base))return s.default.join(r,e.basename);throw new o.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const r=i(73024),s=i(76760);function n(e){return[...a(e)]}function*a(e){for(;e!==(0,s.dirname)(e);)e=(0,s.dirname)(e),yield e}function o(e){try{return(0,r.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=o(e);return t.every((e=>i.includes(e)))}t.ancestors=n,t.ancestorG=a,t.selfAndAncestorG=function*(e){yield e,yield*a(e)},t.childrenSync=o,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return n(e).find((e=>l(e,t)))}},83278:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),v=f(i(1708)),w=i(46466),b=f(i(57975)),S=f(i(38522)),P=i(19851),_=i(40958),T=i(5233),M=i(22573),E=i(42659),k=i(50357),D=i(96249),x=i(98553),C=i(55835),F=i(31586),A=i(68708),I=i(97790),O=i(39926),L=i(51926),R=i(59455),N=i(54993),B=i(48884),j=i(22911),z=i(99331),V=i(56519),W=i(56038),U=i(31562),q=i(76850),H=i(70025),$=i(34102),G=i(80875),J=i(50213),K=i(70417),Y=i(43334),X=i(81168),Z=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),re=i(84542),se=i(89968),ne=i(20197),ae=i(88561),oe=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),ve=i(27794),we=i(73428),be=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const Se=(0,P.lazy)((()=>new ae.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(r.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),s.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),a.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(s=new WeakMap,a=new WeakMap,r=new WeakSet,b.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,B.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,M.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const r=Se().get(i);if(null!=r)return r;const s=(0,fe.resolve)(i),n=new Pe(s,t);return Se().set(i,n),Se().set(s,n),n}static clear(e){(0,$.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(se.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,$.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,s,"f").unset(),h(this,a,void 0,"f"),this}clearThisAndParent(){return(0,$.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,X.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,C.map)(this.statSync(),(e=>new se.DirectoryEntry(this.dir,new se.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,s,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const i=[];for(const r of t)!0===await e(r)&&i.push(r);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,r,"m",n).call(this)??await d(e=this.clearThisAndParent(),r,"m",n).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const r of i)t.push(...(0,R.toA)(await r.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,F.gt0)(t))return;const i=await d(this,s,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const r of i)if(r.isDirectory()){const i=await this._directoryEntryChild(r).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,k.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,C.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,O.pad2)(t+1),(0,O.pad2)(i))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,D.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,E.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),B.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>=(0,E.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,E.unixtime)(t)>(0,E.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,C.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,U.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*E.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,oe.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,oe.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,G.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,G.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,q.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,be.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),re.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,x.stringify)(e,t?.replacer,t?.spaces),(0,A.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,T.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,z.ending)()?1:3,timeoutMs:0,retryDelay:E.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,r,"m",o).call(this,(0,X.stripSuffix)(this.base,".gz"),S.default.createGunzip())}async gzip(){return d(this,r,"m",o).call(this,this.base+".gz",S.default.createGzip())}async compressBrotli(){return d(this,r,"m",o).call(this,this.base+".br",S.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,ne.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,ne.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(S.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,_.isEmpty)(i))return;const r=await e.sha();if(null!=r)for(const e of i.sort(((e,t)=>-(0,Z.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===r)return e}))}firstMatchingLine(e){const t=new j.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,L.newlineRe)(),(r=>{const s=e.exec(r);null!=s&&(t.maybeResolve(s),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const r of e)for(const e of i)if((0,F.closeTo)(r,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new j.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),_e)try{const r=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(r,s)=>{try{const n=await e.f(r,(0,C.denull)(s));t(n)&&i.resolve(n)}catch(e){i.reject(e)}}));i.finally((()=>{r.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,F.gt0)(e.intervalMs)){const r=setInterval((async()=>{try{const r=await e.f();t(r)&&i.resolve(r)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||r.unref(),i.finally((()=>{clearInterval(r)}))}return i}}t.BaseFile=Pe,n=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,X.equalsIgnoreCase)(e.basename,this.base))),t=(0,B.leastBy)(e,(e=>(0,Z.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,C.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},o=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*E.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},19748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const r=i(28874),s=i(88840),n=i(14036),a=i(29882);function o(e){return t=>r.Settings.respectFileExtensions.valueOrDefault?(0,n.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,a.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=o,t.isBrowserExtension=o(s.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=o(s.ExtTypes.Video),t.isAssetFileExtension=o(s.ExtTypes.AssetFile)},84542:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const r=i(40958),s=i(96249),n=i(51926),a=i(54993),o=i(43334);function l(...e){return(0,s.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,a.toS)(e).split((0,n.newlineRe)()))))}t.Newline=o.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(a.toS).join("\n");return o.isWin?t.replace((0,n.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,r.compactBlanks)(l(...e))}},70698:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const r=i(76760),s=i(19851),n=i(50213),a=i(37805),o=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,s.lazy)((()=>(0,n.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,r.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,o.mkdirp_)(i),await(0,d.writeTextfile_)((0,o.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+a.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,a.lazy)((()=>[...(0,o.mapNotBlankOr)(n.default.env.SYSTEMROOT,(e=>[e,s.default.join(e,"System32"),s.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const o=n(i(44652)),l=a(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),v=i(14427),w=i(17217),b=i(16287),S=i(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class T{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new T(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:r}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},s=await o.stat(t);return new T(i,new P(r,s))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return T.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new T(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>T.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new T(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,S.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,b.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await o.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await o.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=T},20197:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const s=r(i(76760)),n=i(39926),a=i(29882),o=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if(await(0,a.mkdirp_)(r.dir),!i.requireNumber&&await(0,o.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if(await(0,o.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},r=(0,a.parseNativePath)(i.nativePath);if((0,a.mkdirpSync_)(r.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=s.default.join(r.dir,`${r.name}-${(0,n.leftPad)(e,i.leftPad,"0")}${r.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},92423:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notInHiddenPhotoStructureDir=t.whyExcludedDirectoryRecursive=t.notExcludedDirs=t.isExcludedDirectory=t.whyExcludedDirectory=t.notExcludedDirPredicates=t.isExcludedFile=t.whyExcludedFile=t.notExcludedFilePredicates=t.excludeBundles=t.excludeGlobs=t.defaultFilePredicates=t.defaultDirPredicates=t.formatPathForGlob=void 0;const l=o(i(83058)),u=i(19851),c=i(40958),d=i(76790),h=i(22573),f=i(55835),m=i(51926),p=i(54993),g=i(48884),y=i(9092),v=i(54557),w=i(50213),b=i(88158),S=i(56519),P=i(46292),_=i(32551),T=i(35280),M=i(87290),E=i(96706),k=i(57902),D=i(43334),x=i(78984),C=i(33995),F=i(28874),A=i(21144),I=i(83278),O=i(48313),L=i(85772),R=i(78133),N=i(46356),B=i(17217),j=(0,u.lazy)((()=>(0,w.mkLogger)("fs.ExcludeGlobs"))),z=new v.FifoCache(256),V=/[\\/]$/;function W(e){const t=(0,p.toS)(e),i=z.get(t);if(null!=i)return i;const r=(0,B.isSimpleFile)(e)?e:I.BaseFile.for(e),s=V.test(t)||r.isDirectorySync(),n=(0,R.native2posix)(r.nativePath),a=s?(0,m.ensureSuffix)(n,"/"):n;return z.set(t,a),z.set(a,a),z.set(r.nativePath,a),a}t.formatPathForGlob=W;class U{constructor(e,t,i=!0){if(r.add(this),this.pattern=e,this.desc=t,this.exclude=i,e.includes("\\")){const t=e;e=(0,R.native2posix)(t),j().warn("globToPredicate(): backslash in patterns aren't supported: assuming you meant forward-slash?",{given:t,input:e})}this.reason=(0,c.compactBlanks)([this.exclude?"not":"",t,"("+(0,m.ellipsize)(e,48,12)+")"]).join(" ");try{this.re=l.default.makeRe(this.pattern,{nocase:F.Settings.globsCaseInsensitive.valueOrDefault,dot:!0,posixSlashes:!0}),this.valid=!0}catch(e){this.valid=!1,j().warn("Cannot parse pattern",{glob:this.pattern,error:e})}this.bundle=this.valid&&null!=this.re?(0,b.pairToObject)(this.reason,a(this,r,"m",s).bind(this)):{}}}r=new WeakSet,s=function(e){const t=W(e),i=this.re.test(t)??this.exclude;return j().tap({msg:"apply()",level:i?k.LogLevels.debug:k.LogLevels.trace,result:i?!this.exclude:this.exclude,meta:{desc:this.desc,pattern:this.pattern,exclude:this.exclude,posixPath:t,matched:i}})};class q{constructor(){n.set(this,[])}push(...e){for(const t of e){if(!t.valid){j().warn("Ignoring invalid glob",{glob:t});continue}const e=a(this,n,"f").find((e=>e.pattern===t.pattern));null==e?a(this,n,"f").push(t):j().debug("Ignoring duplicate glob",{glob:t,prior:e})}}pushNativePath(e,t){this.push(new U((0,R.native2posix)(e),t))}toA(){return a(this,n,"f")}}n=new WeakMap;const H=new U("**/.*","hidden file"),$=new U("**/.*/","hidden directory"),G=(0,u.lazy)((()=>{const e=new q;e.push($,H);for(const t of[{s:"bin",desc:"command binary"},{s:"dev",desc:"device file"},{s:"etc",desc:"system configuration file"},{s:"initrd",desc:"initial ramdisk"},{s:"proc",desc:"process metadata"},{s:"sbin",desc:"system binary"},{s:"snap",desc:"snap software"},{s:"sys",desc:"system metadata"},{s:"Dell",desc:"Windows driver"},{s:"Drivers",desc:"Windows driver"},{s:"Intel",desc:"Windows driver"},{s:"Microsoft",desc:"Windows driver"},{s:"NVIDIA",desc:"Windows driver"},{s:"Windows.old",desc:"Windows system"},{s:"Windows",desc:"Windows system"}])e.push(new U((D.isWin?"*":"")+"/"+t.s+"/",t.desc));if(D.isWin)for(const t of["ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemRoot","windir"]){const i=(0,E.getEnv)(t);(0,h.blank)(i)||e.pushNativePath(i,`%${t}%`)}D.isLinux&&e.push(new U(`${(0,_.homeDir)()}/snap/`,"Snap software"));for(const t of[{s:"__MACOSX",desc:"macOS resource fork"},{s:"_includes",desc:"code"},{s:"@eaDir",desc:"Synology thumbnail"},{s:"@Recently-Snapshot",desc:"QNAP snapshot"},{s:"@Recycle",desc:"QNAP trash"},{s:"@SynoResource",desc:"Synology metadata"},{s:"#recycle",desc:"Synology trash"},{s:"#snapshot",desc:"Synology snapshot"},{s:"$Recycle.Bin",desc:"Windows trash"},{s:"$SysReset",desc:"Windows"},{s:"3rdParty",desc:"code"},{s:"Application Data",desc:"Windows apps"},{s:"Application Support",desc:"macOS apps"},{s:"Applications",desc:"macOS apps"},{s:"arangodb",desc:"3rd party"},{s:"cache",desc:"Cache directory"},{s:"CacheClip",desc:"Movie cache directory"},{s:"caches",desc:"Cache directory"},{s:"Chipset_Software",desc:"Windows apps"},{s:"cmake",desc:"code"},{s:"com.apple.TimeMachine.localsnapshots",desc:"macOS"},{s:"cpan",desc:"code"},{s:"DefinitelyTyped",desc:"TypeScript type"},{s:"Desktop DB",desc:"macOS metadata"},{s:"Desktop DF",desc:"macOS metadata"},{s:"Desktop.ini",desc:"macOS metadata"},{s:"DisplayDriver",desc:"Windows driver"},{s:"DLLs",desc:"Windows library"},{s:"dyld",desc:"macOS library"},{s:"ehthumbs.db",desc:"Windows thumbnail"},{s:"i18n",desc:"i18n code"},{s:"iMovie Cache",desc:"Apple iMovie cache"},{s:"iTunes Cache",desc:"Apple iTunes"},{s:"iTunes Media",desc:"Apple iTunes"},{s:"iTunes",desc:"Apple iTunes"},{s:"lib?(32|64|x64|s)",desc:"program library directory"},{s:"lost+found",desc:"fsck recovered directory"},{s:"macOS Install*",desc:"macOS installer"},{s:"Network Trash",desc:"AFP trash"},{s:"node_modules",desc:"Node.js library"},{s:"pkgconfig",desc:"code"},{s:"pkgs",desc:"Python code"},{s:"Program Files (x86)",desc:"Windows apps"},{s:"Program Files",desc:"Windows apps"},{s:"ProgramData",desc:"Windows application support"},{s:"resources/media/face",desc:"face thumbnail"},{s:"rubygems-*",desc:"Ruby code"},{s:"site-packages",desc:"Python code"},{s:"spotifycache",desc:"Spotify cache"},{s:"SteamApps",desc:"Game files"},{s:"System Volume Information",desc:"Windows system metadata"},{s:"System32",desc:"Windows system"},{s:"SystemTemp",desc:"Windows temporary"},{s:"temp",desc:"temporary"},{s:"Temporary Items",desc:"temporary"},{s:"test_suite",desc:"code"},{s:"testutil?(s)",desc:"code"},{s:"third_party",desc:"code"},{s:"Thumbnail?(s)",desc:"thumbnail"},{s:"Thumbs.db",desc:"Windows thumbnail"},{s:"tmp",desc:"temporary"},{s:"Trash",desc:"trash directory"},{s:"Windows",desc:"Windows"},{s:"Windows.old",desc:"Windows"},{s:"Windows10Upgrade",desc:"Windows upgrade"},{s:"Xcode.app",desc:"macOS code"},{s:"*.sparsebundle/bands",desc:"Time Machine backup"},{s:"ImageMagick*",desc:"ImageMagick source"},{s:"Install OS X*",desc:"macOS installer"},{s:"Install macOS*",desc:"macOS installer"},{s:"*.lrdata",desc:"LightRoom data"},{s:"MinGW*",desc:"code"},{s:"msys*",desc:"code"},{s:"vcpkg",desc:"code"}])e.push(new U("**/"+t.s+"/",t.desc));function t(t,i,r){if(!(0,h.blank)(t)){const s=(0,d.sort)((0,c.uniq)((0,c.compactBlanks)(i).map((e=>e.toLowerCase()))));1===s.length&&e.push(new U(`**/${t}/${s[0]}/`,r)),s.length>1&&e.push(new U(`**/${t}/(${s.join("|")})/`,r))}}(0,f.map)((0,P.configDir)(),(t=>e.pushNativePath(t,"PhotoStructure configuration"))),t("nix",["store"],"NixOS package"),e.push(new U("**/*.(photo|photos|ap)library/!(master|masters|modified|original|originals)/","Apple Photos/Aperture library")),e.push(new U("**/facetile*","face thumbnail"));const i=["bin","cygdrive","dev","etc","games","include","lib?(32|64|x64)","local","locale","man","proc","sbin","share","src","tmp","usr","var"];t("usr",i,"FHS system"),t("cygwin?(64)",i,"Cygwin"),t("local",i,"FHS system"),t("Windows",["assembly","Boot","Containers","Cursors","Fonts","Help","Installer","Logs","Microsoft.NET","Servicing","SoftwareDistribution","System32","SystemApps","SysWOW64","Temp","WinSxS"],"Windows"),t("Recovery",["Customizations","OEM"],"Windows"),t("lib",["firmware","modules","systemd","udev","x86_64-linux-gnu"],"Linux system package"),t("opt",["google","x11",...i],"FHS package"),t("lfs",["incomplete","objects"],"Git LFS object");const r=["cache","crash","games","lib","local","lock","log","logs","mail","run","snap","spool","tmp"];t("var",r,"Linux /var"),t("mnt",r,"Linux /mnt"),t("dev",["block","bsg","bus","char","cpu","disk","dri","fd","hugepages","input","lightnvm","mapper","mqueue","net","pts","shm","snd","ubuntu-vg","usb","vfio"],"Linux /dev backup"),t("proc",["acpi","asound","bus","driver","fs","ipmi","irq","net","scsi","self","sys","sysvipc","thread-self","tty"],"Linux /proc backup"),t("library",["Apple","Assistant","Bluetooth","com.apple.iTunesCloud","Containers","CoreAnalytics","Developer","Desktop Pictures","Documentation","Extensions","Finance","Fonts","Frameworks","FrontBoard","Group Containers","HTTPStorages","iTunes","KeyboardServices","Keychains","Logs","Messages","News","Passes","Photos","Preferences","Ruby","Saved Application State","Scripts","User Pictures","Updates","User Template","WebKit","WebServer"],"macOS Library"),t("packages",["*.pkg","*.mpkg"],"macOS package"),t("src/**",["bin","ci","dist","doc?(s)","etc","lib?(s)","main","spec?(s)","src","test?(s)","tools","util"],"code"),t("docs",["admin","content","general","generated","sql"],"code"),t("pkg",["acceptance","ccl","cli","cmd","server","sql","storage","ui","util","workload"],"code"),t("osv",["apps","arch","compiler","external","include","java","modules","musl","tests"],"code"),t("go",["bin","blog","cmd","doc","lib","misc","pkg","src","test","vt"],"code"),t("Perl?(64)",["bin","eg","etc","html","lib","site"],"code"),t("Python*",["dlls","doc?(s)","include","lib?(s)","scripts","tools","tcl"],"code"),t("Ruby*",["bin","include","lib","msys*","packages","share","ssl"],"code"),t("msys*",["clang*","dev","etc","mingw*","tmp","ucrt*","var"],"code"),t("sdk",["build-tools","emulator","extras","patcher","platforms","platform-tools","sources","tools"],"code"),t("test",["fixtures"],"code"),t("data",["$of"],"windows backup"),t("System",["Applications","Developer","DriverKit","Library","iOSSupport"],"macOS System"),t("contents",["frameworks","plugins","resources","sharedsupport"],"macOS application"),t("pg",["pgsql"],"code");for(const e of["local","locallow","roaming"])t("appdata",[e],"Windows default AppData");return t("ps",["cache","config","logs","tmp"],"PhotoStructure docker directory"),e.toA()})),J=()=>{t.excludeGlobs.unset(),t.excludeBundles.unset()},K=()=>{t.notExcludedDirs.unset()},Y=(0,u.lazy)((()=>{F.Settings.excludeGlobsOmitDefaults.watchLater(J),F.Settings.excludeGlobsAdd.watchLater(J),F.Settings.excludeGlobsOmit.watchLater(J),F.Settings.globsCaseInsensitive.watchLater(J),F.Settings.libraryDir.watchLater(K),F.Settings.originalsDir.watchLater(K),F.Settings.scanPaths.watchLater(K),F.Settings.argvScanPaths.watchLater(K)}));t.defaultDirPredicates=(0,u.lazy)((()=>[{notSymlinkLoop:re,notInHiddenPhotoStructureDir:ne,whyNoMedia:L.whyNoMedia,notHidden:se}])),t.defaultFilePredicates=(0,u.lazy)((()=>[{notInHiddenPhotoStructureDir:ne}])),t.excludeGlobs=(0,u.lazy)((()=>{Y();const e=new y.CaseInsensitiveMap;function t(t){if(null!=t&&t.valid){const i=t.pattern.trim();e.has(i)&&j().warn("Duplicate glob:",{glob:t}),e.set(i,t)}}function i(t){const i=t.trim();e.has(i)?e.delete(i):j().warn("Failed to find and remove glob specified in PS_EXCLUDE_GLOBS_OMIT",{glob:t})}if(!F.Settings.excludeGlobsOmitDefaults.valueOrDefault)for(const e of G())t(e);for(const e of F.Settings.excludeGlobsOmit.values)i(e);for(const e of F.Settings.excludeGlobsAdd.values)t(new U(e,"(from PS_EXCLUDED_GLOBS_ADD)"));const r=(0,d.sortBy)(e.values(),(e=>(0,c.compactBlanks)(e.pattern.toLowerCase().split("/")))),[s,n]=(0,g.partition)(r,(e=>e.pattern.endsWith("/")));return{dir:s,file:n}})),t.excludeBundles=(0,u.lazy)((()=>{const e=(0,t.excludeGlobs)();return{dir:[...(0,t.defaultDirPredicates)(),...e.dir.map((e=>e.bundle))],file:[...(0,t.defaultFilePredicates)(),...e.file.map((e=>e.bundle))]}}));const X=[{disableAllFilters:()=>!0}],Z=[{notBlank:()=>!1}];function Q(e){return F.Settings.disableAllFilters.valueOrDefault?X:(0,h.blank)(e)?Z:(0,t.excludeBundles)().file}function ee(e){return C.SyncPredicates.whyRejected(e,...Q(e))}function te(e){return F.Settings.disableAllFilters.valueOrDefault?X:(0,h.blank)(e)?Z:(0,t.excludeBundles)().dir}async function ie(e){return F.Settings.disableAllFilters.valueOrDefault?void 0:x.Predicates.whyRejected(e,...te(e))}function re(e){return!(0,N.seemsLikeSymlinkLoop)(e)}function se(e){return(0,S.thenNot)((0,O.isHidden)(e))}function ne(e){return!(0,T.inHiddenPhotoStructureDir)(e)}t.notExcludedFilePredicates=Q,t.whyExcludedFile=ee,t.isExcludedFile=function(e){return null!=ee(e)},t.notExcludedDirPredicates=te,t.whyExcludedDirectory=ie,t.isExcludedDirectory=async function(e){return null!=await ie(e)},t.notExcludedDirs=(0,u.lazy)((async()=>{const e=(0,c.uniq)((0,c.compactBlanks)([(0,M.libraryDirPosixFile)(),(0,M.libraryOriginalsDirPosixFile)(),...F.Settings.argvScanPaths.values,...F.Settings.scanPaths.values]));return j().tap({msg:"notExcludedDirs() (these directories will never be excluded)",level:"info",result:(0,c.uniq)([...e,...await Promise.all(e.map((e=>(0,A.actualPath)(e))))])})})),t.whyExcludedDirectoryRecursive=async function(e){const i=await(0,t.notExcludedDirs)();for(let t=e;null!=t&&!t.isRoot;t=await(t?.parent())){if(i.includes(t?.nativePath))return;const e=await ie(t);if(null!=e)return e}},t.notInHiddenPhotoStructureDir=ne},88561:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const a=i(40958),o=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),r.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>n(this,r,"m",s).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,a.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,r=new WeakSet,s=async function(e){if((0,o.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},79267:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCleanup=void 0;const c=i(19851),d=i(40958),h=i(42659),f=i(31586),m=i(71371),p=i(50213),g=i(7282),y=i(409),v=i(78406),w=i(25764),b=i(99331),S=i(91655),P=i(34102),_=i(89968),T=i(85772);class M{static for(e){return new M(e.name,e.rootNativePath,e.staleMs,e.isPrunable,e.minRetained)}constructor(e,t,i,a,d=0){r.add(this),this.name=e,this.rootNativePath=t,this.staleMs=i,this.isPrunable=a,this.minRetained=d,s.set(this,void 0),this.intervalMs=(0,c.lazy)((()=>(0,f.clamp)((0,g.isTest)()?0:5*h.minuteMs,h.dayMs,this.staleMs/2))),n.set(this,void 0),this.cleanup=(0,y.rateLimited)({name:this.name,minCallDelayMs:this.intervalMs()/4,f:()=>u(this,r,"m",o).call(this)}),l(this,s,(0,p.mkLogger)("fs.FileCleanup("+e+")"),"f")}scheduleInterval(){return(null==u(this,n,"f")||u(this,n,"f").ended)&&l(this,n,new v.EndableInterval({name:this.name,callback:()=>this.cleanup(),intervalMs:this.intervalMs(),rank:w.EndableRanks.first}),"f"),u(this,n,"f")}cancelInterval(){u(this,n,"f")?.end(),l(this,n,void 0,"f")}}t.FileCleanup=M,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(e){if(!(0,f.gt0)(this.minRetained))return new Set;const t=new m.BoundedGreatestSet(this.minRetained??0,(e=>e.mtimeMs()));return await e.visitDescendants((e=>{e.isFile()&&t.add(e)})),new Set(t.vacuum().map((e=>e.nativePath)))},o=async function(){try{if((0,b.ending)())return;const e=await this.rootNativePath();if(null==e)return[];const t=await _.DirectoryEntry.for(e);if(null==t)return[];u(this,s,"f").info("cleanup(): starting",{root:t,staleMs:(0,S.fmtFullDuration)(this.staleMs," ")});const i=await u(this,r,"m",a).call(this,t),n=Date.now()-this.staleMs,o=new Set,l=[],c=[];await t.clear().visitDescendants((async e=>{if((e.dir!==t.nativePath||!(0,T.isNoMediaName)(e.base))&&!i.has(e.nativePath)&&(o.has(e.nativePath)||!(0,f.gte)(e.mtimeMs(),n)))if(e.isDirectory())try{await e.rmdir_(),c.push(e.nativePath),o.add(e.dir)}catch(t){"ENOENT"===t.code&&(u(this,s,"f").warn("cleanup(): ENOENT "+e,t),(0,P.ee)().emit("clearCache")),"ENOTEMPTY"!==t.code&&u(this,s,"f").warn("cleanup(): failed to rmdir "+e,t)}else if(!1!==await(this.isPrunable?.(e)))try{await e.unlink_(),l.push(e.nativePath),o.add(e.dir)}catch(t){u(this,s,"f").warn("cleanup(): failed to clean up tmpfile "+e,t)}}));const h=[...l,...c];return(0,d.isNotEmpty)(h)&&t.clear(),u(this,s,"f").info("cleanup(): done",{root:t,pruned_file_count:l.length,pruned_dir_count:c.length}),h}catch(e){return void u(this,s,"f").error("cleanup() failed",{error:e})}}},32144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const r=i(73024),s=i(22573),n=i(45599),a=i(96249),o=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,n.defer)((()=>{const e={};for(const[t,...i]of d)for(const r of i)e[r]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof r.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,s.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,a.flatten)((0,o.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const r=i(68708),s=i(17217),n=i(16287),a=i(68284);async function o(e){return(0,r.pick)(await(0,n.stat_)((0,s.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=o,t.fileStats=async function(e){try{return await o(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,a.statSync)((0,s.toNativePath)(e)))?void 0:(0,r.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const r=i(68817),s=i(19851),n=i(22573),a=i(50213),o=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),h=i(95696),f=i(93854),m=i(16287),p=(0,s.lazy)((()=>(0,a.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,f.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,r.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const s=(0,n.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),a=(0,l.normalizeExt)(h.PosixFile.for(e))??(0,c.mimetypeExt)(s);return(0,n.blank)(s)||(0,n.blank)(a)?void 0:{ext:a,mime:s}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new o.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),r.add(this),this.nativePath=e,s.set(this,[]),n.set(this,void 0),a.set(this,void 0),l(this,a,(0,f.fileStatsSync)(e),"f"),l(this,n,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,r,"m",o).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,s,"f").push(e)}close(){u(this,n,"f").close()}}t.FileWatcher=m,s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,a,"f"),t)){l(this,a,t,"f");for(const t of u(this,s,"f"))t(e,this.nativePath)}}},13829:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withFsAdvisoryLocks_=t.defaultFsAdvisoryLockDir=void 0;const r=i(55835),s=i(13538),n=i(81168),a=i(37628),o=i(46292),l=i(73209),u=i(95696);function c(){return(0,r.map)((0,o.configDir)(),(e=>u.PosixFile.for(e).join("advisory-locks")))}t.defaultFsAdvisoryLockDir=c,t.withFsAdvisoryLocks_=async function({name:e,lockNames:t,f:i,timeoutMs:r,lockDir:o=c()}){if(null==o)return i();await o.mkdirp_();const u=(0,n.sortIgnoreCase)(t).map((e=>l.FsLock.for({name:e,file:o.join((0,a.shortFsStringSha)(e)),timeoutMs:r})));try{for(const t of u)if(!0!==await(0,s.thenOrTimeout)(t.acquire_(),r))throw new Error("Failed to acquire lock for "+e+": "+t.opts.name+" was busy");return await i()}finally{for(const e of u)e.release()}}},73209:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,v,w,b=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},S=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const _=i(58587),T=P(i(44652)),M=i(87997),E=i(40958),k=i(17586),D=i(42659),x=i(50357),C=i(75240),F=i(55835),A=i(31586),I=i(30976),O=i(13538),L=i(54993),R=i(7282),N=i(68852),B=i(23560),j=i(25764),z=i(38836),V=i(99331),W=i(22781),U=i(38835),q=i(55222),H=i(63870),$=i(69734),G=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)($.PsLockExt)+"$");class K extends z.EndableWrapper{static newUid(e=process.pid){return S(this,s,Math.max(Date.now(),b(this,s,"f",n)+1),"f",n),(0,E.compactBlanks)([q.TokenRadix.encode(b(this,s,"f",n)),B.serviceName.prior(),(0,L.toS)(e)]).join("-")}static pidFromLockfile(e){return s.pidFromBasename((0,G.basename)(e))}static pidFromBasename(e){return(0,A.toInt)(J.exec((0,L.toS)(e))?.groups?.pid)}static for(e){return b(this,s,"f",o).find((t=>t.opts.file===e.file))??new s(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>b(this,r,"m",w).call(this)),e.endableRank??j.EndableRanks.postdb,(0,H.commandTimeoutMs)()),r.add(this),this.opts=e,l.set(this,S(t=s,s,(i=b(t,s,"f",a),++i),"f",a)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(b(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,$.fsLockFileBasename)(s.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await b(this,r,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,$.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+b(this,l,"f")),this.staleMs=(0,A.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),b(s,s,"f",o).push(this)}get acquired(){return b(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await b(this,r,"m",f).call(this,e)??b(this,r,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,k.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,x.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==b(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:D.secondMs);S(this,c,setInterval((()=>b(this,r,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=b(this,c,"f")&&(clearInterval(b(this,c,"f")),S(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(b(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),S(this,u,!1,"f"),(0,F.map)(b(this,d,"f"),(e=>(0,M.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?b(this,r,"m",v).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),S(this,d,setTimeout((()=>b(this,r,"m",v).call(this)),(0,A.toGt0)(this.staleMs)??D.secondMs),"f"),b(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(b(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,O.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,s=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,r=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,A.gt0)(this.staleMs)&&Date.now()>b(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await b(this,r,"m",m).call(this),meta:{why:t}})},m=async function(){S(this,h,Date.now(),"f");const e=[],t=await b(this,r,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,A.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+D.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,$.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;s.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+U.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const n=i[0]===this.lockfile.base;if(n)S(this,u,!0,"f");else if(!0!==t?.vacuum){const t=s.pidFromBasename(i[0]);if((0,A.gt0)(t)&&!(0,_.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),b(this,r,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:n,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await b(this,r,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},v=async function(){await b(this,r,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},w=function(){(0,E.filterInPlace)(b(s,s,"f",o),(e=>b(e,l,"f")!==b(this,l,"f")))},n={value:0},K.internalErrors=0,a={value:0},o={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const r=i(22573),s=i(51926),n=i(54993),a=i(17217);function o(e){return(0,r.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,s.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,s.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,r.blank)((0,n.toS)(e)))return;const i=(0,a.basename)(e);return o(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,r.blank)(e)&&o((0,a.basename)(e))}},4001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const r=i(22573),s=i(55835),n=i(31586),a=i(51926),o=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,r.toNotBlank)(e.name)??(0,o.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let r=e;for(const e of i.aggressive?d:c){const t=r.match(e);if((0,n.gt0)(t?.index)){const e=r.slice(0,t.index).trim();e.length>0&&(r=e)}}return e===r?e:f(r,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,r.blank)(i))return e;const s=(0,u.parsePosixPath)(i),n=h(s,{aggressive:!1});return[...t,n+s.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,a.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),r=(0,a.stripPrefix)(t.toLowerCase().normalize(),i);return(0,s.map)((0,l.extractInt)(r),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,a.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,s.map)(m.exec(t),(e=>t=e[1].trim())),(0,s.map)(g.exec(t),(e=>t=e[1].trim())),t}},19254:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fileGrep_=t.GrepReader=void 0;const s=r(i(73024)),n=i(57075),a=i(46466),o=i(54993),l=i(33456),u=i(17217),c=i(58722);class d extends n.Transform{constructor(e,t="\n"){super({objectMode:!1,autoDestroy:!0}),this.pattern=e,this.sep=t}_transform(e,t,i){const r=(0,o.toS)(e).match(this.pattern);null!=r&&this.push(r[1]??r[0]+this.sep),i()}}t.GrepReader=d,t.fileGrep_=async function(e,t){const i=new c.WritableToBuffer;return await(0,a.pipeline)([s.default.createReadStream((0,u.toNativePath_)(e)),new l.LineReader,new d(t),i]),(await i.buffer).toString()}},14977:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const s=r(i(44652)),n=r(i(73024)),a=i(46466),o=r(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,a.pipeline)(n.default.createReadStream(e,{autoClose:!0}),o.default.createGzip(),n.default.createWriteStream(t,{autoClose:!0})),await s.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const s=r(i(77598)),n=r(i(73024)),a=i(46466),o=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),v=i(16287),w=(0,o.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),b=(0,o.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function S(e,{autoInvalidate:i=!0}={}){const r=(0,y.toNativePath_)(e);if(i){const t=b().get(r);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:r,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:r,prior:t}),b().delete(r)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await _(n.default.createReadStream(i)),stats:(0,u.pick)(await(0,v.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],i="sha512"){const r=s.default.createHash(i);return await(0,a.pipeline)([e,...t,r]),r.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:b,impl:P}),t.fileShaMeta_=S,t.fileSha_=async function(e){return(await S(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return s.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const r=i(19851),s=i(42659),n=i(55835),a=i(31586),o=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,o.stdout_)("chflags",["hidden",t],{timeoutMs:10*s.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,r.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,n.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,o.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*s.secondMs}),i=(0,a.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const r=i(22573),s=i(54993),n=i(7282),a=i(43334),o=i(69375),l=/^\/dev(?:\/|$)/i,u=a.isMac||(0,n.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=a.isMac||(0,n.isTest)()?/^\/private\//i:void 0,d=a.isMac||(0,n.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=a.isMac||(0,n.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,s.toS)(e))}function m(e){return(0,r.blank)(e)?"blank":(0,o.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},87128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JsonFileStore=void 0;const r=i(19851),s=i(55835),n=i(57159),a=i(50213);t.JsonFileStore=class{constructor(e,t,i){this.file=e,this.mkObject=t,this.onWrite=i,this.prior=(0,r.lazy)((()=>this.file.readJson("debug")))}async read_(){return await this.prior()??(0,s.map)(await this.mkObject(),(e=>this.write_(e)))}async write_(e){try{return await this.file.writeJson_(e,{spaces:2}),this.prior.set(Promise.resolve(e)),(0,a.mkLogger)("fs.JsonFileStore").info("wrote to "+this.file,e),null!=this.onWrite&&await this.onWrite(this.file,e),e}catch(e){throw new n.WrappedError("Failed to write to "+this.file,{cause:e,path:this.file.nativePath})}}}},33456:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const r=i(57075),s=i(51926),n=i(54993);class a extends r.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const r=(this._prior+(0,n.toS)(e)).split((0,s.newlineRe)()),a=r.pop();this._prior=a??"";let o=!1;for(const e of r)o||(o=!this.push(e));o?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=a},64680:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const s=r(i(76760)),n=i(17217),a=i(73428);t.mkNoMedia_=function(e){return(0,a.writeTextfile_)(s.default.join((0,n.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},61704:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nativePathsEql=t.nativePathsEqlSync=void 0;const r=i(21144),s=i(17217);t.nativePathsEqlSync=function(e,t){if(null==e||null==t)return!1;if(e===t)return!0;try{const i=(0,s.toNativePath_)(e),r=(0,s.toNativePath_)(t);return null!=i&&null!=r&&i===r}catch{return!1}},t.nativePathsEql=async function(e,t){try{return null!=e&&null!=t&&await(0,r.actualPath_)((0,s.toNativePath_)(e))===await(0,r.actualPath_)((0,s.toNativePath_)(t))}catch{return!1}}},85772:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const a=n(i(76760)),o=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),v=i(83278),w=i(70698),b=i(88561),S=i(65238),P=i(16287),_=(0,o.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),T="NoMedia",M=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(a.default.sep),"/"]).join("")+"])\\.?"+T+"$","im"),E=Object.freeze(["."+T,T]),k=Object.freeze((0,u.flatten)(E.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function D(e){return null!=M.exec(e)}t.isNoMediaName=D;const x=(0,o.lazy)((()=>new b.FileCache({name:"fs.noMediaDirsCache"})));async function C(e,t){if(null==e)return null;const i=v.BaseFile.for(e),r=await i.stat();if(null==r||!r.isFile()&&!r.isDirectory())return null;if(r.isFile())return D(i.base)||await(0,w.isCachedirTagFile)(i)?x().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):C(i.parent());{const e=await x().getOrSetAsync(i.nativePath,(()=>F(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:C(i.parent())}}async function F(e){if(D(e.base))return x().set(e.parent().nativePath,e.nativePath),_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,S.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,r=await Promise.race([A(e.nativePath,i),(0,S.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=r?r:await(0,w.isCachedirTagDirectory)(e)?_().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(w.CACHEDIR_TAG).nativePath)}):null}async function A(e,t){for(const i of g.isCaseSensitiveFs?k:E){if(!0===t?.aborted)return null;const r=a.default.join(e,i);if(await(0,P.exists)(r,p.LogLevels.trace))return _().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(r)})}return null}async function I(e,t,i){for(const r of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(D(r.basename))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,a.join)(e,r.basename))});if(r.basename===w.CACHEDIR_TAG){const t=(0,a.join)(e,r.basename);if(await(0,w.isCachedirTagFile)(t))return _().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await C(e,t)},t.whyNoMedia=C,t.whyNoMediaDir=F,t._dirHasNoMediaChild=A},29882:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),v=i(78133),w=i(53265),b=i(17217),S=i(16287),P=i(66430),_=i(5545);function T(e){return((0,b.isSimpleFile)(e)?e.base:n.default.basename(n.default.resolve(e))).startsWith(".")}t.logger=(0,a.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=T,t.containsHiddenPathname=function(e){return C(e).some(T)},t.isNotHiddenPosixPath=function(e){return C(e).every((e=>!T(e)))},t.resolveSimpleFile=function(e){return(0,b.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return E((0,v.posix2native)(e))},t.extname=function(e){return E(e).ext},t.dirname=function(e){return n.default.dirname((0,b.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(n.default.parse(e).ext,n.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function E(e){const t=M.exec(e)?.groups,i=t?.ext2??"",r=n.default.parse(t?.path??e);return{...r,ext:(r.ext??"")+i,base:(r.base??"")+i}}function k(e){const t=n.default.parse((0,b.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,n.default.sep)}function D(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,b.toNativePath_)(e.ancestor),i=(0,b.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const r=e.acceptSelf??!1;return t===i?r:i.startsWith((0,p.ensureSuffix)(t,n.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function x(e,t,i){if(null==t||null==i)return!1;const r=e(t),s=e(i);return null!=r&&null!=s&&(y.isLinux?r===s:(0,p.equalsIgnoreCase)(r,s))}function C(e){return(0,b.isSimpleFile)(e)?e.pathnames:e.split(n.default.sep).filter((e=>null!=e&&""!==e))}function F(e){return(0,u.notBlank)(e)&&C(e).length===(y.isWin?1:0)}function A({p:e,maxLength:t}){const i=(0,b.toNativePath_)(e);if(i.length<=t)return i;const r=C(e),s=[],n=[r.pop()];for(;r.length>0;)if(s.length=t){r.unshift(s.pop());break}}else if(n.unshift(r.pop()),O([...s,...n]).length>=t){r.push(n.shift());break}return r.length>0&&s.push("…"),O([...s,...n])}function I(e){return e.startsWith("\\\\")}function O(e){return(0,h.ensurePrefix)((0,o.compactBlanks)(e).join(n.default.sep),y.isWin?"":n.default.sep)}t.parseNativePath=E,t.parentBasename=k,t.grandParentBasename=function(e){return k(n.default.parse((0,b.toNativePath_)(e)).dir)},t.containedByNativePath=D,t.eqlBasename=function(e,t){return x(b.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return x(b.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return x(b.toNativePath_,e,t)},t.toPathnames=C,t.pathIsRoot=F,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:C(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,b.toNativePath_)(e),r=(0,b.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(r))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===r?"":(0,p.stripPrefix)((0,v.native2posix)(r).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=A,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:r=e.length}){const s=[];for(const r of e.slice(0,i))s.push(A({p:r,maxLength:t}));return s.join(", ")+(r>i?`, and ${r-i} more…`:"")},t.posixPathFromParent=function(e){return C(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return C(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=E(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,S.isReadableDirectory)(e))return;if(F(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await s.default.mkdirp(e)}catch(t){if(await(0,S.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;s.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>s.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,b.toNativePath_)(e).split(n.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=O,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:O(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>D({ancestor:t,descendant:e,acceptSelf:!0})?[(0,b.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const s=r(i(76760)),n=i(19851),a=i(40958),o=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),v=i(64660),w=i(21144),b=i(16287),S=(0,n.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const i=await(0,b.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,v.isStatRX)(i,e)}function T(){if(y.isWin){const e=(0,o.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,o.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,o.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,s.default.join(e,"System32"),s.default.join(e,"System32","Wbem"),s.default.join(i,"chocolatey","bin"),s.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(s.default.delimiter);return(0,a.uniq)((0,a.compactBlanks)([...e,...T()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const r=(0,a.uniq)((0,a.compactBlanks)([...M(),...(0,d.toA)(i)]));for(const i of(0,a.uniq)((0,a.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of r){const i=s.default.join(t,e);if(await _(i))return y.isLinux?i:(0,w.actualPath)(i)}}S().warn("Failed to find tool",{tool:e,dirs:r})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){"use strict";var r,s,n,a=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return o(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),v=i(76790),w=i(5233),b=i(22573),S=i(42659),P=i(26905),_=i(75240),T=i(55835),M=i(31586),E=i(68708),k=i(13538),D=i(89937),x=i(12168),C=i(54993),F=i(48884),A=i(50213),I=i(45255),O=i(81168),L=i(56519),R=i(56038),N=i(31562),B=i(84777),j=i(9595),z=i(38835),V=i(70025),W=i(57902),U=i(55222),q=i(43334),H=i(33847),$=i(24399),G=i(28874),J=i(79915),K=i(45200),Y=i(34238),X=i(87001),Z=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),re=i(32144),se=i(73209),ne=i(48313),ae=i(29882),oe=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,F.contextFilter)(function(e){return(0,v.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),r.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,A.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Y.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,L.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>U.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,L.thenMapOr)((0,Z.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>q.isMac?(0,B.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,b.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,b.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,O.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,oe.toNativePath_)(e),r=new fe(i,t);return(0,O.isString)(e)&&he().set(e,r),he().set(i,r),r}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,L.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,ae.containedByNativePath)({ancestor:(0,j.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,ae.containedByNativePath)({ancestor:(0,j.originalsDir)(),descendant:this,acceptSelf:!0}))return q.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,T.map)((0,ee.bestMountpoint)(this.nativePath,await(0,Z.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,T.map)((0,b.notBlankOr)(e,(()=>this.uri_())),Y.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,C.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===D.PS_LIBRARY_SCHEME?1:t.scheme===D.PS_LOCAL_FILE_SCHEME?2:t.scheme===D.PS_NETWORK_FILESYSTEM_SCHEME?3:1,r=(0,O.countChars)(t.path,"/")-i;return this.isDeleted(r)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(q.isWin||q.isMac)return this.trap("hide",(async()=>(await(0,ne.hide_)(this),this)))}async hidden(){return(0,ne.isHidden)(this)}isSidecar(){return(0,re.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,re.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,O.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,re.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,F.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,T.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,E.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:r=!1,timeoutMs:s,skipWip:n=!1,skipFsLock:a=!1,retries:o=2,dirty:l=!1}){return(0,w.retryOnReject_)((async()=>{const o=await this.clear().isNonEmptyFile(i);if(!o){if(n&&a)return e(this);await this.applyWip_({fn_:async r=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(r),skipFsLock:a,minSizeBytes:i,timeoutMs:s,dirty:l})}return o&&r?void 0:this.utimes()}),{maxRetries:o,timeoutMs:2*s,retryDelay:3*S.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,M.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:r=!1,timeoutMs:s,dirty:n=!1}){return await this.parent().mkdirp_(),(0,se.withLock_)({file:this,skipFsLock:r,timeoutMs:s,dirty:n},(async()=>{const r=this.wip();try{await r.unlink("trace");const n=await(0,k.thenOrTimeoutError)(e(r),s);if(n===t.NoOp)return n;if(await(0,N.untilTrue)((()=>r.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await r.mv_(this),n;throw new Error(this+"applyWip(): still empty after waiting "+(0,_.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await r.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==G.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,r,"m",s).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,r,"m",n).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();G.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:S.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,M.clamp)(I.ShortCommandTimeoutMs,10*S.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,b.notBlank)(this.ext)&&(0,b.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,S.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,T.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,L.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,O.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,ae.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,ae.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,X.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,r=new WeakSet,s=async function(e){let t,i=e;const r=e.wip();try{const s=await this.stat_();if(null==s)return this.pflog().throw("Can't copy missing files"+z.NonRetriableErrorFlag);if(s.size>0){if(G.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+z.NonRetriableErrorFlag);if(null==await r.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,r.nativePath,h.default.constants.COPYFILE_FICLONE),s.size>5*x.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},s.size,(()=>r.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,M.approximates)(s.size,await r.size({refresh:!0}))),{intervalMs:S.secondMs,timeoutMs:S.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:s.size,actualSize:await r.size({refresh:!0})});await this.maybeVerifySameOrThrow_(r),i=e.eql(r)?e:await r.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:s.birthtimeMs,mtimeMs:s.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,s.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${s.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${r?.nativePath}) failed: ${t}`),await r.unlink(),r.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,T.map)(t,(e=>e.end()))}},n=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const r=await this.stat_(),s=r?.size;return null==r||null==s?this.pflog().throw("Can't copy missing files"):(s>5*x.MiB&&(t=new H.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},s,(()=>e.clear().size()))),q.isWin?await $.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,$.pwshQuote)(this.nativePath)} -Destination ${(0,$.pwshQuote)(i.nativePath)}`,(e=>e)):q.isMac?await(0,B.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,B.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+z.DoNotSendErrorFlag,{error:t})}finally{(0,T.map)(t,(e=>e.end()))}}},62105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.acceptFile=t.whyRejectFile=t.expensiveFileFiltersFor=t.acceptParentAndFileAndSimple=t.acceptFileSimple=t.whyRejectFileSimple=t.simpleFileFiltersFor=t.notFileTooBig=t.notFileTooSmall=t.notFileMissing=t.hasBrowserImgMimeType=t.notDimensionsTooSmall=t.requiredTagsFilter=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(54993),o=i(48884),l=i(56519),u=i(78984),c=i(28874),d=i(43207),h=i(47783),f=i(97573),m=i(16170),p=i(54979),g=i(1078),y=i(42231),v=i(83278),w=i(19748),b=i(92423),S=i(16287);function P(e){return async t=>(0,l.thenMapOr)((0,h.readRawTags)(t,!1),e,(()=>!1))}async function _(e){if(!(0,n.gt0)(c.Settings.minVideoDimension.valueOrDefault)&&!(0,n.gt0)(c.Settings.minImageDimension.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);if(null==t||!t.startsWith("image/")&&!t.startsWith("video/"))return!1;const i=t.startsWith("video/")?c.Settings.minVideoDimension.valueOrDefault:c.Settings.minImageDimension.valueOrDefault;return(0,n.gt0)(i)?(0,l.thenMapOr)((0,g.extractSizeInfoFromFile)(e),(e=>(0,n.gte)(e.ImageWidth,i)&&(0,n.gte)(e.ImageHeight,i)),(()=>!1)):null}async function T(e){if(!(0,n.gt0)(c.Settings.minVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.gte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.minVideoDurationSec.valueOrDefault):null)}async function M(e){if(!(0,n.gt0)(c.Settings.maxVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,n.lte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.maxVideoDurationSec.valueOrDefault):null)}async function E(e){return!(0,s.blank)(await(0,p.readMimeType)(e))}async function k(e){if(-100===c.Settings.rejectRatingsLessThan.valueOrDefault)return null;const t=await(0,h.readTags)(e),i=(0,n.toInt)(t?.Rating);return null==i||i>=c.Settings.rejectRatingsLessThan.valueOrDefault}async function D(e){return 0===c.Settings.keywordBlocklist.values.length?null:(0,f.rawTagKeywords)(await(0,h.readTags)(e)).every((e=>!0!==(0,y.leafIsExcluded)(e,c.Settings.keywordBlocklist.values)))}async function x(e){if(!c.Settings.requireMakeModel.valueOrDefault)return null;const t=await(0,h.readRawTags)(e);return null==t||(0,s.blank)(t.MIMEType)?null:t.MIMEType.startsWith("image/")?null!=t&&(0,s.notBlank)(t.Make)&&(0,s.notBlank)(t.Model):null}async function C(e){return(0,v.isBaseFile)(e)?e.exists():(0,S.exists)(e.nativePath)}async function F(e){const t=c.Settings.minAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.gte)(i,t)}async function A(e){const t=c.Settings.maxAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,n.lte)(i,t)}function I(e){return[{isSupportedFileExtension:w.isAssetFileExtension},...(0,b.notExcludedFilePredicates)(e),{notFileMissing:C},{notFileTooSmall:F,notFileTooBig:A}]}function O(e){return[...I(e),{notMissingMimeType:E},{supportedMimeType:m.isAssetFileMimeType},{notMissingMakeAndModelTags:x},{notDimensionsTooSmall:_},{notVideoTooShort:T},{notVideoTooLong:M},{notRejectedRating:k},{notExcludedKeyword:D}]}async function L(e,t){return await u.Predicates.whyRejected(e,...t??O(e))??await(0,b.whyExcludedDirectoryRecursive)(e.parent())}t.requiredTagsFilter=function(e){return P((t=>(0,o.allNotBlank)(...e.map((e=>t[e])))))},t.notDimensionsTooSmall=_,t.hasBrowserImgMimeType=P((e=>(0,r.includes)(["image/jpeg","image/png"],(0,a.toS)(e.MIMEType)))),t.notFileMissing=C,t.notFileTooSmall=F,t.notFileTooBig=A,t.simpleFileFiltersFor=I,t.whyRejectFileSimple=function(e){return u.Predicates.whyRejected(e,...I(e))},t.acceptFileSimple=function(e){return u.Predicates.accepted(e,...I(e))},t.acceptParentAndFileAndSimple=async function(e){const t=await e.parent();return null!=t&&!await(0,b.isExcludedDirectory)(t)&&await u.Predicates.accepted(e,...I(e))},t.expensiveFileFiltersFor=O,t.whyRejectFile=L,t.acceptFile=async function(e){return null==await L(e)}},78133:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const s=r(i(76760)),n=i(22573),a=i(81168);t.posix2native=function(e,t){if((0,n.blank)(e))return e;if(s.default.sep===s.default.posix.sep)return e;const i=(0,n.notBlank)(t)?s.default.sep+s.default.sep+t+s.default.sep:"",r=e.split(s.default.posix.sep);return(0,a.equalsIgnoreCase)(r[0],t)&&r.unshift(),i+r.join(s.default.sep)},t.native2posix=function(e){return(0,n.blank)(e)||s.default.sep===s.default.posix.sep||s.default.posix.sep===s.default.sep?e:e.split(s.default.sep).join(s.default.posix.sep)}},43899:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(19851),o=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,a.lazy)((()=>s.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,a.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(s.default.join((0,p.execDir)(),"resources"),s.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,o.compactBlanks)([(0,p.execDir)(),n.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const r=s.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(r,e))return r}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const r=i(44652),s=i(19851),n=i(31586),a=i(50213),o=i(57902),l=i(69428),u=(0,s.lazy)((()=>(0,a.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=o.LogLevels.info){try{return await(0,r.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,n.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const r=i(44652),s=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let n=-1;try{const s=i??(await(0,r.stat)(e)).size-t,a=Buffer.alloc(s);return n=await(0,r.open)(e,"r"),await(0,r.read)(n,a,0,s,t)}finally{(0,s.mapGte0)(n,r.close)}}},69428:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const a=n(i(73024));t.readFileSync=function(e){try{return a.readFileSync(e)}catch{}}},55690:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const r=i(44652),s=i(84542);t.readLines_=async function(e){return(0,s.splitCompactLines)(await(0,r.readFile)(e))}},32323:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const r=i(57075);class s extends r.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=s},65238:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const s=r(i(51455)),n=i(76760),a=i(19851),o=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),v=i(28874),w=i(63870),b=i(88561),S=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,a.lazy)((()=>(0,n.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,a.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await s.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const T=(0,a.lazy)((()=>new b.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||T.prior()?.delete(e)}async function E(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await T().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,S.statTimeoutMs)(),r=k(e),s=await(0,h.thenOrTimeout)(r,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,S.statTimeoutMs)());if(s===f.Timeout&&(0,g.onTimeout)({soft:!1}),s!==f.Timeout&&s.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),T.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,a.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!T().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=T().get(e)},t.childDirectories_=async function(e){return(await E(e)).filter((e=>e.isDirectory)).map((t=>(0,n.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?E(e):k(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=E,t.readdirCached=function(e){return T().get(e)},t.readdirUncached_=k},53265:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const s=i(73024),n=r(i(76760)),a=i(40958),o=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,a.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=n.default.resolve(t,...e);if((0,s.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,o.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(o.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??n.default.resolve(...e))},t.execDir=(0,l.defer)((()=>n.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},46356:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.seemsLikeSymlinkLoop=void 0;const r=i(22454),s=i(28874),n=i(29882);t.seemsLikeSymlinkLoop=function(e){const t=new r.CountingSet;for(const i of(0,n.toPathnames)(e))t.incr(i.toLowerCase().normalize());return t.max()>s.Settings.maxDuplicatePathElements.valueOrDefault}},8797:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.showFileInFolder=void 0;const r=i(58587),s=i(31421),n=i(19851),a=i(40958),o=i(50213),l=i(43334),u=i(24399),c=i(28874),d=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ShowFileInFolder")));async function h(e,t){try{(0,s.spawn)(e,t,{detached:!0,stdio:"ignore"}).unref()}catch(i){d().warn("spawn() failed",{err:i,cmd:e,args:t})}}t.showFileInFolder=async function(e){if(await e.isEmpty())return!1;if(c.Settings.showFileInFolderUsesThunar.valueOrDefault&&l.isLinux)return async function(e){return h("dbus-send",["--type=method_call","--dest=org.xfce.Thunar","/org/xfce/FileManager org.xfce.FileManager.DisplayFolderAndSelect",`string:"${e.dir}"`,`string:"${e.base}"`,'string:""','string:""'])}(e);if((0,a.isNotEmpty)(c.Settings.showFileInFolderCommand.values)){const t=c.Settings.showFileInFolderUsesFileUri.valueOrDefault?e.fileuri():e.nativePath,i=[...c.Settings.showFileInFolderCommand.values,t],r=i.shift();return d().info("custom showFileInFolderCommand: running",{cmd:r,args:i}),h(r,i)}return l.isLinux?async function(e){return h("nautilus",["-s",e.fileuri()])}(e):l.isWin?async function(e){const t=e.nativePath.replace(/"/g,"").replace(/'/g,"''");try{return await u.PowerShell.instance().execute(`start explorer.exe -ArgumentList '/select,"${t}"'`,r.SimpleParser),!0}catch(t){return d().warn("explorerSelect("+e+") failed",t),!1}}(e):!!l.isMac&&async function(e){return h("open",["-R",e.nativePath])}(e)}},50274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const r=i(50989);t.SidecarExts=(0,r.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const r=i(22573),s=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,r.notBlank)(e.basename)&&(0,s.isBoolean)(e.isFile)&&(0,s.isBoolean)(e.isDirectory)}},17217:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const s=r(i(73024)),n=r(i(76760)),a=i(22573),o=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,a.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,a.blank)(e.nativePath))throw new Error(`toNativePath(${(0,o.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof s.default.Dirent?e.name:f(e)?e.base:n.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:n.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(n.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,o.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(s.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,o.blank)(e)?void 0:v(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function b(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function S(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=b(e),r=b(t);if(i!==r)return"inconsistent file type: "+i+" ≠ "+r;for(const i of["size","mtime"]){const r=e[i],s=t[i],n=(0,u.diff)(S(r),S(s));if(null==n||n>1)return"unmatched "+i+": "+r+" ≠ "+s}}t.stat_=v,t.statMaybe=w,t.statToType=b,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const i=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await w(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,a.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const s=r(i(73024)),n=i(22573);function a(e){try{return(0,n.blank)(e)?void 0:s.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function o(e){return null==e||e.isFile()&&0===e.size}t.statSync=a,t.isEmptyStats=o,t.isFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=a(e);return t.emptyIsNew?null==i:o(i)},t.isNonEmptyFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===a(e)?.isDirectory()}},41080:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const r=i(28874);t.statTimeoutMs=function(){return r.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const r=i(22573),s=i(56409);t.onDataChunked=function(e,t,i){const r=new n(t,i,!0);return r.read(e),r.done};class n{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new s.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,r.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,r.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=n},95705:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const s=r(i(57075)),n=i(41400),a=i(55835),o=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends s.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,r)=>{!1===e.write(t,(e=>{e&&r(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,n.delay)(50);try{(0,o.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:r}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,a.map)(r,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends s.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const s=r(i(73024)),n=i(76760),a=i(22573),o=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,a.blank)(e))return!1;try{return s.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,o.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,a.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,a.notBlank)(t)){const e=(0,n.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,a.blank)(e)&&d((0,u.posix2native)(e))}},74128:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.SyncReport=t.syncReport=t.recentSyncReports=t.ensureSyncReportReadme=t.syncReportReadme=t.syncReportDir=t.SyncReportHeaders=t.isRejectedState=t.SyncReportStates=t.SyncDirStates=t.FileDoneStates=t.SyncFileStates=t.AssetFileSyncStates=void 0;const p=i(51168),g=i(73024),y=i(4927),v=i(19851),w=i(40958),b=i(22573),S=i(42659),P=i(98553),_=i(31586),T=i(68708),M=i(50989),E=i(51926),k=i(85556),D=i(54993),x=i(89788),C=i(23467),F=i(7282),A=i(23560),I=i(77377),O=i(71567),L=i(73568),R=i(25764),N=i(38836),B=i(99331),j=i(12959),z=i(87290),V=i(46296),W=i(98314),U=i(38835),q=i(5012),H=i(32144),$=i(95696),G=i(36868),J=i(57902),K=i(28874),Y=i(84542),X=i(73428);t.AssetFileSyncStates=(0,M.strEnum)("noop","deleted","skipped","synced","unknown"),t.SyncFileStates=(0,M.strEnum)(...t.AssetFileSyncStates.values,"canceled","rejected","failed","timeout","enqueued","started","copied","blocklisted","note"),t.FileDoneStates=(0,I.diff)(t.SyncFileStates.values,["enqueued","started","note"]),t.SyncDirStates=(0,M.strEnum)("scanning","canceled","failed","timeout","skipped","scanned"),t.SyncReportStates=(0,M.strEnum)(...t.SyncFileStates.values,...t.SyncDirStates.values),t.isRejectedState=function(e){return null==e||["canceled","deleted","failed","rejected","timeout","unknown"].includes(e)};const Z={enqueued:"the file looks promising, and will be attempted to be imported soon.",rejected:"the file did not pass all import filters. The details column will explain why.",started:"the file was dequeued from the work queue, and is now going to be processed.",noop:"the current file metadata already matches your library database, so no operation was needed to sync this file.",deleted:"the file was determined to be deleted (the prior mountpoint exists, but the file doesn't exist anymore)",skipped:"the file lives on a volume that isn't currently mounted.",synced:"the file was imported.",blocklisted:"the file was blocklisted and files with the same SHA will not be imported in the future.",failed:"something went wrong. The details column will explain why.",timeout:"the file wasn't processed in a reasonable amount of time.",copied:'"automatic organization" is enabled (copyAssetsToLibrary=true), and the photo or video was copied into your library originals directory. The details column will contain the source file path.',note:"sidecars will be referenced here. The details column will specify which source file(s) it will be associated with.",canceled:"PhotoStructure was shut down while the file was processed.",unknown:"an internal error occurred during processing."},Q={scanning:"the directory contents are about to be read.",scanned:"the directory contents were completely processed.",skipped:"the directory was excluded. The details column will explain why.",canceled:"PhotoStructure was shut down before the directory was processed.",failed:"reading the directory contents failed.",timeout:"reading the directory contents took too long."};function ee(e){return(0,T.entries)(e).map((([e,t])=>` - "${e}": ${t}`)).join("\n")}const te=new Set([t.AssetFileSyncStates.deleted,t.SyncFileStates.failed,t.SyncFileStates.timeout,t.SyncDirStates.canceled]);function ie(){return(0,z.librarySyncReportsDir)()??$.PosixFile.for((0,V.logDir)()).join("sync-reports")}function re(){return ie().join("README.txt")}t.SyncReportHeaders=(0,M.strEnum)(...(0,T.keys)(new class{constructor(e,t,i,r,s,n,a,o,l={}){this.ts=e,this.at=t,this.path=i,this.state=r,this.from=s,this.elapsedMs=n,this.details=a,this.url=o,this.meta=l}}(0,"","","unknown","",0,"",""))),t.syncReportDir=ie,t.syncReportReadme=re,t.ensureSyncReportReadme=(0,v.lazy)((()=>(0,X.writeTextfile_)(re().nativePath,(0,E.wrap)(`\n\nHowdy from PhotoStructure!\n\nThis directory contains your recent "sync reports". \n\nThese files are written as your scan paths are examined for photos and videos.\n\nPhotoStructure creates a new file when it restarts and when it completes importing a given scan path directory.\n\nThese CSV files can be opened with most spreadsheet applications, like LibreOffice.\n\n\nColumn descriptions\n===================\n\nThe "ts" column is the timestamp for the row, in millis from 1970-01-01. Most spreadsheet applications don’t know how to parse these values, though, so we also add the at column.\n\nThe "at" column is ts in ISO format with only second resolution, and should be parsable by most spreadsheet software.\n\nThe "path" column is the native path of the directory or file. It will be empty for messages about system state.\n\nThe "state" column explains why that row was added.\n\nThe "from" column specifies which codepath added the sync report row.\n\nThe "elapsedMs" column is only added to rows completing a given path, and records how long that process took.\n\nThe "details" column will include information about the path, like why a given file or folder were rejected.\n\nThe "url" column is only added to rows when a file or directory is imported. You may need to adjust the domain name of the URL to make it work correctly (it defaults to localhost).\n\n\nDirectory state values\n======================\n\nThe "state" column for directories will be\n\n${ee(Q)}\n\n\nFile state values\n=================\n\nThe "state" column for files will be\n\n${ee(Z)}\n\n\nSee https://photostructure.com/go/sync-reports\n\n`,{maxLineLen:80}).join("\n")))),t.recentSyncReports=async function(e=S.dayMs){const t=Date.now()-e;return ie().descendants((async e=>(0,H.isCsvExt)(e)&&(0,_.gte)(e.mtimeMs(),t)))},t.syncReport=(0,v.lazy)((()=>new se));class se extends N.EndableWrapper{constructor(){super("fs.SyncReport()",(()=>f(this,r,"m",d).call(this)),R.EndableRanks.predb),r.add(this),s.set(this,void 0),n.set(this,void 0),a.set(this,void 0),o.set(this,0),l.set(this,0),this.outputFiles=new x.BoundedList(64),(0,t.ensureSyncReportReadme)()}get outputNativePath(){return f(this,s,"f")?.nativePath}get rowCount(){return f(this,l,"f")}onProgress(e){if(null==e||(0,b.blank)(e.state))return this.logger.error(".onProgress(): invalid input",{s:e,from:(0,q.stack)()});{this.logger.log(te.has(e.state)?J.LogLevels.warn:J.LogLevels.info,"onProgress()",e);const t=Date.now(),i={path:(0,D.toS)(e.path),state:e.state,details:(0,D.toS)(e.details).trim().replace(/\r?\n/g,"; ")},s={ts:t,at:new Date(t).toISOString(),...i,...(0,T.pick)(e,"from","elapsedMs","url")};(0,T.isEmptyObj)(e.meta)||(s.meta=(0,P.stringify)(e.meta)),(0,F.isTest)()&&process.stdout.write((0,P.stringify)(e)+Y.Newline),f(this,r,"m",u).call(this,s)}}maybeSystemData(e){(0,A.isSyncService)()&&this.onProgress(e)}async wrap_({path:e,from:i,fn_:r}){const s=Date.now();this.onProgress({path:e,from:i,state:t.SyncFileStates.started});try{const n=await r(),a=n.state??(null!=n.error?t.SyncFileStates.failed:t.SyncFileStates.unknown);return a===t.SyncFileStates.unknown&&this.logger.error(i+" returned result with no state!"+U.InternalErrorFlag,{path:e,result:n}),this.onProgress({path:e,from:i,elapsedMs:Date.now()-s,...n,state:a}),n}catch(r){throw this.logger.warn("wrap_() caught error",{error:r}),this.onProgress({path:e,from:i,state:(0,B.ending)()||r instanceof L.AbortError?t.SyncFileStates.canceled:r instanceof k.TimeoutError?t.SyncFileStates.timeout:t.SyncFileStates.failed,details:(0,B.ending)()?void 0:(0,W.errorToS)(r),elapsedMs:Date.now()-s}),r}}get output(){return f(this,n,"f")??f(this,r,"m",h).call(this)}async flushClose(){return f(this,r,"m",u).call(this),this.close()}async close(){this.logger.info("Closing sync report");const e=f(this,n,"f");return m(this,n,void 0,"f"),m(this,l,0,"f"),await(0,G.endStream)(e),null==e?void 0:f(this,s,"f")}}t.SyncReport=se,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,r=new WeakSet,u=function(e){var t;const i=f(this,a,"f");if(m(this,a,e,"f"),null!=e&&(0,C.eqlPicked)(e,i,"path","state","details"))return this.logger.debug("deduping row",e),void m(this,o,(t=f(this,o,"f"),t++,t),"f");null!=i&&(0===f(this,o,"f")?f(this,r,"m",c).call(this,i):(f(this,r,"m",c).call(this,{...i,details:(0,w.compactBlanks)([i.details,`(repeated ${f(this,o,"f")+1} times)`]).join(" ")}),m(this,o,0,"f")))},c=function(e){var i;const r=(0,y.unparse)([e],{header:!1,columns:t.SyncReportHeaders.values});this.output.write(r+Y.Newline,(e=>{null!=e&&this.logger.error("Failed to write",e)})),m(this,l,(i=f(this,l,"f"),++i),"f")>K.Settings.syncReportMaxRows.valueOrDefault&&this.close()},d=function(){return this.logger.info("sync report ended",{rowCount:f(this,l,"f"),outputFiles:this.outputFiles}),this.flushClose()},h=function(){return m(this,s,function(){const e=p.DateTime.now();return ie().join(e.toFormat("y-MM-dd"),(0,j.filestamp)()+"-sync-report.csv")}().ensureNewSync_({emptyIsNew:!1}),"f"),this.outputFiles.push(f(this,s,"f").nativePath),this.logger.info("Opening new report: "+f(this,s,"f")),(0,F.isTest)()&&(0,O.stdoutWrite)({syncReport:f(this,s,"f").nativePath},!1),m(this,n,(0,g.createWriteStream)(f(this,s,"f").nativePath),"f"),f(this,n,"f").write((0,y.unparse)([t.SyncReportHeaders.values],{header:!1})+Y.Newline),f(this,n,"f")}},89966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const s=r(i(48161)),n=i(19851),a=i(55835),o=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),h=i(8103),f=i(43899);function m(){return(0,a.map)(f.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,a.map)(m(),(e=>e.join(c.platformName+"-"+s.default.arch())))}async function g(e){if(c.isWin&&(e=(0,o.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,h.pathIfExists)(m()?.join("bin",e))),(()=>(0,h.pathIfExists)(m()?.join(e))),(()=>(0,h.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,h.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,n.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,n.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,n.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,n.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const s=r(i(44652)),n=i(19851),a=i(22573),o=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,o.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,a.blank)(t.file))throw new Error("can't touch blank path");const r=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const o=(0,n.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await o())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await o())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(s.default.utimes(r,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(n){if(!i||"ENOENT"!==n.code)throw n;await(0,c.thenOrTimeoutError)(s.default.ensureFile(r),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},79847:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.trashOrUnlinkFileUri=t.trashOrUnlinkFileUris_=void 0;const o=n(i(51455)),l=a(i(49378)),u=i(40958),c=i(22573),d=i(13538),h=i(83104),f=i(45255),m=i(31562),p=i(98314),g=i(34102),y=i(28874),v=i(45200),w=i(16287),b=i(74128),S=i(84258),P="fs.Trash";async function _(e){const t=Date.now(),i=y.Settings.commandTimeoutMs.valueOrDefault,r=(0,c.toNotBlank)(e.nativePath)??await(0,d.thenOrTimeout)((0,v.uri2nativePath)(e.uri,e.mountpoint),i);if((0,c.blank)(r)||r===h.Timeout)return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not convert URI to native path",path:e.uri,elapsedMs:Date.now()-t}),{uri:e.uri,unlinked:!1};const s=await(0,w.statMaybe)(r);if(null==s)return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: no such file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(!s.isFile())return(0,b.syncReport)().onProgress({from:P,state:"noop",details:"Failed to delete: not a file",path:r}),{uri:e.uri,nativePath:r,unlinked:!1};if(y.Settings.trySoftDeletes.valueOrDefault)try{if(await(0,d.thenOrTimeoutError)((0,l.default)(r,{glob:!1}),i),await function(e){return(0,m.untilTrue)((async()=>null==await(0,w.statMaybe)(e)),{timeoutMs:f.ShortCommandTimeoutMs})}(r))return(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Moved file to trash",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0};(0,S.logger)().warn("soft-delete("+r+") didn't seem to work: the file is still there?")}catch(e){(0,b.syncReport)().onProgress({from:P,state:"note",details:"Failed to soft-delete file to trash: "+(0,p.errorToS)(e),path:r,elapsedMs:Date.now()-t}),(0,S.logger)().warn("Tried to soft-delete, but that failed. We'll try to hard-delete.",{error:e})}try{return await(0,d.thenOrTimeoutError)(o.unlink(r),i),(0,g.ee)().emit("fileChanged",r),(0,S.logger)().info("unlink("+r+") successful"),(0,b.syncReport)().onProgress({from:P,state:"deleted",details:"Permanently deleted file",path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!0}}catch(i){return(0,b.syncReport)().onProgress({from:P,state:"failed",details:"Could not move file to trash or delete: "+(0,p.errorToS)(i),path:r,elapsedMs:Date.now()-t}),{uri:e.uri,nativePath:r,unlinked:!1}}}t.trashOrUnlinkFileUris_=async function(e){const t=[];for(const{uri:i,mountpoint:r}of(0,u.uniqBy)(e,(e=>e.uri)))try{t.push(await _({uri:i,mountpoint:r}))}catch(e){t.push({uri:i,unlinked:!1,error:e})}return t},t.trashOrUnlinkFileUri=_},70854:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryUidStore=t.LibraryUIDStore=t.SystemUIDStore=t.UIDStore=t.mkuid=void 0;const r=i(19851),s=i(41400),n=i(55835),a=i(92782),o=i(37805),l=i(46292),u=i(34102),c=i(55222),d=i(28874),h=i(87128),f=i(95696);function m(){return(0,a.safeRandomUid)({radix:c.TokenRadix,chars:24,splitEveryN:4})}t.mkuid=m;class p extends h.JsonFileStore{constructor(e,t){super(e.join("."+t+"-uid.json"),(()=>({uid:m(),version:o.version,type:this.type,createdAt:Date.now()})),(e=>e.hide())),this.rootDir=e,this.type=t,this.readUid_=(0,r.lazy)((async()=>(await this.read_())?.uid))}}function g(e=d.Settings.libraryDir.valueOrDefault){return(0,n.map)(f.PosixFile.forMaybe(e),(e=>new p(e,"library")))}t.UIDStore=p,t.SystemUIDStore=(0,r.lazy)((()=>(0,n.map)((0,l.configDir)(),(e=>new p(f.PosixFile.for(e),"system"))))),t.LibraryUIDStore=(0,r.lazy)(g),t.libraryUidStore=g,(0,s.later)((()=>{(0,u.ee)().on("clearCache",(()=>{t.SystemUIDStore.unset(),t.LibraryUIDStore.unset()})),d.Settings.libraryDir.watchLater((()=>t.LibraryUIDStore.unset()))}))},84258:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const a=n(i(51455)),o=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,o.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const r of(0,l.toA)(e))try{null!=r&&await a.unlink((0,c.toNativePath_)(r))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+r,{error:e})}}},5545:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const s=r(i(76760)),n=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,n.toS)(i.path??s.default.sep)}},70257:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const r=i(30976),s=i(45255),n=i(17217);t.WipTimeoutMs=s.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,r.randomChars)(5).toUpperCase()+"-"+e};const a=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(a,"")},t.isWip=function(e){return a.test((0,n.basename)(e)??"")}},58722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const r=i(57075),s=i(22911);class n extends r.Writable{constructor(e){super(e),this.deferred=new s.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=n},73428:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const s=r(i(44652)),n=r(i(76760)),a=i(51926),o=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=n.default.dirname(e);await(0,c.mkdirp_)(i),await s.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=n.default.dirname(e);(0,c.mkdirpSync_)(i),s.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,a.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))}},13047:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const s=r(i(73024)),n=i(76760),a=i(46466),o=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await S(e,t)).toString()}async function b(e,t,i){const r=[],n=[s.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>r.push(e)))];if(e.toLowerCase().endsWith(".gz")?n.push((0,o.createGunzip)().on("error",(e=>r.push(e)))):e.toLowerCase().endsWith(".br")&&n.push((0,o.createBrotliDecompress)().on("error",(e=>r.push(e)))),n.push(t),await(0,a.pipeline)(n),(0,u.isNotEmpty)(r))throw new f.WrappedError("zPipe("+e+") failed",{causes:r,path:e})}async function S(e,t){const i=new y.WritableToBuffer;return await b(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await S(e))}async function _(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,n.parse)(e).dir),await(0,a.pipeline)(new g.ReadableBuffer(i),(0,o.createGzip)(),s.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=b,t.zCopyToBuffer_=S,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void v().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await _(e,t)}catch(t){v().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},60526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.exiftoolHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(98314),a=i(47783),o=i(63335),l=i(18454);t.exiftoolHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Tools",id:"tools-exiftool",ordinal:1,pendingMsg:"Checking ExifTool…",settings:[],later:async()=>{try{const e=await(0,a.exiftoolVersion_)();return{level:"ok",msg:["ExifTool is OK","ExifTool "+(0,o.ver)(e),(0,r.tt)((0,a.exiftool)().options.exiftoolPath)],meta:{exiftoolVersion:e}}}catch(e){return{level:"error",msg:"Something's amiss with ExifTool: "+(0,n.errorToS)(e)}}}})))},19652:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.externalDirectoryCheck=void 0;const a=i(51455),o=n(i(22915)),l=i(40958),u=i(82950),c=i(22573),d=i(45599),h=i(12168),f=i(50213),m=i(79960),p=i(32551),g=i(98314),y=(0,d.defer)((()=>(0,f.mkLogger)("health.externalDirectoryCheck")));t.externalDirectoryCheck=async function(){const e=(0,l.uniq)([(0,p.homeDir)(),o.getHomeFolder(),o.getPicturesFolder(),o.getVideosFolder(),o.getDesktopFolder(),await(0,m.defaultApplePhotosLibrary)()]).sort(),t=new Map,i=(0,l.uniq)(e.filter(c.notBlank)).sort();for(const e of i)try{await(0,a.readdir)(e,{withFileTypes:!0})}catch(i){if(["ENOTDIR","ENOENT"].includes(i?.code))continue;t.set(e,i)}const r=0===t.size?{level:"ok",msg:["Default media directories are OK","The following directories are readable:",(0,u.li)(i.map(u.tt))]}:{level:"warn",msg:["Error reading "+(0,h.plur)(t.size,"media directory")+":",(0,u.li)([...t.entries()].map((([e,t])=>(0,u.tt)(e)+":"+(0,g.errorToS)(t,{maxLen:80}))))]};return y().tap({msg:"externalDirectoryCheck",result:r})}},79483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.externalDirsHealthCheck=void 0;const r=i(45599),s=i(45969),n=i(19652),a=i(18454);t.externalDirsHealthCheck=(0,r.defer)((()=>(0,s.isDocker)()?void 0:a.HealthCheck.for({section:"System",id:"media-directories",pendingMsg:"Checking default photo directories…",settings:[],later:n.externalDirectoryCheck})))},63664:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getRemoteOrLocalHealthSummarySync=t.getRemoteOrLocalHealthSummary=t.getLocalHealthSummary=t.getRemoteHealthSummary=void 0;const r=i(22573),s=i(45599),n=i(41400),a=i(50268),o=i(98553),l=i(50213),u=i(23560),c=i(45255),d=i(5916),h=i(28874),f=i(34238),m=i(51140),p=i(4988),g=i(18454),y=(0,s.defer)((()=>(0,l.mkLogger)("health.GetHealthSummary")));t.getRemoteHealthSummary=(0,d.lazyAsync)({later:async()=>{try{if((0,u.isWebService)())return;const e=await(0,p.get_)(f.URI.from({scheme:"http",authority:"127.0.0.1:"+h.Settings.httpPort.valueOrDefault,path:"/api/health"}),{timeoutMs:c.ShortCommandTimeoutMs}),t=(0,o.parseJSON_)(e.data);if(m.HttpStatusIs.ok(e.statusCode)&&(0,a.isHealthCheckSummary)(t))return"ready"===t.state&&(0,r.toNotBlank)(t.libraryDir)!==(0,r.toNotBlank)(h.Settings.libraryDir.valueOrDefault)&&(y().error("getHealthSummary(): libraryDir mismatch! Switching to that library directory...",{local:h.Settings.libraryDir.valueOrDefault,remote:t.libraryDir}),h.Settings.libraryDir.value=t.libraryDir),y().debug("getHealthSummary()",{response:e}),t;y().warn("getHealthSummary(): invalid response",{response:e})}catch(e){y().warn("Failed to get health check summary from web service",{error:e})}}}),t.getLocalHealthSummary=(0,d.lazyAsync)({later:()=>g.HealthCheck.awaitSettled()}),(0,n.later)((()=>{h.Settings.healthCheckIntervalMs.watch((e=>{t.getRemoteHealthSummary.setTTL(e),t.getLocalHealthSummary.setTTL(e)}))})),t.getRemoteOrLocalHealthSummary=async function(){return await(0,t.getRemoteHealthSummary)()??await(0,t.getLocalHealthSummary)()},t.getRemoteOrLocalHealthSummarySync=function(){return t.getRemoteHealthSummary.syncValue()??t.getLocalHealthSummary.syncValue()}},87408:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStatusSummary=void 0;const r=i(63870),s=i(18454),n=i(89035),a=i(82638);t.getStatusSummary=async function(e={}){return(0,a.summarizeHealthChecks)({healthChecks:[...s.HealthCheck.allCritical(),(0,n.memoryHealthCheck)()],errors:s.HealthCheck.lastErrors(),timeoutMs:(0,r.commandTimeoutMs)(),skipPending:!0,...e})}},18454:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,v,w,b,S,P,_=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},T=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const M=i(19851),E=i(40958),k=i(76790),D=i(41400),x=i(50357),C=i(26905),F=i(50268),A=i(55835),I=i(68708),O=i(30976),L=i(51926),R=i(13538),N=i(42279),B=i(59455),j=i(54993),z=i(48884),V=i(89788),W=i(22454),U=i(50213),q=i(69591),H=i(22911),$=i(99331),G=i(5916),J=i(42638),K=i(77740),Y=i(98314),X=i(70025),Z=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),re=i(21525),se=i(82638),ne=(0,M.lazy)((()=>(0,U.mkLogger)("health.HealthCheck")));class ae{static traceLater_(e,t){const i=new H.Deferred(e);i.catch((t=>{_(this,s,"f",l).push(e+": failed: "+(0,Y.errorToS)(t)),this.onResultChange()})),_(this,s,"m",o).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return _(this,s,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){_(this,s,"f",l).push((0,L.isString)(e)?e:(0,Y.errorToS)(e)),this.onResultChange()}static lastErrors(){return _(this,s,"f",l).toA()}static addLoadingMsg(e){_(this,s,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,E.compact)((0,B.toA)(e)).map(j.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return ne().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:_(this,s,"f",h).entriesByCountDesc()}),(0,A.map)((0,z.leastBy)(e,(e=>[_(this,s,"f",h).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=_(this,s,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,A.map)(e,(e=>_(this,s,"f",h).incr(e.msg))),ne().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return Z.Settings.skipHealthCheckIds.envValue=t,s.reset()}static findById(e){return _(this,s,"f",f).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,F.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=_(this,s,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=s.summary();if(e.pendingCount>0){const t=await Promise.all(s.testResultsCritical());e=s.summaryFromResults(t),ne().info("awaitSettled(): summary result",{summary:e,results:t})}return ne().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){s.summary.unset()}static reset(){if((0,$.ending)())ne().warn("Rejecting reset() when ending()",(0,C.shortStack)());else{this.onResultChange(),_(this,s,"f",l).clear(),_(this,s,"f",d).clear(),_(this,s,"f",h).clear(),_(this,s,"f",c).clear(),this.summary.clear(),T(this,s,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new s(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return _(this,s,"f",f).push(i),this.all.unset(),i}constructor(e,t,i,n,o,l,u,c,d,h,f,m,S,P=Q.commandTimeoutMs){r.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=n,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=h,this.errorLinks=f,this.onReset=m,this.ttlMs=S,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),w.set(this,(0,M.lazy)((async()=>{await _(this,p,"f").prior(),(0,x.eql)(_(this,g,"f"),_(this,r,"m",v).call(this))||(this.onReset?.(),await this.refresh(),_(this,w,"f").unset())}))),this.refresh=(0,M.lazy)((()=>new H.Deferred("refresh").observe((async()=>{await _(this,p,"f").prior();const e=_(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,U.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[F.HealthCheckSections.ordinal(this.section),l??999,this.id],T(this,p,(0,G.lazyAsync)({desc:this.pendingMsg,later:()=>_(s,s,"f",a).enqueue({name:this.id,l:()=>_(this,r,"m",b).call(this,o)}),ttlMs:S}),"f"),this.isCritical&&_(this,p,"f").watchLater({onChange:s.onCriticalResult,onError:s.onCriticalResult});for(const e of this.settings)Z.Settings[e].watchLater((()=>_(this,w,"f").call(this)))}isStale(){return _(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return _(this,p,"f").settledCount()}reset(){return _(this,p,"f").unset(),this.onReset?.(),T(this,g,{starting:!0},"f"),this}setTTL(e){_(this,p,"f").setTTL(e)}result(){return _(this,p,"f").call(this)}isSkipped(){return Z.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return _(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return _(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??_(this,r,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function oe(e){if((0,E.isEmpty)(e))return{};const[t,i]=(0,z.partition)(e,(e=>"button"===e.type||"POST"===e.method)),r={};return(0,E.isNotEmpty)(i)&&(r.links=(0,E.uniqBy)(i)),(0,E.isNotEmpty)(t)&&(r.buttons=(0,E.uniqBy)(t)),r}t.HealthCheck=ae,s=ae,p=new WeakMap,g=new WeakMap,y=new WeakMap,w=new WeakMap,r=new WeakSet,o=function(){return(0,E.filterInPlace)(_(this,s,"f",n),(e=>!e.isPending)),_(this,s,"f",n)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=ne().tap({level:"warn",msg:"#summary()",result:(0,se.summarizeHealthChecksSync)({errors:_(this,s,"f",l),skipPending:_(this,s,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&T(this,s,!0,"f",u),i.state!==_(this,s,"f",c).last?.state&&_(this,s,"f",c).push({state:i.state,ts:Date.now()}),i},v=function(){return(0,I.fromEntries)(this.settings.map((e=>[e,Z.Settings[e].valueOrDefault])))},b=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();ne().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,C.shortStack)()}),T(this,g,_(this,r,"m",v).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,D.delay)((0,O.randomInt)(.3*i,.7*i)),this.isSkipped())return _(this,r,"m",S).call(this,{test:{level:"disabled",msg:["Disabled by "+Z.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const s=await(0,R.thenOrTimeoutError)(e(),i);return _(this,r,"m",S).call(this,{test:s,elapsedMs:Date.now()-t})}catch(e){return _(this,r,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},S=function({test:e,src:t="#toResult",elapsedMs:i}){var r,n;const a=s.normalizeMsg(e.msg),o=e.level??((0,j.toS)(a).toLowerCase().includes("error")?"error":(0,j.toS)(a).toLowerCase().includes("warn")?"warn":"ok"),l=(0,E.compact)([...e?.links??("ok"===o||"pending"===o?this.okLinks:"warn"===o?this.warnLinks:"no-library"===o?this.noLibraryLinks:"error"===o?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:o,msg:a,elapsedMs:i,...oe(l)};return u.runCount=(T(this,y,(n=_(this,y,"f"),r=n++,n),"f"),r),(0,$.ending)()?u:this.logger.tap({level:re.HealthCheckLevelToLogLevel[o],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const s=(0,L.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,A.map)(e,Y.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,X.isFatalError)(e)&&s.toLowerCase().includes("warn")?"warn":"error"),_(this,r,"m",S).call(this,{test:{msg:s,level:t},src:"#toErrorResult",elapsedMs:i})},n={value:[]},a={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},h={value:new W.CountingSet},f={value:[]},ae.all=(0,M.lazy)((()=>Object.freeze((0,k.sortBy)(_(s,s,"f",f),(e=>e.sortBy))))),ae.onCriticalResult=(0,q.debounce)((()=>{ne().info("onCriticalResult()",s.summary.refresh())}),250),ae.summary=(0,M.lazy)((()=>_(s,s,"m",m).call(s))),ae.resetDebounced=(0,q.debounce)((()=>s.reset()),50)},85021:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckCommand=void 0,t.HealthCheckCommand="--health"},33866:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const r=i(50989);t.HealthCheckIds=(0,r.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const r=i(82950),s=i(50268),n=i(459),a=i(23560),o=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,a.isPermaService)(t)&&(e===s.HealthCheckLevels.error||(0,a.isLibraryRequiredService)(t)&&e===s.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,o.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,r.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new n.UnreachableCaseError(e)}}},88625:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.healthCheckSetup=t.testHealthCheck=void 0;const r=i(19851),s=i(82950),n=i(45599),a=i(50268),o=i(50213),l=i(7282),u=i(44198),c=i(34102),d=i(2858),h=i(60526),f=i(79483),m=i(18454),p=i(39214),g=i(86403),y=i(42482),v=i(35675),w=i(89035),b=i(31974),S=i(20752),P=i(85200),_=i(37301),T=i(65756),M=i(15024),E=i(3956),k=i(29332),D=i(61274),x=i(38372),C=i(49913),F=i(84728),A=i(7245),I=i(16264),O=(0,n.defer)((()=>(0,o.mkLogger)("health.HealthCheckSetup")));t.testHealthCheck=(0,n.defer)((()=>m.HealthCheck.for({section:"System",id:"test-health-check",ordinal:0,settings:[],pendingMsg:"Test check…",later:async()=>{const e=a.HealthCheckLevels.validOrElse((0,u.env)().PS_TEST_HEALTH_CHECK_LEVEL,a.HealthCheckLevels.ok);return{level:e,msg:[`Test health check: ${e.toUpperCase()}`,`These are ${(0,s.b)("details")}:`,(0,s.li)("alpha",(0,s.tt)("bravo"),"charlie")]}}}))),t.healthCheckSetup=(0,r.lazy)((()=>{(0,h.exiftoolHealthCheck)(),(0,p.heifHealthCheck)(),(0,y.libraryDirectoriesCheck)(),(0,v.libraryFreeSpaceCheck)(),(0,E.settingsEnvHealthCheck)(),(0,D.settingsSystemHealthCheck)(),(0,k.settingsLibraryHealthCheck)(),(0,f.externalDirsHealthCheck)(),(0,w.memoryHealthCheck)(),(0,b.nodejsHealthCheck)(),(0,S.notInDMGHealthCheck)(),(0,P.osHealthCheck)(),(0,_.powershellHealthCheck)(),(0,x.sharpHealthCheck)(),(0,g.jpegtranHealthCheck)(),(0,M.securityHealthCheck)(),(0,T.sqliteHealthCheck)(),(0,C.systemLoadHealthCheck)(),(0,A.videoHealthCheck)(),(0,I.volumeHealthCheck)(),(0,F.versionHealthCheck)(),(0,l.isProd)()||(0,t.testHealthCheck)();let e=(0,d.libraryHasSettings)();d.libraryHasSettings.watchLater((t=>{null!=t&&e!==t&&(O().info("libraryHasSettings changed. Resetting health checks.",{newValue:t}),e=t,m.HealthCheck.resetDebounced())}));for(const e of["volumesChanged","mountpointsChanged","error"])(0,c.ee)().on(e,(()=>{O().debug("Clearing health check cache",{event:e}),m.HealthCheck.resetDebounced()}));(0,c.ee)().on("fatal",(e=>m.HealthCheck.addError(e)))}))},39214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heifHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(41400),a=i(55835),o=i(34102),l=i(277),u=i(45969),c=i(63335),d=i(18454);t.heifHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-heif",pendingMsg:"Checking HEIF/HEIC tooling…",settings:["heifConvertPath"],links:[{text:"Read how to set up HEIF support with PhotoStructure",url:"https://photostructure.com/getting-started/heif-support/",icon:"docs"}],warnLinks:(0,u.isDocker)()?[]:[{text:"Re-check for HEIF tooling",icon:"refresh",method:"POST",type:"button",url:"/admin/recheck-tools"}],later:async()=>{const e=await(0,l.getHeifSupportDetails)();return null!=e&&!1!==e.isSupportedVersion?{level:"ok",msg:["HEIF images will be imported",(0,a.map)(e.version,c.ver),(0,a.map)(e.path,r.tt)]}:{level:"warn",msg:["HEIF images will not be imported","No HEIF tooling was found."]}}}))),(0,n.later)((()=>{(0,o.ee)().on("clearToolCache",(()=>t.heifHealthCheck.prior()?.reset()))}))},86403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.testJpegtran_=t.jpegtranHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(55835),a=i(98314),o=i(89966),l=i(51210),u=i(76280),c=i(63335),d=i(18454);async function h(){const e=await(0,o.jpegtranNativePath_)(),t=await(0,l.jpegtranVersion_)();return{nativePath:e,version:t,satisfies:(0,u.semverSatisfies)(t,">=1.5")}}t.jpegtranHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-jpegtran",ordinal:2,pendingMsg:"Checking "+(0,r.tt)("jpegtran")+"…",settings:[],later:async()=>{try{const e=await h();return{level:"ok",msg:["jpegtran is OK",(0,n.map)(e.version,c.ver),(0,n.map)(e.nativePath,r.tt)]}}catch(e){return{level:"error",msg:["Something's amiss with jpegtran",(0,a.errorToS)(e)]}}}}))),t.testJpegtran_=h},42495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const r=i(40958),s=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,r.compact)([(0,s.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},42482:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryDirectoriesCheck=void 0;const r=i(82950),s=i(42659),n=i(45599),a=i(98553),o=i(31586),l=i(94174),u=i(87290),c=i(98314),d=i(29882),h=i(45969),f=i(43334),m=i(28874),p=i(2858),g=i(59107),y=i(18454),v=i(42495);async function w(){const e=await(0,u.setupLibraryDirs_)();return(0,p.libraryHasSettings)()?{level:"ok",msg:["Library directories are OK","Verified directory permissions for the following directories:",(0,r.li)(...e.map((e=>(0,r.tt)(e))))]}:{level:"no-library",msg:["Your PhotoStructure library hasn't been set up yet"]}}t.libraryDirectoriesCheck=(0,n.defer)((()=>y.HealthCheck.for({section:"Library",id:"library-directories",ordinal:0,pendingMsg:"Checking library directories…",settings:["libraryDir","originalsDir","previewsDir","cacheDir"],ttlMs:s.minuteMs,links:[{text:'What\'s a "PhotoStructure library?"',icon:"docs",url:"https://photostructure.com/faq/library/"},...(0,h.isDocker)()?[{text:"Read how to setup up Docker",icon:"docs",url:"https://photostructure.com/server/photostructure-for-docker/"}]:[]],okLinks:[{type:"button",text:"Run library maintenance jobs",url:"/admin/run-maintenance",method:"POST",icon:"handyman"}],later:async()=>(await(0,p.readSettings)(),(0,h.isDocker)()?async function(){const e=(0,u.libraryDirPosixFile)();if(null==e)return{level:"error",msg:[`Something's amiss: ${(0,r.tt)("PS_LIBRARY_DIR")} is blank`,`The default is ${(0,r.tt)(m.Settings.libraryDir.toEnvLine(m.Settings.libraryDir.defaultValue))}`]};const t=await(0,g.mountpoints_)(),i=(0,d.bestMountpointForDir)(e,t);if(null==i||"/"===i)return{level:"warn",msg:[e.nativePath+" is not a bind-mount",`Your library directory, ${(0,r.tt)(e)}, does not seem to be a bind mount.`,"Your library contents will disappear when you shut down this container."],links:[v.DockerVolumeLink]};try{if(!await e.isReadWriteExecutable_()){const t=await e.stat(),i=[`Your library directory, ${(0,r.tt)(e)}, is not read/write${f.isWin?"":"/execute"} by ${await(0,l.userDesc)()}`];return null!=t&&(0,o.gte0)(t.uid)&&i.push("The owner of this directory is userid "+(0,r.tt)(t.uid)+", groupid "+(0,r.tt)(t.gid)),{level:"error",msg:[...i,"Please fix the permissions for this bind mount and restart the container."],links:[v.DockerVolumeLink]}}return await w()}catch(t){return{level:"error",msg:[`Your library directory, ${(0,r.tt)(e)}, can't be set up for ${await(0,l.userDesc)()}.`,(0,c.errorToS)(t,{maxLen:80}),"Please fix the permissions for this bind mount and restart the container."],links:[v.DockerVolumeLink]}}}():async function(){const e=(0,u.libraryDirPosixFile)();if(null==e)return{level:"no-library",msg:["No PhotoStructure library is open",(0,a.stringify)(m.Settings.libraryDir.getState())]};if(!(0,p.libraryHasSettings)())return{level:"no-library",msg:["No PhotoStructure library is open",m.Settings.libraryDir.hasValue()?(0,r.tt)(m.Settings.libraryDir.toEnvLine()):void 0]};try{return await e.isReadWriteExecutable_()?await w():{level:"no-library",msg:[`Your library directory, ${(0,r.tt)(e)}, is not read/write${f.isWin?"":"/execute"} by ${await(0,l.userDesc)()}`,"Please fix the permissions or pick a new library directory."]}}catch(t){return{level:"no-library",msg:[`Your library directory, ${(0,r.tt)(e)}, can't be set up for ${await(0,l.userDesc)()}`,(0,c.errorToS)(t,{maxLen:80}),"Please fix the permissions for this bind mount and restart the container."]}}}())})))},35675:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFreeSpaceCheck=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(31586),l=i(68708),u=i(12168),c=i(87290),d=i(77740),h=i(28874),f=i(7014),m=i(18454);t.libraryFreeSpaceCheck=(0,a.defer)((()=>(0,l.tap)(m.HealthCheck.for({section:"Library",id:"library-free-space",settings:["libraryDir","minDiskFreeGb","originalsDir","previewsDir","cacheDir"],pendingMsg:"Checking free space on library volume(s)…",ttlMs:n.dayMs,later:async()=>{if(!(0,o.gt0)(h.Settings.minDiskFreeGb.valueOrDefault))return{level:"disabled",msg:`Library disk free test disabled: ${(0,s.tt)(h.Settings.minDiskFreeGb.key+"=0")}`};const e=(0,c.libraryDirPosixFile)();if(null==e)return{level:"disabled",msg:"Library disk free test disabled: no library is open"};if(!0!==await e.isDirectory())return{level:"disabled",msg:`Library disk free test disabled: ${(0,s.tt)(e)} is not a directory`};const t=[];for(const e of await(0,c.setupLibraryDirs_)()){const i=await(0,f.bestVolumeForPath)(e);if(null==i)return{level:"warn",msg:`Could not check for minimum disk free: no volume found for library path ${(0,s.tt)(e)}`};let r=t.find((e=>e.vol.mountpoint===i.mountpoint));null==r&&(r={vol:i,paths:[]},t.push(r)),r.paths.push(e.nativePath)}const i=h.Settings.minDiskFreeGb.valueOrDefault*u.GB,n=[];for(const{vol:e,paths:a}of t){const t=(0,s.b)(`Volume ${(0,s.tt)(e.mountpoint)} has ${(0,u.fmtBytes)(e.available)} free.`)+`\nThis volume is used for these PhotoStructure directories:\n${(0,s.li)((0,r.uniq)(a).sort().map(s.tt))}`;if(e.available{for(const t of["minDiskFreeGb","libraryDir","originalsDir","configDir"])h.Settings[t].watchLater((()=>e.reset()))}))))},89035:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const s=r(i(48161)),n=i(19851),a=i(82950),o=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),h=i(23560),f=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:r}){return{level:i,msg:[e+" from "+(0,h.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,a.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(r,2)])]}}function g(){return s.default.totalmem()f.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(f.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*f.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,n.lazy)((()=>"ok"!==g().level),o.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:o.minuteMs,later:async()=>g()})))},31974:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.nodejsHealthCheck=void 0;const s=r(i(1708)),n=i(82950),a=i(45599),o=i(26033),l=i(63335),u=i(18454);t.nodejsHealthCheck=(0,a.defer)((()=>u.HealthCheck.for({section:"Tools",id:"nodejs-version",ordinal:4,pendingMsg:"Checking Node.js…",settings:[],links:[{text:"Read about PhotoStructure NodeJS support",icon:"docs",url:"https://photostructure.com/server/photostructure-for-node/#prerequisites"}],later:async()=>{const e="You're running Node.js "+(0,l.ver)(s.default.versions.node)+".\nPhotoStructure requires "+(0,n.tt)(o.RequiredNodeRange)+".";return(0,o.isSupportedNode)()?{level:"ok",msg:["Node.js is OK",e]}:{level:"warn",msg:["Node.js is not a supported version",e]}}})))},20752:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notInDMGHealthCheck=void 0;const r=i(45599),s=i(43899),n=i(43334),a=i(18454);t.notInDMGHealthCheck=(0,r.defer)((()=>n.isMac&&n.isElectron?a.HealthCheck.for({section:"System",id:"proc-not-in-dmg",pendingMsg:"Checking PhotoStructure installation directory…",settings:[],later:async()=>s.ProjectPath.isInDMG()?{level:"error",msg:"PhotoStructure cannot run directly from a DMG disk image. Please drag and drop the PhotoStructure icon onto your Applications folder to install.",checkboxLabel:"Open https://photostructure.com/getting-started/installation/ in your browser"}:{level:"ok",msg:"PhotoStructure isn't running directly from a DMG disk image"}}):void 0))},85200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.osHealthCheck=void 0;const r=i(45599),s=i(96175),n=i(18454);t.osHealthCheck=(0,r.defer)((()=>n.HealthCheck.for({section:"System",id:"system-version",pendingMsg:"Checking operating system…",settings:[],links:[{text:"What do I need to run PhotoStructure?",icon:"docs",url:"https://forum.photostructure.com/t/what-do-i-need-to-run-photostructure/44"}],later:async()=>{const e=(0,s.whyOsNotSupported)();return null==e?{level:"ok",msg:["Operating system is OK","PhotoStructure supports "+(0,s.osFullName)()]}:{level:"warn",msg:["Operating system is not supported",(0,s.osFullName)()+" was detected, but only "+e+"."]}}})))},37301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.powershellHealthCheck=void 0;const r=i(42659),s=i(45599),n=i(98314),a=i(43334),o=i(24399),l=i(63335),u=i(18454);t.powershellHealthCheck=(0,s.defer)((()=>a.isWin?u.HealthCheck.for({section:"Tools",id:"tools-powershell",pendingMsg:"Checking PowerShell…",settings:["powerShellArgs"],ttlMs:r.minuteMs,links:[{text:"How to fix PowerShell issues",url:"https://photostructure.com/fix-pwsh/"}],later:async()=>{try{const e=await(0,o.checkPowerShell_)();return{level:"ok",msg:["PowerShell is OK",(0,l.ver)(e)],meta:{version:e}}}catch(e){return{level:"error",msg:"PowerShell failed: "+(0,n.errorToS)(e)}}}}):void 0))},65756:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(27180),a=i(98314),o=i(63335),l=i(18454);t.sqliteHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Tools",id:"tools-sqlite-version",ordinal:0,pendingMsg:"Checking SQLite…",settings:[],links:[{text:"Read about PhotoStructure SQLite support",url:"https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837",icon:"docs"}],async later(){try{const e=await n.sqliteVersion_.refresh();return null==e?{level:"error",msg:"SQLite version could not be found"}:{level:"ok",msg:["SQLite is OK",(0,r.li)(["embedded: "+(0,o.ver)(e.libraryVersion),(0,r.tt)(e.sqliteNativePath)+": "+(0,o.ver)(e.toolVersion)])]}}catch(e){return{level:"error",msg:"Something's amiss with SQLite: "+(0,a.errorToS)(e)}}}})))},15024:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.securityHealthCheck=void 0;const r=i(40958),s=i(82950),n=i(45599),a=i(31586),o=i(94174),l=i(77740),u=i(44198),c=i(59958),d=i(43334),h=i(18454);t.securityHealthCheck=(0,n.defer)((()=>{const e=d.isWin?"an administrator":"root";return h.HealthCheck.for({section:"System",id:"proc-not-superuser",pendingMsg:"Checking user permission level…",settings:[],later:async()=>{if("0"===(0,u.env)().PUID)return{level:"disabled",msg:`Admin health check is disabled (${(0,s.tt)("PUID=0")}).`};const t=(0,r.compact)([(0,a.gte0)((0,o.userid)())?"Current user id: "+(0,s.b)((0,s.tt)((0,o.userid)())):void 0,(0,a.gte0)((0,o.groupid)())?"Current group id: "+(0,s.b)((0,s.tt)((0,o.groupid)())):void 0,"Current user name: "+(0,s.b)((0,s.tt)(await(0,o.username)()??"(unknown)"))]);return!0===await(0,o.isRootUser)()||(0,l.getDevEnvFlag)(c.DevEnvFlags.PS_FAIL_SECURITY_HEALTH_CHECK)?{level:"warn",msg:["PhotoStructure should not be run as "+e,...t],links:[{text:"Read why PhotoStructure should not be run as "+e,url:"https://photostructure.com/server/photostructure-for-docker/#why-not-run-as-root"}]}:{msg:["PhotoStructure is not running as "+e,...t],level:"ok"}}})}))},3956:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsEnvHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(12168),a=i(28874),o=i(63225),l=i(18454);t.settingsEnvHealthCheck=(0,s.defer)((()=>l.HealthCheck.for({section:"Library",id:"settings-env",pendingMsg:"Checking environment settings…",settings:[],links:[{text:"Read about PhotoStructure environment settings",url:"https://photostructure.com/faq/environment-variables/",icon:"docs"}],later:async()=>{const e=[];for(const t of(0,a.allSettings)())if(t.hasValue()&&null!=t._envValue()){const i=!0===t.opts.sensitive?"********":t.toEnvValue(t._envValue());null!=i&&e.push((0,r.tt)(t.key+"="+i))}const t=[(0,n.plur)(e.length,"environment setting"),(0,r.li)(e)],i=(0,o.verifyPsEnvSettings)();return i.length>0?{level:"warn",msg:["Some environment settings may be misconfigured:",(0,r.li)(i.map((e=>(0,r.tt)(e.envKey)+": "+e.msg))),"---",...t]}:{level:"ok",msg:t}}})))},29332:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsLibraryHealthCheck=void 0;const r=i(45599),s=i(2858),n=i(18454),a=i(61274);t.settingsLibraryHealthCheck=(0,r.defer)((()=>n.HealthCheck.for({section:"Library",id:"settings-library",pendingMsg:"Checking library settings…",settings:["libraryDir"],links:[{text:"Read about PhotoStructure library settings",url:"https://photostructure.com/getting-started/advanced-settings/#library-settings",icon:"docs"}],later:()=>(0,a.validateSettingsToml)((0,s.librarySettingsFile)(),"library")})))},61274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.settingsSystemHealthCheck=t.validateSettingsToml=void 0;const r=i(40958),s=i(82950),n=i(45599),a=i(12168),o=i(81168),l=i(98314),u=i(95696),c=i(2858),d=i(32707),h=i(18454);async function f(e,t){try{if(null==e)return{level:"disabled",msg:"No "+t+" settings is set."};if(await e.notExists())return{level:"disabled",msg:(0,o.capitalize)(t)+" settings file "+(0,s.tt)(e)+" does not exist."};const i=await(0,c.importFileSettings_)(e);return(0,r.isNotEmpty)(i.warnings)?{level:"warn",msg:(0,s.tt)(e)+": "+i.warnings.join(", ")}:{level:"ok",msg:[(0,a.plur)(i.settings.length,t+" setting override"),(0,s.b)("Source:"),(0,s.tt)(e),(0,s.b)("Settings:"),(0,s.li)(i.settings.map((e=>(0,s.tt)(e.key+"="+e.toEnvValue(e.value)))))]}}catch(t){return{level:"error",msg:"Failed to parse "+e+":\n"+(0,l.errorToS)(t)}}}t.validateSettingsToml=f,t.settingsSystemHealthCheck=(0,n.defer)((()=>h.HealthCheck.for({section:"Library",id:"settings-system",pendingMsg:"Checking system settings…",settings:[],links:[{text:"Read about PhotoStructure system settings",url:"https://photostructure.com/getting-started/advanced-settings/#system-settings",icon:"docs"}],later:()=>f(u.PosixFile.forMaybe((0,d.systemSettingsFile)()),"system")})))},38372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpHealthCheck=void 0;const r=i(45599),s=i(98314),n=i(21473),a=i(18454);t.sharpHealthCheck=(0,r.defer)((()=>a.HealthCheck.for({section:"Tools",id:"tools-sharp",ordinal:2,pendingMsg:"Checking Sharp…",settings:[],later:async()=>{try{return await(0,n.testSharp_)(),{level:"ok",msg:["Sharp is OK","Image processing is working as expected."]}}catch(e){return{level:"error",msg:["Something's amiss with Sharp",(0,s.errorToS)(e)]}}}})))},82638:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const r=i(40958),s=i(42659),n=i(45599),a=i(41400),o=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),h=i(23560),f=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,n.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function v({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:r}){const s=new Map;for(const e of t??[])s.set(e.id,e);if(null!=e)for await(const t of f.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),r))s.set(t.id,t);return[...s.values()]}t.summarizeHealthChecks=async function(e){return b({...e,healthCheckResults:await v(e)})};const w=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:h.serviceName.prior()??process.title}})));function b(e){const t=(0,r.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),n=i.length,a=i.map((e=>e.id)),c=t.length-n,d=0===n,h=(0,r.uniq)((0,r.compactBlanks)(e.errors));if(h.length>0)return{...w(),level:l.HealthCheckLevels.error,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",h.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const s=t.filter((e=>e.level===i));if((0,r.isNotEmpty)(s)){const e=t.filter((e=>!s.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+s.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...w(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:a,pendingCount:n,settledCount:c,linkIds:s.map((e=>e.id)),ts:Date.now(),msg:(0,r.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,o.flatten)([...s,...e].map((e=>e.msg[0])))])},meta:{checks:s.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...w(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:a,pendingCount:n,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,s.fmtDateShort)(Date.now())]}})}(0,a.later)((()=>{m.Settings.libraryDir.watchLater((()=>w.unset()))})),t.summarizeHealthChecksSync=b},49913:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemLoadHealthCheck=void 0;const r=i(82950),s=i(42659),n=i(45599),a=i(31586),o=i(28874),l=i(14854),u=i(18454);t.systemLoadHealthCheck=(0,n.defer)((()=>u.HealthCheck.for({section:"System",id:"system-load",pendingMsg:"Checking system load…",settings:["cpuBusyPercent"],ttlMs:s.minuteMs,later:async()=>{if(o.Settings.cpuBusyPercent.valueOrDefault<=0)return{level:"ok",msg:["CPU utilization is not monitored",(0,r.tt)(o.Settings.cpuBusyPercent.key)+" is set to <= 0"]};const e=l.CpuUsage.instance().busyPct(),i=(0,l.isTooBusy)();return(0,t.systemLoadHealthCheck)().setTTL((i?6:60)*s.secondMs),{level:i?"stop-sync":"ok",msg:"CPU utilization is "+(0,a.fmtPct)(e)+"\n"+(i?"PhotoStructure sync is paused until CPU utilization drops below":"PhotoStructure sync will pause if CPU utilization exceeds")+" "+(0,r.tt)(o.Settings.cpuBusyPercent.key)+": "+(0,a.fmtPct)(o.Settings.cpuBusyPercent.valueOrDefault)}}})))},84728:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionHealthCheck=void 0;const r=i(42659),s=i(45599),n=i(40044),a=i(18454);t.versionHealthCheck=(0,s.defer)((()=>a.HealthCheck.for({section:"System",id:"ps-version",pendingMsg:"Checking PhotoStructure version…",settings:["autoUpdateCheck","configDir","libraryDir","optOut"],ttlMs:r.hourMs,links:[{text:"Change auto-update setting",icon:"settings",url:"/settings#update-check-section"},{text:"What's new?",icon:"docs",url:"https://photostructure.com/whats-new/"},{text:"Update checking & privacy",icon:"docs",url:"https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956"}],later:n.checkVersion_})))},7245:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.videoHealthCheck=void 0;const r=i(82950),s=i(45599),n=i(41400),a=i(55835),o=i(34102),l=i(66106),u=i(45969),c=i(63335),d=i(18454);t.videoHealthCheck=(0,s.defer)((()=>d.HealthCheck.for({section:"Tools",id:"tools-video",pendingMsg:"Checking video tooling…",settings:["ffmpegPath"],links:[{text:"Read how to set up video support with PhotoStructure",url:"https://photostructure.com/getting-started/video-support/",icon:"docs"}],warnLinks:(0,u.isDocker)()?[]:[{text:"Re-check for video tooling",icon:"refresh",method:"POST",type:"button",url:"/admin/recheck-tools"}],later:async()=>{const e=await(0,l.getVideoToolDetails_)();return null!=e&&!1!==e.isSupportedVersion?{level:"ok",msg:["Videos will be imported",(0,a.map)(e.version,c.ver),(0,a.map)(e.path,r.tt)]}:{level:"warn",msg:["Videos will not be imported","No video tooling was found."]}}}))),(0,n.later)((()=>{(0,o.ee)().on("clearToolCache",(()=>t.videoHealthCheck.prior()?.reset()))}))},16264:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeHealthCheck=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(13538),l=i(83104),u=i(12168),c=i(48884),d=i(45255),h=i(43334),f=i(69108),m=i(48165),p=i(63870),g=i(7014),y=i(18454);t.volumeHealthCheck=(0,a.defer)((()=>y.HealthCheck.for({section:"System",id:"system-volumes",ordinal:0,pendingMsg:"Checking volumes…",settings:[],links:[{text:"What's a “volume”?",url:"https://photostructure.com/faq/what-is-a-volume/",icon:"docs"}],warnLinks:h.isWin?[{text:"Check this page for troubleshooting tips",url:"https://photostructure.com/faq/windows-troubleshooting/#unhealthy-network-shares"}]:void 0,later:async()=>{const e=Date.now(),i=await(0,o.thenOrTimeout)((0,g.volumes)(),(0,p.commandTimeoutMs)());if(i===l.Timeout){const i=await(0,o.thenOrTimeout)(h.isWin?(0,m.getLocalVolumesWin_)():(0,f.dfPosixRawLocal_)(),d.ShortCommandTimeoutMs);return(0,t.volumeHealthCheck)().logger.warn("volumes() timed out, retrying in 5m"),setTimeout((()=>(0,t.volumeHealthCheck)().refresh()),5*n.minuteMs),{level:"warn",msg:[i===l.Timeout?"Something seems wrong with your computer's volumes":"Something seems wrong with one or more remote filesystem mounts","Gathering volume metadata took longer than "+(0,n.fmtAgo)(e,"")+"."]}}const a=i.filter((e=>!1===e.ok));if((0,r.isNotEmpty)(a))return{level:"warn",msg:["One or more volumes are not healthy","Check the following:",(0,s.li)(a.map((e=>(0,s.tt)(e.mountpoint))))]};const[y,v]=(0,c.partition)(i,(e=>!0===e.remote)),w=["Storage volumes are OK"];return(0,r.isNotEmpty)(v)&&w.push((0,s.b)((0,u.plur)(v.length,"local volume")+":"),(0,s.li)(...v.map((e=>(0,s.tt)(e.mountpoint))))),(0,r.isNotEmpty)(y)&&w.push((0,s.b)((0,u.plur)(y.length,"remote volume")+":"),(0,s.li)(...y.map((e=>(0,s.tt)(e.mountpoint))))),{level:"ok",msg:w}}})))},95242:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviewBuilder=t.mkPreviewAssetFile_=void 0;const a=i(57975),o=i(40958),l=i(22573),u=i(33374),c=i(98553),d=i(55835),h=i(68708),f=i(48884),m=i(50213),p=i(92434),g=i(54296),y=i(51837),v=i(57159),w=i(83278),b=i(95696),S=i(62105),P=i(84258),_=i(38156),T=i(69589),M=i(28874),E=i(47783),k=i(29990),D=i(16047),x=i(42725),C=i(4192),F=i(32876),A=i(50961),I=i(181);t.mkPreviewAssetFile_=async function(e){const t=await(0,E.readTags)(e);return{nativePath:e.nativePath,fileSize:await e.size(),mtime:await e.thisOrSidecareMaxMtimeMs(),uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath,mimetype:t.mimetype,rotation:t.rotation,...t.dimensions,sha:await e.sha_()}};class O{constructor(e,t,i){r.add(this),this.ap=e,this.assetFiles=t,this.logger=(0,m.mkLogger)("AssetPreviewBuilder("+e.assetId+")"),this.ctx=(0,T.forceContextOrSetting)(i),this.assetFiles=(0,p.sortAssetFiles)(this.assetFiles)}[(r=new WeakSet,a.inspect.custom)](){return{ctor:"AssetPreviewBuilder",assetId:this.ap.assetId,assetFiles:this.assetFiles}}async build_(){this.logger.info("build_(): asset file candidates:",this.assetFiles.map((e=>(0,h.pick)(e,"id","uri"))));const e=[];for(const t of this.assetFiles){const i=b.PosixFile.forMaybe(await(0,g.getAssetFileNativePath)(t));if(null!=i){{const e=await(0,S.whyRejectFile)(i);(0,l.blank)(e)||this.logger.info("skipping: rejected",{pf:i,whyRejected:e})}try{return await n(this,r,"m",s).call(this,i,t)}catch(i){e.push(i),this.logger.warn("Failed to set shown file to ",{best:t,error:i})}finally{this.ap.parent.clear()}}else this.logger.info("skipping: failed to get PosixFile",{af:t}),e.push(new Error("Cannot get path from URI "+(0,c.stringify)((0,h.pick)(t,"uri","mountpoint","nativePath"))))}return this.logger.throw("Cannot build previews: none of the files are valid",{doNotSend:!0,retriable:!1,files:this.assetFiles.map((e=>e.nativePath??e.uri)),causes:e})}async infoForBest_(e,t){await(0,I.throwIfInvalidFile_)(e);const i=await e.size(),r=await e.thisOrSidecareMaxMtimeMs();if(this.logger.debug("_build",{filesize:i,mtime:r,best:t.uri}),null==i||null==r)return this.logger.throw("build(): missing stat info for best file",{ignorable:!0,best:t});const{uri:s,width:n,height:a,sha:l,mimetype:u}=t;if(null==s||null==n||null==a||null==u||null==l)return this.logger.throw("build(): internal error: missing fields for best file "+e,{ignorable:!0,best:t});const c=(0,k.fitSizes)(t,t.mimetype);return{assetId:t.assetId,assetFileId:t.id,uri:s,uris:this.assetFiles.map((e=>e.uri)),path:e.nativePath,mtime:r,filesize:i,width:n,height:a,sha:l,mimetype:u,fitSizes:c.map((([,e])=>e.name)).join(","),sqWidths:(0,o.compact)(x.ImageSize.sq().map((e=>e.outputSize(t)?.width))),fitWidths:c.map((([e])=>e.width))}}async priorIfValid_(e,t){if(this.ctx.forceSync||this.ctx.forceRebuildPreviews)return;const i=await this.ap.readInfo.refresh();if(null!=i){if(i.assetId!==t.assetId)throw new y.InternalError("priorIfValid_(): mismatched asset IDs for "+e+": "+(0,c.stringify)({priorInfo:i,info:t}));const r=i.fitSizes.split(","),s=t.fitSizes.split(",");if(null!=i.sha&&i.sha===t.sha&&i.rotation===t.rotation&&(0,k.equivalentFitSizes)(r,s)){const n=(0,k.fitSizes)(e,e.mimetype),a=(0,o.diff)(r,s);if((0,o.isNotEmpty)(a)){this.logger.info("priorIfValid_(): removing previews that aren't required anymore.",{leftovers:a});for(const e of a){const t=n.find((([,t])=>t.name===e));if(null==t)this.logger.warn("priorIfValid_(): Failed to clean up: missing fit size",{fitsize:t,fits:n});else{const e=this.ap.fileForWidth(t[1].reducer.name,t[0].width);this.logger.debug("priorIfValid_(): unlinking unwanted preview "+e,{fitsize:t}),await e.unlink("warn")}}}return this.logger.debug("priorIfValid_(): SHA and rotation match, and previews exist.",{info:t,priorInfo:i}),await this.ap.writeInfo(t),t}}}}t.AssetPreviewBuilder=O,s=async function(e,t){this.logger.info("_build("+e+")",{uri:t.uri});const i=await this.infoForBest_(e,t),r=await this.priorIfValid_(t,i);if(null!=r)return r;const s=new _.PushProgressObserver({path:e.nativePath,op:"Building previews"},x.ImageSize.sq().length+x.ImageSize.fit().length);if(this.logger.debug("Rebuilding all previews from "+t.uri,{assetId:t.assetId,info:i}),null==await this.ap.parent.mkdirp())throw new Error("build(): Failed to create previews directory, "+this.ap.parent+" for "+t);const n=await this.ap.existingFiles(),a=await(0,A.sharpReadable_)({src:e,minDim:x.ImageSize.largestFit().max});if(null==a)throw new v.WrappedError("AssetPreviewBuilder.build(): "+t.uri+", "+e.nativePath+", is not readable by sharp.",{retriable:!1});const o=(0,A.toSharp)(a);if(t.mimetype.startsWith("image/")&&!(0,D.isHeifMimeType)(t.mimetype)&&null!=t.rotation&&0!==t.rotation&&(o.rotate(t.rotation),this.logger.debug("build(): rotating "+t.rotation+"°")),(0,w.isBaseFile)(a)&&a.desc.toLowerCase().includes("thumbnail"))try{o.trim(1)}catch{}const l=(0,k.fitSizes)(t,t.mimetype),c=[],m=[];let p,g;const y=x.ImageSize.largestSq(),b=(0,f.leastBy)(l,(([e,t])=>(0,d.map)(y.outputSize(e),(()=>t.megapixels()))))?.[1].name,S=(0,h.pick)(t,"width","height");{let e=o.clone(),t=S;for(const[i,r]of l){const n=Date.now(),a=t,o=this.ap.fileForWidth(r.reducer.name,i.width).wip();e=r.resize(i,e),t=i,r.name===b&&(g=e.clone(),p=i),(0,u.dmegapixels)(i)>=1&&r.reducer===F.Fit&&M.Settings.includePreviewTags.valueOrDefault&&m.push(o),await r.toJpeg({path:o.nativePath,sh:e,outputSize:i}),s.onProgress(),this.logger.debug("resize("+r.name+") "+(0,u.fmtDim)(a)+" -> "+(0,u.fmtDim)(i)+" in "+(Date.now()-n)+" ms"),c.push(o)}}{null==g?(this.logger.debug("square resize(): resorting to ",{origDim:S,bestFitNameForSq:b}),g=o,p=S):this.logger.debug("square resize(): using to ",{sqDim:p,bestFitNameForSq:b});let e=!1;for(const t of x.ImageSize.sq()){const i=Date.now(),r=p,n=t.outputSize(p??S);if(null==n){this.logger.debug("skipping square output for "+t.max);continue}e||(n.position=M.Settings.squareThumbStrategy.valueOrDefault,e=!0),this.logger.debug("Applying ",{outputSize:n});const a=this.ap.fileForWidth(t.reducer.name,n.width).wip();t.resize(n,g),p=n,await t.toJpeg({path:a.nativePath,sh:g,outputSize:n}),s.onProgress(),c.push(a),this.logger.debug("resize("+t.name+") "+(0,u.fmtDim)(r)+" -> "+(0,u.fmtDim)(n)+" in "+(Date.now()-i)+" ms")}}try{await(0,C.includePreviewTags_)(e,m).catch((t=>{this.logger.warn("Failed to restore metadata tags into previews for "+e,{error:t})}));const t=new Set(n.map((e=>e.nativePath)));for(const e of c){const i=await e.unwip_();t.delete(i.nativePath)}await(0,P.unlink)(t),await this.ap.writeInfo(i),this.logger.debug("Previews unwipped and info written",{info:i})}catch(t){throw await(0,P.unlink)(c),new v.WrappedError("Failed to create previews from "+e,{cause:t,path:e.nativePath,fatal:!1})}return i}},35721:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkDownloadableTitle=t.previewToDownloadable=t.extractPreviewInfo=void 0;const r=i(75761),s=i(33374),n=i(11371),a=i(55835),o=i(31586),l=i(56519),u=i(29882),c=i(50213),d=i(97352),h=i(81168),f=i(89782),m=(0,c.mkLogger)("extractPreviewInfo");function p(e,t,i,r){return`Download ${t} ${e.ext} ${i} (${(0,s.fmtDim)(r)})`}t.extractPreviewInfo=function(e,t){const i=t.posixPathFrom(e).replace(/\//g,"").split("-"),r=(0,o.toInt)(i[0]),s=n.ReducerNames.getCI(i[1]),a=(0,d.extractInt)(i[2]);return(0,o.gt0)(r)?{file:t,assetId:r,reducer:s,width:a}:void m.warn("Failed to extract preview info",{file:t,previewsRoot:e,arr:i,assetId:r,reducer:s,width:a})},t.previewToDownloadable=async function(e,t){return(0,a.map2)(t.assetId,t.width,((i,a)=>(0,l.thenMap)((0,f.dimensions)(t.file),(o=>{const l=(0,s.dimToSize)(o);return{size:l,basename:`${(0,h.stripSuffix)(e,(0,u.extname)(e))}-${l}${t.file.ext}`,title:p(t.file,l,"image",o),description:`Download ${l}`,details:`(${(0,s.fmtDim)(o)} ${t.file.ext})`,href:(0,r.assetImgLink)({assetId:i,reducer:n.ReducerNames.fit,width:a})}}))))},t.mkDownloadableTitle=p},16524:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviews=void 0;const a=i(19851),o=i(40958),l=i(75761),u=i(11371),c=i(68708),d=i(39926),h=i(58939),f=i(48884),m=i(50213),p=i(81168),g=i(56519),y=i(38835),v=i(70417),w=i(35721);t.AssetPreviews=class{constructor(e,t){r.add(this),this.previewsRoot=e,this.readInfo=(0,a.lazy)((()=>this.infoJson().readJson("debug"))),this.logger=(0,m.mkLogger)("AssetPreviews(assetId:"+(0,h.id2id)(t)+")"),this.assetId=(0,h.id2id)(t);const i=(0,d.leftPad)(this.assetId,8,"0"),s=(0,p.splitEvery)(i,3);this.basename=s.pop()+"-",this.parent=e.join(...s)}parentNotExists(){return this.parent.clear().notExists()}async existingFiles(){return await this.parent.clear().childFiles((e=>e.base.startsWith(this.basename)))??[]}async existingJpgs(){return(await this.existingFiles()).filter((e=>".jpg"===e.ext))}async previewInfos(){return(0,g.sortByAsync)({name:"img.AssetPreviews.previews",arr:n(this,r,"m",s).call(this),f:e=>e?.file.size()})}async deleteAll(){const e=await this.existingFiles();if(e.length>20)throw new Error("deleteAll(): rejected: > 20 existing files?!"+y.InternalErrorFlag);for(const t of e)await t.unlink();return e}fileForSuffix(e){return this.parent.join(this.basename+e)}mp4(){return this.fileForSuffix("video.mp4")}infoJson(){return this.fileForSuffix("info.json")}writeInfo(e){return this.readInfo.unset(),this.infoJson().writeJson((0,c.pick)(e,"assetId","assetFileId","uri","uris","path","mimetype","width","height","mtime","filesize","sha","rotation","fitSizes","fitWidths"))}fileForWidth(e,t){return this.fileForSuffix(e+"-w"+t+".jpg")}async filesForReducer(e){const t=this.basename+e+"-";return this.logger.tap({msg:"filesForReducer("+e+")",result:(await this.existingFiles()).filter((e=>e.base.startsWith(t)))})}async smallestFileForReducer(e){return(0,f.leastBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async largestFileForReducer(e){return(0,f.greatestBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async widths(e){const t=await this.readInfo(),i=e===u.ReducerNames.sq?"sqWidths":"fitWidths",r=t?.[i];if(!(0,o.isEmpty)(r))return r;const s=(0,o.compact)((await this.previewInfos()).filter((t=>t.reducer===e)).map((e=>e.width)));return null!=t&&(t[i]=s,await this.writeInfo(t)),s}async posterLink(){const e=await this.widths(u.ReducerNames.fit);return(0,l.assetImgLink)({assetId:this.assetId,reducer:u.ReducerNames.fit,width:(0,v.max)(e)})}async imgAttrs(e,t=!1,i=!0){if(t||e!==u.ReducerNames.sq){const t=e===u.ReducerNames.fit?await this.readInfo():void 0;return(0,l.assetImgAttrs)({assetId:this.assetId,reducer:e,widths:await this.widths(e),lazyLoad:i,af:t})}return(0,l.assetSqImgAttrs)({assetId:this.assetId,lazyLoad:i})}},r=new WeakSet,s=async function(){const e=[];for(const t of await this.existingFiles()){const i=(0,w.extractPreviewInfo)(this.previewsRoot,t);null!=i&&e.push(i)}return e}},52086:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const r=i(50989);t.CropStrategies=(0,r.strEnum)("center","entropy","attention")},33106:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.dctPixels=t.dctHashCIELAB=t.dctHash=void 0;const s=r(i(9288)),n=i(96249),a=i(85810),o=32,l=function(e){const t=new Array(32);for(let e=1;e<32;e++)t[e]=1;return t[0]=1/Math.sqrt(2),t}(),u=function(e){const t=new Array(32);for(let e=0;e<32;e++){t[e]=new Array(32);for(let i=0;i<32;i++)t[e][i]=Math.cos((2*e+1)/64*i*Math.PI)}return t}();function c(e){const t=new Array(o);for(let i=0;is?1:0);return n}t.dctHash=async function(e){return c(await e.greyscale().resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer())},t.dctHashCIELAB=async function(e){const t=await e.resize({width:o,height:o,fit:s.default.fit.fill}).raw().toBuffer(),i=(0,a.rgb2labArray)(t);return(0,n.flatten)(i.map(c))},t.dctPixels=c},86580:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(21605),o=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,n.gt0)(e.width)&&(0,n.gt0)(e.height)?(0,n.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,s.dmegapixels)(e.dimensions):(0,n.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,n.lt)(e.width,t.width)&&(0,n.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,n.lte)(e?.width,t?.width)&&(0,n.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,n.lt)(e.width,t.width)||(0,n.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,r.compact)((0,o.toS)(e).split(/[x×]/).map((e=>(0,n.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,r=Math.round(Math.sqrt(t*i));return{width:r,height:Math.round(r/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const r=u(e,i);return null==r?[]:a.Rotations.filter((e=>u(c(t,e),i)===r))}},89782:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const r=i(19851),s=i(31586),n=i(50213),a=i(56519),o=i(1078),l=i(5733),u=(0,r.lazy)((()=>(0,n.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,s.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,a.thenMap)((0,o.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},29990:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.equivalentFitSizes=t.fitSizes=void 0;const r=i(40958),s=i(33374),n=i(16170),a=i(42725),o=[a.ImageSize.QVGA,a.ImageSize.QQVGA];function l(e){return"qhd"===e?"wvga":"uhd"===e?"uhd4k":e}t.fitSizes=function(e,t){const i=a.ImageSize.fit(),r=[];let l=(0,n.isMimeTypeSupportedByBrowser)(t)?e:void 0;for(let t=0;t3||(0,s.dmegapixels)(a)-(0,s.dmegapixels)(l)>2.5)&&(l=a,r.push([a,n])))}return r},t.equivalentFitSizes=function(e,t){return(0,r.includesAll)((0,r.compactBlanks)(e).map(l),(0,r.compactBlanks)(t).map(l))}},277:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const r=i(22573),s=i(41400),n=i(54993),a=i(19851),o=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),h=i(78330),f=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),v=(0,a.lazy)((()=>(0,o.mkLogger)("img.Heif")));function w(e){return(0,n.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function b(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,a.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,r.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){v().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,r.blank)(e))return void v().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=w(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,r.blank)(i)&&(0,l.hasApt)()){const t=await(0,h.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,r.blank)(i)&&(0,f.hasPacman)()&&(i=(await(0,f.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,r.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void v().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=w,t.isHeifSupported=b,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await b()?(0,g.heif2png_)(e):void v().throw("HEIF support is missing",{src:e.nativePath})},(0,s.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(41400),o=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),h=i(28874),f=i(89782),m=i(13940),p=(0,r.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,s.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,r.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:h.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?n.minuteMs:void 0),e})),(0,a.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,f.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(h.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:h.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(o.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const r=i(22573),s=i(54993),n=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,r.blank)(e)&&n.test((0,s.toS)(e))}},13940:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const r=i(51455),s=i(19851),n=i(42659),a=i(59455),o=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),v=i(55222),w=i(63870),b=(0,s.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,s.lazy)((()=>(S(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const S=(0,s.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,r){const s=await(0,t.imageCacheDir_)();i??(i=e.name),r=(0,c.ensurePrefix)(r??e.ext,".");const n=s.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await n.mkdirp_(),await n.utimes();const a=n.join(i+r);return b().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:r,result:a}),a}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,a.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,r.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),r=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+v.TokenRadix.randomChars(2),v.TokenRadix.randomChars(16)+(0,o.toS)(e.ext));return await r.parent().mkdirp_(),r},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:r}){return(await P(e,t,i)).applyIfEmpty_({fn_:r,timeoutMs:2*n.minuteMs})},t.withImageCache_=async function(e,t,i,r){try{const s=await P(e,t,i);return await s.applyIfEmpty_({fn_:r,skipFsLock:!1,skipWip:!1,timeoutMs:(0,w.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),s}catch(r){return b().throw("withImgCache_() failed",{error:r,src:e.nativePath,desc:t,ext:i})}}},48368:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashDim=t.toImageHash=t.isImageHash=t._imageHash_=t.imageHash_=t.imageHash=t.maxPerBits=void 0;const s=r(i(9288)),n=i(19851),a=i(40958),o=i(22573),l=i(42659),u=i(33374),c=i(56038),d=i(85810),h=i(76490),f=i(40401),m=i(86758),p=i(85434),g=i(96706),y=i(38835),v=i(88561),w=i(95696),b=i(17217),S=i(50213),P=i(23624),_=i(28874),T=i(12089),M=i(16170),E=i(1078),k=i(33106),D=i(86580),x=i(78011),C=i(50961);t.maxPerBits=function(e){return Math.floor(52/e)};const F=(0,n.lazy)((()=>(0,S.mkLogger)("img.ImageHash")));t.imageHash=async function(e){try{return await(0,t.imageHash_)((0,b.toNativePath_)(e))}catch(t){return void F().warn("imageHash() failed for "+e,t)}};const A=(0,n.lazy)((()=>new v.FileCache({name:"img.imageHash",timeoutMs:l.minuteMs})));async function I(e){const t=w.PosixFile.for(e),i=await(0,E.extractSizeInfoFromFile)(t);if(null==i)throw new Error("Failed to read dimensions for "+e+y.NonFatalErrorFlag+y.DoNotSendErrorFlag);const r=(0,D.fitToResolution)(i.dimensions,Math.round(_.Settings.dominantColorPixels.valueOrDefault)),n=await(0,C.sharpReadable_)({src:t,minDim:r});return(0,c.time)("img.imageHash",(()=>async function({file:e,readable:t,sizeInfo:i}){const r=(0,S.mkLogger)("ImageHash("+e+")");if(null==t)return r.throw("Cannot build readable stream");const n=(0,D.fitToResolution)(i.dimensions,_.Settings.dominantColorPixels.valueOrDefault);if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-orig.jpg";await(0,C.toSharp)(t).jpeg().toFile(i),console.log({out:i,readable:t})}let a=(0,C.toSharp)(t).removeAlpha();(0,M.isVideoMimeType)(t.mimetype)||(a=a.rotate(i.rotation)),(0,u.dmegapixels)(i.dimensions)<.1&&(a=a.trim({background:"#000",threshold:0})),a=a.resize({fit:s.default.fit.outside,...n,withoutEnlargement:!0});const{data:o,info:l}=await a.raw().toBuffer({resolveWithObject:!0});if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-"+l.width+"w.jpg";await(0,s.default)(o,{raw:{...l,channels:3}}).jpeg().toFile(i),console.log({out:i,rgbInfo:l,readable:t})}const c=(0,d.rgb2labTriplets)(o),h=(0,f.extractDominantColors)(c),p=(0,m.labsAreGreyscale)(c),y=()=>(0,s.default)(o,{raw:{...l,channels:3}}),v=await(p?x.meanDiffHash:x.meanDiffHashCIELAB)(y()),w=await(p?k.dctHash:k.dctHashCIELAB)(y());return{meanHash:(0,P.b64encodeBits)(v.meanHash),diffHash:(0,P.b64encodeBits)(v.diffHash),dctHash:(0,P.b64encodeBits)(w),dominantColors:h.dominantColors,dominantColorsDescription:h.description,dominantColorScore:h.dominantColorScore,isGreyscale:p,mimetype:(0,M.normalizeMimetype)(t.mimetype),...i.dimensions,rotation:i.rotation??0}}({file:t,readable:n,sizeInfo:i})))}function O(e){return null!=e&&(0,o.notBlank)(e.meanHash)&&(0,o.notBlank)(e.mimetype)&&(0,a.isNotEmpty)(e.dominantColors)}t.imageHash_=(0,T.shim1)({name:"img.imageHash",cache:A,impl:I}),t._imageHash_=I,t.isImageHash=O,t.toImageHash=function(e){if(null!=e){if(O(e))return e;if((0,p.isModeData)(e)){const t={...(0,p.omitModeData)(e),dominantColors:h.DominantColor.fromModeData(e)};if(O(t))return t}}},t.HashDim=8},80361:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageHashSimilarity=t.isVerySimilarComparison=t.isVerySimilarImageHash=t.isSimilarImageHash=t.isVerySimilarImage=t.compareImageHashes=t.isSimilarImage=t.hammRatio=t.meanHashVariants=t.isGreyscaleMeanHash=t.labsCorr2=t.isImageHashComparison=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(38639),o=i(33374),l=i(57924),u=i(55835),c=i(31586),d=i(68708),h=i(39926),f=i(21605),m=i(48884),p=i(50213),g=i(97352),y=i(85810),v=i(3048),w=i(32848),b=i(82647),S=i(38812),P=i(70417),_=i(23624),T=i(28874),M=i(86580),E=i(48368),k=i(2090),D=(0,r.lazy)((()=>(0,p.mkLogger)("img.ImageHashComparison")));t.isImageHashComparison=function(e){return null!=e&&(0,E.isImageHash)(e.a)&&(0,E.isImageHash)(e.b)&&[e.imageCorr,e.colorCorr,e.aRotation].every(c.isNumber)},t.labsCorr2=function(e,t){const i=(0,s.sum)(e,(e=>(0,v.diffCIECorr)(e,(0,y.closestLab)(t,e))))+(0,s.sum)(t,(t=>(0,v.diffCIECorr)(t,(0,y.closestLab)(e,t)))),r=Math.max(e.length,t.length,i);return(r-i)/r};const x=/A{20}=?$/;function C(e){return null!=e&&((0,g.within)(7,12,e.length)||null!=e?.match(x))}function F(e,t,i=E.HashDim){const r=(0,_.b64decode)(e).toString(2).split("").map((e=>"1"===e?1:0)),s=i*i;for(;r.length%s!=0;)r.unshift(0);return r.length===s||t?r.slice(0,s):r.slice(0,s).map(((e,t)=>4*e+2*r[t+s]+r[t+2*s]))}function A({a:e,b:t,greyscale:i,dim:r=E.HashDim,rotationsToCheck:a}){if((0,n.blank)(e)||(0,n.blank)(t))return{hammRatio:0,bRotation:0};if(e===t)return{hammRatio:1,bRotation:0};const o=F(e,i,r),l=F(t,i,r);(0,s.isEmpty)(a)&&(a=[0]);const u=a.map((e=>({bRotation:e,hammRatio:(0,c.sigFigs)((0,g.hammRatioIntArrays)(o,(0,S.rotateSquareMatrix)(l,e),i?1:3),2)})));D().debug("hammRatio()",{results:u,rotationsToCheck:a});const d=(0,m.greatestBy)(u,(e=>[(0,c.sigFigs)(e.hammRatio,1),-f.Rotations.indexOf(e.bRotation)]));return{bRotation:d.bRotation,hammRatio:(0,c.sigFigs)(d.hammRatio,2)}}async function I(e,t,i="debug",r={}){return D().tap({msg:`isSimilarImage(${e},${t})`,level:i,result:L(await(0,E.imageHash)(e),await(0,E.imageHash)(t),r)})}function O(e,t,i={}){const r=(0,E.toImageHash)(e),s=(0,E.toImageHash)(t);if(null==r||null==s)return;const n=(0,a.isTrue)(i.capturedAtIsFuzzy),h=!(0,a.isTrue)(i.forceColor)&&((0,a.isTrue)(i.forceGreyscale)||(r.isGreyscale??C(r.meanHash))||(s.isGreyscale??C(s.meanHash))),f=A({a:r.meanHash,b:s.meanHash,greyscale:h,rotationsToCheck:i.rotationsToCheck??(0,M.validRotations)(r,s)}),m=A({a:r.diffHash,b:s.diffHash,greyscale:h,rotationsToCheck:[]}),p=A({a:r.dctHash,b:s.dctHash,greyscale:h,rotationsToCheck:[]}),g=(0,w.dominantColorCorrelation)(r.dominantColors,s.dominantColors);if(null==g)return void D().debug("imageHashCompare(): missing color correlation");const y=r.mimetype===s.mimetype,v=(0,M.aspectRatio)(r),S=(0,M.aspectRatio)((0,o.maybeDimSwap)(s,f.bRotation)),P=null!=v&&null!=S&&!(0,o.isCloseAspectRatio)(v,S);let _=0,x=0;n&&(x+=T.Settings.imageHashFuzzyDateDelta.valueOrDefault,_+=T.Settings.imageHashFuzzyDateDelta.valueOrDefault),y||(x+=T.Settings.imageHashDifferentMimetypesDelta.valueOrDefault,_+=T.Settings.imageHashDifferentMimetypesDelta.valueOrDefault),h&&(_+=T.Settings.imageHashGreyscaleDelta.valueOrDefault,x+=T.Settings.imageHashGreyscaleDelta.valueOrDefault);const F=R((_+(i.minImageCorr??T.Settings.minImageCoeffPct.valueOrDefault))/100),I=R((x+(i.minColorCorr??T.Settings.minColorCoeffPct.valueOrDefault))/100),O=[];P&&O.push(`aspect ratio mismatch (${(0,k.fmtAspectRatio)(v)} vs ${(0,k.fmtAspectRatio)(S)})`);const L=[],N=new b.Average;N.push(f.hammRatio),f.hammRatioN.push(e))),(0,u.map)(p?.hammRatio,(e=>N.push(e))),(0,c.lt)(m?.hammRatio,F)&&L.push("gradient"),(0,c.lt)(p?.hammRatio,F)&&L.push("DCT")),L.length>0&&O.push("different image content ("+(0,l.andList)(L)+")");const j=g>=I,z=j&&N.avg>=F;j||O.push("different dominant colors");const V={meanHashCorr:(0,c.sigFigs)(f.hammRatio,2),diffHashCorr:B?void 0:(0,u.map)(m,(e=>(0,c.sigFigs)(e.hammRatio,2))),dctHashCorr:B?void 0:(0,u.map)(p,(e=>(0,c.sigFigs)(e.hammRatio,2))),hashCorrAvg:N.avg,minImageCorr:F,imageCoeffDelta:_,colorCorr:(0,c.sigFigs)(g,2),minColorCorr:I,colorCoeffDelta:x,isGreyscale:h,bRotation:f.bRotation,aAspectRatio:v,bAspectRatio:S,isSimilar:z,whyNotSimilar:z?void 0:(0,l.andList)(O)};return D().info("compareImageHashes",{a:(0,d.pickCompact)(r,"uri","id","assetId"),b:(0,d.pickCompact)(s,"uri","id","assetId"),...V}),{a:r,b:s,...V}}function L(e,t,i){return O(e,t,i)?.isSimilar??!1}function R(e){return(0,c.sigFigs)((0,c.clamp)(0,1,e),3)}function N(e){return null!=e&&(0,c.gte)(e.meanHashCorr,.9)&&(0,c.gte)(e.colorCorr,.9)}t.isGreyscaleMeanHash=C,t.meanHashVariants=function(e,t=!1,i=E.HashDim){const r=(t=t||null!=e.match(x))?(0,h.padding)("0",2*i*i):"",s=F(e,t,i);return f.Rotations.map((e=>(0,_.b64encode)(BigInt("0b0"+(0,S.rotateSquareMatrix)(s,e).map((e=>e.toString(2))).join("")+r))))},t.hammRatio=A,t.isSimilarImage=I,t.compareImageHashes=O,t.isVerySimilarImage=async function(e,t,i="debug",r={}){return I(e,t,i,{rotationsToCheck:[0],...r,minImageCorr:.92,minColorCorr:.92})},t.isSimilarImageHash=L,t.isVerySimilarImageHash=function(e,t,i={}){return N(O(e,t,i))},t.isVerySimilarComparison=N,t.imageHashSimilarity=function(e,t){return(0,u.map)(O(e,t),(e=>(0,P.avg)([e.meanHashCorr,e.colorCorr])))}},42725:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ImageSize=void 0;const a=i(57975),o=i(19851),l=i(33374),u=i(12168),c=i(48884),d=i(28874),h=i(32876),f=i(5733);class m{static sq(){return n(this,r,"f",s).filter((e=>e.reducer===h.Square))}static largestSq(){return(0,c.greatestBy)(this.sq(),(e=>e.megapixels()))}static fit(){const e=d.Settings.previewResolutions.valueOrDefault;return n(this,r,"f",s).filter((t=>t.reducer===h.Fit&&e.includes(t.name)))}static largestFit(){return(0,c.greatestBy)(this.fit(),(e=>e.megapixels()))}static all(){return[...n(this,r,"f",s)]}constructor(e,t,i,a,l=!0){this.name=e,this.maxWidth=t,this.maxHeight=i,this.reducer=a,this.rotational=l,this.megapixels=(0,o.lazy)((()=>(0,u.megapixels)(this.maxWidth*this.maxHeight))),this.max={width:t,height:i},n(r,r,"f",s).push(this)}[a.inspect.custom](){return{ctor:"ImageSize",name:this.name+" ("+this.reducer.name+")",maxDim:this.maxWidth+"×"+this.maxHeight,maxMP:this.megapixels()}}get aspectRatio(){return this.maxWidth/this.maxHeight}get maxPixels(){return this.maxWidth*this.maxHeight}get minDimension(){return Math.min(this.maxWidth,this.maxHeight)}outputSize(e){return this.reducer.reduce(this.rotational&&(0,l.isPortrait)(e)?(0,l.dimSwap)(this.max):this.max,e)}resize(e,t){return t.resize({...e,fit:this.reducer.fit,withoutEnlargement:!0})}toJpeg({path:e,sh:t,outputSize:i}){return((0,l.dmegapixels)(i)<2||d.Settings.previewSharpen.valueOrDefault)&&(t=t.sharpen()),t.jpeg((0,f.sharpRenderOptions)()).toFile(e)}toString(){return this.name}}t.ImageSize=m,r=m,s={value:[]},m.UHD8k=new r("uhd8k",7680,4320,h.Fit,!1),m.UHD5k=new r("uhd5k",5120,2880,h.Fit,!1),m.UHD=new r("uhd4k",4096,2160,h.Fit),m.QHD=new r("qhd",3120,1440,h.Fit),m.FHD=new r("fhd",1920,1080,h.Fit),m.HD=new r("hd",1280,720,h.Fit),m.WVGA=new r("wvga",720,480,h.Fit),m.QVGA=new r("qvga",320,240,h.Fit),m.QQVGA=new r("qqvga",160,120,h.Fit),m.S480=new r("s480",480,480,h.Square),m.S240=new r("s240",240,240,h.Square),m.S120=new r("s120",120,120,h.Square),m.S60=new r("s60",60,60,h.Square)},4192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includePreviewTags_=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(50213),o=i(56038),l=i(28874),u=i(47783),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.includePreviewTags")));t.includePreviewTags_=async function(e,t){!1===l.Settings.includePreviewTags.valueOrDefault||l.Settings.includedPreviewTags.isEmpty()||(0,s.isEmpty)(t)||(c().info("Re-adding metadata to previews..."),await(0,o.time)("img.includePreviewTags",(async()=>{const i=(0,n.pick)(await(0,u.readTags)(e),...l.Settings.includedPreviewTags.values),r=i?.capturedAt;null!=r&&(delete i.capturedAt,(0,n.assignFields)(i,r.asExifTag()));const s=i?.exposureSettings;null!=s&&(delete i.exposureSettings,i.FocalLength=s.focalLength,i.FNumber=s.aperture,i.ExposureTime=s.shutterSpeed,i.ISO=s.iso),l.Settings.includedPreviewTags.has("Source")&&(i.Source=e.nativePath),(0,n.isEmptyObj)(i)?c().warn("not adding tags to previews: no values for tags in source file",{src:e,includedPreviewTags:l.Settings.includedPreviewTags.values}):(c().info("Overwriting preview tags...",{src:e,writeTags:i}),await Promise.all(t.map((e=>(0,u.overwriteTags_)(e,i)))))})))}},66778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.matchAndWriteRotation_=t.matchRotation=void 0;const r=i(19851),s=i(68708),n=i(21605),a=i(50213),o=i(56038),l=i(47783),u=i(67083),c=i(95141),d=i(48368),h=i(80361),f=(0,r.lazy)((()=>(0,a.mkLogger)("img.MatchRotation")));async function m(e,t){return(0,o.time)("img.matchRotation",(async()=>{const i=await(0,d.imageHash)(e),r=await(0,d.imageHash)(t),s=(0,h.compareImageHashes)(i,r);if(null!=i&&null!=r&&null!=s)return f().tap({level:"info",msg:"matchRotation()",result:{rotation:s.bRotation,exemplarImageHash:i,destImageHash:r,imageHashComparison:s},meta:{src:e,dest:t}});f().warn("failed to compute image hashes",{a:e,b:t})}))}t.matchRotation=m,t.matchAndWriteRotation_=async function(e,t,i=0){const r=await m(e,t);if(null==r)return;const a=(0,n.normalizeRotation)(r.destImageHash.rotation+r.rotation+i);if(f().info("matchRotation() computed newRotation",{currentRotation:r.destImageHash.rotation,additionalRotation:i,rotationToMatch:r.rotation,newRotation:a}),null==a)return void f().warn("Can't compute final orientation",{newRotation:a,file:t.nativePath,r});const o=(0,c.rotationToWriteTag)(a);if((0,s.isEmptyObj)(o))return void f().warn("rotationToWriteTag() returned null",{newRotation:a,mimetype:r.destImageHash.mimetype,file:t.nativePath});const d=await(0,u.ensureHistoryRecords)(await t.sidecar(),(0,u.mkHistoryRecords)(u.Actions.set,o));return await(0,l.writeTags_)(t,o),f().tap({level:"info",msg:"matchAndWriteRotation_()",result:{...r,writtenTags:o,rotation:a,historyRecords:d},meta:{exemplar:e,dest:t}})}},78011:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.meanDiffHashCIELAB=t.meanDiffHash=t.dhash=t.mhash=void 0;const s=r(i(9288)),n=i(96249),a=i(59455),o=i(85810),l=i(70417),u=i(48368);function c(e){const t=(0,l.avg)(e);return null==t?[]:(0,a.toA)(e).map((e=>e>=t?1:0))}function d(e){const t=(0,a.toA)(e),i=Math.round(Math.sqrt(t.length));return t.map(((t,r)=>t>=(0===r?e[i]:r%i==0?e[r-i]:e[r-1])?1:0))}t.mhash=c,t.dhash=d,t.meanDiffHash=async function(e,t=u.HashDim){const i=await e.greyscale().resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer();return{meanHash:c(i),diffHash:d(i)}},t.meanDiffHashCIELAB=async function(e,t=u.HashDim){const i=await e.resize({fit:s.default.fit.fill,width:t,height:t}).raw().toBuffer(),r=(0,o.rgb2labArray)(i);return{meanHash:(0,n.flatten)(r.map(c)),diffHash:(0,n.flatten)(r.map(d))}}},52121:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._prepFileForBrowser=t.prepFileForBrowser=void 0;const r=i(19851),s=i(78923),n=i(95696),a=i(50213),o=i(28874),l=i(12089),u=i(16170),c=i(13940),d=i(4192),h=i(5733),f=i(50961),m=(0,r.lazy)((()=>(0,a.mkLogger)("img.PrepareFileForBrowser")));async function p(e){try{const t=n.PosixFile.for(e.nativePath);if(await t.notExists())return;const i=e.mimetype??(await(0,s.readFileType_)(t.nativePath))?.mime;return(0,u.isMimeTypeSupportedByBrowser)(i,e.userAgent)?t.nativePath:(m().info("prepFileForBrowser(): non-browser-supported mimetype",{file:t,info:e}),(await(0,c.withImageCache_)(t,"web",".jpg",(async e=>{const i=await(0,f.sharpReadable_)({src:t});if(null==i)throw new Error("prepFileForBrowser(): can't read "+t.nativePath);await(0,f.toSharp)(i).jpeg((0,h.sharpRenderOptions)()).toFile(e.nativePath),o.Settings.includePreviewTags.valueOrDefault&&await(0,d.includePreviewTags_)(t,[e])})))?.nativePath)}catch(e){return void m().warn("prepFileForBrowser() failed",{error:e})}}t.prepFileForBrowser=(0,l.shim1)({name:"img.prepFileForBrowser",impl:p}),t._prepFileForBrowser=p},48604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildAssetPreviews_=t.Previews=void 0;const r=i(19851),s=i(55835),n=i(50213),a=i(12089),o=i(87290),l=i(95242),u=i(16524);class c{constructor(e){this.root=e}apb(e,t,i){return new l.AssetPreviewBuilder(this.ap(e),t,i)}ap(e){return new u.AssetPreviews(this.root,e)}}t.Previews=c,c.instance=(0,r.lazy)((()=>((0,n.mkLogger)("Previews").info(".instance()",{libraryPreviewsDir:(0,o.libraryPreviewsDirPosixFile)()}),(0,s.map)((0,o.libraryPreviewsDirPosixFile)(),(e=>new c(e)))))),t.buildAssetPreviews_=(0,a.shim1)({name:"img.buildAssetPreviews",impl:e=>c.instance().apb(e.assetId,e.assetFiles,e).build_()})},2090:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const r=i(40958),s=i(33374),n=i(31586),a=i(34666),o=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,n.isNumber)(e)?e:((0,n.toGt0)(e.width)??0)/((0,n.toGt0)(e.height)??0),(e=>(0,o.leastBy)(t.StandardAspectRatios,(t=>{const r=Math.abs(e-t);return r>i?void 0:r}))??e))}function c(e,i,r=t.RatioEpsilon){return(0,a.lt)((0,n.absdiff)(u(e),u(i)),r)}function d(e,i){return(0,o.leastByCtx)(t.Ratios,(t=>{const r=Math.abs(t.i-e);return r[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,s.maybeDimSwap)(e.dimensions,e.rotation),(0,s.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,n.sigFigs)(e,3))}},34943:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const r=i(19851),s=i(31586),n=i(80049),a=i(50213),o=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),h=(0,r.lazy)((()=>(0,a.mkLogger)("img.RawInfo"))),f=(0,r.lazy)((()=>new n.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:o.ShortCommandTimeoutMs})));async function m(e){return f().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,r,n,a]=e.split("\t"),o=(0,s.toGt0)(n),l=(0,s.toGt0)(a);return null==o||null==l?h().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):h().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:r,ImageSize:{width:o,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>f.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?f.prior()?.clear():f.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{h().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},32876:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Reducers=t.Fit=t.fitInsideToMaxPixels=t.fitInsideToAspectRatio=t.Square=t.SharpFits=void 0;const r=i(19851),s=i(33374),n=i(4188),a=i(11371),o=i(31586),l=i(68708),u=i(50989),c=i(50213),d=i(86580);var h,f;t.SharpFits=(0,u.strEnum)("cover","contain","fill","inside","outside"),function(e){const i=(0,r.lazy)((()=>(0,c.mkLogger)("img.Reducers.Square")));e.name=a.ReducerNames.sq,e.fit="cover",e.reduce=function(e,r){const s=(0,d.lteBoth)(e,r)?{...e,fit:t.SharpFits.cover}:void 0;return i().tap({msg:"reduce()",result:s,meta:{max:e,input:(0,l.pick)(r,"width","height","nativePath")}})}}(h||(t.Square=h={})),t.fitInsideToAspectRatio=function(e,t){return e.width/e.height>=t?{width:Math.floor(e.height*t),height:e.height}:{width:e.width,height:Math.floor(e.width/t)}},t.fitInsideToMaxPixels=function(e,t){if(null==e||!(0,o.gt0)(e.width)||!(0,o.gt0)(e.height))return;if((0,s.pixels)(e)(0,c.mkLogger)("img.Reducers.Fit")));e.name=a.ReducerNames.fit,e.fit="inside",e.reduce=function(e,i){if(!(0,d.ltBoth)(i,e))return(0,n.fitInside)(i,e);t().trace(`reduce(): input ${(0,s.fmtDim)(i)} is too small for ${(0,s.fmtDim)(e)}`)}}(f||(t.Fit=f={})),t.Reducers=[h,f]},5733:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const s=r(i(9288)),n=i(19851),a=i(41400),o=i(50213),l=i(28874),u=i(15674),c=(0,n.lazy)((()=>(0,o.mkLogger)("img.Sharp")));function d(e,t){return(0,s.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,n.lazy)((()=>{s.default.simd(l.Settings.enableSIMD.valueOrDefault),s.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),s.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,a.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const r=i(50989);t.SharpFailOns=(0,r.strEnum)("none","truncated","error","warning")},50961:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractImageForThumbs_=t.sharpReadable_=t.toSharp=t.imgFromExif_=t._imgFromExif_=void 0;const s=i(77988),n=r(i(9288)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(33374),d=i(98553),h=i(31586),f=i(68708),m=i(51926),p=i(41583),g=i(50213),y=i(97352),v=i(56519),w=i(56038),b=i(57159),S=i(95696),P=i(17217),_=i(28874),T=i(47783),M=i(16170),E=i(95141),k=i(54979),D=i(1078),x=i(63870),C=i(86580),F=i(277),A=i(16047),I=i(13940),O=i(5733),L=i(66106),R=i(19350),N=(0,a.lazy)((()=>(0,g.mkLogger)("img.SharpReadable")));async function B(e,t,i){return i?await(0,T.exiftool)().extractBinaryTagToBuffer(t,e.nativePath):(await z(e,t))?.nativePath}async function j(e,t,i,r,a){const o=t?.[i];if(!(o instanceof s.BinaryField))return;const l=o.bytes<_.Settings.maxEmbeddedBuffer.valueOrDefault;try{const t=await B(e,i,l);if(null==t)return;const s=(0,n.default)(t,{failOn:_.Settings.imageFailOn.valueOrDefault}),o=await s.metadata(),u=(0,C.aspectRatio)(o);if(null!=a&&null!=u&&!(0,h.closeTo)(a,u,.2))return void N().info("imgFromExif("+e+", "+i+"): rejecting (aspect ratio mismatch)",{fileAspectRatio:a,renderedAspectRatio:u});const c=(0,C.lteBoth)(r,o);return N().debug("imgFromExif("+e+", "+i+")",{valid:c,minDim:r,useBuffer:l,fileAspectRatio:a,renderedAspectRatio:u,dim:(0,f.pick)(o,"width","height")}),c?{sharp:s,file:(0,m.isString)(t)?S.PosixFile.for(t):void 0}:void 0}catch(t){return void N().info("Failed to read image from EXIF tag "+i,{src:e,error:t})}}async function z(e,t){const i=t.toLowerCase().endsWith("tiff")?".tiff":".jpg";try{const r=await(0,I.tmpImageFile_)({src:e,tag:t,ext:i});return await r.applyIfEmpty_({retries:2,fn_:i=>(0,T.extractBinaryTag)(t,e.nativePath,i.nativePath),timeoutMs:(0,x.commandTimeoutMs)()})}catch(i){return void N().throw("Failed to extract embedded "+t+" from "+e.nativePath,{error:i})}}t._imgFromExif_=B,t.imgFromExif_=j,t.toSharp=function(e){const t=e;if((0,O.isSharp)(t.sharp))return t.sharp;if((0,P.isSimpleFile)(t.file))return(0,n.default)(t.file.nativePath,{failOn:_.Settings.imageFailOn.valueOrDefault});throw new Error("toSharp(): not a Sharp object: "+(0,d.stringify)(e))},t.sharpReadable_=function(e){return(0,w.time)(`img.sharpReadable${e.src.ext.toUpperCase()}`,(()=>async function({src:e,minDim:t,skipEmbedded:i}){const r=N().addParameterContext(e.nativePath);(0,O.setupSharp)();const n=await(0,k.readMimeType)(e);if((0,u.blank)(n))return r.throw(e+" is not supported (missing MIMEType)",{doNotSend:!0});const a=await(0,D.extractSizeInfoFromFile)(e);if(null==a)return void r.warn("Failed to extract size info from "+e);const d=[];function f(e,t){t.desc=e,d.push(t)}const m=a.rotation,g=(0,M.isVideoMimeType)(n),S=(0,M.isLibrawMimeType)(n),P=a.dimensions,x=t??(0,y.map2Gt0)(P.width,P.height,((e,t)=>({width:Math.round(.9*e),height:Math.round(.9*t)})));if(null==x?.width||null==x?.height)return r.throw(e+" is not supported (missing dimensions)",{dim:x,doNotSend:!0,mimetype:n,isRaw:S,isVideo:g});const I=(0,C.aspectRatio)(a.fileDimensions),B=(0,h.lt)(I,1),z=(0,M.isSharpMimeType)(n)&&null==t,V=(0,E.orientationRequiresMirroring)(a.orientation);if(!0===i||g||B||z||V)r.debug("not pulling previews from tags",{isVideo:g,isFilePortrait:B,isSharpMimeAndNoMinDim:z,isMirrorOrientation:V});else{const i=!1,n=await(0,T.readRawTags)(e,i);if(null==n)r.warn("Cannot pull previews from tags: readRawTags() failed");else{const i=[..._.Settings.embeddedPreviews.values];null!=t&&(0,c.dmegapixels)(t)<1&&i.unshift(..._.Settings.embeddedThumbnails.values);const a=x.width*x.height*.2,u=x.width*x.height*.05,d=(0,l.sortBy)(i.filter((e=>n[e]instanceof s.BinaryField)),(e=>{const t=n[e]?.bytes;return(0,h.gt)(t,u)?Math.abs(t-a):void 0}));if(!(0,o.isEmpty)(d)){r.debug("checking previews from tags",{sizeSortedTagNames:d});for(const t of d)f("imgFromExif."+t,(()=>j(e,n,t,x,I)))}}}(0,M.isSharpMimeType)(n)&&f("sharp",(async()=>({file:e}))),(0,A.isHeifMimeType)(n)&&await(0,F.isHeifSupported)()&&f("heif",(()=>(0,v.thenMap)((0,F.heif2img)(e),(e=>({file:e}))))),S&&f("raw2tiff",(()=>(0,v.thenMap)((0,R.raw2tiff_)(e),(e=>({file:e}))))),g&&f("extractVideoFrame",(async()=>{if(await(0,L.isVideoSupported)())try{return await(0,v.thenMap)((0,L.extractVideoFrame_)(e),(e=>({file:e})))}catch(t){throw new b.WrappedError("Failed to extract video frame for "+e,t)}else r.warn("video file, but video support is missing",{src:e.nativePath,mimetype:n,minDim:t})}));const W=[];for(const i of d)try{const s=await(0,w.time)("img.read."+i.desc,i);if(null!=s)return r.debug(i.desc+" strategy succeeded",{src:e,minDim:t,rot:m,img:s.file?.nativePath}),{desc:i.desc,rot:m,mimetype:n,...s};r.debug(i.desc+" returned null",{src:e,minDim:t,rot:m})}catch(e){r.warn(i.desc+" failed",e),W.push((0,p.toErr)(e))}throw new b.WrappedError("Failed to render "+e,{causes:W,path:String(e),fatal:!1,doNotSend:!0,retriable:!1})}(e)))},t.extractImageForThumbs_=z},21473:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.testSharp_=void 0;const s=r(i(34589)),n=i(76760),a=r(i(9288)),o=i(50357),l=i(98553),u=i(68708),c=i(23560),d=i(43899),h=i(28874),f=i(5733);t.testSharp_=async function e(t){try{(0,f.setupSharp)();const e=t??(0,n.join)(d.ProjectPath.Public(),"images","logo@5x.png"),i=(0,a.default)(e,{failOn:"error"}),r=await i.resize(24,32,{fit:"cover",position:"attention"}).toFormat("jpeg").toBuffer({resolveWithObject:!0});(0,s.default)((0,o.eql)((0,u.pick)(r.info,"format","width","height","channels"),{format:"jpeg",width:24,height:32,channels:3}),"Unexpected sharp output: "+(0,l.stringify)(r.info))}catch(i){if(!(0,c.isWorkerService)()&&h.Settings.enableSIMD.valueOrDefault)return h.Settings.enableSIMD.envValue=!1,e(t);throw i}}},181:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.whyInvalidFile=t.clearInvalidFileCache=t.throwIfInvalidFile_=t.isValidFile=void 0;const s=r(i(9288)),n=i(19851),a=i(22573),o=i(42659),l=i(98553),u=i(50213),c=i(12089),d=i(81168),h=i(57159),f=i(88561),m=i(95696),p=i(17217),g=i(28874),y=i(16170),v=i(54979),w=i(63870),b=i(5733),S=i(50961),P=i(66106),_=i(51210),T=(0,n.lazy)((()=>(0,u.mkLogger)("img.ValidFile")));t.isValidFile=async function(e){return(0,a.blank)(await(0,t.whyInvalidFile)((0,p.toNativePath_)(e)))},t.throwIfInvalidFile_=async function(e){if(!g.Settings.validateJpegImages.valueOrDefault&&!g.Settings.validateRawImages.valueOrDefault&&!g.Settings.validateVideos.valueOrDefault)return void T().debug("file validation is disabled for "+e,{validateJpegImages:g.Settings.validateJpegImages.valueOrDefault,validateRawImages:g.Settings.validateRawImages.valueOrDefault,validateVideos:g.Settings.validateVideos.valueOrDefault});const i=(0,p.toNativePath_)(e),r=T().tap({msg:"whyInvalidFile("+i+")",result:await(0,t.whyInvalidFile)(i)});(0,a.notBlank)(r)&&T().throw(r,{path:i,retriable:!1,doNotSend:!0,ignorable:!0})};const M=(0,n.lazy)((()=>new f.FileCache({name:"img.validFile",maxSize:256,timeoutMs:Math.max(o.minuteMs,g.Settings.validateVideos.valueOrDefault?5*o.minuteMs:(0,w.commandTimeoutMs)())})));t.clearInvalidFileCache=function(){return M().clear()},t.whyInvalidFile=(0,c.shim1)({name:"img.whyInvalidFile",cache:M,toKey:p.toNativePath_,impl:async e=>{const t=m.PosixFile.for(e);if(!await t.isFile()||!await t.isReadable())return t+" is not a readable file";if(await t.isEmpty())return t+" is empty";try{const e=await(0,v.readMimeType)(t);if(null==e)throw new Error("Cannot validate, no mimetype");if((0,y.isVideoMimeType)(e))g.Settings.validateVideos.valueOrDefault&&(T().debug("validating "+t),await(0,P.validVideo_)(t));else{if(!e.startsWith("image/"))throw new Error("Unsupported mimetype "+(0,l.stringify)(e));if("image/jpeg"===e)g.Settings.validateJpegImages.valueOrDefault&&await(0,_.validJpeg_)(t);else if(g.Settings.validateRawImages.valueOrDefault)if((0,d.includesIgnoreCase)(g.Settings.validateMimetypeSkiplist.values,e))T().info("Skipping validation of "+t+": validateMimetypeSkiplist matches",{mime:e});else{const e=await(0,S.sharpReadable_)({src:t,skipEmbedded:!0}),i=await async function(e,t=g.Settings.imageFailOn.valueOrDefault){const i=e;if((0,p.isSimpleFile)(i.file))return(0,s.default)(i.file.nativePath,{failOn:t});if((0,b.isSharp)(i.sharp)){const{data:e,info:t}=await i.sharp.raw().toBuffer({resolveWithObject:!0});return(0,s.default)(e,{...t,failOnError:!0})}throw new Error("Cannot read input "+e?.desc)}(e);await i.tiff().toBuffer()}}return""}catch(t){return new h.WrappedError("Failed to validate",{cause:t,path:e,doNotSend:!0}).toS()}}})},19769:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const r=i(19851),s=i(40958),n=i(41400),a=i(50213),o=i(68852),l=i(98314),u=i(28874),c=(0,r.lazy)((()=>(0,a.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:h().test(t)||!d().test(t),meta:{err:e,allow:h().test(t),block:d().test(t),validationErrorAllowlist:h().source,validationErrorBlocklist:d().source}})};const d=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),h=(0,r.lazy)((()=>(0,o.orRegExpPatterns)((0,s.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,n.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>h.unset()))}))},66106:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const r=i(19851),s=i(40958),n=i(38639),a=i(42659),o=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),h=i(7282),f=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),v=i(56038),w=i(31562),b=i(34102),S=i(88561),P=i(95696),_=i(17217),T=i(31843),M=i(70417),E=i(33847),k=i(28874),D=i(94678),x=i(43207),C=i(47783),F=i(16170),A=i(95141),I=i(1078),O=i(63870),L=i(89782),R=i(13940),N=i(34592),B=(0,r.lazy)((()=>(0,d.mkLogger)("img.Video")));function j(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function z(e){return(0,h.isProd)()&&(e=void 0),(0,n.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=z,t.isVideoSupported=(0,r.lazy)((async()=>{try{return!0===(await z())?.isSupportedVersion}catch(e){return B().warn("isVideoSupported",{error:e}),!1}})),(0,o.later)((()=>(0,b.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,T.lerp2d)(e,{x:76800,y:k.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:k.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,r.lazy)((()=>new S.FileCache({name:"img.videoFrame",timeoutMs:a.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,_.toNativePath_)(e))):void 0}async function U(e,t){const i=j("extractVideoFrame",e),r=P.PosixFile.for(e);if(!(0,n.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const s=await(0,R.cachedImageFile_)(r,"frame",".jpg");i.debug("extractVideoFrame("+s+")");const o=await r.mtimeMs();if(null==o)return i.throw("null mtime");const l=await(0,C.readRawTags)(r,!1);if(null==l)return i.throw("no tags");const u=(0,A.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,I.extractSizeInfoFromTags)(l,u)?.dimensions,d=await s.stat(),h=null==d?void 0:await(0,L.dimensions)(s);if(null!=d&&d.mtimeMs>o&&null!=h&&(null==c||h.height===c.height&&h.width===c.width))return i.debug("prior dest, "+s+" seems reasonable",{srcDim:c,destDim:h}),s.nativePath;const f=(0,x.extractDurationSec)(l),m=Math.min(f??0,k.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:f}),await s.applyIfEmpty_({fn_:async e=>{const t={src:r,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,w.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*a.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,C.deleteAllTags_)(e,e)},timeoutMs:(0,O.commandTimeoutMs)()}),s.nativePath}async function q(){return k.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function H(e){const t=j("needsTranscoding",e);if(!await q())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,C.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const r=i.MIMEType;if(!(0,F.isVideoMimeType)(r))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:r}});const n=(0,x.extractDurationSec)(i);if(!(0,c.gt)(n,k.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:n}});const a=(0,s.compactBlanks)([i.AudioFormat]),o=a.some((e=>(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,s.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(k.Settings.doNotTranscodeMimeTypes.values,r);return t.tap({level:"info",msg:"result",result:!(o&&u&&d),meta:{mimetype:r,isSafeMimeType:d,audioCodecs:a,isSafeAudioCodec:o,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>U(e)}),t.__extractVideoFrame_=U,t.isVideoTranscodingSupported=q,t.needsTranscoding=H;const $=new g.TTLMap(a.hourMs);function G(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,r){if(!await q())return;const s=j("transcode",e);{!function(){for(const[e,t]of $.entries())t.isSettled&&$.delete(e)}();const t=$.get(e.nativePath)??$.get(i.nativePath);if(null!=t)return s.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await H(e))return void s.info("no transcoding needed");const n=await e.size();if(!(0,u.gt0)(n))return s.throw("source is empty or cannot read");const a=await(0,C.readTags)(e),o=(0,I.extractSizeInfoFromTags)(a),d=(0,x.extractDurationSec)(a);if(null==a||null==o||null==d)return s.throw("failed: missing video metadata",{sizeInfo:o,durationSec:d});{const e=$.get(i.nativePath);if(null!=e)return s.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const h=new y.Deferred("transcode "+e);$.set(e.nativePath,h),$.set(i.nativePath,h);const m=(0,u.toGt0)(a.VideoFrameRate)??(0,u.toGt0)(a.FrameRate)??30,p=Math.round(o.dimensions.width*o.dimensions.height*(0,M.max)([(0,u.toGt0)(a.FrameCount),(0,u.toGt0)(a.VideoFrameCount),m*d]));if(!0===r?.force)await i.unlink();else if(await async function(e,t){const i=await(0,C.readRawTags)(t),r=await(0,C.readRawTags)(e),s=(0,x.extractDurationSec)(r),n=(0,x.extractDurationSec)(i);return B().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(s,n,1.5),meta:{srcDurationSec:s,destDurationSec:n,src:e.nativePath,dest:t.nativePath}})}(e,i))return s.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const r=j("extractMaxBitrate",e),s=k.Settings.minVideoDimension.valueOrDefault,n=i.ImageWidth;if(null!=n&&!(0,u.gte)(n,s))return r.throw("invalid width: "+n,{ignorable:!0});const a=i.ImageHeight;if(null!=a&&!(0,u.gte)(a,s))return r.throw("invalid height: "+a,{ignorable:!0});const o=(0,D.extractBitrateKbps)(i)??k.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,f.mapGt0)(n,(e=>(0,f.mapGt0)(a,(i=>(0,u.clamp)(0,o,(0,t.bitrateKps)(e*i)))))),c={width:n,height:a,videoBitrateKbps:l};return r.debug("dim()",{src:e,result:c}),c}(e,a);return await h.observe((0,v.time)("video.transcode:"+e,(async()=>{const t=G(n,g.videoBitrateKbps,d);return await i.applyWip_({fn_:n=>async function(n){s.info("starting...",{destWip:n});const o=new E.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:n,fps:m,halt:r.halt,...g},h=k.Settings.transcodeMaxDim.valueOrDefault,f=(0,M.max)([a.dimensions.height,a.dimensions.width]);if((0,u.gt0)(h)&&(0,c.gt)(f,h)){const e=(0,l.fitInside)(a.dimensions,{width:h,height:h});null==e?s.warn("Cannot downsample transcoded video: fitInside() returned null",{input:a.dimensions,maxPixels:h}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),s.info("Downsampling transcoded video",{original:a.dimensions,output:e}))}const p=await o.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&s.throw("transcode failed with code "+p.code)}(n),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&s.info("transcode complete",{src:e,dest:i,elapsedMs:h.elapsedMs,pixels:p}),i},t.guessExpectedSize=G,t.validVideo_=async function(e){return null==await W(e)&&j("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),h=i(56519),f=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),v=i(84258),w=i(28874),b=i(76280),S=i(63870),P=i(19769),_=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function T(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:w.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=T;const M=/ffmpeg version n?(?\S+)/i,E=(0,u.lazy)((async()=>{const e=await T();if(null==e)return void _().info("failed to find ffmpeg in $PATH",{ffmpegPath:w.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,S.commandTimeoutMs)(),ignoreStderr:!0}),i=M.exec(t.result)?.[1];return _().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,b.semverSatisfies)(i,">=3.2")}}));function k(){E.unset(),t.ffmpegVersionDescription.unset()}function D(e){const t=e?.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault;return(0,s.blank)(t)||(0,n.isDisabled)(t)?[]:["-hwaccel",t]}function x(e){const t=[...w.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(w.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),r=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+r),t}function C(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function F(e){const t=w.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,h.thenMapOr)(E(),(e=>"version "+e),(()=>"(not found)")))),(0,o.later)((()=>{(0,g.ee)().on("clearCache",k),(0,g.ee)().on("clearToolCache",k)})),t.ffmpegVersion_=async function(){return await E.prior()??E.refresh()},t.isFFmpegSupported=async function(){return null!=await E()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await T(),(0,r.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:a.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,f.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*a.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=x,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await T(),(0,r.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...x(t),...F(t),...D(t),"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...C(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){_().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,v.unlink)(t.dest,"debug");const r=(0,p.errorToS)(i,{maxLen:1024});if(!(0,n.isDisabled)(t.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(r))return _().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return _().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await T(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},51210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotate_=t.rotateInPlace_=t.validJpeg_=t.jpegtranVersion_=void 0;const r=i(19851),s=i(42659),n=i(21605),a=i(50213),o=i(84777),l=i(57159),u=i(95696),c=i(89966),d=i(43334),h=i(63870),f=i(19769),m=d.isWin?"NUL":"/dev/null",p=(0,r.lazy)((()=>(0,a.mkLogger)("img.jpegtran")));async function g(e,t,i){const r=await(0,c.jpegtranNativePath_)();if(!(0,n.isRotation)(i))throw new Error("refusing to rotate("+e+", "+i+")");await(0,o.stdout_)(r,["-copy","all","-trim","-rotate",i.toFixed(0),"-outfile",t.nativePath,e.nativePath],{timeoutMs:s.minuteMs}),t.clear()}t.jpegtranVersion_=async function(){const e=await(0,o.stdoutResult_)(await(0,c.jpegtranNativePath_)(),["-version"],{quiet:!0,timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:()=>!0});return(e.stderr??e.result).replace(/^libjpeg-turbo version/,"").trim()},t.validJpeg_=async function(e){const t=u.PosixFile.for(e),i=await(0,c.jpegtranNativePath_)();try{await(0,o.stdoutResult_)(i,["-outfile",m,t.nativePath],{timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:f.isIgnorableValidationError,ignoreExitCode:!0})}catch(e){throw p().warn("validJpeg caught invalid file",{src:t,cause:e}),new l.WrappedError("Invalid JPEG: "+t,{cause:e,path:t.nativePath,doNotSend:!0,fatal:!1,retriable:!1})}},t.rotateInPlace_=async function(e,t){p().info("rotateInPlace("+e+")",t),await e.applyWip_({fn_:i=>g(e,i,t),skipFsLock:!1,minSizeBytes:512,timeoutMs:s.minuteMs})},t.rotate_=g},19350:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dcraw_emu_=t.raw2tiff_=t.librawSupported=void 0;const r=i(19851),s=i(40958),n=i(33374),a=i(12168),o=i(23541),l=i(54993),u=i(50213),c=i(84777),d=i(98314),h=i(38835),f=i(57159),m=i(89966),p=i(28874),g=i(16170),y=i(54979),v=i(89782),w=i(13940),b=i(42725),S=i(19769),P=(0,r.lazy)((()=>(0,u.mkLogger)("img.libraw")));t.librawSupported=async function(e){try{return(0,g.isLibrawMimeType)(await(0,y.readMimeType)(e.nativePath))}catch(t){return P().warn("librawSupported("+e+"): failed to read filetype",t),!1}},t.raw2tiff_=async function(e){return(0,w.readableToFile_)({src:e,desc:"dcraw",suffix:".tiff",f:t=>k(e,t)})};const _=["-T"],T=["-Z","-"],M=["-o","1"],E=["-t","0","-j"];async function k(e,t){const i=await(0,v.dimensions)(e);if(null==i)return P().throw("Cannot decode RAW "+e+": no EXIF dimensions."+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);const r=b.ImageSize.largestFit().outputSize(i),u=[];null!=r&&4*(0,n.dmegapixels)(r)<(0,n.dmegapixels)(i)&&(P().debug("Large original source: using -h"),u.push("-h"));const g=await(0,m.dcrawEmuNativePath_)(),y=[..._,...T,...M,...u,...E,...p.Settings.dcrawEmuArgs.values,e.nativePath],w={encoding:"buffer",timeout:p.Settings.taskTimeoutMs.valueOrDefault,maxBuffer:250*a.MB};P().debug("dcraw_emu()",{cmd:g,args:y,opts:w});const k=(0,c.execFile)(g,y,void 0,w),D=[];function x(t){const i=(0,o.isError)(t)?(0,d.errorToS)(t):(0,l.toS)(t);if((0,S.isIgnorableValidationError)(i))P().info("dcraw_emu(): warning",{src:e,msg:i});else{P().warn("dcraw_emu(): error",{src:e,msg:i});const r=(0,o.isError)(t)?t:(0,f.toWrappedError)(i,{fatal:!1});D.push(r)}}if(k.on("error",x),k.stderr.on("data",x),await t.writeStream_(k.stdout),(0,s.isNotEmpty)(D))throw new f.WrappedError("Failed to convert RAW image "+e,{causes:D,path:e.nativePath});(0,c.endProcess)(k)}t.dcraw_emu_=k},36192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const r=i(19851),s=i(84777),n=i(8103),a=i(43334),o=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,r.lazy)((async()=>a.isMac?(0,n.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,s.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(o.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},45657:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.r=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(45599),l=i(98553),u=i(55835),c=i(34666),d=i(50213),h=i(37628),f=i(37805),m=i(46292),p=i(95696),g=i(93756),y=i(28874),v=i(63870),w=i(71706),b=i(81674),S=i(33603),P=i(70114),_=(0,o.defer)((()=>(0,d.mkLogger)(T().l))),T=(0,r.rolazy)((()=>(0,w.j)("G8oAKIzTFfOihHWPgG6m/h0h65IqCWu72UHSOixdfW12GgbIbSdJW2sLEmvLsqcHfOPXk00SqojDRomicXUE+MuLfPaoTzFWZPq8AdmWyQVUWERkBLoYBhqafaAvY27+LDra0blcQ4Vnjn/ukQh/C4o0cd0B")));async function M(e){const t=await(0,S.sids)({timeoutMs:(0,v.commandTimeoutMs)()});if((0,s.isEmpty)(t))return _().warn("no-op: empty sids");const i=(0,l.stringify)({uids:[...t,e],coupon:y.Settings.coupon.valueOrDefault,version:f.version}),r={...T().r,body:i},n=await(0,g.request)(T().u,r);_().info(T().u,{req:r,response:n}),n.ok?await(0,P.writeLicense)(JSON.parse(n.body)?.[T().a],(0,v.commandTimeoutMs)()):_().warn(T().u,{req:r,response:n})}t.r=(0,r.rolazy)((async()=>{const e=T().s+": ";try{if(!y.Settings[T().s].valueOrDefault)return _().debug(e+"no-op (settings disabled)");const t=(await(0,b.m)()).filter((e=>null!=e.l&&(0,n.notBlank)(e.s))),i=new Date,r=t.find((e=>e.ok&&(0,c.gt)(i,e.l?.exp)));if(null!=r)return _().debug(e+"no-op: ",{current:r});const s=await(0,u.map)((0,m.configDir)(),(e=>p.PosixFile.for(e).join(T().s+"-v"+f.version).mkdirp_()));for(const r of t){if((0,n.blank)(r.s)||null==r.l||ie.startsWith("cu:")));if(null!=t){if(await(s?.join((0,h.shortFsStringSha)(r.s,14)+".txt").applyIfEmpty_({fn_:async i=>{await M(t),await i.writeJson_({l:r.l,at:Date.now()}),_().warn(e+"requested",r)},timeoutMs:(0,v.commandTimeoutMs)()})),await(0,b.p)())break}else _().debug(e+"skipping (no cu)",r)}}catch(t){_().warn(e+"failed",t)}}),15*a.minuteMs)},71706:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.j=void 0;const r=i(38522);t.j=function(e){return JSON.parse((0,r.brotliDecompressSync)(Buffer.from(e,"base64")).toString("utf8"))}},42042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEmail=void 0;const r=i(22573),s=i(28874),n=i(81674);t.getEmail=async function(){const e=s.Settings.email.value;if((0,r.notBlank)(e))return e;for(const e of await(0,n.m)())if((0,r.notBlank)(e.l?.sub))return e.l?.sub}},83950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.L=void 0;const r=i(79114),s=i(40958),n=i(42659),a=i(34666),o=i(48884),l=i(97352),u=i(81674),c=i(84194);t.L=class{static for(e){return new this(e.str,e.l,e.sids,e.src)}constructor(e,t,i,r){this.s=e,this._l=t,this._sids=i,this.meta={src:r}}get l(){return this._l}get ok(){if(null==this._l)return!1;const e=(0,o.intersection)(this._sids,this._l.uids),t=(0,s.uniq)(e.map(c.getScheme)),i=(0,s.compact)(t.map((e=>(0,c.prefix2scheme)(e)))),r=i.length>=this._l.mat,a=(0,l.within)(this._l.iat?.getTime(),this._l.exp?.getTime()+n.dayMs,Date.now());return this.meta[(0,u.k)().o]=a,this.meta[(0,u.k)().u]=r,this.meta[(0,u.k)().m]=i,a&&r}cmpVal(){return[this.ok,-(r.S.indexOf(this.l?.[(0,u.k)().T])??0),this.l?.exp?.getTime()??1,this.meta.matchedSchemes]}cmp(e){return(0,a.cmp)(this.cmpVal(),e.cmpVal())}}},81674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p=t.l=t.t=t.b=t.m=t.vok=t.v=t.v_=t.k=void 0;const r=i(76790),s=i(22573),n=i(38639),a=i(45599),o=i(41400),l=i(96249),u=i(55835),c=i(31586),d=i(51926),h=i(79114),f=i(23541),m=i(59455),p=i(54993),g=i(72993),y=i(19851),v=i(50213),w=i(56519),b=i(76596),S=i(46292),P=i(87290),_=i(77740),T=i(34102),M=i(83278),E=i(28874),k=i(37692),D=i(71706),x=i(83950),C=i(72042),F=i(33603),A=i(48132);t.k=(0,y.rolazy)((()=>(0,D.j)("G1UBABwHdkz4hUIkFCfPXW5LlfvrWKSr9W3AIyIhUiw68NDfvLLHVop/bGoNnRxQlnqi2TZp0IJaX+lUHBoi+vMy2LMNpHCv8xVkUGsmQsgB8ldHoDqJeUQzbdybwikWVRs2KSWKjE5LnuqhTNSp3gTLhNfE9EqBLeaXP+UM9YqTGSXcyrcL03rIPMDAVyJplSZC0xoUgguOYJKvrcYFbNArN7BrQsnnsJ4hMtcSxOTxxRdxzETtL93qa3vjDw==")));const I=(0,a.defer)((()=>(0,v.mkLogger)((0,t.k)().l)));async function O(e){const i=await(0,C.V)((0,d.ensurePrefix)((0,p.toS)(e).trim(),(0,t.k)().p)),r=(0,b.utcIsoToTs)(i[(0,t.k)().i]);if(null==r)throw new Error("bad "+(0,t.k)().i+": "+i[(0,t.k)().i]+" ("+e+")");const s=(0,b.utcIsoToTs)(i[(0,t.k)().r]);if(null==s)throw new Error("bad "+(0,t.k)().r+": "+i[(0,t.k)().r]+" ("+e+")");return(0,_.getDevEnvFlag)((0,t.k)().y)&&(i[(0,t.k)().t]=!0),i[(0,t.k)().a]=(0,c.toGte0)(i[(0,t.k)().a])??2,i[(0,t.k)().i]=new Date(r),i[(0,t.k)().r]=new Date(s),i[(0,t.k)().b]=(0,p.toS)(i.uids).split(","),i}async function L(e,i,r,n){try{return(0,s.blank)(e)||e===(0,t.k)().f?void 0:x.L.for({str:e,l:await O(e),sids:null!=n?n:await(0,F.sids)({timeoutMs:r}),src:i})}catch(i){return I().tap({msg:(0,t.k)().v,result:{s:e,ok:!1,meta:{err:i}}})}}async function R(e,t){const i=[],r=await(0,w.sortByAsync)({name:"rawLicenseFromDir("+e+")",arr:e?.childFiles(),f:e=>e.mtimeMs()});for(const e of r.reverse()){const r=await L((0,m.toA)(await e.readLines()).map((e=>e.trim())).join(""),e.nativePath,A.UserTimeoutMs,t);null!=r&&i.push(r)}return i}async function N(){const e=await(0,t.m)();return e[0]?.ok?e[0]:void 0}async function B(){return(await N())?.l?.[(0,t.k)().T]??(0,t.k)().f}t.v_=O,t.v=L,t.vok=async function(e,t,i){if((0,s.blank)(e))return;const r=await L(e,t,i);return(0,n.isTrue)(r?.ok)&&r instanceof x.L?r:void 0},t.m=(0,y.rolazy)((async()=>{if((0,_.getDevEnvFlag)((0,t.k)().x))return[];const e=await(0,F.sids)({timeoutMs:A.UserTimeoutMs}),i=(0,u.map)((0,S.configDir)(),(e=>M.BaseFile.for(e))),s=(n=(0,l.flatten)((await(0,w.someOrTimeout)([()=>function(e){return L(E.Settings[(0,t.k)().L].value,"Settings",A.UserTimeoutMs,e)}(e),()=>R(i?.join((0,t.k)().d),e),()=>R((0,P.libraryDataDirPosixFile)()?.join((0,t.k)().d),e),()=>R(i?.sibling((0,g.AppName)().toLowerCase()).join((0,t.k)().d),e)],{timeoutMs:A.UserTimeoutMs})).filter((e=>!(e instanceof Error)))),(0,r.sortBy)(n.filter((e=>null!=e&&((0,f.isError)(e)&&I().warn((0,t.k)().d+": ",e),null!=e&&!(0,f.isError)(e)&&null!=e?.l))),(e=>[!e.ok,h.S.indexOf(e.l?.[(0,t.k)().T])??h.S.length+1,-(e.l?.exp?.getTime()??1)])));var n;return I().tap({msg:(0,t.k)().d+"()",result:s})})),(0,o.later)((()=>{(0,T.ee)().on("clearCache",(()=>t.m.unset())),(0,T.ee)().on((0,t.k)().c,(()=>t.m.unset())),k.stateEvents.on((0,t.k)().c,(()=>t.m.unset()))})),t.b=N,t.t=B,t.l=async function(){try{return await B()===(0,t.k)().f}catch{return!0}},t.p=async function(){try{return await B()===(0,t.k)().g}catch{return!1}}},72042:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.V=t.l=void 0;const r=i(91227),s=i(19851),n=i(22573),a=i(71706);t.l=(0,s.lazy)((()=>(0,a.j)("G54BgBwHzrkukKDR8Ar6KkW29gbXlfrqQX46gTu5Wfq6dELYTjfBokB0d5+E2SAINBtxlmPquWe3PMUoNgaJrD982QMslkNeZ4BEqcBbQT59DVl9RnoTNi50diuT7NQg0YHxkr8SwDwtmFUOf+LwNVDDnPXUrzTOU++M3b+lcyfr7PXZndKHzho8iztNkZgt+/19//aXe+gvmC0HIdnn64wdLeYeLM7S9jmjTp52SzFsvIVbd4D0+rdtdjiz6R4vc2cmY398kuXiKG7fNXWS/I93etxXiVNPd4RXJF+k6JnuMUKk03GWHQQ="))),t.V=function(e){const i=(0,r.decode)(e).payload;if(null==i)throw new Error("Missing payload");const s=(0,n.notBlankOr)(i.k,(0,t.l)().d),a=(0,t.l)().o.find((e=>e.k===s));if(null==a)throw new Error("Unknown key");return r.V2.verify(e,a)}},84194:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SchemeCounts=t.isValidUid=t.toUID=t.UidLength=t.prefix2scheme=t.sortUids=t.getScheme=t.S=void 0;const n=i(40958),a=i(76790),o=i(22573),l=i(45599),u=i(50989),c=i(54993),d=i(22454),h=i(19851),f=i(50213),m=i(37628),p=i(55222),g=i(71706),y=(0,l.defer)((()=>(0,g.j)("GyABAIzUYs0Z7mSuLfVL1SwGefr+3nCwyXBMg6nD0qduA8HycFjUGK1N/ikYqhiqYLGbs7oxTBbzRPxteP9gA3L9DS0EJ2BJ1pYNa/DtEE2aPI2o03hHx3k9MhdE7jAeRUvKQ6tY3Q1fcIPe8GBMZvOeKibTymyo3Cw/7Ua42DKPjpL3wxWv+7TCGA==")));function v(e){const i=e.split(":",1)[0];return t.S.has(i)?i:void 0}t.S=(0,u.strEnum)("cu","lc","lm","lp","lb","mp","ms","wm","cm","bm","nm","li","si","vl"),t.getScheme=v,t.sortUids=function(e){return(0,a.sortBy)((0,n.uniq)(e.filter(S)),(e=>[t.S.indexOf(v(e))??t.S.length+1,e]))},t.prefix2scheme=function(e){return y()[e]};const w=["uninitialized","b08dfa6083e7567a1921a715000001fb"];t.UidLength=15,t.toUID=function(e,i){try{const r=(0,c.toS)(i).replace(/[^a-z\d=/+]+/gi,"");return(0,o.blank)(r)||w.includes(r.toLowerCase())||null!=r.match(/^[\s0:_/-]*$/)?void 0:e+":"+(0,m.shortStringSha)(r,t.UidLength,p.Radix58)}catch(t){return void(0,f.mkLogger)("toUID").warn("failed",{pfx:e,err:t})}};const b=(0,l.defer)((()=>new RegExp(`^(?:${t.S.values.join("|")}):[0-9a-zA-Z]{${t.UidLength}}$`)));function S(e){return null!=e&&null!=b().exec(e)}t.isValidUid=S,t.SchemeCounts=class{constructor(e){r.set(this,new Set),this.schemeCounts=(0,h.lazy)((()=>{const e=new d.CountingSet;for(const t of s(this,r,"f")){const i=v(t);null!=i&&e.incr(i)}return e})),null!=e&&this.addUids(e)}get size(){return s(this,r,"f").size}addUids(e){for(const t of e)null==v(t)||s(this,r,"f").has(t)||(s(this,r,"f").add(t),this.schemeCounts.unset())}count(e){return this.schemeCounts().get(e)}},r=new WeakMap},33603:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearSids=t.addSids=t.sids=t.win_machineGuid_=t.readInfo=t.k=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(45599),o=i(96249),l=i(68708),u=i(51926),c=i(59455),d=i(54993),h=i(50213),f=i(7282),m=i(56519),p=i(84777),g=i(84542),y=i(19254),v=i(45879),w=i(70854),b=i(57902),S=i(72308),P=i(43334),_=i(24399),T=i(7014),M=i(30933),E=i(71706),k=i(84194);t.k=(0,a.defer)((()=>(0,E.j)("G9ABYIzDOIZ8NLQ4t7qW8tNrmrOzz+qFGfAxl8jW4E2tLxwWRZT5TueCnPcwgTzT1DN3veRB+e7EYGlYHg6nhjBDQv7zI6EcYWk35z6QuZC3Q0itjrLCbmgd0iED0BvGiYLBJwRU1O9/3Agbl8IfG6ITVFWDRwyTw3rbUMo/XMyAVW7R23mkwUx0l4/7iA13RV/nmPuJFKp5BvJW7SoXJZoWEfdSNYYhN5UCtkbC7O1AaPIbU3P6uRLmEyb4TaHWzFigvrlmZVUzzp9j/Mz55vqN88ewd1Nrfh7gkVRQ7TtB7Ztz3XJxYC3ogdJHg8HGsG4=")));const D=(0,a.defer)((()=>(0,h.mkLogger)((0,t.k)().n)));async function x(e=(0,t.k)().pc){if(P.isLinux)try{const t=await(0,y.fileGrep_)(e,/^\s*(?:hardware|revision|serial|model)\s*[:=]\s*[a-z\d]{6}.*$/i),i=(0,r.compactBlanks)((0,g.splitLines)(t).map((e=>e.replace(/\s+/g," ")))).sort();return i.some((e=>null!=e.match(/^serial/i)))?i:void 0}catch{return}}t.readInfo=x;const C=(0,a.defer)((()=>(0,m.thenMap)(x(),(e=>(0,k.toUID)(k.S.lc,e.join(",")))))),F=/o\.e\.m\./i;async function A(e){return(0,r.uniq)(await Promise.all((0,t.k)()[e].map((e=>(0,v.readFileMaybe)(e,b.LogLevels.trace))))).map(d.toS).filter((e=>(0,s.notBlank)(e)&&null==e.match(F)))}async function I(){return P.isLinux?(await A("lm")).map((e=>(0,k.toUID)(k.S.lm,e))):void 0}async function O(){return P.isLinux?(await A("lp")).map((e=>(0,k.toUID)(k.S.lp,e))):void 0}async function L(){return P.isLinux?(await A("lb")).map((e=>(0,k.toUID)(k.S.lb,e))):void 0}async function R(){if(P.isMac)try{return(0,l.entries)(await async function(){const e=await(0,p.stdout_)((0,t.k)().i,(0,t.k)().ia,{timeoutMs:5*n.secondMs}),i=e.match(/uuid" = "([a-z\d-]{12,})"/i)?.[1],r=e.match(/SerialNumber" = "([a-z\d-]{10,})"/i)?.[1];return{mp:i,ms:r}}()).map((([e,t])=>(0,k.toUID)(e,t)))}catch(e){return void D().warn((0,t.k)().i+" failed",e)}}async function N(){return(await _.PowerShell.instance().executeJson((0,t.k)().w))?.MachineGuid}async function B(){return P.isWin?(0,k.toUID)(k.S.wm,await N()):void 0}t.win_machineGuid_=N;const j=(0,a.defer)((()=>(0,k.toUID)(k.S.cm,(0,M.cpuInfo)()[0].model)));async function z(){return P.isLinux?(0,k.toUID)(k.S.bm,(0,r.compactBlanks)(await A("bm")).map((e=>e.trim())).join("\n")):[]}async function V(){return(0,k.toUID)(k.S.li,await((0,w.LibraryUIDStore)()?.readUid_()))}async function W(){return(0,k.toUID)(k.S.si,await((0,w.SystemUIDStore)()?.readUid_()))}function U(){return(0,S.networkMacAddresses)().map((e=>(0,k.toUID)(k.S.nm,e)))}async function q(){return(0,c.toA)(await(0,T.volumes)()).map((e=>(0,k.toUID)(k.S.vl,e.uuid)))}const H=new Set;t.sids=async function({timeoutMs:e}){const t=Date.now(),i=[j,C,R,V,W,z,I,O,L,B,U,q],r=(0,o.flatten)(await(0,m.someOrTimeout)(i,{timeoutMs:e})).filter(u.isString);for(const e of r)H.add(e);return D().tap({msg:"sids()",result:(0,k.sortUids)([...H,...r]),meta:{timeoutMs:e,elapsedMs:Date.now()-t}})},t.addSids=function(e){if((0,f.isTest)())for(const t of e)H.add(t)},t.clearSids=function(){(0,f.isTest)()&&H.clear()}},48132:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UserTimeoutMs=void 0;const r=i(42659);t.UserTimeoutMs=7*r.secondMs},70114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.saveIfBetter=t.licensesInDirectory=t.writeLicense=void 0;const r=i(45599),s=i(55835),n=i(50213),a=i(23560),o=i(37628),l=i(56519),u=i(46292),c=i(87290),d=i(34102),h=i(83278),f=i(37692),m=i(83950),p=i(81674),g=(0,r.defer)((()=>(0,n.mkLogger)("writeLicense")));async function y(e,t){return(await(0,l.mapAsyncSerial)({name:"read",arr:e.childFiles(),f:async e=>(0,p.vok)(await e.readTextFile(),e.nativePath,t)})).filter((e=>e.ok&&e instanceof m.L))}async function v(e,t,i){if(null!=t)if((await y(t,i)).some((t=>t.cmp(e)>=0)))g().info("saveIfBetter(): no-op for "+t);else{const i=t.join((0,o.shortFsStringSha)(e.s)+".txt");try{return await i.writeFile_(e.s),(0,d.ee)().emit("reloadLicenses"),(0,a.isWebService)()&&(0,f.addStateEvent)("reloadLicenses"),g().info("saveIfBetter(): wrote to "+i),i}catch(e){return void g().error("saveIfBetter(): failed to save license to "+t,e)}}}t.writeLicense=async function(e,t){const i=await(0,p.vok)(e,"candidate",t);if(null==i)return g().error("!ok",e);await v(i,(0,c.libraryDataDirPosixFile)()?.join((0,p.k)().d),t),await v(i,(0,s.map)((0,u.configDir)(),(e=>h.BaseFile.for(e).join((0,p.k)().d))),t),await p.m.refresh()},t.licensesInDirectory=y,t.saveIfBetter=v},34474:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allRecentLogEntries=t.recentLogFiles=void 0;const r=i(40958),s=i(42659),n=i(41400),a=i(96249),o=i(68708),l=i(34666),u=i(20214),c=i(71371),d=i(50213),h=i(42638),f=i(31562),m=i(98314),p=i(89968),g=i(28874),y=i(4904),v=i(57902),w=i(89241),b=i(83954);function S(e=10*s.minuteMs){const t=Date.now()-e;return(0,u.thenMap)(p.DirectoryEntry.for(g.Settings.logDir.valueOrDefault),(e=>e.filterDescendantFiles((async e=>[".log",".log.gz"].includes(e.ext)&&(0,l.gte)(e.mtimeMs(),t)))))}t.recentLogFiles=S,t.allRecentLogEntries=async function(e=50){(0,b.writeRecentLogEntries)();const t=(0,o.fromEntries)(v.LogLevels.values.map((t=>[t,new c.BoundedGreatestSet(e,y.logEntrySorter)]))),i=Date.now()-s.hourMs,p=(0,d.mkLogger)("allRecentLogEntries()");return await(0,u.thenMap)(S(),(e=>(0,h.withBoundedConcurrency)({name:"allRecentLogEntries()",laters:e.map((e=>async()=>{try{const a=[],o=new w.LogReader(e,(e=>a.push(e)));for(await(0,f.untilTrue)((()=>o.ready()),{timeoutMs:10*s.secondMs});!o.complete()&&!o.hasErrors();){const e=o.shift();null==e?await(0,n.delay)(5):e.ts>i&&t[e.l]?.add(e)}(0,r.isNotEmpty)(a)&&(p.warn("Read error(s) for "+e,a),a.some((e=>"Z_BUF_ERROR"===e.code||(0,m.errorToS)(e).includes("unexpected end of file")))&&(0,l.lt)(e.mtimeMs(),Date.now()-s.minuteMs)&&(p.warn("Unlinking corrupt logfile "+e),await e.unlink_()))}catch(t){p.warn("Failed to read entries from "+e,t)}}))}))),(0,a.flatten)((0,o.values)(t).map((e=>e.vacuum()))).sort(((e,t)=>(0,l.cmp)(e.ts,t.ts)))}},49794:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const r=i(57975),s=i(19851),n=i(40958),a=i(22573),o=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,s.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,a.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,r.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,n.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:r})}}},32105:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const r=i(19851),s=i(23560),n=i(66184),a=i(72210);class o{log(e,t,i,r){this.enabled(e,t)&&(0,a.pushLogEntries)({ts:Date.now(),l:e,from:(0,s.processName)(),ctx:t,msg:i,meta:r})}enabled(e,t){return(0,n.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=o,o.instance=(0,r.lazy)((()=>new o))},14593:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const r=i(57975),s=i(22573),n=i(26905),a=i(55835),o=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,s.toNotBlank)(e)??(0,n.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[r.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,o.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const r=e.result(),s=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:r,meta:{...e.meta,elapsedMs:s}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,a.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,o.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const r of this.loggers())r.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const r=i(50213),s=i(43705);t.currentFileLogger=function(){return(0,r.rootLoggers)().find((e=>e instanceof s.LogWriter))}},28981:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const r=i(19851),s=i(51879);t.DefaultLogFormatter=(0,r.lazy)((()=>new s.PlaintextLogFormatter))},31256:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(41400),o=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,r.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,n.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,a.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,s.uniq)((0,s.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,o.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,o.stringify)(t)])))})}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}}},51576:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const n=i(77030),a=i(19851),o=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),v=i(31256),w=i(28538),b=(0,a.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),S=String.fromCharCode(0);t.logBroadcaster=(0,a.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,o.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&b().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),r.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,n.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{b().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){b().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),s(this,r,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,n){if(this.enabled(e,t))try{const a=this.socket;null==a?s(this,r,"f").call(this):a.write(this.logFormatter.format(e,t,i,n)+S)}catch(r){b().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:n,error:r})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}r=new WeakMap},20839:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const r=i(76760),s=i(42659),n=i(28874);t.datedLogDir=function(e,t){return(0,r.join)(e??n.Settings.logDir.valueOrDefault,(0,s.fmtIsoDate)(t??new Date))}},12495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogDirCleanup=void 0;const r=i(19851),s=i(42659),n=i(23560),a=i(79267),o=i(32144),l=i(28874);t.LogDirCleanup=(0,r.lazy)((()=>(0,n.isBillingService)()?void 0:a.FileCleanup.for({name:"logDirCleanup",rootNativePath:()=>l.Settings.logDir.valueOrDefault,staleMs:s.weekMs,isPrunable:e=>(0,o.isLogExt)(e.ext)})))},4904:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const r=i(76790),s=i(31586),n=i(51926),a=i(57902);t.isLogEntry=function(e){return null!=e&&(0,s.isNumber)(e?.ts)&&(0,n.isString)(e?.msg)&&a.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,r.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const r=i(19851),s=i(57902);class n{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,s.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,s.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=n,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,r.lazy)((()=>new n(s.LogLevels.warn))),t.defaultLogLevel=(0,r.lazy)((()=>s.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,s.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){r.add(this),this.setting=e,this.silent=!1,s.set(this,[]),n.set(this,(0,l.lazy)((()=>{o(this,s,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:o(this,s,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>o(this,n,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=o(this,r,"m",a).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=o(this,r,"m",a).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){if(null==e||0===o(this,s,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return o(this,s,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const r=i(42659),s=i(31586),n=i(50989);t.LogLevels=(0,n.strEnum)("fatal","error","warn","info","debug","trace");const a=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??a},t.levelGte=function(e,i){return(0,s.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const o=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return o.get(e)},t.msTolevel=function(e,t=7*r.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const r=i(40958),s=i(68708),n=i(20214),a=i(51926),o=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,a.isString)(i)||Buffer.isBuffer(i))return(0,a.ellipsize)(i.toString(),256,32);if((0,o.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,r=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,r).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-r).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,n.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const o=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,s.keys)(i),(0,s.keys)(o));return(0,r.isNotEmpty)(c)&&(o["…"]="omitted: "+(0,a.ellipsize)(c.join(", "),128,32)),o}return i}},89241:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogReader=void 0;const d=i(73024),h=i(38522),f=i(4001),m=i(14977),p=i(33456),g=i(92322),y=i(4904),v=i(98192);t.LogReader=class{constructor(e,t){if(r.add(this),this.f=e,this.start=Date.now(),this.lines=new g.SortedSet(y.logEntrySorter),s.set(this,!1),n.set(this,!1),a.set(this,!1),this.from=(0,f.stripCopySuffixFromName)(e.name),this.fileStream=(0,d.createReadStream)(e.nativePath,{autoClose:!0}),!(0,m.isExtOrCompressedExt)(e.ext,".log"))throw new Error(e+" is not a logfile");this.stream=(e.ext.toLowerCase().endsWith(".gz")?this.fileStream.pipe((0,h.createGunzip)()):e.ext.toLowerCase().endsWith(".br")?this.fileStream.pipe((0,h.createBrotliDecompress)()):this.fileStream).pipe(new p.LineReader).on("error",(e=>{t(e),u(this,a,!0,"f")})),this.stream.on("data",c(this,r,"m",o).bind(this)),this.stream.on("close",(()=>{this.fileStream.resume(),u(this,s,!0,"f")})),this.stream.on("end",(()=>{u(this,s,!0,"f")}))}toString(){return"LogReader("+this.f.nativePath+")"}status(){return{hasErrors:c(this,a,"f"),ended:c(this,s,"f"),destroyed:this.stream.destroyed,lines:this.lines.length,paused:c(this,n,"f")}}hasErrors(){return c(this,a,"f")}get ended(){return c(this,s,"f")}ready(){return this.ended||this.lines.length>32}complete(){return this.ended&&0===this.lines.length}peek(){return this.ready()?this.lines.at(0):void 0}shift(){const e=this.lines.shift();return null!=e&&c(this,r,"m",l).call(this),e}shiftLte(e){const t=this.lines.shiftLte(e);return t.length>0&&c(this,r,"m",l).call(this),t}},s=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakSet,o=function(e){if(null===e)u(this,s,!0,"f");else{const t=(0,v.chunkToLogEntry)(e);null!=t&&this.lines.add({...t,from:this.from}),this.lines.length>10240&&!c(this,n,"f")&&(this.fileStream.pause(),u(this,n,!0,"f"))}},l=function(){this.lines.length<1024&&c(this,n,"f")&&(this.fileStream.resume(),u(this,n,!1,"f"))}},24068:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const r=i(73024),s=i(76760),n=i(1708),a=i(87997),o=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),v=i(22277),w=i(25764),b=i(38836),S=i(99331),P=i(42638),_=i(76596),T=i(98314),M=i(89968),E=i(29882),k=i(28874),D=i(28981),x=i(20839),C=i(21727),F=i(66184),A=i(57902),I=i(72210),O=i(98192);function L(e){const t=(0,D.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=L;class R extends b.EndableWrapper{constructor(e=void 0,t=L){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,o.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,k.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,E.mkdirp_)(e),this.root=await M.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=s.sep+(0,p.serviceName)()+"-"+n.pid+"-",n.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,a.setInterval)((()=>this.flush()),x.DefaultLogFlushMs/2),this.scanTimeout=(0,a.setInterval)((()=>this.scan()),u.minuteMs),n.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,S.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,F.ifLog)(A.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,r.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,s.join)(e,i))}))}catch(t){return void(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,T.errorToS)(t))))}}))}async scan(e=!1){if((0,S.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,_.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,S.ending)()||this.ended)return;const t=(0,C.datedLogDir)(this.root.nativePath);try{await(0,E.mkdirp_)(t),this.watchDir(t)}catch(e){(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,T.errorToS)(e))))}(0,S.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,a.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,a.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await M.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const r=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(r,i))return;await(0,f.thenMap)((0,O.readLogEntries)(e,{start:r,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,F.ifLog)(A.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,T.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,o.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const r=i(92322),s=i(82328),n=i(28981),a=i(20839),o=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new r.SortedSet(o.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,s.stdoutEnded)()||console.log((0,n.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*a.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),v=i(31586),w=i(409),b=i(23560),S=i(81168),P=i(78406),_=i(25764),T=i(20197),M=i(14977),E=i(36868),k=i(28874),D=i(32105),x=i(20839),C=i(21727),F=i(66184),A=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,r){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:r})}enabled(){return!0}end(){}async flush(){}};class O extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*x.DefaultLogFlushMs),rank:_.EndableRanks.logger,unref:!0,onEnd:()=>c(this,s,"f").call(this)}),r.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,s.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,r,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:D.ConsoleLogger.instance(),flushEveryMs:x.DefaultLogFlushMs,processName:b.processName,logFilter:F.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,r,"m",n).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,r){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,r);else{const s={ts:Date.now(),l:e,ctx:t,msg:i};null!=r&&(s.meta=(0,A.prepMeta)(r)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(s)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=O,s=new WeakMap,r=new WeakSet,n=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,r,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),s=e.splice(0,i);this._linesSinceRotate+=s.length,t.write(s.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},a=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},o=function(e){return t=>(c(this,r,"m",a).call(this,e,t),c(this,r,"m",u).call(this))},l=async function(){await c(this,r,"m",u).call(this);const e=(0,S.stripAnsiEsc)(this.logOpts.processName()),t=await(0,T.ensureNewNativePath_)({nativePath:(0,f.join)((0,C.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,r,"m",o).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,E.endStream)(e.stream),k.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,M.gzip_)(e.nativePath))}catch(e){c(this,r,"m",a).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const r=i(57975),s=i(40958),n=i(55835),a=i(68708),o=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,a.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,s.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,n.map)(e.meta,(e=>(0,r.inspect)(e,this.inspectOptions)))]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,r){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:r})}}},98192:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const r=i(22573),s=i(84542),n=i(4001),a=i(13047),o=i(4904);function l(e){if(!(0,r.blank)(e))try{const t=JSON.parse(e);return(0,o.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,n.stripCopySuffixFromName)(e.name),r=[],o=await(0,a.zcat)(e.nativePath,t);if(null!=o)for(const e of(0,s.splitLines)(o)){const t=l(e);null!=t&&r.push({...t,from:i})}return r},t.chunkToLogEntry=l},22662:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const r=i(19851),s=i(76790),n=i(68708),a=i(89788),o=i(57902);t.SentLogLevels=(0,r.lazy)((()=>o.LogLevels.values.filter((e=>e!==o.LogLevels.trace))));const l=(0,r.lazy)((()=>(0,n.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new a.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,n.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,n.values)(l()))e.push(...t.toA());return(0,s.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const r=i(76760),s=i(41400),n=i(55835),a=i(37975),o=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),v=i(66184),w=i(28538),b=i(24068),S=i(43705),P=i(51879);function _(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),T();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,r.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new S.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,n.map)((0,y.logBroadcaster)(),(e=>i.push(e))),o.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&b.LogTail.instance()}function T(){const e=h.Settings.logColor.valueOrDefault;(0,a.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=_,t.setupLogFormatter=T,(0,s.later)((()=>{h.Settings.logStdout.watchLater(_),h.Settings.logDir.watchLater(_),h.Settings.tailLogs.watchLater(_),h.Settings.logColor.watchLater(T),h.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},83954:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeRecentLogEntries=void 0;const r=i(89179);t.writeRecentLogEntries=function(){return(0,r.currentFileLogger)()?.writeRecentLogEntries()}},82647:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const a=i(57975),o=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const r=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...r),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...r]),i}}constructor(e=20){r.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(r=new WeakSet,a.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return n(this,r,"m",s).call(this,-1)}get p29(){return n(this,r,"m",s).call(this,-.5)}get p38(){return n(this,r,"m",s).call(this,-.25)}get p69(){return n(this,r,"m",s).call(this,.5)}get p84(){return n(this,r,"m",s).call(this,1)}get p98(){return n(this,r,"m",s).call(this,2)}get p99(){return n(this,r,"m",s).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,o.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,o.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,o.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,s=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const r=i(40958),s=i(55835),n=i(31586),a=i(30976),o=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),r=[];for(;e>0;)r.unshift(e%i),e=Math.floor(e/i);return r}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,n.clamp)(0,i,(0,n.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,s.map2)(e,t,((e,t)=>(0,r.sum)((0,o.zip)(u(e,i),u(t,i)),(([e,t])=>(0,n.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,n.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,a.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max)),s=this.clampValue(e);let n=0;for(let e=0;ea?(n+=1,i[t]=a):r[t]=a}return n}unzip(e,t){const i=this.dims.map((e=>e.min)),r=this.dims.map((e=>e.max));for(let s=0;s(i[e]+r[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,n.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;in?(t+=1,s.min=n):s.max=n}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,r.sum)(e,((i,r)=>t(i,r)?Math.pow(2,e.length-r-1):0))}},76752:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtEstimate=t.ETA=void 0;const r=i(42659),s=i(75240),n=i(31586),a=i(97352),o=i(82647);function l(e){return(0,n.gt0)(e)?e<=r.minuteMs?"less than a minute remains":"about "+(0,s.fmtDuration)(e,1,{plural:"remains",singular:"remain"}):void 0}t.ETA=class{constructor(){this.taskMillis=new o.Average(10)}push(e){(0,a.mapGt0)(e,(e=>this.taskMillis.push(e)))}clear(){this.taskMillis.clear()}avg(){return this.taskMillis.p69}etaMs(e){const t=this.avg();if(null==t)return;const i=t*e;return i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.kmeans=void 0;const r=i(76790),s=i(93973);t.kmeans=function(e,t,i){const n=s(e,t,i);return{...n,centroids:(0,r.sortBy)(n.centroids.filter((e=>e.size>0)),(e=>-e.size))}}},31843:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const r=i(76790);function s(e,t,i=.5){return(1-i)*e+i*t}t.lerp=s,t.lerp2d=function(e,...t){const i=(0,r.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[n,a]=(0,r.sortBy)(i,(e=>e.x)),o=a.x-n.x,l=(e-n.x)/o;return s(n.y,a.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},75503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.modeReduce=t.submatrixCollect=t.greatestHalf=t.leastVariantQuarter=t.leastMagQuarter=t.submatrixMode=t.submatrixStdDev=t.submatrixMagnitude=t.submatrixForEach=t.index1D=t.slice=t.matXvec=t.vecXvec=void 0;const r=i(40958),s=i(31586),n=i(48884),a=i(82647),o=i(70417);function l(e,t,i,r){const s=Math.floor(Math.max(0,t.row)),n=Math.ceil(Math.min(e.row,i.row)),a=Math.floor(Math.max(0,t.col)),o=Math.ceil(Math.min(e.col,i.col));for(let t=s;t(0,s.mapFinite)(e[t],(e=>n+=e*e)))),Math.sqrt(n)}function c(e,t,i,r){const n=new a.Average;return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),n.stdDev}function d(e,t,i,r){const n=[];return l(t,i,r,(t=>(0,s.mapFinite)(e[t],(e=>n.push(e))))),(0,o.mode)(n)}t.vecXvec=function(e,t){return e.map(((e,i)=>e*t[i]))},t.matXvec=function(e,t){return e.map(((e,i)=>{if(e.length!==t.length)throw new Error("misshaped matrix on row "+i);return(0,o.sumf)(e,((e,i)=>e*t[i]))}))},t.slice=function(e,t,i){const s=Math.max(0,t.row),n=Math.min(e.length,i.row),a=Math.max(0,t.col),o=Math.min(e[0].length,i.col);return(0,r.range)(s,n,(t=>e[t].slice(a,o)))},t.index1D=function(e,t,i){return t*e.col+i},t.submatrixForEach=l,t.submatrixMagnitude=u,t.submatrixStdDev=c,t.submatrixMode=d,t.leastMagQuarter=function(e,t){const i=t.col,r=t.row,s=[u(e,t,{col:i/2,row:0},{col:i,row:r/2}),u(e,t,{col:0,row:0},{col:i/2,row:r/2}),u(e,t,{col:0,row:r/2},{col:i/2,row:r}),u(e,t,{col:i/2,row:r/2},{col:i,row:r})];return(0,n.leastIndex)(s)},t.leastVariantQuarter=function(e,t){const i=t.col,r=t.row;return(0,n.leastIndex)([c(e,t,{col:i/2,row:0},{col:i,row:r/2}),c(e,t,{col:0,row:0},{col:i/2,row:r/2}),c(e,t,{col:0,row:r/2},{col:i/2,row:r}),c(e,t,{col:i/2,row:r/2},{col:i,row:r})])},t.greatestHalf=function(e,t){const i=t.col,r=t.row,s=[d(e,t,{col:0,row:0},{col:i,row:r/2}),d(e,t,{col:0,row:0},{col:i/2,row:r}),d(e,t,{col:0,row:r/2},{col:i,row:r}),d(e,t,{col:i/2,row:0},{col:i,row:r})];return(0,n.greatestIndex)(s)},t.submatrixCollect=function(e,t,i){const r=[];return l(e,t,i,(e=>r.push(e))),r},t.modeReduce=function(e,t,i){const o=Math.floor(t.col/i.col),u=Math.floor(t.row/i.row),c=new a.Average(Math.ceil(o*u));return(0,n.concat)(...(0,r.stepRange)(0,t.row,u,(i=>(0,r.stepRange)(0,t.col,o,(r=>(c.clear(),l(t,{col:r,row:i},{col:r+o,row:i+u},(t=>(0,s.mapFinite)(e[t],(e=>c.push(e))))),c.sampleMode))))))}},36372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stableContentShuffle=t.stableIndexShuffle=t.factors=t.primeSeeds=t.primeInt=t.primes=t.prng=t.prngOrderByClause=void 0;const r=i(76790),s=i(42659),n=i(31586),a=i(97238),o=i(50597),l=i(9103),u=i(55222);function c(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e),u=(s*i*i+n*i)%r,c=(a*i+o)%r;return Math.round((u*c+l)%r)}function d(e){return(0,u.encodeDigits)(a.PrimesPerBin,e,a.PrimeBins).map(((e,i)=>t.primes[i][e]))}t.prngOrderByClause=function(e,i,r){const[s,n,a,o,l]=(0,t.factors)(e);return`(((${s}*${i}*${i}+${n}*${i})%${r})*((${a}*${i}+${o})%${r})+${l})%${r}`},t.prng=c,t.primes=[[353868013,472882027,479001599,517294153],[1012573,1230587,1355297,1572751],[756065159,812182027,899809343,989450477],[3959297,4514113,4823201,5133127],[573259391,666101999,694847533,746151647],[2275327,2770513,3073703,3511973],[173313197,182557181,203457869,222230231],[6054613,6189107,7752103,9852103]],t.primeInt=[1012573,1101689,1183811,1196089,1230587,1355297,1419641,1483733,1572751,2275327,2770513,3010349,3073703,3118691,3174823,3511973,3959297,4514113,4690451,4823201,5133127,5375327,6019889,6054613,6189107,7752103,7752103,9852103],t.primeSeeds=d,t.factors=(0,l.memoize)((e=>{const[i,r,s,o,l,u,c,h]=d(e%a.SeedCount),f=[i/r,s/o,l/u,c/h].map((e=>(0,n.sigFigs)(e,7)));return f.push(t.primeInt[e%t.primeInt.length]),f}),{maxSize:128,ttlMs:s.minuteMs}),t.stableIndexShuffle=function(e,t=1){return(0,r.sortBy)(e,((i,r)=>c(t,r,e.length)))},t.stableContentShuffle=function(e,t=1){return(0,r.sortBy)(e,(e=>(0,o.numericSha)(String(e)+t)))}},55222:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const r=i(77598),s=i(22573),n=i(55835),a=i(32639),o=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const r=[];if(0===t)r.unshift(0);else for(;t>0;)r.unshift(t%e),t=Math.floor(t/e);for(;r.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let r=e;for(;r>u;)t.push(Number(r%i)),r/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,r)=>{i+=e<<8,t[r]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,n.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,s.blank)(e))return;const t="-"===(e=(0,a.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let r=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;r=r*i+BigInt(e)}return t?BigInt(-1)*r:r}randomChars(e){return this.encodeBuffer((0,r.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const r=this.normalizeToken(e),s=this.normalizeToken(t);return r.length>=i&&r===s}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const r=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,r.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const r=i(31586),s=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,r.toInt)(e)]??(0,s.toS)(e)}},38812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SquareMatrix=t.rotateSquareMatrix=void 0;const r=i(21605);t.rotateSquareMatrix=function(e,t){return 0===(0,r.normalizeRotation)(t)?e:new s([...e]).rotate(t).m};class s{constructor(e,t=1){if(this.m=e,this.ary=t,this.rows=Math.sqrt(e.length/t),this.rows!==Math.floor(this.rows))throw new Error(`Only square tuple matrices are supported: ${1===this.ary?"":this.ary}(${this.rows}×${this.rows}) != ${e.length}`)}index(e,t){return this.ary*(t+e*this.rows)}swap(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const r=i(77598),s=i(65713);function n(){const e=(0,r.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=n,t.safeUUID=function(){return(0,s.decuss)(n)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const o=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function v(e,t){let i=0,r=0;for(const s of e){if(null!=s){const e=t(s,i);(0,u.isNumber)(e)&&(r+=e)}i++}return r}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=v;class w{constructor(){r.set(this,0),s.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(a(this,s,null==n(this,s,"f")?e:n(this,s,"f")*n(this,r,"f")/(n(this,r,"f")+1)+e/(n(this,r,"f")+1),"f"),a(this,r,(t=n(this,r,"f"),++t),"f"))}get mean(){return n(this,s,"f")}}function b(e){const t=new w;for(const i of e)t.push(i);return t.mean}function S(e){const t=b(e);if(null==t)return;let i=0,r=0;for(const s of e)(0,u.isNumber)(s)&&(r++,i+=(s-t)*(s-t));return i/r}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function _(e,t){let i=0;for(let r=0;r(1-t)*e+t*(i+a*(e-s)/n)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=b(t);if(null!=i){const e=(t.length-1)/2,r=v(t,((t,r)=>(t-i)*(r-e))),s=v(t,(e=>(e-i)**2));return 0===s?0:r/s}},t.variance=S,t.stdDev=function(e){return(0,l.map)(S(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const r of e)i=null==i?r:i*t+r*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let r=0;re[r]))));return i},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,o.isEmpty)(e)&&(0,o.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},23624:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.b64encodeBits=t.b64hammRatio=t.gz64decodeString=t.d=t.gz64encodeString=t.b64decode=t.b64encode=t.hex2b64=void 0;const r=i(38522),s=i(22573),n=i(97352);function a(e){const t=e.toString(16),i=t.length%2==0?"":"0";return Buffer.from(i+t,"hex").toString("base64")}function o(e){return BigInt("0x0"+Buffer.from(e,"base64").toString("hex"))}function l(e){return(0,r.gunzipSync)(Buffer.from(e,"base64")).toString("utf8")}t.hex2b64=function(e){return Buffer.from(e,"hex").toString("base64")},t.b64encode=a,t.b64decode=o,t.gz64encodeString=function(e){return(0,r.gzipSync)(Buffer.from(e,"utf8")).toString("base64")},t.d=l,t.gz64decodeString=l,t.b64hammRatio=function(e,t){return(0,s.mapNotBlank)(e,(e=>(0,s.mapNotBlank)(t,(t=>(0,n.hammRatioBigInt)(o(e),o(t))))))},t.b64encodeBits=function(e){return a(BigInt("0b0"+e.map((e=>1===e?"1":"0")).join("")))}},39471:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EndableServer=void 0;const r=i(27395),s=i(25764),n=i(36868);t.EndableServer=class{constructor(e,t){this.name=e,this.server=t,this._ended=!1,(0,r.addEndable)(s.EndableRanks.service,this)}get ended(){return this._ended}end(){return this._ended=!0,(0,n.closeStream)(this.server)}}},49076:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const s=r(i(48161)),n=i(19851),a=i(22573),o=i(41400),l=i(81168),u=i(28874);t.hostname=(0,n.lazy)((()=>u.Settings.hostname.value??s.default.hostname())),(0,o.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,a.blank)(e)&&!(0,a.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??s.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},93756:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.request=void 0;const s=r(i(44708)),n=i(22573),a=i(55835),o=i(97352),l=i(57159),u=i(63870),c=i(43205);t.request=async function(e,t={}){return null==t.headers&&(t.headers={}),(0,n.blank)(t.headers["user-agent"])&&(t.headers["user-agent"]=await(0,c.userAgent)()),new Promise(((i,r)=>{const n=s.default.request(e.toString(),t);n.setTimeout((0,a.orElse)(t.timeout,(0,u.commandTimeoutMs)()),(()=>{r(new l.WrappedError("Timeout fetching <"+e+">",{doNotSend:!0,retriable:!0}))})),n.on("response",(e=>{const t=[];e.setEncoding("utf8"),e.on("data",(e=>t.push(e))),e.on("end",(()=>{i({ok:(0,o.within)(200,399,e.statusCode),headers:e.headers,body:t.join(""),statusCode:e.statusCode,statusMessage:e.statusMessage})}))})).on("error",(e=>{r(e)})),(0,a.map)(t.body,(e=>n.write(e))),n.end()}))}},43205:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemUserAgent=t.simpleUserAgent=t.userAgent=void 0;const r=i(72993),s=i(17344),n=i(96175),a=i(37805),o=i(81674),l=i(28874);function u(){return r.SimpleAppName+a.version}async function c(){return u()+" ("+(0,n.osFullName)()+") "+(0,s.EditionType)().toLowerCase()+"/"+await(0,o.t)()}t.userAgent=async function(){return l.Settings.allowUserAgent.valueOrDefault?c():u()},t.simpleUserAgent=u,t.systemUserAgent=c},72308:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isLocalhost=t.isLoopback=t.myExternalIp4Addresses=t.myExternalIpAddresses=t.networkMacAddresses=t.myIpAddresses=void 0;const r=i(48161),s=i(19851),n=i(40958),a=i(22573),o=i(42659),l=i(96249),u=i(31586),c=i(68708),d=i(50213),h=i(81168);function f(){return(0,t.myIpAddresses)().filter((e=>!g(e)))}t.myIpAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.address))))),o.minuteMs),t.networkMacAddresses=(0,s.lazy)((()=>(0,n.uniq)((0,n.compactBlanks)((0,l.flatten)((0,c.values)((0,r.networkInterfaces)())).map((e=>e.mac)))).filter((e=>"00:00:00:00:00:00"!==e))),o.minuteMs),t.myExternalIpAddresses=f,t.myExternalIp4Addresses=function(){return f().filter((e=>!e.includes(":")))};const m=(0,s.lazy)((()=>(0,d.mkLogger)("net.ip"))),p=[/^(?:::ffff:)?127\.\d{1,3}.\d{1,3}.\d{1,3}$/i,/^::1$/];function g(e){return(0,a.notBlank)(e)&&(127===function(e){const t=e.split(".").map((e=>(0,u.toInt)(e)));return 4!==t.length||t.some((e=>null==e||!(0,u.within)(0,255,e)))?void 0:t}(e)?.[0]||p.some((t=>null!=t.exec(e))))}t.isLoopback=g,t.isLocalhost=function(e){return m().tap({msg:"isLocalhost",level:"info",result:!(0,a.blank)(e)&&((0,t.myIpAddresses)().includes(e)||(0,t.myIpAddresses)().includes((0,h.stripPrefix)(e,"::ffff:"))||g(e)),meta:{address:e}})}},96128:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const r=i(40610),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),v=i(34102),w=i(26293),b=new RegExp("^"+w.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==b.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const S=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=S.exec(e)}function _(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=_,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,n.blank)(e)){if(null!=_(e))return[e];try{return await r.promises.resolve4(e)}catch(t){return void T().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs});const T=(0,s.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,o.later)((()=>(0,v.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=_(e)?r.promises.reverse(e):r.promises.resolve4(e),5*a.secondMs);if(t===c.Timeout)return T().info("nslookup("+e+"): timeout"),e;const i=t.find(n.notBlank);return null==i?(T().warn("No name found for "+e),e):i}catch(t){return T().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,n.blank)(e)&&!(0,n.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const r=i(22573),s=i(42659),n=i(31586),a=i(97790),o=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*s.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,n.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,a.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(r.notBlank).flatMap((e=>t.ipv4Re.exec((0,o.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*s.minuteMs})},78330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const r=i(40958),s=i(22573),n=i(45599),a=i(59455),o=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),h=i(63870),f=(0,n.defer)((()=>(0,o.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,a.toA)(await async function(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return f().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,r.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,s.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(f().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const r=i(73024),s=i(38639),n=i(19851),a=i(59958),o=i(43334);t.isDocker=(0,n.lazy)((()=>o.isLinux&&((0,s.toBoolean)(process.env[a.PS_IS_DOCKER])??(0,r.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const r=i(76760),s=i(19851),n=i(54993);t.isPacked=(0,s.lazy)((()=>!(0,n.toS)(__filename).includes((0,r.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const r=i(45599),s=i(50213),n=i(84777),a=i(68284),o=i(63870),l=i(43334),u=(0,r.defer)((()=>(0,s.mkLogger)("platform.Pacman")));t.hasPacman=(0,r.defer)((()=>l.isLinux&&(0,a.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,n.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,o.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const s=r(i(48161)),n=r(i(1708)),a=i(22573),o=i(38639),l=i(59958),u=s.default.platform();t.inspectFlag=n.default.argv.includes("--inspect")||(0,o.isTrue)(n.default.env.NODE_INSPECT),t.isCI=(0,o.isTrue)(n.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,a.notBlank)(n.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===s.default.arch(),t.isArm=null!=/^arm\b/i.exec(s.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,a.notBlank)(n.default.env.APPIMAGE)||(0,a.notBlank)(n.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,a.notBlank)(n.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=n.default.versions.electron,t.isElectron=t.isMainElectron||(0,o.isTrue)(n.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const s=r(i(73024)),n=i(19851),a=i(43334);function o(e="/proc/cpuinfo"){if(a.isWin||a.isMac)return!1;try{return null!=s.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=o,t.isRaspberryPi=(0,n.lazy)((()=>a.isLinux_arm&&o())),t.procDeviceModel=(0,n.lazy)((()=>{try{return a.isLinux?s.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},94137:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.negateFilterName=void 0;const r=i(22573),s=i(51926),n=i(83556);t.negateFilterName=function(e){if((0,r.blank)(e))return;const t=/\s/.test(e)?e:(0,n.camel2words)(e).replace(/\bphoto structure\b/gi,"PhotoStructure");return t.match(/^not\b/)?t.replace(/^not\b/,"").trim():"not "+(0,s.stripPrefix)(t,"is ")}},78984:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Predicates=void 0;const r=i(19851),s=i(40958),n=i(68708),a=i(51926),o=i(50213),l=i(94137),u=(0,r.lazy)((()=>(0,o.mkLogger)("predicates.Predicates")));class c{static async accepted(e,...t){for(const i of t)for(const t of(0,n.values)(i)){const i=await t(e);if(!1===i||(0,a.isString)(i))return!1}return!0}static async rejected(e,...t){return!await c.accepted(e,...t)}static async explain(e,...t){const i=[],r=[],s=[];for(const o of t)for(const[t,l]of(0,n.entries)(o)){const n=await l(e);!0===n?i.push(t):!1===n||(0,a.isString)(n)?r.push(t):s.push(t)}return{accepted:i,rejected:r,notApplicable:s}}static async whyRejected(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))try{const i=await r(e);if(null==i||!0===i)continue;return(0,a.isString)(i)?i:(0,l.negateFilterName)(t)}catch(e){u().warn("whyRejected() caught from "+t,{error:e})}}static async logged({a:e,logger:t,msg:i,predicates:r}){const{accepted:n,rejected:a}=await c.explain(e,...r);return t.tap({msg:i,result:(0,s.isEmpty)(a),meta:{a:e,accepted:n,rejected:a}})}}t.Predicates=c},33995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SyncPredicates=void 0;const r=i(68708),s=i(94137);class n{static firstFalse(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!1===s(e))return t}static firstTrue(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i))if(!0===s(e))return t}static firstDefined(e,...t){for(const i of t)for(const[t,s]of(0,r.entries)(i)){const i=s(e);if(null!=i)return{name:t,result:i}}}static accepted(e,...t){return null==n.firstFalse(e,...t)}static whyRejected(e,...t){return(0,s.negateFilterName)(n.firstFalse(e,...t))}}t.SyncPredicates=n},45643:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const r=i(58587),s=i(59455),n=i(31562);t.existingPids=function(e){return(0,s.toA)(e).filter(r.pidExists)},t.waitForPidExit=function(e,t){return(0,n.untilTrue)((()=>!(0,r.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(97790),w=i(59455),b=i(54993),S=i(54557),P=i(19851),_=i(50213),T=i(88158),M=i(409),E=i(78406),k=i(25764),D=i(99331),x=i(56519),C=i(46292),F=i(8769),A=i(83278),I=i(32144),O=i(29882),L=i(43334),R=i(24399),N=i(58261),B=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),j=10*p.secondMs;function z(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),r=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(r)&&Math.abs(i-r){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,O.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))B().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{B().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??L.isWin,r=await this.pidfiles(),s=await this.pids(r??[]);if((0,f.isEmpty)(s))return B().info("killOldProcs(): no pidfiles"),[];const n=[],a=[],o=await(0,N.pidInfos)(s);if(null!=o){for(const s of r){const r=await s.readJson();if(null==r){B().warn("killOldProcs(): failed to read pidfile "+s.base),await s.unlink("debug");continue}const l=r.pid;if(!(0,y.gt0)(l)){B().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+s.base,{json:r,pid:l}),await s.unlink("debug");continue}const u=o.find((e=>e.pid===l));if(null==u||!z(r,u)){B().debug("killOldProcs(): pid no longer present: unlinking "+s.base,{json:r,pidEntry:u}),await s.unlink("debug"),n.push(r);continue}const c=(0,y.gt0)(r.timeoutMs)?r.startTime+r.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(r.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(B().info("killOldProcs(): killing",{reason:d,json:r}),a.push(W(l,i,!1)),n.push({...r,...u}))}return a.length>0&&await Promise.allSettled(a),n}(0,F.onError)("Pids.killOldProcs(): failed to get process information")}}),a.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const a=e.pid;if(!(0,y.gt0)(a))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(a)?(i&&o(this,s,"f").delete(l),o(this,s,"f").getOrSet(l,(async()=>{const i=o(this,r,"m",n).call(this,e.pid),s=(0,v.opt)((0,T.Try)((()=>(0,O.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),a=t.getTime(),l={...e,cmd:s,startTime:a};return await i.writeJson_(l),B().debug("addPid() wrote "+i,l),i}))):(o(this,s,"f").delete(l),void B().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=o(this,r,"m",n).call(this,e);return(0,x.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{B().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==o(this,a,"f")||o(this,a,"f").ended)&&l(this,a,new E.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:k.EndableRanks.first}),"f"),o(this,a,"f")}cancelInterval(){o(this,a,"f")?.end(),l(this,a,void 0,"f")}}t.Pids=U,s=new WeakMap,a=new WeakMap,r=new WeakSet,n=function(e){return this.pidsDir.join(e+".json")},U.instance=(0,P.lazy)((()=>(0,g.map)((0,C.configDir)(),(e=>new U(A.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return U.instance()?.addPid_(e,t)}},58261:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const s=i(31421),n=i(48161),a=r(i(1708)),o=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),v=i(84968),w=i(48963),b=i(56519),S=i(84777),P=i(8103),_=i(45879),T=i(43334),M=i(24399),E=i(45643),k=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function D(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function x(e){if(T.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,_.readFileMaybe)("/proc/"+i+"/stat")));return k().tap({msg:"pidInfoProc",result:(0,o.compact)(t)})}(e);const t=(0,E.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,T.isWin?I:N)).filter((e=>D(e)&&t.includes(e.pid)));return k().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=D,t.pidInfo=async function(e){return(0,b.thenMap)(x([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,o.isEmpty)(e)?[]:(0,b.thenMap)((0,E.existingPids)(e),(t=>{const i=[a.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=x;const C="Get-Process",F="| Select-Object -Property Id,ProcessName,StartTime";function A(e){return(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).join(",")}async function I(e){if(M.PowerShell.instance().ended)return R(e);const t=[C,"-Id",A(e),"-ErrorAction SilentlyContinue",F].join(" ");return(0,b.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const O={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},L=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,o.isNotEmpty)(e)){const i=(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",L.join(","));const i=await(0,S.stdoutResult_)((0,P.wmic)(),t,O),r=(0,d.onlyReqValued)((0,p.parseFixed)(L,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return r.find((e=>e.pid===a.default.pid))||r.push({pid:a.default.pid,start:new Date(v.StartTs),cmd:"node "+a.default.title}),r}async function N(e){return t=(await(0,S.stdoutResult_)("ps",["-p",A(e),"-wwwo","pid,lstart,command"],{...O,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const B=(0,g.lazy)((()=>{try{if(T.isLinux)return(0,c.toGt0)((0,s.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){k().warn("clk_tck failed",{error:e})}return 100})),j=(0,g.lazy)((()=>Date.now()-(0,n.uptime)()*u.secondMs)),z=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=z.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),r=t?.comm,s=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(r)&&(0,c.gt0)(s)?{pid:i,cmd:r,start:new Date(j()+s/B()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const r=i(40958),s=i(22573),n=i(31586),a=i(29882),o=i(97352);t.progressEvtToS=function(e){const t=(0,s.blank)(e.path)?null:(0,a.ellipsizePath)({p:e.path,maxLength:80});return(0,r.compactBlanks)([t,e.op,!0===e.done?"done":(0,n.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,s.notBlank)(e.op)&&(0,o.within)(0,100,e.pct)}},41944:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const r=i(19851),s=i(42659),n=i(31586),a=i(12089),o=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,r.lazy)((()=>new o.TTLMap(15*s.secondMs))),t.recentDone=(0,r.lazy)((()=>new o.TTLMap(2*s.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,n.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,a.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const r=i(98553),s=i(31586),n=i(409),a=i(78406),o=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends a.EndableInterval{constructor(e,t,i,s=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,r.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:s,rank:o.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=s,this.start=Date.now(),this.onInterval=(0,n.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,s.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,s.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},38156:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PushProgressObserver=void 0;const r=i(31586),s=i(41944);t.PushProgressObserver=class{constructor(e,t){this.context=e,this.total=t,this.start=Date.now()}toJSON(){}incrProgress(e=1){this.onProgress(e+(this.current??0))}onProgress(e){this.current=(e??this.current??0)+1,(0,r.gte)(this.current,this.total)&&(this.done=!0),this.emit()}completed(){this.done=!0,this.current=this.total,this.emit()}emit(){(0,s.emitProgressEvt)({...this.context,pct:(0,r.pct)(this.current,this.total),elapsedMs:Date.now()-this.start,done:this.done})}}},24399:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const r=i(58587),s=i(19851),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),v=i(99331),w=i(56519),b=i(31562),S=i(84777),P=i(34102),_=i(43334),T=i(28874),M=i(63870),E="{ready}",k=" | ConvertTo-Json -Compress";function D(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=D,(0,o.later)((()=>(0,P.ee)().on("clearCache",(()=>x.instance.prior()?.clearMockResults()))));class x extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new r.BatchCluster({processFactory:()=>(0,S.execFile)("powershell",T.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${E}"}`,...(0,n.mapNotBlankOr)(T.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:E,fail:"Error",exitCommand:"exit",maxProcs:T.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:a.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),T.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(T.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,k),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new r.Task(e,((i,r,s)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),r,s)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,k),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,n.blank)(t.stdout)||(0,n.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+D(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=x,x.instance=(0,s.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new x})),t.checkPowerShell_=async function(){const e=x.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,n.blank)(t)){const t=await(0,b.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const r=i(50989);t.AggregateTypes=(0,r.strEnum)("union","intersection")},71988:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const r=i(50989);t.AssetFileSortCriteria=(0,r.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const r=i(22573),s=i(38639),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toBoolean})}}t.BooleanSetting=a},90536:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).flatMap(parseFloat).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=o},75164:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:t=>(0,n.opt)(t).filter(r.notBlank).flatMap(s.toInt).map((t=>(0,s.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,s.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=o},10546:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const r=i(50989);t.ColorDistanceFunctions=(0,r.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const r=i(36507),s=i(22573),n=i(45599),a=i(50213),o=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,n.defer)((()=>(0,a.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,o.trimQuotes)(e);return void((0,s.blank)(t)||(0,r.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,s.blank)(t)?void 0:(0,r.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const r=i(70488),s=i(91655),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration})}get valueOrDefault(){return(0,r.decodeDuration)(super.valueOrDefault)}get value(){return(0,r.decodeDuration)(super.value)}set value(e){super.userValue=(0,r.decodeDuration)(e)}get humanValue(){return(0,s.fmtFullDuration)(this.value)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,r.decodeDuration)(e)}}t.DurationSetting=a;class o extends n.Setting{constructor(e){super({...e,toEnv:r.encodeDuration,fromEnv:r.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,r.decodeDuration)(this.defaultValue)}get fileValue(){return(0,r.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=o},9945:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.FloatSetting=a},69589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.forceContextOrSetting=t.pickForceContext=void 0;const r=i(38639),s=i(68708),n=i(50989),a=i(76740),o=i(28874),l=(0,n.strEnum)("forceSync","forceFilters","skipPreviews","forceRebuildPreviews","skipAssetTagging","recountAllTags","skipAssetRepair");t.pickForceContext=function(e){return(0,s.pick)(e,...l.values)},t.forceContextOrSetting=function(e){const t={...(0,s.pick)(e??{},"retries","halt","path"),...(0,s.fromEntries)(l.values.map((t=>[t,e?.[t]??(0,r.isTrue)(o.Settings[t]?.valueOrDefault)])))};return t.retries??(t.retries=0),t.halt??(t.halt=new a.Abortable),t}},74589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt})}}t.IntegerSetting=a},86941:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAndArchiveSystemSettingsDir_=t.mergeUserDataDirs_=void 0;const r=i(19851),s=i(59455),n=i(72993),a=i(46292),o=i(95696),l=i(50213),u=i(83179),c=i(28874),d=i(2858),h=i(84438),f=(0,r.lazy)((()=>(0,l.mkLogger)("settings.MergeConfigDirs")));async function m(e,t){let i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+e.baseWithGrandparent+" => "+t.baseWithGrandparent+")");const r=await e.resolve_(),n=await t.resolve_();if(null==r||null==n||n.nativePath===r.nativePath)return void i.info("no-op, missing or same directory",{priorResolvedConfigDir:r?.nativePath,currentResolvedConfigDir:n?.nativePath});if(i=(0,l.mkLogger)("mergeAndArchiveSystemSettingsDir_("+r.baseWithGrandparent+" => "+n.baseWithGrandparent+")"),!await r.isDirectory())return void i.info("no-op, prior directory doesn't exist");{const e=r.join(h.SettingsToml);if(await e.isNonEmptyFile()){const t=n.join(h.SettingsToml);await(0,d.readSystemSettings)(e),i.info("read prior settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.readSystemSettings)(t),i.info("read current settings.toml",(0,u.settingsToObj)((0,c.persistedSystemSettings)())),await(0,d.writeSystemSettings_)(t)}}{const e=r.join("licenses"),t=n.join("licenses");for(const r of(0,s.toA)(await e.childFiles())){const e=t.join(r.base);if(await e.notExists())try{await r.copyFile_(e),i.info("Copied license "+r.base)}catch(e){i.warn("Failed to copy license "+r.base,e)}}}const a=n.join("old");try{const e=await r.renameYMDHMS_({subdir:a.nativePath});i.info("merged and archived to "+e)}catch(e){i.warn("Failed to archive to "+a,e)}}t.mergeUserDataDirs_=async function(){const e=(0,a.configDir)();if(null==e)return;const t=o.PosixFile.for(e);for(const e of[t.join((0,n.AppName)()),t.join((0,n.AppName)().toLowerCase()),t.parent().join((0,n.AppName)().toLowerCase())])try{await m(e,t)}catch(i){f().error("Failed to merge "+e+" and "+t,i)}f().info("done")},t.mergeAndArchiveSystemSettingsDir_=m},4175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const r=i(19851),s=i(22573),n=i(38639),a=i(42659),o=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,r.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function v(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function w(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){_(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&v(),y("strictDeduping",e)&&w(),(y("optOut",e)||y("noNetwork",e))&&T()},t.handleDeprecatedSettings=async function(){if((0,n.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,s.blank)(m.Settings.assetPathnameFormat.value)&&(0,s.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*a.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=v,t.setStrictDeduping=w;const b=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],S={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function _(e){for(const t of b)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:S;for(const[e,i]of(0,o.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function T(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=_,t.disableExternalNetworkRequests=T},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const r=i(22573),s=i(53265),n=i(87652);class a extends n.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,r.blank)(e)?void 0:(0,s.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=a},23561:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:r.notBlankToS,fromEnv:s.toFloat})}}t.OptionalFloatSetting=a},69005:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const r=i(22573),s=i(31586),n=i(83179);class a extends n.Setting{constructor(e){super({...e,toEnv:r.notBlankToS,fromEnv:s.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=a},87652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=s},4936:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathToLibraryAsset=void 0;const r=i(51168),s=i(19851),n=i(40958),a=i(22573),o=i(55835),l=i(51926),u=i(50213),c=i(81168),d=i(79842),h=i(21330),f=i(51275),m=i(29882),p=i(28874),g=(0,s.lazy)((()=>(0,u.mkLogger)("settings.PathToLibraryAsset")));function y(e){return(0,a.blank)(e)?"":"'"+e.replace(/'/g,"′")+"'"}t.pathToLibraryAsset=function(e,t){const i=(0,d.datedToDateTime)(e)??(0,o.map)((0,h.datedToISO)(e),(e=>r.DateTime.fromISO(e)));if(null==i||!i.isValid)return g().tap({msg:"pathToLibraryAsset(): failed to convert to a valid date",result:void 0,meta:{capturedAt:e,src:t,dt:i}});const s=(0,f.hasZone)(e),a=p.Settings.assetPathnameFormat.valueOrDefault,u=(0,c.splitKeep)(a,/((?:GRAND)?PARENT|BASE|NAME|EXT|ISO)/g);for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const r=i(51926),s=i(83556);t.nameFromEnv=function(e){return(0,s.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,r.ensurePrefix)((0,s.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const a=i(19851),o=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),v=i(40583),w=i(81168),b=i(44198),S=i(96706),P=i(34102),_=i(28283),T=i(81075),M=i(98778),E=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){r.add(this),this.opts=e,this._envValue=(0,a.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?n(this,r,"m",s).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?n(this,r,"m",s).call(this,e??t)+": "+i:null==this.fromEnv(e)?n(this,r,"m",s).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,S.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,b.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,o.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,o.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,o.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return T.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,b.env)(),r=t??this.value;return null!=r&&(i[this.key]=this.toEnv(r)),null==e&&S.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,b.env)(),r=this.toEnvValue(t);return null!=r&&(i[this.key]=r,null==e&&S.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,S.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],E.WrapComments);function i(e,i){(0,o.isEmpty)(i)||t.push(...(0,w.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],E.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const r=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,w.wrap)(["",e+": "+r],E.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:E.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},r=new WeakSet,s=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const r=i(50989);t.SettingCategories=(0,r.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const r=i(58587),s=i(76760),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),v=i(79840),w=i(7282),b=i(12801),S=i(4328),P=i(70488),_=i(84248),T=i(5531),M=i(99315),E=i(34365),k=i(34580),D=i(96706),x=i(50274),C=i(33866),F=i(52086),A=i(48584),I=i(45969),O=i(43334),L=i(24540),R=i(70379),N=i(71300),B=i(33209),j=i(48987),z=i(68268),V=i(61208),W=i(99023),U=i(30577),q=i(1485),H=i(19861),$=i(55111),G=i(30933),J=i(22859),K=i(71988),Y=i(38483),X=i(90536),Z=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),re=i(57039),se=i(9945),ne=i(74589),ae=i(844),oe=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,n.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new oe.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new re.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new ne.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new ne.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>q.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:q.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>q.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>O.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new re.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new ne.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:$.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!O.isElectron}),commandTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new r.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new re.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>O.isMac?"100ms":O.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new re.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new Z.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new se.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new ne.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new Z.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>b.PriorityClasses.BelowNormal,strEnum:b.PriorityClasses}),maxMemoryMb:new ne.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new Z.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new ne.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new Z.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:T.CheckpointTypes,defaultValue:T.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:E.SynchronousModes,defaultValue:E.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to apply a migration, vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 2 minutes should be very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"2m"}),dbBackupIntervalMs:new re.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new X.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new ne.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new Z.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new Z.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:C.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new ne.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>O.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new ne.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:U.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,k.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new ne.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new Z.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new Z.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new ne.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new ne.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new Z.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,L.isRaspberryPi)()}),taskTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new ne.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,G.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new Z.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:x.SidecarExts,defaultValue:x.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new Z.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new ne.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new se.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new Z.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new Z.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new Z.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new Z.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new Z.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,G.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:F.CropStrategies.attention,strEnum:F.CropStrategies}),videoFrameAtSec:new se.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,a.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new ne.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(O.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new X.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>B.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new ne.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new ne.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new ne.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:A.SharpFailOns.truncated,strEnum:A.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>j.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>S.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new ne.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:ae.MinValidYear}),maxValidFutureMs:new re.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new se.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new Z.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:z.KeywordReparentingStrategies.move,strEnum:z.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new re.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function be(e){const i=((0,l.blank)(e)?"":e).split(s.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,a.uniq)(i).filter(l.notBlank).join(s.delimiter)}function Se(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=be,t.pathWithDefaults=(0,n.lazy)((()=>be((0,D.getEnv)("PATH")))),t.allSettings=(0,n.lazy)((()=>(0,o.sortBy)((0,d.values)(t.Settings),Se))),t.persistedSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,n.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,n.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,n.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,n.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const r=i(19851),s=i(31586),n=i(7282),a=i(49776),o=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),v=i(15674),w=i(28874);t.setSettingsDefaults=(0,r.lazy)((()=>{w.Settings.configDir.opts.defaultValue=o.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=a.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,n.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,n.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,s.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),v=i(54993),w=i(50213),b=i(81168),S=i(83556),P=i(87290),_=i(98314),T=i(34102),M=i(83278),E=i(95696),k=i(60865),D=i(4175),x=i(83179),C=i(81075),F=i(28874),A=i(41692),I=i(84438),O=i(32707),L=i(6707),R=i(98778),N=i(55018),B=i(10357),j=(0,r.lazy)((()=>(0,w.mkLogger)("settings.SettingsIO")));function z(e){return(0,P.libraryDataDirPosixFile)(e)?.join(I.SettingsToml)}async function V(e=(0,O.systemSettingsFile)()){if(null!=e)return Z(M.BaseFile.for(e))}async function W(){try{return(0,a.toNotBlank)((await(0,L.readTomlFile_)((0,O.systemSettingsFile)()))?.[F.Settings.libraryDir.name])}catch{return}}function U(e){return(0,L.readTomlFile_)(e).then((e=>e?.version),(()=>{}))}function q(){return U((0,O.systemSettingsFile)())}function H(e){return U(z(e))}function $(){t.libraryHasSettings.refresh()}function G(e){const t=z(e);return j().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:F.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}async function J(e,i){if(null==e)return void j().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const r=await e.clear().isNonEmpty(),s=r?e.wip():e;if(await async function(e,i){const r=[(0,g.padding)("#",80)];r.push(...ie("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","This is the version of PhotoStructure that wrote this file--please don't edit the following line.")),r.push(...(0,R.stringifyToml)({version:(0,t.versionForSettings)()})),r.push("","");let s="";for(const e of i){const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==s&&(s=t,r.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),r.push(...e.toTomlLines()),r.push("","")}await e.writeText_("\n"+r.map(y.trimRight).join("\n")+"\n\n"),(0,T.ee)().emitDebounced("settingsChanged")}(s,i),j().info("writeToml(): wrote settings",{dest:s,file:e,nonDefaults:(0,x.settingsToObj)(i),wip:r}),r){const t=await(0,L.readTomlFile_)(s),i=await(0,L.readTomlFile_)(e);(0,u.eql)(t,i)?(j().info("Equivalent contents",{dest:s,file:e,a:t,b:i}),await s.unlink()):(j().info("Archiving prior, different contents",{dest:s,file:e}),await e.renameYMDHMS_({subdir:"archive"}),await s.unwip_())}}async function K(e=(0,O.systemSettingsFile)()){const t=E.PosixFile.forMaybe(e);return null!=t&&await J(t,(0,F.persistedSystemSettings)()),t}function Y(e){return Z(z(e))}async function X(e){await(0,P.setupLibraryDataDir_)((0,a.firstNotBlank)(e,F.Settings.libraryDir.value));const i=z(e);return j().info("writeLibrarySettings()",{file:i}),null!=i&&(await J(i,(0,F.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function Z(e){if(null==e)return[];const t=j().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await Q(e);return(0,s.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,_.errorToS)(e)),[]}}async function Q(e){const t=j().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const r=await(0,L.readTomlFile_)(e);if(null==r)return{settings:[],warnings:["No settings found"]};const n=[],a=(0,s.compact)((0,p.entries)(r).map((([e,t])=>{if("version"===e)return;const i=(0,F.getSettingByNameOrKey)(e);if(null==i)n.push(`Failed to import "${e}"${(0,m.mapOr)((0,F.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;n.push(e)}})));return t.info("loaded",{settings:(0,x.settingsToObj)(a),warnings:(0,s.toNotEmpty)(n)}),await(0,D.handleDeprecatedSettings)(),(0,D.handleMetaSettings)(a),{settings:a,warnings:n}}t.librarySettingsFile=z,t.readSettings=(0,r.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await Y()}),o.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return F.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=q,t.librarySettingsVersion=H,t.maybeUpgradeSystemSettings=async function(){(0,t.versionForSettings)()!==await q()&&await K()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&(0,t.versionForSettings)()!==await H()&&await X()},t.libraryHasSettings=(0,r.lazy)((()=>G())),t.libraryHasSettings.unset=()=>{j().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,T.ee)().on("clearCache",$),(0,T.ee)().on("settingsChanged",$),F.Settings.libraryDir.watchLater($)})),t._libraryHasSettings=G,t.versionForSettings=(0,r.lazy)((()=>(0,k.baseVersion)())),t.writeSystemSettings_=K,t.writeAllSettings_=function(e){return J(E.PosixFile.for(e),(0,F.persistedSettings)())},t.readLibrarySettings=Y,t.writeLibrarySettings_=X,t._readSettings=Z,t.importFileSettings_=Q;const ee=(0,r.lazy)((()=>new Set([F.Settings.noNetwork,F.Settings.httpPort,F.Settings.license,F.Settings.logStdout,F.Settings.logLevel].map((e=>e.key)))));function te(){for(const e of(0,p.values)(F.Settings))ee().has(e.key)||e.unset();(0,T.ee)().emit("settingsChanged")}function ie(...e){return(0,d.flatten)(e.map((e=>(0,b.wrap)(e,B.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),F.Settings.libraryDir.unset(),await K()},t.clearSettings=te,t.nukeSettings=async function(){te(),await(E.PosixFile.forMaybe((0,O.systemSettingsFile)())?.unlink("trace")),await(E.PosixFile.forMaybe(z())?.unlink("trace")),(0,T.ee)().emit("clearCache"),A.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...ie("",`Welcome to PhotoStructure! These are the settings for version ${(0,k.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...ie("","The following settings categories are stored in the system settings.toml:","",...(0,n.sort)([...C.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,n.sort)([...C.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...ie("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...ie("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let r="";t.forEach((e=>{const t=`${(0,b.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const n=`${e.key} or ${e.name}`,a={...e.addToJSON()};(0,s.mapNotEmpty)(e.altKeys,(e=>a.aliases=(0,h.orList)(e)));const o=(0,p.entries)(a).map((([e,t])=>`${(0,b.capitalize)((0,S.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,s.isNotEmpty)(o)&&o.push(""),i.push(...ie((0,g.padding)("-",n.length),n,(0,g.padding)("-",n.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...o,`${e.key}=${(0,f.stringify)((0,v.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const r=i(76760),s=i(40958),n=i(22573),a=i(98553),o=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,a.stringify)(e)}t._join=c;function d(e){return(0,o.map)(function(e){const t=(0,n.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,s.compact)((0,l.toA)(JSON.parse(t)).map(n.notBlankToS))}catch{}for(const e of["¦",r.delimiter])if(t.includes(e))return(0,s.compactBlankish)(t.split(e));return[t]}}(e),s.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,n.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,s.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,s.isEmpty)(e)||(this.value=this.toValidValues((0,s.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,s.isEmpty)(this.values)}isNotEmpty(){return(0,s.isNotEmpty)(this.values)}toNotEmpty(){return(0,s.toNotEmpty)((0,s.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const r=i(83179);class s extends r.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=s},72564:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const r=i(40958),s=i(98553),n=i(55835),a=i(58305);class o extends a.StringArraySetting{constructor(e){super({toEnv:e=>(0,n.map)(e,(e=>(0,s.stringify)((0,r.uniq)(e)))),fromEnv:t=>function(e,t){return(0,r.compact)((0,a.splitStringArray)(e)?.map((e=>t.getCI(e))))}(t,e.strEnum),defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=o},80372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const r=i(22573),s=i(81168),n=i(83179);class a extends n.Setting{constructor(e){super({toEnv:o,fromEnv:o,...e})}hasValue(){return(0,r.notBlank)(this.value)}}function o(e){return null==e?void 0:(0,s.trimQuotes)(e)}t.StringSetting=a},32707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const r=i(76760),s=i(55835),n=i(46292),a=i(84438);t.systemSettingsFile=function(){return(0,s.map)((0,n.configDir)(),(e=>(0,r.join)(e,a.SettingsToml)))}},80496:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const r=i(50989);t.TagInferenceSettingValues=(0,r.strEnum)("never","always","auto")},6707:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const r=i(90858),s=i(44652),n=i(22573),a=i(76850),o=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,a.debom)(e),(0,n.blank)(t)?void 0:(0,r.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,n.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,s.readFileSync)(t)):void 0}catch(e){return void(0,o.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,n.mapNotBlank)(e,(async e=>f(await(0,s.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,s.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const r=i(22573),s=i(96249),n=i(98553),a=i(68708),o=i(51926);function l(e,t,i){if((0,r.blank)(e))throw new Error("kvToToml(): Blank key");const s=e+" = "+(0,n.stringifyPretty)(t);return(0,r.blank)(i?.prefix)?[s]:(0,o.wrap)(s.split("\n"),i)}t.stringifyToml=function(e){return(0,s.flatten)((0,a.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,r.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,o.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const r=i(98553);t.valueToS=function(e){return(0,r.stringify)(e,void 0,2)}},63225:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.verifyPsEnvSettings=void 0;const r=i(68708),s=i(81168),n=i(44198),a=i(59958),o=i(28874);t.verifyPsEnvSettings=function(e=(0,n.env)(),t=.25){const i=[];for(const n of(0,r.keys)(e).filter((e=>{const t=e.toUpperCase();return t.startsWith("PS_")&&!a.IgnorableEnvKeys.includes(t)}))){const r=e[n],a=(0,o.ciSettings)().lookup(n);if(null!=a){const e=a.value.whyInvalidEnvValue(r);null!=e&&i.push({envKey:n,msg:e})}else{const e=(0,o.ciSettings)().lookupNearest(n,t);null==e?i.push({envKey:n,msg:`No setting was found like "${n}"`}):(0,s.equalsIgnoreCase)(e.key,n)||i.push({envKey:n,msg:`Did you mean setting "${e.value.key}"?`})}}return i}},10357:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const r=i(54993),s=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=a(e[t]);if(null!=i)return i}};const n=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function a(e){const t=(0,s.extractFloat)(e);if(null==t)return;const i=(0,r.toS)(e).toLowerCase();for(const e of n)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const r=i(4001),s=i(81168);t.bname=function(e,t=!0){let i=(0,s.isString)(e)?e:e.name;return t&&(i=(0,r.stripCopySuffixFromName)(i)),i=(0,s.trimLeftPadding)((0,r.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),h=i(31586),f=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),v=i(81168),w=i(76596),b=i(79842),S=i(66649),P=i(21330),_=i(98725),T=i(928),M=i(54261),E=i(89724),k=i(17415),D=i(88600),x=i(51275),C=i(29882),F=i(17217),A=i(68284),I=i(57902),O=i(28874),L=i(65162),R=i(71300),N=i(14036),B=i(61424),j=(0,s.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function z(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,f.isObject)(e)&&(0,o.notBlank)(e.nativePath)&&(0,b.isDated)(e.date)&&(0,o.notBlank)(e.src)}t.capturedAtSrcFromTags=z,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class U{static fromAssetFile(e){return(0,d.map)((0,E.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>U.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof U?e:W(e)?new U(e):void 0}constructor(e){var t;this.nativePath=(0,F.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,h.toGt0)(e.local)??(0,E.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,b.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(O.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,S.datedToMillis)(e.mtime)??(0,A.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:U.name,...(0,f.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,_.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,k.fmtOffsetMinutes)});return null==t?void 0:new U({...e,date:t})}spread(e){return new U({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,k.fmtOffsetMinutes)(this.offset)}get isFromTags(){return z(this.src)}get isInferred(){return!z(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,E.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,w.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,x.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,M.hasTime)(this.date)}hasMillis(){return(0,h.gt0)((0,T.getMillisecond)(this.date))}toMillis(){return(0,S.datedToMillis)(this.date)}get isValid(){return(0,D.isValidDate)(this.date)}get zoneName(){return(0,r.offsetMinutesToZoneName)(this.offset)??(0,x.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,k.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?O.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,b.datedToStartDateTime)(this.date)??(0,b.datedToDateTime)(this.date);if(null!=i)return{start:(0,E.datedToLocal)(i.minus(t)),end:(0,E.datedToLocal)(i.plus(t))};j().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:O.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),r=Math.max(t,e.fuzzyPrecisionMs());return j().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,b.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:r}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:r}})}}function q(e,t){if(null==e)return;const i=(0,n.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>U.for(e))));for(const r of t){let t=e[r],s=r;if((0,D.isValidDate)(t)){if((0,k.isValidZone)(e.tz)&&(!(0,x.hasZone)(t)||R.OverrideUTCZoneTags.includes(s))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,o.blank)(e.tzSource)?"":" from "+(0,v.stripPrefix)(e.tzSource,"from ");s+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,E.datedToLocalSec)(t),date:t,src:s,precisionMs:(0,b.datedToPrecisionMs)(t),rawValue:e[r]?.rawValue})}}const r=(0,p.leastBy)(i,(e=>(0,b.datedToStartTs)(e.date)));if(null==r)return;const s=i.filter((e=>(0,u.eql)(e.date,r.date)||e.precisionMs<=r.precisionMs&&(0,b.datedOverlap)({a:e.date,b:r.date,aPrecisionMs:e.precisionMs,bPrecisionMs:r.precisionMs}))),a=(0,p.leastBy)(s,(e=>[Math.floor(e.localSec/1e6),(0,x.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return j().debug("capturedAtFromTags()",{least:r,overlapsWithLeast:s,earliest:a}),a}function H(e,t){if(O.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,n.uniq)([(0,L.bname)(e,!0),(0,L.bname)(e,!1)])){const e=(0,_.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,b.datedToPrecisionMs)(e),l.secondMs])}}}function $(e){if(O.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,_.extractDateFromPath)(e.pathsForDateParsing)}}async function G(e){if(O.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=U,t.bestCapturedAt=function(e){const t=(0,a.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const r=await e.mtimeMs();function s(t,i){return W(i)?U.for(i):null!=i&&null!=i.date&&(0,D.isValidDate)(i.date)?U.for({nativePath:e.nativePath,date:i.date,local:(0,E.datedToLocal)(i.date),src:(0,v.uniqPath)([t,i.src]),mtime:r,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const n=function(e,t){return null==e||t||!O.Settings.usePathsToInferDates.valueOrDefault||!O.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,C.containedByNativePath)({ancestor:O.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),a=s("tags",q(t,O.Settings.capturedAtTags.values))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??s("tags",q(t,O.Settings.capturedAtTagsFallback.values))??(n?void 0:s("bname+stat",await(0,B.extractStatBname)(e)))??(n?void 0:s("path+stat",await(0,B.extractStatPathTime)(e)))??(i?void 0:s("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??(n?void 0:s("bname",H(e,t)))??(n?void 0:s("path",$(e)))??(O.Settings.useStatToInferDates.valueOrDefault?s("stat",await G(e)):void 0);return j().tap({level:I.LogLevels.debug,msg:"extractCapturedAt()",result:a})},t.capturedAtFromTags=function(e){return q(e,O.Settings.capturedAtTags.values)},t.capturedAtFromBasename=H,t.capturedAtFromPath=$,t.capturedAtFromStat=G},70379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const r=i(50989);t.DateTagFormats=(0,r.strEnum)("y","ym","ymd","")},71300:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const r=i(31586),s=i(97352),n=i(95696),a=i(47783),o=i(16170);function l(e){if(null!=e&&(0,o.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,r.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,s.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=n.PosixFile.for(e);return l(await(0,a.readRawTags)(t,!1))}},47783:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const s=i(77988),n=r(i(76760)),a=r(i(1708)),o=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(23838),f=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),v=i(12168),w=i(56038),b=i(4867),S=i(36557),P=i(98247),_=i(21330),T=i(98725),M=i(23467),E=i(88561),k=i(95696),D=i(17217),x=i(16287),C=i(50213),F=i(17921),A=i(7282),I=i(88158),O=i(23560),L=i(28874),R=i(12089),N=i(45255),B=i(81168),j=i(63870),z=i(15674),V=i(28544),W=i(43207),U=i(75767),q=i(12788),H=i(80495),$=i(14036),G=i(67083),J=i(3432),K=i(28630),Y=i(15912),X=i(30748),Z=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),re=i(61424),se=i(8791),ne=(0,o.lazy)((()=>(0,C.mkLogger)("exiftool.ExifTool")));let ae=!1;t.addInstanceIdsToTags=function(e){ae=e},t.setExifToolProcs=function(e){return L.Settings.exiftoolProcsPerChild.envValue=e,ue()};const oe=(0,o.lazy)((()=>new S.BatchClusterObserver("ExifTool",new s.ExifTool({useMWG:L.Settings.useMWG.valueOrDefault,backfillTimezones:L.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:L.Settings.defaultVideosToUTC.valueOrDefault,...(0,S.batchClusterOptions)((0,A.isTest)()?8:(0,O.isSyncService)()?L.Settings.exiftoolProcsPerChild.value??(0,z.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=oe();return e.ended?oe.refresh():e}function ue(e=!1){return(0,d.map)(oe.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,b.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(oe.prior(),(e=>e.ended?void 0:(0,b.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,j.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,o.lazy)((()=>new E.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,f.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,D.toNativePath_)(e))}async function he(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function fe(e){const t=[];return L.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*v.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,B.includesIgnoreCase)(L.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return ne().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const r=i??await(0,te.readMimeType)(e),s=await e.sidecar(),n=(0,Z.isImageMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,a=(0,Z.isVideoMimeType)(r)&&L.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,o=L.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await s.exists(),l=n||a||o;return ne().tap({msg:"writeTagDest()",result:l?s:e,meta:{src:e,tagName:t,mimetype:r,writeMetadataToSidecarsIfImage:n,writeMetadataToSidecarsIfVideo:a,writeMetadataToSidecarsIfSidecarExists:o}})}async function pe(e,i=!0){const r=k.PosixFile.for(e);if(r.isSidecar()&&(i=!1),!await r.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(r.nativePath),void ne().debug("readRawTags("+r+"): invalid file, returning null.");const s=await(0,t._readRawTags)(r.nativePath);if(null==s||!i)return s;ne().trace("readRawTags()",{pf:r,pickedFileTags:(0,f.pick)(s,"tz","tzSource",...L.Settings.capturedAtTags.values)});const n=[];for(const e of await r.jsonSidecars())n.push([e,(0,K.readJsonSidecar)(e,s.tz)]);for(const e of await r.existingExifSidecars())n.push([e,(0,t._readRawTags)(e.nativePath)]);const a={original:{},MIMEType:(0,u.mapNotBlank)(s.MIMEType,Z.normalizeMimetype),...s},o=[];for(const[e,i]of n){if(null==i)continue;const r=await i;if(null==r)continue;const s=(0,f.omit)(r,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,f.values)(s))?((a.sidecars??(a.sidecars=[])).push(e.base),o.push(...(0,g.toA)(r.History)),(0,I.assignNullishFields)(a.original,(0,f.pick)(a,...(0,f.keys)(s))),(0,f.assignFields)(a,s),ne().debug("readRawTags() sidecar had values",{sidecar:e.base})):ne().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return a.inferred=(0,G.getInferredHistoricValues)(o,e),(0,I.assignNullishFields)(a,a.inferred),a.Rotation=(0,Q.orientationToRotation)(a.Rotation),ne().debug("readRawTags() final",{pf:r,inferred:a.inferred,pickedResult:(0,f.pick)(a,"tz","tzSource",...L.Settings.capturedAtTags.values)}),a}async function ge(e,t){return null==t?void 0:(0,w.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,r=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,Z.normalizeMimetype);if((0,u.blank)(r))return void ne().debug("No mimetype for "+i);const n={...t.inferred??{},...t};if(n.inferred??(n.inferred={}),n.original??(n.original={}),L.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const t=n[e];if((0,p.isString)(t)){const i=(0,T.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(ne().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),n[e]=i)}}const o=!await(0,re.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,n,o);if(ne().debug("parseTags()",{tzMeta:l,skipSiblingInference:o}),null!=l?.tz){const e=n.tzSource!==s.defaultVideosToUTC&&void 0;for(const t of[...L.Settings.capturedAtTags.values,...L.Settings.capturedAtTagsFallback.values]){const i=n[t];i instanceof s.ExifDateTime&&(n[t]=(0,_.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,f.assignUndefinedFields)(n.original,n,"tz","tzSource"),(0,f.assignFields)(n,l),(0,f.assignFields)(n.inferred,l)}const c=o?(0,X.extractMakeAndModel)(n):await(0,re.inferMakeAndModel)(e,n);c.Make!==(0,X.make)(n.Make)&&(n.original.Make=n.Make,n.inferred.Make=c.Make),c.Model!==(0,X.model)(c.Make,n.Model)&&(n.original.Model=n.Model,n.inferred.Model=c.Model),!(0,u.blank)(L.Settings.defaultCopyright.valueOrDefault)&&(0,q.isExifUnset)(n.Copyright)&&(n.Copyright=L.Settings.defaultCopyright.valueOrDefault);const d=(0,Y.extractLensMakeModel)(n),h=await(0,V.extractCapturedAt)(e,n,o);if(null==h)return void ne().info("No capturedAt for "+e);!o&&h.isInferred&&(n.inferred.capturedAt=h);const m=(0,H.extractExposureSettings)(n),g=await(0,ie.extractSizeInfoFromFile)(e,n);if(null==g)return void ne().info("No size info for "+i);const y={...c,mimetype:r,capturedAt:h,exposureSettings:m,...(0,se.extractTitleDescription)(n),...d,cameraId:(0,U.cameraIdFromTags)(n),imageId:(0,U.imageIdFromTags)(n),lensId:(0,U.lensIdFromLensInfo)({...d,...(0,f.pick)(n,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(n),tz:n.tz,rating:(0,ee.extractRating)(n)};(0,A.isTest)()&&(y.__parsedBy__=a.default.pid);const v={...n,...y};return ne().debug("parsedTags",{nativePath:i,skipInference:o,...y,inferred:n.inferred,original:n.original,pickedResult:(0,f.pick)(v,"capturedAt","tz","tzSource","Make","Model")}),(0,f.definedValues)(v)}catch(e){return void ne().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,f.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,f.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,M.eqlAsync)(e.sha(),t.sha())||await(0,M.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=k.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,D.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,D.toNativePath_)(e),["-"+t]);return(0,I.pluckCaseInsensitive)(i,t)}catch(e){return void ne().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=he,t.overwriteTags_=async function(e,t){try{await(0,w.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await fe(e)),e.clearThisAndParent()}))}catch(i){ne().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,w.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=fe,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,w.time)("exiftool.writeTags:"+e,(async()=>{const r=new h.MultiMap;for(const[s,n]of(0,f.entries)(t)){const t=await me(e,s,i);r.add(t.nativePath,[s,n])}for(const[t,i]of r.entriesArray()){const r=k.PosixFile.for(t),s=(0,f.fromEntries)(i);ne().info("writeTags()",{src:e,dest:t,t:s}),await le().write(r.nativePath,s,await fe(r)),L.Settings.overwriteOriginal.valueOrDefault||await he(r),r.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,x.nativePathIsFile)(e))return ne().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);ne().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...L.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,$.isVideoExt)(n.default.extname(e))?[]:["-fast"]],r=await(0,w.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{ne().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==r)return;ne().debug("_readRawTags()",{nativePath:e,pickedTags:(0,f.pick)(r,"tz","tzSource",...L.Settings.capturedAtTags.values)}),r.MIMEType=(0,u.mapNotBlank)(r.MIMEType,Z.normalizeMimetype),r.GPSDateTime??(r.GPSDateTime=(0,P.concatDateTime)(r.GPSDateStamp,r.GPSTimeStamp));for(const e of(0,f.keys)(r)){const t=r[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete r[e])}const s=(0,l.compactBlanks)([r.Error,...r.errors??[],r.Warning].map(y.toS));return(0,l.isNotEmpty)(s)&&(r.problems=s),ae&&(r.__instance=(0,F.safeUUID)()),r}}),t.parseTags=ge},75767:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(98553),o=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),h=i(54993),f=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),v=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const w=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function b(e){const t=null==e?[]:e.filter((([,e])=>!(0,n.blank)(e)));return 0===t.length?void 0:(0,a.stringify)((0,u.fromEntries)(t))}function S(e){return(0,h.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new o.MultiMap,r=[];for(const a of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(s=e[a])||(0,n.blankish)(s)||(0,l.isNumber)(s)&&(0===s||1===s)||null!=t.zeroesRe.exec((0,h.toS)(s)))continue;const o=e[a],u=S(e[a]),c=(0,t.Tag2SynonymGroup)().get(a);if(null!=c){if(i.includes(c,o)||i.includes(c,u))continue;i.add(c,o)}r.push([a,(0,l.gt0)(o)?o:u])}var s;return b(r)}function _(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function T(e){if((0,n.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([_(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(_)):(0,u.compactBlankValues)(t)}function M({a:e,b:t,field:i,desc:r,parser:s}){const n=s(e[i]),a=s(t[i]),o=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==n||null==a||(0,l.approximates)(n,a,o)?void 0:"Different "+r+": "+e[i]+" ≠ "+t[i]}function E(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,n.blank)(e.lensMake)||(0,n.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,r.lazy)((()=>{const e=new Map;for(const t of w){const i=t[0];for(const r of t)e.set(r,i)}return e})),t.Tag2Synonyms=(0,r.lazy)((()=>{const e=new Map;for(const t of w)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=b,t.renderExifUidId=P,t.decodeExifUid=T,t.findInequalFields=function(e,i){const r=T(e),n=T(i);if(null==r||null==n||e===i)return;const a=(0,f.intersection)((0,u.keys)(r),(0,u.keys)(n)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of a){const t=r[e],i=n[e];if(S(t)!==S(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of w){const t=(0,u.pick)(r,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(n,...e);if((0,u.isEmptyObj)(i))continue;const a=(0,u.values)(t).map(h.toS),o=(0,u.values)(i).map(h.toS);if((0,s.includesAny)(a,o))continue;const l=(0,f.least)((0,u.keys)(t)),c=(0,f.least)((0,u.keys)(i));return{aKey:l,aValue:r[l],bKey:c,bValue:n[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>M({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>M({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>M({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>M({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return E({...(0,v.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=E,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const r=i(22573),s=i(54993),n=/undefined|null|none|n\/a|unknown/i;function a(e){return null==e||(0,r.blank)(e)||n.test((0,s.toS)(e))}t.isExifUnset=a,t.toExifDefined=function(e){return a(e)?void 0:e}},80495:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const r=i(19851),s=i(22573),n=i(31586),a=i(68708),o=i(54993),l=i(50213),u=i(97352),c=(0,r.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,s.firstNotBlank)((0,o.toS)(e.ExposureTime),(0,o.toS)(e.ShutterSpeed),(0,o.toS)(e.ShutterSpeedValue),(0,o.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,a.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,n.gt0)(e))return e;const[t,i]=(0,o.toS)(e).split("/").map((e=>(0,n.toInt)(e)));return(0,n.gt0)(t)&&(0,n.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,n.toFloat)(e);return(0,n.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const r=i(50989);t.ExtTypes=(0,r.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const r=i(19851),s=i(40958),n=i(96249),a=i(23838),o=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,r.lazy)((()=>{const e={};for(const[i,r]of(0,o.entries)(t.AllFiletypes))for(const t of r)e[t]=i;return e})),m=(0,r.lazy)((()=>{const e={};for(const i of(0,o.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AllFiletypes))))),t.AssetFileExts=(0,r.lazy)((()=>(0,s.uniq)((0,n.flatten)((0,o.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,r.lazy)((()=>{const e=new a.MultiMap;for(const{exts:i,type:r}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,n.flatten)((0,o.values)(i)))e.add(t,r);for(const i of t.OldBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const r of t.AllFiletypes[i]??[])e.add(r,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function v(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),r=(0,c.normalizeExt)(t);return null!=i&&null!=r&&(i===r||(p(i)?.includes(r)??!1))},t.extTypes=y,t.isExtType=v,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return v(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return v(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return v(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return v(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return v(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return v(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),h=i(50989),f=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),v=i(50213),w=i(81168),b=i(66649),S=i(17415),P=i(29882),_=i(95696),T=i(17217),M=i(28874),E=i(47783);function k(e,t){return(0,d.entries)(t??{}).map((([t,i])=>D({action:e,key:t,value:i})))}function D({action:e,key:t,value:i,ts:s}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:r.ExifDateTime.fromMillis(s??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,h.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=k,t.mkHistoryRecord=D,t.InferAction="infer";const x=(0,s.lazy)((()=>(0,v.mkLogger)("tags.History")));function C(e,t){if(null==e||null==e.History||(0,f.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function F(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,o.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function A(e){if(null==e)return;const t={};for(const[i,r]of(0,d.entries)(e))(0,w.isFirstCharAZ)(i)&&(t[i]=r);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,S.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function I(e,i,r){if(null==e||(0,o.blank)(e))return void x().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const s=(0,T.toNativePath_)(e),a=await(0,E._readRawTags)(s),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!C(a,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...r??{}};if((0,n.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void x().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:r,tagsToWrite:c});x().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:r});const h=_.PosixFile.for(e);return await(0,E.overwriteTags_)(h,c),h.clearThisAndParent(),u}t.tagsContainHistory=C,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const s=(0,m.toA)(e);if((0,n.isEmpty)(s))return{};const l=(0,a.sortBy)(s.filter((e=>(0,w.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,b.datedToMillis)((0,o.mapNotBlank)(e.When,(e=>r.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,o.notBlank)(t)){const r=F(e);(0,o.blank)(r.nativePath)||(0,P.eqlNameWithoutExt)(r.nativePath,i)?u[t]=r:x().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=F,t.inferredToTags=A,t.ensureInferredHistoryRecords=async function(e,i,r){const s=k(t.Actions.infer,r),n=(M.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?A(r):void 0)??{};return M.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(n.Source=e.nativePath),x().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:s,additionalTags:n}),I(i,s,n)},t.ensureHistoryRecords=I},3432:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const s=r(i(53705)),n=i(77988),a=i(19851),o=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),h=i(17415),f=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),v=i(61424),w=(0,a.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function b(e,t,i){{const e=S(t);if(null!=e&&(0,h.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,h.isValidZone)(t.tz)||t.tzSource===n.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,o.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof n.ExifDateTime&&(0,h.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,v.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function S(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,s.default)(t,i),r=(0,h.normalizeZone)(e);return w().tap({msg:"zoneFromLatLon()",result:r,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,f.isValidDate)(i))for(const r of g.Settings.capturedAtTags.values){const s=(0,u.toDated)(t[r]);if(null==s||(0,f.isValidDate)(s))continue;const n=Math.round(15*i.diff(s,"minutes").as("minutes")/15),a=(0,h.normalizeZoneOffsetMinutes)(n),o=0===a?void 0:(0,h.normalizeZone)(a);if(null!=o)return w().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:o.name,tzSource:"infer:filename (diff with "+r+")"},meta:{dt:(0,c.datedToISO)(s),rawTzoffsetMinutes:n,normalizedOffsetMinutes:a}})}}t.maybeInferTimezone=async function(e,t,i){return w().tap({msg:"maybeInferTimezone()",result:await b(e,t,i)})},t.zoneFromLatLon=S,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const r=i(77988),s=i(40958),n=i(22573),a=i(38639),o=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),h=i(48884),f=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const s=(0,p.normalizeZone)(e?.formatted),n=r.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:s??t??r.UnsetZone});if(!0===n?.isValid)return n}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,n.toNotBlank)(e.title),Description:(0,n.toNotBlank)(e.description),GPSLatitude:(0,h.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,f.validLat)(e)?e:void 0)),GPSLongitude:(0,h.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,f.validLon)(e)?e:void 0)),GPSAltitude:(0,h.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,o.map)(e.favorited,a.isTrue),peopleNames:(0,s.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,s.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const r=i(50989);t.KeywordReparentingStrategies=(0,r.strEnum)("move","copy","retain")},97573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rawTagKeywords=t.parseKeywordStruct=t.isKeywordStruct=t.parseCategories=t.splitKeywords=t.splitKeyword=t.delimRe=t.keywordToPath=void 0;const r=i(77988),s=i(66150),n=i(19851),a=i(40958),o=i(22573),l=i(41400),u=i(96249),c=i(68708),d=i(59455),h=i(48884),f=i(50213),m=i(68852),p=i(81168),g=i(28874),y=(0,n.lazy)((()=>(0,f.mkLogger)("tags.KeywordTags"))),v=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordPathSeparators.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g")))));function w(e){const i=(0,t.delimRe)();return null==i?[e]:(0,a.compactBlanks)(e.split(i))}function b(e){return null==e||e instanceof r.BinaryField?[]:(0,a.compactBlanks)(Array.isArray(e)?(0,u.flatten)(e.map(b)):w(e))}function S(e){return null==e?[]:(0,p.isString)(e)?(0,o.blank)(e)?[]:[[e]]:(0,u.flatten)((0,d.toA)(e.Category).map(S).map((t=>t.map((t=>(0,a.compact)([e._,...t]))))))}(0,l.later)((()=>{g.Settings.keywordPathSeparators.watchLater((()=>v.unset()))})),t.keywordToPath=function(e){const t=v();return(0,a.compactBlanks)(null==t?[e]:e.split(t))},t.delimRe=(0,n.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g"))))),g.Settings.keywordDelimiters.watchLater((()=>t.delimRe.unset())),t.splitKeyword=w,t.splitKeywords=b;const P=/^\(?none\)?$/i;function _(e){if(!(0,o.blank)(e)&&null==P.exec(e))try{const t=new s.XMLParser({textNodeName:"_"}).parse(e);return(0,u.flatten)((0,d.toA)(t?.Categories?.Category).map(S))}catch(t){return void y().warn("parseCategories() failed:",{err:t,s:e})}}function T(e){return Array.isArray(e)&&e.every(T)||null!=e&&(0,p.isString)(e.Keyword)&&(null==e.Children||Array.isArray(e.Children)&&e.Children.every(T))}function M(e){if(null==e)return[];if(Array.isArray(e)&&e.every(T))return(0,h.flatMap)(e,M);if((0,o.blank)(e.Keyword))return[];const t=(0,d.toA)(e.Children);return(0,a.isEmpty)(t)?[[e.Keyword]]:(0,h.flatMap)(t,M).map((t=>[e.Keyword,...t]))}t.parseCategories=_,t.isKeywordStruct=T,t.parseKeywordStruct=M,t.rawTagKeywords=function(e){const t=[];if(null!=e){const i=[...g.Settings.keywordTags.values];if(i.includes("Categories")){(0,h.remove)(i,"Categories");const r=_(e.Categories);null!=r&&t.push(...r)}for(const r of i){const i=(0,c.pluckDeep)(e,r)?.value;(0,o.blank)(i)||(T(i)?t.push(...M(i)):t.push(...Array.isArray(i)?i:b(i)))}}return y().tap({msg:"rawTagKeywords()",result:(0,a.compactBlankish)((0,a.uniq)(t)),meta:{t:null==e?void 0:(0,c.pick)(e,...g.Settings.keywordTags.values)}})}},15912:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(55835),o=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),h=i(28874),f=i(30748),m=(0,r.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,f.make)(e.LensMake),i=(0,f.make)(e.Make),r=[],o=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],b),u=(0,s.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:o,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&r.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==b(e))continue;(0,n.notBlank)(t)&&r.push({lensMake:t,lensModel:e,lensInfo:o});const a=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))a.includes(t)&&r.push({lensMake:i,lensModel:e,lensInfo:o});for(const i of(0,s.compactBlanks)([t,...h.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&r.push({lensMake:i,lensModel:e,lensInfo:o});a.startsWith("vr ")&&"Nikon"===i&&r.push({lensMake:"Nikon",lensModel:e,lensInfo:o})}for(const e of r){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=S(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,a.map)(e.lensInfo,S)}return(0,c.greatestBy)(r,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const v=/([\d. -]+)\s?mm\b/i,w=/\bf\/?([\d.\-]+)/i;function b(e){if((0,n.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=v.exec(e)?.[1].replace(/\s/g,""),i=w.exec(e)?.[1];return y(t)&&y(i)?S(`${t}mm f/${i}`):void 0}function S(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,a.mapOr)((0,o.toFloat)(e),(e=>String((0,o.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=b,t.cleanBogusPrecision=S,t.normalizeLensModel=function(e){return S(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(68708),o=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function h(e,t,i=""){const r=e.replace(t,i);return r===e?e:h(r,t,i)}const f=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=f.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,r.lazy)((()=>new p)),y=/\bgopro\b/i;function v(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=h(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=v(e.Make)??b(e.Software)??b(e.CreatorTool)??function(e){return y.test((0,o.toS)(e.HandlerDescription))||y.test((0,o.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,a.compactValues)({Make:t,Model:i})??{}},t.make=v;const w={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function b(e){if(!(0,s.blank)(e))for(const[t,i]of(0,a.entries)(w))if(i.test(e))return t}t.makeFromSoftware=b;const S=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=S.exec(i);null!=e&&(i=e[1].trim())}const r=(0,n.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=r)return r[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,n.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=h(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},38010:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MergedTags=t.revisionToResourceEvent=t.resourceEventToRevision=t.isSetRevision=t.isPrimitiveRevision=t.isBaseRevision=void 0;const r=i(77988),s=i(19851),n=i(40958),a=i(76790),o=i(22573),l=i(55835),u=i(31586),c=i(68708),d=i(67478),h=i(59455),f=i(54993),m=i(72993),p=i(50213),g=i(84885),y=i(66649),v=i(98725),w=(0,s.lazy)((()=>(0,p.mkLogger)("tags.MergedTags")));function b(e){return(0,u.isNumber)(e?.createdAt)&&(0,o.notBlank)(e?.field)}function S(e){return null==e?.op&&b(e)}function P(e){return e?.sourceIsPrimary??e?.shown??!1}function _(e){return e?.sourceModifiedTime??e?.mtime??0}t.isBaseRevision=b,t.isPrimitiveRevision=S,t.isSetRevision=function(e){return["add","delete"].includes(e?.op)&&b(e)},t.resourceEventToRevision=function(e){if(null==e||!(0,f.toS)(e.SoftwareAgent).startsWith((0,m.AppName)()))return w().tap({msg:"resourceEventToRevision() invalid",result:void 0,meta:{resourceEvent:e}});const t=e.Changed;if((0,o.blank)(t))return w().tap({msg:"resourceEventToRevision() missing Changed field name",result:void 0,meta:{resourceEvent:e}});const i=(0,c.pick)((0,o.mapNotBlank)(e.Parameters,d.parseJSON)??{},"newValue","priorValue");if((0,c.isEmptyObj)(i))return w().tap({msg:"resourceEventToRevision() missing Parameter fields",result:void 0,meta:{resourceEvent:e}});const r=(0,y.datedToMillis)((0,v.parseDated)({input:e.When}));return null==r?w().tap({msg:"resourceEventToRevision() missing createdAt (When)",result:void 0,meta:{resourceEvent:e}}):(0,o.blank)(e.Action)?w().tap({msg:"resourceEventToRevision() missing op (Action)",result:void 0,meta:{resourceEvent:e}}):w().tap({msg:"resourceEventToRevision()",result:{createdAt:r,field:t,op:"assign"===e.Action?void 0:e.Action,...i},meta:{resourceEvent:e}})},t.revisionToResourceEvent=function(e){return{Action:e.op??"assign",Changed:e.field,InstanceID:(0,l.map)(e.id,f.toS),Parameters:(0,g.stringifySorted)((0,c.pick)(e,"newValue","priorValue")),SoftwareAgent:(0,m.AppNameVersion)(),When:r.ExifDateTime.fromMillis(e.createdAt??Date.now())}},t.MergedTags=class{constructor(e){this.name=e,this.revisions=[],this.tags=[],this.logger=(0,p.mkLogger)(`MergedTags(${e})`)}addRevision(...e){this.revisions.push(...e)}addTag(...e){this.tags.push(...e),(0,a.sortBy)(this.tags,(e=>[!P(e),-_(e)]))}get(e){const t=(0,a.sortBy)(this.revisions.filter((t=>t.field===e)),(e=>e.createdAt)),i=this.tags.find((t=>null!=t[e]));let r=i?.[e];const s=[];var l;null!=r&&(0,o.mapNotBlank)((l=i,l?.SourceFile??l?.uri),(e=>s.push(e)));const u=t.every(S)&&this.tags.every((t=>!Array.isArray(t[e])));if(u){for(const i of t)null!=r&&r!==i.priorValue&&r!==i.newValue?this.logger.info("get("+e+"): skipping revision because expected prior or new value didn't match current value",{revision:i}):(r=i.newValue,s.push(`Revision@${i.createdAt}`));return null==r?void 0:{value:r,source:s}}{const e=(0,h.toA)(r);for(const i of t)if("add"===i.op&&null!=i.newValue)s.push(`Revision@${i.createdAt}`),(0,n.pushUniq)(e,...(0,h.toA)(i.newValue));else if("delete"===i.op&&null!=i.priorValue){s.push(`Revision@${i.createdAt}`);for(const t of(0,h.toA)(i.priorValue))(0,n.remove)(e,t)}return{value:e,source:s}}}}},16170:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const r=i(22573),s=i(54993),n=i(2322),a=i(277),o=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function h(e){return(0,r.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function f(e){const t=(0,s.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,n.isChrome)(t)||(0,n.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,s.toS)(e))},t.isImageMimeType=function(e){return(0,s.toS)(e).startsWith("image/")},t.isVideoMimeType=h,t.normalizeMimetype=f,t.isSharpMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,r.blank)(e)&&f(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,r.blank)(t)&&(h(t)?await(0,l.isVideoSupported)():(0,o.isHeifMimeType)(t)?await(0,a.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const r=i(50989);t.NameTagFormats=(0,r.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const r=i(50989);t.NameTagOrders=(0,r.strEnum)("western","eastern")},66039:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderNameTag=t.parseName=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(55835),l=i(75020),u=i(59455),c=i(50213),d=i(68852),h=i(81168),f=i(70417),m=i(28874),p=(0,r.lazy)((()=>(0,c.mkLogger)("tags.Names")));function g(e){return(0,d.matchQuotes)((0,d.escapeRegExp)(e))}const y=/(\(\s*\d+\s*-\s*[\d?]{0,4}\s*\)?)/,v=/([,\s]+(?:jr\.?|junior|sr\.?|senior|[iv]+\.?))$/i,w=/\b([A-Z‘’']+[-A-Z‘’']{2})\b/,b=/^[()[\]/.\-_]+$/;function S(e){if((0,a.blank)(e))return;let t=e.replace(/\s+/g," ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").trim();const i=(0,o.map)((0,h.spliceCapture)(t,y),(e=>(t=e.unmatched.trim(),e.captured.replace(/\s+/g,"")))),r=(0,o.map)((0,h.spliceCapture)(t,v),(e=>(t=e.unmatched.trim(),e.captured.trim()))),l=[],c=[],b=[];for(const e of m.Settings.tagNamesGiven.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(l.push(i.captured),t=i.unmatched.trim())}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesGivenSurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`(${(0,d.escapeRegExp)(e.charAt(0))}\\s*[^${(0,d.escapeRegExp)(e.charAt(0))}]+\\s*${(0,d.escapeRegExp)(e.charAt(1))})`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(c.push(i.captured),t=i.unmatched.trim())}while(null!=i)}let S;function _(e){(null==S||S>e.matchedIndex)&&(S=(0,f.min)([S,e.matchedIndex]))}if(m.Settings.tagNamesCapitalizedAsFamily.valueOrDefault){let e;do{e=(0,h.spliceCapture)(t,w),null!=e&&(_(e),b.push(e.captured),t=e.unmatched.trim())}while(null!=e)}for(const e of function(){const e=(0,s.compactBlanks)(m.Settings.tagNamesFamilySurrounds.values);for(const t of e)2!==t.length&&p().warn("Settings.tagNamesFamilySurrounds has an invalid value:",t);return e.map((e=>new RegExp(`${(0,d.escapeRegExp)(e.charAt(0))}\\s*([^${(0,d.escapeRegExp)(e.charAt(0))}]*)\\s*${(0,d.escapeRegExp)(e.charAt(1))}`,"i")))}()){let i;do{i=(0,h.spliceCapture)(t,e),null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}while(null!=i)}if(m.Settings.tagNamesLexical.valueOrDefault){const e=t.indexOf(",");e>=0&&(S=void 0,b.push(t.substring(0,e).trim()),l.push(t.substring(e+1).trim()),t="")}for(const e of m.Settings.tagNamesSurnames.values.map((e=>new RegExp("\\b("+g(e)+")\\b","i")))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}for(const e of(0,u.toA)((0,s.mapNotEmpty)((0,s.compactBlanks)(m.Settings.tagNamesSurnamePrefixes.values),(e=>(0,n.sortBy)(e,(e=>-e.length)).map((e=>new RegExp(`\\b(${g(e)}\\s+\\S+)`,"i"))))))){const i=(0,h.spliceCapture)(t,e);null!=i&&(_(i),b.push(i.captured),t=i.unmatched.trim())}null!=S&&t.length>S&&(0,s.mapNotEmpty)((0,s.compactBlanks)(t.slice(S).split(/\s+/)),(e=>{b.push(...e),t=t.slice(0,S)}));const T=(0,s.compactBlanks)(t.split(/\s+/)),M=l.length,E=b.length;if(T.length>0)if(0===M&&E>0)l.push(...T);else if(0===E&&M>0&&1===T.length)b.push(...T);else if(1===T.length)l.push(...T);else{const e="western"===m.Settings.tagNamesOrder.valueOrDefault;b.push(e?T.pop():T.shift()),l.push(...T)}return{givenNames:P([...l,...c]),modifier:r,lifespan:i,familyNames:P(b),minFamilyNameIndex:S}}function P(e){return(0,s.uniq)((0,s.compactBlanks)(e).filter((e=>null==b.exec(e))))}function _(e){let t="";for(const i of(0,s.compactBlanks)(e))t+=i.startsWith(",")?i:" "+i;return t.trim()}function T(e,t,i){return _("western"===m.Settings.tagNamesOrder.valueOrDefault?[t,e,i]:[e,t,i])}t.parseName=S,t.renderNameTag=function(e){if((0,a.blank)(e))return[];const t=m.Settings.tagNamesFormatter.valueOrDefault,i="family/given"===t;if("family/fullname"===t||i){const t=S(e);if(null==t)return[];{const e=_([t.modifier,t.lifespan]),r=_(t.givenNames);return(0,s.compactBlanks)((0,s.notEmptyOr)(t.familyNames,[m.Settings.tagNamesDefaultFamily.valueOrDefault])).map((t=>[l.TagRoots.Who,t,i?_([r,e]):T(t,r,e)]))}}return[[l.TagRoots.Who,e.trim()]]}},95141:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const r=i(21605),s=i(54993),n=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,n.isVideoMimeType)(e.MIMEType)?(0,r.normalizeRotation)(e.Rotation):void 0)??o(e.Orientation)};const a=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function o(e){return(0,r.isRotation)(e)?e:null!=e?a.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,s.toS)(e).startsWith("Mirror")},t.orientationToRotation=o;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,r.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,r.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const r=i(55835),s=i(31586),n=i(28874);function a(e){const t=(0,s.toInt)(e);return null==t?void 0:(0,s.clamp)(-1,5,t)}function o(e){return a(e?.Rating)??(0,s.mapNumeric)((0,s.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,r.map)(e?.favorited,(e=>!0===e?n.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=a,t.extractRating=o,t.extractLiked=function(e){const t=o(e);return null==t?void 0:t>=n.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const r=i(19851),s=i(22573),n=i(55835),a=i(88561),o=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,r.lazy)((()=>new a.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,s.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,n.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,o.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const r=i(16928),s=i(40958),n=i(22573),a=i(81168),o=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,a.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const o=(0,u.isJsonExt)(i.ext),l=o||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,r.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=o||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,s.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,s.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return o&&function(e,i){const r=(0,a.commonPrefixIgnoreCase)(e,i);if(r.length<8)return!1;function s(e){return(0,n.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const o=s(e.slice(r.length)),l=s(i.slice(r.length));return o&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,o.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,a.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const r=i(19851),s=i(22573),n=i(42659),a=i(33374),o=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),h=i(34943),f=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),v=(0,r.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),w=(0,r.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:n.minuteMs})));async function b(e,t){if(null==e)return;const i=null==t||(0,s.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const r=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return S(i,r,await(0,h.rawInfo)(e));const n=S(i,r);if(null!=n)return n;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await b(await(0,f.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function S(e,t,i){t??(t=(0,y.extractRotation)(e));const r=(0,o.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,a.isDimensions)(e)?e:void 0));if(null==r)return v().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo,fileDimensions:r}});const s=(0,a.maybeDimSwap)(r,t);return v().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:s.height,ImageWidth:s.width,aspectRatio:(0,d.aspectRatio)(s),dimensions:s,rotation:t,fileDimensions:r,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return w().getOrSetAsync(i.nativePath,(()=>b(i,t)))},t.extractSizeInfoFromTags=S},3127:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tag_fts_path=t.tag_fts_root=void 0;const r=i(54993),s=i(42231);t.tag_fts_root=function(e){const t=(0,r.toS)(e).indexOf(s.TagSep);return-1===t?"":e.substring(0,t)},t.tag_fts_path=function(e){return(0,r.toS)(e).split(s.TagSep).filter((e=>null!=e&&""!==e.trim())).join(" ")}},61424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const r=i(77988),s=i(51168),n=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),h=i(48884),f=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),v=i(79842),w=i(21330),b=i(98725),S=i(51275),P=i(35280),_=i(19748),T=i(88561),M=i(95696),E=i(65238),k=i(17217),D=i(57902),x=i(28874),C=i(80496),F=i(65162),A=i(28544),I=i(47783),O=i(88840),L=i(30748),R=i(16170),N=(0,n.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),B=7;async function j(e){return x.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+x.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(x.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.auto&&await(0,E.isSlowDir)(e.nativePath)&&!await(0,E.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function z(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of r){const r=(0,L.extractMakeAndModel)(await(0,I.readRawTags)(t));if((0,f.definedAndNotEql)(r.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:r});else if((0,f.definedAndNotEql)(r.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:r});else if(null!=r.Make&&null!=r.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:D.LogLevels.info,result:r,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await j(e.parent()))return;const t=await W(e);return null!=t&&(0,w.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,w.toExifDateTime)(t.before.date,(0,S.getZoneName)(t.before.date)),(0,w.toExifDateTime)(t.after.date,(0,S.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,n.lazy)((()=>new T.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await H(e),i=await z(t?.younger),r=await z(t?.older);return null==i||null==r?void 0:{before:i,after:r,index:i.index,slots:i.index+r.index+1}}))}t.beforeAfterCapturedAt=W;const U=(0,_.extFilter)(O.ExtTypes.AssetFile);function q(e){return null==e?[]:(0,a.compact)((0,h.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function H(e,t=7,i=!0){if(!await j(e.parent()))return;const r=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(U(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==r)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const s=(0,o.sortBy)(r,(e=>(0,F.bname)(e))),n=(0,k.findFileIndex)(e,s);if(n<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),H(e,t,!1)):void 0;const l=x.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[s.slice(n-2*t,n),s.slice(n+1,n+1+2*t)],d=[],h=[];for(;(0,a.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,a.isNotEmpty)(c)&&h.length=l&&h.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:h},meta:{f:e}})}t.nearestSiblings=H,t.nearestSiblingTzOffset=async function(e){if(!await j(e.parent()))return;const t=q(await H(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,B);for(const t of e){const e=await(0,I.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==r.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,a.uniq)([(0,F.bname)(e,!0),(0,F.bname)(e,!1)]),i=(0,b.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const r=await e.stat();if(null!=r){for(const e of["birthtime","atime","mtime","ctime"])if((0,v.datedOverlap)({a:i,b:r[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:r}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:r}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,b.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const r=i[e];if(null!=r&&!0===(0,v.datedOverlap)({a:t,b:r}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:s.DateTime.fromJSDate(r)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(55835),o=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),h=i(81168);function f(e){return(0,u.toS)((0,o.isString)(e)?e:e?.name).normalize()}function m(e){return(0,r.compact)((0,l.toA)(e).map(f))}function p(e,i=t.TagSep){return m(e).map((e=>(0,o.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(n.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function v(e){return(0,n.blank)(e)?void 0:Array.isArray(e)?f((0,r.last)(e)):(0,r.last)(g(e))}function w(e,t){if((0,r.isEmpty)(e)||(0,r.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,h.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=f,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,r.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,r.uniqBy)((0,l.toA)(e),(e=>(0,r.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,r.compact)(t).map((e=>y(e))));return(0,r.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=v,t.leafIsExcluded=function(e,t){return(0,a.mapOr)(v(e),(e=>(0,h.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=w,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,s.sortBy)(e.filter(r.isNotEmpty),(e=>-e.length)))t.some((e=>w(i,e)))||t.push(i);return(0,s.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const r=i(40958),s=i(22573),n=i(68708),a=i(54993);t.extractTitleDescription=function(e){const t=(0,r.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,s.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const r of i){const i=(0,a.toS)(e[r]).trim();if((0,s.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,n.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(96249),o=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),v=(0,r.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function w(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function b(e){const t=await w(e);return(0,s.uniq)((0,a.flatten)(t.map(m.uriEncodingVariants)))}async function S(e,t){if((0,n.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void v().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case o.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case o.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case o.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,n.blank)(e)?v().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=w,t.nativePath2uriVariants=b,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(S(e,t),b))),(0,s.uniq)(i)},t.uri2nativePath=S,t.uriExists=async function(e,t){const i=await S(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const r=i(76760),s=i(57975),n=i(90595),a=i(22573),o=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",v=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class w{static isUri(e){return e instanceof w||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,r,s,n=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,n),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(r??""),this.fragment=s??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,n))}get fsPath(){return M(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:r,query:s,fragment:n}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===r?r=this.path:null===r&&(r=g),void 0===s?s=this.query:null===s&&(s=g),void 0===n?n=this.fragment:null===n&&(n=g),t===this.scheme&&i===this.authority&&r===this.path&&s===this.query&&n===this.fragment?this:new S(t,i,r,s,n)}static parse(e,t=!1){const i=v.exec(e);if(!i)return new S(g,g,g,g,g);const r=i[2]||g,s=x(i[4]||g),n=(i[5]||g).split("/").map(x).join("/"),a="psfile"===r&&n.startsWith("//")?n.slice(1):n,o=(0,u.toURLSearchParams)(i[7]),l=x(i[9]||g);return new S(r,s,a,o,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new S("file",t,e,g,g)}static from(e){return new S(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?w.file(r.win32.join(M(e,!0),...t)).path:r.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,o.map)(this.path,(e=>(0,d.findLast)(e.split(y),a.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return E(this,e)}toJSON(){return this}[s.inspect.custom](){return this.toString()}}t.URI=w;const b=h.isWinPortable?1:void 0;class S extends w{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=M(this,!1)),this._fsPath}toString(e=!1){return e?E(this,!0):(null==this._formatted&&(this._formatted=E(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=b),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,a.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function _(e,t){let i,r=-1;for(let s=0;s=97&&n<=122||n>=65&&n<=90||n>=48&&n<=57||45===n||46===n||95===n||126===n||t&&47===n)-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),void 0!==i&&(i+=e.charAt(s));else{void 0===i&&(i=e.substr(0,s));const t=P[n];void 0!==t?(-1!==r&&(i+=encodeURIComponent(e.substring(r,s)),r=-1),i+=t):-1===r&&(r=s)}}return-1!==r&&(i+=encodeURIComponent(e.substring(r))),void 0!==i?i:e}function T(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function E(e,t){const i=t?T:_;let r="";const{scheme:s,query:n,fragment:o}=e;let{authority:l,path:u}=e;if(s&&(r+=s,r+=":"),(l||"file"===s)&&(r+=y,r+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?r+=i(t,!1):(r+=i(t.substr(0,e),!1),r+=":",r+=i(t.substr(e+1),!1)),r+="@"}e=l.indexOf(":"),-1===e?r+=i(l,!1):(r+=i(l.substr(0,e),!1),r+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}r+=i(u,!0)}return(0,a.mapNotBlank)(n,(e=>r+="?"+e)),o&&(r+="#",r+=t?o:_(o,!1)),r}function k(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+k(e.substr(3)):e}}t.encodeURIComponentFast=_,t.uriToFsPath=M;const D=/(?:%[\dA-Z][\dA-Z])+/gi;function x(e){return e.startsWith("xn--")?(0,n.toUnicode)(e):e.match(D)?e.replace(D,(e=>k(e))):e}t.percentDecode=x,t.toURI=function(e){return w.isUri(e)?e:w.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const r=i(19851),s=i(40958),n=i(50357),a=i(89937),o=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",a.PS_LOCAL_FILE_SCHEME,a.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,o.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,r.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),r=(0,c.toURI)(t);return i.scheme===r.scheme&&i.authority===r.authority&&f(i.path,r.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,n.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,s.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const r=i(76760),s=i(22573),n=i(51926),a=i(89937),o=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,r.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,s.blank)(e))return;if(null==(t=null!=t&&(0,o.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,s.blank)(t.uuid))return;const i=(0,l.native2posix)(e),r=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(r.normalize()))return;const u=(0,n.ensurePrefix)(i.slice(r.length),"/");return d.URI.from({scheme:a.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==a.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,s.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?r.win32.sep:r.posix.sep,n=(0,s.notBlank)(t)&&!t.includes(i);if(n&&!(0,s.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const o=await(0,c.bestVolumeForVolsha)(e.authority);return null!=o?f(o.mountpoint,e.path):n&&(0,s.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const r=i(40958),s=i(22573),n=i(51926),a=i(89937),o=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,s.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,s.blank)(t))return;const i=(0,r.uniq)([t,(0,o.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,n.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==a.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,o.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,n.stripPrefix)(e.path,"/"),r=t.join(i);if(r.isFileSync())return r.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return r.nativePath}},12228:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const a=n(i(76760)),o=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,o.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,o.notBlank)(t.remoteHost)&&(0,o.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:a.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,o.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),r=i[0];if((0,o.blank)(r))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(a.sep)}`;const s=i.slice(1),n=await(0,p.volumes)();for(const t of(0,u.toA)(n))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,r)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return a.join(t.mountpoint,...s);return await(0,h.isReadableDirectory)(t)?a.join(t,...s):void 0}},85087:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const r=i(22573),s=i(42659),n=i(9103),a=i(37628);t.volsha=(0,n.memoize)((e=>(0,r.mapNotBlank)(e,a.shortStringSha)),{maxSize:128,ttlMs:s.minuteMs})},50036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.channelVersionsCache=void 0;const r=i(46292),s=i(95696);t.channelVersionsCache=function(){return s.PosixFile.forMaybe((0,r.configDir)())?.join("channel-versions.json")}},60865:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const r=i(37805),s=i(30577);t.channel=function(){return(0,s.extractUpdateChannel)(r.version)},t.baseVersion=()=>[r.versionMajor,r.versionMinor,r.versionPatch].join("."),t.versionMajorMinor=r.versionMajor+"."+r.versionMinor},76280:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const r=i(38064),s=i(22573),n=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function a(e){if(e instanceof r.SemVer)return e.version;const t=n.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=a,t.semverSatisfies=function(e,t){if((0,s.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,r.satisfies)(e,t,i))return!0;const n=a(e);return null!=n&&(0,r.satisfies)(n,t,i)},t.toSemver=function(e){try{return e instanceof r.SemVer?e:(0,r.parse)(e,{loose:!0})??void 0}catch{return}}},27274:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.semverGte=t.semverLatest=void 0;const r=i(54993),s=i(48884),n=i(76280),a=i(30577);function o(e){const t=(0,n.toSemver)(e),i=a.UpdateChannels.ordinal((0,a.extractUpdateChannel)((0,r.toS)(e)));return null==t?void 0:[t.major,t.minor,t.patch,i,...t.prerelease.slice(1)]}function l(...e){return(0,s.greatestBy)(e,o)}t.semverLatest=l,t.semverGte=function(e,t){return l(e,t)===e}},38244:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isUpdateChannelVersion=void 0;const r=i(68708),s=i(51926),n=i(30577);t.isUpdateChannelVersion=function(e){return(0,r.isObject)(e)&&n.UpdateChannels.has(e.channel)&&(0,s.isString)(e.version)}},30577:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const r=i(50989);t.UpdateChannels=(0,r.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},63335:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ver=void 0;const r=i(22573);t.ver=function(e){return(0,r.blank)(e)?"(missing version)":e.replace(/^(?:v|ver|version)?\s*/,"version ")}},40044:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getChannelVersions_=t.checkVersion_=t.currentChannel=void 0;const r=i(40958),s=i(82950),n=i(42659),a=i(45599),o=i(75240),l=i(17344),u=i(50213),c=i(37805),d=i(5916),h=i(46292),f=i(16287),m=i(43205),p=i(28874),g=i(63870),y=i(89372),v=i(50036),w=i(60865),b=i(27274),S=i(38244),P=i(30577),_=i(63335),T=(0,a.defer)((()=>(0,u.mkLogger)("VersionCheck")));t.currentChannel=function(){const e=[p.Settings.updateChannel.valueOrDefault,(0,w.channel)()].map((e=>P.UpdateChannels.ordinal(e))).sort()[0];return P.UpdateChannels.values[e]??p.Settings.updateChannel.valueOrDefault},t.checkVersion_=async function(e){if(p.Settings.noNetwork.valueOrDefault)return{level:"disabled",msg:["PhotoStructure version checking is disabled","Set "+(0,s.tt)(p.Settings.noNetwork.toEnvLine(!1))+" to enable."]};if(!p.Settings.autoUpdateCheck.valueOrDefault){const e=["PhotoStructure version checking is disabled"];return!0===p.Settings.optOut.value?e.push("Set "+(0,s.tt)(p.Settings.optOut.toEnvLine(!1))+" to enable."):!1===p.Settings.autoUpdateCheck.value?e.push("Set "+(0,s.tt)(p.Settings.autoUpdateCheck.toEnvLine(!0))+" to enable."):e.push("Finish setup, or set "+(0,s.tt)(p.Settings.autoUpdateCheck.toEnvLine(!0))+" to enable."),{level:"disabled",msg:e}}const i=(0,h.configDir)();if(null==i||!await(0,f.isDirectory)(i))return{level:"warn",msg:["PhotoStructure version checking is disabled","No suitable configuration directory exists."]};const a=await(0,t.getChannelVersions_)();if(null==a)return{level:"warn",msg:["Failed to fetch PhotoStructure version information"]};const u=e?.installedVersion??c.version,d=(0,P.extractUpdateChannel)(u),m=(0,P.eligibleForChannel)(d),g=a.versions.filter((e=>m.includes(e.channel))).map((e=>e.version)),y=e?.latestVersion??(0,b.semverLatest)(...g);if(null==y)return{level:"warn",msg:["PhotoStructure version checking failed","No suitable version was found for "+p.Settings.updateChannel.toEnvLine()]};const v=(0,P.extractUpdateChannel)(y),w="You are running "+(0,l.EditionName)()+" "+(0,_.ver)(u),S="The latest published "+(0,s.tt)(v)+" build is "+(0,_.ver)(y),T=v===d?void 0:"You should consider switching to the "+(0,s.tt)(v)+" channel.",M=Date.now()-a.updatedAt,E="Last checked "+(M{const e=(0,v.channelVersionsCache)(),i=await(0,y.httpGetJson_)({url:"https://photostructure.com/channel-versions.json",headers:{"User-Agent":await(0,m.userAgent)()},cache:e,ttlMs:n.dayMs,preCacheTransform:e=>({versions:e,updatedAt:Date.now(),updatedByVersion:c.version})}),r=i.data;if(null==r||!Array.isArray(r.versions)||0===r.versions.length||r.versions.some((e=>!(0,S.isUpdateChannelVersion)(e)))||r.updatedByVersion!==c.version){if(i.fromCache)return T().info("getChannelVersions_(): Invalid or stale cached response. Retrying after wiping cache",{result:r,cache:e}),await e.unlink_(),t.getChannelVersions_.refresh();T().throw("getChannelVersions_(): Invalid response",{result:r})}return T().tap({msg:"getChannelVersions_()",result:r})}})},8540:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const r=i(40958),s=i(9595),n=i(29882),a=i(43334),o=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,r.compactBlanks)([o.Settings.libraryDir.valueOrDefault,(0,s.originalsDir)(),...o.Settings.scanPaths.values]))if((!a.isPosix||!(0,n.pathIsRoot)(t))&&(0,n.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},42233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.currentVolumeRoots=void 0;const r=i(45200),s=i(98770),n=i(7014);t.currentVolumeRoots=(0,s.lazyFsAsync)("currentVolumeRoots",(async function(){const e=[],t=[];for(const i of await(0,n.volumes)()){t.push(i.mountpoint);const s=(await(0,r.nativePath2uri)(i.mountpoint,i))?.toString();null!=s&&e.push(s)}return{uris:e,mountpoints:t}}))},1485:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const r=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,r.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const r=i(19851),s=i(22573),n=i(59455),a=i(50213),o=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.DfPosix"))),v=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function w(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),r=(0,g.isExcludedMountpoint)(e.mountpoint),s=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),n=t&&(i||r||s);return y().tap({msg:"acceptPosixVolume()",result:!n,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:r,excludedDir:s}})}t.acceptPosixVolume=w,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,n.toA)(await v());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,s.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,n.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,o.assignMissingPrimitives)(i,e))}return t.filter(w)}},69108:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,a.toInt)(e,{defaultValue:0})*o.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,s.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],r=m(e["1024-blocks"])??0;if(0===r)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const s=m(e.Used)??0,n=m(e.Available)??0;if(0!==s||0!==n)return{filesystem:t,mountpoint:i,size:d.isMac?s+n:r,used:s,available:n};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:r,used:s,available:n})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const r=["-k","-P"];if(!0===e&&r.push("-l"),r.push(...(0,s.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",r,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,n.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const a=p(i);return!0===e&&a.forEach((e=>e.remote=!1)),a},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(22573),o=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),v=i(24399),w=i(28874),b=i(24541),S=i(60224),P=i(63870),_=(0,r.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const T=/([a-z]+)(?::\\)?/i;function M(e){return e?.match(T)?.[1]?.toUpperCase()}function E(e){return(0,l.map)(M(e),(e=>e+":\\"))}function k(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(M(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function D(e){return null!=e&&!(0,a.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,a.notBlank)(e.DisplayRoot),...(0,l.map)((0,S.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function x(e){return`Get-Volume ${(0,f.toS)(M(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=E,t.getPsDriveCommand=k,t.getVolumeCommand=x,t.getLocalVolumesWin_=function(){return v.PowerShell.instance().executeJsonToA(x())};const C=/\{([-a-z\d]{7,})\}/i;function F(e,t){return e=e?.trim(),(0,a.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function A(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void _().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=E(e.DriveLetter);if(null==t)return void _().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,s.compact)([F(e.HealthStatus,"healthy"),F(e.OperationalStatus,"OK")]).join("; "),r=null!=e.Size&&null!=e.SizeRemaining&&(0,a.notBlank)(e.DriveLetter)&&(0,a.blank)(i);return _().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(n=e.UniqueId,_().tap({msg:"uniqueId2uuid",result:(0,l.map)(C.exec((0,f.toS)(n)),(e=>e[1])),meta:{s:n}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:r,status:i},meta:{input:e}});var n}async function I(){const e=(0,s.uniq)((0,h.toA)(await(0,b.mountpointsWin)()).map(E)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(k(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,s.compact)((0,o.flatten)(t).map(D)),r=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(x(e)).catch((t=>(_().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),a=(0,s.compact)((0,o.flatten)(r).map(A)),l=(0,s.uniq)([...i,...a].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,n.sort)((0,s.uniq)([...i,...a].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));_().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:a,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...a.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=A,t.volumeInfoWin=I},68884:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),v=i(83278),w=i(8103),b=i(16287),S=i(45969),P=i(43334),_=i(69108),T=i(98770),M=i(44224),E=i(63870);t.isGioSupported=(0,r.lazy)((async()=>{if(!P.isLinux||(0,S.isDocker)()||(0,d.isBillingService)()||null==await(0,w.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,E.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const k=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,r.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?k().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,M.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),b.isReadableDirectory),(e=>e.map((e=>v.BaseFile.for(e).clear().childDirectories())))))}):k().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,s.isEmpty)(e)?[]:(k().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,E.mountpointsTtlMs)(),f:async e=>{const t=await(0,_.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void k().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const r=await D(i.mountpoint);return null==r?i:{remote:!0,...i,...r}}}))},timeoutMs:(0,E.mountpointsTtlMs)()}))),(0,o.later)((()=>(0,T.setupVolumeTTL)(t.gioVolumes)));const D=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,E.commandTimeoutMs)()})).split(/[\r\n]+/),r=(0,n.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(r,(e=>e.hostname)),remoteShare:(0,u.opt)(r).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(n.notBlank).get()}}catch(t){return void k().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs})},98770:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const r=i(19851),s=i(5233),n=i(41400),a=i(56038),o=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,r.lazy)((()=>(0,a.time)("volumes."+e,(()=>(0,s.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,o.isRetriableError)(e)&&!1!==(0,o.isIgnorableError)(e)})))),i);return(0,n.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const r=i(19851),s=i(40958),n=i(22573),a=i(31586),o=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),v=i(98770),w=i(63870),b=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>b().warn("lsblk failed",{error:e}))),r=await(0,t.localVolumes_blkid_)().catch((e=>b().warn("blkid failed",{error:e})));if(null==i&&null==r)return;const n=(0,c.sortIgnoreCase)((0,s.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),a=[];for(const t of n){const s=e.find((e=>e.mountpoint===t)),n=i?.find((e=>e.mountpoint===t)),o={...s,...n},u=r?.find((e=>e.filesystem===o.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(o,u),null==o.size||null==o.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];b().info("backfilling mountpoint",{info:n,vol:s,df:e}),null!=e&&(0,l.assignMissingPrimitives)(o,e)}a.push(o)}return a};const S=/lsblk from util-linux ([\d.]+)$/i,P=(0,r.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return S.exec(e)?.[1]?.split(".").map((e=>(0,a.toInt)(e)))})),_=(0,r.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,a.gte)(t[0],2)&&(0,a.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,v.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await _()],{timeoutMs:(0,w.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,n.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,a.toInt)(e.fsused),r=(0,a.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=r?{used:i,available:r,size:i+r}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return b().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,v.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,w.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,n.toNotBlank)(e.PARTLABEL)??(0,n.toNotBlank)(e.LABEL),uuid:(0,n.toNotBlank)(e.PARTUUID)??(0,n.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const r=i(57272),s=i(19851),n=i(40958),a=i(22573),o=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),v=(0,s.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,n.uniq)(e.map((e=>e.filesystem?.match(w)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),s=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of s)try{const t=(0,r.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,a.blank)(t.MountPoint)||(0,o.isTrue)(t.OSInternal)?v().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){v().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const w=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const r=i(19851),s=i(40958),n=i(76790),a=i(42659),o=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),v=i(84777),w=i(34330),b=i(8769),S=i(34102),P=i(17217),_=i(16287),T=i(43334),M=i(28874),E=i(8540),k=i(68884),D=i(44224),x=i(24541),C=i(69375),F=i(63870),A=(0,r.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function O(e=(0,F.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function L(){I()}t.localMountpointSetup=(0,r.lazy)((async()=>{M.Settings.libraryDir.watchLater(I),M.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&M.Settings.scanAllDrives.valueOrDefault?(0,o.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(T.isMac&&(e.info("Setting up Mac diskutil activity watcher"),O((0,F.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),T.isLinux){const i=(0,D.maybeWatchProcMounts)();await(0,k.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),O((0,F.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),O((0,F.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),a.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,r.lazy)((()=>{}));t.mountpoints_=(0,r.lazy)((async()=>{{const e=M.Settings.mountpoints.values;if((0,s.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",T.isWin?x.mountpointsWin:D.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,s.isEmpty)(e))return A().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,n.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,F.commandTimeoutMs)(),f:async e=>!(!(0,E.mightBeAssetMountpoint)(e)&&(0,C.isExcludedMountpoint)(e)||M.Settings.validateMountpoints.valueOrDefault&&!await(0,_.isReadableDirectory)(e)&&(A().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,r.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,b.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(T.isWin)return!1;const i=await(0,t.mountpoints)()??[],r=(0,P.toNativePath_)(e);return T.isMac?(0,m.includesIgnoreCase)(i,r):i.includes(r)},(0,o.later)((()=>{(0,S.ee)().on("clearCache",(()=>{k.gioVolumes.unset(),I()})),M.Settings.mountpointsTtlMs.watch(O)}),(0,c.isTest)()?1:a.minuteMs),t.diskUtilActivity=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>L(),minCallDelayMs:1.5*a.secondMs})}))),t.gioMountMonitor=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:k.GioCommand,args:k.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(k.gioVolumes.unset(),L()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const N=(0,r.lazy)((async()=>{if(!T.isLinux)return!1;try{return 0===(await(0,v.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,F.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,r.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>L(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const r=i(19851),s=i(40958),n=i(42659),a=i(48884),o=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),v=i(28874),w=i(69108),b=i(68884),S=i(59107),P=i(69375),_=(0,r.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await k()??await(0,c.thenMap)((0,w.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,b.isGioSupported)())try{await(0,c.thenMap)((0,b.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){_().warn("Failed to fetch gio volumes",e)}return e};const T="/proc/mounts";function M(e){return!v.Settings.excludedFilesystemTypes.has(e)}function E(e){return!(0,P.isExcludedMountpoint)(e)&&(!v.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function k(e=T,t=M,i=E){if(y.isLinux)try{const r=await(0,f.readLines_)(e),n=(0,s.compact)(r.map((e=>{const[t,i]=e.split(/\s+/);return(0,a.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),o=await(0,c.filterAsync)({name:"mountpoints filter",arr:n,f:async([e,r])=>{const s=t(e),n=await i(r);return _().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:s&&n,meta:{fs:e,mp:r,fsOK:s,mpOK:n}})}});return _().tap({msg:"readProcMounts()",result:o.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void _().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=M,t.readProcMounts=k,t.maybeWatchProcMounts=(0,r.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(T)?new h.FileWatcher(T,{recursive:!1,persistent:!1},(()=>{_().info("detected change in "+T),(0,d.setUnrefTimeout)((()=>S.mountpoints.refresh()),n.secondMs)})):void 0))},24541:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const r=i(19851),s=i(42659),n=i(13538),a=i(50213),o=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,r.lazy)((async()=>{try{return await(0,n.thenOrTimeoutError)(f(),o.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*s.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const r=i(19851),s=i(22573),n=i(50213),a=i(9103),o=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,r.lazy)((()=>(0,n.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,s.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,o.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,o.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,o.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,o.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,s.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],r=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(r)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,a.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const r=i(22573),s=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,n=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function a(e){if((0,r.blank)(e))return;const i=s.exec(e)?.groups;if(null!=i&&!(0,r.blank)(i.remoteHost)&&!(0,r.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(n,""),remoteShare:i.remoteShare};const a=t.nfsRe.exec(e);if(null!=a){const e=a[1],t=a[2];if(!(0,r.blank)(e)&&!(0,r.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=a(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=a},60224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const r=i(40958),s=i(22573),n=i(42659),a=i(55835),o=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),v=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await M()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,a.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const w=["LocalName","RemoteName","Status"],b=["NETUSE","get",w.join(",")],S=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function _(e){if(!(0,s.blank)(e))return(0,o.opt)(e).flatMap((e=>S.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,o.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,s.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,o.opt)(e.pathname).filter(s.notBlank).getOrElse((()=>"/"))}))))).get()}async function T(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,b,{timeoutMs:15*n.secondMs}),i=(0,u.parseFixed)(w,t);return(0,r.compact)(i.map((e=>(0,a.map)(S.exec((0,l.toS)(e.RemoteName)),(t=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=_,t._netInfoWinWmic=T;const M=(0,v.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?T():(0,r.compact)(e.filter((e=>(0,s.notBlank)(e.LocalName))).map((e=>(0,a.map)(_(e.RemoteName),(({host:t,share:i})=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(r=>({mountpoint:(0,h.ensureSuffix)(r[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const r=i(42659),s=i(12168),n=i(28874);t.mountpointsTtlMs=function(){return n.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return n.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return n.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=s.MiB/r.secondMs},86848:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(38639),o=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),v=i(95696),w=i(45969),b=i(28874),S=i(59107),P=i(63870),_=i(68995),T=(0,s.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),M=(0,s.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function E(e){return(0,a.isTrue)(e.ignorable)||(0,w.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,r.basename)(e.mountpoint)}function k(e){if((0,n.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function D(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=k(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function x(e){if(b.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of b.Settings.volumeUuidFilePaths.values){const i=v.PosixFile.for(e.mountpoint).join(t),r=await D(i).catch((e=>T().info("Failed to read "+i,{error:e})));if(null!=r)return T().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:r,meta:{mountpoint:e.mountpoint}})}const t=(0,r.join)(e.mountpoint,(0,_.volumeUuidSubpath)());if("/"===e.mountpoint)return T().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(b.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return T().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(b.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,_.writeVolumeUuid)(e);if(!(0,n.blank)(t))return T().tap({msg:"readVolumeUUID(): wrote new "+(0,_.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return T().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,o.later)((()=>{(0,m.ee)().on("clearCache",(()=>M.clear())),S.mountpoints.watchLater((()=>M.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(E(e))return;if((0,a.isFalse)(e.ok))return;const t=await M().getOrSetAsync(e.mountpoint,(async()=>x(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>T().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=E,t.toVolumeUUID=k,t.readUuidFile_=D,t.readVolumeUUID=x},7014:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const s=r(i(48161)),n=r(i(76760)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),v=i(59455),w=i(48884),b=i(50213),S=i(7282),P=i(23560),_=i(28850),T=i(45255),M=i(81168),E=i(56519),k=i(4867),D=i(49776),x=i(9595),C=i(77740),F=i(44198),A=i(96706),I=i(8769),O=i(57159),L=(i(34102),i(21144)),R=i(73209),N=i(29882),B=i(95696),j=i(17217),z=i(16287),V=i(49076),W=i(96128),U=i(45969),q=i(43334),H=i(28874),$=i(85087),G=i(50424),J=i(48165),K=i(98770),Y=i(27461),X=i(66840),Z=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),re=(0,a.lazy)((()=>(0,b.mkLogger)("volumes.Volumes"))),se=s.default.platform(),ne=new Map,ae=new Map,oe=new Map;function le(e,t,i){if((0,u.blank)(e))return;const r=i.get(e);null!=r&&(0,p.gt)(r.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,$.volsha)(t.uuid),(e=>ae.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,ne),le((0,$.volsha)(e.uuid),e,oe),e}function ce(){return(0,o.compact)([B.PosixFile.forMaybe((0,D.cacheDir)())?.join("volumes"),B.PosixFile.forMaybe((0,x.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),ae))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){re().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),ne.clear(),oe.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,E.mapAsync)({name:"readCachedVolumes",arr:(0,E.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,o.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,M.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const r=Date.now(),s=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,U.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:r,os:se}))),n=new Map;for(const e of s)for(const t of(0,o.compactBlanks)([(0,$.volsha)(e.uuid),(0,$.volsha)(e.mountpoint)]))n.set(t,e);const a=ce();for(const e of a)await(0,R.withLock_)({file:e,timeoutMs:T.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of n.entries()){const r=e.join(t+".json");try{await r.writeJson_(i)}catch(e){re().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:r.nativePath,vol:i}),await r.unlink()}}}));re().debug("writeVolumesToCache(): complete.",{dirs:a,vol_mountpoints:s.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,o.isNotEmpty)(e))return e;const i=(0,v.toA)(await(0,Z.mountpoints)()),r=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,H.Settings.volumeMetadataTtlMs.valueOrDefault),s=0!==H.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,r))),n=!(0,o.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return re().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:s,priorIsMissingMountpoints:n}),s||n?void 0:e}async function me(e,i){const r=(0,m.map)(e,j.toNativePath_);if((0,u.blank)(r))return;const s=await(0,L.actualPath)(r);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,o.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(s,t.map((e=>e.mountpoint)));if(null==i)continue;const r=t.find((e=>e.mountpoint===i));if(null!=r)return re().trace("bestVolumeForPath()",{nativePath:s,result:r.mountpoint,src:e.name}),r}return re().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:s}})}async function pe(e,t,i){const r=i.filter((e=>(0,M.equalsIgnoreCase)(t,e.remoteShare)));if((0,o.isEmpty)(r))return;const s=r.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,M.equalsIgnoreCase)(e,t.remoteHost)));if(null!=s)return s;const n=await(0,W.friendlyname)(e);return(0,E.asyncFind)(r,(async e=>(0,M.equalsIgnoreCase)(n,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,a.lazy)((()=>(0,P.isSyncService)()||(0,S.isTest)())),t.priorWriteVolumesToCacheLatch=(0,a.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,a.lazy)((async()=>{const e=(0,o.compact)(await de()),t=(0,v.toA)(await(0,Z.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),r=(0,o.isNotEmpty)(i)?i:e.filter((e=>se===e?.os));return re().tap({msg:"cachedVolumes()",level:"trace",result:r.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,k.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return re().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,k.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,o.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,O.toWrappedError)("volumes() failed",{cause:e}))}return re().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,_.shim0)({name:"fs.volumes",impl:async function(){if((0,S.isTest)()){const e=(0,p.toInt)((0,F.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(re().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,C.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void re().throw("PS_FAIL_VOLUMES")}const e=await(0,k.thenOrTimeoutError)({p:q.isWin?(0,J.dfWin)():(0,G.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void re().warn("df failed");const t=H.Settings.validateMountpoints.valueOrDefault?(0,o.compact)(await(0,E.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,z.isReadableDirectory)(e.mountpoint))return e;re().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){re().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,k.thenOrTimeoutError)({p:q.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(q.isWin?t:q.isMac?await(0,X.addLocalVolumeInfoMac)(t):await(0,Y.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const r=(0,l.sortBy)(i,(e=>e.mountpoint));return re().debug("_volumes(): final result",{sorted:r}),r.forEach(ue),await he(r),Object.freeze(r)}}),t.rootPath=(0,a.lazy)((()=>q.isWin?(0,g.opt)((0,A.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,M.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,o.isEmpty)(t)?void 0:(0,w.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,o.commonPrefixLength)(e.split(n.default.sep),t.split(n.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,v.toA)(await i.vols()).find((t=>(0,$.volsha)(t.uuid)===e));if(re().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,E.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return oe.get(e)??(await de())?.find((t=>(0,$.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,$.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const r=i(76760),s=i(19851),n=i(22573),a=i(50213),o=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,s.lazy)((()=>(0,a.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,n.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,r.join)(e,f());t=(0,n.toNotBlank)(t)??(0,c.safeUUID)();const s=(0,r.dirname)(i);if(await(0,l.isReadWriteableDirectory)(s))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+o.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},72901:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkEventStream=void 0;const r=i(22573),s=i(98553),n=i(65211);t.mkEventStream=function(...e){let t="";for(const i of e)null!=i&&((0,r.blank)(i.event)||(t+="event: "+i.event+"\n"),t+="id: "+(i.id??(0,n.uid)())+"\n",t+="data: "+(0,s.stringify)(i.data)+"\n",t+="\n");return t}},55111:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const r=i(50989);t.HelmetPlugins=(0,r.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},89372:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.httpGetJson_=void 0;const r=i(45599),s=i(98553),n=i(31586),a=i(50213),o=i(51140),l=i(4988),u=(0,r.defer)((()=>(0,a.mkLogger)("web.HttpGet")));t.httpGetJson_=async function(e){const t=e.cache,i=await t.mtimeMs();if(null!=i&&(0,n.gt0)(await t.size())&&(0,n.gte)(i,Date.now()-e.ttlMs))return{data:await t.readJson_(),updatedAt:i,fromCache:!0};const r=await(0,l.get_)(e.url,{headers:e.headers});o.HttpStatusIs.success(r.statusCode)||u().throw("Failed",{url:e.url,response:r});const a=(0,s.parseJSON_)(r.data),c=e.preCacheTransform?.(a)??a;return u().info("Fetch success. Caching",{args:e,json:c,cache:t}),await t.writeJson_(c),{data:c,updatedAt:Date.now(),fromCache:!1}}},49586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAjaxRequest=t.isHttpsRequest=t.parseForwarded=void 0;const r=i(22573),s=i(59455),n=i(81168),a=i(28874);function o(e){if((0,r.blank)(e))return{};let t=(0,s.toA)(e).join(";").trim().replace(/^[,;]/,"").replace(/[,;]$/,"");const i={};for(;t.length>0;){const e=t.indexOf("=");if(e<0)break;const r=(0,n.stripQuotes)(t.slice(0,e).trim().toLowerCase());if(t=t.slice(e+1).trim(),/^["']/.test(t)){const e=/['"]\s*(?:[;,]|$)/.exec(t.slice(1))?.index;if(null==e)break;const s=(0,n.stripQuotes)(t.slice(0,e+2).trim());i[r]=s,console.log("quoted",{k:r,v:s,s:t,vIdx:e}),t=t.slice(e+3).trim()}else{const e=/[;,]|$/.exec(t)?.index;if(null==e)break;const s=t.slice(0,e).trim();i[r]=s,console.log("unquoted",{k:r,v:s,s:t,vIdx:e}),t=t.slice(e+2).trim()}}return i}function l(e){return(0,r.blank)(e)||function(e){return Array.isArray(e)&&0===e.length}(e)?void 0:(0,s.toA)(e).join(";")}t.parseForwarded=o,t.isHttpsRequest=function(e){return null!=e&&"false"!==a.Settings.trustProxy.valueOrDefault&&((0,n.equalsIgnoreCase)("https",o(e.forwarded).proto??l(e["x-forwarded-protocol"])??l(e["x-url-scheme"]))||"on"===l(e["front-end-https"])||"on"===l(e["x-forwarded-ssl"]))},t.isAjaxRequest=function(e){return"application/json"===e?.["content-type"]}},51140:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpStatusIs=t.HttpStatus=void 0;const r=i(31586);t.HttpStatus=Object.freeze({OK:200,Accepted:202,MovedPermanently:301,Found:302,SeeOther:303,BadRequest:400,Unauthorized:401,Forbidden:403,NotFound:404,EnhanceYourCalm:420,InternalServerError:500,NotImplemented:501,ServiceUnavailable:503}),t.HttpStatusIs=Object.freeze({ok:e=>(0,r.within)(200,299,e),success:e=>(0,r.within)(200,299,e),redirect:e=>(0,r.within)(300,399,e),clientError:e=>(0,r.within)(400,499,e),serverError:e=>(0,r.within)(500,599,e),error:e=>(0,r.within)(400,599,e)})},21404:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uriToTagPath=void 0;const r=i(75020),s=i(40958),n=i(22573),a=i(89937),o=i(34238);t.uriToTagPath=function({uri:e,isFile:t}){if(null==e)return;const i=(0,o.toURI)(e),l=i.scheme===a.PS_LIBRARY_SCHEME?r.LibraryTagName:i.scheme===a.PS_LOCAL_FILE_SCHEME?i.authority:void 0;if((0,n.blank)(l))return;const u=i.path.split("/");return(0,s.compactBlanks)([r.TagRoots.fs,l,...t?u.slice(0,-1):u])}},98604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkAssetUrl=t.mkFolderUrl=t.myWebUrl=void 0;const r=i(19851),s=i(40958),n=i(31586),a=i(27776),o=i(49076),l=i(72308),u=i(28874),c=i(42231),d=i(45200),h=i(34238),f=i(21404);function m(e=u.Settings.httpPort.valueOrDefault){const t=[u.Settings.localhost.valueOrDefault];u.Settings.exposeNetworkWithoutAuth.valueOrDefault&&t.push(...(0,s.compactBlanks)([(0,l.myExternalIp4Addresses)()[0],(0,o.hostname)()]));const i=(0,h.toURI)("http://a");return t.map((t=>i.with({authority:t+":"+e})))}t.default=m,t.myWebUrl=(0,r.lazy)((()=>m()[0])),t.mkFolderUrl=async function(e){const i=await(0,d.nativePath2uri)(e),r=(0,f.uriToTagPath)({uri:i,isFile:!1});if((0,s.isEmpty)(r))return;const n=(0,a.mkTagUri)((0,c.tagPathToStringArray)(r));return(0,t.myWebUrl)()?.with(n)},t.mkAssetUrl=function(e){return(0,n.gt0)(e)?(0,t.myWebUrl)()?.with({path:"/asset/"+e}):void 0}},4988:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.httpRequest_=t.get_=t.HttpMethods=void 0;const a=n(i(37067)),o=n(i(44708)),l=i(22573),u=i(45599),c=i(50989),d=i(51926),h=i(50213),f=i(45255),m=i(22911),p=i(43205),g=i(34238),y=i(51140),v=(0,u.defer)((()=>(0,h.mkLogger)("net.get")));async function w(e,t){return b({...t,url:e})}async function b(e){const t=(0,g.toURI)(e.url),i=new m.Deferred("get "+t.toString()),r="http"===t.scheme?a.request:"https"===t.scheme?o.request:v().throw("unsupported scheme: "+t.scheme),s=e?.maxRedirects??8,n=e?.timeoutMs??f.ShortCommandTimeoutMs,u={...e?.headers,"user-agent":await(0,p.userAgent)()},c=e?.method??"GET",h=e?.agent??!1,b=r(t.toString(),{method:c,headers:u,timeout:n,agent:h},(e=>{let r="";e.setEncoding("utf8").on("data",(e=>r+=e.toString())).resume().on("end",(()=>{const a={url:(0,l.toNotBlank)(e.url)??t.toString(),contentType:e.headers["content-type"],statusCode:e.statusCode??-1,data:r};s>0&&y.HttpStatusIs.redirect(a.statusCode)&&!(0,l.blank)(e.headers.location)?(console.log("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),v().info("Following redirect",{from:t.toString(),to:e.headers.location,statusCode:a.statusCode}),i.observe(w(e.headers.location,{timeoutMs:n,maxRedirects:s}))):(v().debug("complete",{...a,data:(0,d.ellipsize)(r,64),data_length:r.length}),i.resolve(a))}))})).on("error",(e=>i.reject(e)));return(0,l.blank)(e.body)||b.write(e.body),b.end(),i}t.HttpMethods=(0,c.strEnum)("GET","PUT","POST","PATCH","DELETE"),t.get_=w,t.httpRequest_=b},65713:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const r=i(76760),s=i(19851),n=i(23838),a=i(81168),o=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,s.lazy)((()=>(0,r.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,s.lazy)((async()=>{const e=(0,o.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,s.lazy)((()=>({trie:new n.MultiMap,small:[]}))),h=3;function f(e){const t=new n.MultiMap,i=[];for(const r of e)r.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tr.startsWith(e)));if(null!=s)return s}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const r=i(22573),s=i(96249),n=i(23838),a=i(59455),o=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=n.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,r.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,a.toA)(u[t])],n=c(e.substring(1));return(0,s.flatten)(n.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const r of e)t+=i[r]?.[0]??r;return t},t.unl33t=function(e){return c((0,o.stripDiacritics)(e).normalize())}},30933:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const s=r(i(48161)),n=i(19851),a=i(42659),o=i(31586),l=i(50213),u=i(28874),c=(0,n.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,n.lazy)((()=>s.default.cpus()),5*a.minuteMs),t.cpuCount=(0,n.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=s.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,o.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},14854:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CpuUsage=t.isTooBusy=void 0;const d=c(i(48161)),h=i(42659),f=i(45599),m=i(55835),p=i(31586),g=i(68708),y=i(19851),v=i(50213),w=i(7282),b=i(78406),S=i(25764),P=i(38835),_=i(74128),T=i(82647),M=i(43334),E=i(28874),k=i(30933),D=i(15674),x=(0,y.lazy)((()=>(0,v.mkLogger)("work.CpuUsage"))),C=(0,y.lazy)((()=>{const e=F.instance().busyPct();(0,_.syncReport)().maybeSystemData({from:"cpuUsage",state:"note",details:"Current system load is too high to schedule more work",meta:(0,g.compactValues)({loadCpuPct:I(),cpuBusyPct:e})}),x().warn("Current system load is too high to schedule more work",{cpuBusyPct:e,max:E.Settings.cpuBusyPercent.valueOrDefault})}),((0,w.isTest)()?15:60)*h.secondMs);t.isTooBusy=function(){if(E.Settings.cpuBusyPercent.valueOrDefault<=0)return!1;const e=F.instance().busyPct(),t=(0,p.clamp)(1,150,Math.round(4*E.Settings.cpuBusyPercent.valueOrDefault/3));return(0,p.gte)(e,t)?(C(),!0):(C.unset(),!1)};class F extends b.EndableInterval{constructor(){super({name:"CpuUsage()",callback:()=>l(this,r,"m",o).call(this),intervalMs:((0,D.singleThreadedMode)()?60:M.isWin?20:10)*h.secondMs,rank:S.EndableRanks.first}),r.add(this),s.set(this,new T.Average(5)),n.set(this,new A),(0,p.mapFinite)(I(),(e=>l(this,s,"f").push(e))),l(this,r,"m",o).call(this)}get cpuCount(){return l(this,n,"f").cpuCount}idlePct(){return(0,m.map)(this.busyPct(),(e=>100-e))}busyPct(){return l(this,s,"f").sampleAvg??I()}}t.CpuUsage=F,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(e){(0,p.gte0)(e)&&l(this,s,"f").push(e)},o=function(){l(this,r,"m",a).call(this,I());const e=new A;l(this,r,"m",a).call(this,e.busyPct(l(this,n,"f"))),u(this,n,e,"f")},F.instance=(0,f.defer)((()=>new F));class A{constructor(e=d.default.cpus()){let t=0,i=0;for(const r of e)t+=r.times.user+r.times.nice+r.times.sys+r.times.irq,i+=r.times.idle;this.busyMs=t,this.idleMs=i,this.cpuCount=e.length}busyPct(e){const t=this.busyMs-e?.busyMs,i=this.idleMs-e?.idleMs,r=t+i;return e?.cpuCount===this.cpuCount&&(0,p.gte0)(t)&&(0,p.gte0)(i)&&(0,p.gt0)(r)?(0,p.sigFigs)(t/r*100,3):void x().warn("busyPct(): Unexpected CpuTimes. If this continues, busyPct() will be incorrect."+P.InternalErrorFlag,{self:this,prior:e,busyMs:t,idleMs:i,totalMs:r})}}function I(){return M.isWin?void 0:(0,p.sigFigs)(d.default.loadavg()[0]/(0,k.cpuInfo)().length*100,3)}},73328:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.whyDoNotRun=t.doNotRun=void 0;const r=i(68708),s=i(99331),n=i(74128),a=i(63664),o=i(14854);t.doNotRun=function(e){return null!=u(e)};const l=["error","no-library","stop-sync"];function u(e){if(!0===e?.ended)return"endable ended";if((0,s.ending)())return"service is ending";if((0,o.isTooBusy)())return"system is too busy";const t=(0,a.getRemoteOrLocalHealthSummarySync)();if(null==t||!l.includes(t.level))return;const i=t.level+": "+t.msg.join("\n");return(0,n.syncReport)().maybeSystemData({from:"whyDoNotRun",state:"note",details:t.level,meta:(0,r.omit)(t,"links","buttons")}),i}t.whyDoNotRun=u},58444:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const s=r(i(48161)),n=i(19851),a=i(31586),o=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,n.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,n.lazy)((()=>{const e=s.default.freemem(),t=s.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const r=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,a.gt0)(r))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([r,i]),meta:{freemem:e,totalmem:t,cgroupMem:r}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,o.fmtBytes)(i),freemem:(0,o.fmtBytes)(e),totalmem:(0,o.fmtBytes)(t)}})}))},69385:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOnResume=t._setPaused=t.resume=t.pause=t.isPaused=void 0;const r=i(34102),s=i(37692);let n=!1;function a(){return n}function o(e=!0){l(e),(0,s.writeStateFile)({paused:e})}function l(e){e!==n&&(n=e,(0,r.ee)().emit(e?"pause":"resume"))}t.isPaused=a,t.pause=o,t.resume=function(){return o(!1)},t._setPaused=l;const u=Promise.resolve();t.resolveOnResume=function(){return a()?new Promise((e=>{(0,r.ee)().once("resume",e)})):u}},15674:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const r=i(19851),s=i(42659),n=i(41400),a=i(31586),o=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,r.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,n.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,r.lazy)((()=>{const e=(0,a.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*o.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/o.MB),worstCaseMemPerProcMb:Math.ceil(e/o.MB)}})}),s.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,a.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function b(){return((0,a.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=b,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(b()*(0,f.cpuCount)())<=1},t.maxCpus=(0,r.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(b()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,r=w();if(1!==r){const e=t;t*=r,g().warn("Recent timeouts! Throttling down.",{penalization:r,resultBeforePenalization:e,resultAfterPenalization:t})}const s=Math.min(e,v());return t=(0,a.clamp)(1,s,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:b(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:r,timeoutsPerSecond:i,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,r.lazy)((function(){return(0,a.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,a.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,a.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},37692:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addStateEvent=t.writeStateFile=t.readStateFile=t.stateEvents=t.StateEvents=t.StateEventFns=void 0;const s=r(i(78474)),n=i(40958),a=i(76790),o=i(42659),l=i(45599),u=i(41400),c=i(68708),d=i(50989),h=i(87290),f=i(73787),m=i(19851),p=i(50213),g=i(28874),y=i(69385),v=(0,l.defer)((()=>(0,p.mkLogger)("work.SharedState")));let w;t.StateEventFns={checkTasks(){},reloadLicenses(){}},t.StateEvents=(0,d.strEnum)(...(0,c.keys)(t.StateEventFns)),t.stateEvents=new s.default;let b=0;function S(){const e=(0,h.libraryDataDirPosixFile)()?.join("state.json"),t=Date.now(),i=t-b>o.minuteMs;i&&(b=t);const r=e?.existsSync({refresh:i})??!1;return r&&null!=e&&e.eql(w?.nativePath)||(w?.close(),w=void 0),r&&null!=e&&(w??(w=new f.FileWatcher(e.nativePath,{encoding:"utf8",persistent:!1,recursive:!1},P))),e}(0,u.later)((()=>{g.Settings.libraryDir.watchLater(P)}));const P=(0,m.lazy)((()=>t.readStateFile.refresh()),25);t.readStateFile=(0,m.lazy)((()=>{const e=S()?.readJsonSync();for(const i of e?.events??[])_.get(i.e)!==i.ts&&(v().info("emitting event "+i.e),t.stateEvents.emit(i.e),_.set(i.e,i.ts));return(0,y._setPaused)(e?.paused??!1),e}));const _=new Map;function T(e){const i=S();if(null==i)v().error("overwrite(): failed: no library directory");else{const r=i?.readJsonSync(),s=function(e){const t=Date.now()-10*o.minuteMs;return(0,n.uniqByLast)((0,a.sortBy)((e??[]).filter((e=>e.ts>t)),(e=>e.ts)),(e=>e.e))}([...r?.events??[],...e.events??[]]),l={paused:e.paused??r?.paused??g.Settings.startPaused.valueOrDefault,events:s};(0,y._setPaused)(l.paused),t.readStateFile.set(l),i.writeJsonSync(l)}}t.writeStateFile=T,t.addStateEvent=function(e){const t=Date.now();_.set(e,t),T({events:[{e,ts:t}]})}},22751:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const r=i(58587),s=i(87997),n=i(19851),a=i(42659),o=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,n.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,n.lazy)((()=>new r.Rate(5*a.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,n.lazy)((()=>(0,s.setInterval)(g,a.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,o.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},83600:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.RequestTask=void 0;const a=i(58587),o=i(80875),l=i(19851),u=i(50213),c=i(34102),d=i(84542),h=i(87445),f=i(40958),m=i(26905),p=i(98553),g=i(31586),y=(0,l.lazy)((()=>(0,u.mkLogger)("worker.RequestTask")));class v extends a.Task{constructor(e){super((0,p.stringify)(e),(e=>n(this,r,"m",s).call(this,e))),r.add(this),this.request=e}}t.RequestTask=v,r=new WeakSet,s=function(e){for(const t of(0,f.compactBlanks)((0,d.splitLines)(e))){const e=(0,o.parseJSON)(t);if(null==e)y().warn("ignoring non-json line from worker",{line:t});else{if(null!=e.error)throw y().warn("worker threw error",{response:e}),(0,m.errorFromJson)(e.error);if((0,g.isNumber)(e.id))return e.id!==this.request.id?y().throw(`bad request: #parse given mismatching requests (${e.id} != ${this.request.id})`,{response:e,request:this.request}):e.response;(0,h.isProgressEvt)(e)?(0,c.ee)().emit("progress",e):y().warn("ignoring json line from worker",{response:e})}}return y().throw("bad request: #parse missing valid response")}},93493:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearShims=t.setupShimDelegates=void 0;const r=i(19851),s=i(5233),n=i(68708),a=i(13538),o=i(57206),l=i(50213),u=i(23560),c=i(70025),d=i(28874),h=i(15674),f=i(22751),m=i(83600),p=i(58800),g=i(24817),y=(0,r.lazy)((()=>(0,l.mkLogger)("worker.ShimDelegation")));let v=0;async function w(e,t){const i=d.Settings.taskTimeoutMs.valueOrDefault;return(0,s.retryOnReject_)((async()=>{y().throwIfAborted_();const r={id:v++,fn:e,args:t},s=new m.RequestTask(r),n=await(0,p.workerCluster)(),o=n?.t,l=null==n||null==o?g.WorkerFunctions[e](...t):n.awaitOrAbort(o.enqueueTask(s));return(0,a.thenOrOnTimeout)(l,i/3,(()=>{y().warn("soft timeout servicing work request",{request:r,timeoutMs:i}),(0,f.onTimeout)()})),(0,a.thenOrTimeoutError)(l,i)}),{maxRetries:d.Settings.maxRetries.valueOrDefault,timeoutMs:i,retryDelay:d.Settings.minDelayBetweenRetriesMs.valueOrDefault,errorIsRetriable:e=>!1!==(0,c.isRetriableError)(e)})}function b(){for(const e of(0,n.values)(g.WorkerFunctions))(0,n.maybeCall)(e,"clearShim")}t.setupShimDelegates=async function(){if((0,o.addDefaultJsonRevivers)(),(0,u.isWorkerService)())b(),y().warn("setupShimDelegates(): in worker service, skipping");else if((0,h.singleThreadedMode)())y().warn("setupShimDelegates(): single-threaded mode, clearing shims"),b(),await(0,p.endWorkerCluster)();else for(const[e,t]of(0,n.entries)(g.WorkerFunctions))t.setShim((t=>w(e,t)))},t.clearShims=b},24817:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleWorkRequest_=t.isWorkRequest=t.mkWorkRequest=t.WorkRequestMethods=t.WorkerFunctions=t.AllWorkerFunctionCandidates=void 0;const r=i(98553),s=i(31586),n=i(68708),a=i(50989),o=i(32639),l=i(13991),u=i(50597),c=i(48368),d=i(52121),h=i(48604),f=i(181),m=i(66106),p=i(47783),g=i(83966);t.AllWorkerFunctionCandidates={_extractVideoFrame_:m._extractVideoFrame_,_readRawTags:p._readRawTags,_readTags:p._readTags,assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkerFunctions={assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkRequestMethods=(0,a.strEnum)(...(0,n.keys)(t.WorkerFunctions));let y=0;t.mkWorkRequest=function(e,t){return{id:++y,fn:e,args:t}},t.isWorkRequest=function(e){return"object"==typeof e&&t.WorkRequestMethods.has(e?.method)&&(0,s.isNumber)(e.id)},t.handleWorkRequest_=async function(e){const i=t.WorkerFunctions[e?.fn];if((0,o.isFunction)(i))return i(e?.args);throw new Error("invalid method "+(0,r.stringify)(e))}},58800:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.workerCluster=t.endWorkerCluster=t.workerClusterPriorEnd=void 0;const r=i(58587),s=i(36557),n=i(19851),a=i(50213),o=i(71567),l=i(25764),u=i(84777),c=i(86335),d=i(38835),h=i(84542),f=i(87445),m=i(41944),p=i(15674),g=i(42659),y=i(98553),v=i(31586),w=i(67478),b=i(54993),S=i(27395),P=i(5916),_=i(55534),T=i(29325),M=i(28874),E=i(30933),k=i(41657),D=(0,n.lazy)((()=>(0,a.mkLogger)("worker.cluster")));t.workerClusterPriorEnd=async function(){return(await t.workerCluster.prior())?.t.closeChildProcesses()},t.endWorkerCluster=function(){return(0,S.end)(t.workerCluster.prior())},t.workerCluster=(0,P.lazyAsync)({later:async()=>{const e=await(0,c.pathToService)("worker");if(null==e)return D().throw("Could not find worker.js"+d.FatalErrorFlag);D().info("worker.js found at "+e);const t={id:-1,fn:"ping",args:{}},i=new r.BatchCluster({processFactory:async()=>(D().info("Spawning new worker",{execPath:process.execPath,worker:e.nativePath,maxProcs:(0,p.maxCpus)()}),(0,u.spawn)(process.execPath,[e.nativePath],0,{env:await(0,k.workerEnv)()})),...(0,s.batchClusterOptions)((0,p.maxCpus)(),"worker.BatchCluster"),streamFlushMillis:0,versionCommand:(0,y.stringify)(t),healthCheckCommand:(0,y.stringify)(t),taskTimeoutMillis:M.Settings.taskTimeoutMs.valueOrDefault,maxProcAgeMillis:4*M.Settings.taskTimeoutMs.valueOrDefault,minDelayBetweenSpawnMillis:(0,T.isPacked)()?g.secondMs:1,pass:o.ReadyStr,fail:d.FatalErrorRe,exitCommand:_.ServiceExitCommand});return i.on("taskData",(e=>{for(const t of(0,h.splitLines)((0,b.toS)(e))){const e=(0,w.parseJSON)(t);(0,f.isProgressEvt)(e)&&(0,m.emitProgressEvt)(e)}})),p.maxCpus.watchLater((e=>{const t=(0,v.clamp)(1,(0,E.cpuCount)(),e??(0,p.maxCpus)());return D().warn("maxConcurrentImports changed",{maxProcs:t,newValue:e}),i.setMaxProcs(t)})),new s.BatchClusterObserver("worker",i,l.EndableRanks.first)}})},41657:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.workerEnv=void 0;const r=i(9727),s=i(28874),n=i(59107);t.workerEnv=async function(){const e={};return s.Settings.libraryDir.addToEnv(e),s.Settings.mountpoints.addToEnv(e,await(0,n.mountpoints)()),(0,r.childEnv)({overrides:e,forWorker:!0})}},83966:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ping=void 0;const s=r(i(1708)),n=i(41400),a=i(31586),o=i(7282),l=i(12089),u=i(45608),c=i(57159),d=i(89035);t.ping=(0,l.shim1)({name:"worker.ping",async impl(e){if((0,a.gt0)(e?.delay)&&await(0,n.delay)(e.delay),(0,o.isTest)()&&!0===e?.pretendMemUsageIsHigh&&d.memoryUsageIsHigh.set(!0),null!=e?.throw)throw new c.WrappedError(e.throw.message,e.throw);if((0,d.memoryUsageIsHigh)())throw(0,u.exit)({reason:"memory usage is high",status:1}),new c.WrappedError("Memory usage is high",{fatal:!0});return{pid:s.default.pid,input:e?.input??"(no input)"}}})},40958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const r=i(76790),s=i(22573),n=i(50357),a=i(98553),o=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function v(e,t){for(let i=0;i=e.length||i>=e.length)return e;const r=e[t];return e.splice(t,1),e.splice(i,0,r),e}function b(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function S(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&(0,o.getOrSet)(i,e,(()=>r))}return[...i.values()]}function P(e,t,i=1,r=(e=>e)){const s=[];if(et;n-=i)s.push(r(n));return s}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,r.sortBy)(e,g),s=(0,r.sortBy)(t,g);return i.every(((e,t)=>e===s[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,n.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const r=e.map(i);for(const s of t){const t=i(s);r.includes(t)||(e.push(s),r.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let r=0;r0)return e.splice(r,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>!(0,n.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=b,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(s.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=b(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return S(t,(e=>(0,l.isPrimitive)(e)?e:(0,a.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,n.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=b(e);if(0===e.length)return[];const i=[];for(const e of(0,r.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,r.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=S,t.uniqByLast=function(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const r of e)if(null!=r){const e=t(r);null!=e&&i.set(e,r)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const r of e)null!=r&&i.every((e=>!t(r,e)))&&i.push(r);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,r)=>e+(t(i,r)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,r)=>e+t(i,r)),0)},t.firstMatch=function(e,t){for(const i of b(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const r=Math.round(i);if(r<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,a.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,r=t.primitiveValueOfOrElse){const s=new Set(i.map(r));return e.filter((e=>!s.has(r(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const r=i(40958),s=i(36783),n=i(41801),a=i(98553),o=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,s.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const r of e)(0,o.getOrSet)(i,(0,a.stringify)(t(r)),(()=>r));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,r.compact)(e),r.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,s.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,r)=>0===r||t(i)>=t(e[r-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,n.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const r=e.findIndex((e=>i(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const r=i(32639);t.asPromise=async function(e){const t=await e;return(0,r.isFunction)(t)?t():t}},75761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetImgAttrs=t.assetSqImgAttrs=t.assetVideoLink=t.assetImgActualLink=t.assetImgLink=t.assetLinkAttrs=t.assetUrl=void 0;const r=i(58939),s=i(40958),n=i(22573),a=i(42659),o=i(11371),l=i(73722),u=i(31586),c=i(54993),d=i(29652),h=i(22403),f=i(2322);function m(e,t){return e+" "+t+"w"}function p(e,t){let i=null==t?void 0:(0,d.mergeURLSearchParams)(...t);const r=(0,c.toS)(e.v);return(0,n.blank)(r)||"1"===r||(i??(i=new URLSearchParams)).append("v",r),i}function g({assetId:e,params:t}){return null==e?"":(0,d.assembleFullPath)("/asset/"+(0,r.id2id)(e),p(e,t))}function y({assetId:e,reducer:t,width:i,params:s}){return(0,d.assembleFullPath)(`/img/${(0,r.id2id)(e)}/${t}/${(0,u.toGt0)(i)??320}`,p(e,s))}function v({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/img/${(0,s.compact)([(0,r.id2id)(e),t]).join("/")}/actual`,p(e,i))}function w({assetId:e,params:t,reducer:i,widths:s,lazyLoad:n,af:l}){if(null==(0,r.id2id)(e))return{src:"/images/clear-64.png"};0===(s=(s??[]).filter(u.gt0)).length&&s.push(320);const d=Math.min(...s),p={width:(0,c.toS)(d)},g=(0,a.fmtLocalToShort)(e.capturedAtLocal);null!=g&&(p.title=g);const w=y({assetId:e,params:t,reducer:i,width:d});n??(n=!0);const b=n&&(0,f.isSafari)((0,h.ua)());b?(p.src="/images/clear-64.png",p["data-src"]=w):p.src=w,(0,f.isSafari)((0,h.ua)())||(p.loading=n?"lazy":"eager"),i===o.ReducerNames.sq&&(p.height=(0,c.toS)(d));const S=s.map((r=>m(y({assetId:e,params:t,reducer:i,width:r}),r)));return null!=l&&S.push(m(v({assetId:e,params:t,assetFileId:l.assetFileId}),l.width)),p[(b?"data-":"")+"srcSet"]=S.join(","),p}t.assetUrl=g,t.assetLinkAttrs=function({assetId:e,params:t}){const i=g({assetId:e,params:t});return(0,n.blank)(i)?{}:{href:i}},t.assetImgLink=y,t.assetImgActualLink=v,t.assetVideoLink=function({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/video/${(0,r.id2id)(e)}-${t}`,p(e,i))},t.assetSqImgAttrs=function({assetId:e,params:t,lazyLoad:i,size:r="m"}){return{...w({assetId:e,params:t,reducer:"sq",widths:l.SqWidths,lazyLoad:i}),sizes:("s"===r?80:"m"===r?160:320)*(0,u.numericOr)(globalThis?.window?.devicePixelRatio,1)+"px"}},t.assetImgAttrs=w},5233:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const r=i(41400),s=i(31586),n=i(13538),a=i(41583);t.retryOnReject_=async function(e,t){const i=(0,s.gt0)(t.timeoutMs)?()=>(0,n.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const o=t.onRetryWaitUntil??(e=>(0,r.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,a.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await o(l),u()}};return u()}},17586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(55938),o=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,a.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,a.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,s.blank)(e)?"":"```"+(0,o.toS)(e)+"```"},t.b=function(e){return"**"+(0,o.toS)(e)+"**"},t.li=function(...e){return(0,r.compactBlankish)((0,n.flatten)(e)).map((e=>"- "+(0,o.toS)(e))).join("\n")}},22573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const r=i(55835),s=i(42279),n=i(54993);function a(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function o(e){return!a(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,n.toS)(e);return o(i)?t(i):void 0}t.blank=a,t.notBlank=o,t.notBlankToS=function(e){return o(e)&&"undefined"!==e?(0,n.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,n.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,s.tot)(t);const i=(0,n.toS)(e).trim();return i.length>0?i:(0,s.tot)(t)},t.notBlankAnd=function(e,t){return!a(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,r.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,n.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{"use strict";function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function r(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!r(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!r(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=r,t.isDisabled=function(e){return r(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):r(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const r=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,r.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const r=i(40958),s=i(22573),n=i(30301),a=i(55835),o=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,n.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,a.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,o.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const r=Math.floor(e/t.hourMs);e-=r*t.hourMs;const s=Math.floor(e/t.minuteMs);e-=s*t.minuteMs;const n=Math.floor(e/t.secondMs),a=Math.floor(e-n*t.secondMs);return(0,l.pad2)(r)+":"+(0,l.pad2)(s)+":"+(0,l.pad2)(n)+(i.includeMs?"."+(0,l.pad3)(a):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},r=10*i(),s=i(),n=i(),a=i(),o=i(),l=i();return new Date(t,l-1,o,a,n,s,r)}function w(){return(new Date).setHours(24,0,0,0)}function b(e,i="ago"){return e<1e3?"just now":(i=(0,s.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const n=Math.floor(e/r.ms);e-=n*r.ms,n>0&&(r.ms>=t.dayMs?i:s).push(n+r.s)}return e>0&&s.push((0,o.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,r.isEmpty)(s)?"":"T"+s.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,a.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return b(Date.now()-e,t)},t.fmtElapsedMs=b},95892:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const r=i(38639),s=i(73872);function n(e,t,i){if(null==i||y(e)||y(t))return null;const r=i.get(e)?.get(t);return"boolean"==typeof r?r:null}function a(e,t,i,r){if(null==i||y(e)||y(t))return;let s=i.get(e);null!=s?s.set(t,r):(s=new WeakMap,s.set(t,r),i.set(e,s))}function o(e,t,i,r){if(null!=i?.comparator)return u(e,t,i,r);const s=l(e,t);return null!==s?s:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,r){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=n(e,t,u);if(null!==f)return f;const m=n(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,r);if(!1===i||!0===i)return a(e,t,u,i),i;const s=l(e,t);if(null!==s)return s}const y=s(e);if(y!==s(t))return a(e,t,u,!1),!1;a(e,t,u,!0);const v=function(e,t,i,r){switch(i){case"String":case"Number":case"Boolean":case"Date":return o(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],r);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,r);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,r);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),r);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),r);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const r=[],s=[];return e.forEach((function(e,t){r.push([e,t])})),t.forEach((function(e,t){s.push([e,t])})),c(r.sort(),s.sort(),i)}(e,t,r);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,r)}}(e,t,y,i);return a(e,t,u,v),v}function c(e,t,i){const r=e.length;if(r!==t.length)return!1;if(0===r)return!0;let s=-1;for(;++s{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,r=!1;const s=function(){if(r){if(null!=i)throw i;return t}try{return r=!0,t=e()}catch(e){throw i=e,e}};return s.prior=()=>t,s.hasPrior=()=>r,s}},41400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const r=i(42659),s=i(35556),n=i(31586),a=i(68708);function o(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const n=setTimeout((()=>i()),Math.ceil(e+.5));e>r.secondMs&&t&&s.isNode&&n.unref?.()}}))}t.delayUntil=function(e){const t=((0,n.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return o(t).then((()=>t))},t.delay=o,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),n=s.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return s.isBrowser||t<=r.secondMs?n:(0,a.maybeCall)(n,"unref")??n}},33374:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const r=i(31586),s=i(21605),n=i(12168);function a(e){return{width:e.height,height:e.width}}function o(e){return((0,r.toGt0)(e?.width)??0)*((0,r.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,r.gt0)(e.width)&&(0,r.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,r.gt0)(e)&&(0,r.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,n.pixels2size)(e.width*e.height)},t.dimSwap=a,t.maybeDimSwap=function(e,t){return(0,s.swappableRotation)(t)?a(e):e},t.maybeFlipInPlace=function(e,t){(0,s.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,n.megapixels)(o(e))},t.pixels=o},87562:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isExampleDomain=void 0;const r=i(40958),s=i(51926),n=["example.com","example.net","example.org","example.edu",".example",".local"].map((e=>(0,s.stripPrefix)(e,".").split(".")));t.isExampleDomain=function(e){const t=e.toLowerCase().split(".");return n.some((e=>(0,r.arrayEndsWith)(t,e)))}},25763:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseEmail=t.isEmailMaybe=void 0;const r=i(22573),s=i(87562),n=i(54993);t.isEmailMaybe=function(e){return null!=o(e)};const a=/^(?.+)@(?.[^@\n\r.\u2028\u2029]*\..+)$/;function o(e){const t=a.exec((0,n.toS)(e).trim());if(null==t?.groups)return;const{local:i,domain:o}=t.groups;return(0,r.blank)(i)||(0,r.blank)(o)||(0,s.isExampleDomain)(o)?void 0:{local:i,domain:o}}t.parseEmail=o},50357:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const r=i(12487),s=i(68708),n=i(34666),a=i(32639);function o(e,t){return(0,r.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,a.isFunction)(e)&&(0,a.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=o,t.eqlSubset=function(e,t){if(null==e||null==t||(0,n.isPrimitive)(e)||(0,n.isPrimitive)(t))return e===t;if(!(0,s.isObject)(e)||!(0,s.isObject)(t))return!1;for(const i of(0,s.keys)(e))if(!o(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const r=d.get(i);if(null!=r)return r(e,t)??null}for(const i of c){const r=i(e,t);if(null!=r)return r}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const r=i(40958),s=i(22573),n=i(96249),a=i(31586),o=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,s.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,a.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,r.uniq)((0,r.compactBlankish)((0,n.flatten)((0,r.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,s.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,s.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,r.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,s.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(s.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,o.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,o.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,o.assignFields)(new Error,(0,o.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},4188:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const r=i(59455);t.flatten=function(e,t=[]){for(const i of(0,r.toA)(e))if(null!=i)for(const e of(0,r.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const r=i(40958),s=i(42659),n=i(55835),a=i(31586),o=i(12168),l=[{ms:s.yearMs,s:"year",p:"years"},{ms:s.yearMs/12,s:"month",p:"months"},{ms:s.weekMs,s:"week",p:"weeks"},{ms:s.dayMs,s:"day",p:"days"},{ms:s.hourMs,s:"hour",p:"hours"},{ms:s.minuteMs,s:"minute",p:"minutes"},{ms:s.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,s){if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,n.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,r.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,o.plur)(t,e.s,e.p)}}})));return(0,r.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,n.mapOr)(s,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const r=i(40958);function s(e,t){return null==(e=(0,r.uniq)((0,r.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=s,t.orList=function(e){return s(e,"or")},t.andList=function(e){return s(e,"and")}},50268:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const r=i(22573),s=i(38639),n=i(68708),a=i(62220),o=i(50989);t.HealthCheckSections=(0,o.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,o.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,n.isObject)(e)&&!(0,r.blank)(e.id)&&!(0,r.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,r.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,n.isObject)(e)&&a.RunStates.has(e.state)&&(0,s.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},11371:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReducerNames=void 0;const r=i(50989);t.ReducerNames=(0,r.strEnum)("fit","sq")},73722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const r=i(50989);t.FitSizes=(0,r.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,r.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const r=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,r.lt0)(t))return[...e].slice(t,i);const s=e[Symbol.iterator]();if((0,r.gt0)(t))for(let e=0;e{"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(r,s){if((0,isFunction_1.isFunction)(r))return;let n,a,o,l=toJSON(r);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(r===l&&(l={...l}),delete l[e]);for(n=0;nnew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let r=0;t.Latch=class{constructor(e=r++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const r=i(40958),s=i(50357),n=i(31586),a=i(65812);t.lazy=function(e,t){let i,o;const l=[];function u(){return u.isStale()&&u.setResult(e()),o}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,r.isEmpty)(l))return;const n=await e,o=await i;if(!(0,s.eql)(n,o))for(const e of l)e(o);null!=t&&t>0&&void 0!==o&&(0,a.setUnrefTimeout)((()=>u.vacuum()),t)}(o,e),o=e},u.isStale=function(){return null==i||(0,n.gt0)(t)&&i+t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const r=i();return null!=r&&e.set(t,r),r}},t.deleteIf=function(e,t){for(const[i,r]of e.entries())t(i,r)&&e.delete(i)}},55835:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const r=i(42279),s=i(54993);function n(e,t){return null==e?void 0:t(e)}function a(e,t,i){return null==e||null==t?void 0:i(e,t)}function o(e,t){return null!=e?e:(0,r.tot)(t)}function l(e){return null!=e}t.map=n,t.mapTry=function(e,t){try{return n(e(),t)}catch{return}},t.map2=a,t.map3=function(e,t,i,r){return null==e||null==t||null==i?void 0:r(e,t,i)},t.orElse=o,t.mapOr=function(e,t,i){return null!=e?t(e):(0,r.tot)(i)},t.map2Or=function(e,t,i,r){return o(a(e,t,i),r)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,s.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const r=i(68708);class s extends Error{constructor(e,t){super(e),this.message=e,(0,r.assignFields)(this,t)}}t.MetaError=s},23838:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const r=i(40958),s=i(76790),n=i(50357),a=i(98553),o=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,r]of Object.entries(e))t.add(i,...r);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,r.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,o.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,r.pushUniq)((0,o.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const r=i.filter((e=>!(0,n.eql)(e,t)));return 0===r.length?this.store.delete(e):this.store.set(e,r),i.length!==r.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,r.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),s=null==i?[]:e(t,i);(0,r.isEmpty)(s)?this.store.delete(t):this.store.set(t,s)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,r.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,s]of this.store.entries()){const n=(0,r.findIndexes)(s,(t=>!e(i,t,s)));if(n.length>0){t=!0;for(const e of n.reverse())s.splice(e,1)}0===s.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const r of i)e.add(r,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,r]of this.entries())r.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,a.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,s.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const r=i(76790),s=i(22573),n=i(42279),a=i(54993);function o(e){return"number"==typeof e&&isFinite(e)}t.isNumber=o,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,a.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return o(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,a.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>o(t)&&o(i)&&e(t,i);function f(e,i,s){return!(null==s||!o(s))&&([e,i]=(0,r.sort)([e,i]),(0,t.lte)(e,s)&&(0,t.gte)(i,s))}function m(e){if(!o(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,s.blank)(e))return t.defaultValue;if(o(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return o(e)&&e>0}function b(e){return o(e)&&e>=0}function S(e,t){return o(e)?t(e):void 0}function P(e){return o(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function T(e,t,i){if(e>t||!o(e)||!o(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return o(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return o(e)?e:t},t.diff=function(e,t){return o(e)&&o(t)?e-t:void 0},t.absdiff=function(e,t){return o(e)&&o(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!o(e)||!o(t))return!1;if(e===t)return!0;if(i>=1)return!1;const r=(0===t?1e-5:t)*(1-i);return f(t-r,t+r,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)o(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return o(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return o(e)&&o(t)&&e>t?e:void 0},t.lte0=function(e){return o(e)&&e<=0},t.gte0=b,t.toGte0=function(e){return b(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=v(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=S,t.map2Numeric=function(e,t,i){return S(e,(e=>S(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return o(e)?t(e):i},t.numericOr=function(e,t){return o(e)?e:(0,n.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return S(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!o(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),r=Math.pow(10,Math.abs(i));return i<0?P(e/r)*r:P(e*r)/r},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=T,t.times=function(e,t){if(!w(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return T(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!o(i))return;t+=i}return t}},68708:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const r=i(40958),s=i(76790),n=i(22573),a=i(32639),o=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,r]=i;null!=e&&void 0!==r&&("object"!=typeof t&&(t={}),t[e]=r)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,r.isEmpty)(i)?void 0:y(i)}function w(e,t,i={}){return y((0,r.compact)((0,s.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function b(...e){const t=(0,r.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const s={};for(const e of(0,r.uniq)((0,r.flatMap)(i,h)))s[e]=b(...i.map((t=>t[e])));return s}function S(e,t){if(!d(e)||(0,n.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=v(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[r,s]of g(t))!0!==i?.omitKeys?.includes(r)&&(null==s&&!0!==i?.assignNullish||(e[r]=s));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const r of i){const i=t[r];void 0!==i&&void 0===e[r]&&(e[r]=i)}return e},t.assignAllFields=function(e,t){for(const[i,r]of g(t??{}))e[i]=r;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,r.isEmpty)(i)?void 0:y(i)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,r.compact)(t.map(e));{const i=(0,r.compact)(g(t).map((([t,i])=>(0,o.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,n.notBlank)(t)));return(0,r.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=b,t.pick=function(e,...t){if(null==e)return e;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const r of t)void 0!==e[r]&&(i[r]=e[r]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const r of t){const t=e[r];(0,n.notBlank)(t)&&(i[r]=t)}return i},t.pickFirst=function(e,t,i=o.defined){if(null!=e)for(const r of t)if(i(e[r]))return e[r]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const r={};function s(e,t){if(null==t)return;const i=r[e];r[e]=null==i?t:b(i,t)}for(const r of i){const[i,a]=(0,c.splitFirst)(r,"."),o=S(t,i);null!=o?.value&&s(o.key,(0,n.blank)(a)?o.value:e(o.value,a))}for(const r of h(t))((0,l.toInt)(r)??-1)>=0&&s(r,e(t[r],...i));return r},t.pluck=S,t.pluckDeep=function e(t,i){if(null==t||(0,n.blank)(i))return;if(Array.isArray(t)){const s=(0,r.compact)(t.map((t=>e(t,i))));return(0,r.isEmpty)(s)?void 0:{key:s[0].key,value:(0,r.flatMap)(s,(e=>e.value))}}const[s,a]=(0,c.splitFirst)(i,"."),o=S(t,s);if(null==o)return;if((0,n.blank)(a))return o;const l=e(o.value,a);return null==l?void 0:{key:o.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,n.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,r.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,r.uniq)(t)},t.maybeCall=function(e,t,...i){const r=e?.[t];return(0,a.isFunction)(r)?r.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,n.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=w(t,((t,i)=>[t,e(i)])),r=p(i);return 1===r.length?r[0]:i}},97790:(e,t)=>{"use strict";var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>n(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class r{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new r(e(this.a))}flatMap(e){const t=e(this.a);return s(t)?t:n(t)}filter(e){return n(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return n(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return n(e).flatMap((e=>n(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,r){return n(e).flatMap((e=>n(t).flatMap((t=>n(i).flatMap((i=>r(this.a,e,t,i)))))))}}function s(e){return e instanceof r||e===t.None}function n(e){return s(e)?e:null!=e?new r(e):t.None}t.Some=r,t.isOpt=s,t.opt=n},97238:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toSeed=t.prngSeed=t.SeedCount=t.PrimeBins=t.PrimesPerBin=void 0;const r=i(31586),s=i(30976),n=i(54993);t.PrimesPerBin=4,t.PrimeBins=8,t.SeedCount=t.PrimesPerBin**t.PrimeBins,t.prngSeed=function(){return(0,s.randomInt)(0,t.SeedCount)},t.toSeed=function(e){const i=(0,r.toInt)((0,n.toS)(e));return(0,r.within)(0,t.SeedCount,i)?i:void 0}},39926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const r=i(31586),s=i(54993),n={};function a(e,t){if(t<1)return"";if(!(0,r.gte)(n[e]?.length,t)){let i=n[e]??e;for(;i.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var r=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return r.parseJSON}})},46891:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const r=i(22573),s=new Map([["child","children"],["photo","photos"],["video","videos"]]),n=/([sxz]|ss|sh|ch)$/,a=/[^aeiou]y$/,o=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,r.blank)(e))return e;const t=s.get(e);return null!=t?t:null!=e.match(n)?e+"es":null!=e.match(a)?e.replace(/y$/i,"ies"):null!=e.match(o)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const r=i(40958),s=i(54993),n=["number","string","boolean"];function a(e){return-1!==n.indexOf(typeof e)}t.isPrimitive=a,t.mapPrimitive=function(e,t){return a(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return a(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(a)};const o=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const r=typeof e,n=typeof i;if(!("string"!==r&&"symbol"!==r||"string"!==n&&"symbol"!==n)){const r=(0,s.toS)(e),n=(0,s.toS)(i),a=r.localeCompare(n);return r[0]===t.CmpReverseFlag&&n[0]===t.CmpReverseFlag?-a:a}return Array.isArray(e)&&Array.isArray(i)?u(e,i):r!==n?o.indexOf(r)-o.indexOf(n):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const r=i(59455);function s(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const s of(0,r.toA)(await e))if(null!=s){const e=await s;if(null!=e){const r=await t(e);null!=r&&i.push(r)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=s,t.isPromise=function(e){return s(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const r=await e;return t(r)?i(r):void 0}},57153:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const r=i(50989);t.PromiseStates=(0,r.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const r=i(40958),s=i(31586);function n(e,t){return Math.floor(Math.random()*(t-e))+e}function a(e,t,i){return null==i||0===i.length?n(e,t):o(e,t,1,i)[0]}function o(e,t,i,r){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const s=t-e,a=new Set(r??[]);if(t===e&&0===s&&0===a.size&&1===i)return[e];const o=s-a.size;if(i>o)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:s,size:i,slotsRemaining:o})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const r of o(0,e.length,t))i.push(e[r]);return i},t.pickWeightedRandom=function(e){if((0,r.isEmpty)(e))return;const t=e.filter((e=>(0,s.gt0)(e.priority)));let i=l(0,(0,r.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let r=e;t.global||(t=new RegExp(t,"g"));let s=null;for(;null!=(s=t.exec(e));)s.index===t.lastIndex&&t.lastIndex++,r=r.slice(0,s.index)+i(s)+r.slice(s.index+s[0].length);return r}},21605:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const r=i(31586);function s(e){if(!(0,r.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,r.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=s,t.swappableRotation=function(e){const t=s(e);return 90===t||270===t}},62220:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const r=i(50989);t.RunStates=(0,r.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const r=i(50989);t.ServiceNames=(0,r.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const r=i(68708),s=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,r.fromEntries)(t.map(((e,t)=>[e,t]))),n={};for(const e of t)n[e]=e;const a=e=>null!=e?i[e]:void 0,o=e=>null!=a(e);return{...n,values:t,length:t.length,has:o,includes:o,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:a,ordinal:e=>a(e)??t.length,validOrElse:(e,t)=>o(e)?e:(0,s.tot)(t),mapValid:(e,t)=>o(e)?t(e):void 0,cmp:(e,t)=>{const i=a(e),r=a(t);return null==i||null==r?void 0:i>r?1:i{const i=a(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const r=i(40958),s=i(17586),n=i(22573),a=i(96249),o=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const r=f();return null!=r?(0,o.sliceIterable)(r.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.startsWith(r)?i.slice(r.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),r=(0,c.toS)(t);return r.length>0&&i.endsWith(r)?i.slice(0,-r.length):i}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function b(e,t,i){null==i&&(i=e.length);for(let r=i;r>=0;r--)if(m(e,r).startsWith(t))return r;return-1}function S(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const r=(0,c.toS)(e),s=(0,c.toS)(t);return r.length===s.length&&(r===s||r.toLowerCase()===s.toLowerCase()||"function"==typeof r.localeCompare&&0===(i?r.normalize():r).localeCompare(i?s.normalize():s,void 0,{sensitivity:"base"}))}function P(e,t){return(0,r.isEmpty)(e)||(0,n.blank)(t)?void 0:e.find((e=>S(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,s.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,o.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const r=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&r.startsWith(t))return e(r.slice(t.length),i);return r},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return w(v(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const r=p(e);return r.length<=t?r.join(""):r.slice(0,t-1-i).join("")+"…"+(i>0?r.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=b,t.wrap=function e(t,i){const r=i?.maxLineLen??80,s=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const r=(0,a.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,a.flatten)(r.map((t=>e(t,i))))}if((t=v((0,c.toS)(t),s).trim()).length<=r)return[t];const n=b(t," ",r);if(n>s.length)return[m(t,0,n),...e(m(t,n+1),i)];{const r=t.indexOf(" ",s.length+1);return r>0&&r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const r=i(42659),s=i(68708),n=i(42279),a=i(83104),o=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,r)=>{let s=!0;const n=setTimeout((()=>{s&&(s=!1,i(a.Timeout))}),t);try{n.unref?.();const t=await e;s&&(s=!1,i(t))}catch(e){s&&(s=!1,r(e))}finally{clearTimeout(n)}}))}async function u(e,t,i=!0){const s=await l(e,t,i);if(s===a.Timeout)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(t)+")");return s}t.toNotTimeout=function(e){return e===a.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const r=t-Date.now();return r<=0?a.Timeout:l(e,r,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(r,n)=>{let a=!0;try{const o=setTimeout((async()=>{if(a){a=!1;try{r(await i())}catch(e){n(e)}}}),t);(0,s.maybeCall)(o,"unref");const l=await e;a&&(a=!1,clearTimeout(o),r(l))}catch(e){a&&(a=!1,n(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const s=t-Date.now();if(s<=0)throw new o.TimeoutError("timeout ("+(0,r.fmtHMS)(s)+")");return u(e,s,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:r=!0}){const s=await l(e,t,r);return s===a.Timeout?(0,n.tot)(i):s}},99036:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbFits=void 0;const r=i(50989);t.ThumbFits=(0,r.strEnum)("aspect","square")},42279:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const r=i(32639);t.tot=function(e){return(0,r.isFunction)(e)?e():e},t.tol=async function(e){return(0,r.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const r=i(40958),s=i(22573),n=i(54993);function a(e){return"URLSearchParams"===e?.constructor?.name}function o(e){return null==e?void 0:a(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,r.compact)(e.map(o)),i=t.shift();if(null!=i){for(const e of t)for(const[t,r]of e.entries())i.set(t,r);return i}}t.isURLSearchParams=a,t.toURLSearchParams=o,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,n.toS)(l(...t));return e+((0,s.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,n.toS)(l(...t));return(0,s.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const r=i(22573),s=i(30301),n=i(31586),a=i(46891),o=i(50989),l=i(51926),u=(0,s.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,s.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const r of e)(0,n.isNumber)(r)&&(i+=r/t.MB);return(0,n.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,r.mapNotBlank)(e,(e=>(0,n.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,n.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),r=Math.floor(i/3),s=Math.pow(10,3*r),a=d[r];return(0,n.sigFigs)(e/s,t)+" "+a}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),r=Math.floor(i/10),s=Math.pow(2,10*r),a=h[r];return(0,n.sigFigs)(e/s,t)+" "+a},t.MP=1e6,t.megapixels=function(e){return(0,n.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,o.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,r.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,a.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,a.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const r=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,r.maybeCall)(i,"unref")??i}},22403:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ua=void 0;const r=i(30301),s=i(54993);t.ua=(0,r.lazy)((()=>(0,s.toS)(globalThis?.navigator?.userAgent)))},2322:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,r=/\bSafari\b/,s=/\bFirefox\b/,n=/\biPad\b/,a=/\biPhone\b/;function o(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return o(e,i)}function u(e){return o(e,s)}t.isChrome=l,t.isSafari=function(e){return o(e,r)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return o(e,n)},t.isIphone=function(e){return o(e,a)}},32790:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeQuote=t.AssetQueryOrderByColumns=void 0;const r=i(50989),s=i(54993);t.AssetQueryOrderByColumns=(0,r.strEnum)("capturedAt","updatedAt"),t.maybeQuote=function(e){return null!=(e=(0,s.toS)(e).trim()).match(/\s/)?`"${e}"`:e}},58939:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.idEql=t.id2id=void 0;const r=i(55835),s=i(31586);function n(e){const t=e;return(0,s.isNumber)(e)?e:(0,s.isNumber)(t.id)?t.id:(0,s.isNumber)(t.assetId)?t.assetId:(0,s.isNumber)(t.tagId)?t.tagId:void 0}t.id2id=n,t.idEql=function(e,t){return(0,r.map2Or)(n(e),n(t),((e,t)=>e===t),(()=>!1))}},12236:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressWithAssetsProps=t.noRecentAssetIdsProgress=t.isRebuildProgress=t.EmptyRemovedURI=t.EmptyDeletedURI=t.RebuildingURI=t.SyncStatuses=void 0;const r=i(50989);t.SyncStatuses=(0,r.strEnum)("processing","paused","done"),t.RebuildingURI="rebuilding://",t.EmptyDeletedURI="emptydeleted://",t.EmptyRemovedURI="emptyremoved://",t.isRebuildProgress=function(e){return t.RebuildingURI===e?.uri},t.noRecentAssetIdsProgress=function(e){return[t.EmptyDeletedURI,t.EmptyRemovedURI].includes(e?.uri)},t.ProgressWithAssetsProps=["uri","volume","state","hed","dek","completePct","incompletePct","scanningPct","recentAssetIds"]},41942:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkReplace=t.XLocationReplace=t.mkRedirect=t.XLocationRedirect=void 0,t.XLocationRedirect="X-Location-Redirect",t.mkRedirect=function(e,i){return{[t.XLocationRedirect]:e,toast:i}},t.XLocationReplace="X-Location-Replace",t.mkReplace=function(e,i){return{[t.XLocationReplace]:e,toast:i}}},71050:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isServerToast=t.DismissAnchor=t.isToastPlusOnly=void 0;const r=i(22573);t.isToastPlusOnly=function(e){return!0===e?.toastPlusOnly},t.DismissAnchor="#dismiss",t.isServerToast=function(e){return(0,r.notBlank)(e?.text)}},79114:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.S=void 0;const r=i(50989);t.S=(0,r.strEnum)("plus","lite")},75020:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isInfoTag=t.NotInfoPanelTags=t.LibraryTagName=t.TagRoots=t.isTagRef=t.ctxToS=t.TagGalleryProps=t.nextChildTagsUrl=t.nextAssetsUrl=t.BeforeAfterStreamLimit=t.ThumbsPerSample=void 0;const r=i(76790),s=i(22573),n=i(98553),a=i(31586),o=i(50989),l=i(51926),u=i(29652);t.ThumbsPerSample=128,t.BeforeAfterStreamLimit=8,t.nextAssetsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/assets`,i)},t.nextChildTagsUrl=function(e,t){const i={};return(0,a.mapNumeric)(t.seed,(e=>i.seed=e.toString())),(0,a.mapNumeric)(t.limit,(e=>i.limit=e.toString())),(0,a.mapNumeric)(t.offset,(e=>i.offset=e.toString())),(0,u.assembleFullPath)(`/api/t/${e}/child-tags`,i)},t.TagGalleryProps=["tagId","tagPath","assetCount","assetIds","nextAssets","childTags","nextChildTags"],t.ctxToS=function(e){return(0,n.stringify)({seed:e.seed,tagIds:(0,r.sort)([...e.tagIds])})},t.isTagRef=function(e){return null!=e&&!(0,l.isString)(e)&&(0,s.notBlank)(e.name)},t.TagRoots=(0,o.strEnum)("When","Who","Where","What","Camera","Lens","Albums","Keywords","Type","fs"),t.LibraryTagName="Library",t.NotInfoPanelTags=[t.TagRoots.When,t.TagRoots.Camera,t.TagRoots.Lens,t.TagRoots.Type,t.TagRoots.fs],t.isInfoTag=function(e){if(null==e)return!1;const i=(0,l.isString)(e)?e:e.tagPath?.[0];return!t.NotInfoPanelTags.includes(i)}},94383:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiProgressPath=void 0,t.ApiProgressPath="/sse/progress"},27776:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mkTagUri=t.mkTagFullPath=t.mkHomeFullPath=t.urlSeed=void 0;const r=i(40958),s=i(30301),n=i(31586),a=i(97238),o=i(29652);function l(e,i){const r=(0,o.toURLSearchParams)(e);if(i||!(0,n.isDigits)(r?.get("seed"))){const e=(0,t.urlSeed)().toString();return r?.set("seed",e),r??{seed:e}}return r}function u(e,t,i=!1){const r=c(e,t,i);return(0,o.assembleFullPath)(r.path,r.query)}function c(e,t,i=!1){return{path:"/tag/"+((0,r.isEmpty)(e)?"":e.map(encodeURIComponent).join("/")),query:l(t,i)}}t.urlSeed=(0,s.lazy)(a.prngSeed,100),t.mkHomeFullPath=function(e){return u([],e,!0)},t.mkTagFullPath=u,t.mkTagUri=c},23541:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const r=i(41801),s=i(51926);function n(e){return Array.isArray(e)?e:null==e?void 0:(0,s.isString)(e)?[e]:(0,r.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return n(e)??[]},t.optToA=n},41583:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const r=i(40958),s=i(23541),n=i(59455),a=i(54993);function o(e){return null==e?void 0:(0,s.isError)(e)?e:new Error((0,a.toS)(e))}t.toErr=o,t.toErrs=function(...e){return(0,r.compact)((0,n.toA)(e).map(o))}},54993:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const r=i(98553);t.toS=function(e){return n(e,",")};const s={}.toString;function n(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>n(e,t))).join(t):e.toString!==s?e.toString():(0,r.stringify)(e)}}t.toStr=n},98401:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cancelFileAndProcCleanups=t.scheduleFileAndProcCleanups=t.fileCleanups=t.cleanup_=t.maybeCleanup_=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(56519),o=i(76187),l=i(87290),u=i(79267),c=i(32144),d=i(13829),h=i(69734),f=i(95696),m=i(65238),p=i(70257),g=i(13940),y=i(12495),v=i(95402),w=i(28874),b=i(40958),S=i(42659),P=i(31586),_=i(64526),T=i(22526),M=i(69032),E=(0,r.lazy)((()=>(0,s.mkLogger)("library.Cleanup")));async function k(){const e=_.Library.instance();if(null==e)E().info("No library to vacuum.");else{E().info("Running tag and search maintenance...");try{await(0,M.runTagMaintenance)()}catch(e){E().warn("Failed to run tag maintenance",{error:e})}E().info("Vacuuming db..."),await(await e.dbModelSetup_()).db.vacuum(),(0,n.isDbJanitorService)()&&(E().info("Running database maintenance..."),await e.runDbBackup_())}E().info("Cleaning child processes..."),await(v.Pids.instance()?.killOldProcs()),E().info("Cleaning stale and temp files..."),await D(),await(0,a.mapAsync)({name:"fileCleanup",arr:j(),f:e=>e.cleanup()})}t.maybeCleanup_=(0,r.lazy)(k,5*S.minuteMs),t.cleanup_=k;const D=(0,r.lazy)((()=>(0,l.libraryDataDirPosixFile)()?.join("shared-state").rmrf())),x=(0,r.lazy)((()=>u.FileCleanup.for({name:"imageCacheCleanup",rootNativePath:g.imageCacheDir_,staleMs:w.Settings.imageCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(g.ImageCacheName)}))),C=(0,r.lazy)((()=>u.FileCleanup.for({name:"readdirCacheCleanup",rootNativePath:async()=>f.PosixFile.for((0,m.readdirCacheDir)()),staleMs:w.Settings.readdirCacheMs.valueOrDefault,isPrunable:e=>e.pathnames.includes(m.ReadDirCacheName)}))),F=(0,r.lazy)((()=>u.FileCleanup.for({name:"previewWipCleanup",rootNativePath:l.libraryPreviewsDirPosixFile,staleMs:S.hourMs,isPrunable:e=>(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)}))),A=(0,r.lazy)((()=>u.FileCleanup.for({name:"advisoryLockWipCleanup",rootNativePath:d.defaultFsAdvisoryLockDir,staleMs:S.hourMs,isPrunable:h.isPsLockFileOrDir}))),I=(0,r.lazy)((()=>u.FileCleanup.for({name:"syncReportCleanup",rootNativePath:()=>(0,P.gt0)(w.Settings.syncReportRetentionCount.valueOrDefault)?(0,l.librarySyncReportsDir)():void 0,staleMs:S.hourMs,isPrunable:e=>(0,p.isWip)(e)||(0,c.isCsvExt)(e)})));function O(e){return(0,h.isPsLockFileOrDir)(e)||(0,p.isWip)(e)||(0,o.isSqliteFile)(e)}const L=(0,r.lazy)((()=>u.FileCleanup.for({name:"oldLibraryDbBackupCleanup",rootNativePath:()=>(0,T.libraryDbObjects_)().libraryDbBackupDir.sibling("backup"),staleMs:S.hourMs,isPrunable:O}))),R=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryDbBackupCleanup",rootNativePath:()=>(0,T.libraryDbObjects_)().libraryDbBackupDir,staleMs:S.hourMs,minRetained:w.Settings.dbBackupRetentionCount.valueOrDefault,isPrunable:O})));async function N(){const e=await(_.Library.instance()?.dbModelSetup_());return null!=e&&e.useReplica?e.db.localBackupDir():void 0}const B=(0,r.lazy)((()=>u.FileCleanup.for({name:"libraryReplicaDbBackupCleanup",rootNativePath:N,staleMs:S.hourMs,minRetained:1,isPrunable:O})));function j(){return(0,b.compact)([x(),C(),F(),A(),(0,y.LogDirCleanup)(),I(),L(),R(),B()])}t.fileCleanups=j,t.scheduleFileAndProcCleanups=(0,r.lazy)((()=>{v.Pids.instance()?.scheduleInterval();for(const e of j())e.scheduleInterval()})),t.cancelFileAndProcCleanups=function(){t.scheduleFileAndProcCleanups.unset(),v.Pids.instance()?.cancelInterval();for(const e of j())e.cancelInterval()}},64526:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Library=void 0;const l=i(27395),u=i(25764),c=i(38836),d=i(99331),h=i(45608),f=i(15056),m=i(87290),p=i(38835),g=i(57159),y=i(61704),v=i(95696),w=i(18454),b=i(13940),S=i(48604),P=i(19851),_=i(23560),T=i(28874),M=i(2858),E=i(7014),k=i(63870),D=i(15674),x=i(22573),C=i(38639),F=i(42659),A=i(56409),I=i(68708),O=i(25470),L=i(22526),R=i(41844);class N extends c.EndableWrapper{static instance(){const e=T.Settings.libraryDir.valueOrDefault,t=a(this,r,"f",s)?.rootDir.nativePath,i=!0===a(this,r,"f",s)?.isReadySync(),n=!0===a(this,r,"f",s)?.ended;return(0,y.nativePathsEqlSync)(t,e)&&!n?a(this,r,"f",s):(0,_.isSyncService)()&&i?void(0,h.exit)({reason:`Library changed mid-run. Shutting down to pick up new library at ${e}.`,status:0}):((0,l.end)(a(this,r,"f",s)),o(this,r,(0,x.blank)(e)||!(0,M._libraryHasSettings)(e)?void 0:new r(e),"f",s))}static get priorInstance(){return a(this,r,"f",s)}static endPriorInstance(){const e=a(this,r,"f",s);return o(this,r,void 0,"f",s),(0,l.end)(e)}static async instanceReady(){const e=r.instance();return await(e?.ready),e}static instanceRequired_(){const e=r.instance();if(null==e)throw new Error("Library is undefined"+p.FatalErrorFlag);return e}constructor(e){super(`library.Library(${e})`,(()=>this.onEnd()),u.EndableRanks.predb),this.start=Date.now(),this.readyLatch=new A.Latch,n.set(this,(0,P.lazy)((async()=>{try{this.logger.debug("setup() started"),this.logger.throwIfAborted_(),await(0,M.readLibrarySettings)(this.rootDir.nativePath),await(0,m.setupLibraryDirs_)(this.rootDir),await(0,b.imageCacheDir_)(),this.logger.throwIfAborted_();const e=await(0,E.bestVolumeForPath)((0,m.libraryPreviewsDirPosixFile)(this.rootDir));if((0,C.isTrue)(e?.remote)){const e=T.Settings.maxConcurrentImportsWhenRemote.valueOrDefault;T.Settings.maxConcurrentImports.hasValue()||(T.Settings.maxConcurrentImports.tmpValue=e,(0,D.clearMaxWorkCaches)()),this.logger.warn(`Library previews are on a remote volume. Setting maxSyncFileJobsMax to ${e}.`)}this.logger.throwIfAborted_(),(0,_.isDbService)()&&await this.dbModelJanitor(),this.previews(),this.logger.throwIfAborted_(),this.readyLatch.isPending()&&(this.logger.info("Library.setup() finished."),this.readyLatch.resolve())}catch(e){this.ended||(0,d.ending)()||(this.logger.warn("setup() failed:",{error:e}),w.HealthCheck.addError(e),this.readyLatch.reject(new g.WrappedError("Failed to start library",{cause:e})))}}))),this.previews=(0,P.lazy)((()=>(0,I.tap)(new S.Previews((0,m.libraryPreviewsDirPosixFile)(this.rootDir)),(e=>S.Previews.instance.set(e))))),this.originalsDir=(0,P.lazy)((()=>(0,m.libraryOriginalsDirPosixFile)(this.rootDir))),this.assetFileRepository=(0,P.lazy)((()=>new R.AssetFileRepository(this.originalsDir()))),this.libraryDbFile=(0,P.lazy)((()=>(0,f.pathToDb)(this.dataDir,"models"))),this.dbModelSetup_=(0,P.lazy)((async()=>{if((0,_.isDbService)())return(0,L.dbModelSetup_)(this.rootDir);throw new Error("Not a db service")})),this.dbFsLock=(0,P.lazy)((async()=>(await this.dbModelSetup_()).fslock)),this.useReplica=(0,P.lazy)((async()=>(await this.dbModelSetup_()).useReplica)),this.modelDb=(0,P.lazy)((async()=>(await this.dbModelSetup_()).db)),this.dbModelJanitor=(0,P.lazy)((async()=>O.DbModelJanitor.for(await this.dbModelSetup_()))),this.onEnd=(0,P.lazy)((async()=>{if(!(0,d.ending)())for(const{ea:e,t}of[{ea:this.dbModelJanitor.clear(),t:5*F.minuteMs},{ea:this.dbFsLock.clear(),t:(0,k.commandTimeoutMs)()}])await(0,l.end)(e,t);this.logger.info("onEnd(): finished.")})),this.rootDir=v.PosixFile.for(e),this.dataDir=(0,m.libraryDataDirPosixFile)(this.rootDir),this.logger.info("new()"),a(this,n,"f").call(this)}get isPendingSetup(){return this.readyLatch.isPending()}get ready(){return this.readyLatch.promise.then((()=>this))}isReadySync(){return this.readyLatch.isResolved()}async runDbBackup_(){return(await this.dbModelJanitor())?.backup_()}}t.Library=N,r=N,n=new WeakMap,s={value:void 0}},19113:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryFileFiltersFor=void 0;const r=i(62105),s=i(181),n=i(94448),a=i(39604);t.libraryFileFiltersFor=function(e,{validateFile:t=!1}={}){const i=(0,r.expensiveFileFiltersFor)(e);return null!=(0,n.modelDb)()&&i.push({notBlocklistedSha:a.notBlocklistedSha}),t&&i.push({isValidFile:s.isValidFile}),i}},78339:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.saveLibrarySettings=t.importSettings=t.librarySettings=void 0;const r=i(19851),s=i(50213),n=i(71567),a=i(87290),o=i(98314),l=i(95696),u=i(28874),c=i(2858),d=i(32707),h=i(22573),f=i(50357),m=i(54993),p=i(14611),g=(0,s.mkLogger)("LibrarySettings");function y(e={}){return g.tap({msg:"librarySettings",level:"info",result:{scanAllDrives:u.Settings.scanAllDrives.valueOrDefault,scanPath:u.Settings.scanPaths.values,copyAssets:u.Settings.copyAssetsToLibrary.valueOrDefault,autoUpdateCheck:u.Settings.autoUpdateCheck.value,allowUserAgent:u.Settings.allowUserAgent.value,reportErrors:u.Settings.reportErrors.value,...e}})}function v(e){u.Settings.scanAllDrives.setValueIfDefined(e.scanAllDrives),u.Settings.scanPaths.setValueIfDefined(e.scanPath),u.Settings.copyAssetsToLibrary.setValueIfDefined(e.copyAssets),u.Settings.autoUpdateCheck.setValueIfDefined(e.autoUpdateCheck),u.Settings.allowUserAgent.setValueIfDefined(e.allowUserAgent),u.Settings.reportErrors.setValueIfDefined(e.reportErrors)}t.librarySettings=y,t.importSettings=v,t.saveLibrarySettings=async function(e,t){const i=l.PosixFile.forMaybe((0,m.toS)(e).trim())?.resolve(),s=y(),w=u.Settings.libraryDir.valueOrDefault,b=i??l.PosixFile.forMaybe(w);let S=Promise.resolve();const P=(0,r.lazy)((()=>{S=S.then((async()=>{try{v(s),u.Settings.libraryDir.value=w,await(0,c.writeSystemSettings_)(),(0,h.blank)(w)||await(0,c.writeLibrarySettings_)(w),await(0,p.restartLibrary_)()}catch(e){g.warn("Failed to roll back to prior settings",{priorSettings:s,priorLibraryDirValue:w,error:e})}}))}));if(null==b)return{error:"Please choose a directory for your library.",ready:S};const _=b?.nativePath!==w;if(_){try{await(0,a.setupLibraryDirs_)(b)}catch(e){return{error:"Failed to set up "+b+". Please choose a different directory for your library. "+(0,o.errorToS)(e)}}g.info("Library directory changed, asking sync to shut down",{prior:w,new:i?.nativePath}),n.StdoutWrite.shutdownSync()}try{v(t);const e=!(0,f.eql)(s,y());if(null==await(0,c.writeLibrarySettings_)(b.nativePath))return P(),{error:"Cannot write to "+b.nativePath+". Please choose a different directory for your library.",ready:S};u.Settings.libraryDir.value=b.nativePath;try{await(0,c.writeSystemSettings_)()}catch(e){return P(),g.warn("Failed to write system settings",e),{error:"Couldn't write your system settings to "+(0,d.systemSettingsFile)()+": "+(0,o.errorToS)(e),ready:S}}return g.info("saveLibrarySettings()",{libraryDirChanged:_,librarySettingsChanged:e,settings:t,priorSettings:s,currentSettings:y()}),(_||e)&&(S=S.then((()=>(0,p.restartLibrary_)({readSettings:!1})))),{msg:"Saved",ready:S}}catch(e){return P(),g.error("Failed to save settings",{error:e}),{error:"Failed to save settings: "+(0,o.errorToS)(e),ready:S}}}},14611:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.restartLibrary_=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(71567),o=i(34102),l=i(18454),u=i(28874),c=i(2858),d=i(64526),h=(0,r.lazy)((()=>(0,s.mkLogger)("library.RestartLibrary")));t.restartLibrary_=async function(e){if((0,n.isWebService)()&&a.StdoutWrite.shutdownSync(),e?.readSettings??1){for(const e of(0,u.persistedSettings)())e.unsetFileValue();await c.readSettings.refresh()}let t=Promise.resolve();h().warn("Shutting down prior library...");try{t=d.Library.endPriorInstance()}catch(e){h().warn("ending prior library failed:",{error:e})}(0,o.ee)().emit("clearCache"),null!=e?.libraryDir&&e.libraryDir!==u.Settings.libraryDir.valueOrDefault?u.Settings.libraryDir.value=e.libraryDir:u.Settings.libraryDir.broadcastChange(),l.HealthCheck.reset();const i=d.Library.instance();return t=t.then((()=>i?.ready)).then((()=>{})),(0,n.isWebService)()&&(t=t.then((async()=>{const e=await l.HealthCheck.awaitSettled();"ready"===e.state?a.StdoutWrite.restartSync():h().error("Restarted library, but health check summary was not ready",{summary:e})}))),{ready:t}}},18449:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sentryEnabled=void 0;const r=i(7282),s=i(96706),n=i(29325),a=i(28874);t.sentryEnabled=function(){return(0,s.isEnvTrue)("ENABLE_SENTRY")||(0,r.isProd)()&&(0,n.isPacked)()&&!0===a.Settings.reportErrors.value}},95629:function(e,t,i){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,i,r){void 0===r&&(r=i);var s=Object.getOwnPropertyDescriptor(t,i);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,r,s)}:function(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&r(t,e,i);return s(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelToSeverity=t.logEntryToBreadcrumb=t.mkBreadcrumbs=t.annotateEvent=t.sentryExceptionToS=t.sentryExceptionsToS=t.extractMessage=t.EventFilter=t.eventFilter=t.sendToSentry=t.installSentry=void 0;const o=n(i(16436)),l=a(i(48161)),u=a(i(1708)),c=i(19851),d=i(19043),h=i(50213),f=i(31578),m=i(7282),p=i(96175),g=i(23560),y=i(84968),v=i(81168),w=i(37805),b=i(25764),S=i(38836),P=i(99331),_=i(85100),T=i(98314),M=i(68301),E=i(70025),k=i(8769),D=i(34102),x=i(34592),C=i(42042),F=i(34474),A=i(20839),I=i(57902),O=i(45969),L=i(43334),R=i(40958),N=i(22573),B=i(42659),j=i(41400),z=i(98553),V=i(55835),W=i(12168),U=i(59455),q=i(54993),H=i(18449),$=(0,c.lazy)((()=>(0,h.mkLogger)("Sentry")));function G(e){(0,H.sentryEnabled)()&&null!=e&&!0!==(0,E.isDoNotSendError)(e)&&o.captureException(e)}t.installSentry=async function(e){try{return!!(0,H.sentryEnabled)()&&(o.init({dsn:L.isElectron?"https://0652cdd351054fe9853ff944b1f54e2c@o130922.ingest.sentry.io/289071":"https://5f52aefec1b3439eaed2e77b2d1210a8@o130922.ingest.sentry.io/1828379",shutdownTimeout:(0,_.serviceExitTimeoutMs)(e.name),release:w.release,environment:(0,m.nodeEnv)(),maxBreadcrumbs:100,integrations:[],beforeSend:(0,t.eventFilter)().beforeSend,onFatalError:e=>(0,k.onError)("sentry.onFatalError",e)}),$().info("Sentry initialized",{isElectron:L.isElectron}),!0)}catch(e){return $().warn("Failed to set up sentry",{error:e}),!1}},t.sendToSentry=G,t.eventFilter=(0,c.lazy)((()=>new J));class J{constructor(){this.beforeSend=async(e,t)=>{if(!(0,H.sentryEnabled)())return $().warn("Sentry.beforeSend(): not sending event",e),null;if(!0===await(M.ErrorStore.instance()?.eventQuotaExceeded(e)))return $().warn("Sentry.beforeSend(): event quota exceeded",e),null;const i=K(e,t);if(!0===(0,E.isDoNotSendError)(i))return $().info("Sentry.beforeSend(): event not sendable. vetoing",{event:e,hint:t,msg:i}),null;(0,N.blank)(e.message)&&(e.message=(0,v.ellipsize)(i,256));const r=await Z(e);return await(M.ErrorStore.instance()?.maybeSendEvent(r))??null},(0,D.ee)().on("fatal",G),(0,D.ee)().on("nonFatal",G),new S.EndableWrapper("EventFilter",(()=>this.end()),b.EndableRanks.first)}end(){return(0,V.map)(o.getCurrentHub().getClient(),(e=>e.close(5*B.secondMs)))}}function K(e,t){return(0,R.uniq)((0,R.compactBlankish)([e.message,...(0,U.toA)(Y(e.exception?.values)),(0,T.errorToS)(t?.originalException)])).join(": ")}function Y(e){return(0,R.mapNotEmpty)(e,(e=>(0,R.compactBlanks)(e.map(X))))}function X(e){return(0,R.mapNotEmpty)((0,R.compactBlanks)([e?.type,e?.value].filter((e=>"error"!==(0,q.toS)(e).toLowerCase()))),(e=>e.join(": ")))}async function Z(e){const t=await(0,C.getEmail)();(0,N.notBlank)(t)&&(null==e.user&&(e.user={}),e.user.email=t),(0,R.isEmpty)(e.breadcrumbs)&&(e.breadcrumbs=await Q());const i=e.extra??{};return i.pid=u.default.pid,i.serviceName=(0,g.serviceName)(),i.serviceEnding=(0,P.ending)(),i.runtimeMs=(0,y.runtimeMs)(),i.version=w.version,i.os=(0,p.osFullName)(),i.isDocker=(0,O.isDocker)(),i.nodeVersion=u.default.versions.node,i.locale=await(0,d.locale)(),i.cpus=(0,p.CPUs)(),i.memoryUsageMb=(0,f.memoryUsageMb)(),i.memoryUsageRssMb=(0,f.memoryUsageRssMb)(),i.systemMemory=(0,W.fmtBytes)(l.default.freemem())+" / "+(0,W.fmtBytes)(l.default.totalmem()),i.ffmpeg=await(0,x.ffmpegVersionDescription)(),i.argv=(0,z.stringify)(u.default.argv),e.extra=i,{timestamp:Date.now()/B.secondMs,...e}}async function Q(){await(0,j.delay)(3*A.DefaultLogFlushMs);const e=await(0,F.allRecentLogEntries)();return(0,R.compact)(e.map(ee))}function ee(e){return(0,V.map)(ie(e.l),(t=>({timestamp:e.ts/B.secondMs,level:t,category:e.from??(0,g.processName)(),message:(0,v.stripAnsiEsc)(e.ctx+": "+e.msg),data:"object"==typeof e.meta?e.meta:{value:(0,v.isString)(e.meta)?(0,v.stripAnsiEsc)(e.meta):e.meta}})))}t.EventFilter=J,t.extractMessage=K,t.sentryExceptionsToS=Y,t.sentryExceptionToS=X,t.annotateEvent=Z,t.mkBreadcrumbs=Q,t.logEntryToBreadcrumb=ee;const te=new Map([[I.LogLevels.fatal,"fatal"],[I.LogLevels.error,"error"],[I.LogLevels.warn,"warning"],[I.LogLevels.info,"info"],[I.LogLevels.debug,"debug"]]);function ie(e){return te.get(e)}t.logLevelToSeverity=ie},37158:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},f=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},m=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Service=t.setupEventHandlers=void 0;const p=m(i(29907)),g=m(i(1708)),y=i(57206),v=i(19851),w=i(50213),b=i(59880),S=i(23560),P=i(19913),_=i(71567),T=i(37805),M=i(38836),E=i(99331),k=i(45608),D=i(56038),x=i(55534),C=i(42499),F=i(49776),A=i(96706),I=i(98314),O=i(38835),L=i(70025),R=i(8769),N=i(57159),B=i(34102),j=i(33456),z=i(87408),V=i(85021),W=i(17181),U=i(86941),q=i(28874),H=i(41692),$=i(2858),G=i(69385),J=i(22573),K=i(42659),Y=i(41400),X=i(56409),Z=i(55835),Q=i(41583),ee=i(54993),te=i(95629);t.setupEventHandlers=(0,v.lazy)((()=>{(0,B.ee)().on("resume",(()=>(0,G.resume)())),(0,B.ee)().on("pause",(()=>(0,G.pause)()))}));class ie extends M.EndableWrapper{constructor(e){super(e),r.add(this),s.set(this,void 0),n.set(this,new X.Latch),a.set(this,new Map),this.setup_=(0,v.lazy)((()=>(0,D.time)("Service.setup",(()=>f(this,r,"m",o).call(this))))),u.set(this,(0,v.lazy)((()=>{const e=g.default.stdin.pipe(new j.LineReader);return e.on("data",(e=>f(this,r,"m",d).call(this,(0,ee.toS)(e)))),e}))),(0,S.isBillingService)()||(0,H.setSettingsDefaults)(),h(this,s,(0,w.mkLogger)("Service("+this.name+")"),"f"),f(this,r,"m",c).call(this),this.setup_()}get name(){return super.name}get ready(){return f(this,n,"f").promise}get isReady(){return f(this,n,"f").isResolved()}setInputHandler(e,t){f(this,a,"f").set(e.trim().toLowerCase(),t)}}t.Service=ie,s=new WeakMap,n=new WeakMap,a=new WeakMap,u=new WeakMap,r=new WeakSet,o=async function(){try{(0,J.mapNotBlank)((0,A.getEnv)("PS_FATAL_"+this.name),(e=>{throw new N.WrappedError(e,{fatal:!0})})),(0,J.mapNotBlank)((0,A.getEnv)("PS_CRASH_"+this.name),(e=>{(0,Y.later)((()=>{throw new N.WrappedError(e)}),5*K.secondMs)})),(0,P.setServiceName)(this.name),(0,b.setProcessTitle)(),(0,S.isMainService)()&&await(0,U.mergeUserDataDirs_)(),await(0,$.readSettings)(),await f(this,r,"m",l).call(this),(0,W.setupLogger)(),(0,y.addDefaultJsonRevivers)(),(0,F.cacheDir)(),(0,t.setupEventHandlers)(),f(this,u,"f").call(this),await(0,C.setupLuxon)(),q.Settings.startPaused.valueOrDefault&&(0,G.pause)(),(0,E.ending)()?f(this,n,"f").reject():f(this,n,"f").resolve()}catch(e){console.error((0,I.errorToS)(e)),f(this,n,"f").reject((0,Q.toErr)(e)),(0,k.exit)({reason:(0,L.addErrorFlags)(this.name+" setup failed: "+(0,I.errorToS)(e),O.FatalErrorFlag),status:14})}},l=async function(){(0,S.isPermaService)()||(0,B.ee)().on("fatal",(e=>(0,k.exit)({error:e,status:12}))),g.default.on("unhandledRejection",(e=>(0,Z.map)(e,(e=>(0,R.onError)("unhandledRejection",e))))),g.default.on("uncaughtException",(e=>(0,Z.map)(e,(e=>(0,R.onError)("uncaughtException",e))))),g.default.on("SIGINT",(()=>(0,k.exit)({reason:"SIGINT",status:0}))),g.default.on("SIGHUP",(()=>(0,k.exit)({reason:"SIGHUP",status:0}))),g.default.on("SIGTERM",(()=>(0,k.exit)({reason:"SIGTERM",status:0}))),p.default.isWorker&&g.default.on("disconnect",(()=>(0,k.exit)({reason:"disconnect",status:0}))),await(0,te.installSentry)(this)},c=function(){this.setInputHandler("--version",(()=>(0,_.stdoutWrite)({version:T.version}))),this.setInputHandler(x.ServiceExitCommand,(()=>(0,Y.later)((()=>(0,k.exit)({reason:x.ServiceExitCommand+" from stdin",status:0}))))),this.setInputHandler("--times",(()=>(0,_.stdoutWrite)(D.PromiseTimer.instance().report()))),this.setInputHandler(V.HealthCheckCommand,(async()=>(0,_.stdoutWrite)(await(0,z.getStatusSummary)({refresh:!0}))))},d=async function(e){if(f(this,s,"f").debug("onLine()",{line:e,ending:this.ended||(0,E.ending)()}),await this.setup_(),e.startsWith("--")){const t=e.split(/\s+/,1)[0],i=f(this,a,"f").get(t);null==i?(f(this,s,"f").error("onLine(): unknown command",{line:e,knownCommands:[...f(this,a,"f").keys()]}),console.warn("unknown command "+e)):await i(e.slice(t.length).trim())}else f(this,s,"f").error("onLine(): failed to process",{line:e})}},53791:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shutdown=void 0;const r=i(19851),s=i(50213),n=i(71567),a=i(99331),o=i(45608),l=i(65812);let u="unspecified";t.shutdown=function(e){return(0,s.mkLogger)("Shutdown").warn("shutdown()",{reason:e}),u=e,c()};const c=(0,r.lazy)((async()=>{n.StdoutWrite.shutdown(),(0,l.setUnrefTimeout)((()=>(0,a.ending)()?void 0:(0,o.exit)({reason:u,status:0})),3e3)}))},57064:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t._suggestedLibraryDirs=t.suggestedLibraryDirs=t.SuggestedLibraryDir=void 0;const s=r(i(76760)),n=r(i(1708)),a=i(72993),o=i(19851),l=i(50213),u=i(7282),c=i(45255),d=i(81168),h=i(56519),f=i(32551),m=i(48195),p=i(55939),g=i(44198),y=i(64660),v=i(83278),w=i(92423),b=i(29882),S=i(65238),P=i(16287),_=i(45969),T=i(28874),M=i(7014),E=i(40958),k=i(76790),D=i(22573),x=i(31586),C=i(12168),F=(0,o.lazy)((()=>(0,l.mkLogger)("library.SuggestedLibraryDir")));class A{static async for(e,t){if((0,D.blank)(e))return;const i=await(0,M.bestVolumeForPath)(e,t);if(null==i)return void F().warn("Skipping library directory suggestion: failed to find mountpoint volume",{nativePath:e});const r=await(0,m.isLibraryDir)(e);return new A(e,r,i)}constructor(e,t,i){this.nativePath=e,this.isLibrary=t,this.vol=i,this.isCurrentLibrary=T.Settings.libraryDir.value===this.nativePath}async whyExcluded(e=T.Settings.minDiskFreeGb.valueOrDefault*C.GB){if(this.isLibrary)return;const t=await(0,P.statMaybe)(this.nativePath,"trace"),i={msg:"whyExcluded()",meta:{nativePath:this.nativePath,stat:t,availableBytes:this.availableBytes,minAvailableBytes:e}};if((0,b.containsHiddenPathname)(this.nativePath))return F().tap({...i,result:"contains hidden path"});{const e=await(0,w.whyExcludedDirectoryRecursive)(v.BaseFile.for(this.nativePath));if(null!=e)return F().tap({...i,result:e})}return null==t||t.isDirectory()?await(0,y.canRWXFirstExistingAncestor)(this.nativePath)?(0,x.gt0)(e)&&this.availableBytesnew A(e,!1,{mountpoint:"/test",available:C.GB})))});const l=[],d=[],y=await i??await(0,M.volumes)();if(null==y||(0,E.isEmpty)(y))return F().warn("volumes() is empty: they don't get any suggestions."),[];async function v(t){const i=await A.for(t,y);if(null!=i)return i.isLibrary||i.isCurrentLibrary?(F().info("addSuggestion(): path is a library",i),void l.push(i)):void(null==await i.whyExcluded(e)&&d.push(i))}if(await v(T.Settings.libraryDir.value),(0,_.isDocker)())return[...l,...d];await v(await(0,p.picturesDir)());const w=[n.default.cwd(),...await(0,S.childDirectories_)(n.default.cwd())];(0,_.isDocker)()||w.push(...await(0,S.childDirectories_)((0,f.homeDir)())),(0,E.filterInPlace)(w,(e=>(0,b.isNotHiddenPosixPath)(e)));for(const e of w)await(0,m.isLibraryDir)(e)&&(F().info("current working dir is a library",e),await v(e));function P(){return Date.now()-r>c.ShortCommandTimeoutMs-500&&(F().debug("...ran out of time, stopping."),!0)}(0,_.isDocker)()||await v(s.default.join((0,f.homeDir)(),(0,a.AppName)())),await(0,h.mapAsync)({name:"suggestedLibraryDirs.addVolume",arr:y,f:e=>async function(e){try{if(await(0,m.isLibraryDir)(e.mountpoint))return F().info("addVolume(): vol.mountpoint is a library",e.mountpoint),void await v(e.mountpoint);for(const t of await(0,S.childDirectories_)(e.mountpoint)){if(P())break;if(await(0,m.isLibraryDir)(t))F().info("addVolume(): dir is a library",t),await v(e.mountpoint);else for(const i of await(0,S.childDirectories_)(t)){if(P())break;await(0,m.isLibraryDir)(i)&&(F().info("addVolume(): dir is a library",t),await v(e.mountpoint))}}const t=s.default.join(e.mountpoint,(0,a.AppName)());F().info("addVolume(): adding default suggestion",t),await v(t)}catch(t){F().warn("addVolume(): Failed to add suggestion",{err:t,vol:e})}}(e),timeoutMs:c.ShortCommandTimeoutMs}),F().debug("Finished gathering suggestions. Filtering...",{priorLibraries:l,suggestions:d});const D=l;for(const e of(0,k.sortBy)(d,(e=>[-e.availableBytes,-e.nativePath.length]))){if(D.length>=t)break;D.some((t=>t.nativePath===e.nativePath||t.mountpoint===e.mountpoint))||(F().debug("adding new path",e),D.push(e))}return(0,E.uniqBy)((0,k.sortBy)(D,(e=>[!e.isCurrentLibrary,!e.isLibrary,-e.free,e.nativePath])),(e=>e.nativePath))}t.SuggestedLibraryDir=A,t.suggestedLibraryDirs=(0,o.lazy)((()=>I())),t._suggestedLibraryDirs=I},77948:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.systemInformation=t.libraryMetrics=void 0;const r=i(21330),s=i(46296),n=i(17344),a=i(18454),o=i(81674),l=i(66184),u=i(96175),c=i(24540),d=i(23560),h=i(28874),f=i(2858),m=i(84968),p=i(94174),g=i(37805),y=i(14854),v=i(15674),w=i(40958),b=i(22573),S=i(38639),P=i(75240),_=i(55835),T=i(31586),M=i(20214),E=i(51926),k=i(12168),D=i(43487),x=i(54017),C=i(48723);async function F(){if(null==D.Asset.db())return;const e=[];e.push((0,k.plurMetric)(D.Asset.shownCount(),"asset"));const t=x.AssetFile.assetFileCountByMimeTypeRoots();for(const i of t){const t=(0,E.stripSuffix)(i.mimeTypeRoot,"/");e.push((0,k.plurMetric)(i.assetFileCount,t+" file"))}return e.push((0,k.plurMetric)(C.Tag.rows(),"tag")),e}t.libraryMetrics=F;const A={pending:"pending",ok:"ok","no-library":"warn",warn:"warn","stop-sync":"warn",error:"fail",disabled:"ok"};t.systemInformation=async function(){const e=await(0,o.b)(),t=e?.l?.tier??"lite",i=a.HealthCheck.summary();return(0,w.compact)([{term:"Version",defn:g.version},{term:"Edition",defn:(0,n.EditionName)()},{term:"Health checks",defnClass:A[i.level],defnTitle:"Click to see all health checks",termURL:"/health",defn:i.msg[0]},{term:"Subscription",defnClass:t,defn:t,termURL:"/plans/billing?then=/about",defnTitle:"Click to manage your PhotoStructure subscription"},...(0,S.isTrue)(e?.ok)?[{term:"Licensed to",defn:e?.l?.sub},{term:"Expires or renews",defn:(0,_.mapOr)(e?.l?.exp,(e=>(0,r.toIsoDate)(e)),"--"),termURL:"/plans/billing?then=/about",defnTitle:"Click to manage your PhotoStructure subscription"}]:[],{term:"OS",defn:(0,u.osFullName)()},{term:"CPUs",defn:(0,u.CPUs)()},{term:"System load",defn:(0,_.map)(y.CpuUsage.instance().busyPct(),(e=>(0,T.fmtPct)(e)+" busy"))??"(unavailable)"},{term:"Concurrency",defn:`Target system use: ${Math.round(h.Settings.cpuBusyPercent.valueOrDefault)}% (${(0,v.maxConcurrentImports)()} concurrent imports, ${(0,v.sharpThreadsPerProcess)()} gfx/process)`},(0,d.isWebService)()?{term:"Web uptime",defn:(0,P.fmtDuration)((0,m.runtimeMs)())}:void 0,(0,b.mapNotBlank)((0,c.procDeviceModel)(),(e=>({term:"Device",defn:e}))),{term:"Current user",defn:await(0,p.username)()+((0,T.gte0)((0,p.userid)())?"":" (userid: "+(0,p.userid)()+", groupid: "+(0,p.groupid)()+")")},(0,f.libraryHasSettings)()?{term:"Library path",defn:h.Settings.libraryDir.valueOrDefault,defnClass:"library"}:void 0,await(0,M.thenMap)(F(),(e=>({term:"Library metrics",termURL:"https://photostructure.com/faq/metrics/",defn:e}))),{term:"Log directory",defn:(0,s.logDir)()},{term:"Log level",termURL:"https://photostructure.com/faq/error-reports/#log-levels",defn:(0,l.defaultLogLevel)()}]).filter((({term:e,defn:t})=>(0,b.notBlank)(e)&&(0,b.notBlank)(t)))}},35580:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d,h,f,m,p,g,y,v=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TaskList=t.TaskListRunLaterMs=void 0;const w=i(19851),b=i(7282),S=i(23560),P=i(88264),_=i(73568),T=i(78406),M=i(25764),E=i(99331),k=i(56038),D=i(42638),x=i(34102),C=i(70417),F=i(28874),A=i(14854),I=i(73328),O=i(69385),L=i(15674),R=i(40958),N=i(42659),B=i(45599),j=i(26905),z=i(56409),V=i(31586),W=i(94710);t.TaskListRunLaterMs=8;class U extends T.EndableInterval{constructor(){const e="TaskList()";super({name:e,callback:()=>this.maybeRunChunk(),intervalMs:7*N.secondMs,onEnd:()=>v(this,r,"m",a).call(this),rank:M.EndableRanks.first,endTimeoutMs:F.Settings.taskTimeoutMs.valueOrDefault}),r.add(this),this.recentlyProcessed=new P.TTLArray(N.minuteMs),s.set(this,[]),this.taskCount=(0,w.lazy)((()=>W.Task.count())),d.set(this,(0,w.lazy)((()=>{this.logger.debug("status",this.state())}),((0,b.isTest)()?1:30)*N.secondMs)),f.set(this,(()=>this.maybeRunChunk())),m.set(this,(0,w.lazy)((()=>this.logger.info("runChunk(): no-op",{isPaused:(0,O.isPaused)(),isFull:this.p.isFull(),isTooBusy:(0,A.isTooBusy)(),whyDoNotRun:(0,I.whyDoNotRun)(this),pendingWorkCount:this.pendingWorkCount(),queueItemCount:this.taskCount(),freeSlots:this.p.freeSlots()})),((0,b.isTest)()?1:30)*N.secondMs)),this.maybeRunChunk=(0,w.lazy)((()=>{setTimeout((()=>{this.ended||(0,E.ending)()||(v(this,r,"m",g).call(this),this.maybeRunChunk.unset())}),t.TaskListRunLaterMs)})),p.set(this,(0,w.lazy)((()=>{const e=F.Settings.minBusyPct.valueOrDefault,t=F.Settings.stuckCheckIntervalMs.valueOrDefault;if(e<=0||this.p.isIdle()||t<=0)return;const i=A.CpuUsage.instance().busyPct();if(this.logger.debug("maybeCheckForStuckTasks()",{cpuBusyPct:i,minBusyPct:e,stuckCheckIntervalMs:t}),!(0,V.gte)(i,e))for(const e of this.p.running)if(e.elapsedMs>t){const t=e.payload;this.logger.error("Stuck serial task. Aborting.",{task:t,elapsedMs:e.elapsedMs});const i="stuck after "+e.elapsedMs+"ms";t.abort(i),e.reject(new _.AbortError(i))}}),F.Settings.stuckCheckIntervalMs.valueOrDefault)),this.p=new D.Promises(e,L.maxConcurrentImports),this.p.ee.on("vacancy",this.maybeRunChunk),this.p.ee.on("drain",(()=>v(this,r,"m",l).call(this))),(0,x.ee)().on("resume",v(this,f,"f")),W.Task.ee.on("added",this.maybeRunChunk)}async awaitDrain(e=[],t=0){(0,R.isEmpty)(e)&&(e=W.TaskNames.values);const i=new z.Latch;return v(this,s,"f").push({l:i,taskNames:e,maxRemaining:t,who:(0,j.shortStack)()}),this.maybeRunChunk(),i}isRunnable(){return!this.p.isFull()}currentWorkCount(){return this.p.unsettledCount()}pendingWorkCount(){return this.taskCount()-this.currentWorkCount()}hasCapacity(e=F.Settings.taskListCap.valueOrDefault){return e<=0||this.taskCount()e.payload))}currentTasksByFn(e){return this.currentTasks().filter((t=>t.fn===e))}state(){return{...this.p.stats(),isDone:v(this,r,"m",l).call(this),freeSlots:this.p.freeSlots(),pendingWork:this.taskCount(),next10:v(this,r,"m",h).call(this,10).map((e=>e.toString())),recentlyProcessedLast10:this.recentlyProcessed.slice(-10).map((e=>e.toString())),isRunnable:this.isRunnable()}}doNotStartMoreWork(){return(0,E.ending)()||this.ended||(0,O.isPaused)()||this.p.isFull()||(0,A.isTooBusy)()||(0,I.doNotRun)(this)||0===this.pendingWorkCount()}}t.TaskList=U,s=new WeakMap,d=new WeakMap,f=new WeakMap,m=new WeakMap,p=new WeakMap,r=new WeakSet,n=function(){this.taskCount.unset()},a=async function(){(0,x.ee)().off("resume",v(this,f,"f"));const e=new _.AbortError((0,E.ending)()?"service ending":"TaskList ended");for(const t of v(this,s,"f"))t.l.reject(e);await this.p.awaitAll()},o=function(){(0,R.filterInPlace)(v(this,s,"f"),(e=>e.l.isPending())),W.Task.dbl.runf((e=>e.delete().where("retries","<",0))),v(this,r,"m",n).call(this)},l=function(){if(this.ended)return;if(v(this,r,"m",o).call(this),(0,R.isEmpty)(v(this,s,"f")))return;const e=W.Task.countTaskNames();for(const t of this.p.deferreds){const i=t.name;e[i]=(e[i]??0)+1}for(const t of v(this,s,"f"))(0,C.sum)(t.taskNames.map((t=>e[t]??0)))<=t.maxRemaining&&t.l.resolve()},u=function(){return(0,R.uniq)(this.currentTasks().filter((e=>e.isSerial)).map((e=>e.fn)))},c=function(){return this.currentTasks().map((e=>e.id))},h=function(e){return 0===e?[]:W.Task.ops().allf((t=>(t=W.Task.orderBy(t.distinct().whereNotIn("id",v(this,r,"m",c).call(this)).whereNotIn("fn",v(this,r,"m",u).call(this))),(0,V.gt0)(e)&&(t=t.limit(e)),t)))},g=function(){if(v(this,r,"m",n).call(this),v(this,p,"f").call(this),this.doNotStartMoreWork())v(this,m,"f").call(this);else{v(this,d,"f").call(this);const e=this.p.freeSlots(),t=v(this,r,"m",h).call(this,e);this.logger.debug("runChunk():",{freeSlots:e,next:t});for(const e of t)this.p.enqueue({name:this.name,payload:e,l:()=>v(this,r,"m",y).call(this,e),serialId:e.isSerial?e.fn:void 0})}v(this,r,"m",l).call(this)},y=async function(e){try{await(0,k.time)("task."+e.fn,e._run())}catch(t){this.logger.warn("Failed to run task",{task:e,error:t})}finally{this.maybeRunChunk()}},U.instance=(0,B.defer)((()=>(0,S.isTaskListManager)()?new U:void 0))},98392:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExposeArg=void 0;const r=i(28874),s=i(38639);t.ExposeArg={beforeParse:e=>e.option("--expose","The web service is only accessible to the computer running PhotoStructure by default. Providing this option will expose your library to all computers on your network. See https://photostructure.com/faq/remote-access/ ."),afterParse:e=>{(0,s.isTrue)(e.expose)&&(r.Settings.exposeNetworkWithoutAuth.envValue=!0)}}},31503:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LogArgs=void 0;const r=i(23560),s=i(83210),n=i(28874),a=i(38639);function o(){return(0,r.isMainService)()||(0,r.isSyncService)()}t.LogArgs={beforeParse:e=>{const t=(o()?', "PS_TAIL_LOGS=true"':"")+' and "PS_LOG_STDOUT=true".';return o()?e.option("-v, --verbose",'Verbose logging from all processes. Shortcut for "--info --tail". Caution: noisy during imports!'):e.option("-v, --verbose","Verbose logging. Equivalent to --info."),e.option("--error",`Emit "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=error"${t}`),e.option("--warn",`Emit "warn" and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=warn"${t}`),e.option("--info",`Emit "info", "warn", and "error" messages from this process to stdout. Sets "PS_LOG_LEVEL=info"${t}`),e.option("--debug",`Emit "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY NOISY. Sets "PS_LOG_LEVEL=debug"${t}}`),e.option("--trace",`Emit "trace", "debug", "info", "warn", and "error" messages from this process to stdout. CAUTION: VERY VERY NOISY. Sets "PS_LOG_LEVEL=trace"${t}}`),o()&&e.option("--tail",'Emit log messages from both this process and all other concurrently running PhotoStructure processes on this host to stdout. This can be really helpful in seeing how PhotoStructure\'s processes are coordinating work. Caution: very noisy especially during imports. Sets "PS_TAIL_LOGS=true".'),e},afterParse:e=>{const t=(0,a.isTrue)(e.error),i=(0,a.isTrue)(e.warn),r=(0,a.isTrue)(e.info)||(0,a.isTrue)(e.verbose)||(0,a.isTrue)(e.v),l=(0,a.isTrue)(e.debug),u=(0,a.isTrue)(e.trace);u?n.Settings.logLevel.envValue="trace":l?n.Settings.logLevel.envValue="debug":r?n.Settings.logLevel.envValue="info":i?n.Settings.logLevel.envValue="warn":t&&(n.Settings.logLevel.envValue="error"),(0,s.isDaemon)(e)?(n.Settings.tailLogs.envValue=!1,n.Settings.logStdout.envValue=!1):((0,a.isTrue)(e.tail)&&(n.Settings.tailLogs.envValue=!0),(t||i||r||l||u)&&(n.Settings.logStdout.tmpValue=!0,o()&&(n.Settings.tailLogs.tmpValue=!0)),(n.Settings.tailLogs.valueOrDefault||n.Settings.logStdout.valueOrDefault)&&n.Settings.logLevel.isUnset()&&(n.Settings.logLevel.envValue="info"))}}},46628:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.albumsFromTags=t.tagFilesWithAlbums=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(81168),o=i(74417),l=i(28874),u=i(47783),c=i(97573),d=i(42231),h=i(40958),f=i(22573),m=i(68708),p=i(75020),g=i(54993),y=(0,s.lazy)((()=>(0,n.mkLogger)("curators.AlbumTagger")));function v(e){return(0,f.blank)(e)?void 0:l.Settings.tagAlbumTitleHierarchies.valueOrDefault?(0,c.keywordToPath)(e):[e]}function w(e){if(null==e)return[];const t=(0,h.uniq)((0,r.flatMap)(l.Settings.tagAlbumTitle.values,(t=>(0,m.pluckDeep)(e,t)?.value))),i=(0,h.compact)(t.map(v));if((0,h.isEmpty)(i))return[];if(i.length>1)return y().tap({level:"info",msg:"albumFromFile()",result:i.map((e=>[p.TagRoots.Albums,...e]))});const s=i[0],n=(0,r.first)(l.Settings.tagAlbumDescription.values,(t=>(0,m.pluckDeep)(e,t)?.value)),u=(0,h.isEmpty)(s)?"(blank title)":(0,a.firstSubstringIgnoreCase)(l.Settings.tagAlbumsExcluded.values,[...s,(0,g.toS)(n)].join(" ")),c=null==u?[p.TagRoots.Albums,...s]:void 0;if(null!=c){const t={name:c[c.length-1],description:n};for(const i of l.Settings.tagAlbumDate.values){const r=(0,o.parseJsonDateToMillis)((0,m.pluckDeep)(e,i)?.value);if(null!=r){t.releasedAt=r;break}}c[c.length-1]=t}return y().tap({level:"info",msg:"albumFromFile()",result:(0,h.compact)([c]),meta:{titles:i,desc:n,whyExclude:u}})}t.tagFilesWithAlbums=async function(e){const t=[];for(const i of e){t.push(...w(await(0,u.readTags)(i)));for(const e of l.Settings.tagAlbumFilenames.values)t.push(...w(await(0,u.readRawTags)(i.sibling(e),!1)))}return y().tap({msg:"tagFilesWithAlbums()",result:(0,d.uniqTagPaths)(t),meta:{files:e}})},t.albumsFromTags=w},88224:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagAsset=t.tagAndUpsertAsset_=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(28874),o=i(42231),l=i(40958),u=i(20214),c=i(43487),d=i(46628),h=i(63175),f=i(4407),m=i(58886),p=i(32646),g=i(48144),y=i(60047),v=i(6186),w=i(42003),b=i(43723),S=(0,r.lazy)((()=>(0,s.mkLogger)("curators.AssetTagger")));async function P({primaryVariation:e,files:t,priorTagPaths:i,capturedAts:r,uris:s}){const u=[];if(t=(0,l.uniqBy)([e,...t],(e=>e.nativePath)),a.Settings.tagCamera.valueOrDefault&&await(0,n.thenMap)((0,h.cameraTagFile)(e),(t=>{S().debug("Camera tag for "+e+":",t),u.push(t)})),a.Settings.tagLens.valueOrDefault&&await(0,n.thenMap)((0,y.lensTagFile)(e),(t=>{S().debug("Lens tag for "+e+":",t),u.push(t)})),a.Settings.tagGeo.valueOrDefault)for(const e of t){const t=await(0,p.geoTagFile)(e);if(null!=t){u.push(t);break}}await(0,n.thenMap)((0,f.dateTagFile)(e,r),(t=>{S().debug("Date tag for "+e+":",t),u.push(t)}));const c=await(0,b.whoTagFiles)(t)??[];S().debug("whoTagFiles for "+e+":",c),u.push(...c),await(0,n.thenMap)((0,g.keywordTagFiles)(t,c),(t=>{S().debug("Keyword tags for "+e+":",t),u.push(...t)})),a.Settings.tagFileType.valueOrDefault&&await(0,n.thenMap)((0,w.typeTagFiles)(t),(t=>{S().debug("MIME type tags for "+e+":",t),u.push(...t)})),await(0,n.thenMap)((0,m.tagAssetPaths)(s),(e=>{S().debug("file paths for uris",{uris:s,arr:e}),u.push(...e)})),await(0,n.thenMap)((0,d.tagFilesWithAlbums)(t),(t=>{S().debug("Album tags for "+e+":",t),u.push(...t)}));const P=(0,o.omitAncestorTags)((0,l.uniqBy)(u.map(v.normalizeTagRoot),o.joinTagPath)),_=await(0,v.tagDeltas)(i,P);return S().info("tagAsset("+e+")",{priorTagPaths:i,after:P,result:_}),_}t.tagAndUpsertAsset_=async function(e){const t=await e.getExistingAssetFiles();S().info("tagAndUpsertAsset()",{asset:e,existing_uris:t.map((e=>e.uri))});const i=t.find((e=>e.shown)),r=await(i?.posixFile_());if(null==i||null==r)return void S().throw("tagAndUpsertAsset(): no existing or primary asset file",{asset:e,existingPrimaryAssetFile:i,primaryVariant:r,doNotSend:!0,fatal:!1});const s=e.getShown();s?.id!==i.id&&(S().warn("Changing primary asset we're using a different variant for tagging.",{newPrimary:i.uri,priorPrimary:s?.uri}),e.setShown_(i));const n=await(0,u.thenCollect)(t,(e=>e.posixFile_())),l=e.getAssetFiles().map((e=>e.uri)),d=e.getTagPaths(),h=await e.getCapturedAts(),f=await P({primaryVariation:r,files:n,priorTagPaths:d,capturedAts:h,uris:l});S().info("tagAndUpsertAsset",f);const m=f.add.find((e=>(0,o.leafIsExcluded)(e,a.Settings.keywordBlocklist.values)));if(null!=m){if(!0!==e.shown)return S().info("this asset has an excluded tag, and it wasn't shown yet, so we're removing it.",{excludedTag:m}),await c.Asset.remove({assetId:e.id,blocklistShas:!1,unlinkAssetFiles:!1}),S().throw("tagAndUpsertAsset(): asset had excluded tag. Removed.",{excludedTag:m,uris:l,files:n.map((e=>e.nativePath))});S().info("this asset has an excluded tag, marking excluded",{excludedTag:m}),e.excludedAt=Date.now()}return e.applyTagPathDeltas(f),await e.updateFromFiles(),f},t.tagAsset=P},63175:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cameraTagFile=t.cameraTag=void 0;const r=i(47783),s=i(75020),n=i(40958),a=i(22573);function o(e){return null==e||(0,a.blank)(e.Make)?void 0:(0,n.compactBlankish)([s.TagRoots.Camera,e.Make,e.Model])}t.cameraTag=o,t.cameraTagFile=async function(e){return o(await(0,r.readTags)(e))}},4407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dateTagFile=t.dateTag=t.dayTagRef=t.monthTagRef=t.yearTagRef=t.dayToOrdinal=t.ordinalToMonth=t.monthToOrdinal=t.yearToOrdinal=void 0;const r=i(19851),s=i(19043),n=i(97352),a=i(81168),o=i(928),l=i(34102),u=i(28874),c=i(28544),d=i(47783),h=i(40958),f=i(55835),m=i(31586),p=i(75020),g=i(54993),y=(0,r.lazy)((()=>new Intl.DateTimeFormat((0,s.localeSync)(),{month:"short"}))),v=(0,r.lazy)((()=>{const e=y();return(0,h.range)(0,12,(t=>e.format(new Date(2016,t,1)))).map((e=>(0,a.stripSuffix)(e,".")))}));function w(e){return 1e4-e}function b(e){return 13-e}function S(e){return 33-e}function P(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:w(e)})))}function _(e){if((0,m.within)(1,12,e))return(0,f.map)(v()[e-1],(t=>({name:String(e),displayName:t,ordinal:b(e)})))}function T(e){return(0,n.mapGt0)(e,(e=>({name:(0,g.toS)(e),ordinal:S(e)})))}function M(e){const t=(0,g.toS)(u.Settings.tagYMD.valueOrDefault).toLowerCase();if(null==e||""===t||"off"===t||t.startsWith("disable"))return;const i=[p.TagRoots.When];if(t.startsWith("y")){const t=(0,f.map)((0,o.getYear)(e),P);if(null==t)return;i.push(t)}if(t.startsWith("ym")){const t=(0,f.map)((0,o.getMonth)(e),_);if(null==t)return i;i.push(t)}if(t.startsWith("ymd")){const t=(0,f.map)((0,o.getDay)(e),T);if(null==t)return i;i.push(t)}return i}(0,l.ee)().on("clearCache",(()=>{y.unset(),v.unset()})),t.yearToOrdinal=w,t.monthToOrdinal=b,t.ordinalToMonth=function(e){return 13-e},t.dayToOrdinal=S,t.yearTagRef=P,t.monthTagRef=_,t.dayTagRef=T,t.dateTag=M,t.dateTagFile=async function(e,t){if(""===u.Settings.tagYMD.valueOrDefault)return;const i=[...t];(0,h.isEmpty)(t)&&i.push((await(0,d.readTags)(e))?.capturedAt);const r=(0,c.bestCapturedAt)(i);return null==r||(0,c.capturedAtSrcFromStat)(r.src)&&!u.Settings.tagDateFromStat.valueOrDefault?void 0:M(r.date)}},58886:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addFileUriTagsToAsset=t.addFilesTagsToAsset=t.isFsTag=t.tagAssetPaths=void 0;const r=i(19851),s=i(50213),n=i(42231),a=i(21404),o=i(40958),l=i(89937),u=i(75020),c=i(54017),d=i(94448),h=i(69032),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.FilePathTagger")));function m(e,t){return e.applyTagPathDeltas({add:(0,o.compact)(t.map((e=>(0,a.uriToTagPath)({uri:e,isFile:!0}))))})}t.tagAssetPaths=async function(e){const t=[];for(const i of e)try{const e=(0,a.uriToTagPath)({uri:i,isFile:!0});if(null==e)continue;if(i.startsWith(l.PS_LOCAL_FILE_SCHEME)&&null!=(0,d.modelDb)()){const t=(0,n.tagRefToS)(e[1]);e[1]={name:t,displayName:await(0,h.displayNameForVolsha)(t)},f().info("tagAssetPaths()",{uri:i,tp:e})}t.push(e)}catch(e){f().warn("Failed to parse asset file URI",{uri:i})}return t},t.isFsTag=function(e){return(0,n.tagRefToS)(e[0]).toLowerCase()===u.TagRoots.fs},t.addFilesTagsToAsset=function(e){const t=c.AssetFile.dbl.pluckAllf((t=>t.select("uri").where({asset:e})));return m(e,t)},t.addFileUriTagsToAsset=m},32646:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.geoTagFile=t.geoTag=void 0;const r=i(48884),s=i(56519),n=i(28874),a=i(47783),o=i(75020),l=i(40958);function u(e){const t=(0,r.compactRight)(n.Settings.tagGeoTemplate.valueOrDefault.map((t=>e?.[t])));return 0===t.length||t.some((e=>null==e))?void 0:(0,l.compact)([o.TagRoots.Where,...t])}t.geoTag=u,t.geoTagFile=function(e){return(0,s.thenMap)((0,a.readTags)(e),u)}},48144:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.keywordTagFiles=t.processKeywords=t.dedupeKeywordPaths=t.normalizeKeywordPaths=t.extractPathnameTags=t.extractDashDashTags=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(68852),o=i(81168),l=i(96859),u=i(56519),c=i(28874),d=i(47783),h=i(97573),f=i(42231),m=i(40958),p=i(76790),g=i(22573),y=i(41400),v=i(96249),w=i(55835),b=i(75020),S=i(54993),P=i(6186),_=i(43723),T=(0,s.lazy)((()=>(0,n.mkLogger)("curators.KeywordTagger"))),M=(0,s.lazy)((()=>(0,g.mapNotBlank)(c.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[ /${(0,a.escapeRegExp)(e)}]`)))));function E(e){return T().tap({msg:"extractDashDashTags()",result:(0,w.mapOr)((0,S.toS)(e).split("--")[1],(e=>(0,m.compactBlanks)((0,w.mapOr)(M(),(t=>e.split(t)),[e]))),(()=>[])),meta:{s:e}})}function k(e){return[...E(e.parent().posixPath),...E(e.name)]}(0,y.later)((()=>{c.Settings.keywordDelimiters.watchLater((()=>M.unset()))})),t.extractDashDashTags=E,t.extractPathnameTags=k;const D=/\w{2,7}:\/\/\S+/g;function x(e){const t=[],i=[],s=[];for(const t of(0,m.compact)(e))if(Array.isArray(t))s.push(t);else{const e=(0,S.toS)(t).replace(D,(e=>(i.push(e),"")));s.push(...(0,w.mapOr)((0,h.delimRe)(),(t=>e.split(t)),[e]))}const n=s.map((e=>(0,o.isString)(e)?(0,h.keywordToPath)(e):e)).map((e=>Array.isArray(e)&&1===e.length?e[0]:e)),[a,l]=(0,r.partition)(n,Array.isArray),u=a.map((e=>(0,m.compactBlanks)(e.map((e=>e.trim()))))).filter(m.isNotEmpty),d=(0,o.uniqIgnoreCase)((0,v.flatten)(u));t.push(...u);const f=[...l,...i].map((e=>e.trim())).filter((e=>(0,g.notBlank)(e)&&!(0,o.includesIgnoreCase)(d,e))),p="copy"===c.Settings.keywordReparenting.valueOrDefault,y="retain"===c.Settings.keywordReparenting.valueOrDefault,P=c.Settings.rootTagKeywordsAliases.values;for(const e of[...t])(0,o.includesIgnoreCase)(P,e[0])&&(e[0]=b.TagRoots.Keywords),e[0]!==b.TagRoots.Keywords&&(p?t.push([b.TagRoots.Keywords,...e]):y&&e.unshift(b.TagRoots.Keywords));for(const e of f)t.push([b.TagRoots.Keywords,e]);return(0,m.uniq)(t)}function C(e){return(0,m.uniqBy2)((0,p.sortBy)(e.map(P.normalizeTagRoot),(e=>{const t=(0,f.joinTagPath)(e);return[t.normalize().toLowerCase(),-1*(0,l.lcdiff)(t)]})),((e,t)=>(0,o.equalsIgnoreCase)((0,f.joinTagPath)(e),(0,f.joinTagPath)(t))))}function F(e,t){const[i,s]=(0,r.partition)(x(e),_.isWhoTag),n=(0,v.flatten)(i.map(_.nameTag)),a=(0,m.uniq)((0,v.flatten)([...n,...t].map((e=>{const t=(0,P.stripTagRoot)(e);return[t.join(", "),t.join(" "),[...t].reverse().join(" ")]})))),l=C([...s.filter((e=>!(0,o.includesIgnoreCase)(a,(0,P.stripTagRoot)(e).join(" ")))),...n]);return T().tap({msg:"processKeywords()",level:"info",result:l})}t.normalizeKeywordPaths=x,t.dedupeKeywordPaths=C,t.processKeywords=F,t.keywordTagFiles=async function(e,t){return F([...c.Settings.tagKeywordsFromPath.valueOrDefault?(0,v.flatten)(e.map(k)):[],...c.Settings.tagKeywordsFromMetadata.valueOrDefault?(0,v.flatten)(await(0,u.mapAsyncSerial)({name:"keywordTagFiles",arr:e,f:e=>(0,u.thenMap)((0,d.readRawTags)(e),h.rawTagKeywords)})):[]],t)}},60047:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lensTagFile=t.lensTag=void 0;const r=i(56519),s=i(28874),n=i(47783),a=i(75020),o=i(40958),l=i(22573),u=i(55835);function c(e){return(0,u.map)(e,(e=>(0,l.mapNotBlank)(e.lensMake,(t=>(0,l.mapNotBlank)((0,o.compactBlanks)(s.Settings.tagFullLensModel.valueOrDefault?[e.lensModel,e.lensInfo]:[e.lensInfo,e.lensModel])[0],(e=>[a.TagRoots.Lens,t,e]))))))}t.lensTag=c,t.lensTagFile=function(e){return(0,r.thenMap)((0,n.readTags)(e),c)}},6186:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagDeltas=t.normalizeTagRoot=t.stripTagRoot=t.hasTagRoot=t.Roots=t.KwRoot=t.WhoRoot=t.AlbumsRoot=t.WhenRoot=void 0;const r=i(50213),s=i(28874),n=i(42231),a=i(75020),o=i(40958),l=i(22573),u=i(45599);t.WhenRoot={name:a.TagRoots.When,ordinal:1},t.AlbumsRoot={name:a.TagRoots.Albums,ordinal:2},t.WhoRoot={name:a.TagRoots.Who,ordinal:4},t.KwRoot={name:a.TagRoots.Keywords,ordinal:7};const c=(0,u.defer)((()=>(0,r.mkLogger)("curators.Taggers")));t.Roots=[t.WhenRoot,t.AlbumsRoot,{name:a.TagRoots.fs,ordinal:3},t.WhoRoot,{name:a.TagRoots.Camera,ordinal:5},{name:a.TagRoots.Lens,ordinal:6},t.KwRoot,{name:a.TagRoots.Type,ordinal:8}];const d=(0,o.uniq)([...a.TagRoots.values,...s.Settings.rootTagKeywordsAliases.values,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function h(e){return d.includes((0,n.tagRefToS)(e[0]).toLowerCase())}t.hasTagRoot=h,t.stripTagRoot=function(e){return h(e)?e.slice(1):e};const f=(0,o.uniq)([a.TagRoots.Albums,...s.Settings.rootTagAlbumsAliases.values].map((e=>e.toLowerCase()))),m=(0,o.uniq)([a.TagRoots.Keywords,...s.Settings.rootTagKeywordsAliases.values].map((e=>e.toLowerCase()))),p=(0,o.uniq)([a.TagRoots.Who,...s.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));t.normalizeTagRoot=function(e){const i=(0,n.tagRefToS)(e[0]).toLowerCase();return(0,l.blank)(i)?e:m.includes(i)||m.includes(i)?[t.KwRoot,...e.slice(1)]:p.includes(i)?[t.WhoRoot,...e.slice(1)]:f.includes(i)?[t.AlbumsRoot,...e.slice(1)]:e},t.tagDeltas=async function(e,t){const i=(0,n.tagDiff)(t,e),r=(0,n.tagDiff)(e,t),a=s.Settings.excludedRootTags.valueOrDefault;return(0,o.filterInPlace)(i,(e=>{const t=a.includes((0,n.tagRefToS)(e[0]).toLowerCase());return t&&!(0,n.tagPathsInclude)(e,r)&&(r.push(e),c().info("tagDeltas(): removing excluded tag",e)),!t})),{add:i,remove:r}}},42003:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fixCase=t.friendlySubtype=t.mimeTypeToTag=t.typeTagFiles=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(56519),o=i(54979),l=i(40958),u=i(22573),c=i(55835),d=i(42279),h=i(75020),f=(0,r.lazy)((()=>(0,s.mkLogger)("curators.TypeTagger")));t.typeTagFiles=async function(e){const t=(0,l.uniq)(await(0,a.mapAsyncSerial)({name:"typeTagFiles",arr:e,f:o.readMimeType}));return(0,l.compact)(t.map(p))};const m=new Map(["M2TS","JPEG","QuickTime"].map((e=>[e.toLowerCase(),e])));function p(e){const[t,i]=e.split("/");if(!(0,u.blank)(t)&&!(0,u.blank)(i))return f().tap({msg:"mimetypeToTag("+e+")",result:(0,c.map)(y(i,e),(e=>(0,l.compactBlanks)([h.TagRoots.Type,(0,n.capitalize)(t),...e])))})}t.mimeTypeToTag=p;const g=(0,r.lazy)((()=>new Map([["image/x-adobe-dng",["Raw","DNG"]],["image/x-fuji-raf",["Raw","Fujifilm"]],["video/m2ts",["MPEG-2"]],["video/mp2t",["MPEG-2"]],["video/mp4",["MPEG-4"]],["video/quicktime",["QuickTime"]],["video/x-msvideo",["AVI"]]])));function y(e,t){return(0,d.firstDefinedThunk)([()=>g().get(t.trim().toLowerCase()),()=>(0,c.map)(e.match(/^x-(\w{4,})-\w{3}/),(e=>["Raw",(0,n.capitalize)(e[1])])),()=>[v(e.replace(/^(?:x-|vnd\.|prs\.)/i,"").replace(/-/g," "))]])}function v(e){return null!=e.match(/[a-z\d]{3,4}/i)?e.toUpperCase():m.get(e.trim().toLowerCase())??(0,n.capitalize)(e)}t.friendlySubtype=y,t.fixCase=v},43723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nameTag=t.isWhoTag=t.whoTagFiles=void 0;const r=i(19851),s=i(50213),n=i(28874),a=i(47783),o=i(28630),l=i(66039),u=i(42231),c=i(40958),d=i(22573),h=i(96249),f=i(68708),m=i(75020),p=i(59455),g=(0,r.lazy)((()=>(0,s.mkLogger)("curators.WhoTagger")));t.whoTagFiles=async function(e){const t=[];if(n.Settings.tagJsonFaces.valueOrDefault){const i=[];for(const t of e)i.push(...(0,p.toA)(await t.jsonSidecars()));for(const e of i){const i=await(0,o.readJsonSidecar)(e),r=i?.peopleNames;(0,c.isNotEmpty)(r)&&t.push(...r)}}if(n.Settings.tagFaceRegions.valueOrDefault)for(const i of e){const e=await(0,a.readRawTags)(i,!0);if(null!=e)for(const i of(0,f.values)(e)){const e=i?.RegionList;if(Array.isArray(e))for(const i of e)"Face"===i.Type&&t.push(i.Name)}}if((0,c.isNotEmpty)(n.Settings.whoTags.values))for(const i of e){const e=await(0,a.readRawTags)(i,!0);for(const i of n.Settings.whoTags.values)t.push(...(0,p.toA)((0,f.pluckDeep)(e,i)?.value))}const i=(0,c.uniq)((0,h.flatten)((0,c.uniq)(t).map(w)));return g().tap({msg:"whoTagFiles()",level:"info",result:i,meta:{names:t,files:e.map((e=>e.nativePath))}})};const y=(0,c.uniq)([m.TagRoots.Who,...n.Settings.rootTagWhoAliases.values].map((e=>e.toLowerCase())));function v(e){return y.includes((0,u.tagRefToS)(e[0]).toLowerCase())}function w(e){if(!(0,d.blank)(e))return Array.isArray(e)?(v(e)&&e.shift(),0===e.length?void 0:1===e.length?(0,l.renderNameTag)(e[0]):[[m.TagRoots.Who,...e]]):(0,l.renderNameTag)(e)}t.isWhoTag=v,t.nameTag=w},98348:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Db=void 0;const c=i(48884),d=i(19851),h=i(23560),f=i(25764),m=i(38836),p=i(99331),g=i(5916),y=i(12959),v=i(55332),w=i(91872),b=i(80632),S=i(51040),P=i(44955),_=i(15056),T=i(70025),M=i(57159),E=i(18454),k=i(28874),D=i(5233),x=i(42659),C=i(31586),F=i(68708),A=i(30976),I=i(17036),O=i(27134),L=i(35052);class R extends m.EndableWrapper{constructor(e,t){super("db.Db("+e+")",(()=>this.closeDb()),f.EndableRanks.db),r.add(this),this.schema=e,this.dbFile=t,s.set(this,0),n.set(this,void 0),this.endTimeoutMs=x.minuteMs,this.onRetry=(0,d.lazy)((()=>this.closeDb()),k.Settings.maxBusyDbMs.valueOrDefault/2),this.maxUpdatedAt=(0,d.lazy)((()=>"models"===this.schema?l(this,r,"m",a).call(this,"Asset","AssetFile","Example"):0),5*x.secondMs),this.migrate_=(0,g.lazyAsync)({desc:"db.migrate",later:async()=>{let e=!1;const t=this.dbFile;if(null==this.dbFile)throw new Error("Cannot migrate database: missing db");let i;if(await this.dbFile.isNonEmptyFile())try{await(0,O.verifyDb_)((()=>this.db))}catch(e){this.logger.warn("verifyDb failed before attempting Migration.",{error:e}),i=e}(null!=i||k.Settings.dbForceRecover.valueOrDefault)&&(E.HealthCheck.addLoadingMsg("Repairing database..."),await this.repair_(),e=!0);const r=new I.Migration(this.schema,this.db,t);return{appliedMigrations:await r.apply_(),migration:r,repaired:e}}}),this.tableInfo_=(0,d.lazy)((()=>(0,L.localTableInfo)(this.db)))}toJSON(){return(0,F.pick)(this,"schema","dbFile")}get isOpen(){return!0===l(this,n,"f")?.open}get inTransaction(){return this.isOpen&&!0===l(this,n,"f")?.inTransaction}prepare(e){return this.db.prepare(e)}pragma(e,t){return this.logger.tapThunk({msg:"PRAGMA "+e,result:()=>this.db.pragma(e,t)})}get db(){var e;const t=null==l(this,n,"f");if(t||!this.isOpen){this.logger.info("setting up new db connection to "+this.dbFile,{priorWasNull:t});try{u(this,n,(0,b.mkdb_)({nativePath:this.dbFile.nativePath}),"f")}catch(e){throw new M.WrappedError("Failed to set up "+this.dbFile,{cause:e,path:this.dbFile.nativePath})}}return(0,h.isSyncService)()&&"INCREMENTAL"===k.Settings.dbAutoVacuumMode.valueOrDefault&&(0,C.gt0)(k.Settings.dbWalAutoCheckpoint.valueOrDefault)&&u(this,s,(e=l(this,s,"f"),++e),"f")%k.Settings.dbWalAutoCheckpoint.valueOrDefault==0&&(this.logger.info("running incremental_vacuum..."),l(this,n,"f")?.pragma("incremental_vacuum")),l(this,n,"f")}async verify_(){await(0,O.verifyDb_)((()=>this.db))}assertHeartbeat_(){const e=(0,A.randomChars)(64),t=Date.now();try{this.db.prepare("INSERT INTO heartbeat (name, createdAt, updatedAt) VALUES (?,?,?)").run(e,t,t);const i=this.db.prepare("SELECT * FROM heartbeat WHERE name = ?").get(e);if(i?.name!==e)throw new Error("heartbeat INSERT/SELECT roundtrip failed")}finally{try{this.db.prepare("DELETE FROM heartbeat WHERE name = ?").run(e)}catch{}}}async closeDb(){try{this.logger.info("closing db",l(this,n,"f")),await(0,D.retryOnReject_)((()=>{!0===l(this,n,"f")?.open&&l(this,n,"f")?.close()}),{timeoutMs:k.Settings.dbBusyTimeoutMs.valueOrDefault,maxRetries:5,errorIsRetriable:T.isSqliteBusyError,retryDelay:x.secondMs})}catch(e){this.logger.warn("closeDb(): .close() failed",e)}u(this,n,void 0,"f")}async vacuum(){try{await(0,w.handleDbRetries_)("db.checkpoint",(()=>this.db),(()=>(0,O.checkpoint_)({db:this.db})),this.onRetry),await(0,w.handleDbRetries_)("db.optimize",(()=>this.db),(()=>this.db.pragma("OPTIMIZE")),this.onRetry),await(0,w.handleDbRetries_)("db.vacuum",(()=>this.db),(()=>this.db.exec("VACUUM")),this.onRetry)}catch(e){throw this.logger.warn("vacuum(): failed",{error:e}),e}}async repair_(){this.logger.warn("repair_(): Attempting restore of "+this.dbFile),await this.closeDb(),await(0,O.repairDbFile_)(this.dbFile),this.logger.info("repair_(): Database restoration was successful!")}localBackupDir(){return(0,_.dbBackupDir)(this.dbFile)}async backup_(e,t){const i=t??await(0,P.isDirSQLiteReadWrite)(e),s=(i?e:this.localBackupDir().join((0,y.filestamp)())).join(this.dbFile.base);return await l(this,r,"m",o).call(this,s),i||await(0,v.dbBackupCold_)(s,e),e.join(this.dbFile.base)}}t.Db=R,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=function(...e){const t=[];for(const i of e)try{t.push(this.db.prepare("SELECT MAX(updatedAt) FROM "+(0,S.dbValueToEscapedString)(i)).pluck().get())}catch(e){this.logger.warn(`#maxUpdatedAt(): failed to get max updatedAt for ${i}`,e)}return(0,c.max)(t)},o=async function(e){await e.parent().mkdirp_(),await this.db.backup(e.nativePath,{progress:e=>(this.logger.log((0,p.ending)()?"info":"debug","backup() "+(0,C.fmtPct)(100-e.remainingPages/e.totalPages*100)+" completed"),(0,p.ending)()?1e3:100)})}},25470:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.DbModelJanitor=t.Contested=t.NoOp=t.NoWriteLock=void 0;const c=i(66364),d=i(50213),h=i(23560),f=i(78406),m=i(25764),p=i(38836),g=i(99331),y=i(56038),v=i(12959),w=i(55332),b=i(76187),S=i(73209),P=i(28874),_=i(42659),T=i(75240),M=i(95700),E=i(22526),k=i(45648),D=5*_.minuteMs;t.NoWriteLock=Symbol("NoWriteLock"),t.NoOp=Symbol("NoOp"),t.Contested=Symbol("Contested");class x extends f.EndableInterval{static for(e){return new x(e.db,e.fslock,e.libraryDbFile,e.libraryDbBackupDir)}constructor(e,t,i,o){super({name:"db.DbModelJanitor",callback:()=>l(this,r,"m",n).call(this),intervalMs:P.Settings.dbBackupIntervalMs.valueOrDefault,initialDelayMs:_.minuteMs,rank:m.EndableRanks.db,endTimeoutMs:5*_.minuteMs,onEnd:()=>l(this,r,"m",a).call(this)}),r.add(this),this.db=e,this.dbFslock=t,this.libraryDbFile=i,this.libraryDbBackupDir=o,this.logger=(0,d.mkLogger)(this.name),this.fslockRelease=new p.EndableWrapper("db.DbModelJanitor.fslockRelease",(()=>this.dbFslock.release()),m.EndableRanks.postdb,D),s.set(this,0),this.dbFslock.tryAcquire_()}get useReplica(){return!this.db.dbFile.eql(this.libraryDbFile)}forceBackup_(){return this.backup_(!0)}async backup_(e=!1){return await(0,S.withLock_)({file:this.libraryDbBackupDir,timeoutMs:5*_.minuteMs,noopIfContested:!e},(async()=>{if(e&&u(this,s,0,"f"),(0,k.hasDbSetupErrors)())return this.logger.warn("backup_(): db has setup errors, skipping backup",{errors:(0,k.dbSetupErrors)()}),t.NoOp;if(!await this.dbFslock.tryAcquire_())return this.logger.info("backup_(): no-op: someone else has the fslock",{me:this.dbFslock.lockfile?.base,owner:(await this.dbFslock.selfAndSiblingNames_())[0]}),t.NoWriteLock;l(this,r,"m",o).call(this)||await(0,M.runMaintenanceTasks)();const i=this.db.maxUpdatedAt();return null!=i&&i>l(this,s,"f")?(0,y.time)("db.DbModelJanitor.backup_()",(async()=>{l(this,r,"m",o).call(this)?this.logger.info("backup_(): posthaste: skipping vacuum"):await this.db.vacuum(),u(this,s,i,"f");const e=this.libraryDbBackupDir.join((0,v.filestamp)()),t=await this.db.backup_(e,!this.useReplica);return this.useReplica&&await(0,w.dbBackupCold_)(t,this.libraryDbFile.parent()),this.logger.info("backup_(): backup successful",{destDbFile:t}),t})):(this.logger.info("backup_(): no update to the db since last backup",{ago:(0,T.fmtDuration)(Date.now()-l(this,s,"f"))}),t.NoOp)}))??t.Contested}}t.DbModelJanitor=x,s=new WeakMap,r=new WeakSet,n=async function(){try{await this.backup_()}catch(e){this.logger.error("backup_() failed",{error:e})}},a=async function(){const e=S.FsLock.for({file:this.libraryDbFile.sibling("db-teardown"),timeoutMs:D,endableRank:m.EndableRanks.postdb,noopIfContested:!1});(0,h.isDbManager)()&&await e.withLock_((async()=>{if(await this.dbFslock.iAmOnly_({vacuum:!0})){if(this.logger.info("#teardown(): I'm the last one in. Running backup and cleanup."),await this.backup_(),this.useReplica){const e=[(0,E.libraryDbInfoFromDbFile)(this.libraryDbFile),...(0,b.sqliteFiles)(this.db.dbFile)];this.logger.info("#teardown(): Removing replica artifacts",{victims:e});for(const t of e)await t.unlink()}}else this.logger.info("#teardown(): no-op: other processes are still running")})),await this.db.closeDb()},o=function(){return this.ended||(0,g.ending)()||(0,c.isSuspended)()}},35758:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelRepair=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(71567),o=i(98314),l=i(38835),u=i(18454),c=i(28874),d=i(63870),h=i(64526),f=i(14611),m=i(74085),p=i(22526),g=i(45648),y=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbModelRepair")));t.dbModelRepair=async function(){return{...await async function(){const e=h.Library.instance();if(null==e)throw new Error("No library set."+l.NoLibraryErrorFlag);const t=await e.dbModelJanitor();if(null==t)throw new Error("No library set (missing dbModelJanitor)."+l.NoLibraryErrorFlag);(0,g.clearDbSetupErrors)();const i=await(0,m.dbModelHealthCheck)().refresh();if(y().info("dbModelRepair: health check result: ",i),c.Settings.dbForceRecover.valueOrDefault)u.HealthCheck.addLoadingMsg("PS_DB_FORCE_REPAIR was set. Trying to repair.");else if("ok"!==i.level)u.HealthCheck.addLoadingMsg(`Database health check failed: ${i.msg}. Trying to repair.`),c.Settings.dbForceRecover.envValue=!0;else try{return u.HealthCheck.addLoadingMsg("Backing up the library database..."),await t.forceBackup_(),u.HealthCheck.addLoadingMsg("Validating the library database..."),await t.db.verify_(),u.HealthCheck.addLoadingMsg("No repair needed: maintenance tasks, backup, and integrity tests ran without error."),y().tap({msg:"dbModelRepair()",level:"info",result:{noop:!0,op:"validated"}})}catch(e){u.HealthCheck.addLoadingMsg(`Maintenance, backup, or integrity tasks failed: ${(0,o.errorToS)(e)}. Trying to repair.`),c.Settings.dbForceRecover.envValue=!0}(0,n.isWebService)()&&a.StdoutWrite.shutdownSync();const r=await e.dbFsLock();if(!await r.acquire_({timeoutMs:2*(0,d.commandTimeoutMs)(),releaseOnFailure:!1}))return y().throw("Failed to acquire exclusive lock on the library database. Shut down other processes before retrying.");try{await(0,p.assertValidDbInfo_)()}catch(e){u.HealthCheck.addLoadingMsg(`Library database setup was invalid: ${(0,o.errorToS)(e)}. Resetting and restarting.`),await(0,p.libraryDbInfoJsonFile)().unlink(),c.Settings.dbForceRecover.envValue=!0}await(0,f.restartLibrary_)();const s=c.Settings.dbForceRecover.valueOrDefault;return c.Settings.dbForceRecover.unset(),y().tap({msg:"dbModelRepair()",level:"info",result:{op:s?"repaired":"restarted",noop:!1}})}(),state:(await u.HealthCheck.rerunSetup()).state}}},22526:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelSetup_=t.assertValidDbInfo_=t.libraryDbInfoFromDbFile=t.libraryDbInfoJsonFile=t.fsLockForDb=t.libraryDbObjects_=void 0;const r=i(19851),s=i(50213),n=i(92407),a=i(55332),o=i(44955),l=i(15056),u=i(87290),c=i(98314),d=i(38835),h=i(73209),f=i(95696),m=i(17217),p=i(18454),g=i(57902),y=i(28874),v=i(2858),w=i(40958),b=i(22573),S=i(42659),P=i(94448),_=i(98348),T=i(45648),M=(0,r.lazy)((()=>(0,s.mkLogger)("db.DbModelSetup")));function E(e=y.Settings.libraryDir.valueOrDefault){if((0,b.blank)(e))throw new Error("Library directory is not set"+d.NoLibraryErrorFlag);const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dataDir"+d.NoLibraryErrorFlag);if(!(0,v._libraryHasSettings)(e))throw new Error(`Library at ${e} does not have a settings file`+d.NoLibraryErrorFlag);const i=(0,l.pathToDb)(t,"models");return{dataDir:t,libraryDbFile:i,libraryDbBackupDir:(0,l.dbBackupDir)(i)}}function k(e){return h.FsLock.for({file:e,timeoutMs:0,noopIfContested:!1})}function D(e=y.Settings.libraryDir.valueOrDefault){const t=(0,u.libraryDataDirPosixFile)(e);if(null==t)throw new Error("missing library dir"+d.NoLibraryErrorFlag);return x((0,l.pathToDb)(t,"models"))}function x(e){return e.sibling("db-info.json")}async function C(e=D(),t){try{const i=await e.readJson(g.LogLevels.info);if(null==i)throw new Error(e+" is missing"+d.DbSetupErrorFlag);if(null!=t&&!await t.equalsUri_(i.uri))throw new Error(e+" expects the live db to be "+i.uri+" but the live db is "+await t.uri_()+d.DbSetupErrorFlag);const r=await f.PosixFile.forUri(i.uri);if(null==r)throw new Error(e+" expects the live db to be "+i.uri+" but that URI cannot be resolved."+d.DbSetupErrorFlag);try{await(0,o.assertDirSQLiteReadWrite_)(r.parent())}catch(t){throw M().error("assertValidDbInfo_(): failed to assert live dir was r/w",{error:t,liveDbFile:r,infoJsonFile:e}),new Error("Failed to validate that the live database directory, "+r.dir+", was read-writable by SQLite: "+(0,c.errorToS)(t)+d.DbSetupErrorFlag)}return{liveDbFile:r}}catch(e){throw(0,T.addDbSetupError)(e),e}}t.libraryDbObjects_=E,t.fsLockForDb=k,t.libraryDbInfoJsonFile=D,t.libraryDbInfoFromDbFile=x,t.assertValidDbInfo_=C,t.dbModelSetup_=async function(e=y.Settings.libraryDir.valueOrDefault){const{libraryDbFile:t,fslock:i,libraryDbBackupDir:r}=await async function(e=y.Settings.libraryDir.valueOrDefault){const t=E(e);return{...t,fslock:k(t.libraryDbFile)}}((0,b.mapNotBlank)(e,m.toNativePath_));let s,o;await i.tryAcquire_();const u=x(t);try{if(await(0,h.withLock_)({file:u,timeoutMs:5*S.minuteMs},(async()=>{const i=await u.readJson(g.LogLevels.info);if(s=i?.useReplica,null!=i){const{liveDbFile:e}=await C(u,t);o=new _.Db(l.Schemas.models,e)}if(null==s||null==o){const i=await(0,n.getLiveDbDir_)(e),r=await i.db.uri_();s=i.useReplica,s&&await p.HealthCheck.traceLater_("Setting up local replica database",(0,a.dbBackupCold_)(t,i.db.parent())).catch((e=>M().throw("Failed to set up replica db"+d.DbSetupErrorFlag,{src:t,dest:i.db,error:e}))),o=new _.Db(l.Schemas.models,i.db),await u.writeJson_({uri:r,useReplica:s})}})),null==o||null==s)return M().throw("Failed to open model db"+d.DbSetupErrorFlag+d.InternalErrorFlag,{libraryDir:e});if(await i.tryAcquire_()){const e=await o.migrate_();s&&(e.repaired||(0,w.isNotEmpty)(e.appliedMigrations))&&await o.backup_(t.parent(),!s),(0,T.clearDbSetupErrors)()}P.modelDb.set(o)}catch(e){throw M().error("Failed to set up model db",{error:e}),(0,T.addDbSetupError)(e),i.release(),e}return M().tap({msg:"dbModelSetup()",result:{db:o,useReplica:s,libraryDbFile:t,libraryDbBackupDir:r,fslock:i}})}},86859:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DbRequest=void 0;const r=i(54557),s=i(50213),n=i(99331),a=i(56038),o=i(65753),l=i(66184),u=i(70417),c=i(28874),d=i(40958),h=i(22573),f=i(45599),m=i(96249),p=i(31586),g=i(51926),y=i(57038),v=i(21074),w=(0,f.defer)((()=>(0,s.mkLogger)("db.DbRequest")));t.DbRequest=class{constructor(e,t){this.db=e,this.tableName=t,this.cachedStatements=new r.FifoCache(256)}qb(){return(0,y.knex)()(this.tableName)}prep(e,t=!1){const i=(0,v.toSqlQuery)(e);try{const r=this.cachedStatements.getOrSet(this.db().db.__uid+":"+(!0===t?"pluck:":"")+i.sql,(()=>{const e=this.db().prepare(i.sql);return!0===t?e.pluck():e}));return r.database.open?{sq:i,stmt:r}:(this.cachedStatements.clear(),this.prep(e,t))}catch(e){return w().throw("prep() failed",{error:e,sqlQuery:i,retriable:!1})}}wrap({q:e,pluck:t,m:i}){try{const{sq:r,stmt:s}=this.prep(e,t);c.Settings.logSql.valueOrDefault&&w().log((0,l.defaultLogLevel)(),i+"(): "+(0,v.sqlQueryToS)(r));const n=s[i].bind(s);return null==r.bindings?n():n(r.bindings)}catch(t){if(!0===t.message?.includes("AdvisoryLock"))throw t;w().throw(t,{method:i,...(0,v.toSqlQuery)(e)})}}run(e){return this.wrap({q:e,m:"run"})}runScript(e,t=""){const i=(0,a.mkElapsed)("db.runScript()");for(const r of e){if((0,h.blank)(r)||r.trim().startsWith("--"))continue;this.run({sql:r});const e=(0,g.replaceAll)((0,g.ellipsize)(r,60),t,"");i.elapsed(e)}}mapRun(e){return e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return null==t.bindings?i.run():i.run(t.bindings)}))}runf(e){return this.wrap({q:e(this.qb()),m:"run"})}upsert(e){const t=(0,v.toSqlQuery)(e(this.qb()));return t.sql=t.sql.replace(/^(?:update|insert)\b/i,(e=>e.toUpperCase()+" OR REPLACE ")),this.wrap({q:t,m:"run"})}first(e){return this.wrap({q:e,m:"get"})}firstf(e){return this.wrap({q:e(this.qb()),m:"get"})}mapAll(e){return(0,m.flatten)(e.map((e=>{const{sq:t,stmt:i}=this.prep(e);return i.all(t.bindings)})))}all(e){return this.wrap({q:e,m:"all"})}allf(e){return this.wrap({q:e(this.qb()),m:"all"})}async batched(e){let t,i=0;do{t=this.wrap({q:e.qb(this.qb(),t).limit((0,o.maxBatchPluckSize)()),m:"all"}),(0,d.isNotEmpty)(t)&&(await e.onResults(t),i+=t.length)}while((0,d.isNotEmpty)(t)&&!(0,n.ending)()&&(null==e.maxResults||e.maxResults>i));return{resultCount:i,done:null==t||t.length<(0,o.maxBatchPluckSize)()}}pluckFirst(e){return this.wrap({q:e,pluck:!0,m:"get"})}pluckFirstf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"get"})}pluckAll(e){return this.wrap({q:e,pluck:!0,m:"all"})}pluckAllf(e){return this.wrap({q:e(this.qb()),pluck:!0,m:"all"})}async pluckBatched(e){let t=0;const i=(0,u.min)([e.limit??(0,o.maxBatchPluckSize)(),e.maxResults]);if(i<=0||(0,p.lte0)(e.maxResults))return{done:!1,resultCount:t};let r;for(;null==e.maxResults||e.maxResults<=0||t(0,o.mkLogger)("db.DbSchemaValid")));function y(e){return l.PosixFile.for(s.default.join(u.ProjectPath.Data(),e+"-schema.json"))}t.schemaJsonFile=y,t.assertValidDbSchema_=async function(e){try{await e.migrate_();const t=(0,p.localTableInfo)(e.db),i=t.map((e=>e.tableName)),r=(await y(e.schema).readJson_()).tableInfo;{const e=r.map((e=>e.tableName)),t=(0,c.diff)(e,i);(0,c.isNotEmpty)(t)&&g().throw("Db is missing "+(0,f.plur)(t.length,"table")+": "+(0,h.andList)(t))}for(const e of t){const t=r.find((t=>t.tableName===e.tableName));if(null==t)g().warn("Unexpected table in db",e);else{const i=(0,n.diffEql)(t.columns,e.columns);(0,c.isNotEmpty)(i)&&g().throw("Db is missing "+(0,f.plur)(i.length,"column")+" from table "+e.tableName+": "+(0,h.andList)(i.map((e=>e.name))))}}g().info("Validated schema.",{from:(0,d.shortStack)()})}catch(e){throw(0,m.dbModelHealthCheck)().reset(),e}},t.writeSchemaJsonFile_=function(e,t){return y(e).writeJson_({info:"This is used in validating PhotoStructure library databases after repair and restore operations.",tableInfo:(0,p.localTableInfo)(t)},{spaces:2})}},45648:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addDbSetupErrorListener=t.hasDbSetupErrors=t.clearDbSetupErrors=t.addDbSetupError=t.dbSetupErrors=t._dbSetupErrors=void 0;const r=i(98314),s=i(22573),n=i(23541);t._dbSetupErrors=new Set;const a=[];t.dbSetupErrors=function(){return[...t._dbSetupErrors.values()]},t.addDbSetupError=function(e){if((0,n.isError)(e)||!(0,s.blank)(e)){t._dbSetupErrors.add((0,r.errorToS)(e));for(const e of a)e()}},t.clearDbSetupErrors=function({notifyListeners:e=!0}={}){if(t._dbSetupErrors.clear(),e)for(const e of a)e()},t.hasDbSetupErrors=function(){return t._dbSetupErrors.size>0},t.addDbSetupErrorListener=function(e){a.push(e)}},36908:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dedupeTags_=t.mergeTags_=void 0;const r=i(19851),s=i(50213),n=i(81168),a=i(42231),o=i(40958),l=i(76790),u=i(23838),c=i(31586),d=i(54993),h=(0,r.lazy)((()=>(0,s.mkLogger)("db.DedupeTags")));function f(e,t){function i(t){return e.prepare(t).run()}(0,o.isEmpty)(t)&&h().warn("mergeTags(): empty tagIds",{tagIds:t}),h().info("mergeTags() starting",{tagIds:t});const r=e.prepare("SELECT id, _path, parentId FROM Tag WHERE id IN ("+t.join(",")+") ORDER BY ID").all(),s=(0,o.compactBlanks)(r.map((e=>(0,a.tagPathLeaf)(e._path))).sort()),n=r[0],l=r.slice(1),u=n?.id;if((0,o.isEmpty)(s)||(0,o.isEmpty)(l)||null==n||!(0,c.gt0)(u))return void h().warn("mergeTags(): missing winner",{winner:n,winnerId:u,leafs:s,losers:l});const d=(0,a.splitTagPath)(n._path).slice(0,-1),f=[...d,s[0]];n._path=(0,a.joinTagPath)(f),n.parentId=0===d.length?null:e.prepare("SELECT id from Tag where _path LIKE ?").pluck().get((0,a.joinTagPath)(d))??n.parentId,h().info("mergeTags()",{winner:n,losers:l,winnerTagPath:f,leafs:s});const m=l.map((e=>e.id)).join(",");i(`UPDATE OR IGNORE AssetTag SET tagId = ${u} WHERE tagId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`UPDATE OR IGNORE Tag SET parentId = ${u} WHERE parentId in (${m})`),i(`DELETE FROM AssetTag WHERE tagId in (${m})`),i(`DELETE FROM Tag WHERE id in (${m})`),e.prepare("UPDATE Tag SET parentId = :parentId, _path = :path WHERE id = :id").run({parentId:n.parentId,path:n._path,id:u});const p=e.prepare("SELECT id, _path FROM Tag WHERE id != :winnerId AND _path LIKE :like COLLATE NOCASE").all({winnerId:u,like:n._path+"%"});for(const t of p){const i=(0,a.splitTagPath)(t._path).slice(f.length),r=(0,a.joinTagPath)([...f,...i]);t._path!==r&&(h().info("mergeTags(): repairing tag path",{ea:t,newPath:r}),e.prepare("UPDATE OR IGNORE Tag SET _path = :path, updatedAt = :updatedAt WHERE id = :id").run({id:t.id,updatedAt:Date.now(),path:r}))}return h().tap({msg:"mergeTags()",level:"info",result:{winner:n,losers:r}})}t.mergeTags_=f,t.dedupeTags_=function(e){const t=new u.MultiMap;for(const{id:i,_path:r}of e.prepare("SELECT id, _path FROM Tag ORDER BY id").iterate())t.add((0,n.stripSuffix)((0,d.toS)(r).trim(),a.TagSep).toLowerCase().normalize(),i);const i=(0,l.sortBy)(t.entriesArray().filter((([,e])=>e.length>1)),(([e])=>[-(0,n.countChars)(e,a.TagSep),-e.length,e]));for(const[,t]of i)f(e,t)}},57038:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstMigratedAt=t.knex=void 0;const s=r(i(31832)),n=i(19851),a=i(56519),o=i(55835),l=i(68708);t.knex=(0,n.lazy)((()=>(0,s.default)({client:"better-sqlite3",useNullAsDefault:!0}))),t.firstMigratedAt=async function(e){return(0,a.thenMap)(e("migrations").min("migration_time").first(),(e=>(0,o.map)((0,l.values)(e)[0],(e=>new Date(e)))))}},17036:function(e,t,i){"use strict";var r,s,n,a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Migration=void 0;const o=i(77598),l=i(19851),u=i(50213),c=i(7282),d=i(37805),h=i(4867),f=i(51040),m=i(77740),p=i(38835),g=i(8769),y=i(57159),v=i(34102),w=i(73209),b=i(95696),S=i(43899),P=i(18454),_=i(28874),T=i(40958),M=i(42659),E=i(41400),k=i(98553),D=i(55835),x=i(34666),C=i(32639),F=i(45648),A=i(94715),I=i(27134);t.Migration=class{constructor(e,t,i){r.add(this),this.schema=e,this.db=t,this.dbFile=i,this.fsMigrations_=(0,l.lazy)((()=>this.migrationsDir.children_((e=>e.isFile&&e.basename.endsWith(".sql"))).catch((e=>this.logger.throw("Failed to read migration directory, "+this.migrationsDir+p.InternalErrorFlag,{error:e}))))),this.ensureMigrationTable_=(0,l.lazy)((()=>{this.db.exec("\nCREATE TABLE IF NOT EXISTS migrations (\n id INTEGER NOT NULL PRIMARY KEY,\n name TEXT NOT NULL,\n migration_time INTEGER NOT NULL\n) STRICT\n")})),this.unknownMigrations_=(0,l.lazy)((()=>this.migrationsInDatabase_().filter((e=>!(0,x.lt)((0,A.migrationNameToDate)(e),d.gitDate))))),this.assertKnownMigrations_=(0,l.lazy)((()=>{const e=this.unknownMigrations_();if((0,T.isNotEmpty)(e)){const t=new y.WrappedError("Please upgrade PhotoStructure to a newer version to open this library: Unknown migrations: "+e.join(","));throw(0,g.onError)(t),t}})),this.logger=(0,u.mkLogger)("db.Migration("+(0,k.stringify)({schema:e,db:i.nativePath})+")"),this.migrationsDir=b.PosixFile.for(S.ProjectPath.Migrations()).join(this.schema)}async pendingMigrationFiles_(){const e=this.migrationsInDatabase_();return(await this.fsMigrations_()).filter((t=>!e.includes(t.name)))}migrationsInDatabase_(){return this.ensureMigrationTable_(),this.db.prepare("SELECT name from migrations").pluck().all()}async apply_(e){return(0,w.withLock_)({file:this.dbFile.sibling("migrate"),timeoutMs:_.Settings.dbMaintenanceTimeoutMs.valueOrDefault},(()=>a(this,r,"m",s).call(this,e)))}async applyMigration_(e,t){try{const i=Date.now(),s=A.Migrations[e.name.replace(/^[\d_-]+/,"")],o=(0,C.isFunction)(s);return o?await s.bind(A.Migrations)(this.db):await a(this,r,"m",n).call(this,e),this.logger.info("applyMigration() completed",{elapsedMs:Date.now()-i,codeMigration:o,migration:e.baseWithParent}),t?.run(e.name,Date.now())}finally{(0,v.ee)().emit("clearDbCache")}}},r=new WeakSet,s=async function(e){try{this.ensureMigrationTable_(),(0,c.isProd)()&&this.assertKnownMigrations_();const t=[],i=this.db.prepare("INSERT INTO migrations (name, migration_time) VALUES (?, ?)");for(const r of await this.pendingMigrationFiles_())await P.HealthCheck.traceLater_("Upgrading database ("+r.name+")",(async()=>{if((0,m.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");(0,m.getDevEnvFlag)("PS_SLOMO")&&await(0,E.delay)((0,o.randomInt)(M.secondMs,3*M.secondMs)),await(0,D.map)(e,(e=>e(r))),await(0,h.thenOrTimeoutError)({p:this.applyMigration_(r,i),timeoutMs:5*_.Settings.dbMaintenanceTimeoutMs.valueOrDefault}).catch((e=>{throw new y.WrappedError("Migration "+r.name+" timed out.",{cause:e,fatal:!0,ignorable:!1})}))})),t.push(r.base);return this.logger.info("Migration complete",{appliedMigrations:t}),t}catch(e){const t=new y.WrappedError("Migrating the "+this.schema+" db failed",{cause:e});throw(0,F.addDbSetupError)(t),P.HealthCheck.addError(t),t}},n=async function(e){const t=e.name.includes("_nofk");try{const i=await e.readTextFile(),r=(0,f.splitBatchSql)(i);if((0,T.isEmpty)(r))this.logger.info("No-op migration: "+e);else{t&&this.db.pragma("foreign_keys = OFF");for(const t of r)try{this.db.exec(t)}catch(i){this.logger.throw("Failed to apply SQL",{stmt:t,migration:e.baseWithParent,cause:i,fatal:!0})}t&&(0,I.foreignKeyCheck_)(this.db)}}finally{t&&this.db.pragma("foreign_keys = ON")}}},94715:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Migrations=t.isoToPrecisionMs=t.fix_root_tags=t.tag_path_suffix=t.migrationNameToDate=t.plucklabmodeb6=t.lowercase_psnet_function=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(97352),o=i(68852),l=i(81168),u=i(85810),c=i(42022),d=i(1971),h=i(79842),f=i(89724),m=i(17415),p=i(88600),g=i(20014),y=i(42231),v=i(87001),w=i(40958),b=i(55835),S=i(31586),P=i(97790),_=i(89937),T=i(54993),M=i(7656),E=i(36908),k=(0,s.lazy)((()=>(0,n.mkLogger)("db.Migrations"))),D=new RegExp(`^(${(0,o.escapeRegExp)(_.PS_NETWORK_FILESYSTEM_SCHEME)}://.*?/)(.*)$`);function x(e,t){return(0,a.mapGt0)(e,(()=>(0,b.map)(function(e,t=c.ModeBits){return(0,g.splitBits)(e,t).map((e=>(0,u.unlabhash)(e,t)))}(e,6)[t],(e=>(0,u.toLabhash)(e,c.ModeBits)))))}function C(e){return e.endsWith(y.TagSep)?e:e+y.TagSep}function F(e){for(const t of e.prepare("SELECT id, parentId, _path FROM Tag WHERE id = parentId").iterate())k().warn("fix_root_tags(): broken tag",{broken:t}),(0,l.countChars)(t._path,y.TagSep)<2&&e.prepare("UPDATE Tag set parentId = null where id = ?").run(t.id)}function A(e){return(0,b.map)((0,h.isoToDated)(e),h.datedToPrecisionMs)??-1}t.lowercase_psnet_function=e=>(0,P.opt)(e).filter(l.isString).flatMap((e=>D.exec(e))).map((e=>e[1].toLowerCase()+e[2])).getOrElse((()=>e)),t.plucklabmodeb6=x,t.migrationNameToDate=function(e){const[t,i,r]=[e.slice(0,4),e.slice(4,6),e.slice(6,8)].map((e=>(0,S.toInt)(e)));return(0,p.validYMD)(t,i,r)?new Date(t,i-1,r):void 0},t.tag_path_suffix=C,t.fix_root_tags=F,t.isoToPrecisionMs=A,t.Migrations={fix_root_tags:F,lowercase_psnet_hostname:e=>{e.function("lowercase_psnet_hostname",{deterministic:!0},t.lowercase_psnet_function),e.exec("DROP INDEX IF EXISTS assetfile_uri_udx"),e.exec("UPDATE AssetFile SET uri = lowercase_psnet_hostname(uri)"),e.exec("CREATE UNIQUE INDEX assetfile_uri_udx ON AssetFile(uri)")},numeric_captured_at:e=>{e.function("isoToLocal",{deterministic:!0},f.isoToLocal),e.function("isoToOffsetMinutes",{deterministic:!0},m.isoToOffsetMinutes),e.function("isoToPrecisionMs",{deterministic:!0},A),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtLocal bigint"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtOffset integer"),e.exec("ALTER TABLE AssetFile ADD COLUMN capturedAtPrecisionMs integer"),e.exec("UPDATE AssetFile SET capturedAtLocal = isoToLocal(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtOffset = isoToOffsetMinutes(capturedAtISO)"),e.exec("UPDATE AssetFile SET capturedAtPrecisionMs = isoToPrecisionMs(capturedAtISO)"),e.exec("DROP INDEX asset_captured_at_geohash_idx"),e.exec("DROP INDEX assetfile_exifuid_idx"),e.exec("CREATE INDEX assetfile_capturedAtLocal_idx ON AssetFile(capturedAtLocal)")},spread_modes:e=>{e.function("plucklabmodeb6",{deterministic:!0},x),(0,S.times)(d.ModeCount,(t=>e.exec(`ALTER TABLE AssetFile ADD COLUMN mode${t} integer`))),e.exec("UPDATE AssetFile SET "+(0,S.times)(d.ModeCount,(e=>`mode${e} = plucklabmodeb6(mode8b6, ${e})`)).join(", "))},normalize_asset_file_uris:e=>{e.function("normalizeURI",{deterministic:!0},v.normalizeURI);const t=e.prepare("SELECT normalizeURI(uri) AS nuri, count(*) AS cnt, GROUP_CONCAT(id) AS ids FROM AssetFile GROUP BY nuri HAVING cnt > 1").all(),i=[];for(const s of t){const t=(0,T.toS)(s.ids).split(","),n=e.prepare("SELECT id, shown, version, updatedAt FROM AssetFile WHERE id in ("+t.join(",")+")").all(),a=(0,r.greatestBy)(n,(e=>[e.shown,e.version,e.updatedAt])),o=n.filter((e=>e.id!==a?.id));i.push(...o.map((e=>e.id)))}for(const t of(0,r.batches)(i,256))e.exec("DELETE FROM AssetFile WHERE id in ("+t.join(",")+")");e.exec("UPDATE AssetFile SET uri = normalizeURI(uri)")},dedupe_tag_paths:E.dedupeTags_,suffix_tag_paths:e=>{e.function("tag_path_suffix",{deterministic:!0},C),(0,E.dedupeTags_)(e),e.exec("UPDATE Tag SET _path = tag_path_suffix(_path)")},normalize_tag_paths:e=>{const t=e.prepare("SELECT id, _path FROM Tag WHERE _path LIKE '%' || char(31) || char(31) || '%'").all();k().info("normalize_tag_paths():",{badTags:t});for(const i of t){const t=(0,y.normalizeTagPath)(i._path);(0,E.mergeTags_)(e,(0,w.compact)([i.id,...e.prepare("SELECT id FROM Tag WHERE _path LIKE ?").pluck().all(t)]))}},drop_tc_tables:e=>{const t=/^(ct|taf|tag_counts)_[a-z\d]{6}$/i,i=e.prepare("SELECT name FROM sqlite_master WHERE type='table'").pluck().all(),r=i.filter((e=>null!=t.exec(e)));k().info("drop_tc_tables()",{tables:i,victims:r});for(const t of r)e.exec("DROP TABLE "+t)},rebuild_rotated_heic:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype = 'image/heif' AND rotation <> 0")},rebuild_videos:e=>{e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%'"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where mimetype LIKE 'video/%')")},copy_asset_duration:e=>{e.exec("CREATE INDEX tmp_af_idx ON AssetFile (assetId, durationMs)"),e.exec("UPDATE Asset SET durationMs = (SELECT durationMs FROM AssetFile WHERE assetId = Asset.id AND durationMs IS NOT NULL LIMIT 1) WHERE durationMs IS NULL"),e.exec("DROP INDEX tmp_af_idx"),e.exec("UPDATE AssetFile SET version = 0 WHERE mimetype LIKE 'video/%' and durationMs IS NULL"),e.exec("UPDATE Asset SET version = 0 WHERE id IN (SELECT DISTINCT assetId from AssetFile where version = 0)")},rebuild_tag_asset_counts:M.rebuildTagAssetCounts,create_tag_fts:e=>{e.exec("DROP TABLE IF EXISTS tag_fts"),e.exec("CREATE VIRTUAL TABLE tag_fts USING fts5 (root, path, content='', contentless_delete=1, tokenize=\"unicode61\");")}}},27134:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.repairDbFile_=t.checkpoint_=t.verifyDbFile_=t.verifyDb_=t.foreignKeyCheck_=t.integrityCheck_=t.quickCheck_=t.backupDbFile_=t.sqlite=void 0;const r=i(14121),s=i(19851),n=i(50213),a=i(84777),o=i(12959),l=i(5531),u=i(91872),c=i(99315),d=i(76187),h=i(51040),f=i(38835),m=i(57159),p=i(29882),g=i(95696),y=i(89966),v=i(38156),w=i(28874),b=i(63870),S=i(5233),P=i(42659),_=i(41400),T=i(50357),M=i(98553),E=i(56409),k=i(31586),D=i(20214),x=i(51926),C=i(12168),F=i(59455),A=i(54993),I=i(94448),O=i(9508),L=(0,s.lazy)((()=>(0,n.mkLogger)("db.SQLite")));function R({db:e,pragma:t,okResult:i}){L().debug("pragmaOrThrow_()",{db:N(e),db_open:e?.open,pragma:t,okResult:i});const r=(0,x.isString)(i)?e.pragma(t,{simple:!0}):e.pragma(t);(0,T.eql)(r,i)||L().throw(`${t} failed for ${N(e)}: ${(0,M.stringify)({result:r})}`)}function N(e){return(0,p.ellipsizePath)({p:e.name,maxLength:80})}function B(e){return R({db:e,pragma:"quick_check",okResult:"ok"})}function j(e){return R({db:e,pragma:"integrity_check",okResult:"ok"})}function z(e){const t=(0,F.toA)(e.pragma("foreign_key_check"));t.length>w.Settings.dbInvalidFKThreshold.valueOrDefault&&L().throw("foreignKeyCheck_(): too many invalid foreign keys to repair",{dbInvalidForeignKeyThreshold:w.Settings.dbInvalidFKThreshold.valueOrDefault,badRowsCount:t.length,badRows:t});for(const i of t)L().warn("repairDbFile_(): deleting row with invalid foreign key",{row:i}),e.prepare(`DELETE FROM ${(0,h.dbValueToEscapedString)(i.table)} WHERE rowid = ?`).run(i.rowid)}async function V(e){await(0,u.handleDbRetries_)("db.quickCheck",e,B),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.integrityCheck",e,j),await(0,_.delay)(1),await(0,u.handleDbRetries_)("db.foreignKeyCheck",e,z)}function W(e){return(0,O.withDbSync)(e,V,(0,b.commandTimeoutMs)())}t.sqlite=async function({dbFile:e,sql:t,args:i}){const s=await(0,y.sqliteNativePath_)(),n=await(0,r.thenElapsed)((0,a.stdout_)(s,[...(0,F.toA)(i),e.nativePath,t],{timeoutMs:1*P.minuteMs}));return L().debug("sqlite("+t+") on "+e+" in "+n.elapsedMs+"ms",n.result),n.result},t.backupDbFile_=function(e,t){return(0,S.retryOnReject_)((()=>async function(e,t){try{await t.parent().mkdirp_(),await t.unlink("trace");const i=await e.size();if(!(0,k.gt0)(i))return void L().warn("backupDbFile_(): "+e+" is empty");await((0,I.modelDb)()?.end()),await(0,O.withDb)(e,(async e=>e.exec("VACUUM INTO "+(0,h.dbValueToEscapedString)(t.nativePath))),2*P.minuteMs),L().info("backupDbFile_(): Finished "+e+" -> "+t)}catch(i){throw new m.WrappedError(`Could not back up db ${e} -> ${t}`,{cause:i})}}(e,t)),{maxRetries:3,retryDelay:P.secondMs,timeoutMs:P.minuteMs,errorIsRetriable:()=>!0})},t.quickCheck_=B,t.integrityCheck_=j,t.foreignKeyCheck_=z,t.verifyDb_=V,t.verifyDbFile_=W,t.checkpoint_=async function e({db:t,retries:i=3,checkpointType:r=w.Settings.dbWalCheckpointType.valueOrDefault}){if((r=l.CheckpointTypes.getCI(r)??l.CheckpointTypes.AUTO)===l.CheckpointTypes.AUTO)return;const s="wal_checkpoint("+r+")",[n]=(0,F.toA)(t.pragma(s));return L().info("checkpoint()",{pragma:s,result:n}),(0,k.gt0)(n?.busy)&&i>0?(await(0,_.delay)(250),e({db:t,retries:i-1})):n};const U=/no such table: sqlite_\w+/i;t.repairDbFile_=async function(e,t=c.RepairModes.dump){const i=g.PosixFile.for(e),r=(await i.parent().join("db-"+t,(0,o.filestamp)()).mkdirp_()).join(i.base);L().info(`repairDbFile_(${i} -> ${r})`);try{const e=await(0,y.sqliteNativePath_)(),s=4*Math.min(20*C.MiB,await(0,d.sqliteSizeBytes)(i)),n=new v.PushProgressObserver({path:(0,A.toS)(i),op:"Repairing your database"},s),o=new E.Latch,l=(0,a.execFile)(e,[i.nativePath,"."+t],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});l.stdout.on("error",(e=>{const i=(0,A.toS)(e);U.test(i)?L().info("repairDbFile_(): ignoring stderr",{err:i}):o.reject(new Error("sqlite "+t+" failed: "+i))}));const u=(0,a.execFile)(e,[r.nativePath],5*P.minuteMs,{encoding:"buffer",maxBuffer:s});u.on("exit",(()=>o.resolve())),l.stdout.on("end",(()=>{u.stdin.end(null)})),l.stdout.on("data",(e=>{const t=e.length;n.incrProgress(t),u.stdin.write(e)})),await o,L().info(`repairDbFile_(): recovered to ${r}.`),await W(r),L().info(`repairDbFile_(): ${r} is valid, finishing repair.`);const c=await(0,D.thenCollect)((0,d.sqliteFiles)(i),(e=>e.renameYMDHMS_({subdir:"needed-repair"})));return await(0,D.thenCollect)((0,d.sqliteFiles)(r),(e=>e.mv_(i.parent()))),c.find((e=>".db"===e.ext||e.ext.startsWith(".sqlite")))}catch(e){return L().throw("failed to recover DB via dump and restore. Please see https://photostructure.com/faq/restore-db-from-backup/ "+f.FatalErrorFlag,{error:e})}}},21074:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sqlWhereInClause=t.isQueryBuilder=t.sqlQueryToS=t.toSqlQuery=t.isSqlQuery=void 0;const r=i(48884),s=i(68852),n=i(81168),a=i(12943),o=i(96249),l=i(98553),u=i(31586),c=i(68708),d=i(32639),h=i(54993);function f(e){return null!=e&&(0,n.isString)(e.sql)&&(null==e.bindings||(0,a.isDbValued)(e.bindings))}t.isSqlQuery=f,t.toSqlQuery=function(e){if(null==e)throw new Error("null sql");if(f(e))return e;if((0,n.isString)(e))return{sql:e};if((0,d.isFunction)(e.toSQL))return(0,c.omit)(e.toSQL(),"__knexQueryUid");throw new Error("not queryish: "+(0,l.stringify)(e))},t.sqlQueryToS=function(e){if(null==e.bindings)return e.sql;if(Array.isArray(e.bindings))return(0,o.flatten)((0,r.zip)(e.sql.split("?"),e.bindings.map((e=>(0,l.stringify)(e))))).join("");{let t=e.sql;for(const i of(0,c.keys)(e.bindings))t=t.replace(new RegExp("[@:$]"+(0,s.escapeRegExp)(i),"gi"),(0,h.toS)(e.bindings[i]));return t}},t.isQueryBuilder=function(e){return(0,d.isFunction)(e?.where)&&(0,d.isFunction)(e?.limit)},t.sqlWhereInClause=function(e){return"("+(0,u.times)(e,(()=>"?")).join(",")+")"}},35052:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.localTableInfo=t.parseTableInfo=void 0;const r=i(22573),s=i(23838);function n(e){const t=new s.MultiMap;for(const i of e)i.tableName.includes("fts")||i.tableName.includes("sqlite_")||(0,r.blank)(i.name)||(0,r.blank)(i.type)||t.add(i.tableName,{name:i.name,type:i.type.toUpperCase().trim().replace(/\s+/g,""),notnull:1===i.notnull,pk:1===i.pk});return t.entriesArray().map((([e,t])=>({tableName:e,columns:t})))}t.parseTableInfo=n,t.localTableInfo=function(e){return n(e.prepare("SELECT \nm.tbl_name as tableName,\np.*\nFROM sqlite_master AS m\nJOIN pragma_table_info(m.name) AS p\nORDER BY m.tbl_name, p.cid").all())}},9508:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withDb=t.withDbSync=void 0;const r=i(80632),s=i(28874),n=i(30301),a=i(54993);t.withDbSync=function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const o=(0,n.lazy)((()=>(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i})));try{return t((function(){const e=o();return e.open?e:o.refresh()}))}finally{o.prior()?.close()}},t.withDb=async function(e,t,i=s.Settings.dbBusyTimeoutMs.valueOrDefault){const n=(0,r.mkdb_)({nativePath:(0,a.toS)(e),timeoutMs:i});try{return await t(n)}finally{n.close()}}},74085:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dbModelHealthCheck=void 0;const r=i(77740),s=i(98314),n=i(18454),a=i(28874),o=i(82950),l=i(42659),u=i(45599),c=i(64526),d=i(16185),h=i(45648),f=i(31687),m={text:"Attempt database repair",title:"Run a dump and reload of your library database to try to repair it",type:"button",method:"POST",url:"/admin/repair-db",icon:"database"};t.dbModelHealthCheck=(0,u.defer)((()=>{const e=n.HealthCheck.for({section:"Library",id:"library-db",ordinal:1,pendingMsg:"Checking library database…",settings:["libraryDir","forceLocalDbReplica"],timeoutMs:()=>10*a.Settings.dbMaintenanceTimeoutMs.valueOrDefault,ttlMs:l.minuteMs,onReset:()=>(0,h.clearDbSetupErrors)({notifyListeners:!1}),links:[{text:"Read about PhotoStructure and SQLite",icon:"docs",url:"https://forum.photostructure.com/t/whats-ps-force-local-db-replica/837"}],later:async()=>{const e=await(c.Library.instance()?.ready);if(null==e)return{level:"disabled",msg:["Library database tests disabled: no library is open"]};let t,i=!1;try{const s=Date.now();if(i=!1,(0,h.hasDbSetupErrors)())return{level:"error",msg:["Something is wrong with your library database.",(0,o.li)((0,h.dbSetupErrors)())],links:[m]};if(t=await e.modelDb(),(0,r.getDevEnvFlag)("PS_FAIL_DB_HEALTH_CHECK"))throw new Error("PS_FAIL_DB_HEALTH_CHECK");await(0,d.assertValidDbSchema_)(t),i=!0,await t.verify_(),await t.vacuum(),f.Heartbeat.assertPing_();const n=await e.dbModelSetup_();return{level:"ok",msg:["Library database is OK",(0,o.li)(["Schema validation, vacuum, optimize, and upsert round-trip took "+(Date.now()-s)+"ms","Live db is "+(0,o.tt)(t.dbFile.nativePath),"Local replica mode is "+(0,o.tt)(n.useReplica),n.useReplica?"Cold library db is "+(0,o.tt)(n.libraryDbFile):void 0])]}}catch(r){return{level:"error",msg:["Library database validation failed",(i?"":"Unrecoverable: ")+(0,s.errorToS)(r),null==t?void 0:"Live db is "+(0,o.tt)(t.dbFile.nativePath),null==e?void 0:"Local replica mode is "+(0,o.tt)(await e.useReplica())],links:i?[m]:void 0}}}});return(0,h.addDbSetupErrorListener)((()=>e.refresh())),e}))},8400:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryHealthCheckSetup=void 0;const r=i(19851),s=i(88625),n=i(2858),a=i(74085),o=i(1991),l=i(40549);t.libraryHealthCheckSetup=(0,r.lazy)((async()=>{await(0,n.readSettings)(),(0,s.healthCheckSetup)(),(0,o.syncHealthCheck)(),(0,a.dbModelHealthCheck)(),(0,l.volumeUuidHealthCheck)()}))},1991:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syncHealthCheck=void 0;const r=i(48884),s=i(50213),n=i(95696),a=i(62105),o=i(18454),l=i(2858),u=i(40958),c=i(82950),d=i(45599),h=i(94019),f=(0,d.defer)((()=>(0,s.mkLogger)("health.SyncHealthCheck")));t.syncHealthCheck=(0,d.defer)((()=>o.HealthCheck.for({section:"Library",id:"library-nothing-to-sync",ordinal:99,settings:["scanAllDrives","scanPaths","scanLibraryFirst","scanLibraryLast"],pendingMsg:"Checking synced directories…",later:async()=>{if(!(0,l.libraryHasSettings)())return{level:"disabled",msg:"Library sync paths test disabled: no library is open"};const e=(await(0,h.pathsToSync)()).map((e=>e.nativePath));if((0,u.isEmpty)(e))return{level:"warn",msg:"No paths are configured to scan\n"+(0,c.li)([(0,c.tt)("PS_SCAN_ALL_DRIVES")+" is false",(0,c.tt)("PS_SCAN_PATHS")+" is empty","both "+(0,c.tt)("PS_SCAN_LIBRARY_FIRST")+" and "+(0,c.tt)("PS_SCAN_LIBRARY_LAST")+" are false"]),links:[{text:"Read more",url:"https://photostructure.com/go/nothing-to-scan"}]};{const t=e.map((e=>n.PosixFile.for(e)));return f().info("Checking if any paths are empty",{posixFiles:t}),null==await(0,r.findAsync)(t,(async e=>null!=await e.someDescendant((e=>e.isDirectorySync()||(0,a.acceptParentAndFileAndSimple)(e)),1)))?{level:"warn",msg:["No eligible files found in scanned paths","Checked paths:",(0,c.li)(e.map(c.tt))],links:[{text:"Read more",url:"https://photostructure.com/go/nothing-to-scan"}]}:{level:"ok",msg:["At least one directory with eligible files is configured to be synced","Checked paths:",(0,c.li)(e.map(c.tt))]}}}})))},40549:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.volumeUuidHealthCheck=void 0;const r=i(50213),s=i(56519),n=i(18454),a=i(28874),o=i(2858),l=i(85087),u=i(63870),c=i(86848),d=i(7014),h=i(40958),f=i(82950),m=i(45599),p=i(57924),g=i(23838),y=i(68708),v=i(94019),w=(0,m.defer)((()=>(0,r.mkLogger)("health.VolumeUUIDHealthCheck")));t.volumeUuidHealthCheck=(0,m.defer)((()=>n.HealthCheck.for({section:"Library",id:"volume-uuids",pendingMsg:"Checking volumes…",settings:["scanAllDrives"],links:[{text:"What's a “volume”?",url:"https://photostructure.com/faq/what-is-a-volume/",icon:"docs"}],later:async()=>{if(!(0,o.libraryHasSettings)())return{level:"disabled",msg:"Volume UUID test disabled: no library is open"};const e=[],t=[];if(a.Settings.scanAllDrives.valueOrDefault)e.push(...await(0,d.volumes)());else{const i=await(0,v.scanPaths)(),r=await(0,s.mapAsyncSerial)({name:"scannedVolumes",arr:i.result.map((e=>e.nativePath)),f:e=>(0,d.bestVolumeForPath)(e),timeoutMs:(0,u.commandTimeoutMs)()});e.push(...(0,h.uniqBy)(r,(e=>e.mountpoint))),t.push(...i.noUriPaths)}const i=[...(0,g.groupBy)(e,(e=>e.uuid)).values()].filter((e=>e.length>1)),r=e.filter((e=>null==e.uuid&&!(0,c.volumeUuidNotExpected)(e))).map((e=>e.mountpoint)),n=(await(0,d.volumes)()).filter((e=>!1===e.ok)).map((e=>(0,h.compactBlanks)([e.mountpoint,e.status]).join(": ")));if(w().debug("volumeHealthCheck result",{missingUUIDs:r,noUriPaths:t,unhealthyVolumes:n,scannedVolumes:e.map((e=>(0,y.pick)(e,"uuid","mountpoint")))}),(0,h.isEmpty)(r)&&(0,h.isEmpty)(i)&&(0,h.isEmpty)(t)&&(0,h.isEmpty)(n))return(0,h.isEmpty)(e)?{msg:["No volumes need UUIDs",(0,f.tt)(a.Settings.scanAllDrives.key)+" is false, and no volumes other than the library are configured to be scanned."],level:"ok"}:{msg:["All scanned volume UUIDs are OK",(0,f.li)(e.map((e=>(0,f.tt)((0,l.volsha)(e.uuid)+" → "+e.mountpoint))))],level:"ok"};{const e=[];return(0,h.isEmpty)(n)||e.push("Some volumes are unhealthy",(0,f.li)(n.map((e=>(0,f.tt)(e))))+"PhotoStructure may crash or hang when accessing unhealthy volumes."),(0,h.isEmpty)(r)||e.push("Some volumes are missing UUIDs",(0,f.li)(r.map((e=>(0,f.tt)(e)))),"This can cause problems with deduplication and library portability."),(0,h.isEmpty)(i)||e.push("Some volumes have duplicate UUIDs",i.map((e=>(0,f.li)((0,p.andList)(e.map((e=>(0,f.tt)(e.mountpoint))))+" share UUID "+(0,f.tt)(e[0].uuid)))).join("\n---\n"),"This can cause problems with deduplication and library portability."),(0,h.isEmpty)(t)||e.push("Some paths failed to have URIs generated",(0,f.li)(t.map((e=>(0,f.tt)(e)))),"This will prevent these paths from being imported."),{level:"warn",msg:e.join("\n---\n"),links:[{text:"How to manually add a UUID",icon:"handyman",url:"https://photostructure.com/faq/what-is-a-volume/#add-uuid"},{text:"Rescan volumes",type:"button",method:"POST",url:"/admin/clear-caches",icon:"refresh"}]}}}})))},43487:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Asset=void 0;const u=i(48884),c=i(19851),d=i(50213),h=i(88158),f=i(45393),m=i(56519),p=i(89724),g=i(38835),y=i(74128),v=i(79847),w=i(28874),b=i(47783),S=i(38010),P=i(40958),_=i(76790),T=i(75761),M=i(38639),E=i(11371),k=i(98553),D=i(55835),x=i(31586),C=i(20214),F=i(59455),A=i(64526),I=i(4407),O=i(54017),L=i(48722),R=i(37094),N=i(45295),B=i(39604),j=i(48723),z=i(41507),V=i(72761),W={"Asset.shown":1,"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null};class U extends V.TimestampedModel{constructor(){super(...arguments),r.add(this),this.attrs={},this.assetIdish=(0,c.lazy)((()=>({assetId:this.id,v:this.updateCount,capturedAtLocal:this.capturedAtLocal}))),this.mergedTags=(0,c.lazy)((async()=>{const e=[];for(const t of this.getAssetFiles()){const i=await t.posixFile(),r=await(0,b.readTags)(i),s=await(i?.mtimeMs());null!=i&&null!=r&&null!=s&&e.push({...r,SourceFile:i.nativePath,sourceModifiedTime:s,sourceIsPrimary:(0,M.isTrue)(t.shown)})}const t=R.AssetRevision.ops().allf((e=>e.where({assetId:this.id}))),i=new S.MergedTags("Asset:"+this.id);return i.addTag(...e,...this.assetFiles),i.addRevision(...t),i}))}static shownUnhidden(e){return null==e?s.query().where(W):e.andWhere(W)}static findUnhiddenById(e){return(0,x.gt0)(e)?s.ops().firstf((t=>s.shownUnhidden(t.where({id:e})))):void 0}static shownRemovable(e,t){return(t??s.query()).whereNotNull(e).andWhere({"Asset.shown":1})}static shownCount(){return s.ops().count(s.shownUnhidden().countDistinct("Asset.id"))}static deletePreviews(e){return A.Library.instance().previews().ap(e).deleteAll()}static async remove({assetId:e,blocklistShas:t,unlinkAssetFiles:i}){const r=(0,d.mkLogger)("Asset("+e+").remove()"),n=s.ops().findById(e);if(null==n)return void r.warn("asset not found");const a=n.isActive(),o=n.tagIds();r.info("starting",{unlinkAssetFiles:i});const l=n.getAssetFiles({refresh:!0});if(t){(0,B.upsertToShaBlockslist)(...l.map((e=>e.sha)));for(const e of l)(0,y.syncReport)().onProgress({from:"Asset.remove",path:await e.getNativePath()??e.uri,state:"blocklisted",details:"sha blocklisted (files with the same sha will not be imported)"})}N.AssetTag.dbl.runf((t=>t.delete().where({assetId:e}))),O.AssetFile.dbl.runf((t=>t.delete().where({assetId:e}))),R.AssetRevision.dbl.runf((t=>t.delete().where({assetId:e}))),s.dbl.runf((t=>t.delete().where({id:e}))),a&&j.Tag.deltaAssetCountAndAncestors(o,-1);try{await s.deletePreviews(e)}catch(e){r.error("Failed to delete previews",{error:e})}return{deletedMeta:i?await(0,v.trashOrUnlinkFileUris_)(l):[],assetFileMeta:l}}static nextOutdated(e=h.identity){return this.ops().findOne(e(l(this,s,"m",n).call(this)))}static nextOutdateds(e){return this.ops().all(e(l(this,s,"m",n).call(this)))}static outdatedCount(e=h.identity){return this.dbl.pluckFirst(e(l(this,s,"m",n).call(this)).count())}static findFirstByFile(e){return this.ops().findOne(e(this.query().select("Asset.*").join("AssetFile","AssetFile.assetId","Asset.id")))}static unshownAssetIds(){return this.dbl.pluckAll("\n SELECT DISTINCT af1.assetId\n FROM AssetFile af1\n LEFT JOIN (SELECT DISTINCT assetId FROM AssetFile WHERE shown = 1) AS af2 \n ON af1.assetId = af2.assetId\n WHERE af2.assetId IS NULL")}static archive(e){null!=s.ops().findById(e)&&(N.AssetTag.dbl.runf((t=>t.where({assetId:e}).delete())),O.AssetFile.dbl.runf((t=>t.where({assetId:e}).delete())),s.dbl.runf((t=>t.where({id:e}).delete())))}markUnshownAndUpsert(){this.shown=!1,this.version=f.AssetVersion,this.upsert()}markShownAndUpsert_(e){const t=this.getShown()?.id;if(null!=e){const t=e.shown;this.setShown_(e,{skipUpsert:!0}),!0!==t&&e.upsert()}this.shown=!0,this.version=f.AssetVersion,t!==this.getShown()?.id&&(this.updateCount=(this.updateCount??0)+1),this.upsert()}async updateFromFiles(){const e=await this.mergedTags();(0,D.map)(e.get("rating"),(e=>{this.logger().info("updateFromFiles()",{rating:e}),this.rating=e.value}))}isActive(){return(0,x.gt0)(this.id)&&!0===this.shown&&null==this.excludedAt&&null==this.deletedAt&&(null==this.rating||(0,x.gte)(this.rating,w.Settings.rejectRatingsLessThan.valueOrDefault))}toAssetId(){return(0,L.toAssetId)(this)}renderCaption(e){return(0,D.map)(this.capturedAtLocal,(t=>"Taken "+(0,p.fmtLocalDateShort)(t,e)))}async whenApiTag(){const e=(0,I.dateTag)((0,p.localToDateObject)(this.capturedAtLocal));return null==e?void 0:j.Tag.findOrCreate(e).toApiTag()}findAssetFileByUri(e){return this.getAssetFiles()?.find((t=>t.uri===e))}addAssetFile(e){(0,P.filterInPlace)(e.asset?.assetFiles??[],(t=>!(t.id===e.id||t.uri===e.uri))),e.assetId=this.id,e.asset=this,e.shown=!1,this.getAssetFiles().push(e),this.clear(),this.capturedAtLocal??(this.capturedAtLocal=e.capturedAtLocal),this.rating??(this.rating=e.rating),this.durationMs??(this.durationMs=e.durationMs)}async assetFileForFile_(e,t){const i=await e.uri();if(null==i)return this.logger().throw("assetFileForFile_(): null uri",{f:e});const r=this.getAssetFiles().find((e=>e.uri===i));if(null!=r)return r;const s=new O.AssetFile;return this.addAssetFile(s),!0!==t?.skipUpsert?await s.upsertIfNeeded_(e):await s.setFile_(e),s}static getTags(e){return j.Tag.ops().all(j.Tag.query().select("Tag.*").join("AssetTag","AssetTag.tagId","Tag.id").where("AssetTag.assetId",e).orderByRaw("COALESCE(Tag.ordinal, Tag._path)"))}tagIds(e){return!0===e?.refresh&&(this.tags=void 0),this.tags?.map((e=>e.id))??N.AssetTag.dbl.pluckAllf((e=>e.select("tagId").where({assetId:this.id})))}getTags(e){return!0===e?.refresh&&(this.tags=void 0),this.tags??(this.tags=s.getTags(this.id))}tagPaths(){return this.getTags().map((e=>e.path.join("/"))).sort()}setTagIds(e){const t=this.tagIds({refresh:!0});if((0,u.eqlUnordered)(t,e))return void this.logger().debug("setTagIds(): no-op, tagIds unchanged");const i=e.filter((e=>!t.includes(e))),r=t.filter((t=>!e.includes(t)));return this.applyTagIdDeltas({tagIdsToAdd:i,tagIdsToRemove:r})}applyTagPathDeltas(e){return this.applyTagIdDeltas({tagIdsToAdd:j.Tag.findOrCreateByPathN(e.add??[]).map((e=>e.id)),tagIdsToRemove:j.Tag.findByPathN(e.remove??[]).map((e=>e.id))})}applyTagIdDeltas(e={}){const t=this.tagIds({refresh:!0}),i=(0,P.uniq)((0,F.toA)(e.tagIdsToAdd).filter((e=>(0,x.gt0)(e)&&!t.includes(e)))),r=(0,P.uniq)((0,F.toA)(e.tagIdsToRemove).filter((e=>(0,x.gt0)(e)&&t.includes(e))));if((0,P.isEmpty)(i)&&(0,P.isEmpty)(r))return this.logger().info("applyTagIdDeltas(): no-op, no changes",{currentTagIds:t,...e}),t;this.isActive()&&j.Tag.deltaAssetCountAndAncestors(t,-1),(0,P.isEmpty)(i)||N.AssetTag.dbl.runf((e=>e.insert(i.map((e=>({assetId:this.id,tagId:e})))).onConflict(["assetId","tagId"]).ignore())),(0,P.isEmpty)(r)||N.AssetTag.dbl.runf((e=>e.whereIn("tagId",r).andWhere({assetId:this.id}).delete())),this.tags=void 0;const s=(0,P.uniq)([...t,...i]).filter((e=>!r.includes(e)));return this.isActive()&&j.Tag.deltaAssetCountAndAncestors(s,1),s}getStreams(e){if(null==this.streams){const t=this.getTags();this.logger().info("getStreams(): fetched tags "+t,{limit:e});const i=t.map((t=>t.getAssetStream(this,e)));this.streams=(0,z.coalesceStreams)((0,P.compact)(i));for(const e of this.streams)for(const t of e.tags)t.getAncestors()}return this.streams}getBeforeAfterId(){const e=s.dbl.all(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",this.capturedAtLocal).orderBy("assetId"));this.afterId=e.find((e=>e.assetId>this.id)),this.beforeId=e.reverse().find((e=>e.assetIde.path))}getAssetFiles({refresh:e=!1}={}){return null!=this.id&&(e&&(this.assetFiles=void 0),this.assetFiles??(this.assetFiles=(0,_.sortBy)(O.AssetFile.ops().findBy({assetId:this.id}),(e=>[!(0,M.isTrue)(e.shown),-e.mtime])))),this.assetFiles??[]}setShown_(e,t){e instanceof O.AssetFile&&(this.getAssetFiles(),this.assetFiles?.some(((t,i)=>{const r=t.id===e.id||t.uri===e.uri;return r&&(this.assetFiles[i]=e),r})));const i=e instanceof O.AssetFile?e.id:e;if(this.getShown()?.id===i)return void this.logger().debug("setShown_(): no-op, already set",{afId:i});this.logger().info("setShown_()",{assetId:this.id,assetFileId:i}),(0,x.gt0)(this.id)&&(0,x.gt0)(i)||this.logger().throw("setShown_(): invalid IDs: "+(0,k.stringify)({assetId:this.id,assetFileId:i})+g.InternalErrorFlag);const r=Date.now();O.AssetFile.dbl.runf((e=>e.update({shown:0,updatedAt:r}).where({assetId:this.id}))).changes<=0&&this.logger().warn("setShown_(): all asset files were already unshown",{afId:i});const s=O.AssetFile.dbl.runf((e=>e.update({shown:1,updatedAt:r}).where({id:i})));1!==s.changes&&this.logger().throw("setShown_(): failed to update asset file: unexpected changed rows",{runResult:s});const n=this.assetFiles?.find((e=>e.id===i))??this.getAssetFiles({refresh:!0}).find((e=>e.id===i));if(null!=n){this.capturedAtLocal=n.capturedAtLocal,this.rating=n.rating,this.durationMs=n.durationMs;for(const e of this.assetFiles??[])e.shown=e.id===i;!0!==t?.skipUpsert&&this.upsert()}else this.logger().throw("setShown_(): failed to find shown asset file",{af:e})}getShown(e){return this.getAssetFiles(e)?.find((e=>(0,M.isTrue)(e.shown)))??this.getAssetFiles({refresh:!0})?.find((e=>(0,M.isTrue)(e.shown)))}getShownNativePath(){return this.getShown()?.getNativePath()}async getCapturedAts(){return(0,C.thenCollect)(this.getAssetFiles(),(e=>e.capturedAt()))}link(){return"/asset/"+this.id}sqAttrs(e=!0){return{...(0,T.assetSqImgAttrs)({assetId:this.assetIdish(),lazyLoad:e}),title:this.renderCaption(),...this.attrs}}async getImgAttrs(e,t,i=!1){if(null==this.imgAttrs&&(this.imgAttrs=new Map),null==this.imgAttrs.get(t)){const r=e.ap(this.id);await(0,m.thenMap)(r.readInfo(),(async e=>{e.mimetype.startsWith("video/")&&(this.poster=await r.posterLink())}));const s=!0;this.imgAttrs.set(t,await r.imgAttrs(t,s,i))}return this.imgAttrs.get(t)}async fitAttrs(e){return{...await this.getImgAttrs(e,E.ReducerNames.fit),...this.attrs}}isVideo(){if(null==this.assetFiles)throw new Error(".video called before getFiles()");return this.assetFiles.some((e=>e.isVideo))}videoAttrs(){return{controls:!0,autoplay:!0,poster:this.poster,...this.attrs}}async videoSources(){const e=[];let t;for(const i of this.getAssetFiles())e.some((e=>e.type===i.mimetype))||await i.exists()&&(t??(t=i),e.push({src:(0,T.assetVideoLink)({assetId:this.assetIdish(),assetFileId:i.id}),type:i.mimetype}));return e.some((e=>"video/mp4"===e.type))||null==t||e.unshift({src:(0,T.assetVideoLink)({assetId:this.assetIdish(),assetFileId:t.id})+".mp4",type:"video/mp4"}),e}async getPosixFiles(){return(0,C.thenCollect)(this.getAssetFiles(),(e=>e.posixFile_()))}async getExistingAssetFiles(){return(0,m.filterAsync)({name:"getExistingAssetFiles",arr:this.getAssetFiles(),f:e=>e.exists()})}async findOrCreateByFile(e){const t=await e.uri_();if(null==t)return;const i=(0,F.toA)(O.AssetFile.ops().findBy({assetId:this.id,uri:t}))[0];return(0,D.orElse)(i,(async()=>{const t=new O.AssetFile;return t.asset=this,t.assetId=this.id,await t.setFile_(e),t}))}partialSimpleAsset(){return{assetId:this.id,liked:(0,x.gte)(this.rating,w.Settings.likeRating.valueOrDefault),hidden:(0,M.isTrue)(this.hidden),excluded:null!=this.excludedAt,deleted:null!=this.deletedAt}}clear(){return this.imgAttrs=void 0,this.streams=void 0,this.tags=void 0,this.mergedTags.unset(),this}}t.Asset=U,s=U,r=new WeakSet,n=function(){return s.shownUnhidden().andWhere("version","<",f.AssetVersion)},a=function(){return this.beforeId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal","<",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId",order:"desc"}]))},o=function(){return this.afterId=s.dbl.first(s.shownUnhidden().clearSelect().select({assetId:"id",v:"updateCount"}).andWhere("capturedAtLocal",">",this.capturedAtLocal).orderBy([{column:"capturedAtLocal",order:"asc"},{column:"assetId",order:"asc"}]))},U.$tableName="Asset",U.$uniqueColumnName="id",U.$booleanFields=["shown","hidden"]},54017:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFile=void 0;const a=i(76760),o=i(19851),l=i(88158),u=i(45393),c=i(68852),d=i(81168),h=i(13991),f=i(54296),m=i(56519),p=i(76490),g=i(89724),y=i(98314),v=i(38835),w=i(8769),b=i(29882),S=i(95696),P=i(62105),_=i(74128),T=i(35721),M=i(69589),E=i(28874),k=i(28544),D=i(16170),x=i(45200),C=i(34238),F=i(87001),A=i(42233),I=i(21404),O=i(40958),L=i(17586),R=i(22573),N=i(38639),B=i(42659),j=i(33374),z=i(50357),V=i(75240),W=i(11371),U=i(55835),q=i(31586),H=i(68708),$=i(34666),G=i(89937),J=i(75020),K=i(64526),Y=i(41844),X=i(43487),Z=i(48723),Q=i(94710),ee=i(72761);class te extends ee.TimestampedModel{constructor(){super(...arguments),r.add(this),this.uriObj=(0,o.lazy)((()=>C.URI.parse(this.uri))),this.whyRejected=(0,o.lazy)((async()=>{const e=await this.posixFile_();return null==e?"invalid URI":!0===await this.isFileDeleted()?"deleted":(0,P.whyRejectFile)(e)})),this.posixFile_=(0,o.lazy)((async()=>S.PosixFile.for(await this.getNativePath())))}static outdatedQuery(e){let t=(e.q??this.query()).where("version","<",u.AssetFileVersion);return null!=e.maxUpdatedAt&&(t=t.andWhere("updatedAt","<",e.maxUpdatedAt)),t.andWhere((t=>{(0,O.isNotEmpty)(e.mountpoints)&&(t=t.whereIn("mountpoint",e.mountpoints));for(const i of e.uris)t=t.orWhereLike("uri",i+"%");return t})).orderBy("id")}static async nextOutdated(e=l.identity){return this.ops().findOne(e(this.outdatedQuery(await(0,A.currentVolumeRoots)())))}static async outdatedCount(e=l.identity){const t=this.outdatedQuery(await(0,A.currentVolumeRoots)());return this.dbl.pluckFirst(e(t.count("id")))}static shownAssetFileId(e){return this.dbl.pluckFirstf((t=>t.where({assetId:e,shown:1}).limit(1)))}static primaryForAssetId(e){return(0,q.gt0)(e)?te.ops().first(X.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id").select("AssetFile.*").where({assetId:e,"AssetFile.shown":1})):void 0}static shownUnhidden({uriRoot:e}={}){let t=X.Asset.shownUnhidden().join("AssetFile","AssetFile.assetId","Asset.id");return(0,R.blank)(e)||(t=t.andWhereLike("AssetFile.uri",e+"%")),t}static recentAssetIdsByUriRoot(e,t,i=64){const r=Date.now()-t;return this.dbl.pluckAll(te.shownUnhidden({uriRoot:e}).distinct("AssetFile.assetId").where("AssetFile.updatedAt",">",r).orderBy("AssetFile.updatedAt","desc").limit(i))}static assetFileCountByMimeType(e){const t=te.shownUnhidden({uriRoot:e}).select("mimetype").countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"}).groupBy("mimetype").orderBy("mimetype");return this.dbl.all(t)}static assetFileCountWithMimeType(e,t){let i=te.shownUnhidden({uriRoot:t}).countDistinct({assetFileCount:"AssetFile.id",assetCount:"Asset.id"});return i=e.endsWith("/")?i.andWhereLike("mimetype",e+"%"):i.andWhere("mimetype",e),this.dbl.first(i)}static assetFileCountByMimeTypeRoots(e=["image/","video/"],t){return e.map((e=>({mimeTypeRoot:e,assetFileCount:te.assetFileCountWithMimeType(e,t)?.assetFileCount??0})))}static children(e,t){const i=this.query().whereLike("uri",e+"/%").andWhere("uri","regexp",`^${(0,c.escapeRegExp)(e)}/[^/]+$}`);return this.ops().all(null==t?i:t(i))}static async sameShaInLibrary(e){if(null==this.db())return;const t=await e.sha(),i=await e.size();return null!=t&&null!=i?this.ops().allf((e=>e.where({sha:t,fileSize:i}).andWhereLike("uri",G.PS_LIBRARY_PROTOCOL+"%"))):void 0}static sameAssetFileInLibrary(e){return this.ops().allf((t=>t.where((0,H.pick)(e,"sha","fileSize")).andWhere((e=>e.whereLike("uri",G.PS_LIBRARY_PROTOCOL+"%"))).andWhere((t=>t.whereNot({id:e.id})))))}librarySiblings(){return this.getAsset()?.getAssetFiles().filter((e=>e.id!==this.id&&e.uri.startsWith(G.PS_LIBRARY_PROTOCOL)))}capturedAtLocale(e){return(0,g.fmtLocalDateShort)(this.capturedAtLocal,e)}get dominantColors(){return p.DominantColor.fromModeData(this)}set dominantColors(e){(0,H.assignAllFields)(this,p.DominantColor.toModeData(e))}get posixPathFromGrandparent(){return(0,U.map)(this.uriObj()?.fsPath,b.posixPathFromGrandparent)}async whyNotMatchesFile(e){const t=n(this,r,"m",s).call(this);if(null!=t)return t;if(null==this.fileSize||null==this.mtime)return"missing file metadata";if(null!=e){const t=await e.uri();if(null==t)return"file has no URI";if(!await(0,F.uriIsEquivalent)(this.uri,t))return"file URI mismatch"}try{const t=e??await this.posixFile_();if(!await t.exists())return"file is missing";const i=await this.fileFields_(t);return null==i?!0===await(t?.isDeleted())?"file is deleted":"file is unreadable":i.fileSize!==this.fileSize?"file size changed since last sync":(0,q.closeTo)(i.mtime,this.mtime,2*B.secondMs)?void 0:"file mtime changed since last sync"}catch(e){return(0,y.errorToS)(e)}}async matchesFile(e){const t=await this.whyNotMatchesFile(e);return this.logger().tap({level:"info",msg:"matchesFile()",result:null==t,meta:{whyNot:t}})}async whyNotInSyncWithFile(e){return E.Settings.forceSync.valueOrDefault?E.Settings.forceSync.key+"=true":this.version!==u.AssetFileVersion?"AssetFileVersion: "+this.version+" != "+u.AssetFileVersion:this.whyNotMatchesFile(e)}async inSyncWithFile(e){const t=await this.whyNotInSyncWithFile(e);return this.logger().tap({msg:"inSyncWithFile()",result:null==t,meta:{whyNotInSync:t}})}async fileFields_(e){const t=e??await this.posixFile_();return null==t?void 0:await(0,h.assetFileStatFields_)(t)}isInLibrary(){return this.uri.startsWith(G.PS_LIBRARY_PROTOCOL)}async isNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){const t=await this.whyNotNoop(e);return this.logger().tap({msg:"isNoop()",result:null==t,meta:{whyNotNoop:t}})}async whyNotNoop(e={forceSync:E.Settings.forceSync.valueOrDefault}){if(!0===e.forceSync)return"forceSync is true";if(!(0,q.gt0)(this.id))return"missing .id";if(!(0,q.gt0)(this.assetId))return"missing .assetId";{const e=await this.whyNotInSyncWithFile();if(null!=e)return e}if(await(0,Y.mayCopyAssetsToLibrary)()){const e=K.Library.instanceRequired_().assetFileRepository(),t=e.whyNotCopyFile(await this.posixFile_());if((0,R.blank)(t)&&null==await e.existingLibraryAssetFile(this))return"need to copy into library"}this.syncState=_.AssetFileSyncStates.noop}isVersionUpToDate(){return(0,$.gte)(this.version,u.AssetFileVersion)}async siblingCount(){return te.dbl.pluckFirstf((e=>e.count().where({assetId:this.assetId}).andWhereNot({id:this.id})))}async upsertIfNeeded_(e,t=(0,M.forceContextOrSetting)()){if(null!=e&&await this.setFile_(e),await this.matchesFile()&&(0,q.gt0)(this.id)&&!t.forceSync)return void(null==this.syncState&&(this.upsert(),this.syncState??(this.syncState=_.AssetFileSyncStates.noop)));const i=await this.isFileDeleted();if(!0===i)return this.syncState=_.AssetFileSyncStates.deleted,this.delete(),!0!==t.skipAssetRepair&&Q.Task.addOne("repairAsset",{assetId:this.assetId}),this;if(!1===i){const i=await this.updateFromFile_(e,t);return this.syncState??(this.syncState=null==i?_.AssetFileSyncStates.noop:_.AssetFileSyncStates.synced),this.upsert()}return this.syncState??(this.syncState=_.AssetFileSyncStates.skipped),this}async updateFileFields_(e){(0,H.assignFields)(this,await this.fileFields_(e))}async updateFromFile_(e,t=(0,M.forceContextOrSetting)()){const i=Date.now(),r=this.logger().addContext(".updateFromFile_()");if(null!=this.id&&!0!==t.forceSync&&await this.matchesFile(e))return void r.info("updateFromFile() no-op: up-to-date version and file stat matches since last update");if(null!=e&&await this.setFile_(e),null==e&&(e=await this.posixFile_()),null==e||await e.clear().notExists())return this.syncState=_.AssetFileSyncStates.deleted,void r.info("no-op, "+e+" is missing");const s=await(0,h.mkAssetFile_)(e);return s.uri!==this.uri&&((0,R.blank)(this.uri)||!0===this.uri?.startsWith("file:"))&&(this.logger().warn("updateFromFile() upgrading uri",{prior:this.uri,new:s.uri}),this.uri=s.uri),(0,H.assignAllFields)(this,(0,H.omit)(s,"uri")),this.version=u.AssetFileVersion,this.syncState=_.SyncFileStates.synced,r.elapsed("finished",Date.now()-i,this.toJSON()),this}async updateFromShaSibling_(e){const t=n(e,r,"m",s).call(e);if(null==t){if(await this.exists())return this.logger().debug("updateFromShaSibling",e),null!=e.sha&&await e.matchesFile()&&this.sha===e.sha?((0,H.assignFields)(this,(0,H.omit)(e,"id","posixFile","uriObj","shown","uri","mtime","fileSize","mountpoint","createdAt","updatedAt","updateCount",...te.$transientFields)),this.updateFileFields_()):this.updateFromFile_();this.logger().warn("updateFromShaSibling(): fail: file is missing")}else this.logger().warn("updateFromShaSibling() sibling is invalid",{whySiblingIsInvalid:t})}getAsset(){return this.asset??(this.asset=(0,q.gt0)(this.assetId)?X.Asset.ops().findById(this.assetId):void 0)}exists(){return(0,x.uriExists)(this.uri,this.mountpoint)}async isFileDeleted(){return(await this.posixFile_())?.isDeletedUri(this.uri)}async accepted(){return(0,R.blank)(await this.whyRejected())}async setFile_(e){const t=await e.uri_();if(null==t)return this.logger().throw("setFile(): no URI for "+e);const i=await e.mountpoint();if(null!=this.uri&&!await(0,F.uriIsEquivalent)(t,this.uri))return this.logger().throw("setFile(): cannot reassign non-equivalent URI",{prior:this.uri,new:t,file:e.nativePath});const r=await e.uriObject_();return null==r?this.logger().throw("failed to create URI for "+e):(this.uri=t,this.uriObj.set(r),this.mountpoint=i?.nativePath,this.nativePath=e.nativePath,this.posixFile_.set(Promise.resolve(e)),this)}get basename(){return(0,R.blank)(this.uri)?void 0:decodeURIComponent(this.uri.slice(this.uri.lastIndexOf("/")+1))}posixFile(){return this.posixFile_().catch((()=>{}))}async getNativePath(){return(0,R.blank)(this.nativePath)&&(null==this.uri?this.logger().error(".getNativePath() called before .setFile_()"+v.InternalErrorFlag):this.nativePath=await(0,f.getAssetFileNativePath)(this)),this.nativePath}async capturedAt(){return null==this.nativePath&&await this.getNativePath(),k.CapturedAt.fromAssetFile(this)}async originalDownloadable({brief:e=!1}={}){const t=this.basename;if(!0===e)return null==t?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:`Download ${t}`,basename:t,description:"Download original"};const i=await this.posixFile_();return this.logger().tap({msg:"originalDownloadable()",level:"info",result:null==i||await i.isEmpty()?void 0:{href:`/dl/${this.assetId}/${this.id}`,size:"original",title:e?`Download ${i.base}`:(0,T.mkDownloadableTitle)(i,"original",this.isVideo?"video":"image",{width:this.width,height:this.height}),basename:i.base,description:"Download original",details:`(${(0,j.fmtDim)(this)} ${i.ext})`},meta:{posixFile:i}})}async downloadables(e,t){try{const i=await this.posixFile_();if(null==i)return[];const r=e.ap(this.assetId),s=[];if(await(0,m.thenMap)(this.originalDownloadable(),(e=>s.push(e))),this.isVideo)return s;if(!(0,N.isTrue)(this.shown)&&this.sha!==t)return s;const n=(0,O.compact)(await Promise.all([...await r.previewInfos()].reverse().filter((e=>e.reducer===W.ReducerNames.fit)).map((e=>(0,T.previewToDownloadable)(i.base,e)))));return s.push(...(0,O.uniqBy)(n,(e=>e.size))),s}catch(e){return(0,w.onError)("AssetFile.downloadables failed for "+this.uri,e),[]}}async pathInfo(){try{const e=C.URI.parse(this.uri),t=(0,U.map)((0,I.uriToTagPath)({uri:e,isFile:!0}),(e=>Z.Tag.findByPath(e)));return this._pathInfo_(await(t?.toApiPathElements()))}catch(e){return void this.logger().warn("pathInfo(): failed",e)}}async _pathInfo_(e){const t=await this.posixFile_();if(null==t)return this.logger().throw("pathInfo(): no posixFile",{uri:this.uri});const i=t.nativePath,r=C.URI.parse(this.uri),s=await t.exists();if(null==e||(0,O.isEmpty)(e))return this.logger().warn("pathInfo(): failed to find existing Tag. Returning a simple path.",{uri:this.uri,nativePath:i,tagLineage:e}),{nativePath:i,pathElements:[],nativePathSuffix:i,pathSep:a.sep,exists:s};function n(){return(0,L.at)((0,L.at)(e,-1)?.tagPath,-1)}(0,z.eql)(e[0]?.tagPath,[J.TagRoots.fs])&&(e=e.slice(1));const o=r.scheme===G.PS_LIBRARY_SCHEME,l=o?r.path.split("/").slice(1):t.pathnames,u=l.pop(),c=[];for(;l.length>0&&(0,d.equalsIgnoreCase)(n(),(0,L.at)(l,-1));){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("added matching tag",t)}if(o&&n()===J.LibraryTagName){l.pop();const t=e.pop();c.unshift(t),this.logger().debug("pslib: added matching library tag",t)}if(r.scheme===G.PS_LOCAL_FILE_SCHEME){const t=C.URI.parse(this.uri).authority;if(this.logger().debug("psfile: pop last?",{lastTagName:n(),thisVolSha:t}),n()===t){l.pop();const t=e.pop();c.unshift(t)}else this.logger().warn("weird: I expected to be able to include the volsha tag element, but it doesn't seem to match",{thisVolSha:t,tagVolSha:n()})}return this.logger().tap({msg:"pathInfo()",result:{nativePath:i,pathElements:c,nativePathSuffix:u,pathSep:a.sep,exists:s}})}async toApi(e,t){return(0,m.thenMap)(this.pathInfo(),(async i=>(0,H.reqValuedOrElse)({assetId:this.assetId,assetFileId:this.id,...i,mimetype:this.mimetype,shown:(0,N.isTrue)(this.shown),name:this.basename,width:this.width,height:this.height,rotation:this.rotation??0,fileSize:this.fileSize,mtime:this.mtime,downloadables:await this.downloadables(e,t),createdAtLocale:ie(this.createdAt),updatedAtLocale:ie(this.updatedAt)})))}get isVideo(){return(0,D.isVideoMimeType)(this.mimetype)}}function ie(e){return(0,U.map)(e,(e=>(0,V.fmtDuration)(Date.now()-e,1)+" ago"))}t.AssetFile=te,r=new WeakSet,s=function(){if((0,R.blank)(this.uri))return"blank uri";if((0,R.blank)(this.sha))return"blank sha";if(!(0,q.gt0)(this.width))return"missing width";if(!(0,q.gt0)(this.height))return"missing height";if(!(0,q.gt0)(this.capturedAtLocal))return"missing capturedAtLocal";if(!(0,q.gte0)(this.capturedAtPrecisionMs))return"missing capturedAtPrecisionMs";if(E.Settings.useImageHashes.valueOrDefault){const e=[];for(const t of["dctHash","diffHash","meanHash"])(0,R.blank)(this[t])&&e.push(t);if(1===e.length)return"missing image hash: "+e[0];if(e.length>1)return"missing image hashes: "+e.join(", ")}return this.isVersionUpToDate()?void 0:"outdated version"},te.$tableName="AssetFile",te.$uniqueColumnName="uri",te.$booleanFields=["shown"],te.$transientFields=["nativePath","syncState"]},48722:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toAssetId=void 0;const r=i(76596),s=i(31586);t.toAssetId=function(e){const t=(0,s.toGt0)(e?.assetId)??(0,s.toGt0)(e?.id);if(null==e||null==t||!(0,s.isNumber)(e?.capturedAtLocal))return;const i=((0,s.toGt0)(e.v)??(0,s.toGt0)(e.updateCount)??(0,s.toGt0)(e.updatedAt)??0)%1e6,n={assetId:t,capturedAtLocal:e.capturedAtLocal,v:i};return(0,s.gt0)(e.durationMs)&&(n.durationHMS=(0,r.durationHMS)(e.durationMs)),n}},37094:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetRevision=void 0;const r=i(98553),s=i(67478),n=i(55046);class a extends n.Model{static insert(...e){return a.ops().insert(e.map((e=>({assetId:e.assetId,createdAt:Date.now(),field:e.field,op:e.op,_priorValueJson:(0,r.stringify)(e.priorValue),_newValueJson:(0,r.stringify)(e.newValue)}))))}get priorValue(){return(0,s.parseJSON)(this._priorValueJson)}get newValue(){return(0,s.parseJSON)(this._newValueJson)}}t.AssetRevision=a,a.$tableName="AssetRevision"},69853:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setAssetRotation_=void 0;const r=i(50213),s=i(39250),n=i(66778),a=i(69589),o=i(40958),l=i(45599),u=i(98553),c=i(31586),d=i(21605),h=i(43487),f=i(94710),m=(0,l.defer)((()=>new s.LastOneInWins("Asset")));t.setAssetRotation_=async function(e,t,i){if(!(0,c.gt0)(e))throw new Error("invalid asset "+(0,u.stringify)(e));if(!(0,d.isRotation)(t))throw new Error("setRotation("+t+"): invalid rotation "+(0,u.stringify)(t));return m().enqueue({key:e,fn:s=>async function(e,t,i,s){const c=Date.now(),d=(0,r.mkLogger)("setAssetRotation("+(0,u.stringify)({assetId:e,rotation:t})+")"),m=h.Asset.ops().findById(e);if(null==m)return d.throw("Unknown assetId:"+e);const p=(0,l.defer)((()=>{f.Task.addOne("repairAsset",{assetId:e})}));d.throwIfAborted_(s);const g=m.getAssetFiles();if(null==m.getShown())return p(),d.throw("No primary asset file for Asset "+e+". Trying to repair.",{doNotSend:!0,fatal:!1,retriable:!1});const y=await i.ap(e).smallestFileForReducer("fit");if(null==y)return p(),d.throw("Missing previews for Asset "+e+". Trying to repair.",{doNotSend:!0,fatal:!1,retriable:!1});const v=[];for(const e of g)try{const i=await e.posixFile();if(null==i||await i.notExists()){d.info("cannot rotate variation: file is missing",{f:i,af:e});continue}if(d.throwIfAborted_(s),null==await(0,n.matchAndWriteRotation_)(y,i,t)){d.info("cannot rotate variation: matchRotation() failed",{f:i,af:e});continue}v.push(await e.upsertIfNeeded_(i.clear(),(0,a.forceContextOrSetting)({forceSync:!0})))}catch(t){d.warn("failed to update asset file",{af:e,error:t})}return(0,o.compact)(v),(0,o.isNotEmpty)(v)&&await i.apb(e,g,{forceRebuildPreviews:!0}).build_(),d.info("setRotation("+t+"): completed.",{elapsedMs:Date.now()-c,updatedAssetFiles:v}),v}(e,t,i,s)})}},45295:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AssetTag=void 0;const r=i(55046);class s extends r.Model{$pk(){return this.assetId+":"+this.tagId}}t.AssetTag=s,s.$tableName="AssetTag",s.$uniqueColumnName="assetId,tagId",s.$useCache=!1,s.$pkColumnNames=["assetId","tagId"]},61204:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeMonthTag=t.normalizeDateTags=t.getMonthTags=void 0;const r=i(19851),s=i(50213),n=i(97352),a=i(75020),o=i(4407),l=i(48723),u=`'${a.TagRoots.When}' || char(31) || '%' || char(31) || '%' || char(31)`,c=u+" || '%' || char(31)",d=(0,r.lazy)((()=>(0,s.mkLogger)("model.DateTagNormalizer")));function h(){return l.Tag.ops().allf((e=>e.whereNotNull("ordinal").andWhereRaw("_path LIKE "+u+" AND _path NOT LIKE "+c).limit(2400)))}function f(e){const t=(0,n.mapGt0)(e.ordinal,(e=>(0,o.monthTagRef)((0,o.ordinalToMonth)(e))));null==t?d().warn("failed to fix tag (no monthTagRef)",{t:e}):t.name!==e.name&&(d().info("Fixing month name",{tagRef:t,tag:e}),e.changeName(t.name)),e.maybeUpsertDisplayName(t?.displayName)}t.getMonthTags=h,t.normalizeDateTags=async function(){for(const e of h())f(e)},t.normalizeMonthTag=f},31687:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Heartbeat=void 0;const r=i(38835),s=i(42659),n=i(31586),a=i(72761);class o extends a.TimestampedModel{static ping(e){return o.ops().upsertOne({name:e})}static assertPing_(e="ping-"+Date.now()){if(null==o.db())throw new Error("no library is open"+r.NoLibraryErrorFlag);try{o.ping(e);const t=o.ops().findOneBy({name:e});if(null==t||t.name!==e||(0,n.lt)(t.updatedAt,Date.now()-20*s.secondMs))throw new Error("Heartbeat row wasn't inserted")}finally{try{o.dbl.runf((t=>t.delete().where({name:e})))}catch{}}}}t.Heartbeat=o,o.$tableName="Heartbeat",o.$uniqueColumnName="name",o.$useCache=!1},95700:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runMaintenanceTasks=void 0;const r=i(19851),s=i(56038),n=i(28874),a=i(42659),o=i(41400),l=i(69032),u=i(61204),c=i(49796);t.runMaintenanceTasks=async function({force:e}={}){await d(),await(!0===e?h.refresh():h());try{await(!0===e?(0,l.forceRunTagMaintenance)():(0,l.runTagMaintenance)())}catch{}};const d=(0,r.lazy)((()=>(0,s.time)("db.normalizeDateTags",u.normalizeDateTags))),h=(0,r.lazy)((()=>(0,s.time)("db.Progress.vacuum",(()=>c.Progress.vacuum()))),2*a.hourMs);(0,o.later)((()=>{n.Settings.libraryDir.watchLater((()=>{d.unset(),h.unset()}))}))},55046:(e,t,i)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const s=i(57975),n=i(50213),a=i(7282),o=i(65211),l=i(40958),u=i(38639),c=i(45599),d=i(31586),h=i(68708),f=i(34666),m=i(54993),p=i(57038),g=i(94448),y=i(33572),v=i(63872);class w{constructor(){this.$instanceId=(0,a.isTest)()?(0,o.uid)():void 0}static get $ctor(){return this.$schema+"."+this.$tableName}static query(){return(0,p.knex)()(this.$tableName)}static queryBy(e){return this.query().where(e)}static queryOneBy(e){return this.queryBy(e)}static ops(){return this._ops??(this._ops=new v.ModelOps(this,this.db))}static get dbl(){return this.ops().dbl}static rows(){return this.ops().rows()}static truncate(){if((0,a.isProd)())throw new Error("rejecting attempt to truncate in prod");this.dbl.run("DELETE FROM "+this.$tableName)}static ucn(e){const t=this.$uniqueColumnName.split(",").map((t=>e[t]));return t.some((e=>null==e))?void 0:1===t.length?t[0]:t.join(",")}static hasId(e){return this.$pkColumnNames.every((t=>null!=e[t]))}static pickId(e){return(0,h.pick)(e,...this.$pkColumnNames)}$ops(){return this.class().ops()}class(){return this.constructor}$pk(){return(0,m.toS)(this.id)}$ucn(){return this.class().ucn(this)}$tableName(){return this.class().$tableName}$uid(){return`${this.$tableName()}(${this.id??this.$ucn()})${!0===this.shown?"!":""}`}logger(){return(0,n.mkLogger)(this.class().$schema+"."+(0,m.toS)(this.valueOf()))}[s.inspect.custom](){return{...this.$toShallowJSON(),$instanceId:this.$instanceId}}toString(){return this.$uid()}valueOf(){return this.$uid()}static fromJSON(e){return(0,y.fromJSON)(this,e)}static toJSON(e){return this.fromJSON(e).toJSON()}$toShallowJSON(){return this.$_toJSON({encodeBool:u.isTrue})}$toDbJSON(e){return this.$_toJSON({encodeBool:u.boolToInt,includeCtor:!1,includeTransient:!1,colNames:e})}$clone(){return(0,y.fromJSON)(this.class(),this.toJSON())}toJSON(){return this.$_toJSON({encodeBool:u.isTrue})}_get(e,t,i=!0){const r=this[e];return null===r?[e,null]:!(0,f.isPrimitive)(r)||!i&&(0,l.includes)(this.class().$transientFields,e)?void 0:(0,l.includes)(this.class().$booleanFields,e)?[e,t(r)]:[e,r]}$_toJSON({encodeBool:e,includeCtor:t=!0,includeTransient:i=!0,colNames:r}){const s=this.class(),n=(0,l.notEmptyOr)(r,s.ops().columnNames());return(0,h.fromEntries)(n.map((t=>this._get(t,e,i))),t?{$ctor:s.$ctor}:{})}insert(){return this.logger().debug("insert()",{self:this.toJSON()}),this.class().ops().insertOne(this)}update(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("update()",{self:this.toJSON()}),this.class().ops().updateOne(this)}upsert(e){return null!=e&&(0,y.assignFromJSON)(this,e),this.logger().debug("upsert()",{self:this.toJSON(),arg:e}),this.class().ops().upsertOne(this)}$afterInsert(){}$beforeUpsert(){}$afterUpsert(){}reload(){return this.class().ops().reloadOne(this)}delete(){(0,d.gt0)(this.id)&&this.class().ops().delete([this.id])}}t.Model=w,r=w,w.$schema="models",w.$logger=(0,c.defer)((()=>(0,n.mkLogger)(r.$schema+"."+r.$tableName))),w.db=g.modelDb,w.$pkColumnNames=["id"]},94448:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.libraryModelDbFile=t.modelDb=void 0;const r=i(15056),s=i(87290),n=i(19851),a=i(55835);t.modelDb=(0,n.lazy)((()=>{})),t.libraryModelDbFile=function(e){return(0,a.map)((0,s.libraryDataDirPosixFile)(e),(e=>(0,r.pathToDb)(e,"models")))}},33572:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toJSON=t.assignFromJSON=t.fromJSON=t.addModelClass=void 0;const r=i(50213),s=i(40958),n=i(22573),a=i(38639),o=i(97790),l=i(51926),u=new Map;function c(e){u.set(e.$ctor,e)}function d(e,t,i=[]){const r=e.class();for(const[n,o]of Object.entries(t)){if("$ctor"===n)continue;if(void 0===o)continue;const t=(0,l.stripPrefixes)(n,i);e[t]=null==o?o:(0,s.includes)(r.$booleanFields,t)?(0,a.isTrue)(o):o}return e}t.addModelClass=c,t.fromJSON=function(e,t){if(null==t)throw new Error("json is null");if(null!=e&&(0,n.notBlank)(e.$ctor)&&!u.has(e.$ctor)&&c(e),t instanceof e)return t;const i=(0,o.opt)(t.$ctor).flatMap((e=>u.get(e))).getOrElse((()=>e));if(t instanceof i)return t;const r=new i;return null==t?r:d(r,t,(0,s.uniq)([e.$tableName+".",i.$tableName+"."]))},t.assignFromJSON=d,t.toJSON=function e(t,i,s){if(null!=t)return Array.isArray(t)?t.map(((t,r)=>e(t,i,`${s}[${r}]`))):"function"==typeof t.toJSON?t.toJSON():void(0,r.mkLogger)("ModelJSON.toJSON()").warn("Failed",{m:t,key:s,mc:i.$ctor})}},63872:function(e,t,i){"use strict";var r,s,n,a,o,l,u,c,d=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},h=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ModelOps=void 0;const f=i(48884),m=i(19851),p=i(50213),g=i(81168),y=i(48299),v=i(12943),w=i(38835),b=i(34102),S=i(28874),P=i(40958),_=i(76790),T=i(22573),M=i(50357),E=i(96249),k=i(98553),D=i(55835),x=i(31586),C=i(68708),F=i(59455),A=i(86859),I=i(33572);t.ModelOps=class{constructor(e,t){r.add(this),this.model=e,this.db=t,s.set(this,void 0),n.set(this,!0),a.set(this,new y.WeakCache),o.set(this,new Set),this.columnNames=(0,m.lazy)((()=>this.db().tableInfo_().find((e=>(0,g.equalsIgnoreCase)(e.tableName,this.tableName))).columns.map((e=>e.name)))),this.updatableColumnNames=(0,m.lazy)((()=>(0,P.diff)(this.columnNames(),this.immutableColumnNames))),this.ucnFieldNames=(0,m.lazy)((()=>this.ucn.split(","))),d(this,s,(0,p.mkLogger)(`ModelOps(${e.$tableName})`),"f"),(0,I.addModelClass)(e),d(this,n,e.$useCache??!0,"f"),this.dbl=new A.DbRequest(this.db,e.$tableName),(0,b.ee)().on("clearCache",(()=>h(this,a,"f").clear())),(0,b.ee)().on("clearDbCache",(()=>h(this,a,"f").clear()))}clearDbCache(){h(this,a,"f").clear()}get $cache(){return h(this,a,"f")}$cachedByJson(e){if(null==e||!h(this,n,"f"))return;const t=this.$pickModelUcn(e);return(null==t?void 0:h(this,a,"f").get((0,k.stringify)(t)))??this.$cachedById(e.id)}$cachedById(e){return(0,x.gt0)(e)&&h(this,n,"f")?h(this,a,"f").get((0,k.stringify)(e))??h(this,a,"f").findEntry((t=>t.id===e)):void 0}get dbOpen(){return(0,D.mapOr)(this.db(),(e=>e.isOpen),(()=>!1))}get tableName(){return this.model.$tableName}query(){return this.model.query()}toDbValued(e){const t=this.model.fromJSON(e),i=(0,v.toDbValued)(t);return(0,C.pick)(i,...this.columnNames())}run(e){return this.dbl.run(e)}fromJSON(e){if((0,C.isEmptyObj)(e))return;const t=this.model.fromJSON(e);return h(this,r,"m",u).call(this,t)}fromJSONs(e){return(0,P.compact)(e.map((e=>this.fromJSON(e))))}first(e){return this.fromJSON(this.dbl.first(e))}firstf(e){return this.first(e(this.query()))}all(e=this.query()){return this.fromJSONs(this.dbl.all(e))}allf(e){return this.all(e(this.query()))}findOne(e){return this.fromJSON(this.dbl.first(e))}findOneBy(e){return this.findOne(this.model.query().where(e))}findById(e,t){return this.findOneBy({...t,id:e})}findByIds(e){e=(0,F.toA)(e).filter(x.gt0);const t=[],i=[];for(const r of e){const e=this.$cachedById(r);null!=e?t.push(e):i.push(r)}const r=(0,f.batches)(i,S.Settings.dbBatchSelectSize.valueOrDefault).map((e=>this.dbl.all(this.query().whereIn("id",e))));return(0,_.sortBy)([...t,...this.fromJSONs((0,E.flatten)(r))],(t=>e.indexOf(t.id)))}findBy(e){return this.all(this.model.queryBy(e))}findWhereIn(e,t){return this.all(this.model.query().whereIn(e,t))}rows(e){return this.count(e??this.model.query().count())}count(e){return(0,x.toGt0)(this.dbl.pluckFirst(e))??0}countf(e){return this.count(e(this.query()))}insert(e){return(0,F.toA)(e).map((e=>this.insertOne(e)))}upsertOne(e){return this.modelSupportsUpsert?this.upsert([e])[0]:this.insertOrUpdateOne(e)}insertOrUpdateOne(e){return null==e.id?this.insertOne(e):this.updateOne(e)}insertOne(e){if(this.model.hasId(e))throw new Error("insert called for "+(0,k.stringify)(e)+w.NonRetriableErrorFlag);const t=this.fromJSON(e);if(null==t)return h(this,s,"f").throw("insertOne(): fromJSON returned null"+w.InternalErrorFlag,{t:e});t instanceof this.model&&h(this,r,"m",u).call(this,t),t.$beforeUpsert();const i=t.$toDbJSON(this.columnNames()),n=this.dbl.runf((e=>e.insert(i)));return t.id=(0,x.toInt)(n.lastInsertRowid),t.$afterInsert(),t.$afterUpsert(),t}unsetField(e,t){return(0,D.map)(this.$cachedById(e),(e=>{e[t]=null})),this.dbl.runf((i=>i.where({id:e}).update(t,null)))}updateOne(e){if(null==e.id)throw new Error("update called for "+(0,k.stringify)(e)+w.NonRetriableErrorFlag+w.InternalErrorFlag);const t=this.model.fromJSON(e);t.$beforeUpsert();const i=t.$toDbJSON(this.updatableColumnNames());return this.dbl.runf((t=>t.where({id:e.id}).update(i))),t.$afterUpsert(),h(this,r,"m",u).call(this,t)??t}get ucn(){return(0,T.toNotBlank)(this.model.$uniqueColumnName)??"id"}get modelSupportsUpsert(){return null!=this.ucn&&"id"!==this.ucn}get ucnConstraint(){return`(${this.ucn})`}get immutableColumnNames(){return(0,P.uniq)([...this.ucnFieldNames(),"id","createdAt"])}onConflictClause(e){const t=this.immutableColumnNames,i=e.filter((e=>!t.includes(e))).sort().map((e=>`${e}=excluded.${e}`)).join(","),r=["ON CONFLICT",this.ucnConstraint];return(0,T.blank)(i)?r.push("DO NOTHING"):r.push("DO UPDATE SET",i),r.join(" ")}$pickModelUcn(e){const t={};for(const i of this.ucnFieldNames()){const r=e[i];if(null==r)return;t[i]=r}return t}reloadOne(e){if(h(this,o,"f").has(e.id))return;const t=this.$pickModelUcn(e);if(null!=t){const i=h(this,r,"m",u).call(this,e),s=this.findOneBy(t);if(null==s)return;return h(this,r,"m",l).call(this,i,s),i!==e&&h(this,r,"m",l).call(this,e,i),i}h(this,s,"f").warn(".reloadOne(): failed to reload "+(0,k.stringify)(e))}reload(e){const t=[],i=this.allf((i=>{for(const r of e){const e=this.model.hasId(r)?this.model.pickId(r):this.$pickModelUcn(r);null!=e?(t.push([r,e]),i=i.orWhere(e)):h(this,s,"f").warn("reload(): given insufficient partial model",{fragment:r})}return i})),n=[];for(const[e,a]of t){const t=i.find((e=>(0,M.eqlSubset)(a,e)));if(null==t)h(this,s,"f").warn("reload(): failed to find result in db",{prior:e,dbArr:i});else{const i=h(this,r,"m",u).call(this,e);h(this,r,"m",l).call(this,i,t),i!==e&&h(this,r,"m",l).call(this,i,t),n.push(t)}}return n}upsert(e){if(e=(0,P.compact)(e),!this.modelSupportsUpsert)return e.map((e=>this.insertOrUpdateOne(e)));const t=this.columnNames(),i=[];for(const s of(0,f.batches)((0,F.toA)(e),S.Settings.dbBatchUpsertSize.valueOrDefault)){const e=new Map,n=new Set,a=(0,P.compact)(s.map((e=>this.fromJSON(e))));for(const t of a){const i=(0,k.stringify)(this.$pickModelUcn(t));e.set(i,t),this.model.hasId(t)||n.add(i),t.$beforeUpsert()}h(this,r,"m",c).call(this,a.map((e=>e.$toDbJSON(t))));const o=this.reload(a),l=new Map(o.map((e=>[(0,k.stringify)(this.$pickModelUcn(e)),e])));for(const e of a){const t=(0,k.stringify)(this.$pickModelUcn(e)),r=l.get(t)??e;n.has(t)&&r.$afterInsert(),r.$afterUpsert(),i.push(r)}}return i}delete(e){const t=(0,F.toA)(e).filter(x.gt0);for(const e of t)h(this,o,"f").add(e);return h(this,a,"f").deleteValueIf((e=>t.includes(e.id))),this.run(this.model.query().delete().whereIn("id",t))}async batched(e){const t=e.batchSize??S.Settings.dbBatchSelectSize.valueOrDefault;let i,r;do{i=this.allf((i=>(i=e.qb(i),null!=r&&(i=i.andWhere("id",">",r)),i.orderBy("id","asc").limit(t)))),(0,P.isNotEmpty)(i)&&(r=Math.max(...i.map((e=>e.id))),await e.onResults(i))}while((0,P.isNotEmpty)(i))}},s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakMap,r=new WeakSet,l=function(e,t){(0,C.assignFields)(e,t,{omitKeys:["$instanceId"],assignNullish:!0})},u=function(e){if(h(this,n,"f")){const t=this.$cachedByJson(e);if(null!=t)return h(this,r,"m",l).call(this,t,e),t;{const t=this.$pickModelUcn(e)??e.id;null!=t&&h(this,a,"f").set((0,k.stringify)(t),e)}}return e},c=function(e){const t=this.query().insert(e).toSQL(),i=new Set;for(const t of e)for(const e of(0,C.keys)(t))i.add(e);const s={sql:t.sql+" "+this.onConflictClause([...i.values()]),bindings:t.bindings};this.run(s);for(const t of e){const e=this.$cachedByJson(t);null!=e&&h(this,r,"m",l).call(this,e,this.model.fromJSON(t))}}},20958:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Operation=t.OperationNames=void 0;const r=i(19851),s=i(50213),n=i(88158),a=i(99331),o=i(70025),l=i(8769),u=i(22573),c=i(98553),d=i(50989),h=i(72761);t.OperationNames=(0,d.strEnum)("rebuildLibrary","forceRestartSync");const f=(0,r.lazy)((()=>(0,s.mkLogger)("model.Operation")));class m extends h.TimestampedModel{static incomplete(){return this.ops().allf((e=>e.whereIn("id",(e=>e.table(m.$tableName).min("id").whereNull("completedAt")))))}static ensurePendingOp(e){return m.getFirstPendingOp(e)??m.ops().insertOne(e)}static getFirstPendingOp(e){return f().tap({msg:"getFirstPendingOp",level:"info",result:this.ops().firstf((t=>{const i=t.whereNull("completedAt").orderBy("createdAt","asc");return null!=e?i.andWhere(e):i})),meta:{crit:e}})}static markOpCompleted(e,t){return(0,u.blank)(e?.name)?f().throw("markOpCompleted(): bad query",{crit:e}):this.dbl.runf((i=>i.whereNull("completedAt").andWhere(e).update({completedAt:Date.now(),...t})))}static async applyIfPending(e,t){const i=this.ops().firstf((t=>t.whereNull("completedAt").andWhere(e)));return f().info("applyIfPending()",{crit:e,op:i}),null==i?void 0:t(i)}static async applyOnce_(e,t,i=n.identity){const r=this.ops().firstf((t=>i(t.whereNotNull("completedAt").andWhere(e))));if(null!=r)return void f().debug("applyOnce(): already done",{priorCompleted:r});const s=this.ops().insertOne(e);try{const e=await t(s);return(0,a.ending)()||s.markCompleted(),e}catch(t){if((0,o.isRedoableError)(t))return void f().info("applyOnce(): redoable error",{crit:e,error:t});throw(0,l.onError)("Operation.applyOnce(): "+(0,c.stringify)(e),t),t}}markCompleted(){null==this.completedAt&&(this.completedAt=Date.now(),this.upsert())}}t.Operation=m,m.$tableName="Operation",m.$uniqueColumnName="id",m.$useCache=!1},49796:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Progress=t.defaultMinCreatedAt=t.toPct=void 0;const r=i(48161),s=i(1708),n=i(48884),a=i(50213),o=i(28874),l=i(40958),u=i(42659),c=i(45599),d=i(98553),h=i(55835),f=i(31586),m=i(68708),p=i(67478),g=i(51926),y=i(59455),v=i(54993),w=i(76386),b=i(33572),S=i(55009),P=i(72761),_=(0,c.defer)((()=>(0,a.mkLogger)("model.Progress")));function T(e){return null==e||!(0,f.isNumber)(e)||e<0||e>100?void 0:(0,f.sigFigs)(e,3)}t.toPct=T;const M=(0,g.compressWhitespace)("\nSELECT\n p1.uri,\n p1.id as lastProgressId,\n p1.createdAt as lastStartedAt,\n p1.updatedAt as lastUpdatedAt,\n p3.lastCompletedAt\nFROM\n Progress AS p1\n JOIN (\n SELECT\n uri,\n max(updatedAt) AS lastUpdatedAt\n FROM\n Progress\n GROUP BY\n 1\n ) AS p2 ON p1.uri = p2.uri\n AND p1.updatedAt = p2.lastUpdatedAt\n LEFT JOIN (\n SELECT\n uri,\n max(completedAt) AS lastCompletedAt\n FROM\n Progress\n WHERE\n CAST(completedAt AS int) > 0\n GROUP BY\n 1\n ) AS p3 ON p1.uri = p3.uri\nGROUP BY\n p1.uri");function E(){const e=o.Settings.progressStaleDays.valueOrDefault;return e<=0?0:Date.now()-e*u.dayMs}t.defaultMinCreatedAt=E;class k extends P.TimestampedModel{static vacuum(e=o.Settings.progressRetentionDays.valueOrDefault*u.dayMs){const t=Date.now()-e,i=this.dbl.pluckAllf((e=>e.select("id").where("createdAt","<=",t)));for(const e of(0,n.batches)(i,o.Settings.dbBatchSelectSize.valueOrDefault))S.ProgressMeta.dbl.runf((t=>t.whereIn("progressId",e).delete())),k.dbl.runf((t=>t.whereIn("id",e).delete()))}static countCompletedDirectorySyncs(){return this.dbl.pluckFirstf((e=>e.where({state:"done"}).whereNotNull("completedAt").where("uri","like","ps%")))}static times(){return _().tap({msg:"times()",result:this.dbl.all({sql:M})})}static insertNew(e){const t=(0,h.map)(e.dek,d.stringify);return this.ops().insertOne({...(0,m.omit)(e,"dek"),dekJSON:t})}upsert(e){return null!=e&&this.assignFromPojo(e),super.upsert()}$beforeUpsert(){super.$beforeUpsert(),null==this.id&&(this.pid??(this.pid=s.pid),this.hostname??(this.hostname=(0,r.hostname)())),"done"===this.state&&(this.completedAt??(this.completedAt=Date.now())),this.completePct=T(this.completePct),this.incompletePct=T(this.incompletePct),this.scanningPct=T(this.scanningPct)}$afterUpsert(){super.$afterUpsert(),(0,w.tellWebProgressUpdated)()}toSyncState(){return{id:this.id,uri:this.uri,volume:this.volume,state:this.state,hed:this.hed,dek:this.dek,completePct:this.completePct,incompletePct:this.incompletePct,scanningPct:this.scanningPct}}get dek(){return(0,l.compactBlanks)((0,p.parseJSON)(this.dekJSON))}set dek(e){var t;this.dekJSON=(t=e,(0,d.stringify)((0,l.compactBlanks)((0,y.toA)(t))))}assignFromPojo(e){return(0,b.assignFromJSON)(this,(0,m.omit)(e,"volume","uri"))}getMeta(){return S.ProgressMeta.ops().allf((e=>e.where({progressId:this.id}).orderBy("createdAt")))}getPriorIncomplete(e=E()){return this.logger().tap({msg:"priorIncompleteProgress()",result:k.ops().firstf((t=>t.where({hostname:this.hostname,uri:this.uri,completedAt:null}).andWhere("createdAt",">",e).orderBy("updatedAt","desc")))})}getLastCompletedAt(e=E()){return k.dbl.pluckFirstf((t=>t.max("completedAt").where({uri:this.uri}).andWhere("createdAt",">",e)))}getLastIncompleteStartAt(){return k.dbl.pluckFirstf((e=>e.min("createdAt").where({uri:this.uri}).andWhere("createdAt",">",this.getLastCompletedAt()??0)))}setMeta(e,t){return this.logger().debug("setMeta()",{progressId:this.id,name:e,value:t}),S.ProgressMeta.ops().upsertOne({progressId:this.id,name:e,value:t})}setMetaRecord(e){const t=this.getMeta(),i=(0,l.diff)(t.map((e=>e.name)),Object.keys(e));this.logger().debug("setMetaRecord()",{progressId:this.id,keysToDelete:i,record:e}),S.ProgressMeta.ops().upsert((0,m.entries)(e).map((([e,t])=>({progressId:this.id,name:e,value:(0,v.toS)(t)})))),(0,l.isNotEmpty)(i)&&S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).whereIn("name",i).delete()))}deleteMeta(...e){return this.logger().debug("deleteMeta()",{progressId:this.id,names:e}),S.ProgressMeta.dbl.runf((t=>t.whereIn("name",e).andWhere({progressId:this.id}).delete()))}deleteAllMeta(){return this.logger().debug("deleteAllMeta()",{progressId:this.id}),S.ProgressMeta.dbl.runf((e=>e.where({progressId:this.id}).delete()))}getMetaAsRecord(){return this.logger().tap({msg:"getMetaAsRecord()",result:(0,m.fromEntries)(this.getMeta().map((e=>[e.name,e.value])))??{}})}}t.Progress=k,k.$tableName="Progress",k.$uniqueColumnName="id"},55009:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressMeta=t.ProgressMetaNames=t.DirSyncProgressMetaNames=void 0;const r=i(50989),s=i(72761);t.DirSyncProgressMetaNames=(0,r.strEnum)("lastScannedDirectory","scannedDirectoryCount","completedDirectoryScan","enqueuedStaleFiles","processedImageCount","processedVideoCount","completedDirectorySync"),t.ProgressMetaNames=(0,r.strEnum)(...t.DirSyncProgressMetaNames.values);class n extends s.TimestampedModel{}t.ProgressMeta=n,n.$tableName="ProgressMeta",n.$uniqueColumnName="progressId,name"},39604:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.upsertToShaBlockslist=t.upsertFileToShaBlockslist=t.isShaBlockslisted=t.notBlocklistedSha=void 0;const r=i(19851),s=i(50213),n=i(95696),a=i(40958),o=i(22573),l=i(86859),u=i(94448),c=(0,r.lazy)((()=>(0,s.mkLogger)("model.ShaBlocklist"))),d=(0,r.lazy)((()=>new l.DbRequest(u.modelDb,"ShaBlocklist")));function h(e){return null!=(0,u.modelDb)()&&!(0,o.blank)(e)&&c().tap({msg:"isShaBlockslisted",result:null!=d().pluckFirstf((t=>t.where({sha:e}).limit(1))),meta:{sha:e}})}function f(...e){if(null==u.modelDb.prior())return;const t=(0,a.uniq)(e).map((e=>({sha:e})));return(0,a.isEmpty)(t)?void 0:d().upsert((e=>e.insert(t)))}t.notBlocklistedSha=async function(e){if(null==(0,u.modelDb)())return null;const t=h(await n.PosixFile.for(e).sha());return null==t?null:!t},t.isShaBlockslisted=h,t.upsertFileToShaBlockslist=async function(e){if(null==(0,u.modelDb)())return;const t=await n.PosixFile.for(e).sha();return null==t?void 0:f(t)},t.upsertToShaBlockslist=f},48723:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Tag=t.UpdateTagAssetCountTimeName=void 0;const a=i(56038),o=i(34102),l=i(19851),u=i(50213),c=i(36372),d=i(97352),h=i(28874),f=i(81168),m=i(42231),p=i(75020),g=i(40958),y=i(22573),v=i(42659),w=i(41400),b=i(50357),S=i(55835),P=i(31586),_=i(34666),T=i(20214),M=i(51926),E=i(59455),k=i(12168),D=i(6186),x=i(57038),C=i(21074),F=i(7656),A=i(43487),I=i(48722),O=i(45295),L=i(98784),R=i(41507),N=i(72761),B=4*v.secondMs,j=(0,l.lazy)((()=>(0,u.mkLogger)("model.Tag")));(0,w.later)((()=>{(0,o.ee)().on("clearCache",(()=>z.clear())),(0,o.ee)().on("clearDbCache",(()=>z.clear()))})),t.UpdateTagAssetCountTimeName="db.updateTagAssetCountTimeName";class z extends N.TimestampedModel{constructor(){super(...arguments),this.displayPath=(0,l.lazy)((()=>{const e=this.getParent();return(0,g.compactBlanks)([...null==e?[]:e.displayPath(),this.displayName])})),this.ancestorIds=(0,l.lazy)((()=>0===this.parentId||null==this.parentId?[]:r.dbl.pluckAll({sql:(0,M.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.id","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}}))),this.firstNonInterstitialTagId=(0,l.lazy)((()=>{if(!this.isRoot&&0===this.directAssetCount()&&1===this.getChildrenCount()){const e=this.getChildren();if(1===e?.length)return e[0].firstNonInterstitialTagId()}return this.id})),this.directAssetCount=(0,l.lazy)((()=>0===this.id?0:A.Asset.dbl.pluckFirst(A.Asset.shownUnhidden().join("AssetTag","AssetTag.assetId","Asset.id").where("AssetTag.tagId",this.id).countDistinct("Asset.id"))))}static orderBy(e){return e.orderByRaw("COALESCE(ordinal, _path) COLLATE NOCASE")}static clear(){this.root.unset(),this.roots.unset(),this._upsertDefaultRoots.unset(),this.ops().clearDbCache()}static validate_(){return(0,a.timeSync)("Tag.validate_",(()=>{r.clear();for(const e of this.ops().allf((e=>e.whereRaw("id = parentId")))){j().warn(`Tag ${e.id} has itself as parentId. Attempting to fix...`);const t=e.path.slice(0,-1),i=(0,g.isEmpty)(t)?void 0:this.findOrCreate(t);e.update({parentId:i?.id??null})}for(const e of r.roots())e.validate_([])}))}validate_(e){const t=this.path;if(!(0,b.eql)(t.slice(0,-1),e))throw new Error(`Tag:${this.id} path ${t.join("/")} does not match expected parent ${e.join("/")}`);for(const e of this.getChildren())e.validate_(t)}static deltaAssetCountAndAncestors(e,t=1){return r.incrAssetCount(r.selfAndAncestorIds(e),t)}static incrAssetCount(e,t=1){(0,g.isEmpty)(e)||r.dbl.runf((i=>i.whereIn("id",e).andWhereNot({assetCount:null}).update({assetCount:(0,x.knex)().raw("assetCount + "+Math.round(t)),updatedAt:Date.now()})))}static selfAndAncestorIds(e){const t=(0,E.toA)(e).filter(P.gt0);return r.dbl.pluckAll({sql:(0,M.compressWhitespace)("WITH RECURSIVE ancestors(id) AS ("," SELECT id FROM Tag where id in "+(0,C.sqlWhereInClause)(t.length)," UNION ALL"," SELECT Tag.parentId as id"," FROM Tag, ancestors"," WHERE Tag.id = ancestors.id",")","SELECT distinct(id)","FROM ancestors","WHERE id IS NOT NULL"),bindings:t})}static updateAssetCount(e){if((0,P.gt0)(e))return(0,a.timeSync)(t.UpdateTagAssetCountTimeName,(()=>{const t=r.dbl.pluckFirst({sql:F.RecursiveAssetCountForTagQuery,bindings:{tagId:e}});r.dbl.runf((i=>i.update({assetCount:t,updatedAt:Date.now()}).where({id:e}))),j().debug("Updated asset counts for tag ",{tagId:e,assetCount:t})}))}static findByIdOrPath(e,t){return 0===e?r.root():(0,P.gt0)(e)?this.findById(e):this.findByPath(t)}static findById(e){return 0===e?r.root():this.ops().findById(e)}static findByPath(e){if((0,g.isEmpty)(e))return r.root();const t=(0,m.joinTagPath)(e);return this.ops().firstf((e=>e.whereLike("_path",t)))}static findByPathN(e){const t=(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,y.toNotBlank)((0,m.joinTagPath)(e))));return(0,g.compact)(t.map((e=>this.findByPath(e))))}static getPagedAssets(e,t){const i=new r;return i.id=e,i.getPagedAssetIds(t)}static findOrCreate(e){if((0,g.isEmpty)(e))throw new Error("empty tagPath");const t=this.findByPath(e);if(null!=t)return t;const i=n(this,r,"m",s).call(this,e),a=i.depth<=1?void 0:this.findOrCreate(e.slice(0,-1));return(0,S.map)(a,(e=>i.parentId=e.id)),this.ops().upsertOne(i)}static findOrCreateByPathN(e){return(0,g.uniqBy)(e.filter(g.isNotEmpty),(e=>(0,m.joinTagPath)(e))).map((e=>this.findOrCreate(e)))}clear(){return this.parent=void 0,this.root=void 0,this.children=void 0,this.ancestors=void 0,this.assets=void 0,this.relatedAssets=void 0,this.ancestorIds.unset(),this}$afterInsert(){L.TagFts.insertFts([this])}siblingPath(e){return(0,m.joinTagPath)([...this.parentPath,e])}changeName(e){return this.changePath(this.siblingPath(e))}maybeUpsertDisplayName(e){return(0,y.blank)(e)||e===this._displayName?void 0:this.upsert({_displayName:e})}changePath(e,t=!0){const i=this._path,s=r.findByPath((0,m.splitTagPath)(e));this.logger().info("changePath(): ",{priorPath:i,newPath:e,existingSibling:s});try{if(null==s)r.dbl.runf((t=>t.whereLike("_path",i+"%").update({updatedAt:Date.now(),_path:(0,x.knex)().raw("REPLACE(_path, ?, ?)",[i,e])}))),this._path=e;else{e=s._path,this.logger().info("changePath(): replacing with sibling",e),O.AssetTag.dbl.upsert((e=>e.where({tagId:this.id}).update({tagId:s.id}))),O.AssetTag.dbl.runf((e=>e.where({tagId:this.id}).delete()));for(const e of this.getChildren())e.changePath((0,m.joinTagPath)([...s.path,e.name]),!1);r.dbl.runf((e=>e.where({parentId:this.id}).update({parentId:s.id}))),this.delete()}}finally{t&&r.clear()}}get name(){const e=this.path;return e[e.length-1]}get path(){return(0,m.splitTagPath)(this._path)}get displayName(){return(0,y.toNotBlank)(this._displayName)??this.name}get isRoot(){return 0===this.id}get depth(){return this.path.length}get parentPath(){return this.path.slice(0,-1)}get sortBy(){return[this.depth,null==this.ordinal?2**51:this.ordinal,this.path.map((e=>e.toLowerCase()))]}$childrenQuery(){return r.orderBy(r.query().where({parentId:this.id}))}$assetsQuery(){return A.Asset.shownUnhidden().columns("Asset.*").join("AssetTag","AssetTag.assetId","Asset.id").where({tagId:this.id})}$selectAssetIdColumns(e){return e.clearSelect().select({assetId:"Asset.id",capturedAtLocal:"Asset.capturedAtLocal",updateCount:"Asset.updateCount",durationMs:"Asset.durationMs"})}$assetIdsQuery(){return this.$selectAssetIdColumns(this.$assetsQuery())}setAncestors(e){this.ancestors=e,this.parent=e[e.length-1],(0,S.map)(this.parent,(t=>t.setAncestors(e.slice(0,-1))))}async toApiPathElements(){return(0,T.thenCollect)(this.getAncestorsAndSelf(),(e=>e.toPathTag()))}toPathTag(){return{tagPath:this.path,displayName:this.displayName}}toApiTag(){return{tagId:this.id,tagPath:this.path,displayPath:this.displayPath(),description:this.description,assetCount:this.assetCount}}toStringId(){return"Tag("+this.path.join("/")+")"}getParent(){if(!this.isRoot)return null!=this.parentId&&null==this.parent?this.parent=r.findById(this.parentId):this.parent}getPagedChildren(e){if(0===this.id){const t=e.offset??0,i=t+(e.limit??this.children.length);return[...this.children].slice(t,i)}const t=this.$childrenQuery();return(0,d.mapGt0)(e.offset,(e=>{t.offset(e)})),(0,d.mapGt0)(e.limit,(e=>{t.limit(e)})),r.ops().all(t)}getChildrenCount(){return null!=this.children?this.children.length:r.dbl.pluckFirstf((e=>(this.isRoot?e.whereNull("parentId"):e.where({parentId:this.id})).count()))}getChildren(){return this.isRoot||(this.children=r.ops().all(this.$childrenQuery()),this.children.forEach((e=>{e.parent=this}))),this.children}link(){return"/tag/"+this.path.map(encodeURIComponent).join("/")}get rootName(){return this.path[0]}get ancestorsAndSelf(){return[...this.ancestors,this]}getAncestors(){return this.ancestors??(this.ancestors=this._getAncestors())}getAncestorsAndSelf(){return[...this.getAncestors(),this]}_getAncestors(){return 0===this.parentId||null==this.parentId?[]:r.ops().all({sql:(0,M.compressWhitespace)("WITH RECURSIVE cte(id, level) AS ("," VALUES (:tagId, 0)"," UNION ALL"," SELECT Tag.parentId as id, cte.level + 1 as level"," FROM Tag, cte"," WHERE Tag.id = cte.id",")","SELECT Tag.*","FROM Tag JOIN cte on cte.id = Tag.id","WHERE Tag.id <> :tagId","ORDER BY cte.level DESC"),bindings:{tagId:this.id}})}getPagedAssetIds(e){let t=this.$assetIdsQuery();return t=t.limit(p.ThumbsPerSample),(0,P.gt0)(e.offset)&&(t=t.offset(e.offset)),t=t.orderBy([{column:"capturedAtLocal",order:"desc"},{column:"assetId"}]),(0,g.compact)(A.Asset.dbl.all(t).map(I.toAssetId))}getAssets(){const e=this.$assetsQuery().orderBy("capturedAtLocal","desc");return A.Asset.ops().all(e)}async assetCountDesc(e){const t=this.assetCount;return(null==t||null==e||e.length===t||0===e.length?"":(0,k.fmt)(e.length)+" of ")+(0,k.plur)(t,"asset")}getAssetCount(){return 0===this.id?r.dbl.pluckFirst({sql:(0,M.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," Asset","WHERE"," Asset.shown = 1"," AND Asset.excluded = 0"," AND Asset.hidden = 0"," AND Asset.deletedAt IS NULL")}):r.dbl.pluckFirst({sql:F.RecursiveAssetCountForTagQuery,bindings:{tagId:this.id}})}$assetStreamQuery(e,t,i){let r=this.path[0]===p.TagRoots.When?A.Asset.shownUnhidden():this.$assetsQuery();return r=r.distinct().where("capturedAtLocal",i,e.capturedAtLocal).andWhereNot("Asset.id",e.id).limit("="===i?2*t:t),"="===i?r.orderByRaw(`ABS(Asset.id-${e.id})`):r.orderBy([{column:"capturedAtLocal",order:">"===i?"asc":"desc"},"Asset.id"])}getAssetStream(e,t){t=(0,P.gt0)(t)?t:p.BeforeAfterStreamLimit;const[i,r,s]=["<","=",">"].map((i=>(0,g.compact)(A.Asset.ops().all(this.$assetStreamQuery(e,t,i)).map(I.toAssetId))));for(const t of r)t.assetIdA.Asset.shownUnhidden(this.$selectAssetIdColumns(r)).distinct().join("Asset","Asset.id","AssetTag.assetId").join("Tag","Tag.id","AssetTag.tagId").whereLike("_path",this._path+"%").orderByRaw((0,c.prngOrderByClause)(e+(this.id??0),"Asset.id",i)).limit(t))).map(I.toAssetId));return this.logger().debug(this.path+": Found "+r.length+" related assets"),r}get attrs(){return{href:this.link(),title:this.name}}}t.Tag=z,r=z,s=function(e){const t=new r;t._path=(0,m.joinTagPath)(e);const i=e[e.length-1];return"object"==typeof i&&((0,y.mapNotBlank)(i.displayName,(e=>t._displayName=e)),(0,P.mapNumeric)(i.ordinal,(e=>t.ordinal=e)),(0,y.mapNotBlank)(i.description,(e=>t.description=e)),(0,P.mapNumeric)(i.releasedAt,(e=>t.releasedAt=e))),t},z.$tableName="Tag",z.$uniqueColumnName="_path",z.$useCache=!0,z.cmp=(e,t)=>(0,_.cmp)([e.ordinal??Number.MAX_SAFE_INTEGER,...e.path],[t.ordinal??Number.MAX_SAFE_INTEGER,...t.path]),z.root=(0,l.lazy)((()=>{const e=new r;return e.id=0,e._path=m.TagSep,e.parentId=void 0,e.children=r.roots().filter((e=>!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.name)&&!(0,f.includesIgnoreCase)(h.Settings.hiddenHomeTags.valueOrDefault,e.description??""))),e.ancestors=[],e.assetCount=A.Asset.shownCount(),e.upsert=()=>{throw new Error("upsert not supported on root")},e}),B),z._upsertDefaultRoots=(0,l.lazy)((()=>r.ops().upsert(D.Roots.map((e=>({_path:(0,m.joinTagPath)([e.name]),ordinal:e.ordinal})))))),z.roots=(0,l.lazy)((()=>{r._upsertDefaultRoots();const e=r.ops().all(r.orderBy(r.query().whereNull("parentId")));for(const t of e)t.parentId=void 0,t.ancestors=[];return e}),B);const V=(0,l.lazy)((()=>A.Asset.dbl.pluckFirstf((e=>e.count()))),v.minuteMs)},98784:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TagFts=void 0;const r=i(38156),s=i(3127),n=i(40958),a=i(41400),o=i(94715),l=i(55046),u=i(48723);class c extends l.Model{static insertFts(e){try{const t=e.filter((e=>null!=e.parentId)).map((e=>({rowid:e.id,root:(0,s.tag_fts_root)(e._path),path:(0,s.tag_fts_path)(e._path)})));(0,n.isEmpty)(t)||this.dbl.runf((e=>e.insert(t)))}catch(e){this.$logger().warn("Failed to update tag_fts",{error:e})}}static async rebuild(){const e=new r.PushProgressObserver({op:"Rebuilding tag search index"},u.Tag.dbl.pluckFirstf((e=>e.count("*")))),t=this.dbl.db();o.Migrations.create_tag_fts(t.db),await u.Tag.ops().batched({qb:e=>e,onResults:t=>(this.$logger().throwIfAborted_(),this.insertFts(t),e.incrProgress(t.length),(0,a.delay)(1))}),e.completed()}}t.TagFts=c,c.$tableName="tag_fts",c.$uniqueColumnName="rowid",c.$booleanFields=[]},41507:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.coalesceStreams=t.TaggedAssetStream=t.cmpAssetDesc=t.cmpAssetAsc=void 0;const r=i(48884),s=i(50213),n=i(28874),a=i(40958),o=i(76790),l=i(31586),u=i(34666),c=i(20214),d=i(59455);t.cmpAssetAsc=(e,t)=>(0,u.cmp)([e.capturedAtLocal,e.id],[t.capturedAtLocal,t.id]),t.cmpAssetDesc=(e,t)=>(0,u.cmp)([t.capturedAtLocal,t.id],[e.capturedAtLocal,e.id]),t.TaggedAssetStream=class{constructor(e,t,i,r){this.tags=e,this.before=t,this.after=i,this.limit=r,this.logger=()=>(0,s.mkLogger)("model.TaggedAssetStream("+this.toString()+")"),this.logger().info("new",this.toJSON())}vacuum(){(0,o.sortByInPlace)(this.before,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainFirstN)(this.before,this.limit),(0,o.sortByInPlace)(this.after,(e=>[-e.capturedAtLocal,-e.assetId])),(0,r.retainLastN)(this.after,this.limit)}toString(){return this.tags.map((e=>e.path.join("/"))).join(",")}valueOf(){return this.toString()}get length(){return(0,d.toA)(this.before).length+(0,d.toA)(this.after).length}leftPad(e){return[...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+1),capturedAtLocal:-1,v:0}))),...e]}rightPad(e){return[...e,...(0,l.times)(this.limit-e.length,(e=>({assetId:-(e+this.limit+1),capturedAtLocal:-1,v:0})))]}toJSON(){return{tags:this.tags.map((e=>e.toString())),assetIdsAfter:this.after,assetIdsBefore:this.before}}mergeWith(e){(0,a.pushUniqBy)(this.tags,e.tags,(e=>e.path)),(0,a.pushUniqBy)(this.before,e.before,(e=>e.assetId)),(0,a.pushUniqBy)(this.after,e.after,(e=>e.assetId)),this.logger().debug("mergeWith() complete",{tas:e.toJSON(),tags:this.tags.map((e=>e.path)),beforeIds:this.before,afterIds:this.after})}async toApi(){return this.vacuum(),this.logger().tap({msg:"toApi()",result:{tags:await(0,c.thenCollect)(this.tags,(e=>e.toApiTag())),assetIdsAfter:this.leftPad(this.after),assetIdsBefore:this.rightPad(this.before)}})}streamCoeff(e){return this.logger().tap({msg:"streamCoeff",meta:{this:this.tags.map((e=>e.path)),tas:e.tags.map((e=>e.path))},result:(0,r.diceCoeff)([...this.before,...this.after],[...e.before,...e.after],(e=>e.assetId))})}},t.coalesceStreams=function(e){const t=n.Settings.minStreamCorrPct.valueOrDefault/100,i=[],s=e.filter((e=>e.length>5));for(const e of s){const s=(0,r.greatestBy)(i,(i=>(0,l.gtOrElse)(i.streamCoeff(e),t)));null==s?i.push(e):s.mergeWith(e)}return i}},94710:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Task=t.StaleTaskError=t.InvalidTaskError=t.TaskNames=t.Tasks=t.testTask=void 0;const c=i(78474),d=i(22454),h=i(23560),f=i(12089),m=i(76740),p=i(22911),g=i(99331),y=i(31562),v=i(38835),w=i(70025),b=i(8769),S=i(74128),P=i(28874),_=i(37692),T=i(40958),M=i(22573),E=i(42659),k=i(45599),D=i(98553),x=i(49769),C=i(68708),F=i(50989),A=i(59455),I=i(58723),O=i(34274),L=i(90901),R=i(61989),N=i(93755),B=i(69032),j=i(55046);t.testTask=(0,f.shim1)({name:"testTask",impl:async e=>{}}),t.Tasks={applyDeleted:I.applyDeleted,applyExcluded:I.applyExcluded,runTagMaintenance:B.runTagMaintenance,repairAsset:async function(e){e.forceSync=!0,e.skipPreviews=!0,e.skipAssetTagging=!0;const t=await(0,R.updateAsset_)(e);return(0,T.isNotEmpty)(t?.assetIdsToUpdate)&&q.add(t?.assetIdsToUpdate.map((t=>({fn:"repairAsset",args:{...e,assetId:t},priority:W.repairAsset+1})))),null!=t&&!0!==t.deleted&&(0,M.blank)((0,A.toA)(t.rejected).join(""))&&(0,M.blank)(t.error)&&q.addOne("assetPostUpsertTasks",(0,C.omit)(e,"skipPreviews","skipAssetTagging")),t},assetPostUpsertTasks:L.assetPostUpsertTasks,updateAssetFile:N.updateAssetFile_,syncFile:O.importFileToResult_,testTask:t.testTask},t.TaskNames=(0,F.strEnum)(...(0,C.keys)(t.Tasks));class z extends Error{}t.InvalidTaskError=z;class V extends Error{}t.StaleTaskError=V;const W={applyDeleted:16,applyExcluded:16,runTagMaintenance:14,repairAsset:12,assetPostUpsertTasks:10,updateAssetFile:8,syncFile:0,testTask:-1},U=["repairAsset"];class q extends j.Model{constructor(){super(...arguments),r.add(this),o.set(this,(0,k.defer)((()=>new m.Abortable)))}static countTaskNames(){const e={};for(const t of s.dbl.allf((e=>e.select("fn").count().groupBy("fn"))))e[t.fn]=t["count(*)"];return e}static orderBy(e){return e.orderBy([{column:"priority",order:"desc"},{column:"retries",order:"desc"},{column:"id",order:"asc"}])}static count(){return s.dbl.pluckFirstf((e=>e.count("id")))}static freeSlots(){return P.Settings.taskListCap.valueOrDefault-s.count()}static countByFn(e){return s.dbl.pluckFirstf((t=>t.where({fn:e}).count("id")))}static nextByFn(e,t=(e=>e)){return s.ops().allf((i=>s.orderBy(t(i.where({fn:e})))))}set args(e){this.argsJSON=(0,D.stringify)(e)}get args(){const e=(0,D.parseJSON)(this.argsJSON);return(0,C.notEmptyObj)(e)&&(e.halt=u(this,o,"f").call(this)),e}get isSerial(){return U.includes(this.fn)}toString(){return`Task#${this.fn}(${this.argsJSON})`}static addOne(e,t){return s.add([{fn:e,args:t}])[0]}static add(e,t=!1){if((0,T.isEmpty)(e))return[];const i=s.ops().upsert(e.map((e=>({fn:e.fn,argsJSON:(0,D.stringify)(e.args)})),t));return s.ee.emit("added",i),(0,h.isTaskListManager)()||(0,_.addStateEvent)("checkTasks"),i}$beforeUpsert(){this.priority??(this.priority=W[this.fn]),this.retries??(this.retries=P.Settings.maxRetries.valueOrDefault)}donePromise(){return(0,h.isTaskListManager)()?(0,x.getOrSet)(u(s,s,"f",n),this.id,(()=>new p.Deferred(this.toString(),{payload:this}))):(0,y.untilTrue)((()=>null==s.ops().findById(this.id)),{intervalMs:E.secondMs})}abort(e){this.logger().warn("aborting task",{reason:e,task:this}),u(this,o,"f").call(this).abort(e),this.delete(),(0,M.blank)(this.args.path)||(0,S.syncReport)().onProgress({path:this.args.path,from:this.fn,state:S.SyncFileStates.failed,details:e})}async _run(){if(this.retries<0)throw this.logger().warn(".run(): too many retries"+v.InternalErrorFlag,{job:this}),this.delete(),new z;if(!u(this,r,"m",l).call(this))throw this.logger().warn(".run(): someone already started this task",{job:this}),new V;try{const e=Date.now(),i=await t.Tasks[this.fn](this.args);return this.logger().throwIfAborted_(u(this,o,"f").prior()),s.taskResolvedCounts.incr(this.fn),s.ee.emit("resolved",this,i,Date.now()-e),this.delete(),u(s,s,"f",n).get(this.id)?.resolve(i),i}catch(e){if((0,g.ending)())throw this.logger().info("task failed, but we're ending. We'll leave it for next time.",{task:this}),e;throw s.taskRejectedCounts.incr(this.fn),(0,w.isRedoableError)(e)?(this.retries++,this.priority--,this.upsert()):!0===(0,w.isRetriableError)(e)&&this.retries>=0?this.logger().warn("run failed, but we can retry it later",{task:this,error:e}):(s.ee.emit("rejected",this,e),this.delete(),u(s,s,"f",n).get(this.id)?.reject(e),(0,b.onError)(this.toString()+" failed",e)),e}finally{u(s,s,"m",a).call(s)}}}t.Task=q,s=q,o=new WeakMap,r=new WeakSet,a=function(){for(const[e,t]of u(this,s,"f",n).entries())t.isSettled&&u(this,s,"f",n).delete(e)},l=function(){const e=this.retries;if(1===s.dbl.runf((t=>t.where({id:this.id,retries:e}).update({retries:e-1}))).changes)return--this.retries,!0;{const e=this.toJSON(),t=this.reload();return this.logger().warn(".#decrRetries(): someone already started this task",{before:e,reloaded:t}),!1}},q.$tableName="Task",q.$uniqueColumnName="fn,argsJSON",q.$useCache=!1,q.taskResolvedCounts=new d.CountingSet,q.taskRejectedCounts=new d.CountingSet,q.ee=new c.EventEmitter,n={value:new Map}},72761:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TimestampedModel=void 0;const r=i(97352),s=i(40958),n=i(31586),a=i(59455),o=i(55046);class l extends o.Model{static touch(e,t={}){t.updatedAt??(t.updatedAt=Date.now()),delete t.id;const i=(0,a.toA)(e).filter(n.gt0);return(0,s.isEmpty)(i)?void 0:this.dbl.runf((e=>e.whereIn("id",i).update(t)))}get createdAtDate(){return(0,r.mapGt0)(this.createdAt,(e=>new Date(e)))}get updatedAtDate(){return(0,r.mapGt0)(this.updatedAt,(e=>new Date(e)))}touch(e={}){e.updatedAt??(e.updatedAt=Date.now());const t=this.id;null==t?this.upsert():this.class().dbl.runf((i=>i.where({id:t}).update(e)))}$beforeUpsert(){if(super.$beforeUpsert(),this.createdAt??(this.createdAt=Date.now()),this.updatedAt=Date.now(),"updateCount"in this){const e=this,t=e.updateCount;e.updateCount=((0,n.toGt0)(e.updateCount)??0)+1,this.logger().debug("$beforeUpsert(): incr updateCount",{prior:t,now:e.updateCount})}}}t.TimestampedModel=l},73407:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.writeAssetTags_=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(47783),o=i(54017),l=(0,r.lazy)((()=>(0,s.mkLogger)("model.WriteAssetTags")));t.writeAssetTags_=async function(e,t){const i=o.AssetFile.ops().findBy({assetId:e});return(0,n.mapAsync)({name:"writeAssetTags",arr:i,f:e=>async function(e,t){const i=await e.posixFile_();if(null!=i&&!0===await(i?.exists()))return(0,a.writeTags_)(i,t,e.mimetype);l().info("Skipping AssetFile:"+e.id+" (file is missing)",{writeTags:t})}(e,t)})}},58723:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyExcluded=t.applyDeleted=void 0;const r=i(50213),s=i(43487),n=(0,r.mkLogger)("ops.ApplyRemovable");async function a(e,t,i){const r=e?"Deleting":"Excluding",a=e?"deletedAt":"excludedAt";await s.Asset.dbl.batched({qb:e=>e.select("id").where("shown",0).andWhere(a,"<=",t),onResults:async t=>{for(const a of t){n.throwIfAborted_(i);try{await s.Asset.remove({assetId:a,blocklistShas:!0,unlinkAssetFiles:e})}catch(e){n.error(r+" failed",{assetId:a,error:e})}}}})}t.applyDeleted=function(e){return a(!0,e.createdAt,e.halt)},t.applyExcluded=function(e){return a(!1,e.createdAt,e.halt)}},76386:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiProgressPatchPath=t.tellWebProgressUpdated=t.ProgressRateMs=void 0;const r=i(19851),s=i(50213),n=i(23560),a=i(24540),o=i(28874),l=i(34238),u=i(4988),c=i(15674),d=i(42659),h=(0,i(45599).defer)((()=>(0,s.mkLogger)("progress.Progress")));t.ProgressRateMs=(0,r.lazy)((()=>d.secondMs*((0,a.isRaspberryPi)()||(0,c.maxCpus)()<=3?5:1.5))),t.tellWebProgressUpdated=(0,r.lazy)((async()=>{if((0,n.isWebService)())return;const e=l.URI.from({scheme:"http",authority:"127.0.0.1:"+o.Settings.httpPort.valueOrDefault,path:t.ApiProgressPatchPath}).toString();await(0,u.httpRequest_)({url:e,method:"PATCH"}).catch((e=>h().warn(".tellWebProgressUpdated: failed",{error:e})))}),(0,t.ProgressRateMs)()),t.ApiProgressPatchPath="/api/progress"},44694:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryTermToFuzzyDate=void 0;const r=i(98725),s=(0,i(19851).lazy)((()=>new r.FuzzyDateParser({fuzzyDateParsing:!0,fuzzyYearParsing:!0})));t.queryTermToFuzzyDate=function(e){return s().parse(e)}},43786:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryToString=t.NormieQuerySymbols=t.SetQuerySymbols=t.isTrueTerm=t.flatTerms=t.findTerm=t.hasNsTerm=t.isQuery=t.isClause=t.isAndClause=t.isOrClause=t.isTerm=void 0;const r=i(40958),s=i(22573),n=i(38639),a=i(51926),o=i(54993);function l(e){return"object"==typeof e&&(0,s.notBlank)(e.term)&&(null==e.not||"boolean"==typeof e.not&&(null==e.ns||(0,a.isString)(e.ns)))}function u(e){return"object"==typeof e&&Array.isArray(e.queries)}function c(e){return"or"===e?.type&&u(e)}function d(e){return"and"===e?.type&&u(e)}function h(e){return d(e)||c(e)}function f(e,t){if(l(e))return t(e)?e:void 0;for(const i of e.queries){const e=f(i,t);if(null!=e)return e}}t.isTerm=l,t.isOrClause=c,t.isAndClause=d,t.isClause=h,t.isQuery=function(e){return l(e)||h(e)},t.hasNsTerm=function(e,t){return null!=f(e,(e=>e.ns===t))},t.findTerm=f,t.flatTerms=function e(t){return l(t)?[t]:(0,r.flatMap)(t.queries,e)},t.isTrueTerm=function(e){return(0,n.isTrue)(e?.not)?(0,n.isFalse)(e?.term):(0,n.isTrue)(e?.term)},t.SetQuerySymbols={not:"¬",and:"∧",or:"∨"},t.NormieQuerySymbols={not:"-",and:"AND",or:"OR"},t.queryToString=function e(i,r=t.SetQuerySymbols){if(null==i)return"";if(l(i)){let e=i.term;return null==i.term.match(/^[a-z]+$/i)&&(e='"'+e.replace(/"/g,'\\"')+'"'),`${(0,n.isTrue)(i.not)?r.not:""}${null==i.ns?"":i.ns+":"+(0,o.toS)(i.op)}${e}`}return"("+i.queries.map((t=>e(t,r))).join(` ${"or"===i.type?r.or:r.and} `)+")"}},7573:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeTerm=t.isAssetTerm=t.AssetTermNs=t.AssetTermDateNs=t.AssetTermBoolNs=t.normalizeQuery=void 0;const r=i(48884),s=i(75020),n=i(40958),a=i(76790),o=i(22573),l=i(38639),u=i(50989),c=i(54993),d=i(44694),h=i(43786);function f(e){return(0,a.sortBy)((0,n.uniqBy)(e,h.queryToString),(e=>[(0,h.isTerm)(e)?0:(0,h.isOrClause)(e)?1:2,(0,h.queryToString)(e).replace(/[¬(]+/g,"")]))}t.normalizeQuery=function e(t){if((0,h.isTerm)(t))return g(t);const i=t.queries.map(e);if(0===i.length)throw new Error("empty query");if(1===i.length)return i[0];const[s,n]=(0,r.partition)(i,h.isTerm),[a,o]=(0,r.partition)(n,(e=>e.type===t.type));for(const e of a)s.push(...e.queries);const l={type:t.type,queries:f([...s,...o])};return l.queries.every((e=>(0,h.isTerm)(e)&&e.not))?e({type:"and"===t.type?"or":"and",queries:f(l.queries.map((e=>({...e,not:!1}))))}):l},t.AssetTermBoolNs=(0,u.strEnum)("deleted","excluded","liked","hidden"),t.AssetTermDateNs=(0,u.strEnum)("date","updated");const m={delete:t.AssetTermBoolNs.deleted,trash:t.AssetTermBoolNs.deleted,trashed:t.AssetTermBoolNs.deleted,exclude:t.AssetTermBoolNs.excluded,remove:t.AssetTermBoolNs.excluded,removed:t.AssetTermBoolNs.excluded,like:t.AssetTermBoolNs.liked,fav:t.AssetTermBoolNs.liked,fave:t.AssetTermBoolNs.liked,faved:t.AssetTermBoolNs.liked,favorite:t.AssetTermBoolNs.liked,favourite:t.AssetTermBoolNs.liked,hide:t.AssetTermBoolNs.hidden,archive:t.AssetTermBoolNs.hidden,archived:t.AssetTermBoolNs.hidden},p={kw:s.TagRoots.Keywords,keyword:s.TagRoots.Keywords,keywords:s.TagRoots.Keywords,dir:s.TagRoots.fs,directory:s.TagRoots.fs,folder:s.TagRoots.fs};function g(e){if((0,o.blank)(e.ns)&&null!=e.term.match(/^\d{4}[-\d]*$/)&&null!=(0,d.queryTermToFuzzyDate)(e.term))return{ns:"date",term:e.term};if("when"===(0,c.toS)(e.ns).toLowerCase())return g({...e,ns:t.AssetTermDateNs.date,term:e.term.replace(/\//g,"-")});let i=(0,o.notBlankOr)(e.ns,e.term).toLowerCase();if(i=m[i]??i,t.AssetTermBoolNs.includes(i)){let t=!(0,l.isFalse)(e.term);return!0===e.not&&(t=!t),{ns:i,term:(0,c.toS)(t)}}if(t.AssetTermNs.includes(i))return{...e,ns:i};if("before"===i||"after"===i){if(null!=e.op)throw new Error(i+": doesn't support operators");const r="after"===i&&!0!==e.not||!0===e.not;return{ns:t.AssetTermDateNs.date,op:r?">":"<",term:e.term}}return i!==e.term.toLowerCase()?{not:e.not,op:e.op,ns:p[i]??i,term:e.term}:e}t.AssetTermNs=(0,u.strEnum)(...t.AssetTermDateNs.values,...t.AssetTermBoolNs.values),t.isAssetTerm=function(e){return(0,h.isTerm)(e)&&t.AssetTermNs.includes(g(e).ns)},t.normalizeTerm=g},33693:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseQuery_=void 0;const s=r(i(31704)),n=i(19851),a=i(50213),o=i(7282),l=i(38835),u=i(31586),c=r(i(70471)),d=(0,n.lazy)((()=>(0,a.mkLogger)("query.QueryParser")));t.parseQuery_=function(e){try{const t=new s.default.Parser(s.default.Grammar.fromCompiled(c.default)).feed(e.trim()).finish();if(t.length>1&&!(0,o.isProd)()&&d().throw("parseQuery(): ambiguous grammar!",{input:e}),null==t[0])throw new Error("invalid query");return d().debug("parseQuery()",{input:e,result:t[0]}),t[0]}catch(t){const i=t.token?.col,r=`Query syntax error${(0,u.gt0)(i)?" around column "+i:""}: "${e}"`;throw d().warn("parseQuery(): bad query",{msg:r,err:t}),new Error(r+l.NonRetriableErrorFlag+l.DoNotSendErrorFlag)}}},23523:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.queryToSql=t.queryStringToSql_=t.defaultAssetQuery=void 0;const r=i(19851),s=i(50213),n=i(66649),a=i(89724),o=i(70417),l=i(28874),u=i(42231),c=i(22573),d=i(38639),h=i(98553),f=i(54993),m=i(57038),p=i(43487),g=i(44694),y=i(43786),v=i(7573),w=i(33693),b=(0,r.lazy)((()=>(0,s.mkLogger)("query.QueryToSql")));function S(e,t,i){if((0,y.isTerm)(t))return function(e,t,i){return(0,v.isAssetTerm)(t)?function(e,t){switch(t.ns){case v.AssetTermNs.date:case v.AssetTermNs.updated:return function(e,t){const i=t.op??"=",r="date"===t.ns?"Asset.capturedAtLocal":"updated"===t.ns?"Asset.updatedAt":void 0;if(null==r)throw new Error("internal error: unexpected namespace for "+(0,h.stringify)(t));const s="Asset.updatedAt"===r?n.datedToMillis:a.maybeDatedToLocal,l=(0,g.queryTermToFuzzyDate)(t.term),u=s(l),c=l?.following()?.toDateTime(),d=s(c?.minus({second:1})),f=(0,o.max)([u,d]);if(null==l||null==u||null==f)throw new Error((0,y.queryToString)(t,y.NormieQuerySymbols)+" can't be parsed as a date");if("="===i)return e.whereBetween(r,[u,f]);if("<"===i)return e.where(r,i,u);if("<="===i)return e.where(r,i,f);if(">="===i)return e.where(r,i,u);if(">"===i)return e.where(r,i,f);throw new Error("internal error: unexpected op for "+(0,h.stringify)(t))}(e,t);case v.AssetTermNs.hidden:return e.where("Asset.hidden",_(t));case v.AssetTermNs.excluded:return M({qb:e,column:"Asset.excludedAt",whereNull:0===_(t)});case v.AssetTermNs.deleted:return M({qb:e,column:"Asset.deletedAt",whereNull:0===_(t)});case v.AssetTermNs.liked:return e.where("Asset.rating",P(t)?">=":"<",l.Settings.likeRating.valueOrDefault);default:throw new Error("not asset term:"+(0,y.queryToString)(t))}}(e,t):function(e,t,i){const r=t.term.startsWith("/"),s="="===t.op,n=function(e,t){if(null==t||"fs"!==e.ns)return e.term;const i=e.term.split("/"),r=i.findIndex(c.notBlank);if(-1===r)return e.term;const s=i[r];return i[r]=t.get(s)??s,i.join("/")}(t,i);if(r||s)return e.whereIn("Asset.id",(0,m.knex)()("AssetTag").join("Tag","Tag.id","AssetTag.tagId").select("assetId").whereLike("Tag._path",t.ns+(r?"":"%")+n.replace(/\//g,u.TagSep).replace(/\*/g,"%")+u.TagSep+(s?"":"%")));let a=(0,m.knex)()("AssetTag").join("tag_fts","tag_fts.rowid","AssetTag.tagId").select("assetId");const o="path:"+T(n.replace(/\//g," + "));if((0,c.blank)(t.ns)){if((0,d.isTrue)(t.not))throw new Error("Cannot negate without a namespace ("+(0,y.queryToString)(t)+")");a=a.where("tag_fts","MATCH",o)}else a=a.where("tag_fts","MATCH","(root:"+T(t.ns)+((0,d.isTrue)(t.not)?" NOT ":" AND ")+o+")");return e.whereIn("Asset.id",a)}(e,t,i)}(e,t,i);for(const r of t.queries)e=(0,y.isAndClause)(t)?e.andWhere((e=>S(e,r,i))):e.orWhere((e=>S(e,r,i)));return e}function P(e){const t=(0,d.isTrue)(e.term);return!0===e.not?!t:t}function _(e){return P(e)?1:0}function T(e){return e.includes("*")?e.split("*").map(T).join(" * "):`"${(0,f.toS)(e).replace(/"/g,'""')}"`}function M({qb:e,column:t,whereNull:i}){return i?e.whereNull(t):e.whereNotNull(t)}function E(){return p.Asset.ops().query().where("Asset.shown",1).join("AssetTag","AssetTag.assetId","Asset.id")}function k(e,t=E(),i){return e=(0,v.normalizeQuery)(e),(0,y.hasNsTerm)(e,v.AssetTermBoolNs.hidden)||(0,y.hasNsTerm)(e,v.AssetTermBoolNs.excluded)||(0,y.hasNsTerm)(e,v.AssetTermBoolNs.deleted)||(t=t.andWhere({"Asset.hidden":0,"Asset.excludedAt":null,"Asset.deletedAt":null})),t.andWhere((t=>S(t,e,i)))}t.defaultAssetQuery=E,t.queryStringToSql_=function(e,t=E()){const i=(0,w.parseQuery_)(e);return null==i?(b().warn("assetQuery("+e+"): parsed to null"),t):k(i,t)},t.queryToSql=k},70471:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};function s(e){return e[0]}Object.defineProperty(t,"__esModule",{value:!0}),t.parseTerm=void 0;const n=r(i(80265)),a=i(40958),o=i(54993);function l(e){if(null==e[0]&&["and","or"].includes((0,o.toS)(e[1]).toLowerCase()))throw new Error("Unmatched "+e[1]);return{not:null!=e[0]?.[0]?.value,ns:e[0]?.[1]?.value,op:e[0]?.[3]?.value,term:e[1]}}function u(e){return e[0]?.value}t.parseTerm=l;const c=n.default.compile({qstr:[{match:/"(?:[^\\"]|\\.)*?"/,value:e=>e.slice(1,-1).replace(/\\"/g,'"')},{match:/'(?:[^\\']|\\.)*?'/,value:e=>e.slice(1,-1).replace(/\\'/g,"'")}],lp:"(",rp:")",not:/[-¬]/,col:":",op:/<=?|>=?|=/,or:/ +(?:or|OR|Or|∨|\|{1,2}) +/,and:/(?:and|AND|And|∧|\&{1,2}) +/,str:/[^\s:\(\)"'][^\s:\(\)]*/,ws:/ +/}),d={Lexer:c,ParserRules:[{name:"Expression$ebnf$1",symbols:[]},{name:"Expression$ebnf$1$subexpression$1",symbols:[c.has("or")?{type:"or"}:or,"Clause"]},{name:"Expression$ebnf$1",symbols:["Expression$ebnf$1","Expression$ebnf$1$subexpression$1"],postprocess:e=>e[0].concat([e[1]])},{name:"Expression",symbols:["Clause","Expression$ebnf$1"],postprocess:function(e){const t=(0,a.compact)([e[0],...e[1].map((e=>e[1]))]);return 1===t.length?t[0]:{type:"or",queries:t}}},{name:"Clause$ebnf$1",symbols:[]},{name:"Clause$ebnf$1$subexpression$1$ebnf$1",symbols:[c.has("and")?{type:"and"}:and],postprocess:s},{name:"Clause$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"Clause$ebnf$1$subexpression$1",symbols:["__","Clause$ebnf$1$subexpression$1$ebnf$1","Factor"]},{name:"Clause$ebnf$1",symbols:["Clause$ebnf$1","Clause$ebnf$1$subexpression$1"],postprocess:e=>e[0].concat([e[1]])},{name:"Clause",symbols:["Factor","Clause$ebnf$1"],postprocess:function(e){const t=(0,a.compact)([e[0],...e[1].map((e=>e[2]))]);return 1===t.length?t[0]:{type:"and",queries:t}}},{name:"Factor",symbols:["Term"],postprocess:s},{name:"Factor",symbols:[c.has("lp")?{type:"lp"}:lp,"_","Expression","_",c.has("rp")?{type:"rp"}:rp],postprocess:function(e){const t=(0,a.compact)(e[2]);return 1===t.length?t[0]:t}},{name:"Term$ebnf$1$subexpression$1$ebnf$1",symbols:[c.has("not")?{type:"not"}:not],postprocess:s},{name:"Term$ebnf$1$subexpression$1$ebnf$1",symbols:[],postprocess:()=>null},{name:"Term$ebnf$1$subexpression$1$ebnf$2",symbols:[c.has("op")?{type:"op"}:op],postprocess:s},{name:"Term$ebnf$1$subexpression$1$ebnf$2",symbols:[],postprocess:()=>null},{name:"Term$ebnf$1$subexpression$1",symbols:["Term$ebnf$1$subexpression$1$ebnf$1",c.has("str")?{type:"str"}:str,c.has("col")?{type:"col"}:col,"Term$ebnf$1$subexpression$1$ebnf$2"]},{name:"Term$ebnf$1",symbols:["Term$ebnf$1$subexpression$1"],postprocess:s},{name:"Term$ebnf$1",symbols:[],postprocess:()=>null},{name:"Term",symbols:["Term$ebnf$1","Value"],postprocess:l},{name:"Value",symbols:[c.has("qstr")?{type:"qstr"}:qstr],postprocess:u},{name:"Value",symbols:[c.has("str")?{type:"str"}:str],postprocess:u},{name:"_$ebnf$1",symbols:[c.has("ws")?{type:"ws"}:ws],postprocess:s},{name:"_$ebnf$1",symbols:[],postprocess:()=>null},{name:"_",symbols:["_$ebnf$1"]},{name:"__",symbols:[c.has("ws")?{type:"ws"}:ws]}],ParserStart:"Expression"};t.default=d},22968:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybeRebuildLibrary=t.forceRebuildLibraryLater=t.rebuildLibraryOperationCrit=void 0;const r=i(45393),s=i(28874),n=i(98553),a=i(43487),o=i(54017),l=i(20958),u=i(33567);function c(){return{name:l.OperationNames.rebuildLibrary,value:(0,n.stringify)({AssetVersion:r.AssetVersion,AssetFileVersion:r.AssetFileVersion})}}t.rebuildLibraryOperationCrit=c,t.forceRebuildLibraryLater=function(){a.Asset.dbl.runf((e=>e.update({version:0}))),o.AssetFile.dbl.runf((e=>e.update({version:0}))),l.Operation.dbl.runf((e=>e.where(c()).delete()))},t.maybeRebuildLibrary=async function(){return s.Settings.skipLibraryRebuild.valueOrDefault?void 0:l.Operation.applyOnce_(c(),(()=>(new u.LibraryRebuild).doneLatch))}},33567:function(e,t,i){"use strict";var r,s,n,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LibraryRebuild=void 0;const c=i(19851),d=i(83412),h=i(25764),f=i(8769),m=i(76752),p=i(28874),g=i(15674),y=i(22573),v=i(42659),w=i(31586),b=i(12168),S=i(12236),P=i(35580),_=i(49796),T=i(94710),M=i(18209);class E extends d.DoneWrapper{constructor(){super("LibraryRebuild",(()=>u(this,r,"m",a).call(this)),h.EndableRanks.first),r.add(this),this.assetFileEta=new m.ETA,this.assetEta=new m.ETA,this.assetFilesUpdated=0,this.assetsUpdated=0,this.initialAssetFileTodoCount=(0,c.lazy)(M.outdatedAssetFileCount),this.initialAssetTodoCount=(0,c.lazy)(M.outdatedAssetCount),s.set(this,(0,c.lazy)((()=>_.Progress.insertNew({uri:S.RebuildingURI,volume:"🔄",scanningPct:0})))),o.set(this,((e,t,i)=>{"updateAssetFile"===e.fn?(this.assetFilesUpdated++,this.assetFileEta.push(i),u(this,r,"m",n).call(this)):"updateAsset"===e.fn&&(this.assetsUpdated++,this.assetEta.push(i),u(this,r,"m",n).call(this))})),T.Task.ee.on("resolved",u(this,o,"f")),this.doneLatch.observe(u(this,r,"m",l).call(this))}async assetFileTodo(){return await this.initialAssetFileTodoCount()-this.assetFilesUpdated}async assetTodo(){return await this.initialAssetTodoCount()-this.assetsUpdated}}t.LibraryRebuild=E,s=new WeakMap,o=new WeakMap,r=new WeakSet,n=async function({force:e=!1,done:t=!1}={}){const i=u(this,s,"f").call(this);if(e||!(0,w.gt)(i.updatedAt,Date.now()-v.secondMs))if((t??this.isDone())&&"done"!==i.state){const e=[];this.assetFilesUpdated>0&&e.push(`Updated file metadata for ${(0,b.fmt)(this.assetFilesUpdated)} files`),this.assetsUpdated>0&&e.push(`Refreshed ${(0,b.fmt)(this.assetsUpdated)} assets`),i.dek=e,i.upsert({state:"done",hed:"Finished rebuilding your library 🎉",completePct:100,incompletePct:0,scanningPct:0})}else{let e="Rebuilding your library";const t=await this.assetFileTodo(),r=await this.assetTodo(),s=(this.assetFileEta.etaMs(t/(0,g.maxConcurrentImports)())??0)+(this.assetEta.etaMs(r)??0),n=[];t>0&&n.push(`Updating file metadata (${(0,b.fmt)(this.assetFilesUpdated)} processed, ${(0,b.fmt)(t)} remain)`),r>0&&n.push(`Refreshing assets and previews (${(0,b.fmt)(this.assetsUpdated)} processed, ${(0,b.fmt)(r)} remain)`);const a=t+r,o=this.assetFilesUpdated+this.assetsUpdated,l=(0,w.clamp)(0,100,Math.round(o/(a+o)*100)),u=(0,m.fmtEstimate)(s);(0,y.notBlank)(u)&&(e+=", "+u+"…"),i.dek=n,i.upsert({state:"processing",hed:e,completePct:l,incompletePct:100-l,scanningPct:0})}},a=function(){T.Task.ee.off("resolved",u(this,o,"f"))},l=async function(){this.logger.info("Starting library rebuild...");const e=p.Settings.forceFilters.getState();try{p.Settings.forceFilters.envValue=!0;const e=P.TaskList.instance(),t=await this.assetFileTodo(),i=await this.assetTodo();if(this.logger.info(".run()",{assetFileTodo:t,assetTodo:i}),0===t&&0===i)return;let s=!1;for(;!s;)s=(await(0,M.enqueueAssetFileUpdates)()).done,this.logger.info("run(): waiting for asset updates to complete..."),await e.awaitDrain(["updateAssetFile"],s?0:p.Settings.taskListCap.valueOrDefault/2);for(s=!1;!s;)s=(await(0,M.enqueueAssetUpdates)()).done,await e.awaitDrain(["repairAsset","assetPostUpsertTasks"],s?0:p.Settings.taskListCap.valueOrDefault/2);await u(this,r,"m",n).call(this,{done:!0,force:!0}),this.logger.info("rebuild complete!")}catch(e){(0,f.onError)("LibraryUpdater.run() failed",e)}finally{p.Settings.forceFilters.setState(e)}}},18209:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.enqueueAssetUpdates=t.outdatedAssetCount=t.enqueueAssetFileUpdates=t.outdatedAssetFileCount=t.currentUriRoots=void 0;const r=i(50213),s=i(45393),n=i(70417),a=i(45200),o=i(5696),l=i(7014),u=i(40958),c=i(45599),d=i(41400),h=i(20214),f=i(54993),m=i(43487),p=i(54017),g=i(94710),y=(0,c.defer)((()=>(0,r.mkLogger)("sync.UpdateQueue")));async function v(){return[...await(0,h.thenCollect)((0,l.volumes)(),(async e=>(0,a.nativePath2uri)(e.mountpoint,e))),o.PSLIB_ROOT_URI].map(f.toS)}t.currentUriRoots=v,t.outdatedAssetFileCount=async function(){const e=await v();return p.AssetFile.dbl.pluckFirstf((t=>t.count("AssetFile.id").distinct().where("version","!=",s.AssetFileVersion).andWhere((t=>e.forEach((e=>t.orWhereLike("AssetFile.uri",e+"%")))))))},t.enqueueAssetFileUpdates=async function(){const e=[];for(const t of await v())e.push(await p.AssetFile.dbl.batched({maxResults:g.Task.freeSlots(),onResults:async e=>{const t=[];for(const i of e)t.push({fn:"updateAssetFile",args:{assetFileId:i.id,path:await(0,a.uri2nativePath)(i.uri),skipAssetRepair:!0}});g.Task.add(t),y().info("Scheduled updateAssetFile",{tasks:t})},qb:(e,i)=>(e=e.select({id:"AssetFile.id",uri:"AssetFile.uri"}).distinct().orderBy("AssetFile.id","asc").where("AssetFile.version","!=",s.AssetFileVersion).andWhereLike("AssetFile.uri",t+"%"),(0,u.isNotEmpty)(i)&&(e=e.andWhere("AssetFile.id",">",(0,n.max)(i.map((e=>e.id))))),e)}));return y().tap({msg:"enqueueAssetFileUpdates",level:"info",result:{done:e.every((e=>e.done)),tasksAdded:(0,n.sumf)(e,(e=>e.resultCount))}})},t.outdatedAssetCount=async function(){const e=await v();return m.Asset.dbl.pluckFirstf((t=>t.count("Asset.id").distinct().leftJoin("AssetFile","AssetFile.assetId","Asset.id").where("Asset.version","!=",s.AssetVersion).andWhere((t=>e.forEach((e=>t.orWhereLike("AssetFile.uri",e+"%")))))))},t.enqueueAssetUpdates=async function(){const e=[];for(const t of await v())e.push(await m.Asset.dbl.pluckBatched({maxResults:g.Task.freeSlots(),onResults:e=>(g.Task.add(e.map((e=>({fn:"repairAsset",args:{assetId:e}})))),y().info("Scheduled repairAsset for ",{assetIds:e}),(0,d.delay)(1)),qb:(e,i)=>(e=e.select("Asset.id").distinct().leftJoin("AssetFile","AssetFile.assetId","Asset.id").orderBy("Asset.id","asc").where("Asset.version","!=",s.AssetVersion).andWhereLike("AssetFile.uri",t+"%"),(0,u.isNotEmpty)(i)&&(e=e.andWhere("Asset.id",">",(0,n.max)(i))),e)}));return y().tap({msg:"enqueueAssetUpdates",level:"info",result:{done:e.every((e=>e.done)),tasksAdded:(0,n.sumf)(e,(e=>e.resultCount))}})}},3996:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileFinder=t.isFileInSync=void 0;const o=i(19851),l=i(50213),u=i(79781),c=i(56519),d=i(56038),h=i(59189),f=i(38835),m=i(95696),p=i(48368),g=i(181),y=i(69589),v=i(28874),w=i(47783),b=i(87001),S=i(40958),P=i(76790),_=i(22573),T=i(42659),M=i(55835),E=i(31586),k=i(43487),D=i(54017);t.isFileInSync=async function(e){return new C(m.PosixFile.for(e)).alreadySynced()};const x=new h.SerialLaterQueue;class C{constructor(e,t=(0,y.forceContextOrSetting)()){this.file=e,this.ctx=t,r.set(this,void 0),s.set(this,new Set),this.alreadySynced=(0,d.timedLazy)("sync-file.AssetFileFinder.alreadySynced: "+this.file,(async()=>a(this,r,"f").tap({msg:"alreadySynced",result:null!=await this.priorIfSynced()}))),this.newAssetFile_=(0,d.timedLazy)("sync-file.AssetFileFinder.newAssetFile: "+this.file,(async()=>{const e=await(new D.AssetFile).updateFromFile_(this.file);return null==e?a(this,r,"f").throw("AssetFile.updateFromFile returned null",{fatal:!1}):e})),this.tags_=(0,o.lazy)((async()=>{const e=await(0,w.readTags)(this.file);if(null==e)throw new Error(this.file+" doesn't have metadata");return e})),this.imageHash=(0,o.lazy)((()=>v.Settings.useImageHashes.valueOrDefault?(0,p.imageHash)(this.file):void 0)),this.dominantLabhashes=(0,o.lazy)((()=>(0,c.thenMap)(this.imageHash(),(e=>(0,S.uniq)(e.dominantColors.filter((e=>e.pct>5)).map((e=>e.labhash))))))),this.capturedAtLocal=(0,o.lazy)((async()=>{const e=await this.capturedAt_();return a(this,r,"f").tap({msg:"capturedAtLocal",result:e?.local,meta:{capturedAt:e}})})),this.mapSibling=e=>this.newAssetFileForAsset(e?.getAsset()),this.apply_=(0,d.timedLazy)("sync-file.AssetFileFinder: "+this.file,(async()=>{if((0,_.blank)(await this.file.uri_()))throw new Error("Cannot import, file URI is blank for "+this.file);{const e=await this.byExistingAsset_();if(null!=e)return a(this,r,"f").info("Found existing asset for file"),e}const e=await this.newAssetFile_(),t=await x.enqueue((async()=>{const t=await this.byExistingAsset_();if(null!=t?.assetId)return a(this,r,"f").info("Found existing asset for file after acquiring lock",{withExistingAsset:t}),t.assetId;const i=new k.Asset;return i.capturedAtLocal=e.capturedAtLocal,i.addAssetFile(e),i.upsert(),i.id}));return e.assetId=t,e.upsert()})),this.byExistingAsset_=()=>(0,d.time)("sync-file.AssetFileFinder.byExistingAsset: "+this.file,(async()=>{const e=[{name:"byUri",f:()=>this.byUri()},{name:"byNormalizedPathUri",f:()=>this.newAssetFileForAsset(this.assetByNormalizedPathUri())},{name:"bySha",f:()=>this.newAssetFileForAsset(this.assetBySha())},{name:"hasTags",f:async()=>{await this.tags_()}},{name:"validFile",f:async()=>{await(0,g.throwIfInvalidFile_)(this.file)}},{name:"byCapturedAtOrImageHash",f:()=>this.newAssetFileForAsset(this.assetByCapturedAtOrImageHash())}];for(const{name:t,f:i}of e)try{const e=await(0,d.time)("sync-file.assetFileFinder."+t+": "+this.file,i);if(null!=e)return a(this,r,"f").info("apply(): "+t,{assetFileId:e.id,assetId:e.assetId}),e;a(this,r,"f").debug("apply(): "+t+": returned null")}catch(e){throw a(this,r,"f").debug("apply(): "+t+" rejected: "+e),e}})),n(this,r,(0,l.mkLogger)("sync-file.AssetFileFinder("+e.baseWithGrandparent+")"),"f")}async prior(){return this.byUri()}async priorIfSynced(){if(this.ctx.forceSync)return;const e=await this.prior();return!0===await(e?.matchesFile())?e:void 0}async newAssetFileForAsset(e){const t=await e;if(null!=t){if(null!=t.id){const e=await this.newAssetFile_();return t.addAssetFile(e),e.insert(),a(this,r,"f").debug("newAssetFileForAsset() upsert success!",{af:e}),e}a(this,r,"f").throw("newAssetFileForAsset(): given non-persisted Asset")}}async capturedAt_(){return(await this.tags_()).capturedAt}async byUri(e=this.file){const t=await e.uri_();if(null!=t)return D.AssetFile.ops().firstf((e=>e.whereIn("uri",[...(0,b.uriEncodingVariants)(t),this.file.fileuri()])));a(this,r,"f").warn("byUri() uri is null",{file:e})}async assetByNormalizedPathUri(){const e=await this.file.normalize();return e.nativePath===this.file.nativePath?void 0:(await this.byUri(e))?.getAsset()}assetBySha(){return(0,c.thenMap)(this.file.sha(),(e=>k.Asset.findFirstByFile((t=>t.where("AssetFile.sha",e)))))}async assetByCapturedAtOrImageHash(){const e=await this.capturedAt_();if(null==e)return a(this,r,"f").throw("Cannot import, capturedAt is null"+f.InternalErrorFlag);if(v.Settings.strictDeduping.valueOrDefault)return this.firstSimilarAsset(D.AssetFile.ops().allf((t=>t.where({capturedAtLocal:e.local}))));const t=v.Settings.maxContemporaryAdoptionAssets.valueOrDefault,i=()=>{let i=D.AssetFile.query();return(0,E.gt0)(t)&&(i=i.limit(t)),i.orderByRaw(`abs(capturedAtLocal - ${e.local})`)},s=Math.max(T.secondMs,v.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault);return(0,d.time)("sync-file.AssetFileFinder.assetByCapturedAtAndImageHash: "+this.file,(async()=>{{const t=e.localBoundaries({delta:s});if(null==t)a(this,r,"f").warn("Failed to fetch localBoundaries, cannot fetch similar assets by localtime",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("captured-at",i().whereBetween("capturedAtLocal",[t.start,t.end]))??(v.Settings.checkBasenameMatches.valueOrDefault?this.firstSimilarAssetByQuery("basename",i().whereILike("uri","%/"+this.file.name+"%")):void 0);if(null!=e)return e}}const t=await this.imageHash();if(null==t)return void a(this,r,"f").warn("assetByCapturedAtAndImageHash: no imageHash");const n=await this.dominantLabhashes();if((0,S.isNotEmpty)(n)){const t=e.localBoundaries({delta:4*s});if(null==t)a(this,r,"f").error("Failed to fetch localBoundaries, cannot fetch similar assets by wide localtime + image hash",{ca:e,delta:s});else{const e=this.firstSimilarAssetByQuery("wide captured-at and dominant color",i().whereBetween("capturedAtLocal",[t.start,t.end]).andWhere((e=>e.whereIn("mode0",n).orWhereIn("mode1",n).orWhereIn("mode2",n))));if(null!=e)return e}}return this.firstSimilarAssetByQuery("image hash",i().where("meanHash",t.meanHash).orWhere("diffHash",t.diffHash).orWhere("dctHash",t.dctHash))}))}async firstSimilarAssetByQuery(e,t){a(this,s,"f").size>0&&(t=t.whereNotIn("AssetFile.id",Array.from(a(this,s,"f"))));const i=await this.firstSimilarAsset(D.AssetFile.ops().all(t));return null!=i&&a(this,r,"f").info("Found similar asset by "+e,{result:i}),i}async firstSimilarAsset(e){const t=await this.newAssetFile_(),i=await this.capturedAtLocal();if(null==t)throw new Error("Failed to update from "+this.file);const n=(0,P.sortBy)(e.filter((e=>!a(this,s,"f").has(e.id))),(e=>[(0,M.mapOr)(i,(t=>Math.abs(e.capturedAtLocal-t)),-e.capturedAtLocal),e.id]));for(const e of n)if(null!=e){await e.getNativePath();const i=D.AssetFile.ops().findBy({assetId:e.assetId});await Promise.all(i.map((e=>e.getNativePath())));const n=(0,u.whyNotSameAsset)(t,e,i);if(null==n)return a(this,r,"f").info("Found sibling AssetFile",e),k.Asset.ops().findById(e.assetId);a(this,s,"f").add(e.id),a(this,r,"f").debug("Contemporary assetFile not similar: "+n,e?.uri)}}}t.AssetFileFinder=C,r=new WeakMap,s=new WeakMap},34274:function(e,t,i){"use strict";var r,s,n,a,o=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i},l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileImporter=t.importFileToResult_=void 0;const u=i(19851),c=i(50213),d=i(73568),h=i(38835),f=i(95696),m=i(62105),p=i(74128),g=i(181),y=i(69589),v=i(28874),w=i(40958),b=i(22573),S=i(38639),P=i(59455),_=i(64526),T=i(19113),M=i(94710),E=i(3996),k=i(90901);t.importFileToResult_=async function(e){const t=_.Library.instanceRequired_();return(0,p.syncReport)().wrap_({path:e.path,from:"AssetFileImporter",fn_:()=>new D(f.PosixFile.for(e.path),t.assetFileRepository(),e).apply_()})};class D{constructor(e,t,i){r.add(this),this.file=e,this.repo=t,this.start=Date.now(),s.set(this,void 0),n.set(this,void 0),this.whyRejected=(0,u.lazy)((async()=>{const e=[],t=await this.file.uri_();if(null==t)e.push("Cannot make URI"+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);else{if(!0===await this.file.isDeletedUri(t))e.push("File was deleted");else if(this.ctx.forceFilters||null==await this.prior()){const t=await(0,m.whyRejectFile)(this.file,(0,T.libraryFileFiltersFor)(this.file));null!=t&&e.push(t)}l(this,s,"f").throwIfAborted_();const i=await this.prior();if((0,w.isNotEmpty)(e)&&null!=i&&(l(this,s,"f").info("Deleting prior AssetFile",{rejected:e,prior:i}),i.delete(),this.ctx.skipAssetRepair?l(this,s,"f").info("Skipping asset repair",{assetId:i.assetId}):(l(this,s,"f").info("Scheduling asset repair",{assetId:i.assetId}),M.Task.addOne("repairAsset",{assetId:i.assetId,forceRebuildPreviews:(0,S.isTrue)(i.shown)}))),null!=i){const t=i.getAsset();null!=t?.deletedAt&&e.push("Asset is marked as deleted"),null!=t?.excludedAt&&e.push("Asset is marked as excluded")}if(l(this,s,"f").throwIfAborted_(),0===e.length&&(null==i||!await i.inSyncWithFile())){const t=await(0,g.whyInvalidFile)(this.file.nativePath);(0,b.blank)(t)||e.push(t)}}return e})),this.assetFile_=(0,u.lazy)((async()=>{const e=await l(this,n,"f").apply_(),t=e.getAsset();return l(this,s,"f").info("assetFileFinder.apply_() result",{asset:t,assetFile:e}),null==t?l(this,s,"f").throw("assetFile.getAsset() was null",{srcAssetFile:e}):null==t.id?l(this,s,"f").throw("repoAssetFile asset has null id",{asset:t}):e})),this.prior=(0,u.lazy)((()=>l(this,n,"f").prior())),this.apply_=(0,u.lazy)((()=>l(this,r,"m",a).call(this))),this.ctx=(0,y.forceContextOrSetting)(i),o(this,s,(0,c.mkLogger)("sync-file."+this.toString()),"f"),o(this,n,new E.AssetFileFinder(e,this.ctx),"f")}toString(){return"AssetFileImporter("+this.file.nativePath+")"}newAssetFile(){return l(this,n,"f").newAssetFile_()}}t.AssetFileImporter=D,s=new WeakMap,n=new WeakMap,r=new WeakSet,a=async function(){l(this,s,"f").throwIfAborted_();const e=await l(this,s,"f").tapAsync_({msg:"whyRejected",result:this.whyRejected(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if((0,w.isNotEmpty)(e)){const t=e.join(", ");return{path:this.file.nativePath,state:p.SyncFileStates.rejected,details:t}}l(this,s,"f").throwIfAborted_();const t=await l(this,s,"f").tapAsync_({msg:"prior()",result:this.prior(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if(null!=t&&await t.isNoop(this.ctx))return{path:this.file.nativePath,state:p.AssetFileSyncStates.noop,assetId:t.assetId,assetFileId:t.id,assetFile:t,asset:t.getAsset(),uri:t.uri};l(this,s,"f").throwIfAborted_();const i=await l(this,s,"f").tapAsync_({msg:"assetFile()",result:this.assetFile_(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault});if(null==i)return l(this,s,"f").throw("_apply(): unexpected null assetFile");const r=i.id;if(null==r)return l(this,s,"f").throw("_apply(): unexpected null assetFileId");const n=i.uri;if(null==n)return l(this,s,"f").throw("_apply(): unexpected null assetFile.uri");const a=i.getAsset();if(null==a)return l(this,s,"f").throw("_apply(): unexpected null assetFile.getAsset()");let o;await l(this,s,"f").tapAsync_({msg:"assetFile.upsertIfNeeded_()",result:i.upsertIfNeeded_(),timeoutMs:v.Settings.taskTimeoutMs.valueOrDefault}),l(this,s,"f").throwIfAborted_();try{o=await(0,k.assetPostUpsertTasks_)({asset:a,...this.ctx})}catch(e){e instanceof d.AbortError?l(this,s,"f").warn("aborted (caller/process after me will complete)",{error:e}):l(this,s,"f").throw("Post-upsert tasks failed",{error:e})}return{path:this.file.nativePath,state:i.syncState??p.SyncFileStates.synced,assetId:a.id,assetFileId:r,assetFile:i,asset:a,uri:n,uris:[n,...(0,P.toA)(o?.newAssetFileUris)]}}},41844:function(e,t,i){"use strict";var r,s,n,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileRepository=t.mayCopyAssetsToLibrary=void 0;const u=i(50213),c=i(74128),d=i(81674),h=i(57902),f=i(4936),m=i(28874),p=i(47783),g=i(67083),y=i(16170),v=i(54979),w=i(98604),b=i(40958),S=i(22573),P=i(98553),_=i(89937),T=i(59455),M=i(54017),E=i(94710);t.mayCopyAssetsToLibrary=async function(){return m.Settings.copyAssetsToLibrary.valueOrDefault&&await(0,d.p)()},t.AssetFileRepository=class{constructor(e){r.add(this),this.originalsDir=e,this.logger=(0,u.mkLogger)("AssetFileRepository")}async shouldCopy(e){const t=await this.whyNotCopyFile(e);return this.logger.tap({level:"info",msg:"shouldCopy()",result:null==t,meta:{file:e?.nativePath,whyNot:t}})}async whyNotCopyFile(e){if(null==e||(0,S.blank)(e.nativePath))return"blank nativePath";if(!0!==m.Settings.copyAssetsToLibrary.value)return"copyAssetsToLibrary !== true";if(await(0,d.l)())return"no active subscription";if(await e.notExists({refresh:!0}))return"file doesn't exist";if(e.isDescendantOf(this.originalsDir))return e+" already contained by "+this.originalsDir;if(e.isDescendantOf(m.Settings.libraryDir.valueOrDefault))return e+" already contained by "+m.Settings.libraryDir.valueOrDefault;const t=await(0,v.readMimeType)(e);return null==t?"readMimeType("+e+") was null":(0,y.isMimeTypeIncluded)(t,m.Settings.copyToLibraryMimeTypes.values)?null:"mimetype "+t+" is not included in copyToLibraryMimeTypes"}async existingLibraryAssetFile(e){if(e.uri.startsWith(_.PS_LIBRARY_PROTOCOL))return e;const t=(0,b.uniqBy)((0,T.toA)(e.librarySiblings()?.filter((t=>t.sha===e.sha))).concat(M.AssetFile.sameAssetFileInLibrary(e)),(e=>e.id));for(const i of t)if(await i.exists()){if(i.assetId!==e.assetId){this.logger.warn("Existing library asset file with a matching SHA is associated to a different asset. Requesting repair of the two impacted assets.",{af:e,prior:i});const t=i.assetId;e.getAsset()?.addAssetFile(i),E.Task.addOne("repairAsset",{assetId:t,forceSync:!0})}return this.logger.info("whyNotCopyAssetFile("+e.uri+"): found existing db record",{af:e,prior:i}),i}return null}async findLibraryFileWithSameContents(e,t){if(await e.matchesContent(t))return t;let i=t.parent();for(;i.isSelfOrDescendantOf(this.originalsDir);){const t=i.childWithSameContents(e);if(null!=t)return t;i=i.parent()}}async importFile_(e){const t=await l(this,r,"m",s).call(this,e);return null!=t&&(await l(this,r,"m",n).call(this,e,t),await l(this,r,"m",o).call(this,e,t)),t}async maybeCopyToLibrary_(e,t){const i=Date.now(),s=await e.posixFile_();null==s&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): posixFile is null",{ignorable:!1,retriable:!1});{const e=await this.whyNotCopyFile(s);if(!(0,S.blank)(e))return this.logger.tap({level:h.LogLevels.info,msg:"maybeCopyToLibrary_(): not copying: "+e,result:void 0})}const a=e.getAsset();null==a&&this.logger.throw("maybeCopyToLibrary_("+e.uri+"): null asset");{const u=await this.existingLibraryAssetFile(e);if(null!=u){const e=await u.posixFile_();if(null!=e){const d=await l(this,r,"m",n).call(this,s,e),h=null!=await l(this,r,"m",o).call(this,s,e),f=null!=await u.upsertIfNeeded_(void 0,t);return!h&&(0,b.isEmpty)(d)&&!f||(0,c.syncReport)().onProgress({path:e.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.synced,details:"Found and synced prior replica already in your library "+(0,P.stringify)({src:s.nativePath,upsertNeeded:f,copiedSidecars:d,copiedInferredMetadata:h}),elapsedMs:Date.now()-i,url:(0,w.mkAssetUrl)(a.id)?.toString()}),u}this.logger.warn("existingLibraryAssetFile() returned an assetFile that could not be resolved to a PosixFile",{prior:u})}}const u=await this.importFile_(s);if(null==u)return void this.logger.info("importFile() returned null",{srcAssetFile:e});if(u.nativePath===s.nativePath)return void this.logger.info("importFile() returned the same nativePath as src",{srcAssetFile:e,dest:u});const d=await a.assetFileForFile_(u,{skipUpsert:!0});await d.updateFromShaSibling_(e);const f=d.upsert();return a.addAssetFile(d),(0,c.syncReport)().onProgress({path:u.nativePath,from:"maybeCopyToLibrary()",state:c.SyncFileStates.copied,details:"Copied into your library from "+s.nativePath,elapsedMs:Date.now()-i,url:(0,w.mkAssetUrl)(a.id)?.toString()}),f}},r=new WeakSet,s=async function(e){const t=await(0,p.readCapturedAt)(e),i=(0,f.pathToLibraryAsset)(t?.date,e);if(this.logger.debug("importFile("+e+")",{capturedAt:t,assetPath:i}),null==i)throw new Error(e.nativePath+" failed to create a library path");const r=this.originalsDir.join(...i),s=await this.findLibraryFileWithSameContents(e,r);if(null!=s)return this.logger.debug("#importFile_("+e+"): found existing file",{src:e,existing:s}),s;const n=await r.ensureNew_();return this.logger.info("#importFile_("+e+"): copying...",{uniqDest:n,dest:r}),e.copyFile_(n)},n=async function(e,t){const i=await e.existingSidecars(),s=[];for(const e of i)s.push(await l(this,r,"m",a).call(this,e,t));return(0,b.compact)(s)},a=async function(e,t){for(const i of await t.existingSidecars())if(await(0,p.sidecarEql)(e,i))return void this.logger.info("handleSidecar(): metadata already exists.",{srcSidecar:e,destSidecar:i,dest:t});const i=await t.parent().join(t.name+e.ext).ensureNew_({emptyIsNew:!0});return e.copyFile_(i)},o=async function(e,t){if(null==e||null==t||e.eql(t))return;const i=await(0,p.readTags)(e);if(null!=i)return(0,g.ensureInferredHistoryRecords)(e,await t.sidecar(),i.inferred);this.logger.warn("#handleInferred(): Failed to read tags from "+e,{dest:t})}},90901:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assetPostUpsertTasks_=t.assetPostUpsertTasks=void 0;const r=i(50213),s=i(92434),n=i(73568),a=i(99331),o=i(39250),l=i(38835),u=i(57159),c=i(48604),d=i(66106),h=i(69589),f=i(40958),m=i(45599),p=i(23838),g=i(31586),y=i(64526),v=i(88224),w=i(43487),b=i(41844),S=i(68640),P=(0,m.defer)((()=>(0,r.mkLogger)("sync-file.AssetPostUpsertTasks"))),_=(0,m.defer)((()=>new o.LastOneInWins("Asset tasks")));async function T(e){const t=e,i=e,r=(0,g.toGt0)(t.asset?.id)??(0,g.toGt0)(i.assetId);if(null==r)throw new Error("assetPostUpsertTasks_(): unexpected null assetId"+l.InternalErrorFlag);const o=(0,h.forceContextOrSetting)(e),m=P().addContext(`.postUpsertAssetTasks_(Asset:${r})`);if(m.abortable=o.halt,o.skipPreviews&&o.skipAssetTagging)return void m.info("skipped (skipPreviews && skipAssetTagging)");const T=t.asset??w.Asset.ops().findById(r);if(null==T)return m.throw("unexpected null asset",{asset:T});try{return await _().enqueue({key:r,abortable:m.abortable,fn:()=>async function(e,t,i){const r=(0,h.forceContextOrSetting)(i),n=t.id,a=t.getAssetFiles({refresh:!0}),o={newAssetFileUris:[],previewsUpdated:!1,tagResult:void 0,transcoded:!1};if(e.throwIfAborted_(),(0,f.isEmpty)(a)&&(await w.Asset.remove({assetId:n,blocklistShas:!1,unlinkAssetFiles:!1}),e.throw(`Asset:${n} had no asset files. Deleted.`)),await(0,b.mayCopyAssetsToLibrary)())for(const[t,i]of(0,p.groupBy)(a,(e=>e.sha)).entries()){e.throwIfAborted_();try{for(const r of i)r.isInLibrary()&&await r.exists()&&e.debug("no-op for file SHA: already in library.",{sha:t,uri:r.uri});for(const e of i)if(await e.exists()){const t=await y.Library.instanceRequired_().assetFileRepository().maybeCopyToLibrary_(e,r);if(null!=t){o.newAssetFileUris.push(t.uri);continue}}}catch(r){e.warn("Failed to copy variation to library, but we'll try to continue",{sha:t,uris:i.map((e=>e.uri)),error:r})}}e.throwIfAborted_();const l=r.skipPreviews?void 0:await(0,S.updateAssetPreviews_)({asset:t,assetFiles:t.getAssetFiles(),...r}),u=await async function(e,t){if((0,g.gt0)(t?.assetFileId)){const i=e.getAssetFiles({refresh:!0}).find((e=>e.id===t?.assetFileId));return null==i?P().throw("AssetPreviewInfo referenced unknown assetFileId",{asset:e,info:t}):i}const i=e.getShown();return null!=i?i:(0,s.bestExistingAssetFile)(e.getAssetFiles())}(t,l);if(null==u)return e.throw("null primaryOrShownAssetFile_()",{asset:t});const m=await u.posixFile_();if(!0!==r.skipPreviews&&t.isVideo()){if(null==m)return e.throw("null primary.posixFile()",{asset:t,assetFiles:t.getAssetFiles()});o.transcoded=null!=await(0,d.transcode_)(m,c.Previews.instance().ap(n).mp4(),{force:r.forceRebuildPreviews,halt:r.halt})}return e.throwIfAborted_(),t.markShownAndUpsert_(u),r.skipAssetTagging?e.info("skipping asset tagging"):o.tagResult=await(0,v.tagAndUpsertAsset_)(t),o}(m,T,{...e,...o})})}catch(e){if(e instanceof n.AbortError)return void m.warn("aborted, next caller will clean up my mess",{error:e});const t=[e];if(!(0,a.ending)()){m.error("failed, marking asset unshown",{error:e});try{T.markUnshownAndUpsert()}catch(e){m.error("failed to mark asset unshown",{upsertError:e}),t.push(e)}}throw new u.WrappedError("Failed to post-process assset "+T.id,{causes:t})}}t.assetPostUpsertTasks=function(e){try{return T(e)}catch(e){if(e instanceof n.AbortError)return void P().warn("aborted, next caller will clean up my mess",{error:e});throw e}},t.assetPostUpsertTasks_=T},61989:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAsset_=t.updateAsset=void 0;const r=i(48884),s=i(50213),n=i(45393),a=i(79184),o=i(79781),l=i(92434),u=i(56519),c=i(70417),d=i(69589),h=i(28874),f=i(40958),m=i(22573),p=i(38639),g=i(50357),y=i(43487),v=i(54017),w=i(90901);async function b(e){const t=(0,d.forceContextOrSetting)(e),i=e.assetId,r=(0,s.mkLogger)(`sync-file.UpdateAsset(${i})`);r.abortable=t.halt;const b=y.Asset.ops().findById(i);if(null==b)return r.throw("no such asset");const P=b.getAssetFiles({refresh:!0});if((0,f.isEmpty)(P))return r.warn("No asset files: deleting."),b.delete(),{asset:b,rejected:"Empty asset (no AssetFiles)"};const _=b.$clone(),T=b.getShown()?.$clone();for(const e of P)r.throwIfAborted_(),await e.upsertIfNeeded_(void 0,t);P.some((e=>(0,p.isTrue)(e.deleted)||(0,m.notBlank)(e.rejected)))&&b.clear(),await S(r,P);const M=(0,l.sortAssetFiles)(P),E=M?.[0];if((0,f.isEmpty)(M)||null==E)return r.warn("No existing files. Skipping for now."),b.markUnshownAndUpsert(),{asset:b,rejected:"Empty asset (no AssetFiles after sorting). Un-showing Asset:"+i};if(!E.isVersionUpToDate())return r.warn("Best file needs update, and we already tried to update all files. Skipping this asset.",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, could not be updated. Un-showing Asset:${i}`};const k=await E.capturedAt();if(null==k)return r.warn("Best file failed to extract a captured-at",{bestAcceptedAF:E}),b.markUnshownAndUpsert(),{asset:b,rejected:`Best AssetFile:${E.id}, failed to extract a captured-at. Un-showing Asset:${i}`};const D=new Set,[x,C]=await(0,u.partitionAsync)(M,(e=>(0,o.isSimilarAssetFile)(e,E)));if(r.throwIfAborted_(),(0,f.isNotEmpty)(C)){const e=await(0,a.aggregateAssetFiles)(C);for(const t of e){if((0,f.isEmpty)(t))continue;const e=y.Asset.ops().insertOne({capturedAtLocal:t[0].capturedAtLocal,shown:!1,version:0});D.add(e.id);for(const i of t)e.addAssetFile(i);v.AssetFile.dbl.runf((i=>i.update({assetId:e.id,shown:0}).whereIn("id",(0,f.compact)(t.map((e=>e.id)))))),r.info("Pushed rejected asset files into new asset",{rejectAssetId:e.id,rejectCluster:t.map((e=>({id:e.id,uri:e.uri})))})}}function F(e){return(0,f.uniq)(x.map((t=>t[e])))}const A=await Promise.all(x.map((e=>e.capturedAt()))),I=h.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,O=A.map((e=>e?.localBoundaries({delta:I}))),L=(0,c.min)(O.map((e=>e?.start)))??k.localBoundaries({delta:I})?.start,R=(0,c.max)(O.map((e=>e?.end)))??k.localBoundaries({delta:I})?.end,N=v.AssetFile.ops().all(v.AssetFile.query().limit(h.Settings.maxContemporaryAdoptionAssets.valueOrDefault).orderByRaw(`abs(AssetFile.capturedAtLocal - ${E.capturedAtLocal})`).select("AssetFile.*").distinct().join("Asset","Asset.id","AssetFile.assetId").where("AssetFile.assetId","!=",i).andWhere("Asset.version","!=",n.AssetVersion).andWhere((e=>(e=e.whereIn("AssetFile.sha",F("sha")),null==L||null==R?r.warn("external asset file check: unset start or end localtime boundary",{capturedAts:A,startBoundary:L,endBoundary:R}):e=e.orWhereBetween("AssetFile.capturedAtLocal",[L,R]),e.orWhereIn("AssetFile.meanHash",F("meanHash")).orWhereIn("AssetFile.diffHash",F("diffHash")).orWhereIn("AssetFile.dctHash",F("dctHash"))))));r.throwIfAborted_(),r.info("asset file candidates for adoption: ",N.map((e=>e.posixPathFromGrandparent)));const B=[];for(const e of N){r.throwIfAborted_();try{await e.updateFromFile_(),(0,o.isSimilarAssetFile)(e,E)&&(r.info("adopting similar asset file",{af:e}),D.add(e.assetId),e.shown=!1,b.addAssetFile(e),e.upsert(),B.push(e))}catch(t){r.warn("Error updating external asset file. Leaving asset file record as-is.",{af:e,error:t})}}r.info("fetched expansion",{retainAFs:x.map((e=>e.id)),rejectAFs:C.map((e=>e.id)),externalAssetFiles:N.map((e=>e.posixPathFromGrandparent)),similarAssetFiles:B.map((e=>e.posixPathFromGrandparent))}),await S(r,[...x,...B]),t.skipPreviews&&t.skipAssetTagging?(r.info("skipping previews and tagging",t),b.upsert()):await(0,w.assetPostUpsertTasks_)({...t,asset:b});const j=!(0,g.eql)(_,b),z=!(0,g.eql)(T,b.getShown()),V=!(j||z||t.forceRebuildPreviews||t.forceSync);return r.tap({msg:"updateAsset() result",level:"info",result:{asset:b,assetIdsToUpdate:Array.from(D),assetFiles:b.assetFiles,skipped:V},meta:{ctx:t,assetChanged:j,primaryAssetFileChanged:z}})}async function S(e,t){const[i,s]=(0,r.partition)(t,(e=>e.isVersionUpToDate()));for(const t of s){e.throwIfAborted_();const r=i.find((e=>e.sha===t.sha));if(null!=r){e.info("backfilling",{sibling:r,dest:t});const i=await t.updateFromShaSibling_(r);null!=i&&i.upsert()}}}t.updateAsset=async function(e){try{const t=await b(e);return{id:e.assetId,skipped:null==t?.asset,...t}}catch(t){return{id:e.assetId,error:t}}},t.updateAsset_=b},93755:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetFileIfNeeded=t.handleAssetFileUriChange=t.updateAssetFile_=t.updateAssetFile=void 0;const r=i(50213),s=i(92434),n=i(98314),a=i(74128),o=i(69589),l=i(87001),u=i(40958),c=i(22573),d=i(68708),h=i(43487),f=i(54017),m=i(94710);async function p(e){const t=Date.now(),i=e,s=e,n=s.af?.id??i.assetFileId,u=(0,r.mkLogger)(`updateAssetFile(${n})`),d=s.af??f.AssetFile.ops().findById(n);if(null==d)return u.throw("db record not found",{assetFileId:n});const h=await d.posixFile_(),p=(0,o.forceContextOrSetting)(e),v={id:n,assetFileId:n,path:h?.nativePath,uri:d?.uri};if(null==h)return{...v,error:"file for URI not found"};const w=await(h?.isDeletedUri(d.uri));if(null==w)return u.info("no-op: file URI points to an unmounted volume",v),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:"volume is not currently mounted",state:a.SyncFileStates.skipped}),{...v,skipped:!0};const b=e.whyReject??await d.whyRejected();if(w||!(0,c.blank)(b)){const e={...v,rejected:b,deleted:w};return u.warn("file was deleted or rejected. Deleting.",e),(0,a.syncReport)().onProgress({path:h.nativePath,elapsedMs:Date.now()-t,from:"updateAssetFile_()",details:w?"file no longer exists":"rejected: "+b,state:a.SyncFileStates.deleted}),d.delete(),!0!==p.skipAssetRepair&&m.Task.addOne("repairAsset",{assetId:d.assetId}),e}const S=await h.uri_();if(!await(0,l.uriIsEquivalent)(S,d.uri)){const e=await g(d,S,p);if(null!=e)return{...v,...e}}return!p.forceSync&&await d.matchesFile()?(u.info("no-op: file already matches db record",v),d.touch(),{...v,skipped:!0}):{...v,...await y(d,p)}}async function g(e,t,i){const n=(0,r.mkLogger)(`handleAssetFileUriChange(${e.id})`),a=(0,u.uniq)([...(0,l.uriEncodingVariants)(e.uri),...(0,l.uriEncodingVariants)(t)]);n.warn("URI is changing. Avoiding duplicate keys.",{priorUri:e.uri,variants:a});const o=f.AssetFile.ops().allf((t=>t.whereIn("uri",a).andWhereNot({id:e.id})));if((0,u.isNotEmpty)(o)){n.warn("Found other AssetFiles with equivalent URIs.",{afIds:o.map((e=>e.id))});const t=[e,...o],r=(0,s.sortAssetFiles)(t);if((0,u.isEmpty)(r))return n.warn("sortAssetFiles returned undefined",{arr:t.map((e=>(0,d.pick)(e,"id","uri"))),variants:a}),{error:"sortAssetFiles returned undefined"};const l=t.map((e=>e.id));for(const e of r)if(await e.exists()){f.AssetFile.dbl.runf((t=>t.whereIn("id",l.filter((t=>t!==e.id))).delete()));const r=y(e,i);return h.Asset.dbl.runf((e=>e.update({version:0,updatedAt:Date.now()}).whereIn("id",(0,u.uniq)(t.map((e=>e.assetId)))))),r}}n.info("no-op, no duplicate URIs.")}async function y(e,t){const i=Date.now();return null!=await e.upsertIfNeeded_(void 0,t)&&h.Asset.touch([e.assetId]),(0,a.syncReport)().onProgress({path:await e.getNativePath(),elapsedMs:Date.now()-i,from:"updateAssetFileIfNeeded()",state:e.syncState??a.SyncFileStates.unknown}),{assetFileId:e.id}}t.updateAssetFile=async function(e){try{return await p(e)}catch(t){return{id:e.assetFileId,...e,error:(0,n.errorToS)(t)}}},t.updateAssetFile_=p,t.handleAssetFileUriChange=g,t.updateAssetFileIfNeeded=y},68640:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.updateAssetPreviews_=void 0;const r=i(99331),s=i(38835),n=i(48604),a=i(50213),o=i(69589),l=i(87001),u=i(40958),c=i(45599),d=i(50357),h=i(31586),f=i(68708),m=i(59455),p=i(43487),g=(0,c.defer)((()=>(0,a.mkLogger)("sync-file.UpdateAssetPreviews")));t.updateAssetPreviews_=async function(e){const t=e.assetId??e.asset?.id??(0,m.toA)(e.assetFiles).find((e=>(0,h.gt0)(e.assetId)))?.assetId,i=(0,o.forceContextOrSetting)(e),a=g().addContext(".Asset:"+t);if(i.skipPreviews)return void a.warn("skipPreviews is true: no-op");if(!(0,h.gt0)(t))return a.throw("invalid assetId",{assetId:t});const c=e.asset??p.Asset.ops().findById(t);if(null==c)return a.throw("Asset:"+t+" not found");a.throwIfAborted_(i.halt);try{const e=await c.getExistingAssetFiles();if((0,u.isEmpty)(e))return void a.warn("no existing assetFiles",{asset:c});const r=n.Previews.instance().ap(t),o=await r.readInfo();a.throwIfAborted_(i.halt);const h=await(0,n.buildAssetPreviews_)({...i,assetId:t,assetFiles:e}),m=e.find((e=>e.id===h?.assetFileId))??e.find((e=>(0,l.uriIsEquivalent)(h?.uri,e.uri)));a.info("buildAssetPreviews_()",{result:h,primaryAssetFile:m});const p=await(m?.posixFile_());if(null==m||null==p||!0!==await(p?.exists()))return a.throw("buildAssetPreviews_() returned invalid assetFileId"+s.InternalErrorFlag,{newInfo:h,assetFiles:e.map((e=>(0,f.pick)(e,"id","uri"))),primaryAssetFile:m,primaryPosixFile:p});const g=(0,d.eql)(o,h),y=null==h||g;return{...h,noop:y}}catch(e){throw(0,r.ending)()||(a.warn("Failed to update previews. Un-showing asset "+t,{error:e}),c.markUnshownAndUpsert()),e}}},94019:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pathsToSync=t.scanPaths=t.logger=void 0;const r=i(19851),s=i(50213),n=i(56519),a=i(87290),o=i(34102),l=i(16287),u=i(45969),c=i(43334),d=i(28874),h=i(45200),f=i(69375),m=i(7014),p=i(41400),g=i(31586),y=i(92244),v=i(46832);t.logger=(0,r.lazy)((()=>(0,s.mkLogger)("sync.PathsToSync")));const w=(0,r.lazy)((async()=>{const e=[];for(const t of await(0,m.volumes)()){if(!0===t.ignorable||!1===t.ok||(c.isMac||(0,u.isDocker)())&&"/"===t.mountpoint||(0,f.isExcludedMountpoint)(t.mountpoint)||!(0,g.gt0)(t.size))continue;const i=await(0,v.toUriPath)(t.mountpoint,(0,h.nativePath2uri)(t.mountpoint,t));null!=i&&e.push(i)}return e}));async function b(){const e=[],i=[],r=d.Settings.argvScanPaths.toNotEmpty()??d.Settings.scanPaths.values;for(const s of r)if(await(0,l.isReadableDirectory)(s)){const r=await(0,v.toUriPath)(s);null==r?(e.push(s),(0,t.logger)().warn("Ignoring scanPath element: failed to create URI path",s)):i.push(r)}else(0,t.logger)().warn("Ignoring scanPath element: not readable directory",s);return{result:i,noUriPaths:e}}t.scanPaths=b,(0,p.later)((()=>{(0,o.ee)().on("volumesChanged",(()=>{w.unset()}))})),t.pathsToSync=async function(){const e=[];if(d.Settings.argvScanPaths.isNotEmpty()){for(const i of d.Settings.argvScanPaths.values){const r=await(0,v.toUriPath)(i);null!=r?e.push(r):(0,t.logger)().warn("pathsToSync(): Ignoring scanPath element: failed to create URI path",i)}return e}e.push(...(await b()).result),!0===d.Settings.scanAllDrives.value&&e.push(...await w());const i=await(0,n.thenMapOr)((0,a.libraryOriginalsDirPosixFile)(),v.posixFileToUriPath,(()=>(0,t.logger)().throw("libraryOriginalsDir was null",{libraryDir:d.Settings.libraryDir.valueOrDefault,originalsDir:d.Settings.originalsDir.value})));d.Settings.scanLibraryFirst.valueOrDefault&&e.unshift(i),d.Settings.scanLibraryLast.valueOrDefault&&e.push(i);const r=await(0,n.filterAsync)({name:"pathsToSync",arr:e,f:e=>!y.nativePathBlocklist.has(e.nativePath)&&(0,l.isReadableDirectory)(e.nativePath)});return(0,t.logger)().info("pathsToSync",r),r}},98622:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.runTimeIsStale=t.SyncCron=void 0;const r=i(28874),s=i(41400),n=i(30301),a=i(31586);t.SyncCron=(0,n.lazy)((()=>r.Settings.syncCron.cron({timezone:r.Settings.syncCronTZ.value}))),(0,s.later)((()=>{r.Settings.syncCron.watchLater((()=>t.SyncCron.unset())),r.Settings.syncCronTZ.watchLater((()=>t.SyncCron.unset()))})),t.runTimeIsStale=function(e){return null==e||(0,a.lte)((0,t.SyncCron)().nextRun(new Date(e))?.getTime(),Date.now())}},92244:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.syncPathsForUI=t.bestStable=t.isStale=t.bestPathToSync=t.stalePathsToSync=t.pathsAndTimesToSync=t.nativePathBlocklist=void 0;const r=i(48884),s=i(19851),n=i(50213),a=i(23560),o=i(22277),l=i(87290),u=i(57902),c=i(28874),d=i(40958),h=i(76790),f=i(42659),m=i(75240),p=i(31586),g=i(20958),y=i(49796),v=i(94019),w=i(98622),b=(0,s.lazy)((()=>(0,n.mkLogger)("sync.SyncPaths")));t.nativePathBlocklist=new o.TTLSet(10*f.minuteMs);const S=10*f.minuteMs;async function P(){const e=await(0,v.pathsToSync)(),t=c.Settings.forceSync.valueOrDefault?[]:await y.Progress.times();return b().tap({msg:"pathsAndTimesToSync()",level:u.LogLevels.info,result:e.map((e=>({...e,...t.find((t=>t.uri===e.uri))})))})}function _(e,t){return null==e.lastStartedAt||null==e.lastCompletedAt||(0,p.lte)(e.lastStartedAt,t)||(0,w.runTimeIsStale)(e.lastCompletedAt)}function T(){return g.Operation.getFirstPendingOp({name:g.OperationNames.forceRestartSync})}async function M(e){const t=T(),i=t?.createdAt,s=e.filter((e=>_(e,i)));if((0,d.isEmpty)(s))return(0,a.isSyncService)()&&t?.markCompleted(),b().tap({msg:"bestStable(): No stale paths to sync!",level:"info",result:void 0,meta:{arr:e,forceRestartOp:t}});{const e=(0,r.greatestBy)(s,(e=>e.lastUpdatedAt));if(null!=e&&(0,p.gt)(e.lastUpdatedAt,Date.now()-10*f.minuteMs))return b().tap({msg:"bestStable(): returning most recently updated",level:"info",result:{...e,why:"recently updated"}})}const n=(0,r.leastBy)(s,(e=>[e.lastStartedAt??0,e.lastCompletedAt??0]));return b().tap({msg:"bestStable(): returning least-recently-started or least-recently-completed:",level:"info",result:null==n?void 0:{...n,why:"least recently started or completed"},meta:{stale:s}})}function E(e,t){return null==e.lastStartedAt?"new":null==e.lastCompletedAt?"todo":(0,p.gt)(e.lastUpdatedAt,Date.now()-f.minuteMs)?"syncing":_(e,t)?"stale":"synced"}function k(e){return null==e?void 0:new Date(e).toISOString()}function D(e){if(null==e)return;const t=Date.now()-e;return t<2*f.secondMs?"just now":(0,m.fmtDuration)(t)+" ago"}t.pathsAndTimesToSync=P,t.stalePathsToSync=async function(){const e=await P(),t=T(),i=t?.createdAt,r=e.filter((e=>_(e,i)));return(0,h.sortBy)(r,(e=>[null!=e.lastUpdatedAt&&Date.now()-Se.nativePath)),t=await M(e),i=(0,l.libraryOriginalsDirPosixFile)()?.nativePath,r=T()?.createdAt;return e.map((e=>({path:e.nativePath,library:i===e.nativePath,status:E(e,r),isNext:e.nativePath===t?.nativePath,lastStartedISO:k(e.lastStartedAt),lastStarted:D(e.lastStartedAt),lastCompletedISO:k(e.lastCompletedAt),lastCompleted:D(e.lastCompletedAt)})))}},46832:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.posixFileToUriPath=t.toUriPath=void 0;const r=i(53265),s=i(45200),n=i(22573),a=i(68708),o=i(54993);async function l(e,t){if((0,a.isObject)(e)&&!(0,n.blank)(e.nativePath)&&!(0,n.blank)(e.uri))return e;const i=(0,r.resolve)((0,o.toS)(e)),l=await t??await(0,s.nativePath2uri)(i);return null==l?void 0:{nativePath:i,uri:l.toString()}}t.toUriPath=l,t.posixFileToUriPath=function(e){return l(e.nativePath,e.uriObject_())}},7656:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.rebuildTagAssetCounts=t.DirectAssetCountForTagQuery=t.RecursiveAssetCountForTagQuery=t.nonLeafTagIds=void 0;const r=i(50213),s=i(56038),n=i(95704),a=i(38156),o=i(42659),l=i(45599),u=i(41400),c=i(31586),d=i(51926),h=(0,l.defer)((()=>(0,r.mkLogger)("tag.TagAssetCounts")));function f(e){return e.prepare((0,d.compressWhitespace)("SELECT"," t1.id,"," count(t2.id) AS cnt","FROM"," Tag t1"," JOIN Tag t2 ON t1.id = t2.parentId","GROUP BY"," 1","HAVING"," cnt > 0")).pluck().all()}async function m(e,i=[]){const r=e.prepare(t.RecursiveAssetCountForTagQuery).pluck(),o=e.prepare(t.DirectAssetCountForTagQuery).pluck(),l=e.prepare("UPDATE Tag SET assetCount = :assetCount, updatedAt = :updatedAt WHERE id = :tagId"),c=new Set(f(e)),d=new a.PushProgressObserver({op:"Rebuilding tag asset counts"},e.prepare("SELECT count(*) FROM Tag").pluck().get());await(0,n.withIdBatches)({db:e,tableName:"Tag",primaryKeyColumnName:"id",whereClauses:i,async fn(e){for(const t of e){const e=!c.has(t);(0,s.timeSync)("db.rebuildTagAssetCounts("+(e?"leaf":"cte")+")",(()=>{const s=(e?o:r).get({tagId:t});l.run({tagId:t,assetCount:s,updatedAt:Date.now()}),d.incrProgress(),h().debug("_rebuildTagAssetCounts()",{isLeaf:e,whereClauses:i,tagId:t,assetCount:s})})),t%10==0&&(h().throwIfAborted_(),await(0,u.delay)(1))}}}),d.completed()}t.nonLeafTagIds=f,t.RecursiveAssetCountForTagQuery=(0,d.compressWhitespace)("WITH RECURSIVE descendants(id) AS ("," VALUES (:tagId)"," UNION"," SELECT Tag.id"," FROM Tag, descendants"," WHERE Tag.parentId = descendants.id",")","SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," descendants"," JOIN AssetTag ON AssetTag.tagId = descendants.id"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL"),t.DirectAssetCountForTagQuery=(0,d.compressWhitespace)("SELECT"," count(DISTINCT Asset.id) AS assetCount","FROM"," AssetTag"," JOIN Asset ON Asset.id = AssetTag.assetId","WHERE"," AssetTag.tagId = :tagId"," AND Asset.shown = 1"," AND Asset.hidden = 0"," AND Asset.excludedAt IS NULL"," AND Asset.deletedAt IS NULL;"),t.rebuildTagAssetCounts=async function(e,t=o.minuteMs){if(await(0,s.time)("db.rebuildNullTagAssetCounts",(()=>m(e,["assetCount IS NULL"]))),(0,c.gt0)(t)){const i=e.prepare("SELECT min(updatedAt) FROM Tag").pluck().get(),r=Date.now()-i;if(rm(e)))}},69032:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.displayNameForVolsha=t.fixFileRootTag=t.runTagMaintenance=t.forceRunTagMaintenance=t.tagFtsRebuild=void 0;const s=r(i(76760)),n=i(19851),a=i(50213),o=i(7282),l=i(409),u=i(1728),c=i(56038),d=i(34102),h=i(49076),f=i(69589),m=i(28874),p=i(42231),g=i(85087),y=i(98770),v=i(59107),w=i(63870),b=i(7014),S=i(22573),P=i(42659),_=i(41400),T=i(75240),M=i(31586),E=i(34666),k=i(51926),D=i(75020),x=i(54017),C=i(48723),F=i(98784),A=i(7656),I=(0,n.lazy)((()=>(0,a.mkLogger)("tag.TagSql")));t.tagFtsRebuild=(0,n.lazy)((()=>(0,c.time)("db.rebuildTagFts",(()=>F.TagFts.rebuild()))),10*P.minuteMs),t.forceRunTagMaintenance=async function(e={forceSync:!0,recountAllTags:!0}){return I().info("forceRunTagMaintenance()"),await t.runTagMaintenance.force(e)};const O=((0,o.isTest)()?5:30)*P.secondMs;t.runTagMaintenance=(0,l.rateLimited)({name:"runTagMaintenance",minCallDelayMs:O,f:async e=>{const i=(0,f.forceContextOrSetting)(e),r=Date.now(),s=I().addContext(".runTagMaintenance()");s.info("starting",{ctx:i});try{s.info("validating all tags..."),C.Tag.validate_(),s.throwIfAborted_(i?.halt),await L(),i.recountAllTags&&(s.info("rebuilding tag search index..."),await(0,t.tagFtsRebuild)(),s.info("rebuilding tag asset counts..."),await(0,A.rebuildTagAssetCounts)(C.Tag.dbl.db().db,0))}catch(e){I().warn("runTagMaintenance() failed",e)}const n=Date.now()-r,a=(0,M.clamp)(O,15*P.minuteMs,20*n);t.runTagMaintenance.setMinCallDelayMs(a),I().info("runTagMaintenance(): complete.",{newMinCallDelayMs:a,elapsedMs:n})}});const L=(0,y.lazyFsAsync)("updateTagMountpoints",(async()=>{I().info("updating tag mountpoints...");const e=C.Tag.findByPath([D.TagRoots.fs]);if(null!=e){e.maybeUpsertDisplayName(m.Settings.tagDisplayNameFS.valueOrDefault);for(const t of e.getChildren())await N(t)}else(0,a.mkLogger)("updateTagMountpoints()").info("No root filesystem tag (new db, I hope?)")}));function R(){t.tagFtsRebuild.unset(),L.unset()}async function N(e){if(null==e||2!==e.depth||!e._path.startsWith(D.TagRoots.fs+p.TagSep))return;const i=(0,a.mkLogger)("fixFileRootTag("+e+")");if(e.name===D.LibraryTagName)return void(1!==e.ordinal&&(i.info("fixing library ordinal",{id:e.id,path:e.path}),e.upsert({ordinal:1}),C.Tag.clear()));if((0,f.forceContextOrSetting)().forceSync&&(0,S.notBlank)(e.displayName)&&(0,E.gt)(e.updatedAt,Date.now()-(0,w.volumeMetadataTtlMs)()))return void i.info("no-op: tag recently updated",{id:e.id,path:e.path,updated:(0,T.fmtDuration)(Date.now()-e.updatedAt)+" ago"});const r=await(0,t.displayNameForVolsha)(e.name);(0,S.notBlank)(r)?(e.maybeUpsertDisplayName(r),i.info("updated tag",{id:e.id,path:e.path,displayName:r}),C.Tag.clear()):i.debug("cannot update tag: no current volume.",{id:e.id,path:e.path})}(0,_.later)((()=>{(0,d.ee)().on("clearCache",R),m.Settings.libraryDir.watchLater(R)})),t.fixFileRootTag=N,t.displayNameForVolsha=(0,u.memoizeAsync)((async e=>{const t=(0,a.mkLogger)("displayNameForVolsha("+e+")"),i=await(0,b.volumes)();if(null!=i){const r=i.find((t=>(0,g.volsha)(t.uuid)===e));return t.info("find()",{vol:r}),null!=r?m.Settings.tagDisplayNameFSLabels.valueOrDefault&&(0,S.notBlank)(r.label)?r.label.trim():"/"===r.mountpoint?m.Settings.tagDisplayNameFSRoot.valueOrDefault+(m.Settings.tagDisplayNameFSRootWithHostname.valueOrDefault?" on "+(0,h.hostname)():""):(0,S.notBlankOr)((0,k.stripPrefixSuffix)(r.mountpoint,{prefix:s.default.sep,suffix:s.default.sep}),s.default.sep):x.AssetFile.dbl.pluckFirstf((t=>t.select("mountpoint").whereLike("uri","psfile://"+e+"/%").limit(1)))}}),{name:"tag.displayNameForVolsha",maxSize:64,timeoutMs:(0,w.volumeMetadataTtlMs)()}),(0,_.later)((()=>{v.mountpoints.watch((()=>t.displayNameForVolsha.clear()))}))},5379:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});try{i(93944).install()}catch{}const r=i(69554),s=i(38790),n=i(53978),a=i(43380),o=i(5670),l=i(98392),u=i(31503),c=i(1739);!async function(){await new r.CLI(o.ServiceNames.web).add(l.ExposeArg,u.LogArgs,n.TimingArg,a.WriteSettingsArg,s.ColorArgs).parse(),new c.WebService}()},13808:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AboutRouter=void 0;const s=r(i(7252)),n=i(45255),a=i(81168),o=i(76596),l=i(51773),u=i(81674),c=i(28874),d=i(85087),h=i(7014),f=i(38639),m=i(42659),p=i(75240),g=i(55835),y=i(31586),v=i(20214),w=i(13538),b=i(83104),S=i(12168),P=i(77948),_=i(49796),T=i(92244),M=i(8283);t.AboutRouter=class{router(){return s.default.Router().get("/about",(0,l.wrap)("AboutRouter",this.about.bind(this)))}async about(e,t,i){const r=n.ShortCommandTimeoutMs+m.secondMs,s=await(0,w.thenOrTimeoutAs)({f:(0,P.systemInformation)(),timeoutMs:r,as:[{term:"System information",defn:"Failed to fetch system information: timeout after "+(0,o.fmtMs)(r),defnClass:"fail"}]}),l=await(0,w.thenOrTimeout)((0,v.thenMap)((0,h.volumes)(),(e=>e.map((e=>({ignorable:e.ignorable,mountpoint:e.mountpoint,uuid:e.uuid,volsha:(0,g.map)(e.uuid,d.volsha),size:(0,S.fmtBytes)(e.size,2),free:(0,S.fmtBytes)(e.available,2),full:(0,y.gt0)(c.Settings.minDiskFreeGb.valueOrDefault)&&(0,y.lt)(e.available,c.Settings.minDiskFreeGb.valueOrDefault*S.GB),label:e.label,remote:!0===e.remote?{remote:e.remote,host:e.remoteHost,share:e.remoteShare}:void 0}))).filter((e=>!0!==e.ignorable)))),r);l===b.Timeout&&s.push({term:"volumes() timeout",defn:"Failed to fetch volume metadata: timeout after "+(0,o.fmtMs)(r),defnClass:"fail"});const E=null==_.Progress.db()?void 0:await(0,w.thenOrTimeout)((0,T.syncPathsForUI)(),n.ShortCommandTimeoutMs);E===b.Timeout&&s.push({term:"sync paths timeout",defn:"Failed to fetch sync path metadata: timeout after "+(0,o.fmtMs)(n.ShortCommandTimeoutMs),defnClass:"fail"});const k=await(0,u.b)();return(0,M.render)(e,t,"about",{title:"About PhotoStructure",systemInfo:s,volumes:Array.isArray(l)?l.map((e=>({...e,mountpoint:(0,a.wbrPath)(e.mountpoint)}))):void 0,syncPaths:Array.isArray(E)?E:void 0,subTier:await(0,u.t)(),subTrial:(0,f.isTrue)(k?.l?.trial),subEmail:k?.l?.sub,subExpiresInDuration:(0,g.map)(k?.l?.exp,(e=>(0,p.fmtDuration)(e.getTime()-Date.now(),1))),subExpiresAt:(0,g.map)(k?.l?.exp,m.fmtIsoDate)})}}},76020:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AdminPostRouter=void 0;const s=r(i(7252)),n=i(45608),a=i(34102),o=i(51773),l=i(40749),u=i(62327),c=i(65238),d=i(18454),h=i(2858),f=i(7014),m=i(42659),p=i(41400),g=i(98553),y=i(98401),v=i(14611),w=i(53791),b=i(35758),S=2*m.secondMs;t.AdminPostRouter=class{router(){return s.default.Router().post("/admin/restart",(0,o.wrap)("AdminHealthRouter:restart",this.restart.bind(this))).post("/admin/bounce",(0,o.wrap)("AdminHealthRouter:bounce",this.bounce.bind(this))).post("/admin/refresh/:id",(0,o.wrap)("AdminHealthRouter:refresh",this.refresh.bind(this))).post("/admin/clear-library",(0,o.wrap)("AdminHealthRouter:clear-library",this.clearLibrary.bind(this))).post("/admin/clear-caches",(0,o.wrap)("AdminHealthRouter:clear-caches",this.clearCaches.bind(this))).post("/admin/recheck-tools",(0,o.wrap)("AdminHealthRouter:recheck-tools",this.recheckTools.bind(this))).post("/admin/repair-db",(0,o.wrap)("AdminHealthRouter:repair-db",this.repairDb_.bind(this))).post("/admin/run-maintenance",(0,o.wrap)("AdminHealthRouter:repair-db",this.maintenance_.bind(this))).post("/admin/shutdown",(0,o.wrap)("AdminHealthRouter:shutdown",this.shutdown.bind(this)))}async restart(e,t,i){await(0,v.restartLibrary_)(),(0,u.sendRedirectionToast)({response:t,toast:{text:"Restarted library...",timeout:S},url:"/splash"})}async refresh(e,t,i){const r=e.params.id,s=d.HealthCheck.findById(r);if(null==s)throw new Error("No health check found with id="+(0,g.stringify)(r));const n=await s.refresh();(0,u.sendRedirectionToast)({response:t,toast:{text:"Health check "+r+": "+n.level,timeout:S},url:"/health"})}async bounce(e,t,i){(0,p.delay)(m.secondMs).then((()=>(0,n.exit)({reason:"/bounce requested by "+e.ip,status:0}))),(0,u.sendRedirectionToast)({response:t,toast:{text:"Restarting webserver...",timeout:15*m.secondMs},url:"/splash"})}async clearLibrary(e,t,i){await(0,h.clearLibraryDirSetting)(),(0,v.restartLibrary_)(),(0,u.sendRedirectionToast)({response:t,toast:{text:"Prior library was unset. Restarting...",timeout:S},url:"/splash"})}async clearCaches(e,t,i){await(0,f.clearVolumesCache)({deleteFileCache:!0}),await(0,c.clearReaddirCaches)(),(0,a.ee)().emit("clearCache"),"/health"===(0,l.referrer)(e)?(0,u.sendRedirectionToast)({response:t,toast:{text:"Cleared caches.",timeout:S},url:"/health"}):(0,u.sendServerToast)({response:t,toast:{text:"Cleared caches."},reload:!0})}async recheckTools(e,t,i){(0,a.ee)().emit("clearToolCache"),(0,u.sendRedirectionToast)({response:t,toast:{text:"Cleared tool caches.",timeout:S},url:"/health"})}async repairDb_(e,t,i){(0,b.dbModelRepair)(),(0,u.sendRedirectionToast)({response:t,toast:{text:"Started library database repair...",timeout:S},url:"/splash"})}async maintenance_(e,t,i){(0,y.cleanup_)(),(0,u.sendRedirectionToast)({response:t,toast:{text:"Started library maintenance jobs...",timeout:S},url:"/"})}async shutdown(e,t,i){(0,p.delay)(S).then((()=>(0,w.shutdown)("requested by "+e.ip))),(0,u.sendServerToast)({response:t,toast:{text:"Shutdown initiated."}})}}},13831:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiAssetRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(97352),o=i(56519),l=i(4867),u=i(76596),c=i(57159),d=i(51773),h=i(62327),f=i(86580),m=i(81674),p=i(72308),g=i(45969),y=i(28874),v=i(40958),w=i(76790),b=i(75761),S=i(38639),P=i(55835),_=i(31586),T=i(68708),M=i(21605),E=i(41942),k=i(75020),D=i(54993),x=i(43487),C=i(37094),F=i(69853),A=i(48723),I=i(94710),O=i(73407),L=(0,n.mkLogger)("web.ApiAssetRouter"),R=["hidden","excludedAt","deletedAt"];t.ApiAssetRouter=class{constructor(e){this.previews=e}wrapApi(e,t){return(i,r,s)=>(0,h.wrapWithToast)({response:r,f:async()=>{const s=(0,_.toGt0)(i.params.assetId);if(null==s)return r.sendStatus(400);const n=await(0,o.thenMapOr)(x.Asset.ops().findById(s,{shown:1}),(e=>t(i,s,e)),(()=>this.onMissingAsset(i,s)));if(L.debug(e,{result:n}),null!=n)return(0,d.jsonOrRedirect)(n,r);throw new c.WrappedError("Asset "+s+" wasn't found",{retriable:!1,doNotSend:!0,fatal:!1})}})}router(){return s.default.Router().get("/api/asset/:assetId/info",this.wrapApi("ApiAssetRouter.assetInfo",this.assetInfo.bind(this))).get("/api/asset/:assetId/streams",this.wrapApi("ApiAssetRouter.assetInfo",this.assetStreams.bind(this))).get("/api/asset/:assetId",this.wrapApi("ApiAssetRouter.asset",this.asset.bind(this))).put("/api/asset/:assetId",this.wrapApi("ApiAssetRouter.save",this.save.bind(this))).put("/api/asset/:assetId/resync",this.wrapApi("ApiAssetRouter.resync",this.resync.bind(this)))}async assetInfo(e,t,i){const r=i.getAssetFiles(),s=i.getShown(),n=(0,P.map)(s,(e=>e.getNativePath())),a=(0,p.isLocalhost)(e.ip)&&!(0,g.isDocker)();if(y.Settings.resyncAssetOnVisit.valueOrDefault&&I.Task.addOne("repairAsset",{assetId:t,forceSync:!1,forceRebuildPreviews:!1}),null==s||null==n)return void L.error("no shown AssetFile found for "+t,{asset:i,shown:s,shownPathP:n});L.debug("assetInfo()",{assetId:t,shown:s,shownPathP:n,ip:e.ip,showOpenFile:a});const l=i.getTags(),c=await(0,o.mapAsync)({name:"api.assetInfo.tags",arr:l,f:e=>e.toApiTag()}),h=await(0,o.mapAsync)({name:"api.assetInfo.files",arr:r,f:e=>e.toApi(this.previews,s.sha)});return(0,w.sortByInPlace)(h,(e=>[!e.shown,!e.exists,e.nativePath])),{assetId:t,capturedAtLocale:s.capturedAtLocale((0,d.requestLang)(e)),...(0,T.pick)(s,"mimetype","focalLength","iso","aperture","shutterSpeed"),durationHMS:(0,P.map)(s.durationMs,u.durationHMS),fps:s.fps,files:h,tags:c,showOpenFile:a}}async onMissingAsset(e,t,i){const r="next"===e.query.from;L.info("onMissingAsset()",{query:(0,T.entries)(e.query),params:(0,T.entries)(e.params),assetId:t});const s=(0,_.toInt)(String(e.query.priorAssetId)),n=(0,P.mapOr)(i,(e=>e.id),(()=>s));if(null==n)return void L.warn("onMissingAsset(): no context asset available");const l=await(0,o.thenMapOr)(i,(e=>e.capturedAtLocal),(()=>x.Asset.dbl.pluckFirstf((e=>e.select("capturedAtLocal").where({id:n})))));let u=x.Asset.shownUnhidden(x.Asset.query().select("id").limit(1).whereNotIn("id",(0,v.compact)([t,s])));u=r?u.andWhere("capturedAtLocal","<",l).orderBy("capturedAtLocal","desc"):u.andWhere("capturedAtLocal",">",l).orderBy("capturedAtLocal","asc");const c=x.Asset.dbl.pluckFirst(u);return L.warn("Asset redirect",{fromAssetId:n,priorAssetId:s,fromTime:l,toAsset:c}),(0,a.mapGt0)(c,(t=>(0,E.mkReplace)((0,b.assetUrl)({assetId:t,params:[e.query,e.params]}),{text:`Asset ${n} is no longer available.`,type:"info"})))}async asset(e,t,i){const r=i.getShown();if(null==r)return L.error("no shown AssetFile found for "+t+", disabling (for now)."),i.upsert({shown:!1}),L.error("Asset un-shown."),I.Task.addOne("repairAsset",{assetId:t,forceSync:!0,forceRebuildPreviews:!0}),this.onMissingAsset(e,t,i);i.getBeforeAfterId();const s={...i.partialSimpleAsset(),name:r.basename,width:r.width,height:r.height,rotation:r.rotation??0,capturedAtLocale:r.capturedAtLocale((0,d.requestLang)(e)),aspectRatio:(0,f.aspectRatio)(r),durationHMS:(0,P.map)(r.durationMs,u.durationHMS),downloadable:await r.originalDownloadable({brief:!0}),contextTag:await i.whenApiTag(),beforeAssetId:i.beforeId,afterAssetId:i.afterId};if(r.isVideo){const r=await i.videoSources();return await i.getExistingAssetFiles(),(0,v.isEmpty)(r)?(L.warn("no existing files for "+t+", trying to repair, but redirecting user now."),I.Task.addOne("repairAsset",{assetId:t,forceSync:!0,forceRebuildPreviews:!0}),this.onMissingAsset(e,t,i)):{...s,videoAttrs:i.videoAttrs(),videoSources:r}}return{...s,imgAttrs:await i.fitAttrs(this.previews)}}async assetStreams(e,t,i){const r=(0,_.toInt)((0,D.toS)(e.query.limit),{defaultValue:k.BeforeAfterStreamLimit}),s=i.getStreams(r);return L.tap({msg:"assetStreams",result:{assetId:t,assetStreams:await(0,o.mapAsync)({name:"assetStreams",arr:s,f:e=>e.toApi()})}})}async save(e,t,i){if(await(0,m.l)())return L.warn("save(): disabled"),{showTryPlusToast:!0};const r=i.isActive(),s={hidden:(0,S.toBoolean)(e.body.hidden),excludedAt:(0,P.map)((0,S.toBoolean)(e.body.excluded),(e=>e?Date.now():null)),deletedAt:(0,P.map)((0,S.toBoolean)(e.body.deleted),(e=>e?Date.now():null)),rating:(0,P.map)((0,S.toBoolean)(e.body.liked),(e=>e?y.Settings.likeRating.valueOrDefault:null))};if(!(0,v.isEmpty)((0,T.keys)(s))){L.info("save()",{obj:s,body:e.body}),C.AssetRevision.insert(...(0,T.entries)((0,T.omit)(s,...R)).map((([e,r])=>({assetId:t,field:e,priorValue:i?.[e],newValue:r}))));const n=null===s.deleted?null:null!=s.deleted?-1:s.rating;void 0!==n&&await(0,O.writeAssetTags_)(t,{Rating:n}),i.upsert(s),i.isActive()!==r&&A.Tag.deltaAssetCountAndAncestors(i.tagIds(),i.isActive()?1:-1)}const n=i.partialSimpleAsset(),a=(0,M.normalizeRotation)((0,_.toInt)(e.body.rotation));return null!=a&&0!==a&&(await(0,F.setAssetRotation_)(t,a,this.previews),n.rotation=a),n}async resync(e,t){return x.Asset.dbl.runf((e=>e.where({id:t}).update({version:0}))),await(0,l.thenOrTimeoutError)({p:I.Task.addOne("repairAsset",{assetId:t,forceSync:!0,forceRebuildPreviews:!0}).donePromise(),timeoutMs:y.Settings.taskTimeoutMs.valueOrDefault}),{v:x.Asset.dbl.pluckFirstf((e=>e.where({id:t}).select("updateCount")))}}}},53881:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiSearchRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(51773),o=i(68178),l=i(28874),u=i(7014),c=i(40958),d=i(22573),h=i(38639),f=i(31586),m=i(12168),p=i(32790),g=i(54993),y=i(43487),v=i(48722),w=i(43786),b=i(7573),S=i(33693),P=i(23523),_=(0,n.mkLogger)("web.ApiSearchRouter");t.ApiSearchRouter=class{router(){return s.default.Router().get("/api/search",(0,a.wrap)("ApiSearchRouter.get",this.get.bind(this)))}async get(e,t){const i=(0,g.toStr)(e.query.q," "),r=p.AssetQueryOrderByColumns.validOrElse((0,g.toStr)(e.query.orderby,","),p.AssetQueryOrderByColumns.capturedAt),s=(0,h.isTrue)(e.query.asc),n={column:r===p.AssetQueryOrderByColumns.capturedAt?"Asset.capturedAtLocal":"Asset.updatedAt",order:s?"asc":"desc"},a=(0,f.toGt0)((0,g.toStr)(e.query.offset));if(_.debug("get()",{q:i,orderBy:n,offset:a}),(0,d.blank)(i))return t.json({});const T=(0,b.normalizeQuery)((0,S.parseQuery_)(i));let M=(0,P.defaultAssetQuery)().select({id:"Asset.id",capturedAtLocal:"Asset.capturedAtLocal",updateCount:"Asset.updateCount",durationMs:"Asset.durationMs"}).orderBy([n,"Asset.id"]).limit(512);const E=(0,w.findTerm)(T,(e=>"fs"===e.ns))?await(0,u.mountpointToVolsha)():void 0;null!=a&&(M=M.offset(a));const k=null==a?await async function(e,t,i){const r=await function(e,t){return y.Asset.dbl.pluckFirst((0,P.queryToSql)(e,(0,P.defaultAssetQuery)().countDistinct("Asset.id"),t))}(t,i),{emptyTrashQuery:s,removeAssetsQuery:n}=function(e){const t=1===(0,w.flatTerms)(e).length,i=t&&(0,w.isTrueTerm)((0,w.findTerm)(e,(e=>e.ns===b.AssetTermBoolNs.deleted)));return{emptyTrashQuery:i,removeAssetsQuery:!i&&t&&(0,w.isTrueTerm)((0,w.findTerm)(e,(e=>e.ns===b.AssetTermBoolNs.excluded)))}}(t);if(0===r)return{description:s?"No assets are marked for trash.":n?"No assets are marked for removal.":"No matching assets."};const a="Found "+(0,m.plur)(r,"asset");if(!s&&!n)return{description:a};const u=await function(e,t){return y.Asset.dbl.pluckFirst((0,P.queryToSql)(e,(0,P.defaultAssetQuery)().join("AssetFile","AssetFile.assetId","Asset.id").countDistinct("AssetFile.id"),t))}(t,i),c=a+" ("+(0,m.plur)(u,"file")+")",d={expectedAssetFileCount:String(u)};if(s){const t="Empty trash";return{description:c,buttonText:t,buttonIcon:"trash_forever",promptTitle:t,refreshOnActivation:!0,...l.Settings.enableEmptyTrash.valueOrDefault?{buttonClass:"error",buttonTitle:null,prompt:[`

    Are you sure you want to permanently delete ${(0,m.plur)(u,"file")} comprising ${(0,m.plur)(r,"asset")}?

    `,"","

    To proceed, please enter the number of files that will be deleted:

    "].join("\n"),formAction:(0,o.requestedUri)(e).with({path:"/api/system/empty-trash",query:d}).toString()}:{buttonClass:"disabled",buttonTitle:'This is disabled. See the "enableEmptyTrash" setting.',prompt:null,formAction:null}}}if(n){const t="Remove assets";return{description:c,buttonText:t,buttonIcon:"warning",promptTitle:t,refreshOnActivation:!0,...l.Settings.enableRemoveAssets.valueOrDefault?{buttonClass:"warning",buttonTitle:null,prompt:["

    Are you sure you want to remove "+(0,m.plur)(r,"asset")+" (comprised of "+(0,m.plur)(u,"file")+") from your library?

    ","","

    To proceed, please enter the number of files that will be removed:

    "].join("\n"),formAction:(0,o.requestedUri)(e).with({path:"/api/system/remove-assets",query:d}).toString()}:{buttonClass:"disabled",buttonTitle:'This is disabled. See the "enableRemoveAssets" setting.',prompt:null,formAction:null}}}throw new Error("internal error (mkBanner)")}(e,T,E):void 0;M=(0,P.queryToSql)(T,M,E).distinct();const D=(0,c.compact)(y.Asset.dbl.all(M).map(v.toAssetId)),x={query:{q:i,normalized:(0,w.queryToString)(T,w.NormieQuerySymbols),orderBy:r,asc:s,offset:a??0,nextOffset:D.length<512?void 0:D.length+(a??0)},banner:k,assetIds:D};return _.debug(".get("+(0,w.queryToString)(T)+") result",x),t.json(x)}validatePostRequest(e,t){return _.debug("validatePostRequest",{req_query:e.query,req_body:e.body}),this.validatePost((0,g.toStr)(e.query.expectedAssetFileCount," "),e.body.answer,t)}async validatePost(e,t,i){_.debug("validatePost",{expectedAssetFileCount:e,answer:t});const r=(0,f.toInt)((0,g.toS)(e));if(null==r)return"Canceled: the expected number of files was missing from the request.";const s=(0,f.toInt)(t);if(null==s)return"Canceled: missing user input.";const n=await y.Asset.dbl.pluckFirst(i().join("AssetFile","Asset.id","AssetFile.assetId").countDistinct("AssetFile.id"));return r!==n?`Canceled: the number of files has changed from ${(0,m.fmt)(r)} to ${(0,m.fmt)(n)}. Reload this page and try again.`:s!==r?`Canceled: you entered "${t??""}" and we expected "${r}".`:{assetFileCount:n}}}},21598:function(e,t,i){"use strict";var r,s=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)},n=this&&this.__classPrivateFieldSet||function(e,t,i,r,s){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?s.call(e,i):s?s.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiSplashRouter=void 0;const a=i(18405),o=i(18454),l=i(37805),u=i(42659),c=i(62220),d={loading:"⏳ Loading...",welcome:"👋 Welcome!",ready:"✅ Ready",failed:"⚠️ Something's not right. Gathering details..."};class h extends a.ServerSentEventsRouter{constructor(){super("/sse/splash"),r.set(this,null)}runStateEvent(e=o.HealthCheck.runState()){const t=e===c.RunStates.loading;return t&&this.streams.length>0?n(this,r,s(this,r,"f")??setInterval((()=>{this.writeToStreams(this.runStateEvent())}),u.secondMs),"f"):null!=s(this,r,"f")&&(clearInterval(s(this,r,"f")),n(this,r,null,"f")),this.logger.tap({msg:"runStateEvent()",level:"warn",result:t?{event:"msg",data:o.HealthCheck.loadingMsg()??d[e]}:{event:"settled",data:d[e]},meta:{state:e}})}firstEvents(){return[{event:"version",data:l.version},this.runStateEvent()]}}t.ApiSplashRouter=h,r=new WeakMap},49296:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiSystemRouter=void 0;const s=r(i(7252)),n=i(19851),a=i(50213),o=i(97352),l=i(71567),u=i(51773),c=i(62327),d=i(74128),h=i(28874),f=i(69385),m=i(40958),p=i(38639),g=i(25763),y=i(31586),v=i(12168),w=i(54993),b=i(53791),S=i(43487),P=i(20958),_=i(94710),T=i(22968),M=(0,n.lazy)((()=>(0,a.mkLogger)("web.ApiSystemRouter")));function E(e){return async(t,i,r)=>{const s=(0,w.toStr)(t.query.expectedAssetFileCount," "),n=(0,o.extractInt)(t.body.answer);M().debug("validatePostCounts",{expectedAssetFileCount:s,answer:n});const a=(0,y.toInt)((0,w.toS)(s));if(null==a)return(0,c.sendWarningServerToast)({response:i,toast:{text:"Canceled",details:"The expected number of files was missing from the request"}});const l=(0,y.toInt)(n);if(null==l)return(0,c.sendWarningServerToast)({response:i,toast:{text:"Canceled",details:"User answer was missing"}});const u=await async function(e,t){var i,r;return M().tap({msg:`countAssetFiles(${t})`,result:(i=e.locals)[r="countAssetFiles-"+t]??(i[r]=await S.Asset.dbl.pluckFirst(S.Asset.shownRemovable(t).join("AssetFile","Asset.id","AssetFile.assetId").countDistinct("AssetFile.id")))})}(i,e);return a!==u?(0,c.sendWarningServerToast)({response:i,toast:{text:"Canceled",details:`The number of files has changed from ${(0,v.fmt)(a)} to ${(0,v.fmt)(u)}. Reload this page and try again.`}}):l!==a?(0,c.sendWarningServerToast)({response:i,toast:{text:"Canceled",details:`You entered "${n??""}" and we expected "${a}".`}}):r()}}async function k(e){M().warn("setting "+e+" to unshown...");const t=Date.now(),i={shown:0,updatedAt:t};i[e]=t;const r=S.Asset.dbl.run(S.Asset.shownRemovable(e).update(i)),s=_.Task.addOne(function(e){if("deletedAt"===e)return _.TaskNames.applyDeleted;if("excludedAt"===e)return _.TaskNames.applyExcluded;throw new Error("invalid RemovableColumn "+e)}(e),{createdAt:t});M().warn("updated assets and scheduled task",{result:r,obj:i,task:s})}async function D(e,t){return await k("deletedAt"),(0,c.sendServerToast)({response:t,reload:!0,toast:{text:"Emptied trash",details:"Assets have been removed from your library and files will be deleted in the background.",type:"success"}})}async function x(e,t){return await k("excludedAt"),(0,c.sendServerToast)({response:t,reload:!0,toast:{text:"Assets have been removed from your library.",type:"success"}})}t.ApiSystemRouter=class{constructor(e){this.openFileService=e,this.getState=(e,t)=>{const i={paused:(0,f.isPaused)()};return t.json(i)},this.getHasEmail=(e,t)=>{t.json({hasEmail:(0,g.isEmailMaybe)(h.Settings.email.value)})},this.postSystem=async(e,t)=>{const i=e.body,r=[];M().info("post()",{body:e.body}),(0,p.mapTrue)(i.pause,(()=>{(0,f.pause)(!0),r.push("Sync was paused")})),(0,p.mapTrue)(i.resume,(()=>{(0,f.pause)(!1),r.push("Sync was resumed")})),await(0,p.mapTrue)(i.restartSync,(async()=>{l.StdoutWrite.restartSync(),r.push("Sync restart was requested")})),await(0,p.mapTrue)(i.forceRestartSync,(async()=>{P.Operation.markOpCompleted({name:"forceRestartSync"},{value:"canceled (force-restarted)"}),P.Operation.ensurePendingOp({name:"forceRestartSync"}),l.StdoutWrite.restartSync(),r.push("Sync force-restart was requested")})),await(0,p.mapTrue)(i.rebuildLibrary,(async()=>{(0,T.forceRebuildLibraryLater)(),l.StdoutWrite.restartSync(),r.push("Library rebuild was requested")})),(0,p.mapTrue)(i.showSyncReports,(()=>{this.openFileService((0,d.syncReportReadme)()),r.push("Opened your sync reports directory")})),(0,p.mapTrue)(i.shutdown,(async()=>{const t="requested by "+e.ip;(0,b.shutdown)(t),r.push("Shutdown "+t)})),(0,m.isNotEmpty)(r)?(0,c.sendServerToast)({response:t,toast:{type:"info",text:r.join(". ")}}):(t.status(400),(0,c.sendServerToast)({response:t,toast:{text:"Nothing requested.",type:"warning"}}))}}router(){return s.default.Router().get("/api/system/state",(0,u.wrap)("state",this.getState)).get("/api/system/hasEmail",(0,u.wrap)("hasEmail",this.getHasEmail)).post("/api/system",((e,t)=>(0,c.wrapWithToast)({response:t,f:()=>this.postSystem(e,t)}))).post("/api/system/empty-trash",c.requirePlus,(0,c.requireEnabled)(h.Settings.enableEmptyTrash),E("deletedAt"),D).post("/api/system/remove-assets",c.requirePlus,(0,c.requireEnabled)(h.Settings.enableRemoveAssets),E("excludedAt"),x)}}},19583:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ApiTagRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(97352),o=i(45255),l=i(76596),u=i(51773),c=i(62327),d=i(28874),h=i(34238),f=i(40958),m=i(31586),p=i(41942),g=i(75020),y=i(27776),v=i(54993),w=i(64526),b=i(43487),S=i(48723),P=(0,n.mkLogger)("ApiTagRouter");function _({name:e,f:t}){return(0,u.wrap)(e,(async(i,r)=>{const s=(0,m.toInt)(i.params.tagId),n=(0,u.extractTagPath)(i.path).map(h.percentDecode),a=(0,u.getSeed)(i),o=(0,u.getFit)(i),l=(0,f.mapNotEmptyOr)(n,(e=>S.Tag.findByIdOrPath(s,e)),(()=>S.Tag.root())),d=null==l?void 0:t(i,l,{tagId:l.id,tagPath:l.path,seed:a,fit:o});return P.debug(e,{result:d,tagPath:n,seed:a,url:i.url}),null==l||null==d?(0,c.send404Toast)({text:"Failed to find tag "+s??n.join("/"),response:r}):(0,u.jsonOrRedirect)(d,r)}))}t.ApiTagRouter=class{router(){return s.default.Router().get("/api/tag*",_({name:"ApiTagRouter.tagGallery",f:this.tagGallery.bind(this)})).get((0,g.nextAssetsUrl)(":tagId",{}),_({name:"ApiTagRouter.tagAssets",f:this.tagAssets.bind(this)})).get((0,g.nextChildTagsUrl)(":tagId",{}),_({name:"ApiTagRouter.childTags",f:this.childTags.bind(this)}))}tagGallery(e,t,i){if(P.debug("tagGallery()",{tag:t}),null==i.seed)return P.debug("tagGallery(): no seed, redirecting..."),(0,p.mkReplace)((0,y.mkTagFullPath)(t.path,e.query));if(d.Settings.fastForwardEmptyTags.valueOrDefault){const i=t.firstNonInterstitialTagId();if(i!==t.id){const t=S.Tag.findById(i);if(null!=t)return(0,p.mkReplace)((0,y.mkTagFullPath)(t.path,e.query),{text:"Skipping to first non-empty child tag…",uuid:"redirect-to-tag",onlyShowUuidOnce:!0,type:"info"})}}const r={fullPath:e.originalUrl,fit:i.fit,...t.toApiTag(),...this.childTags(e,t,i),...this.tagAssets(e,t)};return 0===t.id&&0===b.Asset.shownCount()&&((0,l.isRecentMs)(w.Library.instance()?.start,o.ShortCommandTimeoutMs)?r.startingUp=!0:r.emptyLibrary=!0),r}childTags(e,t,i){const r=(0,m.toInt)((0,v.toS)(e.query.offset))??0,s=(0,m.toInt)((0,v.toS)(e.query.limit))??4;P.debug("childTags() got ",{thisOffset:r,limit:s,query:e.query});const n={tagId:t.id,offset:r,limit:s,seed:i.seed};n.limit=(0,a.firstGt0)(n.limit,4);const o=t.getChildrenCount(),l=0===o?[]:t.getPagedChildren(n);P.debug("childTags()",{crit:n,childTagCount:o,children:l});const u=l.length+r,c=u{const t=e.getRelatedAssetIds({seed:i.seed+e.id,limit:g.ThumbsPerSample});return(0,f.isNotEmpty)(t)?{...e.toApiTag(),assetIds:t}:void 0})));return P.tap({msg:"childTags result",result:{tagId:t.id,childTags:d,childTagCount:o,nextChildTags:c},meta:{nextOffset:u}})}tagAssets(e,t){const i={offset:(0,m.toInt)((0,v.toS)(e.query.offset),{defaultValue:0})},r=t.getPagedAssetIds(i),s=r.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetOpenGraph=void 0;const r=i(48884),s=i(48604),n=i(28874),a=i(16170),o=i(31586);t.getAssetOpenGraph=async function(e,t){if(null==(t=(0,o.toGt0)(t))||!(0,o.gt0)(n.Settings.openGraphTargetWidth.valueOrDefault))return;const i=s.Previews.instance()?.ap(t);if(null==i)return;const l=await i.readInfo();if(null==l)return;const u=[];if((0,a.isVideoMimeType)(l.mimetype)){u.push({property:"og:video",content:e.with({path:"/video/"+t}).toString()});const r=await i.mp4().exists()?"video/mp4":l.mimetype;u.push({property:"og:video:type",content:r},{property:"og:video:width",content:l.width.toString()},{property:"og:video:height",content:l.height.toString()})}else{const s=(await i.widths("fit")??[]).map((e=>({width:e,path:"/img/"+t+"/fit/"+e})));"image/jpeg"===l.mimetype&&s.push({width:l.width,path:"/img/"+t+"/actual"});const a=(0,r.leastBy)(s,(e=>Math.abs(e.width-n.Settings.openGraphTargetWidth.valueOrDefault)));if(null!=a){u.push({property:"og:image",content:e.with({path:a.path}).toString()},{property:"og:image:type",content:"image/jpeg"},{property:"og:image:width",content:a.width.toString()});const t=a.width/(l.width/l.height);(0,o.gt0)(t)&&u.push({property:"og:image:height",content:Math.round(t).toString()})}}return u}},18848:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cspHandler=void 0;const s=r(i(2525)),n=i(19851),a=i(50213),o=i(28874),l=i(49586),u=i(40958),c=(0,n.lazy)((()=>(0,a.mkLogger)("web.WebSecurity")));t.cspHandler=function(e,t,i){(e.secure||(0,l.isHttpsRequest)(e.headers))&&null==o.Settings.upgradeInsecureRequests.value&&(c().warn('Secure https request detected: setting "upgradeInsecureRequests" to true.'),o.Settings.upgradeInsecureRequests.tmpValue=!0);const r=(0,u.compactBlanks)(["'self'",o.Settings.cspDirective.valueOrDefault]),n=(0,u.compactBlanks)(["'self'","'strict-dynamic'",`'nonce-${t.locals.cspNonce}'`,o.Settings.cspDirective.valueOrDefault]);s.default.contentSecurityPolicy({directives:{defaultSrc:["'self'"],scriptSrc:n,styleSrc:r,baseUri:r,formAction:["'self'","https://account.photostructure.com"],objectSrc:["'none'"],upgradeInsecureRequests:o.Settings.upgradeInsecureRequests.valueOrDefault?[]:null},reportOnly:o.Settings.cspReportOnly.valueOrDefault})(e,t,i)}},81100:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.requestAssetRepair=t.ImgActualRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(51773),o=i(62327),l=i(52121),u=i(55835),c=i(31586),d=i(68708),h=i(43487),f=i(54017),m=i(94710),p=(0,n.mkLogger)("web.ImgActualRouter");function g(e){return m.Task.addOne("repairAsset",{assetId:e,forceSync:!0,forceRebuildPreviews:!0})}t.ImgActualRouter=class{constructor(e){this.previews=e}router(){return s.default.Router().get("/img/:assetId/:assetFileId/actual(.*)?",(0,a.wrap)("ImgActualRouter.assetImg",this.assetFileImg.bind(this))).get("/img/:assetId/actual(.*)?",(0,a.wrap)("ImgActualRouter.assetImg",this.assetImg.bind(this))).get("/dl/:assetId/:assetFileId",(0,a.wrap)("ImgActualRouter.assetFileImg",this.assetFileImg.bind(this)))}async assetImg(e,t){const i=(0,c.toInt)(e.params.assetId);if(!(0,c.gt0)(i))return(0,o.sendServerToast)({response:t,toast:{text:"Missing assetId in request",type:"warning"},httpStatusCode:400});const r=f.AssetFile.ops().findOneBy({assetId:i,shown:1});return null==r?(p.info("Unknown assetId",e.originalUrl),this.repairAssetLaterAndSendPreview(i,e,t)):this.sendAssetFile(e,t,r)}async assetFileImg(e,t){const i=(0,c.toInt)(e.params.assetId);if(!(0,c.gt0)(i))return(0,o.send404Toast)({response:t,text:'Request was missing "assetId"',httpStatusCode:400});const r=(0,c.toInt)(e.params.assetFileId);if(!(0,c.gt0)(r))return(0,o.send404Toast)({response:t,text:'Request was missing "assetFileId"',httpStatusCode:400});const s=f.AssetFile.ops().findOneBy({id:r,assetId:i});return null==s?(0,o.send404Toast)({response:t,text:"Bad request: no such asset file "+r}):this.sendAssetFile(e,t,s)}async sendAssetFile(e,t,i){const r=i.assetId,s=await i.posixFile_(),n=e.path.split("/").includes("dl")||(0,a.truthyQuery)(e,"dl");if(null==s||await s.isEmpty())return n?(0,o.send404Toast)({response:t,text:"Asset file "+i.uri+" was missing"}):this.repairAssetLaterAndSendPreview(r,e,t);if(n)return p.info("Sending download",{assetId:r,af:i,nativePath:s.nativePath}),t.download(s.nativePath,s.base);const c=e.headers["user-agent"],h=await(0,l.prepFileForBrowser)({nativePath:s.nativePath,userAgent:c,...(0,d.pick)(i,"width","height","sha","mimetype","rotation","mimetype")});return null==h?(p.warn("cannot send file (null result from prepFileForBrowser)",{assetId:r,af:i}),g(r),(0,o.send404Toast)({response:t,text:`Failed to get browser-friendly preview for Asset ${r}.`,details:"I'll try to fix it."})):(p.info("sendAssetFile(): sending supported file: "+h),t.sendFile(h,(e=>(0,u.map)(e,(e=>p.warn("failed to send file",{error:e,assetId:r,af:i}))))))}async repairAssetLaterAndSendPreview(e,t,i){g(e);const r=await this.previews.ap(e).largestFileForReducer("fit");null!=r?i.sendFile(r.nativePath):(h.Asset.ops().upsertOne({id:e,shown:!1}),(0,o.send404Toast)({response:i,text:`Asset ${e} is missing preview images.`,details:"I'll try to fix it, but it will be hidden for now."}))}},t.requestAssetRepair=g},4950:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ImgRouter=void 0;const s=r(i(7252)),n=i(76760),a=r(i(9288)),o=i(48884),l=i(50213),u=i(45255),c=i(81168),d=i(37628),h=i(51773),f=i(13940),m=i(28874),p=i(16170),g=i(34238),y=i(51140),v=i(11371),w=i(55835),b=i(31586),S=i(54993),P=i(54017),_=(0,l.mkLogger)("web.ImgRouter");t.ImgRouter=class{constructor(e){this.previews=e}router(){const e=(0,h.wrap)("ImgRouter",this.streamImage.bind(this));return s.default.Router().get("/img/:assetId/:reducer/:width",e)}async streamImage(e,t,i){const r=await this.getFileFromRequest(e,t);if(null!=r){if("setHeader"in t&&(0,b.gt)(r.width,500)){const e=P.AssetFile.dbl.pluckFirstf((e=>e.where({assetId:r.assetId,shown:1}).select("uri")))??"/asset-"+r.assetId+"."+r.file.ext,i=(0,w.map)(e,g.uriToBasename);if(_.debug("streamImage(): AssetFile URI",{shownUri:e,basename:i}),null!=i)try{t.setHeader("X-basename",(0,c.ensureSuffixIgnoreCase)(i,"."+r.file.ext))}catch(e){_.warn("streamImage(): setHeader error",{error:e})}else _.warn("streamImage(): failed to extract basename",{result:r})}return t.sendFile(r.file.nativePath)}}async getFileFromRequest(e,t){const i=e.params,r=(0,b.toInt)(i.assetId),s=v.ReducerNames.getCI(i.reducer)??"fit",l=(0,b.toInt)(i.width);if(null==r||null==s&&null==l)return _.warn("getFileFromRequest(): bad request",{assetId:r,reducer:s,width:l}),void t.sendStatus(y.HttpStatus.BadRequest);const h=this.previews.ap(r),g=h.fileForWidth(s,l);if(await g.exists())return{assetId:r,width:l,file:g};if(m.Settings.placeholderThumbs.valueOrDefault){const e=(0,d.stringShaToBuffer)((0,S.toS)(r)).toString("hex").slice(0,6),t=await(0,f.imageCacheDir_)();if(null==t)return;const i=t.join((0,c.splitEvery)(e,3).join(n.sep)+"-8w.png");return await i.applyIfEmpty_({fn_:t=>(0,a.default)({create:{width:8,height:8,channels:3,background:"#"+e}}).png().toFile(t.nativePath),timeoutMs:u.ShortCommandTimeoutMs}),{assetId:r,width:8,file:i}}const w=await h.widths(s)??[],P=await h.readInfo(),T=(0,p.isImageMimeType)(P?.mimetype)&&(0,p.isMimeTypeSupportedByBrowser)(P?.mimetype)?P?.width:void 0,M=(0,o.leastBy)([...w,T],(e=>(0,b.gt0)(e)&&Math.abs(l-e)));return null==M||M===l?(_.warn("Missing file, and no other widths found",{path:g.nativePath,assetId:r,reducer:s,requestedwidth:l,existingWidth:M}),void t.sendStatus(y.HttpStatus.NotFound)):M===T?(_.debug("redirecting to image actual",{assetId:r,reducer:s,width:l,f:g,existingWidth:M}),void t.redirect(["/img",r,"actual"].join("/"))):(_.debug("replacing requested width",{assetId:r,reducer:s,width:l,f:g,existingWidth:M}),void t.redirect(["/img",r,s,M].join("/")))}}},76018:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.siteManifest=t.ManifestRouter=void 0;const s=r(i(7252)),n=i(19851),a=i(50213),o=i(51773),l=i(68178),u=i(70854),c=i(28874),d=(0,n.lazy)((()=>(0,a.mkLogger)("web.ManifestRouter")));async function h({requestUri:e,id:t}){return{id:t??"com.photostructure",name:"PhotoStructure",start_url:e.with({path:c.Settings.defaultHomepagePath.valueOrDefault,query:null,fragment:null}).toString(),display:"fullscreen",icons:[{src:"/192.png",sizes:"192x192",type:"image/png"},{src:"/512.png",sizes:"512x512",type:"image/png"},{src:"/images/logo-gradient.svg",sizes:"any",type:"image/svg+xml"}],theme_color:"#845BAC",background_color:"#845BAC"}}t.ManifestRouter=class{router(){return s.default.Router().get("/site.webmanifest",(0,o.wrap)("SiteManifest",this.siteManifest.bind(this)))}async siteManifest(e,t,i){const r=await((0,u.LibraryUIDStore)()?.readUid_().catch((()=>{}))),s=(0,l.requestedUri)(e,{protocol:"http",host:c.Settings.hostname.value}),n=await h({id:r,requestUri:s});d().debug("siteManifest",n),t.type("application/manifest+json").json(n)}},t.siteManifest=h},16271:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.OpenAssetFileRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(51773),o=i(72308),l=i(31586),u=i(54017),c=(0,n.mkLogger)("web.OpenAssetFileRouter");t.OpenAssetFileRouter=class{constructor(e){this.openFileService=e}router(){return s.default.Router().get("/api/openAssetFile/:assetFileId",(0,a.wrap)("OpenAssetFileRouter.assetFile",this.assetFile.bind(this)))}async assetFile(e,t){if(c.info("assetFile(): got request",{url:e.originalUrl,ip:e.ip}),!(0,o.isLocalhost)(e.ip))return c.info("Non-localhost request",{url:e.originalUrl,ip:e.ip}),t.sendStatus(400);const i=(0,l.toInt)(e.params.assetFileId);if(!(0,l.gt0)(i))return c.info("Missing assetFileId",e.originalUrl),t.sendStatus(400);const r=u.AssetFile.ops().findOneBy({id:i});if(null==r)return c.info("Invalid assetFileId",e.originalUrl),t.sendStatus(400);const s=await r.posixFile_();return null==s||await s.clear().notExists()?(c.info("File not found",{url:e.originalUrl,af:r,file:s}),t.sendStatus(400)):(c.info("Requesting openFileService("+s.nativePath+")...",{url:e.originalUrl,ip:e.ip}),this.openFileService(s.nativePath),t.sendStatus(204))}}},24255:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PingRouter=void 0;const s=r(i(7252)),n=i(99331),a=i(51140);t.PingRouter=class{router(){return s.default.Router().get("/ping",((e,t)=>t.sendStatus((0,n.ending)()?a.HttpStatus.ServiceUnavailable:a.HttpStatus.OK)))}}},39761:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getPlansLicense=t.getPlansBilling=t.getPlansActivate=t.getPlansPick=t.PlansRouter=void 0;const s=r(i(7252)),n=i(19851),a=i(50213),o=i(88158),l=i(37805),u=i(51773),c=i(68178),d=i(33603),h=i(70114),f=i(28874),m=i(22573),p=i(42659),g=i(59455),y=(0,n.lazy)((()=>(0,a.mkLogger)("web.PlansRouter")));async function v(e,t){return await S({req:e,res:t,remotePath:"/plans/pick"})}async function w(e,t){return await S({req:e,res:t,remotePath:"/",params:{skipIndex:!0}})}async function b(e,t){return await S({req:e,res:t,remotePath:"/"})}async function S({req:e,res:t,remotePath:i,params:r={}}){const s=(0,c.requestedUri)(e).with({path:"/plans/license"}),n=await(0,d.sids)({timeoutMs:4*p.secondMs}),a=new URL("https://account.photostructure.com"+i);return a.searchParams.append("version",l.version),a.searchParams.append("uids",n.join(",")),(0,m.mapNotBlank)(f.Settings.coupon.value,(e=>a.searchParams.append("coupon",e))),a.searchParams.append("redirectToLibraryUrl",s.toString()),(0,o.mapEntries)(r,((e,t)=>a.searchParams.append(e,t))),y().info("GET /plans/pick",{redirectToLibraryUrl:s.toString()}),t.redirect(a.toString())}async function P(e,t){try{(0,m.mapNotBlankOr)(e.query.license,(async e=>{await(0,h.writeLicense)(e,3*p.secondMs),y().info("getPlansLicense(): Saved new license",e)}),(()=>{y().info("getPlansLicense(): no license in request",e.originalUrl)}))}catch(t){y().error("getPlansLicense(): Failed to save license",{err:t,url:e.originalUrl})}const i=(0,m.notBlankOr)((0,g.toA)(e.query.then)[0],"/settings");y().info("getPlansLicense(): redirecting to "+i),t.redirect(i)}t.PlansRouter=class{router(){return s.default.Router().get("/plans/pick",(0,u.wrap)("GET /plans/pick",v)).get("/plans/activate",(0,u.wrap)("GET /plans/activate",w)).get("/plans/billing",(0,u.wrap)("GET /plans/billing",b)).get("/plans/license",(0,u.wrap)("GET /plans/license",P))}},t.getPlansPick=v,t.getPlansActivate=w,t.getPlansBilling=b,t.getPlansLicense=P},37380:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgressProvider=void 0;const r=i(58587),s=i(1708),n=i(89788),a=i(54557),o=i(19851),l=i(50213),u=i(56519),c=i(18454),d=i(43334),h=i(69385),f=i(40958),m=i(38639),p=i(42659),g=i(96249),y=i(49769),v=i(12236),w=i(54993),b=i(43487),S=i(54017),P=i(49796),_=(0,o.lazy)((()=>(0,l.mkLogger)("web.ProgressWithAssets")));t.ProgressProvider=class{constructor(e=10){this.maxLen=e,this.priorRecentAssets=new a.FifoCache(15,15*p.secondMs),this.testProgressStatesByVolume=new Map}async updates(){return(0,u.thenMap)(this.states(),(e=>({states:e})))}async states(){if((0,h.isPaused)())return[{volume:"⏸",state:"paused",hed:"Paused",dek:["Processing is paused. Resume via the navigation menu"+(d.isElectron?" or the system tray menu":"")+"."],recentAssetIds:[]}];const e=await c.HealthCheck.errorResults();if((0,f.isNotEmpty)(e))return _().warn("health check is failing",{errors:e}),[{volume:"⚠️",state:"paused",hed:"Health checks failed. Click for details.",dek:(0,f.uniq)((0,g.flatten)(e.map((e=>e.msg)))),recentAssetIds:[]}];const t=this.recentProgress();return _().debug("recentProgressWithAssets()",t),(0,f.isEmpty)(t)&&(0,m.isTrue)(s.env.TEST_PROGRESS)?this.testProgress():t}recentProgress(){const e=P.Progress.ops().allf((e=>e.where("updatedAt",">",Date.now()-p.minuteMs).whereNotNull("state").orderBy("volume")));(0,f.filterInPlace)(e,(e=>!(!(0,r.pidExists)(e.pid)&&"done"!==e.state&&(_().warn("Incomplete progress is from a dead process",{progress:e}),e.upsert({state:null}),1))));const t=[],i=new Set;for(const r of e){const e="done"===r.state,s=r.toSyncState(),n=this.priorRecentAssets.get((0,w.toS)(r.id))??[];if(!e){const e=((0,v.noRecentAssetIdsProgress)(s)?[]:S.AssetFile.recentAssetIdsByUriRoot((0,v.isRebuildProgress)(s)?void 0:s.uri,p.minuteMs,this.maxLen+i.size)).filter((e=>!i.has(e)&&!n.includes(e)));(0,f.isNotEmpty)(n)&&e.length>=this.maxLen&&e.splice(0,this.maxLen-1),n.unshift(...e),n.length=this.maxLen,this.priorRecentAssets.set((0,w.toS)(r.id),n);for(const e of n)i.add(e)}t.push({...s,recentAssetIds:n})}return t}async testAssetIds(e){const t=(0,y.getOrSet)(this.testProgressStatesByVolume,e,(()=>new n.BoundedList(this.maxLen))),i=b.Asset.dbl.pluckFirstf((e=>b.Asset.shownUnhidden(e).select("id").orderByRaw("random()").first()));return null!=i&&t.push(i),t.toA()}async testProgress(){const e=Math.round(Date.now()/(30*p.secondMs))%3,t=(d.isWin?["C:","D:","E:"]:["/","/home/bob/pictures","/mnt/nas"])[e];return[{volume:t,state:"processing",hed:"Processing, about 32 minutes remaining",dek:["Processing C:\\Users\\mrm\\Pictures\\20161214-pixel\\DCIM\\Camera\\IMG_20160903_090736.jpg","Processed 445 images and videos. 1,386 remain to be processed."],completePct:40,incompletePct:25,scanningPct:35,recentAssetIds:await this.testAssetIds(t)}]}}},8283:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.render=void 0;const r=i(72993),s=i(19851),n=i(50213),a=i(7282),o=i(81674),l=i(72308),u=i(45969),c=i(43334),d=i(28874),h=i(69385),f=i(38639),m=i(13538),p=i(2322),g=i(48723),y=(0,s.lazy)((()=>(0,n.mkLogger)("web.PugHelpers")));t.render=async function(e,t,i,s={}){const n=e.headers["user-agent"];t.setHeader("Feature-Policy","autoplay 'self'");const v=[],w=!0===n?.toLowerCase().includes("electron")&&(0,l.isLocalhost)(e.ip)||(0,f.isTrue)(e.query.electron);w&&(v.push("electron"),c.isMac?v.push("mac"):c.isWin?v.push("win"):c.isLinux&&v.push("linux")),(0,a.isDev)()&&v.push("is-dev"),(0,p.isChrome)(n)?v.push("chrome"):(0,p.isSafari)(n)?v.push("safari"):(0,p.isFirefox)(n)&&v.push("firefox"),(0,p.isIphone)(n)?v.push("iphone"):(0,p.isIpad)(n)&&v.push("ipad"),(0,h.isPaused)()&&v.push("is-paused"),(0,l.isLocalhost)(e.ip)&&!(0,u.isDocker)()&&v.push("is-localhost");try{!0===await(0,m.thenOrTimeout)((0,o.p)(),250)&&v.push("is-plus")}catch{}d.Settings.enableArchive.valueOrDefault&&v.push("enable-archive"),d.Settings.enableDelete.valueOrDefault&&v.push("enable-delete"),d.Settings.enableRemove.valueOrDefault&&v.push("enable-remove");const b={bodyClass:v.join(" "),isDocker:(0,u.isDocker)(),isElectron:w,isDev:a.isDev,nonce:t.locals.cspNonce,hasEmail:d.Settings.email.hasValue(),...s};y().debug("render()",{ua:n,template:i,options:b,headers:e.headers}),t.render(i,{rootTags:null==g.Tag.db()?void 0:g.Tag.roots(),title:(0,r.AppName)(),...b})}},8446:(e,t,i)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SSEHealthRouter=void 0;const r=i(22911),s=i(18405),n=i(18454),a=i(72901),o={event:"done",data:{done:!0}};function l(e){return null==e?void 0:{event:"result",data:e}}class u extends s.ServerSentEventsRouter{constructor(){super("/sse/health")}firstEvents(e,t){return this.sendResults(t),[]}async sendResults(e){const t=[],i=[];i.push(n.HealthCheck.summary());for(const e of n.HealthCheck.all()){const r=e.toResultSync();i.push(r),("pending"===r.level||e.isStale())&&t.push(e)}e.write((0,a.mkEventStream)(...i.map(l))),this.logger.debug("sendResults (sync)",{pending:t.map((e=>e.id)),resolved:i.map((e=>e.id))});for await(const i of r.Deferred.toAsyncIterable(t.map((e=>e.result())))){const t=(0,a.mkEventStream)(l(i),l(n.HealthCheck.summary()));this.logger.debug("sendResults (async)",{result:i,chunk:t}),e.write(t)}e.write((0,a.mkEventStream)(l(n.HealthCheck.summary()),o),(()=>this.endStream(e)))}}t.SSEHealthRouter=u},44143:function(e,t,i){"use strict";var r,s,n=this&&this.__classPrivateFieldGet||function(e,t,i,r){if("a"===i&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?r:"a"===i?r.call(e):r?r.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SSEProgressRouter=void 0;const a=i(18405),o=i(72901),l=i(51140),u=i(40958),c=i(94383),d=i(76386);class h extends a.ServerSentEventsRouter{constructor(e){super(c.ApiProgressPath),r.add(this),this.updatesProvider=e}firstEvents(){return setTimeout((()=>n(this,r,"m",s).call(this)),250),[]}router(){return super.router().patch(d.ApiProgressPatchPath,this.onSendUpdates.bind(this))}async onSendUpdates(e,t){try{return this.logger.debug("Received PATCH, sending updates.",{remotePort:e.socket?.remotePort}),await n(this,r,"m",s).call(this),t.sendStatus(l.HttpStatus.OK)}catch(e){return this.logger.warn("onSendUpdates(): Failed to send updates",{error:e}),t.sendStatus(l.HttpStatus.InternalServerError)}}}t.SSEProgressRouter=h,r=new WeakSet,s=async function(){if(!this.ended&&!(0,u.isEmpty)(this.streams))try{const e=await this.updatesProvider.updates();if(null==e)return void this.logger.warn("Failed to fetch updates");if(this.ended)return;const t=(0,o.mkEventStream)({data:e});(0,u.filterInPlace)(this.streams,(e=>!e.destroyed));for(const e of this.streams)try{e.write(t)}catch{}}catch(e){this.logger.warn("Failed to send updates",e)}}},59898:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsRouter=void 0;const s=r(i(7252)),n=i(51168),a=i(76760),o=i(50213),l=i(7282),u=i(71567),c=i(87290),d=i(55939),h=i(34102),f=i(51773),m=i(83278),p=i(66106),g=i(81674),y=i(43205),v=i(45969),w=i(43334),b=i(4936),S=i(28874),P=i(2858),_=i(40958),T=i(22573),M=i(38639),E=i(42659),k=i(75240),D=i(98553),x=i(55835),C=i(68708),F=i(13538),A=i(12168),I=i(59455),O=i(54993),L=i(78339),R=i(57064),N=i(8283),B=(0,o.mkLogger)("web.SettingsRouter");t.SettingsRouter=class{constructor(e=c.libraryDirPosixFile,t=L.librarySettings,i=R.suggestedLibraryDirs){this.libraryDir=e,this.settings=t,this.libraryDirSuggester=i}router(){return s.default.Router().get("/setting",((e,t)=>t.redirect("/settings"))).get("/settings",(0,f.wrap)("GET /settings",this.get.bind(this))).post("/settings",(0,f.wrap)("POST /settings",this.post.bind(this)))}async get(e,t){const{err:i,libraryDir:r}=e.body;try{await(0,P.readSettings)();const s=await(0,F.thenOrTimeoutError)(this.requestSettings(e),1e3);return await(0,F.thenOrTimeoutError)(this.renderSettings(e,t,s,r,i),1e3)}catch(e){return B.warn("requestSettings() took too long. Redirecting to the health check page.",e),t.redirect("/health")}}async renderSettings(e,t,i,r,s){(0,h.ee)().emit("clearCache");let o=await this.libraryDirSuggester();if(null==(0,O.toS)(s).match(/choose a different directory/i)){const e=await R.SuggestedLibraryDir.for(r);null!=e&&o.unshift(e)}(0,_.isEmpty)(o)&&(o=void 0);const u=this.libraryDir();(0,T.blank)(s)&&(0,v.isDocker)()&&(null==u||await u.isNotDirectory())&&(s=`PS_LIBRARY_DIR, ${u?.nativePath??"/ps/library"}, doesn't exist: please add it as a bind mount.`);const c=await(0,p.getVideoToolDetails_)((0,l.isProd)()?void 0:e.query),C=await(0,d.picturesDir)(),F=await(0,g.b)(),I={err:s,...i,autoUpdateCheck:i.autoUpdateCheck??!0,allowUserAgent:i.allowUserAgent??!0,reportErrors:i.reportErrors??!0,welcome:(0,x.mapOr)((0,l.isProd)()?void 0:e.query.welcome,M.isTrue,(()=>!(0,P.libraryHasSettings)())),title:null==u?"Welcome!":"Settings",videoToolDetails:c,picturesPath:C,jsonScanPaths:(0,x.map)(S.Settings.scanPaths.value,D.stringify),delimiter:a.delimiter,exampleScanPath:[C,w.isWin?"D:\\PHOTOS":w.isMac?"/Volumes/External HD/Pictures":"/mnt/nas/homes/photos"].join(a.delimiter),currentLibraryDir:(0,x.map)(u,(e=>e.nativePath)),minFreeAvailable:(0,A.fmtBytes)(S.Settings.minDiskFreeGb.valueOrDefault*A.GB),suggestedLibraryDirs:o,samplePath:(0,b.pathToLibraryAsset)(n.DateTime.now(),m.BaseFile.for("photo.jpg")).join(a.sep),subTier:await(0,g.t)(),subTrial:(0,M.isTrue)(F?.l?.trial),subEmail:F?.l?.sub,subExpiresInDuration:(0,x.map)(F?.l?.exp,(e=>(0,k.fmtDuration)(e.getTime()-Date.now(),1))),subExpiresAt:(0,x.map)(F?.l?.exp,E.fmtIsoDate),userAgent:await(0,y.systemUserAgent)()};B.info("rendering settings",I),(0,f.disableCache)(t),await(0,N.render)(e,t,"settings",I)}async post(e,t){const i=e.body,r=(0,T.toNotBlank)("libraryDirCustom"===i.libraryDirRadio?i.libraryDir:i.libraryDirRadio),s=i=>this.renderSettings(e,t,c,r,i),n=r??S.Settings.libraryDir.valueOrDefault;if((0,T.blank)(n))return s("Please choose a directory for your library.");const o=(0,a.resolve)(n),c=await this.requestSettings(e);B.info("POST",{libraryDir:o,settings:c,body:i}),(0,l.isTest)()&&(0,u.stdoutWrite)({post:i,settings:c,method:e.method,libraryDir:o});try{const e=await(0,L.saveLibrarySettings)(o,c);if("error"in e)return B.info("error saving library settings",{result:e}),s(e.error);B.info("saved library settings. Waiting for bookkeeping to finish...",e),await e.ready,B.info("ready. Redirecting to /splash...",e)}catch(e){return s(e)}return t.redirect("/splash")}async requestSettings(e){const{scan:t,scanPath:i,copyAssets:r,autoUpdateCheck:s,allowUserAgent:n,reportErrors:a}=e.body,o=this.settings();return(0,T.notBlank)(t)&&(o.scanAllDrives="scanAllDrives"===t,o.scanPath=(0,_.compactBlanks)((0,I.toA)(i))),(0,T.notBlank)(r)&&(o.copyAssets="copyEnabled"===r),o.allowUserAgent=(0,M.toBoolean)(n),o.autoUpdateCheck=(0,M.toBoolean)(s),o.reportErrors=(0,M.toBoolean)(a),B.info("requestSettings()",{req_body:(0,C.pick)(e.body,"scan","scanPath","copyAssets","autoUpdateCheck","allowUserAgent","reportErrors"),result:o}),(0,L.librarySettings)(o)}}},77203:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SpaRouter=void 0;const s=r(i(7252)),n=i(51773),a=i(68178),o=i(75710),l=i(8283);t.SpaRouter=class{router(){const e=(0,n.wrap)("SpaRouter",this.get.bind(this));return s.default.Router().get("/tag*",e).get("/asset/:assetId",(0,n.wrap)("SpaRouter.Asset",this.getAsset.bind(this))).get("/search",e)}async getAsset(e,t,i){const r=await(0,o.getAssetOpenGraph)((0,a.requestedUri)(e),e.params.assetId);return(0,l.render)(e,t,"app",null==r?{}:{meta:r})}get(e,t,i){if(!e.path?.startsWith("/tag")||null!=(0,n.getSeedOrRedirect)(e,t))return(0,l.render)(e,t,"app",{})}}},2314:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.VideoRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(51773),o=i(40958),l=i(55835),u=i(31586),c=i(54017),d=(0,n.mkLogger)("web.VideoRouter");t.VideoRouter=class{constructor(e){this.previews=e}router(){return s.default.Router().get("/video/:assetId",(0,a.wrap)("VideoRouter",this.videoImage.bind(this)))}async videoImage(e,t,i){const r=e.params,s=(0,u.toInt)(r.assetId);if(!(0,u.gt0)(s))return d.warn("Malformed request (missing assetId)",{params:e.params}),t.sendStatus(400);const n=this.previews.ap(s).mp4();if(await n.exists())return d.info("streaming transcoded video",n),t.sendFile(n.nativePath);const a=c.AssetFile.ops().findBy({assetId:s,shown:1});if((0,o.isEmpty)(a))return d.warn("Malformed request (bad assetId)",{params:e.params}),t.sendStatus(400);const h=a[0],f=await(0,l.map)(h,(e=>e.posixFile_()));return null!=f&&h.isVideo&&await f.exists()?t.sendFile(f.nativePath):(d.warn("Shown assetFile isn't a video",h),t.sendStatus(400))}}},1739:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebService=void 0;const s=r(i(7252)),n=r(i(2525)),a=r(i(77598)),o=r(i(1708)),l=i(19851),u=i(50213),c=i(97352),d=i(71567),h=i(99331),f=i(45608),m=i(56519),p=i(38835),g=i(57159),y=i(41293),v=i(27821),w=i(78147),b=i(68178),S=i(43394),P=i(62327),_=i(30576),T=i(95696),M=i(43899),E=i(8797),k=i(63664),D=i(18454),x=i(21525),C=i(45657),F=i(33603),A=i(39471),I=i(29325),O=i(28874),L=i(2858),R=i(63870),N=i(7014),B=i(55111),j=i(51140),z=i(93493),V=i(41400),W=i(55835),U=i(62220),q=i(13538),H=i(459),$=i(27776),G=i(64526),J=i(18449),K=i(95629),Y=i(37158),X=i(8400),Z=i(13808),Q=i(76020),ee=i(13831),te=i(53881),ie=i(21598),re=i(49296),se=i(19583),ne=i(18848),ae=i(81100),oe=i(4950),le=i(76018),ue=i(16271),ce=i(24255),de=i(39761),he=i(37380),fe=i(8446),me=i(44143),pe=i(59898),ge=i(77203),ye=i(2314),ve=i(98949),we=i(43268);function be(e,t){t.endsWith(".js")&&e.setHeader("Content-Type","application/javascript")}const Se=(0,u.mkLogger)("web.WebService"),Pe=e=>(0,E.showFileInFolder)(T.PosixFile.for(e));t.WebService=class{constructor(){this.setup=(0,l.lazy)((async()=>{if(Se.debug("setup(): started"),o.default.on("SIGPIPE",(()=>{})),O.Settings.libraryDir.watchLater((()=>ke.unset())),await(0,m.rejected)(this.service.ready))return void Se.error("setup(): failed, service.ready was rejected");await(0,z.setupShimDelegates)();const e=this.app;if(e.use((new w.RequestLogger).router),e.use(((e,t,i)=>{t.locals.cspNonce=a.default.randomBytes(16).toString("hex"),i()})),O.Settings.trustProxy.hasValue()){const t=O.Settings.trustProxy.value,i="true"===t||"false"!==t&&(0,c.mapGte0Or)(t,(e=>e),t);e.set("trust proxy",i),Se.info("trust proxy set",{value:i})}if(e.use(P.expressErrorHandlerWithToast),(0,J.sentryEnabled)())try{e.use(i(16436).Handlers.requestHandler())}catch(e){Se.warn("Failed to initialize Sentry requestHandler",{error:e})}if(O.Settings.disabledHelmetMiddleware.valueOrDefault.includes(B.HelmetPlugins.all))Se.warn("DANGER: disabledHelmetMiddleware includes 'all': not enabling any Helmet middleware.");else{O.Settings.disabledHelmetMiddleware.valueOrDefault.includes(B.HelmetPlugins.contentSecurityPolicy)||e.use(ne.cspHandler);const t={contentSecurityPolicy:!1};for(const e of O.Settings.disabledHelmetMiddleware.valueOrDefault.filter((e=>e!==B.HelmetPlugins.all)))t[e]=!1;e.use((0,n.default)(t))}e.use(b.addXSettingsHandler),e.use(we.json()),e.use(we.urlencoded({extended:!1}));const t=M.ProjectPath.Public(),r=M.ProjectPath.Views();if(Se.info("setup()",{libraryDir:O.Settings.libraryDir.valueOrDefault,publicRoot:t,viewsRoot:r}),L.libraryHasSettings.watch((()=>e.set("etag",(0,L.libraryHasSettings)()))),e.set("views",r),e.set("view engine","pug"),e.use((new ce.PingRouter).router()),e.use((new y.ApiHealthRouter).router()),e.use((0,_.viewRouter)({path:"/splash",view:"splash"})),e.use((new ie.ApiSplashRouter).router()),e.use((0,_.viewRouter)({path:"/health",view:"health"})),e.use((new fe.SSEHealthRouter).router()),e.use((new Q.AdminPostRouter).router()),e.get("/status",((e,t)=>t.redirect("/health"))),e.use(await(0,S.serveStaticGz)(t)),e.use(s.default.static(t,{setHeaders:be})),e.use((new Z.AboutRouter).router()),e.use((new ve.WelcomeRouter).router()),e.use((new de.PlansRouter).router()),e.use(Ee()),(0,I.isPacked)()||(e.use("/die",((e,t)=>{Se.info("/die was requested",{url:e.originalUrl}),t.sendStatus(j.HttpStatus.Accepted),(0,f.exit)({reason:"/die",status:1})})),e.use("/test-sentry",((e,t)=>{(0,K.sendToSentry)(new g.WrappedError("test message sent to sentry at "+new Date)),t.sendStatus(j.HttpStatus.Accepted)}))),e.use(((e,t,i)=>(0,h.ending)()?(Se.info("ending(): returning 500",{requestUri:(0,b.requestedUri)(e)}),t.sendStatus(500)):function(){const e=D.HealthCheck.runState();switch(e){case U.RunStates.loading:return _e();case U.RunStates.welcome:return Me();case U.RunStates.ready:return ke()??ke.refresh()??Te();case U.RunStates.failed:return Te();default:throw new H.UnreachableCaseError(e)}}()(e,t,i))),(0,J.sentryEnabled)())try{e.use(i(16436).Handlers.errorHandler())}catch(e){Se.warn("Failed to initialize Sentry error handling",{error:e})}const l=O.Settings.httpPort.valueOrDefault,u=O.Settings.exposeNetworkWithoutAuth.valueOrDefault,v=G.Library.instance();null!=v?D.HealthCheck.addLoadingMsg("Loading library..."):D.HealthCheck.addLoadingMsg("Starting...");const T=async()=>{Se.info("setup(): http server callback",{httpPort:l,expose:u});const e=[O.Settings.httpPort];null!=v&&e.push(O.Settings.libraryDir),(0,d.stdoutWriteSettings)(...e),null==v?((0,F.sids)((0,R.commandTimeoutMs)()).catch((e=>Se.warn("failed to prefetch sids",e))),(0,N.volumes)().catch((e=>Se.warn("failed to prefetch volumes",e)))):(await(0,L.maybeUpgradeSystemSettings)(),await(0,L.maybeUpgradeLibrarySettings)(),await v.ready,ke.unset()),await(0,X.libraryHealthCheckSetup)(),await D.HealthCheck.awaitSettled(),await(0,q.thenOrTimeout)((0,C.r)(),(0,R.commandTimeoutMs)()),null!=v&&((0,x.isHealthCheckLevelFatal)((await(0,k.getLocalHealthSummary)()).level,"sync")?Se.warn("setup(): health check failed, so we're not starting sync."):d.StdoutWrite.restartSync())},E=u?e.listen(l,T):e.listen(l,O.Settings.localhost.valueOrDefault,T);return E.on("error",(e=>{Se.warn("http.server.onError()",e),"EADDRINUSE"===e.code&&(0,f.exit)({reason:"Port "+l+" is already in use: is PhotoStructure already running?"+p.FatalErrorFlag+p.DoNotSendErrorFlag+p.WebFatalErrorFlag,error:e,status:3})})),new A.EndableServer("http.WebService",E)})),this.app=(0,s.default)(),this.service=new Y.Service("web"),this.setup()}};const _e=(0,l.lazy)((()=>(0,v.redirectRouter)("/splash"))),Te=(0,l.lazy)((()=>(0,v.redirectRouter)("/health"))),Me=(0,l.lazy)((()=>(0,v.redirectRouter)("/welcome"))),Ee=(0,l.lazy)((()=>(new pe.SettingsRouter).router())),ke=(0,l.lazy)((()=>{const e=G.Library.instance();if(null==e)return Se.warn("libraryRouter invoked before library is set up."),void setImmediate((()=>ke.unset()));Se.info("Setting up library router for "+(0,W.map)(e,(e=>e.rootDir)));const t=e.previews(),i=new he.ProgressProvider,r=s.default.Router();return r.use((new le.ManifestRouter).router()),r.use(new re.ApiSystemRouter(Pe).router()),r.use((new se.ApiTagRouter).router()),r.use(new ee.ApiAssetRouter(t).router()),r.use((new te.ApiSearchRouter).router()),r.use((new ge.SpaRouter).router()),r.use(new ue.OpenAssetFileRouter(Pe).router()),r.use(new ae.ImgActualRouter(t).router()),r.use(new oe.ImgRouter(t).router()),r.use(new ye.VideoRouter(t).router()),r.use(new me.SSEProgressRouter(i).router()),r.use("/",((e,t)=>{Se.debug("in root route",{res_headersSent:t.headersSent,res_headers:t.getHeaders()}),t.redirect(302,(0,$.mkHomeFullPath)(e.query))})),r}));(0,V.later)((()=>{O.Settings.libraryDir.watchLater((()=>ke.unset()))}))},98949:function(e,t,i){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WelcomeRouter=void 0;const s=r(i(7252)),n=i(50213),a=i(51773),o=i(18454),l=i(81674),u=i(28874),c=i(51140),d=i(57064),h=i(39761),f=i(8283);t.WelcomeRouter=class{constructor(){this.logger=(0,n.mkLogger)("WelcomeRouter")}router(){return s.default.Router().get("/welcome",(0,a.wrap)("GET /welcome",this.get.bind(this))).post("/welcome",(0,a.wrap)("POST /welcome",this.post.bind(this)))}async get(e,t){return"welcome"!==o.HealthCheck.runState()?t.redirect(c.HttpStatus.Found,"/"):((0,d.suggestedLibraryDirs)(),(0,f.render)(e,t,"welcome",{}))}async post(e,t){return!u.Settings.pickPlanOnWelcome.valueOrDefault||await(0,l.p)()?t.redirect("/settings"):(0,h.getPlansPick)(e,t)}}},90858:e=>{"use strict";e.exports=require("@iarna/toml")},53705:e=>{"use strict";e.exports=require("@photostructure/tz-lookup")},16436:e=>{"use strict";e.exports=require("@sentry/node")},64770:e=>{"use strict";e.exports=require("assert")},58587:e=>{"use strict";e.exports=require("batch-cluster")},87550:e=>{"use strict";e.exports=require("better-sqlite3")},43268:e=>{"use strict";e.exports=require("body-parser")},6858:e=>{"use strict";e.exports=require("commander")},36507:e=>{"use strict";e.exports=require("croner")},66261:e=>{"use strict";e.exports=require("events")},77988:e=>{"use strict";e.exports=require("exiftool-vendored")},7252:e=>{"use strict";e.exports=require("express")},66150:e=>{"use strict";e.exports=require("fast-xml-parser")},68817:e=>{"use strict";e.exports=require("file-type")},44652:e=>{"use strict";e.exports=require("fs-extra")},28787:e=>{"use strict";e.exports=require("he")},2525:e=>{"use strict";e.exports=require("helmet")},31832:e=>{"use strict";e.exports=require("knex")},51168:e=>{"use strict";e.exports=require("luxon")},93973:e=>{"use strict";e.exports=require("ml-kmeans")},80265:e=>{"use strict";e.exports=require("moo")},31704:e=>{"use strict";e.exports=require("nearley")},4927:e=>{"use strict";e.exports=require("papaparse")},83058:e=>{"use strict";e.exports=require("picomatch")},22915:e=>{"use strict";e.exports=require("platform-folders")},57272:e=>{"use strict";e.exports=require("plist")},85949:e=>{"use strict";e.exports=require("process")},90595:e=>{"use strict";e.exports=require("punycode")},38064:e=>{"use strict";e.exports=require("semver")},9288:e=>{"use strict";e.exports=require("sharp")},93944:e=>{"use strict";e.exports=require("source-map-support")},49378:e=>{"use strict";e.exports=require("trash")},73872:e=>{"use strict";e.exports=require("type-detect")},92460:e=>{"use strict";e.exports=require("util")},75162:e=>{"use strict";e.exports=require("util/types")},29907:e=>{"use strict";e.exports=require("cluster")},76982:e=>{"use strict";e.exports=require("crypto")},34589:e=>{"use strict";e.exports=require("node:assert")},31421:e=>{"use strict";e.exports=require("node:child_process")},77598:e=>{"use strict";e.exports=require("node:crypto")},40610:e=>{"use strict";e.exports=require("node:dns")},78474:e=>{"use strict";e.exports=require("node:events")},73024:e=>{"use strict";e.exports=require("node:fs")},51455:e=>{"use strict";e.exports=require("node:fs/promises")},37067:e=>{"use strict";e.exports=require("node:http")},44708:e=>{"use strict";e.exports=require("node:https")},77030:e=>{"use strict";e.exports=require("node:net")},48161:e=>{"use strict";e.exports=require("node:os")},76760:e=>{"use strict";e.exports=require("node:path")},53916:e=>{"use strict";e.exports=require("node:path/posix")},1708:e=>{"use strict";e.exports=require("node:process")},57075:e=>{"use strict";e.exports=require("node:stream")},46466:e=>{"use strict";e.exports=require("node:stream/promises")},87997:e=>{"use strict";e.exports=require("node:timers")},57975:e=>{"use strict";e.exports=require("node:util")},38522:e=>{"use strict";e.exports=require("node:zlib")},16928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=5379);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/bin/worker.js b/bin/worker.js index 5af725e..14cdf41 100755 --- a/bin/worker.js +++ b/bin/worker.js @@ -6,4 +6,4 @@ * IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THIS SOFTWARE */ -(()=>{"use strict";var __webpack_modules__={37975:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const n=i(22573),r=i(38639),s=i(44198);function a(){return(0,r.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,n.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=a;let o=!a();function l(){return o}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){o=e??!a()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const n=i(19851),r=i(7282),s=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,n.lazy)((()=>t.SimpleAppName+((0,r.isProd)()?"":`-${(0,r.nodeEnv)()}`))),t.AppNameVersion=(0,n.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const n=i(40958),r=i(36783),s=i(76790),a=i(22573),o=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=n.primitiveValueOfOrElse){const r=new Set(t.map(i));return e.filter((e=>r.has(i(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...v(e.slice(i+1))]}function w(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let n=0;ne?.[n])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return M(e,(e=>e.valueOf()))}function P(e,t){return E(e,t,((e,t)=>(0,h.lt)(e,t)))}function M(e,t){return E(e,t,((e,t)=>(0,h.gt)(e,t)))}function _(e,t){return(0,n.isEmpty)(e)?void 0:e[P(e,t)]}function E(e,t,i){return x(e,t,i).index}function x(e,t,i){if((0,n.isEmpty)(e))return{index:-1,value:void 0};let r,s=-1;for(let n=0;ne.slice(i,i+t)))}async function D(e,t){return(0,n.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,o.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(a.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const n=e[i];if(null!=n&&!0===await t(n))return n}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const n of e){i++;try{if(null!=n){const e=await t(n,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,n.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let n=i;n<=e.length-1;n++)if(t(e[n]))return n},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,n.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,o.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,r.copyArrayTo)((0,n.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],n=[];let r=0;for(const s of e)(t(s,r++)?i:n).push(s);return[i,n]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,n.compact)((0,n.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const n=(0,c.times)(t,(()=>new Array(i)));for(let r=0;re.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=M,t.leastBy=_,t.least=function(e){return _(e,(e=>e))},t.greatestBy=function(e,t){return(0,n.isEmpty)(e)?void 0:e[M(e,t)]},t.leastByCtx=function(e,t){const i=x(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=T,t.collectBatched=function(e,t,i){const r=[];for(const s of T((0,n.compact)((0,f.toA)(e)),t))r.push(...(0,n.compact)(i(s)));return r},t.collectBatchedAsync=async function(e,t,i){const r=[];for(const s of T((0,n.compact)((0,f.toA)(e)),t))r.push(...(0,n.compact)(await i(s)));return r},t.contextFilter=function(e,t){let i;return e.filter(((e,n)=>(0,d.tap)(t(e,n,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const n of e){const e=i.find((e=>e.some((e=>t(n,e)))));e?e.push(n):i.push([n])}return i},t.clusterEvery=function(e,t){const i=[];for(const n of e){const e=i.find((e=>e.every((e=>t(n,e)))));e?e.push(n):i.push([n])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const n of e){for(const e of i)if(null!=n&&await D(e,(e=>t(n,e)))){e.push(n);continue e}null!=n&&i.push([n])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[n],(e=>i(e,n))))return n}{const n=t+r;if(ne+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const o=i(77988),l=a(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),v=i(25764),w=i(38836),S=i(99331),b=i(95937),P=i(98314),M=i(38835),_=i(70025),E=i(8769),x=i(43334),T=i(95402),D=i(28874),k=i(63870);class C extends w.EndableWrapper{constructor(e,t,i=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,n,"m",r).call(this)),i,"worker"===e?(0,k.commandTimeoutMs)():y.ShortCommandTimeoutMs),n.add(this),this.t=t;const a=t;a.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,T.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),a.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),a.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),a.on("fatalError",(e=>{this.onError("on(fatalError)"+M.FatalErrorFlag,e)})),a.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),a.on("noTaskData",((e,i,n)=>{const r=t.options.streamFlushMillis;r{this.logger.error("observeBatchCluster.endError()",e)})),a.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&T.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof o.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,_.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,E.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=C,n=new WeakSet,r=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(x.isWin?3:1)*c.minuteMs,maxTasksPerProcess:D.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:D.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:D.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:D.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:D.Settings.taskTimeoutMs.valueOrDefault}}},89788:function(e,t,i){var n,r,s,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(n.add(this),this.maxLength=e,r.set(this,void 0),s.set(this,0),a.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,r,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,n,"m",o).call(this,e,(e=>u(this,r,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,n,"m",o).call(this,e,(e=>u(this,r,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(r=new WeakMap,s=new WeakMap,a=new WeakMap,n=new WeakSet,o=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,a,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,r,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,r,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,n,"m",o).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,r,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,s,"f"){u(this,r,"f")[e]=c,l(this,a,e,"f")}));return u(this,s,"f")}shift(){return u(this,n,"m",o).call(this,0,(e=>{var t,i;return l(this,a,(t=u(this,a,"f"),++t),"f"),l(this,s,(i=u(this,s,"f"),--i),"f"),u(this,r,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,n,"m",o).call(this,u(this,s,"f")-1-e,(e=>{const i=u(this,r,"f")[e];u(this,r,"f")[e]=u(this,r,"f")[t],u(this,r,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const n=i(54993),r=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:i}of r)if(a(e,t))return e.subarray(t.length).toString(i);return e.toString()}function a(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,n.toS)(e)},t.bufferStartsWith=a},9092:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const n=i(94863);class r{constructor(e=[],t=n.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=r},36638:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const n=i(94863);class r{constructor(e=[],t=n.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=r},40583:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const a=i(40958),o=i(23838),l=s(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new o.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,a.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let n,r=-1;for(const[i,s]of this.m.entries()){const a=(0,c.diceCoeff)(i,e);if(a>t&&a>r){const e=this.getFirst(s);null!=e&&(n=e,r=a)}}return n}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const n=i(76790),r=i(31586),s=i(68708),a=i(54993),o=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new o.Average(0);for(const t of this.keys()){if(!(0,r.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,a.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,n.sortBy)([...this.entries()],(([t,i])=>[-i,(0,r.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new o.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,n.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,n.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[n,r]of this.m.entries()){const s=e(n);t.fill(s,i,i+r),i+=r}return t}}t.CountingSet=u},79840:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const n=i(19851),r=i(72993),s=i(45969),a=i(43334);t.EditionType=(0,n.lazy)((()=>a.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,n.lazy)((()=>r.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const n=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,n.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const n=i(50357),r=i(55835),s=i(68708);var a=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return a.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,n.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,n.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,r.map2Or)(await e,await t,n.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,n.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,n.eql)((0,s.omit)(e,...i),(0,s.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,r.map2Or)(await e,await t,((e,t)=>(0,n.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const n=i(31658),r=i(19851),s=i(95696);t.examples=(0,r.lazy)((()=>s.PosixFile.for((0,n.examplesNativePath_)())))},31658:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const n=i(19851),r=i(65843),s=i(29882);t.examplesNativePath_=(0,n.lazy)((()=>{const e=(0,r.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,s.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const n=i(57975),r=i(40958),s=i(55835),a=i(31586),o=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,a.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,a.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,r.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[n.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,r.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,o.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,o.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,o.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,a.isNumber)(e.__uid)&&(0,a.isNumber)(e.__start)}},80049:function(e,t,i){var n,r,s,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,n.set(this,0),r.set(this,0),s.set(this,0),a.set(this,0),o.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,n,l(this,n,"f")+e.cacheHitsSync,"f"),u(this,r,l(this,r,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,a,l(this,a,"f")+e.rejections,"f"),u(this,o,l(this,o,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,n,"f"),cacheHitsAsync:l(this,r,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,a,"f"),timeouts:l(this,o,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,a,o;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,r,(i=l(this,r,"f"),++i),"f"),c.promise):(u(this,n,(a=l(this,n,"f"),++a),"f"),c.value)}if(c instanceof Error)throw c;return u(this,n,(o=l(this,n,"f"),++o),"f"),c}get(e){var t,i;const r=this.cache.get(e);return null==r||r instanceof m.Deferred&&r.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,n,(i=l(this,n,"f"),++i),"f"),r instanceof m.Deferred?r.value:r}clear(){this.cache.clear(),u(this,n,0,"f"),u(this,r,0,"f"),u(this,s,0,"f"),u(this,a,0,"f"),u(this,o,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const n=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,n),(0,c.gt0)(this.opts.timeoutMs)&&n.setTimeout(this.opts.timeoutMs),n.promise.then((e=>{this.set(i,e)}),(e=>{var t,n;this.cache.set(i,e),u(this,a,(t=l(this,a,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,o,(n=l(this,o,"f"),++n),"f")})),n.promise}},n=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,o=new WeakMap},54127:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class n{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=n},53507:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(31586),o=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,n.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const n=(0,a.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,r.range)(0,n).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,o.fromEntries)(e))).filter((e=>(0,o.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let n,o=0;for(;null!=(n=t.exec(this.headerRow));){const l=this.headerRow.substring(o,n.index);(0,s.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:n.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(n.index,t.lastIndex),d=n.index+((0,c.indexOfNonSpace)(u)??0),h=n.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:n,left:d,right:h});else{const e=(0,r.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,a.max_)(e?.rightIdx,n.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}o=t.lastIndex}const l=(0,r.last)(i);return null!=l&&((0,s.blank)(this.headerRow.slice(o))?l.rightIdx=(0,a.max_)(...this.rows.map((e=>e.length))):l.rightIdx=o),i}}t.Fixed=m},73168:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const n=i(55835),r=i(20014),s=i(55222),a=i(97352),o=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,a.within)(-90,90,e)&&0!==e}function c(e){return(0,a.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function h(e,t,i=o){return(0,n.map)(m(e,t,l(i)),(e=>s.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=o){return h(e?.lat,e?.lon,t)},t.geohash=h,t.geohashNumericShort=function(e,t){return m(e,t,30)};const f=new r.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=o){return d(e,t)?f.zip([t,e],l(i)):void 0}function p(e,t=o){return f.unzip(e,l(t))?.reverse()}function g(e,t=o){const[i,n]=p(e,t);return{lat:i,lon:n}}t.geohashNumeric=m,t.ungeohash=function(e,t=o){return(0,n.map)(s.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,n=t.lat*Math.PI/180,r=(t.lat-e.lat)*Math.PI/180,s=(t.lon-e.lon)*Math.PI/180,a=Math.sin(r/2)*Math.sin(r/2)+Math.cos(i)*Math.cos(n)*Math.sin(s/2)*Math.sin(s/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const n=i(51455),r=i(98553);var s=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const i=(0,r.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,r.parseJSON)((await(0,n.readFile)(e)).toString())}},19851:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const a=i(57975),o=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),n.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,n,"m",r).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,o.isEmpty)(this.watchers))return;const i=await e,n=await t;if(!(0,l.eql)(i,n))for(const e of this.watchers)e(n);null!=this.ttlMs&&this.ttlMs>0&&void 0!==n&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(42659),o=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,n.lazy)((()=>(0,o.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?_():E()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,n.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=w.exec(e.trim())?.groups;return null==i?void 0:(0,r.compact)([i.lang,i.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const M={timeoutMs:10*a.secondMs};async function _(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],M))}async function E(){return b(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],M)})))}t.localeMac=_,t.localePosix=E,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const n=i(48161),r=i(1708),s=i(45599),a=i(68708),o=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,s.defer)((()=>{(0,o.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:r.argv,arch:(0,n.arch)(),platform:(0,n.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,a.pick)(r.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:r.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const n=i(19851),r=i(32105),s=i(14593);t.rootLoggers=(0,n.lazy)((()=>[r.ConsoleLogger.instance()]));const a=(0,n.lazy)((()=>[r.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,a)}},56639:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const n=i(40958),r=i(55835),s=i(59455),a=i(48884);function o(e){const t=(0,n.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,a.concat)(...e.map((e=>t(e)))))},t.compactMap=o,t.toMap=function(e,t){return o((0,n.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:o(await Promise.all((0,n.compact)((0,s.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,n]of e)t[i]=n;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,n])=>t(i,n)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,r.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const n=i(98553),r=i(54557);t.memoize=function(e,t){let i=0;const s=new r.FifoCache(t.maxSize,t.ttlMs),a=t=>{if(null!=t)return i++,s.getOrSet((0,n.stringify)(t),(()=>e(t)))};return a.clear=e=>null==e?s.clear():s.delete((0,n.stringify)(e)),a.size=()=>s.size,a.callCount=()=>i,a}},31578:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const n=i(1708),r=i(31586),s=i(12168),a=i(70417);function o(){const e=(0,n.memoryUsage)();return(0,a.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,n.memoryUsage)().rss}t.memoryUsageBytes=o,t.memoryUsageMb=function(){return(0,r.sigFigs)(o()/s.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,r.sigFigs)(l()/s.MB,2)}},7282:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const r=n(i(1708)),s=i(38639),a=i(54993),o=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,o.lazy)((()=>r.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,a.toS)(r.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return r.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(r.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){r.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const n=i(40958),r=i(22573),s=i(96249),a=i(55835),o=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,o.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(o.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,o.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,a.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,o.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const n=(0,o.toInt)(e),r=(0,o.toInt)(t);return null!=n&&n>0&&null!=r&&r>0?i(n,r):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,o.isNumber)(e))return e;if((0,r.blank)(e))return;const t=String(e);return(0,a.map)(f.exec(t),(e=>(0,o.toFloat)(t.substr(e.index))))}function p(e){return(0,o.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),n=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,n,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let n=0;ne/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,a.map)(g(e,t),(([e,t])=>(0,n.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,a.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,n.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let n=0;const r=i*e.length;for(let i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const n=i(40958),r=i(42659),s=i(96249),a=i(55835),o=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,r.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[n,r]of(0,l.entries)(e)){const e=t(n,r);null!=e&&(i[n]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,a.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(a.defined)},t.firstDefinedField=function(e,...t){return(0,a.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,a.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,n.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,n]of m(t))null==e[i]&&(e[i]=n);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,n]of(0,l.entries)(t))null==e[i]&&(e[i]=n);return e},t.pickMap=function(e,t,i){const n={};for(const r of t)n[r]=i(r,e[r]);return n},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const n={};let r=0;for(const s of(0,l.keys)(e))if(n[s]=t(s,e[s]),r++,(0,o.gt)(r,i))break;return n},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const n of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[n]=e(t[n]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,n)=>i.includes(t)?void 0:e(n,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,n.uniq)((0,s.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const n=i(31421),r=i(73024),s=i(48161),a=i(19851),o=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),v=i(30933),w=(0,a.lazy)((()=>(0,f.mkLogger)("os")));function S(){return(0,s.platform)()+" "+(0,s.release)()}t.osArch=(0,a.lazy)((()=>`${function(){switch((0,s.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return C();case"win32":return F();default:return S()}}()} on ${(0,s.arch)()}`)),t.osFullName=(0,a.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const b=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function M(){return"ubuntu"===(0,t.osDistributionLinux)()}function _(){return"fedora"===(0,t.osDistributionLinux)()}function E(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,a.lazy)((()=>{if(g.isLinux)for(const e of b)try{const t=(0,r.readFileSync)(e).toString();if((0,o.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,a.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,o.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),S)})),t.osDistributionLinux=(0,a.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=M,t.hasApt=function(){return P()||M()},t.isFedora=_,t.isAlpine=E;const x={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},T={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function D(e,t){const[i,n]=function(e){return e.split(".").slice(0,2)}(e),r=t[i];return(0,c.isString)(r)?r:r?.[n]}const k=(0,a.lazy)((()=>(0,n.execSync)("sw_vers -productVersion").toString().trim()));function C(e=k()){try{return(0,o.mapNotBlankOr)(function(e=k()){return D(e,x)}(e),(t=>`macOS ${t} (${e})`),S)}catch(e){return w().warn("osNameMac(): unknown release",e),S()}}function F(e=(0,s.release)()){const t=e.startsWith("10.0.22")?"11":D(e,T);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=C,t.osNameWin=F,t.CPUs=(0,a.lazy)((()=>(0,h.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,a.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(F())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=k();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(M())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(_())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(E())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},12801:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const r=n(i(48161)),s=i(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:r.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:r.default.constants.priority.PRIORITY_NORMAL,BelowNormal:r.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:r.default.constants.priority.PRIORITY_LOW,Low:r.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{Object.defineProperty(t,"__esModule",{value:!0}),t.setProcessTitle=t.setShortProcessNames=void 0;const n=i(72993),r=i(50213),s=i(23560),a=i(43334);let o=!a.isElectron;t.setShortProcessNames=function(e){o=e},t.setProcessTitle=function(){try{const e=[o?n.SimpleShortAppName:n.SimpleAppName];(0,s.isMainService)()&&a.isElectron||e.push((0,s.serviceName)());const t=e.join(a.isElectron?" ":"-");i(85949).title=t}catch(e){(0,r.mkLogger)("ServiceNames").warn("Failed to set friendly process name",e)}}},409:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const n=i(41400),r=i(56409),s=i(31586),a=i(22911),o=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...n){f=!0,m=Date.now()+(0,s.max_)(t,i);const r=d=new a.Deferred(c);(0,s.gt0)(i)&&r.setTimeout(i);try{r.resolve(await e(...n))}catch(e){r.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,o.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return r.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,n.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new r.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const n=i(68708),r=i(54993);function s(e){return e instanceof a?e.source:(0,r.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let r;for(;null!=(r=e.exec(t));)r.index===e.lastIndex?e.lastIndex++:i.push((0,n.pick)(r,"index","groups"));return i},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const n=[];for(const t of e)try{n.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{n.push(s(t))}const r=0===n.length?t.NothingRegExp:n.map((e=>"(?:"+e+")")).join("|");return new RegExp(r,i)};class a{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=a;class o extends a{static from(...e){const t=l(e);return new o("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",n=t?.includes("g")??!1,o=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof a||t instanceof RegExp?(i+=t.source,n||(n=t.global),o||(o=t.ignoreCase),l||(l=t.multiline)):i+=s((0,r.toS)(t));return new RegExp(i,t??(n?"g":"")+(o?"i":"")+(l?"m":""))}t.RegExpOptional=o,t.concatRegexp=l},79089:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const r=n(i(48161)),s=n(i(76760)),a=i(19851),o=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),v=i(34102),w=i(43334),S=i(24399),b=i(28874),P=(0,a.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>E.prior()?.clear()))));const M=(0,a.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,o.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>M().includes(e.toLowerCase())))};let _=!0;const E=(0,a.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||E().has(e))return;E().add(e);const i=(0,p.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),_)try{return r.default.setPriority(e,t),t}catch(i){const n=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:n,error:i}),n)return;_=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const r=n(i(1708)),s=i(19851),a=i(40958),o=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===o.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===o.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===o.ServiceNames.sync}function p(){return(0,t.serviceName)()===o.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,a.compactBlanks)([t.serviceName.prior(),(0,l.toS)(r.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return o.ServiceNames.indexOf(e)??o.ServiceNames.length+1},t.MainServices=[o.ServiceNames.main,o.ServiceNames.desktop],t.DbServices=[o.ServiceNames.sync,o.ServiceNames.info,o.ServiceNames.web,o.ServiceNames.list,o.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[o.ServiceNames.sync,o.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===o.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===o.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,s.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const n=i(59455);function r(e){return e instanceof Set?e:new Set((0,n.toA)(e))}t.asSet=r,t.setEql=function(e,t){return(0,n.toA)(e.keys()).every((e=>t.has(e)))&&(0,n.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=r(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=r(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const n=i(5670),r=i(57150),s=i(7282),a=i(23560),o=i(17181);t.setServiceName=function(e){(0,a.isMainService)(e)&&(e=n.ServiceNames.main);const t=a.serviceName.prior();t!==e&&((0,s.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),a.serviceName.set(e),(0,o.setupLogger)(),(0,r.logStartup)())}},28850:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const o=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends o.ExtensibleFunction{constructor(e,t){super(),this.impl=t,n.set(this,void 0),r.set(this,void 0),s(this,n,e,"f")}_call(){return(0,l.time)(a(this,n,"f")+(null==a(this,r,"f")?"(local)":"(remote)"),null==a(this,r,"f")?this.impl():a(this,r,"f").call(this))}setShim(e){s(this,r,e,"f")}hasShim(){return null!=a(this,r,"f")}clearShim(){s(this,r,void 0,"f")}}n=new WeakMap,r=new WeakMap},12089:function(e,t,i){var n,r,s,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,a){super(),n.add(this),this.impl=t,this.cache=i,this.toKey=a,r.set(this,void 0),s.set(this,void 0),l(this,r,e,"f")}async _call(e){return null==this.cache?u(this,n,"m",o).call(this,e):this.cache().getOrSetAsync(u(this,n,"m",a).call(this,e),(()=>u(this,n,"m",o).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,n,"m",a).call(this,e))}}r=new WeakMap,s=new WeakMap,n=new WeakSet,a=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},o=function(e){return(0,m.time)(u(this,r,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const n=i(42659);t.ShortCommandTimeoutMs=7*n.secondMs},92322:function(e,t,i){var n,r=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=i(76790),a=i(17586);class o{constructor(e,t){this.valueOf=e,this.diff=t,n.set(this,[])}[(n=new WeakMap,Symbol.iterator)](){return r(this,n,"f")[Symbol.iterator]()}get length(){return r(this,n,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=r(this,n,"f").length-1;for(;t<=i;){const s=t+Math.floor((i-t)/2),a=this.valueOf(r(this,n,"f")[s]);if(e===a)return{found:!0,index:s};e>a?t=s+1:i=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&r(this,n,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...r(this,n,"f")];const a=t=>t<0||t>r(this,n,"f").length-1?null:(i??this.diff)(r(this,n,"f")[t],e),o=this.findIndex(e);if(null==o)return;let l=o.index-1,u=a(l),c=o.index,d=a(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return r(this,n,"f").shift()}at(e){return(0,a.at)(r(this,n,"f"),e)}toA(){return[...r(this,n,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===r(this,n,"f").length-1){const e=[...r(this,n,"f")];return r(this,n,"f").length=0,e}return r(this,n,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return r(this,n,"f").splice(e,t)}retainLastN(e){return e{Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const n=i(1708),r=i(82328),s=i(84542),a=i(95705),o=i(28874);t.consoleLog=function(e,...t){o.Settings.quiet.valueOrDefault||(0,r.stdoutEnded)()||console.log((0,s.crlf)(e),...t)},t.consoleError=function(e){o.Settings.quiet.valueOrDefault||(0,a.streamEnded)(n.stderr)||n.stderr.write(e)},t.quietly=async function(e){const t=o.Settings.quiet.envValue;try{return o.Settings.quiet.envValue=!0,await e()}finally{o.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const n=i(1708),r=i(95705);t.stdoutEnded=function(){return(0,r.streamEnded)(n.stdout)}},71567:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const r=n(i(1708)),s=i(22573),a=i(98553),o=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:r.default.stdout})}function f({obj:e,ready:i,stream:n}){if(null==n||(0,d.streamEnded)(n))return;const r=(0,a.stringify)(e,void 0,(0,o.isInfoService)()||(0,o.isMainService)()?2:void 0);n.write(r+"\n"),(0,o.isWorkerService)()&&null!=i&&(r.includes(u.FailStr)||(0,c.isFatalError)(r)||(0,c.isHealthCheckError)(r)?n.write(u.FailStr+"\n"):n.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||r.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:r.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const n=i(40958),r=i(76790),s=i(22573),a=i(55835),o=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const n=String(e);return n+(0,l.padding)(i,t-n.length)},t.padReplace=function(e,t,i,n){return(0,c.strslice)(e,0,t)+(0,l.padding)(n,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,n=0){if(null==i||0===i.length)return 0;const r=t.indexOf(i,n);return-1===r?0:1+e(t,i,r+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,i){const n=Math.min(Math.ceil(e.length/t),i??e.length)-1;return n<=0?[e]:[...(0,o.times)(n,(i=>e.slice(i*t,(i+1)*t))),e.slice(n*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const n=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,n)+e.substring(n+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:n}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const n=(0,h.toS)(e),r=(0,h.toS)(t);return r.length>0&&(0,c.equalsIgnoreCase)(n.slice(-r.length),r,i)?n.slice(0,-r.length):n},t.gist=function(e,t=80,i=80){const n=(0,h.toS)(e),r=n.length-(t+i);return r<=0?n:n.slice(0,t).trim()+" …(+"+r+" chars)…"+n.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,n.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,a.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=S(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,n.isEmpty)(e)||(0,s.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),n=e.toLowerCase(),r=t.indexOf(n);if(r>=0)return{index:r,match:n}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const M=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function _(e){return M.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=_;const E=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,h.toS)(e).trim(),null!=E.exec(_(e))&&(e=e.slice(1,-1).trim())),e};const x=/^['‘’].*['‘’]$/,T=/^["“”„«»〃].*["“”„«»〃]$/;function D(e,t){const i=k(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function k(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],n=[];let r,s=0;for(;null!=(r=t.exec(e));)r.index===t.lastIndex?t.lastIndex++:(t.lastIndex=r[0].length+r.index,i.push(e.substring(s,r.index)),n.push(e.substring(r.index,t.lastIndex)),s=t.lastIndex);return s(0,o.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),x.test(e)||T.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,n.compactBlanks)(e),r=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,a.map)(i[e],(e=>t+=e))));return t},t.splitKeep=D,t.splitUp=k,t.sortNaturalBy=C,t.sortNatural=function(e){return(0,r.sortBy)(e,(e=>C(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,n.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,r.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const i=Math.min(e.length,t.length);for(let n=0;n4===e?.length?(0,o.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const F=/#.*$/gm;t.stripComments=function(e){return e.replace(F,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const n of(0,d.toA)(e))if(null!=n&&!(0,s.blank)(n))for(const e of n.split(t))(0,s.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,s.blank)(t))return e;const n=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),r=e.findIndex((e=>n.test(e))),a=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(r<0)return e;for(let t=r+1;te.trim()))))}},83556:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const n=i(54993);function r(e){return(0,n.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,n.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,n.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=r,t.asObjectKey=function(e){return r(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const r=n(i(77598)),s=i(73913),a=i(55222);function o(e,t=s.HashBits){return r.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=a.Radix58,n=224){return i.encodeBuffer(o(e,n)).substring(0,t)}t.stringShaToBuffer=o,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=a.GeoRadix,n=224){return l(e,t,i,n)}},94863:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const n=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,n.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const n=i(40958),r=i(76790),s=i(22573),a=i(31586),o=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let n=0,r="";for(let s=0;s=n&&(n=i.get(s,a),r=(0,l.substr)(e,s-n+1,n)));return r}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const n=e.normalize(),r=t.normalize();return e!==n||t!==r?y(n,r):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,n)=>i===t.charAt(n)?e:e+1),0)}function v(e,t){const i=e.toUpperCase().normalize(),n=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===n?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(i),t=w(n);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function S(e,t){const i=(0,f.intersection)(e,t),r=[];return i.forEach((i=>{const s=Math.min((0,n.count)(e,(e=>e===i)),(0,n.count)(t,(e=>e===i)));(0,a.times)(s,(()=>r.push(i)))})),r}function b(e,t,i){const r=(0,n.commonPrefixLength)(e,t);return i((0,l.strslice)(e,r))-i((0,l.strslice)(t,r))}function P(e){const t=(0,n.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,r.sortBy)(t,(e=>-e.length))[0]}function M(e,t){const[i,n]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(i,n,(e=>(0,a.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=M;const _=/[^\da-z]+/gi;function E(e,t){const[i,n]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(_,"").toLowerCase()));return b(i,n,(e=>c.RadixAlphaNum.decode(e)))}function x(e,t){let i;for(let n=Math.max(e.length,t.length);n>=0;n--){const r=(0,a.mapNumericOr)(e.charCodeAt(n),(e=>e),256),s=(0,a.mapNumericOr)(t.charCodeAt(n),(e=>e),256),o=(0,a.clamp)(-256,256,r-s);i=null==i?o:(i+o)/2}return i}t.radixDiff=E,t.str=function(e,t){return{pref:(0,n.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:M(e,t),radixDiff:E(e,t)}},t.lcdiff=function(e){return(0,n.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=x,t.paddedPositionalDiff=function(e,t,i=8){return x((0,o.leftPad)(e,i," "),(0,o.leftPad)(t,i," "))}},84885:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const n=i(98553),r=i(88158);t.stringifySorted=function(e){return(0,n.stringify)((0,r.sortedKeys)(e))}},75387:function(e,t,i){var n,r,s,a,o,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){n.add(this),this[c]="TTLMap",r.set(this,[]),s.set(this,new Map),a.set(this,void 0),o.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,a,"f")}set ttlMs(e){h(this,a,e,"f"),null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),h(this,o,(0,p.setUnrefInterval)((()=>d(this,n,"m",u).call(this)),e),"f"),d(this,n,"m",u).call(this)}destroy(){null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),this.ttlMs=-m.dayMs,d(this,n,"m",u).call(this)}clear(){return d(this,s,"f").clear(),this}delete(e){return d(this,s,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,s,"f").entries())d(this,n,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,s,"f").get(e);return d(this,n,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,s,"f").get(e);if(d(this,n,"m",l).call(this,e,i))return i.v;const r=t();return null!=r&&this.set(e,r),r}lastSetOrGetTs(e){return d(this,s,"f").get(e)?.ts}set(e,t){return d(this,s,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,n,"m",l).call(this,e,d(this,s,"f").get(e))}get size(){return d(this,n,"m",u).call(this),d(this,s,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,n,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,n,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,n,"m",u).call(this),(0,f.sortBy)(d(this,s,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,n,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(r=new WeakMap,s=new WeakMap,a=new WeakMap,o=new WeakMap,n=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,r,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,s,"f").delete(e);for(const i of d(this,r,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,s,"f").entries())d(this,n,"m",l).call(this,e,t)}},22277:function(e,t,i){var n,r,s,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){n.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[a]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return o(this,n,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>o(this,n,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||o(this,n,"m",r).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)o(this,n,"m",r).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!o(this,n,"m",r).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,n,"m",r).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,n,"m",r).call(e,t,i)||(yield[t,t])}()}toA(){return o(this,n,"m",s).call(this),[...this.delegate.keys()]}[(n=new WeakSet,a=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,r=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},s=function(){for(const[e,t]of this.delegate)o(this,n,"m",r).call(this,e,t)}},84699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},94174:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const r=n(i(48161)),s=n(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,a.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,a.lazy)((()=>(0,o.uniq)([s.default.geteuid?.(),s.default.getuid?.(),r.default.userInfo().uid]))),t.userid=(0,a.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,a.lazy)((()=>(0,o.uniq)([s.default.getegid?.(),s.default.getgid?.(),r.default.userInfo().gid]))),t.groupid=(0,a.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,a.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,a.lazy)((()=>(0,l.toNotBlank)(r.default.userInfo()?.username))),t.userNameFromWhoami=(0,a.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,a.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,a.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,a.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.0-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=0,t.versionPrerelease=["prealpha"],t.release="2024.3.0-prealpha+20240308102353",t.gitSha="92cba1b21937cb9ca770f6a339e44b0fbee04bf9",t.gitDate=new Date(1709922233e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const n=i(42659),r=i(55835),s=i(31586),a=i(97790),o=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,r.allDefined)(i))return;const[a,o,u,c,d,h,f]=i,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(a,o-1,u,c,d,h,f/1e3)-m*n.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,a.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,o.within)(0,Date.now()+n.dayMs,e))).map((e=>new Date(e))).get()}},13991:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkSortableAssetFile_=t.mkAssetFile_=t.assetFileMetadata_=t.assetFileImageHashFields_=t.imageHashToAssetFileImageHashFields=t.assetFileStatFields_=t.assetFileUriFields_=void 0;const n=i(19851),r=i(55835),s=i(31586),a=i(59455),o=i(73168),l=i(50213),u=i(12089),c=i(76490),d=i(95696),h=i(48368),f=i(70417),m=i(28874),p=i(43207),g=i(47783),y=(0,n.lazy)((()=>(0,l.mkLogger)("asset-file.AssetFileFactory")));async function v(e){try{return{nativePath:e.nativePath,uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath}}catch(t){return y().throw("Failed to build URI for "+e,{error:t})}}async function w(e){const t=await e.stat_(),i=await e.sidecareStats();return{mtime:Math.floor((0,f.max)([t.mtimeMs,...(0,a.toA)(i).map((e=>e.mtimeMs))])),fileSize:t.size}}function S(e){return{...e,...c.DominantColor.toModeData(e.dominantColors)}}async function b(e){if(!m.Settings.useImageHashes.valueOrDefault)return;const t=await(0,h.imageHash_)(e.nativePath);return null==t?y().throw("Failed to extract image hash for "+e):S(t)}async function P(e){const[i,n,r,s]=await Promise.all([v(e),w(e),(0,t.assetFileMetadata_)(e),e.sha_()]);return{...i,...n,...r,sha:s}}t.assetFileUriFields_=v,t.assetFileStatFields_=w,t.imageHashToAssetFileImageHashFields=S,t.assetFileImageHashFields_=b,t.assetFileMetadata_=(0,u.shim1)({name:"asset-file.assetFileMetadata",impl:async function(e){try{const t=d.PosixFile.for(e),i=await(0,g.readTags)(t);if(null==i)throw new Error("Failed to read tags");if(null==i.capturedAt)throw new Error("Failed to read capturedAt");const n=i.capturedAt.toAssetFileFields();return null==n?y().throw("Failed to render assetFileFields from capturedAt",{capturedAt:i.capturedAt}):{...n,...i.exposureSettings,...i.dimensions,mimetype:i.mimetype,rotation:i.rotation,make:i.Make,model:i.Model,rating:i.rating,cameraId:i.cameraId,imageId:i.imageId,lensId:i.lensId,geohash:(0,o.geohashNumericShort)(i.GPSLatitude,i.GPSLongitude),durationMs:(0,p.extractDurationMs)(i),fps:(0,r.map)((0,s.toFloat)(i.VideoFrameRate),Math.floor)}}catch(t){return y().throw("_assetFileMetadata_() failed",{nativePath:e,error:t})}}}),t.mkAssetFile_=async function(e){const[t,i]=await Promise.all([P(e),b(e)]);return{...t,...i}},t.mkSortableAssetFile_=P},92434:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bestExistingAssetFile=t.assetFileSortCriteria=t.assetFileSortFields=t.assetFileSortCriteriaPojo=t.sortAssetFiles=t.mtime2sort=t.sortScale=t.dim2sort=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(22573),o=i(42659),l=i(23838),u=i(31586),c=i(68708),d=i(34666),h=i(50989),f=i(89937),m=i(50213),p=i(4001),g=i(29882),y=i(28874),v=i(14036),w=i(45200),S=i(34238),b=(0,n.lazy)((()=>(0,m.mkLogger)("img.AssetFileSorter"))),P=(0,h.strEnum)("file",f.PS_NETWORK_FILESYSTEM_SCHEME,f.PS_LOCAL_FILE_SCHEME,f.PS_LIBRARY_SCHEME);function M(e){return(0,u.map2Numeric)(e?.width,e?.height,((e,t)=>_(e*t)))}function _(e){if((0,u.gt0)(e))return Math.round(Math.pow(e,y.Settings.variantSortCriteriaPower.valueOrDefault))}function E(e){return Math.round(e/(5*o.minuteMs))}t.dim2sort=M,t.sortScale=_,t.mtime2sort=E;const x=["make","model","rating","cameraId","imageId","lensId","geohash"];function T(e){for(const t of(0,l.groupBy)(e,(e=>e.sha)).values())if(t.length>1){const e=Math.max(...(0,r.compact)(t.map((e=>e.mtime))));for(const i of t)i.mtime=e}return(0,s.sortBy)(e,C).reverse()}function D(e){const t=S.URI.parse(e.uri);if((0,a.blank)(t?.scheme)||(0,a.blank)(t?.path))return void b().warn("assetFileSortCriteriaPojo(): skipping (invalid URI)",{uri_scheme:t?.scheme,uri_path:t?.path,af:e,parsedURI:t});const i=M(e);if(null==i)return void b().warn("assetFileSortCriteriaPojo(): skipping (invalid resolution)",{resolution:i,af:e,parsedURI:t});const n=P.indexOf(t.scheme);if(null==n)return void b().warn("assetFileSortCriteriaPojo(): skipping (invalid URI scheme)",{uri_scheme:t.scheme,af:e,parsedURI:t});const r=e.mtime??0,s=(0,g.parsePosixPath)(t.path),l=[];for(const t of x)(0,a.blank)(e[t])||l.push(t);const u={resolution:i,schemeIdx:n,capturedAtPrecision:-(e.capturedAtPrecisionMs??o.weekMs),metadataCoverage:l.length,metadataFields:l.join(","),isBrowserSupported:(0,v.isSupportedByCurrentBrowserExt)(s.ext),mtime:E(r),isEditOrUpdate:/edit|update/i.test(s.base),isCover:/cover/i.test(s.base),count:Math.abs((0,p.copySuffixCountFromName)(s.name)??0),basename:d.CmpReverseFlag+s.base,parentBasename:d.CmpReverseFlag+(0,g.parentBasename)(e.nativePath??t.path),uri:d.CmpReverseFlag+e.uri};return b().tap({msg:"assetFileSortCriteriaPojo()",result:(0,c.toReqValued)(u)})}function k(){return(0,r.uniq)([...y.Settings.variantSortCriteria.values,"uri"])}function C(e){const t=D(e);if(null==t)return;const i=[];for(const e of k())i.push(t[e]);return i}t.sortAssetFiles=T,t.assetFileSortCriteriaPojo=D,t.assetFileSortFields=k,t.assetFileSortCriteria=C,t.bestExistingAssetFile=async function(e){for(const t of T(e))if(await(0,w.uriExists)(t.uri,t.nativePath))return b().tap({msg:"bestExistingAssetFile()",result:t,meta:{files:e.map((e=>e.uri))}});return b().tap({msg:"bestExistingAssetFile(): no existing uris",result:void 0,meta:{files:e.map((e=>e.uri))}})}},54296:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetFileNativePath=void 0;const n=i(45200);t.getAssetFileNativePath=async function(e){return e.nativePath??(e.nativePath=await(0,n.uri2nativePath)(e.uri,e.mountpoint))}},73568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const o=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,n.set(this,void 0),r.set(this,(0,o.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,r,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,r,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,r,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),a(this,n,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,n,"f")&&clearTimeout(s(this,n,"f")),a(this,n,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},n=new WeakMap,r=new WeakMap},69591:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const r=n(i(87997)),s=i(31586);t.debounce=function(e,t){let i,n=[];const a=(0,s.gt0)(t)?(...s)=>{n=s,null!=i&&r.default.clearTimeout(i),i=r.default.setTimeout((()=>{e(...n)}),t)}:e;return a.reset=()=>{null!=i&&r.default.clearTimeout(i),i=void 0},a.force=()=>{a.reset(),e()},a.setTimeoutMs=e=>{a.reset(),t=e},a.timeoutMs=()=>t,a}},22911:function(e,t,i){var n,r,s,a,o,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(i(87997)),w=y(i(57975)),S=i(45599),b=i(26905),P=i(55835),M=i(31586),_=i(68708),E=i(20214),x=i(57153),T=i(85556),D=i(50213),k=i(70025),C=i(95937),F="TIMEOUT",O=(0,S.defer)((()=>(0,D.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),n=(0,M.gt0)(t)?new r(F).setTimeout(t):void 0;for(null!=n&&i.push(n);;){for(let n=i.length-1;n>=0;n--){const r=i[n];if(r.isSettled){if(r.name===F)return void O().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(n,1),yield r.value}}if(i.every((e=>e.name===F)))break;try{await Promise.race(i)}catch{}}n?.clearTimeout()}static resolve(e,t){return new r(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;n.add(this),this.name=e,this.startedAt=Date.now(),a.set(this,void 0),o.set(this,x.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=r,r,(y=p(i,r,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,D.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof r&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,o,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,_.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,a,"f")}get elapsedMs(){return(p(this,a,"f")??Date.now())-this.startedAt}get[(a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,n=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,E.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,E.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,M.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new T.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,C.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,o,"f")===x.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,o,"f")!==x.PromiseStates.pending}get isResolved(){return p(this,o,"f")===x.PromiseStates.resolved}get isRejected(){return p(this,o,"f")===x.PromiseStates.rejected}get settledMs(){return null==p(this,a,"f")?void 0:p(this,a,"f")-this.startedAt}resolve(e){return p(this,n,"m",m).call(this,(()=>{g(this,o,x.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,k.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return p(this,n,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,o,x.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,r=I,m=function(e){if(p(this,o,"f")===x.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,a,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},s={value:0}},27395:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const n=i(19851),r=i(40958),s=i(42659),a=i(23838),o=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,n.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new a.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const i=await e;if(null==i||!0===i?.ended)return;const n=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:n});try{await(0,o.thenOrTimeoutError)(i.end(),n,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,n.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,r.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,r.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){var n,r,s,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,n,"m",a).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),n.add(this),this.opts=e,r.set(this,void 0),s.set(this,void 0),o.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,r,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,n,"m",a).call(this);const h=()=>{u(this,n,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,r,(0,d.setInterval)(u(this,o,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,r,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,n,"a",l)&&(u(this,o,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):h(),!0}}t.EndableInterval=v,r=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakSet,a=function(){(0,h.map)(u(this,r,"f"),d.clearInterval),c(this,r,void 0,"f"),(0,h.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const n=i(50989);t.EndableRanks=(0,n.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const o=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,a){this.endTimeoutMs=a,n.set(this,void 0),this.onEnds=[],r.set(this,(0,o.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,r,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){a(this,n,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,n,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,r,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},n=new WeakMap,r=new WeakMap},99331:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const n=i(7282);let r=!1;t.ending=function(){return r},t.setEnding=function(e){r=(0,n.isTest)()?e:e||r}},45608:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const r=n(i(1708)),s=i(22573),a=i(45599),o=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,a.defer)((()=>(0,l.mkLogger)((0,o.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,a.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const n=(0,s.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(n)}(0,m.ending)()||(await(0,f.endEndables)(),r.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,a.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])r.default[e].on(t,(i=>{v({reason:`${e}:${t}`,status:0,error:i})}))}))},60172:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,n)=>{t=e,i=n})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){var n,r,s,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:n}){return new y(e,t,i,n)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),n.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,r.set(this,void 0),s.set(this,0),a.set(this,void 0),o.set(this,[])}_call(){return this.isStale()?c(this,n,"m",u).call(this,this.later()):c(this,a,"f")}unset(){d(this,s,0,"f"),d(this,r,void 0,"f"),d(this,a,void 0,"f")}set(e){return c(this,n,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,n,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,o,"f").push(e)}prior(){return this.isStale()?void 0:c(this,a,"f")}lastValue(){return c(this,a,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,r,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,r,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,r,"f")?void 0:Date.now()-c(this,r,"f")}elapsedMs(){return c(this,a,"f")?.settledMs??c(this,a,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}r=new WeakMap,s=new WeakMap,a=new WeakMap,o=new WeakMap,n=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,o,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,o,"f"))e.onError(t)}finally{d(this,s,(i=c(this,s,"f"),++i),"f")}},u=function(e){d(this,r,Date.now(),"f");const t=c(this,a,"f");return d(this,a,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,a,"f").setTimeout(this.timeoutMs),c(this,n,"m",l).call(this,t,c(this,a,"f")),c(this,a,"f")}},1728:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const n=i(98553),r=i(80049);t.memoizeAsync=function(e,t){let i=0;const s=new r.FifoCacheAsync(t),a=t=>(i++,s.getOrSetAsync((0,n.stringify)(t),(async()=>e(t))));return a.clear=e=>{if(null==e)return s.clear();{const t=(0,n.stringify)(e);return s.deleteIf((e=>t===e))}},a.size=()=>s.size,a.callCount=()=>i,a}},22781:function(e,t,i){var n,r,s,a=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,n.set(this,void 0),r.set(this,!1),s.set(this,!1)}_call(){return a(this,r,"f")?(o(this,s,!0,"f"),!0===this.undefinedIfBusy?void 0:a(this,n,"f")):(o(this,r,!0,"f"),o(this,n,(0,u.postrun)({fn:this.fn,postrun:()=>{o(this,r,!1,"f"),!0===this.runLaterIfBusy&&a(this,s,"f")&&(o(this,s,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return a(this,r,"f")}prior(){return a(this,n,"f")}async force(){return await a(this,n,"f"),this._call()}}n=new WeakMap,r=new WeakMap,s=new WeakMap},37461:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const n=i(40958),r=i(76790),s=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),v=i(15674),w=i(42638);var S=i(20214);async function b(e){if(null==e)return[];const t=(0,n.compact)(await e);return(0,n.isEmpty)(t)?[]:(0,n.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function M({name:e,arr:t,f:i,timeoutMs:r}){const s=[];for(const a of(0,n.compact)(await t))try{const e=await((0,l.gt0)(r)?(0,c.thenOrTimeoutError)(i(a),r):i(a));null!=e&&s.push([e,a])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:a,error:t})}return s}async function _({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:a}){if(null==e)return[];const o=(0,n.compact)(await e);if((0,n.isEmpty)(o))return[];if((r=Math.round(r??(0,v.maxCpus)()))<=1)return M({arr:e,f:t,name:i,timeoutMs:s});const u=a??(o.length<=r?w.PermissivePromises:new w.Promises(i,(()=>r))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,h=await u.enqueueAll(i,o.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,n.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,i){const n=[];for(const r of(0,p.batches)((0,f.toA)(await e),t)){const e=await b(r);n.push(...await b(i(e)))}return n},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,o.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,n.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,n.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=M,t.mapAsyncSerial=async function(e){return(await M(e)).map((e=>e[0]))},t.thenCollectParallel=_,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:n,timeoutMs:r,promises:s}){return(await _({arr:e,f:t,name:i,maxConcurrent:n,timeoutMs:r,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:r,timeoutMs:s}){return(await _({name:e,arr:(0,n.compact)(t),f:i,maxConcurrent:r,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await _({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*a.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),n=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,n)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let n,r=null;try{n=await((0,h.isFunction)(e)?e():e)}catch(e){r=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(r??n)}catch{}if(null!=r)throw r;return n},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,s.isTrue)(i)},t.thenMap2=async function(e,t,i){const n=await e;if(null==n)return;const r=await t;return null!=r?i(n,r):void 0},t.thenMapOr=async function(e,t,i){const n=await e;if(null==n)return i();const r=await t(n);return null==r?i():r},t.thenMap2Or=async function(e,t,i,n){const r=await e;if(null==r)return n();const s=await t;if(null==s)return n();const a=await i(r,s);return null==a?n():a},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const n of e){i++;try{if(null==n)continue;const e=await t(n,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const n=await _({name:e,arr:t,f:i});return(0,r.sortBy)(n,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(42659),o=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),v=i(25764),w=i(38836),S=i(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const n=Date.now(),r=(0,l.clamp)(10*a.secondMs,a.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-n)+"ms")}),r);try{const r=await(0,c.tot)(t),s=Date.now()-n;return i?.(r,s),this.push(e,s),r}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-n),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),n=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...n])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,o.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/a.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function M(e,t,i){return P.instance().time(e,t,i)}function _(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,n.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,r.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=M,t.timeSync=function(e,t){const i=Date.now(),n=t();return _(e,Date.now()-i),n},t.pushTime=_,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,n.lazy)((async()=>M(e,t)),i)}},42638:function(e,t,i){var n,r,s,a,o,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),v=i(54993),w=i(89788),S=i(82647),b=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class M{constructor(e,t){n.add(this),this.name=e,this.ee=new f.default.EventEmitter,r.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),a.set(this,[]),o.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,r,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,b.maxCpus)(),d(this,r,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,o,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,a,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,a,"f").map((e=>e.name)),pendingNames:d(this,o,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:i,serialId:r}){const s=d(this,n,"m",l).call(this,{name:e,l:t,payload:i,serialId:r});return this.laterPop(),s}enqueueAll(e,t){const i=t.map((t=>d(this,n,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,n,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,a,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,o,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,o,"f").length,e),i=this.runningSerialIds,r=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,a,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,o,"f").length}hasPending(){return d(this,o,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,o,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,o,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=M,r=new WeakMap,s=new WeakMap,a=new WeakMap,o=new WeakMap,n=new WeakSet,l=function({name:e,l:t,payload:i,serialId:n}){const r=new P.Deferred(e,{payload:i,serialId:n});return d(this,o,"f").push({d:r,l:t}),r},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,a,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,a,"f").push(e),e},t.maybeRun=function(e,t){const i=new M(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new M(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},4867:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const n=i(40958),r=i(34546),s=i(41400),a=i(31586),o=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let o=!0;return Promise.race((0,n.compact)([(0,r.asPromise)(e).finally((()=>o=!1)),(0,a.gt0)(t)?(0,s.delay)(t).then((()=>{if(o)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(o)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,n.compact)([(0,r.asPromise)(e).finally((()=>l=!1)),(0,a.gt0)(t)?(0,s.delay)(t).then((()=>o.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const n=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,n.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,n.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const n=i(38639),r=i(42659),s=i(41400),a=i(32639),o=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:n,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const n=i??(0,o.clamp)(10*m,l.ShortCommandTimeoutMs,(t??r.minuteMs)/5);await(0,s.delay)(n,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:n.isTrue,timeoutResult:!1})}},9727:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const r=n(i(1708)),s=i(45599),a=i(41400),o=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),v=i(50213),w=i(7282),S=i(88158),b=i(45969),P=i(43334),M=i(28874),_=i(3790);function E(e){return x().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const x=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(M.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>E(e))))},(0,a.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,M.allSettings)())t.watchLater(e)}));const T=["HOME","LANG","USER"],D=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],k=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?T:D),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,M.pathWithDefaults)(),e}));function C(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,M.persistedSettings)()){const n=e?i.value:i.envValue;null==n||(0,o.eql)(n,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(r.default.env,(e=>E(e)||!(0,_.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=C,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:O({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let F=!1;function O({overrides:e,forceCLocale:i=!0,forWorker:n=!1}={}){const r=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...k(),...i?(0,g.childProcLocale)():{},...C(n),...e??{}});for(const e of(0,M.transientSettings)())e.deleteFromEnv(r);if((0,y.isLogged)("debug")&&!F){F=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(r).map((([e,t])=>[e,(0,_.isHiddenEnvKey)(e)?"(hidden)":t])),[i,n]=(0,u.partition)(t,(([e])=>E(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(n))}return r}t.childEnv=O},84777:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const r=n(i(31421)),s=n(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),v=i(79089),w=i(45255),S=i(22911),b=i(4867),P=i(73614),M=i(70025),_=i(57159),E=i(36868),x=i(66184),T=i(45643),D=i(95402),k=i(9727),C=(0,a.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function F(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function O(e,t=30*u.secondMs){if(null==e)return!1;C().debug("endProcess()",F(e));const i=e.pid;if(null==i||i<=0)return C().warn("endProcess(): asked to end invalid pid",F(e)),!1;if(i===s.default.pid)return C().warn("endProcess(): asked to end MY pid",F(e)),!1;if(i===s.default.ppid)return C().warn("endProcess(): asked to end my parent pid",F(e)),!1;(0,E.closeStreams)(e);{const t=e.kill();C().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,D.killPid)(i).catch((e=>{C().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,T.waitForPidExit)(i,t))return C().debug("endProcess(): exitted",F(e)),!0;{D.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");C().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,D.killPid)(i,!0).catch((e=>{C().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,T.waitForPidExit)(i,5e3)}function I(e,i,n,r=0){const a=new Date,o=[];return(0,v.niceable)(i,n)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(r,u.secondMs)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&O(e)}),r-250)),o.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,D.addPid)({pid:e.pid,cmd:i,timeoutMs:r,ppid:s.default.pid},a)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>o.forEach(clearTimeout))),e}function L(e,t,i,n){const s=(0,k.spawnOptions)(n);return(0,x.isLogged)("trace",C().context)?C().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:s}):C().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(r.default.execFile(e,t,s),e,t,i)}async function A(e,t,i){const n=i.quiet??!1,r=i.ignoreStderr??!1,s=i.ignoreExitCode??!1,a=L(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{a.disconnect?.()}catch{}return{result:"",pid:a.pid}}const u=a.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new S.Deferred(f);a.on("error",(e=>g.push(e))),a.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),a.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,E.endStream)(a.stdin);const v=new d.Latch;null==a.stdout?v.resolve():(a.stdout.on("error",(e=>g.push(e))),a.stdout.on("data",(e=>m.push(e))),a.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==a.stderr||r?P.resolve():(a.stderr?.on("error",(e=>g.push(e))),a.stderr?.on("data",(e=>p.push(e))),a.stderr?.on("end",(()=>P.resolve()))),C().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),C().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt});const x=p.join("");(0,l.notBlank)(x)&&g.push(new Error(x)),!n&&(0,o.isNotEmpty)(g)&&C().warn(f+" resulted in errors:",g);const T=i.isIgnorableError??M.isIgnorableError,D=g.filter((e=>!0!==T(e)));if(D.length>0)throw 1===D.length?D[0]:new _.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:D});if(!s&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:x}}catch(e){throw C().error("stdoutResult_() failed",e),await(0,D.killPid)(a.pid,!0),e}}t.endProcess=O,t.ReniceAfterMs=(0,a.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,a.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,n){const s=(0,k.spawnOptions)(n);return C().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(r.default.spawn(e,t,s),e,t,i)},t.execFile=L,t.stdoutResult_=A,t.stdout_=async function(e,t,i){const n=await A(e,t,i);return C().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(n.result),meta:{cmd:e,args:t,opts:i,result:n}})}},3790:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const n=i(22573),r=i(41400),s=i(19851),a=i(28874);(0,r.later)((()=>a.Settings.sensitiveEnvRegExp.watchLater((()=>o.unset()))));const o=(0,s.lazy)((()=>{try{return new RegExp(a.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${a.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(a.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,n.blank)(e)&&o().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||a.Settings.license.includesEnvKey(e)}},55534:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceExitCommand=void 0,t.ServiceExitCommand="--exit"},34330:function(e,t,i){var n,r,s,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(54993),w=i(27395),S=i(25764),b=i(99331),P=i(42638),M=i(38835),_=i(8769),E=i(57159),x=i(66003),T=i(50213),D=i(45643),k=i(28874),C=i(84777);t.mkBasicWatchedChild=function(e){return new F({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,C.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class F{constructor(e){n.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,T.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),r.set(this,!1),this.onError=(e,t,i)=>{const s=new E.WrappedError(e,{cause:t}),a=!1!==s.ignorable;this.logger().log(a?"warn":"error","onError()",s),u(this,r,"f")||a||(this.lastError=s,(0,_.onError)(s),!0!==s.fatal?(i??this.opts.onError(e,s))&&(this.logger().warn("onError requested restart",{src:e,error:s}),u(this,n,"m",o).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:k.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:S.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,w.addEndable)(this.opts.endableRank,this),u(this,n,"m",o).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,r,"f")}async end(){return c(this,r,!0,"f"),u(this,n,"m",s).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,n,"m",s).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,r,"f")}),!u(this,r,"f")&&!(0,b.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,n,"m",s).call(this),this._stopped=!1,u(this,n,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,r,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,n,"m",l).call(this))))}}t.WatchedChild=F,r=new WeakMap,n=new WeakSet,s=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,r,"f")});const e=this.cp;return this.cp=void 0,u(this,n,"m",a).call(this,e)},a=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,D.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,C.endProcess)(e,this.endTimeoutMs)},o=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,r,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,n,"m",s).call(this),!this._stopped&&!u(this,r,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,_.onError)("Can't restart "+this.name+", failure rate is too high."+M.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,n,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,r,"f")}),this._stopped||u(this,r,"f")||(0,b.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,x.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,v.toS)(e).includes("Error: Cannot find module")&&(0,_.onError)("Failed to start "+this.name+M.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,r,"f")}),(0,b.ending)()||(this.opts.restartOnExit?(await u(this,n,"m",o).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const a=s(i(53916)),o=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,o.toNativePath_)(e);const i=f.PosixFile.for(e),n=t?.stableBasename??1?m(i):i.base.normalize(),r=i.sibling(n);if(r.isSelfOrDescendantOf((0,l.examples)()))return a.join("$examples",r.posixPathFrom((0,l.examples)()));const s=(0,d.originalsDir)();if(r.isSelfOrDescendantOf(s))return a.join("$library",r.posixPathFrom(s));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?a.join("$library",r.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},80061:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const n=i(1708),r=i(31586),s=i(51926),a=i(17344),o=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,r.toInt)(n.env.maxLineLen)??n.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,a.EditionName)()+" v"+o.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},54772:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bestLabhashName=t.bestLabName=t.bestRgbName=t.colorToTuple=t.bestRgbTripletName=t.ColorNames=void 0;const n=i(19851),r=i(40958),s=i(49769),a=i(31586),o=i(48884),l=i(50213),u=i(81168),c=i(85810),d=i(42079),h=i(91482),f=i(3048),m=i(85409),p=i(16050),g=i(42022),y=i(85042),v=(0,n.lazy)((()=>(0,l.mkLogger)("color.ColorNames")));function w(e){const t=(0,y.normalizeRgbHex)(e.rgb);if(null==t)return void v().warn(`skipping invalid entry (bad rgb): ${e.rgb}`,e);const i=(0,c.rgbhex2Lab)(t);if(null==i)return void v().warn(`skipping invalid entry (failed to convert to L*a*b): ${t}`,e);const n=(0,c.toLabhash)(i,g.ModeBits);return{...e,rgb:t,lab:i,labhash:n,closeLabhashes:[n],closeRgb:[t],name:(0,u.capitalize)(e.name)}}function S(e,i){return null==e?void 0:(0,o.leastBy)(i??(0,t.ColorNames)(),(t=>(0,f.ciede2000_delta_e)(t.lab,e)))}t.ColorNames=(0,n.lazy)((()=>(0,r.compact)([...d.CrayonColors,...d.CrayonSupplements,...h.DarkWikipediaColors,...p.LightWikipediaColors,...m.Greys].map(w)))),t.bestRgbTripletName=function(e,i=(0,t.ColorNames)()){return S((0,c.rgb2lab)(e),i)},t.colorToTuple=w,t.bestRgbName=function(e){return P((0,c.rgbhex2Labhash)(e))},t.bestLabName=S;const b=new Map;function P(e){return(0,a.gte0)(e)?(0,s.getOrSet)(b,e,(()=>{const i=(0,t.ColorNames)().find((t=>t.labhash===e));if(null!=i)return i;const n=(0,c.unlabhash)(e),s=S(n);return null!=n&&null!=s&&((0,r.pushUniq)(s.closeLabhashes,e),(0,r.pushUniq)(s.closeRgb,(0,c.lab2rgbhex)(n))),s})):void 0}t.bestLabhashName=P},85810:(e,t,i)=>{e=i.nmd(e),Object.defineProperty(t,"__esModule",{value:!0}),t.hsv2rgb=t.hsl2hsv=t.hsv2hsl=t.hsl2rgb=t.rgb2hsl=t.rgbhex2hsl=t.rgb2hsv=t.closestLab=t.maxLabhash=t.minLabhash=t.unlabhash=t.toLabhash=t.LabBitZip=t.xyz2rgb=t.lab2xyz=t.xyz2lab=t.rgb2xyz=t.clampLab=t.lab2rgb=t.rgb2lab=t.rgb2labArray=t.rgb2labTriplets=t.lab2rgbhex=t.rgbhex2Labhash=t.rgbhex2Lab=void 0;const n=i(19851),r=i(40958),s=i(49769),a=i(55835),o=i(31586),l=i(48884),u=i(20014),c=i(75503),d=i(3048),h=i(42022),f=i(85042),m=[[.4124564,.3575761,.1804375],[.2126729,.7151522,.072175],[.0193339,.119192,.9503041]],p=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]];function g(e){return M(w(e))}function y(e){return(0,f.clampRGB)(E(_(e)))}function v(e){return(0,t.LabBitZip)().clampValue(e)}function w(e){const t=(0,f.clampRGB)(e).map((e=>e/255)).map((e=>e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92));return(0,c.matXvec)(m,t)}t.rgbhex2Lab=function(e){return(0,a.map)((0,f.rgbhex2triplet)(e),g)},t.rgbhex2Labhash=function(e,t=h.ModeBits){return(0,a.map)((0,f.rgbhex2triplet)(e),(e=>x(g(e),t)))},t.lab2rgbhex=function(e){return(0,f.rgbTriplet2hex)(y(e))},t.rgb2labTriplets=function(e){return(0,r.stepRange)(0,e.length,3).map((t=>g([e[t],e[t+1],e[t+2]])))},t.rgb2labArray=function(e){const t=[],i=[],n=[];for(let r=0;re>b?Math.pow(e,1/3):(P*e+16)/116));return v([116*i-16,500*(t-i),200*(i-n)])}function _(e){const[t,i,n]=v(e),r=(t+16)/116,s=i/500+r,a=r-n/200,o=s*s*s,l=a*a*a,u=o>b?o:(116*s-16)/P,c=t>8?Math.pow(r,3):t/P,d=l>b?l:(116*a-16)/P;return[u*S.X,c*S.Y,d*S.Z]}function E(e){return(0,c.matXvec)(p,e).map((e=>{const t=e<0?-1:1,i=e*t;return(0,o.round)(255*t*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055))}))}function x(e,i=h.ModeBits){return(0,t.LabBitZip)().zip(e,i)}t.xyz2lab=M,t.lab2xyz=_,t.xyz2rgb=E,t.LabBitZip=(0,n.lazy)((()=>new u.BitZip([{min:0,max:100},{min:-79,max:90},{min:-102,max:89}]))),t.toLabhash=x;const T=new Map;function D(e,i=h.ModeBits){return(0,t.LabBitZip)().unzip(e,i)}function k(e){const[t,i,n]=(0,f.clampRGB)(e),r=Math.max(t,i,n),s=r-Math.min(t,i,n),a=s?r===t?(i-n)/s:r===i?2+(n-t)/s:4+(t-i)/s:0;return[60*(a<0?a+6:a),r?s/r*100:0,r/255*100]}function C(e){return F(k(e))}function F(e){const[t,i,n]=e,r=(200-i)*n/100;return[t,r>0&&r<200?i*n/100/(r<=100?r:200-r)*100:0,r/2]}function O(e){const[t,i,n]=e,r=i*(n<50?n:100-n)/100;return[t,r>0?2*r/(n+r)*100:0,n+r]}function I(e){const t=e[0]/360*6,i=e[1]/100,n=e[2]/100,r=Math.floor(t),s=n*(1-i),a=n*(1-(t-r)*i),o=n*(1-(1-t+r)*i),l=r%6;return(0,f.clampRGB)([255*[n,a,s,s,o,n][l],255*[o,n,n,a,s,s][l],255*[s,s,o,n,n,a][l]])}t.unlabhash=function(e,t=h.ModeBits){return t===h.ModeBits?(0,s.getOrSet)(T,e,(()=>D(e,t))):D(e,t)},t.minLabhash=(0,n.lazy)((()=>(0,t.LabBitZip)().zipMin(h.ModeBits))),t.maxLabhash=(0,n.lazy)((()=>(0,t.LabBitZip)().zipMax(h.ModeBits))),t.closestLab=function(e,t){return(0,l.leastBy)(e,(e=>(0,d.ciede2000_delta_e)(e,t)))},t.rgb2hsv=k,t.rgbhex2hsl=function(e){return C((0,f.rgbhex2triplet)(e))},t.rgb2hsl=C,t.hsl2rgb=function(e){return I(O(e))},t.hsv2hsl=F,t.hsl2hsv=O,t.hsv2rgb=I,i.c[i.s]===e&&console.log(x([0,0,0]))},42079:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CrayonSupplements=t.CrayonColors=void 0,t.CrayonColors=[{name:"Aquamarine",rgb:"#95E0E8"},{name:"Asparagus",rgb:"#7BA05B"},{name:"Blue-green",rgb:"#0095B7"},{name:"Royal blue",rgb:"#273BE2"},{name:"Blush",rgb:"#DB5079"},{name:"Brilliant rose",rgb:"#E667CE"},{name:"Brown",rgb:"#AF593E"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Burnt umber",rgb:"#805533"},{name:"Cadet blue",rgb:"#A9B2C3"},{name:"Canary",rgb:"#FFFF99"},{name:"Carmine",rgb:"#E62E6B"},{name:"Carnation pink",rgb:"#FFA6C9"},{name:"Celestial blue",rgb:"#7070CC"},{name:"Cerise",rgb:"#DA3287"},{name:"Cerulean blue",rgb:"#339ACC"},{name:"Chestnut",rgb:"#B94E48"},{name:"Cobalt blue",rgb:"#8C90C8"},{name:"Copper",rgb:"#DA8A67"},{name:"Cornflower",rgb:"#93CCEA"},{name:"Cotton candy",rgb:"#FFB7D5"},{name:"Denim",rgb:"#1560BD"},{name:"Eggplant",rgb:"#614051"},{name:"Fern",rgb:"#63B76C"},{name:"Fuchsia",rgb:"#C154C1"},{name:"Russet",rgb:"#87421F"},{name:"Green",rgb:"#01A638"},{name:"Green-yellow",rgb:"#F1E788"},{name:"Indigo",rgb:"#4F69C6"},{name:"Jungle green",rgb:"#29AB87"},{name:"Magenta",rgb:"#F653A6"},{name:"Maize",rgb:"#F2C649"},{name:"Maroon",rgb:"#C32148"},{name:"Medium chrome green",rgb:"#6CA67C"},{name:"Medium violet",rgb:"#8F47B3"},{name:"Melon",rgb:"#FEBAAD"},{name:"Middle blue-green",rgb:"#8DD9CC"},{name:"Middle blue-purple",rgb:"#8B72BE"},{name:"Green-yellow",rgb:"#ACBF60"},{name:"Middle purple",rgb:"#D982B5"},{name:"Middle yellow-red",rgb:"#ECAC76"},{name:"Midnight blue",rgb:"#003366"},{name:"Mulberry",rgb:"#C8509B"},{name:"Navy blue",rgb:"#0066CC"},{name:"Olive green",rgb:"#B5B35C"},{name:"Orange",rgb:"#FF8833"},{name:"Orchid",rgb:"#E29CD2"},{name:"Peach",rgb:"#FFCBA4"},{name:"Periwinkle",rgb:"#C3CDE6"},{name:"Pine green",rgb:"#01796F"},{name:"Pink flamingo",rgb:"#FC74FD"},{name:"Plum",rgb:"#8E3179"},{name:"Raw umber",rgb:"#665233"},{name:"Red-orange",rgb:"#FF681F"},{name:"Red",rgb:"#ED0A3F"},{name:"Salmon",rgb:"#FF91A4"},{name:"Vivid scarlet",rgb:"#FD0E35"},{name:"Sea green",rgb:"#93DFB8"},{name:"Sepia",rgb:"#9E5B40"},{name:"Shamrock",rgb:"#33CC99"},{name:"Sky blue",rgb:"#76D7EA"},{name:"Spring green",rgb:"#ECEBBD"},{name:"Sunset orange",rgb:"#FE4C40"},{name:"Tan",rgb:"#FA9D5A"},{name:"Teal blue",rgb:"#008080"},{name:"Thistle",rgb:"#D8BFD8"},{name:"Vivid tangerine",rgb:"#ED3C10"},{name:"Vivid violet",rgb:"#a625c3"},{name:"Wisteria",rgb:"#C9A0DC"},{name:"Yellow-green",rgb:"#C5E17A"},{name:"Yellow-orange",rgb:"#FFAE42"},{name:"Yellow",rgb:"#FBE870"}],t.CrayonSupplements=[{name:"Artichoke",rgb:"#8F9779"},{name:"Aubergine",rgb:"#48213A"},{name:"Brandy rose",rgb:"#B1847F"},{name:"Burgundy",rgb:"#800020"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Crimson red",rgb:"#990000"},{name:"Dark brown",rgb:"#664228"},{name:"Dark coral",rgb:"#CD5B45"},{name:"Dark green",rgb:"#006400"},{name:"Dark raspberry",rgb:"#872657"},{name:"Dark turquoise",rgb:"#610079"},{name:"Deep teal",rgb:"#004040"},{name:"Deep coffee",rgb:"#704241"},{name:"Dusty rasberry",rgb:"#917980"},{name:"Ecru",rgb:"#BCAC7C"},{name:"Evergreen",rgb:"#05472A"},{name:"Eggplant",rgb:"#380835"},{name:"Eggplant purple",rgb:"#430541"},{name:"Emerald green",rgb:"#028F1E"},{name:"Flamingo pink",rgb:"#D67C99"},{name:"Grape",rgb:"#6C3461"},{name:"Kelly green",rgb:"#4CBB17"},{name:"Light forest green",rgb:"#4F9153"},{name:"Medium dark brown",rgb:"#AF7200"},{name:"Medium dark cyan-blue",rgb:"#2D537C"},{name:"Mustard",rgb:"#FAAF18"},{name:"Neon green",rgb:"#39FF14"},{name:"Pear",rgb:"#D1E231"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Phthalo blue",rgb:"#0016C7"},{name:"Pink lace",rgb:"#FFDDF4"},{name:"Raw sienna",rgb:"#884B15"},{name:"Rebecca purple",rgb:"#663399"},{name:"Sap green",rgb:"#536916"},{name:"Blue sapphire",rgb:"#133ECB"},{name:"Sand",rgb:"#B38751"},{name:"Shadow blue",rgb:"#778BA5"},{name:"Shadow green",rgb:"#121E06"},{name:"Swamp green",rgb:"#748500"},{name:"Verdigris",rgb:"#43B3AE"},{name:"Vivid blue-magenta",rgb:"#4817E8"},{name:"Vivid blue-purple",rgb:"#ACACE6"},{name:"Vivid blue",rgb:"#47ABCC"},{name:"Vivid green-yellow",rgb:"#D9E650"},{name:"Vivid green",rgb:"#7BE214"},{name:"Vivid turqoise",rgb:"#06ECD2"},{name:"Vivid lavender",rgb:"#A354FD"},{name:"Vivid mint",rgb:"#00F28C"},{name:"Vivid pink",rgb:"#D752FB"},{name:"Vivid red-purple",rgb:"#C31D7E"},{name:"Vivid red",rgb:"#D92121"},{name:"Vivid yellow-red",rgb:"#F2BA49"},{name:"Vivid yellow",rgb:"#FAFA37"}]},91482:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DarkWikipediaColors=void 0,t.DarkWikipediaColors=[{name:"Bistre",rgb:"#3D2B1F"},{name:"Black bean",rgb:"#3D0C02"},{name:"Black pearl",rgb:"#041322"},{name:"Shadow blue",rgb:"#001440"},{name:"Charcoal",rgb:"#36454F"},{name:"Dark indigo",rgb:"#1F0A52"},{name:"Dark magenta",rgb:"#8B008B"},{name:"Dark moss green",rgb:"#4A5D23"},{name:"Dark navy",rgb:"#02075D"},{name:"Dark pastel blue",rgb:"#779ECB"},{name:"Dark purple",rgb:"#580040"},{name:"Dark tan",rgb:"#918151"},{name:"Dark yellow-green",rgb:"#304000"},{name:"Dark yellow",rgb:"#9B870C"},{name:"Deep violet",rgb:"#330066"},{name:"Dusk",rgb:"#4E5481"},{name:"Elderberry",rgb:"#1d1a34"},{name:"Grey jade",rgb:"#757C55"},{name:"Grey magenta",rgb:"#83667F"},{name:"Grey ochre",rgb:"#716659"},{name:"Grey olive",rgb:"#656c5a"},{name:"Grey sage",rgb:"#69724d"},{name:"Taupe",rgb:"#483C32"}]},3048:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciede2000_delta_e=t.diffCIECorr=t.MaxCie=t.MinCie=t.cie94_delta_e=t.cie76_delta_e=void 0;const n=i(31586),r=i(97352);t.cie76_delta_e=function(e,t){return Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2)},t.cie94_delta_e=function(e,t){const[i,n,s]=e,[a,o,l]=t,u=i-a,c=n-o,d=s-l,h=(0,r.sqrt)(n**2+s**2),f=h-(0,r.sqrt)(o**2+l**2),m=(0,r.sqrt)(c**2+d**2-f**2);return(0,r.sqrt)((u/1)**2+(f/(1+.045*h))**2+(m/(1+.015*h))**2)},t.MinCie=2,t.MaxCie=20,t.diffCIECorr=function(e,i){return null==e||null==i?1:(0,n.clamp)(0,t.MaxCie,l(e,i)-t.MinCie)/t.MaxCie};const s=1,a=1,o=1;function l(e,t){const[i,n,l]=e,u=(0,r.sqrt)(n**2+l**2),[c,d,h]=t,f=(u+(0,r.sqrt)(d**2+h**2))/2,m=.5*(1-(0,r.sqrt)(Math.pow(f,7)/(Math.pow(f,7)+Math.pow(25,7)))),p=n*(1+m),g=d*(1+m),y=(0,r.sqrt)(p*p+l*l),v=(0,r.sqrt)(g*g+h*h);let w=Math.abs(p)+Math.abs(l)===0?0:Math.atan2(l,p);w+=2*(w<0?1:0)*Math.PI;let S=Math.abs(g)+Math.abs(h)===0?0:Math.atan2(h,g);S+=2*(S<0?1:0)*Math.PI;const b=c-i,P=v-y;let M=y*v==0?0:S-w;M-=2*(M>Math.PI?1:0)*Math.PI,M+=2*(M<-Math.PI?1:0)*Math.PI;const _=2*(0,r.sqrt)(y*v)*Math.sin(M/2),E=(i+c)/2,x=(y+v)/2;let T;y*v==0?T=w+S:(T=(w+S)/2,T-=(Math.abs(w-S)>Math.PI?1:0)*Math.PI,T+=2*(T<0?1:0)*Math.PI);const D=(E-50)**2,k=1-.17*Math.cos(T-Math.PI/6)+.24*Math.cos(2*T)+.32*Math.cos(3*T+Math.PI/30)-.2*Math.cos(4*T-63*Math.PI/180),C=1+.015*D/(0,r.sqrt)(20+D),F=1+.045*x,O=1+.015*x*k,I=30*Math.PI/180*Math.exp(-1*((180/Math.PI*T-275)/25)**2),L=2*(0,r.sqrt)(Math.pow(x,7)/(Math.pow(x,7)+Math.pow(25,7))),A=-1*Math.sin(2*I)*L;return(0,r.sqrt)(Math.pow(b/(s*C),2)+Math.pow(P/(a*F),2)+Math.pow(_/(o*O),2)+A*P/(a*F)*_/(o*O))}t.ciede2000_delta_e=l},76490:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColor=t.dominantColorsToRgbHex=void 0;const n=i(40958),r=i(31586),s=i(97352),a=i(54772),o=i(85810),l=i(42022),u=i(1971);t.dominantColorsToRgbHex=function(e){return(0,n.compact)(e.map((e=>[e.rgbhex,(0,r.fmtPct)(e.pct)])))};class c{static fromModeData(e){return(0,n.compact)((0,r.times)(u.ModeCount,(t=>c.fromLabhash({labhash:e[`mode${t}`],pct:e[`mode${t}pct`]}))))}static toModeData(e){const t={};return(0,r.times)(u.ModeCount,(i=>{t["mode"+i]=e[i]?.labhash??null,t["mode"+i+"pct"]=e[i]?.pct??null})),t}static fromLabhash({labhash:e,labhashBits:t=l.ModeBits,pct:i}){const n=(0,s.mapGt0)(e,(e=>(0,o.unlabhash)(e,t)));return null!=n&&(0,r.gt0)(i)?new c(n,i,e):void 0}static fromCentroid(e,t){return new c(e.centroid,Math.round(e.size/t*100))}constructor(e,t,i){this.lab=e,this.pct=(0,r.clamp)(0,100,t),this.labhash=i??(0,o.toLabhash)(e,l.ModeBits)}get rgbhex(){return(0,o.lab2rgbhex)(this.lab)}get color(){return(0,a.bestLabhashName)(this.labhash)}toGreyscale(){return new c([this.lab[0],0,0],this.pct)}eql(e){return this.labhash===e.labhash&&(0,r.closeTo)(this.pct,e.pct,5)}}t.DominantColor=c},40401:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeNearCentroids=t.mergeLabhashes=t.dominantColorsFromModes=t.maybeFilterGrey=t.centroidsScore=t.extractDominantColors=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(41400),o=i(98553),l=i(31586),u=i(68708),c=i(48884),d=i(22454),h=i(50213),f=i(56038),m=i(82647),p=i(44983),g=i(70417),y=i(28874),v=i(85810),w=i(3048),S=i(76490),b=i(1971),P=(0,n.lazy)((()=>(0,h.mkLogger)("color.DominantColors")));t.extractDominantColors=function(e,t=b.ModeCount){return(0,f.timeSync)("img.extractDominantColors",(()=>function(e,t=b.ModeCount){const i=Date.now(),n=y.Settings.dominantColorKmeansRuns.valueOrDefault,a=new d.CountingSet;for(const i of x({labs:e,minK:t}))a.incr((0,v.toLabhash)(i));const h=_[y.Settings.dominantColorDeltaE.valueOrDefault]??w.ciede2000_delta_e;const f=a.sortedByKey().valuesToA((e=>(0,v.unlabhash)(e)));let g=(0,l.round)(t+y.Settings.dominantColorMergeThreshold.valueOrDefault);function D(e){const i=t,n=4*t;g=Math.round(Math.max(i,Math.min(n,e)))}const C=f.length<=g?[]:(0,r.compact)(M.slice(0,n).map((e=>{const n=(0,p.kmeans)(f,g,{...E,seed:e}),r=k(n.centroids,f.length);if(r.lengtht&&D(g-1);const s=r.slice(0,t),o=(0,l.sigFigs)(function(e){const t=new m.Average;for(const[i,n]of a.entries()){const r=(0,v.unlabhash)(i),s=(0,c.leastByCtx)(e,(e=>h(e.centroid,r)));null!=s&&(0,l.times)(n,(()=>t.push(s.value)))}return t.p84}(s),2);return{...n,centroids:s,description:{kIn:g,kOut:n.centroids.length,kMerged:r.length,score:o,iterations:n.iterations,uniqColors:a.size,elapsedMs:Date.now()-i},score:o}})));P().trace("extractDominantColors()",{kmeansResults:C.map((e=>(0,u.pick)(e,"description","score")))});const F=(0,c.leastBy)(C,(e=>e.score));if(null==F)return P().info("kmeans failed or was disabled, using dominantColorsFromModes",{runs:n}),T(a,t);const O=(0,o.stringify)({...F?.description,elapsedMs:Date.now()-i}),I=(0,s.sortBy)(F?.centroids,(e=>-e.size)).map((e=>S.DominantColor.fromCentroid(e,f.length)));return P().debug("extractDominantColors() result",{description:O,score:F?.score,totalColors:a.size,totalPixels:f.length,iters:F?.iterations,dominantColors:(0,S.dominantColorsToRgbHex)(I),pixelCount:f.length}),{dominantColors:I,description:O,dominantColorScore:F?.score}}(e,t)))},t.centroidsScore=function(e,t){const i=new m.Average;for(const n of e){const e=(0,c.leastBy)(t,(e=>(0,w.ciede2000_delta_e)(e.centroid,n)));null!=e&&i.push((0,w.ciede2000_delta_e)(e.centroid,n))}return i};const M=[6147062518717073,8176726750919909,5426648081701673,0xce2a345532a3c,0x713f9716da824,6348935463312109,5900323173950995,7358780886584433,5704068712193493,0x51ceeef755892,0xe1557fe94c084,0xd42d7cc96d6b4,0xcbc36dfd76e8a,6738189173486085,8537822851166899,5390086061821835,7712057976331355,0xe9b820db7a8e4,0xb96cebcd6aa40,7036994544380825,5353634786120155,0x99a11417794bc,0xa93d36019aaae,0x74a470887095e,5481147022770415,5347523348244809,0x541d1098e90fc,0xa24d9fb3510c2,0x78aa8e4f692fa,6354921850669697,0x714e1ec1b0a14,8622097963014773,0x6ff5d462d8eb6,0x6782a6b5166b8,7128984079394103,0xe6efba28a3752,5088704486053871,0xc84df40627fae,8018285280412081,4524300326741245,8307147030534695,8135486835878813,7699950603263999,0xb2889592968ae,5903399874280295,7462660765348991,6442509751447017,0xe218d44834db6,7214173935589545,6001326758941961,0x53eb7d39bbb50,0xc3a7ab8add332,0x4e6e81bc443e2,6757635537583321,8501611905255957,0x51840465cc07c,5958243312989149,8928005021308717,5032083390680559,0xb35d70ac51c68,0xfc3826a2dfe7c,0xd155853c61e96,0xda2045ee9be1e,4753952745315177],_={cie76:w.cie76_delta_e,cie94:w.cie94_delta_e,ciede2000:w.ciede2000_delta_e},E=(0,n.lazy)((()=>({maxIterations:50,initialization:"kmeans++",distanceFunction:_[y.Settings.dominantColorDeltaE.valueOrDefault]})));function x({labs:e,minK:t,thresh:i,retries:n=3}){if(n<0)return P().debug("maybeFilterGrey(): exhausted retries: grey filtering disabled."),e;const r=i??y.Settings.dominantColorGreyThreshold.valueOrDefault;if(!(0,l.gt0)(r))return P().debug("maybeFilterGrey(): grey threshold is <= 0: grey filtering disabled."),e;const s=e.filter((e=>Math.abs(e[1])+Math.abs(e[2])>=r));return s.length>=e.length/2?(P().debug("maybeFilterGrey(): sufficient remaining pixels with this threshold.",{greyThreshold:r,minK:t,pixelCount:e.length,filteredCount:s.length}),s):(P().debug("maybeFilterGrey(): insufficient remaining pixels with this threshold. Retrying with smaller threshold.",{greyThreshold:r,minK:t,retries:n,pixelCount:e.length,filteredCount:s.length}),x({labs:e,minK:t,thresh:.75*r,retries:n-1}))}function T(e,t){const i=e.countSum,n=e.size;D(e);const s=e.size,a=(0,r.compact)(e.top(t).map((([e,t])=>S.DominantColor.fromLabhash({labhash:e,pct:Math.round(100*t/i)})))),l=100-(0,g.sumf)(a,(e=>e.pct));return{dominantColors:a,description:"dominantColorsFromModes: "+(0,o.stringify)({uniqColors:n,mergedColors:s,pixelCount:i,pctOmitted:l})}}function D(e,t=y.Settings.dominantColorMergeThreshold.valueOrDefault){const i=[];for(const[n,r]of[...e.entriesByCountDesc()]){const s=(0,v.unlabhash)(n),a=i.find((e=>(0,w.ciede2000_delta_e)(e.lab,s)<=t));null==a?i.push({lab:s,labhash:n}):(e.delete(n),e.incr(a.labhash,r))}return e}function k(e,t,i=y.Settings.dominantColorMergeThreshold.valueOrDefault){if(i<=0)return e;const n=[];for(const t of e){const e=n.find((e=>(0,w.ciede2000_delta_e)(t.centroid,e.centroid)<=i));null==e?n.push(t):e.size+=t.size}const r=t/100;return(0,s.sortBy)(n.filter((e=>e.size>r)),(e=>-e.size))}(0,a.later)((()=>{y.Settings.dominantColorDeltaE.watchLater((()=>{E.unset()}))})),t.maybeFilterGrey=x,t.dominantColorsFromModes=T,t.mergeLabhashes=D,t.mergeNearCentroids=k},85409:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Greys=void 0,t.Greys=[{name:"Black",rgb:"#000000"},{name:"90% black",rgb:"#1b1b1b"},{name:"80% black",rgb:"#303030"},{name:"70% black",rgb:"#474747"},{name:"60% black",rgb:"#5e5e5e"},{name:"Grey",rgb:"#777777"},{name:"60% white",rgb:"#919191"},{name:"70% white",rgb:"#ababab"},{name:"80% white",rgb:"#c6c6c6"},{name:"90% white",rgb:"#e2e2e2"},{name:"White",rgb:"#ffffff"}]},86758:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.labsAreGreyscale=t.isLab=void 0;const n=i(19851),r=i(31586),s=i(50213),a=i(82647),o=i(28874),l=i(85810),u=(0,n.lazy)((()=>(0,s.mkLogger)("color.Lab")));t.isLab=function(e){return Array.isArray(e)&&3===e.length&&(0,r.within)(0,100,e[0])&&(0,r.within)(-110,110,e[1])&&(0,r.within)(-110,110,e[2])},t.labsAreGreyscale=function(e){const t=o.Settings.greyscaleColorThreshold.valueOrDefault,i=new a.Average,n=new a.Average;for(const t of e){const e=(0,l.clampLab)(t);i.push(e[1]),n.push(e[2])}const r=(i.stdDev??0)+(n.stdDev??0),s=r{Object.defineProperty(t,"__esModule",{value:!0}),t.LightWikipediaColors=void 0,t.LightWikipediaColors=[{name:"Beige",rgb:"#F5F5DC"},{name:"Laurel green",rgb:"#A9BA9D"},{name:"Light sage",rgb:"#93A58B"},{name:"Light green-cyan",rgb:"#CFEADE"},{name:"Pastel purple",rgb:"#B39EB5"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Powder blue",rgb:"#B0E0E6"},{name:"Vanilla",rgb:"#F3E5AB"}]},42022:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ModeBits=void 0,t.ModeBits=12},1971:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ModeCount=void 0,t.ModeCount=7},85434:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.omitModeData=t.pickModeData=t.ModeDataKeys=t.isModeData=void 0;const n=i(31586),r=i(68708),s=i(50989);t.isModeData=function(e){return(0,n.gt0)(e.mode0)&&(0,n.gt0)(e.mode0pct)},t.ModeDataKeys=(0,s.strEnum)("mode0","mode0pct","mode1","mode1pct","mode2","mode2pct","mode3","mode3pct","mode4","mode4pct","mode5","mode5pct","mode6","mode6pct"),t.pickModeData=function(e){return(0,r.pick)(e,...t.ModeDataKeys.values)},t.omitModeData=function(e){return(0,r.omit)(e,...t.ModeDataKeys.values)}},85042:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clampRGB=t.rgbTriplet2hex=t.rgbhex2triplet=t.normalizeRgbHex=void 0;const n=i(31586),r=i(39926),s=i(51926),a=i(54993),o=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;function l(e){return[e[0],e[1],e[2]].map((e=>(0,n.clamp)(0,255,Math.round(e))))}t.normalizeRgbHex=function(e){const t=(0,a.toS)(e).trim();return o.test(t)?(0,s.ensurePrefix)(t,"#").toUpperCase():void 0},t.rgbhex2triplet=function(e){const t=(0,a.toS)(e).trim().match(o);if(null!=t)try{return[t[1],t[2],t[3]].map((e=>(0,n.clamp)(0,255,parseInt(e,16))))}catch{return}},t.rgbTriplet2hex=function(e){return"#"+l(e).map((e=>(0,r.leftPad)(Math.round(e).toString(16).toUpperCase(),2,"0"))).join("")},t.clampRGB=l},76596:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const n=i(51168),r=i(19851),s=i(22573),a=i(42659),o=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,r.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,o.mapOr)(e,(e=>e.getTime()),(()=>0)),n=(0,o.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,n)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,a.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const n=i(77988),r=i(19851),s=i(55835),a=i(31586),o=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,r.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),h=["year","month","day","hour","minute","second","millisecond"];class f{static fromISO(e,t){const i=d().exec((0,o.toS)(e).trim()),n=i?.groups;return null==n?void 0:f.for((0,c.parseExifDateTime)(n.start,t),(0,c.parseExifDateTime)(n.end,t),(0,a.toInt)(n.index),(0,a.toInt)(n.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,s.map)(e.start,(e=>n.ExifDateTime.fromJSON(e))),(0,s.map)(e.end,(e=>n.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,n=1){if(null==e||!e.isValid||null==t||!t.isValid)return;n=(0,a.clamp)(1,1e3,(0,a.toInt)(n,{defaultValue:1})),i=(0,a.clamp)(0,n-1,(0,a.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const r=e.toMillis(),s=(t.toMillis()-r)/(n+1)*(i+1),o=e.plus({milliseconds:s});return null==o?void 0:new f(e,o,t,i,n)}constructor(e,t,i,n=0,r=1){this.start=e,this.middle=t,this.end=i,this.index=n,this.splits=r,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=h.map((n=>function({start:e,end:t,middle:i,field:n}){return null!=e[n]&&null!=t[n]?i[n]:void 0}({start:e,middle:t,end:i,field:n})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new f(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=f},79842:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const n=i(77988),r=i(51168),s=i(19851),a=i(76790),o=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),h=i(51926),f=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),v=i(21330),w=i(928),S=i(54261),b=i(73389),P=i(51275),M=(0,s.lazy)((()=>(0,f.mkLogger)("date.Dated")));function _(e){return null!=e&&(e instanceof v.FuzzyDate||e instanceof n.ExifDate||e instanceof n.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,b.isDateTime)(e)||(0,m.isDateObject)(e))}function E(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof n.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function x(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof n.ExifDate?e.toMillis(l.dayMs):e instanceof v.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),D(e),((e,t)=>e+t))}function T(e){try{if(null==e||(0,h.isString)(e)||(0,c.isNumber)(e))return;return(0,b.isDateTime)(e)?e:e instanceof n.ExifDateTime||e instanceof v.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?r.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void M().warn("datedToDateTime() failed",{d:e,error:t})}}function D(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,S.hasTime)(e)){if((0,c.gt0)((0,w.getMillisecond)(e)))return 0;if((0,c.gt0)((0,w.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,w.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,w.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,w.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,w.getMonth)(e))?l.monthMs-1:l.yearMs-1}function k(e,t){const i=E(e),n=x(e);if(null!=i&&null!=n)return(0,c.gt0)(t)&&t>n-i?{start:Math.round((i+n)/2-t/2),end:Math.round((i+n)/2+t/2)}:{start:i,end:n}}function C(e,t,i,n){const[r,s]=(0,a.sortBy)([k(e,i),k(t,n)],(e=>e?.start));return null!=r&&null!=s&&null!=r&&null!=s&&(r.start===s.start||r.end>=Math.min(s.start,s.end))}function F(e,t){return(0,o.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??v.FuzzyDate.fromISO(e)}t.isDated=_,t.toDated=function(e){return _(e)?e:void 0},t.mapDated=function(e,t){return _(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=E,t.datedToEndTs=x,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof n.ExifDate?r.DateTime.fromObject(e):T(e)},t.datedToDateTime=T,t.datedToPrecisionMs=D,t.isoToPrecisionMs=function(e){return(0,u.map)(F(e),D)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:n}){if(null==e||null==t)return!1;if(i??(i=D(e)),n??(n=D(t)),C(e,t,i,n))return!0;const r=(0,P.getZoneName)(e),s=(0,P.getZoneName)(t);return null==r&&null!=s&&(e=(0,v.setZone)(e,s)??e),null==s&&null!=r&&(t=(0,v.setZone)(t,r)??t),C(e,t,i,n)},t.isoToDated=F,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof r.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const n=i(31586),r=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,r.isString)(e))return(0,n.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const n=i(22573),r=i(31586),s=i(54557),a=i(91655),o=new s.FifoCache(512);function l(e){return(0,r.isNumber)(e)?e:(0,n.blank)(e)?void 0:o.getOrSet(e,(()=>(0,a.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,n.blank)(e)?void 0:u.getOrSet(e,(()=>(0,a.fmtFullDuration)((0,r.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const n=i(51168),r=i(40958),s=i(22573),a=i(42659),o=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,o.isNumber)(e))return;if((0,o.isNumber)(e))return e;if((0,o.isDigits)(e))return(0,o.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=n.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,r.compact)(d.map((e=>function(e,t){const i=(0,o.toFloat)(e);if(null!=i){if((0,s.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*a.yearMs;case"weeks":case"week":case"w":return i*a.weekMs;case"days":case"day":case"d":return i*a.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*a.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*a.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*a.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,o.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:a.yearMs,s:"y"},{ms:a.weekMs,s:"w"},{ms:a.dayMs,s:"d"},{ms:a.hourMs,s:"h"},{ms:a.minuteMs,s:"m"},{ms:a.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,o.isNumber)(t))return;if(0===t)return"0";if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const n=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&n.push(i+e.s)}return n.join(i)}},98247:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const n=i(77988),r=i(51168),s=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),h=i(68852),f=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function v(e,t,i){const n=t.exec(e);if(null==n||(0,u.isEmptyObj)(n.groups))return;const{year:r,month:s,day:a,hour:c,minute:h,second:p}=(0,d.mapEntries)(n.groups,((e,t)=>(0,l.toInt)(t)));if(null==r||null==s||null==a)return;if(!f.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==h))return;const g=(0,o.map)((0,l.toFloat)(n.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),v=(0,y.timezoneOffsetFromRegExpMatch)(n);return b({year:r,month:s,day:a,hour:c??0,minute:h??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(v)??i,rawValue:e,tzoffsetMinutes:v})}t.UnsetZone=r.Info.normalizeZone(n.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof n.ExifDate&&t instanceof n.ExifTime))return;const i=new n.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:s}){return(0,a.blank)(e)?void 0:n.ExifDateTime.fromDateTime(r.DateTime.fromFormat(e,i,{zone:s??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,a.blank)(e)?void 0:n.ExifDateTime.fromDateTime(r.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,a.blank)(e)?void 0:n.ExifDateTime.from(e,t)??v(e,S(),t)},t.parseExifDateTimeRe=v;const w=/[-:_\s]?/,S=(0,s.lazy)((()=>(0,h.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,w,p.monthRE,w,p.dayRE,/[T\s]/,p.hourRE,w,p.minuteRE,w,p.secondRE,p.subsecRE,/\s?/,h.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function b(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof n.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=n.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,o.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=b},74417:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const n=i(51168),r=i(22573),s=i(42659),a=i(49769),o=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),h=i(66649),f=i(98725),m=i(88600);t.recent=function(e,t=5*s.secondMs){return(0,c.isRecentMs)((0,h.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=n.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,r.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,r.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=n.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,a.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,h.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,o.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*s.secondMs):void 0)??(0,f.parseDateTime)(t)?.toMillis()}},21330:function(e,t,i){var n,r=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const s=i(77988),a=i(51168),o=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(31586),f=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),v=i(79842),w=i(66649),S=i(98247),b=i(98725),P=i(928),M=i(54261),_=i(73389),E=i(89724),x=i(17415),T=i(88600),D=i(51275);function k(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class C{constructor(e,t,i){this.year=e,this.month=t,this.day=i,n.set(this,(0,p.lazy)((()=>(0,T.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(b.ISO_YMD_RE.exec(e)?.groups??b.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,h.toGt0)(e?.year);if(null==e||null==t||tk(e))).join("-")}toLocal(){return(0,E.datedToLocal)(this)}toDateTime(){return a.DateTime.fromObject((0,f.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,f.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,f.pick)(e.plus({month:1}),"year","month"):(0,f.pick)(e.plus({year:1}),"year");return new C(t.year,t.month,t.day)}}function F(e,t){if(e instanceof s.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,M.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,x.zoneToTzOffsetMinutes)((0,w.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(n=>(0,d.map)((0,P.getMonth)(e),(r=>(0,d.map)((0,P.getDay)(e),(s=>(0,d.map)((0,P.getHour)(e),(a=>(0,S.dateObjectToExifDateTime)({year:n,month:r,day:s,hour:a,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=C,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",n=15*(0,h.round)(e/15),r=Math.abs(n),s=Math.floor(r/60),a=Math.floor(Math.abs(r%60));return`${t?"UTC":""}${i}${k(s)}:${k(a)}`},t.toExifDateTime=F,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof s.ExifDateTime?e.tzoffsetMinutes:(0,_.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,M.hasTime)(e)||(i??(0,v.datedToPrecisionMs)(e))>=c.dayMs?L(e):F(e,(0,D.getZoneName)(e))?.toISOString({includeOffset:t})};const O="yyyy:MM:dd HH:mm:ss.SSS",I=O+"ZZ";function L(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>k(e))).join(t)}function A(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new C(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,n]=[e,t].map(w.datedToMillis);return null==i||null==n?void 0:i-n}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,h.isNumber)(t)?a.DateTime.fromMillis(t):(0,v.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,D.hasZone)(t)?I:O):void 0},t.datedToYMD=L,t.toFuzzyDate=A,t.sameDay=function(e,t){return(0,h.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,h.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,n=1){if(null==(0,w.datedToMillis)(e)||null==(0,w.datedToMillis)(t))return;const[r,s]=[e,t].map((e=>(0,w.datedToMillis)(e))).sort(),o=(s-r)/(n+1),l=(0,D.getZoneName)(e),u=l===(0,D.getZoneName)(t)?l:void 0,c=a.DateTime.fromMillis(r+o*i,{zone:u});return[e,t].some((e=>!(0,M.hasTime)(e)))?A(c):c},t.setZone=function(e,t,i){const n={...(0,f.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,D.hasZone)(e)},r=(0,x.normalizeZone)(t);if(null!=e&&null!=r&&(0,M.hasTime)(e))return e instanceof y.DateInterval?e.setZone(r,n):F(e)?.setZone(r,n)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,h.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,v.datedToDateTime)(e);if(null==i)return;const n=(0,D.getZoneName)(e);return null!=n&&"UTC"!==n||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){var n,r,s,a=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const o=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),h=i(49769),f=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),v=i(68852),w=i(4001),S=i(28874),b=i(24689),P=i(79842),M=i(66649),_=i(98247),E=i(21330),x=i(54261),T=i(73389),D=i(16400),k=i(88600),C=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return C().tap({msg:"extractDateFromPath",result:L.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return L.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return L.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,f.mapNumeric)((0,M.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,v.concatRegexp)([/^/,t.yearRE,v.RegExpOptional.from(/-/,t.monthRE,v.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,v.concatRegexp)([/^/,t.yearishRE,v.RegExpOptional.from(/-/,t.monthishRE,v.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=I({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,T.isDateTime)(i)?i:(0,x.isExifDateTime)(i)?i.toDateTime():void 0};const F=new Map;function O(e,t,i){try{const n=(0,_.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=n)return n;const r=(0,h.getOrSet)(F,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void C().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,_.parseExifDateTimeFormat)({input:r?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void C().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function I({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:n=!0,descPredicate:r=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const s=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(w.stripDSC));if(0!==s.length)for(const{desc:e,f:a}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>b.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,_.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:_.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(S.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(S.Settings.extraDateTimeFormats.values)){const n=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${n})`,f:i=>O(i,n,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>o.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of L.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:n}))if(r(e))for(const e of s){const t=a(e);if(null!=t&&(0,k.isValidDate)(t))return t}}t.parseDated=I;class L{constructor(e={}){n.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&S.Settings.fuzzyDateParsing.watchLater((()=>a(this,n,"m",s).call(this))),null==e.fuzzyYearParsing&&S.Settings.fuzzyYearParsing.watchLater((()=>a(this,n,"m",s).call(this))),a(this,n,"m",s).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??S.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??S.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!S.Settings.usePathsToInferDates.valueOrDefault)return;E.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=I({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=L,n=new WeakSet,r=function(e){const t=new A(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},s=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new v.RegExpEscaped("(?"+(0,D.monthNames)().map(v.escapeRegExp).join("|")+")");a(this,n,"m",r).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),a(this,n,"m",r).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),a(this,n,"m",r).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),a(this,n,"m",r).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),a(this,n,"m",r).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),a(this,n,"m",r).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),a(this,n,"m",r).call(this,[t.yearRE,t.seps,t.monthishRE]),a(this,n,"m",r).call(this,[e,t.seps,t.yearRE]),a(this,n,"m",r).call(this,[t.yearRE,t.seps,e]),a(this,n,"m",r).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},L.instance=(0,u.lazy)((()=>new L));class A{constructor(e){this.regex=e instanceof RegExp?e:(0,v.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return E.FuzzyDate.for({year:(0,f.toInt)(t.year),month:(0,f.toInt)(t.month)??(0,D.monthName2index)(t.monthname),day:(0,f.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const n=i(55835),r=i(31586),s=i(54261);function a(e){return e instanceof Date?e.getMinutes():e?.minute}function o(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=a,t.getSecond=o,t.getMillisecond=l,t.getCentisecond=function(e){return(0,n.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,s.hasTime)(e)&&((0,r.gt0)(a(e))||(0,r.gt0)(o(e))||(0,r.gt0)(l(e)))},t.getSecMs=function(e){return(0,n.map)(o(e),(t=>{const i=l(e)??0;let n=(t+i/1e3).toString();for(t<10&&(n="0"+n),0===i&&(n+=".");n.length<6;)n+="0";return n}))}},54261:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const n=i(77988),r=i(31586),s=i(68708);t.hasTime=function(e){if(!(0,s.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,r.gt0)(t.hour)||(0,r.gt0)(t.minute)||(0,r.gt0)(t.second)||(0,r.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof n.ExifDateTime}},73389:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const n=i(51168);t.isDateTime=function(e){return n.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const n=i(51168),r=i(19851),s=i(42659),a=i(55835),o=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),h=i(74417),f=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,r.lazy)((()=>v(l.Settings.datesBeforeAreEstimated.valueOrDefault)??v(l.Settings.datesBeforeAreEstimated.defaultValue)));function v(e){return(0,a.map)((0,c.isoToDated)(e),w)}function w(e){return(0,o.isNumber)(e)?_(e):100*S(e)+((0,m.getCentisecond)(e)??0)}function S(e){if((0,o.isNumber)(e))return Math.floor(_(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function b(e,t){if(null==e||e<0)return;let i=e;const n=()=>{const e=i%100;return i=Math.floor(i/100),e},r=10*n(),s=n(),a=n(),l=(0,o.toGt0)(n()),u=(0,o.toGt0)(n()),c=(0,o.toGt0)(n());return{year:i,month:c,day:u,hour:l,minute:a,second:s,millisecond:r,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=b(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):f.FuzzyDate.for(i)}function M(e,t){return _(Date.now()-e,t)}function _(e,t){return w(n.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const n=i(19851),r=i(76790),s=i(31586),a=i(9092),o=(0,n.lazy)((()=>{const e=new a.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const n=new Intl.DateTimeFormat(t,{month:i});(0,s.times)(12,(r=>{const s=n.format(new Date(2017,r));e.set(s,r+1),"short"===i&&"en-US"===t&&e.set(s+".",r+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:o().get(e)},t.monthNames=function(){return(0,r.sort)([...o().keys()])}},17415:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const n=i(77988),r=i(51168),s=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),h=i(54993),f=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,s.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const n=(0,f.leastBy)(g(),(t=>Math.abs(t-e)));return null!=n&&Math.abs(n-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(n)}t.isUTCZone=function(e){return S(e)||0===b(e)?.offset(Date.now())},t.normalizeZone=b,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,o.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=M,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:M(i)};const _=/\b(?Z|UTC|GMT)\b/,E=/(?[-±+−])/,x=/[-−]/,T=/(?[01]\d)/,D=/(?[01]?\d)/,k=/(?::(?\d\d))/;function C(e){return S(e)?0:F((0,t.TimezoneOffsetRE)().exec(e))}function F(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,a.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=x.test((0,h.toS)(e.groups.tzSign))?-1:1,n=(0,l.toInt)(e.groups.tzMinutes)??0,r=null==t?void 0:i*(60*t+n);return v(r)?r:void 0}t.TimezoneOffsetRE=(0,s.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),_,new m.RegExpEscaped("|"),E,T,m.RegExpOptional.from(k),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=C,t.timezoneOffsetFromRegExpMatch=F;const O=/\b(?(?:Etc\/)?GMT)\b/,I=(0,s.lazy)((()=>(0,m.concatRegexp)([O,E,D,m.RegExpOptional.from(k)])));function L(e){return F(I().exec(e))}t.ianaZoneToOffsetMinutes=L,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,a.blank)(e))return;const i=L(e)??C(e);if(null!=i)return M(i);if(null!=t){const i=b(e);if(null!=i)return M(i.offset(t))}}},88600:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const n=i(51168),r=i(19851),s=i(40958),a=i(22573),o=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),h=i(28874),f=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),v=(0,r.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),w=(0,r.lazy)((()=>(0,s.compact)(h.Settings.badDates.values.map((e=>(0,f.isoToDated)(e)))))),S=(0,r.lazy)((()=>(0,s.compact)(w().map((e=>(0,p.datedToISO)(e)))))),b=(0,r.lazy)((()=>(0,s.compact)(w().map((e=>(0,y.datedToLocal)(e)))))),P=(0,r.lazy)((()=>(0,s.compact)(w().map((e=>(0,m.datedToMillis)(e))))));function M(e){if(null==e)return!1;const t=E(e);return v().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return M(e)?e:void 0},t.isValidDate=M;const _=String(new Date("bad"));function E(e){try{if(!(0,f.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===_)return _;const t=(0,s.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const r=[];if((0,l.isNumber)(e)||r.push("year is not a number"),(0,l.lt)(e,h.Settings.minValidYear.valueOrDefault)&&r.push("year is less than "+h.Settings.minValidYear.key),(0,u.gt)(e,x())&&r.push("year is in the future"),null==t&&null!=i&&r.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&r.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&r.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const s=n.DateTime.fromObject({year:e,month:t,day:i});s.isValid||r.push(s.invalidExplanation??"not valid")}return(0,s.compact)(r)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=h.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const n=(0,m.datedToMillis)(e);(0,u.gt)(n,Date.now()+i)&&t.push("date is too far in the future: see "+h.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):b().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):S().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,a.toNotBlank)((0,s.uniq)((0,s.compactBlanks)(t)).join("; "))}catch(t){return v().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=E;const x=(0,r.lazy)((()=>n.DateTime.now().plus({milliseconds:h.Settings.maxValidFutureMs.valueOrDefault}).year),o.dayMs);t.mapValidDate=function(e,t){return M(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==E({year:e,month:t,day:i})}},51275:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const n=i(77988),r=i(31586),s=i(24689),a=i(73389);t.hasZone=function(e){return null!=e&&!(0,r.isNumber)(e)&&(e instanceof s.DateInterval||e instanceof n.ExifDateTime?e.hasZone:!!(0,a.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==n.UnsetZoneName&&e.zone.offset(Date.now())!==n.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,a.isDateTime)(e)?e.zoneName===n.UnsetZoneName?void 0:e.zone?.name:e instanceof n.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const n=i(50989);t.AutoVacuumModes=(0,n.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const n=i(50989);t.CheckpointTypes=(0,n.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const n=i(50989);t.RepairModes=(0,n.strEnum)("dump","recover")},15056:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const n=i(50989),r=i(7311);function s(e,t){return e.join(t)}t.Schemas=(0,n.strEnum)("models"),t.pathToDbDir=s,t.pathToDb=function(e,t){return s(e,t).join(r.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const n=i(50989);t.SynchronousModes=(0,n.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const a=s(i(76760)),o=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),v=i(70698),w=i(64680),S=i(29882),b=i(45969),P=i(43334),M=i(28874),_=i(41692),E=i(32774),x=i(80612),T=i(32551),D=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function k(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+D(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,a.join)(i,".photostructure-cache"+D()),preexistingDir:i});return e}}function C(){if((0,b.isDocker)())return(0,o.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,a.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:E.DefaultDockerLibraryDir+"/.photostructure/cache"+D(),preexistingDir:E.DefaultDockerLibraryDir},...k()]);const e=(0,o.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),a.default.resolve((0,T.homeDir)(),"AppData","Local")]:P.isMac?[a.default.resolve((0,T.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,a.join)((0,T.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,a.join)(e,t),preexistingDir:e})));return i.push(...k()),i}t.tmpCacheDirs=k,t.tmpDirs=function(){return(0,x.filterDirs)({dirs:k(),desc:"tmp"})},t.cacheDirs=C,t.defaultCacheDir=(0,d.lazy)((()=>(0,x.firstDir)({dirs:C(),desc:"cache"})));const F=(0,d.lazy)((()=>{(0,_.setSettingsDefaults)(),M.Settings.cacheDir.watchLater(O)}));function O(){M.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{F();const e=M.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=O},46292:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const n=i(19851),r=i(45969),s=i(41692),a=i(32774),o=i(10924),l=i(84373),u=i(80612);t.configDir=(0,n.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,r.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,o.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:a.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:a.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,r.isDocker)()?c:(0,o.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const n=i(66430),r=i(45969),s=i(32774);t.defaultLibraryDir=function(){return(0,r.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,r.isDocker)()&&(0,n.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const r=n(i(76760)),s=i(40958),a=i(72993),o=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),r.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(r.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,o.env)().XDG_DATA_HOME,(0,o.env)().XDG_CONFIG_HOME,r.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:r.default.join(e,(0,a.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const n=i(22573),r=i(96706),s=i(29882);t.envConfigDir=function(){const e=(0,r.getEnv)("PS_CONFIG_DIR");if(!(0,n.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const n=i(44652),r=i(40958),s=i(22573),a=i(66430);function o({dirs:e,desc:t}){for(const{dir:i,preexistingDir:o}of(0,r.compact)(e))if(!(0,s.blank)(i)){if((0,a.isReadWriteableDirectorySync)(i))return i;if((0,s.blank)(o)||(0,a.isReadWriteableDirectorySync)(o))try{return(0,n.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=o,t.filterDirs=function({dirs:e,desc:t}){return(0,r.compact)(e.map((e=>o({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const n=i(48161),r=i(76760),s=i(1708),a=i(19851),o=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,a.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,o.compactBlanks)(e)){const e=(0,r.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,n.homedir)()}))},35280:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const n=i(29882),r=i(49776),s=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,n.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[s.libraryDataDir,s.libraryPreviewsDir,r.cacheDir])if((0,n.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},9595:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const n=i(22573),r=i(54993),s=i(29882),a=i(28874);function o(e){return(0,n.toNotBlank)((0,r.toS)(e))??a.Settings.libraryDir.valueOrDefault}t.libraryDir=o,t.originalsDir=function(e){return(0,s.resolveMaybe)(o(e),a.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,s.resolveMaybe)(o(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,s.resolveMaybe)(o(e),a.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const n=i(40958),r=i(55835),s=i(37805),a=i(15056),o=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${s.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function v(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+o.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function w(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function S(e){return y(w(e),!1)}function b(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(b(e))}function M(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function _(e){return y(M(e))}async function E(e){return y((0,r.map)(g(e),(e=>(0,a.pathToDbDir)(e,a.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await v(t);return(0,n.uniq)([t,i,await S(t),await P(t),await _(t),await E(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=v,t.libraryOriginalsDirPosixFile=w,t.setupLibraryOriginalsDir_=S,t.libraryPreviewsDirPosixFile=b,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=M,t.setupLibrarySyncReportsDir_=_,t.setupLibraryDbDir_=E},46296:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const r=n(i(76760)),s=i(19851),a=i(40958),o=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),v=i(80612),w=i(32551);function S(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:r.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,a.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>r.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,o.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,o.notBlank)(i)?i:b()}catch(e){return console.error("defaultLogDir_() failed",e),r.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const n=i(76760),r=i(19851),s=i(22573),a=i(44198),o=i(43334),l=i(24399),u=i(32551);async function c(){return o.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,r.lazy)((async()=>{if(o.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,r.lazy)((()=>(0,a.env)().XDG_PICTURES_DIR??(0,n.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const n=i(38639),r=i(7282),s=i(29325),a=i(44198);t.getDevEnvFlag=function(e){return!(0,r.isProd)()&&!(0,s.isPacked)()&&((0,n.toBoolean)((0,a.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,a.env)()[e]=String(t)}},34580:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const n=i(38639),r=i(44198);t.doNotTrack=function(){return(0,n.isTrue)((0,r.env)().DO_NOT_TRACK)}},44198:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const r=n(i(73024)),s=i(76760),a=n(i(1708)),o=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),v=i(6012),w=i(96706);t.env=(0,o.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>a.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===a.default.env.PS_LICENSE||e.push((0,s.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),i={...a.default.env};for(const n of e)try{const e=(0,d.debom)(r.default.readFileSync((0,p.resolve)(n))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,n]of(0,c.entries)(s))t.test(e)||(i[e]=n)}catch(e){console.warn("env(): failed to read .env file, "+n,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const n=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,n.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const n=i(50989);t.EnvKeys=(0,n.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const n=i(22573),r=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,n.blank)(e))return i;let s;for(const a of(0,r.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(a));){if(null==s.groups)continue;const{key:e,val:r}=s.groups;if((0,n.blank)(e)||null==r)continue;const a=r.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=a}}return i}},96706:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const r=n(i(1708)),s=i(19851),a=i(22573),o=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,a.firstNotBlank)(r.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,r.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,o.isTrue)(g(e))}},98314:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const n=i(58587),r=i(19851),s=i(40958),a=i(22573),o=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),v=i(70025),w=i(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(o.errorName),...e.map(o.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(o.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(i)))}function b(e){return(0,s.compact)(e).filter((e=>!o.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(a.notBlank)}function P(e,t){const i=(0,s.uniqSubstrings)(b(e)),n=t?.maxLen??400,r=t?.trailingChars??64,a=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(i.join(o.ErrorDelimiter)),n-a.length,r)+a.sort().join("")}function M(e,t){return e instanceof w.WrappedError?e.toString():(0,a.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,r.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new n.Rate,t.fatalErrorRate=new n.Rate,t.internalErrorRate=new n.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(M(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,a.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,a.notBlank)(i))return i}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=M,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,n=7){return(0,a.blank)(e)&&(e=t.MissingError),M(e,{maxLen:i})+" at "+(0,o.shortStack)(e?.stack,n).join("; ")}},41954:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const n=i(40958),r=i(26905),s=i(55835),a=i(54993),o=i(81168);t.describeError=function(e){const t=(0,o.stripSuffix)((0,a.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,s.map)((0,r.errorErrno)(i),(e=>t.push(u.get(e)))),(0,s.map)((0,r.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,n.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const n=i(40958),r=i(76790),s=i(50989),a=i(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,r.sortBy)((0,n.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(a.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const n=i(40958),r=i(38639),s=i(26905),a=i(54993),o=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,a.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,a.toS)(e)+(0,n.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,o.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,r.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,r.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,r.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},51837:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalError=void 0;const n=i(38835);class r extends Error{constructor(e){super(e+n.InternalErrorFlag)}}t.InternalError=r},8769:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const n=i(22573),r=i(31586),s=i(68708),a=i(7282),o=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,n.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const r=!0===i.fatal,c=!0===i.ignorable;if(!r&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),r&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!r||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!r||(0,a.isTest)()||(0,o.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),r}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,r.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,o.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,r.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,r.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const n=i(40958),r=i(22573),s=i(38639),a=i(26905),o=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,r.blank)(i.message)||e.message.includes(i.message)))return e;const n=(0,r.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(n??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,n.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,a.errorName)(t)??(0,d.first)(this.causes,a.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(a.errorCode)],a.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,a.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,r.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,r.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const n=t?.path;return(0,r.blank)(n)||(i=(0,h.dedupeNeedle)(i,n,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,o.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const a=i(49769),o=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,n.set(this,new Map),r.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,a.getOrSet)(s(this,n,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,o.map)(s(this,r,"f").get(e),clearTimeout),s(this,r,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),a=s(this,n,"f").get(e);return null!=a&&(a.resolve(t),s(this,n,"f").delete(e)),i}emitDebounced(e,...t){(0,o.map)(s(this,r,"f").get(e),clearTimeout),s(this,r,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},n=new WeakMap,r=new WeakMap},34102:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const n=i(78474),r=i(19851),s=i(15197);t.ee=(0,r.lazy)((()=>{const e=new n.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const r=n(i(73024)),s=n(i(1708)),a=i(19851),o=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,a.lazy)((()=>s.default.geteuid?.())),h=(0,a.lazy)((()=>s.default.getgroups?.()));function f(e,t){try{return!(0,o.blank)(e)&&(r.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,r.default.constants.R_OK|r.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,r.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:n=!1,processUid:r,processGid:s}){if(null==e)return!1;const a=r??d(),o=null!=s?[s]:h()??[],l=0===a,u=l||e.uid===a,f=l||o.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!n||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const n=await(0,u.statMaybe)(i);if(null!=n){if(!n.isDirectory())return!1;if(t){if(!p(n,e))return!1}else if(t=!0,!m(n,e))return!1}}return!0},t.access=g},21144:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const r=n(i(76760)),s=i(19851),a=i(81168),o=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),n=await m(i.dir);for(const e of await(0,d.readdir_)(n))if((0,a.equalsIgnoreCase)(e.basename,i.base))return r.default.join(n,e.basename);throw new o.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const n=i(73024),r=i(76760);function s(e){return[...a(e)]}function*a(e){for(;e!==(0,r.dirname)(e);)e=(0,r.dirname)(e),yield e}function o(e){try{return(0,n.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=o(e);return t.every((e=>i.includes(e)))}t.ancestors=s,t.ancestorG=a,t.selfAndAncestorG=function*(e){yield e,yield*a(e)},t.childrenSync=o,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,i){var n,r,s,a,o,l=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),v=f(i(1708)),w=i(46466),S=f(i(57975)),b=f(i(38522)),P=i(19851),M=i(40958),_=i(5233),E=i(22573),x=i(42659),T=i(50357),D=i(96249),k=i(98553),C=i(55835),F=i(31586),O=i(68708),I=i(97790),L=i(39926),A=i(51926),R=i(59455),N=i(54993),B=i(48884),z=i(22911),j=i(99331),V=i(56519),W=i(56038),H=i(31562),U=i(76850),q=i(70025),G=i(34102),$=i(80875),J=i(50213),K=i(70417),Z=i(43334),X=i(81168),Y=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),ne=i(84542),re=i(89968),se=i(20197),ae=i(88561),oe=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),ve=i(27794),we=i(73428),Se=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new ae.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(n.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),r.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),a.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(r=new WeakMap,a=new WeakMap,n=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,M.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,B.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,E.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const n=be().get(i);if(null!=n)return n;const r=(0,fe.resolve)(i),s=new Pe(r,t);return be().set(i,s),be().set(r,s),s}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(re.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(re.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,r,"f").unset(),h(this,a,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,X.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new re.DirectoryEntry(this.dir,new re.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,C.map)(this.statSync(),(e=>new re.DirectoryEntry(this.dir,new re.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,r,"f").call(this);if(null==t||null==e||(0,M.isEmpty)(t))return t;const i=[];for(const n of t)!0===await e(n)&&i.push(n);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,n,"m",s).call(this)??await d(e=this.clearThisAndParent(),n,"m",s).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,M.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,M.isNotEmpty)(e)?(0,M.includesAll)(t,e):(0,M.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,M.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const n of i)t.push(...(0,R.toA)(await n.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,F.gt0)(t))return;const i=await d(this,r,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const n of i)if(n.isDirectory()){const i=await this._directoryEntryChild(n).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Z.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,M.isEmpty)(e)||(0,T.eql)(["."],e)||e.every(E.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,C.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,L.pad2)(t+1),(0,L.pad2)(i))))}child(...e){if((0,M.isEmpty)(e))return this;const t=(0,D.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,x.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),B.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Z.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,M.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,x.unixtime)(t)>=(0,x.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,x.unixtime)(t)>(0,x.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,C.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,H.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*x.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,oe.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,oe.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,$.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,$.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,U.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),ne.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces),(0,O.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,_.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,j.ending)()?1:3,timeoutMs:0,retryDelay:x.secondMs,errorIsRetriable:q.isRetriableError})}async gunzip(){return d(this,n,"m",o).call(this,(0,X.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,n,"m",o).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,n,"m",o).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,M.isEmpty)(i))return;const n=await e.sha();if(null!=n)for(const e of i.sort(((e,t)=>-(0,Y.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===n)return e}))}firstMatchingLine(e){const t=new z.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,A.newlineRe)(),(n=>{const r=e.exec(n);null!=r&&(t.maybeResolve(r),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const n of e)for(const e of i)if((0,F.closeTo)(n,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new z.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),Me)try{const n=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(n,r)=>{try{const s=await e.f(n,(0,C.denull)(r));t(s)&&i.resolve(s)}catch(e){i.reject(e)}}));i.finally((()=>{n.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,F.gt0)(e.intervalMs)){const n=setInterval((async()=>{try{const n=await e.f();t(n)&&i.resolve(n)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||n.unref(),i.finally((()=>{clearInterval(n)}))}return i}}t.BaseFile=Pe,s=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,X.equalsIgnoreCase)(e.basename,this.base))),t=(0,B.leastBy)(e,(e=>(0,Y.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,C.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},o=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*x.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let Me=!0;t.useFsWatch=function(e){Me=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},19748:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const n=i(28874),r=i(88840),s=i(14036),a=i(29882);function o(e){return t=>n.Settings.respectFileExtensions.valueOrDefault?(0,s.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,a.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=o,t.isBrowserExtension=o(r.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=o(r.ExtTypes.Video),t.isAssetFileExtension=o(r.ExtTypes.AssetFile)},84542:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const n=i(40958),r=i(96249),s=i(51926),a=i(54993),o=i(43334);function l(...e){return(0,r.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,a.toS)(e).split((0,s.newlineRe)()))))}t.Newline=o.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(a.toS).join("\n");return o.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,n.compactBlanks)(l(...e))}},70698:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const n=i(76760),r=i(19851),s=i(50213),a=i(37805),o=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,r.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,n.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,o.mkdirp_)(i),await(0,d.writeTextfile_)((0,o.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+a.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const r=n(i(76760)),s=n(i(1708)),a=i(19851),o=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,a.lazy)((()=>[...(0,o.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,r.default.join(e,"System32"),r.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const o=s(i(44652)),l=a(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),v=i(14427),w=i(17217),S=i(16287),b=i(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const M=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class _{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new _(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:n}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},r=await o.stat(t);return new _(i,new P(n,r))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return _.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new _(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void M().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>_.fromSimpleDirent(this.nativePath,e)))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new _(this.nativePath,new P(e.name,e))))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await o.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await o.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=_},20197:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const r=n(i(76760)),s=i(39926),a=i(29882),o=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},n=(0,a.parseNativePath)(i.nativePath);if(await(0,a.mkdirp_)(n.dir),!i.requireNumber&&await(0,o.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=r.default.join(n.dir,`${n.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${n.ext}`);if(await(0,o.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},n=(0,a.parseNativePath)(i.nativePath);if((0,a.mkdirpSync_)(n.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=r.default.join(n.dir,`${n.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${n.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},92423:function(e,t,i){var n,r,s,a=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notInHiddenPhotoStructureDir=t.whyExcludedDirectoryRecursive=t.notExcludedDirs=t.isExcludedDirectory=t.whyExcludedDirectory=t.notExcludedDirPredicates=t.isExcludedFile=t.whyExcludedFile=t.notExcludedFilePredicates=t.excludeBundles=t.excludeGlobs=t.defaultFilePredicates=t.defaultDirPredicates=t.formatPathForGlob=void 0;const l=o(i(83058)),u=i(19851),c=i(40958),d=i(76790),h=i(22573),f=i(55835),m=i(51926),p=i(54993),g=i(48884),y=i(9092),v=i(54557),w=i(50213),S=i(88158),b=i(56519),P=i(46292),M=i(32551),_=i(35280),E=i(87290),x=i(96706),T=i(57902),D=i(43334),k=i(78984),C=i(33995),F=i(28874),O=i(21144),I=i(83278),L=i(48313),A=i(85772),R=i(78133),N=i(46356),B=i(17217),z=(0,u.lazy)((()=>(0,w.mkLogger)("fs.ExcludeGlobs"))),j=new v.FifoCache(256),V=/[\\/]$/;function W(e){const t=(0,p.toS)(e),i=j.get(t);if(null!=i)return i;const n=(0,B.isSimpleFile)(e)?e:I.BaseFile.for(e),r=V.test(t)||n.isDirectorySync(),s=(0,R.native2posix)(n.nativePath),a=r?(0,m.ensureSuffix)(s,"/"):s;return j.set(t,a),j.set(a,a),j.set(n.nativePath,a),a}t.formatPathForGlob=W;class H{constructor(e,t,i=!0){if(n.add(this),this.pattern=e,this.desc=t,this.exclude=i,e.includes("\\")){const t=e;e=(0,R.native2posix)(t),z().warn("globToPredicate(): backslash in patterns aren't supported: assuming you meant forward-slash?",{given:t,input:e})}this.reason=(0,c.compactBlanks)([this.exclude?"not":"",t,"("+(0,m.ellipsize)(e,48,12)+")"]).join(" ");try{this.re=l.default.makeRe(this.pattern,{nocase:F.Settings.globsCaseInsensitive.valueOrDefault,dot:!0,posixSlashes:!0}),this.valid=!0}catch(e){this.valid=!1,z().warn("Cannot parse pattern",{glob:this.pattern,error:e})}this.bundle=this.valid&&null!=this.re?(0,S.pairToObject)(this.reason,a(this,n,"m",r).bind(this)):{}}}n=new WeakSet,r=function(e){const t=W(e),i=this.re.test(t)??this.exclude;return z().tap({msg:"apply()",level:i?T.LogLevels.debug:T.LogLevels.trace,result:i?!this.exclude:this.exclude,meta:{desc:this.desc,pattern:this.pattern,exclude:this.exclude,posixPath:t,matched:i}})};class U{constructor(){s.set(this,[])}push(...e){for(const t of e){if(!t.valid){z().warn("Ignoring invalid glob",{glob:t});continue}const e=a(this,s,"f").find((e=>e.pattern===t.pattern));null==e?a(this,s,"f").push(t):z().debug("Ignoring duplicate glob",{glob:t,prior:e})}}pushNativePath(e,t){this.push(new H((0,R.native2posix)(e),t))}toA(){return a(this,s,"f")}}s=new WeakMap;const q=new H("**/.*","hidden file"),G=new H("**/.*/","hidden directory"),$=(0,u.lazy)((()=>{const e=new U;e.push(G,q);for(const t of[{s:"bin",desc:"command binary"},{s:"dev",desc:"device file"},{s:"etc",desc:"system configuration file"},{s:"initrd",desc:"initial ramdisk"},{s:"proc",desc:"process metadata"},{s:"sbin",desc:"system binary"},{s:"snap",desc:"snap software"},{s:"sys",desc:"system metadata"},{s:"Dell",desc:"Windows driver"},{s:"Drivers",desc:"Windows driver"},{s:"Intel",desc:"Windows driver"},{s:"Microsoft",desc:"Windows driver"},{s:"NVIDIA",desc:"Windows driver"},{s:"Windows.old",desc:"Windows system"},{s:"Windows",desc:"Windows system"}])e.push(new H((D.isWin?"*":"")+"/"+t.s+"/",t.desc));if(D.isWin)for(const t of["ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemRoot","windir"]){const i=(0,x.getEnv)(t);(0,h.blank)(i)||e.pushNativePath(i,`%${t}%`)}D.isLinux&&e.push(new H(`${(0,M.homeDir)()}/snap/`,"Snap software"));for(const t of[{s:"__MACOSX",desc:"macOS resource fork"},{s:"_includes",desc:"code"},{s:"@eaDir",desc:"Synology thumbnail"},{s:"@Recently-Snapshot",desc:"QNAP snapshot"},{s:"@Recycle",desc:"QNAP trash"},{s:"@SynoResource",desc:"Synology metadata"},{s:"#recycle",desc:"Synology trash"},{s:"#snapshot",desc:"Synology snapshot"},{s:"$Recycle.Bin",desc:"Windows trash"},{s:"$SysReset",desc:"Windows"},{s:"3rdParty",desc:"code"},{s:"Application Data",desc:"Windows apps"},{s:"Application Support",desc:"macOS apps"},{s:"Applications",desc:"macOS apps"},{s:"arangodb",desc:"3rd party"},{s:"cache",desc:"Cache directory"},{s:"CacheClip",desc:"Movie cache directory"},{s:"caches",desc:"Cache directory"},{s:"Chipset_Software",desc:"Windows apps"},{s:"cmake",desc:"code"},{s:"com.apple.TimeMachine.localsnapshots",desc:"macOS"},{s:"cpan",desc:"code"},{s:"DefinitelyTyped",desc:"TypeScript type"},{s:"Desktop DB",desc:"macOS metadata"},{s:"Desktop DF",desc:"macOS metadata"},{s:"Desktop.ini",desc:"macOS metadata"},{s:"DisplayDriver",desc:"Windows driver"},{s:"DLLs",desc:"Windows library"},{s:"dyld",desc:"macOS library"},{s:"ehthumbs.db",desc:"Windows thumbnail"},{s:"i18n",desc:"i18n code"},{s:"iMovie Cache",desc:"Apple iMovie cache"},{s:"iTunes Cache",desc:"Apple iTunes"},{s:"iTunes Media",desc:"Apple iTunes"},{s:"iTunes",desc:"Apple iTunes"},{s:"lib?(32|64|x64|s)",desc:"program library directory"},{s:"lost+found",desc:"fsck recovered directory"},{s:"macOS Install*",desc:"macOS installer"},{s:"Network Trash",desc:"AFP trash"},{s:"node_modules",desc:"Node.js library"},{s:"pkgconfig",desc:"code"},{s:"pkgs",desc:"Python code"},{s:"Program Files (x86)",desc:"Windows apps"},{s:"Program Files",desc:"Windows apps"},{s:"ProgramData",desc:"Windows application support"},{s:"resources/media/face",desc:"face thumbnail"},{s:"rubygems-*",desc:"Ruby code"},{s:"site-packages",desc:"Python code"},{s:"spotifycache",desc:"Spotify cache"},{s:"SteamApps",desc:"Game files"},{s:"System Volume Information",desc:"Windows system metadata"},{s:"System32",desc:"Windows system"},{s:"SystemTemp",desc:"Windows temporary"},{s:"temp",desc:"temporary"},{s:"Temporary Items",desc:"temporary"},{s:"test_suite",desc:"code"},{s:"testutil?(s)",desc:"code"},{s:"third_party",desc:"code"},{s:"Thumbnail?(s)",desc:"thumbnail"},{s:"Thumbs.db",desc:"Windows thumbnail"},{s:"tmp",desc:"temporary"},{s:"Trash",desc:"trash directory"},{s:"Windows",desc:"Windows"},{s:"Windows.old",desc:"Windows"},{s:"Windows10Upgrade",desc:"Windows upgrade"},{s:"Xcode.app",desc:"macOS code"},{s:"*.sparsebundle/bands",desc:"Time Machine backup"},{s:"ImageMagick*",desc:"ImageMagick source"},{s:"Install OS X*",desc:"macOS installer"},{s:"Install macOS*",desc:"macOS installer"},{s:"*.lrdata",desc:"LightRoom data"},{s:"MinGW*",desc:"code"},{s:"msys*",desc:"code"},{s:"vcpkg",desc:"code"}])e.push(new H("**/"+t.s+"/",t.desc));function t(t,i,n){if(!(0,h.blank)(t)){const r=(0,d.sort)((0,c.uniq)((0,c.compactBlanks)(i).map((e=>e.toLowerCase()))));1===r.length&&e.push(new H(`**/${t}/${r[0]}/`,n)),r.length>1&&e.push(new H(`**/${t}/(${r.join("|")})/`,n))}}(0,f.map)((0,P.configDir)(),(t=>e.pushNativePath(t,"PhotoStructure configuration"))),t("nix",["store"],"NixOS package"),e.push(new H("**/*.(photo|photos|ap)library/!(master|masters|modified|original|originals)/","Apple Photos/Aperture library")),e.push(new H("**/facetile*","face thumbnail"));const i=["bin","cygdrive","dev","etc","games","include","lib?(32|64|x64)","local","locale","man","proc","sbin","share","src","tmp","usr","var"];t("usr",i,"FHS system"),t("cygwin?(64)",i,"Cygwin"),t("local",i,"FHS system"),t("Windows",["assembly","Boot","Containers","Cursors","Fonts","Help","Installer","Logs","Microsoft.NET","Servicing","SoftwareDistribution","System32","SystemApps","SysWOW64","Temp","WinSxS"],"Windows"),t("Recovery",["Customizations","OEM"],"Windows"),t("lib",["firmware","modules","systemd","udev","x86_64-linux-gnu"],"Linux system package"),t("opt",["google","x11",...i],"FHS package"),t("lfs",["incomplete","objects"],"Git LFS object");const n=["cache","crash","games","lib","local","lock","log","logs","mail","run","snap","spool","tmp"];t("var",n,"Linux /var"),t("mnt",n,"Linux /mnt"),t("dev",["block","bsg","bus","char","cpu","disk","dri","fd","hugepages","input","lightnvm","mapper","mqueue","net","pts","shm","snd","ubuntu-vg","usb","vfio"],"Linux /dev backup"),t("proc",["acpi","asound","bus","driver","fs","ipmi","irq","net","scsi","self","sys","sysvipc","thread-self","tty"],"Linux /proc backup"),t("library",["Apple","Assistant","Bluetooth","com.apple.iTunesCloud","Containers","CoreAnalytics","Developer","Desktop Pictures","Documentation","Extensions","Finance","Fonts","Frameworks","FrontBoard","Group Containers","HTTPStorages","iTunes","KeyboardServices","Keychains","Logs","Messages","News","Passes","Photos","Preferences","Ruby","Saved Application State","Scripts","User Pictures","Updates","User Template","WebKit","WebServer"],"macOS Library"),t("packages",["*.pkg","*.mpkg"],"macOS package"),t("src/**",["bin","ci","dist","doc?(s)","etc","lib?(s)","main","spec?(s)","src","test?(s)","tools","util"],"code"),t("docs",["admin","content","general","generated","sql"],"code"),t("pkg",["acceptance","ccl","cli","cmd","server","sql","storage","ui","util","workload"],"code"),t("osv",["apps","arch","compiler","external","include","java","modules","musl","tests"],"code"),t("go",["bin","blog","cmd","doc","lib","misc","pkg","src","test","vt"],"code"),t("Perl?(64)",["bin","eg","etc","html","lib","site"],"code"),t("Python*",["dlls","doc?(s)","include","lib?(s)","scripts","tools","tcl"],"code"),t("Ruby*",["bin","include","lib","msys*","packages","share","ssl"],"code"),t("msys*",["clang*","dev","etc","mingw*","tmp","ucrt*","var"],"code"),t("sdk",["build-tools","emulator","extras","patcher","platforms","platform-tools","sources","tools"],"code"),t("test",["fixtures"],"code"),t("data",["$of"],"windows backup"),t("System",["Applications","Developer","DriverKit","Library","iOSSupport"],"macOS System"),t("contents",["frameworks","plugins","resources","sharedsupport"],"macOS application"),t("pg",["pgsql"],"code");for(const e of["local","locallow","roaming"])t("appdata",[e],"Windows default AppData");return t("ps",["cache","config","logs","tmp"],"PhotoStructure docker directory"),e.toA()})),J=()=>{t.excludeGlobs.unset(),t.excludeBundles.unset()},K=()=>{t.notExcludedDirs.unset()},Z=(0,u.lazy)((()=>{F.Settings.excludeGlobsOmitDefaults.watchLater(J),F.Settings.excludeGlobsAdd.watchLater(J),F.Settings.excludeGlobsOmit.watchLater(J),F.Settings.globsCaseInsensitive.watchLater(J),F.Settings.libraryDir.watchLater(K),F.Settings.originalsDir.watchLater(K),F.Settings.scanPaths.watchLater(K),F.Settings.argvScanPaths.watchLater(K)}));t.defaultDirPredicates=(0,u.lazy)((()=>[{notSymlinkLoop:ne,notInHiddenPhotoStructureDir:se,whyNoMedia:A.whyNoMedia,notHidden:re}])),t.defaultFilePredicates=(0,u.lazy)((()=>[{notInHiddenPhotoStructureDir:se}])),t.excludeGlobs=(0,u.lazy)((()=>{Z();const e=new y.CaseInsensitiveMap;function t(t){if(null!=t&&t.valid){const i=t.pattern.trim();e.has(i)&&z().warn("Duplicate glob:",{glob:t}),e.set(i,t)}}function i(t){const i=t.trim();e.has(i)?e.delete(i):z().warn("Failed to find and remove glob specified in PS_EXCLUDE_GLOBS_OMIT",{glob:t})}if(!F.Settings.excludeGlobsOmitDefaults.valueOrDefault)for(const e of $())t(e);for(const e of F.Settings.excludeGlobsOmit.values)i(e);for(const e of F.Settings.excludeGlobsAdd.values)t(new H(e,"(from PS_EXCLUDED_GLOBS_ADD)"));const n=(0,d.sortBy)(e.values(),(e=>(0,c.compactBlanks)(e.pattern.toLowerCase().split("/")))),[r,s]=(0,g.partition)(n,(e=>e.pattern.endsWith("/")));return{dir:r,file:s}})),t.excludeBundles=(0,u.lazy)((()=>{const e=(0,t.excludeGlobs)();return{dir:[...(0,t.defaultDirPredicates)(),...e.dir.map((e=>e.bundle))],file:[...(0,t.defaultFilePredicates)(),...e.file.map((e=>e.bundle))]}}));const X=[{disableAllFilters:()=>!0}],Y=[{notBlank:()=>!1}];function Q(e){return F.Settings.disableAllFilters.valueOrDefault?X:(0,h.blank)(e)?Y:(0,t.excludeBundles)().file}function ee(e){return C.SyncPredicates.whyRejected(e,...Q(e))}function te(e){return F.Settings.disableAllFilters.valueOrDefault?X:(0,h.blank)(e)?Y:(0,t.excludeBundles)().dir}async function ie(e){return F.Settings.disableAllFilters.valueOrDefault?void 0:k.Predicates.whyRejected(e,...te(e))}function ne(e){return!(0,N.seemsLikeSymlinkLoop)(e)}function re(e){return(0,b.thenNot)((0,L.isHidden)(e))}function se(e){return!(0,_.inHiddenPhotoStructureDir)(e)}t.notExcludedFilePredicates=Q,t.whyExcludedFile=ee,t.isExcludedFile=function(e){return null!=ee(e)},t.notExcludedDirPredicates=te,t.whyExcludedDirectory=ie,t.isExcludedDirectory=async function(e){return null!=await ie(e)},t.notExcludedDirs=(0,u.lazy)((async()=>{const e=(0,c.uniq)((0,c.compactBlanks)([(0,E.libraryDirPosixFile)(),(0,E.libraryOriginalsDirPosixFile)(),...F.Settings.argvScanPaths.values,...F.Settings.scanPaths.values]));return z().tap({msg:"notExcludedDirs() (these directories will never be excluded)",level:"info",result:(0,c.uniq)([...e,...await Promise.all(e.map((e=>(0,O.actualPath)(e))))])})})),t.whyExcludedDirectoryRecursive=async function(e){const i=await(0,t.notExcludedDirs)();for(let t=e;null!=t&&!t.isRoot;t=await(t?.parent())){if(i.includes(t?.nativePath))return;const e=await ie(t);if(null!=e)return e}},t.notInHiddenPhotoStructureDir=se},88561:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const a=i(40958),o=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),n.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>s(this,n,"m",r).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,a.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,n=new WeakSet,r=async function(e){if((0,o.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const n=i(73024),r=i(22573),s=i(45599),a=i(96249),o=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,s.defer)((()=>{const e={};for(const[t,...i]of d)for(const n of i)e[n]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof n.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,r.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,a.flatten)((0,o.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const n=i(68708),r=i(17217),s=i(16287),a=i(68284);async function o(e){return(0,n.pick)(await(0,s.stat_)((0,r.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=o,t.fileStats=async function(e){try{return await o(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,a.statSync)((0,r.toNativePath)(e)))?void 0:(0,n.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const n=i(68817),r=i(19851),s=i(22573),a=i(50213),o=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),h=i(95696),f=i(93854),m=i(16287),p=(0,r.lazy)((()=>(0,a.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,f.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,n.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const r=(0,s.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),a=(0,l.normalizeExt)(h.PosixFile.for(e))??(0,c.mimetypeExt)(r);return(0,s.blank)(r)||(0,s.blank)(a)?void 0:{ext:a,mime:r}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new o.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){var n,r,s,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),n.add(this),this.nativePath=e,r.set(this,[]),s.set(this,void 0),a.set(this,void 0),l(this,a,(0,f.fileStatsSync)(e),"f"),l(this,s,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,n,"m",o).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,r,"f").push(e)}close(){u(this,s,"f").close()}}t.FileWatcher=m,r=new WeakMap,s=new WeakMap,a=new WeakMap,n=new WeakSet,o=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,a,"f"),t)){l(this,a,t,"f");for(const t of u(this,r,"f"))t(e,this.nativePath)}}},73209:function(e,t,i){var n,r,s,a,o,l,u,c,d,h,f,m,p,g,y,v,w,S=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},b=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const M=i(58587),_=P(i(44652)),E=i(87997),x=i(40958),T=i(17586),D=i(42659),k=i(50357),C=i(75240),F=i(55835),O=i(31586),I=i(30976),L=i(13538),A=i(54993),R=i(7282),N=i(68852),B=i(23560),z=i(25764),j=i(38836),V=i(99331),W=i(22781),H=i(38835),U=i(55222),q=i(63870),G=i(69734),$=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)(G.PsLockExt)+"$");class K extends j.EndableWrapper{static newUid(e=process.pid){return b(this,r,Math.max(Date.now(),S(this,r,"f",s)+1),"f",s),(0,x.compactBlanks)([U.TokenRadix.encode(S(this,r,"f",s)),B.serviceName.prior(),(0,A.toS)(e)]).join("-")}static pidFromLockfile(e){return r.pidFromBasename((0,$.basename)(e))}static pidFromBasename(e){return(0,O.toInt)(J.exec((0,A.toS)(e))?.groups?.pid)}static for(e){return S(this,r,"f",o).find((t=>t.opts.file===e.file))??new r(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>S(this,n,"m",w).call(this)),e.endableRank??z.EndableRanks.postdb,(0,q.commandTimeoutMs)()),n.add(this),this.opts=e,l.set(this,b(t=r,r,(i=S(t,r,"f",a),++i),"f",a)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(S(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,G.fsLockFileBasename)(r.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await S(this,n,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,G.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+S(this,l,"f")),this.staleMs=(0,O.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),S(r,r,"f",o).push(this)}get acquired(){return S(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await S(this,n,"m",f).call(this,e)??S(this,n,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,T.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,k.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==S(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:D.secondMs);b(this,c,setInterval((()=>S(this,n,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=S(this,c,"f")&&(clearInterval(S(this,c,"f")),b(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(S(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),b(this,u,!1,"f"),(0,F.map)(S(this,d,"f"),(e=>(0,E.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?S(this,n,"m",v).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),b(this,d,setTimeout((()=>S(this,n,"m",v).call(this)),(0,O.toGt0)(this.staleMs)??D.secondMs),"f"),S(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(S(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,L.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,r=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,n=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,O.gt0)(this.staleMs)&&Date.now()>S(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await S(this,n,"m",m).call(this),meta:{why:t}})},m=async function(){b(this,h,Date.now(),"f");const e=[],t=await S(this,n,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,O.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+D.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,G.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;r.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+H.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const s=i[0]===this.lockfile.base;if(s)b(this,u,!0,"f");else if(!0!==t?.vacuum){const t=r.pidFromBasename(i[0]);if((0,O.gt0)(t)&&!(0,M.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),S(this,n,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:s,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await S(this,n,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},v=async function(){await S(this,n,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},w=function(){(0,x.filterInPlace)(S(r,r,"f",o),(e=>S(e,l,"f")!==S(this,l,"f")))},s={value:0},K.internalErrors=0,a={value:0},o={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const n=i(22573),r=i(51926),s=i(54993),a=i(17217);function o(e){return(0,n.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,r.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,r.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,n.blank)((0,s.toS)(e)))return;const i=(0,a.basename)(e);return o(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,n.blank)(e)&&o((0,a.basename)(e))}},4001:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const n=i(22573),r=i(55835),s=i(31586),a=i(51926),o=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,n.toNotBlank)(e.name)??(0,o.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let n=e;for(const e of i.aggressive?d:c){const t=n.match(e);if((0,s.gt0)(t?.index)){const e=n.slice(0,t.index).trim();e.length>0&&(n=e)}}return e===n?e:f(n,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,n.blank)(i))return e;const r=(0,u.parsePosixPath)(i),s=h(r,{aggressive:!1});return[...t,s+r.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,a.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),n=(0,a.stripPrefix)(t.toLowerCase().normalize(),i);return(0,r.map)((0,l.extractInt)(n),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,a.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,r.map)(m.exec(t),(e=>t=e[1].trim())),(0,r.map)(g.exec(t),(e=>t=e[1].trim())),t}},14977:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const r=n(i(44652)),s=n(i(73024)),a=i(46466),o=n(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,a.pipeline)(s.default.createReadStream(e,{autoClose:!0}),o.default.createGzip(),s.default.createWriteStream(t,{autoClose:!0})),await r.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const r=n(i(77598)),s=n(i(73024)),a=i(46466),o=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),v=i(16287),w=(0,o.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),S=(0,o.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:i=!0}={}){const n=(0,y.toNativePath_)(e);if(i){const t=S().get(n);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:n,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:n,prior:t}),S().delete(n)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await M(s.default.createReadStream(i)),stats:(0,u.pick)(await(0,v.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function M(e,t=[],i="sha512"){const n=r.default.createHash(i);return await(0,a.pipeline)([e,...t,n]),n.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=M,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return r.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const n=i(19851),r=i(42659),s=i(55835),a=i(31586),o=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,o.stdout_)("chflags",["hidden",t],{timeoutMs:10*r.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,n.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,s.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,o.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*r.secondMs}),i=(0,a.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const n=i(22573),r=i(54993),s=i(7282),a=i(43334),o=i(69375),l=/^\/dev(?:\/|$)/i,u=a.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=a.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=a.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=a.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,r.toS)(e))}function m(e){return(0,n.blank)(e)?"blank":(0,o.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},33456:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const n=i(57075),r=i(51926),s=i(54993);class a extends n.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const n=(this._prior+(0,s.toS)(e)).split((0,r.newlineRe)()),a=n.pop();this._prior=a??"";let o=!1;for(const e of n)o||(o=!this.push(e));o?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=a},64680:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const r=n(i(76760)),s=i(17217),a=i(73428);t.mkNoMedia_=function(e){return(0,a.writeTextfile_)(r.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},85772:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const a=s(i(76760)),o=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),v=i(83278),w=i(70698),S=i(88561),b=i(65238),P=i(16287),M=(0,o.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),_="NoMedia",E=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(a.default.sep),"/"]).join("")+"])\\.?"+_+"$","im"),x=Object.freeze(["."+_,_]),T=Object.freeze((0,u.flatten)(x.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function D(e){return null!=E.exec(e)}t.isNoMediaName=D;const k=(0,o.lazy)((()=>new S.FileCache({name:"fs.noMediaDirsCache"})));async function C(e,t){if(null==e)return null;const i=v.BaseFile.for(e),n=await i.stat();if(null==n||!n.isFile()&&!n.isDirectory())return null;if(n.isFile())return D(i.base)||await(0,w.isCachedirTagFile)(i)?k().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):C(i.parent());{const e=await k().getOrSetAsync(i.nativePath,(()=>F(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:C(i.parent())}}async function F(e){if(D(e.base))return k().set(e.parent().nativePath,e.nativePath),M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,b.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,n=await Promise.race([O(e.nativePath,i),(0,b.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=n?n:await(0,w.isCachedirTagDirectory)(e)?M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(w.CACHEDIR_TAG).nativePath)}):null}async function O(e,t){for(const i of g.isCaseSensitiveFs?T:x){if(!0===t?.aborted)return null;const n=a.default.join(e,i);if(await(0,P.exists)(n,p.LogLevels.trace))return M().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(n)})}return null}async function I(e,t,i){for(const n of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(D(n.basename))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,a.join)(e,n.basename))});if(n.basename===w.CACHEDIR_TAG){const t=(0,a.join)(e,n.basename);if(await(0,w.isCachedirTagFile)(t))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await C(e,t)},t.whyNoMedia=C,t.whyNoMediaDir=F,t._dirHasNoMediaChild=O},29882:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const r=n(i(44652)),s=n(i(76760)),a=i(19851),o=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),v=i(78133),w=i(53265),S=i(17217),b=i(16287),P=i(66430),M=i(5545);function _(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,a.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=_,t.containsHiddenPathname=function(e){return C(e).some(_)},t.isNotHiddenPosixPath=function(e){return C(e).every((e=>!_(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return x((0,v.posix2native)(e))},t.extname=function(e){return x(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const E=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function x(e){const t=E.exec(e)?.groups,i=t?.ext2??"",n=s.default.parse(t?.path??e);return{...n,ext:(n.ext??"")+i,base:(n.base??"")+i}}function T(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,s.default.sep)}function D(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),i=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const n=e.acceptSelf??!1;return t===i?n:i.startsWith((0,p.ensureSuffix)(t,s.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function k(e,t,i){if(null==t||null==i)return!1;const n=e(t),r=e(i);return null!=n&&null!=r&&(y.isLinux?n===r:(0,p.equalsIgnoreCase)(n,r))}function C(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function F(e){return(0,u.notBlank)(e)&&C(e).length===(y.isWin?1:0)}function O({p:e,maxLength:t}){const i=(0,S.toNativePath_)(e);if(i.length<=t)return i;const n=C(e),r=[],s=[n.pop()];for(;n.length>0;)if(r.length=t){n.unshift(r.pop());break}}else if(s.unshift(n.pop()),L([...r,...s]).length>=t){n.push(s.shift());break}return n.length>0&&r.push("…"),L([...r,...s])}function I(e){return e.startsWith("\\\\")}function L(e){return(0,h.ensurePrefix)((0,o.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=x,t.parentBasename=T,t.grandParentBasename=function(e){return T(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=D,t.eqlBasename=function(e,t){return k(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return k(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return k(S.toNativePath_,e,t)},t.toPathnames=C,t.pathIsRoot=F,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:C(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,S.toNativePath_)(e),n=(0,S.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(n))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===n?"":(0,p.stripPrefix)((0,v.native2posix)(n).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=O,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:n=e.length}){const r=[];for(const n of e.slice(0,i))r.push(O({p:n,maxLength:t}));return r.join(", ")+(n>i?`, and ${n-i} more…`:"")},t.posixPathFromParent=function(e){return C(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return C(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=x(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(M.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(F(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await r.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;r.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>r.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=L,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:L(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>D({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const r=n(i(76760)),s=i(19851),a=i(40958),o=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),v=i(64660),w=i(21144),S=i(16287),b=(0,s.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function M(e,t=P){const i=await(0,S.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,v.isStatRX)(i,e)}function _(){if(y.isWin){const e=(0,o.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,o.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,o.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,r.default.join(e,"System32"),r.default.join(e,"System32","Wbem"),r.default.join(i,"chocolatey","bin"),r.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function E(){const e=(0,h.toS)((0,m.env)().PATH).split(r.default.delimiter);return(0,a.uniq)((0,a.compactBlanks)([...e,..._()]))}t.isRXFile=M,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const n=(0,a.uniq)((0,a.compactBlanks)([...E(),...(0,d.toA)(i)]));for(const i of(0,a.uniq)((0,a.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of n){const i=r.default.join(t,e);if(await M(i))return y.isLinux?i:(0,w.actualPath)(i)}}b().warn("Failed to find tool",{tool:e,dirs:n})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){var n,r,s,a=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return o(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),v=i(76790),w=i(5233),S=i(22573),b=i(42659),P=i(26905),M=i(75240),_=i(55835),E=i(31586),x=i(68708),T=i(13538),D=i(89937),k=i(12168),C=i(54993),F=i(48884),O=i(50213),I=i(45255),L=i(81168),A=i(56519),R=i(56038),N=i(31562),B=i(84777),z=i(9595),j=i(38835),V=i(70025),W=i(57902),H=i(55222),U=i(43334),q=i(33847),G=i(24399),$=i(28874),J=i(79915),K=i(45200),Z=i(34238),X=i(87001),Y=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),ne=i(32144),re=i(73209),se=i(48313),ae=i(29882),oe=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,F.contextFilter)(function(e){return(0,v.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),n.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,O.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Z.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,A.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>H.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,A.thenMapOr)((0,Y.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>U.isMac?(0,B.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,S.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,S.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,L.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,oe.toNativePath_)(e),n=new fe(i,t);return(0,L.isString)(e)&&he().set(e,n),he().set(i,n),n}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,A.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,ae.containedByNativePath)({ancestor:(0,z.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,ae.containedByNativePath)({ancestor:(0,z.originalsDir)(),descendant:this,acceptSelf:!0}))return U.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,_.map)((0,ee.bestMountpoint)(this.nativePath,await(0,Y.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,_.map)((0,S.notBlankOr)(e,(()=>this.uri_())),Z.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,C.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===D.PS_LIBRARY_SCHEME?1:t.scheme===D.PS_LOCAL_FILE_SCHEME?2:t.scheme===D.PS_NETWORK_FILESYSTEM_SCHEME?3:1,n=(0,L.countChars)(t.path,"/")-i;return this.isDeleted(n)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(U.isWin||U.isMac)return this.trap("hide",(async()=>(await(0,se.hide_)(this),this)))}async hidden(){return(0,se.isHidden)(this)}isSidecar(){return(0,ne.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,ne.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,L.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,ne.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,F.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,_.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,x.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:n=!1,timeoutMs:r,skipWip:s=!1,skipFsLock:a=!1,retries:o=2,dirty:l=!1}){return(0,w.retryOnReject_)((async()=>{const o=await this.clear().isNonEmptyFile(i);if(!o){if(s&&a)return e(this);await this.applyWip_({fn_:async n=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(n),skipFsLock:a,minSizeBytes:i,timeoutMs:r,dirty:l})}return o&&n?void 0:this.utimes()}),{maxRetries:o,timeoutMs:2*r,retryDelay:3*b.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,E.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:n=!1,timeoutMs:r,dirty:s=!1}){return await this.parent().mkdirp_(),(0,re.withLock_)({file:this,skipFsLock:n,timeoutMs:r,dirty:s},(async()=>{const n=this.wip();try{await n.unlink("trace");const s=await(0,T.thenOrTimeoutError)(e(n),r);if(s===t.NoOp)return s;if(await(0,N.untilTrue)((()=>n.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await n.mv_(this),s;throw new Error(this+"applyWip(): still empty after waiting "+(0,M.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await n.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==$.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,n,"m",r).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,n,"m",s).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();$.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:b.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,E.clamp)(I.ShortCommandTimeoutMs,10*b.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,S.notBlank)(this.ext)&&(0,S.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,b.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,_.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,A.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,L.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,ae.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,ae.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,X.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,n=new WeakSet,r=async function(e){let t,i=e;const n=e.wip();try{const r=await this.stat_();if(null==r)return this.pflog().throw("Can't copy missing files"+j.NonRetriableErrorFlag);if(r.size>0){if($.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+j.NonRetriableErrorFlag);if(null==await n.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,n.nativePath,h.default.constants.COPYFILE_FICLONE),r.size>5*k.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},r.size,(()=>n.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,E.approximates)(r.size,await n.size({refresh:!0}))),{intervalMs:b.secondMs,timeoutMs:b.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:r.size,actualSize:await n.size({refresh:!0})});await this.maybeVerifySameOrThrow_(n),i=e.eql(n)?e:await n.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:r.birthtimeMs,mtimeMs:r.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,r.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${r.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${n?.nativePath}) failed: ${t}`),await n.unlink(),n.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,_.map)(t,(e=>e.end()))}},s=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const n=await this.stat_(),r=n?.size;return null==n||null==r?this.pflog().throw("Can't copy missing files"):(r>5*k.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},r,(()=>e.clear().size()))),U.isWin?await G.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,G.pwshQuote)(this.nativePath)} -Destination ${(0,G.pwshQuote)(i.nativePath)}`,(e=>e)):U.isMac?await(0,B.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,B.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+j.DoNotSendErrorFlag,{error:t})}finally{(0,_.map)(t,(e=>e.end()))}}},62105:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.acceptFile=t.whyRejectFile=t.expensiveFileFiltersFor=t.acceptParentAndFileAndSimple=t.acceptFileSimple=t.whyRejectFileSimple=t.simpleFileFiltersFor=t.notFileTooBig=t.notFileTooSmall=t.notFileMissing=t.hasBrowserImgMimeType=t.notDimensionsTooSmall=t.requiredTagsFilter=void 0;const n=i(40958),r=i(22573),s=i(31586),a=i(54993),o=i(48884),l=i(56519),u=i(78984),c=i(28874),d=i(43207),h=i(47783),f=i(97573),m=i(16170),p=i(54979),g=i(1078),y=i(42231),v=i(83278),w=i(19748),S=i(92423),b=i(16287);function P(e){return async t=>(0,l.thenMapOr)((0,h.readRawTags)(t,!1),e,(()=>!1))}async function M(e){if(!(0,s.gt0)(c.Settings.minVideoDimension.valueOrDefault)&&!(0,s.gt0)(c.Settings.minImageDimension.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);if(null==t||!t.startsWith("image/")&&!t.startsWith("video/"))return!1;const i=t.startsWith("video/")?c.Settings.minVideoDimension.valueOrDefault:c.Settings.minImageDimension.valueOrDefault;return(0,s.gt0)(i)?(0,l.thenMapOr)((0,g.extractSizeInfoFromFile)(e),(e=>(0,s.gte)(e.ImageWidth,i)&&(0,s.gte)(e.ImageHeight,i)),(()=>!1)):null}async function _(e){if(!(0,s.gt0)(c.Settings.minVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,s.gte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.minVideoDurationSec.valueOrDefault):null)}async function E(e){if(!(0,s.gt0)(c.Settings.maxVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,s.lte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.maxVideoDurationSec.valueOrDefault):null)}async function x(e){return!(0,r.blank)(await(0,p.readMimeType)(e))}async function T(e){if(-100===c.Settings.rejectRatingsLessThan.valueOrDefault)return null;const t=await(0,h.readTags)(e),i=(0,s.toInt)(t?.Rating);return null==i||i>=c.Settings.rejectRatingsLessThan.valueOrDefault}async function D(e){return 0===c.Settings.keywordBlocklist.values.length?null:(0,f.rawTagKeywords)(await(0,h.readTags)(e)).every((e=>!0!==(0,y.leafIsExcluded)(e,c.Settings.keywordBlocklist.values)))}async function k(e){if(!c.Settings.requireMakeModel.valueOrDefault)return null;const t=await(0,h.readRawTags)(e);return null==t||(0,r.blank)(t.MIMEType)?null:t.MIMEType.startsWith("image/")?null!=t&&(0,r.notBlank)(t.Make)&&(0,r.notBlank)(t.Model):null}async function C(e){return(0,v.isBaseFile)(e)?e.exists():(0,b.exists)(e.nativePath)}async function F(e){const t=c.Settings.minAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,s.gte)(i,t)}async function O(e){const t=c.Settings.maxAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,s.lte)(i,t)}function I(e){return[{isSupportedFileExtension:w.isAssetFileExtension},...(0,S.notExcludedFilePredicates)(e),{notFileMissing:C},{notFileTooSmall:F,notFileTooBig:O}]}function L(e){return[...I(e),{notMissingMimeType:x},{supportedMimeType:m.isAssetFileMimeType},{notMissingMakeAndModelTags:k},{notDimensionsTooSmall:M},{notVideoTooShort:_},{notVideoTooLong:E},{notRejectedRating:T},{notExcludedKeyword:D}]}async function A(e,t){return await u.Predicates.whyRejected(e,...t??L(e))??await(0,S.whyExcludedDirectoryRecursive)(e.parent())}t.requiredTagsFilter=function(e){return P((t=>(0,o.allNotBlank)(...e.map((e=>t[e])))))},t.notDimensionsTooSmall=M,t.hasBrowserImgMimeType=P((e=>(0,n.includes)(["image/jpeg","image/png"],(0,a.toS)(e.MIMEType)))),t.notFileMissing=C,t.notFileTooSmall=F,t.notFileTooBig=O,t.simpleFileFiltersFor=I,t.whyRejectFileSimple=function(e){return u.Predicates.whyRejected(e,...I(e))},t.acceptFileSimple=function(e){return u.Predicates.accepted(e,...I(e))},t.acceptParentAndFileAndSimple=async function(e){const t=await e.parent();return null!=t&&!await(0,S.isExcludedDirectory)(t)&&await u.Predicates.accepted(e,...I(e))},t.expensiveFileFiltersFor=L,t.whyRejectFile=A,t.acceptFile=async function(e){return null==await A(e)}},78133:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const r=n(i(76760)),s=i(22573),a=i(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(r.default.sep===r.default.posix.sep)return e;const i=(0,s.notBlank)(t)?r.default.sep+r.default.sep+t+r.default.sep:"",n=e.split(r.default.posix.sep);return(0,a.equalsIgnoreCase)(n[0],t)&&n.unshift(),i+n.join(r.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||r.default.sep===r.default.posix.sep||r.default.posix.sep===r.default.sep?e:e.split(r.default.sep).join(r.default.posix.sep)}},43899:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const r=n(i(76760)),s=n(i(1708)),a=i(19851),o=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,a.lazy)((()=>r.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,a.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(r.default.join((0,p.execDir)(),"resources"),r.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,o.compactBlanks)([(0,p.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const n=r.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(n,e))return n}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const n=i(44652),r=i(19851),s=i(31586),a=i(50213),o=i(57902),l=i(69428),u=(0,r.lazy)((()=>(0,a.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=o.LogLevels.info){try{return await(0,n.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const n=i(44652),r=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let s=-1;try{const r=i??(await(0,n.stat)(e)).size-t,a=Buffer.alloc(r);return s=await(0,n.open)(e,"r"),await(0,n.read)(s,a,0,r,t)}finally{(0,r.mapGte0)(s,n.close)}}},69428:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const a=s(i(73024));t.readFileSync=function(e){try{return a.readFileSync(e)}catch{}}},55690:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const n=i(44652),r=i(84542);t.readLines_=async function(e){return(0,r.splitCompactLines)(await(0,n.readFile)(e))}},32323:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const n=i(57075);class r extends n.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=r},65238:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const r=n(i(51455)),s=i(76760),a=i(19851),o=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),v=i(28874),w=i(63870),S=i(88561),b=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,a.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,a.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function M(){try{await r.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=M;const _=(0,a.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function E(e){(0,l.blank)(e)||_.prior()?.delete(e)}async function x(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await _().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,b.statTimeoutMs)(),n=T(e),r=await(0,h.thenOrTimeout)(n,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(r===f.Timeout&&(0,g.onTimeout)({soft:!1}),r!==f.Timeout&&r.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=E,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),_.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),M()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?M():E(e)))})),t.slowDirs=(0,a.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!_().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){E(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=_().get(e)},t.childDirectories_=async function(e){return(await x(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?x(e):T(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=x,t.readdirCached=function(e){return _().get(e)},t.readdirUncached_=T},53265:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const r=i(73024),s=n(i(76760)),a=i(40958),o=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,a.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=s.default.resolve(t,...e);if((0,r.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,o.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(o.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},46356:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.seemsLikeSymlinkLoop=void 0;const n=i(22454),r=i(28874),s=i(29882);t.seemsLikeSymlinkLoop=function(e){const t=new n.CountingSet;for(const i of(0,s.toPathnames)(e))t.incr(i.toLowerCase().normalize());return t.max()>r.Settings.maxDuplicatePathElements.valueOrDefault}},50274:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const n=i(50989);t.SidecarExts=(0,n.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const n=i(22573),r=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,n.notBlank)(e.basename)&&(0,r.isBoolean)(e.isFile)&&(0,r.isBoolean)(e.isDirectory)}},17217:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const r=n(i(73024)),s=n(i(76760)),a=i(22573),o=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,a.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,a.blank)(e.nativePath))throw new Error(`toNativePath(${(0,o.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof r.default.Dirent?e.name:f(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:s.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(s.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,o.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(r.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,o.blank)(e)?void 0:v(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=S(e),n=S(t);if(i!==n)return"inconsistent file type: "+i+" ≠ "+n;for(const i of["size","mtime"]){const n=e[i],r=t[i],s=(0,u.diff)(b(n),b(r));if(null==s||s>1)return"unmatched "+i+": "+n+" ≠ "+r}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const i=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await w(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,a.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const r=n(i(73024)),s=i(22573);function a(e){try{return(0,s.blank)(e)?void 0:r.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function o(e){return null==e||e.isFile()&&0===e.size}t.statSync=a,t.isEmptyStats=o,t.isFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=a(e);return t.emptyIsNew?null==i:o(i)},t.isNonEmptyFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===a(e)?.isDirectory()}},41080:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const n=i(28874);t.statTimeoutMs=function(){return n.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const n=i(22573),r=i(56409);t.onDataChunked=function(e,t,i){const n=new s(t,i,!0);return n.read(e),n.done};class s{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new r.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,n.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,n.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const r=n(i(57075)),s=i(41400),a=i(55835),o=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends r.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,n)=>{!1===e.write(t,(e=>{e&&n(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,o.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:n}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,a.map)(n,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends r.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const r=n(i(73024)),s=i(76760),a=i(22573),o=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,a.blank)(e))return!1;try{return r.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,o.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,a.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,a.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,a.blank)(e)&&d((0,u.posix2native)(e))}},89966:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const r=n(i(48161)),s=i(19851),a=i(55835),o=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),h=i(8103),f=i(43899);function m(){return(0,a.map)(f.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,a.map)(m(),(e=>e.join(c.platformName+"-"+r.default.arch())))}async function g(e){if(c.isWin&&(e=(0,o.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,h.pathIfExists)(m()?.join("bin",e))),(()=>(0,h.pathIfExists)(m()?.join(e))),(()=>(0,h.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,h.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,s.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,s.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,s.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,s.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const r=n(i(44652)),s=i(19851),a=i(22573),o=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,o.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,a.blank)(t.file))throw new Error("can't touch blank path");const n=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const o=(0,s.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await o())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await o())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(r.default.utimes(n,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!i||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(r.default.ensureFile(n),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},84258:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const a=s(i(51455)),o=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,o.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const n of(0,l.toA)(e))try{null!=n&&await a.unlink((0,c.toNativePath_)(n))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+n,{error:e})}}},5545:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const r=n(i(76760)),s=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,s.toS)(i.path??r.default.sep)}},70257:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const n=i(30976),r=i(45255),s=i(17217);t.WipTimeoutMs=r.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,n.randomChars)(5).toUpperCase()+"-"+e};const a=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(a,"")},t.isWip=function(e){return a.test((0,s.basename)(e)??"")}},58722:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const n=i(57075),r=i(22911);class s extends n.Writable{constructor(e){super(e),this.deferred=new r.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=s},73428:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const r=n(i(44652)),s=n(i(76760)),a=i(51926),o=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=s.default.dirname(e);await(0,c.mkdirp_)(i),await r.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=s.default.dirname(e);(0,c.mkdirpSync_)(i),r.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,a.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))}},13047:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const r=n(i(73024)),s=i(76760),a=i(46466),o=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,i){const n=[],s=[r.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>n.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,o.createGunzip)().on("error",(e=>n.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,o.createBrotliDecompress)().on("error",(e=>n.push(e)))),s.push(t),await(0,a.pipeline)(s),(0,u.isNotEmpty)(n))throw new f.WrappedError("zPipe("+e+") failed",{causes:n,path:e})}async function b(e,t){const i=new y.WritableToBuffer;return await S(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function M(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,a.pipeline)(new g.ReadableBuffer(i),(0,o.createGzip)(),r.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void v().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=M,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await M(e,t)}catch(t){v().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},18454:function(e,t,i){var n,r,s,a,o,l,u,c,d,h,f,m,p,g,y,v,w,S,b,P,M=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},_=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const E=i(19851),x=i(40958),T=i(76790),D=i(41400),k=i(50357),C=i(26905),F=i(50268),O=i(55835),I=i(68708),L=i(30976),A=i(51926),R=i(13538),N=i(42279),B=i(59455),z=i(54993),j=i(48884),V=i(89788),W=i(22454),H=i(50213),U=i(69591),q=i(22911),G=i(99331),$=i(5916),J=i(42638),K=i(77740),Z=i(98314),X=i(70025),Y=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),ne=i(21525),re=i(82638),se=(0,E.lazy)((()=>(0,H.mkLogger)("health.HealthCheck")));class ae{static traceLater_(e,t){const i=new q.Deferred(e);i.catch((t=>{M(this,r,"f",l).push(e+": failed: "+(0,Z.errorToS)(t)),this.onResultChange()})),M(this,r,"m",o).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return M(this,r,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){M(this,r,"f",l).push((0,A.isString)(e)?e:(0,Z.errorToS)(e)),this.onResultChange()}static lastErrors(){return M(this,r,"f",l).toA()}static addLoadingMsg(e){M(this,r,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,x.compact)((0,B.toA)(e)).map(z.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return se().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:M(this,r,"f",h).entriesByCountDesc()}),(0,O.map)((0,j.leastBy)(e,(e=>[M(this,r,"f",h).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=M(this,r,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,O.map)(e,(e=>M(this,r,"f",h).incr(e.msg))),se().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return Y.Settings.skipHealthCheckIds.envValue=t,r.reset()}static findById(e){return M(this,r,"f",f).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,F.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=M(this,r,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=r.summary();if(e.pendingCount>0){const t=await Promise.all(r.testResultsCritical());e=r.summaryFromResults(t),se().info("awaitSettled(): summary result",{summary:e,results:t})}return se().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){r.summary.unset()}static reset(){if((0,G.ending)())se().warn("Rejecting reset() when ending()",(0,C.shortStack)());else{this.onResultChange(),M(this,r,"f",l).clear(),M(this,r,"f",d).clear(),M(this,r,"f",h).clear(),M(this,r,"f",c).clear(),this.summary.clear(),_(this,r,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new r(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return M(this,r,"f",f).push(i),this.all.unset(),i}constructor(e,t,i,s,o,l,u,c,d,h,f,m,b,P=Q.commandTimeoutMs){n.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=s,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=h,this.errorLinks=f,this.onReset=m,this.ttlMs=b,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),w.set(this,(0,E.lazy)((async()=>{await M(this,p,"f").prior(),(0,k.eql)(M(this,g,"f"),M(this,n,"m",v).call(this))||(this.onReset?.(),await this.refresh(),M(this,w,"f").unset())}))),this.refresh=(0,E.lazy)((()=>new q.Deferred("refresh").observe((async()=>{await M(this,p,"f").prior();const e=M(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,H.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[F.HealthCheckSections.ordinal(this.section),l??999,this.id],_(this,p,(0,$.lazyAsync)({desc:this.pendingMsg,later:()=>M(r,r,"f",a).enqueue({name:this.id,l:()=>M(this,n,"m",S).call(this,o)}),ttlMs:b}),"f"),this.isCritical&&M(this,p,"f").watchLater({onChange:r.onCriticalResult,onError:r.onCriticalResult});for(const e of this.settings)Y.Settings[e].watchLater((()=>M(this,w,"f").call(this)))}isStale(){return M(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return M(this,p,"f").settledCount()}reset(){return M(this,p,"f").unset(),this.onReset?.(),_(this,g,{starting:!0},"f"),this}setTTL(e){M(this,p,"f").setTTL(e)}result(){return M(this,p,"f").call(this)}isSkipped(){return Y.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return M(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return M(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??M(this,n,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function oe(e){if((0,x.isEmpty)(e))return{};const[t,i]=(0,j.partition)(e,(e=>"button"===e.type||"POST"===e.method)),n={};return(0,x.isNotEmpty)(i)&&(n.links=(0,x.uniqBy)(i)),(0,x.isNotEmpty)(t)&&(n.buttons=(0,x.uniqBy)(t)),n}t.HealthCheck=ae,r=ae,p=new WeakMap,g=new WeakMap,y=new WeakMap,w=new WeakMap,n=new WeakSet,o=function(){return(0,x.filterInPlace)(M(this,r,"f",s),(e=>!e.isPending)),M(this,r,"f",s)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=se().tap({level:"warn",msg:"#summary()",result:(0,re.summarizeHealthChecksSync)({errors:M(this,r,"f",l),skipPending:M(this,r,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&_(this,r,!0,"f",u),i.state!==M(this,r,"f",c).last?.state&&M(this,r,"f",c).push({state:i.state,ts:Date.now()}),i},v=function(){return(0,I.fromEntries)(this.settings.map((e=>[e,Y.Settings[e].valueOrDefault])))},S=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();se().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,C.shortStack)()}),_(this,g,M(this,n,"m",v).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,D.delay)((0,L.randomInt)(.3*i,.7*i)),this.isSkipped())return M(this,n,"m",b).call(this,{test:{level:"disabled",msg:["Disabled by "+Y.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const r=await(0,R.thenOrTimeoutError)(e(),i);return M(this,n,"m",b).call(this,{test:r,elapsedMs:Date.now()-t})}catch(e){return M(this,n,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},b=function({test:e,src:t="#toResult",elapsedMs:i}){var n,s;const a=r.normalizeMsg(e.msg),o=e.level??((0,z.toS)(a).toLowerCase().includes("error")?"error":(0,z.toS)(a).toLowerCase().includes("warn")?"warn":"ok"),l=(0,x.compact)([...e?.links??("ok"===o||"pending"===o?this.okLinks:"warn"===o?this.warnLinks:"no-library"===o?this.noLibraryLinks:"error"===o?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:o,msg:a,elapsedMs:i,...oe(l)};return u.runCount=(_(this,y,(s=M(this,y,"f"),n=s++,s),"f"),n),(0,G.ending)()?u:this.logger.tap({level:ne.HealthCheckLevelToLogLevel[o],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const r=(0,A.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,O.map)(e,Z.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,X.isFatalError)(e)&&r.toLowerCase().includes("warn")?"warn":"error"),M(this,n,"m",b).call(this,{test:{msg:r,level:t},src:"#toErrorResult",elapsedMs:i})},s={value:[]},a={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},h={value:new W.CountingSet},f={value:[]},ae.all=(0,E.lazy)((()=>Object.freeze((0,T.sortBy)(M(r,r,"f",f),(e=>e.sortBy))))),ae.onCriticalResult=(0,U.debounce)((()=>{se().info("onCriticalResult()",r.summary.refresh())}),250),ae.summary=(0,E.lazy)((()=>M(r,r,"m",m).call(r))),ae.resetDebounced=(0,U.debounce)((()=>r.reset()),50)},33866:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const n=i(50989);t.HealthCheckIds=(0,n.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const n=i(82950),r=i(50268),s=i(459),a=i(23560),o=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,a.isPermaService)(t)&&(e===r.HealthCheckLevels.error||(0,a.isLibraryRequiredService)(t)&&e===r.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,o.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,n.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new s.UnreachableCaseError(e)}}},42495:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const n=i(40958),r=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,n.compact)([(0,r.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},89035:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const r=n(i(48161)),s=i(19851),a=i(82950),o=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),h=i(23560),f=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:n}){return{level:i,msg:[e+" from "+(0,h.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,a.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(n,2)])]}}function g(){return r.default.totalmem()f.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(f.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*f.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,s.lazy)((()=>"ok"!==g().level),o.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:o.minuteMs,later:async()=>g()})))},82638:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const n=i(40958),r=i(42659),s=i(45599),a=i(41400),o=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),h=i(23560),f=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,s.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function v({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:n}){const r=new Map;for(const e of t??[])r.set(e.id,e);if(null!=e)for await(const t of f.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),n))r.set(t.id,t);return[...r.values()]}t.summarizeHealthChecks=async function(e){return S({...e,healthCheckResults:await v(e)})};const w=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:h.serviceName.prior()??process.title}})));function S(e){const t=(0,n.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),s=i.length,a=i.map((e=>e.id)),c=t.length-s,d=0===s,h=(0,n.uniq)((0,n.compactBlanks)(e.errors));if(h.length>0)return{...w(),level:l.HealthCheckLevels.error,settled:d,pendingIds:a,pendingCount:s,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",h.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const r=t.filter((e=>e.level===i));if((0,n.isNotEmpty)(r)){const e=t.filter((e=>!r.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+r.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...w(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:a,pendingCount:s,settledCount:c,linkIds:r.map((e=>e.id)),ts:Date.now(),msg:(0,n.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,o.flatten)([...r,...e].map((e=>e.msg[0])))])},meta:{checks:r.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...w(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:a,pendingCount:s,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,r.fmtDateShort)(Date.now())]}})}(0,a.later)((()=>{m.Settings.libraryDir.watchLater((()=>w.unset()))})),t.summarizeHealthChecksSync=S},95242:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviewBuilder=t.mkPreviewAssetFile_=void 0;const a=i(57975),o=i(40958),l=i(22573),u=i(33374),c=i(98553),d=i(55835),h=i(68708),f=i(48884),m=i(50213),p=i(92434),g=i(54296),y=i(51837),v=i(57159),w=i(83278),S=i(95696),b=i(62105),P=i(84258),M=i(38156),_=i(69589),E=i(28874),x=i(47783),T=i(29990),D=i(16047),k=i(42725),C=i(4192),F=i(32876),O=i(50961),I=i(181);t.mkPreviewAssetFile_=async function(e){const t=await(0,x.readTags)(e);return{nativePath:e.nativePath,fileSize:await e.size(),mtime:await e.thisOrSidecareMaxMtimeMs(),uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath,mimetype:t.mimetype,rotation:t.rotation,...t.dimensions,sha:await e.sha_()}};class L{constructor(e,t,i){n.add(this),this.ap=e,this.assetFiles=t,this.logger=(0,m.mkLogger)("AssetPreviewBuilder("+e.assetId+")"),this.ctx=(0,_.forceContextOrSetting)(i),this.assetFiles=(0,p.sortAssetFiles)(this.assetFiles)}[(n=new WeakSet,a.inspect.custom)](){return{ctor:"AssetPreviewBuilder",assetId:this.ap.assetId,assetFiles:this.assetFiles}}async build_(){this.logger.info("build_(): asset file candidates:",this.assetFiles.map((e=>(0,h.pick)(e,"id","uri"))));const e=[];for(const t of this.assetFiles){const i=S.PosixFile.forMaybe(await(0,g.getAssetFileNativePath)(t));if(null!=i){{const e=await(0,b.whyRejectFile)(i);(0,l.blank)(e)||this.logger.info("skipping: rejected",{pf:i,whyRejected:e})}try{return await s(this,n,"m",r).call(this,i,t)}catch(i){e.push(i),this.logger.warn("Failed to set shown file to ",{best:t,error:i})}finally{this.ap.parent.clear()}}else this.logger.info("skipping: failed to get PosixFile",{af:t}),e.push(new Error("Cannot get path from URI "+(0,c.stringify)((0,h.pick)(t,"uri","mountpoint","nativePath"))))}return this.logger.throw("Cannot build previews: none of the files are valid",{doNotSend:!0,retriable:!1,files:this.assetFiles.map((e=>e.nativePath??e.uri)),causes:e})}async infoForBest_(e,t){await(0,I.throwIfInvalidFile_)(e);const i=await e.size(),n=await e.thisOrSidecareMaxMtimeMs();if(this.logger.debug("_build",{filesize:i,mtime:n,best:t.uri}),null==i||null==n)return this.logger.throw("build(): missing stat info for best file",{ignorable:!0,best:t});const{uri:r,width:s,height:a,sha:l,mimetype:u}=t;if(null==r||null==s||null==a||null==u||null==l)return this.logger.throw("build(): internal error: missing fields for best file "+e,{ignorable:!0,best:t});const c=(0,T.fitSizes)(t,t.mimetype);return{assetId:t.assetId,assetFileId:t.id,uri:r,uris:this.assetFiles.map((e=>e.uri)),path:e.nativePath,mtime:n,filesize:i,width:s,height:a,sha:l,mimetype:u,fitSizes:c.map((([,e])=>e.name)).join(","),sqWidths:(0,o.compact)(k.ImageSize.sq().map((e=>e.outputSize(t)?.width))),fitWidths:c.map((([e])=>e.width))}}async priorIfValid_(e,t){if(this.ctx.forceSync||this.ctx.forceRebuildPreviews)return;const i=await this.ap.readInfo.refresh();if(null!=i){if(i.assetId!==t.assetId)throw new y.InternalError("priorIfValid_(): mismatched asset IDs for "+e+": "+(0,c.stringify)({priorInfo:i,info:t}));const n=i.fitSizes.split(","),r=t.fitSizes.split(",");if(null!=i.sha&&i.sha===t.sha&&i.rotation===t.rotation&&(0,T.equivalentFitSizes)(n,r)){const s=(0,T.fitSizes)(e,e.mimetype),a=(0,o.diff)(n,r);if((0,o.isNotEmpty)(a)){this.logger.info("priorIfValid_(): removing previews that aren't required anymore.",{leftovers:a});for(const e of a){const t=s.find((([,t])=>t.name===e));if(null==t)this.logger.warn("priorIfValid_(): Failed to clean up: missing fit size",{fitsize:t,fits:s});else{const e=this.ap.fileForWidth(t[1].reducer.name,t[0].width);this.logger.debug("priorIfValid_(): unlinking unwanted preview "+e,{fitsize:t}),await e.unlink("warn")}}}return this.logger.debug("priorIfValid_(): SHA and rotation match, and previews exist.",{info:t,priorInfo:i}),await this.ap.writeInfo(t),t}}}}t.AssetPreviewBuilder=L,r=async function(e,t){this.logger.info("_build("+e+")",{uri:t.uri});const i=await this.infoForBest_(e,t),n=await this.priorIfValid_(t,i);if(null!=n)return n;const r=new M.PushProgressObserver({path:e.nativePath,op:"Building previews"},k.ImageSize.sq().length+k.ImageSize.fit().length);if(this.logger.debug("Rebuilding all previews from "+t.uri,{assetId:t.assetId,info:i}),null==await this.ap.parent.mkdirp())throw new Error("build(): Failed to create previews directory, "+this.ap.parent+" for "+t);const s=await this.ap.existingFiles(),a=await(0,O.sharpReadable_)({src:e,minDim:k.ImageSize.largestFit().max});if(null==a)throw new v.WrappedError("AssetPreviewBuilder.build(): "+t.uri+", "+e.nativePath+", is not readable by sharp.",{retriable:!1});const o=(0,O.toSharp)(a);if(t.mimetype.startsWith("image/")&&!(0,D.isHeifMimeType)(t.mimetype)&&null!=t.rotation&&0!==t.rotation&&(o.rotate(t.rotation),this.logger.debug("build(): rotating "+t.rotation+"°")),(0,w.isBaseFile)(a)&&a.desc.toLowerCase().includes("thumbnail"))try{o.trim(1)}catch{}const l=(0,T.fitSizes)(t,t.mimetype),c=[],m=[];let p,g;const y=k.ImageSize.largestSq(),S=(0,f.leastBy)(l,(([e,t])=>(0,d.map)(y.outputSize(e),(()=>t.megapixels()))))?.[1].name,b=(0,h.pick)(t,"width","height");{let e=o.clone(),t=b;for(const[i,n]of l){const s=Date.now(),a=t,o=this.ap.fileForWidth(n.reducer.name,i.width).wip();e=n.resize(i,e),t=i,n.name===S&&(g=e.clone(),p=i),(0,u.dmegapixels)(i)>=1&&n.reducer===F.Fit&&E.Settings.includePreviewTags.valueOrDefault&&m.push(o),await n.toJpeg({path:o.nativePath,sh:e,outputSize:i}),r.onProgress(),this.logger.debug("resize("+n.name+") "+(0,u.fmtDim)(a)+" -> "+(0,u.fmtDim)(i)+" in "+(Date.now()-s)+" ms"),c.push(o)}}{null==g?(this.logger.debug("square resize(): resorting to ",{origDim:b,bestFitNameForSq:S}),g=o,p=b):this.logger.debug("square resize(): using to ",{sqDim:p,bestFitNameForSq:S});let e=!1;for(const t of k.ImageSize.sq()){const i=Date.now(),n=p,s=t.outputSize(p??b);if(null==s){this.logger.debug("skipping square output for "+t.max);continue}e||(s.position=E.Settings.squareThumbStrategy.valueOrDefault,e=!0),this.logger.debug("Applying ",{outputSize:s});const a=this.ap.fileForWidth(t.reducer.name,s.width).wip();t.resize(s,g),p=s,await t.toJpeg({path:a.nativePath,sh:g,outputSize:s}),r.onProgress(),c.push(a),this.logger.debug("resize("+t.name+") "+(0,u.fmtDim)(n)+" -> "+(0,u.fmtDim)(s)+" in "+(Date.now()-i)+" ms")}}try{await(0,C.includePreviewTags_)(e,m).catch((t=>{this.logger.warn("Failed to restore metadata tags into previews for "+e,{error:t})}));const t=new Set(s.map((e=>e.nativePath)));for(const e of c){const i=await e.unwip_();t.delete(i.nativePath)}await(0,P.unlink)(t),await this.ap.writeInfo(i),this.logger.debug("Previews unwipped and info written",{info:i})}catch(t){throw await(0,P.unlink)(c),new v.WrappedError("Failed to create previews from "+e,{cause:t,path:e.nativePath,fatal:!1})}return i}},35721:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkDownloadableTitle=t.previewToDownloadable=t.extractPreviewInfo=void 0;const n=i(75761),r=i(33374),s=i(11371),a=i(55835),o=i(31586),l=i(56519),u=i(29882),c=i(50213),d=i(97352),h=i(81168),f=i(89782),m=(0,c.mkLogger)("extractPreviewInfo");function p(e,t,i,n){return`Download ${t} ${e.ext} ${i} (${(0,r.fmtDim)(n)})`}t.extractPreviewInfo=function(e,t){const i=t.posixPathFrom(e).replace(/\//g,"").split("-"),n=(0,o.toInt)(i[0]),r=s.ReducerNames.getCI(i[1]),a=(0,d.extractInt)(i[2]);return(0,o.gt0)(n)?{file:t,assetId:n,reducer:r,width:a}:void m.warn("Failed to extract preview info",{file:t,previewsRoot:e,arr:i,assetId:n,reducer:r,width:a})},t.previewToDownloadable=async function(e,t){return(0,a.map2)(t.assetId,t.width,((i,a)=>(0,l.thenMap)((0,f.dimensions)(t.file),(o=>{const l=(0,r.dimToSize)(o);return{size:l,basename:`${(0,h.stripSuffix)(e,(0,u.extname)(e))}-${l}${t.file.ext}`,title:p(t.file,l,"image",o),description:`Download ${l}`,details:`(${(0,r.fmtDim)(o)} ${t.file.ext})`,href:(0,n.assetImgLink)({assetId:i,reducer:s.ReducerNames.fit,width:a})}}))))},t.mkDownloadableTitle=p},16524:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviews=void 0;const a=i(19851),o=i(40958),l=i(75761),u=i(11371),c=i(68708),d=i(39926),h=i(58939),f=i(48884),m=i(50213),p=i(81168),g=i(56519),y=i(38835),v=i(70417),w=i(35721);t.AssetPreviews=class{constructor(e,t){n.add(this),this.previewsRoot=e,this.readInfo=(0,a.lazy)((()=>this.infoJson().readJson("debug"))),this.logger=(0,m.mkLogger)("AssetPreviews(assetId:"+(0,h.id2id)(t)+")"),this.assetId=(0,h.id2id)(t);const i=(0,d.leftPad)(this.assetId,8,"0"),r=(0,p.splitEvery)(i,3);this.basename=r.pop()+"-",this.parent=e.join(...r)}parentNotExists(){return this.parent.clear().notExists()}async existingFiles(){return await this.parent.clear().childFiles((e=>e.base.startsWith(this.basename)))??[]}async existingJpgs(){return(await this.existingFiles()).filter((e=>".jpg"===e.ext))}async previewInfos(){return(0,g.sortByAsync)({name:"img.AssetPreviews.previews",arr:s(this,n,"m",r).call(this),f:e=>e?.file.size()})}async deleteAll(){const e=await this.existingFiles();if(e.length>20)throw new Error("deleteAll(): rejected: > 20 existing files?!"+y.InternalErrorFlag);for(const t of e)await t.unlink();return e}fileForSuffix(e){return this.parent.join(this.basename+e)}mp4(){return this.fileForSuffix("video.mp4")}infoJson(){return this.fileForSuffix("info.json")}writeInfo(e){return this.readInfo.unset(),this.infoJson().writeJson((0,c.pick)(e,"assetId","assetFileId","uri","uris","path","mimetype","width","height","mtime","filesize","sha","rotation","fitSizes","fitWidths"))}fileForWidth(e,t){return this.fileForSuffix(e+"-w"+t+".jpg")}async filesForReducer(e){const t=this.basename+e+"-";return this.logger.tap({msg:"filesForReducer("+e+")",result:(await this.existingFiles()).filter((e=>e.base.startsWith(t)))})}async smallestFileForReducer(e){return(0,f.leastBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async largestFileForReducer(e){return(0,f.greatestBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async widths(e){const t=await this.readInfo(),i=e===u.ReducerNames.sq?"sqWidths":"fitWidths",n=t?.[i];if(!(0,o.isEmpty)(n))return n;const r=(0,o.compact)((await this.previewInfos()).filter((t=>t.reducer===e)).map((e=>e.width)));return null!=t&&(t[i]=r,await this.writeInfo(t)),r}async posterLink(){const e=await this.widths(u.ReducerNames.fit);return(0,l.assetImgLink)({assetId:this.assetId,reducer:u.ReducerNames.fit,width:(0,v.max)(e)})}async imgAttrs(e,t=!1,i=!0){if(t||e!==u.ReducerNames.sq){const t=e===u.ReducerNames.fit?await this.readInfo():void 0;return(0,l.assetImgAttrs)({assetId:this.assetId,reducer:e,widths:await this.widths(e),lazyLoad:i,af:t})}return(0,l.assetSqImgAttrs)({assetId:this.assetId,lazyLoad:i})}},n=new WeakSet,r=async function(){const e=[];for(const t of await this.existingFiles()){const i=(0,w.extractPreviewInfo)(this.previewsRoot,t);null!=i&&e.push(i)}return e}},52086:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const n=i(50989);t.CropStrategies=(0,n.strEnum)("center","entropy","attention")},33106:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.dctPixels=t.dctHashCIELAB=t.dctHash=void 0;const r=n(i(9288)),s=i(96249),a=i(85810),o=32,l=function(e){const t=new Array(32);for(let e=1;e<32;e++)t[e]=1;return t[0]=1/Math.sqrt(2),t}(),u=function(e){const t=new Array(32);for(let e=0;e<32;e++){t[e]=new Array(32);for(let i=0;i<32;i++)t[e][i]=Math.cos((2*e+1)/64*i*Math.PI)}return t}();function c(e){const t=new Array(o);for(let i=0;ir?1:0);return s}t.dctHash=async function(e){return c(await e.greyscale().resize({width:o,height:o,fit:r.default.fit.fill}).raw().toBuffer())},t.dctHashCIELAB=async function(e){const t=await e.resize({width:o,height:o,fit:r.default.fit.fill}).raw().toBuffer(),i=(0,a.rgb2labArray)(t);return(0,s.flatten)(i.map(c))},t.dctPixels=c},86580:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const n=i(40958),r=i(33374),s=i(31586),a=i(21605),o=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,s.gt0)(e.width)&&(0,s.gt0)(e.height)?(0,s.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,r.dmegapixels)(e.dimensions):(0,s.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,s.lt)(e.width,t.width)&&(0,s.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,s.lte)(e?.width,t?.width)&&(0,s.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,s.lt)(e.width,t.width)||(0,s.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,n.compact)((0,o.toS)(e).split(/[x×]/).map((e=>(0,s.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,n=Math.round(Math.sqrt(t*i));return{width:n,height:Math.round(n/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const n=u(e,i);return null==n?[]:a.Rotations.filter((e=>u(c(t,e),i)===n))}},89782:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const n=i(19851),r=i(31586),s=i(50213),a=i(56519),o=i(1078),l=i(5733),u=(0,n.lazy)((()=>(0,s.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,r.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,a.thenMap)((0,o.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},29990:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.equivalentFitSizes=t.fitSizes=void 0;const n=i(40958),r=i(33374),s=i(16170),a=i(42725),o=[a.ImageSize.QVGA,a.ImageSize.QQVGA];function l(e){return"qhd"===e?"wvga":"uhd"===e?"uhd4k":e}t.fitSizes=function(e,t){const i=a.ImageSize.fit(),n=[];let l=(0,s.isMimeTypeSupportedByBrowser)(t)?e:void 0;for(let t=0;t3||(0,r.dmegapixels)(a)-(0,r.dmegapixels)(l)>2.5)&&(l=a,n.push([a,s])))}return n},t.equivalentFitSizes=function(e,t){return(0,n.includesAll)((0,n.compactBlanks)(e).map(l),(0,n.compactBlanks)(t).map(l))}},277:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const n=i(22573),r=i(41400),s=i(54993),a=i(19851),o=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),h=i(78330),f=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),v=(0,a.lazy)((()=>(0,o.mkLogger)("img.Heif")));function w(e){return(0,s.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function S(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,a.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,n.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){v().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,n.blank)(e))return void v().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=w(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,n.blank)(i)&&(0,l.hasApt)()){const t=await(0,h.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,n.blank)(i)&&(0,f.hasPacman)()&&(i=(await(0,f.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,n.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void v().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=w,t.isHeifSupported=S,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await S()?(0,g.heif2png_)(e):void v().throw("HEIF support is missing",{src:e.nativePath})},(0,r.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const n=i(19851),r=i(22573),s=i(42659),a=i(41400),o=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),h=i(28874),f=i(89782),m=i(13940),p=(0,n.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,r.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,n.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:h.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?s.minuteMs:void 0),e})),(0,a.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,f.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(h.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:h.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(o.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const n=i(22573),r=i(54993),s=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,n.blank)(e)&&s.test((0,r.toS)(e))}},13940:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const n=i(51455),r=i(19851),s=i(42659),a=i(59455),o=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),v=i(55222),w=i(63870),S=(0,r.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,r.lazy)((()=>(b(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const b=(0,r.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,n){const r=await(0,t.imageCacheDir_)();i??(i=e.name),n=(0,c.ensurePrefix)(n??e.ext,".");const s=r.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await s.mkdirp_(),await s.utimes();const a=s.join(i+n);return S().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:n,result:a}),a}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,a.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,n.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),n=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+v.TokenRadix.randomChars(2),v.TokenRadix.randomChars(16)+(0,o.toS)(e.ext));return await n.parent().mkdirp_(),n},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:n}){return(await P(e,t,i)).applyIfEmpty_({fn_:n,timeoutMs:2*s.minuteMs})},t.withImageCache_=async function(e,t,i,n){try{const r=await P(e,t,i);return await r.applyIfEmpty_({fn_:n,skipFsLock:!1,skipWip:!1,timeoutMs:(0,w.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),r}catch(n){return S().throw("withImgCache_() failed",{error:n,src:e.nativePath,desc:t,ext:i})}}},48368:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashDim=t.toImageHash=t.isImageHash=t._imageHash_=t.imageHash_=t.imageHash=t.maxPerBits=void 0;const r=n(i(9288)),s=i(19851),a=i(40958),o=i(22573),l=i(42659),u=i(33374),c=i(56038),d=i(85810),h=i(76490),f=i(40401),m=i(86758),p=i(85434),g=i(96706),y=i(38835),v=i(88561),w=i(95696),S=i(17217),b=i(50213),P=i(23624),M=i(28874),_=i(12089),E=i(16170),x=i(1078),T=i(33106),D=i(86580),k=i(78011),C=i(50961);t.maxPerBits=function(e){return Math.floor(52/e)};const F=(0,s.lazy)((()=>(0,b.mkLogger)("img.ImageHash")));t.imageHash=async function(e){try{return await(0,t.imageHash_)((0,S.toNativePath_)(e))}catch(t){return void F().warn("imageHash() failed for "+e,t)}};const O=(0,s.lazy)((()=>new v.FileCache({name:"img.imageHash",timeoutMs:l.minuteMs})));async function I(e){const t=w.PosixFile.for(e),i=await(0,x.extractSizeInfoFromFile)(t);if(null==i)throw new Error("Failed to read dimensions for "+e+y.NonFatalErrorFlag+y.DoNotSendErrorFlag);const n=(0,D.fitToResolution)(i.dimensions,Math.round(M.Settings.dominantColorPixels.valueOrDefault)),s=await(0,C.sharpReadable_)({src:t,minDim:n});return(0,c.time)("img.imageHash",(()=>async function({file:e,readable:t,sizeInfo:i}){const n=(0,b.mkLogger)("ImageHash("+e+")");if(null==t)return n.throw("Cannot build readable stream");const s=(0,D.fitToResolution)(i.dimensions,M.Settings.dominantColorPixels.valueOrDefault);if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-orig.jpg";await(0,C.toSharp)(t).jpeg().toFile(i),console.log({out:i,readable:t})}let a=(0,C.toSharp)(t).removeAlpha();(0,E.isVideoMimeType)(t.mimetype)||(a=a.rotate(i.rotation)),(0,u.dmegapixels)(i.dimensions)<.1&&(a=a.trim({background:"#000",threshold:0})),a=a.resize({fit:r.default.fit.outside,...s,withoutEnlargement:!0});const{data:o,info:l}=await a.raw().toBuffer({resolveWithObject:!0});if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-"+l.width+"w.jpg";await(0,r.default)(o,{raw:{...l,channels:3}}).jpeg().toFile(i),console.log({out:i,rgbInfo:l,readable:t})}const c=(0,d.rgb2labTriplets)(o),h=(0,f.extractDominantColors)(c),p=(0,m.labsAreGreyscale)(c),y=()=>(0,r.default)(o,{raw:{...l,channels:3}}),v=await(p?k.meanDiffHash:k.meanDiffHashCIELAB)(y()),w=await(p?T.dctHash:T.dctHashCIELAB)(y());return{meanHash:(0,P.b64encodeBits)(v.meanHash),diffHash:(0,P.b64encodeBits)(v.diffHash),dctHash:(0,P.b64encodeBits)(w),dominantColors:h.dominantColors,dominantColorsDescription:h.description,dominantColorScore:h.dominantColorScore,isGreyscale:p,mimetype:(0,E.normalizeMimetype)(t.mimetype),...i.dimensions,rotation:i.rotation??0}}({file:t,readable:s,sizeInfo:i})))}function L(e){return null!=e&&(0,o.notBlank)(e.meanHash)&&(0,o.notBlank)(e.mimetype)&&(0,a.isNotEmpty)(e.dominantColors)}t.imageHash_=(0,_.shim1)({name:"img.imageHash",cache:O,impl:I}),t._imageHash_=I,t.isImageHash=L,t.toImageHash=function(e){if(null!=e){if(L(e))return e;if((0,p.isModeData)(e)){const t={...(0,p.omitModeData)(e),dominantColors:h.DominantColor.fromModeData(e)};if(L(t))return t}}},t.HashDim=8},42725:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ImageSize=void 0;const a=i(57975),o=i(19851),l=i(33374),u=i(12168),c=i(48884),d=i(28874),h=i(32876),f=i(5733);class m{static sq(){return s(this,n,"f",r).filter((e=>e.reducer===h.Square))}static largestSq(){return(0,c.greatestBy)(this.sq(),(e=>e.megapixels()))}static fit(){const e=d.Settings.previewResolutions.valueOrDefault;return s(this,n,"f",r).filter((t=>t.reducer===h.Fit&&e.includes(t.name)))}static largestFit(){return(0,c.greatestBy)(this.fit(),(e=>e.megapixels()))}static all(){return[...s(this,n,"f",r)]}constructor(e,t,i,a,l=!0){this.name=e,this.maxWidth=t,this.maxHeight=i,this.reducer=a,this.rotational=l,this.megapixels=(0,o.lazy)((()=>(0,u.megapixels)(this.maxWidth*this.maxHeight))),this.max={width:t,height:i},s(n,n,"f",r).push(this)}[a.inspect.custom](){return{ctor:"ImageSize",name:this.name+" ("+this.reducer.name+")",maxDim:this.maxWidth+"×"+this.maxHeight,maxMP:this.megapixels()}}get aspectRatio(){return this.maxWidth/this.maxHeight}get maxPixels(){return this.maxWidth*this.maxHeight}get minDimension(){return Math.min(this.maxWidth,this.maxHeight)}outputSize(e){return this.reducer.reduce(this.rotational&&(0,l.isPortrait)(e)?(0,l.dimSwap)(this.max):this.max,e)}resize(e,t){return t.resize({...e,fit:this.reducer.fit,withoutEnlargement:!0})}toJpeg({path:e,sh:t,outputSize:i}){return((0,l.dmegapixels)(i)<2||d.Settings.previewSharpen.valueOrDefault)&&(t=t.sharpen()),t.jpeg((0,f.sharpRenderOptions)()).toFile(e)}toString(){return this.name}}t.ImageSize=m,n=m,r={value:[]},m.UHD8k=new n("uhd8k",7680,4320,h.Fit,!1),m.UHD5k=new n("uhd5k",5120,2880,h.Fit,!1),m.UHD=new n("uhd4k",4096,2160,h.Fit),m.QHD=new n("qhd",3120,1440,h.Fit),m.FHD=new n("fhd",1920,1080,h.Fit),m.HD=new n("hd",1280,720,h.Fit),m.WVGA=new n("wvga",720,480,h.Fit),m.QVGA=new n("qvga",320,240,h.Fit),m.QQVGA=new n("qqvga",160,120,h.Fit),m.S480=new n("s480",480,480,h.Square),m.S240=new n("s240",240,240,h.Square),m.S120=new n("s120",120,120,h.Square),m.S60=new n("s60",60,60,h.Square)},4192:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includePreviewTags_=void 0;const n=i(19851),r=i(40958),s=i(68708),a=i(50213),o=i(56038),l=i(28874),u=i(47783),c=(0,n.lazy)((()=>(0,a.mkLogger)("img.includePreviewTags")));t.includePreviewTags_=async function(e,t){!1===l.Settings.includePreviewTags.valueOrDefault||l.Settings.includedPreviewTags.isEmpty()||(0,r.isEmpty)(t)||(c().info("Re-adding metadata to previews..."),await(0,o.time)("img.includePreviewTags",(async()=>{const i=(0,s.pick)(await(0,u.readTags)(e),...l.Settings.includedPreviewTags.values),n=i?.capturedAt;null!=n&&(delete i.capturedAt,(0,s.assignFields)(i,n.asExifTag()));const r=i?.exposureSettings;null!=r&&(delete i.exposureSettings,i.FocalLength=r.focalLength,i.FNumber=r.aperture,i.ExposureTime=r.shutterSpeed,i.ISO=r.iso),l.Settings.includedPreviewTags.has("Source")&&(i.Source=e.nativePath),(0,s.isEmptyObj)(i)?c().warn("not adding tags to previews: no values for tags in source file",{src:e,includedPreviewTags:l.Settings.includedPreviewTags.values}):(c().info("Overwriting preview tags...",{src:e,writeTags:i}),await Promise.all(t.map((e=>(0,u.overwriteTags_)(e,i)))))})))}},78011:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.meanDiffHashCIELAB=t.meanDiffHash=t.dhash=t.mhash=void 0;const r=n(i(9288)),s=i(96249),a=i(59455),o=i(85810),l=i(70417),u=i(48368);function c(e){const t=(0,l.avg)(e);return null==t?[]:(0,a.toA)(e).map((e=>e>=t?1:0))}function d(e){const t=(0,a.toA)(e),i=Math.round(Math.sqrt(t.length));return t.map(((t,n)=>t>=(0===n?e[i]:n%i==0?e[n-i]:e[n-1])?1:0))}t.mhash=c,t.dhash=d,t.meanDiffHash=async function(e,t=u.HashDim){const i=await e.greyscale().resize({fit:r.default.fit.fill,width:t,height:t}).raw().toBuffer();return{meanHash:c(i),diffHash:d(i)}},t.meanDiffHashCIELAB=async function(e,t=u.HashDim){const i=await e.resize({fit:r.default.fit.fill,width:t,height:t}).raw().toBuffer(),n=(0,o.rgb2labArray)(i);return{meanHash:(0,s.flatten)(n.map(c)),diffHash:(0,s.flatten)(n.map(d))}}},52121:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t._prepFileForBrowser=t.prepFileForBrowser=void 0;const n=i(19851),r=i(78923),s=i(95696),a=i(50213),o=i(28874),l=i(12089),u=i(16170),c=i(13940),d=i(4192),h=i(5733),f=i(50961),m=(0,n.lazy)((()=>(0,a.mkLogger)("img.PrepareFileForBrowser")));async function p(e){try{const t=s.PosixFile.for(e.nativePath);if(await t.notExists())return;const i=e.mimetype??(await(0,r.readFileType_)(t.nativePath))?.mime;return(0,u.isMimeTypeSupportedByBrowser)(i,e.userAgent)?t.nativePath:(m().info("prepFileForBrowser(): non-browser-supported mimetype",{file:t,info:e}),(await(0,c.withImageCache_)(t,"web",".jpg",(async e=>{const i=await(0,f.sharpReadable_)({src:t});if(null==i)throw new Error("prepFileForBrowser(): can't read "+t.nativePath);await(0,f.toSharp)(i).jpeg((0,h.sharpRenderOptions)()).toFile(e.nativePath),o.Settings.includePreviewTags.valueOrDefault&&await(0,d.includePreviewTags_)(t,[e])})))?.nativePath)}catch(e){return void m().warn("prepFileForBrowser() failed",{error:e})}}t.prepFileForBrowser=(0,l.shim1)({name:"img.prepFileForBrowser",impl:p}),t._prepFileForBrowser=p},48604:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.buildAssetPreviews_=t.Previews=void 0;const n=i(19851),r=i(55835),s=i(50213),a=i(12089),o=i(87290),l=i(95242),u=i(16524);class c{constructor(e){this.root=e}apb(e,t,i){return new l.AssetPreviewBuilder(this.ap(e),t,i)}ap(e){return new u.AssetPreviews(this.root,e)}}t.Previews=c,c.instance=(0,n.lazy)((()=>((0,s.mkLogger)("Previews").info(".instance()",{libraryPreviewsDir:(0,o.libraryPreviewsDirPosixFile)()}),(0,r.map)((0,o.libraryPreviewsDirPosixFile)(),(e=>new c(e)))))),t.buildAssetPreviews_=(0,a.shim1)({name:"img.buildAssetPreviews",impl:e=>c.instance().apb(e.assetId,e.assetFiles,e).build_()})},2090:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const n=i(40958),r=i(33374),s=i(31586),a=i(34666),o=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,s.isNumber)(e)?e:((0,s.toGt0)(e.width)??0)/((0,s.toGt0)(e.height)??0),(e=>(0,o.leastBy)(t.StandardAspectRatios,(t=>{const n=Math.abs(e-t);return n>i?void 0:n}))??e))}function c(e,i,n=t.RatioEpsilon){return(0,a.lt)((0,s.absdiff)(u(e),u(i)),n)}function d(e,i){return(0,o.leastByCtx)(t.Ratios,(t=>{const n=Math.abs(t.i-e);return n[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,r.maybeDimSwap)(e.dimensions,e.rotation),(0,r.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,s.sigFigs)(e,3))}},34943:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const n=i(19851),r=i(31586),s=i(80049),a=i(50213),o=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),h=(0,n.lazy)((()=>(0,a.mkLogger)("img.RawInfo"))),f=(0,n.lazy)((()=>new s.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:o.ShortCommandTimeoutMs})));async function m(e){return f().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,n,s,a]=e.split("\t"),o=(0,r.toGt0)(s),l=(0,r.toGt0)(a);return null==o||null==l?h().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):h().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:n,ImageSize:{width:o,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>f.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?f.prior()?.clear():f.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{h().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},32876:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Reducers=t.Fit=t.fitInsideToMaxPixels=t.fitInsideToAspectRatio=t.Square=t.SharpFits=void 0;const n=i(19851),r=i(33374),s=i(4188),a=i(11371),o=i(31586),l=i(68708),u=i(50989),c=i(50213),d=i(86580);var h,f;t.SharpFits=(0,u.strEnum)("cover","contain","fill","inside","outside"),function(e){const i=(0,n.lazy)((()=>(0,c.mkLogger)("img.Reducers.Square")));e.name=a.ReducerNames.sq,e.fit="cover",e.reduce=function(e,n){const r=(0,d.lteBoth)(e,n)?{...e,fit:t.SharpFits.cover}:void 0;return i().tap({msg:"reduce()",result:r,meta:{max:e,input:(0,l.pick)(n,"width","height","nativePath")}})}}(h||(t.Square=h={})),t.fitInsideToAspectRatio=function(e,t){return e.width/e.height>=t?{width:Math.floor(e.height*t),height:e.height}:{width:e.width,height:Math.floor(e.width/t)}},t.fitInsideToMaxPixels=function(e,t){if(null==e||!(0,o.gt0)(e.width)||!(0,o.gt0)(e.height))return;if((0,r.pixels)(e)(0,c.mkLogger)("img.Reducers.Fit")));e.name=a.ReducerNames.fit,e.fit="inside",e.reduce=function(e,i){if(!(0,d.ltBoth)(i,e))return(0,s.fitInside)(i,e);t().trace(`reduce(): input ${(0,r.fmtDim)(i)} is too small for ${(0,r.fmtDim)(e)}`)}}(f||(t.Fit=f={})),t.Reducers=[h,f]},5733:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const r=n(i(9288)),s=i(19851),a=i(41400),o=i(50213),l=i(28874),u=i(15674),c=(0,s.lazy)((()=>(0,o.mkLogger)("img.Sharp")));function d(e,t){return(0,r.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,s.lazy)((()=>{r.default.simd(l.Settings.enableSIMD.valueOrDefault),r.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),r.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,a.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const n=i(50989);t.SharpFailOns=(0,n.strEnum)("none","truncated","error","warning")},50961:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractImageForThumbs_=t.sharpReadable_=t.toSharp=t.imgFromExif_=t._imgFromExif_=void 0;const r=i(77988),s=n(i(9288)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(33374),d=i(98553),h=i(31586),f=i(68708),m=i(51926),p=i(41583),g=i(50213),y=i(97352),v=i(56519),w=i(56038),S=i(57159),b=i(95696),P=i(17217),M=i(28874),_=i(47783),E=i(16170),x=i(95141),T=i(54979),D=i(1078),k=i(63870),C=i(86580),F=i(277),O=i(16047),I=i(13940),L=i(5733),A=i(66106),R=i(19350),N=(0,a.lazy)((()=>(0,g.mkLogger)("img.SharpReadable")));async function B(e,t,i){return i?await(0,_.exiftool)().extractBinaryTagToBuffer(t,e.nativePath):(await j(e,t))?.nativePath}async function z(e,t,i,n,a){const o=t?.[i];if(!(o instanceof r.BinaryField))return;const l=o.bytes(0,_.extractBinaryTag)(t,e.nativePath,i.nativePath),timeoutMs:(0,k.commandTimeoutMs)()})}catch(i){return void N().throw("Failed to extract embedded "+t+" from "+e.nativePath,{error:i})}}t._imgFromExif_=B,t.imgFromExif_=z,t.toSharp=function(e){const t=e;if((0,L.isSharp)(t.sharp))return t.sharp;if((0,P.isSimpleFile)(t.file))return(0,s.default)(t.file.nativePath,{failOn:M.Settings.imageFailOn.valueOrDefault});throw new Error("toSharp(): not a Sharp object: "+(0,d.stringify)(e))},t.sharpReadable_=function(e){return(0,w.time)(`img.sharpReadable${e.src.ext.toUpperCase()}`,(()=>async function({src:e,minDim:t,skipEmbedded:i}){const n=N().addParameterContext(e.nativePath);(0,L.setupSharp)();const s=await(0,T.readMimeType)(e);if((0,u.blank)(s))return n.throw(e+" is not supported (missing MIMEType)",{doNotSend:!0});const a=await(0,D.extractSizeInfoFromFile)(e);if(null==a)return void n.warn("Failed to extract size info from "+e);const d=[];function f(e,t){t.desc=e,d.push(t)}const m=a.rotation,g=(0,E.isVideoMimeType)(s),b=(0,E.isLibrawMimeType)(s),P=a.dimensions,k=t??(0,y.map2Gt0)(P.width,P.height,((e,t)=>({width:Math.round(.9*e),height:Math.round(.9*t)})));if(null==k?.width||null==k?.height)return n.throw(e+" is not supported (missing dimensions)",{dim:k,doNotSend:!0,mimetype:s,isRaw:b,isVideo:g});const I=(0,C.aspectRatio)(a.fileDimensions),B=(0,h.lt)(I,1),j=(0,E.isSharpMimeType)(s)&&null==t,V=(0,x.orientationRequiresMirroring)(a.orientation);if(!0===i||g||B||j||V)n.debug("not pulling previews from tags",{isVideo:g,isFilePortrait:B,isSharpMimeAndNoMinDim:j,isMirrorOrientation:V});else{const i=!1,s=await(0,_.readRawTags)(e,i);if(null==s)n.warn("Cannot pull previews from tags: readRawTags() failed");else{const i=[...M.Settings.embeddedPreviews.values];null!=t&&(0,c.dmegapixels)(t)<1&&i.unshift(...M.Settings.embeddedThumbnails.values);const a=k.width*k.height*.2,u=k.width*k.height*.05,d=(0,l.sortBy)(i.filter((e=>s[e]instanceof r.BinaryField)),(e=>{const t=s[e]?.bytes;return(0,h.gt)(t,u)?Math.abs(t-a):void 0}));if(!(0,o.isEmpty)(d)){n.debug("checking previews from tags",{sizeSortedTagNames:d});for(const t of d)f("imgFromExif."+t,(()=>z(e,s,t,k,I)))}}}(0,E.isSharpMimeType)(s)&&f("sharp",(async()=>({file:e}))),(0,O.isHeifMimeType)(s)&&await(0,F.isHeifSupported)()&&f("heif",(()=>(0,v.thenMap)((0,F.heif2img)(e),(e=>({file:e}))))),b&&f("raw2tiff",(()=>(0,v.thenMap)((0,R.raw2tiff_)(e),(e=>({file:e}))))),g&&f("extractVideoFrame",(async()=>{if(await(0,A.isVideoSupported)())try{return await(0,v.thenMap)((0,A.extractVideoFrame_)(e),(e=>({file:e})))}catch(t){throw new S.WrappedError("Failed to extract video frame for "+e,t)}else n.warn("video file, but video support is missing",{src:e.nativePath,mimetype:s,minDim:t})}));const W=[];for(const i of d)try{const r=await(0,w.time)("img.read."+i.desc,i);if(null!=r)return n.debug(i.desc+" strategy succeeded",{src:e,minDim:t,rot:m,img:r.file?.nativePath}),{desc:i.desc,rot:m,mimetype:s,...r};n.debug(i.desc+" returned null",{src:e,minDim:t,rot:m})}catch(e){n.warn(i.desc+" failed",e),W.push((0,p.toErr)(e))}throw new S.WrappedError("Failed to render "+e,{causes:W,path:String(e),fatal:!1,doNotSend:!0,retriable:!1})}(e)))},t.extractImageForThumbs_=j},181:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.whyInvalidFile=t.clearInvalidFileCache=t.throwIfInvalidFile_=t.isValidFile=void 0;const r=n(i(9288)),s=i(19851),a=i(22573),o=i(42659),l=i(98553),u=i(50213),c=i(12089),d=i(81168),h=i(57159),f=i(88561),m=i(95696),p=i(17217),g=i(28874),y=i(16170),v=i(54979),w=i(63870),S=i(5733),b=i(50961),P=i(66106),M=i(51210),_=(0,s.lazy)((()=>(0,u.mkLogger)("img.ValidFile")));t.isValidFile=async function(e){return(0,a.blank)(await(0,t.whyInvalidFile)((0,p.toNativePath_)(e)))},t.throwIfInvalidFile_=async function(e){if(!g.Settings.validateJpegImages.valueOrDefault&&!g.Settings.validateRawImages.valueOrDefault&&!g.Settings.validateVideos.valueOrDefault)return void _().debug("file validation is disabled for "+e,{validateJpegImages:g.Settings.validateJpegImages.valueOrDefault,validateRawImages:g.Settings.validateRawImages.valueOrDefault,validateVideos:g.Settings.validateVideos.valueOrDefault});const i=(0,p.toNativePath_)(e),n=_().tap({msg:"whyInvalidFile("+i+")",result:await(0,t.whyInvalidFile)(i)});(0,a.notBlank)(n)&&_().throw(n,{path:i,retriable:!1,doNotSend:!0,ignorable:!0})};const E=(0,s.lazy)((()=>new f.FileCache({name:"img.validFile",maxSize:256,timeoutMs:Math.max(o.minuteMs,g.Settings.validateVideos.valueOrDefault?5*o.minuteMs:(0,w.commandTimeoutMs)())})));t.clearInvalidFileCache=function(){return E().clear()},t.whyInvalidFile=(0,c.shim1)({name:"img.whyInvalidFile",cache:E,toKey:p.toNativePath_,impl:async e=>{const t=m.PosixFile.for(e);if(!await t.isFile()||!await t.isReadable())return t+" is not a readable file";if(await t.isEmpty())return t+" is empty";try{const e=await(0,v.readMimeType)(t);if(null==e)throw new Error("Cannot validate, no mimetype");if((0,y.isVideoMimeType)(e))g.Settings.validateVideos.valueOrDefault&&(_().debug("validating "+t),await(0,P.validVideo_)(t));else{if(!e.startsWith("image/"))throw new Error("Unsupported mimetype "+(0,l.stringify)(e));if("image/jpeg"===e)g.Settings.validateJpegImages.valueOrDefault&&await(0,M.validJpeg_)(t);else if(g.Settings.validateRawImages.valueOrDefault)if((0,d.includesIgnoreCase)(g.Settings.validateMimetypeSkiplist.values,e))_().info("Skipping validation of "+t+": validateMimetypeSkiplist matches",{mime:e});else{const e=await(0,b.sharpReadable_)({src:t,skipEmbedded:!0}),i=await async function(e,t=g.Settings.imageFailOn.valueOrDefault){const i=e;if((0,p.isSimpleFile)(i.file))return(0,r.default)(i.file.nativePath,{failOn:t});if((0,S.isSharp)(i.sharp)){const{data:e,info:t}=await i.sharp.raw().toBuffer({resolveWithObject:!0});return(0,r.default)(e,{...t,failOnError:!0})}throw new Error("Cannot read input "+e?.desc)}(e);await i.tiff().toBuffer()}}return""}catch(t){return new h.WrappedError("Failed to validate",{cause:t,path:e,doNotSend:!0}).toS()}}})},19769:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const n=i(19851),r=i(40958),s=i(41400),a=i(50213),o=i(68852),l=i(98314),u=i(28874),c=(0,n.lazy)((()=>(0,a.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:h().test(t)||!d().test(t),meta:{err:e,allow:h().test(t),block:d().test(t),validationErrorAllowlist:h().source,validationErrorBlocklist:d().source}})};const d=(0,n.lazy)((()=>(0,o.orRegExpPatterns)((0,r.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),h=(0,n.lazy)((()=>(0,o.orRegExpPatterns)((0,r.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,s.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>h.unset()))}))},66106:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const n=i(19851),r=i(40958),s=i(38639),a=i(42659),o=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),h=i(7282),f=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),v=i(56038),w=i(31562),S=i(34102),b=i(88561),P=i(95696),M=i(17217),_=i(31843),E=i(70417),x=i(33847),T=i(28874),D=i(94678),k=i(43207),C=i(47783),F=i(16170),O=i(95141),I=i(1078),L=i(63870),A=i(89782),R=i(13940),N=i(34592),B=(0,n.lazy)((()=>(0,d.mkLogger)("img.Video")));function z(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function j(e){return(0,h.isProd)()&&(e=void 0),(0,s.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=j,t.isVideoSupported=(0,n.lazy)((async()=>{try{return!0===(await j())?.isSupportedVersion}catch(e){return B().warn("isVideoSupported",{error:e}),!1}})),(0,o.later)((()=>(0,S.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,_.lerp2d)(e,{x:76800,y:T.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:T.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,n.lazy)((()=>new b.FileCache({name:"img.videoFrame",timeoutMs:a.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,M.toNativePath_)(e))):void 0}async function H(e,t){const i=z("extractVideoFrame",e),n=P.PosixFile.for(e);if(!(0,s.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const r=await(0,R.cachedImageFile_)(n,"frame",".jpg");i.debug("extractVideoFrame("+r+")");const o=await n.mtimeMs();if(null==o)return i.throw("null mtime");const l=await(0,C.readRawTags)(n,!1);if(null==l)return i.throw("no tags");const u=(0,O.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,I.extractSizeInfoFromTags)(l,u)?.dimensions,d=await r.stat(),h=null==d?void 0:await(0,A.dimensions)(r);if(null!=d&&d.mtimeMs>o&&null!=h&&(null==c||h.height===c.height&&h.width===c.width))return i.debug("prior dest, "+r+" seems reasonable",{srcDim:c,destDim:h}),r.nativePath;const f=(0,k.extractDurationSec)(l),m=Math.min(f??0,T.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:f}),await r.applyIfEmpty_({fn_:async e=>{const t={src:n,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,w.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*a.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,C.deleteAllTags_)(e,e)},timeoutMs:(0,L.commandTimeoutMs)()}),r.nativePath}async function U(){return T.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function q(e){const t=z("needsTranscoding",e);if(!await U())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,C.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const n=i.MIMEType;if(!(0,F.isVideoMimeType)(n))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:n}});const s=(0,k.extractDurationSec)(i);if(!(0,c.gt)(s,T.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:s}});const a=(0,r.compactBlanks)([i.AudioFormat]),o=a.some((e=>(0,p.includesIgnoreCase)(T.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,r.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(T.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(T.Settings.doNotTranscodeMimeTypes.values,n);return t.tap({level:"info",msg:"result",result:!(o&&u&&d),meta:{mimetype:n,isSafeMimeType:d,audioCodecs:a,isSafeAudioCodec:o,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>H(e)}),t.__extractVideoFrame_=H,t.isVideoTranscodingSupported=U,t.needsTranscoding=q;const G=new g.TTLMap(a.hourMs);function $(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,n){if(!await U())return;const r=z("transcode",e);{!function(){for(const[e,t]of G.entries())t.isSettled&&G.delete(e)}();const t=G.get(e.nativePath)??G.get(i.nativePath);if(null!=t)return r.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await q(e))return void r.info("no transcoding needed");const s=await e.size();if(!(0,u.gt0)(s))return r.throw("source is empty or cannot read");const a=await(0,C.readTags)(e),o=(0,I.extractSizeInfoFromTags)(a),d=(0,k.extractDurationSec)(a);if(null==a||null==o||null==d)return r.throw("failed: missing video metadata",{sizeInfo:o,durationSec:d});{const e=G.get(i.nativePath);if(null!=e)return r.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const h=new y.Deferred("transcode "+e);G.set(e.nativePath,h),G.set(i.nativePath,h);const m=(0,u.toGt0)(a.VideoFrameRate)??(0,u.toGt0)(a.FrameRate)??30,p=Math.round(o.dimensions.width*o.dimensions.height*(0,E.max)([(0,u.toGt0)(a.FrameCount),(0,u.toGt0)(a.VideoFrameCount),m*d]));if(!0===n?.force)await i.unlink();else if(await async function(e,t){const i=await(0,C.readRawTags)(t),n=await(0,C.readRawTags)(e),r=(0,k.extractDurationSec)(n),s=(0,k.extractDurationSec)(i);return B().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(r,s,1.5),meta:{srcDurationSec:r,destDurationSec:s,src:e.nativePath,dest:t.nativePath}})}(e,i))return r.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const n=z("extractMaxBitrate",e),r=T.Settings.minVideoDimension.valueOrDefault,s=i.ImageWidth;if(null!=s&&!(0,u.gte)(s,r))return n.throw("invalid width: "+s,{ignorable:!0});const a=i.ImageHeight;if(null!=a&&!(0,u.gte)(a,r))return n.throw("invalid height: "+a,{ignorable:!0});const o=(0,D.extractBitrateKbps)(i)??T.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,f.mapGt0)(s,(e=>(0,f.mapGt0)(a,(i=>(0,u.clamp)(0,o,(0,t.bitrateKps)(e*i)))))),c={width:s,height:a,videoBitrateKbps:l};return n.debug("dim()",{src:e,result:c}),c}(e,a);return await h.observe((0,v.time)("video.transcode:"+e,(async()=>{const t=$(s,g.videoBitrateKbps,d);return await i.applyWip_({fn_:s=>async function(s){r.info("starting...",{destWip:s});const o=new x.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:s,fps:m,halt:n.halt,...g},h=T.Settings.transcodeMaxDim.valueOrDefault,f=(0,E.max)([a.dimensions.height,a.dimensions.width]);if((0,u.gt0)(h)&&(0,c.gt)(f,h)){const e=(0,l.fitInside)(a.dimensions,{width:h,height:h});null==e?r.warn("Cannot downsample transcoded video: fitInside() returned null",{input:a.dimensions,maxPixels:h}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),r.info("Downsampling transcoded video",{original:a.dimensions,output:e}))}const p=await o.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&r.throw("transcode failed with code "+p.code)}(s),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&r.info("transcode complete",{src:e,dest:i,elapsedMs:h.elapsedMs,pixels:p}),i},t.guessExpectedSize=$,t.validVideo_=async function(e){return null==await W(e)&&z("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const n=i(40958),r=i(22573),s=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),h=i(56519),f=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),v=i(84258),w=i(28874),S=i(76280),b=i(63870),P=i(19769),M=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function _(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:w.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=_;const E=/ffmpeg version n?(?\S+)/i,x=(0,u.lazy)((async()=>{const e=await _();if(null==e)return void M().info("failed to find ffmpeg in $PATH",{ffmpegPath:w.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,b.commandTimeoutMs)(),ignoreStderr:!0}),i=E.exec(t.result)?.[1];return M().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,S.semverSatisfies)(i,">=3.2")}}));function T(){x.unset(),t.ffmpegVersionDescription.unset()}function D(e){const t=e?.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault;return(0,r.blank)(t)||(0,s.isDisabled)(t)?[]:["-hwaccel",t]}function k(e){const t=[...w.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(w.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),n=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+n),t}function C(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function F(e){const t=w.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,h.thenMapOr)(x(),(e=>"version "+e),(()=>"(not found)")))),(0,o.later)((()=>{(0,g.ee)().on("clearCache",T),(0,g.ee)().on("clearToolCache",T)})),t.ffmpegVersion_=async function(){return await x.prior()??x.refresh()},t.isFFmpegSupported=async function(){return null!=await x()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,n.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:a.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,f.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*a.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=k,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,n.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...k(t),...F(t),...D(t),"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...C(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){M().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,v.unlink)(t.dest,"debug");const n=(0,p.errorToS)(i,{maxLen:1024});if(!(0,s.isDisabled)(t.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(n))return M().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return M().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await _(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},51210:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rotate_=t.rotateInPlace_=t.validJpeg_=t.jpegtranVersion_=void 0;const n=i(19851),r=i(42659),s=i(21605),a=i(50213),o=i(84777),l=i(57159),u=i(95696),c=i(89966),d=i(43334),h=i(63870),f=i(19769),m=d.isWin?"NUL":"/dev/null",p=(0,n.lazy)((()=>(0,a.mkLogger)("img.jpegtran")));async function g(e,t,i){const n=await(0,c.jpegtranNativePath_)();if(!(0,s.isRotation)(i))throw new Error("refusing to rotate("+e+", "+i+")");await(0,o.stdout_)(n,["-copy","all","-trim","-rotate",i.toFixed(0),"-outfile",t.nativePath,e.nativePath],{timeoutMs:r.minuteMs}),t.clear()}t.jpegtranVersion_=async function(){const e=await(0,o.stdoutResult_)(await(0,c.jpegtranNativePath_)(),["-version"],{quiet:!0,timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:()=>!0});return(e.stderr??e.result).replace(/^libjpeg-turbo version/,"").trim()},t.validJpeg_=async function(e){const t=u.PosixFile.for(e),i=await(0,c.jpegtranNativePath_)();try{await(0,o.stdoutResult_)(i,["-outfile",m,t.nativePath],{timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:f.isIgnorableValidationError,ignoreExitCode:!0})}catch(e){throw p().warn("validJpeg caught invalid file",{src:t,cause:e}),new l.WrappedError("Invalid JPEG: "+t,{cause:e,path:t.nativePath,doNotSend:!0,fatal:!1,retriable:!1})}},t.rotateInPlace_=async function(e,t){p().info("rotateInPlace("+e+")",t),await e.applyWip_({fn_:i=>g(e,i,t),skipFsLock:!1,minSizeBytes:512,timeoutMs:r.minuteMs})},t.rotate_=g},19350:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dcraw_emu_=t.raw2tiff_=t.librawSupported=void 0;const n=i(19851),r=i(40958),s=i(33374),a=i(12168),o=i(23541),l=i(54993),u=i(50213),c=i(84777),d=i(98314),h=i(38835),f=i(57159),m=i(89966),p=i(28874),g=i(16170),y=i(54979),v=i(89782),w=i(13940),S=i(42725),b=i(19769),P=(0,n.lazy)((()=>(0,u.mkLogger)("img.libraw")));t.librawSupported=async function(e){try{return(0,g.isLibrawMimeType)(await(0,y.readMimeType)(e.nativePath))}catch(t){return P().warn("librawSupported("+e+"): failed to read filetype",t),!1}},t.raw2tiff_=async function(e){return(0,w.readableToFile_)({src:e,desc:"dcraw",suffix:".tiff",f:t=>T(e,t)})};const M=["-T"],_=["-Z","-"],E=["-o","1"],x=["-t","0","-j"];async function T(e,t){const i=await(0,v.dimensions)(e);if(null==i)return P().throw("Cannot decode RAW "+e+": no EXIF dimensions."+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);const n=S.ImageSize.largestFit().outputSize(i),u=[];null!=n&&4*(0,s.dmegapixels)(n)<(0,s.dmegapixels)(i)&&(P().debug("Large original source: using -h"),u.push("-h"));const g=await(0,m.dcrawEmuNativePath_)(),y=[...M,..._,...E,...u,...x,...p.Settings.dcrawEmuArgs.values,e.nativePath],w={encoding:"buffer",timeout:p.Settings.taskTimeoutMs.valueOrDefault,maxBuffer:250*a.MB};P().debug("dcraw_emu()",{cmd:g,args:y,opts:w});const T=(0,c.execFile)(g,y,void 0,w),D=[];function k(t){const i=(0,o.isError)(t)?(0,d.errorToS)(t):(0,l.toS)(t);if((0,b.isIgnorableValidationError)(i))P().info("dcraw_emu(): warning",{src:e,msg:i});else{P().warn("dcraw_emu(): error",{src:e,msg:i});const n=(0,o.isError)(t)?t:(0,f.toWrappedError)(i,{fatal:!1});D.push(n)}}if(T.on("error",k),T.stderr.on("data",k),await t.writeStream_(T.stdout),(0,r.isNotEmpty)(D))throw new f.WrappedError("Failed to convert RAW image "+e,{causes:D,path:e.nativePath});(0,c.endProcess)(T)}t.dcraw_emu_=T},36192:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const n=i(19851),r=i(84777),s=i(8103),a=i(43334),o=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,n.lazy)((async()=>a.isMac?(0,s.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,r.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(o.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},49794:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const n=i(57975),r=i(19851),s=i(40958),a=i(22573),o=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,r.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,a.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,n.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,s.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,n){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:n})}}},32105:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const n=i(19851),r=i(23560),s=i(66184),a=i(72210);class o{log(e,t,i,n){this.enabled(e,t)&&(0,a.pushLogEntries)({ts:Date.now(),l:e,from:(0,r.processName)(),ctx:t,msg:i,meta:n})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=o,o.instance=(0,n.lazy)((()=>new o))},14593:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const n=i(57975),r=i(22573),s=i(26905),a=i(55835),o=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,r.toNotBlank)(e)??(0,s.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[n.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,o.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const n=e.result(),r=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:n,meta:{...e.meta,elapsedMs:r}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,a.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,o.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const n of this.loggers())n.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const n=i(50213),r=i(43705);t.currentFileLogger=function(){return(0,n.rootLoggers)().find((e=>e instanceof r.LogWriter))}},28981:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const n=i(19851),r=i(51879);t.DefaultLogFormatter=(0,n.lazy)((()=>new r.PlaintextLogFormatter))},31256:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(41400),o=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,n.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,s.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,a.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,r.uniq)((0,r.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,o.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,o.stringify)(t)])))})}format(e,t,i,n){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:n})}}},51576:function(e,t,i){var n,r=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const s=i(77030),a=i(19851),o=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),v=i(31256),w=i(28538),S=(0,a.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),b=String.fromCharCode(0);t.logBroadcaster=(0,a.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,o.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&S().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),n.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,s.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{S().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){S().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),r(this,n,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,s){if(this.enabled(e,t))try{const a=this.socket;null==a?r(this,n,"f").call(this):a.write(this.logFormatter.format(e,t,i,s)+b)}catch(n){S().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:s,error:n})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}n=new WeakMap},20839:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const n=i(76760),r=i(42659),s=i(28874);t.datedLogDir=function(e,t){return(0,n.join)(e??s.Settings.logDir.valueOrDefault,(0,r.fmtIsoDate)(t??new Date))}},4904:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const n=i(76790),r=i(31586),s=i(51926),a=i(57902);t.isLogEntry=function(e){return null!=e&&(0,r.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&a.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,n.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const n=i(19851),r=i(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,r.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,r.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,n.lazy)((()=>new s(r.LogLevels.warn))),t.defaultLogLevel=(0,n.lazy)((()=>r.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,r.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){var n,r,s,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){n.add(this),this.setting=e,this.silent=!1,r.set(this,[]),s.set(this,(0,l.lazy)((()=>{o(this,r,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:o(this,r,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>o(this,s,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=o(this,n,"m",a).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=o(this,n,"m",a).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},r=new WeakMap,s=new WeakMap,n=new WeakSet,a=function(e){if(null==e||0===o(this,r,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return o(this,r,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const n=i(42659),r=i(31586),s=i(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const a=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??a},t.levelGte=function(e,i){return(0,r.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const o=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return o.get(e)},t.msTolevel=function(e,t=7*n.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const n=i(40958),r=i(68708),s=i(20214),a=i(51926),o=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,a.isString)(i)||Buffer.isBuffer(i))return(0,a.ellipsize)(i.toString(),256,32);if((0,o.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,n=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,n).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-n).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,s.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const o=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,r.keys)(i),(0,r.keys)(o));return(0,n.isNotEmpty)(c)&&(o["…"]="omitted: "+(0,a.ellipsize)(c.join(", "),128,32)),o}return i}},24068:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const n=i(73024),r=i(76760),s=i(1708),a=i(87997),o=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),v=i(22277),w=i(25764),S=i(38836),b=i(99331),P=i(42638),M=i(76596),_=i(98314),E=i(89968),x=i(29882),T=i(28874),D=i(28981),k=i(20839),C=i(21727),F=i(66184),O=i(57902),I=i(72210),L=i(98192);function A(e){const t=(0,D.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=A;class R extends S.EndableWrapper{constructor(e=void 0,t=A){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,o.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,T.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,x.mkdirp_)(e),this.root=await E.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=r.sep+(0,p.serviceName)()+"-"+s.pid+"-",s.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,a.setInterval)((()=>this.flush()),k.DefaultLogFlushMs/2),this.scanTimeout=(0,a.setInterval)((()=>this.scan()),u.minuteMs),s.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,b.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,F.ifLog)(O.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,n.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,r.join)(e,i))}))}catch(t){return void(0,F.ifLog)(O.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,_.errorToS)(t))))}}))}async scan(e=!1){if((0,b.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,M.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,b.ending)()||this.ended)return;const t=(0,C.datedLogDir)(this.root.nativePath);try{await(0,x.mkdirp_)(t),this.watchDir(t)}catch(e){(0,F.ifLog)(O.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,_.errorToS)(e))))}(0,b.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,a.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,a.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await E.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const n=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(n,i))return;await(0,f.thenMap)((0,L.readLogEntries)(e,{start:n,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,F.ifLog)(O.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,_.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,o.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const n=i(92322),r=i(82328),s=i(28981),a=i(20839),o=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new n.SortedSet(o.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,r.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*a.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){var n,r,s,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),v=i(31586),w=i(409),S=i(23560),b=i(81168),P=i(78406),M=i(25764),_=i(20197),E=i(14977),x=i(36868),T=i(28874),D=i(32105),k=i(20839),C=i(21727),F=i(66184),O=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,n){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:n})}enabled(){return!0}end(){}async flush(){}};class L extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*k.DefaultLogFlushMs),rank:M.EndableRanks.logger,unref:!0,onEnd:()=>c(this,r,"f").call(this)}),n.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,r.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,n,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:D.ConsoleLogger.instance(),flushEveryMs:k.DefaultLogFlushMs,processName:S.processName,logFilter:F.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,n,"m",s).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,n){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,n);else{const r={ts:Date.now(),l:e,ctx:t,msg:i};null!=n&&(r.meta=(0,O.prepMeta)(n)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(r)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=L,r=new WeakMap,n=new WeakSet,s=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,n,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),r=e.splice(0,i);this._linesSinceRotate+=r.length,t.write(r.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},a=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},o=function(e){return t=>(c(this,n,"m",a).call(this,e,t),c(this,n,"m",u).call(this))},l=async function(){await c(this,n,"m",u).call(this);const e=(0,b.stripAnsiEsc)(this.logOpts.processName()),t=await(0,_.ensureNewNativePath_)({nativePath:(0,f.join)((0,C.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,n,"m",o).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,x.endStream)(e.stream),T.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,E.gzip_)(e.nativePath))}catch(e){c(this,n,"m",a).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const n=i(57975),r=i(40958),s=i(55835),a=i(68708),o=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,a.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,r.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,n.inspect)(e,this.inspectOptions)))]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,n){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:n})}}},98192:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const n=i(22573),r=i(84542),s=i(4001),a=i(13047),o=i(4904);function l(e){if(!(0,n.blank)(e))try{const t=JSON.parse(e);return(0,o.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,s.stripCopySuffixFromName)(e.name),n=[],o=await(0,a.zcat)(e.nativePath,t);if(null!=o)for(const e of(0,r.splitLines)(o)){const t=l(e);null!=t&&n.push({...t,from:i})}return n},t.chunkToLogEntry=l},22662:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const n=i(19851),r=i(76790),s=i(68708),a=i(89788),o=i(57902);t.SentLogLevels=(0,n.lazy)((()=>o.LogLevels.values.filter((e=>e!==o.LogLevels.trace))));const l=(0,n.lazy)((()=>(0,s.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new a.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,s.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,s.values)(l()))e.push(...t.toA());return(0,r.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const n=i(76760),r=i(41400),s=i(55835),a=i(37975),o=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),v=i(66184),w=i(28538),S=i(24068),b=i(43705),P=i(51879);function M(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),_();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,n.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new b.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,s.map)((0,y.logBroadcaster)(),(e=>i.push(e))),o.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&S.LogTail.instance()}function _(){const e=h.Settings.logColor.valueOrDefault;(0,a.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=M,t.setupLogFormatter=_,(0,r.later)((()=>{h.Settings.logStdout.watchLater(M),h.Settings.logDir.watchLater(M),h.Settings.tailLogs.watchLater(M),h.Settings.logColor.watchLater(_),h.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},82647:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const a=i(57975),o=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const n=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...n),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...n]),i}}constructor(e=20){n.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(n=new WeakSet,a.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,n,"m",r).call(this,-1)}get p29(){return s(this,n,"m",r).call(this,-.5)}get p38(){return s(this,n,"m",r).call(this,-.25)}get p69(){return s(this,n,"m",r).call(this,.5)}get p84(){return s(this,n,"m",r).call(this,1)}get p98(){return s(this,n,"m",r).call(this,2)}get p99(){return s(this,n,"m",r).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,o.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,o.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,o.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,r=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const n=i(40958),r=i(55835),s=i(31586),a=i(30976),o=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),n=[];for(;e>0;)n.unshift(e%i),e=Math.floor(e/i);return n}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,s.clamp)(0,i,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,r.map2)(e,t,((e,t)=>(0,n.sum)((0,o.zip)(u(e,i),u(t,i)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,a.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),n=this.dims.map((e=>e.max)),r=this.clampValue(e);let s=0;for(let e=0;ea?(s+=1,i[t]=a):n[t]=a}return s}unzip(e,t){const i=this.dims.map((e=>e.min)),n=this.dims.map((e=>e.max));for(let r=0;r(i[e]+n[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;is?(t+=1,r.min=s):r.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,n.sum)(e,((i,n)=>t(i,n)?Math.pow(2,e.length-n-1):0))}},44983:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.kmeans=void 0;const n=i(76790),r=i(93973);t.kmeans=function(e,t,i){const s=r(e,t,i);return{...s,centroids:(0,n.sortBy)(s.centroids.filter((e=>e.size>0)),(e=>-e.size))}}},31843:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const n=i(76790);function r(e,t,i=.5){return(1-i)*e+i*t}t.lerp=r,t.lerp2d=function(e,...t){const i=(0,n.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[s,a]=(0,n.sortBy)(i,(e=>e.x)),o=a.x-s.x,l=(e-s.x)/o;return r(s.y,a.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},75503:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.modeReduce=t.submatrixCollect=t.greatestHalf=t.leastVariantQuarter=t.leastMagQuarter=t.submatrixMode=t.submatrixStdDev=t.submatrixMagnitude=t.submatrixForEach=t.index1D=t.slice=t.matXvec=t.vecXvec=void 0;const n=i(40958),r=i(31586),s=i(48884),a=i(82647),o=i(70417);function l(e,t,i,n){const r=Math.floor(Math.max(0,t.row)),s=Math.ceil(Math.min(e.row,i.row)),a=Math.floor(Math.max(0,t.col)),o=Math.ceil(Math.min(e.col,i.col));for(let t=r;t(0,r.mapFinite)(e[t],(e=>s+=e*e)))),Math.sqrt(s)}function c(e,t,i,n){const s=new a.Average;return l(t,i,n,(t=>(0,r.mapFinite)(e[t],(e=>s.push(e))))),s.stdDev}function d(e,t,i,n){const s=[];return l(t,i,n,(t=>(0,r.mapFinite)(e[t],(e=>s.push(e))))),(0,o.mode)(s)}t.vecXvec=function(e,t){return e.map(((e,i)=>e*t[i]))},t.matXvec=function(e,t){return e.map(((e,i)=>{if(e.length!==t.length)throw new Error("misshaped matrix on row "+i);return(0,o.sumf)(e,((e,i)=>e*t[i]))}))},t.slice=function(e,t,i){const r=Math.max(0,t.row),s=Math.min(e.length,i.row),a=Math.max(0,t.col),o=Math.min(e[0].length,i.col);return(0,n.range)(r,s,(t=>e[t].slice(a,o)))},t.index1D=function(e,t,i){return t*e.col+i},t.submatrixForEach=l,t.submatrixMagnitude=u,t.submatrixStdDev=c,t.submatrixMode=d,t.leastMagQuarter=function(e,t){const i=t.col,n=t.row,r=[u(e,t,{col:i/2,row:0},{col:i,row:n/2}),u(e,t,{col:0,row:0},{col:i/2,row:n/2}),u(e,t,{col:0,row:n/2},{col:i/2,row:n}),u(e,t,{col:i/2,row:n/2},{col:i,row:n})];return(0,s.leastIndex)(r)},t.leastVariantQuarter=function(e,t){const i=t.col,n=t.row;return(0,s.leastIndex)([c(e,t,{col:i/2,row:0},{col:i,row:n/2}),c(e,t,{col:0,row:0},{col:i/2,row:n/2}),c(e,t,{col:0,row:n/2},{col:i/2,row:n}),c(e,t,{col:i/2,row:n/2},{col:i,row:n})])},t.greatestHalf=function(e,t){const i=t.col,n=t.row,r=[d(e,t,{col:0,row:0},{col:i,row:n/2}),d(e,t,{col:0,row:0},{col:i/2,row:n}),d(e,t,{col:0,row:n/2},{col:i,row:n}),d(e,t,{col:i/2,row:0},{col:i,row:n})];return(0,s.greatestIndex)(r)},t.submatrixCollect=function(e,t,i){const n=[];return l(e,t,i,(e=>n.push(e))),n},t.modeReduce=function(e,t,i){const o=Math.floor(t.col/i.col),u=Math.floor(t.row/i.row),c=new a.Average(Math.ceil(o*u));return(0,s.concat)(...(0,n.stepRange)(0,t.row,u,(i=>(0,n.stepRange)(0,t.col,o,(n=>(c.clear(),l(t,{col:n,row:i},{col:n+o,row:i+u},(t=>(0,r.mapFinite)(e[t],(e=>c.push(e))))),c.sampleMode))))))}},55222:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const n=i(77598),r=i(22573),s=i(55835),a=i(32639),o=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const n=[];if(0===t)n.unshift(0);else for(;t>0;)n.unshift(t%e),t=Math.floor(t/e);for(;n.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let n=e;for(;n>u;)t.push(Number(n%i)),n/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,n)=>{i+=e<<8,t[n]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,r.blank)(e))return;const t="-"===(e=(0,a.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let n=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;n=n*i+BigInt(e)}return t?BigInt(-1)*n:n}randomChars(e){return this.encodeBuffer((0,n.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const n=this.normalizeToken(e),r=this.normalizeToken(t);return n.length>=i&&n===r}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const n=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,n.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const n=i(31586),r=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,n.toInt)(e)]??(0,r.toS)(e)}},17921:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const n=i(77598),r=i(65713);function s(){const e=(0,n.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=s,t.safeUUID=function(){return(0,r.decuss)(s)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const o=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function v(e,t){let i=0,n=0;for(const r of e){if(null!=r){const e=t(r,i);(0,u.isNumber)(e)&&(n+=e)}i++}return n}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=v;class w{constructor(){n.set(this,0),r.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(a(this,r,null==s(this,r,"f")?e:s(this,r,"f")*s(this,n,"f")/(s(this,n,"f")+1)+e/(s(this,n,"f")+1),"f"),a(this,n,(t=s(this,n,"f"),++t),"f"))}get mean(){return s(this,r,"f")}}function S(e){const t=new w;for(const i of e)t.push(i);return t.mean}function b(e){const t=S(e);if(null==t)return;let i=0,n=0;for(const r of e)(0,u.isNumber)(r)&&(n++,i+=(r-t)*(r-t));return i/n}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function M(e,t){let i=0;for(let n=0;n(1-t)*e+t*(i+a*(e-r)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=S(t);if(null!=i){const e=(t.length-1)/2,n=v(t,((t,n)=>(t-i)*(n-e))),r=v(t,(e=>(e-i)**2));return 0===r?0:n/r}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const n of e)i=null==i?n:i*t+n*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let n=0;ne[n]))));return i},t.l2norm=P,t.dot=M,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(M(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,o.isEmpty)(e)&&(0,o.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},23624:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.b64encodeBits=t.b64hammRatio=t.gz64decodeString=t.d=t.gz64encodeString=t.b64decode=t.b64encode=t.hex2b64=void 0;const n=i(38522),r=i(22573),s=i(97352);function a(e){const t=e.toString(16),i=t.length%2==0?"":"0";return Buffer.from(i+t,"hex").toString("base64")}function o(e){return BigInt("0x0"+Buffer.from(e,"base64").toString("hex"))}function l(e){return(0,n.gunzipSync)(Buffer.from(e,"base64")).toString("utf8")}t.hex2b64=function(e){return Buffer.from(e,"hex").toString("base64")},t.b64encode=a,t.b64decode=o,t.gz64encodeString=function(e){return(0,n.gzipSync)(Buffer.from(e,"utf8")).toString("base64")},t.d=l,t.gz64decodeString=l,t.b64hammRatio=function(e,t){return(0,r.mapNotBlank)(e,(e=>(0,r.mapNotBlank)(t,(t=>(0,s.hammRatioBigInt)(o(e),o(t))))))},t.b64encodeBits=function(e){return a(BigInt("0b0"+e.map((e=>1===e?"1":"0")).join("")))}},49076:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const r=n(i(48161)),s=i(19851),a=i(22573),o=i(41400),l=i(81168),u=i(28874);t.hostname=(0,s.lazy)((()=>u.Settings.hostname.value??r.default.hostname())),(0,o.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,a.blank)(e)&&!(0,a.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??r.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},96128:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const n=i(40610),r=i(19851),s=i(22573),a=i(42659),o=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),v=i(34102),w=i(26293),S=new RegExp("^"+w.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==S.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const b=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=b.exec(e)}function M(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=M,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,s.blank)(e)){if(null!=M(e))return[e];try{return await n.promises.resolve4(e)}catch(t){return void _().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs});const _=(0,r.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,o.later)((()=>(0,v.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=M(e)?n.promises.reverse(e):n.promises.resolve4(e),5*a.secondMs);if(t===c.Timeout)return _().info("nslookup("+e+"): timeout"),e;const i=t.find(s.notBlank);return null==i?(_().warn("No name found for "+e),e):i}catch(t){return _().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,s.blank)(e)&&!(0,s.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const n=i(22573),r=i(42659),s=i(31586),a=i(97790),o=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*r.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*r.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,s.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,a.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(n.notBlank).flatMap((e=>t.ipv4Re.exec((0,o.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*r.minuteMs})},78330:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const n=i(40958),r=i(22573),s=i(45599),a=i(59455),o=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),h=i(63870),f=(0,s.defer)((()=>(0,o.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,a.toA)(await async function(e){if(!(0,l.hasApt)()||(0,r.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return f().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,n.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,r.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(f().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const n=i(73024),r=i(38639),s=i(19851),a=i(59958),o=i(43334);t.isDocker=(0,s.lazy)((()=>o.isLinux&&((0,r.toBoolean)(process.env[a.PS_IS_DOCKER])??(0,n.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const n=i(76760),r=i(19851),s=i(54993);t.isPacked=(0,r.lazy)((()=>!(0,s.toS)(__filename).includes((0,n.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const n=i(45599),r=i(50213),s=i(84777),a=i(68284),o=i(63870),l=i(43334),u=(0,n.defer)((()=>(0,r.mkLogger)("platform.Pacman")));t.hasPacman=(0,n.defer)((()=>l.isLinux&&(0,a.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,s.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,o.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const r=n(i(48161)),s=n(i(1708)),a=i(22573),o=i(38639),l=i(59958),u=r.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,o.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,o.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,a.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===r.default.arch(),t.isArm=null!=/^arm\b/i.exec(r.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,a.notBlank)(s.default.env.APPIMAGE)||(0,a.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,a.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,o.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const r=n(i(73024)),s=i(19851),a=i(43334);function o(e="/proc/cpuinfo"){if(a.isWin||a.isMac)return!1;try{return null!=r.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=o,t.isRaspberryPi=(0,s.lazy)((()=>a.isLinux_arm&&o())),t.procDeviceModel=(0,s.lazy)((()=>{try{return a.isLinux?r.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},94137:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.negateFilterName=void 0;const n=i(22573),r=i(51926),s=i(83556);t.negateFilterName=function(e){if((0,n.blank)(e))return;const t=/\s/.test(e)?e:(0,s.camel2words)(e).replace(/\bphoto structure\b/gi,"PhotoStructure");return t.match(/^not\b/)?t.replace(/^not\b/,"").trim():"not "+(0,r.stripPrefix)(t,"is ")}},78984:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Predicates=void 0;const n=i(19851),r=i(40958),s=i(68708),a=i(51926),o=i(50213),l=i(94137),u=(0,n.lazy)((()=>(0,o.mkLogger)("predicates.Predicates")));class c{static async accepted(e,...t){for(const i of t)for(const t of(0,s.values)(i)){const i=await t(e);if(!1===i||(0,a.isString)(i))return!1}return!0}static async rejected(e,...t){return!await c.accepted(e,...t)}static async explain(e,...t){const i=[],n=[],r=[];for(const o of t)for(const[t,l]of(0,s.entries)(o)){const s=await l(e);!0===s?i.push(t):!1===s||(0,a.isString)(s)?n.push(t):r.push(t)}return{accepted:i,rejected:n,notApplicable:r}}static async whyRejected(e,...t){for(const i of t)for(const[t,n]of(0,s.entries)(i))try{const i=await n(e);if(null==i||!0===i)continue;return(0,a.isString)(i)?i:(0,l.negateFilterName)(t)}catch(e){u().warn("whyRejected() caught from "+t,{error:e})}}static async logged({a:e,logger:t,msg:i,predicates:n}){const{accepted:s,rejected:a}=await c.explain(e,...n);return t.tap({msg:i,result:(0,r.isEmpty)(a),meta:{a:e,accepted:s,rejected:a}})}}t.Predicates=c},33995:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SyncPredicates=void 0;const n=i(68708),r=i(94137);class s{static firstFalse(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))if(!1===r(e))return t}static firstTrue(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))if(!0===r(e))return t}static firstDefined(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i)){const i=r(e);if(null!=i)return{name:t,result:i}}}static accepted(e,...t){return null==s.firstFalse(e,...t)}static whyRejected(e,...t){return(0,r.negateFilterName)(s.firstFalse(e,...t))}}t.SyncPredicates=s},45643:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const n=i(58587),r=i(59455),s=i(31562);t.existingPids=function(e){return(0,r.toA)(e).filter(n.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,n.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){var n,r,s,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(97790),w=i(59455),S=i(54993),b=i(54557),P=i(19851),M=i(50213),_=i(88158),E=i(409),x=i(78406),T=i(25764),D=i(99331),k=i(56519),C=i(46292),F=i(8769),O=i(83278),I=i(32144),L=i(29882),A=i(43334),R=i(24399),N=i(58261),B=(0,P.lazy)((()=>(0,M.mkLogger)("proc.Pids"))),z=10*p.secondMs;function j(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),n=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(n)&&Math.abs(i-n){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,L.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))B().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,E.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{B().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??A.isWin,n=await this.pidfiles(),r=await this.pids(n??[]);if((0,f.isEmpty)(r))return B().info("killOldProcs(): no pidfiles"),[];const s=[],a=[],o=await(0,N.pidInfos)(r);if(null!=o){for(const r of n){const n=await r.readJson();if(null==n){B().warn("killOldProcs(): failed to read pidfile "+r.base),await r.unlink("debug");continue}const l=n.pid;if(!(0,y.gt0)(l)){B().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+r.base,{json:n,pid:l}),await r.unlink("debug");continue}const u=o.find((e=>e.pid===l));if(null==u||!j(n,u)){B().debug("killOldProcs(): pid no longer present: unlinking "+r.base,{json:n,pidEntry:u}),await r.unlink("debug"),s.push(n);continue}const c=(0,y.gt0)(n.timeoutMs)?n.startTime+n.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(n.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(B().info("killOldProcs(): killing",{reason:d,json:n}),a.push(W(l,i,!1)),s.push({...n,...u}))}return a.length>0&&await Promise.allSettled(a),s}(0,F.onError)("Pids.killOldProcs(): failed to get process information")}}),a.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const a=e.pid;if(!(0,y.gt0)(a))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(a)?(i&&o(this,r,"f").delete(l),o(this,r,"f").getOrSet(l,(async()=>{const i=o(this,n,"m",s).call(this,e.pid),r=(0,v.opt)((0,_.Try)((()=>(0,L.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),a=t.getTime(),l={...e,cmd:r,startTime:a};return await i.writeJson_(l),B().debug("addPid() wrote "+i,l),i}))):(o(this,r,"f").delete(l),void B().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=o(this,n,"m",s).call(this,e);return(0,k.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{B().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==o(this,a,"f")||o(this,a,"f").ended)&&l(this,a,new x.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:T.EndableRanks.first}),"f"),o(this,a,"f")}cancelInterval(){o(this,a,"f")?.end(),l(this,a,void 0,"f")}}t.Pids=H,r=new WeakMap,a=new WeakMap,n=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},H.instance=(0,P.lazy)((()=>(0,g.map)((0,C.configDir)(),(e=>new H(O.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return H.instance()?.addPid_(e,t)}},58261:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const r=i(31421),s=i(48161),a=n(i(1708)),o=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),v=i(84968),w=i(48963),S=i(56519),b=i(84777),P=i(8103),M=i(45879),_=i(43334),E=i(24399),x=i(45643),T=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function D(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function k(e){if(_.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,M.readFileMaybe)("/proc/"+i+"/stat")));return T().tap({msg:"pidInfoProc",result:(0,o.compact)(t)})}(e);const t=(0,x.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,_.isWin?I:N)).filter((e=>D(e)&&t.includes(e.pid)));return T().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=D,t.pidInfo=async function(e){return(0,S.thenMap)(k([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,o.isEmpty)(e)?[]:(0,S.thenMap)((0,x.existingPids)(e),(t=>{const i=[a.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=k;const C="Get-Process",F="| Select-Object -Property Id,ProcessName,StartTime";function O(e){return(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).join(",")}async function I(e){if(E.PowerShell.instance().ended)return R(e);const t=[C,"-Id",O(e),"-ErrorAction SilentlyContinue",F].join(" ");return(0,S.thenMap)(E.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const L={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},A=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,o.isNotEmpty)(e)){const i=(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",A.join(","));const i=await(0,b.stdoutResult_)((0,P.wmic)(),t,L),n=(0,d.onlyReqValued)((0,p.parseFixed)(A,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return n.find((e=>e.pid===a.default.pid))||n.push({pid:a.default.pid,start:new Date(v.StartTs),cmd:"node "+a.default.title}),n}async function N(e){return t=(await(0,b.stdoutResult_)("ps",["-p",O(e),"-wwwo","pid,lstart,command"],{...L,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const B=(0,g.lazy)((()=>{try{if(_.isLinux)return(0,c.toGt0)((0,r.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){T().warn("clk_tck failed",{error:e})}return 100})),z=(0,g.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),j=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=j.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),n=t?.comm,r=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(n)&&(0,c.gt0)(r)?{pid:i,cmd:n,start:new Date(z()+r/B()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const n=i(40958),r=i(22573),s=i(31586),a=i(29882),o=i(97352);t.progressEvtToS=function(e){const t=(0,r.blank)(e.path)?null:(0,a.ellipsizePath)({p:e.path,maxLength:80});return(0,n.compactBlanks)([t,e.op,!0===e.done?"done":(0,s.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,r.notBlank)(e.op)&&(0,o.within)(0,100,e.pct)}},41944:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const n=i(19851),r=i(42659),s=i(31586),a=i(12089),o=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,n.lazy)((()=>new o.TTLMap(15*r.secondMs))),t.recentDone=(0,n.lazy)((()=>new o.TTLMap(2*r.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,s.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,a.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const n=i(98553),r=i(31586),s=i(409),a=i(78406),o=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends a.EndableInterval{constructor(e,t,i,r=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,n.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:r,rank:o.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=r,this.start=Date.now(),this.onInterval=(0,s.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,r.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,r.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},38156:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PushProgressObserver=void 0;const n=i(31586),r=i(41944);t.PushProgressObserver=class{constructor(e,t){this.context=e,this.total=t,this.start=Date.now()}toJSON(){}incrProgress(e=1){this.onProgress(e+(this.current??0))}onProgress(e){this.current=(e??this.current??0)+1,(0,n.gte)(this.current,this.total)&&(this.done=!0),this.emit()}completed(){this.done=!0,this.current=this.total,this.emit()}emit(){(0,r.emitProgressEvt)({...this.context,pct:(0,n.pct)(this.current,this.total),elapsedMs:Date.now()-this.start,done:this.done})}}},24399:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const n=i(58587),r=i(19851),s=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),v=i(99331),w=i(56519),S=i(31562),b=i(84777),P=i(34102),M=i(43334),_=i(28874),E=i(63870),x="{ready}",T=" | ConvertTo-Json -Compress";function D(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=D,(0,o.later)((()=>(0,P.ee)().on("clearCache",(()=>k.instance.prior()?.clearMockResults()))));class k extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new n.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",_.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${x}"}`,...(0,s.mapNotBlankOr)(_.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:x,fail:"Error",exitCommand:"exit",maxProcs:_.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,E.commandTimeoutMs)(),maxIdleMsPerProcess:a.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),_.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(_.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,T),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new n.Task(e,((i,n,r)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),n,r)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,T),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+D(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=k,k.instance=(0,r.lazy)((()=>{if(!M.isWin)throw new Error("PowerShell isn't available on this platform");return new k})),t.checkPowerShell_=async function(){const e=k.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,E.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const n=i(50989);t.AggregateTypes=(0,n.strEnum)("union","intersection")},71988:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const n=i(50989);t.AssetFileSortCriteria=(0,n.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const n=i(22573),r=i(38639),s=i(83179);class a extends s.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:r.toBoolean})}}t.BooleanSetting=a},90536:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const n=i(22573),r=i(31586),s=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,r.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=o},75164:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const n=i(22573),r=i(31586),s=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(n.notBlank).flatMap(r.toInt).map((t=>(0,r.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,r.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=o},10546:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const n=i(50989);t.ColorDistanceFunctions=(0,n.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const n=i(36507),r=i(22573),s=i(45599),a=i(50213),o=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,s.defer)((()=>(0,a.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,o.trimQuotes)(e);return void((0,r.blank)(t)||(0,n.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,r.blank)(t)?void 0:(0,n.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const n=i(70488),r=i(91655),s=i(83179);class a extends s.Setting{constructor(e){super({...e,toEnv:n.encodeDuration,fromEnv:n.decodeDuration})}get valueOrDefault(){return(0,n.decodeDuration)(super.valueOrDefault)}get value(){return(0,n.decodeDuration)(super.value)}set value(e){super.userValue=(0,n.decodeDuration)(e)}get humanValue(){return(0,r.fmtFullDuration)(this.value)}get fileValue(){return(0,n.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,n.decodeDuration)(e)}}t.DurationSetting=a;class o extends s.Setting{constructor(e){super({...e,toEnv:n.encodeDuration,fromEnv:n.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,n.decodeDuration)(this.defaultValue)}get fileValue(){return(0,n.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=o},9945:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const n=i(22573),r=i(31586),s=i(83179);class a extends s.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:r.toFloat})}}t.FloatSetting=a},69589:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.forceContextOrSetting=t.pickForceContext=void 0;const n=i(38639),r=i(68708),s=i(50989),a=i(76740),o=i(28874),l=(0,s.strEnum)("forceSync","forceFilters","skipPreviews","forceRebuildPreviews","skipAssetTagging","recountAllTags","skipAssetRepair");t.pickForceContext=function(e){return(0,r.pick)(e,...l.values)},t.forceContextOrSetting=function(e){const t={...(0,r.pick)(e??{},"retries","halt","path"),...(0,r.fromEntries)(l.values.map((t=>[t,e?.[t]??(0,n.isTrue)(o.Settings[t]?.valueOrDefault)])))};return t.retries??(t.retries=0),t.halt??(t.halt=new a.Abortable),t}},74589:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const n=i(22573),r=i(31586),s=i(83179);class a extends s.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:r.toInt})}}t.IntegerSetting=a},4175:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const n=i(19851),r=i(22573),s=i(38639),a=i(42659),o=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,n.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function v(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function w(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){M(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&v(),y("strictDeduping",e)&&w(),(y("optOut",e)||y("noNetwork",e))&&_()},t.handleDeprecatedSettings=async function(){if((0,s.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,r.blank)(m.Settings.assetPathnameFormat.value)&&(0,r.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*a.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=v,t.setStrictDeduping=w;const S=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],b={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function M(e){for(const t of S)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:b;for(const[e,i]of(0,o.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function _(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=M,t.disableExternalNetworkRequests=_},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const n=i(22573),r=i(53265),s=i(87652);class a extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,n.blank)(e)?void 0:(0,r.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=a},23561:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const n=i(22573),r=i(31586),s=i(83179);class a extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:n.notBlankToS,fromEnv:r.toFloat})}}t.OptionalFloatSetting=a},69005:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const n=i(22573),r=i(31586),s=i(83179);class a extends s.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:r.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=a},87652:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const n=i(83179);class r extends n.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=r},28283:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const n=i(51926),r=i(83556);t.nameFromEnv=function(e){return(0,r.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,n.ensurePrefix)((0,r.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const a=i(19851),o=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),v=i(40583),w=i(81168),S=i(44198),b=i(96706),P=i(34102),M=i(28283),_=i(81075),E=i(98778),x=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){n.add(this),this.opts=e,this._envValue=(0,a.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,n,"m",r).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?s(this,n,"m",r).call(this,e??t)+": "+i:null==this.fromEnv(e)?s(this,n,"m",r).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,o.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,o.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,M.envFromName)(e),this._keys=(0,o.uniq)([...this._names.map(M.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return _.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,S.env)(),n=t??this.value;return null!=n&&(i[this.key]=this.toEnv(n)),null==e&&b.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,S.env)(),n=this.toEnvValue(t);return null!=n&&(i[this.key]=n,null==e&&b.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],x.WrapComments);function i(e,i){(0,o.isEmpty)(i)||t.push(...(0,w.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],x.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const n=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,w.wrap)(["",e+": "+n],x.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,E.wrapTomlToLines)({lines:e,wrap:x.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,E.wrapTomlToLines)({lines:e,wrap:x.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,E.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},n=new WeakSet,r=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const n=i(50989);t.SettingCategories=(0,n.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const n=i(58587),r=i(76760),s=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),v=i(79840),w=i(7282),S=i(12801),b=i(4328),P=i(70488),M=i(84248),_=i(5531),E=i(99315),x=i(34365),T=i(34580),D=i(96706),k=i(50274),C=i(33866),F=i(52086),O=i(48584),I=i(45969),L=i(43334),A=i(24540),R=i(70379),N=i(71300),B=i(33209),z=i(48987),j=i(68268),V=i(61208),W=i(99023),H=i(30577),U=i(1485),q=i(19861),G=i(55111),$=i(30933),J=i(22859),K=i(71988),Z=i(38483),X=i(90536),Y=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),ne=i(57039),re=i(9945),se=i(74589),ae=i(844),oe=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new oe.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new ne.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new ne.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new ne.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Z.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new ne.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>q.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>U.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:U.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>U.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new ne.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>L.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new ne.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Z.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Z.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!L.isElectron}),commandTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new ne.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new n.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new ne.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new ne.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new ne.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>L.isMac?"100ms":L.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new ne.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new ne.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new Y.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new re.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new Y.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new Y.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new Y.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:M.AutoVacuumModes,defaultValue:M.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:_.CheckpointTypes,defaultValue:_.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:x.SynchronousModes,defaultValue:x.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:E.RepairModes,defaultValue:E.RepairModes.dump}),maxBusyDbMs:new ne.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 1 minute is very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"1m"}),dbBackupIntervalMs:new ne.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new X.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new Y.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new Y.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Z.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Z.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:C.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Z.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>L.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Z.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:H.UpdateChannels}),autoUpdateCheck:new Z.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Z.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Z.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,T.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Z.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new Y.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new Y.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Z.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Z.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new Y.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,A.isRaspberryPi)()}),taskTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Z.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Z.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Z.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Z.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,$.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new Y.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:k.SidecarExts,defaultValue:k.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new re.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new Y.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new Y.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new Y.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new Y.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new Y.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Z.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Z.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,$.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:F.CropStrategies.attention,strEnum:F.CropStrategies}),videoFrameAtSec:new re.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Z.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,a.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(L.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new X.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>B.DefaultIncludedPreviewTags}),disableAllFilters:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Z.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:O.SharpFailOns.truncated,strEnum:O.SharpFailOns}),validateRawImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>z.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:ae.MinValidYear}),maxValidFutureMs:new ne.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new re.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new Y.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:j.KeywordReparentingStrategies.move,strEnum:j.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Z.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function Se(e){const i=((0,l.blank)(e)?"":e).split(r.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,a.uniq)(i).filter(l.notBlank).join(r.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,D.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,o.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const n=i(19851),r=i(31586),s=i(7282),a=i(49776),o=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),v=i(15674),w=i(28874);t.setSettingsDefaults=(0,n.lazy)((()=>{w.Settings.configDir.opts.defaultValue=o.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=a.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,r.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(22573),o=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),v=i(54993),w=i(50213),S=i(81168),b=i(83556),P=i(37805),M=i(87290),_=i(98314),E=i(34102),x=i(83278),T=i(95696),D=i(60865),k=i(4175),C=i(83179),F=i(81075),O=i(28874),I=i(41692),L=i(84438),A=i(32707),R=i(6707),N=i(55018),B=i(10357),z=(0,n.lazy)((()=>(0,w.mkLogger)("settings.SettingsIO")));function j(e){return(0,M.libraryDataDirPosixFile)(e)?.join(L.SettingsToml)}async function V(e=(0,A.systemSettingsFile)()){if(null!=e)return Q(x.BaseFile.for(e))}async function W(){try{return(0,a.toNotBlank)((await(0,R.readTomlFile_)((0,A.systemSettingsFile)()))?.[O.Settings.libraryDir.name])}catch{return}}async function H(){return J((0,A.systemSettingsFile)())}async function U(e){return(0,m.map)(j(e),(e=>J(e)))}function q(){t.libraryHasSettings.refresh()}function G(e){const t=j(e);return z().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:O.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}t.librarySettingsFile=j,t.readSettings=(0,n.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await X()}),o.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return O.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=H,t.librarySettingsVersion=U,t.maybeUpgradeSystemSettings=async function(){P.version!==await H()&&await Z()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&P.version!==await U()&&await Y()},t.libraryHasSettings=(0,n.lazy)((()=>G())),t.libraryHasSettings.unset=()=>{z().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,E.ee)().on("clearCache",q),(0,E.ee)().on("settingsChanged",q),O.Settings.libraryDir.watchLater(q)})),t._libraryHasSettings=G;const $=/^# PhotoStructure v(?\d+\.\d+\.\d+(?:-\S+)?)$/i;async function J(e){if((0,a.blank)(e))return;const t=await x.BaseFile.for(e).firstMatchingLine($);return t?.groups?.version}async function K(e,i){if(null==e)return void z().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const n=await e.clear().isNonEmpty(),r=n?e.wip():e;if(await async function(e,i){const n=[(0,g.padding)("#",80)];n.push(...ne("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","-- ","","PhotoStructure v"+(0,t.versionForSettings)())),n.push("","");let r="";for(const e of i){const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,n.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),n.push(...e.toTomlLines()),n.push("","")}await e.writeText_("\n"+n.map(y.trimRight).join("\n")+"\n\n"),(0,E.ee)().emitDebounced("settingsChanged")}(r,i),z().info("writeToml(): wrote settings",{dest:r,file:e,nonDefaults:(0,C.settingsToObj)(i),wip:n}),n){const t=await(0,R.readTomlFile_)(r),i=await(0,R.readTomlFile_)(e);(0,u.eql)(t,i)?(z().info("Equivalent contents",{dest:r,file:e,a:t,b:i}),await r.unlink()):(z().info("Archiving prior, different contents",{dest:r,file:e}),await e.renameYMDHMS_({subdir:"old"}),await r.unwip_())}}async function Z(e=(0,A.systemSettingsFile)()){const t=T.PosixFile.forMaybe(e);return null!=t&&await K(t,(0,O.persistedSystemSettings)()),t}function X(e){return Q(j(e))}async function Y(e){await(0,M.setupLibraryDataDir_)((0,a.firstNotBlank)(e,O.Settings.libraryDir.value));const i=j(e);return z().info("writeLibrarySettings()",{file:i}),null!=i&&(await K(i,(0,O.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function Q(e){if(null==e)return[];const t=z().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await ee(e);return(0,r.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,_.errorToS)(e)),[]}}async function ee(e){const t=z().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const n=await(0,R.readTomlFile_)(e);if(null==n)return{settings:[],warnings:["No settings found"]};const s=[],a=(0,r.compact)((0,p.entries)(n).map((([e,t])=>{const i=(0,O.getSettingByNameOrKey)(e);if(null==i)s.push(`Failed to import "${e}"${(0,m.mapOr)((0,O.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;s.push(e)}})));return t.info("loaded",{settings:(0,C.settingsToObj)(a),warnings:(0,r.toNotEmpty)(s)}),await(0,k.handleDeprecatedSettings)(),(0,k.handleMetaSettings)(a),{settings:a,warnings:s}}t.versionForSettings=(0,n.lazy)((()=>P.version)),t.writeSystemSettings_=Z,t.writeAllSettings_=function(e){return K(T.PosixFile.for(e),(0,O.persistedSettings)())},t.readLibrarySettings=X,t.writeLibrarySettings_=Y,t._readSettings=Q,t.importFileSettings_=ee;const te=(0,n.lazy)((()=>new Set([O.Settings.noNetwork,O.Settings.httpPort,O.Settings.license,O.Settings.logStdout,O.Settings.logLevel].map((e=>e.key)))));function ie(){for(const e of(0,p.values)(O.Settings))te().has(e.key)||e.unset();(0,E.ee)().emit("settingsChanged")}function ne(...e){return(0,d.flatten)(e.map((e=>(0,S.wrap)(e,B.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),O.Settings.libraryDir.unset(),await Z()},t.clearSettings=ie,t.nukeSettings=async function(){ie(),await(T.PosixFile.forMaybe((0,A.systemSettingsFile)())?.unlink("trace")),await(T.PosixFile.forMaybe(j())?.unlink("trace")),(0,E.ee)().emit("clearCache"),I.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...ne("",`Welcome to PhotoStructure! These are the settings for version ${(0,D.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...ne("","The following settings categories are stored in the system settings.toml:","",...(0,s.sort)([...F.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,s.sort)([...F.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...ne("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...ne("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let n="";t.forEach((e=>{const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==n&&(n=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const s=`${e.key} or ${e.name}`,a={...e.addToJSON()};(0,r.mapNotEmpty)(e.altKeys,(e=>a.aliases=(0,h.orList)(e)));const o=(0,p.entries)(a).map((([e,t])=>`${(0,S.capitalize)((0,b.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,r.isNotEmpty)(o)&&o.push(""),i.push(...ne((0,g.padding)("-",s.length),s,(0,g.padding)("-",s.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...o,`${e.key}=${(0,f.stringify)((0,v.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const n=i(76760),r=i(40958),s=i(22573),a=i(98553),o=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,a.stringify)(e)}t._join=c;function d(e){return(0,o.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,r.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",n.delimiter])if(t.includes(e))return(0,r.compactBlankish)(t.split(e));return[t]}}(e),r.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,r.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,r.isEmpty)(e)||(this.value=this.toValidValues((0,r.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,r.isEmpty)(this.values)}isNotEmpty(){return(0,r.isNotEmpty)(this.values)}toNotEmpty(){return(0,r.toNotEmpty)((0,r.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const n=i(83179);class r extends n.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=r},72564:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const n=i(40958),r=i(98553),s=i(55835),a=i(58305);class o extends a.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,r.stringify)((0,n.uniq)(e)))),fromEnv:t=>{return i=t,r=e.strEnum,(0,n.compact)((0,a.splitStringArray)(i)?.map((e=>r.getCI(e))));var i,r},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=o},80372:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const n=i(22573),r=i(81168),s=i(83179);class a extends s.Setting{constructor(e){super({toEnv:o,fromEnv:o,...e})}hasValue(){return(0,n.notBlank)(this.value)}}function o(e){return null==e?void 0:(0,r.trimQuotes)(e)}t.StringSetting=a},32707:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const n=i(76760),r=i(55835),s=i(46292),a=i(84438);t.systemSettingsFile=function(){return(0,r.map)((0,s.configDir)(),(e=>(0,n.join)(e,a.SettingsToml)))}},80496:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const n=i(50989);t.TagInferenceSettingValues=(0,n.strEnum)("never","always","auto")},6707:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const n=i(90858),r=i(44652),s=i(22573),a=i(76850),o=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,a.debom)(e),(0,s.blank)(t)?void 0:(0,n.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,r.readFileSync)(t)):void 0}catch(e){return void(0,o.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>f(await(0,r.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,r.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const n=i(22573),r=i(96249),s=i(98553),a=i(68708),o=i(51926);function l(e,t,i){if((0,n.blank)(e))throw new Error("kvToToml(): Blank key");const r=e+" = "+(0,s.stringifyPretty)(t);return(0,n.blank)(i?.prefix)?[r]:(0,o.wrap)(r.split("\n"),i)}t.stringifyToml=function(e){return(0,r.flatten)((0,a.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,n.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,o.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const n=i(98553);t.valueToS=function(e){return(0,n.stringify)(e,void 0,2)}},10357:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const n=i(54993),r=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=a(e[t]);if(null!=i)return i}};const s=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function a(e){const t=(0,r.extractFloat)(e);if(null==t)return;const i=(0,n.toS)(e).toLowerCase();for(const e of s)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const n=i(4001),r=i(81168);t.bname=function(e,t=!0){let i=(0,r.isString)(e)?e:e.name;return t&&(i=(0,n.stripCopySuffixFromName)(i)),i=(0,r.trimLeftPadding)((0,n.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const n=i(77988),r=i(19851),s=i(40958),a=i(76790),o=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),h=i(31586),f=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),v=i(81168),w=i(76596),S=i(79842),b=i(66649),P=i(21330),M=i(98725),_=i(928),E=i(54261),x=i(89724),T=i(17415),D=i(88600),k=i(51275),C=i(29882),F=i(17217),O=i(68284),I=i(57902),L=i(28874),A=i(65162),R=i(71300),N=i(14036),B=i(61424),z=(0,r.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function j(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,f.isObject)(e)&&(0,o.notBlank)(e.nativePath)&&(0,S.isDated)(e.date)&&(0,o.notBlank)(e.src)}t.capturedAtSrcFromTags=j,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class H{static fromAssetFile(e){return(0,d.map)((0,x.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>H.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof H?e:W(e)?new H(e):void 0}constructor(e){var t;this.nativePath=(0,F.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,h.toGt0)(e.local)??(0,x.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,S.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(L.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,b.datedToMillis)(e.mtime)??(0,O.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:H.name,...(0,f.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,M.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,T.fmtOffsetMinutes)});return null==t?void 0:new H({...e,date:t})}spread(e){return new H({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,T.fmtOffsetMinutes)(this.offset)}get isFromTags(){return j(this.src)}get isInferred(){return!j(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,x.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,w.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,k.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,E.hasTime)(this.date)}hasMillis(){return(0,h.gt0)((0,_.getMillisecond)(this.date))}toMillis(){return(0,b.datedToMillis)(this.date)}get isValid(){return(0,D.isValidDate)(this.date)}get zoneName(){return(0,n.offsetMinutesToZoneName)(this.offset)??(0,k.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,T.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?L.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,S.datedToStartDateTime)(this.date)??(0,S.datedToDateTime)(this.date);if(null!=i)return{start:(0,x.datedToLocal)(i.minus(t)),end:(0,x.datedToLocal)(i.plus(t))};z().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:L.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),n=Math.max(t,e.fuzzyPrecisionMs());return z().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,S.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:n}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:n}})}}function U(e,t){if(null==e)return;const i=(0,s.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>H.for(e))));for(const n of t){let t=e[n],r=n;if((0,D.isValidDate)(t)){if((0,T.isValidZone)(e.tz)&&(!(0,k.hasZone)(t)||R.OverrideUTCZoneTags.includes(r))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,o.blank)(e.tzSource)?"":" from "+(0,v.stripPrefix)(e.tzSource,"from ");r+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,x.datedToLocalSec)(t),date:t,src:r,precisionMs:(0,S.datedToPrecisionMs)(t),rawValue:e[n]?.rawValue})}}const n=(0,p.leastBy)(i,(e=>(0,S.datedToStartTs)(e.date)));if(null==n)return;const r=i.filter((e=>(0,u.eql)(e.date,n.date)||e.precisionMs<=n.precisionMs&&(0,S.datedOverlap)({a:e.date,b:n.date,aPrecisionMs:e.precisionMs,bPrecisionMs:n.precisionMs}))),a=(0,p.leastBy)(r,(e=>[Math.floor(e.localSec/1e6),(0,k.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return z().debug("capturedAtFromTags()",{least:n,overlapsWithLeast:r,earliest:a}),a}function q(e,t){if(L.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,s.uniq)([(0,A.bname)(e,!0),(0,A.bname)(e,!1)])){const e=(0,M.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,S.datedToPrecisionMs)(e),l.secondMs])}}}function G(e){if(L.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,M.extractDateFromPath)(e.pathsForDateParsing)}}async function $(e){if(L.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=H,t.bestCapturedAt=function(e){const t=(0,a.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const n=await e.mtimeMs();function r(t,i){return W(i)?H.for(i):null!=i&&null!=i.date&&(0,D.isValidDate)(i.date)?H.for({nativePath:e.nativePath,date:i.date,local:(0,x.datedToLocal)(i.date),src:(0,v.uniqPath)([t,i.src]),mtime:n,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const s=function(e,t){return null==e||t||!L.Settings.usePathsToInferDates.valueOrDefault||!L.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,C.containedByNativePath)({ancestor:L.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),a=r("tags",U(t,L.Settings.capturedAtTags.values))??(i?void 0:r("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??r("tags",U(t,L.Settings.capturedAtTagsFallback.values))??(s?void 0:r("bname+stat",await(0,B.extractStatBname)(e)))??(s?void 0:r("path+stat",await(0,B.extractStatPathTime)(e)))??(i?void 0:r("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??(s?void 0:r("bname",q(e,t)))??(s?void 0:r("path",G(e)))??(L.Settings.useStatToInferDates.valueOrDefault?r("stat",await $(e)):void 0);return z().tap({level:I.LogLevels.debug,msg:"extractCapturedAt()",result:a})},t.capturedAtFromTags=function(e){return U(e,L.Settings.capturedAtTags.values)},t.capturedAtFromBasename=q,t.capturedAtFromPath=G,t.capturedAtFromStat=$},70379:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const n=i(50989);t.DateTagFormats=(0,n.strEnum)("y","ym","ymd","")},71300:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const n=i(31586),r=i(97352),s=i(95696),a=i(47783),o=i(16170);function l(e){if(null!=e&&(0,o.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,n.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,r.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=s.PosixFile.for(e);return l(await(0,a.readRawTags)(t,!1))}},47783:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const r=i(77988),s=n(i(76760)),a=n(i(1708)),o=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(23838),f=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),v=i(12168),w=i(56038),S=i(4867),b=i(36557),P=i(98247),M=i(21330),_=i(98725),E=i(23467),x=i(88561),T=i(95696),D=i(17217),k=i(16287),C=i(50213),F=i(17921),O=i(7282),I=i(88158),L=i(23560),A=i(28874),R=i(12089),N=i(45255),B=i(81168),z=i(63870),j=i(15674),V=i(28544),W=i(43207),H=i(75767),U=i(12788),q=i(80495),G=i(14036),$=i(67083),J=i(3432),K=i(28630),Z=i(15912),X=i(30748),Y=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),ne=i(61424),re=i(8791),se=(0,o.lazy)((()=>(0,C.mkLogger)("exiftool.ExifTool")));let ae=!1;t.addInstanceIdsToTags=function(e){ae=e},t.setExifToolProcs=function(e){return A.Settings.exiftoolProcsPerChild.envValue=e,ue()};const oe=(0,o.lazy)((()=>new b.BatchClusterObserver("ExifTool",new r.ExifTool({useMWG:A.Settings.useMWG.valueOrDefault,backfillTimezones:A.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:A.Settings.defaultVideosToUTC.valueOrDefault,...(0,b.batchClusterOptions)((0,O.isTest)()?8:(0,L.isSyncService)()?A.Settings.exiftoolProcsPerChild.value??(0,j.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=oe();return e.ended?oe.refresh():e}function ue(e=!1){return(0,d.map)(oe.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,S.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(oe.prior(),(e=>e.ended?void 0:(0,S.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,z.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,o.lazy)((()=>new x.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,o.lazy)((()=>new x.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,f.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,D.toNativePath_)(e))}async function he(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function fe(e){const t=[];return A.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*v.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,B.includesIgnoreCase)(A.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return se().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const n=i??await(0,te.readMimeType)(e),r=await e.sidecar(),s=(0,Y.isImageMimeType)(n)&&A.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,a=(0,Y.isVideoMimeType)(n)&&A.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,o=A.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await r.exists(),l=s||a||o;return se().tap({msg:"writeTagDest()",result:l?r:e,meta:{src:e,tagName:t,mimetype:n,writeMetadataToSidecarsIfImage:s,writeMetadataToSidecarsIfVideo:a,writeMetadataToSidecarsIfSidecarExists:o}})}async function pe(e,i=!0){const n=T.PosixFile.for(e);if(n.isSidecar()&&(i=!1),!await n.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(n.nativePath),void se().debug("readRawTags("+n+"): invalid file, returning null.");const r=await(0,t._readRawTags)(n.nativePath);if(null==r||!i)return r;se().trace("readRawTags()",{pf:n,pickedFileTags:(0,f.pick)(r,"tz","tzSource",...A.Settings.capturedAtTags.values)});const s=[];for(const e of await n.jsonSidecars())s.push([e,(0,K.readJsonSidecar)(e,r.tz)]);for(const e of await n.existingExifSidecars())s.push([e,(0,t._readRawTags)(e.nativePath)]);const a={original:{},MIMEType:(0,u.mapNotBlank)(r.MIMEType,Y.normalizeMimetype),...r},o=[];for(const[e,i]of s){if(null==i)continue;const n=await i;if(null==n)continue;const r=(0,f.omit)(n,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,f.values)(r))?((a.sidecars??(a.sidecars=[])).push(e.base),o.push(...(0,g.toA)(n.History)),(0,I.assignNullishFields)(a.original,(0,f.pick)(a,...(0,f.keys)(r))),(0,f.assignFields)(a,r),se().debug("readRawTags() sidecar had values",{sidecar:e.base})):se().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return a.inferred=(0,$.getInferredHistoricValues)(o,e),(0,I.assignNullishFields)(a,a.inferred),a.Rotation=(0,Q.orientationToRotation)(a.Rotation),se().debug("readRawTags() final",{pf:n,inferred:a.inferred,pickedResult:(0,f.pick)(a,"tz","tzSource",...A.Settings.capturedAtTags.values)}),a}async function ge(e,t){return null==t?void 0:(0,w.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,n=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,Y.normalizeMimetype);if((0,u.blank)(n))return void se().debug("No mimetype for "+i);const s={...t.inferred??{},...t};if(s.inferred??(s.inferred={}),s.original??(s.original={}),A.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...A.Settings.capturedAtTags.values,...A.Settings.capturedAtTagsFallback.values]){const t=s[e];if((0,p.isString)(t)){const i=(0,_.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(se().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),s[e]=i)}}const o=!await(0,ne.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,s,o);if(se().debug("parseTags()",{tzMeta:l,skipSiblingInference:o}),null!=l?.tz){const e=s.tzSource!==r.defaultVideosToUTC&&void 0;for(const t of[...A.Settings.capturedAtTags.values,...A.Settings.capturedAtTagsFallback.values]){const i=s[t];i instanceof r.ExifDateTime&&(s[t]=(0,M.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,f.assignUndefinedFields)(s.original,s,"tz","tzSource"),(0,f.assignFields)(s,l),(0,f.assignFields)(s.inferred,l)}const c=o?(0,X.extractMakeAndModel)(s):await(0,ne.inferMakeAndModel)(e,s);c.Make!==(0,X.make)(s.Make)&&(s.original.Make=s.Make,s.inferred.Make=c.Make),c.Model!==(0,X.model)(c.Make,s.Model)&&(s.original.Model=s.Model,s.inferred.Model=c.Model),!(0,u.blank)(A.Settings.defaultCopyright.valueOrDefault)&&(0,U.isExifUnset)(s.Copyright)&&(s.Copyright=A.Settings.defaultCopyright.valueOrDefault);const d=(0,Z.extractLensMakeModel)(s),h=await(0,V.extractCapturedAt)(e,s,o);if(null==h)return void se().info("No capturedAt for "+e);!o&&h.isInferred&&(s.inferred.capturedAt=h);const m=(0,q.extractExposureSettings)(s),g=await(0,ie.extractSizeInfoFromFile)(e,s);if(null==g)return void se().info("No size info for "+i);const y={...c,mimetype:n,capturedAt:h,exposureSettings:m,...(0,re.extractTitleDescription)(s),...d,cameraId:(0,H.cameraIdFromTags)(s),imageId:(0,H.imageIdFromTags)(s),lensId:(0,H.lensIdFromLensInfo)({...d,...(0,f.pick)(s,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(s),tz:s.tz,rating:(0,ee.extractRating)(s)};(0,O.isTest)()&&(y.__parsedBy__=a.default.pid);const v={...s,...y};return se().debug("parsedTags",{nativePath:i,skipInference:o,...y,inferred:s.inferred,original:s.original,pickedResult:(0,f.pick)(v,"capturedAt","tz","tzSource","Make","Model")}),(0,f.definedValues)(v)}catch(e){return void se().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,f.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,f.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,E.eqlAsync)(e.sha(),t.sha())||await(0,E.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=T.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,D.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,D.toNativePath_)(e),["-"+t]);return(0,I.pluckCaseInsensitive)(i,t)}catch(e){return void se().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=he,t.overwriteTags_=async function(e,t){try{await(0,w.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await fe(e)),e.clearThisAndParent()}))}catch(i){se().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,w.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=fe,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,w.time)("exiftool.writeTags:"+e,(async()=>{const n=new h.MultiMap;for(const[r,s]of(0,f.entries)(t)){const t=await me(e,r,i);n.add(t.nativePath,[r,s])}for(const[t,i]of n.entriesArray()){const n=T.PosixFile.for(t),r=(0,f.fromEntries)(i);se().info("writeTags()",{src:e,dest:t,t:r}),await le().write(n.nativePath,r,await fe(n)),A.Settings.overwriteOriginal.valueOrDefault||await he(n),n.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,k.nativePathIsFile)(e))return se().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);se().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...A.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,G.isVideoExt)(s.default.extname(e))?[]:["-fast"]],n=await(0,w.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{se().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==n)return;se().debug("_readRawTags()",{nativePath:e,pickedTags:(0,f.pick)(n,"tz","tzSource",...A.Settings.capturedAtTags.values)}),n.MIMEType=(0,u.mapNotBlank)(n.MIMEType,Y.normalizeMimetype),n.GPSDateTime??(n.GPSDateTime=(0,P.concatDateTime)(n.GPSDateStamp,n.GPSTimeStamp));for(const e of(0,f.keys)(n)){const t=n[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete n[e])}const r=(0,l.compactBlanks)([n.Error,...n.errors??[],n.Warning].map(y.toS));return(0,l.isNotEmpty)(r)&&(n.problems=r),ae&&(n.__instance=(0,F.safeUUID)()),n}}),t.parseTags=ge},75767:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(98553),o=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),h=i(54993),f=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),v=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const w=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function S(e){const t=null==e?[]:e.filter((([,e])=>!(0,s.blank)(e)));return 0===t.length?void 0:(0,a.stringify)((0,u.fromEntries)(t))}function b(e){return(0,h.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new o.MultiMap,n=[];for(const a of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(r=e[a])||(0,s.blankish)(r)||(0,l.isNumber)(r)&&(0===r||1===r)||null!=t.zeroesRe.exec((0,h.toS)(r)))continue;const o=e[a],u=b(e[a]),c=(0,t.Tag2SynonymGroup)().get(a);if(null!=c){if(i.includes(c,o)||i.includes(c,u))continue;i.add(c,o)}n.push([a,(0,l.gt0)(o)?o:u])}var r;return S(n)}function M(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function _(e){if((0,s.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([M(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(M)):(0,u.compactBlankValues)(t)}function E({a:e,b:t,field:i,desc:n,parser:r}){const s=r(e[i]),a=r(t[i]),o=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==s||null==a||(0,l.approximates)(s,a,o)?void 0:"Different "+n+": "+e[i]+" ≠ "+t[i]}function x(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,s.blank)(e.lensMake)||(0,s.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,n.lazy)((()=>{const e=new Map;for(const t of w){const i=t[0];for(const n of t)e.set(n,i)}return e})),t.Tag2Synonyms=(0,n.lazy)((()=>{const e=new Map;for(const t of w)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=S,t.renderExifUidId=P,t.decodeExifUid=_,t.findInequalFields=function(e,i){const n=_(e),s=_(i);if(null==n||null==s||e===i)return;const a=(0,f.intersection)((0,u.keys)(n),(0,u.keys)(s)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of a){const t=n[e],i=s[e];if(b(t)!==b(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of w){const t=(0,u.pick)(n,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(s,...e);if((0,u.isEmptyObj)(i))continue;const a=(0,u.values)(t).map(h.toS),o=(0,u.values)(i).map(h.toS);if((0,r.includesAny)(a,o))continue;const l=(0,f.least)((0,u.keys)(t)),c=(0,f.least)((0,u.keys)(i));return{aKey:l,aValue:n[l],bKey:c,bValue:s[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>E({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>E({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>E({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>E({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return x({...(0,v.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=x,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const n=i(22573),r=i(54993),s=/undefined|null|none|n\/a|unknown/i;function a(e){return null==e||(0,n.blank)(e)||s.test((0,r.toS)(e))}t.isExifUnset=a,t.toExifDefined=function(e){return a(e)?void 0:e}},80495:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const n=i(19851),r=i(22573),s=i(31586),a=i(68708),o=i(54993),l=i(50213),u=i(97352),c=(0,n.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,r.firstNotBlank)((0,o.toS)(e.ExposureTime),(0,o.toS)(e.ShutterSpeed),(0,o.toS)(e.ShutterSpeedValue),(0,o.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,a.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,s.gt0)(e))return e;const[t,i]=(0,o.toS)(e).split("/").map((e=>(0,s.toInt)(e)));return(0,s.gt0)(t)&&(0,s.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,s.toFloat)(e);return(0,s.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const n=i(50989);t.ExtTypes=(0,n.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const n=i(19851),r=i(40958),s=i(96249),a=i(23838),o=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,n.lazy)((()=>{const e={};for(const[i,n]of(0,o.entries)(t.AllFiletypes))for(const t of n)e[t]=i;return e})),m=(0,n.lazy)((()=>{const e={};for(const i of(0,o.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,n.lazy)((()=>(0,r.uniq)((0,s.flatten)((0,o.values)(t.AllFiletypes))))),t.AssetFileExts=(0,n.lazy)((()=>(0,r.uniq)((0,s.flatten)((0,o.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,n.lazy)((()=>{const e=new a.MultiMap;for(const{exts:i,type:n}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,s.flatten)((0,o.values)(i)))e.add(t,n);for(const i of t.OldBrowserMimetypes)for(const n of t.AllFiletypes[i]??[])e.add(n,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const n of t.AllFiletypes[i]??[])e.add(n,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function v(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),n=(0,c.normalizeExt)(t);return null!=i&&null!=n&&(i===n||(p(i)?.includes(n)??!1))},t.extTypes=y,t.isExtType=v,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return v(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return v(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return v(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return v(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return v(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return v(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const n=i(77988),r=i(19851),s=i(40958),a=i(76790),o=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),h=i(50989),f=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),v=i(50213),w=i(81168),S=i(66649),b=i(17415),P=i(29882),M=i(95696),_=i(17217),E=i(28874),x=i(47783);function T(e,t){return(0,d.entries)(t??{}).map((([t,i])=>D({action:e,key:t,value:i})))}function D({action:e,key:t,value:i,ts:r}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:n.ExifDateTime.fromMillis(r??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,h.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=T,t.mkHistoryRecord=D,t.InferAction="infer";const k=(0,r.lazy)((()=>(0,v.mkLogger)("tags.History")));function C(e,t){if(null==e||null==e.History||(0,f.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function F(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,o.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function O(e){if(null==e)return;const t={};for(const[i,n]of(0,d.entries)(e))(0,w.isFirstCharAZ)(i)&&(t[i]=n);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,b.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function I(e,i,n){if(null==e||(0,o.blank)(e))return void k().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const r=(0,_.toNativePath_)(e),a=await(0,x._readRawTags)(r),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!C(a,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...n??{}};if((0,s.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void k().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:n,tagsToWrite:c});k().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:n});const h=M.PosixFile.for(e);return await(0,x.overwriteTags_)(h,c),h.clearThisAndParent(),u}t.tagsContainHistory=C,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const r=(0,m.toA)(e);if((0,s.isEmpty)(r))return{};const l=(0,a.sortBy)(r.filter((e=>(0,w.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,S.datedToMillis)((0,o.mapNotBlank)(e.When,(e=>n.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,o.notBlank)(t)){const n=F(e);(0,o.blank)(n.nativePath)||(0,P.eqlNameWithoutExt)(n.nativePath,i)?u[t]=n:k().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=F,t.inferredToTags=O,t.ensureInferredHistoryRecords=async function(e,i,n){const r=T(t.Actions.infer,n),s=(E.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?O(n):void 0)??{};return E.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(s.Source=e.nativePath),k().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:r,additionalTags:s}),I(i,r,s)},t.ensureHistoryRecords=I},3432:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const r=n(i(53705)),s=i(77988),a=i(19851),o=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),h=i(17415),f=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),v=i(61424),w=(0,a.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function S(e,t,i){{const e=b(t);if(null!=e&&(0,h.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,h.isValidZone)(t.tz)||t.tzSource===s.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,o.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof s.ExifDateTime&&(0,h.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,v.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function b(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,r.default)(t,i),n=(0,h.normalizeZone)(e);return w().tap({msg:"zoneFromLatLon()",result:n,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,f.isValidDate)(i))for(const n of g.Settings.capturedAtTags.values){const r=(0,u.toDated)(t[n]);if(null==r||(0,f.isValidDate)(r))continue;const s=Math.round(15*i.diff(r,"minutes").as("minutes")/15),a=(0,h.normalizeZoneOffsetMinutes)(s),o=0===a?void 0:(0,h.normalizeZone)(a);if(null!=o)return w().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:o.name,tzSource:"infer:filename (diff with "+n+")"},meta:{dt:(0,c.datedToISO)(r),rawTzoffsetMinutes:s,normalizedOffsetMinutes:a}})}}t.maybeInferTimezone=async function(e,t,i){return w().tap({msg:"maybeInferTimezone()",result:await S(e,t,i)})},t.zoneFromLatLon=b,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const n=i(77988),r=i(40958),s=i(22573),a=i(38639),o=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),h=i(48884),f=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const r=(0,p.normalizeZone)(e?.formatted),s=n.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:r??t??n.UnsetZone});if(!0===s?.isValid)return s}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,s.toNotBlank)(e.title),Description:(0,s.toNotBlank)(e.description),GPSLatitude:(0,h.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,f.validLat)(e)?e:void 0)),GPSLongitude:(0,h.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,f.validLon)(e)?e:void 0)),GPSAltitude:(0,h.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,o.map)(e.favorited,a.isTrue),peopleNames:(0,r.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,r.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const n=i(50989);t.KeywordReparentingStrategies=(0,n.strEnum)("move","copy","retain")},97573:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rawTagKeywords=t.parseKeywordStruct=t.isKeywordStruct=t.parseCategories=t.splitKeywords=t.splitKeyword=t.delimRe=t.keywordToPath=void 0;const n=i(77988),r=i(66150),s=i(19851),a=i(40958),o=i(22573),l=i(41400),u=i(96249),c=i(68708),d=i(59455),h=i(48884),f=i(50213),m=i(68852),p=i(81168),g=i(28874),y=(0,s.lazy)((()=>(0,f.mkLogger)("tags.KeywordTags"))),v=(0,s.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordPathSeparators.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g")))));function w(e){const i=(0,t.delimRe)();return null==i?[e]:(0,a.compactBlanks)(e.split(i))}function S(e){return null==e||e instanceof n.BinaryField?[]:(0,a.compactBlanks)(Array.isArray(e)?(0,u.flatten)(e.map(S)):w(e))}function b(e){return null==e?[]:(0,p.isString)(e)?(0,o.blank)(e)?[]:[[e]]:(0,u.flatten)((0,d.toA)(e.Category).map(b).map((t=>t.map((t=>(0,a.compact)([e._,...t]))))))}(0,l.later)((()=>{g.Settings.keywordPathSeparators.watchLater((()=>v.unset()))})),t.keywordToPath=function(e){const t=v();return(0,a.compactBlanks)(null==t?[e]:e.split(t))},t.delimRe=(0,s.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g"))))),g.Settings.keywordDelimiters.watchLater((()=>t.delimRe.unset())),t.splitKeyword=w,t.splitKeywords=S;const P=/^\(?none\)?$/i;function M(e){if(!(0,o.blank)(e)&&null==P.exec(e))try{const t=new r.XMLParser({textNodeName:"_"}).parse(e);return(0,u.flatten)((0,d.toA)(t?.Categories?.Category).map(b))}catch(t){return void y().warn("parseCategories() failed:",{err:t,s:e})}}function _(e){return Array.isArray(e)&&e.every(_)||null!=e&&(0,p.isString)(e.Keyword)&&(null==e.Children||Array.isArray(e.Children)&&e.Children.every(_))}function E(e){if(null==e)return[];if(Array.isArray(e)&&e.every(_))return(0,h.flatMap)(e,E);if((0,o.blank)(e.Keyword))return[];const t=(0,d.toA)(e.Children);return(0,a.isEmpty)(t)?[[e.Keyword]]:(0,h.flatMap)(t,E).map((t=>[e.Keyword,...t]))}t.parseCategories=M,t.isKeywordStruct=_,t.parseKeywordStruct=E,t.rawTagKeywords=function(e){const t=[];if(null!=e){const i=[...g.Settings.keywordTags.values];if(i.includes("Categories")){(0,h.remove)(i,"Categories");const n=M(e.Categories);null!=n&&t.push(...n)}for(const n of i){const i=(0,c.pluckDeep)(e,n)?.value;(0,o.blank)(i)||(_(i)?t.push(...E(i)):t.push(...Array.isArray(i)?i:S(i)))}}return y().tap({msg:"rawTagKeywords()",result:(0,a.compactBlankish)((0,a.uniq)(t)),meta:{t:null==e?void 0:(0,c.pick)(e,...g.Settings.keywordTags.values)}})}},15912:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(55835),o=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),h=i(28874),f=i(30748),m=(0,n.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,f.make)(e.LensMake),i=(0,f.make)(e.Make),n=[],o=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],S),u=(0,r.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:o,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&n.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==S(e))continue;(0,s.notBlank)(t)&&n.push({lensMake:t,lensModel:e,lensInfo:o});const a=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))a.includes(t)&&n.push({lensMake:i,lensModel:e,lensInfo:o});for(const i of(0,r.compactBlanks)([t,...h.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&n.push({lensMake:i,lensModel:e,lensInfo:o});a.startsWith("vr ")&&"Nikon"===i&&n.push({lensMake:"Nikon",lensModel:e,lensInfo:o})}for(const e of n){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=b(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,a.map)(e.lensInfo,b)}return(0,c.greatestBy)(n,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const v=/([\d. -]+)\s?mm\b/i,w=/\bf\/?([\d.\-]+)/i;function S(e){if((0,s.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=v.exec(e)?.[1].replace(/\s/g,""),i=w.exec(e)?.[1];return y(t)&&y(i)?b(`${t}mm f/${i}`):void 0}function b(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,a.mapOr)((0,o.toFloat)(e),(e=>String((0,o.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=S,t.cleanBogusPrecision=b,t.normalizeLensModel=function(e){return b(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const n=i(19851),r=i(22573),s=i(55835),a=i(68708),o=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function h(e,t,i=""){const n=e.replace(t,i);return n===e?e:h(n,t,i)}const f=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=f.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,n.lazy)((()=>new p)),y=/\bgopro\b/i;function v(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=h(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=v(e.Make)??S(e.Software)??S(e.CreatorTool)??function(e){return y.test((0,o.toS)(e.HandlerDescription))||y.test((0,o.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,a.compactValues)({Make:t,Model:i})??{}},t.make=v;const w={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function S(e){if(!(0,r.blank)(e))for(const[t,i]of(0,a.entries)(w))if(i.test(e))return t}t.makeFromSoftware=S;const b=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=b.exec(i);null!=e&&(i=e[1].trim())}const n=(0,s.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=n)return n[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,s.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=h(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},16170:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const n=i(22573),r=i(54993),s=i(2322),a=i(277),o=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function h(e){return(0,n.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function f(e){const t=(0,r.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,s.isChrome)(t)||(0,s.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,r.toS)(e))},t.isImageMimeType=function(e){return(0,r.toS)(e).startsWith("image/")},t.isVideoMimeType=h,t.normalizeMimetype=f,t.isSharpMimeType=function(e){return!(0,n.blank)(e)&&f(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,n.blank)(e)&&f(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,n.blank)(t)&&(h(t)?await(0,l.isVideoSupported)():(0,o.isHeifMimeType)(t)?await(0,a.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const n=i(50989);t.NameTagFormats=(0,n.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const n=i(50989);t.NameTagOrders=(0,n.strEnum)("western","eastern")},95141:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const n=i(21605),r=i(54993),s=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,s.isVideoMimeType)(e.MIMEType)?(0,n.normalizeRotation)(e.Rotation):void 0)??o(e.Orientation)};const a=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function o(e){return(0,n.isRotation)(e)?e:null!=e?a.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,r.toS)(e).startsWith("Mirror")},t.orientationToRotation=o;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,n.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,n.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const n=i(55835),r=i(31586),s=i(28874);function a(e){const t=(0,r.toInt)(e);return null==t?void 0:(0,r.clamp)(-1,5,t)}function o(e){return a(e?.Rating)??(0,r.mapNumeric)((0,r.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,n.map)(e?.favorited,(e=>!0===e?s.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=a,t.extractRating=o,t.extractLiked=function(e){const t=o(e);return null==t?void 0:t>=s.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const n=i(19851),r=i(22573),s=i(55835),a=i(88561),o=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,n.lazy)((()=>new a.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,r.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,s.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,o.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const n=i(16928),r=i(40958),s=i(22573),a=i(81168),o=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,a.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const o=(0,u.isJsonExt)(i.ext),l=o||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,n.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=o||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,r.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,r.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return o&&function(e,i){const n=(0,a.commonPrefixIgnoreCase)(e,i);if(n.length<8)return!1;function r(e){return(0,s.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const o=r(e.slice(n.length)),l=r(i.slice(n.length));return o&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,o.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,a.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const n=i(19851),r=i(22573),s=i(42659),a=i(33374),o=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),h=i(34943),f=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),v=(0,n.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),w=(0,n.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:s.minuteMs})));async function S(e,t){if(null==e)return;const i=null==t||(0,r.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const n=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return b(i,n,await(0,h.rawInfo)(e));const s=b(i,n);if(null!=s)return s;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await S(await(0,f.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function b(e,t,i){t??(t=(0,y.extractRotation)(e));const n=(0,o.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,a.isDimensions)(e)?e:void 0));if(null==n)return v().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo,fileDimensions:n}});const r=(0,a.maybeDimSwap)(n,t);return v().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:r.height,ImageWidth:r.width,aspectRatio:(0,d.aspectRatio)(r),dimensions:r,rotation:t,fileDimensions:n,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return w().getOrSetAsync(i.nativePath,(()=>S(i,t)))},t.extractSizeInfoFromTags=b},61424:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const n=i(77988),r=i(51168),s=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),h=i(48884),f=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),v=i(79842),w=i(21330),S=i(98725),b=i(51275),P=i(35280),M=i(19748),_=i(88561),E=i(95696),x=i(65238),T=i(17217),D=i(57902),k=i(28874),C=i(80496),F=i(65162),O=i(28544),I=i(47783),L=i(88840),A=i(30748),R=i(16170),N=(0,s.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),B=7;async function z(e){return k.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+k.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(k.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.auto&&await(0,x.isSlowDir)(e.nativePath)&&!await(0,x.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function j(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of n){const n=(0,A.extractMakeAndModel)(await(0,I.readRawTags)(t));if((0,f.definedAndNotEql)(n.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:n});else if((0,f.definedAndNotEql)(n.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:n});else if(null!=n.Make&&null!=n.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:D.LogLevels.info,result:n,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await z(e.parent()))return;const t=await W(e);return null!=t&&(0,w.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,w.toExifDateTime)(t.before.date,(0,b.getZoneName)(t.before.date)),(0,w.toExifDateTime)(t.after.date,(0,b.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,s.lazy)((()=>new _.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await q(e),i=await j(t?.younger),n=await j(t?.older);return null==i||null==n?void 0:{before:i,after:n,index:i.index,slots:i.index+n.index+1}}))}t.beforeAfterCapturedAt=W;const H=(0,M.extFilter)(L.ExtTypes.AssetFile);function U(e){return null==e?[]:(0,a.compact)((0,h.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function q(e,t=7,i=!0){if(!await z(e.parent()))return;const n=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(H(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==n)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const r=(0,o.sortBy)(n,(e=>(0,F.bname)(e))),s=(0,T.findFileIndex)(e,r);if(s<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),q(e,t,!1)):void 0;const l=k.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[r.slice(s-2*t,s),r.slice(s+1,s+1+2*t)],d=[],h=[];for(;(0,a.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,a.isNotEmpty)(c)&&h.length=l&&h.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:h},meta:{f:e}})}t.nearestSiblings=q,t.nearestSiblingTzOffset=async function(e){if(!await z(e.parent()))return;const t=U(await q(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,B);for(const t of e){const e=await(0,I.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==n.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,a.uniq)([(0,F.bname)(e,!0),(0,F.bname)(e,!1)]),i=(0,S.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const n=await e.stat();if(null!=n){for(const e of["birthtime","atime","mtime","ctime"])if((0,v.datedOverlap)({a:i,b:n[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:n}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:n}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,S.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const n=i[e];if(null!=n&&!0===(0,v.datedOverlap)({a:t,b:n}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:r.DateTime.fromJSDate(n)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const n=i(40958),r=i(76790),s=i(22573),a=i(55835),o=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),h=i(81168);function f(e){return(0,u.toS)((0,o.isString)(e)?e:e?.name).normalize()}function m(e){return(0,n.compact)((0,l.toA)(e).map(f))}function p(e,i=t.TagSep){return m(e).map((e=>(0,o.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(s.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function v(e){return(0,s.blank)(e)?void 0:Array.isArray(e)?f((0,n.last)(e)):(0,n.last)(g(e))}function w(e,t){if((0,n.isEmpty)(e)||(0,n.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,h.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=f,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,n.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,n.uniqBy)((0,l.toA)(e),(e=>(0,n.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,n.compact)(t).map((e=>y(e))));return(0,n.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=v,t.leafIsExcluded=function(e,t){return(0,a.mapOr)(v(e),(e=>(0,h.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=w,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,r.sortBy)(e.filter(n.isNotEmpty),(e=>-e.length)))t.some((e=>w(i,e)))||t.push(i);return(0,r.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const n=i(40958),r=i(22573),s=i(68708),a=i(54993);t.extractTitleDescription=function(e){const t=(0,n.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,r.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const n of i){const i=(0,a.toS)(e[n]).trim();if((0,r.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,s.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(96249),o=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),v=(0,n.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function w(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function S(e){const t=await w(e);return(0,r.uniq)((0,a.flatten)(t.map(m.uriEncodingVariants)))}async function b(e,t){if((0,s.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void v().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case o.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case o.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case o.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,s.blank)(e)?v().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=w,t.nativePath2uriVariants=S,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(b(e,t),S))),(0,r.uniq)(i)},t.uri2nativePath=b,t.uriExists=async function(e,t){const i=await b(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const n=i(76760),r=i(57975),s=i(90595),a=i(22573),o=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",v=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class w{static isUri(e){return e instanceof w||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,n,r,s=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,s),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(n??""),this.fragment=r??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,s))}get fsPath(){return E(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:n,query:r,fragment:s}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===n?n=this.path:null===n&&(n=g),void 0===r?r=this.query:null===r&&(r=g),void 0===s?s=this.fragment:null===s&&(s=g),t===this.scheme&&i===this.authority&&n===this.path&&r===this.query&&s===this.fragment?this:new b(t,i,n,r,s)}static parse(e,t=!1){const i=v.exec(e);if(!i)return new b(g,g,g,g,g);const n=i[2]||g,r=k(i[4]||g),s=(i[5]||g).split("/").map(k).join("/"),a="psfile"===n&&s.startsWith("//")?s.slice(1):s,o=(0,u.toURLSearchParams)(i[7]),l=k(i[9]||g);return new b(n,r,a,o,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new b("file",t,e,g,g)}static from(e){return new b(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?w.file(n.win32.join(E(e,!0),...t)).path:n.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,o.map)(this.path,(e=>(0,d.findLast)(e.split(y),a.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return x(this,e)}toJSON(){return this}[r.inspect.custom](){return this.toString()}}t.URI=w;const S=h.isWinPortable?1:void 0;class b extends w{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=E(this,!1)),this._fsPath}toString(e=!1){return e?x(this,!0):(null==this._formatted&&(this._formatted=x(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=S),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,a.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function M(e,t){let i,n=-1;for(let r=0;r=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57||45===s||46===s||95===s||126===s||t&&47===s)-1!==n&&(i+=encodeURIComponent(e.substring(n,r)),n=-1),void 0!==i&&(i+=e.charAt(r));else{void 0===i&&(i=e.substr(0,r));const t=P[s];void 0!==t?(-1!==n&&(i+=encodeURIComponent(e.substring(n,r)),n=-1),i+=t):-1===n&&(n=r)}}return-1!==n&&(i+=encodeURIComponent(e.substring(n))),void 0!==i?i:e}function _(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function x(e,t){const i=t?_:M;let n="";const{scheme:r,query:s,fragment:o}=e;let{authority:l,path:u}=e;if(r&&(n+=r,n+=":"),(l||"file"===r)&&(n+=y,n+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?n+=i(t,!1):(n+=i(t.substr(0,e),!1),n+=":",n+=i(t.substr(e+1),!1)),n+="@"}e=l.indexOf(":"),-1===e?n+=i(l,!1):(n+=i(l.substr(0,e),!1),n+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}n+=i(u,!0)}return(0,a.mapNotBlank)(s,(e=>n+="?"+e)),o&&(n+="#",n+=t?o:M(o,!1)),n}function T(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+T(e.substr(3)):e}}t.encodeURIComponentFast=M,t.uriToFsPath=E;const D=/(?:%[\dA-Z][\dA-Z])+/gi;function k(e){return e.startsWith("xn--")?(0,s.toUnicode)(e):e.match(D)?e.replace(D,(e=>T(e))):e}t.percentDecode=k,t.toURI=function(e){return w.isUri(e)?e:w.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const n=i(19851),r=i(40958),s=i(50357),a=i(89937),o=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",a.PS_LOCAL_FILE_SCHEME,a.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,o.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,n.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),n=(0,c.toURI)(t);return i.scheme===n.scheme&&i.authority===n.authority&&f(i.path,n.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,s.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,r.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const n=i(76760),r=i(22573),s=i(51926),a=i(89937),o=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,n.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,r.blank)(e))return;if(null==(t=null!=t&&(0,o.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,r.blank)(t.uuid))return;const i=(0,l.native2posix)(e),n=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(n.normalize()))return;const u=(0,s.ensurePrefix)(i.slice(n.length),"/");return d.URI.from({scheme:a.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==a.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,r.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?n.win32.sep:n.posix.sep,s=(0,r.notBlank)(t)&&!t.includes(i);if(s&&!(0,r.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const o=await(0,c.bestVolumeForVolsha)(e.authority);return null!=o?f(o.mountpoint,e.path):s&&(0,r.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const n=i(40958),r=i(22573),s=i(51926),a=i(89937),o=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,r.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,r.blank)(t))return;const i=(0,n.uniq)([t,(0,o.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,s.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==a.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,o.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,s.stripPrefix)(e.path,"/"),n=t.join(i);if(n.isFileSync())return n.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return n.nativePath}},12228:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const a=s(i(76760)),o=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,o.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,o.notBlank)(t.remoteHost)&&(0,o.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:a.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,o.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),n=i[0];if((0,o.blank)(n))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(a.sep)}`;const r=i.slice(1),s=await(0,p.volumes)();for(const t of(0,u.toA)(s))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,n)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return a.join(t.mountpoint,...r);return await(0,h.isReadableDirectory)(t)?a.join(t,...r):void 0}},85087:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const n=i(22573),r=i(42659),s=i(9103),a=i(37628);t.volsha=(0,s.memoize)((e=>(0,n.mapNotBlank)(e,a.shortStringSha)),{maxSize:128,ttlMs:r.minuteMs})},60865:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const n=i(37805),r=i(30577);t.channel=function(){return(0,r.extractUpdateChannel)(n.version)},t.baseVersion=()=>[n.versionMajor,n.versionMinor,n.versionPatch].join("."),t.versionMajorMinor=n.versionMajor+"."+n.versionMinor},76280:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const n=i(38064),r=i(22573),s=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function a(e){if(e instanceof n.SemVer)return e.version;const t=s.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=a,t.semverSatisfies=function(e,t){if((0,r.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,n.satisfies)(e,t,i))return!0;const s=a(e);return null!=s&&(0,n.satisfies)(s,t,i)},t.toSemver=function(e){try{return e instanceof n.SemVer?e:(0,n.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const n=i(50989);t.UpdateChannels=(0,n.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},8540:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const n=i(40958),r=i(9595),s=i(29882),a=i(43334),o=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,n.compactBlanks)([o.Settings.libraryDir.valueOrDefault,(0,r.originalsDir)(),...o.Settings.scanPaths.values]))if((!a.isPosix||!(0,s.pathIsRoot)(t))&&(0,s.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},1485:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const n=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,n.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const n=i(19851),r=i(22573),s=i(59455),a=i(50213),o=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,n.lazy)((()=>(0,a.mkLogger)("volumes.DfPosix"))),v=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function w(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),n=(0,g.isExcludedMountpoint)(e.mountpoint),r=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),s=t&&(i||n||r);return y().tap({msg:"acceptPosixVolume()",result:!s,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:n,excludedDir:r}})}t.acceptPosixVolume=w,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,s.toA)(await v());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,r.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,s.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,o.assignMissingPrimitives)(i,e))}return t.filter(w)}},69108:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(31586),o=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,n.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,a.toInt)(e,{defaultValue:0})*o.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,r.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],n=m(e["1024-blocks"])??0;if(0===n)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const r=m(e.Used)??0,s=m(e.Available)??0;if(0!==r||0!==s)return{filesystem:t,mountpoint:i,size:d.isMac?r+s:n,used:r,available:s};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:n,used:r,available:s})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const n=["-k","-P"];if(!0===e&&n.push("-l"),n.push(...(0,r.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",n,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,s.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const a=p(i);return!0===e&&a.forEach((e=>e.remote=!1)),a},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(22573),o=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),v=i(24399),w=i(28874),S=i(24541),b=i(60224),P=i(63870),M=(0,n.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const _=/([a-z]+)(?::\\)?/i;function E(e){return e?.match(_)?.[1]?.toUpperCase()}function x(e){return(0,l.map)(E(e),(e=>e+":\\"))}function T(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(E(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function D(e){return null!=e&&!(0,a.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,a.notBlank)(e.DisplayRoot),...(0,l.map)((0,b.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function k(e){return`Get-Volume ${(0,f.toS)(E(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=x,t.getPsDriveCommand=T,t.getVolumeCommand=k,t.getLocalVolumesWin_=function(){return v.PowerShell.instance().executeJsonToA(k())};const C=/\{([-a-z\d]{7,})\}/i;function F(e,t){return e=e?.trim(),(0,a.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function O(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void M().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=x(e.DriveLetter);if(null==t)return void M().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,r.compact)([F(e.HealthStatus,"healthy"),F(e.OperationalStatus,"OK")]).join("; "),n=null!=e.Size&&null!=e.SizeRemaining&&(0,a.notBlank)(e.DriveLetter)&&(0,a.blank)(i);return M().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(s=e.UniqueId,M().tap({msg:"uniqueId2uuid",result:(0,l.map)(C.exec((0,f.toS)(s)),(e=>e[1])),meta:{s}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:n,status:i},meta:{input:e}});var s}async function I(){const e=(0,r.uniq)((0,h.toA)(await(0,S.mountpointsWin)()).map(x)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(T(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,r.compact)((0,o.flatten)(t).map(D)),n=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(k(e)).catch((t=>(M().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),a=(0,r.compact)((0,o.flatten)(n).map(O)),l=(0,r.uniq)([...i,...a].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,s.sort)((0,r.uniq)([...i,...a].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));M().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:a,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...a.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=O,t.volumeInfoWin=I},68884:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),v=i(83278),w=i(8103),S=i(16287),b=i(45969),P=i(43334),M=i(69108),_=i(98770),E=i(44224),x=i(63870);t.isGioSupported=(0,n.lazy)((async()=>{if(!P.isLinux||(0,b.isDocker)()||(0,d.isBillingService)()||null==await(0,w.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,x.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const T=(0,n.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,n.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?T().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,E.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),S.isReadableDirectory),(e=>e.map((e=>v.BaseFile.for(e).clear().childDirectories())))))}):T().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,r.isEmpty)(e)?[]:(T().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,x.mountpointsTtlMs)(),f:async e=>{const t=await(0,M.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void T().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const n=await D(i.mountpoint);return null==n?i:{remote:!0,...i,...n}}}))},timeoutMs:(0,x.mountpointsTtlMs)()}))),(0,o.later)((()=>(0,_.setupVolumeTTL)(t.gioVolumes)));const D=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,x.commandTimeoutMs)()})).split(/[\r\n]+/),n=(0,s.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(n,(e=>e.hostname)),remoteShare:(0,u.opt)(n).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(s.notBlank).get()}}catch(t){return void T().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs})},98770:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const n=i(19851),r=i(5233),s=i(41400),a=i(56038),o=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,n.lazy)((()=>(0,a.time)("volumes."+e,(()=>(0,r.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,o.isRetriableError)(e)&&!1!==(0,o.isIgnorableError)(e)})))),i);return(0,s.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(31586),o=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),v=i(98770),w=i(63870),S=(0,n.lazy)((()=>(0,o.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>S().warn("lsblk failed",{error:e}))),n=await(0,t.localVolumes_blkid_)().catch((e=>S().warn("blkid failed",{error:e})));if(null==i&&null==n)return;const s=(0,c.sortIgnoreCase)((0,r.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),a=[];for(const t of s){const r=e.find((e=>e.mountpoint===t)),s=i?.find((e=>e.mountpoint===t)),o={...r,...s},u=n?.find((e=>e.filesystem===o.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(o,u),null==o.size||null==o.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];S().info("backfilling mountpoint",{info:s,vol:r,df:e}),null!=e&&(0,l.assignMissingPrimitives)(o,e)}a.push(o)}return a};const b=/lsblk from util-linux ([\d.]+)$/i,P=(0,n.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return b.exec(e)?.[1]?.split(".").map((e=>(0,a.toInt)(e)))})),M=(0,n.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,a.gte)(t[0],2)&&(0,a.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,v.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await M()],{timeoutMs:(0,w.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,s.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,a.toInt)(e.fsused),n=(0,a.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=n?{used:i,available:n,size:i+n}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return S().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,v.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,w.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,s.toNotBlank)(e.PARTLABEL)??(0,s.toNotBlank)(e.LABEL),uuid:(0,s.toNotBlank)(e.PARTUUID)??(0,s.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const n=i(57272),r=i(19851),s=i(40958),a=i(22573),o=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),v=(0,r.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,s.uniq)(e.map((e=>e.filesystem?.match(w)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),r=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of r)try{const t=(0,n.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,a.blank)(t.MountPoint)||(0,o.isTrue)(t.OSInternal)?v().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){v().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const w=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(42659),o=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),v=i(84777),w=i(34330),S=i(8769),b=i(34102),P=i(17217),M=i(16287),_=i(43334),E=i(28874),x=i(8540),T=i(68884),D=i(44224),k=i(24541),C=i(69375),F=i(63870),O=(0,n.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function L(e=(0,F.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function A(){I()}t.localMountpointSetup=(0,n.lazy)((async()=>{E.Settings.libraryDir.watchLater(I),E.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&E.Settings.scanAllDrives.valueOrDefault?(0,o.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(_.isMac&&(e.info("Setting up Mac diskutil activity watcher"),L((0,F.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),_.isLinux){const i=(0,D.maybeWatchProcMounts)();await(0,T.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),L((0,F.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),L((0,F.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),a.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,n.lazy)((()=>{}));t.mountpoints_=(0,n.lazy)((async()=>{{const e=E.Settings.mountpoints.values;if((0,r.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",_.isWin?k.mountpointsWin:D.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,r.isEmpty)(e))return O().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,s.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,F.commandTimeoutMs)(),f:async e=>!(!(0,x.mightBeAssetMountpoint)(e)&&(0,C.isExcludedMountpoint)(e)||E.Settings.validateMountpoints.valueOrDefault&&!await(0,M.isReadableDirectory)(e)&&(O().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,n.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,S.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(_.isWin)return!1;const i=await(0,t.mountpoints)()??[],n=(0,P.toNativePath_)(e);return _.isMac?(0,m.includesIgnoreCase)(i,n):i.includes(n)},(0,o.later)((()=>{(0,b.ee)().on("clearCache",(()=>{T.gioVolumes.unset(),I()})),E.Settings.mountpointsTtlMs.watch(L)}),(0,c.isTest)()?1:a.minuteMs),t.diskUtilActivity=(0,n.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>A(),minCallDelayMs:1.5*a.secondMs})}))),t.gioMountMonitor=(0,n.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:T.GioCommand,args:T.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(T.gioVolumes.unset(),A()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const N=(0,n.lazy)((async()=>{if(!_.isLinux)return!1;try{return 0===(await(0,v.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,F.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,n.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>A(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const n=i(19851),r=i(40958),s=i(42659),a=i(48884),o=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),v=i(28874),w=i(69108),S=i(68884),b=i(59107),P=i(69375),M=(0,n.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await T()??await(0,c.thenMap)((0,w.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,S.isGioSupported)())try{await(0,c.thenMap)((0,S.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){M().warn("Failed to fetch gio volumes",e)}return e};const _="/proc/mounts";function E(e){return!v.Settings.excludedFilesystemTypes.has(e)}function x(e){return!(0,P.isExcludedMountpoint)(e)&&(!v.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function T(e=_,t=E,i=x){if(y.isLinux)try{const n=await(0,f.readLines_)(e),s=(0,r.compact)(n.map((e=>{const[t,i]=e.split(/\s+/);return(0,a.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),o=await(0,c.filterAsync)({name:"mountpoints filter",arr:s,f:async([e,n])=>{const r=t(e),s=await i(n);return M().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:r&&s,meta:{fs:e,mp:n,fsOK:r,mpOK:s}})}});return M().tap({msg:"readProcMounts()",result:o.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void M().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=E,t.readProcMounts=T,t.maybeWatchProcMounts=(0,n.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(_)?new h.FileWatcher(_,{recursive:!1,persistent:!1},(()=>{M().info("detected change in "+_),(0,d.setUnrefTimeout)((()=>b.mountpoints.refresh()),s.secondMs)})):void 0))},24541:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const n=i(19851),r=i(42659),s=i(13538),a=i(50213),o=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,n.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,n.lazy)((async()=>{try{return await(0,s.thenOrTimeoutError)(f(),o.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*r.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const n=i(19851),r=i(22573),s=i(50213),a=i(9103),o=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,n.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,r.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,o.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,o.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,o.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,o.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,r.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],n=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(n)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,a.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const n=i(22573),r=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,s=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function a(e){if((0,n.blank)(e))return;const i=r.exec(e)?.groups;if(null!=i&&!(0,n.blank)(i.remoteHost)&&!(0,n.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(s,""),remoteShare:i.remoteShare};const a=t.nfsRe.exec(e);if(null!=a){const e=a[1],t=a[2];if(!(0,n.blank)(e)&&!(0,n.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=a(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=a},60224:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const n=i(40958),r=i(22573),s=i(42659),a=i(55835),o=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),v=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await E()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,a.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const w=["LocalName","RemoteName","Status"],S=["NETUSE","get",w.join(",")],b=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function M(e){if(!(0,r.blank)(e))return(0,o.opt)(e).flatMap((e=>b.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,o.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,r.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,o.opt)(e.pathname).filter(r.notBlank).getOrElse((()=>"/"))}))))).get()}async function _(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,S,{timeoutMs:15*s.secondMs}),i=(0,u.parseFixed)(w,t);return(0,n.compact)(i.map((e=>(0,a.map)(b.exec((0,l.toS)(e.RemoteName)),(t=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=M,t._netInfoWinWmic=_;const E=(0,v.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?_():(0,n.compact)(e.filter((e=>(0,r.notBlank)(e.LocalName))).map((e=>(0,a.map)(M(e.RemoteName),(({host:t,share:i})=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(n=>({mountpoint:(0,h.ensureSuffix)(n[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const n=i(42659),r=i(12168),s=i(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=r.MiB/n.secondMs},86848:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const n=i(76760),r=i(19851),s=i(22573),a=i(38639),o=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),v=i(95696),w=i(45969),S=i(28874),b=i(59107),P=i(63870),M=i(68995),_=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),E=(0,r.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function x(e){return(0,a.isTrue)(e.ignorable)||(0,w.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,n.basename)(e.mountpoint)}function T(e){if((0,s.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function D(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=T(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function k(e){if(S.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of S.Settings.volumeUuidFilePaths.values){const i=v.PosixFile.for(e.mountpoint).join(t),n=await D(i).catch((e=>_().info("Failed to read "+i,{error:e})));if(null!=n)return _().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:n,meta:{mountpoint:e.mountpoint}})}const t=(0,n.join)(e.mountpoint,(0,M.volumeUuidSubpath)());if("/"===e.mountpoint)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(S.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(S.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,M.writeVolumeUuid)(e);if(!(0,s.blank)(t))return _().tap({msg:"readVolumeUUID(): wrote new "+(0,M.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return _().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,o.later)((()=>{(0,m.ee)().on("clearCache",(()=>E.clear())),b.mountpoints.watchLater((()=>E.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(x(e))return;if((0,a.isFalse)(e.ok))return;const t=await E().getOrSetAsync(e.mountpoint,(async()=>k(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>_().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=x,t.toVolumeUUID=T,t.readUuidFile_=D,t.readVolumeUUID=k},7014:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const r=n(i(48161)),s=n(i(76760)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),v=i(59455),w=i(48884),S=i(50213),b=i(7282),P=i(23560),M=i(28850),_=i(45255),E=i(81168),x=i(56519),T=i(4867),D=i(49776),k=i(9595),C=i(77740),F=i(44198),O=i(96706),I=i(8769),L=i(57159),A=(i(34102),i(21144)),R=i(73209),N=i(29882),B=i(95696),z=i(17217),j=i(16287),V=i(49076),W=i(96128),H=i(45969),U=i(43334),q=i(28874),G=i(85087),$=i(50424),J=i(48165),K=i(98770),Z=i(27461),X=i(66840),Y=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),ne=(0,a.lazy)((()=>(0,S.mkLogger)("volumes.Volumes"))),re=r.default.platform(),se=new Map,ae=new Map,oe=new Map;function le(e,t,i){if((0,u.blank)(e))return;const n=i.get(e);null!=n&&(0,p.gt)(n.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,G.volsha)(t.uuid),(e=>ae.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,se),le((0,G.volsha)(e.uuid),e,oe),e}function ce(){return(0,o.compact)([B.PosixFile.forMaybe((0,D.cacheDir)())?.join("volumes"),B.PosixFile.forMaybe((0,k.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),ae))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){ne().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),se.clear(),oe.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,x.mapAsync)({name:"readCachedVolumes",arr:(0,x.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,o.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,E.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const n=Date.now(),r=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,H.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:n,os:re}))),s=new Map;for(const e of r)for(const t of(0,o.compactBlanks)([(0,G.volsha)(e.uuid),(0,G.volsha)(e.mountpoint)]))s.set(t,e);const a=ce();for(const e of a)await(0,R.withLock_)({file:e,timeoutMs:_.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of s.entries()){const n=e.join(t+".json");try{await n.writeJson_(i)}catch(e){ne().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:n.nativePath,vol:i}),await n.unlink()}}}));ne().debug("writeVolumesToCache(): complete.",{dirs:a,vol_mountpoints:r.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,o.isNotEmpty)(e))return e;const i=(0,v.toA)(await(0,Y.mountpoints)()),n=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,q.Settings.volumeMetadataTtlMs.valueOrDefault),r=0!==q.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,n))),s=!(0,o.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return ne().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:r,priorIsMissingMountpoints:s}),r||s?void 0:e}async function me(e,i){const n=(0,m.map)(e,z.toNativePath_);if((0,u.blank)(n))return;const r=await(0,A.actualPath)(n);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,o.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(r,t.map((e=>e.mountpoint)));if(null==i)continue;const n=t.find((e=>e.mountpoint===i));if(null!=n)return ne().trace("bestVolumeForPath()",{nativePath:r,result:n.mountpoint,src:e.name}),n}return ne().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:r}})}async function pe(e,t,i){const n=i.filter((e=>(0,E.equalsIgnoreCase)(t,e.remoteShare)));if((0,o.isEmpty)(n))return;const r=n.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,E.equalsIgnoreCase)(e,t.remoteHost)));if(null!=r)return r;const s=await(0,W.friendlyname)(e);return(0,x.asyncFind)(n,(async e=>(0,E.equalsIgnoreCase)(s,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,a.lazy)((()=>(0,P.isSyncService)()||(0,b.isTest)())),t.priorWriteVolumesToCacheLatch=(0,a.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,a.lazy)((async()=>{const e=(0,o.compact)(await de()),t=(0,v.toA)(await(0,Y.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),n=(0,o.isNotEmpty)(i)?i:e.filter((e=>re===e?.os));return ne().tap({msg:"cachedVolumes()",level:"trace",result:n.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,T.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return ne().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,T.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,o.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,L.toWrappedError)("volumes() failed",{cause:e}))}return ne().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,M.shim0)({name:"fs.volumes",impl:async function(){if((0,b.isTest)()){const e=(0,p.toInt)((0,F.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(ne().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,C.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void ne().throw("PS_FAIL_VOLUMES")}const e=await(0,T.thenOrTimeoutError)({p:U.isWin?(0,J.dfWin)():(0,$.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void ne().warn("df failed");const t=q.Settings.validateMountpoints.valueOrDefault?(0,o.compact)(await(0,x.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,j.isReadableDirectory)(e.mountpoint))return e;ne().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){ne().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,T.thenOrTimeoutError)({p:U.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(U.isWin?t:U.isMac?await(0,X.addLocalVolumeInfoMac)(t):await(0,Z.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const n=(0,l.sortBy)(i,(e=>e.mountpoint));return ne().debug("_volumes(): final result",{sorted:n}),n.forEach(ue),await he(n),Object.freeze(n)}}),t.rootPath=(0,a.lazy)((()=>U.isWin?(0,g.opt)((0,O.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,E.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,o.isEmpty)(t)?void 0:(0,w.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,o.commonPrefixLength)(e.split(s.default.sep),t.split(s.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,v.toA)(await i.vols()).find((t=>(0,G.volsha)(t.uuid)===e));if(ne().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,x.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return oe.get(e)??(await de())?.find((t=>(0,G.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,G.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const n=i(76760),r=i(19851),s=i(22573),a=i(50213),o=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,s.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,n.join)(e,f());t=(0,s.toNotBlank)(t)??(0,c.safeUUID)();const r=(0,n.dirname)(i);if(await(0,l.isReadWriteableDirectory)(r))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+o.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const n=i(50989);t.HelmetPlugins=(0,n.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},65713:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const n=i(76760),r=i(19851),s=i(23838),a=i(81168),o=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,r.lazy)((()=>(0,n.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,r.lazy)((async()=>{const e=(0,o.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,r.lazy)((()=>({trie:new s.MultiMap,small:[]}))),h=3;function f(e){const t=new s.MultiMap,i=[];for(const n of e)n.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tn.startsWith(e)));if(null!=r)return r}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const n=i(22573),r=i(96249),s=i(23838),a=i(59455),o=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=s.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,n.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,a.toA)(u[t])],s=c(e.substring(1));return(0,r.flatten)(s.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const n of e)t+=i[n]?.[0]??n;return t},t.unl33t=function(e){return c((0,o.stripDiacritics)(e).normalize())}},30933:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const r=n(i(48161)),s=i(19851),a=i(42659),o=i(31586),l=i(50213),u=i(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>r.default.cpus()),5*a.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=r.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,o.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const r=n(i(48161)),s=i(19851),a=i(31586),o=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=r.default.freemem(),t=r.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const n=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,a.gt0)(n))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([n,i]),meta:{freemem:e,totalmem:t,cgroupMem:n}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,o.fmtBytes)(i),freemem:(0,o.fmtBytes)(e),totalmem:(0,o.fmtBytes)(t)}})}))},15674:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const n=i(19851),r=i(42659),s=i(41400),a=i(31586),o=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,n.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,n.lazy)((()=>{const e=(0,a.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*o.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/o.MB),worstCaseMemPerProcMb:Math.ceil(e/o.MB)}})}),r.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,a.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,a.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,f.cpuCount)())<=1},t.maxCpus=(0,n.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,n=w();if(1!==n){const e=t;t*=n,g().warn("Recent timeouts! Throttling down.",{penalization:n,resultBeforePenalization:e,resultAfterPenalization:t})}const r=Math.min(e,v());return t=(0,a.clamp)(1,r,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:n,timeoutsPerSecond:i,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,n.lazy)((function(){return(0,a.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,a.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,a.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},22751:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const n=i(58587),r=i(87997),s=i(19851),a=i(42659),o=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new n.Rate(5*a.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,s.lazy)((()=>(0,r.setInterval)(g,a.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,o.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},91863:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=n(i(1708)),s=i(98553),a=i(5670),o=i(59880),l=i(19913),u=i(71567),c=i(80061),d=i(17181),h=i(41944),f=i(28874),m=i(7014),p=i(16848);!async function(){r.default.argv.includes("--help")&&(console.log((0,c.cliWrapWithFooter)("This is PhotoStructure's background worker, and is for internal use only")),r.default.exit(0)),(r.default.argv.includes("--version")||r.default.argv.includes("-V"))&&(console.log((0,c.cliWrapVersion)()),r.default.exit(0)),(0,l.setServiceName)(a.ServiceNames.worker),(0,o.setShortProcessNames)(f.Settings.shortProcessNames.valueOrDefault),(0,o.setProcessTitle)(),(0,d.setupLogger)(),r.default.argv.includes("--volumes")&&(console.log((0,s.stringify)(await(0,m.volumes)())),r.default.exit(0)),h.onProgressEvt.setShim((async e=>{(0,u.stdoutWrite)(e,void 0)})),(0,p.handleWorkRequests)()}()},24817:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.handleWorkRequest_=t.isWorkRequest=t.mkWorkRequest=t.WorkRequestMethods=t.WorkerFunctions=t.AllWorkerFunctionCandidates=void 0;const n=i(98553),r=i(31586),s=i(68708),a=i(50989),o=i(32639),l=i(13991),u=i(50597),c=i(48368),d=i(52121),h=i(48604),f=i(181),m=i(66106),p=i(47783),g=i(83966);t.AllWorkerFunctionCandidates={_extractVideoFrame_:m._extractVideoFrame_,_readRawTags:p._readRawTags,_readTags:p._readTags,assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkerFunctions={assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkRequestMethods=(0,a.strEnum)(...(0,s.keys)(t.WorkerFunctions));let y=0;t.mkWorkRequest=function(e,t){return{id:++y,fn:e,args:t}},t.isWorkRequest=function(e){return"object"==typeof e&&t.WorkRequestMethods.has(e?.method)&&(0,r.isNumber)(e.id)},t.handleWorkRequest_=async function(e){const i=t.WorkerFunctions[e?.fn];if((0,o.isFunction)(i))return i(e?.args);throw new Error("invalid method "+(0,n.stringify)(e))}},16848:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.handleWorkRequests=void 0;const r=n(i(1708)),s=i(19851),a=i(50213),o=i(71567),l=i(33456),u=i(22573),c=i(26905),d=i(67478),h=i(54993),f=i(45608),m=i(55534),p=i(8769),g=i(57159),y=i(24817),v=(0,s.lazy)((()=>(0,a.mkLogger)("worker.Worker")));async function w(e){if(e=(0,h.toS)(e),(0,u.blank)(e))return;if(e.trim()===m.ServiceExitCommand)return(0,f.exit)({reason:e+" from stdin",status:0});const t=(0,d.parseJSON)(e);v().trace("onData",{request:t});try{const e=await(0,y.handleWorkRequest_)(t);(0,o.stdoutWrite)({id:t.id,response:e},!0)}catch(e){const i=(0,c.errorToJson)(e);v().warn("failed to process request",{request:t,error:i}),(0,o.stdoutWrite)({id:t.id,error:i},!1)}}t.handleWorkRequests=function(){!0!==r.default.stdin?.readable?(0,f.exit)({reason:"process.stdin is not readable",status:13}):(function(){for(const e of["SIGINT","SIGTERM"])r.default.on(e,(e=>(0,f.exit)({reason:e,status:0})))}(),function(){for(const e of["uncaughtException","uncaughtException","disconnect"])r.default.on(e,(e=>{const t=new g.WrappedError("uncaughtException",{cause:e});return(0,p.onError)(t)?(0,f.exit)({error:t,status:(0,c.errorErrno)(t)??1}):void 0}))}(),(0,f.exitOnStdStream)(),r.default.stdin.pipe(new l.LineReader).on("data",w),v().info("Child process mode: listening on stdin..."))}},83966:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ping=void 0;const r=n(i(1708)),s=i(41400),a=i(31586),o=i(7282),l=i(12089),u=i(45608),c=i(57159),d=i(89035);t.ping=(0,l.shim1)({name:"worker.ping",async impl(e){if((0,a.gt0)(e?.delay)&&await(0,s.delay)(e.delay),(0,o.isTest)()&&!0===e?.pretendMemUsageIsHigh&&d.memoryUsageIsHigh.set(!0),null!=e?.throw)throw new c.WrappedError(e.throw.message,e.throw);if((0,d.memoryUsageIsHigh)())throw(0,u.exit)({reason:"memory usage is high",status:1}),new c.WrappedError("Memory usage is high",{fatal:!0});return{pid:r.default.pid,input:e?.input??"(no input)"}}})},40958:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const n=i(76790),r=i(22573),s=i(50357),a=i(98553),o=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function v(e,t){for(let i=0;i=e.length||i>=e.length)return e;const n=e[t];return e.splice(t,1),e.splice(i,0,n),e}function S(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const n of e)if(null!=n){const e=t(n);null!=e&&(0,o.getOrSet)(i,e,(()=>n))}return[...i.values()]}function P(e,t,i=1,n=(e=>e)){const r=[];if(et;s-=i)r.push(n(s));return r}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,n.sortBy)(e,g),r=(0,n.sortBy)(t,g);return i.every(((e,t)=>e===r[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,s.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const n=e.map(i);for(const r of t){const t=i(r);n.includes(t)||(e.push(r),n.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let n=0;n0)return e.splice(n,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(r.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,a.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,s.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const i=[];for(const e of(0,n.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,n.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const n of e)if(null!=n){const e=t(n);null!=e&&i.set(e,n)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const n of e)null!=n&&i.every((e=>!t(n,e)))&&i.push(n);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,n)=>e+(t(i,n)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,n)=>e+t(i,n)),0)},t.firstMatch=function(e,t){for(const i of S(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const n=Math.round(i);if(n<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,a.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,n=t.primitiveValueOfOrElse){const r=new Set(i.map(n));return e.filter((e=>!r.has(n(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const n=i(40958),r=i(36783),s=i(41801),a=i(98553),o=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,r.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const n of e)(0,o.getOrSet)(i,(0,a.stringify)(t(n)),(()=>n));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,n.compact)(e),n.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,r.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,n)=>0===n||t(i)>=t(e[n-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,s.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const n=e.findIndex((e=>i(t){Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const n=i(32639);t.asPromise=async function(e){const t=await e;return(0,n.isFunction)(t)?t():t}},75761:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.assetImgAttrs=t.assetSqImgAttrs=t.assetVideoLink=t.assetImgActualLink=t.assetImgLink=t.assetLinkAttrs=t.assetUrl=void 0;const n=i(58939),r=i(40958),s=i(22573),a=i(42659),o=i(11371),l=i(73722),u=i(31586),c=i(54993),d=i(29652),h=i(22403),f=i(2322);function m(e,t){return e+" "+t+"w"}function p(e,t){let i=null==t?void 0:(0,d.mergeURLSearchParams)(...t);const n=(0,c.toS)(e.v);return(0,s.blank)(n)||"1"===n||(i??(i=new URLSearchParams)).append("v",n),i}function g({assetId:e,params:t}){return null==e?"":(0,d.assembleFullPath)("/asset/"+(0,n.id2id)(e),p(e,t))}function y({assetId:e,reducer:t,width:i,params:r}){return(0,d.assembleFullPath)(`/img/${(0,n.id2id)(e)}/${t}/${(0,u.toGt0)(i)??320}`,p(e,r))}function v({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/img/${(0,r.compact)([(0,n.id2id)(e),t]).join("/")}/actual`,p(e,i))}function w({assetId:e,params:t,reducer:i,widths:r,lazyLoad:s,af:l}){if(null==(0,n.id2id)(e))return{src:"/images/clear-64.png"};0===(r=(r??[]).filter(u.gt0)).length&&r.push(320);const d=Math.min(...r),p={width:(0,c.toS)(d)},g=(0,a.fmtLocalToShort)(e.capturedAtLocal);null!=g&&(p.title=g);const w=y({assetId:e,params:t,reducer:i,width:d});s??(s=!0);const S=s&&(0,f.isSafari)((0,h.ua)());S?(p.src="/images/clear-64.png",p["data-src"]=w):p.src=w,(0,f.isSafari)((0,h.ua)())||(p.loading=s?"lazy":"eager"),i===o.ReducerNames.sq&&(p.height=(0,c.toS)(d));const b=r.map((n=>m(y({assetId:e,params:t,reducer:i,width:n}),n)));return null!=l&&b.push(m(v({assetId:e,params:t,assetFileId:l.assetFileId}),l.width)),p[(S?"data-":"")+"srcSet"]=b.join(","),p}t.assetUrl=g,t.assetLinkAttrs=function({assetId:e,params:t}){const i=g({assetId:e,params:t});return(0,s.blank)(i)?{}:{href:i}},t.assetImgLink=y,t.assetImgActualLink=v,t.assetVideoLink=function({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/video/${(0,n.id2id)(e)}-${t}`,p(e,i))},t.assetSqImgAttrs=function({assetId:e,params:t,lazyLoad:i,size:n="m"}){return{...w({assetId:e,params:t,reducer:"sq",widths:l.SqWidths,lazyLoad:i}),sizes:("s"===n?80:"m"===n?160:320)*(0,u.numericOr)(globalThis?.window?.devicePixelRatio,1)+"px"}},t.assetImgAttrs=w},5233:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const n=i(41400),r=i(31586),s=i(13538),a=i(41583);t.retryOnReject_=async function(e,t){const i=(0,r.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const o=t.onRetryWaitUntil??(e=>(0,n.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,a.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await o(l),u()}};return u()}},17586:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const n=i(40958),r=i(22573),s=i(96249),a=i(55938),o=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,a.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,a.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,r.blank)(e)?"":"```"+(0,o.toS)(e)+"```"},t.b=function(e){return"**"+(0,o.toS)(e)+"**"},t.li=function(...e){return(0,n.compactBlankish)((0,s.flatten)(e)).map((e=>"- "+(0,o.toS)(e))).join("\n")}},22573:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const n=i(55835),r=i(42279),s=i(54993);function a(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function o(e){return!a(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,s.toS)(e);return o(i)?t(i):void 0}t.blank=a,t.notBlank=o,t.notBlankToS=function(e){return o(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,r.tot)(t);const i=(0,s.toS)(e).trim();return i.length>0?i:(0,r.tot)(t)},t.notBlankAnd=function(e,t){return!a(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,n.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function n(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!n(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!n(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=n,t.isDisabled=function(e){return n(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):n(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const n=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,n.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const n=i(40958),r=i(22573),s=i(30301),a=i(55835),o=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,a.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,o.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const n=Math.floor(e/t.hourMs);e-=n*t.hourMs;const r=Math.floor(e/t.minuteMs);e-=r*t.minuteMs;const s=Math.floor(e/t.secondMs),a=Math.floor(e-s*t.secondMs);return(0,l.pad2)(n)+":"+(0,l.pad2)(r)+":"+(0,l.pad2)(s)+(i.includeMs?"."+(0,l.pad3)(a):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},n=10*i(),r=i(),s=i(),a=i(),o=i(),l=i();return new Date(t,l-1,o,a,s,r,n)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,i="ago"){return e<1e3?"just now":(i=(0,r.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const s=Math.floor(e/n.ms);e-=s*n.ms,s>0&&(n.ms>=t.dayMs?i:r).push(s+n.s)}return e>0&&r.push((0,o.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,n.isEmpty)(r)?"":"T"+r.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,a.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const n=i(38639),r=i(73872);function s(e,t,i){if(null==i||y(e)||y(t))return null;const n=i.get(e)?.get(t);return"boolean"==typeof n?n:null}function a(e,t,i,n){if(null==i||y(e)||y(t))return;let r=i.get(e);null!=r?r.set(t,n):(r=new WeakMap,r.set(t,n),i.set(e,r))}function o(e,t,i,n){if(null!=i?.comparator)return u(e,t,i,n);const r=l(e,t);return null!==r?r:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,n){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=s(e,t,u);if(null!==f)return f;const m=s(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,n);if(!1===i||!0===i)return a(e,t,u,i),i;const r=l(e,t);if(null!==r)return r}const y=r(e);if(y!==r(t))return a(e,t,u,!1),!1;a(e,t,u,!0);const v=function(e,t,i,n){switch(i){case"String":case"Number":case"Boolean":case"Date":return o(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],n);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,n);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,n);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),n);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),n);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const n=[],r=[];return e.forEach((function(e,t){n.push([e,t])})),t.forEach((function(e,t){r.push([e,t])})),c(n.sort(),r.sort(),i)}(e,t,n);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,n)}}(e,t,y,i);return a(e,t,u,v),v}function c(e,t,i){const n=e.length;if(n!==t.length)return!1;if(0===n)return!0;let r=-1;for(;++r{Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,n=!1;const r=function(){if(n){if(null!=i)throw i;return t}try{return n=!0,t=e()}catch(e){throw i=e,e}};return r.prior=()=>t,r.hasPrior=()=>n,r}},41400:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const n=i(42659),r=i(35556),s=i(31586),a=i(68708);function o(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const s=setTimeout((()=>i()),Math.ceil(e+.5));e>n.secondMs&&t&&r.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return o(t).then((()=>t))},t.delay=o,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),s=r.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return r.isBrowser||t<=n.secondMs?s:(0,a.maybeCall)(s,"unref")??s}},33374:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const n=i(31586),r=i(21605),s=i(12168);function a(e){return{width:e.height,height:e.width}}function o(e){return((0,n.toGt0)(e?.width)??0)*((0,n.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,n.gt0)(e.width)&&(0,n.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,n.gt0)(e)&&(0,n.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,s.pixels2size)(e.width*e.height)},t.dimSwap=a,t.maybeDimSwap=function(e,t){return(0,r.swappableRotation)(t)?a(e):e},t.maybeFlipInPlace=function(e,t){(0,r.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,s.megapixels)(o(e))},t.pixels=o},50357:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const n=i(12487),r=i(68708),s=i(34666),a=i(32639);function o(e,t){return(0,n.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,a.isFunction)(e)&&(0,a.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=o,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,r.isObject)(e)||!(0,r.isObject)(t))return!1;for(const i of(0,r.keys)(e))if(!o(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const n=d.get(i);if(null!=n)return n(e,t)??null}for(const i of c){const n=i(e,t);if(null!=n)return n}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const n=i(40958),r=i(22573),s=i(96249),a=i(31586),o=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,r.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,a.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,n.uniq)((0,n.compactBlankish)((0,s.flatten)((0,n.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,r.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,r.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,n.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,r.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(r.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,o.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,o.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,o.assignFields)(new Error,(0,o.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},4188:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const n=i(59455);t.flatten=function(e,t=[]){for(const i of(0,n.toA)(e))if(null!=i)for(const e of(0,n.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const n=i(40958),r=i(42659),s=i(55835),a=i(31586),o=i(12168),l=[{ms:r.yearMs,s:"year",p:"years"},{ms:r.yearMs/12,s:"month",p:"months"},{ms:r.weekMs,s:"week",p:"weeks"},{ms:r.dayMs,s:"day",p:"days"},{ms:r.hourMs,s:"hour",p:"hours"},{ms:r.minuteMs,s:"minute",p:"minutes"},{ms:r.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,r){if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,s.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,n.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,o.plur)(t,e.s,e.p)}}})));return(0,n.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,s.mapOr)(r,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const n=i(40958);function r(e,t){return null==(e=(0,n.uniq)((0,n.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=r,t.orList=function(e){return r(e,"or")},t.andList=function(e){return r(e,"and")}},50268:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const n=i(22573),r=i(38639),s=i(68708),a=i(62220),o=i(50989);t.HealthCheckSections=(0,o.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,o.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,s.isObject)(e)&&!(0,n.blank)(e.id)&&!(0,n.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,n.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,s.isObject)(e)&&a.RunStates.has(e.state)&&(0,r.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},11371:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReducerNames=void 0;const n=i(50989);t.ReducerNames=(0,n.strEnum)("fit","sq")},73722:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const n=i(50989);t.FitSizes=(0,n.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,n.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const n=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,n.lt0)(t))return[...e].slice(t,i);const r=e[Symbol.iterator]();if((0,n.gt0)(t))for(let e=0;e{Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(n,r){if((0,isFunction_1.isFunction)(n))return;let s,a,o,l=toJSON(n);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(n===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let n=0;t.Latch=class{constructor(e=n++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const n=i(40958),r=i(50357),s=i(31586),a=i(65812);t.lazy=function(e,t){let i,o;const l=[];function u(){return u.isStale()&&u.setResult(e()),o}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,n.isEmpty)(l))return;const s=await e,o=await i;if(!(0,r.eql)(s,o))for(const e of l)e(o);null!=t&&t>0&&void 0!==o&&(0,a.setUnrefTimeout)((()=>u.vacuum()),t)}(o,e),o=e},u.isStale=function(){return null==i||(0,s.gt0)(t)&&i+t{Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const n=i();return null!=n&&e.set(t,n),n}},t.deleteIf=function(e,t){for(const[i,n]of e.entries())t(i,n)&&e.delete(i)}},55835:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const n=i(42279),r=i(54993);function s(e,t){return null==e?void 0:t(e)}function a(e,t,i){return null==e||null==t?void 0:i(e,t)}function o(e,t){return null!=e?e:(0,n.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=a,t.map3=function(e,t,i,n){return null==e||null==t||null==i?void 0:n(e,t,i)},t.orElse=o,t.mapOr=function(e,t,i){return null!=e?t(e):(0,n.tot)(i)},t.map2Or=function(e,t,i,n){return o(a(e,t,i),n)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,r.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const n=i(68708);class r extends Error{constructor(e,t){super(e),this.message=e,(0,n.assignFields)(this,t)}}t.MetaError=r},23838:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const n=i(40958),r=i(76790),s=i(50357),a=i(98553),o=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,n]of Object.entries(e))t.add(i,...n);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,n.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,o.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,n.pushUniq)((0,o.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const n=i.filter((e=>!(0,s.eql)(e,t)));return 0===n.length?this.store.delete(e):this.store.set(e,n),i.length!==n.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,n.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),r=null==i?[]:e(t,i);(0,n.isEmpty)(r)?this.store.delete(t):this.store.set(t,r)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,n.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,r]of this.store.entries()){const s=(0,n.findIndexes)(r,(t=>!e(i,t,r)));if(s.length>0){t=!0;for(const e of s.reverse())r.splice(e,1)}0===r.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const n of i)e.add(n,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,n]of this.entries())n.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,a.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,r.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const n=i(76790),r=i(22573),s=i(42279),a=i(54993);function o(e){return"number"==typeof e&&isFinite(e)}t.isNumber=o,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,a.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return o(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,a.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>o(t)&&o(i)&&e(t,i);function f(e,i,r){return!(null==r||!o(r))&&([e,i]=(0,n.sort)([e,i]),(0,t.lte)(e,r)&&(0,t.gte)(i,r))}function m(e){if(!o(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,r.blank)(e))return t.defaultValue;if(o(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return o(e)&&e>0}function S(e){return o(e)&&e>=0}function b(e,t){return o(e)?t(e):void 0}function P(e){return o(e)?e<0?-Math.round(-e):Math.round(e):0}function M(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function _(e,t,i){if(e>t||!o(e)||!o(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return o(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return o(e)?e:t},t.diff=function(e,t){return o(e)&&o(t)?e-t:void 0},t.absdiff=function(e,t){return o(e)&&o(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!o(e)||!o(t))return!1;if(e===t)return!0;if(i>=1)return!1;const n=(0===t?1e-5:t)*(1-i);return f(t-n,t+n,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)o(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return o(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return o(e)&&o(t)&&e>t?e:void 0},t.lte0=function(e){return o(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=v(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,i){return b(e,(e=>b(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return o(e)?t(e):i},t.numericOr=function(e,t){return o(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d+\.\d+)0+$/,"")},t.toPrecision=M,t.toPrecisionMaybe=function(e,t){return d(e,(e=>M(e,t)))},t.sigFigs=function(e,t){if(!o(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),n=Math.pow(10,Math.abs(i));return i<0?P(e/n)*n:P(e*n)/n},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=_,t.times=function(e,t){if(!w(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return _(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!o(i))return;t+=i}return t}},68708:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const n=i(40958),r=i(76790),s=i(22573),a=i(32639),o=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,n]=i;null!=e&&void 0!==n&&("object"!=typeof t&&(t={}),t[e]=n)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,n.isEmpty)(i)?void 0:y(i)}function w(e,t,i={}){return y((0,n.compact)((0,r.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function S(...e){const t=(0,n.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const r={};for(const e of(0,n.uniq)((0,n.flatMap)(i,h)))r[e]=S(...i.map((t=>t[e])));return r}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=v(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[n,r]of g(t))!0!==i?.omitKeys?.includes(n)&&(null==r&&!0!==i?.assignNullish||(e[n]=r));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const n of i){const i=t[n];void 0!==i&&void 0===e[n]&&(e[n]=i)}return e},t.assignAllFields=function(e,t){for(const[i,n]of g(t??{}))e[i]=n;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,n.isEmpty)(i)?void 0:y(i)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,n.compact)(t.map(e));{const i=(0,n.compact)(g(t).map((([t,i])=>(0,o.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,n.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const i={};for(const n of t)void 0!==e[n]&&(i[n]=e[n]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const n of t)void 0!==e[n]&&(i[n]=e[n]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const n of t){const t=e[n];(0,s.notBlank)(t)&&(i[n]=t)}return i},t.pickFirst=function(e,t,i=o.defined){if(null!=e)for(const n of t)if(i(e[n]))return e[n]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const n={};function r(e,t){if(null==t)return;const i=n[e];n[e]=null==i?t:S(i,t)}for(const n of i){const[i,a]=(0,c.splitFirst)(n,"."),o=b(t,i);null!=o?.value&&r(o.key,(0,s.blank)(a)?o.value:e(o.value,a))}for(const n of h(t))((0,l.toInt)(n)??-1)>=0&&r(n,e(t[n],...i));return n},t.pluck=b,t.pluckDeep=function e(t,i){if(null==t||(0,s.blank)(i))return;if(Array.isArray(t)){const r=(0,n.compact)(t.map((t=>e(t,i))));return(0,n.isEmpty)(r)?void 0:{key:r[0].key,value:(0,n.flatMap)(r,(e=>e.value))}}const[r,a]=(0,c.splitFirst)(i,"."),o=b(t,r);if(null==o)return;if((0,s.blank)(a))return o;const l=e(o.value,a);return null==l?void 0:{key:o.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,n.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,n.uniq)(t)},t.maybeCall=function(e,t,...i){const n=e?.[t];return(0,a.isFunction)(n)?n.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=w(t,((t,i)=>[t,e(i)])),n=p(i);return 1===n.length?n[0]:i}},97790:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class n{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new n(e(this.a))}flatMap(e){const t=e(this.a);return r(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return s(e).flatMap((e=>s(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,n){return s(e).flatMap((e=>s(t).flatMap((t=>s(i).flatMap((i=>n(this.a,e,t,i)))))))}}function r(e){return e instanceof n||e===t.None}function s(e){return r(e)?e:null!=e?new n(e):t.None}t.Some=n,t.isOpt=r,t.opt=s},39926:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const n=i(31586),r=i(54993),s={};function a(e,t){if(t<1)return"";if(!(0,n.gte)(s[e]?.length,t)){let i=s[e]??e;for(;i.length{Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var n=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return n.parseJSON}})},46891:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const n=i(22573),r=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,a=/[^aeiou]y$/,o=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,n.blank)(e))return e;const t=r.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(a)?e.replace(/y$/i,"ies"):null!=e.match(o)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const n=i(40958),r=i(54993),s=["number","string","boolean"];function a(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=a,t.mapPrimitive=function(e,t){return a(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return a(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(a)};const o=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const n=typeof e,s=typeof i;if(!("string"!==n&&"symbol"!==n||"string"!==s&&"symbol"!==s)){const n=(0,r.toS)(e),s=(0,r.toS)(i),a=n.localeCompare(s);return n[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-a:a}return Array.isArray(e)&&Array.isArray(i)?u(e,i):n!==s?o.indexOf(n)-o.indexOf(s):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const n=i(59455);function r(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const r of(0,n.toA)(await e))if(null!=r){const e=await r;if(null!=e){const n=await t(e);null!=n&&i.push(n)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=r,t.isPromise=function(e){return r(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const n=await e;return t(n)?i(n):void 0}},57153:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const n=i(50989);t.PromiseStates=(0,n.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const n=i(40958),r=i(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function a(e,t,i){return null==i||0===i.length?s(e,t):o(e,t,1,i)[0]}function o(e,t,i,n){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const r=t-e,a=new Set(n??[]);if(t===e&&0===r&&0===a.size&&1===i)return[e];const o=r-a.size;if(i>o)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:r,size:i,slotsRemaining:o})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const n of o(0,e.length,t))i.push(e[n]);return i},t.pickWeightedRandom=function(e){if((0,n.isEmpty)(e))return;const t=e.filter((e=>(0,r.gt0)(e.priority)));let i=l(0,(0,n.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let n=e;t.global||(t=new RegExp(t,"g"));let r=null;for(;null!=(r=t.exec(e));)r.index===t.lastIndex&&t.lastIndex++,n=n.slice(0,r.index)+i(r)+n.slice(r.index+r[0].length);return n}},21605:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const n=i(31586);function r(e){if(!(0,n.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,n.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=r,t.swappableRotation=function(e){const t=r(e);return 90===t||270===t}},62220:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const n=i(50989);t.RunStates=(0,n.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const n=i(50989);t.ServiceNames=(0,n.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const n=i(68708),r=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,n.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const a=e=>null!=e?i[e]:void 0,o=e=>null!=a(e);return{...s,values:t,length:t.length,has:o,includes:o,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:a,ordinal:e=>a(e)??t.length,validOrElse:(e,t)=>o(e)?e:(0,r.tot)(t),mapValid:(e,t)=>o(e)?t(e):void 0,cmp:(e,t)=>{const i=a(e),n=a(t);return null==i||null==n?void 0:i>n?1:i{const i=a(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const n=i(40958),r=i(17586),s=i(22573),a=i(96249),o=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const n=f();return null!=n?(0,o.sliceIterable)(n.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),n=(0,c.toS)(t);return n.length>0&&i.startsWith(n)?i.slice(n.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),n=(0,c.toS)(t);return n.length>0&&i.endsWith(n)?i.slice(0,-n.length):i}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,i){null==i&&(i=e.length);for(let n=i;n>=0;n--)if(m(e,n).startsWith(t))return n;return-1}function b(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const n=(0,c.toS)(e),r=(0,c.toS)(t);return n.length===r.length&&(n===r||n.toLowerCase()===r.toLowerCase()||"function"==typeof n.localeCompare&&0===(i?n.normalize():n).localeCompare(i?r.normalize():r,void 0,{sensitivity:"base"}))}function P(e,t){return(0,n.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,r.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,o.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const n=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&n.startsWith(t))return e(n.slice(t.length),i);return n},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return w(v(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const n=p(e);return n.length<=t?n.join(""):n.slice(0,t-1-i).join("")+"…"+(i>0?n.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,i){const n=i?.maxLineLen??80,r=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const n=(0,a.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,a.flatten)(n.map((t=>e(t,i))))}if((t=v((0,c.toS)(t),r).trim()).length<=n)return[t];const s=S(t," ",n);if(s>r.length)return[m(t,0,s),...e(m(t,s+1),i)];{const n=t.indexOf(" ",r.length+1);return n>0&&n{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const n=i(42659),r=i(68708),s=i(42279),a=i(83104),o=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,n)=>{let r=!0;const s=setTimeout((()=>{r&&(r=!1,i(a.Timeout))}),t);try{s.unref?.();const t=await e;r&&(r=!1,i(t))}catch(e){r&&(r=!1,n(e))}finally{clearTimeout(s)}}))}async function u(e,t,i=!0){const r=await l(e,t,i);if(r===a.Timeout)throw new o.TimeoutError("timeout ("+(0,n.fmtHMS)(t)+")");return r}t.toNotTimeout=function(e){return e===a.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const n=t-Date.now();return n<=0?a.Timeout:l(e,n,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(n,s)=>{let a=!0;try{const o=setTimeout((async()=>{if(a){a=!1;try{n(await i())}catch(e){s(e)}}}),t);(0,r.maybeCall)(o,"unref");const l=await e;a&&(a=!1,clearTimeout(o),n(l))}catch(e){a&&(a=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const r=t-Date.now();if(r<=0)throw new o.TimeoutError("timeout ("+(0,n.fmtHMS)(r)+")");return u(e,r,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:n=!0}){const r=await l(e,t,n);return r===a.Timeout?(0,s.tot)(i):r}},42279:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const n=i(32639);t.tot=function(e){return(0,n.isFunction)(e)?e():e},t.tol=async function(e){return(0,n.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const n=i(40958),r=i(22573),s=i(54993);function a(e){return"URLSearchParams"===e?.constructor?.name}function o(e){return null==e?void 0:a(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,n.compact)(e.map(o)),i=t.shift();if(null!=i){for(const e of t)for(const[t,n]of e.entries())i.set(t,n);return i}}t.isURLSearchParams=a,t.toURLSearchParams=o,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,s.toS)(l(...t));return e+((0,r.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,s.toS)(l(...t));return(0,r.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const n=i(22573),r=i(30301),s=i(31586),a=i(46891),o=i(50989),l=i(51926),u=(0,r.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,r.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,r.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const n of e)(0,s.isNumber)(n)&&(i+=n/t.MB);return(0,s.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,n.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),n=Math.floor(i/3),r=Math.pow(10,3*n),a=d[n];return(0,s.sigFigs)(e/r,t)+" "+a}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),n=Math.floor(i/10),r=Math.pow(2,10*n),a=h[n];return(0,s.sigFigs)(e/r,t)+" "+a},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,o.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,n.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,a.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,a.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const n=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,n.maybeCall)(i,"unref")??i}},22403:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ua=void 0;const n=i(30301),r=i(54993);t.ua=(0,n.lazy)((()=>(0,r.toS)(globalThis?.navigator?.userAgent)))},2322:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,n=/\bSafari\b/,r=/\bFirefox\b/,s=/\biPad\b/,a=/\biPhone\b/;function o(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return o(e,i)}function u(e){return o(e,r)}t.isChrome=l,t.isSafari=function(e){return o(e,n)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return o(e,s)},t.isIphone=function(e){return o(e,a)}},58939:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.idEql=t.id2id=void 0;const n=i(55835),r=i(31586);function s(e){const t=e;return(0,r.isNumber)(e)?e:(0,r.isNumber)(t.id)?t.id:(0,r.isNumber)(t.assetId)?t.assetId:(0,r.isNumber)(t.tagId)?t.tagId:void 0}t.id2id=s,t.idEql=function(e,t){return(0,n.map2Or)(s(e),s(t),((e,t)=>e===t),(()=>!1))}},23541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const n=i(41801),r=i(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,r.isString)(e)?[e]:(0,n.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const n=i(40958),r=i(23541),s=i(59455),a=i(54993);function o(e){return null==e?void 0:(0,r.isError)(e)?e:new Error((0,a.toS)(e))}t.toErr=o,t.toErrs=function(...e){return(0,n.compact)((0,s.toA)(e).map(o))}},54993:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const n=i(98553);t.toS=function(e){return s(e,",")};const r={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==r?e.toString():(0,n.stringify)(e)}}t.toStr=s},23227:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),i(91863)},90858:e=>{e.exports=require("@iarna/toml")},53705:e=>{e.exports=require("@photostructure/tz-lookup")},58587:e=>{e.exports=require("batch-cluster")},36507:e=>{e.exports=require("croner")},66261:e=>{e.exports=require("events")},77988:e=>{e.exports=require("exiftool-vendored")},66150:e=>{e.exports=require("fast-xml-parser")},68817:e=>{e.exports=require("file-type")},44652:e=>{e.exports=require("fs-extra")},28787:e=>{e.exports=require("he")},51168:e=>{e.exports=require("luxon")},93973:e=>{e.exports=require("ml-kmeans")},83058:e=>{e.exports=require("picomatch")},57272:e=>{e.exports=require("plist")},85949:e=>{e.exports=require("process")},90595:e=>{e.exports=require("punycode")},38064:e=>{e.exports=require("semver")},9288:e=>{e.exports=require("sharp")},73872:e=>{e.exports=require("type-detect")},92460:e=>{e.exports=require("util")},31421:e=>{e.exports=require("node:child_process")},77598:e=>{e.exports=require("node:crypto")},40610:e=>{e.exports=require("node:dns")},78474:e=>{e.exports=require("node:events")},73024:e=>{e.exports=require("node:fs")},51455:e=>{e.exports=require("node:fs/promises")},77030:e=>{e.exports=require("node:net")},48161:e=>{e.exports=require("node:os")},76760:e=>{e.exports=require("node:path")},53916:e=>{e.exports=require("node:path/posix")},1708:e=>{e.exports=require("node:process")},57075:e=>{e.exports=require("node:stream")},46466:e=>{e.exports=require("node:stream/promises")},87997:e=>{e.exports=require("node:timers")},57975:e=>{e.exports=require("node:util")},38522:e=>{e.exports=require("node:zlib")},16928:e=>{e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=23227);module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{"use strict";var __webpack_modules__={37975:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const n=i(22573),r=i(38639),s=i(44198);function a(){return(0,r.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,n.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=a;let o=!a();function l(){return o}function u(e,t){return function(i){return l()?`[${e}m${i}[${t}m`:i}}t.setColorEnabled=function(e){o=e??!a()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const n=i(19851),r=i(7282),s=i(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,n.lazy)((()=>t.SimpleAppName+((0,r.isProd)()?"":`-${(0,r.nodeEnv)()}`))),t.AppNameVersion=(0,n.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const n=i(40958),r=i(36783),s=i(76790),a=i(22573),o=i(50357),l=i(98553),u=i(55835),c=i(31586),d=i(68708),h=i(34666),f=i(59455),m=i(84885);var p=i(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,i=n.primitiveValueOfOrElse){const r=new Set(t.map(i));return e.filter((e=>r.has(i(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],i=e.lastIndexOf(t);return[{t,count:i+1},...v(e.slice(i+1))]}function w(...e){const t=[],i=Math.max(...e.map((e=>e?.length??0)));for(let n=0;ne?.[n])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return M(e,(e=>e.valueOf()))}function P(e,t){return E(e,t,((e,t)=>(0,h.lt)(e,t)))}function M(e,t){return E(e,t,((e,t)=>(0,h.gt)(e,t)))}function _(e,t){return(0,n.isEmpty)(e)?void 0:e[P(e,t)]}function E(e,t,i){return x(e,t,i).index}function x(e,t,i){if((0,n.isEmpty)(e))return{index:-1,value:void 0};let r,s=-1;for(let n=0;ne.slice(i,i+t)))}async function D(e,t){return(0,n.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,o.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(a.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const i of(0,f.toA)(e))if(null!=i&&!0===await t(i))return i},t.findLastAsync=async function(e,t){for(let i=(e=(0,f.toA)(e)).length-1;i>=0;i--){const n=e[i];if(null!=n&&!0===await t(n))return n}},t.first=function(e,t){if(null!=e)for(const i of(0,f.toA)(e))if(null!=i){const e=t(i);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let i=-1;for(const n of e){i++;try{if(null!=n){const e=await t(n,i);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,n.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,i){for(let n=i;n<=e.length-1;n++)if(t(e[n]))return n},t.findLast=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return e[i]},t.findLastIndex=function(e,t){for(let i=e.length-1;i>=0;i--)if(t(e[i]))return i;return-1},t.concat=function(...e){const t=[];for(const i of e)if(Array.isArray(i))for(const e of i)null!=e&&t.push(e);else null!=i&&t.push(i);return t},t.moveToEnd=function(e,t){return(0,n.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const i=e[t];if(null==i)return e;e.push(i);for(let i=t;i(0,o.eql)(e,t)))},t.removeFirst=function(e,t){const i=e.findIndex(t);return i>=0?e.splice(i,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,r.copyArrayTo)((0,n.uniqBy)(e,t),e)},t.partition=function(e,t){const i=[],n=[];let r=0;for(const s of e)(t(s,r++)?i:n).push(s);return[i,n]},t.isUniq=function(e){return e.every(((t,i)=>e.indexOf(t)===i))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,n.compact)((0,n.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),i=[];return(0,c.times)(t,(t=>e.map((e=>i.push(e?.[t]))))),i},t.unFlatZip=function(e,t){const i=e.length/t;if(i!==Math.round(i))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const n=(0,c.times)(t,(()=>new Array(i)));for(let r=0;re.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=M,t.leastBy=_,t.least=function(e){return _(e,(e=>e))},t.greatestBy=function(e,t){return(0,n.isEmpty)(e)?void 0:e[M(e,t)]},t.leastByCtx=function(e,t){const i=x(e??[],t,h.lt);return null==e||null==i||i.index<0||null==i.value?void 0:{result:e[i.index],index:i.index,value:i.value}},t.reverse=function(e){const t=[];for(let i=e.length-1;i>=0;i--)t.push(e[i]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=T,t.collectBatched=function(e,t,i){const r=[];for(const s of T((0,n.compact)((0,f.toA)(e)),t))r.push(...(0,n.compact)(i(s)));return r},t.collectBatchedAsync=async function(e,t,i){const r=[];for(const s of T((0,n.compact)((0,f.toA)(e)),t))r.push(...(0,n.compact)(await i(s)));return r},t.contextFilter=function(e,t){let i;return e.filter(((e,n)=>(0,d.tap)(t(e,n,i),(t=>{t&&(i=e)}))))},t.clusterSome=function(e,t){const i=[];for(const n of e){const e=i.find((e=>e.some((e=>t(n,e)))));e?e.push(n):i.push([n])}return i},t.clusterEvery=function(e,t){const i=[];for(const n of e){const e=i.find((e=>e.every((e=>t(n,e)))));e?e.push(n):i.push([n])}return i},t.clusterAsync=async function(e,t){const i=[];e:for(const n of e){for(const e of i)if(null!=n&&await D(e,(e=>t(n,e)))){e.push(n);continue e}null!=n&&i.push([n])}return i},t.someAsync=async function(e,t){if(null!=e)for(let i=0;i=0&&!0===(0,u.map)(e[n],(e=>i(e,n))))return n}{const n=t+r;if(ne+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,i){return e.lengthi))),e}},36557:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const o=i(77988),l=a(i(1708)),u=i(19851),c=i(42659),d=i(55835),h=i(31586),f=i(85556),m=i(54993),p=i(50213),g=i(79089),y=i(45255),v=i(25764),w=i(38836),S=i(99331),b=i(95937),P=i(98314),M=i(38835),_=i(70025),E=i(8769),x=i(43334),T=i(95402),D=i(28874),k=i(63870);class C extends w.EndableWrapper{constructor(e,t,i=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,n,"m",r).call(this)),i,"worker"===e?(0,k.commandTimeoutMs)():y.ShortCommandTimeoutMs),n.add(this),this.t=t;const a=t;a.on("childStart",(async i=>{null!=i.pid?(this.logger.info("Started child process",{pid:i.pid}),(0,g.renice)(i.pid).catch((e=>this.onError("renice failed",e))),(0,T.addPid)({pid:i.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),a.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),a.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),a.on("fatalError",(e=>{this.onError("on(fatalError)"+M.FatalErrorFlag,e)})),a.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),a.on("noTaskData",((e,i,n)=>{const r=t.options.streamFlushMillis;r{this.logger.error("observeBatchCluster.endError()",e)})),a.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&T.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof o.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,_.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,E.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=C,n=new WeakSet,r=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(x.isWin?3:1)*c.minuteMs,maxTasksPerProcess:D.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:D.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:D.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:D.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:D.Settings.taskTimeoutMs.valueOrDefault}}},89788:function(e,t,i){var n,r,s,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=i(92460),d=i(31586);class h{constructor(e){if(n.add(this),this.maxLength=e,r.set(this,void 0),s.set(this,0),a.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,r,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,n,"m",o).call(this,e,(e=>u(this,r,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,n,"m",o).call(this,e,(e=>u(this,r,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(r=new WeakMap,s=new WeakMap,a=new WeakMap,n=new WeakSet,o=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,a,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,r,"f")[t]))}()}push(...e){var t,i;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,r,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,n,"m",o).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,r,"f")[e]}))}unshift(...e){var t,i;for(const c of e.reverse())u(this,s,"f"){u(this,r,"f")[e]=c,l(this,a,e,"f")}));return u(this,s,"f")}shift(){return u(this,n,"m",o).call(this,0,(e=>{var t,i;return l(this,a,(t=u(this,a,"f"),++t),"f"),l(this,s,(i=u(this,s,"f"),--i),"f"),u(this,r,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,n,"m",o).call(this,u(this,s,"f")-1-e,(e=>{const i=u(this,r,"f")[e];u(this,r,"f")[e]=u(this,r,"f")[t],u(this,r,"f")[t]=i}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const n=i(54993),r=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:i}of r)if(a(e,t))return e.subarray(t.length).toString(i);return e.toString()}function a(e,t){return t.every(((t,i)=>e[i]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,n.toS)(e)},t.bufferStartsWith=a},9092:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const n=i(94863);class r{constructor(e=[],t=n.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,i]of e)this.set(t,i)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const i=this.normalizer(e);return null!=e&&null!=i&&this.store.set(i,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=r},36638:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const n=i(94863);class r{constructor(e=[],t=n.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=r},40583:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const a=i(40958),o=i(23838),l=s(i(68708)),u=i(59455),c=i(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new o.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const i of(0,a.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(i,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const i=this.lookup(e);if(null!=i)return i;let n,r=-1;for(const[i,s]of this.m.entries()){const a=(0,c.diceCoeff)(i,e);if(a>t&&a>r){const e=this.getFirst(s);null!=e&&(n=e,r=a)}}return n}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),i=this.m.get(t);if(null!=i){for(const e of i)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const i of e){const e=this.lookup(i);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const n=i(76790),r=i(31586),s=i(68708),a=i(54993),o=i(82647),l=i(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const i=this.get(e)+t;return 0===i?this.m.delete(e):this.m.set(e,i),i}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new o.Average(0);for(const t of this.keys()){if(!(0,r.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,i]of this.m.entries())e[(0,a.toS)(t)]=i;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,n.sortBy)([...this.entries()],(([t,i])=>[-i,(0,r.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new o.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,i]of(0,n.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,i);return e}addAll(e){for(const[t,i]of e.entries())this.incr(t,i);return this}get toS(){return(0,n.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let i=0;for(const[n,r]of this.m.entries()){const s=e(n);t.fill(s,i,i+r),i+=r}return t}}t.CountingSet=u},79840:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const n=i(19851),r=i(72993),s=i(45969),a=i(43334);t.EditionType=(0,n.lazy)((()=>a.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,n.lazy)((()=>r.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const n=i(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),i=t-this.ts;this.ts=t,(0,n.map)(this.listener,(t=>t(e,i))),i>2&&this.l.log(i>500?"warn":i>100?"info":"debug",e,{elapsedMs:i})}},t.elapsed=function(e){const t=Date.now(),i=e();return{elapsedMs:Date.now()-t,result:i}},t.thenElapsed=async function(e){const t=Date.now(),i=await e;return{elapsedMs:Date.now()-t,result:i}}},23467:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const n=i(50357),r=i(55835),s=i(68708);var a=i(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return a.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,n.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,n.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,r.map2Or)(await e,await t,n.eql,(()=>!1))},t.eqlPicked=function(e,t,...i){return null!=e&&null!=t&&(0,n.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))},t.eqlOmit=function(e,t,...i){return null!=e&&null!=t&&(0,n.eql)((0,s.omit)(e,...i),(0,s.omit)(t,...i))},t.eqlAsyncPicked=async function(e,t,...i){return(0,r.map2Or)(await e,await t,((e,t)=>(0,n.eql)((0,s.pick)(e,...i),(0,s.pick)(t,...i))),(()=>!1))}},19935:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.examples=void 0;const n=i(31658),r=i(19851),s=i(95696);t.examples=(0,r.lazy)((()=>s.PosixFile.for((0,n.examplesNativePath_)())))},31658:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.examplesNativePath_=void 0;const n=i(19851),r=i(65843),s=i(29882);t.examplesNativePath_=(0,n.lazy)((()=>{const e=(0,r.ancestorWithChildren)(__dirname,["examples"]);if(null==e)throw new Error("Couldn't find the examples directory");return(0,s.joinNativePath)([e,"examples"])}))},62344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const n=i(57975),r=i(40958),s=i(55835),a=i(31586),o=i(54993),l=i(77377),u=i(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,a.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,a.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,r.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const i of this.expireListeners)i(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[n.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const i of this.expireListeners)i(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,r.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const i of this.expireListeners)i(e,t)}const i=this.priorCache[e];if(void 0!==i&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,i)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const i=this.currentCache[t]??this.priorCache[t];null!=i&&e(t,i)}}deleteIf(e){for(const t of this.keys()){const i=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=i&&e(t,i)&&this.delete(t)}}get(e){return e=(0,o.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,o.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,o.toS)(e),this.has(e))return this.get(e);const i=t();return this.set(e,i),i}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,a.isNumber)(e.__uid)&&(0,a.isNumber)(e.__start)}},80049:function(e,t,i){var n,r,s,a,o,l=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=i(31586),d=i(85556),h=i(54993),f=i(54557),m=i(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,n.set(this,0),r.set(this,0),s.set(this,0),a.set(this,0),o.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,n,l(this,n,"f")+e.cacheHitsSync,"f"),u(this,r,l(this,r,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,a,l(this,a,"f")+e.rejections,"f"),u(this,o,l(this,o,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,n,"f"),cacheHitsAsync:l(this,r,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,a,"f"),timeouts:l(this,o,"f")}}has(e){return this.cache.has(e)}get_(e){var t,i,a,o;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,r,(i=l(this,r,"f"),++i),"f"),c.promise):(u(this,n,(a=l(this,n,"f"),++a),"f"),c.value)}if(c instanceof Error)throw c;return u(this,n,(o=l(this,n,"f"),++o),"f"),c}get(e){var t,i;const r=this.cache.get(e);return null==r||r instanceof m.Deferred&&r.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,n,(i=l(this,n,"f"),++i),"f"),r instanceof m.Deferred?r.value:r}clear(){this.cache.clear(),u(this,n,0,"f"),u(this,r,0,"f"),u(this,s,0,"f"),u(this,a,0,"f"),u(this,o,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const i=this.get(e);if(null!=i){if(i instanceof Error)throw i;return i}return this.set(e,t())}getOrSetAsync(e,t){const i=(0,h.toS)(e);{const e=this.get_(i);if(null!=e)return e instanceof m.Deferred?e.promise:e}const n=new m.Deferred(this.opts.name).observe(t());return this.cache.set(i,n),(0,c.gt0)(this.opts.timeoutMs)&&n.setTimeout(this.opts.timeoutMs),n.promise.then((e=>{this.set(i,e)}),(e=>{var t,n;this.cache.set(i,e),u(this,a,(t=l(this,a,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,o,(n=l(this,o,"f"),++n),"f")})),n.promise}},n=new WeakMap,r=new WeakMap,s=new WeakMap,a=new WeakMap,o=new WeakMap},54127:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class n{constructor(e){this.maxSize=e,this[i]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(i=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=n},53507:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(31586),o=i(68708),l=i(50213),u=i(68852),c=i(81168),d=i(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,n.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,i=!0){return new m(e,t,i).entries};class m{constructor(e,t,i=!0){this.warnIfMissingHeaders=i,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const n=(0,a.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,r.range)(0,n).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,o.fromEntries)(e))).filter((e=>(0,o.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let i=e;i!==t;t>e?i++:i--)if(this.blankColumns.has(i))return i;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),i=[];let n,o=0;for(;null!=(n=t.exec(this.headerRow));){const l=this.headerRow.substring(o,n.index);(0,s.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:n.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(n.index,t.lastIndex),d=n.index+((0,c.indexOfNonSpace)(u)??0),h=n.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:n,left:d,right:h});else{const e=(0,r.last)(i);if(i.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,a.max_)(e?.rightIdx,n.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}o=t.lastIndex}const l=(0,r.last)(i);return null!=l&&((0,s.blank)(this.headerRow.slice(o))?l.rightIdx=(0,a.max_)(...this.rows.map((e=>e.length))):l.rightIdx=o),i}}t.Fixed=m},73168:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.distanceMeters=t.geohashDistanceMeters=t.geoHashToLocation=t.ungeohash_num=t.ungeohash=t.geohashNumeric=t.geohashNumericShort=t.geohash=t.locationToGeohash=t.validLatLon=t.validLon=t.validLat=void 0;const n=i(55835),r=i(20014),s=i(55222),a=i(97352),o=30;function l(e){return 5*Math.floor(e/5)}function u(e){return(0,a.within)(-90,90,e)&&0!==e}function c(e){return(0,a.within)(-180,180,e)&&0!==e}function d(e,t){return u(e)&&c(t)}function h(e,t,i=o){return(0,n.map)(m(e,t,l(i)),(e=>s.GeoRadix.encode(e)))}t.validLat=u,t.validLon=c,t.validLatLon=d,t.locationToGeohash=function(e,t=o){return h(e?.lat,e?.lon,t)},t.geohash=h,t.geohashNumericShort=function(e,t){return m(e,t,30)};const f=new r.BitZip([{min:-180,max:180},{min:-90,max:90}]);function m(e,t,i=o){return d(e,t)?f.zip([t,e],l(i)):void 0}function p(e,t=o){return f.unzip(e,l(t))?.reverse()}function g(e,t=o){const[i,n]=p(e,t);return{lat:i,lon:n}}t.geohashNumeric=m,t.ungeohash=function(e,t=o){return(0,n.map)(s.GeoRadix.decode(e),(e=>p(e,t)))},t.ungeohash_num=p,t.geoHashToLocation=g;function y(e,t){const i=e.lat*Math.PI/180,n=t.lat*Math.PI/180,r=(t.lat-e.lat)*Math.PI/180,s=(t.lon-e.lon)*Math.PI/180,a=Math.sin(r/2)*Math.sin(r/2)+Math.cos(i)*Math.cos(n)*Math.sin(s/2)*Math.sin(s/2);return 12742e3*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}t.geohashDistanceMeters=function(e,t){if(null!=e&&null!=t)return e===t?0:y(g(e),g(t))},t.distanceMeters=y},73913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const n=i(51455),r=i(98553);var s=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const i=(0,r.parseJSON)(e);return null==i?void 0:t(i)},t.readJson_=async function(e){return(0,r.parseJSON)((await(0,n.readFile)(e)).toString())}},19851:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const a=i(57975),o=i(40958),l=i(50357),u=i(31586),c=i(65812),d=i(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),n.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,n,"m",r).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,o.isEmpty)(this.watchers))return;const i=await e,n=await t;if(!(0,l.eql)(i,n))for(const e of this.watchers)e(n);null!=this.ttlMs&&this.ttlMs>0&&void 0!==n&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(42659),o=i(50213),l=i(81168),u=i(5916),c=i(56519),d=i(84777),h=i(44198),f=i(6012),m=i(43334),p=i(24399),g=i(63870);t.DefaultLocale="en";const y=(0,n.lazy)((()=>(0,o.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?_():E()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,n.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const i=w.exec(e.trim())?.groups;return null==i?void 0:(0,r.compact)([i.lang,i.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const M={timeoutMs:10*a.secondMs};async function _(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],M))}async function E(){return b(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],M)})))}t.localeMac=_,t.localePosix=E,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},57150:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.logStartup=void 0;const n=i(48161),r=i(1708),s=i(45599),a=i(68708),o=i(50213),l=i(88158),u=i(96175),c=i(23560),d=i(84968),h=i(37805),f=i(9727),m=i(3790),p=i(29325),g=i(43334),y=i(28874);t.logStartup=(0,s.defer)((()=>{(0,o.mkLogger)("LogStartup").info("setup(): starting "+(0,c.serviceName)(),{version:h.version,StartTs:d.StartTs,argv:r.argv,arch:(0,n.arch)(),platform:(0,n.platform)(),os:(0,u.osFullName)(),isPacked:(0,p.isPacked)(),isElectron:g.isElectron,versions:(0,a.pick)(r.versions,"electron","node"),settings:{logLevel:y.Settings.logLevel.valueOrDefault,logServer:y.Settings.logServer.valueOrDefault,httpPort:y.Settings.httpPort.valueOrDefault,libraryDir:y.Settings.libraryDir.valueOrDefault,copyAssetsToLibrary:y.Settings.copyAssetsToLibrary.value??"(unset)",UV_THREADPOOL_SIZE:r.env.UV_THREADPOOL_SIZE},...(0,l.mapEntries)((0,f.psenv)(),((e,t)=>[e,(0,m.isHiddenEnvKey)(e)?"(hidden)":t]))})}))},50213:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const n=i(19851),r=i(32105),s=i(14593);t.rootLoggers=(0,n.lazy)((()=>[r.ConsoleLogger.instance()]));const a=(0,n.lazy)((()=>[r.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,a)}},56639:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.inverse=t.getLike=t.pickKeys=t.filterInPlace=t.filter=t.toObj=t.toMapAsync=t.toMap=t.compactMap=t.flatMap=t.hasAll=void 0;const n=i(40958),r=i(55835),s=i(59455),a=i(48884);function o(e){const t=(0,n.compact)(e).filter((([e,t])=>null!=e&&null!=t));return new Map(t)}function l(e,t){return new Map([...e.entries()].filter((([e,i])=>t(e,i))))}t.hasAll=function(e,t){return t.every((t=>e.has(t)))},t.flatMap=function(e,t){return new Map((0,a.concat)(...e.map((e=>t(e)))))},t.compactMap=o,t.toMap=function(e,t){return o((0,n.compact)(e).map(t))},t.toMapAsync=async function(e,t){return null==e?new Map:o(await Promise.all((0,n.compact)((0,s.toA)(e)).map((e=>t(e)))))},t.toObj=function(e){const t={};for(const[i,n]of e)t[i]=n;return t},t.filter=l,t.filterInPlace=function(e,t){[...e.entries()].forEach((([i,n])=>t(i,n)||e.delete(i)))},t.pickKeys=function(e,t){return l(e,(e=>t.indexOf(e)>=0))},t.getLike=function(e,t){return(0,r.map)([...e.entries()].find((([e])=>t(e))),(([,e])=>e))},t.inverse=function(e){return new Map([...e.entries()].map((([e,t])=>[t,e])))}},9103:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const n=i(98553),r=i(54557);t.memoize=function(e,t){let i=0;const s=new r.FifoCache(t.maxSize,t.ttlMs),a=t=>{if(null!=t)return i++,s.getOrSet((0,n.stringify)(t),(()=>e(t)))};return a.clear=e=>null==e?s.clear():s.delete((0,n.stringify)(e)),a.size=()=>s.size,a.callCount=()=>i,a}},31578:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoryUsageRssMb=t.memoryUsageRssBytes=t.memoryUsageMb=t.memoryUsageBytes=void 0;const n=i(1708),r=i(31586),s=i(12168),a=i(70417);function o(){const e=(0,n.memoryUsage)();return(0,a.sum)([e.external,e.heapUsed,e.arrayBuffers])}function l(){return(0,n.memoryUsage)().rss}t.memoryUsageBytes=o,t.memoryUsageMb=function(){return(0,r.sigFigs)(o()/s.MB,2)},t.memoryUsageRssBytes=l,t.memoryUsageRssMb=function(){return(0,r.sigFigs)(l()/s.MB,2)}},7282:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const r=n(i(1708)),s=i(38639),a=i(54993),o=i(19851),l=i(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,o.lazy)((()=>r.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,a.toS)(r.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return r.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(r.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){r.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const n=i(40958),r=i(22573),s=i(96249),a=i(55835),o=i(31586),l=i(39926),u=i(54993),c=i(20014);var d=i(31586);function h(e,t){return(0,o.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(o.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,o.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,i){return(0,a.orElse)(h(e,t),i)},t.mapGte0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>=0?t(i):void 0},t.mapGt0f=function(e,t){const i=(0,o.toFloat)(e);return null!=i&&i>0?t(i):void 0},t.mapGt0=function(e,t){const i=(0,o.toInt)(e);return null!=i&&i>0?t(i):void 0},t.map2Gt0=function(e,t,i){const n=(0,o.toInt)(e),r=(0,o.toInt)(t);return null!=n&&n>0&&null!=r&&r>0?i(n,r):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,o.isNumber)(e))return e;if((0,r.blank)(e))return;const t=String(e);return(0,a.map)(f.exec(t),(e=>(0,o.toFloat)(t.substr(e.index))))}function p(e){return(0,o.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const i=[e,t].map((e=>e.toString(2))),n=Math.max(...i.map((e=>e.length)));return i.map((e=>(0,l.leftPad)(e,n,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let i=0;for(let n=0;ne/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,i){this.store[e*this.columns+t]=i}},t.hammingDistanceBigInt=function(e,t){return(0,a.map)(g(e,t),(([e,t])=>(0,n.count)([...e],((e,i)=>e!==t.charAt(i)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,a.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,n.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,i){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let n=0;const r=i*e.length;for(let i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const n=i(40958),r=i(42659),s=i(96249),a=i(55835),o=i(31586),l=i(68708),u=i(34666),c=i(41583),d=i(48884),h=i(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,r.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const i={};for(const[n,r]of(0,l.entries)(e)){const e=t(n,r);null!=e&&(i[n]=e)}return i}t.definedThunks=function(...e){return e.every((e=>(0,a.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const i of e){const e=i();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(a.defined)},t.firstDefinedField=function(e,...t){return(0,a.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(i=>t(i,e[i])?e[i]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,i){if(null!=e)return t(e);throw new Error(i)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,a.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,n.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[i,n]of m(t))null==e[i]&&(e[i]=n);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[i,n]of(0,l.entries)(t))null==e[i]&&(e[i]=n);return e},t.pickMap=function(e,t,i){const n={};for(const r of t)n[r]=i(r,e[r]);return n},t.mapEntries=p,t.mapNullEntries=function(e,t,i){const n={};let r=0;for(const s of(0,l.keys)(e))if(n[s]=t(s,e[s]),r++,(0,o.gt)(r,i))break;return n},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const i={};for(const n of(0,h.sortIgnoreCase)((0,l.keys)(t)))i[n]=e(t[n]);return i}return t},t.deepDelete=function e(t,...i){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...i))):p(t,((t,n)=>i.includes(t)?void 0:e(n,...i)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const i of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[i])return e[i]}},t.pairToObject=function(e,t){const i={};return i[e]=t,i},t.zipPojos=function(...e){const t={};for(const i of(0,n.uniq)((0,s.flatten)(e.map(l.keys))))t[i]=e.map((e=>e?.[i]));return t}},96175:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyOsNotSupported=t.CPUs=t.osNameWin=t.osNameMac=t.isAlpine=t.isFedora=t.hasApt=t.isUbuntu=t.isDebian=t.osDistributionLinux=t.osNameLinux=t.osReleaseTokens=t.osFullName=t.osArch=void 0;const n=i(31421),r=i(73024),s=i(48161),a=i(19851),o=i(22573),l=i(42659),u=i(55835),c=i(51926),d=i(54993),h=i(48884),f=i(50213),m=i(6012),p=i(45969),g=i(43334),y=i(76280),v=i(30933),w=(0,a.lazy)((()=>(0,f.mkLogger)("os")));function S(){return(0,s.platform)()+" "+(0,s.release)()}t.osArch=(0,a.lazy)((()=>`${function(){switch((0,s.platform)()){case"linux":return(0,t.osNameLinux)();case"darwin":return C();case"win32":return F();default:return S()}}()} on ${(0,s.arch)()}`)),t.osFullName=(0,a.lazy)((()=>(0,t.osArch)()+((0,p.isDocker)()?" (Docker)":"")));const b=["/etc/os-release","/usr/lib/os-release"];function P(){return"debian"===(0,t.osDistributionLinux)()}function M(){return"ubuntu"===(0,t.osDistributionLinux)()}function _(){return"fedora"===(0,t.osDistributionLinux)()}function E(){return"alpine"===(0,t.osDistributionLinux)()}t.osReleaseTokens=(0,a.lazy)((()=>{if(g.isLinux)for(const e of b)try{const t=(0,r.readFileSync)(e).toString();if((0,o.notBlank)(t))return(0,m.parseEnvTokens)({input:t,lowerCaseKeys:!0})}catch(t){w().warn("failed to read os-release file",{filename:e,error:t})}})),t.osNameLinux=(0,a.lazy)((()=>{const e=(0,t.osReleaseTokens)();return(0,o.notBlank)(e?.pretty_name)?e?.pretty_name:(0,u.map2Or)(e?.name,e?.version??e?.version_id,((e,t)=>e+" "+t),S)})),t.osDistributionLinux=(0,a.lazy)((()=>g.isLinux?(0,t.osReleaseTokens)()?.id?.toLowerCase():void 0)),t.isDebian=P,t.isUbuntu=M,t.hasApt=function(){return P()||M()},t.isFedora=_,t.isAlpine=E;const x={10:{6:"Snow Leopard",7:"Lion",8:"Mountain Lion",9:"Mavericks",10:"Yosemite",11:"El Capitan",12:"Sierra",13:"High Sierra",14:"Mojave",15:"Catalina"},11:"Big Sur",12:"Monterey",13:"Ventura",14:"Sonoma"},T={10:"10",6:{3:"8.1",2:"8",1:"7",0:"Vista"},5:{2:"Server 2003",1:"XP",0:"2000"},4:{9:"ME",1:"98",0:"95"}};function D(e,t){const[i,n]=function(e){return e.split(".").slice(0,2)}(e),r=t[i];return(0,c.isString)(r)?r:r?.[n]}const k=(0,a.lazy)((()=>(0,n.execSync)("sw_vers -productVersion").toString().trim()));function C(e=k()){try{return(0,o.mapNotBlankOr)(function(e=k()){return D(e,x)}(e),(t=>`macOS ${t} (${e})`),S)}catch(e){return w().warn("osNameMac(): unknown release",e),S()}}function F(e=(0,s.release)()){const t=e.startsWith("10.0.22")?"11":D(e,T);return null!=t?`Windows ${t} (${e})`:(w().warn("osNameWin(): unknown release: "+e),`Windows (${e})`)}t.osNameMac=C,t.osNameWin=F,t.CPUs=(0,a.lazy)((()=>(0,h.uniqCount)((0,v.cpuInfo)().map((e=>e.model))).map((e=>`${e.count} × ${e.t}`)).join(", ")),l.minuteMs),t.whyOsNotSupported=(0,a.lazy)((()=>{if(g.isWin)return/^Windows (?:10|11) /i.test(F())?void 0:"Windows 10 and 11 is supported";if(g.isMac){const e=k();return(0,y.semverSatisfies)(e,">=12")?void 0:"macOS 12 (Monterey) or later is supported"}if(g.isLinux){const e=(0,d.toS)((0,y.debianVersionToSemver)((0,t.osReleaseTokens)()?.version_id));if(P())return(0,y.semverSatisfies)(e,">=11")?void 0:"Debian 11 or later is supported";if(M())return(0,y.semverSatisfies)(e,"20 || 22")?void 0:"Ubuntu 20.x LTS or 22.x LTS is supported";if(_())return(0,y.semverSatisfies)(e,"37 || 38")?void 0:"Fedora 37 or 38 is supported";if(E())return(0,y.semverSatisfies)(e,">=3.15")?void 0:"Alpine >= 3.15 is supported"}return"recent versions of Windows 10/11, macOS, Debian, Ubuntu, and Fedora are supported"}))},12801:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const r=n(i(48161)),s=i(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:r.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:r.default.constants.priority.PRIORITY_NORMAL,BelowNormal:r.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:r.default.constants.priority.PRIORITY_LOW,Low:r.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{Object.defineProperty(t,"__esModule",{value:!0}),t.setProcessTitle=t.setShortProcessNames=void 0;const n=i(72993),r=i(50213),s=i(23560),a=i(43334);let o=!a.isElectron;t.setShortProcessNames=function(e){o=e},t.setProcessTitle=function(){try{const e=[o?n.SimpleShortAppName:n.SimpleAppName];(0,s.isMainService)()&&a.isElectron||e.push((0,s.serviceName)());const t=e.join(a.isElectron?" ":"-");i(85949).title=t}catch(e){(0,r.mkLogger)("ServiceNames").warn("Failed to set friendly process name",e)}}},409:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const n=i(41400),r=i(56409),s=i(31586),a=i(22911),o=i(73614),l=i(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:i,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...n){f=!0,m=Date.now()+(0,s.max_)(t,i);const r=d=new a.Deferred(c);(0,s.gt0)(i)&&r.setTimeout(i);try{r.resolve(await e(...n))}catch(e){r.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,o.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return r.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,n.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new r.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const n=i(68708),r=i(54993);function s(e){return e instanceof a?e.source:(0,r.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const i=[];if(!e.global)throw new Error("must provide global regex");let r;for(;null!=(r=e.exec(t));)r.index===e.lastIndex?e.lastIndex++:i.push((0,n.pick)(r,"index","groups"));return i},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,i){const n=[];for(const t of e)try{n.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{n.push(s(t))}const r=0===n.length?t.NothingRegExp:n.map((e=>"(?:"+e+")")).join("|");return new RegExp(r,i)};class a{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=a;class o extends a{static from(...e){const t=l(e);return new o("(?:"+t.source+")?",t.flags)}}function l(e,t){let i="",n=t?.includes("g")??!1,o=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof a||t instanceof RegExp?(i+=t.source,n||(n=t.global),o||(o=t.ignoreCase),l||(l=t.multiline)):i+=s((0,r.toS)(t));return new RegExp(i,t??(n?"g":"")+(o?"i":"")+(l?"m":""))}t.RegExpOptional=o,t.concatRegexp=l},79089:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const r=n(i(48161)),s=n(i(76760)),a=i(19851),o=i(40958),l=i(42659),u=i(41400),c=i(96249),d=i(31586),h=i(51926),f=i(54993),m=i(50213),p=i(12801),g=i(22277),y=i(84777),v=i(34102),w=i(43334),S=i(24399),b=i(28874),P=(0,a.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>E.prior()?.clear()))));const M=(0,a.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,o.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>M().includes(e.toLowerCase())))};let _=!0;const E=(0,a.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||E().has(e))return;E().add(e);const i=(0,p.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[i]),_)try{return r.default.setPriority(e,t),t}catch(i){const n=-13===i?.errno||"EACCES"===i?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:n,error:i}),n)return;_=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,i):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[i]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+i),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const r=n(i(1708)),s=i(19851),a=i(40958),o=i(5670),l=i(54993),u=i(7282),c=i(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===o.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===o.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===o.ServiceNames.sync}function p(){return(0,t.serviceName)()===o.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,a.compactBlanks)([t.serviceName.prior(),(0,l.toS)(r.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return o.ServiceNames.indexOf(e)??o.ServiceNames.length+1},t.MainServices=[o.ServiceNames.main,o.ServiceNames.desktop],t.DbServices=[o.ServiceNames.sync,o.ServiceNames.info,o.ServiceNames.web,o.ServiceNames.list,o.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[o.ServiceNames.sync,o.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===o.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===o.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,s.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const n=i(59455);function r(e){return e instanceof Set?e:new Set((0,n.toA)(e))}t.asSet=r,t.setEql=function(e,t){return(0,n.toA)(e.keys()).every((e=>t.has(e)))&&(0,n.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,i){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),i())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const i=r(t);return new Set([...e].filter((e=>i.has(e))))},t.diff=function(e,t){const i=r(t);return new Set([...e].filter((e=>!i.has(e))))}},19913:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setServiceName=void 0;const n=i(5670),r=i(57150),s=i(7282),a=i(23560),o=i(17181);t.setServiceName=function(e){(0,a.isMainService)(e)&&(e=n.ServiceNames.main);const t=a.serviceName.prior();t!==e&&((0,s.isTest)()||null==t||t===e||console.error("Don't set service name twice",{prior:t,new:e}),a.serviceName.set(e),(0,o.setupLogger)(),(0,r.logStartup)())}},28850:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},a=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim0=void 0;const o=i(62344),l=i(56038);t.shim0=function(e){return new u(e.name,e.impl)};class u extends o.ExtensibleFunction{constructor(e,t){super(),this.impl=t,n.set(this,void 0),r.set(this,void 0),s(this,n,e,"f")}_call(){return(0,l.time)(a(this,n,"f")+(null==a(this,r,"f")?"(local)":"(remote)"),null==a(this,r,"f")?this.impl():a(this,r,"f").call(this))}setShim(e){s(this,r,e,"f")}hasShim(){return null!=a(this,r,"f")}clearShim(){s(this,r,void 0,"f")}}n=new WeakMap,r=new WeakMap},12089:function(e,t,i){var n,r,s,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=i(98553),d=i(34666),h=i(54993),f=i(62344),m=i(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,i,a){super(),n.add(this),this.impl=t,this.cache=i,this.toKey=a,r.set(this,void 0),s.set(this,void 0),l(this,r,e,"f")}async _call(e){return null==this.cache?u(this,n,"m",o).call(this,e):this.cache().getOrSetAsync(u(this,n,"m",a).call(this,e),(()=>u(this,n,"m",o).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,n,"m",a).call(this,e))}}r=new WeakMap,s=new WeakMap,n=new WeakSet,a=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},o=function(e){return(0,m.time)(u(this,r,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const n=i(42659);t.ShortCommandTimeoutMs=7*n.secondMs},92322:function(e,t,i){var n,r=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=i(76790),a=i(17586);class o{constructor(e,t){this.valueOf=e,this.diff=t,n.set(this,[])}[(n=new WeakMap,Symbol.iterator)](){return r(this,n,"f")[Symbol.iterator]()}get length(){return r(this,n,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,i=r(this,n,"f").length-1;for(;t<=i;){const s=t+Math.floor((i-t)/2),a=this.valueOf(r(this,n,"f")[s]);if(e===a)return{found:!0,index:s};e>a?t=s+1:i=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&r(this,n,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:i}){if(t>=this.length)return[...r(this,n,"f")];const a=t=>t<0||t>r(this,n,"f").length-1?null:(i??this.diff)(r(this,n,"f")[t],e),o=this.findIndex(e);if(null==o)return;let l=o.index-1,u=a(l),c=o.index,d=a(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return r(this,n,"f").shift()}at(e){return(0,a.at)(r(this,n,"f"),e)}toA(){return[...r(this,n,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===r(this,n,"f").length-1){const e=[...r(this,n,"f")];return r(this,n,"f").length=0,e}return r(this,n,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return r(this,n,"f").splice(e,t)}retainLastN(e){return e{Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},54826:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.quietly=t.consoleError=t.consoleLog=void 0;const n=i(1708),r=i(82328),s=i(84542),a=i(95705),o=i(28874);t.consoleLog=function(e,...t){o.Settings.quiet.valueOrDefault||(0,r.stdoutEnded)()||console.log((0,s.crlf)(e),...t)},t.consoleError=function(e){o.Settings.quiet.valueOrDefault||(0,a.streamEnded)(n.stderr)||n.stderr.write(e)},t.quietly=async function(e){const t=o.Settings.quiet.envValue;try{return o.Settings.quiet.envValue=!0,await e()}finally{o.Settings.quiet.envValue=t}}},82328:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const n=i(1708),r=i(95705);t.stdoutEnded=function(){return(0,r.streamEnded)(n.stdout)}},71567:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const r=n(i(1708)),s=i(22573),a=i(98553),o=i(23560),l=i(82328),u=i(38835),c=i(70025),d=i(95705);function h(e,t){return f({obj:e,ready:t,stream:r.default.stdout})}function f({obj:e,ready:i,stream:n}){if(null==n||(0,d.streamEnded)(n))return;const r=(0,a.stringify)(e,void 0,(0,o.isInfoService)()||(0,o.isMainService)()?2:void 0);n.write(r+"\n"),(0,o.isWorkerService)()&&null!=i&&(r.includes(u.FailStr)||(0,c.isFatalError)(r)||(0,c.isHealthCheckError)(r)?n.write(u.FailStr+"\n"):n.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||r.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:r.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const i of e)i.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const n=i(40958),r=i(76790),s=i(22573),a=i(55835),o=i(31586),l=i(39926),u=i(34666),c=i(51926),d=i(59455),h=i(54993),f=i(48884),m=i(68852),p=i(38835);var g=i(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=i(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=i(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,i){if(0===i.length)throw new Error("rightPad() given empty pad");const n=String(e);return n+(0,l.padding)(i,t-n.length)},t.padReplace=function(e,t,i,n){return(0,c.strslice)(e,0,t)+(0,l.padding)(n,i)+(0,c.strslice)(e,t+i)},t.contains=function(e,t,i){return(0,h.toS)(e).indexOf((0,h.toS)(t),i)>-1},t.countChars=function e(t,i,n=0){if(null==i||0===i.length)return 0;const r=t.indexOf(i,n);return-1===r?0:1+e(t,i,r+i.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,i){const n=Math.min(Math.ceil(e.length/t),i??e.length)-1;return n<=0?[e]:[...(0,o.times)(n,(i=>e.slice(i*t,(i+1)*t))),e.slice(n*t)]},t.spliceCapture=function(e,t){const i=t.exec(e);if(null==i||null==i[1])return;const n=i[0].indexOf(i[1])+i.index;return{captured:i[1],uncaptured:e.substring(0,n)+e.substring(n+i[1].length),unmatched:e.substring(0,i.index)+e.substring(i.index+i[0].length),matchedIndex:n}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,i={}){if(null==t)return e;const n=(0,h.toS)(e),r=(0,h.toS)(t);return r.length>0&&(0,c.equalsIgnoreCase)(n.slice(-r.length),r,i)?n.slice(0,-r.length):n},t.gist=function(e,t=80,i=80){const n=(0,h.toS)(e),r=n.length-(t+i);return r<=0?n:n.slice(0,t).trim()+" …(+"+r+" chars)…"+n.slice(-i).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const i=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===i?e.localeCompare(t):i}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,n.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,a.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const i=S(e.cmp[0],t.cmp[0]);return 0!==i?i:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,n.isEmpty)(e)||(0,s.blank)(t))return;for(const i of e)if((0,c.equalsIgnoreCase)(i,t))return{index:0,match:i};for(const i of e){const e=t.indexOf(i);if(e>=0)return{index:e,match:i}}const i=t.normalize();for(const t of e){{const e=i.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=i.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=i.toLowerCase(),n=e.toLowerCase(),r=t.indexOf(n);if(r>=0)return{index:r,match:n}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const M=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function _(e){return M.reduce(((e,[t,i])=>e.replace(t,i)),e).normalize()}t.dumbquote=_;const E=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,h.toS)(e).trim(),null!=E.exec(_(e))&&(e=e.slice(1,-1).trim())),e};const x=/^['‘’].*['‘’]$/,T=/^["“”„«»〃].*["“”„«»〃]$/;function D(e,t){const i=k(e,t);return(0,f.flatZip)(i.nonSeparators,i.separators).filter((e=>null!=e&&e.length>0))}function k(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const i=[],n=[];let r,s=0;for(;null!=(r=t.exec(e));)r.index===t.lastIndex?t.lastIndex++:(t.lastIndex=r[0].length+r.index,i.push(e.substring(s,r.index)),n.push(e.substring(r.index,t.lastIndex)),s=t.lastIndex);return s(0,o.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),x.test(e)||T.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const i=(0,n.compactBlanks)(e),r=Math.max(...i.map((e=>e.length)));for(let e=0;e(0,a.map)(i[e],(e=>t+=e))));return t},t.splitKeep=D,t.splitUp=k,t.sortNaturalBy=C,t.sortNatural=function(e){return(0,r.sortBy)(e,(e=>C(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,n.compactBlanks)(e)),i=t.filter(((e,i)=>!P(t[i+1],e)));return(0,r.sortBy)(i,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const i=Math.min(e.length,t.length);for(let n=0;n4===e?.length?(0,o.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const F=/#.*$/gm;t.stripComments=function(e){return e.replace(F,"")},t.uniqPath=function(e,t=":"){const i=new Set;for(const n of(0,d.toA)(e))if(null!=n&&!(0,s.blank)(n))for(const e of n.split(t))(0,s.blank)(e)||i.add(e);return[...i].join(t)},t.dedupeNeedle=function(e,t,i){if((0,s.blank)(t))return e;const n=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),r=e.findIndex((e=>n.test(e))),a=new RegExp("("+(0,m.escapeRegExp)(i)+"[,:\\s]*){2,}","gim");if(r<0)return e;for(let t=r+1;te.trim()))))}},83556:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const n=i(54993);function r(e){return(0,n.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,n.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>"_"+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,n.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,i)=>" "+t.toLowerCase()+i)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=r,t.asObjectKey=function(e){return r(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const r=n(i(77598)),s=i(73913),a=i(55222);function o(e,t=s.HashBits){return r.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,i=a.Radix58,n=224){return i.encodeBuffer(o(e,n)).substring(0,t)}t.stringShaToBuffer=o,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,i=a.GeoRadix,n=224){return l(e,t,i,n)}},94863:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const n=i(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,n.toS)(e).toLowerCase().normalize()}},96859:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const n=i(40958),r=i(76790),s=i(22573),a=i(31586),o=i(39926),l=i(51926),u=i(54993),c=i(55222),d=i(97352),h=i(88158),f=i(77377),m=i(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const i=new d.Array2D(e.length);let n=0,r="";for(let s=0;s=n&&(n=i.get(s,a),r=(0,l.substr)(e,s-n+1,n)));return r}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const i=y(e,t);if(null!=i)return i;const n=e.normalize(),r=t.normalize();return e!==n||t!==r?y(n,r):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,i,n)=>i===t.charAt(n)?e:e+1),0)}function v(e,t){const i=e.toUpperCase().normalize(),n=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>i===n?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(i),t=w(n);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,i)=>e+t[i+1]))}function S(e,t){const i=(0,f.intersection)(e,t),r=[];return i.forEach((i=>{const s=Math.min((0,n.count)(e,(e=>e===i)),(0,n.count)(t,(e=>e===i)));(0,a.times)(s,(()=>r.push(i)))})),r}function b(e,t,i){const r=(0,n.commonPrefixLength)(e,t);return i((0,l.strslice)(e,r))-i((0,l.strslice)(t,r))}function P(e){const t=(0,n.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,r.sortBy)(t,(e=>-e.length))[0]}function M(e,t){const[i,n]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(i,n,(e=>(0,a.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=M;const _=/[^\da-z]+/gi;function E(e,t){const[i,n]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(_,"").toLowerCase()));return b(i,n,(e=>c.RadixAlphaNum.decode(e)))}function x(e,t){let i;for(let n=Math.max(e.length,t.length);n>=0;n--){const r=(0,a.mapNumericOr)(e.charCodeAt(n),(e=>e),256),s=(0,a.mapNumericOr)(t.charCodeAt(n),(e=>e),256),o=(0,a.clamp)(-256,256,r-s);i=null==i?o:(i+o)/2}return i}t.radixDiff=E,t.str=function(e,t){return{pref:(0,n.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:M(e,t),radixDiff:E(e,t)}},t.lcdiff=function(e){return(0,n.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=x,t.paddedPositionalDiff=function(e,t,i=8){return x((0,o.leftPad)(e,i," "),(0,o.leftPad)(t,i," "))}},84885:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const n=i(98553),r=i(88158);t.stringifySorted=function(e){return(0,n.stringify)((0,r.sortedKeys)(e))}},75387:function(e,t,i){var n,r,s,a,o,l,u,c,d=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLMap=void 0;const f=i(76790),m=i(42659),p=i(73614);class g{constructor(e){n.add(this),this[c]="TTLMap",r.set(this,[]),s.set(this,new Map),a.set(this,void 0),o.set(this,void 0),this.ttlMs=e}get ttlMs(){return d(this,a,"f")}set ttlMs(e){h(this,a,e,"f"),null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),h(this,o,(0,p.setUnrefInterval)((()=>d(this,n,"m",u).call(this)),e),"f"),d(this,n,"m",u).call(this)}destroy(){null!=d(this,o,"f")&&clearInterval(d(this,o,"f")),this.ttlMs=-m.dayMs,d(this,n,"m",u).call(this)}clear(){return d(this,s,"f").clear(),this}delete(e){return d(this,s,"f").delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){for(const[t,i]of d(this,s,"f").entries())d(this,n,"m",l).call(this,t,i)&&e(i.v,t,this)}get(e){const t=d(this,s,"f").get(e);return d(this,n,"m",l).call(this,e,t)?(t.ts=Date.now(),t.v):void 0}getOrMaybeSet(e,t){const i=d(this,s,"f").get(e);if(d(this,n,"m",l).call(this,e,i))return i.v;const r=t();return null!=r&&this.set(e,r),r}lastSetOrGetTs(e){return d(this,s,"f").get(e)?.ts}set(e,t){return d(this,s,"f").set(e,{ts:Date.now(),v:t}),this}has(e){return d(this,n,"m",l).call(this,e,d(this,s,"f").get(e))}get size(){return d(this,n,"m",u).call(this),d(this,s,"f").size}keys(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,n,"m",l).call(e,t,i)&&(yield t)}()}values(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,n,"m",l).call(e,t,i)&&(yield i.v)}()}valuesByRecency(){return d(this,n,"m",u).call(this),(0,f.sortBy)(d(this,s,"f").values(),(e=>-e.ts))}entries(){const e=this;return function*(){for(const[t,i]of d(e,s,"f").entries())d(e,n,"m",l).call(e,t,i)&&(yield[t,i.v])}()}[(r=new WeakMap,s=new WeakMap,a=new WeakMap,o=new WeakMap,n=new WeakSet,c=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}on(e,t){d(this,r,"f").push(t)}}t.TTLMap=g,l=function(e,t){if(null==t)return!1;if(t.ts+this.ttlMs>Date.now())return!0;d(this,s,"f").delete(e);for(const i of d(this,r,"f"))i(e,t.v);return!1},u=function(){for(const[e,t]of d(this,s,"f").entries())d(this,n,"m",l).call(this,e,t)}},22277:function(e,t,i){var n,r,s,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=i(73614);class u{constructor(e,t=!1){n.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[a]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return o(this,n,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>o(this,n,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const i=this.delegate.get(e);return null==i||o(this,n,"m",r).call(this,e,i)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,i]of this.delegate)o(this,n,"m",r).call(this,t,i)||e(t,t,this)}has(e){return null!=e&&!o(this,n,"m",r).call(this,e)}values(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,n,"m",r).call(e,t,i)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,i]of e.delegate)o(e,n,"m",r).call(e,t,i)||(yield[t,t])}()}toA(){return o(this,n,"m",s).call(this),[...this.delegate.keys()]}[(n=new WeakSet,a=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,r=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const i=t<=Date.now()-this.ttlMs;if(i){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return i},s=function(){for(const[e,t]of this.delegate)o(this,n,"m",r).call(this,e,t)}},84699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TestLibraryDirPrefix=void 0,t.TestLibraryDirPrefix="test-ps-lib-"},94174:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const r=n(i(48161)),s=n(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(38639),c=i(31586),d=i(50213),h=i(45255),f=i(84777),m=i(96706),p=i(43334),g=i(24399),y=(0,a.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,a.lazy)((()=>(0,o.uniq)([s.default.geteuid?.(),s.default.getuid?.(),r.default.userInfo().uid]))),t.userid=(0,a.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,a.lazy)((()=>(0,o.uniq)([s.default.getegid?.(),s.default.getgid?.(),r.default.userInfo().gid]))),t.groupid=(0,a.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,a.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,a.lazy)((()=>(0,l.toNotBlank)(r.default.userInfo()?.username))),t.userNameFromWhoami=(0,a.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,a.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,a.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,a.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.1-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=1,t.versionPrerelease=["prealpha"],t.release="2024.3.1-prealpha+20240308150212",t.gitSha="d92384e8659ff46fbae8e6f81fa5867114a4a843",t.gitDate=new Date(1709938932e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const n=i(42659),r=i(55835),s=i(31586),a=i(97790),o=i(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const i=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,r.allDefined)(i))return;const[a,o,u,c,d,h,f]=i,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(a,o-1,u,c,d,h,f/1e3)-m*n.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,a.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,o.within)(0,Date.now()+n.dayMs,e))).map((e=>new Date(e))).get()}},13991:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkSortableAssetFile_=t.mkAssetFile_=t.assetFileMetadata_=t.assetFileImageHashFields_=t.imageHashToAssetFileImageHashFields=t.assetFileStatFields_=t.assetFileUriFields_=void 0;const n=i(19851),r=i(55835),s=i(31586),a=i(59455),o=i(73168),l=i(50213),u=i(12089),c=i(76490),d=i(95696),h=i(48368),f=i(70417),m=i(28874),p=i(43207),g=i(47783),y=(0,n.lazy)((()=>(0,l.mkLogger)("asset-file.AssetFileFactory")));async function v(e){try{return{nativePath:e.nativePath,uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath}}catch(t){return y().throw("Failed to build URI for "+e,{error:t})}}async function w(e){const t=await e.stat_(),i=await e.sidecareStats();return{mtime:Math.floor((0,f.max)([t.mtimeMs,...(0,a.toA)(i).map((e=>e.mtimeMs))])),fileSize:t.size}}function S(e){return{...e,...c.DominantColor.toModeData(e.dominantColors)}}async function b(e){if(!m.Settings.useImageHashes.valueOrDefault)return;const t=await(0,h.imageHash_)(e.nativePath);return null==t?y().throw("Failed to extract image hash for "+e):S(t)}async function P(e){const[i,n,r,s]=await Promise.all([v(e),w(e),(0,t.assetFileMetadata_)(e),e.sha_()]);return{...i,...n,...r,sha:s}}t.assetFileUriFields_=v,t.assetFileStatFields_=w,t.imageHashToAssetFileImageHashFields=S,t.assetFileImageHashFields_=b,t.assetFileMetadata_=(0,u.shim1)({name:"asset-file.assetFileMetadata",impl:async function(e){try{const t=d.PosixFile.for(e),i=await(0,g.readTags)(t);if(null==i)throw new Error("Failed to read tags");if(null==i.capturedAt)throw new Error("Failed to read capturedAt");const n=i.capturedAt.toAssetFileFields();return null==n?y().throw("Failed to render assetFileFields from capturedAt",{capturedAt:i.capturedAt}):{...n,...i.exposureSettings,...i.dimensions,mimetype:i.mimetype,rotation:i.rotation,make:i.Make,model:i.Model,rating:i.rating,cameraId:i.cameraId,imageId:i.imageId,lensId:i.lensId,geohash:(0,o.geohashNumericShort)(i.GPSLatitude,i.GPSLongitude),durationMs:(0,p.extractDurationMs)(i),fps:(0,r.map)((0,s.toFloat)(i.VideoFrameRate),Math.floor)}}catch(t){return y().throw("_assetFileMetadata_() failed",{nativePath:e,error:t})}}}),t.mkAssetFile_=async function(e){const[t,i]=await Promise.all([P(e),b(e)]);return{...t,...i}},t.mkSortableAssetFile_=P},92434:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bestExistingAssetFile=t.assetFileSortCriteria=t.assetFileSortFields=t.assetFileSortCriteriaPojo=t.sortAssetFiles=t.mtime2sort=t.sortScale=t.dim2sort=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(22573),o=i(42659),l=i(23838),u=i(31586),c=i(68708),d=i(34666),h=i(50989),f=i(89937),m=i(50213),p=i(4001),g=i(29882),y=i(28874),v=i(14036),w=i(45200),S=i(34238),b=(0,n.lazy)((()=>(0,m.mkLogger)("img.AssetFileSorter"))),P=(0,h.strEnum)("file",f.PS_NETWORK_FILESYSTEM_SCHEME,f.PS_LOCAL_FILE_SCHEME,f.PS_LIBRARY_SCHEME);function M(e){return(0,u.map2Numeric)(e?.width,e?.height,((e,t)=>_(e*t)))}function _(e){if((0,u.gt0)(e))return Math.round(Math.pow(e,y.Settings.variantSortCriteriaPower.valueOrDefault))}function E(e){return Math.round(e/(5*o.minuteMs))}t.dim2sort=M,t.sortScale=_,t.mtime2sort=E;const x=["make","model","rating","cameraId","imageId","lensId","geohash"];function T(e){for(const t of(0,l.groupBy)(e,(e=>e.sha)).values())if(t.length>1){const e=Math.max(...(0,r.compact)(t.map((e=>e.mtime))));for(const i of t)i.mtime=e}return(0,s.sortBy)(e,C).reverse()}function D(e){const t=S.URI.parse(e.uri);if((0,a.blank)(t?.scheme)||(0,a.blank)(t?.path))return void b().warn("assetFileSortCriteriaPojo(): skipping (invalid URI)",{uri_scheme:t?.scheme,uri_path:t?.path,af:e,parsedURI:t});const i=M(e);if(null==i)return void b().warn("assetFileSortCriteriaPojo(): skipping (invalid resolution)",{resolution:i,af:e,parsedURI:t});const n=P.indexOf(t.scheme);if(null==n)return void b().warn("assetFileSortCriteriaPojo(): skipping (invalid URI scheme)",{uri_scheme:t.scheme,af:e,parsedURI:t});const r=e.mtime??0,s=(0,g.parsePosixPath)(t.path),l=[];for(const t of x)(0,a.blank)(e[t])||l.push(t);const u={resolution:i,schemeIdx:n,capturedAtPrecision:-(e.capturedAtPrecisionMs??o.weekMs),metadataCoverage:l.length,metadataFields:l.join(","),isBrowserSupported:(0,v.isSupportedByCurrentBrowserExt)(s.ext),mtime:E(r),isEditOrUpdate:/edit|update/i.test(s.base),isCover:/cover/i.test(s.base),count:Math.abs((0,p.copySuffixCountFromName)(s.name)??0),basename:d.CmpReverseFlag+s.base,parentBasename:d.CmpReverseFlag+(0,g.parentBasename)(e.nativePath??t.path),uri:d.CmpReverseFlag+e.uri};return b().tap({msg:"assetFileSortCriteriaPojo()",result:(0,c.toReqValued)(u)})}function k(){return(0,r.uniq)([...y.Settings.variantSortCriteria.values,"uri"])}function C(e){const t=D(e);if(null==t)return;const i=[];for(const e of k())i.push(t[e]);return i}t.sortAssetFiles=T,t.assetFileSortCriteriaPojo=D,t.assetFileSortFields=k,t.assetFileSortCriteria=C,t.bestExistingAssetFile=async function(e){for(const t of T(e))if(await(0,w.uriExists)(t.uri,t.nativePath))return b().tap({msg:"bestExistingAssetFile()",result:t,meta:{files:e.map((e=>e.uri))}});return b().tap({msg:"bestExistingAssetFile(): no existing uris",result:void 0,meta:{files:e.map((e=>e.uri))}})}},54296:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getAssetFileNativePath=void 0;const n=i(45200);t.getAssetFileNativePath=async function(e){return e.nativePath??(e.nativePath=await(0,n.uri2nativePath)(e.uri,e.mountpoint))}},73568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class i extends Error{}t.AbortError=i},76740:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const o=i(45599),l=i(56409),u=i(73568);t.Abortable=class{constructor(){this._aborted=!1,n.set(this,void 0),r.set(this,(0,o.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,r,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,r,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,r,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),a(this,n,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,n,"f")&&clearTimeout(s(this,n,"f")),a(this,n,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},n=new WeakMap,r=new WeakMap},69591:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;const r=n(i(87997)),s=i(31586);t.debounce=function(e,t){let i,n=[];const a=(0,s.gt0)(t)?(...s)=>{n=s,null!=i&&r.default.clearTimeout(i),i=r.default.setTimeout((()=>{e(...n)}),t)}:e;return a.reset=()=>{null!=i&&r.default.clearTimeout(i),i=void 0},a.force=()=>{a.reset(),e()},a.setTimeoutMs=e=>{a.reset(),t=e},a.timeoutMs=()=>t,a}},22911:function(e,t,i){var n,r,s,a,o,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(i(87997)),w=y(i(57975)),S=i(45599),b=i(26905),P=i(55835),M=i(31586),_=i(68708),E=i(20214),x=i(57153),T=i(85556),D=i(50213),k=i(70025),C=i(95937),F="TIMEOUT",O=(0,S.defer)((()=>(0,D.mkLogger)("async.Deferred")));class I{static async*toAsyncIterable(e,t){const i=[...e].reverse(),n=(0,M.gt0)(t)?new r(F).setTimeout(t):void 0;for(null!=n&&i.push(n);;){for(let n=i.length-1;n>=0;n--){const r=i[n];if(r.isSettled){if(r.name===F)return void O().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});i.splice(n,1),yield r.value}}if(i.every((e=>e.name===F)))break;try{await Promise.race(i)}catch{}}n?.clearTimeout()}static resolve(e,t){return new r(".resolved()",t).resolve(e)}constructor(e,t){var i,m,y;n.add(this),this.name=e,this.startedAt=Date.now(),a.set(this,void 0),o.set(this,x.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(i=r,r,(y=p(i,r,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,D.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof r&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,o,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,_.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,a,"f")}get elapsedMs(){return(p(this,a,"f")??Date.now())-this.startedAt}get[(a=new WeakMap,o=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,n=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,E.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,E.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,M.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new T.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,C.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,o,"f")===x.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,o,"f")!==x.PromiseStates.pending}get isResolved(){return p(this,o,"f")===x.PromiseStates.resolved}get isRejected(){return p(this,o,"f")===x.PromiseStates.rejected}get settledMs(){return null==p(this,a,"f")?void 0:p(this,a,"f")-this.startedAt}resolve(e){return p(this,n,"m",m).call(this,(()=>{g(this,o,x.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,k.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return p(this,n,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,o,x.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=I,r=I,m=function(e){if(p(this,o,"f")===x.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,a,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},s={value:0}},27395:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const n=i(19851),r=i(40958),s=i(42659),a=i(23838),o=i(13538),l=i(50213),u=i(7282),c=i(97352),d=i(77740),h=i(25764),f=i(99331),m=i(73614),p=(0,n.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new a.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const i=await e;if(null==i||!0===i?.ended)return;const n=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,i.endTimeoutMs,y);p().trace(i.name+" ending...",{timeoutMs:n});try{await(0,o.thenOrTimeoutError)(i.end(),n,(0,u.isTest)())}catch(e){try{p().warn(i.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,n.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const i=g.get(t)??[];(0,r.isNotEmpty)(i)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(i.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,r.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const i=g.get(t)??[];e[t]=i.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,i){var n,r,s,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=i(87997),h=i(55835),f=i(31586),m=i(68708),p=i(25764),g=i(38836),y=i(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,n,"m",a).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),n.add(this),this.opts=e,r.set(this,void 0),s.set(this,void 0),o.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,r,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,i=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!i&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,n,"m",a).call(this);const h=()=>{u(this,n,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,r,(0,d.setInterval)(u(this,o,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,r,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,n,"a",l)&&(u(this,o,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):h(),!0}}t.EndableInterval=v,r=new WeakMap,s=new WeakMap,o=new WeakMap,n=new WeakSet,a=function(){(0,h.map)(u(this,r,"f"),d.clearInterval),c(this,r,void 0,"f"),(0,h.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const n=i(50989);t.EndableRanks=(0,n.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const o=i(19851),l=i(45599),u=i(56409),c=i(50213),d=i(27395),h=i(25764),f=i(99331),m=i(56519);t.EndableWrapper=class{constructor(e,t,i=h.EndableRanks.first,a){this.endTimeoutMs=a,n.set(this,void 0),this.onEnds=[],r.set(this,(0,o.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,r,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(i,this)}setName(e){a(this,n,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,n,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,r,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},n=new WeakMap,r=new WeakMap},99331:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const n=i(7282);let r=!1;t.ending=function(){return r},t.setEnding=function(e){r=(0,n.isTest)()?e:e||r}},45608:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const r=n(i(1708)),s=i(22573),a=i(45599),o=i(37975),l=i(50213),u=i(71567),c=i(57159),d=i(57902),h=i(28874),f=i(27395),m=i(99331),p=i(56038),g=(0,a.defer)((()=>(0,l.mkLogger)((0,o.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,a.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const i=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==i.errno||!0===i.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const n=(0,s.toNotBlank)(e?.reason)??i.toString();for(const e of t.onFatalHandlers)await e(n)}(0,m.ending)()||(await(0,f.endEndables)(),r.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,a.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])r.default[e].on(t,(i=>{v({reason:`${e}:${t}`,status:0,error:i})}))}))},60172:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.firstDefinedLater=t.laterPromise=void 0,t.laterPromise=function(e){let t,i;return{promise:new Promise(((e,n)=>{t=e,i=n})),later:async()=>{try{const i=await e();return t(i),i}catch(e){throw i(e),e}}}},t.firstDefinedLater=async function(...e){if(null!=e)for(const t of e){if(null==t)continue;const e=await t();if(null!=e)return e}}},5916:function(e,t,i){var n,r,s,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=i(50357),f=i(31586),m=i(41583),p=i(62344),g=i(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:i,timeoutMs:n}){return new y(e,t,i,n)};class y extends p.ExtensibleFunction{constructor(e,t,i,l){super(),n.add(this),this.later=e,this.desc=t,this.ttlMs=i,this.timeoutMs=l,r.set(this,void 0),s.set(this,0),a.set(this,void 0),o.set(this,[])}_call(){return this.isStale()?c(this,n,"m",u).call(this,this.later()):c(this,a,"f")}unset(){d(this,s,0,"f"),d(this,r,void 0,"f"),d(this,a,void 0,"f")}set(e){return c(this,n,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,n,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,o,"f").push(e)}prior(){return this.isStale()?void 0:c(this,a,"f")}lastValue(){return c(this,a,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,r,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,r,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,r,"f")?void 0:Date.now()-c(this,r,"f")}elapsedMs(){return c(this,a,"f")?.settledMs??c(this,a,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}r=new WeakMap,s=new WeakMap,a=new WeakMap,o=new WeakMap,n=new WeakSet,l=async function(e,t){var i;try{const i=await t;if(!(0,h.eql)(e?.value??await(e?.promise),i))for(const e of c(this,o,"f"))await e.onChange(i)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,o,"f"))e.onError(t)}finally{d(this,s,(i=c(this,s,"f"),++i),"f")}},u=function(e){d(this,r,Date.now(),"f");const t=c(this,a,"f");return d(this,a,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,a,"f").setTimeout(this.timeoutMs),c(this,n,"m",l).call(this,t,c(this,a,"f")),c(this,a,"f")}},1728:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoizeAsync=void 0;const n=i(98553),r=i(80049);t.memoizeAsync=function(e,t){let i=0;const s=new r.FifoCacheAsync(t),a=t=>(i++,s.getOrSetAsync((0,n.stringify)(t),(async()=>e(t))));return a.clear=e=>{if(null==e)return s.clear();{const t=(0,n.stringify)(e);return s.deleteIf((e=>t===e))}},a.size=()=>s.size,a.callCount=()=>i,a}},22781:function(e,t,i){var n,r,s,a=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.oneAtATime=void 0;const l=i(62344),u=i(37461);t.oneAtATime=function({fn:e,runLaterIfBusy:t=!1,undefinedIfBusy:i}){return new c(e,t,i)};class c extends l.ExtensibleFunction{constructor(e,t=!1,i=!1){super(),this.fn=e,this.runLaterIfBusy=t,this.undefinedIfBusy=i,n.set(this,void 0),r.set(this,!1),s.set(this,!1)}_call(){return a(this,r,"f")?(o(this,s,!0,"f"),!0===this.undefinedIfBusy?void 0:a(this,n,"f")):(o(this,r,!0,"f"),o(this,n,(0,u.postrun)({fn:this.fn,postrun:()=>{o(this,r,!1,"f"),!0===this.runLaterIfBusy&&a(this,s,"f")&&(o(this,s,!1,"f"),setImmediate((()=>this._call())))}}),"f"))}isRunning(){return a(this,r,"f")}prior(){return a(this,n,"f")}async force(){return await a(this,n,"f"),this._call()}}n=new WeakMap,r=new WeakMap,s=new WeakMap},37461:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.postrun=void 0,t.postrun=async function(e){try{return await e.fn()}finally{await e.postrun()}}},56519:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const n=i(40958),r=i(76790),s=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(20214),c=i(13538),d=i(42279),h=i(32639),f=i(59455),m=i(41583),p=i(48884),g=i(50213),y=i(88158),v=i(15674),w=i(42638);var S=i(20214);async function b(e){if(null==e)return[];const t=(0,n.compact)(await e);return(0,n.isEmpty)(t)?[]:(0,n.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function M({name:e,arr:t,f:i,timeoutMs:r}){const s=[];for(const a of(0,n.compact)(await t))try{const e=await((0,l.gt0)(r)?(0,c.thenOrTimeoutError)(i(a),r):i(a));null!=e&&s.push([e,a])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:a,error:t})}return s}async function _({arr:e,f:t,name:i,maxConcurrent:r,timeoutMs:s,promises:a}){if(null==e)return[];const o=(0,n.compact)(await e);if((0,n.isEmpty)(o))return[];if((r=Math.round(r??(0,v.maxCpus)()))<=1)return M({arr:e,f:t,name:i,timeoutMs:s});const u=a??(o.length<=r?w.PermissivePromises:new w.Promises(i,(()=>r))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,h=await u.enqueueAll(i,o.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(i).warn("failed to apply",{ea:e,error:t})}})));return(0,n.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,i){const n=[];for(const r of(0,p.batches)((0,f.toA)(await e),t)){const e=await b(r);n.push(...await b(i(e)))}return n},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,o.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const i of(0,n.compact)(e)){const e=await i();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;if(null!=e)if(Array.isArray(e))for(const i of e){const e=await i;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const i of(0,f.toA)(await e)){const e=await i;null!=e&&t.push(e)}return(0,n.uniq)(t)},t.asyncFind=async function(e,t){for(const i of e)if(await t(i))return i},t.thenCollectSerial=M,t.mapAsyncSerial=async function(e){return(await M(e)).map((e=>e[0]))},t.thenCollectParallel=_,t.mapAsync=async function({arr:e,f:t,name:i,maxConcurrent:n,timeoutMs:r,promises:s}){return(await _({arr:e,f:t,name:i,maxConcurrent:n,timeoutMs:r,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:i,maxConcurrent:r,timeoutMs:s}){return(await _({name:e,arr:(0,n.compact)(t),f:i,maxConcurrent:r,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const i=await _({name:"partitionAsync",arr:e,f:t});return[i.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),i.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*a.secondMs,t.tryAll=async function(e,i=(e=>console.error(e)),n=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,n)}catch(e){i((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),i=(()=>{})){let n,r=null;try{n=await((0,h.isFunction)(e)?e():e)}catch(e){r=(0,m.toErr)(e);try{await t(e)}catch{}}try{await i(r??n)}catch{}if(null!=r)throw r;return n},t.thenNot=async function(e,t=!0){if(null==e)return t;const i=await e;return null==i?t:!(0,s.isTrue)(i)},t.thenMap2=async function(e,t,i){const n=await e;if(null==n)return;const r=await t;return null!=r?i(n,r):void 0},t.thenMapOr=async function(e,t,i){const n=await e;if(null==n)return i();const r=await t(n);return null==r?i():r},t.thenMap2Or=async function(e,t,i,n){const r=await e;if(null==r)return n();const s=await t;if(null==s)return n();const a=await i(r,s);return null==a?n():a},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let i=-1;for(const n of e){i++;try{if(null==n)continue;const e=await t(n,i);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const i of e){const e=await i();if(null!=e){const i=await t(e);if(null!=i)return i}}},t.firstResolvedDefinedPromise=async function(e,t){for(const i of e)try{const e=await i();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const i of t)try{const t=await i();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:i}){const n=await _({name:e,arr:t,f:i});return(0,r.sortBy)(n,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(42659),o=i(49769),l=i(31586),u=i(68708),c=i(42279),d=i(41583),h=i(22454),f=i(14121),m=i(50213),p=i(7282),g=i(34102),y=i(82647),v=i(25764),w=i(38836),S=i(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,i){const n=Date.now(),r=(0,l.clamp)(10*a.secondMs,a.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-n)+"ms")}),r);try{const r=await(0,c.tot)(t),s=Date.now()-n;return i?.(r,s),this.push(e,s),r}catch(t){throw this.errors.incr(e),i?.((0,d.toErr)(t),Date.now()-n),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),i=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),n=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",i.stats()],...n])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,o.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:i.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,i])=>({...e,[t]:(0,l.mapFinite)(i.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:i.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,i])=>({...e,[t]:{sumSec:(0,l.sigFigs)(i.sum/a.secondMs,3),...(0,u.omit)(i.stats(),"sum")}})),{})}}function M(e,t,i){return P.instance().time(e,t,i)}function _(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,n.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,r.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=M,t.timeSync=function(e,t){const i=Date.now(),n=t();return _(e,Date.now()-i),n},t.pushTime=_,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,i){return(0,n.lazy)((async()=>M(e,t)),i)}},42638:function(e,t,i){var n,r,s,a,o,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},d=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(i(66261)),m=i(40958),p=i(55835),g=i(31586),y=i(42279),v=i(54993),w=i(89788),S=i(82647),b=i(15674),P=i(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class M{constructor(e,t){n.add(this),this.name=e,this.ee=new f.default.EventEmitter,r.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),a.set(this,[]),o.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,r,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,b.maxCpus)(),d(this,r,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,o,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,a,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,a,"f").map((e=>e.name)),pendingNames:d(this,o,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:i,serialId:r}){const s=d(this,n,"m",l).call(this,{name:e,l:t,payload:i,serialId:r});return this.laterPop(),s}enqueueAll(e,t){const i=t.map((t=>d(this,n,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(i)}serial(e,t,i){return this.enqueue({name:e,l:t,serialId:e,payload:i})}push(e,t,i){return d(this,n,"m",u).call(this,new P.Deferred(e,{payload:i}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,a,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,o,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,o,"f").length,e),i=this.runningSerialIds,r=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,a,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,o,"f").length}hasPending(){return d(this,o,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,o,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,o,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=M,r=new WeakMap,s=new WeakMap,a=new WeakMap,o=new WeakMap,n=new WeakSet,l=function({name:e,l:t,payload:i,serialId:n}){const r=new P.Deferred(e,{payload:i,serialId:n});return d(this,o,"f").push({d:r,l:t}),r},u=function(e,t){const i=Date.now();return this.lastWorkTs=i,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,a,"f"),e),this.settleMsAvg.push(Date.now()-i),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,a,"f").push(e),e},t.maybeRun=function(e,t){const i=new M(e);return()=>i.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:i}){return new M(e,(0,p.map)(i,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class i extends Error{}t.RedoableError=i},4867:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const n=i(40958),r=i(34546),s=i(41400),a=i(31586),o=i(83104),l=i(85556),u=i(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:i}){let o=!0;return Promise.race((0,n.compact)([(0,r.asPromise)(e).finally((()=>o=!1)),(0,a.gt0)(t)?(0,s.delay)(t).then((()=>{if(o)throw new l.TimeoutError})):void 0,i?.abortPromise_().then((()=>{if(o)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:i}){let l=!0;return Promise.race((0,n.compact)([(0,r.asPromise)(e).finally((()=>l=!1)),(0,a.gt0)(t)?(0,s.delay)(t).then((()=>o.Timeout)):void 0,i?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let i=e=>null;t.setTimeoutHandler=function(e){i=e},t.onTimeout=function({soft:e}={}){i(e)}},73614:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const n=i(87997);t.setUnrefTimeout=function(e,t,...i){return(0,n.setTimeout)(e,Math.round(t),...i).unref()},t.setUnrefInterval=function(e,t,...i){return(0,n.setInterval)(e,Math.round(t),...i).unref()}},31562:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const n=i(38639),r=i(42659),s=i(41400),a=i(32639),o=i(31586),l=i(45255),u=i(95937);async function c(e,{timeoutMs:t,intervalMs:i,acceptable:n,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const n=i??(0,o.clamp)(10*m,l.ShortCommandTimeoutMs,(t??r.minuteMs)/5);await(0,s.delay)(n,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:n.isTrue,timeoutResult:!1})}},9727:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const r=n(i(1708)),s=i(45599),a=i(41400),o=i(50357),l=i(68708),u=i(48884),c=i(36638),d=i(44198),h=i(59958),f=i(96706),m=i(34102),p=i(19851),g=i(19043),y=i(66184),v=i(50213),w=i(7282),S=i(88158),b=i(45969),P=i(43334),M=i(28874),_=i(3790);function E(e){return x().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const x=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(M.Settings)){for(const i of t.names)e.add(i);for(const i of t.keys)e.add(i)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>E(e))))},(0,a.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,M.allSettings)())t.watchLater(e)}));const T=["HOME","LANG","USER"],D=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],k=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?T:D),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,M.pathWithDefaults)(),e}));function C(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const i of(0,M.persistedSettings)()){const n=e?i.value:i.envValue;null==n||(0,o.eql)(n,i.defaultValue)||i.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(r.default.env,(e=>E(e)||!(0,_.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=C,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:O({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let F=!1;function O({overrides:e,forceCLocale:i=!0,forWorker:n=!1}={}){const r=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...k(),...i?(0,g.childProcLocale)():{},...C(n),...e??{}});for(const e of(0,M.transientSettings)())e.deleteFromEnv(r);if((0,y.isLogged)("debug")&&!F){F=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(r).map((([e,t])=>[e,(0,_.isHiddenEnvKey)(e)?"(hidden)":t])),[i,n]=(0,u.partition)(t,(([e])=>E(e)));e.debug("PS env:",(0,l.fromEntries)(i)),e.debug("non PS env:",(0,l.fromEntries)(n))}return r}t.childEnv=O},84777:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const r=n(i(31421)),s=n(i(1708)),a=i(19851),o=i(40958),l=i(22573),u=i(42659),c=i(98553),d=i(56409),h=i(31586),f=i(68708),m=i(51926),p=i(50213),g=i(7282),y=i(88158),v=i(79089),w=i(45255),S=i(22911),b=i(4867),P=i(73614),M=i(70025),_=i(57159),E=i(36868),x=i(66184),T=i(45643),D=i(95402),k=i(9727),C=(0,a.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function F(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function O(e,t=30*u.secondMs){if(null==e)return!1;C().debug("endProcess()",F(e));const i=e.pid;if(null==i||i<=0)return C().warn("endProcess(): asked to end invalid pid",F(e)),!1;if(i===s.default.pid)return C().warn("endProcess(): asked to end MY pid",F(e)),!1;if(i===s.default.ppid)return C().warn("endProcess(): asked to end my parent pid",F(e)),!1;(0,E.closeStreams)(e);{const t=e.kill();C().debug("endProcess("+i+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,D.killPid)(i).catch((e=>{C().warn("endProcess(): kill("+i+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,T.waitForPidExit)(i,t))return C().debug("endProcess(): exitted",F(e)),!0;{D.Pids.instance()?.onKill(i);const t=e.kill("SIGKILL");C().warn("endProcess("+i+") had to resort to SIGKILL",{killResult:t}),t||await(0,D.killPid)(i,!0).catch((e=>{C().warn("endProcess(): kill("+i+",true) failed: "+e)}))}return(0,T.waitForPidExit)(i,5e3)}function I(e,i,n,r=0){const a=new Date,o=[];return(0,v.niceable)(i,n)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(r,u.secondMs)&&o.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&O(e)}),r-250)),o.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,D.addPid)({pid:e.pid,cmd:i,timeoutMs:r,ppid:s.default.pid},a)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>o.forEach(clearTimeout))),e}function L(e,t,i,n){const s=(0,k.spawnOptions)(n);return(0,x.isLogged)("trace",C().context)?C().debug("execFile()",{command:e,args:t,timeoutMs:i,opts:s}):C().debug("execFile()",{command:e,args:t,timeoutMs:i}),I(r.default.execFile(e,t,s),e,t,i)}async function A(e,t,i){const n=i.quiet??!1,r=i.ignoreStderr??!1,s=i.ignoreExitCode??!1,a=L(e,t,i.timeoutMs,(0,f.omit)(i,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===i.disconnect){try{a.disconnect?.()}catch{}return{result:"",pid:a.pid}}const u=a.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new S.Deferred(f);a.on("error",(e=>g.push(e))),a.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),a.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,E.endStream)(a.stdin);const v=new d.Latch;null==a.stdout?v.resolve():(a.stdout.on("error",(e=>g.push(e))),a.stdout.on("data",(e=>m.push(e))),a.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==a.stderr||r?P.resolve():(a.stderr?.on("error",(e=>g.push(e))),a.stderr?.on("data",(e=>p.push(e))),a.stderr?.on("end",(()=>P.resolve()))),C().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:i.timeoutMs,halt:i.halt}),C().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:i.halt});const x=p.join("");(0,l.notBlank)(x)&&g.push(new Error(x)),!n&&(0,o.isNotEmpty)(g)&&C().warn(f+" resulted in errors:",g);const T=i.isIgnorableError??M.isIgnorableError,D=g.filter((e=>!0!==T(e)));if(D.length>0)throw 1===D.length?D[0]:new _.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:D});if(!s&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:x}}catch(e){throw C().error("stdoutResult_() failed",e),await(0,D.killPid)(a.pid,!0),e}}t.endProcess=O,t.ReniceAfterMs=(0,a.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,a.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,i,n){const s=(0,k.spawnOptions)(n);return C().debug("spawn()",{command:e,args:t,maxAgeMs:i}),I(r.default.spawn(e,t,s),e,t,i)},t.execFile=L,t.stdoutResult_=A,t.stdout_=async function(e,t,i){const n=await A(e,t,i);return C().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(n.result),meta:{cmd:e,args:t,opts:i,result:n}})}},3790:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const n=i(22573),r=i(41400),s=i(19851),a=i(28874);(0,r.later)((()=>a.Settings.sensitiveEnvRegExp.watchLater((()=>o.unset()))));const o=(0,s.lazy)((()=>{try{return new RegExp(a.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${a.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(a.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,n.blank)(e)&&o().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||a.Settings.license.includesEnvKey(e)}},55534:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceExitCommand=void 0,t.ServiceExitCommand="--exit"},34330:function(e,t,i){var n,r,s,a,o,l,u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.WatchedChild=t.mkBasicWatchedChild=void 0;const d=i(58587),h=i(19851),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(54993),w=i(27395),S=i(25764),b=i(99331),P=i(42638),M=i(38835),_=i(8769),E=i(57159),x=i(66003),T=i(50213),D=i(45643),k=i(28874),C=i(84777);t.mkBasicWatchedChild=function(e){return new F({name:(0,f.compact)([e.cmd,...e.args]).join(" "),childFactory:()=>(0,C.spawn)(e.cmd,e.args,30*p.minuteMs),onStdout:()=>{},onError:()=>!0,ignoreStopErrors:!0,...e})};class F{constructor(e){n.add(this),this.startTs=Date.now(),this._stopped=!1,this.logger=(0,h.lazy)((()=>(0,T.mkLogger)("WatchedChild("+(0,f.compact)([this.name,this.pid]).join(":")+")"))),this.startRate=new d.Rate,this.mutex=new P.Promises("child.WatchedChild.mutex",(()=>1)),r.set(this,!1),this.onError=(e,t,i)=>{const s=new E.WrappedError(e,{cause:t}),a=!1!==s.ignorable;this.logger().log(a?"warn":"error","onError()",s),u(this,r,"f")||a||(this.lastError=s,(0,_.onError)(s),!0!==s.fatal?(i??this.opts.onError(e,s))&&(this.logger().warn("onError requested restart",{src:e,error:s}),u(this,n,"m",o).call(this)):this.end())},this.name=e.name,this.opts={dataSep:"\n",maxErrorsPerMinute:k.Settings.fatalErrorRatePerMinute.valueOrDefault,endableRank:S.EndableRanks.first,exitCommand:"",restartOnExit:!0,endTimeoutMs:null,...e},(0,w.addEndable)(this.opts.endableRank,this),u(this,n,"m",o).call(this)}get endTimeoutMs(){return(0,g.denull)(this.opts.endTimeoutMs)}get stopped(){return this._stopped}get ended(){return u(this,r,"f")}async end(){return c(this,r,!0,"f"),u(this,n,"m",s).call(this)}get proc(){return this.cp}get pid(){return(0,g.map)(this.cp,(e=>e.pid))}running(){return(0,d.pidExists)(this.pid)}notRunning(){return!this.running()}writeStdin(e){return this.cp?.stdin?.write(e)}async stop(){return this.logger().info("stop()"),this._stopped=!0,this.mutex.serial("",(()=>(this._stopped=!0,u(this,n,"m",s).call(this))))}isErrorRateExceeded(){return this.logger().tap({msg:"isErrorRateExceeded()",result:(0,y.gt)(this.startRate.eventsPerMinute,this.opts.maxErrorsPerMinute),meta:{startRatePerMin:this.startRate.eventsPerMinute,maxErrorsPerMin:this.opts.maxErrorsPerMinute}})}async restart(e=!1){return this.logger().info("restart()",{stopped:this._stopped,ended:u(this,r,"f")}),!u(this,r,"f")&&!(0,b.ending)()&&(e||!(0,y.lt)(this.startRate.msSinceLastEvent,k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault)?this.mutex.serial("",(async()=>(await u(this,n,"m",s).call(this),this._stopped=!1,u(this,n,"m",l).call(this)))):void this.logger().info("restart(): last restart was too recent. Ignoring.",{msSinceLastEvent:this.startRate.msSinceLastEvent,minTimeBetweenServiceRestartsMs:k.Settings.minTimeBetweenServiceRestartsMs.valueOrDefault}))}async start(){return this.logger().info("start()",{stopped:this._stopped,ended:u(this,r,"f")}),this.mutex.serial("",(async()=>(this._stopped=!1,u(this,n,"m",l).call(this))))}}t.WatchedChild=F,r=new WeakMap,n=new WeakSet,s=async function(){this.logger().info("#stop()",{stopped:this._stopped,ended:u(this,r,"f")});const e=this.cp;return this.cp=void 0,u(this,n,"m",a).call(this,e)},a=async function(e){if(null==e)return!0;if((0,y.gt0)(e.pid)&&(0,m.notBlank)(this.opts.exitCommand)&&!0===e.stdin?.writable)try{e.stdin.write(this.opts.exitCommand+"\n"),await(0,D.waitForPidExit)(e.pid,(this.endTimeoutMs??p.secondMs)/2)}catch(e){this.logger().warn("stopChild: error writing to stdin",{error:e})}return(0,C.endProcess)(e,this.endTimeoutMs)},o=async function(){return this.logger().info("#restart()",{stopped:this._stopped,ended:u(this,r,"f")}),this.mutex.maybeRun("",(async()=>(await u(this,n,"m",s).call(this),!this._stopped&&!u(this,r,"f")&&(this.isErrorRateExceeded()?(this.logger().warn("Cannot restart, error/restart rate is too high.",{errorsPerMinute:this.startRate.eventsPerMinute,msSinceLastStart:this.startRate.msSinceLastEvent}),this.opts.onRestartPaused?.(),(0,_.onError)("Can't restart "+this.name+", failure rate is too high."+M.FatalErrorFlag,this.lastError),!1):(this.logger().info("#restart()",{currentPid:this.pid,startRate:this.startRate,maxErrorsPerMinute:this.opts.maxErrorsPerMinute}),this.opts.onRestart?.(),u(this,n,"m",l).call(this))))))},l=async function(){if(this.logger().info("#start()",{stopped:this._stopped,ended:u(this,r,"f")}),this._stopped||u(this,r,"f")||(0,b.ending)())return!1;if(this.running())return!1;this.startRate.onEvent();const e=this.cp=await this.opts.childFactory();this.logger.unset(),this.logger().info("#start(): spawned pid "+this.pid);const t="cp("+e.pid+")";return[{o:e,desc:""},{o:e.stdin,desc:".stdin"},{o:e.stdout,desc:".stdout"},{o:e.stderr,desc:".stderr"}].forEach((({o:e,desc:i})=>{(0,g.map)(e,(e=>e.on("error",(e=>this.onError(t+i+".on(error)",e)))))})),(0,g.map)(this.cp.stdout,(e=>(0,x.onDataChunked)(e,this.opts.dataSep,(e=>{this.logger().trace("onDataChunked()",e),this.opts.onStdout(e)})))),(0,g.map)(this.cp.stderr,(e=>e.on("data",(async e=>{(0,v.toS)(e).includes("Error: Cannot find module")&&(0,_.onError)("Failed to start "+this.name+M.FatalErrorFlag,new Error(e)),!0===await(this.opts.onStderr?.(e))&&this.onError(t+".stderr.on(data)",e)})))),this.cp.on("exit",(async(e,t)=>{this.logger().info("onExit",{code:e,signal:t,stopped:this._stopped,ended:u(this,r,"f")}),(0,b.ending)()||(this.opts.restartOnExit?(await u(this,n,"m",o).call(this),this.logger().info("onExit(): finished setting up new child",{pid:this.pid})):(this.logger().info("onExit(): this.opts.restartOnExit is false. Ending.",{pid:this.pid}),this.end()))})),!0}},46199:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.stableBasename=t.ciSafePath=void 0;const a=s(i(53916)),o=i(17217),l=i(19935),u=i(7282),c=i(84699),d=i(9595),h=i(4001),f=i(95696);function m(e){return(0,h.stripCopySuffixFromName)(e,{aggressive:!1})+e.ext}t.ciSafePath=function(e,t){if(!(0,u.isTest)())return(0,o.toNativePath_)(e);const i=f.PosixFile.for(e),n=t?.stableBasename??1?m(i):i.base.normalize(),r=i.sibling(n);if(r.isSelfOrDescendantOf((0,l.examples)()))return a.join("$examples",r.posixPathFrom((0,l.examples)()));const s=(0,d.originalsDir)();if(r.isSelfOrDescendantOf(s))return a.join("$library",r.posixPathFrom(s));const h=i.findAncestor((e=>e.base.startsWith(c.TestLibraryDirPrefix)));return null!=h?a.join("$library",r.posixPathFrom(h)):i.baseWithGrandparent},t.stableBasename=m},80061:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const n=i(1708),r=i(31586),s=i(51926),a=i(17344),o=i(37805),l=i(84542);function u(e,t){const i=t?.maxLineLen??(0,r.toInt)(n.env.maxLineLen)??n.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:i,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,a.EditionName)()+" v"+o.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},54772:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bestLabhashName=t.bestLabName=t.bestRgbName=t.colorToTuple=t.bestRgbTripletName=t.ColorNames=void 0;const n=i(19851),r=i(40958),s=i(49769),a=i(31586),o=i(48884),l=i(50213),u=i(81168),c=i(85810),d=i(42079),h=i(91482),f=i(3048),m=i(85409),p=i(16050),g=i(42022),y=i(85042),v=(0,n.lazy)((()=>(0,l.mkLogger)("color.ColorNames")));function w(e){const t=(0,y.normalizeRgbHex)(e.rgb);if(null==t)return void v().warn(`skipping invalid entry (bad rgb): ${e.rgb}`,e);const i=(0,c.rgbhex2Lab)(t);if(null==i)return void v().warn(`skipping invalid entry (failed to convert to L*a*b): ${t}`,e);const n=(0,c.toLabhash)(i,g.ModeBits);return{...e,rgb:t,lab:i,labhash:n,closeLabhashes:[n],closeRgb:[t],name:(0,u.capitalize)(e.name)}}function S(e,i){return null==e?void 0:(0,o.leastBy)(i??(0,t.ColorNames)(),(t=>(0,f.ciede2000_delta_e)(t.lab,e)))}t.ColorNames=(0,n.lazy)((()=>(0,r.compact)([...d.CrayonColors,...d.CrayonSupplements,...h.DarkWikipediaColors,...p.LightWikipediaColors,...m.Greys].map(w)))),t.bestRgbTripletName=function(e,i=(0,t.ColorNames)()){return S((0,c.rgb2lab)(e),i)},t.colorToTuple=w,t.bestRgbName=function(e){return P((0,c.rgbhex2Labhash)(e))},t.bestLabName=S;const b=new Map;function P(e){return(0,a.gte0)(e)?(0,s.getOrSet)(b,e,(()=>{const i=(0,t.ColorNames)().find((t=>t.labhash===e));if(null!=i)return i;const n=(0,c.unlabhash)(e),s=S(n);return null!=n&&null!=s&&((0,r.pushUniq)(s.closeLabhashes,e),(0,r.pushUniq)(s.closeRgb,(0,c.lab2rgbhex)(n))),s})):void 0}t.bestLabhashName=P},85810:(e,t,i)=>{e=i.nmd(e),Object.defineProperty(t,"__esModule",{value:!0}),t.hsv2rgb=t.hsl2hsv=t.hsv2hsl=t.hsl2rgb=t.rgb2hsl=t.rgbhex2hsl=t.rgb2hsv=t.closestLab=t.maxLabhash=t.minLabhash=t.unlabhash=t.toLabhash=t.LabBitZip=t.xyz2rgb=t.lab2xyz=t.xyz2lab=t.rgb2xyz=t.clampLab=t.lab2rgb=t.rgb2lab=t.rgb2labArray=t.rgb2labTriplets=t.lab2rgbhex=t.rgbhex2Labhash=t.rgbhex2Lab=void 0;const n=i(19851),r=i(40958),s=i(49769),a=i(55835),o=i(31586),l=i(48884),u=i(20014),c=i(75503),d=i(3048),h=i(42022),f=i(85042),m=[[.4124564,.3575761,.1804375],[.2126729,.7151522,.072175],[.0193339,.119192,.9503041]],p=[[3.2404542,-1.5371385,-.4985314],[-.969266,1.8760108,.041556],[.0556434,-.2040259,1.0572252]];function g(e){return M(w(e))}function y(e){return(0,f.clampRGB)(E(_(e)))}function v(e){return(0,t.LabBitZip)().clampValue(e)}function w(e){const t=(0,f.clampRGB)(e).map((e=>e/255)).map((e=>e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92));return(0,c.matXvec)(m,t)}t.rgbhex2Lab=function(e){return(0,a.map)((0,f.rgbhex2triplet)(e),g)},t.rgbhex2Labhash=function(e,t=h.ModeBits){return(0,a.map)((0,f.rgbhex2triplet)(e),(e=>x(g(e),t)))},t.lab2rgbhex=function(e){return(0,f.rgbTriplet2hex)(y(e))},t.rgb2labTriplets=function(e){return(0,r.stepRange)(0,e.length,3).map((t=>g([e[t],e[t+1],e[t+2]])))},t.rgb2labArray=function(e){const t=[],i=[],n=[];for(let r=0;re>b?Math.pow(e,1/3):(P*e+16)/116));return v([116*i-16,500*(t-i),200*(i-n)])}function _(e){const[t,i,n]=v(e),r=(t+16)/116,s=i/500+r,a=r-n/200,o=s*s*s,l=a*a*a,u=o>b?o:(116*s-16)/P,c=t>8?Math.pow(r,3):t/P,d=l>b?l:(116*a-16)/P;return[u*S.X,c*S.Y,d*S.Z]}function E(e){return(0,c.matXvec)(p,e).map((e=>{const t=e<0?-1:1,i=e*t;return(0,o.round)(255*t*(i<=.0031308?12.92*i:1.055*Math.pow(i,1/2.4)-.055))}))}function x(e,i=h.ModeBits){return(0,t.LabBitZip)().zip(e,i)}t.xyz2lab=M,t.lab2xyz=_,t.xyz2rgb=E,t.LabBitZip=(0,n.lazy)((()=>new u.BitZip([{min:0,max:100},{min:-79,max:90},{min:-102,max:89}]))),t.toLabhash=x;const T=new Map;function D(e,i=h.ModeBits){return(0,t.LabBitZip)().unzip(e,i)}function k(e){const[t,i,n]=(0,f.clampRGB)(e),r=Math.max(t,i,n),s=r-Math.min(t,i,n),a=s?r===t?(i-n)/s:r===i?2+(n-t)/s:4+(t-i)/s:0;return[60*(a<0?a+6:a),r?s/r*100:0,r/255*100]}function C(e){return F(k(e))}function F(e){const[t,i,n]=e,r=(200-i)*n/100;return[t,r>0&&r<200?i*n/100/(r<=100?r:200-r)*100:0,r/2]}function O(e){const[t,i,n]=e,r=i*(n<50?n:100-n)/100;return[t,r>0?2*r/(n+r)*100:0,n+r]}function I(e){const t=e[0]/360*6,i=e[1]/100,n=e[2]/100,r=Math.floor(t),s=n*(1-i),a=n*(1-(t-r)*i),o=n*(1-(1-t+r)*i),l=r%6;return(0,f.clampRGB)([255*[n,a,s,s,o,n][l],255*[o,n,n,a,s,s][l],255*[s,s,o,n,n,a][l]])}t.unlabhash=function(e,t=h.ModeBits){return t===h.ModeBits?(0,s.getOrSet)(T,e,(()=>D(e,t))):D(e,t)},t.minLabhash=(0,n.lazy)((()=>(0,t.LabBitZip)().zipMin(h.ModeBits))),t.maxLabhash=(0,n.lazy)((()=>(0,t.LabBitZip)().zipMax(h.ModeBits))),t.closestLab=function(e,t){return(0,l.leastBy)(e,(e=>(0,d.ciede2000_delta_e)(e,t)))},t.rgb2hsv=k,t.rgbhex2hsl=function(e){return C((0,f.rgbhex2triplet)(e))},t.rgb2hsl=C,t.hsl2rgb=function(e){return I(O(e))},t.hsv2hsl=F,t.hsl2hsv=O,t.hsv2rgb=I,i.c[i.s]===e&&console.log(x([0,0,0]))},42079:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CrayonSupplements=t.CrayonColors=void 0,t.CrayonColors=[{name:"Aquamarine",rgb:"#95E0E8"},{name:"Asparagus",rgb:"#7BA05B"},{name:"Blue-green",rgb:"#0095B7"},{name:"Royal blue",rgb:"#273BE2"},{name:"Blush",rgb:"#DB5079"},{name:"Brilliant rose",rgb:"#E667CE"},{name:"Brown",rgb:"#AF593E"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Burnt umber",rgb:"#805533"},{name:"Cadet blue",rgb:"#A9B2C3"},{name:"Canary",rgb:"#FFFF99"},{name:"Carmine",rgb:"#E62E6B"},{name:"Carnation pink",rgb:"#FFA6C9"},{name:"Celestial blue",rgb:"#7070CC"},{name:"Cerise",rgb:"#DA3287"},{name:"Cerulean blue",rgb:"#339ACC"},{name:"Chestnut",rgb:"#B94E48"},{name:"Cobalt blue",rgb:"#8C90C8"},{name:"Copper",rgb:"#DA8A67"},{name:"Cornflower",rgb:"#93CCEA"},{name:"Cotton candy",rgb:"#FFB7D5"},{name:"Denim",rgb:"#1560BD"},{name:"Eggplant",rgb:"#614051"},{name:"Fern",rgb:"#63B76C"},{name:"Fuchsia",rgb:"#C154C1"},{name:"Russet",rgb:"#87421F"},{name:"Green",rgb:"#01A638"},{name:"Green-yellow",rgb:"#F1E788"},{name:"Indigo",rgb:"#4F69C6"},{name:"Jungle green",rgb:"#29AB87"},{name:"Magenta",rgb:"#F653A6"},{name:"Maize",rgb:"#F2C649"},{name:"Maroon",rgb:"#C32148"},{name:"Medium chrome green",rgb:"#6CA67C"},{name:"Medium violet",rgb:"#8F47B3"},{name:"Melon",rgb:"#FEBAAD"},{name:"Middle blue-green",rgb:"#8DD9CC"},{name:"Middle blue-purple",rgb:"#8B72BE"},{name:"Green-yellow",rgb:"#ACBF60"},{name:"Middle purple",rgb:"#D982B5"},{name:"Middle yellow-red",rgb:"#ECAC76"},{name:"Midnight blue",rgb:"#003366"},{name:"Mulberry",rgb:"#C8509B"},{name:"Navy blue",rgb:"#0066CC"},{name:"Olive green",rgb:"#B5B35C"},{name:"Orange",rgb:"#FF8833"},{name:"Orchid",rgb:"#E29CD2"},{name:"Peach",rgb:"#FFCBA4"},{name:"Periwinkle",rgb:"#C3CDE6"},{name:"Pine green",rgb:"#01796F"},{name:"Pink flamingo",rgb:"#FC74FD"},{name:"Plum",rgb:"#8E3179"},{name:"Raw umber",rgb:"#665233"},{name:"Red-orange",rgb:"#FF681F"},{name:"Red",rgb:"#ED0A3F"},{name:"Salmon",rgb:"#FF91A4"},{name:"Vivid scarlet",rgb:"#FD0E35"},{name:"Sea green",rgb:"#93DFB8"},{name:"Sepia",rgb:"#9E5B40"},{name:"Shamrock",rgb:"#33CC99"},{name:"Sky blue",rgb:"#76D7EA"},{name:"Spring green",rgb:"#ECEBBD"},{name:"Sunset orange",rgb:"#FE4C40"},{name:"Tan",rgb:"#FA9D5A"},{name:"Teal blue",rgb:"#008080"},{name:"Thistle",rgb:"#D8BFD8"},{name:"Vivid tangerine",rgb:"#ED3C10"},{name:"Vivid violet",rgb:"#a625c3"},{name:"Wisteria",rgb:"#C9A0DC"},{name:"Yellow-green",rgb:"#C5E17A"},{name:"Yellow-orange",rgb:"#FFAE42"},{name:"Yellow",rgb:"#FBE870"}],t.CrayonSupplements=[{name:"Artichoke",rgb:"#8F9779"},{name:"Aubergine",rgb:"#48213A"},{name:"Brandy rose",rgb:"#B1847F"},{name:"Burgundy",rgb:"#800020"},{name:"Burnt sienna",rgb:"#E97451"},{name:"Crimson red",rgb:"#990000"},{name:"Dark brown",rgb:"#664228"},{name:"Dark coral",rgb:"#CD5B45"},{name:"Dark green",rgb:"#006400"},{name:"Dark raspberry",rgb:"#872657"},{name:"Dark turquoise",rgb:"#610079"},{name:"Deep teal",rgb:"#004040"},{name:"Deep coffee",rgb:"#704241"},{name:"Dusty rasberry",rgb:"#917980"},{name:"Ecru",rgb:"#BCAC7C"},{name:"Evergreen",rgb:"#05472A"},{name:"Eggplant",rgb:"#380835"},{name:"Eggplant purple",rgb:"#430541"},{name:"Emerald green",rgb:"#028F1E"},{name:"Flamingo pink",rgb:"#D67C99"},{name:"Grape",rgb:"#6C3461"},{name:"Kelly green",rgb:"#4CBB17"},{name:"Light forest green",rgb:"#4F9153"},{name:"Medium dark brown",rgb:"#AF7200"},{name:"Medium dark cyan-blue",rgb:"#2D537C"},{name:"Mustard",rgb:"#FAAF18"},{name:"Neon green",rgb:"#39FF14"},{name:"Pear",rgb:"#D1E231"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Phthalo blue",rgb:"#0016C7"},{name:"Pink lace",rgb:"#FFDDF4"},{name:"Raw sienna",rgb:"#884B15"},{name:"Rebecca purple",rgb:"#663399"},{name:"Sap green",rgb:"#536916"},{name:"Blue sapphire",rgb:"#133ECB"},{name:"Sand",rgb:"#B38751"},{name:"Shadow blue",rgb:"#778BA5"},{name:"Shadow green",rgb:"#121E06"},{name:"Swamp green",rgb:"#748500"},{name:"Verdigris",rgb:"#43B3AE"},{name:"Vivid blue-magenta",rgb:"#4817E8"},{name:"Vivid blue-purple",rgb:"#ACACE6"},{name:"Vivid blue",rgb:"#47ABCC"},{name:"Vivid green-yellow",rgb:"#D9E650"},{name:"Vivid green",rgb:"#7BE214"},{name:"Vivid turqoise",rgb:"#06ECD2"},{name:"Vivid lavender",rgb:"#A354FD"},{name:"Vivid mint",rgb:"#00F28C"},{name:"Vivid pink",rgb:"#D752FB"},{name:"Vivid red-purple",rgb:"#C31D7E"},{name:"Vivid red",rgb:"#D92121"},{name:"Vivid yellow-red",rgb:"#F2BA49"},{name:"Vivid yellow",rgb:"#FAFA37"}]},91482:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DarkWikipediaColors=void 0,t.DarkWikipediaColors=[{name:"Bistre",rgb:"#3D2B1F"},{name:"Black bean",rgb:"#3D0C02"},{name:"Black pearl",rgb:"#041322"},{name:"Shadow blue",rgb:"#001440"},{name:"Charcoal",rgb:"#36454F"},{name:"Dark indigo",rgb:"#1F0A52"},{name:"Dark magenta",rgb:"#8B008B"},{name:"Dark moss green",rgb:"#4A5D23"},{name:"Dark navy",rgb:"#02075D"},{name:"Dark pastel blue",rgb:"#779ECB"},{name:"Dark purple",rgb:"#580040"},{name:"Dark tan",rgb:"#918151"},{name:"Dark yellow-green",rgb:"#304000"},{name:"Dark yellow",rgb:"#9B870C"},{name:"Deep violet",rgb:"#330066"},{name:"Dusk",rgb:"#4E5481"},{name:"Elderberry",rgb:"#1d1a34"},{name:"Grey jade",rgb:"#757C55"},{name:"Grey magenta",rgb:"#83667F"},{name:"Grey ochre",rgb:"#716659"},{name:"Grey olive",rgb:"#656c5a"},{name:"Grey sage",rgb:"#69724d"},{name:"Taupe",rgb:"#483C32"}]},3048:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciede2000_delta_e=t.diffCIECorr=t.MaxCie=t.MinCie=t.cie94_delta_e=t.cie76_delta_e=void 0;const n=i(31586),r=i(97352);t.cie76_delta_e=function(e,t){return Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2)},t.cie94_delta_e=function(e,t){const[i,n,s]=e,[a,o,l]=t,u=i-a,c=n-o,d=s-l,h=(0,r.sqrt)(n**2+s**2),f=h-(0,r.sqrt)(o**2+l**2),m=(0,r.sqrt)(c**2+d**2-f**2);return(0,r.sqrt)((u/1)**2+(f/(1+.045*h))**2+(m/(1+.015*h))**2)},t.MinCie=2,t.MaxCie=20,t.diffCIECorr=function(e,i){return null==e||null==i?1:(0,n.clamp)(0,t.MaxCie,l(e,i)-t.MinCie)/t.MaxCie};const s=1,a=1,o=1;function l(e,t){const[i,n,l]=e,u=(0,r.sqrt)(n**2+l**2),[c,d,h]=t,f=(u+(0,r.sqrt)(d**2+h**2))/2,m=.5*(1-(0,r.sqrt)(Math.pow(f,7)/(Math.pow(f,7)+Math.pow(25,7)))),p=n*(1+m),g=d*(1+m),y=(0,r.sqrt)(p*p+l*l),v=(0,r.sqrt)(g*g+h*h);let w=Math.abs(p)+Math.abs(l)===0?0:Math.atan2(l,p);w+=2*(w<0?1:0)*Math.PI;let S=Math.abs(g)+Math.abs(h)===0?0:Math.atan2(h,g);S+=2*(S<0?1:0)*Math.PI;const b=c-i,P=v-y;let M=y*v==0?0:S-w;M-=2*(M>Math.PI?1:0)*Math.PI,M+=2*(M<-Math.PI?1:0)*Math.PI;const _=2*(0,r.sqrt)(y*v)*Math.sin(M/2),E=(i+c)/2,x=(y+v)/2;let T;y*v==0?T=w+S:(T=(w+S)/2,T-=(Math.abs(w-S)>Math.PI?1:0)*Math.PI,T+=2*(T<0?1:0)*Math.PI);const D=(E-50)**2,k=1-.17*Math.cos(T-Math.PI/6)+.24*Math.cos(2*T)+.32*Math.cos(3*T+Math.PI/30)-.2*Math.cos(4*T-63*Math.PI/180),C=1+.015*D/(0,r.sqrt)(20+D),F=1+.045*x,O=1+.015*x*k,I=30*Math.PI/180*Math.exp(-1*((180/Math.PI*T-275)/25)**2),L=2*(0,r.sqrt)(Math.pow(x,7)/(Math.pow(x,7)+Math.pow(25,7))),A=-1*Math.sin(2*I)*L;return(0,r.sqrt)(Math.pow(b/(s*C),2)+Math.pow(P/(a*F),2)+Math.pow(_/(o*O),2)+A*P/(a*F)*_/(o*O))}t.ciede2000_delta_e=l},76490:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColor=t.dominantColorsToRgbHex=void 0;const n=i(40958),r=i(31586),s=i(97352),a=i(54772),o=i(85810),l=i(42022),u=i(1971);t.dominantColorsToRgbHex=function(e){return(0,n.compact)(e.map((e=>[e.rgbhex,(0,r.fmtPct)(e.pct)])))};class c{static fromModeData(e){return(0,n.compact)((0,r.times)(u.ModeCount,(t=>c.fromLabhash({labhash:e[`mode${t}`],pct:e[`mode${t}pct`]}))))}static toModeData(e){const t={};return(0,r.times)(u.ModeCount,(i=>{t["mode"+i]=e[i]?.labhash??null,t["mode"+i+"pct"]=e[i]?.pct??null})),t}static fromLabhash({labhash:e,labhashBits:t=l.ModeBits,pct:i}){const n=(0,s.mapGt0)(e,(e=>(0,o.unlabhash)(e,t)));return null!=n&&(0,r.gt0)(i)?new c(n,i,e):void 0}static fromCentroid(e,t){return new c(e.centroid,Math.round(e.size/t*100))}constructor(e,t,i){this.lab=e,this.pct=(0,r.clamp)(0,100,t),this.labhash=i??(0,o.toLabhash)(e,l.ModeBits)}get rgbhex(){return(0,o.lab2rgbhex)(this.lab)}get color(){return(0,a.bestLabhashName)(this.labhash)}toGreyscale(){return new c([this.lab[0],0,0],this.pct)}eql(e){return this.labhash===e.labhash&&(0,r.closeTo)(this.pct,e.pct,5)}}t.DominantColor=c},40401:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeNearCentroids=t.mergeLabhashes=t.dominantColorsFromModes=t.maybeFilterGrey=t.centroidsScore=t.extractDominantColors=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(41400),o=i(98553),l=i(31586),u=i(68708),c=i(48884),d=i(22454),h=i(50213),f=i(56038),m=i(82647),p=i(44983),g=i(70417),y=i(28874),v=i(85810),w=i(3048),S=i(76490),b=i(1971),P=(0,n.lazy)((()=>(0,h.mkLogger)("color.DominantColors")));t.extractDominantColors=function(e,t=b.ModeCount){return(0,f.timeSync)("img.extractDominantColors",(()=>function(e,t=b.ModeCount){const i=Date.now(),n=y.Settings.dominantColorKmeansRuns.valueOrDefault,a=new d.CountingSet;for(const i of x({labs:e,minK:t}))a.incr((0,v.toLabhash)(i));const h=_[y.Settings.dominantColorDeltaE.valueOrDefault]??w.ciede2000_delta_e;const f=a.sortedByKey().valuesToA((e=>(0,v.unlabhash)(e)));let g=(0,l.round)(t+y.Settings.dominantColorMergeThreshold.valueOrDefault);function D(e){const i=t,n=4*t;g=Math.round(Math.max(i,Math.min(n,e)))}const C=f.length<=g?[]:(0,r.compact)(M.slice(0,n).map((e=>{const n=(0,p.kmeans)(f,g,{...E,seed:e}),r=k(n.centroids,f.length);if(r.lengtht&&D(g-1);const s=r.slice(0,t),o=(0,l.sigFigs)(function(e){const t=new m.Average;for(const[i,n]of a.entries()){const r=(0,v.unlabhash)(i),s=(0,c.leastByCtx)(e,(e=>h(e.centroid,r)));null!=s&&(0,l.times)(n,(()=>t.push(s.value)))}return t.p84}(s),2);return{...n,centroids:s,description:{kIn:g,kOut:n.centroids.length,kMerged:r.length,score:o,iterations:n.iterations,uniqColors:a.size,elapsedMs:Date.now()-i},score:o}})));P().trace("extractDominantColors()",{kmeansResults:C.map((e=>(0,u.pick)(e,"description","score")))});const F=(0,c.leastBy)(C,(e=>e.score));if(null==F)return P().info("kmeans failed or was disabled, using dominantColorsFromModes",{runs:n}),T(a,t);const O=(0,o.stringify)({...F?.description,elapsedMs:Date.now()-i}),I=(0,s.sortBy)(F?.centroids,(e=>-e.size)).map((e=>S.DominantColor.fromCentroid(e,f.length)));return P().debug("extractDominantColors() result",{description:O,score:F?.score,totalColors:a.size,totalPixels:f.length,iters:F?.iterations,dominantColors:(0,S.dominantColorsToRgbHex)(I),pixelCount:f.length}),{dominantColors:I,description:O,dominantColorScore:F?.score}}(e,t)))},t.centroidsScore=function(e,t){const i=new m.Average;for(const n of e){const e=(0,c.leastBy)(t,(e=>(0,w.ciede2000_delta_e)(e.centroid,n)));null!=e&&i.push((0,w.ciede2000_delta_e)(e.centroid,n))}return i};const M=[6147062518717073,8176726750919909,5426648081701673,0xce2a345532a3c,0x713f9716da824,6348935463312109,5900323173950995,7358780886584433,5704068712193493,0x51ceeef755892,0xe1557fe94c084,0xd42d7cc96d6b4,0xcbc36dfd76e8a,6738189173486085,8537822851166899,5390086061821835,7712057976331355,0xe9b820db7a8e4,0xb96cebcd6aa40,7036994544380825,5353634786120155,0x99a11417794bc,0xa93d36019aaae,0x74a470887095e,5481147022770415,5347523348244809,0x541d1098e90fc,0xa24d9fb3510c2,0x78aa8e4f692fa,6354921850669697,0x714e1ec1b0a14,8622097963014773,0x6ff5d462d8eb6,0x6782a6b5166b8,7128984079394103,0xe6efba28a3752,5088704486053871,0xc84df40627fae,8018285280412081,4524300326741245,8307147030534695,8135486835878813,7699950603263999,0xb2889592968ae,5903399874280295,7462660765348991,6442509751447017,0xe218d44834db6,7214173935589545,6001326758941961,0x53eb7d39bbb50,0xc3a7ab8add332,0x4e6e81bc443e2,6757635537583321,8501611905255957,0x51840465cc07c,5958243312989149,8928005021308717,5032083390680559,0xb35d70ac51c68,0xfc3826a2dfe7c,0xd155853c61e96,0xda2045ee9be1e,4753952745315177],_={cie76:w.cie76_delta_e,cie94:w.cie94_delta_e,ciede2000:w.ciede2000_delta_e},E=(0,n.lazy)((()=>({maxIterations:50,initialization:"kmeans++",distanceFunction:_[y.Settings.dominantColorDeltaE.valueOrDefault]})));function x({labs:e,minK:t,thresh:i,retries:n=3}){if(n<0)return P().debug("maybeFilterGrey(): exhausted retries: grey filtering disabled."),e;const r=i??y.Settings.dominantColorGreyThreshold.valueOrDefault;if(!(0,l.gt0)(r))return P().debug("maybeFilterGrey(): grey threshold is <= 0: grey filtering disabled."),e;const s=e.filter((e=>Math.abs(e[1])+Math.abs(e[2])>=r));return s.length>=e.length/2?(P().debug("maybeFilterGrey(): sufficient remaining pixels with this threshold.",{greyThreshold:r,minK:t,pixelCount:e.length,filteredCount:s.length}),s):(P().debug("maybeFilterGrey(): insufficient remaining pixels with this threshold. Retrying with smaller threshold.",{greyThreshold:r,minK:t,retries:n,pixelCount:e.length,filteredCount:s.length}),x({labs:e,minK:t,thresh:.75*r,retries:n-1}))}function T(e,t){const i=e.countSum,n=e.size;D(e);const s=e.size,a=(0,r.compact)(e.top(t).map((([e,t])=>S.DominantColor.fromLabhash({labhash:e,pct:Math.round(100*t/i)})))),l=100-(0,g.sumf)(a,(e=>e.pct));return{dominantColors:a,description:"dominantColorsFromModes: "+(0,o.stringify)({uniqColors:n,mergedColors:s,pixelCount:i,pctOmitted:l})}}function D(e,t=y.Settings.dominantColorMergeThreshold.valueOrDefault){const i=[];for(const[n,r]of[...e.entriesByCountDesc()]){const s=(0,v.unlabhash)(n),a=i.find((e=>(0,w.ciede2000_delta_e)(e.lab,s)<=t));null==a?i.push({lab:s,labhash:n}):(e.delete(n),e.incr(a.labhash,r))}return e}function k(e,t,i=y.Settings.dominantColorMergeThreshold.valueOrDefault){if(i<=0)return e;const n=[];for(const t of e){const e=n.find((e=>(0,w.ciede2000_delta_e)(t.centroid,e.centroid)<=i));null==e?n.push(t):e.size+=t.size}const r=t/100;return(0,s.sortBy)(n.filter((e=>e.size>r)),(e=>-e.size))}(0,a.later)((()=>{y.Settings.dominantColorDeltaE.watchLater((()=>{E.unset()}))})),t.maybeFilterGrey=x,t.dominantColorsFromModes=T,t.mergeLabhashes=D,t.mergeNearCentroids=k},85409:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Greys=void 0,t.Greys=[{name:"Black",rgb:"#000000"},{name:"90% black",rgb:"#1b1b1b"},{name:"80% black",rgb:"#303030"},{name:"70% black",rgb:"#474747"},{name:"60% black",rgb:"#5e5e5e"},{name:"Grey",rgb:"#777777"},{name:"60% white",rgb:"#919191"},{name:"70% white",rgb:"#ababab"},{name:"80% white",rgb:"#c6c6c6"},{name:"90% white",rgb:"#e2e2e2"},{name:"White",rgb:"#ffffff"}]},86758:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.labsAreGreyscale=t.isLab=void 0;const n=i(19851),r=i(31586),s=i(50213),a=i(82647),o=i(28874),l=i(85810),u=(0,n.lazy)((()=>(0,s.mkLogger)("color.Lab")));t.isLab=function(e){return Array.isArray(e)&&3===e.length&&(0,r.within)(0,100,e[0])&&(0,r.within)(-110,110,e[1])&&(0,r.within)(-110,110,e[2])},t.labsAreGreyscale=function(e){const t=o.Settings.greyscaleColorThreshold.valueOrDefault,i=new a.Average,n=new a.Average;for(const t of e){const e=(0,l.clampLab)(t);i.push(e[1]),n.push(e[2])}const r=(i.stdDev??0)+(n.stdDev??0),s=r{Object.defineProperty(t,"__esModule",{value:!0}),t.LightWikipediaColors=void 0,t.LightWikipediaColors=[{name:"Beige",rgb:"#F5F5DC"},{name:"Laurel green",rgb:"#A9BA9D"},{name:"Light sage",rgb:"#93A58B"},{name:"Light green-cyan",rgb:"#CFEADE"},{name:"Pastel purple",rgb:"#B39EB5"},{name:"Pewter blue",rgb:"#8BA8B7"},{name:"Powder blue",rgb:"#B0E0E6"},{name:"Vanilla",rgb:"#F3E5AB"}]},42022:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ModeBits=void 0,t.ModeBits=12},1971:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ModeCount=void 0,t.ModeCount=7},85434:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.omitModeData=t.pickModeData=t.ModeDataKeys=t.isModeData=void 0;const n=i(31586),r=i(68708),s=i(50989);t.isModeData=function(e){return(0,n.gt0)(e.mode0)&&(0,n.gt0)(e.mode0pct)},t.ModeDataKeys=(0,s.strEnum)("mode0","mode0pct","mode1","mode1pct","mode2","mode2pct","mode3","mode3pct","mode4","mode4pct","mode5","mode5pct","mode6","mode6pct"),t.pickModeData=function(e){return(0,r.pick)(e,...t.ModeDataKeys.values)},t.omitModeData=function(e){return(0,r.omit)(e,...t.ModeDataKeys.values)}},85042:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clampRGB=t.rgbTriplet2hex=t.rgbhex2triplet=t.normalizeRgbHex=void 0;const n=i(31586),r=i(39926),s=i(51926),a=i(54993),o=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i;function l(e){return[e[0],e[1],e[2]].map((e=>(0,n.clamp)(0,255,Math.round(e))))}t.normalizeRgbHex=function(e){const t=(0,a.toS)(e).trim();return o.test(t)?(0,s.ensurePrefix)(t,"#").toUpperCase():void 0},t.rgbhex2triplet=function(e){const t=(0,a.toS)(e).trim().match(o);if(null!=t)try{return[t[1],t[2],t[3]].map((e=>(0,n.clamp)(0,255,parseInt(e,16))))}catch{return}},t.rgbTriplet2hex=function(e){return"#"+l(e).map((e=>(0,r.leftPad)(Math.round(e).toString(16).toUpperCase(),2,"0"))).join("")},t.clampRGB=l},76596:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const n=i(51168),r=i(19851),s=i(22573),a=i(42659),o=i(55835),l=i(31586),u=i(68708),c=i(34666),d=i(50213),h=(0,r.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,i){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=i}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const i=(0,o.mapOr)(e,(e=>e.getTime()),(()=>0)),n=(0,o.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(i,n)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),i=Date.now();return t<=i?0:t-i},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,a.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){Object.defineProperty(t,"__esModule",{value:!0}),t.DateInterval=void 0;const n=i(77988),r=i(19851),s=i(55835),a=i(31586),o=i(54993),l=i(68852),u=i(79842),c=i(98247),d=(0,r.lazy)((()=>(0,l.concatRegexp)([/^/,/(?\d{2,}[-+\dTZ:.,]+?)/i,/(?:--|\/)/,/(?\d{2}[-+\dTZ:.,]+)/,l.RegExpOptional.from(/\/(?\d+)\/(?\d+)/),/$/]))),h=["year","month","day","hour","minute","second","millisecond"];class f{static fromISO(e,t){const i=d().exec((0,o.toS)(e).trim()),n=i?.groups;return null==n?void 0:f.for((0,c.parseExifDateTime)(n.start,t),(0,c.parseExifDateTime)(n.end,t),(0,a.toInt)(n.index),(0,a.toInt)(n.splits))}toJSON(){return{_ctor:"DateInterval",start:this.start?.toJSON(),end:this.end?.toJSON(),index:this.index,splits:this.splits}}static fromJSON(e){return this.for((0,s.map)(e.start,(e=>n.ExifDateTime.fromJSON(e))),(0,s.map)(e.end,(e=>n.ExifDateTime.fromJSON(e))),e.index,e.splits)}static for(e,t,i=0,n=1){if(null==e||!e.isValid||null==t||!t.isValid)return;n=(0,a.clamp)(1,1e3,(0,a.toInt)(n,{defaultValue:1})),i=(0,a.clamp)(0,n-1,(0,a.toInt)(i,{defaultValue:0})),e.hasZone&&!t.hasZone&&null!=e.zone?t=t.setZone(e.zone)??t:!e.hasZone&&t.hasZone&&null!=t.zone&&(e=e.setZone(t.zone)??e);const r=e.toMillis(),s=(t.toMillis()-r)/(n+1)*(i+1),o=e.plus({milliseconds:s});return null==o?void 0:new f(e,o,t,i,n)}constructor(e,t,i,n=0,r=1){this.start=e,this.middle=t,this.end=i,this.index=n,this.splits=r,[this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond]=h.map((n=>function({start:e,end:t,middle:i,field:n}){return null!=e[n]&&null!=t[n]?i[n]:void 0}({start:e,middle:t,end:i,field:n})))}get intervalMs(){return this.end.toMillis()-this.start.toMillis()}get precisionMs(){return Math.max((0,u.datedToPrecisionMs)(this.end),(0,u.datedToPrecisionMs)(this.start))}toDate(){return this.middle.toDate()}toMillis(){return this.middle.toMillis()}get isValid(){return!0}get zone(){return this.start.zone??this.end.zone}get hasZone(){return this.start.hasZone||this.end.hasZone}toString(e={}){const t=[this.start.toISOString({includeOffset:this.start.hasZone,...e}),this.end.toISOString({includeOffset:this.end.hasZone,...e})];return 0===this.index&&1===this.splits||t.push(this.index.toString(),this.splits.toString()),t.join("/")}toISOString(e={}){return this.toString(e)}overlaps(e){return!0===(0,u.datedOverlap)({a:this,b:e})}setZone(e,t){return new f(this.start.setZone(e,t)??this.start,this.middle.setZone(e,t)??this.middle,this.end.setZone(e,t)??this.end,this.index,this.splits)}}t.DateInterval=f},79842:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.datedToJson=t.isoToDated=t.datedOverlap=t.isoToPrecisionMs=t.datedToPrecisionMs=t.datedToDateTime=t.datedToStartDateTime=t.datedToEndTs=t.datedToStartTs=t.toDate=t.mapDated=t.toDated=t.isDated=void 0;const n=i(77988),r=i(51168),s=i(19851),a=i(76790),o=i(22573),l=i(42659),u=i(55835),c=i(31586),d=i(68708),h=i(51926),f=i(50213),m=i(76596),p=i(24689),g=i(66649),y=i(98247),v=i(21330),w=i(928),S=i(54261),b=i(73389),P=i(51275),M=(0,s.lazy)((()=>(0,f.mkLogger)("date.Dated")));function _(e){return null!=e&&(e instanceof v.FuzzyDate||e instanceof n.ExifDate||e instanceof n.ExifDateTime||e instanceof Date||e instanceof p.DateInterval||(0,b.isDateTime)(e)||(0,m.isDateObject)(e))}function E(e){return null==e?void 0:e instanceof p.DateInterval?e.start.toMillis():e instanceof n.ExifDate?e.toMillis(0):(0,g.datedToMillis)(e)}function x(e){if(null!=e)return e instanceof p.DateInterval?e.end.toMillis():e instanceof n.ExifDate?e.toMillis(l.dayMs):e instanceof v.FuzzyDate?e.following().toMillis()-1:(0,c.map2Numeric)((0,g.datedToMillis)(e),D(e),((e,t)=>e+t))}function T(e){try{if(null==e||(0,h.isString)(e)||(0,c.isNumber)(e))return;return(0,b.isDateTime)(e)?e:e instanceof n.ExifDateTime||e instanceof v.FuzzyDate?e.toDateTime():e instanceof p.DateInterval?e.middle.toDateTime():e instanceof Date?r.DateTime.fromJSDate(e):(0,y.dateObjectToExifDateTime)(e)?.toDateTime()}catch(t){return void M().warn("datedToDateTime() failed",{d:e,error:t})}}function D(e){if(e instanceof p.DateInterval)return e.precisionMs;if((0,S.hasTime)(e)){if((0,c.gt0)((0,w.getMillisecond)(e)))return 0;if((0,c.gt0)((0,w.getSecond)(e)))return l.secondMs-1;if((0,c.gt0)((0,w.getMinute)(e)))return l.minuteMs-1;if((0,c.gt0)((0,w.getHour)(e)))return l.hourMs-1}return(0,c.gt0)((0,w.getDay)(e))?l.dayMs-1:(0,c.gt0)((0,w.getMonth)(e))?l.monthMs-1:l.yearMs-1}function k(e,t){const i=E(e),n=x(e);if(null!=i&&null!=n)return(0,c.gt0)(t)&&t>n-i?{start:Math.round((i+n)/2-t/2),end:Math.round((i+n)/2+t/2)}:{start:i,end:n}}function C(e,t,i,n){const[r,s]=(0,a.sortBy)([k(e,i),k(t,n)],(e=>e?.start));return null!=r&&null!=s&&null!=r&&null!=s&&(r.start===s.start||r.end>=Math.min(s.start,s.end))}function F(e,t){return(0,o.blank)(e)?void 0:p.DateInterval.fromISO(e,t)??(0,y.parseExifDateTime)(e,t)??v.FuzzyDate.fromISO(e)}t.isDated=_,t.toDated=function(e){return _(e)?e:void 0},t.mapDated=function(e,t){return _(e)?t(e):void 0},t.toDate=function(e){if(null!=e)return"number"==typeof e?new Date(e):e instanceof Date?e:(0,d.maybeCall)(e,"toJSDate")??(0,d.maybeCall)(e,"toDate")},t.datedToStartTs=E,t.datedToEndTs=x,t.datedToStartDateTime=function(e){return e instanceof p.DateInterval?e.start.toDateTime():e instanceof n.ExifDate?r.DateTime.fromObject(e):T(e)},t.datedToDateTime=T,t.datedToPrecisionMs=D,t.isoToPrecisionMs=function(e){return(0,u.map)(F(e),D)},t.datedOverlap=function({a:e,b:t,aPrecisionMs:i,bPrecisionMs:n}){if(null==e||null==t)return!1;if(i??(i=D(e)),n??(n=D(t)),C(e,t,i,n))return!0;const r=(0,P.getZoneName)(e),s=(0,P.getZoneName)(t);return null==r&&null!=s&&(e=(0,v.setZone)(e,s)??e),null==s&&null!=r&&(t=(0,v.setZone)(t,r)??t),C(e,t,i,n)},t.isoToDated=F,t.datedToJson=function(e){const t=e.toJSON?.();return null!=t?t:e instanceof r.DateTime?{...e.toObject(),zone:e.zoneName}:e}},66649:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.datedToMillis=void 0;const n=i(31586),r=i(81168);t.datedToMillis=function(e){if(null!=e&&!(0,r.isString)(e))return(0,n.isNumber)(e)?e:e instanceof Date?e.getTime():e.toMillis?.()}},4328:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const n=i(22573),r=i(31586),s=i(54557),a=i(91655),o=new s.FifoCache(512);function l(e){return(0,r.isNumber)(e)?e:(0,n.blank)(e)?void 0:o.getOrSet(e,(()=>(0,a.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,n.blank)(e)?void 0:u.getOrSet(e,(()=>(0,a.fmtFullDuration)((0,r.isNumber)(e)?e:l(e))))}},91655:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const n=i(51168),r=i(40958),s=i(22573),a=i(42659),o=i(31586),l=i(51926),u=i(68852),c=i(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,o.isNumber)(e))return;if((0,o.isNumber)(e))return e;if((0,o.isDigits)(e))return(0,o.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=n.Duration.fromISO(e);if(t.isValid)return t.toMillis();const i=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(i,e);if(0===d.length)return;const h=(0,r.compact)(d.map((e=>function(e,t){const i=(0,o.toFloat)(e);if(null!=i){if((0,s.blank)(t))return i;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*a.yearMs;case"weeks":case"week":case"w":return i*a.weekMs;case"days":case"day":case"d":return i*a.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return i*a.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return i*a.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return i*a.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return i;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,o.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:a.yearMs,s:"y"},{ms:a.weekMs,s:"w"},{ms:a.dayMs,s:"d"},{ms:a.hourMs,s:"h"},{ms:a.minuteMs,s:"m"},{ms:a.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,i=""){if(!(0,o.isNumber)(t))return;if(0===t)return"0";if(!(0,o.gte0)(t))return(0,o.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const n=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const i=Math.floor(t/e.ms);t-=i*e.ms,i>0&&n.push(i+e.s)}return n.join(i)}},98247:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToExifDateTime=t.parseExifDateTimeRe=t.parseExifDateTime=t.parseExifDateTimeFromRFC2822=t.parseExifDateTimeFormat=t.concatDateTime=t.UnsetZone=void 0;const n=i(77988),r=i(51168),s=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(54993),d=i(88158),h=i(68852),f=i(28874),m=i(21330),p=i(98725),g=i(54261),y=i(17415);function v(e,t,i){const n=t.exec(e);if(null==n||(0,u.isEmptyObj)(n.groups))return;const{year:r,month:s,day:a,hour:c,minute:h,second:p}=(0,d.mapEntries)(n.groups,((e,t)=>(0,l.toInt)(t)));if(null==r||null==s||null==a)return;if(!f.Settings.fuzzyDateParsing.valueOrDefault&&(null==c||null==h))return;const g=(0,o.map)((0,l.toFloat)(n.groups.subsec),(e=>(0,l.within)(0,1,e)?Math.round(1e3*e):void 0)),v=(0,y.timezoneOffsetFromRegExpMatch)(n);return b({year:r,month:s,day:a,hour:c??0,minute:h??0,second:p??0,millisecond:g,zone:(0,m.zoneOffsetToName)(v)??i,rawValue:e,tzoffsetMinutes:v})}t.UnsetZone=r.Info.normalizeZone(n.UnsetZoneOffsetMinutes),t.concatDateTime=function(e,t){if(!(e instanceof n.ExifDate&&t instanceof n.ExifTime))return;const i=new n.ExifDateTime(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,void 0,e.rawValue+" "+t.rawValue,t.zone,t.inferredZone);return i.isValid?i:void 0},t.parseExifDateTimeFormat=function({input:e,format:i,defaultZone:s}){return(0,a.blank)(e)?void 0:n.ExifDateTime.fromDateTime(r.DateTime.fromFormat(e,i,{zone:s??t.UnsetZone,setZone:!0}),{rawValue:e,unsetMilliseconds:!0})},t.parseExifDateTimeFromRFC2822=function(e){return(0,a.blank)(e)?void 0:n.ExifDateTime.fromDateTime(r.DateTime.fromRFC2822(e,{zone:t.UnsetZone,setZone:!0}))},t.parseExifDateTime=function(e,t){return(0,a.blank)(e)?void 0:n.ExifDateTime.from(e,t)??v(e,S(),t)},t.parseExifDateTimeRe=v;const w=/[-:_\s]?/,S=(0,s.lazy)((()=>(0,h.concatRegexp)([p.nonNumericLookbackRE,p.yearRE,w,p.monthRE,w,p.dayRE,/[T\s]/,p.hourRE,w,p.minuteRE,w,p.secondRE,p.subsecRE,/\s?/,h.RegExpOptional.from((0,y.TimezoneOffsetRE)())])));function b(e){if(null!=e&&(0,g.hasTime)(e)){if(e instanceof n.ExifDateTime&&e.isValid)return e;try{const t=e.tzoffsetMinutes??(0,y.zoneToTzOffsetMinutes)(new Date(e.year,e.month-1,e.day).getTime(),e.zone),i=n.ExifDateTime.fromJSON({...e,tzoffsetMinutes:t,zoneName:(0,o.map)(e.zone,c.toS)});return i.isValid?i:void 0}catch{return}}}t.dateObjectToExifDateTime=b},74417:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseJsonDateToMillis=t.fmtDateShort=t.shortDateTimeFormat=t.isoToDateTime=t.fmtDateTime=t.recent=void 0;const n=i(51168),r=i(22573),s=i(42659),a=i(49769),o=i(31586),l=i(68708),u=i(81168),c=i(76596),d=i(24689),h=i(66649),f=i(98725),m=i(88600);t.recent=function(e,t=5*s.secondMs){return(0,c.isRecentMs)((0,h.datedToMillis)(e),t)},t.fmtDateTime=function(e,t,i=n.DateTime.DATETIME_MED){return(0,m.mapValidDate)(e,(e=>((0,r.mapNotBlank)(t,(t=>e=e.setLocale(t))),e.toLocaleString(i))))};const p=/(\.\d\d\d)\d+/;t.isoToDateTime=function(e){if((0,r.blank)(e))return;if(e.includes("/")){const t=d.DateInterval.fromISO(e)?.middle.toDateTime();if(null!=t)return t}const t=n.DateTime.fromISO(e.replace(p,((e,t)=>t)),{setZone:!0});return t.isValid?t:void 0};const g=new Map;function y(e="en-US"){return(0,a.getOrSet)(g,e,(()=>new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric"})))}t.shortDateTimeFormat=y,t.fmtDateShort=function(e,t="en-US"){return y(t).format((0,h.datedToMillis)(e))},t.parseJsonDateToMillis=function(e){if(null==e)return;const t=(0,u.isString)(e)?e:e.formatted;return((0,l.isObject)(e)&&(0,o.isNumber)(e.timestamp)?(0,m.toValidMillis)(e.timestamp*s.secondMs):void 0)??(0,f.parseDateTime)(t)?.toMillis()}},21330:function(e,t,i){var n,r=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.utcToZone=t.toIsoDate=t.setZone=t.dateBetween=t.gtDated=t.closeTo=t.diffMillis=t.sameDay=t.toFuzzyDate=t.datedToYMD=t.datedToEXIF=t.datedToISO=t.datedToOffsetMinutes=t.toExifDateTime=t.zoneOffsetToName=t.clearIgnorableSubpaths=t.addIgnorableSubpath=t.ignorableSubpaths=t.FuzzyDate=void 0;const s=i(77988),a=i(51168),o=i(57975),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(31586),f=i(68708),m=i(39926),p=i(19851),g=i(28874),y=i(24689),v=i(79842),w=i(66649),S=i(98247),b=i(98725),P=i(928),M=i(54261),_=i(73389),E=i(89724),x=i(17415),T=i(88600),D=i(51275);function k(e,t=2){return null==e?"":(0,m.leftPad)(e,t,"0")}class C{constructor(e,t,i){this.year=e,this.month=t,this.day=i,n.set(this,(0,p.lazy)((()=>(0,T.whyNotValidDate)(this.toDateTime()))))}static fromISO(e){if(!(0,u.blank)(e))return this.for(b.ISO_YMD_RE.exec(e)?.groups??b.ISO_YMD_LAX_RE.exec(e)?.groups)}toJSON(){return{_ctor:"FuzzyDate",...this}}static fromJSON(e){return this.for(e)}static for(e){const t=(0,h.toGt0)(e?.year);if(null==e||null==t||tk(e))).join("-")}toLocal(){return(0,E.datedToLocal)(this)}toDateTime(){return a.DateTime.fromObject((0,f.pick)(this,"year","month","day"))}toDate(){return this.toDateTime().toJSDate()}toMillis(){return this.toDateTime().toMillis()}following(){const e=this.toDateTime(),t=null!=this.day?(0,f.pick)(e.plus({day:1}),"year","month","day"):null!=this.month?(0,f.pick)(e.plus({month:1}),"year","month"):(0,f.pick)(e.plus({year:1}),"year");return new C(t.year,t.month,t.day)}}function F(e,t){if(e instanceof s.ExifDateTime&&(null==t||e.zone===t))return e;if(null==e||!(0,M.hasTime)(e))return;const i=(0,u.mapNotBlank)(t,(t=>(0,x.zoneToTzOffsetMinutes)((0,w.datedToMillis)(e),t)));return null==t||null!=i?(0,d.map)((0,P.getYear)(e),(n=>(0,d.map)((0,P.getMonth)(e),(r=>(0,d.map)((0,P.getDay)(e),(s=>(0,d.map)((0,P.getHour)(e),(a=>(0,S.dateObjectToExifDateTime)({year:n,month:r,day:s,hour:a,minute:(0,P.getMinute)(e)??0,second:(0,P.getSecond)(e)??0,millisecond:(0,P.getMillisecond)(e),tzoffsetMinutes:i,rawValue:e.rawValue,zone:t}))))))))):void 0}t.FuzzyDate=C,t.ignorableSubpaths=[],t.addIgnorableSubpath=function(e){t.ignorableSubpaths.push(e)},t.clearIgnorableSubpaths=function(){t.ignorableSubpaths.length=0},t.zoneOffsetToName=function(e,t=!0){if(null==e)return;if(0===e)return t?"UTC":"";const i=e<0?"-":"+",n=15*(0,h.round)(e/15),r=Math.abs(n),s=Math.floor(r/60),a=Math.floor(Math.abs(r%60));return`${t?"UTC":""}${i}${k(s)}:${k(a)}`},t.toExifDateTime=F,t.datedToOffsetMinutes=function(e){return(0,d.map)(e,(e=>e instanceof s.ExifDateTime?e.tzoffsetMinutes:(0,_.isDateTime)(e)?e.offset:void 0))},t.datedToISO=function(e,t,i){return null==e?void 0:e instanceof y.DateInterval?e.toString({includeOffset:t}):!(0,M.hasTime)(e)||(i??(0,v.datedToPrecisionMs)(e))>=c.dayMs?L(e):F(e,(0,D.getZoneName)(e))?.toISOString({includeOffset:t})};const O="yyyy:MM:dd HH:mm:ss.SSS",I=O+"ZZ";function L(e,t="-"){return(0,l.compact)([(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)]).map((e=>k(e))).join(t)}function A(e){return(0,d.map)(e,(e=>(0,d.map)((0,P.getYear)(e),(t=>new C(t,(0,P.getMonth)(e),(0,P.getDay)(e))))))}function R(e,t){const[i,n]=[e,t].map(w.datedToMillis);return null==i||null==n?void 0:i-n}t.datedToEXIF=function e(t){if(null==t)return;if(t instanceof y.DateInterval)return e(t.middle);const i=(0,h.isNumber)(t)?a.DateTime.fromMillis(t):(0,v.datedToDateTime)(t);return null!=i&&i.isValid?i.toFormat((0,D.hasZone)(t)?I:O):void 0},t.datedToYMD=L,t.toFuzzyDate=A,t.sameDay=function(e,t){return(0,h.lte)(R(e,t),c.dayMs)},t.diffMillis=R,t.closeTo=function(e,t,i){return(0,d.mapOr)(R(e,t),(e=>Math.abs(e)!1))},t.gtDated=function(e,t){if(null==e||null==t)return!1;for(const i of[P.getYear,P.getMonth,P.getDay,P.getHour,P.getMinute,P.getSecond,P.getMillisecond])if((0,h.lte)(i(e),i(t)))return!1;return!0},t.dateBetween=function(e,t,i=1,n=1){if(null==(0,w.datedToMillis)(e)||null==(0,w.datedToMillis)(t))return;const[r,s]=[e,t].map((e=>(0,w.datedToMillis)(e))).sort(),o=(s-r)/(n+1),l=(0,D.getZoneName)(e),u=l===(0,D.getZoneName)(t)?l:void 0,c=a.DateTime.fromMillis(r+o*i,{zone:u});return[e,t].some((e=>!(0,M.hasTime)(e)))?A(c):c},t.setZone=function(e,t,i){const n={...(0,f.compactValues)(i),keepLocalTime:i?.keepLocalTime??!(0,D.hasZone)(e)},r=(0,x.normalizeZone)(t);if(null!=e&&null!=r&&(0,M.hasTime)(e))return e instanceof y.DateInterval?e.setZone(r,n):F(e)?.setZone(r,n)},t.toIsoDate=function(e){if(null==e)return;const t=[(0,P.getYear)(e),(0,P.getMonth)(e),(0,P.getDay)(e)];return(0,h.gt0)(t[0])?(0,l.compact)(t).map(m.pad2).join("-"):void 0},t.utcToZone=function(e,t){let i=(0,v.datedToDateTime)(e);if(null==i)return;const n=(0,D.getZoneName)(e);return null!=n&&"UTC"!==n||(i=i.toUTC(0,{keepLocalTime:!0})),i.setZone(t)}},98725:function(e,t,i){var n,r,s,a=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FuzzyDateParser=t.parseDated=t.parseDateTime=t.ISO_YMD_LAX_RE=t.ISO_YMD_RE=t.agoMs=t.dateTimeBetween=t.subsecRE=t.optSeps=t.seps=t.secondRE=t.minuteRE=t.hourRE=t.dayishRE=t.dayRE=t.monthishRE=t.monthRE=t.yearishRE=t.yearRE=t.nonNumericLookbackRE=t.parseFuzzyDate=t.parseYMD=t.extractDateFromPath=void 0;const o=i(77988),l=i(51168),u=i(19851),c=i(40958),d=i(22573),h=i(49769),f=i(31586),m=i(51926),p=i(59455),g=i(48884),y=i(50213),v=i(68852),w=i(4001),S=i(28874),b=i(24689),P=i(79842),M=i(66649),_=i(98247),E=i(21330),x=i(54261),T=i(73389),D=i(16400),k=i(88600),C=(0,u.lazy)((()=>(0,y.mkLogger)("date.FuzzyDateParser")));t.extractDateFromPath=function(e){return C().tap({msg:"extractDateFromPath",result:L.instance().extractDateFromPath(e),meta:{path:e}})},t.parseYMD=function(e){return L.instance().parseYMD(e)},t.parseFuzzyDate=function(e){return L.instance().parse(e)},t.nonNumericLookbackRE=/(?(?:19|20)\d{2})/,t.yearishRE=/(?(?:19|20)?\d{2})/,t.monthRE=/(?[0-3]\d)/,t.monthishRE=/(?[0-3]?\d)/,t.dayRE=/(?[1-3]\d|0[1-9])/,t.dayishRE=/(?[1-3]\d|0?[1-9])/,t.hourRE=/(?1\d|2[0-3]|0\d)/,t.minuteRE=/(?[0-5]\d)/,t.secondRE=/(?[0-5]\d)/,t.seps=/([-.,:_/ |])/,t.optSeps=new RegExp(t.seps.source+"?"),t.subsecRE=/(?\.\d+)?/,t.dateTimeBetween=function(e,t){return e.until(t).divideEqually(2)[0].end},t.agoMs=function(e){return(0,f.mapNumeric)((0,M.datedToMillis)(e),(e=>Date.now()-e))},t.ISO_YMD_RE=(0,v.concatRegexp)([/^/,t.yearRE,v.RegExpOptional.from(/-/,t.monthRE,v.RegExpOptional.from(/-/,t.dayRE)),/$/]),t.ISO_YMD_LAX_RE=(0,v.concatRegexp)([/^/,t.yearishRE,v.RegExpOptional.from(/-/,t.monthishRE,v.RegExpOptional.from(/-/,t.dayishRE)),/$/]),t.parseDateTime=function(e,t){const i=I({input:e,defaultZone:t,descPredicate:e=>null!=e.match(/DateTime/i)});return(0,T.isDateTime)(i)?i:(0,x.isExifDateTime)(i)?i.toDateTime():void 0};const F=new Map;function O(e,t,i){try{const n=(0,_.parseExifDateTimeFormat)({input:e,format:t,defaultZone:i});if(null!=n)return n;const r=(0,h.getOrSet)(F,t,(()=>{const e=l.DateTime.fromFormatExplain(l.DateTime.now().toFormat(t),t);if(!(e.regex instanceof RegExp))return void C().warn("extractDateTime() failed to parse format",{format:t});const i=(0,m.stripPrefixSuffix)(e.regex.source,{prefix:"^",suffix:"$"});return new RegExp(i,"i")}));return(0,_.parseExifDateTimeFormat)({input:r?.exec(e)?.[0],format:t,defaultZone:i})}catch(i){return void C().debug("unexpected error thrown from extractDateTime()",{input:e,format:t,error:i})}}function I({input:e,defaultZone:t,includeDate:i=!0,includeFuzzyDate:n=!0,descPredicate:r=(()=>!0)}){if(null==e)return;if((0,P.isDated)(e))return e;const s=(0,c.uniq)((0,c.compactBlanks)((0,p.toA)(e)).map(w.stripDSC));if(0!==s.length)for(const{desc:e,f:a}of function*(e){yield{desc:"DateInterval.fromISO",f:e=>b.DateInterval.fromISO(e)},yield{desc:"parseExifDateTime",f:t=>(0,_.parseExifDateTime)(t,e.defaultZone)},yield{desc:"ExifDateTime.fromRFC2822",f:_.parseExifDateTimeFromRFC2822};for(const t of(0,c.uniq)([...(0,c.compactBlanks)(S.Settings.extraDateTimeZoneSuffixes.values),""]))for(const i of(0,c.compactBlanks)(S.Settings.extraDateTimeFormats.values)){const n=(0,d.blank)(t)?i:i+" "+t;yield{desc:`extractDateTime(${n})`,f:i=>O(i,n,(0,d.blank)(t)?e.defaultZone:void 0)}}if(!0===e.includeDate&&(yield{desc:"ExifDate.fromEXIF",f:e=>o.ExifDate.fromEXIF(e)}),!0===e.includeFuzzyDate)for(const e of L.instance().allParsers)yield{desc:"FuzzyDateParser "+e.source,f:t=>e.apply(t)}}({defaultZone:t,includeDate:i,includeFuzzyDate:n}))if(r(e))for(const e of s){const t=a(e);if(null!=t&&(0,k.isValidDate)(t))return t}}t.parseDated=I;class L{constructor(e={}){n.add(this),this.opts=e,this.ymdParsers=[],this.ymParsers=[],this.yParsers=[],this.allParsers=[],null==e.fuzzyDateParsing&&S.Settings.fuzzyDateParsing.watchLater((()=>a(this,n,"m",s).call(this))),null==e.fuzzyYearParsing&&S.Settings.fuzzyYearParsing.watchLater((()=>a(this,n,"m",s).call(this))),a(this,n,"m",s).call(this)}get fuzzyDateParsing(){return this.opts.fuzzyDateParsing??S.Settings.fuzzyDateParsing.valueOrDefault}get fuzzyYearParsing(){return this.opts.fuzzyYearParsing??S.Settings.fuzzyYearParsing.valueOrDefault}parse(e,t=this.allParsers){for(const i of t){const t=i.apply(e);if(null!=t)return t}}parseYMD(e){return this.parse(e,this.ymdParsers)}parseYM(e){return this.parse(e,this.ymParsers)}parseY(e){return this.parse(e,this.yParsers)}extractDateFromPath(e){if(!S.Settings.usePathsToInferDates.valueOrDefault)return;E.ignorableSubpaths.forEach((t=>{(0,c.startsWith)(e,t)&&e.splice(0,t.length)})),e=e.filter((t=>(0,d.notBlank)(t)&&null==e[0].match(R)));const t=[...e].reverse();for(const e of t){const t=I({input:e,includeDate:!1,includeFuzzyDate:!1})??this.parseYMD(e);if(null!=t)return t}return this.parseYMD(t.slice(1,4).join(" "))??this.parseYMD(e.slice(0,-1).join(" "))??(0,g.first)(t,(e=>this.parseYM(e)))??this.parseYM(e.join(" "))??(0,g.first)(t.slice(1),(e=>this.parseY(e)))}}t.FuzzyDateParser=L,n=new WeakSet,r=function(e){const t=new A(e);t.hasDay?this.ymdParsers.push(t):t.hasMonth?this.fuzzyDateParsing&&this.ymParsers.push(t):this.fuzzyYearParsing&&this.yParsers.push(t)},s=function(){try{this.ymdParsers.length=0,this.ymParsers.length=0,this.yParsers.length=0,this.allParsers.length=0;const e=new v.RegExpEscaped("(?"+(0,D.monthNames)().map(v.escapeRegExp).join("|")+")");a(this,n,"m",r).call(this,[t.yearRE,t.seps,t.monthishRE,/\2/,t.dayishRE]),a(this,n,"m",r).call(this,[t.yearRE,t.optSeps,t.monthRE,/\2/,t.dayRE]),a(this,n,"m",r).call(this,[t.yearRE,t.optSeps,e,/\2/,t.dayishRE]),a(this,n,"m",r).call(this,[e,t.optSeps,t.dayishRE,/,?\2/,t.yearRE]),a(this,n,"m",r).call(this,[t.nonNumericLookbackRE,t.dayishRE,t.optSeps,e,/,?\2/,t.yearRE]),a(this,n,"m",r).call(this,[/^(?\d\d\d\d):(? {2}|\d\d):(? {2}|\d\d)( ( {2}|00):( {2}|00):( {2}|00))?$/]),a(this,n,"m",r).call(this,[t.yearRE,t.seps,t.monthishRE]),a(this,n,"m",r).call(this,[e,t.seps,t.yearRE]),a(this,n,"m",r).call(this,[t.yearRE,t.seps,e]),a(this,n,"m",r).call(this,[t.nonNumericLookbackRE,t.yearRE]),this.allParsers.push(...this.ymdParsers,...this.ymParsers,...this.yParsers)}catch(e){console.error(e)}},L.instance=(0,u.lazy)((()=>new L));class A{constructor(e){this.regex=e instanceof RegExp?e:(0,v.concatRegexp)([...e,/(?:$|\D)/],"i")}get source(){return this.regex.source}get hasDay(){return this.source.includes("(?")}get hasMonth(){return this.source.includes("(?")||this.source.includes("(?")}apply(e){const t=this.regex.exec(e)?.groups;if(null!=t)return E.FuzzyDate.for({year:(0,f.toInt)(t.year),month:(0,f.toInt)(t.month)??(0,D.monthName2index)(t.monthname),day:(0,f.toInt)(t.day)})}}const R=/^((DCIM)|(DSC[_F]?|IMG[-_]|GOPRO|MOV[-_]|MVI[-_]|P_?)\d+)$/i},928:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSecMs=t.hasSeconds=t.getCentisecond=t.getMillisecond=t.getSecond=t.getMinute=t.getHour=t.getDay=t.getMonth=t.getYear=void 0;const n=i(55835),r=i(31586),s=i(54261);function a(e){return e instanceof Date?e.getMinutes():e?.minute}function o(e){return e instanceof Date?e.getSeconds():e?.second}function l(e){return e instanceof Date?e.getMilliseconds():e?.millisecond}t.getYear=function(e){return e instanceof Date?e.getFullYear():e?.year},t.getMonth=function(e){return e instanceof Date?e.getMonth()+1:e?.month},t.getDay=function(e){return e instanceof Date?e.getDate():e?.day},t.getHour=function(e){return e instanceof Date?e.getHours():e?.hour},t.getMinute=a,t.getSecond=o,t.getMillisecond=l,t.getCentisecond=function(e){return(0,n.map)(l(e),(e=>Math.floor(e/10)))},t.hasSeconds=function(e){return(0,s.hasTime)(e)&&((0,r.gt0)(a(e))||(0,r.gt0)(o(e))||(0,r.gt0)(l(e)))},t.getSecMs=function(e){return(0,n.map)(o(e),(t=>{const i=l(e)??0;let n=(t+i/1e3).toString();for(t<10&&(n="0"+n),0===i&&(n+=".");n.length<6;)n+="0";return n}))}},54261:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isExifDateTime=t.hasTime=void 0;const n=i(77988),r=i(31586),s=i(68708);t.hasTime=function(e){if(!(0,s.isObject)(e))return!1;if(e instanceof Date)return!0;const t=e;return(0,r.gt0)(t.hour)||(0,r.gt0)(t.minute)||(0,r.gt0)(t.second)||(0,r.gt0)(t.millisecond)},t.isExifDateTime=function(e){return e instanceof n.ExifDateTime}},73389:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDateTime=void 0;const n=i(51168);t.isDateTime=function(e){return n.DateTime.isDateTime(e)??!1}},89724:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.localPlusMs=t.tsToLocal=t.agoLocal=t.nowLocal=t.localToTs=t.localToDateTime=t.fmtLocalDateShort=t.localToDateObject=t.datedToLocalSec=t.datedToLocal=t.maybeDatedToLocal=t.isoToLocal=t.localIsFuzzy=void 0;const n=i(51168),r=i(19851),s=i(42659),a=i(55835),o=i(31586),l=i(28874),u=i(76596),c=i(79842),d=i(66649),h=i(74417),f=i(21330),m=i(928),p=i(54261),g=i(17415),y=(0,r.lazy)((()=>v(l.Settings.datesBeforeAreEstimated.valueOrDefault)??v(l.Settings.datesBeforeAreEstimated.defaultValue)));function v(e){return(0,a.map)((0,c.isoToDated)(e),w)}function w(e){return(0,o.isNumber)(e)?_(e):100*S(e)+((0,m.getCentisecond)(e)??0)}function S(e){if((0,o.isNumber)(e))return Math.floor(_(e)/100);let t=0;for(const i of[m.getYear,m.getMonth,m.getDay,m.getHour,m.getMinute,m.getSecond])t=100*t+(i(e)??0);return t}function b(e,t){if(null==e||e<0)return;let i=e;const n=()=>{const e=i%100;return i=Math.floor(i/100),e},r=10*n(),s=n(),a=n(),l=(0,o.toGt0)(n()),u=(0,o.toGt0)(n()),c=(0,o.toGt0)(n());return{year:i,month:c,day:u,hour:l,minute:a,second:s,millisecond:r,zone:(0,g.normalizeZone)(t)}}function P(e,t){const i=b(e,t);return(0,p.hasTime)(i)?(0,u.dateObjectToDateTime)(i):f.FuzzyDate.for(i)}function M(e,t){return _(Date.now()-e,t)}function _(e,t){return w(n.DateTime.fromMillis(e,{zone:t}))}t.localIsFuzzy=function(e){return null==e||e%1e6==0||e{Object.defineProperty(t,"__esModule",{value:!0}),t.monthNames=t.monthName2index=void 0;const n=i(19851),r=i(76790),s=i(31586),a=i(9092),o=(0,n.lazy)((()=>{const e=new a.CaseInsensitiveMap;for(const t of["en-US",void 0]){e.set("Sept",9),e.set("Sept.",9);for(const i of["short","long"]){const n=new Intl.DateTimeFormat(t,{month:i});(0,s.times)(12,(r=>{const s=n.format(new Date(2017,r));e.set(s,r+1),"short"===i&&"en-US"===t&&e.set(s+".",r+1)}))}}return e}));t.monthName2index=function(e){return null==e?void 0:o().get(e)},t.monthNames=function(){return(0,r.sort)([...o().keys()])}},17415:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.luxonTzOffsetToOffsetMinutes=t.ianaZoneToOffsetMinutes=t.timezoneOffsetFromRegExpMatch=t.isoToOffsetMinutes=t.TimezoneOffsetRE=t.zoneToExifOffsetMinutes=t.fmtOffsetMinutes=t.zoneToTzOffsetMinutes=t.zoneOffsetMinutes=t.normalizeZone=t.isUTCZone=t.isValidZone=t.normalizeZoneOffsetMinutes=t.offsetToMinutes=t.ValidTimezoneOffsets=t.MaxTzOffsetHours=void 0;const n=i(77988),r=i(51168),s=i(19851),a=i(22573),o=i(55835),l=i(31586),u=i(68708),c=i(39926),d=i(51926),h=i(54993),f=i(48884),m=i(68852);function p(e){const[t,i]=e.split(":").map(Number);return(e.startsWith("-")?-1:1)*(60*Math.abs(t)+i)}t.MaxTzOffsetHours=14,t.ValidTimezoneOffsets=["-12:00","-11:00","-10:30","-10:00","-09:30","-09:00","-08:30","-08:00","-07:30","-07:00","-06:00","-05:00","-04:30","-04:00","-03:30","-03:00","-02:30","-02:00","-01:00","-00:44","+00:00","+00:20","+00:30","+01:00","+01:24","+01:30","+02:00","+02:30","+03:00","+03:30","+04:00","+04:30","+04:51","+05:00","+05:30","+05:40","+05:45","+06:00","+06:30","+07:00","+07:20","+07:30","+08:00","+08:30","+08:45","+09:00","+09:30","+09:45","+10:00","+10:30","+11:00","+11:30","+12:00","+12:45","+13:00","+13:45","+14:00"],t.offsetToMinutes=p;const g=(0,s.lazy)((()=>t.ValidTimezoneOffsets.map(p)));function y(e,i=14){if(!(0,l.isNumber)(e)||Math.abs(e)>60*t.MaxTzOffsetHours)return;const n=(0,f.leastBy)(g(),(t=>Math.abs(t-e)));return null!=n&&Math.abs(n-e)=0?"+":"-")+(0,c.pad2)(i)+":"+(0,c.pad2)(n)}t.isUTCZone=function(e){return S(e)||0===b(e)?.offset(Date.now())},t.normalizeZone=b,t.zoneOffsetMinutes=function(e){return y(e.tzoffsetMinutes)??y(e.offset)??(0,o.map)(e.zone,(t=>t.offset(e.toMillis())))},t.zoneToTzOffsetMinutes=P,t.fmtOffsetMinutes=M,t.zoneToExifOffsetMinutes=function(e,t){const i=P(e,t);return null==i?void 0:M(i)};const _=/\b(?Z|UTC|GMT)\b/,E=/(?[-±+−])/,x=/[-−]/,T=/(?[01]\d)/,D=/(?[01]?\d)/,k=/(?::(?\d\d))/;function C(e){return S(e)?0:F((0,t.TimezoneOffsetRE)().exec(e))}function F(e){if(null==e||(0,u.isEmptyObj)(e.groups))return;if(!(0,a.blank)(e.groups.utc))return 0;const t=(0,l.toInt)(e.groups.tzHour),i=x.test((0,h.toS)(e.groups.tzSign))?-1:1,n=(0,l.toInt)(e.groups.tzMinutes)??0,r=null==t?void 0:i*(60*t+n);return v(r)?r:void 0}t.TimezoneOffsetRE=(0,s.lazy)((()=>(0,m.concatRegexp)([new m.RegExpEscaped("(?:"),_,new m.RegExpEscaped("|"),E,T,m.RegExpOptional.from(k),new m.RegExpEscaped(")"),/(?:$|[^-−+:_\d.T/])/]))),t.isoToOffsetMinutes=C,t.timezoneOffsetFromRegExpMatch=F;const O=/\b(?(?:Etc\/)?GMT)\b/,I=(0,s.lazy)((()=>(0,m.concatRegexp)([O,E,D,m.RegExpOptional.from(k)])));function L(e){return F(I().exec(e))}t.ianaZoneToOffsetMinutes=L,t.luxonTzOffsetToOffsetMinutes=function(e,t){if((0,a.blank)(e))return;const i=L(e)??C(e);if(null!=i)return M(i);if(null!=t){const i=b(e);if(null!=i)return M(i.offset(t))}}},88600:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validYMD=t.mapValidDate=t.whyNotValidDate=t.isValidDate=t.toValidMillis=void 0;const n=i(51168),r=i(19851),s=i(40958),a=i(22573),o=i(42659),l=i(31586),u=i(34666),c=i(50213),d=i(98314),h=i(28874),f=i(79842),m=i(66649),p=i(21330),g=i(928),y=i(89724),v=(0,r.lazy)((()=>(0,c.mkLogger)("date.ValidDate"))),w=(0,r.lazy)((()=>(0,s.compact)(h.Settings.badDates.values.map((e=>(0,f.isoToDated)(e)))))),S=(0,r.lazy)((()=>(0,s.compact)(w().map((e=>(0,p.datedToISO)(e)))))),b=(0,r.lazy)((()=>(0,s.compact)(w().map((e=>(0,y.datedToLocal)(e)))))),P=(0,r.lazy)((()=>(0,s.compact)(w().map((e=>(0,m.datedToMillis)(e))))));function M(e){if(null==e)return!1;const t=E(e);return v().tap({msg:"isValidDate()",result:null==t,meta:{d:e,why:t}})}t.toValidMillis=function(e){return M(e)?e:void 0},t.isValidDate=M;const _=String(new Date("bad"));function E(e){try{if(!(0,f.isDated)(e)&&!(0,l.isNumber)(e))return"not Dated";if(String(e)===_)return _;const t=(0,s.compact)([e.invalidExplanation]);if(0===t.length&&t.push(...function(e,t,i){const r=[];if((0,l.isNumber)(e)||r.push("year is not a number"),(0,l.lt)(e,h.Settings.minValidYear.valueOrDefault)&&r.push("year is less than "+h.Settings.minValidYear.key),(0,u.gt)(e,x())&&r.push("year is in the future"),null==t&&null!=i&&r.push("year and day is set but month is not"),((0,l.lt)(t,1)||(0,u.gt)(t,12))&&r.push("month is invalid"),null!=t&&((0,l.lt)(t,1)||(0,u.gt)(t,12))&&r.push("month is invalid"),(0,l.isNumber)(e)&&(0,l.isNumber)(t)&&(0,l.isNumber)(i)){const s=n.DateTime.fromObject({year:e,month:t,day:i});s.isValid||r.push(s.invalidExplanation??"not valid")}return(0,s.compact)(r)}((0,g.getYear)(e),(0,g.getMonth)(e),(0,g.getDay)(e))),e instanceof Date&&isNaN(e.getTime())&&t.push("not valid js Date"),0===t.length){const i=h.Settings.maxValidFutureMs.valueOrDefault;if((0,l.gt0)(i)){const n=(0,m.datedToMillis)(e);(0,u.gt)(n,Date.now()+i)&&t.push("date is too far in the future: see "+h.Settings.maxValidFutureMs.key)}}return P().includes((0,m.datedToMillis)(e))?t.push("bad date (via millis)"):b().includes((0,y.datedToLocal)(e))?t.push("bad date (via localtime)"):S().includes((0,p.datedToISO)(e))&&t.push("bad date (via ISO)"),(0,a.toNotBlank)((0,s.uniq)((0,s.compactBlanks)(t)).join("; "))}catch(t){return v().warn("whyNotValidDate() caught error",{input:e,error:t}),(0,d.errorToS)(t)}}t.whyNotValidDate=E;const x=(0,r.lazy)((()=>n.DateTime.now().plus({milliseconds:h.Settings.maxValidFutureMs.valueOrDefault}).year),o.dayMs);t.mapValidDate=function(e,t){return M(e)?t(e):void 0},t.validYMD=function(e,t,i){return null==E({year:e,month:t,day:i})}},51275:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getZoneName=t.hasZone=void 0;const n=i(77988),r=i(31586),s=i(24689),a=i(73389);t.hasZone=function(e){return null!=e&&!(0,r.isNumber)(e)&&(e instanceof s.DateInterval||e instanceof n.ExifDateTime?e.hasZone:!!(0,a.isDateTime)(e)&&null!=e.zone&&e.zone.isValid&&"local"!==e.zone.type&&e.zone.name!==n.UnsetZoneName&&e.zone.offset(Date.now())!==n.UnsetZoneOffsetMinutes)},t.getZoneName=function(e){return null==e||e instanceof Date?void 0:(0,a.isDateTime)(e)?e.zoneName===n.UnsetZoneName?void 0:e.zone?.name:e instanceof n.ExifDateTime?e.zone:void 0}},84248:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const n=i(50989);t.AutoVacuumModes=(0,n.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const n=i(50989);t.CheckpointTypes=(0,n.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const n=i(50989);t.RepairModes=(0,n.strEnum)("dump","recover")},15056:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dbBackupDir=t.pathToDb=t.pathToDbDir=t.Schemas=void 0;const n=i(50989),r=i(7311);function s(e,t){return e.join(t)}t.Schemas=(0,n.strEnum)("models"),t.pathToDbDir=s,t.pathToDb=function(e,t){return s(e,t).join(r.SqliteBase)},t.dbBackupDir=function(e){return e.sibling("backups")}},7311:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqliteBase=t.SqliteExt=void 0,t.SqliteExt=".sqlite3",t.SqliteBase="db"+t.SqliteExt},34365:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const n=i(50989);t.SynchronousModes=(0,n.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const a=s(i(76760)),o=i(40958),l=i(22573),u=i(55835),c=i(72993),d=i(19851),h=i(97352),f=i(94174),m=i(44198),p=i(96706),g=i(8769),y=i(57159),v=i(70698),w=i(64680),S=i(29882),b=i(45969),P=i(43334),M=i(28874),_=i(41692),E=i(32774),x=i(80612),T=i(32551),D=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function k(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+D(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const i of t)(0,l.blank)(i)||e.push({dir:(0,a.join)(i,".photostructure-cache"+D()),preexistingDir:i});return e}}function C(){if((0,b.isDocker)())return(0,o.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,a.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:E.DefaultDockerLibraryDir+"/.photostructure/cache"+D(),preexistingDir:E.DefaultDockerLibraryDir},...k()]);const e=(0,o.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),a.default.resolve((0,T.homeDir)(),"AppData","Local")]:P.isMac?[a.default.resolve((0,T.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,a.join)((0,T.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,i=e.map((e=>({dir:(0,a.join)(e,t),preexistingDir:e})));return i.push(...k()),i}t.tmpCacheDirs=k,t.tmpDirs=function(){return(0,x.filterDirs)({dirs:k(),desc:"tmp"})},t.cacheDirs=C,t.defaultCacheDir=(0,d.lazy)((()=>(0,x.firstDir)({dirs:C(),desc:"cache"})));const F=(0,d.lazy)((()=>{(0,_.setSettingsDefaults)(),M.Settings.cacheDir.watchLater(O)}));function O(){M.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{F();const e=M.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=O},46292:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const n=i(19851),r=i(45969),s=i(41692),a=i(32774),o=i(10924),l=i(84373),u=i(80612);t.configDir=(0,n.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,r.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,o.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:a.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:a.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,r.isDocker)()?c:(0,o.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const n=i(66430),r=i(45969),s=i(32774);t.defaultLibraryDir=function(){return(0,r.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,r.isDocker)()&&(0,n.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const r=n(i(76760)),s=i(40958),a=i(72993),o=i(44198),l=i(96706),u=i(43334),c=i(80612),d=i(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),r.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(r.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,o.env)().XDG_DATA_HOME,(0,o.env)().XDG_CONFIG_HOME,r.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:r.default.join(e,(0,a.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const n=i(22573),r=i(96706),s=i(29882);t.envConfigDir=function(){const e=(0,r.getEnv)("PS_CONFIG_DIR");if(!(0,n.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const n=i(44652),r=i(40958),s=i(22573),a=i(66430);function o({dirs:e,desc:t}){for(const{dir:i,preexistingDir:o}of(0,r.compact)(e))if(!(0,s.blank)(i)){if((0,a.isReadWriteableDirectorySync)(i))return i;if((0,s.blank)(o)||(0,a.isReadWriteableDirectorySync)(o))try{return(0,n.mkdirpSync)(i),i}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=o,t.filterDirs=function({dirs:e,desc:t}){return(0,r.compact)(e.map((e=>o({dirs:[e],desc:t}))))}},32551:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const n=i(48161),r=i(76760),s=i(1708),a=i(19851),o=i(40958),l=i(68284),u=i(43334);t.homeDir=(0,a.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,o.compactBlanks)(e)){const e=(0,r.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,n.homedir)()}))},35280:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.inHiddenPhotoStructureDir=void 0;const n=i(29882),r=i(49776),s=i(9595);t.inHiddenPhotoStructureDir=function(e){if((0,n.toPathnames)(e).some((e=>e.toLowerCase().startsWith(".photostructure"))))return!0;for(const t of[s.libraryDataDir,s.libraryPreviewsDir,r.cacheDir])if((0,n.containedByNativePath)({descendant:e,ancestor:t(),acceptSelf:!0}))return!0;return!1}},9595:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.libraryPreviewsDir=t.libraryDataDir=t.originalsDir=t.libraryDir=void 0;const n=i(22573),r=i(54993),s=i(29882),a=i(28874);function o(e){return(0,n.toNotBlank)((0,r.toS)(e))??a.Settings.libraryDir.valueOrDefault}t.libraryDir=o,t.originalsDir=function(e){return(0,s.resolveMaybe)(o(e),a.Settings.originalsDir.valueOrDefault)},t.libraryDataDir=function(e){return(0,s.resolveMaybe)(o(e),".photostructure")},t.libraryPreviewsDir=function(e){return(0,s.resolveMaybe)(o(e),a.Settings.previewsDir.valueOrDefault)}},87290:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupLibraryDbDir_=t.setupLibrarySyncReportsDir_=t.librarySyncReportsDir=t.setupLibraryPreviewsDir_=t.libraryPreviewsDirPosixFile=t.setupLibraryOriginalsDir_=t.libraryOriginalsDirPosixFile=t.setupLibraryDataDir_=t.setupLibraryDirs_=t.libraryDataDirPosixFile=t.libraryDirPosixFile=void 0;const n=i(40958),r=i(55835),s=i(37805),a=i(15056),o=i(38835),l=i(64680),u=i(95696),c=i(73428),d=i(13940),h=i(28874),f=i(9595),m=`\nHello, and thank you for using PhotoStructure!\n\nThe files in this folder support your PhotoStructure Library, including\n\n * a database with the filepaths to your photos and movies\n * previews and thumbnails of your photos and movies\n * content metadata about these assets, like ratings and sharing information\n * albums that both you and PhotoStructure Curators have assembled\n * synchronization reports describing what directories and files were synced (and why)\n\nMoving or deleting any files here will cause problems using your library.\n\nIf you have any questions, please visit https://forum.photostructure.com .\n\nSincerely,\n\nYour Friendly Neighborhood PhotoStructure, v${s.version}\n`;function p(e){return u.PosixFile.forMaybe((0,f.libraryDir)(e))}function g(e){return u.PosixFile.forMaybe((0,f.libraryDataDir)(e))}async function y(e,t=!0){if(null!=e)return await(e?.mkdirp_()),await(e?.assertReadWriteExecutable()),t&&await(e?.join(".metadata_never_index").touch()),e}async function v(e){const t=g(e);if(null==t)throw new Error("empty libraryDataDir"+o.NoLibraryErrorFlag);await y(t),await(0,l.mkNoMedia_)(t);const i=t.join("README.txt");return await(0,c.writeTextfile_)(i.nativePath,m),t}function w(e){return u.PosixFile.forMaybe((0,f.originalsDir)(e))}async function S(e){return y(w(e),!1)}function b(e){return u.PosixFile.forMaybe((0,f.libraryPreviewsDir)(e))}async function P(e){return y(b(e))}function M(e){return p(e)?.join(h.Settings.syncReportsDir.valueOrDefault)}async function _(e){return y(M(e))}async function E(e){return y((0,r.map)(g(e),(e=>(0,a.pathToDbDir)(e,a.Schemas.models))))}t.libraryDirPosixFile=p,t.libraryDataDirPosixFile=g,t.setupLibraryDirs_=async function(e){const t=p(e);await y(t,!1);const i=await v(t);return(0,n.uniq)([t,i,await S(t),await P(t),await _(t),await E(t),await(0,d.imageCacheDir_)()])},t.setupLibraryDataDir_=v,t.libraryOriginalsDirPosixFile=w,t.setupLibraryOriginalsDir_=S,t.libraryPreviewsDirPosixFile=b,t.setupLibraryPreviewsDir_=P,t.librarySyncReportsDir=M,t.setupLibrarySyncReportsDir_=_,t.setupLibraryDbDir_=E},46296:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const r=n(i(76760)),s=i(19851),a=i(40958),o=i(22573),l=i(55835),u=i(54993),c=i(72993),d=i(96706),h=i(45969),f=i(43334),m=i(32707),p=i(6707),g=i(49776),y=i(32774),v=i(80612),w=i(32551);function S(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:r.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,a.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>r.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,o.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),i=(0,u.toS)(t?.logDir);return(0,o.notBlank)(i)?i:b()}catch(e){return console.error("defaultLogDir_() failed",e),r.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const n=i(76760),r=i(19851),s=i(22573),a=i(44198),o=i(43334),l=i(24399),u=i(32551);async function c(){return o.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,r.lazy)((async()=>{if(o.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,r.lazy)((()=>(0,a.env)().XDG_PICTURES_DIR??(0,n.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const n=i(38639),r=i(7282),s=i(29325),a=i(44198);t.getDevEnvFlag=function(e){return!(0,r.isProd)()&&!(0,s.isPacked)()&&((0,n.toBoolean)((0,a.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,a.env)()[e]=String(t)}},34580:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const n=i(38639),r=i(44198);t.doNotTrack=function(){return(0,n.isTrue)((0,r.env)().DO_NOT_TRACK)}},44198:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const r=n(i(73024)),s=i(76760),a=n(i(1708)),o=i(19851),l=i(40958),u=i(41400),c=i(68708),d=i(76850),h=i(7282),f=i(32551),m=i(34102),p=i(53265),g=i(45969),y=i(59958),v=i(6012),w=i(96706);t.env=(0,o.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>a.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===a.default.env.PS_LICENSE||e.push((0,s.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),i={...a.default.env};for(const n of e)try{const e=(0,d.debom)(r.default.readFileSync((0,p.resolve)(n))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,n]of(0,c.entries)(s))t.test(e)||(i[e]=n)}catch(e){console.warn("env(): failed to read .env file, "+n,e)}return i})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const n=i(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,n.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const n=i(50989);t.EnvKeys=(0,n.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const n=i(22573),r=i(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const i={};if((0,n.blank)(e))return i;let s;for(const a of(0,r.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(a));){if(null==s.groups)continue;const{key:e,val:r}=s.groups;if((0,n.blank)(e)||null==r)continue;const a=r.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");i[t?e.toLowerCase():e]=a}}return i}},96706:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const r=n(i(1708)),s=i(19851),a=i(22573),o=i(38639),l=i(41400),u=i(40583),c=i(79840),d=i(83556),h=i(34102),f=i(44198),m=i(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,a.firstNotBlank)(r.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,r.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,o.isTrue)(g(e))}},98314:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const n=i(58587),r=i(19851),s=i(40958),a=i(22573),o=i(26905),l=i(96249),u=i(51926),c=i(23541),d=i(54993),h=i(89788),f=i(50213),m=i(81168),p=i(84542),g=i(41954),y=i(38835),v=i(70025),w=i(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const i=[...e.filter(c.isError).map(o.errorName),...e.map(o.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(o.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(i)))}function b(e){return(0,s.compact)(e).filter((e=>!o.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(a.notBlank)}function P(e,t){const i=(0,s.uniqSubstrings)(b(e)),n=t?.maxLen??400,r=t?.trailingChars??64,a=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(i.join(o.ErrorDelimiter)),n-a.length,r)+a.sort().join("")}function M(e,t){return e instanceof w.WrappedError?e.toString():(0,a.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,r.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new n.Rate,t.fatalErrorRate=new n.Rate,t.internalErrorRate=new n.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(M(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,a.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const i=(0,d.toS)(t?.[e]);if((0,a.notBlank)(i))return i}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=M,t.MissingError="(missing error)",t.errorToVerbose=function(e,i=256,n=7){return(0,a.blank)(e)&&(e=t.MissingError),M(e,{maxLen:i})+" at "+(0,o.shortStack)(e?.stack,n).join("; ")}},41954:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const n=i(40958),r=i(26905),s=i(55835),a=i(54993),o=i(81168);t.describeError=function(e){const t=(0,o.stripSuffix)((0,a.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const i of e)(0,s.map)((0,r.errorErrno)(i),(e=>t.push(u.get(e)))),(0,s.map)((0,r.errorCode)(i),(e=>t.push(l[e]?.description)));return(0,n.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const n=i(40958),r=i(76790),s=i(50989),a=i(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,r.sortBy)((0,n.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(a.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const n=i(40958),r=i(38639),s=i(26905),a=i(54993),o=i(68852),l=i(73568),u=i(78656),c=i(98314),d=i(38835);function h(e){return(0,a.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const i=(0,a.toS)(e)+(0,n.compact)(t).join("");return h(i)+f(i).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,o.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const i=(0,c.errorToS)(e);return!p.test(i)&&(!!g.test(i)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,r.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const i=(0,c.errorToS)(e);return!(!i.includes("EBUSY")&&!i.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const i=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>i.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,r.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,r.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},51837:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalError=void 0;const n=i(38835);class r extends Error{constructor(e){super(e+n.InternalErrorFlag)}}t.InternalError=r},8769:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const n=i(22573),r=i(31586),s=i(68708),a=i(7282),o=i(23560),l=i(45608),u=i(34102),c=i(28874),d=i(98314),h=i(38835),f=i(70025),m=i(57159),p=i(5012);function g(e,t){try{if((0,n.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const i=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const r=!0===i.fatal,c=!0===i.ignorable;if(!r&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),r&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",i));const h=!r||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:i}),!r||(0,a.isTest)()||(0,o.isWebService)()||(0,l.exit)({reason:i.toString(),status:i.errno??13}),r}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,r.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,o.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,r.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,r.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,i){return g(e+h.InternalErrorFlag,{cause:t,...i})}},57159:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const n=i(40958),r=i(22573),s=i(38639),a=i(26905),o=i(98553),l=i(68708),u=i(59455),c=i(41583),d=i(48884),h=i(81168),f=i(98314),m=i(38835),p=i(70025);t.toWrappedError=function(e,t){const i=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,r.blank)(i.message)||e.message.includes(i.message)))return e;const n=(0,r.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,i?.message);return new g(n??"(missing error message)",i)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,n.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,a.errorName)(t)??(0,d.first)(this.causes,a.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(a.errorCode)],a.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,a.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,r.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,r.toNotBlank)(e.path))),this.flags=t?.flags??[];const i=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??i.some(p.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(i.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(i.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(i.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let i=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const n=t?.path;return(0,r.blank)(n)||(i=(0,h.dedupeNeedle)(i,n,"file")),(0,f.joinErrorMessages)([i[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,o.stringify)(t.meta):void 0,...i.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const a=i(49769),o=i(55835),l=i(54993),u=i(22911),c=i(89788),d=i(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,n.set(this,new Map),r.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,a.getOrSet)(s(this,n,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,o.map)(s(this,r,"f").get(e),clearTimeout),s(this,r,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const i=this.target.emit(e,...t),a=s(this,n,"f").get(e);return null!=a&&(a.resolve(t),s(this,n,"f").delete(e)),i}emitDebounced(e,...t){(0,o.map)(s(this,r,"f").get(e),clearTimeout),s(this,r,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},n=new WeakMap,r=new WeakMap},34102:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const n=i(78474),r=i(19851),s=i(15197);t.ee=(0,r.lazy)((()=>{const e=new n.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const r=n(i(73024)),s=n(i(1708)),a=i(19851),o=i(22573),l=i(65843),u=i(16287),c=i(43334),d=(0,a.lazy)((()=>s.default.geteuid?.())),h=(0,a.lazy)((()=>s.default.getgroups?.()));function f(e,t){try{return!(0,o.blank)(e)&&(r.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,r.default.constants.R_OK|r.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,r.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:i=!1,x:n=!1,processUid:r,processGid:s}){if(null==e)return!1;const a=r??d(),o=null!=s?[s]:h()??[],l=0===a,u=l||e.uid===a,f=l||o.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(i&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!n||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const i of(0,l.selfAndAncestorG)(e)){const n=await(0,u.statMaybe)(i);if(null!=n){if(!n.isDirectory())return!1;if(t){if(!p(n,e))return!1}else if(t=!0,!m(n,e))return!1}}return!0},t.access=g},21144:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const r=n(i(76760)),s=i(19851),a=i(81168),o=i(57159),l=i(43334),u=i(88561),c=i(29882),d=i(65238),h=i(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const i=(0,c.parseNativePath)((0,h.resolve)(...e)),n=await m(i.dir);for(const e of await(0,d.readdir_)(n))if((0,a.equalsIgnoreCase)(e.basename,i.base))return r.default.join(n,e.basename);throw new o.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const n=i(73024),r=i(76760);function s(e){return[...a(e)]}function*a(e){for(;e!==(0,r.dirname)(e);)e=(0,r.dirname)(e),yield e}function o(e){try{return(0,n.readdirSync)(e)}catch(e){return[]}}function l(e,t){const i=o(e);return t.every((e=>i.includes(e)))}t.ancestors=s,t.ancestorG=a,t.selfAndAncestorG=function*(e){yield e,yield*a(e)},t.childrenSync=o,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,i){var n,r,s,a,o,l=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&l(t,e,i);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(i(44652)),p=c(i(73024)),g=i(51455),y=f(i(76760)),v=f(i(1708)),w=i(46466),S=f(i(57975)),b=f(i(38522)),P=i(19851),M=i(40958),_=i(5233),E=i(22573),x=i(42659),T=i(50357),D=i(96249),k=i(98553),C=i(55835),F=i(31586),O=i(68708),I=i(97790),L=i(39926),A=i(51926),R=i(59455),N=i(54993),B=i(48884),z=i(22911),j=i(99331),V=i(56519),W=i(56038),H=i(31562),U=i(76850),q=i(70025),G=i(34102),$=i(80875),J=i(50213),K=i(70417),Z=i(43334),X=i(81168),Y=i(96859),Q=i(65162),ee=i(94174),te=i(64660),ie=i(21144),ne=i(84542),re=i(89968),se=i(20197),ae=i(88561),oe=i(50597),le=i(33456),ue=i(29882),ce=i(78133),de=i(43899),he=i(65238),fe=i(53265),me=i(17217),pe=i(16287),ge=i(68284),ye=i(66003),ve=i(27794),we=i(73428),Se=i(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new ae.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(n.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,J.mkLogger)("fs.BaseFile("+this.nativePath+")"))),r.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),a.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(r=new WeakMap,a=new WeakMap,n=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,M.compact)(e),i=await Promise.all(t.map((e=>e.shaMs())));return t[(0,B.leastIndex)(i)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const i=(0,me.isSimpleFile)(e)?e.nativePath:(0,N.toS)(e);if((0,E.blank)(i))throw new Error("BaseFile.for(): empty nativePathOrFile");const n=be().get(i);if(null!=n)return n;const r=(0,fe.resolve)(i),s=new Pe(r,t);return be().set(i,s),be().set(r,s),s}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(re.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(re.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,r,"f").unset(),h(this,a,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,X.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,V.thenMap)(this.stat(),(e=>new re.DirectoryEntry(this.dir,new re.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,C.map)(this.statSync(),(e=>new re.DirectoryEntry(this.dir,new re.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,r,"f").call(this);if(null==t||null==e||(0,M.isEmpty)(t))return t;const i=[];for(const n of t)!0===await e(n)&&i.push(n);return i}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,V.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,n,"m",s).call(this)??await d(e=this.clearThisAndParent(),n,"m",s).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,M.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,M.isNotEmpty)(e)?(0,M.includesAll)(t,e):(0,M.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,M.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,V.thenMap)(this.children(),(async t=>{for(const i of t)await i.visitDescendants(e),await e(i)}))}async descendants(e){const t=[];t.push(...(0,R.toA)(await this.childFiles(e)));const i=await this.childDirectories();if(null==i)return t;for(const n of i)t.push(...(0,R.toA)(await n.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,F.gt0)(t))return;const i=await d(this,r,"f").call(this)??[];for(const t of i)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const n of i)if(n.isDirectory()){const i=await this._directoryEntryChild(n).someDescendant(e,t-1);if(null!=i)return i}}descendantsSync(e){const t=this.directoryEntrySync(),i=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&i.push(this.forDirectoryEntry(t))})),i}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Z.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,ie.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,M.isEmpty)(e)||(0,T.eql)(["."],e)||e.every(E.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,C.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,i)=>this.join((0,N.toS)(e),(0,L.pad2)(t+1),(0,L.pad2)(i))))}child(...e){if((0,M.isEmpty)(e))return this;const t=(0,D.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,i="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(i,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,i="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(i,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,i){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(i??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,a,void 0,"f"),h(this,a,d(this,a,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,V.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,V.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,V.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,V.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,x.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,V.thenMap)(this.statTimes(),B.max)}maxStatDate(){return(0,V.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,V.thenMap)(this.statTimes(),K.min)}minStatDate(){return(0,V.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,V.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,V.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,V.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Z.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,M.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,V.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,V.thenMap)(this.mtime(),(t=>(0,x.unixtime)(t)>=(0,x.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,V.thenMap)(this.mtimeMs(),(i=>Math.abs(i-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,V.thenMap)(this.mtime(),(t=>(0,x.unixtime)(t)>(0,x.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,V.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,C.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,I.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,H.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*x.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,oe.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,oe.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,$.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,$.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,U.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,V.thenMap)(this.zReadFile_(e),N.toS)))}readLines(e="warn"){return(0,V.thenMap)(this.readTextFile(e),ne.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,k.stringify)(e,t?.replacer,t?.spaces),(0,O.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,_.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,j.ending)()?1:3,timeoutMs:0,retryDelay:x.secondMs,errorIsRetriable:q.isRetriableError})}async gunzip(){return d(this,n,"m",o).call(this,(0,X.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,n,"m",o).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,n,"m",o).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const i=await this.children((async i=>!i.isNameHidden()&&t===i.size()&&i.nativePath!==e.nativePath));if((0,M.isEmpty)(i))return;const n=await e.sha();if(null!=n)for(const e of i.sort(((e,t)=>-(0,Y.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===n)return e}))}firstMatchingLine(e){const t=new z.Deferred("firstMatchingLine("+this+")"),i=p.default.createReadStream(this.nativePath,{flags:"r"});return i.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),i.close()):t.maybeReject(e)})),i.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(i,(0,A.newlineRe)(),(n=>{const r=e.exec(n);null!=r&&(t.maybeResolve(r),i.close())})),t.promise}contemporary(e,t){return(0,V.thenMap2Or)(this.statTimes(),e.statTimes(),((e,i)=>{for(const n of e)for(const e of i)if((0,F.closeTo)(n,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),i=new z.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&i.setTimeout(e.timeoutMs),Me)try{const n=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(n,r)=>{try{const s=await e.f(n,(0,C.denull)(r));t(s)&&i.resolve(s)}catch(e){i.reject(e)}}));i.finally((()=>{n.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,F.gt0)(e.intervalMs)){const n=setInterval((async()=>{try{const n=await e.f();t(n)&&i.resolve(n)}catch(e){i.reject(e)}}),e.intervalMs);e.persistent||n.unref(),i.finally((()=>{clearInterval(n)}))}return i}}t.BaseFile=Pe,s=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,X.equalsIgnoreCase)(e.basename,this.base))),t=(0,B.leastBy)(e,(e=>(0,Y.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,C.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},o=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const i=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(i.nativePath,{autoClose:!0})]),await this.unlink(),i}))},Pe.attrTTL=3*x.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let Me=!0;t.useFsWatch=function(e){Me=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},19748:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isAssetFileExtension=t.isVideoExtension=t.isBrowserExtension=t.extFilter=t.excludedPathFilter=void 0;const n=i(28874),r=i(88840),s=i(14036),a=i(29882);function o(e){return t=>n.Settings.respectFileExtensions.valueOrDefault?(0,s.isExtType)(t?.ext,e):null}t.excludedPathFilter=function(e){const t=new Set(e.map((e=>e.toLowerCase())));return e=>(0,a.toPathnames)(e.nativePath).every((e=>!t.has(e.toLowerCase())))},t.extFilter=o,t.isBrowserExtension=o(r.ExtTypes.SupportedByCurrentBrowser),t.isVideoExtension=o(r.ExtTypes.Video),t.isAssetFileExtension=o(r.ExtTypes.AssetFile)},84542:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const n=i(40958),r=i(96249),s=i(51926),a=i(54993),o=i(43334);function l(...e){return(0,r.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,a.toS)(e).split((0,s.newlineRe)()))))}t.Newline=o.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(a.toS).join("\n");return o.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,n.compactBlanks)(l(...e))}},70698:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const n=i(76760),r=i(19851),s=i(50213),a=i(37805),o=i(29882),l=i(93854),u=i(17217),c=i(16287),d=i(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,r.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const i=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return i===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,n.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const i=(0,u.toNativePath_)(e);await(0,o.mkdirp_)(i),await(0,d.writeTextfile_)((0,o.joinNativePath)([i,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+a.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const r=n(i(76760)),s=n(i(1708)),a=i(19851),o=i(22573),l=i(45969),u=i(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,a.lazy)((()=>[...(0,o.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,r.default.join(e,"System32"),r.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const o=s(i(44652)),l=a(i(73024)),u=i(76760),c=i(57975),d=i(19851),h=i(59455),f=i(50213),m=i(81168),p=i(34102),g=i(29882),y=i(65238),v=i(14427),w=i(17217),S=i(16287),b=i(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const M=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class _{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new _(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:i,base:n}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},r=await o.stat(t);return new _(i,new P(n,r))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return _.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new _(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void M().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>_.fromSimpleDirent(this.nativePath,e)))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new _(this.nativePath,new P(e.name,e))))}catch(e){return void M().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const i of t)i.isDirectory()&&await i.visitDescendants(e);for(const i of t)i.isFile()&&await e(i);for(const i of t)i.isDirectory()&&await e(i)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const i of t)i.isFile()&&e(i);for(const i of t)i.isDirectory()&&(i.visitDescendantsSync(e),e(i))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async i=>{!0===await e(i)&&t.push(i)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await o.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await o.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=_},20197:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const r=n(i(76760)),s=i(39926),a=i(29882),o=i(16287),l=i(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const i={...t.DefaultEnsureNewOptions,...e},n=(0,a.parseNativePath)(i.nativePath);if(await(0,a.mkdirp_)(n.dir),!i.requireNumber&&await(0,o.isEmptyFile)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=r.default.join(n.dir,`${n.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${n.ext}`);if(await(0,o.isEmptyFile)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)},t.ensureNewNativePathSync_=function(e){const i={...t.DefaultEnsureNewOptions,...e},n=(0,a.parseNativePath)(i.nativePath);if((0,a.mkdirpSync_)(n.dir),!i.requireNumber&&(0,l.isEmptyFileSync)(i.nativePath,i))return i.nativePath;for(let e=i.startIndex;e<=i.maxVersions;e++){const t=r.default.join(n.dir,`${n.name}-${(0,s.leftPad)(e,i.leftPad,"0")}${n.ext}`);if((0,l.isEmptyFileSync)(t,i))return t}throw new Error("There are already more than "+i.maxVersions+" of "+i.nativePath)}},92423:function(e,t,i){var n,r,s,a=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.notInHiddenPhotoStructureDir=t.whyExcludedDirectoryRecursive=t.notExcludedDirs=t.isExcludedDirectory=t.whyExcludedDirectory=t.notExcludedDirPredicates=t.isExcludedFile=t.whyExcludedFile=t.notExcludedFilePredicates=t.excludeBundles=t.excludeGlobs=t.defaultFilePredicates=t.defaultDirPredicates=t.formatPathForGlob=void 0;const l=o(i(83058)),u=i(19851),c=i(40958),d=i(76790),h=i(22573),f=i(55835),m=i(51926),p=i(54993),g=i(48884),y=i(9092),v=i(54557),w=i(50213),S=i(88158),b=i(56519),P=i(46292),M=i(32551),_=i(35280),E=i(87290),x=i(96706),T=i(57902),D=i(43334),k=i(78984),C=i(33995),F=i(28874),O=i(21144),I=i(83278),L=i(48313),A=i(85772),R=i(78133),N=i(46356),B=i(17217),z=(0,u.lazy)((()=>(0,w.mkLogger)("fs.ExcludeGlobs"))),j=new v.FifoCache(256),V=/[\\/]$/;function W(e){const t=(0,p.toS)(e),i=j.get(t);if(null!=i)return i;const n=(0,B.isSimpleFile)(e)?e:I.BaseFile.for(e),r=V.test(t)||n.isDirectorySync(),s=(0,R.native2posix)(n.nativePath),a=r?(0,m.ensureSuffix)(s,"/"):s;return j.set(t,a),j.set(a,a),j.set(n.nativePath,a),a}t.formatPathForGlob=W;class H{constructor(e,t,i=!0){if(n.add(this),this.pattern=e,this.desc=t,this.exclude=i,e.includes("\\")){const t=e;e=(0,R.native2posix)(t),z().warn("globToPredicate(): backslash in patterns aren't supported: assuming you meant forward-slash?",{given:t,input:e})}this.reason=(0,c.compactBlanks)([this.exclude?"not":"",t,"("+(0,m.ellipsize)(e,48,12)+")"]).join(" ");try{this.re=l.default.makeRe(this.pattern,{nocase:F.Settings.globsCaseInsensitive.valueOrDefault,dot:!0,posixSlashes:!0}),this.valid=!0}catch(e){this.valid=!1,z().warn("Cannot parse pattern",{glob:this.pattern,error:e})}this.bundle=this.valid&&null!=this.re?(0,S.pairToObject)(this.reason,a(this,n,"m",r).bind(this)):{}}}n=new WeakSet,r=function(e){const t=W(e),i=this.re.test(t)??this.exclude;return z().tap({msg:"apply()",level:i?T.LogLevels.debug:T.LogLevels.trace,result:i?!this.exclude:this.exclude,meta:{desc:this.desc,pattern:this.pattern,exclude:this.exclude,posixPath:t,matched:i}})};class U{constructor(){s.set(this,[])}push(...e){for(const t of e){if(!t.valid){z().warn("Ignoring invalid glob",{glob:t});continue}const e=a(this,s,"f").find((e=>e.pattern===t.pattern));null==e?a(this,s,"f").push(t):z().debug("Ignoring duplicate glob",{glob:t,prior:e})}}pushNativePath(e,t){this.push(new H((0,R.native2posix)(e),t))}toA(){return a(this,s,"f")}}s=new WeakMap;const q=new H("**/.*","hidden file"),G=new H("**/.*/","hidden directory"),$=(0,u.lazy)((()=>{const e=new U;e.push(G,q);for(const t of[{s:"bin",desc:"command binary"},{s:"dev",desc:"device file"},{s:"etc",desc:"system configuration file"},{s:"initrd",desc:"initial ramdisk"},{s:"proc",desc:"process metadata"},{s:"sbin",desc:"system binary"},{s:"snap",desc:"snap software"},{s:"sys",desc:"system metadata"},{s:"Dell",desc:"Windows driver"},{s:"Drivers",desc:"Windows driver"},{s:"Intel",desc:"Windows driver"},{s:"Microsoft",desc:"Windows driver"},{s:"NVIDIA",desc:"Windows driver"},{s:"Windows.old",desc:"Windows system"},{s:"Windows",desc:"Windows system"}])e.push(new H((D.isWin?"*":"")+"/"+t.s+"/",t.desc));if(D.isWin)for(const t of["ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemRoot","windir"]){const i=(0,x.getEnv)(t);(0,h.blank)(i)||e.pushNativePath(i,`%${t}%`)}D.isLinux&&e.push(new H(`${(0,M.homeDir)()}/snap/`,"Snap software"));for(const t of[{s:"__MACOSX",desc:"macOS resource fork"},{s:"_includes",desc:"code"},{s:"@eaDir",desc:"Synology thumbnail"},{s:"@Recently-Snapshot",desc:"QNAP snapshot"},{s:"@Recycle",desc:"QNAP trash"},{s:"@SynoResource",desc:"Synology metadata"},{s:"#recycle",desc:"Synology trash"},{s:"#snapshot",desc:"Synology snapshot"},{s:"$Recycle.Bin",desc:"Windows trash"},{s:"$SysReset",desc:"Windows"},{s:"3rdParty",desc:"code"},{s:"Application Data",desc:"Windows apps"},{s:"Application Support",desc:"macOS apps"},{s:"Applications",desc:"macOS apps"},{s:"arangodb",desc:"3rd party"},{s:"cache",desc:"Cache directory"},{s:"CacheClip",desc:"Movie cache directory"},{s:"caches",desc:"Cache directory"},{s:"Chipset_Software",desc:"Windows apps"},{s:"cmake",desc:"code"},{s:"com.apple.TimeMachine.localsnapshots",desc:"macOS"},{s:"cpan",desc:"code"},{s:"DefinitelyTyped",desc:"TypeScript type"},{s:"Desktop DB",desc:"macOS metadata"},{s:"Desktop DF",desc:"macOS metadata"},{s:"Desktop.ini",desc:"macOS metadata"},{s:"DisplayDriver",desc:"Windows driver"},{s:"DLLs",desc:"Windows library"},{s:"dyld",desc:"macOS library"},{s:"ehthumbs.db",desc:"Windows thumbnail"},{s:"i18n",desc:"i18n code"},{s:"iMovie Cache",desc:"Apple iMovie cache"},{s:"iTunes Cache",desc:"Apple iTunes"},{s:"iTunes Media",desc:"Apple iTunes"},{s:"iTunes",desc:"Apple iTunes"},{s:"lib?(32|64|x64|s)",desc:"program library directory"},{s:"lost+found",desc:"fsck recovered directory"},{s:"macOS Install*",desc:"macOS installer"},{s:"Network Trash",desc:"AFP trash"},{s:"node_modules",desc:"Node.js library"},{s:"pkgconfig",desc:"code"},{s:"pkgs",desc:"Python code"},{s:"Program Files (x86)",desc:"Windows apps"},{s:"Program Files",desc:"Windows apps"},{s:"ProgramData",desc:"Windows application support"},{s:"resources/media/face",desc:"face thumbnail"},{s:"rubygems-*",desc:"Ruby code"},{s:"site-packages",desc:"Python code"},{s:"spotifycache",desc:"Spotify cache"},{s:"SteamApps",desc:"Game files"},{s:"System Volume Information",desc:"Windows system metadata"},{s:"System32",desc:"Windows system"},{s:"SystemTemp",desc:"Windows temporary"},{s:"temp",desc:"temporary"},{s:"Temporary Items",desc:"temporary"},{s:"test_suite",desc:"code"},{s:"testutil?(s)",desc:"code"},{s:"third_party",desc:"code"},{s:"Thumbnail?(s)",desc:"thumbnail"},{s:"Thumbs.db",desc:"Windows thumbnail"},{s:"tmp",desc:"temporary"},{s:"Trash",desc:"trash directory"},{s:"Windows",desc:"Windows"},{s:"Windows.old",desc:"Windows"},{s:"Windows10Upgrade",desc:"Windows upgrade"},{s:"Xcode.app",desc:"macOS code"},{s:"*.sparsebundle/bands",desc:"Time Machine backup"},{s:"ImageMagick*",desc:"ImageMagick source"},{s:"Install OS X*",desc:"macOS installer"},{s:"Install macOS*",desc:"macOS installer"},{s:"*.lrdata",desc:"LightRoom data"},{s:"MinGW*",desc:"code"},{s:"msys*",desc:"code"},{s:"vcpkg",desc:"code"}])e.push(new H("**/"+t.s+"/",t.desc));function t(t,i,n){if(!(0,h.blank)(t)){const r=(0,d.sort)((0,c.uniq)((0,c.compactBlanks)(i).map((e=>e.toLowerCase()))));1===r.length&&e.push(new H(`**/${t}/${r[0]}/`,n)),r.length>1&&e.push(new H(`**/${t}/(${r.join("|")})/`,n))}}(0,f.map)((0,P.configDir)(),(t=>e.pushNativePath(t,"PhotoStructure configuration"))),t("nix",["store"],"NixOS package"),e.push(new H("**/*.(photo|photos|ap)library/!(master|masters|modified|original|originals)/","Apple Photos/Aperture library")),e.push(new H("**/facetile*","face thumbnail"));const i=["bin","cygdrive","dev","etc","games","include","lib?(32|64|x64)","local","locale","man","proc","sbin","share","src","tmp","usr","var"];t("usr",i,"FHS system"),t("cygwin?(64)",i,"Cygwin"),t("local",i,"FHS system"),t("Windows",["assembly","Boot","Containers","Cursors","Fonts","Help","Installer","Logs","Microsoft.NET","Servicing","SoftwareDistribution","System32","SystemApps","SysWOW64","Temp","WinSxS"],"Windows"),t("Recovery",["Customizations","OEM"],"Windows"),t("lib",["firmware","modules","systemd","udev","x86_64-linux-gnu"],"Linux system package"),t("opt",["google","x11",...i],"FHS package"),t("lfs",["incomplete","objects"],"Git LFS object");const n=["cache","crash","games","lib","local","lock","log","logs","mail","run","snap","spool","tmp"];t("var",n,"Linux /var"),t("mnt",n,"Linux /mnt"),t("dev",["block","bsg","bus","char","cpu","disk","dri","fd","hugepages","input","lightnvm","mapper","mqueue","net","pts","shm","snd","ubuntu-vg","usb","vfio"],"Linux /dev backup"),t("proc",["acpi","asound","bus","driver","fs","ipmi","irq","net","scsi","self","sys","sysvipc","thread-self","tty"],"Linux /proc backup"),t("library",["Apple","Assistant","Bluetooth","com.apple.iTunesCloud","Containers","CoreAnalytics","Developer","Desktop Pictures","Documentation","Extensions","Finance","Fonts","Frameworks","FrontBoard","Group Containers","HTTPStorages","iTunes","KeyboardServices","Keychains","Logs","Messages","News","Passes","Photos","Preferences","Ruby","Saved Application State","Scripts","User Pictures","Updates","User Template","WebKit","WebServer"],"macOS Library"),t("packages",["*.pkg","*.mpkg"],"macOS package"),t("src/**",["bin","ci","dist","doc?(s)","etc","lib?(s)","main","spec?(s)","src","test?(s)","tools","util"],"code"),t("docs",["admin","content","general","generated","sql"],"code"),t("pkg",["acceptance","ccl","cli","cmd","server","sql","storage","ui","util","workload"],"code"),t("osv",["apps","arch","compiler","external","include","java","modules","musl","tests"],"code"),t("go",["bin","blog","cmd","doc","lib","misc","pkg","src","test","vt"],"code"),t("Perl?(64)",["bin","eg","etc","html","lib","site"],"code"),t("Python*",["dlls","doc?(s)","include","lib?(s)","scripts","tools","tcl"],"code"),t("Ruby*",["bin","include","lib","msys*","packages","share","ssl"],"code"),t("msys*",["clang*","dev","etc","mingw*","tmp","ucrt*","var"],"code"),t("sdk",["build-tools","emulator","extras","patcher","platforms","platform-tools","sources","tools"],"code"),t("test",["fixtures"],"code"),t("data",["$of"],"windows backup"),t("System",["Applications","Developer","DriverKit","Library","iOSSupport"],"macOS System"),t("contents",["frameworks","plugins","resources","sharedsupport"],"macOS application"),t("pg",["pgsql"],"code");for(const e of["local","locallow","roaming"])t("appdata",[e],"Windows default AppData");return t("ps",["cache","config","logs","tmp"],"PhotoStructure docker directory"),e.toA()})),J=()=>{t.excludeGlobs.unset(),t.excludeBundles.unset()},K=()=>{t.notExcludedDirs.unset()},Z=(0,u.lazy)((()=>{F.Settings.excludeGlobsOmitDefaults.watchLater(J),F.Settings.excludeGlobsAdd.watchLater(J),F.Settings.excludeGlobsOmit.watchLater(J),F.Settings.globsCaseInsensitive.watchLater(J),F.Settings.libraryDir.watchLater(K),F.Settings.originalsDir.watchLater(K),F.Settings.scanPaths.watchLater(K),F.Settings.argvScanPaths.watchLater(K)}));t.defaultDirPredicates=(0,u.lazy)((()=>[{notSymlinkLoop:ne,notInHiddenPhotoStructureDir:se,whyNoMedia:A.whyNoMedia,notHidden:re}])),t.defaultFilePredicates=(0,u.lazy)((()=>[{notInHiddenPhotoStructureDir:se}])),t.excludeGlobs=(0,u.lazy)((()=>{Z();const e=new y.CaseInsensitiveMap;function t(t){if(null!=t&&t.valid){const i=t.pattern.trim();e.has(i)&&z().warn("Duplicate glob:",{glob:t}),e.set(i,t)}}function i(t){const i=t.trim();e.has(i)?e.delete(i):z().warn("Failed to find and remove glob specified in PS_EXCLUDE_GLOBS_OMIT",{glob:t})}if(!F.Settings.excludeGlobsOmitDefaults.valueOrDefault)for(const e of $())t(e);for(const e of F.Settings.excludeGlobsOmit.values)i(e);for(const e of F.Settings.excludeGlobsAdd.values)t(new H(e,"(from PS_EXCLUDED_GLOBS_ADD)"));const n=(0,d.sortBy)(e.values(),(e=>(0,c.compactBlanks)(e.pattern.toLowerCase().split("/")))),[r,s]=(0,g.partition)(n,(e=>e.pattern.endsWith("/")));return{dir:r,file:s}})),t.excludeBundles=(0,u.lazy)((()=>{const e=(0,t.excludeGlobs)();return{dir:[...(0,t.defaultDirPredicates)(),...e.dir.map((e=>e.bundle))],file:[...(0,t.defaultFilePredicates)(),...e.file.map((e=>e.bundle))]}}));const X=[{disableAllFilters:()=>!0}],Y=[{notBlank:()=>!1}];function Q(e){return F.Settings.disableAllFilters.valueOrDefault?X:(0,h.blank)(e)?Y:(0,t.excludeBundles)().file}function ee(e){return C.SyncPredicates.whyRejected(e,...Q(e))}function te(e){return F.Settings.disableAllFilters.valueOrDefault?X:(0,h.blank)(e)?Y:(0,t.excludeBundles)().dir}async function ie(e){return F.Settings.disableAllFilters.valueOrDefault?void 0:k.Predicates.whyRejected(e,...te(e))}function ne(e){return!(0,N.seemsLikeSymlinkLoop)(e)}function re(e){return(0,b.thenNot)((0,L.isHidden)(e))}function se(e){return!(0,_.inHiddenPhotoStructureDir)(e)}t.notExcludedFilePredicates=Q,t.whyExcludedFile=ee,t.isExcludedFile=function(e){return null!=ee(e)},t.notExcludedDirPredicates=te,t.whyExcludedDirectory=ie,t.isExcludedDirectory=async function(e){return null!=await ie(e)},t.notExcludedDirs=(0,u.lazy)((async()=>{const e=(0,c.uniq)((0,c.compactBlanks)([(0,E.libraryDirPosixFile)(),(0,E.libraryOriginalsDirPosixFile)(),...F.Settings.argvScanPaths.values,...F.Settings.scanPaths.values]));return z().tap({msg:"notExcludedDirs() (these directories will never be excluded)",level:"info",result:(0,c.uniq)([...e,...await Promise.all(e.map((e=>(0,O.actualPath)(e))))])})})),t.whyExcludedDirectoryRecursive=async function(e){const i=await(0,t.notExcludedDirs)();for(let t=e;null!=t&&!t.isRoot;t=await(t?.parent())){if(i.includes(t?.nativePath))return;const e=await ie(t);if(null!=e)return e}},t.notInHiddenPhotoStructureDir=se},88561:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const a=i(40958),o=i(22573),l=i(41400),u=i(68708),c=i(25764),d=i(38836),h=i(34102),f=i(80049),m=i(50213),p=i(88158),g=i(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),n.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>s(this,n,"m",r).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,a.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,n=new WeakSet,r=async function(e){if((0,o.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const n=i(73024),r=i(22573),s=i(45599),a=i(96249),o=i(68708),l=i(54993),u=i(49047),c=i(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,s.defer)((()=>{const e={};for(const[t,...i]of d)for(const n of i)e[n]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof n.Dirent?e.name:(0,l.toS)(e),i=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,r.blank)(i)?void 0:h()[i]??i}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,a.flatten)((0,o.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const i of t)if(i===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const n=i(68708),r=i(17217),s=i(16287),a=i(68284);async function o(e){return(0,n.pick)(await(0,s.stat_)((0,r.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=o,t.fileStats=async function(e){try{return await o(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,a.statSync)((0,r.toNativePath)(e)))?void 0:(0,n.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},78923:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFileType_=void 0;const n=i(68817),r=i(19851),s=i(22573),a=i(50213),o=i(57159),l=i(32144),u=i(47783),c=i(14036),d=i(16170),h=i(95696),f=i(93854),m=i(16287),p=(0,r.lazy)((()=>(0,a.mkLogger)("fs.FileType"))),g=["image/tiff","audio/mpeg","image/x-sony-arw","image/x-nikon-nef"];t.readFileType_=async function(e){try{const{buffer:t}=await(0,f.readFilePart_)({nativePath:e,position:0,length:256}),i=await(0,n.fromBuffer)(t);if(null!=i&&!g.includes(i.mime))return{ext:(0,l.normalizeExt)(i.ext)??i.ext,mime:(0,d.normalizeMimetype)(i.mime)};if(!await(0,m.exists)(e))return;const r=(0,s.mapNotBlank)(await(0,u.readRawField)(e,"MIMEType"),d.normalizeMimetype),a=(0,l.normalizeExt)(h.PosixFile.for(e))??(0,c.mimetypeExt)(r);return(0,s.blank)(r)||(0,s.blank)(a)?void 0:{ext:a,mime:r}}catch(t){if("EISDIR"===t?.code)return;throw p().warn("readFileType() failed for "+e,t),new o.WrappedError("Failed to read mimetype for "+e,{cause:t,ignorable:!0,retriable:!1,fatal:!1,path:e})}}},73787:function(e,t,i){var n,r,s,a,o,l=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileWatcher=void 0;const c=i(73024),d=i(50357),h=i(38836),f=i(43624);class m extends h.EndableWrapper{constructor(e,t,i){super("fs.FileWatcher("+e+")",(()=>this.close())),n.add(this),this.nativePath=e,r.set(this,[]),s.set(this,void 0),a.set(this,void 0),l(this,a,(0,f.fileStatsSync)(e),"f"),l(this,s,(0,c.watch)(e,{encoding:"utf8",persistent:!1,...t??{}},(e=>u(this,n,"m",o).call(this,e))),"f"),null!=i&&this.addListener(i)}addListener(e){null!=e&&u(this,r,"f").push(e)}close(){u(this,s,"f").close()}}t.FileWatcher=m,r=new WeakMap,s=new WeakMap,a=new WeakMap,n=new WeakSet,o=async function(e){const t=await(0,f.fileStats)(this.nativePath);if(!(0,d.eql)(u(this,a,"f"),t)){l(this,a,t,"f");for(const t of u(this,r,"f"))t(e,this.nativePath)}}},73209:function(e,t,i){var n,r,s,a,o,l,u,c,d,h,f,m,p,g,y,v,w,S=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},b=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},P=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.withLock_=t.FsLock=void 0;const M=i(58587),_=P(i(44652)),E=i(87997),x=i(40958),T=i(17586),D=i(42659),k=i(50357),C=i(75240),F=i(55835),O=i(31586),I=i(30976),L=i(13538),A=i(54993),R=i(7282),N=i(68852),B=i(23560),z=i(25764),j=i(38836),V=i(99331),W=i(22781),H=i(38835),U=i(55222),q=i(63870),G=i(69734),$=i(17217),J=new RegExp("-(?\\d+)"+(0,N.escapeRegExp)(G.PsLockExt)+"$");class K extends j.EndableWrapper{static newUid(e=process.pid){return b(this,r,Math.max(Date.now(),S(this,r,"f",s)+1),"f",s),(0,x.compactBlanks)([U.TokenRadix.encode(S(this,r,"f",s)),B.serviceName.prior(),(0,A.toS)(e)]).join("-")}static pidFromLockfile(e){return r.pidFromBasename((0,$.basename)(e))}static pidFromBasename(e){return(0,O.toInt)(J.exec((0,A.toS)(e))?.groups?.pid)}static for(e){return S(this,r,"f",o).find((t=>t.opts.file===e.file))??new r(e)}constructor(e){var t,i;super(e.name??"FsLock",(()=>S(this,n,"m",w).call(this)),e.endableRank??z.EndableRanks.postdb,(0,q.commandTimeoutMs)()),n.add(this),this.opts=e,l.set(this,b(t=r,r,(i=S(t,r,"f",a),++i),"f",a)),u.set(this,!1),c.set(this,void 0),d.set(this,void 0),h.set(this,Date.now()),this.tryAcquire_=(0,W.oneAtATime)({runLaterIfBusy:!1,undefinedIfBusy:!0,fn:async()=>{if(S(this,u,"f"))return!0;await(this.lockfile??(this.lockfile=this.lockdir.join((0,G.fsLockFileBasename)(r.newUid())))).touch_(),this.startRefreshTimer_();try{return null!=this.lockfile&&!!await S(this,n,"m",g).call(this)&&(this.logger.debug("tryAcquire(): acquired"),!0)}catch(e){return this.release(),this.logger.error("tryAcquire() failed",e),!1}}}),this.lockdir=(0,G.fsLockDir)(this.opts.file),null==e.name&&this.setName("fs.FsLock("+e.file.baseWithGrandparent+")#"+S(this,l,"f")),this.staleMs=(0,O.round)(this.opts.timeoutMs/(0,I.randomFloat)(2,4)),S(r,r,"f",o).push(this)}get acquired(){return S(this,u,"f")}toLogJSON(){return{name:this.name,acquired:this.acquired}}async selfAndSiblingNames_(e){return await S(this,n,"m",f).call(this,e)??S(this,n,"m",p).call(this)}async siblingNames(e){return(await this.selfAndSiblingNames_(e)).filter((e=>e!==this.lockfile?.base))}async iAmLast_(e){return null!=this.lockfile&&(0,T.at)(await this.selfAndSiblingNames_(e),-1)===this.lockfile.base}async iAmOnly_(e){return null!=this.lockfile&&!0===(0,k.eql)(await this.selfAndSiblingNames_(e),[this.lockfile.base])}startRefreshTimer_(){if(null==S(this,c,"f")&&this.staleMs>0){const e=Math.max(this.staleMs/2,(0,R.isTest)()?10:D.secondMs);b(this,c,setInterval((()=>S(this,n,"m",y).call(this)),e),"f")}}stopRefreshTimer(){null!=S(this,c,"f")&&(clearInterval(S(this,c,"f")),b(this,c,void 0,"f"))}async acquire_({releaseOnFailure:e=!0,timeoutMs:t=this.opts.timeoutMs}={}){if(S(this,u,"f"))return!0;try{return!!await this.tryAcquire_()||(await this.lockdir.watchUntil({f:()=>this.tryAcquire_(),persistent:!1,recursive:!1,timeoutMs:t,intervalMs:Math.round(Math.min(this.staleMs,t)/5)}),!this.acquired&&e&&this.release(),this.acquired)}catch(t){throw e&&this.release(),this.logger.warn("acquire_() failed",{error:t}),t}}release(){this.stopRefreshTimer(),b(this,u,!1,"f"),(0,F.map)(S(this,d,"f"),(e=>(0,E.clearTimeout)(e)));try{return this.lockfile?.unlinkSync_(),this.lockfile=void 0,this.logger.debug("#release() success"),!0}catch(e){return this.logger.warn("#release() failed to delete lockfile",e),!1}finally{!0===this.opts.dirty||((0,V.ending)()||this.ended?S(this,n,"m",v).call(this):(this.logger.debug("#release() scheduling lockdir cleanup",{ms:2*this.staleMs}),b(this,d,setTimeout((()=>S(this,n,"m",v).call(this)),(0,O.toGt0)(this.staleMs)??D.secondMs),"f"),S(this,d,"f").unref()))}}async withLock_(e){if(!0===this.opts.skipFsLock)return this.logger.debug("withLock(): skipLock is true, running f()"),e(this);if(S(this,u,"f"))return this.logger.debug("withLock() already acquired"),e(this);try{const t=await(!0===this.opts.noopIfContested?this.tryAcquire_():this.acquire_());return this.logger.debug("withLock()",{acquired:t}),t?await(0,L.thenOrTimeoutError)(e(this),this.opts.timeoutMs,!1):void 0}catch(e){throw this.logger.warn("withLock_() rejected",e),e}finally{this.release()}}}t.FsLock=K,r=K,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,n=new WeakSet,f=async function(e){const t=!0===e?.vacuum?"arg.vacuum":(0,O.gt0)(this.staleMs)&&Date.now()>S(this,h,"f")+this.staleMs?"lastVacuumTs was too long ago":void 0;return this.logger.tap({msg:"#maybeVacuum()",level:null==t?"trace":"debug",result:null==t?void 0:await S(this,n,"m",m).call(this),meta:{why:t}})},m=async function(){b(this,h,Date.now(),"f");const e=[],t=await S(this,n,"m",p).call(this);for(const i of t){const t=this.lockdir.join(i);if((0,O.gt0)(this.staleMs)){const e=1e3*Math.round((Date.now()-(this.staleMs+D.secondMs))/1e3),i=await t.mtimeMs({refresh:!0});if(null!=i&&i{if(this.logger.warn("readdir() failed",{error:e}),"ENOENT"===e.code)return[];throw e}))).filter((e=>e.isFile()&&(0,G.isPsLockFileOrDir)(e))).map((e=>e.name))},g=async function e(t){if(null==this.lockfile)return this.release(),!1;const i=await this.selfAndSiblingNames_(t);if(null==this.lockfile)return this.release(),!1;if(!i.includes(this.lockfile.base)){if(!(0,R.isTest)())return this.release(),!1;r.internalErrors++,this.logger.throw("#iAmNext_(): missing lockfile, "+this.lockfile+H.InternalErrorFlag,{children:i,lockfile:this.lockfile})}const s=i[0]===this.lockfile.base;if(s)b(this,u,!0,"f");else if(!0!==t?.vacuum){const t=r.pidFromBasename(i[0]);if((0,O.gt0)(t)&&!(0,M.pidExists)(t))return this.logger.info("#iAmNext_(): auto-vacuuming, owner pid is gone."),S(this,n,"m",e).call(this,{vacuum:!0})}return this.logger.tap({msg:"#iAmNext_()",result:s,meta:{lockfiles:i}})},y=async function(){if(null==this.lockfile||await this.lockfile.notExists({refresh:!0}))this.logger.warn("#refreshLockfile_(): null or missing lockfile",{lockfile:this.lockfile,notExists:await(this.lockfile?.notExists())}),this.release();else try{await this.lockfile.touch_(),this.logger.debug("#refreshLockfile_(): Touched lockfile",{lockfile:this.lockfile,selfAndSiblings:await S(this,n,"m",p).call(this)})}catch(e){throw this.logger.warn("#refreshLockfile_(): failed, force-releasing.",e),this.release(),e}},v=async function(){await S(this,n,"m",m).call(this);const e=this.lockdir.rmdirSync("trace");this.logger.debug("#rmLockDir() attempting lockdir rmdir...",{success:e})},w=function(){(0,x.filterInPlace)(S(r,r,"f",o),(e=>S(e,l,"f")!==S(this,l,"f")))},s={value:0},K.internalErrors=0,a={value:0},o={value:[]},t.withLock_=async function(e,t){return!0===e.skipFsLock?t():new K(e).withLock_(t)}},69734:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPsLockFileOrDir=t.uidFromFsLockfile=t.fsLockFileBasename=t.fsLockDir=t.PsLockExt=void 0;const n=i(22573),r=i(51926),s=i(54993),a=i(17217);function o(e){return(0,n.notBlank)(e)&&e.startsWith(".")&&e.endsWith(t.PsLockExt)}t.PsLockExt=".pslock",t.fsLockDir=function(e){return e.sibling((0,r.ensurePrefixSuffix)(e.base,{prefix:".",suffix:t.PsLockExt}))},t.fsLockFileBasename=function(e){return(0,r.ensurePrefixSuffix)(e,{prefix:".",suffix:t.PsLockExt})},t.uidFromFsLockfile=function(e){if(null==e||(0,n.blank)((0,s.toS)(e)))return;const i=(0,a.basename)(e);return o(i)?i.substring(1,i.length-t.PsLockExt.length):void 0},t.isPsLockFileOrDir=function(e){return!(0,n.blank)(e)&&o((0,a.basename)(e))}},4001:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const n=i(22573),r=i(55835),s=i(31586),a=i(51926),o=i(54993),l=i(97352),u=i(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,n.toNotBlank)(e.name)??(0,o.toS)(e),t).normalize()}function f(e,i){if(t.ymdIsoRE.test(e))return e;let n=e;for(const e of i.aggressive?d:c){const t=n.match(e);if((0,s.gt0)(t?.index)){const e=n.slice(0,t.index).trim();e.length>0&&(n=e)}}return e===n?e:f(n,i)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),i=t.pop();if((0,n.blank)(i))return e;const r=(0,u.parsePosixPath)(i),s=h(r,{aggressive:!1});return[...t,s+r.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,a.isString)(e)?e:e.name).toLowerCase().normalize(),i=h(t),n=(0,a.stripPrefix)(t.toLowerCase().normalize(),i);return(0,r.map)((0,l.extractInt)(n),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,a.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,r.map)(m.exec(t),(e=>t=e[1].trim())),(0,r.map)(g.exec(t),(e=>t=e[1].trim())),t}},14977:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.matcherForExtOrCompressedExt=t.isExtOrCompressedExt=t.gzip_=void 0;const r=n(i(44652)),s=n(i(73024)),a=i(46466),o=n(i(38522)),l=i(49769),u=i(68852);t.gzip_=async function(e){if(e.endsWith(".gz"))return e;const t=e+".gz";return await(0,a.pipeline)(s.default.createReadStream(e,{autoClose:!0}),o.default.createGzip(),s.default.createWriteStream(t,{autoClose:!0})),await r.default.unlink(e),t},t.isExtOrCompressedExt=function(e,t){return d(t)(e)};const c=new Map;function d(e){return(0,l.getOrSet)(c,e,(()=>{const t=new RegExp("^"+(0,u.escapeRegExp)(e)+"(?:\\.(gz|br))?$","i");return e=>null!=t.exec(e)}))}t.matcherForExtOrCompressedExt=d},50597:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const r=n(i(77598)),s=n(i(73024)),a=i(46466),o=i(19851),l=i(98553),u=i(68708),c=i(23467),d=i(80049),h=i(73913),f=i(50213),m=i(12089),p=i(37628),g=i(43624),y=i(17217),v=i(16287),w=(0,o.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),S=(0,o.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:i=!0}={}){const n=(0,y.toNativePath_)(e);if(i){const t=S().get(n);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:n,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:n,prior:t}),S().delete(n)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),i=(0,y.toNativePath_)(e);return{sha:await M(s.default.createReadStream(i)),stats:(0,u.pick)(await(0,v.stat_)(i),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function M(e,t=[],i="sha512"){const n=r.default.createHash(i);return await(0,a.pipeline)([e,...t,n]),n.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=M,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return r.default.randomBytes(h.HashBits/8).toString("base64")}},48313:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHidden=t.hide_=void 0;const n=i(19851),r=i(42659),s=i(55835),a=i(31586),o=i(84777),l=i(34102),u=i(43334),c=i(24399),d=i(28874),h=i(63870),f=i(83278),m=i(88561),p=i(17217),g=i(16287);t.hide_=async function(e){if(!u.isWin&&!u.isMac)return;const t=(0,p.toNativePath_)(e);await(0,g.exists)(t)&&(u.isWin?await c.PowerShell.instance().execute(`(Get-Item ${(0,c.pwshQuote)(t)}).Attributes += 'Hidden'`,(()=>{})):u.isMac&&await(0,o.stdout_)("chflags",["hidden",t],{timeoutMs:10*r.secondMs}),(0,l.ee)().emit("fileChanged",t))};const y=(0,n.lazy)((()=>new m.FileCache({name:"fs.hidden",maxSize:512,timeoutMs:(0,h.commandTimeoutMs)()})));t.isHidden=function(e){if(u.isLinux||!d.Settings.excludeHidden.valueOrDefault)return!1;const t=(0,p.isSimpleFile)(e)?e:f.BaseFile.for(e);return!t.isRoot&&(u.isWin?y().getOrSetAsync(t.nativePath,(()=>async function(e){if(e.isRoot)return!1;const t=await c.PowerShell.instance().executeJsonToA(["Get-Item -Force -LiteralPath",(0,c.pwshQuote)(e.nativePath),"-ErrorAction SilentlyContinue","| Select-Object -Property Name, Mode"].join(" "));return(0,s.mapOr)(t?.[0]?.Mode,(e=>["s","h"].some((t=>e.includes(t)))),(()=>!1))}(t))):!!u.isMac&&y().getOrSetAsync(t.nativePath,(()=>async function(e){try{const t=await(0,o.stdout_)("stat",["-f","%f",e.nativePath],{timeoutMs:10*r.secondMs}),i=(0,a.toInt)(t);return null!=i&&(32768&i)>0}catch(e){return!1}}(t))))}},25675:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const n=i(22573),r=i(54993),s=i(7282),a=i(43334),o=i(69375),l=/^\/dev(?:\/|$)/i,u=a.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=a.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=a.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=a.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,r.toS)(e))}function m(e){return(0,n.blank)(e)?"blank":(0,o.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},33456:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const n=i(57075),r=i(51926),s=i(54993);class a extends n.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,i){const n=(this._prior+(0,s.toS)(e)).split((0,r.newlineRe)()),a=n.pop();this._prior=a??"";let o=!1;for(const e of n)o||(o=!this.push(e));o?setTimeout(i,1):i()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=a},64680:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const r=n(i(76760)),s=i(17217),a=i(73428);t.mkNoMedia_=function(e){return(0,a.writeTextfile_)(r.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},85772:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._dirHasNoMediaChild=t.whyNoMediaDir=t.whyNoMedia=t.hasNoMedia=t.isNoMediaName=void 0;const a=s(i(76760)),o=i(19851),l=i(40958),u=i(96249),c=i(59455),d=i(50213),h=i(68852),f=i(76740),m=i(46199),p=i(57902),g=i(43334),y=i(59107),v=i(83278),w=i(70698),S=i(88561),b=i(65238),P=i(16287),M=(0,o.lazy)((()=>(0,d.mkLogger)("fs.hasNoMedia()"))),_="NoMedia",E=new RegExp("(?:^|["+(0,l.uniq)([(0,h.escapeRegExp)(a.default.sep),"/"]).join("")+"])\\.?"+_+"$","im"),x=Object.freeze(["."+_,_]),T=Object.freeze((0,u.flatten)(x.map((function(e){return[e,e.toLowerCase(),e.toUpperCase()]}))));function D(e){return null!=E.exec(e)}t.isNoMediaName=D;const k=(0,o.lazy)((()=>new S.FileCache({name:"fs.noMediaDirsCache"})));async function C(e,t){if(null==e)return null;const i=v.BaseFile.for(e),n=await i.stat();if(null==n||!n.isFile()&&!n.isDirectory())return null;if(n.isFile())return D(i.base)||await(0,w.isCachedirTagFile)(i)?k().set(i.parent().nativePath,(0,m.ciSafePath)(i.nativePath)):C(i.parent());{const e=await k().getOrSetAsync(i.nativePath,(()=>F(i)));return null!=e||!1===t?.recurse||i.isRoot||await(0,y.isPosixMountpoint)(i)?e:C(i.parent())}}async function F(e){if(D(e.base))return k().set(e.parent().nativePath,e.nativePath),M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.nativePath)});const t=(0,b.readdirCached)(e.nativePath);if(null!=t)return I(e.nativePath,t);const i=new f.Abortable,n=await Promise.race([O(e.nativePath,i),(0,b.readdir)(e.nativePath).then((t=>I(e.nativePath,t,i)))]);return i.abort("done"),null!=n?n:await(0,w.isCachedirTagDirectory)(e)?M().tap({msg:"whyNoMedia()",result:(0,m.ciSafePath)(e.join(w.CACHEDIR_TAG).nativePath)}):null}async function O(e,t){for(const i of g.isCaseSensitiveFs?T:x){if(!0===t?.aborted)return null;const n=a.default.join(e,i);if(await(0,P.exists)(n,p.LogLevels.trace))return M().tap({msg:"_dirHasNoMediaChild",result:(0,m.ciSafePath)(n)})}return null}async function I(e,t,i){for(const n of(0,c.toA)(t)){if(!0===i?.aborted)return null;if(D(n.basename))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)((0,a.join)(e,n.basename))});if(n.basename===w.CACHEDIR_TAG){const t=(0,a.join)(e,n.basename);if(await(0,w.isCachedirTagFile)(t))return M().tap({msg:"dirHasNoMedia()",result:(0,m.ciSafePath)(t)})}}return null}t.hasNoMedia=async function(e,t){return null!=await C(e,t)},t.whyNoMedia=C,t.whyNoMediaDir=F,t._dirHasNoMediaChild=O},29882:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const r=n(i(44652)),s=n(i(76760)),a=i(19851),o=i(40958),l=i(5233),u=i(22573),c=i(98553),d=i(39426),h=i(51926),f=i(48884),m=i(50213),p=i(81168),g=i(70025),y=i(43334),v=i(78133),w=i(53265),S=i(17217),b=i(16287),P=i(66430),M=i(5545);function _(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,a.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=_,t.containsHiddenPathname=function(e){return C(e).some(_)},t.isNotHiddenPosixPath=function(e){return C(e).every((e=>!_(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return x((0,v.posix2native)(e))},t.extname=function(e){return x(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const E=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function x(e){const t=E.exec(e)?.groups,i=t?.ext2??"",n=s.default.parse(t?.path??e);return{...n,ext:(n.ext??"")+i,base:(n.base??"")+i}}function T(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,s.default.sep)}function D(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),i=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(i))return!1;const n=e.acceptSelf??!1;return t===i?n:i.startsWith((0,p.ensureSuffix)(t,s.default.sep))}catch(i){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:i}),!1}}function k(e,t,i){if(null==t||null==i)return!1;const n=e(t),r=e(i);return null!=n&&null!=r&&(y.isLinux?n===r:(0,p.equalsIgnoreCase)(n,r))}function C(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function F(e){return(0,u.notBlank)(e)&&C(e).length===(y.isWin?1:0)}function O({p:e,maxLength:t}){const i=(0,S.toNativePath_)(e);if(i.length<=t)return i;const n=C(e),r=[],s=[n.pop()];for(;n.length>0;)if(r.length=t){n.unshift(r.pop());break}}else if(s.unshift(n.pop()),L([...r,...s]).length>=t){n.push(s.shift());break}return n.length>0&&r.push("…"),L([...r,...s])}function I(e){return e.startsWith("\\\\")}function L(e){return(0,h.ensurePrefix)((0,o.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=x,t.parentBasename=T,t.grandParentBasename=function(e){return T(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=D,t.eqlBasename=function(e,t){return k(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return k(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return k(S.toNativePath_,e,t)},t.toPathnames=C,t.pathIsRoot=F,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:C(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const i=(0,S.toNativePath_)(e),n=(0,S.toNativePath_)(t);if((0,u.blank)(i)||(0,u.blank)(n))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return i===n?"":(0,p.stripPrefix)((0,v.native2posix)(n).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(i),"/").normalize()).normalize()},t.ellipsizePath=O,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:i=4,arrLength:n=e.length}){const r=[];for(const n of e.slice(0,i))r.push(O({p:n,maxLength:t}));return r.join(", ")+(n>i?`, and ${n-i} more…`:"")},t.posixPathFromParent=function(e){return C(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return C(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const i=x(e);return`${i.base}${t}${i.ext}`},t.isUNC=I,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(I(e)||null!=e.match(M.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(F(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await r.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;r.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>r.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=L,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:L(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>D({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const r=n(i(76760)),s=i(19851),a=i(40958),o=i(22573),l=i(31586),u=i(51926),c=i(12168),d=i(59455),h=i(54993),f=i(50213),m=i(44198),p=i(96706),g=i(45969),y=i(43334),v=i(64660),w=i(21144),S=i(16287),b=(0,s.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function M(e,t=P){const i=await(0,S.statMaybe)(e,"trace");return null!=i&&i.isFile()&&(0,l.gte)(i.size,t)&&(0,v.isStatRX)(i,e)}function _(){if(y.isWin){const e=(0,o.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,o.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",i=(0,o.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,r.default.join(e,"System32"),r.default.join(e,"System32","Wbem"),r.default.join(i,"chocolatey","bin"),r.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function E(){const e=(0,h.toS)((0,m.env)().PATH).split(r.default.delimiter);return(0,a.uniq)((0,a.compactBlanks)([...e,..._()]))}t.isRXFile=M,t.pathTo=async function({tool:e,alternativePath:t,paths:i}){const n=(0,a.uniq)((0,a.compactBlanks)([...E(),...(0,d.toA)(i)]));for(const i of(0,a.uniq)((0,a.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(i,".exe"):i;for(const t of n){const i=r.default.join(t,e);if(await M(i))return y.isLinux?i:(0,w.actualPath)(i)}}b().warn("Failed to find tool",{tool:e,dirs:n})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},95696:function(e,t,i){var n,r,s,a=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),l=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&a(t,e,i);return o(t,e),t},u=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PosixFile=t.NoOp=t.uniquePrefixes=void 0;const d=l(i(44652)),h=c(i(73024)),f=c(i(51455)),m=c(i(76760)),p=i(46466),g=i(19851),y=i(40958),v=i(76790),w=i(5233),S=i(22573),b=i(42659),P=i(26905),M=i(75240),_=i(55835),E=i(31586),x=i(68708),T=i(13538),D=i(89937),k=i(12168),C=i(54993),F=i(48884),O=i(50213),I=i(45255),L=i(81168),A=i(56519),R=i(56038),N=i(31562),B=i(84777),z=i(9595),j=i(38835),V=i(70025),W=i(57902),H=i(55222),U=i(43334),q=i(33847),G=i(24399),$=i(28874),J=i(79915),K=i(45200),Z=i(34238),X=i(87001),Y=i(59107),Q=i(63870),ee=i(7014),te=i(83278),ie=i(88561),ne=i(32144),re=i(73209),se=i(48313),ae=i(29882),oe=i(17217),le=i(36868),ue=i(27794),ce=i(70257),de=i(13047),he=(0,g.lazy)((()=>new ie.FileCache({name:"fs.PosixFile"})));t.uniquePrefixes=function(e){return(0,F.contextFilter)(function(e){return(0,v.sortBy)(e,(e=>e.nativePath))}(e),((e,t,i)=>null==i||!e.isDescendantOf(i)))},t.NoOp=Symbol("no-op");class fe extends te.BaseFile{constructor(e,t){super(e,t),n.add(this),this.nativePath=e,this.pflog=(0,g.lazy)((()=>(0,O.mkLogger)("fs.PosixFile("+this.nativePath+")"))),this.uriObject_=(0,g.lazy)((()=>(0,K.nativePath2uri)(this.nativePath))),this.uri_=(0,g.lazy)((async()=>(await this.uriObject_()).toString())),this.fileuri=(0,g.lazy)((()=>Z.URI.file(this.nativePath).toString())),this.normalizedPathUri_=(0,g.lazy)((async()=>(await this.normalize()).uri_())),this.etag=(0,g.lazy)((()=>(0,A.thenMap)(this.stat(),(e=>[e.size,e.mtime.getTime()].map((e=>H.Radix58.encode(e))).join("-"))))),this.isMountpoint=(0,g.lazy)((async()=>await this.isDirectory()&&await(0,A.thenMapOr)((0,Y.mountpoints)(),(e=>e.includes(this.nativePath)),(()=>!1)))),this.existingSidecars=(0,g.lazy)((()=>(0,J.existingSidecars)(this))),this.unlock=(0,g.lazy)((()=>U.isMac?(0,B.stdout_)("chflags",["nouchg",this.nativePath],{quiet:!0,timeoutMs:I.ShortCommandTimeoutMs}):void 0))}static forDirectoryEntry(e){return fe.for(e.nativePath,e)}static forMaybe(e){return(0,S.notBlank)(e)?fe.for(e):void 0}static for(e,t){if(e instanceof fe)return e;if((0,S.blank)(e))throw new Error("PosixFile.for(): empty nativePathOrFile");if((0,L.isString)(e)){const t=he().get(e);if(null!=t)return t}const i=(0,oe.toNativePath_)(e),n=new fe(i,t);return(0,L.isString)(e)&&he().set(e,n),he().set(i,n),n}static forPosix(e){return fe.for(e.replace(/\//g,m.default.sep))}static forUri(e,t){return(0,A.thenMap)((0,K.uri2nativePath)(e,t),(e=>fe.for(e)))}for(e,t){return fe.for(e,t)}forDirectoryEntry(e){return fe.for(e.nativePath,e)}clear({emit:e}={emit:!0}){return super.clear({emit:e}),this.uriObject_.unset(),this.uri_.unset(),this.normalizedPathUri_.unset(),this.fileuri.unset(),this.etag.unset(),this.existingSidecars.unset(),this.unlock.unset(),this}uri(){return this.trap("uri",(()=>this.uri_()))}async mountpoint(){if(!(0,ae.containedByNativePath)({ancestor:(0,z.libraryDir)(),descendant:this,acceptSelf:!0})&&!(0,ae.containedByNativePath)({ancestor:(0,z.originalsDir)(),descendant:this,acceptSelf:!0}))return U.isWin&&this.nativePath.startsWith("\\\\")?fe.for(this.nativePath.split("\\").slice(0,4).join("\\")):(0,_.map)((0,ee.bestMountpoint)(this.nativePath,await(0,Y.mountpoints)()),(e=>fe.for(e)))}async isDeletedUri(e){if(await this.exists({refresh:!0}))return!1;if(this.isUNC)return this.pflog().tap({result:await this.isDeleted(),msg:"isDeletedUri(): is UNC, delegating to isDeleted()"});const t=(0,_.map)((0,S.notBlankOr)(e,(()=>this.uri_())),Z.toURI);if(null==t)return this.pflog().tap({result:await this.isDeleted(),level:"warn",msg:"isDeletedUri(): missing URI, delegating to isDeleted()"});if(t.isRootPath())return this.pflog().tap({result:await this.notExists(),msg:"isDeletedUri(): uri isRootPath",meta:{uri:t}});if((0,C.toS)(t.pathBase).normalize()!==this.base.normalize())return this.pflog().tap({level:"warn",result:await this.notExists(),msg:"isDeleted(): uri isn't correct, returning notExists()",meta:{uri:t,expectedBase:this.base,uriBase:t.pathBase}});const i=t.scheme===D.PS_LIBRARY_SCHEME?1:t.scheme===D.PS_LOCAL_FILE_SCHEME?2:t.scheme===D.PS_NETWORK_FILESYSTEM_SCHEME?3:1,n=(0,L.countChars)(t.path,"/")-i;return this.isDeleted(n)}async httpHeaders(){return{ETag:await this.etag(),"Last-Modified":await this.lastModifiedUtc()}}hide(){if(U.isWin||U.isMac)return this.trap("hide",(async()=>(await(0,se.hide_)(this),this)))}async hidden(){return(0,se.isHidden)(this)}isSidecar(){return(0,ne.isSidecarExt)(this.ext)}async existingExifSidecars(){return(await this.existingSidecars()).filter((e=>!(0,ne.isJsonExt)(e)))}async sidecar(){return(await this.existingExifSidecars()).find((e=>(0,L.equalsIgnoreCase)(e.ext,(0,J.defaultSidecarExt)())))??this.defaultSidecar()}defaultSidecar(){return this.sibling(this.base+(0,J.defaultSidecarExt)())}async jsonSidecars(){return(await this.existingSidecars()).filter((e=>(0,ne.isJsonExt)(e)))}async sidecareStats(e){return(e?.refresh??!1)&&this.existingSidecars.unset(),(0,y.compact)(await Promise.all([this,...await this.existingSidecars()].map((t=>t.stat(e)))))}async thisOrSidecareMaxMtimeMs(e){const t=await this.sidecareStats(e);return(0,F.max)(t.map((e=>e.mtimeMs)))}async writeStream_(e,t){return await(0,p.pipeline)((0,y.compact)([e,(0,_.map)(t?.onProgress,(e=>new le.ByteCounter(e))),d.createWriteStream(this.nativePath,{autoClose:!0,...(0,x.omit)(t,"onProgress")})])),e.destroy(),this.clearThisAndParent()}async applyIfEmpty_({fn_:e,minSizeBytes:i=0,returnUndefinedIfNotEmpty:n=!1,timeoutMs:r,skipWip:s=!1,skipFsLock:a=!1,retries:o=2,dirty:l=!1}){return(0,w.retryOnReject_)((async()=>{const o=await this.clear().isNonEmptyFile(i);if(!o){if(s&&a)return e(this);await this.applyWip_({fn_:async n=>await this.clear().isNonEmptyFile(i)?t.NoOp:e(n),skipFsLock:a,minSizeBytes:i,timeoutMs:r,dirty:l})}return o&&n?void 0:this.utimes()}),{maxRetries:o,timeoutMs:2*r,retryDelay:3*b.secondMs,errorIsRetriable:e=>"EBUSY"===(0,P.errorCode)(e)})}wip(){return this.sibling((0,ce.addWipPrefix)(this.base))}isWip(){return(0,ce.isWip)(this.name)}async wipIsRecent(e=ce.WipTimeoutMs){return await this.wip().isFile()&&(0,E.gte)(await this.wip().clear().maxStatMs(),Date.now()-e)}unwip_(){return this.isWip()?this.mv_(this.sibling((0,ce.rmWipPrefix)(this.base))):Promise.resolve(this)}async applyWip_({fn_:e,minSizeBytes:i=0,skipFsLock:n=!1,timeoutMs:r,dirty:s=!1}){return await this.parent().mkdirp_(),(0,re.withLock_)({file:this,skipFsLock:n,timeoutMs:r,dirty:s},(async()=>{const n=this.wip();try{await n.unlink("trace");const s=await(0,T.thenOrTimeoutError)(e(n),r);if(s===t.NoOp)return s;if(await(0,N.untilTrue)((()=>n.clear().isNonEmptyFile(i)),{timeoutMs:I.ShortCommandTimeoutMs,intervalMs:250}))return await n.mv_(this),s;throw new Error(this+"applyWip(): still empty after waiting "+(0,M.fmtDuration)(I.ShortCommandTimeoutMs))}catch(e){throw this.pflog().warn("applyWip() threw error",e),await n.unlink("trace"),await this.unlink("trace"),e}}))}copyFile_(e){return(0,R.time)("fs.copyFile",(async()=>{const t=this.dest(e);if(this.nativePath===t.nativePath)return this;if(!0!==$.Settings.onlyNativeFileCopy.valueOrDefault)try{return await u(this,n,"m",r).call(this,t)}catch(e){if(!0===(0,V.isNonRetriableError)(e))return this.pflog().throw("_copyFile failed, but error wasn't retriable",{error:e,dest:t.nativePath,src:this.nativePath});this.pflog().warn("_copyFile failed, trying _nativeCopyFile",{dest:t.nativePath,src:this.nativePath,error:e})}return await u(this,n,"m",s).call(this,t)}))}async maybeVerifySameOrThrow_(e){const t=Date.now();$.Settings.verifyFileCopies.valueOrDefault&&(await(0,N.untilTrue)((()=>this.matchesContent(e)),{timeoutMs:(0,Q.commandTimeoutMs)(),intervalMs:b.secondMs})||this.pflog().throw("copyFile_() failed (contents did not match after copy)",{dest:e,elapsedMs:Date.now()-t}))}async zCopyFile_(e,t){await e.parent().mkdirp_();const i=e.wip();try{await(0,de.zpipe_)(this.nativePath,h.default.createWriteStream(i.nativePath,{autoClose:!0}),t),await i.unwip_()}catch(e){throw await i.unlink(),e}return e.clear()}async copyTimeoutMs(){return(0,E.clamp)(I.ShortCommandTimeoutMs,10*b.minuteMs,(await this.size()??0)*Q.MinIoRate)}dest(e){const t=e.clear();return(0,S.notBlank)(this.ext)&&(0,S.blank)(t.ext)||t.isDirectorySync()?t.join(this.base):t}async renameYMDHMS_(e={}){if(await this.clear().notExists())throw new Error("Cannot rename: "+this+" doesn't exist.");const t=(0,b.fmtYMDHMS)(e.ts??await this.mtime()??Date.now()),i=(0,_.mapOr)(e.subdir,(e=>this.parent().join(e)),(()=>this.parent()));return this.mv_(i.join(this.name+"-"+t+this.ext))}async renameWithNameSuffix_(e){return(0,A.thenMap)(this.withNameSuffix(e).ensureNew_({emptyIsNew:!0}),(e=>e.unlink("debug").then((()=>this.mv_(e)))))}async saveIfNewOrDelete(e){if(await this.clear().isEmpty())return void await this.unlink("trace");const t=await this.siblingWithSameContents();if(null!=t)return await this.unlink(),t;const i=await this.sibling(e).ensureNew_();return this.mv_(i)}async mv_(e,t=W.LogLevels.debug){const i=(0,L.isString)(e)?this.parent().join(e):this.dest(e);if(this.nativePath===i.nativePath)return this.pflog().warn("mv(): no-op",new Error("internal error")),this;this.dir!==i.dir&&await i.parent().mkdirp_(),this.pflog().log(t,"mv_()",{dest:i});try{await(0,ae.move_)(this.nativePath,i.nativePath)}catch(e){this.pflog().warn("mv() failed. Calling unlock() and retrying...",e),await Promise.all([this.unlock(),i.unlock()]),await(0,ae.move_)(this.nativePath,i.nativePath)}return this.dir!==i.dir&&this.clearThisAndParent(),i.clearThisAndParent()}async equalsUri_(e){return(0,X.uriIsEquivalent)(await this.uriObject_(),e)}}t.PosixFile=fe,n=new WeakSet,r=async function(e){let t,i=e;const n=e.wip();try{const r=await this.stat_();if(null==r)return this.pflog().throw("Can't copy missing files"+j.NonRetriableErrorFlag);if(r.size>0){if($.Settings.verifyFileCopies.valueOrDefault&&null==await this.sha())return this.pflog().throw("Can't copy file without SHA"+j.NonRetriableErrorFlag);if(null==await n.parent().mkdirp())return this.pflog().throw("Cannot mkdirp "+e.dir);if(await f.default.copyFile(this.nativePath,n.nativePath,h.default.constants.COPYFILE_FICLONE),r.size>5*k.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:e.nativePath},r.size,(()=>n.size({refresh:!0})))),!await(0,N.untilTrue)((async()=>(0,E.approximates)(r.size,await n.size({refresh:!0}))),{intervalMs:b.secondMs,timeoutMs:b.minuteMs}))return this.pflog().throw("copyFile_() failed",{expectedSize:r.size,actualSize:await n.size({refresh:!0})});await this.maybeVerifySameOrThrow_(n),i=e.eql(n)?e:await n.mv_(e,W.LogLevels.trace)}try{await(0,ue.touch_)({file:i,btimeMs:r.birthtimeMs,mtimeMs:r.mtimeMs,ensureFile:!1})}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't set utimes to match source: ${e}`)}try{await d.chmod(i.nativePath,r.mode)}catch(e){this.pflog().warn(`copyFile_(${i.nativePath}): couldn't chmod to ${r.mode}: ${e}`)}return this.pflog().debug(`copyFile_(${i.nativePath}): success`),i}catch(t){throw this.pflog().warn(`copyFile_(${n?.nativePath}) failed: ${t}`),await n.unlink(),n.eql(e)||await e.unlink(),t}finally{i?.clearThisAndParent(),(0,_.map)(t,(e=>e.end()))}},s=async function(e){let t;const i=e.wip();try{if(null==await e.parent().mkdirp())return this.pflog().throw("Can't mkdir destination directory",{src:this.nativePath,dest:e.nativePath});const n=await this.stat_(),r=n?.size;return null==n||null==r?this.pflog().throw("Can't copy missing files"):(r>5*k.MiB&&(t=new q.PullProgressObserver({op:"Copying",path:this.nativePath,dest:i.nativePath},r,(()=>e.clear().size()))),U.isWin?await G.PowerShell.instance().execute(`Copy-Item -LiteralPath ${(0,G.pwshQuote)(this.nativePath)} -Destination ${(0,G.pwshQuote)(i.nativePath)}`,(e=>e)):U.isMac?await(0,B.stdout_)("ditto",[this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}):await(0,B.stdout_)("cp",["-a","-f",this.nativePath,i.nativePath],{timeoutMs:await this.copyTimeoutMs()}),await this.maybeVerifySameOrThrow_(i),await i.mv_(e,W.LogLevels.trace),await(0,ue.touch_)({file:e,reference:this,ensureFile:!1}),e.clearThisAndParent())}catch(t){return await i.unlink(),this.pflog().throw("_nativeCopyFile("+e+") failed"+j.DoNotSendErrorFlag,{error:t})}finally{(0,_.map)(t,(e=>e.end()))}}},62105:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.acceptFile=t.whyRejectFile=t.expensiveFileFiltersFor=t.acceptParentAndFileAndSimple=t.acceptFileSimple=t.whyRejectFileSimple=t.simpleFileFiltersFor=t.notFileTooBig=t.notFileTooSmall=t.notFileMissing=t.hasBrowserImgMimeType=t.notDimensionsTooSmall=t.requiredTagsFilter=void 0;const n=i(40958),r=i(22573),s=i(31586),a=i(54993),o=i(48884),l=i(56519),u=i(78984),c=i(28874),d=i(43207),h=i(47783),f=i(97573),m=i(16170),p=i(54979),g=i(1078),y=i(42231),v=i(83278),w=i(19748),S=i(92423),b=i(16287);function P(e){return async t=>(0,l.thenMapOr)((0,h.readRawTags)(t,!1),e,(()=>!1))}async function M(e){if(!(0,s.gt0)(c.Settings.minVideoDimension.valueOrDefault)&&!(0,s.gt0)(c.Settings.minImageDimension.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);if(null==t||!t.startsWith("image/")&&!t.startsWith("video/"))return!1;const i=t.startsWith("video/")?c.Settings.minVideoDimension.valueOrDefault:c.Settings.minImageDimension.valueOrDefault;return(0,s.gt0)(i)?(0,l.thenMapOr)((0,g.extractSizeInfoFromFile)(e),(e=>(0,s.gte)(e.ImageWidth,i)&&(0,s.gte)(e.ImageHeight,i)),(()=>!1)):null}async function _(e){if(!(0,s.gt0)(c.Settings.minVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,s.gte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.minVideoDurationSec.valueOrDefault):null)}async function E(e){if(!(0,s.gt0)(c.Settings.maxVideoDurationSec.valueOrDefault))return null;const t=await(0,p.readMimeType)(e);return null!=t&&((0,m.isVideoMimeType)(t)?(0,s.lte)((0,d.extractDurationSec)(await(0,h.readRawTags)(e,!1)),c.Settings.maxVideoDurationSec.valueOrDefault):null)}async function x(e){return!(0,r.blank)(await(0,p.readMimeType)(e))}async function T(e){if(-100===c.Settings.rejectRatingsLessThan.valueOrDefault)return null;const t=await(0,h.readTags)(e),i=(0,s.toInt)(t?.Rating);return null==i||i>=c.Settings.rejectRatingsLessThan.valueOrDefault}async function D(e){return 0===c.Settings.keywordBlocklist.values.length?null:(0,f.rawTagKeywords)(await(0,h.readTags)(e)).every((e=>!0!==(0,y.leafIsExcluded)(e,c.Settings.keywordBlocklist.values)))}async function k(e){if(!c.Settings.requireMakeModel.valueOrDefault)return null;const t=await(0,h.readRawTags)(e);return null==t||(0,r.blank)(t.MIMEType)?null:t.MIMEType.startsWith("image/")?null!=t&&(0,r.notBlank)(t.Make)&&(0,r.notBlank)(t.Model):null}async function C(e){return(0,v.isBaseFile)(e)?e.exists():(0,b.exists)(e.nativePath)}async function F(e){const t=c.Settings.minAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,s.gte)(i,t)}async function O(e){const t=c.Settings.maxAssetFileSizeBytes.valueOrDefault;if(t<=0)return null;const i=await e.size();return(0,s.lte)(i,t)}function I(e){return[{isSupportedFileExtension:w.isAssetFileExtension},...(0,S.notExcludedFilePredicates)(e),{notFileMissing:C},{notFileTooSmall:F,notFileTooBig:O}]}function L(e){return[...I(e),{notMissingMimeType:x},{supportedMimeType:m.isAssetFileMimeType},{notMissingMakeAndModelTags:k},{notDimensionsTooSmall:M},{notVideoTooShort:_},{notVideoTooLong:E},{notRejectedRating:T},{notExcludedKeyword:D}]}async function A(e,t){return await u.Predicates.whyRejected(e,...t??L(e))??await(0,S.whyExcludedDirectoryRecursive)(e.parent())}t.requiredTagsFilter=function(e){return P((t=>(0,o.allNotBlank)(...e.map((e=>t[e])))))},t.notDimensionsTooSmall=M,t.hasBrowserImgMimeType=P((e=>(0,n.includes)(["image/jpeg","image/png"],(0,a.toS)(e.MIMEType)))),t.notFileMissing=C,t.notFileTooSmall=F,t.notFileTooBig=O,t.simpleFileFiltersFor=I,t.whyRejectFileSimple=function(e){return u.Predicates.whyRejected(e,...I(e))},t.acceptFileSimple=function(e){return u.Predicates.accepted(e,...I(e))},t.acceptParentAndFileAndSimple=async function(e){const t=await e.parent();return null!=t&&!await(0,S.isExcludedDirectory)(t)&&await u.Predicates.accepted(e,...I(e))},t.expensiveFileFiltersFor=L,t.whyRejectFile=A,t.acceptFile=async function(e){return null==await A(e)}},78133:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const r=n(i(76760)),s=i(22573),a=i(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(r.default.sep===r.default.posix.sep)return e;const i=(0,s.notBlank)(t)?r.default.sep+r.default.sep+t+r.default.sep:"",n=e.split(r.default.posix.sep);return(0,a.equalsIgnoreCase)(n[0],t)&&n.unshift(),i+n.join(r.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||r.default.sep===r.default.posix.sep||r.default.posix.sep===r.default.sep?e:e.split(r.default.sep).join(r.default.posix.sep)}},43899:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const r=n(i(76760)),s=n(i(1708)),a=i(19851),o=i(40958),l=i(48884),u=i(50213),c=i(45969),d=i(29325),h=i(43334),f=i(65843),m=i(25675),p=i(53265);function g(...e){return(0,a.lazy)((()=>r.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,a.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(r.default.join((0,p.execDir)(),"resources"),r.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,o.compactBlanks)([(0,p.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const i of t){if((0,f.hasChildrenSync)(i,e))return i;for(const t of(0,f.ancestors)(i).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const n=r.default.join(i,"node_modules","photostructure");if((0,f.hasChildrenSync)(n,e))return n}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const n=i(44652),r=i(19851),s=i(31586),a=i(50213),o=i(57902),l=i(69428),u=(0,r.lazy)((()=>(0,a.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=o.LogLevels.info){try{return await(0,n.readFile)(e)}catch(i){return void u().log(t,".readFileMaybe("+e+")",i)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const n=i(44652),r=i(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:i}){let s=-1;try{const r=i??(await(0,n.stat)(e)).size-t,a=Buffer.alloc(r);return s=await(0,n.open)(e,"r"),await(0,n.read)(s,a,0,r,t)}finally{(0,r.mapGte0)(s,n.close)}}},69428:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const a=s(i(73024));t.readFileSync=function(e){try{return a.readFileSync(e)}catch{}}},55690:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readLines_=void 0;const n=i(44652),r=i(84542);t.readLines_=async function(e){return(0,r.splitCompactLines)(await(0,n.readFile)(e))}},32323:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const n=i(57075);class r extends n.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=r},65238:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const r=n(i(51455)),s=i(76760),a=i(19851),o=i(76790),l=i(22573),u=i(42659),c=i(41400),d=i(31586),h=i(13538),f=i(83104),m=i(54127),p=i(50213),g=i(95937),y=i(34102),v=i(28874),w=i(63870),S=i(88561),b=i(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,a.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,a.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function M(){try{await r.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=M;const _=(0,a.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function E(e){(0,l.blank)(e)||_.prior()?.delete(e)}async function x(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await _().getOrSetAsync(e,(()=>async function(e){const i=Date.now()+2*(0,b.statTimeoutMs)(),n=T(e),r=await(0,h.thenOrTimeout)(n,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(r===f.Timeout&&(0,g.onTimeout)({soft:!1}),r!==f.Timeout&&r.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=E,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),_.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),M()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?M():E(e)))})),t.slowDirs=(0,a.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!_().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){E(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=_().get(e)},t.childDirectories_=async function(e){return(await x(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?x(e):T(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=x,t.readdirCached=function(e){return _().get(e)},t.readdirUncached_=T},53265:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const r=i(73024),s=n(i(76760)),a=i(40958),o=i(22573),l=i(45599),u=i(50213),c=i(43334),d=i(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,a.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const i=s.default.resolve(t,...e);if((0,r.existsSync)(i))return i}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,o.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(o.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},46356:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.seemsLikeSymlinkLoop=void 0;const n=i(22454),r=i(28874),s=i(29882);t.seemsLikeSymlinkLoop=function(e){const t=new n.CountingSet;for(const i of(0,s.toPathnames)(e))t.incr(i.toLowerCase().normalize());return t.max()>r.Settings.maxDuplicatePathElements.valueOrDefault}},50274:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const n=i(50989);t.SidecarExts=(0,n.strEnum)("xmp","mie","exv")},14427:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const n=i(22573),r=i(38639);t.isSimpleDirent=function(e){return null!=e&&(0,n.notBlank)(e.basename)&&(0,r.isBoolean)(e.isFile)&&(0,r.isBoolean)(e.isDirectory)}},17217:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const r=n(i(73024)),s=n(i(76760)),a=i(22573),o=i(98553),l=i(81168),u=i(43334),c=i(29882),d=i(53265),h=i(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,a.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,a.blank)(e.nativePath))throw new Error(`toNativePath(${(0,o.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof r.default.Dirent?e.name:f(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:s.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),i=t.indexOf(s.default.sep);return i>0?t.slice(1,i):void 0}},t.findFileIndex=function(e,t){for(let i=0;i(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,o.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(r.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,o.blank)(e)?void 0:v(e).catch((i=>{y().log(t,"stat() failed",{error:i,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const i=S(e),n=S(t);if(i!==n)return"inconsistent file type: "+i+" ≠ "+n;for(const i of["size","mtime"]){const n=e[i],r=t[i],s=(0,u.diff)(b(n),b(r));if(null==s||s>1)return"unmatched "+i+": "+n+" ≠ "+r}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const i=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=i&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(i)},t.isNonEmptyFile=async function(e,t=0){const i=await w(e);return null!=i&&i.isFile()&&i.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.access)({stat:i,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const i=await w(e,t);return null!=i&&i.isDirectory()&&(0,m.isStatRWX)(i,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,a.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const r=n(i(73024)),s=i(22573);function a(e){try{return(0,s.blank)(e)?void 0:r.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function o(e){return null==e||e.isFile()&&0===e.size}t.statSync=a,t.isEmptyStats=o,t.isFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const i=a(e);return t.emptyIsNew?null==i:o(i)},t.isNonEmptyFileSync=function(e,t=0){const i=a(e);return null!=i&&i.isFile()&&i.size>=t},t.isDirectorySync=function(e){return!0===a(e)?.isDirectory()}},41080:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const n=i(28874);t.statTimeoutMs=function(){return n.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const n=i(22573),r=i(56409);t.onDataChunked=function(e,t,i){const n=new s(t,i,!0);return n.read(e),n.done};class s{constructor(e,t,i=!0){this.sep=e,this.onData=t,this.filterBlanks=i,this.incompleteChunk="",this.done=new r.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,n.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,n.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const r=n(i(57075)),s=i(41400),a=i(55835),o=i(68708),l=i(42279),u=i(99331),c=i(70025);class d extends r.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((i,n)=>{!1===e.write(t,(e=>{e&&n(e)}))?e.once("drain",i):i()}))},t.endStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,o.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,o.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:i,ea:n}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,a.map)(n,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(i,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends r.default.Transform{constructor(e){super({transform:(e,t,i)=>{this.onProgress(this.bytes+=e.length),i(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const r=n(i(73024)),s=i(76760),a=i(22573),o=i(76596),l=i(64660),u=i(78133),c=i(68284);function d(e){if((0,a.blank)(e))return!1;try{return r.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,o.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,a.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,a.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,a.blank)(e)&&d((0,u.posix2native)(e))}},89966:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sqliteNativePath_=t.jpegtranNativePath_=t.rawIdentifyNativePath_=t.dcrawEmuNativePath_=t.pathToTool_=t.osToolsDir=t.toolsDir=void 0;const r=n(i(48161)),s=i(19851),a=i(55835),o=i(51926),l=i(60172),u=i(38835),c=i(43334),d=i(83278),h=i(8103),f=i(43899);function m(){return(0,a.map)(f.ProjectPath.Tools(),(e=>d.BaseFile.for(e)))}function p(){return(0,a.map)(m(),(e=>e.join(c.platformName+"-"+r.default.arch())))}async function g(e){if(c.isWin&&(e=(0,o.ensureSuffix)(e,".exe")),!0!==await(m()?.isDirectory()))throw new Error("Cannot find project path for /tools/"+u.FatalErrorFlag);return(0,l.firstDefinedLater)((()=>(0,h.pathIfExists)(m()?.join("bin",e))),(()=>(0,h.pathIfExists)(m()?.join(e))),(()=>(0,h.pathIfExists)(p()?.join(e))),(()=>async function(e){return(0,l.firstDefinedLater)((()=>(0,h.pathTo)({tool:e})),(()=>{throw new Error("Cannot find path for "+e)}))}(e)))}t.toolsDir=m,t.osToolsDir=p,t.pathToTool_=g,t.dcrawEmuNativePath_=(0,s.lazy)((()=>g("dcraw_emu"))),t.rawIdentifyNativePath_=(0,s.lazy)((()=>g("raw-identify"))),t.jpegtranNativePath_=(0,s.lazy)((()=>g("jpegtran"))),t.sqliteNativePath_=(0,s.lazy)((()=>g("sqlite3")))},27794:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const r=n(i(44652)),s=i(19851),a=i(22573),o=i(42659),l=i(31586),u=i(68708),c=i(13538),d=i(29882),h=i(17217),f=i(16287),m=i(41080);function p(e){return null==e?void 0:(0,o.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const i=t.ensureFile??!0;if(null==t.file||(0,a.blank)(t.file))throw new Error("can't touch blank path");const n=(0,h.toNativePath_)(t.file);i&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const o=(0,s.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await o())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await o())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(r.default.utimes(n,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!i||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(r.default.ensureFile(n),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},84258:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.unlink=t.logger=void 0;const a=s(i(51455)),o=i(19851),l=i(59455),u=i(50213),c=i(17217);t.logger=(0,o.lazy)((()=>(0,u.mkLogger)("fs.Unlink"))),t.unlink=async function(e,i="warn"){for(const n of(0,l.toA)(e))try{null!=n&&await a.unlink((0,c.toNativePath_)(n))}catch(e){(0,t.logger)().log(i,"Failed to unlink "+n,{error:e})}}},5545:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const r=n(i(76760)),s=i(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const i=t.driveRe.exec(e)?.groups;return null==i?e:i.drive.toUpperCase()+(0,s.toS)(i.path??r.default.sep)}},70257:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isWip=t.rmWipPrefix=t.addWipPrefix=t.WipPrefix=t.WipTimeoutMs=void 0;const n=i(30976),r=i(45255),s=i(17217);t.WipTimeoutMs=r.ShortCommandTimeoutMs,t.WipPrefix=".WIP-",t.addWipPrefix=function(e){return t.WipPrefix+(0,n.randomChars)(5).toUpperCase()+"-"+e};const a=/^.WIP-[\da-z]{5}-/i;t.rmWipPrefix=function(e){return e.replace(a,"")},t.isWip=function(e){return a.test((0,s.basename)(e)??"")}},58722:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const n=i(57075),r=i(22911);class s extends n.Writable{constructor(e){super(e),this.deferred=new r.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,i){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),i()}}t.WritableToBuffer=s},73428:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const r=n(i(44652)),s=n(i(76760)),a=i(51926),o=i(54993),l=i(34102),u=i(84542),c=i(29882);async function d(e,t){const i=s.default.dirname(e);await(0,c.mkdirp_)(i),await r.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",i)}function h(e,t){const i=s.default.dirname(e);(0,c.mkdirpSync_)(i),r.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",i)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const i=(0,u.crlf)(...(0,a.wrap)(t));await d(e,i)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,a.ensureSuffix)(t.map(o.toS).join("\n"),"\n")))}},13047:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const r=n(i(73024)),s=i(76760),a=i(46466),o=i(38522),l=i(19851),u=i(40958),c=i(98553),d=i(80875),h=i(50213),f=i(57159),m=i(29882),p=i(57902),g=i(32323),y=i(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,i){const n=[],s=[r.default.createReadStream(e,{autoClose:!0,...i}).on("error",(e=>n.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,o.createGunzip)().on("error",(e=>n.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,o.createBrotliDecompress)().on("error",(e=>n.push(e)))),s.push(t),await(0,a.pipeline)(s),(0,u.isNotEmpty)(n))throw new f.WrappedError("zPipe("+e+") failed",{causes:n,path:e})}async function b(e,t){const i=new y.WritableToBuffer;return await S(e,i,t),await i.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function M(e,t){const i=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,a.pipeline)(new g.ReadableBuffer(i),(0,o.createGzip)(),r.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(i){return void v().log(t,"readJsonGz("+e+"): failed",i)}},t.outputJsonGz_=M,t.outputJsonGz=async function(e,t,i=p.LogLevels.warn){try{await M(e,t)}catch(t){v().log(i,"outputJsonGz("+e+"): failed",t)}}},680:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessStatusHealthCheckIds=t.CriticalHealthCheckIds=void 0,t.CriticalHealthCheckIds=["library-db","library-directories","library-free-space","nodejs-version","proc-not-in-dmg","tools-exiftool","test-health-check","tools-powershell","tools-sharp","tools-sqlite-version"],t.ProcessStatusHealthCheckIds=[...t.CriticalHealthCheckIds,"proc-memory-use"]},18454:function(e,t,i){var n,r,s,a,o,l,u,c,d,h,f,m,p,g,y,v,w,S,b,P,M=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},_=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheck=void 0;const E=i(19851),x=i(40958),T=i(76790),D=i(41400),k=i(50357),C=i(26905),F=i(50268),O=i(55835),I=i(68708),L=i(30976),A=i(51926),R=i(13538),N=i(42279),B=i(59455),z=i(54993),j=i(48884),V=i(89788),W=i(22454),H=i(50213),U=i(69591),q=i(22911),G=i(99331),$=i(5916),J=i(42638),K=i(77740),Z=i(98314),X=i(70025),Y=i(28874),Q=i(63870),ee=i(30933),te=i(680),ie=i(33866),ne=i(21525),re=i(82638),se=(0,E.lazy)((()=>(0,H.mkLogger)("health.HealthCheck")));class ae{static traceLater_(e,t){const i=new q.Deferred(e);i.catch((t=>{M(this,r,"f",l).push(e+": failed: "+(0,Z.errorToS)(t)),this.onResultChange()})),M(this,r,"m",o).call(this).push(i);try{return i.observe((0,N.tot)(t))}catch(e){throw i.reject(e),e}}static priorRunStates(){return M(this,r,"f",c).toA()}static allCritical(){return this.all().filter((e=>e.isCritical))}static addError(e){M(this,r,"f",l).push((0,A.isString)(e)?e:(0,Z.errorToS)(e)),this.onResultChange()}static lastErrors(){return M(this,r,"f",l).toA()}static addLoadingMsg(e){M(this,r,"f",d).push({at:Date.now(),msg:e})}static normalizeMsg(e){return(0,x.compact)((0,B.toA)(e)).map(z.toS).join("\n").replace(/\n{3,}/g,"\n\n").replace(/\n{2,} {2}- /g,"\n - ").trim().split("\n")}static unseenOrOldestPendingTrace(){const e=this.allCritical().map((e=>e.result())).filter((e=>e.isPending));return se().info("unseenOrOldestPendingTrace",{pending:e.map((e=>({name:e.name,id:e.id}))),shownCounts:M(this,r,"f",h).entriesByCountDesc()}),(0,O.map)((0,j.leastBy)(e,(e=>[M(this,r,"f",h).get(e.name),e.startedAt])),(e=>({msg:this.findById(e.name)?.pendingMsg??e.name,at:e.startedAt})))}static loadingMsg(){const e=M(this,r,"f",d).shift()??this.unseenOrOldestPendingTrace();return(0,O.map)(e,(e=>M(this,r,"f",h).incr(e.msg))),se().tap({msg:"loadingMsg",level:"info",result:e?.msg,meta:{runState:this.summary().state}})}static enableAll(){return this.disableAll(!1)}static disableAll(e=!0){const t=e?ie.HealthCheckIds.values:[];return Y.Settings.skipHealthCheckIds.envValue=t,r.reset()}static findById(e){return M(this,r,"f",f).find((t=>t.id===e))}static testResults(){return this.all().map((e=>e.result()))}static testResultsCritical(){return this.allCritical().map((e=>e.result()))}static async errorResults(){return(await Promise.all(this.testResults())).filter((e=>"error"===e.level))}static async notOkResults(){return(await Promise.all(this.testResults())).filter((e=>(0,F.levelIsNotOK)(e.level)))}static runState(){return this.summary().state}static summaryFromResults(e){const t=M(this,r,"m",m).call(this,e);return this.summary.set(t),t}static async awaitSettled(){let e=r.summary();if(e.pendingCount>0){const t=await Promise.all(r.testResultsCritical());e=r.summaryFromResults(t),se().info("awaitSettled(): summary result",{summary:e,results:t})}return se().tap({msg:"awaitSettled(): done",level:"info",result:e})}static rerunSetup(){return this.reset(),this.awaitSettled()}static onResultChange(){r.summary.unset()}static reset(){if((0,G.ending)())se().warn("Rejecting reset() when ending()",(0,C.shortStack)());else{this.onResultChange(),M(this,r,"f",l).clear(),M(this,r,"f",d).clear(),M(this,r,"f",h).clear(),M(this,r,"f",c).clear(),this.summary.clear(),_(this,r,!1,"f",u);for(const e of this.all())e.reset()}}static for(e){const t=this.findById(e.id);if(null!=t)throw new Error(`Health check with id ${e.id} already exists in section ${t.section}`);const i=new r(e.section,e.id,e.pendingMsg,e.settings,e.later,e.ordinal,e.links,e.okLinks,e.warnLinks,e.noLibraryLinks,e.errorLinks,e.onReset,e.ttlMs,e.timeoutMs);return M(this,r,"f",f).push(i),this.all.unset(),i}constructor(e,t,i,s,o,l,u,c,d,h,f,m,b,P=Q.commandTimeoutMs){n.add(this),this.section=e,this.id=t,this.pendingMsg=i,this.settings=s,this.ordinal=l,this.links=u,this.okLinks=c,this.warnLinks=d,this.noLibraryLinks=h,this.errorLinks=f,this.onReset=m,this.ttlMs=b,this.timeoutMs=P,p.set(this,void 0),g.set(this,{starting:!0}),y.set(this,0),w.set(this,(0,E.lazy)((async()=>{await M(this,p,"f").prior(),(0,k.eql)(M(this,g,"f"),M(this,n,"m",v).call(this))||(this.onReset?.(),await this.refresh(),M(this,w,"f").unset())}))),this.refresh=(0,E.lazy)((()=>new q.Deferred("refresh").observe((async()=>{await M(this,p,"f").prior();const e=M(this,p,"f").refresh();return e.finally((()=>this.refresh.unset())),e})()))),this.logger=(0,H.mkLogger)("health.HealthCheck."+this.id),this.isCritical=te.CriticalHealthCheckIds.includes(this.id),this.sortBy=[F.HealthCheckSections.ordinal(this.section),l??999,this.id],_(this,p,(0,$.lazyAsync)({desc:this.pendingMsg,later:()=>M(r,r,"f",a).enqueue({name:this.id,l:()=>M(this,n,"m",S).call(this,o)}),ttlMs:b}),"f"),this.isCritical&&M(this,p,"f").watchLater({onChange:r.onCriticalResult,onError:r.onCriticalResult});for(const e of this.settings)Y.Settings[e].watchLater((()=>M(this,w,"f").call(this)))}isStale(){return M(this,p,"f").isStale()}isPending(){return null==this.toResultSyncMaybe()}settledAtLeastOnce(){return M(this,p,"f").settledCount()}reset(){return M(this,p,"f").unset(),this.onReset?.(),_(this,g,{starting:!0},"f"),this}setTTL(e){M(this,p,"f").setTTL(e)}result(){return M(this,p,"f").call(this)}isSkipped(){return Y.Settings.skipHealthCheckIds.values.includes(this.id)}toLevelSync(){return M(this,p,"f").lastValue()?.level??"pending"}toResultSyncMaybe(){return M(this,p,"f").lastValue()}toResultSync(){return this.toResultSyncMaybe()??{section:this.section,id:this.id,ts:Date.now(),level:"pending",msg:[this.pendingMsg]}}async resultOrTimeout(e){const t=Date.now();return await(0,R.thenOrTimeoutAs)({f:this.result(),timeoutMs:e,as:void 0})??M(this,n,"m",P).call(this,{error:"Timeout",level:"warn",elapsedMs:Date.now()-t})}}function oe(e){if((0,x.isEmpty)(e))return{};const[t,i]=(0,j.partition)(e,(e=>"button"===e.type||"POST"===e.method)),n={};return(0,x.isNotEmpty)(i)&&(n.links=(0,x.uniqBy)(i)),(0,x.isNotEmpty)(t)&&(n.buttons=(0,x.uniqBy)(t)),n}t.HealthCheck=ae,r=ae,p=new WeakMap,g=new WeakMap,y=new WeakMap,w=new WeakMap,n=new WeakSet,o=function(){return(0,x.filterInPlace)(M(this,r,"f",s),(e=>!e.isPending)),M(this,r,"f",s)},m=function(e){const t=e??this.allCritical().map((e=>e.toResultSync())),i=se().tap({level:"warn",msg:"#summary()",result:(0,re.summarizeHealthChecksSync)({errors:M(this,r,"f",l),skipPending:M(this,r,"f",u),healthCheckResults:t}),meta:{healthCheckResults:t}});return i.settled&&_(this,r,!0,"f",u),i.state!==M(this,r,"f",c).last?.state&&M(this,r,"f",c).push({state:i.state,ts:Date.now()}),i},v=function(){return(0,I.fromEntries)(this.settings.map((e=>[e,Y.Settings[e].valueOrDefault])))},S=async function(e){const t=Date.now(),i=this.timeoutMs()??(0,Q.commandTimeoutMs)();se().debug("#wrapLater() starting",{id:this.id,timeoutMs:i,caller:(0,C.shortStack)()}),_(this,g,M(this,n,"m",v).call(this),"f");try{if((0,K.getDevEnvFlag)("PS_SLOMO")&&await(0,D.delay)((0,L.randomInt)(.3*i,.7*i)),this.isSkipped())return M(this,n,"m",b).call(this,{test:{level:"disabled",msg:["Disabled by "+Y.Settings.skipHealthCheckIds.key]},elapsedMs:Date.now()-t});const r=await(0,R.thenOrTimeoutError)(e(),i);return M(this,n,"m",b).call(this,{test:r,elapsedMs:Date.now()-t})}catch(e){return M(this,n,"m",P).call(this,{error:e,elapsedMs:Date.now()-t})}},b=function({test:e,src:t="#toResult",elapsedMs:i}){var n,s;const a=r.normalizeMsg(e.msg),o=e.level??((0,z.toS)(a).toLowerCase().includes("error")?"error":(0,z.toS)(a).toLowerCase().includes("warn")?"warn":"ok"),l=(0,x.compact)([...e?.links??("ok"===o||"pending"===o?this.okLinks:"warn"===o?this.warnLinks:"no-library"===o?this.noLibraryLinks:"error"===o?this.errorLinks:[])??[],...this.links??[]]),u={section:this.section,id:this.id,ts:Date.now(),level:o,msg:a,elapsedMs:i,...oe(l)};return u.runCount=(_(this,y,(s=M(this,y,"f"),n=s++,s),"f"),n),(0,G.ending)()?u:this.logger.tap({level:ne.HealthCheckLevelToLogLevel[o],msg:t,result:u})},P=function({error:e,level:t,elapsedMs:i}){this.logger.warn("#toErrorResult",{error:e,level:t});const r=(0,A.stripSuffix)(this.pendingMsg,"…")+" failed:\n"+((0,O.map)(e,Z.errorToS)??"Unknown error");return t??(t=!this.isCritical||!(0,X.isFatalError)(e)&&r.toLowerCase().includes("warn")?"warn":"error"),M(this,n,"m",b).call(this,{test:{msg:r,level:t},src:"#toErrorResult",elapsedMs:i})},s={value:[]},a={value:new J.Promises("HealthCheck",(()=>(0,ee.cpuCount)()))},l={value:new V.BoundedList(10)},u={value:!1},c={value:new V.BoundedList(10)},d={value:new V.BoundedList(100)},h={value:new W.CountingSet},f={value:[]},ae.all=(0,E.lazy)((()=>Object.freeze((0,T.sortBy)(M(r,r,"f",f),(e=>e.sortBy))))),ae.onCriticalResult=(0,U.debounce)((()=>{se().info("onCriticalResult()",r.summary.refresh())}),250),ae.summary=(0,E.lazy)((()=>M(r,r,"m",m).call(r))),ae.resetDebounced=(0,U.debounce)((()=>r.reset()),50)},33866:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const n=i(50989);t.HealthCheckIds=(0,n.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},21525:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.summaryForLevel=t.HealthCheckLevelOrder=t.HealthCheckLevelToLogLevel=t.isHealthCheckLevelFatal=void 0;const n=i(82950),r=i(50268),s=i(459),a=i(23560),o=i(87290),l=i(45969),u=i(28874),c=i(42495);t.isHealthCheckLevelFatal=function(e,t){return!(0,a.isPermaService)(t)&&(e===r.HealthCheckLevels.error||(0,a.isLibraryRequiredService)(t)&&e===r.HealthCheckLevels["no-library"])},t.HealthCheckLevelToLogLevel={error:"error","no-library":"info",pending:"debug","stop-sync":"info",warn:"warn",ok:"info",disabled:"debug"},t.HealthCheckLevelOrder=["error","no-library","pending","stop-sync","warn"],t.summaryForLevel=function(e){switch(e){case"error":return{level:e,state:"failed",msg:["Some health checks failed","Your library won't be synced until these issues are addressed."],buttons:(0,c.restartResetOrShutdownButtons)()};case"no-library":return(0,l.isDocker)()&&!0!==(0,o.libraryDirPosixFile)()?.isReadWriteExecutableSync()?{level:e,state:"failed",msg:["Your docker container is missing a bind mount for "+(0,n.tt)(u.Settings.libraryDir.valueOrDefault)],links:[c.DockerVolumeLink],buttons:[{text:"Shut down and add a bind mount for "+u.Settings.libraryDir.valueOrDefault,type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}]}:{level:e,state:"welcome",msg:["No PhotoStructure library is open"],links:[c.WhatIsALibraryLink],buttons:[{text:"Set up your library",type:"button",method:"GET",url:"/welcome",icon:"rocket_launch"}]};case"pending":return{level:e,state:"loading",msg:["Some health checks are still pending"]};case"stop-sync":return{level:e,state:"ready",msg:["Some health checks are preventing your library from being synced.","You should still be able to view your library, however."]};case"warn":return{level:e,state:"ready",msg:["Some health checks are not OK","Your library will still be synced, but you may want to address these issues."]};default:throw new s.UnreachableCaseError(e)}}},42495:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.restartResetOrShutdownButtons=t.WhatIsALibraryLink=t.DockerVolumeLink=void 0;const n=i(40958),r=i(2858);t.DockerVolumeLink={type:"link",text:"Read about PhotoStructure docker bind-mounts",url:"https://photostructure.com/go/docker-volumes/",icon:"docs"},t.WhatIsALibraryLink={type:"link",text:'What\'s a "PhotoStructure library?"',url:"https://photostructure.com/faq/library/",icon:"docs"},t.restartResetOrShutdownButtons=function(){return(0,n.compact)([(0,r.libraryHasSettings)()?{text:"Try again",title:"Restart the current library",type:"button",method:"POST",url:"/admin/restart",icon:"refresh"}:void 0,{text:"Change PhotoStructure library",title:"Create a new library or switch to an existing library",type:"button",method:"POST",url:"/admin/clear-library",icon:"switch_folder"},{text:"Exit PhotoStructure",title:"Shut down PhotoStructure. Your library will no longer be accessible until you re-launch PhotoStructure.",type:"button",method:"POST",url:"/admin/shutdown",icon:"power"}])}},89035:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.memoryHealthCheck=t.memoryUsageIsHigh=t.memoryUsageTest=void 0;const r=n(i(48161)),s=i(19851),a=i(82950),o=i(42659),l=i(45599),u=i(31586),c=i(12168),d=i(31578),h=i(23560),f=i(28874),m=i(18454);function p({desc:e,bytes:t,level:i,thresholdBytes:n}){return{level:i,msg:[e+" from "+(0,h.serviceName)()+" is "+("ok"===i?"OK":"high"),(0,a.li)(["Current: "+(0,c.fmtBytes)(t,2),"Threshold: "+(0,c.fmtBytes)(n,2)])]}}function g(){return r.default.totalmem()f.Settings.maxMemoryMb.valueOrDefault?p({level:"error",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):(0,u.gt0)(f.Settings.maxMemoryMb.valueOrDefault)&&(0,d.memoryUsageMb)()>.75*f.Settings.maxMemoryMb.valueOrDefault?p({level:"warn",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB}):p({level:"ok",desc:"Used memory",bytes:(0,d.memoryUsageBytes)(),thresholdBytes:f.Settings.maxMemoryMb.valueOrDefault*c.MB})}t.memoryUsageTest=g,t.memoryUsageIsHigh=(0,s.lazy)((()=>"ok"!==g().level),o.secondMs),t.memoryHealthCheck=(0,l.defer)((()=>m.HealthCheck.for({section:"System",id:"proc-memory-use",pendingMsg:"Checking memory usage…",settings:["maxMemoryMb"],errorLinks:[{text:"Restart web service",type:"button",method:"POST",url:"/admin/bounce",icon:"refresh"}],ttlMs:o.minuteMs,later:async()=>g()})))},82638:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.summarizeHealthChecksSync=t.summarizeHealthChecks=void 0;const n=i(40958),r=i(42659),s=i(45599),a=i(41400),o=i(96249),l=i(50268),u=i(62220),c=i(19851),d=i(50213),h=i(23560),f=i(22911),m=i(28874),p=i(21525),g=i(42495),y=(0,s.defer)((()=>(0,d.mkLogger)("health.SummarizeHealthChecks")));async function v({healthChecks:e,healthCheckResults:t,refresh:i,timeoutMs:n}){const r=new Map;for(const e of t??[])r.set(e.id,e);if(null!=e)for await(const t of f.Deferred.toAsyncIterable(e.map((e=>!0===i?e.refresh():e.result())),n))r.set(t.id,t);return[...r.values()]}t.summarizeHealthChecks=async function(e){return S({...e,healthCheckResults:await v(e)})};const w=(0,c.lazy)((()=>({...l.BaseHealthCheckSummary,libraryDir:m.Settings.libraryDir.valueOrDefault??null,from:{pid:process.pid,title:h.serviceName.prior()??process.title}})));function S(e){const t=(0,n.uniqBy)(e.healthCheckResults,(e=>e.id)),i=t.filter((e=>"pending"===e.level)),s=i.length,a=i.map((e=>e.id)),c=t.length-s,d=0===s,h=(0,n.uniq)((0,n.compactBlanks)(e.errors));if(h.length>0)return{...w(),level:l.HealthCheckLevels.error,settled:d,pendingIds:a,pendingCount:s,settledCount:c,ts:Date.now(),state:u.RunStates.failed,msg:["Errors encountered during setup:",h.join("\n---\n")],buttons:(0,g.restartResetOrShutdownButtons)()};for(const i of p.HealthCheckLevelOrder){if(e.skipPending&&i===l.HealthCheckLevels.pending)continue;const r=t.filter((e=>e.level===i));if((0,n.isNotEmpty)(r)){const e=t.filter((e=>!r.includes(e)&&(0,l.levelIsNotOK)(e.level))),u=(0,p.summaryForLevel)(i);return y().tap({msg:"summary() found "+r.length+" "+u.level+" checks",level:p.HealthCheckLevelToLogLevel[u.level],result:{...w(),level:u.level,state:u.state,links:u.links,buttons:u.buttons,settled:d,pendingIds:a,pendingCount:s,settledCount:c,linkIds:r.map((e=>e.id)),ts:Date.now(),msg:(0,n.uniq)([...u.msg,...u.level===l.HealthCheckLevels.pending?[]:(0,o.flatten)([...r,...e].map((e=>e.msg[0])))])},meta:{checks:r.map((e=>e.id))}})}}return y().tap({msg:"summary(): all are passing",result:{...w(),level:l.HealthCheckLevels.ok,state:u.RunStates.ready,settled:d,pendingIds:a,pendingCount:s,settledCount:c,ts:Date.now(),msg:["All critical health checks pass","Last updated: "+(0,r.fmtDateShort)(Date.now())]}})}(0,a.later)((()=>{m.Settings.libraryDir.watchLater((()=>w.unset()))})),t.summarizeHealthChecksSync=S},95242:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviewBuilder=t.mkPreviewAssetFile_=void 0;const a=i(57975),o=i(40958),l=i(22573),u=i(33374),c=i(98553),d=i(55835),h=i(68708),f=i(48884),m=i(50213),p=i(92434),g=i(54296),y=i(51837),v=i(57159),w=i(83278),S=i(95696),b=i(62105),P=i(84258),M=i(38156),_=i(69589),E=i(28874),x=i(47783),T=i(29990),D=i(16047),k=i(42725),C=i(4192),F=i(32876),O=i(50961),I=i(181);t.mkPreviewAssetFile_=async function(e){const t=await(0,x.readTags)(e);return{nativePath:e.nativePath,fileSize:await e.size(),mtime:await e.thisOrSidecareMaxMtimeMs(),uri:await e.uri_(),mountpoint:(await e.mountpoint())?.nativePath,mimetype:t.mimetype,rotation:t.rotation,...t.dimensions,sha:await e.sha_()}};class L{constructor(e,t,i){n.add(this),this.ap=e,this.assetFiles=t,this.logger=(0,m.mkLogger)("AssetPreviewBuilder("+e.assetId+")"),this.ctx=(0,_.forceContextOrSetting)(i),this.assetFiles=(0,p.sortAssetFiles)(this.assetFiles)}[(n=new WeakSet,a.inspect.custom)](){return{ctor:"AssetPreviewBuilder",assetId:this.ap.assetId,assetFiles:this.assetFiles}}async build_(){this.logger.info("build_(): asset file candidates:",this.assetFiles.map((e=>(0,h.pick)(e,"id","uri"))));const e=[];for(const t of this.assetFiles){const i=S.PosixFile.forMaybe(await(0,g.getAssetFileNativePath)(t));if(null!=i){{const e=await(0,b.whyRejectFile)(i);(0,l.blank)(e)||this.logger.info("skipping: rejected",{pf:i,whyRejected:e})}try{return await s(this,n,"m",r).call(this,i,t)}catch(i){e.push(i),this.logger.warn("Failed to set shown file to ",{best:t,error:i})}finally{this.ap.parent.clear()}}else this.logger.info("skipping: failed to get PosixFile",{af:t}),e.push(new Error("Cannot get path from URI "+(0,c.stringify)((0,h.pick)(t,"uri","mountpoint","nativePath"))))}return this.logger.throw("Cannot build previews: none of the files are valid",{doNotSend:!0,retriable:!1,files:this.assetFiles.map((e=>e.nativePath??e.uri)),causes:e})}async infoForBest_(e,t){await(0,I.throwIfInvalidFile_)(e);const i=await e.size(),n=await e.thisOrSidecareMaxMtimeMs();if(this.logger.debug("_build",{filesize:i,mtime:n,best:t.uri}),null==i||null==n)return this.logger.throw("build(): missing stat info for best file",{ignorable:!0,best:t});const{uri:r,width:s,height:a,sha:l,mimetype:u}=t;if(null==r||null==s||null==a||null==u||null==l)return this.logger.throw("build(): internal error: missing fields for best file "+e,{ignorable:!0,best:t});const c=(0,T.fitSizes)(t,t.mimetype);return{assetId:t.assetId,assetFileId:t.id,uri:r,uris:this.assetFiles.map((e=>e.uri)),path:e.nativePath,mtime:n,filesize:i,width:s,height:a,sha:l,mimetype:u,fitSizes:c.map((([,e])=>e.name)).join(","),sqWidths:(0,o.compact)(k.ImageSize.sq().map((e=>e.outputSize(t)?.width))),fitWidths:c.map((([e])=>e.width))}}async priorIfValid_(e,t){if(this.ctx.forceSync||this.ctx.forceRebuildPreviews)return;const i=await this.ap.readInfo.refresh();if(null!=i){if(i.assetId!==t.assetId)throw new y.InternalError("priorIfValid_(): mismatched asset IDs for "+e+": "+(0,c.stringify)({priorInfo:i,info:t}));const n=i.fitSizes.split(","),r=t.fitSizes.split(",");if(null!=i.sha&&i.sha===t.sha&&i.rotation===t.rotation&&(0,T.equivalentFitSizes)(n,r)){const s=(0,T.fitSizes)(e,e.mimetype),a=(0,o.diff)(n,r);if((0,o.isNotEmpty)(a)){this.logger.info("priorIfValid_(): removing previews that aren't required anymore.",{leftovers:a});for(const e of a){const t=s.find((([,t])=>t.name===e));if(null==t)this.logger.warn("priorIfValid_(): Failed to clean up: missing fit size",{fitsize:t,fits:s});else{const e=this.ap.fileForWidth(t[1].reducer.name,t[0].width);this.logger.debug("priorIfValid_(): unlinking unwanted preview "+e,{fitsize:t}),await e.unlink("warn")}}}return this.logger.debug("priorIfValid_(): SHA and rotation match, and previews exist.",{info:t,priorInfo:i}),await this.ap.writeInfo(t),t}}}}t.AssetPreviewBuilder=L,r=async function(e,t){this.logger.info("_build("+e+")",{uri:t.uri});const i=await this.infoForBest_(e,t),n=await this.priorIfValid_(t,i);if(null!=n)return n;const r=new M.PushProgressObserver({path:e.nativePath,op:"Building previews"},k.ImageSize.sq().length+k.ImageSize.fit().length);if(this.logger.debug("Rebuilding all previews from "+t.uri,{assetId:t.assetId,info:i}),null==await this.ap.parent.mkdirp())throw new Error("build(): Failed to create previews directory, "+this.ap.parent+" for "+t);const s=await this.ap.existingFiles(),a=await(0,O.sharpReadable_)({src:e,minDim:k.ImageSize.largestFit().max});if(null==a)throw new v.WrappedError("AssetPreviewBuilder.build(): "+t.uri+", "+e.nativePath+", is not readable by sharp.",{retriable:!1});const o=(0,O.toSharp)(a);if(t.mimetype.startsWith("image/")&&!(0,D.isHeifMimeType)(t.mimetype)&&null!=t.rotation&&0!==t.rotation&&(o.rotate(t.rotation),this.logger.debug("build(): rotating "+t.rotation+"°")),(0,w.isBaseFile)(a)&&a.desc.toLowerCase().includes("thumbnail"))try{o.trim(1)}catch{}const l=(0,T.fitSizes)(t,t.mimetype),c=[],m=[];let p,g;const y=k.ImageSize.largestSq(),S=(0,f.leastBy)(l,(([e,t])=>(0,d.map)(y.outputSize(e),(()=>t.megapixels()))))?.[1].name,b=(0,h.pick)(t,"width","height");{let e=o.clone(),t=b;for(const[i,n]of l){const s=Date.now(),a=t,o=this.ap.fileForWidth(n.reducer.name,i.width).wip();e=n.resize(i,e),t=i,n.name===S&&(g=e.clone(),p=i),(0,u.dmegapixels)(i)>=1&&n.reducer===F.Fit&&E.Settings.includePreviewTags.valueOrDefault&&m.push(o),await n.toJpeg({path:o.nativePath,sh:e,outputSize:i}),r.onProgress(),this.logger.debug("resize("+n.name+") "+(0,u.fmtDim)(a)+" -> "+(0,u.fmtDim)(i)+" in "+(Date.now()-s)+" ms"),c.push(o)}}{null==g?(this.logger.debug("square resize(): resorting to ",{origDim:b,bestFitNameForSq:S}),g=o,p=b):this.logger.debug("square resize(): using to ",{sqDim:p,bestFitNameForSq:S});let e=!1;for(const t of k.ImageSize.sq()){const i=Date.now(),n=p,s=t.outputSize(p??b);if(null==s){this.logger.debug("skipping square output for "+t.max);continue}e||(s.position=E.Settings.squareThumbStrategy.valueOrDefault,e=!0),this.logger.debug("Applying ",{outputSize:s});const a=this.ap.fileForWidth(t.reducer.name,s.width).wip();t.resize(s,g),p=s,await t.toJpeg({path:a.nativePath,sh:g,outputSize:s}),r.onProgress(),c.push(a),this.logger.debug("resize("+t.name+") "+(0,u.fmtDim)(n)+" -> "+(0,u.fmtDim)(s)+" in "+(Date.now()-i)+" ms")}}try{await(0,C.includePreviewTags_)(e,m).catch((t=>{this.logger.warn("Failed to restore metadata tags into previews for "+e,{error:t})}));const t=new Set(s.map((e=>e.nativePath)));for(const e of c){const i=await e.unwip_();t.delete(i.nativePath)}await(0,P.unlink)(t),await this.ap.writeInfo(i),this.logger.debug("Previews unwipped and info written",{info:i})}catch(t){throw await(0,P.unlink)(c),new v.WrappedError("Failed to create previews from "+e,{cause:t,path:e.nativePath,fatal:!1})}return i}},35721:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkDownloadableTitle=t.previewToDownloadable=t.extractPreviewInfo=void 0;const n=i(75761),r=i(33374),s=i(11371),a=i(55835),o=i(31586),l=i(56519),u=i(29882),c=i(50213),d=i(97352),h=i(81168),f=i(89782),m=(0,c.mkLogger)("extractPreviewInfo");function p(e,t,i,n){return`Download ${t} ${e.ext} ${i} (${(0,r.fmtDim)(n)})`}t.extractPreviewInfo=function(e,t){const i=t.posixPathFrom(e).replace(/\//g,"").split("-"),n=(0,o.toInt)(i[0]),r=s.ReducerNames.getCI(i[1]),a=(0,d.extractInt)(i[2]);return(0,o.gt0)(n)?{file:t,assetId:n,reducer:r,width:a}:void m.warn("Failed to extract preview info",{file:t,previewsRoot:e,arr:i,assetId:n,reducer:r,width:a})},t.previewToDownloadable=async function(e,t){return(0,a.map2)(t.assetId,t.width,((i,a)=>(0,l.thenMap)((0,f.dimensions)(t.file),(o=>{const l=(0,r.dimToSize)(o);return{size:l,basename:`${(0,h.stripSuffix)(e,(0,u.extname)(e))}-${l}${t.file.ext}`,title:p(t.file,l,"image",o),description:`Download ${l}`,details:`(${(0,r.fmtDim)(o)} ${t.file.ext})`,href:(0,n.assetImgLink)({assetId:i,reducer:s.ReducerNames.fit,width:a})}}))))},t.mkDownloadableTitle=p},16524:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.AssetPreviews=void 0;const a=i(19851),o=i(40958),l=i(75761),u=i(11371),c=i(68708),d=i(39926),h=i(58939),f=i(48884),m=i(50213),p=i(81168),g=i(56519),y=i(38835),v=i(70417),w=i(35721);t.AssetPreviews=class{constructor(e,t){n.add(this),this.previewsRoot=e,this.readInfo=(0,a.lazy)((()=>this.infoJson().readJson("debug"))),this.logger=(0,m.mkLogger)("AssetPreviews(assetId:"+(0,h.id2id)(t)+")"),this.assetId=(0,h.id2id)(t);const i=(0,d.leftPad)(this.assetId,8,"0"),r=(0,p.splitEvery)(i,3);this.basename=r.pop()+"-",this.parent=e.join(...r)}parentNotExists(){return this.parent.clear().notExists()}async existingFiles(){return await this.parent.clear().childFiles((e=>e.base.startsWith(this.basename)))??[]}async existingJpgs(){return(await this.existingFiles()).filter((e=>".jpg"===e.ext))}async previewInfos(){return(0,g.sortByAsync)({name:"img.AssetPreviews.previews",arr:s(this,n,"m",r).call(this),f:e=>e?.file.size()})}async deleteAll(){const e=await this.existingFiles();if(e.length>20)throw new Error("deleteAll(): rejected: > 20 existing files?!"+y.InternalErrorFlag);for(const t of e)await t.unlink();return e}fileForSuffix(e){return this.parent.join(this.basename+e)}mp4(){return this.fileForSuffix("video.mp4")}infoJson(){return this.fileForSuffix("info.json")}writeInfo(e){return this.readInfo.unset(),this.infoJson().writeJson((0,c.pick)(e,"assetId","assetFileId","uri","uris","path","mimetype","width","height","mtime","filesize","sha","rotation","fitSizes","fitWidths"))}fileForWidth(e,t){return this.fileForSuffix(e+"-w"+t+".jpg")}async filesForReducer(e){const t=this.basename+e+"-";return this.logger.tap({msg:"filesForReducer("+e+")",result:(await this.existingFiles()).filter((e=>e.base.startsWith(t)))})}async smallestFileForReducer(e){return(0,f.leastBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async largestFileForReducer(e){return(0,f.greatestBy)(await this.filesForReducer(e),(e=>(0,w.extractPreviewInfo)(this.previewsRoot,e)?.width))}async widths(e){const t=await this.readInfo(),i=e===u.ReducerNames.sq?"sqWidths":"fitWidths",n=t?.[i];if(!(0,o.isEmpty)(n))return n;const r=(0,o.compact)((await this.previewInfos()).filter((t=>t.reducer===e)).map((e=>e.width)));return null!=t&&(t[i]=r,await this.writeInfo(t)),r}async posterLink(){const e=await this.widths(u.ReducerNames.fit);return(0,l.assetImgLink)({assetId:this.assetId,reducer:u.ReducerNames.fit,width:(0,v.max)(e)})}async imgAttrs(e,t=!1,i=!0){if(t||e!==u.ReducerNames.sq){const t=e===u.ReducerNames.fit?await this.readInfo():void 0;return(0,l.assetImgAttrs)({assetId:this.assetId,reducer:e,widths:await this.widths(e),lazyLoad:i,af:t})}return(0,l.assetSqImgAttrs)({assetId:this.assetId,lazyLoad:i})}},n=new WeakSet,r=async function(){const e=[];for(const t of await this.existingFiles()){const i=(0,w.extractPreviewInfo)(this.previewsRoot,t);null!=i&&e.push(i)}return e}},52086:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const n=i(50989);t.CropStrategies=(0,n.strEnum)("center","entropy","attention")},33106:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.dctPixels=t.dctHashCIELAB=t.dctHash=void 0;const r=n(i(9288)),s=i(96249),a=i(85810),o=32,l=function(e){const t=new Array(32);for(let e=1;e<32;e++)t[e]=1;return t[0]=1/Math.sqrt(2),t}(),u=function(e){const t=new Array(32);for(let e=0;e<32;e++){t[e]=new Array(32);for(let i=0;i<32;i++)t[e][i]=Math.cos((2*e+1)/64*i*Math.PI)}return t}();function c(e){const t=new Array(o);for(let i=0;ir?1:0);return s}t.dctHash=async function(e){return c(await e.greyscale().resize({width:o,height:o,fit:r.default.fit.fill}).raw().toBuffer())},t.dctHashCIELAB=async function(e){const t=await e.resize({width:o,height:o,fit:r.default.fit.fill}).raw().toBuffer(),i=(0,a.rgb2labArray)(t);return(0,s.flatten)(i.map(c))},t.dctPixels=c},86580:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validRotations=t.rotateDimensions=t.aspectRatio=t.fitToResolution=t.parseDimensions=t.ltEither=t.lteBoth=t.ltBoth=t.tmegapixels=void 0;const n=i(40958),r=i(33374),s=i(31586),a=i(21605),o=i(54993),l=i(2090);function u(e,t){return null!=e&&(0,s.gt0)(e.width)&&(0,s.gt0)(e.height)?(0,s.sigFigs)((0,l.roundAspectRatio)(e.width/e.height,t),3):void 0}function c(e,t){return 0===t||180===t?e:{width:e.height,height:e.width}}t.tmegapixels=function(e){return null!=e.dimensions?(0,r.dmegapixels)(e.dimensions):(0,s.gt0)(e.Megapixels)?e.Megapixels:void 0},t.ltBoth=function(e,t){return(0,s.lt)(e.width,t.width)&&(0,s.lt)(e.height,t.height)},t.lteBoth=function(e,t){return(0,s.lte)(e?.width,t?.width)&&(0,s.lte)(e?.height,t?.height)},t.ltEither=function(e,t){return(0,s.lt)(e.width,t.width)||(0,s.lt)(e.height,t.height)},t.parseDimensions=function(e){const t=(0,n.compact)((0,o.toS)(e).split(/[x×]/).map((e=>(0,s.toInt)(e))));return 2===t.length?{width:t[0],height:t[1]}:void 0},t.fitToResolution=function(e,t){if(e.width*e.height<=t)return e;const i=e.width/e.height,n=Math.round(Math.sqrt(t*i));return{width:n,height:Math.round(n/i)}},t.aspectRatio=u,t.rotateDimensions=c,t.validRotations=function(e,t,i=.2){const n=u(e,i);return null==n?[]:a.Rotations.filter((e=>u(c(t,e),i)===n))}},89782:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dimensions=void 0;const n=i(19851),r=i(31586),s=i(50213),a=i(56519),o=i(1078),l=i(5733),u=(0,n.lazy)((()=>(0,s.mkLogger)("img.FileDimensions")));t.dimensions=async function(e){try{if(null==e)return;if((0,l.isSharp)(e)){const t=await e.metadata();return(0,r.map2Numeric)(t.width,t.height,((e,t)=>({width:e,height:t})))}return(0,a.thenMap)((0,o.extractSizeInfoFromFile)(e),(e=>({width:e.ImageWidth,height:e.ImageHeight})))}catch(e){return void u().warn("dimensions() failed",{error:e})}}},29990:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.equivalentFitSizes=t.fitSizes=void 0;const n=i(40958),r=i(33374),s=i(16170),a=i(42725),o=[a.ImageSize.QVGA,a.ImageSize.QQVGA];function l(e){return"qhd"===e?"wvga":"uhd"===e?"uhd4k":e}t.fitSizes=function(e,t){const i=a.ImageSize.fit(),n=[];let l=(0,s.isMimeTypeSupportedByBrowser)(t)?e:void 0;for(let t=0;t3||(0,r.dmegapixels)(a)-(0,r.dmegapixels)(l)>2.5)&&(l=a,n.push([a,s])))}return n},t.equivalentFitSizes=function(e,t){return(0,n.includesAll)((0,n.compactBlanks)(e).map(l),(0,n.compactBlanks)(t).map(l))}},277:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.heif2img=t.isHeifSupported=t.extractHeifConvertVersion=t.getHeifSupportDetails=void 0;const n=i(22573),r=i(41400),s=i(54993),a=i(19851),o=i(50213),l=i(96175),u=i(45255),c=i(84777),d=i(34102),h=i(78330),f=i(46305),m=i(43334),p=i(28874),g=i(91354),y=i(36192),v=(0,a.lazy)((()=>(0,o.mkLogger)("img.Heif")));function w(e){return(0,s.toS)(e).match(/(?:heif-convert|libheif)\s+version[^\d.]*(?[\d.]{5,})/i)?.groups?.version}async function S(){return!0===(await(0,t.getHeifSupportDetails)())?.isSupportedVersion}t.getHeifSupportDetails=(0,a.lazy)((async()=>{try{if(m.isMac)try{const e=await(0,y.sipsPath)();if(!(0,n.blank)(e))return{path:e,version:(0,l.osNameMac)(),isSupportedVersion:!0}}catch(e){v().warn("Failed to find the sips tool (either in PATH or /usr/bin).",e)}const e=await(0,g.heifConvertPath)();if((0,n.blank)(e))return void v().warn("Failed to find heif-convert",{heifConvertPath:p.Settings.heifConvertPath.valueOrDefault});{let t="",i=w(await(0,c.stdout_)(e,[],{timeoutMs:u.ShortCommandTimeoutMs,quiet:!0,ignoreExitCode:!0,isIgnorableError:e=>(t+=e.message,!0)})+t);if((0,n.blank)(i)&&(0,l.hasApt)()){const t=await(0,h.aptInstalledVersion)(e);i=t?.find((e=>"libheif-examples"===e.pkg))?.version}return(0,n.blank)(i)&&(0,f.hasPacman)()&&(i=(await(0,f.pacmanInstalledVersion)(e))?.version),{path:e,version:(0,n.toNotBlank)(i)??"(unknown)",isSupportedVersion:!0}}}catch(e){return void v().warn("Failed to get heif-convert tool details",{error:e})}})),t.extractHeifConvertVersion=w,t.isHeifSupported=S,t.heif2img=async function(e){return m.isMac?(0,y.sips2jpeg_)(e):await S()?(0,g.heif2png_)(e):void v().throw("HEIF support is missing",{src:e.nativePath})},(0,r.later)((()=>(0,d.ee)().on("clearCache",(()=>t.getHeifSupportDetails.unset()))))},91354:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.heif2png_=t.isHeifConvertSupported=t.heifConvertPath=void 0;const n=i(19851),r=i(22573),s=i(42659),a=i(41400),o=i(12168),l=i(50213),u=i(84777),c=i(34102),d=i(8103),h=i(28874),f=i(89782),m=i(13940),p=(0,n.lazy)((()=>(0,l.mkLogger)("img.HeifConvert")));function g(){t.heifConvertPath.unset()}async function y(){return(0,r.notBlank)(await(0,t.heifConvertPath)())}t.heifConvertPath=(0,n.lazy)((async()=>{const e=p().tap({msg:"heifConvertPath",result:await(0,d.pathTo)({tool:"heif-convert",alternativePath:h.Settings.heifConvertPath.valueOrDefault})});return t.heifConvertPath.setTTL(null==e?s.minuteMs:void 0),e})),(0,a.later)((()=>{(0,c.ee)().on("clearCache",g),(0,c.ee)().on("clearToolCache",g)})),t.isHeifConvertSupported=y,t.heif2png_=async function(e){if(await y())return null==await(0,f.dimensions)(e)&&p().throw("heif2png_() failed: no dimensions for "+e),(0,m.withImageCache_)(e,"heif",".png",(t=>async function(e,t){try{await(0,u.stdoutResult_)(h.Settings.heifConvertPath.valueOrDefault,[e.nativePath,t.base],{cwd:t.dir,timeoutMs:h.Settings.taskTimeoutMs.valueOrDefault,ignoreStderr:!0}),await t.clear().isEmptyFile(o.KB)&&p().throw("heif2png_() failed: empty output",{src:e,dest:t})}catch(t){p().throw("heif2png() failed",{error:t,src:e.nativePath})}}(e,t)))}},16047:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHeifMimeType=void 0;const n=i(22573),r=i(54993),s=/^image\/hei[fc]$/i;t.isHeifMimeType=function(e){return!(0,n.blank)(e)&&s.test((0,r.toS)(e))}},13940:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.withImageCache_=t.readableToFile_=t.cachedImageFile_=t.tmpImageFile_=t.rmImageCacheDir=t.imageCacheDir_=t.ImageCacheName=void 0;const n=i(51455),r=i(19851),s=i(42659),a=i(59455),o=i(54993),l=i(50213),u=i(7282),c=i(81168),d=i(37628),h=i(46199),f=i(49776),m=i(77740),p=i(34102),g=i(95696),y=i(17217),v=i(55222),w=i(63870),S=(0,r.lazy)((()=>(0,l.mkLogger)("img.ImgCache")));t.ImageCacheName="image-cache",t.imageCacheDir_=(0,r.lazy)((()=>(b(),g.PosixFile.for((0,f.cacheDir_)()).join(t.ImageCacheName).mkdirp_())));const b=(0,r.lazy)((()=>{f.cacheDir_.watchLater((()=>t.imageCacheDir_.unset()))}));async function P(e,i,n){const r=await(0,t.imageCacheDir_)();i??(i=e.name),n=(0,c.ensurePrefix)(n??e.ext,".");const s=r.join(...function(e){const t=e.statSync({refresh:!0}),i=(0,d.shortFsStringSha)(JSON.stringify({np:(0,u.isTest)()?(0,h.ciSafePath)(e):e.nativePath,size:t?.size,mtime:(0,u.isTest)()?0:t?.mtime}),24);return(0,c.splitEvery)(i.slice(0,24),2,3)}(e));await s.mkdirp_(),await s.utimes();const a=s.join(i+n);return S().debug("cachedImgFile("+e.baseWithGrandparent+")",{desc:i,ext:n,result:a}),a}t.rmImageCacheDir=async function(){if((0,u.isProd)())throw new Error("rmImgCacheDir is for tests");for(const e of(0,a.toA)(await(await(0,t.imageCacheDir_)()).clear().children()))await(0,n.rm)(e.nativePath,{recursive:e.isDirectorySync(),maxRetries:32,retryDelay:250,force:!0});(0,p.ee)().emit("fileChanged"),(0,p.ee)().emit("clearCache")},t.tmpImageFile_=async function(e){const i=await(0,t.imageCacheDir_)(),n=(0,m.getDevEnvFlag)("PS_NO_RANDOM_IMAGE_CACHE")?i.join("tmp",(0,y.basename)(e.src.dir).normalize(),e.src.name.normalize(),e.tag+e.ext):i.join("tmp-"+v.TokenRadix.randomChars(2),v.TokenRadix.randomChars(16)+(0,o.toS)(e.ext));return await n.parent().mkdirp_(),n},t.cachedImageFile_=P,t.readableToFile_=async function({src:e,desc:t,suffix:i,f:n}){return(await P(e,t,i)).applyIfEmpty_({fn_:n,timeoutMs:2*s.minuteMs})},t.withImageCache_=async function(e,t,i,n){try{const r=await P(e,t,i);return await r.applyIfEmpty_({fn_:n,skipFsLock:!1,skipWip:!1,timeoutMs:(0,w.commandTimeoutMs)(),minSizeBytes:256,dirty:!0}),r}catch(n){return S().throw("withImgCache_() failed",{error:n,src:e.nativePath,desc:t,ext:i})}}},48368:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HashDim=t.toImageHash=t.isImageHash=t._imageHash_=t.imageHash_=t.imageHash=t.maxPerBits=void 0;const r=n(i(9288)),s=i(19851),a=i(40958),o=i(22573),l=i(42659),u=i(33374),c=i(56038),d=i(85810),h=i(76490),f=i(40401),m=i(86758),p=i(85434),g=i(96706),y=i(38835),v=i(88561),w=i(95696),S=i(17217),b=i(50213),P=i(23624),M=i(28874),_=i(12089),E=i(16170),x=i(1078),T=i(33106),D=i(86580),k=i(78011),C=i(50961);t.maxPerBits=function(e){return Math.floor(52/e)};const F=(0,s.lazy)((()=>(0,b.mkLogger)("img.ImageHash")));t.imageHash=async function(e){try{return await(0,t.imageHash_)((0,S.toNativePath_)(e))}catch(t){return void F().warn("imageHash() failed for "+e,t)}};const O=(0,s.lazy)((()=>new v.FileCache({name:"img.imageHash",timeoutMs:l.minuteMs})));async function I(e){const t=w.PosixFile.for(e),i=await(0,x.extractSizeInfoFromFile)(t);if(null==i)throw new Error("Failed to read dimensions for "+e+y.NonFatalErrorFlag+y.DoNotSendErrorFlag);const n=(0,D.fitToResolution)(i.dimensions,Math.round(M.Settings.dominantColorPixels.valueOrDefault)),s=await(0,C.sharpReadable_)({src:t,minDim:n});return(0,c.time)("img.imageHash",(()=>async function({file:e,readable:t,sizeInfo:i}){const n=(0,b.mkLogger)("ImageHash("+e+")");if(null==t)return n.throw("Cannot build readable stream");const s=(0,D.fitToResolution)(i.dimensions,M.Settings.dominantColorPixels.valueOrDefault);if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-orig.jpg";await(0,C.toSharp)(t).jpeg().toFile(i),console.log({out:i,readable:t})}let a=(0,C.toSharp)(t).removeAlpha();(0,E.isVideoMimeType)(t.mimetype)||(a=a.rotate(i.rotation)),(0,u.dmegapixels)(i.dimensions)<.1&&(a=a.trim({background:"#000",threshold:0})),a=a.resize({fit:r.default.fit.outside,...s,withoutEnlargement:!0});const{data:o,info:l}=await a.raw().toBuffer({resolveWithObject:!0});if((0,g.isEnvTrue)("DEBUG_IMAGE_HASH")){const i="/tmp/image-hash-"+e.base+"-"+l.width+"w.jpg";await(0,r.default)(o,{raw:{...l,channels:3}}).jpeg().toFile(i),console.log({out:i,rgbInfo:l,readable:t})}const c=(0,d.rgb2labTriplets)(o),h=(0,f.extractDominantColors)(c),p=(0,m.labsAreGreyscale)(c),y=()=>(0,r.default)(o,{raw:{...l,channels:3}}),v=await(p?k.meanDiffHash:k.meanDiffHashCIELAB)(y()),w=await(p?T.dctHash:T.dctHashCIELAB)(y());return{meanHash:(0,P.b64encodeBits)(v.meanHash),diffHash:(0,P.b64encodeBits)(v.diffHash),dctHash:(0,P.b64encodeBits)(w),dominantColors:h.dominantColors,dominantColorsDescription:h.description,dominantColorScore:h.dominantColorScore,isGreyscale:p,mimetype:(0,E.normalizeMimetype)(t.mimetype),...i.dimensions,rotation:i.rotation??0}}({file:t,readable:s,sizeInfo:i})))}function L(e){return null!=e&&(0,o.notBlank)(e.meanHash)&&(0,o.notBlank)(e.mimetype)&&(0,a.isNotEmpty)(e.dominantColors)}t.imageHash_=(0,_.shim1)({name:"img.imageHash",cache:O,impl:I}),t._imageHash_=I,t.isImageHash=L,t.toImageHash=function(e){if(null!=e){if(L(e))return e;if((0,p.isModeData)(e)){const t={...(0,p.omitModeData)(e),dominantColors:h.DominantColor.fromModeData(e)};if(L(t))return t}}},t.HashDim=8},42725:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.ImageSize=void 0;const a=i(57975),o=i(19851),l=i(33374),u=i(12168),c=i(48884),d=i(28874),h=i(32876),f=i(5733);class m{static sq(){return s(this,n,"f",r).filter((e=>e.reducer===h.Square))}static largestSq(){return(0,c.greatestBy)(this.sq(),(e=>e.megapixels()))}static fit(){const e=d.Settings.previewResolutions.valueOrDefault;return s(this,n,"f",r).filter((t=>t.reducer===h.Fit&&e.includes(t.name)))}static largestFit(){return(0,c.greatestBy)(this.fit(),(e=>e.megapixels()))}static all(){return[...s(this,n,"f",r)]}constructor(e,t,i,a,l=!0){this.name=e,this.maxWidth=t,this.maxHeight=i,this.reducer=a,this.rotational=l,this.megapixels=(0,o.lazy)((()=>(0,u.megapixels)(this.maxWidth*this.maxHeight))),this.max={width:t,height:i},s(n,n,"f",r).push(this)}[a.inspect.custom](){return{ctor:"ImageSize",name:this.name+" ("+this.reducer.name+")",maxDim:this.maxWidth+"×"+this.maxHeight,maxMP:this.megapixels()}}get aspectRatio(){return this.maxWidth/this.maxHeight}get maxPixels(){return this.maxWidth*this.maxHeight}get minDimension(){return Math.min(this.maxWidth,this.maxHeight)}outputSize(e){return this.reducer.reduce(this.rotational&&(0,l.isPortrait)(e)?(0,l.dimSwap)(this.max):this.max,e)}resize(e,t){return t.resize({...e,fit:this.reducer.fit,withoutEnlargement:!0})}toJpeg({path:e,sh:t,outputSize:i}){return((0,l.dmegapixels)(i)<2||d.Settings.previewSharpen.valueOrDefault)&&(t=t.sharpen()),t.jpeg((0,f.sharpRenderOptions)()).toFile(e)}toString(){return this.name}}t.ImageSize=m,n=m,r={value:[]},m.UHD8k=new n("uhd8k",7680,4320,h.Fit,!1),m.UHD5k=new n("uhd5k",5120,2880,h.Fit,!1),m.UHD=new n("uhd4k",4096,2160,h.Fit),m.QHD=new n("qhd",3120,1440,h.Fit),m.FHD=new n("fhd",1920,1080,h.Fit),m.HD=new n("hd",1280,720,h.Fit),m.WVGA=new n("wvga",720,480,h.Fit),m.QVGA=new n("qvga",320,240,h.Fit),m.QQVGA=new n("qqvga",160,120,h.Fit),m.S480=new n("s480",480,480,h.Square),m.S240=new n("s240",240,240,h.Square),m.S120=new n("s120",120,120,h.Square),m.S60=new n("s60",60,60,h.Square)},4192:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includePreviewTags_=void 0;const n=i(19851),r=i(40958),s=i(68708),a=i(50213),o=i(56038),l=i(28874),u=i(47783),c=(0,n.lazy)((()=>(0,a.mkLogger)("img.includePreviewTags")));t.includePreviewTags_=async function(e,t){!1===l.Settings.includePreviewTags.valueOrDefault||l.Settings.includedPreviewTags.isEmpty()||(0,r.isEmpty)(t)||(c().info("Re-adding metadata to previews..."),await(0,o.time)("img.includePreviewTags",(async()=>{const i=(0,s.pick)(await(0,u.readTags)(e),...l.Settings.includedPreviewTags.values),n=i?.capturedAt;null!=n&&(delete i.capturedAt,(0,s.assignFields)(i,n.asExifTag()));const r=i?.exposureSettings;null!=r&&(delete i.exposureSettings,i.FocalLength=r.focalLength,i.FNumber=r.aperture,i.ExposureTime=r.shutterSpeed,i.ISO=r.iso),l.Settings.includedPreviewTags.has("Source")&&(i.Source=e.nativePath),(0,s.isEmptyObj)(i)?c().warn("not adding tags to previews: no values for tags in source file",{src:e,includedPreviewTags:l.Settings.includedPreviewTags.values}):(c().info("Overwriting preview tags...",{src:e,writeTags:i}),await Promise.all(t.map((e=>(0,u.overwriteTags_)(e,i)))))})))}},78011:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.meanDiffHashCIELAB=t.meanDiffHash=t.dhash=t.mhash=void 0;const r=n(i(9288)),s=i(96249),a=i(59455),o=i(85810),l=i(70417),u=i(48368);function c(e){const t=(0,l.avg)(e);return null==t?[]:(0,a.toA)(e).map((e=>e>=t?1:0))}function d(e){const t=(0,a.toA)(e),i=Math.round(Math.sqrt(t.length));return t.map(((t,n)=>t>=(0===n?e[i]:n%i==0?e[n-i]:e[n-1])?1:0))}t.mhash=c,t.dhash=d,t.meanDiffHash=async function(e,t=u.HashDim){const i=await e.greyscale().resize({fit:r.default.fit.fill,width:t,height:t}).raw().toBuffer();return{meanHash:c(i),diffHash:d(i)}},t.meanDiffHashCIELAB=async function(e,t=u.HashDim){const i=await e.resize({fit:r.default.fit.fill,width:t,height:t}).raw().toBuffer(),n=(0,o.rgb2labArray)(i);return{meanHash:(0,s.flatten)(n.map(c)),diffHash:(0,s.flatten)(n.map(d))}}},52121:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t._prepFileForBrowser=t.prepFileForBrowser=void 0;const n=i(19851),r=i(78923),s=i(95696),a=i(50213),o=i(28874),l=i(12089),u=i(16170),c=i(13940),d=i(4192),h=i(5733),f=i(50961),m=(0,n.lazy)((()=>(0,a.mkLogger)("img.PrepareFileForBrowser")));async function p(e){try{const t=s.PosixFile.for(e.nativePath);if(await t.notExists())return;const i=e.mimetype??(await(0,r.readFileType_)(t.nativePath))?.mime;return(0,u.isMimeTypeSupportedByBrowser)(i,e.userAgent)?t.nativePath:(m().info("prepFileForBrowser(): non-browser-supported mimetype",{file:t,info:e}),(await(0,c.withImageCache_)(t,"web",".jpg",(async e=>{const i=await(0,f.sharpReadable_)({src:t});if(null==i)throw new Error("prepFileForBrowser(): can't read "+t.nativePath);await(0,f.toSharp)(i).jpeg((0,h.sharpRenderOptions)()).toFile(e.nativePath),o.Settings.includePreviewTags.valueOrDefault&&await(0,d.includePreviewTags_)(t,[e])})))?.nativePath)}catch(e){return void m().warn("prepFileForBrowser() failed",{error:e})}}t.prepFileForBrowser=(0,l.shim1)({name:"img.prepFileForBrowser",impl:p}),t._prepFileForBrowser=p},48604:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.buildAssetPreviews_=t.Previews=void 0;const n=i(19851),r=i(55835),s=i(50213),a=i(12089),o=i(87290),l=i(95242),u=i(16524);class c{constructor(e){this.root=e}apb(e,t,i){return new l.AssetPreviewBuilder(this.ap(e),t,i)}ap(e){return new u.AssetPreviews(this.root,e)}}t.Previews=c,c.instance=(0,n.lazy)((()=>((0,s.mkLogger)("Previews").info(".instance()",{libraryPreviewsDir:(0,o.libraryPreviewsDirPosixFile)()}),(0,r.map)((0,o.libraryPreviewsDirPosixFile)(),(e=>new c(e)))))),t.buildAssetPreviews_=(0,a.shim1)({name:"img.buildAssetPreviews",impl:e=>c.instance().apb(e.assetId,e.assetFiles,e).build_()})},2090:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtAspectRatio=t.roundAspectRatio=t.similarRatiosWithRotation=t.similarRatios=t.roundToNearestRatio=t.RatioEpsilon=t.StandardAspectRatios=t.Ratios=void 0;const n=i(40958),r=i(33374),s=i(31586),a=i(34666),o=i(48884),l=i(97352);function u(e,i=2*t.RatioEpsilon){return(0,l.mapGt0f)((0,s.isNumber)(e)?e:((0,s.toGt0)(e.width)??0)/((0,s.toGt0)(e.height)??0),(e=>(0,o.leastBy)(t.StandardAspectRatios,(t=>{const n=Math.abs(e-t);return n>i?void 0:n}))??e))}function c(e,i,n=t.RatioEpsilon){return(0,a.lt)((0,s.absdiff)(u(e),u(i)),n)}function d(e,i){return(0,o.leastByCtx)(t.Ratios,(t=>{const n=Math.abs(t.i-e);return n[{i:e/t,s:e+":"+t},{i:t/e,s:t+":"+e}])),(e=>e.s)),t.StandardAspectRatios=t.Ratios.map((e=>e.i)),t.RatioEpsilon=.045,t.roundToNearestRatio=u,t.similarRatios=c,t.similarRatiosWithRotation=function(e,t,i=.05){return c((0,r.maybeDimSwap)(e.dimensions,e.rotation),(0,r.maybeDimSwap)(t.dimensions,t.rotation),i)},t.roundAspectRatio=function(e,t=.05){return d(e,t)?.result.i??e},t.fmtAspectRatio=function(e,t=.05){return d(e,t)?.result.s??String((0,s.sigFigs)(e,3))}},34943:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseRawInfoOutput_=t.rawInfo_=t.rawInfo=void 0;const n=i(19851),r=i(31586),s=i(80049),a=i(50213),o=i(45255),l=i(84777),u=i(34102),c=i(41080),d=i(89966),h=(0,n.lazy)((()=>(0,a.mkLogger)("img.RawInfo"))),f=(0,n.lazy)((()=>new s.FifoCacheAsync({maxSize:512,name:"img.RawInfoCache",timeoutMs:o.ShortCommandTimeoutMs})));async function m(e){return f().getOrSetAsync(e.nativePath,(async()=>{const t=await(0,d.rawIdentifyNativePath_)();return p(await(0,l.stdout_)(t,["-s",e.nativePath],{timeoutMs:(0,c.statTimeoutMs)()}))}))}function p(e){const[t,i,n,s,a]=e.split("\t"),o=(0,r.toGt0)(s),l=(0,r.toGt0)(a);return null==o||null==l?h().throw("parseRawInfoOutput_ failed (missing dimensions)",{cause:e}):h().tap({msg:"parseRawInfoOutput()",result:{Filename:t,Make:i,Model:n,ImageSize:{width:o,height:l}},meta:{input:e}})}(0,u.ee)().on("clearCache",(()=>f.prior()?.clear())),(0,u.ee)().on("fileChanged",(e=>null==e?f.prior()?.clear():f.prior()?.delete(e))),t.rawInfo=async function(e){return m(e).catch((t=>{h().warn("rawInfo() failed",{error:t,src:e})}))},t.rawInfo_=m,t.parseRawInfoOutput_=p},32876:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Reducers=t.Fit=t.fitInsideToMaxPixels=t.fitInsideToAspectRatio=t.Square=t.SharpFits=void 0;const n=i(19851),r=i(33374),s=i(4188),a=i(11371),o=i(31586),l=i(68708),u=i(50989),c=i(50213),d=i(86580);var h,f;t.SharpFits=(0,u.strEnum)("cover","contain","fill","inside","outside"),function(e){const i=(0,n.lazy)((()=>(0,c.mkLogger)("img.Reducers.Square")));e.name=a.ReducerNames.sq,e.fit="cover",e.reduce=function(e,n){const r=(0,d.lteBoth)(e,n)?{...e,fit:t.SharpFits.cover}:void 0;return i().tap({msg:"reduce()",result:r,meta:{max:e,input:(0,l.pick)(n,"width","height","nativePath")}})}}(h||(t.Square=h={})),t.fitInsideToAspectRatio=function(e,t){return e.width/e.height>=t?{width:Math.floor(e.height*t),height:e.height}:{width:e.width,height:Math.floor(e.width/t)}},t.fitInsideToMaxPixels=function(e,t){if(null==e||!(0,o.gt0)(e.width)||!(0,o.gt0)(e.height))return;if((0,r.pixels)(e)(0,c.mkLogger)("img.Reducers.Fit")));e.name=a.ReducerNames.fit,e.fit="inside",e.reduce=function(e,i){if(!(0,d.ltBoth)(i,e))return(0,s.fitInside)(i,e);t().trace(`reduce(): input ${(0,r.fmtDim)(i)} is too small for ${(0,r.fmtDim)(e)}`)}}(f||(t.Fit=f={})),t.Reducers=[h,f]},5733:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setupSharp=t.sharpRenderOptions=t.sharpFromRawBuffer=t.sharpClone=t.isSharp=void 0;const r=n(i(9288)),s=i(19851),a=i(41400),o=i(50213),l=i(28874),u=i(15674),c=(0,s.lazy)((()=>(0,o.mkLogger)("img.Sharp")));function d(e,t){return(0,r.default)(e,{raw:t})}t.isSharp=function(e){return"object"==typeof e&&"function"==typeof e.jpeg&&"function"==typeof e.raw&&"function"==typeof e.toBuffer},t.sharpClone=async function(e){try{return e.clone()}catch(e){c().info("sharp.clone() failed",e)}try{const{data:t,info:i}=await e.raw().toBuffer({resolveWithObject:!0});return d(t,i)}catch(e){return c().throw("clone via sharp.raw().toBuffer() failed",{error:e})}},t.sharpFromRawBuffer=d,t.sharpRenderOptions=function(){return{quality:l.Settings.previewQuality.valueOrDefault,progressive:l.Settings.previewProgressive.valueOrDefault,mozjpeg:l.Settings.previewMinimized.valueOrDefault}},t.setupSharp=(0,s.lazy)((()=>{r.default.simd(l.Settings.enableSIMD.valueOrDefault),r.default.cache(!!l.Settings.enableVipsCache.valueOrDefault&&{files:32,memory:64,items:128}),r.default.concurrency((0,u.sharpThreadsPerProcess)())})),(0,a.later)((()=>{l.Settings.enableSIMD.watchLater((()=>t.setupSharp.refresh())),l.Settings.enableVipsCache.watchLater((()=>t.setupSharp.refresh()))}))},48584:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const n=i(50989);t.SharpFailOns=(0,n.strEnum)("none","truncated","error","warning")},50961:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.extractImageForThumbs_=t.sharpReadable_=t.toSharp=t.imgFromExif_=t._imgFromExif_=void 0;const r=i(77988),s=n(i(9288)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(33374),d=i(98553),h=i(31586),f=i(68708),m=i(51926),p=i(41583),g=i(50213),y=i(97352),v=i(56519),w=i(56038),S=i(57159),b=i(95696),P=i(17217),M=i(28874),_=i(47783),E=i(16170),x=i(95141),T=i(54979),D=i(1078),k=i(63870),C=i(86580),F=i(277),O=i(16047),I=i(13940),L=i(5733),A=i(66106),R=i(19350),N=(0,a.lazy)((()=>(0,g.mkLogger)("img.SharpReadable")));async function B(e,t,i){return i?await(0,_.exiftool)().extractBinaryTagToBuffer(t,e.nativePath):(await j(e,t))?.nativePath}async function z(e,t,i,n,a){const o=t?.[i];if(!(o instanceof r.BinaryField))return;const l=o.bytes(0,_.extractBinaryTag)(t,e.nativePath,i.nativePath),timeoutMs:(0,k.commandTimeoutMs)()})}catch(i){return void N().throw("Failed to extract embedded "+t+" from "+e.nativePath,{error:i})}}t._imgFromExif_=B,t.imgFromExif_=z,t.toSharp=function(e){const t=e;if((0,L.isSharp)(t.sharp))return t.sharp;if((0,P.isSimpleFile)(t.file))return(0,s.default)(t.file.nativePath,{failOn:M.Settings.imageFailOn.valueOrDefault});throw new Error("toSharp(): not a Sharp object: "+(0,d.stringify)(e))},t.sharpReadable_=function(e){return(0,w.time)(`img.sharpReadable${e.src.ext.toUpperCase()}`,(()=>async function({src:e,minDim:t,skipEmbedded:i}){const n=N().addParameterContext(e.nativePath);(0,L.setupSharp)();const s=await(0,T.readMimeType)(e);if((0,u.blank)(s))return n.throw(e+" is not supported (missing MIMEType)",{doNotSend:!0});const a=await(0,D.extractSizeInfoFromFile)(e);if(null==a)return void n.warn("Failed to extract size info from "+e);const d=[];function f(e,t){t.desc=e,d.push(t)}const m=a.rotation,g=(0,E.isVideoMimeType)(s),b=(0,E.isLibrawMimeType)(s),P=a.dimensions,k=t??(0,y.map2Gt0)(P.width,P.height,((e,t)=>({width:Math.round(.9*e),height:Math.round(.9*t)})));if(null==k?.width||null==k?.height)return n.throw(e+" is not supported (missing dimensions)",{dim:k,doNotSend:!0,mimetype:s,isRaw:b,isVideo:g});const I=(0,C.aspectRatio)(a.fileDimensions),B=(0,h.lt)(I,1),j=(0,E.isSharpMimeType)(s)&&null==t,V=(0,x.orientationRequiresMirroring)(a.orientation);if(!0===i||g||B||j||V)n.debug("not pulling previews from tags",{isVideo:g,isFilePortrait:B,isSharpMimeAndNoMinDim:j,isMirrorOrientation:V});else{const i=!1,s=await(0,_.readRawTags)(e,i);if(null==s)n.warn("Cannot pull previews from tags: readRawTags() failed");else{const i=[...M.Settings.embeddedPreviews.values];null!=t&&(0,c.dmegapixels)(t)<1&&i.unshift(...M.Settings.embeddedThumbnails.values);const a=k.width*k.height*.2,u=k.width*k.height*.05,d=(0,l.sortBy)(i.filter((e=>s[e]instanceof r.BinaryField)),(e=>{const t=s[e]?.bytes;return(0,h.gt)(t,u)?Math.abs(t-a):void 0}));if(!(0,o.isEmpty)(d)){n.debug("checking previews from tags",{sizeSortedTagNames:d});for(const t of d)f("imgFromExif."+t,(()=>z(e,s,t,k,I)))}}}(0,E.isSharpMimeType)(s)&&f("sharp",(async()=>({file:e}))),(0,O.isHeifMimeType)(s)&&await(0,F.isHeifSupported)()&&f("heif",(()=>(0,v.thenMap)((0,F.heif2img)(e),(e=>({file:e}))))),b&&f("raw2tiff",(()=>(0,v.thenMap)((0,R.raw2tiff_)(e),(e=>({file:e}))))),g&&f("extractVideoFrame",(async()=>{if(await(0,A.isVideoSupported)())try{return await(0,v.thenMap)((0,A.extractVideoFrame_)(e),(e=>({file:e})))}catch(t){throw new S.WrappedError("Failed to extract video frame for "+e,t)}else n.warn("video file, but video support is missing",{src:e.nativePath,mimetype:s,minDim:t})}));const W=[];for(const i of d)try{const r=await(0,w.time)("img.read."+i.desc,i);if(null!=r)return n.debug(i.desc+" strategy succeeded",{src:e,minDim:t,rot:m,img:r.file?.nativePath}),{desc:i.desc,rot:m,mimetype:s,...r};n.debug(i.desc+" returned null",{src:e,minDim:t,rot:m})}catch(e){n.warn(i.desc+" failed",e),W.push((0,p.toErr)(e))}throw new S.WrappedError("Failed to render "+e,{causes:W,path:String(e),fatal:!1,doNotSend:!0,retriable:!1})}(e)))},t.extractImageForThumbs_=j},181:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.whyInvalidFile=t.clearInvalidFileCache=t.throwIfInvalidFile_=t.isValidFile=void 0;const r=n(i(9288)),s=i(19851),a=i(22573),o=i(42659),l=i(98553),u=i(50213),c=i(12089),d=i(81168),h=i(57159),f=i(88561),m=i(95696),p=i(17217),g=i(28874),y=i(16170),v=i(54979),w=i(63870),S=i(5733),b=i(50961),P=i(66106),M=i(51210),_=(0,s.lazy)((()=>(0,u.mkLogger)("img.ValidFile")));t.isValidFile=async function(e){return(0,a.blank)(await(0,t.whyInvalidFile)((0,p.toNativePath_)(e)))},t.throwIfInvalidFile_=async function(e){if(!g.Settings.validateJpegImages.valueOrDefault&&!g.Settings.validateRawImages.valueOrDefault&&!g.Settings.validateVideos.valueOrDefault)return void _().debug("file validation is disabled for "+e,{validateJpegImages:g.Settings.validateJpegImages.valueOrDefault,validateRawImages:g.Settings.validateRawImages.valueOrDefault,validateVideos:g.Settings.validateVideos.valueOrDefault});const i=(0,p.toNativePath_)(e),n=_().tap({msg:"whyInvalidFile("+i+")",result:await(0,t.whyInvalidFile)(i)});(0,a.notBlank)(n)&&_().throw(n,{path:i,retriable:!1,doNotSend:!0,ignorable:!0})};const E=(0,s.lazy)((()=>new f.FileCache({name:"img.validFile",maxSize:256,timeoutMs:Math.max(o.minuteMs,g.Settings.validateVideos.valueOrDefault?5*o.minuteMs:(0,w.commandTimeoutMs)())})));t.clearInvalidFileCache=function(){return E().clear()},t.whyInvalidFile=(0,c.shim1)({name:"img.whyInvalidFile",cache:E,toKey:p.toNativePath_,impl:async e=>{const t=m.PosixFile.for(e);if(!await t.isFile()||!await t.isReadable())return t+" is not a readable file";if(await t.isEmpty())return t+" is empty";try{const e=await(0,v.readMimeType)(t);if(null==e)throw new Error("Cannot validate, no mimetype");if((0,y.isVideoMimeType)(e))g.Settings.validateVideos.valueOrDefault&&(_().debug("validating "+t),await(0,P.validVideo_)(t));else{if(!e.startsWith("image/"))throw new Error("Unsupported mimetype "+(0,l.stringify)(e));if("image/jpeg"===e)g.Settings.validateJpegImages.valueOrDefault&&await(0,M.validJpeg_)(t);else if(g.Settings.validateRawImages.valueOrDefault)if((0,d.includesIgnoreCase)(g.Settings.validateMimetypeSkiplist.values,e))_().info("Skipping validation of "+t+": validateMimetypeSkiplist matches",{mime:e});else{const e=await(0,b.sharpReadable_)({src:t,skipEmbedded:!0}),i=await async function(e,t=g.Settings.imageFailOn.valueOrDefault){const i=e;if((0,p.isSimpleFile)(i.file))return(0,r.default)(i.file.nativePath,{failOn:t});if((0,S.isSharp)(i.sharp)){const{data:e,info:t}=await i.sharp.raw().toBuffer({resolveWithObject:!0});return(0,r.default)(e,{...t,failOnError:!0})}throw new Error("Cannot read input "+e?.desc)}(e);await i.tiff().toBuffer()}}return""}catch(t){return new h.WrappedError("Failed to validate",{cause:t,path:e,doNotSend:!0}).toS()}}})},19769:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isIgnorableValidationError=void 0;const n=i(19851),r=i(40958),s=i(41400),a=i(50213),o=i(68852),l=i(98314),u=i(28874),c=(0,n.lazy)((()=>(0,a.mkLogger)("img.ValidationError")));t.isIgnorableValidationError=function(e){const t=(0,l.errorToS)(e);return c().tap({msg:"isIgnorableValidationError",level:"info",result:h().test(t)||!d().test(t),meta:{err:e,allow:h().test(t),block:d().test(t),validationErrorAllowlist:h().source,validationErrorBlocklist:d().source}})};const d=(0,n.lazy)((()=>(0,o.orRegExpPatterns)((0,r.compactBlanks)(u.Settings.validationErrorBlocklist.values),"i"))),h=(0,n.lazy)((()=>(0,o.orRegExpPatterns)((0,r.compactBlanks)(u.Settings.validationErrorAllowlist.values),"i")));(0,s.later)((()=>{u.Settings.validationErrorBlocklist.watchLater((()=>d.unset())),u.Settings.validationErrorAllowlist.watchLater((()=>h.unset()))}))},66106:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validVideo_=t.guessExpectedSize=t.transcode_=t.needsTranscoding=t.isVideoTranscodingSupported=t.__extractVideoFrame_=t._extractVideoFrame_=t.extractVideoFrame_=t.bitrateKps=t.isVideoSupported=t.getVideoToolDetails_=void 0;const n=i(19851),r=i(40958),s=i(38639),a=i(42659),o=i(41400),l=i(4188),u=i(31586),c=i(34666),d=i(50213),h=i(7282),f=i(97352),m=i(12089),p=i(81168),g=i(75387),y=i(22911),v=i(56038),w=i(31562),S=i(34102),b=i(88561),P=i(95696),M=i(17217),_=i(31843),E=i(70417),x=i(33847),T=i(28874),D=i(94678),k=i(43207),C=i(47783),F=i(16170),O=i(95141),I=i(1078),L=i(63870),A=i(89782),R=i(13940),N=i(34592),B=(0,n.lazy)((()=>(0,d.mkLogger)("img.Video")));function z(e,t){return(0,d.mkLogger)("img/Video."+e+"("+t+")")}async function j(e){return(0,h.isProd)()&&(e=void 0),(0,s.isTrue)(e?.ignoreffmpeg)?void 0:await(0,N.ffmpegVersion_)()}t.getVideoToolDetails_=j,t.isVideoSupported=(0,n.lazy)((async()=>{try{return!0===(await j())?.isSupportedVersion}catch(e){return B().warn("isVideoSupported",{error:e}),!1}})),(0,o.later)((()=>(0,S.ee)().on("clearCache",(()=>t.isVideoSupported.unset())))),t.bitrateKps=e=>(0,u.sigFigs)((0,_.lerp2d)(e,{x:76800,y:T.Settings.transcodeBitrateQVGA.valueOrDefault},{x:8294400,y:T.Settings.transcodeBitrateUHD.valueOrDefault}),2);const V=(0,n.lazy)((()=>new b.FileCache({name:"img.videoFrame",timeoutMs:a.minuteMs})));async function W(e){return await(0,t.isVideoSupported)()?P.PosixFile.for(await(0,t._extractVideoFrame_)((0,M.toNativePath_)(e))):void 0}async function H(e,t){const i=z("extractVideoFrame",e),n=P.PosixFile.for(e);if(!(0,s.isTrue)(t?.useFfmpeg)&&!await(0,N.isFFmpegSupported)())return i.throw("no video implementation");const r=await(0,R.cachedImageFile_)(n,"frame",".jpg");i.debug("extractVideoFrame("+r+")");const o=await n.mtimeMs();if(null==o)return i.throw("null mtime");const l=await(0,C.readRawTags)(n,!1);if(null==l)return i.throw("no tags");const u=(0,O.extractRotation)(l);i.debug("video orientation:"+u);const c=(0,I.extractSizeInfoFromTags)(l,u)?.dimensions,d=await r.stat(),h=null==d?void 0:await(0,A.dimensions)(r);if(null!=d&&d.mtimeMs>o&&null!=h&&(null==c||h.height===c.height&&h.width===c.width))return i.debug("prior dest, "+r+" seems reasonable",{srcDim:c,destDim:h}),r.nativePath;const f=(0,k.extractDurationSec)(l),m=Math.min(f??0,T.Settings.videoFrameAtSec.valueOrDefault);return i.info("extracted metadata",{startAtSec:m,duration:f}),await r.applyIfEmpty_({fn_:async e=>{const t={src:n,dest:e,startAtSec:m,...c};await(0,N.ffmpegFrame_)(t),!1===await(0,w.untilTrue)((async()=>i.tap({msg:"frame extracted?",result:await e.clear().isNonEmptyFile()})),{timeoutMs:5*a.secondMs,intervalMs:500})&&i.throw("ffmpeg failed to extract frame"),await(0,C.deleteAllTags_)(e,e)},timeoutMs:(0,L.commandTimeoutMs)()}),r.nativePath}async function U(){return T.Settings.transcodeVideos.valueOrDefault&&await(0,N.isFFmpegSupported)()}async function q(e){const t=z("needsTranscoding",e);if(!await U())return t.tap({msg:"videoTranscodingSupported is false",result:!1});const i=await(0,C.readRawTags)(e);if(null==i)return t.tap({msg:"Cannot transcode files that exiftool can't read",result:!1});const n=i.MIMEType;if(!(0,F.isVideoMimeType)(n))return t.tap({msg:"not transcoding (unsupported mimetype)",result:!1,meta:{mimetype:n}});const s=(0,k.extractDurationSec)(i);if(!(0,c.gt)(s,T.Settings.minVideoDurationSec.valueOrDefault))return t.tap({msg:"not transcoding (video duration is too short)",result:!1,meta:{duration:s}});const a=(0,r.compactBlanks)([i.AudioFormat]),o=a.some((e=>(0,p.includesIgnoreCase)(T.Settings.doNotTranscodeAudioCodecs.values,e))),l=(0,r.compactBlanks)([i.VideoCodec,i.CompressorID,i.CompressorName]),u=l.some((e=>(0,p.includesIgnoreCase)(T.Settings.doNotTranscodeVideoCodecs.values,e))),d=(0,p.includesIgnoreCase)(T.Settings.doNotTranscodeMimeTypes.values,n);return t.tap({level:"info",msg:"result",result:!(o&&u&&d),meta:{mimetype:n,isSafeMimeType:d,audioCodecs:a,isSafeAudioCodec:o,videoCodecs:l,isSafeVideoCodec:u}})}t.extractVideoFrame_=W,t._extractVideoFrame_=(0,m.shim1)({name:"img.extractVideoFrame",cache:V,impl:e=>H(e)}),t.__extractVideoFrame_=H,t.isVideoTranscodingSupported=U,t.needsTranscoding=q;const G=new g.TTLMap(a.hourMs);function $(e,t,i){return Math.min(e,(i??10)*(t??1e3))}t.transcode_=async function(e,i,n){if(!await U())return;const r=z("transcode",e);{!function(){for(const[e,t]of G.entries())t.isSettled&&G.delete(e)}();const t=G.get(e.nativePath)??G.get(i.nativePath);if(null!=t)return r.info("already transcoding",{dest:i,elapsedMs:t.elapsedMs,priorSrc:t.name}),t}if(!1===await q(e))return void r.info("no transcoding needed");const s=await e.size();if(!(0,u.gt0)(s))return r.throw("source is empty or cannot read");const a=await(0,C.readTags)(e),o=(0,I.extractSizeInfoFromTags)(a),d=(0,k.extractDurationSec)(a);if(null==a||null==o||null==d)return r.throw("failed: missing video metadata",{sizeInfo:o,durationSec:d});{const e=G.get(i.nativePath);if(null!=e)return r.info("already transcoding",{dest:i,elapsedMs:e.elapsedMs,priorSrc:e.name}),e}const h=new y.Deferred("transcode "+e);G.set(e.nativePath,h),G.set(i.nativePath,h);const m=(0,u.toGt0)(a.VideoFrameRate)??(0,u.toGt0)(a.FrameRate)??30,p=Math.round(o.dimensions.width*o.dimensions.height*(0,E.max)([(0,u.toGt0)(a.FrameCount),(0,u.toGt0)(a.VideoFrameCount),m*d]));if(!0===n?.force)await i.unlink();else if(await async function(e,t){const i=await(0,C.readRawTags)(t),n=await(0,C.readRawTags)(e),r=(0,k.extractDurationSec)(n),s=(0,k.extractDurationSec)(i);return B().tap({msg:"isTranscodeOf()",result:(0,u.closeTo)(r,s,1.5),meta:{srcDurationSec:r,destDurationSec:s,src:e.nativePath,dest:t.nativePath}})}(e,i))return r.info("no-op, dest duration looks reasonable",{dest:i}),i;const g=function(e,i){const n=z("extractMaxBitrate",e),r=T.Settings.minVideoDimension.valueOrDefault,s=i.ImageWidth;if(null!=s&&!(0,u.gte)(s,r))return n.throw("invalid width: "+s,{ignorable:!0});const a=i.ImageHeight;if(null!=a&&!(0,u.gte)(a,r))return n.throw("invalid height: "+a,{ignorable:!0});const o=(0,D.extractBitrateKbps)(i)??T.Settings.transcodeBitrateUHD.valueOrDefault,l=(0,f.mapGt0)(s,(e=>(0,f.mapGt0)(a,(i=>(0,u.clamp)(0,o,(0,t.bitrateKps)(e*i)))))),c={width:s,height:a,videoBitrateKbps:l};return n.debug("dim()",{src:e,result:c}),c}(e,a);return await h.observe((0,v.time)("video.transcode:"+e,(async()=>{const t=$(s,g.videoBitrateKbps,d);return await i.applyWip_({fn_:s=>async function(s){r.info("starting...",{destWip:s});const o=new x.PullProgressObserver({path:e.nativePath,op:"Transcoding video"},t,(async()=>await i.clear().size()??0)),d={src:e,dest:s,fps:m,halt:n.halt,...g},h=T.Settings.transcodeMaxDim.valueOrDefault,f=(0,E.max)([a.dimensions.height,a.dimensions.width]);if((0,u.gt0)(h)&&(0,c.gt)(f,h)){const e=(0,l.fitInside)(a.dimensions,{width:h,height:h});null==e?r.warn("Cannot downsample transcoded video: fitInside() returned null",{input:a.dimensions,maxPixels:h}):(d.width=(0,u.roundEven)(e.width),d.height=(0,u.roundEven)(e.height),r.info("Downsampling transcoded video",{original:a.dimensions,output:e}))}const p=await o.observe((0,N.ffmpegTranscode_)(d));0!==p.code&&r.throw("transcode failed with code "+p.code)}(s),skipFsLock:!1,timeoutMs:0}),i}))),(0,u.gt0)(p)&&r.info("transcode complete",{src:e,dest:i,elapsedMs:h.elapsedMs,pixels:p}),i},t.guessExpectedSize=$,t.validVideo_=async function(e){return null==await W(e)&&z("validVideo",e).throw("Could not extract a video frame"),(0,N.ffmpegValidVideo_)(e)}},34592:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ffmpegValidVideo_=t.ffmpegTranscode_=t.avcArgs=t.ffmpegFrame_=t.isFFmpegSupported=t.ffmpegVersion_=t.ffmpegVersionDescription=t.ffmpegNativePath=void 0;const n=i(40958),r=i(22573),s=i(38639),a=i(42659),o=i(41400),l=i(31586),u=i(19851),c=i(50213),d=i(97352),h=i(56519),f=i(31562),m=i(84777),p=i(98314),g=i(34102),y=i(8103),v=i(84258),w=i(28874),S=i(76280),b=i(63870),P=i(19769),M=(0,u.lazy)((()=>(0,c.mkLogger)("img.ffmpeg")));function _(){return(0,y.pathTo)({tool:"ffmpeg",alternativePath:w.Settings.ffmpegPath.valueOrDefault})}t.ffmpegNativePath=_;const E=/ffmpeg version n?(?\S+)/i,x=(0,u.lazy)((async()=>{const e=await _();if(null==e)return void M().info("failed to find ffmpeg in $PATH",{ffmpegPath:w.Settings.ffmpegPath.valueOrDefault});const t=await(0,m.stdoutResult_)(e,["-version"],{timeoutMs:(0,b.commandTimeoutMs)(),ignoreStderr:!0}),i=E.exec(t.result)?.[1];return M().debug("ffmpegVersion",{version:i,code:t.code,stdout:t.result.split("\n",1)[0]}),{path:e,version:i??"(unknown)",isSupportedVersion:(0,S.semverSatisfies)(i,">=3.2")}}));function T(){x.unset(),t.ffmpegVersionDescription.unset()}function D(e){const t=e?.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault;return(0,r.blank)(t)||(0,s.isDisabled)(t)?[]:["-hwaccel",t]}function k(e){const t=[...w.Settings.ffmpegAvcTranscodeArgs.values];if(!(0,l.gt0)(e.width)||!(0,l.gt0)(e.height)||!(0,l.gt0)(w.Settings.transcodeMaxDim.valueOrDefault))return t;const i=(0,l.roundEven)(e.width),n=(0,l.roundEven)(e.height);return t.unshift("-s",i+"x"+n),t}function C(e){if(!(0,l.gt0)(e))return[];const t=(0,l.sigFigs)(e,2);return["-b:v",t+"k","-maxrate",t+"k","-bufsize",(0,l.sigFigs)(t/2,2)+"k"]}function F(e){const t=w.Settings.transcodeFrameRate.valueOrDefault;return!(0,l.gt0)(t)||(0,l.lte)(e?.fps,t)?[]:["-r",Math.round(t)]}t.ffmpegVersionDescription=(0,u.lazy)((()=>(0,h.thenMapOr)(x(),(e=>"version "+e),(()=>"(not found)")))),(0,o.later)((()=>{(0,g.ee)().on("clearCache",T),(0,g.ee)().on("clearToolCache",T)})),t.ffmpegVersion_=async function(){return await x.prior()??x.refresh()},t.isFFmpegSupported=async function(){return null!=await x()},t.ffmpegFrame_=async function(e){if(await e.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,n.compact)(["-loglevel","error","-i",e.src.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...(0,d.mapGte0f)(e.startAtSec,(e=>["-ss",e.toFixed(1)]))??[],"-vframes","1","-y",e.dest.nativePath]),{timeoutMs:a.minuteMs,isIgnorableError:P.isIgnorableValidationError}),!await(0,f.untilTrue)((()=>e.dest.clear().isNonEmptyFile()),{timeoutMs:3*a.secondMs}))throw new Error("Failed to extract frame for "+e.src)},t.avcArgs=k,t.ffmpegTranscode_=async function e(t){try{return await t.dest.parent().mkdirp_(),await(0,m.stdoutResult_)(await _(),(0,n.compactBlanks)(["-loglevel","error","-i",t.src.nativePath,...k(t),...F(t),...D(t),"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),...C(t.videoBitrateKbps),t.dest.nativePath]),{halt:t.halt,timeoutMs:t.timeoutMs??0,isIgnorableError:P.isIgnorableValidationError})}catch(i){M().warn("ffmpegTranscode_() failed",{args:t,error:i}),await(0,v.unlink)(t.dest,"debug");const n=(0,p.errorToS)(i,{maxLen:1024});if(!(0,s.isDisabled)(t.ffmpegHwaccel??w.Settings.ffmpegHwaccel.valueOrDefault)&&/hwaccel.*error/i.test(n))return M().warn("ffmpegTranscode_() failed: bad -hwaccel arg? Disabling hwaccel and retrying...",{args:t,error:i}),e({...t,ffmpegHwaccel:"disabled"});throw i}},t.ffmpegValidVideo_=async function(e){return M().tap({msg:"ffmpegValidVideo",meta:{src:e.nativePath},result:await(0,m.stdoutResult_)(await _(),["-v","error","-nostats","-i",e.nativePath,"-threads",String(w.Settings.ffmpegThreads.valueOrDefault),"-f","null","-"],{timeoutMs:0,isIgnorableError:P.isIgnorableValidationError,ignoreExitCode:!0,quiet:!1})})}},51210:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rotate_=t.rotateInPlace_=t.validJpeg_=t.jpegtranVersion_=void 0;const n=i(19851),r=i(42659),s=i(21605),a=i(50213),o=i(84777),l=i(57159),u=i(95696),c=i(89966),d=i(43334),h=i(63870),f=i(19769),m=d.isWin?"NUL":"/dev/null",p=(0,n.lazy)((()=>(0,a.mkLogger)("img.jpegtran")));async function g(e,t,i){const n=await(0,c.jpegtranNativePath_)();if(!(0,s.isRotation)(i))throw new Error("refusing to rotate("+e+", "+i+")");await(0,o.stdout_)(n,["-copy","all","-trim","-rotate",i.toFixed(0),"-outfile",t.nativePath,e.nativePath],{timeoutMs:r.minuteMs}),t.clear()}t.jpegtranVersion_=async function(){const e=await(0,o.stdoutResult_)(await(0,c.jpegtranNativePath_)(),["-version"],{quiet:!0,timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:()=>!0});return(e.stderr??e.result).replace(/^libjpeg-turbo version/,"").trim()},t.validJpeg_=async function(e){const t=u.PosixFile.for(e),i=await(0,c.jpegtranNativePath_)();try{await(0,o.stdoutResult_)(i,["-outfile",m,t.nativePath],{timeoutMs:(0,h.commandTimeoutMs)(),isIgnorableError:f.isIgnorableValidationError,ignoreExitCode:!0})}catch(e){throw p().warn("validJpeg caught invalid file",{src:t,cause:e}),new l.WrappedError("Invalid JPEG: "+t,{cause:e,path:t.nativePath,doNotSend:!0,fatal:!1,retriable:!1})}},t.rotateInPlace_=async function(e,t){p().info("rotateInPlace("+e+")",t),await e.applyWip_({fn_:i=>g(e,i,t),skipFsLock:!1,minSizeBytes:512,timeoutMs:r.minuteMs})},t.rotate_=g},19350:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dcraw_emu_=t.raw2tiff_=t.librawSupported=void 0;const n=i(19851),r=i(40958),s=i(33374),a=i(12168),o=i(23541),l=i(54993),u=i(50213),c=i(84777),d=i(98314),h=i(38835),f=i(57159),m=i(89966),p=i(28874),g=i(16170),y=i(54979),v=i(89782),w=i(13940),S=i(42725),b=i(19769),P=(0,n.lazy)((()=>(0,u.mkLogger)("img.libraw")));t.librawSupported=async function(e){try{return(0,g.isLibrawMimeType)(await(0,y.readMimeType)(e.nativePath))}catch(t){return P().warn("librawSupported("+e+"): failed to read filetype",t),!1}},t.raw2tiff_=async function(e){return(0,w.readableToFile_)({src:e,desc:"dcraw",suffix:".tiff",f:t=>T(e,t)})};const M=["-T"],_=["-Z","-"],E=["-o","1"],x=["-t","0","-j"];async function T(e,t){const i=await(0,v.dimensions)(e);if(null==i)return P().throw("Cannot decode RAW "+e+": no EXIF dimensions."+h.DoNotSendErrorFlag+h.NonRetriableErrorFlag);const n=S.ImageSize.largestFit().outputSize(i),u=[];null!=n&&4*(0,s.dmegapixels)(n)<(0,s.dmegapixels)(i)&&(P().debug("Large original source: using -h"),u.push("-h"));const g=await(0,m.dcrawEmuNativePath_)(),y=[...M,..._,...E,...u,...x,...p.Settings.dcrawEmuArgs.values,e.nativePath],w={encoding:"buffer",timeout:p.Settings.taskTimeoutMs.valueOrDefault,maxBuffer:250*a.MB};P().debug("dcraw_emu()",{cmd:g,args:y,opts:w});const T=(0,c.execFile)(g,y,void 0,w),D=[];function k(t){const i=(0,o.isError)(t)?(0,d.errorToS)(t):(0,l.toS)(t);if((0,b.isIgnorableValidationError)(i))P().info("dcraw_emu(): warning",{src:e,msg:i});else{P().warn("dcraw_emu(): error",{src:e,msg:i});const n=(0,o.isError)(t)?t:(0,f.toWrappedError)(i,{fatal:!1});D.push(n)}}if(T.on("error",k),T.stderr.on("data",k),await t.writeStream_(T.stdout),(0,r.isNotEmpty)(D))throw new f.WrappedError("Failed to convert RAW image "+e,{causes:D,path:e.nativePath});(0,c.endProcess)(T)}t.dcraw_emu_=T},36192:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sips2jpeg_=t.sipsPath=void 0;const n=i(19851),r=i(84777),s=i(8103),a=i(43334),o=i(28874),l=i(63870),u=i(13940);t.sipsPath=(0,n.lazy)((async()=>a.isMac?(0,s.pathTo)({tool:"sips"}):void 0)),t.sips2jpeg_=async function(e){return(0,u.withImageCache_)(e,"heif",".jpeg",(t=>(0,r.stdoutResult_)("sips",["-s","format","jpeg","-s","formatOptions",String(o.Settings.previewQuality.valueOrDefault),e.nativePath,"--out",t.base],{cwd:t.dir,timeoutMs:(0,l.commandTimeoutMs)()})))}},49794:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColoredLogFormatter=t.colorProcessName=void 0;const n=i(57975),r=i(19851),s=i(40958),a=i(22573),o=i(54993),l=i(37975),u=i(7282),c=i(23560),d=i(28874),h=i(66184),f=i(93475),m=(0,r.lazy)((()=>[{re:/billing|worker/,f:l.cyan},{re:/sync/,f:l.blue},{re:/web/,f:l.green},{re:/main/,f:l.yellow},{re:/info/,f:l.blueBright},{re:/test|log/,f:l.magenta}]));function p(e){if((0,a.blank)(e))return"";const t=m().find((t=>e.match(t.re)));return null!=t?(0,l.bgBlack)(t.f(e)):e}t.colorProcessName=p,t.ColoredLogFormatter=class{constructor(e={}){this._inspectOptions=e,this.logLevels={trace:"trace",debug:(0,l.darkGrey)("debug"),info:(0,l.cyan)("info_"),warn:(0,l.yellowBright)("warn_"),error:(0,l.redBright)("error_"),fatal:(0,l.bgRedBright)((0,l.black)("fatal"))},this.inspectOptions={colors:!0,showHidden:!1,depth:5,compact:!0,customInspect:!0,maxArrayLength:d.Settings.logContextLimit.valueOrDefault+3,processName:c.processName,...this._inspectOptions},(0,u.isTest)()&&(this.inspectOptions.breakLength=255),d.Settings.logContextLimit.watchLater((e=>{this.inspectOptions.maxArrayLength=e+1})),this.inspectOptions.processName.watch((e=>this.defaultProcessName=p(e)))}formatMeta(e){if(null==e)return;const t=(0,f.prepMeta)(e);return null==t?void 0:(0,n.inspect)(t,this.inspectOptions)}formatLogEntry(e){const t=(0,h.logFilter)().highlight(e.ctx)?l.yellow:l.blue;return(0,s.compactBlanks)([(0,l.darkGrey)(new Date(e.ts).toISOString()),null==e.from?this.defaultProcessName:p(e.from),this.logLevels[e.l],t(e.ctx),e.msg,this.formatMeta(e.meta)]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,n){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,c.processName)(),ctx:t,msg:i,meta:n})}}},32105:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const n=i(19851),r=i(23560),s=i(66184),a=i(72210);class o{log(e,t,i,n){this.enabled(e,t)&&(0,a.pushLogEntries)({ts:Date.now(),l:e,from:(0,r.processName)(),ctx:t,msg:i,meta:n})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=o,o.instance=(0,n.lazy)((()=>new o))},14593:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const n=i(57975),r=i(22573),s=i(26905),a=i(55835),o=i(68708),l=i(13538),u=i(50213),c=i(97352),d=i(45255),h=i(76740),f=i(57159),m=i(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,r.toNotBlank)(e)??(0,s.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[n.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const i=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,o.omit)(t,"error")});throw Error.captureStackTrace?.(i),this.log(!0===i.ignorable?"warn":"error",".throw() "+i.message,{stack:i.stack,...t}),i}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let i;try{i=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const n=e.result(),r=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:n,meta:{...e.meta,elapsedMs:r}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,a.map)(i,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,o.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const i of this.loggers())if(i.enabled(e,t??this.context))return!0;return!1}log(e,t,i){for(const n of this.loggers())n.log(e,this.context,t,i)}elapsed(e,t,i){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...i})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},89179:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.currentFileLogger=void 0;const n=i(50213),r=i(43705);t.currentFileLogger=function(){return(0,n.rootLoggers)().find((e=>e instanceof r.LogWriter))}},28981:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const n=i(19851),r=i(51879);t.DefaultLogFormatter=(0,n.lazy)((()=>new r.PlaintextLogFormatter))},31256:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GelfLogFormatter=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(41400),o=i(98553),l=i(55835),u=i(31586),c=i(68708),d=i(72993),h=i(23560),f=i(81168),m=i(98314),p=i(57902),g=i(93475),y=(0,n.lazy)((()=>({_service:(0,h.serviceName)(),_pid:process.pid})));function v(e){if(null==e)return y();{const[t,i]=e.split("-",2);return(0,s.blank)(t)?y():{_service:t,_pid:(0,u.toInt)(i)}}}(0,a.later)((()=>h.serviceName.watchLater((()=>y.unset())))),t.GelfLogFormatter=class{formatLogEntry(e){const t={version:"1.1",level:(0,p.level2syslog)(e.l)??7,host:d.SimpleAppName,timestamp:e.ts/1e3,short_message:(0,f.stripAnsiEsc)((0,r.uniq)((0,r.compactBlanks)([e.ctx,e.msg])).join(" ")),full_message:(0,l.map)(e.meta?.error,m.errorToVerbose)};return(0,o.stringify)({...t,...v(e.from),...(0,c.fromEntries)((0,c.entries)((0,g.prepMeta)(e.meta,3)??{}).map((([e,t])=>"id"===e?void 0:["_"+e,(0,o.stringify)(t)])))})}format(e,t,i,n){return this.formatLogEntry({ts:Date.now(),l:e,ctx:t,msg:i,meta:n})}}},51576:function(e,t,i){var n,r=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.logBroadcaster=void 0;const s=i(77030),a=i(19851),o=i(22573),l=i(42659),u=i(41400),c=i(98553),d=i(56409),h=i(31586),f=i(25764),m=i(38836),p=i(50213),g=i(409),y=i(28874),v=i(31256),w=i(28538),S=(0,a.lazy)((()=>(0,p.mkConsoleLogger)("log.LogBroadcaster"))),b=String.fromCharCode(0);t.logBroadcaster=(0,a.lazy)((()=>{const e=function(){const[e,t]=(y.Settings.logServer.valueOrDefault??"").split(":"),i=(0,h.toInt)(t);return(0,o.blank)(e)||!(0,h.gt0)(i)?void 0:{host:e,port:i}}();return null==e?void(y.Settings.logServer.hasValue()&&S().info(`setup(): no-op: invalid PS_LOG_SERVER setting (expecting "host:port", got ${(0,c.stringify)(y.Settings.logServer.valueOrDefault)})`)):new P(e.host,e.port)})),(0,u.later)((()=>y.Settings.logServer.watchLater((()=>t.logBroadcaster.unset()))));class P extends m.EndableWrapper{constructor(e,t){super("log.LogBroadcaster("+e+":"+t+")",(()=>this.socket?.end()),f.EndableRanks.logtail),this.host=e,this.port=t,this.logFormatter=new v.GelfLogFormatter,this.logFilter=new w.LogFilterImpl(y.Settings.logServerLevel),n.set(this,(0,g.rateLimited)({f:async()=>{try{const e=this.socket=(0,s.createConnection)({host:this.host,port:this.port});e.on("close",(()=>{this.socket=void 0})),e.on("error",(t=>{S().warn("Error from logging server",t);try{e.end()}catch{}}))}catch(e){S().warn("Failed to connect to the log server",e)}},minCallDelayMs:l.minuteMs,name:"#mkSocket"})),r(this,n,"f").call(this)}enabled(e,t){return this.logFilter.enabled(e,t)}log(e,t,i,s){if(this.enabled(e,t))try{const a=this.socket;null==a?r(this,n,"f").call(this):a.write(this.logFormatter.format(e,t,i,s)+b)}catch(n){S().warn("Failed to write log entry to socket",{level:e,context:t,msg:i,meta:s,error:n})}}flush(){const e=new d.Latch;return this.socket?.write("",(()=>e.resolve())),e.promise}}n=new WeakMap},20839:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},21727:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.datedLogDir=void 0;const n=i(76760),r=i(42659),s=i(28874);t.datedLogDir=function(e,t){return(0,n.join)(e??s.Settings.logDir.valueOrDefault,(0,r.fmtIsoDate)(t??new Date))}},4904:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const n=i(76790),r=i(31586),s=i(51926),a=i(57902);t.isLogEntry=function(e){return null!=e&&(0,r.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&a.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,n.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const n=i(19851),r=i(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,r.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,r.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,n.lazy)((()=>new s(r.LogLevels.warn))),t.defaultLogLevel=(0,n.lazy)((()=>r.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,r.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,i){return(0,t.logFilter)().enabled(e)?i():void 0},t.isLogged=function(e,i){return(0,t.logFilter)().enabled(e,i)}},28538:function(e,t,i){var n,r,s,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.LogFilterImpl=void 0;const l=i(19851),u=i(40958),c=i(22573),d=i(54993),h=i(28874),f=i(66184),m=i(57902);t.LogFilterImpl=class{constructor(e=h.Settings.logLevel){n.add(this),this.setting=e,this.silent=!1,r.set(this,[]),s.set(this,(0,l.lazy)((()=>{o(this,r,"f").length=0;const e=this.setting.valueOrDefault;this.defaultLevelIndex=m.LogLevels.indexOf(e)??m.LogLevels.indexOf(this.setting.defaultValue)??m.LogLevels.indexOf(m.LogLevels.warn);const t=(0,u.compactBlanks)(e.split(/[,;]/));for(const i of t){const t=f.LogLevelRe.exec(i.trim());if(null==t)console.error("LogFilterImpl: Ignoring '"+i+"' from "+e);else{const e=(0,d.toS)(t[1]).toLowerCase(),i=(0,m.levelIndex)(t[2]);(0,c.blank)(e)?this.defaultLevelIndex=i:o(this,r,"f").push({prefix:e,levelIndex:i})}}}))),e.watch((()=>o(this,s,"f").refresh()))}enabled(e,t){if(this.silent)return!1;const i=(0,m.levelIndex)(e);if(null!=t){const e=o(this,n,"m",a).call(this,t);if(null!=e)return i<=e.levelIndex}return i<=this.defaultLevelIndex}highlight(e){const t=o(this,n,"m",a).call(this,e);return null!=t&&t.levelIndex>=this.defaultLevelIndex}},r=new WeakMap,s=new WeakMap,n=new WeakSet,a=function(e){if(null==e||0===o(this,r,"f").length||(0,c.blank)(e))return;const t=(0,d.toS)(e).toLowerCase();return o(this,r,"f").find((e=>t.startsWith(e.prefix)))}},57902:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const n=i(42659),r=i(31586),s=i(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const a=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??a},t.levelGte=function(e,i){return(0,r.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(i))};const o=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return o.get(e)},t.msTolevel=function(e,t=7*n.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},93475:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.prepMeta=t.PromisePlaceholder=void 0;const n=i(40958),r=i(68708),s=i(20214),a=i(51926),o=i(23541),l=i(48884),u=i(88158),c=i(98314),d=i(28874);t.PromisePlaceholder="(promise)",t.prepMeta=function e(i,h=4){if(null==i)return null;if(h<0)return"…";if((0,a.isString)(i)||Buffer.isBuffer(i))return(0,a.ellipsize)(i.toString(),256,32);if((0,o.isError)(i))return(0,c.errorToVerbose)(i);if(Array.isArray(i)){const t=d.Settings.logContextLimit.valueOrDefault,n=Math.floor(t/2);return i.length<=t?i:[...i.slice(0,n).map((t=>e(t,h-1))),`… (${i.length} total entries)`,...i.slice(-n).map((t=>e(t,h-1)))]}if("object"==typeof i||"function"==typeof i){for(const t of["toLogJSON","toJSON"])if("function"==typeof i[t])return e(i[t](),h-1);if((0,s.isPromiseLike)(i))return t.PromisePlaceholder;if("…"in i)return i;const o=(0,u.mapNullEntries)(i,((t,i)=>e(i,h-1)),d.Settings.logContextLimit.valueOrDefault),c=(0,l.diff)((0,r.keys)(i),(0,r.keys)(o));return(0,n.isNotEmpty)(c)&&(o["…"]="omitted: "+(0,a.ellipsize)(c.join(", "),128,32)),o}return i}},24068:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LogTail=t.DefaultLogEntryWriter=void 0;const n=i(73024),r=i(76760),s=i(1708),a=i(87997),o=i(19851),l=i(22573),u=i(42659),c=i(49769),d=i(55835),h=i(34666),f=i(20214),m=i(7282),p=i(23560),g=i(54826),y=i(82328),v=i(22277),w=i(25764),S=i(38836),b=i(99331),P=i(42638),M=i(76596),_=i(98314),E=i(89968),x=i(29882),T=i(28874),D=i(28981),k=i(20839),C=i(21727),F=i(66184),O=i(57902),I=i(72210),L=i(98192);function A(e){const t=(0,D.DefaultLogFormatter)();for(const i of e)(0,g.consoleLog)(t.formatLogEntry(i))}t.DefaultLogEntryWriter=A;class R extends S.EndableWrapper{constructor(e=void 0,t=A){super("LogTail",(()=>this.close()),w.EndableRanks.logtail),this.rootNativePath=e,this.writer=t,this.watchers=new Map,this.filenameMutexes=new P.Promises("log.LogTail",(()=>8)),this.file2pos=new Map,this.lastReadFiles=new v.TTLSet(5*u.secondMs),this.setup=(0,o.lazy)((async()=>{const e=(0,l.notBlankOr)(this.rootNativePath,T.Settings.logDir.valueOrDefault);(0,m.isTest)()&&(0,g.consoleLog)("tailing "+e+"..."),await(0,x.mkdirp_)(e),this.root=await E.DirectoryEntry.for(e),await this.scan(!0)})),this.ignorableFilename=r.sep+(0,p.serviceName)()+"-"+s.pid+"-",s.stdout.writableFinished||((0,I.setLogTailEnabled)(!0),this.flushTimeout=(0,a.setInterval)((()=>this.flush()),k.DefaultLogFlushMs/2),this.scanTimeout=(0,a.setInterval)((()=>this.scan()),u.minuteMs),s.stdout.on("end",(()=>this.end())),this.setup())}async flush(){this.writer((0,I.popExpiredLogEntries)())}readable(e){return e.endsWith(".log")&&!e.includes(this.ignorableFilename)}watchDir(e){(0,b.ending)()||this.ended||(0,c.getOrSet)(this.watchers,e,(()=>{(0,F.ifLog)(O.LogLevels.debug,(()=>(0,g.consoleLog)("LogTail(): watching "+e)));try{return(0,n.watch)(e,((t,i)=>{(0,l.notBlank)(i)&&this.watchListener(t,(0,r.join)(e,i))}))}catch(t){return void(0,F.ifLog)(O.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): failed to read "+e+": "+(0,_.errorToS)(t))))}}))}async scan(e=!1){if((0,b.ending)()||this.ended)return;if(await this.root.visitDescendants((async t=>{this.readable(t.nativePath)&&(e&&await(0,f.thenMap)(t.size(),(e=>this.file2pos.set(t.nativePath,e))),(0,M.nowish)(t.mtimeMs(),5*u.minuteMs)&&this.watchDir(t.dir))})),(0,b.ending)()||this.ended)return;const t=(0,C.datedLogDir)(this.root.nativePath);try{await(0,x.mkdirp_)(t),this.watchDir(t)}catch(e){(0,F.ifLog)(O.LogLevels.warn,(()=>(0,g.consoleError)("LogTail(): Failed to list or mkdir -p "+t+": there may be permission issues: "+(0,_.errorToS)(e))))}(0,b.ending)()||this.ended||e&&(0,g.consoleLog)("LogTail(): Tailing "+this.root+"/**/*.log...")}async close(){(0,I.setLogTailEnabled)(!1),(0,d.map)(this.flushTimeout,a.clearInterval),this.flushTimeout=void 0,(0,d.map)(this.scanTimeout,a.clearInterval),this.scanTimeout=void 0;for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of this.lastReadFiles)await this.watchListener("onEnd",e);try{this.writer((0,I.popExpiredLogEntries)(-1))}catch(e){console.warn("failed to flush last log entries",e)}}async watchListener(e,t){this.readable(t)&&"rename"!==e&&await this.filenameMutexes.serial(t,(async()=>{try{const e=await E.DirectoryEntry.for(t);if(null==e)return;const i=e.size();if(null==i||i<=0)return;const n=this.file2pos.get(e.nativePath)??0;if((0,h.gte)(n,i))return;await(0,f.thenMap)((0,L.readLogEntries)(e,{start:n,end:i}),(e=>(0,I.pushLogEntries)(...e))),this.lastReadFiles.add(e.nativePath),this.file2pos.set(e.nativePath,i)}catch(e){(0,F.ifLog)(O.LogLevels.warn,(()=>(0,g.consoleError)("Failed to read "+t+": "+(0,_.errorToS)(e))))}}))}}t.LogTail=R,R.instance=(0,o.lazy)((()=>(0,y.stdoutEnded)()?void 0:new R))},72210:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const n=i(92322),r=i(82328),s=i(28981),a=i(20839),o=i(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new n.SortedSet(o.logEntrySorter),t.pushLogEntries=function(...e){for(const i of e)l?t.logEntries.add(i):(0,r.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(i))},t.popExpiredLogEntries=function(e=2*a.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},43705:function(e,t,i){var n,r,s,a,o,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LogWriter=t.CaptureLogger=void 0;const h=d(i(73024)),f=i(76760),m=i(19851),p=i(42659),g=i(41400),y=i(98553),v=i(31586),w=i(409),S=i(23560),b=i(81168),P=i(78406),M=i(25764),_=i(20197),E=i(14977),x=i(36868),T=i(28874),D=i(32105),k=i(20839),C=i(21727),F=i(66184),O=i(93475),I=i(22662);t.CaptureLogger=class{constructor(){this.logEntries=[]}log(e,t,i,n){this.logEntries.push({ts:Date.now(),l:e,ctx:t,msg:i,meta:n})}enabled(){return!0}end(){}async flush(){}};class L extends P.EndableInterval{constructor(e,t={}){super({name:"LogWriter("+e+")",callback:()=>this.flush(),intervalMs:Math.round(t.flushEveryMs??1.25*k.DefaultLogFlushMs),rank:M.EndableRanks.logger,unref:!0,onEnd:()=>c(this,r,"f").call(this)}),n.add(this),this.logDir=e,this.pendingWrites=[],this._linesSinceRotate=0,this._nextForcedRotateTs=(0,p.nextMidnightTs)(),this._startIndex=0,this.endTimeoutMs=15*p.secondMs,r.set(this,(0,m.lazy)((async()=>(await this.flush.force(),c(this,n,"m",u).call(this))))),this.logOpts={maxLinesPerFile:25e4,errorLogger:D.ConsoleLogger.instance(),flushEveryMs:k.DefaultLogFlushMs,processName:S.processName,logFilter:F.logFilter,...t},this.setIntervalMs(this.logOpts.flushEveryMs),this.flush=(0,w.rateLimited)({name:"LogWriter.flush()",minCallDelayMs:this.logOpts.flushEveryMs,f:()=>c(this,n,"m",s).call(this)})}toJSON(){return{_ctor:"LogWriter",logDir:this.logDir}}enabled(e,t){return this.logOpts.logFilter().enabled(e,t)}log(e,t,i,n){if(this.enabled(e,t))if(this.ended&&"error"===e)this.logOpts.errorLogger.log(e,t,i,n);else{const r={ts:Date.now(),l:e,ctx:t,msg:i};null!=n&&(r.meta=(0,O.prepMeta)(n)),"error"===e&&this.writeRecentLogEntries(),this.pendingWrites.push(r)}}writeRecentLogEntries(){this.pendingWrites.push(...(0,I.recentLogEntries)()),(0,I.clearRecentLogEntries)()}shouldRotate(){return null==this._logfile||this._linesSinceRotate>=this.logOpts.maxLinesPerFile||Date.now()>=this._nextForcedRotateTs}}t.LogWriter=L,r=new WeakMap,n=new WeakSet,s=async function(){const e=[...this.pendingWrites];for(this.pendingWrites.length=0;e.length>0;){this.shouldRotate()&&await c(this,n,"m",l).call(this);const t=this._logfile?.stream;if(null==t)return void this.logOpts.errorLogger.log("error","LogWriter.flush()","this._rotate() returned an empty stream");const i=(0,v.clamp)(0,e.length,this.logOpts.maxLinesPerFile-this._linesSinceRotate),r=e.splice(0,i);this._linesSinceRotate+=r.length,t.write(r.map((e=>(0,y.stringify)(e)+"\n")).join(""))}},a=function(e,t){this.logOpts.errorLogger.log("error","Caught error from "+e,t)},o=function(e){return t=>(c(this,n,"m",a).call(this,e,t),c(this,n,"m",u).call(this))},l=async function(){await c(this,n,"m",u).call(this);const e=(0,b.stripAnsiEsc)(this.logOpts.processName()),t=await(0,_.ensureNewNativePath_)({nativePath:(0,f.join)((0,C.datedLogDir)(this.logDir),e+".log"),emptyIsNew:!0,startIndex:++this._startIndex,requireNumber:!0,leftPad:3}),i=h.default.createWriteStream(t).on("error",c(this,n,"m",o).call(this,"file write stream"));this._logfile={stream:i,nativePath:t},this._nextForcedRotateTs=(0,p.nextMidnightTs)()},u=async function(){const e=this._logfile;if(this._logfile=void 0,this._linesSinceRotate=0,null!=e)try{await(0,x.endStream)(e.stream),T.Settings.logCompression.valueOrDefault&&(await(0,g.delay)(this.logOpts.flushEveryMs),await(0,E.gzip_)(e.nativePath))}catch(e){c(this,n,"m",a).call(this,"_closeCurrent()",e)}}},51879:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const n=i(57975),r=i(40958),s=i(55835),a=i(68708),o=i(54993),l=i(23560),u=i(81168),c=i(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,a.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,r.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,n.inspect)(e,this.inspectOptions)))]).map((e=>(0,o.toS)(e))).join(" ")}format(e,t,i,n){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:i,meta:n})}}},98192:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.chunkToLogEntry=t.readLogEntries=void 0;const n=i(22573),r=i(84542),s=i(4001),a=i(13047),o=i(4904);function l(e){if(!(0,n.blank)(e))try{const t=JSON.parse(e);return(0,o.isLogEntry)(t)?t:void 0}catch(e){return}}t.readLogEntries=async function(e,t){const i=(0,s.stripCopySuffixFromName)(e.name),n=[],o=await(0,a.zcat)(e.nativePath,t);if(null!=o)for(const e of(0,r.splitLines)(o)){const t=l(e);null!=t&&n.push({...t,from:i})}return n},t.chunkToLogEntry=l},22662:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.recentLogEntries=t.addRecentLogEntry=t.clearRecentLogEntries=t.SentLogLevels=void 0;const n=i(19851),r=i(76790),s=i(68708),a=i(89788),o=i(57902);t.SentLogLevels=(0,n.lazy)((()=>o.LogLevels.values.filter((e=>e!==o.LogLevels.trace))));const l=(0,n.lazy)((()=>(0,s.fromEntries)((0,t.SentLogLevels)().map((e=>[e,new a.BoundedList(48)])))));t.clearRecentLogEntries=function(){(0,s.values)(l()).forEach((e=>e.clear()))},t.addRecentLogEntry=function(e){l()[e.l]?.push(e)},t.recentLogEntries=function(){const e=[];for(const t of(0,s.values)(l()))e.push(...t.toA());return(0,r.sortBy)(e,(e=>e.ts))}},17181:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupLogFormatter=t.setupLogger=void 0;const n=i(76760),r=i(41400),s=i(55835),a=i(37975),o=i(50213),l=i(27395),u=i(46296),c=i(96706),d=i(73428),h=i(28874),f=i(49794),m=i(32105),p=i(89179),g=i(28981),y=i(51576),v=i(66184),w=i(28538),S=i(24068),b=i(43705),P=i(51879);function M(){(0,v.logFilter)()instanceof w.LogFilterImpl||v.logFilter.set(new w.LogFilterImpl),_();const e=(0,u.logDir)();let t=(0,p.currentFileLogger)();null!=t&&t.logDir===e||((0,l.end)(t),(0,d.writeTextfile_)((0,n.join)(e,"README.txt"),'PhotoStructure writes logfiles to dated subdirectories.\n\nAlthough you _can_ directly read these .json files, you don\'t need to!\n\nUse PhotoStructure\'s "logcat" and "logtail" tools to merge,\nchronologically sort, and pretty-print these files.\n\nSee https://photostructure.com/server/tools/#logging for details.\n').catch((()=>null)),t=new b.LogWriter(e));const i=[t];((0,c.isEnvTrue)("logStdout")||h.Settings.logStdout.valueOrDefault||h.Settings.tailLogs.valueOrDefault)&&i.push(m.ConsoleLogger.instance()),(0,s.map)((0,y.logBroadcaster)(),(e=>i.push(e))),o.rootLoggers.set(i),h.Settings.tailLogs.valueOrDefault&&S.LogTail.instance()}function _(){const e=h.Settings.logColor.valueOrDefault;(0,a.setColorEnabled)(e),g.DefaultLogFormatter.set(e?new f.ColoredLogFormatter:new P.PlaintextLogFormatter)}t.setupLogger=M,t.setupLogFormatter=_,(0,r.later)((()=>{h.Settings.logStdout.watchLater(M),h.Settings.logDir.watchLater(M),h.Settings.tailLogs.watchLater(M),h.Settings.logColor.watchLater(_),h.Settings.logLevel.watchLater((()=>v.defaultLogLevel.unset()))}))},82647:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const a=i(57975),o=i(40958),l=i(96249),u=i(55835),c=i(31586),d=i(68708),h=i(59455),f=i(48884),m=i(89788),p=i(22454),g=i(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const i=t.clone();return i.pushAll(e.samples),i}if(t.n<=t.maxSamples){const i=e.clone();return i.pushAll(t.samples),i}{const i=new y(Math.max(e.maxSamples,t.maxSamples));i._n=e.n+t.n,i._min=Math.min(e._min,t._min),i._max=Math.max(e._max,t._max),i._m=e._m*e.n/i.n+t._m*t.n/i.n,i._s=e._s*e.n/i.n+t._s*t.n/i.n;const n=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return i._samples.push(...n),i._weightedTotalAvg=(0,g.weightedAvg)([i._m,...n]),i}}constructor(e=20){n.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(n=new WeakSet,a.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),i={};return i.k=t(this.n),this.empty||(i.mean=t(this.avg),i.sum=t(this.sum),i.sd=t(this.stdDev),i.max=t(this.max),i.min=t(this.min)),i}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,n,"m",r).call(this,-1)}get p29(){return s(this,n,"m",r).call(this,-.5)}get p38(){return s(this,n,"m",r).call(this,-.25)}get p69(){return s(this,n,"m",r).call(this,.5)}get p84(){return s(this,n,"m",r).call(this,1)}get p98(){return s(this,n,"m",r).call(this,2)}get p99(){return s(this,n,"m",r).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,o.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,o.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,o.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,r=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const n=i(40958),r=i(55835),s=i(31586),a=i(30976),o=i(48884),l=i(70417);function u(e,t){const i=Math.pow(2,t),n=[];for(;e>0;)n.unshift(e%i),e=Math.floor(e/i);return n}t.concatBits=function(e,t){const i=Math.pow(2,t);return e.reduce(((e,t)=>e*i+(0,s.clamp)(0,i,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,i){return(0,r.map2)(e,t,((e,t)=>(0,n.sum)((0,o.zip)(u(e,i),u(t,i)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,a.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const i=this.dims.map((e=>e.min)),n=this.dims.map((e=>e.max)),r=this.clampValue(e);let s=0;for(let e=0;ea?(s+=1,i[t]=a):n[t]=a}return s}unzip(e,t){const i=this.dims.map((e=>e.min)),n=this.dims.map((e=>e.max));for(let r=0;r(i[e]+n[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,i){return!0!==i&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let i=0;is?(t+=1,r.min=s):r.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const i=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,n.sum)(e,((i,n)=>t(i,n)?Math.pow(2,e.length-n-1):0))}},44983:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.kmeans=void 0;const n=i(76790),r=i(93973);t.kmeans=function(e,t,i){const s=r(e,t,i);return{...s,centroids:(0,n.sortBy)(s.centroids.filter((e=>e.size>0)),(e=>-e.size))}}},31843:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lerp2d_=t.lerp2d=t.lerp=void 0;const n=i(76790);function r(e,t,i=.5){return(1-i)*e+i*t}t.lerp=r,t.lerp2d=function(e,...t){const i=(0,n.sortBy)(t,(t=>Math.abs(e-t.x))).slice(0,2),[s,a]=(0,n.sortBy)(i,(e=>e.x)),o=a.x-s.x,l=(e-s.x)/o;return r(s.y,a.y,l)},t.lerp2d_=function(e,t,i){return(t.y*(i.x-e)+i.y*(e-t.x))/(i.x-t.x)}},75503:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.modeReduce=t.submatrixCollect=t.greatestHalf=t.leastVariantQuarter=t.leastMagQuarter=t.submatrixMode=t.submatrixStdDev=t.submatrixMagnitude=t.submatrixForEach=t.index1D=t.slice=t.matXvec=t.vecXvec=void 0;const n=i(40958),r=i(31586),s=i(48884),a=i(82647),o=i(70417);function l(e,t,i,n){const r=Math.floor(Math.max(0,t.row)),s=Math.ceil(Math.min(e.row,i.row)),a=Math.floor(Math.max(0,t.col)),o=Math.ceil(Math.min(e.col,i.col));for(let t=r;t(0,r.mapFinite)(e[t],(e=>s+=e*e)))),Math.sqrt(s)}function c(e,t,i,n){const s=new a.Average;return l(t,i,n,(t=>(0,r.mapFinite)(e[t],(e=>s.push(e))))),s.stdDev}function d(e,t,i,n){const s=[];return l(t,i,n,(t=>(0,r.mapFinite)(e[t],(e=>s.push(e))))),(0,o.mode)(s)}t.vecXvec=function(e,t){return e.map(((e,i)=>e*t[i]))},t.matXvec=function(e,t){return e.map(((e,i)=>{if(e.length!==t.length)throw new Error("misshaped matrix on row "+i);return(0,o.sumf)(e,((e,i)=>e*t[i]))}))},t.slice=function(e,t,i){const r=Math.max(0,t.row),s=Math.min(e.length,i.row),a=Math.max(0,t.col),o=Math.min(e[0].length,i.col);return(0,n.range)(r,s,(t=>e[t].slice(a,o)))},t.index1D=function(e,t,i){return t*e.col+i},t.submatrixForEach=l,t.submatrixMagnitude=u,t.submatrixStdDev=c,t.submatrixMode=d,t.leastMagQuarter=function(e,t){const i=t.col,n=t.row,r=[u(e,t,{col:i/2,row:0},{col:i,row:n/2}),u(e,t,{col:0,row:0},{col:i/2,row:n/2}),u(e,t,{col:0,row:n/2},{col:i/2,row:n}),u(e,t,{col:i/2,row:n/2},{col:i,row:n})];return(0,s.leastIndex)(r)},t.leastVariantQuarter=function(e,t){const i=t.col,n=t.row;return(0,s.leastIndex)([c(e,t,{col:i/2,row:0},{col:i,row:n/2}),c(e,t,{col:0,row:0},{col:i/2,row:n/2}),c(e,t,{col:0,row:n/2},{col:i/2,row:n}),c(e,t,{col:i/2,row:n/2},{col:i,row:n})])},t.greatestHalf=function(e,t){const i=t.col,n=t.row,r=[d(e,t,{col:0,row:0},{col:i,row:n/2}),d(e,t,{col:0,row:0},{col:i/2,row:n}),d(e,t,{col:0,row:n/2},{col:i,row:n}),d(e,t,{col:i/2,row:0},{col:i,row:n})];return(0,s.greatestIndex)(r)},t.submatrixCollect=function(e,t,i){const n=[];return l(e,t,i,(e=>n.push(e))),n},t.modeReduce=function(e,t,i){const o=Math.floor(t.col/i.col),u=Math.floor(t.row/i.row),c=new a.Average(Math.ceil(o*u));return(0,s.concat)(...(0,n.stepRange)(0,t.row,u,(i=>(0,n.stepRange)(0,t.col,o,(n=>(c.clear(),l(t,{col:n,row:i},{col:n+o,row:i+u},(t=>(0,r.mapFinite)(e[t],(e=>c.push(e))))),c.sampleMode))))))}},55222:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const n=i(77598),r=i(22573),s=i(55835),a=i(32639),o=i(88158),l=i(81168),u=BigInt(0);function c(e,t,i=0){if(!isFinite(t)||e<=1)return[];const n=[];if(0===t)n.unshift(0);else for(;t>0;)n.unshift(t%e),t=Math.floor(t/e);for(;n.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const i=e<0;return i&&(e=Math.abs(e),t--),(i?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],i=BigInt(this.base);let n=e;for(;n>u;)t.push(Number(n%i)),n/=i;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let i of e)for(t.forEach(((e,n)=>{i+=e<<8,t[n]=i%this.base,i=Math.floor(i/this.base)}));i>0;)t.push(i%this.base),i=Math.floor(i/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,r.blank)(e))return;const t="-"===(e=(0,a.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const i=BigInt(this.base);let n=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;n=n*i+BigInt(e)}return t?BigInt(-1)*n:n}randomChars(e){return this.encodeBuffer((0,n.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,i="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(i)}tokenEql(e,t,i){const n=this.normalizeToken(e),r=this.normalizeToken(t);return n.length>=i&&n===r}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const n=i(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,n.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},56946:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intToRoman=t.romanToInt=t.RomanNumerals=void 0;const n=i(31586),r=i(54993);t.RomanNumerals=[void 0,"I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX","XX","XXI","XXII","XXIII","XXIV","XXV","XXVI","XXVII","XXVIII","XXIX","XXX","XXXI","XXXII","XXXIII","XXXIV","XXXV","XXXVI","XXXVII","XXXVIII","XXXIX","XL","XLI","XLII","XLIII","XLIV","XLV","XLVI","XLVII","XLVIII","XLIX","L","LI","LII","LIII","LIV","LV","LVI","LVII","LVIII","LIX","LX"],t.romanToInt=function(e){const i=t.RomanNumerals.indexOf(e);return-1===i?void 0:i},t.intToRoman=function(e){return t.RomanNumerals[(0,n.toInt)(e)]??(0,r.toS)(e)}},17921:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UUIDRegExp=t.safeUUID=t.uuid=void 0;const n=i(77598),r=i(65713);function s(){const e=(0,n.randomBytes)(16);e[6]=15&e[6]|64;const t=e.toString("hex");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")}t.uuid=s,t.safeUUID=function(){return(0,r.decuss)(s)},t.UUIDRegExp=/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/},70417:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},a=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const o=i(40958),l=i(55835),u=i(31586),c=i(59455),d=i(22454),h=i(77377),f=i(82647);function m(e){let t;for(const i of e)null!=i&&(null==t||it)&&(t=i);return t}function y(e,t){const i=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&i.incr(t);return i.topKeys(t)}function v(e,t){let i=0,n=0;for(const r of e){if(null!=r){const e=t(r,i);(0,u.isNumber)(e)&&(n+=e)}i++}return n}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,i)=>e-t[i]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const i of e)(0,u.isNumber)(i)&&(t+=i);return t},t.sumf=v;class w{constructor(){n.set(this,0),r.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(a(this,r,null==s(this,r,"f")?e:s(this,r,"f")*s(this,n,"f")/(s(this,n,"f")+1)+e/(s(this,n,"f")+1),"f"),a(this,n,(t=s(this,n,"f"),++t),"f"))}get mean(){return s(this,r,"f")}}function S(e){const t=new w;for(const i of e)t.push(i);return t.mean}function b(e){const t=S(e);if(null==t)return;let i=0,n=0;for(const r of e)(0,u.isNumber)(r)&&(n++,i+=(r-t)*(r-t));return i/n}function P(e){let t=0;for(const i of e)t+=i*i;return Math.sqrt(t)}function M(e,t){let i=0;for(let n=0;n(1-t)*e+t*(i+a*(e-r)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),i=S(t);if(null!=i){const e=(t.length-1)/2,n=v(t,((t,n)=>(t-i)*(n-e))),r=v(t,(e=>(e-i)**2));return 0===r?0:n/r}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let i;t=(0,u.clamp)(0,1,t);for(const n of e)i=null==i?n:i*t+n*(1-t);return i},t.centroid=function(e){const t=e[0].length,i=[];for(let n=0;ne[n]))));return i},t.l2norm=P,t.dot=M,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(M(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,o.isEmpty)(e)&&(0,o.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},23624:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.b64encodeBits=t.b64hammRatio=t.gz64decodeString=t.d=t.gz64encodeString=t.b64decode=t.b64encode=t.hex2b64=void 0;const n=i(38522),r=i(22573),s=i(97352);function a(e){const t=e.toString(16),i=t.length%2==0?"":"0";return Buffer.from(i+t,"hex").toString("base64")}function o(e){return BigInt("0x0"+Buffer.from(e,"base64").toString("hex"))}function l(e){return(0,n.gunzipSync)(Buffer.from(e,"base64")).toString("utf8")}t.hex2b64=function(e){return Buffer.from(e,"hex").toString("base64")},t.b64encode=a,t.b64decode=o,t.gz64encodeString=function(e){return(0,n.gzipSync)(Buffer.from(e,"utf8")).toString("base64")},t.d=l,t.gz64decodeString=l,t.b64hammRatio=function(e,t){return(0,r.mapNotBlank)(e,(e=>(0,r.mapNotBlank)(t,(t=>(0,s.hammRatioBigInt)(o(e),o(t))))))},t.b64encodeBits=function(e){return a(BigInt("0b0"+e.map((e=>1===e?"1":"0")).join("")))}},49076:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fsSafeHostname=t.cleanHostname=t.hostname=void 0;const r=n(i(48161)),s=i(19851),a=i(22573),o=i(41400),l=i(81168),u=i(28874);t.hostname=(0,s.lazy)((()=>u.Settings.hostname.value??r.default.hostname())),(0,o.later)((()=>u.Settings.hostname.watchLater((()=>t.hostname.unset())))),t.cleanHostname=function(e){return(0,a.blank)(e)&&!(0,a.blank)(u.Settings.hostname.value)?u.Settings.hostname.value:(e??r.default.hostname()).replace(/\.local$/,"").replace(/-?\d+$/,"")},t.fsSafeHostname=function(e=(0,t.hostname)()){return(0,l.stripDiacritics)(e).replace(/[^a-z\d\s-]/gi,"").trim().replace(/\s+/g,"-").toLowerCase()}},96128:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isEquivalentHost=t.nslookup=t.resolve4=t.octets=t.isLoopback=t.friendlyname=void 0;const n=i(40610),r=i(19851),s=i(22573),a=i(42659),o=i(41400),l=i(31586),u=i(13538),c=i(83104),d=i(54993),h=i(50213),f=i(97352),m=i(45255),p=i(81168),g=i(1728),y=i(56519),v=i(34102),w=i(26293),S=new RegExp("^"+w.ipv4Re.source+"$");t.friendlyname=(0,g.memoizeAsync)((async e=>{const i=null==S.exec(e)?e:await(0,t.nslookup)(e);return(0,d.toS)(i).toLowerCase().normalize()}),{name:"net.nslookup.friendlyname",maxSize:128,timeoutMs:m.ShortCommandTimeoutMs});const b=/^(?:localhost\.?(?:localdomain\.?)?|127(?:\.\d{1,3}){3})$/i;function P(e){return null!=b.exec(e)}function M(e){const t=e.split(".").map((e=>(0,l.toInt)(e))).filter((e=>(0,f.within)(0,255,e)));return 4===t.length?t:void 0}t.isLoopback=P,t.octets=M,t.resolve4=(0,g.memoizeAsync)((async e=>{if(!(0,s.blank)(e)){if(null!=M(e))return[e];try{return await n.promises.resolve4(e)}catch(t){return void _().warn("No name found for "+e)}}}),{name:"net.nslookup.resolve4",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs});const _=(0,r.lazy)((()=>(0,h.mkLogger)("net.nslookup")));(0,o.later)((()=>(0,v.ee)().on("clearCache",(()=>t.nslookup.clear())))),t.nslookup=(0,g.memoizeAsync)((async e=>{try{const t=await(0,u.thenOrTimeout)(P(e)?e.startsWith("127.")?["localhost"]:["127.0.0.1"]:null!=M(e)?n.promises.reverse(e):n.promises.resolve4(e),5*a.secondMs);if(t===c.Timeout)return _().info("nslookup("+e+"): timeout"),e;const i=t.find(s.notBlank);return null==i?(_().warn("No name found for "+e),e):i}catch(t){return _().warn("Failed to look up "+e+", using name.",t),e}}),{name:"net.nslookup",maxSize:256,timeoutMs:m.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs}),t.isEquivalentHost=async function(e,i){return!(0,s.blank)(e)&&!(0,s.blank)(i)&&(!!(0,p.equalsIgnoreCase)(e,i)||!(!P(e)||!P(i))||(0,y.thenMap2Or)((0,t.resolve4)(e),(0,t.resolve4)(i),((e,t)=>e.some((e=>t.includes(e)))),(()=>!1)))}},26293:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ipAddrFromPing=t.ipv4Re=t.ping=void 0;const n=i(22573),r=i(42659),s=i(31586),a=i(97790),o=i(54993),l=i(1728),u=i(84777),c=i(8103),d=i(43334),h=i(45255);t.ping=(0,l.memoizeAsync)((async e=>{const t=d.isWin?(0,c.pingWin)():"ping";return(0,u.stdout_)(t,[d.isWin?"-n":"-c","1",e],{timeoutMs:5*r.secondMs})}),{name:"net.ping",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*r.minuteMs}),t.ipv4Re=new RegExp("\\b"+(0,s.times)(4,(()=>"[0-9]{1,3}")).join("\\.")+"\\b"),t.ipAddrFromPing=(0,l.memoizeAsync)((async e=>(0,a.opt)(await(0,t.ping)(e).catch((e=>{console.warn("failed to ping: "+e)}))).filter(n.notBlank).flatMap((e=>t.ipv4Re.exec((0,o.toS)(e)))).map((e=>e[0])).get()),{name:"net.ipAddrFromPing",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*r.minuteMs})},78330:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.aptCachePolicyVersion=t.aptInstalledVersion=void 0;const n=i(40958),r=i(22573),s=i(45599),a=i(59455),o=i(50213),l=i(96175),u=i(84777),c=i(84542),d=i(76280),h=i(63870),f=(0,s.defer)((()=>(0,o.mkLogger)("platform.Apt")));t.aptInstalledVersion=async function(e){if(!(0,l.hasApt)())return;const t=[];for(const i of(0,a.toA)(await async function(e){if(!(0,l.hasApt)()||(0,r.blank)(e))return;const t=await(0,u.stdoutResult_)("dpkg",["-S",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});return f().debug("dpkg -S",{nativePath:e,result:t}),0!==t.code?void 0:(0,n.uniq)((0,c.splitLines)(t.result).map((e=>m.exec(e)?.[0])))}(e))){const e=await p(i);t.push({pkg:i,version:e,semver:(0,d.debianVersionToSemver)(e)})}return t};const m=/^[a-z][a-z\d+\-.]+/;async function p(e){if(!(0,l.hasApt)()||(0,r.blank)(e))return;const t=await(0,u.stdoutResult_)("apt-cache",["policy",e],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreExitCode:!0,ignoreStderr:!0,isIgnorableError:()=>!0});if(f().debug("apt-cache policy",{packageName:e,result:t}),0===t.code)for(const e of(0,c.splitLines)(t.result)){const t=/^\s*Installed: (.*)$/.exec(e);if(null!=t)return t[1]}}t.aptCachePolicyVersion=p},45969:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const n=i(73024),r=i(38639),s=i(19851),a=i(59958),o=i(43334);t.isDocker=(0,s.lazy)((()=>o.isLinux&&((0,r.toBoolean)(process.env[a.PS_IS_DOCKER])??(0,n.existsSync)("/.running-in-container"))))},29325:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const n=i(76760),r=i(19851),s=i(54993);t.isPacked=(0,r.lazy)((()=>!(0,s.toS)(__filename).includes((0,n.join)("core","platform","IsPacked"))))},46305:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pacmanInstalledVersion=t.hasPacman=void 0;const n=i(45599),r=i(50213),s=i(84777),a=i(68284),o=i(63870),l=i(43334),u=(0,n.defer)((()=>(0,r.mkLogger)("platform.Pacman")));t.hasPacman=(0,n.defer)((()=>l.isLinux&&(0,a.isNonEmptyFileSync)("/etc/pacman.conf")));const c=/is owned by (?\S+) (?\S+)/i;t.pacmanInstalledVersion=async function(e){if((0,t.hasPacman)())try{const t=await(0,s.stdoutResult_)("pacman",["-Qo",e],{timeoutMs:(0,o.commandTimeoutMs)(),ignoreExitCode:!1,ignoreStderr:!1,isIgnorableError:()=>!0,env:{LC_ALL:"C",LOCALE:"C"}});return u().tap({msg:"pacman -Qo",result:t.result.match(c)?.groups,meta:{nativePathOrBasename:e,result:t}})}catch(t){return void u().debug("pacman doesn't seem to know about "+e,{error:t})}}},43334:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const r=n(i(48161)),s=n(i(1708)),a=i(22573),o=i(38639),l=i(59958),u=r.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,o.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,o.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,a.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===r.default.arch(),t.isArm=null!=/^arm\b/i.exec(r.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,a.notBlank)(s.default.env.APPIMAGE)||(0,a.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,a.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,o.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const r=n(i(73024)),s=i(19851),a=i(43334);function o(e="/proc/cpuinfo"){if(a.isWin||a.isMac)return!1;try{return null!=r.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=o,t.isRaspberryPi=(0,s.lazy)((()=>a.isLinux_arm&&o())),t.procDeviceModel=(0,s.lazy)((()=>{try{return a.isLinux?r.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},94137:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.negateFilterName=void 0;const n=i(22573),r=i(51926),s=i(83556);t.negateFilterName=function(e){if((0,n.blank)(e))return;const t=/\s/.test(e)?e:(0,s.camel2words)(e).replace(/\bphoto structure\b/gi,"PhotoStructure");return t.match(/^not\b/)?t.replace(/^not\b/,"").trim():"not "+(0,r.stripPrefix)(t,"is ")}},78984:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Predicates=void 0;const n=i(19851),r=i(40958),s=i(68708),a=i(51926),o=i(50213),l=i(94137),u=(0,n.lazy)((()=>(0,o.mkLogger)("predicates.Predicates")));class c{static async accepted(e,...t){for(const i of t)for(const t of(0,s.values)(i)){const i=await t(e);if(!1===i||(0,a.isString)(i))return!1}return!0}static async rejected(e,...t){return!await c.accepted(e,...t)}static async explain(e,...t){const i=[],n=[],r=[];for(const o of t)for(const[t,l]of(0,s.entries)(o)){const s=await l(e);!0===s?i.push(t):!1===s||(0,a.isString)(s)?n.push(t):r.push(t)}return{accepted:i,rejected:n,notApplicable:r}}static async whyRejected(e,...t){for(const i of t)for(const[t,n]of(0,s.entries)(i))try{const i=await n(e);if(null==i||!0===i)continue;return(0,a.isString)(i)?i:(0,l.negateFilterName)(t)}catch(e){u().warn("whyRejected() caught from "+t,{error:e})}}static async logged({a:e,logger:t,msg:i,predicates:n}){const{accepted:s,rejected:a}=await c.explain(e,...n);return t.tap({msg:i,result:(0,r.isEmpty)(a),meta:{a:e,accepted:s,rejected:a}})}}t.Predicates=c},33995:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SyncPredicates=void 0;const n=i(68708),r=i(94137);class s{static firstFalse(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))if(!1===r(e))return t}static firstTrue(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i))if(!0===r(e))return t}static firstDefined(e,...t){for(const i of t)for(const[t,r]of(0,n.entries)(i)){const i=r(e);if(null!=i)return{name:t,result:i}}}static accepted(e,...t){return null==s.firstFalse(e,...t)}static whyRejected(e,...t){return(0,r.negateFilterName)(s.firstFalse(e,...t))}}t.SyncPredicates=s},45643:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const n=i(58587),r=i(59455),s=i(31562);t.existingPids=function(e){return(0,r.toA)(e).filter(n.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,n.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,i){var n,r,s,a,o=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,i,n,r){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?r.call(e,i):r?r.value=i:t.set(e,i),i},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=i(58587),d=u(i(31421)),h=u(i(1708)),f=i(40958),m=i(22573),p=i(42659),g=i(55835),y=i(31586),v=i(97790),w=i(59455),S=i(54993),b=i(54557),P=i(19851),M=i(50213),_=i(88158),E=i(409),x=i(78406),T=i(25764),D=i(99331),k=i(56519),C=i(46292),F=i(8769),O=i(83278),I=i(32144),L=i(29882),A=i(43334),R=i(24399),N=i(58261),B=(0,P.lazy)((()=>(0,M.mkLogger)("proc.Pids"))),z=10*p.secondMs;function j(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const i=(0,g.map)(t.start,(e=>e.getTime())),n=e.startTime;return(0,y.gt0)(i)&&(0,y.gt0)(n)&&Math.abs(i-n){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,I.isJsonExt)(t)&&(0,L.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))B().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,E.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{B().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,i=e.force??A.isWin,n=await this.pidfiles(),r=await this.pids(n??[]);if((0,f.isEmpty)(r))return B().info("killOldProcs(): no pidfiles"),[];const s=[],a=[],o=await(0,N.pidInfos)(r);if(null!=o){for(const r of n){const n=await r.readJson();if(null==n){B().warn("killOldProcs(): failed to read pidfile "+r.base),await r.unlink("debug");continue}const l=n.pid;if(!(0,y.gt0)(l)){B().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+r.base,{json:n,pid:l}),await r.unlink("debug");continue}const u=o.find((e=>e.pid===l));if(null==u||!j(n,u)){B().debug("killOldProcs(): pid no longer present: unlinking "+r.base,{json:n,pidEntry:u}),await r.unlink("debug"),s.push(n);continue}const c=(0,y.gt0)(n.timeoutMs)?n.startTime+n.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(n.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(B().info("killOldProcs(): killing",{reason:d,json:n}),a.push(W(l,i,!1)),s.push({...n,...u}))}return a.length>0&&await Promise.allSettled(a),s}(0,F.onError)("Pids.killOldProcs(): failed to get process information")}}),a.set(this,void 0)}async addPid_(e,t,i=!1){if(null==e)throw new Error("undefined info");const a=e.pid;if(!(0,y.gt0)(a))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(a)?(i&&o(this,r,"f").delete(l),o(this,r,"f").getOrSet(l,(async()=>{const i=o(this,n,"m",s).call(this,e.pid),r=(0,v.opt)((0,_.Try)((()=>(0,L.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),a=t.getTime(),l={...e,cmd:r,startTime:a};return await i.writeJson_(l),B().debug("addPid() wrote "+i,l),i}))):(o(this,r,"f").delete(l),void B().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=o(this,n,"m",s).call(this,e);return(0,k.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{B().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==o(this,a,"f")||o(this,a,"f").ended)&&l(this,a,new x.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:T.EndableRanks.first}),"f"),o(this,a,"f")}cancelInterval(){o(this,a,"f")?.end(),l(this,a,void 0,"f")}}t.Pids=H,r=new WeakMap,a=new WeakMap,n=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},H.instance=(0,P.lazy)((()=>(0,g.map)((0,C.configDir)(),(e=>new H(O.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return H.instance()?.addPid_(e,t)}},58261:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const r=i(31421),s=i(48161),a=n(i(1708)),o=i(40958),l=i(22573),u=i(42659),c=i(31586),d=i(68708),h=i(59455),f=i(54993),m=i(48884),p=i(53507),g=i(19851),y=i(50213),v=i(84968),w=i(48963),S=i(56519),b=i(84777),P=i(8103),M=i(45879),_=i(43334),E=i(24399),x=i(45643),T=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function D(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function k(e){if(_.isLinux)return async function(e){const t=[];for(const i of e)t.push(V(await(0,M.readFileMaybe)("/proc/"+i+"/stat")));return T().tap({msg:"pidInfoProc",result:(0,o.compact)(t)})}(e);const t=(0,x.existingPids)(e),i=(await(0,m.collectBatchedAsync)(t,20,_.isWin?I:N)).filter((e=>D(e)&&t.includes(e.pid)));return T().tap({msg:"pidInfos()",result:i,meta:{pids:e}})}t.isProcEntry=D,t.pidInfo=async function(e){return(0,S.thenMap)(k([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,o.isEmpty)(e)?[]:(0,S.thenMap)((0,x.existingPids)(e),(t=>{const i=[a.default.pid,...t];return e.filter((e=>!i.includes(e)))}))},t.pidInfos=k;const C="Get-Process",F="| Select-Object -Property Id,ProcessName,StartTime";function O(e){return(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).join(",")}async function I(e){if(E.PowerShell.instance().ended)return R(e);const t=[C,"-Id",O(e),"-ErrorAction SilentlyContinue",F].join(" ");return(0,S.thenMap)(E.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const L={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},A=["CommandLine","CreationDate","ProcessId"];async function R(e){const t=["process"];if((0,o.isNotEmpty)(e)){const i=(0,o.uniq)([...e.filter(c.gt0),a.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",i)}t.push("get",A.join(","));const i=await(0,b.stdoutResult_)((0,P.wmic)(),t,L),n=(0,d.onlyReqValued)((0,p.parseFixed)(A,i.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return n.find((e=>e.pid===a.default.pid))||n.push({pid:a.default.pid,start:new Date(v.StartTs),cmd:"node "+a.default.title}),n}async function N(e){return t=(await(0,b.stdoutResult_)("ps",["-p",O(e),"-wwwo","pid,lstart,command"],{...L,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=R;const B=(0,g.lazy)((()=>{try{if(_.isLinux)return(0,c.toGt0)((0,r.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){T().warn("clk_tck failed",{error:e})}return 100})),z=(0,g.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),j=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function V(e){const t=j.exec((0,f.toS)(e))?.groups,i=(0,c.toInt)(t?.pid),n=t?.comm,r=(0,c.toInt)(t?.starttime);return(0,c.gt0)(i)&&!(0,l.blank)(n)&&(0,c.gt0)(r)?{pid:i,cmd:n,start:new Date(z()+r/B()*u.secondMs),state:t?.state}:void 0}},87445:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isProgressEvt=t.progressEvtToS=void 0;const n=i(40958),r=i(22573),s=i(31586),a=i(29882),o=i(97352);t.progressEvtToS=function(e){const t=(0,r.blank)(e.path)?null:(0,a.ellipsizePath)({p:e.path,maxLength:80});return(0,n.compactBlanks)([t,e.op,!0===e.done?"done":(0,s.fmtPct)(e.pct)]).join(": ")},t.isProgressEvt=function(e){return null!=e&&(0,r.notBlank)(e.op)&&(0,o.within)(0,100,e.pct)}},41944:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onProgressEvt=t.emitProgressEvt=t.recentDone=t.recentProgress=t.DefaultThrottleMs=void 0;const n=i(19851),r=i(42659),s=i(31586),a=i(12089),o=i(75387),l=i(34102),u=i(87445);t.DefaultThrottleMs=500,t.recentProgress=(0,n.lazy)((()=>new o.TTLMap(15*r.secondMs))),t.recentDone=(0,n.lazy)((()=>new o.TTLMap(2*r.minuteMs))),t.emitProgressEvt=function(e){if((0,u.isProgressEvt)(e)){const i=!0===e.done;i&&null!=e.path&&(0,t.recentDone)().set(e.path,e),!i&&null!=e.path&&(0,s.gte)((0,t.recentProgress)().lastSetOrGetTs(e.path),Date.now()-t.DefaultThrottleMs)||((0,t.onProgressEvt)(e),null!=e.path&&(0,t.recentProgress)().set(e.path,e))}},t.onProgressEvt=(0,a.shim1)({name:"onProgressEvt",impl:async e=>{(0,l.ee)().emit("progress",e)}})},33847:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PullProgressObserver=void 0;const n=i(98553),r=i(31586),s=i(409),a=i(78406),o=i(25764),l=i(99331),u=i(56519),c=i(98314),d=i(41944);class h extends a.EndableInterval{constructor(e,t,i,r=d.DefaultThrottleMs){super({name:"PullProgressObserver("+(0,n.stringify)(e)+")",callback:()=>this.onInterval(),intervalMs:r,rank:o.EndableRanks.first}),this.ctx=e,this.total=t,this.progress=i,this.throttleMs=r,this.start=Date.now(),this.onInterval=(0,s.rateLimited)({name:"PullProgressObserver.onInterval",f:()=>(0,l.ending)()?this.end():(0,u.thenMap)(this.progress(),(e=>this.emit(e))),minCallDelayMs:this.throttleMs})}observe(e){return e.then((()=>this.completed()),(e=>{this.logger.warn("failed: ",e),this.ctx.op+=" (failed: "+(0,c.errorToS)(e,{maxLen:128})+")",this.end()})),e}emit(e){(0,r.gt0)(e)&&(0,d.emitProgressEvt)({...this.ctx,pct:(0,r.pct)(e,this.total),elapsedMs:Date.now()-this.start,done:this.done})}completed(){this.done=!0,this.ended||(this.emit(this.total),this.end())}}t.PullProgressObserver=h},38156:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PushProgressObserver=void 0;const n=i(31586),r=i(41944);t.PushProgressObserver=class{constructor(e,t){this.context=e,this.total=t,this.start=Date.now()}toJSON(){}incrProgress(e=1){this.onProgress(e+(this.current??0))}onProgress(e){this.current=(e??this.current??0)+1,(0,n.gte)(this.current,this.total)&&(this.done=!0),this.emit()}completed(){this.done=!0,this.current=this.total,this.emit()}emit(){(0,r.emitProgressEvt)({...this.context,pct:(0,n.pct)(this.current,this.total),elapsedMs:Date.now()-this.start,done:this.done})}}},24399:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const n=i(58587),r=i(19851),s=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(13538),c=i(36557),d=i(14121),h=i(50213),f=i(7282),m=i(45255),p=i(81168),g=i(25764),y=i(38836),v=i(99331),w=i(56519),S=i(31562),b=i(84777),P=i(34102),M=i(43334),_=i(28874),E=i(63870),x="{ready}",T=" | ConvertTo-Json -Compress";function D(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=D,(0,o.later)((()=>(0,P.ee)().on("clearCache",(()=>k.instance.prior()?.clearMockResults()))));class k extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new n.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",_.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${x}"}`,...(0,s.mapNotBlankOr)(_.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:x,fail:"Error",exitCommand:"exit",maxProcs:_.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,E.commandTimeoutMs)(),maxIdleMsPerProcess:a.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),_.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(_.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,T),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const i=this.mockResults.get(e);return t(i.stdout,i.stderr,i.passed)}try{const i=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new n.Task(e,((i,n,r)=>t((0,l.map)(i,(t=>(0,p.stripPrefix)(t,e))),n,r)))));return this.logger.tap({msg:"execute()",result:i.result,meta:{elapsedMs:i.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,T),((e,t,i)=>({stdout:e,stderr:t,passed:i})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const i=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(i)}),JSON.parse(i)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+D(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=k,k.instance=(0,r.lazy)((()=>{if(!M.isWin)throw new Error("PowerShell isn't available on this platform");return new k})),t.checkPowerShell_=async function(){const e=k.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,E.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const n=i(50989);t.AggregateTypes=(0,n.strEnum)("union","intersection")},71988:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const n=i(50989);t.AssetFileSortCriteria=(0,n.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const n=i(22573),r=i(38639),s=i(83179);class a extends s.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:r.toBoolean})}}t.BooleanSetting=a},90536:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const n=i(22573),r=i(31586),s=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,r.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=o},75164:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const n=i(22573),r=i(31586),s=i(97790),a=i(83179);class o extends a.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(n.notBlank).flatMap(r.toInt).map((t=>(0,r.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,r.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=o},10546:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const n=i(50989);t.ColorDistanceFunctions=(0,n.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const n=i(36507),r=i(22573),s=i(45599),a=i(50213),o=i(81168),l=i(98314),u=i(8769),c=i(80372),d=(0,s.defer)((()=>(0,a.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,o.trimQuotes)(e);return void((0,r.blank)(t)||(0,n.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,i){try{return(0,r.blank)(t)?void 0:(0,n.Cron)(t,{name:e,unref:!0,protect:!0,catch:i=>(0,u.onError)(i,{name:e,crontab:t}),...i})}catch(i){return void d().warn("invalid cron",{name:e,crontab:t,error:i})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const n=i(70488),r=i(91655),s=i(83179);class a extends s.Setting{constructor(e){super({...e,toEnv:n.encodeDuration,fromEnv:n.decodeDuration})}get valueOrDefault(){return(0,n.decodeDuration)(super.valueOrDefault)}get value(){return(0,n.decodeDuration)(super.value)}set value(e){super.userValue=(0,n.decodeDuration)(e)}get humanValue(){return(0,r.fmtFullDuration)(this.value)}get fileValue(){return(0,n.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,n.decodeDuration)(e)}}t.DurationSetting=a;class o extends s.Setting{constructor(e){super({...e,toEnv:n.encodeDuration,fromEnv:n.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,n.decodeDuration)(this.defaultValue)}get fileValue(){return(0,n.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=o},9945:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const n=i(22573),r=i(31586),s=i(83179);class a extends s.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:r.toFloat})}}t.FloatSetting=a},69589:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.forceContextOrSetting=t.pickForceContext=void 0;const n=i(38639),r=i(68708),s=i(50989),a=i(76740),o=i(28874),l=(0,s.strEnum)("forceSync","forceFilters","skipPreviews","forceRebuildPreviews","skipAssetTagging","recountAllTags","skipAssetRepair");t.pickForceContext=function(e){return(0,r.pick)(e,...l.values)},t.forceContextOrSetting=function(e){const t={...(0,r.pick)(e??{},"retries","halt","path"),...(0,r.fromEntries)(l.values.map((t=>[t,e?.[t]??(0,n.isTrue)(o.Settings[t]?.valueOrDefault)])))};return t.retries??(t.retries=0),t.halt??(t.halt=new a.Abortable),t}},74589:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const n=i(22573),r=i(31586),s=i(83179);class a extends s.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:r.toInt})}}t.IntegerSetting=a},4175:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.disableExternalNetworkRequests=t.setQuickSyncMode=t.setStrictDeduping=t.disableAllFilters=t.handleDeprecatedSettings=t.handleMetaSettings=void 0;const n=i(19851),r=i(22573),s=i(38639),a=i(42659),o=i(68708),l=i(51926),u=i(50213),c=i(55939),d=i(10546),h=i(67958),f=i(55948),m=i(28874),p=i(80496),g=(0,n.lazy)((()=>(0,u.mkLogger)("settings.MetaSettings")));function y(e,t){return m.Settings[e].value??t.find((t=>t.name===e))?.value??m.Settings[e].defaultValue}function v(){m.Settings.respectFileExtensions.envValue=!1,m.Settings.requireMakeModel.envValue=!1,m.Settings.rejectRatingsLessThan.envValue=-100,m.Settings.minImageDimension.envValue=0,m.Settings.minVideoDimension.envValue=0,m.Settings.minVideoDurationSec.envValue=0,m.Settings.maxVideoDurationSec.envValue=0,m.Settings.minAssetFileSizeBytes.envValue=0,m.Settings.maxAssetFileSizeBytes.envValue=0,m.Settings.validateJpegImages.envValue=!1,m.Settings.validateRawImages.envValue=!1,m.Settings.validateVideos.envValue=!1}function w(){m.Settings.strictDeduping.envValue=!0,m.Settings.useImageHashes.envValue=!0,m.Settings.minExposureSettingsCoeffPct.envValue=98,m.Settings.minImageCoeffPct.envValue=95,m.Settings.imageHashFuzzyDateDelta.envValue=1,m.Settings.imageHashDifferentMimetypesDelta.envValue=-10,m.Settings.imageHashGreyscaleDelta.envValue=1}t.handleMetaSettings=function(e){M(m.Settings.quickSyncMode.valueOrDefault),y("disableAllFilters",e)&&v(),y("strictDeduping",e)&&w(),(y("optOut",e)||y("noNetwork",e))&&_()},t.handleDeprecatedSettings=async function(){if((0,s.isTrue)(m.Settings.scanMyPictures.value)){m.Settings.scanMyPictures.unset();const e=await(0,c.picturesDir)();g().info("Upgrading setting scanMyPictures to scanPaths",{priorValues:m.Settings.scanPaths.values,newPath:e}),m.Settings.scanPaths.push(e)}{const e=m.Settings.assetSubdirectoryDatestampFormat.value;if(m.Settings.assetSubdirectoryDatestampFormat.unset(),(0,r.blank)(m.Settings.assetPathnameFormat.value)&&(0,r.notBlank)(e)){const t=(0,l.ensureSuffix)(e,"/")+"BASE";g().info("Upgrading setting assetSubdirectoryDatestampFormat to assetPathnameFormat",{prior:e,newValue:t}),m.Settings.assetPathnameFormat.value=t}}if(m.Settings.dbBackupIntervalMinutes.hasValue()&&!m.Settings.dbBackupIntervalMs.hasValue()){const e=m.Settings.dbBackupIntervalMinutes.valueOrDefault*a.minuteMs;g().info("Upgrading setting dbBackupIntervalMinutes to dbBackupIntervalMs",{newValue:e}),m.Settings.dbBackupIntervalMs.value=e}if(m.Settings.siblingInferenceBasenameCoeff.hasValue()&&!m.Settings.siblingInferenceBasenameCoeffPct.hasValue()){const e=Math.round(100*m.Settings.siblingInferenceBasenameCoeff.valueOrDefault);g().info("Upgrading setting siblingInferenceBasenameCoeff to siblingInferenceBasenameCoeffPct",{newValue:e}),m.Settings.siblingInferenceBasenameCoeffPct.value=e}if(m.Settings.enableSiblingInference.hasValue()&&!m.Settings.siblingInference.hasValue()){const e=m.Settings.enableSiblingInference.valueOrDefault?m.Settings.siblingInference.valueOrDefault:p.TagInferenceSettingValues.never;g().info("Upgrading setting enableSiblingInference to siblingInference",{newValue:e}),m.Settings.siblingInference.value=e}},t.disableAllFilters=v,t.setStrictDeduping=w;const S=[m.Settings.validateJpegImages,m.Settings.validateRawImages,m.Settings.validateVideos,m.Settings.transcodeVideos,m.Settings.previewMinimized,m.Settings.previewProgressive,m.Settings.previewSharpen,m.Settings.useImageHashes,m.Settings.enableSiblingInference],b={argon2TimeCost:8,argon2MemoryCostMB:64,argon2Parallelism:1},P={argon2TimeCost:4,argon2MemoryCostMB:32,argon2Parallelism:1};function M(e){for(const t of S)e?t.tmpValueIfUnset=!1:t.tmpValue=void 0;const t=e?P:b;for(const[e,i]of(0,o.entries)(t))m.Settings[e].defaultValue=i;m.Settings.dominantColorPixels.defaultValue=e?256:f.DominantColorPixelsDefault,m.Settings.dominantColorKmeansRuns.defaultValue=e?0:h.DominantColorKmeansRunsDefault,m.Settings.dominantColorDeltaE.defaultValue=e?d.ColorDistanceFunctions.cie76:d.ColorDistanceFunctions.ciede2000}function _(){m.Settings.autoUpdateCheck.defaultValue=!1,m.Settings.allowUserAgent.defaultValue=!1,m.Settings.reportErrors.defaultValue=!1,m.Settings.autoRefreshLicense.defaultValue=!1,m.Settings.noNetwork.defaultValue=!0}t.setQuickSyncMode=M,t.disableExternalNetworkRequests=_},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const n=i(22573),r=i(53265),s=i(87652);class a extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,n.blank)(e)?void 0:(0,r.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=a},23561:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const n=i(22573),r=i(31586),s=i(83179);class a extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:n.notBlankToS,fromEnv:r.toFloat})}}t.OptionalFloatSetting=a},69005:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const n=i(22573),r=i(31586),s=i(83179);class a extends s.Setting{constructor(e){super({...e,toEnv:n.notBlankToS,fromEnv:r.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=a},87652:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const n=i(83179);class r extends n.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=r},28283:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const n=i(51926),r=i(83556);t.nameFromEnv=function(e){return(0,r.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,n.ensurePrefix)((0,r.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,i){var n,r,s=this&&this.__classPrivateFieldGet||function(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const a=i(19851),o=i(40958),l=i(79666),u=i(50357),c=i(57924),d=i(98553),h=i(55835),f=i(68708),m=i(39926),p=i(46891),g=i(42279),y=i(59455),v=i(40583),w=i(81168),S=i(44198),b=i(96706),P=i(34102),M=i(28283),_=i(81075),E=i(98778),x=i(10357);t.settingsToObj=function(e){const t={};for(const i of e)i.hasValue()&&(t[i.name]=i.value);return t},t.Setting=class{constructor(e){n.add(this),this.opts=e,this._envValue=(0,a.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,n,"m",r).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const i=this.opts.whyInvalid?.(e);return null!=i?s(this,n,"m",r).call(this,e??t)+": "+i:null==this.fromEnv(e)?s(this,n,"m",r).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const i=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=i)return i}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,o.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const i=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(i)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,o.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,M.envFromName)(e),this._keys=(0,o.uniq)([...this._names.map(M.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return _.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const i=e??(0,S.env)(),n=t??this.value;return null!=n&&(i[this.key]=this.toEnv(n)),null==e&&b.caseInsensitiveEnv.unset(),i}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const i=e??(0,S.env)(),n=this.toEnvValue(t);return null!=n&&(i[this.key]=n,null==e&&b.caseInsensitiveEnv.unset()),i}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],x.WrapComments);function i(e,i){(0,o.isEmpty)(i)||t.push(...(0,w.wrap)(["",(1===i.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(i.map((e=>(0,d.stringify)(e))))],x.WrapComments))}i("alias",this.opts.aliases),i("environment alias",this.altKeys);for(const[e,i]of(0,f.entries)(this.addToJSON())){const n=Array.isArray(i)?(0,c.orList)(i.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(i);t.push(...(0,w.wrap)(["",e+": "+n],x.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,E.wrapTomlToLines)({lines:e,wrap:x.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,E.wrapTomlToLines)({lines:e,wrap:x.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,E.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},n=new WeakSet,r=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const n=i(50989);t.SettingCategories=(0,n.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const n=i(58587),r=i(76760),s=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(73722),d=i(68708),h=i(50989),f=i(12168),m=i(54993),p=i(37975),g=i(9092),y=i(40583),v=i(79840),w=i(7282),S=i(12801),b=i(4328),P=i(70488),M=i(84248),_=i(5531),E=i(99315),x=i(34365),T=i(34580),D=i(96706),k=i(50274),C=i(33866),F=i(52086),O=i(48584),I=i(45969),L=i(43334),A=i(24540),R=i(70379),N=i(71300),B=i(33209),z=i(48987),j=i(68268),V=i(61208),W=i(99023),H=i(30577),U=i(1485),q=i(19861),G=i(55111),$=i(30933),J=i(22859),K=i(71988),Z=i(38483),X=i(90536),Y=i(75164),Q=i(10546),ee=i(90967),te=i(67958),ie=i(55948),ne=i(57039),re=i(9945),se=i(74589),ae=i(844),oe=i(96093),le=i(23561),ue=i(69005),ce=i(87652),de=i(81075),he=i(58305),fe=i(57571),me=i(72564),pe=i(80372),ge=i(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new oe.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new ne.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new ne.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new ne.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Z.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Z.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new ne.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>q.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>U.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:U.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>U.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Z.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new ne.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>L.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Z.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new ne.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Z.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,I.isDocker)()}),cspReportOnly:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Z.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Z.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!L.isElectron}),commandTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new ne.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new n.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new ne.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new ne.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new ne.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>L.isMac?"100ms":L.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new ne.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new ne.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new Y.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new re.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new Y.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new Y.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Z.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new Y.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:M.AutoVacuumModes,defaultValue:M.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:_.CheckpointTypes,defaultValue:_.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:x.SynchronousModes,defaultValue:x.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:E.RepairModes,defaultValue:E.RepairModes.dump}),maxBusyDbMs:new ne.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to apply a migration, vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 2 minutes should be very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"2m"}),dbBackupIntervalMs:new ne.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new X.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new Y.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new Y.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Z.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Z.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Z.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,I.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:C.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Z.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Z.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>L.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Z.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Z.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:H.UpdateChannels}),autoUpdateCheck:new Z.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Z.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Z.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,T.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Z.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new Y.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new Y.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Z.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Z.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new Y.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,A.isRaspberryPi)()}),taskTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Z.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Z.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Z.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Z.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,$.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Z.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new Y.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:k.SidecarExts,defaultValue:k.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Z.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:J.AggregateTypes.intersection,strEnum:J.AggregateTypes}),useImageHashes:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Z.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new Y.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new re.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new Y.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:ie.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new Y.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new Y.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new Y.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new Y.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Z.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Z.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,$.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:F.CropStrategies.attention,strEnum:F.CropStrategies}),videoFrameAtSec:new re.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Z.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,a.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(L.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:K.AssetFileSortCriteria}),variantSortCriteriaPower:new X.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Z.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>B.DefaultIncludedPreviewTags}),disableAllFilters:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Z.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:O.SharpFailOns.truncated,strEnum:O.SharpFailOns}),validateRawImages:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Z.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.DefaultCapturedAtTagsConst}),useMWG:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:N.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>z.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:ae.MinValidYear}),maxValidFutureMs:new ne.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new re.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new Y.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Z.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:R.DateTagFormats.ym,strEnum:R.DateTagFormats}),tagDateFromStat:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:j.KeywordReparentingStrategies.move,strEnum:j.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Z.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:V.NameTagFormats["as-is"],strEnum:V.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,I.isDocker)()}),tagDisplayNameFSLabels:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Z.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new ne.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Z.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,i]of(0,d.entries)(t.Settings))i._setName(e);function Se(e){const i=((0,l.blank)(e)?"":e).split(r.delimiter);return(0,I.isDocker)()&&i.unshift("/opt/photostructure/tools/bin"),i.push(...t.Settings.toolPaths.valueOrDefault),(0,a.uniq)(i).filter(l.notBlank).join(r.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,D.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,o.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const i of(0,t.persistedSettings)()){for(const t of i.names)e.set(t,i);for(const t of i.keys)e.set(t,i)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const n=i(19851),r=i(31586),s=i(7282),a=i(49776),o=i(46292),l=i(32774),u=i(55086),c=i(46296),d=i(55939),h=i(96706),f=i(83278),m=i(92234),p=i(45969),g=i(60865),y=i(30933),v=i(15674),w=i(28874);t.setSettingsDefaults=(0,n.lazy)((()=>{w.Settings.configDir.opts.defaultValue=o.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=a.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,r.sigFigs)(50/(0,y.cpuCount)(),2)}))},2858:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeEnv=t.nukeSettings=t.clearSettings=t.clearLibraryDirSetting=t.importFileSettings_=t._readSettings=t.writeLibrarySettings_=t.readLibrarySettings=t.writeAllSettings_=t.writeSystemSettings_=t.versionForSettings=t._libraryHasSettings=t.libraryHasSettings=t.maybeUpgradeLibrarySettings=t.maybeUpgradeSystemSettings=t.librarySettingsVersion=t.systemSettingsVersion=t.savedLibraryDir=t.envOrSavedLibraryDir=t.readSystemSettings=t.readSettings=t.librarySettingsFile=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(22573),o=i(42659),l=i(41400),u=i(50357),c=i(26905),d=i(96249),h=i(57924),f=i(98553),m=i(55835),p=i(68708),g=i(39926),y=i(51926),v=i(54993),w=i(50213),S=i(81168),b=i(83556),P=i(87290),M=i(98314),_=i(34102),E=i(83278),x=i(95696),T=i(60865),D=i(4175),k=i(83179),C=i(81075),F=i(28874),O=i(41692),I=i(84438),L=i(32707),A=i(6707),R=i(98778),N=i(55018),B=i(10357),z=(0,n.lazy)((()=>(0,w.mkLogger)("settings.SettingsIO")));function j(e){return(0,P.libraryDataDirPosixFile)(e)?.join(I.SettingsToml)}async function V(e=(0,L.systemSettingsFile)()){if(null!=e)return Y(E.BaseFile.for(e))}async function W(){try{return(0,a.toNotBlank)((await(0,A.readTomlFile_)((0,L.systemSettingsFile)()))?.[F.Settings.libraryDir.name])}catch{return}}function H(e){return(0,A.readTomlFile_)(e).then((e=>e?.version),(()=>{}))}function U(){return H((0,L.systemSettingsFile)())}function q(e){return H(j(e))}function G(){t.libraryHasSettings.refresh()}function $(e){const t=j(e);return z().tap({msg:"_libraryHasSettings",result:t?.clear().existsSync()??!1,level:"info",meta:{libraryDir:e,settings:F.Settings.libraryDir.valueOrDefault,librarySettingsFile:t?.nativePath}})}async function J(e,i){if(null==e)return void z().warn("writeToml(): null file, failed to write settings",{file:e,settings:i});const n=await e.clear().isNonEmpty(),r=n?e.wip():e;if(await async function(e,i){const n=[(0,g.padding)("#",80)];n.push(...ie("","Howdy!","",`These are ${i[0].categoryType} settings for PhotoStructure.`,""," - Please shut down PhotoStructure before editing this file.",""," - PhotoStructure has TWO settings files! See"," https://photostructure.com/getting-started/advanced-settings/#omg-why-2"," to see why.","",' - NOTE: lines starting with a "#" are commented out.',"",' - To override a setting, uncomment the line by removing the "# " from'," the beginning of the line, and change the value.","",' - All duration settings end with "Duration" or "Ms" (for milliseconds).'," See https://photostructure.com/getting-started/advanced-settings#duration"," for details.",""," - See https://photostructure.com/settings/ for more documentation.","Thanks for using PhotoStructure! Visit https://forum.photostructure.com/ if you find any bugs or have any questions, ideas, or feedback. We'd love to hear from you.","","This is the version of PhotoStructure that wrote this file--please don't edit the following line.")),n.push(...(0,R.stringifyToml)({version:(0,t.versionForSettings)()})),n.push("","");let r="";for(const e of i){const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==r&&(r=t,n.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#","","")),n.push(...e.toTomlLines()),n.push("","")}await e.writeText_("\n"+n.map(y.trimRight).join("\n")+"\n\n"),(0,_.ee)().emitDebounced("settingsChanged")}(r,i),z().info("writeToml(): wrote settings",{dest:r,file:e,nonDefaults:(0,k.settingsToObj)(i),wip:n}),n){const t=await(0,A.readTomlFile_)(r),i=await(0,A.readTomlFile_)(e);(0,u.eql)(t,i)?(z().info("Equivalent contents",{dest:r,file:e,a:t,b:i}),await r.unlink()):(z().info("Archiving prior, different contents",{dest:r,file:e}),await e.renameYMDHMS_({subdir:"archive"}),await r.unwip_())}}async function K(e=(0,L.systemSettingsFile)()){const t=x.PosixFile.forMaybe(e);return null!=t&&await J(t,(0,F.persistedSystemSettings)()),t}function Z(e){return Y(j(e))}async function X(e){await(0,P.setupLibraryDataDir_)((0,a.firstNotBlank)(e,F.Settings.libraryDir.value));const i=j(e);return z().info("writeLibrarySettings()",{file:i}),null!=i&&(await J(i,(0,F.persistedLibrarySettings)()),t.libraryHasSettings.refresh()),i}async function Y(e){if(null==e)return[];const t=z().addContext(".importFileSettings("+e?.nativePath+")");try{const i=await Q(e);return(0,r.isNotEmpty)(i.warnings)&&t.warn("Problems during import",i.warnings),i.settings}catch(e){return t.error("Cannot read: "+(0,M.errorToS)(e)),[]}}async function Q(e){const t=z().addContext(".importFileSettings_("+e.nativePath+")"),i=await e.stat();if(null==i)return{settings:[],warnings:["Cannot read"]};if(0===i.size)return{settings:[],warnings:["Cannot read empty file"]};const n=await(0,A.readTomlFile_)(e);if(null==n)return{settings:[],warnings:["No settings found"]};const s=[],a=(0,r.compact)((0,p.entries)(n).map((([e,t])=>{if("version"===e)return;const i=(0,F.getSettingByNameOrKey)(e);if(null==i)s.push(`Failed to import "${e}"${(0,m.mapOr)((0,F.ciSettings)().lookupNearest(e),(e=>`: did you mean "${e.key}"?`),"")}`);else{const e=i.whyInvalidValue(t);if(null==e)return i.fileValue=t,i;s.push(e)}})));return t.info("loaded",{settings:(0,k.settingsToObj)(a),warnings:(0,r.toNotEmpty)(s)}),await(0,D.handleDeprecatedSettings)(),(0,D.handleMetaSettings)(a),{settings:a,warnings:s}}t.librarySettingsFile=j,t.readSettings=(0,n.lazy)((async()=>{await V(),(0,t.libraryHasSettings)()&&await Z()}),o.minuteMs),t.readSystemSettings=V,t.envOrSavedLibraryDir=async function(){return F.Settings.libraryDir.valueOrDefault??W()},t.savedLibraryDir=W,t.systemSettingsVersion=U,t.librarySettingsVersion=q,t.maybeUpgradeSystemSettings=async function(){(0,t.versionForSettings)()!==await U()&&await K()},t.maybeUpgradeLibrarySettings=async function(){(0,t.libraryHasSettings)()&&(0,t.versionForSettings)()!==await q()&&await X()},t.libraryHasSettings=(0,n.lazy)((()=>$())),t.libraryHasSettings.unset=()=>{z().error("libraryHasSettings.unset() is invalid",(0,c.shortStack)())},(0,l.later)((()=>{(0,_.ee)().on("clearCache",G),(0,_.ee)().on("settingsChanged",G),F.Settings.libraryDir.watchLater(G)})),t._libraryHasSettings=$,t.versionForSettings=(0,n.lazy)((()=>(0,T.baseVersion)())),t.writeSystemSettings_=K,t.writeAllSettings_=function(e){return J(x.PosixFile.for(e),(0,F.persistedSettings)())},t.readLibrarySettings=Z,t.writeLibrarySettings_=X,t._readSettings=Y,t.importFileSettings_=Q;const ee=(0,n.lazy)((()=>new Set([F.Settings.noNetwork,F.Settings.httpPort,F.Settings.license,F.Settings.logStdout,F.Settings.logLevel].map((e=>e.key)))));function te(){for(const e of(0,p.values)(F.Settings))ee().has(e.key)||e.unset();(0,_.ee)().emit("settingsChanged")}function ie(...e){return(0,d.flatten)(e.map((e=>(0,S.wrap)(e,B.WrapComments))))}t.clearLibraryDirSetting=async function(){await V(),F.Settings.libraryDir.unset(),await K()},t.clearSettings=te,t.nukeSettings=async function(){te(),await(x.PosixFile.forMaybe((0,L.systemSettingsFile)())?.unlink("trace")),await(x.PosixFile.forMaybe(j())?.unlink("trace")),(0,_.ee)().emit("clearCache"),O.setSettingsDefaults.refresh()},t.writeEnv=async function(e,t){const i=[];i.push(...ie("",`Welcome to PhotoStructure! These are the settings for version ${(0,T.baseVersion)()}.`,"","Please see https://photostructure.com/environment-variables for more information about using environment variables with PhotoStructure.","",'As of version 2.1, ".env" files (like this one) can be imported by PhotoStructure, but requires extra configuration. See https://photostructure.com/faq/environment-variables/#PS_ENV_FILE for details.')),i.push("",""),i.push(...ie("","The following settings categories are stored in the system settings.toml:","",...(0,s.sort)([...C.SystemCategories]).map((e=>"* System."+e)),"","The following settings categories are stored in the library settings.toml:","",...(0,s.sort)([...C.LibraryCategories]).map((e=>"* Library."+e)),"","Please visit https://forum.photostructure.com if you find anything that may be a bug or have any questions, ideas, or feedback. We'd love to hear from you!")),i.push("",""),i.push(...ie("-------------","PS_CONFIG_DIR","-------------","","If the environment variable PS_CONFIG_DIR is set, PhotoStructure will use that value as your system configuration directory.","","This is an advanced setting--we recommend using the default value, if possible.","","If the PS_CONFIG_DIR environment variable is not set, the default is specific to your operating system:","",'- On Docker: "/ps/config" if that bind-mount exists, otherwise "/ps/library/.photostructure/docker-config".',"",'- On Linux: firstNonBlank([$XDG_DATA_HOME, $XDG_CONFIG_HOME, "$HOME/.config"]) + "/PhotoStructure"',"",'- On macOS: "$HOME/Library/Application Support/PhotoStructure"',"",'- On Windows: "$APPDATA/PhotoStructure" ($APPDATA is normally set to $HOME/AppData/Roaming)')),i.push("",""),i.push(...ie("-----------","PS_ENV_FILE","-----------","","If set, PhotoStructure will attempt to read the .env file specified by this environment variable.","","This must be a full pathname.","","Any value set by this file will override values in settings.toml files.","","See https://photostructure.com/faq/environment-variables/#alternative-coming-in-v21-support-for-env-files for details.")),i.push("","");let n="";t.forEach((e=>{const t=`${(0,S.capitalize)(e.categoryType)}.${e.category.toLowerCase()}`;t!==n&&(n=t,i.push("",(0,g.padding)("#",78),"#","# Settings for "+t+":","#",""));const s=`${e.key} or ${e.name}`,a={...e.addToJSON()};(0,r.mapNotEmpty)(e.altKeys,(e=>a.aliases=(0,h.orList)(e)));const o=(0,p.entries)(a).map((([e,t])=>`${(0,S.capitalize)((0,b.camel2snake)(e)).replace(/_+/g," ")}: ${(0,N.valueToS)(t)}`));(0,r.isNotEmpty)(o)&&o.push(""),i.push(...ie((0,g.padding)("-",s.length),s,(0,g.padding)("-",s.length),"",...!0===e.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],e.opts.description.replace(/\n+/g,"\n\n"),"",...e.transient?["This setting is transient and only set via environment variables.","\n"]:[],...o,`${e.key}=${(0,f.stringify)((0,v.toS)(e.opts.toEnv(e.fileValue??e.defaultValue)))}`)),i.push("","")})),await e.writeText_(i.map((e=>(0,y.trimRight)(e))).join("\n"))}},84438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const n=i(76760),r=i(40958),s=i(22573),a=i(98553),o=i(55835),l=i(59455),u=i(83179);function c(e){return null==e?void 0:(0,a.stringify)(e)}t._join=c;function d(e){return(0,o.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,r.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",n.delimiter])if(t.includes(e))return(0,r.compactBlankish)(t.split(e));return[t]}}(e),r.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,r.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,r.isEmpty)(e)||(this.value=this.toValidValues((0,r.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,r.isEmpty)(this.values)}isNotEmpty(){return(0,r.isNotEmpty)(this.values)}toNotEmpty(){return(0,r.toNotEmpty)((0,r.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const n=i(83179);class r extends n.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=r},72564:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const n=i(40958),r=i(98553),s=i(55835),a=i(58305);class o extends a.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,r.stringify)((0,n.uniq)(e)))),fromEnv:t=>{return i=t,r=e.strEnum,(0,n.compact)((0,a.splitStringArray)(i)?.map((e=>r.getCI(e))));var i,r},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=o},80372:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const n=i(22573),r=i(81168),s=i(83179);class a extends s.Setting{constructor(e){super({toEnv:o,fromEnv:o,...e})}hasValue(){return(0,n.notBlank)(this.value)}}function o(e){return null==e?void 0:(0,r.trimQuotes)(e)}t.StringSetting=a},32707:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const n=i(76760),r=i(55835),s=i(46292),a=i(84438);t.systemSettingsFile=function(){return(0,r.map)((0,s.configDir)(),(e=>(0,n.join)(e,a.SettingsToml)))}},80496:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const n=i(50989);t.TagInferenceSettingValues=(0,n.strEnum)("never","always","auto")},6707:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const n=i(90858),r=i(44652),s=i(22573),a=i(76850),o=i(50213),l=i(81168),u=i(84542),c=i(17217),d=i(68284),h=i(98778);function f(e){return t=(0,a.debom)(e),(0,s.blank)(t)?void 0:(0,n.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,r.readFileSync)(t)):void 0}catch(e){return void(0,o.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>f(await(0,r.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,r.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const n=i(22573),r=i(96249),s=i(98553),a=i(68708),o=i(51926);function l(e,t,i){if((0,n.blank)(e))throw new Error("kvToToml(): Blank key");const r=e+" = "+(0,s.stringifyPretty)(t);return(0,n.blank)(i?.prefix)?[r]:(0,o.wrap)(r.split("\n"),i)}t.stringifyToml=function(e){return(0,r.flatten)((0,a.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,n.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,o.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},55018:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.valueToS=void 0;const n=i(98553);t.valueToS=function(e){return(0,n.stringify)(e,void 0,2)}},10357:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},94678:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractBitrateKbps=void 0;const n=i(54993),r=i(97352);t.extractBitrateKbps=function(e){for(const t of["AvgBitrate","MaxDataRate"]){const i=a(e[t]);if(null!=i)return i}};const s=[{pat:"mb/s",fac:1024},{pat:"mbps",fac:1024},{pat:"kb/s",fac:1},{pat:"kbps",fac:1}];function a(e){const t=(0,r.extractFloat)(e);if(null==t)return;const i=(0,n.toS)(e).toLowerCase();for(const e of s)if(i.includes(e.pat))return t*e.fac}},65162:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const n=i(4001),r=i(81168);t.bname=function(e,t=!0){let i=(0,r.isString)(e)?e:e.name;return t&&(i=(0,n.stripCopySuffixFromName)(i)),i=(0,r.trimLeftPadding)((0,n.stripDSC)(i)),i.toLowerCase().normalize()}},28544:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.capturedAtFromStat=t.capturedAtFromPath=t.capturedAtFromBasename=t.capturedAtFromTags=t.extractCapturedAt=t.bestCapturedAt=t.CapturedAt=t.isCapturedAtJson=t.capturedAtSrcFromStat=t.capturedAtSrcFromTags=void 0;const n=i(77988),r=i(19851),s=i(40958),a=i(76790),o=i(22573),l=i(42659),u=i(50357),c=i(98553),d=i(55835),h=i(31586),f=i(68708),m=i(54993),p=i(48884),g=i(50213),y=i(7282),v=i(81168),w=i(76596),S=i(79842),b=i(66649),P=i(21330),M=i(98725),_=i(928),E=i(54261),x=i(89724),T=i(17415),D=i(88600),k=i(51275),C=i(29882),F=i(17217),O=i(68284),I=i(57902),L=i(28874),A=i(65162),R=i(71300),N=i(14036),B=i(61424),z=(0,r.lazy)((()=>(0,g.mkLogger)("tags.CapturedAt")));function j(e){return(0,m.toS)(e).toLowerCase().includes("tags")}function V(e){return(e=(0,m.toS)(e).toLowerCase()).includes("stat")&&!e.includes("+")}function W(e){return null!=e&&(0,f.isObject)(e)&&(0,o.notBlank)(e.nativePath)&&(0,S.isDated)(e.date)&&(0,o.notBlank)(e.src)}t.capturedAtSrcFromTags=j,t.capturedAtSrcFromStat=V,t.isCapturedAtJson=W;class H{static fromAssetFile(e){return(0,d.map)((0,x.localToDateTime)(e.capturedAtLocal,e.capturedAtOffset),(t=>H.for({nativePath:e.nativePath,date:t,src:e.capturedAtSrc,mtime:e.mtime,precisionMs:e.capturedAtPrecisionMs,offset:e.capturedAtOffset,local:e.capturedAtLocal})))}static for(e){return e instanceof H?e:W(e)?new H(e):void 0}constructor(e){var t;this.nativePath=(0,F.toNativePath_)(e.nativePath),this.date=e.date,this.src=(t=e.src,(0,y.isTest)()?t.replace(/SubSec/,"").replace(/ \(.+\)/,""):t),this.local=(0,h.toGt0)(e.local)??(0,x.datedToLocal)(this.date),this.offset=e.offset??(0,P.datedToOffsetMinutes)(this.date);let i=(0===e.precisionMs?void 0:e.precisionMs)??(0,S.datedToPrecisionMs)(this.date);V(this.src)&&(i=Math.max(L.Settings.minCapturedAtPrecisionStat.valueOrDefault,i)),this.precisionMs=i,this.mtime=(0,b.datedToMillis)(e.mtime)??(0,O.statSync)(this.nativePath)?.mtimeMs}toJSON(){return{_ctor:H.name,...(0,f.pick)(this,"nativePath","date","src","local","offset","precisionMs","mtime")}}static fromJSON(e){const t=(0,M.parseDated)({input:e.date,defaultZone:(0,d.map)(e.offset,T.fmtOffsetMinutes)});return null==t?void 0:new H({...e,date:t})}spread(e){return new H({...this.toJSON(),...e})}toISOString(){return(0,P.datedToISO)(this.date)}toExifString(){return(0,P.datedToEXIF)(this.date)}exifOffsetMinutes(){return null==this.offset?void 0:(0,T.fmtOffsetMinutes)(this.offset)}get isFromTags(){return j(this.src)}get isInferred(){return!j(this.src)&&!V(this.src)}get isFuzzy(){const e=this.local;return!this.isFromTags||(0,x.localIsFuzzy)(e)}get rawValue(){return this.date?.rawValue}get localSec(){return Math.floor(this.local/100)}toString(){return(0,c.stringify)({nativePath:this.nativePath,date:this.toISOString(),src:this.src})}toISOStringWithPrecision(){return(0,P.datedToISO)(this.date,!0,this.precisionMs)+(null==this.precisionMs?"":" (±"+(0,w.fmtMs)(this.precisionMs)+")")}hasTz(){return(0,k.hasZone)(this.date)||null!=this.offset}isUTC(){return 0===this.offset}hasTime(){return(0,E.hasTime)(this.date)}hasMillis(){return(0,h.gt0)((0,_.getMillisecond)(this.date))}toMillis(){return(0,b.datedToMillis)(this.date)}get isValid(){return(0,D.isValidDate)(this.date)}get zoneName(){return(0,n.offsetMinutesToZoneName)(this.offset)??(0,k.getZoneName)(this.date)}toAssetFileFields(){const e=this.local;return null==e||null==this.mtime?void 0:{nativePath:this.nativePath,mtime:this.mtime,capturedAtLocal:e,capturedAtOffset:this.offset,capturedAtPrecisionMs:this.precisionMs,capturedAtSrc:this.src}}asExifTag(){const e=this.toExifString();return null==e?void 0:{DateTimeOriginal:e,OffsetTime:(0,d.map)(this.offset,T.fmtOffsetMinutes)}}fuzzyPrecisionMs(){return(this.isFuzzy?L.Settings.fuzzyDatePrecisionCoeff.valueOrDefault:1)*(this.precisionMs??l.secondMs)}localBoundaries(e){const t=(e?.delta??0)+this.fuzzyPrecisionMs(),i=(0,S.datedToStartDateTime)(this.date)??(0,S.datedToDateTime)(this.date);if(null!=i)return{start:(0,x.datedToLocal)(i.minus(t)),end:(0,x.datedToLocal)(i.plus(t))};z().warn("localBoundaries() failed",{date:this.date,args:e,d:i,path:this.nativePath})}overlaps(e){if(null==e)return!1;if(this.local===e.local)return!0;const t=(0,N.extMimetype)(this.nativePath)===(0,N.extMimetype)(e.nativePath)?0:L.Settings.minCapturedAtPrecisionDifferentMimetypes.valueOrDefault,i=Math.max(t,this.fuzzyPrecisionMs()),n=Math.max(t,e.fuzzyPrecisionMs());return z().tap({level:"trace",msg:"overlaps()",result:this.local===e.local||(0,S.datedOverlap)({a:this.date,b:e.date,aPrecisionMs:i,bPrecisionMs:n}),meta:{a:this,b:e,aPrecisionMs:i,bPrecisionMs:n}})}}function U(e,t){if(null==e)return;const i=(0,s.compact)([e.capturedAt,e?.inferred?.capturedAt].map((e=>H.for(e))));for(const n of t){let t=e[n],r=n;if((0,D.isValidDate)(t)){if((0,T.isValidZone)(e.tz)&&(!(0,k.hasZone)(t)||R.OverrideUTCZoneTags.includes(r))){t=(0,P.setZone)(t,e.tz)??t;const i=(0,o.blank)(e.tzSource)?"":" from "+(0,v.stripPrefix)(e.tzSource,"from ");r+=` (TZ ${e.tz}${i})`}i.push({localSec:(0,x.datedToLocalSec)(t),date:t,src:r,precisionMs:(0,S.datedToPrecisionMs)(t),rawValue:e[n]?.rawValue})}}const n=(0,p.leastBy)(i,(e=>(0,S.datedToStartTs)(e.date)));if(null==n)return;const r=i.filter((e=>(0,u.eql)(e.date,n.date)||e.precisionMs<=n.precisionMs&&(0,S.datedOverlap)({a:e.date,b:n.date,aPrecisionMs:e.precisionMs,bPrecisionMs:n.precisionMs}))),a=(0,p.leastBy)(r,(e=>[Math.floor(e.localSec/1e6),(0,k.hasZone)(e.date)?0:1,e.precisionMs,-1*(e.rawValue?.length??0),e.src]));return z().debug("capturedAtFromTags()",{least:n,overlapsWithLeast:r,earliest:a}),a}function q(e,t){if(L.Settings.usePathsToInferDates.valueOrDefault)for(const i of(0,s.uniq)([(0,A.bname)(e,!0),(0,A.bname)(e,!1)])){const e=(0,M.parseDated)({input:i,defaultZone:t?.tz});if(null!=e)return{date:e,precisionMs:(0,p.max)([(0,S.datedToPrecisionMs)(e),l.secondMs])}}}function G(e){if(L.Settings.usePathsToInferDates.valueOrDefault)return{date:(0,M.extractDateFromPath)(e.pathsForDateParsing)}}async function $(e){if(L.Settings.useStatToInferDates.valueOrDefault)return{date:await e.minStatDate()}}t.CapturedAt=H,t.bestCapturedAt=function(e){const t=(0,a.sortBy)(e,(e=>-(e?.mtime??0)));return t.find((e=>e.src.includes("tags")))??t.find((e=>e.src.includes("bname+stat")))??t.find((e=>e.src.includes("path+stat")))??t.find((e=>e.src.includes("bname")))??t.find((e=>e.src.includes("path")))??t.find((e=>e.src.includes("siblings")))??t.find((e=>e.src.includes("stat")))??t[0]},t.extractCapturedAt=async function(e,t,i=!1){const n=await e.mtimeMs();function r(t,i){return W(i)?H.for(i):null!=i&&null!=i.date&&(0,D.isValidDate)(i.date)?H.for({nativePath:e.nativePath,date:i.date,local:(0,x.datedToLocal)(i.date),src:(0,v.uniqPath)([t,i.src]),mtime:n,precisionMs:i.precisionMs,offset:(0,P.datedToOffsetMinutes)(i.date)}):void 0}const s=function(e,t){return null==e||t||!L.Settings.usePathsToInferDates.valueOrDefault||!L.Settings.useLibraryDirsToInferDates.valueOrDefault&&(0,C.containedByNativePath)({ancestor:L.Settings.libraryDir.value,descendant:e.nativePath,acceptSelf:!0})}(e,i),a=r("tags",U(t,L.Settings.capturedAtTags.values))??(i?void 0:r("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??r("tags",U(t,L.Settings.capturedAtTagsFallback.values))??(s?void 0:r("bname+stat",await(0,B.extractStatBname)(e)))??(s?void 0:r("path+stat",await(0,B.extractStatPathTime)(e)))??(i?void 0:r("siblings",await(0,B.inferCapturedAtFromSiblings)(e)))??(s?void 0:r("bname",q(e,t)))??(s?void 0:r("path",G(e)))??(L.Settings.useStatToInferDates.valueOrDefault?r("stat",await $(e)):void 0);return z().tap({level:I.LogLevels.debug,msg:"extractCapturedAt()",result:a})},t.capturedAtFromTags=function(e){return U(e,L.Settings.capturedAtTags.values)},t.capturedAtFromBasename=q,t.capturedAtFromPath=G,t.capturedAtFromStat=$},70379:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const n=i(50989);t.DateTagFormats=(0,n.strEnum)("y","ym","ymd","")},71300:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},43207:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extactDuration=t.extractDurationMs=t.extractDurationSec=void 0;const n=i(31586),r=i(97352),s=i(95696),a=i(47783),o=i(16170);function l(e){if(null!=e&&(0,o.isVideoMimeType)(e?.MIMEType))for(const t of["duration","Duration","MediaDuration","TrackDuration"]){const i=(0,n.toGt0f)(e[t]);if(null!=i)return i}}t.extractDurationSec=l,t.extractDurationMs=function(e){return(0,r.mapGt0f)(l(e),(e=>Math.round(1e3*e)))},t.extactDuration=async function(e){if(null==e)return;const t=s.PosixFile.for(e);return l(await(0,a.readRawTags)(t,!1))}},47783:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseTags=t._readRawTags=t.readRawTags=t.writeTags_=t.writeTagDest=t.writeTagArgs=t.deleteAllTags_=t.overwriteTags_=t.moveOriginal=t.readRotation=t.readRawField=t.readCapturedAt=t.cachedTags=t._readTags=t.readTags=t.sidecarEql=t.IgnoredSidecarFields=t.IgnoredTypedFields=t.clearTagsCache=t.rawTagsCache=t.tagsCache=t.extractBinaryTag=t.shutdownExiftool=t.exiftoolVersionMaybe=t.exiftoolVersion_=t.exiftool=t.setExifToolProcs=t.addInstanceIdsToTags=void 0;const r=i(77988),s=n(i(76760)),a=n(i(1708)),o=i(19851),l=i(40958),u=i(22573),c=i(42659),d=i(55835),h=i(23838),f=i(68708),m=i(34666),p=i(51926),g=i(59455),y=i(54993),v=i(12168),w=i(56038),S=i(4867),b=i(36557),P=i(98247),M=i(21330),_=i(98725),E=i(23467),x=i(88561),T=i(95696),D=i(17217),k=i(16287),C=i(50213),F=i(17921),O=i(7282),I=i(88158),L=i(23560),A=i(28874),R=i(12089),N=i(45255),B=i(81168),z=i(63870),j=i(15674),V=i(28544),W=i(43207),H=i(75767),U=i(12788),q=i(80495),G=i(14036),$=i(67083),J=i(3432),K=i(28630),Z=i(15912),X=i(30748),Y=i(16170),Q=i(95141),ee=i(7330),te=i(54979),ie=i(1078),ne=i(61424),re=i(8791),se=(0,o.lazy)((()=>(0,C.mkLogger)("exiftool.ExifTool")));let ae=!1;t.addInstanceIdsToTags=function(e){ae=e},t.setExifToolProcs=function(e){return A.Settings.exiftoolProcsPerChild.envValue=e,ue()};const oe=(0,o.lazy)((()=>new b.BatchClusterObserver("ExifTool",new r.ExifTool({useMWG:A.Settings.useMWG.valueOrDefault,backfillTimezones:A.Settings.backfillTimezones.valueOrDefault,inferTimezoneFromDatestamps:!1,defaultVideosToUTC:A.Settings.defaultVideosToUTC.valueOrDefault,...(0,b.batchClusterOptions)((0,O.isTest)()?8:(0,L.isSyncService)()?A.Settings.exiftoolProcsPerChild.value??(0,j.maxConcurrentImports)():2,"exiftool.ExifTool")})).t));function le(){const e=oe();return e.ended?oe.refresh():e}function ue(e=!1){return(0,d.map)(oe.clear(),(t=>t.end(e)))}t.exiftool=le,t.exiftoolVersion_=async function(){return(0,S.thenOrTimeoutError)({p:le().version(),timeoutMs:N.ShortCommandTimeoutMs})},t.exiftoolVersionMaybe=function(){return(0,d.map)(oe.prior(),(e=>e.ended?void 0:(0,S.thenOrTimeoutError)({p:e.version(),timeoutMs:(0,z.commandTimeoutMs)()})))},t.shutdownExiftool=ue,t.extractBinaryTag=function(e,t,i){return le().extractBinaryTag(e,t,i)},t.tagsCache=(0,o.lazy)((()=>new x.FileCache({name:"exiftool.parsed",maxSize:256,timeoutMs:c.minuteMs}))),t.rawTagsCache=(0,o.lazy)((()=>new x.FileCache({name:"exiftool.raw",maxSize:256,timeoutMs:c.minuteMs}))),t.clearTagsCache=function(){t.tagsCache.prior()?.clear(),t.rawTagsCache.prior()?.clear(),te.mimetypeCache.prior()?.clear()};async function ce(e){return(0,f.omit)(await pe(e,!1),...t.IgnoredSidecarFields)}function de(e){return null==e?void 0:(0,t._readTags)((0,D.toNativePath_)(e))}async function he(e,t="_original"){return e.sibling(e.base+t).saveIfNewOrDelete(e.name+t+e.ext)}async function fe(e){const t=[];return A.Settings.overwriteOriginal.valueOrDefault&&t.push("-overwrite_original"),(0,m.gt)(await e.size(),2*v.GB)&&t.push("-api LargeFileSupport=1"),t}async function me(e,t,i){if((0,B.includesIgnoreCase)(A.Settings.sidecarTagBlocklist.values,(0,p.stripSuffix)(t,"#")))return se().tap({msg:"writeTagDest(): blocklisted tag, not writing to sidecar",result:e,meta:{src:e,tagName:t}});const n=i??await(0,te.readMimeType)(e),r=await e.sidecar(),s=(0,Y.isImageMimeType)(n)&&A.Settings.writeMetadataToSidecarsIfImage.valueOrDefault,a=(0,Y.isVideoMimeType)(n)&&A.Settings.writeMetadataToSidecarsIfVideo.valueOrDefault,o=A.Settings.writeMetadataToSidecarsIfSidecarExists.valueOrDefault&&await r.exists(),l=s||a||o;return se().tap({msg:"writeTagDest()",result:l?r:e,meta:{src:e,tagName:t,mimetype:n,writeMetadataToSidecarsIfImage:s,writeMetadataToSidecarsIfVideo:a,writeMetadataToSidecarsIfSidecarExists:o}})}async function pe(e,i=!0){const n=T.PosixFile.for(e);if(n.isSidecar()&&(i=!1),!await n.isNonEmptyFile(128))return(0,t.rawTagsCache)().delete(n.nativePath),void se().debug("readRawTags("+n+"): invalid file, returning null.");const r=await(0,t._readRawTags)(n.nativePath);if(null==r||!i)return r;se().trace("readRawTags()",{pf:n,pickedFileTags:(0,f.pick)(r,"tz","tzSource",...A.Settings.capturedAtTags.values)});const s=[];for(const e of await n.jsonSidecars())s.push([e,(0,K.readJsonSidecar)(e,r.tz)]);for(const e of await n.existingExifSidecars())s.push([e,(0,t._readRawTags)(e.nativePath)]);const a={original:{},MIMEType:(0,u.mapNotBlank)(r.MIMEType,Y.normalizeMimetype),...r},o=[];for(const[e,i]of s){if(null==i)continue;const n=await i;if(null==n)continue;const r=(0,f.omit)(n,...t.IgnoredSidecarFields);(0,l.isNotEmpty)((0,f.values)(r))?((a.sidecars??(a.sidecars=[])).push(e.base),o.push(...(0,g.toA)(n.History)),(0,I.assignNullishFields)(a.original,(0,f.pick)(a,...(0,f.keys)(r))),(0,f.assignFields)(a,r),se().debug("readRawTags() sidecar had values",{sidecar:e.base})):se().debug("readRawTags() sidecar was empty",{sidecar:e.base})}return a.inferred=(0,$.getInferredHistoricValues)(o,e),(0,I.assignNullishFields)(a,a.inferred),a.Rotation=(0,Q.orientationToRotation)(a.Rotation),se().debug("readRawTags() final",{pf:n,inferred:a.inferred,pickedResult:(0,f.pick)(a,"tz","tzSource",...A.Settings.capturedAtTags.values)}),a}async function ge(e,t){return null==t?void 0:(0,w.time)("exiftool.parseTags:"+e,(()=>async function(e,t){try{const i=e.nativePath,n=t.MIMEType=(0,u.mapNotBlank)(t.MIMEType,Y.normalizeMimetype);if((0,u.blank)(n))return void se().debug("No mimetype for "+i);const s={...t.inferred??{},...t};if(s.inferred??(s.inferred={}),s.original??(s.original={}),A.Settings.fuzzyDateParsing.valueOrDefault)for(const e of[...A.Settings.capturedAtTags.values,...A.Settings.capturedAtTagsFallback.values]){const t=s[e];if((0,p.isString)(t)){const i=(0,_.parseDated)({input:t,includeDate:!0,includeFuzzyDate:!0});null!=i&&(se().debug("parseTags() fuzzy date",{fuzzy:i,k:e,v:t}),s[e]=i)}}const o=!await(0,ne.canInferForDir)(e.parent()),l=await(0,J.maybeInferTimezone)(e,s,o);if(se().debug("parseTags()",{tzMeta:l,skipSiblingInference:o}),null!=l?.tz){const e=s.tzSource!==r.defaultVideosToUTC&&void 0;for(const t of[...A.Settings.capturedAtTags.values,...A.Settings.capturedAtTagsFallback.values]){const i=s[t];i instanceof r.ExifDateTime&&(s[t]=(0,M.setZone)(i,l.tz,{keepLocalTime:e})??i)}(0,f.assignUndefinedFields)(s.original,s,"tz","tzSource"),(0,f.assignFields)(s,l),(0,f.assignFields)(s.inferred,l)}const c=o?(0,X.extractMakeAndModel)(s):await(0,ne.inferMakeAndModel)(e,s);c.Make!==(0,X.make)(s.Make)&&(s.original.Make=s.Make,s.inferred.Make=c.Make),c.Model!==(0,X.model)(c.Make,s.Model)&&(s.original.Model=s.Model,s.inferred.Model=c.Model),!(0,u.blank)(A.Settings.defaultCopyright.valueOrDefault)&&(0,U.isExifUnset)(s.Copyright)&&(s.Copyright=A.Settings.defaultCopyright.valueOrDefault);const d=(0,Z.extractLensMakeModel)(s),h=await(0,V.extractCapturedAt)(e,s,o);if(null==h)return void se().info("No capturedAt for "+e);!o&&h.isInferred&&(s.inferred.capturedAt=h);const m=(0,q.extractExposureSettings)(s),g=await(0,ie.extractSizeInfoFromFile)(e,s);if(null==g)return void se().info("No size info for "+i);const y={...c,mimetype:n,capturedAt:h,exposureSettings:m,...(0,re.extractTitleDescription)(s),...d,cameraId:(0,H.cameraIdFromTags)(s),imageId:(0,H.imageIdFromTags)(s),lensId:(0,H.lensIdFromLensInfo)({...d,...(0,f.pick)(s,"LensSerialNumber")}),...g,duration:(0,W.extractDurationSec)(s),tz:s.tz,rating:(0,ee.extractRating)(s)};(0,O.isTest)()&&(y.__parsedBy__=a.default.pid);const v={...s,...y};return se().debug("parsedTags",{nativePath:i,skipInference:o,...y,inferred:s.inferred,original:s.original,pickedResult:(0,f.pick)(v,"capturedAt","tz","tzSource","Make","Model")}),(0,f.definedValues)(v)}catch(e){return void se().warn("parseTags() failed",{error:e})}}(e,t)))}t.IgnoredTypedFields={Duration:void 0,MediaDuration:void 0,TrackDuration:void 0,FileFormat:void 0,FileIndex:void 0,FileName:void 0,FileNumber:void 0,FileNumberMemory:void 0,FileNumberSequence:void 0,FileSize:void 0,FileType:void 0,FileTypeExtension:void 0,FileVersion:void 0,MIMEType:void 0,SourceFile:void 0},t.IgnoredSidecarFields=["errors",...(0,f.keys)({ExifToolVersion:void 0,RAFVersion:void 0,Directory:void 0,ExifByteOrder:void 0,FileAccessDate:void 0,FileCreateDate:void 0,FileIndex2:void 0,FileInfoVersion:void 0,FileInodeChangeDate:void 0,FileModifyDate:void 0,FilePermissions:void 0}),...(0,f.keys)(t.IgnoredTypedFields)],t.sidecarEql=async function(e,t){return await(0,E.eqlAsync)(e.sha(),t.sha())||await(0,E.eqlAsync)(ce(e),ce(t))},t.readTags=de,t._readTags=(0,R.shim1)({name:"exiftool.readTags",impl:async e=>{const t=T.PosixFile.for(e);return ge(t,await pe(t))},cache:t.tagsCache}),t.cachedTags=async function(e){return(0,t.tagsCache)().get((0,D.toNativePath_)(e))},t.readCapturedAt=async function(e){return(await de(e))?.capturedAt},t.readRawField=async function(e,t){try{const i=await le().readRaw((0,D.toNativePath_)(e),["-"+t]);return(0,I.pluckCaseInsensitive)(i,t)}catch(e){return void se().info("readRawField failed",e)}},t.readRotation=async function(e){return(0,Q.extractRotation)(await pe(e,!0))},t.moveOriginal=he,t.overwriteTags_=async function(e,t){try{await(0,w.time)("exiftool.overwriteTags:"+e,(async()=>{await le().write(e.nativePath,t,await fe(e)),e.clearThisAndParent()}))}catch(i){se().throw("failed to overwrite tags to "+e,{error:i,tags:t})}},t.deleteAllTags_=async function(e,t){await(0,w.time)("exiftool.deleteAllTags:"+e,(async()=>{const i=["-all="];e.eql(t)?i.push("-overwrite_original"):i.push("-o",t.nativePath),await le().write(e.nativePath,{},i),t.clear()}))},t.writeTagArgs=fe,t.writeTagDest=me,t.writeTags_=function(e,t,i){return(0,w.time)("exiftool.writeTags:"+e,(async()=>{const n=new h.MultiMap;for(const[r,s]of(0,f.entries)(t)){const t=await me(e,r,i);n.add(t.nativePath,[r,s])}for(const[t,i]of n.entriesArray()){const n=T.PosixFile.for(t),r=(0,f.fromEntries)(i);se().info("writeTags()",{src:e,dest:t,t:r}),await le().write(n.nativePath,r,await fe(n)),A.Settings.overwriteOriginal.valueOrDefault||await he(n),n.clearThisAndParent()}}))},t.readRawTags=pe,t._readRawTags=(0,R.shim1)({name:"exiftool.readRawTags",cache:t.rawTagsCache,impl:async e=>{if(!await(0,k.nativePathIsFile)(e))return se().debug("_readRawTags(): !nativePathIsFile(), returning null.",{nativePath:e}),void(0,t.rawTagsCache)().delete(e);se().debug("_readRawTags() not cached, reading now.",{nativePath:e});const i=[...A.Settings.tagGeo.valueOrDefault?["-api","geolocation"]:[],...(0,G.isVideoExt)(s.default.extname(e))?[]:["-fast"]],n=await(0,w.time)("exiftool.read()",(()=>le().read(e,i).catch((t=>{se().warn("ExifTool failed to read",{nativePath:e,error:t})}))));if(null==n)return;se().debug("_readRawTags()",{nativePath:e,pickedTags:(0,f.pick)(n,"tz","tzSource",...A.Settings.capturedAtTags.values)}),n.MIMEType=(0,u.mapNotBlank)(n.MIMEType,Y.normalizeMimetype),n.GPSDateTime??(n.GPSDateTime=(0,P.concatDateTime)(n.GPSDateStamp,n.GPSTimeStamp));for(const e of(0,f.keys)(n)){const t=n[e];"string"==typeof t&&("0000:00:00"!==t&&"0000:00:00 00:00:00"!==t||delete n[e])}const r=(0,l.compactBlanks)([n.Error,...n.errors??[],n.Warning].map(y.toS));return(0,l.isNotEmpty)(r)&&(n.problems=r),ae&&(n.__instance=(0,F.safeUUID)()),n}}),t.parseTags=ge},75767:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uidGeoHash=t.imageIdFromTags=t.lensIdFromLensInfo=t.lensIdFromTags=t.cameraIdFromTags=t.whyExposureSettingsNotSimilar=t.findInequalFields=t.decodeExifUid=t.renderExifUidId=t.stringifyExifUid=t.zeroesRe=t.Tag2Synonyms=t.Tag2SynonymGroup=t.CameraSerialNumberSynonyms=t.ImageNumberSynonyms=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(98553),o=i(23838),l=i(31586),u=i(68708),c=i(67478),d=i(42279),h=i(54993),f=i(48884),m=i(73168),p=i(97352),g=i(81168),y=i(28874),v=i(15912);t.ImageNumberSynonyms=["ImageNumber","ShutterCount","ShutterCount2","ShutterCount3"],t.CameraSerialNumberSynonyms=["CameraSerialNumber","SerialNumber","BodySerialNumber","InternalSerialNumber"];const w=[t.ImageNumberSynonyms,t.CameraSerialNumberSynonyms];function S(e){const t=null==e?[]:e.filter((([,e])=>!(0,s.blank)(e)));return 0===t.length?void 0:(0,a.stringify)((0,u.fromEntries)(t))}function b(e){return(0,h.toS)(e).trim().replace(/\s+/g," ")}function P(e){const i=new o.MultiMap,n=[];for(const a of(0,g.sortIgnoreCase)((0,u.keys)(e))){if(null==(r=e[a])||(0,s.blankish)(r)||(0,l.isNumber)(r)&&(0===r||1===r)||null!=t.zeroesRe.exec((0,h.toS)(r)))continue;const o=e[a],u=b(e[a]),c=(0,t.Tag2SynonymGroup)().get(a);if(null!=c){if(i.includes(c,o)||i.includes(c,u))continue;i.add(c,o)}n.push([a,(0,l.gt0)(o)?o:u])}var r;return S(n)}function M(e){const t=(0,g.splitFirst)(e,":");return 2===t.length?t:void 0}function _(e){if((0,s.blank)(e))return;const t=(0,c.parseJSON)(e);return null==t?(0,u.fromEntries)([M(e)]):Array.isArray(t)?(0,u.fromEntries)(t.map(M)):(0,u.compactBlankValues)(t)}function E({a:e,b:t,field:i,desc:n,parser:r}){const s=r(e[i]),a=r(t[i]),o=y.Settings.minExposureSettingsCoeffPct.valueOrDefault/100;return null==s||null==a||(0,l.approximates)(s,a,o)?void 0:"Different "+n+": "+e[i]+" ≠ "+t[i]}function x(e){const t=(0,u.pick)(e,"LensSerialNumber");return null==e||(0,s.blank)(e.lensMake)||(0,s.blank)(e?.lensInfo)||(t.mli=`${e.lensMake.toLowerCase()}/${e.lensInfo}`),P(t)}t.Tag2SynonymGroup=(0,n.lazy)((()=>{const e=new Map;for(const t of w){const i=t[0];for(const n of t)e.set(n,i)}return e})),t.Tag2Synonyms=(0,n.lazy)((()=>{const e=new Map;for(const t of w)for(const i of t)e.set(i,t);return e})),t.zeroesRe=/^[\s0]*1?$/,t.stringifyExifUid=S,t.renderExifUidId=P,t.decodeExifUid=_,t.findInequalFields=function(e,i){const n=_(e),s=_(i);if(null==n||null==s||e===i)return;const a=(0,f.intersection)((0,u.keys)(n),(0,u.keys)(s)).filter((e=>!(0,t.Tag2SynonymGroup)().has(e)));for(const e of a){const t=n[e],i=s[e];if(b(t)!==b(i))return{aKey:e,aValue:t,bKey:e,bValue:i}}for(const e of w){const t=(0,u.pick)(n,...e);if((0,u.isEmptyObj)(t))continue;const i=(0,u.pick)(s,...e);if((0,u.isEmptyObj)(i))continue;const a=(0,u.values)(t).map(h.toS),o=(0,u.values)(i).map(h.toS);if((0,r.includesAny)(a,o))continue;const l=(0,f.least)((0,u.keys)(t)),c=(0,f.least)((0,u.keys)(i));return{aKey:l,aValue:n[l],bKey:c,bValue:s[c]}}},t.whyExposureSettingsNotSimilar=function(e,t){if(null!=e&&null!=t)return(0,d.firstDefinedThunk)([()=>E({a:e,b:t,field:"focalLength",desc:"focal length",parser:p.extractFloat}),()=>E({a:e,b:t,field:"aperture",desc:"aperture",parser:p.extractFloat}),()=>E({a:e,b:t,field:"shutterSpeed",desc:"shutter speed",parser:p.extractFraction}),()=>E({a:e,b:t,field:"iso",desc:"ISO",parser:p.extractFloat})])},t.cameraIdFromTags=function(e){return P((0,u.pick)(e,...t.CameraSerialNumberSynonyms))},t.lensIdFromTags=function(e){return x({...(0,v.extractLensMakeModel)(e),...e})},t.lensIdFromLensInfo=x,t.imageIdFromTags=function(e){return P((0,u.pick)(e,...t.ImageNumberSynonyms,"BurstUUID","RunTimeValue"))},t.uidGeoHash=function(e,t){return(0,m.geohash)((0,l.toFixed)(e,4),(0,l.toFixed)(t,4))}},12788:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toExifDefined=t.isExifUnset=void 0;const n=i(22573),r=i(54993),s=/undefined|null|none|n\/a|unknown/i;function a(e){return null==e||(0,n.blank)(e)||s.test((0,r.toS)(e))}t.isExifUnset=a,t.toExifDefined=function(e){return a(e)?void 0:e}},80495:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.focalLengthToInt=t.exposureTimeToFloat=t.extractExposureSettings=void 0;const n=i(19851),r=i(22573),s=i(31586),a=i(68708),o=i(54993),l=i(50213),u=i(97352),c=(0,n.lazy)((()=>(0,l.mkLogger)("tags.ExposureSettings")));t.extractExposureSettings=function(e){const t={focalLength:e.FocalLength,iso:(0,u.firstNonZero)(e.ISO,e.ISOSpeed,e.SonyISO),aperture:(0,u.firstNonZero)(e.FNumber,e.Fnumber,e.ApertureValue,e.Aperture,e.SonyFNumber),shutterSpeed:(0,r.firstNotBlank)((0,o.toS)(e.ExposureTime),(0,o.toS)(e.ShutterSpeed),(0,o.toS)(e.ShutterSpeedValue),(0,o.toS)(e.SonyExposureTime))};return c().debug("extracted from "+e.FileName,{exposureSettings:t}),(0,a.reqValuedOrElse)(t)},t.exposureTimeToFloat=function(e){if((0,s.gt0)(e))return e;const[t,i]=(0,o.toS)(e).split("/").map((e=>(0,s.toInt)(e)));return(0,s.gt0)(t)&&(0,s.gt0)(i)?t/i:void 0},t.focalLengthToInt=function(e){const t=(0,s.toFloat)(e);return(0,s.gt0)(t)?Math.round(t):void 0}},88840:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtTypes=void 0;const n=i(50989);t.ExtTypes=(0,n.strEnum)("Sharp","HEIF","RawImage","Video","Sidecar","AssetFile","Exif","SupportedByCurrentBrowser","SupportedByOldBrowser")},14036:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripExt=t.isSupportedByOldBrowserExt=t.isSupportedByCurrentBrowserExt=t.isExifExt=t.isAssetFileExt=t.isVideoExt=t.isSharpExt=t.isRawImageExt=t.mimeRootType=t.isExtType=t.extTypes=t.equivalentExts=t.CurrentBrowserMimetypes=t.OldBrowserMimetypes=t.getExtAliases=t.mimetypeExt=t.extMimetype=t.AssetFileExts=t.AllFileExts=t.ExifFiletypes=t.AssetFiletypes=t.AllFiletypes=t.VideoFiletypes=t.RawImageFiletypes=t.HeifFiletypes=t.SharpImageFiletypes=t.BrowserFiletypes=void 0;const n=i(19851),r=i(40958),s=i(96249),a=i(23838),o=i(68708),l=i(51926),u=i(54993),c=i(32144),d=i(49047),h=i(88840);t.BrowserFiletypes={"application/javascript":["js"],"application/toml":["toml"],"application/manifest+json":["webmanifest"],"application/xml":["xml"],"image/vnd.microsoft.icon":["ico"],"font/ttf":["ttf"],"font/woff2":["woff2"],"text/css":["css"],"text/html":["html","htm"],"text/plain":["txt"],"text/x-scss":["scss"]},t.SharpImageFiletypes={"image/jpeg":d.JpegExts,"image/gif":["gif"],"image/png":["png"],"image/svg+xml":["svg"],"image/tiff":["tif","tiff"],"image/webp":["webp"]},t.HeifFiletypes={"image/avif":["avif"],"image/heic":["heic"],"image/heif":["heif"]},t.RawImageFiletypes={"image/x-adobe-dng":["dng"],"image/x-canon-cr2":["cr2"],"image/x-canon-cr3":["cr3"],"image/x-canon-crw":["crw"],"image/x-epson-erf":["erf"],"image/x-fuji-raf":["raf"],"image/x-fujifilm-raf":["raf"],"image/x-kodak-dcr":["dcr"],"image/x-kodak-k25":["k25"],"image/x-kodak-kdc":["kdc"],"image/x-hasselblad-3fr":["3fr"],"image/x-mamiya-mef":["mef"],"image/x-minolta-mrw":["mrw"],"image/x-nikon-nef":["nef"],"image/x-nikon-nrw":["nrw"],"image/x-olympus-orf":["orf"],"image/x-panasonic-raw":["rwl"],"image/x-panasonic-rw2":["rw2"],"image/x-pentax-pef":["pef","dng"],"image/x-raw":["raw"],"image/x-samsung-srw":["srw"],"image/x-sony-arw":["arw"],"image/x-sony-sr2":["sr2"],"image/x-sony-srf":["srf"]},t.VideoFiletypes={"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/mp2t":["mts","ts"],"video/mp4":["mp4","insv"],"video/mpeg":["m2v","mpeg","mpg"],"video/quicktime":["mov","qt"],"video/webm":["webm"],"video/x-m4v":["m4v"],"video/x-mng":["mng"],"video/x-ms-asf":["asf"],"video/x-msvideo":["avi"],"video/x-ms-wmv":["wmv"]},t.AllFiletypes={...t.BrowserFiletypes,...c.SidecarFiletypes,...t.SharpImageFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.AssetFiletypes={...t.SharpImageFiletypes,...t.HeifFiletypes,...t.RawImageFiletypes,...t.VideoFiletypes},t.ExifFiletypes={...t.AssetFiletypes,...c.SidecarFiletypes};const f=(0,n.lazy)((()=>{const e={};for(const[i,n]of(0,o.entries)(t.AllFiletypes))for(const t of n)e[t]=i;return e})),m=(0,n.lazy)((()=>{const e={};for(const i of(0,o.values)(t.AllFiletypes))for(const t of i)e[t]=i;return e}));function p(e){return m()[(0,c.normalizeExt)(e)??""]}t.AllFileExts=(0,n.lazy)((()=>(0,r.uniq)((0,s.flatten)((0,o.values)(t.AllFiletypes))))),t.AssetFileExts=(0,n.lazy)((()=>(0,r.uniq)((0,s.flatten)((0,o.values)(t.AssetFiletypes))))),t.extMimetype=function(e){return f()[(0,c.normalizeExt)(e)??""]},t.mimetypeExt=function(e){return t.AllFiletypes[(0,u.toS)(e).trim().toLowerCase()]?.[0]},t.getExtAliases=p,t.OldBrowserMimetypes=["image/gif","image/jpeg","image/png"],t.CurrentBrowserMimetypes=[...t.OldBrowserMimetypes,"image/svg+xml","image/webp","video/mp4","video/webm"];const g=(0,n.lazy)((()=>{const e=new a.MultiMap;for(const{exts:i,type:n}of[{exts:t.SharpImageFiletypes,type:h.ExtTypes.Sharp},{exts:t.HeifFiletypes,type:h.ExtTypes.HEIF},{exts:t.RawImageFiletypes,type:h.ExtTypes.RawImage},{exts:t.VideoFiletypes,type:h.ExtTypes.Video},{exts:c.SidecarFiletypes,type:h.ExtTypes.Sidecar},{exts:t.AssetFiletypes,type:h.ExtTypes.AssetFile},{exts:t.ExifFiletypes,type:h.ExtTypes.Exif}])for(const t of(0,s.flatten)((0,o.values)(i)))e.add(t,n);for(const i of t.OldBrowserMimetypes)for(const n of t.AllFiletypes[i]??[])e.add(n,h.ExtTypes.SupportedByOldBrowser);for(const i of t.CurrentBrowserMimetypes)for(const n of t.AllFiletypes[i]??[])e.add(n,h.ExtTypes.SupportedByCurrentBrowser);return e}));function y(e){const t=(0,c.normalizeExt)(e);return null==t?void 0:g().get(t)}function v(e,t){return y(e)?.includes(t)??!1}t.equivalentExts=function(e,t){const i=(0,c.normalizeExt)(e),n=(0,c.normalizeExt)(t);return null!=i&&null!=n&&(i===n||(p(i)?.includes(n)??!1))},t.extTypes=y,t.isExtType=v,t.mimeRootType=function(e){const t=y(e);return null==t?void 0:t.includes(h.ExtTypes.Sharp)||t.includes(h.ExtTypes.RawImage)?"image":t.includes(h.ExtTypes.Video)?"video":void 0},t.isRawImageExt=function(e){return v(e,h.ExtTypes.RawImage)},t.isSharpExt=function(e){return v(e,h.ExtTypes.Sharp)},t.isVideoExt=function(e){return v(e,h.ExtTypes.Video)},t.isAssetFileExt=function(e){return v(e,h.ExtTypes.AssetFile)},t.isExifExt=function(e){return v(e,h.ExtTypes.Exif)},t.isSupportedByCurrentBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByCurrentBrowser)},t.isSupportedByOldBrowserExt=function(e){return v(e,h.ExtTypes.SupportedByOldBrowser)},t.stripExt=function(e,t=h.ExtTypes.AssetFile){const i=(0,l.splitLast)(e,".");return v(i,t)?e.slice(0,-(i.length+1)):e}},67083:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ensureHistoryRecords=t.ensureInferredHistoryRecords=t.inferredToTags=t.valueFromResourceEvent=t.getInferredHistoricValues=t.tagsContainHistory=t.InferAction=t.mkHistoryRecord=t.mkHistoryRecords=t.Actions=void 0;const n=i(77988),r=i(19851),s=i(40958),a=i(76790),o=i(22573),l=i(50357),u=i(98553),c=i(31586),d=i(68708),h=i(50989),f=i(51926),m=i(59455),p=i(54993),g=i(72993),y=i(80875),v=i(50213),w=i(81168),S=i(66649),b=i(17415),P=i(29882),M=i(95696),_=i(17217),E=i(28874),x=i(47783);function T(e,t){return(0,d.entries)(t??{}).map((([t,i])=>D({action:e,key:t,value:i})))}function D({action:e,key:t,value:i,ts:r}){return{Action:e,Changed:(0,p.toS)(t).replace(/[#+]$/,""),Parameters:(0,u.stringify)((0,d.maybeCall)(i,"toJSON")??i),When:n.ExifDateTime.fromMillis(r??Date.now()),SoftwareAgent:(0,g.AppNameVersion)()}}t.Actions=(0,h.strEnum)("infer","set","add","delete"),t.mkHistoryRecords=T,t.mkHistoryRecord=D,t.InferAction="infer";const k=(0,r.lazy)((()=>(0,v.mkLogger)("tags.History")));function C(e,t){if(null==e||null==e.History||(0,f.isString)(e.History))return!1;const i=e.History;return Array.isArray(i)?i.some(t):t(i)}function F(e){if(null==e?.Parameters)return;if((0,c.isNumber)(e?.Parameters))return e.Parameters;const t=(0,p.toS)(e);return(0,o.blank)(t)?void 0:(0,y.parseJSON)(e.Parameters)??(0,u.revive)(e.Parameters)}function O(e){if(null==e)return;const t={};for(const[i,n]of(0,d.entries)(e))(0,w.isFirstCharAZ)(i)&&(t[i]=n);"duration"in e&&(t.Duration=e.duration),"title"in e&&(t.Title=e.title),"description"in e&&(t.Description=e.description),"rating"in e&&(t.Rating=e.rating),(0,d.assignFields)(t,e.capturedAt?.asExifTag());const i=(0,b.luxonTzOffsetToOffsetMinutes)(e.tz??e.capturedAt?.zoneName,e.capturedAt?.toMillis());return null!=i&&(t.OffsetTime=i),t}async function I(e,i,n){if(null==e||(0,o.blank)(e))return void k().warn("ensureHistoryRecords(): no-op: empty path",{sidecar:e});const r=(0,_.toNativePath_)(e),a=await(0,x._readRawTags)(r),u=(0,m.toA)(i).filter((e=>{if(e.Action!==t.Actions.infer)return!0;const i=(0,d.pick)(e,"Changed","Parameters");return!C(a,(e=>(0,l.eql)(i,(0,d.pick)(e,"Changed","Parameters"))))})),c={...n??{}};if((0,s.isNotEmpty)(u)&&(c["History+"]=u),(0,d.isEmptyObj)(c))return void k().debug("ensureHistoryRecords(): no-op: nothing to write",{sidecar:e,historyRecords:i,newHistoryRecords:u,additionalTags:n,tagsToWrite:c});k().debug("ensureHistoryRecords(): write",{sidecar:e,tagsToWrite:c,historyRecords:i,additionalTags:n});const h=M.PosixFile.for(e);return await(0,x.overwriteTags_)(h,c),h.clearThisAndParent(),u}t.tagsContainHistory=C,t.getInferredHistoricValues=function(e,i){if(null==e)return{};const r=(0,m.toA)(e);if((0,s.isEmpty)(r))return{};const l=(0,a.sortBy)(r.filter((e=>(0,w.startsWithIgnoreCase)(e.SoftwareAgent,"PhotoStructure")&&e.Action===t.Actions.infer)),(e=>(0,S.datedToMillis)((0,o.mapNotBlank)(e.When,(e=>n.ExifDateTime.from(e))))??0)),u={};for(const e of l){const t=e.Changed;if((0,o.notBlank)(t)){const n=F(e);(0,o.blank)(n.nativePath)||(0,P.eqlNameWithoutExt)(n.nativePath,i)?u[t]=n:k().debug("getInferredHistoricValues(): skipping mismatching filename (without file extension)",{ea:e,src:i})}}return u},t.valueFromResourceEvent=F,t.inferredToTags=O,t.ensureInferredHistoryRecords=async function(e,i,n){const r=T(t.Actions.infer,n),s=(E.Settings.writeInferredTagsToLibraryCopies.valueOrDefault?O(n):void 0)??{};return E.Settings.writeSourceTagToLibraryCopies.valueOrDefault&&(s.Source=e.nativePath),k().debug("ensureInferredHistoryRecords()",{sidecar:i,historyRecords:r,additionalTags:s}),I(i,r,s)},t.ensureHistoryRecords=I},3432:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.inferTzOffsetMinutesFromFilename=t.zoneFromLatLon=t.maybeInferTimezone=void 0;const r=n(i(53705)),s=i(77988),a=i(19851),o=i(40958),l=i(50357),u=i(79842),c=i(21330),d=i(98725),h=i(17415),f=i(88600),m=i(73168),p=i(50213),g=i(28874),y=i(65162),v=i(61424),w=(0,a.lazy)((()=>(0,p.mkLogger)("tags.InferTimezone")));async function S(e,t,i){{const e=b(t);if(null!=e&&(0,h.isValidZone)(e)){const i={tz:e.name,tzSource:"GPSLatitude/GPSLongitude"};return(0,l.eqlSubset)(i,t)?void 0:i}}if(!(0,h.isValidZone)(t.tz)||t.tzSource===s.defaultVideosToUTC){if(g.Settings.inferTimezoneFromDatestamps.valueOrDefault)for(const e of(0,o.compactBlanks)([...g.Settings.capturedAtTags.values,...g.Settings.capturedAtTagsFallback.values])){const i=t[e];if(i instanceof s.ExifDateTime&&(0,h.isValidZone)(i.zone)&&"UTC"!==i.zone)return{tz:i.zone,tzSource:"infer:tag."+e+".zone"}}if(!i){const i=P(e,t);if(null!=i)return i}if(!i){const t=await(0,v.nearestSiblingTzOffset)(e);if(null!=t)return{tz:t.zoneName,tzSource:"infer:nearestSibling:"+t.base}}}}function b(e={}){const t=e.GPSLatitude,i=e.GPSLongitude;if(!(0,m.validLat)(t)||!(0,m.validLon)(i))return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i}});try{const e=(0,r.default)(t,i),n=(0,h.normalizeZone)(e);return w().tap({msg:"zoneFromLatLon()",result:n,meta:{lat:t,lon:i,zoneName:e}})}catch(e){return w().tap({msg:"zoneFromLatLon(): invalid lat/lon",result:void 0,meta:{lat:t,lon:i,error:e}})}}function P(e,t){const i=(0,d.parseDateTime)([(0,y.bname)(e.name,!0),(0,y.bname)(e.name,!1)]);if(null!=i&&(0,f.isValidDate)(i))for(const n of g.Settings.capturedAtTags.values){const r=(0,u.toDated)(t[n]);if(null==r||(0,f.isValidDate)(r))continue;const s=Math.round(15*i.diff(r,"minutes").as("minutes")/15),a=(0,h.normalizeZoneOffsetMinutes)(s),o=0===a?void 0:(0,h.normalizeZone)(a);if(null!=o)return w().tap({msg:"inferTzOffsetMinutesFromFilename("+e.name+")",result:{tz:o.name,tzSource:"infer:filename (diff with "+n+")"},meta:{dt:(0,c.datedToISO)(r),rawTzoffsetMinutes:s,normalizedOffsetMinutes:a}})}}t.maybeInferTimezone=async function(e,t,i){return w().tap({msg:"maybeInferTimezone()",result:await S(e,t,i)})},t.zoneFromLatLon=b,t.inferTzOffsetMinutesFromFilename=P},28630:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJsonSidecar=void 0;const n=i(77988),r=i(40958),s=i(22573),a=i(38639),o=i(55835),l=i(31586),u=i(68708),c=i(20214),d=i(59455),h=i(48884),f=i(73168),m=i(98725),p=i(17415);function g(e,t){if(null==e)return;const i=(0,l.toInt)(e?.timestamp);if((0,l.isNumber)(i)){const r=(0,p.normalizeZone)(e?.formatted),s=n.ExifDateTime.fromMillis(1e3*i,{rawValue:e.formatted,zone:r??t??n.UnsetZone});if(!0===s?.isValid)return s}return(0,m.parseDated)({input:e.formatted,defaultZone:t})}t.readJsonSidecar=async function(e,t){return(0,c.thenMap)(e.readJson("info"),(e=>(0,u.compactValues)({Title:(0,s.toNotBlank)(e.title),Description:(0,s.toNotBlank)(e.description),GPSLatitude:(0,h.first)([e.geoData?.latitude,e.geoDataExif?.latitude],(e=>(0,f.validLat)(e)?e:void 0)),GPSLongitude:(0,h.first)([e.geoData?.longitude,e.geoDataExif?.longitude],(e=>(0,f.validLon)(e)?e:void 0)),GPSAltitude:(0,h.first)([e.geoData?.altitude,e.geoDataExif?.altitude],(e=>(0,l.isNumber)(e)?e:void 0)),favorited:(0,o.map)(e.favorited,a.isTrue),peopleNames:(0,r.mapNotEmpty)([...(0,d.toA)(e.people),...(0,d.toA)(e.person)],(e=>(0,r.compactBlanks)(e.map((e=>e.name))))),creationTime:g(e.creationTime,t),modificationTime:g(e.modificationTime,t),photoTakenTime:g(e.photoTakenTime,t),imageViews:(0,l.mapInt)(e.imageViews,(e=>e)),googlePhotosOrigin:!0})))}},68268:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const n=i(50989);t.KeywordReparentingStrategies=(0,n.strEnum)("move","copy","retain")},97573:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rawTagKeywords=t.parseKeywordStruct=t.isKeywordStruct=t.parseCategories=t.splitKeywords=t.splitKeyword=t.delimRe=t.keywordToPath=void 0;const n=i(77988),r=i(66150),s=i(19851),a=i(40958),o=i(22573),l=i(41400),u=i(96249),c=i(68708),d=i(59455),h=i(48884),f=i(50213),m=i(68852),p=i(81168),g=i(28874),y=(0,s.lazy)((()=>(0,f.mkLogger)("tags.KeywordTags"))),v=(0,s.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordPathSeparators.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g")))));function w(e){const i=(0,t.delimRe)();return null==i?[e]:(0,a.compactBlanks)(e.split(i))}function S(e){return null==e||e instanceof n.BinaryField?[]:(0,a.compactBlanks)(Array.isArray(e)?(0,u.flatten)(e.map(S)):w(e))}function b(e){return null==e?[]:(0,p.isString)(e)?(0,o.blank)(e)?[]:[[e]]:(0,u.flatten)((0,d.toA)(e.Category).map(b).map((t=>t.map((t=>(0,a.compact)([e._,...t]))))))}(0,l.later)((()=>{g.Settings.keywordPathSeparators.watchLater((()=>v.unset()))})),t.keywordToPath=function(e){const t=v();return(0,a.compactBlanks)(null==t?[e]:e.split(t))},t.delimRe=(0,s.lazy)((()=>(0,o.mapNotBlank)(g.Settings.keywordDelimiters.valueOrDefault,(e=>new RegExp(`[${(0,m.escapeRegExp)(e)}]+`,"g"))))),g.Settings.keywordDelimiters.watchLater((()=>t.delimRe.unset())),t.splitKeyword=w,t.splitKeywords=S;const P=/^\(?none\)?$/i;function M(e){if(!(0,o.blank)(e)&&null==P.exec(e))try{const t=new r.XMLParser({textNodeName:"_"}).parse(e);return(0,u.flatten)((0,d.toA)(t?.Categories?.Category).map(b))}catch(t){return void y().warn("parseCategories() failed:",{err:t,s:e})}}function _(e){return Array.isArray(e)&&e.every(_)||null!=e&&(0,p.isString)(e.Keyword)&&(null==e.Children||Array.isArray(e.Children)&&e.Children.every(_))}function E(e){if(null==e)return[];if(Array.isArray(e)&&e.every(_))return(0,h.flatMap)(e,E);if((0,o.blank)(e.Keyword))return[];const t=(0,d.toA)(e.Children);return(0,a.isEmpty)(t)?[[e.Keyword]]:(0,h.flatMap)(t,E).map((t=>[e.Keyword,...t]))}t.parseCategories=M,t.isKeywordStruct=_,t.parseKeywordStruct=E,t.rawTagKeywords=function(e){const t=[];if(null!=e){const i=[...g.Settings.keywordTags.values];if(i.includes("Categories")){(0,h.remove)(i,"Categories");const n=M(e.Categories);null!=n&&t.push(...n)}for(const n of i){const i=(0,c.pluckDeep)(e,n)?.value;(0,o.blank)(i)||(_(i)?t.push(...E(i)):t.push(...Array.isArray(i)?i:S(i)))}}return y().tap({msg:"rawTagKeywords()",result:(0,a.compactBlankish)((0,a.uniq)(t)),meta:{t:null==e?void 0:(0,c.pick)(e,...g.Settings.keywordTags.values)}})}},15912:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeLensModel=t.cleanBogusPrecision=t.justLengthAndAperture=t.extractLensMakeModel=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(55835),o=i(31586),l=i(68708),u=i(54993),c=i(48884),d=i(50213),h=i(28874),f=i(30748),m=(0,n.lazy)((()=>(0,d.mkLogger)("tags.LensMakeModel"))),p={nikkor:"Nikon","m.zuiko":"Olympus",zuiko:"Olympus"},g=/^zeiss batis (?[\d.]+)\/(?[\d.]+)(?.*)/i;function y(e){return null!=e&&null==e.match(/^0+$/)}t.extractLensMakeModel=function(e){const t=(0,f.make)(e.LensMake),i=(0,f.make)(e.Make),n=[],o=(0,c.first)([e.LensInfo,e.DNGLensInfo,e.LensSpec,e.LensModel,e.LensID],S),u=(0,r.uniq)([e.LensModel,e.LensID,e.LensSpec,e.LensInfo,e.LensType,e.LensType2,e.LensType3,e.Lens]);m().debug("extractLensMakeModel",{lensMake:t,lensInfo:o,lensModels:u});for(const e of u){{const t=g.exec(e)?.groups;null!=t&&n.push({lensMake:"Zeiss",lensModel:`Batis ${t.mm}mm F${t.f} ${t.etc.trim()}`.trim(),lensInfo:`${t.mm}mm f/${t.f}`})}if(null==S(e))continue;(0,s.notBlank)(t)&&n.push({lensMake:t,lensModel:e,lensInfo:o});const a=e.toLowerCase();for(const[t,i]of(0,l.entries)(p))a.includes(t)&&n.push({lensMake:i,lensModel:e,lensInfo:o});for(const i of(0,r.compactBlanks)([t,...h.Settings.lensMakes.values]))e.toLowerCase().includes(i.toLowerCase())&&n.push({lensMake:i,lensModel:e,lensInfo:o});a.startsWith("vr ")&&"Nikon"===i&&n.push({lensMake:"Nikon",lensModel:e,lensInfo:o})}for(const e of n){const t=p[e.lensMake.toLowerCase()];e.lensMake=t??e.lensMake,e.lensModel=b(e.lensModel.replace(new RegExp("\\b"+e.lensMake+"\\b","i"),"")),e.lensInfo=(0,a.map)(e.lensInfo,b)}return(0,c.greatestBy)(n,(e=>[null==e.lensModel.match(/\bor\b/i),e.lensModel.length]))};const v=/([\d. -]+)\s?mm\b/i,w=/\bf\/?([\d.\-]+)/i;function S(e){if((0,s.blank)(e)||(0,u.toS)(e).toLowerCase().includes("unknown"))return;e=e.replace(/\s+/g," ").trim();const t=v.exec(e)?.[1].replace(/\s/g,""),i=w.exec(e)?.[1];return y(t)&&y(i)?b(`${t}mm f/${i}`):void 0}function b(e,t=3){return e.replace(/\d+\.\d+/g,(e=>(0,a.mapOr)((0,o.toFloat)(e),(e=>String((0,o.sigFigs)(e,t))),e))).replace(/\s+/g," ").trim()}t.justLengthAndAperture=S,t.cleanBogusPrecision=b,t.normalizeLensModel=function(e){return b(e).replace(/(\d) - (\d)/g,((e,t,i)=>`${t}-${i}`)).replace(/(\d)\s+mm\b/,((e,t)=>t+"mm")).replace(/\s+f\/?(\d)/i,((e,t)=>" f/"+t))}},30748:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.model=t.makeFromSoftware=t.make=t.extractMakeAndModel=t.companyCased=void 0;const n=i(19851),r=i(22573),s=i(55835),a=i(68708),o=i(54993),l=i(68852),u=i(81168),c=i(56946),d=i(12788);function h(e,t,i=""){const n=e.replace(t,i);return n===e?e:h(n,t,i)}const f=new Map(["BenQ","GoPro","HTC","LG","NEC","OnePlus","Sony","TrueHDR"].map((e=>[e.toLowerCase(),e])));function m(e){const t=e.trim(),i=f.get(t.toLowerCase());return null!=i?i:t.length<4?t:t.toLowerCase().replace(/(?:^|\s|-)\S/g,(e=>e.toUpperCase()))}t.companyCased=m;class p{constructor(){this.ignorables=["ag","camera","co","company","computer","corp","corporation","digital","elec","electric","electronics","fototechnic","global","gmbh","group","imaging","inc","international","ltd","optical","photo","products","solutions","system","technologies","technology","techwin"].join("|"),this.ignorableSep="[\\s\\.,_-]*",this.IgnorableMakePatterns=new RegExp(`${this.ignorableSep}(?:${this.ignorables})${this.ignorableSep}$`,"i"),this.IgnorableModelPatterns=[/[\da-f]{24,}$/i,/\(v\d(?:\d?[^\d\n\r\u2028\u2029]\d+|\d{2,}(?:[^\d\n\r\u2028\u2029]\d+)?)\)\w?$/i,/digital camera$/i,/zoom camera$/i],this.samsungPatterns=[[/^PL150 /,"PL150"],[/^SCH-I545|SHV-E300|SGH-I337|SGH-M919|SPH-L720|SCH-R970|SGH-N045|GT-I950/i,"Galaxy S4"],[/^SGH-i537|GT-I9295/,"Galaxy S4 Active"],[/^GT-S50\S+|SM-G90/,"Galaxy S5"],[/^SM-G870A/,"Galaxy S5 Active"],[/^SM-A30\S+/,"Galaxy A3"],[/^SM-A530/,"Galaxy A8"],[/^SM-A700\S+/,"Galaxy A7"],[/^SM-A730/,"Galaxy A8+"],[/^SM-G920\S+/,"Galaxy S6"],[/^SM-G925\S+/,"Galaxy S6 Edge"],[/^SM-G928/,"Galaxy S6 Edge+"],[/^SM-G930\S+/,"Galaxy S7"],[/^SM-G935\S+/,"Galaxy S7 Edge"],[/^SM-G950/,"Galaxy S8"],[/^SM-G955/,"Galaxy S8+"],[/^SM-G960/,"Galaxy S9"],[/^SM-G965/,"Galaxy S9+"],[/^SM-G970/,"Galaxy S10e"],[/^SM-G973|SM-G977|SC-03|SCV41/,"Galaxy S10"],[/^SM-G975|SC-04|SC-05|SCV42/,"Galaxy S10+"],[/^SM-G98[01]/,"Galaxy S20"],[/^SM-G98[56]/,"Galaxy S20+"],[/^SM-G988/,"Galaxy S20 Ultra"],[/^SM-J510\S+/,"Galaxy J5"],[/^SM-N900/,"Galaxy Note 3"],[/^SM-N910/,"Galaxy Note 4"],[/^SM-N920/,"Galaxy Note 5"],[/^SM-N930/,"Galaxy Note 7"],[/^SM-N950/,"Galaxy Note 8"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-G991/,"Galaxy S21"],[/^SM-G996/,"Galaxy S21+"],[/^SM-G998/,"Galaxy S21 Ultra"],[/^SM-S901/,"Galaxy S22"],[/^SM-S906/,"Galaxy S22+"],[/^SM-S908/,"Galaxy S22 Ultra"],[/^SM-S911/,"Galaxy S23"],[/^SM-S916/,"Galaxy S23+"],[/^SM-S918/,"Galaxy S23 Ultra"],[/^SM-A245/,"Galaxy A24 4G"],[/^SM-E146B/,"Galaxy F14"],[/^SM-F711/,"Galaxy Z Flip 3"],[/^SM-F721/,"Galaxy Z Flip 4"],[/^SM-F936/,"Galaxy Z Fold 4"],[/^SM-E546B/,"Galaxy F54"],[/^SM-X700|SM-X706/,"Galaxy Tab S8"],[/^SM-X800|SM-X806/,"Galaxy Tab S8+"],[/^SM-X900|SM-X906/,"Galaxy Tab S8 Ultra"],[/SM-T509/,"Galaxy Tab A7"]],this.lgPatterns=[[/LG-D80[0-35]|LS98|VS98|L-01F/,"G2"],[/D85|F400|LS990|US990|VS985/,"G3"],[/H81\d|F500|LS991|US991|VS986/,"G4"],[/H850|H858|VS987|H820|LS992|H830|US992|H860N/,"G5"],[/H87[0-3]|LS993|AS993|US997|VS998/,"G6"],[/^(LM-)?G71/i,"G7"]],this.onePlusPatterns=[[/A0001/,"One"],[/A100\d/,"X"],[/A20\d\d/,"2"],[/A30\d\d/,"3(T)"],[/A40\d\d/,"4"],[/A500\d/,"5"],[/A501\d/,"5T"],[/A600\d/,"6"],[/A601\d/,"6T"],[/GM1900|GM1901|GM1903/,"7"],[/GM1910|GM1911|GM1913|GM1915|GM1917/,"7 Pro"],[/HD1900|HD1901|HD1903|HD1905|HD1907/,"7T"],[/HD1910|HD1911|HD1913/,"7T Pro"],[/HD1925/,"7T Pro 5G"],[/IN2010|IN2011|IN2013|IN2015|IN2017|IN2019/,"8"],[/IN2020|IN2021|IN2023|IN2025/,"8 Pro"],[/LE2115|LE2113|LE2111/,"9"],[/LE2121|LE2125|LE2123|LE2120/,"9 Pro"],[/LE2101/,"9r"],[/CPH2389/,"Nord N300"],[/CPH2415|CPH2413|CPH2417/,"10T"],[/NE2210|NE2211|NE2213|NE2215|NE2217/,"10 Pro"],[/PGP110/,"Ace Pro"],[/PHB110|CPH2449|CPH2447|CPH2451/,"11"]],this.CommonNamesByMake={Samsung:this.samsungPatterns,LG:this.lgPatterns,OnePlus:this.onePlusPatterns}}}const g=(0,n.lazy)((()=>new p)),y=/\bgopro\b/i;function v(e){if((0,d.isExifUnset)(e))return;let t=(0,u.stripQuotes)(e);return/Hewlett[- ]Packard/i.test(t)?"HP":(t=h(t,g().IgnorableMakePatterns),t=t.replace(/\s+app on Apple iDevice$/i,""),t=t.replace(/\bLGE\b/,"LG"),t=t.replace(/\bEastman Kodak\b/i,"Kodak"),t=m(t),t=t.replace(/^OM$/i,"OM System"),t)}t.extractMakeAndModel=function(e){if(null==e)return{};const t=v(e.Make)??S(e.Software)??S(e.CreatorTool)??function(e){return y.test((0,o.toS)(e.HandlerDescription))||y.test((0,o.toS)(e.CompressorName))?"GoPro":void 0}(e),i=P(t,(0,d.toExifDefined)(e.Model)??(0,d.toExifDefined)(e.CameraModelName)??(0,d.toExifDefined)(e.CameraModel));return(0,a.compactValues)({Make:t,Model:i})??{}},t.make=v;const w={Acer:/^Acer\b/i,Canon:/^(Canon|CanoScan)\b/i,Daisy:/^Exif Daisy\b/i,Fujifilm:/Digital Camera FinePix\b/i,GE:/Digital Camera GE\b/i,Kodak:/\bKodak\b/i,Kyocera:/^Kyocera|SAMURAI\b/i,LG:/^(LGE_SW|LG Electronics)\b/i,Minolta:/^(Minolta|DiMAGE|DYNAX|MAXXUM|ALPHA SWEET)\b/i,Nikon:/^(Nikon|COOLPIX)\b/i,Olympus:/^OLYMPUS\b/i,OnePlus:/^OnePlus/i,Pentax:/^(Optio|PENTAX)\b/i,Ricoh:/^RICOH\b/i,RIM:/^(Rim Exif Version|BlackBerry)/i};function S(e){if(!(0,r.blank)(e))for(const[t,i]of(0,a.entries)(w))if(i.test(e))return t}t.makeFromSoftware=S;const b=/<\s*(\S[^,/]+)[,/]/;function P(e,t){if((0,d.isExifUnset)(e)||(0,d.isExifUnset)(t))return;let i=(0,u.stripQuotes)(t);if("Samsung"===e){const e=b.exec(i);null!=e&&(i=e[1].trim())}const n=(0,s.map)(g().CommonNamesByMake[e],(e=>e.find((([e])=>null!=i.match(e)))));if(null!=n)return n[1].trim();if(i=i.replace(new RegExp(`^${(0,l.escapeRegExp)(e)}\\s+`,"i"),""),"Sony"===e){i=i.replace(/^(?:DSLR-A|SLT-A|ILCA-|ILCE-)/,"α").replace(/7CL?/i,"7c");const e=/M(\d+)$/.exec(i);null!=e&&(i=i.slice(0,e.index)+" "+(0,c.intToRoman)(e[1]))}if("Kodak"===e&&(i=i.replace(/Kodak|digital|science|zoom|camera/gi,"").replace(/\s+/g," ")),"Olympus"!==e&&"OM System"!==e||(i=(0,s.mapOr)(/^(.+?\d)mark(i.+)$/i.exec(i),(e=>`${e[1]} Mark ${e[2]}`),(()=>i))),"Panasonic"===e&&(i=i.replace(/^(?:DC|DMC)-(.{2,})$/i,"$1")),"Motorola"===e&&(i=i.replace(/DROID/i,"Droid ")),"Canon"===e){i=i.replace(/\bDIGITAL\b/i,"").trim().replace(/EOS\s+REBEL/i,"EOS Rebel");const e=i.match(/^EOS R(\d+)\s*m(\d+)$/i);null!=e&&(i=`EOS R${e[1]} Mark ${(0,c.intToRoman)(e[2])}`)}for(const e of g().IgnorableModelPatterns)i=h(i,e).trim();return null!=e.match(/^HP|Hewlett.Packard$/i)&&null!=i.match(/^hp\b/i)&&(i=i.slice(2).trim()),i}t.model=P},16170:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isMimeTypeIncluded=t.isAssetFileMimeType=t.isFileMimeTypeIncluded=t.isLibrawMimeType=t.isSharpMimeType=t.normalizeMimetype=t.isVideoMimeType=t.isImageMimeType=t.isMimeTypeSupportedByBrowser=void 0;const n=i(22573),r=i(54993),s=i(2322),a=i(277),o=i(16047),l=i(66106),u=i(14036),c=i(54979),d={"video/m2ts":"video/mp2t","video/avi":"video/x-msvideo","video/vnd.avi":"video/x-msvideo","video/msvideo":"video/x-msvideo"};function h(e){return(0,n.notBlank)(e)&&(e.startsWith("video/")||"application/mp4"===e||"application/ogg"===e)}function f(e){const t=(0,r.toS)(e).toLowerCase();return d[t]??t}function m(e,t){if(null==e)return!1;for(const i of t)if(i.includes("*")){if(null!=new RegExp("^"+i.replace(/\*/g,".*")+"$","i").exec(e))return!0}else if(i.toLowerCase()===e)return!0;return!1}t.isMimeTypeSupportedByBrowser=function(e,t=""){return((0,s.isChrome)(t)||(0,s.isFirefox)(t)?u.CurrentBrowserMimetypes:u.OldBrowserMimetypes).includes((0,r.toS)(e))},t.isImageMimeType=function(e){return(0,r.toS)(e).startsWith("image/")},t.isVideoMimeType=h,t.normalizeMimetype=f,t.isSharpMimeType=function(e){return!(0,n.blank)(e)&&f(e)in u.SharpImageFiletypes},t.isLibrawMimeType=function(e){return!(0,n.blank)(e)&&f(e)in u.RawImageFiletypes},t.isFileMimeTypeIncluded=async function(e,t){return m(await(0,c.readMimeType)(e),t)},t.isAssetFileMimeType=async function(e){const t=await(0,c.readMimeType)(e);return!(0,n.blank)(t)&&(h(t)?await(0,l.isVideoSupported)():(0,o.isHeifMimeType)(t)?await(0,a.isHeifSupported)():t in u.AssetFiletypes)},t.isMimeTypeIncluded=m},61208:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const n=i(50989);t.NameTagFormats=(0,n.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const n=i(50989);t.NameTagOrders=(0,n.strEnum)("western","eastern")},95141:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rotationToWriteTag=t.rotationToExifOrientation=t.orientationToRotation=t.orientationRequiresMirroring=t.extractRotation=void 0;const n=i(21605),r=i(54993),s=i(16170);t.extractRotation=function(e){return null==e?void 0:((0,s.isVideoMimeType)(e.MIMEType)?(0,n.normalizeRotation)(e.Rotation):void 0)??o(e.Orientation)};const a=new Map([["Horizontal (normal)",0],["Rotate 90 CW",90],["Rotate 180",180],["Rotate 270 CW",270],[1,0],[6,90],[3,180],[8,270]]);function o(e){return(0,n.isRotation)(e)?e:null!=e?a.get(e):void 0}t.orientationRequiresMirroring=function(e){return[2,4,5,7].includes(e)||(0,r.toS)(e).startsWith("Mirror")},t.orientationToRotation=o;const l=new Map([[0,1],[90,6],[180,3],[270,8]]);t.rotationToExifOrientation=function(e){return l.get((0,n.normalizeRotation)(e))},t.rotationToWriteTag=function(e){const t=(0,n.normalizeRotation)(e);return null==t?void 0:{"Orientation#":l.get(t),Rotation:t}}},7330:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractLiked=t.extractRating=t.clampRating=void 0;const n=i(55835),r=i(31586),s=i(28874);function a(e){const t=(0,r.toInt)(e);return null==t?void 0:(0,r.clamp)(-1,5,t)}function o(e){return a(e?.Rating)??(0,r.mapNumeric)((0,r.toInt)(e?.RatingPercent),(e=>Math.ceil(5*e/100)))??(0,n.map)(e?.favorited,(e=>!0===e?s.Settings.likeRating.valueOrDefault:void 0))}t.clampRating=a,t.extractRating=o,t.extractLiked=function(e){const t=o(e);return null==t?void 0:t>=s.Settings.likeRating.valueOrDefault}},54979:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readMimeType=t.mimetypeCache=void 0;const n=i(19851),r=i(22573),s=i(55835),a=i(88561),o=i(78923),l=i(95696),u=i(63870),c=i(47783),d=i(16170);t.mimetypeCache=(0,n.lazy)((()=>new a.FileCache({name:"tags.mimetype",maxSize:2048,timeoutMs:(0,u.commandTimeoutMs)()}))),t.readMimeType=async function(e){if((0,r.blank)(e))return;const i=l.PosixFile.for(e);return(0,t.mimetypeCache)().getOrSetAsync(i.nativePath,(async()=>(0,s.map)((0,c.rawTagsCache)().get(i.nativePath)?.MIMEType??(await(0,c.cachedTags)(i))?.MIMEType??(await(0,o.readFileType_)(i.nativePath).catch((()=>{})))?.mime,d.normalizeMimetype)))}},79915:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultSidecarExt=t.existingSidecars=t.AllowedUncommonSuffixRe=t.isSidecarOf=void 0;const n=i(16928),r=i(40958),s=i(22573),a=i(81168),o=i(56519),l=i(35280),u=i(32144),c=i(4001),d=i(28874),h=i(14036);function f(e,t,{ignoreCase:i}){return i?(0,a.equalsIgnoreCase)(e,t,{normalize:!0}):e===t}function m(e,i){if(!(0,u.isSidecarExt)(i.ext)||i.base.startsWith("."))return!1;const o=(0,u.isJsonExt)(i.ext),l=o||d.Settings.matchSidecarsCaseInsensitively.valueOrDefault;if(f(e.base,i.name,{ignoreCase:l}))return!0;if(f(e.name,i.name,{ignoreCase:l}))return!0;if((0,u.normalizeExt)(e)===(0,u.normalizeExt)(i.name)){const t=(0,n.parse)(i.name).name;if(f(e.name,t,{ignoreCase:l}))return!0}const m=o||d.Settings.matchSidecarsFuzzily.valueOrDefault;if(m)for(const t of(0,r.uniq)([e.base,e.name,(0,h.stripExt)(e.base)]))for(const e of(0,r.uniq)([i.name,i.name,(0,h.stripExt)(i.name)]))if(f((0,c.stripCopySuffixFromName)(t),(0,c.stripCopySuffixFromName)(e),{ignoreCase:m}))return!0;return o&&function(e,i){const n=(0,a.commonPrefixIgnoreCase)(e,i);if(n.length<8)return!1;function r(e){return(0,s.blank)(e)||null!=e.match(t.AllowedUncommonSuffixRe)}const o=r(e.slice(n.length)),l=r(i.slice(n.length));return o&&l}(e.name,i.name)}t.isSidecarOf=m,t.AllowedUncommonSuffixRe=/^((-edit(ed)?)|(-?\w{1,2})|(-?\(\d{1,2}\)))$/i,t.existingSidecars=async function(e){return t=e,(0,u.isSidecarExt)(t.ext)||(0,l.inHiddenPhotoStructureDir)(t)?[]:(0,o.sortByAsync)({name:"_existingSidecars",arr:e.siblings((t=>m(e,t))),f:e=>e.mtimeMs()});var t},t.defaultSidecarExt=function(){return(0,a.ensurePrefix)(d.Settings.defaultSidecarType.valueOrDefault,".")}},1078:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractSizeInfoFromTags=t.extractSizeInfoFromFile=void 0;const n=i(19851),r=i(22573),s=i(42659),a=i(33374),o=i(48884),l=i(50213),u=i(88561),c=i(95696),d=i(86580),h=i(34943),f=i(66106),m=i(43207),p=i(47783),g=i(16170),y=i(95141),v=(0,n.lazy)((()=>(0,l.mkLogger)("tags.SizeInfo"))),w=(0,n.lazy)((()=>new u.FileCache({name:"tags.sizeInfo",maxSize:256,timeoutMs:s.minuteMs})));async function S(e,t){if(null==e)return;const i=null==t||(0,r.blank)(t.ImageHeight)?await(0,p.readRawTags)(e):t;if(null==i)return;const n=(0,y.extractRotation)(t)??(0,y.extractRotation)(i);if((0,g.isLibrawMimeType)(i.MIMEType))return b(i,n,await(0,h.rawInfo)(e));const s=b(i,n);if(null!=s)return s;if((0,g.isVideoMimeType)(i.MIMEType)){const t=await S(await(0,f.extractVideoFrame_)(e),i);if(null!=t)return{...t,durationMs:(0,m.extractDurationMs)(i)}}}function b(e,t,i){t??(t=(0,y.extractRotation)(e));const n=(0,o.first)([i?.ImageSize,{width:e?.ImageWidth,height:e?.ImageHeight}],(e=>(0,a.isDimensions)(e)?e:void 0));if(null==n)return v().tap({msg:"extractSizeInfo("+e?.FileName+") (undefined fileDimensions)",result:void 0,meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo,fileDimensions:n}});const r=(0,a.maybeDimSwap)(n,t);return v().tap({msg:"extractSizeInfo("+e?.FileName+")",result:{ImageHeight:r.height,ImageWidth:r.width,aspectRatio:(0,d.aspectRatio)(r),dimensions:r,rotation:t,fileDimensions:n,orientation:e?.Orientation},meta:{mimetype:e?.MIMEType,rawInfo:h.rawInfo}})}t.extractSizeInfoFromFile=async function(e,t){if(null==e)return;const i=c.PosixFile.for(e);return w().getOrSetAsync(i.nativePath,(()=>S(i,t)))},t.extractSizeInfoFromTags=b},61424:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractStatPathTime=t.extractStatBname=t.nearestSiblingTzOffset=t.nearestSiblings=t.beforeAfterCapturedAt=t.inferCapturedAtFromSiblings=t.inferMakeAndModel=t.canInferForDir=void 0;const n=i(77988),r=i(51168),s=i(19851),a=i(40958),o=i(76790),l=i(22573),u=i(42659),c=i(55835),d=i(59455),h=i(48884),f=i(23467),m=i(50213),p=i(96859),g=i(56038),y=i(24689),v=i(79842),w=i(21330),S=i(98725),b=i(51275),P=i(35280),M=i(19748),_=i(88561),E=i(95696),x=i(65238),T=i(17217),D=i(57902),k=i(28874),C=i(80496),F=i(65162),O=i(28544),I=i(47783),L=i(88840),A=i(30748),R=i(16170),N=(0,s.lazy)((()=>(0,m.mkLogger)("tags.TagInference"))),B=7;async function z(e){return k.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.never?(N().debug("canInferForDir("+e+"): disabled: "+k.Settings.siblingInference.toEnvLine()),!1):!0===(0,P.inHiddenPhotoStructureDir)(e)?(N().debug("canInferForDir("+e+"): disabled (PhotoStructure directory)"),!1):!(k.Settings.siblingInference.valueOrDefault===C.TagInferenceSettingValues.auto&&await(0,x.isSlowDir)(e.nativePath)&&!await(0,x.isCachedDir)(e.nativePath)&&(N().debug("canInferForDir("+e+"): disabled (slow uncached directory)"),1))}async function j(e){e=(0,d.toA)(e);for(let t=0;te.base)));for(const t of n){const n=(0,A.extractMakeAndModel)(await(0,I.readRawTags)(t));if((0,f.definedAndNotEql)(n.Make,i.Make))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Make)",{mm:i,fromSibling:n});else if((0,f.definedAndNotEql)(n.Model,i.Model))N().debug("inferMakeAndModel("+e+"): skipping sibling (mismatching Model)",{mm:i,fromSibling:n});else if(null!=n.Make&&null!=n.Model)return N().tap({msg:"inferMakeAndModel("+e+")",level:D.LogLevels.info,result:n,meta:{sibling:t.base}})}return i},t.inferCapturedAtFromSiblings=async function(e){if(!await z(e.parent()))return;const t=await W(e);return null!=t&&(0,w.closeTo)(t.before.date,t.after.date,2*u.dayMs)?(0,c.map)(y.DateInterval.for((0,w.toExifDateTime)(t.before.date,(0,b.getZoneName)(t.before.date)),(0,w.toExifDateTime)(t.after.date,(0,b.getZoneName)(t.after.date)),t.index,t.slots),(e=>({date:e,src:`before:${t.before.src},after:${t.after.src}`}))):void 0};const V=(0,s.lazy)((()=>new _.FileCache({name:"tags.beforeAfterCapturedAt"})));function W(e){return V().getOrSet(e.nativePath,(async()=>{const t=await q(e),i=await j(t?.younger),n=await j(t?.older);return null==i||null==n?void 0:{before:i,after:n,index:i.index,slots:i.index+n.index+1}}))}t.beforeAfterCapturedAt=W;const H=(0,M.extFilter)(L.ExtTypes.AssetFile);function U(e){return null==e?[]:(0,a.compact)((0,h.flatZip)((0,d.toA)(e.younger),(0,d.toA)(e.older)))}async function q(e,t=7,i=!0){if(!await z(e.parent()))return;const n=await(0,g.time)("tags.nearestSiblings:"+e,(async()=>{const t=await e.parent().directoryEntry(),i=await(t?.childFiles());return i?.filter((async e=>e.isFile()&&!e.isNameHidden()&&(H(e)??await(0,R.isAssetFileMimeType)(e))))}));if(null==n)return void N().info("nearestSiblings(): can't readdir parent, "+e.parent());const r=(0,o.sortBy)(n,(e=>(0,F.bname)(e))),s=(0,T.findFileIndex)(e,r);if(s<0)return N().warn("nearestSiblings(): can't find self in siblings: "+e,{canRetry:i}),i?(e.parent().clear(),q(e,t,!1)):void 0;const l=k.Settings.siblingInferenceBasenameCoeffPct.valueOrDefault/100,[u,c]=[r.slice(s-2*t,s),r.slice(s+1,s+1+2*t)],d=[],h=[];for(;(0,a.isNotEmpty)(u)&&d.length=l&&d.push(t)}for(;(0,a.isNotEmpty)(c)&&h.length=l&&h.push(t)}return N().tap({msg:"nearestSiblings()",level:"trace",result:{younger:d,older:h},meta:{f:e}})}t.nearestSiblings=q,t.nearestSiblingTzOffset=async function(e){if(!await z(e.parent()))return;const t=U(await q(e)),i=await async function(e){e=(0,d.toA)(e).slice(0,B);for(const t of e){const e=await(0,I.readRawTags)(t);if(null!=e&&(0,l.notBlank)(e.tz)&&e.tzSource!==n.defaultVideosToUTC)return N().tap({msg:"firstWithZoneName()",result:{zoneName:e.tz,path:t.nativePath,base:t.base,src:e.tzSource??"tags.tz"},meta:{tzSource:e.tzSource}})}N().debug("firstWithZoneName(): no zone name found",{arr:e})}(t);return N().tap({msg:"nearestSiblingTzOffset()",result:i,meta:{f:e,sibs:t.map((e=>e.base))}})},t.extractStatBname=async function(e){const t=(0,a.uniq)([(0,F.bname)(e,!0),(0,F.bname)(e,!1)]),i=(0,S.parseDated)({input:t});if(null==i)return void N().debug("extractStatBname(): bname isn't dated",{base:e.base,input:t});const n=await e.stat();if(null!=n){for(const e of["birthtime","atime","mtime","ctime"])if((0,v.datedOverlap)({a:i,b:n[e]}))return N().tap({msg:"extractStatBname()",result:{src:e,date:i},meta:{input:t,stat:n}});return N().tap({msg:"extractStatBname(): no stat overlap with bname",result:void 0,meta:{input:t,fromName:i,stat:n}})}N().debug("extractStatBname(): no stat",{path:e.nativePath})},t.extractStatPathTime=async function(e){const t=(0,S.extractDateFromPath)(e.pathsForDateParsing);if(null==t)return;const i=await e.stat();if(null!=i){for(const e of["birthtime","mtime","ctime"]){const n=i[e];if(null!=n&&!0===(0,v.datedOverlap)({a:t,b:n}))return N().tap({msg:"extractStatPathTime()",result:{src:"path+"+e,date:r.DateTime.fromJSDate(n)},meta:{dateFromPath:t,stat:i,src:e}})}return N().tap({msg:"extractStatPathTime(): no match",result:void 0,meta:{dateFromPath:t,stat:i}})}}},42231:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.omitAncestorTags=t.isTagPathDescendant=t.leafIsExcluded=t.tagPathLeaf=t.tagPathsInclude=t.tagDiff=t.tagPathEql=t.uniqTagPaths=t.normalizeTagPath=t.splitTagPath=t.joinedTagPathBasename=t.joinTagPath=t.tagPathToStringArray=t.tagPathToPathTag=t.tagRefToS=t.TagSep=void 0;const n=i(40958),r=i(76790),s=i(22573),a=i(55835),o=i(51926),l=i(59455),u=i(54993),c=i(48884),d=i(28874),h=i(81168);function f(e){return(0,u.toS)((0,o.isString)(e)?e:e?.name).normalize()}function m(e){return(0,n.compact)((0,l.toA)(e).map(f))}function p(e,i=t.TagSep){return m(e).map((e=>(0,o.replaceAll)(e,i,""))).join(i)+(i===t.TagSep?i:"")}function g(e,i=t.TagSep){return(0,u.toS)(e).split(i).filter(s.notBlank)}function y(e){return m(e).join(t.TagSep).toLowerCase()}function v(e){return(0,s.blank)(e)?void 0:Array.isArray(e)?f((0,n.last)(e)):(0,n.last)(g(e))}function w(e,t){if((0,n.isEmpty)(e)||(0,n.isEmpty)(t)||e.length>t.length)return!1;const i=m(t);return m(e).every(((e,t)=>(0,h.equalsIgnoreCase)(e,i[t])))}t.TagSep=String.fromCharCode(31),t.tagRefToS=f,t.tagPathToPathTag=function(e){return(0,c.ancestry)(m(e)).map(((e,t)=>({tagPath:e,displayName:e[t].displayName})))},t.tagPathToStringArray=m,t.joinTagPath=p,t.joinedTagPathBasename=function(e){return(0,n.last)(g(e))},t.splitTagPath=g,t.normalizeTagPath=function(e){return p(g(e))},t.uniqTagPaths=function(e){return(0,n.uniqBy)((0,l.toA)(e),(e=>(0,n.isEmpty)(e)?void 0:p(e)))},t.tagPathEql=function(e,t){return null!=e&&null!=t&&y(e)===y(t)},t.tagDiff=function(e,t){const i=new Set((0,n.compact)(t).map((e=>y(e))));return(0,n.compact)(e).filter((e=>!i.has(y(e))))},t.tagPathsInclude=function(e,t){const i=y(e);return t.some((e=>i===y(e)))},t.tagPathLeaf=v,t.leafIsExcluded=function(e,t){return(0,a.mapOr)(v(e),(e=>(0,h.includesIgnoreCase)(t,e)),(()=>!1))},t.isTagPathDescendant=w,t.omitAncestorTags=function(e){if(!d.Settings.omitAncestorTags.valueOrDefault)return e;const t=[];for(const i of(0,r.sortBy)(e.filter(n.isNotEmpty),(e=>-e.length)))t.some((e=>w(i,e)))||t.push(i);return(0,r.sortBy)(t,(t=>e.indexOf(t)))}},8791:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extractTitleDescription=void 0;const n=i(40958),r=i(22573),s=i(68708),a=i(54993);t.extractTitleDescription=function(e){const t=(0,n.uniq)(["OLYMPUS DIGITAL CAMERA",e.original?.Make,e.original?.Model,e.Model,e.Make,e.CameraID]).map((e=>(0,r.mapNotBlank)(e,(e=>e.trim().toLowerCase().normalize())))),i=(...i)=>{for(const n of i){const i=(0,a.toS)(e[n]).trim();if((0,r.notBlank)(i)&&!t.includes(i.toLowerCase().normalize()))return i}};return(0,s.compactValues)({title:i("XPTitle","Title","ObjectName"),description:i("XPSubject","Description","ImageDescription","Caption-Abstract")})}},45200:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriExists=t.uri2nativePath=t.uriVariants=t.nativePath2uriVariants=t.nativePath2uris=t.nativePath2uri=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(96249),o=i(89937),l=i(59455),u=i(50213),c=i(56519),d=i(16287),h=i(7014),f=i(34238),m=i(87001),p=i(20237),g=i(5696),y=i(12228),v=(0,n.lazy)((()=>(0,u.mkLogger)("uri.FileURI")));async function w(e){const t=await(0,h.bestVolumeForPath)(e);return(0,c.thenCompact)([(0,g.nativePath2pslib)(e),(0,p.nativePath2psfile)(e,t),(0,y.nativePath2psnet)(e,t),f.URI.file(e)])}async function S(e){const t=await w(e);return(0,r.uniq)((0,a.flatten)(t.map(m.uriEncodingVariants)))}async function b(e,t){if((0,s.blank)(e))return;const i=function(e){try{return f.URI.isUri(e)?e:f.URI.parse(e,!0)}catch(t){return void v().warn("bad URI",{uri:e,err:t})}}(e);if(null!=i)switch(i.scheme){case"file":return i.fsPath;case o.PS_LOCAL_FILE_SCHEME:return(0,p.psfile2nativePath)(i,t);case o.PS_NETWORK_FILESYSTEM_SCHEME:return(0,y.psnet2nativePath)(i,t);case o.PS_LIBRARY_SCHEME:return(0,g.pslib2nativePath)(i);default:throw new Error("unsupported URI: "+e)}}t.nativePath2uri=async function(e,t){return null==e||(0,s.blank)(e)?v().throw("empty nativePath passed to nativePath2uri()",{retriable:!1}):(0,g.nativePath2pslib)(e)??await(0,p.nativePath2psfile)(e,t)??await(0,y.nativePath2psnet)(e,t)??f.URI.file(e)},t.nativePath2uris=w,t.nativePath2uriVariants=S,t.uriVariants=async function(e,t){const i=(0,m.uriEncodingVariants)(e);return i.push(...(0,l.toA)(await(0,c.thenMap)(b(e,t),S))),(0,r.uniq)(i)},t.uri2nativePath=b,t.uriExists=async function(e,t){const i=await b(e,t);return null!=i&&await(0,d.exists)(i)}},34238:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriToBasename=t.toURI=t.percentDecode=t.uriToFsPath=t.encodeURIComponentFast=t.URI=void 0;const n=i(76760),r=i(57975),s=i(90595),a=i(22573),o=i(55835),l=i(51926),u=i(29652),c=i(54993),d=i(48884),h=i(43334),f=/^\w[\w+.-]*$/,m=/^\//,p=/^\/\//,g="",y="/",v=/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;class w{static isUri(e){return e instanceof w||null!=e&&"string"==typeof e.authority&&"string"==typeof e.fragment&&"string"==typeof e.path&&"string"==typeof e.query&&"string"==typeof e.scheme&&"function"==typeof e.fsPath&&"function"==typeof e.with&&"function"==typeof e.toString}constructor(e,t,i,n,r,s=!1){"object"==typeof e?(this.scheme=e.scheme||g,this.authority=e.authority||g,this.path=e.path||g,this.query=(0,u.toURLSearchParams)(e.query??""),this.fragment=e.fragment||g):(this.scheme=function(e,t){return e||t?e:"file"}(e,s),this.authority=t??g,this.path=function(e,t){switch(e){case"https":case"http":case"file":t?t[0]!==y&&(t=y+t):t=y}return t}(this.scheme,i??g),this.query=(0,u.toURLSearchParams)(n??""),this.fragment=r??g,function(e,t){if(!e.scheme&&!0===t)throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${e.authority}", path: "${e.path}", query: "${e.query}", fragment: "${e.fragment}"}`);if(e.scheme&&!f.test(e.scheme))throw new Error("[UriError]: Scheme contains illegal characters.");if(e.path)if(e.authority){if(!m.test(e.path))throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character')}else if(p.test(e.path))throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")')}(this,s))}get fsPath(){return E(this,!1)}with(e){if(null==e)return this;let{scheme:t,authority:i,path:n,query:r,fragment:s}=e;return void 0===t?t=this.scheme:null===t&&(t=g),void 0===i?i=this.authority:null===i&&(i=g),void 0===n?n=this.path:null===n&&(n=g),void 0===r?r=this.query:null===r&&(r=g),void 0===s?s=this.fragment:null===s&&(s=g),t===this.scheme&&i===this.authority&&n===this.path&&r===this.query&&s===this.fragment?this:new b(t,i,n,r,s)}static parse(e,t=!1){const i=v.exec(e);if(!i)return new b(g,g,g,g,g);const n=i[2]||g,r=k(i[4]||g),s=(i[5]||g).split("/").map(k).join("/"),a="psfile"===n&&s.startsWith("//")?s.slice(1):s,o=(0,u.toURLSearchParams)(i[7]),l=k(i[9]||g);return new b(n,r,a,o,l,t)}static file(e){let t=g;if(h.isWin&&(e=e.replace(/\\/g,y)),e[0]===y&&e[1]===y){const i=e.indexOf(y,2);-1===i?(t=e.substring(2),e=y):(t=e.substring(2,i),e=e.substring(i)||y)}return new b("file",t,e,g,g)}static from(e){return new b(e.scheme,e.authority,e.path,e.query,e.fragment)}static joinPath(e,...t){if(!e.path)throw new Error("[UriError]: cannot call joinPaths on URI without path");let i;return i=h.isWin&&"file"===e.scheme?w.file(n.win32.join(E(e,!0),...t)).path:n.posix.join(e.path,...t),e.with({path:i})}isRootPath(){return null==this.path||this.path===y}get pathBase(){return this.isRootPath()?"":(0,o.map)(this.path,(e=>(0,d.findLast)(e.split(y),a.notBlank)))}parent(){return this.isRootPath()?this:this.with({path:this.path.slice(0,this.path.lastIndexOf(y))})}join(...e){return this.with({path:(0,l.ensureSuffix)(this.path,y)+e.join(y)})}toString(e=!1){return x(this,e)}toJSON(){return this}[r.inspect.custom](){return this.toString()}}t.URI=w;const S=h.isWinPortable?1:void 0;class b extends w{constructor(){super(...arguments),this._formatted=null,this._fsPath=null}get fsPath(){return null==this._fsPath&&(this._fsPath=E(this,!1)),this._fsPath}toString(e=!1){return e?x(this,!0):(null==this._formatted&&(this._formatted=x(this,!1)),this._formatted)}toJSON(){const e={$mid:1};return null!=this._fsPath&&(e.fsPath=this._fsPath,e._sep=S),null!=this._formatted&&(e.external=this._formatted),this.path&&(e.path=this.path),this.scheme&&(e.scheme=this.scheme),this.authority&&(e.authority=this.authority),(0,a.mapNotBlank)(this.query,(t=>e.query=t)),this.fragment&&(e.fragment=this.fragment),e}}const P={58:"%3A",47:"%2F",63:"%3F",35:"%23",91:"%5B",93:"%5D",64:"%40",33:"%21",36:"%24",38:"%26",39:"%27",40:"%28",41:"%29",42:"%2A",43:"%2B",44:"%2C",59:"%3B",61:"%3D",32:"%20"};function M(e,t){let i,n=-1;for(let r=0;r=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57||45===s||46===s||95===s||126===s||t&&47===s)-1!==n&&(i+=encodeURIComponent(e.substring(n,r)),n=-1),void 0!==i&&(i+=e.charAt(r));else{void 0===i&&(i=e.substr(0,r));const t=P[s];void 0!==t?(-1!==n&&(i+=encodeURIComponent(e.substring(n,r)),n=-1),i+=t):-1===n&&(n=r)}}return-1!==n&&(i+=encodeURIComponent(e.substring(n))),void 0!==i?i:e}function _(e){let t;for(let i=0;i1&&"file"===e.scheme?`//${e.authority}${e.path}`:47===e.path.charCodeAt(0)&&(e.path.charCodeAt(1)>=65&&e.path.charCodeAt(1)<=90||e.path.charCodeAt(1)>=97&&e.path.charCodeAt(1)<=122)&&58===e.path.charCodeAt(2)?t?e.path.substr(1):e.path[1].toLowerCase()+e.path.substr(2):e.path,h.isWin&&(i=i.replace(/\//g,"\\")),i}function x(e,t){const i=t?_:M;let n="";const{scheme:r,query:s,fragment:o}=e;let{authority:l,path:u}=e;if(r&&(n+=r,n+=":"),(l||"file"===r)&&(n+=y,n+=y),l){let e=l.indexOf("@");if(-1!==e){const t=l.substr(0,e);l=l.substr(e+1),e=t.indexOf(":"),-1===e?n+=i(t,!1):(n+=i(t.substr(0,e),!1),n+=":",n+=i(t.substr(e+1),!1)),n+="@"}e=l.indexOf(":"),-1===e?n+=i(l,!1):(n+=i(l.substr(0,e),!1),n+=l.substr(e))}if(u){if(u.length>=3&&47===u.charCodeAt(0)&&58===u.charCodeAt(2)){const e=u.charCodeAt(1);e>=65&&e<=90&&(u=`/${String.fromCharCode(e+32)}:${u.substr(3)}`)}else if(u.length>=2&&58===u.charCodeAt(1)){const e=u.charCodeAt(0);e>=65&&e<=90&&(u=`${String.fromCharCode(e+32)}:${u.substr(2)}`)}n+=i(u,!0)}return(0,a.mapNotBlank)(s,(e=>n+="?"+e)),o&&(n+="#",n+=t?o:M(o,!1)),n}function T(e){try{return decodeURIComponent(e)}catch{return e.length>3?e.substr(0,3)+T(e.substr(3)):e}}t.encodeURIComponentFast=M,t.uriToFsPath=E;const D=/(?:%[\dA-Z][\dA-Z])+/gi;function k(e){return e.startsWith("xn--")?(0,s.toUnicode)(e):e.match(D)?e.replace(D,(e=>T(e))):e}t.percentDecode=k,t.toURI=function(e){return w.isUri(e)?e:w.parse(e)},t.uriToBasename=function(e){return(0,l.splitLast)((0,c.toS)(e),"/")}},87001:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.uriEncodingVariants=t.uriIsEquivalent=t.uriEqlSync=t.normalizeURI=t.isUri=void 0;const n=i(19851),r=i(40958),s=i(50357),a=i(89937),o=i(54993),l=i(50213),u=i(45200),c=i(34238),d=["http:","https:","file:",a.PS_LOCAL_FILE_SCHEME,a.PS_NETWORK_FILESYSTEM_SCHEME].map((e=>e+"//"));t.isUri=function(e){const t=(0,o.toS)(e).toLowerCase();return d.some((e=>t.startsWith(e)))};const h=(0,n.lazy)((()=>(0,l.mkLogger)("uri.UriNormalization")));function f(e,t){return null!=e&&null!=t&&(e===t||e.normalize()===t.normalize())}function m(e,t){try{if(null==e||null==t)return!1;const i=(0,c.toURI)(e),n=(0,c.toURI)(t);return i.scheme===n.scheme&&i.authority===n.authority&&f(i.path,n.path)}catch{return!1}}t.normalizeURI=function(e){try{return c.URI.parse(e).toString()}catch(t){return h().warn("Failed to normalize invalid URI",{uri:e,err:t}),e}},t.uriEqlSync=m,t.uriIsEquivalent=async function(e,t){try{return null!=e&&null!=t&&((0,s.eql)(e,t)||m(e,t)||f(await(0,u.uri2nativePath)(e),await(0,u.uri2nativePath)(t)))}catch{return!1}},t.uriEncodingVariants=function(e){const t=(0,c.toURI)(e);return(0,r.uniq)([t.toString(),t.with({path:t.path.normalize("NFC")}).toString(),t.with({path:t.path.normalize("NFD")}).toString()])}},20237:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.psfile2nativePath=t.joinMountpoint=t.nativePath2psfile=void 0;const n=i(76760),r=i(22573),s=i(51926),a=i(89937),o=i(29882),l=i(78133),u=i(43334),c=i(7014),d=i(34238),h=i(85087);function f(e,t){return(0,n.join)(e,...t.split("/").slice(1))}t.nativePath2psfile=async function(e,t){if((0,r.blank)(e))return;if(null==(t=null!=t&&(0,o.containedByNativePath)({ancestor:t.mountpoint,descendant:e,acceptSelf:!0})?t:await(0,c.bestVolumeForPath)(e))||(0,r.blank)(t.uuid))return;const i=(0,l.native2posix)(e),n=(0,l.native2posix)(t.mountpoint);if(!i.normalize().startsWith(n.normalize()))return;const u=(0,s.ensurePrefix)(i.slice(n.length),"/");return d.URI.from({scheme:a.PS_LOCAL_FILE_SCHEME,authority:(0,h.volsha)(t.uuid),path:u})},t.joinMountpoint=f,t.psfile2nativePath=async function(e,t){if(e.scheme!==a.PS_LOCAL_FILE_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,r.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=u.isPosix?n.win32.sep:n.posix.sep,s=(0,r.notBlank)(t)&&!t.includes(i);if(s&&!(0,r.blank)(t)){const i=await(0,c.bestVolumeForPath)(t);if(null!=i?.uuid&&(0,h.volsha)(i.uuid)===e.authority)return f(i.mountpoint,e.path)}const o=await(0,c.bestVolumeForVolsha)(e.authority);return null!=o?f(o.mountpoint,e.path):s&&(0,r.notBlank)(t)?f(t,e.path):void 0}},5696:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pslib2nativePath=t.nativePath2pslib=t.PSLIB_ROOT_URI=void 0;const n=i(40958),r=i(22573),s=i(51926),a=i(89937),o=i(87290),l=i(29882),u=i(95696),c=i(28874),d=i(34238);t.PSLIB_ROOT_URI=d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:""}),t.nativePath2pslib=function(e){if((0,r.blank)(e))return;const t=c.Settings.libraryDir.valueOrDefault;if((0,r.blank)(t))return;const i=(0,n.uniq)([t,(0,o.libraryOriginalsDirPosixFile)()]).find((t=>(0,l.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0})));if(null==i)return;const u=(0,s.ensurePrefix)((0,l.posixPathFrom)(i,e),"/");return d.URI.from({scheme:a.PS_LIBRARY_SCHEME,path:u})},t.pslib2nativePath=function(e){if(e.scheme!==a.PS_LIBRARY_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");const t=(0,o.libraryOriginalsDirPosixFile)();if(null==t)throw new Error("invalid URI: "+e+" (no library set)");const i=(0,s.stripPrefix)(e.path,"/"),n=t.join(i);if(n.isFileSync())return n.nativePath;if(!t.eql(c.Settings.libraryDir.valueOrDefault)){const e=u.PosixFile.for(c.Settings.libraryDir.valueOrDefault).join(i);if(e.isFileSync())return e.nativePath}return n.nativePath}},12228:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)"default"!==i&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.psnet2nativePath=t.nativePath2psnet=void 0;const a=s(i(76760)),o=i(22573),l=i(89937),u=i(59455),c=i(81168),d=i(78133),h=i(16287),f=i(96128),m=i(43334),p=i(7014),g=i(34238);t.nativePath2psnet=async function(e,t){if(!(0,o.blank)(e))return t??(t=await(0,p.bestVolumeForPath)(e)),null!=t&&!0===t.remote&&(0,o.notBlank)(t.remoteHost)&&(0,o.notBlank)(t.remoteShare)?g.URI.from({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME,authority:t.remoteHost,path:a.posix.join("/"+t.remoteShare,(0,c.stripPrefix)((0,d.native2posix)(e),(0,d.native2posix)(t.mountpoint)))}):e.startsWith("\\\\")?g.URI.file(e).with({scheme:l.PS_NETWORK_FILESYSTEM_SCHEME}):void 0},t.psnet2nativePath=async function(e,t){if(e.scheme!==l.PS_NETWORK_FILESYSTEM_SCHEME)throw new Error("invalid URI: "+e+" (bad scheme)");if((0,o.blank)(e.authority))throw new Error("invalid URI: "+e+" (missing authority)");const i=e.path.split("/").slice(1),n=i[0];if((0,o.blank)(n))throw new Error("invalid URI: "+e+" (missing share)");if(m.isWin)return`\\\\${e.authority}\\${i.join(a.sep)}`;const r=i.slice(1),s=await(0,p.volumes)();for(const t of(0,u.toA)(s))if(!0===t.remote&&(0,c.equalsIgnoreCase)(t.remoteShare,n)&&await(0,f.isEquivalentHost)(e.authority,t.remoteHost))return a.join(t.mountpoint,...r);return await(0,h.isReadableDirectory)(t)?a.join(t,...r):void 0}},85087:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.volsha=void 0;const n=i(22573),r=i(42659),s=i(9103),a=i(37628);t.volsha=(0,s.memoize)((e=>(0,n.mapNotBlank)(e,a.shortStringSha)),{maxSize:128,ttlMs:r.minuteMs})},60865:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const n=i(37805),r=i(30577);t.channel=function(){return(0,r.extractUpdateChannel)(n.version)},t.baseVersion=()=>[n.versionMajor,n.versionMinor,n.versionPatch].join("."),t.versionMajorMinor=n.versionMajor+"."+n.versionMinor},76280:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toSemver=t.semverSatisfies=t.debianVersionToSemver=void 0;const n=i(38064),r=i(22573),s=/^(?:\d+:)?[vn]?(?\d+)(?\.\d+)?(?\.\d+)?/;function a(e){if(e instanceof n.SemVer)return e.version;const t=s.exec(e??"")?.groups;return null==t?void 0:t.major+(t.minor??".0")+(t.patch??".0")}t.debianVersionToSemver=a,t.semverSatisfies=function(e,t){if((0,r.blank)(e))return!1;const i={loose:!0,includePrerelease:!0};if((0,n.satisfies)(e,t,i))return!0;const s=a(e);return null!=s&&(0,n.satisfies)(s,t,i)},t.toSemver=function(e){try{return e instanceof n.SemVer?e:(0,n.parse)(e,{loose:!0})??void 0}catch{return}}},30577:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const n=i(50989);t.UpdateChannels=(0,n.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const i of t.UpdateChannels.values)if(e.includes("-"+i))return i;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},8540:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mightBeAssetMountpoint=void 0;const n=i(40958),r=i(9595),s=i(29882),a=i(43334),o=i(28874);t.mightBeAssetMountpoint=function(e){for(const t of(0,n.compactBlanks)([o.Settings.libraryDir.valueOrDefault,(0,r.originalsDir)(),...o.Settings.scanPaths.values]))if((!a.isPosix||!(0,s.pathIsRoot)(t))&&(0,s.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))return!0;return!1}},1485:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const n=i(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,n.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},50424:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dfPosix=t.acceptPosixVolume=void 0;const n=i(19851),r=i(22573),s=i(59455),a=i(50213),o=i(88158),l=i(66430),u=i(45969),c=i(28874),d=i(8540),h=i(69108),f=i(68884),m=i(98770),p=i(59107),g=i(69375),y=(0,n.lazy)((()=>(0,a.mkLogger)("volumes.DfPosix"))),v=(0,m.lazyFsAsync)("localMountpoints",(async()=>(await(0,h.dfPosixRaw)({localsOnly:!0,paths:await(0,p.mountpoints)()}))?.map((e=>e.mountpoint))));function w(e){const t=!(0,d.mightBeAssetMountpoint)(e.mountpoint),i=null!=e.filesystem&&(0,g.isExcludedFilesystem)(e.filesystem),n=(0,g.isExcludedMountpoint)(e.mountpoint),r=!!c.Settings.validateMountpoints.valueOrDefault&&!(0,l.isReadableDirectorySync)(e.mountpoint),s=t&&(i||n||r);return y().tap({msg:"acceptPosixVolume()",result:!s,meta:{volume:e,notAssetMountpoint:t,excludedFS:i,excludedMP:n,excludedDir:r}})}t.acceptPosixVolume=w,t.dfPosix=async function(){const e=(0,u.isDocker)()?await(0,p.mountpoints)():void 0,t=await(0,h.dfPosixRaw)({paths:e});if(null==t)return;const i=(0,s.toA)(await v());if(t.forEach((e=>{var t;e.remote=!i.includes(e.mountpoint)||(t=e.filesystem,(0,r.notBlank)(t)&&c.Settings.remoteFilesystemTypes.values.includes(t))})),await(0,f.isGioSupported)())for(const e of(0,s.toA)(await(0,f.gioVolumes)())){const i=t.find((t=>t.mountpoint===e.mountpoint));null==i?t.push(e):(y().info("Merging GIO and df volume",{dfVol:i,gioVol:e}),(0,o.assignMissingPrimitives)(i,e))}return t.filter(w)}},69108:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseDfVolume=t.parseDfVolumes=t.dfPosixRaw=t.dfPosixRawLocal_=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(31586),o=i(12168),l=i(53507),u=i(50213),c=i(84777),d=i(43334),h=i(63870),f=(0,n.lazy)((()=>(0,u.mkLogger)("volumes.DfPosixRaw")));function m(e){return(0,a.toInt)(e,{defaultValue:0})*o.KiB}function p(e){const t=(0,l.parseFixed)(["Filesystem","1024-blocks","Used","Available","Capacity","Mounted on"],e);return(0,r.compact)(t.map((e=>g(e))))}function g(e){const t=e.Filesystem,i=e["Mounted on"],n=m(e["1024-blocks"])??0;if(0===n)return void f().info("parseDfVolume(): skipping (size is 0)",{vol:e});const r=m(e.Used)??0,s=m(e.Available)??0;if(0!==r||0!==s)return{filesystem:t,mountpoint:i,size:d.isMac?r+s:n,used:r,available:s};f().info("parseDfVolume(): skipping (used and available is 0)",{vol:e,size:n,used:r,available:s})}t.dfPosixRawLocal_=async function(){return(0,c.stdout_)("df",["-l","-k","-P"],{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!1,ignoreExitCode:!1})},t.dfPosixRaw=async function({localsOnly:e,paths:t,output:i}={}){const n=["-k","-P"];if(!0===e&&n.push("-l"),n.push(...(0,r.compactBlanks)(t)),i??(i=await(0,c.stdout_)("df",n,{timeoutMs:(0,h.commandTimeoutMs)(),ignoreStderr:!0,ignoreExitCode:!0})),(0,s.blank)(i))return f().warn("empty output",{localsOnly:e,paths:t}),[];f().debug("output",{localsOnly:e,paths:t,output:i});const a=p(i);return!0===e&&a.forEach((e=>e.remote=!1)),a},t.parseDfVolumes=p,t.parseDfVolume=g},48165:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.volumeInfoWin=t.parseGetVolumeRow=t.getLocalVolumesWin_=t.getVolumeCommand=t.getPsDriveCommand=t.normalizeDriveLetter=t.dfWin=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(22573),o=i(96249),l=i(55835),u=i(31586),c=i(68708),d=i(51926),h=i(59455),f=i(54993),m=i(50213),p=i(81168),g=i(56519),y=i(8769),v=i(24399),w=i(28874),S=i(24541),b=i(60224),P=i(63870),M=(0,n.lazy)((()=>(0,m.mkLogger)("volumes.DfWin")));t.dfWin=async function(){return(await I()).filter((e=>!1!==e.ok&&(0,u.gt0)(e.size)))};const _=/([a-z]+)(?::\\)?/i;function E(e){return e?.match(_)?.[1]?.toUpperCase()}function x(e){return(0,l.map)(E(e),(e=>e+":\\"))}function T(e){return`Get-PSDrive -PSProvider FileSystem ${(0,f.toS)(E(e))} | Select-Object -Property Root,DisplayRoot,Description,Used,Free`}function D(e){return null!=e&&!(0,a.blank)(e.Root)&&(0,u.gte0)(e.Free)&&(0,u.gte0)(e.Used)?(0,c.compactBlankValues)({mountpoint:(0,d.ensureSuffix)(e.Root,":\\").toUpperCase(),label:e.Description,size:e.Used+e.Free,used:e.Used,available:e.Free,remote:(0,a.notBlank)(e.DisplayRoot),...(0,l.map)((0,b.parseRemoteName)(e.DisplayRoot),(e=>({remoteHost:e.host,remoteShare:e.share})))}):void 0}function k(e){return`Get-Volume ${(0,f.toS)(E(e))} | Select-Object -Property DriveLetter,FileSystem,FileSystemLabel,Size,SizeRemaining,HealthStatus,OperationalStatus,UniqueId`}t.normalizeDriveLetter=x,t.getPsDriveCommand=T,t.getVolumeCommand=k,t.getLocalVolumesWin_=function(){return v.PowerShell.instance().executeJsonToA(k())};const C=/\{([-a-z\d]{7,})\}/i;function F(e,t){return e=e?.trim(),(0,a.blank)(e)||(0,p.equalsIgnoreCase)(e,t)?void 0:e}function O(e){if(null==e.DriveLetter||"null"===e.DriveLetter||"System Reserved"===e.FileSystemLabel)return void M().debug("parseGetVolumeRow(): skipping system recovery volume",{o:e});const t=x(e.DriveLetter);if(null==t)return void M().debug("parseGetVolumeRow(): skipping volume: invalid DriveLetter",{o:e});const i=(0,r.compact)([F(e.HealthStatus,"healthy"),F(e.OperationalStatus,"OK")]).join("; "),n=null!=e.Size&&null!=e.SizeRemaining&&(0,a.notBlank)(e.DriveLetter)&&(0,a.blank)(i);return M().tap({msg:"parseGetVolumeRow()",result:{mountpoint:t,filesystem:e.FileSystem,label:e.FileSystemLabel,uuid:(s=e.UniqueId,M().tap({msg:"uniqueId2uuid",result:(0,l.map)(C.exec((0,f.toS)(s)),(e=>e[1])),meta:{s}})),size:e.Size,used:e.Size-e.SizeRemaining,available:e.SizeRemaining,remote:!1,ok:n,status:i},meta:{input:e}});var s}async function I(){const e=(0,r.uniq)((0,h.toA)(await(0,S.mountpointsWin)()).map(x)),t=await(0,g.mapAsync)({name:"volumeInfoWin.psDrivesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(T(e)).catch((t=>((0,y.onError)("volumeInfoWin(): Get-PSDrive failed for drive "+e,{error:t}),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),i=(0,r.compact)((0,o.flatten)(t).map(D)),n=await(0,g.mapAsync)({name:"volumeInfoWin.volumesJson",arr:e,f:e=>v.PowerShell.instance().executeJsonToA(k(e)).catch((t=>(M().debug("volumeInfoWin(): Get-Volume failed for drive "+e,t),[]))),maxConcurrent:w.Settings.powerShellProcs.valueOrDefault,timeoutMs:(0,P.commandTimeoutMs)()}),a=(0,r.compact)((0,o.flatten)(n).map(O)),l=(0,r.uniq)([...i,...a].filter((e=>!1===e.ok)).map((e=>e.mountpoint))),u=(0,s.sort)((0,r.uniq)([...i,...a].map((e=>e.mountpoint))).filter((e=>!l.includes(e))));M().info("volumeInfoWin()",{psDriveVols:i,getVolumesVols:a,healthyMountpoints:u,unhealthy:l});const c=u.map((e=>({...i.find((t=>e===t.mountpoint)),...a.find((t=>e===t.mountpoint))})));return c.forEach((e=>{l.includes(e.mountpoint)&&(e.ok=!1),e.ignorable=!0===e.ignorable||!1===e.ok})),c}t.parseGetVolumeRow=O,t.volumeInfoWin=I},68884:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gioVolumes=t.GioMountMonitorArgs=t.GioCommand=t.isGioSupported=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(42659),o=i(41400),l=i(55835),u=i(97790),c=i(50213),d=i(23560),h=i(45255),f=i(81168),m=i(1728),p=i(56519),g=i(4867),y=i(84777),v=i(83278),w=i(8103),S=i(16287),b=i(45969),P=i(43334),M=i(69108),_=i(98770),E=i(44224),x=i(63870);t.isGioSupported=(0,n.lazy)((async()=>{if(!P.isLinux||(0,b.isDocker)()||(0,d.isBillingService)()||null==await(0,w.pathTo)({tool:t.GioCommand}))return!1;try{return 0===(await(0,y.stdoutResult_)(t.GioCommand,["version"],{timeoutMs:(0,x.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}})),t.GioCommand="gio",t.GioMountMonitorArgs=["mount","--monitor","--anonymous"];const T=(0,n.lazy)((()=>(0,c.mkLogger)("volumes.Gio")));t.gioVolumes=(0,n.lazy)((async()=>(0,g.thenOrTimeoutError)({p:async()=>{if(!await(0,t.isGioSupported)())return;const e=await async function(){return await(0,t.isGioSupported)()?T().tap({msg:"gvfsFuseDirectories()",result:await(0,p.thenFlatten)(await(0,p.thenMap)((0,E.readProcMounts)(void 0,(e=>"gvfsd-fuse"===e),S.isReadableDirectory),(e=>e.map((e=>v.BaseFile.for(e).clear().childDirectories())))))}):T().tap({msg:"gvfsFuseDirectories(): gio is not supported",result:[]})}();return(0,r.isEmpty)(e)?[]:(T().info("gioVolumes()",{fuseDirs:e}),(0,p.mapAsyncSerial)({arr:e,name:"gioVolumes",timeoutMs:(0,x.mountpointsTtlMs)(),f:async e=>{const t=await(0,M.dfPosixRaw)({paths:[e.nativePath]}),i=t?.[0];if(null==i||!e.nativePath.startsWith(i.mountpoint))return void T().warn("df failed to find "+e,{vols:t});i.mountpoint=e.nativePath;const n=await D(i.mountpoint);return null==n?i:{remote:!0,...i,...n}}}))},timeoutMs:(0,x.mountpointsTtlMs)()}))),(0,o.later)((()=>(0,_.setupVolumeTTL)(t.gioVolumes)));const D=(0,m.memoizeAsync)((async e=>{try{const i=(await(0,y.stdout_)(t.GioCommand,["info",e],{timeoutMs:(0,x.commandTimeoutMs)()})).split(/[\r\n]+/),n=(0,s.mapNotBlank)(i.find((e=>e.startsWith("uri: "))),(e=>new URL((0,f.stripPrefix)(e,"uri: "))));return{displayName:(0,l.map)(i.find((e=>e.startsWith("display name: "))),(e=>(0,f.stripPrefix)(e,"display name: "))),remoteHost:(0,l.map)(n,(e=>e.hostname)),remoteShare:(0,u.opt)(n).flatMap((e=>e.pathname)).flatMap((e=>(0,f.stripPrefix)(e,"/"))).flatMap((e=>(0,f.stripSuffix)(e,"/"))).flatMap(decodeURIComponent).filter(s.notBlank).get()}}catch(t){return void T().warn("getRemoteInfo(): info failed",{mountpoint:e,err:t})}}),{name:"gio.getRemoteInfo",maxSize:255,timeoutMs:h.ShortCommandTimeoutMs,clearEveryMs:10*a.minuteMs})},98770:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setupVolumeTTL=t.lazyFsAsync=void 0;const n=i(19851),r=i(5233),s=i(41400),a=i(56038),o=i(70025),l=i(34102),u=i(28874),c=i(59107),d=i(63870);function h(e){e.setTTL(u.Settings.volumeMetadataTtlMs.valueOrDefault),u.Settings.volumeMetadataTtlMs.watchLater((t=>e.setTTL(t)))}t.lazyFsAsync=function(e,t,i){const u=(0,n.lazy)((()=>(0,a.time)("volumes."+e,(()=>(0,r.retryOnReject_)(t,{maxRetries:2,timeoutMs:(0,d.commandTimeoutMs)(),errorIsRetriable:e=>!1!==(0,o.isRetriableError)(e)&&!1!==(0,o.isIgnorableError)(e)})))),i);return(0,s.later)((()=>{c.mountpoints.watchLater((()=>u.unset())),(0,l.ee)().on("clearCache",(()=>u.unset())),null==i&&h(u)})),u},t.setupVolumeTTL=h},27461:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.localVolumes_blkid_=t.localVolumes_lsblk_=t.addLocalVolumeInfoLinux=void 0;const n=i(19851),r=i(40958),s=i(22573),a=i(31586),o=i(50213),l=i(88158),u=i(45255),c=i(81168),d=i(84777),h=i(6012),f=i(84542),m=i(68284),p=i(57902),g=i(45969),y=i(69108),v=i(98770),w=i(63870),S=(0,n.lazy)((()=>(0,o.mkLogger)("volumes.LocalVolumesLinux")));t.addLocalVolumeInfoLinux=async function(e){if((0,g.isDocker)())return;const i=await(0,t.localVolumes_lsblk_)().catch((e=>S().warn("lsblk failed",{error:e}))),n=await(0,t.localVolumes_blkid_)().catch((e=>S().warn("blkid failed",{error:e})));if(null==i&&null==n)return;const s=(0,c.sortIgnoreCase)((0,r.uniq)([...(i??[]).filter((e=>!e.ignorable)).map((e=>e.mountpoint)),...e.map((e=>e.mountpoint))])),a=[];for(const t of s){const r=e.find((e=>e.mountpoint===t)),s=i?.find((e=>e.mountpoint===t)),o={...r,...s},u=n?.find((e=>e.filesystem===o.filesystem));if(null!=u&&(0,l.assignMissingPrimitives)(o,u),null==o.size||null==o.available){const e=(await(0,y.dfPosixRaw)({localsOnly:!1,paths:[t]}))?.[0];S().info("backfilling mountpoint",{info:s,vol:r,df:e}),null!=e&&(0,l.assignMissingPrimitives)(o,e)}a.push(o)}return a};const b=/lsblk from util-linux ([\d.]+)$/i,P=(0,n.lazy)((async()=>{const e=await(0,d.stdout_)("lsblk",["--version"],{timeoutMs:u.ShortCommandTimeoutMs});return b.exec(e)?.[1]?.split(".").map((e=>(0,a.toInt)(e)))})),M=(0,n.lazy)((async()=>{const e=["mountpoint","label","uuid"],t=await P();return null!=t&&(0,a.gte)(t[0],2)&&(0,a.gte)(t[1],34)&&e.push("fsused","fsavail"),e.join(",")}));t.localVolumes_lsblk_=(0,v.lazyFsAsync)("localVolumes_lsblk",(async()=>{const e=await(0,d.stdout_)("lsblk",["-P","-b","--output",await M()],{timeoutMs:(0,w.commandTimeoutMs)()}),t=(0,f.splitLines)(e).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!0}))).filter((e=>null!=e)).map((e=>{const t=(0,s.blank)(e.mountpoint)||e.mountpoint.startsWith("/snap/")||"/boot"===e.mountpoint||e.mountpoint.startsWith("/boot/")||!(0,m.isDirectorySync)(e.mountpoint),i=(0,a.toInt)(e.fsused),n=(0,a.toInt)(e.fsavail);return{mountpoint:e.mountpoint,label:e.label,uuid:e.uuid,ignorable:t,...null!=i&&null!=n?{used:i,available:n,size:i+n}:void 0,...(0,g.isDocker)()?void 0:{remote:!1}}}));return S().tap({msg:"localVolumes_lsblk",level:p.LogLevels.trace,result:t})}),0),t.localVolumes_blkid_=(0,v.lazyFsAsync)("localVolumes_blkid",(async()=>(await(0,d.stdout_)("blkid",["-o","export"],{timeoutMs:(0,w.commandTimeoutMs)()})).split(/\n{2,}/).map((e=>(0,h.parseEnvTokens)({input:e,lowerCaseKeys:!1}))).filter((e=>!0===e?.DEVNAME?.includes("/"))).map((e=>({filesystem:e.DEVNAME,label:(0,s.toNotBlank)(e.PARTLABEL)??(0,s.toNotBlank)(e.LABEL),uuid:(0,s.toNotBlank)(e.PARTUUID)??(0,s.toNotBlank)(e.UUID)})))),0)},66840:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mnt2uuidMac=t.addLocalVolumeInfoMac=void 0;const n=i(57272),r=i(19851),s=i(40958),a=i(22573),o=i(38639),l=i(55835),u=i(20214),c=i(59455),d=i(50213),h=i(56519),f=i(4867),m=i(84777),p=i(69108),g=i(98770),y=i(63870),v=(0,r.lazy)((()=>(0,d.mkLogger)("volumes.LocalVolumesMac")));t.addLocalVolumeInfoMac=async function(e){return(0,u.thenMap)((0,t.mnt2uuidMac)(),(t=>e.map((e=>(0,l.mapOr)(t.get(e.mountpoint),(t=>({...e,...t})),(()=>e))))))},t.mnt2uuidMac=(0,g.lazyFsAsync)("mnt2uuidMac",(async function(){const e=await(0,p.dfPosixRaw)({localsOnly:!0}),t=(0,s.uniq)(e.map((e=>e.filesystem?.match(w)?.[1]))),i=Math.round((0,y.commandTimeoutMs)()/3),r=await(0,h.mapAsyncSerial)({name:"_mnt2uuidMac()",arr:t,f:async e=>(0,f.thenOrTimeoutError)({p:(0,m.stdout_)("diskutil",["list","-plist",e],{timeoutMs:i}),timeoutMs:i})}),l=new Map;for(const e of r)try{const t=(0,n.parse)(e);for(const e of(0,c.toA)(t.AllDisksAndPartitions))for(const t of(0,c.toA)(e.APFSVolumes))(0,a.blank)(t.MountPoint)||(0,o.isTrue)(t.OSInternal)?v().debug("skipping",t):l.set(t.MountPoint,{filesystem:"/dev/"+t.DeviceIdentifier,label:t.VolumeName,size:t.Size,uuid:t.VolumeUUID})}catch(t){v().warn("Failed to parse diskutil output",{err:t,out:e})}return l}),0);const w=/^(\/dev\/disk\d+)/},59107:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findmntPoll=t.gioMountMonitor=t.diskUtilActivity=t.isPosixMountpoint=t.mountpoints=t.mountpoints_=t.localMountpointSetup=void 0;const n=i(19851),r=i(40958),s=i(76790),a=i(42659),o=i(41400),l=i(13538),u=i(50213),c=i(7282),d=i(409),h=i(23560),f=i(45255),m=i(81168),p=i(27395),g=i(56519),y=i(56038),v=i(84777),w=i(34330),S=i(8769),b=i(34102),P=i(17217),M=i(16287),_=i(43334),E=i(28874),x=i(8540),T=i(68884),D=i(44224),k=i(24541),C=i(69375),F=i(63870),O=(0,n.lazy)((()=>(0,u.mkLogger)("volumes.Mountpoints")));function I(){t.mountpoints.unset(),t.mountpoints_.unset()}function L(e=(0,F.mountpointsTtlMs)()){t.mountpoints.setTTL(e),t.mountpoints_.setTTL(e)}async function A(){I()}t.localMountpointSetup=(0,n.lazy)((async()=>{E.Settings.libraryDir.watchLater(I),E.Settings.scanPaths.watchLater(I),(0,h.isSyncService)()&&E.Settings.scanAllDrives.valueOrDefault?(0,o.later)((async()=>{const e=(0,u.mkLogger)("Mountpoints.localMountpointSetup()");if(_.isMac&&(e.info("Setting up Mac diskutil activity watcher"),L((0,F.volumeMetadataTtlMs)()),(0,t.diskUtilActivity)()),_.isLinux){const i=(0,D.maybeWatchProcMounts)();await(0,T.isGioSupported)()&&(e.info("Setting up Linux gio mount monitor"),L((0,F.volumeMetadataTtlMs)()),(0,t.gioMountMonitor)()),null==i&&await N()&&(e.info("Setting up Linux findmnt mount monitor"),L((0,F.volumeMetadataTtlMs)()),(0,t.findmntPoll)())}}),a.minuteMs):await(0,g.awaitAll)([(0,p.end)(t.diskUtilActivity.clear()),(0,p.end)(t.gioMountMonitor.clear()),(0,p.end)(t.findmntPoll.clear())])}));const R=(0,n.lazy)((()=>{}));t.mountpoints_=(0,n.lazy)((async()=>{{const e=E.Settings.mountpoints.values;if((0,r.isNotEmpty)(e))return e}const e=await(0,l.thenOrTimeoutError)((0,y.time)("volumes.Mountpoints",_.isWin?k.mountpointsWin:D.mountpointsPosix),f.ShortCommandTimeoutMs);if((0,r.isEmpty)(e))return O().throw("mountpointsImpl() returned empty.",{fatal:!1});{const t=(0,s.sort)(await(0,g.filterAsync)({arr:e,name:"mountpointFilter",timeoutMs:(0,F.commandTimeoutMs)(),f:async e=>!(!(0,x.mightBeAssetMountpoint)(e)&&(0,C.isExcludedMountpoint)(e)||E.Settings.validateMountpoints.valueOrDefault&&!await(0,M.isReadableDirectory)(e)&&(O().warn(`mountpoint ${e} is not readable`),1))}));return R.set(t),t}})),t.mountpoints=(0,n.lazy)((async()=>{try{return await(0,t.mountpoints_)()}catch(e){return(0,S.onError)("mountpoints() failed",{cause:e}),R()}})),t.isPosixMountpoint=async function(e){if(_.isWin)return!1;const i=await(0,t.mountpoints)()??[],n=(0,P.toNativePath_)(e);return _.isMac?(0,m.includesIgnoreCase)(i,n):i.includes(n)},(0,o.later)((()=>{(0,b.ee)().on("clearCache",(()=>{T.gioVolumes.unset(),I()})),E.Settings.mountpointsTtlMs.watch(L)}),(0,c.isTest)()?1:a.minuteMs),t.diskUtilActivity=(0,n.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"diskutil",args:["activity"],onStdout:(0,d.rateLimited)({name:"diskUtilActivity",f:()=>A(),minCallDelayMs:1.5*a.secondMs})}))),t.gioMountMonitor=(0,n.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:T.GioCommand,args:T.GioMountMonitorArgs,onStdout:(0,d.rateLimited)({name:"gioMountMonitor",f:()=>(T.gioVolumes.unset(),A()),minCallDelayMs:f.ShortCommandTimeoutMs})})));const N=(0,n.lazy)((async()=>{if(!_.isLinux)return!1;try{return 0===(await(0,v.stdoutResult_)("findmnt",["--version"],{timeoutMs:(0,F.commandTimeoutMs)(),ignoreStderr:!0})).code}catch(e){return!1}}));t.findmntPoll=(0,n.lazy)((()=>(0,w.mkBasicWatchedChild)({cmd:"findmnt",args:["--poll"],onStdout:(0,d.rateLimited)({name:"findmntPoll",f:()=>A(),minCallDelayMs:f.ShortCommandTimeoutMs})})))},44224:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.maybeWatchProcMounts=t.readProcMounts=t.defaultFilesystemTypePredicate=t.mountpointsPosix=void 0;const n=i(19851),r=i(40958),s=i(42659),a=i(48884),o=i(50213),l=i(23560),u=i(81168),c=i(56519),d=i(73614),h=i(73787),f=i(55690),m=i(16287),p=i(68284),g=i(57902),y=i(43334),v=i(28874),w=i(69108),S=i(68884),b=i(59107),P=i(69375),M=(0,n.lazy)((()=>(0,o.mkLogger)("volumes.MountpointsPosix")));t.mountpointsPosix=async function(){const e=await T()??await(0,c.thenMap)((0,w.dfPosixRaw)({localsOnly:!1}),(e=>e.map((e=>e.mountpoint))));if(null!=e&&await(0,S.isGioSupported)())try{await(0,c.thenMap)((0,S.gioVolumes)(),(t=>e.push(...t.map((e=>e.mountpoint)))))}catch(e){M().warn("Failed to fetch gio volumes",e)}return e};const _="/proc/mounts";function E(e){return!v.Settings.excludedFilesystemTypes.has(e)}function x(e){return!(0,P.isExcludedMountpoint)(e)&&(!v.Settings.validateMountpoints.valueOrDefault||(0,m.isReadableDirectory)(e))}async function T(e=_,t=E,i=x){if(y.isLinux)try{const n=await(0,f.readLines_)(e),s=(0,r.compact)(n.map((e=>{const[t,i]=e.split(/\s+/);return(0,a.allNotBlank)(t,i)?[t,(0,u.unoctal)(i)]:void 0}))),o=await(0,c.filterAsync)({name:"mountpoints filter",arr:s,f:async([e,n])=>{const r=t(e),s=await i(n);return M().tap({level:g.LogLevels.trace,msg:"readProcMounts().predicate filters",result:r&&s,meta:{fs:e,mp:n,fsOK:r,mpOK:s}})}});return M().tap({msg:"readProcMounts()",result:o.map((([,e])=>e)),meta:{procMounts:e}})}catch(e){return void M().info("Failed to read /proc/mount",e)}}t.defaultFilesystemTypePredicate=E,t.readProcMounts=T,t.maybeWatchProcMounts=(0,n.lazy)((()=>y.isLinux&&(0,l.isSyncService)()&&!(0,p.isEmptyFileSync)(_)?new h.FileWatcher(_,{recursive:!1,persistent:!1},(()=>{M().info("detected change in "+_),(0,d.setUnrefTimeout)((()=>b.mountpoints.refresh()),s.secondMs)})):void 0))},24541:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mountpointsWinFsutil=t.mountpointsWinPwsh=t.mountpointsWin=void 0;const n=i(19851),r=i(42659),s=i(13538),a=i(50213),o=i(45255),l=i(81168),u=i(84777),c=i(8103),d=i(24399),h=(0,n.lazy)((()=>(0,a.mkLogger)("volumes.MountpointsWin")));async function f(){const e=await d.PowerShell.instance().executeJsonToA("Get-PSDrive -PSProvider FileSystem | Select-Object -Property Root");return null==e?void 0:(0,l.sortIgnoreCase)(e.map((e=>e.Root)))}t.mountpointsWin=(0,n.lazy)((async()=>{try{return await(0,s.thenOrTimeoutError)(f(),o.ShortCommandTimeoutMs)}catch(e){return h().warn("mountpointsWinPwsh()",{error:e}),p()}})),t.mountpointsWinPwsh=f;const m=/\s([A-Z]:\\)/g;async function p(){const e=await(0,u.stdout_)((0,c.fsutil)(),["fsinfo","drives"],{timeoutMs:10*r.secondMs}),t=[];let i;for(;null!==(i=m.exec(e));)t.push(i[1]);return(0,l.sortIgnoreCase)(t)}t.mountpointsWinFsutil=p},69375:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const n=i(19851),r=i(22573),s=i(50213),a=i(9103),o=i(7282),l=i(29882),u=i(43334),c=i(28874),d=(0,n.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,r.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,o.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,o.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,o.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,o.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,r.blank)(e))return"blank";const t=(0,l.toPathnames)(e),i=t[0],n=t[t.length-1];return c.Settings.excludedRootDirectories.has(i)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(n)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===i&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,a.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},70313:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseRemote=t.addRemoteVolumeInfoPosix=t.nfsRe=void 0;const n=i(22573),r=/\/\/(?.+@)?(?[^/@]+)\/(?.+)/,s=/(?:\._(?:smb|afs|nfs|tcp|afpovertcp))+/i;function a(e){if((0,n.blank)(e))return;const i=r.exec(e)?.groups;if(null!=i&&!(0,n.blank)(i.remoteHost)&&!(0,n.blank)(i.remoteShare))return{remoteHost:i.remoteHost.replace(s,""),remoteShare:i.remoteShare};const a=t.nfsRe.exec(e);if(null!=a){const e=a[1],t=a[2];if(!(0,n.blank)(e)&&!(0,n.blank)(t))return{remoteHost:e,remoteShare:t}}}t.nfsRe=/^([^:\s]+):(\/.*)$/,t.addRemoteVolumeInfoPosix=function(e){for(const t of e)if(!0===t.remote){const e=a(t.filesystem);null!=e&&(t.remoteHost=e.remoteHost,t.remoteShare=e.remoteShare)}return e},t.parseRemote=a},60224:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t._netInfoWinWmic=t.parseRemoteName=t.NetInfoCmd=t.addRemoteVolumeInfoWin=void 0;const n=i(40958),r=i(22573),s=i(42659),a=i(55835),o=i(97790),l=i(54993),u=i(53507),c=i(56639),d=i(88158),h=i(81168),f=i(84777),m=i(38835),p=i(8103),g=i(43334),y=i(24399),v=i(98770);t.addRemoteVolumeInfoWin=async function(e,t){if(!g.isWin)throw new Error("unsupported platform"+m.InternalErrorFlag);const i=(0,c.toMap)(t??await E()??[],(e=>[e.mountpoint,e]));return e.forEach((e=>{(0,a.map)(i.get(e.mountpoint),(t=>{e.remote=!0,e.remoteHost=t.host,e.remoteShare=t.share,e.ok=t.ok}))})),e};const w=["LocalName","RemoteName","Status"],S=["NETUSE","get",w.join(",")],b=/^\\\\([^\\]+)\\(.+)$/,P=/^[a-z]:\\?$/i;function M(e){if(!(0,r.blank)(e))return(0,o.opt)(e).flatMap((e=>b.exec(e))).map((e=>({host:e[1],share:e[2]}))).orElse((()=>(0,o.opt)(e).flatMap((e=>(0,d.Try)((()=>new URL(e))))).filter((e=>(0,r.notBlank)(e.hostname))).map((e=>({host:e.hostname,share:(0,o.opt)(e.pathname).filter(r.notBlank).getOrElse((()=>"/"))}))))).get()}async function _(){const e=(0,p.wmic)(),t=await(0,f.stdout_)(e,S,{timeoutMs:15*s.secondMs}),i=(0,u.parseFixed)(w,t);return(0,n.compact)(i.map((e=>(0,a.map)(b.exec((0,l.toS)(e.RemoteName)),(t=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(i=>({mountpoint:(0,h.ensureSuffix)(i[0],"\\"),host:t[1],share:t[2],ok:"OK"===e.Status}))))))))}t.NetInfoCmd="Get-WmiObject Win32_NetworkConnection | Select-Object -Property LocalName,RemoteName,ConnectionState,Status",t.parseRemoteName=M,t._netInfoWinWmic=_;const E=(0,v.lazyFsAsync)("netInfoWin",(async function(){const e=await y.PowerShell.instance().executeJsonToA(t.NetInfoCmd);return null==e?_():(0,n.compact)(e.filter((e=>(0,r.notBlank)(e.LocalName))).map((e=>(0,a.map)(M(e.RemoteName),(({host:t,share:i})=>(0,a.map)(P.exec((0,l.toS)(e.LocalName)),(n=>({mountpoint:(0,h.ensureSuffix)(n[0],"\\"),host:t,share:i,ok:"OK"===e.Status&&"Connected"===e.ConnectionState}))))))))}),0)},63870:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const n=i(42659),r=i(12168),s=i(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=r.MiB/n.secondMs},86848:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readVolumeUUID=t.readUuidFile_=t.toVolumeUUID=t.volumeUuidNotExpected=t.addVolumeUUIDs=void 0;const n=i(76760),r=i(19851),s=i(22573),a=i(38639),o=i(41400),l=i(13538),u=i(80049),c=i(50213),d=i(7282),h=i(81168),f=i(42638),m=i(34102),p=i(83278),g=i(84542),y=i(85772),v=i(95696),w=i(45969),S=i(28874),b=i(59107),P=i(63870),M=i(68995),_=(0,r.lazy)((()=>(0,c.mkLogger)("volumes.VolumeUUID"))),E=(0,r.lazy)((()=>new u.FifoCacheAsync({name:"volumes.VolumeUUID",maxSize:500,timeoutMs:(0,P.commandTimeoutMs)()})));function x(e){return(0,a.isTrue)(e.ignorable)||(0,w.isDocker)()&&"/"===e.mountpoint||(0,d.isTest)()&&"node_modules"===(0,n.basename)(e.mountpoint)}function T(e){if((0,s.blank)(e))return;const t=(0,h.stripComments)(e).replace(/[^\da-z-]+/gi,"").trim().replace(/^-|-$/g,"");return t.length<=8||/^[0-]*$/.test(t)||/^[F-]*$/i.test(t)?void 0:t}async function D(e){const t=await(0,l.thenOrTimeoutError)(e.readTextFile_(),(0,P.commandTimeoutMs)());for(const e of(0,g.splitLines)(t)){const t=T(e);if(null!=t)return t}throw new Error("No UUID found in "+e)}async function k(e){if(S.Settings.readVolumeUuidFiles.valueOrDefault)for(const t of S.Settings.volumeUuidFilePaths.values){const i=v.PosixFile.for(e.mountpoint).join(t),n=await D(i).catch((e=>_().info("Failed to read "+i,{error:e})));if(null!=n)return _().tap({msg:"readVolumeUUID(): serving UUID from "+t,result:n,meta:{mountpoint:e.mountpoint}})}const t=(0,n.join)(e.mountpoint,(0,M.volumeUuidSubpath)());if("/"===e.mountpoint)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t,result:e.uuid,meta:{volume:e}});if(S.Settings.skipWriteVolumeUuidFilesWithNoMedia.valueOrDefault){const i=await(0,y.whyNoMediaDir)(p.BaseFile.for(e.mountpoint));if(null!=i)return _().tap({msg:"readVolumeUUID(): not attempting to write "+t+": mountpoint is marked as NoMedia",result:e.uuid,meta:{volume:e,why:i}})}if(S.Settings.writeVolumeUuidFiles.valueOrDefault){const t=await(0,M.writeVolumeUuid)(e);if(!(0,s.blank)(t))return _().tap({msg:"readVolumeUUID(): wrote new "+(0,M.volumeUuidSubpath)(),result:t,meta:{volume:e}})}return _().tap({msg:"readVolumeUUID(): serving UUID from volume metadata",result:e.uuid})}(0,o.later)((()=>{(0,m.ee)().on("clearCache",(()=>E.clear())),b.mountpoints.watchLater((()=>E.clear()))})),t.addVolumeUUIDs=async function(e){await(0,f.withBoundedConcurrency)({name:"addVolumeUUIDs",laters:e.map((e=>()=>(0,l.thenOrOnTimeout)(async function(e){if(x(e))return;if((0,a.isFalse)(e.ok))return;const t=await E().getOrSetAsync(e.mountpoint,(async()=>k(e)));null!=t&&(e.uuid=t)}(e),(0,P.commandTimeoutMs)(),(()=>_().warn("addVolumeUUIDs("+e.mountpoint+") timed out",{timeoutMs:(0,P.commandTimeoutMs)()})))))})},t.volumeUuidNotExpected=x,t.toVolumeUUID=T,t.readUuidFile_=D,t.readVolumeUUID=k},7014:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.findVolumeForVolsha=t.bestRemoteVolume=t.remoteVolumeFor=t.bestVolumeForVolsha=t.bestVolumeForPath=t.bestMountpoint=t.rootVolume=t.rootPath=t.volumesImpl=t.volumes=t.priorVolumesIfMountpointsMatch=t.cachedVolumes=t.writeVolumesToCache=t.priorWriteVolumesToCacheLatch=t.canWriteVolumesToCache=t.clearVolumesCache=t.mountpointToVolsha=void 0;const r=n(i(48161)),s=n(i(76760)),a=i(19851),o=i(40958),l=i(76790),u=i(22573),c=i(38639),d=i(42659),h=i(41400),f=(i(50357),i(56409)),m=i(55835),p=i(31586),g=i(97790),y=i(42279),v=i(59455),w=i(48884),S=i(50213),b=i(7282),P=i(23560),M=i(28850),_=i(45255),E=i(81168),x=i(56519),T=i(4867),D=i(49776),k=i(9595),C=i(77740),F=i(44198),O=i(96706),I=i(8769),L=i(57159),A=(i(34102),i(21144)),R=i(73209),N=i(29882),B=i(95696),z=i(17217),j=i(16287),V=i(49076),W=i(96128),H=i(45969),U=i(43334),q=i(28874),G=i(85087),$=i(50424),J=i(48165),K=i(98770),Z=i(27461),X=i(66840),Y=i(59107),Q=i(70313),ee=i(60224),te=i(63870),ie=i(86848),ne=(0,a.lazy)((()=>(0,S.mkLogger)("volumes.Volumes"))),re=r.default.platform(),se=new Map,ae=new Map,oe=new Map;function le(e,t,i){if((0,u.blank)(e))return;const n=i.get(e);null!=n&&(0,p.gt)(n.updatedAt,t.updatedAt)||(i.set(e,t),(0,m.map)((0,G.volsha)(t.uuid),(e=>ae.set(t.mountpoint,e))))}function ue(e){if(null!=e)return le(e.mountpoint,e,se),le((0,G.volsha)(e.uuid),e,oe),e}function ce(){return(0,o.compact)([B.PosixFile.forMaybe((0,D.cacheDir)())?.join("volumes"),B.PosixFile.forMaybe((0,k.libraryDataDir)())?.join("volumes")])}t.mountpointToVolsha=(0,K.lazyFsAsync)("mountpointToVolsha",(async()=>(await de(),ae))),t.clearVolumesCache=async function({deleteFileCache:e=!1}={}){ne().warn("clearVolumesCache()",{deleteFileCache:e}),t.volumes.unset(),se.clear(),oe.clear(),de.unset(),t.cachedVolumes.unset(),e&&await Promise.all(ce().map((e=>e.rmrf())))};const de=(0,K.lazyFsAsync)("loadCachedVolumes",(async()=>{const e=await async function(){const e=await(0,x.mapAsync)({name:"readCachedVolumes",arr:(0,x.thenFlatten)(ce().map((e=>e.childFiles((e=>".json"===e.ext&&!e.base.startsWith(".")))))),f:e=>e.readJson()}),t=(0,l.sortBy)(e,(e=>[e.mountpoint,-e.updatedAt]));[...t.reverse()].forEach(ue);const i=(0,o.uniqBy)(t,(e=>e.mountpoint)).map((e=>({...e,fromCache:!0})));return(0,E.sortByCaseInsensitive)(i,(e=>e.mountpoint))}();return e?.forEach(ue),e}));async function he(e){if(null==e)return;const i=new f.Latch;t.priorWriteVolumesToCacheLatch.set(i);const n=Date.now(),r=e.filter((e=>!(0,c.isTrue)(e.fromCache))).map((e=>({...e,...(0,H.isDocker)()?{}:{fromHost:(0,V.cleanHostname)()},updatedAt:n,os:re}))),s=new Map;for(const e of r)for(const t of(0,o.compactBlanks)([(0,G.volsha)(e.uuid),(0,G.volsha)(e.mountpoint)]))s.set(t,e);const a=ce();for(const e of a)await(0,R.withLock_)({file:e,timeoutMs:_.ShortCommandTimeoutMs},(async()=>{for(const[t,i]of s.entries()){const n=e.join(t+".json");try{await n.writeJson_(i)}catch(e){ne().warn("writeVolumesToCache(): failed to write volumes cache",{error:e,output:n.nativePath,vol:i}),await n.unlink()}}}));ne().debug("writeVolumesToCache(): complete.",{dirs:a,vol_mountpoints:r.map((e=>e.mountpoint))}),i.resolve()}async function fe(){const e=await(0,t.cachedVolumes)();if((0,P.isWorkerService)()&&(0,o.isNotEmpty)(e))return e;const i=(0,v.toA)(await(0,Y.mountpoints)()),n=Date.now()-(0,p.clamp)(d.minuteMs,d.dayMs,q.Settings.volumeMetadataTtlMs.valueOrDefault),r=0!==q.Settings.volumeMetadataTtlMs.valueOrDefault&&e.some((e=>!(0,p.gt)(e.updatedAt,n))),s=!(0,o.eqlPrimitiveUnordered)(i,e.map((e=>e.mountpoint)));return ne().debug("priorVolumesIfMountpointsMatch()",{priorIsStale:r,priorIsMissingMountpoints:s}),r||s?void 0:e}async function me(e,i){const n=(0,m.map)(e,z.toNativePath_);if((0,u.blank)(n))return;const r=await(0,A.actualPath)(n);for(const e of[{name:"args",vols:i},{name:"cachedVolumes()",vols:t.cachedVolumes},{name:"volumes()",vols:t.volumes},{name:"allPriorVolumes()",vols:de}]){const t=await(0,y.tol)(e.vols);if((0,o.isEmpty)(t))continue;const i=(0,N.bestMountpointForDir)(r,t.map((e=>e.mountpoint)));if(null==i)continue;const n=t.find((e=>e.mountpoint===i));if(null!=n)return ne().trace("bestVolumeForPath()",{nativePath:r,result:n.mountpoint,src:e.name}),n}return ne().tap({msg:"bestVolume(): no volumes were applicable(!!)",result:void 0,meta:{nativePath:r}})}async function pe(e,t,i){const n=i.filter((e=>(0,E.equalsIgnoreCase)(t,e.remoteShare)));if((0,o.isEmpty)(n))return;const r=n.find((t=>(0,c.isTrue)(t.remote)&&(0,u.notBlank)(t.remoteHost)&&(0,E.equalsIgnoreCase)(e,t.remoteHost)));if(null!=r)return r;const s=await(0,W.friendlyname)(e);return(0,x.asyncFind)(n,(async e=>(0,E.equalsIgnoreCase)(s,await(0,W.friendlyname)(e.remoteHost))))}t.canWriteVolumesToCache=(0,a.lazy)((()=>(0,P.isSyncService)()||(0,b.isTest)())),t.priorWriteVolumesToCacheLatch=(0,a.lazy)((()=>{})),t.writeVolumesToCache=he,t.cachedVolumes=(0,a.lazy)((async()=>{const e=(0,o.compact)(await de()),t=(0,v.toA)(await(0,Y.mountpoints)()),i=e.filter((e=>t.includes(e.mountpoint))),n=(0,o.isNotEmpty)(i)?i:e.filter((e=>re===e?.os));return ne().tap({msg:"cachedVolumes()",level:"trace",result:n.filter((e=>!(0,c.isTrue)(e.ignorable))),meta:{currentMountpoints:t,withCurrentMountpoints:i.map((e=>e.mountpoint))}})}),d.minuteMs),t.priorVolumesIfMountpointsMatch=fe,t.volumes=(0,K.lazyFsAsync)("volumes",(async function(){try{const e=await(0,T.thenOrTimeoutError)({p:fe(),timeoutMs:(0,te.commandTimeoutMs)()});if(null!=e)return ne().debug("volumes(): returning prior-cached volumes"),e;const i=await(0,T.thenOrTimeoutError)({p:(0,t.volumesImpl)(),timeoutMs:(0,te.commandTimeoutMs)()});if((0,o.isNotEmpty)(i))return i}catch(e){(0,I.onError)((0,L.toWrappedError)("volumes() failed",{cause:e}))}return ne().debug("fallback: returning priorVolumes()"),(0,t.cachedVolumes)()})),t.volumesImpl=(0,M.shim0)({name:"fs.volumes",impl:async function(){if((0,b.isTest)()){const e=(0,p.toInt)((0,F.env)().PS_VOLUMES_HANG_MS);if((0,p.gt0)(e)&&(ne().warn("PS_VOLUMES_HANG_MS: delay for "+e),await(0,h.delay)(e,!1)),(0,C.getDevEnvFlag)("PS_FAIL_VOLUMES"))return void ne().throw("PS_FAIL_VOLUMES")}const e=await(0,T.thenOrTimeoutError)({p:U.isWin?(0,J.dfWin)():(0,$.dfPosix)(),timeoutMs:(0,te.mountpointsTtlMs)()});if(null==e)return void ne().warn("df failed");const t=q.Settings.validateMountpoints.valueOrDefault?(0,o.compact)(await(0,x.mapAsync)({name:"nonRpcVolumes: filter unhealthy volumes",arr:e,timeoutMs:(0,te.commandTimeoutMs)(),f:async e=>{try{if(await(0,j.isReadableDirectory)(e.mountpoint))return e;ne().info("validateMountpoints(): "+e.mountpoint+" is not a directory")}catch(t){ne().info("validateMountpoints(): failed to stat "+e.mountpoint,t)}}})):e;t.some((e=>!0===e.remote&&(0,u.blank)(e?.remoteHost)))&&await(0,T.thenOrTimeoutError)({p:U.isWin?(0,ee.addRemoteVolumeInfoWin)(t):(0,Q.addRemoteVolumeInfoPosix)(t),timeoutMs:10*d.secondMs}).catch((e=>{(0,I.onError)("Failed to get remote volume info",{error:e})}));const i=(U.isWin?t:U.isMac?await(0,X.addLocalVolumeInfoMac)(t):await(0,Z.addLocalVolumeInfoLinux)(t))??t;for(const e of i)e.updatedAt??(e.updatedAt=Date.now()),e.remote=(0,c.isTrue)(e.remote),(0,u.blank)(e.label)&&delete e.label,(0,u.mapNotBlank)(e.remoteHost,(t=>e.remoteHost=t.toLowerCase().normalize().trim()));await(0,ie.addVolumeUUIDs)(i);const n=(0,l.sortBy)(i,(e=>e.mountpoint));return ne().debug("_volumes(): final result",{sorted:n}),n.forEach(ue),await he(n),Object.freeze(n)}}),t.rootPath=(0,a.lazy)((()=>U.isWin?(0,g.opt)((0,O.getEnv)("SystemDrive")).filter(u.notBlank).orElse((()=>"C:")).map((e=>(0,E.ensureSuffix)(e,"\\"))).get():"/")),t.rootVolume=function(){return me((0,t.rootPath)())},t.bestMountpoint=function(e,t){return(0,u.blank)(e)||(0,o.isEmpty)(t)?void 0:(0,w.greatestBy)(t.filter((t=>(0,N.containedByNativePath)({ancestor:t,descendant:e,acceptSelf:!0}))),(t=>(0,o.commonPrefixLength)(e.split(s.default.sep),t.split(s.default.sep))))},t.bestVolumeForPath=me,t.bestVolumeForVolsha=async function(e){for(const i of[{name:"allPriorVolumes()",vols:de},{name:"volumes()",vols:t.volumes}]){const t=(0,v.toA)(await i.vols()).find((t=>(0,G.volsha)(t.uuid)===e));if(ne().debug("bestVolumeForVolsha(): "+i.name,{match:t}),null!=t)return t}},t.remoteVolumeFor=async function(e,i){return(0,x.thenMap)((0,t.volumes)(),(t=>pe(e,i,t)))},t.bestRemoteVolume=pe,t.findVolumeForVolsha=async function(e){if(!(0,u.blank)(e))return oe.get(e)??(await de())?.find((t=>(0,G.volsha)(t.uuid)===e))??(await(0,t.volumes)())?.find((t=>(0,G.volsha)(t.uuid)===e))}},68995:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeVolumeUuid=t.volumeUuidSubpath=void 0;const n=i(76760),r=i(19851),s=i(22573),a=i(50213),o=i(37805),l=i(16287),u=i(73428),c=i(17921),d=i(28874),h=(0,r.lazy)((()=>(0,a.mkLogger)("volumes.WriteVolumeUUID")));function f(){return(0,s.toNotBlank)(d.Settings.volumeUuidFilePaths.values[0])??".uuid"}t.volumeUuidSubpath=f,t.writeVolumeUuid=async function({mountpoint:e,uuid:t}){const i=(0,n.join)(e,f());t=(0,s.toNotBlank)(t)??(0,c.safeUUID)();const r=(0,n.dirname)(i);if(await(0,l.isReadWriteableDirectory)(r))try{return await(0,u.writeText_)(i,t,"","# This volume UUID was written by PhotoStructure v"+o.version,"# See https://photostructure.com/faq/what-is-a-volume/ for details."),h().info("writeVolumeUuid(): Saved new UUID for "+e,{uuid:t}),t}catch(t){h().warn("writeVolumeUuid(): Failed to save new UUID for "+e,{error:t})}else h().warn(`writeVolumeUuid(): cannot write to ${i}, directory is not read/write`)}},55111:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const n=i(50989);t.HelmetPlugins=(0,n.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},65713:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decuss=t.isCussy=t.getCuss=t.loadCuss=t.CussNativePath=void 0;const n=i(76760),r=i(19851),s=i(23838),a=i(81168),o=i(84542),l=i(43899),u=i(13047),c=i(31589);t.CussNativePath=(0,r.lazy)((()=>(0,n.join)(l.ProjectPath.Data(),"cuss.txt.br"))),t.loadCuss=(0,r.lazy)((async()=>{const e=(0,o.splitCompactLines)(await(0,u.zcat)((0,t.CussNativePath)()));d.set(f(e))}));const d=(0,r.lazy)((()=>({trie:new s.MultiMap,small:[]}))),h=3;function f(e){const t=new s.MultiMap,i=[];for(const n of e)n.lengthe.includes(t)));if(null!=t)return t;for(let t=0;tn.startsWith(e)));if(null!=r)return r}}}}function p(e){return null!=m(e)}t.getCuss=m,t.isCussy=p,t.decuss=function(e){let t=10,i="";do{i=e()}while(t-- >0&&p(i.replace(/[^a-z]/gi,"")));return i}},31589:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unl33t=t.l33t=void 0;const n=i(22573),r=i(96249),s=i(23838),a=i(59455),o=i(81168),l={a:["4","@","Д"],b:["8","6","Ъ"],c:["[","(","©"],e:["3","€"],f:["ƒ"],g:["9"],i:["1","!","|"],l:["1","£"],o:["0"],s:["5","$"],t:["7","+","†"],x:["×"],z:["2"]},u=s.MultiMap.fromJSON(l).inverse().toJSON();function c(e){if((0,n.blank)(e))return[""];const t=e.substring(0,1),i=[t,...(0,a.toA)(u[t])],s=c(e.substring(1));return(0,r.flatten)(s.map((e=>i.map((t=>t+e)))))}t.l33t=function(e){let t="";const i=l;for(const n of e)t+=i[n]?.[0]??n;return t},t.unl33t=function(e){return c((0,o.stripDiacritics)(e).normalize())}},30933:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const r=n(i(48161)),s=i(19851),a=i(42659),o=i(31586),l=i(50213),u=i(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>r.default.cpus()),5*a.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=r.default.availableParallelism?.(),i=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,o.clamp)(1,128,Math.ceil(e??i)),meta:{availableParallelism:e,cpuInfoLength:i}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const r=n(i(48161)),s=i(19851),a=i(31586),o=i(12168),l=i(50213),u=i(45879),c=i(70417),d=i(45969),h=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=r.default.freemem(),t=r.default.totalmem(),i=(2*e+t)/3;if((0,d.isDocker)()){const n=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,a.gt0)(n))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([n,i]),meta:{freemem:e,totalmem:t,cgroupMem:n}})}return h().tap({msg:"estimatedFreeMem() ",result:i,meta:{result:(0,o.fmtBytes)(i),freemem:(0,o.fmtBytes)(e),totalmem:(0,o.fmtBytes)(t)}})}))},15674:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const n=i(19851),r=i(42659),s=i(41400),a=i(31586),o=i(12168),l=i(50213),u=i(7282),c=i(34102),d=i(57902),h=i(28874),f=i(30933),m=i(58444),p=i(22751),g=(0,n.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,n.lazy)((()=>{const e=(0,a.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*o.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/o.MB),worstCaseMemPerProcMb:Math.ceil(e/o.MB)}})}),r.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,i=0===e||0===t?1:(0,a.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:i>1?d.LogLevels.warn:d.LogLevels.debug,result:i,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,a.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,f.cpuCount)())<=1},t.maxCpus=(0,n.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,f.cpuCount)())-1);let t=e;const i=p.timeoutRate.prior()?.eventsPerMinute??0,n=w();if(1!==n){const e=t;t*=n,g().warn("Recent timeouts! Throttling down.",{penalization:n,resultBeforePenalization:e,resultAfterPenalization:t})}const r=Math.min(e,v());return t=(0,a.clamp)(1,r,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:n,timeoutsPerSecond:i,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,n.lazy)((function(){return(0,a.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,a.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,a.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},22751:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const n=i(58587),r=i(87997),s=i(19851),a=i(42659),o=i(41400),l=i(50213),u=i(7282),c=i(45255),d=i(34102),h=i(976),f=i(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new n.Rate(5*a.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,s.lazy)((()=>(0,r.setInterval)(g,a.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,o.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},91863:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=n(i(1708)),s=i(98553),a=i(5670),o=i(59880),l=i(19913),u=i(71567),c=i(80061),d=i(17181),h=i(41944),f=i(28874),m=i(7014),p=i(16848);!async function(){r.default.argv.includes("--help")&&(console.log((0,c.cliWrapWithFooter)("This is PhotoStructure's background worker, and is for internal use only")),r.default.exit(0)),(r.default.argv.includes("--version")||r.default.argv.includes("-V"))&&(console.log((0,c.cliWrapVersion)()),r.default.exit(0)),(0,l.setServiceName)(a.ServiceNames.worker),(0,o.setShortProcessNames)(f.Settings.shortProcessNames.valueOrDefault),(0,o.setProcessTitle)(),(0,d.setupLogger)(),r.default.argv.includes("--volumes")&&(console.log((0,s.stringify)(await(0,m.volumes)())),r.default.exit(0)),h.onProgressEvt.setShim((async e=>{(0,u.stdoutWrite)(e,void 0)})),(0,p.handleWorkRequests)()}()},24817:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.handleWorkRequest_=t.isWorkRequest=t.mkWorkRequest=t.WorkRequestMethods=t.WorkerFunctions=t.AllWorkerFunctionCandidates=void 0;const n=i(98553),r=i(31586),s=i(68708),a=i(50989),o=i(32639),l=i(13991),u=i(50597),c=i(48368),d=i(52121),h=i(48604),f=i(181),m=i(66106),p=i(47783),g=i(83966);t.AllWorkerFunctionCandidates={_extractVideoFrame_:m._extractVideoFrame_,_readRawTags:p._readRawTags,_readTags:p._readTags,assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkerFunctions={assetFileMetadata_:l.assetFileMetadata_,buildAssetPreviews_:h.buildAssetPreviews_,imageHash_:c.imageHash_,ping:g.ping,prepFileForBrowser:d.prepFileForBrowser,whyInvalidFile:f.whyInvalidFile,shimmedFileSha_:u.shimmedFileSha_},t.WorkRequestMethods=(0,a.strEnum)(...(0,s.keys)(t.WorkerFunctions));let y=0;t.mkWorkRequest=function(e,t){return{id:++y,fn:e,args:t}},t.isWorkRequest=function(e){return"object"==typeof e&&t.WorkRequestMethods.has(e?.method)&&(0,r.isNumber)(e.id)},t.handleWorkRequest_=async function(e){const i=t.WorkerFunctions[e?.fn];if((0,o.isFunction)(i))return i(e?.args);throw new Error("invalid method "+(0,n.stringify)(e))}},16848:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.handleWorkRequests=void 0;const r=n(i(1708)),s=i(19851),a=i(50213),o=i(71567),l=i(33456),u=i(22573),c=i(26905),d=i(67478),h=i(54993),f=i(45608),m=i(55534),p=i(8769),g=i(57159),y=i(24817),v=(0,s.lazy)((()=>(0,a.mkLogger)("worker.Worker")));async function w(e){if(e=(0,h.toS)(e),(0,u.blank)(e))return;if(e.trim()===m.ServiceExitCommand)return(0,f.exit)({reason:e+" from stdin",status:0});const t=(0,d.parseJSON)(e);v().trace("onData",{request:t});try{const e=await(0,y.handleWorkRequest_)(t);(0,o.stdoutWrite)({id:t.id,response:e},!0)}catch(e){const i=(0,c.errorToJson)(e);v().warn("failed to process request",{request:t,error:i}),(0,o.stdoutWrite)({id:t.id,error:i},!1)}}t.handleWorkRequests=function(){!0!==r.default.stdin?.readable?(0,f.exit)({reason:"process.stdin is not readable",status:13}):(function(){for(const e of["SIGINT","SIGTERM"])r.default.on(e,(e=>(0,f.exit)({reason:e,status:0})))}(),function(){for(const e of["uncaughtException","uncaughtException","disconnect"])r.default.on(e,(e=>{const t=new g.WrappedError("uncaughtException",{cause:e});return(0,p.onError)(t)?(0,f.exit)({error:t,status:(0,c.errorErrno)(t)??1}):void 0}))}(),(0,f.exitOnStdStream)(),r.default.stdin.pipe(new l.LineReader).on("data",w),v().info("Child process mode: listening on stdin..."))}},83966:function(e,t,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ping=void 0;const r=n(i(1708)),s=i(41400),a=i(31586),o=i(7282),l=i(12089),u=i(45608),c=i(57159),d=i(89035);t.ping=(0,l.shim1)({name:"worker.ping",async impl(e){if((0,a.gt0)(e?.delay)&&await(0,s.delay)(e.delay),(0,o.isTest)()&&!0===e?.pretendMemUsageIsHigh&&d.memoryUsageIsHigh.set(!0),null!=e?.throw)throw new c.WrappedError(e.throw.message,e.throw);if((0,d.memoryUsageIsHigh)())throw(0,u.exit)({reason:"memory usage is high",status:1}),new c.WrappedError("Memory usage is high",{fatal:!0});return{pid:r.default.pid,input:e?.input??"(no input)"}}})},40958:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const n=i(76790),r=i(22573),s=i(50357),a=i(98553),o=i(49769),l=i(34666),u=i(30976),c=i(42279),d=i(32639),h=i(59455),f=i(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,i)=>e===t[i]))}function v(e,t){for(let i=0;i=e.length||i>=e.length)return e;const n=e[t];return e.splice(t,1),e.splice(i,0,n),e}function S(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const n of e)if(null!=n){const e=t(n);null!=e&&(0,o.getOrSet)(i,e,(()=>n))}return[...i.values()]}function P(e,t,i=1,n=(e=>e)){const r=[];if(et;s-=i)r.push(n(s));return r}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,i){return m(e)?t(e):(0,c.tot)(i)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let i=0;it.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const i of t)if(!e.includes(i))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const i=(0,n.sortBy)(e,g),r=(0,n.sortBy)(t,g);return i.every(((e,t)=>e===r[t]))},t.pushUniq=function(e,...t){for(const i of t)null==i||e.some((e=>(0,s.eql)(e,i)))||e.push(i);return e},t.pushUniqBy=function(e,t,i){const n=e.map(i);for(const r of t){const t=i(r);n.includes(t)||(e.push(r),n.push(t))}return e},t.insertAt=function(e,t,...i){return e.splice(t,0,...i),e},t.insertUniq=function(e,t,i){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let n=0;n0)return e.splice(n,0,t),e}return e.push(t),e},t.remove=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),i!==e.length},t.removeSame=function(e,...t){const i=e.length;return v(e,(e=>t.every((t=>e!==t)))),i!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(r.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,a.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const i of e)null==i||(0,s.eql)(t[t.length-1],i)||t.push(i);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const i=[];for(const e of(0,n.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))i.some((t=>t.includes(e)))||i.push(e);return(0,n.sortBy)(i,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,a.stringify)(e))){const i=new Map;for(const n of e)if(null!=n){const e=t(n);null!=e&&i.set(e,n)}return[...i.values()]},t.uniqBy2=function(e,t){const i=[];for(const n of e)null!=n&&i.every((e=>!t(n,e)))&&i.push(n);return i},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,i,n)=>e+(t(i,n)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,i,n)=>e+t(i,n)),0)},t.firstMatch=function(e,t){for(const i of S(t)){const t=e.exec(i);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let i=0;for(;e[i]===t[i];)i++;return i},t.anneal=function({array:e,expense:t,allowedDelta:i}){const n=Math.round(i);if(n<2)return e;for(let i=0;ie)){return P(e,t,1,i)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,a.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,i,n=t.primitiveValueOfOrElse){const r=new Set(i.map(n));return e.filter((e=>!r.has(n(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const n=i(40958),r=i(36783),s=i(41801),a=i(98553),o=i(49769),l=i(55835),u=i(34666),c=i(59455);function d(e,t){return(0,r.copyArrayTo)(f(e,t),e)}function h(e,t){const i=new Map;for(const n of e)(0,o.getOrSet)(i,(0,a.stringify)(t(n)),(()=>n));return f(i.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,i)=>({item:e,cmp:(0,l.map)(t(e,i),(e=>[e,i]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,n.compact)(e),n.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,r.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,i)=>0===i||t>=e[i-1]))},t.sortedBy=function(e,t){return e.every(((i,n)=>0===n||t(i)>=t(e[n-1])))},t.sortBy=f,t.deepSortBy=function e(t,i){return f(t,i).map((t=>(0,s.isIterable)(t)?e(t,i):t))},t.pushSorted=function(e,t,i){const n=e.findIndex((e=>i(t){Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const n=i(32639);t.asPromise=async function(e){const t=await e;return(0,n.isFunction)(t)?t():t}},75761:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.assetImgAttrs=t.assetSqImgAttrs=t.assetVideoLink=t.assetImgActualLink=t.assetImgLink=t.assetLinkAttrs=t.assetUrl=void 0;const n=i(58939),r=i(40958),s=i(22573),a=i(42659),o=i(11371),l=i(73722),u=i(31586),c=i(54993),d=i(29652),h=i(22403),f=i(2322);function m(e,t){return e+" "+t+"w"}function p(e,t){let i=null==t?void 0:(0,d.mergeURLSearchParams)(...t);const n=(0,c.toS)(e.v);return(0,s.blank)(n)||"1"===n||(i??(i=new URLSearchParams)).append("v",n),i}function g({assetId:e,params:t}){return null==e?"":(0,d.assembleFullPath)("/asset/"+(0,n.id2id)(e),p(e,t))}function y({assetId:e,reducer:t,width:i,params:r}){return(0,d.assembleFullPath)(`/img/${(0,n.id2id)(e)}/${t}/${(0,u.toGt0)(i)??320}`,p(e,r))}function v({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/img/${(0,r.compact)([(0,n.id2id)(e),t]).join("/")}/actual`,p(e,i))}function w({assetId:e,params:t,reducer:i,widths:r,lazyLoad:s,af:l}){if(null==(0,n.id2id)(e))return{src:"/images/clear-64.png"};0===(r=(r??[]).filter(u.gt0)).length&&r.push(320);const d=Math.min(...r),p={width:(0,c.toS)(d)},g=(0,a.fmtLocalToShort)(e.capturedAtLocal);null!=g&&(p.title=g);const w=y({assetId:e,params:t,reducer:i,width:d});s??(s=!0);const S=s&&(0,f.isSafari)((0,h.ua)());S?(p.src="/images/clear-64.png",p["data-src"]=w):p.src=w,(0,f.isSafari)((0,h.ua)())||(p.loading=s?"lazy":"eager"),i===o.ReducerNames.sq&&(p.height=(0,c.toS)(d));const b=r.map((n=>m(y({assetId:e,params:t,reducer:i,width:n}),n)));return null!=l&&b.push(m(v({assetId:e,params:t,assetFileId:l.assetFileId}),l.width)),p[(S?"data-":"")+"srcSet"]=b.join(","),p}t.assetUrl=g,t.assetLinkAttrs=function({assetId:e,params:t}){const i=g({assetId:e,params:t});return(0,s.blank)(i)?{}:{href:i}},t.assetImgLink=y,t.assetImgActualLink=v,t.assetVideoLink=function({assetId:e,assetFileId:t,params:i}){return(0,d.assembleFullPath)(`/video/${(0,n.id2id)(e)}-${t}`,p(e,i))},t.assetSqImgAttrs=function({assetId:e,params:t,lazyLoad:i,size:n="m"}){return{...w({assetId:e,params:t,reducer:"sq",widths:l.SqWidths,lazyLoad:i}),sizes:("s"===n?80:"m"===n?160:320)*(0,u.numericOr)(globalThis?.window?.devicePixelRatio,1)+"px"}},t.assetImgAttrs=w},5233:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const n=i(41400),r=i(31586),s=i(13538),a=i(41583);t.retryOnReject_=async function(e,t){const i=(0,r.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return i();const o=t.onRetryWaitUntil??(e=>(0,n.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await i()}catch(e){const i=(0,a.toErr)(e);if(!1===t.errorIsRetriable?.(i)||l>t.maxRetries)throw i;return l++,await o(l),u()}};return u()}},17586:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},82950:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.li=t.b=t.tt=t.md2html=void 0;const n=i(40958),r=i(22573),s=i(96249),a=i(55938),o=i(54993);t.md2html=function(e){let t=e.replace(/").replace(/^ *- (.*)$/gm,((e,t)=>"
  • "+t.trim()+"
  • "));return t=(0,a.replaceAllMatches)(t,/```([^`]+)```/g,(e=>`${e[1]}`)),t=(0,a.replaceAllMatches)(t,/\*\*([^*]+)\*\*/,(e=>`${e[1]}`)),t},t.tt=function(e){return(0,r.blank)(e)?"":"```"+(0,o.toS)(e)+"```"},t.b=function(e){return"**"+(0,o.toS)(e)+"**"},t.li=function(...e){return(0,n.compactBlankish)((0,s.flatten)(e)).map((e=>"- "+(0,o.toS)(e))).join("\n")}},22573:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const n=i(55835),r=i(42279),s=i(54993);function a(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function o(e){return!a(e)}function l(e,t){if(!1===e||null==e||""===e)return;const i=(0,s.toS)(e);return o(i)?t(i):void 0}t.blank=a,t.notBlank=o,t.notBlankToS=function(e){return o(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,r.tot)(t);const i=(0,s.toS)(e).trim();return i.length>0?i:(0,r.tot)(t)},t.notBlankAnd=function(e,t){return!a(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,i){return(0,n.orElse)(l(e,t),i)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{function i(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function n(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const i=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=i,t.toBoolean=function(e){return!!i(e)||!n(e)&&void 0},t.toNotBoolean=function(e){return!i(e)&&(!!n(e)||void 0)},t.boolToInt=function(e){return i(e)?1:0},t.isFalse=n,t.isDisabled=function(e){return n(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>i(e)))},t.and=function(e){return e.every((e=>i(e)))},t.maybeAnd=function(e){let t;for(const i of e){if(!1===i)return!1;!0===i&&(t=!0)}return t},t.mapBoolean=function(e,t){return i(e)?t(!0):n(e)?t(!1):void 0},t.mapTrue=function(e,t){return i(e)?t():void 0}},79666:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const n=i(98553);t.clone=function(e){return null==e?e:JSON.parse((0,n.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const n=i(40958),r=i(22573),s=i(30301),a=i(55835),o=i(31586),l=i(39926),u=i(51926),c=i(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,a.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const i=p(e)?e.getTime():(0,o.isNumber)(e)?e:Date.now();return Math.floor(i/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,i={includeMs:!0}){const n=Math.floor(e/t.hourMs);e-=n*t.hourMs;const r=Math.floor(e/t.minuteMs);e-=r*t.minuteMs;const s=Math.floor(e/t.secondMs),a=Math.floor(e-s*t.secondMs);return(0,l.pad2)(n)+":"+(0,l.pad2)(r)+":"+(0,l.pad2)(s)+(i.includeMs?"."+(0,l.pad3)(a):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const i=()=>{const e=t%100;return t=Math.floor(t/100),e},n=10*i(),r=i(),s=i(),a=i(),o=i(),l=i();return new Date(t,l-1,o,a,s,r,n)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,i="ago"){return e<1e3?"just now":(i=(0,r.blank)(i)?"":(0,u.ensurePrefix)(i," "),et.ms<=e)))){const s=Math.floor(e/n.ms);e-=s*n.ms,s>0&&(n.ms>=t.dayMs?i:r).push(s+n.s)}return e>0&&r.push((0,o.toFixedStr)(e/t.secondMs,3)+"S"),"P"+i.join("")+((0,n.isEmpty)(r)?"":"T"+r.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,a.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const n=i(38639),r=i(73872);function s(e,t,i){if(null==i||y(e)||y(t))return null;const n=i.get(e)?.get(t);return"boolean"==typeof n?n:null}function a(e,t,i,n){if(null==i||y(e)||y(t))return;let r=i.get(e);null!=r?r.set(t,n):(r=new WeakMap,r.set(t,n),i.set(e,r))}function o(e,t,i,n){if(null!=i?.comparator)return u(e,t,i,n);const r=l(e,t);return null!==r?r:u(e,t,i)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,i,n){i??(i={});const u=!1===i.memoize?void 0:i.memoize??(i.memoize=new WeakMap),d=i?.comparator,f=s(e,t,u);if(null!==f)return f;const m=s(t,e,u);if(null!==m)return m;if(d){const i=d(e,t,n);if(!1===i||!0===i)return a(e,t,u,i),i;const r=l(e,t);if(null!==r)return r}const y=r(e);if(y!==r(t))return a(e,t,u,!1),!1;a(e,t,u,!0);const v=function(e,t,i,n){switch(i){case"String":case"Number":case"Boolean":case"Date":return o(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],n);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,n);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,i){return c(h(e),h(t),i)}(e,t,n);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),n);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),n);case"Set":case"Map":return function(e,t,i){if(e.size!==t.size)return!1;if(0===e.size)return!0;const n=[],r=[];return e.forEach((function(e,t){n.push([e,t])})),t.forEach((function(e,t){r.push([e,t])})),c(n.sort(),r.sort(),i)}(e,t,n);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,n)}}(e,t,y,i);return a(e,t,u,v),v}function c(e,t,i){const n=e.length;if(n!==t.length)return!1;if(0===n)return!0;let r=-1;for(;++r{Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,i,n=!1;const r=function(){if(n){if(null!=i)throw i;return t}try{return n=!0,t=e()}catch(e){throw i=e,e}};return r.prior=()=>t,r.hasPrior=()=>n,r}},41400:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const n=i(42659),r=i(35556),s=i(31586),a=i(68708);function o(e,t=!0){return new Promise((i=>{if(e<=0)i();else{const s=setTimeout((()=>i()),Math.ceil(e+.5));e>n.secondMs&&t&&r.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return o(t).then((()=>t))},t.delay=o,t.later=function(e,t=1){const i=Math.max(1,Math.ceil(t)),s=r.isNode&&i<=1?setImmediate(e):setTimeout(e,i);return r.isBrowser||t<=n.secondMs?s:(0,a.maybeCall)(s,"unref")??s}},33374:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pixels=t.dmegapixels=t.isPortrait=t.maybeFlipInPlace=t.maybeDimSwap=t.dimSwap=t.dimToSize=t.fmtDim=t.dimGte=t.isCloseAspectRatio=t.isDimensions=void 0;const n=i(31586),r=i(21605),s=i(12168);function a(e){return{width:e.height,height:e.width}}function o(e){return((0,n.toGt0)(e?.width)??0)*((0,n.toGt0)(e?.height)??0)}t.isDimensions=function(e){return null!=e&&(0,n.gt0)(e.width)&&(0,n.gt0)(e.height)},t.isCloseAspectRatio=function(e,t,i=.05){return(0,n.gt0)(e)&&(0,n.gt0)(t)&&e>1==t>1&&Math.abs(e-t)<=Math.max(e,t)*i},t.dimGte=function(e,t){return e.width>=t.width&&e.height>=t.height},t.fmtDim=function(e,t=" "){return`${e.width}${t}×${t}${e.height}`},t.dimToSize=function(e){return(0,s.pixels2size)(e.width*e.height)},t.dimSwap=a,t.maybeDimSwap=function(e,t){return(0,r.swappableRotation)(t)?a(e):e},t.maybeFlipInPlace=function(e,t){(0,r.swappableRotation)(t)&&([e.width,e.height]=[e.height,e.width])},t.isPortrait=function(e){return e.width/e.height<1},t.dmegapixels=function(e){return(0,s.megapixels)(o(e))},t.pixels=o},50357:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const n=i(12487),r=i(68708),s=i(34666),a=i(32639);function o(e,t){return(0,n.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,a.isFunction)(e)&&(0,a.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=o,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,r.isObject)(e)||!(0,r.isObject)(t))return!1;for(const i of(0,r.keys)(e))if(!o(e[i],t[i]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,i){if(null==e||null==t)return e===t;if(null!=i){const n=d.get(i);if(null!=n)return n(e,t)??null}for(const i of c){const n=i(e,t);if(null!=n)return n}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const n=i(40958),r=i(22573),s=i(96249),a=i(31586),o=i(68708),l=i(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,r.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,a.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const i=[];for(const t of e)null!=t&&(t instanceof Error?i.push(u(t),c(t),t?.message):i.push((0,l.toS)(t)));return(0,n.uniq)((0,n.compactBlankish)((0,s.flatten)((0,n.compact)(i).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,r.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const i=(0,l.toS)(e).split("\n").filter((e=>!(0,r.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,n.isEmpty)(i)?["(missing stack)"]:i}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,r.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(r.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,o.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,o.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,o.assignFields)(new Error,(0,o.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},4188:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fitInside=void 0,t.fitInside=function(e,t){const i=e.width/e.height;if(i>=t.width/t.height){const e=t.width;return{width:e,height:Math.floor(e/i)}}{const e=t.height;return{width:Math.floor(e*i),height:e}}}},96249:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const n=i(59455);t.flatten=function(e,t=[]){for(const i of(0,n.toA)(e))if(null!=i)for(const e of(0,n.toA)(i))null!=e&&t.push(e);return t}},75240:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtDuration=void 0;const n=i(40958),r=i(42659),s=i(55835),a=i(31586),o=i(12168),l=[{ms:r.yearMs,s:"year",p:"years"},{ms:r.yearMs/12,s:"month",p:"months"},{ms:r.weekMs,s:"week",p:"weeks"},{ms:r.dayMs,s:"day",p:"days"},{ms:r.hourMs,s:"hour",p:"hours"},{ms:r.minuteMs,s:"minute",p:"minutes"},{ms:r.secondMs,s:"second",p:"seconds"}];t.fmtDuration=function e(t,i=2,r){if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t),i):"";const u=l.findIndex((e=>e.ms<=t));if(-1===u)return"";let c=t+(0,s.mapOr)(l[u+Math.max(2,i)-1],(e=>Math.round(.4*e.ms)),0);const d=(0,n.compact)(l.slice(u,u+i).map((e=>{if(!(e.ms>c)){const t=Math.floor(c/e.ms);return c-=t*e.ms,{i:t,s:(0,o.plur)(t,e.s,e.p)}}})));return(0,n.isEmpty)(d)?"":d.map((e=>e.s)).join(", ")+(0,s.mapOr)(r,(e=>" "+(1!==d[d.length-1].i?e.singular:e.plural)),"")}},57924:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const n=i(40958);function r(e,t){return null==(e=(0,n.uniq)((0,n.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=r,t.orList=function(e){return r(e,"or")},t.andList=function(e){return r(e,"and")}},50268:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.newHealthCheckSections=t.BaseHealthCheckSummary=t.isHealthCheckSummary=t.isHealthCheckResult=t.HealthCheckLevelDescription=t.healthCheckLevelToEmoji=t.HealthCheckLevelToEmoji=t.levelIsNotOK=t.HealthCheckLevels=t.HealthCheckSections=void 0;const n=i(22573),r=i(38639),s=i(68708),a=i(62220),o=i(50989);t.HealthCheckSections=(0,o.strEnum)("Summary","Library","System","Tools");const l={Summary:"bookmark-tabs",Library:"library",System:"computer",Tools:"wrench"};t.HealthCheckLevels=(0,o.strEnum)("error","no-library","pending","stop-sync","warn","ok","disabled");const u=[t.HealthCheckLevels.ok,t.HealthCheckLevels.disabled,t.HealthCheckLevels.pending];function c(e){return(0,s.isObject)(e)&&!(0,n.blank)(e.id)&&!(0,n.blank)(e.section)&&t.HealthCheckLevels.has(e.level)&&!(0,n.blank)(e.msg)}t.levelIsNotOK=function(e){return!u.includes(e)},t.HealthCheckLevelToEmoji={pending:"busy-dots","no-library":"new-yellow",ok:"green-check",warn:"warning","stop-sync":"pause",error:"error",disabled:"sleeping-face-desat"},t.healthCheckLevelToEmoji=function(e){return t.HealthCheckLevelToEmoji[e]},t.HealthCheckLevelDescription={pending:"Health checks are running...","no-library":"No library is open",ok:"OK",warn:"Warning","stop-sync":"Some health checks are preventing sync from running",error:"Some health checks failed: sync will not run",disabled:"Some health checks are disabled"},t.isHealthCheckResult=c,t.isHealthCheckSummary=function(e){return(0,s.isObject)(e)&&a.RunStates.has(e.state)&&(0,r.isBoolean)(e.settled)&&c(e)},t.BaseHealthCheckSummary={id:"summary",section:t.HealthCheckSections.Summary},t.newHealthCheckSections=function(){return t.HealthCheckSections.values.map((e=>({section:e,emoji:l[e],results:"Summary"===e?[{...t.BaseHealthCheckSummary,level:"pending",settled:!1,ts:Date.now(),msg:["⌚ Requesting health check results..."]}]:[]})))}},11371:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReducerNames=void 0;const n=i(50989);t.ReducerNames=(0,n.strEnum)("fit","sq")},73722:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const n=i(50989);t.FitSizes=(0,n.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,n.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const n=i(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,i){if((0,n.lt0)(t))return[...e].slice(t,i);const r=e[Symbol.iterator]();if((0,n.gt0)(t))for(let e=0;e{Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,i){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(i))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],i=[];return function e(n,r){if((0,isFunction_1.isFunction)(n))return;let s,a,o,l=toJSON(n);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(n===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let n=0;t.Latch=class{constructor(e=n++){this.id=e,this[i]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},i=Symbol.toStringTag},30301:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const n=i(40958),r=i(50357),s=i(31586),a=i(65812);t.lazy=function(e,t){let i,o;const l=[];function u(){return u.isStale()&&u.setResult(e()),o}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return i=Date.now(),async function(e,i){if((0,n.isEmpty)(l))return;const s=await e,o=await i;if(!(0,r.eql)(s,o))for(const e of l)e(o);null!=t&&t>0&&void 0!==o&&(0,a.setUnrefTimeout)((()=>u.vacuum()),t)}(o,e),o=e},u.isStale=function(){return null==i||(0,s.gt0)(t)&&i+t{Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,i){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const n=i();return null!=n&&e.set(t,n),n}},t.deleteIf=function(e,t){for(const[i,n]of e.entries())t(i,n)&&e.delete(i)}},55835:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const n=i(42279),r=i(54993);function s(e,t){return null==e?void 0:t(e)}function a(e,t,i){return null==e||null==t?void 0:i(e,t)}function o(e,t){return null!=e?e:(0,n.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=a,t.map3=function(e,t,i,n){return null==e||null==t||null==i?void 0:n(e,t,i)},t.orElse=o,t.mapOr=function(e,t,i){return null!=e?t(e):(0,n.tot)(i)},t.map2Or=function(e,t,i,n){return o(a(e,t,i),n)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,r.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const n=i(68708);class r extends Error{constructor(e,t){super(e),this.message=e,(0,n.assignFields)(this,t)}}t.MetaError=r},23838:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const n=i(40958),r=i(76790),s=i(50357),a=i(98553),o=i(49769),l=i(55835),u=i(51926),c=i(59455);class d{static fromJSON(e){const t=new d;for(const[i,n]of Object.entries(e))t.add(i,...n);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,n.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const i=(0,o.getOrSet)(this.store,e,(()=>[]));return i.push(...t),i}addUniq(e,...t){return(0,n.pushUniq)((0,o.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const i=this.store.get(e);if(null==i)return!1;{const n=i.filter((e=>!(0,s.eql)(e,t)));return 0===n.length?this.store.delete(e):this.store.set(e,n),i.length!==n.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,n.uniq)(t))){for(const t of this.keys()){const i=this.store.get(t),r=null==i?[]:e(t,i);(0,n.isEmpty)(r)?this.store.delete(t):this.store.set(t,r)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,n.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,i]of e.store.entries())i.length>0&&(yield[t,i])}()}tuples(){const e=this;return function*(){for(const[t,i]of e.store.entries())for(const e of(0,c.toA)(i))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[i,r]of this.store.entries()){const s=(0,n.findIndexes)(r,(t=>!e(i,t,r)));if(s.length>0){t=!0;for(const e of s.reverse())r.splice(e,1)}0===r.length&&this.store.delete(i)}return t}inverse(){const e=new d;for(const[t,i]of this.store.entries())for(const n of i)e.add(n,t);return e}findKeyByTuple(e){for(const[t,i]of this.tuples())if(e(t,i))return t}filterKeysByTuple(e){const t=[];for(const[i,n]of this.entries())n.some((t=>e(i,t)))&&t.push(i);return t}toJSON(){const e={};for(const[t,i]of this.entries())e[(0,u.isString)(t)?t:(0,a.stringify)(t)]=i;return e}}function h(e,t){const i=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>i.add(t,e))))),i}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const i=h(e,t);return(0,r.sortBy)((0,c.toA)(i.values()),(e=>t(e[0])))}},35556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const i=globalThis;t.isBrowser="object"==typeof i?.window&&"object"==typeof i?.document,t.isNode="string"==typeof i?.process?.versions?.node},31586:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const n=i(76790),r=i(22573),s=i(42279),a=i(54993);function o(e){return"number"==typeof e&&isFinite(e)}t.isNumber=o,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,a.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return o(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,a.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,i)=>o(t)&&o(i)&&e(t,i);function f(e,i,r){return!(null==r||!o(r))&&([e,i]=(0,n.sort)([e,i]),(0,t.lte)(e,r)&&(0,t.gte)(i,r))}function m(e){if(!o(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,r.blank)(e))return t.defaultValue;if(o(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return o(e)&&e>0}function S(e){return o(e)&&e>=0}function b(e,t){return o(e)?t(e):void 0}function P(e){return o(e)?e<0?-Math.round(-e):Math.round(e):0}function M(e,t){if(null==e)return 0;const i=Math.pow(10,t);return P(e*i)/i}function _(e,t,i){if(e>t||!o(e)||!o(t))throw new Error(`invalid clamp(${e}, ${t}, ${i})`);return o(i)?it?t:i:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return o(e)?e:t},t.diff=function(e,t){return o(e)&&o(t)?e-t:void 0},t.absdiff=function(e,t){return o(e)&&o(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,i=.95){if(!o(e)||!o(t))return!1;if(e===t)return!0;if(i>=1)return!1;const n=(0===t?1e-5:t)*(1-i);return f(t-n,t+n,e)},t.within=f,t.max_=function(...e){let t;for(const i of e)o(i)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return o(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return o(e)&&o(t)&&e>t?e:void 0},t.lte0=function(e){return o(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const i=y(e);return null==i?void 0:t(i)},t.mapFloat=function(e,t){const i=v(e);return null==i?void 0:t(i)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,i){return b(e,(e=>b(t,(t=>i(e,t)))))},t.mapNumericOr=function(e,t,i){return o(e)?t(e):i},t.numericOr=function(e,t){return o(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d\.\d+)0+$/,"")},t.toPrecision=M,t.toPrecisionMaybe=function(e,t){return d(e,(e=>M(e,t)))},t.sigFigs=function(e,t){if(!o(e)||0===e||0===t)return 0;const i=t-P(Math.ceil(Math.log10(Math.abs(e)))),n=Math.pow(10,Math.abs(i));return i<0?P(e/n)*n:P(e*n)/n},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=_,t.times=function(e,t){if(!w(e))return[];const i=Math.round(e);return i<=0?[]:[...Array(i)].map(((e,i)=>t(i)))},t.pct=function(e,t){return _(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const i=Math.round(e??-1);return null==t||f(0,t,i)?i+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const i of e){if(!o(i))return;t+=i}return t}},68708:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const n=i(40958),r=i(76790),s=i(22573),a=i(32639),o=i(55835),l=i(31586),u=i(34666),c=i(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const i of e)if(null!=i&&Array.isArray(i)){const[e,n]=i;null!=e&&void 0!==n&&("object"!=typeof t&&(t={}),t[e]=n)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const i=t.filter((([,e])=>null!=e));return(0,n.isEmpty)(i)?void 0:y(i)}function w(e,t,i={}){return y((0,n.compact)((0,r.sort)(h(e)).map((i=>t(i,e[i])))).filter((([e,t])=>null!=e&&void 0!==t)),i)}function S(...e){const t=(0,n.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const i=t.filter(d);if(t.length!==i.length)return t;const r={};for(const e of(0,n.uniq)((0,n.flatMap)(i,h)))r[e]=S(...i.map((t=>t[e])));return r}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const i=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(i.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const i=v(e);return m(i)?t(i):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,i){if(null==t)return e;for(const[n,r]of g(t))!0!==i?.omitKeys?.includes(n)&&(null==r&&!0!==i?.assignNullish||(e[n]=r));return e},t.assignUndefinedFields=function(e,t,...i){if(null==t)return e;for(const n of i){const i=t[n];void 0!==i&&void 0===e[n]&&(e[n]=i)}return e},t.assignAllFields=function(e,t){for(const[i,n]of g(t??{}))e[i]=n;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const i=t.filter((([,e])=>void 0!==e));return(0,n.isEmpty)(i)?void 0:y(i)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,n.compact)(t.map(e));{const i=(0,n.compact)(g(t).map((([t,i])=>(0,o.map)(e(i),(e=>[t,e])))));return 0===i.length?void 0:y(i)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,n.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const i={};for(const n of t)void 0!==e[n]&&(i[n]=e[n]);return i},t.pickCompact=function(e,...t){if(null==e)return;const i={};for(const n of t)void 0!==e[n]&&(i[n]=e[n]);return i},t.pickNonBlank=function(e,...t){if(null==e)return e;const i={};for(const n of t){const t=e[n];(0,s.notBlank)(t)&&(i[n]=t)}return i},t.pickFirst=function(e,t,i=o.defined){if(null!=e)for(const n of t)if(i(e[n]))return e[n]},t.pickDeep=function e(t,...i){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...i)));const n={};function r(e,t){if(null==t)return;const i=n[e];n[e]=null==i?t:S(i,t)}for(const n of i){const[i,a]=(0,c.splitFirst)(n,"."),o=b(t,i);null!=o?.value&&r(o.key,(0,s.blank)(a)?o.value:e(o.value,a))}for(const n of h(t))((0,l.toInt)(n)??-1)>=0&&r(n,e(t[n],...i));return n},t.pluck=b,t.pluckDeep=function e(t,i){if(null==t||(0,s.blank)(i))return;if(Array.isArray(t)){const r=(0,n.compact)(t.map((t=>e(t,i))));return(0,n.isEmpty)(r)?void 0:{key:r[0].key,value:(0,n.flatMap)(r,(e=>e.value))}}const[r,a]=(0,c.splitFirst)(i,"."),o=b(t,r);if(null==o)return;if((0,s.blank)(a))return o;const l=e(o.value,a);return null==l?void 0:{key:o.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const i=g(e).filter((([e])=>!t.includes(e)));return(0,n.isEmpty)(i)?void 0:y(i)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,i])=>t(e,i))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,n.uniq)(t)},t.maybeCall=function(e,t,...i){const n=e?.[t];return(0,a.isFunction)(n)?n.bind(e)(...i):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const i=t.toLowerCase().normalize();for(const t of h(e))if(i===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const i=w(t,((t,i)=>[t,e(i)])),n=p(i);return 1===n.length?n[0]:i}},97790:(e,t)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(i||(i={})),t.None=i;class n{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new n(e(this.a))}flatMap(e){const t=e(this.a);return r(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,i){return s(e).flatMap((e=>s(t).flatMap((t=>i(this.a,e,t)))))}zip3(e,t,i,n){return s(e).flatMap((e=>s(t).flatMap((t=>s(i).flatMap((i=>n(this.a,e,t,i)))))))}}function r(e){return e instanceof n||e===t.None}function s(e){return r(e)?e:null!=e?new n(e):t.None}t.Some=n,t.isOpt=r,t.opt=s},39926:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const n=i(31586),r=i(54993),s={};function a(e,t){if(t<1)return"";if(!(0,n.gte)(s[e]?.length,t)){let i=s[e]??e;for(;i.length{Object.defineProperty(t,"__esModule",{value:!0}),t.parseJSON=void 0;var n=i(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return n.parseJSON}})},46891:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const n=i(22573),r=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,a=/[^aeiou]y$/,o=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,n.blank)(e))return e;const t=r.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(a)?e.replace(/y$/i,"ies"):null!=e.match(o)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const n=i(40958),r=i(54993),s=["number","string","boolean"];function a(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=a,t.mapPrimitive=function(e,t){return a(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,i){return a(e)?t(e):i()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(a)};const o=["boolean","number","bigint","symbol","string","object","function"];function l(e,i){if(null==e&&null==i)return 0;if(null==e)return-1;if(null==i)return 1;const n=typeof e,s=typeof i;if(!("string"!==n&&"symbol"!==n||"string"!==s&&"symbol"!==s)){const n=(0,r.toS)(e),s=(0,r.toS)(i),a=n.localeCompare(s);return n[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-a:a}return Array.isArray(e)&&Array.isArray(i)?u(e,i):n!==s?o.indexOf(n)-o.indexOf(s):e>i?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const n=i(59455);function r(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const i=await e;return null==i?void 0:t(i)},t.thenCollect=async function(e,t){const i=[];for(const r of(0,n.toA)(await e))if(null!=r){const e=await r;if(null!=e){const n=await t(e);null!=n&&i.push(n)}}return i},t.thenTap=async function(e,t=console.dir.bind(console)){const i=await e;return await t(i),i},t.isPromiseLike=r,t.isPromise=function(e){return r(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:i}){const n=await e;return t(n)?i(n):void 0}},57153:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const n=i(50989);t.PromiseStates=(0,n.strEnum)("pending","resolved","rejected")},30976:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const n=i(40958),r=i(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function a(e,t,i){return null==i||0===i.length?s(e,t):o(e,t,1,i)[0]}function o(e,t,i,n){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const r=t-e,a=new Set(n??[]);if(t===e&&0===r&&0===a.size&&1===i)return[e];const o=r-a.size;if(i>o)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:r,size:i,slotsRemaining:o})}`);const l=new Set;for(;l.size0;e--){const i=Math.floor(Math.random()*(e+1));e!==i&&([t[e],t[i]]=[t[i],t[e]])}return t},t.sample=function(e,t){const i=[];for(const n of o(0,e.length,t))i.push(e[n]);return i},t.pickWeightedRandom=function(e){if((0,n.isEmpty)(e))return;const t=e.filter((e=>(0,r.gt0)(e.priority)));let i=l(0,(0,n.sum)(t,(e=>e.priority)));return t.find((e=>(i-=e.priority,i<=0)))}},55938:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.replaceAllMatches=void 0,t.replaceAllMatches=function(e,t,i){let n=e;t.global||(t=new RegExp(t,"g"));let r=null;for(;null!=(r=t.exec(e));)r.index===t.lastIndex&&t.lastIndex++,n=n.slice(0,r.index)+i(r)+n.slice(r.index+r[0].length);return n}},21605:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.swappableRotation=t.normalizeRotation=t.isRotation=t.Rotations=void 0;const n=i(31586);function r(e){if(!(0,n.isNumber)(e))return;const t=90*Math.round(e/90)%360;return t<=0?(t+360)%360:t}t.Rotations=[0,90,270,180],t.isRotation=function(e){return(0,n.isNumber)(e)&&t.Rotations.includes(e)},t.normalizeRotation=r,t.swappableRotation=function(e){const t=r(e);return 90===t||270===t}},62220:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RunStates=void 0;const n=i(50989);t.RunStates=(0,n.strEnum)("loading","welcome","ready","failed")},5670:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const n=i(50989);t.ServiceNames=(0,n.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const i=e.indexOf(t);return-1===i?[e]:[e.slice(0,i),e.slice(i+t.length)]}},50989:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const n=i(68708),r=i(42279);t.strEnum=function(...e){const t=Object.freeze(e),i=(0,n.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const a=e=>null!=e?i[e]:void 0,o=e=>null!=a(e);return{...s,values:t,length:t.length,has:o,includes:o,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:a,ordinal:e=>a(e)??t.length,validOrElse:(e,t)=>o(e)?e:(0,r.tot)(t),mapValid:(e,t)=>o(e)?t(e):void 0,cmp:(e,t)=>{const i=a(e),n=a(t);return null==i||null==n?void 0:i>n?1:i{const i=a(e);return null==i?void 0:t[i]}}}},51926:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const n=i(40958),r=i(17586),s=i(22573),a=i(96249),o=i(41801),l=i(31586),u=i(59455),c=i(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,i){if(d(e))return t<0&&(t+=e.length),e.slice(t,i);{const n=f();return null!=n?(0,o.sliceIterable)(n.segment(e),t,i).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,i).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const i=(0,c.toS)(e),n=(0,c.toS)(t);return n.length>0&&i.startsWith(n)?i.slice(n.length):i}function y(e,t){if(null==t)return e;const i=(0,c.toS)(e),n=(0,c.toS)(t);return n.length>0&&i.endsWith(n)?i.slice(0,-n.length):i}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,i){null==i&&(i=e.length);for(let n=i;n>=0;n--)if(m(e,n).startsWith(t))return n;return-1}function b(e,t,{normalize:i=!0}={}){if(null==e||null==t)return!1;const n=(0,c.toS)(e),r=(0,c.toS)(t);return n.length===r.length&&(n===r||n.toLowerCase()===r.toLowerCase()||"function"==typeof n.localeCompare&&0===(i?n.normalize():n).localeCompare(i?r.normalize():r,void 0,{sensitivity:"base"}))}function P(e,t){return(0,n.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,r.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,o.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,i){return d(e)?e.slice(t,null==i?void 0:t+i):m(e,t,null==i?void 0:t+i)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,i){if(null==t)return"";const n=(0,c.toS)(t);for(const t of i)if(null!=t&&t.length>0&&n.startsWith(t))return e(n.slice(t.length),i);return n},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:i}){return y(g(e,t),i)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:i}){return w(v(e,t),i)},t.ellipsize=function(e,t=80,i=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),i=(0,l.clamp)(0,t-1,(0,l.round)(i));const n=p(e);return n.length<=t?n.join(""):n.slice(0,t-1-i).join("")+"…"+(i>0?n.slice(-i).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,i){const n=i?.maxLineLen??80,r=i?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const n=(0,a.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,a.flatten)(n.map((t=>e(t,i))))}if((t=v((0,c.toS)(t),r).trim()).length<=n)return[t];const s=S(t," ",n);if(s>r.length)return[m(t,0,s),...e(m(t,s+1),i)];{const n=t.indexOf(" ",r.length+1);return n>0&&n{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const n=i(42659),r=i(68708),s=i(42279),a=i(83104),o=i(85556);async function l(e,t,i=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(i,n)=>{let r=!0;const s=setTimeout((()=>{r&&(r=!1,i(a.Timeout))}),t);try{s.unref?.();const t=await e;r&&(r=!1,i(t))}catch(e){r&&(r=!1,n(e))}finally{clearTimeout(s)}}))}async function u(e,t,i=!0){const r=await l(e,t,i);if(r===a.Timeout)throw new o.TimeoutError("timeout ("+(0,n.fmtHMS)(t)+")");return r}t.toNotTimeout=function(e){return e===a.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,i=!0){const n=t-Date.now();return n<=0?a.Timeout:l(e,n,i)},t.thenOrOnTimeout=async function(e,t,i){return t<=0?e:new Promise((async(n,s)=>{let a=!0;try{const o=setTimeout((async()=>{if(a){a=!1;try{n(await i())}catch(e){s(e)}}}),t);(0,r.maybeCall)(o,"unref");const l=await e;a&&(a=!1,clearTimeout(o),n(l))}catch(e){a&&(a=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,i=!0){const r=t-Date.now();if(r<=0)throw new o.TimeoutError("timeout ("+(0,n.fmtHMS)(r)+")");return u(e,r,i)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:i,unref:n=!0}){const r=await l(e,t,n);return r===a.Timeout?(0,s.tot)(i):r}},42279:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const n=i(32639);t.tot=function(e){return(0,n.isFunction)(e)?e():e},t.tol=async function(e){return(0,n.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class i extends Error{}t.TimeoutError=i},89937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PS_EXAMPLES_SCHEME=t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME=t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME=t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME=void 0,t.PS_LIBRARY_SCHEME="pslib",t.PS_LIBRARY_PROTOCOL=t.PS_LIBRARY_SCHEME+":",t.PS_LOCAL_FILE_SCHEME="psfile",t.PS_LOCAL_FILE_PROTOCOL=t.PS_LOCAL_FILE_SCHEME+":",t.PS_NETWORK_FILESYSTEM_SCHEME="psnet",t.PS_NETWORK_FILESYSTEM_PROTOCOL=t.PS_NETWORK_FILESYSTEM_SCHEME+":",t.PS_EXAMPLES_SCHEME="examples"},29652:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addQueryToFullpath=t.assembleFullPath=t.mergeURLSearchParams=t.toURLSearchParams=t.isURLSearchParams=void 0;const n=i(40958),r=i(22573),s=i(54993);function a(e){return"URLSearchParams"===e?.constructor?.name}function o(e){return null==e?void 0:a(e)?e:new URLSearchParams(e)}function l(...e){const t=(0,n.compact)(e.map(o)),i=t.shift();if(null!=i){for(const e of t)for(const[t,n]of e.entries())i.set(t,n);return i}}t.isURLSearchParams=a,t.toURLSearchParams=o,t.mergeURLSearchParams=l,t.assembleFullPath=function(e,...t){const i=(0,s.toS)(l(...t));return e+((0,r.blank)(i)?"":"?"+i)},t.addQueryToFullpath=function(e,...t){const i=(0,s.toS)(l(...t));return(0,r.blank)(i)?e:e+(e.includes("?")?"&":"?")+i}},12168:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const n=i(22573),r=i(30301),s=i(31586),a=i(46891),o=i(50989),l=i(51926),u=(0,r.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,r.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,r.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let i=0;for(const n of e)(0,s.isNumber)(n)&&(i+=n/t.MB);return(0,s.round)(i)},t.fmt=c,t.fmtToInt=function(e){return(0,n.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const i=Math.floor(Math.log10(e)),n=Math.floor(i/3),r=Math.pow(10,3*n),a=d[n];return(0,s.sigFigs)(e/r,t)+" "+a}t.fmtMB=function(e,i=3){return f(e*t.MB,i)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const i=Math.floor(Math.log2(e)),n=Math.floor(i/10),r=Math.pow(2,10*n),a=h[n];return(0,s.sigFigs)(e/r,t)+" "+a},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,o.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,i){return null==e?"":(0,n.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(i??(0,a.pluralize)(t)).trim())},t.plurMetric=function(e,t,i){return i??(i=(0,a.pluralize)(t)),{count:c(e),desc:1===e?t:i}}},459:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnreachableCaseError=void 0;class i extends Error{constructor(e){super(`Unreachable case: ${e}`),this.name="UnreachableCaseError"}}t.UnreachableCaseError=i},65812:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const n=i(68708);t.setUnrefTimeout=function(e,t){const i=setTimeout(e,t);return(0,n.maybeCall)(i,"unref")??i}},22403:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ua=void 0;const n=i(30301),r=i(54993);t.ua=(0,n.lazy)((()=>(0,r.toS)(globalThis?.navigator?.userAgent)))},2322:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isIphone=t.isIpad=t.isFirefox=t.isSafari=t.isChrome=void 0;const i=/\bChrome\b/,n=/\bSafari\b/,r=/\bFirefox\b/,s=/\biPad\b/,a=/\biPhone\b/;function o(e,t){return null!=e&&null!=String(e).match(t)}function l(e){return o(e,i)}function u(e){return o(e,r)}t.isChrome=l,t.isSafari=function(e){return o(e,n)&&!l(e)&&!u(e)},t.isFirefox=u,t.isIpad=function(e){return o(e,s)},t.isIphone=function(e){return o(e,a)}},58939:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.idEql=t.id2id=void 0;const n=i(55835),r=i(31586);function s(e){const t=e;return(0,r.isNumber)(e)?e:(0,r.isNumber)(t.id)?t.id:(0,r.isNumber)(t.assetId)?t.assetId:(0,r.isNumber)(t.tagId)?t.tagId:void 0}t.id2id=s,t.idEql=function(e,t){return(0,n.map2Or)(s(e),s(t),((e,t)=>e===t),(()=>!1))}},23541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const n=i(41801),r=i(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,r.isString)(e)?[e]:(0,n.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const n=i(40958),r=i(23541),s=i(59455),a=i(54993);function o(e){return null==e?void 0:(0,r.isError)(e)?e:new Error((0,a.toS)(e))}t.toErr=o,t.toErrs=function(...e){return(0,n.compact)((0,s.toA)(e).map(o))}},54993:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const n=i(98553);t.toS=function(e){return s(e,",")};const r={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==r?e.toString():(0,n.stringify)(e)}}t.toStr=s},23227:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),i(91863)},90858:e=>{e.exports=require("@iarna/toml")},53705:e=>{e.exports=require("@photostructure/tz-lookup")},58587:e=>{e.exports=require("batch-cluster")},36507:e=>{e.exports=require("croner")},66261:e=>{e.exports=require("events")},77988:e=>{e.exports=require("exiftool-vendored")},66150:e=>{e.exports=require("fast-xml-parser")},68817:e=>{e.exports=require("file-type")},44652:e=>{e.exports=require("fs-extra")},28787:e=>{e.exports=require("he")},51168:e=>{e.exports=require("luxon")},93973:e=>{e.exports=require("ml-kmeans")},83058:e=>{e.exports=require("picomatch")},57272:e=>{e.exports=require("plist")},85949:e=>{e.exports=require("process")},90595:e=>{e.exports=require("punycode")},38064:e=>{e.exports=require("semver")},9288:e=>{e.exports=require("sharp")},73872:e=>{e.exports=require("type-detect")},92460:e=>{e.exports=require("util")},31421:e=>{e.exports=require("node:child_process")},77598:e=>{e.exports=require("node:crypto")},40610:e=>{e.exports=require("node:dns")},78474:e=>{e.exports=require("node:events")},73024:e=>{e.exports=require("node:fs")},51455:e=>{e.exports=require("node:fs/promises")},77030:e=>{e.exports=require("node:net")},48161:e=>{e.exports=require("node:os")},76760:e=>{e.exports=require("node:path")},53916:e=>{e.exports=require("node:path/posix")},1708:e=>{e.exports=require("node:process")},57075:e=>{e.exports=require("node:stream")},46466:e=>{e.exports=require("node:stream/promises")},87997:e=>{e.exports=require("node:timers")},57975:e=>{e.exports=require("node:util")},38522:e=>{e.exports=require("node:zlib")},16928:e=>{e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(i.exports,i,i.exports,__webpack_require__),i.loaded=!0,i.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var __webpack_exports__=__webpack_require__(__webpack_require__.s=23227);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/data/migrations/models/20240307_rebuild_progress_nofk.sql b/data/migrations/models/20240307_rebuild_progress_nofk.sql new file mode 100644 index 0000000..aea4b7d --- /dev/null +++ b/data/migrations/models/20240307_rebuild_progress_nofk.sql @@ -0,0 +1,57 @@ +CREATE TABLE Progress_new ( + -- records sync process state + id INTEGER NOT NULL PRIMARY KEY, + uri TEXT NOT NULL, + hostname TEXT NOT NULL, + pid INTEGER NOT NULL, + volume TEXT NOT NULL, + state TEXT, + hed TEXT, + dekJSON TEXT, + completePct REAL, + incompletePct REAL, + scanningPct REAL, + createdAt INTEGER NOT NULL, + updatedAt INTEGER NOT NULL, + completedAt INTEGER +) STRICT; + +INSERT INTO + Progress_new ( + id, + uri, + hostname, + pid, + volume, + state, + hed, + dekJSON, + completePct, + incompletePct, + scanningPct, + createdAt, + updatedAt, + completedAt + ) +SELECT + id, + uri, + hostname, + pid, + volume, + state, + hed, + dekJSON, + completePct, + incompletePct, + scanningPct, + createdAt, + updatedAt, + completedAt +FROM + Progress; + +DROP TABLE Progress; + +ALTER TABLE Progress_new +RENAME TO Progress; diff --git a/defaults.env b/defaults.env index f6a0cfa..7a018d7 100644 --- a/defaults.env +++ b/defaults.env @@ -1797,14 +1797,15 @@ # PS_DB_MAINTENANCE_TIMEOUT_MS or dbMaintenanceTimeoutMs # ------------------------------------------------------ # -# How long is a reasonable time to wait for the library database to vacuum, -# quick check, validate foreign keys, or validate the schema? +# How long is a reasonable time to wait for the library database to apply a +# migration, vacuum, quick check, validate foreign keys, or validate the +# schema? # -# Note that the default of 1 minute is very generous--these operations should -# only take a second or two unless your library is very large and/or your disk -# is very slow. +# Note that the default of 2 minutes should be very generous--these operations +# should only take a second or two unless your library is very large and/or +# your disk is very slow. # -# PS_DB_MAINTENANCE_TIMEOUT_MS="1m" +# PS_DB_MAINTENANCE_TIMEOUT_MS="2m" # ---------------------------------------- diff --git a/package.json b/package.json index 852f6dc..edf2380 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "photostructure", "productName": "PhotoStructure", "author": "PhotoStructure, Inc. ", - "version": "2024.3.0-prealpha", + "version": "2024.3.1-prealpha", "license": "SEE LICENSE IN LICENSE.md", "description": "PhotoStructure for Servers", "homepage": "https://photostructure.com/server/photostructure-for-node/", diff --git a/photostructure b/photostructure index 651b206..2642899 100755 --- a/photostructure +++ b/photostructure @@ -6,4 +6,4 @@ * IF YOU DO NOT ACCEPT THESE TERMS, DO NOT USE THIS SOFTWARE */ -(()=>{"use strict";var __webpack_modules__={37975:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const i=r(22573),n=r(38639),s=r(44198);function o(){return(0,n.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,i.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=o;let a=!o();function l(){return a}function u(e,t){return function(r){return l()?`[${e}m${r}[${t}m`:r}}t.setColorEnabled=function(e){a=e??!o()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const i=r(19851),n=r(7282),s=r(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,i.lazy)((()=>t.SimpleAppName+((0,n.isProd)()?"":`-${(0,n.nodeEnv)()}`))),t.AppNameVersion=(0,i.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const i=r(40958),n=r(36783),s=r(76790),o=r(22573),a=r(50357),l=r(98553),u=r(55835),c=r(31586),d=r(68708),h=r(34666),f=r(59455),m=r(84885);var p=r(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,r=i.primitiveValueOfOrElse){const n=new Set(t.map(r));return e.filter((e=>n.has(r(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],r=e.lastIndexOf(t);return[{t,count:r+1},...v(e.slice(r+1))]}function w(...e){const t=[],r=Math.max(...e.map((e=>e?.length??0)));for(let i=0;ie?.[i])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function E(e,t){return(0,i.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,r){return C(e,t,r).index}function C(e,t,r){if((0,i.isEmpty)(e))return{index:-1,value:void 0};let n,s=-1;for(let i=0;ie.slice(r,r+t)))}async function x(e,t){return(0,i.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,a.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(o.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const r of(0,f.toA)(e))if(null!=r&&!0===await t(r))return r},t.findLastAsync=async function(e,t){for(let r=(e=(0,f.toA)(e)).length-1;r>=0;r--){const i=e[r];if(null!=i&&!0===await t(i))return i}},t.first=function(e,t){if(null!=e)for(const r of(0,f.toA)(e))if(null!=r){const e=t(r);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null!=i){const e=await t(i,r);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,i.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,r){for(let i=r;i<=e.length-1;i++)if(t(e[i]))return i},t.findLast=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return e[r]},t.findLastIndex=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1},t.concat=function(...e){const t=[];for(const r of e)if(Array.isArray(r))for(const e of r)null!=e&&t.push(e);else null!=r&&t.push(r);return t},t.moveToEnd=function(e,t){return(0,i.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const r=e[t];if(null==r)return e;e.push(r);for(let r=t;r(0,a.eql)(e,t)))},t.removeFirst=function(e,t){const r=e.findIndex(t);return r>=0?e.splice(r,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,n.copyArrayTo)((0,i.uniqBy)(e,t),e)},t.partition=function(e,t){const r=[],i=[];let n=0;for(const s of e)(t(s,n++)?r:i).push(s);return[r,i]},t.isUniq=function(e){return e.every(((t,r)=>e.indexOf(t)===r))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,i.compact)((0,i.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),r=[];return(0,c.times)(t,(t=>e.map((e=>r.push(e?.[t]))))),r},t.unFlatZip=function(e,t){const r=e.length/t;if(r!==Math.round(r))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const i=(0,c.times)(t,(()=>new Array(r)));for(let n=0;ne.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=E,t.least=function(e){return E(e,(e=>e))},t.greatestBy=function(e,t){return(0,i.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const r=C(e??[],t,h.lt);return null==e||null==r||r.index<0||null==r.value?void 0:{result:e[r.index],index:r.index,value:r.value}},t.reverse=function(e){const t=[];for(let r=e.length-1;r>=0;r--)t.push(e[r]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=T,t.collectBatched=function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(r(s)));return n},t.collectBatchedAsync=async function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(await r(s)));return n},t.contextFilter=function(e,t){let r;return e.filter(((e,i)=>(0,d.tap)(t(e,i,r),(t=>{t&&(r=e)}))))},t.clusterSome=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.some((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterEvery=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.every((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterAsync=async function(e,t){const r=[];e:for(const i of e){for(const e of r)if(null!=i&&await x(e,(e=>t(i,e)))){e.push(i);continue e}null!=i&&r.push([i])}return r},t.someAsync=async function(e,t){if(null!=e)for(let r=0;r=0&&!0===(0,u.map)(e[i],(e=>r(e,i))))return i}{const i=t+n;if(ie+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,r){return e.lengthr))),e}},36557:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const a=r(77988),l=o(r(1708)),u=r(19851),c=r(42659),d=r(55835),h=r(31586),f=r(85556),m=r(54993),p=r(50213),g=r(79089),y=r(45255),v=r(25764),w=r(38836),S=r(99331),b=r(95937),P=r(98314),_=r(38835),E=r(70025),M=r(8769),C=r(43334),T=r(95402),x=r(28874),D=r(63870);class k extends w.EndableWrapper{constructor(e,t,r=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,i,"m",n).call(this)),r,"worker"===e?(0,D.commandTimeoutMs)():y.ShortCommandTimeoutMs),i.add(this),this.t=t;const o=t;o.on("childStart",(async r=>{null!=r.pid?(this.logger.info("Started child process",{pid:r.pid}),(0,g.renice)(r.pid).catch((e=>this.onError("renice failed",e))),(0,T.addPid)({pid:r.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),o.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),o.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),o.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),o.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),o.on("noTaskData",((e,r,i)=>{const n=t.options.streamFlushMillis;n{this.logger.error("observeBatchCluster.endError()",e)})),o.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&T.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof a.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,E.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=k,i=new WeakSet,n=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(C.isWin?3:1)*c.minuteMs,maxTasksPerProcess:x.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:x.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:x.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:x.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:x.Settings.taskTimeoutMs.valueOrDefault}}},89788:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=r(92460),d=r(31586);class h{constructor(e){if(i.add(this),this.maxLength=e,n.set(this,void 0),s.set(this,0),o.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,n,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,i=new WeakSet,a=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,o,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,n,"f")[t]))}()}push(...e){var t,r;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,n,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,i,"m",a).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,n,"f")[e]}))}unshift(...e){var t,r;for(const c of e.reverse())u(this,s,"f"){u(this,n,"f")[e]=c,l(this,o,e,"f")}));return u(this,s,"f")}shift(){return u(this,i,"m",a).call(this,0,(e=>{var t,r;return l(this,o,(t=u(this,o,"f"),++t),"f"),l(this,s,(r=u(this,s,"f"),--r),"f"),u(this,n,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,i,"m",a).call(this,u(this,s,"f")-1-e,(e=>{const r=u(this,n,"f")[e];u(this,n,"f")[e]=u(this,n,"f")[t],u(this,n,"f")[t]=r}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const i=r(54993),n=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:r}of n)if(o(e,t))return e.subarray(t.length).toString(r);return e.toString()}function o(e,t){return t.every(((t,r)=>e[r]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,i.toS)(e)},t.bufferStartsWith=o},9092:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,r]of e)this.set(t,r)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const r=this.normalizer(e);return null!=e&&null!=r&&this.store.set(r,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=n},36638:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=n},40583:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const o=r(40958),a=r(23838),l=s(r(68708)),u=r(59455),c=r(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new a.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const r of(0,o.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(r,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const r=this.lookup(e);if(null!=r)return r;let i,n=-1;for(const[r,s]of this.m.entries()){const o=(0,c.diceCoeff)(r,e);if(o>t&&o>n){const e=this.getFirst(s);null!=e&&(i=e,n=o)}}return i}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),r=this.m.get(t);if(null!=r){for(const e of r)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const i=r(76790),n=r(31586),s=r(68708),o=r(54993),a=r(82647),l=r(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const r=this.get(e)+t;return 0===r?this.m.delete(e):this.m.set(e,r),r}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new a.Average(0);for(const t of this.keys()){if(!(0,n.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,r]of this.m.entries())e[(0,o.toS)(t)]=r;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,i.sortBy)([...this.entries()],(([t,r])=>[-r,(0,n.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new a.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,r]of(0,i.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,r);return e}addAll(e){for(const[t,r]of e.entries())this.incr(t,r);return this}get toS(){return(0,i.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let r=0;for(const[i,n]of this.m.entries()){const s=e(i);t.fill(s,r,r+n),r+=n}return t}}t.CountingSet=u},79840:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const i=r(19851),n=r(72993),s=r(45969),o=r(43334);t.EditionType=(0,i.lazy)((()=>o.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,i.lazy)((()=>n.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const i=r(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),r=t-this.ts;this.ts=t,(0,i.map)(this.listener,(t=>t(e,r))),r>2&&this.l.log(r>500?"warn":r>100?"info":"debug",e,{elapsedMs:r})}},t.elapsed=function(e){const t=Date.now(),r=e();return{elapsedMs:Date.now()-t,result:r}},t.thenElapsed=async function(e){const t=Date.now(),r=await e;return{elapsedMs:Date.now()-t,result:r}}},23467:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const i=r(50357),n=r(55835),s=r(68708);var o=r(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return o.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,i.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,i.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,n.map2Or)(await e,await t,i.eql,(()=>!1))},t.eqlPicked=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))},t.eqlOmit=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.omit)(e,...r),(0,s.omit)(t,...r))},t.eqlAsyncPicked=async function(e,t,...r){return(0,n.map2Or)(await e,await t,((e,t)=>(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))),(()=>!1))}},62344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(31586),a=r(54993),l=r(77377),u=r(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,o.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,o.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,n.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const r of this.expireListeners)r(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[i.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const r of this.expireListeners)r(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,n.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const r of this.expireListeners)r(e,t)}const r=this.priorCache[e];if(void 0!==r&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,r)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const r=this.currentCache[t]??this.priorCache[t];null!=r&&e(t,r)}}deleteIf(e){for(const t of this.keys()){const r=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=r&&e(t,r)&&this.delete(t)}}get(e){return e=(0,a.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,a.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,a.toS)(e),this.has(e))return this.get(e);const r=t();return this.set(e,r),r}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,o.isNumber)(e.__uid)&&(0,o.isNumber)(e.__start)}},80049:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=r(31586),d=r(85556),h=r(54993),f=r(54557),m=r(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,i.set(this,0),n.set(this,0),s.set(this,0),o.set(this,0),a.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,i,l(this,i,"f")+e.cacheHitsSync,"f"),u(this,n,l(this,n,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,o,l(this,o,"f")+e.rejections,"f"),u(this,a,l(this,a,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,i,"f"),cacheHitsAsync:l(this,n,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,o,"f"),timeouts:l(this,a,"f")}}has(e){return this.cache.has(e)}get_(e){var t,r,o,a;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,n,(r=l(this,n,"f"),++r),"f"),c.promise):(u(this,i,(o=l(this,i,"f"),++o),"f"),c.value)}if(c instanceof Error)throw c;return u(this,i,(a=l(this,i,"f"),++a),"f"),c}get(e){var t,r;const n=this.cache.get(e);return null==n||n instanceof m.Deferred&&n.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,i,(r=l(this,i,"f"),++r),"f"),n instanceof m.Deferred?n.value:n}clear(){this.cache.clear(),u(this,i,0,"f"),u(this,n,0,"f"),u(this,s,0,"f"),u(this,o,0,"f"),u(this,a,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const r=this.get(e);if(null!=r){if(r instanceof Error)throw r;return r}return this.set(e,t())}getOrSetAsync(e,t){const r=(0,h.toS)(e);{const e=this.get_(r);if(null!=e)return e instanceof m.Deferred?e.promise:e}const i=new m.Deferred(this.opts.name).observe(t());return this.cache.set(r,i),(0,c.gt0)(this.opts.timeoutMs)&&i.setTimeout(this.opts.timeoutMs),i.promise.then((e=>{this.set(r,e)}),(e=>{var t,i;this.cache.set(r,e),u(this,o,(t=l(this,o,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,a,(i=l(this,a,"f"),++i),"f")})),i.promise}},i=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap},54127:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class i{constructor(e){this.maxSize=e,this[r]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(r=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=i},53507:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(31586),a=r(68708),l=r(50213),u=r(68852),c=r(81168),d=r(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,i.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,r=!0){return new m(e,t,r).entries};class m{constructor(e,t,r=!0){this.warnIfMissingHeaders=r,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const i=(0,o.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,n.range)(0,i).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,a.fromEntries)(e))).filter((e=>(0,a.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let r=e;r!==t;t>e?r++:r--)if(this.blankColumns.has(r))return r;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),r=[];let i,a=0;for(;null!=(i=t.exec(this.headerRow));){const l=this.headerRow.substring(a,i.index);(0,s.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:i.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(i.index,t.lastIndex),d=i.index+((0,c.indexOfNonSpace)(u)??0),h=i.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:i,left:d,right:h});else{const e=(0,n.last)(r);if(r.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,o.max_)(e?.rightIdx,i.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}a=t.lastIndex}const l=(0,n.last)(r);return null!=l&&((0,s.blank)(this.headerRow.slice(a))?l.rightIdx=(0,o.max_)(...this.rows.map((e=>e.length))):l.rightIdx=a),r}}t.Fixed=m},73913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const i=r(51455),n=r(98553);var s=r(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const r=(0,n.parseJSON)(e);return null==r?void 0:t(r)},t.readJson_=async function(e){return(0,n.parseJSON)((await(0,i.readFile)(e)).toString())}},19851:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const o=r(57975),a=r(40958),l=r(50357),u=r(31586),c=r(65812),d=r(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),i.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,i,"m",n).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,a.isEmpty)(this.watchers))return;const r=await e,i=await t;if(!(0,l.eql)(r,i))for(const e of this.watchers)e(i);null!=this.ttlMs&&this.ttlMs>0&&void 0!==i&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(42659),a=r(50213),l=r(81168),u=r(5916),c=r(56519),d=r(84777),h=r(44198),f=r(6012),m=r(43334),p=r(24399),g=r(63870);t.DefaultLocale="en";const y=(0,i.lazy)((()=>(0,a.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?E():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,i.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const r=w.exec(e.trim())?.groups;return null==r?void 0:(0,n.compact)([r.lang,r.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const _={timeoutMs:10*o.secondMs};async function E(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return b(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=E,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},50213:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const i=r(19851),n=r(32105),s=r(14593);t.rootLoggers=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));const o=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,o)}},9103:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const i=r(98553),n=r(54557);t.memoize=function(e,t){let r=0;const s=new n.FifoCache(t.maxSize,t.ttlMs),o=t=>{if(null!=t)return r++,s.getOrSet((0,i.stringify)(t),(()=>e(t)))};return o.clear=e=>null==e?s.clear():s.delete((0,i.stringify)(e)),o.size=()=>s.size,o.callCount=()=>r,o}},7282:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const n=i(r(1708)),s=r(38639),o=r(54993),a=r(19851),l=r(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,a.lazy)((()=>n.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,o.toS)(n.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return n.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(n.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){n.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(55835),a=r(31586),l=r(39926),u=r(54993),c=r(20014);var d=r(31586);function h(e,t){return(0,a.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(a.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,a.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,r){return(0,o.orElse)(h(e,t),r)},t.mapGte0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>=0?t(r):void 0},t.mapGt0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>0?t(r):void 0},t.mapGt0=function(e,t){const r=(0,a.toInt)(e);return null!=r&&r>0?t(r):void 0},t.map2Gt0=function(e,t,r){const i=(0,a.toInt)(e),n=(0,a.toInt)(t);return null!=i&&i>0&&null!=n&&n>0?r(i,n):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,a.isNumber)(e))return e;if((0,n.blank)(e))return;const t=String(e);return(0,o.map)(f.exec(t),(e=>(0,a.toFloat)(t.substr(e.index))))}function p(e){return(0,a.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const r=[e,t].map((e=>e.toString(2))),i=Math.max(...r.map((e=>e.length)));return r.map((e=>(0,l.leftPad)(e,i,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let r=0;for(let i=0;ie/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,r){this.store[e*this.columns+t]=r}},t.hammingDistanceBigInt=function(e,t){return(0,o.map)(g(e,t),(([e,t])=>(0,i.count)([...e],((e,r)=>e!==t.charAt(r)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,o.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,i.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,r){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let i=0;const n=r*e.length;for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const i=r(40958),n=r(42659),s=r(96249),o=r(55835),a=r(31586),l=r(68708),u=r(34666),c=r(41583),d=r(48884),h=r(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,n.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const r={};for(const[i,n]of(0,l.entries)(e)){const e=t(i,n);null!=e&&(r[i]=e)}return r}t.definedThunks=function(...e){return e.every((e=>(0,o.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const r of e){const e=r();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(o.defined)},t.firstDefinedField=function(e,...t){return(0,o.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(r=>t(r,e[r])?e[r]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,r){if(null!=e)return t(e);throw new Error(r)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,o.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,i.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[r,i]of m(t))null==e[r]&&(e[r]=i);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[r,i]of(0,l.entries)(t))null==e[r]&&(e[r]=i);return e},t.pickMap=function(e,t,r){const i={};for(const n of t)i[n]=r(n,e[n]);return i},t.mapEntries=p,t.mapNullEntries=function(e,t,r){const i={};let n=0;for(const s of(0,l.keys)(e))if(i[s]=t(s,e[s]),n++,(0,a.gt)(n,r))break;return i},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const r={};for(const i of(0,h.sortIgnoreCase)((0,l.keys)(t)))r[i]=e(t[i]);return r}return t},t.deepDelete=function e(t,...r){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...r))):p(t,((t,i)=>r.includes(t)?void 0:e(i,...r)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const r of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[r])return e[r]}},t.pairToObject=function(e,t){const r={};return r[e]=t,r},t.zipPojos=function(...e){const t={};for(const r of(0,i.uniq)((0,s.flatten)(e.map(l.keys))))t[r]=e.map((e=>e?.[r]));return t}},12801:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const n=i(r(48161)),s=r(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:n.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:n.default.constants.priority.PRIORITY_NORMAL,BelowNormal:n.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:n.default.constants.priority.PRIORITY_LOW,Low:n.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const i=r(41400),n=r(56409),s=r(31586),o=r(22911),a=r(73614),l=r(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:r,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...i){f=!0,m=Date.now()+(0,s.max_)(t,r);const n=d=new o.Deferred(c);(0,s.gt0)(r)&&n.setTimeout(r);try{n.resolve(await e(...i))}catch(e){n.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,a.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return n.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,i.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new n.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const i=r(68708),n=r(54993);function s(e){return e instanceof o?e.source:(0,n.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const r=[];if(!e.global)throw new Error("must provide global regex");let n;for(;null!=(n=e.exec(t));)n.index===e.lastIndex?e.lastIndex++:r.push((0,i.pick)(n,"index","groups"));return r},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,r){const i=[];for(const t of e)try{i.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{i.push(s(t))}const n=0===i.length?t.NothingRegExp:i.map((e=>"(?:"+e+")")).join("|");return new RegExp(n,r)};class o{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=o;class a extends o{static from(...e){const t=l(e);return new a("(?:"+t.source+")?",t.flags)}}function l(e,t){let r="",i=t?.includes("g")??!1,a=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof o||t instanceof RegExp?(r+=t.source,i||(i=t.global),a||(a=t.ignoreCase),l||(l=t.multiline)):r+=s((0,n.toS)(t));return new RegExp(r,t??(i?"g":"")+(a?"i":"")+(l?"m":""))}t.RegExpOptional=a,t.concatRegexp=l},79089:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const n=i(r(48161)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(42659),u=r(41400),c=r(96249),d=r(31586),h=r(51926),f=r(54993),m=r(50213),p=r(12801),g=r(22277),y=r(84777),v=r(34102),w=r(43334),S=r(24399),b=r(28874),P=(0,o.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,o.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,a.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let E=!0;const M=(0,o.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const r=(0,p.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[r]),E)try{return n.default.setPriority(e,t),t}catch(r){const i=-13===r?.errno||"EACCES"===r?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:i,error:r}),i)return;E=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,r):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[r]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+r),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const n=i(r(1708)),s=r(19851),o=r(40958),a=r(5670),l=r(54993),u=r(7282),c=r(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===a.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===a.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===a.ServiceNames.sync}function p(){return(0,t.serviceName)()===a.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,o.compactBlanks)([t.serviceName.prior(),(0,l.toS)(n.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return a.ServiceNames.indexOf(e)??a.ServiceNames.length+1},t.MainServices=[a.ServiceNames.main,a.ServiceNames.desktop],t.DbServices=[a.ServiceNames.sync,a.ServiceNames.info,a.ServiceNames.web,a.ServiceNames.list,a.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[a.ServiceNames.sync,a.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===a.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===a.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,s.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const i=r(59455);function n(e){return e instanceof Set?e:new Set((0,i.toA)(e))}t.asSet=n,t.setEql=function(e,t){return(0,i.toA)(e.keys()).every((e=>t.has(e)))&&(0,i.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,r){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),r())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const r=n(t);return new Set([...e].filter((e=>r.has(e))))},t.diff=function(e,t){const r=n(t);return new Set([...e].filter((e=>!r.has(e))))}},12089:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=r(98553),d=r(34666),h=r(54993),f=r(62344),m=r(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,r,o){super(),i.add(this),this.impl=t,this.cache=r,this.toKey=o,n.set(this,void 0),s.set(this,void 0),l(this,n,e,"f")}async _call(e){return null==this.cache?u(this,i,"m",a).call(this,e):this.cache().getOrSetAsync(u(this,i,"m",o).call(this,e),(()=>u(this,i,"m",a).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,i,"m",o).call(this,e))}}n=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},a=function(e){return(0,m.time)(u(this,n,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const i=r(42659);t.ShortCommandTimeoutMs=7*i.secondMs},92322:function(e,t,r){var i,n=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=r(76790),o=r(17586);class a{constructor(e,t){this.valueOf=e,this.diff=t,i.set(this,[])}[(i=new WeakMap,Symbol.iterator)](){return n(this,i,"f")[Symbol.iterator]()}get length(){return n(this,i,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,r=n(this,i,"f").length-1;for(;t<=r;){const s=t+Math.floor((r-t)/2),o=this.valueOf(n(this,i,"f")[s]);if(e===o)return{found:!0,index:s};e>o?t=s+1:r=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&n(this,i,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:r}){if(t>=this.length)return[...n(this,i,"f")];const o=t=>t<0||t>n(this,i,"f").length-1?null:(r??this.diff)(n(this,i,"f")[t],e),a=this.findIndex(e);if(null==a)return;let l=a.index-1,u=o(l),c=a.index,d=o(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return n(this,i,"f").shift()}at(e){return(0,o.at)(n(this,i,"f"),e)}toA(){return[...n(this,i,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===n(this,i,"f").length-1){const e=[...n(this,i,"f")];return n(this,i,"f").length=0,e}return n(this,i,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return n(this,i,"f").splice(e,t)}retainLastN(e){return e{Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},82328:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const i=r(1708),n=r(95705);t.stdoutEnded=function(){return(0,n.streamEnded)(i.stdout)}},71567:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const n=i(r(1708)),s=r(22573),o=r(98553),a=r(23560),l=r(82328),u=r(38835),c=r(70025),d=r(95705);function h(e,t){return f({obj:e,ready:t,stream:n.default.stdout})}function f({obj:e,ready:r,stream:i}){if(null==i||(0,d.streamEnded)(i))return;const n=(0,o.stringify)(e,void 0,(0,a.isInfoService)()||(0,a.isMainService)()?2:void 0);i.write(n+"\n"),(0,a.isWorkerService)()&&null!=r&&(n.includes(u.FailStr)||(0,c.isFatalError)(n)||(0,c.isHealthCheckError)(n)?i.write(u.FailStr+"\n"):i.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||n.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:n.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const r of e)r.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(55835),a=r(31586),l=r(39926),u=r(34666),c=r(51926),d=r(59455),h=r(54993),f=r(48884),m=r(68852),p=r(38835);var g=r(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=r(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=r(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,r){if(0===r.length)throw new Error("rightPad() given empty pad");const i=String(e);return i+(0,l.padding)(r,t-i.length)},t.padReplace=function(e,t,r,i){return(0,c.strslice)(e,0,t)+(0,l.padding)(i,r)+(0,c.strslice)(e,t+r)},t.contains=function(e,t,r){return(0,h.toS)(e).indexOf((0,h.toS)(t),r)>-1},t.countChars=function e(t,r,i=0){if(null==r||0===r.length)return 0;const n=t.indexOf(r,i);return-1===n?0:1+e(t,r,n+r.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,r){const i=Math.min(Math.ceil(e.length/t),r??e.length)-1;return i<=0?[e]:[...(0,a.times)(i,(r=>e.slice(r*t,(r+1)*t))),e.slice(i*t)]},t.spliceCapture=function(e,t){const r=t.exec(e);if(null==r||null==r[1])return;const i=r[0].indexOf(r[1])+r.index;return{captured:r[1],uncaptured:e.substring(0,i)+e.substring(i+r[1].length),unmatched:e.substring(0,r.index)+e.substring(r.index+r[0].length),matchedIndex:i}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,r={}){if(null==t)return e;const i=(0,h.toS)(e),n=(0,h.toS)(t);return n.length>0&&(0,c.equalsIgnoreCase)(i.slice(-n.length),n,r)?i.slice(0,-n.length):i},t.gist=function(e,t=80,r=80){const i=(0,h.toS)(e),n=i.length-(t+r);return n<=0?i:i.slice(0,t).trim()+" …(+"+n+" chars)…"+i.slice(-r).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const r=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===r?e.localeCompare(t):r}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,i.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,o.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const r=S(e.cmp[0],t.cmp[0]);return 0!==r?r:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,i.isEmpty)(e)||(0,s.blank)(t))return;for(const r of e)if((0,c.equalsIgnoreCase)(r,t))return{index:0,match:r};for(const r of e){const e=t.indexOf(r);if(e>=0)return{index:e,match:r}}const r=t.normalize();for(const t of e){{const e=r.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=r.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=r.toLowerCase(),i=e.toLowerCase(),n=t.indexOf(i);if(n>=0)return{index:n,match:i}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function E(e){return _.reduce(((e,[t,r])=>e.replace(t,r)),e).normalize()}t.dumbquote=E;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(E(e))&&(e=e.slice(1,-1).trim())),e};const C=/^['‘’].*['‘’]$/,T=/^["“”„«»〃].*["“”„«»〃]$/;function x(e,t){const r=D(e,t);return(0,f.flatZip)(r.nonSeparators,r.separators).filter((e=>null!=e&&e.length>0))}function D(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const r=[],i=[];let n,s=0;for(;null!=(n=t.exec(e));)n.index===t.lastIndex?t.lastIndex++:(t.lastIndex=n[0].length+n.index,r.push(e.substring(s,n.index)),i.push(e.substring(n.index,t.lastIndex)),s=t.lastIndex);return s(0,a.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),C.test(e)||T.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const r=(0,i.compactBlanks)(e),n=Math.max(...r.map((e=>e.length)));for(let e=0;e(0,o.map)(r[e],(e=>t+=e))));return t},t.splitKeep=x,t.splitUp=D,t.sortNaturalBy=k,t.sortNatural=function(e){return(0,n.sortBy)(e,(e=>k(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,i.compactBlanks)(e)),r=t.filter(((e,r)=>!P(t[r+1],e)));return(0,n.sortBy)(r,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const r=Math.min(e.length,t.length);for(let i=0;i4===e?.length?(0,a.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const O=/#.*$/gm;t.stripComments=function(e){return e.replace(O,"")},t.uniqPath=function(e,t=":"){const r=new Set;for(const i of(0,d.toA)(e))if(null!=i&&!(0,s.blank)(i))for(const e of i.split(t))(0,s.blank)(e)||r.add(e);return[...r].join(t)},t.dedupeNeedle=function(e,t,r){if((0,s.blank)(t))return e;const i=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),n=e.findIndex((e=>i.test(e))),o=new RegExp("("+(0,m.escapeRegExp)(r)+"[,:\\s]*){2,}","gim");if(n<0)return e;for(let t=n+1;te.trim()))))}},83556:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const i=r(54993);function n(e){return(0,i.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>"_"+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>" "+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=n,t.asObjectKey=function(e){return n(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const n=i(r(77598)),s=r(73913),o=r(55222);function a(e,t=s.HashBits){return n.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,r=o.Radix58,i=224){return r.encodeBuffer(a(e,i)).substring(0,t)}t.stringShaToBuffer=a,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,r=o.GeoRadix,i=224){return l(e,t,r,i)}},94863:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const i=r(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,i.toS)(e).toLowerCase().normalize()}},96859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(31586),a=r(39926),l=r(51926),u=r(54993),c=r(55222),d=r(97352),h=r(88158),f=r(77377),m=r(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const r=new d.Array2D(e.length);let i=0,n="";for(let s=0;s=i&&(i=r.get(s,o),n=(0,l.substr)(e,s-i+1,i)));return n}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const r=y(e,t);if(null!=r)return r;const i=e.normalize(),n=t.normalize();return e!==i||t!==n?y(i,n):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,r,i)=>r===t.charAt(i)?e:e+1),0)}function v(e,t){const r=e.toUpperCase().normalize(),i=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>r===i?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(r),t=w(i);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,r)=>e+t[r+1]))}function S(e,t){const r=(0,f.intersection)(e,t),n=[];return r.forEach((r=>{const s=Math.min((0,i.count)(e,(e=>e===r)),(0,i.count)(t,(e=>e===r)));(0,o.times)(s,(()=>n.push(r)))})),n}function b(e,t,r){const n=(0,i.commonPrefixLength)(e,t);return r((0,l.strslice)(e,n))-r((0,l.strslice)(t,n))}function P(e){const t=(0,i.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,n.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[r,i]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(r,i,(e=>(0,o.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=_;const E=/[^\da-z]+/gi;function M(e,t){const[r,i]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(E,"").toLowerCase()));return b(r,i,(e=>c.RadixAlphaNum.decode(e)))}function C(e,t){let r;for(let i=Math.max(e.length,t.length);i>=0;i--){const n=(0,o.mapNumericOr)(e.charCodeAt(i),(e=>e),256),s=(0,o.mapNumericOr)(t.charCodeAt(i),(e=>e),256),a=(0,o.clamp)(-256,256,n-s);r=null==r?a:(r+a)/2}return r}t.radixDiff=M,t.str=function(e,t){return{pref:(0,i.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,i.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=C,t.paddedPositionalDiff=function(e,t,r=8){return C((0,a.leftPad)(e,r," "),(0,a.leftPad)(t,r," "))}},84885:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const i=r(98553),n=r(88158);t.stringifySorted=function(e){return(0,i.stringify)((0,n.sortedKeys)(e))}},22277:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=r(73614);class u{constructor(e,t=!1){i.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[o]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return a(this,i,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>a(this,i,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const r=this.delegate.get(e);return null==r||a(this,i,"m",n).call(this,e,r)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,r]of this.delegate)a(this,i,"m",n).call(this,t,r)||e(t,t,this)}has(e){return null!=e&&!a(this,i,"m",n).call(this,e)}values(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield[t,t])}()}toA(){return a(this,i,"m",s).call(this),[...this.delegate.keys()]}[(i=new WeakSet,o=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,n=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const r=t<=Date.now()-this.ttlMs;if(r){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return r},s=function(){for(const[e,t]of this.delegate)a(this,i,"m",n).call(this,e,t)}},94174:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(38639),c=r(31586),d=r(50213),h=r(45255),f=r(84777),m=r(96706),p=r(43334),g=r(24399),y=(0,o.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,o.lazy)((()=>(0,a.uniq)([s.default.geteuid?.(),s.default.getuid?.(),n.default.userInfo().uid]))),t.userid=(0,o.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,o.lazy)((()=>(0,a.uniq)([s.default.getegid?.(),s.default.getgid?.(),n.default.userInfo().gid]))),t.groupid=(0,o.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,o.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,o.lazy)((()=>(0,l.toNotBlank)(n.default.userInfo()?.username))),t.userNameFromWhoami=(0,o.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,o.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,o.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,o.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.0-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=0,t.versionPrerelease=["prealpha"],t.release="2024.3.0-prealpha+20240308102353",t.gitSha="92cba1b21937cb9ca770f6a339e44b0fbee04bf9",t.gitDate=new Date(1709922233e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const i=r(42659),n=r(55835),s=r(31586),o=r(97790),a=r(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const r=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,n.allDefined)(r))return;const[o,a,u,c,d,h,f]=r,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(o,a-1,u,c,d,h,f/1e3)-m*i.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,o.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,a.within)(0,Date.now()+i.dayMs,e))).map((e=>new Date(e))).get()}},73568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class r extends Error{}t.AbortError=r},76740:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const a=r(45599),l=r(56409),u=r(73568);t.Abortable=class{constructor(){this._aborted=!1,i.set(this,void 0),n.set(this,(0,a.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,n,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,n,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,n,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),o(this,i,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,i,"f")&&clearTimeout(s(this,i,"f")),o(this,i,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},i=new WeakMap,n=new WeakMap},22911:function(e,t,r){var i,n,s,o,a,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(r(87997)),w=y(r(57975)),S=r(45599),b=r(26905),P=r(55835),_=r(31586),E=r(68708),M=r(20214),C=r(57153),T=r(85556),x=r(50213),D=r(70025),k=r(95937),O="TIMEOUT",I=(0,S.defer)((()=>(0,x.mkLogger)("async.Deferred")));class F{static async*toAsyncIterable(e,t){const r=[...e].reverse(),i=(0,_.gt0)(t)?new n(O).setTimeout(t):void 0;for(null!=i&&r.push(i);;){for(let i=r.length-1;i>=0;i--){const n=r[i];if(n.isSettled){if(n.name===O)return void I().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});r.splice(i,1),yield n.value}}if(r.every((e=>e.name===O)))break;try{await Promise.race(r)}catch{}}i?.clearTimeout()}static resolve(e,t){return new n(".resolved()",t).resolve(e)}constructor(e,t){var r,m,y;i.add(this),this.name=e,this.startedAt=Date.now(),o.set(this,void 0),a.set(this,C.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(r=n,n,(y=p(r,n,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,x.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof n&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,a,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,E.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,o,"f")}get elapsedMs(){return(p(this,o,"f")??Date.now())-this.startedAt}get[(o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,i=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new T.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,k.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,a,"f")===C.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,a,"f")!==C.PromiseStates.pending}get isResolved(){return p(this,a,"f")===C.PromiseStates.resolved}get isRejected(){return p(this,a,"f")===C.PromiseStates.rejected}get settledMs(){return null==p(this,o,"f")?void 0:p(this,o,"f")-this.startedAt}resolve(e){return p(this,i,"m",m).call(this,(()=>{g(this,a,C.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,D.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return p(this,i,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,a,C.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=F,n=F,m=function(e){if(p(this,a,"f")===C.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,o,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},s={value:0}},27395:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const i=r(19851),n=r(40958),s=r(42659),o=r(23838),a=r(13538),l=r(50213),u=r(7282),c=r(97352),d=r(77740),h=r(25764),f=r(99331),m=r(73614),p=(0,i.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new o.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const r=await e;if(null==r||!0===r?.ended)return;const i=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,r.endTimeoutMs,y);p().trace(r.name+" ending...",{timeoutMs:i});try{await(0,a.thenOrTimeoutError)(r.end(),i,(0,u.isTest)())}catch(e){try{p().warn(r.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,i.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const r=g.get(t)??[];(0,n.isNotEmpty)(r)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(r.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,n.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const r=g.get(t)??[];e[t]=r.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,r){var i,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=r(87997),h=r(55835),f=r(31586),m=r(68708),p=r(25764),g=r(38836),y=r(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,i,"m",o).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),i.add(this),this.opts=e,n.set(this,void 0),s.set(this,void 0),a.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,n,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,r=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!r&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,i,"m",o).call(this);const h=()=>{u(this,i,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,n,(0,d.setInterval)(u(this,a,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,i,"a",l)&&(u(this,a,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):h(),!0}}t.EndableInterval=v,n=new WeakMap,s=new WeakMap,a=new WeakMap,i=new WeakSet,o=function(){(0,h.map)(u(this,n,"f"),d.clearInterval),c(this,n,void 0,"f"),(0,h.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const i=r(50989);t.EndableRanks=(0,i.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const a=r(19851),l=r(45599),u=r(56409),c=r(50213),d=r(27395),h=r(25764),f=r(99331),m=r(56519);t.EndableWrapper=class{constructor(e,t,r=h.EndableRanks.first,o){this.endTimeoutMs=o,i.set(this,void 0),this.onEnds=[],n.set(this,(0,a.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,n,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(r,this)}setName(e){o(this,i,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,i,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,n,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},i=new WeakMap,n=new WeakMap},99331:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const i=r(7282);let n=!1;t.ending=function(){return n},t.setEnding=function(e){n=(0,i.isTest)()?e:e||n}},45608:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const n=i(r(1708)),s=r(22573),o=r(45599),a=r(37975),l=r(50213),u=r(71567),c=r(57159),d=r(57902),h=r(28874),f=r(27395),m=r(99331),p=r(56038),g=(0,o.defer)((()=>(0,l.mkLogger)((0,a.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,o.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const r=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==r.errno||!0===r.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const i=(0,s.toNotBlank)(e?.reason)??r.toString();for(const e of t.onFatalHandlers)await e(i)}(0,m.ending)()||(await(0,f.endEndables)(),n.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,o.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])n.default[e].on(t,(r=>{v({reason:`${e}:${t}`,status:0,error:r})}))}))},5916:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=r(50357),f=r(31586),m=r(41583),p=r(62344),g=r(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:r,timeoutMs:i}){return new y(e,t,r,i)};class y extends p.ExtensibleFunction{constructor(e,t,r,l){super(),i.add(this),this.later=e,this.desc=t,this.ttlMs=r,this.timeoutMs=l,n.set(this,void 0),s.set(this,0),o.set(this,void 0),a.set(this,[])}_call(){return this.isStale()?c(this,i,"m",u).call(this,this.later()):c(this,o,"f")}unset(){d(this,s,0,"f"),d(this,n,void 0,"f"),d(this,o,void 0,"f")}set(e){return c(this,i,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,i,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,a,"f").push(e)}prior(){return this.isStale()?void 0:c(this,o,"f")}lastValue(){return c(this,o,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,n,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,n,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,n,"f")?void 0:Date.now()-c(this,n,"f")}elapsedMs(){return c(this,o,"f")?.settledMs??c(this,o,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=async function(e,t){var r;try{const r=await t;if(!(0,h.eql)(e?.value??await(e?.promise),r))for(const e of c(this,a,"f"))await e.onChange(r)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,a,"f"))e.onError(t)}finally{d(this,s,(r=c(this,s,"f"),++r),"f")}},u=function(e){d(this,n,Date.now(),"f");const t=c(this,o,"f");return d(this,o,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,o,"f").setTimeout(this.timeoutMs),c(this,i,"m",l).call(this,t,c(this,o,"f")),c(this,o,"f")}},56519:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const i=r(40958),n=r(76790),s=r(38639),o=r(42659),a=r(41400),l=r(31586),u=r(20214),c=r(13538),d=r(42279),h=r(32639),f=r(59455),m=r(41583),p=r(48884),g=r(50213),y=r(88158),v=r(15674),w=r(42638);var S=r(20214);async function b(e){if(null==e)return[];const t=(0,i.compact)(await e);return(0,i.isEmpty)(t)?[]:(0,i.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:r,timeoutMs:n}){const s=[];for(const o of(0,i.compact)(await t))try{const e=await((0,l.gt0)(n)?(0,c.thenOrTimeoutError)(r(o),n):r(o));null!=e&&s.push([e,o])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:o,error:t})}return s}async function E({arr:e,f:t,name:r,maxConcurrent:n,timeoutMs:s,promises:o}){if(null==e)return[];const a=(0,i.compact)(await e);if((0,i.isEmpty)(a))return[];if((n=Math.round(n??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:r,timeoutMs:s});const u=o??(a.length<=n?w.PermissivePromises:new w.Promises(r,(()=>n))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,h=await u.enqueueAll(r,a.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(r).warn("failed to apply",{ea:e,error:t})}})));return(0,i.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,r){const i=[];for(const n of(0,p.batches)((0,f.toA)(await e),t)){const e=await b(n);i.push(...await b(r(e)))}return i},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,a.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const r of(0,i.compact)(e)){const e=await r();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;if(null!=e)if(Array.isArray(e))for(const r of e){const e=await r;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;null!=e&&t.push(e)}return(0,i.uniq)(t)},t.asyncFind=async function(e,t){for(const r of e)if(await t(r))return r},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=E,t.mapAsync=async function({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s}){return(await E({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:r,maxConcurrent:n,timeoutMs:s}){return(await E({name:e,arr:(0,i.compact)(t),f:r,maxConcurrent:n,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const r=await E({name:"partitionAsync",arr:e,f:t});return[r.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),r.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*o.secondMs,t.tryAll=async function(e,r=(e=>console.error(e)),i=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,i)}catch(e){r((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),r=(()=>{})){let i,n=null;try{i=await((0,h.isFunction)(e)?e():e)}catch(e){n=(0,m.toErr)(e);try{await t(e)}catch{}}try{await r(n??i)}catch{}if(null!=n)throw n;return i},t.thenNot=async function(e,t=!0){if(null==e)return t;const r=await e;return null==r?t:!(0,s.isTrue)(r)},t.thenMap2=async function(e,t,r){const i=await e;if(null==i)return;const n=await t;return null!=n?r(i,n):void 0},t.thenMapOr=async function(e,t,r){const i=await e;if(null==i)return r();const n=await t(i);return null==n?r():n},t.thenMap2Or=async function(e,t,r,i){const n=await e;if(null==n)return i();const s=await t;if(null==s)return i();const o=await r(n,s);return null==o?i():o},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null==i)continue;const e=await t(i,r);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const r of e){const e=await r();if(null!=e){const r=await t(e);if(null!=r)return r}}},t.firstResolvedDefinedPromise=async function(e,t){for(const r of e)try{const e=await r();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const r of t)try{const t=await r();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:r}){const i=await E({name:e,arr:t,f:r});return(0,n.sortBy)(i,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const i=r(19851),n=r(40958),s=r(76790),o=r(42659),a=r(49769),l=r(31586),u=r(68708),c=r(42279),d=r(41583),h=r(22454),f=r(14121),m=r(50213),p=r(7282),g=r(34102),y=r(82647),v=r(25764),w=r(38836),S=r(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,r){const i=Date.now(),n=(0,l.clamp)(10*o.secondMs,o.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-i)+"ms")}),n);try{const n=await(0,c.tot)(t),s=Date.now()-i;return r?.(n,s),this.push(e,s),n}catch(t){throw this.errors.incr(e),r?.((0,d.toErr)(t),Date.now()-i),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),r=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),i=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",r.stats()],...i])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,a.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:r.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:(0,l.mapFinite)(r.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:r.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:{sumSec:(0,l.sigFigs)(r.sum/o.secondMs,3),...(0,u.omit)(r.stats(),"sum")}})),{})}}function _(e,t,r){return P.instance().time(e,t,r)}function E(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,i.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,n.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const r=Date.now(),i=t();return E(e,Date.now()-r),i},t.pushTime=E,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,r){return(0,i.lazy)((async()=>_(e,t)),r)}},42638:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(r(66261)),m=r(40958),p=r(55835),g=r(31586),y=r(42279),v=r(54993),w=r(89788),S=r(82647),b=r(15674),P=r(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){i.add(this),this.name=e,this.ee=new f.default.EventEmitter,n.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),o.set(this,[]),a.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,n,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,b.maxCpus)(),d(this,n,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,a,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,o,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,o,"f").map((e=>e.name)),pendingNames:d(this,a,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:r,serialId:n}){const s=d(this,i,"m",l).call(this,{name:e,l:t,payload:r,serialId:n});return this.laterPop(),s}enqueueAll(e,t){const r=t.map((t=>d(this,i,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(r)}serial(e,t,r){return this.enqueue({name:e,l:t,serialId:e,payload:r})}push(e,t,r){return d(this,i,"m",u).call(this,new P.Deferred(e,{payload:r}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,o,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,a,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,a,"f").length,e),r=this.runningSerialIds,n=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,o,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,a,"f").length}hasPending(){return d(this,a,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,a,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,a,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=function({name:e,l:t,payload:r,serialId:i}){const n=new P.Deferred(e,{payload:r,serialId:i});return d(this,a,"f").push({d:n,l:t}),n},u=function(e,t){const r=Date.now();return this.lastWorkTs=r,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,o,"f"),e),this.settleMsAvg.push(Date.now()-r),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,o,"f").push(e),e},t.maybeRun=function(e,t){const r=new _(e);return()=>r.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:r}){return new _(e,(0,p.map)(r,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class r extends Error{}t.RedoableError=r},4867:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const i=r(40958),n=r(34546),s=r(41400),o=r(31586),a=r(83104),l=r(85556),u=r(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:r}){let a=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>a=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>{if(a)throw new l.TimeoutError})):void 0,r?.abortPromise_().then((()=>{if(a)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:r}){let l=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>l=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>a.Timeout)):void 0,r?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let r=e=>null;t.setTimeoutHandler=function(e){r=e},t.onTimeout=function({soft:e}={}){r(e)}},73614:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const i=r(87997);t.setUnrefTimeout=function(e,t,...r){return(0,i.setTimeout)(e,Math.round(t),...r).unref()},t.setUnrefInterval=function(e,t,...r){return(0,i.setInterval)(e,Math.round(t),...r).unref()}},31562:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const i=r(38639),n=r(42659),s=r(41400),o=r(32639),a=r(31586),l=r(45255),u=r(95937);async function c(e,{timeoutMs:t,intervalMs:r,acceptable:i,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const i=r??(0,a.clamp)(10*m,l.ShortCommandTimeoutMs,(t??n.minuteMs)/5);await(0,s.delay)(i,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:i.isTrue,timeoutResult:!1})}},9727:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const n=i(r(1708)),s=r(45599),o=r(41400),a=r(50357),l=r(68708),u=r(48884),c=r(36638),d=r(44198),h=r(59958),f=r(96706),m=r(34102),p=r(19851),g=r(19043),y=r(66184),v=r(50213),w=r(7282),S=r(88158),b=r(45969),P=r(43334),_=r(28874),E=r(3790);function M(e){return C().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const C=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const r of t.names)e.add(r);for(const r of t.keys)e.add(r)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,o.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const T=["HOME","LANG","USER"],x=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],D=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?T:x),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function k(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const r of(0,_.persistedSettings)()){const i=e?r.value:r.envValue;null==i||(0,a.eql)(i,r.defaultValue)||r.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(n.default.env,(e=>M(e)||!(0,E.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=k,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:I({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let O=!1;function I({overrides:e,forceCLocale:r=!0,forWorker:i=!1}={}){const n=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...D(),...r?(0,g.childProcLocale)():{},...k(i),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(n);if((0,y.isLogged)("debug")&&!O){O=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(n).map((([e,t])=>[e,(0,E.isHiddenEnvKey)(e)?"(hidden)":t])),[r,i]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(r)),e.debug("non PS env:",(0,l.fromEntries)(i))}return n}t.childEnv=I},84777:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const n=i(r(31421)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(42659),c=r(98553),d=r(56409),h=r(31586),f=r(68708),m=r(51926),p=r(50213),g=r(7282),y=r(88158),v=r(79089),w=r(45255),S=r(22911),b=r(4867),P=r(73614),_=r(70025),E=r(57159),M=r(36868),C=r(66184),T=r(45643),x=r(95402),D=r(9727),k=(0,o.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function O(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function I(e,t=30*u.secondMs){if(null==e)return!1;k().debug("endProcess()",O(e));const r=e.pid;if(null==r||r<=0)return k().warn("endProcess(): asked to end invalid pid",O(e)),!1;if(r===s.default.pid)return k().warn("endProcess(): asked to end MY pid",O(e)),!1;if(r===s.default.ppid)return k().warn("endProcess(): asked to end my parent pid",O(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();k().debug("endProcess("+r+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,x.killPid)(r).catch((e=>{k().warn("endProcess(): kill("+r+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,T.waitForPidExit)(r,t))return k().debug("endProcess(): exitted",O(e)),!0;{x.Pids.instance()?.onKill(r);const t=e.kill("SIGKILL");k().warn("endProcess("+r+") had to resort to SIGKILL",{killResult:t}),t||await(0,x.killPid)(r,!0).catch((e=>{k().warn("endProcess(): kill("+r+",true) failed: "+e)}))}return(0,T.waitForPidExit)(r,5e3)}function F(e,r,i,n=0){const o=new Date,a=[];return(0,v.niceable)(r,i)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(n,u.secondMs)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&I(e)}),n-250)),a.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,x.addPid)({pid:e.pid,cmd:r,timeoutMs:n,ppid:s.default.pid},o)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>a.forEach(clearTimeout))),e}function A(e,t,r,i){const s=(0,D.spawnOptions)(i);return(0,C.isLogged)("trace",k().context)?k().debug("execFile()",{command:e,args:t,timeoutMs:r,opts:s}):k().debug("execFile()",{command:e,args:t,timeoutMs:r}),F(n.default.execFile(e,t,s),e,t,r)}async function N(e,t,r){const i=r.quiet??!1,n=r.ignoreStderr??!1,s=r.ignoreExitCode??!1,o=A(e,t,r.timeoutMs,(0,f.omit)(r,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===r.disconnect){try{o.disconnect?.()}catch{}return{result:"",pid:o.pid}}const u=o.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new S.Deferred(f);o.on("error",(e=>g.push(e))),o.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),o.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(o.stdin);const v=new d.Latch;null==o.stdout?v.resolve():(o.stdout.on("error",(e=>g.push(e))),o.stdout.on("data",(e=>m.push(e))),o.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==o.stderr||n?P.resolve():(o.stderr?.on("error",(e=>g.push(e))),o.stderr?.on("data",(e=>p.push(e))),o.stderr?.on("end",(()=>P.resolve()))),k().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:r.timeoutMs,halt:r.halt}),k().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt});const C=p.join("");(0,l.notBlank)(C)&&g.push(new Error(C)),!i&&(0,a.isNotEmpty)(g)&&k().warn(f+" resulted in errors:",g);const T=r.isIgnorableError??_.isIgnorableError,x=g.filter((e=>!0!==T(e)));if(x.length>0)throw 1===x.length?x[0]:new E.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:x});if(!s&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:C}}catch(e){throw k().error("stdoutResult_() failed",e),await(0,x.killPid)(o.pid,!0),e}}t.endProcess=I,t.ReniceAfterMs=(0,o.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,o.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,r,i){const s=(0,D.spawnOptions)(i);return k().debug("spawn()",{command:e,args:t,maxAgeMs:r}),F(n.default.spawn(e,t,s),e,t,r)},t.execFile=A,t.stdoutResult_=N,t.stdout_=async function(e,t,r){const i=await N(e,t,r);return k().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(i.result),meta:{cmd:e,args:t,opts:r,result:i}})}},3790:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const i=r(22573),n=r(41400),s=r(19851),o=r(28874);(0,n.later)((()=>o.Settings.sensitiveEnvRegExp.watchLater((()=>a.unset()))));const a=(0,s.lazy)((()=>{try{return new RegExp(o.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${o.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(o.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,i.blank)(e)&&a().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||o.Settings.license.includesEnvKey(e)}},41269:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const i=r(1708),n=r(31586),s=r(51926),o=r(17344),a=r(37805),l=r(84542);function u(e,t){const r=t?.maxLineLen??(0,n.toInt)(i.env.maxLineLen)??i.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:r,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,o.EditionName)()+" v"+a.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},94361:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const i=r(19851),n=r(40958),s=r(55835),o=r(31586),a=r(94174),l=r(44198),u=r(45969);function c(e,t,r){const i=(0,o.toGt0)((0,l.env)()[t]);return null==i||r.includes(i)?void 0:`WARNING: ${e} is running as ${r} but $${t}=${i}`}function d(){const e=(0,n.compactBlanks)([c("user id","PUID",(0,a.userids)()),c("group id","PGID",(0,a.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,i.lazy)((()=>{(0,u.isDocker)()&&(0,s.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},76596:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const i=r(51168),n=r(19851),s=r(22573),o=r(42659),a=r(55835),l=r(31586),u=r(68708),c=r(34666),d=r(50213),h=(0,n.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,r){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=r}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const r=(0,a.mapOr)(e,(e=>e.getTime()),(()=>0)),i=(0,a.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(r,i)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),r=Date.now();return t<=r?0:t-r},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,o.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const i=r(22573),n=r(31586),s=r(54557),o=r(91655),a=new s.FifoCache(512);function l(e){return(0,n.isNumber)(e)?e:(0,i.blank)(e)?void 0:a.getOrSet(e,(()=>(0,o.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,i.blank)(e)?void 0:u.getOrSet(e,(()=>(0,o.fmtFullDuration)((0,n.isNumber)(e)?e:l(e))))}},91655:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const i=r(51168),n=r(40958),s=r(22573),o=r(42659),a=r(31586),l=r(51926),u=r(68852),c=r(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,a.isNumber)(e))return;if((0,a.isNumber)(e))return e;if((0,a.isDigits)(e))return(0,a.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=i.Duration.fromISO(e);if(t.isValid)return t.toMillis();const r=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(r,e);if(0===d.length)return;const h=(0,n.compact)(d.map((e=>function(e,t){const r=(0,a.toFloat)(e);if(null!=r){if((0,s.blank)(t))return r;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*o.yearMs;case"weeks":case"week":case"w":return r*o.weekMs;case"days":case"day":case"d":return r*o.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return r*o.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return r*o.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return r;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,a.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:o.yearMs,s:"y"},{ms:o.weekMs,s:"w"},{ms:o.dayMs,s:"d"},{ms:o.hourMs,s:"h"},{ms:o.minuteMs,s:"m"},{ms:o.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,r=""){if(!(0,a.isNumber)(t))return;if(0===t)return"0";if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const i=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const r=Math.floor(t/e.ms);t-=r*e.ms,r>0&&i.push(r+e.s)}return i.join(r)}},84248:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const i=r(50989);t.AutoVacuumModes=(0,i.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const i=r(50989);t.CheckpointTypes=(0,i.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const i=r(50989);t.RepairModes=(0,i.strEnum)("dump","recover")},34365:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const i=r(50989);t.SynchronousModes=(0,i.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const o=s(r(76760)),a=r(40958),l=r(22573),u=r(55835),c=r(72993),d=r(19851),h=r(97352),f=r(94174),m=r(44198),p=r(96706),g=r(8769),y=r(57159),v=r(70698),w=r(64680),S=r(29882),b=r(45969),P=r(43334),_=r(28874),E=r(41692),M=r(32774),C=r(80612),T=r(32551),x=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function D(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+x(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const r of t)(0,l.blank)(r)||e.push({dir:(0,o.join)(r,".photostructure-cache"+x()),preexistingDir:r});return e}}function k(){if((0,b.isDocker)())return(0,a.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,o.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+x(),preexistingDir:M.DefaultDockerLibraryDir},...D()]);const e=(0,a.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),o.default.resolve((0,T.homeDir)(),"AppData","Local")]:P.isMac?[o.default.resolve((0,T.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,o.join)((0,T.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,r=e.map((e=>({dir:(0,o.join)(e,t),preexistingDir:e})));return r.push(...D()),r}t.tmpCacheDirs=D,t.tmpDirs=function(){return(0,C.filterDirs)({dirs:D(),desc:"tmp"})},t.cacheDirs=k,t.defaultCacheDir=(0,d.lazy)((()=>(0,C.firstDir)({dirs:k(),desc:"cache"})));const O=(0,d.lazy)((()=>{(0,E.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(I)}));function I(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{O();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=I},46292:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const i=r(19851),n=r(45969),s=r(41692),o=r(32774),a=r(10924),l=r(84373),u=r(80612);t.configDir=(0,i.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,n.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,a.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:o.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:o.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,n.isDocker)()?c:(0,a.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const i=r(66430),n=r(45969),s=r(32774);t.defaultLibraryDir=function(){return(0,n.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,n.isDocker)()&&(0,i.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const n=i(r(76760)),s=r(40958),o=r(72993),a=r(44198),l=r(96706),u=r(43334),c=r(80612),d=r(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),n.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(n.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,a.env)().XDG_DATA_HOME,(0,a.env)().XDG_CONFIG_HOME,n.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:n.default.join(e,(0,o.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const i=r(22573),n=r(96706),s=r(29882);t.envConfigDir=function(){const e=(0,n.getEnv)("PS_CONFIG_DIR");if(!(0,i.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const i=r(44652),n=r(40958),s=r(22573),o=r(66430);function a({dirs:e,desc:t}){for(const{dir:r,preexistingDir:a}of(0,n.compact)(e))if(!(0,s.blank)(r)){if((0,o.isReadWriteableDirectorySync)(r))return r;if((0,s.blank)(a)||(0,o.isReadWriteableDirectorySync)(a))try{return(0,i.mkdirpSync)(r),r}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=a,t.filterDirs=function({dirs:e,desc:t}){return(0,n.compact)(e.map((e=>a({dirs:[e],desc:t}))))}},32551:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const i=r(48161),n=r(76760),s=r(1708),o=r(19851),a=r(40958),l=r(68284),u=r(43334);t.homeDir=(0,o.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,a.compactBlanks)(e)){const e=(0,n.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,i.homedir)()}))},46296:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(55835),u=r(54993),c=r(72993),d=r(96706),h=r(45969),f=r(43334),m=r(32707),p=r(6707),g=r(49776),y=r(32774),v=r(80612),w=r(32551);function S(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:n.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,o.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>n.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,a.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),r=(0,u.toS)(t?.logDir);return(0,a.notBlank)(r)?r:b()}catch(e){return console.error("defaultLogDir_() failed",e),n.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const i=r(76760),n=r(19851),s=r(22573),o=r(44198),a=r(43334),l=r(24399),u=r(32551);async function c(){return a.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,n.lazy)((async()=>{if(a.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,n.lazy)((()=>(0,o.env)().XDG_PICTURES_DIR??(0,i.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const i=r(38639),n=r(7282),s=r(29325),o=r(44198);t.getDevEnvFlag=function(e){return!(0,n.isProd)()&&!(0,s.isPacked)()&&((0,i.toBoolean)((0,o.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,o.env)()[e]=String(t)}},34580:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const i=r(38639),n=r(44198);t.doNotTrack=function(){return(0,i.isTrue)((0,n.env)().DO_NOT_TRACK)}},44198:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const n=i(r(73024)),s=r(76760),o=i(r(1708)),a=r(19851),l=r(40958),u=r(41400),c=r(68708),d=r(76850),h=r(7282),f=r(32551),m=r(34102),p=r(53265),g=r(45969),y=r(59958),v=r(6012),w=r(96706);t.env=(0,a.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>o.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===o.default.env.PS_LICENSE||e.push((0,s.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),r={...o.default.env};for(const i of e)try{const e=(0,d.debom)(n.default.readFileSync((0,p.resolve)(i))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,i]of(0,c.entries)(s))t.test(e)||(r[e]=i)}catch(e){console.warn("env(): failed to read .env file, "+i,e)}return r})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const i=r(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,i.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const i=r(50989);t.EnvKeys=(0,i.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const i=r(22573),n=r(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const r={};if((0,i.blank)(e))return r;let s;for(const o of(0,n.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(o));){if(null==s.groups)continue;const{key:e,val:n}=s.groups;if((0,i.blank)(e)||null==n)continue;const o=n.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");r[t?e.toLowerCase():e]=o}}return r}},96706:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const n=i(r(1708)),s=r(19851),o=r(22573),a=r(38639),l=r(41400),u=r(40583),c=r(79840),d=r(83556),h=r(34102),f=r(44198),m=r(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,o.firstNotBlank)(n.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,n.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,a.isTrue)(g(e))}},98314:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const i=r(58587),n=r(19851),s=r(40958),o=r(22573),a=r(26905),l=r(96249),u=r(51926),c=r(23541),d=r(54993),h=r(89788),f=r(50213),m=r(81168),p=r(84542),g=r(41954),y=r(38835),v=r(70025),w=r(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const r=[...e.filter(c.isError).map(a.errorName),...e.map(a.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(a.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(r)))}function b(e){return(0,s.compact)(e).filter((e=>!a.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(o.notBlank)}function P(e,t){const r=(0,s.uniqSubstrings)(b(e)),i=t?.maxLen??400,n=t?.trailingChars??64,o=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(r.join(a.ErrorDelimiter)),i-o.length,n)+o.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,o.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,n.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new i.Rate,t.fatalErrorRate=new i.Rate,t.internalErrorRate=new i.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,o.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const r=(0,d.toS)(t?.[e]);if((0,o.notBlank)(r))return r}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,r=256,i=7){return(0,o.blank)(e)&&(e=t.MissingError),_(e,{maxLen:r})+" at "+(0,a.shortStack)(e?.stack,i).join("; ")}},41954:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const i=r(40958),n=r(26905),s=r(55835),o=r(54993),a=r(81168);t.describeError=function(e){const t=(0,a.stripSuffix)((0,o.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const r of e)(0,s.map)((0,n.errorErrno)(r),(e=>t.push(u.get(e)))),(0,s.map)((0,n.errorCode)(r),(e=>t.push(l[e]?.description)));return(0,i.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const i=r(40958),n=r(76790),s=r(50989),o=r(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,n.sortBy)((0,i.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(o.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const i=r(40958),n=r(38639),s=r(26905),o=r(54993),a=r(68852),l=r(73568),u=r(78656),c=r(98314),d=r(38835);function h(e){return(0,o.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const r=(0,o.toS)(e)+(0,i.compact)(t).join("");return h(r)+f(r).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,a.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const r=(0,c.errorToS)(e);return!p.test(r)&&(!!g.test(r)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,n.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const r=(0,c.errorToS)(e);return!(!r.includes("EBUSY")&&!r.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const r=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>r.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,n.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,n.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},8769:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const i=r(22573),n=r(31586),s=r(68708),o=r(7282),a=r(23560),l=r(45608),u=r(34102),c=r(28874),d=r(98314),h=r(38835),f=r(70025),m=r(57159),p=r(5012);function g(e,t){try{if((0,i.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const r=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const n=!0===r.fatal,c=!0===r.ignorable;if(!n&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),n&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",r));const h=!n||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:r}),!n||(0,o.isTest)()||(0,a.isWebService)()||(0,l.exit)({reason:r.toString(),status:r.errno??13}),n}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,n.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,a.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,n.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,n.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,r){return g(e+h.InternalErrorFlag,{cause:t,...r})}},57159:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const i=r(40958),n=r(22573),s=r(38639),o=r(26905),a=r(98553),l=r(68708),u=r(59455),c=r(41583),d=r(48884),h=r(81168),f=r(98314),m=r(38835),p=r(70025);t.toWrappedError=function(e,t){const r=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,n.blank)(r.message)||e.message.includes(r.message)))return e;const i=(0,n.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,r?.message);return new g(i??"(missing error message)",r)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,i.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,o.errorName)(t)??(0,d.first)(this.causes,o.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(o.errorCode)],o.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,o.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.path))),this.flags=t?.flags??[];const r=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??r.some(p.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(r.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(r.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(r.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let r=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const i=t?.path;return(0,n.blank)(i)||(r=(0,h.dedupeNeedle)(r,i,"file")),(0,f.joinErrorMessages)([r[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,a.stringify)(t.meta):void 0,...r.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const o=r(49769),a=r(55835),l=r(54993),u=r(22911),c=r(89788),d=r(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,i.set(this,new Map),n.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,o.getOrSet)(s(this,i,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const r=this.target.emit(e,...t),o=s(this,i,"f").get(e);return null!=o&&(o.resolve(t),s(this,i,"f").delete(e)),r}emitDebounced(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},i=new WeakMap,n=new WeakMap},34102:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const i=r(78474),n=r(19851),s=r(15197);t.ee=(0,n.lazy)((()=>{const e=new i.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const n=i(r(73024)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(65843),u=r(16287),c=r(43334),d=(0,o.lazy)((()=>s.default.geteuid?.())),h=(0,o.lazy)((()=>s.default.getgroups?.()));function f(e,t){try{return!(0,a.blank)(e)&&(n.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,n.default.constants.R_OK|n.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,n.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:r=!1,x:i=!1,processUid:n,processGid:s}){if(null==e)return!1;const o=n??d(),a=null!=s?[s]:h()??[],l=0===o,u=l||e.uid===o,f=l||a.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(r&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!i||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const r of(0,l.selfAndAncestorG)(e)){const i=await(0,u.statMaybe)(r);if(null!=i){if(!i.isDirectory())return!1;if(t){if(!p(i,e))return!1}else if(t=!0,!m(i,e))return!1}}return!0},t.access=g},21144:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const n=i(r(76760)),s=r(19851),o=r(81168),a=r(57159),l=r(43334),u=r(88561),c=r(29882),d=r(65238),h=r(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const r=(0,c.parseNativePath)((0,h.resolve)(...e)),i=await m(r.dir);for(const e of await(0,d.readdir_)(i))if((0,o.equalsIgnoreCase)(e.basename,r.base))return n.default.join(i,e.basename);throw new a.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const i=r(73024),n=r(76760);function s(e){return[...o(e)]}function*o(e){for(;e!==(0,n.dirname)(e);)e=(0,n.dirname)(e),yield e}function a(e){try{return(0,i.readdirSync)(e)}catch(e){return[]}}function l(e,t){const r=a(e);return t.every((e=>r.includes(e)))}t.ancestors=s,t.ancestorG=o,t.selfAndAncestorG=function*(e){yield e,yield*o(e)},t.childrenSync=a,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,r){var i,n,s,o,a,l=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&l(t,e,r);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(r(44652)),p=c(r(73024)),g=r(51455),y=f(r(76760)),v=f(r(1708)),w=r(46466),S=f(r(57975)),b=f(r(38522)),P=r(19851),_=r(40958),E=r(5233),M=r(22573),C=r(42659),T=r(50357),x=r(96249),D=r(98553),k=r(55835),O=r(31586),I=r(68708),F=r(97790),A=r(39926),N=r(51926),L=r(59455),R=r(54993),j=r(48884),B=r(22911),V=r(99331),z=r(56519),W=r(56038),q=r(31562),U=r(76850),H=r(70025),G=r(34102),J=r(80875),K=r(50213),$=r(70417),Y=r(43334),Z=r(81168),X=r(96859),Q=r(65162),ee=r(94174),te=r(64660),re=r(21144),ie=r(84542),ne=r(89968),se=r(20197),oe=r(88561),ae=r(50597),le=r(33456),ue=r(29882),ce=r(78133),de=r(43899),he=r(65238),fe=r(53265),me=r(17217),pe=r(16287),ge=r(68284),ye=r(66003),ve=r(27794),we=r(73428),Se=r(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new oe.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(i.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,K.mkLogger)("fs.BaseFile("+this.nativePath+")"))),n.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),o.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(n=new WeakMap,o=new WeakMap,i=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),r=await Promise.all(t.map((e=>e.shaMs())));return t[(0,j.leastIndex)(r)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const r=(0,me.isSimpleFile)(e)?e.nativePath:(0,R.toS)(e);if((0,M.blank)(r))throw new Error("BaseFile.for(): empty nativePathOrFile");const i=be().get(r);if(null!=i)return i;const n=(0,fe.resolve)(r),s=new Pe(n,t);return be().set(r,s),be().set(n,s),s}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,n,"f").unset(),h(this,o,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,z.thenMap)(this.stat(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,k.map)(this.statSync(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,n,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const r=[];for(const i of t)!0===await e(i)&&r.push(i);return r}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,z.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,i,"m",s).call(this)??await d(e=this.clearThisAndParent(),i,"m",s).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,z.thenMap)(this.children(),(async t=>{for(const r of t)await r.visitDescendants(e),await e(r)}))}async descendants(e){const t=[];t.push(...(0,L.toA)(await this.childFiles(e)));const r=await this.childDirectories();if(null==r)return t;for(const i of r)t.push(...(0,L.toA)(await i.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,O.gt0)(t))return;const r=await d(this,n,"f").call(this)??[];for(const t of r)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const i of r)if(i.isDirectory()){const r=await this._directoryEntryChild(i).someDescendant(e,t-1);if(null!=r)return r}}descendantsSync(e){const t=this.directoryEntrySync(),r=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&r.push(this.forDirectoryEntry(t))})),r}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,re.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,T.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,k.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,r)=>this.join((0,R.toS)(e),(0,A.pad2)(t+1),(0,A.pad2)(r))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,x.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,r="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(r,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,r="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(r,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,r){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(r??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,z.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,z.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,z.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,z.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,C.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,z.thenMap)(this.statTimes(),j.max)}maxStatDate(){return(0,z.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,z.thenMap)(this.statTimes(),$.min)}minStatDate(){return(0,z.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,z.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,z.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,z.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,z.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>=(0,C.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,z.thenMap)(this.mtimeMs(),(r=>Math.abs(r-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>(0,C.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,z.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,k.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,F.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,q.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*C.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,ae.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,ae.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,J.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,J.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,U.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,z.thenMap)(this.zReadFile_(e),R.toS)))}readLines(e="warn"){return(0,z.thenMap)(this.readTextFile(e),ie.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces),(0,I.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,E.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,V.ending)()?1:3,timeoutMs:0,retryDelay:C.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,i,"m",a).call(this,(0,Z.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,i,"m",a).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,i,"m",a).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const r=await this.children((async r=>!r.isNameHidden()&&t===r.size()&&r.nativePath!==e.nativePath));if((0,_.isEmpty)(r))return;const i=await e.sha();if(null!=i)for(const e of r.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===i)return e}))}firstMatchingLine(e){const t=new B.Deferred("firstMatchingLine("+this+")"),r=p.default.createReadStream(this.nativePath,{flags:"r"});return r.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),r.close()):t.maybeReject(e)})),r.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(r,(0,N.newlineRe)(),(i=>{const n=e.exec(i);null!=n&&(t.maybeResolve(n),r.close())})),t.promise}contemporary(e,t){return(0,z.thenMap2Or)(this.statTimes(),e.statTimes(),((e,r)=>{for(const i of e)for(const e of r)if((0,O.closeTo)(i,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),r=new B.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&r.setTimeout(e.timeoutMs),_e)try{const i=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(i,n)=>{try{const s=await e.f(i,(0,k.denull)(n));t(s)&&r.resolve(s)}catch(e){r.reject(e)}}));r.finally((()=>{i.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,O.gt0)(e.intervalMs)){const i=setInterval((async()=>{try{const i=await e.f();t(i)&&r.resolve(i)}catch(e){r.reject(e)}}),e.intervalMs);e.persistent||i.unref(),r.finally((()=>{clearInterval(i)}))}return r}}t.BaseFile=Pe,s=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,j.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,k.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},a=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const r=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(r.nativePath,{autoClose:!0})]),await this.unlink(),r}))},Pe.attrTTL=3*C.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},84542:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const i=r(40958),n=r(96249),s=r(51926),o=r(54993),a=r(43334);function l(...e){return(0,n.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,o.toS)(e).split((0,s.newlineRe)()))))}t.Newline=a.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(o.toS).join("\n");return a.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,i.compactBlanks)(l(...e))}},70698:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const i=r(76760),n=r(19851),s=r(50213),o=r(37805),a=r(29882),l=r(93854),u=r(17217),c=r(16287),d=r(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,n.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const r=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return r===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,i.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const r=(0,u.toNativePath_)(e);await(0,a.mkdirp_)(r),await(0,d.writeTextfile_)((0,a.joinNativePath)([r,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+o.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(45969),u=r(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,o.lazy)((()=>[...(0,a.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,n.default.join(e,"System32"),n.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const a=s(r(44652)),l=o(r(73024)),u=r(76760),c=r(57975),d=r(19851),h=r(59455),f=r(50213),m=r(81168),p=r(34102),g=r(29882),y=r(65238),v=r(14427),w=r(17217),S=r(16287),b=r(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class E{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new E(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:r,base:i}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},n=await a.stat(t);return new E(r,new P(i,n))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return E.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new E(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>E.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new E(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const r of t)r.isDirectory()&&await r.visitDescendants(e);for(const r of t)r.isFile()&&await e(r);for(const r of t)r.isDirectory()&&await e(r)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const r of t)r.isFile()&&e(r);for(const r of t)r.isDirectory()&&(r.visitDescendantsSync(e),e(r))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async r=>{!0===await e(r)&&t.push(r)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await a.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await a.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=E},20197:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const n=i(r(76760)),s=r(39926),o=r(29882),a=r(16287),l=r(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if(await(0,o.mkdirp_)(i.dir),!r.requireNumber&&await(0,a.isEmptyFile)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if(await(0,a.isEmptyFile)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)},t.ensureNewNativePathSync_=function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if((0,o.mkdirpSync_)(i.dir),!r.requireNumber&&(0,l.isEmptyFileSync)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if((0,l.isEmptyFileSync)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)}},88561:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const o=r(40958),a=r(22573),l=r(41400),u=r(68708),c=r(25764),d=r(38836),h=r(34102),f=r(80049),m=r(50213),p=r(88158),g=r(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),i.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>s(this,i,"m",n).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,o.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,i=new WeakSet,n=async function(e){if((0,a.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const i=r(73024),n=r(22573),s=r(45599),o=r(96249),a=r(68708),l=r(54993),u=r(49047),c=r(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,s.defer)((()=>{const e={};for(const[t,...r]of d)for(const i of r)e[i]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof i.Dirent?e.name:(0,l.toS)(e),r=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,n.blank)(r)?void 0:h()[r]??r}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,o.flatten)((0,a.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const r of t)if(r===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const i=r(68708),n=r(17217),s=r(16287),o=r(68284);async function a(e){return(0,i.pick)(await(0,s.stat_)((0,n.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=a,t.fileStats=async function(e){try{return await a(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,o.statSync)((0,n.toNativePath)(e)))?void 0:(0,i.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},4001:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const i=r(22573),n=r(55835),s=r(31586),o=r(51926),a=r(54993),l=r(97352),u=r(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,i.toNotBlank)(e.name)??(0,a.toS)(e),t).normalize()}function f(e,r){if(t.ymdIsoRE.test(e))return e;let i=e;for(const e of r.aggressive?d:c){const t=i.match(e);if((0,s.gt0)(t?.index)){const e=i.slice(0,t.index).trim();e.length>0&&(i=e)}}return e===i?e:f(i,r)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),r=t.pop();if((0,i.blank)(r))return e;const n=(0,u.parsePosixPath)(r),s=h(n,{aggressive:!1});return[...t,s+n.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,o.isString)(e)?e:e.name).toLowerCase().normalize(),r=h(t),i=(0,o.stripPrefix)(t.toLowerCase().normalize(),r);return(0,n.map)((0,l.extractInt)(i),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,o.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,n.map)(m.exec(t),(e=>t=e[1].trim())),(0,n.map)(g.exec(t),(e=>t=e[1].trim())),t}},50597:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const n=i(r(77598)),s=i(r(73024)),o=r(46466),a=r(19851),l=r(98553),u=r(68708),c=r(23467),d=r(80049),h=r(73913),f=r(50213),m=r(12089),p=r(37628),g=r(43624),y=r(17217),v=r(16287),w=(0,a.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),S=(0,a.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:r=!0}={}){const i=(0,y.toNativePath_)(e);if(r){const t=S().get(i);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:i,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:i,prior:t}),S().delete(i)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),r=(0,y.toNativePath_)(e);return{sha:await _(s.default.createReadStream(r)),stats:(0,u.pick)(await(0,v.stat_)(r),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],r="sha512"){const i=n.default.createHash(r);return await(0,o.pipeline)([e,...t,i]),i.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return n.default.randomBytes(h.HashBits/8).toString("base64")}},25675:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const i=r(22573),n=r(54993),s=r(7282),o=r(43334),a=r(69375),l=/^\/dev(?:\/|$)/i,u=o.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=o.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=o.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=o.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,n.toS)(e))}function m(e){return(0,i.blank)(e)?"blank":(0,a.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},33456:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const i=r(57075),n=r(51926),s=r(54993);class o extends i.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,r){const i=(this._prior+(0,s.toS)(e)).split((0,n.newlineRe)()),o=i.pop();this._prior=o??"";let a=!1;for(const e of i)a||(a=!this.push(e));a?setTimeout(r,1):r()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=o},64680:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const n=i(r(76760)),s=r(17217),o=r(73428);t.mkNoMedia_=function(e){return(0,o.writeTextfile_)(n.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},29882:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(5233),u=r(22573),c=r(98553),d=r(39426),h=r(51926),f=r(48884),m=r(50213),p=r(81168),g=r(70025),y=r(43334),v=r(78133),w=r(53265),S=r(17217),b=r(16287),P=r(66430),_=r(5545);function E(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,o.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=E,t.containsHiddenPathname=function(e){return k(e).some(E)},t.isNotHiddenPosixPath=function(e){return k(e).every((e=>!E(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return C((0,v.posix2native)(e))},t.extname=function(e){return C(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function C(e){const t=M.exec(e)?.groups,r=t?.ext2??"",i=s.default.parse(t?.path??e);return{...i,ext:(i.ext??"")+r,base:(i.base??"")+r}}function T(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,s.default.sep)}function x(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),r=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(r))return!1;const i=e.acceptSelf??!1;return t===r?i:r.startsWith((0,p.ensureSuffix)(t,s.default.sep))}catch(r){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:r}),!1}}function D(e,t,r){if(null==t||null==r)return!1;const i=e(t),n=e(r);return null!=i&&null!=n&&(y.isLinux?i===n:(0,p.equalsIgnoreCase)(i,n))}function k(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function O(e){return(0,u.notBlank)(e)&&k(e).length===(y.isWin?1:0)}function I({p:e,maxLength:t}){const r=(0,S.toNativePath_)(e);if(r.length<=t)return r;const i=k(e),n=[],s=[i.pop()];for(;i.length>0;)if(n.length=t){i.unshift(n.pop());break}}else if(s.unshift(i.pop()),A([...n,...s]).length>=t){i.push(s.shift());break}return i.length>0&&n.push("…"),A([...n,...s])}function F(e){return e.startsWith("\\\\")}function A(e){return(0,h.ensurePrefix)((0,a.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=C,t.parentBasename=T,t.grandParentBasename=function(e){return T(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=x,t.eqlBasename=function(e,t){return D(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return D(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return D(S.toNativePath_,e,t)},t.toPathnames=k,t.pathIsRoot=O,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:k(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const r=(0,S.toNativePath_)(e),i=(0,S.toNativePath_)(t);if((0,u.blank)(r)||(0,u.blank)(i))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return r===i?"":(0,p.stripPrefix)((0,v.native2posix)(i).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(r),"/").normalize()).normalize()},t.ellipsizePath=I,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:r=4,arrLength:i=e.length}){const n=[];for(const i of e.slice(0,r))n.push(I({p:i,maxLength:t}));return n.join(", ")+(i>r?`, and ${i-r} more…`:"")},t.posixPathFromParent=function(e){return k(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return k(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const r=C(e);return`${r.base}${t}${r.ext}`},t.isUNC=F,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(F(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(O(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await n.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;n.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>n.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=A,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:A(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>x({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(31586),u=r(51926),c=r(12168),d=r(59455),h=r(54993),f=r(50213),m=r(44198),p=r(96706),g=r(45969),y=r(43334),v=r(64660),w=r(21144),S=r(16287),b=(0,s.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const r=await(0,S.statMaybe)(e,"trace");return null!=r&&r.isFile()&&(0,l.gte)(r.size,t)&&(0,v.isStatRX)(r,e)}function E(){if(y.isWin){const e=(0,a.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,a.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",r=(0,a.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,n.default.join(e,"System32"),n.default.join(e,"System32","Wbem"),n.default.join(r,"chocolatey","bin"),n.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(n.default.delimiter);return(0,o.uniq)((0,o.compactBlanks)([...e,...E()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:r}){const i=(0,o.uniq)((0,o.compactBlanks)([...M(),...(0,d.toA)(r)]));for(const r of(0,o.uniq)((0,o.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(r,".exe"):r;for(const t of i){const r=n.default.join(t,e);if(await _(r))return y.isLinux?r:(0,w.actualPath)(r)}}b().warn("Failed to find tool",{tool:e,dirs:i})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},78133:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const n=i(r(76760)),s=r(22573),o=r(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(n.default.sep===n.default.posix.sep)return e;const r=(0,s.notBlank)(t)?n.default.sep+n.default.sep+t+n.default.sep:"",i=e.split(n.default.posix.sep);return(0,o.equalsIgnoreCase)(i[0],t)&&i.unshift(),r+i.join(n.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||n.default.sep===n.default.posix.sep||n.default.posix.sep===n.default.sep?e:e.split(n.default.sep).join(n.default.posix.sep)}},43899:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(48884),u=r(50213),c=r(45969),d=r(29325),h=r(43334),f=r(65843),m=r(25675),p=r(53265);function g(...e){return(0,o.lazy)((()=>n.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,o.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(n.default.join((0,p.execDir)(),"resources"),n.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,a.compactBlanks)([(0,p.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const r of t){if((0,f.hasChildrenSync)(r,e))return r;for(const t of(0,f.ancestors)(r).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const i=n.default.join(r,"node_modules","photostructure");if((0,f.hasChildrenSync)(i,e))return i}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const i=r(44652),n=r(19851),s=r(31586),o=r(50213),a=r(57902),l=r(69428),u=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=a.LogLevels.info){try{return await(0,i.readFile)(e)}catch(r){return void u().log(t,".readFileMaybe("+e+")",r)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const i=r(44652),n=r(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:r}){let s=-1;try{const n=r??(await(0,i.stat)(e)).size-t,o=Buffer.alloc(n);return s=await(0,i.open)(e,"r"),await(0,i.read)(s,o,0,n,t)}finally{(0,n.mapGte0)(s,i.close)}}},69428:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const o=s(r(73024));t.readFileSync=function(e){try{return o.readFileSync(e)}catch{}}},32323:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const i=r(57075);class n extends i.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=n},65238:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const n=i(r(51455)),s=r(76760),o=r(19851),a=r(76790),l=r(22573),u=r(42659),c=r(41400),d=r(31586),h=r(13538),f=r(83104),m=r(54127),p=r(50213),g=r(95937),y=r(34102),v=r(28874),w=r(63870),S=r(88561),b=r(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,o.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,o.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await n.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const E=(0,o.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||E.prior()?.delete(e)}async function C(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await E().getOrSetAsync(e,(()=>async function(e){const r=Date.now()+2*(0,b.statTimeoutMs)(),i=T(e),n=await(0,h.thenOrTimeout)(i,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(n===f.Timeout&&(0,g.onTimeout)({soft:!1}),n!==f.Timeout&&n.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),E.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,o.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!E().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=E().get(e)},t.childDirectories_=async function(e){return(await C(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?C(e):T(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=C,t.readdirCached=function(e){return E().get(e)},t.readdirUncached_=T},53265:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const n=r(73024),s=i(r(76760)),o=r(40958),a=r(22573),l=r(45599),u=r(50213),c=r(43334),d=r(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,o.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const r=s.default.resolve(t,...e);if((0,n.existsSync)(r))return r}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,a.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(a.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},50274:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const i=r(50989);t.SidecarExts=(0,i.strEnum)("xmp","mie","exv")},14427:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const i=r(22573),n=r(38639);t.isSimpleDirent=function(e){return null!=e&&(0,i.notBlank)(e.basename)&&(0,n.isBoolean)(e.isFile)&&(0,n.isBoolean)(e.isDirectory)}},17217:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const n=i(r(73024)),s=i(r(76760)),o=r(22573),a=r(98553),l=r(81168),u=r(43334),c=r(29882),d=r(53265),h=r(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,o.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,o.blank)(e.nativePath))throw new Error(`toNativePath(${(0,a.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof n.default.Dirent?e.name:f(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:s.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),r=t.indexOf(s.default.sep);return r>0?t.slice(1,r):void 0}},t.findFileIndex=function(e,t){for(let r=0;r(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,a.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(n.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,a.blank)(e)?void 0:v(e).catch((r=>{y().log(t,"stat() failed",{error:r,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const r=S(e),i=S(t);if(r!==i)return"inconsistent file type: "+r+" ≠ "+i;for(const r of["size","mtime"]){const i=e[r],n=t[r],s=(0,u.diff)(b(i),b(n));if(null==s||s>1)return"unmatched "+r+": "+i+" ≠ "+n}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const r=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=r&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(r)},t.isNonEmptyFile=async function(e,t=0){const r=await w(e);return null!=r&&r.isFile()&&r.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.access)({stat:r,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.isStatRWX)(r,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,o.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const n=i(r(73024)),s=r(22573);function o(e){try{return(0,s.blank)(e)?void 0:n.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function a(e){return null==e||e.isFile()&&0===e.size}t.statSync=o,t.isEmptyStats=a,t.isFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const r=o(e);return t.emptyIsNew?null==r:a(r)},t.isNonEmptyFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isDirectorySync=function(e){return!0===o(e)?.isDirectory()}},41080:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const i=r(28874);t.statTimeoutMs=function(){return i.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const i=r(22573),n=r(56409);t.onDataChunked=function(e,t,r){const i=new s(t,r,!0);return i.read(e),i.done};class s{constructor(e,t,r=!0){this.sep=e,this.onData=t,this.filterBlanks=r,this.incompleteChunk="",this.done=new n.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,i.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,i.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const n=i(r(57075)),s=r(41400),o=r(55835),a=r(68708),l=r(42279),u=r(99331),c=r(70025);class d extends n.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((r,i)=>{!1===e.write(t,(e=>{e&&i(e)}))?e.once("drain",r):r()}))},t.endStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,a.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:r,ea:i}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,o.map)(i,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(r,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends n.default.Transform{constructor(e){super({transform:(e,t,r)=>{this.onProgress(this.bytes+=e.length),r(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const n=i(r(73024)),s=r(76760),o=r(22573),a=r(76596),l=r(64660),u=r(78133),c=r(68284);function d(e){if((0,o.blank)(e))return!1;try{return n.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,a.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,o.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,o.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,o.blank)(e)&&d((0,u.posix2native)(e))}},27794:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const n=i(r(44652)),s=r(19851),o=r(22573),a=r(42659),l=r(31586),u=r(68708),c=r(13538),d=r(29882),h=r(17217),f=r(16287),m=r(41080);function p(e){return null==e?void 0:(0,a.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const r=t.ensureFile??!0;if(null==t.file||(0,o.blank)(t.file))throw new Error("can't touch blank path");const i=(0,h.toNativePath_)(t.file);r&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const a=(0,s.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await a())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await a())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(n.default.utimes(i,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!r||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(n.default.ensureFile(i),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},5545:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const n=i(r(76760)),s=r(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const r=t.driveRe.exec(e)?.groups;return null==r?e:r.drive.toUpperCase()+(0,s.toS)(r.path??n.default.sep)}},58722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const i=r(57075),n=r(22911);class s extends i.Writable{constructor(e){super(e),this.deferred=new n.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,r){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),r()}}t.WritableToBuffer=s},73428:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(51926),a=r(54993),l=r(34102),u=r(84542),c=r(29882);async function d(e,t){const r=s.default.dirname(e);await(0,c.mkdirp_)(r),await n.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",r)}function h(e,t){const r=s.default.dirname(e);(0,c.mkdirpSync_)(r),n.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",r)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const r=(0,u.crlf)(...(0,o.wrap)(t));await d(e,r)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))}},13047:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const n=i(r(73024)),s=r(76760),o=r(46466),a=r(38522),l=r(19851),u=r(40958),c=r(98553),d=r(80875),h=r(50213),f=r(57159),m=r(29882),p=r(57902),g=r(32323),y=r(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,r){const i=[],s=[n.default.createReadStream(e,{autoClose:!0,...r}).on("error",(e=>i.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,a.createGunzip)().on("error",(e=>i.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,a.createBrotliDecompress)().on("error",(e=>i.push(e)))),s.push(t),await(0,o.pipeline)(s),(0,u.isNotEmpty)(i))throw new f.WrappedError("zPipe("+e+") failed",{causes:i,path:e})}async function b(e,t){const r=new y.WritableToBuffer;return await S(e,r,t),await r.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function _(e,t){const r=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,o.pipeline)(new g.ReadableBuffer(r),(0,a.createGzip)(),n.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(r){return void v().log(t,"readJsonGz("+e+"): failed",r)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,r=p.LogLevels.warn){try{await _(e,t)}catch(t){v().log(r,"outputJsonGz("+e+"): failed",t)}}},33866:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const i=r(50989);t.HealthCheckIds=(0,i.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},52086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const i=r(50989);t.CropStrategies=(0,i.strEnum)("center","entropy","attention")},48584:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const i=r(50989);t.SharpFailOns=(0,i.strEnum)("none","truncated","error","warning")},32105:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const i=r(19851),n=r(23560),s=r(66184),o=r(72210);class a{log(e,t,r,i){this.enabled(e,t)&&(0,o.pushLogEntries)({ts:Date.now(),l:e,from:(0,n.processName)(),ctx:t,msg:r,meta:i})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=a,a.instance=(0,i.lazy)((()=>new a))},14593:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const i=r(57975),n=r(22573),s=r(26905),o=r(55835),a=r(68708),l=r(13538),u=r(50213),c=r(97352),d=r(45255),h=r(76740),f=r(57159),m=r(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,n.toNotBlank)(e)??(0,s.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[i.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const r=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,a.omit)(t,"error")});throw Error.captureStackTrace?.(r),this.log(!0===r.ignorable?"warn":"error",".throw() "+r.message,{stack:r.stack,...t}),r}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let r;try{r=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const i=e.result(),n=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:i,meta:{...e.meta,elapsedMs:n}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,o.map)(r,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,a.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const r of this.loggers())if(r.enabled(e,t??this.context))return!0;return!1}log(e,t,r){for(const i of this.loggers())i.log(e,this.context,t,r)}elapsed(e,t,r){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...r})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},28981:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const i=r(19851),n=r(51879);t.DefaultLogFormatter=(0,i.lazy)((()=>new n.PlaintextLogFormatter))},20839:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},4904:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const i=r(76790),n=r(31586),s=r(51926),o=r(57902);t.isLogEntry=function(e){return null!=e&&(0,n.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&o.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,i.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const i=r(19851),n=r(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,n.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,n.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,i.lazy)((()=>new s(n.LogLevels.warn))),t.defaultLogLevel=(0,i.lazy)((()=>n.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,n.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,r){return(0,t.logFilter)().enabled(e)?r():void 0},t.isLogged=function(e,r){return(0,t.logFilter)().enabled(e,r)}},57902:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const i=r(42659),n=r(31586),s=r(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const o=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??o},t.levelGte=function(e,r){return(0,n.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(r))};const a=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return a.get(e)},t.msTolevel=function(e,t=7*i.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},72210:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const i=r(92322),n=r(82328),s=r(28981),o=r(20839),a=r(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new i.SortedSet(a.logEntrySorter),t.pushLogEntries=function(...e){for(const r of e)l?t.logEntries.add(r):(0,n.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(r))},t.popExpiredLogEntries=function(e=2*o.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},51879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(68708),a=r(54993),l=r(23560),u=r(81168),c=r(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,o.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,n.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,i.inspect)(e,this.inspectOptions)))]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,r,i){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:r,meta:i})}}},82647:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const o=r(57975),a=r(40958),l=r(96249),u=r(55835),c=r(31586),d=r(68708),h=r(59455),f=r(48884),m=r(89788),p=r(22454),g=r(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const r=t.clone();return r.pushAll(e.samples),r}if(t.n<=t.maxSamples){const r=e.clone();return r.pushAll(t.samples),r}{const r=new y(Math.max(e.maxSamples,t.maxSamples));r._n=e.n+t.n,r._min=Math.min(e._min,t._min),r._max=Math.max(e._max,t._max),r._m=e._m*e.n/r.n+t._m*t.n/r.n,r._s=e._s*e.n/r.n+t._s*t.n/r.n;const i=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return r._samples.push(...i),r._weightedTotalAvg=(0,g.weightedAvg)([r._m,...i]),r}}constructor(e=20){i.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(i=new WeakSet,o.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),r={};return r.k=t(this.n),this.empty||(r.mean=t(this.avg),r.sum=t(this.sum),r.sd=t(this.stdDev),r.max=t(this.max),r.min=t(this.min)),r}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,i,"m",n).call(this,-1)}get p29(){return s(this,i,"m",n).call(this,-.5)}get p38(){return s(this,i,"m",n).call(this,-.25)}get p69(){return s(this,i,"m",n).call(this,.5)}get p84(){return s(this,i,"m",n).call(this,1)}get p98(){return s(this,i,"m",n).call(this,2)}get p99(){return s(this,i,"m",n).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,a.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,a.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,a.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,n=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const i=r(40958),n=r(55835),s=r(31586),o=r(30976),a=r(48884),l=r(70417);function u(e,t){const r=Math.pow(2,t),i=[];for(;e>0;)i.unshift(e%r),e=Math.floor(e/r);return i}t.concatBits=function(e,t){const r=Math.pow(2,t);return e.reduce(((e,t)=>e*r+(0,s.clamp)(0,r,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,r){return(0,n.map2)(e,t,((e,t)=>(0,i.sum)((0,a.zip)(u(e,r),u(t,r)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,o.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max)),n=this.clampValue(e);let s=0;for(let e=0;eo?(s+=1,r[t]=o):i[t]=o}return s}unzip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max));for(let n=0;n(r[e]+i[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,r){return!0!==r&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let r=0;rs?(t+=1,n.min=s):n.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const r=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,i.sum)(e,((r,i)=>t(r,i)?Math.pow(2,e.length-i-1):0))}},55222:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const i=r(77598),n=r(22573),s=r(55835),o=r(32639),a=r(88158),l=r(81168),u=BigInt(0);function c(e,t,r=0){if(!isFinite(t)||e<=1)return[];const i=[];if(0===t)i.unshift(0);else for(;t>0;)i.unshift(t%e),t=Math.floor(t/e);for(;i.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const r=e<0;return r&&(e=Math.abs(e),t--),(r?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],r=BigInt(this.base);let i=e;for(;i>u;)t.push(Number(i%r)),i/=r;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let r of e)for(t.forEach(((e,i)=>{r+=e<<8,t[i]=r%this.base,r=Math.floor(r/this.base)}));r>0;)t.push(r%this.base),r=Math.floor(r/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,n.blank)(e))return;const t="-"===(e=(0,o.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const r=BigInt(this.base);let i=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;i=i*r+BigInt(e)}return t?BigInt(-1)*i:i}randomChars(e){return this.encodeBuffer((0,i.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,r="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(r)}tokenEql(e,t,r){const i=this.normalizeToken(e),n=this.normalizeToken(t);return i.length>=r&&i===n}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const i=r(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,i.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},70417:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const a=r(40958),l=r(55835),u=r(31586),c=r(59455),d=r(22454),h=r(77377),f=r(82647);function m(e){let t;for(const r of e)null!=r&&(null==t||rt)&&(t=r);return t}function y(e,t){const r=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&r.incr(t);return r.topKeys(t)}function v(e,t){let r=0,i=0;for(const n of e){if(null!=n){const e=t(n,r);(0,u.isNumber)(e)&&(i+=e)}r++}return i}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,r)=>e-t[r]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const r of e)(0,u.isNumber)(r)&&(t+=r);return t},t.sumf=v;class w{constructor(){i.set(this,0),n.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(o(this,n,null==s(this,n,"f")?e:s(this,n,"f")*s(this,i,"f")/(s(this,i,"f")+1)+e/(s(this,i,"f")+1),"f"),o(this,i,(t=s(this,i,"f"),++t),"f"))}get mean(){return s(this,n,"f")}}function S(e){const t=new w;for(const r of e)t.push(r);return t.mean}function b(e){const t=S(e);if(null==t)return;let r=0,i=0;for(const n of e)(0,u.isNumber)(n)&&(i++,r+=(n-t)*(n-t));return r/i}function P(e){let t=0;for(const r of e)t+=r*r;return Math.sqrt(t)}function _(e,t){let r=0;for(let i=0;i(1-t)*e+t*(r+o*(e-n)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),r=S(t);if(null!=r){const e=(t.length-1)/2,i=v(t,((t,i)=>(t-r)*(i-e))),n=v(t,(e=>(e-r)**2));return 0===n?0:i/n}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let r;t=(0,u.clamp)(0,1,t);for(const i of e)r=null==r?i:r*t+i*(1-t);return r},t.centroid=function(e){const t=e[0].length,r=[];for(let i=0;ie[i]))));return r},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,a.isEmpty)(e)&&(0,a.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},45969:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const i=r(73024),n=r(38639),s=r(19851),o=r(59958),a=r(43334);t.isDocker=(0,s.lazy)((()=>a.isLinux&&((0,n.toBoolean)(process.env[o.PS_IS_DOCKER])??(0,i.existsSync)("/.running-in-container"))))},29325:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const i=r(76760),n=r(19851),s=r(54993);t.isPacked=(0,n.lazy)((()=>!(0,s.toS)(__filename).includes((0,i.join)("core","platform","IsPacked"))))},43334:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(22573),a=r(38639),l=r(59958),u=n.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,a.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,a.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,o.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===n.default.arch(),t.isArm=null!=/^arm\b/i.exec(n.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,o.notBlank)(s.default.env.APPIMAGE)||(0,o.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,o.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,a.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const n=i(r(73024)),s=r(19851),o=r(43334);function a(e="/proc/cpuinfo"){if(o.isWin||o.isMac)return!1;try{return null!=n.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=a,t.isRaspberryPi=(0,s.lazy)((()=>o.isLinux_arm&&a())),t.procDeviceModel=(0,s.lazy)((()=>{try{return o.isLinux?n.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},45643:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const i=r(58587),n=r(59455),s=r(31562);t.existingPids=function(e){return(0,n.toA)(e).filter(i.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,i.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=r(58587),d=u(r(31421)),h=u(r(1708)),f=r(40958),m=r(22573),p=r(42659),g=r(55835),y=r(31586),v=r(97790),w=r(59455),S=r(54993),b=r(54557),P=r(19851),_=r(50213),E=r(88158),M=r(409),C=r(78406),T=r(25764),x=r(99331),D=r(56519),k=r(46292),O=r(8769),I=r(83278),F=r(32144),A=r(29882),N=r(43334),L=r(24399),R=r(58261),j=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),B=10*p.secondMs;function V(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const r=(0,g.map)(t.start,(e=>e.getTime())),i=e.startTime;return(0,y.gt0)(r)&&(0,y.gt0)(i)&&Math.abs(r-i){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,F.isJsonExt)(t)&&(0,A.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))j().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{j().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,r=e.force??N.isWin,i=await this.pidfiles(),n=await this.pids(i??[]);if((0,f.isEmpty)(n))return j().info("killOldProcs(): no pidfiles"),[];const s=[],o=[],a=await(0,R.pidInfos)(n);if(null!=a){for(const n of i){const i=await n.readJson();if(null==i){j().warn("killOldProcs(): failed to read pidfile "+n.base),await n.unlink("debug");continue}const l=i.pid;if(!(0,y.gt0)(l)){j().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+n.base,{json:i,pid:l}),await n.unlink("debug");continue}const u=a.find((e=>e.pid===l));if(null==u||!V(i,u)){j().debug("killOldProcs(): pid no longer present: unlinking "+n.base,{json:i,pidEntry:u}),await n.unlink("debug"),s.push(i);continue}const c=(0,y.gt0)(i.timeoutMs)?i.startTime+i.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(i.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(j().info("killOldProcs(): killing",{reason:d,json:i}),o.push(W(l,r,!1)),s.push({...i,...u}))}return o.length>0&&await Promise.allSettled(o),s}(0,O.onError)("Pids.killOldProcs(): failed to get process information")}}),o.set(this,void 0)}async addPid_(e,t,r=!1){if(null==e)throw new Error("undefined info");const o=e.pid;if(!(0,y.gt0)(o))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(o)?(r&&a(this,n,"f").delete(l),a(this,n,"f").getOrSet(l,(async()=>{const r=a(this,i,"m",s).call(this,e.pid),n=(0,v.opt)((0,E.Try)((()=>(0,A.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),o=t.getTime(),l={...e,cmd:n,startTime:o};return await r.writeJson_(l),j().debug("addPid() wrote "+r,l),r}))):(a(this,n,"f").delete(l),void j().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=a(this,i,"m",s).call(this,e);return(0,D.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{j().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==a(this,o,"f")||a(this,o,"f").ended)&&l(this,o,new C.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:T.EndableRanks.first}),"f"),a(this,o,"f")}cancelInterval(){a(this,o,"f")?.end(),l(this,o,void 0,"f")}}t.Pids=q,n=new WeakMap,o=new WeakMap,i=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},q.instance=(0,P.lazy)((()=>(0,g.map)((0,k.configDir)(),(e=>new q(I.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return q.instance()?.addPid_(e,t)}},58261:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const n=r(31421),s=r(48161),o=i(r(1708)),a=r(40958),l=r(22573),u=r(42659),c=r(31586),d=r(68708),h=r(59455),f=r(54993),m=r(48884),p=r(53507),g=r(19851),y=r(50213),v=r(84968),w=r(48963),S=r(56519),b=r(84777),P=r(8103),_=r(45879),E=r(43334),M=r(24399),C=r(45643),T=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function x(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function D(e){if(E.isLinux)return async function(e){const t=[];for(const r of e)t.push(z(await(0,_.readFileMaybe)("/proc/"+r+"/stat")));return T().tap({msg:"pidInfoProc",result:(0,a.compact)(t)})}(e);const t=(0,C.existingPids)(e),r=(await(0,m.collectBatchedAsync)(t,20,E.isWin?F:R)).filter((e=>x(e)&&t.includes(e.pid)));return T().tap({msg:"pidInfos()",result:r,meta:{pids:e}})}t.isProcEntry=x,t.pidInfo=async function(e){return(0,S.thenMap)(D([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,a.isEmpty)(e)?[]:(0,S.thenMap)((0,C.existingPids)(e),(t=>{const r=[o.default.pid,...t];return e.filter((e=>!r.includes(e)))}))},t.pidInfos=D;const k="Get-Process",O="| Select-Object -Property Id,ProcessName,StartTime";function I(e){return(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).join(",")}async function F(e){if(M.PowerShell.instance().ended)return L(e);const t=[k,"-Id",I(e),"-ErrorAction SilentlyContinue",O].join(" ");return(0,S.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const A={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},N=["CommandLine","CreationDate","ProcessId"];async function L(e){const t=["process"];if((0,a.isNotEmpty)(e)){const r=(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",r)}t.push("get",N.join(","));const r=await(0,b.stdoutResult_)((0,P.wmic)(),t,A),i=(0,d.onlyReqValued)((0,p.parseFixed)(N,r.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return i.find((e=>e.pid===o.default.pid))||i.push({pid:o.default.pid,start:new Date(v.StartTs),cmd:"node "+o.default.title}),i}async function R(e){return t=(await(0,b.stdoutResult_)("ps",["-p",I(e),"-wwwo","pid,lstart,command"],{...A,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=L;const j=(0,g.lazy)((()=>{try{if(E.isLinux)return(0,c.toGt0)((0,n.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){T().warn("clk_tck failed",{error:e})}return 100})),B=(0,g.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),V=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function z(e){const t=V.exec((0,f.toS)(e))?.groups,r=(0,c.toInt)(t?.pid),i=t?.comm,n=(0,c.toInt)(t?.starttime);return(0,c.gt0)(r)&&!(0,l.blank)(i)&&(0,c.gt0)(n)?{pid:r,cmd:i,start:new Date(B()+n/j()*u.secondMs),state:t?.state}:void 0}},24399:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const i=r(58587),n=r(19851),s=r(22573),o=r(42659),a=r(41400),l=r(55835),u=r(13538),c=r(36557),d=r(14121),h=r(50213),f=r(7282),m=r(45255),p=r(81168),g=r(25764),y=r(38836),v=r(99331),w=r(56519),S=r(31562),b=r(84777),P=r(34102),_=r(43334),E=r(28874),M=r(63870),C="{ready}",T=" | ConvertTo-Json -Compress";function x(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=x,(0,a.later)((()=>(0,P.ee)().on("clearCache",(()=>D.instance.prior()?.clearMockResults()))));class D extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new i.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",E.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${C}"}`,...(0,s.mapNotBlankOr)(E.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:C,fail:"Error",exitCommand:"exit",maxProcs:E.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:o.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),E.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(E.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,T),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const r=this.mockResults.get(e);return t(r.stdout,r.stderr,r.passed)}try{const r=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new i.Task(e,((r,i,n)=>t((0,l.map)(r,(t=>(0,p.stripPrefix)(t,e))),i,n)))));return this.logger.tap({msg:"execute()",result:r.result,meta:{elapsedMs:r.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,T),((e,t,r)=>({stdout:e,stderr:t,passed:r})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const r=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(r)}),JSON.parse(r)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+x(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=D,D.instance=(0,n.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new D})),t.checkPowerShell_=async function(){const e=D.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const i=r(50989);t.AggregateTypes=(0,i.strEnum)("union","intersection")},71988:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const i=r(50989);t.AssetFileSortCriteria=(0,i.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const i=r(22573),n=r(38639),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toBoolean})}}t.BooleanSetting=o},90536:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=a},75164:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(i.notBlank).flatMap(n.toInt).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,n.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=a},10546:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const i=r(50989);t.ColorDistanceFunctions=(0,i.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const i=r(36507),n=r(22573),s=r(45599),o=r(50213),a=r(81168),l=r(98314),u=r(8769),c=r(80372),d=(0,s.defer)((()=>(0,o.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,a.trimQuotes)(e);return void((0,n.blank)(t)||(0,i.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,r){try{return(0,n.blank)(t)?void 0:(0,i.Cron)(t,{name:e,unref:!0,protect:!0,catch:r=>(0,u.onError)(r,{name:e,crontab:t}),...r})}catch(r){return void d().warn("invalid cron",{name:e,crontab:t,error:r})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const i=r(70488),n=r(91655),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration})}get valueOrDefault(){return(0,i.decodeDuration)(super.valueOrDefault)}get value(){return(0,i.decodeDuration)(super.value)}set value(e){super.userValue=(0,i.decodeDuration)(e)}get humanValue(){return(0,n.fmtFullDuration)(this.value)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,i.decodeDuration)(e)}}t.DurationSetting=o;class a extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,i.decodeDuration)(this.defaultValue)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=a},9945:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.FloatSetting=o},74589:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt})}}t.IntegerSetting=o},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const i=r(22573),n=r(53265),s=r(87652);class o extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,i.blank)(e)?void 0:(0,n.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=o},23561:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.OptionalFloatSetting=o},69005:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=o},87652:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=n},28283:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const i=r(51926),n=r(83556);t.nameFromEnv=function(e){return(0,n.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,i.ensurePrefix)((0,n.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const o=r(19851),a=r(40958),l=r(79666),u=r(50357),c=r(57924),d=r(98553),h=r(55835),f=r(68708),m=r(39926),p=r(46891),g=r(42279),y=r(59455),v=r(40583),w=r(81168),S=r(44198),b=r(96706),P=r(34102),_=r(28283),E=r(81075),M=r(98778),C=r(10357);t.settingsToObj=function(e){const t={};for(const r of e)r.hasValue()&&(t[r.name]=r.value);return t},t.Setting=class{constructor(e){i.add(this),this.opts=e,this._envValue=(0,o.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,i,"m",n).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const r=this.opts.whyInvalid?.(e);return null!=r?s(this,i,"m",n).call(this,e??t)+": "+r:null==this.fromEnv(e)?s(this,i,"m",n).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const r=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=r)return r}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,a.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const r=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(r)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,a.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,a.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return E.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const r=e??(0,S.env)(),i=t??this.value;return null!=i&&(r[this.key]=this.toEnv(i)),null==e&&b.caseInsensitiveEnv.unset(),r}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const r=e??(0,S.env)(),i=this.toEnvValue(t);return null!=i&&(r[this.key]=i,null==e&&b.caseInsensitiveEnv.unset()),r}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],C.WrapComments);function r(e,r){(0,a.isEmpty)(r)||t.push(...(0,w.wrap)(["",(1===r.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(r.map((e=>(0,d.stringify)(e))))],C.WrapComments))}r("alias",this.opts.aliases),r("environment alias",this.altKeys);for(const[e,r]of(0,f.entries)(this.addToJSON())){const i=Array.isArray(r)?(0,c.orList)(r.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(r);t.push(...(0,w.wrap)(["",e+": "+i],C.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},i=new WeakSet,n=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const i=r(50989);t.SettingCategories=(0,i.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const i=r(58587),n=r(76760),s=r(19851),o=r(40958),a=r(76790),l=r(22573),u=r(42659),c=r(73722),d=r(68708),h=r(50989),f=r(12168),m=r(54993),p=r(37975),g=r(9092),y=r(40583),v=r(79840),w=r(7282),S=r(12801),b=r(4328),P=r(70488),_=r(84248),E=r(5531),M=r(99315),C=r(34365),T=r(34580),x=r(96706),D=r(50274),k=r(33866),O=r(52086),I=r(48584),F=r(45969),A=r(43334),N=r(24540),L=r(70379),R=r(71300),j=r(33209),B=r(48987),V=r(68268),z=r(61208),W=r(99023),q=r(30577),U=r(1485),H=r(19861),G=r(55111),J=r(30933),K=r(22859),$=r(71988),Y=r(38483),Z=r(90536),X=r(75164),Q=r(10546),ee=r(90967),te=r(67958),re=r(55948),ie=r(57039),ne=r(9945),se=r(74589),oe=r(844),ae=r(96093),le=r(23561),ue=r(69005),ce=r(87652),de=r(81075),he=r(58305),fe=r(57571),me=r(72564),pe=r(80372),ge=r(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new ae.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>U.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:U.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>U.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>A.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,F.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!A.isElectron}),commandTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new i.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>A.isMac?"100ms":A.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new ne.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:E.CheckpointTypes,defaultValue:E.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:C.SynchronousModes,defaultValue:C.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 1 minute is very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"1m"}),dbBackupIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,F.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:k.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>A.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:q.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,T.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,N.isRaspberryPi)()}),taskTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,J.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:D.SidecarExts,defaultValue:D.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:K.AggregateTypes.intersection,strEnum:K.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new ne.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:re.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,J.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:O.CropStrategies.attention,strEnum:O.CropStrategies}),videoFrameAtSec:new ne.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,o.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(A.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:$.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>j.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:I.SharpFailOns.truncated,strEnum:I.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>B.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:oe.MinValidYear}),maxValidFutureMs:new ie.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new ne.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:L.DateTagFormats.ym,strEnum:L.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:V.KeywordReparentingStrategies.move,strEnum:V.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:z.NameTagFormats["as-is"],strEnum:z.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,F.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,r]of(0,d.entries)(t.Settings))r._setName(e);function Se(e){const r=((0,l.blank)(e)?"":e).split(n.delimiter);return(0,F.isDocker)()&&r.unshift("/opt/photostructure/tools/bin"),r.push(...t.Settings.toolPaths.valueOrDefault),(0,o.uniq)(r).filter(l.notBlank).join(n.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,x.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,a.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const r of(0,t.persistedSettings)()){for(const t of r.names)e.set(t,r);for(const t of r.keys)e.set(t,r)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const i=r(19851),n=r(31586),s=r(7282),o=r(49776),a=r(46292),l=r(32774),u=r(55086),c=r(46296),d=r(55939),h=r(96706),f=r(83278),m=r(92234),p=r(45969),g=r(60865),y=r(30933),v=r(15674),w=r(28874);t.setSettingsDefaults=(0,i.lazy)((()=>{w.Settings.configDir.opts.defaultValue=a.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=o.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,n.sigFigs)(50/(0,y.cpuCount)(),2)}))},84438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const i=r(76760),n=r(40958),s=r(22573),o=r(98553),a=r(55835),l=r(59455),u=r(83179);function c(e){return null==e?void 0:(0,o.stringify)(e)}t._join=c;function d(e){return(0,a.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,n.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",i.delimiter])if(t.includes(e))return(0,n.compactBlankish)(t.split(e));return[t]}}(e),n.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,n.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,n.isEmpty)(e)||(this.value=this.toValidValues((0,n.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,n.isEmpty)(this.values)}isNotEmpty(){return(0,n.isNotEmpty)(this.values)}toNotEmpty(){return(0,n.toNotEmpty)((0,n.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=n},72564:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const i=r(40958),n=r(98553),s=r(55835),o=r(58305);class a extends o.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,n.stringify)((0,i.uniq)(e)))),fromEnv:t=>{return r=t,n=e.strEnum,(0,i.compact)((0,o.splitStringArray)(r)?.map((e=>n.getCI(e))));var r,n},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=a},80372:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const i=r(22573),n=r(81168),s=r(83179);class o extends s.Setting{constructor(e){super({toEnv:a,fromEnv:a,...e})}hasValue(){return(0,i.notBlank)(this.value)}}function a(e){return null==e?void 0:(0,n.trimQuotes)(e)}t.StringSetting=o},32707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const i=r(76760),n=r(55835),s=r(46292),o=r(84438);t.systemSettingsFile=function(){return(0,n.map)((0,s.configDir)(),(e=>(0,i.join)(e,o.SettingsToml)))}},80496:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const i=r(50989);t.TagInferenceSettingValues=(0,i.strEnum)("never","always","auto")},6707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const i=r(90858),n=r(44652),s=r(22573),o=r(76850),a=r(50213),l=r(81168),u=r(84542),c=r(17217),d=r(68284),h=r(98778);function f(e){return t=(0,o.debom)(e),(0,s.blank)(t)?void 0:(0,i.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,n.readFileSync)(t)):void 0}catch(e){return void(0,a.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>f(await(0,n.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,n.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const i=r(22573),n=r(96249),s=r(98553),o=r(68708),a=r(51926);function l(e,t,r){if((0,i.blank)(e))throw new Error("kvToToml(): Blank key");const n=e+" = "+(0,s.stringifyPretty)(t);return(0,i.blank)(r?.prefix)?[n]:(0,a.wrap)(n.split("\n"),r)}t.stringifyToml=function(e){return(0,n.flatten)((0,o.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,i.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,a.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},10357:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},65162:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const i=r(4001),n=r(81168);t.bname=function(e,t=!0){let r=(0,n.isString)(e)?e:e.name;return t&&(r=(0,i.stripCopySuffixFromName)(r)),r=(0,n.trimLeftPadding)((0,i.stripDSC)(r)),r.toLowerCase().normalize()}},70379:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const i=r(50989);t.DateTagFormats=(0,i.strEnum)("y","ym","ymd","")},71300:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},68268:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const i=r(50989);t.KeywordReparentingStrategies=(0,i.strEnum)("move","copy","retain")},61208:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const i=r(50989);t.NameTagFormats=(0,i.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const i=r(50989);t.NameTagOrders=(0,i.strEnum)("western","eastern")},60865:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const i=r(37805),n=r(30577);t.channel=function(){return(0,n.extractUpdateChannel)(i.version)},t.baseVersion=()=>[i.versionMajor,i.versionMinor,i.versionPatch].join("."),t.versionMajorMinor=i.versionMajor+"."+i.versionMinor},30577:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const i=r(50989);t.UpdateChannels=(0,i.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const r of t.UpdateChannels.values)if(e.includes("-"+r))return r;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},1485:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const i=r(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,i.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},69375:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const i=r(19851),n=r(22573),s=r(50213),o=r(9103),a=r(7282),l=r(29882),u=r(43334),c=r(28874),d=(0,i.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,n.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,a.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,a.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,a.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,a.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,n.blank)(e))return"blank";const t=(0,l.toPathnames)(e),r=t[0],i=t[t.length-1];return c.Settings.excludedRootDirectories.has(r)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(i)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===r&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,o.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},63870:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const i=r(42659),n=r(12168),s=r(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=n.MiB/i.secondMs},55111:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const i=r(50989);t.HelmetPlugins=(0,i.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},30933:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const n=i(r(48161)),s=r(19851),o=r(42659),a=r(31586),l=r(50213),u=r(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>n.default.cpus()),5*o.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=n.default.availableParallelism?.(),r=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,a.clamp)(1,128,Math.ceil(e??r)),meta:{availableParallelism:e,cpuInfoLength:r}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const n=i(r(48161)),s=r(19851),o=r(31586),a=r(12168),l=r(50213),u=r(45879),c=r(70417),d=r(45969),h=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=n.default.freemem(),t=n.default.totalmem(),r=(2*e+t)/3;if((0,d.isDocker)()){const i=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,o.gt0)(i))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([i,r]),meta:{freemem:e,totalmem:t,cgroupMem:i}})}return h().tap({msg:"estimatedFreeMem() ",result:r,meta:{result:(0,a.fmtBytes)(r),freemem:(0,a.fmtBytes)(e),totalmem:(0,a.fmtBytes)(t)}})}))},15674:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const i=r(19851),n=r(42659),s=r(41400),o=r(31586),a=r(12168),l=r(50213),u=r(7282),c=r(34102),d=r(57902),h=r(28874),f=r(30933),m=r(58444),p=r(22751),g=(0,i.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,i.lazy)((()=>{const e=(0,o.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*a.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/a.MB),worstCaseMemPerProcMb:Math.ceil(e/a.MB)}})}),n.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,r=0===e||0===t?1:(0,o.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:r>1?d.LogLevels.warn:d.LogLevels.debug,result:r,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,o.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,f.cpuCount)())<=1},t.maxCpus=(0,i.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,f.cpuCount)())-1);let t=e;const r=p.timeoutRate.prior()?.eventsPerMinute??0,i=w();if(1!==i){const e=t;t*=i,g().warn("Recent timeouts! Throttling down.",{penalization:i,resultBeforePenalization:e,resultAfterPenalization:t})}const n=Math.min(e,v());return t=(0,o.clamp)(1,n,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:i,timeoutsPerSecond:r,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,i.lazy)((function(){return(0,o.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,o.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,o.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},22751:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const i=r(58587),n=r(87997),s=r(19851),o=r(42659),a=r(41400),l=r(50213),u=r(7282),c=r(45255),d=r(34102),h=r(976),f=r(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new i.Rate(5*o.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,s.lazy)((()=>(0,n.setInterval)(g,o.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,a.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const i=r(76790),n=r(22573),s=r(50357),o=r(98553),a=r(49769),l=r(34666),u=r(30976),c=r(42279),d=r(32639),h=r(59455),f=r(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,r)=>e===t[r]))}function v(e,t){for(let r=0;r=e.length||r>=e.length)return e;const i=e[t];return e.splice(t,1),e.splice(r,0,i),e}function S(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&(0,a.getOrSet)(r,e,(()=>i))}return[...r.values()]}function P(e,t,r=1,i=(e=>e)){const n=[];if(et;s-=r)n.push(i(s));return n}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,r){return m(e)?t(e):(0,c.tot)(r)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let r=0;rt.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const r of t)if(!e.includes(r))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const r=(0,i.sortBy)(e,g),n=(0,i.sortBy)(t,g);return r.every(((e,t)=>e===n[t]))},t.pushUniq=function(e,...t){for(const r of t)null==r||e.some((e=>(0,s.eql)(e,r)))||e.push(r);return e},t.pushUniqBy=function(e,t,r){const i=e.map(r);for(const n of t){const t=r(n);i.includes(t)||(e.push(n),i.push(t))}return e},t.insertAt=function(e,t,...r){return e.splice(t,0,...r),e},t.insertUniq=function(e,t,r){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let i=0;i0)return e.splice(i,0,t),e}return e.push(t),e},t.remove=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),r!==e.length},t.removeSame=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>e!==t)))),r!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(n.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,o.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const r of e)null==r||(0,s.eql)(t[t.length-1],r)||t.push(r);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const r=[];for(const e of(0,i.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))r.some((t=>t.includes(e)))||r.push(e);return(0,i.sortBy)(r,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&r.set(e,i)}return[...r.values()]},t.uniqBy2=function(e,t){const r=[];for(const i of e)null!=i&&r.every((e=>!t(i,e)))&&r.push(i);return r},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,r,i)=>e+(t(r,i)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,r,i)=>e+t(r,i)),0)},t.firstMatch=function(e,t){for(const r of S(t)){const t=e.exec(r);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let r=0;for(;e[r]===t[r];)r++;return r},t.anneal=function({array:e,expense:t,allowedDelta:r}){const i=Math.round(r);if(i<2)return e;for(let r=0;re)){return P(e,t,1,r)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,o.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,r,i=t.primitiveValueOfOrElse){const n=new Set(r.map(i));return e.filter((e=>!n.has(i(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const i=r(40958),n=r(36783),s=r(41801),o=r(98553),a=r(49769),l=r(55835),u=r(34666),c=r(59455);function d(e,t){return(0,n.copyArrayTo)(f(e,t),e)}function h(e,t){const r=new Map;for(const i of e)(0,a.getOrSet)(r,(0,o.stringify)(t(i)),(()=>i));return f(r.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,l.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,i.compact)(e),i.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,n.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,r)=>0===r||t>=e[r-1]))},t.sortedBy=function(e,t){return e.every(((r,i)=>0===i||t(r)>=t(e[i-1])))},t.sortBy=f,t.deepSortBy=function e(t,r){return f(t,r).map((t=>(0,s.isIterable)(t)?e(t,r):t))},t.pushSorted=function(e,t,r){const i=e.findIndex((e=>r(t){Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const i=r(32639);t.asPromise=async function(e){const t=await e;return(0,i.isFunction)(t)?t():t}},5233:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const i=r(41400),n=r(31586),s=r(13538),o=r(41583);t.retryOnReject_=async function(e,t){const r=(0,n.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return r();const a=t.onRetryWaitUntil??(e=>(0,i.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await r()}catch(e){const r=(0,o.toErr)(e);if(!1===t.errorIsRetriable?.(r)||l>t.maxRetries)throw r;return l++,await a(l),u()}};return u()}},17586:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},22573:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const i=r(55835),n=r(42279),s=r(54993);function o(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function a(e){return!o(e)}function l(e,t){if(!1===e||null==e||""===e)return;const r=(0,s.toS)(e);return a(r)?t(r):void 0}t.blank=o,t.notBlank=a,t.notBlankToS=function(e){return a(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,n.tot)(t);const r=(0,s.toS)(e).trim();return r.length>0?r:(0,n.tot)(t)},t.notBlankAnd=function(e,t){return!o(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,r){return(0,i.orElse)(l(e,t),r)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{function r(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function i(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const r=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=r,t.toBoolean=function(e){return!!r(e)||!i(e)&&void 0},t.toNotBoolean=function(e){return!r(e)&&(!!i(e)||void 0)},t.boolToInt=function(e){return r(e)?1:0},t.isFalse=i,t.isDisabled=function(e){return i(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>r(e)))},t.and=function(e){return e.every((e=>r(e)))},t.maybeAnd=function(e){let t;for(const r of e){if(!1===r)return!1;!0===r&&(t=!0)}return t},t.mapBoolean=function(e,t){return r(e)?t(!0):i(e)?t(!1):void 0},t.mapTrue=function(e,t){return r(e)?t():void 0}},79666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const i=r(98553);t.clone=function(e){return null==e?e:JSON.parse((0,i.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const i=r(40958),n=r(22573),s=r(30301),o=r(55835),a=r(31586),l=r(39926),u=r(51926),c=r(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,o.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const r=p(e)?e.getTime():(0,a.isNumber)(e)?e:Date.now();return Math.floor(r/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,r={includeMs:!0}){const i=Math.floor(e/t.hourMs);e-=i*t.hourMs;const n=Math.floor(e/t.minuteMs);e-=n*t.minuteMs;const s=Math.floor(e/t.secondMs),o=Math.floor(e-s*t.secondMs);return(0,l.pad2)(i)+":"+(0,l.pad2)(n)+":"+(0,l.pad2)(s)+(r.includeMs?"."+(0,l.pad3)(o):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const r=()=>{const e=t%100;return t=Math.floor(t/100),e},i=10*r(),n=r(),s=r(),o=r(),a=r(),l=r();return new Date(t,l-1,a,o,s,n,i)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,r="ago"){return e<1e3?"just now":(r=(0,n.blank)(r)?"":(0,u.ensurePrefix)(r," "),et.ms<=e)))){const s=Math.floor(e/i.ms);e-=s*i.ms,s>0&&(i.ms>=t.dayMs?r:n).push(s+i.s)}return e>0&&n.push((0,a.toFixedStr)(e/t.secondMs,3)+"S"),"P"+r.join("")+((0,i.isEmpty)(n)?"":"T"+n.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,o.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const i=r(38639),n=r(73872);function s(e,t,r){if(null==r||y(e)||y(t))return null;const i=r.get(e)?.get(t);return"boolean"==typeof i?i:null}function o(e,t,r,i){if(null==r||y(e)||y(t))return;let n=r.get(e);null!=n?n.set(t,i):(n=new WeakMap,n.set(t,i),r.set(e,n))}function a(e,t,r,i){if(null!=r?.comparator)return u(e,t,r,i);const n=l(e,t);return null!==n?n:u(e,t,r)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,r,i){r??(r={});const u=!1===r.memoize?void 0:r.memoize??(r.memoize=new WeakMap),d=r?.comparator,f=s(e,t,u);if(null!==f)return f;const m=s(t,e,u);if(null!==m)return m;if(d){const r=d(e,t,i);if(!1===r||!0===r)return o(e,t,u,r),r;const n=l(e,t);if(null!==n)return n}const y=n(e);if(y!==n(t))return o(e,t,u,!1),!1;o(e,t,u,!0);const v=function(e,t,r,i){switch(r){case"String":case"Number":case"Boolean":case"Date":return a(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],i);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,i);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,r){return c(h(e),h(t),r)}(e,t,i);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),i);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),i);case"Set":case"Map":return function(e,t,r){if(e.size!==t.size)return!1;if(0===e.size)return!0;const i=[],n=[];return e.forEach((function(e,t){i.push([e,t])})),t.forEach((function(e,t){n.push([e,t])})),c(i.sort(),n.sort(),r)}(e,t,i);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,i)}}(e,t,y,r);return o(e,t,u,v),v}function c(e,t,r){const i=e.length;if(i!==t.length)return!1;if(0===i)return!0;let n=-1;for(;++n{Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,r,i=!1;const n=function(){if(i){if(null!=r)throw r;return t}try{return i=!0,t=e()}catch(e){throw r=e,e}};return n.prior=()=>t,n.hasPrior=()=>i,n}},41400:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const i=r(42659),n=r(35556),s=r(31586),o=r(68708);function a(e,t=!0){return new Promise((r=>{if(e<=0)r();else{const s=setTimeout((()=>r()),Math.ceil(e+.5));e>i.secondMs&&t&&n.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return a(t).then((()=>t))},t.delay=a,t.later=function(e,t=1){const r=Math.max(1,Math.ceil(t)),s=n.isNode&&r<=1?setImmediate(e):setTimeout(e,r);return n.isBrowser||t<=i.secondMs?s:(0,o.maybeCall)(s,"unref")??s}},50357:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const i=r(12487),n=r(68708),s=r(34666),o=r(32639);function a(e,t){return(0,i.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,o.isFunction)(e)&&(0,o.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=a,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return!1;for(const r of(0,n.keys)(e))if(!a(e[r],t[r]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,r){if(null==e||null==t)return e===t;if(null!=r){const i=d.get(r);if(null!=i)return i(e,t)??null}for(const r of c){const i=r(e,t);if(null!=i)return i}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(31586),a=r(68708),l=r(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,n.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,o.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const r=[];for(const t of e)null!=t&&(t instanceof Error?r.push(u(t),c(t),t?.message):r.push((0,l.toS)(t)));return(0,i.uniq)((0,i.compactBlankish)((0,s.flatten)((0,i.compact)(r).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,n.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const r=(0,l.toS)(e).split("\n").filter((e=>!(0,n.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,i.isEmpty)(r)?["(missing stack)"]:r}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,n.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(n.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,a.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,a.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,a.assignFields)(new Error,(0,a.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},96249:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const i=r(59455);t.flatten=function(e,t=[]){for(const r of(0,i.toA)(e))if(null!=r)for(const e of(0,i.toA)(r))null!=e&&t.push(e);return t}},57924:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const i=r(40958);function n(e,t){return null==(e=(0,i.uniq)((0,i.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=n,t.orList=function(e){return n(e,"or")},t.andList=function(e){return n(e,"and")}},73722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const i=r(50989);t.FitSizes=(0,i.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,i.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const i=r(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,r){if((0,i.lt0)(t))return[...e].slice(t,r);const n=e[Symbol.iterator]();if((0,i.gt0)(t))for(let e=0;e{Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,r){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(r))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],r=[];return function e(i,n){if((0,isFunction_1.isFunction)(i))return;let s,o,a,l=toJSON(i);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(i===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let i=0;t.Latch=class{constructor(e=i++){this.id=e,this[r]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},r=Symbol.toStringTag},30301:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const i=r(40958),n=r(50357),s=r(31586),o=r(65812);t.lazy=function(e,t){let r,a;const l=[];function u(){return u.isStale()&&u.setResult(e()),a}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return r=Date.now(),async function(e,r){if((0,i.isEmpty)(l))return;const s=await e,a=await r;if(!(0,n.eql)(s,a))for(const e of l)e(a);null!=t&&t>0&&void 0!==a&&(0,o.setUnrefTimeout)((()=>u.vacuum()),t)}(a,e),a=e},u.isStale=function(){return null==r||(0,s.gt0)(t)&&r+t{Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,r){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const i=r();return null!=i&&e.set(t,i),i}},t.deleteIf=function(e,t){for(const[r,i]of e.entries())t(r,i)&&e.delete(r)}},55835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const i=r(42279),n=r(54993);function s(e,t){return null==e?void 0:t(e)}function o(e,t,r){return null==e||null==t?void 0:r(e,t)}function a(e,t){return null!=e?e:(0,i.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=o,t.map3=function(e,t,r,i){return null==e||null==t||null==r?void 0:i(e,t,r)},t.orElse=a,t.mapOr=function(e,t,r){return null!=e?t(e):(0,i.tot)(r)},t.map2Or=function(e,t,r,i){return a(o(e,t,r),i)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,n.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const i=r(68708);class n extends Error{constructor(e,t){super(e),this.message=e,(0,i.assignFields)(this,t)}}t.MetaError=n},23838:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const i=r(40958),n=r(76790),s=r(50357),o=r(98553),a=r(49769),l=r(55835),u=r(51926),c=r(59455);class d{static fromJSON(e){const t=new d;for(const[r,i]of Object.entries(e))t.add(r,...i);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,i.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const r=(0,a.getOrSet)(this.store,e,(()=>[]));return r.push(...t),r}addUniq(e,...t){return(0,i.pushUniq)((0,a.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const r=this.store.get(e);if(null==r)return!1;{const i=r.filter((e=>!(0,s.eql)(e,t)));return 0===i.length?this.store.delete(e):this.store.set(e,i),r.length!==i.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,i.uniq)(t))){for(const t of this.keys()){const r=this.store.get(t),n=null==r?[]:e(t,r);(0,i.isEmpty)(n)?this.store.delete(t):this.store.set(t,n)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,i.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield[t,r])}()}tuples(){const e=this;return function*(){for(const[t,r]of e.store.entries())for(const e of(0,c.toA)(r))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[r,n]of this.store.entries()){const s=(0,i.findIndexes)(n,(t=>!e(r,t,n)));if(s.length>0){t=!0;for(const e of s.reverse())n.splice(e,1)}0===n.length&&this.store.delete(r)}return t}inverse(){const e=new d;for(const[t,r]of this.store.entries())for(const i of r)e.add(i,t);return e}findKeyByTuple(e){for(const[t,r]of this.tuples())if(e(t,r))return t}filterKeysByTuple(e){const t=[];for(const[r,i]of this.entries())i.some((t=>e(r,t)))&&t.push(r);return t}toJSON(){const e={};for(const[t,r]of this.entries())e[(0,u.isString)(t)?t:(0,o.stringify)(t)]=r;return e}}function h(e,t){const r=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>r.add(t,e))))),r}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const r=h(e,t);return(0,n.sortBy)((0,c.toA)(r.values()),(e=>t(e[0])))}},35556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const r=globalThis;t.isBrowser="object"==typeof r?.window&&"object"==typeof r?.document,t.isNode="string"==typeof r?.process?.versions?.node},31586:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const i=r(76790),n=r(22573),s=r(42279),o=r(54993);function a(e){return"number"==typeof e&&isFinite(e)}t.isNumber=a,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,o.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return a(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,o.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,r)=>a(t)&&a(r)&&e(t,r);function f(e,r,n){return!(null==n||!a(n))&&([e,r]=(0,i.sort)([e,r]),(0,t.lte)(e,n)&&(0,t.gte)(r,n))}function m(e){if(!a(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,n.blank)(e))return t.defaultValue;if(a(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return a(e)&&e>0}function S(e){return a(e)&&e>=0}function b(e,t){return a(e)?t(e):void 0}function P(e){return a(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const r=Math.pow(10,t);return P(e*r)/r}function E(e,t,r){if(e>t||!a(e)||!a(t))throw new Error(`invalid clamp(${e}, ${t}, ${r})`);return a(r)?rt?t:r:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return a(e)?e:t},t.diff=function(e,t){return a(e)&&a(t)?e-t:void 0},t.absdiff=function(e,t){return a(e)&&a(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,r=.95){if(!a(e)||!a(t))return!1;if(e===t)return!0;if(r>=1)return!1;const i=(0===t?1e-5:t)*(1-r);return f(t-i,t+i,e)},t.within=f,t.max_=function(...e){let t;for(const r of e)a(r)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return a(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return a(e)&&a(t)&&e>t?e:void 0},t.lte0=function(e){return a(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const r=y(e);return null==r?void 0:t(r)},t.mapFloat=function(e,t){const r=v(e);return null==r?void 0:t(r)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,r){return b(e,(e=>b(t,(t=>r(e,t)))))},t.mapNumericOr=function(e,t,r){return a(e)?t(e):r},t.numericOr=function(e,t){return a(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d+\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!a(e)||0===e||0===t)return 0;const r=t-P(Math.ceil(Math.log10(Math.abs(e)))),i=Math.pow(10,Math.abs(r));return r<0?P(e/i)*i:P(e*i)/i},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=E,t.times=function(e,t){if(!w(e))return[];const r=Math.round(e);return r<=0?[]:[...Array(r)].map(((e,r)=>t(r)))},t.pct=function(e,t){return E(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const r=Math.round(e??-1);return null==t||f(0,t,r)?r+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const r of e){if(!a(r))return;t+=r}return t}},68708:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(32639),a=r(55835),l=r(31586),u=r(34666),c=r(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const r of e)if(null!=r&&Array.isArray(r)){const[e,i]=r;null!=e&&void 0!==i&&("object"!=typeof t&&(t={}),t[e]=i)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const r=t.filter((([,e])=>null!=e));return(0,i.isEmpty)(r)?void 0:y(r)}function w(e,t,r={}){return y((0,i.compact)((0,n.sort)(h(e)).map((r=>t(r,e[r])))).filter((([e,t])=>null!=e&&void 0!==t)),r)}function S(...e){const t=(0,i.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const r=t.filter(d);if(t.length!==r.length)return t;const n={};for(const e of(0,i.uniq)((0,i.flatMap)(r,h)))n[e]=S(...r.map((t=>t[e])));return n}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const r=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(r.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const r=v(e);return m(r)?t(r):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,r){if(null==t)return e;for(const[i,n]of g(t))!0!==r?.omitKeys?.includes(i)&&(null==n&&!0!==r?.assignNullish||(e[i]=n));return e},t.assignUndefinedFields=function(e,t,...r){if(null==t)return e;for(const i of r){const r=t[i];void 0!==r&&void 0===e[i]&&(e[i]=r)}return e},t.assignAllFields=function(e,t){for(const[r,i]of g(t??{}))e[r]=i;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const r=t.filter((([,e])=>void 0!==e));return(0,i.isEmpty)(r)?void 0:y(r)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,i.compact)(t.map(e));{const r=(0,i.compact)(g(t).map((([t,r])=>(0,a.map)(e(r),(e=>[t,e])))));return 0===r.length?void 0:y(r)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,i.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickCompact=function(e,...t){if(null==e)return;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickNonBlank=function(e,...t){if(null==e)return e;const r={};for(const i of t){const t=e[i];(0,s.notBlank)(t)&&(r[i]=t)}return r},t.pickFirst=function(e,t,r=a.defined){if(null!=e)for(const i of t)if(r(e[i]))return e[i]},t.pickDeep=function e(t,...r){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...r)));const i={};function n(e,t){if(null==t)return;const r=i[e];i[e]=null==r?t:S(r,t)}for(const i of r){const[r,o]=(0,c.splitFirst)(i,"."),a=b(t,r);null!=a?.value&&n(a.key,(0,s.blank)(o)?a.value:e(a.value,o))}for(const i of h(t))((0,l.toInt)(i)??-1)>=0&&n(i,e(t[i],...r));return i},t.pluck=b,t.pluckDeep=function e(t,r){if(null==t||(0,s.blank)(r))return;if(Array.isArray(t)){const n=(0,i.compact)(t.map((t=>e(t,r))));return(0,i.isEmpty)(n)?void 0:{key:n[0].key,value:(0,i.flatMap)(n,(e=>e.value))}}const[n,o]=(0,c.splitFirst)(r,"."),a=b(t,n);if(null==a)return;if((0,s.blank)(o))return a;const l=e(a.value,o);return null==l?void 0:{key:a.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const r=g(e).filter((([e])=>!t.includes(e)));return(0,i.isEmpty)(r)?void 0:y(r)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,r])=>t(e,r))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,i.uniq)(t)},t.maybeCall=function(e,t,...r){const i=e?.[t];return(0,o.isFunction)(i)?i.bind(e)(...r):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const r=t.toLowerCase().normalize();for(const t of h(e))if(r===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const r=w(t,((t,r)=>[t,e(r)])),i=p(r);return 1===i.length?i[0]:r}},97790:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(r||(r={})),t.None=r;class i{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new i(e(this.a))}flatMap(e){const t=e(this.a);return n(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,r){return s(e).flatMap((e=>s(t).flatMap((t=>r(this.a,e,t)))))}zip3(e,t,r,i){return s(e).flatMap((e=>s(t).flatMap((t=>s(r).flatMap((r=>i(this.a,e,t,r)))))))}}function n(e){return e instanceof i||e===t.None}function s(e){return n(e)?e:null!=e?new i(e):t.None}t.Some=i,t.isOpt=n,t.opt=s},39926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const i=r(31586),n=r(54993),s={};function o(e,t){if(t<1)return"";if(!(0,i.gte)(s[e]?.length,t)){let r=s[e]??e;for(;r.length{Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const i=r(22573),n=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,o=/[^aeiou]y$/,a=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,i.blank)(e))return e;const t=n.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(o)?e.replace(/y$/i,"ies"):null!=e.match(a)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const i=r(40958),n=r(54993),s=["number","string","boolean"];function o(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=o,t.mapPrimitive=function(e,t){return o(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,r){return o(e)?t(e):r()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(o)};const a=["boolean","number","bigint","symbol","string","object","function"];function l(e,r){if(null==e&&null==r)return 0;if(null==e)return-1;if(null==r)return 1;const i=typeof e,s=typeof r;if(!("string"!==i&&"symbol"!==i||"string"!==s&&"symbol"!==s)){const i=(0,n.toS)(e),s=(0,n.toS)(r),o=i.localeCompare(s);return i[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-o:o}return Array.isArray(e)&&Array.isArray(r)?u(e,r):i!==s?a.indexOf(i)-a.indexOf(s):e>r?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const i=r(59455);function n(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const r=await e;return null==r?void 0:t(r)},t.thenCollect=async function(e,t){const r=[];for(const n of(0,i.toA)(await e))if(null!=n){const e=await n;if(null!=e){const i=await t(e);null!=i&&r.push(i)}}return r},t.thenTap=async function(e,t=console.dir.bind(console)){const r=await e;return await t(r),r},t.isPromiseLike=n,t.isPromise=function(e){return n(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:r}){const i=await e;return t(i)?r(i):void 0}},57153:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const i=r(50989);t.PromiseStates=(0,i.strEnum)("pending","resolved","rejected")},30976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const i=r(40958),n=r(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function o(e,t,r){return null==r||0===r.length?s(e,t):a(e,t,1,r)[0]}function a(e,t,r,i){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const n=t-e,o=new Set(i??[]);if(t===e&&0===n&&0===o.size&&1===r)return[e];const a=n-o.size;if(r>a)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:n,size:r,slotsRemaining:a})}`);const l=new Set;for(;l.size0;e--){const r=Math.floor(Math.random()*(e+1));e!==r&&([t[e],t[r]]=[t[r],t[e]])}return t},t.sample=function(e,t){const r=[];for(const i of a(0,e.length,t))r.push(e[i]);return r},t.pickWeightedRandom=function(e){if((0,i.isEmpty)(e))return;const t=e.filter((e=>(0,n.gt0)(e.priority)));let r=l(0,(0,i.sum)(t,(e=>e.priority)));return t.find((e=>(r-=e.priority,r<=0)))}},5670:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const i=r(50989);t.ServiceNames=(0,i.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]}},50989:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const i=r(68708),n=r(42279);t.strEnum=function(...e){const t=Object.freeze(e),r=(0,i.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const o=e=>null!=e?r[e]:void 0,a=e=>null!=o(e);return{...s,values:t,length:t.length,has:a,includes:a,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:o,ordinal:e=>o(e)??t.length,validOrElse:(e,t)=>a(e)?e:(0,n.tot)(t),mapValid:(e,t)=>a(e)?t(e):void 0,cmp:(e,t)=>{const r=o(e),i=o(t);return null==r||null==i?void 0:r>i?1:r{const r=o(e);return null==r?void 0:t[r]}}}},51926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const i=r(40958),n=r(17586),s=r(22573),o=r(96249),a=r(41801),l=r(31586),u=r(59455),c=r(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,r){if(d(e))return t<0&&(t+=e.length),e.slice(t,r);{const i=f();return null!=i?(0,a.sliceIterable)(i.segment(e),t,r).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,r).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.startsWith(i)?r.slice(i.length):r}function y(e,t){if(null==t)return e;const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.endsWith(i)?r.slice(0,-i.length):r}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,r){null==r&&(r=e.length);for(let i=r;i>=0;i--)if(m(e,i).startsWith(t))return i;return-1}function b(e,t,{normalize:r=!0}={}){if(null==e||null==t)return!1;const i=(0,c.toS)(e),n=(0,c.toS)(t);return i.length===n.length&&(i===n||i.toLowerCase()===n.toLowerCase()||"function"==typeof i.localeCompare&&0===(r?i.normalize():i).localeCompare(r?n.normalize():n,void 0,{sensitivity:"base"}))}function P(e,t){return(0,i.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,n.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,a.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,r){return d(e)?e.slice(t,null==r?void 0:t+r):m(e,t,null==r?void 0:t+r)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,r){if(null==t)return"";const i=(0,c.toS)(t);for(const t of r)if(null!=t&&t.length>0&&i.startsWith(t))return e(i.slice(t.length),r);return i},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:r}){return y(g(e,t),r)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:r}){return w(v(e,t),r)},t.ellipsize=function(e,t=80,r=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),r=(0,l.clamp)(0,t-1,(0,l.round)(r));const i=p(e);return i.length<=t?i.join(""):i.slice(0,t-1-r).join("")+"…"+(r>0?i.slice(-r).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,r){const i=r?.maxLineLen??80,n=r?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const i=(0,o.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,o.flatten)(i.map((t=>e(t,r))))}if((t=v((0,c.toS)(t),n).trim()).length<=i)return[t];const s=S(t," ",i);if(s>n.length)return[m(t,0,s),...e(m(t,s+1),r)];{const i=t.indexOf(" ",n.length+1);return i>0&&i{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const i=r(42659),n=r(68708),s=r(42279),o=r(83104),a=r(85556);async function l(e,t,r=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(r,i)=>{let n=!0;const s=setTimeout((()=>{n&&(n=!1,r(o.Timeout))}),t);try{s.unref?.();const t=await e;n&&(n=!1,r(t))}catch(e){n&&(n=!1,i(e))}finally{clearTimeout(s)}}))}async function u(e,t,r=!0){const n=await l(e,t,r);if(n===o.Timeout)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(t)+")");return n}t.toNotTimeout=function(e){return e===o.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,r=!0){const i=t-Date.now();return i<=0?o.Timeout:l(e,i,r)},t.thenOrOnTimeout=async function(e,t,r){return t<=0?e:new Promise((async(i,s)=>{let o=!0;try{const a=setTimeout((async()=>{if(o){o=!1;try{i(await r())}catch(e){s(e)}}}),t);(0,n.maybeCall)(a,"unref");const l=await e;o&&(o=!1,clearTimeout(a),i(l))}catch(e){o&&(o=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,r=!0){const n=t-Date.now();if(n<=0)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(n)+")");return u(e,n,r)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:r,unref:i=!0}){const n=await l(e,t,i);return n===o.Timeout?(0,s.tot)(r):n}},42279:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const i=r(32639);t.tot=function(e){return(0,i.isFunction)(e)?e():e},t.tol=async function(e){return(0,i.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class r extends Error{}t.TimeoutError=r},12168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const i=r(22573),n=r(30301),s=r(31586),o=r(46891),a=r(50989),l=r(51926),u=(0,n.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let r=0;for(const i of e)(0,s.isNumber)(i)&&(r+=i/t.MB);return(0,s.round)(r)},t.fmt=c,t.fmtToInt=function(e){return(0,i.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const r=Math.floor(Math.log10(e)),i=Math.floor(r/3),n=Math.pow(10,3*i),o=d[i];return(0,s.sigFigs)(e/n,t)+" "+o}t.fmtMB=function(e,r=3){return f(e*t.MB,r)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const r=Math.floor(Math.log2(e)),i=Math.floor(r/10),n=Math.pow(2,10*i),o=h[i];return(0,s.sigFigs)(e/n,t)+" "+o},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,a.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,r){return null==e?"":(0,i.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(r??(0,o.pluralize)(t)).trim())},t.plurMetric=function(e,t,r){return r??(r=(0,o.pluralize)(t)),{count:c(e),desc:1===e?t:r}}},65812:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const i=r(68708);t.setUnrefTimeout=function(e,t){const r=setTimeout(e,t);return(0,i.maybeCall)(r,"unref")??r}},23541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const i=r(41801),n=r(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,n.isString)(e)?[e]:(0,i.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const i=r(40958),n=r(23541),s=r(59455),o=r(54993);function a(e){return null==e?void 0:(0,n.isError)(e)?e:new Error((0,o.toS)(e))}t.toErr=a,t.toErrs=function(...e){return(0,i.compact)((0,s.toA)(e).map(a))}},54993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const i=r(98553);t.toS=function(e){return s(e,",")};const n={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==n?e.toString():(0,i.stringify)(e)}}t.toStr=s},92636:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(6858),s=i(r(73024)),o=i(r(76760)),a=r(1708),l=r(37805),u=r(41269),c=r(80061),d=r(94361);function h(e){for(const t of["bin",__dirname]){const r=o.default.join(t,e);if(s.default.existsSync(r))return r}return console.error("failed to find command "+e),e}n.program.version(l.version),n.program.description("Welcome to PhotoStructure, your new home for all your photos and videos.\nSee https://photostructure.com/server/tools/ for details about these tools."),(0,d.verifyUidGid)(),(0,c.addHelpFooter)(n.program).command("main",u.CliDesc.main+" (default)",{isDefault:!0,executableFile:h("main.js")}).command("info",u.CliDesc.info,{executableFile:h("info.js")}).command("list",u.CliDesc.list,{executableFile:h("list.js")}).command("logcat",u.CliDesc.logcat,{executableFile:h("logcat.js")}).command("logtail",u.CliDesc.logtail,{executableFile:h("logtail.js")}).command("web",u.CliDesc.web,{executableFile:h("web.js")}).command("sync",u.CliDesc.sync,{executableFile:h("sync.js")}).parse(a.argv)},90858:e=>{e.exports=require("@iarna/toml")},58587:e=>{e.exports=require("batch-cluster")},6858:e=>{e.exports=require("commander")},36507:e=>{e.exports=require("croner")},66261:e=>{e.exports=require("events")},77988:e=>{e.exports=require("exiftool-vendored")},44652:e=>{e.exports=require("fs-extra")},28787:e=>{e.exports=require("he")},51168:e=>{e.exports=require("luxon")},73872:e=>{e.exports=require("type-detect")},92460:e=>{e.exports=require("util")},31421:e=>{e.exports=require("node:child_process")},77598:e=>{e.exports=require("node:crypto")},78474:e=>{e.exports=require("node:events")},73024:e=>{e.exports=require("node:fs")},51455:e=>{e.exports=require("node:fs/promises")},48161:e=>{e.exports=require("node:os")},76760:e=>{e.exports=require("node:path")},1708:e=>{e.exports=require("node:process")},57075:e=>{e.exports=require("node:stream")},46466:e=>{e.exports=require("node:stream/promises")},87997:e=>{e.exports=require("node:timers")},57975:e=>{e.exports=require("node:util")},38522:e=>{e.exports=require("node:zlib")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__=__webpack_require__(92636);module.exports=__webpack_exports__})(); \ No newline at end of file +(()=>{"use strict";var __webpack_modules__={37975:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bgWhite=t.bgCyanBright=t.bgMagentaBright=t.bgBlueBright=t.bgYellowBright=t.bgGreenBright=t.bgRedBright=t.bgDarkGrey=t.bgLightGrey=t.bgCyan=t.bgMagenta=t.bgBlue=t.bgYellow=t.bgGreen=t.bgRed=t.bgBlack=t.white=t.cyanBright=t.magentaBright=t.blueBright=t.yellowBright=t.greenBright=t.redBright=t.darkGrey=t.lightGrey=t.cyan=t.magenta=t.blue=t.yellow=t.green=t.red=t.black=t.strikethrough=t.hidden=t.inverse=t.overline=t.underline=t.italic=t.dim=t.bold=t.reset=t.isColorEnabled=t.setColorEnabled=t.noColor=void 0;const i=r(22573),n=r(38639),s=r(44198);function o(){return(0,n.toNotBoolean)((0,s.env)().PS_LOG_COLOR)??(!(0,i.blank)((0,s.env)().NO_COLOR)||["dumb","unknown"].includes((0,s.env)().TERM))}t.noColor=o;let a=!o();function l(){return a}function u(e,t){return function(r){return l()?`[${e}m${r}[${t}m`:r}}t.setColorEnabled=function(e){a=e??!o()},t.isColorEnabled=l,t.reset=u(0,0),t.bold=u(1,22),t.dim=u(2,22),t.italic=u(3,23),t.underline=u(4,24),t.overline=u(53,55),t.inverse=u(7,27),t.hidden=u(8,28),t.strikethrough=u(9,29),t.black=u(30,39),t.red=u(31,39),t.green=u(32,39),t.yellow=u(33,39),t.blue=u(34,39),t.magenta=u(35,39),t.cyan=u(36,39),t.lightGrey=u(37,39),t.darkGrey=u(90,39),t.redBright=u(91,39),t.greenBright=u(92,39),t.yellowBright=u(93,39),t.blueBright=u(94,39),t.magentaBright=u(95,39),t.cyanBright=u(96,39),t.white=u(97,39),t.bgBlack=u(40,49),t.bgRed=u(41,49),t.bgGreen=u(42,49),t.bgYellow=u(43,49),t.bgBlue=u(44,49),t.bgMagenta=u(45,49),t.bgCyan=u(46,49),t.bgLightGrey=u(47,49),t.bgDarkGrey=u(100,49),t.bgRedBright=u(101,49),t.bgGreenBright=u(102,49),t.bgYellowBright=u(103,49),t.bgBlueBright=u(104,49),t.bgMagentaBright=u(105,49),t.bgCyanBright=u(106,49),t.bgWhite=u(107,49)},72993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AppNameVersion=t.AppName=t.SimpleAppNameLC=t.SimpleShortAppName=t.SimpleAppName=void 0;const i=r(19851),n=r(7282),s=r(37805);t.SimpleAppName="PhotoStructure",t.SimpleShortAppName="phstr",t.SimpleAppNameLC=t.SimpleAppName.toLowerCase(),t.AppName=(0,i.lazy)((()=>t.SimpleAppName+((0,n.isProd)()?"":`-${(0,n.nodeEnv)()}`))),t.AppNameVersion=(0,i.lazy)((()=>(0,t.AppName)()+" "+s.version))},48884:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reverse=t.leastByCtx=t.greatestBy=t.least=t.leastBy=t.greatestIndexBy=t.leastIndexBy=t.greatestIndex=t.max=t.leastIndex=t.min=t.ancestry=t.unFlatZip=t.flatZip=t.zip=t.retainFirstN=t.retainLastN=t.toMapEntries=t.compactRight=t.mapCompact=t.uniqCount=t.isUniq=t.partition=t.uniqInPlace=t.removeFirst=t.eqlUnordered=t.diceCoeff=t.intersection=t.moveIndexToEnd=t.moveToEnd=t.concat=t.findLastIndex=t.findLast=t.findFromIndex=t.firstNonEmptyThunk=t.firstAsync=t.first=t.findLastAsync=t.findAsync=t.anyDefined=t.anyNotDefined=t.allNotBlank=t.allNotDefined=t.mapAll=t.mapAllDefined=t.allDefined=t.diffEql=t.remove=t.flatMap=t.diff=void 0,t.leftPadArray=t.dupes=t.firstIndexNearest=t.everyAsync=t.someAsync=t.clusterAsync=t.clusterEvery=t.clusterSome=t.contextFilter=t.collectBatchedAsync=t.collectBatched=t.batches=t.reverseG=void 0;const i=r(40958),n=r(36783),s=r(76790),o=r(22573),a=r(50357),l=r(98553),u=r(55835),c=r(31586),d=r(68708),h=r(34666),f=r(59455),m=r(84885);var p=r(40958);function g(e){return(0,u.defined)(e)&&e.every(u.defined)}function y(e,t,r=i.primitiveValueOfOrElse){const n=new Set(t.map(r));return e.filter((e=>n.has(r(e))))}function v(e){if(null==e||0===e.length)return[];const t=e[0],r=e.lastIndexOf(t);return[{t,count:r+1},...v(e.slice(r+1))]}function w(...e){const t=[],r=Math.max(...e.map((e=>e?.length??0)));for(let i=0;ie?.[i])));return t}function S(e){return P(e,(e=>e.valueOf()))}function b(e){return _(e,(e=>e.valueOf()))}function P(e,t){return M(e,t,((e,t)=>(0,h.lt)(e,t)))}function _(e,t){return M(e,t,((e,t)=>(0,h.gt)(e,t)))}function E(e,t){return(0,i.isEmpty)(e)?void 0:e[P(e,t)]}function M(e,t,r){return C(e,t,r).index}function C(e,t,r){if((0,i.isEmpty)(e))return{index:-1,value:void 0};let n,s=-1;for(let i=0;ie.slice(r,r+t)))}async function x(e,t){return(0,i.isEmpty)(e)||(await Promise.all(e.map(t))).every((e=>e))}Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return p.diff}}),Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return p.flatMap}}),Object.defineProperty(t,"remove",{enumerable:!0,get:function(){return p.remove}}),t.diffEql=function(e,t){return e.filter((e=>!t.some((t=>(0,a.eql)(e,t)))))},t.allDefined=g,t.mapAllDefined=function(e,t){return g(e)?t(e):void 0},t.mapAll=function(e,t){return g(e)?t(e):void 0},t.allNotDefined=function(e){return null==e||e.every((e=>null==e))},t.allNotBlank=function(...e){return null!=e&&e.every(o.notBlank)},t.anyNotDefined=function(e){return null==e||e.some((e=>null==e))},t.anyDefined=function(e){return null!=e&&e.some((e=>null!=e))},t.findAsync=async function(e,t){for(const r of(0,f.toA)(e))if(null!=r&&!0===await t(r))return r},t.findLastAsync=async function(e,t){for(let r=(e=(0,f.toA)(e)).length-1;r>=0;r--){const i=e[r];if(null!=i&&!0===await t(i))return i}},t.first=function(e,t){if(null!=e)for(const r of(0,f.toA)(e))if(null!=r){const e=t(r);if(null!=e)return e}},t.firstAsync=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null!=i){const e=await t(i,r);if(null!=e)return e}}catch(e){}}}},t.firstNonEmptyThunk=function(...e){for(const t of e){const e=t();if((0,i.isNotEmpty)(e))return e}},t.findFromIndex=function(e,t,r){for(let i=r;i<=e.length-1;i++)if(t(e[i]))return i},t.findLast=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return e[r]},t.findLastIndex=function(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1},t.concat=function(...e){const t=[];for(const r of e)if(Array.isArray(r))for(const e of r)null!=e&&t.push(e);else null!=r&&t.push(r);return t},t.moveToEnd=function(e,t){return(0,i.remove)(e,t),e.push(t),e},t.moveIndexToEnd=function(e,t){const r=e[t];if(null==r)return e;e.push(r);for(let r=t;r(0,a.eql)(e,t)))},t.removeFirst=function(e,t){const r=e.findIndex(t);return r>=0?e.splice(r,1)[0]:void 0},t.uniqInPlace=function(e,t=(e=>(0,l.stringify)(e))){(0,n.copyArrayTo)((0,i.uniqBy)(e,t),e)},t.partition=function(e,t){const r=[],i=[];let n=0;for(const s of e)(t(s,n++)?r:i).push(s);return[r,i]},t.isUniq=function(e){return e.every(((t,r)=>e.indexOf(t)===r))},t.uniqCount=function(e){return v(e.sort())},t.mapCompact=function(e,t){return(0,i.compact)((0,i.compact)(e).map(t))},t.compactRight=function(e){for(let t=e.length-1;t>=0&&null==e[t];t--)e.splice(t,1);return e},t.toMapEntries=function(e,t){return new Map(e.map(t).filter(u.defined))},t.retainLastN=function(e,t){return e.length>t&&e.splice(0,e.length-t),e},t.retainFirstN=function(e,t){return e.length=Math.min(e.length,t),e},t.zip=w,t.flatZip=function(...e){const t=Math.max(...e.map((e=>e?.length??0))),r=[];return(0,c.times)(t,(t=>e.map((e=>r.push(e?.[t]))))),r},t.unFlatZip=function(e,t){const r=e.length/t;if(r!==Math.round(r))throw new Error("unFlatZip(): bad input array length "+(0,l.stringify)({arr_length:e.length,n:t}));const i=(0,c.times)(t,(()=>new Array(r)));for(let n=0;ne.slice(0,t+1)))},t.min=function(e){return e[S(e)]},t.leastIndex=S,t.max=function(e){return e[b(e)]},t.greatestIndex=b,t.leastIndexBy=P,t.greatestIndexBy=_,t.leastBy=E,t.least=function(e){return E(e,(e=>e))},t.greatestBy=function(e,t){return(0,i.isEmpty)(e)?void 0:e[_(e,t)]},t.leastByCtx=function(e,t){const r=C(e??[],t,h.lt);return null==e||null==r||r.index<0||null==r.value?void 0:{result:e[r.index],index:r.index,value:r.value}},t.reverse=function(e){const t=[];for(let r=e.length-1;r>=0;r--)t.push(e[r]);return t},t.reverseG=function*(e){for(let t=e.length-1;t>=0;t--)yield e[t]},t.batches=T,t.collectBatched=function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(r(s)));return n},t.collectBatchedAsync=async function(e,t,r){const n=[];for(const s of T((0,i.compact)((0,f.toA)(e)),t))n.push(...(0,i.compact)(await r(s)));return n},t.contextFilter=function(e,t){let r;return e.filter(((e,i)=>(0,d.tap)(t(e,i,r),(t=>{t&&(r=e)}))))},t.clusterSome=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.some((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterEvery=function(e,t){const r=[];for(const i of e){const e=r.find((e=>e.every((e=>t(i,e)))));e?e.push(i):r.push([i])}return r},t.clusterAsync=async function(e,t){const r=[];e:for(const i of e){for(const e of r)if(null!=i&&await x(e,(e=>t(i,e)))){e.push(i);continue e}null!=i&&r.push([i])}return r},t.someAsync=async function(e,t){if(null!=e)for(let r=0;r=0&&!0===(0,u.map)(e[i],(e=>r(e,i))))return i}{const i=t+n;if(ie+1),1));return(0,f.toA)(t.entries()).filter((([,e])=>e>1))},t.leftPadArray=function(e,t,r){return e.lengthr))),e}},36557:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.batchClusterOptions=t.BatchClusterObserver=void 0;const a=r(77988),l=o(r(1708)),u=r(19851),c=r(42659),d=r(55835),h=r(31586),f=r(85556),m=r(54993),p=r(50213),g=r(79089),y=r(45255),v=r(25764),w=r(38836),S=r(99331),b=r(95937),P=r(98314),_=r(38835),E=r(70025),M=r(8769),C=r(43334),T=r(95402),x=r(28874),D=r(63870);class k extends w.EndableWrapper{constructor(e,t,r=v.EndableRanks.service){super(`proc.BatchClusterObserver(${e})`,(()=>s(this,i,"m",n).call(this)),r,"worker"===e?(0,D.commandTimeoutMs)():y.ShortCommandTimeoutMs),i.add(this),this.t=t;const o=t;o.on("childStart",(async r=>{null!=r.pid?(this.logger.info("Started child process",{pid:r.pid}),(0,g.renice)(r.pid).catch((e=>this.onError("renice failed",e))),(0,T.addPid)({pid:r.pid,ppid:l.default.pid,cmd:e,timeoutMs:t.options.maxProcAgeMillis+c.minuteMs},new Date)?.catch((t=>this.onError("addPid failed for "+e,t)))):this.onError("No PID returned for "+e,new f.TimeoutError)})),o.on("startError",(e=>{this.lastStartError=e,this.onError("failed to start",e)})),o.on("taskError",((e,t)=>{null!=(0,P.errorToS)(e).match(/timeout/)&&(0,b.onTimeout)(),this.lastTaskError=e,this.onError("failed to run "+(0,d.map)(t,(e=>e.command)),e)})),o.on("fatalError",(e=>{this.onError("on(fatalError)"+_.FatalErrorFlag,e)})),o.on("internalError",(e=>{this.lastInternalError=e,this.onError("internal error",e)})),o.on("noTaskData",((e,r,i)=>{const n=t.options.streamFlushMillis;n{this.logger.error("observeBatchCluster.endError()",e)})),o.on("childEnd",(e=>{this.logger.info("on(childEnd)",{pid:e?.pid,name:e?.name}),(0,h.gt0)(e?.pid)&&T.Pids.instance()?.onKill(e.pid)}))}childEndCounts(){return this.t instanceof a.ExifTool?this.t.childEndCounts():this.t.stats?.().childEndCounts}onError(e,t){this.t.ended||(0,S.ending)()||!0===(0,E.isIgnorableError)(t)?this.logger.warn("onError() (ending or ignorable)",{reason:e,error:t}):(0,M.onError)(this.name+": "+e,t)}}t.BatchClusterObserver=k,i=new WeakSet,n=function(){return this.logger.info("onEnd()",{childEndCounts:this.childEndCounts()}),this.t.end(!0)},t.batchClusterOptions=function(e,t){return{maxProcs:e,maxIdleMsPerProcess:(C.isWin?3:1)*c.minuteMs,maxTasksPerProcess:x.Settings.maxTasksPerProcess.valueOrDefault,minDelayBetweenSpawnMillis:x.Settings.minDelayBetweenSpawnMs.valueOrDefault,streamFlushMillis:x.Settings.streamFlushMs.valueOrDefault,logger:(0,u.lazy)((()=>(0,p.mkLogger)(t))),spawnTimeoutMillis:x.Settings.commandTimeoutMs.defaultValue,taskTimeoutMillis:x.Settings.taskTimeoutMs.valueOrDefault}}},89788:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedList=void 0;const c=r(92460),d=r(31586);class h{constructor(e){if(i.add(this),this.maxLength=e,n.set(this,void 0),s.set(this,0),o.set(this,0),e>1e3)throw new Error("BoundedList.maxLength of "+e);l(this,n,new Array(...(0,d.times)(e,(()=>null))),"f")}at(e){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]))}get last(){return this.at(-1)}set(e,t){return u(this,i,"m",a).call(this,e,(e=>u(this,n,"f")[e]=t))}get length(){return u(this,s,"f")}set length(e){l(this,s,(0,d.clamp)(0,u(this,s,"f"),e),"f")}clear(){this.length=0}[(n=new WeakMap,s=new WeakMap,o=new WeakMap,i=new WeakSet,a=function(e,t){return(e=Math.trunc(e)??0)<0&&(e+=u(this,s,"f")),e<0||e>=u(this,s,"f")?void 0:t((e+u(this,o,"f")+this.maxLength)%this.maxLength)},Symbol.iterator)](){const e=this;return function*(){for(let t=0;tu(e,n,"f")[t]))}()}push(...e){var t,r;for(const c of e.slice(-this.maxLength))u(this,s,"f"){u(this,n,"f")[e]=c}));return u(this,s,"f")}pop(){return u(this,i,"m",a).call(this,u(this,s,"f")-1,(e=>{var t;return l(this,s,(t=u(this,s,"f"),--t),"f"),u(this,n,"f")[e]}))}unshift(...e){var t,r;for(const c of e.reverse())u(this,s,"f"){u(this,n,"f")[e]=c,l(this,o,e,"f")}));return u(this,s,"f")}shift(){return u(this,i,"m",a).call(this,0,(e=>{var t,r;return l(this,o,(t=u(this,o,"f"),++t),"f"),l(this,s,(r=u(this,s,"f"),--r),"f"),u(this,n,"f")[e]}))}shiftOrFirst(){return this.length>1?this.shift():this.at(0)}every(e){for(let t=0;t{u(this,i,"m",a).call(this,u(this,s,"f")-1-e,(e=>{const r=u(this,n,"f")[e];u(this,n,"f")[e]=u(this,n,"f")[t],u(this,n,"f")[t]=r}))}));return this}[c.inspect.custom](){return this.toA()}toA(){return[...this]}slice(e,t){return[...this].slice(e,t)}}t.BoundedList=h},76850:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferStartsWith=t.bufferToString=t.debom=void 0;const i=r(54993),n=[{bom:[239,187,191],encoding:"utf8"},{bom:[255,254],encoding:"utf16le"}];function s(e){for(const{bom:t,encoding:r}of n)if(o(e,t))return e.subarray(t.length).toString(r);return e.toString()}function o(e,t){return t.every(((t,r)=>e[r]===t))}t.debom=s,t.bufferToString=function(e){return Buffer.isBuffer(e)?s(e):(0,i.toS)(e)},t.bufferStartsWith=o},9092:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveMap=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Map;for(const[t,r]of e)this.set(t,r)}get(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)?.[1]}lookup(e){const t=this.normalizer(e);return null==t?void 0:this.store.get(t)}has(e){const t=this.normalizer(e);return null!=t&&this.store.has(t)}set(e,t){const r=this.normalizer(e);return null!=e&&null!=r&&this.store.set(r,[e,t]),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t[1],t[0],this)))}get size(){return this.store.size}entries(){return this.store.values()}keys(){return[...this.store.values()].map((e=>e[0]))[Symbol.iterator]()}values(){return[...this.store.values()].map((e=>e[1]))[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e&&(t[e[0]]=e[1])}return t}}t.CaseInsensitiveMap=n},36638:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveSet=void 0;const i=r(94863);class n{constructor(e=[],t=i.DefaultNormalizer){this.normalizer=t,this.store=new Set;for(const t of e)this.add(t)}add(e){const t=this.normalizer(e);return null!=t&&this.store.add(t),this}clear(){this.store.clear()}delete(e){const t=this.normalizer(e);return null!=t&&this.store.delete(t)}forEach(e){this.store.forEach((t=>e(t,t,this)))}has(e){if(null==e)return!1;if(this.store.has(e))return!0;const t=this.normalizer(e);return null!=t&&this.store.has(t)}get size(){return this.store.size}entries(){return this.store.entries()}keys(){return this.store.keys()}values(){return this.store.values()}[Symbol.iterator](){return this.store[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}t.CaseInsensitiveSet=n},40583:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CaseInsensitiveValued=void 0;const o=r(40958),a=r(23838),l=s(r(68708)),u=r(59455),c=r(96859);t.CaseInsensitiveValued=class{constructor(e,t=(()=>{})){this.obj=e,this.synonyms=t,this.m=new a.MultiMap,this.vacuum()}vacuum(){this.m.clear();for(const[e,t]of l.entries(this.obj))for(const r of(0,o.uniq)([e,...(0,u.toA)(this.synonyms(e,t))].map((e=>e.toLowerCase()))))this.m.add(r,e);this.m.vacuum()}lookup(e){if(null==e)return;const t=this.obj[e];return null!=t?{key:e,value:t}:this.getFirst(this.m.get(e.toLowerCase()))}lookupNearest(e,t=.4){const r=this.lookup(e);if(null!=r)return r;let i,n=-1;for(const[r,s]of this.m.entries()){const o=(0,c.diceCoeff)(r,e);if(o>t&&o>n){const e=this.getFirst(s);null!=e&&(i=e,n=o)}}return i}get(e){return this.lookup(e)?.value}set(e,t){this.obj[e]=t,this.vacuum()}getFirst(e){if(null!=e)for(const t of e){const e=this.obj[t];if(null!=e)return{key:t,value:e}}}delete(e){const t=e.toLowerCase(),r=this.m.get(t);if(null!=r){for(const e of r)delete this.obj[e];this.m.delete(t)}}pick(...e){const t={};for(const r of e){const e=this.lookup(r);null!=e?.key&&(t[e.key]=e.value)}return t}}},22454:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CountingSet=void 0;const i=r(76790),n=r(31586),s=r(68708),o=r(54993),a=r(82647),l=r(70417);class u{constructor(){this.m=new Map}incr(e,t=1){const r=this.get(e)+t;return 0===r?this.m.delete(e):this.m.set(e,r),r}get(e){return this.m.get(e)??0}max(...e){return Math.max(...0===e.length?this.m.values():e.map((e=>this.get(e))))}has(e){return this.m.has(e)}delete(e){return this.m.delete(e)}get size(){return this.m.size}get countSum(){return(0,l.sum)(this.m.values())}keys(){return this.m.keys()}keyAvg(){const e=new a.Average(0);for(const t of this.keys()){if(!(0,n.isNumber)(t))return;e.push(t)}return e.avg}entries(){return this.m.entries()}toJSON(){return this.toRecord()}toRecord(){const e={};for(const[t,r]of this.m.entries())e[(0,o.toS)(t)]=r;return e}entriesByCountDesc(){const e=this.keyAvg();return(0,i.sortBy)([...this.entries()],(([t,r])=>[-r,(0,n.mapNumericOr)(e,(e=>Math.abs(t-e)),0)]))}top(e=1){return this.entriesByCountDesc().slice(0,e)}topKeys(e=1){return this.top(e).map((e=>e[0]))}get averageCounts(){return(0,s.tap)(new a.Average(this.size),(e=>[...this.m.values()].forEach((t=>e.push(t)))))}forEach(e){this.m.forEach(e)}clear(){this.m.clear()}sortedByKey(){const e=new u;for(const[t,r]of(0,i.sortBy)(this.m.entries(),(e=>e[0])))e.incr(t,r);return e}addAll(e){for(const[t,r]of e.entries())this.incr(t,r);return this}get toS(){return(0,i.sort)([...this.keys()]).map((e=>e+" "+this.get(e))).join("\n")}valuesToA(e){const t=[];t.length=(0,l.sum)(this.m.values());let r=0;for(const[i,n]of this.m.entries()){const s=e(i);t.fill(s,r,r+n),r+=n}return t}}t.CountingSet=u},79840:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSensitiveEnvRegexPattern=void 0,t.DefaultSensitiveEnvRegexPattern="(?:^|[^a-z])(?:"+["keys?","aws","npm","pass","password","private","secret","token"].join("|")+")(?:$|[^a-z])"},17344:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EditionName=t.EditionType=void 0;const i=r(19851),n=r(72993),s=r(45969),o=r(43334);t.EditionType=(0,i.lazy)((()=>o.isElectron?"Desktops":(0,s.isDocker)()?"Docker":"Servers")),t.EditionName=(0,i.lazy)((()=>n.SimpleAppName+" for "+(0,t.EditionType)()))},14121:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenElapsed=t.elapsed=t.Elapsed=void 0;const i=r(55835);t.Elapsed=class{constructor(e,t){this.l=e,this.listener=t,this.ts=Date.now()}elapsed(e){const t=Date.now(),r=t-this.ts;this.ts=t,(0,i.map)(this.listener,(t=>t(e,r))),r>2&&this.l.log(r>500?"warn":r>100?"info":"debug",e,{elapsedMs:r})}},t.elapsed=function(e){const t=Date.now(),r=e();return{elapsedMs:Date.now()-t,result:r}},t.thenElapsed=async function(e){const t=Date.now(),r=await e;return{elapsedMs:Date.now()-t,result:r}}},23467:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eqlAsyncPicked=t.eqlOmit=t.eqlPicked=t.eqlAsync=t.definedAndNotEql=t.definedAndEql=t.eql=void 0;const i=r(50357),n=r(55835),s=r(68708);var o=r(50357);Object.defineProperty(t,"eql",{enumerable:!0,get:function(){return o.eql}}),t.definedAndEql=function(e,t){return null!=e&&null!=t&&(0,i.eql)(e,t)},t.definedAndNotEql=function(e,t){return null!=e&&null!=t&&!(0,i.eql)(e,t)},t.eqlAsync=async function(e,t){return(0,n.map2Or)(await e,await t,i.eql,(()=>!1))},t.eqlPicked=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))},t.eqlOmit=function(e,t,...r){return null!=e&&null!=t&&(0,i.eql)((0,s.omit)(e,...r),(0,s.omit)(t,...r))},t.eqlAsyncPicked=async function(e,t,...r){return(0,n.map2Or)(await e,await t,((e,t)=>(0,i.eql)((0,s.pick)(e,...r),(0,s.pick)(t,...r))),(()=>!1))}},62344:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ExtensibleFunction=void 0,t.ExtensibleFunction=class extends Function{constructor(){super("...args","return this._self._call(...args)");const e=this.bind(this);return this._self=e,e}}},54557:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPlaceholder=t.FifoCache=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(31586),a=r(54993),l=r(77377),u=r(73614);function c(e){return null==e?[]:Object.keys(e)}class d{constructor(e,t){if(this.maxSize=e,this.clearEveryMs=t,this.setsSinceLastSpill=0,this.expireListeners=[],e>3e4)throw new Error("maxSize is too big");this.clear(),(0,o.gt0)(t)&&(this.clearInterval=(0,u.setUnrefInterval)((()=>{this.spill()}),(0,o.round)(t/2)))}spill(){if(null!=this.priorCache&&null!=this.currentCache&&(0,n.isNotEmpty)(this.expireListeners))for(const e in this.priorCache)if(null==this.currentCache[e]){const t=this.priorCache[e];if(null!=t)for(const r of this.expireListeners)r(e,t)}this.priorCache=this.currentCache??Object.create(null),this.currentCache=Object.create(null),this.setsSinceLastSpill=0}[i.inspect.custom](){return{...this.priorCache,...this.currentCache}}end(){null!=this.clearInterval&&clearInterval(this.clearInterval)}clear(){return this.visit(((e,t)=>{for(const r of this.expireListeners)r(e,t)})),this.currentCache=Object.create(null),this.priorCache=Object.create(null),this.setsSinceLastSpill=0,this}get size(){if(null==this.currentCache||null==this.priorCache)return 0;let e=0;for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache)))this.has(t)&&e++;return e}has(e){return void 0!==this.currentCache[e]||void 0!==this.priorCache[e]}keys(){return(0,n.uniq)([...c(this.priorCache),...c(this.currentCache)]).filter((e=>null!=this.currentCache[e]??this.priorCache[e]))}delete(e){const t=this.currentCache[e];if(void 0!==t){this.currentCache[e]=void 0;for(const r of this.expireListeners)r(e,t)}const r=this.priorCache[e];if(void 0!==r&&(this.priorCache[e]=void 0,null==t))for(const t of this.expireListeners)t(e,r)}visit(e){for(const t of(0,l.union)(c(this.priorCache),c(this.currentCache))){const r=this.currentCache[t]??this.priorCache[t];null!=r&&e(t,r)}}deleteIf(e){for(const t of this.keys()){const r=(0,s.orElse)(this.currentCache[t],this.priorCache[t]);null!=r&&e(t,r)&&this.delete(t)}}get(e){return e=(0,a.toS)(e),this.currentCache[e]??this.priorCache[e]}set(e,t){this.maxSize<=0||(e=(0,a.toS)(e),null==this.currentCache[e]&&(this.setsSinceLastSpill>=this.maxSize&&this.spill(),this.setsSinceLastSpill++),this.currentCache[e]=t)}getOrSet(e,t){if(e=(0,a.toS)(e),this.has(e))return this.get(e);const r=t();return this.set(e,r),r}on(e,t){this.expireListeners.push(t)}}t.FifoCache=d,t.isPlaceholder=function(e){return null!=e&&(0,o.isNumber)(e.__uid)&&(0,o.isNumber)(e.__start)}},80049:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},u=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.FifoCacheAsync=void 0;const c=r(31586),d=r(85556),h=r(54993),f=r(54557),m=r(22911);t.FifoCacheAsync=class{constructor(e){this.opts=e,i.set(this,0),n.set(this,0),s.set(this,0),o.set(this,0),a.set(this,0),this.cache=new f.FifoCache(e.maxSize,e.clearEveryMs)}get name(){return this.opts.name}get size(){return this.cache.size}mergeStats(e){u(this,i,l(this,i,"f")+e.cacheHitsSync,"f"),u(this,n,l(this,n,"f")+e.cacheHitsAsync,"f"),u(this,s,l(this,s,"f")+e.cacheMisses,"f"),u(this,o,l(this,o,"f")+e.rejections,"f"),u(this,a,l(this,a,"f")+e.timeouts,"f")}stats(){return{size:this.size,cacheHitsSync:l(this,i,"f"),cacheHitsAsync:l(this,n,"f"),cacheMisses:l(this,s,"f"),rejections:l(this,o,"f"),timeouts:l(this,a,"f")}}has(e){return this.cache.has(e)}get_(e){var t,r,o,a;if(!this.cache.has(e))return void u(this,s,(t=l(this,s,"f"),t++,t),"f");const c=this.cache.get(e);if(c instanceof m.Deferred){if(c.isRejected)throw c.error;return c.isPending?(u(this,n,(r=l(this,n,"f"),++r),"f"),c.promise):(u(this,i,(o=l(this,i,"f"),++o),"f"),c.value)}if(c instanceof Error)throw c;return u(this,i,(a=l(this,i,"f"),++a),"f"),c}get(e){var t,r;const n=this.cache.get(e);return null==n||n instanceof m.Deferred&&n.isPending?u(this,s,(t=l(this,s,"f"),++t),"f"):u(this,i,(r=l(this,i,"f"),++r),"f"),n instanceof m.Deferred?n.value:n}clear(){this.cache.clear(),u(this,i,0,"f"),u(this,n,0,"f"),u(this,s,0,"f"),u(this,o,0,"f"),u(this,a,0,"f")}delete(e){return this.cache.delete(e)}deleteIf(e){for(const t of this.cache.keys())e(t)&&this.delete(t)}set(e,t){return this.cache.set(e,t),t}getOrSet(e,t){const r=this.get(e);if(null!=r){if(r instanceof Error)throw r;return r}return this.set(e,t())}getOrSetAsync(e,t){const r=(0,h.toS)(e);{const e=this.get_(r);if(null!=e)return e instanceof m.Deferred?e.promise:e}const i=new m.Deferred(this.opts.name).observe(t());return this.cache.set(r,i),(0,c.gt0)(this.opts.timeoutMs)&&i.setTimeout(this.opts.timeoutMs),i.promise.then((e=>{this.set(r,e)}),(e=>{var t,i;this.cache.set(r,e),u(this,o,(t=l(this,o,"f"),++t),"f"),e instanceof d.TimeoutError&&u(this,a,(i=l(this,a,"f"),++i),"f")})),i.promise}},i=new WeakMap,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap},54127:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.FifoSet=void 0;class i{constructor(e){this.maxSize=e,this[r]="FifoSet",this.values=()=>this.delegate.values(),this.keys=this.values,this.delegate=new Set}get size(){return this.delegate.size}add(e){return this.delegate.add(e),this.vacuum(),this}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){this.delegate.forEach(e)}has(e){return this.delegate.has(e)}entries(){return this.delegate.entries()}[(r=Symbol.toStringTag,Symbol.iterator)](){return this.values()}vacuum(){if(this.size>this.maxSize){const e=this.delegate.entries();for(;this.size>this.maxSize;)this.delete(e.next().value[0])}}}t.FifoSet=i},53507:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Fixed=t.parseFixed=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(31586),a=r(68708),l=r(50213),u=r(68852),c=r(81168),d=r(84542);class h{constructor(e){this.text=(0,c.isString)(e)?e:e.text,this.greedyLeft=!(0,c.isString)(e)&&(e.greedyLeft??!1)}toEntry(e){return[this.text,e.substring(this.leftIdx,this.rightIdx).trim()]}}const f=(0,i.lazy)((()=>(0,l.mkLogger)("Fixed")));t.parseFixed=function(e,t,r=!0){return new m(e,t,r).entries};class m{constructor(e,t,r=!0){this.warnIfMissingHeaders=r,this.skippedHeaders=[],this.rows=(0,d.splitLines)(t),this.headerRow=this.rows.shift();const i=(0,o.max_)(...this.rows.map((e=>e.length)));this.blankColumns=new Set((0,n.range)(0,i).filter((e=>this.rows.every((t=>(0,s.blank)(t[e])))))),this.headers=this.extractHeaders(e.map((e=>new h(e)))),this.entries=this.rows.map((e=>this.headers.map((t=>t.toEntry(e))))).map((e=>(0,a.fromEntries)(e))).filter((e=>(0,a.values)(e).some(s.notBlank)))}firstBlankColumn(e,t){for(let r=e;r!==t;t>e?r++:r--)if(this.blankColumns.has(r))return r;return this.blankColumns.has(t)?t:0===e||0===t?0:void 0}extractHeaders(e){const t=new RegExp(e.map((e=>(e.greedyLeft?"\\s+":"\\b")+(0,u.escapeRegExp)(e.text)+"\\b")).join("|"),"gi"),r=[];let i,a=0;for(;null!=(i=t.exec(this.headerRow));){const l=this.headerRow.substring(a,i.index);(0,s.blank)(l)||(f().debug("extractHeaders: skipping over unknown header",{skippedOver:l,m_index:i.index}),this.skippedHeaders.push(l.trim()));const u=this.headerRow.substring(i.index,t.lastIndex),d=i.index+((0,c.indexOfNonSpace)(u)??0),h=i.index+((0,c.lastIndexOfNonSpace)(u)??u.length),m=u.trim(),p=e.find((e=>e.text===m));if(null==p||null==d||null==h)this.skippedHeaders.push(m),f().debug("extractHeaders: internal error",{matched:u,match:i,left:d,right:h});else{const e=(0,n.last)(r);if(r.push(p),null!=e){const t=e.rightIdx+((0,c.indexOfNonSpace)(l)??l.length)+1;e.rightIdx=p.greedyLeft?this.firstBlankColumn(e.rightIdx,t):this.firstBlankColumn(t,e.rightIdx)}const t=(0,o.max_)(e?.rightIdx,i.index-((0,c.lastIndexOfNonSpace)(l)??l.length));p.leftIdx=p.greedyLeft?this.firstBlankColumn(t,d):this.firstBlankColumn(d,t),p.rightIdx=h}a=t.lastIndex}const l=(0,n.last)(r);return null!=l&&((0,s.blank)(this.headerRow.slice(a))?l.rightIdx=(0,o.max_)(...this.rows.map((e=>e.length))):l.rightIdx=a),r}}t.Fixed=m},73913:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashBits=void 0,t.HashBits=192},80875:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readJson_=t.mapParsed=t.parseJSON=void 0;const i=r(51455),n=r(98553);var s=r(98553);Object.defineProperty(t,"parseJSON",{enumerable:!0,get:function(){return s.parseJSON}}),t.mapParsed=function(e,t){const r=(0,n.parseJSON)(e);return null==r?void 0:t(r)},t.readJson_=async function(e){return(0,n.parseJSON)((await(0,i.readFile)(e)).toString())}},19851:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.rolazy=t.lazy=void 0;const o=r(57975),a=r(40958),l=r(50357),u=r(31586),c=r(65812),d=r(62344);t.lazy=function(e,t){return new h(e,t)};class h extends d.ExtensibleFunction{constructor(e,t){super(),i.add(this),this.thunk=e,this.ttlMs=t,this.watchers=[]}_call(){return this.isStale()&&s(this,i,"m",n).call(this,this.thunk()),this.result}async onSetResult(e,t){if((0,a.isEmpty)(this.watchers))return;const r=await e,i=await t;if(!(0,l.eql)(r,i))for(const e of this.watchers)e(i);null!=this.ttlMs&&this.ttlMs>0&&void 0!==i&&(0,c.setUnrefTimeout)((()=>this.vacuum()),this.ttlMs)}vacuum(){this.isStale()&&this.unset()}isStale(){return null==this.lastSetTs||(0,u.gt0)(this.ttlMs)&&this.lastSetTs+this.ttlMs{Object.defineProperty(t,"__esModule",{value:!0}),t.childProcLocale=t.localePosix=t.localeMac=t.localeWin=t.lc2locale=t.envLocale=t.locale=t.localeSync=t.DefaultLocale=void 0;const i=r(19851),n=r(40958),s=r(22573),o=r(42659),a=r(50213),l=r(81168),u=r(5916),c=r(56519),d=r(84777),h=r(44198),f=r(6012),m=r(43334),p=r(24399),g=r(63870);t.DefaultLocale="en";const y=(0,i.lazy)((()=>(0,a.mkLogger)("Locale")));function v(e=(0,h.env)()){for(const t of[e.LC_ALL,e.LC_MESSAGES,e.LANG,e.LANGUAGE]){const e=S(t);if(null!=e)return e}}t.localeSync=function(){return t.locale.lastValue()??(0,t.envLocale)()??t.DefaultLocale},t.locale=(0,u.lazyAsync)({desc:"locale",later:async()=>b(v()??await(m.isWin?P():m.isMac?E():M()).catch((e=>(y().warn("Failed to get locale",{error:e}),t.DefaultLocale)))),timeoutMs:(0,g.commandTimeoutMs)()}),t.envLocale=(0,i.lazy)(v);const w=/^(?[a-z]{2,3})(?:[_-](?[a-z]{2,3}))?\b/i;function S(e){if((0,s.blank)(e))return;if(e===t.DefaultLocale||(0,l.equalsIgnoreCase)("c",e)||(0,l.equalsIgnoreCase)("posix",e))return t.DefaultLocale;const r=w.exec(e.trim())?.groups;return null==r?void 0:(0,n.compact)([r.lang,r.country]).join("-")}function b(e){return S(e)??t.DefaultLocale}function P(){return(0,c.thenMap)(p.PowerShell.instance().executeJson("Get-WinSystemLocale | Select-Object -Property Name"),(e=>e.Name))}t.lc2locale=b,t.localeWin=P;const _={timeoutMs:10*o.secondMs};async function E(){return S(await(0,d.stdout_)("defaults",["read","-globalDomain","AppleLocale"],_))}async function M(){return b(v((0,f.parseEnvTokens)({lowerCaseKeys:!1,input:await(0,d.stdout_)("locale",[],_)})))}t.localeMac=E,t.localePosix=M,t.childProcLocale=function(){return{LANG:"C",LC_ALL:"C"}}},50213:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mkConsoleLogger=t.mkLogger=t.rootLoggers=void 0;const i=r(19851),n=r(32105),s=r(14593);t.rootLoggers=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));const o=(0,i.lazy)((()=>[n.ConsoleLogger.instance()]));t.mkLogger=function(e){return new s.ContextualLogger(e,t.rootLoggers)},t.mkConsoleLogger=function(e){return new s.ContextualLogger(e,o)}},9103:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.memoize=void 0;const i=r(98553),n=r(54557);t.memoize=function(e,t){let r=0;const s=new n.FifoCache(t.maxSize,t.ttlMs),o=t=>{if(null!=t)return r++,s.getOrSet((0,i.stringify)(t),(()=>e(t)))};return o.clear=e=>null==e?s.clear():s.delete((0,i.stringify)(e)),o.size=()=>s.size,o.callCount=()=>r,o}},7282:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setSingleSpecTests=t.isSingleSpecTests=t.isProd=t.isTest=t.isDev=t.nodeEnv=void 0;const n=i(r(1708)),s=r(38639),o=r(54993),a=r(19851),l=r(29325),u=/mocha(?:\.js)?$|\.spec(\.js)?$/;function c(){return"test"===(0,t.nodeEnv)()}t.nodeEnv=(0,a.lazy)((()=>n.default.env.NODE_ENV=function(){if((0,l.isPacked)())return"production";switch((0,o.toS)(n.default.env.NODE_ENV).toLowerCase()){case"test":return"test";case"dev":case"development":return"development";case"prod":case"production":return"production";default:return n.default.argv.some((e=>null!=u.exec(e)))?"test":"development"}}())),t.isDev=function(){return"development"===(0,t.nodeEnv)()},t.isTest=c,t.isProd=function(){return"production"===(0,t.nodeEnv)()},t.isSingleSpecTests=function(){return c()&&(0,s.isTrue)(n.default.env.SINGLE_SPEC_TESTS)},t.setSingleSpecTests=function(e){n.default.env.SINGLE_SPEC_TESTS=e?"true":"false"}},97352:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=t.sqrt=t.hammRatioIntArrays=t.valuesToBigInt=t.hammRatioBinaryString=t.hammRatioBigInt=t.hammingDistanceBigInt=t.Array2D=t.assertPositive=t.extractFraction=t.extractInt=t.extractFloat=t.map2Gt0=t.mapGt0=t.mapGt0f=t.mapGte0f=t.mapGte0Or=t.mapGte0=t.firstNonZero=t.firstGt0=t.within=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(55835),a=r(31586),l=r(39926),u=r(54993),c=r(20014);var d=r(31586);function h(e,t){return(0,a.mapInt)(e,(e=>e>=0?t(e):void 0))}Object.defineProperty(t,"within",{enumerable:!0,get:function(){return d.within}}),t.firstGt0=function(...e){return e.find(a.gt0)},t.firstNonZero=function(...e){for(const t of(0,s.flatten)(e)){const e=(0,a.toFloat)(t);if(null!=e&&0!==e)return e}},t.mapGte0=h,t.mapGte0Or=function(e,t,r){return(0,o.orElse)(h(e,t),r)},t.mapGte0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>=0?t(r):void 0},t.mapGt0f=function(e,t){const r=(0,a.toFloat)(e);return null!=r&&r>0?t(r):void 0},t.mapGt0=function(e,t){const r=(0,a.toInt)(e);return null!=r&&r>0?t(r):void 0},t.map2Gt0=function(e,t,r){const i=(0,a.toInt)(e),n=(0,a.toInt)(t);return null!=i&&i>0&&null!=n&&n>0?r(i,n):void 0};const f=/[+-]?[\d,.]+/;function m(e){if((0,a.isNumber)(e))return e;if((0,n.blank)(e))return;const t=String(e);return(0,o.map)(f.exec(t),(e=>(0,a.toFloat)(t.substr(e.index))))}function p(e){return(0,a.toInt)(m(e))}function g(e,t){if(null==e||null==t)return;const r=[e,t].map((e=>e.toString(2))),i=Math.max(...r.map((e=>e.length)));return r.map((e=>(0,l.leftPad)(e,i,"0")))}function y(e,t){if(e===t)return 1;if(e.length!==t.length)throw new Error(`hammRatioBinaryString(${e}, ${t}): invalid lengths`);let r=0;for(let i=0;ie/t))}return m(t)},t.assertPositive=function(e,t){if(null==t||t<=0)throw new Error(e+" must be positive")},t.Array2D=class{constructor(e){this.columns=e,this.store=[]}get(e,t){return e<0||t<0?0:this.store[e*this.columns+t]??0}set(e,t,r){this.store[e*this.columns+t]=r}},t.hammingDistanceBigInt=function(e,t){return(0,o.map)(g(e,t),(([e,t])=>(0,i.count)([...e],((e,r)=>e!==t.charAt(r)))))},t.hammRatioBigInt=function(e,t){return null==e||null==t?0:(0,o.map)(g(e,t),(([e,t])=>y(e,t)))},t.hammRatioBinaryString=y,t.valuesToBigInt=function(e,t){return(0,i.isEmpty)(e)?BigInt(0):BigInt("0b0"+e.map((e=>(0,l.leftPad)(e.toString(2),t-1,"0"))).join(""))},t.hammRatioIntArrays=function(e,t,r){if(e.length!==t.length)throw new Error("hammRatioIntArrays(): inequal arrays");let i=0;const n=r*e.length;for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.zipPojos=t.pairToObject=t.pluckCaseInsensitive=t.deepDelete=t.sortedKeys=t.mapNullEntries=t.mapEntries=t.pickMap=t.assignNullishFields=t.assignMissingPrimitives=t.spread=t.primitiveEntries=t.hasKeys=t.ctor=t.identity=t.tryEach=t.Try=t.mapOrThrow=t.mapAnd=t.ornull=t.firstFieldLike=t.firstDefinedField=t.firstDefined=t.firstTrueThunk=t.firstThunk=t.definedThunks=void 0;const i=r(40958),n=r(42659),s=r(96249),o=r(55835),a=r(31586),l=r(68708),u=r(34666),c=r(41583),d=r(48884),h=r(81168);function f(e,t){try{return e()}catch(e){return t?.((0,c.toErr)(e))}}function m(e){return(0,l.keys)(e).filter((t=>(0,u.isPrimitive)(e[t])||(0,n.isDate)(e[t]))).map((t=>[t,e[t]]))}function p(e,t){const r={};for(const[i,n]of(0,l.entries)(e)){const e=t(i,n);null!=e&&(r[i]=e)}return r}t.definedThunks=function(...e){return e.every((e=>(0,o.defined)(e())))},t.firstThunk=function(...e){for(const t of e){const e=t();if(null!=e)return e}},t.firstTrueThunk=function(e,t){for(const r of e){const e=r();if(null!=e&&(null==t||t(e)))return e}},t.firstDefined=function(...e){return e.find(o.defined)},t.firstDefinedField=function(e,...t){return(0,o.map)(t.find((t=>null!=e[t])),(t=>e[t]))},t.firstFieldLike=function(e,t){return(0,d.first)((0,l.keys)(e),(r=>t(r,e[r])?e[r]:void 0))},t.ornull=function(e){return void 0===e?null:e},t.mapAnd=function(e,t){return null!=e&&t(e)},t.mapOrThrow=function(e,t,r){if(null!=e)return t(e);throw new Error(r)},t.Try=f,t.tryEach=function(e,t){[...e].forEach((e=>f((()=>t(e)))))},t.identity=function(e){return e},t.ctor=function(e){return(0,o.map)(e.constructor,(e=>e.name))},t.hasKeys=function(e){return Object.keys(e).some((t=>"string"==typeof t&&e.propertyIsEnumerable(t)))},t.primitiveEntries=m,t.spread=function(e,...t){return Object.assign({},e,...(0,i.compact)(t))},t.assignMissingPrimitives=function(e,t){if(null==t)return e;for(const[r,i]of m(t))null==e[r]&&(e[r]=i);return e},t.assignNullishFields=function(e,t){if(null==t)return e;for(const[r,i]of(0,l.entries)(t))null==e[r]&&(e[r]=i);return e},t.pickMap=function(e,t,r){const i={};for(const n of t)i[n]=r(n,e[n]);return i},t.mapEntries=p,t.mapNullEntries=function(e,t,r){const i={};let n=0;for(const s of(0,l.keys)(e))if(i[s]=t(s,e[s]),n++,(0,a.gt)(n,r))break;return i},t.sortedKeys=function e(t){if(null==t||(0,u.isPrimitive)(t))return t;if(Array.isArray(t))return t.map((t=>e(t)));if("object"==typeof t){const r={};for(const i of(0,h.sortIgnoreCase)((0,l.keys)(t)))r[i]=e(t[i]);return r}return t},t.deepDelete=function e(t,...r){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t,...r))):p(t,((t,i)=>r.includes(t)?void 0:e(i,...r)))},t.pluckCaseInsensitive=function(e,t){if("object"==typeof e){if(void 0!==e[t])return e[t];for(const r of(0,l.keys)(e).filter((e=>(0,h.equalsIgnoreCase)(e,t))))if(void 0!==e[r])return e[r]}},t.pairToObject=function(e,t){const r={};return r[e]=t,r},t.zipPojos=function(...e){const t={};for(const r of(0,i.uniq)((0,s.flatten)(e.map(l.keys))))t[r]=e.map((e=>e?.[r]));return t}},12801:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.priorityPosixToClass=t.PriorityClassToNode=t.PriorityClassToPosix=t.PriorityClasses=void 0;const n=i(r(48161)),s=r(50989);t.PriorityClasses=(0,s.strEnum)("Normal","BelowNormal","Idle","Low"),t.PriorityClassToPosix=Object.freeze({Normal:0,BelowNormal:10,Low:19,Idle:19}),t.PriorityClassToNode=Object.freeze({AboveNormal:n.default.constants.priority.PRIORITY_ABOVE_NORMAL,Normal:n.default.constants.priority.PRIORITY_NORMAL,BelowNormal:n.default.constants.priority.PRIORITY_BELOW_NORMAL,Idle:n.default.constants.priority.PRIORITY_LOW,Low:n.default.constants.priority.PRIORITY_LOW}),t.priorityPosixToClass=function(e){return null!=e&&isFinite(e)?e{Object.defineProperty(t,"__esModule",{value:!0}),t.rateLimited=void 0;const i=r(41400),n=r(56409),s=r(31586),o=r(22911),a=r(73614),l=r(57159);t.rateLimited=function({f:e,minCallDelayMs:t,timeoutMs:r,nullOnBusy:u,name:c}){let d,h,f=!1,m=0;t=Math.ceil(t);const p=[];function g(){return f||m>Date.now()}function y(){if(null!=h){const e=h;h=void 0,w(...e)}}async function v(...i){f=!0,m=Date.now()+(0,s.max_)(t,r);const n=d=new o.Deferred(c);(0,s.gt0)(r)&&n.setTimeout(r);try{n.resolve(await e(...i))}catch(e){n.reject(new l.WrappedError("RateLimited("+c+") failed",{cause:e}))}finally{f=!1,m=Date.now()+t,(0,a.setUnrefTimeout)(y,t+1),p.forEach((e=>e.resolve())),p.length=0}return n.promise}const w=(...e)=>{if(g()){if(!0===u)return null;const t=d?.promise;return h=e,(0,i.delay)(1).then((()=>t))}return v(...e)};return w.clear=()=>{h=void 0},w.donePromise=()=>{if(!f)return Promise.resolve();const e=new n.Latch;return p.push(e),e},w.force=async(...e)=>(h=void 0,f&&await w.donePromise(),v(...e)),w.isRateLimited=()=>g(),w.status=()=>({running:f,needToDelay:m>Date.now(),minNextDelayMs:Math.max(0,Date.now()-m)}),w.minCallDelayMs=()=>t,w.setMinCallDelayMs=e=>{t=e},w}},68852:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatRegexp=t.RegExpOptional=t.RegExpEscaped=t.orRegExpPatterns=t.matchQuotes=t.escapeRegExp=t.captures=t.NothingRegExp=void 0;const i=r(68708),n=r(54993);function s(e){return e instanceof o?e.source:(0,n.toS)(e).replace(/[-.,\\^$*+?()|[\]{}]/g,"\\$&")}t.NothingRegExp=/$^/,t.captures=function(e,t){const r=[];if(!e.global)throw new Error("must provide global regex");let n;for(;null!=(n=e.exec(t));)n.index===e.lastIndex?e.lastIndex++:r.push((0,i.pick)(n,"index","groups"));return r},t.escapeRegExp=s,t.matchQuotes=function(e){return e.replace(/[‘’']/g,"[‘’']").replace(/[“”„«»〃"]/g,'[“”„”«»〃"]')},t.orRegExpPatterns=function(e,r){const i=[];for(const t of e)try{i.push(t instanceof RegExp?t.source:new RegExp(t).source)}catch{i.push(s(t))}const n=0===i.length?t.NothingRegExp:i.map((e=>"(?:"+e+")")).join("|");return new RegExp(n,r)};class o{constructor(e,t){this.source=e,this.flags=t}get global(){return this.flags?.includes("g")??!1}get ignoreCase(){return this.flags?.includes("m")??!1}get multiline(){return this.flags?.includes("i")??!1}}t.RegExpEscaped=o;class a extends o{static from(...e){const t=l(e);return new a("(?:"+t.source+")?",t.flags)}}function l(e,t){let r="",i=t?.includes("g")??!1,a=t?.includes("i")??!1,l=t?.includes("m")??!1;for(const t of e)t instanceof o||t instanceof RegExp?(r+=t.source,i||(i=t.global),a||(a=t.ignoreCase),l||(l=t.multiline)):r+=s((0,n.toS)(t));return new RegExp(r,t??(i?"g":"")+(a?"i":"")+(l?"m":""))}t.RegExpOptional=a,t.concatRegexp=l},79089:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.renice=t.niceable=void 0;const n=i(r(48161)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(42659),u=r(41400),c=r(96249),d=r(31586),h=r(51926),f=r(54993),m=r(50213),p=r(12801),g=r(22277),y=r(84777),v=r(34102),w=r(43334),S=r(24399),b=r(28874),P=(0,o.lazy)((()=>(0,m.mkLogger)("Renice")));(0,u.later)((()=>(0,v.ee)().on("clearCache",(()=>M.prior()?.clear()))));const _=(0,o.lazy)((()=>["sync.js","worker.js",...(0,c.flatten)(["dcraw_emu",s.default.basename(b.Settings.ffmpegPath.valueOrDefault)].map((e=>w.isWin?[e,(0,h.ensureSuffix)(e,".exe")]:e)))]));t.niceable=function(e,t){return(0,a.compactBlanks)([s.default.basename(e),...t.map((e=>s.default.basename(e)))]).some((e=>_().includes(e.toLowerCase())))};let E=!0;const M=(0,o.lazy)((()=>new g.TTLSet(l.minuteMs)));t.renice=async function(e,t){if(!(0,d.gt0)(e)||M().has(e))return;M().add(e);const r=(0,p.priorityPosixToClass)(t)??b.Settings.processPriority.valueOrDefault;if(t??(t=p.PriorityClassToNode[r]),E)try{return n.default.setPriority(e,t),t}catch(r){const i=-13===r?.errno||"EACCES"===r?.info?.code;if(P().warn("Failed to renice using node:os",{pid:e,priority:t,permissionDenied:i,error:r}),i)return;E=!1}try{return await(w.isWin?async function(e,t){(0,d.gt0)(e)&&p.PriorityClasses.includes(t)&&await S.PowerShell.instance().execute(`(Get-Process -Id ${e}).PriorityClass = "${t}"`,(e=>e)).catch((e=>P().info("reniceWin() failed",e)))}(e,r):async function(e,t=19){await(0,y.stdoutResult_)("renice",[t,"-p",e].map(f.toS),{timeoutMs:10*l.secondMs,isIgnorableError:()=>!0,ignoreExitCode:!0}).catch((e=>P().info("renicePosix() failed",e)))}(e,p.PriorityClassToPosix[r]??p.PriorityClassToPosix.BelowNormal)),P().info("Renice pid "+e+" to "+r),t}catch(t){return void P().info("Failed to renice pid "+e,t)}}},23560:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isTaskListManager=t.isDbJanitorService=t.isDbManager=t.isTestService=t.isInfoService=t.isSyncService=t.isWorkerService=t.isBillingService=t.isWebService=t.isMainService=t.isPermaService=t.isLibraryRequiredService=t.isDbService=t.DbServices=t.MainServices=t.serviceNameIndex=t.processName=t.serviceName=void 0;const n=i(r(1708)),s=r(19851),o=r(40958),a=r(5670),l=r(54993),u=r(7282),c=r(29325);function d(e){return t.MainServices.includes(e??(0,t.serviceName)())}function h(e){return(e??(0,t.serviceName)())===a.ServiceNames.web}function f(e){return(e??(0,t.serviceName)())===a.ServiceNames.worker}function m(e){return(e??(0,t.serviceName)())===a.ServiceNames.sync}function p(){return(0,t.serviceName)()===a.ServiceNames.test}t.serviceName=(0,s.lazy)((()=>{if((0,c.isPacked)())throw Error("serviceName() is unset");return""})),t.processName=(0,s.lazy)((()=>(0,o.compactBlanks)([t.serviceName.prior(),(0,l.toS)(n.default.pid)]).join("-"))),t.serviceName.watchLater((()=>{t.processName.unset()})),t.serviceNameIndex=function(e){return a.ServiceNames.indexOf(e)??a.ServiceNames.length+1},t.MainServices=[a.ServiceNames.main,a.ServiceNames.desktop],t.DbServices=[a.ServiceNames.sync,a.ServiceNames.info,a.ServiceNames.web,a.ServiceNames.list,a.ServiceNames.test],t.isDbService=function(){return t.DbServices.includes((0,t.serviceName)())},t.isLibraryRequiredService=function(e){return[a.ServiceNames.sync,a.ServiceNames.list].includes(e??(0,t.serviceName)())},t.isPermaService=function(e){return d(e)||h(e)},t.isMainService=d,t.isWebService=h,t.isBillingService=function(e){return(e??(0,t.serviceName)())===a.ServiceNames.billing},t.isWorkerService=f,t.isSyncService=m,t.isInfoService=function(){return(0,t.serviceName)()===a.ServiceNames.info},t.isTestService=p,t.isDbManager=function(){return m()||h()||((0,u.isTest)()||p())&&!f()},t.isDbJanitorService=(0,s.lazy)((()=>m()||p())),t.isTaskListManager=function(){return!h()&&!d()&&!f()}},77377:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.intersection=t.union=t.getOrAdd=t.setEql=t.asSet=void 0;const i=r(59455);function n(e){return e instanceof Set?e:new Set((0,i.toA)(e))}t.asSet=n,t.setEql=function(e,t){return(0,i.toA)(e.keys()).every((e=>t.has(e)))&&(0,i.toA)(t.keys()).every((t=>e.has(t)))},t.getOrAdd=function(e,t,r){if(null==t)throw new Error("null key");return e.has(t)?void 0:(e.add(t),r())},t.union=function(e,t){return new Set([...e,...t])},t.intersection=function(e,t){const r=n(t);return new Set([...e].filter((e=>r.has(e))))},t.diff=function(e,t){const r=n(t);return new Set([...e].filter((e=>!r.has(e))))}},12089:function(e,t,r){var i,n,s,o,a,l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.shim1=void 0;const c=r(98553),d=r(34666),h=r(54993),f=r(62344),m=r(56038);t.shim1=function(e){return new p(e.name,e.impl,e.cache,e.toKey)};class p extends f.ExtensibleFunction{constructor(e,t,r,o){super(),i.add(this),this.impl=t,this.cache=r,this.toKey=o,n.set(this,void 0),s.set(this,void 0),l(this,n,e,"f")}async _call(e){return null==this.cache?u(this,i,"m",a).call(this,e):this.cache().getOrSetAsync(u(this,i,"m",o).call(this,e),(()=>u(this,i,"m",a).call(this,e)))}setShim(e){l(this,s,e,"f")}hasShim(){return null!=u(this,s,"f")}clearShim(){l(this,s,void 0,"f")}cacheDelete(e){this.cache?.().delete(u(this,i,"m",o).call(this,e))}}n=new WeakMap,s=new WeakMap,i=new WeakSet,o=function(e){return this.toKey?.(e)??((0,d.isPrimitive)(e)?(0,h.toS)(e):(0,c.stringify)(e))},a=function(e){return(0,m.time)(u(this,n,"f")+(null==u(this,s,"f")?"(local)":"(remote)"),null==u(this,s,"f")?this.impl(e):u(this,s,"f").call(this,e))}},45255:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ShortCommandTimeoutMs=void 0;const i=r(42659);t.ShortCommandTimeoutMs=7*i.secondMs},92322:function(e,t,r){var i,n=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.SortedSet=void 0;const s=r(76790),o=r(17586);class a{constructor(e,t){this.valueOf=e,this.diff=t,i.set(this,[])}[(i=new WeakMap,Symbol.iterator)](){return n(this,i,"f")[Symbol.iterator]()}get length(){return n(this,i,"f").length}addAll(...e){for(const t of e)this.add(t)}findIndex(e){return this.findValueIndex(null==e?void 0:this.valueOf(e))}findValueIndex(e){if(null==e)return;let t=0,r=n(this,i,"f").length-1;for(;t<=r;){const s=t+Math.floor((r-t)/2),o=this.valueOf(n(this,i,"f")[s]);if(e===o)return{found:!0,index:s};e>o?t=s+1:r=s-1}return{found:!1,index:t}}add(e){const t=this.findIndex(e);return!1===t?.found&&n(this,i,"f").splice(t.index,0,e),t}nearest({t:e,limit:t,diff:r}){if(t>=this.length)return[...n(this,i,"f")];const o=t=>t<0||t>n(this,i,"f").length-1?null:(r??this.diff)(n(this,i,"f")[t],e),a=this.findIndex(e);if(null==a)return;let l=a.index-1,u=o(l),c=a.index,d=o(c);const h=[];for(;h.lengththis.valueOf(e)))}shift(){return n(this,i,"f").shift()}at(e){return(0,o.at)(n(this,i,"f"),e)}toA(){return[...n(this,i,"f")]}shiftLte(e){const t=this.findValueIndex(e);if(null==t||0===t.index&&!t.found)return[];if(t.index===n(this,i,"f").length-1){const e=[...n(this,i,"f")];return n(this,i,"f").length=0,e}return n(this,i,"f").splice(0,t.index+(t.found?1:0))}splice(e,t){return n(this,i,"f").splice(e,t)}retainLastN(e){return e{Object.defineProperty(t,"__esModule",{value:!0}),t.runtimeMs=t.StartTs=void 0,t.StartTs=Date.now(),t.runtimeMs=function(){return Date.now()-t.StartTs}},82328:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stdoutEnded=void 0;const i=r(1708),n=r(95705);t.stdoutEnded=function(){return(0,n.streamEnded)(i.stdout)}},71567:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StdoutWrite=t.isMigrationEvent=t.stdoutWriteMigration=t.stdoutWriteSettings=t.writeTTY=t.stderrWrite=t.stdoutWrite=t.stdoutWriteReady=t.ReadyStr=void 0;const n=i(r(1708)),s=r(22573),o=r(98553),a=r(23560),l=r(82328),u=r(38835),c=r(70025),d=r(95705);function h(e,t){return f({obj:e,ready:t,stream:n.default.stdout})}function f({obj:e,ready:r,stream:i}){if(null==i||(0,d.streamEnded)(i))return;const n=(0,o.stringify)(e,void 0,(0,a.isInfoService)()||(0,a.isMainService)()?2:void 0);i.write(n+"\n"),(0,a.isWorkerService)()&&null!=r&&(n.includes(u.FailStr)||(0,c.isFatalError)(n)||(0,c.isHealthCheckError)(n)?i.write(u.FailStr+"\n"):i.write(t.ReadyStr+"\n"))}t.ReadyStr=JSON.stringify({ready:!0}),t.stdoutWriteReady=function(e=!0){(0,l.stdoutEnded)()||n.default.stdout.write(JSON.stringify({ready:e})+"\n")},t.stdoutWrite=h,t.stderrWrite=function(e){return f({obj:e,stream:n.default.stdout})},t.writeTTY=f,t.stdoutWriteSettings=function(...e){const t={};for(const r of e)r.addToEnv(t);h(t)},t.stdoutWriteMigration=function(e){return h({migration:e.name})},t.isMigrationEvent=function(e){return null!=e&&(0,s.notBlank)(e.migration)},t.StdoutWrite={shutdownSync:()=>h({shutdownSync:!0}),restartSync:()=>h({restartSync:!0}),forceRestartSync:()=>h({forceRestartSync:!0}),rebuildLibrary:()=>h({rebuildLibrary:!0}),shutdown:()=>h({shutdown:!0})}},81168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.commonPrefixLengthIgnoreCase=t.commonPrefixIgnoreCase=t.commonPrefix=t.uniqSubstr=t.stripEmoji=t.stripDiacritics=t.sortNatural=t.sortNaturalBy=t.splitUp=t.splitKeep=t.zipStrings=t.wbrPath=t.trimQuotes=t.stripQuotes=t.dumbquote=t.stripAnsiEsc=t.longestPrefix=t.reverse=t.firstSubstringIgnoreCase=t.startsWithIgnoreCase=t.sortByCaseInsensitive=t.sortIgnoreCase=t.uniqIgnoreCase=t.compareIgnoreCase=t.capitalize=t.isFirstCharAZ=t.isUpperCase=t.isLowerCase=t.gist=t.stripSuffixIgnoreCase=t.stripPrefixIgnoreCase=t.spliceCapture=t.splitEvery=t.trim=t.maybeToS=t.countChars=t.contains=t.padReplace=t.rightPad=t.ensureSuffixIgnoreCase=t.wrap=t.stripSuffix=t.stripPrefix=t.isString=t.includesIgnoreCase=t.equalsIgnoreCase=t.ensureSuffix=t.ensurePrefix=t.ellipsize=t.splitFirst=void 0,t.splitUniq=t.dedupeNeedle=t.uniqPath=t.stripComments=t.unoctal=t.trimLeftPadding=t.lastIndexOfNonSpace=t.indexOfNonSpace=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(55835),a=r(31586),l=r(39926),u=r(34666),c=r(51926),d=r(59455),h=r(54993),f=r(48884),m=r(68852),p=r(38835);var g=r(38453);Object.defineProperty(t,"splitFirst",{enumerable:!0,get:function(){return g.splitFirst}});var y=r(51926);Object.defineProperty(t,"ellipsize",{enumerable:!0,get:function(){return y.ellipsize}}),Object.defineProperty(t,"ensurePrefix",{enumerable:!0,get:function(){return y.ensurePrefix}}),Object.defineProperty(t,"ensureSuffix",{enumerable:!0,get:function(){return y.ensureSuffix}}),Object.defineProperty(t,"equalsIgnoreCase",{enumerable:!0,get:function(){return y.equalsIgnoreCase}}),Object.defineProperty(t,"includesIgnoreCase",{enumerable:!0,get:function(){return y.includesIgnoreCase}}),Object.defineProperty(t,"isString",{enumerable:!0,get:function(){return y.isString}}),Object.defineProperty(t,"stripPrefix",{enumerable:!0,get:function(){return y.stripPrefix}}),Object.defineProperty(t,"stripSuffix",{enumerable:!0,get:function(){return y.stripSuffix}}),Object.defineProperty(t,"wrap",{enumerable:!0,get:function(){return y.wrap}});const v=r(28787);t.ensureSuffixIgnoreCase=function(e,t){return null==t||""===t?e:(e=(0,h.toS)(e),t=(0,h.toS)(t),e.endsWith(t)||(0,c.equalsIgnoreCase)(e.slice(-t.length),t)?e:e+t)},t.rightPad=function(e,t,r){if(0===r.length)throw new Error("rightPad() given empty pad");const i=String(e);return i+(0,l.padding)(r,t-i.length)},t.padReplace=function(e,t,r,i){return(0,c.strslice)(e,0,t)+(0,l.padding)(i,r)+(0,c.strslice)(e,t+r)},t.contains=function(e,t,r){return(0,h.toS)(e).indexOf((0,h.toS)(t),r)>-1},t.countChars=function e(t,r,i=0){if(null==r||0===r.length)return 0;const n=t.indexOf(r,i);return-1===n?0:1+e(t,r,n+r.length)},t.maybeToS=function(e){return null==e?void 0:String(e)},t.trim=function(e){return e.map(h.toS).filter((e=>(0,s.notBlank)(e)))},t.splitEvery=function(e,t,r){const i=Math.min(Math.ceil(e.length/t),r??e.length)-1;return i<=0?[e]:[...(0,a.times)(i,(r=>e.slice(r*t,(r+1)*t))),e.slice(i*t)]},t.spliceCapture=function(e,t){const r=t.exec(e);if(null==r||null==r[1])return;const i=r[0].indexOf(r[1])+r.index;return{captured:r[1],uncaptured:e.substring(0,i)+e.substring(i+r[1].length),unmatched:e.substring(0,r.index)+e.substring(r.index+r[0].length),matchedIndex:i}},t.stripPrefixIgnoreCase=function(e,t){return P(e=(0,h.toS)(e),t=(0,h.toS)(t))?e.slice(t.length):e},t.stripSuffixIgnoreCase=function(e,t,r={}){if(null==t)return e;const i=(0,h.toS)(e),n=(0,h.toS)(t);return n.length>0&&(0,c.equalsIgnoreCase)(i.slice(-n.length),n,r)?i.slice(0,-n.length):i},t.gist=function(e,t=80,r=80){const i=(0,h.toS)(e),n=i.length-(t+r);return n<=0?i:i.slice(0,t).trim()+" …(+"+n+" chars)…"+i.slice(-r).trim()},t.isLowerCase=function(e){return(0,h.toS)(e).toLocaleLowerCase()===e},t.isUpperCase=function(e){return(0,h.toS)(e).toLocaleUpperCase()===e};const w=/^[A-Z]/;function S(e,t){const r=e.localeCompare(t,void 0,{sensitivity:"base"});return 0===r?e.localeCompare(t):r}function b(e){return(0,d.toA)(e).sort(S)}function P(e,t){return null!=e&&null!=t&&0!==t.length&&0!==e.length&&(0,c.equalsIgnoreCase)(e.substring(0,t.length),t)}t.isFirstCharAZ=function(e){return w.test((0,h.toS)(e))},t.capitalize=function(e){return e=(0,h.toS)(e),(0,s.blank)(e)?e:(0,c.strslice)(e,0,1).toLocaleUpperCase()+(0,c.strslice)(e,1)},t.compareIgnoreCase=S,t.uniqIgnoreCase=function(e){return(0,i.uniqBy2)(e,c.equalsIgnoreCase)},t.sortIgnoreCase=b,t.sortByCaseInsensitive=function(e,t){return(0,d.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,o.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>{const r=S(e.cmp[0],t.cmp[0]);return 0!==r?r:(0,u.cmp)(e.cmp[1],t.cmp[1])})).map((e=>e.item))},t.startsWithIgnoreCase=P,t.firstSubstringIgnoreCase=function(e,t){if((0,i.isEmpty)(e)||(0,s.blank)(t))return;for(const r of e)if((0,c.equalsIgnoreCase)(r,t))return{index:0,match:r};for(const r of e){const e=t.indexOf(r);if(e>=0)return{index:e,match:r}}const r=t.normalize();for(const t of e){{const e=r.indexOf(t);if(e>=0)return{index:e,match:t}}const e=t.normalize();{const t=r.indexOf(e);if(t>=0)return{index:t,match:e}}{const t=r.toLowerCase(),i=e.toLowerCase(),n=t.indexOf(i);if(n>=0)return{index:n,match:i}}}},t.reverse=function(e){return null==e?e:[...e].reverse().join("")},t.longestPrefix=function(e,t){return(0,f.greatestBy)(t.filter((t=>e.startsWith(t))),(e=>e.length))},t.stripAnsiEsc=function(e){return(0,h.toS)(e).replace(/\u001B\[[\d;]+[a-z]/gi,"")};const _=[[/[‘’]/g,"'"],[/[“”„«»〃]/g,'"']];function E(e){return _.reduce(((e,[t,r])=>e.replace(t,r)),e).normalize()}t.dumbquote=E;const M=/^(['"]).+\1$/;t.stripQuotes=function(e){return(0,s.blank)(e)||(e=(0,h.toS)(e).trim(),null!=M.exec(E(e))&&(e=e.slice(1,-1).trim())),e};const C=/^['‘’].*['‘’]$/,T=/^["“”„«»〃].*["“”„«»〃]$/;function x(e,t){const r=D(e,t);return(0,f.flatZip)(r.nonSeparators,r.separators).filter((e=>null!=e&&e.length>0))}function D(e,t){if(!t.global)throw new Error("bad regex (missing global flag)"+p.NonRetriableErrorFlag);const r=[],i=[];let n,s=0;for(;null!=(n=t.exec(e));)n.index===t.lastIndex?t.lastIndex++:(t.lastIndex=n[0].length+n.index,r.push(e.substring(s,n.index)),i.push(e.substring(n.index,t.lastIndex)),s=t.lastIndex);return s(0,a.toFloat)(e.trim())??e))}t.trimQuotes=function(e){return e=(0,h.toS)(e).trim(),C.test(e)||T.test(e)?e.slice(1,-1).trim():e},t.wbrPath=function(e){return e.split(/(?<=[\\/_,:=-])/).map((e=>v.escape(e.normalize()))).join("")},t.zipStrings=function(...e){let t="";const r=(0,i.compactBlanks)(e),n=Math.max(...r.map((e=>e.length)));for(let e=0;e(0,o.map)(r[e],(e=>t+=e))));return t},t.splitKeep=x,t.splitUp=D,t.sortNaturalBy=k,t.sortNatural=function(e){return(0,n.sortBy)(e,(e=>k(e)))},t.stripDiacritics=function(e){return(0,h.toS)(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"")},t.stripEmoji=function(e){return(0,h.toS)(e).replace(/\ud83c[\udf00-\udfff]|\ud83d[\udc00-\ude4f]|\ud83d[\ude80-\udeff]/g,"")},t.uniqSubstr=function(e){const t=b((0,i.compactBlanks)(e)),r=t.filter(((e,r)=>!P(t[r+1],e)));return(0,n.sortBy)(r,(t=>e.indexOf(t)))},t.commonPrefix=function(e,t){if((0,s.blank)(e)||(0,s.blank)(t))return"";const r=Math.min(e.length,t.length);for(let i=0;i4===e?.length?(0,a.mapNumeric)(parseInt(e.slice(1),8),String.fromCharCode):void 0))).map(h.toS).join("")};const O=/#.*$/gm;t.stripComments=function(e){return e.replace(O,"")},t.uniqPath=function(e,t=":"){const r=new Set;for(const i of(0,d.toA)(e))if(null!=i&&!(0,s.blank)(i))for(const e of i.split(t))(0,s.blank)(e)||r.add(e);return[...r].join(t)},t.dedupeNeedle=function(e,t,r){if((0,s.blank)(t))return e;const i=new RegExp("(['\"]?)"+(0,m.escapeRegExp)(t)+"\\1","gm"),n=e.findIndex((e=>i.test(e))),o=new RegExp("("+(0,m.escapeRegExp)(r)+"[,:\\s]*){2,}","gim");if(n<0)return e;for(let t=n+1;te.trim()))))}},83556:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.asObjectKey=t.snake2camel=t.camel2words=t.camel2snake=void 0;const i=r(54993);function n(e){return(0,i.toS)(e).replace(/_([A-Z])/gi,((e,t)=>t.toUpperCase()))}t.camel2snake=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>"_"+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>"_"+e)).replace(/^_/,"").replace(/_+/g,"_")},t.camel2words=function(e){return(0,i.toS)(e).replace(/([A-Z])([a-z])/g,((e,t,r)=>" "+t.toLowerCase()+r)).replace(/[A-Z]+|\d+/g,(e=>" "+e)).trim()},t.snake2camel=n,t.asObjectKey=function(e){return n(e.replace(/^[A-Z]+/,(e=>e.toLowerCase())).replace(/[^a-z]+/gi,"_"))}},37628:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.shortFsStringSha=t.shortStringSha=t.stringShaToBuffer=void 0;const n=i(r(77598)),s=r(73913),o=r(55222);function a(e,t=s.HashBits){return n.default.createHash("sha512").update(e).digest().subarray(0,t/8)}function l(e,t=9,r=o.Radix58,i=224){return r.encodeBuffer(a(e,i)).substring(0,t)}t.stringShaToBuffer=a,t.shortStringSha=l,t.shortFsStringSha=function(e,t=24,r=o.GeoRadix,i=224){return l(e,t,r,i)}},94863:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultNormalizer=void 0;const i=r(54993);t.DefaultNormalizer=function(e){return null==e||""===e?void 0:(0,i.toS)(e).toLowerCase().normalize()}},96859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.paddedPositionalDiff=t.positionalDiff=t.lcdiff=t.str=t.radixDiff=t.lnsDiff=t.nonUniqIntersection=t.bigrams=t.diceCoeff=t.hamming=t.lcs=t.commonSubstringRatio=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(31586),a=r(39926),l=r(51926),u=r(54993),c=r(55222),d=r(97352),h=r(88158),f=r(77377),m=r(81168);function p(e,t){if(null==e)return t;if(null==t)return e;if((e=e.normalize())===(t=t.normalize())||t.includes(e))return e;if(e.includes(t))return t;const r=new d.Array2D(e.length);let i=0,n="";for(let s=0;s=i&&(i=r.get(s,o),n=(0,l.substr)(e,s-i+1,i)));return n}function g(e,t){if(null==e||null==t)return;if(e===t)return 0;const r=y(e,t);if(null!=r)return r;const i=e.normalize(),n=t.normalize();return e!==i||t!==n?y(i,n):void 0}function y(e,t){return e.length!==t.length?void 0:[...e].reduce(((e,r,i)=>r===t.charAt(i)?e:e+1),0)}function v(e,t){const r=e.toUpperCase().normalize(),i=t.toUpperCase().normalize();return(0,h.firstThunk)((()=>r===i?1:void 0),(()=>(0,s.blank)(e)!==(0,s.blank)(t)?0:void 0),(()=>1===e.length&&1===t.length?0:void 0),(()=>{const e=w(r),t=w(i);return 2*S(e,t).length/(e.length+t.length)}))}function w(e){if(null==e||0===e.length)return[];const t=[...e];return t.slice(0,-1).map(((e,r)=>e+t[r+1]))}function S(e,t){const r=(0,f.intersection)(e,t),n=[];return r.forEach((r=>{const s=Math.min((0,i.count)(e,(e=>e===r)),(0,i.count)(t,(e=>e===r)));(0,o.times)(s,(()=>n.push(r)))})),n}function b(e,t,r){const n=(0,i.commonPrefixLength)(e,t);return r((0,l.strslice)(e,n))-r((0,l.strslice)(t,n))}function P(e){const t=(0,i.compactBlanks)((0,u.toS)(e).split(/\D+/));return(0,n.sortBy)(t,(e=>-e.length))[0]}function _(e,t){const[r,i]=[e,t].map(P).map((e=>(0,s.blank)(e)?"":e));return b(r,i,(e=>(0,o.toInt)(e,{defaultValue:0})))}t.commonSubstringRatio=function(e,t){return[e,t].some(s.blank)?0:p(e,t).length/Math.max(e.length,t.length)},t.lcs=p,t.hamming=g,t.diceCoeff=v,t.bigrams=w,t.nonUniqIntersection=S,t.lnsDiff=_;const E=/[^\da-z]+/gi;function M(e,t){const[r,i]=[e,t].map((e=>(0,m.stripDiacritics)(e).replace(E,"").toLowerCase()));return b(r,i,(e=>c.RadixAlphaNum.decode(e)))}function C(e,t){let r;for(let i=Math.max(e.length,t.length);i>=0;i--){const n=(0,o.mapNumericOr)(e.charCodeAt(i),(e=>e),256),s=(0,o.mapNumericOr)(t.charCodeAt(i),(e=>e),256),a=(0,o.clamp)(-256,256,n-s);r=null==r?a:(r+a)/2}return r}t.radixDiff=M,t.str=function(e,t){return{pref:(0,i.commonPrefixLength)(e,t),ham:g(e,t),dice:v(e,t),lns:_(e,t),radixDiff:M(e,t)}},t.lcdiff=function(e){return(0,i.count)([...e.normalize()],(e=>0!==e.toLowerCase().localeCompare(e)))},t.positionalDiff=C,t.paddedPositionalDiff=function(e,t,r=8){return C((0,a.leftPad)(e,r," "),(0,a.leftPad)(t,r," "))}},84885:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringifySorted=void 0;const i=r(98553),n=r(88158);t.stringifySorted=function(e){return(0,i.stringify)((0,n.sortedKeys)(e))}},22277:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.TTLSet=void 0;const l=r(73614);class u{constructor(e,t=!1){i.add(this),this.ttlMs=e,this.scheduleExpirationTimers=t,this[o]="TTLSet",this.expireListeners=[],this.delegate=new Map,this.keys=this.values.bind(this)}get size(){return a(this,i,"m",s).call(this),this.delegate.size}add(e){return this.delegate.set(e,Date.now()),this.scheduleExpirationTimers&&(0,l.setUnrefTimeout)((()=>a(this,i,"m",s).call(this)),this.ttlMs+1),this}addAll(e){for(const t of e)this.add(t)}addIfMissing(e,t){const r=this.delegate.get(e);return null==r||a(this,i,"m",n).call(this,e,r)?(this.add(e),t()):void 0}clear(){return this.delegate.clear(),this}delete(e){return this.delegate.delete(e)}forEach(e){for(const[t,r]of this.delegate)a(this,i,"m",n).call(this,t,r)||e(t,t,this)}has(e){return null!=e&&!a(this,i,"m",n).call(this,e)}values(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield t)}()}entries(){const e=this;return function*(){for(const[t,r]of e.delegate)a(e,i,"m",n).call(e,t,r)||(yield[t,t])}()}toA(){return a(this,i,"m",s).call(this),[...this.delegate.keys()]}[(i=new WeakSet,o=Symbol.toStringTag,Symbol.iterator)](){return this.values()}on(e,t){this.expireListeners.push(t)}}t.TTLSet=u,n=function(e,t){if(t??(t=this.delegate.get(e)),null==t||!this.delegate.has(e))return!0;const r=t<=Date.now()-this.ttlMs;if(r){this.delegate.delete(e);for(const t of this.expireListeners)t(e)}return r},s=function(){for(const[e,t]of this.delegate)a(this,i,"m",n).call(this,e,t)}},94174:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isRootUser=t.username=t.userNameFromWindowsAccessToken=t.userNameFromWhoami=t.usernameFromUserInfo=t.usernameFromEnv=t.groupid=t.groupids=t.userid=t.userids=t.userDesc=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(38639),c=r(31586),d=r(50213),h=r(45255),f=r(84777),m=r(96706),p=r(43334),g=r(24399),y=(0,o.lazy)((()=>(0,d.mkLogger)("UserInfo")));t.userDesc=async function(){let e="user "+await(0,t.username)();return(0,c.gte0)((0,t.userid)())&&(e+=" (userid "+(0,t.userid)()+")"),e},t.userids=(0,o.lazy)((()=>(0,a.uniq)([s.default.geteuid?.(),s.default.getuid?.(),n.default.userInfo().uid]))),t.userid=(0,o.lazy)((()=>(0,t.userids)()[0])),t.groupids=(0,o.lazy)((()=>(0,a.uniq)([s.default.getegid?.(),s.default.getgid?.(),n.default.userInfo().gid]))),t.groupid=(0,o.lazy)((()=>(0,t.groupids)()[0])),t.usernameFromEnv=(0,o.lazy)((()=>{for(const e of["SUDO_USER","C9_USER","LOGNAME","USER","LNAME","USERNAME"]){const t=(0,m.getEnv)(e);if(!(0,l.blank)(t))return t}})),t.usernameFromUserInfo=(0,o.lazy)((()=>(0,l.toNotBlank)(n.default.userInfo()?.username))),t.userNameFromWhoami=(0,o.lazy)((async()=>(0,f.stdout_)("whoami",[],{ignoreExitCode:!0,timeoutMs:h.ShortCommandTimeoutMs,isIgnorableError:()=>!0}).then(l.toNotBlank).catch((e=>y().warn("$(whoami) failed",{error:e}))))),t.userNameFromWindowsAccessToken=(0,o.lazy)((async()=>p.isWin?g.PowerShell.instance().execute("[System.Security.Principal.WindowsIdentity]::GetCurrent().Name",l.toNotBlank):void 0)),t.username=(0,o.lazy)((async()=>(0,t.usernameFromEnv)()??(0,t.usernameFromUserInfo)()??await(0,t.userNameFromWhoami)()??await(0,t.userNameFromWindowsAccessToken)())),t.isRootUser=(0,o.lazy)((async()=>p.isWin?p.isWin?g.PowerShell.instance().execute("(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)",u.toBoolean):void 0:(0,t.userids)().includes(0)))},37805:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gitDate=t.gitSha=t.release=t.versionPrerelease=t.versionPatch=t.versionMinor=t.versionMajor=t.version=void 0,t.version="2024.3.1-prealpha",t.versionMajor=2024,t.versionMinor=3,t.versionPatch=1,t.versionPrerelease=["prealpha"],t.release="2024.3.1-prealpha+20240308150212",t.gitSha="d92384e8659ff46fbae8e6f81fa5867114a4a843",t.gitDate=new Date(1709938932e3),t.default={version:t.version,versionMajor:t.versionMajor,versionMinor:t.versionMinor,versionPatch:t.versionPatch,versionPrerelease:t.versionPrerelease,release:t.release,gitSha:t.gitSha,gitDate:t.gitDate}},48963:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pwshJsonDate=t.wmiDate=void 0;const i=r(42659),n=r(55835),s=r(31586),o=r(97790),a=r(97352),l=/((?:19|20)\d\d)([01]\d)([0-3]\d)([012]\d)([0-5]\d)([0-5]\d)\.(\d{6})([+-]\d{3})?/;t.wmiDate=function(e){const t=l.exec(e);if(null==t)return;const r=t.slice(1,8).map((e=>(0,s.toInt)(e)));if(!(0,n.allDefined)(r))return;const[o,a,u,c,d,h,f]=r,m=(0,s.toInt)(t[8],{defaultValue:0});return new Date(Date.UTC(o,a-1,u,c,d,h,f/1e3)-m*i.minuteMs)};const u=/Date\((\d+)\)/;t.pwshJsonDate=function(e){return(0,o.opt)(e).flatMap((e=>u.exec(e))).flatMap((e=>e[1])).flatMap(s.toInt).filter((e=>(0,a.within)(0,Date.now()+i.dayMs,e))).map((e=>new Date(e))).get()}},73568:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AbortError=void 0;class r extends Error{}t.AbortError=r},76740:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.Abortable=void 0;const a=r(45599),l=r(56409),u=r(73568);t.Abortable=class{constructor(){this._aborted=!1,i.set(this,void 0),n.set(this,(0,a.defer)((()=>new l.Latch)))}abort(e){this._aborted||(this._aborted=!0,this._abortReason=e,s(this,n,"f").call(this).reject(new u.AbortError(e)).catch((()=>{})))}throwIfAborted_(e){if(!0===e?.aborted||this.aborted){const t=e?.reason??this._abortReason??"(no reason given)";throw new u.AbortError(t)}}get aborted(){return this._aborted}get reason(){return this._abortReason}abortPromise_(){return s(this,n,"f").call(this).promise}awaitOrAbort(e){return this.throwIfAborted_(),Promise.race([e,s(this,n,"f").call(this).promise])}setAbortTimeout(e,t){this.clearAbortTimeout(),o(this,i,setTimeout((()=>this.abort(t)),e).unref(),"f")}clearAbortTimeout(){null!=s(this,i,"f")&&clearTimeout(s(this,i,"f")),o(this,i,void 0,"f")}observeRejections(e){e.catch((e=>this.abort(e.message)))}observeResolutions(e,t){e.then((()=>this.abort(t)))}},i=new WeakMap,n=new WeakMap},22911:function(e,t,r){var i,n,s,o,a,l,u,c,d,h,f,m,p=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},g=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},y=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Deferred=void 0;const v=y(r(87997)),w=y(r(57975)),S=r(45599),b=r(26905),P=r(55835),_=r(31586),E=r(68708),M=r(20214),C=r(57153),T=r(85556),x=r(50213),D=r(70025),k=r(95937),O="TIMEOUT",I=(0,S.defer)((()=>(0,x.mkLogger)("async.Deferred")));class F{static async*toAsyncIterable(e,t){const r=[...e].reverse(),i=(0,_.gt0)(t)?new n(O).setTimeout(t):void 0;for(null!=i&&r.push(i);;){for(let i=r.length-1;i>=0;i--){const n=r[i];if(n.isSettled){if(n.name===O)return void I().warn("toAsyncIterable(): timeout",{timeoutMs:t,pending:e.map((e=>e.name))});r.splice(i,1),yield n.value}}if(r.every((e=>e.name===O)))break;try{await Promise.race(r)}catch{}}i?.clearTimeout()}static resolve(e,t){return new n(".resolved()",t).resolve(e)}constructor(e,t){var r,m,y;i.add(this),this.name=e,this.startedAt=Date.now(),o.set(this,void 0),a.set(this,C.PromiseStates.pending),l.set(this,void 0),u.set(this,void 0),c.set(this,void 0),d.set(this,void 0),h.set(this,void 0),f.set(this,void 0),this.id=(g(r=n,n,(y=p(r,n,"f",s),m=y++,y),"f",s),m),this.promise=new Promise(((e,t)=>{g(this,u,e,"f"),g(this,c,t,"f")})),this.payload=t?.payload,this.serialId=t?.serialId}get logger(){return p(this,f,"f")??(0,x.mkLogger)("async.Deferred("+this.name+")")}eql(e){return e instanceof n&&e.id===this.id}toLogJSON(){return{_ctor:"Deferred",name:this.name,state:p(this,a,"f"),value:this.value,serialId:this.serialId,payload:this.payload,elapsedMs:this.elapsedMs}}toJSON(){return(0,E.omit)(this.toLogJSON(),"value","elapsedMs")}get settledAt(){return p(this,o,"f")}get elapsedMs(){return(p(this,o,"f")??Date.now())-this.startedAt}get[(o=new WeakMap,a=new WeakMap,l=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,h=new WeakMap,f=new WeakMap,i=new WeakSet,Symbol.toStringTag)](){return"async.Deferred("+this.name+")"}[w.default.inspect.custom](){return this.toJSON()}observeQuietly(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.logger.warn("observeQuietly.reject()",e),this.maybeResolve(void 0)})):this.maybeResolve(e),this}observe(e){return(0,M.isPromise)(e)?e.then((e=>{this.maybeResolve(e)})).catch((e=>{this.maybeReject(e)})):this.maybeResolve(e),this}clearTimeout(){return null!=p(this,h,"f")&&(v.default.clearTimeout(p(this,h,"f")),g(this,h,void 0,"f"),!0)}setTimeout(e){return this.clearTimeout(),(0,_.gt0)(e)&&(g(this,h,v.default.setTimeout((()=>{this.isPending&&(this.reject(new T.TimeoutError("Timeout "+this.name+" after "+(Date.now()-this.startedAt)+"ms")),(0,k.onTimeout)())}),e),"f"),p(this,h,"f").unref()),this}get stateStr(){return this.isPending?"pending":this.isResolved?"resolved":"rejected"}get isPending(){return p(this,a,"f")===C.PromiseStates.pending}get value(){return this.isResolved?p(this,l,"f"):void 0}get error(){return p(this,d,"f")}get isSettled(){return p(this,a,"f")!==C.PromiseStates.pending}get isResolved(){return p(this,a,"f")===C.PromiseStates.resolved}get isRejected(){return p(this,a,"f")===C.PromiseStates.rejected}get settledMs(){return null==p(this,o,"f")?void 0:p(this,o,"f")-this.startedAt}resolve(e){return p(this,i,"m",m).call(this,(()=>{g(this,a,C.PromiseStates.resolved,"f"),g(this,l,e,"f"),p(this,u,"f").call(this,e)}))}maybeResolve(e){return this.isPending?this.resolve(e):this}reject(e){this.logger.log(!0===(0,D.isIgnorableError)(e)?"info":"warn",".reject()",e);const t=(0,b.asError)(e);return p(this,i,"m",m).call(this,(()=>{g(this,d,t,"f"),g(this,a,C.PromiseStates.rejected,"f"),p(this,c,"f").call(this,t)}))}maybeReject(e){return this.isPending?this.reject(e):this}finally(e){return this.promise.finally(e).catch((()=>{})),this}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch((t=>e(t)))}}t.Deferred=F,n=F,m=function(e){if(p(this,a,"f")===C.PromiseStates.pending){(0,P.map)(p(this,h,"f"),v.default.clearTimeout),e(),g(this,o,Date.now(),"f");const t=this.settledMs;this.isResolved&&t>5e3&&this.logger.info("Completed in "+t+"ms")}else this.logger.warn("settled multiple times (already "+this.stateStr+")",{value:p(this,l,"f")});return this},s={value:0}},27395:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.endablesStats=t.endAllEndables=t.endEndables=t.end=t.endAll=t.addEndable=void 0;const i=r(19851),n=r(40958),s=r(42659),o=r(23838),a=r(13538),l=r(50213),u=r(7282),c=r(97352),d=r(77740),h=r(25764),f=r(99331),m=r(73614),p=(0,i.lazy)((()=>(0,l.mkLogger)("async.Endable"))),g=new o.MultiMap;(0,m.setUnrefInterval)((()=>w()),10*s.minuteMs);const y=5*s.secondMs;async function v(e,t){const r=await e;if(null==r||!0===r?.ended)return;const i=(0,u.isTest)()&&(0,d.getDevEnvFlag)("PS_SINGLE_SPEC_TESTS")?500:(0,c.firstGt0)(t,r.endTimeoutMs,y);p().trace(r.name+" ending...",{timeoutMs:i});try{await(0,a.thenOrTimeoutError)(r.end(),i,(0,u.isTest)())}catch(e){try{p().warn(r.name+".end() failed",e)}catch{}}}function w(){g.filterInPlace(((e,t)=>!0!==t.ended)),p().debug("vacuumEndables()",g.entriesArray().map((([e,t])=>[e,t.map((e=>e.name))])))}t.addEndable=function(e,t){return h.EndableRanks.validOrElse(e,(()=>{throw new Error("internal error: invalid rank "+e)})),g.add(e,t),t},t.endAll=function(...e){return Promise.all(e.map((e=>v(e))))},t.end=v,t.endEndables=(0,i.lazy)((async()=>{const e=(0,u.isSingleSpecTests)()?500:void 0;p().info("endEndables()",{isTest:(0,u.isTest)(),isSingleSpecTests:(0,u.isSingleSpecTests)()}),(0,u.isTest)()||(0,f.setEnding)(!0),w();for(const t of h.EndableRanks.values){const r=g.get(t)??[];(0,n.isNotEmpty)(r)&&(p().debug("endEndables(): ending "+t),await Promise.allSettled(r.map((t=>v(t,e)))))}})),t.endAllEndables=async function(){return(0,f.setEnding)(!0),Promise.all((0,n.compact)(g.valuesFlat()).map((e=>v(e))))},t.endablesStats=function(){const e={};for(const t of h.EndableRanks.values){const r=g.get(t)??[];e[t]=r.map((e=>({name:e.name,ended:e.ended})))}return e}},78406:function(e,t,r){var i,n,s,o,a,l,u=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableInterval=void 0;const d=r(87997),h=r(55835),f=r(31586),m=r(68708),p=r(25764),g=r(38836),y=r(99331);class v extends g.EndableWrapper{constructor(e){super(e.name,(()=>u(this,i,"m",o).call(this)),e.rank??p.EndableRanks.first,e.endTimeoutMs),i.add(this),this.opts=e,n.set(this,void 0),s.set(this,void 0),a.set(this,(()=>{(0,y.ending)()||this.ended||this.opts.callback()})),null!=e.onEnd&&this.onEnds.push(e.onEnd),this.setIntervalMs(this.opts.intervalMs,this.opts.initialDelayMs,!0)}hasTimer(){return null!=u(this,n,"f")}hasTimeout(){return null!=u(this,s,"f")}get timingOpts(){return(0,m.pick)(this.opts,"intervalMs","initialDelayMs")}setIntervalMs(e,t,r=!1){if((0,y.ending)()||this.ended)return!1;if(e=(0,f.toInt)(e)??0,t=(0,f.toInt)(t)??0,!r&&this.opts.intervalMs===e&&(this.opts.initialDelayMs??0)===t)return!1;this.opts.intervalMs=e,this.opts.initialDelayMs=t,u(this,i,"m",o).call(this);const h=()=>{u(this,i,"a",l)&&(0,f.gt0)(this.opts.intervalMs)&&(c(this,n,(0,d.setInterval)(u(this,a,"f"),this.opts.intervalMs),"f"),!0===this.opts.unref&&u(this,n,"f").unref())};return(0,f.gt0)(this.opts.initialDelayMs)?(c(this,s,(0,d.setTimeout)((()=>{u(this,i,"a",l)&&(u(this,a,"f").call(this),h())}),this.opts.initialDelayMs),"f"),!0===this.opts.unref&&u(this,s,"f").unref()):h(),!0}}t.EndableInterval=v,n=new WeakMap,s=new WeakMap,a=new WeakMap,i=new WeakSet,o=function(){(0,h.map)(u(this,n,"f"),d.clearInterval),c(this,n,void 0,"f"),(0,h.map)(u(this,s,"f"),d.clearTimeout),c(this,s,void 0,"f")},l=function(){return!(0,y.ending)()&&!this.ended}},25764:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EndableRanks=void 0;const i=r(50989);t.EndableRanks=(0,i.strEnum)("first","stats","service","predb","db","postdb","logger","logtail","last")},38836:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.EndableWrapper=void 0;const a=r(19851),l=r(45599),u=r(56409),c=r(50213),d=r(27395),h=r(25764),f=r(99331),m=r(56519);t.EndableWrapper=class{constructor(e,t,r=h.EndableRanks.first,o){this.endTimeoutMs=o,i.set(this,void 0),this.onEnds=[],n.set(this,(0,a.lazy)((()=>new u.Latch))),this.end=(0,l.defer)((async()=>{this.logger.abortable.abort((0,f.ending)()?"service ending":"onEnd()"),await(0,m.awaitSettled)(this.onEnds.map((e=>e()))),s(this,n,"f").call(this).resolve()})),this.setName(e),null!=t&&this.onEnds.push(t),(0,d.addEndable)(r,this)}setName(e){o(this,i,e,"f"),this.logger=(0,c.mkLogger)(e)}get name(){return s(this,i,"f")}get ended(){return this.end.hasPrior()}awaitEnd(){return s(this,n,"f").call(this)}awaitOrAbort(e){return this.logger.awaitOrAbort(e)}get aborted(){return this.logger.abortable.aborted}},i=new WeakMap,n=new WeakMap},99331:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setEnding=t.ending=void 0;const i=r(7282);let n=!1;t.ending=function(){return n},t.setEnding=function(e){n=(0,i.isTest)()?e:e||n}},45608:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.exitOnStdStream=t.exit=t.onFatalHandlers=void 0;const n=i(r(1708)),s=r(22573),o=r(45599),a=r(37975),l=r(50213),u=r(71567),c=r(57159),d=r(57902),h=r(28874),f=r(27395),m=r(99331),p=r(56038),g=(0,o.defer)((()=>(0,l.mkLogger)((0,a.magenta)("Exit"))));t.onFatalHandlers=[];const y=(0,o.defer)((()=>{h.Settings.emitTimingsOnExit.valueOrDefault&&(0,u.stdoutWrite)(p.PromiseTimer.instance().report())}));async function v(e){g().log(0===e.status?d.LogLevels.info:d.LogLevels.warn,"exit()",{...e,ending:(0,m.ending)()}),y();const r=(0,c.toWrappedError)(e.error,{message:e.reason,errno:e.status});if(0!==r.errno||!0===r.fatal||0!==e.status){(0,u.stderrWrite)({fatal:!0,...e});const i=(0,s.toNotBlank)(e?.reason)??r.toString();for(const e of t.onFatalHandlers)await e(i)}(0,m.ending)()||(await(0,f.endEndables)(),n.default.exit(e.status))}t.exit=v,t.exitOnStdStream=(0,o.defer)((()=>{for(const e of["stdin","stdout","stderr"])for(const t of["close","error","disconnect","end"])n.default[e].on(t,(r=>{v({reason:`${e}:${t}`,status:0,error:r})}))}))},5916:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},d=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.lazyAsync=void 0;const h=r(50357),f=r(31586),m=r(41583),p=r(62344),g=r(22911);t.lazyAsync=function({later:e,desc:t,ttlMs:r,timeoutMs:i}){return new y(e,t,r,i)};class y extends p.ExtensibleFunction{constructor(e,t,r,l){super(),i.add(this),this.later=e,this.desc=t,this.ttlMs=r,this.timeoutMs=l,n.set(this,void 0),s.set(this,0),o.set(this,void 0),a.set(this,[])}_call(){return this.isStale()?c(this,i,"m",u).call(this,this.later()):c(this,o,"f")}unset(){d(this,s,0,"f"),d(this,n,void 0,"f"),d(this,o,void 0,"f")}set(e){return c(this,i,"m",u).call(this,g.Deferred.resolve(e))}refresh(){return c(this,i,"m",u).call(this,this.later())}ttl(){return this.ttlMs}setTTL(e){this.ttlMs=(0,f.gt0)(e)?e:void 0}watchLater(e){c(this,a,"f").push(e)}prior(){return this.isStale()?void 0:c(this,o,"f")}lastValue(){return c(this,o,"f")?.value}syncValue(){const e=this.lastValue();return this._call(),e}settledCount(){return c(this,s,"f")}isStale(){return null==c(this,n,"f")||(0,f.gt0)(this.ttlMs)&&Date.now()-c(this,n,"f")>this.ttlMs}lastSetAgoMs(){return null==c(this,n,"f")?void 0:Date.now()-c(this,n,"f")}elapsedMs(){return c(this,o,"f")?.settledMs??c(this,o,"f")?.elapsedMs}toString(){return this.desc??"[LazyAsync]"}toJSON(){return this.toString()}}n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=async function(e,t){var r;try{const r=await t;if(!(0,h.eql)(e?.value??await(e?.promise),r))for(const e of c(this,a,"f"))await e.onChange(r)}catch(e){const t=(0,m.toErr)(e);if(null!=t)for(const e of c(this,a,"f"))e.onError(t)}finally{d(this,s,(r=c(this,s,"f"),++r),"f")}},u=function(e){d(this,n,Date.now(),"f");const t=c(this,o,"f");return d(this,o,e instanceof g.Deferred?e:new g.Deferred(this.toString()).observe(e),"f"),(0,f.gt0)(this.timeoutMs)&&c(this,o,"f").setTimeout(this.timeoutMs),c(this,i,"m",l).call(this,t,c(this,o,"f")),c(this,o,"f")}},56519:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortByAsync=t.firstTruePromise=t.firstResolvedDefinedPromise=t.firstDefinedPromise=t.first=t.thenOrElse=t.thenAnd=t.thenMap2Or=t.thenMapOr=t.thenMap2=t.thenNot=t.thenFinally=t.tryAll=t.DefaultTryAllTimeoutMs=t.tryAsync=t.partitionAsync=t.filterAsync=t.mapAsync=t.thenCollectParallel=t.mapAsyncSerial=t.thenCollectSerial=t.asyncFind=t.thenUniq=t.thenFlatten=t.awaitSettled=t.awaitAll=t.allSerial=t.thenDefined=t.rejected=t.resolved=t.resolvedWithin=t.thenMapResolved=t.thenCollectBatched=t.thenCompact=t.someOrTimeout=t.thenMap=void 0;const i=r(40958),n=r(76790),s=r(38639),o=r(42659),a=r(41400),l=r(31586),u=r(20214),c=r(13538),d=r(42279),h=r(32639),f=r(59455),m=r(41583),p=r(48884),g=r(50213),y=r(88158),v=r(15674),w=r(42638);var S=r(20214);async function b(e){if(null==e)return[];const t=(0,i.compact)(await e);return(0,i.isEmpty)(t)?[]:(0,i.compact)(await Promise.all(t))}async function P(e){try{return await e,!0}catch(e){return!1}}async function _({name:e,arr:t,f:r,timeoutMs:n}){const s=[];for(const o of(0,i.compact)(await t))try{const e=await((0,l.gt0)(n)?(0,c.thenOrTimeoutError)(r(o),n):r(o));null!=e&&s.push([e,o])}catch(t){(0,g.mkLogger)(e).warn("failed to apply",{ea:o,error:t})}return s}async function E({arr:e,f:t,name:r,maxConcurrent:n,timeoutMs:s,promises:o}){if(null==e)return[];const a=(0,i.compact)(await e);if((0,i.isEmpty)(a))return[];if((n=Math.round(n??(0,v.maxCpus)()))<=1)return _({arr:e,f:t,name:r,timeoutMs:s});const u=o??(a.length<=n?w.PermissivePromises:new w.Promises(r,(()=>n))),d=(0,l.gt0)(s)?e=>(0,c.thenOrTimeoutError)(t(e),s):t,h=await u.enqueueAll(r,a.map((e=>async()=>{try{return[await d(e),e]}catch(t){return void(0,g.mkLogger)(r).warn("failed to apply",{ea:e,error:t})}})));return(0,i.compact)(h).filter((([e,t])=>null!=e&&null!=t))}Object.defineProperty(t,"thenMap",{enumerable:!0,get:function(){return S.thenMap}}),t.someOrTimeout=async function(e,t){return Promise.all(e.map((e=>(0,c.thenOrTimeoutError)((0,d.tol)(e),t.timeoutMs).catch((e=>e)))))},t.thenCompact=b,t.thenCollectBatched=async function(e,t,r){const i=[];for(const n of(0,p.batches)((0,f.toA)(await e),t)){const e=await b(n);i.push(...await b(r(e)))}return i},t.thenMapResolved=async function(e,t){if(null==e)return Promise.resolve(void 0);try{return await(0,u.thenMap)(e,t)}catch(e){return}},t.resolvedWithin=function(e,t){return Promise.race([e.then((()=>!0)),(0,a.delay)(t).then((()=>!1))]).catch((()=>!1))},t.resolved=P,t.rejected=async function(e){return!await P(e)},t.thenDefined=async function(e){return null!=await e},t.allSerial=async function(e){const t=[];for(const r of(0,i.compact)(e)){const e=await r();null!=e&&t.push(e)}return t},t.awaitAll=async function(e){for(const t of(0,f.toA)(e))null!=t&&await t},t.awaitSettled=async function(e){for(const t of(0,f.toA)(e))try{null!=t&&await t}catch{}},t.thenFlatten=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;if(null!=e)if(Array.isArray(e))for(const r of e){const e=await r;null!=e&&t.push(e)}else t.push(e)}return t},t.thenUniq=async function(e){const t=[];for(const r of(0,f.toA)(await e)){const e=await r;null!=e&&t.push(e)}return(0,i.uniq)(t)},t.asyncFind=async function(e,t){for(const r of e)if(await t(r))return r},t.thenCollectSerial=_,t.mapAsyncSerial=async function(e){return(await _(e)).map((e=>e[0]))},t.thenCollectParallel=E,t.mapAsync=async function({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s}){return(await E({arr:e,f:t,name:r,maxConcurrent:i,timeoutMs:n,promises:s})).map((e=>e[0]))},t.filterAsync=async function({name:e,arr:t,f:r,maxConcurrent:n,timeoutMs:s}){return(await E({name:e,arr:(0,i.compact)(t),f:r,maxConcurrent:n,timeoutMs:s})).filter((([e])=>e)).map((([,e])=>e))},t.partitionAsync=async function(e,t){const r=await E({name:"partitionAsync",arr:e,f:t});return[r.filter((([e])=>(0,s.isTrue)(e))).map((([,e])=>e)),r.filter((([e])=>(0,s.isFalse)(e))).map((([,e])=>e))]},t.tryAsync=async function(e){try{return await e()}catch{return}},t.DefaultTryAllTimeoutMs=30*o.secondMs,t.tryAll=async function(e,r=(e=>console.error(e)),i=t.DefaultTryAllTimeoutMs){for(const t of e)try{await(0,c.thenOrTimeout)(t,i)}catch(e){r((0,m.toErr)(e))}},t.thenFinally=async function(e,t=(()=>{}),r=(()=>{})){let i,n=null;try{i=await((0,h.isFunction)(e)?e():e)}catch(e){n=(0,m.toErr)(e);try{await t(e)}catch{}}try{await r(n??i)}catch{}if(null!=n)throw n;return i},t.thenNot=async function(e,t=!0){if(null==e)return t;const r=await e;return null==r?t:!(0,s.isTrue)(r)},t.thenMap2=async function(e,t,r){const i=await e;if(null==i)return;const n=await t;return null!=n?r(i,n):void 0},t.thenMapOr=async function(e,t,r){const i=await e;if(null==i)return r();const n=await t(i);return null==n?r():n},t.thenMap2Or=async function(e,t,r,i){const n=await e;if(null==n)return i();const s=await t;if(null==s)return i();const o=await r(n,s);return null==o?i():o},t.thenAnd=async function(e,t){return null!=e&&(0,s.isTrue)(await e)?t():void 0},t.thenOrElse=async function(e,t){return await e??t()},t.first=async function(e,t){if(null!=e){let r=-1;for(const i of e){r++;try{if(null==i)continue;const e=await t(i,r);if(null!=e)return e}catch{}}}},t.firstDefinedPromise=async function(e,t=y.identity){for(const r of e){const e=await r();if(null!=e){const r=await t(e);if(null!=r)return r}}},t.firstResolvedDefinedPromise=async function(e,t){for(const r of e)try{const e=await r();if(null!=e)return e}catch(e){t((0,m.toErr)(e))}},t.firstTruePromise=async function(e,...t){for(const r of t)try{const t=await r();if(null!=t&&!0===await e(t))return t}catch(e){}},t.sortByAsync=async function({name:e,arr:t,f:r}){const i=await E({name:e,arr:t,f:r});return(0,n.sortBy)(i,(e=>e[0])).map((e=>e[1]))}},56038:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timedLazy=t.timeStatsWithName=t.timeStatsWithPrefix=t.pushTime=t.timeSync=t.time=t.mkElapsed=t.PromiseTimer=void 0;const i=r(19851),n=r(40958),s=r(76790),o=r(42659),a=r(49769),l=r(31586),u=r(68708),c=r(42279),d=r(41583),h=r(22454),f=r(14121),m=r(50213),p=r(7282),g=r(34102),y=r(82647),v=r(25764),w=r(38836),S=r(73614);function b(e){return e.split(":")[0].trim()}class P{constructor(){this.errors=new h.CountingSet,this.times=new Map}clear(){this.errors.clear(),this.times.clear()}async time(e,t,r){const i=Date.now(),n=(0,l.clamp)(10*o.secondMs,o.minuteMs,Math.round(this.times.get(e)?.p98??0)),s=(0,S.setUnrefTimeout)((()=>{(0,m.mkLogger)("time("+e+")").warn("unsettled for "+(Date.now()-i)+"ms")}),n);try{const n=await(0,c.tot)(t),s=Date.now()-i;return r?.(n,s),this.push(e,s),n}catch(t){throw this.errors.incr(e),r?.((0,d.toErr)(t),Date.now()-i),t}finally{clearTimeout(s)}}get entriesBySumDesc(){return(0,s.sortBy)([...this.times.entries()],(([,e])=>-e.sum))}statsWithName(e){return this.times.get(b(e))?.stats()}statsWithPrefix(e){const t=this.entriesBySumDesc.filter((([t])=>t.startsWith(e))),r=t.reduce(((e,t)=>y.Average.merge(t[1],e)),new y.Average),i=t.map((([e,t])=>[e,t.stats()]));return(0,u.fromEntries)([["merged",r.stats()],...i])}mkElapsed(e){return new f.Elapsed(e,((e,t)=>this.push(e,t)))}push(e,t){t>15&&(0,a.getOrSet)(this.times,b(e),(()=>new y.Average)).push(t)}weightedAvg(e){return this.times.get(b(e))?.weightedSampleAvg}errorCounts(){return this.errors.top(10)}callCounts(){return[...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:r.n})),{})}weightedAvgs(){return(0,u.compactValues)([...this.times.entries()].reduce(((e,[t,r])=>({...e,[t]:(0,l.mapFinite)(r.weightedSampleAvg,l.round)})),{}))}toJSON(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:r.toJSON()})),{})}report(){return this.entriesBySumDesc.reduce(((e,[t,r])=>({...e,[t]:{sumSec:(0,l.sigFigs)(r.sum/o.secondMs,3),...(0,u.omit)(r.stats(),"sum")}})),{})}}function _(e,t,r){return P.instance().time(e,t,r)}function E(e,t){P.instance().push(e,t)}t.PromiseTimer=P,P.instance=(0,i.lazy)((()=>{const e=new P;return new w.EndableWrapper("PromiseTimer",(()=>{const t=(0,m.mkLogger)("async.PromiseTimer");(0,u.mapCompactObj)(e.report(),(e=>t.info("timings:",e))),(0,n.mapNotEmpty)(e.errorCounts(),(e=>t.warn("error counts:",(0,u.fromEntries)(e))))}),v.EndableRanks.stats),(0,p.isTest)()&&(0,g.ee)().on("clearCache",(()=>e.clear())),e})),t.mkElapsed=function(e){return P.instance().mkElapsed((0,m.mkLogger)(e))},t.time=_,t.timeSync=function(e,t){const r=Date.now(),i=t();return E(e,Date.now()-r),i},t.pushTime=E,t.timeStatsWithPrefix=function(e){return P.instance().statsWithPrefix(e)},t.timeStatsWithName=function(e){return P.instance().statsWithName(e)},t.timedLazy=function(e,t,r){return(0,i.lazy)((async()=>_(e,t)),r)}},42638:function(e,t,r){var i,n,s,o,a,l,u,c=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PermissivePromises=t.withBoundedConcurrency=t.maybeRun=t.Promises=t.toName=void 0;const f=h(r(66261)),m=r(40958),p=r(55835),g=r(31586),y=r(42279),v=r(54993),w=r(89788),S=r(82647),b=r(15674),P=r(22911);t.toName=function(e){return e?.name??(0,v.toS)(e)};class _{constructor(e,t){i.add(this),this.name=e,this.ee=new f.default.EventEmitter,n.set(this,void 0),this.lastWorkTs=0,this.settleMsAvg=new S.Average,s.set(this,0),o.set(this,[]),a.set(this,[]),this.lastPushedNames=new w.BoundedList(16),c(this,n,t,"f")}get maxConcurrency(){return Math.floor((0,g.clamp)(1,(0,b.maxCpus)(),d(this,n,"f")?.call(this)??(0,b.maxCpus)()))}end(){return d(this,a,"f").length=0,this.awaitAll()}vacuum(){return(0,m.filterInPlace)(d(this,o,"f"),(e=>e.isPending))}get running(){return this.vacuum()}get settledCount(){return d(this,s,"f")}stats(){return{maxConcurrency:this.maxConcurrency,lastPushMsAgo:Date.now()-this.lastWorkTs,freeSlots:this.freeSlots(),unsettledCount:this.unsettledCount(),runningNames:d(this,o,"f").map((e=>e.name)),pendingNames:d(this,a,"f").map((e=>e.d.name)),totalWorkCount:d(this,s,"f")}}enqueue({name:e,l:t,payload:r,serialId:n}){const s=d(this,i,"m",l).call(this,{name:e,l:t,payload:r,serialId:n});return this.laterPop(),s}enqueueAll(e,t){const r=t.map((t=>d(this,i,"m",l).call(this,{name:e,l:t}).promise));return this.laterPop(),Promise.all(r)}serial(e,t,r){return this.enqueue({name:e,l:t,serialId:e,payload:r})}push(e,t,r){return d(this,i,"m",u).call(this,new P.Deferred(e,{payload:r}),t).promise}get runningSerialIds(){return(0,m.compact)(this.vacuum().map((e=>e.serialId)))}laterPop(){setImmediate((()=>this.maybePopPendingWork()))}maybePopPendingWork(){this.vacuum();const e=this.maxConcurrency-d(this,o,"f").length;if(0===e)return;(0,m.isEmpty)(d(this,a,"f"))&&e>0&&this.ee.emit("vacancy"),this.isIdle()&&this.ee.emit("drain");const t=Math.min(d(this,a,"f").length,e),r=this.runningSerialIds,n=[];for(let e=0;et.name===e))}maybeRun(e,t){return this.freeSlots()>0&&!this.isTaskRunning(e)?this.push(e,t):void 0}runningCount(){return(0,m.count)(d(this,o,"f"),(e=>e.isPending))}unsettledCount(){return this.runningCount()+d(this,a,"f").length}hasPending(){return d(this,a,"f").length>0||this.running.length>0}isIdle(){return!this.hasPending()}freeSlots(){return(0,g.clamp)(0,this.maxConcurrency,this.maxConcurrency-this.unsettledCount())}isFull(){return 0===this.freeSlots()}pendingNames(){return[...d(this,a,"f").map((e=>e.d.name)),...this.running.map((e=>e.name))]}get deferreds(){return[...this.running,...d(this,a,"f").map((e=>e.d))]}pendingWithName(e){return this.deferreds.filter((t=>t.name===e))}payloadsWithName(e){return this.pendingWithName(e).filter((e=>null!=e.payload)).map((e=>e.payload))}get pendingPromises(){return this.deferreds.map((e=>e.promise))}async awaitSettled(){await Promise.allSettled(this.pendingPromises)}async awaitAll(){await Promise.all(this.pendingPromises)}async awaitAllByName(e){await Promise.all(this.deferreds.filter((t=>t.name===e)).map((e=>e.promise)))}}t.Promises=_,n=new WeakMap,s=new WeakMap,o=new WeakMap,a=new WeakMap,i=new WeakSet,l=function({name:e,l:t,payload:r,serialId:i}){const n=new P.Deferred(e,{payload:r,serialId:i});return d(this,a,"f").push({d:n,l:t}),n},u=function(e,t){const r=Date.now();return this.lastWorkTs=r,e.observe((0,y.tot)(t)).finally((()=>{var t;c(this,s,(t=d(this,s,"f"),++t),"f"),(0,m.remove)(d(this,o,"f"),e),this.settleMsAvg.push(Date.now()-r),this.laterPop()})),this.lastPushedNames.push(e.name),d(this,o,"f").push(e),e},t.maybeRun=function(e,t){const r=new _(e);return()=>r.maybeRun(e,t)},t.withBoundedConcurrency=async function({name:e,laters:t,maxConcurrent:r}){return new _(e,(0,p.map)(r,(e=>()=>e))).enqueueAll(e,t)},t.PermissivePromises={enqueueAll:(e,t)=>Promise.all(t.map((e=>e())))}},78656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RedoableError=void 0;class r extends Error{}t.RedoableError=r},4867:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeout=t.thenOrTimeoutError=t.timeoutStacks=void 0;const i=r(40958),n=r(34546),s=r(41400),o=r(31586),a=r(83104),l=r(85556),u=r(73568);t.timeoutStacks=[],t.thenOrTimeoutError=async function({p:e,timeoutMs:t,halt:r}){let a=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>a=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>{if(a)throw new l.TimeoutError})):void 0,r?.abortPromise_().then((()=>{if(a)throw new u.AbortError}))]))},t.thenOrTimeout=async function({p:e,timeoutMs:t,halt:r}){let l=!0;return Promise.race((0,i.compact)([(0,n.asPromise)(e).finally((()=>l=!1)),(0,o.gt0)(t)?(0,s.delay)(t).then((()=>a.Timeout)):void 0,r?.abortPromise_().then((()=>{if(l)throw new u.AbortError}))]))}},95937:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.setTimeoutHandler=void 0;let r=e=>null;t.setTimeoutHandler=function(e){r=e},t.onTimeout=function({soft:e}={}){r(e)}},73614:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefInterval=t.setUnrefTimeout=void 0;const i=r(87997);t.setUnrefTimeout=function(e,t,...r){return(0,i.setTimeout)(e,Math.round(t),...r).unref()},t.setUnrefInterval=function(e,t,...r){return(0,i.setInterval)(e,Math.round(t),...r).unref()}},31562:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.untilTrue=t.until=void 0;const i=r(38639),n=r(42659),s=r(41400),o=r(32639),a=r(31586),l=r(45255),u=r(95937);async function c(e,{timeoutMs:t,intervalMs:r,acceptable:i,timeoutResult:c,unref:d}={}){let h=!1;const f=null==t?void 0:t+Date.now();let m=1;for(;null==f||Date.now()t/2&&!h&&(h=!0,(0,u.onTimeout)({soft:!0}));const i=r??(0,a.clamp)(10*m,l.ShortCommandTimeoutMs,(t??n.minuteMs)/5);await(0,s.delay)(i,d),m++}}return h||(0,u.onTimeout)({soft:!1}),c}t.until=c,t.untilTrue=async function(e,t={}){return c(e,{...t,acceptable:i.isTrue,timeoutResult:!1})}},9727:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.childEnv=t.spawnOptions=t.childProcEnvSettings=t.sanitizedEnv=t.psenv=void 0;const n=i(r(1708)),s=r(45599),o=r(41400),a=r(50357),l=r(68708),u=r(48884),c=r(36638),d=r(44198),h=r(59958),f=r(96706),m=r(34102),p=r(19851),g=r(19043),y=r(66184),v=r(50213),w=r(7282),S=r(88158),b=r(45969),P=r(43334),_=r(28874),E=r(3790);function M(e){return C().has(e)||e.startsWith("LC_")||e.startsWith("PS_")}const C=(0,s.defer)((()=>{const e=new c.CaseInsensitiveSet;for(const t of(0,l.values)(_.Settings)){for(const r of t.names)e.add(r);for(const r of t.keys)e.add(r)}return e.add("NODE_ENV"),e.add(h.UV_THREADPOOL_SIZE),e.add("TZ"),e}));t.psenv=function(){return(0,S.sortedKeys)((0,l.filter)((0,d.env)(),(e=>M(e))))},(0,o.later)((()=>{function e(){t.sanitizedEnv.unset()}(0,m.ee)().on("clearCache",e),(0,m.ee)().on("settingsChanged",e);for(const t of(0,_.allSettings)())t.watchLater(e)}));const T=["HOME","LANG","USER"],x=["APPDATA","HOME","HOMEDRIVE","LOCALAPPDATA","SYSTEMDRIVE","SYSTEMROOT","TEMP"],D=(0,p.lazy)((()=>{const e=(0,f.caseInsensitiveEnv)().pick(...P.isPosix?T:x),t=(0,f.caseInsensitiveEnv)().lookup("PATH");return e[t?.key??"PATH"]=(0,_.pathWithDefaults)(),e}));function k(e){const t={NODE_ENV:(0,w.nodeEnv)(),NO_COLOR:"1",PS_LOG_STDOUT:"0"};t[h.PS_IS_CHILD_PROCESS]="1",t[h.PS_IS_DOCKER]=(0,b.isDocker)()?"1":"0",P.isElectron&&(t[h.ELECTRON_RUN_AS_NODE]="1");for(const r of(0,_.persistedSettings)()){const i=e?r.value:r.envValue;null==i||(0,a.eql)(i,r.defaultValue)||r.addToEnv(t)}return t}t.sanitizedEnv=(0,p.lazy)((()=>(0,l.filter)(n.default.env,(e=>M(e)||!(0,E.isSensitiveEnvKey)(e))))),t.childProcEnvSettings=k,t.spawnOptions=function(e){const t=e??{};return{...(0,l.omit)(t,"forceCLocale"),env:I({overrides:t.env,forceCLocale:t.forceCLocale}),detached:!1,shell:!1}};let O=!1;function I({overrides:e,forceCLocale:r=!0,forWorker:i=!1}={}){const n=(0,l.compactValues)({...(0,t.sanitizedEnv)(),...D(),...r?(0,g.childProcLocale)():{},...k(i),...e??{}});for(const e of(0,_.transientSettings)())e.deleteFromEnv(n);if((0,y.isLogged)("debug")&&!O){O=!0;const e=(0,v.mkLogger)("child.ChildEnv"),t=(0,l.entries)(n).map((([e,t])=>[e,(0,E.isHiddenEnvKey)(e)?"(hidden)":t])),[r,i]=(0,u.partition)(t,(([e])=>M(e)));e.debug("PS env:",(0,l.fromEntries)(r)),e.debug("non PS env:",(0,l.fromEntries)(i))}return n}t.childEnv=I},84777:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.stdout_=t.stdoutResult_=t.execFile=t.spawn=t.AddPidAfterMs=t.ReniceAfterMs=t.endProcess=void 0;const n=i(r(31421)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(22573),u=r(42659),c=r(98553),d=r(56409),h=r(31586),f=r(68708),m=r(51926),p=r(50213),g=r(7282),y=r(88158),v=r(79089),w=r(45255),S=r(22911),b=r(4867),P=r(73614),_=r(70025),E=r(57159),M=r(36868),C=r(66184),T=r(45643),x=r(95402),D=r(9727),k=(0,o.lazy)((()=>(0,p.mkLogger)("child.ChildProcess")));function O(e){return(0,f.pick)(e,"pid","killed","connected","exitCode","signalCode","spawnfile","spawnargs")}async function I(e,t=30*u.secondMs){if(null==e)return!1;k().debug("endProcess()",O(e));const r=e.pid;if(null==r||r<=0)return k().warn("endProcess(): asked to end invalid pid",O(e)),!1;if(r===s.default.pid)return k().warn("endProcess(): asked to end MY pid",O(e)),!1;if(r===s.default.ppid)return k().warn("endProcess(): asked to end my parent pid",O(e)),!1;(0,M.closeStreams)(e);{const t=e.kill();k().debug("endProcess("+r+")",{killResult:t,childGotSigterm:e.killed}),t||await(0,x.killPid)(r).catch((e=>{k().warn("endProcess(): kill("+r+",false) failed: "+e)}))}if((0,y.Try)((()=>e.unref())),(0,g.isSingleSpecTests)())return!0;if(await(0,T.waitForPidExit)(r,t))return k().debug("endProcess(): exitted",O(e)),!0;{x.Pids.instance()?.onKill(r);const t=e.kill("SIGKILL");k().warn("endProcess("+r+") had to resort to SIGKILL",{killResult:t}),t||await(0,x.killPid)(r,!0).catch((e=>{k().warn("endProcess(): kill("+r+",true) failed: "+e)}))}return(0,T.waitForPidExit)(r,5e3)}function F(e,r,i,n=0){const o=new Date,a=[];return(0,v.niceable)(r,i)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&(0,v.renice)(e.pid)}),(0,t.ReniceAfterMs)())),(0,h.gt)(n,u.secondMs)&&a.push((0,P.setUnrefTimeout)((()=>{(0,h.gt0)(e.pid)&&I(e)}),n-250)),a.push((0,P.setUnrefTimeout)((()=>{if((0,h.gt0)(e.pid))return(0,x.addPid)({pid:e.pid,cmd:r,timeoutMs:n,ppid:s.default.pid},o)}),(0,t.AddPidAfterMs)())),e.on("exit",(()=>a.forEach(clearTimeout))),e}function A(e,t,r,i){const s=(0,D.spawnOptions)(i);return(0,C.isLogged)("trace",k().context)?k().debug("execFile()",{command:e,args:t,timeoutMs:r,opts:s}):k().debug("execFile()",{command:e,args:t,timeoutMs:r}),F(n.default.execFile(e,t,s),e,t,r)}async function N(e,t,r){const i=r.quiet??!1,n=r.ignoreStderr??!1,s=r.ignoreExitCode??!1,o=A(e,t,r.timeoutMs,(0,f.omit)(r,"timeout","quiet","ignoreStderr","ignoreExitCode"));try{if(!0===r.disconnect){try{o.disconnect?.()}catch{}return{result:"",pid:o.pid}}const u=o.pid,f=(0,c.stringify)({pid:u,cmd:e,args:t}),m=[],p=[],g=[],y=new S.Deferred(f);o.on("error",(e=>g.push(e))),o.on("exit",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),o.on("close",(e=>{(0,h.isNumber)(e)&&y.isPending&&y.resolve(e)})),(0,M.endStream)(o.stdin);const v=new d.Latch;null==o.stdout?v.resolve():(o.stdout.on("error",(e=>g.push(e))),o.stdout.on("data",(e=>m.push(e))),o.stdout.on("end",(()=>v.resolve())));const P=new d.Latch;null==o.stderr||n?P.resolve():(o.stderr?.on("error",(e=>g.push(e))),o.stderr?.on("data",(e=>p.push(e))),o.stderr?.on("end",(()=>P.resolve()))),k().debug("stdoutResult_() invoked and waiting for completion...",{name:f}),await(0,b.thenOrTimeoutError)({p:y.promise,timeoutMs:r.timeoutMs,halt:r.halt}),k().debug("stdoutResult_() exitCode settled...",{name:f,exitCode:y.value,stdout:v.state(),stderr:P.state()}),await(0,b.thenOrTimeoutError)({p:v.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt}),await(0,b.thenOrTimeoutError)({p:P.promise,timeoutMs:w.ShortCommandTimeoutMs,halt:r.halt});const C=p.join("");(0,l.notBlank)(C)&&g.push(new Error(C)),!i&&(0,a.isNotEmpty)(g)&&k().warn(f+" resulted in errors:",g);const T=r.isIgnorableError??_.isIgnorableError,x=g.filter((e=>!0!==T(e)));if(x.length>0)throw 1===x.length?x[0]:new E.WrappedError("Failed to run "+e+" "+t.join(" "),{causes:x});if(!s&&0!==y.value)throw new Error(f+": exit code "+y.value);return{result:m.join(""),pid:u,code:y.value,stderr:C}}catch(e){throw k().error("stdoutResult_() failed",e),await(0,x.killPid)(o.pid,!0),e}}t.endProcess=I,t.ReniceAfterMs=(0,o.lazy)((()=>15*u.secondMs)),t.AddPidAfterMs=(0,o.lazy)((()=>30*u.secondMs)),t.spawn=function(e,t,r,i){const s=(0,D.spawnOptions)(i);return k().debug("spawn()",{command:e,args:t,maxAgeMs:r}),F(n.default.spawn(e,t,s),e,t,r)},t.execFile=A,t.stdoutResult_=N,t.stdout_=async function(e,t,r){const i=await N(e,t,r);return k().tap({level:"trace",msg:"stdout_()",result:(0,m.trimLastNewline)(i.result),meta:{cmd:e,args:t,opts:r,result:i}})}},3790:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isHiddenEnvKey=t.isSensitiveEnvKey=void 0;const i=r(22573),n=r(41400),s=r(19851),o=r(28874);(0,n.later)((()=>o.Settings.sensitiveEnvRegExp.watchLater((()=>a.unset()))));const a=(0,s.lazy)((()=>{try{return new RegExp(o.Settings.sensitiveEnvRegExp.valueOrDefault,"i")}catch(e){return console.error(`Invalid setting: ${o.Settings.sensitiveEnvRegExp.toEnvLine()}: ${e}. Using default.`),new RegExp(o.Settings.sensitiveEnvRegExp.defaultValue,"i")}}));function l(e){return!(0,i.blank)(e)&&a().test(e)}t.isSensitiveEnvKey=l,t.isHiddenEnvKey=function(e){return l(e)||o.Settings.license.includesEnvKey(e)}},41269:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CliDesc=void 0,t.CliDesc={main:"PhotoStructure's main process manager. Runs and manages web and sync services.",desktop:"PhotoStructure for Desktops. Manages web and sync services.",info:"Configuration, file metadata and import diagnostics tool.",list:"List items in a PhotoStructure Library.",logcat:"Chronologically sort and pretty-print PhotoStructure logfiles.",logtail:"View the log messages of currently-running PhotoStructure processes as they are emitted. (Like `tail -f`).",web:"PhotoStructure's web service. Automatically started by main. See https://phstr.com/tools for details.",sync:"PhotoStructure's directory synchronization service. Automatically started by main, but can be run manually. See https://phstr.com/go/sync for details."}},80061:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.addHelpFooter=t.cliWrapWithFooter=t.cliWrapVersion=t.cliWrap=void 0;const i=r(1708),n=r(31586),s=r(51926),o=r(17344),a=r(37805),l=r(84542);function u(e,t){const r=t?.maxLineLen??(0,n.toInt)(i.env.maxLineLen)??i.stdout.columns??75;return(0,s.wrap)(e,{maxLineLen:r,prefix:t?.prefix??""})}function c(...e){return(0,l.joinLines)(...u([...e,"",`Copyright © 2017-${(new Date).getFullYear()}, PhotoStructure Inc.`,"","BY USING THIS SOFTWARE, YOU ARE ACCEPTING ALL THE TERMS AND CONDITIONS OF THIS LICENSE: https://photostructure.com/eula/","","User guide: https://photostructure.com/user-guide/","","Questions, bug reports, and feature requests: https://forum.photostructure.com/",""]))}t.cliWrap=u,t.cliWrapVersion=function(){return c((0,o.EditionName)()+" v"+a.version)},t.cliWrapWithFooter=c,t.addHelpFooter=function(e){return e.addHelpText("afterAll",c())}},94361:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.verifyUidGid=t.whyUidGidMismatched=void 0;const i=r(19851),n=r(40958),s=r(55835),o=r(31586),a=r(94174),l=r(44198),u=r(45969);function c(e,t,r){const i=(0,o.toGt0)((0,l.env)()[t]);return null==i||r.includes(i)?void 0:`WARNING: ${e} is running as ${r} but $${t}=${i}`}function d(){const e=(0,n.compactBlanks)([c("user id","PUID",(0,a.userids)()),c("group id","PGID",(0,a.groupids)())]);return 0===e.length?void 0:e}t.whyUidGidMismatched=d,t.verifyUidGid=(0,i.lazy)((()=>{(0,u.isDocker)()&&(0,s.map)(d(),(e=>console.log(["",...e,"This may result in file permission issues!","See https://forum.photostructure.com/t/1597/2 for details.",""].join("\n"))))}))},76596:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateObjectToDateTime=t.utcIsoToTs=t.isoNow=t.durationHMS=t.durationToPaddedHMS=t.fmtMs=t.isRecentMs=t.nowish=t.closeTo=t.msUntil=t.cmpDate=t.isDateObject=void 0;const i=r(51168),n=r(19851),s=r(22573),o=r(42659),a=r(55835),l=r(31586),u=r(68708),c=r(34666),d=r(50213),h=(0,n.lazy)((()=>(0,d.mkLogger)("date.Date")));function f(e,t,r){return null!=e&&null!=t&&Math.abs(e.getTime()-t.getTime())<=r}t.isDateObject=function(e){return(0,u.isObject)(e)&&["year","month","day"].every((t=>t in e))},t.cmpDate=function(e,t){const r=(0,a.mapOr)(e,(e=>e.getTime()),(()=>0)),i=(0,a.mapOr)(t,(e=>e.getTime()),(()=>0));return(0,c.cmp)(r,i)},t.msUntil=function(e){if(null==e)return 0;const t=e.getTime(),r=Date.now();return t<=r?0:t-r},t.closeTo=f,t.nowish=function(e,t=2500){return null!=e&&((0,o.isDate)(e)?f(e,new Date,t):Math.abs(e-Date.now()){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultTimezoneSuffixes=t.DefaultDateTimeFormats=void 0,t.DefaultDateTimeFormats=["y-M-d 'at' HH.mm.ss","y-M-d HH-mm-ss","y-MM-dd HH-mm-ss","y-MMM-d HH-mm-ss","y-MMM-dd HH-mm-ss","y-MMMM-d HH-mm-ss","y-MMMM-dd HH-mm-ss","y-MM-dd HHmmss","yMMdd_HHmmss","yMMdd-HHmmss","y_MMdd_HHmmss","MM.dd.yyyy HH:mm:ss","F","FF"],t.DefaultTimezoneSuffixes=["ZZ","z"]},70488:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeDuration=t.decodeDuration=void 0;const i=r(22573),n=r(31586),s=r(54557),o=r(91655),a=new s.FifoCache(512);function l(e){return(0,n.isNumber)(e)?e:(0,i.blank)(e)?void 0:a.getOrSet(e,(()=>(0,o.parseDuration)(e)))}t.decodeDuration=l;const u=new s.FifoCache(512);t.encodeDuration=function(e){return(0,i.blank)(e)?void 0:u.getOrSet(e,(()=>(0,o.fmtFullDuration)((0,n.isNumber)(e)?e:l(e))))}},91655:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtFullDuration=t.parseDuration=void 0;const i=r(51168),n=r(40958),s=r(22573),o=r(42659),a=r(31586),l=r(51926),u=r(68852),c=r(70417);t.parseDuration=function(e){try{if(null==e||!(0,l.isString)(e)&&!(0,a.isNumber)(e))return;if((0,a.isNumber)(e))return e;if((0,a.isDigits)(e))return(0,a.toInt)(e);if(0===(e=e.trim().toUpperCase()).length)return;const t=i.Duration.fromISO(e);if(t.isValid)return t.toMillis();const r=/[\s,]*(?-?\d*\.?\d+)\s*(?milliseconds?|msecs?|millis|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?[\s,]*?/gi,d=(0,u.captures)(r,e);if(0===d.length)return;const h=(0,n.compact)(d.map((e=>function(e,t){const r=(0,a.toFloat)(e);if(null!=r){if((0,s.blank)(t))return r;switch(t.toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*o.yearMs;case"weeks":case"week":case"w":return r*o.weekMs;case"days":case"day":case"d":return r*o.dayMs;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o.hourMs;case"minutes":case"minute":case"mins":case"min":case"m":return r*o.minuteMs;case"seconds":case"second":case"secs":case"sec":case"s":return r*o.secondMs;case"milliseconds":case"millisecond":case"millis":case"msecs":case"msec":case"ms":return r;default:throw new Error(`parseDuration(): unit ${t} was matched, but no matching case exists.`)}}}(e.groups?.value,e.groups?.type)))),f=(0,a.lt0)(h[0])?[h[0],...h.slice(1).map((e=>-e))]:h;return(0,c.sum)(f)}catch{return}};const d=[{ms:o.yearMs,s:"y"},{ms:o.weekMs,s:"w"},{ms:o.dayMs,s:"d"},{ms:o.hourMs,s:"h"},{ms:o.minuteMs,s:"m"},{ms:o.secondMs,s:"s"},{ms:1,s:"ms"}];t.fmtFullDuration=function e(t,r=""){if(!(0,a.isNumber)(t))return;if(0===t)return"0";if(!(0,a.gte0)(t))return(0,a.isNumber)(t)?"-"+e(Math.abs(t)):void 0;const i=[];for(const e of d.slice(d.findIndex((e=>e.ms<=t)))){const r=Math.floor(t/e.ms);t-=r*e.ms,r>0&&i.push(r+e.s)}return i.join(r)}},84248:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AutoVacuumModes=void 0;const i=r(50989);t.AutoVacuumModes=(0,i.strEnum)("NONE","FULL","INCREMENTAL")},5531:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CheckpointTypes=void 0;const i=r(50989);t.CheckpointTypes=(0,i.strEnum)("AUTO","PASSIVE","FULL","RESTART","TRUNCATE")},99315:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RepairModes=void 0;const i=r(50989);t.RepairModes=(0,i.strEnum)("dump","recover")},34365:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SynchronousModes=void 0;const i=r(50989);t.SynchronousModes=(0,i.strEnum)("OFF","NORMAL","FULL","EXTRA")},49776:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.resetCacheDir=t.cacheDir_=t.cacheDir=t.defaultCacheDir=t.cacheDirs=t.tmpDirs=t.tmpCacheDirs=void 0;const o=s(r(76760)),a=r(40958),l=r(22573),u=r(55835),c=r(72993),d=r(19851),h=r(97352),f=r(94174),m=r(44198),p=r(96706),g=r(8769),y=r(57159),v=r(70698),w=r(64680),S=r(29882),b=r(45969),P=r(43334),_=r(28874),E=r(41692),M=r(32774),C=r(80612),T=r(32551),x=(0,d.lazy)((()=>(0,h.mapGte0)((0,f.userid)(),(e=>"-"+e))??""));function D(){if((0,b.isDocker)())return[{dir:"/tmp/.photostructure-cache"+x(),preexistingDir:"/tmp"}];{const e=[],t=P.isWin?[(0,p.getEnv)("TEMP"),(0,p.getEnv)("TMP")]:["/tmp","/var/tmp"];for(const r of t)(0,l.blank)(r)||e.push({dir:(0,o.join)(r,".photostructure-cache"+x()),preexistingDir:r});return e}}function k(){if((0,b.isDocker)())return(0,a.compact)([(0,u.map)((0,m.env)().XDG_CACHE_HOME,(e=>({dir:(0,o.join)(e,c.SimpleAppNameLC),preexistingDir:e}))),{dir:"/ps/tmp",preexistingDir:"/ps/tmp"},{dir:"/ps/cache",preexistingDir:"/ps/cache"},{dir:M.DefaultDockerLibraryDir+"/.photostructure/cache"+x(),preexistingDir:M.DefaultDockerLibraryDir},...D()]);const e=(0,a.compactBlanks)(P.isWin?[(0,p.getEnv)("LOCALAPPDATA"),o.default.resolve((0,T.homeDir)(),"AppData","Local")]:P.isMac?[o.default.resolve((0,T.homeDir)(),"Library","Caches")]:[(0,m.env)().XDG_CACHE_HOME,(0,o.join)((0,T.homeDir)(),".cache")]),t=P.isLinux?c.SimpleAppNameLC:c.SimpleAppName,r=e.map((e=>({dir:(0,o.join)(e,t),preexistingDir:e})));return r.push(...D()),r}t.tmpCacheDirs=D,t.tmpDirs=function(){return(0,C.filterDirs)({dirs:D(),desc:"tmp"})},t.cacheDirs=k,t.defaultCacheDir=(0,d.lazy)((()=>(0,C.firstDir)({dirs:k(),desc:"cache"})));const O=(0,d.lazy)((()=>{(0,E.setSettingsDefaults)(),_.Settings.cacheDir.watchLater(I)}));function I(){_.Settings.cacheDir.refreshEnvValue({broadcastChange:!1}),t.defaultCacheDir.unset(),t.cacheDir.unset(),t.cacheDir_.unset()}t.cacheDir=(0,d.lazy)((()=>{try{return(0,t.cacheDir_)()}catch(e){return void(0,g.onError)("cacheDir_() failed",{error:e})}})),t.cacheDir_=(0,d.lazy)((()=>{O();const e=_.Settings.cacheDir.valueOrDefault;try{return(0,S.mkdirpSync_)(e),(0,v.writeCachedirTag_)(e).then((()=>(0,w.mkNoMedia_)(e))),e}catch(t){throw new y.WrappedError("Failed to set up cacheDir, "+e,{path:e,fatal:!0,cause:t})}})),t.resetCacheDir=I},46292:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.osConfigDirs=t.resetConfigDir=t.configDir=void 0;const i=r(19851),n=r(45969),s=r(41692),o=r(32774),a=r(10924),l=r(84373),u=r(80612);t.configDir=(0,i.lazy)((()=>((0,s.setSettingsDefaults)(),(0,l.envConfigDir)()??((0,n.isDocker)()?(0,u.firstDir)({dirs:c,desc:"config"}):(0,a.desktopConfigDir)()))));const c=[{dir:"/ps/config",preexistingDir:"/ps/config"},{dir:o.DefaultDockerLibraryDir+"/.photostructure/docker-config",preexistingDir:o.DefaultDockerLibraryDir}];t.resetConfigDir=function(){t.configDir.unset()},t.osConfigDirs=function(){return((0,n.isDocker)()?c:(0,a.desktopConfigDirs)()).map((e=>e.dir))}},32774:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultDockerLibraryDir=void 0,t.DefaultDockerLibraryDir="/ps/library"},55086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultOriginalsDir=t.defaultLibraryDir=void 0;const i=r(66430),n=r(45969),s=r(32774);t.defaultLibraryDir=function(){return(0,n.isDocker)()?s.DefaultDockerLibraryDir:void 0},t.defaultOriginalsDir=function(){return(0,n.isDocker)()&&(0,i.isReadWriteableDirectorySync)("/ps/originals")?"/ps/originals":"."}},10924:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.desktopConfigDirs=t.desktopConfigDir=void 0;const n=i(r(76760)),s=r(40958),o=r(72993),a=r(44198),l=r(96706),u=r(43334),c=r(80612),d=r(32551);function h(){const e=[];return u.isWin?e.push((0,l.getEnv)("APPDATA"),n.default.resolve((0,d.homeDir)(),"AppData","Roaming")):u.isMac?e.push(n.default.resolve((0,d.homeDir)(),"Library","Application Support")):e.push((0,a.env)().XDG_DATA_HOME,(0,a.env)().XDG_CONFIG_HOME,n.default.resolve((0,d.homeDir)(),".config")),(0,s.compactBlanks)(e).map((e=>({dir:n.default.join(e,(0,o.AppName)()),preexistingDir:e})))}t.desktopConfigDir=function(){return(0,c.firstDir)({dirs:h(),desc:"config"})},t.desktopConfigDirs=h},84373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envConfigDir=void 0;const i=r(22573),n=r(96706),s=r(29882);t.envConfigDir=function(){const e=(0,n.getEnv)("PS_CONFIG_DIR");if(!(0,i.blank)(e))try{return(0,s.mkdirpSync_)(e),e}catch(t){console.error("The environment variable PS_CONFIG_DIR is set to "+e+", but mkdir failed.",t)}}},80612:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filterDirs=t.firstDir=void 0;const i=r(44652),n=r(40958),s=r(22573),o=r(66430);function a({dirs:e,desc:t}){for(const{dir:r,preexistingDir:a}of(0,n.compact)(e))if(!(0,s.blank)(r)){if((0,o.isReadWriteableDirectorySync)(r))return r;if((0,s.blank)(a)||(0,o.isReadWriteableDirectorySync)(a))try{return(0,i.mkdirpSync)(r),r}catch(e){console.error("Failed to mkdir for "+t,e)}}}t.firstDir=a,t.filterDirs=function({dirs:e,desc:t}){return(0,n.compact)(e.map((e=>a({dirs:[e],desc:t}))))}},32551:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.homeDir=void 0;const i=r(48161),n=r(76760),s=r(1708),o=r(19851),a=r(40958),l=r(68284),u=r(43334);t.homeDir=(0,o.lazy)((()=>{const e=[];u.isWin?e.push(s.env.USERPROFILE):e.push(s.env.HOME);for(const t of(0,a.compactBlanks)(e)){const e=(0,n.resolve)(t);if((0,l.isDirectorySync)(e))return e}return(0,i.homedir)()}))},46296:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logDir=t.defaultLogDir_=t.defaultLogDirs=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(55835),u=r(54993),c=r(72993),d=r(96706),h=r(45969),f=r(43334),m=r(32707),p=r(6707),g=r(49776),y=r(32774),v=r(80612),w=r(32551);function S(){return(0,h.isDocker)()?[{dir:"/ps/logs",preexistingDir:"/ps/logs"},{dir:y.DefaultDockerLibraryDir+"/.photostructure/logs",preexistingDir:"/ps/library"},{dir:"/tmp/photostructure-logs",preexistingDir:"/tmp"}]:f.isMac?[{dir:n.default.resolve((0,w.homeDir)(),"Library","Logs",c.SimpleAppName),preexistingDir:(0,w.homeDir)()}]:(0,o.compact)((0,g.cacheDirs)()).map((e=>({dir:(0,l.map)(e.dir,(e=>n.default.resolve(e,"logs"))),preexistingDir:e.preexistingDir})))}function b(){return(0,v.firstDir)({dirs:S(),desc:"logs"})}t.defaultLogDirs=S,t.defaultLogDir_=b,t.logDir=(0,s.lazy)((()=>{try{const e=(0,d.getEnv)("logDir");if((0,a.notBlank)(e))return e;const t=(0,p.readTomlFileSync)((0,m.systemSettingsFile)()),r=(0,u.toS)(t?.logDir);return(0,a.notBlank)(r)?r:b()}catch(e){return console.error("defaultLogDir_() failed",e),n.default.resolve((0,w.homeDir)(),"logs")}}))},55939:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultPicturesDir=t.picturesDir=t.picturesDirWindows=void 0;const i=r(76760),n=r(19851),s=r(22573),o=r(44198),a=r(43334),l=r(24399),u=r(32551);async function c(){return a.isWin?l.PowerShell.instance().executeJson('Get-ItemPropertyValue "Registry::HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders" -name "My Pictures"'):void 0}t.picturesDirWindows=c,t.picturesDir=(0,n.lazy)((async()=>{if(a.isWin){const e=await c();if((0,s.notBlank)(e))return e}return(0,t.defaultPicturesDir)()})),t.defaultPicturesDir=(0,n.lazy)((()=>(0,o.env)().XDG_PICTURES_DIR??(0,i.resolve)((0,u.homeDir)(),"Pictures")))},77740:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDevEnvFlag=t.getDevEnvFlag=void 0;const i=r(38639),n=r(7282),s=r(29325),o=r(44198);t.getDevEnvFlag=function(e){return!(0,n.isProd)()&&!(0,s.isPacked)()&&((0,i.toBoolean)((0,o.env)()[e])??!1)},t.setDevEnvFlag=function(e,t){process.env[e]=(0,o.env)()[e]=String(t)}},34580:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=void 0;const i=r(38639),n=r(44198);t.doNotTrack=function(){return(0,i.isTrue)((0,n.env)().DO_NOT_TRACK)}},44198:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.env=void 0;const n=i(r(73024)),s=r(76760),o=i(r(1708)),a=r(19851),l=r(40958),u=r(41400),c=r(68708),d=r(76850),h=r(7282),f=r(32551),m=r(34102),p=r(53265),g=r(45969),y=r(59958),v=r(6012),w=r(96706);t.env=(0,a.lazy)((()=>{const e=(0,l.uniq)((0,l.compactBlanks)(y.PS_ENV_KEYS.map((e=>o.default.env[e])).join(s.delimiter).split(s.delimiter)));0!==e.length||(0,g.isDocker)()||(0,h.isTest)()&&"lite"===o.default.env.PS_LICENSE||e.push((0,s.join)((0,f.homeDir)(),".psenv"));const t=(0,w.SensitiveEnvRE)(),r={...o.default.env};for(const i of e)try{const e=(0,d.debom)(n.default.readFileSync((0,p.resolve)(i))),s=(0,v.parseEnvTokens)({input:e,lowerCaseKeys:!1});for(const[e,i]of(0,c.entries)(s))t.test(e)||(r[e]=i)}catch(e){console.warn("env(): failed to read .env file, "+i,e)}return r})),(0,u.later)((()=>{(0,m.ee)().on("clearCache",(()=>t.env.unset()))}))},59958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IgnorableEnvKeys=t.DevEnvKeys=t.DevEnvFlags=t.UV_THREADPOOL_SIZE=t.ELECTRON_RUN_AS_NODE=t.PS_IS_DOCKER=t.PS_IS_CHILD_PROCESS=t.PS_ENV_KEYS=void 0;const i=r(50989);t.PS_ENV_KEYS=["PS_ENV","PS_ENV_FILE","PS_ENV_PATH"],t.PS_IS_CHILD_PROCESS="PS_IS_CHILD_PROCESS",t.PS_IS_DOCKER="PS_IS_DOCKER",t.ELECTRON_RUN_AS_NODE="ELECTRON_RUN_AS_NODE",t.UV_THREADPOOL_SIZE="UV_THREADPOOL_SIZE",t.DevEnvFlags=(0,i.strEnum)("PS_BAIL_ON_ERROR","PS_FAIL_DB_HEALTH_CHECK","PS_FAIL_SECURITY_HEALTH_CHECK","PS_FAIL_VOLUMES","PS_FORCE_FULLDISK","PS_FORCE_LITE","PS_FORCE_TRIAL","PS_KEEP_ENV","PS_NO_RANDOM_IMAGE_CACHE","PS_PRIVATE_KEYS","PS_QUICK","PS_SINGLE_SPEC_TESTS","PS_SKIP_ALL_TESTS","PS_SKIP_CLEANUP","PS_SKIP_RUN","PS_SLOMO","PS_TEST_HEALTH_CHECK_LEVEL","PS_FIX_JSON"),t.DevEnvKeys=["PS_NO_PUID_CHOWN","PS_TEST_VOLUME_UUIDS"],t.IgnorableEnvKeys=["PS_CONFIG_DIR",t.PS_IS_DOCKER,t.PS_IS_CHILD_PROCESS,...t.DevEnvKeys,...t.PS_ENV_KEYS,...t.DevEnvFlags.values]},83373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EnvKeys=void 0;const i=r(50989);t.EnvKeys=(0,i.strEnum)("HOME","NO_COLOR","PATH","PS_CONFIG_DIR","TMP","TEMP","XDG_CACHE_HOME","APPDATA","LOCALAPPDATA","ProgramData","ProgramFiles","ProgramFiles(x86)","ProgramW6432","SystemDrive","SystemRoot","USERPROFILE","windir")},6012:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseEnvTokens=void 0;const i=r(22573),n=r(84542);t.parseEnvTokens=function({input:e,lowerCaseKeys:t}){const r={};if((0,i.blank)(e))return r;let s;for(const o of(0,n.splitCompactLines)(e)){const e=/#.*$|(?:export\s+)?(?[a-z_]+)=(["'])?(?(?:\\["']|.)*?)\2(?=$|\s|#)/gim;for(;null!=(s=e.exec(o));){if(null==s.groups)continue;const{key:e,val:n}=s.groups;if((0,i.blank)(e)||null==n)continue;const o=n.replace(/\\n/g,"\n").replace(/\\(["'])/g,"$1");r[t?e.toLowerCase():e]=o}}return r}},96706:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isEnvTrue=t.getEnv=t.onEnvChange=t.caseInsensitiveEnv=t.SensitiveEnvRE=t.SensitiveEnvRegexPattern=void 0;const n=i(r(1708)),s=r(19851),o=r(22573),a=r(38639),l=r(41400),u=r(40583),c=r(79840),d=r(83556),h=r(34102),f=r(44198),m=r(83373);function p(){t.caseInsensitiveEnv.unset(),t.SensitiveEnvRegexPattern.unset(),t.SensitiveEnvRE.unset()}function g(e){return(0,t.caseInsensitiveEnv)().get(e)??(m.EnvKeys.includes(e)?void 0:(0,t.caseInsensitiveEnv)().get("PS_"+(0,d.camel2snake)(e)))}t.SensitiveEnvRegexPattern=(0,s.lazy)((()=>(0,o.firstNotBlank)(n.default.env.PS_SENSITIVE_ENV_REGEX_PATTERN,n.default.env.sensitiveEnvRegexPattern,c.DefaultSensitiveEnvRegexPattern))),t.SensitiveEnvRE=(0,s.lazy)((()=>{try{return new RegExp((0,t.SensitiveEnvRegexPattern)(),"i")}catch(e){return console.error(`Invalid setting for "sensitiveEnvRegExp": ${e}. Using default value.`),new RegExp(c.DefaultSensitiveEnvRegexPattern,"i")}})),t.caseInsensitiveEnv=(0,s.lazy)((()=>new u.CaseInsensitiveValued((0,f.env)()))),t.onEnvChange=p,(0,l.later)((()=>{f.env.watchLater(p),(0,h.ee)().on("clearCache",p)})),t.getEnv=g,t.isEnvTrue=function(e){return(0,a.isTrue)(g(e))}},98314:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToVerbose=t.MissingError=t.errorToS=t.joinErrorMessages=t.normalizeErrorMessages=t.splitErrorMessage=t.errorsToPath=t.addMessage=t.throws=t.errorContains=t.mapError=t.lastInternalErrors=t.internalErrorRate=t.fatalErrorRate=t.errorRate=t.logger=t.StartTs=void 0;const i=r(58587),n=r(19851),s=r(40958),o=r(22573),a=r(26905),l=r(96249),u=r(51926),c=r(23541),d=r(54993),h=r(89788),f=r(50213),m=r(81168),p=r(84542),g=r(41954),y=r(38835),v=r(70025),w=r(57159);function S(...e){if((0,s.isEmpty)(e))return[];const t=e.map((e=>(0,m.isString)(e)?e:(0,u.isBuffer)(e)?e.toString():(0,d.toS)(e?.message??e)));t.push(...(0,g.getErrorDescriptions)(e));const r=[...e.filter(c.isError).map(a.errorName),...e.map(a.errorCode),...(0,s.compactBlanks)(t).map(m.stripAnsiEsc).flatMap((e=>(0,p.splitCompactLines)(e))).flatMap((e=>e.split(a.ErrorDelimiter)))];return(0,s.uniqSubstrings)(b((0,l.flatten)(r)))}function b(e){return(0,s.compact)(e).filter((e=>!a.IgnoredErrorNames.includes(e))).map((e=>e.replace(/\s+/g," ").trim().replace(/^code ([A-Z]+)$/i,"$1").trim())).filter(o.notBlank)}function P(e,t){const r=(0,s.uniqSubstrings)(b(e)),i=t?.maxLen??400,n=t?.trailingChars??64,o=(0,y.sortErrorFlags)([...t?.flags??[],...(0,v.extractErrorFlags)(e.join(""))]);return(0,m.ellipsize)((0,v.stripErrorFlags)(r.join(a.ErrorDelimiter)),i-o.length,n)+o.sort().join("")}function _(e,t){return e instanceof w.WrappedError?e.toString():(0,o.blank)(e)?"":P(S(e),t)}t.StartTs=Date.now(),t.logger=(0,n.lazy)((()=>(0,f.mkLogger)("Error"))),t.errorRate=new i.Rate,t.fatalErrorRate=new i.Rate,t.internalErrorRate=new i.Rate,t.lastInternalErrors=new h.BoundedList(10),t.mapError=function(e,t){return e instanceof Error?t(e):void 0},t.errorContains=function(e,t){return t.test(_(e))},t.throws=function(e){try{return e(),!1}catch{return!0}},t.addMessage=function(e,t){return null==e?new Error(t):((0,o.notBlank)(t)&&(e.message.toLowerCase().includes(t.toLowerCase())||(e.message+=": "+t)),e)},t.errorsToPath=function(...e){for(const t of e)for(const e of["nativePath","path"]){const r=(0,d.toS)(t?.[e]);if((0,o.notBlank)(r))return r}},t.splitErrorMessage=S,t.normalizeErrorMessages=b,t.joinErrorMessages=P,t.errorToS=_,t.MissingError="(missing error)",t.errorToVerbose=function(e,r=256,i=7){return(0,o.blank)(e)&&(e=t.MissingError),_(e,{maxLen:r})+" at "+(0,a.shortStack)(e?.stack,i).join("; ")}},41954:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getErrorDescriptions=t.describeError=void 0;const i=r(40958),n=r(26905),s=r(55835),o=r(54993),a=r(81168);t.describeError=function(e){const t=(0,a.stripSuffix)((0,o.toS)(e).trim().toUpperCase(),":");return l[t]?.description??e},t.getErrorDescriptions=function(...e){const t=[];for(const r of e)(0,s.map)((0,n.errorErrno)(r),(e=>t.push(u.get(e)))),(0,s.map)((0,n.errorCode)(r),(e=>t.push(l[e]?.description)));return(0,i.uniq)(t)};const l={UNKNOWN:{errno:-1,description:"unknown error"},OK:{errno:0,description:"success"},EOF:{errno:1,description:"end of file"},EADDRINFO:{errno:2,description:"getaddrinfo error"},EACCES:{errno:3,description:"permission denied"},EAGAIN:{errno:4,description:"resource temporarily unavailable"},EADDRINUSE:{errno:5,description:"address already in use"},EADDRNOTAVAIL:{errno:6,description:"address not available"},EAFNOSUPPORT:{errno:7,description:"address family not supported"},EALREADY:{errno:8,description:"connection already in progress"},EBADF:{errno:9,description:"bad file descriptor"},EBUSY:{errno:10,description:"resource busy or locked"},ECONNABORTED:{errno:11,description:"software caused connection abort"},ECONNREFUSED:{errno:12,description:"connection refused"},ECONNRESET:{errno:13,description:"connection reset by peer"},EDESTADDRREQ:{errno:14,description:"destination address required"},EFAULT:{errno:15,description:"bad address in system call argument"},EHOSTUNREACH:{errno:16,description:"host is unreachable"},EINTR:{errno:17,description:"interrupted system call"},EINVAL:{errno:18,description:"invalid argument"},EISCONN:{errno:19,description:"socket is already connected"},EMFILE:{errno:20,description:"too many open files"},EMSGSIZE:{errno:21,description:"message too long"},ENETDOWN:{errno:22,description:"network is down"},ENETUNREACH:{errno:23,description:"network is unreachable"},ENFILE:{errno:24,description:"file table overflow"},ENOBUFS:{errno:25,description:"no buffer space available"},ENOMEM:{errno:26,description:"not enough memory"},ENOTDIR:{errno:27,description:"not a directory"},EISDIR:{errno:28,description:"illegal operation on a directory"},ENONET:{errno:29,description:"machine is not on the network"},ENOTCONN:{errno:31,description:"socket is not connected"},ENOTSOCK:{errno:32,description:"socket operation on non-socket"},ENOTSUP:{errno:33,description:"operation not supported on socket"},ENOENT:{errno:34,description:"no such file or directory"},ENOSYS:{errno:35,description:"function not implemented"},EPIPE:{errno:36,description:"broken pipe"},EPROTO:{errno:37,description:"protocol error"},EPROTONOSUPPORT:{errno:38,description:"protocol not supported"},EPROTOTYPE:{errno:39,description:"protocol wrong type for socket"},ETIMEDOUT:{errno:40,description:"connection timed out"},ECHARSET:{errno:41,description:"invalid Unicode character"},EAIFAMNOSUPPORT:{errno:42,description:"address family for hostname not supported"},EAISERVICE:{errno:44,description:"servname not supported for ai_socktype"},EAISOCKTYPE:{errno:45,description:"ai_socktype not supported"},ESHUTDOWN:{errno:46,description:"cannot send after transport endpoint shutdown"},EEXIST:{errno:47,description:"file already exists"},ESRCH:{errno:48,description:"no such process"},ENAMETOOLONG:{errno:49,description:"name too long"},EPERM:{errno:50,description:"operation not permitted"},ELOOP:{errno:51,description:"too many symbolic links encountered"},EXDEV:{errno:52,description:"cross-device link not permitted"},ENOTEMPTY:{errno:53,description:"directory not empty"},ENOSPC:{errno:54,description:"no space left on device"},EIO:{errno:55,description:"i/o error"},EROFS:{errno:56,description:"read-only file system"},ENODEV:{errno:57,description:"no such device"},ESPIPE:{errno:58,description:"invalid seek"},ECANCELED:{errno:59,description:"operation canceled"}},u=new Map(Object.values(l).map((e=>[e.errno,e.description])))},38835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.InternalErrorRe=t.FatalErrorRe=t.FatalErrorPatterns=t.FailStr=t.ErrorFlagsRE=t.RedoableFlag=t.WebFatalErrorFlag=t.NonFatalErrorFlag=t.DbSetupErrorFlag=t.NoLibraryErrorFlag=t.InternalErrorFlag=t.HealthCheckWarningFlag=t.RetriableErrorFlag=t.DoNotSendErrorFlag=t.HealthCheckErrorFlag=t.PleaseSendErrorFlag=t.IgnorableErrorFlag=t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag=t.FatalErrorFlag=t.sortErrorFlags=t.ErrorFlags=void 0;const i=r(40958),n=r(76790),s=r(50989),o=r(68852);t.ErrorFlags=(0,s.strEnum)("⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","₀","₁","₂","₃","₄"),t.sortErrorFlags=function(e){return(0,n.sortBy)((0,i.uniq)(e),(e=>t.ErrorFlags.indexOf(e)))},t.FatalErrorFlag=t.ErrorFlags["¹"],t.NonRetriableErrorFlag=t.ErrorFlags["²"],t.DoNotRetryErrorFlag=t.NonRetriableErrorFlag,t.IgnorableErrorFlag=t.ErrorFlags["³"],t.PleaseSendErrorFlag=t.ErrorFlags["⁴"],t.HealthCheckErrorFlag=t.ErrorFlags["⁵"],t.DoNotSendErrorFlag=t.ErrorFlags["⁶"],t.RetriableErrorFlag=t.ErrorFlags["⁷"],t.HealthCheckWarningFlag=t.ErrorFlags["⁸"],t.InternalErrorFlag=t.ErrorFlags["⁹"],t.NoLibraryErrorFlag=t.ErrorFlags["₀"],t.DbSetupErrorFlag=t.ErrorFlags["₁"],t.NonFatalErrorFlag=t.ErrorFlags["₂"],t.WebFatalErrorFlag=t.ErrorFlags["₃"],t.RedoableFlag=t.ErrorFlags["₄"],t.ErrorFlagsRE=new RegExp("("+t.ErrorFlags.values.join("|")+")","g"),t.FailStr=JSON.stringify({fatal:!0}),t.FatalErrorPatterns=["EADDRINUSE","SQLITE_FULL","SQLITE_CORRUPT","SQLITE_IOERR","SQLITE_NOMEM","SQLITE_NOTADB","ON CONFLICT","SQLITE_CONSTRAINT_NOTNULL","Error: Cannot find module",t.FatalErrorFlag,t.FailStr],t.FatalErrorRe=new RegExp(t.FatalErrorPatterns.map(o.escapeRegExp).join("|"),"i"),t.InternalErrorRe=/⁹|internal ?error/i},70025:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInternalError=t.isFatalError=t.isDoNotSendError=t.isNonRetriableError=t.isRetriableError=t.isRedoableError=t.isSqliteConstraintError=t.isSqliteDisconnectedError=t.isSqliteBusyError=t.isIgnorableError=t.isPleaseSendError=t.isHealthCheckError=t.hasErrorFlag=t.extractErrorFlags=t.stripErrorFlags=t.addErrorFlags=void 0;const i=r(40958),n=r(38639),s=r(26905),o=r(54993),a=r(68852),l=r(73568),u=r(78656),c=r(98314),d=r(38835);function h(e){return(0,o.toS)(e).replace(d.ErrorFlagsRE,"").trim()}function f(e){return d.ErrorFlags.values.filter((t=>e.includes(t)))}function m(e){return(0,c.errorToS)(e).includes(d.PleaseSendErrorFlag)}t.addErrorFlags=function(e,...t){const r=(0,o.toS)(e)+(0,i.compact)(t).join("");return h(r)+f(r).join("")},t.stripErrorFlags=h,t.extractErrorFlags=f,t.hasErrorFlag=function(e){return d.ErrorFlags.values.some((t=>e.includes(t)))},t.isHealthCheckError=function(e){return(0,c.errorToS)(e).includes(d.HealthCheckErrorFlag)},t.isPleaseSendError=m;const p=/Can't write [a-z\d]+ files/i,g=(0,a.orRegExpPatterns)([d.IgnorableErrorFlag,"AbortError","0 output files created","debugger attached","debugger listening on","diskutil: interrupted","ECONNRESET","ECONNREFUSED","EPIPE","for help","Format error in file","https://nodejs.org/en/docs/inspector","Missing expected status message","net::ERR_","This socket has been ended by the other party","Unexpected error while trimming",/\bwarning\b/i],"i");t.isIgnorableError=function(e){if(null==e)return!0;const t=e?.ignorable;if("boolean"==typeof t)return t;const r=(0,c.errorToS)(e);return!p.test(r)&&(!!g.test(r)||void 0)};const y=/SQLITE_BUSY|database is locked|busy executing a query/i;function v(e){return"SQLITE_BUSY"===e.code||y.test((0,c.errorToS)(e))}function w(e){return null!=(0,c.errorToS)(e).match(/database .+ not open/i)}function S(e){return null!=(0,c.errorToS)(e).match(/SQLITE_CONSTRAINT|constraint failed/i)}function b(e){return!!((0,n.isFalse)(e.retriable)||e instanceof l.AbortError||(0,c.errorToS)(e).includes(d.NonRetriableErrorFlag)||S(e))||void 0}t.isSqliteBusyError=v,t.isSqliteDisconnectedError=w,t.isSqliteConstraintError=S,t.isRedoableError=function(e){return e instanceof u.RedoableError||(0,c.errorToS)(e).includes(d.RedoableFlag)},t.isRetriableError=function(e){if(null==e)return;if(!0===b(e))return!1;const t=e?.retriable;if("boolean"==typeof t)return t;if("EBUSY"===(0,s.errorCode)(e)||v(e)||w(e))return!0;const r=(0,c.errorToS)(e);return!(!r.includes("EBUSY")&&!r.includes(d.RetriableErrorFlag))||void 0},t.isNonRetriableError=b;const P=[d.DoNotSendErrorFlag,"BatchCluster has ended","Corrupt JPEG data","ENOSPC","Invalid data found when processing input","premature end of data segment","VipsJpeg"];t.isDoNotSendError=function(e){const t=e?.doNotSend;if("boolean"==typeof t)return t;if(m(e))return!1;const r=(0,c.errorToS)(e).toLowerCase();return!!P.some((e=>r.includes(e)))||void 0},t.isFatalError=function(e){if(null==e)return!1;if((0,n.isTrue)(e.fatal))return!0;const t=(0,c.errorToS)(e);return!!t.includes(d.FatalErrorFlag)||!t.includes(d.NonFatalErrorFlag)&&d.FatalErrorRe.test(t)},t.isInternalError=function(e){return null!=e&&((0,n.isTrue)(e.internalError)||d.InternalErrorRe.test((0,c.errorToS)(e)))}},8769:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onInternalError=t.isFatalErrorAllowed=t.onError=void 0;const i=r(22573),n=r(31586),s=r(68708),o=r(7282),a=r(23560),l=r(45608),u=r(34102),c=r(28874),d=r(98314),h=r(38835),f=r(70025),m=r(57159),p=r(5012);function g(e,t){try{if((0,i.blank)(e)&&(0,s.isEmptyObj)(t))return(0,d.logger)().warn("onError() with no args",(0,p.stack)()),!1;const r=(0,m.toWrappedError)(e,t);(0,f.isInternalError)(e)&&(d.internalErrorRate.onEvent(),d.lastInternalErrors.push(e));const n=!0===r.fatal,c=!0===r.ignorable;if(!n&&c)return(0,d.logger)().info("onError(): (ignorable)",{error:e}),!1;d.errorRate.onEvent(),n&&(d.fatalErrorRate.onEvent(),(0,u.ee)().emit("fatal",r));const h=!n||y()?"nonFatal":"fatal";return(0,d.logger)().log("fatal"===h?"error":"warn","onError()",{event:h,error:r}),!n||(0,o.isTest)()||(0,a.isWebService)()||(0,l.exit)({reason:r.toString(),status:r.errno??13}),n}catch{return console.error("onError() threw an error!",{err:e,meta:t}),!1}}function y(){const e=(0,n.lt)(d.fatalErrorRate.eventsPerMinute,c.Settings.fatalErrorRatePerMinute.valueOrDefault),t=!(0,a.isPermaService)();return(0,d.logger)().tap({level:"info",msg:"isFatalErrorAllowed()",result:t&&e,meta:{acceptsFatalErrors:t,lowErrorRate:e,fatalErrorRatePerMin:(0,n.sigFigs)(d.fatalErrorRate.eventsPerMinute,2),errorRatePerMin:(0,n.sigFigs)(d.errorRate.eventsPerMinute,2),fatalErrorRatePerMinuteSetting:c.Settings.fatalErrorRatePerMinute.valueOrDefault}})}t.onError=g,t.isFatalErrorAllowed=y,t.onInternalError=function(e,t,r){return g(e+h.InternalErrorFlag,{cause:t,...r})}},57159:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrappedError=t.toWrappedError=void 0;const i=r(40958),n=r(22573),s=r(38639),o=r(26905),a=r(98553),l=r(68708),u=r(59455),c=r(41583),d=r(48884),h=r(81168),f=r(98314),m=r(38835),p=r(70025);t.toWrappedError=function(e,t){const r=null==t?{}:t instanceof Error?{cause:t}:{cause:t?.error,...t};if(e instanceof g&&(null==t||(0,n.blank)(r.message)||e.message.includes(r.message)))return e;const i=(0,n.firstNotBlank)((0,h.isString)(e)?e:void 0,e?.message,r?.message);return new g(i??"(missing error message)",r)};class g extends Error{constructor(e,t={}){super(e),this.causes=(0,i.uniqBy)((0,c.toErrs)(t.cause,t.meta?.error,...(0,u.toA)(t.causes)),(e=>e.message)),this.name=(0,o.errorName)(t)??(0,d.first)(this.causes,o.errorName)??"Error",this.codes=(0,h.splitUniq)([t.code,...this.causes.map(o.errorCode)],o.ErrorDelimiter),this.code=this.codes[0],this.codes.length<=1&&(this.codes=void 0),this.errno=t.errno??(0,d.first)(this.causes,(e=>(0,o.errorErrno)(e))),this.syscall=t.syscall??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.syscall))),this.path=t.path??(0,d.first)(this.causes,(e=>(0,n.toNotBlank)(e.path))),this.flags=t?.flags??[];const r=[t,this.flags.join(""),...this.causes];this.fatal=t.fatal??r.some(p.isFatalError),this.retriable=t.retriable??(0,s.maybeAnd)(r.map(p.isRetriableError)),this.ignorable=t.ignorable??(0,s.maybeAnd)(r.map(p.isIgnorableError)),this.doNotSend=t.doNotSend??(0,s.maybeAnd)(r.map(p.isDoNotSendError)),this.flags=(0,m.sortErrorFlags)([...this.flags,this.fatal?m.FatalErrorFlag:void 0,!0===this.retriable?m.RetriableErrorFlag:void 0,!1===this.retriable?m.NonRetriableErrorFlag:void 0,!0===this.ignorable?m.IgnorableErrorFlag:void 0,!1===this.doNotSend?m.PleaseSendErrorFlag:void 0,!0===this.doNotSend?m.DoNotSendErrorFlag:void 0]),this.meta=(0,l.mergeObjectsDeep)(...(t.causes??[]).map((e=>e.meta)),t.cause?.meta,(0,l.omit)(t,"_ctor","name","message","stack","code","codes","errno","syscall","path","cause","causes","retriable","ignorable","fatal","doNotSend","flags","meta"),t.meta),this.message=(0,p.stripErrorFlags)(function(e,t){let r=(0,f.splitErrorMessage)(e,t?.message,t?.cause,...t?.causes??[]);const i=t?.path;return(0,n.blank)(i)||(r=(0,h.dedupeNeedle)(r,i,"file")),(0,f.joinErrorMessages)([r[0],t?.code,...(0,u.toA)(t?.codes),t?.syscall,e,null!=t&&(0,l.notEmptyObj)(t?.meta)?(0,a.stringify)(t.meta):void 0,...r.slice(1)])}(e,this))+this.flags.join(""),this.stack=t.stack??(0,d.first)(this.causes,(e=>e.stack)),null==this.stack&&Error.captureStackTrace(this)}toJSON(){return{_ctor:"WrappedError",...this,message:this.message}}static fromJSON(e){return new g(e.message,e)}toString(){return this.message}toS(e){return null==e?this.message:(0,h.ellipsize)(this.message,e.maxLen,Math.max(e.trailingChars,this.flags.length+1))}}t.WrappedError=g},5012:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stack=void 0,t.stack=function e(){const t={};return Error.captureStackTrace(t,e),t.stack.split(/\n(?:\s*at\s+)?/).slice(1)}},15197:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.CapturingEventEmitter=void 0;const o=r(49769),a=r(55835),l=r(54993),u=r(22911),c=r(89788),d=r(7282);t.CapturingEventEmitter=class{constructor(e,t=((0,d.isTest)()?10:0)){this.target=e,this.eventsToRetain=t,i.set(this,new Map),n.set(this,new Map),this.priorEvents=new c.BoundedList(t)}once(e,t){return this.target.once(e,t),this}watchEvent(e){return(0,o.getOrSet)(s(this,i,"f"),e,(()=>new u.Deferred("watchEvent("+(0,l.toS)(e)+")")))}on(e,t){return this.target.on(e,t),this}off(e,t){return this.target.off(e,t),this}emit(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").delete(e),this.eventsToRetain>0&&this.priorEvents.push({name:e,args:t});const r=this.target.emit(e,...t),o=s(this,i,"f").get(e);return null!=o&&(o.resolve(t),s(this,i,"f").delete(e)),r}emitDebounced(e,...t){(0,a.map)(s(this,n,"f").get(e),clearTimeout),s(this,n,"f").set(e,setTimeout((()=>this.emit(e,...t)),50))}listeners(e){return this.target.listeners(e)}removeAllListeners(e){return this.target.removeAllListeners(e),this}},i=new WeakMap,n=new WeakMap},34102:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ee=void 0;const i=r(78474),n=r(19851),s=r(15197);t.ee=(0,n.lazy)((()=>{const e=new i.EventEmitter;return e.setMaxListeners(70),new s.CapturingEventEmitter(e)}))},64660:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.access=t.canRWXFirstExistingAncestor=t.isStatRX=t.isStatRWX=t.canAccessSync=void 0;const n=i(r(73024)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(65843),u=r(16287),c=r(43334),d=(0,o.lazy)((()=>s.default.geteuid?.())),h=(0,o.lazy)((()=>s.default.getgroups?.()));function f(e,t){try{return!(0,a.blank)(e)&&(n.default.accessSync(e,t),!0)}catch{return!1}}function m(e,t){return c.isWin?f(t,n.default.constants.R_OK|n.default.constants.W_OK):g({stat:e,r:!0,w:!0,x:!0})}function p(e,t){return c.isWin?f(t,n.default.constants.R_OK):g({stat:e,r:!0,x:!0})}function g({stat:e,r:t=!1,w:r=!1,x:i=!1,processUid:n,processGid:s}){if(null==e)return!1;const o=n??d(),a=null!=s?[s]:h()??[],l=0===o,u=l||e.uid===o,f=l||a.includes(e.gid);return!(t&&!(((u?256:0)|(f?32:0)|4)&e.mode))&&(!(r&&!(((u?128:0)|(f?16:0)|2)&e.mode))&&!!(!i||c.isWin||((u?64:0)|(f?8:0)|1)&e.mode))}t.canAccessSync=f,t.isStatRWX=m,t.isStatRX=p,t.canRWXFirstExistingAncestor=async function(e){let t=!1;for(const r of(0,l.selfAndAncestorG)(e)){const i=await(0,u.statMaybe)(r);if(null!=i){if(!i.isDirectory())return!1;if(t){if(!p(i,e))return!1}else if(t=!0,!m(i,e))return!1}}return!0},t.access=g},21144:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.actualPath_=t.actualPath=void 0;const n=i(r(76760)),s=r(19851),o=r(81168),a=r(57159),l=r(43334),u=r(88561),c=r(29882),d=r(65238),h=r(53265);t.actualPath=async function(...e){try{return await m(...e)}catch(t){return(0,c.logger)().warn("actualPath() failed, reverting to resolve()",{nativePath:e,error:t}),(0,h.resolve)(...e)}};const f=(0,s.lazy)((()=>new u.FileCache({name:"fs.Path.actualPathCache"})));async function m(...e){const t=(0,h.resolve)(...e);return l.isLinux||(0,c.pathIsRoot)(t)?t:f().getOrSetAsync(t,(async()=>{const r=(0,c.parseNativePath)((0,h.resolve)(...e)),i=await m(r.dir);for(const e of await(0,d.readdir_)(i))if((0,o.equalsIgnoreCase)(e.basename,r.base))return n.default.join(i,e.basename);throw new a.WrappedError(t+" not found",{code:"ENOENT",path:t})}))}t.actualPath_=m},65843:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ancestorWithChildren=t.hasChildrenSync=t.childrenSync=t.selfAndAncestorG=t.ancestorG=t.ancestors=void 0;const i=r(73024),n=r(76760);function s(e){return[...o(e)]}function*o(e){for(;e!==(0,n.dirname)(e);)e=(0,n.dirname)(e),yield e}function a(e){try{return(0,i.readdirSync)(e)}catch(e){return[]}}function l(e,t){const r=a(e);return t.every((e=>r.includes(e)))}t.ancestors=s,t.ancestorG=o,t.selfAndAncestorG=function*(e){yield e,yield*o(e)},t.childrenSync=a,t.hasChildrenSync=l,t.ancestorWithChildren=function(e,t){return s(e).find((e=>l(e,t)))}},83278:function(e,t,r){var i,n,s,o,a,l=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),u=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&l(t,e,r);return u(t,e),t},d=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},h=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execDir=t.useFsWatch=t.BaseFile=t.isBaseFile=void 0;const m=c(r(44652)),p=c(r(73024)),g=r(51455),y=f(r(76760)),v=f(r(1708)),w=r(46466),S=f(r(57975)),b=f(r(38522)),P=r(19851),_=r(40958),E=r(5233),M=r(22573),C=r(42659),T=r(50357),x=r(96249),D=r(98553),k=r(55835),O=r(31586),I=r(68708),F=r(97790),A=r(39926),N=r(51926),L=r(59455),R=r(54993),j=r(48884),B=r(22911),V=r(99331),z=r(56519),W=r(56038),q=r(31562),U=r(76850),H=r(70025),G=r(34102),J=r(80875),K=r(50213),$=r(70417),Y=r(43334),Z=r(81168),X=r(96859),Q=r(65162),ee=r(94174),te=r(64660),re=r(21144),ie=r(84542),ne=r(89968),se=r(20197),oe=r(88561),ae=r(50597),le=r(33456),ue=r(29882),ce=r(78133),de=r(43899),he=r(65238),fe=r(53265),me=r(17217),pe=r(16287),ge=r(68284),ye=r(66003),ve=r(27794),we=r(73428),Se=r(13047);t.isBaseFile=function(e){return(0,me.isSimpleFile)(e)&&e instanceof Pe};const be=(0,P.lazy)((()=>new oe.FileCache({name:"fs.BaseFile"})));class Pe{constructor(e,t){if(i.add(this),this.dirent=t,this.bflog=(0,P.lazy)((()=>(0,K.mkLogger)("fs.BaseFile("+this.nativePath+")"))),n.set(this,(0,P.lazy)((async()=>(await this.directoryEntry())?.children()))),o.set(this,void 0),null!=t)this.nativePath=t.nativePath,this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext;else{this.nativePath=e;const t=(0,ue.parseNativePath)(this.nativePath);this.dir=t.dir,this.base=t.base,this.name=t.name,this.ext=t.ext}this.posixPath=(0,ce.native2posix)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[(n=new WeakMap,o=new WeakMap,i=new WeakSet,S.default.inspect.custom)](){return this.toJSON()}static async withFastestAccess(e){const t=(0,_.compact)(e),r=await Promise.all(t.map((e=>e.shaMs())));return t[(0,j.leastIndex)(r)]}static forPosix(e){return e instanceof Pe?e:this.for(e.split("/").join(y.default.sep))}static forDirectoryEntry(e){return this.for(e.nativePath,e)}static for(e,t){if(e instanceof Pe)return e;const r=(0,me.isSimpleFile)(e)?e.nativePath:(0,R.toS)(e);if((0,M.blank)(r))throw new Error("BaseFile.for(): empty nativePathOrFile");const i=be().get(r);if(null!=i)return i;const n=(0,fe.resolve)(r),s=new Pe(n,t);return be().set(r,s),be().set(n,s),s}static clear(e){(0,G.ee)().emit("fileChanged",e)}for(e,t){return Pe.for(e,t)}forDirectoryEntry(e){return Pe.for(e.nativePath,e)}forChildDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.nativePath,e))}forSiblingDirent(e){return this.forDirectoryEntry(ne.DirectoryEntry.fromSimpleDirent(this.dir,e))}clear({emit:e}={}){return!0===e&&(0,G.ee)().emit("fileChanged",this.nativePath),this.dirent=void 0,d(this,n,"f").unset(),h(this,o,void 0,"f"),this}clearThisAndParent(){return(0,G.ee)().emit("fileChanged",this.dir),this.clear({emit:!1})}toString(){return this.nativePath}valueOf(){return this.pathnames}resolve(){const e=(0,fe.resolve)(this.nativePath);return e===this.nativePath?this:this.for(e)}eql(e){return null!=e&&(0,ue.eqlPath)(this,e)}get isUNC(){return(0,ue.isUNC)(this.nativePath)}get baseWithParent(){return(this.isRoot?"/":this.parent().isRoot?"/"+this.base:(this.parent().parent().isRoot?"/":"")+this.parent().base+"/"+this.base).normalize()}ellipsize({maxLength:e=80}={}){return(0,ue.ellipsizePath)({p:this,maxLength:e})}get baseWithParentNoExt(){return(0,Z.stripSuffix)(this.baseWithParent,this.ext)}get baseWithGrandparent(){return(this.isRoot?"/":this.parent().isRoot?this.baseWithParent:this.parent().baseWithParent+"/"+this.base).normalize()}posixPathFrom(e){return(0,ue.posixPathFrom)(e,this)+(this.isDirectorySync()?"/":"")}async directoryEntry(){return this.dirent??(this.dirent=await(0,z.thenMap)(this.stat(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}directoryEntrySync(){return this.dirent??(this.dirent=(0,k.map)(this.statSync(),(e=>new ne.DirectoryEntry(this.dir,new ne.StatDirent(this.base,e)))))}async childDirectoryEntries(e){const t=await d(this,n,"f").call(this);if(null==t||null==e||(0,_.isEmpty)(t))return t;const r=[];for(const i of t)!0===await e(i)&&r.push(i);return r}_directoryEntryChild(e){return this.for(y.default.join(this.nativePath,e.base),e)}childNames(){return(0,z.thenMap)(this.childDirectoryEntries(),(e=>e.map((e=>e.base))))}async resolve_(){var e;return await d(this,i,"m",s).call(this)??await d(e=this.clearThisAndParent(),i,"m",s).call(e)}async children_(e){const t=await(0,he.readdir_)(this.nativePath);return null!=e&&await(0,_.filterInPlaceAsync)(t,e),t.map((e=>this.forChildDirent(e)))}async children(e){return(await this.childDirectoryEntries(e))?.map((e=>this._directoryEntryChild(e)))}async childFiles(e){const t=await this.childDirectoryEntries((async t=>t.isFile()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}async childDirectories(e){const t=await this.childDirectoryEntries((async t=>t.isDirectory()&&(null==e||!0===await e(t))));return null==t?void 0:t.map((e=>this._directoryEntryChild(e)))}childrenSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath).map((e=>this.join(e)))))??[]}childFilesSync(){return this.trapSync("childrenSync",(()=>p.default.readdirSync(this.nativePath,{withFileTypes:!0}).filter((e=>e.isFile())).map((e=>this.join(e.name)))))??[]}async hasChildren(e){const t=await this.childNames();return(0,_.isNotEmpty)(e)?(0,_.includesAll)(t,e):(0,_.isNotEmpty)(t)}async hasNoChildren(){return await this.isFile()||(0,_.isEmpty)(await this.childNames())}async visitDescendants(e){return(0,z.thenMap)(this.children(),(async t=>{for(const r of t)await r.visitDescendants(e),await e(r)}))}async descendants(e){const t=[];t.push(...(0,L.toA)(await this.childFiles(e)));const r=await this.childDirectories();if(null==r)return t;for(const i of r)t.push(...(0,L.toA)(await i.descendants(e)));return t}async someDescendant(e,t=0){if(!(0,O.gt0)(t))return;const r=await d(this,n,"f").call(this)??[];for(const t of r)if(!0===await e(t))return this._directoryEntryChild(t);if(t>0)for(const i of r)if(i.isDirectory()){const r=await this._directoryEntryChild(i).someDescendant(e,t-1);if(null!=r)return r}}descendantsSync(e){const t=this.directoryEntrySync(),r=[];return t?.visitDescendantsSync((t=>{!0===e(t)&&r.push(this.forDirectoryEntry(t))})),r}async ancestorWithChildren(e){return await this.hasChildren(e)?this:this.isRoot?void 0:this.parent().ancestorWithChildren(e)}async siblings(e){const t=this.parent();return(await this.siblingDirectoryEntries(e))?.map((e=>t._directoryEntryChild(e)))}async siblingDirectoryEntries(e){return this.parent().childDirectoryEntries((async t=>t.base!==this.base&&(null==e||!0===await e(t))))}async selfAndSiblings(){return this.parent().children()}async firstExistingSelfOrAncestor(){return this.isRoot||await this.exists()?this:this.parent().firstExistingSelfOrAncestor()}get pathnames(){return(0,ue.splitNativePath)(this.nativePath)}get pathsForDateParsing(){return[...this.isRoot?[]:this.parent().pathnamesWithoutDrive,(0,Q.bname)(this.name)]}get pathnamesWithoutDrive(){return Y.isWin?this.pathnames.slice(1):this.pathnames}get depth(){return(0,ue.pathDepth)(this)}get isRoot(){return(0,ue.pathIsRoot)(this)}root(e=0){return this.depth<=e?this:this.parent().root(e)}parent(){return this.isRoot?this:this.for(this.dir)}isAncestorOf(e,t){return(0,ue.containedByNativePath)({ancestor:this,descendant:e,...t})}isDescendantOf(e){return(0,ue.containedByNativePath)({descendant:this,ancestor:e})}isSelfOrDescendantOf(e){return null!=e&&(this.nativePath===(0,me.toNativePath_)(e)||this.isDescendantOf(e))}parentsAndSelf(){return[...this.parents(),this]}selfAndParents(e){return[this,...this.isRoot||e<=0?[]:this.parent().selfAndParents(e-1)]}ancestor(e=1){return this.isRoot&&e>0?void 0:0===e?this:this.parent().ancestor(e-1)}findAncestor(e){return this.isRoot?void 0:e(this)?this:this.parent().findAncestor(e)}parents(){const e=this.parent();return this.isRoot?[]:[...e.parents(),e]}async normalize(){return this.isUNC?this:this.for(await(0,re.actualPath)(this.nativePath))}sibling(e){return this.parent().join(e)}withPrefix(e){return this.sibling(e+this.base)}withNameSuffix(e){return this.sibling(this.name+e+this.ext)}withSuffix(e){return this.sibling(this.base+e)}siblingOf(e){return this.nativePath!==e.nativePath&&this.dir===e.dir}join(...e){return(0,_.isEmpty)(e)||(0,T.eql)(["."],e)||e.every(M.blank)?this:(0,ue.isAbsolute)(e[0])?this.for(y.default.join(...e)):this.for(y.default.join(this.nativePath,...e))}joinYMD(e=new Date){return(0,k.map3)(e?.getFullYear(),e?.getMonth(),e?.getDate(),((e,t,r)=>this.join((0,R.toS)(e),(0,A.pad2)(t+1),(0,A.pad2)(r))))}child(...e){if((0,_.isEmpty)(e))return this;const t=(0,x.flatten)(e.map((e=>e.split(y.default.sep)))).filter((e=>".."!==e));return this.join(...t)}async trap(e,t,r="warn"){try{return await(0,W.time)("fs."+e+":"+this.nativePath,t)}catch(t){return void this.bflog().log(r,`trap: ${e}() failed: ${t}`)}}async trapOr(e,t,r="warn"){try{return await(0,W.time)("fs."+e,t),!0}catch(t){return this.bflog().log(r,`trapOr: ${e}() failed: ${t}`),!1}}trapSync(e,t,r){try{return(0,W.timeSync)("fs."+e,t)}catch(t){return void this.bflog().log(r??"warn",`${e}() failed: ${t}`)}}stat_(){return(0,pe.stat_)(this.nativePath)}async stat(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??await(0,pe.statMaybe)(this.nativePath,e?.logLevel??"trace"),"f")}statSync(e){return e?.refresh&&h(this,o,void 0,"f"),h(this,o,d(this,o,"f")??(0,ge.statSync)(this.nativePath),"f")}async exists(e){return e?.refresh&&(this.dirent=void 0),null!=this.dirent||await(0,z.thenDefined)(this.stat(e))}existsSync(e){return(e?.refresh??1)&&(this.dirent=void 0),null!=this.dirent||null!=this.statSync(e)}async notExists(e){return(0,z.thenNot)(this.exists(e))}async isDeleted(e=3){if(await this.exists({refresh:!0}))return this.bflog().tap({result:!1,msg:"isDeleted(): file exists"});if(this.isRoot||e<=0)return this.bflog().tap({result:void 0,msg:"isDeleted(): isRoot() and doesn't exist (volume is just unmounted)"});const t=await this.parent().isDeleted(e-1);return null==t?this.bflog().tap({result:void 0,msg:"isDeleted(): parent().isDeleted was undefined",meta:{parentIsDeleted:t}}):this.bflog().tap({result:!0,msg:"isDeleted(): parent was either deleted or not deleted: either way, that means I am deleted.",meta:{parentIsDeleted:t}})}mtime(){return(0,z.thenMap)(this.stat(),(e=>e.mtime))}mtimeMs(e){return(0,z.thenMap)(this.stat(e),(e=>Math.floor(e.mtimeMs)))}async mtimeSec(){const e=await this.stat();return null==e?void 0:(0,C.unixtime)(e.mtimeMs)}async lastModifiedUtc(){return(await this.stat())?.mtime.toUTCString()}async statTimes(){const e=await this.stat();return null==e?void 0:(0,pe.statTimes)(e)}maxStatMs(){return(0,z.thenMap)(this.statTimes(),j.max)}maxStatDate(){return(0,z.thenMap)(this.maxStatMs(),(e=>new Date(e)))}minStatMs(){return(0,z.thenMap)(this.statTimes(),$.min)}minStatDate(){return(0,z.thenMap)(this.minStatMs(),(e=>new Date(e)))}async size(e){return(0,z.thenMap)(this.stat(e),(e=>e.size))}async size_(){return(await this.stat_()).size}async isExecutable(){return(0,te.access)({stat:await this.stat(),r:!0,x:!0})}async isReadable(){return(0,te.access)({stat:await this.stat(),r:!0})}isNotReadable(){return(0,z.thenNot)(this.isReadable())}async isReadWritable(){return(0,te.access)({stat:await this.stat(),r:!0,w:!0})}isNotReadWritable(){return(0,z.thenNot)(this.isReadWritable())}async isReadWriteExecutable(){return(0,te.isStatRWX)(await this.stat(),this.nativePath)}isReadWriteExecutableSync(){return(0,te.isStatRWX)(this.statSync(),this.nativePath)}async isReadWriteExecutable_(){return(0,te.isStatRWX)(await this.stat_(),this.nativePath)}async isReadWriteDirectory(){const e=await this.stat();return!0===e?.isDirectory()&&(0,te.isStatRWX)(e,this.nativePath)}async assertReadWriteExecutable(){if(!await this.isReadWriteExecutable())throw new Error(`Please check directory permissions for ${this.nativePath}: it must be read/write${Y.isWin?"":"/execute"} by ${await(0,ee.userDesc)()}`)}async maybeReadWriteDirectory(){return!0!==await this.isFile()&&(await this.isDirectory()?this.isReadWriteExecutable():this.parent().maybeReadWriteDirectory())}isHiddenBasename(){return(0,ue.isHiddenBasename)(this.base)}async isEmpty(e=0){if(await this.isDirectory())return(0,_.isNotEmpty)(await this.childNames());{const t=await this.size();return null==t||t<=e}}isNonEmpty(e=1){return(0,z.thenNot)(this.isEmpty(e))}async isEmptyFile(e=1){const t=await this.stat({logLevel:"trace"});return null==t||t.isFile()&&t.size=e}async modifiedGTE(e){return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>=(0,C.unixtime)(e)))}async modifiedCloseTo(e,t){return(0,z.thenMap)(this.mtimeMs(),(r=>Math.abs(r-e)<=t))}async isRecent(e){const t=await this.maxStatMs();return null!=t&&t>Date.now()-e}async modifiedGT(e){if(null!=e)return(0,z.thenMap)(this.mtime(),(t=>(0,C.unixtime)(t)>(0,C.unixtime)(e)))}async isDirectory_(){return null!=this.dirent?this.dirent.isDirectory():(await this.stat_()).isDirectory()}async isDirectory(e){return this.dirent?.isDirectory()??(await this.stat(e))?.isDirectory()??!1}async isNotDirectory(){return(0,z.thenNot)(this.isDirectory())}isDirectorySync(e){return null!=this.dirent?this.dirent.isDirectory():(0,k.mapOr)(this.statSync(e),(e=>e.isDirectory()),(()=>!1))}async nearestDir(){return await this.isDirectory()?this:this.parent()}async isFile_(){if(null!=this.dirent)return this.dirent.isFile();const e=await this.stat_();return null!=e&&e.isFile()}async isFile(){return!0===await this.trap("isFile()",(()=>this.isFile_()))}isFileSync(){return null!=this.dirent?this.dirent.isFile():(0,F.opt)(this.statSync()).filter((e=>e.isFile())).isDefined}async rmdir(e="warn"){return this.clear(),await this.trap("rmdir",(async()=>(await m.rmdir(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}rmdirSync(e="warn"){return this.clear(),this.trapSync("rmdirSync",(()=>(m.rmdirSync(this.nativePath,{recursive:!1,maxRetries:8,retryDelay:500}),!0)),e)??!1}async mkdirp_(){try{await(0,ue.mkdirp_)(this.nativePath)}catch(e){if("EEXIST"!==e?.code)throw e}if(!1===await(0,q.untilTrue)((()=>this.clear().isDirectory()),{timeoutMs:2*C.secondMs,intervalMs:200}))throw new Error("Failed to mkdirp "+this);return this.clearThisAndParent()}async mkdirp(){return await this.clear().isDirectory()||this.isRoot?this:this.trap("mkdirp",(async()=>this.mkdirp_()))}mkdirpSync_(){return(0,ue.mkdirpSync_)(this.nativePath),this.clearThisAndParent()}mkdirpSync(){return this.isRoot?this:this.trapSync("mkdirpSync",(()=>this.mkdirpSync_()))}sha_(){return(0,ae.fileSha_)(this.nativePath)}async sha(){return this.trap("sha",(()=>this.sha_()))}async shaMs(){return this.trap("shaMs",(async()=>(await(0,ae.fileShaMeta_)(this,{autoInvalidate:!1})).elapsedMs))}async readJson_(){return(0,J.parseJSON)((await m.readFile(this.nativePath)).toString())}async readJson(e="warn"){return await this.isNonEmptyFile()?this.trap("readJson",(()=>this.readJson_()),e):void 0}readJsonSync(e){return this.trapSync("readJsonSync",(()=>(0,J.parseJSON)((0,p.readFileSync)(this.nativePath).toString())),e)}readFileSync_(){return(0,p.readFileSync)(this.nativePath)}readFile_(){return(0,g.readFile)(this.nativePath)}readFile(e="warn"){return this.trap("readFile",(()=>this.readFile_()),e)}async readTextFile_(){return(0,U.bufferToString)(await this.readFile_())}readTextFile(e="warn"){return this.trap("readTextFile",(()=>this.readTextFile_()),e)}async zReadFile_(e){return(0,Se.zCopyToBuffer_)(this.nativePath,e)}async zcat(e){return this.trap("zcat",(()=>(0,z.thenMap)(this.zReadFile_(e),R.toS)))}readLines(e="warn"){return(0,z.thenMap)(this.readTextFile(e),ie.splitLines)}readFileSync(){try{return p.default.readFileSync(this.nativePath).toString()}catch(e){return void this.bflog().warn("readFileSync() failed",{error:e})}}async writeText_(...e){return await(0,we.writeText_)(this.nativePath,...e),this}writeTextSync_(...e){return(0,we.writeTextSync_)(this.nativePath,...e),this}async writeFile_(e){return await(0,we.writeFile_)(this.nativePath,e),this}writeJsonSync(e,t){return this.trapSync("writeJsonSync",(()=>(0,we.writeFileSync_)(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces))))}async writeJson(e,t){return this.trap("writeJson",(()=>this.writeJson_(e,t)))}async writeJson_(e,t){return await(0,ue.mkdirp_)(this.dir),await m.writeFile(this.nativePath,(0,D.stringify)(e,t?.replacer,t?.spaces),(0,I.omit)(t,"replacer","spaces")),this.clearThisAndParent(),this}async matchesContent(e){const t=await Promise.all([this.stat({refresh:!0}),e.stat({refresh:!0})]);return null!=t[0]&&null!=t[1]&&t[0].size===t[1].size&&await this.sha()===await e.sha()}async touch(e={}){return this.trap("touch",(()=>this.touch_(e)))}async touch_(e={}){return await(0,ve.touch_)({...e,file:this,ensureFile:!0}),this.clearThisAndParent()}async utimes(e={}){return this.trap("utimes",(async()=>(await(0,ve.touch_)({...e,file:this,ensureFile:!1}),this.clearThisAndParent(),this)))}async rm(e="warn"){return this.unlink(e)}async unlink(e="warn"){return this.trap("unlink",(()=>this.unlink_()),e)}unlinkSync_(){try{m.unlinkSync(this.nativePath)}finally{this.clearThisAndParent()}}unlinkSync(e="info"){return this.trapSync("unlinkSync",(()=>this.unlinkSync_()),e)}async unlink_(){return await m.unlink(this.nativePath),this.clearThisAndParent()}async rmrf(e="info"){return this.trap("rmrf",(()=>this.rmrf_()),e)}async rmrf_(){return(0,E.retryOnReject_)((async()=>{const e=await this.stat({refresh:!0});return null!=e&&await m.rm(this.nativePath,{recursive:e.isDirectory(),force:!0}),this.clearThisAndParent()}),{maxRetries:(0,V.ending)()?1:3,timeoutMs:0,retryDelay:C.secondMs,errorIsRetriable:H.isRetriableError})}async gunzip(){return d(this,i,"m",a).call(this,(0,Z.stripSuffix)(this.base,".gz"),b.default.createGunzip())}async gzip(){return d(this,i,"m",a).call(this,this.base+".gz",b.default.createGzip())}async compressBrotli(){return d(this,i,"m",a).call(this,this.base+".br",b.default.createBrotliCompress())}ensureFile_(){return m.ensureFile(this.nativePath).then((()=>this.clearThisAndParent()))}ensureFile(){return this.trap("ensureFile",(()=>this.ensureFile_()))}ensureFileSync_(){return m.ensureFileSync(this.nativePath),this.clearThisAndParent()}async ensureNewNativePath(e){return(0,se.ensureNewNativePath_)({nativePath:this.nativePath,...e})}ensureNew_(e={}){return this.ensureNewNativePath(e).then((e=>this.for(e)))}ensureNewSync_(e={}){return this.for((0,se.ensureNewNativePathSync_)({nativePath:this.nativePath,...e}))}async chmod_(e){return await m.chmod(this.nativePath,e),this.clear()}async chmod(e){try{return await this.chmod_(e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}chmodSync(e){try{return p.default.chmodSync(this.nativePath,e),this}catch(t){return void this.bflog().warn("failed to chmod to "+e.toString(8),t)}}zreadline(){return p.default.createReadStream(this.nativePath).on("error",(e=>{throw new Error("Failed to read from "+this+": "+e)})).pipe(b.default.createGunzip()).on("error",(e=>{throw new Error("Failed to gunzip "+this+": "+e)})).pipe(new le.LineReader)}async siblingWithSameContents(){return this.parent().childWithSameContents(this)}async childWithSameContents(e){return(0,W.time)("fs.childWithSameContents",(async()=>{if(!await this.isDirectory())return;const t=await e.size();if(null==t)return;if(!this.eql(e.parent())){const t=this.join(e.base);if(await e.matchesContent(t))return t}const r=await this.children((async r=>!r.isNameHidden()&&t===r.size()&&r.nativePath!==e.nativePath));if((0,_.isEmpty)(r))return;const i=await e.sha();if(null!=i)for(const e of r.sort(((e,t)=>-(0,X.diceCoeff)(e.base,t.base))).slice(0,64))if(await e.sha()===i)return e}))}firstMatchingLine(e){const t=new B.Deferred("firstMatchingLine("+this+")"),r=p.default.createReadStream(this.nativePath,{flags:"r"});return r.on("error",(e=>{-2===e.errno||"ENOENT"===e.code?(t.maybeResolve(void 0),r.close()):t.maybeReject(e)})),r.on("close",(()=>t.maybeResolve(void 0))),(0,ye.onDataChunked)(r,(0,N.newlineRe)(),(i=>{const n=e.exec(i);null!=n&&(t.maybeResolve(n),r.close())})),t.promise}contemporary(e,t){return(0,z.thenMap2Or)(this.statTimes(),e.statTimes(),((e,r)=>{for(const i of e)for(const e of r)if((0,O.closeTo)(i,e,t))return!0;return!1}),(()=>!1))}watchUntil(e){const t=e.accept??(e.accept=e=>null!=e&&!1!==e),r=new B.Deferred("watchUntil("+this.nativePath+")");if(e.timeoutMs>0&&r.setTimeout(e.timeoutMs),_e)try{const i=(0,p.watch)(this.nativePath,{persistent:e.persistent,recursive:e.recursive,encoding:"utf8"},(async(i,n)=>{try{const s=await e.f(i,(0,k.denull)(n));t(s)&&r.resolve(s)}catch(e){r.reject(e)}}));r.finally((()=>{i.close()}))}catch(t){e.intervalMs??(e.intervalMs=500),this.bflog().warn("fs.watch failed, using polling",{error:t,opts:e})}else e.intervalMs??(e.intervalMs=500),this.bflog().warn("watchUntil(): fsWatch disabled, using polling",{opts:e});if((0,O.gt0)(e.intervalMs)){const i=setInterval((async()=>{try{const i=await e.f();t(i)&&r.resolve(i)}catch(e){r.reject(e)}}),e.intervalMs);e.persistent||i.unref(),r.finally((()=>{clearInterval(i)}))}return r}}t.BaseFile=Pe,s=async function(){const e=(await(0,he.readdir_)(this.dir)).filter((e=>(0,Z.equalsIgnoreCase)(e.basename,this.base))),t=(0,j.leastBy)(e,(e=>(0,X.hamming)(e.basename,this.base)));return this.bflog().tap({msg:"resolve()",result:t?.basename===this.base?this:(0,k.map)(t,(e=>this.forSiblingDirent(e))),meta:{sibs:e}})},a=async function(e,t){return this.trap("pipeTo("+e+")",(async()=>{const r=await this.sibling(e).ensureNew_();return await(0,w.pipeline)([p.default.createReadStream(this.nativePath,{autoClose:!0}),t,p.default.createWriteStream(r.nativePath,{autoClose:!0})]),await this.unlink(),r}))},Pe.attrTTL=3*C.minuteMs,Pe.projectRoot=(0,P.lazy)((()=>{const e=de.ProjectPath.Root();if(null==e)throw new Error("Cannot find project path");return Pe.for(e)}));let _e=!0;t.useFsWatch=function(e){_e=e},t.execDir=function(){return Pe.for(v.default.execPath).parent()}},84542:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitCompactLines=t.joinLines=t.splitLines=t.crlf=t.Newline=void 0;const i=r(40958),n=r(96249),s=r(51926),o=r(54993),a=r(43334);function l(...e){return(0,n.flatten)(e.map((e=>Array.isArray(e)?l(...e):(0,o.toS)(e).split((0,s.newlineRe)()))))}t.Newline=a.isWin?"\r\n":"\n",t.crlf=function(...e){const t=e.map(o.toS).join("\n");return a.isWin?t.replace((0,s.newlineRe)(),"\r\n"):t},t.splitLines=l,t.joinLines=function(...e){return l(...e).join(t.Newline)},t.splitCompactLines=function(...e){return(0,i.compactBlanks)(l(...e))}},70698:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeCachedirTag_=t.isCachedirTagFile=t.isCachedirTagDirectory=t.CACHEDIR_TAG_CONTENT=t.CACHEDIR_TAG=void 0;const i=r(76760),n=r(19851),s=r(50213),o=r(37805),a=r(29882),l=r(93854),u=r(17217),c=r(16287),d=r(73428);t.CACHEDIR_TAG="CACHEDIR.TAG",t.CACHEDIR_TAG_CONTENT="Signature: 8a477f597d28d172789f06886806bc55";const h=(0,n.lazy)((()=>(0,s.mkLogger)("fs.CachedirTag")));async function f(e){if((0,u.basename)(e)!==t.CACHEDIR_TAG)return!1;if(!await(0,c.isNonEmptyFile)((0,u.toNativePath_)(e),t.CACHEDIR_TAG_CONTENT.length))return!1;try{const r=(await(0,l.readFilePart_)({nativePath:(0,u.toNativePath_)(e),position:0,length:t.CACHEDIR_TAG_CONTENT.length}))?.buffer?.toString();return r===t.CACHEDIR_TAG_CONTENT}catch(t){return h().debug("isCachedirTagFile(): failed to read "+e,t),!1}}t.isCachedirTagDirectory=async function(e){return f((0,i.join)((0,u.toNativePath_)(e),t.CACHEDIR_TAG))},t.isCachedirTagFile=f,t.writeCachedirTag_=async function(e){const r=(0,u.toNativePath_)(e);await(0,a.mkdirp_)(r),await(0,d.writeTextfile_)((0,a.joinNativePath)([r,t.CACHEDIR_TAG]),t.CACHEDIR_TAG_CONTENT,"# This file marks this directory hierarchy as cached content.","# It can be safely deleted if PhotoStructure is not currently running.","#","# Created by https://photostructure.com "+o.version,"#","# See https://bford.info/cachedir/ for details about this file")}},92234:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultPaths=t.DefaultWinPaths=t.DefaultDockerPaths=t.DefaultPosixPaths=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(22573),l=r(45969),u=r(43334),c=Object.freeze(["/opt/homebrew/bin","/opt/homebrew/sbin","/usr/local/bin","/usr/local/sbin","/usr/bin","/bin","/usr/sbin","/sbin"]);t.DefaultPosixPaths=Object.freeze(["/usr/local/bin","/usr/local/sbin","/usr/lib/libraw","/opt/local/bin","/opt/local/sbin","/usr/sbin","/usr/bin","/sbin","/bin"]),t.DefaultDockerPaths=Object.freeze(["/opt/photostructure/tools/bin",...t.DefaultPosixPaths]),t.DefaultWinPaths=(0,o.lazy)((()=>[...(0,a.mapNotBlankOr)(s.default.env.SYSTEMROOT,(e=>[e,n.default.join(e,"System32"),n.default.join(e,"System32","webm")]),(()=>[])),"C:\\cygwin64\\bin"])),t.DefaultPaths=Object.freeze((0,l.isDocker)()?t.DefaultDockerPaths:u.isWin?(0,t.DefaultWinPaths)():u.isMac?c:t.DefaultPosixPaths)},89968:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DirectoryEntry=t.StatDirent=void 0;const a=s(r(44652)),l=o(r(73024)),u=r(76760),c=r(57975),d=r(19851),h=r(59455),f=r(50213),m=r(81168),p=r(34102),g=r(29882),y=r(65238),v=r(14427),w=r(17217),S=r(16287),b=r(68284);class P{constructor(e,t){this.base=e,(0,v.isSimpleDirent)(t)?(this.isFile=t.isFile,this.isDirectory=t.isDirectory):(this.isFile=t.isFile(),this.isDirectory=t.isDirectory()),t instanceof l.default.Stats&&(this.size=t.size,this.mtimeMs=t.mtimeMs)}}t.StatDirent=P;const _=(0,d.lazy)((()=>(0,f.mkLogger)("fs.DirectoryEntry")));class E{constructor(e,t){this.dir=e,this.dirent=t,this.nativePath=(0,u.join)(this.dir,t.base),this.ext=(0,g.parseNativePath)(t.base).ext}static fromSimpleDirent(e,t){return new E(e,new P(t.basename,t))}static async for(e){try{return await this.for_(e)}catch{return}}static async for_(e){const{nativePath:t,dir:r,base:i}=(0,w.isSimpleFile)(e)?e:{nativePath:e,...(0,g.parseNativePath)(e)},n=await a.stat(t);return new E(r,new P(i,n))}clear(){return(0,p.ee)().emit("fileChanged",this.nativePath),this.dirent.size=void 0,this.dirent.mtimeMs=void 0,this}async join(...e){return E.for((0,u.join)(this.nativePath,...e))}get base(){return this.dirent.base}get name(){return(0,m.stripSuffix)(this.base,this.ext)}get pathnames(){return this.nativePath.split(u.sep)}get parentAndBase(){return this.pathnames.slice(-2).join("/")}get parentBasename(){return(0,g.parentBasename)(this.nativePath)}toJSON(){return{_ctor:this.constructor.name,nativePath:this.nativePath}}toLogJSON(){return this.nativePath}[c.inspect.custom](){return this.toJSON()}toString(){return this.nativePath}isFile(){return this.dirent.isFile}isFileSync(){return this.dirent.isFile}isDirectory(){return this.dirent.isDirectory}isDirectorySync(){return this.dirent.isDirectory}get isRoot(){return this.dir===(0,u.parse)(this.dir).dir}isNameHidden(){return this.name.startsWith(".")}parent(){const e=(0,g.parseNativePath)(this.dir);return e.dir===this.dir?this:new E(e.dir,{base:e.base,isFile:!1,isDirectory:!0,mtimeMs:void 0,size:void 0})}async childNames(){try{return this.isDirectory()?(await(0,y.readdir)(this.nativePath))?.map((e=>e.basename)):void 0}catch(e){return void _().warn("childNames() failed to readdir("+this.nativePath+")",e)}}async children(){try{if(!this.isDirectory())return;const e=await(0,y.readdir)(this.nativePath);return e?.map((e=>E.fromSimpleDirent(this.nativePath,e)))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}childrenSync(){try{if(!this.isDirectory())return;const e=l.default.readdirSync(this.nativePath,{withFileTypes:!0});return e?.map((e=>new E(this.nativePath,new P(e.name,e))))}catch(e){return void _().warn("children() failed to readdir("+this.nativePath+")",e)}}async childDirectories(){return(0,h.toA)(await this.children()).filter((e=>e.isDirectory()))}async childFiles(){return(0,h.toA)(await this.children()).filter((e=>e.isFile()))}async visitDescendants(e){const t=await this.children();if(null!=t){for(const r of t)r.isDirectory()&&await r.visitDescendants(e);for(const r of t)r.isFile()&&await e(r);for(const r of t)r.isDirectory()&&await e(r)}}visitDescendantsSync(e){const t=this.childrenSync();if(null!=t){for(const r of t)r.isFile()&&e(r);for(const r of t)r.isDirectory()&&(r.visitDescendantsSync(e),e(r))}}async visitDescendantFiles(e){return this.visitDescendants((t=>t.isFile()?e(t):void 0))}async filterDescendantFiles(e){const t=[];return await this.visitDescendantFiles((async r=>{!0===await e(r)&&t.push(r)})),t}statDirent(){const e=(0,b.statSync)(this.nativePath);return null==e?void 0:this.dirent=new P(this.base,e)}async stat(){try{const e=await(0,S.stat_)(this.nativePath);return this.dirent=new P(this.base,e),e}catch{return}}size(){return this.dirent?.size??this.statDirent()?.size}mtimeMs(){return this.dirent?.mtimeMs??this.statDirent()?.mtimeMs}async unlink_(){await a.unlink(this.nativePath),(0,p.ee)().emit("fileChanged",this.nativePath)}async rmdir_(e){await a.rmdir(this.nativePath,e),(0,p.ee)().emit("fileChanged",this.nativePath)}}t.DirectoryEntry=E},20197:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ensureNewNativePathSync_=t.ensureNewNativePath_=t.DefaultEnsureNewOptions=void 0;const n=i(r(76760)),s=r(39926),o=r(29882),a=r(16287),l=r(68284);t.DefaultEnsureNewOptions=Object.freeze({emptyIsNew:!0,maxVersions:512,requireNumber:!1,leftPad:1,startIndex:1}),t.ensureNewNativePath_=async function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if(await(0,o.mkdirp_)(i.dir),!r.requireNumber&&await(0,a.isEmptyFile)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if(await(0,a.isEmptyFile)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)},t.ensureNewNativePathSync_=function(e){const r={...t.DefaultEnsureNewOptions,...e},i=(0,o.parseNativePath)(r.nativePath);if((0,o.mkdirpSync_)(i.dir),!r.requireNumber&&(0,l.isEmptyFileSync)(r.nativePath,r))return r.nativePath;for(let e=r.startIndex;e<=r.maxVersions;e++){const t=n.default.join(i.dir,`${i.name}-${(0,s.leftPad)(e,r.leftPad,"0")}${i.ext}`);if((0,l.isEmptyFileSync)(t,r))return t}throw new Error("There are already more than "+r.maxVersions+" of "+r.nativePath)}},88561:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.FileCache=t.isCacheableFile=t.InstanceCacheMaxSize=void 0;const o=r(40958),a=r(22573),l=r(41400),u=r(68708),c=r(25764),d=r(38836),h=r(34102),f=r(80049),m=r(50213),p=r(88158),g=r(45255);function y(e){return"object"==typeof e&&"function"==typeof e.clear}t.InstanceCacheMaxSize=256,t.isCacheableFile=y;class v extends f.FifoCacheAsync{constructor(e){super({maxSize:t.InstanceCacheMaxSize,timeoutMs:g.ShortCommandTimeoutMs,...e}),i.add(this),(0,l.later)((()=>{(0,h.ee)().on("fileChanged",(e=>s(this,i,"m",n).call(this,e))),(0,h.ee)().on("clearCache",(()=>this.clear())),new d.EndableWrapper(e.name+" stats",(()=>{const t=(0,p.mapEntries)(this.stats(),((e,t)=>t>0?t:void 0));(0,o.isNotEmpty)((0,u.keys)(t))&&(0,m.mkLogger)(e.name).info("stats",t)}),c.EndableRanks.stats)}))}}t.FileCache=v,i=new WeakSet,n=async function(e){if((0,a.blank)(e))this.clear();else for(const t of this.cache.keys())if(t.startsWith(e)){const e=await this.cache.get(t);y(e)?e.clear({emit:!1}):this.cache.delete(t)}}},32144:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSidecarMimetype=t.isSidecarExt=t.SidecarExts=t.SidecarFiletypes=t.isLogExt=t.isCsvExt=t.isJsonExt=t.isJpegExt=t.normalizeExt=void 0;const i=r(73024),n=r(22573),s=r(45599),o=r(96249),a=r(68708),l=r(54993),u=r(49047),c=r(17217),d=[u.JpegExts,["tiff","tif"],["heif","heic"],["html","htm"],["jp2","jp2k"]],h=(0,s.defer)((()=>{const e={};for(const[t,...r]of d)for(const i of r)e[i]=t;return e})),f=/(?:^\.?|.\.)(?[a-z\d]{2,4})(?:_original)?$/i;function m(e){const t=(0,c.isSimpleFile)(e)?e.ext:e instanceof i.Dirent?e.name:(0,l.toS)(e),r=f.exec((0,l.toS)(t))?.groups?.ext?.toLowerCase();return(0,n.blank)(r)?void 0:h()[r]??r}t.normalizeExt=m,t.isJpegExt=function(e){return m(e)===u.JpegExts[0]},t.isJsonExt=function(e){return"json"===m(e)},t.isCsvExt=function(e){return"csv"===m(e)},t.isLogExt=function(e){const t=(0,l.toS)(e);return t.endsWith(".log")||t.endsWith(".log.gz")},t.SidecarFiletypes={"application/rdf+xml":["xmp"],"application/json":["json"],"application/x-mie":["mie"],"application/x-exif":["exif"],"application/vnd.apple.photos":["aae"],"image/x-exv":["exv"]},t.SidecarExts=(0,o.flatten)((0,a.values)(t.SidecarFiletypes)),t.isSidecarExt=function(e){return function(e,...t){e=m(e);for(const r of t)if(r===e)return!0;return!1}(e,...t.SidecarExts)},t.isSidecarMimetype=function(e){return null!=e&&e in t.SidecarFiletypes}},43624:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fileStatsSync=t.fileStats=t.fileStats_=void 0;const i=r(68708),n=r(17217),s=r(16287),o=r(68284);async function a(e){return(0,i.pick)(await(0,s.stat_)((0,n.toNativePath_)(e)),"size","mtimeMs","ino","birthtimeMs")}t.fileStats_=a,t.fileStats=async function(e){try{return await a(e)}catch{return}},t.fileStatsSync=function(e){return null==(t=(0,o.statSync)((0,n.toNativePath)(e)))?void 0:(0,i.pick)(t,"size","mtimeMs","ino","birthtimeMs");var t}},4001:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stripDSC=t.copySuffixCountFromName=t.stripCopySuffixFromName=t.ciStablePosixPath=t.ymdIsoRE=void 0;const i=r(22573),n=r(55835),s=r(31586),o=r(51926),a=r(54993),l=r(97352),u=r(29882),c=[/\s*(?:-\s*)?copy(?:\s*\d{1,3}\s*)?$/i,/\s*(?:-\s*)?copy\s*\(\s*\d{1,3}\s*\)$/i,/\s*\((?:another|\d+[a-z]{2})?\s*copy\)$/i,/\s*-?\(\s*\d{1,4}\s*\)$/,/(?<=[\da-f-]{37}-)[\da-f-]+$/i,/\s*-\s*\d{1,3}$/],d=[...c,/\s*-?edit(?:ed)?$/i];function h(e,t={aggressive:!0}){return f((0,i.toNotBlank)(e.name)??(0,a.toS)(e),t).normalize()}function f(e,r){if(t.ymdIsoRE.test(e))return e;let i=e;for(const e of r.aggressive?d:c){const t=i.match(e);if((0,s.gt0)(t?.index)){const e=i.slice(0,t.index).trim();e.length>0&&(i=e)}}return e===i?e:f(i,r)}t.ymdIsoRE=/^(?:\d\d){1,2}-\d\d-\d\d$/,t.ciStablePosixPath=function(e){const t=e.split("/"),r=t.pop();if((0,i.blank)(r))return e;const n=(0,u.parsePosixPath)(r),s=h(n,{aggressive:!1});return[...t,s+n.ext].join("/").normalize()},t.stripCopySuffixFromName=h,t.copySuffixCountFromName=function(e){const t=((0,o.isString)(e)?e:e.name).toLowerCase().normalize(),r=h(t),i=(0,o.stripPrefix)(t.toLowerCase().normalize(),r);return(0,n.map)((0,l.extractInt)(i),Math.abs)};const m=/burst\s*([\w-]{8,})\s*$/i,p=/(?<=.{6})_cover$/i,g=/^(?:dsc|dscf|img|gpfr|gopro?|gf|gh|gp|mov|mvi|mvimg|p|vid)[-_ ]{0,2}e?(\d.+)$/i;t.stripDSC=function(e){let t=((0,o.isString)(e)?e:e.name).trim().replace(p,"").trim();return(0,n.map)(m.exec(t),(e=>t=e[1].trim())),(0,n.map)(g.exec(t),(e=>t=e[1].trim())),t}},50597:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.randomSha=t.numericSha=t.streamSha_=t.uncachedFileSha_=t.fileSha_=t.fileShaMeta_=t.shimmedFileSha_=void 0;const n=i(r(77598)),s=i(r(73024)),o=r(46466),a=r(19851),l=r(98553),u=r(68708),c=r(23467),d=r(80049),h=r(73913),f=r(50213),m=r(12089),p=r(37628),g=r(43624),y=r(17217),v=r(16287),w=(0,a.lazy)((()=>(0,f.mkLogger)("fs.Hash"))),S=(0,a.lazy)((()=>new d.FifoCacheAsync({name:"fs.fileSha",maxSize:512,timeoutMs:0,clearEveryMs:0})));async function b(e,{autoInvalidate:r=!0}={}){const i=(0,y.toNativePath_)(e);if(r){const t=S().get(i);if(null!=t){if((0,c.eql)(t.stats,await(0,g.fileStats_)(e)))return w().debug("fileSha_() cache matches current Stats",{nativePath:i,prior:t}),t;w().debug("fileSha_() prior cache is invalid, re-reading SHA",{nativePath:i,prior:t}),S().delete(i)}}return(0,t.shimmedFileSha_)(e)}async function P(e){const t=Date.now(),r=(0,y.toNativePath_)(e);return{sha:await _(s.default.createReadStream(r)),stats:(0,u.pick)(await(0,v.stat_)(r),"size","mtimeMs","birthtimeMs","ino"),elapsedMs:Date.now()-t}}async function _(e,t=[],r="sha512"){const i=n.default.createHash(r);return await(0,o.pipeline)([e,...t,i]),i.digest().subarray(0,h.HashBits/8).toString("base64")}t.shimmedFileSha_=(0,m.shim1)({name:"fs.Hash",cache:S,impl:P}),t.fileShaMeta_=b,t.fileSha_=async function(e){return(await b(e)).sha},t.uncachedFileSha_=P,t.streamSha_=_,t.numericSha=function(e,t=48){return parseInt((0,p.stringShaToBuffer)((0,l.stringify)(e),t).toString("hex"),16)},t.randomSha=function(){return n.default.randomBytes(h.HashBits/8).toString("base64")}},25675:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyIgnorableMountpoint=t.isIgnorableMountpoint=t.isPhotoStructureDmg=void 0;const i=r(22573),n=r(54993),s=r(7282),o=r(43334),a=r(69375),l=/^\/dev(?:\/|$)/i,u=o.isMac||(0,s.isTest)()?["/dev","/System/Volumes/Hardware","/System/Volumes/iSCPreboot","/System/Volumes/Preboot","/System/Volumes/Update","/System/Volumes/VM","/System/Volumes/xarts","/Volumes/Install","/Volumes/Recovery"].map((e=>e.toLowerCase())):void 0,c=o.isMac||(0,s.isTest)()?/^\/private\//i:void 0,d=o.isMac||(0,s.isTest)()?/^\/Volumes\/install macos\b/i:void 0,h=o.isMac||(0,s.isTest)()?/^\/Volumes\/PhotoStructure v?[\d.]{3,}/i:void 0;function f(e){return null!=h?.exec((0,n.toS)(e))}function m(e){return(0,i.blank)(e)?"blank":(0,a.isExcludedMountpoint)(e)?"excluded":l.test(e)?"/dev":!0===u?.includes(e.toLowerCase())?"macOS system volume":!0===d?.test(e)?"macOS installer volume":!0===c?.test(e)?"macOS private volume":f(e)?"PhotoStructure dmg":void 0}t.isPhotoStructureDmg=f,t.isIgnorableMountpoint=function(e){return null!=m(e)},t.whyIgnorableMountpoint=m},49047:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.JpegExts=void 0,t.JpegExts=["jpg","jpeg","jpe"]},33456:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LineReader=void 0;const i=r(57075),n=r(51926),s=r(54993);class o extends i.Transform{constructor(){super({objectMode:!1,autoDestroy:!0}),this._prior=""}_transform(e,t,r){const i=(this._prior+(0,s.toS)(e)).split((0,n.newlineRe)()),o=i.pop();this._prior=o??"";let a=!1;for(const e of i)a||(a=!this.push(e));a?setTimeout(r,1):r()}_flush(e){""!==this._prior&&this.push(this._prior),this._prior="",e()}}t.LineReader=o},64680:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.mkNoMedia_=void 0;const n=i(r(76760)),s=r(17217),o=r(73428);t.mkNoMedia_=function(e){return(0,o.writeTextfile_)(n.default.join((0,s.toNativePath_)(e),".NoMedia"),"This directory's contents are excluded from PhotoStructure libraries.","","See https://photostructure.com/nomedia/ for details.")}},29882:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathIncludesPathElement=t.bestMountpointForDir=t.joinNativePathMaybe=t.joinNativePath=t.splitNativePath=t.move_=t.mkdirpSync_=t.mkdirp_=t.isAbsolute=t.isUNC=t.addNameSuffix=t.posixPathFromGrandparent=t.posixPathFromParent=t.ellipsizePaths=t.ellipsizePath=t.posixPathFrom=t.pathDepth=t.pathIsRoot=t.toPathnames=t.eqlPath=t.eqlNameWithoutExt=t.eqlBasename=t.containedByNativePath=t.grandParentBasename=t.parentBasename=t.parseNativePath=t.extMatches=t.dirname=t.extname=t.parsePosixPath=t.resolveMaybe=t.resolveSimpleFile=t.isNotHiddenPosixPath=t.containsHiddenPathname=t.isHiddenBasename=t.logger=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(19851),a=r(40958),l=r(5233),u=r(22573),c=r(98553),d=r(39426),h=r(51926),f=r(48884),m=r(50213),p=r(81168),g=r(70025),y=r(43334),v=r(78133),w=r(53265),S=r(17217),b=r(16287),P=r(66430),_=r(5545);function E(e){return((0,S.isSimpleFile)(e)?e.base:s.default.basename(s.default.resolve(e))).startsWith(".")}t.logger=(0,o.lazy)((()=>(0,m.mkLogger)("fs.Path"))),t.isHiddenBasename=E,t.containsHiddenPathname=function(e){return k(e).some(E)},t.isNotHiddenPosixPath=function(e){return k(e).every((e=>!E(e)))},t.resolveSimpleFile=function(e){return(0,S.isSimpleFile)(e)?e.nativePath:(0,w.resolve)(e.toString())},t.resolveMaybe=function(...e){return e.some(u.blank)?void 0:(0,w.resolve)(...e)},t.parsePosixPath=function(e){return C((0,v.posix2native)(e))},t.extname=function(e){return C(e).ext},t.dirname=function(e){return s.default.dirname((0,S.toNativePath_)(e))},t.extMatches=function(e,t){return!(0,u.blank)(e)&&!(0,u.blank)(t)&&(0,p.equalsIgnoreCase)(s.default.parse(e).ext,s.default.parse(t).ext)};const M=/^(?.*?)(?\.(?:gz|z|7z|xz|bz2|br))?$/i;function C(e){const t=M.exec(e)?.groups,r=t?.ext2??"",i=s.default.parse(t?.path??e);return{...i,ext:(i.ext??"")+r,base:(i.base??"")+r}}function T(e){const t=s.default.parse((0,S.toNativePath_)(e));return t.root===t.dir?t.root:(0,h.splitLast)(t.dir,s.default.sep)}function x(e){try{if(null==e.descendant||null==e.ancestor)return!1;const t=(0,S.toNativePath_)(e.ancestor),r=(0,S.toNativePath_)(e.descendant);if((0,u.blank)(t)||(0,u.blank)(r))return!1;const i=e.acceptSelf??!1;return t===r?i:r.startsWith((0,p.ensureSuffix)(t,s.default.sep))}catch(r){return(0,t.logger)().warn("containedByNativePath() failed (returning false)",{args:e,error:r}),!1}}function D(e,t,r){if(null==t||null==r)return!1;const i=e(t),n=e(r);return null!=i&&null!=n&&(y.isLinux?i===n:(0,p.equalsIgnoreCase)(i,n))}function k(e){return(0,S.isSimpleFile)(e)?e.pathnames:e.split(s.default.sep).filter((e=>null!=e&&""!==e))}function O(e){return(0,u.notBlank)(e)&&k(e).length===(y.isWin?1:0)}function I({p:e,maxLength:t}){const r=(0,S.toNativePath_)(e);if(r.length<=t)return r;const i=k(e),n=[],s=[i.pop()];for(;i.length>0;)if(n.length=t){i.unshift(n.pop());break}}else if(s.unshift(i.pop()),A([...n,...s]).length>=t){i.push(s.shift());break}return i.length>0&&n.push("…"),A([...n,...s])}function F(e){return e.startsWith("\\\\")}function A(e){return(0,h.ensurePrefix)((0,a.compactBlanks)(e).join(s.default.sep),y.isWin?"":s.default.sep)}t.parseNativePath=C,t.parentBasename=T,t.grandParentBasename=function(e){return T(s.default.parse((0,S.toNativePath_)(e)).dir)},t.containedByNativePath=x,t.eqlBasename=function(e,t){return D(S.basename,e,t)},t.eqlNameWithoutExt=function(e,t){return D(S.nameWithoutExt,e,t)},t.eqlPath=function(e,t){return D(S.toNativePath_,e,t)},t.toPathnames=k,t.pathIsRoot=O,t.pathDepth=function(e){return(0,u.blank)(e)?void 0:k(e).length-(y.isWin?1:0)},t.posixPathFrom=function(e,t){const r=(0,S.toNativePath_)(e),i=(0,S.toNativePath_)(t);if((0,u.blank)(r)||(0,u.blank)(i))throw new Error("posixPathFrom empty args "+(0,c.stringify)({parent:e,child:t}));return r===i?"":(0,p.stripPrefix)((0,v.native2posix)(i).normalize(),(0,p.ensureSuffix)((0,v.native2posix)(r),"/").normalize()).normalize()},t.ellipsizePath=I,t.ellipsizePaths=function({arr:e,maxPathLength:t,sampleSize:r=4,arrLength:i=e.length}){const n=[];for(const i of e.slice(0,r))n.push(I({p:i,maxLength:t}));return n.join(", ")+(i>r?`, and ${i-r} more…`:"")},t.posixPathFromParent=function(e){return k(e).slice(-2).join("/")},t.posixPathFromGrandparent=function(e){return k(e).slice(-3).join("/")},t.addNameSuffix=function(e,t){const r=C(e);return`${r.base}${t}${r.ext}`},t.isUNC=F,t.isAbsolute=function(e){return y.isPosix&&e.startsWith("/")||y.isWin&&(F(e)||null!=e.match(_.driveRe))},t.mkdirp_=async function(e){try{if(await(0,b.isReadableDirectory)(e))return;if(O(e))throw new d.MetaError("refusing to create root directory",{code:"ENOENT"});await n.default.mkdirp(e)}catch(t){if(await(0,b.isReadableDirectory)(e))return;throw t}},t.mkdirpSync_=function(e,t){try{if((0,P.isReadWriteableDirectorySync)(e))return;n.default.mkdirpSync(e,t)}catch(t){if((0,P.isReadWriteableDirectorySync)(e))return;throw t}},t.move_=async function(e,t){return(0,l.retryOnReject_)((()=>n.default.move(e,t,{overwrite:!0})),{errorIsRetriable:g.isRetriableError,maxRetries:5,retryDelay:250})},t.splitNativePath=function(e){return(0,S.toNativePath_)(e).split(s.default.sep).filter((e=>null!=e&&""!==e))},t.joinNativePath=A,t.joinNativePathMaybe=function(...e){return e.some(u.blank)?void 0:A(e)},t.bestMountpointForDir=function(e,t){return(0,f.greatestBy)(t,(t=>x({ancestor:t,descendant:e,acceptSelf:!0})?[(0,S.toNativePath_)(t).length]:void 0))},t.posixPathIncludesPathElement=function(e,t){return e.split("/").includes(t)}},8103:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.arpWin=t.pingWin=t.nslookupWin=t.fsutil=t.wmic=t.pathIfExists=t.pathTo=t.isRXFile=void 0;const n=i(r(76760)),s=r(19851),o=r(40958),a=r(22573),l=r(31586),u=r(51926),c=r(12168),d=r(59455),h=r(54993),f=r(50213),m=r(44198),p=r(96706),g=r(45969),y=r(43334),v=r(64660),w=r(21144),S=r(16287),b=(0,s.lazy)((()=>(0,f.mkLogger)("fs.PathTo"))),P=c.KiB;async function _(e,t=P){const r=await(0,S.statMaybe)(e,"trace");return null!=r&&r.isFile()&&(0,l.gte)(r.size,t)&&(0,v.isStatRX)(r,e)}function E(){if(y.isWin){const e=(0,a.toNotBlank)((0,p.getEnv)("SystemRoot"))??"C:\\Windows",t=(0,a.toNotBlank)((0,p.getEnv)("SystemDrive"))??"C:",r=(0,a.toNotBlank)((0,p.getEnv)("ProgramData"))??"C:\\ProgramData";return[e,n.default.join(e,"System32"),n.default.join(e,"System32","Wbem"),n.default.join(r,"chocolatey","bin"),n.default.join(t,"cygwin64","bin")]}return[...(0,g.isDocker)()?["/opt/photostructure/bin","/opt/photostructure/tools/bin"]:[],"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"]}function M(){const e=(0,h.toS)((0,m.env)().PATH).split(n.default.delimiter);return(0,o.uniq)((0,o.compactBlanks)([...e,...E()]))}t.isRXFile=_,t.pathTo=async function({tool:e,alternativePath:t,paths:r}){const i=(0,o.uniq)((0,o.compactBlanks)([...M(),...(0,d.toA)(r)]));for(const r of(0,o.uniq)((0,o.compactBlanks)([e,t]))){const e=y.isWin?(0,u.ensureSuffix)(r,".exe"):r;for(const t of i){const r=n.default.join(t,e);if(await _(r))return y.isLinux?r:(0,w.actualPath)(r)}}b().warn("Failed to find tool",{tool:e,dirs:i})},t.pathIfExists=async function(e){if(null==e)return;const t=await e.stat({logLevel:"debug"});return null!=t&&t.isFile()&&t.size>P&&(0,v.isStatRX)(t,e.nativePath)?e.nativePath:void 0},t.wmic=()=>"wmic",t.fsutil=()=>"fsutil",t.nslookupWin=()=>"nslookup",t.pingWin=()=>"ping",t.arpWin=()=>"arp"},78133:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.native2posix=t.posix2native=void 0;const n=i(r(76760)),s=r(22573),o=r(81168);t.posix2native=function(e,t){if((0,s.blank)(e))return e;if(n.default.sep===n.default.posix.sep)return e;const r=(0,s.notBlank)(t)?n.default.sep+n.default.sep+t+n.default.sep:"",i=e.split(n.default.posix.sep);return(0,o.equalsIgnoreCase)(i[0],t)&&i.unshift(),r+i.join(n.default.sep)},t.native2posix=function(e){return(0,s.blank)(e)||n.default.sep===n.default.posix.sep||n.default.posix.sep===n.default.sep?e:e.split(n.default.sep).join(n.default.posix.sep)}},43899:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ProjectPath=void 0;const n=i(r(76760)),s=i(r(1708)),o=r(19851),a=r(40958),l=r(48884),u=r(50213),c=r(45969),d=r(29325),h=r(43334),f=r(65843),m=r(25675),p=r(53265);function g(...e){return(0,o.lazy)((()=>n.default.join(t.ProjectPath.Root(),...e)))}t.ProjectPath={Root:(0,o.lazy)((()=>{const e=["data","public","views"],t=[];(0,c.isDocker)()&&t.push("/opt/photostructure"),h.isElectron&&t.push(n.default.join((0,p.execDir)(),"resources"),n.default.join((0,p.execDir)(),"..","Resources")),t.push(...(0,a.compactBlanks)([(0,p.execDir)(),s.default.cwd(),__dirname])),(0,l.uniqInPlace)(t);for(const r of t){if((0,f.hasChildrenSync)(r,e))return r;for(const t of(0,f.ancestors)(r).slice(0,(0,d.isPacked)()?4:6)){if((0,f.hasChildrenSync)(t,e))return t;const i=n.default.join(r,"node_modules","photostructure");if((0,f.hasChildrenSync)(i,e))return i}}return(0,u.mkLogger)("fs.ProjectPath").throw("Failed to find project root. Looked in "+t)})),Bin:g("bin"),Data:g("data"),ICC:g("data","icc"),Migrations:g("data","migrations"),Public:g("public"),Tools:g("tools"),Views:g("views"),isInDMG:function(e){return!!h.isMac&&(0,m.isPhotoStructureDmg)(e??t.ProjectPath.Root())}}},45879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.intFromFileSync=t.readFileMaybe=void 0;const i=r(44652),n=r(19851),s=r(31586),o=r(50213),a=r(57902),l=r(69428),u=(0,n.lazy)((()=>(0,o.mkLogger)("fs.ReadFile")));t.readFileMaybe=async function(e,t=a.LogLevels.info){try{return await(0,i.readFile)(e)}catch(r){return void u().log(t,".readFileMaybe("+e+")",r)}},t.intFromFileSync=function(e){return u().tap({msg:"intFromFileSync()",result:(0,s.toInt)((0,l.readFileSync)(e)?.toString(),{defaultValue:void 0}),meta:{nativePath:e}})}},93854:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.readFilePart_=void 0;const i=r(44652),n=r(97352);t.readFilePart_=async function({nativePath:e,position:t=0,length:r}){let s=-1;try{const n=r??(await(0,i.stat)(e)).size-t,o=Buffer.alloc(n);return s=await(0,i.open)(e,"r"),await(0,i.read)(s,o,0,n,t)}finally{(0,n.mapGte0)(s,i.close)}}},69428:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.readFileSync=void 0;const o=s(r(73024));t.readFileSync=function(e){try{return o.readFileSync(e)}catch{}}},32323:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ReadableBuffer=void 0;const i=r(57075);class n extends i.Readable{constructor(e){super(),this.push(e),this.push(null)}}t.ReadableBuffer=n},65238:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.readdirUncached_=t.readdirCached=t.readdir_=t.readdir=t.childDirectories_=t.isCachedDir=t.setSlowDir=t.isSlowDir=t.slowDirs=t.clearCachedReaddir=t.clearReaddirCaches=t.readdirCacheDir=t.ReadDirCacheName=void 0;const n=i(r(51455)),s=r(76760),o=r(19851),a=r(76790),l=r(22573),u=r(42659),c=r(41400),d=r(31586),h=r(13538),f=r(83104),m=r(54127),p=r(50213),g=r(95937),y=r(34102),v=r(28874),w=r(63870),S=r(88561),b=r(41080);t.ReadDirCacheName="readdircache",t.readdirCacheDir=(0,o.lazy)((()=>(0,s.join)(v.Settings.cacheDir.valueOrDefault,t.ReadDirCacheName)));const P=(0,o.lazy)((()=>(0,p.mkLogger)("fs.Readdir")));async function _(){try{await n.default.rm((0,t.readdirCacheDir)(),{force:!0,recursive:!0})}catch(e){P().warn("clearReaddirCaches(): failed",{error:e})}}t.clearReaddirCaches=_;const E=(0,o.lazy)((()=>new S.FileCache({name:"fs.readdir",maxSize:256,timeoutMs:(0,w.commandTimeoutMs)(),clearEveryMs:u.minuteMs})));function M(e){(0,l.blank)(e)||E.prior()?.delete(e)}async function C(e){return P().tap({level:"trace",msg:"readdir_("+e+")",result:await E().getOrSetAsync(e,(()=>async function(e){const r=Date.now()+2*(0,b.statTimeoutMs)(),i=T(e),n=await(0,h.thenOrTimeout)(i,(0,d.toGt0)(v.Settings.fsCacheSlowMs.valueOrDefault)??(0,b.statTimeoutMs)());if(n===f.Timeout&&(0,g.onTimeout)({soft:!1}),n!==f.Timeout&&n.length({basename:e.name,isFile:e.isFile(),isDirectory:e.isDirectory()}))),(e=>[e.isFile,e.basename.toLowerCase(),e.basename]))}t.clearCachedReaddir=M,(0,c.later)((()=>{v.Settings.cacheDir.watchLater((()=>{t.readdirCacheDir.clear(),E.prior()?.clear(),t.slowDirs.prior()?.clear()})),(0,y.ee)().on("clearCache",(()=>(t.slowDirs.prior()?.clear(),_()))),(0,y.ee)().on("fileChanged",(e=>(0,l.blank)(e)?_():M(e)))})),t.slowDirs=(0,o.lazy)((()=>new m.FifoSet(256))),t.isSlowDir=async function(e){return!((0,l.blank)(e)||!(0,t.slowDirs)().has(e)&&(!E().has(e)||((0,t.slowDirs)().add(e),0)))},t.setSlowDir=function(e){M(e),(0,t.slowDirs)().add(e)},t.isCachedDir=async function(e){return null!=E().get(e)},t.childDirectories_=async function(e){return(await C(e)).filter((e=>e.isDirectory)).map((t=>(0,s.join)(e,t.basename)))},t.readdir=async function(e){try{return(0,d.gt0)(v.Settings.readdirCacheMs.valueOrDefault)?C(e):T(e)}catch(t){return void P().warn("readdir() failed for "+e,t)}},t.readdir_=C,t.readdirCached=function(e){return E().get(e)},t.readdirUncached_=T},53265:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveRelativeMaybe=t.currentWorkingDirectories=t.execDir=t.resolve=void 0;const n=r(73024),s=i(r(76760)),o=r(40958),a=r(22573),l=r(45599),u=r(50213),c=r(43334),d=r(5545),h=(0,l.defer)((()=>(0,u.mkLogger)("fs.Resolve"))),f=c.isWin?/[\\/]/:/\//;function m(){return(0,o.compactBlanks)([(0,t.execDir)(),process.cwd(),__dirname])}function p(...e){for(const t of m()){const r=s.default.resolve(t,...e);if((0,n.existsSync)(r))return r}h().warn("resolveRelative: failed to find a working cwd",{input:e,cwds:m()})}t.resolve=function(...e){if((0,a.blank)(e.join("")))throw new Error("resolve(): empty paths");if(c.isWin)if(1===e.length&&/^[a-z]:$/i.test(e[0]))e[0]+="\\";else{const t=/^\/(?[a-z])\/(?.*)$/i.exec(e[0])?.groups;null!=t&&(e[0]=t.drive.toUpperCase()+":\\"+t.path.replace(/\//g,"\\"))}const t=e[0].split(f).slice(0,2).find(a.notBlank);return(0,d.upcaseDriveLetters)(([".",".."].includes(t)?p(...e):void 0)??s.default.resolve(...e))},t.execDir=(0,l.defer)((()=>s.default.dirname(process.execPath))),t.currentWorkingDirectories=m,t.resolveRelativeMaybe=p},50274:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SidecarExts=void 0;const i=r(50989);t.SidecarExts=(0,i.strEnum)("xmp","mie","exv")},14427:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isSimpleDirent=void 0;const i=r(22573),n=r(38639);t.isSimpleDirent=function(e){return null!=e&&(0,i.notBlank)(e.basename)&&(0,n.isBoolean)(e.isFile)&&(0,n.isBoolean)(e.isDirectory)}},17217:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstSelfOrAncestor=t.someSelfOrAncestor=t.isFileSync=t.findFileIndex=t.rootDir=t.dirname=t.nameWithoutExt=t.basename=t.toNativePath_=t.toNativePath=t.isSimpleFile=void 0;const n=i(r(73024)),s=i(r(76760)),o=r(22573),a=r(98553),l=r(81168),u=r(43334),c=r(29882),d=r(53265),h=r(14427);function f(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.nativePath&&"string"==typeof e.base&&"string"==typeof e.ext&&"string"==typeof e.base&&"string"==typeof e.dir&&"function"==typeof e.isFile}function m(e){if(null==e)throw new Error("toNativePath(null)");if((0,o.blank)(e))throw new Error("toNativePath(blank)");if((0,l.isString)(e))return(0,d.resolve)(e);if((0,o.blank)(e.nativePath))throw new Error(`toNativePath(${(0,a.stringify)(e)})`);return e.nativePath}function p(e){return e instanceof n.default.Dirent?e.name:f(e)?e.base:s.default.basename(String(e))}t.isSimpleFile=f,t.toNativePath=function(e){try{return m(e)}catch{return}},t.toNativePath_=m,t.basename=p,t.nameWithoutExt=function(e){return(0,c.parseNativePath)(p(e)).name},t.dirname=function(e){return f(e)?e.dir:s.default.dirname(m(e))};const g=/^[a-z]:$/i;t.rootDir=function(e){if(f(e)){const t=e.pathnames;return u.isWin&&null!=t[0].match(g)?t[1]:t[0]}{const t=(0,l.stripPrefix)(e,"/"),r=t.indexOf(s.default.sep);return r>0?t.slice(1,r):void 0}},t.findFileIndex=function(e,t){for(let r=0;r(0,d.mkLogger)("fs.Stat")));async function v(e){return(0,a.blank)(e)?y().throw("stat_() for blank path",{nativePath:e,retriable:!1,fatal:!1}):await(0,c.thenOrTimeoutError)(n.default.stat(e),(0,g.statTimeoutMs)(),!0)}function w(e,t=f.LogLevels.debug){return(0,a.blank)(e)?void 0:v(e).catch((r=>{y().log(t,"stat() failed",{error:r,nativePath:e})}))}function S(e){return e.isDirectory()?"directory":e.isFile()?"file":"special"}function b(e){return(0,l.isDate)(e)?(0,l.unixtime)(e):(0,u.isNumber)(e)?e:void 0}function P(e,t){if(null==e||null==t)return"both must be defined: "+(null==e?"null":"stat")+" ≠ "+(null==t?"null":"stat");const r=S(e),i=S(t);if(r!==i)return"inconsistent file type: "+r+" ≠ "+i;for(const r of["size","mtime"]){const i=e[r],n=t[r],s=(0,u.diff)(b(i),b(n));if(null==s||s>1)return"unmatched "+r+": "+i+" ≠ "+n}}t.stat_=v,t.statMaybe=w,t.statToType=S,t.whyStatNotEql=P,t.statEql=function(e,t){return null==P(e,t)},t.exists=async function(e,t=f.LogLevels.info){return null!=await w(e,t)},t.isEmptyFile=async function(e,t){const r=await w(e,t?.logLevel??f.LogLevels.trace);return!(null!=r&&!(t?.emptyIsNew??1))&&(0,p.isEmptyStats)(r)},t.isNonEmptyFile=async function(e,t=0){const r=await w(e);return null!=r&&r.isFile()&&r.size>=t},t.nativePathIsFile=async function(e,t=f.LogLevels.info){return!0===(await w(e,t))?.isFile()},t.isDirectory=async function(e){return!0===(await w(e))?.isDirectory()},t.isReadableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.access)({stat:r,r:!0,x:!0})},t.isReadWriteableDirectory=async function(e,t=f.LogLevels.trace){const r=await w(e,t);return null!=r&&r.isDirectory()&&(0,m.isStatRWX)(r,e)},t.isMtimeRecent=async function(e,t){return(0,h.isRecentMs)((await w(e))?.mtimeMs,t)},t.statTimes=function(e){return(0,o.uniq)([e.birthtimeMs,e.mtimeMs].filter((e=>null!=e&&0!==e)))}},68284:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isDirectorySync=t.isNonEmptyFileSync=t.isEmptyFileSync=t.isFileSync=t.isEmptyStats=t.statSync=void 0;const n=i(r(73024)),s=r(22573);function o(e){try{return(0,s.blank)(e)?void 0:n.default.statSync(e,{throwIfNoEntry:!1})}catch{return}}function a(e){return null==e||e.isFile()&&0===e.size}t.statSync=o,t.isEmptyStats=a,t.isFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isEmptyFileSync=function(e,t={emptyIsNew:!0}){const r=o(e);return t.emptyIsNew?null==r:a(r)},t.isNonEmptyFileSync=function(e,t=0){const r=o(e);return null!=r&&r.isFile()&&r.size>=t},t.isDirectorySync=function(e){return!0===o(e)?.isDirectory()}},41080:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.statTimeoutMs=void 0;const i=r(28874);t.statTimeoutMs=function(){return i.Settings.statTimeoutMs.valueOrDefault}},66003:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Chunker=t.onDataChunked=void 0;const i=r(22573),n=r(56409);t.onDataChunked=function(e,t,r){const i=new s(t,r,!0);return i.read(e),i.done};class s{constructor(e,t,r=!0){this.sep=e,this.onData=t,this.filterBlanks=r,this.incompleteChunk="",this.done=new n.Latch}onChunk(e){if(null==e)return;const t=(this.incompleteChunk+e.toString()).split(this.sep);this.incompleteChunk=t.pop(),t.forEach((e=>{this.filterBlanks&&!(0,i.notBlank)(e)||this.onData(e)}))}clear(){this.onChunk(""),(0,i.notBlank)(this.incompleteChunk)&&this.onData(this.incompleteChunk),this.incompleteChunk=""}read(e){return e.on("data",(e=>this.onChunk(e))),e.on("end",(()=>{this.clear(),this.done.resolve()})),this}}t.Chunker=s},95705:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.streamEnded=void 0,t.streamEnded=function(e){return null==e||!e.writable||e.destroyed||e.writableEnded||e.writableFinished}},36868:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ByteCounter=t.remoteDesc=t.closeStreams=t.onChildError=t.closeStream=t.endStream=t.writeAsync=t.PassthroughStream=void 0;const n=i(r(57075)),s=r(41400),o=r(55835),a=r(68708),l=r(42279),u=r(99331),c=r(70025);class d extends n.default.Duplex{_write(e,t){this.push(e,t)}}t.PassthroughStream=d,t.writeAsync=async function(e,t){return new Promise(((r,i)=>{!1===e.write(t,(e=>{e&&i(e)}))?e.once("drain",r):r()}))},t.endStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}(0,u.ending)()?e.end(null):await new Promise((t=>e.end(null,t))),await(0,s.delay)(50);try{(0,a.maybeCall)(e,"destroy")}catch{}}},t.closeStream=async function(e){if(null!=e){try{(0,a.maybeCall)(e,"unref")}catch{}if((0,u.ending)())try{e.close(l.NoOp)}catch{}else await new Promise((t=>e.close(t)))}},t.onChildError=function(e,t){for(const{name:r,ea:i}of[{name:"cp",ea:e},{name:"stdin",ea:e.stdin},{name:"stdout",ea:e.stdout},{name:"stderr",ea:e.stderr}])(0,o.map)(i,(e=>e.on("error",(e=>{!1===(0,c.isIgnorableError)(e)&&t(r,e)}))))},t.closeStreams=function(e){for(const t of[e?.stdin,e?.stdout,e?.stderr])try{!1===t?.destroyed&&t?.destroy()}catch{}},t.remoteDesc=function(e){return e.destroyed?"destroyed":`${e.remoteFamily}:${e.remoteAddress}:${e.remotePort}`};class h extends n.default.Transform{constructor(e){super({transform:(e,t,r)=>{this.onProgress(this.bytes+=e.length),r(e)}}),this.onProgress=e,this.bytes=0}}t.ByteCounter=h},66430:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.posixPathExistsSync=t.firstExistingDirectory=t.isReadWriteableDirectorySync=t.isReadableDirectorySync=t.isMtimeRecentSync=t.nativePathSizeSync=t.nativePathExistsSync=void 0;const n=i(r(73024)),s=r(76760),o=r(22573),a=r(76596),l=r(64660),u=r(78133),c=r(68284);function d(e){if((0,o.blank)(e))return!1;try{return n.default.existsSync(e)}catch{return!1}}t.nativePathExistsSync=d,t.nativePathSizeSync=function(e){return(0,c.statSync)(e)?.size},t.isMtimeRecentSync=function(e,t){return(0,a.isRecentMs)((0,c.statSync)(e)?.mtimeMs,t)},t.isReadableDirectorySync=function(e){const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,x:!0})},t.isReadWriteableDirectorySync=function(e){if((0,o.blank)(e))return!1;const t=(0,c.statSync)(e);return null!=t&&t.isDirectory()&&(0,l.access)({stat:t,r:!0,w:!0,x:!0})},t.firstExistingDirectory=function(e){for(const t of e)if((0,o.notBlank)(t)){const e=(0,s.resolve)(t);if((0,c.isDirectorySync)(e))return e}},t.posixPathExistsSync=function(e){return!(0,o.blank)(e)&&d((0,u.posix2native)(e))}},27794:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.touch_=void 0;const n=i(r(44652)),s=r(19851),o=r(22573),a=r(42659),l=r(31586),u=r(68708),c=r(13538),d=r(29882),h=r(17217),f=r(16287),m=r(41080);function p(e){return null==e?void 0:(0,a.isDate)(e)?e.getTime():(0,l.gt0)(e)?e:void 0}t.touch_=async function e(t){const r=t.ensureFile??!0;if(null==t.file||(0,o.blank)(t.file))throw new Error("can't touch blank path");const i=(0,h.toNativePath_)(t.file);r&&await(0,d.mkdirp_)((0,h.dirname)(t.file));const a=(0,s.lazy)((()=>(0,f.statMaybe)(t.reference?.nativePath))),l=Math.round(p(t.mtimeMs)??(await a())?.mtimeMs??Date.now()),g=Math.round(p(t.atimeMs)??(await a())?.atimeMs??l);try{await(0,c.thenOrTimeoutError)(n.default.utimes(i,new Date(g),new Date(l)),(0,m.statTimeoutMs)())}catch(s){if(!r||"ENOENT"!==s.code)throw s;await(0,c.thenOrTimeoutError)(n.default.ensureFile(i),(0,m.statTimeoutMs)()),(0,u.keys)(t).length>1&&await e({...t,ensureFile:!1})}}},5545:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.upcaseDriveLetters=t.driveRe=void 0;const n=i(r(76760)),s=r(54993);t.driveRe=/^(?[A-Z]:)(?[\\/].*)?$/i,t.upcaseDriveLetters=function(e){const r=t.driveRe.exec(e)?.groups;return null==r?e:r.drive.toUpperCase()+(0,s.toS)(r.path??n.default.sep)}},58722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WritableToBuffer=void 0;const i=r(57075),n=r(22911);class s extends i.Writable{constructor(e){super(e),this.deferred=new n.Deferred("WritableToBuffer"),this._buf=[],this.on("finish",(()=>{this.deferred.resolve(this.data)})),this.on("error",(e=>{this.deferred.reject(e)}))}get data(){return Buffer.concat(this._buf)}get buffer(){return this.deferred.promise}_write(e,t,r){this._buf.push(Buffer.isBuffer(e)?e:Buffer.from(e,t)),r()}}t.WritableToBuffer=s},73428:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.writeTextSync_=t.writeFileSync_=t.writeTextfile_=t.writeText_=t.writeFile_=void 0;const n=i(r(44652)),s=i(r(76760)),o=r(51926),a=r(54993),l=r(34102),u=r(84542),c=r(29882);async function d(e,t){const r=s.default.dirname(e);await(0,c.mkdirp_)(r),await n.default.writeFile(e,t),(0,l.ee)().emit("fileChanged",r)}function h(e,t){const r=s.default.dirname(e);(0,c.mkdirpSync_)(r),n.default.writeFileSync(e,t),(0,l.ee)().emit("fileChanged",r)}t.writeFile_=d,t.writeText_=async function(e,...t){return d(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))},t.writeTextfile_=async function(e,...t){const r=(0,u.crlf)(...(0,o.wrap)(t));await d(e,r)},t.writeFileSync_=h,t.writeTextSync_=function(e,...t){return h(e,(0,u.crlf)((0,o.ensureSuffix)(t.map(a.toS).join("\n"),"\n")))}},13047:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.outputJsonGz=t.outputJsonGz_=t.readJsonGz=t.readJsonGz_=t.zCopyToBuffer_=t.zpipe_=t.zcat=t.zcat_=void 0;const n=i(r(73024)),s=r(76760),o=r(46466),a=r(38522),l=r(19851),u=r(40958),c=r(98553),d=r(80875),h=r(50213),f=r(57159),m=r(29882),p=r(57902),g=r(32323),y=r(58722),v=(0,l.lazy)((()=>(0,h.mkLogger)("fs.zcat")));async function w(e,t){return(await b(e,t)).toString()}async function S(e,t,r){const i=[],s=[n.default.createReadStream(e,{autoClose:!0,...r}).on("error",(e=>i.push(e)))];if(e.toLowerCase().endsWith(".gz")?s.push((0,a.createGunzip)().on("error",(e=>i.push(e)))):e.toLowerCase().endsWith(".br")&&s.push((0,a.createBrotliDecompress)().on("error",(e=>i.push(e)))),s.push(t),await(0,o.pipeline)(s),(0,u.isNotEmpty)(i))throw new f.WrappedError("zPipe("+e+") failed",{causes:i,path:e})}async function b(e,t){const r=new y.WritableToBuffer;return await S(e,r,t),await r.buffer}async function P(e){return(0,d.parseJSON)(await b(e))}async function _(e,t){const r=(0,c.stringify)(t);await(0,m.mkdirp_)((0,s.parse)(e).dir),await(0,o.pipeline)(new g.ReadableBuffer(r),(0,a.createGzip)(),n.default.createWriteStream(e,{autoClose:!0}))}t.zcat_=w,t.zcat=async function(e,t){try{return w(e,t)}catch(t){return void v().warn("zcat failed to read "+e,t)}},t.zpipe_=S,t.zCopyToBuffer_=b,t.readJsonGz_=P,t.readJsonGz=async function(e,t=p.LogLevels.warn){try{return await P(e)}catch(r){return void v().log(t,"readJsonGz("+e+"): failed",r)}},t.outputJsonGz_=_,t.outputJsonGz=async function(e,t,r=p.LogLevels.warn){try{await _(e,t)}catch(t){v().log(r,"outputJsonGz("+e+"): failed",t)}}},33866:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HealthCheckIds=void 0;const i=r(50989);t.HealthCheckIds=(0,i.strEnum)("library-db","library-directories","library-free-space","library-nothing-to-sync","ps-version","media-directories","nodejs-version","proc-memory-use","proc-not-in-dmg","proc-not-superuser","settings-env","settings-library","settings-system","sync-paused","system-load","system-version","system-volumes","tools-exiftool","tools-heif","tools-jpegtran","tools-powershell","tools-sharp","tools-sqlite-version","tools-video","volume-uuids")},52086:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CropStrategies=void 0;const i=r(50989);t.CropStrategies=(0,i.strEnum)("center","entropy","attention")},48584:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharpFailOns=void 0;const i=r(50989);t.SharpFailOns=(0,i.strEnum)("none","truncated","error","warning")},32105:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;const i=r(19851),n=r(23560),s=r(66184),o=r(72210);class a{log(e,t,r,i){this.enabled(e,t)&&(0,o.pushLogEntries)({ts:Date.now(),l:e,from:(0,n.processName)(),ctx:t,msg:r,meta:i})}enabled(e,t){return(0,s.logFilter)().enabled(e,t)}async flush(){}toJSON(){return{_ctor:"ConsoleLogger"}}}t.ConsoleLogger=a,a.instance=(0,i.lazy)((()=>new a))},14593:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ContextualLogger=void 0;const i=r(57975),n=r(22573),s=r(26905),o=r(55835),a=r(68708),l=r(13538),u=r(50213),c=r(97352),d=r(45255),h=r(76740),f=r(57159),m=r(57902),p=/logger|lazy/i;class g{constructor(e,t=u.rootLoggers){this.loggers=t,this.abortable=new h.Abortable,this.context=(0,n.toNotBlank)(e)??(0,s.shortStack)().find((e=>!p.test(e)))??""}toLogJSON(){return"CtxLogger("+this.context+")"}[i.inspect.custom](){return this.toLogJSON()}addContext(e){return new g(this.context+e,this.loggers)}addParameterContext(e){return new g(this.context+"("+e+")",this.loggers)}throwIfAborted_(e){try{e?.throwIfAborted_(),this.abortable.throwIfAborted_()}catch(e){throw this.log("warn","throwIfAborted_()",{error:e}),e}}async awaitOrAbort(e){try{return await this.abortable.awaitOrAbort(e)}catch(e){throw this.log("warn","awaitOrAbort()",{error:e}),e}}throw(e,t){const r=(0,f.toWrappedError)(e,{message:this.context,error:t?.error,meta:(0,a.omit)(t,"error")});throw Error.captureStackTrace?.(r),this.log(!0===r.ignorable?"warn":"error",".throw() "+r.message,{stack:r.stack,...t}),r}tap(e){const t=e.level??(0,c.mapGt0)(e.meta?.elapsedMs,m.msTolevel)??m.LogLevels.debug;return this.log(t,e.msg,{result:e.result,...e.meta}),e.result}tapThunk(e){const t=Date.now();let r;try{r=setTimeout((()=>this.log("warn","slow: "+e.msg)),d.ShortCommandTimeoutMs);const i=e.result(),n=Date.now()-t;return this.tap({level:e.level,msg:e.msg,result:i,meta:{...e.meta,elapsedMs:n}})}catch(t){throw this.log("error","error: "+e.msg,{error:t,...e.meta}),t}finally{(0,o.map)(r,clearTimeout)}}async tapAsync_(e){try{return this.tap({...e,result:await(0,l.thenOrTimeoutError)(e.result,e.timeoutMs)})}catch(t){return this.throw(t,(0,a.pick)(e,"errorMsg","msg","timeoutMs","meta"))}}enabled(e,t){for(const r of this.loggers())if(r.enabled(e,t??this.context))return!0;return!1}log(e,t,r){for(const i of this.loggers())i.log(e,this.context,t,r)}elapsed(e,t,r){this.log((0,m.msTolevel)(t),e,{elapsedMs:t,...r})}async flush(){for(const e of this.loggers())await e.flush()}error(e,t){this.log("error",e,t)}warn(e,t){this.log("warn",e,t)}info(e,t){this.log("info",e,t)}debug(e,t){this.log("debug",e,t)}trace(e,t){this.log("trace",e,t)}}t.ContextualLogger=g},28981:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFormatter=void 0;const i=r(19851),n=r(51879);t.DefaultLogFormatter=(0,i.lazy)((()=>new n.PlaintextLogFormatter))},20839:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLogFlushMs=void 0,t.DefaultLogFlushMs=750},4904:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sortLogEntriesInPlace=t.logEntrySorter=t.isLogEntry=void 0;const i=r(76790),n=r(31586),s=r(51926),o=r(57902);t.isLogEntry=function(e){return null!=e&&(0,n.isNumber)(e?.ts)&&(0,s.isString)(e?.msg)&&o.LogLevels.includes(e.l)},t.logEntrySorter=function(e){return e?.ts},t.sortLogEntriesInPlace=function(e){(0,i.sortByInPlace)(e,(e=>e.ts))}},66184:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isLogged=t.ifLog=t.silentlyAsync=t.silently=t.isDefaultLogLevelAtLeast=t.defaultLogLevel=t.logFilter=t.LogLevelRe=t.SimpleLogFilter=void 0;const i=r(19851),n=r(57902);class s{constructor(e){this.minLogLevel=e,this.silent=!1,this.defaultLevelIndex=(0,n.levelIndex)(e)}highlight(){return!1}enabled(e){return(0,n.levelIndex)(e)<=this.defaultLevelIndex}}t.SimpleLogFilter=s,t.LogLevelRe=/^(?:(.+?):)?(fatal|error|warn|info|debug|trace)$/i,t.logFilter=(0,i.lazy)((()=>new s(n.LogLevels.warn))),t.defaultLogLevel=(0,i.lazy)((()=>n.LogLevels.values[(0,t.logFilter)().defaultLevelIndex])),t.isDefaultLogLevelAtLeast=function(e){return(0,t.logFilter)().defaultLevelIndex>=(0,n.levelIndex)(e)},t.silently=function(e){try{return(0,t.logFilter)().silent=!0,e()}finally{(0,t.logFilter)().silent=!1}},t.silentlyAsync=async function(e){try{return(0,t.logFilter)().silent=!0,await e()}finally{(0,t.logFilter)().silent=!1}},t.ifLog=function(e,r){return(0,t.logFilter)().enabled(e)?r():void 0},t.isLogged=function(e,r){return(0,t.logFilter)().enabled(e,r)}},57902:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.msTolevel=t.level2syslog=t.levelGte=t.levelIndex=t.LogLevels=void 0;const i=r(42659),n=r(31586),s=r(50989);t.LogLevels=(0,s.strEnum)("fatal","error","warn","info","debug","trace");const o=t.LogLevels.indexOf("trace");t.levelIndex=function(e){return t.LogLevels.indexOf(e)??t.LogLevels.indexOf(e.trim().toLowerCase())??o},t.levelGte=function(e,r){return(0,n.gte)(t.LogLevels.indexOf(e),t.LogLevels.indexOf(r))};const a=new Map([[t.LogLevels.fatal,1],[t.LogLevels.error,3],[t.LogLevels.warn,4],[t.LogLevels.info,6],[t.LogLevels.debug,7]]);t.level2syslog=function(e){return a.get(e)},t.msTolevel=function(e,t=7*i.secondMs){return e>=t?"error":e>=t/2?"warn":e>=t/4?"info":"debug"}},72210:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popExpiredLogEntries=t.pushLogEntries=t.logEntries=t.setLogTailEnabled=t.logTailEnabled=void 0;const i=r(92322),n=r(82328),s=r(28981),o=r(20839),a=r(4904);let l=!1;t.logTailEnabled=function(){return l},t.setLogTailEnabled=function(e){l=e},t.logEntries=new i.SortedSet(a.logEntrySorter),t.pushLogEntries=function(...e){for(const r of e)l?t.logEntries.add(r):(0,n.stdoutEnded)()||console.log((0,s.DefaultLogFormatter)().formatLogEntry(r))},t.popExpiredLogEntries=function(e=2*o.DefaultLogFlushMs){return t.logEntries.shiftLte(Date.now()-e)}},51879:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PlaintextLogFormatter=void 0;const i=r(57975),n=r(40958),s=r(55835),o=r(68708),a=r(54993),l=r(23560),u=r(81168),c=r(57902);t.PlaintextLogFormatter=class{constructor(e={colors:!1,showHidden:!1,depth:5,compact:!0,customInspect:!0}){this.inspectOptions=e,this.paddedLogLevels=(0,o.fromEntries)(c.LogLevels.values.map((e=>[e,(0,u.rightPad)(e,5," ")])))}formatLogEntry(e){return(0,n.compactBlanks)([new Date(e.ts).toISOString(),e.from??(0,l.processName)(),this.paddedLogLevels[e.l],(0,u.stripAnsiEsc)(e.ctx),(0,u.stripAnsiEsc)(e.msg),(0,s.map)(e.meta,(e=>(0,i.inspect)(e,this.inspectOptions)))]).map((e=>(0,a.toS)(e))).join(" ")}format(e,t,r,i){return this.formatLogEntry({ts:Date.now(),l:e,from:(0,l.processName)(),ctx:t,msg:r,meta:i})}}},82647:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Average=t.averageStats=t.p84=void 0;const o=r(57975),a=r(40958),l=r(96249),u=r(55835),c=r(31586),d=r(68708),h=r(59455),f=r(48884),m=r(89788),p=r(22454),g=r(70417);t.p84=function(e){return null!=e&&(0,c.isNumber)(e.mean)&&(0,c.isNumber)(e.sd)?e.mean+e.sd:0},t.averageStats=function(e){return(new y).pushAll(e).stats()};class y{static merge(e,t){if(0===e.n&&0===t.n)return new y(Math.max(e.maxSamples,t.maxSamples));if(0===e.n)return t.clone();if(0===t.n)return e.clone();if(e.n<=e.maxSamples){const r=t.clone();return r.pushAll(e.samples),r}if(t.n<=t.maxSamples){const r=e.clone();return r.pushAll(t.samples),r}{const r=new y(Math.max(e.maxSamples,t.maxSamples));r._n=e.n+t.n,r._min=Math.min(e._min,t._min),r._max=Math.max(e._max,t._max),r._m=e._m*e.n/r.n+t._m*t.n/r.n,r._s=e._s*e.n/r.n+t._s*t.n/r.n;const i=(0,l.flatten)((0,f.zip)(e.samples,t.samples));return r._samples.push(...i),r._weightedTotalAvg=(0,g.weightedAvg)([r._m,...i]),r}}constructor(e=20){i.add(this),this.maxSamples=e,this._n=0,this._samples=new m.BoundedList(e)}[(i=new WeakSet,o.inspect.custom)](){return this.stats()}toJSON(){return{_ctor:"Average",n:this._n,_m:this._m,_s:this._s,min:this._min,max:this._max,samples:this._samples.toA()}}static fromJSON(e){return(new y).with(e)}with(e){this._n=e.n,this._min=e.min,this._max=e.max,this._m=e._m,this._s=e._s,this._samples.push(...(0,h.toA)(e.samples))}merge(e){if(null==e||0===e.n)return this;if(0===this.n)return this.with(e.toJSON());this._min=(0,g.min)([this._min,e.min]),this._max=(0,g.max)([this._max,e.max]);const t=this.n+e.n;return this._m=this._m*this.n/t+e._m*e.n/t,this._s=this._s*this.n/t+e._s*e.n/t,this._n+=e._n,this._samples.push(...(0,h.toA)(e.samples)),this}push(e){if(!isFinite(e))throw new Error("Average.push("+e+"): not a number");if(this._n++,this._samples.push(e),this._min=null==this._min?e:Math.min(e,this._min),this._max=null==this._max?e:Math.max(e,this._max),1===this._n||null==this._m||null==this._s||null==this._weightedTotalAvg)this._m=e,this._s=0,this._weightedTotalAvg=e;else{const t=this._m;this._m+=(e-t)/this._n,this._s+=((e-this._m)*(e-this._m)-this._s)/this._n,this._weightedTotalAvg=(this._weightedTotalAvg+e)/2}return e}clone(){return(0,d.tap)(new y(this.maxSamples),(e=>{e._n=this._n,e._m=this._m,e._s=this._s,e._min=this._min,e._max=this._max,e._weightedTotalAvg=this._weightedTotalAvg,e._samples.push(...this._samples)}))}pushAll(e){if(null!=e)for(const t of e)(0,c.isNumber)(t)&&this.push(t);return this}stats(e=2){const t=t=>(0,u.map)(t,(t=>t>100?Math.round(t):(0,c.sigFigs)(t,e))),r={};return r.k=t(this.n),this.empty||(r.mean=t(this.avg),r.sum=t(this.sum),r.sd=t(this.stdDev),r.max=t(this.max),r.min=t(this.min)),r}get empty(){return 0===this._n}get n(){return this._n}get avg(){return this.empty?void 0:(0,c.sigFigs)(this._m,4)}get sum(){return this._n>0?this._m*this._n:0}get max(){return this._max}get min(){return this._min}get last(){return this._samples.last}get p16(){return s(this,i,"m",n).call(this,-1)}get p29(){return s(this,i,"m",n).call(this,-.5)}get p38(){return s(this,i,"m",n).call(this,-.25)}get p69(){return s(this,i,"m",n).call(this,.5)}get p84(){return s(this,i,"m",n).call(this,1)}get p98(){return s(this,i,"m",n).call(this,2)}get p99(){return s(this,i,"m",n).call(this,3)}get stdDevOverMean(){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(Math.sqrt(this._s)/this._m,4)}get variance(){return this._s}get stdDev(){const e=this.variance;return null==e?void 0:Math.sqrt(e)}get sampleMode(){return this.sampleModes(1)?.[0]}sampleModes(e){if(this.empty)return;const t=new p.CountingSet;return this._samples.forEach((e=>t.incr(e))),t.topKeys(e)}get sampleVariance(){return(0,a.mapNotEmpty)(this._samples,g.variance)}get sampleStdDev(){return(0,a.mapNotEmpty)(this._samples,g.stdDev)}get sampleAvg(){return(0,a.mapNotEmpty)(this._samples,g.avg)}get sampleSlope(){return(0,g.slope)(this._samples)??0}get samples(){return[...this._samples]}get weightedSampleAvg(){return(0,u.map)((0,g.weightedAvg)(this._samples),(e=>(0,c.sigFigs)(e,4)))}get weightedTotalAvg(){return this._weightedTotalAvg}clear(){this._n=0,this._m=void 0,this._s=void 0,this._weightedTotalAvg=0,this._samples.length=0}}t.Average=y,n=function(e){return null==this._m||null==this._s?void 0:(0,c.sigFigs)(this._m+Math.sqrt(this._s)*e,4)}},20014:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bits=t.pop=t.bitsSetBig=t.bitUnzip=t.bitZip=t.isBitSet=t.BitZip=t.diffConcattedBits=t.splitBits=t.concatBits=void 0;const i=r(40958),n=r(55835),s=r(31586),o=r(30976),a=r(48884),l=r(70417);function u(e,t){const r=Math.pow(2,t),i=[];for(;e>0;)i.unshift(e%r),e=Math.floor(e/r);return i}t.concatBits=function(e,t){const r=Math.pow(2,t);return e.reduce(((e,t)=>e*r+(0,s.clamp)(0,r,(0,s.toInt)(t,{defaultValue:0}))),0)},t.splitBits=u,t.diffConcattedBits=function(e,t,r){return(0,n.map2)(e,t,((e,t)=>(0,i.sum)((0,a.zip)(u(e,r),u(t,r)),(([e,t])=>(0,s.absdiff)(e,t)))))},t.BitZip=class{constructor(e){this.dims=e}clampValue(e){return e.map(((e,t)=>(0,s.clamp)(this.dims[t].min,this.dims[t].max,e)))}randomValue(){return this.dims.map((e=>(0,o.randomInt)(e.min,e.max)))}zipMin(e){return this.zip(this.dims.map((e=>e.min)),e)}zipMax(e){return this.zip(this.dims.map((e=>e.max)),e)}zip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max)),n=this.clampValue(e);let s=0;for(let e=0;eo?(s+=1,r[t]=o):i[t]=o}return s}unzip(e,t){const r=this.dims.map((e=>e.min)),i=this.dims.map((e=>e.max));for(let n=0;n(r[e]+i[e])/2))}};const c=Math.pow(2,32)-1;function d(e,t,r){return!0!==r&&e>t&1):1==Math.floor(e/Math.pow(2,t))%2}function h(e){return[...e.toString(2)].reverse().map(((e,t)=>"1"===e?t:-1)).filter((e=>-1!==e))}t.isBitSet=d,t.bitZip=function(e){e.dims.forEach((e=>e.value=(0,s.clamp)(e.min,e.max,e.value)));let t=0;for(let r=0;rs?(t+=1,n.min=s):n.max=s}return t},t.bitUnzip=function(e,t){if(t.bitDepth>52||t.bitDepth<0)return;const r=h(e);for(let e=0;e(0,l.avg)([e.min,e.max])))},t.bitsSetBig=h,t.pop=function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,63&(e+=e>>8)+(e>>16)},t.bits=function(e,t){return(0,i.sum)(e,((r,i)=>t(r,i)?Math.pow(2,e.length-i-1):0))}},55222:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NumericRadix=t.AlphaRadix=t.TokenRadix=t.GeoRadix=t.RadixAlphaNum=t.Base64=t.Radix58=t.Hex=t.Radix=t.encodeDigits=void 0;const i=r(77598),n=r(22573),s=r(55835),o=r(32639),a=r(88158),l=r(81168),u=BigInt(0);function c(e,t,r=0){if(!isFinite(t)||e<=1)return[];const i=[];if(0===t)i.unshift(0);else for(;t>0;)i.unshift(t%e),t=Math.floor(t/e);for(;i.lengththis.numerals[e])).join("")}encode(e,t=0){if(!isFinite(e))return"";const r=e<0;return r&&(e=Math.abs(e),t--),(r?"-":"")+this.digitsToNumerals(c(this.base,e,t))}encodeBigInt(e){if("bigint"!=typeof e)throw new Error("bad input");if(e===u)return this.numerals[0];const t=[],r=BigInt(this.base);let i=e;for(;i>u;)t.push(Number(i%r)),i/=r;return this.digitsToNumerals(t.reverse())}encodeBuffer(e){if(null==e||0===e.length)return"";const t=[0];for(let r of e)for(t.forEach(((e,i)=>{r+=e<<8,t[i]=r%this.base,r=Math.floor(r/this.base)}));r>0;)t.push(r%this.base),r=Math.floor(r/this.base);return this.digitsToNumerals(t.reverse())}decode(e){return(0,s.map)(this.decodeBigInt(e),(t=>{if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("decode("+e+") is > 2^53");return Number(t)}))}normalize(e){return this.decodePreparser(e)}decodeBigInt(e){if(null==e||(0,n.blank)(e))return;const t="-"===(e=(0,o.isFunction)(this.decodePreparser)?this.decodePreparser(e):e)[0];t&&(e=e.slice(1));const r=BigInt(this.base);let i=BigInt(0);for(const t of e){const e=this.numerals.indexOf(t);if(e<0)return;i=i*r+BigInt(e)}return t?BigInt(-1)*i:i}randomChars(e){return this.encodeBuffer((0,i.randomBytes)(Math.ceil(Math.log2(this.base)*(e+4)/8))).slice(2,2+e)}randomUid(e=20,t=5,r="-"){return(0,l.splitEvery)(this.randomChars(e),t).join(r)}tokenEql(e,t,r){const i=this.normalizeToken(e),n=this.normalizeToken(t);return i.length>=r&&i===n}normalizeToken(e){return[...this.decodePreparser(e.trim())].filter((e=>this.numerals.includes(e))).join("")}}t.Radix=d,t.Hex=new d("hex","0123456789abcdef",(e=>e.toLowerCase())),t.Radix58=new d("Radix58","123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),t.Base64=new d("Radix64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),t.RadixAlphaNum=new d("RadixAlphaNum","0123456789abcdefghijklmnopqrstuvwxyz",(e=>e.toLowerCase())),t.GeoRadix=new d("GeoRadix","0123456789bcdefghjkmnpqrstuvwxyz",(e=>e.toLowerCase())),t.TokenRadix=new d("TokenRadix","0123456789abcdefhjkmnpqrtuvwxy",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9"))),t.AlphaRadix=new d("AlphaRadix","abcdefghjkmnopqrtuvwxyz",(e=>e.toLowerCase().replace(/0/g,"o").replace(/2/g,"z").replace(/5/g,"s").replace(/9/g,"g"))),t.NumericRadix=new d("NumericRadix","0123456789",(e=>e.toLowerCase().replace(/o/g,"0").replace(/[il]/g,"1").replace(/z/g,"2").replace(/s/g,"5").replace(/g/g,"9")))},976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rateStats=void 0;const i=r(31586);t.rateStats=function(e){return{eventCount:e?.eventCount,eventsPerSecond:(0,i.sigFigs)(e?.eventsPerSecond,2),msSinceLastEvent:e?.msSinceLastEvent}}},70417:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},o=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r};Object.defineProperty(t,"__esModule",{value:!0}),t.jaccard=t.cosineSimilarity=t.dot=t.l2norm=t.centroid=t.weightedAvg=t.p84=t.stdDev=t.variance=t.slope=t.normalize=t.avg=t.Mean=t.sumf=t.sum=t.mode=t.modes=t.deltas=t.max=t.min=void 0;const a=r(40958),l=r(55835),u=r(31586),c=r(59455),d=r(22454),h=r(77377),f=r(82647);function m(e){let t;for(const r of e)null!=r&&(null==t||rt)&&(t=r);return t}function y(e,t){const r=new d.CountingSet;for(const t of e)(0,u.isNumber)(t)&&r.incr(t);return r.topKeys(t)}function v(e,t){let r=0,i=0;for(const n of e){if(null!=n){const e=t(n,r);(0,u.isNumber)(e)&&(i+=e)}r++}return i}t.min=m,t.max=g,t.deltas=function(e){const t=(0,c.toA)(e);return null==e||t.length<=1?[]:t.slice(1).map(((e,r)=>e-t[r]))},t.modes=y,t.mode=function(e){return y(e,1)[0]},t.sum=function(e){let t=0;for(const r of e)(0,u.isNumber)(r)&&(t+=r);return t},t.sumf=v;class w{constructor(){i.set(this,0),n.set(this,void 0)}push(e){var t;(0,u.isNumber)(e)&&(o(this,n,null==s(this,n,"f")?e:s(this,n,"f")*s(this,i,"f")/(s(this,i,"f")+1)+e/(s(this,i,"f")+1),"f"),o(this,i,(t=s(this,i,"f"),++t),"f"))}get mean(){return s(this,n,"f")}}function S(e){const t=new w;for(const r of e)t.push(r);return t.mean}function b(e){const t=S(e);if(null==t)return;let r=0,i=0;for(const n of e)(0,u.isNumber)(n)&&(i++,r+=(n-t)*(n-t));return r/i}function P(e){let t=0;for(const r of e)t+=r*r;return Math.sqrt(t)}function _(e,t){let r=0;for(let i=0;i(1-t)*e+t*(r+o*(e-n)/s)))},t.slope=function(e){const t=(0,c.toA)(e).filter(u.isNumber),r=S(t);if(null!=r){const e=(t.length-1)/2,i=v(t,((t,i)=>(t-r)*(i-e))),n=v(t,(e=>(e-r)**2));return 0===n?0:i/n}},t.variance=b,t.stdDev=function(e){return(0,l.map)(b(e),Math.sqrt)},t.p84=function(e){return(new f.Average).pushAll(e).p84},t.weightedAvg=function(e,t=.5){let r;t=(0,u.clamp)(0,1,t);for(const i of e)r=null==r?i:r*t+i*(1-t);return r},t.centroid=function(e){const t=e[0].length,r=[];for(let i=0;ie[i]))));return r},t.l2norm=P,t.dot=_,t.cosineSimilarity=function(e,t){return(0,u.finiteOrElse)(_(e,t)/(P(e)*P(t)),void 0)},t.jaccard=function(e,t){return(0,a.isEmpty)(e)&&(0,a.isEmpty)(t)?0:(0,u.finiteOrElse)((0,h.intersection)(e,t).size/(0,h.union)(e,t).size,void 0)}},45969:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isDocker=void 0;const i=r(73024),n=r(38639),s=r(19851),o=r(59958),a=r(43334);t.isDocker=(0,s.lazy)((()=>a.isLinux&&((0,n.toBoolean)(process.env[o.PS_IS_DOCKER])??(0,i.existsSync)("/.running-in-container"))))},29325:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPacked=void 0;const i=r(76760),n=r(19851),s=r(54993);t.isPacked=(0,n.lazy)((()=>!(0,s.toS)(__filename).includes((0,i.join)("core","platform","IsPacked"))))},43334:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.platformName=t.isElectron=t.isMainElectron=t.isCaseSensitiveFs=t.isPosix=t.isLinuxSnap=t.isLinuxAppImage=t.isLinux_arm=t.isArm=t.isLinux_x64=t.isLinux=t.isMac=t.isWinPortable=t.isWin=t.isCI=t.inspectFlag=void 0;const n=i(r(48161)),s=i(r(1708)),o=r(22573),a=r(38639),l=r(59958),u=n.default.platform();t.inspectFlag=s.default.argv.includes("--inspect")||(0,a.isTrue)(s.default.env.NODE_INSPECT),t.isCI=(0,a.isTrue)(s.default.env.CI),t.isWin="win32"===u||"cygwin"===u,t.isWinPortable=t.isWin&&(0,o.notBlank)(s.default.env.PORTABLE_EXECUTABLE_DIR),t.isMac="darwin"===u,t.isLinux="linux"===u,t.isLinux_x64=t.isLinux&&"x64"===n.default.arch(),t.isArm=null!=/^arm\b/i.exec(n.default.arch()),t.isLinux_arm=t.isLinux&&t.isArm,t.isLinuxAppImage=t.isLinux&&((0,o.notBlank)(s.default.env.APPIMAGE)||(0,o.notBlank)(s.default.env.APPDIR)),t.isLinuxSnap=t.isLinux&&(0,o.notBlank)(s.default.env.SNAP_USER_DATA),t.isPosix=t.isMac||t.isLinux,t.isCaseSensitiveFs=t.isLinux,t.isMainElectron=null!=s.default.versions.electron,t.isElectron=t.isMainElectron||(0,a.isTrue)(s.default.env[l.ELECTRON_RUN_AS_NODE]),t.platformName=t.isWin?"win":t.isMac?"mac":t.isLinux?"linux":u},24540:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.procDeviceModel=t.isRaspberryPi=t.containsRpiModel=void 0;const n=i(r(73024)),s=r(19851),o=r(43334);function a(e="/proc/cpuinfo"){if(o.isWin||o.isMac)return!1;try{return null!=n.default.readFileSync(e).toString().match(/^\s*model\s*:\s*Raspberry Pi/im)}catch{return!1}}t.containsRpiModel=a,t.isRaspberryPi=(0,s.lazy)((()=>o.isLinux_arm&&a())),t.procDeviceModel=(0,s.lazy)((()=>{try{return o.isLinux?n.default.readFileSync("/proc/device-tree/model").toString():void 0}catch{return}}))},45643:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.waitForPidExit=t.existingPids=void 0;const i=r(58587),n=r(59455),s=r(31562);t.existingPids=function(e){return(0,n.toA)(e).filter(i.pidExists)},t.waitForPidExit=function(e,t){return(0,s.untilTrue)((()=>!(0,i.pidExists)(e)),{timeoutMs:t,intervalMs:250})}},95402:function(e,t,r){var i,n,s,o,a=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)},l=this&&this.__classPrivateFieldSet||function(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.addPid=t.Pids=t.killPid=void 0;const c=r(58587),d=u(r(31421)),h=u(r(1708)),f=r(40958),m=r(22573),p=r(42659),g=r(55835),y=r(31586),v=r(97790),w=r(59455),S=r(54993),b=r(54557),P=r(19851),_=r(50213),E=r(88158),M=r(409),C=r(78406),T=r(25764),x=r(99331),D=r(56519),k=r(46292),O=r(8769),I=r(83278),F=r(32144),A=r(29882),N=r(43334),L=r(24399),R=r(58261),j=(0,P.lazy)((()=>(0,_.mkLogger)("proc.Pids"))),B=10*p.secondMs;function V(e,t){if(null==e||null==t||e.pid!==t.pid)return!1;const r=(0,g.map)(t.start,(e=>e.getTime())),i=e.startTime;return(0,y.gt0)(r)&&(0,y.gt0)(i)&&Math.abs(r-i){const e=Date.now()-2*p.minuteMs,t=await this.pidsDir.childFiles((async t=>(0,F.isJsonExt)(t)&&(0,A.isHiddenBasename)(t.base)&&(0,y.lt)(t.mtimeMs(),e)));for(const e of(0,w.toA)(t))j().warn("killOldProcs(): deleting old pid WIP, "+e.base),await e.unlink("debug")}}),this.killOldProcs=(0,M.rateLimited)({name:"Pids.killOldProcs()",minCallDelayMs:p.minuteMs,f:async(e={})=>{j().info("killOldProcs()",e),await this.vacuumOldWip();const t=e.everything??!1,r=e.force??N.isWin,i=await this.pidfiles(),n=await this.pids(i??[]);if((0,f.isEmpty)(n))return j().info("killOldProcs(): no pidfiles"),[];const s=[],o=[],a=await(0,R.pidInfos)(n);if(null!=a){for(const n of i){const i=await n.readJson();if(null==i){j().warn("killOldProcs(): failed to read pidfile "+n.base),await n.unlink("debug");continue}const l=i.pid;if(!(0,y.gt0)(l)){j().warn("killOldProcs(): invalid json.pid: unlinking pidfile "+n.base,{json:i,pid:l}),await n.unlink("debug");continue}const u=a.find((e=>e.pid===l));if(null==u||!V(i,u)){j().debug("killOldProcs(): pid no longer present: unlinking "+n.base,{json:i,pidEntry:u}),await n.unlink("debug"),s.push(i);continue}const c=(0,y.gt0)(i.timeoutMs)?i.startTime+i.timeoutMs:void 0,d=t?"all pids are being shut down":(0,y.gt)(Date.now(),c)?`timed out ${Date.now()-c} ms ago`:(0,y.lt)(i.startTime,e.everythingBefore)?"cleanup everything before "+new Date(e.everythingBefore).toISOString():void 0;null!=d&&(j().info("killOldProcs(): killing",{reason:d,json:i}),o.push(W(l,r,!1)),s.push({...i,...u}))}return o.length>0&&await Promise.allSettled(o),s}(0,O.onError)("Pids.killOldProcs(): failed to get process information")}}),o.set(this,void 0)}async addPid_(e,t,r=!1){if(null==e)throw new Error("undefined info");const o=e.pid;if(!(0,y.gt0)(o))throw new Error("undefined pid");const l=e.ppid+":"+e.pid;return(0,c.pidExists)(o)?(r&&a(this,n,"f").delete(l),a(this,n,"f").getOrSet(l,(async()=>{const r=a(this,i,"m",s).call(this,e.pid),n=(0,v.opt)((0,E.Try)((()=>(0,A.parseNativePath)(e.cmd).base))).filter(m.notBlank).getOrElse((()=>e.cmd)),o=t.getTime(),l={...e,cmd:n,startTime:o};return await r.writeJson_(l),j().debug("addPid() wrote "+r,l),r}))):(a(this,n,"f").delete(l),void j().debug("addPid(): no-op, pid already gone",{info:e,start:t}))}pidfiles(){return this.pidsDir.clear().children((e=>{const t=(0,y.toInt)(e.name);return".json"===e.ext&&null!=t&&t!==h.default.pid}))}async pids(e=this.pidfiles()){return(0,f.compact)((0,w.toA)(await e).map((e=>(0,y.toInt)(e.name))))}async onKill(e){const t=a(this,i,"m",s).call(this,e);return(0,D.thenMap)(t.readJson(),(t=>this.addPid_({...t,timeoutMs:1},(0,p.ago)(p.minuteMs),!0).catch((t=>{j().info("onKill(): failed to rewrite pidfile: "+t,{pid:e})}))))}scheduleInterval(){return(null==a(this,o,"f")||a(this,o,"f").ended)&&l(this,o,new C.EndableInterval({name:"Pids.cleanup",callback:()=>this.killOldProcs(),intervalMs:5*p.minuteMs,rank:T.EndableRanks.first}),"f"),a(this,o,"f")}cancelInterval(){a(this,o,"f")?.end(),l(this,o,void 0,"f")}}t.Pids=q,n=new WeakMap,o=new WeakMap,i=new WeakSet,s=function(e){return this.pidsDir.join(e+".json")},q.instance=(0,P.lazy)((()=>(0,g.map)((0,k.configDir)(),(e=>new q(I.BaseFile.for(e).join("pids")))))),t.addPid=function(e,t){return q.instance()?.addPid_(e,t)}},58261:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.psWinWmic=t.pidInfos=t.notExistingPids=t.pidInfo=t.isProcEntry=void 0;const n=r(31421),s=r(48161),o=i(r(1708)),a=r(40958),l=r(22573),u=r(42659),c=r(31586),d=r(68708),h=r(59455),f=r(54993),m=r(48884),p=r(53507),g=r(19851),y=r(50213),v=r(84968),w=r(48963),S=r(56519),b=r(84777),P=r(8103),_=r(45879),E=r(43334),M=r(24399),C=r(45643),T=(0,g.lazy)((()=>(0,y.mkLogger)("proc.ps")));function x(e){return null!=e&&(0,c.gt0)(e.pid)&&null!=e.start&&(0,l.notBlank)(e.cmd)}async function D(e){if(E.isLinux)return async function(e){const t=[];for(const r of e)t.push(z(await(0,_.readFileMaybe)("/proc/"+r+"/stat")));return T().tap({msg:"pidInfoProc",result:(0,a.compact)(t)})}(e);const t=(0,C.existingPids)(e),r=(await(0,m.collectBatchedAsync)(t,20,E.isWin?F:R)).filter((e=>x(e)&&t.includes(e.pid)));return T().tap({msg:"pidInfos()",result:r,meta:{pids:e}})}t.isProcEntry=x,t.pidInfo=async function(e){return(0,S.thenMap)(D([e]),(t=>(0,h.toA)(t).find((t=>t.pid===e))))},t.notExistingPids=async function(e){return(0,a.isEmpty)(e)?[]:(0,S.thenMap)((0,C.existingPids)(e),(t=>{const r=[o.default.pid,...t];return e.filter((e=>!r.includes(e)))}))},t.pidInfos=D;const k="Get-Process",O="| Select-Object -Property Id,ProcessName,StartTime";function I(e){return(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).join(",")}async function F(e){if(M.PowerShell.instance().ended)return L(e);const t=[k,"-Id",I(e),"-ErrorAction SilentlyContinue",O].join(" ");return(0,S.thenMap)(M.PowerShell.instance().executeJsonToA(t),(e=>e.map((e=>({pid:e.Id,start:(0,w.pwshJsonDate)(e.StartTime),cmd:e.ProcessName})))))}const A={maxBuffer:1048576,timeoutMs:15*u.secondMs,ignoreExitCode:!0,ignoreStderr:!0},N=["CommandLine","CreationDate","ProcessId"];async function L(e){const t=["process"];if((0,a.isNotEmpty)(e)){const r=(0,a.uniq)([...e.filter(c.gt0),o.default.pid]).map((e=>`ProcessId=${e}`)).join(" or ");t.push("where",r)}t.push("get",N.join(","));const r=await(0,b.stdoutResult_)((0,P.wmic)(),t,A),i=(0,d.onlyReqValued)((0,p.parseFixed)(N,r.result).map((e=>({pid:(0,c.toInt)(e.ProcessId,{defaultValue:-1}),start:(0,w.wmiDate)(e.CreationDate),cmd:(0,f.toS)(e.CommandLine)}))));return i.find((e=>e.pid===o.default.pid))||i.push({pid:o.default.pid,start:new Date(v.StartTs),cmd:"node "+o.default.title}),i}async function R(e){return t=(await(0,b.stdoutResult_)("ps",["-p",I(e),"-wwwo","pid,lstart,command"],{...A,ignoreExitCode:!0})).result,(0,l.blank)(t)?[]:(0,p.parseFixed)(["PID",{text:"STARTED",greedyLeft:!0},"COMMAND"],t).map((e=>({pid:(0,c.toInt)(e.PID,{defaultValue:-1}),start:new Date(e.STARTED),cmd:(0,f.toS)(e.COMMAND)})));var t}t.psWinWmic=L;const j=(0,g.lazy)((()=>{try{if(E.isLinux)return(0,c.toGt0)((0,n.spawnSync)("getconf",["CLK_TCK"],{shell:!1}))??100}catch(e){T().warn("clk_tck failed",{error:e})}return 100})),B=(0,g.lazy)((()=>Date.now()-(0,s.uptime)()*u.secondMs)),V=/(?\d+) \((?.+)\) (?[A-Z]) (?:\d+ ){18}(?\d+)/i;function z(e){const t=V.exec((0,f.toS)(e))?.groups,r=(0,c.toInt)(t?.pid),i=t?.comm,n=(0,c.toInt)(t?.starttime);return(0,c.gt0)(r)&&!(0,l.blank)(i)&&(0,c.gt0)(n)?{pid:r,cmd:i,start:new Date(B()+n/j()*u.secondMs),state:t?.state}:void 0}},24399:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.checkPowerShell_=t.PowerShell=t.pwshQuote=void 0;const i=r(58587),n=r(19851),s=r(22573),o=r(42659),a=r(41400),l=r(55835),u=r(13538),c=r(36557),d=r(14121),h=r(50213),f=r(7282),m=r(45255),p=r(81168),g=r(25764),y=r(38836),v=r(99331),w=r(56519),S=r(31562),b=r(84777),P=r(34102),_=r(43334),E=r(28874),M=r(63870),C="{ready}",T=" | ConvertTo-Json -Compress";function x(e){return'"'+e.replace(/['`"“”#]/g,(e=>"`"+e)).replace(/\0/g,"`0").replace(/\n/g,"`n").replace(/\r/g,"`r").replace(/\t/g,"`t").replace(/\v/g,"`v")+'"'}t.pwshQuote=x,(0,a.later)((()=>(0,P.ee)().on("clearCache",(()=>D.instance.prior()?.clearMockResults()))));class D extends y.EndableWrapper{static ensureInstance(){const e=this.instance();return e.ended?this.instance.refresh():e}constructor(){super("PowerShell",(()=>this.bco.end()),g.EndableRanks.postdb),this.mockResults=new Map,this.bco=new c.BatchClusterObserver("PowerShell",new i.BatchCluster({processFactory:()=>(0,b.execFile)("powershell",E.Settings.powerShellArgs.values),logger:()=>(0,h.mkLogger)("PowerShell"),versionCommand:[`function prompt {"${C}"}`,...(0,s.mapNotBlankOr)(E.Settings.powerShellCulture.valueOrDefault,(e=>[`[System.Threading.Thread]::CurrentThread.CurrentCulture = '${e}'`,`[System.Threading.Thread]::CurrentThread.CurrentUICulture = '${e}'`]),[])].join(";"),pass:C,fail:"Error",exitCommand:"exit",maxProcs:E.Settings.powerShellProcs.valueOrDefault,taskTimeoutMillis:(0,M.commandTimeoutMs)(),maxIdleMsPerProcess:o.minuteMs,cleanupChildProcs:!1}),g.EndableRanks.postdb),E.Settings.powerShellProcs.watch((()=>this.bco.t.setMaxProcs(E.Settings.powerShellProcs.valueOrDefault))),this.pwsh=this.bco.t}get lastStartError(){return this.bco.lastStartError}get lastTaskError(){return this.bco.lastTaskError}get ended(){return this.pwsh.ended}versionPojo(){return this.executeJson("$PSVersionTable.PSVersion")}version(){return(0,w.thenMap)(this.executeJson("$PSVersionTable.PSVersion"),(e=>`${e.Major}.${e.Minor}.${e.Build}`))}get spawnedProcCount(){return this.pwsh.spawnedProcCount}pushMockJsonResult(e,t){this.pushMockResult((0,p.ensureSuffix)(e,T),t)}pushMockResult(e,t){this.mockResults.set(e,t)}clearMockResults(){this.mockResults.clear()}async execute(e,t){if(this.pwsh.ended||(0,v.ending)())this.logger.warn("execute() failed (ended)",{cmd:e});else{if((0,f.isTest)()&&this.mockResults.has(e)){const r=this.mockResults.get(e);return t(r.stdout,r.stderr,r.passed)}try{const r=await(0,d.thenElapsed)(this.pwsh.enqueueTask(new i.Task(e,((r,i,n)=>t((0,l.map)(r,(t=>(0,p.stripPrefix)(t,e))),i,n)))));return this.logger.tap({msg:"execute()",result:r.result,meta:{elapsedMs:r.elapsedMs,cmd:e}})}catch(t){return void this.logger.warn("execute() failed: "+t,{cmd:e})}}}async executeJson(e){const t=await this.execute((0,p.ensureSuffix)(e,T),((e,t,r)=>({stdout:e,stderr:t,passed:r})));if(null!=t)if((0,s.blank)(t.stdout)||(0,s.notBlank)(t.stderr)||!t.passed)this.logger.warn("executeJson(): failed result",{cmd:e,...t});else try{return JSON.parse(t.stdout)}catch(e){const r=t.stdout.replace(/\\/g,"\\\\");return this.logger.info("executeJson(): parsing failed, trying dub-whack fix...",{before:(0,p.ellipsize)(t.stdout),after:(0,p.ellipsize)(r)}),JSON.parse(r)}else this.logger.warn("executeJson(): null result",{cmd:e})}async executeJsonToA(e){return(0,w.thenMap)(this.executeJson(e),(e=>Array.isArray(e)?e:[e]))}async which(e){const t=await this.executeJson("Get-Command -ErrorAction SilentlyContinue "+x(e)+" | Select-Object -Property Source");return Array.isArray(t)?t[0]?.Source:t?.Source}}t.PowerShell=D,D.instance=(0,n.lazy)((()=>{if(!_.isWin)throw new Error("PowerShell isn't available on this platform");return new D})),t.checkPowerShell_=async function(){const e=D.instance();if(e.ended||(0,v.ending)())return"PowerShell ended";const t=await(0,u.thenOrTimeoutError)(e.version(),(0,M.commandTimeoutMs)());if((0,s.blank)(t)){const t=await(0,S.until)((()=>e.lastStartError??e.lastTaskError),{timeoutMs:m.ShortCommandTimeoutMs,intervalMs:250});throw null!=t?t:new Error("(unknown error)")}return t}},22859:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AggregateTypes=void 0;const i=r(50989);t.AggregateTypes=(0,i.strEnum)("union","intersection")},71988:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AssetFileSortCriteria=void 0;const i=r(50989);t.AssetFileSortCriteria=(0,i.strEnum)("resolution","schemeIdx","capturedAtPrecision","metadataCoverage","isBrowserSupported","isEditOrUpdate","isCover","count","mtime","basename","parentBasename","uri")},38483:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BooleanSetting=void 0;const i=r(22573),n=r(38639),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toBoolean})}}t.BooleanSetting=o},90536:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).flatMap(parseFloat).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedFloatSetting=a},75164:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BoundedIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(97790),o=r(83179);class a extends o.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:t=>(0,s.opt)(t).filter(i.notBlank).flatMap(n.toInt).map((t=>(0,n.clamp)(e.min,e.max,t))).get()}),this.options=e}get min(){return this.options.min}get max(){return this.options.max}clamp(e){return(0,n.clamp)(this.min,this.max,e??this.min)}addToJSON(){return{"minimum value":this.options.min,"maximum value":this.options.max}}}t.BoundedIntegerSetting=a},10546:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ColorDistanceFunctions=void 0;const i=r(50989);t.ColorDistanceFunctions=(0,i.strEnum)("cie76","cie94","ciede2000")},90967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CronSetting=void 0;const i=r(36507),n=r(22573),s=r(45599),o=r(50213),a=r(81168),l=r(98314),u=r(8769),c=r(80372),d=(0,s.defer)((()=>(0,o.mkLogger)("settings.CronSetting")));function h(e){try{const t=(0,a.trimQuotes)(e);return void((0,n.blank)(t)||(0,i.Cron)(t))}catch(e){return e?.message??(0,l.errorToS)(e)}}function f(e,t,r){try{return(0,n.blank)(t)?void 0:(0,i.Cron)(t,{name:e,unref:!0,protect:!0,catch:r=>(0,u.onError)(r,{name:e,crontab:t}),...r})}catch(r){return void d().warn("invalid cron",{name:e,crontab:t,error:r})}}class m extends c.StringSetting{constructor(e){super({whyInvalid:h,...e})}cron(e){return f(this.name,this.value,e)??f(this.name,this.defaultValue,e)}}t.CronSetting=m},67958:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorKmeansRunsDefault=void 0,t.DominantColorKmeansRunsDefault=7},55948:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DominantColorPixelsDefault=void 0,t.DominantColorPixelsDefault=1024},57039:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalDurationSetting=t.DurationSetting=void 0;const i=r(70488),n=r(91655),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration})}get valueOrDefault(){return(0,i.decodeDuration)(super.valueOrDefault)}get value(){return(0,i.decodeDuration)(super.value)}set value(e){super.userValue=(0,i.decodeDuration)(e)}get humanValue(){return(0,n.fmtFullDuration)(this.value)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}set fileValue(e){super.fileValue=(0,i.decodeDuration)(e)}}t.DurationSetting=o;class a extends s.Setting{constructor(e){super({...e,toEnv:i.encodeDuration,fromEnv:i.decodeDuration,defaultValue:void 0})}get valueOrDefault(){return this.value??(0,i.decodeDuration)(this.defaultValue)}get fileValue(){return(0,i.encodeDuration)(super.fileValue)}}t.OptionalDurationSetting=a},9945:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.FloatSetting=o},74589:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.IntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt})}}t.IntegerSetting=o},844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinValidYear=void 0,t.MinValidYear=1920},96093:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFileSetting=void 0;const i=r(22573),n=r(53265),s=r(87652);class o extends s.OptionalStringSetting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>(0,i.blank)(e)?void 0:(0,n.resolve)(e),defaultValue:void 0,...e})}}t.OptionalFileSetting=o},23561:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalFloatSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({defaultValue:void 0,...e,toEnv:i.notBlankToS,fromEnv:n.toFloat})}}t.OptionalFloatSetting=o},69005:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalIntegerSetting=void 0;const i=r(22573),n=r(31586),s=r(83179);class o extends s.Setting{constructor(e){super({...e,toEnv:i.notBlankToS,fromEnv:n.toInt,defaultValue:void 0})}}t.OptionalIntegerSetting=o},87652:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalStringSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:e=>e?.trim(),fromEnv:e=>e,defaultValue:void 0,...e})}hasValue(){return null!=this.value}}t.OptionalStringSetting=n},28283:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.envFromName=t.nameFromEnv=void 0;const i=r(51926),n=r(83556);t.nameFromEnv=function(e){return(0,n.snake2camel)(e.replace(/^PS_/,"").toLowerCase())},t.envFromName=function(e){return(0,i.ensurePrefix)((0,n.camel2snake)(e).toUpperCase(),"PS_")}},83179:function(e,t,r){var i,n,s=this&&this.__classPrivateFieldGet||function(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.settingsToObj=void 0;const o=r(19851),a=r(40958),l=r(79666),u=r(50357),c=r(57924),d=r(98553),h=r(55835),f=r(68708),m=r(39926),p=r(46891),g=r(42279),y=r(59455),v=r(40583),w=r(81168),S=r(44198),b=r(96706),P=r(34102),_=r(28283),E=r(81075),M=r(98778),C=r(10357);t.settingsToObj=function(e){const t={};for(const r of e)r.hasValue()&&(t[r.name]=r.value);return t},t.Setting=class{constructor(e){i.add(this),this.opts=e,this._envValue=(0,o.lazy)((()=>this.readFromEnv())),this.watchers=[],this.optsOverrides={}}getState(){return{user:this._userValue,env:this.envValue,file:this._fileValue,tmp:this._tmpValue}}dump(){return{name:this.name,key:this.key,...this.getState(),hasValue:this.hasValue(),isUnset:this.isUnset(),defaultValue:this.defaultValue}}setState(e){null!=e&&(this._userValue=e.user,this.envValue=e.env,this._fileValue=e.file,this._tmpValue=e.tmp)}toEnv(e){return null!=this.opts.whyInvalid?.(e)?void 0:this.opts.toEnv(e)}fromEnv(e){if(null==e)return;const t=this.opts.fromEnv(e);return null==t||null!=this.opts.whyInvalid?.(t)?void 0:t}normalizeValue(e){return null==e?void 0:this.fromEnv(this.toEnv(e))}whyInvalidValue(e){const t=this.opts.whyInvalid?.(e);return null!=t?s(this,i,"m",n).call(this,e)+": "+t:this.whyInvalidEnvValue(this.toEnv(e),e)}whyInvalidEnvValue(e,t){const r=this.opts.whyInvalid?.(e);return null!=r?s(this,i,"m",n).call(this,e??t)+": "+r:null==this.fromEnv(e)?s(this,i,"m",n).call(this,e??t):void 0}get fileValue(){return this._userValue??this._fileValue}set fileValue(e){this.onChange(e,(e=>this._fileValue=e))}get envValue(){return this._envValue()}set envValue(e){this.onChange(e,(t=>{null==e?this.deleteFromEnv():this.addToEnv(void 0,t),this._envValue.unset()}))}refreshEnvValue(e={}){const t=(0,l.shallowClone)(this.valueOrDefault);this._envValue.unset(),!0===e?.broadcastChange&&this.maybeBroadcastChange(t)}get tmpValue(){return this._userValue??this._tmpValue}set tmpValue(e){this.onChange(e,(e=>this._tmpValue=e))}get value(){return this._userValue??this._envValue()??this._fileValue??this._tmpValue}set value(e){this.userValue=null==e?void 0:e}get humanValue(){return this.value}set userValue(e){this.onChange(e,(e=>this._userValue=e))}get valueOrThrow(){const e=this.value;if(null==e)throw new Error("Missing value for setting "+this.name);return e}hasValue(){return null!=this.value}isUnset(){return null==this.value}includesEnvKey(e){return(0,w.includesIgnoreCase)([...this.keys,...this.names],e)}readFromEnv(e){const t=null==e?(0,b.caseInsensitiveEnv)():new v.CaseInsensitiveValued(e);for(const e of[...this.keys,...this.names]){const r=(0,h.map)(t.get(e),(e=>this.fromEnv(e)));if(null!=r)return r}}setFromEnv(e=(0,S.env)()){return this.envValue=this.readFromEnv(e)}setValueIfDefined(e){null!=e&&(this.value=e)}watchLater(e){this.watchers.push(e)}watch(e){this.watchLater(e),setImmediate((()=>this.broadcastChange()))}unWatch(e){(0,a.filterInPlace)(this.watchers,(t=>t===e))}broadcastChange(){const e=this.valueOrDefault;for(const t of this.watchers)t(e);(0,P.ee)().emitDebounced("settingsChanged")}onChange(e,t){const r=(0,l.shallowClone)(this.valueOrDefault);t(this.normalizeValue(e)),this.maybeBroadcastChange(r)}maybeBroadcastChange(e){(0,u.eql)(this.valueOrDefault,e)||this.broadcastChange()}get name(){return this._name}get names(){return this._names}_setName(e){if(null!=this._name)throw new Error("cannot set name twice");this._name=e,this._names=(0,a.uniq)([e,...(0,y.toA)(this.opts.aliases)]),this._key=(0,_.envFromName)(e),this._keys=(0,a.uniq)([...this._names.map(_.envFromName),this._key,...(0,y.toA)(this.opts.envAliases)])}get key(){return this._key}get keys(){return this._keys}get altKeys(){return this._keys.filter((e=>e!==this._key))}get category(){return this.opts.category}get categoryType(){return E.LibraryCategories.includes(this.category)?"library":"system"}get transient(){return!0===this.opts.transient}get advanced(){return(0,h.mapOr)(this.opts.advanced,(e=>e()),(()=>!0))}get envValueOrDefault(){return this.toEnv(this.valueOrDefault)}set tmpValueIfUnset(e){this.isUnset()&&(this.tmpValue=e)}get defaultValue(){return(0,g.tot)(this.optsOverrides.defaultValue)??(0,g.tot)(this.opts.defaultValue)}set defaultValue(e){const t=(0,l.shallowClone)(this.valueOrDefault);this.optsOverrides.defaultValue=e,this.maybeBroadcastChange(t)}resetDefaultValue(){this.optsOverrides.defaultValue=void 0}get exampleValue(){return(0,g.tot)(this.optsOverrides.exampleValue??this.opts.exampleValue)}set exampleValue(e){this.optsOverrides.exampleValue=e}get valueOrDefault(){return this.value??this.defaultValue}addToEnvMaybe(e,t){const r=e??(0,S.env)(),i=t??this.value;return null!=i&&(r[this.key]=this.toEnv(i)),null==e&&b.caseInsensitiveEnv.unset(),r}toEnvValue(e){return this.toEnv(e??this.valueOrDefault)}addToEnv(e,t){const r=e??(0,S.env)(),i=this.toEnvValue(t);return null!=i&&(r[this.key]=i,null==e&&b.caseInsensitiveEnv.unset()),r}deleteFromEnv(e){const t=(0,h.map)(e,(e=>new v.CaseInsensitiveValued(e)))??(0,b.caseInsensitiveEnv)();for(const e of[...this.names,...this.keys])t.delete(e);return t.obj}unsetFileValue(){this._userValue=void 0,this._fileValue=void 0,this._tmpValue=void 0}unset(){return this.onChange(void 0,(()=>{this.unsetFileValue(),this._envValue.unset(),this.optsOverrides={},this.deleteFromEnv()})),this}addToJSON(){return{}}toJSON(){return{key:this.key,value:this.value,valueOrDefault:this.valueOrDefault}}toCommentedLines(){const e=this.name+" or "+this.key,t=(0,w.wrap)([(0,m.padding)("-",e.length),e,(0,m.padding)("-",e.length),"",...!0===this.opts.deprecated?["NOTE: this setting has been deprecated and will be removed in a future version of PhotoStructure.",""]:[],`${this.opts.description.replace(/\n+/g,"\n\n")}`],C.WrapComments);function r(e,r){(0,a.isEmpty)(r)||t.push(...(0,w.wrap)(["",(1===r.length?e:(0,p.pluralize)(e))+": "+(0,c.orList)(r.map((e=>(0,d.stringify)(e))))],C.WrapComments))}r("alias",this.opts.aliases),r("environment alias",this.altKeys);for(const[e,r]of(0,f.entries)(this.addToJSON())){const i=Array.isArray(r)?(0,c.orList)(r.map((e=>(0,d.stringify)(e)))):(0,d.stringify)(r);t.push(...(0,w.wrap)(["",e+": "+i],C.WrapComments))}return t}toEnvLine(e){return this.key+"="+((0,h.map)(e,(e=>this.toEnv(e)))??this.envValueOrDefault)}toTomlLines(){const e=this.toCommentedLines();return(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Example value:"],key:this.name,value:(0,g.tot)(this.exampleValue)}),(0,M.wrapTomlToLines)({lines:e,wrap:C.WrapComments,prepend:["Default value:"],key:this.name,value:(0,g.tot)(this.defaultValue)}),(0,M.wrapTomlToLines)({lines:e,key:this.name,value:(0,g.tot)(this.fileValue)}),e}},i=new WeakSet,n=function(e){return`Invalid value for ${this.constructor.name} "${this.key}": ${(0,d.stringify)(e)}`}},81075:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SystemCategories=t.LibraryCategories=t.SettingCategories=void 0;const i=r(50989);t.SettingCategories=(0,i.strEnum)("Paths","Desktops","Filesystem","Cache","Logging","Networking","Processes","Security","Tools","Performance","Auth","Color","Db","Deduping","Filters","HealthChecks","Parsing","Previews","Privacy","Reporting","Sidecars","Subscriptions","Sync","Tagging","Updates","Video","Volumes","Web"),t.LibraryCategories=Object.freeze([t.SettingCategories.Auth,t.SettingCategories.Color,t.SettingCategories.Db,t.SettingCategories.Deduping,t.SettingCategories.Filters,t.SettingCategories.HealthChecks,t.SettingCategories.Parsing,t.SettingCategories.Previews,t.SettingCategories.Privacy,t.SettingCategories.Reporting,t.SettingCategories.Sidecars,t.SettingCategories.Subscriptions,t.SettingCategories.Sync,t.SettingCategories.Tagging,t.SettingCategories.Updates,t.SettingCategories.Video,t.SettingCategories.Volumes,t.SettingCategories.Web].sort()),t.SystemCategories=Object.freeze(t.SettingCategories.values.filter((e=>!t.LibraryCategories.includes(e))).sort())},28874:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ciSettings=t.getSettingByNameOrKey=t.persistedLibrarySettings=t.persistedSystemSettings=t.transientSettings=t.persistedSettings=t.allSettings=t.pathWithDefaults=t.withDefaultPaths=t.SuggestedDirsEnvKey=t.Settings=t.DefaultMaxEmbeddedBuffer=t.isProd=void 0;const i=r(58587),n=r(76760),s=r(19851),o=r(40958),a=r(76790),l=r(22573),u=r(42659),c=r(73722),d=r(68708),h=r(50989),f=r(12168),m=r(54993),p=r(37975),g=r(9092),y=r(40583),v=r(79840),w=r(7282),S=r(12801),b=r(4328),P=r(70488),_=r(84248),E=r(5531),M=r(99315),C=r(34365),T=r(34580),x=r(96706),D=r(50274),k=r(33866),O=r(52086),I=r(48584),F=r(45969),A=r(43334),N=r(24540),L=r(70379),R=r(71300),j=r(33209),B=r(48987),V=r(68268),z=r(61208),W=r(99023),q=r(30577),U=r(1485),H=r(19861),G=r(55111),J=r(30933),K=r(22859),$=r(71988),Y=r(38483),Z=r(90536),X=r(75164),Q=r(10546),ee=r(90967),te=r(67958),re=r(55948),ie=r(57039),ne=r(9945),se=r(74589),oe=r(844),ae=r(96093),le=r(23561),ue=r(69005),ce=r(87652),de=r(81075),he=r(58305),fe=r(57571),me=r(72564),pe=r(80372),ge=r(80496);t.isProd=(0,s.lazy)(w.isProd);const ye=()=>!(0,t.isProd)();function ve(){return t.Settings.exposeNetworkWithoutAuth.valueOrDefault}function we(){return(0,t.isProd)()?"warn":"info"}t.DefaultMaxEmbeddedBuffer=25e4,t.Settings={configDir:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,description:["This is the system configuration directory. This can't be overridden in the system settings.toml, as it's used to _find_ the system settings.toml! This setting is here for documentation, and to allow the PS_CONFIG_DIR environment variable to override the default setting.","PhotoStructure's system configuration directory defaults to:","- Windows: %APPDATA%\\PhotoStructure (%APPDATA% is normally set to %HOME%/AppData/Roaming)","- macOS: ~/Library/Application Support/PhotoStructure","- Linux: ${XDG_CONFIG_DIR:$HOME/.config}/PhotoStructure."].join("\n"),defaultValue:()=>"",advanced:()=>!1,transient:!0}),libraryDir:new ae.OptionalFileSetting({aliases:["libraryPath","library"],category:de.SettingCategories.Paths,description:"This is the absolute path to your PhotoStructure library. If missing, or set to an empty string, the welcome page will be shown when PhotoStructure launches. Use native file separators (so on windows, use back-slashes).",defaultValue:()=>"",advanced:()=>!1}),copyAssetsToLibrary:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'Should PhotoStructure copy photos and videos to your PhotoStructure Library? This setting holds the value for the welcome page\'s "May PhotoStructure organize your photos and videos?" section, and is called "automatic organization" on the website.\nRead more about this setting here: https://photostructure.com/getting-started/automatic-library-organization/ .',defaultValue:!0,advanced:()=>!1}),previewsDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store preview images. This defaults to the ".photostructure/previews" directory inside your PhotoStructure library. Absolute paths here are supported, but if you keep your library and previews directory separated, take care when you open your library on different computers, as this setting needs to be adjusted for those computers as well.\nNOTE: "originalDirs" is recommended instead of this setting; If you get "previewsDir" wrong, your library won\'t work. If you get "originalsDir" wrong, you just break full-screen asset zooming and playback for non-transcoded videos.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 .',defaultValue:()=>".photostructure/previews"}),originalsDir:new pe.StringSetting({aliases:["originalDir"],category:de.SettingCategories.Paths,description:'This is the directory that PhotoStructure uses to store original images when "copyAssetsToLibrary" is enabled. Absolute paths are supported. Relative paths are evaluated from your libraryDir. This setting defaults to ".", which is the same as your PhotoStructure library directory, unless you are on docker, and a /ps/originals directory exists.\nIf you open your PhotoStructure library on a different computer, and that computer doesn\'t have access to your originals volume, full-screen zoom won\'t work, and non-transcoded videos will not play.\nThis system setting needs to be set appropriately on different computers (it won\'t be set automatically!)\nIf you have a large library and want to use an SSD, we recommend you set your libraryDir to your SSD, and use this setting to store your originals on a larger volume, rather than using the "previewsDir" setting.\nSee https://forum.photostructure.com/t/hybrid-photostructure-libraries/775 and https://forum.photostructure.com/t/new-easy-mode-for-docker-coming-in-v2-1/1278/6?u=mrm .',defaultValue:""}),scanAllDrives:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Should PhotoStructure scan all folders on all drives available to this computer for photos and videos?",defaultValue:!0,advanced:()=>!1}),scanMyPictures:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:'If set, PhotoStructure will automatically add your pictures directory to your "scanPaths" setting and then flip this setting back to false. Add your Pictures directory directly to your scanPaths setting instead.',defaultValue:!1,deprecated:!0}),scanPaths:new he.StringArraySetting({aliases:["scanPath"],category:de.SettingCategories.Paths,description:'This holds an array of absolute paths to scan for assets. If you are setting this via an environment variable, you may use either standard PATH formatting, like `PS_SCAN_PATHS="/path/one:/path/two"`, or use JSON encoding, like `PS_SCAN_PATHS=\'["/path/one","/path/two"]\'`.',advanced:()=>!1}),argvScanPaths:new he.StringArraySetting({category:de.SettingCategories.Paths,description:'This holds an array of absolute paths provided on the command line to import. This overrides "scanPaths", and should always be scanned for changes. See https://forum.photostructure.com/t/1597/4 . For internal use only.',transient:!0,advanced:()=>!0}),pidFile:new ce.OptionalStringSetting({category:de.SettingCategories.Paths,envAliases:["PIDFILE"],description:"This is the absolute path to the PID file for the main process. This is optional and only used by PhotoStructure for Servers. Make sure the UID/GID that PhotoStructure runs as can read and write to this file.",exampleValue:()=>"/var/run/photostructure.pid"}),cacheDir:new pe.StringSetting({category:de.SettingCategories.Paths,description:"Where would you like PhotoStructure's scratch file directory? This must be a fast, local disk with several gigabytes free.\nNote that if PS_FORCE_LOCAL_DB_REPLICA is enabled, the local DB replica will be stored in this directory while PhotoStructure is running: don't delete it!\nIf this is set to /tmp PhotoStructure will write to a user-specific /tmp/.photostructure-cache-$UID directory.",defaultValue:()=>""}),fsCacheSlowMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"If a cache entry takes longer than this value to compute, cache results for later reuse to the filesystem.\nThe default is very short, under the assumption that cache filesystem read/writes are <10ms.\nSet this to 0 to never cache to the filesystem.",defaultValue:()=>ye()?"1":"25"}),imageCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"Assets requiring conversion may need intermediary file storage as they are imported. These intermediary files only need to live as long as the import process for that asset. Too short of a time will result in this conversion work being re-done during import. Too long of a time will result in additional diskspace in your cache directory being consumed.",defaultValue:"15m"}),readdirCacheMs:new ie.DurationSetting({category:de.SettingCategories.Cache,description:"readdir() can take a long time over slow network shares and when directories are very large. This setting controls how long to cache readdir results that are slow (which take >= .5 seconds). Too short of a time will result in low cache hit rates, and very slow imports for these problematic directories. Too long of a time will result in PhotoStructure not seeing changes made to these directories.\nSet to 0 to disable readdir() caching.",defaultValue:"5m"}),readdirSizeCacheThresh:new se.IntegerSetting({category:de.SettingCategories.Cache,description:"If readdir() has more than this number of child elements, always cache it.\nSet to 0 to disable readdir() caching.",defaultValue:()=>ye()?32:1024}),quiet:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"If true, the main service won't emit lifecycle messages to stdout. Note that logStdout=true or logTail=true will override quiet=true.",defaultValue:!1}),logLevel:new pe.StringSetting({envAliases:["PS_LOG","LOG","LOG_LEVEL"],category:de.SettingCategories.Logging,description:'Determines which level of log messages are emitted to log files. May be "debug", "info", "warn", "error", "fatal", or several log level directives followed by a context (like "debug:web").',defaultValue:we}),logDir:new pe.StringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to.",defaultValue:()=>""}),logCompression:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Should log files be compressed as they are rotated?",defaultValue:t.isProd}),logWebRequests:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Write an access log for all web requests?",defaultValue:!1}),logWebDir:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:"Determines the directory that log files will be written to. If unset, will use logDir."}),logStdout:new Y.BooleanSetting({envAliases:["LOG_STDOUT","PS_STDOUT"],category:de.SettingCategories.Logging,description:"Log to stdout? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),tailLogs:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs from currently running PhotoStructure processes? This should be false unless you're running a service by hand.",defaultValue:!1,transient:!0}),logColor:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Output all logs with terminal escape codes to colorize output. If NO_COLOR=1, TERM=dumb, or TERM=unknown, this defaults to false. See https://no-color.org/ .",defaultValue:()=>!(0,p.noColor)()}),logContextLimit:new se.IntegerSetting({category:de.SettingCategories.Logging,description:"PhotoStructure will only log, at most, this number of elements or key/value pairs.",defaultValue:()=>32}),logSql:new Y.BooleanSetting({category:de.SettingCategories.Logging,description:"Log SQL queries to the default log level. **Enabling this negatively impacts performance.**.\nThis defaults to false.",defaultValue:()=>!1}),logServer:new ce.OptionalStringSetting({category:de.SettingCategories.Logging,description:'Format as hostname:port or ip_address:port.\nIf set, processes will emit log entries, formatted as GELF and separated by null bytes, via TCP.\nIf this is set, the default PS_LOG_LEVEL drops from "error" to "info".\nSee https://docs.greylog.org/v1/docs/gelf .',exampleValue:()=>"localhost:12201"}),logServerLevel:new pe.StringSetting({category:de.SettingCategories.Logging,description:'This is the log level used to filter logs before sending them to "PS_LOG_SERVER".\nIf unset, we\'ll use the value of "PS_LOG_LEVEL".',defaultValue:we}),useFsWatch:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will use the native filesystem watch APIs to detect file changes. This is the default and recommended setting. If false, PhotoStructure will poll the filesystem for changes instead. This is not recommended, but may be useful if you're running PhotoStructure on an OS or filesystem that doesn't support change notifications, like some network filesystems.\nSee https://nodejs.org/api/fs.html#availability for more information.",defaultValue:()=>!0}),allowFilesystemSleep:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"If true, PhotoStructure will set disable a handful of other settings which will allow the OS to put the filesystem to sleep when it's idle. This can save power, but can also cause PhotoStructure to miss file changes.\nThis sets sharedStatePollMs=0 and dbFsLockStaleMs=0.",defaultValue:()=>!1}),statTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'Filesystem traversal can be dangerous business with scratched CDROMs and old busted hard drives. To prevent PhotoStructure from getting "stuck" when trying to read these devices, it will timeout directory iteration if stat() or readdir() exceeds this value. The default of 30 seconds should cover most issues with spun-down hard drives and NAS/WAN latency.\nSet to 0 to disable.',defaultValue:()=>"30s"}),watchDebounceMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:'How long to wait for a file to "settle down" and stop changing before the file watcher notifies listeners that the file changed. Some applications (like PhotoStructure) use work-in-progress "atomic" writes, but many applications overwrite in-place, which can cause the file watcher to see incomplete results until the write process is complete.\nThe default is 500ms (½ second) to handle slow remote NASes and slow-writing applications.\nSet to 0 to disable.',defaultValue:()=>"500ms"}),excludedFilesystemTypes:new he.StringArraySetting({aliases:["ignoredFilesystemTypes"],category:de.SettingCategories.Filesystem,description:"Volumes with these filesystem types will never be scanned or imported.\nThese are only relevant to Linux and macOS systems.",defaultValue:()=>H.DefaultExcludedFilesystemTypes}),excludedRootDirectories:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into these root directories looking for assets.",defaultValue:()=>U.DefaultExcludedLinuxRoots}),excludedMountpointPaths:new he.StringArraySetting({aliases:["ignoredMountpoints"],category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these paths.",defaultValue:U.defaultExcludedLinuxMountpointPaths}),excludedMountpointBasenames:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"PhotoStructure won't descend into mountpoints that match these names.",defaultValue:()=>U.DefaultExcludedLinuxMountpointNames}),validateMountpoints:new Y.BooleanSetting({category:de.SettingCategories.Filesystem,description:"When true, PhotoStructure ignores volumes whose mountpoints do not exist. If any volumes are unhealthy, though, this may wedge volume handlers.",defaultValue:!0}),mountpoints:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:"If set, this value will be used instead of the cross-platform mountpoints() method. Normally only for internal use."}),mountpointsTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure scan for new volumes (so PhotoStructure can detect when drives are inserted or ejected)? Shorter than 10-15 seconds may cause issues on Windows. A value of 0 will cache indefinitely. This defaults to 15 minutes on Windows, which relies on polling. On Linux and macOS this is set to 0 because findmnt/gio and diskutil notify mountpoint changes without polling.",defaultValue:()=>A.isWin?"15m":"0"}),remoteFilesystemTypes:new he.StringArraySetting({category:de.SettingCategories.Filesystem,description:'Filesystems with these types should always be considered "remote".',defaultValue:["sshfs","s3fs"]}),volumeUuidFilePaths:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:'PhotoStructure will append these paths to all mountpoints to look for previously-set volume universally unique identifiers (UUIDs). The first item in this list that exists will be used, and if "writeVolumeUuidFiles" is true, the first item in this list will be used to write the volume UUID (which will be the partition UUID, if available, or a random UUID if not available). Windows users should use a forward slash as a path separator.',defaultValue:()=>[".uuid","System Volume Information/IndexerVolumeGuid"]}),readVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure uses ".uuid" files found in the root directory of volumes as the volume universally unique identifier (UUID), which supports cross-host and cross-OS library portability. Set this to false if you don\'t want PhotoStructure to read these ".uuid" files.\nNote that "globally unique identifier," or "GUID," is synonymous with "UUID" in this case. Microsoft tends to use the term "GUID" instead of "UUID."\nSee https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),skipWriteVolumeUuidFilesWithNoMedia:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:"When true, PhotoStructure will NOT write files with universally unique identifiers into the root directory of volumes that have been marked with a NoMedia file or folder. If writeVolumeUuidFiles is false this setting is ignored.",defaultValue:!0}),writeVolumeUuidFiles:new Y.BooleanSetting({category:de.SettingCategories.Volumes,description:'When true, PhotoStructure (tries to) write files with universally unique identifiers into the root directory of volumes, which enables cross-host library portability. Set this to false if you don\'t want PhotoStructure to try to write these ".uuid" files. See https://photostructure.com/faq/what-is-a-volume for more information.',defaultValue:!0}),writeVolumeUuidMountpointBlocklist:new he.StringArraySetting({category:de.SettingCategories.Volumes,description:"Never try to write a volume UUID file to these directories.",defaultValue:["sshfs","s3fs"]}),volumeMetadataTtlMs:new ie.DurationSetting({category:de.SettingCategories.Filesystem,description:"How frequently should PhotoStructure reload volume metadata (like bytes-free, which is used in a health check)? Values less than a minute are not necessary. A value of 0 will cache indefinitely.",defaultValue:"15m"}),hostname:new ce.OptionalStringSetting({category:de.SettingCategories.Networking,description:"If set, this overrides the local hostname. Useful under docker and when OSes change hostnames due to networking bugs (see macOS)."}),localhost:new pe.StringSetting({category:de.SettingCategories.Networking,description:'If "exposeNetworkWithoutAuth" is false, what value should PhotoStructure use for localhost? (Some firewalls are OK with "127.0.0.1", some require "localhost"). See https://letsencrypt.org/docs/certificates-for-localhost/ and https://photostructure.com/faq/troubleshooting/#windows-firewall-issues .',defaultValue:()=>"127.0.0.1"}),httpPort:new se.IntegerSetting({category:de.SettingCategories.Networking,description:"Network port for HTTP access to your PhotoStructure library.",defaultValue:1787}),noNetwork:new Y.BooleanSetting({category:de.SettingCategories.Networking,description:"If set, PhotoStructure will assume all outbound network requests will fail.",defaultValue:!1}),trustProxy:new pe.StringSetting({category:de.SettingCategories.Security,description:'What reverse proxies should PhotoStructure "trust"? See .\nThis setting should either be "false" (don\'t trust any proxies), "loopback", (only trust loopback/localhost), a single subnet (like "192.168.1.0/24"), or a comma-delimited set of subnets.',defaultValue:"loopback"}),exposeNetworkWithoutAuth:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"Normally the web service is only accessible to the computer running PhotoStructure. Setting this to true will expose your library to all computers on your network. You should own or trust all systems on that network, as there is no auth in PhotoStructure currently. Future versions of PhotoStructure will add authorization mechanisms, at which point this setting will be deleted.\n**Don't enable this unless you know what you are doing**.",defaultValue:()=>(0,F.isDocker)()}),cspReportOnly:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"DANGEROUS: do not enforce, and only report CSP violations. This should only be set to true temporarily to assist in debugging. See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP .",defaultValue:()=>!1}),upgradeInsecureRequests:new Y.BooleanSetting({category:de.SettingCategories.Security,description:"May PhotoStructure send the Upgrade-Insecure-Requests header? PhotoStructure will set the default to true automatically if it sees _any_ request is via https.\nSet this explicitly to false if you access PhotoStructure via both http (inside your LAN) and https (outside your LAN).",defaultValue:()=>!1}),cspDirective:new ce.OptionalStringSetting({category:de.SettingCategories.Security,description:"If you're seeing CSP errors with older browsers, add your externally-available base URL to this setting, and it will be appended to the CSP directives. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src .",exampleValue:()=>"https://myphotos.example.com"}),disabledHelmetMiddleware:new me.StringEnumsSetting({category:de.SettingCategories.Security,description:'What Helmet middleware should PhotoStructure disable?\nBy default, PhotoStructure enables all middleware, but if your reverse proxy is handling HTTP headers, you may want to remove some of Helmet\'s functionality.\nDisable all middleware by using the value "all", but know that CSP management is handled by the "cspDirective" and "cspReportOnly" settings.\nSee https://github.com/helmetjs/helmet#reference .',defaultValue:[],strEnum:G.HelmetPlugins}),shortProcessNames:new Y.BooleanSetting({category:de.SettingCategories.Processes,description:'Should PhotoStructure name its own processes "PhotoStructure" + the name of the sub-process, or abbreviated "phstr"? This defaults to false on PhotoStructure for Desktops and true everywhere else.',defaultValue:()=>!A.isElectron}),commandTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How long should PhotoStructure wait for a command that touches the filesystem (and doesn't do anything computationally expensive)? Note that external hard drives can take 10-15 seconds to spin up, and antivirus apps can hang for tens of seconds on slow machines, so values less than the default may result in undesired timeouts.",defaultValue:()=>"30s"}),minDelayBetweenSpawnMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"The shorter this time is, the faster PhotoStructure will ramp up parallelism at the start of a sync. Having a larger value here mitigates initial system load from forking. See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#minDelayBetweenSpawnMillis .",defaultValue:()=>(0,P.encodeDuration)((new i.BatchClusterOptions).minDelayBetweenSpawnMillis)}),minDelayBetweenRetriesMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["minDelayBetweenSpawnMillis"],description:"If a task has an error, should we wait a bit before retrying? This may help temper error cascades.",defaultValue:()=>"250ms"}),maxRetries:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If a task has an error, how many times should we retry before giving up?\nIf you have a flaky network, this can help ensure imports are comprehensive.\nSet this to 0 to disable retries.",defaultValue:()=>1}),minBusyPct:new se.IntegerSetting({category:de.SettingCategories.Processes,description:'Every couple of minutes, if a sync is currently running, and the system load is below this value, we will assume any task running longer than "stuckCheckIntervalMs" is "stuck" and should be canceled.\nSet this to 0 to disable this check.',defaultValue:()=>1}),stuckCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:'How often should sync check for stuck tasks? See "minBusyPct" for details.',defaultValue:()=>ye()?"5s":"5m"}),streamFlushMs:new ie.DurationSetting({category:de.SettingCategories.Processes,aliases:["streamFlushMillis"],description:"See https://photostructure.github.io/batch-cluster.js/classes/BatchClusterOptions.html#streamFlushMillis .",defaultValue:()=>A.isMac?"100ms":A.isWin?"200ms":"30ms"}),healthCheckIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"How often should the main process check on the health of the web and sync subprocesses?",defaultValue:()=>"10m"}),exiftoolProcsPerChild:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,description:'Controls the number of exiftool child processes allowed by the sync process. Note that each PhotoStructure process may spin up an ExifTool child process if needed. The "web" and "worker" services are limited to a single exiftool child process.\nIf this is unset, "sync" will default to the number of supported concurrent imports.'}),sensitiveEnvRegExp:new pe.StringSetting({category:de.SettingCategories.Processes,description:'PhotoStructure spawns several external processes, including "exiftool" and "ffmpeg".\nPhotoStructure filters out environment keys that are likely to contain sensitive information (like API access tokens or passwords) from these child processes so they aren\'t accidentally logged or accessible by external tools.\nThis regex is applied case-insensitively.',defaultValue:()=>v.DefaultSensitiveEnvRegexPattern}),syncExitTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"Wait at most this time for sync to shut down cleanly. This needs to be long enough to possibly copy the library database back to the remote filesystem if your library is stored on a network drive. Set to 0 to disable this timeout.",defaultValue:"2m"}),minTimeBetweenServiceRestartsMs:new ie.DurationSetting({category:de.SettingCategories.Processes,description:"If a service (like web or sync) is restarted due to an error, how many milliseconds must elapse before another restart is allowed? This helps prevent system load due to service flapping.",defaultValue:"7s"}),fatalErrorRatePerMinute:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"If PhotoStructure sees errors at a higher rate per minute than this setting, PhotoStructure will shut down. If this value is too high, PhotoStructure may look busy, but it's just busy failing. If this value is set too low, temporary errors (due to network flakiness or USB hiccups) might shut down PhotoStructure needlessly.",defaultValue:20}),minDiskFreeGb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will pause processing if the GB free on the disk that your library is stored on drops below this value. The value provided here will be multiplied by 1000^3. Note that many OSes will corrupt themselves when disks fill up, and SSDs can fail as they approach full capacity. A value of less than 8 may be unsafe (due to hibernation and OS update files).\nSet this value to 0 to disable free disk space health checks.",defaultValue:16}),cpuBusyPercent:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["cpuLoadPercent","cpuPct"],description:'This setting is a rough goal for PhotoStructure to load the system during library synchronization. A higher value here will allow PhotoStructure to run more tasks in parallel, but may impact your system\'s responsiveness.\nUnder normal circumstances, setting this to any value over 100 will result in full CPU saturation, and is not recommended, as it will cause spurious timeouts leading to some percentage of failed imports.\nWhile syncing, PhotoStructure will not dequeue sync file jobs if the current system busy percent exceeds this value.\nSetting this value to 0 will run the sync process in "single-process mode"--no external worker processes will be spun up by the "sync" process, and file imports will be done serially.',defaultValue:75,min:0,max:500}),timeoutThrottleCoeff:new ne.FloatSetting({category:de.SettingCategories.Processes,description:"When timeouts are detected, PhotoStructure throttles back concurrency automatically, with the assumption that some system is currently being overwhelmed and that less load should result in fewer failures due to timeouts.\nSpecifically, concurrency will be set to 1 / current rate of timeouts per minute over the past several minutes.\nThrottling will be more aggressive as this value approaches 0. For example a value of 0.1 will be very aggressive throttling. A value of 8 will only slow down sync after many soft timeouts.\nDisable throttling by setting to 0.",defaultValue:1}),maxConcurrentImports:new ue.OptionalIntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobs"],advanced:()=>!0,description:'How many imports can PhotoStructure schedule concurrently? This will be clamped between 1 and 32.\nIf not set, a sensible value will be computed based on "cpuLoadPercent".\nIf set explicitly, this and "sharpThreadsPerProcess" will override "cpuLoadPercent" and "maxConcurrentImportsWhenRemote" settings.'}),maxConcurrentImportsWhenRemote:new se.IntegerSetting({category:de.SettingCategories.Processes,aliases:["maxSyncFileJobsWhenRemote"],description:"How many concurrent files can be imported if the library is on a remote volume? This defaults to 2 to try to avoid overwhelming HDD I/O on the remote NAS. If this is larger than (cpus.length * cpuLoadPercent) or max child processes given available memory, this value will be ignored.",defaultValue:2}),sharpThreadsPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,aliases:["sharpThreadsPerJob"],advanced:()=>!0,description:"How many image processing threads can be spun per process?\nIf set to 0 (the default), PhotoStructure will pick an optimal value based on available memory and CPU cores.",min:0,max:8,defaultValue:0}),processPriority:new fe.StringEnumSetting({category:de.SettingCategories.Processes,description:'By default, PhotoStructure runs child processes with a "below normal" priority, so your system remains usable while imports run. Changing this value to "normal" or "above normal" may speed up imports but cause your system to be unresponsive. Changing this value to "idle" may prevent imports from running at all.\nFor Linux and macOS systems, see https://en.wikipedia.org/wiki/Nice_%28Unix%29 .\nFor Windows, see https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processpriorityclass?view=netframework-4.8 .',defaultValue:()=>S.PriorityClasses.BelowNormal,strEnum:S.PriorityClasses}),maxMemoryMb:new se.IntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will restart services if they use more than this value (measured in megabytes, or 1,000,000 bytes). Note that this is not the allocated memory. See maxRssMemoryMb for total allocated.\nSet to 0 to deactivate this check.",defaultValue:()=>2048}),maxTasksPerProcess:new X.BoundedIntegerSetting({category:de.SettingCategories.Processes,description:"PhotoStructure will recycle threads and worker processes after they handle this number of requests. Smaller values may reduce overall memory pressure. Larger values amortize startup costs over fewer restarts.",defaultValue:()=>ye()?50:500,min:1,max:5e3}),enableArchive:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Archive" button in Asset views will be visible and enabled for all visitors.',defaultValue:()=>!0}),enableDelete:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Delete" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableEmptyTrash:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Empty Trash" button will be enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),enableRemove:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove asset" button in Asset views will be visible and enabled for all visitors.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!0}),enableRemoveAssets:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, the "Remove Assets" buttons will be visible and enabled for all visitors.\nUntil PhotoStructure has visitor user levels, if you don\'t trust all your users, disable this!\nThis setting is disabled by default if exposeNetworkWithoutAuth is true.\nThis is a temporary setting until PhotoStructure enforces authentication/authorization.',defaultValue:()=>!ve()}),argon2TimeCost:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "time" cost parameter.',defaultValue:8}),argon2MemoryCostMB:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "memory" cost parameter, and is specified in megabytes. Each parallel thread will consume this amount of RAM: don\'t exceed your system memory.',defaultValue:64}),argon2Parallelism:new se.IntegerSetting({category:de.SettingCategories.Auth,description:'PhotoStructure encrypts user passwords with Argon2. This value sets the Argon2 "parallelism" parameter. RAM consumption will be ((this value) × argon2MemoryCost) KB of RAM: don\'t exceed your system memory.',defaultValue:1}),forceLocalDbReplica:new Y.BooleanSetting({category:de.SettingCategories.Paths,description:"Libraries on remote filesystems can suffer from bad performance and inconsistent transactions due to slow file I/O and missing file locking mechanics. When opening libraries on remote filesystems, or if this setting is `true`, PhotoStructure will copy the library database to the `cacheDir` and perform I/O against this local replica. Changes made to the local db replica are then periodically copied back to the remote library.\nIf you've overridden this value in the past, know that v23.5 and after should automatically set this to the correct value for you.\nFor more details, see https://forum.photostructure.com/t/whats-force-local-db-replica/837 and https://photostructure.com/about/2023-release-notes/#-sqlite-improvements .",defaultValue:()=>!1}),dbRetries:new se.IntegerSetting({category:de.SettingCategories.Db,description:"If SQLITE_BUSY is encountered, how many times should an operation be retried before giving up?",advanced:()=>!0,defaultValue:20}),dbBackupRetentionCount:new X.BoundedIntegerSetting({aliases:["dbBackupsCount"],category:de.SettingCategories.Db,description:"How many prior backups should PhotoStructure retain? These will typically be 10-500 MB, depending on the size of your library.\nWe don't retain that many backups by default because they get stale pretty quickly, as they fall out of sync with your filesystem and previews directory contents.",advanced:()=>!0,defaultValue:3,max:128,min:1}),dbAutoVacuumMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"SQLite can auto-vacuum your library database, which ensures the database stays performant. If this is set to NONE, PhotoStructure will periodically run vacuum and optimizations from the sync process. For details, https://sqlite.org/pragma.html#pragma_auto_vacuum .",advanced:()=>!0,strEnum:_.AutoVacuumModes,defaultValue:_.AutoVacuumModes.INCREMENTAL}),dbWalCheckpointType:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\n- PASSIVE, FULL, RESTART, and TRUNCATE values will enable.\nSee https://sqlite.org/pragma.html#pragma_wal_checkpoint .",strEnum:E.CheckpointTypes,defaultValue:E.CheckpointTypes.TRUNCATE}),dbWalAutoCheckpoint:new se.IntegerSetting({category:de.SettingCategories.Db,description:"The write-ahead log of your PhotoStructure library database is checkpointed periodically by the sync subprocess.\n- Choosing 0 will disable SQLite's built-in automatic PASSIVE checkpointing.\nSee https://sqlite.org/pragma.html#pragma_wal_autocheckpoint .",defaultValue:1e3}),dbInvalidFKThreshold:new se.IntegerSetting({category:de.SettingCategories.Db,description:"When PhotoStructure runs a database recovery, it will check for foreign key violations. If there are fewer than this number of invalid rows, PhotoStructure will drop those rows, with the hope that the next sync will finish the recovery.\nSet this to 0 to disable this recovery step, which will make any foreign key violation fatal.",defaultValue:64}),dbSynchronousMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'Change SQLite\'s synchronous mode.\n"OFF" will cause data corruption. "FULL" and "EXTRA" may be required if you\'re seeing dataloss.\nSee https://sqlite.org/pragma.html#pragma_synchronous .',strEnum:C.SynchronousModes,defaultValue:C.SynchronousModes.NORMAL}),dbRepairMode:new fe.StringEnumSetting({category:de.SettingCategories.Db,description:'PhotoStructure will automatically attempt to repair library databases that don\'t pass validation tests. SQLite has two repair strategies:\n- "dump", which will recover from minor errors and normally retains the current schema\n- "recover", which will recover as much data as possible from corrupt db. Unfortunately, this can result in an invalid and unusable schema, which is why PhotoStructure defaults to "dump".\nNote that PhotoStructure validates the schema after a repair, and will report via logs and the health check system if there are any issues.',strEnum:M.RepairModes,defaultValue:M.RepairModes.dump}),maxBusyDbMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite supports concurrent readers but concurrent writers may collide, causing a LOCKED or BUSY error. PhotoStructure will retry the db operation for maxBusyDbMs milliseconds. This defaults to 90 seconds to accommodate slow hard drive spinups and VACUUM write locks.",advanced:()=>!0,defaultValue:()=>"90s"}),dbBusyTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"SQLite can time out requests if the db file is unavailable. PhotoStructure will retry those requests (up to `maxBusyDbMs`). A shorter time may help overall throughput, but may require more work done in retry logic. A longer time may be better for slower machines and slower disks. Note that setting this value to be lower than disk I/O latency (~1ms-100ms) will cause all database queries to fail.\nSee https://sqlite.org/pragma.html#pragma_busy_timeout for more details.\nSet this to 0 to disable.",advanced:()=>!0,defaultValue:()=>"7s"}),dbMaintenanceTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How long is a reasonable time to wait for the library database to apply a migration, vacuum, quick check, validate foreign keys, or validate the schema?\nNote that the default of 2 minutes should be very generous--these operations should only take a second or two unless your library is very large and/or your disk is very slow.",advanced:()=>!0,defaultValue:()=>"2m"}),dbBackupIntervalMs:new ie.DurationSetting({category:de.SettingCategories.Db,description:"How frequently should PhotoStructure backup your library database?",advanced:()=>!0,defaultValue:()=>ye()?"30s":"30m"}),dbBackupIntervalMinutes:new Z.BoundedFloatSetting({category:de.SettingCategories.Db,deprecated:!0,description:'This setting was replaced by "dbBackupIntervalMs".',min:ye()?.5:1,max:1440,advanced:()=>!0,defaultValue:()=>ye()?.5:30}),dbPageSizeBytes:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's page_size PRAGMA. A default of 4k should be OK. This must be a power of 2. See https://sqlite.org/pragma.html#pragma_page_size for more information.",advanced:()=>!0,defaultValue:4096}),dbCacheSizeMb:new se.IntegerSetting({category:de.SettingCategories.Db,description:"This value will be used for SQLite's cache_size PRAGMA. The cache_size pragma should ideally be set such that the whole DB can be in memory. Note that PhotoStructure automatically increases this value to accommodate your library as it gets larger, if there is sufficient memory, so this setting is only a lower bound. See https://sqlite.org/pragma.html#pragma_cache_size for more information.",advanced:()=>!0,defaultValue:128}),dbBatchSelectSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be selected at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:1024}),dbBatchUpsertSize:new X.BoundedIntegerSetting({category:de.SettingCategories.Db,description:"How many objects can be upserted at at time? The default should be fine. (Exposed for performance tests).",advanced:()=>!0,defaultValue:32,min:1,max:128}),dbForceRecover:new Y.BooleanSetting({category:de.SettingCategories.Db,aliases:["dbForceRebuild"],transient:!0,description:"SQLite databases can sometimes be repaired with SQLite's .recover tooling. Set this to true to have PhotoStructure attempt a .recover on startup.\nThis can take a while to perform, especially on large libraries or slow computers: don't set this value to true normally.\nSee https://sqlite.org/recovery.html .",defaultValue:()=>!1}),dbBackupRemoteOnSuspend:new Y.BooleanSetting({aliases:["backupRemoteDbOnSuspend"],category:de.SettingCategories.Db,description:"Run a database backup when system suspend is requested and the database is on a remote volume.",defaultValue:()=>!0}),trySoftDeletes:new Y.BooleanSetting({category:de.SettingCategories.Auth,description:'If true, "Empty Trash" will _try_ to move files into the "Trash can" or "Recycle bin", when possible. If moving a file into the trash can fails (due to permissions or filesystem functionality), the file will be "hard" deleted (or "unlinked"). This setting defaults to false on docker.',defaultValue:()=>!!ye()||!(0,F.isDocker)()}),skipHealthCheckIds:new me.StringEnumsSetting({category:de.SettingCategories.HealthChecks,description:"List of health check IDs to skip.",defaultValue:[],strEnum:k.HealthCheckIds}),ffmpegHwaccel:new pe.StringSetting({category:de.SettingCategories.Video,description:'FFmpeg supports both software and hardware encoders. Valid values include "auto" (which should "just work" for everyone), "h264_nvenc" for GPUs, "cuda" for NVIDIA GPUs, "dxva2" or "d3d11va" for Windows, or use "disable" to omit this argument.\nRun "ffmpeg -hwaccels" to see supported acceleration methods.\nNote that some hardware acceleration is only relevant for a handful of video codecs, so what might help for one transcode may not for another.\nNote that PhotoStructure will automatically retry "disable" if there are hwaccel errors.\nSee https://forum.photostructure.com/t/hardware-accelerated-encoding-transcoding/166>, https://trac.ffmpeg.org/wiki/HWAccelIntro , and 1,min:1,max:6}),ffmpegAvcTranscodeArgs:new he.StringArraySetting({category:de.SettingCategories.Video,aliases:["ffmpegTranscodeArgs"],description:'The following are the default arguments added to transcode requests made to ffmpeg, when ffmpeg is available. The following arguments will follow "ffmpeg -loglevel error -threads T -i INPUT_FILE_PATH" (where T is replaced by ~half the available CPU threads, and INPUT_FILE_PATH is the full native pathname to the source video).\nIf your videos are in high colorspace like bt2020, you may want to remove the "-vf" and "colorspace=all=bt709:iall=bt709:itrc=srgb" options, but this may cause rendering issues on SDR displays. See https://forum.photostructure.com/t/1003/3 for more details.\nCAUTION: this is an advanced setting. Invalid values may cause videos that require transcoding to not be imported, or not be viewable on some browsers.',defaultValue:["-c:a","aac","-c:v","libx264","-pix_fmt","yuv420p","-vf","colorspace=all=bt2020:iall=bt601-6-625:fast=1","-color_range","1","-colorspace","1","-color_primaries","1","-movflags","+faststart"]}),transcodeMaxDim:new se.IntegerSetting({category:de.SettingCategories.Video,description:"If a video that needs transcoding exceeds this setting's value, the transcoded version will be downsampled such that the long side will equal this setting. A value of 1920 is good for 1080p, and 1280 would transcode to 720p resolution.\nSet this to 0 to disable this setting.",defaultValue:1920}),transcodeFrameRate:new ue.OptionalIntegerSetting({category:de.SettingCategories.Video,description:"If set, transcoded videos will be bounded to this framerate. Videos that are lower than this framerate will retain their original (lower) framerate.\nNote that framerate reduction does not reduce the final transcoded video size linearly: it may only reduce file sizes by ~20% to go from 60 FPS to 30 FPS.\nUnset this or set to 0 to disable bounded framerates.",exampleValue:()=>30}),transcodeVideos:new Y.BooleanSetting({aliases:["transcodeVideo"],category:de.SettingCategories.Video,description:"Should videos that are not in a browser-supported format be transcoded during import? Note that this is a plus-only feature. FFmpeg must be installed. Note that this *dramatically* slows down imports, and *dramatically* increases the disk space your library will need to use, but allows you to see videos that aren't directly supported by your browser. If this is set to false, your browser will only render videos directly supported by your OS.",defaultValue:!0}),transcodeBitrateQVGA:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode QVGA (320 × 240) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:800}),transcodeBitrateUHD:new se.IntegerSetting({category:de.SettingCategories.Video,description:"What max bitrate should PhotoStructure encode UHD (3840 × 2160) videos? Videos with resolutions between QVGA and UHD will use an interpolated value between these two settings, and will not exceed the encoded bitrate of the original video. This value is in kilobytes per second.",defaultValue:18e3}),doNotTranscodeMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following MIME types.\nSee https://www.iana.org/assignments/media-types/media-types.xhtml#video for a complete list.\nIf you are setting this via an environment variable, you can separate the values either like a PATH (like "video/quicktime:video/mp4") or use JSON encoding (like "[\'video/quicktime\',\'video/mp4\']").',defaultValue:()=>["video/quicktime","video/mp4","video/mpv","video/mp2t"]}),doNotTranscodeVideoCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following video codecs. The video codec may be stored in the "VideoCodec", "CompressorID", or "CompressorName" tags.',defaultValue:()=>["avc1"]}),doNotTranscodeAudioCodecs:new he.StringArraySetting({category:de.SettingCategories.Video,description:'Videos are transcoded when the "transcodeVideos" is set to true and is not one of the following audio codecs. The audio codec is stored in the "AudioCodec" tag.',defaultValue:()=>["mp4a","sowt"]}),enableSIMD:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable SIMD extensions when running image operations? This defaults to true, but automatically downgrades to false.",defaultValue:()=>!0}),enableVipsCache:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Should PhotoStructure enable VIPS caching, which may help speed up image operations? Note that this increases memory usage, and cache hit rates are low.",defaultValue:()=>!1}),showFileInFolderUsesThunar:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:'If we\'re on Linux, should we use Thunar (via dbus) to "show file in folder"?',defaultValue:!1}),showFileInFolderUsesFileUri:new Y.BooleanSetting({category:de.SettingCategories.Tools,description:"Does the showFileInFolderCommand expect a file: URI to the file? If this is false, the native path will be appended instead.",exampleValue:()=>!0,defaultValue:()=>A.isLinux}),showFileInFolderCommand:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'If set, the first argument will be used as a command (or path to command), and the subsequent arguments (if present) will be used as arguments. The native path to the file or the file: URI will be appended, based on the value given to the "showFileInFolderUsesFileUri" setting. If this is set to an empty array, the default tool for your platform will be used instead: "nautilus -s" on linux, "open -R" on mac, and "explorer /select" on Windows.\nThis is provided to support Linux desktops that don\'t use Gnome.',defaultValue:[]}),dcraw_emuPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "dcraw_emu" binary on this system. If this is set to "dcraw_emu", PhotoStructure will search your $PATH. See https://www.libraw.org/docs/Samples-LibRaw.html .',defaultValue:"dcraw_emu"}),ffmpegPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "ffmpeg" binary on this system. If this is set to "ffmpeg", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/video-support/ .',defaultValue:"ffmpeg"}),heifConvertPath:new pe.StringSetting({category:de.SettingCategories.Tools,description:'This should be the absolute, native path to the "heif-convert" binary on this system. If this is set to "heif-convert", PhotoStructure will search your $PATH. See https://photostructure.com/getting-started/heif-support/ .',defaultValue:"heif-convert"}),powerShellArgs:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'The following are the default arguments added to spin up PowerShell on Windows devices.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for all arguments that PowerShell.exe accepts.\nSee https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-5.1 for a description of Bypass.\nSee https://forum.photostructure.com/t/eliminate-powershell-profile-and-execution-policy-related-errors/184 for more details about why this needs to be configurable.\n(Versions prior to v1.0.0 only specified "-NoLogo").',defaultValue:["-NoLogo","-NoProfile","-ExecutionPolicy","Bypass"]}),powerShellCulture:new pe.StringSetting({category:de.SettingCategories.Tools,description:"If set to a non-blank value, PhotoStructure on Windows machines will set PowerShell's `[System.Threading.Thread]::CurrentThread.CurrentCulture` to this value. This allows PhotoStructure to parse PowerShell output reliably.",defaultValue:()=>"en-US"}),powerShellProcs:new se.IntegerSetting({category:de.SettingCategories.Tools,description:"How many PowerShell child processes may each PhotoStructure process run? Defaults to max(2, (maxCpus() / 4)).",defaultValue:()=>2}),toolPaths:new he.StringArraySetting({category:de.SettingCategories.Tools,description:'These paths are appended to the PATH to ensure PhotoStructure can find and run external tools like ffmpeg. Use your operating system\'s separator to separate paths (":" for mac and linux, ";" for windows).',defaultValue:()=>[]}),emitTimingsOnExit:new Y.BooleanSetting({category:de.SettingCategories.Performance,transient:!0,description:"If true, PhotoStructure will emit a JSON payload containing function performance information including timings to stdout on exit.",defaultValue:!1}),autoHideMenuBar:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops on Windows and Linux will auto hide the menu bar unless the Alt key is pressed.",defaultValue:!1}),hideOnLaunch:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will not open the main window when launched. The tray icon will still be visible.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),pauseSyncOnBattery:new Y.BooleanSetting({category:de.SettingCategories.Desktops,description:"If true, PhotoStructure for Desktops will pause sync when the system is on battery power.\nThis setting is ignored by PhotoStructure for Server editions.",defaultValue:!1}),updateChannel:new fe.StringEnumSetting({category:de.SettingCategories.Updates,description:'TL:DR; keep this on "stable". This setting controls which builds of PhotoStructure you are eligible to update to, and on desktops, this upgrade is automated.\nPlease note that "prealpha" and "alpha" builds may not even launch, and "beta" builds have not been thoroughly tested. See https://forum.photostructure.com/t/alpha-beta-stable-and-latest-what-should-you-use/274 for details.',defaultValue:()=>"stable",strEnum:q.UpdateChannels}),autoUpdateCheck:new Y.BooleanSetting({category:de.SettingCategories.Updates,description:'While running, PhotoStructure will check periodically for updates.\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.\nSet this to "false" to disable automatic update checking.',defaultValue:!1}),allowUserAgent:new Y.BooleanSetting({category:de.SettingCategories.Privacy,description:"Can PhotoStructure include a User-Agent header that includes basic installation information when it makes external requests, like for the version update check?\nSee https://forum.photostructure.com/t/new-in-v2023-10-automated-photostructure-version-checking/1956 for details.",defaultValue:!0}),optOut:new Y.BooleanSetting({aliases:["doNotTrack"],envAliases:["DO_NOT_TRACK","DNT","GPC"],category:de.SettingCategories.Privacy,description:'If set to true, your library will not originate external network requests.\nThis is a "meta" setting that currently sets "reportErrors=false", "autoUpdateCheck=false", and "allowUserAgent=false".\nThis setting will be kept up to date with any other feature that could result in an external network request (like, for example, reverse geocoding).\nTechnically speaking, this is **not** the same as "DNT" (Do Not Track) or "GPC" (Global Privacy Control), because PhotoStructure, Inc. **never shares or sells any user telemetry or data** (so "DNT" is always _technically_ true!), but we check and respect "DO_NOT_TRACK", "DNT" and "GPC" as aliases for this setting.\nSee https://photostructure.com/legal/privacy/ for more details about PhotoStructure\'s privacy policies.',defaultValue:()=>(0,T.doNotTrack)()}),email:new ce.OptionalStringSetting({category:de.SettingCategories.Reporting,description:"If set, this email will be used for license subscriptions and added to error reports, so we can contact you to help debug the issue. It is not required. Setting a value here does not subscribe you to any marketing emails.",exampleValue:()=>"email@example.com",advanced:()=>!1}),reportErrors:new Y.BooleanSetting({category:de.SettingCategories.Reporting,description:"If true, PhotoStructure will send crash reports when it encounters errors. Crash reports may include the path to the file that caused an error, system metadata, and recent log messages.",defaultValue:!1,advanced:()=>!1}),maxErrorsPerDay:new se.IntegerSetting({category:de.SettingCategories.Reporting,description:"Set this to zero to remove all bugs in PhotoStructure.\nHUR HUR #DADJOKE\nIf your system generates more than this number of errors in the course of a day, the subsequent error reports will not be reported.",defaultValue:3}),webUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:"How many libuv threads should the web process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for more concurrent requests, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),minStreamCorrPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Web,description:'Streams (shown on the asset page) are coalesced when the dice coefficient of their contents are greater than this value. A value of 100 requires streams to match exactly. A value of ~50 allows streams with a couple differences to be considered the "same" stream.',defaultValue:()=>50,max:100,min:1}),lazyLoadExtraVh:new se.IntegerSetting({category:de.SettingCategories.Web,description:'PhotoStructure only loads photos as they come close to the viewport. This setting determines what "close to the viewport" means, and is measured in "vh" units, or percentage points of your visitor\'s browsers view height.\nThe default is 50, so approximately the next 50% of the screen will be pre-loaded before the user scrolls.\nIf you have fast hardware and fast network, you could try bumping this up to 200.\nIf you have very slow network, you might want to set this to 0.',defaultValue:50}),hiddenHomeTags:new he.StringArraySetting({category:de.SettingCategories.Web,description:'The given root tags will be omitted from the home page. (Valid values include "When", "Camera", "Lens", "Type", "Fs", and "Keyword").',defaultValue:()=>["Type"]}),openGraphTargetWidth:new se.IntegerSetting({category:de.SettingCategories.Web,description:"When generating OpenGraph header metadata, include the preview image closest to this number of pixels wide.\nSee https://forum.photostructure.com/t/image-thumbnail-in-link-preview/1950 for details.",defaultValue:800}),placeholderThumbs:new Y.BooleanSetting({category:de.SettingCategories.Web,description:"Render missing asset previews as placeholder images (only useful for customer support).",defaultValue:!1,transient:!0}),fastForwardEmptyTags:new Y.BooleanSetting({category:de.SettingCategories.Web,description:'When browsing tags in the UI, should tags that only have one child tag and no direct assets be skipped, or "fast-forwarded," over? See https://forum.photostructure.com/t/volume-id-shows-as-a-tag/754/5 for context.',defaultValue:!0}),defaultHomepagePath:new fe.StringEnumSetting({category:de.SettingCategories.Web,description:'Should the /site.webmanifest send you to "/splash", or just directly to the home page, "/tag"?\n(IMHO /splash is more fun, but it slows down getting to the home page).',strEnum:(0,h.strEnum)("/tag","/splash"),defaultValue:()=>"/tag"}),syncUvThreads:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,description:"How many libuv threads should the primary sync process be given? If unset, UV_THREADPOOL_SIZE will be used. Higher values may allow for slightly higher concurrency, but may also consume more memory and CPU and overwhelm non-SSD storage. The default is 4, which should be fine for most installations. Read more about UV_THREADPOOL_SIZE: https://nodejs.org/api/cli.html#cli_uv_threadpool_size_size.",advanced:()=>!0,defaultValue:()=>4,max:32,min:1}),syncReportsDir:new pe.StringSetting({category:de.SettingCategories.Sync,description:'Detailed reports for every sync are stored in this directory, which defaults to ".photostructure/sync-reports" within your PhotoStructure library. Absolute paths here are supported.',defaultValue:()=>".photostructure/sync-reports"}),syncReportMaxRows:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"Some software can't open large CSVs, so PhotoStructure will start a new sync report if the rows exceed this value. Excel and LibreOffice can open million-row CSVs, so that's our default.",defaultValue:()=>1e6}),syncReportRetentionCount:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many historical sync reports should be retained?\nSet to 0 to retain all sync reports.",defaultValue:()=>64}),quickSyncMode:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure disable a bunch of features to make imports faster? Note that this disables image validation, video transcoding, image hashing (required for good deduplication), metadata inference, and more efficient preview encoding. It is true by default on Raspberry Pis and false everywhere else.",defaultValue:()=>(0,N.isRaspberryPi)()}),taskTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Sync,aliases:["taskTimeoutMillis"],description:"What's the longest time it can validly take to fetch a file SHA, generate image previews for an asset, compute an image hash, or extract tags for a file?\nNote that this does not impact video transcoding timeouts.\nOn a reasonable server and disk, these tasks should take at most a handful of seconds, but the default should be sufficiently long for a RPi4 on a slow, remote disk.\nSet this to 0 to disable task timeouts.",defaultValue:()=>"2m"}),scanLibraryFirst:new Y.BooleanSetting({aliases:["syncLibraryFirst"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library before all other paths are synchronized?\nThis defaults to true if you are using automatic organization, to make sure existing files in your library are in sync with your library database. This prevents additional copies of the same SHA being copied into your library directory if you have automatic organization enabled.",defaultValue:!0}),scanLibraryLast:new Y.BooleanSetting({aliases:["syncLibraryLast"],category:de.SettingCategories.Sync,description:"Should PhotoStructure scan your library after all other paths are synchronized?",defaultValue:!1}),progressRetentionDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many days of sync progress should we keep around in the database before it's removed?",defaultValue:180}),progressStaleDays:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"When sync starts, it tries to pick up where it was previously, but this doesn't make sense if the prior work was done a while ago, as it is more likely that the filesystem has changed since.",defaultValue:6}),copyToLibraryMimeTypes:new he.StringArraySetting({category:de.SettingCategories.Sync,description:'When "automatic organization" is enabled, files whose mimetypes are included in this list will be copied into your originals directory.\nNote that MIME types can include an asterisk to do glob-matching.\nSee the related system setting "copyAssetsToLibrary".\nA list of MIME types are here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types .',defaultValue:()=>["image/*","video/*"]}),onlyNativeFileCopy:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure skip the built-in file copy code, and only use the "OS native" file copy mechanism?\nPhotoStructure is typically faster than native file copies by 2x or more.\nIf true, PhotoStructure will use "cp" on macOS and Linux, and PowerShell "Copy-Item" on Windows.',defaultValue:!1}),verifyFileCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should PhotoStructure verify all file copies by comparing SHAs of the source and destination? This shouldn't be necessary on most OSes and filesystems, and slows down library imports.",defaultValue:!0}),assetPathnameFormat:new pe.StringSetting({category:de.SettingCategories.Sync,description:'If you opt into "automatic organization" (see the setting "copyAssetsToLibrary"), they will be copied into /.\n- See the originalsDir system setting for what your is (it defaults to your library root directory).\n- Please encode this path with forward-slashes, even if you\'re on Windows.\n- If any patterns resolve to including forward-slashes, know that will be interpreted as subdirectories.\n- If you want to add a static path, escape the pathname with single quotes (like "\'photos\'/y/MM/dd").\n- The result of this will always be interpreted as a relative path from your PhotoStructure originals directory.\n- Use token "BASE" as a shorthand for the original basename ("photo.jpg" for "/path/to/photo.jpg").\n- Use token "NAME" as a shorthand for the original filename, without the file extension ("photo" for "/path/to/photo.jpg").\n- Use token "PARENT" as a shorthand for the original file\'s parent directory name ("to" for "/path/to/photo.jpg").\n- Use token "GRANDPARENT" as a shorthand for the original file\'s grandparent directory name ("path" for "/path/to/photo.jpg").\n- Use token "EXT" for the filename\'s extension without the "." prefix (like "jpg" for "/path/to/photo.jpg").\n- Use token "ISO" as a shorthand for "yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ".\n- You can escape other static text by wrapping with single quotes.\n- For other tokens, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens .\n- See https://forum.photostructure.com/t/how-to-change-the-naming-structure/1184/2?u=mrm for more details.',defaultValue:"y/y-MM-dd/BASE"}),writeSourceTagToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should PhotoStructure write to the "Source" tag add metadata to assets copied into your library that includes the path where the file was originally found? This defaults to false to prevent adding sidecars to every file in your library.',defaultValue:!1}),assetSubdirectoryDatestampFormat:new pe.StringSetting({category:de.SettingCategories.Sync,envAliases:["PS_ASSET_SUBDIR_FORMAT"],description:'This setting has been replaced by "assetPathnameFormat".\nIf this setting is provided, and assetPathnameFormat is _not_ provided, we will give assetPathnameFormat the value of this setting + "/BASE".',defaultValue:"",deprecated:!0}),startPaused:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should processing be paused by default when PhotoStructure starts? You'll have to manually resume processing via the system tray or nav menu.",defaultValue:!1}),syncCron:new ee.CronSetting({category:de.SettingCategories.Sync,description:"This is a crontab entry that defines when sync will start work.\nIf the value you provide is not a valid crontab entry, the default value will be used instead (which is to run at 2AM, nightly).\nSee https://github.com/Hexagon/croner?tab=readme-ov-file#pattern for details on what patterns are accepted (or ask for help on the forum or discord).",defaultValue:"0 2 * * *"}),syncCronTZ:new ce.OptionalStringSetting({category:de.SettingCategories.Sync,description:'The system timezone will be used to interpret "syncCron", unless this setting is specified. This must be an IANA time zone, like "America/Los_Angeles" or "Europe/Stockholm". See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list.'}),forceRebuildLibrary:new Y.BooleanSetting({category:de.SettingCategories.Sync,aliases:["rebuild"],description:"When set, all files in your library will be re-imported (caution: slow!).",defaultValue:!1,transient:!0}),forceSync:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files will be visited, even if the asset seems in sync with the filesystem.",defaultValue:!1,transient:!0}),forceFilters:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, all files filters will be applied to visited files. If this is false, files already in the library database will be assumed to be validly passing all import filters. This is set to true by default when rebuilding libraries.",defaultValue:!1,transient:!0}),forceRebuildPreviews:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, previews and transcoded videos will always be rebuilt.",defaultValue:!1,transient:!0}),skipLibraryRebuild:new Y.BooleanSetting({aliases:["noModelUpdates"],category:de.SettingCategories.Sync,description:"When set, skip any pending library database updates (only used for tests).",defaultValue:!1,transient:!0}),exitWhenDone:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"When set, the sync process will exit after jobs are completed (used internally and for tests).",defaultValue:!1,transient:!0}),overwriteOriginal:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:'Should changes made through the UI, like rotations, captions, and keywords, overwrite the original file? This is potentially dangerous, as your original may be lost if the disk has errors, or there are issues in rewriting the file contents. If this is set to false, the original file will be retained in the same directory. "image.jpg" will be stored as "image_original.jpg".',defaultValue:!1}),maxDuplicatePathElements:new se.IntegerSetting({category:de.SettingCategories.Sync,description:"How many times can a given path element exist in a directory before it is considered within an infinite filesystem loop, and should be skipped from import?",defaultValue:7}),resyncAssetOnVisit:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should Assets be automatically re-synchronized whenever their info panel is viewed? This can make sure Assets are in-sync with the filesystem, but this can slow down current imports, and add load to slower computers. This defaults to true only if the current machine has >= 8 CPUs.",defaultValue:()=>!!ye()||(0,J.cpuCount)()>=8}),excludeNoMediaAssetsOnRebuild:new Y.BooleanSetting({category:de.SettingCategories.Sync,description:"Should previously-imported assets that are found to have *any* files in NoMedia directories be excluded from your library?",defaultValue:()=>!0}),taskListCap:new X.BoundedIntegerSetting({category:de.SettingCategories.Sync,aliases:["workQueueHighWater"],description:"Whenever PhotoStructure is scheduling work, the task scheduler will pause producing tasks if the current task list has more than this number of items already scheduled. For example, when PhotoStructure is syncing a directory, the first step is to walk the directory and search for files to import. When the list of files scheduled to process is larger than this value, sync will pause looking for additional files to process.\nThis backpressure should help import directories that contain very large numbers of files. Note that until the last batch of work is scheduled, ETAs will be inaccurate.",defaultValue:1024,min:64,max:65536}),matchSidecarsCaseInsensitively:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match file basenames (with or without the file extension), regardless of case (for example: "IMAGE.XMP" will be a sidecar for "image.jpg").\nIf set to false, sidecars must match case (so only "image.jpg.xmp" and "image.xmp" will match for "image.jpg").',defaultValue:!0}),matchSidecarsFuzzily:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:'If set to true, PhotoStructure will look for sidecar files that match the basename of the asset, plus some common suffixes (like "-edit", "-edited", or variant copies, like "-2").\nThis setting only impacts .XMP, .MIE, and .EXIF sidecars.\nNote that PhotoStructure always matches .JSON files fuzzily, as that is required to handle Google Takeouts properly.',defaultValue:!1}),defaultSidecarType:new fe.StringEnumSetting({category:de.SettingCategories.Sidecars,description:'What type of sidecar file do you want to generate for non-destructive edits?\n- "XMP" is a popular and well-adopted format.\n-"MIE" is defined at https://exiftool.org/TagNames/MIE.html .\n- "EXIF" and "EXV" should only be used if required, as they have substantial limitations.\nCase is preserved.',strEnum:D.SidecarExts,defaultValue:D.SidecarExts.xmp}),writeMetadataToSidecarsIfImage:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to images into sidecars. If set to false, PhotoStructure will overwrite original images with metadata changes.",defaultValue:!0}),sidecarTagBlocklist:new he.StringArraySetting({category:de.SettingCategories.Sidecars,description:"Many applications don't read metadata from sidecars, which can make some tags, like Orientation, Rotation, or Rating, not seem to work properly in other applications. This setting is ignored if writeMetadataToSidecarsIfImage, writeMetadataToSidecarsIfVideo, and writeMetadataToSidecarsIfSidecarExists are all set to false.",defaultValue:()=>["Orientation","Rotation","Rating"]}),writeMetadataToSidecarsIfVideo:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes made to videos into sidecars. If set to false, PhotoStructure will overwrite original videos with metadata changes. This defaults to false, as most software does not use sidecars except for images.",defaultValue:!1}),writeMetadataToSidecarsIfSidecarExists:new Y.BooleanSetting({category:de.SettingCategories.Sidecars,description:"If set to true, PhotoStructure will write metadata changes into sidecars if the file already has a sidecar and the tag is not in the sidecarTagBlocklist.",defaultValue:!0}),strictDeduping:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'How strict should PhotoStructure de-duplicate files? If this is false, we consider files to be equivalent if sufficient metadata matches (even if the image hash is different). If this is true, we will always compare image hashes. NOTE: This will most likely cause RAW and JPEG pairs to not always merge to the same asset, especially if your camera uses extensive computational imagery. ALSO NOTE: If this is true, "useImageHashes" will be forced to true, and the "*corr*" and "*coeffPct" settings will be set to 95.',defaultValue:!1}),assetAggregation:new fe.StringEnumSetting({category:de.SettingCategories.Deduping,description:'How should assets be aggregated?\n- "union" will allow asset file variants to join an asset if they match *any* existing variant.\n- "intersection" will only allow asset file variants to join an asset if they match *all* existing variants.\nVersions prior to 2.1 defaulted to "union" behavior.',defaultValue:K.AggregateTypes.intersection,strEnum:K.AggregateTypes}),useImageHashes:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:"Building image hashes slows down imports, but supports more robust asset merging heuristics, and allows for dominant color tagging and browsing. If you set this from false to true, and you'd previously imported new assets, you may want to rebuild your library to re-aggregate your assets.",defaultValue:!0}),checkBasenameMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'Most cameras take JPG/RAW pairs with matching basenames (so "P01234" for "P01234.JPG"). When PhotoStructure is trying to find matching assets for a given file, may it check assets that have matching basename file variants?\nNote that image hash and other asset file comparisons will still be performed before determining a given asset is a match.',defaultValue:!0}),allowFuzzyDateImageHashMatches:new Y.BooleanSetting({category:de.SettingCategories.Deduping,description:'For images that don\'t have a reliable precise captured-at time (say, from "stat" or datestamp from pathname), can we aggregate assets purely by exact image hash matches?\nSee https://forum.photostructure.com/t/deduplicate-shenanigans/1732/11 for more details.',defaultValue:!1}),minMatchesWithoutImageHashes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If "useImageHashes" is true, this is ignored. This is a "backstop" that allows files to be aggregated together if their metadata is equal "enough." As of Sept 2022, there are 5 metadata classes to match: "cameraId", "lensId", "imageId", "exposureSettings", and "geohash". All of these "classes" pull from several individual tags. Note that if any of these classes _don\'t_ match, the files will always be considered to be from different assets.',defaultValue:3}),maxContemporaryAdoptionAssets:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'To handle photos and videos with "fuzzy" captured-at times (those that are missing second, minute, hour, or even day resolution), how many previously-imported assets with nearby captured-at times should PhotoStructure look for in your library to find an adoption candidate?\nMonitor the "sync.AssetFileFinder.assetByCapturedAtOrImageHash" timer to see how long adoption is taking on your machine.\nHigher values will slow down imports, but may result in more accurate de-duplication results.',defaultValue:512}),datesBeforeAreEstimated:new pe.StringSetting({category:de.SettingCategories.Deduping,description:'PhotoStructure automatically interprets captured-at timestamps before this ISO-formatted datestamp as "estimated." PhotoStructure also considers timestamps whose minutes, seconds, and milliseconds are all 0 as "estimated."\nWhen assets have an estimated captured-at time, tighter image correlation is required to prevent different images as being incorrectly aggregated into the same asset.\nThe default value is the release date for the Nikon Coolpix 950, which was one of the first prosumer digital cameras with ~2MP resolution.',defaultValue:"1999-02-15"}),minExposureSettingsCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This is the minimum similarity coefficient between exposure setting values two images must be to be considered equivalent. Many cameras actually report different exposure setting values between JPG and RAW: values within 90% of each other should avoid false-positives.",defaultValue:()=>90,max:100,min:0}),minImageCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting controls how aggressively images are merged with each other, and is the minimum image hash similarity coefficient for images to be considered equivalent when their date is accurate, their mimetypes match, and are in color.\nThis value is applied when the captured-at date has a non-zero minute, second, or millisecond, and was captured after "datesBeforeAreEstimated," so the timestamp is considered to have high precision.\n100 (or 100%) requires exact image correlation is not recommended due to causing false negative matches.\nA value of less than 50% is fairly low image correlation, and can lead to false positive matches.',defaultValue:()=>70,max:100,min:0}),imageHashFuzzyDateDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when captured-at dates have low precision. It defaults to a positive value so we are more strict about merging images with inaccurate dates. Set to 0 to disable this delta.',defaultValue:()=>12,max:100,min:-100}),imageHashDifferentMimetypesDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'This setting\'s value is added to "minImageCoeffPct" and "minColorCoeffPct" when file mimetypes don\'t match. It defaults to a negative value because RAW and JPEG formats frequently raster slightly different image hashes, requiring a more lax threshold to match JPG+RAW pairs. Set to 0 to disable this delta.',defaultValue:()=>-15,max:100,min:-100}),imageHashGreyscaleDelta:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"This setting's value is added to \"minImageCoeffPct\" when either image is essentially greyscale. It defaults to a positive value so we are more strict about merging greyscale images. We also don't have color correlation to help us, so a more strict threshold is warranted.",defaultValue:()=>10,max:100,min:-100}),minColorCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:"Given two sets of dominant colors, this is the average percent that those sets correlate with eachother. A higher number requires stronger dominant color correlation. 100 (or 100%) requires exact dominant color correlation. A value of less than 50% indicates fairly low correlation of dominant colors, and can lead to false positives.",defaultValue:()=>73,max:100,min:0}),greyscaleColorThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Deduping,description:'Many "black and white" images, which scanned, actually include color information, especially if the source has yellowed with age. PhotoStructure determines if an image is "greyscale" if the standard deviation of a* plus the standard deviation of b* values is less than this value. By only looking at standard deviation, we can categorize sepia photos as "greyscale." Smaller values are stricter.',defaultValue:3,max:128,min:0}),gpsErrorMeters:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"What's the maximum number of meters between GPS fixpoints that should be considered equivalent locations? Note that JPG+RAW pairs from smartphones frequently have different GPS locations due to one being recorded from a rough WiFi fix, and another from aGPS.\nGPS position error is ~10-100m. Cellular position error is ~500-750m.",defaultValue:500}),minCapturedAtPrecisionDifferentMimetypes:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:"Some cameras store JPEG+RAW pairs with slightly different captured-at times (!!). To ensure these are merged properly, we need to allow for these discrepancies. This setting controls how many milliseconds of difference we allow between captured-at times for different mimetypes. Set to 0 to disable this feature.",defaultValue:()=>1500}),minCapturedAtPrecisionStat:new se.IntegerSetting({category:de.SettingCategories.Deduping,description:'If a captured-at time is low quality (using the mtime or birthtime of the file), what should PhotoStructure use as the "minimum" precision for that time? This is used to determine how much "fuzziness" to allow when comparing captured-at times during assert aggregation. Set to 0 to disable this feature.',defaultValue:()=>u.minuteMs}),fuzzyDatePrecisionCoeff:new ne.FloatSetting({category:de.SettingCategories.Deduping,description:'When comparing "captured-at" dates that aren\'t from reliable metadata tags, what coefficient should be applied to the inferred precision of those dates? Larger values will mean PhotoStructure will consider these "fuzzy" dates to be less precise, and expand the date range when searching for matching assets. Set to 1 to disable this feature.',defaultValue:2}),dominantColorPixels:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modePixels"],description:"PhotoStructure downsamples images to contain this number of pixels, converts each pixel into CIELAB space, and then runs k-means clustering to extract dominant colors. Larger values will be slower to process, but will result in more accurate dominant colors. Smaller values will be faster, but may result in inaccurate dominant colors.",defaultValue:re.DominantColorPixelsDefault,max:4096,min:256}),dominantColorDeltaE:new fe.StringEnumSetting({aliases:["delta_e"],category:de.SettingCategories.Color,description:"What delta_e algorithm should PhotoStructure use to determine color differences? cie76 is quick but inaccurate. cie94 is more accurate than cie76 but 6x more computationally expensive than cie76. ciede2000 is best, but 4-6x more expensive than cie94.",defaultValue:Q.ColorDistanceFunctions.ciede2000,strEnum:Q.ColorDistanceFunctions}),dominantColorKmeansRuns:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeRuns"],description:'PhotoStructure uses k-means clustering to extract dominant colors from your images.\nLarger values will allow PhotoStructure to run k-means with more random seeds and different pre-merged k values, which should result in higher quality results.\nUsing 0 will revert to posterizing the image and using the top-n colors, which is fast and deterministic, but has lower quality results.\nChanging this value will subtly change many image\'s dominant color lists.\nThis defaults to 0 run when "quickSyncMode" is enabled.',defaultValue:te.DominantColorKmeansRunsDefault,max:64,min:0}),dominantColorMergeThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,description:"The best dominant color cluster centroids may be quite similar. PhotoStructure will merge centroids if their Δe is less than this value. Larger values will result in more different dominant colors, but those may not be as accurate.",defaultValue:10,max:32,min:0}),dominantColorGreyThreshold:new X.BoundedIntegerSetting({category:de.SettingCategories.Color,aliases:["modeGrey"],description:'May PhotoStructure ignore pixels that are greyscale, or "desaturated," when looking for dominant colors? Larger values will result in only saturated colors being considered for dominant colors. A pixel color will be removed if its absolute a* and b* values in CIELAB space sum to less than this value.\nSet this to 0 to include greys in dominant colors, but note that this tends to reduce image deduplication effectiveness, as most natural-tone images contain a good deal of greyscales, which results in false matches.',defaultValue:11,max:80,min:0}),previewQuality:new X.BoundedIntegerSetting({aliases:["jpegQuality"],category:de.SettingCategories.Previews,description:"JPEG output quality for previews. Smaller values produce smaller images with lower quality. The default value of 80 strikes a balance that has almost no noticeable compression artifacts, yet still compresses images reasonably well. Depending on image content, values less than 50-70 can produce noticeable artifacts.",defaultValue:()=>80,max:100,min:10}),previewProgressive:new Y.BooleanSetting({category:de.SettingCategories.Previews,aliases:["progressive","jpegProgressive"],description:"Should preview JPEGs be progressively encoded? If set, thumbnails will take ~15% longer to generate, but FHD/QHD/UHD previews will be smaller.",defaultValue:!0}),previewMinimized:new Y.BooleanSetting({aliases:["jpegMinimized"],category:de.SettingCategories.Previews,description:'Should preview JPEGs be optimized? If set, preview generation can take 50% longer, but can result in up to ~30% smaller images. This saves disk space and network transport time.\nThis setting controls the "mozjpeg" option: see https://sharp.pixelplumbing.com/api-output#jpeg for details.\nThis automatically defaults to true if at least 4 CPU cores are present.',defaultValue:()=>!!ye()||(0,J.cpuCount)()>=4}),dcrawEmuArgs:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'What options do you want to pass to dcraw_emu? Note that "-T -o 1 -j -Z -" will always be added (as we need TIFF, sRGB, raw pixels send to stdout). The "-h" arg will be added if the preview image needed is less than half the resolution of the original.\nRun "dcraw_emu" with no arguments to get usage help.\n"-q 1" sets interpolation quality to "0".\n"-H 2" turns on highlight blending.\n"-w" uses the camera-set white balance.\nNote: changing these values can dramatically (> 10x!) increase the time it takes to render RAW images.',defaultValue:["-q","0","-w"]}),iccProfileMappings:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'Maps an original image profile to a filename stored in the "icc" directory. See that directory\'s _info.md for more information about this settings.',defaultValue:["Display P3:DisplayP3Compat-v2-magic.icc","Adobe RGB:AdobeCompat-v2.icc"]}),squareThumbStrategy:new fe.StringEnumSetting({category:de.SettingCategories.Previews,description:'When PhotoStructure crops images and videos to square thumbnails, it needs to crop non-square images to a square. The default, "attention," focuses on faces and higher image energy, but is more expensive than simply cropping to the center of the image (which is faster, but will mean less-nice cropping, where faces are chopped in half). More details are available here: https://sharp.pixelplumbing.com/api-resize .',defaultValue:O.CropStrategies.attention,strEnum:O.CropStrategies}),videoFrameAtSec:new ne.FloatSetting({category:de.SettingCategories.Previews,description:"When capturing a frame from videos for thumbnails, how many seconds should be passed over before capturing a frame? A value of 0 means capture from the start of the video. Frequently, though, videos start out of focus, so we default to 1.5 for better frame clarity.\nNote that if a video is shorter than this value, the frame will be captured from the middle of the video.",defaultValue:1.5}),previewSharpen:new Y.BooleanSetting({aliases:["sharpen"],category:de.SettingCategories.Previews,description:'Should previews be sharpened? This can make the images "pop" a bit more, but almost doubles the time it takes to make the thumbnails.',defaultValue:!1}),previewResolutions:new me.StringEnumsSetting({category:de.SettingCategories.Previews,description:"This controls the resolutions that PhotoStructure creates for every asset. Note that resolutions will be skipped if there already is a preview value with <= 2.5x pixel count, so even though there are a lot of sizes here, you'll only see 3-4 images on your disk per asset.\nSee https://en.wikipedia.org/wiki/Graphics_display_resolution for a description of these resolution codes.",defaultValue:(0,o.diff)(c.FitSizes.values,["uhd8k","uhd5k"]),strEnum:c.FitSizes}),embeddedPreviews:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"For larger source images that are greater than 15MP, what embedded image preview tags should be used when present? Using these embedded images speeds up image preview generation, but if the embedded image doesn't match the full-sized image, the image preview will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["PreviewImage","PreviewTIFF","JpgFromRaw","JpgFromRaw2"]}),embeddedThumbnails:new he.StringArraySetting({category:de.SettingCategories.Previews,description:"Should embedded image thumbnails be used when available? This speeds up image hashing, but if the embedded image thumbnail doesn't match the full-sized image, the image hash will be incorrect.\nSet this to an empty array to disable using embedded previews.",defaultValue:["ThumbnailImage","ThumbnailTIFF"]}),maxEmbeddedBuffer:new se.IntegerSetting({category:de.SettingCategories.Previews,description:`PhotoStructure tries to use embedded images for preview generation to minimize work. For smaller images, we can directly pipe the buffer from the embedded image into our image pipeline, but for larger images, it can be faster to use an intermediary file stored on the cache drive. Larger values will reduce disk I/O but increase memory and CPU consumption. Set this to 0 to force all previews to be written to the cache dir.\nThis defaults to ${(0,f.fmtBytes)(4*t.DefaultMaxEmbeddedBuffer)} on Windows due to slow disk I/O on that platform.`,defaultValue:()=>(A.isWin?4:1)*t.DefaultMaxEmbeddedBuffer}),skipPreviews:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:"Only used for tests.",advanced:()=>!0,defaultValue:!1}),variantSortCriteria:new me.StringEnumsSetting({category:de.SettingCategories.Previews,aliases:["assetFileSortCriteria"],description:'How should PhotoStructure pick the "best" asset file variant for a given asset?\nDetails about these fields are here: https://photostructure.com/faq/what-do-you-mean-by-dedupe/#variantSortCriteria .',strEnum:$.AssetFileSortCriteria}),variantSortCriteriaPower:new Z.BoundedFloatSetting({category:de.SettingCategories.Previews,description:'Variant sort criteria "resolution" and "fileSize" are scaled down to ignore irrelevant differences. Scalars are raised to this power to reduce them, so a value of 1 means the criterion is unchanged from the "raw" value. Smaller values for this setting let _larger_ differences be ignored.',defaultValue:()=>1/6,max:1,min:1e-6}),includePreviewTags:new Y.BooleanSetting({category:de.SettingCategories.Previews,description:'By default, PhotoStructure strips all metadata from preview images. This both saves space, and reduces disk I/O during preview generation. If this setting is enabled, all "includedPreviewTags" will be restored in preview images that are more than 1 megapixel. If this setting is enabled, each preview image will be written to twice (once for the image and once for the metadata), so imports will be slower.',defaultValue:!1}),includedPreviewTags:new he.StringArraySetting({category:de.SettingCategories.Previews,description:'If "includePreviewTags" is true, what tags should PhotoStructure retain when building preview images? A partial list of tags is here: https://photostructure.github.io/exiftool-vendored.js/interfaces/Tags.html . Note that not all files contain all (or even some!) of those tags.\n- "capturedAt" is a special meta-tag which will retain whatever tag contains the "best" time that PhotoStructure could find that encoded the date and time when the image was captured, and will store that value in DateTimeOriginal.\n- "exposureSettings" is a special meta-tag that will retain shutter time (ExposureTime), aperture (FNumber), and ISO (ISOSpeed) metadata (but may be encoded with different values).\n- including "GPSLatitude" and "GPSLongitude" will mean previews will contain location metadata if the source image had location metadata.',defaultValue:()=>j.DefaultIncludedPreviewTags}),disableAllFilters:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Setting this to true will force all other filter settings to their most permissive value. Note that this also disables file validation tests and the file SHA blocklist, so corrupt files and previously removed files will be attempted to be imported as well.\nIf you have to resort to using this setting, please consider hopping onto the PhotoStructure Forum or PhotoStructure Discord and describe your situation.",defaultValue:!1}),excludeGlobsAdd:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"This setting adds glob patterns for files and directories that should be excluded from your library.\nThese patterns will be added to PhotoStructure's default set of (several hundred!) exclusion globs.\nSee https://forum.photostructure.com/t/1458 for details.",exampleValue:()=>["**/tmp/"],defaultValue:()=>[]}),excludeGlobsOmitDefaults:new Y.BooleanSetting({aliases:["omitDefaultExcludeGlobs","disableIgnorableFilters"],category:de.SettingCategories.Filters,description:'Setting this to true will omit ALL default exclusion globs, and is equivalent to providing all default exclusion globs to the "excludeGlobsOmit" setting. You\'re then free to add whatever exclusion globs you want, using the "excludeGlobsAdd" setting.',defaultValue:!1}),excludeGlobsOmit:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'PhotoStructure has several hundred default "exclusion globs" to avoid scanning system and application directories and otherwise irrelevant directories and files.\nIf you don\'t like one or two of them, add them here, and they will be removed from the excluded globs list.\nIf you don\'t want ANY of the default exclusion globs, see "excludeGlobsOmitDefaults".\nSee https://forum.photostructure.com/t/1458 for details.',defaultValue:()=>[]}),globsCaseInsensitive:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should "globs" match case-insensitively?',defaultValue:!0}),excludeHidden:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'PhotoStructure may check for filesystem "hidden" metadata flags on macOS and Windows filesystems, and automatically skip importing those files.\nAs of v2023, this defaults to "false", as most people don\'t use this filesystem feature, and it\'s expensive for PhotoStructure to check for this flag on every file it imports.\nThis setting is ignored on Linux systems.',defaultValue:!1}),respectFileExtensions:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Normally PhotoStructure uses file extensions (like .JPEG or .MP4) to perform initial file filtering, rather than examining the content of the file to determine the file format (or "mimetype"). If you have files that don\'t use valid file extensions, you can set this to false, but know that file imports will be slower.',defaultValue:!0}),requireMakeModel:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"PhotoStructure can require images to have EXIF tags for Make and Model. This prevents unwanted preview images from other photo apps and screenshots from being imported. If you have images you want in your library that don't have these tags, set this to false. Note that this is ignored for video files, as those files seldom have Make and Model set (and would prevent most video files from being imported).",defaultValue:!1}),rejectRatingsLessThan:new se.IntegerSetting({category:de.SettingCategories.Filters,description:'Files with a metadata rating that is less than this value will not be imported into your library. Set to -100 to disable this filter.\nNote: if you change this value, be sure to recount tag asset counts by clicking the "perform maintenance" button on the health check page.',defaultValue:0}),keywordBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"Any asset that contains any of these keywords will be excluded from your library. Set this to an empty array to disable this feature.",defaultValue:["private"]}),minImageDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels an image's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the image. The default comes from the VGA standard of 640x480. If this is set to 0, no minimum resolution filter will be applied to photos.",defaultValue:480}),minVideoDimension:new se.IntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of pixels a video's dimensions must meet or exceed to be imported? Note that this value is applied to both the height and width of the video. The default comes from the QVGA standard of 320x240. If this is set to 0, no minimum resolution filter will be applied to videos.",defaultValue:240}),minVideoDurationSec:new le.OptionalFloatSetting({category:de.SettingCategories.Filters,description:"What's the minimum number of seconds for a video to be imported? If this is set to 0 or unset, no minimum duration limit will be applied.",defaultValue:2}),maxVideoDurationSec:new ue.OptionalIntegerSetting({category:de.SettingCategories.Filters,description:"What's the maximum length a video can be and still be imported? If this is set to 0 or unset, no maximum duration limit will be applied."}),minAssetFileSizeBytes:new se.IntegerSetting({aliases:["minAssetSizeBytes","minAssetSize","minFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the minimum photo or video size you want imported into your library?\nThis setting can prevent small GIFs and screenshots from being imported.\nValues less than 1000 will be ignored.\nA 20-year-old 1600x1200 JPEG at 50% quality is more than 150k, so 50k is a very conservative default.",defaultValue:50*f.KB}),maxAssetFileSizeBytes:new se.IntegerSetting({aliases:["maxAssetSizeBytes","maxAssetSize","maxFileSizeBytes"],category:de.SettingCategories.Filters,description:"What's the maximum photo or video size you want imported into your library? (This can prevent movies from being pulled into and filling up your library). A value of 0 will disable this filter.",defaultValue:.5*f.GB}),validateJpegImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should JPEG photos be validated before importing? If a JPEG has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports.",defaultValue:!0}),imageFailOn:new fe.StringEnumSetting({category:de.SettingCategories.Filters,description:'How sensitive should PhotoStructure be with warnings or errors when loading images?\nUse "none" to try loading images with best efforts, even if the file may be corrupt.\nUse "warning" to be conservative--any defects in the image will prevent it from being imported. \nThe default, "truncated," will allow images with minor encoding defects to be imported.',defaultValue:I.SharpFailOns.truncated,strEnum:I.SharpFailOns}),validateRawImages:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:"Should raw-format images (like NEF, CR2, ARW, and ORF) be validated before importing? If an image has any decoding errors, and this setting is true, that file will not be imported into your library.\nNote that more recent cameras may use a raw encoding that isn't supported yet (like CR3), but PhotoStructure may still be able to import those files if full-resolution embedded images are present, so this defaults to false.\nEnabling this feature slows down imports.",defaultValue:!1}),validateMimetypeSkiplist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:"If a file's mimetype matches any of these values, it will be imported without being validated. This is useful for files from cameras that may render RAW image formats that are not supported by LibRaw (yet). Note that this setting is case-insensitive.",defaultValue:()=>["image/x-panasonic-rw2"]}),validateVideos:new Y.BooleanSetting({category:de.SettingCategories.Filters,description:'Should videos be validated before importing? If a video has any decoding errors, and this setting is true, that file will not be imported into your library. Enabling this feature slows down imports, as videos must be fully decoded (or "played") to be validated.',defaultValue:()=>!1}),validationErrorBlocklist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'If any of the following patterns match a validation error found in a photo or video, and *doesn\'t* match any of the patterns in the validationErrorAllowlist, the file will be considered corrupt and not be imported into your library.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message, so, for example, a value of "caution" will ignore any error message that contains the string (not the word!) "caution".\nAlso see "validationErrorAllowlist".',defaultValue:()=>["cannot decode","cannot determine format of input stream","corrupt","error while decoding","failed","invalid","not a jpeg file","not raw file","nothing was written into output file","partial file","premature end of .*?file","unsupported file format"]}),validationErrorAllowlist:new he.StringArraySetting({category:de.SettingCategories.Filters,description:'All validation errors that match any of these values they will be ignored, EVEN IF they match a "validationErrorBlocklist" pattern, so all of these patterns should be specific enough to not cause false-negatives.\nNote the patterns are case-insensitive, will be converted into a regular expression, and only need to partially match the error message.\nAlso see "validationErrorBlocklist".',defaultValue:()=>["warning: ignored non-standard exif","invalid SOS parameters for sequential jpeg","referenced qt chapter track not found","non monotonically increasing dts"]}),capturedAtTags:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'The following tags are examined to determine when a file was captured at.\nThe tag with the oldest valid value is returned: order here doesn\'t matter.\nIf none of these tags have a valid datetime stamp, PhotoStructure will fall back to "capturedAtTagsFallback" tags.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.DefaultCapturedAtTagsConst}),useMWG:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Enable Metadata Working Group composite tag reading and writing. See https://exiftool.org/TagNames/MWG.html for details.",defaultValue:!0}),capturedAtTagsFallback:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'If none of the "capturedAtTags" have a valid value, PhotoStructure will fallback to look at these tags. These tags are only "fallbacks" as they sometimes contain spurious values.\nSee https://photostructure.com/faq/captured-at/ for details.',defaultValue:R.ProblematicCapturedAtTags}),badDates:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"The following ISO values will be ignored when extracting a file's captured-at time. See https://forum.photostructure.com/t/photostructure-ignored-the-date-metadata-of-some-photos-marked-them-as-taken-in-2002/340/8 and https://forum.photostructure.com/t/incorrect-date-assigned-to-photo/419 .",defaultValue:()=>["2002-12-08T12:00:00"]}),defaultVideosToUTC:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should video created-at times be assumed to be in UTC? Most cameras use UTC (even if the timezone is set in the camera!). Set this to false to revert to pre-v2.1 behavior.",defaultValue:()=>!0}),defaultCopyright:new ce.OptionalStringSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure doesn't find a value for Copyright in a source image or source video, it will apply the given string as the copyright holder.\nThis has no default."}),likeRating:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'What\'s the minimum "rating" for an asset to be considered "liked"?\nKnow that metadata "ratings" are stored in both EXIF and XMP "Rating" and "RatingPercent" tags. Ratings are typically encoded as a value between -1 and 5 (where -1 is used by some DAMs to mark "rejected").\nPhotoStructure will prefer the XMP Rating tag.\nIf the only tag with a rating is a "RatingPercent", it will be converted to a 5-point scale.\nIf you want only ratings of 5 to be considered a "liked" asset, set this to 5.\nThis value will be used when assets are liked via the PhotoStructure UI.\nNote that PhotoStructure doesn\'t import assets with a negative Rating (to respect the "rejected" rating).',defaultValue:()=>3}),lensMakes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:"Used to extract and parse lens metadata (useful when Google Takeout has stripped metadata).",defaultValue:()=>B.DefaultLensMakes}),extraDateTimeFormats:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These formats are used to parse datetime strings in EXIF metadata and in file pathnames. Note that we will try each format with each value from "extraDateTimeZoneSuffixes," and once without a timezone suffix. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultDateTimeFormats}),extraDateTimeZoneSuffixes:new he.StringArraySetting({category:de.SettingCategories.Parsing,description:'These timezone formats are appended to each "extraDateTimeFormats" template to try to capture the timezone offset. Note that ZZZZ and ZZZZZ are not supported for parsing. See https://moment.github.io/luxon/#/formatting?id=table-of-tokens for a description of these tokens.',defaultValue:()=>b.DefaultTimezoneSuffixes}),fuzzyDateParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will first attempt to parse datetime strings with strict ISO-compliant parsers, and then use additional, "fuzzy" datetime parsers. When disabled, only ISO-compliant parsers are used.',defaultValue:!0}),fuzzyYearParsing:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, PhotoStructure will use directories starting with a number that looks year-like (four digits, 1826-the present) to infer the captured-at time, if all other date parsers have failed. Note that setting this to true "forces" the "fuzzyDateParsing" setting to be true.\nTo elaborate: PhotoStructure first looks for metadata with a date, then looks for an ISO-compliant YMD timestamp in the filename or path, and then, if "fuzzyDateParsing" or this setting is enabled, a YMD or YM datestamp, and then finally, if this setting is enabled, it looks for a directory that begins with a number that is between 1826-2020.',defaultValue:!1}),twoDigitCutoffYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:'If "yy" is used in extraDateTimeFormats, and a year is only 2 digits, what threshold value should be used to consider the date to be in the 1900s vs 2000s?\nAs an example, a value of "50" would make "49" be interpreted as 1949, and "50" as 2050.\nSee https://moment.github.io/luxon/api-docs/index.html#settingstwodigitcutoffyear for details.\nThis defaults to 3 years in the future (modulus 100) and is updated automatically.',defaultValue:()=>((new Date).getFullYear()+3)%100}),minValidYear:new se.IntegerSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is less than this value, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nFor what it's worth, 1826 is the first year a photograph was captured (see https://en.wikipedia.org/wiki/History_of_photography ), and KODAK Brownies were available in 1900 (see https://en.wikipedia.org/wiki/Kodak_Brownie ).\nYou should set this to the earliest year you expect to find in your library.",defaultValue:oe.MinValidYear}),maxValidFutureMs:new ie.DurationSetting({category:de.SettingCategories.Parsing,description:"If PhotoStructure encounters a year that is more than this value in the future, it will consider that source to be invalid and look elsewhere for the captured-at date for that given file.\nSet to 0 to disable future date filtering.",defaultValue:()=>"2d"}),useStatToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in the file "birthtime" (on Windows), or the lesser value of "mtime" and "ctime" (on macOS and Linux). Note that these values are not very reliable, as file transfers and backups frequently don\'t retain these values correctly.',defaultValue:!0}),usePathsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths.',defaultValue:!0}),useLibraryDirsToInferDates:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time isn\'t found in metadata, PhotoStructure will also look for the captured-at datetime encoded in file paths *for files that are in your PhotoStructure library. This defaults to false, as prior versions of PhotoStructure may have placed files into incorrect datestamped directories.',defaultValue:!1}),backfillTimezones:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"Should we try to backfill timezones for date-times that don't have them? If set to true, and {@link defaultVideosToUTC} is also true, we'll try backfilling timezones for date-times that are UTC, as well.\nSetting this to false removes **all** timezone inference--only those date-times with an explicit offset will have a defined timezone.\nPrior versions of exiftool-vendored would use the file's \".tz\" as a backstop even if this was set to false.\nAs of version 2023.10, this now defaults to true, as it's more likely to be what people expect.",defaultValue:!0}),inferTimezoneFromDatestamps:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"We always look at {@link Tags.TimeZone}, {@link Tags.OffsetTime}, {@link Tags.TimeZoneOffset}, {@link Tags.OffsetTimeOriginal}, {@link Tags.OffsetTimeDigitized}, and GPS metadata to infer the timezone.\nIf these strategies fail, and this is enabled, we'll try to infer the timezone from non-UTC datestamps included in the {@link capturedAtTags} and {@link capturedAtTagsFallback} settings.\nThis defaults to true as of version 2023.10.",defaultValue:!0}),enableSiblingInference:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:'This setting has been replaced by the "siblingInference" setting. "true" is equivalent to "auto", and "false" is equivalent to "never".',defaultValue:!0,deprecated:!0}),siblingInference:new fe.StringEnumSetting({category:de.SettingCategories.Parsing,description:'When enabled, and the "captured-at" time, Make, or Model isn\'t found in metadata, PhotoStructure will try to use nearby files to "fill in the blanks." If this is set to "auto", this is disabled automatically for slow directories. If this is set to "always", even files in slow directories will have tag inference, when necessary. Set to "never" to disable.',strEnum:ge.TagInferenceSettingValues,defaultValue:ge.TagInferenceSettingValues.auto}),siblingInferenceBasenameCoeff:new ne.FloatSetting({category:de.SettingCategories.Filters,deprecated:!0,description:'This setting has been replaced by the siblingInferenceBasenameCoeffPct" setting.',defaultValue:.6}),siblingInferenceBasenameCoeffPct:new X.BoundedIntegerSetting({category:de.SettingCategories.Filters,description:"What's the minimum case-insensitive Sørensen–Dice similarity index between file basenames, without the extension, to be used for sibling inference?\n0 will accept all siblings, 100 will only accept exact matches.",defaultValue:60,max:100,min:0}),writeInferredTagsToLibraryCopies:new Y.BooleanSetting({category:de.SettingCategories.Parsing,description:"When enabled, inferred metadata will be stored as _actual_ metadata in the library copy.",defaultValue:!0}),recountAllTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should all tags be recounted? PhotoStructure normally only recounts tags that have had assets recently added or removed, unless there are more than 20 changed tags.",defaultValue:!1,transient:!0}),tagCamera:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with cameras' make and model?",defaultValue:!0}),tagLens:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with lens' make and model?",defaultValue:!0}),tagFullLensModel:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure tag assets with the full lens model (like "Canon EF-M 15-45mm f/3.5-6.3 IS STM") or a just the lens information ("15-45mm f/3.5-6.3")? (If you change this value, you\'ll need to "Rebuild" your library to make the setting take effect).',defaultValue:!0}),tagYMD:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'Should assets be tagged with "When > Year" (the "y" option), or "When > Year > Month" (the "ym" option), or "When > Year > Month > Day" (the "ymd" option)? Setting this to "" will disable date tagging.',defaultValue:L.DateTagFormats.ym,strEnum:L.DateTagFormats}),tagDateFromStat:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should PhotoStructure tag assets with a date if the captured at time was only found in filesystem metadata? Filesystem metadata is not as reliable as EXIF metadata, as it can be changed arbitrarily when files are backed up.",defaultValue:()=>!ye()}),tagKeywordsFromPath:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file pathnames?",defaultValue:!0}),tagKeywordsFromMetadata:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should assets be tagged with keywords extracted from file metadata, as well as sidecar metadata?",defaultValue:!0}),keywordTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"PhotoStructure should look in the following tags for keywords. Note that these values are case-sensitive.",defaultValue:()=>["CatalogSets","Categories","HierarchicalSubject","HierarchicalKeywords","KeywordInfo","Keywords","LastKeywordXMP","Subject","TagsList","XPKeywords"]}),keywordReparenting:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure handle hierarchical keywords?\nIf this is set to "move", PhotoStructure will try to put hierarchical keywords into their "correct" root tag, like "Who," "Album," or "Where."\nIf this is set to "retain," PhotoStructure will always place hierarchical keywords under the "Keyword" root tag.\nIf this is set to "copy," PhotoStructure will add both the "correct" root tag _and_ the "Keyword" tag. For example, "Person|Doe|Jane" will be tagged as "Who|Doe|Jane" as well as "Keyword|Person|Doe|Jane".\nSee https://forum.photostructure.com/t/prefix-for-keywords-tag/499 for details.',defaultValue:V.KeywordReparentingStrategies.move,strEnum:V.KeywordReparentingStrategies}),rootTagAlbumsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be album names. This is matched case-insensitively.",defaultValue:()=>["Album","Albums","Collection","Collections"]}),rootTagKeywordsAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"List hierarchical tag roots that PhotoStructure should interpret to be keywords. This is matched case-insensitively.",defaultValue:()=>["Keyword","Keywords","Tag","Tags"]}),rootTagWhoAliases:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoSynonyms"],description:'When hierarchical tag values are found with any of these root names PhotoStructure will replace the root with "Who".\nFor example, using default values, "People/Jane Doe" will be replaced with "Who/Jane Doe" (or "Who/Doe/Jane", if tagNamesFormatter="family/given").\nDigicam uses "People". This is matched case-insensitively.',defaultValue:()=>["Person","People","Face","Faces"]}),keywordDelimiters:new ce.OptionalStringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure splits apart keywords, by default, when they are delimited by a comma or semicolon. For example, "car, blue, tree" will be interpreted as having the keywords "car", "blue", and "tree".\nNote that some software doesn\'t encode lists of keywords properly, so we have to include the comma and semicolon by default to handle these cases: but this makes keywords that contain a comma be split incorrectly. If the files in your library don\'t have this encoding issue, you can replace this setting with just an empty string to disable splitting.\nSee https://forum.photostructure.com/t/incorrect-handling-of-keywords-with-comma/992 for more discussion.\nAfter changing this value, you must force-resync your library for the changes to take affect.',defaultValue:",;"}),keywordPathSeparators:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure interprets keywords as hierarchical if a path separator character is found in a keyword. This allows for tags like "Family/Einstein/Albert", "Flora|Fruit|Orange", "Objects⊃Tools⊃Hammer", or "Fauna>Oceanic>Pelican". By default, these separators are the forward-slash, vertical-bar, and greater-than characters. If you don\'t want to interpret keywords as hierarchical, change this value to an empty string (""). After changing this value, you must force-resync your entire library for the changes to take affect.',defaultValue:"/|>⊃"}),tagFileType:new Y.BooleanSetting({category:de.SettingCategories.Tagging,aliases:["tagType"],description:'Should assets be tagged with their file type (like "Type/Image/JPEG")?',defaultValue:!0}),tagGeo:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Should we add geolocation tags to assets that have latitude/longitude?",defaultValue:!0}),tagGeoTemplate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'How should geo tags be rendered into a hierarchy? These will be attached to the "/Where" root tag.',defaultValue:["GeolocationCountry","GeolocationRegion","GeolocationCity"]}),tagJsonFaces:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Google Takeout provides .json sidecars that may contain the names of the people (or pets) found in the image. Should PhotoStructure import these tags under "Who"?.',defaultValue:!0}),tagFaceRegions:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Picasa and other software supports embedding face names within "RegionInfo.RegionList.Name" metadata. If this setting is enabled, and "RegionInfo.RegionList.Type" is "Face", PhotoStructure will import these tags under "Who".',defaultValue:!0}),whoTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,aliases:["tagWhoNames"],description:'This is a list of tags that will be examined for strings or string arrays. All values associated to these fields will be interpreted as names. Note that "dotted notation" is supported.',defaultValue:["People","PersonInImage","PersonInImageWDetails.PersonName","PersonInImageName","RegionInfoMP.Regions.PersonDisplayName"]}),tagNamesFormatter:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure format the "Who" tags for assets whose files are tagged with "people" strings?\n- "as-is" will tag names directly to "Who", so, "Who/Albert Einstein".\n- "family/given" will tag "Who/Einstein/Albert" (for regions that provide given names first).\n- "family/fullname" will tag "Who/Einstein/Albert Einstein".\nThe default is "as-is," because discerning given and family names aren\'t reliably inferable.\nSee https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:z.NameTagFormats["as-is"],strEnum:z.NameTagFormats}),tagNamesDefaultFamily:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'If a name is missing a family name, if this value is not blank, it will be provided as a default. If this value is blank, the name tag will be Who/given. Note that this setting is only used if "tagNamesFormatter" is set to "family/given".',defaultValue:"-"}),tagNamesCapitalizedAsFamily:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"Assume uppercased names are family names (this is common practice in geneology).",defaultValue:!0}),tagNamesOrder:new fe.StringEnumSetting({category:de.SettingCategories.Tagging,description:'How should PhotoStructure parse people\'s names? Note that this setting is only used if "tagNamesFormatter" is set to "family/given". See https://en.wikipedia.org/wiki/Personal_name#Name_order .',defaultValue:"western",strEnum:W.NameTagOrders}),tagNamesSurnamePrefixes:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family name prefixes to be considered part of the family name. These are matched case-insensitively. This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>["A","D’","Da","De la","De las","De","Del","Della","Den","Des","Di","Du","La","Las","Le","Li","Lo","Mc","Mac","op de","ten","ter","Van ‘t","van de","van der","van","von der","von","z","zu"]}),tagNamesSurnames:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all family names you expect in tags that are not single words that are found at the end of a tagged name. Hyphenated family names (like "Ocasio-Cortez") do not need to be listed here: only compound family names, and if your language doesn\'t separate family names with whitespace. In the latter case, either include all family names, or include all givenNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesGiven:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'List all given names you expect in tags that are not single words. Hyphenated given names (like "Rose-Ann") do not need to be listed here. If your language doesn\'t separate family names and given names with whitespace, either include all given names, or include all familyNames (whatever\'s easier for you). This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:()=>[]}),tagNamesFamilySurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added as a family name. As an example, if you use the default "()", then "Michelle LaVaughn (Robinson) Obama" will be name tagged with both "Who/Robinson/Michelle LaVaughn" and "Who/Obama/Michell LaVaugn". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["()"]}),tagNamesGivenSurrounds:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'This setting contains pairs of characters. When name portions are surrounded by these pairs, the contents will be added to the end of the given name with the surrounds retained. As an example, if you use the defaults of "[]" and double-quotes, then "Joe "Joey" Smith" will be name tagged with Who/Smith/Joe "Joey". This setting is used by the "tagNamesFormatter" if it is set to "family/given".',defaultValue:["[]",'""']}),tagNamesLexical:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Assume any name with a comma is in "lexical name order", which is always "lastname, given name(s)". If the given name is found to be "sr.", "senior", "jr.", or "junior", the name will be considered to be in western order ($givenNames $familyName, $modifier), and the $modifier will be added to the $givenNames. If this is set to false, commas are ignored.',defaultValue:!0}),excludedRootTags:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:"Keywords starting with the given roots will be omitted from your PhotoStructure library. Changing this value requires a library rebuild.",defaultValue:()=>["http:","https:","file:"]}),tagDisplayNameFS:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'What should PhotoStructure call the "root" tag for browsing by filesystem paths? Note that this value is only for the UI, and will update the "_displayName" of the /fs/ tag: this value won\'t change the URL path from be "/tag/fs/.../". Reasonable options that have been suggested include "Folder", "Directory", "Drive", "File", "Path", "Volume", or "Computer".',defaultValue:"Folder"}),tagDisplayNameFSRoot:new pe.StringSetting({category:de.SettingCategories.Tagging,description:'On POSIX systems, how should PhotoStructure reference the "root" directory (/)? "/" is a bit confusing, so "root" may be less confusing? Also see "tagDisplayNameFSRootWithHostname".',defaultValue:"root"}),tagDisplayNameFSRootWithHostname:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:"On non-docker hosts (which typically don't have reliable hostnames), should the root directory tag have the hostname appended?",defaultValue:()=>!!ye()||!(0,F.isDocker)()}),tagDisplayNameFSLabels:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'Should PhotoStructure use volume labels, if available, as display names for filesystem tags? As an example, instead of showing "Folder / D:", you\'d see "Folder / Photo backup #3" (or whatever the label D: has).',defaultValue:!0}),tagAlbumFilenames:new he.StringArraySetting({aliases:["tagAlbumJsonFilenames"],category:de.SettingCategories.Tagging,description:'PhotoStructure will look for files in the same directory with these names for album metadata. This can be JSON, XMP, MIE, or EXIF encoded, and is case-sensitive if your filesystem is case sensitive.\nSet this to an empty array ("[]") to disable this feature.',defaultValue:["metadata.json"]}),tagAlbumTitle:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'What\'s the name of the field encoding the album file?\nThe first defined field will win.\nObject hierarchies are separated with a ".".\nGoogle Takeout uses "albumData.title" for album titles.\n"Album" will pull in the XMP "Album" tag.\nThe MWG 2.0 specification added Collections tags, whose names are encoded as a "CollectionName". See https://exiftool.org/TagNames/MWG.html#Collections for details.\nNote that if you edit this setting, you need to rebuild your library to see the changes take effect.',defaultValue:["Album","albumData.title","Collections.CollectionName"]}),tagAlbumTitleHierarchies:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'If true, album titles will be split as hierarchical keywords. If false, album titles will not be split, and all albums will be under the "Albums" root tag.',defaultValue:!0}),tagAlbumDescription:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["Notes","albumData.description"]}),tagAlbumDate:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'If you have enabled "tagAlbumFromJson", what\'s the name of the field encoded in the album file? Object hierarchies are separated with a ".".',defaultValue:["albumData.date"]}),tagAlbumsExcluded:new he.StringArraySetting({category:de.SettingCategories.Tagging,description:'For "metadata.json" albums, some are automatically generated. If the title or description includes any of these strings, it will be ignored.',defaultValue:["Album for automatically uploaded content"]}),omitAncestorTags:new Y.BooleanSetting({category:de.SettingCategories.Tagging,description:'PhotoStructure\'s hierarchical tags assume implicit inheritance: that is, if you tag an asset with "nature/sky", "nature" is implicitly assumed.\nIf this setting is true, PhotoStructure will omit tags that are already inferred from deeper descendant tags--that is, if an asset is tagged with "nature/sky" and "nature", and this setting is true, the "nature" tag will be omitted.',defaultValue:!0}),subscriptionTimeoutMs:new ie.DurationSetting({category:de.SettingCategories.Subscriptions,description:"How long can PhotoStructure spend trying to gather system metadata and validating subscription licenses? This is fairly short, as the user is presumably waiting for PhotoStructure to spin up. If you have a slow system, you may want to increase this value.",defaultValue:()=>"7s"}),pickPlanOnWelcome:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'If set to true, the welcome page flow will redirect to https://account.photostructure.com/plans to have you pick between a "PLUS" and "LITE" plan. If set to false, the welcome page will continue directly to the settings page with a "LITE" plan. You can still upgrade to a paid plan later from the main menu or the about page, even if this is false.',defaultValue:!0}),coupon:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,description:"Coupon to automatically apply during subscription setup. This value will be ignored if you've already gone through the subscription setup flow.\nThe example value is a valid coupon code: thanks for reading!)\nNote that you can apply a coupon after your free trial starts by visiting https://account.photostructure.com .",exampleValue:()=>"RTFM15"}),autoRefreshLicense:new Y.BooleanSetting({category:de.SettingCategories.Subscriptions,description:'PhotoStructure uses cryptographically signed licenses to locally store your current plan subscription status. These licenses are only valid for the current subscription period, and must be refreshed when your subscription renews or converts from a free trial to a paid subscription. To minimize the hassle of license renewals, PhotoStructure can automatically renew expired licenses in the background.\nIf the current license has expired and this value is true, PhotoStructure will make one secure POST request to https://account.photostructure.com/ that contains several lossy one-way hashes of current system metadata. We hash all identifying metadata to only 15 characters to alleviate any privacy concerns. If your plan subscription is active, a new license will be added to your library.\nSet this to false and set the "reportErrors" setting to false if you don\'t want PhotoStructure "phoning home" for any reason.\nNote that if this is disabled, license renewals will require manual intervention: click "Upgrade" from the main menu, pick your plan, authenticate, and the license will automatically refresh.',defaultValue:!0}),license:new ce.OptionalStringSetting({category:de.SettingCategories.Subscriptions,sensitive:!0,description:'Subscription licenses are normally saved automatically into both your library and system configuration directories. This setting just provides users with an alternative way to provide a license, if it\'s more convenient. Any value provided to this setting will be considered in addition to existing license files when PhotoStructure is trying to find the "best" license available.'})};for(const[e,r]of(0,d.entries)(t.Settings))r._setName(e);function Se(e){const r=((0,l.blank)(e)?"":e).split(n.delimiter);return(0,F.isDocker)()&&r.unshift("/opt/photostructure/tools/bin"),r.push(...t.Settings.toolPaths.valueOrDefault),(0,o.uniq)(r).filter(l.notBlank).join(n.delimiter)}function be(e){return["system"===e.categoryType?0:1,de.SettingCategories.indexOf(e.category)??de.SettingCategories.length+1,e.advanced,e.name]}t.SuggestedDirsEnvKey="SUGGESTED_DIRS",t.withDefaultPaths=Se,t.pathWithDefaults=(0,s.lazy)((()=>Se((0,x.getEnv)("PATH")))),t.allSettings=(0,s.lazy)((()=>(0,a.sortBy)((0,d.values)(t.Settings),be))),t.persistedSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>!e.transient)))),t.transientSettings=(0,s.lazy)((()=>(0,t.allSettings)().filter((e=>e.transient)))),t.persistedSystemSettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.SystemCategories.includes(e.category))))),t.persistedLibrarySettings=(0,s.lazy)((()=>(0,t.persistedSettings)().filter((e=>de.LibraryCategories.includes(e.category)))));const Pe=(0,s.lazy)((()=>{const e=new g.CaseInsensitiveMap;for(const r of(0,t.persistedSettings)()){for(const t of r.names)e.set(t,r);for(const t of r.keys)e.set(t,r)}return e}));t.getSettingByNameOrKey=function(e){return Pe().get((0,m.toS)(e).toLowerCase())},t.ciSettings=(0,s.lazy)((()=>new y.CaseInsensitiveValued(t.Settings,((e,t)=>[...t.names,...t.keys]))))},41692:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setSettingsDefaults=void 0;const i=r(19851),n=r(31586),s=r(7282),o=r(49776),a=r(46292),l=r(32774),u=r(55086),c=r(46296),d=r(55939),h=r(96706),f=r(83278),m=r(92234),p=r(45969),g=r(60865),y=r(30933),v=r(15674),w=r(28874);t.setSettingsDefaults=(0,i.lazy)((()=>{w.Settings.configDir.opts.defaultValue=a.configDir,w.Settings.logDir.opts.defaultValue=c.defaultLogDir_,w.Settings.logServerLevel.opts.defaultValue=()=>w.Settings.logLevel.valueOrDefault,w.Settings.cacheDir.opts.defaultValue=o.defaultCacheDir,w.Settings.toolPaths.opts.defaultValue=()=>(0,h.isEnvTrue)("SETTINGS_IO_TEST")?m.DefaultPosixPaths:m.DefaultPaths,w.Settings.libraryDir.opts.exampleValue=()=>(0,s.isProd)()&&(0,p.isDocker)()?l.DefaultDockerLibraryDir:(0,s.isTest)()?"/home/test/Pictures":(0,d.defaultPicturesDir)(),w.Settings.libraryDir.opts.defaultValue=u.defaultLibraryDir,w.Settings.originalsDir.opts.defaultValue=u.defaultOriginalsDir,w.Settings.scanPaths.opts.exampleValue=()=>[(0,d.defaultPicturesDir)()],w.Settings.powerShellProcs.opts.defaultValue=()=>Math.max(2,Math.round((0,v.maxCpus)()/4)),w.Settings.useFsWatch.watch(f.useFsWatch),w.Settings.updateChannel.opts.defaultValue=g.channel,w.Settings.ffmpegThreads.opts.defaultValue=()=>(0,v.maxCpus)()>=12?2:1,w.Settings.minBusyPct.opts.defaultValue=()=>(0,n.sigFigs)(50/(0,y.cpuCount)(),2)}))},84438:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsToml=void 0,t.SettingsToml="settings.toml"},58305:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringArraySetting=t.splitStringArray=t._join=void 0;const i=r(76760),n=r(40958),s=r(22573),o=r(98553),a=r(55835),l=r(59455),u=r(83179);function c(e){return null==e?void 0:(0,o.stringify)(e)}t._join=c;function d(e){return(0,a.map)(function(e){const t=(0,s.notBlankToS)(e);if(null!=t){if(t.startsWith("[")&&t.endsWith("]"))try{return(0,n.compact)((0,l.toA)(JSON.parse(t)).map(s.notBlankToS))}catch{}for(const e of["¦",i.delimiter])if(t.includes(e))return(0,n.compactBlankish)(t.split(e));return[t]}}(e),n.compactBlankish)}t.splitStringArray=d;class h extends u.Setting{constructor(e){super({defaultValue:[],fromEnv:d,toEnv:c,...e})}toValidValue(e){return(0,s.notBlankToS)(e)}toValidValues(e){return null==e?void 0:(0,n.uniq)(e.map((e=>this.toValidValue(e))))}push(...e){(0,n.isEmpty)(e)||(this.value=this.toValidValues((0,n.uniq)([...(0,l.toA)(this.value),...(0,l.toA)(e)])))}has(e){return(0,l.toA)(this.values).includes(e)}get values(){return(0,l.optToA)(this.value)??this.defaultValue}set values(e){this.userValue=this.toValidValues(e)}isEmpty(){return(0,n.isEmpty)(this.values)}isNotEmpty(){return(0,n.isNotEmpty)(this.values)}toNotEmpty(){return(0,n.toNotEmpty)((0,n.compactBlanks)(this.values))}}t.StringArraySetting=h},57571:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumSetting=void 0;const i=r(83179);class n extends i.Setting{constructor(e){super({toEnv:t=>e.strEnum.getCI(t),fromEnv:t=>e.strEnum.getCI(t),...e}),this.strEnum=e.strEnum;const t=this.defaultValue;if(!this.strEnum.has(t))throw new Error(`${this.strEnum.values}, doesn't include defaultValue, ${e.defaultValue}`)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumSetting=n},72564:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringEnumsSetting=void 0;const i=r(40958),n=r(98553),s=r(55835),o=r(58305);class a extends o.StringArraySetting{constructor(e){super({toEnv:e=>(0,s.map)(e,(e=>(0,n.stringify)((0,i.uniq)(e)))),fromEnv:t=>{return r=t,n=e.strEnum,(0,i.compact)((0,o.splitStringArray)(r)?.map((e=>n.getCI(e))));var r,n},defaultValue:e.defaultValue??e.strEnum.values,...e}),this.strEnum=e.strEnum}toValidValue(e){return this.strEnum.getCI(e)}addToJSON(){return{"valid values":this.strEnum.values}}}t.StringEnumsSetting=a},80372:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringSetting=void 0;const i=r(22573),n=r(81168),s=r(83179);class o extends s.Setting{constructor(e){super({toEnv:a,fromEnv:a,...e})}hasValue(){return(0,i.notBlank)(this.value)}}function a(e){return null==e?void 0:(0,n.trimQuotes)(e)}t.StringSetting=o},32707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.systemSettingsFile=void 0;const i=r(76760),n=r(55835),s=r(46292),o=r(84438);t.systemSettingsFile=function(){return(0,n.map)((0,s.configDir)(),(e=>(0,i.join)(e,o.SettingsToml)))}},80496:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TagInferenceSettingValues=void 0;const i=r(50989);t.TagInferenceSettingValues=(0,i.strEnum)("never","always","auto")},6707:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.writeTomlFile_=t.readTomlFile_=t.readTomlFileSync=void 0;const i=r(90858),n=r(44652),s=r(22573),o=r(76850),a=r(50213),l=r(81168),u=r(84542),c=r(17217),d=r(68284),h=r(98778);function f(e){return t=(0,o.debom)(e),(0,s.blank)(t)?void 0:(0,i.parse)((0,l.dumbquote)(t));var t}t.readTomlFileSync=function(e){const t=(0,s.mapNotBlank)(e,c.toNativePath_);if(null!=t)try{return(0,d.isFileSync)(t)?f((0,n.readFileSync)(t)):void 0}catch(e){return void(0,a.mkLogger)("settings.Toml").warn("readTomlFileSync() failed",{nativePath:t,error:e})}},t.readTomlFile_=async function(e){return(0,s.mapNotBlank)(e,(async e=>f(await(0,n.readFile)((0,c.toNativePath_)(e)))))},t.writeTomlFile_=function(e,t){return(0,n.writeFile)((0,c.toNativePath_)(e),(0,u.joinLines)(...(0,h.stringifyToml)(t)))}},98778:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapTomlToLines=t.kvToToml=t.stringifyToml=void 0;const i=r(22573),n=r(96249),s=r(98553),o=r(68708),a=r(51926);function l(e,t,r){if((0,i.blank)(e))throw new Error("kvToToml(): Blank key");const n=e+" = "+(0,s.stringifyPretty)(t);return(0,i.blank)(r?.prefix)?[n]:(0,a.wrap)(n.split("\n"),r)}t.stringifyToml=function(e){return(0,n.flatten)((0,o.entries)(e).map((([e,t])=>l(e,t))))},t.kvToToml=l,t.wrapTomlToLines=function(e){return(0,i.blank)(e.key)||null==e.value||(null!=e.prepend&&e.lines.push(...(0,a.wrap)(["",...e.prepend],e.wrap)),e.lines.push(...l(e.key,e.value,e.wrap))),e.lines}},10357:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WrapComments=void 0,t.WrapComments={maxLineLen:78,prefix:"# "}},65162:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bname=void 0;const i=r(4001),n=r(81168);t.bname=function(e,t=!0){let r=(0,n.isString)(e)?e:e.name;return t&&(r=(0,i.stripCopySuffixFromName)(r)),r=(0,n.trimLeftPadding)((0,i.stripDSC)(r)),r.toLowerCase().normalize()}},70379:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DateTagFormats=void 0;const i=r(50989);t.DateTagFormats=(0,i.strEnum)("y","ym","ymd","")},71300:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultCapturedAtTagsConst=t.ProblematicCapturedAtTags=t.OverrideUTCZoneTags=t.IgnoredCapturedAtTags=void 0,t.IgnoredCapturedAtTags=["creationTime","HistoryWhen","MediaModifyDate","MetadataDate","SubSecTime","TrackModifyDate"],t.OverrideUTCZoneTags=["DateTimeUTC","GPSDateTime"],t.ProblematicCapturedAtTags=["SubSecCreateDate","SubSecMediaCreateDate","SubSecModifyDate","CreateDate","MediaCreateDate","ModifyDate","DateTime","DateTimeCreated","photoTakenTime","TrackCreateDate","CreationTime",...t.OverrideUTCZoneTags],t.DefaultCapturedAtTagsConst=["CreationDate","DateTimeOriginal","SubSecDateTimeOriginal","DateTimeDigitized","OriginalCreateDateTime","DigitalCreationDateTime"]},33209:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultIncludedPreviewTags=void 0,t.DefaultIncludedPreviewTags=["AttributionName","AttributionURL","capturedAt","Copyright","exposureSettings","GPSLatitude","GPSLongitude","License","Make","Model","Permits","Prohibits","Rating","Requires","Source"]},48987:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultLensMakes=void 0,t.DefaultLensMakes=["7artisans","Bower","Canon","Carl Zeiss","Cosina","Fuji","Fujifilm","Goerz","Hasselblad","Hirox","Hoya","Kodak","Konica","Leica","Leidolf","Lensbaby","Lumix","Meike","Meopta","Minolta","Neewer","Nikon","Olympus","Opteka","Panasonic","Pentacon","Pentax","Ricoh","Rodenstock","Rokinon","Ross","Samsung","Samyang","Seiko","Sigma","Silor","Soligor","Sony","Sunpak","Tamron","Tiffen","Tokina","Topcon","Venus","Voigtländer","Wray","Yongnuo","Zeiss","Zhong Yi","Zuiko"]},68268:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.KeywordReparentingStrategies=void 0;const i=r(50989);t.KeywordReparentingStrategies=(0,i.strEnum)("move","copy","retain")},61208:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagFormats=void 0;const i=r(50989);t.NameTagFormats=(0,i.strEnum)("as-is","family/given","family/fullname")},99023:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NameTagOrders=void 0;const i=r(50989);t.NameTagOrders=(0,i.strEnum)("western","eastern")},60865:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.versionMajorMinor=t.baseVersion=t.channel=void 0;const i=r(37805),n=r(30577);t.channel=function(){return(0,n.extractUpdateChannel)(i.version)},t.baseVersion=()=>[i.versionMajor,i.versionMinor,i.versionPatch].join("."),t.versionMajorMinor=i.versionMajor+"."+i.versionMinor},30577:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.eligibleForChannel=t.extractUpdateChannel=t.UpdateChannels=void 0;const i=r(50989);t.UpdateChannels=(0,i.strEnum)("prealpha","alpha","beta","stable"),t.extractUpdateChannel=function(e){for(const r of t.UpdateChannels.values)if(e.includes("-"+r))return r;return t.UpdateChannels.stable},t.eligibleForChannel=function(e){return t.UpdateChannels.values.slice(t.UpdateChannels.ordinal(e))}},1485:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedLinuxMountpointNames=t.defaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxMountpointPaths=t.DefaultExcludedLinuxRoots=void 0;const i=r(45969);t.DefaultExcludedLinuxRoots=["boot","efi","etc","lib","proc","snap","sys","tmp"],t.DefaultExcludedLinuxMountpointPaths=["/dev/shm","/run","/run/lock","/run/qemu","/run/snapd/ns","/tmp","/var/tmp"],t.defaultExcludedLinuxMountpointPaths=function(){return[...(0,i.isDocker)()?["/"]:[],...t.DefaultExcludedLinuxMountpointPaths]},t.DefaultExcludedLinuxMountpointNames=["#snapshot"]},19861:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultExcludedFilesystemTypes=void 0,t.DefaultExcludedFilesystemTypes=["cgmfs","cgroup","debugfs","devfs","devtmpfs","sunrpc","sysfs","tracefs","udev"]},69375:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.whyExcludedMountpoint=t.isExcludedMountpoint=t.isExcludedFilesystem=void 0;const i=r(19851),n=r(22573),s=r(50213),o=r(9103),a=r(7282),l=r(29882),u=r(43334),c=r(28874),d=(0,i.lazy)((()=>(0,s.mkLogger)("volumes.PosixVolumes")));t.isExcludedFilesystem=function(e){return!(0,n.blank)(e)&&u.isPosix&&c.Settings.excludedFilesystemTypes.values.includes(e)};const h=u.isLinux||(0,a.isTest)()?/^\/dev(?!\/mapper)(?:\/|\/?$)/i:void 0,f=u.isLinux||(0,a.isTest)()?/^\/var\/snap(?:$|\/)/:void 0,m=u.isLinux||(0,a.isTest)()?/^\/run\/user\/\d+\/gvfs\/.+$/i:void 0,p=u.isLinux||(0,a.isTest)()?/^\/var\/lib\//:void 0;function g(e){if((0,n.blank)(e))return"blank";const t=(0,l.toPathnames)(e),r=t[0],i=t[t.length-1];return c.Settings.excludedRootDirectories.has(r)?"ExcludedRootDirectory":c.Settings.excludedMountpointPaths.has(e)?"excludedMountpointPaths":c.Settings.excludedMountpointBasenames.has(i)?"excludedMountpointBasenames":!0===h?.test(e)?"LinuxDevMapperRE":!0===f?.test(e)?"LinuxVarSnapRE":"run"===r&&!1===m?.test(e)?"LinuxRunRE":!0===p?.test(e)?"LinuxDockerRE":void 0}t.isExcludedMountpoint=(0,o.memoize)((e=>{if(u.isWin)return!1;const t=g(e);return d().tap({msg:"isExcludedMountpoint",result:null!=t,meta:{mountpoint:e,why:t}})}),{maxSize:512}),t.whyExcludedMountpoint=g},63870:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MinIoRate=t.commandTimeoutMs=t.volumeMetadataTtlMs=t.mountpointsTtlMs=void 0;const i=r(42659),n=r(12168),s=r(28874);t.mountpointsTtlMs=function(){return s.Settings.mountpointsTtlMs.valueOrDefault},t.volumeMetadataTtlMs=function(){return s.Settings.volumeMetadataTtlMs.valueOrDefault},t.commandTimeoutMs=function(){return s.Settings.commandTimeoutMs.valueOrDefault},t.MinIoRate=n.MiB/i.secondMs},55111:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HelmetPlugins=void 0;const i=r(50989);t.HelmetPlugins=(0,i.strEnum)("all","contentSecurityPolicy","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","dnsPrefetchControl","expectCt","frameguard","hidePoweredBy","hsts","ieNoOpen","noSniff","originAgentCluster","permittedCrossDomainPolicies","referrerPolicy","xssFilter")},30933:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.cpuCount=t.cpuInfo=void 0;const n=i(r(48161)),s=r(19851),o=r(42659),a=r(31586),l=r(50213),u=r(28874),c=(0,s.lazy)((()=>(0,l.mkLogger)("work.CpuInfo")));t.cpuInfo=(0,s.lazy)((()=>n.default.cpus()),5*o.minuteMs),t.cpuCount=(0,s.lazy)((()=>{try{if(u.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=n.default.availableParallelism?.(),r=(0,t.cpuInfo)().length;return c().tap({msg:"cpuCount()",result:(0,a.clamp)(1,128,Math.ceil(e??r)),meta:{availableParallelism:e,cpuInfoLength:r}})}catch(e){return c().warn("availableParallelism()/cpuCount() failed",{error:e}),1}}))},58444:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.estimatedFreeMem=void 0;const n=i(r(48161)),s=r(19851),o=r(31586),a=r(12168),l=r(50213),u=r(45879),c=r(70417),d=r(45969),h=(0,s.lazy)((()=>(0,l.mkLogger)("work.FreeMem")));t.estimatedFreeMem=(0,s.lazy)((()=>{const e=n.default.freemem(),t=n.default.totalmem(),r=(2*e+t)/3;if((0,d.isDocker)()){const i=(0,u.intFromFileSync)("/sys/fs/cgroup/memory/memory.limit_in_bytes");if((0,o.gt0)(i))return h().tap({msg:"estimatedFreeMem() (docker mode)",result:(0,c.avg)([i,r]),meta:{freemem:e,totalmem:t,cgroupMem:i}})}return h().tap({msg:"estimatedFreeMem() ",result:r,meta:{result:(0,a.fmtBytes)(r),freemem:(0,a.fmtBytes)(e),totalmem:(0,a.fmtBytes)(t)}})}))},15674:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sharpThreadsPerProcess=t.maxConcurrentImports=t.maxCpus=t.singleThreadedMode=t.targetCpuLoadPct=t.timeoutPenalization=t.clearMaxWorkCaches=void 0;const i=r(19851),n=r(42659),s=r(41400),o=r(31586),a=r(12168),l=r(50213),u=r(7282),c=r(34102),d=r(57902),h=r(28874),f=r(30933),m=r(58444),p=r(22751),g=(0,i.lazy)((()=>(0,l.mkLogger)("work.MaxCpus")));function y(){m.estimatedFreeMem.unset(),t.maxCpus.unset(),t.maxConcurrentImports.unset(),p.timeoutRate.prior()?.clear(),f.cpuCount.unset()}(0,s.later)((()=>{(0,u.isTest)()&&(0,c.ee)().on("clearCache",(()=>y())),(0,c.ee)().on("settingsChanged",y),h.Settings.cpuBusyPercent.watchLater(y),h.Settings.maxConcurrentImports.watchLater(y)})),t.clearMaxWorkCaches=y;const v=(0,i.lazy)((()=>{const e=(0,o.clamp)(128,1024,h.Settings.maxMemoryMb.valueOrDefault)*a.MB;return g().tap({msg:"maxProcsForMem",result:Math.max(1,Math.floor((0,m.estimatedFreeMem)()/e)),meta:{estFreeMemMb:Math.floor((0,m.estimatedFreeMem)()/a.MB),worstCaseMemPerProcMb:Math.ceil(e/a.MB)}})}),n.minuteMs);function w(){const e=Math.round(p.timeoutRate.prior()?.eventsPerMinute??0),t=h.Settings.timeoutThrottleCoeff.valueOrDefault,r=0===e||0===t?1:(0,o.sigFigs)(t/e,2);return g().tap({msg:"timeoutPenalization()",level:r>1?d.LogLevels.warn:d.LogLevels.debug,result:r,meta:{timeoutsPerMinute:e,timeoutThrottleCoeff:t}})}function S(){return((0,o.toGt0)(h.Settings.cpuBusyPercent.valueOrDefault)??1)/100}t.timeoutPenalization=w,t.targetCpuLoadPct=S,t.singleThreadedMode=function(){return 1===(0,t.maxCpus)()||Math.round(S()*(0,f.cpuCount)())<=1},t.maxCpus=(0,i.lazy)((function(){if(h.Settings.cpuBusyPercent.valueOrDefault<=0)return 1;const e=Math.max(1,Math.floor(S()*(0,f.cpuCount)())-1);let t=e;const r=p.timeoutRate.prior()?.eventsPerMinute??0,i=w();if(1!==i){const e=t;t*=i,g().warn("Recent timeouts! Throttling down.",{penalization:i,resultBeforePenalization:e,resultAfterPenalization:t})}const n=Math.min(e,v());return t=(0,o.clamp)(1,n,Math.floor(t)),g().tap({msg:"maxCpus()",level:d.LogLevels.info,result:t,meta:{cpuLoadPct:S(),cpuCount:(0,f.cpuCount)(),cpuPortion:e,penalization:i,timeoutsPerSecond:r,maxProcsForMem:v()}})})),t.maxConcurrentImports=(0,i.lazy)((function(){return(0,o.gt0)(h.Settings.maxConcurrentImports.valueOrDefault)?(0,o.clamp)(1,(0,t.maxCpus)(),h.Settings.maxConcurrentImports.valueOrDefault):Math.ceil(.8*(0,t.maxCpus)())})),t.sharpThreadsPerProcess=function(){const e=h.Settings.sharpThreadsPerProcess.valueOrDefault;return e>0?e:(0,o.clamp)(1,Math.min((0,t.maxCpus)(),h.Settings.sharpThreadsPerProcess.max),Math.round((0,t.maxCpus)()/4))}},22751:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onTimeout=t.timeoutRate=void 0;const i=r(58587),n=r(87997),s=r(19851),o=r(42659),a=r(41400),l=r(50213),u=r(7282),c=r(45255),d=r(34102),h=r(976),f=r(15674),m=(0,s.lazy)((()=>(0,l.mkLogger)("work.WorkTimeout")));t.timeoutRate=(0,s.lazy)((()=>new i.Rate(5*o.minuteMs,(0,u.isTest)()?100:c.ShortCommandTimeoutMs)));const p=(0,s.lazy)((()=>(0,n.setInterval)(g,o.minuteMs).unref()));function g(){f.maxCpus.refresh(),f.maxConcurrentImports.refresh(),p()}t.onTimeout=function(){const e=(0,t.timeoutRate)();e.onEvent(),m().warn("onTimeout()",(0,h.rateStats)(e)),g()},(0,a.later)((()=>{(0,d.ee)().on("clearCache",(()=>{f.maxCpus.unset(),f.maxConcurrentImports.unset(),t.timeoutRate.unset()}))}))},40958:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndexes=t.arrayEndsWith=t.arrToIterator=t.commaList=t.last=t.diff=t.primitiveValueOfOrElse=t.stepRange=t.range=t.anneal=t.commonPrefixLength=t.firstMatch=t.sum=t.count=t.clear=t.uniqBy2=t.uniqByLast=t.uniqBy=t.uniqSubstrings=t.uniqFirst=t.uniq=t.compactBlankish=t.compactBlanks=t.compact=t.removeSame=t.remove=t.insertUniq=t.insertAt=t.pushUniqBy=t.pushUniq=t.eqlPrimitiveUnordered=t.includesAll=t.includesAny=t.indexOfPrimitive=t.indexOf=t.includes=t.flatMap=t.move=t.filterInPlaceAsync=t.filterInPlace=t.startsWith=t.toPrimitive=t.mapNotEmptyOr=t.mapNotEmpty=t.mapArray=t.isEmpty=t.notEmptyOr=t.toNotEmpty=t.isNotEmpty=void 0;const i=r(76790),n=r(22573),s=r(50357),o=r(98553),a=r(49769),l=r(34666),u=r(30976),c=r(42279),d=r(32639),h=r(59455),f=r(54993);function m(e){return null!=e&&(0,h.toA)(e).length>0}function p(e){return null==e||0===(0,h.toA)(e).length}function g(e){return(0,l.isPrimitive)(e)||(0,l.isPrimitiveArray)(e)?e:e.valueOf()}function y(e,t){return null!=e&&null!=t&&e.length===t.length&&e.every(((e,r)=>e===t[r]))}function v(e,t){for(let r=0;r=e.length||r>=e.length)return e;const i=e[t];return e.splice(t,1),e.splice(r,0,i),e}function S(e){return null==e?[]:v((0,h.toA)(e),(e=>null!=e))}function b(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&(0,a.getOrSet)(r,e,(()=>i))}return[...r.values()]}function P(e,t,r=1,i=(e=>e)){const n=[];if(et;s-=r)n.push(i(s));return n}t.isNotEmpty=m,t.toNotEmpty=function(e){return m(e)?e:void 0},t.notEmptyOr=function(e,t){return m(e)?e:(0,c.tot)(t)},t.isEmpty=p,t.mapArray=function(e,t){return Array.isArray(e)?t(e):void 0},t.mapNotEmpty=function(e,t){return m(e)?t(e):void 0},t.mapNotEmptyOr=function(e,t,r){return m(e)?t(e):(0,c.tot)(r)},t.toPrimitive=g,t.startsWith=function(e,t){return y(e.slice(0,t.length),t)},t.filterInPlace=v,t.filterInPlaceAsync=async function(e,t){for(let r=0;rt.includes(e)))},t.includesAll=function(e,t){if(p(e)||p(t))return!1;for(const r of t)if(!e.includes(r))return!1;return!0},t.eqlPrimitiveUnordered=function(e,t){if(null==e||null==t||e.length!==t.length)return!1;const r=(0,i.sortBy)(e,g),n=(0,i.sortBy)(t,g);return r.every(((e,t)=>e===n[t]))},t.pushUniq=function(e,...t){for(const r of t)null==r||e.some((e=>(0,s.eql)(e,r)))||e.push(r);return e},t.pushUniqBy=function(e,t,r){const i=e.map(r);for(const n of t){const t=r(n);i.includes(t)||(e.push(n),i.push(t))}return e},t.insertAt=function(e,t,...r){return e.splice(t,0,...r),e},t.insertUniq=function(e,t,r){for(let t=0;t0)throw new Error("badly sorted array: "+e);for(let i=0;i0)return e.splice(i,0,t),e}return e.push(t),e},t.remove=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>!(0,s.eql)(e,t))))),r!==e.length},t.removeSame=function(e,...t){const r=e.length;return v(e,(e=>t.every((t=>e!==t)))),r!==e.length},t.compact=S,t.compactBlanks=function(e){return null==e?[]:(0,h.toA)(e).map((e=>(0,f.toS)(e).trim())).filter((e=>e.length>0))},t.compactBlankish=function(e){return null==e?[]:[...e].filter(n.notBlankish)},t.uniq=function(e){if(null==e)return[];const t=S(e);if(t.length<=1)return t;if(t.length<10){const e=t[0];if(t.every((t=>t===e)))return[e]}return b(t,(e=>(0,l.isPrimitive)(e)?e:(0,o.stringify)(e)))},t.uniqFirst=function(e){if(null==e)return[];const t=[];for(const r of e)null==r||(0,s.eql)(t[t.length-1],r)||t.push(r);return t},t.uniqSubstrings=function(e){if(null==e)return[];const t=S(e);if(0===e.length)return[];const r=[];for(const e of(0,i.sortBy)(t,(e=>[-e.length,e.toLowerCase()])))r.some((t=>t.includes(e)))||r.push(e);return(0,i.sortBy)(r,(e=>t.indexOf(e)))},t.uniqBy=b,t.uniqByLast=function(e,t=(e=>(0,o.stringify)(e))){const r=new Map;for(const i of e)if(null!=i){const e=t(i);null!=e&&r.set(e,i)}return[...r.values()]},t.uniqBy2=function(e,t){const r=[];for(const i of e)null!=i&&r.every((e=>!t(i,e)))&&r.push(i);return r},t.clear=function(e){return e.length=0,e},t.count=function(e,t){return e.reduce(((e,r,i)=>e+(t(r,i)?1:0)),0)},t.sum=function(e,t){return e.reduce(((e,r,i)=>e+t(r,i)),0)},t.firstMatch=function(e,t){for(const r of S(t)){const t=e.exec(r);if(null!=t)return t}},t.commonPrefixLength=function(e,t){if(null==e||null==t)return 0;if(e===t)return e.length;if("string"==typeof e&&(e=[...e]),"string"==typeof t&&(t=[...t]),y(e,t))return e.length;let r=0;for(;e[r]===t[r];)r++;return r},t.anneal=function({array:e,expense:t,allowedDelta:r}){const i=Math.round(r);if(i<2)return e;for(let r=0;re)){return P(e,t,1,r)},t.stepRange=P,t.primitiveValueOfOrElse=e=>{if((0,l.isPrimitive)(e))return e;if(Array.isArray(e))return(0,o.stringify)(e);if((0,d.isFunction)(e.valueOf))return e.valueOf();throw new Error("Cannot get primitive value for "+JSON.stringify(e))},t.diff=function(e,r,i=t.primitiveValueOfOrElse){const n=new Set(r.map(i));return e.filter((e=>!n.has(i(e))))},t.last=function(e){return null!=e?e[e.length-1]:void 0},t.commaList=function(e,t="or"){return e.length<=1?e.join(""):2===e.length?e.join(" "+t+" "):e.slice(0,-1).join(", ")+", "+t+" "+e[e.length-1]},t.arrToIterator=function(e){return e[Symbol.iterator]()},t.arrayEndsWith=function(e,t){if(e.length{Object.defineProperty(t,"__esModule",{value:!0}),t.copyArrayTo=void 0,t.copyArrayTo=function(e,t){for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.pushSorted=t.deepSortBy=t.sortBy=t.sortedBy=t.isSorted=t.sortUniqByInPlace=t.sortUniq=t.sortUniqBy=t.sortByInPlace=t.sort=void 0;const i=r(40958),n=r(36783),s=r(41801),o=r(98553),a=r(49769),l=r(55835),u=r(34666),c=r(59455);function d(e,t){return(0,n.copyArrayTo)(f(e,t),e)}function h(e,t){const r=new Map;for(const i of e)(0,a.getOrSet)(r,(0,o.stringify)(t(i)),(()=>i));return f(r.values(),t)}function f(e,t){return(0,c.toA)(e).filter((e=>null!=e)).map(((e,r)=>({item:e,cmp:(0,l.map)(t(e,r),(e=>[e,r]))}))).filter((e=>null!=e.cmp)).sort(((e,t)=>(0,u.cmp)(e.cmp,t.cmp))).map((e=>e.item))}t.sort=function(e){return d((0,i.compact)(e),i.toPrimitive)},t.sortByInPlace=d,t.sortUniqBy=h,t.sortUniq=function(e){return h(e,(e=>e))},t.sortUniqByInPlace=function(e,t){return(0,n.copyArrayTo)(h(e,t),e)},t.isSorted=function(e){return e.every(((t,r)=>0===r||t>=e[r-1]))},t.sortedBy=function(e,t){return e.every(((r,i)=>0===i||t(r)>=t(e[i-1])))},t.sortBy=f,t.deepSortBy=function e(t,r){return f(t,r).map((t=>(0,s.isIterable)(t)?e(t,r):t))},t.pushSorted=function(e,t,r){const i=e.findIndex((e=>r(t){Object.defineProperty(t,"__esModule",{value:!0}),t.asPromise=void 0;const i=r(32639);t.asPromise=async function(e){const t=await e;return(0,i.isFunction)(t)?t():t}},5233:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryOnReject_=void 0;const i=r(41400),n=r(31586),s=r(13538),o=r(41583);t.retryOnReject_=async function(e,t){const r=(0,n.gt0)(t.timeoutMs)?()=>(0,s.thenOrTimeoutError)(e(),t.timeoutMs):e;if(t.maxRetries<=0)return r();const a=t.onRetryWaitUntil??(e=>(0,i.delay)(Math.max(250,(t.retryDelay??250)*(e??1))));let l=0;const u=async()=>{try{return await r()}catch(e){const r=(0,o.toErr)(e);if(!1===t.errorIsRetriable?.(r)||l>t.maxRetries)throw r;return l++,await a(l),u()}};return u()}},17586:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.at=void 0,t.at=function(e,t){if(null!=e&&((t=Math.trunc(t)||0)<0&&(t+=e.length),!(t<0||t>=e.length)))return e[t]}},22573:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notBlankish=t.blankish=t.firstNotBlank=t.mapNotBlankOr=t.mapNotBlank=t.notBlankAnd=t.notBlankOr=t.toNotBlank=t.notBlankToS=t.notBlank=t.blank=void 0;const i=r(55835),n=r(42279),s=r(54993);function o(e){return null==e||""===e||"string"==typeof e&&""===e.trim()}function a(e){return!o(e)}function l(e,t){if(!1===e||null==e||""===e)return;const r=(0,s.toS)(e);return a(r)?t(r):void 0}t.blank=o,t.notBlank=a,t.notBlankToS=function(e){return a(e)&&"undefined"!==e?(0,s.toS)(e).trim():void 0},t.toNotBlank=function(e){if(null==e)return;const t=(0,s.toS)(e);return 0===t.length||0===t.trim().length?void 0:t},t.notBlankOr=function(e,t){if(null==e)return(0,n.tot)(t);const r=(0,s.toS)(e).trim();return r.length>0?r:(0,n.tot)(t)},t.notBlankAnd=function(e,t){return!o(e)&&t(e)},t.mapNotBlank=l,t.mapNotBlankOr=function(e,t,r){return(0,i.orElse)(l(e,t),r)},t.firstNotBlank=function(...e){for(const t of e)if("string"==typeof t&&t.trim().length>0)return t};const u=/^\s*(?:(?:null|undefined)\s*)?$/i;function c(e){return null==e||u.test((0,s.toS)(e))}t.blankish=c,t.notBlankish=function(e){return!c(e)}},38639:(e,t)=>{function r(e){if("boolean"==typeof e)return e;if(null==e)return!1;if(1===e)return!0;{const t=String(e).toLowerCase().trim();return["true","1"].includes(t)}}function i(e,...t){if("boolean"==typeof e)return!e;if(null==e)return!1;if(0===e)return!0;const r=String(e).toLowerCase();return["false","0",...t].map((e=>e.toLowerCase())).includes(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.mapTrue=t.mapBoolean=t.maybeAnd=t.and=t.or=t.isDisabled=t.isFalse=t.boolToInt=t.toNotBoolean=t.toBoolean=t.isTrue=t.isBoolean=void 0,t.isBoolean=function(e){return"boolean"==typeof e},t.isTrue=r,t.toBoolean=function(e){return!!r(e)||!i(e)&&void 0},t.toNotBoolean=function(e){return!r(e)&&(!!i(e)||void 0)},t.boolToInt=function(e){return r(e)?1:0},t.isFalse=i,t.isDisabled=function(e){return i(e,"no","disable","disabled")},t.or=function(e){return e.some((e=>r(e)))},t.and=function(e){return e.every((e=>r(e)))},t.maybeAnd=function(e){let t;for(const r of e){if(!1===r)return!1;!0===r&&(t=!0)}return t},t.mapBoolean=function(e,t){return r(e)?t(!0):i(e)?t(!1):void 0},t.mapTrue=function(e,t){return r(e)?t():void 0}},79666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shallowClone=t.clone=void 0;const i=r(98553);t.clone=function(e){return null==e?e:JSON.parse((0,i.stringify)(e))},t.shallowClone=function(e){return Array.isArray(e)?[...e]:"object"==typeof e?{...e}:e}},42659:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtElapsedMs=t.fmtAgo=t.msUntilMidnight=t.nextMidnightTs=t.fmtLocalToShort=t.localToDate=t.fmtIsoDate=t.fmtIsoDuration=t.fmtHMS=t.fmtYMDHMS=t.unixtime=t.hence=t.ago=t.thisYear=t.isDate=t.splitHMS=t.fmtDateShort=t.toDate=t.yearMs=t.monthMs=t.weekMs=t.dayMs=t.hourMs=t.minuteMs=t.secondMs=void 0;const i=r(40958),n=r(22573),s=r(30301),o=r(55835),a=r(31586),l=r(39926),u=r(51926),c=r(12168);t.secondMs=1e3,t.minuteMs=60*t.secondMs,t.hourMs=60*t.minuteMs,t.dayMs=24*t.hourMs,t.weekMs=7*t.dayMs,t.monthMs=32*t.dayMs,t.yearMs=365.25*t.dayMs;const d=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}))),h=(0,s.lazy)((()=>new Intl.DateTimeFormat(void 0,{day:"numeric",year:"numeric",month:"short"})));function f(e){return e instanceof Date?e:new Date(e)}function m(e){if(null!=e)return e instanceof Date&&0===e.getHours()&&0===e.getMinutes()&&0===e.getSeconds()?h().format(e):d().format(e)}function p(e){return e instanceof Date}function g(e,t){return new Date((t?.getTime()??Date.now())-e)}t.toDate=f,t.fmtDateShort=m,t.splitHMS=function(e){return(0,o.mapOr)(/^[0:]{1,4}/.exec(e),(t=>[t[0],e.slice(t[0].length)]),(()=>["",e]))},t.isDate=p,t.thisYear=function(){return(new Date).getFullYear()},t.ago=g,t.hence=function(e,t){return g(-e,t)},t.unixtime=function(e){const r=p(e)?e.getTime():(0,a.isNumber)(e)?e:Date.now();return Math.floor(r/t.secondMs)},t.fmtYMDHMS=function(e){const t=f(e);return t.getFullYear()+(0,l.pad2)(t.getMonth()+1)+(0,l.pad2)(t.getDate())+(0,l.pad2)(t.getHours())+(0,l.pad2)(t.getMinutes())+(0,l.pad2)(t.getSeconds())},t.fmtHMS=function(e,r={includeMs:!0}){const i=Math.floor(e/t.hourMs);e-=i*t.hourMs;const n=Math.floor(e/t.minuteMs);e-=n*t.minuteMs;const s=Math.floor(e/t.secondMs),o=Math.floor(e-s*t.secondMs);return(0,l.pad2)(i)+":"+(0,l.pad2)(n)+":"+(0,l.pad2)(s)+(r.includeMs?"."+(0,l.pad3)(o):"")};const y=[{ms:t.yearMs,s:"Y"},{ms:t.weekMs,s:"W"},{ms:t.dayMs,s:"D"},{ms:t.hourMs,s:"H"},{ms:t.minuteMs,s:"M"}];function v(e){if(null==e||e<0)return;let t=e;const r=()=>{const e=t%100;return t=Math.floor(t/100),e},i=10*r(),n=r(),s=r(),o=r(),a=r(),l=r();return new Date(t,l-1,a,o,s,n,i)}function w(){return(new Date).setHours(24,0,0,0)}function S(e,r="ago"){return e<1e3?"just now":(r=(0,n.blank)(r)?"":(0,u.ensurePrefix)(r," "),et.ms<=e)))){const s=Math.floor(e/i.ms);e-=s*i.ms,s>0&&(i.ms>=t.dayMs?r:n).push(s+i.s)}return e>0&&n.push((0,a.toFixedStr)(e/t.secondMs,3)+"S"),"P"+r.join("")+((0,i.isEmpty)(n)?"":"T"+n.join(""))},t.fmtIsoDate=function(e){const t=p(e)?e:new Date(e);return t.getFullYear()+"-"+(0,l.pad2)(t.getMonth()+1)+"-"+(0,l.pad2)(t.getDate())},t.localToDate=v,t.fmtLocalToShort=function(e){return(0,o.map)(v(e),m)},t.nextMidnightTs=w,t.msUntilMidnight=function(){return w()-Date.now()},t.fmtAgo=function(e,t="ago"){return S(Date.now()-e,t)},t.fmtElapsedMs=S},95892:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateToJson=void 0,t.dateToJson=function(e){return{_ctor:Date.name,iso:e.toISOString()}}},12487:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEql=void 0;const i=r(38639),n=r(73872);function s(e,t,r){if(null==r||y(e)||y(t))return null;const i=r.get(e)?.get(t);return"boolean"==typeof i?i:null}function o(e,t,r,i){if(null==r||y(e)||y(t))return;let n=r.get(e);null!=n?n.set(t,i):(n=new WeakMap,n.set(t,i),r.set(e,n))}function a(e,t,r,i){if(null!=r?.comparator)return u(e,t,r,i);const n=l(e,t);return null!==n?n:u(e,t,r)}function l(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t||!y(e)&&!y(t)&&null}function u(e,t,r,i){r??(r={});const u=!1===r.memoize?void 0:r.memoize??(r.memoize=new WeakMap),d=r?.comparator,f=s(e,t,u);if(null!==f)return f;const m=s(t,e,u);if(null!==m)return m;if(d){const r=d(e,t,i);if(!1===r||!0===r)return o(e,t,u,r),r;const n=l(e,t);if(null!==n)return n}const y=n(e);if(y!==n(t))return o(e,t,u,!1),!1;o(e,t,u,!0);const v=function(e,t,r,i){switch(r){case"String":case"Number":case"Boolean":case"Date":return a(e.valueOf(),t.valueOf());case"Promise":case"Symbol":case"function":case"WeakMap":case"WeakSet":return e===t;case"Error":return p(e,t,["name","message","code"],i);case"Arguments":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"Array":return c(e,t,i);case"RegExp":return function(e,t){return e.toString()===t.toString()}(e,t);case"Generator":return function(e,t,r){return c(h(e),h(t),r)}(e,t,i);case"DataView":return c(new Uint8Array(e.buffer),new Uint8Array(t.buffer),i);case"ArrayBuffer":return c(new Uint8Array(e),new Uint8Array(t),i);case"Set":case"Map":return function(e,t,r){if(e.size!==t.size)return!1;if(0===e.size)return!0;const i=[],n=[];return e.forEach((function(e,t){i.push([e,t])})),t.forEach((function(e,t){n.push([e,t])})),c(i.sort(),n.sort(),r)}(e,t,i);case"Temporal.PlainDate":case"Temporal.PlainTime":case"Temporal.PlainDateTime":case"Temporal.Instant":case"Temporal.ZonedDateTime":case"Temporal.PlainYearMonth":case"Temporal.PlainMonthDay":return e.equals(t);case"Temporal.Duration":return e.total("nanoseconds")===t.total("nanoseconds");case"Temporal.TimeZone":case"Temporal.Calendar":return e.toString()===t.toString();default:return g(e,t,i)}}(e,t,y,r);return o(e,t,u,v),v}function c(e,t,r){const i=e.length;if(i!==t.length)return!1;if(0===i)return!0;let n=-1;for(;++n{Object.defineProperty(t,"__esModule",{value:!0}),t.defer=void 0,t.defer=function(e){let t,r,i=!1;const n=function(){if(i){if(null!=r)throw r;return t}try{return i=!0,t=e()}catch(e){throw r=e,e}};return n.prior=()=>t,n.hasPrior=()=>i,n}},41400:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.later=t.delay=t.delayUntil=void 0;const i=r(42659),n=r(35556),s=r(31586),o=r(68708);function a(e,t=!0){return new Promise((r=>{if(e<=0)r();else{const s=setTimeout((()=>r()),Math.ceil(e+.5));e>i.secondMs&&t&&n.isNode&&s.unref?.()}}))}t.delayUntil=function(e){const t=((0,s.gt0)(e)?e:e.getTime())-Date.now();if(t<0){if(t>-500)return;throw new Error("Mr. Fusion not found, cannot time travel back "+-t+"ms")}return a(t).then((()=>t))},t.delay=a,t.later=function(e,t=1){const r=Math.max(1,Math.ceil(t)),s=n.isNode&&r<=1?setImmediate(e):setTimeout(e,r);return n.isBrowser||t<=i.secondMs?s:(0,o.maybeCall)(s,"unref")??s}},50357:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setFieldComparator=t.unshiftObjComparator=t.pushObjComparator=t.functionComparator=t.dateComparator=t.eqlSubset=t.eql=void 0;const i=r(12487),n=r(68708),s=r(34666),o=r(32639);function a(e,t){return(0,i.deepEql)(e,t,{comparator:h})}function l(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime()}function u(e,t){return(0,o.isFunction)(e)&&(0,o.isFunction)(t)?e.toString()===t.toString():void 0}t.eql=a,t.eqlSubset=function(e,t){if(null==e||null==t||(0,s.isPrimitive)(e)||(0,s.isPrimitive)(t))return e===t;if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return!1;for(const r of(0,n.keys)(e))if(!a(e[r],t[r]))return!1;return!0},t.dateComparator=l,t.functionComparator=u;const c=[l,u],d=new Map;function h(e,t,r){if(null==e||null==t)return e===t;if(null!=r){const i=d.get(r);if(null!=i)return i(e,t)??null}for(const r of c){const i=r(e,t);if(null!=i)return i}return null}t.pushObjComparator=function(e){c.push(e)},t.unshiftObjComparator=function(e){c.unshift(e)},t.setFieldComparator=function(e,t){d.set(e,t)}},26905:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorToS=t.errorToArr=t.errorFromJson=t.errorToJson=t.asError=t.shortStack=t.errorErrno=t.errorCode=t.errorName=t.IgnoredErrorNames=t.ErrorDelimiter=void 0;const i=r(40958),n=r(22573),s=r(96249),o=r(31586),a=r(68708),l=r(54993);function u(e){return null==e?void 0:[e?.name,e?.constructor?.name].find((e=>null!=e&&!t.IgnoredErrorNames.includes(e)))?.toString()}function c(e){return null==e?void 0:(0,n.toNotBlank)(e?.code)}function d(e){return null==e?void 0:(0,o.toInt)(e?.errno)}t.ErrorDelimiter=": ",t.IgnoredErrorNames=["Error","String","Object","WrappedError"],t.errorName=u,t.errorCode=c,t.errorErrno=d;const h=/shortStack|errorToVerbose/;function f(...e){const r=[];for(const t of e)null!=t&&(t instanceof Error?r.push(u(t),c(t),t?.message):r.push((0,l.toS)(t)));return(0,i.uniq)((0,i.compactBlankish)((0,s.flatten)((0,i.compact)(r).map((e=>e.split(t.ErrorDelimiter))))))}function m(...e){return f(...e).join(t.ErrorDelimiter)}t.shortStack=function(e,t=9){try{if((0,n.blank)(e)){const t=new Error;Error.captureStackTrace?.(t),e=t.stack}const r=(0,l.toS)(e).split("\n").filter((e=>!(0,n.blank)(e)&&e.trim().startsWith("at ")&&null==h.exec(e))).slice(0,t).map((e=>e.replace(/^\s*at /i,"")));return(0,i.isEmpty)(r)?["(missing stack)"]:r}catch(e){return["Failed to captured stacktrace: "+e]}},t.asError=function(e){if((0,n.blank)(e))throw new Error("undefined error");if(e instanceof Error)return e;if(Array.isArray(e)){const t=e[0];return t instanceof Error?(e.length>1&&(t.errors=e.slice(1)),t):new Error(e.map((e=>(0,l.toS)(e))).filter(n.notBlank).join(", "))}{const t=m(e).replace(/^Error: /i,"");return new Error(t)}},t.errorToJson=function(e){return(0,a.compactValues)({_ctor:Error.name,message:e.message??String(e),stack:e.stack,name:u(e),code:c(e),errno:d(e),...(0,a.omit)(e,"name","message","code","errno")})},t.errorFromJson=function(e){return(0,a.assignFields)(new Error,(0,a.omit)(e,"_ctor"))},t.errorToArr=f,t.errorToS=m},96249:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatten=void 0;const i=r(59455);t.flatten=function(e,t=[]){for(const r of(0,i.toA)(e))if(null!=r)for(const e of(0,i.toA)(r))null!=e&&t.push(e);return t}},57924:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.andList=t.orList=t.fmtList=void 0;const i=r(40958);function n(e,t){return null==(e=(0,i.uniq)((0,i.compactBlanks)(e)))||0===e.length?"":1===e.length?e.join(""):e.slice(0,-1).join(", ")+" "+t.trim()+" "+e[e.length-1]}t.fmtList=n,t.orList=function(e){return n(e,"or")},t.andList=function(e){return n(e,"and")}},73722:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SqWidths=t.SqSizes=t.FitSizeValues=t.FitSizes=void 0;const i=r(50989);t.FitSizes=(0,i.strEnum)("uhd8k","uhd5k","uhd4k","qhd","fhd","hd","wvga","qvga","qqvga"),t.FitSizeValues=t.FitSizes.values,t.SqSizes=(0,i.strEnum)("s480","s240","s120","s60"),t.SqWidths=[60,120,240,480]},41801:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.countIterable=t.sliceIterable=t.isIterable=void 0;const i=r(31586);t.isIterable=function(e){return null!=e&&"string"!=typeof e&&"function"==typeof e[Symbol.iterator]},t.sliceIterable=function(e,t,r){if((0,i.lt0)(t))return[...e].slice(t,r);const n=e[Symbol.iterator]();if((0,i.gt0)(t))for(let e=0;e{Object.defineProperty(exports,"__esModule",{value:!0}),exports.revive=exports.parseJsonObj=exports.parseJSON=exports.parseJSON_=exports.addJsonRevivers=exports.stringifyPretty=exports.stringify=void 0;const DateToJson_1=__webpack_require__(95892),Error_1=__webpack_require__(26905),Maybe_1=__webpack_require__(55835),isFunction_1=__webpack_require__(32639),toS_1=__webpack_require__(54993);function stringify(e,t,r){return JSON.stringify(decycle(e),t,(0,Maybe_1.denull)(r))}function stringifyPretty(e,t=2){return stringify(e,void 0,t)}exports.stringify=stringify,exports.stringifyPretty=stringifyPretty;const Revivers=new Map;function addJsonRevivers(...e){for(const t of e)Revivers.set(t.name,t)}function parseJSON_(e){return retrocycle(JSON.parse(e,reviver))}function parseJSON(e){try{const t=e?.toString().trim();if(null!=t&&t.length>0)return parseJSON_(t)}catch{}}function parseJsonObj(e){if(null!=e)return 0!==(e=(0,toS_1.toS)(e).trim()).length&&e.startsWith("{")&&e.endsWith("}")?parseJSON(e):void 0}function revive(e){const t=Revivers.get(e?._ctor);return null==t?e:t.fromJSON(e)}function reviver(e,t){return revive(t)}function toJSON(e){return(e instanceof Date?(0,DateToJson_1.dateToJson)(e):void 0)??e?.toJSON?.()??(e instanceof Error?(0,Error_1.errorToJson)(e):e)}function decycle(e){const t=[],r=[];return function e(i,n){if((0,isFunction_1.isFunction)(i))return;let s,o,a,l=toJSON(i);if("object"==typeof l&&null!=l){for(const e in l)e.startsWith("__")&&(i===l&&(l={...l}),delete l[e]);for(s=0;snew Date(e.iso)}),exports.parseJSON_=parseJSON_,exports.parseJSON=parseJSON,exports.parseJsonObj=parseJsonObj,exports.revive=revive},56409:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Latch=void 0;let i=0;t.Latch=class{constructor(e=i++){this.id=e,this[r]="Latch",this._state="pending",this.promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}toLogJSON(){return{_ctor:"Latch",id:this.id,state:this.state()}}resolve(){return this.isPending()&&(this._resolve(),this._state="resolved"),this}reject(e){return this.isPending()&&(this._reject(e),this._state="rejected",this.error=e),this}observe(e){return e.then((()=>this.resolve()),(e=>this.reject(e))),this}observeQuietly(e){return e.then((()=>this.resolve()),(()=>this.resolve())),this}isPending(){return"pending"===this._state}isSettled(){return!this.isPending()}isResolved(){return"resolved"===this._state}isRejected(){return"rejected"===this._state}state(){return this._state}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e),this}},r=Symbol.toStringTag},30301:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.lazy=void 0;const i=r(40958),n=r(50357),s=r(31586),o=r(65812);t.lazy=function(e,t){let r,a;const l=[];function u(){return u.isStale()&&u.setResult(e()),a}return u.vacuum=function(){u.isStale()&&u.unset()},u.setResult=function(e){return r=Date.now(),async function(e,r){if((0,i.isEmpty)(l))return;const s=await e,a=await r;if(!(0,n.eql)(s,a))for(const e of l)e(a);null!=t&&t>0&&void 0!==a&&(0,o.setUnrefTimeout)((()=>u.vacuum()),t)}(a,e),a=e},u.isStale=function(){return null==r||(0,s.gt0)(t)&&r+t{Object.defineProperty(t,"__esModule",{value:!0}),t.deleteIf=t.getOrSet=void 0,t.getOrSet=function(e,t,r){if(null==t)throw new Error("null key");if(e.has(t))return e.get(t);{const i=r();return null!=i&&e.set(t,i),i}},t.deleteIf=function(e,t){for(const[r,i]of e.entries())t(r,i)&&e.delete(r)}},55835:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nulled=t.denull=t.firstDefined=t.allDefined=t.ifDefined=t.defined=t.map2Or=t.mapOr=t.orElse=t.map3=t.map2=t.mapTry=t.map=void 0;const i=r(42279),n=r(54993);function s(e,t){return null==e?void 0:t(e)}function o(e,t,r){return null==e||null==t?void 0:r(e,t)}function a(e,t){return null!=e?e:(0,i.tot)(t)}function l(e){return null!=e}t.map=s,t.mapTry=function(e,t){try{return s(e(),t)}catch{return}},t.map2=o,t.map3=function(e,t,r,i){return null==e||null==t||null==r?void 0:i(e,t,r)},t.orElse=a,t.mapOr=function(e,t,r){return null!=e?t(e):(0,i.tot)(r)},t.map2Or=function(e,t,r,i){return a(o(e,t,r),i)},t.defined=l,t.ifDefined=function(e,t){return void 0===e?void 0:t(e)},t.allDefined=function(e){return null!=e&&e.every(l)},t.firstDefined=function(...e){return e.find(l)},t.denull=function(e){return null==e||"null"===(0,n.toS)(e)?void 0:e},t.nulled=function(e){return null==e?null:e}},39426:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MetaError=void 0;const i=r(68708);class n extends Error{constructor(e,t){super(e),this.message=e,(0,i.assignFields)(this,t)}}t.MetaError=n},23838:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupByValues=t.groupBy=t.MultiMap=void 0;const i=r(40958),n=r(76790),s=r(50357),o=r(98553),a=r(49769),l=r(55835),u=r(51926),c=r(59455);class d{static fromJSON(e){const t=new d;for(const[r,i]of Object.entries(e))t.add(r,...i);return t}constructor(e=new Map){this.store=e}get(e){return this.store.get(e)}has(e){return this.store.has(e)}includes(e,t){return!0===this.store.get(e)?.includes(t)}keyCount(){return this.store.size}isEmpty(){for(const e of this.store.values())if(e.length>0)return!1;return!0}valueCount(){return(0,i.sum)([...this.store.values()].map((e=>e.length)),(e=>e))}add(e,...t){const r=(0,a.getOrSet)(this.store,e,(()=>[]));return r.push(...t),r}addUniq(e,...t){return(0,i.pushUniq)((0,a.getOrSet)(this.store,e,(()=>[])),...t)}set(e,t){this.store.set(e,t)}delete(e,t){if(null==t)return this.store.delete(e);{const r=this.store.get(e);if(null==r)return!1;{const i=r.filter((e=>!(0,s.eql)(e,t)));return 0===i.length?this.store.delete(e):this.store.set(e,i),r.length!==i.length}}}clear(){return this.store.clear(),this}keys(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield t)}()}values(){const e=this;return function*(){for(const[,t]of e.store.entries())t.length>0&&(yield t)}()}vacuum(e=((e,t)=>(0,i.uniq)(t))){for(const t of this.keys()){const r=this.store.get(t),n=null==r?[]:e(t,r);(0,i.isEmpty)(n)?this.store.delete(t):this.store.set(t,n)}}valuesFlat(){const e=this;return function*(){for(const[,t]of e.store.entries())if(t.length>0)for(const e of t)yield e}()}entriesArray(){return[...this.store.entries()].filter((([,e])=>(0,i.isNotEmpty)(e)))}entries(){const e=this;return function*(){for(const[t,r]of e.store.entries())r.length>0&&(yield[t,r])}()}tuples(){const e=this;return function*(){for(const[t,r]of e.store.entries())for(const e of(0,c.toA)(r))null!=e&&(yield[t,e])}()}filterInPlace(e){let t=!1;for(const[r,n]of this.store.entries()){const s=(0,i.findIndexes)(n,(t=>!e(r,t,n)));if(s.length>0){t=!0;for(const e of s.reverse())n.splice(e,1)}0===n.length&&this.store.delete(r)}return t}inverse(){const e=new d;for(const[t,r]of this.store.entries())for(const i of r)e.add(i,t);return e}findKeyByTuple(e){for(const[t,r]of this.tuples())if(e(t,r))return t}filterKeysByTuple(e){const t=[];for(const[r,i]of this.entries())i.some((t=>e(r,t)))&&t.push(r);return t}toJSON(){const e={};for(const[t,r]of this.entries())e[(0,u.isString)(t)?t:(0,o.stringify)(t)]=r;return e}}function h(e,t){const r=new d;return e.forEach((e=>(0,l.map)(t(e),(t=>r.add(t,e))))),r}t.MultiMap=d,t.groupBy=h,t.groupByValues=function(e,t){const r=h(e,t);return(0,n.sortBy)((0,c.toA)(r.values()),(e=>t(e[0])))}},35556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNode=t.isBrowser=void 0;const r=globalThis;t.isBrowser="object"==typeof r?.window&&"object"==typeof r?.document,t.isNode="string"==typeof r?.process?.versions?.node},31586:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fmtPct=t.pct=t.times=t.clamp=t.base10Ceil=t.base2Ceil=t.sigFigs=t.toPrecisionMaybe=t.toPrecision=t.toFixedStr=t.toFixed=t.round=t.numericOr=t.mapNumericOr=t.map2Numeric=t.mapNumeric=t.id=t.mapFloat=t.mapInt=t.toGte0=t.gte0=t.lte0=t.gtOrElse=t.firstGt0=t.gt0=t.lt0=t.toGt0f=t.toGt0=t.toFloat=t.toInt=t.isToNumber=t.trunc=t.closeTo=t.max_=t.within=t.approximates=t.safeDivide=t.absdiff=t.diff=t.finiteOrElse=t.gte=t.gt=t.lte=t.lt=t.mapFinite=t.isBigInt=t.isNumeric=t.isDigits=t.isInvalidNumber=t.isNumber=void 0,t.toSum=t.roundEven=void 0;const i=r(76790),n=r(22573),s=r(42279),o=r(54993);function a(e){return"number"==typeof e&&isFinite(e)}t.isNumber=a,t.isInvalidNumber=function(e){return"number"==typeof e&&(isNaN(e)||!isFinite(e))};const l=/^\d+$/;t.isDigits=function(e){return null!=(0,o.toS)(e).match(l)};const u=/[^-.\d\s]/;function c(e){return"bigint"==typeof e}function d(e,t){return a(e)?t(e):void 0}t.isNumeric=function(e){return null==(0,o.toS)(e).match(u)&&null!=v(e)},t.isBigInt=c,t.mapFinite=d;const h=e=>(t,r)=>a(t)&&a(r)&&e(t,r);function f(e,r,n){return!(null==n||!a(n))&&([e,r]=(0,i.sort)([e,r]),(0,t.lte)(e,n)&&(0,t.gte)(r,n))}function m(e){if(!a(e))return;const t=Math.trunc(e);return 0===t?Math.abs(t):t}function p(e){return"function"==typeof e?.toNumber}function g(e,t){if((0,n.blank)(e))return t.defaultValue;if(a(e))return t.nton(e);if(c(e)){if(e>BigInt(Number.MAX_SAFE_INTEGER)||em(e),ston:parseInt,...t})}function v(e,t){return g(e,{defaultValue:void 0,nton:e=>e,ston:parseFloat,...t})}function w(e){return a(e)&&e>0}function S(e){return a(e)&&e>=0}function b(e,t){return a(e)?t(e):void 0}function P(e){return a(e)?e<0?-Math.round(-e):Math.round(e):0}function _(e,t){if(null==e)return 0;const r=Math.pow(10,t);return P(e*r)/r}function E(e,t,r){if(e>t||!a(e)||!a(t))throw new Error(`invalid clamp(${e}, ${t}, ${r})`);return a(r)?rt?t:r:(e+t)/2}t.lt=h(((e,t)=>ee<=t)),t.gt=h(((e,t)=>e>t)),t.gte=h(((e,t)=>e>=t)),t.finiteOrElse=function(e,t){return a(e)?e:t},t.diff=function(e,t){return a(e)&&a(t)?e-t:void 0},t.absdiff=function(e,t){return a(e)&&a(t)?Math.abs(e-t):void 0},t.safeDivide=function(e,t){return e/(0===t?1e-8:t)},t.approximates=function(e,t,r=.95){if(!a(e)||!a(t))return!1;if(e===t)return!0;if(r>=1)return!1;const i=(0===t?1e-5:t)*(1-r);return f(t-i,t+i,e)},t.within=f,t.max_=function(...e){let t;for(const r of e)a(r)&&(null==t||t0?t:void 0},t.toGt0f=function(e){const t=v(e);return null!=t&&t>0?t:void 0},t.lt0=function(e){return a(e)&&e<0},t.gt0=w,t.firstGt0=function(...e){for(const t of e){if(w(t))return t;const e=y(t);if(w(e))return e}},t.gtOrElse=function(e,t){return a(e)&&a(t)&&e>t?e:void 0},t.lte0=function(e){return a(e)&&e<=0},t.gte0=S,t.toGte0=function(e){return S(e)?e:void 0},t.mapInt=function(e,t){const r=y(e);return null==r?void 0:t(r)},t.mapFloat=function(e,t){const r=v(e);return null==r?void 0:t(r)},t.id=function(e){const t=y(e);return w(t)?String(t):void 0},t.mapNumeric=b,t.map2Numeric=function(e,t,r){return b(e,(e=>b(t,(t=>r(e,t)))))},t.mapNumericOr=function(e,t,r){return a(e)?t(e):r},t.numericOr=function(e,t){return a(e)?e:(0,s.tot)(t)},t.round=P,t.toFixed=function(e,t){try{return b(e,(e=>P(e*10**t)/10**t))}catch(e){return}},t.toFixedStr=function(e,t){return e.toFixed(t).replace(/\.0*$|(?<=\d\.\d+)0+$/,"")},t.toPrecision=_,t.toPrecisionMaybe=function(e,t){return d(e,(e=>_(e,t)))},t.sigFigs=function(e,t){if(!a(e)||0===e||0===t)return 0;const r=t-P(Math.ceil(Math.log10(Math.abs(e)))),i=Math.pow(10,Math.abs(r));return r<0?P(e/i)*i:P(e*i)/i},t.base2Ceil=function(e){return Math.pow(2,Math.ceil(Math.log2(e)))},t.base10Ceil=function(e){return Math.pow(10,Math.ceil(Math.log10(e)))},t.clamp=E,t.times=function(e,t){if(!w(e))return[];const r=Math.round(e);return r<=0?[]:[...Array(r)].map(((e,r)=>t(r)))},t.pct=function(e,t){return E(0,100,w(t)?P(100*(w(e)?e:0)/t):0)},t.fmtPct=function(e,t){const r=Math.round(e??-1);return null==t||f(0,t,r)?r+"%":void 0},t.roundEven=function(e){return 2*Math.round(e/2)},t.toSum=function(...e){let t=0;for(const r of e){if(!a(r))return;t+=r}return t}},68708:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flattenObject=t.firstValueCaseInsensitive=t.maybeCall=t.allKeys=t.filter=t.onlyReqValued=t.mapReqValued=t.reqValuedOrElse=t.toReqValued=t.allKeysDefined=t.isReqValued=t.omit=t.pluckDeep=t.pluck=t.pickDeep=t.pickFirst=t.pickNonBlank=t.pickCompact=t.pick=t.mergeObjectsDeep=t.mapFields=t.compactBlankValues=t.compactValuesDeep=t.compactValues=t.definedValues=t.assignAllFields=t.assignUndefinedFields=t.assignFields=t.fromEntries=t.entries=t.values=t.mapCompactObj=t.notEmptyObj=t.isEmptyObj=t.keysWithDefinedValues=t.keys=t.tap=t.isObject=void 0;const i=r(40958),n=r(76790),s=r(22573),o=r(32639),a=r(55835),l=r(31586),u=r(34666),c=r(38453);function d(e){return null!=e&&"object"==typeof e}function h(e){return null==e||"object"!=typeof e?[]:Object.keys(e).filter((t=>"string"==typeof t&&(null==e.propertyIsEnumerable||!0===e.propertyIsEnumerable(t))))}function f(e){if(null==e||"object"!=typeof e)return!0;for(const t in e)if(void 0!==e[t])return!1;return!0}function m(e){return!f(e)}function p(e){return h(e).map((t=>e[t]))}function g(e){return null==e?[]:Object.entries?.(e)??h(e??{}).map((t=>[t,e[t]]))}function y(e,t){if(null==e)return t;for(const r of e)if(null!=r&&Array.isArray(r)){const[e,i]=r;null!=e&&void 0!==i&&("object"!=typeof t&&(t={}),t[e]=i)}return t}function v(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>null!=e)))return e;const r=t.filter((([,e])=>null!=e));return(0,i.isEmpty)(r)?void 0:y(r)}function w(e,t,r={}){return y((0,i.compact)((0,n.sort)(h(e)).map((r=>t(r,e[r])))).filter((([e,t])=>null!=e&&void 0!==t)),r)}function S(...e){const t=(0,i.compact)(e);if(0===t.length)return;if(1===t.length)return t[0];const r=t.filter(d);if(t.length!==r.length)return t;const n={};for(const e of(0,i.uniq)((0,i.flatMap)(r,h)))n[e]=S(...r.map((t=>t[e])));return n}function b(e,t){if(!d(e)||(0,s.blank)(t))return;if(t in e)return{key:t,value:e[t]};const r=new RegExp("^"+t.replace(/\*/g,".*")+"$","i");for(const t of h(e))if(r.test(t))return{key:t,value:e[t]}}function P(e){return p(e).every((e=>null!=e))}t.isObject=d,t.tap=function(e,t){return null!=t?t(e):"string"==typeof e?console.log(e):console.dir(e,{depth:null}),e},t.keys=h,t.keysWithDefinedValues=function(e){return null==e?[]:h(e).filter((t=>void 0!==e[t]))},t.isEmptyObj=f,t.notEmptyObj=m,t.mapCompactObj=function(e,t){const r=v(e);return m(r)?t(r):void 0},t.values=p,t.entries=g,t.fromEntries=y,t.assignFields=function(e,t,r){if(null==t)return e;for(const[i,n]of g(t))!0!==r?.omitKeys?.includes(i)&&(null==n&&!0!==r?.assignNullish||(e[i]=n));return e},t.assignUndefinedFields=function(e,t,...r){if(null==t)return e;for(const i of r){const r=t[i];void 0!==r&&void 0===e[i]&&(e[i]=r)}return e},t.assignAllFields=function(e,t){for(const[r,i]of g(t??{}))e[r]=i;return e},t.definedValues=function(e){if(null==e)return;const t=g(e);if(t.every((([,e])=>void 0!==e)))return e;const r=t.filter((([,e])=>void 0!==e));return(0,i.isEmpty)(r)?void 0:y(r)},t.compactValues=v,t.compactValuesDeep=function e(t){if(null!=t){if((0,u.isPrimitive)(t))return t;if(Array.isArray(t))return(0,i.compact)(t.map(e));{const r=(0,i.compact)(g(t).map((([t,r])=>(0,a.map)(e(r),(e=>[t,e])))));return 0===r.length?void 0:y(r)}}},t.compactBlankValues=function(e){if(null==e)return;const t=g(e).filter((([e,t])=>null!=e&&(0,s.notBlank)(t)));return(0,i.isEmpty)(t)?void 0:y(t)},t.mapFields=w,t.mergeObjectsDeep=S,t.pick=function(e,...t){if(null==e)return e;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickCompact=function(e,...t){if(null==e)return;const r={};for(const i of t)void 0!==e[i]&&(r[i]=e[i]);return r},t.pickNonBlank=function(e,...t){if(null==e)return e;const r={};for(const i of t){const t=e[i];(0,s.notBlank)(t)&&(r[i]=t)}return r},t.pickFirst=function(e,t,r=a.defined){if(null!=e)for(const i of t)if(r(e[i]))return e[i]},t.pickDeep=function e(t,...r){if(null==t)return t;if(Array.isArray(t))return t.map((t=>e(t,...r)));const i={};function n(e,t){if(null==t)return;const r=i[e];i[e]=null==r?t:S(r,t)}for(const i of r){const[r,o]=(0,c.splitFirst)(i,"."),a=b(t,r);null!=a?.value&&n(a.key,(0,s.blank)(o)?a.value:e(a.value,o))}for(const i of h(t))((0,l.toInt)(i)??-1)>=0&&n(i,e(t[i],...r));return i},t.pluck=b,t.pluckDeep=function e(t,r){if(null==t||(0,s.blank)(r))return;if(Array.isArray(t)){const n=(0,i.compact)(t.map((t=>e(t,r))));return(0,i.isEmpty)(n)?void 0:{key:n[0].key,value:(0,i.flatMap)(n,(e=>e.value))}}const[n,o]=(0,c.splitFirst)(r,"."),a=b(t,n);if(null==a)return;if((0,s.blank)(o))return a;const l=e(a.value,o);return null==l?void 0:{key:a.key+"."+l.key,value:l.value}},t.omit=function(e,...t){if(null==e||t.every((t=>(0,s.blank)(e[t]))))return e;const r=g(e).filter((([e])=>!t.includes(e)));return(0,i.isEmpty)(r)?void 0:y(r)},t.isReqValued=P,t.allKeysDefined=function(e,...t){return null!=e&&t.every((t=>null!=e[t]))},t.toReqValued=function(e){return P(e)?e:void 0},t.reqValuedOrElse=function(e){return P(e)?e:void 0},t.mapReqValued=function(e,t){return P(e)?t(e):void 0},t.onlyReqValued=function(e){return e.filter(P)},t.filter=function(e,t){return null==e?e:y(g(e).filter((([e,r])=>t(e,r))))},t.allKeys=function(e){const t=h(e);for(;null!=(e=Reflect.getPrototypeOf(e));)t.push(...Reflect.ownKeys(e).filter((e=>"string"==typeof e)));return(0,i.uniq)(t)},t.maybeCall=function(e,t,...r){const i=e?.[t];return(0,o.isFunction)(i)?i.bind(e)(...r):void 0},t.firstValueCaseInsensitive=function(e,t){if((0,s.blank)(t))return;if(null!=e[t])return e[t];const r=t.toLowerCase().normalize();for(const t of h(e))if(r===t.toLowerCase().normalize()&&null!=e[t])return e[t]},t.flattenObject=function e(t){if(Array.isArray(t))return t.map(e);if("object"!=typeof t)return t;const r=w(t,((t,r)=>[t,e(r)])),i=p(r);return 1===i.length?i[0]:r}},97790:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.opt=t.isOpt=t.Some=t.None=void 0,function(e){e.isDefined=!1,e.isEmpty=!0,e.get=()=>{},e.exists=()=>!1;const t=()=>e;e.map=t,e.flatMap=t,e.filter=t,e.forEach=t,e.getOrElse=e=>e(),e.orElse=e=>s(e()),e.zip1=t,e.zip2=t,e.zip3=t}(r||(r={})),t.None=r;class i{constructor(e){this.a=e,this.isDefined=!0,this.isEmpty=!1}get(){return this.a}exists(e){return e(this.a)}map(e){return new i(e(this.a))}flatMap(e){const t=e(this.a);return n(t)?t:s(t)}filter(e){return s(e(this.a)?this.a:void 0)}forEach(e){return e(this.a),this}getOrElse(){return this.a}orElse(){return this}zip1(e,t){return s(e).flatMap((e=>t(this.a,e)))}zip2(e,t,r){return s(e).flatMap((e=>s(t).flatMap((t=>r(this.a,e,t)))))}zip3(e,t,r,i){return s(e).flatMap((e=>s(t).flatMap((t=>s(r).flatMap((r=>i(this.a,e,t,r)))))))}}function n(e){return e instanceof i||e===t.None}function s(e){return n(e)?e:null!=e?new i(e):t.None}t.Some=i,t.isOpt=n,t.opt=s},39926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pad4=t.pad3=t.pad2=t.padNumeric=t.leftPad=t.padding=void 0;const i=r(31586),n=r(54993),s={};function o(e,t){if(t<1)return"";if(!(0,i.gte)(s[e]?.length,t)){let r=s[e]??e;for(;r.length{Object.defineProperty(t,"__esModule",{value:!0}),t.pluralize=void 0;const i=r(22573),n=new Map([["child","children"],["photo","photos"],["video","videos"]]),s=/([sxz]|ss|sh|ch)$/,o=/[^aeiou]y$/,a=/[aeiou]y$/,l=/is$/;t.pluralize=function(e){if((0,i.blank)(e))return e;const t=n.get(e);return null!=t?t:null!=e.match(s)?e+"es":null!=e.match(o)?e.replace(/y$/i,"ies"):null!=e.match(a)?e+"s":e.endsWith("o")?e+"es":null!=e.match(l)?e.replace(l,"es"):e+"s"}},34666:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.cmpArr=t.gt=t.gte=t.lte=t.lt=t.cmp=t.CmpReverseFlag=t.isPrimitiveArray=t.mapPrimitiveOr=t.mapPrimitive=t.isPrimitive=void 0;const i=r(40958),n=r(54993),s=["number","string","boolean"];function o(e){return-1!==s.indexOf(typeof e)}t.isPrimitive=o,t.mapPrimitive=function(e,t){return o(e)?t(e):void 0},t.mapPrimitiveOr=function(e,t,r){return o(e)?t(e):r()},t.isPrimitiveArray=function(e){return Array.isArray(e)&&e.every(o)};const a=["boolean","number","bigint","symbol","string","object","function"];function l(e,r){if(null==e&&null==r)return 0;if(null==e)return-1;if(null==r)return 1;const i=typeof e,s=typeof r;if(!("string"!==i&&"symbol"!==i||"string"!==s&&"symbol"!==s)){const i=(0,n.toS)(e),s=(0,n.toS)(r),o=i.localeCompare(s);return i[0]===t.CmpReverseFlag&&s[0]===t.CmpReverseFlag?-o:o}return Array.isArray(e)&&Array.isArray(r)?u(e,r):i!==s?a.indexOf(i)-a.indexOf(s):e>r?1:e=0},t.gt=function(e,t){return l(e,t)>0},t.cmpArr=u},20214:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.thenIf=t.isPromise=t.isPromiseLike=t.thenTap=t.thenCollect=t.thenMap=void 0;const i=r(59455);function n(e){return null!=e&&"object"==typeof e&&"function"==typeof e.then}t.thenMap=async function(e,t){const r=await e;return null==r?void 0:t(r)},t.thenCollect=async function(e,t){const r=[];for(const n of(0,i.toA)(await e))if(null!=n){const e=await n;if(null!=e){const i=await t(e);null!=i&&r.push(i)}}return r},t.thenTap=async function(e,t=console.dir.bind(console)){const r=await e;return await t(r),r},t.isPromiseLike=n,t.isPromise=function(e){return n(e)&&"function"==typeof e.catch&&"function"==typeof e.finally},t.thenIf=async function({p:e,predicate:t,ifTrue:r}){const i=await e;return t(i)?r(i):void 0}},57153:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromiseStates=void 0;const i=r(50989);t.PromiseStates=(0,i.strEnum)("pending","resolved","rejected")},30976:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pickWeightedRandom=t.sample=t.shuffle=t.pickRandom=t.randomChars=t.RandomChars=t.LowercaseChars=t.NumericChars=t.randomFloat=t.randomBoolean=t.randomInts=t.randomInt=void 0;const i=r(40958),n=r(31586);function s(e,t){return Math.floor(Math.random()*(t-e))+e}function o(e,t,r){return null==r||0===r.length?s(e,t):a(e,t,1,r)[0]}function a(e,t,r,i){if(e=Math.ceil(e),(t=Math.floor(t)) ${t}`);const n=t-e,o=new Set(i??[]);if(t===e&&0===n&&0===o.size&&1===r)return[e];const a=n-o.size;if(r>a)throw new Error(`randomInts(): cannot satisfy request: ${JSON.stringify({max:t,min:e,range:n,size:r,slotsRemaining:a})}`);const l=new Set;for(;l.size0;e--){const r=Math.floor(Math.random()*(e+1));e!==r&&([t[e],t[r]]=[t[r],t[e]])}return t},t.sample=function(e,t){const r=[];for(const i of a(0,e.length,t))r.push(e[i]);return r},t.pickWeightedRandom=function(e){if((0,i.isEmpty)(e))return;const t=e.filter((e=>(0,n.gt0)(e.priority)));let r=l(0,(0,i.sum)(t,(e=>e.priority)));return t.find((e=>(r-=e.priority,r<=0)))}},5670:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceNames=void 0;const i=r(50989);t.ServiceNames=(0,i.strEnum)("main","desktop","web","sync","info","test","logcat","logtail","list","billing","worker","test-worker")},38453:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.splitFirst=void 0,t.splitFirst=function(e,t){const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]}},50989:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.strEnum=void 0;const i=r(68708),n=r(42279);t.strEnum=function(...e){const t=Object.freeze(e),r=(0,i.fromEntries)(t.map(((e,t)=>[e,t]))),s={};for(const e of t)s[e]=e;const o=e=>null!=e?r[e]:void 0,a=e=>null!=o(e);return{...s,values:t,length:t.length,has:a,includes:a,getCI:e=>{if(null!=e)return e=e.toLowerCase(),t.find((t=>t.toLowerCase()===e))},pick:(...e)=>t.filter((t=>e.includes(t))),omit:(...e)=>t.filter((t=>!e.includes(t))),indexOf:o,ordinal:e=>o(e)??t.length,validOrElse:(e,t)=>a(e)?e:(0,n.tot)(t),mapValid:(e,t)=>a(e)?t(e):void 0,cmp:(e,t)=>{const r=o(e),i=o(t);return null==r||null==i?void 0:r>i?1:r{const r=o(e);return null==r?void 0:t[r]}}}},51926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.includesIgnoreCase=t.firstIgnoreCase=t.equalsIgnoreCase=t.splitLast=t.compressWhitespace=t.replaceAll=t.eqlStrings=t.wrap=t.leftIndexOf=t.trimLastNewline=t.newlineRe=t.ellipsize=t.ensurePrefixSuffix=t.ensureSuffix=t.ensurePrefix=t.stripPrefixSuffix=t.stripSuffix=t.stripPrefixes=t.stripPrefix=t.trimRight=t.charArr=t.substr=t.strslice=t.strlen=t.charAt=t.isBMP=t.isBuffer=t.isString=void 0;const i=r(40958),n=r(17586),s=r(22573),o=r(96249),a=r(41801),l=r(31586),u=r(59455),c=r(54993);function d(e){for(let t=e.length-1;t>=0;t--)if(e.charCodeAt(t)!==e.codePointAt(t))return!1;return!0}let h;function f(){if(void 0===h)try{h=new Intl.Segmenter(void 0,{granularity:"grapheme"})}catch{h=null}return h??null}function m(e,t,r){if(d(e))return t<0&&(t+=e.length),e.slice(t,r);{const i=f();return null!=i?(0,a.sliceIterable)(i.segment(e),t,r).map((e=>e.segment)).join(""):[...(0,c.toS)(e)].slice(t,r).join("")}}function p(e){const t=f();return null==t?[...(0,c.toS)(e)]:[...t.segment(e)].map((e=>e.segment))}function g(e,t){const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.startsWith(i)?r.slice(i.length):r}function y(e,t){if(null==t)return e;const r=(0,c.toS)(e),i=(0,c.toS)(t);return i.length>0&&r.endsWith(i)?r.slice(0,-i.length):r}function v(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.startsWith(t)?e:t+e)}function w(e,t){return null==t||""===t?e:(e=(0,c.toS)(e),t=(0,c.toS)(t),e.endsWith(t)?e:e+t)}function S(e,t,r){null==r&&(r=e.length);for(let i=r;i>=0;i--)if(m(e,i).startsWith(t))return i;return-1}function b(e,t,{normalize:r=!0}={}){if(null==e||null==t)return!1;const i=(0,c.toS)(e),n=(0,c.toS)(t);return i.length===n.length&&(i===n||i.toLowerCase()===n.toLowerCase()||"function"==typeof i.localeCompare&&0===(r?i.normalize():i).localeCompare(r?n.normalize():n,void 0,{sensitivity:"base"}))}function P(e,t){return(0,i.isEmpty)(e)||(0,s.blank)(t)?void 0:e.find((e=>b(t,e)))}t.isString=function(e){return"string"==typeof e},t.isBuffer=function(e){return"Buffer"===e?.constructor?.name},t.isBMP=d,t.charAt=function(e,t){if(d(e)){if((t=Math.trunc(t)||0)<0&&(t+=e.length),t<0||t>=e.length)return;return e[t]}return(0,n.at)([...(0,c.toS)(e)],t)},t.strlen=function(e){const t=f();return null!=t?(0,a.countIterable)(t.segment(e)):d(e)?e.length:[...e].length},t.strslice=m,t.substr=function(e,t,r){return d(e)?e.slice(t,null==r?void 0:t+r):m(e,t,null==r?void 0:t+r)},t.charArr=p,t.trimRight=function(e){return(0,c.toS)(e).replace(/\s+$/,"")},t.stripPrefix=g,t.stripPrefixes=function e(t,r){if(null==t)return"";const i=(0,c.toS)(t);for(const t of r)if(null!=t&&t.length>0&&i.startsWith(t))return e(i.slice(t.length),r);return i},t.stripSuffix=y,t.stripPrefixSuffix=function(e,{prefix:t,suffix:r}){return y(g(e,t),r)},t.ensurePrefix=v,t.ensureSuffix=w,t.ensurePrefixSuffix=function(e,{prefix:t,suffix:r}){return w(v(e,t),r)},t.ellipsize=function(e,t=80,r=0){if(null==e)return"";t=Math.max(1,(0,l.round)(t)),r=(0,l.clamp)(0,t-1,(0,l.round)(r));const i=p(e);return i.length<=t?i.join(""):i.slice(0,t-1-r).join("")+"…"+(r>0?i.slice(-r).join(""):"")},t.newlineRe=function(){return/\r?\n/g},t.trimLastNewline=function(e){return(0,c.toS)(e).replace(/\r?\n$/,"")},t.leftIndexOf=S,t.wrap=function e(t,r){const i=r?.maxLineLen??80,n=r?.prefix??"";if(Array.isArray(t)||t.includes("\n")){const i=(0,o.flatten)((0,u.toA)(t).map((e=>(0,c.toS)(e).split(/\r?\n/g))));return(0,o.flatten)(i.map((t=>e(t,r))))}if((t=v((0,c.toS)(t),n).trim()).length<=i)return[t];const s=S(t," ",i);if(s>n.length)return[m(t,0,s),...e(m(t,s+1),r)];{const i=t.indexOf(" ",n.length+1);return i>0&&i{Object.defineProperty(t,"__esModule",{value:!0}),t.thenOrTimeoutAs=t.thenOrTimeoutAtError=t.thenOrTimeoutError=t.thenOrOnTimeout=t.thenOrTimeoutAt=t.thenOrTimeout=t.toNotTimeout=void 0;const i=r(42659),n=r(68708),s=r(42279),o=r(83104),a=r(85556);async function l(e,t,r=!0){return(t=Math.round(t??0))<=0?e:new Promise((async(r,i)=>{let n=!0;const s=setTimeout((()=>{n&&(n=!1,r(o.Timeout))}),t);try{s.unref?.();const t=await e;n&&(n=!1,r(t))}catch(e){n&&(n=!1,i(e))}finally{clearTimeout(s)}}))}async function u(e,t,r=!0){const n=await l(e,t,r);if(n===o.Timeout)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(t)+")");return n}t.toNotTimeout=function(e){return e===o.Timeout?void 0:e},t.thenOrTimeout=l,t.thenOrTimeoutAt=async function(e,t,r=!0){const i=t-Date.now();return i<=0?o.Timeout:l(e,i,r)},t.thenOrOnTimeout=async function(e,t,r){return t<=0?e:new Promise((async(i,s)=>{let o=!0;try{const a=setTimeout((async()=>{if(o){o=!1;try{i(await r())}catch(e){s(e)}}}),t);(0,n.maybeCall)(a,"unref");const l=await e;o&&(o=!1,clearTimeout(a),i(l))}catch(e){o&&(o=!1,s(e))}}))},t.thenOrTimeoutError=u,t.thenOrTimeoutAtError=async function(e,t,r=!0){const n=t-Date.now();if(n<=0)throw new a.TimeoutError("timeout ("+(0,i.fmtHMS)(n)+")");return u(e,n,r)},t.thenOrTimeoutAs=async function({f:e,timeoutMs:t,as:r,unref:i=!0}){const n=await l(e,t,i);return n===o.Timeout?(0,s.tot)(r):n}},42279:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NoOp=t.firstDefinedSuccess=t.firstDefinedThunk=t.tol=t.tot=void 0;const i=r(32639);t.tot=function(e){return(0,i.isFunction)(e)?e():e},t.tol=async function(e){return(0,i.isFunction)(e)?e():e},t.firstDefinedThunk=function(e){for(const t of e){const e=t();if(null!=e)return e}},t.firstDefinedSuccess=function(e){for(const t of e)try{const e=t();if(null!=e)return e}catch{}},t.NoOp=()=>{}},83104:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Timeout=void 0,t.Timeout=Symbol("timeout")},85556:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeoutError=void 0;class r extends Error{}t.TimeoutError=r},12168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.plurMetric=t.plur=t.pixels2size=t.SizeDescriptions=t.megapixels=t.MP=t.fmtMebi=t.fmtBytes=t.fmtMB=t.TiB=t.GiB=t.MiB=t.KiB=t.TB=t.GB=t.MB=t.KB=t.fmtToInt=t.fmt=t.bytesToMB=t.decimalSep=t.thousandsSep=void 0;const i=r(22573),n=r(30301),s=r(31586),o=r(46891),a=r(50989),l=r(51926),u=(0,n.lazy)((()=>new Intl.NumberFormat));function c(e){return u().format(e)}t.thousandsSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1111),"1","").charAt(0))),t.decimalSep=(0,n.lazy)((()=>(0,l.replaceAll)(u().format(1.1),"1","").charAt(0))),t.bytesToMB=function(...e){let r=0;for(const i of e)(0,s.isNumber)(i)&&(r+=i/t.MB);return(0,s.round)(r)},t.fmt=c,t.fmtToInt=function(e){return(0,i.mapNotBlank)(e,(e=>(0,s.toInt)((0,l.replaceAll)(e,(0,t.thousandsSep)(),""))))},t.KB=1e3,t.MB=1e3*t.KB,t.GB=1e3*t.MB,t.TB=1e3*t.GB,t.KiB=1024,t.MiB=1024*t.KiB,t.GiB=1024*t.MiB,t.TiB=1024*t.GiB;const d=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],h=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];function f(e,t=3){if(0===e)return"0";if(!(0,s.isNumber)(e))return"-";const r=Math.floor(Math.log10(e)),i=Math.floor(r/3),n=Math.pow(10,3*i),o=d[i];return(0,s.sigFigs)(e/n,t)+" "+o}t.fmtMB=function(e,r=3){return f(e*t.MB,r)},t.fmtBytes=f,t.fmtMebi=function(e,t=3){if(0===e)return"0";const r=Math.floor(Math.log2(e)),i=Math.floor(r/10),n=Math.pow(2,10*i),o=h[i];return(0,s.sigFigs)(e/n,t)+" "+o},t.MP=1e6,t.megapixels=function(e){return(0,s.sigFigs)(e/t.MP,2)},t.SizeDescriptions=(0,a.strEnum)("tiny","small","medium","large","original"),t.pixels2size=function(e){return e<76800?"tiny":e<345600?"small":e<2073600?"medium":"large"},t.plur=function(e,t,r){return null==e?"":(0,i.blank)(t)?c(e):(0===e?"no":c(e))+" "+(1===e?t:(r??(0,o.pluralize)(t)).trim())},t.plurMetric=function(e,t,r){return r??(r=(0,o.pluralize)(t)),{count:c(e),desc:1===e?t:r}}},65812:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUnrefTimeout=void 0;const i=r(68708);t.setUnrefTimeout=function(e,t){const r=setTimeout(e,t);return(0,i.maybeCall)(r,"unref")??r}},23541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isError=void 0,t.isError=function(e){return null!=e&&e instanceof Error}},32639:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},59455:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.optToA=t.toA=void 0;const i=r(41801),n=r(51926);function s(e){return Array.isArray(e)?e:null==e?void 0:(0,n.isString)(e)?[e]:(0,i.isIterable)(e)?Array.from(e):[e]}t.toA=function(e){return s(e)??[]},t.optToA=s},41583:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toErrs=t.toErr=void 0;const i=r(40958),n=r(23541),s=r(59455),o=r(54993);function a(e){return null==e?void 0:(0,n.isError)(e)?e:new Error((0,o.toS)(e))}t.toErr=a,t.toErrs=function(...e){return(0,i.compact)((0,s.toA)(e).map(a))}},54993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toStr=t.toS=void 0;const i=r(98553);t.toS=function(e){return s(e,",")};const n={}.toString;function s(e,t=","){if(null==e)return"";switch(typeof e){case"string":return e;case"boolean":case"number":case"bigint":case"symbol":return String(e);default:return Array.isArray(e)?e.map((e=>s(e,t))).join(t):e.toString!==n?e.toString():(0,i.stringify)(e)}}t.toStr=s},92636:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(6858),s=i(r(73024)),o=i(r(76760)),a=r(1708),l=r(37805),u=r(41269),c=r(80061),d=r(94361);function h(e){for(const t of["bin",__dirname]){const r=o.default.join(t,e);if(s.default.existsSync(r))return r}return console.error("failed to find command "+e),e}n.program.version(l.version),n.program.description("Welcome to PhotoStructure, your new home for all your photos and videos.\nSee https://photostructure.com/server/tools/ for details about these tools."),(0,d.verifyUidGid)(),(0,c.addHelpFooter)(n.program).command("main",u.CliDesc.main+" (default)",{isDefault:!0,executableFile:h("main.js")}).command("info",u.CliDesc.info,{executableFile:h("info.js")}).command("list",u.CliDesc.list,{executableFile:h("list.js")}).command("logcat",u.CliDesc.logcat,{executableFile:h("logcat.js")}).command("logtail",u.CliDesc.logtail,{executableFile:h("logtail.js")}).command("web",u.CliDesc.web,{executableFile:h("web.js")}).command("sync",u.CliDesc.sync,{executableFile:h("sync.js")}).parse(a.argv)},90858:e=>{e.exports=require("@iarna/toml")},58587:e=>{e.exports=require("batch-cluster")},6858:e=>{e.exports=require("commander")},36507:e=>{e.exports=require("croner")},66261:e=>{e.exports=require("events")},77988:e=>{e.exports=require("exiftool-vendored")},44652:e=>{e.exports=require("fs-extra")},28787:e=>{e.exports=require("he")},51168:e=>{e.exports=require("luxon")},73872:e=>{e.exports=require("type-detect")},92460:e=>{e.exports=require("util")},31421:e=>{e.exports=require("node:child_process")},77598:e=>{e.exports=require("node:crypto")},78474:e=>{e.exports=require("node:events")},73024:e=>{e.exports=require("node:fs")},51455:e=>{e.exports=require("node:fs/promises")},48161:e=>{e.exports=require("node:os")},76760:e=>{e.exports=require("node:path")},1708:e=>{e.exports=require("node:process")},57075:e=>{e.exports=require("node:stream")},46466:e=>{e.exports=require("node:stream/promises")},87997:e=>{e.exports=require("node:timers")},57975:e=>{e.exports=require("node:util")},38522:e=>{e.exports=require("node:zlib")}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__=__webpack_require__(92636);module.exports=__webpack_exports__})(); \ No newline at end of file diff --git a/public/3rd-party-licenses.txt.gz b/public/3rd-party-licenses.txt.gz index fad7e63b7d126f947271fd5da309e6e5947c1775..3049b2c206ff28b472211cac1c329811d2921e0e 100644 GIT binary patch delta 17 Zcmdn@gK6InCN}wQ4i2H28`&)O002Rs28RFu delta 17 Zcmdn@gK6InCN}wQ4vtIV8`&)O002bQ2L%8C diff --git a/public/app/about.css.gz b/public/app/about.css.gz index 7f3e9c3f4c4dab465884bcafdbef0329b7123d2f..3959491573ea0ab46e8d545a4c56ba0b03e85d66 100644 GIT binary patch delta 15 Wcmew%`$LvZzMF$Xc;-g7PkaC^D+Nvf delta 15 Wcmew%`$LvZzMF&NO87>$PkaC{X9djw diff --git a/public/app/about.css.map.gz b/public/app/about.css.map.gz index 1277d8732773728b9fda4537d3be51d0e0b56921..8e12f390509cd31b812f2e69f59cdeb0822c4e1b 100644 GIT binary patch delta 15 WcmaFO`I?hWzMF$Xc;-g7rz`*|lLYku delta 15 WcmaFO`I?hWzMF&NO87>$rz`+0&joY< diff --git a/public/app/about.js.gz b/public/app/about.js.gz index 2f1653b05b2f6ee64acf4ea799e70e511aea3692..fad8b375accf5fa65c41b11d0ab1504d1fd0474f 100644 GIT binary patch delta 15 WcmaE${6LvazMF$XcIHO5TY>;9HU%F5 delta 15 WcmaE${6LvazMF&NZumyFTY>;CYz3VF diff --git a/public/app/about.js.map.gz b/public/app/about.js.map.gz deleted file mode 100644 index 631d4fb1fb8d776ee1683f0ed8da721ad8ff40f1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 50069 zcmV(zK<2+6iwFoSf$C)f17Tusb#yLjb1rRRZ~*Q7>3SQ-k|>J4N=a+=HeiF`q>-AM z7$nmaMNuRzYe{Ug2o%W@0The^C)?WJeVFsz|NH0tyYHKvC%G9BIYdqckdocK`<}IT z%S2UH4v~?OF~=WwFS1FQ7o)pttBt$I`5?Qyb~imL&Zo`K<=w{JVLBe?qmxoReG>oQ z`uh64w)nR_YKeclgH~gAeSNoa(pq0XX+3#zuLW-!UGeJ4&U*Kk#;~)#{=U%`AK*j! zYh!(VgMRkJUr#=)cQ0D-aI3MizP{6VwZ8s}wf?Za{(=75f+p}6d~(&MPtx`Els>_a zv2XJaKEsdq*Vp&yFKjHkX%D*8&3l;Vt-E=3D!V~w=r=Su>;ZqmATa1@haO^U1eO3` z`-m+Xm#U}pBwcS$TCi&Q;RDfV(*^6Mer86*3Fr|fZu2LFc=|?eAB~6Knib#_@h|hw znP`62a-Zs+VYUO<|MrjOwZNU7^-=357&dP;t~;`I(K17b1+L$h+lq4*vs-^jf9{Hw z|6*t;`+o9Y?|bvtI}IGA4d)6v8g^jt(d{9u4p z)Je=?)tv+Ub$lzNm}5RM9GO(XNW8g59Qj@1$ho=M%s+@J_c};Tt7ljJ4~~Fz5B9FB z=Jl#W^U7ODMCrt~6}iN};OO4(XzYH?<^}%%Ro;s~3*fVP2JI$%U8c>xz5wtab$&Ks zx?Q&~voWGE?sux*w#RKo+r?)-&Dhb1vIV#425=d;S_70eyRV(GaeA7MV1L;!U=m{u z_N^eg?!YYG!PG7hF|Il^n7Mqdg?8C9^FmQ)+=NrPDb;9h`ZBQAKY_b=++x3X*V{jd z3t8;m2fzkr*^?{05;u?;Kt65jmH@(8tUs1O-qwtb=>3F!`s7j!y2u~=)&d~HRJZWu z{9uGH1stEiXWbuR@)C;Te*#*+Fj}L~WL-KB33-(YLx(X_cw zczDDvH1+HkHlPD<@%BQ}+Q4hrRl$aeM(YeAHenrzB${z^_tJ298|uRGz^8d(2EGl& zC3vkhfn;De45;{SxfQ|LSN8o+O?LFhkHl_?!#tM!ygHxM0C-rq!ik3!dnzV&CXe0v z=N98!KLD7`bQQ+QXDcl}gLV{u0AcVfF19p#X^tcA*g9O4&e9mOA^u!~UV#rodPxM+ z2sQi`AT%Q;1eZE!%cY*Rq3y~`xzwq*RO}|SJ&2-aRpw$lY3cEBc(KY+C$LJK4DiSm z44mlT5?QJ%Bz=PWMsBX{@^IEVwY)!NvDv+xaE_fLQ0vS+Vz`IhTsyw?u$IbB3((f&8&2`4Sa z?Y@6Pv7 zTz@bjbvAk$f<1keshKz^8+|s5L$xL>2Kn4|ucfn2;L3iln0frBeXDPrJLyK;vBMy$ zLHYzX#gaab$(538fK3toWP(o>n#9% zwt5^vSTP}a*iCpS{`wg{en2PoAsf(TbHk#^NBfTBIZlFx;u!Uj*KhrZ1 z1b5tHwGTh>*?W0nAICVv?J9iOphMn%3xC~%o9Na3)>jCAuYxj*RG_yn+VR8ZP$TC> zsGTn=p2~?BW&mH8Eu{-&Q-)1{+-5T2Ef*bG>Zl!;9}M>GfIQ_M5sSLG6bC-J;)lg> zD<}9~T8>fkkT(DxC^!KboTy_! zV$i0Ezu-j4KR4j@4*Ye38b7?iI<~~)$>JosrJ8gbGfjwVGRTzbE!u&fOpoeZiIMwZ z)Fz%@L*yZoe;f{0%S2KK63}sfEu1EQJ)8_%puYVXn(S+koFXtz3`mx51d>fh1m4iJ ztUF;WU6Az(NvUo4X%@_O*g2U70K57xB}SMflEV6BL|M#dyBeIWBofXAC?5XAo`og} zciS5VIWyh76CiGmEz@DwQbYqoC7iWKE&+!7sDtzvz6_Alf`UE|H{CM!x*BFS^>9#R5MW?$J{m>NH;@_KPT;~Z}rJ)_!Dym6)vb- z zi=R{cv(#wEj1Ow-l`>ClJrcZ|?!DTT-&#hoHfqnSSTlz%g!AlZhcx}pp$q5_8OPjl zm3Zp?u0G`#tr$D(Dd-dkdx}cHJc<^(e{TRnqu7lcpZl$#64&rQe&37E_DJ6W5D-sW zic1nahyg_iJRwqN1QUziok|<1eNe8#{aUOjs@0V^c-CqZ-GKJdIWi8?8+Oz@L!sWn z1iCjLwKUJDTt*NaAaDMtIJ=Fb02VOaff+Ew3YcxQ#wRoJuobXnZ`wQ{=)1&B&QZs7 zL6GgBPT;hID%{H!J2mG%9l*&A@WV4QOLv02wj!rHh#7rNRKq7z?P}lcE95)kD5#uX z$W7)^+m>=2-n%Cqad2B-5_e**WOZ0~*5CZd=?(1cam@E*`(O6Pp0sV_ui4mrxk*>8 z3LEC%yh*S%zqh`IxN6|{4eH1D@T8^gSC^b=&`O%gd7*mmb4&OzV&6cakP8eddqlbvy zQD1EQa+7;YElA5yaACxB8dbvUj@==+!Wb2ccyrxGSBth|y<`B`51@;qUEPluA%k+~ zjsAfHh<~1W7GLpy_q*;gV`vgm8Id4W|wKoikI4V>~-Op1z-Yn`FGEi%=7Bl_BnzLID1{- z8qED8TK@)TaedN8X1V0dvT`BXBP}ARGbPn9cfX~t>&8K{j%#!r0A)AQ_~uP+L*A`z zx@U2s9WjL;TGGuIUd%UZ3r}}66;xcc#o!y_a1^x3m?g(}?0~Q~_S{-4St8iwBiiI$ z=}7kazrth;#;INXnehS$Wp3=+mtEkMrcPhb(^r9fz;t>rYc(1+dXfFFfZ(*y?-&^jGM$NN{!8>M`LI%KG{F{3;G87AP_zD9=g7(RpTKq2M5!ffuo)t;mv8U+DF2-V<{o}qCx<)z0aV-#a49~ zg%mH1cYJ6U@TaX45Ad<~+jATFw*pE|&&c1MdN?tAUM^&DMvex>G3Vp_fpm7~@lvxR zVV00aEu%B_J(SPyw}VP?m(TxpP7oXRiG4N0s-v~$t$7qg0Yej$r@UCUi($(K6LItJ zwF?{(j^)m`#T1aW-UqH-rw8i_T9p^2`7Vm;8_3-u05B$V9k1b=1{4Yz=K<3G*YM9v z`!9g%&Y-2E|5Rk3gb;+zzLFZCw$cC@8~P9JfKCMgWLsuGcdE&Y2Jd-Gx=p#kOItB* zOelh49p_rUYk6{wLR ziRm6P)5Iw4%!*(QnQo&VI_L{%^W%KC3~+X&a)RXf4RXUVSjJ*8Lq0VQ?Q?kch?biK zX?-nRX<+_{D&JRwmc9;O&T!E2tykQ|XV<804G{cI-)xkfus7z0d(>WWR@xRZc9A;> zIVbIUi51>9+FazlXjQv9bM3bsTv2^FIH>eNQgFdL-RoEyqaXurE0yBy438t0cY(jp zk-z@z$@BBL?V@`NYWUl(Ei+^*3W*+vomXZrOo(8_Hx#KX=iQx?SnH0^C+tqF`Ln9uUktGmN8hH?2Jn z%ohQ!#}W9Ml3F&woc>V1laX z$k_mdhi`%^B4Zf(;DmFB2(TIDgX2`GG`L6c3l<~Nn5TVg%aM&~MZ_{{lX5vZ6y)Fl zCL}vtw`2N~jQ}aObSjgs>vp}*^>ACpcPeTf#5NPp))AVN)D(xzW>Gf7Swbj6%3fAb zk!NvCo57{(aO7*nF;&|{*$r>mNCzJIonwEbb9G2ta@#Z^mU8%hyAlhHw7S%?RZtOH zcJqJKvHBdHiNm-Kt!*&3i(`OvNQh}?N!^c`y#y|c&n*_&9Yk77C8w0(p#xg=Pq$K` zdDWgv;nik&Rm82mLLTCBMvvNh1!hO1!p@A;F{z9~BB%WoRHm<@QhNpESn)Rm5$GQq z*k}j;zQh;gK|v9lbNggDLDeRFJCs=~VjJVU=1c=fpL3V(_g zKCHOC3^@t9?D`bxVZ~8USIp;jFn-qRXL555Pw*CB_4Vpf*$N!GF*q0+tT5TQ^KUy| z3(V>ib_6l0!gfq@17mdBwbb;k35{8qlxpl&>Fm@DKey+eVQ8p1 zW*Ayne1=~I!>CPmU300-G0vL%76oOUVbD0>+5~ATg$PVqDw@2jf@Xh1nkxRz+bWp8 zJ?cbHPsn{q8s(}v80OVe?bWp*iP2T-=I4VWLS{R$E6cPb`TO=E3F!gMsqGaoR-XG(r^VT@ydMZWoGF6i2(+6R=$wCQ9id7jmMgc$>&O znTcMZOI2Ia3oDdUupx$J&$LQy2am3Kqx0gBOX5SGr^;|JMw&6F0KW8`N%TOCrM69Q z*+6)GblHt#vwX&Blii;%kA9U|dcR}qF+W$s4_(kfn%*KOlUK)o86a`)Z<#leL5KY+ z5c2Rg{KRKZFIui##^>VrI&NaJ9m9;8Y1ncSx=`Mv;~g|_M%UtGec8lxIGhVTY55^0 z852ukRK1bg=wBcm43zozE&bKge{JZ$UTIa_hK@=#lD?B9NG<;%MxygKMH^JpPV-k< zSz!5z4cZJ*4Ok2?I2bKO%3_BJkO6eA015nkU)`4ipH+UO9UDaFE&XR(Ga8#7VyUCY za~4<3-?4RWq8HDGmV%La$JfqD;=L)9A4$r99~pIw>!XMM=*rLURp&<2)fOHTa?)}2 zR*HDY@5#XPSRP008|TLQ2HnJ!;YG8c))ArLyw&9N1RZ`Kc48*k&H5~A z%57cURh3(d9Tzhr{?u}tUhT|Bv_0Yl&SdhPJk1nbwIi2z6GFICO$a}j?9NCCcaacE zC$*Vm*X1tE2$hrobh`6HhKu?-*#@T}uWr(tW!}8+F{2;>ULv`fL{G>E9ec1Xar&4r zcK%ryo(I%BQHf8|Kr^Yu3TE_!O%DrP;aF-L z+=-J1z{N@@S0BpY-S}9cIT^(UiD1!>kuHCbyS44zxQJA3mdf{oOg5*ZR>X)AL~t~x zMx(;>TC=nxg0f*%2K$7_bSUwM#vDRY1U>`-aA?l>?^SKJU!(K{x?xM5E`#Gv@Sy`h z<4-w@huXn(l$LG$7vmo~gT7sK4Dcw?fx7E^bB{ji8nmK3fP4k*LCZCs7&Nywd+Oy7 z=V)&=y=VvV0@W$bB7;Go^=l6BTNrg!m-pOY#7@c7HCFn z8{4`F3Gk<2M&IG-A2+QL^(#6K@O^jY5p?zw3`2I*#ePU0I%o3GrR5ZR!(`8s4kOm@m;Qx5-vq8Yj5Ob10wZq%&L!h4%Wxjf zaOQ>WeBxn}BE4h8q#s(6&f>ZmP1T&1!%Ny^gWI}{p3=J=SO7*8#~kk>^~q@zv)q_@ zH#tDp&Uk1|#L^5q_l`Y>2mx~-{Q*zARH(OK!|!!F$+Z_d>L~}*2H84p9o`7@(7VMq z$h}Y*1+{Ne(U!k+uF?s=N;$Pt+8_R{@=chw*?r(>tC4frF@787jZ7h-T@IYcH0$fB zXE6!Iv2pGh63X)V@48ACHh+b?&f2zY9F%Mb?5aGU;r6izJMC;e?L67hgvFFmW4D^} zq50WG7j-rKQnf9+>gpMB!foOXeaE+{XM~BJ25!Cz-3ONMsFE|ILsKCLbAcL?85$Zr z?in!L_$mVpo^C{KvLa%3fIGZ7)|vxmytFBWN@NkTJ#taZv!c1KY@3LfRiT4&35+|` zkKL7aMnjWl@urvEjiMl{cF6aS4TW^-$Qs_z z980V2&#BiVzgDcKpLsqZ<11=xilG;3kC(k5a)*}=z2G$}&1Gzo&6^Td&Kg3oYv!+z zQRjmbvfz+JnY}JFiFxr-MHCMZFCUN{m2UAz_~Wt1w{5u8Is{x&6-Bwcu#I{LX$W1N z9qzHX<%Ufw^Yo<6l2|Y;aOK1vw?lSy54&u`^H)#Ik&OLmopypUWGHYmDpFo`tKbnC z_;Y72{gFF~$iVHct36bVnQ}ShRsi*G?C}6N8>47q^W<}~TcLkJhfH!f6Qyo>tr30C z9fH)3UY}j#Zw0(7{O(jS;FbYETrA?KajwA(Di}tfnEXCAFCha_+m&*cP_fE;P<()kwx8sKEkFXZYZ`JrjpGUq^qf<<_Af!8 z?`X zimP2NS~pcIlRnCv;Sf$R^;u{Q%tyz;9_#gTD?*fJIz)A2DY@QzsW@0~z zGW#KcChTA92oZr7Qvc(--)e*QhLep^UHvB2A-CW_wv(=ZLs@eD58zk}wSPU8hKgE! z*p924+g_4t1zgT~sGd%_;yNU+uOru0u}!-&zY*;dcDme+FzTU#taeF~PCP!e%@qUS z4aKvI-8iSNO*xj^@zmlwTFK%%q(yV9@w`jUEQ|!QUFqvRZ0k=p(MCqB6w#tbm@wk{ zM@f9{hltOt3_Mmo}m{FJ-2Qwil2PY*6KO1fLS)oajPV8P;jsK>S5cR@}|CGcEHaKV%`4LIB!!j zYFSkb@$eoN#g>RA_cAvz%w_O)(P2Xl0qSuw2DsqTeHM()qzJ|vUVpY`zD&OHn@lHD}6`) zi_MVddbLa-pF6?)m6ny^gGuFJp{#G1``ij=nl;Oitfz@f-qNZc%V0HVyU{eefsR8t zU$s)O?dE1~K-e6RtqY6G*|=1D;y)p3cvQ?@n8him|vcN^35obvC`w@j&5e zcLS|(R^zcb>iA0zBu@_Eu%*&KVyunVB}TJ-FfNIX$RX*FHW8?xAdYs!cB~K#x!r~O zRjRo`%Z;P;yO_?`#tajnmJLcr^PtT`nm@Q{+#Q!vTfK$F1CU6(j%A@VSGCeb|JKnu zF#FD;f7pB+D~=_Fm?XzMA&*STp?%gN_IY3FsdR-na1g3Vk7SaXMG4E>PE3 z9DNH}R8?SoJWmNF$)4{@=h7>_gAQQ9{^mx1fi z&C2|W1!{i->`^|oc;GG#8F+6y9dLOC=-4btY`wks<5G)f46}<^l^s0tSRsmL0`n>; zuQ#w4#b*UTZ6-!Ax0e1nbTk#;=FJywXeAh$% z0l%T4M*}8O7Hp2x#?{~+wJ=rN=Ab=G^f2kiEot%>*F>&tau=<6l6_lFQmeL;ROV+v z+F=e4o8+q`FAp+RWr*HZ^psJE_cBiuf5b zo7blzROCbv<;NbEqV)g&VrKnN;Wr3m3+MSZ{C`y@B(wA2)VCTz)f@{6yJLl$+Dhqm%h`xf4qYG56|Hb!654p9{j_?Rw1ZVlZmyo2c9F2PrB5E*fT$wx zKLI}}b-OUtSyyLH-C_64rpzYYyC)0%I~(}t7u75?X>@Nb(5nN)B$OIvi=lB#h!;&Wzzi4@Z9 z2K~#`8C^DtU`rh8D2S4Kch}7tV^ES(Qksne-YtEi$^*7L?&nUL5_EnvUmI5Ly-hV7 zitZLJeA1Sg5i!TUpO8kSq@A?gsK98>Szo}|31|IN$b=m}Xvx4yOKa!(LZ+(JCNka~ zmhjNQF2{X2Slqf>Q8yluLxm*o`^lHlqglt*l1vTClkVFYl@gW50x8rAzU*0~K7j1)|6#KY%E&^_si3 z>1*5$=2e_G5mJcB)RhW6yPh@D2Tc|BxttTYj!`^sxt&=)**m0h(c9g94FHfpF?MWc z;^&>fR!3F+!!}aY8DT$5QtRdVw9i zpe{bTibzQ&Iq7wc7i4OL3gi~YUjrXmP=RG1-P`pbIy z8y%PYcrLp-6g!&4UUYNXnp<0cLX)=Ly5VW}?L45278?p6!lWH9aIhJ$Y=p8OMhk_R zO9w!@*d~x_b=#}g6-#t#i|YxGJoAGge<7EXP(4$P=F?6PI(+rgp5Oz}(&vN%7M!pm z4=fNe1m_7Mg5Lg!Z{3a?X=Ob1RG7wbyc~~Jv*vTlqrZN3%d3{f#&zE`&R(vspFzo; z?g%-jb+#bKTDr5oWw~ZJXUzT!iEGQ12rJzvjV_}d-}k`n?*7FyJ;Cu>oQo)h%HqaO z(zqS3b)jm|caMX53A1|F8g;DfOY6fI*Pa$H&+`Njs>D7+tLQUJF>E4UXL9ty4@xZnFm za6f4~a1YgHbmsm5Z-^&3p5c>r4DJsQ?$-!$5Bj@O1NdV+fAI!zsb8ss5kP!rCx(@r zvW^^<1x9baQNd!PwZPIgCLL)A6q1?0ZaMJ_ zd(;@?WNDCsiVji`)9WB%Z~uT(Rf$T>7iKG?^;UO0O$IXZ#y)Z7Ir+`ot99AFX|%Zw z`TwA~c2$)I)t7~dAE=Z7XokK95%IRPG0$dsmD7cuJr$FmbY|3foOeEzW}@(=X3+z0 zW>?=}X3<#FYR@4x<rLtxP7BKO&iXI8t8Gc<;DxlVQjsT1Yui;Wm>S1Q7Po; z7JA00hl-2a3Rq&_Yhv}Dh3~S6q>g# zislQcLmh#}UZ-?BcbwUG(Qn`Kn2lC&4yhO^&P_7vJBBQ(a?-}uvgsE@*^!ko!Ebeo zCFk0tfaLCxOJdDm4qU9lEvqI#HcVrU$BiR8tGuAoP#xA^B1#43FR0BOa~z9ZBUL+k z(@KUOT`pSl6r0_c(-GA!zU&c+8HL}vb2v9`=`2IGDBZEOwdg|r8~PO@$=Tp}bwWXq z4k2f(20L{jCzsH7p^Ji*XbV}>q;7j-)H2zSg2rYqh0O;O{4-B`3KpU`$@!*uF|p-3^ENl&GOu%H)6o5uV}yc z;0GR6Y3ZW30}X$-W6!pIt)z|l>nE5I`qW#A^bnJUjXzj^tU5$daeZx_eQMJ!vMieH zQT7tz$IN$<12UmYq*wnb!X3*ngB($mas}etyWeK+JMx%yT>kLR)RleYG8T8MLeaZUvoztSOHFrYYLViX_)uEd%+Q+J~*bsoNdt zTPV|^0qb@I2!q~oM@TW{pBwOc2mS(XEF~}Oar;IbTEJJrtFiq-89~En*X5SQQ7af( z;P$J?{G>Ijc6ZP)s;h_OE!X@phgi$Q&Yf+MHJEm=c#t1U{bN;Po}gl2OFBNzffrWh z2w&g!7j+vvzs_xND_z}byHeS1+;60dK$%zJ({3b$L29PVtaT+nsqX9^e@l2O<)?2%v@IE0 zcD*{6`B-q3+jXQfVb2DJCVZpP zlRrNCoC1i6C7T}`LT|mYGTjS)wqDIP4_6}5Ek8q+u~SL>cfH`?s6S*i{43ebu)Bdx zNw}xaycq%T&=7AqLf^=ScM5Vmqi=yJXo1Gp(-6cz}?J3BTV7 zjuTRtIrtJvMoG#?L*t@Y7{$yRe_`j-*>bjJLnV~ptmp5YAeMyItOD44=HJ? z%u<2A6}hJD6(JnlxB19wySeZC_>+kM4fAwX+SJRK4OXfCe%6Yuj=KJ>1YK4Y&i>6v zPqkn)hs0#p*~L@R3FOgv6Lh?_q#ee0<&5tN6MJWA#<_Cm+eDt3F-g2)gr$a2x$Y!th=aMI=n#)_!m@AK+hQ3*G4ae9gdeg`0&g zc3wIBC0;?@B_zcU+d*2aONxP$!zm8@jek_2DpcqBL*XGf2A^cjq!e zM_p1v=gjx`8HMA=-9)8PcG{^TXBEhtwC73jZ^_VB$p7M@Ul^quuO?bFtQ`J|IB#dO*YHNjwb*=*H+*i#0 z{0cS?D8yde7sxpIKs?>*&HR}{AxWVG0Cuh@B$E#*sk70J{OrW#0e~=iw)=TjMH7n* zQAq7+JAQ3khWw{wwtz|@3&Tr)sZ3C)v;_aE&{%Ki^jpdoTiO%PJJ?tEqBEl!f>ZEE zmnINb1ISC;(PWTU^94e_m*pXUl8HrH`cLBvwA8k8Xxq2PW+*}Gpu+u7arT?KG-YIL zv;m*ABxF9s_i7gc(&nkuvKhKttv$MwAwFbZEs;Z?B8N_%^i$%{^^XndR}X)mwDAXQ z>$G*tZOy5h?MC^ss@%<1P=d6~(biEi$7UmzvCCYJw3U@vy#VC*J2wHjijUb)@TPNl zDKn@Ix)G$FgYIgSe>@ZARi2#oY>b+=Zc_V)W%F!PHlXe=Gc@YTnQ*Z+PchdG6OJ8< zeA|~B1(p58+Tn^r&i$oUx@^%kWVTuKg$DdAq~|iFjkkh&DZ@5?{m4`%*Ug_F)kTJs zAXY~3&59xv|Htf;naPIs`-<$-!}d4br|8HVs`BaIuuo2Xge_A+duHOgc?+7MvbG|X zkvx^NHM~ebwjB!UrWv{=(6#DSz#=96UgD-SvPEXxAM8%Lw z!+QI(&h5!u?(G`BAQ)B=#@p{@+q>TGBMk2uPw;U^C(HUNh{Gp33%x$5Kruce?@3`{ zpNaR>KQ^Sp9{hcezL0h1;+qnrezB8klh(Og2OX_RfcDwPPneuM6E2oz3Sfvk|O4{7SO}JGwfBczumE8P|VrH-<0q7x<#LXP~Go zqA@?1HtcGKVW%PHUmwA*-`g|X?Ki#r5R~c|mPmzVZKwVVc}!lQbQf+=S6k4#o%wL{4fZSG=jOF`RQwPNZK}|8HI7}jFlMCV z=A3YHdD`Wnuy~|7VO6D}RPs@-d6cE>)X9G9YWDDmv!KnWyGb`t!6}rY+-c|3x@w~i z(O0o+WvJMNvK3&vxQ;tSFtAb431mebwks1FX(+9>T&iPyPad^mq{tjF@FK=~u${T- z?p84H%{bJl0#$Rkls;(tOSid%X)p_`V`bOUa5t2mz^!1Q{ZcqKJ6=2?#~jD>8*&p3 zC7nS_A5QGV!jeG2_%ZWc11$MDp3pRSqu8mP8D@u|;@r;^&s%-->{bcj8x$Jd{a4(e z!nWJr$}Jw^KDU}novOAcKvr8i$<7z`ITb%Cqvo*X6pi=wzpr@F>|@tX{lPBt;B3*W zN>ziickY;uK5W;cVYqR;MiA)tu!PEH;8HNSW?c#oLzjX~t~e_m%()cEhiPurXo$cE zRHKi*+d6a|1n4@q&O7YD4hjv`6+1$wEkrz`w`E0nPO6u^T$RI9st?7K3e+kB%Qrxl zk1`?-h~?8iHn7nS{tdUw8A%g^3PX0NoTtGzc5hYXr~MaY$+Zsd#5iK@U^0Lf3lO-K zeiLrh^&gS@eHAnon6+59kyhY1F%%mZnDY1NGgZS4<5}~#9mvYF6H7T4F5Ye{8^hT_ zWw=iJzIJ#M64Td8r_oH9p)?oO&Ro`N`jk@Dk8#t>-jhR@FHR$|BW7&~~ z@zlb9wR@Fu279H#vBsTvnMo^?S2WZZZgC^G@6IWoTcW6|JdZkz-d2~+xCJXfR^KCz z9=+{ZfVRCbER{O;u~UmDjTHqPaZk1o;~9#=3wX@p<>pmb*#=6D&sJKNqwGv*!kumc zYkR(Plk^eCOl_iuRiQzj|c})F8SvMyxxJo zpoBv236BnQRvF7Y#Pk6?EQIk=H;Ohj|1bsqd;21dXA-<_Y3)cz5L@lcEo!ymIs9XR zmH{;VTw&yY&-1^vnR}cJ8vF_&$<#1$Zs5RhaWkJ=M?1!WfVgzgogpr5g-U;JnY3Ip z#GGnS+wrQ(alhILPu& z`-i6?tIp7Tbb_Z0;*VY_O*+z5C)Jx1>tmz~V6hk5t~<6O`zi|3kZOnGzKSHJ3RjJ^ z@~fH)io!bXcm5v!fN_(SVP5-_dfDZ_&5U%$r*Pya*Q+Y<`vKmeYi>hV!SlJ+_kmOp zuiX6BvYx4O;n-94-vyDF_b*Is*9IS7RKPfRD1CdkmhG|}l0D1-?&QG+HtORUKFby1 z^c&;$91V@^)Vg7men99mcT(&%d9Sv)*2BqM?mW|lUfMVM1ZyL}huw8|I-#WCTs1X+ z%TP3YfV867A)KASG(`N^hy|(YCRoh16B4fB&7S*g6Ohm(?W@+&-9U|Z)efeh^~-UOQ{gbX6amdfhI8CYKQs4Rfep6Ri={YU9}0LG!bXOW*vDMum#Hjw zWCwswV~Nv(bY#8(tejRCfByh~8HhH0`8AZU2)I~G_p~nLqp~Z1bd>@$sHu*=2{3Wf z_Bo5zyAyjbMIM)UI3E>h@f*^2V^3 zFH~|SmpSf!oA6>GU;gwPBKAA@=W(k#y*AwQ(~4m5P?^q<<4Y)BTm=%DEDk$C9}Jid zIj+gSc36?QXbioRaM`-?9=GE=<=ER?)%||V>h0ifRRt5n>h9Q4qrm8d7QCSg!||nu zj%q~NGj7euUcg&-C#_)C5_Kexg4svTL21hz2)9_hYMrIG8&u5O|8Q?Ego~N9BP*p~ zlfu7x`Y$_1#&|>WGLoi4N6dH36wV4m0f5>B(G9w+h&3PS#L%44HuJEDgT{~BZg%vZ zR5x|Gmk6JU*c0%Tx^9Q6*J3u$j&>IKk^QwvaS<}i9{&1CDZH5N5ih>iiW2_T>bNYX znQ2#6T0d5~&+PNaSGgakuD)v-W3l#Z*t5ofhytGstv|tZeOnR-+p?Nc zM1hSRWfb1CB6$LB3XB#qR)X)S9nVDjtr0l1J!&^N4a*>}ve9ZN1KN8!p<{PJE)kGN|RuSTJ6 z#*OYoATZhx%(+SlRAYHGO+UPeDOL5Q|NpSygHI_n>nr3R~vKSHbL^mgG6$ z^#UE`^o~=C*gxm5<3}~*JrqjV5GtnWSU`RHs&XX$RY{)Sp}n9DLRuS-4#r=XnB8fB z|NcwmcnZ{cRQHHg{=~@K&8Chm)-b1WS=(`Vgu<4FT4jEBP{>xR2o+BPDVXStrQ09C4-q{3i zmf5NOcDaXyTLM6{nh$4L8!kJ3UZVK=Aeyfe-PoX6cFQeR+T!v~S6`<_i}m|tg>rR>9(%@Thr@MbT*782Za$2zJ271`Vx}at}Mfm=vQ-`PO5uqx!2dK{!u1P(^nG2`O1JS#ckop47tf}ToY$tvZI{R?Yz&S3teI0RckKrNu$6`VmYIQFK-7> zyl$tG^q9rZ3s>7h5h|=%o#|~h3T`;GC7OfgKNnX+>DTAL)u^&-Ch9)!Ml=2Zfi&{8 z=)HvNZ(Y!tEvbd=D#lQ|#hZ-?=@6U^whl%a)NycA-J%VWBMIbbGGL1B@y~3h zV!J!`_$YHU<|tSclO%Cp+W#HE5hyZyGp7=tu2{sX)5P8YLoY>8#vQ zaIl7UHe6G^W_D_}?lepnHNr|uT+~pZ)l7U=zD2Ql?DViC)Klu ziy8sK+^zD!ykHIpb_r=Wu*Wck7dK!EjU%ucjx+Kf&QmBgK?mX!2%(Q%9_8cM%ZhdUN6Q&9E?Oz9!B zvvaqD{pwV$*l?&*-y0bU(M}_K6G;e?L3;l@~<;6mi=tSUgXtb0?O@ zdDD)swGd!g#+Ny|eYuxxG9kv*4F29mFF(wh1@#%P6Nw?FS91#m*Y4a(PE80m9f3nm z5hWDdmxGxNZP!`e$xz!vNG2@2kk>s3DOeyq!tP(GkuV529;5^57FcKBoK$SjASW&#WN>3cE(!<;5c_c%&?E@vCgbA zi4PEm9@>8kaGasoGU!kkdPkdw1t@bKn2wzeTiQf1BgsKj$AqV8!(7E?Ph&g4D-z7p zlAHZ)DKwZZQcdW0u7wUADYfinZ~itA%b>&^#bwewlgS~LIv((KM`qpt)>SGYx_vL7gu?+o z2uP!thORv$6-kJbG(6Zji+>9!t>G^#eBF*S-VEszDwb#DCnF~~E=kJrH~4lg8KSfO zOPFrnQU$cEN>@D|K|gn(c1+r|T`>qknLQxXSHS89Xkz^qV?KF;Do5s$VQC^aFv0{g z!;xc#*zzT`s+_wOQ>@VGtr(M~h^C_#W`WULvdG$CR^li{>VYa_MkVRUc&iChNvoIf zxnsqv@Z<|;@+nUKgEn%f>)p5EL}=cEoCLu=lP999ve8#y>s1E>i>EES@EBg8ULEO) zXS+?c%w&RFhb?9yunH?H@GD#@+pO=dTL|1_`LMe4HHO}5a=gtrflNG@i={>hy9^Y?xRLe_vs_34+yr^>!bu836nHYbNd>2zDcsI(Z<0%)E zQ|ae+(5V#J_IN%F!McZBLq6~XCT8(CDwhU4-(49DvmsNm?dZhz$JKplhGgpabpFUb z(VT@Wn|Ia<*vwZ^ulS?(^6LbzsXzzj3>f@!3XL)^htPfhONqD!B^9>rw_FBQ{B@2B zZJny)Lm>ExshrnUGO%bI!g)LF>=e$^%&$jz=Y~v1JYTXUfP_+A=AA%_Z{W?20$S@G z^P0N_{niP%QWP!QO)I3`vRi*{#fM~GnSp(qwsLfWUTwJrxK-HL=WsFx#{)0m`?*DT zjuVS24O6cal33mLG)`i!t3K)%dgfrwZzVMfUPN%`q<%nKl<_=2Y1whs$ch_xRFnMF zNwx7ohk?bO@vcL`S}2D|W$(NxC5l$a)E=@h<71@Sgs}!}=Sk=cF+MUOw!^KmKd~AtnX@hqqjdw8hHuJ8u0g z6EX1l_O1Ww*?jZK{ng9+M#KHx-+gn~{55d?n|JR&8N&Z%hx&h7|Cee_ukl}g>F&2j zA39I=vBf^Lz&~&K59`704F30C@RsXO-osD(ALI|ODX-{d8y}`y0qo03hsq_t2iC*ow%`2Lp{p9eIchUE6RMju z>}u^OUEziey4$#07Uz>*R^DCvc=s|p8mGOpwZ+AMADWbTn7n zPCCu@il542&gNM*?*2BItL@zFCX-?^SId`!bUMxEo9V_ho1{mBY_7&X?QXxBtKn8U zp0nNc(R@R{IUgQn^DTe-=yTSa4_V$$@?k#BFXo%WyL8kqhI2LD9S`#9%Y0JKH;>)v zBp;p3)pYOld`|p6o^Mro`SN_!o91((b}@RFrTzI1__SD`v)%4o?M6jE`*m3K&jkTn zoL-N!g?=^_d(HoDexBKpe7Sg36jSjc9nbs0ENbcou=jX<>;*%yF3*H^i*KxP5T+9XIU~zhgm5eXGwvlX7(PWN5wfJ z^?|;3+Qmqan<-pB`EV?zll+k!0U2&2!*u+nm?BM1z9h$!VwiloD~a@{yPrn7{XhT7 z-ydi2^3y20!q>+VL6g+EzH0U4k58i{IW8tityhf7X_BQ$aV)xf`s3c#>-AAjfTugi zhGKrtYoG3>A5SOQ@xiCNb@^qIEG{PSEV;}FgXAbnrl*-0Q2gCXN5v@brGsSu-RmYb zX6vbCX%jwd(C5#ds}8Ztz0~Xz*|H@^vAmMhg@l>OSr~OGYsJ|M5Tcvt~I>C)4tMK0Os3{sVgp z^z}A9$!^rsqBSqE=uR>EZkixsmD%8UVE}uS2t*wvqwG>ZSkTYQ(pkND^B!M_vG3T+ z5+mPXlT+X2$4O0pRX1Qy0DNMC0)nEiPj`PkQfNkRznIBF7e{Irr+`v*J{pbhbq(#3 zXXaTV25ArS-dQp&XqlhxCO^UYB?&<;T{LzyesUUgu&DSp)cOH4wY8 zJ=x8yMuI=E+H{bh_U$HuHLx1tlLr0g4Irl5dQaQ}CI1BA*e-_S6j_`G{8Tr7@Ih%k zq4#+i{f*$qhl8ouEi)V4!kYgC*@umh1qtFQ{B^=5TZ{(RIEM9seBplrFxkBx^|mML zrT7p3h&{HxLuO)oveys@Y)uPaSWOL^z}uOpR%3DT^H$=g^Lp2Qy-Va?kPsoD2t3G3 zL1nwcG2CxOvH_%+$O@9v$pk2?Ky#u`X<3S!P)uRXzc5TkPhTh5mAIz*C8F%pbaegv zc}?`SW}x@<_4E3g>i;$2&mY>FupQ_ILA6dtO|e7Mgg|B-hM+AW%^M{qcbP zg1f`{S>p6!pW2f)Bc^r0Pxp#}$Kp(hRisViAGeQdYW{*`!f6m-N(ZIjECf1_^`I$y zT{e^RGJ`|*+km>O3s$6@igP5GTD@?=4A`SS-P3!gUkGxA2;NAJ2+`M)BhsQ+OR5ng zlQN1)Pma7NDL;fq>W6uoU1XE%n!t)ilJ~C=F9e5=jX#P92goaFV0{0*`1yVE?{XeO za>;(vVk}+`UP}bj&U2rSId%H{~~#Ge#iXR*ozdIzwnMA2l#EaCB$+* zm3#GE62D@Ymlrg{qtT1l6-nmx{mV7)2>Yk9}&;W)Hn&b2GwAO6GqQ+@&T00gOnm}6@`KYx4P|)JP{dVb9Bc*4qSN2!NNiXVBq$#B6fnLX>L<5 zc<;H*xjO{UyME|%dimS{1NwFWfm#8ebac)^z6ihszO>+ROq>pUWR{LUWgGaDNE`!1 zH3&3oF&8WV4u8{PB_lWe1`8!rUmsmt*#2UTbKMNHOZ!cfF_Q$F$rT2R6_3hZ%FfL@ zafUa(8=|U0K;lBoQxKae-2LB`g1{VQBf-Q?f#v{k(rG?ANyIfXNe*RKhe;%nJw6oYqXor_JzPT~4sMgZD4l>(jMfg)*cARlBT5DVGp#@*8PbS2lHHYcACcm%G z1s2(Z_*~twY>9~Q(7QqQi&j^iT{ah$o3ws80bwOTHmhGf+5uT}yjCab_jGJ?ss~hjkReu-EmnJRfGIY%9J^ z%U(8u)(dcY;*vALK^=e~$^eIgNH84#Dv%{bj^#+948h7q7jbEb;|L}ksW?xsaZZB? z*zjRZWW&ajy?~Txww#tMB+E}g(6WviOiBx8_}}D*WLe0H&yyvFLDSPoafwzi^k=Dk zx_gxN2iFM!ho-njW;EcVU38iyLGoESl1zTUANRyloU%UtY$>D>t~=rpNepzJ0E#C9 zh`qU=1acfgk@w@52^v>l|c}2g-=T%0ev3Ou}{NVNDZB__F8**)BFe1IU4p*8HL!~e8(WGT)RS25=z6rpO9(3t!R zXLtl4u`o0Q2=5EP(}C#Y^#)FhWf+~I0&CO0H6gzTIM5@y2?>@p}MXh>=eavjiCNTV_4 zL9Q2V+~pjrCfhb!vG_d{;-{eK$N803Mx5l+L3)I`h+!{Fd#BlG(Q%5&1;NkC#ruyU zYo){cLMjUqG)2f|8b<=W#%aydVi)-FCQXR9Az&%aC1s|^d7zS)r?3v)} zU>Aj^9gKZG=8Tw{+3`Vy;i6^Ldg>_ExS1(KgHi?-CGF&)G*Z!BLvO~pw(d1|o*xl# zOAax5^c?RRn+VMVAK7692N{cIGcX|#>%jw{74HDHQrwe+DopygplMG7y`qZO#bq{W zr)5^FAJlE(S%Q>{T&a;QM9=lu2Ee-r=;geqwVIZkWm77>q)x-SND+euE(?I|H9DV!DJmrA{9Q!#W;SEK5V3I+@{c|G`r>=fO z^k-l-A|HZ<`@mfUnkU+2t2S&T7mcJQrFhR#&D|Kd5Qe0?Ed?$(;D4Ro0Q%7QzuOK7 z7CW>D@Hn&!!)7VAK)h{yJ?w9W`YVR7!hJCfkgtXfiVaJ z7cUukv^ycf(a&_$NB%^7fSu8pP4X)qX4BK6Pj;#@>46-I>IlK2=OZ!7Fze?+G^MVL zZbDmk;o9Nrwkevjwa8acD@4*i_ z90QfwN~gWk8uh-Gyvt6ySL235j5HU;UD&W?_bTh53(a#+O^m?fe3Qe61I3?Y%}n%A zE15cIXsEMX?{Ge|lo)GRjNYQ7&TBlsamS%l(^<61$_3)OkAknfy@*=`^t_jNyJv!M z>J4Oi4fMUZ9%n$4vDv4)G~}ndb$Eg|O?m(q=N^%A_QjF+#gY8t$o;~1dLmjLniFXJ zh-NFQdwH4hX{ljCeuW_rIPr!F0hvUC6kPhB9=XwctVRo+c|?Wtv`F3fp1c zCzUPy@l=vLu22@wJ>{(+x^D{*ceL+(P2KZ2r(t>pzH!jy0?oGGup8u~8Xt<<{@}L# zD4t45y3U;wXmoXo#GC~EKF_o=7;s?%K3J%U$iWPYUBQAHYVx232ergU`5WKSES4>m zbgm#RSEUy~AL2)K_`J@)`mDe5ma03mI{3lqK+^oK#O7xT&!{tWvidAP07amBEc#MQ ztUFsaPgeqZ0-Xv3A?g?NWBzGgg1Y7ipp5fww2!0UlWp>p<qXsiYOQ?|y!)9rfe{)J@QjkYL{pj8irYYwC(Z-b42KXSdv0G4h^al!Qy7fN9o|F zLTo0m@Wn*1@9MRsq7Irm;Q43qZB2)?22|23q2_e3%-}yH_^ciXC;@}H3W!)(uB#pz z&>X*OL^>mP0vA}^=gni=CzHJb^@~EPceFuD?Z{rcyYzAQdU#X}nz?LpP^%ayz3vK; z(1|QDJbOT7FVBzTQ6=s+$<|Rfu#i)Q^@;6Qq3v)|uYqa`*cCCVpfuvpl-Y0Rpjmm< zX56#~e`^S_LHPmN!RhhG{NUF9bz=AXC2X-gsozm)U7rMu2>^QqK#1}1;55<89=Vn6Z_4xr-i=G%m;VXw)rS zDFN?m@n3QW0G+T{`g7?HDINn4R0V{rUx`WPEZlxVh$1kjdL%g1BU0?8mM3$b(YMBd?AAcQHdB?HJk zlflM=E7~b$&jEGoBaFreRzyVJ>4xW$4>TT`Low}5-VpPfEhJ4$(O0i&Uy;Xrx z)YRa=_}cssB1}*xRnxf_9B($u(GQL>(G`@t(9hN2Pt62-!gFn7ACA}HqO2XW_S$Jh zBB1K`i_(^OUUi}yJr~&ofL9~y1T+#YYS`|Mc!K|}^Vu3V7xK;xp00kDjd$gq1f3l0 zyDzkDd$3=w3D5F)2x|qc>%`1h1v9DsrIVPMD4yYC$fZC&&B`TH`HLpg>oM9wqY)8A z(Pp~0N9e1AUm@8YDGQPvEdt2xkWmie*dOa?CsZRzS|o%?b(Q(v)wbSC0Z%8y7?8#JA1Y!rW|9i2 z9K_)|8m<~(|K$?i71IQ0N4A3lnK?>Jzobl==8J(h8m?Bv; z3Jir2)5yzHxHzTnt>P1v5ANluI1ZRoFsAOK#A^lVnb)XaCvlI~F`SPk#bBWB(CzV* zfw2U4z0^e3e87q%xl%j!VttE&fM!K+w z?;TotS)b9}Ua}6Oa*j1$5#X40i| z!Uis_arZo}H{C!dy$rdKI>T;cCwK&{J!>LP5ghria+&^)!{|` z#XlGG5I~M(C-N*P+8xdzS8|*)!#BlUH?7f8optPF2+rL11Wv6!lZk|MxgI0w>l0+U z^BN`k)t4{+f~kbgy1F*05$&K-gWq+?Z|!B8PX^a@MDrflnX^fcE)Kkkeg8%}(dQ$u z4kw2N#`BPiDKHa<%ZK77nP_#A5WJx)xUR&#em6mj>@wMjf&sN9<_gkxm1iPxcmlmH zmxvTh25@dSyP>gD*p1OlW;fN@Of1pD5GP6qE^bLXyn66Hu#Xv%~Ist5PIIFj3VEQ2TN6l zM*>1#*5bA(uSdn`dRQ8Z@y!mEB5g&KOEd?_oSY>u0np4t!h<68svERkYb6J^zQ*dL zZl9uvj<%DRppEE9sEoz|2~3#8sG!O8=~L@RA2%d8Rxu%Y9g{Xy=v!H&l|(%j2<5w` z_UG%Bha>vkM$;~0G{GsTiKdC@S8Q7`$`pwQ&FiSpm@C-!NuI^xQZSBlT}{_M)r?`W z54!OhcHhq%$)ovBA4TmHMq)*EE?^MEb<23y`k}W(mOAwf*JrmQ{`eeDBr^LZEyx;0Th&}ug>{C{<5yCY1 zZ$90FG(bYm9Tk_OMzXhJekmydX+a{W!M30olf0iP*+c;A1PmyrLl9RW`XwI$dm#ab z@m%@zn(|fw+!F@O7i-D~XpkLGe-yN1dz^t&xZtIiB_d$n4g1xKe07#x1IE12BKe<5 ziKsw|Y$NlE7ZkK_ujTEexPYakYPLfJbxNd}xZ}&yymv}fBzll3KpK4D)I;Qn>Y|=f&I9}{d-eO|nss*n%Ta#-axg=D1?Or+xuu46pvQWc|hO?@)${(~N2$fYw@&Md*)x z1UJAW14ly0@S@0MLG7lOSULeVtTe2S^kUq~ud@CZch5sj+|9S!=(&7R%K}#m+Y?fr z#Xn*Hzi4uez%Ue%J|;T^C5ZO$Q3?G%I;uBj3KnoJM=rucEqU){y;H13GPu@<7_hoT zRQMhguit~kQKD4?y)w1aW7)J5keUfFp;l2-qHHAp&p=(-L?Z4CoCW8M zuf|u07U-LuI*_cE@ss;+g1#DIfT2{q;^?!GSIwJ$)8!$!Ma{o6O6Vd<%9&YPuv(GLsuIQl+7D2rwa?OnaxXfCA!LtJu{rF_g?? zl$Dgb@nX$qjG_PMoGAK^+4Ae;#fxXiZ_BtMlr+GE=j^p65zce`-aGC5O8b=nAi(4w zVxI=c?v*&Np=f&f&jqARP=6g_-(3(x#@%B`_#`80%rR}i(;gL{FI(Y(- zNk?fuphUcoSReRVw3q0sM@^U=e2c5pHuY1FwPN9JD(VaT{Iasa%@5hr|||Krh_%viVK#9fx#D*}|t^#!oN4 zuTldOWYY|%g`aY&TFb6_*?5X1or@=ZFUX4viWO#p z?_9vjg@jXCSh0Y8dJpICF=`CbOI(+fiCj}<23oOa-_ZsAT_eexSyK{0K{9lJt=8xO z4^6w>kbUYjUNBihTlJBl`Jo%FMxSOV05rf?SF_X{S-NR?ji>Txu_tJ4a)~ajNUSNf zCDq>q(reBs9?giUty+-VgYa^w!ZIjM@}3gp4)w)$s6qGNlv>I!RQng%U&bYUYbMF(LuL2}ZFx+}SEWx~c2rwQj60p>ctdVIVBZ>wMyb}UW+X;ay(b;dD|6HGdC>RS%#F#%t78r zF{aCF>1fNW_wO*lbY#+z>4n!abJ8@_T(ice_BFO~Y;oXlk&VT!WTR<=YSJ0@+O%>~ zz?c`B`8AK`VI37aO?YC=Gd$V@76&m7l6YY}g^(65Q}QJ|0r7w|+={{;W#Z1ti%FAZ zZS`i#z1D(n$wp_gmKast91D}J8(!CL3UT*63mKK3++@h&#w)C7tge;s#i{&WFBt_X zF$F9$BBi8c7iycph2GEmAY%2ip7>G^aS413fUm%>N77B3N=2VfGUl@lB>5;U#cd6) zRi)$wWW39z%oaoUb@I)mqj}^bUgBDkFt~5P{XdzCg+Q#%2&5h~giII3dM0^>sk2k` z=Rn7C$!9g4J#wWk6VhvlfLaQ;d4ZMLSPEw<9`O@c5&tO8sNE6~$+8?})U+}fY@$M9 zgS7ur(XK2&a0W3YkOZ*gDFpBY;kW?TUbwbZ5F%!d8eOxVk~r%=)i!neF}MxrXXR?8mG2(h3%;`-T4ex0^ty%Oj&)9{I{n@!*-3UazS+GkyL^?6DA9`F>xp{xb(0nZ zB>g$hE@uJ7;2Tg3gCyRWKRQ1?hGG}d4?IfXe=!54MK3M<=37nr2D6=enn6M%-2uOD z%Q$8GwmnN8X3%^)5Mc(e$*s z88+#J$bgH=G8uRE5!Ib{&L^pL8M%3$0=GePT1){?1+^a)WhU6QehCg9;sT1_6OoU? zXsD+L@B?5*fzyT{vwk|64VP)5JQ9O9C3~+D=Ad-xc1v9FtuXeB>#9ZK2b$gm8Acnd zpv8h=ERjP4MVzG{v~+|-xT|%ds?A&$5yxqTF{>4KfzApY;7#d`?LYc8yAlPSpjss) z>~TPryi7}76buV<8a1{_gXsZQ^i~a3Y;aRO^R`ml-VpW{i3|z{VmcU?iYX(;Pth_3 zzatVuW%D_ug@B>AyS$wAiwtwc%8JM^)Ia3>!M+DS|NY-p7B#Y40>*5^I(qn})1F_$D3~RN0>lcZk}CTs6Q3RYasR&d=;3FKSxB zHty(hu{FK_Cn+Fqm!L=$C{PITe3r0#%9ilaG@~RNU+N)TxW!=hVyZ{0;!^2zOyx%XqFCvj^!B6JVX}jp|mBVJQu>Okn52tDjNxivm^u{KE4rBN%M1=5Gxm;1S7pBEw?UG0@_b zcLb)Vg6T3&21nPdZN**qU-bkya%Aub=!~EhC%|uWy8}=m$emu?f*|{xTO9TW57m9%&k| zDv(b?SNfcjrY(?rLsfs5?WkYrn@&^p8#(D>=k3)?Gb@KN`o7R+y%M~us&zxdDUL}e z;i2uLy=Y2Rsr-p>9u*-tn&zRp%^N%&I>F84?LMOjXGIS);Hr4QiAm<6E`K0 zm3}s+O3Fz=MglegJ6rZmkgC+44?5)=B?Q=(&qQ|chuC`DYD4wa4LpfSWu zC)Xa$4xQKtHfWvk7a_!=mR-Fo~%Q*?cIb6U$@j&Nd2Ta%C4q0=GKt*dgntBInb}+qw^^#{0|u4;5O(( z7%huU)k!$#nL@&cCvG}80Y9Oc`7DMD#U%z63+_j-^f`F{XCtxi#35t6hr|-vzOO&0 za}J1sW@bod*Sq?YP4R_uXze1Mx{zNPDr5(h{J?-ohuBJkLg!O7pd{BOLkV_9+rS)u zEklWG$FrtPN8Xz?KCPIwM8v^hlb%XS5BZQTM{i|TGrRA4G?z8?Vp2duy0&G1GJ36)MH;tFn5y?N_@nM0#IhKNq<>@4B~vG|_SlAUI%vV?f+S`Oj=JRe$VME#~5yoQu* zbG(JU8#;hYPPThpU8b=7CQ|H~IY&1ZJ3~ivjw5--&!e2qY3WPUNW6Hf3AXZNQPYgY zXJU^IX9{lEDtt5Wnw@F{!)eJCwXEm*)(FE+Ujd-HkRff{( zRW;R{?Z!XM-u8eS+#F_oKHuO;x6w$dFi;ENDW*ag;UGih_t6kj+de3pn~kk}ZEdjq z&N}Vx=X^iB@2!_r=0W*E!|P%ORgIzQ(mcyGjY60mYZB^cj=(}28y$|5bSx@$8}OT{ z^oRuMGc|#-hV?`J9;AvI5ra0k*6LsE2ZOpmD4B^rp~A~5}~vxqaCBH zC(4>P;t_e&;sqt)^%6LeME;B=f0efty|`oDhOVZD(GZnqukIz+!R5)N1eq@l`Iir%LRq$2)4r>tC|X_>pXYlQI}|5NuXRT0MFDK*0Y2}e1UnI z7NEXc^_4&ZB2m|UZH;;>qJcR<>?n)ucm(c@a*r)ki#aqf+Q7>ND ziSIn>W^bLVHNisV)Rh@+;*BxHgBgQ!B`te9dI&2OfU7Sf0pK(Lfl(3n2%_6 zoJ9&fgaS87dQ85)z|RhV4p5L{ne4xNElrO{8Q?V(i~_fAs|GvT;5*p>Zc(gR|LN{p zV(}@|ZiAQsYz_yEWONl;)nM^)@V8nE{QZ8CLIFD2@*tS38S-IZK3&Wn-Wv$OCGb;O zq3~m`H#1QGZnu`{@SAr>Z3 zs6uhIrgD|Ky_~EBYsp8^=mjMcPVi5r-l69QMj?Pj#k_)ba8=&%cF1H8SJlR3W(424 zJP3()(a&m`5*g-Prc)n>73`5~>kB4C;IG=H*8c7XEwcotAr>?${CQAjnfd1d$?0IFtsv8Ea*3`ZJ5`XR$v?Wv@ zM2s<+?n0k`;tPQD)&>9>hNB@MkDdF`j2oK&Aq?z>XmEim`A&F+V5;IVmp7Y@)S~*kjY{ zNsj98#=0ctZ;&BQ5|3ryeX7>|1@GjHLAvv!Fg6*kp3qt2xZ7; z@)xEcj2LP%#fs=+0I~fb+}ds3eQst~Sr7ZP4!u^!!h}`nc(sk@l~o8}l8v$UFV&S1 zqc7$SDlb%bBxiYdD*J>$d_k9M!<^FANO;{n5Ql(SER-u&#`4XZdIc}jd_c(&XFtx+j^@#O&z?(y>amxNW~h?K?Xg*v=MN;M-zyFhK2$Jyxw%kwGBWKM`g6XagA z8Yk2Rmv?OMGHtYhX3n?BWHj?q#t=G_QLH*-fOsZ5__)N(%k(Nba>C|kiVQ7Vw%RAM z6DdbFagn7SPGZe+-Lc~ubsBsfHZ3cL%m9;Fh!rsO^%m~*9Tmsu}A7x}10 zcfK3m_QlT|3wgL`m6J?t?gZ8@Z|yatDU^KdCP@B&T!PMOcB027s03`!4@ z&Y)j;ax5rJF3yVJQA)gik1_qrT6B*ENrNhDL{ChOm5@UrR$2A^2}w$%4*b$2QVbML z1s`;77bU5nh`PQl+v>F5;G2s-(-#Vr>S5}pJF>~u7hijo|5h_;-onFk+Na(4F1Z}8x2<)eyw3c>CEMn#;EIpmWoaL>qT{v5KTAJzYUu{)DQ+JTv^B4npL$ zn=OQ2#{H5-!X2Dn_7pYF$1Cb%(bo0{qYhTM@&rAd=^&&l^;uq8ETazJ*psPXCr_rC z_;)Z}3acb4D(W76rpkMQEm84IkZg<8RjEY6?**%tQ9i?RQbL8@>1n)fm#*KfDdCzL zN0$!AP~1RZ3$!z0t>v3Rubc{wZi^d6qbw$V#i1)ex7;do-iTEMcS;b6{&>x&JWVG2%LGT8u-_)ZRH~nTk$R5DNSH7!=wuDah&?wN9;POtU`l+Bi)%w_$s7yL9ECgE>;Lh0A*0VOu~+@?if-IlWHpaxjsJl6hm9?_>TRY zUYpPBmQ#)HTF1vYog4|K{>;K?W4F*bY1*YUjOvBBGU;sizd2USz>z_C#W$0IF`XQik&@J zqyE283;3Ie6Q2R>OaI$V19Kx)OvnuP#eC2=Q&YUt`(kpokfQ2ZTqNM{+Ef)z#cd;# z+>?iqsx3kRqZx<;l-^Iu^5k(Y$(CgFt(4~>&PoqP28xsgj8LywqYfnvZPzr4WA0rf zco_95T9LT*likJv3B+D?t)KO-djl!2saZ7SNvL7p(bAu~m$!Hm)YO77alr_#j}=>l zHp6CVgXfQ@51esK0YTWwciBaLp$OH8*_rXagR>6q%W?`7T4`1Lmf!m}`UdYlVw+F< zeb%Vdh0obTA@K!75w|9&>H)3YLNt|Tqtw#(xTC?lKe&R$Q{Sldui2yzJ8gKMyVWn* z*C;Xre4q_XFfR)=x3JejIw>>w_*Yq$To$Nz3(rF$+k#LHF%ZA2VM%CQWxcKwnSQAp z=jk4V0E)W{26GF~3+$&{bp`@?GH;x^l&;G4E<<4J5>O zw%(MK^;&TnE=nI>vDig%Ux-C3|19wWrs?Orrd;b!HnWhO-857&}OQ&R}V z^L=qLg<;RNU!xS)MrJcpuPYfy5mqABG~@f;h(RgvTy!c`6vi5Gz?kbFL)JPEY-WlgM?qa&=UF!Inaw{%{+JeBt`oROWiDch5tBW_~~>yF4qlIILqe(;wRyFb3B z!fr}d00l6xq7AIUG|?qaAO%#0j>bYlFJuHLaPc}9FDODGGR^5oC5$FUnyhYMzdxU3 zkbr>vf&1sc+5?z*VH`?6FvJY^N9e6Q#3C86sIqP`49F~CS8ORHHo<532LC4x*gwS> z;K=cIeecIF#A)E-pfNlncWMCV+fw&%|SucYckXpjTz+ru`WP`bzlDo&dvnNf(>Og_HZ-)eQ=9l)cHyL<08 z-n=?s9i>8k%m@7>qr@Z$WKAFdBMa;$B2ZgF2WdeQS_Za|AR;h?1kv0!XB(xKlS2Hs5Zj83~Mtm-*++vqlXV@Sj6csvq>(b zxZkt>T0n(=2ITx#JN=)U*_qAC{Q4_c>Ubk+W+oo!2hFHz6aE0pr2O@Tx3PYJ`chC0 zYWMMs`Gb97HUlrMyxE`7)JC@MY03zOF!(7xADf zTBbC7spwMdHRxhle^8Q4+#03$r*}%*gLE0}^W~tpBwqkDsna15xL_UqGC2Wvqo!Fh zZXZ*bDy)j69#H!vn|;g=;+v(ycyO6(M6uw5FEck`8yJeqycG0Dr>(I_zqw1G;3M?R zmZX+|+QwhGrZJ&O&>N&|?%wB9x#@DN;eyKb#iO!earYG41?E>p#26$-=S+mCshpg`|V4GsIXq7u}o;l6a>oqg>SM$GgQWftD471BdJ7w4mtvnW#4rih`WtKsV`kKgv5R2YS z4)Mc7%~}r6r=UEPSVqf-xh2JC!&s=({bpf_f4sN~~g7dak8- zFoleLjU|p$DM?tanfq7(h9G;SAcihf0x;L)Q_I_9!70@oJH@)OI0kIHIefj@BpNA1G#*_c>E#J)$)%%+ri+9lE*p)VifE!y3Q!fWl{_l5Lx6G|MBV5KWi`6 zK7IO#|Mq|Q^V41N*GKVO{O|6kPv=YGe+&5E<>P}t;VHbQ*NaETqsjE(&vWs+pDz5q zzVNSuKkj|0*S`lc^XZ`e{XZ88{!eObHInzQI}AUt`zCKyIyfsO_fMH_d;tLYB=qqX z=!aXVx|32A1VJb7rGN?U`6Y6@Q*{KC%&5w!rbxQAOscz+1d4VF26AkhmULw(mg-hf zF2l!5@u_J^9#APP8`70TmoDeLZF{K6jTGX<9S2wMLR5OuW;z}ZuGMZ(A0Oq?kli@2 z`tsR|Ik*Z~llVY!6Q4%zb&U=Db@u;7JQ3MNbFTbcOt$Q(cN(NW1j8d>i>G}pLI*g@lR#lb~WITzHkC{4mKOf&*Y3V zTtib8K1lvlbxx`J!O!HCbGDXj;vWcrz0>oNcv3?f;m>FV{Mpz8&Wt_4chbkhb(URA zrX78gfG@6{d435)3Sz9^@g2kI!nsgLgY)4=l?#I?Lo|b(HIfV45&ELa`b&@7lV(>tbG&*& zzMMC6B0xB9Pxc^S(uzC87dP<{;CUjRivISWld*z(T{`}9``Wm)|6IF@S?x`(<;0E^Cfk!csh%9O^(lOX{21V?eNqpYSc@}}VZ#z^@m$_r$bR`PR zspxaMQUT9ZJ@viSTTOquYCTy*l`{I%BQk|5lmpX>Yr;y_US|zJ0yk z?k4Xygm?f(Ef*5Sq$}tY*dPP=F3TqUOjJUhHu1_cWpfYL7x)X}6Q?!aL&aunPb6;3 zztUopXBWwg7&99LkHe+9M&)>31b;;aMrs|NGY`+i)vw<=(P zyu7?@V%1Gd{yRto3tLQ17W+l7Ts%!jeL?%r7SsL($gKSZY}q`W4hR1Lx=yGDVo*P) zj6~GJ^Kis$?j040w(oLSGopeW<%TjQBP6 z^<1>&X^&jSrJ{pP)XYqA_{8sKIXxdAM2%R>ZQqZfJRA6400yTRjPrS;QNka(C!4I0pzR<-9~0 zyW*jrETcLt#(xb~Qt*Ok>!}qwUW7coN%fH8yltPk9o2Ue~!3^fW~WGC`MoFp&?Ab<*;> zmqP}Fj`;LzwY-sh#uo;EN2UkaKrQ~ zHxr}JFDGbFgc~5K)s`2;ckLoOKCXX%RR7=q>nOrGrsMIXxXOp%*JWi`v`#QjwdlQ2 z1L>8DB{U!352s3+IrLTbPz#_ z-k>P6y@JAZWH+(XNgc)B;&@i1Y&e0Y0<0X&rlmB5_Oqv8Q1WVo)rj@|I)K6*R5)5z zjTX@R6)c4%WzPVvmmEmhf5iIQ@;CEOt%2>s8<`!bxqhbX%zIZ)X{_jWpIvi z0IM#qCL`ujfeR&%1rO~>o?NPi<*!=ZY(|9XR3FwZ)VaR^5ZnFPjOPV7*2~v^*t#1h zAiLM58y|NdLXNoHKTUj>nt(1BB6z+(tlIBCv)=f@PLk2I5ZhH7S=^-w$b%4XY+wR; zwDO&I^o8klyvrhOtWdTMGh?qeE`#~8Q(cs(1U~l$Hz?^hW7fq?#unxcarTv zKiN%>(@9P$p0fnX)uHw4@%vLR1KZX zWXU$ldH~m&ZbW|mf@qU}(;xpn$VcGryZfb)z!Ha`X$03(bT1M;y(y;39c+^31L#ml z-U}lVy|KIAshF7{_mfgjrOXG}Xev;3MzV0qzxef(>ctv{SsMuI>=ALA0$F&?;uLuW zeiMp7;&y|xnFjbM>p{+;35G`)l?2DTMwnn4B`&9yIi^#?n<%f}X>dA;z!#8VS*pY$ zSsMHhBuVR04NDo*_f>HFMk~+#72^sj*6gxkht_3|3jC3Dr7B9w%@6nW2^qo|=0gt`t7!F1rDRala8`z)yx$332VVA|<#GxUHjcob1;GX4tsABnqQ zDbnA`t@?W&?GG&kuq#UXP+717Fq$b~z~oSTP-(MLm-fqquxZ`?C^z5a^M%=-Oi2fX z2hwF_N$fr^r>*Q2W-OfS3D(+Trcbhd!so0(TueC3`??Gp~CG^FGhKsnVF@5798^3iT3Q_XY36gLLxG9eyGXVt-A<|{Vo~Q${kh2OU z2Ad7QIke^@H5RVjIC^md-0T++Y=|xKJ zC`k=@A?jygxp|*#(+kT7BDgKIGZfI%TBsi<2xLE)rxBNI4sfdr%%nL z@BjH{?Zwk)U`-Z3;Xn1IAO5+hGY?nb$Xg};M^~*|@MX(gdy8=pku!p70I%Z8k_61S zxK!Evg><@%XUOW+PCEw8rK(W;SzBIm=3wOop~C@Ub#V!pCjJxUQ1tQ;$rY{kdBfm} zXYhsE>}*a1hbN>)vKJA}zm%W6%uh;d2W*7%L2nTisK8|sz0kMeBH>F;c0vdwd#1iv zkg&yl=w=j&W#Td&=HyT6(#|3W1Fug%K99I~#Br_I8 z6fmVdNArzk&JvFubE0UX)NQUF@h~T!966bP{vp2p(n!RA(<}ThPU1`buD?UZr-wXVAO{-2}`Y-U`HC5WtqI&CgT(``uDg@HQ3p~W|`NL$I z4>4f$_>d(O!ETUXLk=@RlXc00--Ds9qBX1E6Q1*?NDAwc}!KHZ%|_`p%Sf|AZf zbPOe30Xn)8GqFN`pYtJVaKwC-(H3h^P9}$b!6!&_qI21x+K1{tm9DNj$aCzT4=Zfj zfeRN*+?r#!kyX1czWd>s);lqavzvXjjF(A+I`4Oyt)nLXj$&+*9>mpyf8dSi5)GZ}dxm^PALe+sv-Fj~laduil_M zEY=Zti8-}c+g<%s7k8t0l#Ms9H{NtLB4Zxd2IwiEqOe@LR9mQD^xwdQL-uJ|1J!nl ze3$i#NuS~ay%g<5AcVGXB0ys-F~o|Yu4Jzv(67LfR>sX8q700XPgY>j#)}EXr&2Rz zhYhj_(83A-bShsJgACXo*^3{~soL~&A>cRAZZe*puF=B3#41b_k%dF`SU3HmiQ1v~ zAjCE1Y%fsY&`rZ+Abh9|%Ad>RGKErq(;|8KeS0(cu)Uw`zf~aQ0d%Hjw8^4xf_6i9 zx(w*X>bDR|U>DUoWA(IT$7g=jt!e=sd<3g7Wk=a4yL7i64KgTAWhQB2VJp9=otcQi zde!XZd)-~++UHU0NMV-)`gjt71~N!r36!^BDErv05l;E`&aR7`{;8-y=&NLyLytP zO6Rlgk@~VXkN)=}h`hy`C5DAnAh%>-jeL+z;ZXP1&+O9w=j$JY|P-j6=Nkg243 z`a$%THMJ`1Y_(Q30HE=5kyP-khRqv-@bmQ9(i;N`3*4EDQ?)CH+PS~7)UOmNL)r~L zi*v;EImw&-*RN%&y)~W>&PF@%<%`e=Dfti&jJ+uF|vJ55? zD%fl?3#hyTq7yr{08Xx{XJ$&k@(VLiuIqvq!NA)HT2pVhCjo^T%6F4UOzT&pLZP7wFd!Qkd_G*arjk0^2td(2+`K;A;xu z1zh0bcl9=`4+drf6!4>vH^7~R-I9W9_&vEH_C+F%<9y)M;R5N0C6{uFz}!}+9yt$q zCR33;wLqg>Gl8_Vj{pV|iX5tG7%iSbH^-U;(1GMWD|)bOm{c|vJE*%>eRcyT58e*}Lf9A<{cMn&k4qu_m$K3U zXp131*?5wT#U0g`y_Jw~6I8;)fQHZ$L!_i2#3Z3(NWg^RkOfbd|4(eX5ZN4;);3^n zPdS%N0^A*4MWIS@G0Y|>8S(yfP5RnQYyhG#qWsP0#V4g|-2ur|vI18^ zWY;Q(bWQ5i0YoL%M=I-_CPF_S#Z%xbB3n>e#bL2={bn`QR2G*_O>blh7p98ZQ{1U| z1@&=(J(YZ^Vx=}2#bI)?D@}3`A#}9p9|DpZF2J#(+$B~UWm)SE0QmP5zKX(?gxK?@(9%0694(7Qz0YQD?r*v3ABwL3n}sy#t=g0h5MHj>4!RMWfl6 zKF3DcSqc?`);T(aP&ORNq8Ou?f4Ym=rZGkb!AG?= zOo50foQZFi^^zJkqASge$56+SJis;|eYV!lZU8+#C>Ghs_4=pTWQCQ7dxtG*)#an? z>Jr|@YR+I6Ht&0JhB1Ew)~GG*=+xlprH%EgRcey<2Y>p69f{DQWT%n?b)p*XMBPO-sXnsZo#vdi>-pu^F9Sws5Vqz=~U`tF)O$t zzYTBmn{+-YY=a6*Nj*LESb|Uno>5JS3E1pXwCbgkzDcadaZXl1u`mjrQ`!bIr%L?6 z!{9^~z`9I<&l_TsW%MLel3Al|T#D*e3^Qn}SLBtUCk=N7_3XwQlR$sLeAS$yh+zMc ztGN&&T9YHOl5sASYDE#Qx>qH99?DGV>J4c&tCPpqrOL$fMif>qt*u*0o23C2aqAg_ z)J2%`DkT=Rx9x;p6-fmyfE6CmCLUyBL^%BDi7v_%9+SSMrp*NwkcoC%KSV82oB=aHdrCsOAWdo(XwZ5xV!>jc_xAPXPs{ z^EjERPfS|1zin(mpIMJ4ZLvE(i?Ca>P;XYkYHwD@@SoWe1J568JB&MmeunZ5Z{(+K zHR?LuE}pCvTH5Mxj{Gt|!~cj%vsU_io;=@`Vo3*~b?9@6XHg}swmmRUEUv9(Y4=fu zAYQB4xV53C zn-W&&10$@XWBEx?Ie!egt{2UZ^vQum6Lj6sV#t)N8W4c?bjwZg`^GDP$AT z{CY&Nvh*NvNlA)AcidB`^$9XZXAi-T^3b$+4dokQ8nt?J1lk-Zvss&40+OAHy*!I| z2G?W3FG4o885*f~tke^gos;#lq(_@FTTBZ&;Ns}!lSHzfvgmJ`le^^*YCYTE#l#d~ z$OY+i9j>j7@P!GrDij^8E;N@t%OkU}k z9*1-F74eub6uu&Zt=W)f^VT=Yv6tg*~#-!u~Fm_jsQj zE&h~Vq`R1FVey?Rxwp7IrbxhYkx)a?2tb?HSfw4vgP1lW1r7SGNrrr_(*4oT@_Kkw z49rhOQ|PB6=<+8|26@10b<4Vrr4@!_ZoQXqV2Q{P>Bfo{M?xM%p7}bVqSjQu0#rHp zmAv)P>jHMOnDny=75f(8E;FXmGxeVT=l?uSduRXieEi z$b=O@#eX4*qxf;Tke0nX$7^4}y%-LQQImtUrqnRZvinr#G=54>v`=+R<5N|z6kI}J zyGl!FU#3idLNIDTE)V?i6n-qx-;h{2#$EJ=VY(sE!#hbwW)OBc*GK@mle) zb+QecvS?ul>)oa|Yduk*`jSib-Ys+UUJ7IYatz7iXx<#zZ;n1`_L`X9n*7uboDw)? zJ(o11t|O{yN0HBtLZ6{*%krFxoA^}*HFq1y|M&mGBL;igaoRRBnr4k{EJ9&DU37j_l^?}C(uEz8Oj~dty{lqd-%Ct_o zG*r82RXQ41WoYKxi@#agA1Y)(-RZ<7(!Lc)2BMmBqosOgc_b^Nt-&zFth%z@>KT^$ zT_b_)g9-%brum^n#PK`(_9o4*)UC3F%`PsBVaqm#IiD5cY3-LXnzGgMs4gU2(7 z;ktISsr1hge`$z=ClxCE?TR7KaGl~Fk^N#MiTG*yY6ASs3;k=^<>H{;$^r9*qe+#6 zVp_h-hG{;6y?!PKT5v}&6T=anJ0C`&scsqvszOSFI+kTR&C6rZZ2xwSA$b4%166H0 zP`JjzZs7#6U*b@iUpQ;_8z#wrT9eg5xb-iGu7w3S#duMy6g7ZEt(6eKy`2b!X zqk;hS4q^toSvu*R*6JpVpjLArx`1IQhAyyzmZA?V zvog$v#pD_zM0(glT;~Ot?l1FE+0+YhL??=W*Uz&-ev*^URKKxU906Eja>R~vCP%cB z&T|Yop;~)h=PeRF0vYS_x_+g$_)BP5$yvd6d85j#ynUc8lHxBl%s7l$!{)Sf8eTU7 z2c=$C6P<{Q0LXvcnT_N3Nbi^s<$zU^5S0L`#x0z30(e%RN({6aMS&A}9}DtDuCNfG z^;f>1do%6#+4~4b32E1;{efA0*s}uZMT-Q78gSe10ORl^-j9eBHv99Gm~{Lsn($fP zlE+x4QeBaU0u+aMY7PZF4lD0D$~+xqFe~O~v1b-{W~l{bGTHWNitbLI?k+8_tlqo- z;Nhdk!0cLW(f$ZdkfwEd)az%*C#U)6v*D;1|28S7=NFe(*T2KZ0{(A`MAh+?i@T3US-9*w4Yx!Wob@L zcT!MWVmj>-=|L}_^v(sHg7igAXJzjYYHC>)Onz{dUAfUx9jkqQ7eA&8zb`F3KKKK3 z2Yy+s+-&T>MrVEEe5Fyj`q=zBK)oB z(1GVM0N;Hsgow#A;f5j;Xx2`R<)D29BJB(tE~a3j;OZ`C`!X-Z-L-HHr2vIUeSUl_ zwi^ z(mS=eK)K~QBa=A_)}QOi#|g^alaHSd!1v@M`~g4n13y+OS_TrXV7|zP#UclmEMp1x z(BFljlex46WEuZu?G^RzMidf~!4`|p4{jbT_&&=|P6c^T=%ke}e^3xdKD}o3T%Mbx zHG5V#9CxtNdX>qf?uWq%S^Qs^(b^96B+p4IuF+H@^Q64fVww)#$`{~8d_Jt{zL+<% z`u0v;rC9`k62Gi(fu)AspPfTVc1rcYsbd9m=xX7aHIBu*V}qws>inXWD<19`7ig5M zw6BkJFc%ORSw7}E1X|kklRwoX3&W&t7r>+Sys|sXiB>g}_Gg*>sMP6?K9XRwk=kh`Z(L_wI+pN8FX@rh45_rruq0LkYf(S>x9Zu~dW~S} z*aoFHoski8H#-4d9*!8x-l!frz9{RqFUtBYtD?)Q6u!Nj-+xZ=YIL2nz2THG9IE0X zH4|fxfP^G9a%WW4SCP+1la{y}vPnHyN*iAVW<)PspXL`$MEc2jZ(2-VG%>)0W=HMK z>|!bL4$DJw#zMh~)ga3$hU6$M^B#F)LDe#-SUDEhmzlKmN^_WvnwR-mKF<0%DGlM* z;#+9^Yi)m&_lka2|3?e@`*n-;_v>5LUoe|qYwInmcj)la){R-ZH|8_<%0!hw6BgMP zlUbiamUXxd#WV5yt>8JP_|Vrn>)d$(IiVtj9t1*NwcJnYC0qo^x_jpihG&K#1@4(e<1e*I*a`f zr}F6h1=m* zA;ZY-{@b_P@AeYGrwy8>GpLlJz6y-Z;+1_au_ctN{?c}jLS_I4Y| z-mY@RK+HVOPtGTx$eM!Y%yXuduIpmDNAf-@j#>O3JrmOHu=q@VG^uzb=regHh)XCJ zm^Zj)v4NzR$D45v9FM>;3HqfXQ4kHG3Ko|+OiYj5#P-Pa$Trv^1-0r+L){s2wgR${ zdcVoXhD#B;%FqelbSK!stVgA+U~AZ1%mmO2%GhGSs-POFtmP@4a_adzG01n#g~Bv)BI>q9@t;>vnVup8;bz%0e zEHzo8gfu2Uu3NejmcJ9cHPikmE6X4?lqXEFs^DRW>=ne=BKw{Jov}qd#szplbEe^z zfqIoqZQ6E}o#Z35LdZjGD1uVpBasu7QyKbL3*5%$H>Yy9pm350g`T9!Ky=0UYC#mF zK~r_6DTtX!?C@ZNn)tui;i1ua(Tjj6Baf1H2YUgHtPRx0<6u!jJUt1sBY?bY4)%1S zu=hsY#2M(x#F79)(Nq;jQI#TeBbd=c5^3s!x+;Mq#Jr-Qn?RgN^;VA{#vgUKHAvK| zv+=Sspj8Lr5kJfamFG2<(tnZ<-+^K(uy&_{FbvMKC6rzru>cj$$8RTMFRnNt9^;e9 zaMA{=eGf}sF6#J7KBX==;Ke&7m_3(vU%)nWiiYIzHPN7M;h_1VPKY&o6_C%=U5AsP zhOY$$LC@^B z*>(gKHt^t8&O(b)qXqTA(V`3j2KXifOX(uTQX^R?Z;lvpwZ4k+4+%iE{N&4;er9r5 z*r1VlrUQr2f-FB=YM<(AoY;{Re4h{oZg?hTCMmW#An5BS&xi*C1?I1E8r(_LM<(fbcO2`Gu`q(ipO0x6xnH*Gc1g_zcZgY65NsyVP z_&rv z61?|`u5L<7D~QoiFonn*Oel&8Un`iB*J(L@LnGasHNknrs+=m72QbB>ES*3u@}k!} zpP;ykr52dLAf@X;c1+dEq*_FC`4+2gvFNAiwOC~DOo|7pw-OzslJq2ncz^4QQI_=w z8MWsVke>+Fz-q4NVB`rQ)Q~Mee1)Qp{1(NIjbqGsGnI-3)h)Iwl{^$yBLt)bfXIfl ze8Fa@uu;(F zF5450BE1xHflaG*Sh94S*F`7bcniE1M_dEpiKMhIg7n(S>7YMPRCx#X=*0^`av9I8 zu3l;=e~Ly#R>Q$FCF=f5lOaen6>aaj*|Fes0(q5o!P>M~hm&a1WWmwQ(mFbNO>2yD zxY@E)57;B?0HKQYUc~h4EJrWpIbxR;Q2~8pHGzm26@TfFV*-}v5LzBM&Z~gsyMQt4 z;9tgZz69!$K;$^<&j6Hv_*_m(bCu4hie?+(wvj9~_}KLZ%ddej;cfX?;D;fhMV}nR z^hy&D`^?&m9a}ETnltvxvfS}+C1Y(pdurLqd`s6y=80;rns-xY4y&PsTSIy)muvTn z!`ZuS^z32Q=C=WR8MFfq#gaI(afDAP z141h~&Wb}KdeJ0B49pd1{VVA>qNE4q7SczFC>uAc)mo$`-#8H{glT2`05y#eWXKPM zs|8#9k!Y-xabF~Y=%>7Bk|`fx9TYprn4c2Al$>TBd8De0Q!T9^RqVCosppS8TeR+$ z8q+x|y$X0>bUn?$#tXig6cP?j8;~^v$~TL<34+bZmLoW=z4OVL*4fE6_E`g%7oB@Zo*%gfg zDRlNu&mq~q+#7Ig*o$S`!KT}j*C{5_<6j7J_*RUVmsC^ci<<>Uez^x0G_?)A! zjIIx94e?yol>5^yv&yvg#~?mKCyuP7gH(>W?N&Z@{g0gV238)ls+H`X_j-bN`s>zW zdF#X$Hs{iUjx=G-%#Uil>D5~DWeuWs2dp-6r!EAlgc;Vno5eJ*W+2W)<@#RPGwvuX07Jzx0)f|si|xl zY7l0yt)$v0VahJzytb2$`~>st zel`8iTRV*YP1enpF?-F$s4b+{GrExamU3c{mjVKCM|Cg6q+ZLP+Y|eztWO}R1-XlDL8UA(gR) zihfB}iqEIX$>e-EzE093h{Qf09Z`ljqmGiEe>#;aSk3Uug??TFC$aztw189jcVJ$n z^C2}_JW59k_%uW=HGk*_FKBt7GN6LXyy2LkV)QOc``5K&l~U0Z?*W>s_jCfScBdFI zj9r6lKFFpS(~C)-NU6&S=YUsIgViki#C&~gc8PIZ?8{+sk-2z}{h`gRcM1{k))8=d zE*Z3{Jy+g(Mi%gn7b$@~LS~c$m z7`>r%@r95xNeLB7vU9V@qdCHjR78&zLZriVY)KI9DS3HHk|6$iE#Lq@|746g{DQ!B z5)gR@+oNoIvL(c0BTKSAgVxhxUB^lq)?T~(^BMh#=}h;Wbe+X`x>u}YR3YWyh!J*d zceAlnjkAO26&XTtWOQg(`4(l8NRxFD`7u={c2DO8Un8qM*S1IMuIR8VGZ+!N3FMVV zQlk-PlEDQ8J1#8&MpY%iqb6}+p02U4aRBoQKB3hD?szZPto|Ha);T~p=0SE4J5}gz zKFlE~1S&hJMMCWeP-7lyP{?S002E}fA3jJV;y#@dU>$f1) zNWjPe4jagD09v{GY2|WSYLKisFBE*-=L%Tv za|JGcNR80?;-k%6gEMRaS1?H&zN(*4s>nJI12U_#4cXHP^15mV>e8mAf14g8fN?W4 zUZKj}!MxbG>YJM1Y3Ku!8z|);c*adZOKOJkIKjA#2B!2aCdA=zheAZ_%bsXte}gC37{PhU{)YDU;Uy=bPxzUYj8)bs?g2RZL1 z^wbedMsLbTsXq}btpP_XIBSc^5)&=Sr$sE~3DL{s4zanStA#%HC7I~)HJX-dy?U~; zw7i;p2JUwtc=+Tg{Q2+cpg73|{|p4NUtEEG<~e@4wXv7H&U@LY)P;F2#AzLqy0d#F zSeMeIl9gIe2M%g-HlY*rb^$@HJ0(DnbY%Jzve>b`Z7=BAn*88N;uBG%pLu`bXdoy# z@K-Pe7=sR?JMUeJ{c^Vd34J0CjoW@J9Y-3MLVj~Q&!&;amsxtY<@f%c9#?#{>yPrD z9!Eavr_&T9F88aBd>&g3!Ub=BfsXoP3y9_r5fq!bY+l)?q8NMW$(-Fz%@-B0r*b={ zOARR2Up8%yRS}q`EYRbltlD~~M}rNfN3mJ+_9!N#z^Mz-$az`=iO%UDxFu^;R=K(w zhiHVHZK!W=5tV&IjlMwN$UsF9!Fg=pLf4Xp%tr@74#FU^hT;ne%^|v$j|bjxW;Jxd z+;lmFe>Yx_J(#uYp=m@{^xbzAD^jQ9wQ`+$ErW=XM^1}(+Q&#YSy+Bzxb1)Z;~xo) zn5d#k^kN@U9URKJ8FW|u9%9J2xO65%sgfaq4|uSVEJi~)L8bM)r1&+||D20$?@fvl zqKZ%8bI6%3U?{*L2%eC=glv|>)zbIka{t)Mud@CZUiDKs!2Cfo`=aZOiuq83bet#S z^CJNTd8t{pN4kcoumeSfi<>ps9cMyRkQ33#^F(iNCln?w{!A42I>0>|AmehCtTvWb zAB+FHFFr39%dD6D@Bg*je6aFwN$ugIWO6RnNlAfZ*dlbKblwJ?Q9uq$3$mXU}N4@!G#);9Y<2W-6*_tt?C5P#PGs_H2S`qh=jgNKhBtE&#kma4EJ2z$}f>VsABe~+x5mL68^Vi5RZ zbt{h_G#)+Vb6RRXegHkKhI(40Vm%W{9JjH|no&+Zv8zFCVKq>p!EmwfYMyX)0s}IB(6o~L(#p-nxd%YJ0l_?+?7G}SLhu?*k z-vcE$R-qsDGC8+BOr;tp#!b+L*Dmu>zqqU)9;y{BByWno(!hR{RFSyo11VEttM;j2 zRP_SVc;fQi%#l z&z?!o%|HK4?$iRJQI5P;-L9{qV2eZ9poR3HkO`D>WoB1si=eQfL!uvtvdG{7Ri&)( zXaAh)vKQiuDb-0*8F%%k7`G#CFGyT2%ei1GQJCj%=V_TQ98HSLQeYEHCsQ_^T7uM@ zr@WDm@3dU>BO%IJ{m;UG`guAK7lr+a2!>7+Y+DBa;Xw{%~VnzGa zS?w2%+0FvHo`wg1b)MbndXWj=DUcBEY3%#Dt@?*Dw1xL%wJGj;wI?0f^w7u&^o79w zY%SR;!1Y>gctWvrSTwf}3Ats=-22sb(%IfhsJ7Y)Cekp#rWi#v;mga*=H)6*bMM`v z_-X;aT3A_txzTzMuQoahD-RwmJr@7eoz5uotvo+D!4rci!u1@bIUIC=(BmGcz1l)j zQhpaQPdMuiYpd;b@HFrJsFMGbO$9V%4#7ymGHW`YGtg47W4Y$ENRsDR)=k`!LO2C= zqS*hm6jEG6UbwoJ=@5+ff{qn3xnH2C%Sk?^e2YDS8IbddenCl&jPeYF7E#ip>jbj+ z^#lFDgw^f~kQSv(X#^H_*j4?`xM9*Pn>ReP8XN7?8sw$;q?{ug=BX+^2r^6+?TLIW zxx7QPu}5jD`;O6@$X8LSqrf?f>S(b0R7VZxQ5}D@QF@V|q~u5z5L2oN)lF`d%j_r} zkJE83@0DRb%wQ_WW7JuPoRmFkJ`lw0J}}aQbBu0Xfc$Y1UAIIRVAZGmsHTVc&{nU! zIh6gB27@b6W@}fCT(*k=xB>|Zf52>0YI7?AZiaPtnp=jPO%F|)o01d;SfEj8z!2fD z+t)E})K}~(J^R`{rD@E+qjDx+v!8OvTkWQrZfGwVK&+kgPPQ{M%Nx-)(Ea(R8D_>u znj-L(pre+oav%J5UIOxM@ytfEdrk5G6d!aXn6$Is&IQwRsMG&(tUH8HcHq5S!J+B& zX4hb|CoX^8P3=1~@^^KHjuqGlQ)$6hvJZxeHYSSp&1rh_M&$<#ht zdAxjo>EZpl*WEW_YrmSYH7I>cjGp$ttJiI^8fEs}g;->@n(dqUX_Nu1{IdE4?RDZO zCxm~0=?OZ`(tbAi_Gjov?DzjUMgO^{==8twDf)57De^Ed#M#WF2Q_L?*iWog@!%fv zO4@MoVC8<}!M%Hy)#Cmm&{i(_+DhHa>WbaVa%1J;wfwcQQ& zv;6Q;WBHM7n|XXcVsKLZEI;u2Sz3D3Sbel)&1dC)#k!!MM^-m9pOr_ArF(Wi%gYgM zF7&hEElaLzsjJ+v&w zkMGUcuSadjFqZXYe>k7zrN)ERRjZ$srRch}3O$OD4;#x%0wo_Va}-!@-UGe-gL^l? z$@`5*j~+H2FWVNmdk-S|{U}a8Xxw|e+<5R{*)~Bxh?sbzIQgJ)|Ni5~!^e)f|KW`J zcsMEM^I)~{_uEuR2C&juRtv2p2+wgfj1Gjyg ze9(BX^q{fy&^B8?yjL-wAWlL*D~**Eo2ET{7^5NDW?gD?$+Nhvg;Y%+eH+U`-LY=- z{($V$PtVA$TX6#nOh*jE-GajIKVa2)a-&;dlAUB%uGwn2@$lh_pqDmoKDu8)52znj zGKFkv%lB3VJ-BDlIXrVACkBTe1g9oY9Z2xfW7|x3KiXwvYN8+T)>wLE^+Q+Py%<`^ z`XJAb_bf7d58P=U%m!<)O977it76w} z$C}mXj>o|vc>b&c81Q;-4+dn1B{!V)hUo&T-$w|mbU?}Y;ql6YmBk0mrA18UMSQVX z!h&=_HnUmy_kW)jbixD+rtG-g-3R|%x!=6kypJl7x9(RT;VW~n72}LiU$U`s+Mied zp~jeGWihybj5q<0fv3;zJ*>3HVPmOEUs;;nR589Qj~5^-MLBgok+TZ95yIiS) zisd`)LB;Z-_Mjr(-VQ3@FYjzF+=8nss{&sfZXY;@hYw~#CD`S?#>(nL!5rCLE-lX_ zv$jKj2r|;QzXCe4#qA;FY&1aV{?bxo<$<%DmHF=XV3(_cO&5TFWV37c?$5*cO{!+&<(32PqW?`09sBW zM^|e(l}}Tc4F2eE(feo7xqVcfAHW2sn0}3adB-b%`f2)Us?x2omMVH4yZNH#iB`ZQ z#k!_)t~Ibdj?br1Qv)-Hf^ijls;jvV=btsemgXde8x<;)Kks8IRxA$i+lhqi3Mr^ diff --git a/public/app/app.js.gz b/public/app/app.js.gz index 7217950510ab1a0954b6a82820c126257eda9bdb..38b4945628cb1b40c4d1f117c718afed854adc07 100644 GIT binary patch delta 61 zcmV-D0K)&@@CM)T1_mFC2nZdSfd;h(0mE(?8r2msob%PxvF_pkL=bbi(W?&zt^T0Z TbhqMe0d+|T*jT%$3%LaVM6erc delta 61 zcmV-D0K)&@@CM)T1_mFC2ngL*fd;h(0mE(?>eUr7ob%PxvF_pkL=bbi(W?&z&1SRJ Ta<}4c0d+|TZP-c#3%LaVaLOA} diff --git a/public/app/app.js.map.gz b/public/app/app.js.map.gz deleted file mode 100644 index 055c3f470bab8877c6978906a0b3e31f0e48ddc8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 320419 zcmV(vKAm`d2vh?s~^{O&c&^Ou4)3 zX%EPPE3`tlDa-CpO1pMGdxUOqb?{jmJQh4|I&pN_<}SI&PG@t^o7{j>hFypdKa z8|m_wtWx=s$xGWi%LDPpAX`2a|91-4F00GWlS<`zviw3^djZ#Ocb311cfX{|Bk_Nu z6t3mVtKxyxZ22ayRBm#4tyj}8Ek766p2M}<+VV@$-pfQk?z9IlrRIUIc%TaptmN(k zPsIaIljSSX>J_v)uIjEVcXz}~JM!A~Ytzt3JU7bqXugW)zNX8k;<;0JZunZRbzWKS zipM(3yOqlBviJqxx=vnA`md61Wq0s!TfZUxeJB6fm;Zc}ZLcTGwMwP2d{C(zELSU) zs{FI2ex>qLwMr_Ukw4W%@%?;xuTt5wx6gyy&{1>y*uUG5-!pd))m^v-ciWXp+ups_ zO`DPD%SV;Uk-dGdZ|_$s`|7r&82u#N!GD^SO4Gjv??Gd!SiDUA6z}e+Ie{+2Keo$i zp5PbElX+v9s#hA$dq5LO@~I$&Q=G$nIkJBGs#!^M^(xLEe%&q*St{|y zN`n1TzvMr!4%}6#3&Kw1XEJpWny6PQbKDD2*Tb-VC{9=)z7LAFH-q^XaQHaZm+>J+znj%i_H9dB{$%n?Ad1Kul8MP zhsZSdsx3BkLYl_~5O+Sgw4!IP>9%FJ4|!PJ9m5=r61$q$s>hN>#av0ISR=ED?b($j zyNtVwGZei`n@?{ux!)xDq&sBY@j)bN$q`%rZG45&INm}|AO_pFTQ=R1e`o&W;{wG# zBY0l3a<~SI(@mD|GSz_OPy=y)0F4h*F`k{8T6CZ=Np(BwXRC7b3pr-f*QVX??LRSJ z*#+=+_~(=SXBT*v_-FqY`RA$R_f^Jp%?&f}5ReFZQdbjQQa+wm|E?x_HM$-~XLrG-$ zXEj=!6e?GE-*&}Z_mHRZuN3=pUj}l?wJCe?L3Zs12typn@GQ2qeTpfzyAkT++C=}c!nrPUWk*~=$Z^;RgvOq&_$;ONm1ih$i>q*|VQjuu= zl)U=tMtpRIUig~GNt9h}z|Hd0DBnDn>Y#Wne=R$&XHonoX6rNIHHK_zW&%Y+Eud(l zxJk~O_N3gJ=IR}wH@P%=Yr;iG>o_C_nz{Cwe9)WkCJ6WN3Ugbo>M)THRR}@Ur7gJ-BGoOhJ|TUBG?)4^oHNdbCNH?->d&v#)=^_$ zP2>YtW|@2Z*u5ppopX;47RIBvw4EC{_z%I@VR1kB!?yaGY{46N4aWWE5r;i_oNF_V zlgM68kaKb%Xz~14kO_wg5pwWAuqVG9i_oU<4jNgSm1;jBG6F6j+69j6=EUb5esc*k zKCtqT*kP>bQaBDh5W^mVFM2oV5Q5Em4f4m=Wcd`h+Q@9ydt&C23vxoni(kTDCvPW595u0#rl7#AXSeig{|5%cS$l%CEd!u|O zo#`F#OqxnM_5?)pkz+M&MkL*i>6Kb)kc%SP=?FPhES8Y1_mr?Ke#xcKKWp-KQ~r{c zwzjhAjZ>=&9CG}F6>GVTBfS7spA+JPp2%<5iO|ovX3>%>Xzv7!NUvYZ850_`=rwSd zN?#Lr%}9xF%!yJvW~eog2zbMUmSOAiVlJ(R;^h}=$8M1i`l1g0!p$ltbt|FWUfwW# zbx1pZpeLUimKiIceC|5orirzso8wlSItnIPK6K2si!xbT^ii(H&NNf&lBqp4+OyGX z4Rm5pEEFC1qz#^l{D!x!_T-;%ZC~%$?U;nPTSN~vwaL@>^4EquiK?5)9Ex9+)me<` z{yL3sK93uDH@N3QRq;%B1cd>(JxYu%kaSrt`gTfm!Wjo08EQX`>kmkMO)wdITg2fm zKF5)-+|td0(hB-sv@axgc2ziCAIm6y-sca@aj(D9lIjvpV)2FqCta}~WBQ>_0N7A+ z2Xy3)I*~*yt!d(y+)?^xP2O(GU#DR4g99w%ykX>QRjQkH0uqM?Cp954we1ptuf=!a zghmYSeCVf2rnfV)Mf4xv@nv)(Z3AI!-1E-U@ZskP#RBv0C;7;posu({j8mMFwW+40 z?y0~v%ggd15$Rabi_=n5$2&|{*xQ*n0WJH>s1Z0sWw73f7>j9d*V*1`CgB}`;^G@} zjq9X5+uo6x!|rx7hPj1~J1VZVfebj8W6QP>9s-2+!3G%!d>u)g&MesdFzuR&Nl5I| zd#+*hX=;Vr3XqrA4aZvb5{|*kj0i-WSpk+onP#FgjuYK5PFTU8vUWeDVV!@)b-vP5 zq*~-EkPjaF4dRaVmelM!m}}5yo9^+kp131LTkB`v)XJSMp3|B*Ah@-S-Z({nuybR5l-t<72by-mm14~fK_`9?f* zzh!s%brKVY0|T9zLK`Y0`!Pt!`8&lFqG30(eKr%;h>P-1*!GIIJZ*JHDu`!^jTrgG zk28oWgUISoF>(0anf8IY8|9X7*AYd*tZvl7FUj&CXRMFjmhp%l#ZkP5!8PV#b#A^) ztjyTUF)Ri2&DTbI>UEPZ~Az8h1s(<7Lgr8pm zkFWUOX6_GDe@1Q!9A^43!z|LQ?P(i!Iu!8i249dH7;_Ncqa_`-zFuUOBk@ARB7v$f!}gb#z|S{1fzvqrmVfmeb6-- zYzAH+cu$H=>OGt=rL`HFhHbc+F5+z(LBmBe6!t$Q+>he{9*^dNb7;`1(MFAAdYeXg zQ$4VQ<(1~Wj8b^7KhTyQLU_3&?Y1)JOSIVdMG+!eOPD1i0b(`lBk{eaq0?!dT7kr#OpnsJE^J;p|_uh~TQr97Eu~ntRq!e9!AyQ44*>=$yV&p~6TNUeJ3>5of+x zV9(`7!QJ(G$h-^jRau!YapRu-o9p_Upz?Xzn&+YjcAJdU^@!4=3MWkaR!<~`_?Q1w zZafVyt+=eZ>?W07x*6?!3p!WRXKSj?S?FjsRGCK*<|}WM>$O9t zP0Iz1RP6}($Q%w?pNyA%!6hPu%GzZR)>$IWN*KR&LG8^RsBR{0hnd# z?Ap^!z>#Kl9~hivgu2X&4W21$gHt!Sv zlW69t%gseriE{vU#lPKvN4CNa+FoAgPV~#ZYbVyz^b&T*c4E9ODa4t7&0s@kklY7< zRcy1NE+{sAr)Mi@R$=_g%oPm=+ z9|trsxnKUwLXSKPis#OU{!7-Gmx)qyGhtSNN3B6H^#1wqu@9b28? z)v;Fdq>O=xaWoNqD#&HKzDV3@Qqugs4S`dPV=Y@OrAS?CpE-8D7Mvq!T_2SAUX;{p zAl<8noONgD0G|`!293Ie|Fqoa#owY#Ag4Q%sxFsGRL^8EkLQU0HF{4Y0B7C zV1iuF?0HtqUhMQE05FF!pUix9P-4* z=DZQ4wacTSEb4rm$JOw+MufgP7)qn@!O_~s(6MC;`h))a6wm1plqSu#4 z86S;V^S4@+iqfu%(E{m!3r=de6eiw$znoH)_c|#Kb*9#DH@TwtaPUa!Kyz>*J8fi+ z#fTNaU87R`Ih1k4@UG$SE0C|x1AV?s*scPfsToh`x=88tZ)mLF2#(E+MA3|&90or)JT6hv-7G=`f zl=!hP`>^kZXNBfQwJom_Ln0N0vvC2y7?-^A*it4!xutRc;5W@j-jS?uLmZ9ZoGq>o+*OEO#G$P;t)?aEey?)=XxF&D>&I|y-s;H@6q`w|kHOc55x7LooO z19a*qoB?M&a7}Dx{B-Z>T-$XC3YE(P@gSEmzUjVf2EG4BQan6Xc>;ob-r7A1P&6lM zd{sHMX0u7}#o>9fe37`s=k7!CP+jPWM@(vNTaMJZ_KO@4LH$vm=C18q)}@v8dfyUK z{$}|_qThM1(26iX)RSr;dl-?Vl=bpuqI>p%eVY&=zO$;b;i`}sw+E4ZdRA?26xx5d z_%Y5j)1)F=V0Nq_W&?C#!k~@jcbQE0j&G?mQ+An>b~X}AAA8#5*wNNq#!;fyngjSj z9ntqF$$mvu~Nm$0HS5O6OANH{-(ZY5&?~3J+Jf&p2POU*m1f&oY^z2zjsE3%Y5JWZgLUcv(MXiPz`aW@eZ-rvetY%b`fLWhWa0pk6m z?c3SkR748DKll@EX&7eh8Vz0YyKQxpNEPMCCZe<_eDX8})f!J^XkA`CCgu=0nO-E; z%PYV4y5<HWC||!mYYD01vvx>m`z#{KPQV%WHNAccjwYWrDoZ_-4{}x?Lu9=_)byEPj4G z!MtuyBuO!SO+AuOKH?BwM<&Sx2z&-h=+o3`QfFs@%kiyzHP6`NSKj$W{Y{_?_gvqq zbK(FFXN`#=fSAyI?DtBlXZ|fal`36d{8tAom70|CWi*-;$xT@1f)udrHwtC-ovVdi zB+A?^#bJ4&I+Q=_nK4=`bMquC&w$Vb0G`%5rm%L{cpg8rkI)WBHckqkF^w44XN9nawpA;R z?5~>rRkaec!xqvK_Iq&lXJtZrsh_cND@<{z1ai}{9cbAhA?&MmSJP+ii zFH$*3cm;QVSGcmrJFnmDcbR75#V;uF^ntGA!jLS&(jvO94+ecQ}fL{{Kx$ZOgiEt3Y7)oMHyU{TbPZ|6Zr>OlHU|(p*lmS^1I%L`r zazxnNP9~49!HrKka`p-q%?t?E<363aw;jvx1g))vw5B;z`c7?&0q)l6rMoCy>!i9qa>8W$!K8*gH>FRfZ81A!Xui6Jj?NU=M^?8S1R=m?K?}i3`u2 zuosKpD7+@s#Ld*k-zr`VQp6X?|L$oUos^C~S>a+&jcygzjVe1%%=?y=+k}==6h$IO zb+jcZ?2uow3CpMr1Fan&eSsr8o!cJG5Ng_JZ!b<&$Jm+pv+GnHNnUtI^ep6DB}mve zDGdwir@lPTg&h^A7b@dIG(6nI)_zdeo`bc_5iicYw+)IP+LrH9#>HsEJTw2}Qa$VV z(up6hPeGN?%;qf5Ifci@=54@CLXiAWn4^bLf#TY7%HY?L{Z+HS zteAs=t~7lH(dtHMi+`E=z<>E>>W0J+<+Y3CVptE*PMCqEFm$V z3Qr~4V;dROPyBFEPb%Rk-wp4S-`-5gw-HhJCUaNNe03#Z6A(D!l&!B(^1!8OFln9p zn(1%qW7>o0FH1*Ue0Bg5SviNlyWlwKhc3POfE`^-@ zI$?7!>P1>qkc{Oe-r&;#4okk4On@!pF;LBdYd=T69YnG?I>^aXTDy4uCN*&Isf2^C zo6s<49?SqdCxNH`Iv$0!#G61RVR1Bs>0t*Rs52LafnPcBpj8a%9LB?JQq9u0dE1ej za*;%WGu1O~8ZFDQMsH#`iT^H*MN!unDZ`1Z9_Bvyl4CJyAc8_PM-ZMFCQ;*qXS+X3 z*yOoru#q`S`6i4re`e{;G~Fb zriE09Zf+Gru$dJT_6+}+ZFL^)i5I?h;Vc7M;Jh?MkA>iKPVDVA$(oXf)Hyx&S)z51 zl_b7Fi~h+A(;9BmQep2YsjhG!OHct$lww6X_@Sv4ZEY5>4FcxKs=1m(+-tBBs-gM>%;Mmey z@^thph=vz#6`WqkPFUcckRxpsYz1?~oTn^`uG7viS%i^YW_JYHH4R%LidadJ2OCO8 zW8bcqyG(M=_;hebsaXqB&st8h4kP$pCT@bnq5q1fi;@I4VCZ!zv7i>@F@&gx+Y^hO zF5RYndKQPwz%6Foga8HxM(1Q}P~jum#p3)zPWWb6cC-jiz&ubBGCg#HWTyXAi5|wh zCVUU)n!{*jW(9p92#?|Py`i8Pzd$63q_v?5C(7Zs#+1$tbnaK+snS}S8c6N5pG9{M z2V$U8^NJ-HlG|U5?O;q8x5@PTgAziA@uBWnmcQq25-u9pQBYl=ts({)x>Q&x*GsJQ z92+Lbu*Jk6hP8+sJ$6seax^m#$J%zwx0qi9EmMB4ADkRc=>49C--rhOPy4;lnd2zt znnnp=#t2OA>DmksO;*T@lo$wOCJk_k7iLkq$i#%KpFtAfk(Mpk6!oD^RSK(6-Er&s zX_^8 zpgLywjDhZO9o@+6AYUwK2Uk+7Ir(h>X^8C@RcI|}r{RXcRv>&Bo{`R|iv)wnYpPtv zE2x~a?^;mMRY!%Z{5O!suOsCQg?^-lcqsWzI*edco7XFAlp%3Az&O#!^9X}9kLCV@-fV z`iZNq>ttQYx$;o%qU)d1$ zIyG9c7b?s61ze*}J&;Fs?ZVe|wI*wg;r7CwmP&NVpDSDZ!nz8z^mvgnWduC;folT` zKt>(+6z!x6Q|2t>OdM)_4()rY{^)H`4`3?2V>ec9x|>aDmf|Btth8Q`Tj3sL76{1@Q6Jl;OBuD5%3*1U0koc(Kju5S!3CVU_HY$Po!MEb*iY zlVL3YBq!FvXZiwIGd-0r(4|%9sC7B-6(EIi>+2LwKj(qUY)F4HUE4@I%Cy9_ZFo>` z&bB=XtN3Nc@u(FWBuH)*RRoX$lYTwtGqF?*-}VpxkY=LX#38SB*T9tfff;hZzxeUy z9Il1KG{(sSUg7-X&MU)3e8tPa@?J49WnA2w(4Vxsj;j=h_L7EU^28GnVOF;JJK(A? zWtFZHCTtOZaS6RGCQCNgLxY6a140!R&-5&xP_U_Z({Nx(3Qv#Q*Y4BW`^ve(l}^vW zF?q;d#qK}v8i!aA0hYPWUE@J4hhKpwbD;?rUd}jjmM}@4LP7Z<&K3_!aSrZN{;A|c zuEac}@dWs2z(w#zI?Ren9IIEl6J>y@NmRka_PhzhJTfj7+TxKeDYt95;E7!rebm69xm?It z%?9uGu-t9WM{I8Q6W>4Y-0mf8l%%s-;36g31efW>Y>_3Z+KP2s1983QdteKUJ{Ax?I^Ti|j6t(P-P66xyD-wQ zOnIu~WTX<%(&A5UL|qFqc&U`CE`r?3M>Z)uuD20gk1ZMNJao>aqrwlg9lc#bb4 zjx4Ol2J7QKVL$4~K=1tC7=izzo8Iu2G{s>vPeDuLWB><>fy~B^Utm>=ml>(4cPhnd zs;ufvvH{SaAf!_hV34ZF1BGK)1#eoaUD;0RV=p1%f|V|G@H^hIh1-?A9CCKjiXU8q zf*+n_rwN00jAD#RCBi%8LzKHR(MVWTfJ&jFAIC+wse73Vv~^xQe^4VuD!2_LuvAYT zY$BoW?}-A6@C5u6sB3_6Vtt69nXY;>2L3#LT=-ZY^cHJLweonCZ`q($nz z{ivq*dO%oa>(QK(g8qBbXdPgtYt}G%pb>ql{!XH;S%YtG51Rv`LHi)`P%yo0J zj>c~4+imD}ARVR=-d&?i#ADOm4VR1Qpo82G&n#fWN10#C=)Rb8p9AHtlOQCE^EmCs zwxJs7XMd++L{igY&5$sdrm3Q4UkUP-OELgBy$G~oQ23;HE6SBO5Rf{N5?(b@!PwGu zdP0^SGcwW-(u>ThZai+zN}jazw9y=o4#idVG#JG zX%|(0);loy?M(&bd|h)Ax?QkG^r}ouW%m@!E zxx)xszzB8f-bA+ROBeWsLQWvl4a(1q6GyU@g*>D>O>0i(-DV(+%HYHsg-{UPAqTcN z&aS5E6GgG*d*OIgx1+&`ng?R1RtkjC1D78H&Wwy1Gx$&kG)^9~E3guD^cw1C7&Qf* z71Z;Ql}y=%2ViR4EE^s)!#gt0cY{Aq3Bg zhTe8+;UIOf(+|pN*;GzzQvT}3Lvkp#0f9fX@;*`)1d(oRfL~)oT zLp32?*Gb#_j0FrP@VDy>Cr?%4MT>FSulI8#E9Lj3Bha3J8cXKRVjIs3K1j*ldGtDE z=>ih34)7>0(}f%}Gx-na);8vU&O}px@a^9vCha_5TpI%=&RKSl6kfI*QC;5Fmxyend5em?5iV7 zkZAZI*}^LPp#ZMne5@M4Gf$BTzUj!Gy^K|4q76B+&vp_wiWzLmy}% zb0292t=v{=$;fRk1j6$zkX&Zx@15{KFV}(FjIib@I?xX~;2kpFuu$^wK8H8ln9zWd z4C}oFN_v`TJ`3X}Jk?5Co-FCI4Vs39cFN#%AQgh5H0C9~n^(@Fl*M8|5l6M>ly*Ae zScbiG$Mf#+49uJ91K8~b+3KzQyF!M_6*mlw17?9-8@H{$cbbsZq6_37sDy*Mr|D(t z-1CmoAw5bdw=>os`mRZv9n(k@&sq(VOA`aL@s4)A+H6=4A=P<%93=B_c&b!-PPbhH zYAXvN>`ea+?RsNtxHPE65V@*)fAY`AO2FBOt8u2BT)1RLtv08cN$>vTlZ!bTJ{K)Z z%N#v@%DA~eCmTH&IALPDfo4{5=Yiur8m1FI-8AUa`##I$J`E*d$Yl5hz;HGwzLr^J z!^GSQtSWNHSPp2Mjl(HSrDZNHj;dmTN7fJbs{>&c)wa_^Akv{40)}MrWAO5@u%|lj z)+^L4XQX`TH!jheiI;=z8~}qb8O{{Z9dk2@Fv}*CucA4=5tyWglct_4q8Cj6LFN_= zJ}aLDS6ogx_qJhsOl7d34d${a$C*k*4*SOQ&CjP<9*ak;34Yhbg(oVeqB%F zo*o7$cLAY<9otShzj{DjuH$*`j(M7K*sZgS)gigcf>D+7HZPiw$cN9fQuZUi6Oj+6 zxop=?9}W9Vk8 z;8D}8NC0;n0ODW~Ta8K$_|Y$_L3l zU3ztV*NLO(fnP{5$U0#A}gu@r{@DgNLuh( zfD+=B3`DZ5Ywop{M!#z15vRAF0nhj~ok^&fNwB7wH<8FWLBfONxy(4(-IPf(&0N(U z5NxF`m*sO)errH{zT#r7m)bgL5{|@%&zacK>Uq5A4nfn{3!%t0W_H~zM`GoBdHXsc zw_Q!d4=Ion@y7hBt0G*GA@(s|^~~bow%ux8TPbPiMdDVID$|h3!Q5VaL;1v^VPdS8 zQnBaQN@BBvIA*Q7 zy7jPB?Kb&PQ|`X!DHR#GhIhj(FP#GtZ@8|-m1DMe7^(*c9>N+NT8?56R0i?a{Qwcn zIkS{C5K`r?rIowaW(bW8TsO2HT>}DHn^>{-F$dx4{pAM1tOG#6YP7GU(nwWtk04)B z@C3A>95B6b5^XFpmIAS8TSj)k!@D2ukMo>26J2_ z+WR9E68e%T3?oypNM=BJ2X@UMqHYE$lp84nDOLiBim7Xb05c6%E{H%zY$v{n!m+EI zuy?VA15+!mA@|ICvNch(H$dZu%co*%o@Oq>$ga~p>B{7c2X&_G2v-;DNKc1XbUMt9 zbCBkbthoi^J>`}j*z(i&lz*GAs~EanllG0KuP{ma#J7LzIm$iA%BG)&aYO@hG;T~D zGsiYuJC9SpBdlHp#f<%ARarZvVXZnkrj=$;NVJlgH1PbQ*2pqQU-ILoIi*U_1w?$x zqT*jIUhpvUF;|hr z%O+q(rN;GU5$ew~pJjSR_vkf`pP>nXT_COxb#>-eJ_CvF)6CsHchJV+RK=i}8o3yf zi2|=G28wM{yf>ovtXUln3nzA>+0BB~|O!q+Fg~NRMMvf_Qmz^Dz9NemLoF3U^tXoi(PvWK(-L*QYcY5NXX;y-IZS#UzJbv5GGuCiFQ zKkkl?3he|cY*T@Sg^w$~?Sn{bXOzPFeVQ?{kOdnW^3cCghT=?q)!-h6fD%4fa0}uI zLiFD-t{?z<3MpgV18Y9;mkO^DZ@+h9GT9Bj_9ZzD4T3N*yI~O-YO)XeYtF~3%oQzN zlG)=t+q~?^AcZm!q$>#n5o|LXYMC3>X!tv#e9%zd3RbkGt_ml><0$}j-7>K)=G@*& z<8g=fbPgt$x}Z!;XEcJ53*4xH`>kM^T5wP~V%1t6@z{D8;vo)qXwi46z#e`wEsi35 zOy)L)oMVlxiREhgjUY48AD$!f_6ux829mu1;RJC&<@On;uawnF@uHVtqPlynna?K2 zd>RvqrZ`$~k1vKqxQ_{`xlJZ>pT+(s^C?bqQ-e!%Rnp08`Ew&tD6O*2)1?<(Y%#QR z16N0L2R+V(d;ou8R)~1{IuFi1NrWotdKlPh2sTHFtjY;egoE~6^dN{@bYU8wID6|vIewoD8596gfV<)auz3|M9)tNARmM3O~qHdEa z@Y8pS6k;taX1e~&D&xd{t_l!I<7w)5xo(e`rc8L0+TqQUHW;aq8(7laVQA44YbP~q43HDK+)I5}l@`-5;~m53u%HZa1PlH;AL1b{FPzuWLdF?aG*lN3wBQBO^}1&Q zw9ZtOEBi-Hr(w(A&(#~WL^<+93yXYgBzlMf=y2IkFML7i^_QI}r6`XG8DH(d3W7FxagRH@v_Skvap9x=+j zJd@u%Q?VyqTHfioU~PBGJ$OjEekx|`Mxm0vBa_&DU#UFZ1q7D&q%&P<$ID>+)bI86 zb)|Cg8Z1t)F%@um^iizDM~KGTBhzvrX1^=juJzs%%f!t{EdFQ&N#AEFB}!a8p><}?rHpJJR;uy&%x5dxf!fpODVrh}LNzyQ0ab zu=txbvO!P9zb|1D@989V55@S~Ft>+f{3Fr!KsEB3OyWgT@2zyDNs*oe@xO$i-0Syb zMADty1yZ@rNFxKu*dZqR>@8(lW;oT$*JS*s;xjMb0WDMRbSJ&4O}PAl%B{S2L<9Oz11 z{tB1-bg5nnTG@akh|5o8W3Eck??w%^w@xW}RqVDK08Kq>(sR!?zxkOg^cO)+r$A2Y zZ^>oLQ)L1zepRYa7nx3t!OK@-Z+-=Ku=1Kr*p)PX!^~_~$>ot0&juiX>B3biW*;G%Wr<5pR|`RTjcUUEYKI&s^X_sf zYqohIZ@phjZF9C(gJ>zZw*SVqUe#90x*J|=EER{=1VfYHts}7!Bo2Ayjjffe#(3h- zt#SJUAK!a{Q5{@NyfI%uPSz2FUpThOFs)rUa=^%aqB416p~cpx+n~@9Ue63Qx9imO?NXhbn8-;3RD|pLu{VVgag!Ys4Z{qJgz70V0v> z9Pkcp`L)fkJ80BhV0X??HE&vgA#Zy-jsj=-kTz>bo3MP(Z5|a}zM_@8=2s5(1a69H zSB}EOM5oHGO*;SDO!dLDEH?Yju0NTuEH(6nK-9ey@}0~TrW!&16fAY-0K?;s7!aAN z8~ow-F~aYshV z1>xc^>aDJhGk=sRQ_+|E#aqnA$vVZEbgG1pwe;Jzhn-Zy@Z595jI6Gvji%V12~X)K zj>SK(V-zt>8V0jJK0aNn%7+_>mF%UH;tOo`J2zzHvk!=35E!n5l;(+$SYA!cj_XK~ ze(ffKx2ao6rK%>R_DhhG5Q5ie*tNSv1M4?c#Btz+^1<-0QHd&CMik z@#ox;riOjK$@>>T_hHKGO{Vkn)OSa7CHQDLC`t!3|6$l=lYC6 zV!P%3c7v1AiR!&lQN1at385G^P~U`fEOuB>NNfqCX!|1Cbl9=L>;{qKgOI@3v8PopFLd1lt*ON-)O!?Di&e}G!@IY#38B4a*}b%% zVG>UcG@v*uNj##-%fM<&s1Eog3FWOFbMD5sU-DV0(NxrEvV?bxyTw8?Kbo&*t(s-@~3)HpG^(XSTasu?EV6uwW@vDqk>S#RgMG9QCRU)qjN-`!~avu>UQM*H{(!Cc*V2icqYl#oB!U^qqhgQ$R3>%7b zVtAq63Hdc{rk1iP8mc?cf$?SsOXFq!*-ygf=%ZPwuO)1Wyr#|A$9PbuFw9v-Fkf*K zG#op|IPuAcI|ktK0eKvufv`ClkaDTDSE-{mNp9{}h{b{?GJi85tLOrDqzXnkkT@|+ zX7#M7tuWZs1#JlU01ig>^gdzjXdIctJF@$0w)?e=MI`buW;lk8rWeu7SyDPA_f&P- zHADb*!}~H*>3I;MQ#nvLqtSBn^}^D|IGbMib*=`voYIw4O{tBktG+E5BJKlsG5bM` zF|t1{uMDTa8@(j+amLOL9lZ`34kyqF+T!48JrL<&S|mWU+)pqgfb9zOmS;Y$2;#E2 z_1k@!!P5pSXxAnD*Ue4?gGAzparwLDFFTdWmmPUV^+9r~kO6rq5zR`&$-naUnEMNu zYvOB!g`jz8%Shwv&YbT4FIv}6Zm*S6Ov&2;g*)jo0MqrjqIf7jVeJwge26!ANvNA? z)DR-?=VwX05k}c&2eFZ02_}vmaD43!&XQLzU`ubr!ersGPa(0>=vt2+&_X^)FbLd( z4D$3Fcgp(wdSIvIy!8@xE$n=pCGmORSkSzmrrx}J?1G#37jQzn>cSpAO=I)^0_Ob= zW;~dE2I|Kr*_xD6%h+H9g*G#vADY~I89uNFA(P4^Aj@7>P5^gp&&k87T&5N?^6dal zZD43SBt^Gb`JimS22RqTMXn^)_1jI1EY}#PlQATBV;GVv4}&3DRls>Z(4xv(LFv_8 zJ7%3xXdK}RtmF1+>5{4r`RDnzk&+D*ZHC_SHC_C=IT`e=BnpPD8^hR=ygo&Ke1Myjc zFXiv#KZq{*W#?Y^)eNUb(xT-roeg1fikfAk`m=o$IF|=I2B_B{mK98%q z#X$v2tUBVnmrUoFRvix0&;ZA02|49jlCNNHVFR(jn>evr4}))#v?mOD0I8 zE16hytff^9&T@$oWVMPV2`Q6ZD;YG4D?}cQnI{7y*OH>>bq1l$9TGvd&uGEopF8il-KYR z^qRCJZ0KJwOk$X@9d$^lWrR>0EQ7n+n;q8cZ}xYKC@Zl6+Kz4JY{yXi4#Bl*8X}+D z-)@aRe$d!4YjV|){alMJr})a5zqr8kXZTLTv$R6-u7ssC*Mp9RlUc^)RH`^E)9M5g zDZylGh!{6{mGwL@`28ievTaqtclR?gCv1d5f$86IEY%Pp$?FA%IC*xdT?qsM@MRgX z>@X+3HeQunQLpjKz^v;e)1UY~4L`lce;V~fOr&k1pVHv&pC@J4M#@v`gs%Ymf;sJRul0&m}8;vkg6h^GN3>imNY^>%`V~agrOnxF{|@I%X>+IgOq`)D-gldd_hm z=~6kS_*U2&&TThwA=(c@X+r+<3qd=_UJ$r%A6^WYUS@ytu0*ug`r7=9#H@&)NMUoX zg1~+hR2<1<7l4g`q%RX&o+qpb5kT|gLahLaaAF>h!uw<)XCUI(Xkh5hq1s| zD6UCoL+vkX3f)fFA|p7Pp}DlN3mFkG6~}hsc4g1rrI35rj-QnV+3Pm(BiOlkr31HY zgU&pvv*32lTh~7CAPGly8h0YoQbY9SfKFKRaEwHZf}9xBxR>!U@H0LJ50tATog5@t z$8~h5LCQTl0*1EjjIs=k83d~tMp!<@1jdlY#~^-n{ag_|I(4qNb9frw*3#eISxyO9 za(*8~{pSdvU9%DLc;0g8q(<@RWnA%Jr^YYIcA)i~jc=P~yK}JxUT5q!*02?rrr>c# z*S<+j7#v={dB#ziQ8kZs0>Sv$ook=$dN;@1d;m60@r6{f08Bu$zho{g=w?chuOAcBP!w&~ z#x&3rAvP`xE4+k((G!U2I)T(}4M@MO_ebF(JXiO`Wa=z>4o#QZRn89(*5WK_0#IH$Yp`u*GPk^NjO^L&+)r zeOT$#6sW(c813Go1O$Q5iu2}K270Dt`+SJunrrj5(1Hfa4d)Rj;@yYkR<{ z;K?$6Tl^lf@Cq7=#a%BmVV9_#bnknah#bjH!FyKH82EB6Ky>sL*2|k>!at$7Q_3YF zyt2yaDjb7rpi(Qy`ZbkhWB;gW%clIjq22)DEwhO2yKzfu#YhAkdxfVV^T}2*;2`Vo zq7|aJ@X^@h!)j-%O#U=^ZI=22z{u7d2Pi6bc(KQ1x!!a*3Xys)ussJaJDU}2( zp2m~wOxtD~N8663n?wyFP9HWizxoEsQlPr4;vy499?veqo_PVthL_&bq!-WD2`URQ zPddA_q3cSP?to``_F`SR*)x4S&m$6dIU?ZsnUmFYibsY@@G=$snk8%Z75`&Otz5?@ zJ5^|^aQi0JNV}lXt4dH-^BsY^YAYq+KAs7!8N1;fW}fB0hPF!4y$p`H^r?aYO8v|} zT*^I052@*i_e>?A($s0qH4jR-Y^#pg@oqV#NvwaMzUF@EMTZg(w7F#^n~M-ZZg45j z75*!!NB^g$OlS17F`hb|z-sqI7RS)%dUm^jo|P@(80m7zkI+okLX~6R)I43G$=LV_ zFzQ4z6**bO#;~}#;q|bHATTl=cu9Yol7iCMu$qz-_TuBJ@GfKV+vc$n@ImA0H6gd| zfy%VF62J(T$o8B{mvRk>I=GR`YU7YLxNBi`$p%;FZ{ISjeNrTh)IEupgqpk6(b2CHpp$5|Xn+0-AK^2|dEQ9nxbYzKTi{`KaJf0u@2Ig=RnyTb zOB30mDeZ~LUS3I4>8ohMyE$098`2aZf2%M?0Mb45S*#a%!(iKh?HtQ+@jMpe8$2U| z39=gdqN5zj=fZN+r^a7ic3Y6Ra8Ic#6zFw?8W*};_H>D6)>JSA5}8Dpo3}z`+|r7o z0fAZz(%X&Q8i4A*0kE*>mr42Sp8&+_-c;ZRM|lha%03 zvE`{FQM*S=Kd(xXsA^2yF4W#DH>*tU?UmF^V~A!9`=~E<8L&eb0$0naV8utY_Xv;}somsQ<#(9}@7)SFyPl~wQPzZv!?1=Z4j z!)!kGwup|J^C72Exf)O`jnAVaAC42&j~^@fIK73IgI4nxd?&3n9!)->*=aC*p%hP>8OKcox+o$MYiB%&E#1CcQ+Wd5xHoj4j9T0H-S z;wB$%;Bpcg^Hg>LiU}dok(Gjji1SBit8luWO~5!Sc0EVnM^{qTvUWqN*>tSAu0s(D z5tMo}W52^0%shHwC|DaGk;g@;FiM$Izu{KxZFtL4Gl=$7^t{hlD&fXVuuMu=yd5cf zovmNZv~Ae6g3sq@aL<(^i~Z(d6zCg-pyg#cY`TTVY2br3roT_tu$7tP-zfu*uGXf> zoG#6JiWQ?08WWBAchbh(YQ68+5M)Q&A#zuj$Xz_M_lAbfg(Lf`8ge=6nLszLhuG+` zQZ!5#Cy_@tl2Mhm@>#e$w}z2ePqaADUAX|~RN^x6DObizFWYRUBXDgoMQntu>PkqYgin zk$cV~vyg&boMr?9o|Ce|_Q$U2ec~TeUV|-}%#K-$(T7o5@DSk~)Sk1Hl>XodAhh3| z!l4Xq;+2%GfQ^F;YQF@hMi!4L=c`M|%=3NC6oD}XOMBo!uhSGqPcu4&dfAc3xPzT0 z=kCA}l&=CS-bz_sto?&21UXb)?|N~_KZnCRX>Qc9g++*X;lxFswWA}QCvkBavE2^bAfdXnFcM1kAR_`}8X46Y)y6$Lgq@uvRyUt=G!4UDK(Y#g=kM97=ubU_?A?y1)ZfPsvvNqhZcK zW-DlvfiO#u;6#Ap-ynt*iRMm4g^QH&#UTp*k^NP5fmywAqotwA6bFkW;CUbn*Li_C zw@UoaRk?Vo%yBdp2!nhy63jHB0+*b{A&|SE48SJ0R4r7rj(qYm6y*c~d~bf9ObA=^ z@X7`Xqa=E4+;H(z8m_!h$%3@$&jjB#ly{7k;Fki6b`y<#gR@{Y%*m$3#+E)sdj;W# zm?=^#{xe2l2I%SPMC`LIE4Eb7!lwMmIXyN%>btAfb;zLRXRWVC;(X2aWdnwc2zUG%cC8=jzexgHdqbPaYvsg?6#@JN(SNKsFt#@tdN}Y&1{+} zH~BF&Gv8`o-sloey*xtHCHSr-`R$1$Zwhs!lPPMPlo?(gmJ>`>ITBOOBWh8%$X9_y zJ>pdzC-EG>J-twMIl8xS#MLb}0~lQz>KLNe&><_z66x7VbeMQ!3D_!V1MZc_E?2offG*HEe+T*lT)iJ+fuMWTin?Ek+vKuTj>N^3_!=Y%uIfI<%32mu2pIuVzew{ zp|g^ax+PRa&ZOborD%NC+nhP-u~ZC;7~||~nFhz(Cd}amMuJ~vwpz~{mWGvATN{UU zEM5z=u|1O(cCKVk`$tU&?8)C7>J6|+WCe@Da=+M4by;iar`f7;-XrbJ>vD)}KJuSN^^68sixQc<*j3UsHEij@oKOwpbFqXrK( z;deJRWSgHQWlRqwN*V(da2=;=8NPK;SzV6cr z;r8_aA41hyl|#&dw5BUi-Az@2>Kaz1C`nqpIzl5~3dTy#B*1xinOOO0&$&;VGG3&G&`x%i))SxWVC>1uB*uzxgUKjjIkK~?G~aEoiEkKC_X;siCxw)fB@DTS zV@h$Ocswt=)rNBpp1=pQwQ(twn!P9TV9Ow*q`k-T{4wc|PmP#&3?3$#K zPw|S1?1{p_g!|zUu}z}$d5ce;R*?c;(@?a(#2qSRxx=Mw&=mL5W-ha<(m;VM_H-&g zUo_@a{Hd@-FFZ);erW%#61B&vQ>z{LPMvvgiK>OB25;^BZ%%~&hlL{?4(xj}tvIbS zhXPY8LGFkx?oiM$launnyhEX8sz8)8jdBd0F^z5qr!{vRFnpbQ=RI+tX$y{!rEC^1 zWi+ZUdRj7PJSpW5D+o9ncZh*lO#lN(NP@sj_Dy-JR$hbjTV*JKv>T*h84%rVuTVyt4VhMzQZbT^6Fj*r zJSJjR7Z~wEiFYNZhHK9gw`|L#*_3BGCe|K>!A&|w9FW-b;k7R#e7&gLjg*J!9VcZn zTXim*u9zd47gYH@QjFtkVt>};?WX)CYt05XwT^I#*m_o4)k@;k3}T6v44Ix6IQjP}{u?bqtdj=kP?G94Ysx!;na{=D zd`{SOI8Y}<{W_nZE;T&1i2(w=GHOooRJ-}ACUCzvJehD3kKDNg)ICO8^`Jz(Ow>^N zU)M#m@YA{fX|8O8D#+;#z1TTl@*fIA7E9OII=q7C!2kJ?0${r((lm4O5RJ|D><4!w z6FN{S+j=|a>m=EO0zSxCh*n&YDunJRLir&@!J=@+6a?;R$|N>Ee^W60zS<^(2 z$-uRP0o;Be7Qfn5gGN@~21y=*9eq;PNG@9zhh3NFZmj^cEob!^caUyrk}8*A-msKn zfMRzw)~_y7;+G-zob!{=AeAW`9(bNIg&3mMcQ|ROL}CuN1H5onC*i%9vl;K)o}+j< zp3voei<7aPH1O*{BXW~l$f8hv1;5(OCc|;~bp?y9SI8^ejKi!vbP|V|;qdeOJahHHOoOWn8wy-pOey4%_SJQ>INJQwB)ll zHj;u@oKT#e0*8{x@l`|Rp!9R~d+`_L3}2F!)MqxvCSf2t(2n4pOw|ZtDu~xv#D3+& zi>aLB&FpcESH#rmM2*^Hr=SSbVtRy?R#{jQ>hw3$AEFO&Hkg`Lu-nm1?BbMF{o*Si zjwLp}_@mWAK9v3ixXYH~ zeQ{9ho*2PABEPqukwlF`JcYSn^rD6ob(C=t;(Bg$ezUvH4ftVURnox3!edyle5Bk5 z9KhA<$N#{CO;J5`u5e(Q(!>f_q?N5?d6erva^sz6!ziM67z^V#Ed#ga89KZXIyUy( zpinWFoX%9HKru}2l+7d_GF%)##%+P7XEpMG@F4WVfl~hH`#h$ei*h&~6HTC(`Qor| zgcMv`l{(t4Dqq*J@a;-6rRA5us88M`a6IlCE6*#)5HM*khX3tB0=#-|QB`%tf2pJ< zYo6~|$KeWm{skPU3din?nIO@Rd^549pf0|t@1)0I4^&wW3a?*-7sv~Tuw`m?+o$?1 z8F>p&-6c|xs=1@9N&wm;sm96=?D&ly6O|UkH`$1qzT9o)lWb*=w!#p%YV^cCeblFi zysUKNh0Z%m(qw5%bg{OUsYb}>SjQ^pWV#B(?;P2)Rn zqHEjl*q)A}Rze=Rfj^(a;(w6; zY$wG9xTLZ*E`W>k>bH0ifl6MJ!-T~(HFD7* z>v6e~VO=D}5FKba*73>N&^`Abn(qbk!q}PB^tNTxD*QUKzg!dz%$KYYjT9U70s*{0 zMsI{1M34yES>yv7KA*Ol2jIAGT zddBPUT*u_;g)10ei3!d@s#RW9X&&rloQDOeRgUI73vx#5Hq)*SE!80E<9Vw8unv5W z>C~j$Tvny?@)sPHZaZORK-|xqt=MGa%ry$np}oRgjN@meiE zjg=qJU!mbwDvTkqUu>bPIXdfJ%s~uODYg>BQpE;~sXU4a+BEPnK^?sVQ%ZP7HD2~( zjn||1V(+!UUFg$E6jv0h>e%Fdl`li9!Fb94SjzK@LQUA4Kr3Ek8-h)xe(qUuz=M~u z8bg?hraU_!Cz|^64}tk85`}mh93I@3z@Ybwj3G-WvF|KFNXV3?t)Qe%%9)^~&Slm# z^<9$GKni`31JUyxg%u`@UD+#HZ%3z>-*q`+Cn(B~YZTF&+~FK=qI!l{r1}@|4sEiL zY`!Zq%wK}%_MnAyQc+JfzQjwNcBE_sn7q&YfFlniNV)INXap4ZIiA`)LMukm4w6v= z^CO&lf!D4CxJ=pF5awFjotg$SHKrPNdL0Bgdyip=!f;Zyqm^|jeE76V>skU4DAlTt z^K*Q~u-l)4II*H~oLe09ief{mE(~sljy(;WptZ|b7KaRB*PJ)~Ab)MBWEN8#n#1<1 zQIx+r`L5;OTZx7Wl#r$K;9tggv+sp!NfXo*_@B~(G9bQZyQfudM=yxg#d+oAcs8=w z%eFSMp9yq*Q6id*JH6eVK?7nLLc2~bVAxxUTfWiuLNTX=7PxQeAWu_>gVY#i0jX%z z?3c_&Iz@BB+!{$#eh<2zdI{IN8oq&4?x_LEs>-O2FmalwIPSWN1eXi6&p6koDx1X@ zGqxaWT0w8P*u~~lGL>ua~j#GX8Jv{Vj4Oy^ZexF0GbBGUlSIqQS0yEGEmNKU_id-Bg|g-?x%og*bpAc+E=fjpQbKS9tx&yF|J=?3 zSPL(0sMUO@JHf#Sw>ZLb4V>z*3LOgtY_l zk=@%oQX0NV)zzAREq9S8f@Tk&e_ zxel~0o)P=qjC}WNsts+&>bqz_^)v!=n4Q@$wOY3PG|?0Wfp#rj;HZfl06y%Qb1>lO zz$DwQ(|`bK%#{Qw51rv;NCkWt6-IYLEwKC7Vv|5!1c%6;53F&x_js(}2)&was2w;AQ1bY^Zsy>P zKj;ZUo<(@7h`1NNu&M}RqXkbcpv8R`dhHrW}BUERPpd4zllZy! z4%{*dO)PsH$!Yk-&#JfrI$DJ)BrImazH2b3OUK6KqO~oG{S&xkjG26EQmWET7DjT$ z$0u>>v*^OIfFljB_~>0ity#IXwPFfFHN&#?r-0;enNhctWVB{2wXfJKmWKEVV*TClGj%Lk~EUP^S=R*3TuhKm-JI@5JB}HNA!=X zT_Yz9sMBDIx*{0OfjwsrXsPdl&1YaXJu~`2Oe8RyXgk1|@FFujpN^ttuObXjuFV*^ zT2^)F3sR-2*Run;=!<7H_!KzQ#2pg`io;kUMXoX~m4p&JJ8LNq)thDHFRzN55_^v}x zPAQ!tzRL)iq)hrM$cYgWFejtJ+40bxfbxjoK2N<9FW*(0q#W`sjxK$aeQGB2q z3cO89O`i^CpQcIyhs-(0gevo@W<5Cgvh(WUfwW{W)if~-lS#1V@s?hvWm5QzIWgti4)+muw6w@SOUD7|pba=Ts(`Td`#bPs^R7GzpGR3*{ ztl<;MbexsMA>Fs(o}lbVWa)uM>lT+~P@={r&f?NC@I0e(Q>dBvrhQIOBtsi`5>|Ezb46+)9!s{u7LeK4QI}{|ok=&4`#tTnXwykuq ziq&cwE5JE*V|(W_8vVmq&$Em*&tVVCnc{jWiy*}<1jF2kX~}4B*O`|LU}x!bF_1qv z5;WM#Qz%xIucUsu++J}Ja(Gbr+$^MJ>br&~v_Zm1bQ}43S{hJ=WBy*r8e4#g`eR9+ zY@86;A|71qzqjc;u+rS*daU||J#q|D-;E2d`0;(0yutz^1g;*lB{hX$t9S~rWA{!a zS5XfN?Rf0e<{IjuH=q zgnN4f#StF$JN=VzP|z0W%XVhL$r9?PQG zemX_w1<=rz`&&%M7f@SznJTc7+4x5>m0enLMTLhZ)7K0l(RN-2uU7}zbm*R1p}8$(hP@Vi#S5omZiLNL#}ok>UjZ52!8=(`%P^y8$OR{f zMDts;hLCQ}*I*7-oEBA&b23Xbc3YQ&#TrG2{uU;AQcaD2Bt=(kgvgJBN=cps_=3?! zHKuHFku6S=L>cUggcLJIYx&D5%)*0YJNATv;i3M7dV&}2XFPws>_K8OM8kWKGpB+r zq zugXawjuGa6C{$?vmHg1te01gyW@5Evq8$7w3E-`zU1~yCu~TkMINA_5WUCk^On=W4 zKa>frsZA3>EM=#nWB5S+x>Lt+6Q@mQc94kEelh_-FZXhUJpdFBW8?rGKjMgv5M0OJ9A3DDMG8d7}~|ZyxH@ z9nAA;%W&U=5PBIN{NyjBSB6@?{eh8s8}izFC-gg~zD(RTkfcPGIn{PqhqGzJI)=S9 zbl_q?ExiF<=R(SM3ss>bZ2;xVMWO6(mfuvr1HqPUQd!!(f&rYgguC;|{;Jtum@Ipj z+JibTv^+U}vF(fu-4=U$et*u7P zc42f8&)rHYX*D!w?MapUYGk|;@p^iZh+Q2n=&07sh^tyOcx%?w(Qmc$X3L2>tpcGCY`$r8PYQpd5>J4zD1$hZX|KhT^{4rvAEV?Z` z&y_iM*OJ0mipDE#V^%3#H(;dr;%`d@jUl(&XAO;Ukp{s{%Fzf?V=*>{!rpDf@Fu*( z{i6mCHR1QE%BzA*n;_?bSXDGQ zhdR1Vghft`cU}O=VxTmb3SW6dPu7S#$v2$@Zq&+q?ivx~wNJibfs4MGDh`Lc<^*%x z&tnLXApg&ynG?ATFBC6?e*tDtR^6x#gJjOPy!bdKXg*;QJ1kk{;Fh$b z-#X7YCopq_Zm13(mPf@oJ2C!2;nf3f+PZv|fB!&!$_}@=Fw(^ht$V3b7DrI$MdVFWwS4&3xM>@))m< zmd=m;_=W}=di_qIGR2%NLGk9AF$A0@t`SVCj}2S0N2^Eadz)bVfm}0T3!g~>?LNiy zIHI7VjR;%UK8Y}G>;oIQ;=O#};p!W_s*mi;uGa#TLPysIpq&T3?MjZnB zrTl%Jm^`WcWU3U5iKRfRkxYS<)Z2(=_C`bK3N;WNBWsrIb(!{K)eF>;v@4Z&Hfs8v zT_z<*wc;&!UU;b~vAFx3QNbX&z{ zyKxoeU%LR5jwktLV%fyL$`J~1H*xZ~C|p8pH(cF#`{PC2LL&OLMYR$JSY%@Xm7-V_#G6y+8Qu-C1K)X z_jJK#zBRjaj+3#AO9v$qHq$s-hnHHw?O3MLEH6Pgpf25nvUaZiY?Im~x06M+#s(d7 z@z-wg22}S7sutOv+!yr3DRjM(_y7{ljH}kh1+6*3T${;5%z4z#bDlPQj3oj(r?HDY zyNsg~ttHWTR$YOx%x&tYX0R#X(EtqU3sg#@VQ}8&S_Kp&>}mjG<+-T6Sjoxu-ScWLfiE%K5g?lXN{mjY(OP*%P7m;1;REaEkN4=UDzIii~zBnSRuf{3u^;s7i+5ZqA6L;N_fw-O?XxM z0H3OFY!MJ*?JR5i26{nhkdTKIBk_EF5(x2YTcvT`_5{8Me$V7pVtxAU=q>qSyyzGZ4+-IubZ`OjN zn>{g@pi-!+5mYMyXy6Lg+v(U?67-ng$M4Coo4{dTg#eVAm&xC-)|5EdmPscM(INC1 z>9)T`)8lNt1lNHcIN=JvzQ-g-4vah{pTB~wJW^#>avRY3mejEaK3_0I5kAAB)#s_6!0~%P5fM;-Temv%MZ!gJVAZ;s=1lq6vkF|{sE3hJ<1rE)wNpniI%=B}MAGTm zFQPpw`b9K>7k$wL{2~TQ_MNS)T(35>v@3RL_ZsdV*q|qvV&^71{-ZMFK+Mjbw$^+i z*Y>s3<+Eb(GR7r|0dT2;`X>QR};V$|xxNBObHqaw**9fd{i31)(r?rw~ z>)+s6*VdLAuN*_o0<=2N0w)um&cAOL=H*=n4luHGSVgXh z)&qOT2YS0mETe}{tfqlS)PV#Hia&&;a38BvbpNK|pGh4Rq+Twr^d2PFwndng(WNPv zWkI6YwbxE<3Y1bQ8}`?MvSu0EwR)y$n>aM>@JMvd%aDl2bugR&XsAz9k@OGeXu z-+`VNKoMekjLzF+pIXf_zWpXOefCieN$1pQGX z=L_4BH?)nG8FuwD(;VI`)jK4fDjNz#omeu#6|sVX)FK+~DsxtodI<9CUva<3kGXE;RjNVx!9 zj`7*ls{*EC^>947w8-2x#RrX2r{Sy=PJ~nc@Fr0>79{yr)n02tB&+l6DAAaxPI*?i zDtGceh4LIFSe=cz>ISOGi|@i~`Mb#X-JBeq;ph~yQJp&T#Ws2IGr6WSp9R}N%^j}Q z4cA3Lh>XGKYroPp>dGj0Chi4;_?;XsE{dPXF}o!iU-cBY0}Byc3^U#x4~@p4p={>geJ_Q$K=5WW#v9(I1wM+;9};Tm zJ?PPiXN2-XO{Inx^vOX5ZPRd6rykN?83a7k@nxP9pRR8Gv&Z=J4K0tvL0WP3#LW0V zUyu@je1#WC?ed)~8$+$k21Ly#8cMJq ztLfqe^>duw$M=EU#N5IeYHT+6^)zKtAEP`Yx~1JhQLVC<`BHfr zIFBl__9v52WjU_2ZCBpQT2;!-y%om6d*SXLdV(7Um~mwiq91c`WTH|&Rj8QfeA7Gg_6JPDFcv^I>mTA|?k=hR0_3R4-Zjo&lB?70vTaVT*HL#nOhpAsW zbdf49De;co@UQ^dG-RwacgJhRfnp9Px8Yzuv}HPlREQ}b_z&UmESiHh1-tX_2R-I~ zZ;t5Pwkaq~@rEmw5jkML5TLHG4_>C#QAh)H^CC2aN{+9_1TepdYZfUzN20TyCoZPB z3FzVA*Q=qoy9rS_u^I6&I`;g%&|<0!7}MY|D?QE$Ovr^CY`McBK+kZ_XT`9pXiz5y zq9fC_5pV+~&L$22Ev6(-aIv;pX}TQ;u;!TNPzPf>N>2!N7O4O@=0!z=nt7c>VJ4JM zgDd9bp;CLxRz&NRO%Na}oMi88BL((kcXmpfJ~>$Ag8+VTYl2c({5jPiQ?Xet;+j{} z+G}QzIJg)2b`Y~4wJtY}YqUl%M(`i5k95$@75`JpR_?@e9x;&8mx)RgPC5Cd-Fz{cXWJ(uC={-mFY ze#GV9qQQkTy?6qJHvloOo3Oz)0MKGZm$*Yq@LggeB4sh$4_t1%vm~_>UvA4S#AM5L zrG-;)>_F0b3Z$G#9c`Vyv)!b{u1Q9j0p#`qyDtMNOIHY$?mo|ir8M45i$d(*yF@@B0R2BBJ#&Tvmtt!%Ln8h)!C-@LeSdHhO>Zg7I7<(shL&cPP z6)nacf7bGSX2Lb1-o)I*&z7#G{jS*17_GTe2)qr3 zv^i$F^i;Y!s8ugjZdFhB!2kHJj%3?R;^qFLLWk4BTFOGpq5xsSES*vf6CNyK{mKiN zfITYKq6)Ogt&v64<&BjG2YW+%W-$Qyq? zoUCyd3<;;fNV5)>g1PvPC zR1?RnlE+^|gT4%Q$=Sn}HJ(keSlCsL_nTFBoY;-8yzNcNSLQ?#?*<_sY9M1FaA_nUC&bn zm2K#`(mOU{{~Y4*FI2b%Ou&W-BON4Qk@8TR7$7moU%d{h`V?1!fab;I!-`15FA_8) z#8xl)g1In7GJA2CVAh)hzN-6OJJTTTSC{~TW)1>=E@N%i=@xHEyabg7o>@~1g}jkt zd1w2B@Y6KHSK_{#Q*rs>P)FQyPIE^M2Gsz~#+^%mIOH-nDL#uZcCSs%?^1^0$N)x&8o`6|L~Bh#-A< zS)oQ=-!NJQ4%6_jGuq=e$v;TPiEHyzW)XERn+WRncfV zzI~NaXzIlT*x#Nd1B)A+!}3G&$_OqV+kpBV8)`3a*G;x49wv3bs#SHTeQ)Rlj*OY^ zZXzMfBF&LAQ-4SfwF3fy=awRNFh6>Umusi$-s7jsoEj}DwnLJ?`NI2w+)%s3TmII^ z2X_)`?~L7Q$|*vNNH|5~?|h2B!W0deDav)Z3$1@>pClX$8e{e*h1wVSEj>F(#tl>1 z=R9GLgr^Cnn6~8sD@Ug*YK$_=H!&w1CoHE^PBS%K@k^D}xXnqjp9iFHrNB;e#3`<^ z(%aX}F@Sk;U68YbE97u=zan&pBsyOL#XSYdYXu=|<>c+F)P5Ah`lO6g&7OtIoW4u? z3TNFWt)lfbWiVgKF$<<*cx@$}UVyX3={yIA3#fCMSo!gaRGsQ&tVHQvgD3lmlIFa% ztP&wk!4+(%p*UsCi)Wzf_O-E=`oOMe-mrO~s%LfupcmF8o1Ibmb0jj8XN&?!ZEC>$O z8$exgs}sV-e&U`R2UwigR7&y?Xl^_N8W`v?a^gk+@01$AZPFuT4sico)1VTIy@{>6 zDB>IlerT;xRijLK0NLp`_%oY06?CY0Rp%qRQ?!y2IG#P(|2|4-B zPbc$URJdg?)Q7eb+*u)oWFBacPa)X@QAkP(NQhp(-VtA}s`6cedW24(v@oT85T+1( zAUy<9$cgXcA~yswrsBN=gqp(#4i%o#jfba%?9cT?D^)B}k<$Z1%?+i;r0=JeUAJB< z(G?&`ZG8$4V_FT~Djjk{CZaR-sg3=wZQ_6?9Q?`q0L{`JuGjcAe`-b=Ur&5l*zwk4;}>D$ z9F&UF_}V1o%(Jwc8ejk@hzdGPT~>Ch8su7}RDxXlJY_>RWtOn#w2+m?u)f6Cgktm} z8D5|p$xZdUq*dTqG>#GoTdeidD32>aGND({*gB^GT5;MBdbYl%C;VVLNA_3Mt=!Pm zAqr4$(8NHP=W zwMgxjc1U<(BjBIUbZR2>yJaS+aw%dO*%}@#2n+f7`KKr$#^P(ro4f52a=RX9^|c6yd2H z)P4N2+xB?@9$eQTKuxgy>Gd?42WddSbc8AH@dD`Pr zV@lR}72ip53>WmlKh^4vz708*d?5@sT+;fMwh|S{RkcncFW?TE6*E&+D!Dic4~!bV zuj2f`ItV2z@tXImC7I=mR2h5TkyI}6=l-Feyn7Tt1|5-7V5bQka?R?ECj1=hFT7{d z58`c_@zyYMZaw2-Yjn(kSLFx2{Nm00n9Mk;bmGp@I3a8ZH)hobSJ>5MJH0ZU&h~cf zI5d=)O9pE(1reOM<6eN*uFI|4q@x8jtJFQ3OH;OC2RZ#R^TYA*mAWZcnGb`lLhy2Q z@kiCs2*J)}E_j(hgnGoeeBcfRdBPZ&Fp*t_;IeOP|uxzKLXK0tE%3QlWu4V`n zw&%xtSqz%GUt!%lF}xdYX$S~H%l-HZT<-%T?$y<)aGKa4>yS-KDUlhO%VjN_Jg`yT zV7*gV$WykAvwo_Kw_eL2_RCxE%C*cOJ_jwsQK3nuCBdufDr>u%u~W^h3wO<|MlWMy zeYnMGR$69p5S|5mgScRr5#jaAD?6van~;<-dkdH7z@k+%eRtZbZtJ$-U_UTEPTyV^ z_F~RxgV{CJyT)&Kc}SR6Frd$m^;OY^atv9Oxj3IC2YZ00LK1`shNXi-0=M z@M(i>d0zgcaz4FXtQs9?(7dQpTAcnf`4P8lTg@v+`#jOA{saZeN-3Z)2I`XuOngIr zO{Yk`lKV&5OS=fB*9O$<%QPb9GB|fNjDm2l9r{C5A=7x#l#J^o4rHSl_2V66`brqXWIrfOP?B}d{dWV@$7&e4Pm6OCy3;-l4@#8 zFdbk~5i{qX$ih0x3O8Hhhn+3+;MuIR1@hH-I$^f<^xGE+!DfisZXNJ7m78STW(OGE z!cC_K`cpNNm;{s9O#nIuLQeTKQ>hLomb@}ZwI`U%t>FOpxD-9F2A`KX;^vsil$Bo2Syn8rL4z?#ph|H4s6AVg;K1ONsH#dkK{Z{j*1#aK#vl38z30L`n1BFUbM4M42bW5i25w4e z+mgJ%Y-wC@WncM%vE2hdwmSvVhPXJYMZZWR!D>z{2?$Jr0~$YQTV;yV#5=L5)z>6b z+>tGhOQ(5yMwEj}ex6#J$$Q1SahS0DcZp?GV|Uv&GQYa2-jlYD3I?BFWE4Z*;LDi- zDCSoWqcbokQVFIQ#RS_nb#g{`m<&7v=DrK;N{6>|D1~ID9Ea@=aNeC#x#%jHcOkZr~K9%D(6r^aO& z!{;SMHw=6I#XTC_x>>FOycIL*AgwszB>l|M=o>psX5=8H!P_wpKm^!XZYd(p=u($W z3g7dIDw!W^3)VUoM4Bbt{deO_bd^Z$>1eI)TMcq(-UD&0u04u zJB3)d+6JufCsW`m?bzZUst(9&3*-OJ{t1nw=U!z8e;rItq_QZ2gdfzqrjg#_JC&(pU=6IdSEBEU)NnX981Z}@(*bBU- zZ9NAds$u7(ATCFdJ5<5-j!h`wTo+9Au>7UsS5^T5Wj$m2Z4A=K{%U}68#^soWrMmu zqMhboNW3IUS~RjHi`uYVGfsKOO>JO}KKj+zT_RB=B&%yAM$oTkZYVBv1A`k5Y_N!| z7(~31NX4gFQKfCIG<$(MOwD)~8Rt5{Z}6hPl_SUlSo6x>f@DMCx>aO)TcVeM{X&Y= zht~L%2NmgcvL>lPl34kZQ%mujQH`{x`&<_)q)O5GeaPu$SyXc9cpDS3mAIm36m?aC zDgj9uJCqKLX{oRZK@?4kwua$4>hBFtC5-2XhOk(dDLW>KX!J6Jp>JlTTFqr)B}kz` z1zF}YYO_n!5KKy9+0biSljMzywK(C63c$=tgs%zk zpOM5qIC6(Gp-!2l)MJ9$599?mqKnlzVNLk?-K0WAbtqKSa!ZaBwJauyG|GDHWTQPI z3lqz0nDyVJ6+*cP6QnZ7{dXU@5*>lFNzr9JRTc;3X>=UYs1q)98-xovkN`~zWjbYS zs%P5vq9CG$ARTy$`+{l!7T%^u! z*i7e=JEHSf(gG6uONi6euqkK?l~a76A>q?Xm7Z8$y+PMVMY@8^Jz4KHCmxJhHO9wP6`7FpxF(tOQVlfupcf%+~3X`Dy>|VYl7ggfL z87T_NvA&-T2Fm?5icTxf$kO#HMdI;-dI5SzNfAB;$0qx8=fqz>%@9otjYaQ>ehs*k<*%ZJA8yUF9F4AY&)QDQ+@cBZ_LZMaT;4m3PX~(=4egJu)$C; z@gtSJ=8#Im#;(~+6^at#HReI)#qhyGzQ8qx7SFJ;+li$sWwTFJs1}?(5J8ix-*9jN zP)4pSQ(%P}2RTm(X)gt!)Kc4^S2S>*i@g% z>D*1|X+w{z?wW>gQzjR#Tsy`g*-L%6Fc`ztEUqvdajLK z#sY6#NVzqG1^JockpW^d%r_Wfr{nNiCBh#Mhl(St(bHMYzQMjDv(H(o{4LJ#;MvCK z6?ONF7+xLZx(wlQ##qg`nhJnW5Ehg6IHt3>xBTr8y3t8o#s1Npq}*}xv>ikyJ4?U%Z|2 zi(VVfRj2}%PgoIz@};%|5?R2_A*o{TxYX~1zz%P_c%ZXn|9X`bYGAwfs9Cv&xOZI4 zbuR^@2w>UcR9rp3=-d}xb8E>_7y+oboUm29d_#asu@kJa0}yOXEH`^Fan<&$DP4;z z_amNp|SMfqF|d`FER3Ogx{`816D@yJqhdx&^~#l-Sp{(&uUg3EkiX%0 ztXPF^LcJ3Jq{5OPbYv{MawAnJ5Y5bbKsd4aK6A^IW+c%WU0?$rq(jFyD zY~^^0(kWc+kh(PEN-gW7OgvB~-P-`>qmY(^U`DspZN>gy~*Z2wttc_UJ9FjFgeJ&E0TC8J3rK!G@|F)DV7-BcI zSvW&~@MpYgQ&s@K8sMx|2Fpha5m;A=;P6`+qqY5JAXu*9lM7KV2 z?uVRv)*(Y9ppaXPDhqF>0T#O;qbYp7ujwlTo8y6j!piBGfI7HYrOB@fK{ztDt8$(o zl#?H6%+0HD=MYQx`+2W@}#}o94_XyVU7zBD1-g9|o;df!gM( z%ubVuN{VuFbo58UW5=lvBIsF2F!ZKY$-t+XUctX>vir@z>^C8CjD*-va9eF~_^n>- zjvmbO7>UhaYZ{U z@6%$IzN^_&BB9N;ExIH6_F9?&tDw2Qv8v4ui4ryN8HbjMQOX>oI-$n{t*Bd6j=o4!zgmz^oOiLgpk^D**Hy(^0w_nEQ%y>e8SFxkOK!Z=Um#4y zWN&nHC;W((M)mY$c?evjex%aA`^y49xe1kq)1jci?pGYN!}N@kw~TifS`VUvb0gy1^Qquo1d>e?OoG@0=DfmZ z8vZj>=Ch^Q0@=mOR%;gKj@TAz#6fj{u^ZmVo|8ggPJxllj3kw|Rmx8O*6#~fB@_G7 zf=cubikDa9+em|uz1&Uo!VW-5+REag=W>@^VI2K+P!yWO8*53epOpGWv1K)71gTJ# zHIN1*MH7|U1Do+|pQNAonlU!3jf{f0tke07f1_^ZDumK+8kMEyvjbI&1wVISL2Qg@ zvts3nk9YE?(41^|1_nrpZxTVo1H<=z8I2o|Sckcfuj1KhDBN;>8N{u-B{gX12iL3- z6^0b58faHgPX5_~RJ`R_y(6W_O^!lLq#&H+BW=6nx2e^u_g&>h z)g$@}Cm#Sb`yPe>55G!9C@4T)5qt6_B(wQlRLJB$C#SoLlux}6{Drukz3|lH=uy*w z#u^-@aea_R-uZqEn3ed)rTZrH1t6{=PjT>?sX=^W&8|MnjCF_tCcQI04lM?8&p6rxb{ECLM|nUNL?oaI+msU`OD8A`Tm=NL-`+LH z`fH*g32J+U{7jq)@^~*e(ho>Mo_N7ohOk3lG74AVc^z)E;N%NKcurW-lKG#{lR_H3 z43Ih9^&m_}q3K~ZJ2&0PccOReG!B>4=x%r>A@w{cgGobf1c zmWPVQ(xRlUu-Tfg{p!7)l8}EL8c?d_wWnN^;%y#@lozCqbyjNEL9me@e}14j3KRjX z7bLcDpL)9n2K!xO`_IkyXvrz_#ad5)@&&RX8c`*_+J^yOnD9{Z_4Fh2?N8v3sNN=w zF?(Q8J`q|8NR5RwDs*c{&oI}XnY*AZ{Y-%X?dvn@9bta)Vi>bJXg&@w6(T(a!#6l$ z?%;x|kO5w71>1FD(<8S4==;3lT(F! zmQybtjv$g^*$ONai`TfjkSBudN)Nw zCKuq6He{yd!xRk}Tjejb&LHHvH& zx89(@E78`eaeFTem~;IcY;*+}1FW4WRT;hqENepRwHF*%uQd9ZMLPe8S@qq7O%&wV zzccd=5g%!!S&fL?HQD--ru2qV6|k#5a>bR3L(RQ3Ba?5Tpfo7SbTnA!A@eC?fB3|H z>dtrp())6sLTKLbQ`(fEDt8B;S~WJjbgj&%uoA?fKHN5vN~38NoG(cM0~3$ty@Hgp z)6~?C-G%I4O=4eUxu%pAE7cmy>YpnaG@k_`F*-A3^Cv;;3UP2k>wPGFn%DiL+)i2$*>W7!}2=8qsgz>ka z{@#WvFv(yaup>bGpnS2coiF^0~u?bX&jojoP?2u|C ztwWN)kXp3Co%SL@9JmcY*W5QCIkHg|^8@?;qm@1V47fN$qSdbD>aL|&LVM2-Gf-rx za>%jSeM%v(T7p8LE)@m1UPu_x>kA^LzOi7okgxH{{*#-!_bQVYFy(TH9(r%VC-!t~ zhZ18q;$kdXzni9B7h=8{M=w2?WR4-&L(h10cn;{^0Sq6Q>N#j*HHn?QgoWcX!Q`)P zlkeEzFBEC@uly6@;Hx^NRkwf#1&cuoCU;6Zmbr5qN|0wRTm`V5 zAXdD1mojxvIaDS2Vn5{yMJoAQ*OT`Sdv`=K;$WQk#g7Wc;h6l|*5P!U5HD|A&N2Kc zH|iVvNuADK4}*Bld9x99b>daDCA2|#JWvj-G@tJ4rovR2mpt)RN0&)EsBEOdcHV$j zM!SBdyB-D#y_?jjh5-`(myf;S$Am>gN?u zFRs_No%q{y0`MM7t%Jk~&odFEgT&1uRt6-_P9Ck263fSvO&t)7Xf+#wc&=sx{KTm> z*3yBmVkmmU(tn8s-lQFRp;j`)aZ|f!Etu1$g^&v?0?KF{ITs{IKLpNur@piQ18s-S_DfhClxS1q0Ug<_==$l%_F5SK2I6;g!9n0e09$a9P&zJV7``D?Bp9v zh7q_`l2;eP`Fg=*n9!O-*~2{OA=w(n5_Oice7cv=F-q?@^-Qp1MhBB*Cua^w8T$h6 zeO{R)afcpRKK>k1~yLGTxT*JwvQd1o# zKJZl)PgVpG3`CZ;b&8;{agn$=&bPVm#x#3#L;(tO-;-yYBQ>|V%>cW}Fm&47IA{(# z=rtIY;&TJ=tX)C@jEoU5mR8=DXXlRXN{-kco-Ob?VT{Ue$hGHQ%vbyq82yJXUCDR$ z{U9hO9AD+m5v;y2Y21Wj--1+rr_64!s*r`0ZzjG~9sg-skuT!1?Pq?>6u!ch$-z-h zpeilYOI;#2#=>!8Vlng2ewf6B*&QXO@SZVUJ@=p@y{T`;V*a^IyQtB<WHHYQd z1#8x|E0?b25h7MWQu9y87wgo%e$46EFC=GM#6qFmpnHEDOousrhlvs#z|!0VNmJEh zC&NLeapcCHa6uF;Hfk0{BquC(Z1`RX+(TjQ?DKoJjSE0G6bi!2RR19d$#y!-Kxw*| z@Q~Iw%t+V0aiVq7z$!YDW4dsE@JznFI(Sc|Ox+oWzp@(FAOQjOD?{)5w*IzfgENID+!8mg(r7C1 zd8H+t(kv#&812=bkzCi3^HGjGM^hbw(wyRIdk$c!ES$mBdqM=_1Dim~>y)_$5RnH_$V+MM4eHENbA)kD=_sW_H>VFN^gYv+tW4;9{TVPKZV8czyNAtt}NUdL4q_BEfEg*)!G8;?Pce) zBAuwJRY8pwRoJJ?AW4fnXD8B+IC%Z&kl}QF;y364zP@<04g_=J!vJ3YNrjrg5Oo4QRO}mK-{gh%x z%dgA#)rRrFXL?#-xdUeqD{DE>i7iI{G8r;9lw91_kR75ULM{~_sy6)-@ztxlM9Y@jpD4yjRTCUP;&@17`#1wXjvGEMwkEN_OUK8H1Oo@0bg0uDG{n<%LfkWnEs!60 zEqU%+sma#0tRp-AzV5_x?4BjB&9weGJ#%UyxQZlQt5{BT(+D_@=ZDfedE<3(mG`!A34o?REQV2_T zc=vR8pI96^3}BO#ea2#602|2TneFgBO?P*oM@sTdiK>lh$~OsScz98IXtwks_aJ5~ zodmmqu|AS*Zqg_boken*V)Z6?P{ft89EXf+_$H0Y!kqcw^ z$j0vIa0U6mHU$BI7^Ry8le*;ZHwAP3)j!Ihv%Q_J1I8n!bg;9fmwiubHn2)1j9lCA z5Nawnl~jG?5R#v#`G!-+d@YUFyuC?{LYA*-Ay8`~Ms)jPjEyArM1$~ACdG(_Zlx<@ z;M5_XZu9r*^lpUVk}i}|00O5)Jp{p_AQ}!7c6d8lyH2V0T*e0{<8nBYH41vXLWfc< zOzG!@Ya$plO_?Ua$p`AZx~b{x(rp6ut)e{`(OiNJyhHM0a+OscoHq0m!lEK1jY1+h ziBRDrFRUWt0zgnm74j)88~{n)P?S%FGKPd6gLa2k3k=or6l(YwttS7_kzzb%kA!84 zRBxt{FI0oHYV!dD8}0!;0RyU_yLTdYxKS4GO88G+k>9C6F0%TkF8`^Sf21NT{$0)G zg#+`@vb|5}DPZwGTlXMexK(#2)9fH0%;T6%${{5PrD7-hU;Npz|v z21!91Q<7@f`o%7@otpY%(fQ;E*iNssfQo-du)>3?x7*qwBUpY4l+)dTe?4{~-X5lU^*j9R7ty8oV%&H zu1)4`QC2b!$;c`qlTL!V$B3Wir5V0Fr6+9|pOj{#`)(3DOVU!?jr*tWoqS&yQjQ;l z%zlC%J~;IZvd zQnI($<-FjO-KxcT$)p8})5rroTFAw=qq0bK(!eHBQzbnq&$wcexqp|x)+)udrMGc6 zR*9mQl8`-$)nzo1rV9aP6zQIi=|WPEb%KM+mKj| zmyQ8HRhxDcP5w1ACeFYFvo$z;k(2_G*~Wu3!R~P{g_5@!0ZZ~pS(n}kyw94R5xnS z_Ziv45aO(cS}%=wgyG2I&D@DT#2}=v2;O|7T+AdXq0WF16{Jo`G(D3;W?Nh{w_!TZ zlVXTF=;|@4CLx>1{ps~s8lkp&Icnno_~fT6s-ox93~IGl*;YvA;$}6oF?zLl8uTDF zPCokNfr}btNn4jHq%QogiE>4&aw;5>L=&RJ4*)htXwc7-PvVcYB=wB&D&I78%AKsI5JSQw5UZ_LM4V|U;!G_v^aSEeJ>vA_kuD@8>Ei@W+!t`-ZX~*j z01JKsx7TzmJt1FpE->W#C86}&wnD-HihDj7{mSM;`n^eA`gLnY%iFn5bE*@l*sqx@ zG+NYFbIy1$wes60s=P}wt;N)RkUC>C*ML~uB!eiaIj@pMGon@*Deo%L0423Ddo9FG zbdVGYH&OA6XblZJV9a-$DO(r}I{*l#P1NAgvV{nCQ-8?Vdp=J3kTGbA zaq0pfIdzc8*{PXH-?J$?Ep1vq%lte&$WWtj8(d*R4isD$mI$$@K9^11)TSFw!Eum5 zY}p@UP$fwZVF>84{S_3Bugk1`ZQ=5C4{u+`Gj5$yXqQ37Wm4d3LPJhviR~mF@9l*J z+8{oYh7q+S z3Lx%YVFC;@gOt82vUeRLXCTgKz2t8g$#v@DbcXa1H0pFDcWKQT~1p z6l$^T!TQWotWiV5Nxn`WVUocU*pfDI|6`^^#gLy{&B2;(nN7cWXru))+H}pAn7DY` z#u?mK0-Lzl%OxZHlE3#;+I1?7!>FW1|42te(0YbmNnr;eJUGq0^Gm!2=^A_PHCsz3 zmFc;JeWG|%zS=ut{OB6=5;Q6*&(y4A!^vnz0qL5SjWwduxxV;3vBpKP-J~GvW7dww zC(#bm$)5?w<&-KqvJ&Qb<|ha>b;`vFrb;!L+CL5njCyK(3Uw&Oq+@6X8N>lZ z3-#dcMFMnASD>it+^48$upn1fz%OCslv|<(gtBXMfVMsklHFCD*EIi-6T2I4xbBA2 za=1{Ws&urFodcnfOM~@o?zt1OQkY^*)(m_^3)#EVaBR(tS5 ziM`lic_8IpStWU>rN=Iobcl}ZOEnHU@;0RbEj9rn9m$c_$a@jLs>8o%AVB(2_H2}) zTeY@L8Ny2|@X8u?DaB)LOOOcob!2~4UAHFBpQQN!>Pcy`5bPbRG3f`>cd{?ljEYrK z4N~HGfXs=!42#~`6|yd)5S+;oYB-ynE+B-@4=^%_>??6dNkNc+7c__wz_rzK(pVMX zYL4L8+#pC3UYHtaYa0m~*}cKo`_~12-y!S|HSbf#Q&5lqy>3Y89B_tP=K#tR zY-O&9VS+1iMBCd?L3ADu^dc5+oX*iAbPBG-4@t-=k?h6zo~iiYMG?VMZlJ||Vn9jh z)#G?%DHKT5(HA7vQ97+ZhW46)3OXZoepOIiH?@`Xpe^2otsX|N_+=K44;)w+yaxP! z$HuR~9_gkSTdY3rg?-dRMs=0A0+T^4(4xnILC9LkT<}V=)nWPiNe~y{m0#<5oaj!m zG6TLwU>i6*AO9I>sx9M{8>X)GJG*mpX6NSDnUB^1w_X5jO&1K~ry%uhfG+VeVY&jo zxiX*LH*2t&`jhMNRPGD}Qa=TQ4trw1fK%tOxJ^s4Xh*Zj2`BihHsd}gu*35Wn=5vz z;%3;w6aHI99Omdi8>D#vrt4hVXe&B8-u$5#~(xy%Z;G43y~ z>e2={v0x__!%CSTCNE9NXugW?3=>vxZx9SA?mkStygyFZ6agTHL5h-7!Tmi7aNaam zS@0ht`gTcp7Q|%L91*E`LZh=V>yig^VsQMah zi{e+Mm`6e2snk_m8dVDvuCJ#>SXC*eyS#u1VL7scfU|SEV9)Y~fgf0I&#q&)7>5h^ znW9*l)2Z??T?y~*rUVB^boEWm!9%Qlh9`1W#;dr3mupoRg0QU%eO@O8R)r16svysq zTLVr9ob$cnoCNAi^Ub%cWI$uGw8$IZ%tjZwv}-LsCxaQkX4)Gd+juQCx@xM4l=~>j zsWlA$+$+1CBg22swn3wQwTAK~(JyOf{uf|_8dz;3F;#0LgEOAzapBJcPp8b0lb?y30g7W2cTWD8!8sMEUTq1E=(%9q`Oqs?i89f2z;5B76^oVo*=2e zdt(P)gR-Wty@BJ(9oRKn<)Z2w%=;cS2tIa5oH%ffR2DNJTs?)KTk_x5F=jZoY%24P zjbPicv2tBq07x3Z@4%fTQ$EaSL!bq8 zL0#5KB3?_;usK!h6%$FYDlc!Zue_H;yDOLKUCP>uArOxy!m9AyxUz6CL033{bPOyM z$xJ_>o?&gL8dJ|>-7A;yhR{)4@37BYp?dkqv6t-|O?g$@8Uqf_65F^N9+1DaCQT1x zl4qFtn1&(aVRKNazAND%(cl7n3+ABWe7T$i=Crz*#)<^nBAlY#6NpCY;MsValFS#C zg`S$seL?_6r>lAH-yCyfF4OWaX?7#SW0bPTv8$&h%)w~ZS*RD8hTaoXgJjfU0<{PC z!IhE5N6^#@>{bB>@2azZWW-{_O3~uc&lJEva?=(ViF6Toj2*Q$iq8|+8F$ySCw#RV z)+Ag^LC{jl80thp$0kzPEl6tA*~S{9nA57!Njy-(4Ci6g5n1wy+jPqDO8w?O1%0Yo zZoFTCP*oC-{6p(0Z>_ALyhI_z8j(~5v(R#8+@QFU-X0`8#kCQS4?+J|qV8s0zFQwvE?)og4OD?&JpT7Y?9w*oEL zmu;j=Yn*y}d0OM8XEn0>xtD~~!`W_ZA%Y%T^amR}^xF&S&@jaU92{IbwPQ^0Jkmw1 zQ&V0#bwxbg6_o?X6=*gdpY>onc%_C)ge27+Ym0m8D?jB|9Ex&%z67`7P#y?kU#N^n zC(^3zyTRe~e*xL4iqDmqMz?65ax=sxks6UbnC3m5+d%2766X#K~ikrB1LaW`Qv7oUkO-M7Cp+;M#2Fo*r+>SX5k8Wjv*!f(H_`3Gt4S7O2lMy?7#^fdJD?iH7xH}!nnVxMU*S5Swuk!xfi zx+KN)?QxMd3f{%;F1dq$A&QK_4L^3PXlcG->*OYWv1O<7)fgey8@A?RTZ6HAFA`Wh z7ewE@>emy%S36_}N{xKp7ptT?t9JGTGFNJ&Y-U!WYXs)U)SmMdo1#Y$@(m4{_7wD;mrKUgVsqmt=&LYF7bAGqm&2EK@1>oR3wz{GLLgswCL1PoQpE~A+D1Y+WZjZNmvB!k35d+|O= zHUWPWj+0Y(3TFL-h2OkPaHF}X{F^-Ne;Si@+$oz>-k7^lb9345Ql^%at)!82bR&!N zrY6~;0>C#A5qGSS8{lV6nK{KT8RU87od3k{PCoAqyc!9Vf<=gJA3;@Mv2CmeVo0i! zkI(s($uK-0*2oh2*R4j165hc>mk}MyDESJ+JlGR78G&S54U6@eqH+- zf`TDZMpJb*>>k*FzqhO^q8%Cr>`P^By#g0S5(fiDq;KQ>QnR3ZS``_wH4#quf&Ni8 ze6SK$5PVc`Fgaz9(UBq~^m(6t=-w>6a}Pbd1%2+Z-&^?HJj^^l^6Gu#8UAiR_1Dwi z)zj)W{2SN7`UiJAN*PojH?P37g$ME#+`Zm0dhS(Km(g0&w)4{+DGEp>K$j2n{@&P; z;%G%f)l5FCjV!fi@`=02iAD9PsE7nsAxZD@U?A614CH0*cD(BiWcASovXLYHydKE< z6a)FIEvKkI#9@6p$_WaQXauW_@9@6p$cK2ulIo$~cvNFX$MqbBnyuZ8E zzXtN3x<|f-1G$`HAkV!$^1}Oj^k@UQ3I{TtVjzCUpXMQ{J31W>KMx18HpM`?-;HAR zr_o0)!h!Ur7|5MRTE56Kcw|}2QFZ%M3}p4Yk+nwQK;{t|eMRf)kx9!L$oUilx%m!A zOAh0yiT{MekJXxX0W$U1E81(QAH6Ah^wxQFQ1ocudGu@1qu0)(Uy2_6k~tk{lpfZX z@{gVtJ^G6?S4B@=CZ!);E8o?7=g}8$3m)w`k3KDW^w?Re@}nwz)TMw?(WC1R(benn zvpRGh?KVo!>P7hpC?wV`=h5fU3Ha;3@8Um6U5yE@VTd)@$cz`fm-`Pu7^kW@0f$OD zs}mZ+lVl}S>xq8PeoKaNZ>VyrGknYBtyUoFPG_1=ILNqWbbfBw zkPPAqKp-wMs6p2kQU3?io$2{7aD0$p>d=76Er7mjkUSXzF@MM6bmx2%d$uxHIEX^? zt;kR#omqmUu&Kl5#m__Xh8iv;R({EJ5SndeN>YJzlN)GdB`@v)#MZw|{JpWg;Nc?~ ztP~D^1A;_>l4ltH93-Jh6S>=EHU)cfci_xBeg6I{#-lk7-+xn|NF@U5LfrE*C$hl3 zY{~|tMwHS9473Z`j<*>(FfFvo@f%1ucNnWY`sxRp~JiF|jgq`guy| zYN1><;J3=6Va_Dn@?!pwpWd^R;*82^ZWh{<;fSeTTMd9+s#9jdJbtvEPy19;)*A9K_?MIk)Z2OTGWd4_ejW|zd+JOeoO~dQ}(L7!d zCN}}NYXwu8Gy#j8itm1A@SNFx4AOXv`3TRz@Bod-O?dimX44ADGF|#>%8TexsUj}H zYH$Y0N@f<}7)^Ekgdc3{$Pbz&=c=&Y&{Nafp+6LPP^`WEb3G z!@Qhkg^iZC5}9|g?*TI?@kqpUfNz}T52{x$s7bYsu(eaI+(G+vttCw8RYs(t>)d&7 zkwYxiE|Kw8(rJc3jEWC7gwlPboI-T(E+dEGdhWazNE=|8CCq1gVFC~IWCoFU)(=vB zEIfK9b8v;Q?CUr^+kN$f^)nrO9a>X6vH4(xSd9QnvUiu)0R&&CH_X~!_i`2 z0%}s}qtHwnacyNYZis%dWQ#leI-59C$O8K*mz(VC$%T_i-i1VQ9IN3qdJ;Ts|1u)V z89ZO`WlibYixHvI1>Cg(_cb`ucr2Xf3pA?SX7lHb!`e(`=3tv*-k5$oE6H>oLMSTr zG}EF1WW6KXyG)TmIQkm8`6H?o2i297IzEtP^wW9PBVtoRV(-to?brE%n5Y2nGkSuI z6BcJ~EiLW9jZubK6Vx9}sHWarDECeB2%1S!+Lbcoa8BZB&)_Lcz0*E0X9o&qLB)Yi zGBAL=l}v3ao^uptX=S~>3$t&vGKo6tlsq!_tw$MA;aOrvX0M%R4?&F64%FC~aD%O+ z6Ky8cfcvn<9@o2J8#v469=BHaJyYeJ(LoH8-F!QZzX2yK;HuLf#1RP%S^D`55}M`z zVB92z@>zp=O7iB3!kF1%ND0BgSmKd#lt@*T1^C(UMuC-zi+-9n+%VKDsTCdxWqVPU zNj(PTIj{~_lU_|fj(WsG?QkYw2}9#n@(I&`tF!We7L{oh=7HvBjvgTg?d1%T`w4Kre)zA@L#8O?x3}a_tS9Zs))-6hkaSvR%kex+rkvaIT>}A$$SSBa!V7BVx6(ux*D1U*)Q(I`JA0#n0NePYC=Z_+MhWxf4+#Pg_}J>4uCsi z7D26aG)6RDATPf$&|+H!{=1W{ci`*J-)15F0=m zx~CR}zfn30gT`*7LbRyB(b6y=xc+A;`#?i8gA-F`YE@MSI!j6&zT{xNw&giVs8$TZ z00p>Gmf51O(QujR0TYZgh`VYSv0spn-DsA@a^awvnECnC&P(y*IFT-wP&*quPo9-Y_?|$=z9E5bK!&el)5hlNb$ba z66-p{EX^BjGBMPJ#QIYj^8`({wqL1()>rn^2@;E!B3VG%(+N@~%ppm6xr#q3joHY{ zTcD?wA$zPjIaS_FnHYQ|8O=rzYiv6&F=?iYL=s6KU{e}t8pGNn`zo6MJV(}{W}*1) zQo@$$G6~(v=8OrFV7e5Z z#^+(OU>;u4nW*EC49G?4IFnCDrL*`tRyw`%WhNQ{*|u`SP>`P1(Vf{lXhVtUEKA3t!54oEF^5}`R?7_fxTKQZiZC6-x-25aeem>7<^2qluR zkcEh6=$vt>pZ)YJ06#A_f8f@)+1CN{jd{K*< zJrb1kSfCCn;*&C(rp2If@Pk6Ij|KVgXSb+K0T%TL_MPd}eaC~1Q#GG0r4Z%r0kSh^ zIz)Z+JKh4%1syzuhCbuhoWbDyZKu;WI@P?)**wzX<`jl^vEz5cy3q3P1%yeIDmOjd z#c~<&4@2a#M3VgV=1~f-gXAoKy_@+X;aXQ`YiEW#enD|6_G`t0dzpqOCGl_IS||jW znhETSxISi~MDIJMK$iN>eLBNdFi|4%57SY9ipp;dk3cwjQM+Hh_j=luEY+hz-Cq7W zjw>vLD$u{FbzLHAWkobqrc-h9k$2t%*a58NdRhr-0?|&#W7xJ*DB2|MWb-p3R(_DL zIFd$*Aw@?xJ?|_v6NHA)h|o)>blU|$DOm63HZ5~VPsipzpbe0j% ze5$)VdzRy(+zwm(s)EVF$_gt}aPs-4wp1JbBI`Ym8c295aU$X*(V_fG%_;URK$c*S zoIPC$_0z(+gUatQ>ZH)`xxeMlUmi;PDLp+8uxiElo3kiu1(QsY6Vu2QcA}##!qdeI zG~vWvP&0)GI4bGGbjpP@o@H#}I*rVA>2sI%klR+J7oD9k)on%qDPjo0&vMUBAUAWI zU$T4H1yi53l?UT1-&2PI$;PF}*|LJB;2RVAJZTJyB=u%Q$5KD0j6YaMCbUj+m6Os} zxNn$n2h*KiNwWjXu!;>3QVIk##)a3n^Q^tF>L@-K&-#P zZfIG)_?~F%b=20Ovi+bz0pZ^j8*dcfwVR;;o0sNrXLLNJ+zaztbR4(xWY15Lt$KzX z5Eqq5^@4Ot^B6l$th{Fmv0)g*W`@ zpF2e7JkAt7?~fZ9G0n}%9A*|PS($y|_fmtN7$&rxPLed>OspBA3C!juj`vG0XiiB+ zy{c2p2cN_^n*9ITq9rr7M2DcyjZ|aMD8^*8i?yBd-a=h_3pv+$K9kNIcb72Wi8^E#KYE*) z*iFq1lu|dJq1z97(26T|XZ@l4No0PVus_d)TF$*Rzo%{{UskaIKO>}%ZKYh7=JG;3 zincYM|D}xeNt+=tOmq_EPBeN?8`x7$9$1uAH*JLS0vy?{^yi)_i*V*nMi^4LA@<`m zl8InDM5DGAA6c?ck#$Pz%}gHSx%|XsV=CFbxkzSOFqT;kA73?_GF+dV43m+7L2lXx zGDQ$pd{@LKhHQeUIboqpd6B2Z!bx+A9TJ!zFgNBbC9#v^XsN6THqF^By9;IEGeRNB zwm$lTQfWPkZKG`9$#elCDBH--y=8JWCa5xjF^#o>#!r)l#{4?IRbKO7fH+agZc!rG zbWz6__pP~6npksq8Hr;dA1;$#I-d_P#{J8i>mSmaGBJB}XyzBEqo*nJWga0Ke9o;fH~E$=(Y}BM zobb_yYHYqx_3{+6NL|p_mgS?4ae0>AT|S#E{^0DP{xf8eOc{{3NMf1??s}$hDW1~& z?$6>C`zC=(6OI3BIJ$0y4&jm4oFPpjr{!Gyi^}|UIx~}w*-3Q%v3z;k!%~=Fc`Ii! ze@HiN89{l0f5!z1?8pQTw16fa=d>(S%wpkjehW2R%obV_U!c&?Go^`}9m#Sxmr>Rb zYmft5WU->ZR25~97mfj8Vve6?mC93El4rB(gjU0B>iQElHh9NDY}UWc-P;|t=qFaFO!3F6vE;w<}e0N4>z+ z*=Cw=EU>$aY3f1Z!XJ^TPltU4Ay#0NslIxUs)~Qae20B)a=9+l$nVWl#Yos zUkj`Kc*e`%`QklS_S#h2mwRqe29bwb(AAwvWp$@i?AsslpYm$1#s|mH_x0?-6$*{p zs-mK2fa1p_65Ma4fLZ+gqr)JJOIws8@VT^GCu(#qJHUdLW+awo1dFnn&uPMZ;3IB2 zd7yZ1|C-UiX7sNa{cA?Qn;D(*h?~CFR*5&bM;_!u4|-lN{zx}yf+`)N0HgYkL|+D& z;f0WnUw~Y^Qk^!w+LSpkmZ^RkL&A%$jxGdbmia8DS0LiV29gX-X#$(cRREz_L_aK@ z)6aqn0_*B+?MzSI2ARO5KbKdoXWWGkVuC5H%}%XA&cho@G&TL*slGA&4bHZpLGPWi z4-dlUBghe@X*mEbT}-LRnXu9yQCTay1)SQ6B#nDgAp@t-%8WZhdk)Zy-_M*(_{Rcn zFIg;S`f4LV*+_kSm2K#ImZA|2XiD3L&hNB%HrWI6tXaM_9ebJFu}9qCbB8#UIZ^+J zf}(O{s+{+UGNKa|F||-wcofg*ikbd3!g;2lbD}1!r4O?&N_MQY=%}{13hgEnt#hJr zDK{tOyhKo5)MbTyZ=x`Ct(tOb-$QZ&CG8s}V@ho0=(%U$*Npscz!)ZA3H0(5%0tT+^I^ZM5J4*26F)m zrJh5N!e#K>m3Zz-KS!$LRj2!|THGRcu?g@;J>xPjPc|x4M+?yqtRwyhQ+1ZTTF`%@ zt<$WiV4+2H>7|dM)BN?%gYHrtRfBtj!Xz6MADz}j)UfKGa4J;YZBjMren%ah;(u9j zxK{BaQ$6<|LvjREaN&%EDQYz31CJIFR?dX;NU#5KR`|P#DO*s^16tJwk;0%jj4g%hJ^=VRZ`R^_WcLraMyAwV6YufU?-;8NlW6*465WkPL`0EJaSe?)} zx|ubZ-)7&-X=Yfg&H5W=#xjW~LvNDP4xmNqQD_lek&K>mdS`0X*smfuZSw`u14NXi-t&Cn zBhdMBq#DhXWq>qVt?gp=m%Rd&Ry=95atgM|7BG}wz6e7ZLw6DDdjOVSEBhTMKA&E( z^Kdx9cL@mM^*Dm~g!>B`_gr6@vQ~xf!qYjoYP#Mos%Pb2T)-5UD+)BtxC4HziUJsB zH3dri1Bz~Q!KO`;jQ$dl7qfxO?@nKmnT9~8_o{qPTGxaq)cM6gA^|S4vH7DvALn=} z+pp4C1m6U(@nOA;b7eoodFiZ{*fJ!$>$c8+ss9S2-i-By69V3x1Vx8fzU6J?bkDctCt>fx}D?ZJ}x{QQH5b{H7160xj}vnzFH2eb>dBy#M?bFO|4wRqM6vJD@~^_GLO%;LZ+P9^} zZ*3o#y8|=C5>qVx$BxocUVjDXt&qNF3z~dXIbuo;^LvVvoz~l95_n;-COXvkyEb3X zmW<@9e=j|LAUC;zcrh!~&;CF#=70V32M{wJ zI=tg?!d?~-N9ahSvwMuq5rV)v^BIe#jQCvS3@zU2^-yNt;JlvpB>cW+-WeN;Neeqv zrfxZe87v2}X^ySSZxTcMjTdkc3jVjVk1BvEgM!|F>54Lq2k;4lp} z{2olXPSimdvO3XsI5CW7n!L2BUtLHLk1qg(l|KG(c9t2A)IXO~>s!DB&Jl~o^UR6K zj?1g!y;Z$I%x)3yOfW;Sz+=0qOTdVIhhFgVQ}BHW z1~Zvl7dnJ*Wb*pPZibkN{xPk^k8QOwCSo_QNIX9z4d)|7w&|_+O zlvOIDjCadSt1QgwVo|=0GT?#lN;q<>6&x9?@UsoH$v#2f8AvX9NJ45?*( zJPN;wKkOsCbUCBtRkR-ft z@jLAs1K=(C^UJHbm^s*lYxy53ZE)5)7Yj3gJSbdt8Sn5+`7Lu575&TeFcbb-acPy} zyPDw>+gk2p4e3XSxr{u*HUFpa!}t`;rhPee{=O^s{tWBDj<7_TiP$6L#vhj*{Ktc) zg7jn+$gT9xFxOMpZut`s=uEQKe+cz25`ZKc&s%~c|K|oVe5+{Ac~<`0a1pJn+JNR+ zFyT!=9XdpMsiPvGiS>4pefFu45TC+wtYqH&h^YAs1sGi25yTD=0&6?-QPd*Mi4P9F_SZiT9TxcN z4^g;u;=aQ&lz(8KNetiS4|=(rsaQIu9~u63dPDNVP_+qQ&@`-7F{5twtAW{oFx+0X zoX&%9tmPBI8BwH~(p(-70l{3f@dF@YfA>3@FK(>M5sv{t|Bf!aw-aLc1(JJ!V>+Ds-1SFdoLfe34fw7r>aec2wzy z4bjMkYNWcnSE=m5QAm#6nX$nQLOJ@u`?=`{!kFFX1X5XR(aRg+%0^Z?r)FjXSqSj> z6qT*M1zaV{L~DP-WNdTPU~u?l_1jsb_4b>K*)0m;@2`Iz3ln}(DG5F-L;0QSsV@(l z;r!L1H+|zvsnUejyHm7c`k-?c3F7 z(0#!}VQc4)yCdcg*!?~@(ej2M<&9jW;{2%sg#U_ce$WZ~Q+YDKiK%jK0(}e@=(qaX z9|U}0(M*QeBKrBG8EF8h_AeH=VE?KNo#|jvkK33|qVrpT0>6SpIeX$CbB>dDmiC^W+jwrFK`D&akuf zpPLN47LCFL|8U6RI(qT}vooem?0bNNZE}-wzwv`<^;2=O64^w-QKTU9 zsDljsM%y!cx*j&s?R!`6nbHu2C??-`g6j8RsQaczApya>$tM^u4Qo%ImdD2TfsB?% z;(H@mN2HQtO%YYxZatk??dWk$jD~3-wXLNKTJ`b*wh^l(So$|UQHv>ciV|DO?P-Vf zZ8C*R@4LA+=ws||!h!LZiOl>AfgbYLC-MuQv)96tQ=>qZJ}x;JtiOyY|IxPhl4iI< z1cpEAY5#~BvBu^yWnB8=fG-}z-fF^d4U3vtKQm{jX=s>DMsR$ns($l{4O;n-Pza@E zut&tw0n^)m$R3?0kDSq(iqPi`{IU|3A<%7SK7DCNe11m*@0JO36f*gjoP7UwXLjaP z3f*JA5DdsrAd|fPeWmnI3u{D(qo!hdA3#x_%>0+13o?98$GXN} zT^xOQ=$98n{%|GpzViauj~mY7qgpR07v{S};G55t^*uPk76)~-d?zHryIdvlJSx7D zmPLWQ@`VXMkHrw|DSyoU`HktufaMtL!EO3T^jQBsp|`$oJ+r*XF@?HeOt!`p{~exf zWd!s9Tm74G-+8Jd{)fOXO$=3;-jMhhZ!7|_Xt8(xgF@ML(yiUyr4EhdRq@g)zI2{{ zH#3 z+s4ckzI-F(n429!i1$?<14gU*L>?LL=s$Fsc4I6wZlKM4VVnFr$y_zyjd;r6et*ge zkq)0Ac(MI!9H5R334U#?avF!^WSA2#H- zk7M~0qB1$cUlF)fG0hvKS33oYcWM`NI}@GF;Ssj z-`|;pW=tM-g4YT|+vXO&rkwbavBop<Sz7#@|f{b|RxP>`UMG!EzBmw46Mo{|fhjxsle60R79a`g?osdziSr3uM z9Qmn?@jg1C^kRIj6t*-io|I1{Ez*CidU2U7!cWeAO7~6$XUQv$vRuBm^KG0tcj4@J zN@t~8+I&5UlH(8Z3m`WW9vVjEW&6M}wK(~C(bto^-hp?^|7kzDOicJoV$C{5H$g@Ua^UzV|l2eKUz!M;1^S0eU7|#iqDuz z5NPvR&kNX=<1A6eH)Hfc2kusGD{p-$&*-?+o1*WjP*~+Kp6`35&OcKc)aWNheeubm zV0Rd_a&&HN?i7#{-!1hK1?mWY^wN?WasnNfYBNq5*jaz#rfhc>)SXugDnGd}PQ3sa z8)6B|%CNbq65A%7yk%4kqf)(hxD+yy`>d2~Wdg#iVIT~|Dx-*5k}6gG%Lh6t5TK*e z9KT(lg_RL@rn{{;UOmq7$X0|=%fH_)xaCsoM64Z&`-exIK{9Q54K_pyg!4X|#J;pn zNx~^JkID;_lQLX!R%`H7sC(F1#;g81XJWTeC%1zLvFE~F#8je;NClCcOMd|5RK5Gt$&gs7S^@}s%!?6uLt@!HyJ#}DZONW0dy+0EM2^FRtc zI=dt+0qL89lnzi@XpJB^d+NlLx?pKLb9saGLpchxeMqcyN7OO?0?vvDKu)pksmmB6Pf9DVQhvgqegR9|DXY|8Qzy5I3IlOEi zefeo+<^Q`p8;l2|@$l+sd^PN>oOD*6t@H=So&R$&IKJw2Mk^#TpWDqd>nl2jzx>l#${d{4%>I-pG*grQ#{=o49Df39*sKV ztkWB}N9CX28}>>*U9J;JuigJr?#aQR*J<}lJ)5=1ozf3}9K0C~O19fM99;E}O19nU zT;^YUC7(U%42PZLk`MPvl26vX==4Y3LBHIZmF;al91e!1p4{oR$Ky`9$$i~vA9seY zJKfW>a+aj)~b-539s>vrv;ecJiZIlemT3`gbPXm#&Pa)8=szuP|^+`MaF zcTd~nZvV90Yvazaeb_5Ue{Wj5?@B%Rwmm*NEBWO8UFiqk4&-{4dc4uTEcx8sVY$J- z6I_0Gm<$Iuqmq4icXe@C^3mPH^UhH@8h!uaUA5eU?cjEEy?d&o%ZnPOiX$EqTCF& z&f3FH$tSxPYvrE2>~+UG-QlPl#kI!Wqc3-gnU;KEnD?(P%063`SA9Gi4#wk>yz1kb z*nKnf+6{*+Ib z>&+)|6qemL?aQtb7n@g|;a%xhYFYV5FD`|gyWcr%b;k1e9F=}kFqhL|XEZ9$UF2Ir z80ZemGJW|%t24ar3_lLqqw?>3Y@e2V_Hw0i*)=11-yWY$@!nYiU zD*Z}+Judz1&Q-4`hdY|;4W-vjHxQxO3HhvF`uRque>L3~8iV6@Z@O2+0X^F7_wLHS zFaxn)iZk+R+$lfBt?^)3zVVjOm^&AOe5ZV)0V;dxm((FK)v%}8tm5fmTc}p!(#n;5 z=eRo(I!j;hk&>#OeCebk#B((V<;QdQV&lB5R(muM%(O2L0=0dokRAM2YyFeK%rEYD zk4rMLlTOLU$|^R-^i$^9?x?(g&>ihu^^Z!*oBo^#VXGshitDS+w66m7Px)dt99(9S z&r zRGL?&d`k#0iJ;lzqv7=AC*G~Ldp#*HPW__hSW~_y*?mQA&KchPIJ}d`ahX>y+ozoo zNM0o#ezr2`e-Ps-cgX9e<({A7d8M>W@j_Y2^s?6;pA3fOl*#d+Qt~;$a7#YfD)pS> z0~p_3cK&wU8H-by{x0PLh#Z}zmYF>}XL@srgW}ojN5!*Q4~u8>9v9E%Jusfleq=nG z>CkvK+>8DKd*J#Cv%+>KOe3htxkDZ{Jiz@<@P)h?a$jAM@O@Z zwLc#pJztxT2X4Kbl7DzSaC5c2K06P5`LZ*=sQdGajg9sBd0_j+=H^^HaC=IAjy&+? z`pL=6Jn&@e`J6KF&z;Vc{3GOn&yS8b=H-Fg>o2!v=7Ae)TgP+qz@wK(n{)BNt>^7I zc;H%RZDTGTcy#h|K3Vza7bhFj3e2M0FJDeAHUGS^eY`!r==}56$@+^a<>#N}5;24iufeOdMevp&b2lWxDWbSaLQ z&TxFUblMq(VBd((e!zCAh{4992f{_(W!T(rM*miq0B&PZJD zEDazqs`S)#P6ory-$vv1aC}vI{-%7qeIjPne&aVADVz@aW3f48!0>f@xb&rSxAc#t z|M}POU;QQV--$iC^S%tYJN{{Db(y)@>s*LNep*_yH;0|CSDn!q&;Fm5p4*$9+pcqG zooVw(tix&Nr=<<%UPn5fep=dOZvC|MLSFp$EBUV+k(hul-LV+dujb+ZR+o1CvHkaQ z{0TL{;E50ZD1#?*XQ;t#f4l_`z@W+fzo`fQCZG5lZT>eq_KU&2GjQ>@>`N;$YWH?9 zWO18}x8)B=+)ms5qfRe&w_vQ!-C&^NZs90L?jT1+E9=}1hd3%)(Th=ZH5)Cwocg1q zH}ha{qraVaEvlidtSpTNOM-Nd2c1#>zsF1Cv*F-ose7{2A1vKK*zD3^DDECz$x)cu zFn^0VkyiY{iFx+F{_&5c|Gw%getZ1iOaJfx>pt+zzUe>tbMVAZOaFsA?7Aav4#oGL zJo)c{Vf^<}w~u`i-_${)g3*kgh<|?kaq0j5Uo#s|6iNTO`kVijy5T%4sDgP=Ty>us zaSx5?Gr#`!qaBNOfKwjGaIzEa%wBrZQ6%)^(*KC(1kdd+=_|jgS@~5A@mbKqZ@)eH z@zv75j7(dpIMAy2ra3|{>0H>dFt+xT_6C)2k!j$$om!_sLB;6kt)H)8N#Km4n2 z9~P?NMO*I08{3&n$t1mNt#!Fd8%tlwS2{FC>&drjTswcn7W&KsG&%b_H z7XJg4`1Mo9^ z;!r3c&q4S%p8HKmK|kV1N1aPCKpk~2r$fkC!&E4*PhPHV zZ;}TuheBw%70>?u)rr3L#PEh%Zq&EsqpDWQNKW^e9Y zUYeWg6LRWWXI-%zPnTdLis#gwpVZHP%Yh0B^5br{`_oeEY;e^(UO8&_g%H^tEnST| zVryM=mV}}&NdL4e=3T6e7+a@(yd)&Tvo1uFFSUEUrK7WM?-&}>^2TVXbKM!(J@RzW%TO_4n5w8*eLuzYd1_==kRoH5>o>;aAgv-tkd>~A4)JsZn!OJQ-z{P9e%ywQGleD=if6!EI)j~MM$hf+y< zC}m=?Ww9M~dui#}NanIU5mb$rPP#pzp+D)gm;Uk3rT^-*pMkEfzND!7NBuD2RZq<8 zl4U*lReVT}OWNzi(3Y3nzn}XT)_?nP*)$;Karx!{F&CEP0G?f5jm+l-m05-H@(bsKZr{$tzkzZoLl>N6oZJQ6SZ4P+oU%U{0}t+w z&WibR=WCBXkbmttx7DWao;aVBDTK~bat`PN@^9w>!4YY zlLD?RtN(i^_(|~eM zPdNP_LP}b#@63eCQwzr_q@D!T=2}w@v)$T?#OIwsrc8HB)bN~;`pos+(dA0 zLFRC*ED5!$GXxbeWS`j3-`@&#Z!9?$knG>v{kwnu^NDEdC!D>%zx}5;>~#BY75(TV zN?z3G7?=wN75VOu&w8Ey>G*8vpG&Lyr15(&9!%c@_*49JdVoWLFN=du_UWf3Yn_O6 zps(NB9r7KJpTJItuL4DDA@ozbch&jH(uuhHufFKu+fqFfH1&kG^JAok-4Swde>!YG zm;NuaG2j;TNH3b5j9~Hpp%+h_U;g4r=_0m#g0ZVFi9NFSPp*p}fBj8O*~w2r2NrYn z>u*2G<6{r{r6zUHT}p-a&>g}5n>jmCKPE3IIrO*{U0(VSTU6P@PFpM=bnpY|;D<@H zHcRh#iYwp0B0~J2mig5YyD|jh1eNh$IAm^U=0^d-M#1T(QZ%_Ed8} z8u|7a(Ex-n;C}V*AMM)N8-iT{fiEu|DnkEh=}?(joFQphtW7wkx^fs?Y12)3X#T*v zAYVTbR3U`&<6EE$DHqCze-#&g16j#V#{d4`;?MuR^#AF8jE6#~7eegsN^JXGGJ)UE z#FUJMdi8A7>mGHUtS)O!Nq_st-=E1gRzlK1DU_cY*%Q;ank9KfH4c9RNpSNO%>9!| zoiu;@BmdADx4V5%R=VTP#Yi2pzY9Y6ed*?`GgK$&?_WBd%i76DF+IQQK8%)rm$Rh? zA5NfZpgmermYd_)94XPg)_>mR5B^9pYj+mrAAT9{uyp4QR zPZ&(zN3(Z8^%45=Qdh{%tFOfW{T)PTH9fDE92EvXDY?O~T|vIxW%)R2I^w~nPu0(V z3$a}67kfiCE0q+n4C1XdExP~P*I~tD-^W_CLHOfW1SG)4EDI-c{#~!tKQ;3M%mz3h zXIM2DuiWTQ+Bfa)c&T6&A7mMWgKcmP6m6#s*0bi$(0Jfnpd>5Dq+PV;Js6&TMS5Yp zyMJF=wO7qk^cp_-&wr444Bm0>0>3oVLI8NTh!^GMJ!4u^@Y9K|~L_{T>L5vhPCx_d(lCd+De*7+noJKjE|tJ0l@Ls5btw z^y_cF6{an%Fd%W*36?J?+rhJEa!{A;qw$jyaiIP9Yuh^!-RrQ^VqS4Jx%v=FHLxQ(M9i@bOLpMTm;M;9R7eWkJu%Equrw=e+5vz3 zrz^R83@ z@f29mqSRc-d3dD3YC&$ifPpGfuk`O6YXA8sDs>ae9=Ug-f|+L6M6W<9HZm%?sT;?8 zVh`8;`vOcAVkWLdKLxWH%d`K#M}ol|cKSky8%v%eCkIf!mc%hLT>4!%_50FbXq&R4 z>+j287SSyq4rGh+Rnd+#63Q=JJX5csAUU|`Xp^dL`!oPaQceQOID z=42o=LK#(ny^F|(c9nX)1+5a$I=?2itTHY?X)jX^ z_(y!`kUVr4K4gyfwIYRW&1h`wtjIHRuiyRZ%2?vi1mW4Jo2~|+`X(RH4CcaJJh(&5 zcK-!J3ho545~`=-IY*4N27kCSwXA5ylH9SvHjW7X)Q24vT+nLm>OE?}*A;N6$WBVf zgMRj*9Pmzk2zN1XdlEcC6C+(vnv1c{E{r%|T^7kJ>1%p;A zqtVqxXQZDM@3u!roxXhfZ*up88uffxrjqU zY)9$B(T4N(9rURuGY9VEm{hPa?Cie*Cz`CME&Xk2?UhutoUJB1Wfe2{|D~r(YeHB2 z=h7;nAQibM{qqq1_e8q7k9&7ZYI0N;e^QQIDM$O{G)aS`z4A1f?r-$+k+=$7w%eZ! zMOlP@^wcAzF{u3{XYo`_q7;T?nDmko+km2!>tBU3i|e#qcP?C&bk*s{Qt)w{gm4#f z+EvKW|ReXV1n-S;{Ab^~=uiMIBDZQRIf&fCoRKZ#SSMHcVXT}Vuj|?>f zzVhi9BxIY*OPU$07WE0zX+Kx)U(KS$-&$kRgVoK;6OMj>Wio0Et@gz?8%L)NJ%v$} z9E4$1sZtu3{*T95&4!zF^(X#|nz@PIu=KOgotFd)bLUX{ zWk5-=Gug)25ka;>8;uDMdc5G{9+eoi@@f6u3-3`(aPq_$XHF3%CEnfs1!R)j4yy=T#Xr`B-%edQyrquIAIZ;HgP?c znU(J7Y$j?bSiWD?K|B1-bd5wF#JY4vB|J|BRey?(MCtN<{$b}QG=d7Q)&VE6I2GX3 zUX#C`+vpq_%qE(YkvWQ%&)Slb2f8)jjaMM1{bXh8VW8dWr6cEtw&Iur3V6F&j=%q7 zY0bWQ6y9E1TlG$;6WQditG|(h!txFxKA%uQ%=GN!w}`-{hV|sgY^5jE&C~&hQb&4} zY>;yZuI&QvNSBGkHM|8&2rGLU%<1(Q#^P?M#&>#`fTmgogV*7DsYQ;S{ zw_4rPA2pQp>)$Nzk(a#KRyTO;zx0$+m8*@qg=qQ5*aFCVk*U}HQcs(1>0Un5MlWsC za1K(S;J*#}9dUgA?M6szk;C&!Yi`R+pJIMKSkaLB9cv=7K!5t@(m$Mj>J2Ap>=UQq zU0@LF-#;xciCy>Ol;lsQ6;(c%7V9bz&tEf-FWHc-Cl||0*UL*!v=;A2u>}hw4}=S4 zyB!Hy@TUK5dy3hY5C7R#KxGsLYoMZE!&SI=Hd4W~%k$6ubfo{>Q9;ezYE88B^{U+) zh59G!r*(PGN1olV^XTw#%^1|Fc&POP*$rv1I*js=_DszCNDO00^#tGGV0f&ub4Lvf z`PZwiSPz+K1!AQXkxV49atKQ)UJLTzcLIV_f42L_AfJdApfUB$XGu^&O(VjP!bblRP4Ts`0wZIETj7zgE&xu`?<+#3bBDqvU)*gAHTK{S3L+3QVy%f7>H)&I57}G6TEsm9w%@Dtxqk@8X%~>#H6ZpvWy7k+{`G_U@PTn{S-Z<269QtpBK~IX8bA6H)KgF{R*S$IG_Bvu9TCD#~hlJ_Be$-DZ z2O{fT*LCpAL_C#bKRUF4>= zNTbmi(9UTGED>GlhJ~i&fR;_?r4?M7C4SX^!#&lDHOC~~H8ZV8We1>MgqMDlum4Ej zI=62HL$!@L4LtQ4&^$la)cg-aXR0v>vN|{EHiK(>S+r$__@lREWttMRC&+04Qwa7& znaq!`b|KCG5CBkq!WHR_pSay!CNEJbkoJ_0KJK1s-}%mOxnnNWu?iaNNG5cUJAx~8 zZkg*R5k>%%B2IvR=q;xhzii)bUI@S#IDg8+x$A7^k5-ehMhaKxHfr*?bNK-hb>%lC zV_24?ck&}YP%#`c8%FTCx|CNBug2N~Ce?N+!2CWQ{H|Udbvo8qdOSE9J-fUUB2WL> zV0gOnT!Ie`+rzsRGXoAyNfhs0l*ZT7Uv;%X}pnRM^}eJSU(eg{7xi%p<~D_=Z+x9i>r|~Ot+Wl)QJZ`=5HI>!fe$4 z5rp~gCG!OgdfIZg+<^iH3K z?cu2;0->q23w+rN!WarnzW7Ik+_{Z!(#NIw3qRzt5=&XJmF<9X5gWUq6WVA|~nQ+~aCv;m0A5TesmQlt_oUNr?E{+K;9M znQ;Fjytf=_OobEplSO0R0o{d6=8j0>u8UUB0ptRGI>HNZ?ES4DhPa2l~`MiP3b zKVGV)M4Arf-}!`Cpzd$r2UnMW?fy1%e4SYRW6*&*qtKAaaujNy>a62pK1Liwx?#rd~N@3W7fUDaul42nD)WXEg6juV<#j9fw{A$U+0*!I$&&8DZ% z+UWb~^X8{Wiw8`W61nk@lMsJ&aakhSozDPg%U_IvafsjLVScLqq-5&d}1PVWq{GikIOnNF8XZ@JDuvoq0>u| zaY@e?^%$abtVAErfyj7r(Qif6)7ao5Mufeqzr0Eky7Lz5>s>nPQpU~9D)O+D22}IH|W(@b<=D0O|4#iTX)^J zRc~@$p!*TpKC?ag08$G5d8$t3pCLNj_h{R;Z8O_8#LFd>U^2+cLT;Sis59IMgc#y( zFiXbaEW*OW6m1$W-lqZ7t*c-hB2JMsJca?DG926>9Flyk+_+Iy@>LmC^0=Y=-MJ32 zVDEajIYvoQi~m&H{vZ*iP$yL}u@^GdY@VSXwz1F^mb=)_)#6XZI(y>1xnrL%cX3cw zPMz|`Xhk8QZug7UmgKDJs2MXBRRqAR$n69QQHctdyFqXGZ`B>GHFFW`+``>8iK69! zT9ZN}2mkCVTDC*1SN00evv?@h3VO$h9kF(1((NlFF*{J+!>5R)AU4g~BvadqB7`d6 zg_e3m2t~WnyuF0JX7H;>c4x}MWXFgAYB`jb18w_Lmqc7R!qILA-w014#^m;t$^#V0%hpp!)f4GGuKyD_ul?q+|G7-&~7aK{v^H@!N zm35L3E=EtG-{~}ZL~}KWGbQKYM>=j+MCVa5*HFkAOeSrI{zeGb?MV+w>r5cpmM; z&p}6>L;e)WKwpt|Q39Ns1#zaWOhf`MudZ<?!!3gI(nvTU~M6JVkzjIo6tk%x2~{Mr2r;*TqLhrwUP)fvsI-+S`Q8N#kWT=hf}0AN=#G={5F+Tdn+X%2nGKV`kLvx+K{ z=xh~5sb%xbRSDHv1A}$cO~cN4aKfFJYNP73u4;O%U9l-t&2gG?QguXwy<&}Y6fa>0 z_n5NjU%RkeQ_bw^$^P)!Z{Q1!y!z9z)B8Lww7D59u#T23RAtE3Yh%Q&rIhz&|I;zp|3a7j7b~V&r z$Kf#ED+;ZHJDN;bM0es^m{Ntd(a9`o%#yRp+ndi471oFiurLm00T^a-kK@Cz>cPt# zH+GcSI6!`P2QsbF=4-A&ww^@IzEX$ft|mtE)7Wa;(XB4smdwsaEN9_Zd`6vy#)1J4 zWap}Z1sq#=w`hQYGD3wgf- ziiAPRbg+ERRe#Rec2*H`UR9jlvTL884K}ybV{=7}UJqwCC>^Lfqc3K$gE1^ugG%J+ zMb&i{rF>W*AYfClXnmD+=|&*M#{9|krdQhs&x7IzEt^N zM^F)Xo!TwnzWs7dh^w)9?G=x#5ge{Ad0(C(f*NeGgOiwEn{oNAU=Hq^s{4b$|A3wU zum`0UrZ8O^8~;z=78dQTo?!a#$nJb91}{?87^e>Kkk>3qEp4d!8T zfb3ygRTnSWTzvJ6wo}dh;VC?x%)_%tef0GO2OoZmC+lgx^Z{`{>9<^s1!wDK4UBKJ zipS5{j`o*z)2;VR3}wAxFbBalC6kQeA{%FUeuAN8Vl2zc^cumD-5WgYkvXv$NJjI5 zXcF%R8uwZB>gB$OBrjkEB)50|JFx+F+Rs$+hO!CWk-SQy)x9(1SMoJC2jOYBiVI7o zqKUCF^xhw=#?V%5Rj=RNYnJXo*p}E1V_2B`*Fy>-8Ao|5xb5aJz2dV6Oye|U`Fhqv0loI6##dZ! zKVH1Qw_dN(fBeJ+C8nzgF5ed3L1w(_MAac87%@-@g4yRU$T%i#WUUTqd5M}#n4^yg zLt+rbGOq;ga(;%{=O-@CJaWwPrn@FMRJ~o7qMJ7Mtgpe>0*;R0ryJJIg2SR=zvPUg zyBTcqQH62ncqg8p?fmfBN0l%1MvWDZOzJBD2h1aF;=THT1O=#hdJob%uFl%=u_@ z(+Y_={x!=`2-(;1Buf4PQ2iF5`qq?Jf$kh5&!cYrhtB{sK+C_*Fuwd{03Ce5x^5$Y zlHwx#bh%G*l9(TYmB9(cnJfM(d9;o1?OH24>1A)%GEcb^L>-OrN7I|g&Vw%loVnot zocW0KuE-Vb)DLuI>i0|uNT}Cbrum@9sV|XhMx&y2_Y#afUPWV3-b1N99&c9A6b4Ta zb%{M*!jA$&ILM4)ydYAAbuAJrhBc0#f_`E9F@ z*F@E-!7VFd7+$whk(9wa2gRT4HAMQ|YfR`c8AmVTkJ0QUnDChN; zZAf-46w94D1(+9}eh+-xdQPQ#)`qhjIm6RE9K;0_;U}M=Wx!PZYiim%{;sz7(K!v7 z#`Pdwje)5J}43C_W1Yb@K zMimIKFw0$y3(O&$Ms)!@h#UUsTpMx)nH)$28o_0>Zn!<@_s--YE8vI9nHSM?R)!Yo z5vY}7HB@wWgdY^dgLBE|r$XrV$4M zyyKvG9@j`1mSCQ0*Ws4`!rbl~dHL(`aW}ZY;S^lx(_dNOpXT<18G&qf<36eTbyA=e zu&McRc;qlVZ8*Q}amme{3boL0s*d-q1UY0Bv{)=T5`m9uxwXrOOu=BNnvV7i@%>1+ z(VVL63JsCtDe1a9p2f8G5*uzk?u>R2`z}etS$!4Jpy~Lov&|eLe~JqJpL87eGC`oo z5vUf#8O=yZoG49zk|%_%XKbz!A^;T>dqTI3e=*UO#kdl4q~xZmcMpEu!6G{2p$B^C z)^w3}fH|a)g`g@fj($u;YUug%pTY4&Det4R4Iu^%NHn}AHkolyavJ2g&3>+eYGDm@ z0?q414FBJ?V!Zxuc%o-W#QSqs+RdcXGM+!1#VVQ2v}Nn_<=O#p z;>Msz6d$S&mObaDVpk_!PclIx>?MAp!XRc^LEUY!|8*Qf_HBVBAsxw>jv-I=W+lvmPyT5WWwo9*P_$ubkRN ztH$Z&e)gBni;-f9Mp8sFtkWY#mbk>y=L@l#sT#Nc!PktYTLbMJ6Ru$XDtkwTI<01- zM^+nb)P{|yu1I88R?7m*>xv}FqznThny386Nf@TUQQ*;-=HjFvS(s{}>IL6ZU@{Bn zdE2j?h@1oz6yMD>wH3YYEhc9CIun|q2(ejYl77uM!j%~RVM zXQo<|aW42XP-u8q6{BMh@PeBar#p;a{5!6baE@ahnW|7__~`}RfRP0oJ4ceQ6{JoP z-Y6U32XqS|9lc$C*NG$B*+1sW62Uh%PR;-E-)x95f z;v#^Ys7BOY(6qZavt#PwobA3rXWhCYTlK1Krvl?%`<&pRRj*_sVPKtOB=cTAKg(XO zBy8$z4qyI-p%m?PeQZi0SwXFtxS1ipl}BN`nq5{I&Briej#gu3N{XX6A9YN2^k#vW z4Z(53QFbNp8<>gX)-jzVE92x9i=hsVs|}KubDV^haNUJr?o-a-WzMRc<8p>4F!Rb1 zk;D;2GpCzh(B6^zh1q#MW5cF%40#f+B~GHppi|Nhdg>eoHXNgdNKN2zmR) zp%f4r!IM)+S}8N;By+OhC!SGedz7(v>%^d%&nM`dZJDH$vP@OQu@S+I(?@`$yb~n3 znhFbh@{JwqPQ0GgXs+rQjk7GIdoAsyC3d&hUJM@9HMb4Flzr1I**AioHzm&xtPY#o zHje^?I;`omNG})3;&PtaI1XR8sWfRzO1VV4f$Yv{=F)Oqxk=nmrDoPOnXfmKBj1b4 zYozM$q7u)^2V#XeDWNh32NWKSmQGMOPSbEyGD0+RI7DE%+jwc%`BR@<2);Pq*BGQCQdpXB)52 zSBrR^7WktX|2|?vn$2d`2Q6M~*5a$yZ$gW%P{lV`sKhmW5eAg$Kl(xB7UrK>J+P!mWN>#6wK zwQZwbk;^EQ!FT$-M!RQAX=x(Gtq%+b;cf<_@^G!R|18Tf#><|EITRiBvxZ-~VsPBC zV~rIT#>pPurlgN|0YTeK7W zV%~ud=j1gs!H=IFXk{0tHw%NxGD*|;WOgZ9;;PCbj&t@?v`V5>#X~@(f_WG(P*sI# zDvQ^M&Zwix)bgOY)E3r*^|>|x-}#R>&E2EVty=fXj)YvM2J{8doL%ECIGR5H3?ji{{5 zglUfyD&fs|0LN@e{xm(-H;+qk5GcGWI!h|5xQ+aaLuXG=zGzdKF>xfzJq!%^RAG}h z>&jNup>(Yu@AZazy1`w1$$+O3f%2<|jA_xjC-OQ9^a;&&Jq#>sKFg`OlRSCZ;2bJ6~}r9gL@hi8sidrH@JNI zbTWDTcs@_dm~5hGe}DP_Ta2}r*}1veY<1wX8ufw14?8Oeqc`z!QXBJt7pe#u17WX7 zsNnop!Rvw#iZB*6sOe(CH$xT+O)Ay-Hji<^6-;1ACD{^#$B%cPKHWVyXr$Xf2e^qZ zrxz?XS*}xq% zIaTK#W9Q1*TaeH6AyCVftyBG5et923cyXp?t=`_;g}Jr!ZNBAOYQ9wf<%WSI-{3dc za2pJFMMhWEm-+7M%kY_ZMif1K`pioxOk*ubQR(k6d#c%w!pEwQzhyo$bE&>P$b6Hv zQ6C>?K5FQz&rikH>ZpYIc#2ynsKn6OK| zcT(}nJwio&z(v1ECVO_CxG&Q)s;VF?ge_bp_2d7d1;-oORFhg({`2=nE$E2R$bmw* zFL~srb+8z1hUUaJHR!FgOxrOl_XS4jLvgP&1G5bj61pb`&+Ed`!5kF*68nLWMwj)c zPwSIOIf(#x}lLWBxFfOHkSrma=f3f8FLJ*XjTTRvE z)CCj7)JL~9HL98#cFmpP7WvFG>KwZ?vfzHx34Y^Z$2di(Ku6Xqz2%EO68AA#z!dK= zE$7lx&Azm|9MY+|B~8sdeYIG}Gu>>(I!oAQs^(_K@|BevdpEp`?d;g<9-CPPzk9?K zuN@v*1T?nkBz`#;v{|c2=j(^FaG4@5Ma2(Xk?J5gwQpuH_=Nm#1wEveqn6dto}ZL6x9M^!xfRg0q&QX;76=O*d@g6HP#88sOm1N>bXd(?l=S2X*iC82g)&9nHGo< z##w4FVBo|p{Ualv^MbdK{#g>}Pui|%i<3;_99@d4OGXQct7Qdb7CJJ+!!gEDW~A`0 zWU!F;PRkiiais&y@BrN2O;|h5E9#^xcRI0l!zv~M8;$EQU`|1G47yeC=sLN;VW%1x zaNX2Xci6H9!#jI6f7hYqO_5fhi`hQaQ1l)DX{B16WP`A4=T;!zG-)6q;FTd(EqFy3 zH@qh)oz$z}qVWCGaH)Q)*qz#&h`7P`;Mx&_u^xSxN!})YAB>5DCUf!J=lJqz167@? zke`h>Yp-amjffVpa54OD60O;ggy!;L6R!wYZ{mGj-ZPmsh;4Vx(`cT=pCTH*iC(Fu zb6YG^YPsL~qVKMX+EuUkQ#qr*oKLA=jR0GZo-Cdt|)6bVH+AVD9Z|&UY4_t{;bs$@67|6jZyxVM_-k z!>R3mYO7E0qf5}EJ#!fT8KjH~60ywM@-e3ldvJd)FIEYB{}Am~MmuLvi{?XF{aj4r z@sv=W_}ww`k}IVx*iPiRQ!Qaiv*@F$l&ZiN=@RzXG=@~USm=&_zU2J!oZ?4a0AD5> zgtiFOUAQ}x8fOM#`)f50WOo_ItMO(Qu2hqBYDX*R{@C2%1V-kZF8~=!T;NN)fSH3= ze|k2IJGXAIq;!88jo)*?kccm|(VkNYH`}WSX-g2NMl>X@rO--ZWSJBzX+!fDN-1F1#)@eA zthRZDGE=J-7RpYus)7J|(wB}V@Fkm@f#`=F3}n(=r>qq(?!~dA(XDN_P|FB`-rzih zMxa%@eKo3T5+!#xK9c|UKwVWtA?_78t9^(5624|=fxWdbRCZS~^v|k;BFf1Z=82h>LkJ?NUz4%M;CJ}b#h!x`O z6KNHT*>!fN0d5G z@g!GrBle2Z(m4j0M8GIZUnX4ZHg>g`7%FD6l$BJgfg8;%V~qCixm{bdcME0T8Fa zWa5H3kpR3&r>kUhHkD9{w6)KusFR5Ky8x$}%N0#WhC3cmq7z=`aRhHj=oF%GMW@ku z9IC0=bBLDErj_JHPaEI$+{utGC0pd_mo?rgUsq*WTF9nZPK&F$RJ9U)97jtDk|-t= zX;p*CBtKygWtkP#0W;M(lyV&P@tUCeW4*~~Pf`z?vW?x)o{OzuCn)L(?+bwGpy5>d zdlo*k{aNO)sKe~LfBxr!2*Dg2c#+i8Xm(l`oQjGS3*2Vz<@H-Eb#gINyr(FWB*K9^ zal-avf0G0HZ?zz9L=8m*VTYsB`5KK*T2l&3iP(bZ4oo^zNwDMC8|p111GS~>g_DGi!2Yr^pbbw$W6J=6av<)+})$+Ahc)a%i6z z7nx`ASPOE;=3qNEp!*+`>HN=QIKM^@b`6H}`>VeGIij|W595-)HhETBkT& ziweP;rEoa=v?NxJcNKfN7iVuHX#r^mKq}4>4!4CzO<_+WICOiY!o z<(jT$k`H9Rd-1C|LXBKxxtCX%Yod>pTeK^0nJKd%MMD7boGU3Q;H(HZ&?oT(BGx1t zQ%%#w1^5_%FX7q?6@F$Oz9;&-AtA!Xq5(-h2~#?)VQ`fyUO;8nqq=h%Rv_nf@ZF@N z>&Qn=;BrmEBO&=JoHc@Duqx8yF;am>fO6dk5|YOtU8^P}30h{4muuxD zY1;EsWb4Sn+kUHh6Cz%G9;Z=uo?_yVeQOjknfHqKDtgT!+;%flxQ=eXYw00UOyt|a z-H$-R2B0h6R9iL{{_oA(o4DB*_wad?rUB-dmk*<`N*^ zhs6_ZBa;1Ktw##K+@FQ>Wi%-)Ky9}ArBzElQKe41v{K2ZN3$f{`mNtB{N}&3Udt*M z={G3uoW@^9XAeIv^R2I&|V}Y4uZ*9MIwE3f0|;wqpx;e3%3 zz#vI(&!22gNgj1WFlH*`C_%o)6(~)u{LFQ}*Py>*wAUVHA)!%W4*uGbxs>huwyb!V zS>wfw$i8>B6qbN}+x8OLnY6Uj6F!yJrQd%~=v2M3748d81MD5Jy%-mHP(%i@sLWcD zw6cARn#Q#|PQKmp)1a|V*1%Ju_KQS}gi{!JAPZdSIZ;xn7!A$v06ze;6gc-0JZ}=N zu7=Ax(e|!|C#CaUxpjzinQd0M;BUg%FIiJ95kL6qoyaiX!4fSdhB0Lh4T?BVKj`TQ zg>Y}ziRv=fx)I43tvJl;ma_ms!qG?3Wr%$7t&{)Cs+0ncs8)&$%o&gckHT~f84xm` zq@yxwY@?;m1D0Cb4plDjwR+~~T5ROM;dq;zpniFqZ>I3OL}J)l{F>52 z!A0-GRx1~+n!5TYHGbUh;pe~n3m+l(r-rVm5D zo-4W%;ER*eBO}1jwVTVB6hXTcl zn|V27c*M<%gWnrlOhUe^lsQ=deSK&CWVZLVjZ2m4DSVtf_hHD??k3I82W3S5=IX5%;ytK~8FWKuVUfxnsy$p}k zyNYzUEkL1yuCh57OznA>^6B3R&|QPW6W-@aLs zkQBF15uKDEE0YMh6v3gXj33Sbm@Ywm7k({LrN;6hT*zQyC6a?j!DO>IMGb45(i_P~ zDdED5A8t7g+KU)3OSREw<#%ieHW;0;NrkLGv0gTR9teY2a2UKfD#IZURAFF-)+kwT zdj?#w;Q3WFZU2RZwBsvSzZ_i6U^8UfUrikNrlh%rG;bPkD|fy7k$-Fsk%R3T-ejtZ z!vDzO8?pr^2oLJS-2ALb`E`a6xZMjkT{wW8QL$643>T6M4wg#X53%$ytp6hpQpX%J z`+F!Xk>&gA`}CR}vZI;pGPCLrO_g7%MrPCcanoe|xZ#4RF7%!+Fl7^a;oW6_Qh_5T z?Kbi{Hzv#A82)+}CE0sCZ^*LcbED?BTSl!AaW?x^-YQCuJP#L(7b;te-*(l^R>$pV z{uCfljA}(O(mzQWnpVb+1F*THi*m*n4V%KQA4KVR6)$1qA-#(s$6mu(-vSGYJTMDr znFG@t`;szG;rOL6Sz`MyoIG-`S5wDh$oJQThTJWJ)JI}DVXp;M7Qu`yqu9aS3L=t( zQJGIz*fMkb+DuV8VWbiZP;R8ALc1wsVEXDsysoe{Z}lH$(5SW{qtiWSFY*hT{8($r zXqW;oe9hh*;=h~?t-3`0t{l99lz->=4fow>02wNL^SbJrqwgohzPJ16tHsWut$B?t z`QF`+YB-#%Fe`n6czMBixKvISwZ$C&Ol~p5nZgWPyKfeJc6K#`VVb&%TbAU#S5EmN z@zxkT`7U&NGVtcVeHTIQNzKsUB`y_XDrJWa1N_2VIvYLM{+G0hwMc3%LOf^{6bs+&da&qE2 zlh*02h%YF5?cLQn9}2Oc%)DhDF0)WUQ&oKdR9MpMRTnjjo%MgXdf5xi;I474?~b={ zr~7E6R2ZxU$SJ0ZFd~BtTkDs)nELmFs<>U)t)IOG_P=?%JzL#fk6eB4uA|ZW-)=}27eyra^sHlZ7 zXtPVB{^fSqsS8>mB}%h1<2H9g36UV-i8-T|z9f>w-Le}?Sx=TVzluk6y%x_UxnM3a zl}O}woKU9fw2}`uywfnNsc~qC&L33GB@IF(&3ugtG?$ld6+clRzUo|o%H%gsc(_!~ z%1EJuUrJx1XHw57E8~N8h_IsWuhh%W;(YM4<33zqs{w;l8TP$nkHBPh4i{|%fdKdr z9BNJFBx*g!pR2)Dly$;NVZw>Nk^TFliOQp!H77GJ0D^n7GzkzEB89gfd_L9X!LcCO z@#$uU%+Jx}m{al|>oFX|t6*((FiUAYlWbu;3)58eJuAsdXf7a9Js^|tXJ@VrvQ9oH_*6^ z#F?rvU%(&UHNg%uH314#q|VZ0v8S-Gpe(~`*TV}Mvxg=P1$gI-68@=TZ#jsNG}L@l zAR9ZWN=412rtriK1E}ii$#TRze#(CSL&wwOjcU@OSick#>rE36bH#WHO6Tbx&3s&G@>Rl(@IvrvjiEV5&Xi|ErHYb9n?#;(Y|q1dY^v(Vaa~`=3z;7_ef3; zqV;-qWs@#Qn4asGdO%K_@bkERDAyuz?mesp>Q|c)^*mbLReV6QFeGKq7;qv}t=@f- z4@|d}*^27*-Kwpb^P!cPaQZHOp+VsHCR^6-STo$h4%^r0kU0y7%-9*2MvB0!DJMW! zaez~EhVF5%(6Q^*^T7S8*%nXs8|G>!xpj^__Db=*s28wC0D(LqmSx3I)2ioTEu(Np zu(jV@+f|R>hqExLtn|b4*ijG_I%^(aA@>&x}^V9NLf;rJ+jmYuLr5*B#l-C+@*^?G#8GF zphmKk{ixfM924B5UYaPhQZVry&UYRVz0&H99A4(f@^70sS`&h1hh$kN7yZ46!b_VE z%p0HGEKaz9fWfVYotfm7)6`k3uG3G^yd6KzFF6j{k*~m$P-7F+T4t_x*p{*C5M>B~B!1*-ldVEN+F;8{U zJ%cB?3m-18XH^wc75vlhN+Xw}qNH@N5&t)I>YQ4F~O;O}a{ z(u9QcPlIRmmQGUS1m$UDQZ(qjj05a$#W3IA{#C8qcCRh%p;Rqi8yfI9BGmh_+2~dM z2mu_AAzrJ6=Ed0c@9@?-qIxc_x#_hgi9)y!HNYPO^yOXbsV{f!-u>r)7C7TUHmG;s zN5fW16IC^a3M4*{aa}**kO3#+3_?@lhHTw+gJ0}5XsFcAZCQ^6XaG29{&=JC60tOC z3vI1c#iXERZwrN5Ci9xT4R+G6F>L1H$4bkElg7%bzw;HHB7jJKq82hIM(Zc@c{D*@ zwaO_HNjXb#S_|f0E*nGiz=fOLf5$?7k2>15B&@Qou}vhvcawAEt#j1&x|wN-ZXqe{ zFIN)K^dej?p~85Xh;gA?Ucd86Zgdtd3LF+_ZCvYvq8H?BFBAy_p zr%pc*1k(t5K>MaN=eBOA5*iCc&aIf~K&zs3I72Kc$a>h|uB-O9^jx0I@jfW=y>v;3 z%S*t8No$x%8N{dVNzu!T7(vgtCM*~l&0eX|v$k`_u&PEuik~O;XGlA^#j@iGKS|g( zY($A$NTXkYq7dh2Ud|AOVjM0NFTuMYJRuO$kws14b~Z^^!<$>~u(zdBn#A*8kN|Mk zS%4Y?g^yP=o zT<**N_CM(-e3S0J9GB1aFgYNk_xtoaarQ<<^@aes87$L!L_M<4dP7hjs%Xt@3A~er zFtp;(u<`tWwseL5WxEv^9QO^G@I#IObrwr$?OVAHc~vS99^pDMwk_| zvji2UKih`)XcjM@EMCk)Bm~V2uWW2i=H4wsF{k8DZw#nv4kXzr%>}F}b>w=l=1I*9 zwRsEHv1kj~b=q-yM;@dy47OA}*M*-4%a*gnt7Umwn*bOU2>9lNq~N$Ljhx%JO0i}} zaMvF~h0ie*-P0tS&c-Hallw{SEBTf?I914GPfC$j-Sd;|ww8Cx+PB4G4J=JU6+-o7n~#Tr15@`Jb?1aH`;uMN2OKynIE|y3gf2P`kHuCr zI6gVv3m$$X9CbgR9J5%VO5(hU&lbr_80;b}pkW_uNR(dRzE=x=Hfde%-Sv;wdzn)e z`3;Hpy#4dtyT#^4p_`lU#QovkiG{h?o+s7@CzO*_w|GOZxT@95QBr;}@ z`NFX~a7Qaye2}Y$Z<>MOx{bF9vrg`dld8^v9%jAdPjc6YyJf@06{Qnt52>3nql8#e zFix8VDLMJW3Dvjjv?hMc{xa4I0CS|9;_c_g{gVqO_@UXkQ4RO699_X@+}SvZe!K|*UmQI}cRaast|2-V5O zj31X_X013lX-UePavGJTKVa#(P&#EdBC(U7`3inC2Rqhmz;+d4l29TyQ>62-2EQEN z(N@=i6_pG?C#sj>CP&@;rOTQ}BHmmmP1)X7x!zW#@s8bdoEHG+u6pe)+Qh8JE%_{7r@w>nj9w z#0WlHFs7$w)~}VHMndP-70d^bHMa!)R0a$?5@V31r0`UNdce$J209?o2-D!z%YEfz zbP@rt)8#Bi{1$B}z$?sp#s|?1rzq=Q-rnRC+lx%OC&CPHacnR##?vv>YEB?LJnOmO z`L`9Z;Hu`^n@2^gCmTUJQFQnQrs~+ups>KZt#W*?MY6`fFB(@ z1bKgCHFBJT+oa!i)gm`?E2NXDr?^n4+BWv`QDh1saX*yP;7VIoWN@*(Y&ofL_O576eHJgvjzb+kH3 z(rBmffHb8mJPw0%HDcmF?z1=8onVx60(6{mL8(=eT(scc2`c&zXgQY+Raes;E@A1! zBRE`v%pfE&4zQDm?Vz+P0}VByeR?9=Qe$S!EjDtk>@}QAx20aG0#u#Am9 zp{<&WZlJ+54T;joZKmcGq4jFhZ`x=D77t}@qPHrjyD1hv-ciiUX-Zo-v!d^d9Aoq=MR zy3AxW;#36-%nU}e>In6GM>X)K>G+Y!r_!DSXMEZ$_O9db#wsY)h>{~4Jjv8_r?93~ z&D^!v+kMn7zP56%#zBPSu;@9FU7NE7Ug%BdEZ3=<`ydHL;WuWH&dnqpFgztM?+NEgJ* zOR2R){g!j^Z|oeZd-vNb9}GwALLW;$FI;|w*N-iO;V5ewj5%DiB%QDpyt`hwa3O~{ z9}YAsI>bN?$q)lSm8Dr@Kfqq$v8r-rN7A5+vTkU0&8}AbG}=PmojlqqyzQ>E-B3Rv zeJD_4Ao_?9k6}t8RgpclBMelWQ&%JbR6>6YV4?DwK^Y^uJO_{oPKmaG`U1K6?$eS(n#O5e3iX0F!JCF+;AX1_<;Hki((8|5AdyW^{@JD^!LJ?tG z&Z-Azsl#f`U0nVd?rBsixs*2z`Q++LUV9aPsM!22j__Gga$!Zihc$fFKZ}LQ@Fk^c zRr>l)>vT}QN?8s!x2#p6yqWP8Uq3(F_~tex!Y#jksm!_gSoE%z)rX9%de4_t@A<~| z_XWJ-FQH(b2G5^84E7(sez;#ElBt5QwPvldk;%Nl-8OTBQR1J0`}57wT`vXfp@}wF zl^>sT2;buMO71Z#WN^NfQ`BTCw{>MI>pOl+18rA%!XZs$BZTehRqohM=zQdk-w6(% zKX|?y{QB_Wi{Qz#;Nb7i?gzg;IebjV$|`2phDJJ0(~Knlm>?Ie9!DxuOSjFf>0B<0 z&AXE%0aJc_dl?d|GP(2i=F@g7=#A^GMypkCbb9r6qtmH3di4(dNB`eyjCw({-fc8{ zjc&cy=mjl)+r>XEl)^&~U-0*!O<#g;V-&Q4{&}n0==a9WpwaH(|K)$JfL^qy@g`p4 z&;1U)Y&TJ}M?dK?=r{0ZEWHQPd!Tx!|7e_zVK3-3hUhd3WFLDAnL78^JdVZDKdC8bUfe;7&g>&zo&uodN|%P zz&3SEFrq5-kzSv-=>4a+H+SwjOVS#kY?C@}42M*K`sp;9BdSP4@4p^3+Fcs&U{nVj zY0_PqNSDUes1xC4H+6Oae>b4dRVoyqZU1t0qJ`umbET zOXiJs>3VxJUO)?*tmu>sV#1(ZIlsnJ5(xa6bb<~cMC-go>r5MW+IrpjeNIE>Rewyw zX$9SBt9{;TKJNcM?*wf^9m3_d1E$U5x-CEMd~(`;O)J<97#kmt+$MEC95boSk`L|) zN3~i(+fy?csg&2`;&g)~iLg0h7@+JdA(08wPj^+5g##tR-UAY~J2N2E2wQV_pB9F8 zG41*m)~GuOhyc;=#~{RA5Cr;6A3=EOEa>fb8r?oOg2Q3}f{H4A!YlsMd)*q1K@*4= z1?@nf00II`uj5_4P54KL5j8&~3IT#b#H9;L(H?wy+HU~Ur=Z5|Sz}1e3?9>&)1_xB zNd*XlMz4o}ZL9T|Ks&@?F#^ty&O48Xvu;5Dt9S9D=VCd5rFaGB01Obj-L`PKNBy?~ z{zvV_5}@>4ptQ3}YS&XK_HWz03FhbU?@WjGz|~d*C3&$trmtE#Ad*maF|!fsaI5qB;?* z5&hF9>e?I5Xuo4!3B>}1YO>6D`x;BgEDBY?|A3&qU@zAEW_)TNP3rN)o&+)rAqkaPJt4l9i0sf)?nlrF$ z^xqhKK$rP2K#IP3b2{0imo3cV45s#r6qimk6@G?cbEVa;wTO+sc{fuc9fz~1(rgU) zo1AIE_#=I3(&;e1qz9T|kDgcb*g>I?Br7D$(5(a{2d(0h%{qd#tb4^5ss*bCdc~$~ z5&fQQ&`v8wgV8by*Y}gnVtogP601>TF7-aTgsDf0Vf@sh7ZMQ-KS2wA>h$?9MzfP0 z4!x3T(8C%3=PZ2qK4e&RG|)09H_^;d8w=GOb+d?^YQ!`6W)PN`4Pu8|gc;3I|7+`Y z=_L8;ir;A=+F!d6kfM1RK$zNSHvwMs%?pwQb^uTp>SLAqSwoqKYJKt=?Duz!^d45d?e0way$eJsX7OOWHwOravrVD;>Fnx zD_C%mwrl4ydxx(X%0~wnWWd%w_yO?M0a!Sk1}uZozk@)R`ScV5#PD&ebw=ygyTw+8|Ja7XEqNZjx9~$E;>_y0vk{`H&ok2w(Fq*{qSfJ3AamtJGkBMzS(7 zBTbTPnk3P-@3;8;$5z9J8<3pD>@e+x?l5p3TJ5xpr&iPae_g$(x0+-87(k}&v}lln zHjyj(Ne5z=IDiq>g4mn^9RxJDK?{Y)kYM|u(j5$qAVSj`Vy=)R8<=%-xKCueJqSiK zW>NBL@3i`BY|U1XqG_gc5l|fvi6}rY4(XB{PeWl0^}j!kJ{iO+I5Il zfKVSS6@hG@cxJ5SbVPMO&FMqX0={%dGs5)-v_XSD@gnWseK7kpa~cpstl#1XEE%mH zL1<7H%?T*aQ@!NW;fOjKKuts(&j9!V&a*QLq;f!&sV=L98lY?3H)9B29 zFsuWJ01cECz~z2!-QI;WraCUWz=r|z3;e{~LZhA04AGp42PQJuEh6ykD+zo*L*S=a z&cQx!D#A}1Z4bCX3)W=rtPPf}m&yZ}*nnwKmpNK_z`OheSIKOaqpQ7K@2%Io`n{e= z9rzzhJ3S~J!Nk$afP~zl+4eHC9cCsw9lq{O>qFYav~B4Dha$b{yzWdPW_RenAqjJz zo-$Ry*+~#+)(85L*iSCV$6(z)m%R4~I-+N0HYZS@K;2~trVad*awJP*{_iT@v{(-!Yt9R$a| zS*+hJk!32Ut7&3wI#?Sz7KWgqMAk_L$t@WXn-M|!b(dh)nd0D_f-QmetV4Akcj&0R zQi|{9kO;K*KG73&&L@KCu$tgr+GEBg76=FiK`X8E1JH`FO<|ozv^sMZg8?)|ym*OsdFwdplD?=H0|;a$fRTFwuzH~!WMrrdXO>8$nheF$(;gR zX?3r}ghFn$56u^=X>vmAli^vrbihH=)9nuFHFgPY zw+=9-(;cuj8|PD#4=J3{)DZ)+-^V2gt!NWar+MzBy0Vn?UmH_scR(;&JO@6SS~=}L?yVQ$d3**_s*}qA z^o=F(NtC`{C(GUJ9Wb4~S2L7!>^&Yb--L6Q50b%E=QC5~E}iY&X^Z$Rf25OSobKAI zY5g`%5%Jm|BM~fI6A-o!?g43rf&44V?Jnd;rWGN9u8aTV3u76f^nF775gqI85#e)F zxEzSUEE>_q>yd=ef&I5q&yrj14L^>o2}iY-asRJeKW!~ z7OO4yiyif^e4}G{j{NQ*&oa3pNVG;oXhHtE1f0PLq(-PfcMuYrHUI-4f23*; zLT(c`y?y52`uYxMC<1K1mjxk_D)jX`ZIce$4)ojDm@U>Nj7B&an{t#7Kw{gi0e@-Z z{1^^;@~ZB9=EJVbtl((C*Y7>`$e&ZxlE=V#4HZX+IxXvakn6iYaQYq;^xe08_lx^h zud{@OqsZoDP!a;q+fCe=4rkC{;L4PkMy6;(VT!xXuR8I=uUU~uC>)F)XLO+Y9yG_& zjz}zd-FZAZCw_D`2vWhKy_;1JbOBA=w3gtR0lR?qbCrOWSuYQGcNhAh|YiAA4i&bfUx3=C{ArJ~fuU}ieRru*F! z@_Cvv_1s1gd!nJ32oepS@uqbKFFn+C7pnVuYhP9Fed4K&FsXAh0ZipFy=Q$7)!><$ zPgGPs;-Z*YL55O)X2I50knE!$UWb_hgMxqGt_VRA>oCpTA;)BfrE4S-?Ujai6&hm}% zK%n98%f_gz=pTg4Fw&`jh5W_ zkM_an%^)iht42QwPJL+EhnR57)vld}=Lz!hU1o|Kjm@+LZIV|X~> zah27@{Z1DOI9wZch)fK+O#HeK7O_@*qk_woCQxd~nl)maI^g1Z_%ni5u!HLjZm!LZ zkI}|}H7NuU63>Uc&2YoAug6$08Ip`vlW3Jk0WlT9*y?I*bvw2ultDZ;n2YMU=!xlZ zIl~I{u!4eN%`D`I5$bEu8Q3Y{sb=-`WstZW6=*}F%GMYB|Mv$CXrHVL(EjAkfOF*>0?x_Em zNI)@*8wp&|4aCNz=>b2UMP(PV#6ucW1OJ@q21bF+=Zw65+{#`}Xx{TF!4O*T0Uu~B zI>a(V@VoBg=I%T6OWn+gVwCW;FnXWm5w7XpIr-hg&hpBur(y1N#VxF7>L~rbOP0|h z$AR{B`R_UiW>nh7z@h04X0@5;)FiNSJs*MD$g!R+*Z{sBS zVF)xRbO8%++IxHnM?*!w?%q3#PqTbq6Xrd*dF?Rg-tP`^MGtK+E?fGLrH4Z(fChte zs8(jIe`h-hXo*M+p)-6;V)YQpanaW`yLISyx}q2Df-=LtfmrUounjo)S+++}eU0Oe ziij#niCtVWvITvIHZp;Z1U>cTG0n8A-aqaZ^NlkS%r@+u#&e$~C;1BrAUICbLH;y_ zg&~o6kiO=9b%OH$o99;Bo~+Uo^FkfQ<;JK7YlXJH|}th@;7nT-_Jh3KuBYL#@Cd z$yA{cON)KB>V);ws8e@wrH^$bsf*Q}{eFWld(e4T544V^Rp(v3)Gz?=3xcqL42_ET zP3|4{2>pPK7&^Z3{@E&?yh}f9!W_4YZAzPTcn-?|(Cz*?;b{N&r$rwglVn5(ObhQ} zx$l?nWL{HghlpVWAqOSR@eiHz5fRxAs2Z)ltKiRC#vS&L>mLSJ$R{fZjU|W9rEiNXP z^Dtv{4H;^{YSICW-SFQO6clDxJ-#FBp5rInw0f}3?XW!$1TFbXvJ5PD<(8@)QrSNK zQ(DlbHIZ;Fy$8G_nk+YHJBom9d$~ z!x(p8ggEtvy8zFpKt~48b+1ln!hF*rR zhmSp@qiHgaaxw_8r$6nUGnx&j9X9agl_h$ZvG8U03Ppq8tq>VDD?>vy3#?-N0%COC zpM(@$aQf;e383!RA<0qS#RgAZkP?+=86TUbXB-nX z;3v*3-aDiJPFu$=42Jy;D)gd;Z@#WpG9w|Y+Bkw|lZC-M`IG|%&OBJW&9JBM~@&HOSf zF!+5NM&tw@5-s|;hGP?SI&s0%9`HNyEAQf)6v0m}B#(nnMKD8h&H6Hl7aSwZqLJLM zO_Fu$0F!@at@?ZLPVZpZKESA~$M)g_*dl=$!2bhz=+{=uz8hi@fD`!p|D z*iT{9@S6JSJ%(e}d56u@O%2?Rj8p}*NDWF27)d>DHD3=J!+lsAf+oAAp**L8(-um9 z0CC}o^g2VCApZwTowmIFo&CbNeS~s&je&yhbr{OBZF}xB4;Q}LFvZ1QX|tkoh@cR( zTJX%pa-mOPq+f1`?1CQ0LoknZK_QHeL9p~~mZ-hMD z;xY?i=6vu;1bZkgdhGd1V&6#gV&=+E%_D~2&Ki9>E}KmV+ReT&>G0_3_Ho<6X0^>G+de|g)Py}Ke0bU&+!b;pmkwBQ zmSCHrVr8KKQYmb1S?|&twb_b{PZl=kVHaIG$l1E5%T~+19$PK#ntJI z{=vGm(;*CPNfu`Nwq6g{IV~#Ef>&?92cz0Hd-}rpY0&BO{gv2_jY8O*L9d2?wJ_X< zF#(KMnWbji*EUbD*MsB&QKZY-rXibxwnuzx2+Pk-osDhzaSEd~@cVRrh#T9mgFW0j zhxIC`Xsb^vOE1`6rr+iF9c+PC3zyC9E{W}Q@Ap+Kv{cn8B{ zHoM2h(r7o>igvv+wCfqP8(Fl2Bs6S}*w1dnh}V{9jd}PN`tTlhL$e) zX5A4n&20WijPHQpH5!C4LC0Rlzf!m@{_?#pJI4*!6jYS+P;0SU0WLNOA=<3fZFks4 zugxagyqMGt>#*1ek3idHpMj3^48qdGB%AE<12g$SpN-i8jsfqw4q|8YpxWYV7dB)c zu%l@Q7c$NMSlIP0`)M}Wm!%E7r{|$UjFworGVZovpwDaFYvXDR3k-b(EV(hW9st)9 zj&5iG*J|~6Ty0`Ed+;>CP4STT^J6edvTKW7o9{h%5Inf|^4FdHC%-&C44yuJ@bHF} zB-iU@y1TP8iO!>0vW!-ZdGd)Uci2c)XFJiN{_0={2F^RbMJGG=4-R$^#Cugw$J1yY z!AR&^+xZvHb+)tQ4EAZ=ZC3nRR`1`(DMW<&uPL6nbL+ z(_!oN5#Nb)LJ|bI1sV*AgiVgj!Zy((&=9`2j1+YN|1J&%Pf8`T* zO$RXUQM!Dw&=~2K;MwYuytC=L0A7f1GS(r*c=}LqrgeD|BQ{~CJ9YUk?_gqOohXe7 zUTRJ79N$UDUhfn1@O1EG?|xI~&bXbsGfvG7^rv}?)@f^fIB;!g0E(k_?q)l+wv;(% z&D6Fd%AqZ_&+A*OKkcayU&D;rTZ#8Uu`=AK;2mXn$11~9iL3*(kO(rS7wEJ3P80ur z&n}B^D`ujWz(3S8KQ@U&C@x$$8fif~u1n8#-MboE>W^e*yL>ueT@a4J|Ew-O<~BJ? za?C`BBM8tLixY7~goMsZblxPw&~M^0VKl&|rgH=&odX0kp)OxRChHT6H)V(8XF+I%5Swk^3W~x8(O^yGm zPMYUY6p4-?-GaeBhnt%BM1B6hgMkMouwZx=k27Ot+qph876Ygw*kBP?Ct?DKK$-y} zX)vR_4+ZC(LwODNVP4%eUs@c)sV(6?_o0R5s0tiXk$-mS#3D%Wr7pHVYP8+z1Go0T zR3;P{z@!ARP?)UL6_IYM2LNOrZk-@lqa5jJ+l$anmpxL8FG8UP8;DoaSXI{@8KTVL zPT`ct;SPm|;A?7i^^Cp2{B76XBwQgclb8S{LM&;`mV}($l+$&T&?0!Y}FnQUJrosjyasn z&-c=UUGls0DCfl94zgPyH4`&~5A-O-N&jmiJ~e}{4D@97N^%}&snw8mHVkA0i0ISb z?zz5jZfjRZ1|YA8>*&V9#+zMK7}?w#he=Z3z!eK-Fzb4e8#ug!NS(P`dT8=l{6 z>%C7*cVCRkwPCq1IBZq!hi@=VE~1Y)%etVy&t~InKrXiA2u}eP36x{Rn$O|PHzr>s z>nP0zq$IGlFg>6nOj&Ss+8Vy@!~ya_}2MIB=974(~N%dkEG{@p09L zW-5U59Lxi{4R1`dYz#Ew^I$vMYSjmsa)pQmJRweP#xC`B{`Y+JJ$x3v11o|-&*F3q zJ#fx&tkqa>pcX)kFpgu| z!hLNUF-(Ur?-)VE??}UJWg-?P_+M(xO~eC^BS^shi9=Sjpkx@jw#=*ObQPu9i-3XL za&>z5`Ra@Vn0I03qoR}5*>9rBVbHLELwVwrB_=D7Ut{ps0iu_)POJwd3o+bmXWN7( zf}Q@^PPB>GDF_=Lum&6W0_|6S1pE9{9^k+;78g3G_quEkE7#!zV%9pa;~u>3G85C| z$O7Ixp};Lh|G$jqJr3E*(W{#oa=uE&@1ym*qU)9st$GbW22E;qYaA*MZuqqxAPP{{ z;DNZ`uEBwMG{cP;UyF^Kjqae1e`*}oi@pwPtV}`--F?%refku@Zn{O~3EyhXT1POW z*W(`GVK$b4_T3t2z^Ku0*Sc(oMJ*Dm)r7TglMU%u6^v^LeBna(VV_VNHJYOubpWG4 z{WsXxyF3~FElFoSLl1{L%)9M-_S-bXl#8oYXHZR(N#Nt+TS4`qi#1UPEn2gcWM zr;O#nlzO#3{S(}$&hSv9eh>!-e}|ZDr#6x^fx4yxpvH!9ct#g#ogeV}fJ(wjvxXWO z+(B&3cd)IVW4X{|>0T;m9nKpY8U}Udb`$I{I0PQ%UK)uGm$88wo z)4t>jZ9cghqgGmHBW^?#tjn8oh5{~q*;5bXci00lZj3sqxOxtNgYw2D9I^;2$uyr~ zK6^5reO$(z!+7OB!b^ZpgvtH@(FxdMAMJyqgjo&R=euLpisFu?J7jKT#M}r*kHKRv zb^>|vy4A$_kDbu%aTH1@k6YuqY(~g(9GhjpMpL+X8IGKTY0Tz@Jqg;`7m*Qb#h4+k z8Z;<@khIp~pg~>sweIlsTc0&{e9h72YzsZH6Yh;bKd^AD1tTU){btEmOqIsm0vp$N zdrCT1qns*0fSdyxI0Ok>LdqD2-b!rNIa6&IEf9z}F8T02K?c`Vh>Y40kGp_Zmjqu{ zJ-2W{Ld804QpT)R7p5UtGFqj8wF7*hAncH+%SX)9NsMHiP57H~Y&X93!lby>F&jx^ zYIV6-Y(c2w*p&^wqX}9v%1?aJ4t9d2-Sch%uh_jtXzHxpBt)^HBYd%QpDSTyUs%wl z5yzy>T4mAk(FGwNQC}d{L_UdtHTyVlTKWke@uf}wH1SU#1)Br@M0{+MEl-F9g9T}# z#U?ls1g52@7T0J6z%GuaNpz#GUbpd22My7|h{%2Xj?ecI2x%WB`B)k<)u@APGisr0 zaLzbXaoVWSx6MCY9F^T6KLzZQ(;f4-8s^f)G+XAlK}^C%8%HHEMDVl00X?b>X_WLd zYS*B?p<}iUQ=m4^2Shnh<8KaCGdu&#y}ggURYRDS;C>q?EghXWjHuxeP7oS1p1MPZ z9-mjB@3a)St)U}#h^PKYo^V<O&fYqp>Ucw3x*y$ZgfahqUIj|x9wshRY5ZSE(ID>NSuKtHtygTHlDZ^Yo z;04CkVrVnmTig))M~wB-<2Y_%m3#e~S>~C+26V_nZ*mUJHoN8g;eh}h32D|AOtf{aFR(ji{FiIWbF-a${f(Q%N-1Ag0+E(3KPioe`% zOI(uWhiloNPV=5gLkOiTCa}DYbBBrVh=}=sc!3c^gE$s87?hcG`}~LGE50o44#W{` zFdGOTNoOX`!k&1%aWJ=LSK_#dSYbkMq$Wm(zRu)09h|)hh7*Vn(j+cvAMx5)*1HdN zGAgG59lU;&$agyeo0-U&?ZO!fVMz2YB=56sBvM>?I zF3V1BlKy%#m6icgIQ+QBDnx>cAfw#H-FP#vIq)`KGW)>sYCBLsQf&zIa7^eRhPgfl z17(Be&LCN>-%X-)T%d^SZ_~rIvwAqyR+w)}^2c<|9>90P4y=jkD==a7k5dx#iyqrqCXBeCrG z*o831#0LS|JX`sDhv^$?^mG%gYzqT^q9F{tArv>$9hsqw3WowC zIsytbAbcr|Aa?y=!jlLL?TRGim73>+Eo z(1Q{2L|jAw?*nTn*asJq5>{fwAu0j5k;FV@|MdZr#y*Gh147_#s|ouk*qpUEFe?=r z2_g-Ma`!sKMq)6HZnGyNZw+x54#p1URlLn6uW<7!` zG;FDgt!8h(&#`U?ykU{ls>>JEzt6E*TWpX%LPH$>>jNUIsxYny=sU!*-ey+}7IX>u z&Lu$72kEcH%f(@Qfnr_ksg8u}Lo7e|=&*dxQA{y539H(zbGTY8J;Mc-{i8ugqP1do ztB}(i$9AMb+zPN%U}bhpqs`)$u0qHvyJ`1)*A%&rJvyoSW&wPC@7w{UYED35na8{a=aK|bEw!};2p@xueDa)+A8vQz8 zJvRxdLs4kcpU(E$`N|zsmaa!6F?69frUvni{%q}dL{&!+N=ZI#!YK&};%btK&flXK z@p?S{Pq(aZahQ+SEoA;go;(#`s;>UNhDeJnlfC^Oi!Ys-`sxqRxsUWYI}H&6T(-jF8jdQn7H|B0 z+ON|t|3G4jpzHrY!8*cwL2uO41=O3a{I0iA@Rl2Z|zqHs8%MpVETEU#r8}C=n$Nv9&pZq6Exuv6 z^H!UHf&8iGZ2hASDfR5EAwcwQ6+y_1{!arcu_l2nthh_((}99E<7zVpDi|@HXUX#a z;Gp7=+PKdWhdTU&R4m4*&}cB~#;DLSFZ929wutJh4Q*q-c5KV}1VWoMTD?oBaWu;Z zWyOsh966gHEF3X_^Z$%EYgZs~B)g&nBe=m%10f>WdcF0UPJ>~cwL@J3bwu-~00HCQ$|eieqK)bsAsYvL3P3;9)X!VYkRX>gvS-p$)ucpjL+UhXhDz z=^``}+|P0tls<>3>T*H|e5dgvDemZXiz5VbYByOll)zs;2Jep~mkwL5vzbt;v+Hoy zSNT!zx&dRjTh3Ggt0Pgo4w+kTfi+;em_F`TI~^)N%w%)jEGJ<$VrrW+M{8c<7|YfoJzUUs(QR8jwKyXm=Q4sd35)z4q@8U^#u!)^rMTtb zuN+s7#GZXrKZoWShF?ezdEQmgmD&HSE=B|G7T0+avDcOP{TNB%-rhXY#UH2`{Z0j%)Z3d6o
    (2hM&6>9SOeRPR% z`{wr?W%6%e_T<00m`0IpW}R%t({vrK*5;Ke@OE*8xkMis0?79o+*@2eqFK_|D%If5 z-5^|CIz`kpqSJ6QTi+Y6C`^Vve{#^y1+1hU<&9dR`gj!#(Hj(=w)HBI`AnAFMEM}KM zvOuf57Bf_yI!s`-853(%!SBGO0}kj%jpolC^O|e3^FU8@266gSMh03;nxD$DmAj+tQJoB z9LU}GNIzXP6f<7kHTt=6&5lmPS?cy=LF)BI8<=pes0%@#f-VeRIb9%pRYmYS3Xzk- zB^9P|qGv?6!LMugvz=ErQvt;9t@xGXCb#qHz(wkC$*JXIFFl+WBP_E~oK0eK(0y zwxB1NC$r5uPJo2Bb~5vR6t55Hi1+5qhw5fJ8NN41EdA|h;M$fj#l9b@ddY#xn+^8 zgAfZ!o!$y6C(#%LH%M10o%$E+Y1Q8b&Mb606>5AJykd1%_oF}Ernh&!87fW*>JFk91lZx)m2 zl%(y6^KoAAK6kLhRnws2D1#MnkXZb!E z3xFaqHPQTu{@fNA(BqFkI@|@CYru`M;&KjO>@Z~M1fWD3k4&@{>Y2vPFeRL+1*^@1 zkZ~Q)f(9}4(XPt*V27dl2ZgC%#=#yB3ylc#=Z{Ug$IuiMykR1ujLPG-Bml23gBd6> z;X4*l11X3X^mH0R>VER{@$&|;S&P4|^^$}O(-`geXuOtalVQNe6J{8%iT{dH)L~>% zpKe&*5`&WC%#a(}KKvG7U_yh*IWQNHHkO-o>QwhRH`6pXawp%&2?0xYclNauA4y$MAxl0s5 zz^i)inmv2(Jc%c1@XLKUg~l}7wQR{C#Kz+&1B6(RQ=9osQ?gqwrZH{q3ZGe67zeEw z(A8l4cELPMhfCI9k#KrXitsyc%z2 z;fhdVNqa6@jALSt!xi)5R|WC}iGBc{y^ctG!*3 zn&nIIJ~Gp+2?Z2(OsVkXP+n5SJzdO!Z`HhW*))IFl}R+d91~?Arle*@QBymi!fjWp zCA7t~@`6u-ik=Wrf2xn;qwO=nwp+;0W|4J;Oh4ufVI+GQofG@8(i}NLs#~POe!#@^ z5URVP;rwECx~e|pj74-o`*(R;1J-H&Zl#d1CwajslvaqPAZobl)_ilM=9*&!siYz6 zx`hVB|0rx=B7}LNqX~Gs$o7VBs=iE|DVNk$Y=@fvu21^7(ORxLc1KC=5SRt{pbQ2W zr->e0A!LY+P9s!)2lg@5ivmv2TYCDlN(9vy1G!!$1EsJjXVFUgxqV10h_efw z87h3+VE@mXQ`&`hGkiTRaW8!iCvAf_+G`LA<+^kf(cihN>!c!9l%WcZS+qE#9e+1y zdTa&H&_aUhc}!g}4%g$UuCTL{Il#Bhm{yU_3z{??mPCkB943WR&(D}=pk)hJ|Asw4 zv#zA>jP(}Pa|G+t1WR>;kQE$c`Wq2D5|lra+^^naKb^IQi|&% zvmI%!sdd8r7}2>%NJf%mD+Yz&xnx(W%Cwfm0spZ{HOriuQ$`x7usBX|3F)|j78AnJ zp2H=fK$T{0)`HmnJtLv-sgCv<75hHhCQ}(|)M1}=tN4=`lUZ`IGY?au?>kHr8h@njIsG(z50-xtMN3-!jGZIXbgr1~pZVFtyo)emhLfVO$hNu8D=)y>&J-PkatfB^S z@)0*Q*?_f|n-g`+r$L1nTWW6(ALHO80_~rpK2IvGdJF?I3*3}56%m_Ijlb~!(FXg0 z`gnVDH+XUH@bMSnGyBThVz8h)^HxK z77Fd)c6tI;d$hogxQJ<66P(8(CojNJ%L~doQJT9~(AFv%N3>y6BVj^4W;d3q0A;`1 zk^wIbg>Ncos|s|LI2V7Qreq}>!4F_!Vhj6qvLr$2JetuWb8~o^LA*xr=Gm*KKRy>ORGuK-%~D>hna z5gRjQxO#Im!?x|=w%(li*#cr74ZK3wzL8VM`HpeO$U{nG|QOiV>UDFlI@z6j56Q8!6^;sVMnE zEgOGuifv?Osx5F|g&>mB?*xPI=yOINLIx~KmC7d|4)MQ9V}FA>EjUX8?5$J2jMD0s z6qms>++Q2Qbh24Pe{9t>3!~$?h~m|R3dA6l8lyaDsuAdsvieravBp<_xS=@{!%0y` zFZr@9py3epie{5ks9HKrHnRydEVTR6Xcdzb_bHm}>Y5JI{T}38x^SA7k-hg>nRoAq zYw-$6F+1>rcJO~@5k3bb3aDRS+%nz|s4sEP&E?*_KeFFUu`e2cT5}3eoAoI={0QgX zV{73ij0UaMs^JVb`1G(Yn+cZFi1!j~%-;W-$Ji#R3v6Veen-^?^SSgbD}H%1)ww97I;7DuZU4Rhws3}eq6Ik6ls#ZcU#M6&Ti93J5I=t#KK z{6`~r8e!+BxYbG3Mq%}tG^WXb&;AB$^3B zGw-2qjF|?55s#slZ!iaY#>z*MkZHK7->Cu#M4!kAK1M2tKCV~9E8>PX!Wl}SrOEIt zs8wnZoZC7ik%$-#62K^J=Wjp_J=&< zzx*hgcwq=qI>OiWNt^=V>bQrg<4`A#ua2>-l3AURMb-F^w{L%_?CrjN`-cCW{P^eF zoAmUC-qZixeEW9Or2nh)-`45TpLmP!@_Favbg^0={kfsvld%5jUj6r@&)qN8>Mf9& zw@1}mKkNwnf2ugMQM`XO!|;RMH>EDZ+51#+|0LhdE(-(z=92(gpdT-xZca&2F{r?A zO28ymf08n{yVhGk%Z&VjnIe#GBa@ou6oHbJLPwdqO;5VA6iYX&DVOErmH5=~B##>I z&gOC?$)W3V-u`_kvD%6iFXF`A%jlv5QR_t;;c_{<)T<$FyirqQcH_uvE6-M3gR8)t zsDkDu+~ZscXef}Mm((kpmUGbZmE*i2>+gSeBo--}wNRnW(;#7dExcN;{lE+xCK>ds zc{;a9p5xJk;}g#1t%w<2uXZs{gB%AF7^`bsHnE*^5;P9LdbroS?t5eIsiiaK2TpLDo}IC} zI)z0|Fb=KN#NyJsz+_UwN`!bK_xD!kdO(ArbB9P@oyA2Q9HKWQnVSxtm^B-&*(6)# z@AK6L*PXNXgBtQ}=(O(|vw~IhVH2;^c;k~sl(w6#-mU;e8KP_30Zn)g!!s=8+nd~n zu));SL+YNE?|3O49b?)TPzf%ysmL?|Yg1n*^|K_I(6bqp*Pm)&*B`QHn4YfLG~Zhu zj0hlQ%;bAq=*Rcet(;e#El$s)8@tMy5FKO+VB6t4HKLnvie{Y=95)2f8QsBBI>tL< zSS`aDit**$X4jvwfI-n^{`=fCQsSVO#APs78I(xhExSex}Tgqjn*NPDTT1R z;z~?kF}*1k$P17KRXX4!YI=8VmHoW771 zuDGPegHEODzfKKur~(r$xP9@ah0@+o0K#F>tm|Zf?&zDT5u8S zi;i2y`z}K_OPg|PVs&mGwras)`>wVpCJ|>Qc|>6xQ#s#d+Q^G@*b4sCo$SZ&BdU70 z>Y5KJqoSH_N)MM?64BBc)Eu_6t+fkVI>H?Tpde4Y z2Ij0Q0(52&cY}ZSHZu>*>p#~==}yh?Uvc_yzFc3rtQU(mp6T6vHs#bV18!OWi*Jhf z!Lty2_+gf}CcK6T;aQnufOVsZ)~^Wgr-$)8N;Ye^wENzx^J;Oi3YQL+__Z=04Fme> z;NgSd=f4O0&wtqs9z1{cx5MDU!xs;qJqVsZ3+_Gp`{Cm!&wdFi^UZi#Ewtx)8qE`2 z-|UB&EJppihPSfKjEVHF(ri2G zqj94s`pRu{^@?LvKtcB}4X5GPYEl_O5EoYAtSF=ch!^3^Bi8Lo?EOhKy zz{@342KxU3_l-FUIxW)F#8;17CBVk35PG82#~Aupp^D}X*C9NGV0|*@G^K0kmvAj0 z5T0o|!0H_>DX9ws+zI82s`lbj$J#_0h(k0pW4vH8%KswXh)-Pz5er9oKR>dvMSb<7>hXhCH`68&W(JW8(^S{huDysMJAu2X_uwSaVS?r^;ubqlUI6*d{NF;2k z5sgFT!lygJCt{WEoh47xE70aQzLAwguh(fUdm`SZ z*W3Xgi;o}vy%s!rb@=M#!{F(|-QY3`r?ub-U!Me*$%dVq-t(o1xH+*&msmD1wGekU z0(2uG8RaJ9%b}_J6wcwLyHb#%*cCH)TXYC(uPm zL`sf;vv741o<+epA&zv+Sc2UkC1p%-{$Pd5<}Bg{B{g6`1AE`_oDvN=ewqT$n?N{m zPjVRaDT@C3>zeiXrHyeiXsw+X%X4i zg^bTt_M=>)C^D87(6OwO7U6=63cp2v!@-Wb9oF1W%-mAOf*LPX6ixu6Q(Ay*ICk)aq6 zy2zLFm@r_Z-xXcKLkKpY#-8Fs2A+u6T9y^0vyRVkp=rk;MaO}@%p)mR zdbyWO{NgTAGy0*Y3HLR}sM_5@(`Y7Ej~UXMtc<*#kUvY)`rg>zN|_s5dE%ga!0E+n$m% z-4>1TnOWm4XM@`!#6YJt=4Z2dDy)9NdP7q5mwcOeXs%fpm+k}#+u%}-G3=Hvmz9Rx z?ye^z>0UKi6w5*Nt6JDou9L55zao4?)mh#AIP+_uqycXsjD(O`jkh=7pwf}2Hdf8x zGRSYlzaA3b8Rc%hSu&@{bztW@iFPIt{_J}Fl`e}bJG!0vGUb(&$MJazb{z^6)NSEx z*IKM}yS1WbX_xAJ@~)7~UdbsoPvaRa+LOhL8T;a2OV26lou_Hm(b_BY!w>G~Q~x8& zB+h3Znpnj!K-6q;G{_~ZnNp%C zD`+=UE*qT>P^%+G4(@zh+g|f*B8gRfmr=zn&f@X=E$fh9f=PTXOR!nZoF(9~QCm!? zs@Biv#A6FtjK-J>R%uEm!dEC*gTFuL(x=hYwKuCaQ1kxv`QeFclVXCqy$|*99qItl|<1m0VP7qJv`wv|f3#5^3RKQ;(I0UkRvO}vr;72Dr z7`BLwhKKkJXb2LD>{mV`&XcnUjS~X6ENG2Jw1AfUK{N|5pVC%tHJibgY90mx?fds4Q;Nmgc;29mo8^o z;$WZe-JTcDi$gMABj%;v>E+QUGnRANh^57oEmFi3A^lg+WNY9@J(;qRf5{zvntTH@ z9!I=8)afVGs@E(ID(9k-PgFAoCIEnmTB#pY*=!sD8`M;Xn_`nLVK;t;Ei!Gl`?Hv; zzJxVS)v+ayKSr~s;p!}2XruByR39;8L(FsrhO<0xF9Jex`_A>oLabP6JILyNjfOa?q2G@6m?suJyUYak=PP0#Z~s~g zUW>`ce3!$N@Cy<{e~ZHR_{||!UQ0waI>vvMFy2sR9lHAQ*Bk-nwMC8h76(8tFPPP0 zgEQi?Sd4j3WcQ{CZ#IXBQhA??Nj2y23-7CaGN; zu+crDxi%h zq%wzX89eV$fB0Hm)pE6(>vkzH*VN{^y#<~fGxWpGHw}N?@!odICxr(peAxNs+2L2` zin-E%9VhO{;qwR2cY~J?U+mwz|1kLN$>C!TXp)5lvCXrTLtGZ%`$Ph+zZNQ?cbk|e z_+gCP=%#!8YZrU6;ShSK1{ryOVDSh?dKv!5-l zOx1lEor}k&x#N<%`H2~ei8^v9;ewTut25XPqN0FNXMSjAEQm_TE);;4RZ1({a>UO=J0jT_2@l3~*(`Cev)5TBZ<*n`tE6}a-` z^iD_Ta_4K#NS0s?%vtqw_~r=FQC2G--Z~Voj`Tp^o!d=Fe84iq0F>K}k`6hFkkcgz z;U>{Is-er~5>CfUeEfSV;jXT?Gh-g|6RK*t2 z@<^soK_AbO2}hDKRhO$|9Hr@A15wssowC~lut9Gz^H#=hq#up192${ta=-wR%lu$01h32N9U z9E6G<9?cT?EsNDs!>Zq@_h=Q)UOpteg5&t)#~%tq%s+_F;&o~#=P5Gu#AyE})yACf zFHOVM%$cG3O%~5kA|6ZEZ~mj+px)oUO^YN&sWa*fv>O75UyXfvqW?%-G4X^;{XPHuxV`nSqR}{-f|dQ@3g7z5O$ysn#0+^=_}<>snPE}`RoQat#Y(+6#V2kke+$Ld zC+_eomADrC!6Ssr`XAL?g=lMyJNYVSTl=_MRAFl$ccqV_^BF7u+z2@N_0I?pRmZmB zaLeMywDNA%vJ;ya$%0P*$h^r~W|wyCF6JLHj(YG%0T$*sqm%R>K9;A5$Uq%ccu>`A zj4BOJqX#hp87dmaH)(o*5WADiQh{3cf>u-?@`9O9)eKji z=l%l@je`>)s8m{YT#zKu>1p-WN%epIUrtK+;BZN7!pC@y2!$*jhDAFVA5O|X=#I=x zX$p-|kLAFeO8bUcfl!}g>i0=Cug*q|kb!byK5FF@Yc*BZ*iS9LIv>^6eTRwu4XgK_ zM6)$QWmZmHnD+?gCs1-%T7(e>g3ihbfT>npnjn!T_)$NGxkVCFYHEm1*YRwFTN3X> z_|gARutKUwYQrKL)w4eq`uJI7c?!;d;4;w`+KU2c|MZ4B;l^?03|6pW-?%^^0$Sk@ z3*J;`_!)l0&(b69<2w^)+uN)xXSieLlq{HD&hukyEN;0kQj?299v24XrDLI=w-KMa z%8!zBMX7cfn{4qyt$Lycng(aITpUD+s#K~<&Ca@Wqo(|L)qXVrlI*tqU;h_DOU!M& z-h{Iflo-#FG&)Qq@VsiKYSBrA;jX zFLW+oL(-e81h=6tj+Q#N$}F^IBf?^s4WBK_(2}AG7;eQzft2z}7|29xq|I>u-phxN zUhUrqp3f%1L3kRjVo_MVj}TB8y1|LK#Li$jL+d3?X@f|F5C2NDuJD<&L;m|1w;RZ_H=6){Pf zLc>33%fMq zFrKl`RI;cqMD*t7##0&@k^5C@hLXm!XkopmCuLe()?s`HO0~Dk34<&IjUQS$O`(mm zu#?l|75pZ_R+c+R78c-(2->)Cb=mM#5-#4=iV3DwNxRfCW}7iSiQ?*wnoB1c_yigC z5;|U*q{Oc(J2REmV>>KWc8b3Qx9>FbI6q^a!In8^S+Qg9Fz4%tg$fFoq%o%?#(8}f zv58n3c|1WeI{vb5Rt!I0FnLQQ1a&h!grm`q*;h&A_N$~)?)UWC9m`68pRQ-_gcl`B zO^3fi`wKb?nkDU>eN%gPOWWi74y=lnJ~&u@F^sMhFfce4AJjOaFiZPoRaFWgTPe16 z;_D@hIa`Ykh&N=Gl@+mjldgY`eqp!X)giIg9vgoRjmX01;&bg8*yg@yPJf}f@vE^U z`X)5FvjtDSsl~hHEn*Wz+jp;ORr&~Yg@5EYwO;+}Mw+GCp~*akm=8MQ zGbC#BTtvdl?tv$j^SoGMk2*79^}CpiTmI9aNK?2vO5$r*A&c&bsQZ&^ z_S$y3WuDmPvirk68eaH`&8@|}mgpvaXIz89jMi}Lt z7x@j1WEaxZKM`?=KW^cx_-o;1$T*&dv(yb6k*C{*W`rI-0!d_;>{!xj2DfgR#>M#A zd*cdY9Ne(n0#Q%*Uy%TeohOt4tY%eX?H_Jy5sW=tM9BvECngi3Zl9u60+XfS8zDy2 z$6^JM63AKfS?+7?4$)Y$R&hR`JwJqp2W;fSS$(-#agbIFrVcW=Tt=(<%joRk$K?$d zef5kgem~WQil$xJdHc4}y!FGMmA%_{aGOj&@u%AS@rNC_YGqRuWM}+Bi~pswHYMC? zt5svKkF;cuuo@s|SKm~CStb`cwhKw8E#5<3t9}Aq6j!Q3daSgXnK5`7?qqX7tWGX~ zY4oR*Low51B-gY$&l?ub_zJ$zTszwx;ldNX68E+0KJ`avGgj~EYDuAYR%hbjQbs$`445fy);Ti@+0R35 zj>ymfx69QmV8mfnxe4nXB`7Z?b>%Tjd6|0p2MO(x1ZiA7YQXfr@~#%dRpArkQY2fB z*Y5Rvj%T>$Exn+J;80WPm0C^xgh~7N^P;uZ8@>XM#9Jc&o58TqXfFSEY2v_}qGoo5 zxRu&*&etz!mU)hduT|NmX~!P1{`!ZDDq3 z5~+^<%iEjR5I(q9IOSc7=vYeH1|4meU9lolQ=i-^?tl#^iIx=b4IHaq&ZimaWY?q z$O&~ygym_tGyx=PoC58NFcR0d3#~yd{`1uqqBc#VTh6}q3O~>`*~U0~jv0s{{?_Od zfQhQjB9y3-#XQwKJ=1Ze`Il4fW%NOQ5jd|jU=@qX?Qt%CjV_;`){ywwEl58zuz9hH z=c2#xGDxVG{@N^O@%j;Ghjq#xn72091bf#!dA9%L*+YZKpD~si^b|iQ$xKaMsV(#` z`CBmHqWfvdJ(Dqtd>J7&rg%Fdl)G_Bj}} z5%T30n9Ag`oA6tunev?=om?hK#&WvqdyFTu2<(q)CGT^u%S>Vt@N0Z;vRqGhW#V5l zZiW^%B@=%iU8dPY;?@UAyqy@=9M=Itf#YmKQ48T?bD{i4%AqAW8{4B>_kRuk{`^(& z>V*cO>kbIRd<7l$Rr1r%6rJfRH4(CAS>DTNp=rEm)L7A4~eU8{|L) z;P3?AA7vufU1e*etj!U^)A4VilZWjAkQfV{ArDDyIoe zJ+t>S&K-=eKH63xn-(_lj>#ksm7IZ_yRoFzVr^csE}06*_Ge!gW=n3-R^FGh zmx?KBB`5(j5f1wuy?cK0M~QmZveD`g7liXw>F%h__FhP2Xj`IntL|{wVhv;&w@VvEGn){`^IzE{c*j(2ihdM&Z#>Da%fW z=R@U(&X#$GVdP8pCu^ZYw`J|$cuYH=nn!otKlXM7&Tb-Yww6Wim5dgPitBhT z9B2(RUQJS>0#~?rjR-%~H#%>rvc{ki?{8d-Q>C}gLGEXX zXRr46Rnq8PH{!~Bw~O=A0G|HAU2rrp25_=j_hfjF(VUkA0SP>K78|XnX?(VL#KYDX z6O$+fKf()_uEu(AzX(_BID~Ip#+-sA!8IW+e&|%}KdFYF$v)Y$R+?YjOAJhzda zE6XqtGnK+P2|7vwHR1roIL$cosQ?8V=Y*@smG`8bGChb4>y<8ky|q-{ zz~F3UHAx<%?*Nv2;(v$5lAWj8uI58^&=(LPe+gXYRN6LZ8-;wg)vELUTA;tjkmAg( z!ai82CtSW3Ku4;KfiJ}&8Mxqz-`khr-fU(UKm)%N@)o#PVYi~-27W(%CH9s0O_%e5 z>kJntKRmhAr3jAMYChOcfn_pNeKSF;T(fS$l{Wx`2t^sHX&Eg?4IYx@h$zt1fZ{&4 zwBX%gO3Ws1pqjnacTPYlP^Kkz*_`Xc(@5+8sj!q5zYU5~_a6(t2T`=Ne5}VUBw2u1 zi&&#;fP<+cjTWV-PjX>})Bq|8GfBDORI6p-h6MV$y2&V~Caw6*ifrntG9t*gUpcSp zJ1i6>npQ1L_vVJ_Q|9|+@W#NLz|LQ`L!Q-L|6R~maLZ@h;!80tM(rrJ`4^YKRE~v zp1(Z2A?YjU;d>G`=E)?Q1)F6`(toOwH$hvBRJ+Snv_#$*6ReOpV~*{(na6PG!gB*p|{{G zN|qpX#K|b+!j6|hCI)-)t(W43el_$)1*CCQQHPp4rBBZY>A{{VzErbPzd97hk(0C1 zqzfX3juHKffTX)C;8{&Tz`{(*TlxRXR=^eAIkK&}cKBGRNJYL*^;i%7SVYrf6N2zq zb(6B3TqYJ_efU!6dW++&OfI0}IqUb1+)xg%p3xkIRYOvtt1zpk7BnsZ%q&JQ6G@eZwx6W4KV#3dFZ(?L~_R(SR(FCKViDI+`&cZjJC<|C0 z(Y0nK$559ec>&ve@`pEf=L9hQL$T=eT&=#nnyeTZdNNVDHcI&{XJG_y3l`RJmR|M| zhZy;EM-?-78Pe`<{@hbJgsknfPA+@h9sdUQip*Tr0$%GE;d;uh>*nqgGlyki!^F2Y zY7`pjY=c`rTz{IDs;)Y7uOWlaUKa)qXsrS<3b9Nz`$9ZU&B(w)QyC2pXNeoi2g(-J zjpVKc3xSg=RB~3cB8KVov8qfu*!Q7u3JfC`<9R7_c=sKN;y6sBdb~)Zg&650?0t?- zO6)dTyj!$~Ier7&_mE%I^-e9^y|S=s<2uN1NZM!j?N82@2)_7^;rce4t;=LV0n;q2 zi?xs|DV^{>V5q8w6WJVJ+^x$Qp)UflqpiHX`5)}b3L55^%ih{KWAwcRoi)sAevqUF zvBGEXPRt;Kj|!`(v5v46s{ZJ9gZJ(Lk8+D!Om{hbosRfNONHL!i8xs3GE2f?wfeND zI7^-;zqQ=rH)MZ`+Xim|)jGGBLMVe}R6}6`7rUTR<8U>xVFF#86KwM_ic@)U*akbM zt@y*6A>&zqdD;A!Ux`iLrKg}0+RNcmscywGgT8u29T{fOI5VW>tiQ1c^yiMPS}tw) zu11b?644qi5^EXfT&q?z;i@{AbA8H;5xS(=&Q5LLEL9esw?tu;rL|Qr1hu+AW!$>s zK0$Dm+T0Be6l-o{mmUzbV+VefDvT*jLeZ<;qpyT~RuOu5H|ybMJ706A zw(A&~>MAy@+J9Q#M4z1&Z4l;c|Bi>J)#j9vCctyydXw2<9EjH*TSP z5L&CQGv&%d&!VKS4tJ4X#b@~EQfbyp2H>Uw$V#!IgD^VuYl&y2N?LRG;8rDZyF>^cvLZ8B9?Gf6{Uskv9uyUU1m>Wq^iiV$h7UaIbmuTmdA>= zSX~0{W~F{`3t>6p1#Q-tTDYb14zFoyK_xyFQ!gD`IaEoibk6A-Gn&!IaK45q0I1NrGffN~#sr+;s>93vRrl z?}vycV)*qE!OGKvluJrV6uOb!g+`yCVswrf{45Wxll|l(T45NKYGVOy&Mf{ERjw@o zsm5q6-YEy)rQc3^|d`tiiRn5P4xj&x%C{uL;9tUuBV*_(*84_=sn(SeCac z_pkWv4^_S%W!QejS9#$U&%FyIXp=}P0k>D2i6ywEk$z1_+}m!f4<%wU&lvT;V?^qD?^TOQ^rA4JjQKK!QWtJl!2TefDQLVvY5L*+`bTaB3^ ze0fYKGsDyT}AO`+yy>cbI#Le$}bJMsKudu`x?5Q4BK2T z%GOZJF*vcjw&X^z0OAsKyMnM*mW~S=J3dZ|+c6te;rVUnniLMvj*neb!6@FK-J?CV zFLc9}-f8C|TNe61JgB_Da=PlfPwG%#f*Q>r`xx08$_&zJ@J^6sPdoedMkC#v$n3Dl zs-EDAyKZwK*?R|yUiWTS^=>I9d$co)OZ@p88ym`rrKei3RkOsql zyqb}tQ_e0co5_bdY57D5g`Q2@5ACPC^;DGtkvBV%4Pm zXc0OT1nu;F)OFNyfXs5HKo$gn((>1x`lp|K& z4~t`%aq?@24&k>-(va6uh6`M@zFN&H(kDG}4&oi-oMbR@2c^>;=zjLF)$TB6N|xFCci{WG2ZIi6OLszB-e;CZzO z7wdPIl1(6t;$(AlX-k|FOE^CQQF^ zFZE)!xiOIB{CuXSvCp&VUu(zi=kstiyKIb;`Oe8KIopvz*B7)K(;Z`t ztU6H%5^&viqu4lEmt=LP@K;VW%}hHE^sj8tUVRY!W4`D>^VMzbtF^n{U`xje4Fo*8 zh~yKhRsYhAy?Im^IN9{8_%H_W8%GvJ{w?DuTM~U)7l6Z!w7}BG^HcE2 zUsXFTuMP#R=6W7K{Cn`|)#0m`4}+%tzDzP`v9=K$_ zygL3@+D69$dt&_4)p+ML;`5=g&Sf>T4Jd&@R_f2-0fI{W>3lEFdG6W&T78bvHQNTg z1J7II1_z!Xh*&3_D$A4gR=KLwG|UP~Cji>o0qa#U(Co-V(T9fD41;DW+NffoA5|yME-++nc1J3rpQmN#ZW)p2S0r3tY)&BM4aCZQG_^9vQ2lV zVsM4QfBmo1aQyzi{@38b58lT2>LD)QVL_&%Q>f9flMM~;JeK4EP&uhSoSr2QpEnJi zE-<5Ol9jnXU%r$^9?iltW-BmJqOviD| zx-NoyGM^`lh6~n;zI$}c8E>mZ9=FAF?6wKyaa#=?PrO{IcT?4p@YZ*OlNtip@sHd1 z(UfOo6Dd=vjps|}f8sGUC*s&m+P6Gh$z1~6%X-K=z2I#tFQGL^7|^=2bCYBNw! zeZ>pszO`KTHv}25dF(>_<;4GT^492-Ro-${)sGfHIOV-pG@@$42vkl=s+|;7;|m=p zxIdl5zeKBfxTppH+yBg4EG3Yh!Z!U=4POr~qDh=iozLMZ@e#o%&+Fx#74SpPQ0>I| za^ih4#(!M7F-ykbEE2qoDqJn&>w;I%o?=Fs9Sz(n|7@*A>e}2(+ltuVUy3!(l8MEC zcanD(nlI^71=)0bUSF0DYy+=Gww^gM47U+Vv3kKLX(8`;Wa7#a#XuS$nidlb%(tcE zFnuYFZ0yhrhbnv(Nhr#>LLd=%YzdYy)NvHZUNTnw5GJJ?-Eugq;(oRwYiz#wf92Y8#E6F`fH643Ql* z)PGuUmNNzh{sa@kQX9>ELT zx)T~!1n>w7l8FlPqQHROF~gU7RLqU@;n>l+Q9ab?Os!L!Yr&X1yNXfFLaaeN@7-4>6Sgk=m3M(L({T|Y7C2Mhtp1W9tf-2SFmZ|M61T~aOV&X%*y~&Zkiw3o|7VRb6X%3m4={0FBiv`QST>T8i}+=ZO2o5dz3PSV8HVgh5Avar^9tZB^(stPO(8 zWP?0y$)dhl#PDJaCNVS=CmR(V&AaRSZcB~P?1*JhHUjVIEJ;=>R|FTRFwc!p)|@Z5 z3R8o5yeQ9uTQT`=tJzGrmFT1Y$w=nXmrmspoJ8x3hy)bd-UJFmFlM$LysB|K@)K}2 z&Os6lSeH94lhmwvluC4LmY07!fy*Tot2AdqFDncE0=p|+)OEYi?>w6n?RH`@j4`XK zy-&;tQ}e9`I}!r|4z%!H7lSAw$0AROKR(VZO?t)Jh_ctN&-YlH^jeF9(SF5h>8q1@ zY~)~$at|C=&FlBFCuC9FRKgtl-EgnDAoR}osaGA6p5C6(I3*^1a90JTKhD|%aWOW% zR2$FDfxz=Rh}OyogPsh;VGG74%YM$|J3LQfyHvXz3x|H%wi7qj^aD$pSYB(osFzgB=+6a5q!26q=f;&p>q?E*1&(964x(^1o>rj zv4mmC1P1}ge>F3jjC?2G9F2GetcrwaGvA8qqoD@Cd-b-$Kws-eI1x{TlPf;LiU4hD zULwOIafFmVvXd|N4P$!ovj{B}NK-F?al8|ICHi5X{kbg~SFTo?vQC|n zr^tY3j>uyI#WC-iV}i%=)^kpB=an*;TgK;^zTRJ=$li+nWjsJK*UnI*9t8~3Nzxa6h36%-{&yrw+yix4^jazBu#Gms9 zhnrZGUZ(44o;HGqAH~yOF20F&WBZHxLoS{ATy>+40-MWcdu=6IYe`?l8N1r+S$(Nn2i_Ps< zWG}kOSojUT8H3Y1?ueOvaV=5ZAYP8u$3CVi+}j&ViukvtLq|EEC)E2R zi5C?&mse426&ba0J3Mq!Wn_$H5G%~{Qm}Ens#(tV5p*A``X$Su>2z~?O3RIq##0HG zHl8JmhUK6jEek3}w+vQh~j7At~rXc1%` z{>xh{X+0YgO^^&rOx2IRKHS-FQG7Nf@}SYl+^Bt)Ff{S{(#c5eXw?tBfL^YPsJSFt zt*ZGzUL=eE&N=z~V0GgAE$M+9x@R}7*g9Ei- z>V0xa1bPXwOrzR?A>=HcCdq^&>_P41lj%e_N46v-aE$1`_JICr4Vy>Mo^df>ucYfx z6>XDfnyJ1K94WDd)a5EGtx;yq8F3LVm$;(0KvoY~SZ5E7g5|N8U^gPm z)+5e;D9?o5U*V7O)jRfzd_>9zK2yXPN9Mr8^6CrdlG2L&psADaHc2iTTBd8r2cLC? zu<`2U{z1Nh(r_A+iC5ah4A60AH|cWE#7^*=mfO(GOBoN<3ikHy6b`6*Wr%Sv92Yf3 zb6q1S?0McxJY8;awvB z<|}Y4IGD!s*6k;?;H9F;m3Xn-5YzPpfjC%=8Ld&M!f6@xH=OY=sRRfuFD!|yD=ubU zY7_2_3Om7RJs<%Q@3~BgcZKUgya-Msl2~>QlQ3N)>vIvX%n&P3rVfU->z&WG-xi6_xPuj!qp!}qkd^G8qrP&$lz4vFhi+&<$2w3c>_I+p_;Ga zMS$`hb{vMaz+uk`e#J{^yn|I}F~Wj{7hTK*zgCVd!Jqn-$C)bwN3fN~*ikj-g-_DO zloN)^dy|^PH*eBL%DSUwO&6|G-|D5V{-YkMFNL{?|AUM4r~dYT9EHU3J!Zz;E#|)W zDkL1VXS;P4)WNu>bxR$pcfKn=hc!7^lk9LQJ*vCyReTOD743?NglI_4&Sud=Lhr|i zPxl{+wz9C~G@eBF(X3s%qEb9Dn~K@Xw@p&@;!H(#;ro2W=dLzm;s02(8m&{={>jCH z%>u%;cpGe%yKbK;7r0~7ULg$=2j#p3S2T%c>yRU8pFjx}eH;^CB*?5=;L?BJ%Z%3h zdYCMA2Fu)BC(#KphvVoej+R!l>1=h($f)a)2WHnQ_@=xbdpU@+zF#dz@mI41d+r** z&R2)+b}kO+pwO)al8eUv-rEZ%$yoB_o+Oh?r;h1ESF$hma45*=>-2UKEp(_DsVTUA zN7Cptq#!E&P|?-kak$q=PETol)z+Zz-j-MxlXI2E@ie%IppIXO4vaIE3WpuRl5EA% z-WQvbkmQZC5K7mJNc#pXlC^0rTCm}1%6mdBg4ijTb}HIQAYL=9Q|6Y1pX01Qt7K-{ zJK3z)5UHFIf3@Gxy%$e*)Ee)kV`_c&j?-%;Mut2%wJ$Mo#fMuFULYwyss&~O& z6gt7p?o}f^CG<+20Y1X-tHwu1>1N4eV){k!r=OYKuaHd>h>FQ!s7@$kuURFR6@Mq> zi<`l(qIq&2T@%7?Pb5Mn>&JR`RPs>~2>T>3g1@o6<5ZCn1t4=07Y^F+MR-RHJ3koJ zy=RQ5zp^Gx8pBWLn!&!5yALkzTP==3I6Okq;B^6*TpPy1_Q9Pg*jD`cSG^**=iu*I za9RV#OoCCrT1m5R&*d%q*D9G6krihU$O)@&PfvG!en|oIovu=;I%(b>MBz+($+`Y) zAX0FMMU0zZ9us*Ll;fMnwM_;`3w}stlFho}_o6V<9zyz(NL|#<;{_saJ&0!E8OoOyb-Phe-igt`saV9M((<={Mg@xBlEYR4CZ#g>I%2*yMdc5Cnp+xolm+G znXgz6VM-oOH;ebrSBI=7^;yD=j#rU6l}^GGQHC35@tVlSd)gZbd#9#iDupu+XAvJz z{Co-D@ZSiN4T6z&>f|WWbIY}ZV<6dtaprRANNUMP!E}|YX#<&CC{Su z{U>F`Y~rIpQkFb7vpT$s0CmJAKj%A_hacA~m9OLZU6~oj$K6taN9b12^3c}7C}kaY zu$sU~x2(K{D4Xl3fTAP{7nQGN9K$tUQh82Q_os;T^KkhZjg>d!nUcS>`dc0`yTTM! zJGthZ3FX#TuT~jy7GkA``*(wX&SCQ1lGfPH6V=cPJOAm%b$9XNl=!lLze}>~zmw3q z01I5Gs3;pAC*0BZdS()y*|D-iyQ9;jp01+k6B~tdWY42a$;0Fc&4zVGsqIZWd5dN&KW@?K9`yli*G!D12IJGlSkiIWVAw>eJ2LfmmqN4Dq6x&3k;E8<5YzAECwA18lN z|2h&{z}m{x58~)?mkQ|4hXkXN%<_RxavHl+n3o}l7Z^fsZU#ap}0kmHiR2dqdNoNxt(`UW zYk!GVMW%r2nUh;6#TIRbny$c8)E|Tn*zsvJ*RqL1KlPI^L_Gnvt{eK!tpI->N<`*h zlZI!}ZqBCb0Y`pT_vF?q;~ABhiWkNK$xrI>VVJJv={F?0&AMfnwu*f+Y*&1;gRT7P zKvki~tl#sQ`fFTvsvxs&p-1w{E5`OtI@@|JVC}a4>D^wbcYigQ)_6vXbj@I;(HV4J zzU72@c@00{>qhW$j2qOwUp|abK}d0+6t_ zG7Ns+oDv^bEgF%0Dj1P`$mTcLYdEUqy#^!0k|?8OJHU;L57VRi5<{_ z#*$Blq{DbDk(p-*$p&v|!oJA*{%ScgS~M==_wh2C#G=^5ubmet{I2q95hL7U^`Cx5 zd+(k)?Y(=U+uJFG$kP{<)QM*5S*3cmXKB{<>`vDBjG3_pCV8I*b8n4koY02RJNo@1 zi5F{rnRmuF7YYRyw-R)qI3+H1b#HCQPt31lWhMfKmK+>2ES|IDO02ErsHepkgQlaa z=^Dq~MgV~rv1={gk142B_!(+A{cKA6GHQ&E}b=W zr45*Io~^>=lz3sY*()a2<5@1!qesCiXN^=URZMy~c$iUxtn!y6w+Zb(sP9?L9j<6s zo@~y}E~~*sc$tT}27m)c$Fe#-GVk@Sx3Pt0;ipTEEL5+%hPFfqqQw}Vion!&x#{jY zwC_*Fn)qy!jr)-YRY7fSR4=!AD=038R8Yxek+IV;qo}#cU8FQr_Hi&e z(2d%x1YfkGGhpvzZ`hL%`)-jK;2HaCCUHbtqs2L*F1y!i#RE6Fka9Gjpgc)3yc#U) z9XvTas0D`y`WA{Y^E5u&zyJ_28#e1)V11RwA}}$fIog29;>t)DisZr!Y}DEe z^l#M3-x|R)ZGESNYNj9p1U(Ns8Zic8{_LNaJE}Ht-N*&fz`;(A*{vLVXq{->+`Jl| zC|y+QHB|N|lRrG?MBa(*KDk^(i?neP?JSaYlCyOXe3#p;nVVYG%;6-My5blN9 z_Xu>xH=1_1fE>^=!}yXRZ@<8#!=-H}(OJA;e?GN|Ek)2~lT74@a%z`Zrvxu!^24nUA*a*D@Q}RXl%*tHgr2`+_NV?q*I+ zfBa#m7HsoFLNm)3D_V<>E+Jm>o09H|voR=j>gh-IR+{h>A2Layfgd1R7RXVYNhwenikUOZFh0s_+|G|}DoNxtcu6X)kzv(J+F z%*2WSV<(xjtG)tY2bkb_rx6TPIz#WbdXPrpjk^m!N8Dd-$>m{bg*!gv^_(C!~v(VV#3v@=;9(POkFi z8te0)gj5~`ef+pSTFqwh68?uKru;noxX%$Thj6A_g{+6uZokcf^$2rDI~jWUMMVYK zcLHaIA1f`T_^rq%p>o*{SwoD?t?F|oAgSgRbv+7&dDg5!sGa-;LUOg>_mgqc)#;z^ zs7^IUkagje(;RON39_T4|NH?uRf8X`?&9su|Mq|Rf5PO?zVc_rS#YnY~N;mXM!!*#TUDcKLx^)u<|>sb>XN0vLu zsyx6HFQRZ2;c|66-mF+$#fj?*3`)92vL*Q>Y7xWbd#t+0qEEw1n&kMs5)X81%3F&q zhSRlI1O9WfNXokdP*sRE@QRx;Sa|~GeS8UT5;Vn(E3@ zey`!Y+S?+sC_=#_%%=iZ(otHm+JQ`Y@E9<@}I$~swlRBRpU6XaFh3sw-Mly)NI z5M|atTQdr)95Q8HaVST%>fcD~7Pv*H0fs8fc`$rc>5D#(y~9eVfH|=mAR<=9pJvFh z04o<-DLu-BfdZBv0Audq=H114PAe2}f;HQo1*lu`t{PM$lL%1vYAkMza9ayFv7c$8 zT61#kGECgEZeNIKpr9pHj>_~(D~Nq|Zq~C&P0JfIw`=#2S64CC-n-l0Jz4&y>x~oB z$)B~`Ow|efR5Wp~%iPS>-1Bza{%Tu2dogSCVJ0fe6ugaQFHg$u3Qe36*Zw1`6mahO zcDd*sDuX-2K3`9i>a0=(rIp6|zmIih-eVWz-ZqXKJfjqEL8S zZO6T=Ho|pP0Xz95VPChDELM=ULN5Kh8 zMA5RbU9BZ*@+W76LY!hcAGhBigk0noMDZ^y@!5LWt8n-tf|$2^c2{T@vFt|ibFa9& zq?)@9H_W4(z(ZMKrC#n1Zq<+;PHU07i#E+lVcBPC)xT($IA_xccf5#lB$;wxv|)TF zE>_6FV;p-AH>>wXXQ#%Iw~IW}Z%+b{xamt&-f2HNa*i@p>?-e}370q#-J+A;&xvA*wOjEd zTk#}y$hy7kvhO|zI#`vuiajAv(GLD%)5ELKo!&lv!uPx+U_^5caH)B`W339G@M~f5 zj`zxPenS_Z*)v(*Rxxxwck6_^@r*5uI$Xlu=(d=}690e2bm}$8*h=hLzSlLn&F*b! z1d(p4)qenxFCdrlAmIhS6+BKZh^eF%6FLKN`E)^Bhuw+e z#d-2Rn(Rs09TUT>Qq8!dsK$O{OMs9QPH?c8<#GlmMdqCXn53UX#?frD6Z2Yl&Bv*k zO2satqE)7!mpWeeg}$>Ek$Ro$neYD=QN!s1zjaV~Ct^7wE8NX?^c%<1C%F$061QvJ zg9K++*XFCJ&OI6*I9fbF-|d&05&pto7B>pJ-}zJOVZNC=mu~ZTHlwn18clR;-mD;v zGoEK3+Z#sJ-dbNB>auL(>y&i{>-*KY>#h7VpZW!4WX>g>8>qq$RZP>M%|wX6VeA20 zNtaSc2sE-Fwwc(+)$+r$QSD*Ooq@1Q-b9?qi~G*F*!`EDlrcc&}clh`Q!%#A~tdxDzxz8~p{2Li!wK-4{7R z6L-7UP+{8j6+XYsM!g8kK#)(A4$uqZhLInSXC%H-P6AnYJ6aIcgztu^!>?Tw^vRCB z^yTgyHLM?V(6+*r8J}jPq;&$k1KECq|C-B1x$Im-G07Ye8aKEjRM77#4U?mZOE z5d@UZ&;$oDuG(Cv=VefCIOl>Hh@SYLe>zA6r3>SYuIZ5b>_*X0R_*K&f6V~ap`v)V zf^9Zb+TTxRbb5nI>-`x9jL_ zHU~YZ-4~m5D#V@xLnnwB!GtA2bm&wa3exOFB*P#k4f?TN56?10BDXb($hVrdhUEHS z=7|<|i>tdw2>l&kw&x8oJJh~y7$;IIT*Qkja{&Fd>>-{L#^IEZ`BA*~eK10fI;WCf z6SIr}QW=j6U9s5V!ZdsLyAJe##2|m9sSI*1e`dwQJP=vCY@FO`E>p)NePlbsvu{iJ z*3II*z>qm^GH_|s#ea;~k$m5g05QCxTHawqqb#d(D6I;Ol>$k1kf+N;EQh>Y?2aZ&7y49oR(V%p05H1 z$@UaM$xL^vXKx`{kgV!j<0xJsKL)E_pR4k9vuLK$lj+4_i7#era&1s}+v`FC{&~$i zJ`}PIPQmMn(9h&W)hFhaGdb9d$5ER8otinb-Hj%0`*= zvzHYHsnkAD;-oRt=s!Sad`hzP1h=2E9QwYq!00-}!|B2oNS)Z~x+u zs9{4#MJ>qY;KfC~DjB0b#!hKah>D7Rv9qLyy$=YE`cL6vJWW{Zp%v8ABwdT0K2lnF z#Y&D_gx8uA_#df0Dk?VP)VsE#^+Q{6bd3efn~#1_cLIgzVVkac2Bab1a#lno`=KBt z>xV57ayfYHVS-65^`tZuzj0!JbwU6~K)AnpB1W~ZhNCy8S!9~Des*vC_i()jApEn1 z0>q0C#bJ_h559bstbe|m__GI_rd8O1!msbjBYGbNQjFT3@LS`wB(v}sf<4ni+ne~44zcoiXC zq~yd67vO7G5yzNi6{wD=jZ8s&7ejop(&X@jAK~VOO&18p72yOxXxW?YnNy@9o{b*= zu%0HHlsZliqNUe_b8n1W=Y`h}#A`gX=>MvaXj&rJ;Qm#4szUC}cQ=W~@jRS;TW5{y z_GNbM$>lmq50j@qV*~MzOynNu0&Jw+&0Gt^ITFp4Jv$>4XRe{6=Y|Fe9hZ}`*+*TUluqBoYnsw?hA}YN~w-}{S(})#ggDsUsW%8I9hj3L) zt_U7_#X&q+A-OxEQdO8{@7w&4XT`4SPot9<2$MnnUw@WRuFcH*r+7~vZxwy~1s|W5 zd_2U*U+l+hhq3h7?q+-B5BPkm=<_f9`DxkbL;n1W^H~!lO#0PA)HHA2-uzj1>aXhW zQ}y>3_4iQyeWCt7RDXY0fB#N@k95;>f@wk1v2I&G{GuNY^}`GO@K8Vet{?s$OBaP$ zMpR=SorQ{QXul{reopE5p;2^-tyHMy&!}Q6<4);kQ*#Rmkb2kd5L8Gy;Hz@S`=lwi z{eChEAz@Cby6dDeD@dd>OU_zNUC%X6Jo5|Bi0E~yUg#lRV3}N0T5RroMqqFYiGXEM z<_#4&a;<&joL4j4L8BIi#G|me5B)_uX-89bhfnjP5P;?zl)V4FQ6a)8Np z<3dP5=629&H))~U-6oFs59ep0X5;nDH5+eg47f&j$TcoZ4XL95WTkCWtu^9$t)^5w zoldO6f6oD?eYQKZm^*CX3ql#SG;nG(^;n4#T$TaKLZ}Z$c5sh^-s8ID- zK{dY08a%)TU9%j#7p!xWxl)e3LN}?h$b`Ol206cCldfnD*q)nx1(DP5ox!iS`jr_` zu*GqwIEkVqypjVk_@Vhfcz&=O+!lfKj@HAY-roaLJbPJru1lZ)GDe*{tyG7z72U``xYZJn|0XNXAjA>et!dc*w@4ci)JKCCoaJ95?f$29j zu2+Zir`>SIsb8qoz?;(kZJDnhfLVPrwA6l(`t=c z!+z1go)F%A)2IaD%4ht9aqb(N7Idv$sn8S~F)9f?{ z?N+zb8s?{T7OxMcAy;kB`() zCCR(4ur4T8HTvg_IcUuHdnp}#PrPe1ew7K0xT5KCVk$p4qIq3#cyTkV{CYg&k*esD+ntx_E@RH^-oH%><3O8QX|J%jg;{0E%IOhtoSwFbU zmdyg`zD=a%-LlTus{*W$v5ciUoN30j$c3%XbAD?Rrn2=+vJ5|LjE5+zc26#$6+|Q$ z=o**dS&sS3&gkcGvCzU6LeZ~bS+qh-IK-Ywbd*Idq)cwD1maE>l~p;Yoaf1e__&xB zTUC?fGeF%vo64=U;@g|ge>lg{F zy#DcK&+&`WH<@TaI(I8AX-_QI*QsPDDs{FO=agyzD;lTCY+{y3>b|h=%bI!havygE zh?T{We@<0Z+}}O_^>2g$#@u;+Z>+p;3tLiwuzCQNnYo@U2h}E zmSm!r?rQS)=E%(ocEJ-pVIS~yva3IZXHsPuABJaAV-4EJ9au_Oavcq};NLdMy4+{o z`hqzgs>T6LcuRP#?Nps0=*Mqw{_r{d^7iI2yub>Cs%886$~yt_8Qijx!Pn##F1$Y5 zcBm9A=#vLZlAm}<9vqwRtl7kq2XPASglhh&DdwN1+dpycVYO`f=>n&|G+0QA`G6BQ z7W%bJ+VP}djVrYN1s6FZD}2nfT3dJUO<8eNRq_NUW!PCn{wLbjixT zwAZG@2|RgFV{jfvA7;mm(zSm0VFo{5USxLT<)=~>9ve$3j08_Y?UO7&PxQ}9Ttnh` zqy%7v$RGMWzcW_g`IO&>eI_v_cOt}5N@+||9Tjc8+s zq^=!@<--Li+dc~kd@WqCJ#q7ZP8O=rea^fH*MIe5FDpG+1)rXsQ@ZL$y~>TDAk$M( zp}@B2S=^U23hzi~3{Dm)3opmp(eop~*$)lrJ(fbWXh#V8Vw!Lc;LRA!Fm?w7*~{R+ z{onszN;$3nZxXG;7%JnpH}!}_LvM!U6&GHnb*MUiAhk1XszNG{=G&VXW^obbZ&2j< zQaN(Xh+B6=JPsNPWAu=xDEYXG+j>sSSt}rh%OdPDcOmiAfo;`Z*e-qv4Zq{eTy4~i&C47Zl z{5He*gUiMEU>&YGI=m}65*rI^UACBkgqcxpBOVPB!su zLfyT3`GmC*EAxhM5hM4?vq$fP2u?#2T_eJ~iM%VV^HLaPua07#Rh=RQlp5ZPRdR+1 z35eg%@nklu*ohlca+YQ0Mih=C`%~SrI8VvTXdErpis4GXt=l&l7}c@>II=cpdO*cS zpO%$;5v?$=)QG#vnNqzsQB^shEVDYPWItlx0QRC)h^5R_wHvMYf4vy5_lkXKuk3)< zFpL)xeW|byn(Np0qTOiEp=^lsL`Vd_1(%`AXboW(b4tgMeI^L>q*_8Y(U9Gb==_K| z;x5SMdAQI%O>_#a!}NVEU_ovcpRB^wWni&BU^`B<#W>0)I*|4x2c#AkX|he%tycHy z&rxf7alJx9;@g`VqYgM0*v()S!uJU?#DS-`D!w@Bac%qsu+u5G`1WQ(zZdxD$=`_C zR#XDaA`$>!@>>(37p_W|VzQn`Eq6%97T!lV7w@&)9KH`pnBOecOQd&bP`CGY^#FFJ zG~^V)w`qD8J1=5B%2NIL|M&m+pZ;(E-~adjm3|8FWS!j(I93`2P(!?Qx5%f9XxgHs zux@HH2?E3-n&}LL(IhwONi=?sz%EE5g3xDF{UUKSLsg?JdcS8K{7d(x3p|9=x+h!1 zfYAf4q7p8N(YTWBLMW%MZd;}|#3Tfj_t7O7tm5vgZ;n`d&A0y`ciIv_0Bvmu1lQEB zDIYWPOtUx7&h|C$yiIM}vzx%Y^QQ|8Jn|3GZ&Jek`@Z58UPcqn62ynfzt{Eax_)0G znwx5pFf-TOk&8E9p$&Pj8>nnnGkXtR&_Z=LGYE6%TsRtPPBoJa+mr(c3*LEn@as}= zNTnP!`1M}^hQuVg7A%|*6oNtzB?k!?nYK%dMc!g)=*4W4K1WWE&t``D)$X<|G;!)x z*X}i0M;fm|=0oyrx@tfJ7r18=%ePP%B65~%D8XWnN8=P{P46n>S&~NFj^?wC;eg4F z=Lk|>Gp_7Z^ugB%J0G5ZOaJYX{@Z2!x6Ar(e?|Xa3UZsJ$PRr^d_J&){%InwlqG@j zd6dW+2q?MWC{6!*@cbF>FeJz%7BHwx`Gmon=SXBo98xrkC-O!ulX5)~bV@U^w+c}L zQ`LtHn!POoN)gi3v`LTd>}K#MA`5v7<-Kg1m#C@~fDj}0AY!HBN2qE>G@y8`d>_2!wZ@)#;C6kL!FTHX=K(81qypSqy@p^g{)%@G0@t2a;d$PS9!(b0p|zHu}GJN?ZSc_2~Pt zWI-JUY%y~9a5tE5*pwEA3}+B5R+sg&RXhm}?jIcZVSiJi1cdboTbs!|cfw`7vkuR8 zc3HdK_#gY_r>JS ziit|?HM!?sBTIY^2^h8JY>3832pf)*Ow3L;^VEuA7m<{~#bJ0B1?Mq>MCqIQ{k4jF z2caN5Q}V6ODRMWvfZU>v8w^7SrzQ9$)zmF^aI#9?!$~RQE5XJ+jRIxgdS{KE7C77M zIDDv)x*RHX*8k6DJN-d#r`6xv+?lWDMO;mICX&GY6+E?RnxBiW=#j>YuVoN>j7~24 z2YJ?Z2~>ZhpX~w)3MNI|4V*vYx}x1YPg6VpNJkS z0*=c;;6m#dAnAE?cz7iV0{Jbyk450}X@Q-R8G+xrXQs!1W|CnQ$T z)r2KC+IIrwzWGR_oC!$3>xpGoO4A%#T{#p$ zPf*iui>+&Mj>g!&kK||vr-L~2EsuI{vu0&ghiNQVZWCGg0dPh3!893BQT4hrEWxe@ zgHY27t!6xpwv~oXiMg@S^z}z!Xr*>AHTR(SQ> zEYbcB(m?y=7fAaMrj+{X=aV2VQ1bzE*zza53r_(0MFHAhs2|hJ;ejTmS`p|=tfQ>A z6h|K_JY#1-m>3s1q{YvYd^esZFHkqYcbrNxAwpjpF;j1jr+}s~#mMvAdc4YBj<;ALwBa#6PjIu(PpU%j$&J@RL72s_VqAWp|Ry zgWBfmyVdZSfBZCvmvwE8DpvEo<3lv%b~h9sttNo#KcW57IIY|zql(r1qla1yG=I|3 zL6qs3uvlo{@qG)szgU!dL;oI9KQ6LyIrD}c*kn88tcN=Dkc zPaPHr)wCfOL`OO!)=QEGWqZ5l!lPNMS*6)aVmwm9qeVMiovu|e(@z*z*UwgmBA^KH zcC>)2Kta%%u%jqR*NQ4K_tPZy^JH)c-1KrZ2$PL63E9xQqP6slrHbG(o(a;9OqXNq ziY!H`1=(q*{(`MTnXvWIxLlfRzA6!&+wF)I?USSl z+Z6Pr>#98gI?`u!=_!)qtT`j-_tDd|&q8@@Vp9QkQ#k8-8+G)ZwPXLdKZoP3wJ;96 zvr%?@*hkk6tSwHtvmU;mM(QMEZR2P=+e{U?)TU(9&|<66_s*O7qy(bFEYScl84i4> zJNSm|E1>H?&G{M8Re{f?S8vCTbUjJNOH6-TSkvJ z$R|TIx|laGUfMj^+k0##zCP=zs}rw$%PW^HM#XcX=K=OFb=f=|s1F92C`Vazg;_id z__g#Xh;s7kJPs&+sM$=_$V%FSe0P2bQ(OAclhD$%P_tKQl$F#df;;cE)zCbGy@}Bh zG3&8^1QhI@_zRQ6P?e0f!TZRl_V|5dErO#|8g*C|XU>{}lTrAL#q+dB3?sh7lJs$u z1#KKBFc%ISDfnNPqea=Uni5X-JfU?}fytV*Pp~WDVf-M9eh!0ZlG$n~VZu>h081zJ zS}#(R$b`p%rA-r#Z7-ADFIjubLcIwhHL$6K2R;4A&tb&8{q7tn>w`Q`nfZUZ%u)D6 zb$((&122NU{w16Q2~~#EVHlc+4p&5$Z39>RTR6#Q#$0VKP}Q=S3%WOTZPsF8Ue<70 zsDqNq>s1~`rQ{zdUwRzl0w+yuLt8e$M%{u5Q1wuP^(-lFFOz2|iXEK8Q~$#r#)Cue z-@#2GrTSOYU`)wTOT_*fiZA7$6hx!$?)AKvL{Xs*%N!^r*F={l(I;i2hEYqI4)1lv zHy~7)lpenRLVxYU4ZuB%3O=j+p#oFNQib`FF%+vj6@POjRfFbB-{~*^@K zp?xL>&dOmbZUG{WLzYnZnK<@$;iiY?M3{5 zL5qgoW-;=ul2?Gy}+j2PyoYZ9-HRGtw6bX6R^7mr{5j4n-Sf|r9X$=hLn zsm4&ZN^&Jz>_`cg^rFhRd=Lw#S#DQU7a~zisc1&wVNyk2AhHjK4_8G<@4~g3Eidm0 zaW!6BQn+NCiu+PUOsad7y^og>#o;r6no>40V9IF|B0ix`@Nx>yj0uvKaeF{#!Ytw= zP;%_a203TU%TK*~D)JAfX@g;b7GapJ4%t{bX4M^fLVL`J+~ea&4rM$dGN?t~2hO9& zQ|@V{Cqp@Fy%eSKV&baw%*=2KC4e88i5Ha`7|L^!l#;gqz<-0)2^WwMU0L}G>=XRN zIRK2XZb&#SU89#@tzLc=a}&7!8!5DxnXu=MGkhxdIW*SLLmO4J*~$`i98r+#Q>02Z z?VuXnf$EU64$t8};I~>{z#f}^$Ke~lBiM7c#H7&e%$HFfVx}f&Df^>ksl8FwWQ0K| zogL_43+IQwnW5AqvVA9at83K$wYoMBXgxwhv^GDX3zG6e`5LqDnD6;ZRWV+~4 znw(@%iML>=Z4I&F=IAv0KJC3W%bC08uUzxjnh6#&qih^N1kjfr^FjLXH3Lqp=lN(; zqwmttgyzH?xFb($pT2gz4R4z=EYW9gj4C2_iAeb__alxlW$i-vb_NZ&6*I1)G}9tx4x zdmc`ZkCcWj)ceruY=3|m4{qABl9Q8@0bDfmBqP(6f^2RaA0D5~Z{3bZMT$qtD2|(f zwof9Jt^B>I?MC{6gT*5SRHyOEJuNZIj<<;%p1cI;jbnJ!ah6fRFBmRgACOPOB=huM z!PN6GmCiOCgbtCSzW1SvyCQzTIHv0wGkQ==WSGf@0G2fSQf_zJl1?vlNq;q_bXvP4 zJU*v#Nx#-E$(Xtf4|9`{IqoU087g zt5AAW$lLVk^ zvzuY|R4}|2JLGnfbFfB2av-m!9tMXHT>?g9Ow}7ifcYN9jR;Zn%cj*pA^)BvWDH`@ zY(@g)mjQ*Qbg^pUp7PZSNPAW+N2G?ItFMwNW;_!Noe;5zGs|)ob$~H-LN-v(CutHA z_~NQo=TRg#qw2)&ma1}18DG)U*vB zfiDjonE`pD+;yr1UYpC)ULWFwYAsYC_ZE~;7jU*BgW|PK{|NU(ID00ADjwAuaWHDY zYKGdP%#V`_Qsz}X>@<5P7UY=E!NoZ5#6~1#6h75Q0**O6In^#v(S=yIvr~u34NZW% zqPyzPDnPA9m`M`pq&^#CC)U0Kjd|zT>>EGp4QLJi-<_yO1ZKZ8u!s>PnuG zRud|2+wz>Gn5$h!QWECqh_?GTB925o>v~&LC{P;i5gUp%jz<(&@>xn0;&ndsfP+Q? zjC|*5w~RfkQmV&&b@eLz2kLv6cN{b9_8eg9cI~r(+BHAqU~u)gD<}XF{Eo@m*w}2Z zEIa=d5WYI$kYl}uRHn-!JAt+eVm>U1Z&wr8u{RJoC~@fGQ6OLO5BK)aCw_q!2$0qg z{e_N#tPpOElJqE;41~OHP#6%9q>&jdcoAkSbJQnjZLpe9I#6;8?7|-bcd%r85iv%x zD3YtD1Cj=a-<%v~pyYC7w`d|>x0Fg%KMUg4a6(&4Psl=9L$r-Y;z~i?l~LWtGrft; z`!nZcJYl-lL!-Yyy>nSdX5^wX(+*!WT*wL9tRlNl;}8NjSffK#kZ3dy5qv_ym- zx``VG)+)l{apok7O`)NW;xF`Ub%Jch&(r72y!7JSAxBz~hAdg;MMx(p|IFc4oren) z%N&I$?VQ3S;sgVh47Iu(C*z*?j=X7cpYfdx^izy{Ht_Z^Q{VR_dpwy1K}3=3Cgl5t zbqDX%lo>d$-(hjT=;Gahk^B5i2WTde|I*zmJ2LeNo~3p0g!HJ#oRAqui{3z-K&k_5 zGzx-rNt2LsnQQ~|#>XcTh}{Z3iaLX&bkeQaaS=VK&XiC7Gl^At_CrO~<&-gVv@#js z_s=OkVEB3{-rXqLNXPn5XgUe!R)sy((;DZ@y1R7b-V5@cv3o5I|&yNOuapzh<>9KMko4< zO~AxLJbh|_TGGhCeBoxo;>w&TFcrhXN~kas&=%ku*HNM8Eh#zKc2l=c&_P%!akwgH zhDuCdNW#R;?)m&vaXa@6dAeamCZQ+Kp+BJj5fjx|g{~7~awTVh8U1uho~M8$;&N0P zyB^9Y@h(8;oee}i594Iv?ZM$1iL?&2?bZ!$Fs*4Je~}t^{S8r+mbi{HOJnWcLa_ms z`4uLEvv#A**9Q3uIgb)rOoxWql#xmLANtNCKR{}eQ|K^4_jKh*{orScdL`mACx?fm zkD3nLFaT%;?<121@TWFWgp!qD-2l}jeu~%S)8sg?K@c40WRim;9OH{zOXpJ>xIl9J z4oyu4)8JI~+J>qCT?vo#0S6!W5Bu|9jn98=A?(t3+9A>JG3vTf&S;`dQ)q~*vw3KJ zJtea*)38;OMG7eztGWt_g)+XO$-x8qx*{W0YxN4Zv%>4mkH-6iaTDU$bR!;ZwNhRn zS9BNNO4omoRx+D|+c%|wj8Wy*t=omVZ>v!D6`=WEErc|~1$8FP8|J{FoI_F2A0s=* z;p)8H=Twq!uKpca94!epuB1}5W$~u`-c(buFKRTI%OW6Q{YjW10{4-$^`Rv2{sm2H z*xabkl{Vs}A184iyXYetr@4wmTcB01#P!-6ph>H*c)HZL>%3W$7+dYeZB25FGo?*S zvya%?>dGW_uCajsy}-eKs2uAztnw>JJt&*^zX7q9 zrTPmpTQ11zN|?HM@QR3~c4knm_AW#R`c+>89VC#03EtX&MSC$om+M=A6xXkldi(lz z32gpkvY!-UU=w($b*N!Q%eYUkBU%96P17(XmpZZ{V{P{-nKESo>X>}GwodVVJW1rs zi?_aDJ}T5I@~V+*z5sS5=%iKLO6fxL3iJ7nlky8Gs|~i1Qs{~`m1I=fV^9;;-t$Hj zs0ntBZIuTUv=Zhylm+Z*(5alS?e@Sv3qarJp>k>2z*@SUaF1;y;Yz@yuyUn-b{dbh zoNE9I0yp_P8_o-N4gMxRWy4PtNJlx=wuL@T5VylwkD~Si8kbk{js{2>BA6Xpcx~)x_&6 zbi`SXVkVIdhPX=wY&n3n4^1Prho4yPnX-mGGa|7Yk|2E7U>G&%@n=7bSR#i267wxA zH8pE(3kkHRuY{vkRJ>&M_pV2AeNM>fh|Ke002t={$L|fDUM|%$^sS&h( zMTqiKfcLAkQ<&%;b`br^*y3IZw<@>60!!DBN)?U>h44TIu&;o;tVRnRN*5flZqd1$ z9WiOqT9kC;3ROY9u+_h`{x6X!DT69J7&w+?PsP_A+D|?DBwQDUa(^^Ca;0h^F@yR= zVr=#6sjimylycRwihnWAEd%6cGFXBU-^=P=)FavQ7mz4G=#49{kJI#oGdQBspqz1>Gu ziQ7`-~SANstN>AcNx5j1}(@^8*ob=8W( z+^lh$<-we(OxdSP#kF<&cFS0VzhKNnAgp(VOLK%OpkbceuSi=XGQS2-f~jB+WD*r^ zd+(Qx59Eb|#@-JkS0Umr3Ebu|GJ;)H>fD$L|ekkr8 zY-aOr#l@*aYUc&cOBBVg0UdTtxODKuX2O+~!6TOKVAYvx)S?5rl5S7hv*$yMq&^R` z;BFa;_cftB5GKj17OK251652>^T82zj1$2{>9TzDn0G|LFMiIDE=uvoA8A!RZyw~c zgc6^;c(o5z&Z=^_s;T@X^y#Q$%852mF_8ypLI>qD#+j$LTgh=;Jj3t?0cH$_tKUz) zj)cS*hVF2%F8E7XynX9&B(8dgTbkOw79+b?neTGE`PIhDEpxZ1ebLaS z&1=qh%gOJrY3T>W*OvRG>`0)#=mUzbP~UV=%qN$Q4%#YZ<_+gMwW*b~G4?LRT?LS3B@q;9*L9nIsDBc+G)Z|F}fnV4G8#_v@0BozMua{~W zr^bVe6$lX6)Hneq7XM?Q-VWD()nyvo&F&y_**l zMG)z0nYI?SMAl7u&Fg>~(1)Iv!^A{vEsPU2h?5hfAZI0AvN3CwaO)MJsrk*FXG;%u z&%lGd!Cds1V6G8{MP@FhxOD;X3t5D!Q>5QAD2gH|;^qGQ=`RLhD<1p5?f>k(-2LU( z{T=V;B_)8H!%1e5(KHSGBac#Vz0+vSJG5rOGpapsd&1LFnBm|V@ZNFlfoV&FZzI^0 zJz!uSG*D}&NJ3jxJ#hozA+1qS{B_|BSr{>mGm309qe6Se+Q&jbgCxeTXvm|QNV`ks zFB4rGTICq)|Qh ztR6VgoWvTmC+gEm>0oHH(d-o4znxc0B*)lJsvTlGp<|96WM*AMg%AewGxN)d)WjHE ziNlF@ZMS*V&>fSp==Z*h;ru2*fgC>~R8UWbPPF_p|hXXX=& zV>XNN&|1@;H_*yud=z5@6xZUDxV-eS=x(Sw)|W3@6xFIYd8i2|Z{^-an{xjuZ7@CU z)Mq3&@D$2(j26TR`Uu<+Mlp+nG%M1m5lAbZsNW>hY4v1xDrPI%*pt-*ONAL_(`yJ6 z75RTRt2}{%b(2Fs3J=4)F_004pWh3tL>ez%KKsRvF;vQ8!H*X!R|S=pBVC)ZgdF)T z*jfO$D9C`KT0~))MtdCo8X?q?b0*zb*AQI?aRyg5e(VUs%}?X~yu*+FXsg z$h0nc)W)>f!+8S#%>j(H`-Syge#8lEDXXIIacJXH|5T5w4L#T=Og{6)hST<7ushB| z(RudVd-3x5{_}^=pLow-dcQv3+kf`p>EkQiinBF8Lh7yJb`uD9Tw&2I0niZ;eAVjp zLC=#HFT7g1l}WtxM$S|pJ(a26ISHvQEh7l*mIz;CpbDyrY1mh3*b$?tx#}Ht>!O(_ z6!#9enSn&H>hp;>I9Y>>k^#OR17HOv!K;_M z>Zzt2QZT}wl*ozmYoBNbFv|(m8Uy!*SrOu}Cxkggi7B$?vWiS>MI$X)qTag}f2$PU z%4&>qH)nt5HkiHZzdDurJgrVv8U#R^?Uc28de4X%8Il-#ICCThq+P)Q%EAo#>WR43nb(E%@KV4e}&83DSpt7U-ftWeatWYN9>Ud%UfvUu7w!TWb`& zIt>QrbIcD%>h(u5{1noi*Kj+@9`Ws6eaJ`N7A!l9r-@W5A|M(7Rl zTIPR~l{b}Op(t|{Z9B@YJIZdbtnEOz5Zon`Udr{3&wRg_C@V|T9vP9Sp$6>B5@Gru zj4_L$1v6AZs~$xHKDdl2xy9qXhhAr^i^+IJs&9(Ja`Oq*FZujXAlMN72=Rf$ zJ2vt1lW<&ET`-cP<_rFP#C>#>uNx!5VT?*f&T|NBUM|pb4*H!W0infVz%MQFNQ3J# zj2Fv%XbE6)_2|Ht*mCjMd2V&-6$w>v{i5=KPV&8bV%G4hYgGoeP*lzGWPyo4{6k^( zUs12TbfcPZKH`@XwRj>H0jK^5fq{&tT$tJVOqc&?e~UihwYyS>C40FQ=Vk=>trU(O z$spE4Pbz`f7TNnA$RY|#SW*deH&U|;BBe26iU<_2Yl?AA2~SnJMsciOq?C5tifyS5 z*eIEt4#@Ed7d()n#Ezh~h4XHC1k+-F)$Yl}v95bGGE9@`JWCjJ7sV)6qPYp+YlN=A zgL(4zFpB&^k{)gZasSoc26Ufo{1%Kh9=zDyFb>wn5nnl)39<}VUUPqvE=5KCV+RjD ze5ALL?05f_^m?v1?U2>$Rg~Pd@RWlU3s6drJ9&*j#2So;ppX~8c9-f zNaE{o8e$$tWPvb`3eQ*E`bJ-pPU*GK9$$=vQYrp?B*X6t$9>>|UOnh^3-EjTT&~E! z#YZFZBG13bpkgdbvLic~1%xu}*xZm)4XBVr$;4?&+~?5KN9b8!#YBo?Sn9AK+*);j z#!!QdTwB*t=h4$*94vrgLrxWScXZnEj|90CjG#+9ghOQt6<=do8!{w>-H>Msf9x@> zpg+fGmB{;qzv2HM6lqY3+s2Ynj6LltDzlef<#7kn-x(X;rmJ3!ZEwZuIqW+{Q3G6@h0b(Zh^@d__qz7gb?O$Fu=pRIUHn3jZ)FQv0UGgI)9HN`)#{`{ zw;#}b;sNUm4BshHp%iGeKOs!aF<~gnSp)Ih85S;N@&(i(hn-G`XaN7<>Cc1Q|2N!I zwIDyjJF-B=3|MKh+;!~#7_bqe@1|*Tg39MNSBJ%Z2ellK+Dfsm0ZMT7&-%q~j`Whl z(XKxf0P6%0zj3s5ok3J81>U6ULB#!~jeu01*(n%E=^wmjOvoz*c!nJVCw zhB8|lTlDQO&;k203KYgv`r}k04Bh|?*+)e6hx7n=3?w%gW3m+Q7&DLBb!pE<11&HE za}S022c7_UZ&G9kYypQ9&*lO-rGeHCUwcRP7_Sy9&4#Ks&IO(_ZD%4n7iXwuA~h#Y zM$RD##+$2A!1oVrL)U064^Yc-?DJ*~l*;JP`bY)99>bbnQ$oIVmiS@LdGdnHM?hGbPTZdi(R7{Nf~O;YX}Gm%G_!z8s-%(8Gr z{dc>(I}SZfkqS;|BG@`jC9jljt*rg@yzemmCQ1X@R~Aq`%R~(M6dvaRt_L2Qsej_3 zD$}slODDVQh5+))RzUYp9(gwm{6wye9u#$0O$x)syrL#b`lkyOe){WwoFVo=W z^^Hf*pT1b8;gqGb-%)NiF-^z9a6{2te32Kb9_{mjJ|QaZkP*DF6o4Ain6Xs(1sYY& zk_dpYQ!yY5Zk+=rM`&5-YM306U7`CE=00G~yMtd$keHHr(UmW)D6Ff@|76u>k3W1wNp=l`ba3V4<5Fd0~m`3zN7jZOylVEY?Pz-yYNeR5*`J2Q9OTN$Zw`$I$ym9fjsw%eTF{Bz`WSHQlm$# zff4S|_Z^hjtUj?00&MqWGOQcyH)(C}e_{2l&ns(JNjZ{4PQ9Ea9!S1A1w7SYf?{mPJj1qz^h zTp6L7iUVT!hPx45v&3cORlH15D9Nr&Ii-J-B-H*!3($Ux6_nk~ivaO>mL=1|G_4S* z6l)T;iw4p$kSFL^pG3zTo62~4O-y`PiB5i5aJHJA7tE6Iw}!NnTo}Md_xt3iX$xv^ znNJUL$EOO2!&oro)&RCH$%}<^C6F}{9T~vS1xZ5UBWc$pfJ=n({LrJBUKJY@uW5tc z7wX+s8Qm#P;JWceYMX+y!H0_293I#vce;RHZ}kvCm@d)Sp;ZTtbn?pU7^U=`7f)X8 zk-D#IW|3b#4Q-ggW2KFO@u)=}*r=46_E8Y6Y^Y43fG*0j9(`5wJTmLPsfKdy|EkwEHO8z)C7fB^%iqu6Y2O}$5Bh{(#$!JE*i(dKh zu^9p2S&*M3=@B{al5>apA3y@mgall-lR4q$y!PNBzkel25x zUpSo>VSMNj4F@yu=g5)E;eqDhxS7|H5BOxRWT5<3mK`hmOd%o3q|tZy@37@G zDtFj7+g_(_PRrwKBwUXF`T!pR&9f+8aH!6QayfO9Q0^tmbR0PSU4r8KZuStp=WG)W z=&VQ?WQ7~V`g?niJBIn8^aswE4X5^I>P@P#Goa>W+tFkZ#MtTBj$~y3fW=&zC-hkO z$uTr3RR9jHW$S>S12W(c&$4?o$HDU#kDqmQjS#uWR;ZG+7*fKTl7gaV@|D*S88~G^ z5Doqv>zK=HF>{HkC5MEUY(VZiCd;ACL%!UIrgwq?zAuf~ochhbWa>3kRD>u>Vs3&{61`~ddCp);RRN3KL5pY##knPV#lkWz3WFBNh)Ap$(fH23 zZf~w40$#0izbiCDy1~&jNtg4%VwU6y-}6h3(zcOr04)hHDqtU|QXc>sQ<$kft+6k* ztdC|m{d5_}K!*CGU?TnKDws90pn?csN z;?YAYi3$o4R?Vr=^;VdkGT*Y}F*E&_uTS#ddy0s6{pRLo>5KI2L*0b9*coxAmcO)o z)w?_bl{6uY(NT-|mZyO9YIMn6YUW{#-KZ3>=!|`2ifC84I6)llP}I{R_;ZCGQ1Px7 zQW8aMglsgMtBi3C6jIG?HnKLe@$plTLhE$NJdQApMz?{Y82d1#n1nPpk6@3}9V(#ctMACB4@t{3gm`86uwql(3NG^dPBB6V z$EDC8WPSEEHyih>&$PpQ6FL1|E2Njh#nW~&^BR0H%{X39gcZ?? zWj5=XMK9T}z9GPu;oDQ;SS2cR`~%H32JY32qn}wp#(2)9s$6W<1-e+O2xWt^J9}f0 zF}f9Xh*UhV1dm91bcqEbWdI!S#a$`U6M>%`e()kJn$jUK?(vm4PbQ>K5>{k_O`;a~ zcCbPK$jDeg`Sq|?GW-D)f2Wn}AqV_JJJdkR@mMhImhuY~r32+BYRk7vGqEF7TA>(* zGO&enR(g0tEdmeaeaZY&if=}9r7PrWPX#}~96>^II;dHe3e81ltHW#KIAQ}81hjF9 zY{24LW9f^wHb&n%pbMwSw1_|fbKy%~&pt|D8m2fE&gzay>IjhrlMq;w9OFzFsASl~ zqR*-MlK+=X?s;!Hbes5vu|X#C&yzFYd_Y&r&7N5e-O5mKi;pIFS#led zc7148J{{WRhy2iC^75Qg#3pOpQyN$A=}h-9(-Wt%SDm>n9de(c?I_3r`O@_7vulku zK7HtFn5IF+m{xT(U?VRQ+ZpSQqxks8*mp7(^QoQ4%3hCSMP19?cJ~_Q{|Y2=$Lw(P zQ$UWX3~ZzWPYo;!6>5~6oI0ikm3!Z(+;gfI+8m4sZVT2eBs;6h1tj@faTb{me(aBD zoz7eBJQ>F+ma=_4$xngqSXVRAwone^78uyjlWcj#a=Q*>yIPvA5xNLwZp3g@Ki~+| z4`u~H_Gqo0t_3A}CNYp;BpSkmN6t?B!uWoJh@*lCk)KkqK`HIn(B1*!u}|uBiYkF{ ztM1r}BCmQ>Y_1B}XefgQ?c8o1Ta;*hVPR!&rtZ-(IO^Q`-knbyMJZJrDdV` zf{U%OIL1KLNaC?eV^j=Q3bBxi5DTe{;PjDVI2FO0v=AJQTq}$f$oqAqfxV@$m%%5+ zSGi71m72|@WNJq{@kLG5s4FwE2qawS3o!m+>aDas~`FiZ$F z@3XG}rH|wSVbfn;k^|nAFcMUn*fzq`KXH)XZUH@gc+pA?W;W&U$)%>oMCpH31(X8& zQSr@*k3}xqr|`T3R8+s85!bDqKDkwh=R@!3-DkUdzuMRk#yT#vvef+xYX7QK%+jaY zR1Dk7(@8K&U_pVUKITHJCI*2S-MaC&EHT9bqRbRwOeVhuaN<%a#cPl`K>dPglWls^ zVWIq~K`!ypL&}3Lzwj2#|)RSEVa3YTHpv^d?p?5>s)m?7;OF%Bb6^5tm^p z9hyJAlWN7d9#Fkip!NOPay}~8r()GT;is@p2}a99iq%PO)`K8E9z1*g=<(af&;CN; zN{GvuEa|*(TQna*fi$9SS%$&_9VJ5fFyH`_QicNaDrA2m9JwCBQ<(x0K!!FXr7>{4 z9BLaP4dro>LmdR-!_a8kV6B|dL%DC?m0Or0sR(`?V#eF7K-Zk{w$nKFr*Rv zVC&0?_yrUtn~Ch<=R(RABv zFG>n)Eh4PMNU1H6F0{5ff9*Gjn4q9<#(oDmnK>Q%QOBG%#^NI{2Nin5t0uRscyJQw z&NOr6$eLywM$je7kCk&nQ~ zh%35{R+}Ujy6!8<@(#!LN0_A(B?H!UM74qSd7>PlycACV`JNF^ACC9G1;GM#fNW?u z2+@N@$fSj3$u2DC$0M|`j6rDjANjL(b}HUvgie*6@b{)(D99Te7<>#?_hr{=p4(^% zJnWNjl=|su)%^52O+99_Wv=@PntjQy&AlWiIRBSyv{coZQOWFcrRaBafALHRJ9};Q zP0c2MSnwqACm2cnSIW0ts*j)TlsN6v>jaJYbUlG+6x2zGkqRV4^0CW+naiJ7L#Zl{Uad;mr&s6pm7#=zrz@CA7^kf|dgYoyQ_=FO zpyJP6#PhsFo)TpDh}O5XZlEXD&ml0N@~_M?6X()$qdj^Ps6QResJPrPdl962J|@j6 zk^g-ZW*gK8qx*;{pjEK^+aQH%<^y1?!^!jXF;J3@9%pEWekzP0g%H)A&K^BthQ;#B6Qb1{Gio)LJ$}w%e5tt+-K{i-m&r-i$rSxn zgWm62iLsQ>3+Y?M+_GXoT@uC_*F~8}I#u!K-2cE6=oV$H^KZ3GY|FV6;2naRxx>Vd zM2Dikt`xpitXzlwJ!@xNASf+LuBfz}HP(WccWD_CeXQi5#S&nyL;WXZ(&x^0^!Go1-W<6I;-3PHMXX^v8+?Qe|!A+g}3|6+xzRYhu&|y`@ec`58-th zq^JGEG@SJ3VcZ8G4zh8EQPr3_{{mlr@$tI5VRJTx9LuzW&q{k)d`q=&8jvlIb8(`F zChh1c(_y9V`?nu%kifrOXRg(`E|miC_cjtX$1DI!EhmEXSIk3D zN*V~!;H@ed$`T*L66Mu{?o&_-y4JM(lVT}+l7Tnui)hj7?Ra{K2Lx8C(%Uq*Ku~(B}bm3QK#ro ztJKiNMnyBdZ{A`DW4t9;m^(LnIL6JRq37MiW4nRG6ZE~-U;Q-(K`gKtq)Nd180s*ebFhO^C+PGDtf_-d_?19iQ}z3^rTkX6Y zObC{lMxN(Zub7;+-HPYIFXr1#t5x}eEAdr5Z;G!D`O#n?m6fzxRxw2ZjKNs7e8iFD zLZ;d6YKTsJoHAZ@ub|BI_B`uJTC)hprAhBdDMo0yf<2+*EiXYl>oOpx(N$ z4R%Z1P}f@4TxX??hNpH~Mle)zM!63Y*fM|v7)CygWjrfSozZfW(6Z-sEHtEZlP2)q zL{1fs#r1BNGQLK_$=H-36eAf3U0Tj0a4p9?FU693UVp3H1xE>a)S@SSO}aC=R(#jn zsu*B5zK{X#SM5hh3SA6RC4??&lx5JGnTirY>j<-g1X`Dh&?mt1JV*=ivl1BeOlgOs zNPAfKENMnh>0tEzG)v_sXnw&ZVYqrb_q5+AO%|aqb@LG=K35`VvqbAgqM@8npv|Ox z;LI1#_jdPppFe{~^Iu;)HoXYR`WIs*`?;mu#6ey}%fm2!PT7@t5@v2}y(rF&g55{O z-=z*j!Gn16GI+lX(_kXnYY869vqSx5E*u`Sbj*KQK7y^I*YxMLn=`{RcXDqg$j<_!(T|J1$Gm#)$OE_=;R)@??dWza1 zt(NYeTBLT?>MOUvY(uMHySCyN6;-Ob@qT)WwMs6pdGf#tU-ZEGzGr>ky9k2?o)hyp z$cN~bV^zVw+R>D?!-DDLO`O>@D$2@!80Xfg^ z3@EfK0Dy8&$@pzM1LR`J|5434HzQ2ozHHML?M@ty+v2Jep4)}hS{MOBacG8zX+Rm2 zFnZ9i;riro1i16{^>7=zO_jWVh(MzRKz$+bTn&6-eW|5h419bfWG-cnDsQ-zLaImr1rslR&}xdGY9y-$W^jk~Qr28D zT)}^2j44`}fy3GYx>|lI1B8UmA`(|PQASSUlfAbTpOJQUz(HhW&7R>&o0I#x+BW5a znJgr`jgcvlSLl$OfD&M#jR18`;j7up1xTJ1rAd1Yt8MOTd){u24fC|-TAJ0Ht3F(M z{V6-Q9TdLbI8W8fmf?>qjd`^^4S)}WTwHrQJNJxxP$PDEmBdIp_7q`G=ki^)bsQ*$ zvW24Bi}Qvmk8Aq+Jf_gYMijaU5cNZ!vP@{DWmGRT(wHJZx<~xvr$)Pwf{<$k@T8@M z1E{y9^#ah>0M-`oCkvx4S&Kc7e@@2B>`9Vku8+Sa$ALMd@`+bZsKHOq_xGPaefx6v zmtXfqtu(hH15;ep0%WRZuES9laHW}u$^*A1N*iZbOZr}m?Hw9>TL4OZ*2gVey>OQR zo%{O+uk-e;^fs(kHSq!Hh{Mi!UV7jO6yGs#5V$Wi2XbY2BCoi@ibH?5bW9UQq=+Ye ziaETqC1uIMw++q7JDG(Mg^g5i8Z=>-M^H{m9e5-5o-&X`s#P5Hj@?=X+LB8&E`qMk z(HR$&Q5_x#lddsvLFjqh+Nn!cWm4Fj%#$of#vE=gAbGI%Va2It?!H4YK*}!(8Ywe( z&E$^+Sk#UbL0pR73x}o!Q#lnI1fvGS0EUetM#oz&m}y^TIWYDpsbJRuXx@3SSPb%v z!f$3Io5$?9Gs-?msx^PHxRwde-mb;}m&54XZcKz~}1QN-Px-bNY?0d5jEtm>2@3#z%_qhk95G!zh0%BM_5H$EZ8jEFgDCrLE^A8_1WOhbRJBj%2og+pq81&;z|ap zVpggmb6;D}%k{+?Y+1SiD-X@ITD@7?mMbBC7_#Cj+PY;pD<2+Y-k|ivl z3lT~e z|FI8dv8cBijuqt0LgcA~OAw(WRyx zi`o&CWgt->Ap~76f5m{`h3MNUZ9rPm*Usj2rT$K&Z`6;2b9BF zH-#3x;?Pn+kG%~3mV|M~RI+r@FZ@>5I5i#GidKj=6xf9=t~8;SuAtT6DV3K96{*u> zsE7}A)ERQ{XRml}3=6b#`4E{w)oC!iY7rAV+}sGegOVWQ5raY9h<%c-O`0@BCJYMv zuG6Kj>I9&WTJX>PKx(h(MeuW&!u$UN#-n{TTE;nMe?%^gBXgs6=rRAP_sI$B{XEBQ zU_O&woY69ZeAWm2Sd!^&-dtU^xfXO2nnJUes0ZKByZMLN<{wiPfSf*TgziXI#_M&yphIQr1!7y(!fF$L3_Bandj3CBjZ;+OZ91M9!tAtYmg)NN6_84%O{6!{2-E9 zIL+`in7W>2#S;#I?)}HFFX3pwTNs5+oajUgAtAd%D=ac26o9S?)Uc6ph#Tg#3+<-0 z5q3r%hxr0Y9(w%GGgNEnF@FrLyer|Q5zk^+^deMQg|A&gihJ?u)$&XT+QqkS*41O0 zdP6;ngr6s)PIjehWG!&zW^Zf%vWnFU-i*JnsS#SGEmR%?`o)M=?b+JiKh=--W`2s6 zYWNQtEm`IVz7;YWLzz-kp}&Ma#UJX4EV@)knZqnE(glZ$dXQ-ov@Q80TiW|G`YPli#%M@MOYG|cMgnTJFq25n_BXt~8v{-`xE=yK7P zOdGmdJx}--qJW-bFc)=Yq;zVXHJJGJ)!hT*-E8de_=w-y^GQW>|=-sN7I(yOrdVZt9<-#E0j{AcvPJW>!Eq zOmw!{+O${0jl zz`Hnyk+?L4@g`^8yl);PdBQbtXfe+OKxo*W2Lp69euE84Ez@)SV#GH-+bhxzy(P;L;Eg%()v8u;GLd~)v8{3CLRkK zz1CC}fp47b+)oiws2ipCm>;b-U8b>XO;+9?tIU4Y!IYqfe}#fWPB5`;U2sHlPj{36eCMS6kmLBVglTTLv6uaa>Xu>3#fv$IoPJ~6H z%&1`ov@ox7brb1H$xFB3M?Dolp{Ie9O<@URcnJzwRGdhkcaG_a=Uo?G=t<%9A+N}b ztkbOe1SB^OnHl|^|vAwyuS!A^{ zRk)9m6SCi={FfZ<2$Q>!q!YU?GT>S11C>|Q0{*~H6caTG(K?Z+Y92(gL3gND(vGKP>aOlo2sIWxXx}b?29nKEV z7?bnhzXy6wLL4Cau1AhCJvLI^N0WSVE-Z~?3OBasm zJV)siutzDpX|o0J?7u$UYmi<+n{aN{3FkqaQQ9)&+56t~HF*3!x-5T*!+i7d@^#Jg zpH3G6j6E;xNzb?8M@3#MsdC7jmGb&{l$snvF3>6b2)HnIxEbILxpq zCfuqBj8)_}UR^x#C`}ef>I&(XEGZ}a`U#C!#wkVzC<0IG#j;5&c?G*tsJ9L<4lr<^ z(j;CTs(GpKTe*MOAE}YBiZOKYh?1sQS_o>qCmAP{E7>#|dhAt$MiDr_7toH}`}7UF zuk5>m<1jdRFdce(h3A6v(FS-gjXUYA6h9b`if`)dDYd3J-YN{XL^#FEMj~Z@;x` zmZy1-$F;gpymiI=pAdU`ib=(^$y=S2Ctvhn&CA?3DNkWrB(!y;2L>SmbHKm=Vndxp z@JN!hFF$d>5<-rmmYvfH=R>-1A(yh>J&Pb#Xt5gR=uc#$8?<$qQeBn!yCIR83$rDJ zI@VIVHbmY%hrvDZ+zPY5gp(i<<74|{{4D}DQTVGjSIY-2;}sH}HGqMn zc888J&I~J}ou(TLcD#3VuNebxeDje2;>&{F$=N#{UUs4`MNVn)t4^9{HV2-Dta8lE zNd&%)65f!Fd$KqsdRy+2&L*DGf`c7L;bN5d>11bcl7@MJs$R2CDt;)d4aGCJSc@`9 zFI@!IdxYN=YV2a@V&snQ8N~ldOR}r5u23F&WuyJEWCℑp3xf1zx;?2_FMkt-)(~ z@19c~f@BKVg^tq8F_(3}4rPJi$aJSDa*_%Bq2SQEA}@8$Nq=5%9*~SwvTcLkWVM)DKcqn`)~sgKxM~!%z&(J< zdX6WRCMa$pxd}XRr4e)ha5-Y7Gv?WdT+32}?#M}7${Rm>42&wKg?_{~9d+6g4Jt)e z%K~~+yaS)m%USn^^C(-QR?lAqDfAbZm0Ueyp!+;X_ZC4gsqHe%iu{<}(h`XbwpgFm z;bciM6JvZ1UeT{DMe*>l_(;@R35jul9x>pEPFRe8>mwFV(XO?akl#VH3dTv`&zcb$ zU939l6;%e%uGVc8aJ01YY5;80bw2!6VwrLTx??{LQL>d$)H%zHL%lmhq%-dZ26xj< z8_ZX8)uVY$!-j9NaMT&+ABNtq`%j;Ua7;ZdO{*(g9n>FC^hO!K=?cFv_C%`(QFIr( z+l_%Hiz@d!vd=2Zy>IUBd;DU|^vM87v|mLx?x`tLC1XN&_gf5qiQ^+cT1gd>sBq79;u*133fHg_sC=?`x~a{e?DiN71WU zpadZV;(`xoU@fQE?W*;o^U&v8JC1%K>(-Xhyk_P7fjFs*iD~+g2m&$mjF=G5Q}ZW> zbBQ(kV?`=}#Sts|>2!C}VI$;-Sg**HmTQbtL6Ni^x^mhwMQ=x&vo})7zxRwB&7?ZX z=D>Q*RH6!Fo(4(7X$t3}9JBqdS5n8wKQ(G#L1Sd1#=u17xJ0%Ty+(*$&JN)crQ^59F-#7H;>kQT>N_G8 z+3|!N;e=!)5~EfrYLF)kk!{KLhF)$o_>UsR?IcVoquPI1S#R}zQ1&2e+Vj(56QP%> z5hKXz!X1%_j*yVhQ~aYEyYP~qduD}3DqhXS&%&+Cn2*aO5!0^=s-V>^N-dj57)Y;2 z1#S+qFy7U|OK9@y9tQ}*h?p9_d6H>GKtXWG7S(dbq7@8Od|)y96vCVfhy2zq38k07G@8kp&pE2)elu^ zr>oc2RKH5;+cP{J@z8W|IL$rtX{I|6qPv_AP%B0raFH3uLo5QlRc$lKh~B$Z6z;3YYdl56G#%!Gr@{``&Of zS)e4M4smdL+7>|t;AY32(n$jVX6O~JR+{X{nTg177ulCkIi#CWlzPgy)^!+!Vtzm2 z;(GW4qCT36Te%B`4Y`5eGsW`mcpuMT8Km@uhd=$>nIR*i(dEue2DE{yGqJ2F z$i27hsfUROvZZ6q7xq?FH^&GWlrTaDCXXC&V`Z>|Om zCcu&~hQ29qfTVq$(Lj7wSfYmm(xLns&a$fA=^k`d3wXI`SyRLYSR!1?^+_?3QUoBM zvTl{DfG`gkkk5hP4M46=w$Gl3q@?7iWTQxq1;RK?&?rIFz3-uGlTNXOHzn6Qo$8!@ zf>;(tdioZzEUZ=At)&ZVVYky1{NhusO)?=XhUyrk+)mgN83~4sq^+4F%vy)57{e^% zqc}N7tw7!nk<2Soja7x*ixH2p6#CxSnl|~eW-2$ny*QmN8jZuG} zLSY;bT;5!Tvl+=39}-i(yOq@--;aWbyd}!`{r7LBr?H6br+i0urI+AcGnCDJ!G$T^ zWY6H~yZVqc65-=L&3(t<5d{p{CR{Ag2=1YCkGSiq`&<7+aBwE#uZdQ)%K#z)sSS=6mh_3ygLqOOgRe`>KIkAhPS4r!A=D9$Vk zS(zr5v!zxTeL_2JY}B8Ly9{%YNuWIRy+jL$E6LHo+s)ygr5vpos07dl$sJtSi-DzK zE&`_5W}uEmA-;=P0CtQjdnMXipVqN6poXR8h!qf^X2_d+92|{?Lfi3^FdkZSCgNfQ zOc0F#m9Zlp%G89L`$AGCBFvn)P@Cb7B-7gFln{?2Avuw*BwFd3_@xw@92dzrcAS}Z zvm>SlpBZ!Lw<^_J00hwoq!d_&jl6s4G4JiYc+kg6db=_!SVUrSA%SMQbaqat5QBE9 zKyh)BE3MD4(O2t9j*OX+7o9*yMJ!6hSk%zWKFsK4w1t0t@K{%?kBiy7tA zEH|zUvGATjRTZRyPZ@}4k-n!HXVp>c1iT14Z}sjqH%<|# zMA_OpAD~4`^$5i+VnwJHsuc~?TwWY-= zVlst}x^)3}L+HehA_s&;9}){4iqHZv$22@Sqn1Ee9qA1%j?383T%KNDtVYZw_z>py zCYaZstSMrlXqAl}>KdUu%4d^F6$xlLUK0F?oG=qt{jlN(EnYj-L(s-!OkBhgaxsjI z^9qmU45pH1GV}2wO-BAGI%R{qFs2BhK$F9ig3Pg~3yrVE1bZlQK24U?8|n%K15ajp z98J_aOqcV;sppR{Oyn{iVLB`Qcuj%gqrt^MM3Y@VSgDJ$3HfdrfJzyr!%$>-!YVBP zm}<%~hTUBZpA~WTC(pY(36DKGWcS`&&GIxLS0eF(#gFPnHR===+{b-5N>I)&ntSw> zL?7@kZWYr|{O<&i6sHQejX1N?V)B3r5lwlRBhsmah} zW>GAGYRMI=$)YW)IV&2-Xoc-e_Z@?AshGPkZ!PAk>I-8|9$lGs+O^O{9hhdVrdDFs z-q4r0VeBdw0dU-q68U6JAYJMAJ-z#9&-Wh>>HUW<|BPbF2Au3T4$x27PvPyVaxelo zkC%bB-6OAaiYPl-ve1fq;P}hh2>rf3JOQ##X}$DW$Q=uOd&30evj@|hb^RI?!wEI9 zN_odL)Kt3`PPW4dM#rNPAA7uJHAZ>aJycGhftLA6$hC35(xvfnqs0n&veN6>=-GcL zHZ08gJ{;rYV8s=QUb~-aEzP^dSpzO~yV(Ezg7-^5J;mShFXOnuPp0S|ypj*GS0*GC z#y~%s?xfCuRC*m+Y{`pq_mN(UOmHdnoW?P$vVk>jd#}hJ*L923@#E@Hn_pYk$X>}e zQig$2w@A;^j?F=@MMxgL&Q4@=rc_5BRP zjojT}yt(hXm&5rX9H($fr~g%qk3cxaiiC5%YYJJ&#-H#lOUL&pbO1c~vJJ9C=-;|A zSfD|YK<&G%-a}^O2)ZYJZuWT@YdsH&sdY~!b3A~Kj{Bo9##5iY-<= zz}XqV7kUu~S6lcOc!1g08(s!t6MBMpD(INb^Ar`1QsDjA!lS&+DJ~9~jKwZDy+`p5 z4z*tqS?jTiM2zK}DJ0(u?CLP-c7L?oKQvTxdLV1y)@3Wo z8(Va&2}dH4kym`fpSnvhB_J;7hL#o-B`4POv;*j#okEVz$I_ha?%L59I%M)NEi*VC zY~SCHfuI*B+xPy340fRsIyoA2=opjwAZ5tW^Ayhx{)+`!eo6&YV-J65{N~*(O7izITIo!$03EcF&P5&v;j!X%}>1W z0V-$kg@KWo%?fha`~HH$Z*ZVxcJ&J4rCAv@?0sNsHj&-Q##Nk0vAnt^`*GNZ7o=m| z1?)mUN)CzKnyW8%hpX7zqqay6rtN~UX^w|RdHOp4Bq;L5(BHk|LyEgunBQ`N#=M9; zZ8>`3aY|J*JkaC)OKHZ+yp9^)W>drwV48?~UYuw<{D9aIGYb^Pcvri^kq3LlGaOK` z{Ne1!8b{LN1nPdpU6Lo1BO`dp!XJnEsh}-lhTe{cHV|84B$L-UK~cIkoLrL{3w@1U zA@F2wnr=g==Xo;mqdtXIcym=!I*-LwjiH^Ljq6x7CUWL1byzsU^88q5m|^_!dCU3qT97~u13fGf8& zXF?+W4jK)=`A9kF=l+Mzot`JU>Ygn=ywlfJ-nF8aQIhA$e7JSXZll9f&XacXdvAOD zrgz_%DEUTK%#(Ic&NRgx=xp7BUP|q~KCOW2ue1i7mN|en*{xgUzU+W@1wBITz6?k4 zqkb4YlU{J-%^&q}Dy8&|juehW{frY`=RU*^(}-uivKkZ9O_hSW$e1r#79P95o^_3a ztxfG`vDz~`6b)W9IFSeO2FD7}EyLRhB7g{k%p$FB+I5T=7b-VW2Tn0s6B{m5o68VS1#rj8QmEHL~ z0F26m%DQLT-^CtxtQehI^2$=w)&dRbX8qClSX`oHHK*S1HtO*e(gOR+w~7c9uiuQc z8Zoa92Ko@!qfu6Y*BWt5Ws9Ocvj?r zt90f+wvtlVt26UAXnn07v)!e9_uSEUDGkD4iV=Q_HZ9mOd-gI=RvD+tadFD}e-WWm zhK63_)vV*UMBZN#GPQA|Bz~#IN9`>rOShpI+rfKj9F))%pb8*8{Yed3!c&2!ewrpH zZ+U9x!$1dqHDZgsliIY)VYXR7HyF{!HMS)R71(FVJdlK-5MyW(K&5~r(I-~#XgU&Y zXEc?Y-0EMGxh4a!l-YKH!epOW%ty!+3{LsuM@CBT>`a%&%(n0APZMKs@#b)&yUoum=d=NC{2@ubjqeYOsD%cM8;^P5_zLM_72nF)K=?j%X>&Q z?Fxl}HRcMA30Gel{GauT5(DWgC@6o+Wx;w%77FrPawJp&l`C1#3tDfqk>5p3RXoz`5P5B<@C=hJ0rGo& zcv=R1Nvlf|aE+Im1g7pW_6t$~fA?9C&pm6uhguz}AT9Okz5`I4h0>S)nDD<(5}jK8 zg(5VL1EZc$CibI;i7ohmm&*VAAOHP-_x5Lge3X$Dr0}~zG2#mhuDJ(n@fc&hv6S*O zSz?`$%4l%qn%(KpqufeXDGjzSa=4+0ZwmakcO0Y{*@;e_qj8?ki8l>=EX)Si%H6`t z$|%*>ZIZTde(0ua%xan6Ozk<==pUy31m&RpLwE&e10Y0pBR|Tak+qU??*2pn}OzaEzLVx@!N(t~Z6uQ5vn zWwFRY0cV-M`E6|8@X+=FJafx7Fp10|iN!YVAKhf4crc(7;IrUlFJNJYf(1qh^3c?j zB0xH<3Y`m^(W9btfe9V$ePoR_YXGMy2U zQ1s+%4e0pCNylPeNdMM}ex(0LR32;V30f5j0p~Pb^|Ou%;iP!yp>X9jyU; z(eqm#vS|;*#6I&D13q>BLy z=fU1-JT_jYFR552Lj=Uifa*<_s13#VRBhIbj%aVkVLGn8aKu2^=_)I4TDNfJsaZHx zF0K0omXduRTKdF4FRxfWhpo;{LUEgv2M!zH-K-uhaH`edajn*q#~8!tWW$XOo~e|zVTR+4!(@Z^ zvD~;=Kc++^4_;GPcP*p&p!yPh8q0m$FLzp&-UQL&E%c2pzHR_m8-LNLkOre=7)|Oi zfT|c|4!OcK=(8q*;*i5dKou_F0n9;5YVm<*)XAdcq$a@%K7Zpi%V! zKLPo~L^YVKu?`x0GqkcslWLP{47|VU$A}oHIPszch-qqOQudZ{9@448qZawgcs#Rv zTOFv2mj(T)qpEmE;>{Wu##mfRCqg*0qAQOV4*7Nc`Tsp5jDajOED&q z18$X)1FiFLFb!>N*gYVMAQe>~KdL_skHT}Jr2^F~@S}WYO9ON&4ObLbg4;S6AGOmb z$X+Wo3VM&{;7{A4L=CY%nfZCvkAstqb70I~5O~e>U_t?I5tz(3G7lL5kWViX($WaKmUo~9 zdbGgL32*Y6JX`{gbRIB2@TiLkC8I?UN)Y%W!jQMj$_o0mAY1odeFcl*nS3&k0s<}P z0|#Kwg|u17+4d~O{LeTTdL&^=J{fPcNR&Pef{AX$yNW6dI<5gM4g5LL6d2-3n2kwr zzBXJRa>!5Ny5=wQS;C4`7-7DQ!~B%#E@eRs$DtqD8}NwdK;$DXTfwzJV7Z7&P>Uhf z0ruSu%^0A@lz=_L3Zo)nd{J}+%ptm8U=UOr0;bQkF!y-z7=pFb(2(P(FO4T^Ijrpb$Wy^fRslV;n@G2fG zLURpvo+C5SkzP~Ve53vgC@+VC(4LA$ZQN&A{=B_8VYTlvzSnj$5_wIugvRKM#^HyB zW7B4?A6&a7t40)6k(l00jOze_|hv3?=`C>!x#LV=J@vU zDV>&zL+9y;s^z7&50*NRwp(@qaN#Tq*TghT=Z1^vYx5R(M@EVCW>>;5!NhW+^4NHO z4c=J}qVGxt|Mj2$FHDMX2#XdSlb1KWK;Sg|*MI)sU!gDzIXKu{ACJ|4{pbIKu1@%t z28RIH1?K@I6%TxLj)C`z2z2P@xj&wfzz$Dr8pCA^Ow2?IcPTt~7>}dnL{k7!_Z|n# z@@Oky)PZxXN5LW>S8!!3BzwWICNy^{73VT#e?f9R&(Y2TrkQ452d*T%kFIoEfbjuL z3gsl2+L-=0@#9?XyfKFzv+aR&NPhDs))P|cG3`yCeVw{@oL;?*ic&K6I$9G$(tp47M68-LT%%3X zE~->a+~|X+o+p!}e(FY}H7Ad1UsQEhPF+^0n7G!Sr=3iNXq9OKoAFQ*u@Q!v!H4~% zepy=w|XZ zB2{wXQKUJd+6}b;TRJ6PM%uM-WcsD5n?PSJsR>0WW=sYhQru;3D@a$!)Hv{o7@MMx zLdz(aBfhD?9~__1xW9 zMr!x0aAX%P_KpkfVfHM^AI}&0sTuTZiS@p_hnBRv%idK$ec3_+IPR1O+{U@jbarL+cgEr=qT_0yz981qAQ5jv*md zR*F5KvrzZED|VSRNhV^8ARSZ26;85OenCqTLup4u?LnUW9Dbls6_|wN&yL8kt9Z5Z z?QJrVk}~#z5CKIb0vReVUW3{gAzC!R5~<9r2q0u?q3QG$}_2E2cM{ z=bfUjt`*MY<41iUn9LR>zM?Xb`%1~uq!`X2gVLT*N)vtwO5$IF921h)aZrR~D=K!e z>*s0DOVY>mYOz(Sc0{}fMiuyN>89s7#;aYXMzvRQm>a`tCs8qQMcJC%o5%401bIcS zO&i7vHeF=XVEU-?YZz&RdPZIj!V|5qI6YdSgPN;v@|w_!)M=-Z+H?Q{0gQwIN^Pkf zWqbzmRapS9E65C$YqM+f>O>@x z+SsMcvdDNU{x*qe^<&aF5gjY!uB1JR9@=v?h+@xbt!s7dZ?*T0Ie0<%R3~dj^C@m{ zk*7+i+Y2F>E(GuoRc@hfA?ni7a5aYi^F=m|PN*kJlH5p0>H~e4((_a$g#l)pwH8{I zBCXSc(i(wj43WQ+lPR)e=-iTcFKbzAfb45YE?{J!{qRQ8ONuTwEH%zKldX7$2-Ow5 zaIKr9$0D``TErMv#_I3#2TBKHisBydJ-K?ymWQ)2n!vd%Rout0lg4#}8~D`!fEhqa z_Zj6yT1O73YG&}yPmWr9Q0~YwBk`e>WJVO&CPo$MW&nwwi2Nskc}*6@E4>4ytj<3i zde29HgVzea-Q@1ymEe~4M46Aek)ih!iwb3FI0BqIgnD$%4L#0+ql-Gy0AQ_|k}w&> zB#rwRkBq~o6$*cSnVl{MI}>?LC3)*=5>obhx}?s}nP2B&5@mL}9rf#Fa*|zqE-aNj zC&LR^oIw2sR=E{;H@oG;<>Q2;vc-_Nj8aYljBsPr!u9;fDHFu6PB|DceRCu@z>9R^ z6*rus{ly(ivGk`=lB69P`#YLw*U=eZK6S>Yw8NeEJj!1OxX=&$!PsA*(q!@=Cu=CZ z69IAVr6$dUu`}9?t1Unp<#c+|GSAa5<9gdM&E87OHEHt}yy5gx;XlPw1?ptTx+hOs5y=T5=)rDd|SxRX>9Oq%Y%u3cu<*2+BQBaAx z^y%KMkeU_I+E3td5T7!GkWA$&r5){vGcv{GJVA+wI7S4s4M>A`Dp&RKW5HZlF}SUe zo2%{FZroze=48TKyJcbAxMla+Z<&ZxTDxPG#g1P^`-(Y^PsdR}oT!#UP%xJJq_p2J zMLsWQUMe zNIceAuTLuA%Jsg=FhE;)7^1yB*Y!vW(q_G)?^V~!&DtG3R$G5kOd-CMP^A)Tdvo+t zDA1$W{LQNs_lq6TPv)=3w3-`7SLpbkHUxAvtIB z-z!MGEXO~W!bxtaAq%q#`AY7Ut5$w6I2QXmOW3qhi$!;RldPcnrk2KUva$sXI^IPp zpWsI_e8Bg15!(Cg$CB_(Z0(NJ;-C)M@|eP2SxJQ5>L>gC(9i_E-qc_GXST?ya?Jay z4f*bykJhMX!*4zoh~KfSjLV8LX&*qZYcuI%_w1c}4N7^kVWm~v_YZ$18ZeL>LncC6 zeNWm5nBeLeRk-m`EMEJhnHC8F4p*_|QpLl+Qfym>d$ClM#&Mi>vcCw?jMe+zvz4L} zaNY)d*GwyhUJ)^VEzefh0o8aYYd=~jZ{4DSLEX<1lk3ew0P|naF9Xc{jJ>*=CF6jh!!4|mc0>c;UAU6}@=vgK5 zf$~8sd!^l{*5aq-3ugRnvLdQ$F5aSiJl}rnsedGPIgvlx~7C2!kH-aglox0{x{-D1hxEtb4pz2wW)=I)^}Zn}>c z{7@Rklo%PU6184U$LQ2By2ias@2ZV=FzB_qgknLs#bTGH{So=gm^ef~y%0-j}JJ{8dBT$mC7~-4f9xq}9_YQ%Vnw zC;4_7=j_^cenM4Anp%ZnSv`&JSog*vhA&Szo+O4}m?xt!3WnNO!O$&WCNJTQl*~Ku z0@|Yx0`pT51c-wI=LGjxtx)`dfC*Cp+;Q$t3knQ)nz`6@dJ~VR&PF(z&3Zp?y@}YEh z*tcTf3INC=%GRgiF+;kEdN~^b(70<0NJ@gpoV#&gE&Q2({1h?O*+P6gr_WcB zp>QaNlh&pEsDa9--g! z&?ZZ_#-ax}atc@Uirx(_TnCn6V^+2aDh^-`!4{aREKrgd{kBg#Q<;tw zU9h-M1hI^7IY0}6(>)bXLJt7ZRax9SUB-5lZ(#(|AOQf2gR7s9|tUdF}+ev-@ylt3PukI6$$+qld`t>J|A3Yg7c@BHo>v ztSS5zX696ZUnemg9_t73g!BPMBl#Hv*jNLkNuFC*_r569Ya&)YScC-dp8n%!;AM@1 zUAPd80(eUVIBr~Fs;&EOwd^Mswr8gxL}}9bj@LM$+|X`Ve*a&7!=7 zDSo8Z44z8(&FrhkmzwAh{dmmpqSHYb!<2tRE6JXx7yU|}&0W!+|2-3n`1SE$y`Nw0 zzk2!Dd-`}t6fcZ84)jS9WIOJM4TqqnlyP(`571luPY+_aPblzU|0S)u&%}sF`bpeH z6wwFnsxTcdBR_@1LGO4d2Gaju|M}lDU{K)M&E6iIy{qS8M|;ft1977MWF;r%W#REU-UN;=$4fw2SMr zaK-f{6GU47c((4Ng_a8AZ9y zv9@t95dsiHHz&)Al0_PzSmD9cD3wtiiV_*zLD!OhFn^w!>b|jWY1I*gyMzu}VVdN^ zP0do6+qM9%<%HQT9|c{jm;Hs$jZyYAjQ7eD!q{S^DFV=!B!V-G|64)`r*$ff@r^<{ zv!d8q&_YrHyz4BI;0{VG2!&XTSeKz!MUz&(4{)fF-FRT&s2o~-HZaIIl_+@L)5gDABcE`xG5ippmdXd{x=A0q zUCm2Oo=;EY_~W=QNjTxp#bWryTH$c!dSvMh;38y!2#L*}1aN70-j>87A4OG%L|n6pk+ zzP#$kucH_xk)`IfDB4#!0iyWey@#?vLnc`130TDRef|D`L}i9EUio;sl+fBGLslUM zosb2r6>_Pk-4Xg?=$~b1h_lmI!DM2pmhXH3EB`A`Of?Robo`h(%>G@L>0@7etOq)ts@t#5X zi(YYLRmWveps7O)V{5==WHWYS5y78SC5H2>SLjW2b_Pkcj7Y|q5*i_?&$_l}u!a^T zgrpvJ)Qxrp*5H@?MhSSBW=)c`EceGpK!a0wG@nqs*Y``fxR6|LY~9+re*5~Jtqr7N zH<^*_2T_0`>V6tfMd0=P)4s?ufYCNE2Ln1IjNx%T4~lV>@KdIt2&R})19?$mx-phz z*Wn3`l28-ii=ic)QctP-mc1w@FNJR_djcPSGGh$tthOO{An}lN`0vPx1ewp|bczh44D5NlY38(wO%Lrz{ zh-c7v%!@-VF8!|AQ~+U!Y%CkIpy&rBK60n7SOLML;)5&SGgSng*EV$E4X7b~Pk^E9 zgCBHzcGEXk>+`Q2D1&0JZ`#F*l@ZRO3CStiwoix3j=RWE_{rYB)mn0yGz zALRStJb*j5W6w>=I+TF0wYg~)b{)j}6K8H?&!)rx0%m4HA!K}<^M+eDBQ+Qm=vk`si@b-PhZK9gfKo5PkT z!L^hegwwoF;_(n==>`RAW_k=vD_zD7cUJX{MdHNHJMEhK=A&5G*#;h}cRB^r2tQG5 z?YdX-xXYwo68bWcFD*MSeRW>|`jgC{k!M9L2-`|_&ybbYL>?(0d>1RJy0V$c%RksA ze`*}YE2X!=<(=hEcPMI}3vJE?b!1Al4M~c8Nv?8mq}06X?1+2l6CEFIRTkKPK@7oL zbcC@B;AxV>-H)sSJV7)5g4}hF7B60fl3C(+p>d0njf03k<$6MPdw93k9muNf(6tHb z%)XF%0OQ>azf2Vd8Ux%f8P8X-jxRLj0=(BsgaXJ4oaowDqIrjjrwBfyQfiCpNoH$H zlD@8qawc|lN)LvzlyHNGux?3~Uf}cY#jE{-r7VDM-MV2MW|&ZkJ1ZW5)$_Hja?=2} zuv3EGufPY|yiV(_*(;PWj1XPhGc8Arhu-(!B{GO8pZ`EP(0$Vk`tPIy9>MEe#sbBh zvmTj;W757j=Ypf)bd+HJJ1QIK)K}WrbpGBgoB7-8!IcQTj`#O&gNeTz7@TW@)jL&u zrKST`CBMyrAQF0H`djFc+iZYnE%nLfV7lo`{r#!e)GmmM{>XTyU58ZF(W5YzLu7Ad zaP}yqp?uw13F`D&yvp_uLe^@u+yCo}$7TzX$%NBzth9ya@Vzz+mN|f$9!$+!EVJ3G zIDFs6Vy%b{*1~X&Qs(r~YLMQ$MvI?hIvs6p`()v#R}!lGt7h!u-7I;8`B&lC0{NLd z&6vCSE3g1PU;u(6EIEZ=Pt93A@^f>;CPM0N8P{>)$~JhF*#-1eX@BMtzUWE%QmY1u4seOtd5 zC}pDhJ&!Bx*{kK^5?(gMTD7bMRY-#8DS+*#(}$SsCFVp$Jit$wRxH&D{#}JD=HD;L z8@kG5P{ccE72$QQ4AWYpG?>EGJR{9WrK`ev)`BaV)`i)l;J70FvoQe}-HL_|B{mNA zJQ96b75CWqj$cPFDam4V$_k+gBFj)m9O1>E;4Y6&hm{*Y5K8R_Y&hy?W8IX61bxUa z$>F39TnNr(h7Jsw`4&Fm45e`$$rgn%7|wW)0%(beswtAFLCq4G0?|3^uJq}!R6@;& ze6fnEaw>EGFdXANq@AA_9TObu5PE$86CjbLbbDw7RUx)i8n3Zw_@id`EI0vPmtU?* z$zVWh5@ciD%;B7~&}>T7B%Vi;hDrEp4sYUv0$2~Ch~R|~av)j{4Sc8qwNXsT`#i}y z$GRESKV*iOe|R1B7wK$XA9N*4D#F1t1Ozj4tUbK>=ItB{MrOx;-U6)fddH_e{;Mit z)ng?l))>Sg9xtkPrp=!6rs1kO6bECdF+g{#S0Q<5VY$e=2XG@;P)9ohQL1@X0NkMt z^9ZsQly#-ghU!NEfs_T~lEO;>i?-tR=7DmE5C)epgxtx&6m1lg0G>O$N1a07fj=ll zyyxljl`(NuQVp>OnS{N@s4Lu+o$c(Xxyb=~x{1`dX9W)$nyEtw^F8Ru)(UlMM(CPV zSz&86$8~ewjxp=RL_l0Tl(ImVN${bOt%{@LIgYbnwl&(bkav3+P^v(A(=!P&&k(YH zzX8+t1nwMU0XqhMMWXa6?kzHagE%>XDt*Bq7By#nG{t_P9`lgihPO4iu5D>Y8FQjC zc38lu;7L2$czxBS0x&dT(}c#x-xrOsTGs$i@PTdy0U($#@{4zgCJMmAixUl}fq#R4 zhzO_ZdAanU{Q1DQH1Jc-cO2l_HC zv-IjJh?=)q`hHK2 zh!E~6;ZCRXUcdATr)qfa%tLrZ`jHpIv(t~lzmq6!D0xZ|xP^G>_dBp@N~h&S3E1kH z4=k)+(SS|{?{y6mh;zi+;(|9dO)$HVU7zw~!MM!6YWL>3uh~!6 zdh5s-dua1%`rPbJD*SC^-jc%8hNLY4p9E(cO-xm^8j%>QrasHLiUw%y`g}Si(?>@m zR*BqS)sv@PqL?;OH1$B4g=30?hG`pN;FGB%q6{e_dZA*P?e@i+xRk%FE3ClCCcnc< zBGibIMy6|DPBrrsrt4QBd8(-6opJ~O&#HWB^s-up#nU&9x{YT6BQ{?lp zGT9uMN0Cn`9ki0o4Kjjt=g?&XBtyT5J6kslQEzL2PB{T$Aur05bVvv@@t}6DWF!-- zwpPN-ofPNFk;75fCfE;>OUNkX${=Lt87j@+6rxaN2s|0V|(l^?o5y_A&aXPlBDc(p7G)E9QZ5Y_yc*qYiJ( zQ15@XoDW`mI zc_X~JDo#bI+}CA|mRT@BC1HDJjpH|xTSz}jcm^ABI)((|5&zu&5-WXl5J&qDr>HDM{o&*Ct^}~osp@=R= zif7qLrBOawuRTQxe~GRK(a;m5!g34?B3*fRrLf(=FF^Tz-GBN-w(OSkDmuKUgmO)u zmfD-I#>(GBIfr4d9HGJHH%2&hRvfipReJ(U$IX?XQ%A=QL&~x7alK%)MnA z(Q~n$I+pIG0*0P+PiC<;^w)JIi-19#CarpXCV3*~whkn^%H$XBZ>NG3!c2jN$#6pv zTrC<+4#G&EIV16j zcHv4-w@}YA4k#sR=pU0Kkr8;LpDaW#I#&Kv$|f9G>s(o4K9YofX5K-SocGtc~HWh!YO|hM74jbhfB$Cc;HYjvr?y zxbYUqT^=mBak!ox;RWFm($$OUN?v5GUIItbuW12}=>F83Ojvg~9 zw^B`cQsYm0Ea0zGct((`mORBO(J6K2O+p{$QBa@?uM-{_<0(MlF^15ygET<>X_(H} zSh;9vuHC4rElyMxpa<+Q7GHvxsNOL}6=kTM8*UopEWj`>t^pTr*bXcL;aftbdZsZHEv^$ zE+XXa`-i`RTj>vyp8j`~Hh{P`SYP)>7WJpP;s5Vf#+Jdilh5Iax1i=tAs$e?gm% zK?6;6P_aR+Z1hmk*mt8|5rtIklkr_?w}u*ml;VqiEJ8wY(!V`YBeXSAfPtz)e-?w5 z75|PvcBMRpgQ8O5Gb-mvs`Da-olA?_y)Zii%F(Cvim+tUy??0a+3SOqir^@yHg2WY~koT;65Dfo0U z=gpaa>zTBT|K-h_4Zt1v-<@wZ26>Q~nti-8+N*N~;Jxw#-ip2?>%p}4{H;mn)=s7*4fW%Zsl(B>K9QgKcD-t4kvHmJRevL?c`9kg( z%kEK9ihO9T?W~Jfan~ch4<@&PkCE6+s9PZzur8{SELrS?EgybBIQ9ZqfNPoLIg zhBkawQ)0>54hU(Qv=cv#YZe(Na#ZoEv9xQAd#W_Xcn9iu)ikks;G6eIoSd*m_-fl| zpnwdNUlYUEqU;Q_bfDQFvQT~Ebo)6GhHmM015QM;UIkZPm}Y3#XTdTvTdW^lxL}H} z#b479Zvcy;j47;x{2!(&;xmnN{!v9HbYc@X3qGR96`;$d z2xeGFV;rC>)SssAQ#E&LKL-T^j991Y7RAoU`nHIy6f&b6F=OfLpI>D``rwef>14v0 z1h^X3HzJ7CqrY%>9!DL5Am*^NvI=U60%=d>O|df=LAN^v-18)|mEMPc?>e3X7k{OrOhzqu+K;`X{mfmS|hyq6!m zQS!mr{S*4?=$o3=c0BjT&Mu$&V^@bzox8KD{}wveb`r+U>JJtRx}i%A!UcyBMI|g1 zWd77oL!&5M%#t|Ze(j!Lpjt-n_M_!4WR1e59eXU`1+Q3xVVSTyOwygf-2bqjEXT7K zz+k}PxbJPTqmXU7??5r&sEau?))tlx67;3am&%1lW<2DGYG*od)FC00Z_8gxtTXFR zf@A6BWw#4r)a^fDPeW&WuF+S{h;{wE6vi6W-AGTxx?UaynB%anmq{QpHWooVQ1y^| z&;JeChe-ldVmY01=BGun@Rkej=a3RWv0qb0+6c;8wc`RNMf;s4MGkixq>-#pOrm_w zUOg~TcH_;P5o|W#Rg%r%?|;A#FUh9x$aR)!g#DV?W}-!mDbf}BU;H2~dpWw;9RO*O6ecFN|r zL$!(8U@QcJ2imDe*sKsI4bYbkcbwa3)@%SCIf(-;wY1i{!~UrSue2jpi?~zzI5he@ zGjUmjMs0oK!qMu``a3 z$OI*(xE=FR649R$6h?neK;ilgNcB7vnmnBODanoyE+*{AjlC*%4{mMQ{WycoL>q4r z^2FB-7|;f(SjMnq=;T{96-b8G2MHg$Tms83m*6T7sSsLacjnC;BH=WE3uj-4uP#lq zXna{I#H-T+5b$mUez5~xkrqJxE{V=)GZbD?^kxh5s>YRVI^BACoQ#;HT(|wQkW4-M zh?aB;G1y_0jQj}0x{fh42+ie9F3^Cnkqt<%F%Ykj7?wZJlgTpT5cb#90l9{m20-f=Xj+!9#Am%;5o*n@YiSmMC6ii`$MsmEK*D+KT zFi`*>f(n-MBhyRo3XwPLsz0H===Z~9ahg(S({b0^-rTzG{mln9G+F|Qyo-PS3mU$J zz&|2EoFpGGZtHz&`gC_69>L=v&gh0m3U~~sb-~G+AAf*%13lLn3?hfK1qV4flhC0Q zh(N76Wk3k;devtZL{oFycDQUP8vN*$i73&}aMB+|K*=L|#Pb+@5bb&IQK`NCKXMZ| zG#ZIOY$$q!&1%~t$EzUtypS!#JdJ^%b3OG(ybQ)puzTwSB`{ zTzwM*Re=araRC>;mK0=OTL^OC29Yt8z7W?OD%bM*pfp^u8oppwT@K^l%Ih%)Gj`oI zjmi~WyH>Lzc{(s8_Fe=8`-zO5a>uGcF|N%j{jDDhZu?Jv`jf{adh{&7Li+G31EhW@ z=2oD)?DrkXIpESs=SX~ICT)sTPp=bb)}xL@j2&{78U-`|I82tX?c+4bG7sj2&5wgL z!(ag3w?OdVMFS7w5U&=@iY?~zFO=iX`}j2c5KPX*2>eBwDe=tYH<}Mu@E4)CSdIV+ z;!-QvRCNvWdx=9ez|HFIEzrzcOhhG5gx+4HBKYEW$bK?&6ww|<#JGI$uJ<;t{{a7Y z6PjlmSupng&;Re%;MVq^z0U1BDBI0YskDeh)<^0{`mSp|eekw=H@0u|wyxjNI=V5q zc>_DTS<#UQNN>()t9R?>_1@Oa>&A?J*n*DkY*%ztyeZXxAG{xWKit04yLD^R>}b1g zMhe(^N87!dH*fWB-}=Gm==OE&=(e+?7m3ugR|Eb|@8+!=z1u(BGJ4&*iM{@?3goYE z^|o%@>HToST56bYX0Ku4 zHP`aTz`w`nw1T>5F}M8y=2=6G2WW34g2#2=y^|~Id(V>YpYeY$CJaLp<+9DQl4TR zngUM0CFv1)^|b_-v;HHIx@W>)f1&1k<75%Iz;m817;?@Y8XFQUS8Q6sfBm6XItTpm z+M0xbctnHX($#Y3&Yj-%o7)C)yVaTwxI5kM-2gIv>!yojZq?EOUa%>&A!b9`?{z94 zNz(g|Yp1pjH=0O zVBQ`=MOG5th~g_YNv)=wxSt&vg$!eg4Kk=UIGOqR$st7|V;fZeFxU_i6S2o+TB5G% z=Qn8d+b?7<_08?U?ZI_8A^X7fzI!67zGD~Msjm&b3gK3%kR;71j^W*VCECYb9w^bE zabltV^``n8TFfvV>}nb%_{;NbPq$=8drg9baZfYoInP%8Nvg8ldvbjMcfH(`N22Px z;+?=P0Q-ZX_cTFYWwGJjc$uag4cec~f>dTJ`|bKe3~Ay$366uv+xBoi1+Y0fx}5OI z$;sg4I!$x`*@VALqvFA-vjs)Ze~!XY&X6pRU!}$t)btyli=RNGB$TwH0&B zX2~*|cqjwJ9`{k~^$=c4!psU!q1D|efydtdBRb9dzj`9gaW;@Zlj;yM+{l7~)m#HD z@Y+~!Xw~q%``*uR_&GK+iW6b~{ftr)@r5gZpLz2ohG>nl#DnKwpycj)PbX=Z9fsD zXv*Bi7*6+Os3BCV+$tx*$X_h{MJVo-c{mSnD#T-SwGMSsc4u%4h}lhKq@(3w7-LF- zU4^bsp$jynV1;$jLp!upD<8~7KUsmnwJ7s+PmY{DOd>Qb0}6kj>89l7)&jg3*4}9& z9FDo^u1Pxr7hE$yBhkRHC%vqFUC>6IV^_KCynD*iXuqRkCg<5tG2~jiDW~h&OAR2# zPL@u#H8ahi-B!>UQL5@2DT<)41lIx6%@JpuZQBx%i^Ve&&29|f|4BY*1Wek|`z0_v z?<5CcVBI@x^6&Uvtl(YI>1x;DfI|#Rv+rxg$k)0WI@Vw#PUR!!g4o(~GqwdvuZhw5-L@A)*Vwf^TW*wg_G=O>sG0s&CNT#>vuMd`E1{;Sr_(m z$LNOVvwf$xdBf~yYpX(RrE~tM+aVZvTM& z+^X!yS{B3S=AGW{&D(~?_=g(}`*r7G1f{`5^hfjA+U(uBe%O$oDI8@>cK04_m!kx3)|b^sNdN zZzWFN>fOBgL+|zvmb(9T!+c6O3G=yiz4yZ{Q+a&@RpNJUu7Hzx?zeh(Zs_X*IR8+O z+hv@Db=|q%ySZh;=Z6N|F5~2_-mT4Bz0KRE+WPj5n)x_!68qWiZEu@2?e^^|8lrU8 znNpYBtJbx!sOfcC$8ylMwA*@rNcQ<>Ny)8h=?WN}4h*B41-Z?CP^u;u$CZ?1CT|yR7W4)t;+GNMk+1`fZbH}_b zuWwb}y2jCQc6p%*3sFzUVFhHgbcgm5_Aj;v~YZ(0C50Tt~yM8zygb zv-<8gpyKTE1^^j|$_@Prxh1;Xu7iqUJ6(c`VMSen3VdA;DrhfnZ7$w|*SD_&zF6Eo zat^m|HA2PN<&EC<_1nN4nO$yfHIiA=px*@GjA5r5|-A^d=Jr0ADRu>e!qu`3#Mq>r(kkRgn zlC@X8qtMV_wxu7$QvbA^PJ^_w)itlIb_OKHZdtx2uI(zX(#1?rl~1){e+G1wcJ*pj zf3DdyG%vXc8@CN0`twtV>&2hzb`Je}WQ%on&vw%|&xX~LWtUfpi#n_2e6k$_61?J$ zZ5KPX=WxWS-7$2oI?s;TPCMt>v3mBxm`Z!-c7k#nbbf}D#}2xyY~+@{k$Y~JsQUBA{vGRXrQ3VzT!*m2d#ijN z-K#AhNppqkF>_+l6iz|-FW@5p-G;7jZs7kQkrOsfLi1K(A2D)mKI@Vjo*vnP z<4^R+P%<39q+dVBnGs$DW11E5)py|kzQvC3V-s9hflY6)BY+k=PnT)^HB8YHA z2zN($R`kR5zK#6&@LryMtHosaZmq_`i(7c_{XHmxozw1$*{RPesQi_|U?WZ@!CUsF z&o*F?J_U_UH==N~0l0!GQ;Nv*&r}zKzfpJ~l#v#L-P6V(Q+l3jk8vcHanLQ$QyH1g zbBX~#y7C|R@0++QRys>^5#5*Tz6xh&Ns4j zys^L-pqY#TN=4J43=pW*=fV0I#&!bKM37yC0UPLO(NYjJ&pwROqyG+s8#C~n=?S-l*BTy zpB>`?JK;sPYhE?`bp)`*E?L%X1q6|GwYuP7~g z@b)c+|Ds4JS{4Rto!T*$NeGIbM3{UfxCR=es;x(Z+B9#ZL9I_tD+;7d>5HO3a+Q}we}MA}{CQRl$eZKqw?{Yc+-M|0 z&Ys$np|;JxlA=EdDUyiSK#Ekg^+-{h=8dFil|$5u8fmloqNtI!(90r7l#8Gmk~e-B z-M&7#wbe+D9R0K>M(rAZB}IP_QY4YCffT7~>ye^1%^OKk`{UD!5NUJzq6m>%<|UA! zM`^Nnl$^xXP}~}gM|Upg#x!k_gv8fK;{h2vD2mbp&XogVT!q zXfyg!$dA6rOCUa&feTJg5X3)G!t-ia-u8pZog1UgIwDlxTPtF;au;8T(jSBl6_HxG zi?2lL52I9L1Z-5QiE8UA)tZ~v5vjEfR7=g8n%S2^q+E-=3?c=H+XT&#e|y`X26t-7 zQ$;`R2vhsUUrEv*gd|C%YamIg+Il3ZP4ilkwA%4$MU1pLeKEwySmq^=p{L2jkE%g9 z-JaZrtXM&0A2S z70yvBdZbP33!_Ju`u2K}CWmQ|WiR|Vi0YoPH+~px)k}eDx@tw0R%`#2D*a((L5zBh zvLI1yU0G0b^E#@u`Z;PT4pP(lQm9gCrI$^WYK%tj-2UO_jXU*EwYt7mr%PY0ufGx| zL6{`+H4r9MZ9T%&rg>|^)b1#?qDvJ=xPHgq-l`Q>J3DDb zjM}#RN`?L?c8>zxn(Q8BwKeS?TQskuLaUsbc4m*oguWE=qpk50=+3@>_!I2tWSrJo zuW#L$-UvpwYdNBtu3FKc)!KihM1K@YBv7x363J?7Qlb{k>nPFc=cpY$DyH?N(4*2y zFNZ4q0(cdqr`4bw2X{u-Z`6C}SM}4D9<^=!l^Fd&h>=9P24bYDtw)U7G;bhAs~n$J zlt`P?7etA)WnK;$YK*sXYwPyr`1ZJg3c0#zON3gs{Yr!WD2CMn<(dquWwkX8t6Ma0 zpg}8~opu)0#gx7v5_GANiuMyf%O4P6YIKs@H-EV8|4>hZsyb>%g;r?&l@9$;^!ftr zn)Ldz+M0U(7R_tv(26IhomRh?)E7gE%ynKCE!s~{Uqs6qf&Y!scyoNC-q5JJr}osS zZS$|>=#LUAL?B*Ms1R9g%}^mNnm3Z8RSr?RU?IhYI#!HdEXb4`K-hSvx8@HX_plg zttQUp=GN9E*uLEu4{gopuwNs?ekCy+8CD=#Q)F0KZOzEAEt)sRKx=hc+C_yert>8b z8M(O2u>1-9bUdqu-1X7z>12ARHtwS6V`W0quH9Ek^9P|c64e?gjjFaDrD@Z=*664G zfoVl*wE27iq^4NiPd8)8EOKv|Y{@xfyNZKmI=Uq0LIZ z$Sr6W5byV~3GLSMC2zw&5oKCsMPKBWtP&9E_pv3btmw<%lI)*vPkxs#^L8;YejmHh zZY^KrHmnjB;P`1S4a96sf9kvR2b9F{!^vzXaTJllYkvxq2 zEF0qYa1!*BxF1fU!1GaU)8{5$6ioB}7{-M~r{Uo&e{~u~kv~2vsvcW_kCTbFece>}6r8@fijDd$Yj1P)w>8zzD!<^l{pgJ&IHF7dk{BoZ ze3@4^sw!t%nH?YY5tKx(6pTD9!dXViashW+7%wwCd~muCD!SWp6?dJL-E_f5ovUHI zpe?A{vWi zLGE271=)=+k$`-1(vdBEF(GTu3A_7?AVsFs(?|xa(tV2+W5!kc@8J z57&iHT4l7GcJ=38)`6?|z%J^V1-!v;gO1s_8i)kEsWL9n80ePm;mg>M_hx8ghGwet4lij|E=eiq>Me?Gpt4T+V*)==54 z%ODhS6DE{4Yi$gu-hHuyL~Nt*D3}1MzPb7;#=l|SILs6JvnvSmB3fq8
  • K!e;Y6 z{?3VurF+=LaF#dIK|*k153!(B-Tqy=naX%ko~VPq6cC#F$4MII5=Qdp+Yx$KrA|Uv z;^J&fGqCInz$E*5UV~W0o$xY&t^@Cf&HwZNi-tIQXKBey7N-3D*aJShkXY@fr5f6DmKOAjU!RO#z!$h!;fj43%#-8K#ivAT z@hSD9J3{r~0|{y;)ek}3het_#4c&eb0<6o3!cpp{r&X^CzU6_uxtg>%I4w7s{Yc6_FhpC~{*3A54(U1FFtt|CyI%92Q3B~bihY?~k-};jYI_gFU zlzLQuhW(JN57veYLsbZuAQ6(y<`!jKB?B70LsQtVX_w`c_x;(?7VJC z69CnRVoA;w2^}76qBD+z`JYg+zpgv0RbsRj#ICKNyis6&0g|(|rD*M>*)?Zyo%7gm zHVyGy<8mvs9+krC*XnR-(0%pt2^u9db#>72eXH(sw~kM6l7ZDk@@<8TpA)s4@nKyV z(3PMlB_1M=k2PdV{+^ugJRXQC&&;+_u}=leOxV+m;Zo zBg{S*m203#<`rH)kU(FJ5Y+E~{m8WkweFBs9?&oU;I)?1uYMk?#q*bR9@>cXS3o_r zMLJ}-tL|4+QK)hODDwF+MA=eb0E&pd{*XA*<{l@xTVJ?9_)!G!vcSVoh#8vf8gJlU z(}Sg?IXv%`UO%8f-a;brO>j(xNR79wbOJyJf?ytEEXy>=PUEo%^11e9`ne7c&i$<) zo$Js9eeA{9@h|k$T%Dy&kMVX-b{4b?tt0t}D1G4X>FwT*Bj<^U#ZGvOGgPwqVGPF& zy)TYDKb{Z;5ZaR-yue0FAPi~X2|X!G=P__u?1zze90n&DHJc|{?qwA8FvtdNAC9eG z0Bs)Zt1FeiC|O(^c&(L`yq~wWJFdC13EoD{Y9#O60`2V=afG z`u`mAqa03crkkU+z<}1+zt#>{?uh683e$8_oHh1tl|2*}T)T?hHq}~)fBuO?RF)Ns zyjt7n`hU-tE3a1Ft$1suqDUYy@K)k#_3&OTm~HbO{(`R0X5*3H>HXP^j3#2PYJ_5* ztkwo8zr(w^y@Fshn4iNKtPK8_>vmu{wp;?UunJVZvI{lr!p}rX)mw(hFDxJi(0=6? zei!@#+bBtXK^i{&ld=nsgfUbrcHzOZM_l@a@dr&-WxrGIprxVOAMp}zJeB1;+-2Ii z%H=IBK);OpdIbP{y{=cft|er@-qxStwmxWYUA#z>52vLtIn`}Si(bnoYz`#k?QxJ^ zs7Kfp8CnN3IDJ}c`xQL7lM_#v;g|GmVZC3sd#_j5ooPBVOe7-!)t__hTKhlRT<&wjIV|FUZd){j}O&ry1@b)CkXM1@XE*8L0+@n*2*$qXswwi>L zpEEkzRX>HvP)wKdMZ*pc6cj22#PK6fkCJ9sCQ@H~ubDy7uFkGo%#1puivH7?EJ8}? z+k};A0{8Aw+DQ3kpsDRnyes!q6LZrzP^=8XQL=Q%ATBMzgc8yflTak zNWL-|-KmRIG^w@>`RGCne}O4j;n6E@@$-b=$&-nHx>op|a$ya7R4>FhC-|xz#a^#z zIg}<#G#8A*_-K6_BAebdb=KPID3Ru^@e!u!&Hcj-6;?MlF8!7}$*r7WRlAiI;uMaT4c0;gq=f z?O5yWGahvJW1!*$zpe`KW$cf8DLXAfuC85kx552A0 znhl{@+n(#QipNO9>$gSZwU(zy+dskeR*7jE9e5N;nj#^362ym92xAOeI1iQ2<dkHh@5 zmJM-X?(W`m&xyLQv`fd@gLQ7OcG9mkxJkJ3{sM32UW!Msa z%thA4XayE5%pWZ|0z?(=v>;0~8*d^zYD1UGayk4@&SmH|k)e8*=EF2NZRN{cCXEJ6 zUT+?p$EC2j|E+_PYO#Lh)x@`v474G-1-G=w8W2Kpq7Gu20yCd^3%scUI6#wgpv2EF z_Rfn9xR&*hL4x93ex>W~*uf>x4HSOE8|#v3E{$+*k}Hx;d=d1v32qIvc3cw+yIwzE zLS}lmXWn=gF6veB4UfRLk-~6XSWgpv!;`+j;jJkgk9I0o5;*XG6gkKiN)wqJV#$!$ zsGJkN>`ri4z>_`Rv7d&1Tptpu!FhE($5onr z@FC3dOzMTCR%?+4=oQoVr+8)w_G`(`R!xym>!jJzOs~y}=Ue8A27&r>h$d&FG&u_5 zx8dABY&0Ab6pT6bP6Pbp0P_T3-rTd0VXrODybu+`#V07K(OWeg$jM~I<2dH~6z7X= z=z8T{`g(#d@dVf9YH6@jEN8WYU&ldzfhsBFFpl~sNjhmTPi%gHM1%$d>{b}L7`IU1 zHwFW+^8sFnNQw|W@FiQK>oVKOp<0;tj$4NFYO4!wsTDqtes~=wPw9-?8-Qv$<@Sw= zy;{YjbujlAogf}3li=0M-G|A1k;F&^R_a5;jn<~C?VSuHO#TAIMfw>`lVv>d!q{6E zMm%SA^7ev7+o`uRMs8Qj(%-}M1S|i{pEv6k+Ngk zq)$d^8=N|5tg&?td3TFgB=H3h-LhaqG7J0oQ#?nSl>o0DyTex(;{D!oIt@QGpw_w( zQ?@TPVoG&D$#9N}5*bvuQ4&$F2G+!J^We~5gdc)Pfbk@pz}^2HGeNTeEegAhy4^Qd z|Ih#D(-&T+nNn#ZPv`lgaL#)^5Gh?d8{WoYkNQJ{qULeCt<}kOnw(4Bx;bneCUtDP zaXM1Vw%yM*dz{8z`1jy~(GE8Mr_($T%ansu;lbzGRrGdz&#Wt_ZWi4CgK1+l?3&zv zK@^NRZhUL$`J1a9^n8fBO&7(%h5MDP`y|y>;>pSLMG)iT5ua1q>#FPh;~!PshuO0v ze>`90r;H+cnA)scXU|jj9;%E5-BZ@zP?JM2GP+)J-YPmF{Yrgq$^J1Y^D0E)qcI&RMzptt`N}`Iz%`pvz1&{ zTRk!wIFr|_PFzc5ketvV!^iYAi6|QLs&hG5t---cwYOGqoNe!q-P+f66|Sh<2FcmO zWI?LAPWO*T!PX@>Z>}QLD7F;8T|E-JCQ}xF3xv%R?=)GaD9T=p5qSZ0>t(%wTPGMn{h?fXXZ5~>G`|oItlmX;)h1_OuM6GFE{Su%gtrSn%Y#pUYbdHl zhYe3yn@l!;SYrM*YJJGc&$8BFD#(Q1ekEeD8t>gwjCuY$$6Nix&~s&-JU$n5eMuJl z{4-FG$hGnb+5Z*!h1Sa|^l7QGw+4TDZd&Wrr!iU`M618H)}b@!IFKvo8r=GahCEHH zclml9o@9-PF5ot+5_X=aA5VA2JjY_r&e8Vuc@}W4^WK2i=R5fqMgcA!_b-GRTnbeLY?&KoGiC*tC|5r(IOys_m&5CMDXCrD25F;^3b;pjljIT*^xH9QvQ@zB-zx z1L-{XxQ1?Js+HrC@n4E~p@|(_R;Fbh%HWBVV~yccLmF6ZKs3qAUT+>a+-samGsZIl zTQy}nckp|w`a8X@a3itT)5gE4$&aMHFH;SmoBWoVL?bKtD6Qd{R1snEGN?z(XqxL{ z&Y>SgL3+9-(ukeQ9!zs2JBxnEGqYL7EQ4| z(X1lydtT)K9r~X7Q5N((VWh-2tvga?w{aiagfVKd>Q-ykj*ScH>dr?vF;1NuS_(hH ztnZKW>YP?O7+v2D$hL|=dbXxdoC`013Z@ALRQb$^IihKNKFn-QVHB|veX5=||GC4i zl6l&z81`N2yM@(XI6t&-z@ndoCKy>g&K7=(qw2e?_BKn$SbKxK;ZX){Vg; zJ~T+L+{~fPvQ+t#7}%-#Yw-!L2o|b^0(^jloi6JK3T(sA;zxBz&W8JkVP}@oHjFyu zFt1|juLVRA=(H>ILtY5|qEA1E`GMmgxW^L)4exj7hhn9r3UttF0=~Asf$7{2WPp!f zpYFMWTGtqaYmq^m#xah_3&wB`lj4I`ahJ72|4$rNxf1Zp3=S4s@%G~+E=N(0UAn_+ zl5i{@v3iA5=^8;F_wcuiOlUq7^rwO6B{Pn;CK?)*Lwh*Wq{n@_i@#Xkj;@lEVCpX; z%1*1kikqaXKiaI*VL;I2Ny}$IS$OI*&|**10|SX|$VbJH6rdK7EZqG`;0&h18<2&g zC~%%l8Lg#!_Ut#^I1T5{``i`hV*wNwUm5c-%g8ziuy<)jV&1Hd#9XoYt0IB?k3SEx zJXyQ|X#0mmKB~;TG}NKs$^(C~h)z2sEAssGa7nJ8-Sy+mpS7Y;cKmS{1#X8MejN6* zC|nOg;`Ztohrf>>CB#f<)PM_#98|>OSBFoX45#30d#!-`S_pIX*Oq>w5B{lHzA0ca zoa7*gA5#vjiOKwF+}CKC=N3(`3)^lao6wWOIQcPir?e{|%zjogq{s)4KZLo5v-Y@9 zq(u5zFX@%U07eA(sa4~0qQ2+J;b9aMv+t}I^WA1J>x?U^p1eh7sS-Gg{eK$(WCb*f z(h@MOX*VaYP|UnIe18BjuXR+^emIZF$R8g$&qw(h{UxE=uB--hYdZ28V13~F#-@>C zDU})kB2UuOpL{Kmn*6twX2MU?gF+u{$DDQBIRfOK$>U~32& zK2Ihh&5YwZa=#Z^y%n7N{3^VBdp=%&{>6JZ8%i2ku6ow~x@%HJREJ^*s0mJv*TIdlN(T_6Rs>Vp@&Q_i zz)Et?UNR2 z7+R4O4|@$JL+?SF`lrCC)4!c!g58=hyNI%(R<}o%EM4!u*WaoSDqFLkE9dnCreV2Q z$z3X(dNtO0R|I`Wzz;%HF+HEc;UV6n3umn%Y{QWle*g_00)``Z3_nRd>TO-`dBtb^ z^q4cm%Xgu@d!(b)YBaiXTH@;vp8qPJ`wci90 z)RkM}r-wm(b!1<#(Li7};3?_vhAwS`i4x`!fJt_1fzK;B_U<*?Z+-JkD7mT-JMLk_ z8skHpjlPHmZyxOauD6NzfOZ-Q5dHvo*s-5?Uc-n7bIU-+4tU7w|0etm$rRzWSCt>pS z?*GE>{x;XVy3yqpHeTJuElnikz2nOLdTahu-C9I;^3VH*Fz=D|UJ+%0 zekDD>Bho{scV*BU+&A!E^F@+{@nMUVuDnQ-(K5y*%)2bQcOKzUDa>DzMv=wQ!ZPsaQZ`6p&FB)#6S3l5u{xrhpG>whpQ%ZAn;h+qtNgWh zyk?D4(Ff_A&X?WQ3hHV~-IJsJ;6vUr$Jbg3_pI-(PZnMjO!NMjXlg&jsL~Z$(l%a64Vtg9^d)h`vzjA{`r zoet}00`x!s$AACdy?uBJA7OZYIOxj-9$Mfly%(5029EV|j5%{XJmeg>EnALMIE*W9 ze{*SHp9fU~?_)%`kj+7-X%KkFL5j~lj27n_ISS{{+r*o~frr9uP&F`=m*G^e*>(AP zxt$*>_J>UqR`f%%Tq3ZK{vk@EV6*#&QIcf?xSy(?s8NoMEl5?)jJzWHnNQg(wKo!>3+X;PAlXFtx22YP7?aRMk(VY(jxNsGiZVraX-y)}CQO=< z{Tw0Ec@puu14FWLUR6v;w|vxLD&TOZDwSBxR+Zj-7W6Y60pSMD0zbw0&pj<^n<%PG z-Exk-&$PZTVfW?KzwZB9=!AsL-|rvPKmk0;(diSz2n;TMiNbX8s& z=E&8-MgNt4T*mb!&}v#2^iAQ~Pib0&qB_pH? zasL%1F99X_KH7PIFACATfy8%LTQXJD#G^#B84<)|%w+r7*{i94oTTDecX^mei~ow1 z?HMg`r&1`8@}(LjV-*14;!)x-N=Ct@Q>tPOU$Nq{uFr@5JV^c4BnozAOf9^*e-sF= zti;Aodj}SD{o-0!kKEiB3_#xhpRVH7=i6(E`3A#VSbgZ^0=h z5O*WS5r4cKq=@`c5M4S>9I5qv#f!_j!1gJ3YWwSpG(=vKGILFKgrA?ohBxTtzxyy_ z6la?KJz(S2S?YEh{3m@c;y>YW+b3gP8dDa~i|$0a_<^@S3$md6xP*!U22Gd*u{TYV zISTYWj^h~ynPBj;+~awYs`&Gs6|u0(JuVV@UkUdmV|^OTlZ!+8G(h8y=+qP4HX{E? z7)9PFQ1$r)%mOb8N2#Bl_Po(D$AVA@3bCdi#wb0UgxS$&KMi7@Z+QWidng2uzMhFo zJ`;KBXS0hx6QbL5p9!jq`d?xwj{P*`RM4v7B#44Mn0)rLK?}azBO!+Pr{$;k)VM9W z&SyNNH|+FpW>-^HJ%i)B>3?lfm0@n2wv?t8G*NRp7PQFy5T%e5_SjTb!Xf zE;I0sc?g_g89x6hc!4v7+xt{I2m%_n_ zRW~4cyY4TZcvh1l$)V2je31<|HW;s@^8k7jZyY8YysDZ&IvU>k@TwZY8`JXGxRw!Y zFnilL$m)!pR`>pFV_O?Ui?=WYcPp5u>%UqmPw|bg z;@eT=S1QbG^Bm!}-t*WYqepBn2E&XoIFl#x#ScE0C|?Vjf3cYOfOskCv~Nc=5#`;_ zilm<#-)4ay<+GM}q(80T{mgAS&L;##s!kC zy&&+gW56=#*$ZQety3L;<8xu(VK~h%1^0eai{JT*c@>yPcO^WrqrlICew^e%c40VJ z&AYN8o47OsyhpPf5t1e0EENa#5ZKo*4qGS5m~sJLk|>Av!J~cninA3sOLUsc`~nwylh59{cExWjt}mU;}Yen3c6dJ%iI-g?!}W= zdv2hrDpx8;8l_dS=IY}D(^1wjh)*O((evXM;rQrP8g;skB+S+j`@rsE+FLj=6etn@ z*t+RW{L{=ec-=AwZ)C#CGM?za9YXPgKS)~S^%A+(W^R4vABTs&%+hEFWuBLlv+9vl z+epXTq(UquC)PigL!qve|8?fiM@zUV(m!hYS3Ra{6`lx5u!bpGm|WBjKH>@#9W_~~ zB09 zB>XdikpWYv5LD#XG^YY>yEXS@)1<5bzeQ5k{$ZLd7v*Tb_T1UurO#e2xQbF9*DMNE zB3H+1q7GZQU^fr2m)%K*`1<;wryU2Mztn`7b~B|-UPMk76zJQ~6C<`s$U-ZmAeL(- zWkH9e0$emM0&?M}{+u8wrlRIl>7jpq7P2~Quw&i%Y&jo!jjPx0l_GBN;RfklGN-(m5H+hNz{bMqBF!y5%FusndjUU>G0Tk(`_238%>+<_Pj8aM$g|l^Jhw zK+KYYo?S1-xjPWGNmSZq?hw7!SPo_RsSLk;5>E12$C^#I*VeAZYDl~MXK#|kL5)3& zJ6%C-vVx{(3mE{#mjlqE-&H|s%xE>B8chXQ^JJ2Ida$DPH@Y-jEKp^ytAbRUO*257 zOz-NfqpZQa@9Qe#?j%#8sv_1w_%&xJ*%}2N^%P9jvF2NKR}aczoiBu7HSV&_-PByH zd%U$DJ=$2D#@6QMpDS?ttl=4{iyjp5FDkfkoH#2#dlVcMjd$8bIsE`Yn7ob1cHBz7 z;@Fmzhc7rZYXXvgz>N~zmWzATxOKM`q|+ID8C3=vDm@jBDv8kR8n0kx1EICf^#y*< z3tN~|6~fAo%)EsT#y#-6&Y1X>yhU64K+QrMNmg~X>joRsTKQ@lS!*L>yBZZ-K^{Bx z-){&5kiN7{-e{cTN@Ch(TG;lxuAB5R-bxz$*MI&WRY|w%Ofsv8YRmhz$|!W(;j!M* z_Vb{Q-26dg8)WVMEXg0w7da=Qrwb<&pxLpd3AK;j${Vo{bUujqVhm&F%U2`Cmasa~ zrezX5i`rGaZtZ!LjtvbnDiIPv9|K>=FnT5W4RfZ)oJT5Y0CF(S`+4vocartSd3Z2Z zsmS56YaqBT-s?K=Z~mje@PF!TUz|!uB8J9DA=4qiW0Ug_^C-?F)dr${a&j^_xjsnJ z!;S6D&CLxnJ z6Q<{iXGoqUUg>FKL*R(hU-zFr8S2KFFzrrPCaXUC!^&p`4(QVMbU7alX=y#3xW!3- zlKO`zuP=QopYT$p4B&AD1mg-NL`(MQXSKw=LSCDgbm6rvTY=|nw44N(`{O6pT)2cP zn0KVFG#fhan+BBFcqmvg`r$}?SaE08%Y6i`j>3Ka@P(hxbaG7zWr0P-jKP)3+*(IR zaa)O%M18pR;H5IGW^GHG<9+)rFWI~68K4wqxG(A}Z4 z*%Ra#edBit^52Uc_}<&<*7oqXB#e=EY}C9ESBk)8zFO(>RTxhbPop6fq9K#W)@M@ZOMW`fJLWXu%5RXc8M$ZcD{CWZ zfB>Lv(YX-{7*8o;MPoV0$`)m>_(OQ@JMD&l?)Srfpz*r9T33Mbp) z1m{qhfmP9YYKf*jIODbQjyhDZtWvDdE{r;@q>8jaOGmC2eOAHVR1GX0!uQ@U{WQQH zc33p}es_NO0AWJw=TW9%u9rHya|WPt$ZS@%#R?~b$ucE_m|vgnRpth*B+#;PEonBd z8*@lb>s@)Vog>5O*9U(2r8f)wiIyq3d{$A;DCoZJ8Vo-dnOF+cY{%}U=)WI2W?a< zz416OZYi*^l%!OAZrDQ2xRMDZCgmAb3H%^6B03?%Vo}CX;L$L5k*U z^v_Nvz_NsGB_NQ36+{nz6a^E78~E!{Fiu}4Ct0PQscc2NH%m^uX>bCRJM+kF-jvQQ;A<*HcOV#gp5mO7*GW*@6ks^#3J=*o>}%Zfjj#}^Z6Ep(+A~rhuTpPW;-bS}Kb^hwu=z6Us zewO!ro?3*mkN)V;_E)@Qm)0bHh}{nS#UeWGpfa}S!Fiy7ELl58S3^oxb@%gHl_j5k z&)bi;(!*_l&5T!D+0#BBOv-lU4YD2OSX$?AZ%jnA=&tSr-p1%YA21o*+K2T@ZMiCZ z&O2q>*2Y1Cb*-123^i=`oKTCZdr7#c{3=wn4c0rb-vn*rA!tu~ z%N%(ll52af;kqrISl6LL_P_1It?e%fx3*Wut?e%tx3<3^+}b_|ZXJBRxZ7XcWgc_i zU!b>L6!tHk1x! zX32?D;h6d-&qST$eq}8({4OFa?ZV_7wE!#8`7RWKBvH}Pq0O?|a;7R(w2D2Wu)q-$ z2O+1|aLpCwiR9*i3?wIiHn7%=Ou|=%cSz#YuTVrokryI$*Y~Hz_ZM;qn?*Q>s>)>^ zP;Hk>&=`aq-ey{>o?`SZ3~QM3^c6grS?F63S0lIVol z?i`3tl{srgmZfTA-daoI8uh+&r)r$Mt*wFyJ&>WAY#sjJYtuC~CT#L_og)nK-;!kB zt9O6+_GA{I_wCAQo-8!@4ZEpEfo5ZX`ft@=>UUURjxfZotW;r$?KH-&D3pxPUoiXM zia1Ic1J}k<2Qqph@`C8N7JT)C^YBz>eGv8<<9G1PX_&oanT}2Gb~-`r!gftjRdAYJ;&GOJIcC^(atBbf$IU{;;F zU>?f&_RZDWj%}jPX7jBY2t)6`ed_d$5(aNa!8A$N%iwtVn9P&=qEMO4qP-Xe_m_mr zG3n)2z~h%VrAt9%VFSJjCLet^Opb*<^RwddxdY-mFi*!bPlhG$t(~e}! z?6l6|zk~tx-BIM``uphBo4fZpB|B7Q?rlJ z94Ko#toIcC>Lhv|dvkd;&)0Gn#V|&cKBI-l=&YT`XpoKTd`8htXdbi>3a{k_I!ork zC-VW-P!%2t^VW)NaVWxgvCLg(!gTg@?jai+kRPvfe6^N45As<;bnq}JGtgQROFHp- z)>Nxu=+cr~PqUrq10gt<$=URIOswszfSj z-jf_?nJ3d^yv+EiRDy^emQGj8@IGFga$!yDu610DGPo*#I=xh*ty0#OJs7idLH1Uy zylZfgm+riD@z+Yd8&e{^!l!AF&EOU(2+K<@^8{kT-^(a>8Pl(IiyT~{Wt%ec>j@r>Z=RjAHxNZJ?6jq z0scY!0BO6Uug-v%?+hsaaG?iVQu<-p)_8-yELKc*Df{3i(iDR6p(p=p>In^&bbDt({LK@ud5s<)I{H*rW~K;7CvJf%ZWIy$RZ z0JV?NauG>P>Rjw(@Kr;J1HWYmakCY1Pv0U@E4_|NAKil&{pcZ>^e-aq}WvD`$T8 z46yk5bP7w*$;{6AY+iQ5YhA3~&0^0IEr#&L8 zk3QZB^oNLao&tgOqwQL`g-`)3(}*k zyw1<>i`%S?3o@sRycKDBk%mc%SP%xL8>z__IpZW>oo!d-0doaX^Sl>0mZxT?e_AmT zntv|-g@rC-^rGz3`uhdMTE{_qh|Rr)xuk}uXNDjK+rQADfAJy6>Lhj5_uEPd?N>1+ zs>r`rkG>VS6_t=zzlz=?RcoLG)#i584md$M2A{_t}(CQN_w?kV-|yk%!JywIdLqO7c4Dm@V=DDybXU> zV_R3vDpq&a)=19@mCZ&=p{D2{)$r7*wW=djxWNY*$I*mfU0-qSxzbt%b?C#K$y}W$&~GPDtvd=W)3EX}s7k)tD&6WiGIccucn;#_+fkAnRbO#c zSo>gd?8oC^BCg`YWjF~M5%xS1)J8qqXWjm3k}iRbDV^O9F$_F{fqHDflY)X_^FSsJT?`#t6RYTv`6xKH zMWs#2qc2oseVO85KMLGNKo@wUD)`F5zRd9AmkDM#NYgN#e=0y1!~O9}Eq^8Lo7Z00l?RF+i^Ia&v7>)k>`RT6fHK0FNJGfR^= z{5u6}8w>{aE9%^0szn8Zvx4Tcf*0fvX>pi`e&mI7B1_5CLqjrVqCG#Jcoe!I^XC33 zoUfz6^SzT<7zG3GugTKr4r`qFm`H_U3LXb+&kqdv0>vQSB3e?u+AyYm(`6hZ2$SO= zjnUR}V5n#7*HRC+i`#%wNWlx~Z>v_eczy+V-9*|Q+*T*a=wj`&^jFR40|WMnbUe|i zNBv*ud1CNyUvPidFSx%Omx3M#7wz9&9abCeZlV3J&Q2!Ka169$vhN>e)#;Y2^Nd#} zrgCb6XsCXUW7Wltv9i~y3F^XTS=fpr9(U>k71b}JhKIKl^DtZ1$jjM@tiAP(tANxn zrL)?vEv_p~bFAiTB`L1{Z>L4}!)6<$Hgz?oQU|M(Np$~b@S3WRI%czC)*1_HLd?a3 zuCr^BUu~+>cn_^k`82LyQH~b7*?uSSa44{~fC8r@W7D2C)x%K)%nbBxJrd-Q?e?f? ze;O2^2en_fsy|jg)vE{GTp_AhEygs;Jp?GxAn2i_#%RxWr7bUWzI&t^Y&z|%r}52} zPQ~q1XYI5a>YFA}6e>rDA-Y^QAK<*@MdIA1x+dMV;^nmu6?mSofAE$W1yB6HpQ6Q; z5TrDkc(t4UI-vlaxg;INU{#4D*EyI6>j(-gd$3%;)ZxgsY@&FsZly?}_0`{~N^dJO zT3dEhE8M(rrrf?lHFF-k0>y-T>Vl(Ce{Q`}JGl^^cZy7wtr(cBj_kGyNLFX=bP=Yd z?Mbbh&@xn-sBC*0+Xmvz#I>5rG!WMH$m&HA)w2tXrnZhad&EKF*B;TGvQzSucSn43F(|QXHMnM?{R-t*pnG>p82ed!(1-mUUh*frHOWVHKF$f znI~*~=N(4L2%Zk!+qZvt_4w`H-pjWSpFi7w{2%*o-+JF|U{4zx-tN;E&tL98c(y)z)~Iz%V%Tii0uUJkogw<2gi%C2j-aEMG6hX|5&_I1_9O2k z7%hCbEYWPi8v!MZf`JB{Nig-7QC^^8jA$H%e-9q2Vd+e;Blcrz#h%Ins`SwWtbyEq zv>(9x3~-i;!x+u8_wrMK2Dcq2i$FXVc!9eU7&V-RxMi?CF!5uUJH~>c?SLjTf0CR$ zO(p?;KVAlXVCahq;xGYJ{;~`P@WOz30Tg4tx&g9c?ewrp7SgIDAwP3uK{29OGBua% z-Me?syCxTPOPTM@;kl)y&*!EI4Z^Z}b}!i{4i!xRZngEQbN{tw!153UPb4GWiYQPaDp zWepTXKy9Jb*hlA4_y>=rtkOY}F!<&;Muh$LTTlBr$g=dI9G<(t4GgBsQu~FEx@6U! zf7-norAFt*{u=At_Kgx5WF7SFr@#c-8dBaUA| z!{q{YT>OxGBaN2~ZmM3;aZsck{dfRn#$R2`S(m_JQN)y{gvMu@GfD|dhQ@p}f`lu^ z#i_YtL3u7FnL%8V#I{d27`!n0X@Jhyuq$I9xeU6{{hYTDuXcHb#K4^f_{hKEaL!lV&UgC9RJGw{H@DN##m-6B=Z!&utW!q3L z`Hh%5nA@(T!T{dl^y&zLGiSuG&$eQH%}MDU+2@DR_hTIqV$h`g^7b?1^cY}7a0DNq zE?S2bfGD3f&-o3S$kuw)gVzUW0zUThj{MrAQ4N3j*I06((FB2|0v=+0%n4;f2YaWc zH1ssK=8PnF#5Z5T-^_locc6ECeQe{17bd=+c@zar)iRQ;C=DB znBW0B$H|_$#e%e zh-62>DIUj>nvee)iVgsQM)Zg5QSHAkdM{v4xEhavAY*V$V47Y&hUOcuuUzYNzdP7C z{Lxi~laQE}-QzAjxoDVce@5nQJQ&Y>U_~augS@lZ9gv&_(6+O6tNWvOCVGbRHTQYY zKW{&z0qJQo4L`sw#pAwuxm&zTPG;eF=Fv+k#jA~<;4C40`SZi;Kis)Bq#pWSkd6HX zP&u(0QHt3WaTz>xrZ3P~5u9~xP34(T1%~@TUnWa_ z@n{s6P?)rBJ$M{mrK83JBb|HmhT<%LkC{e<4~clGlvT=W^&RL?>-wu8tf@|nk}L*?_B%#T6X}O{}^5XodO;U1e3AzP=cZlkG>RBdGqG`4PZL1dC-mM z@!mCwZW5pF30l;lPJp`(F*loD>zHH({J99?1)wz={w)b(>K{EnaAU;6rPL%7SO>eK zZd{F66&3#f?EQ;c8%dTZjJ`_RZa332fq+U21zu439Y9>7)I8#7cQC6H~QR4XMg z?dH73d7$%RXWb%VMPy`3VAo8~{{Q;AjWRRtv0~j~U9i6mkITabd{{N5JCPQ8<5_u* z``p=x^NOmgL-V_fy&idJ&g`7tCLh(=5Gn#U0CW|ofpyON5U@z5D_+Y8@4 zw%Kg~R5B-8iCw33AZiy@L0YS&ZmjCsz^#i{XVOUHYiOr}R60RxvNovBMEA7~|JyJE z@bGr6a_KK)UTd7V8-3s~)zDUC0R(Db$P8R+B{~~H%K@;>sScDE&J6r3?`W!(Hhu4| zjmX|e^Lz*aZPaW~btfYOaI%&IQIH;i16F(TSs~=l3N38tTETEEUeLpag8|IROJYSP zsDM}}IE}EqK-F@zdEFnTTqc$%BjhcSZ7js>6kxkR}NEv+J;c<2i7lB4-wt0Lc=4iPk z1Gp=F1`RkN4~6QP zXn`99sE!RFopj?3YSHsU5R>SQPfpoYFW zK6X(6lvoG~Xuc3N@>&cE(W>-jBWAPY(}wv%K>EU*K30QPKqkV7CSa{@-Rk2fPpo*E;<^#^ z1pvzU1CLnxXOKRiSuKmC9m>+w?$|?o5-D}!m7+bzQikyR2jf%$@2{?X z0jQhg9_2}YB>^ba3Jo*RL^?jq%@;bg_yq^W;*>WGLw2YIZuvyF3`@nfwC_m+hDS9+vB*Y!cZh@_Lnd09DH^mRH5m6``N|@B)$5ih zpr+ql>!(Yg;CQkdF)pM7Fb|zGpE&1CaNQSF$A!u?eSCApPP==?Z2%v#pb` zBrU3K7!fJd!=sBgkojnqIWc^Y4YO%Bw?(&J4_0Nx;K!eEJZ_~Ptg5xDjH7p)mp^3y z&#wSAOp0q#a9{(6Q1Pg3ilI6)W?*omw5*ijUc^Ke5?i#@6a3H$Y{8Tp>R7TaYVpzz zmyZjiakt9Evl?x8?E2X1Wg#{O*4#vvjt8rUg;Yx}V`$q3NjWU0%2@TB zwYp@9^B9$+O}~{MgRaUoC_08FfpMltk2183b=MWT>`>; ziI$fZK(Ku}yzZT?^@35Xd=hcb8G!k7qi9LUknrmOqmd=pD~3kjX6&W^OmLd4J1JbW zm!`ggJ`b(XM1J^TqhcuI*Z!1c<4s%xJpqQ<9W!n9#Vkc&2xQkspg-u+o=Gz^?_AzQ zkJ2mI2%3im48a^A@n7b}tYolIyPr_VAsG>JZ*HF*HI2-}LhwMgg&tz$g$lX*?iacm zS`^r)o;|hR-USVKYY7wlZtda9s`qA`mL(rapKN$NjZX73%9tDIvQP8jklyDbEE)FR zrG@Y6QPU=LlbY5yJXLd`Xg;rPUNE)OHCOcJk-g>EUAV)Mo+2i8?#v3yQDH#{oU}yI zSNmux!6q6G$KhQI2_Yo%AnEMFri=>P4CBiJlW`@yg045k*qP$Qf<%Bq!C~^kY1CtD zaid1Z*f{9WZ|jTuysj4FMo%)GPE$1JFpQFCWaW&iNIM574=vwOc4Es!WAkomw@R_v zf=|QzG^6aE)Jmz5fS9-uyRze0KXpNLLHBpQ&E6$h!Oezfpyxz3;>u-ZmMVQ&OfPwbzz|rZRFF#1N(ZNdd@bke{ArGzS7|*{zK>?H8GjB5`+5M9w=s zI|99V!159OQPXdjJkdZqL<0?mboj?HvIeLNj?dqb1+@YIIZPM^=zcbm*@{QnK*1>4 zHd5mrTn6*9w3ev2M{L!7Z+wail|itpS-jgqS>r-`*NV7^Om9U8KS@VrE+ShG-4hL z9bRWZec)_dF*ZUAC-f-nnbKA9SESzxa50^*Bv2s>mQ@tJpcfwIKqekT74ll8?DJxq zB4~t~jvmA*Ia?XF75?_(QBdRS{HN>Lt(&&i^@F?cb;4`NCWI8+a0OLXz=DQj0vgFb zN~ysmi{E*&Q18~A$Ot`_L$XrjLGd10rx$!?onT4jsg-u!w8Q|5J zCbY8fGG=5-tmeu8=G%Etujcwsb)faEN|#bwBBss=Z4LS8_**A~DX((6sdI+E?pwl$ zUl{BwE#=gfyrNTHmvHQG3VhYMc}W`ViJs00EF$R=E{l57o~`-J&6BfMuuF@C|n9OA=ZA!3?KC)a`%GmuaTSG)bkQc>eX6(5CmzjDOww}KTnb_v$j z*|UJ;GHlaDw<ONc91khc-Z)4zH|6{QoyyGFw(DdA1_}~e!C(V`m5q8V@ zt8pJxuS5V&K(W8?6<5$1SWkl@E8Qe0brV=^#mDnfjYk#p2K0ApMsB-PMSnTM^tnb8ln?p6{FX1%;uD;)gW|Q!kBWpZgR;=! zwv51k*@*Z_W z*;T@2+J}N8*no-sZ3ZaMPC(AhCMDl4T#?#@^7UNhu)K)6N%0L^iV+k8*LVf>V0fSiljYA~b5 z_)dO_FFDkEa+pq$EkDgaOH){u4K~ptY<7xnOJ$FH0LflvnwCNdrPjy$%j+QcPib(2 zA3A8R`r^mr5Z*ICgCF@9e#c*yOT(8hy*Ed$Rbrn^tI#O5s;b6+Mtg}h|2;P8{!>Gq z+lSX3v~$F}bBJSI?j3brwqLHp|L}30CUEsbN1oel`9a(G&%^&RzuTRo4onmN>vUfJ zbK#=x!ymqX2|fOk`uV=oX?+|W2_gDts{<(MOxPQ9j^2|yP%4IC?7oZoiS$ZNpE^SX zFiG--%ibjH)TF;KvU+i&JS^d>!NvCoH<{DtlS6U>>zaCsB=RVnt)TP9Sh3H!(4Liz zz+_JmQepmIWyAa;pK3o|)Iu1`Gg*UiLZblXF@Jm>1$VN7;4aNYgv`X20P;$ePuo!$Z0a$Wv*)pady)Vld$ zKNz4|Pww3_zf~=o^}3z@OF2+K@r}sgTdg z(GM?;Vb@J4Br>~zq2v_DQBLtH3PfLEuaM6){5#{5KM~pqOcyCj8BGD%6c6?2A&kK56 zM*?;9)+jYJ-L|DlS9tvwoeGH*t~yF2y@@-ny3Jm>UIq6nSfKY449%B`vpA*xIZZz7 z?eI=n5x;gx{F$kjdJGa7-R)^@u^xY8(SH6F~r}UZcqz?}tfPbBA zrDfLkjWn&i#BTExywsdJ%Q5$oeK=u5VoyM%qG|lzCF2-j?n#%BeVZlQH2vRVq5iv8 ziKWUE9iz?*zB9IB3ZFD$-*R)f382iVdf|LSAWqu+CWLuFCH73q)tBywr9dXc&ZeOh z0gv5)1epjTb1J{ET|vJlD2g1#)C@nW6Z6{kHDbz0nM)n!M|IZ7GHfcLMbp-Qfhd5R zXItnQ(gFCs^PmO$K1|O_6Rf8bQ-2xLSG&^CKP__^I86JDiLwQR3f^UjA9D^{s(iMw zC=9>NM+Yfh9dcNYe6rlYEf-%&6jr;y%1C`Bptpy&hEJz|4PZzf74!Uzeb(2z0M@|= za1{@!cCTtGB`7x-ndi=5v4!Qf46hOxGa>Ve+{$QR*-4{7WzNX5`eB1oyyEEVEkMs> zHzWSE)n$o$0K0%U2e1ts^rp2?e7tYLo?T)9-a&AOBY%=5HbPs(&g#ZrNKwUw zzJT^Jk9%P5uJdgMh}Q(dE)t!XWc`fHC4R>m|FOUO&bh@J4@Ri`d#lsziayKC#Q+)Y z2cw+}7qNY*^UeO6sl)!zEk~;pfJk(1_FVss&-LHnTMCB7;BsbyRHD_1EI|wbR@O8$ z@i4b=Hz6a%3g8rZm)VfQtdS1aMbBsuNURVtkDXLfVuYDQ>CJMG?Ze&=-@knEU-#A@ ze7R|Nfb%~3Cve}WS3K&_?FRmQu-fXxXF^&MlH##5R>ho%f{8BMs;X|(IA3JxsClx~ z)GekdzSPHT5A|5m{k9%?n z0VVtotR3Z~fuXGEUtGAbax@b1L2OU5F4eSiByYro{Q62ilteI}pR*|kSVpFiqk)=> zlv8xv$8UyVtImgo)*6*>&CYO7?WiCd(aM$?naN$Ejem=@9(gO2U{U{7kaGe|nueV& zum^G+^(V6pi|+z=W3I|rY2ob!Fkc@?N*ZNnd>M}s_)|=x?a&hi%M4D86Jhw#-hLLd zNndQU@xHO$etGZX$Cm)LI*Jn4u^2SQEK4tOW*KJ?XxfafEm!s~M#Dy70X%ypqgxBU zIK^6MI%D)|;d`rC3qLr;TD6L3)v)u5*q&;iOi zvIdZAITfH^zfPay>qOH}N|!?!!l^^DLX%xvA0(3ibNt7tA7gn6a8i0f>sv$UPJ+O1#+otLeRW>t-AuAv#fm3kkxg&K>l ziUkoV8KLmuWuylcbyxo#ebh>f-mPs1*qWDb-m~XUK_b^Ih$U`l4v2C$n%{gle#%x9}k5T`+ zMAXBg3o5j3GD13kVtXG<3T4nTFPa}>3^t-&-JO@-?yPi^$Oeha2Qd|L z7#sl5yB81a8Bk`(&|5GBJj)NHoCnr!zx^f1fY)KSo(j9~qydmAFJ|=Dxi}Oh=CaOE zjGmQDd*NMP6)5cPiLr&g#p?xQ7gz*oE4Gj$v|arD z@QaBskq>~gRU#9{39JZ8zI>G29Q_{Qy4t)#|Kz3rC$U$Zn50|byc}(tf2Dm}E=Zx5m74D0%=7Gpts12O5u&l z9RTlE+l1BolJG4!hZ2&gz>(njcX3xUd-QPS=^92;pkyG>(C>D5za#6W=Pe#?i%gxe zC0yiXY1fv>DMu(4U?xYlb@6d?q5M1Xz@{8{`-XG<4X+g|CGL+%s#kCZIXf|@gMoAJ zV+TpI7aMb2-E1bIHwJFl;Vr$Q(`W*YId`|Zz{g_HDl3Mj(|VDBi~1rCDER3np}!l# zB(o_#hb=P{VMH0T?C=I5QNZs(R7tAhg_D#)DaTppwd2QoV&p<~`DsI&uF_{0H_w!h z+p4HW0(V^w85!MeI}zozX1&$0n&k+jc@6`r`*J}d8fK1f%m~88^<(e2g`r4f(uQiv zMd71qb@gC6YWYk#Z%?FmF=f_8Hsb4OhEnx@GnM^-a)G4_?D%`O-wBEz#;cQWp^I^= z#zT!b8rGJUyLNy3{A{jlY?=>$Tlts5B=O8#5J$z87}p3Npp%H}EJJtJbNjp1B*w6bQ->w;dGe z+U~lEa}}kr@uLkQZ^}g?tn1`6ZJqaoy3u}d)UbY08`fPXsbQbvz^{>-GC?F&cNG6v zyDehl_}BRlGiWFWUup8={qG3iY!gxcKXu+!z`n2X3-nk;VnNag<>kK0@(HjjsL?r@ zof+3Qv{xV*L?QqR!+2zpP+>HLN*Q+L+c5rvqoNplK~p+LUcs+;KC;2qteh4X`@>?o zp@g^UAiUvN!53NXy!)Z~8a41t%mhyBO2Ri+x2~|H$&lZo6 zn6~`NeVXZd@)NtecTN7cv_Fl$pMDwVebAd0sTmU015_9byUw`O!+9L$eKtz4X3 z{nx-{pHL74v#^n=h%e7vq&@ktqmu!Kl)-9W!Xtc2)^wI?ej65Le!d_bVnKxV-vucWm ziiFgTwSY`873b|y3D3;Q5{%7f=P(>H3e76PfQ$6(4Zo}A`(F9ZnO0N3L06d4o_ST( zlZZx@$()@zy=W_>|Y9Zt{}Kw^Ap_4aRH~2Hx_sQ-)E~&SvR^X?r_j+05A7 z*t~_=s|+e;gE*Hn204$;oZCRDOqZe!HN$8{-uwt-e@Td7!9lh&Np6&6*w39@9+s z2_Aq4&8wv|SgHx^?=uJ2yI-NL$&unY;Q18$-~&9zB^}L4~8&=O0BC z<(T5L*y#iZVBs8-yu{2$dLVHxF2;_D*G|ZriGvVPl+cv!yw*Q{ z9Q{dAL+Sg)$NOLG=5(2nxdHKr8~pK4%c{zc&_qig&B~NOtfV<=qlTHJ90S}KnE80$ z^9g8Lnx|mH&m9C8!e3vc2IxUd=T5Lvun8`VVfpBSpLErNv z*V{*6^ER(lqOi#)3ifD#X|I4pp#ukq>^9mtpESA_*2mkOOm)O-4rX#boq~kCyiB?d zA&Qr?>~CeSn4B%2&0xouFY+@EsJr|fwUG{&iqj<`C`&M)B^c`xEyhwlT2k|3F}r8Tibp*NE2+Q>&c;gINGT9-&0E_ zdTBHPGSI`GCF(HMEe7-$8@`fOzdqHSH_cBDaykocNBSe2~E>V=<1Htrf( zX(b|2G&wvH^lr-G7Vx!)y#mDi#Rp}o+!NiE=&k&Zhd!FXA%=)zqcO?ApvX#OT+T5n zvqco$5KB;Ak>RQG1c{-uo4OFl1}~Zb#xaZ%4~DD+Ml0meuyN2vXTfX~@>G*zXpEg0 zxG0M&WICqw%{kstr;B}==h=?WuvORVEpA_{PPf7ho>={=X?v_;LW zqN+AOJD;+g>{=`7D=*QdX%%x@pf1NcH3|fm!eR1xNFIMW|NgFi_22`p0l1(XJgP)P8M- z4#W|^rhfD|-1W-~$FCoADxhDHMN$WahSkm~ld1eh^(yl|;mc^g5WPXUHyqEhUgq;F zW=+mN=Od#_;xH-fU!^XW^lQ4g^usaWn0$Fel*xhrHqU^0ytc1OI@|&zFO*tuO z44SOs^e~uck2i8JV`UbV1HPNB(cX(^G@eoy#}-ykt_)i?Ap>A@H3}pZ zZFQ!?wX*ws_rAZf>!4@s!-o2Adr1Q+sUWXav=ra4(+zybcLGbvN0TdIWO%s_e47F7 z+sDtaD_LpG$!0n~4JDMhfP&<2&tJ#55A^8d{COBm0Pm|)R-KniYwL~xl98aHP(CTw(4y<7SlblI3>U?hGbgu z1|U{HLs9ei4wlF~^5LS!tYx31O(!!Q!!90Fd!@ z!@*N4rsy?R#;!Kb?1dUT){UDQ&uMJLljX)_=Jk!awTxV!=tQRp+F#PL?NN%)wwZF* z48Lo-wwXxOS_|W(qHjq=_A6iq`oPQ^8{(8gl(HOWos+6giQQx<*2_2s#}omlG^~c< zGUaRpuJ2nxY*T8*x;WDlM#RT}tKDR^bGV{p!{O4Bv2h_^6^XBD5IzpgHepF@!ZE%{LY<+6%#z$NAMcx} z1OrxuWAKUobVhmmbPhTIQmdkNr_58>Ba$tFG)yg>Kt(wb3&1Q(LfMwcJH%c_FJrjz z*$Vu(M1P;YKKfyqg>d!@atp&5%}L3^=D_BmijDf}Mnv75)%}JmD9SFt;?X=AH zZ9pBOJtnV`7tgoStg91isT$ZrGMRfRIQ+?3gG=aV-FSTos)ASTpmc0l2J~FI(e>~M z^8!1A$nb<4NeFsMZEbpRhC<#7(l^h?Lz`|LszOKFUMte@I&gwr6Rlkm3u4A%W9(@Y zrmL4O*tI1M6S4_aINDlL{bo?xs|ysIlK>_sH4 zoO7)4p`$888UXQPu;9D5jIB(f(9Ke#3!8$e-IlMk&dcI)6Pl`GtPlzZ(Ze=TNmaipwJ(kVCFOLnF76EBA#Z1p;S)#+~KsICV`*EU{vbo_>uysF^1>jw|?-?(x5 z;r_I*N0O+MAZ~Ov{*6Nsof@5s=Yq-Jq&y5x2dup_^?U!s-QIVR?5Jdjp&z3%eF&iR z#R_^BJBts;YYYDo-XtXQC^HLolrhxxi_BzTu0BAvU68*b9eGlQlQ7 zJgony<}|8)a2{AIC(?)?95n2=X+w0e-9j~UooUZ#!5vryF(N$ena7fBe1pv8Mv`fJ zs#+Rj%jXLjvBkcS1+VKc_w&B zhizO;tyh4mK2-Vj3?=pMr98E%-8hLgaW5VLC8-pAp)HAnIG!4IRFD<@y4M_WMag0q zkq*tMtCb@*wD;OlJQ!|A@S5y~&EZVT^<%QMTCubZ8bGGx$i*7b!=O)dEr-<-sirHT zM;zE*;uY*h{UhEKigB@7H z^8_B4G|mod`uxYB`D)`k6<+6ml##B zN=!o-c!T-D)U1$zVv?U>AgVo6TVW`Ed3wT5%!+OySPOi9B^PZ4K5PP89q>tCo@YApl8)75&mO(dkt#R_j{R1ZP;vKaWR2xo^oh82_{ilXD9(l#eJ4^CznGd-YCTcIvO|j0Ei<7t`?(Y|s%VIpRWtz6>VmVhKD z{!nA63vd*@Fsuo59-auLEb|E>Y}RVe?3au8W)>?RzD$bq z;;L(K;X5}}<7=*Qf4q{#o51A#yntr@22Sd18q5fzj0FtlVUP0YPAR6a$$5*{N_?i| zI`RB#cGuu&H?iC7@@+QrTcGc6fU>_5QAboAbQRFV82ESU6*hr21`(h#ckfX)Rch4( zm%if)fJ^l%Q8`1PsRtRQ7~nB`szY(oRBZ>6sYDF4mpNR>1QOh++(Bdmi*!x!!AQ`- zje36B>&7Es@s0O-jYGhl*+^Y}5r}C}G0@!|uM9@g^Vv#|Arm#Ou!e>m^qWTJD?Za` zKh zIUD)cuSPrYLfvp2=K9Ft0Q?IM6Ek@A`SVBX63+g6K~Nn2kKz=cp|fX7*4c8q!TimN zLo`P8XWJ6IxU+GD$^BHsg$rwe?Ly`bGD;SSpD;AVg%fcj#Br7Hv8a$}eenT391e0yg`JM`q>ZXw=#Aplk`XpqE2jPajFR%; zR$*j>yd-fHcMmFOY(nTJ~A63{$lnB`mcMHx|qNRwr`dWTN~Qp6;Ca~)OV|opFO5uuL0+t7N5iK zYpc&6C!2$TO)!BrP7_T0B0jiic7Wyv64NxrP^LKGGCfTvxec)aZ_D0QcJe8oQgDs( zytq1sm%aX3{xToDSbetk32 zX_DD^@0|5AS&HC1kd^n!5XuuDV|(!@J#LN+vv{{L*}KB@1n?H@S50f@6y8#xy+n^BEUyx&}0*nxw6Lb!VUv6S1nA_NmH@3CozEK7*eb@?e&m7> zsIe6HZ!7c+;+T4fqjDf*MpUS6YvY8v-immYf&5cwfHxARpxrWu6l!s(hWEvI-wn$U zY#nabJD+U#bGt?>dNzJ^McWo_}aY8HE&=+=&J#?aOdv?(- zYMzR7YxkN%n>5@ENqH~0$K*{M%;Efo!Yyrx+syA zx$3D_XX+e@1J)S**!f44#)!GwfFU} z{MAM8ti@>t@wr$m)yb&gW=s+|o(TQy=@}>Km%y9$&>!6^xSd6Y^sKl3T+ZuUJtbpz;(BrFhm{ z)|a$l_qifSlBZJ;4W(Q2$m8#Q7J#_6#ixLqTxoui!q?Fi%FAC-<>!{CIQg5;%jf00 z*~JOaQTWpPOaTtOSC+$%ShCf(>Lwbt|1zN;Ny7oSUJr*LwXT!8gK<+kNG@~7A+9Vk zqLrGJ=kgq+L`%+01uhxukEl>f$#SS8hEp<`Qf5GIWN#Z&u>IF}A3qM31HmakdPyDD zbB7@>SsZiP0H1)W3&ahVF-__?y9tksmDv!!8onaD;{;a09o3(%cLpHoAYTi7FLa1^ zHP{Img`0LPyPvYWj^?jy*EtYP{xJWPCEr~@p+k(cvV@YSK&ocw0Y3G)DILndbx}c=ekG3^(H*%1w^*mQ>{1I9 zK8|QK168UOBPx(yrH--!-*7$DH^+j%4c^jsZb<#s?K~{`V|IP4zUYg!Mo3SrFtF}} zl6gHh^msU2H99q(sOi415-VBzQof%Nj+jO?jQCt949!xfY!F{LIPjR6Kld}z8zigGB$+diG0Iv?$%|K4 zR)Q8wn*&N#;6*U=FrOt~ScUlszM+!JO6qY%RYXHYgk-Lkif+~yP*K5#)gAB(Ftop* zw6gArKb~T}gID)qt2GHE1NGpc43aXd@K4J2jG+_GMy;c^ZStmix#Ffr5NHyX+Hn(9 z($&aDeFnzKZ1kVAYz9sI9shKb(@{6+pD6aQoMwK`D>|UwB`Up1eteNo8xdptlXl&5 zV|A)^NR1r%*0m$=TQ{Z&G@y}m+>XS+!R=!$seeT%~wkH$3#w0CQf}!)ZFrsddCsa^~hti2zO<8n8 zDlv@|Lo0Xtj^nYO6}V*VLT&xw@UeF~L(2`%BMwlSD`d@4_>$Xc?}RL>+*JnkF4HwM%jnym|G5Pf6#Wz?rx0`O&HZOtrW@MfNgdhd+Lrn%Fph+=9D;?zr6vN~cAvh$N4|fZT2)7ly}8#s`1!stDGJu8Dm6hAVQXBdVt7 z)}fnlP)U>9xOzr$*?CP&nGFZR$9cJD1C|t06Jj)0T z^>PD=*0y<89u#kiGt4$=>~4XLV6$KNK}NhsfpW*gez>aY9!hvx99fVW+bEg}=jKUP zAe@4t@QU=DpJ(8KC6aY8{5ih5qR(|5Se!a+$ zNzBU&kcj%}tjzqTu8^?9(L7IwQ;8H~(IH=@;>&ylW5d?m5KYFGhzWi#;zBn-w`otT zML`(e_Hc<_M8lSdp|aU;FP}6|7o3Ko%ci<*6ZNSiq3?J)MfCgs^FEE%~BCk?NzOu+CRPU0)M*P zC6J%`e1zj32`H>zWk_yOkB^j&HT>UI=!l%CRQ~uQ0Py15jPr zC_klSMO|TPW6^e2liG~6MKM2DcPi%CHP}(IDMP~`>$1O~mm(}HfXp=gY?4>4^&a}A zOh#5dDDLqq|iX6CZSInt}wL-Jz_JzVookpMUQ|Cu`5u&lK`(i^f1|NtUFh)2g z3_+(8n?Fn?X{RAW$T7GaKiCI+l}>w0i?qB!)kA0*3Fe#9jCv7GxA$@GR9QO zYh4qyw8o)m9gx${%2 z55|9(2Lq&c>Y9W#OfOM#@x%(!qh+|vp z?F%`D@EKxF1O_(rhZl5}Wy7qAPWK#dKH6AlX({PYy+f*Uq$|lQ??cu z?7EPPiQTKZ5 zgf}mEO?0>VEsMW)iPPjgYgvCWcLWxFa6!Gy@}_Nd={&^~R2QB!w1lc!nUw=(eg$ob zn7MVL1%Ep^7lFtq+_BxY#mmX5LiE8gTV7$~{56fl z0zL6BYqB7&Ce6^@JMzuBSnHf%*hN6xBhwWk@yz-}u*NI9G}Dlwx+6yM+b0(XcB9&A z@A<&!Z}K81gO!IUkLMZ{Dt zzT}L#U!Y_B+cuduU@1Bqk$l>c2y}u(70-Gfa8Y61gM{(3spIuo*TWRd5eVw~>jD5E zKoBgFf0O1XFsic##zD)O3KG84J1QLyX9Qnte(>mwF~l>*VoZnj&?(SlPnF3hVlvDX zby~{WUTdQvyaZvr42%50H=UhPsAsve*3C- zGe=gPbShCUCSn`xe=|V&-?tY;EDpU)LfJMdS?WvJCfr}aAesPFKboVcaDNg4X%pIa zTuL0FIcCKX2zC@gC#4rPhlSF@q@y$BmJ!RKuPkM`rOP(!L$xr}jDb;Fez@}Jsd2j? z28_Gt+LpYi>gIk&DInP_ll3N)@&eDL7e&4a5GC22Q+x-g!Qfp3KamXcVUfj9R{&s* zCIDZR!(OyUEf`HY!+fBu8yd_eHVchf&h=J}1_gi=1gVUt8O4h7N8psnS%5=b`ify% zP9>k&+GtU@=kdd^xv><)?D z8c1kVc~aj8oSspYQEznUjG&Y*V+K#QKO}jHdZw+QX~`*uhm;SG?v5qY3~3wsQ%aQg zGre!CVRReCoUvn~l$tgeCt5@qOL+2zVWIeHj5KS*%Xb2Bj~eG$Y;= z>}VtUHyfo!rv_2MMCpFZQ=XRwv|`tRZMQOJyRC1)6ax(Sf*WzV!OfsT=Z5|v{`4c& z&H-)T@*@h__KbKMZp~oZTKY1x6C!-MBfHv`{Oy5(~E3Pqk7i~Sk#*~gstJ_kK2ZLF_t2~`Jbv=LwVh?-@d zH@N1qT&~<~u#nC|Wjw8uD3wl06F&Xg%fT9GubtdybiO8qv{tLsbxxsA-YCVh9~8xX zQE^dTiS0>_8-TYBsaz)|*~J*M;nwO+Gl0|L$`hIGJJkUN`-cTcIR1*&i_7O*=rPtF zK3c8n*JFYmcIoEpbld*>w%X4+t-XvAofoE-Y8$oCgi{XRUYGOy(H(9s0yAyzE+uKJ zs~8Rdk(OCtX)o?UmDrnO6yyJd6@E;n>6!Mjz?Z(ev+w5D!U9S*m3yAH)C1td1SdSAl_(a}Fg5n0P;~$r^;=gF+U#@@ri0LaZ)#dWh56dn< zN|lyLGp^?w9f!vyubko~Q;WmI(Djs;XBXF$Mp8+VYZuscl>9&sUceudd1#X6L$77Q zy#6#@YL1#%S>lU97XN~dDI+W(Loe!CZbkQt6s7gI90BdKLE<8=GnZ}@D;qY3nF@9d zm8yA}r4D|v0*itDCK z)Yw4?wGeIzA%`KuN}E-eew^eZ7IiV0)TGS3g*`K5ziOdq8VfBHjg3OoP|>#OI0+gc zSEVSrN}E6>tMZbcFpLZ7tZZyH?aPU#DGP`&YkpZXVn1O2`uqxE*o=w+iL9>~Al@U= zi#CRn<5!)gP2@eqg~GpN@KLpQM!Uv)ag!Wo`~U-!IRn`&q*EjEU*w<3og8DojmN{> zT1}Fnq-TUTFvfQp%FzH&;`c~Eis(d?3L^1z5T0p=2fDf#;0k7CiR+-oT3y%}JixYHrq%Nhc>N#LIXY&UKlGeha z)08i(%EmKz*`*H6p!~H7aF!q`y-?J0t8ybID^h31tWKvJnyC~&Y|-_1m3dm+f;IN4 zoS<;^Cw2MwfS8^h{;>XJ!Cc(g3N#*e*5;-iH^{a1!mfsYej{3(NRA$^=X2ij@>7s^SH*Vb)*$)$%;YAY0T=-wMD_$Us{|h$8 zUTNvAaWC5lg`PGe&Ipmz=v{+559J!VbhZugXqt%I&_zk#RxL`Q4$ADs$NS6a$NOR?h)$w5t0jFJkKtoJLf3V8TE@pa zXoep@er)XF3v}_6>tbXrd_AEtiov02Z6qF+b~{*w7cczDcI@q|U()(9J81P6=?7A8 zay+G#jtUs2k_oe-jTTcY548fMtx|z^B2lu-ES>bvW8t$&LmCsP;KSYJDOK4MrwAzx zG0??r1S@Nkm-Rnc9?~?F3^F*l`RJ2GG3K4KUt#yC-fMZG4pzP7Kt>}3DEkN+?M6Y( z&9z=mQ)RwVOpCP?N@=c)yKlj1b57l1dJPP>b7zKwmRuAwu}i_CMUo=p&j!2D7+WgZ zi>Blx6PbWa!iofdYj|Bhy8l-e{9h{zYX4h(9-1YhdU*&4(l6A&w-kutjL>|!$V3Vc zcdFuXOMC&1JK)R~lC}t{a1SKLR24E_CQcs0h-2=|wdP1{rc>K~*Jl+q2)Hom-%5&e zz1~8Ii=v2sad|7u#^u7(HvlotVGhuI6+geYPt8r&$pGS1+Ij=Q>`me$39*CbX5EE&nDY?jP1GfL(Eok4*a6Wg^?lA%>ji=bSjHUKM6%` z_1w-zg-LUSj5SfaX_5jCC`+f`UNYIFpjF`b#*=J`le9q__iT_?#&5AiL{@6f#mR%R z6WO>|-??l=WHv@C;O=j+%AbhgH4D;e86HqNrS`-~Lr2wAi-<)cYxrR@^zzg$Jd@g4 z80`Q?YQfl~D{#iu_{bCmGb5YUj94qM`tkmE6k&$O6b{(n3UA1ogRC-kPXEKR<(e@s z?I^^sT;3Q8_Lc+kbWgV(lR4s%dQs7S^Q5HP^gE09VFP!*F}36zcwaz>>gJfLI1N7zuuqgrqJ!b`XOhqHXaH29|RpsTOJox$t!n6Bdb?;M?>^ zrXD6FV>hW=dCI$J%r#zB&C3*eurCb9cb69;5|MyZ2$(wYun8M16<;Qy6vYX47aRRN z2~L}3jtWeoSP^Nelq(c#e6HfxS!Tob+AiJ8wy01QJ0yWwN)ic3;k*L$+`i->w|7gd zNDkqw@)py?;?xZWGb+lkOeRGM@?@iJWBfXdtxK6aRB}Z@0;n?&10Ye_RzGBsn~VHX z@td3A&K)`DV(oz=RhjCXlE5JvP(tT4G|s=gJHGSZjUaYBtvJDozL<*vUc z4ISCFXzDCD?Tb!DV!W>Fn}XX1aPU)2wm;s_0iz57AK<1)a8cTyz(&-@xU$KF5&3QQ zvHOBU2pUKC2Hos*csPUQ1D`Vh>@tN^Y+QNL|x+xeX! z%Yos?`x1J9a3}{2Dct;eY=7W<@-5cq+Y|JoboZ_3-8LK3@-kaR6rR<3>8~!i*c1n_%aF-o+g+!kVcD+rPOjYEmcE@6Oe<(GtJ?T#L;L=5}_w7_A;3B;~wf8_j*)Dsrmp$A(>--^U-J0j|x%NrcST z4Bk_5&BR?yVmdRUW;0V%uJDi?NzrPW2^)945;RmN`BU?(iPtVpVAW8%HO<79Yr_*B zVw>>CsfPboY=yZ|`ug3dwsf}*saGp|-5Cpq29(H}bcYG)CSJD%Z7i)eHv-7>irvUv zbbEOfHZ`XuAbhN=8K}GfzM`@Ez3nBwv$|^u&i4`{9I1$L=AFwhtuZ>b)w5wY>{l&n zI@<%Ea0;v)9);G(Hb$Jd2XpbmqgYJ4+KdKw%xO>ww^PYz;0*ON40oE*L4|^vS2Q_E zh?6!-W)q;& z*Gk}MeIu#xTHl+Cjm)7e2Us!r3p}*N5?os9I@O$K;UQb;GAaf)XA@TG=vx=;imeD- z@I8#N5oT88k9JuH2Sv4YiC(qtV$$5qImmmgWc5$4ylgipg>0#IGgmbjRH7i+ckOYC z8@f9YOSDQvB-5Fx5wGAYV*}8P1Ss~3c^tlvmLu%_0!ZJCwTw-<6h2&OW0`#isYO1>pPr?*06NzT$}_%~0!dmbK)n z@?P@&xBTzpJb^sWPPqPeh7TPnO zTqkFM1TbQ)8NtCX+sXd!>x17m_qLOr{p9`L?yozqwqGS5?{DtIi;wq{&3CU7EVlXK z;FsOKPv6+uMA1u(Q3N{I+xO3pTm8{qyD?RM~}E(4uSo-PW5A zuXf)3Oci(DzJId={ip_ZUng(3_qKk4$IYL1-s~Lw6`RBEU+)~e+uq;rK^w`t-DLaM z?RN*s{x8^$8re_V$(x=)LW&gD$qW^G+TTD73Zv zZh!kfKR|O(EP1v0cJpT(2-h}`zx}d#u)hnP?j?KM`ybvM;2d7>?Y_n4-t6wv$Up3F zLpPfTn^+rG5r(|qg{s>yz&#xICj4)UpdU&@zXyApIEZ)KKfl@edHdbgHdMq0cd5d` z?jDr=urGDG$>!e9KK8r&;Q$-hr8c3NciY@3u0AaW3`AObzr6*4lie|$_a6CFZtIFz!w~^6qxX8R-4nN+ftS=w$AALn%)Fw`S&$vMSvQwqD*!7tXXtczWs#4W zIAyHP@_g{u_uKSFZ7#l3JBp96cKaW;wgCOW>QNrdazGFMw^i*GCZ|CP< zybg$%#>@Y-dvLJ()*I4EF`X6{4Wp7e{=lSG)7Ye*H$17PM+ggVDlr-{55Wcy4ciZw zpWmv*=NHiZ=BrnxR}c%-5N!z{%x`xblmgFyyhW_!hxb6JwoO5{6^xbJdb7Q0mk3$Z zNquX_0*?EBv&RCKrCT1ZNQ)ys)zXlibn@%L@w?5p+xzb~x3;M6(coaJtkGmr@{cKXGr zd6H%{qKNAzuLX#Y?lizH;G?#WfBFDt%p0iH(lw7J9E2TT&1m50&fw?*6wTRZSt9q! zmMYJStKHErAn;GBdy`J`^i6t_4Q~yDc+h~2uMA8t7OlPSD7)d0`%}tgJ+q%{}8>G$s%g*Ijrl?`X|Ct>mGV^Hy5$8x@WIa9D{ASnrcc)*Y|BG*iWd529DWC1ukOR(#>b!^itZ zjuctT)Mp$qw>IZ*3hKTqM%(CU9&5w2Y+n7_zj1p2+4)7gqarZ*P11>*JDd>}3x@N- zAdb1!Es6t6!Zs)J)JfDVMxeV;nd2jou`(3ZRe$=@4%&^WsessTWOKqad} zNjP1gu7A%!MQvSiNs3kOO9}$gJNA3WTfQ!Pp#j)~)bCBRi}4U+0Nkbx6SpBP_b?;p zL@jiDMRx>hb|+E5fWLu<98S*P3o0A~G=di08kWIa&}Sp`qHyODUf)wEn#=#&znMv4 zl`=^aK}+)1trZpj=Rfr#L6yDiY&K-SL+645VCjHcm9JZinzjXX&;?rxi;hcewd1;M zbtB>pBK9yF?vD$;)YN$gJP)8h!B1W#|D;oWe}`V}zTFe#XEw)zez5umP1CVI&rrcx z`}ry#;5Bv4*GXet)YH~}oEGESZ>)ON^Amg`vm+yf@t@K93#KXN3(klH3h!Qx#E?Ov zQFyidhW+i7E(EaeOy6Tjn4!vIU=2V${>CF)=F8^f`()>pyA|PA%WmlC`b@O4owL-% zoBqQOo%RYhq^*+vVrWhkcRS)@%DiL>)ME#0`ktX<4Df9^y#GtGE(PRSE?s(VAGr-QNJVs7Q2y0)ivpCa>3M7McnzrLyLS_DdWJtaWy~syqx>TEW#Hc*eBnSSteCsGD1YxZR((HAugSMc%#f|J888B%O#ThL zIx2%mt2l^gj!1qSr+rdciTRtS>Vw8spo!H=%^MG3d|>I1X<-{yg}agsfIh0a>amPr z=_H-}PLojAY<`#S*98m0VaL?l1HdiSprH5ddZG#PeKD}LFSjw5dnW=7>=pEiJwa>x zi$wyxbC(y{^t>2^N(aAQY{_Lb7x}a;YQZJaJQ&fUX+f{h7$Q`2Fof22Ww-T3AR_n! zvWZef^%>TsShUR}yy?_rrF59xaFSgBc?HXo_ z+!I#bwSpC|^kGfM&AW~I;^?JmyYb4Y-e1%Sd4T&Jf=+ZCFEKmJ(Pp3+_moNt=(G#+ zVP-1m-pjBB_<-Nrpdjn=Vng*G(8SVPN7+a629n=~Q}ox+M*ZN{UWCOrVudmMaNZa8 zm#1TD1)rkTkCBw*L(hjC^AQAoj1!Pj8YdKwVud+XJmI*@5uPFwQ-U9RWjWb0!{i1job~B! zPHW5<+t&Co?8AGjyV~#}E4n;uEXD)xurqp>T}f5ukHQKh6_|B#PIt%0zkb+023&NE zD&+0I92_6V9Pk>}_(iOZDt8*00Pn5h)d}U7v60i4nt{+a9g4AnXDyg@78;i^>sKRV zkWX?)U&v^gbHks{MxS6Zrx|QzKf3U0-Q{QR*z}^^-

    ?UI&?^>XB@o=uL>ikljp9 zt`h)2bo`*`Iw}lGY0eOOikzrBo1mEyCSFC^s+6cxalBJb_RJE$@XoxzvHS^Lry0*>BZo&Yxo*d$jqd7c@ETCcpO}t)VA~C)mkN)@=z~-1=Q*c{TiOXB= z5Nn{)fy*-pPHV?i>U7+1 zqgCo9%7I_l$Znmghzu=q3%{eE7*%8$UA>xz2hr_Z&-`5Vm{f|{(J6- z*2F*oS7(?yW@1WhTUx$hsuHspsY@S@^Fh2?l?ql{;4;UqOuVTG&m5addF%=vn}WRM zHo%@;3OP*NOzaDaT=icWk0*oT!WJ?`^_c8grC}_8|D6jj9g%1GEPN4swH|SI3NUH|*N_@jg~qDn?7^SS3_ZHBH*IBUFah&RWYXq)3`iO9-wEh%HD@ zsLp>cMd8B+#R919x-Z9PHnNlsqMe?t`&JL#0AhqX@nWlw>2x|l-6WbRPV#hVh=zzC z?{jf$`K@9M+qyK}VGx{3z8=z0F99w-;*0;^{}=uMP#mc+6b)pMRz5-qF>CR+AcfTa zU5H`4;vLChys@t%hzzs;0wj?J@^wTJL&7ae7NNUF!U%1}NMq%-+vtVJV^A!*$={qr zuDQ6;3n0EVhxpbOMSN@jGl&m}$mN;ETo$|WX3Lcym08M1Xp^wCbeh7tE>X&%rG7r? z1H{7f)zaz{g#ZnP(@{_f)t%=9*eS$yAMcZ@Oe4)xH2Y`QgOB$)6OaB3%zrvfm&Oy= zsL$NQXguX@^{`h=&X(6!R#ukv za#8q*JiGd-_>47Hl9lA~>Kgvv#B_Dh6AhBKm>h)}3d?}fOqDihx{YqGG#QSuu~iJw zF|@0T4Ay-@|MC9Y$19JLwZ~8TE6M7^C%xxSo-VDfuJ%?QK1|jgJzIkR z?Pt37Gh5sAmw5dpdYop2Qe?Oa%Lf0axjaw!Un#>6+;(qeW%VC!o4rhp{A*FdyH-PZ z*S--h3Gdo12=Ce)!n+nHylZuYcWp7kyEd2bu6=XD z`|wtT_n{-a4;Ll85C3-&UUcREUqE-&F#jJ$c8P3m5gC1iWb_%6)Mr9c4LN@Pl*#HN zOIGp!B~dbbzhcSs77}vP1`+GWhFCxQ#|1REy3${J*js)61Qz1aTC)1A_Y7*luSaX; zl6_jD7x1sVTH;ssfj|D^0-9ZW{0N5mgb4LxpnMOLRj37J*Up!oJwqajBy|N|@#iJ_ zd*Na&=_|+OGS$_UPMC=!Z2F`r$XC z&=2oQp&x!r3jOd8pwJKhRVehsucy!tZ$Y6S&Y{o`;}rT~9ff|l7=?Z~mqI`M<`nwT zttj*(N1-1rN}(V9@1oGz=l(EdJH!74gt|J~|7VNI&qYjr6cv-73+3H%RNYbfKwy66 z1m+8B=kZE^Y3*_E(aK|>evg36uJj&1e~iB#Jt_Gip$Gool6|#gAC~yx(GzI$(Zk*o zq>@j7B>LIYM?kt)p2JI!g&#j!GUe&%eCf%<-os}PkIkesovz{ODVf=SP14d4BY-LY^OeJ$Zg~ z3-bJE4tahQC(n=S$n&Gc$n&GQMV=o!^89#F^8EOJFL?&ckdDqQfqwR{ zPN2Kto-s9D$$)iUry_MC6TaTYT?LB`Al=0~r2+ANXK6wN}>=WiH z*5KPC{P_z|xD}9OmyoPKM2Yk9bD-eQm#~$`K6^7jPkN8mfMh>} z$H#pTiyu9Cy7Uk`c%DG}PuG?nLdnOg$up3(9|Kt%u04E?T|HWT(pyzziTvYlN#q~@0Yv`szY39m{Pjfs@hyn_<2gkBah%9Mt|Rh~ z7bEhI=MwqH-<-%lS;T_N3qVt2x#hx$ktZ>%dxK-5@jREzE;axe(jwKu$NQa_Ez?Vr z%s#*P72~6X&Gd8|(H0sV9fR4_`B-|sC; zckAn6xb0h4lDOc}dTR~!C{B2^*5ig+5;;6t@6jBmb-h8jh=+VC;pfqut=al2+gWU( z$!7Kzrz2|g>Yv+NThPw;vX45VJ8VXw!MaI?k-aETHAZf!Lp7BkU=o4sr5830gP35M zZ)C;$#Hj?HEUFTC^53lzAUj)Yxr<2*s>Zq6CRYI_EQpb1#ekN3<2Eb&P>1A}qXi_E zCp8kwlW!!kJh`jH^5k1eEKmLbiRH<^ip28d>m`;aw~$z#%#m20#3hy|brQ>y#Uz#| zb0wB1-&|sOS|hQzq>5-C??qXzY)?1Y(jkr`_R!sgJ}=_c!|WRAWB zCE>pSVdQ6{_7^}I;uYh9gUTCv=rjh|VQ9lIF;+wcLa)Typ%ytz*ntiHS{bu-!^xnP zR~V=p<-B+qjN`pOO(z(UJNof`K|ApozbDu5Z$RQrIgASj1?wUqDJq5&Up!{eZCr0+ z#J|c?P(YV>z@VDKOG_r;5b!%UwN*K&fCOic6g%=*4?iAwr=G>BZunx}K_;G@3lqGM zcx3yXOoxkfRJ&$S|MzdjPYmG3J!Abb2Eqh<>nUPp|Q)HX6s^g5M-VLNnKBVr{74B{?e9{ zgoA#S4X5eN_;V+I=)90ztI1OGHl3dL(v!07w~#EG8+JrGg^A8i7}>DMe6gitaRoDCA(eZF}phRlpA`djoQva6fAlGb?c2v zk6;Vxb#fAG)a@ib&Cx}){n8vdRF9C}a>&r{-CLc=VsVVMa@P=R-btmt>%xP%Qx9E^ z+nxF-2e!>HgGOD`bW_>b?1BN@?l7AzjL`K*%x6x+D#;1YrMfp|Ha(D-ZEZgorU$@A zOl_O+b)nB}vbwUevUp^=xDqY!K?Yuz^mMh+Ril$5&^g9qkI|04o(KsbH&4GTp zkw}0IYunsspqxgJ@Ar5#8h1%&$Z6Ut7Z0;84&lwbu?*AeZ$6Yt^tCx7AskS=!p$ItH=f)eWnr(ZxrlW4Utu?a^TI{%7NPwQE480laSw zG;x4#hMUeUTe~F?Gz@9sEo&IaSGIARoo^V$Z8u-7SS3=ths!oX#}{#3#hgW}Y6Uba8| zpR&K_P>g~7eM8_Y6`j#nXWJ5-)7IBUn6{i^LYa#bOF%i-xtNoS!$QFNU1quv$Qg4j z+r?7AHT9CM-FL`3AGv51%8P9UtmVF`+?8C1_>8}j8*BT_MvS!HAhCKuz9^0tG^*bA z+n$$zTKpg|nYRh**2FWjw*zPQ0g61Pv$FPVHdTZHn@`mlaO<#SYR%~UNqlQE%8+zk zUWULhV(?+a@U8TC+B6$P zxAQ88uhfep)$p46Iqyu}yJwe-tq3Y7U0E0e?k#mLE}j*G+7oW1GJV`cIGsx)jJ)V= zVvvqGQZtDED1mRINtq+HBcTU91Q2FQuB1E~RY0<`4vfGpb$VcBkILTiryiitF&Ye~ zXDQROjoQl|AKFdZVey-gPLDKkzY88lJkE@41zME7$}OPfK_#5sevT>Mp zXi4Y%F_kK*$AhXiy?JyFwYwTeG`>Q6k%bk9AL(LsLC2q`HD+{AzmXZ;)4Q6{J^hwu zbWi^PGrFh$DrR&~zut`Q=`GCYp3X6&dm1;Rds=5k_jEBcx~Fr^=$?KXGrHyF#EJRl zLJ`=GPuVCr1*RuKhtG0-dHD>^$Ls_RW0!x*N9km%7-Y*ZxHV-HRGP%sB6d8hG0a=Q zNKOpks;RBxcb24)6J8z7|y2IdokFY4^wIu(t5*OYI>-S$F4Fd>t5h< zae4~X-{A8Pn33{xWSMQXDP=6SwGQBMekIDd%(o9)Vt31ig)l_^SYMZuIoDO@ul2Q! zeJp`cDl0T6_pI~{ZLXD+VLd*&2+&lXkaJ^PYaHxw?xPOhTR3mcShG^nmXpG53LdTU$`pd{!fCKKn+p=CixXn$NzatoiH@ zkTswEtH_$qzFyXRb_-ea*&JE(SzOk9RwrvdTTIq`Hdoes_RU?ko-gFGMasCC#}!EM zzfKR7aeQp=Ztm`Qh50WxciwI9bt{7C*SKT#(S|$b9Ay|8H%M~AE!*#R!(J_|#I-3a zUQ%q3OgO9jBV4Gc+s(-&ZpbK2`g3p|N@b(bU_PXbn6&A0bC{bs_PClC?B zYVDKgnkjgYC;;YW+!ZBlEy;nV7w56of}PHE?Z`k*O#z`Wgu z`5+#X!-FIq0gkNtn!H1bGOL9$U8uc)&j^F%ARA`W%!kZ*9xoOp$MA-L+NbQ=CyG7T zsO_|W-lmnSvu3N{?sh)7XpO1pS4$lli0gRKgY;jEoU&wuCj8vJ3=kiOPNRytxPB6)3GkE8rI9FS8aZb zCsqDH-xP`m2=1S!qccBub`-X`-QHXpqBxRDl?8!X5!ktiPo_I}eHa+OB#5siAF;`C z-354TFmH7Tpk~Ifusf$oYA%~Gfw_?~D1|vZXMdlem|4K+vjmubVd=WE`bj>mX*f-W z`E&~MVaavJ?y?)(g`e59j`Ewd%Vu1Fmcm!oMa)god~0A4f>wU`;g;sg7Gu}!t{aTq ztIlnr%kj20!KbCa)e#_wpgZG&9anIdaoC@Ww3;)hnltlz*W#h0jawu)wFt(xRO6I? zcTMker|EsZsHXS%zk=x|RT`3+oRw)EJB>T140gh%YK##RAeig8RrN-K6*In%_qBeY zVuBViF0w|BKA=@?%<3#}d~ba+OtlQ2{SdKO^Hk*nb7^!HbvEw2!x>?O!nt;n}b_Nr$^*<3NNg07bFbQhE?PDZb1T zDAd|sGgh^RSH|%VK&pWANA0q9I6~&d?>wrxbtK)Ul7B(XwUxFy0#=<)J93e{4zSsu zkyEBeXxl>Ns#;x=(_f|2blsnxuf~mOAdAskju28=8T(};42t1NA+}gd{IDO})fK7> zkYRo-fB(HL@O|xZcl6^75#81Y}T#DD^`FAc$DL;k0@=B zoB%|PV4rKpE1DA=XiUoz8>Cg6YekD2n8CfC7>q*jmn4K)1Te+`h7fiZU84vCbsv;C%Bn!%scMoj64Erk3BbSO4S{FD&;;kPFEdt z362bN>dYG`K+)*5m@`Z&@{PxcQJ)tZU^bZ)lQ|>gGT(TJ6f1g>F(y~(g#0C&2Wd)u z<6%m0YHy%MMQCA_^BCDf%m=_{WsII@cd{+qMHl&s2djL0-3ghNyo9$qBX+XJNfjr5 zqj|tzfGU1poN^l;YvR?cb{mppnM^QRY8IEm@IvcJr6t5fjDV_#yRp^CQV{RPYl;8x z8bEPs0MK%uHo@6C%G7_QH~zo9yN{Bd-@ zdw==+dobYdX}o_clgqW<)7~?B)9!bYwUyOJOKU4@YsvN{oczBQGy1fLKBy(oJ!Hx! zq`!Q-bCA5r``M_>dRRuZL=?W84~}DwPA6IRj|@%_ujD1EJn2dZ%Fy4QJkxh{5;)Jw zEIH4H<7`qQ^D>zAQP(E1Gb+P+lqFHm|(8dfWlAluKcMzi720i|l{Rb4~(yoUbm-{e(o zLkANKwq7?R>mMFgdyU7gzMk`Dr-}x#0t0xS^*zngv*A!`a-EW$ zX6y!W$7OPLo{f^LEcrAluIRMVd#MUdr*Lp~-z}j`In2`$XP2niT|UE1Tf*rgp)s&a z*SI`=d`*+*QAVf!b2g=sP0}l>mM}yl1zy0I)B?S;UN0y%kY+7*mTZeBP z9yZ@Lyh%-qz4Qw6Zq#j~ZL`-0Nk~e`Md7nOIAyprDcaLsvO9uZ)46{_+ECl{dpWi8{wJ+t#ZYq z);yHL;0HhQL6Q;)U=kId?XOslD8mkx!kthf!|g{>KTaoQ_Ig;P)3(blQDw$P7@1@R z;gllS00Jo{?Gevogs8$zQPcC3t}@g9bOt+jEtw+-`4AXJgBm9}@FlQZJk*-Cen)-G2WvZi zwHJB$E`5jaOF2|vuA|rt-=?23m<+Ig!~sd&)UiT1KSEQu_&H+VPuaC275Rt(2pWja z;R4zRezOhJ>>|U3sOwE}l})x%Pwjw{!a-Oh&3tSdx6VxsOJNiRypWtudLZ8A({`)d zawTxMZQ>xI%*qD*`4iQUyjAexhaUp*1-d=NB8U0WQ5aDtlt#iCz~b7e$~Kvz*epY? zE#2-MZ6r6z`n)<=su5A9=$yi+@?@3|r%SjE=~+no^71GAx`X+$U}k17TIH~qcCE&^ zrDdmBXCu00%ui<1jQd1ugvli^9rk^-=RGO2X{)LM00?y_*=d&sg8wYhwL&*9Tj4PF z$i9$H;555nh6YDO2qXq^Y>@b1tqn!GR7veOO1JP{pdkPR8aUDs7%CQ`-@B)6YNMjA z=8``mwXe18#8wbUfiIxq-DI^%KONm}VAcSWOmNadOV88N*oXk;nO=vB58rpMM(^co zjPLPF_}mYFL&l(sN4<*V{mPb&;L=gBWnE*M^i#kjgT!D&;^oG(NoLPObVIpT`*akb z3wl2XVaSk!wqB1AA4PWmJST}C3mrmf+UM6} zp!7=vcn01a7NtrDc#d3SZyT=)m)ajcUUinwHp0(l(6CAtv-mTV!6Vk3WWZAbM7p-S z3LzbLlfJ@8?LMHmJ|M9VH_MZ*EGlG9|Ap=5~yXF9sRC?-ZQDRWdQ!thb3 zq`^QD6eeLyFuw!JjM=D|ot-0ta8UroKA99(KoN}GlKceR6rpP3E2ha+F&hq&3y`g$ zXqFPYL24YD%oU(Kl;n~1n#_aAKyg;%9`~msG^-z8w_!wG*M3ccStw1In+r!+V^tucot5eJjwK%` zqQGz_G7Bjh5ttZ&YF5&q?okf`%njp4w0HkLEti-bTjJXVg2R3~La2wW|J^Flem6%J zOOU$U=xG#5q}nglkdk$8uQzHX1Cn8uhB+|OMz$}ANdm5WvzASn7A*T9=Semk6K#oE zN(^283*=_Sm==mw8J6`ErVVRy0As}Y2%0K~pD8=;bM3C3DlbZHjtJ>z^Rmf()3ijf2P zdUkSxs2nyQFI!0jNI+=40yc6yzE03o4GomhBO1$5JWITnMGM0*fa!p!fHa4tlU@&~ zD4_SY2?m6!-d-^|TRs^UXUl6Vt526#9xtyvU1p8jk~!^5TY%4&HYb4impjqT8x_U4 zopzHGVS)ni*c@J^*QLcws3H$Jhf$#nUlZMyu4Uvqx7NT5EU?sj#kiCp8BK5S5 z-4G~+k}PS%PCAh#@w6B$kuzS}1hBAL`?M1+^OG)f(h2T{O*^C!l?ov$o?KVale*X2 z3@`TdNFwEbs+2#8rxmpA)8M%7oWxqGA)>UF=Ak~2bc)7(lWPT=SvSe&M2t2Jo!d^R zbW*|4zE$yUTp?0@qyGv|GOWN!__BE^Qnba!NapR1EQWo)#YpbyJ-9b#6NIFfn@)}= zhqN@lE~fZTLGhD#akItLgWhIpWByiiy>PpIrO0Btof0>KTaJIf#iqwSlp1B2nqe-I z7RfVkq+5q})b(uP{%iZLGASCe6z;iKhkT@IQSGM;%kp#*5oM~&868|qL#OERX+A-l z8&V3Qz1Z-(MCH^MhwZGF3*dL*Q)ilK}vjR>(;I>O>KATOP6 z0^H`(Dz0QcWqBRVRI?Hdf@^8dj_5#1nd;v|+>LwHhk|%iZnjgG7`~Q+Us{ck?CnvB z3Pp8+0W(E878uC_uUQLsN#jo!Kg5)bR5c9mALc@!`6FGpt|rUyh^7Mg>-rXFlpFbs zoZdBe79Lm$^|HUecf5IUum`K&!XP6{bUiUyGPj*AtJvGz-`_qsMr*2lbg^mai;~tL zpJWt@3Ln_JxOHT!zS()bz4h0vH`~X*?C$<~U+3y=ohT3ZmNji{vD$i|-l!-b>aAql ztdwIzY4w_|V54Qny z|KwFL@AI=W+6eq`WJB}-YCFx(bo?6M$dmmFk_(dDVLmX*Gt@b>$tnhLVjt$dJe%gj zWn=6YF#v6}7~*=Q8`!rUtjF#hy74joCRaEh|Drk;{d$c_s>n|MXi5;SFf@-Ji`H** z{~Xn=WckJmK)TX=3@cHV=^1(-CnrTQeHm%rRXfPX>-dOP&b@4O*?YJ9YWsNm-LG^Q zTdrVh{?tT-1Ew@R3crNk2k*-}Kj|0C6 z$YWEX4-z4Koed0XMw`-=S+!{dfLP1;evyWEn7`_06C(Ybqr;?Ki#5y)*+9I0U=t3H zYMS2Sw%`P@!Yv)c?y?G*pw{Qw>;Hpv7s($l%;2r%!6R~CoqhvNh>%o!D^QX$cuZ$|*{ReJB0J32K z#u$(?NsQ5;xu8{*z9WsJ;F_MjGv(Jwvscsld$glrV?$Kg;}o$Yf_CDe*{!EnVjhKY!(tnCF7pwv*X8x7 ze?BQj#jG4&_Y$-!hc3wC)PU>BH5!a32dI|)0Hju-ABNQ{yr)Dz39@7#P07rRjJ6e$ z#+4{Dx;|05ReugNnjjBpfXqLS3mg+}-!MB%``A@l7Exq-Jj_qC{&jzt{ZbU406_&D zoU_b#BF1c#)5YYF%*{()0Wt#v7{JXspI#6cVc-$#xJj@}r_<~ul%Jm4`_P$GW%m8* z>Z*73ka+fky=83h@x$dZ!;96tUoNq4E?!*YC*aJ{BPCCVOa$auV2|d$_ESzK|H;RX zGfdyTvIIZ2U&DXKE*?-2ncur2|xU#Z}kFTCmQ?H-%*VnJM=<(HSetiA<)pD(!lTm%soma`14G&OiK8{L~6k56Ob?JK&`M5RE)_QwtlofM2k z4vE)*Hbx*sPJ$fvLXG*F)EM-rn!&|2;GA`8&GQws4X-En?ztzg5K4TwpgzrtY|36fFJ)oG@YRB|iLFbt8B9_Fu{p)WL*`y=WJ=it2UqzBV>XcBVa)}cCg1~I zme^|l_HR<5H%c$_vvgWaddMSho*}`lTJP`$#ty>b2U1xsUzB3o9nidn>I@@}t-SaE0x`Sr)C4!G~p4yjlWi(WJ-+l_qy~_uYu|@j1}1 zf9B(K0RI&5Pf-RVmy*aM0KxgV3@7LZS432`I8I%9%mn6dWpo*UE~z_Ly`J)J z7YEg;MirSif&X@*^ph%q4|*t`0QW`r_{(`&&a!fO?b&0GfbhAi0w$HyDDux&(_5pvYr0@7CNy@(&HE=tL=n1do~B}g4h zTF)I5|K>)~^?mZXbo5xB1E^Csw04ACQae&f6MNa|5SMU)Hl%2;xEi6gh$BG9``L7( zUZqucusD>Y%p{8qL5)9~YBmx2LL4JYh?U7lGra`X68pBIFb)mYYhT;l`G85mBuB+) z35Pg9lUJ-_jfF|!L^okq#pIJnInG0rOlgA7fcZ}Tonq4AB-^#b#D0Kk?S}kBb8Pl2 z2M?O_eHT337{89!F<7BXu?&0>p;SJZ_4@*Pvp`=#C%5au#K~zS(YIN-m?5zN7b@Tm zqPb$3O#n$xRj3H-Z0_VPqjJoYdd0J)W=Ohx2m}^YRAq7D{5r@_?AKZLp)?waNjAh= z8bmtNPA_@I#_BUt#F1OsG@Fdr8vSpm55q6N2Lt_GL_cZr-%TZM!Ws1uVZTU66q*&? zZU-4av*biFy>X&uM#`&*bvI<5H3T9C=AI7CxgSyBXdMCItd2cK_pHAs(P|}b?CvX z9>BJ%%Mpw4$*T2CKs44%zE1l<@vdX38>Zxe2meOW3~+u9FY|><4k+V5 zClmQuErf%@*5Oa}BaED~s9jV)Q6M}OU9r+R&lmgVU)3U~qb*ygp{3K2i@euZY#;Z0 zXV6>>@1%Ia5LEClzKV_C-zJ)f|Ei&q0?&rAjME9n^W0Mn2-$NJuG?iLnOr z10c~{WCd}s;iZScE^Z|+098P$zj;5AuJTW&u1Z$6lfz`zf zR}SOAnD_~3`hbp{Aalw5Jwb>XvIm#PU>iq1!+Rqxq#ZL_ruO`sH~=Yb_yF@5as&L{ z;|Uz|L#xEJm&++CBp($`xD>$W7hyrBgj`0GK--QxFPHua3X5t&&PDB;YEef|P0^5? z+My7#84Cnr9^8!bRNSLxM5_`oWn4hq8V$D6$egUny|l zRR#hxi8b$$AJ;xMqkKy5ta^7Li>Bbf5QfMGY;jp0uj&v9JAlAPXgc7~&b#zo*TkUd zQh1MUEBQgA{g#Uf(xsm}qiGkU9azl|dpquzjh5SmLoOffFZVHQ9pmD3IVMRL-3hv6 z+uvoX-2I6|V|5uhcKLd(3zO-B_}Rs{EL|ARu=`Vfwi9Vwl&UQ}w}>M}CAci=uKe`c z6!)E0&|d0YF?!FI%(RG#PLb1L7|6hwSv^>5f4pzwBtV~>$Se8y5%c7l>q5E;g%|MB zm`$7LY>YImmql_in?lKsKQoz~VAMe}n2~;$(RPm`u#nL*sb&Z+t%(3x3vuq#Zqkah zo8@E+C-&pS60^A?nR^p&gCfw<3B~7g2@Shwvk_|$p({tve5Hluo91Zo{S5dEqtw5g zWq&KlXyI~g`D~UCvSk@P`dX8z!YdNJq3xwTnb*>L>nPg8P$aZtu?V+jv(2?TnwaLF zzhcAdx7nEBq!j)Y7LJeretJOC2JCUHn!zM-5Ks=WWMO~{%Q#STc(a@qWTAPJ_#$KK zhcIO$0$oUJYz6I2U_I%1kl(3yNow>Gs?GmX@1w-2wQ+TfzLb_{UjNY>#%T99^TI|8 ztcsB>fsZ#*__n?fN>Pm^FN|wC7q9bXWQvcnb3pr9x9o?XH2;}P1>*K}c+5uEH5V;~ zD;+nLzt{GL-y=NNi91=|!}*GHAJ3uzwqwmU0dJpUI0zkNPo&U@CLZOa%yI`4g%^}#Az8-uo=}~vxlMA%L zV-G)4)LZ+0Aj`Ar0*FzEk(e%e4~mHL(IFFR3yYfkYs@O@yl%og`k8)S`Y^ZdA-QT_ z7d=TMW7f!#yGsyt%{V%@y%DcAe0kCAy2g6_Z}}g#yH$*@C;8d=ltNd(%~5$$oKBOi zVlpmNmR*W#G^Td1=hFiBZP}uaIFwPCFfuh%%l{ z@QRFCFLd~j5ErKzS^opOo&oQDHc8Q+%Z}jSm+fSK_w~VVn|s^I&OT=P{&nZo_A6it zH}~NMFov7&UL{y;^TWX}yL-v2o&Bvhn>%m!lg&485~#Pg`R-t6dq4SY=inD?a&Ps{*ZRAyHy>VMNP4We^Y;Cl9q30ju=_fByS=yd3p{TAwDV@?;IG&mcK>?k z;NABAeh=D6-t8uo8zR~N1=~?0`)NCQv$Ofro9*N^JZ--FYqI}-duwO&O&12ex4m^h zy2_n*@{mBGt=)I~+yD6inuB7=tIfBYKjT2Swt4*Rm(7FyUFdW#+1uX#@a6#L@Op3e zEjIUNcb`W7VSgLC**w_9+OUc+1Gb+6(j>?3k4XNWTgvvZfMZAtJt5Nc!E3Bji$VZ zCVS&qc}@i)JL5OZ!9VA>ZG(i`PP)lL9k7Fq*E(ijiEt8FPgt@l#Ji8U7P#6tkT|=& zkYrn+s=aFBI;IgR7`=Y&Ra!b zx5{aX)+PUtU^xQ$nM47mmA)%(yz9LVx)j!s+Sf>b*yMO{E6{ETAyd+U$G&6K zL*`8|PEO_xaC>lqVJ&-fFcWC&Sk zv^+}84-$;<59LFTINHiewbWv*jWH?rqExO?qdMizawuG()X9OVK z9~AG!?ZL&fz%5cy9AH&-5C~Ma>Yx;(@C}E>)-M1lc~K!SOmt?VL3j)lB{u3~Xjgk5 zY}N@c(=lzGq)CFZ4i zVdouk!T}FMOLSt$@$qqSA{Oa>%yqPE3bbk^91Zl=sO*Xhq65c@p>RF^%>dncR39dt z^8Cvv(V#%Y8}Y^keivz5IFPl@f}Pw{L(Ox0ovI^Vj|GTKV!WDy8v!3B3|F5*_1uXO zilt#aL3UV}xptH|a~iyl_f5pAspJz!^C=;+yJJkXQ}$5(@YmzF9}YH2jQ)PP8*PxV z@;bp&v;Zab_Rncen$!hUS^f+=b45o!9vh(tYsZR&vjA`LON0#58VX)9XG(?6_i|r7KF}R3s*%t4N)q5H0gTro&CNj19D8 z*2E98bD^_sd5&SbcNqq?Ifjaddv-R=xP;hDd3Rx93+^(=*i@Az1{wu+0=B}^C3t4B z_KPzR!%YezJ+QbIykzM!cxfd^ey_Z8?9$30K4h-X7?Uu3$pg61)kNAut5G`27%Ao{r&ngIli ziIhuthj2sf9B-*GF!kD!n@h~!y0lXf>DZXZ`38gbtqqeK)+0dhEAgvn4Wc@dZ7p)m z$TFhsQ+`#8NDufYM6A^ws`lLkr_{zv3%Ki~Z6`HLwZF@YEsXYMRY&IIfYV3e`nH&s z;+=d&ai9XB%5kgn`;Kf*^)h5yG~7dT1Y+x!ZP*~eUA33GvB1aFM2*Mk9qyQ8(y2wi zi;1X_(4)GMI$1NaU1SEJS7u%u(A(d1+f5ZPu9*)3n8!3Qh}ItDfT2YkrmP0HPVn|??O=xTF^n< zy>iR3Yq?Jz(Wa=gH47ID#_-95xmsXzK=!EtzSxY$*iU&NR$&o5vt=JCFRH_BZQShBaUVtdxOFYpDhv3bo-{_~#{FXvP} zON3jMhx(mwQa&$qN^uezjbYxZfIgZ8f<&b7jqcIxWY8%Ith&xdeN1AXef9N>tvs9 z2DV94;_;)S(dKI$qo}ELsY>Gn+xMh(09vkDfo@I{`XVCGLY+{9MJ3ld6}{L{LJ-B% zypTT%dUfm~%o?7EOlTZVvoyd*|F;T@rTwrL2yWG_Hv=;e|1&LGyT;bg$QrW9FXe~I z=1VcUqBn_+SCU_=4RYMcSZ+z%jSRKXLRPS8CS?_6k~^wpSJV`Cx7ZQ`gJLj9PO5aj@*U%uHSKPS=#%v&r15)ux352$V(N7ygH=}aP@DePZm>5Fl zb*Ih&Yl~xDV?3KEm#;Jy63=a-A{0p+Qs=&6x~npQOa?(97@&Tr9XF6)c-nUS7!}E8 zy2AmZ%BJ3#3=_X+gLPxC!7hC?qMi*jx|qCcEfhkzRMUI2DTLAhUUMevl*lFKRU|Fi zJf7&}*}F(Tx4jP$D}DJc`K@Wjs|;76lAOHH5y_x70@3^a{$AH)u`w6-;`Mf(|BVtv zgbHn#JtF1er03zYUX2Pn#^t*#=S_Ebn)G{+6yVJ&P`ZZe)y9rbV zQ&00+z~tqk;I1GYE}B4ii+#${!GQf#{UeH`m~vry4vDa-`4k|#fGs4)l9-nvXBZ(f zIJ6{6mLw7rMPHhYPbbA_8gXUqwK}(2FaVNowgDBLLQkt(3Az-za?sheu(@$-99z-4 zG+wjYEB3)4ey{%ORg8q%i*zOm;pbYa>8Rypgj6~bX;)>QH(r$-*4?^?8YHt}H-Q#t zSmRLjKSAVRG}$!!Z=rKvh5kJ({>^C8{}k$?RabcvB-GrUan=$Cp+k-(CsjV~R~#+< z!CXkqyg%N5#enwT%$FFM7&Y(u&@HICl+zLO>5C)srg8j%xRu8lMX#^6-)tXje+7p9 z#`rNzVH-09DNI})lP!ojG?!X1M-o3{JC!nrvtsfuXC_fiZcQ+~mPBw*C>y%Pb!T#O z8&}$gnx{yHK{Bo&gOBbVuK%oQMtGr$P(x7*%|%ZvskVHoSG?WS*j*upwq&0Un=_s$zosqBKDT5B+ zQfYFC83?`W{)wZ5y<`VqWmpzu6HSbNI-6qh>#IpR#`seuY|SMGfFj!fb0vzXni`Jh z@0QW;-EOgbxxmqU#FThNmY4h7E+YW{rfg^bnEW4ie?uG)v{ke2&geHboT~lCGKChN zPOin}tFU+P24k}ya@R$Z%iJflqqe4d?t*p>LHZi)PlO+-(GdkSw#nI}-RUJCIGjsk z$ET{#Q`;S~8L-4ISr>61OKVHCDMMuQ#H8~6B2FZP2IWS7*Ku7GvOUUwc}UJxL~LiD ztSpV2+H5yucj~~h3&w&VRXY=D8`nzK2g6eH@|cen%NT@0MnQIu#5{b9T^XA(lnHNCyrx zYl%a`99mIlv1Y0+U(7-dHfB*{dg=#Xhuf-jddOtD-hZ-HWnre;$EWQ{ z6nrVP%EW^0sZA6R12LfS4_4~{mreZk+@2~%{3gz-o-W*0-H2R40K;EBi>wF=bERq! znE4#n_)KtlbaEmDV0hUz+YsZY>HF=O=~AO5udNn{QLS#Mo#juoTJX^=25Z-v$atp$ z&d^p2zp(JX$K$xGZt)(}MOm^=cR0!VS&k@*nIaQ)GBw?knHaXA$=z4$LS#@8C6jzv z$kXc%H@QYpg4_L|s6*bJ_2JO_TwDf^w`nE`@ zekWaH=w8nNjcu6S$ddY9ScY9vI{NDWxLKcfDgFmp_BGh@q1zFSwi?mQN7|S3Y>cqA zUObfIt*lHY*8W)-x;nwq-OSbokt-IkSBu=f#X0u|^RISYgiV@`+(|9G)TV+q18TIQ zGZh+K&2G63YM_fXcN5E+>No_l2E%!rR#KGAvv@vE$+?cI)#rZt8gdAGUyvw0Xe=yaVn2_Dk68Y<<(|CLF8dIPEdAH&10?wl17%fR_0% zHDuzT$RW*!r_x5Pl_?rq#mplkK1K7m=VorSP%Oornb8WL)6M0U1r3Q)RwzgbJ!n=Df90@}?(srKsU6@|^vQ;e8L z-};28VZ@DEzr|6JmK&Wt-1otbo^1WBAL1R!; zJ}&9s^ZmvCCGL3Y6})^=MK{Uid>yW5!u{>F%{-WIqHS(w^5!b!X(XNr5Ql-TSOU$z z+^F6}hCXEOHpi|3pVC{|u`J#XC+qevFg1=dH%W5v+>KA|>0GZK^^I7ICM>a-o#>8y z{OnbTPt+^YEP(sbww(9idt)}bds?;e(znripj~d(FDN3m(}Ehz6xFotZEwEXefQ?C z5v6jau|~~!H7|rCZgD74?bjf4Pn%`-o-P5*7029`zxML}W{$cfob(;kBvyY(`($+z zG6AKUD9K~Jq7PkESF&(FF>(^un@HXNIkib$Ab7PL3U2OI{HHtYaz-jUcdgV}*ySuX zy1QEOdDP$!bT5c%2|_C%&DJm7*7%35bELhh@ehrQFZqe|zS})Ww9U_`K<2hTo0QNw zQDM6O_aY(yL+Tpt1?h=xiakQJI)_myh*$&_lZG!loefo9q&a3qcjD;uy^Xf%;<#Gb zKpf+CCpLfFAUm0z$x|RvaM_4|w)YDA|Jk^0=jCe?_&eyy$Jnk?ry^T$OF{LG;B;6o z@%e`!JOMA850*CZ{cVzahOXuSnB_E)CEP)1Ex@L6*snz{6Y5r@7p8qF>k5`J)`-(v zaV*ytu{$c=^h>(a(r-AR)NkBCJIJuyl_7LF=2`M38K(cZW(2I&G`CV5n89KS-Z;GS zu2CryU>fuGs>0^=MqL$-*Bhxs9~PF5F^n8W#T(`)ob}SAZW~iJl71%feHnF_Fs>G& z5H|(QQRZ(zR~LW}Cv=m6st?KrcQIyTSO!lM^z|YQ-BwLVVVQ4tVR0U}Nh&os@|$HG za(me;HA>UQTna(*K$#4yQyMSIa5N_1xXaPI^`?Or*I^L}?mG0rx zZd-*H;Fh)e!z`V=h2F|LRpdTHf<~kFQ%;_#==o}n^kqW<7gd*;=oUul1)A(&Qpf`Y zIXI68)M!P%@K&R)-bPI|w;XL#XOXgXt->N=VSlk`OdhLpvr%*j~|QC4-`{0Q=Sbz;faUypW1m>*#HW-Y`yv)aHkTriAn2!*JWUGpP6OdX zYop;?r$%#NGnAi>;(0;p^f;1udVT~)9w3^fY-8qiO23BOJ2yaD9JWTYVXkm3kepmD z6(f^$ZE-W^hIpLIE`1?qr_-jQEdRpDhMCRuRu{6TW=gb=cbH5yvZUHo-kT7Rr9ecp z#bJ!!0HMl8FoiZHJ{}Hs;ZHgkbS12FSAY;hFiS?f00apm5jq9YiJItg3ISieN5_zE zG=u$zT6F9Wv4pRXg0}Dz4l43B6YS@sL&kj(5NDrc=&kcdsh{AOqSvs68k{!|($_)J zyB@C@tD@GEvqJJ;C*nGQ1ErOoV+o)q2P@U7y>PPg@6{ah>SiF?3{Vj5aX6|5hlT^- z0cFC7DR0@Yf;w;2XcYWHu>elSMY+gE;4~0wa3dmDx5I%PR47*& zubMm*oOAB|BZUVfazSaqLRyY3{=$dIMSAxZQ60|49cl8=yvRT}q!^~Z6ve0Z0EL8e z`1NPh)#8ufh87CUi+(yFMaBRvRx#^1HbPGH{u?yythu$&cvG3f{le9tnL`<&!%22N zsFWRNR5ql?Sg9!mo+3f{1zxMBBa)hN-Fck`)CNV&9}zp8V~Bf+-YhAJ`dQExYK={X z^9yKfa-9I{`6-&$O_7wYo=R=>1dDs9R5cUXsBi&waqJ$La%T}lbEvvLTF6v+p48<= z{K}1&kRgYBAXH^u^ICV}Im_IIuWX4-qk;nM?4;R^ni4n)&fFAT@WuHSyU=Vt6fXCi zC6`fp+kUht3nEML!p}FZPm1G0BP#vuGkTTcmF~EFJt;2eRKJ3w+Q#$RO}3`R1TWmq zeDB_?j4ntB@TCa~y^~%sx5imxd#VP}XjU-NWeVHpn9|r7)9-kcGZy2ZdnWTRU8QWq&W@_oxkVUf5E`r2>FIPz8ITFf(L+}*apYZW7=_k;esxbU6Jp#brOg9-n6;)RIQCR)1~GJQ>u^=uL5zO|~%85XFM; zO$+;`Mpb7*RAEm+6Mz_aLE(o4>yS0|3pPawo#ta;4iT`ccaf?Ido7ulBptHnt^+pW z4x3b&x@l5LO}9*C%#G7-sw-+8woY8iP+GyWhGXG`>CN$I&k$@7*gH52r_h%mRebHp zl6YP&Fp>I8+ukDU@UECjQrKS(-oBw7q|DQNyfMGe66Sjvl^idK9j7m{A#TF}yPwlO zpC^-V5|h-yWOIbSlk{YXvRq|3;z-q71)Z z-5n}dJ&42+r#>!yRLt(r?*tC;dC&)4Voffq4$FuEv3w_<=^hb*ZLSkFi7t(eCYGyr zoVXVmf^XPOfqv>6sf!ovk>Prg#hVN-%OdmPl3zcix^`|qs}LkOtC4et;$!yU0iRg~^#q=Nk#0k&T#XIJq|2weXr!vQCcD;q^a^&4ld(vr=<6F8}B9 zvQ&SKG0TWcBP4}t@7cH;bSB9}u@zi1=n9>jfi<(~F(t$cG{T$noY7!5SeHtxz2r9&5s4Tl z7z^5>Oktv>vKGNKxiW*)4m4HvB+?${U^CfuO(IW)+ft*6LkpT7rf{PKqJ5&L6nP9w zTu3%>5=NrKhv5L^rlV^fw4@lP?z+fho(>UAcv@HIg>4RcgH6Zy%3MVt0CvL-HYh!xj`@)TDiyWBnB0*7Y*&XnJhLTytz7Bot$Z%w21 z3S6y0HpS5|vEEUnW~o>%K0NB$UKhmvrnr~m`3O=ljQQ@~3iGOyTe4(kY537zL-&XHNE0mpOvj36XA-DwyB~rH!Sl zNlx$;oZK>5PX1&6F9g_RMa}0CPt0)W!?HB#AR3uRN^XH6M=^a=QBqzLG0KL+V@Jrc zj}JGaMIgqy^twnYwv=ylbI8Kx0U!~=H?G`~Z;KN`Qm1O~WQRs2tK+L0C|QS$Xh01d z6pd-*E0XN&kQv}_q$n_ty(v_bcdwD!@LRO2zd)T%%oSnI*t-IE6m&8S!jT2JZ0V@N zVd>Jf8dc$+zUKXQr@4=c0e6b)73m!le*z(iZ{1D`z>Fz~XccA=j$J+qD7PIn^ayiP zsiG^zxWu8YaTF@cWZ7!bQk`17Z+iWaG9pGfRjnNjcCG6PU25xaZCWj|bx^E#Uc+r8 zokQ(Ok`Dfs_9;U-Kvsg#RMrWs3T*p_D@R6$W!~XZH3_Bua$04OJD>QG06h62!44SM zYmH_4J<1q-J7XBuc?sSp7QKJ#+dEzhg@5XAKo(k@+wO&AvSh@I+KY5@Z6b9i=hp)< zwY2P-ZOm|5kp`g^=r||VQq*chR+u_4ZYQRZW%IITb#Jl3xA7b5vr48_zknt+p$o|i z1HQyrH^D)>LLxd}f0r8`mD`+?+k(RFmb~Ub-NO0{#%HvbsJTpXiFc2}`6?bYbL8%^5Mwl2XX`6}(1?f?giFxg5g4mShr^o3Z z$+`>^D@O5h1tYULTFh!-F5YVQZ=DFTqOA~%p8cJ-@84`6zuVn=yZL74|6qFRRcpew z`R2FHzwUb<*G%F>R@5s|k29Gew~2yDnq1&D$muZqOspS;fjUk5nPNaOF$@|IV)^Tg zu91Kr1^_ul*Pp66$~K$mK3HudRR1D9}l^zu9;_Zw*2&@A4GXrDv>K6fr7`f%5;}A|@fdPfPSL=av>@DwY7dOUher1a> zl^E}h<$~!#L89t?>#*E9uBnYY$GHvI4<#*`rqE06>-iu1yYG5T8ZjOMjhR)RBQ~*U zZL+i{X+=-rJf5qzqytP9&S}Y+?%o4_PS!A*RY6w!Vm!TObl-`3amwh+Ymh`gV;7f8 zC;4cw*jndhH46Qix!K9fnlR(jib*6&iX)OHNf5M`4C|=y&nQqk>d&sL`Fd_QS=`Me zJwuTj3Fm0Zu>>lB_pMCa>la7J33;q}h@%%#()wZV8O;0vO0w6IHO7$u_bp`T7|xbQ zvx}2#qEfSB0NWVA=+!Z<)1t#tdTYT~(7B=TWxqhRAL<)oNYe@DERGttB`eCUR1`9T z`RET|+b=g2yx8MT_n}X^X*7dbPgJvkm2MzndYRZgsEi=X7gcl_N~aE!Hz+6?vd+eP z4e4)vuXELD@vB-wE`VhHi&yKEe#Y`M!%{0^!-;omHj=xy-gM7waC`3oV=>Hh=e_BT z_-dEENYUTwAU(rd!Ey}T0GnHf!n2e`Lw&}+P=!jyjUrGbhS!eC$t)jEmk@VKjQp?3 z*catbJq*xXqBlzMFz=4)ic%rm0qWdh!q(hi&gWSojRTW4$WL>z_#*?(ykrG08w85S zqUdn(ax|YpOX710U;m_Ym7F21`VsHuYUoWo$~A2~hoTbkiT7`uPRi`PY>wQdZ?W(UX%4i+8(xQ)S6{oED<$jH7g-6|ctp zj4RgPg03OM`k_MJA03ry(!Mz5J(U!mzzDapUC29_hL|Xpm%x+M>0ZpfQysnUw~i)H zZWpJ?caI;gJ~OwqR-@|dT?L^{vL(4JBjkrSsL6?(0ZyW`UQVxvWZfgJt@nq3J;?^h z5ME@bokCAVpsG7qp-?PQF_>G%{wng>B*io$nJ!WXV!AOJYja~9GQ@5HN3C1 zZUfq3P*sU$w^2EIetx6H&Kd@|%a4c)!O39<H(ICP(o>`L~lAo0*EdGnM8dw?=Z| zi5UKct=<~}MUND|I!6Iih9q@jRHyFjppBT=*yXoYk4yNySL7)k3y|hRnAV`$ z3yP46S3*)Qjvv{$qaHJ&UPL^JPt)P>B<+9Vpd;2C5((077*~@5&sfFEYt$;>4Px(s z(zXQdZtV3t$b7CzH&SJiA_^nX%aScP|E=nMu;J*i?-Y;Xo<%jP%{ftOh$gdA)Lu{+ zHyIZ{)#MIFnGjZQ0SVd698N5TZIC}-ZoF-ht!t3``11BeC0K&m46&WBF@0?-^_&kk z7+A}H(?$p7pwJ>Le9a&Q&K!jOw+)ffp-2iQ*$Ds-`q9JjM3SG@#7Cql_%|CZW0BRu z06o~84eE8%<+bSCLh$iV+QMuVYB4BHcRrjNpWq7KAXUd}D$&jdRbwMh8NzdQnhlZX0O`NX-@jJB1YzotM;uUJ7LN(-ITNDTBk~PbSV9 zs#C}=pPd(Rwa`leYLMNL#XDt&UZ7-wi`^rv1HKxtNozWdZ8i<@&oaEWX?}~uV$_?+hYRx0lA5Rp;dz_IU{h@X4ZjQTkooOXc00WSh`eL1)}`*!aOOAd zPpnBf@6BqFj=T!4AFAHak2juZH_lnfFDouWwU@Yh1b!&!1-TD2IAPfgiPDRY_a%}n zdUSB^cvQu-O4eJ)z|Ijf@}(2^Ins;?o10<^u`y-yxgPZcG!V-NA$*w=8sZ5ZzJU{c zYhk*N>Qy!eH(86SY{0_yK{|jHD>W=GTR!%>Z6n2&M!c($A!O71H9`=&QH7G9L8!ox+zah`@dCjcr z$=WuIgXWi;Ti6_N#G8u@HTVPer!-$K3J(HcX&UeT(`7KS>V`!-mj0%zf)}P9IJ2*4go9$(rD* zS&#!Mr*@|s2zCbXoz&5hYm$k>R#GB|g;l-O($p3U&EaG{54bFg8x}#!ldHVUjHVX- zM98$s>nS#2tAa4T>O4D^=3b9VDb_=8H(6Eg;=RPdrdNIbK`}n*c<4tSLNk*czIo!>{&6h6l4!@rnF@keib691(iOo`& z5)R5Z{LyV>S{j%jx1JPOzx?krvU7?;IW~atZDd9Q=RVD^nK=%wI&X!*D7*8qkJBjC zGZ_`cGp&28Ig%$y5UG-ASTv6zuJ_v&vBbkISb z0AFcyP2X`tT%vtf4Lir%;>Ic~6d8lRj7=A-LFJK?A1iwx?nhiYRD{w;tJK{H>g;k1 zKmHL>Bsi(UMGRxfB9`#EL5K)q$$y3nxpK@@b{ar2%#oy->JMgDjsz^IJ%68go)$l%9HYMS6YIT~i>wxbGa}M=Vw2WFIaH7L`@;hq{P47WEUg zQ9`6*88f<4<{1C1dZ1aD(?p7G4*G4C$B`Dp@F6ioj&*zENJ^Mnv_rafZ0B^;Gx=dE zK>=za2$Y9ZQ(#|O*_eMPRSQ} z?S>5V&^CFb+Q)nDqXpo8Ve(<3{wAGTNbyk)V7s%R+W_3nVn=m1B~JHtwMm(=+Ls!4P=UUkj~&R zq?FX5rx6eI<2B5j1XBtM))PsjVt}0ova}LdjF9sQCYmaR!pKb6(i(jgtmccuB8Ju` zsL?XU`{CTg-c&vlE;YYVUr!%TM_bj;F+)~asMu?oI*{->3T{GG(>;r=5WSBPM&6l9 z9Iw)aYTJL~>k~ci8EZpJq{CV$)NsDc8oOu+%=gQ>spAyu?l#%cO*cHguQy!d_2?OE zY`a4C4Xse8w$GcGCR3ufGK5li9vioZ0QKrTpR&<+1u4+RtRak2?T8LSZQ$Bb4~3s= z5X^qFO?K)JnOAi&=Bl)mA&ffXdaQ{%6GW3C%`m-6%j;49wMj=0OKyYFFsvo5s3piI zR(n5$4$q4r8tw$$#$rICRvV}xGJg`>h1jBCq}72|#u*urbxG0kZgB-9^4E*5vZpGI zbFw^OAY)af8YRcm?}OC*&eaZVELFQ56$!?Vu!H(Ebe?~q#{@j!y?g4pCn|-6bqcD> zjUX9j&<-q?*GyakL`jFs@8(1XzemiVg9S)-Kli*&eooj5Q+)@ zAm?k3{&_k&i#Z9`^xo)6Ba7`L_+ZQDd_@@!L;78d($6n#WYM4&%kX~DU?;<`l@@IA zruAK0PXttyg=U#tQJ`!|izb+_V5LkqXp3;5i9YHg!G&?ZZDvz%l#3Z@1%MT5ErEdM z-uBjL?zKfLRXY+n`*;;She`B)(5ki7wv}GQkcGn)9(tfE9{!M4Zmr0tc-m+|=5I^k z&AdW^urne+8o5MN;cZ(GGbPoB+yqj?CX=799W1shQ(jwuuBMm8Bv1d5lv#Gc@h%JW zHzdDzQeSg`IBkd=WU`i6@)G1OovL8P1N3>M`@btA zBwU&rq{1Ru6}ma?7+OyXhHiB&N)MBhQ7Kr=7T?3gzS<++>IS4Gl9;S)3IL}7`7#2- z-Q;u>W?9jbtxft#5)P%)2vS*w88)~4&+Ra)hl@F9wT^~HzJ$REqZ*{KA!FcCJG}Oo z#H^9=rMuIkB8U(e;*9w?Ys~S8#BjvR5?0%aLxC)lN#%56%7wpWR=`-BHUnvrxPdC4z9>|&!0Sg)=j=!U3vI? zwHijznkH7`C3+`GTSJ&oXQDCSuo)aI_sU!xNMsZ5{-B4Uh2in+9Cdnm8HCf%hek$L zG_mU}2qc-1#_*m^hPh=34p}_2 zcl8WckUC|-bO*VT$Fea8xP(#+@_>72zdplxz<=EYs!^Z3ly(kPxx~Xfo}9xsjwYE| zpa;#T`%rY;t|X5tY`TQY3u}QArfHs`0<3UZfM;Xh6$anL5aAS~OG2N$V=7{G45H-Q zS1)m7o!cTwlxq)2N7t@m66$i#`i#|N1EW$VAJ`!d)%xbR^x1S1fM~Ugb2>8F!l-T- zy=+{JqeF^JC+2T%JwMd&Ya%WL;c9EH1*^#-=@MEtQ`&f;S8Ji1S7Jmkf0V{8_^Ujb z^j^+MK2*8np}KHdMA^ndH60t#!tz}YAflzl)Bqpvn^4%*5Z@AVXm0*Hf=zQAP$8c+ zEWIq?@o{DKBMO%eWm|`9a=!Re*`MU&DYy1xG%~#Es7I~VEL~_Kp*OiXRq{P& z@jTDaSu9OHU*nnF%T7OxFq|H7W2(P^7hK3v^Y*uqbA}m>iU#YGBN-4K8D%DAQySMB^3^fmV(EFE`HH#FcL@8vys5M0y*r@TyI+FC*6rbh zW%I8Em76=nyS)?Ax~IKSBD1Z-RxbL!+z%ytSw916G|;!s9;uT%bl@>t__qZdr7-y( zvfh{z5F!XX8PaN>i(r7;;yh?CRQ3mb%M|8`rwfz1Jn{Ds2&u&T29uQv*t!}GU@KXl z5Pn+6msIDNo?D@Lrl-9JW`EzF3ex~`O_D!FX}y?3Xz`a;XW;}J{uDOq6Nuyb4XrI; z(;C`Rw^~QPR>NA>uZnFVx-$0bEmy}M*qjw2zPMeV3W4}yEW?AZoqFwQnqxH^6 zJ}y|yJj~6cZW8+Dz?AF(0oqRc=j}z@wmhwDl<$yc8wknG!fMQjm=_$CY0)Lljqg;t zmak=BsnFMgwER`v8d6|vuuk7ecgIDHCv&YwcgqUepRdu6jYiHk(EgAY5FBuPZ2o#r zZUJI`t#igylaW;|15C4F5onR_vJ7+&IW4NTy$#7xsL2R4go`SeGq$d7q;buMuIf#y zQJ+!OWrX;1yDR*lB*~pEP^n2a%rVW)NZK1_XKDYM1#V7(6SH%IHupn{Ejt6yXqeAVFSyqK z7Z~3TXw0B>m}qNrOU34V&o>i)z?koF2G5jLb;%Cpq~`n) zR;urt3zzQ+fO;VWMV;R;uf{9xqij#otFGxWwC6BUd+be6dKILWf;YWM278w&CQPZ= zld;lMx7C-!@sYvL$~0mFW5xvD-Rsy%EyoiXxzcT$csEu2hwummI?YiDs04ZPTg5EC zs$nr*R}`=tPue<;qU&OJo8fY)o3Ak^gNBu%m)G!J^7znd)f?akb6aRaU!g#0(vdJ! z>g+4E8EeUXc!ZgJCum(+kj7M>t7;b3T3*iOZm!<0NHiv2F#_nphV_L--AKf(3ezQG zW}wj$H;>r9WYlHQNrECl-1G6I9+Qu zMDv#6|3fC?Anw+aX)uudwj0Jb|9|94#(HoAHj1*Pp7WFDZfiHz+0m5Q@HA?TxZwwZzmA%@Q2zE7$r^@IUZgqs&7fi3 zG=HSJZg?`gaGKpH>xm74Hpf49DUM`83kdg?_oyPU+v78 zaB)X5`wRjM4l7B{II^%DguELmO}QVl%e;t1n*FNiV(Q$kB2e~zts+s0O4Ze;e+c81v$W9a^-Ionq>e^E1^P{}ma6Drj} z#N#=ZBC0x$hJl&K+K6_$6n-PPq`(ioT05qvi#n^-*qk{B4dBbC+QWYw0OC7*JK)2$hsCVGbM(x&l zQG8klx-p#;*V&-ejr)>tXbm7aW>(!qb||!d!U0gWF$S|BezwufW5(9Fd>o4=~X&~QjIm9;yIS)I)vr|u<|Sho@})8D#=pjMVR471d1V^F=GQJoJVjcl|X zsRN%ojnr13Gtx#VUCH_(%;tVvUfcV{*)J9m_yosFrlZ zBu4f!BB>jbR0vy4tTVgrq4!BjNB?|Mj8IgRt|E=KiE5exEYFwc`Najh>*+=YGm6Ny zzrWXsdwvkEsdx8qXSf|VfWFPO^a4larp9f~?JM#>1S^$|P0M2R$K*fwc>i@uS5_dn z8_424urj)~x@XSMV0<79wd}QwngRoV{5aa9C*72p)q2uubvg}MCg-vsAtbZLp~j-| zPP-r7E~b9cX_Kk{QDrR(sW$-p^}=L-C! z0hU2#9L<~7Ep-Et`SmQEb?U=1=wi1TmxCg1h1uJNsaJrlf(}h9O=z)^0_pJ>?rwn* zDJCv9CiwtaK&HPuZ&Z#2z)FK`m~wEEl{xN6!6=$e*L)|n#-3tPflvnfk9{JlXy&FP z0xiTQfT(QQmc`4u}+kN1M0^|d)88WT!%6AelK{AaSZvhuYK zX|aPMTi>)uUkNxBj_oc$vpC!LwK&>gN5+2(>fn$Zo7HG*VyqS!HOCia=i_}O&cqxy zCl#sPZ37%;^ESTHAJK}BzC(zw{xm92%g-vNQLK#{rDV!CSVg((bJP*O((NppzRoA* z)aqf#WWWZptVv_ASe|bd5UUX=>r;C-gr4-zTA$F9d2lp$moGZREVQC&>v!sDHyiQX zE;n~*X}FE|NoCd2knWjOh&5K*wSADqg6C=ZOHq8Hb}HaQGE8poY}4tKZ4J3~t!i?% z9sd1KXb$12oNT3FiP%cW0*Et1$EzDxsm6SQ!?ZqF_3b3m0Xpi@z=Lo;raY-dT!E+> zk(42Gn>jsgZihDm0}E5&iEL8SB-t+5Or74mVlhAp*I>*(g5w9(1`De2WbcS|1MHL?Fhji+`ugjk>mK+TpCbT?UV?-QjL*kNi6i)oqwqP*0AJ zO3XfoA|k@k+uMdFmj8?Nam#f!Hk9B(Igv)7rP&U~ODlR=BU8k5a8!741solIIY*S- z#T`L0$|;(y@p=*#~ zQnMNAPQnS5oBr z7`UN&zHdcX@9M)uoO5xNO}0QRGw7X9(X@DDKD6U1;GiN!+PxH`YXx0?v7l2e&2sIYqV=nj0x_pEiZR$ha)Jtp^UMG<+lwRZ zrJ(nSe0YpDMO>!G)|)qocLjPuldHnP+cz#{fH9IRvn8PA82^-WzKjORbuq)dks}JU zn9Yd{Mj6nih48NUi!!+4A_~G~gUgxZJ70RW`_}oy^yakwR~U*I=m2z`q$k5`9+S6i zLDuY!+c?LiG%jMr6R!Ed-3Fh=(J9w<7%BNNSxsKT>WK#6gaVqvpJP%mGzQcha7C9TW-A!Yf^kwV&NJ6VBV;7Y7K=DP{)GeYd;?TS$^=?E z@@a^f2y)Ez8s84BEN~$avgxMRTs1lr8o_RcUHW6NBdrWg%_0^8Q_s6nx7zVWlURzH zk2m>g*1zr#v)hKs1d==~FhXB)ipnku>ztmT@X!xU+nf`W^1I|0p0-5Fpec$eWm*g! z;+cGN1*eO#{aa5M<7yDQKs6)sOV%?XrkvHjkr1XO<{Rzn7PRmAYLcCy`2r}wG)?c< zH4KpPut~{*!k^zxb{Ygvmx!L1`G9Wo!yeqX^|^|(E3%BAglrqRfsDi>F7l1TOYXQ5 zzQ)b-BB}ZM${6j`eE%tf!x}H-L-^1@cT7DI_~5WU#p9DM*{=8edN3jUa4Vl2JdE2z zIX&4h`u*2N(`eCYO^ZoZK_^i(6iSE3o(XX%um$r!CQpdtSfE zh*9X>o0b$uOPLsxoqyW@go)SCiL{cQ=boK+++YQf66U%SPlbqdoynrw5p#61VK)i) zOPpfSvw-zpyJ(*B{qn7ov7-Mgfk(O6fb1M)Obs1IH#lI3ZTHFX@#QRoJ%WP|oMMoJ zff;p#x~RPfe(0G7BC=RTuH(7Y=r}Un)*RUl8WTj6Q-0iEcDK4_Mmg|`xPmFLj9FEM z;GCMomBSGUkbI5&E?;}In2F)d+);}0<=2fcMEA9N ziY70q;SlwU;zHg!$zc65X|YvBn-L0AQAw(-Y}xRXT@oS|{hIZ0;8&He9qVI&xH1U* zsBfNXcq3jAF=`EYmWU^E=yjN-6Uwe3q4Xt4Lw`6!7mSkv#1`dHVt53UAjwHDXidJC za@#NnSDHHk3^=Z$JXv0g>UfRW9r7g1crz*fk(r>e$whiimWSk9S)5RS=1DIGT;y|l zd|aFyAJ-fKRibx!v4wog(o*9JBDB#O4KWQ5o#$S!3S#r1OKdC68Nzlb9gNtzyA*jk zAc<*Slg48qi&b?hE*x-ci8Yd@UYbshGpDY!M6wEMl5zURdC1*vRa{k3DO$JZbIIJ| zq^X(AQJ2FE^%nhn(w_~9TMV1TmrP0wK(~a8R7iVVnoG zyoVxTCWc_(pIG%;sF=&-k{md+lc_e=l(qD06^0QfP-rgh0@~I?Guoxl<eOUJ(Y0ZD{|&smBI01hzYDC&b}*%A(Q ziQcX|)nYz~>n36QDs|!AoSHcOw&^(Duy!_PAZgdM!$XLC1Zn_me49q5Y}Rq9NOy02 z=(~0ix=C$obB26j6c1Hp!#5r_aRdvD`eu=sG`EF1HBGfKwX>~B&@9~Ku2oEW9r1~s z6U5g^6-EUmY_;ad>hAHPD1xQ1*6ku?e+`-RSD{yo4kl?3n+iaX4X zyck+FUF2tHL4=w`I-y$8Zgi@^tBf3?Nz?$$ua%Dy<_(FDylP>rHDE6%Gc?K6VdHYd zl72~}O(NhYxq!HHPkwG^y|bR_hy0dOftak)p-tW+Ss$+uun3wvk}kG zAoUrhFZ+!P(rN{V38T~%<8H7C98rmh44ZLF6P`ZHo~M|lc+WbS2BMX(*@~MWhKllv zj2NCd8D^^~-gmumqIdO04O0BiSLC&>YztLP0vnDpZrOYn+}3ax=gnVl>>!(FlM6Ut z$VU_V>n`gt94h4rGzt(O>zL3*0|`dS7(D?Ibb_G{@fT4jp7_C|b#A@Retc{_la}}XE0LF3Fvoa0f=#hw*onEp}aZ>$UzVX15G;}tO*glHu;m&Xtn!+~Ejh@lmx$bQ9Bb9JD~y?gC;FakVSn(<$bdWavU9INj1@Ib`0K_KDyG@TC(30q-hilZu zUBIVS!(lA#C_4=> zhSfl5HHVq`*_@C0NqCDSiLl|cr6KQ8(R2ryc>J+;6Upb*wt!A^CL;>(O*`vV_pr!^zUf|EEaBn{_}U?3@WNJzSr40W?Z!;2csYm?Tuo0wI4iDRHfALt zeLbu=CPv~U0IF?|e{a0>3s<}v69Go_Da*!)X^Jsf)lbqZ*M1#AcKiOq6^^p-Ci(=k zBR^EIC8I^3gGa~;F-uj1ipSRv!|F$Z^jB_$Yl7|E{DC5mFTqE0Rp#Z+$XHro_5|OE zPpsrFFUYZzZrR-xbSIKuNtSlW{4N&BX%IvGQ_3<1**oQC*i? z+70;1PkUeN^&gGA6^9JZY7Q`uZ$;Oj0ce_P3}0!3!8tgqc2`^rfW$hB+f|qbD>{fU z72F>O4;9AZTZ4m5(w4`8AlS6Zc)oJa8rJTvyXKmlvu{B~RA?Eq?b7DJ3U(Qaa2UGky(+84rYf3&=hK*?4Q@$u<(E5wy;&WTrPP zUqc2gH84(U+!O|yH5z1CA5il{9L$kd&>G|`Ck9$W%-e(7L1lVRE|k)6qw=(y{0;t? zqMk|q-|B#<&K%#g;@RXQwqjT6xNZJTExyxUoe|26-Zc`XuLU%pwCYvlId?m7J6*kT zG4?jy`T)G${LAr&_pde&wvV@VKfF7DMO$52u}%P_@^%K+)@uMy#a6}sS`=B%^qQPQ zi~))F_A1RQ`gn>Yh`RUK2Z}mLUe`Q2l|e1zTM}h<2*NxnHY5;ykoRnY<@Zfd)E#DC zhC163P2R;Xt4ur=+RU5&*YH2pW%Kr5tzT@#ILX{{LUAdQY;eZzP04pp9zS^kEAaPO zj&A;CdTGos&;|q6>|)Glgq>r&Trtw52?o(iekrb?*n}?%NWtc=<$I&z3RV@DBc=DG zJw8VVq>OwP@y~(0%~;^PV>)d52gh*oQ8`I zK+K)H`PnYvB)==JppRDw<*?SKt5-_v4+G^E-QMDIoJ@+VlFeku3a6KBjz+~bhI+p4 z8s#`Dnry8;j*U%dPGF1jB^)qO?CO`kxHkVz5wjHsjQcN&CC!Padw3gh1@o=qFie zjv~9W9Xdq0<3irlSAcqoD{b83V-c^oAHon<0S=2-1i^xXQ5)1320mmcf@At)GAR1w zHz$5CM4Z|!`qS!Aw4!}nmZ}C%4sWo081)^G@!2_iNryAK3*3Btu)Rm64b-BoLms+M zloxoLhzYn-yesUIt}jbRrRvDQE(Tm+aCBXVF7L37>Q2kpY)Lhf!;JD@dB;z|LXw7K zM4S9xbtyxG51TVE+?RIs(%;6hDT@hNI>J$SJ*s2_3mD0?H!jL)EGh5_f2omIS2yY< zx|3L&Qg3OsR?1C#z{D;kCp|HZx(Vp?YrbbkQ)!~CjD{z(kv2{!qa>TovnAR8iM2J! zu0y~EzFpQ(M=L!EL|M@QxDB-SZXb3-*dVzEb;w_e9N--(U+$DdAJ)~!)n2mYZokR& zQCu37Z9HK=Pr)N zD<7Dzo3Z#^S6hh;#&1cF>LHNuQ_`8KbTiJ>TF7i#$w~v`H{*g)cl|Np;GI!@ijzvp zPx*MPT&fs?bnT;ylxQ|t#ND)0J_e0FGQv(JD` za5|=zm%diBw3hAslgD=2_Z5M~xgk>dLn&8vx;D-#ygAW?s=7c^h6b{JG{pl0NMPI! z^FcJ4g{e`sNFjTE*!)X2nC*(m0OAF7esD~%xS93tWKWIs*9`AoZCoqUm&~H=J%g|Z z;`t8>ZF+v~y6BG;nQ8%(XnSRiByV(z_E}cZJ1k%&8f=s84&%XWib{xq4q>?ssh4%`MIZ1mCkdHbnhs({$+wOCp;aWLlJ6H|GCu>B2tzyx zy%GFG0w5hr5)!?eP9x*}rwG1Pp|7NfB{AD)TS+iYP%tWYYTQHiR&Lb{oxsyzhv6%8 zu*RnOgi3|7?a#oqk40HaF9r3OeH55oPK#pbS!OL_#4YtoWv6XkRdQ|e>mKVmh@j5b zv3aAXB@X!MJdoKp0*!w)tc{}k4v`*hL_P5wyhi--Ozaig*b7^sk|S_I)7nrUDf`uG zQZog)!g^$9G5Qh%%!|+y|TQVCB0n%uXq$V?4Ebvb)Xp)U0?kX#I8bHn%7*`#9t$Rm=!C|#?69>_B z$)%CPt8Cnp$exrVm%ADjdl?8Z<)T+-j@j~dm7|V{j1z+ihD9^?MLZfI|b+FXio)=y5B|z0vMQFYXrRdhZDx zrt}rDaDFkldgHc!Ij1f8;o64vpAXQ+Jot|Ro7!T{v ztQj7(tG|gIX+H7EI1pr?GKEn zYdY>GUyL6`3t8}1a)VL4sxND2wGSZsuRJR}Qk7YmmmTjG#<<&{CNv|8ZnX$VCB;}1 zoeoSuVZTagV07o*&cV*+n_~m3ziz(yuqub04_bh?EIeKBBxU{jJAv;I=hPvr%8OAY`))#2gv(){{s-M-}N~Q zdXUI>Jt_2if{Jl+H;%Vg&c@?n0`%$k+9iA0apUgk3+kI1$c!y}1oC6WkJB(T_z9&c zSC#_+xZ1FP9lmxQ6~)pgJ^R=N`70aqOZ){r^!bUPxGT3OFX*-I0`@;^VdH%at83ir zpq@PNTjLQY@9A;lPVjZFe-cq_yJ=w^dt#!BEde~<#tvyXY;_8X$XkK@Bf-Oj?k1;( z!E{dQb&(lO+jhT%Cd~(wXlNnYm^)1iYyKNCV!bc2P z`sY6|ZLyKb>g;Oh0vQ!QdPxw0VcTqK5;+7M_0qE(l0cZGeT@c!tTS)H&TLYEva1{b zaR_x&m|8S>|$4Qhc32w{tjQH<90pr@a-E3n3~hNank}f3+G~r z!p8y~O(!YdIAh^Eb@o~&zEEd~RuD=0LeXtIuI*)EI$lBl3(x*$u^0^D+Qea<0uaZe zD+(NvMyh`j7HCF1yvjl?!=(<+>|!w$M+NfKOFsggRbu60qpCd%h7w_}HTk_raEBWC ze{P~Ok&)-*kR8p&?OVWO!-{v4!(z0>O&&#pPAp>09>?n#b-=6rHE>@?ZzO&`R6?{K zxurnm+Rrp3G8GD_?|dk=h(|Zn?!;qH5KqEu>3cMr6%Lq{&~(ujGJ3XRw2#-hb6}PB z6}gc>6;q1@{CriI_f}lZDFT!=`JreH#J%;WGmxo`mH;o-@~Mfb4(uXswRYTc+UF!o z&wSrfplcLA&n8!IcdEuwS8{7Yo|>kR=q2eF#$-tRT-xLxLzl|$#&odR8jAvOSj6%AyEQ;CAH9t z__9P*J{s^%R0ebhI8C7e1fp;Rs9JA0eWHryvLg6Yb0ptui)MgvUDndXBqS_BbkaM7 zCv76wp<<>J4d|6!nWZ&z^W7dQqIW!~oyP>ni?qGHt0Q?Y?T|ti`Vz#hIhid5n9tL4 zi#?&Sl7XIzYm3iC)qPpl&6%;eRyz%umJO0OHWh%lP_+O=EImu}(SIvnusB+hI72+o zhODXRMy|B695jRiCa?~dU2Tvs7`JrP>e3Yth5bj{(Yof{iHCC(*XX`feXrXJwF9n2 zju8Y|9fe(xuTIxy4(4{0VXZ%dHBrD6wjsTG+ybs=Bh)Ko*B~fp9ENugHLa4}P(&iG z^crQiqIb<3iv^KG@bjZ%H}@IMT^hm4H0OY}v1z(O+hU_qf9^4crXibC6Ua=kKs0P9 zGOrw4>xCi^I$Rc}^oxI?w0^Z&%(>Yf-SY09x-0!ZB`dWUPwK?)!S4{DGrrNy2kF~6 zNjv`9XyfJAMqMeR$*HR5Z-V5nlx<)(@+FieeSCvyX+tcs`sGy^Y7x{i_n_;u5YEFu zA7w%m?>iGXtQ$Y#{+Kk|*KoGu6S-M5wT-E6qLH^d&AELT5mN*od(W-jVgAwYzfbTO@Ds=zO?UsMDl%%?y>?Ou!GH;6ecrbOmH7*`JKKN+P%|GgLV7~_-m z>TR69qEVI-OFz5JSGFmxm)Ci%NQc*47GN~=E%kIrY&WH2`mS=JuNAi`bvBV4kpME-O zFF;s;#iQVh3wK+c+HJYEuL(nLujV8r9`2VmoRn)ePG3-eH>hGmyQB0y`_YIt#@ygZ zWJ!u;JzBB{gdtDWtsX&l{Nk`y{Quc|6ZSTaD{b_zv}D}?u$rJKZ!xH4WG#ulM3z5M zab_;bFioIIwgsROG(d{6d4KyoTkTbi1|`oo_jzuf8H?zyuDwp3^*yZ;@x~?pA2J9p zMQz7X_-V$>VB*a*zV;4dmwt++5bJh8(TR^Q2F{wtf5#K-S;_Tmy4*d>p8XYi07fp) z^!beSKvD56yP!UUK6GhX&m?b?M9t9-@)zB^r@P1>;v`Y-kr47IZK;XbG0JA8wmCYT zcqvOv=vzVSKPzW7P+*v)4^471tc)rM zH+^w?(`2G-=NFZFw!DgSmirMmbC*O0$PVLrIkD?fs{Y2~pa_G738D+Xl4KTKVU5cn z@&-}LD6!*Lid+$Q#6MaiUCuR>2ah0}uQ(&))>6;u&5No5(Wi9zDDofKz+HyCo+f%U z5Ia?OD0$sZloi&(>-xaLmsVc?+QJiIJK`>VNM+C;sA=kPMX@eu>kU2kNPg0@C|MyH zM2-}H-Zb9v)G3k6@RM0B)ro=Q*+i(F0?saIgDtvrVQs(`P)GttG*b(@KLQJ){O^+Iw^621f{`XXpAt1f98jhR!y!O?A^b{Ye0 zB^0M#esBE1RyXLR zbdicxv#rR1G~0aOW$TGeWQFa&;78AzR|RHSxc10Fw2XJdB+3LT5d_CohGE#Q|CB?f z&CTkx{Zog)(Wa8vcOjUS9RgQq{=KlmOt*Abw3W-Dz59!YUq5)@CqSz+aj4GzSu7S9 zrTouqFawyysyvVkok z&Nabj2xnRuIuN%{ZcS6IeX43EGTOmluT!2|`P0*0bn*R%(_tK_?42Lgq(5~I$B^uA zdRN3g7&#y8|2JqTG~M*#+7DLbtbyqADxjTwEzauoe1cbKXZ`XgaXCV0HeTxJcN{ym zO@eocaLP;=OinPm0XgkQwpgD|t1*KpP0H~UV=b_dg1o3!lF3CXC8nsntm<`xDMM85 zkYc^Ms43|pIz;nDg&Eu)#<=v0KD#y(_HC{KY`0^rx;kMc_s99PKBd0Hbz5^L5^puw zU)tw73&nu9c+gwWCfbLDqKVOrd9keLJbf-oLQli5z>>4ek`0)UG!_V86G#2r+Y7x{ zqO+Z64>`cs!UHrbM1Y6nCEhQWOAF%AVb5M@giJ)DY|zI{#a3eorYsRY;8co&qi7_4 zVDOs?fh;xTh0d03b4v$hIm#|pt3@-~-8~1seSHe2dA57GE`Mq8zaMw2rU5Q)cki1A z-?Rc<1}a_--%sn2!z|8LjA@?>z<*Ql!FFw&s#J>WOo})&&x-{{Q%sTy2Kux`p%4oa zr*AgErgqYP2eZPxMR-kY0<}f#fU$<1;%yh?eL|f=?0;lm>5h_iPANXFc z7!SG^nUvnv>0C{{;T*c_ohbR~xy&>N_EJr$mE9DYK(2fwO#48+fKCioweao(3yI22 z;&9V~S44cfi&*3!bgF1(xRvWEuTM{V;RWctT#8o%d)G-3K^qHKJ<7Pt5o@wHYmVN2 zD=FHg*Bn9jH)N>ZRO4m+zGyxKFv-f9ym3*PG1kn-2zJpGpQ{gTjdScX%?2>U)??G8 zAYMIiL8tgt1S&bkv~Z;@TniU)O=vfEto@&nPgmfvL}F3&ggGb1bP4wdI+n54Zidsi zf@y3NLhS2#_Hg(OeowMke^x+=K}Kb8zaYDQ3Iu@z>M>l%)G<(%Xk6qYR=2hyeB2?|8nqNrFog9y4LJbdx(ANRh>vwFSSsVJZW1Vs)cH~6*<93LK= z+x1F;3o9P{iVV~&E0dGgu@CafWQ>>yfIueCHv0Vd03AJB+Or6mrRz$6{&?N z@U|jJV^X5+yK0o~OJx|O!8GG?UM#Cx4TCd@TTKeIaGhPitRvVY6kb-VYf_`0A(T~x zLh$Me;Rr~51=~RbRyXCp)_7kO0vg?@x%m2Nifl7o*EurSMSfYlZ8Au(1 zH>(>tU7wy3h&BfoGt4osS)Wk52O9htor{;KtWls3h|#4$So9KRQ=Hf0yyTlq51w5X zRrf?+sIqNIg_l*K0H5a!-7HMYaCN~s8hsk2mMoxMcmS>{6l+Bbh#3;-eBkjwUkQ-+ zSROuIpPy@`CDiq|*MBchf3C_aN*en1AbavS`+oS<@GB9?wf89=hZBA z25R#ifl6q#`|kA+0C>KhI{?{w(SYlBHjUDUT1!C?k2%_Be6T1YI%o@ppks%mkO!mv>6Ru6tl9)K%L<`J-axUQPy>?J+QuN&}=pQFsE+W-j;hiXvE%QCU$+(VBt(in&EYhFdL(-QVPfyYc3)W$?G{ zgd%`$7xL^uv=<$nkTe<|2BeKwAARs9xsD?;5_{IP#b`#uA(M*R@u}#;pc9+@4L2x6 zJv9>4nP)vU*3OCu$AG4$BGRII754omLI>yy5?R&fVzdMsXwdX7>BnIkLnh6&Pn}v? zg9Nh{_i#YEt5l9=xi?RSN!RGkNUIMMu%pkL=1q-|jD1X)?x}F_k>{eokFwsqW_3L+ zd;8m{Rl>01c01nIfC{8KvImvT*3HWCd9dxLzE70x4-(0J8*ElQva@;;dPE%JEJb2C zpztRQu>~jo=&tw$8rKJ8sfp7dA@ljc0d^Iq1p7Ae4Bz-nDb7MW_qOvQWud)RBlJ6D zp=XHIJYAH85S1OgdfscOvoN=cgHg8nvr=%ygwTRqeyJeZJvz&K;OAo5^f^A?Hz2$D zcQ|2g3%KqU4lsAB-^nO##$1S=p{oX*O2%cO2j!sS;xl;3Ja25(kOnk7VZ%ZT3w zBh2Am(5@EjrNK&%N9gtRWS5*ScA){jc6O-p9h3KbGF&PDjli!1Jvy`-pg4t4eX%3Q z^;0%8gBLECHtyluh{n_?$gy83ZCJS+sYeMs8ZKop$oO|o&oN1`l^@tDVZX`Qh!ZL4 zKFSBTGFW+84HbKZ|7{F(VeRK!R@d-t?s4l zL8!$v#o$60C`-!E=bo2FBjm77k&gom=^^U;@FjC6lep)MWf6IYs$7ctaMISWaT;Vl zvT!^Io?o{~7V_c!`}+}2G|`}Sr{cctr(hTHWn0@Mre7c`9W@iHzwh-VL^SDJHDHo* zujg@tB_79q(sd)WmnUtXBqJ3T}OKFhA_HK)ZRv!!hQ9C(orcpWTB z?XAE?DMcOqNnsnqm~^*shUoqS7OP$;aY=5$wkgG7C*(6tHL=X_2JT$Y#knu z@3+=Lzc0>@SqshOdV>usKy5#!e}>Z4-+5oiXfbOk3xaYU_>pGq=;5HtNj1dUz&aO^ z{e-&-hG(NZb0gaiSo;#q7V*%?!60_YZi3)o?Ydzhz1!NVB1F$qpN-6)d6>x_7|jv? z6TB3ba-{wU3J@nd@)+HqlyJtQfO&4iS#;G(tn~kDbyhyd9P{L%`lG8|3TBc}t;xAC z7BtRDalBv|c^F9JAyV9(Xw9EZ_hR-VC30QiSk0g*Ey(6L#ZY7yn_d)`+)znBY_XNN z9^J)N8RM#0iWLwrn=sZu5`L8*%ki4yM$eMbgk2!}G}1UWi}|c%S@TRyRh~JaqY=k5 zYku3*l|A;95rjcs)2dXMTe6Vic>Zc{_Y?3>U!P z(EI3lL1C@;sY3CY+Kc8vvF6ceRh*f0Z42U5?&xdenX$p~??Y7$25QbqSR}n`sJ)<= zSvZ}jxSsz&(@U6Pct|~(AhS=ednVCNJy(hFBA=+KwTp8re^cORiDvk{^Pyx6jD6!~ z({tM42^3rh~k9_9%mOG#7lyR}obOJi(6BDbE=wkdc#<=|n zksHuD6#24oN;n^LtRmr&#amt41)`rS51*Egr3ilRDBOOmSLKM2cLg_ZQZ*|K7eSaI zyg-MuU&I+t94U}XDL-=V7xE#&xT$Jd+Uev-;VDVOffzg-emDGMZ$Dulyp{Scrnrmg z;fx9{nHR}E{2CgpDa$!?b&WUyoE&I>e@k^wkhO4ap+~f!N29BWcuv6llo$h$anjN` zykAKcYq&`%ZwY3o%p}3d-Hg*Fl=Ja* zG{>KYxds-~nvN6ud2Y{uxr?la1a`1=QnxChBSNJkmHTN0bJRvRUM`Gh1o_M98L+#K zVhvqtp1CYImhqioBsdy)@@4&R5MXK8ZV`B7D^Y$%|AsA+7sBU~wj#m^!)m;qaHPMT z+oB31XmM7C7e&*jPi_MTOf|qkl^Wu`g-P>yOX;4M64r|1!nCk~$< znXHl10jDa?Gtpj~^EK`p69kXH+`XcPh;Ke=j938-G(J*IJJ!`i5|+Ef;+clhUKCIx zg-P0(qvbd^=KNNrM1Oy&eQp~Ag|72^TKTCNd6(U#84B4seKv#2RPtydTHiS5zAR946EyE2CPNw0wadXauh zcU^={i&U|>oJC6?chrhJRfNp;pdDqsp6>-tWZ$ONI4P23HSkB)3Ph=VkUI4`r->BY zzs+9Ml~5mlDpnV|-RP0LV|~?j^3oY%K8NPX(LSNgrIbW?lA--# zz0IVCuP;G^Hk8E0$yciq_2+XyI$vT{C=w#0pt5@)kFZ4Xi&zzhQyE48IsdMJ;x)h% zt18n06$X%i@Bt%!G(I*8J)Nl`dq4zHzfWh5cx3DZicE<==Ut;^HToiw@^1d2*xb=w zIU-iZTW`~Pbjb?r{3KL%F%NFB!ID6{6qP~IMR2BAjMefhNw?)SnXf3ZkEl9|CKefN z?I)TMx+AY5_mnf`k$g~Q0~r222Gki$SS+|d22qL^Qh#$^9S`3v0f_r-0uy4%?OL;< z`SEV23q-#crHev4iKfaTo**HH-f=HXl1Qsb^8PUeQShuLiD{ENoE^BaQ!V$(WK+Xz z1X^H=2kX-asc7*$ODq9p2SG47-gbH=gwzqjOqV6Fw#OzPluFScWPLUWrg2ZdiQyoz z4vqgVY zgtl}c8pNI2axk^ccv+naxWe+R7~AJO`#T1e7^iL4!a94?mh(4l%*}~WHhZo+R2R96 zq$sL{fMq8nGcD_+>bq5P3@7hMxQ92Agabs_U1KEpFZF4sB|5$4xMcNVx0UITcx*FV zxX;uiQh0GOg}*H9Vmx0Lp;xKv7Xbl~`O`n3qpWb-CGD)nbEm*?j4@7BskK(zbk*oc z?p%A`n%A@9I#Ca~^Up9c4?P&83G|Fk7(r>{gWSYFP$c_`L`JG71zcq%Vlfk&Rxha4 zN*C+GPa2o}vl=SHlmnt0ybU**b_+}Z8Hw55XA zyKcg3{Wh@d8;OD=7V$C)8i7hY<0m>G(GgChc6|tRA>GJCsakHK6`>4x9@ldy0_`es zQiFa$cMhI;WZ~($G{z?)dW6;MkH2Lwe2e|Q9Fol!#dC>oT|a@wFVLi|qG(=}1m?(UM%|lozMhp! z4EN%2ZtaxDxK``fD>&aHPP%H0wDN@d;KCR!Fuq7T9C6UXUl7O{<9JL*Ql0hHH&or9 zB#mt}juR*KP`7jJ;`N%@OE%a<8a&_zUGueCLBBD+WFt+AxsX+3I=V?s4WV17dKLFW zs#XWcjkr*m;&P-w!F^97vFbEKf*u{X`PM25x@zw2kz&d!W~a6#4+jQ0LI*ZoF?NT% z)NF;8Zf;htF6v3x;2VB!8dL?tDlqszND)`95R9N7#TyH6bjDgh3yWYK5U#nP3jBKG z>9=YMCazC`oIOWJA}e;}Cg>eHh^#S5qu;;h^1_}~T{s*iU24>>`Gwpwqgl{tk4yqR zH}%tJ8?YkX#in(B8<_h9v3t?H;5o9k)X+Tt?Khab{ootKb`acn`T@HeVYlD0TT|J0 zCLHmAFvAFa$`*Fzr*gI?Xj86+rAl_2tl(54f5KksBo;XN5=pO(+|uNFUd*boa+AR* zL?L~So<$-QRmb&6X#{`a7k2JTb{TnB*GMw%7}R}xQ0Pu%JWF{DCb_xmqoX5PsZO8P z)aU2Zk|9Bm8Rpp8cpTNq6sR$QYnaR4CAi9sfz@O9F0T1zYDPKHal0@Gzr9&fBC&yfBL|D3v3!_uF@^yIW0INS%SfL{!J{^*Rr2<% zw%(2v*C_JvL=Sd^wbl-CEh43fX5pMu1b;)YUqlR8Cygj!6?tcCIp|81A)CTlj_#^_ z?5lE43IPt+L~6sC2h0R6%N=%NY=#}`ea$pR+0^JJsW}#5?ReFl77ZtxlT;v!Uelp^ z4yeIsw}rr9i2}m6Gk!2zC%O1>S#)b9*QPDgQX%R#Rs=}KbdXInOPD~i-+Zjh6xj&u zT8i=N5=Z%;VT#I+D-yPb+22c+e-Q>uQp$Y1miBb!@BrG3=<}*#2uX|)2mrh8^i}M7 z)K!Q1TsE-rg?Dt9ncPkCpC22axQWR*jLEu7)^wHr1z`ip`&YkWn%tXy5?=E7NH=BP zE1t>DPeJV2QJQ~>Ns3F z7e({-YObE}x!ZILv*eMcqXd$vsM9H;fok&6C{nM;d&e91CNlhmJpe;Y2ftU$6bAG= zeQ%k8%1nTEk*C2Em$4~83ZeP<{uVp~QNWA43DU<_-v=AWP;p!R^wb#gi^JPMeeL{V zEDF-3xR`vFoai2|gkTut4D{%r4VL!Bci(*XRVFxAWL7nHU&)JxN^rd2Xtl(7f4e*y zLeQ{+xWCCQVCs+VVs#;glZvmr`7AjNR6r*(QKI2`tK+DCC1p0Nr7}<76p^^KubDGVZFXIK?*d)jqs#dj|W5#6J&UPL1ZjhPQ}6;9K3U7N_arGD~I~%{9@Kz z`D{aElr|Q@i}FmOm9bEm#R|)5-#P16mv8Z6SJjNvU#OhB9Yx3EqgrFkjkc^&tnZ_U zor+V}oJD!;Bq58F=P+88<~^R6fR{PbF+|GNg*{RHs?(ccI2_(ON=b+oKHE86<^#AS zQm)E>D{fBFf3=)w{*6b+2Duph~EDcL`q)G~fcQym`U9|AwI$M&c6(WATBJ z;V6Cbf75`txo!Euh=SJJ+K!n(6Ja>P7MaMv<$c41soL=rf!3lDj00;W2g#M>s$?G%Ui-B4}>(O~@(YhPX-w zqgij+35+1Soe!^F-(GrY`tGiZ7M*kMN1tP?ze*MutnXEXfM%lFxryR8+#l8*2{N%WpAyr%S8$GlylU&-!O zA6}+&&)y`Dhf5V5$c^m|hblccj$Qt-ze%W2ZOe7YWOUQN`9fTrS@~2pRp79ta+W{n zQ#GF6XVH}rtb&&!EYh@Lp*&4Lvph`uH|dsMR1?A|LxhWEsjNcQqA%HG^fabrN)ngt z)N!9vo46$(>l~+H$U4uWZD>l&r9o9Am_wK*h|J0qs0U@k7Pgk1OW}b2DCmi&w4a==)O$qV1LWcse`>- z56@KK6dm5&D*QRgokcDqDtaLu7gx`5I-bH_vhNu5&xh>u}7EEmNdd#VTSM&HO<+fFfK|gsUBbcS)hOj`e_AsYFnzW&i+=8mC&uX74k-yPx7`gTP2+ihSEH;;Q3?Ph1>IyBmE&h$pIqM1K}vR7IU`>y2uVg+Gt8=qJH_ zbXcEFlBE|$nDlQ<94+_6Sf|934d;=B5#$s~QU~yyqhfxoV}(gtQkhO>sIe&L_4@n* zg&B&ODl@p8ogHPIPAa_M7j%CMT3af~jThL~z5H zRCc7A42Q#%GK)lH2CVE262A9vE+gT~*454t0Ngz7u^~oLrcmD07i=>=F}G24M_W5r zykOM_ho-LMEv(o*@r>(HE^X826v&?$<_mGDbBEfNhrsQ8$o)u-$y^*yy{40VP{0qp z06aj$zew~dJujbfEofq{FVz+`C!XOm%m9B2|4ox1#vWXN%&CDnT;l<1V(#sEx)@i; zJHdjEjJK^=hi*352UkftJmGG^f4yu-oXZVJ+WX=hM5y@${@oPM1M79mXdcdKLE$vO zOcBC7UaIgEsA|j*r@BUx*yXz1!OwQ+>By|F3@}_u9*_GmJnQl)cBrqKZ+E^b;DUfw z;4;9EI8dEb{EpsSr4Ixi8!u|kR&D@+eGjaQa{R$x#H#su9feH9P7oub>T5WXoOuF8 zi2dqLE>D^d)gnGr>5s8bff9h_8j&x9Q_DOYqC!afPa69T#4fIce0kQ|9u zHEjV!f@C_Y{%yJH`3WAx;Vkkkb9FjcP@2a+lCBIDqvZ-A#()K2Xu3I6EN~2w`XXIW zm2#H)W>JnSL?lNxfbw>Sf zG)13U%ASJ#j)>g)lHp4#^0F*2?^d7guFSo%R1#sDU*cr^OMHXlv#m@hr}07Eqg)z( z(e92Ln+aJI!=UeyD_3lCsnSqYx~`1AFIuji1zTW zaGJ_F2R+2UpQ;kx_e@nO3>f}Qem<50-q(6m%(cb8U0EEet!^a zc*OiVn*yQPnbni(tSTqF#Y%WtwN(8tzW)BZZwE1rg!(90kT>oN-U+cT34$WVj%OU< z9AlMrJfvG~LOzyAX__JaTLU@x6>OH+;~UmzEA5%jv#{kjM1xveFW*?Cc|-r2L;I^^ z>DM++_?Bev=IMzX>gYPUCt6LZn=TjuOjfB=&e?#9DOss_BhxQ`>-t_sTx-O2kY5-l zD6TH0Xd+XU>ULDQqh5w#+4ftdX|h`1?=F4hE>|S) zIB#7}h#~M)CLKsHa{qHqfQq_*Vnbd|OBCH~Kz04ME&DZAC4|mb0E1rrYfUIH#E|bW zpMuKe5?Rw?c`c!CM@v#2KhK=&LOC+ZO!QE_5u`TNp9TyTf9J^@ zs`T)rURLKA+o{=+F5wsA)1$_GIfHMThGUxu^~9MwE>twxRXLpw0}VY-7^$7F&vF7@5die;+R(dF2r7b$JAq@gbDqQ*+IweiBoNe z&$8>Q#ORlXj|(_9{?;9%`*Lb=k>q9s9sKRLteh=Y*SzW6@|Lve+dh4}r@u=X+!szs zvkC3+4$*<(Jt`a_hI5(Ek~CVA11zQw6OE!VFY>H!S7*A-pZRoYFxc#WVb|9kQI4G0 zdsfeSxjVEZ?4QQ>YqguIJnY*|j#-s{(md`+ZpvLj1^d!zu!zG7_72`IuAisc@1Z@9 z)HWy#YIzcCX72xhIQsq|fGxcjxGDunR>(%nJSi`{RW1CERjM|KJtzB-VrKp*zHR&Y zmYto%tz&{h-@Ts1pj}VK&KZJh_7tvIXfK5dE#j@w8-w$GG)EK1?qVp=X8={@0&7~Y6mPqgEP_o;Jy6A@qO z>YECe_2+U5gr(^xxG!U|8tg~Bwar&X>w~P7gB!;ToYj9tEVmPo?Vy_oAmLm8D0|U3 zOh8_gXML-*zsF*5O=*dX8n9qNBS3l~j-GcfZo)7LHl^MUc@515yRL zSf%${>f;FUuJw5cqBpK{leLk=gtR4-Z*3Y^j<%_htLkCXHTqoSZV%uPdQV)3Dz2_m z-p*`1g}wf4K6z6tKiES;YcW@(w!Pa0MbLG6!bE>!$u3(+qn-`tCQ+(6`35)MVTcQ| zEL9RSs{!RWvf0bTDW38(fi?~+JS3avt)bMPpE7qXw){3-UiT%nHf5qO9vILc_rBxm zGumQeU%^;pf;&-H5>$uUsjG^Y9OWq9lIRzYV31a&{c?Cd#K2~ZcV;MY(aFjB6Sp$p zz&U;Ak%qjnB+bT&#lR>n21^qJ${G3oPFU)KKOMa}k4V;(&Wda_Jh|2t#YO+w% z(UfJ2NOJTqt|v=!9E}K?m#&@WwekZA!P@R5ilXa-2H=l;$Dh&m_)wOMXVW-}K1|Su za`t@yk0s^RZ@a9;XXWPDH{~)s_>q+u>)TAt ztlZwQDNam&7(Wsv32*qkL{55J@tBvF=U@?ho@YHdoV`u%1l>px79A_byKN*wx6o-1 zNX)8SezEs(?_nx~6w`BoiHBnxrFXqXcE6#3EvcW_DoK&6Is)LTn0{c-f)Yt*NztiT z2TdYV58APG5hW@nV}a7{t9>}k1XUWf*BBLsZOqV_tcKB0jxmH>9bZt)L89iS@XJUA;#akwiu-YU`OAiFL5siNThE0&1#!>Je^0?NLaJ5cn^(nD+D` zp70gg?G%6R!`hZWhra4~a^lDPo{X*kiD4W69qVB-#Sjnz9+CI;8*&D9QH>*3bjKG(+GJAoswfc${eCdps-fE@J zw&l#^c2EKbV?C4}sLl*6`+gi;8fpYSkL+f!j_2YIh2osk0R-SE=D-hPLU_Y9pB4D> zI=3@il(bwC@B`{wE7HuTIDJ~4{-jyUo=1>mMwYLfq=!H$(wmuF?kZAIpnUAQp6ltP-8UmcI;%j|h&RfhHVr3ohWl$- zTv1pvI##NL_DTyfjMU4qNT$4s(xb!~rnl6}QbO%G^lzg0bvqAlO#e=k{gasqZ@OCv z(FV<~Wu^53QUn#74C ztkDuy&Xr19n)34_$@ipYd9|!(bZc2K;CwkbOOF675pR*sgoAto?C}jvb%TU%`j(a% z%P!M8dzR>?17!(21Y;gpC9`7JZ7VA~@!1YbZtAgfIlXxMCX@ontt#{|aL)^oE5@`j zW$EXTvui2eBl}Q03+z-QhOg&i6lIX^Yc_rZ{pM)GJ%0 znbdT#BQJ^0j4MB>J&GWxP-Zu1br{X${DD-!-WP4k9&%nwX)4qCJjj7G)Qaj!lq!ST zqJaKlytGlqia9Vkbhoftu%5H~PjG`-vOdkSlPu+&@eKQ-m((7j)Y zJdQGt2#sudr1$2?rZO-)Bm9pcP$T^p2!9UyH1IQM8ms+Hn_v;>2}R!wLi&d}hJ+&< zElP~%j?_ZD426vg5(mjWth16zTxBDNj_`OUw~ph~MrGftqK|Ezwfin&l6MOvpxcadzgs-v;~#V8 z55H~o_P70^FlBdC^E$*G-ETo>Yauu8YF~&gg60f=khRGCB4bhLB5VT#TC#SFP1eNy z+aLJx|5!=`LrT$jZi$ta?jsU?_{j$D4!4DFmvYNX_2?pG-oP*Q_wa=5Us22*({1A5 zdyA^?ChcMDo*_ioPffMo+t^364EeQx3DiP!m+!#PIr<`a*&zZ;fyDWbQ&x_U%ohg92Wd$4412S9C z72Kn~_MB^&yS2FzD#x`{^Tm2)YO!2&%vt82Z23iOiN&!x^IV+^noQTg-1V#N8|Krd z2;PCM=ZDm@W2b-yIdj@nPb0KhpNc`u4~d;dbeRxeOP|pSNbJYAXMM93P#dwc7eZ}0 zhu;(rjX3vw_CDdp2qO07ITNI`frOxxqMzU2r!?K3kQF{ zi@n+fhOyU+5j?$Ursi35?turH@LAfYgt_nl+b1-R@p`$mO#~s18;Wbh2F)mKVr=#M zoIkPG3&bS}O2&@SAAHbB3S?fWJp%DE$5lI1u%1MgaCpsA*DKnB?~L%PBHM|Teq zvjV$wY%6A=BL*>?`m!-=CZC@!t8?oeZop}C;P*?n62jY~J^k^*y97-XjQC+K98X&v5S%ChC3CYeyI~LWKnsgw?|QVbC>f^gEolE2QS|J`toi zGPou23@LW3H{4M>P?+=cSh9HRFiMQXj%cPoTZ+{7dy;aq{62 zfcTjg5FkF4_X7QZd)bsFrLT{or^#jYu7p1tV5<+xf2~V4c|Qm~kQIoM8EpZC=0v=N z8GX=#zQ_@=6c39Z9ok>+WP8W^sSi1}wOQFjLg=3ZR+F`6X-SRTgT@MaJrg+EM2JWy z+`87xD$d25T%Y#2WlKn8QgJ8X+~vvfAMf90)}s5Rb(qnI)LnFa>8G$MH_d-4M5o_7 z0>&H!M&hNbIsZx^o?|ysg8{O>=zCXm%SuS|HV|D!oAm(@(%#O_&XcSMq*KwyelP3g z**CyqRN0r=!+~axw3B}tc#rQ=yQMe~&EbP%x)6rLVb-^Dw!oV`%F+V8k>w>Br@@@B zZH5>aQ?W&I<`c=qRP_ea^1HPFS#$n5<|x2Z`*uo z&XWq|5Fb)OkBx=!Mz1058zPh0lIaH1y<;X*}^2d|s5L#V<4@Qu7YXM!& zBw48=kpVQx^emRxqTct?(t|Wv|6EMDnxC!s_86kAU1JDt8#L;o+|uh-UH1lj+cd5% zV+&|BTLWXOGB_pRY&${OM%e+HG-QG5P#G>W84b74DaS}|g z9aIta(-tVWAh!W0vLg=_ySp`El;BV=E0C9k$`0EyX7CtrSH+WN*hUlD=$59%?1QIz z!h-~b*~r?THlDLt`ln_RVxOCm+sCZOhpUvG>0vAX3{D;g-^A0cm}*=dl%APHid|>2 zkZDNp$)ou8*NLV0S`OPcQx@-lH{Y#2h@WMHN^j;MiAU~lA?usm9>gbkguASY0}~kc z@{YvN3a>Ybvw7PSTat+tDZ=EnVxv%xHm0}i3jWywG2X+R;YW9IOu$D9qiM*zML&A! z#0@=%6oL#;E_d_+Q9Qn7J#DMXcs)0mh$|*KcfUsb&6TCL0&dcrtVY=-V|%R6L5dZHX#_7_o>YGwNeg7ox@cQd#A%c%vArYx ziW7`O_4?Rlio?}3`bMa9Qcl(jcC?(ch7YDo|y`5aP%#83M1JtOvQxG)-#xx`6w7S(ZCjg-CZmTvk_@ zK{n#~o$I?(zEJW5K<@B7sSoZh+)SeF~;2TPJ$DgdVA~L8I&0@=A1e zry~Zon~aT6-ywZ+oQ#536~)S#jV3+>>ONNwV>%40`9t-0yCGMa*1%)%?Nj}y!(|M7 zo32sIFZEl;DX5_vnIDDqB{K|K!hxzKB5Zr2o) z9%Fm9COR=Qp)D$WN^+sw9Ffk(zLq1D5Xq7m5uG}NZ4=zuYrEd??oEtw zS;md4ym`%@q~sBgU7^F<-zsUASZJ<&Ly4`7-*nxD*fq}8py|FXC-_~q~tG#Di`O`-QzFs9o-!ah6pRo?Reu* z;<*Y7c4rekUm`*@dCvq-d(a&#te93KCW7~b??MY3dOHLEE^V)yRXqcClB18P6wg zn`rx{x}k`Q?O+J=M2yW*F-F(Gcvo6DiX|9cv;#ukVf@0Duy7*)d6<(`j=LbIN%6d< zg?nHiMNdFh=*voojyOM6J3CP~pQ-vbmZ;GR%)b;e)oUmuK6TxRH=0KMx=hh)MDJ6G z`@fPhZbZyzcJtqx^{>b4IfGM&DmWfp!&ZznVgHhlBb&`P&~``-V1X^#maOPP#*jjr z4a@c+mO#>928SfamcZ@YC7S{+=>k%#gTHR}I}Y|XD-)nIurl*Z>ng}5&vDl92fFkx zIMr@3XPikvpx{yD(e$@RcQLf?ytcg%SM|H%ikLE7l)Fuv^r*LftKA-rXP0SmF_Oz&|f)&(Okberj`z(l~8rRWfVG*s(;ktnqA?2 z)o`&pH*`HDj6n*n~q=Az%m{OA%$eFbXg9r}y^y z@r-0pyUi+?#+>tmr8aEBND<5Mh*4KiAie>4-)nOu6i;EG>pJL=omO*T*r0eW$Y}Iq z)AigI%@~NloP~~dPt1fD9F%p6Ro$=^-FS56$K`HIvlR#1?nUld_pQirr|54beN-M- zg6TwQs^-cm4}=L|aM!D9TCJ|x-wZYcxi>h;Nl9N{%`eJjW#u4=DeDygOW-i)Ex>JP zgD+(Ij%n__;Tq|;#A|W1Z~?HpZpmZp&0zO~5^~436>$!|H#q3;v&CY1EtH!rC<3HI z9xSEfmD$*cSh&B)rw}HlV!tsWR4)7%d%;u+5Wqq#GLA2zuy>Z4oN+BpdG>a$9REyS zGV)`AstAaTm`ltJG7PoM3{{pguZt&BlT>f|xxSojsJ`BiAJ(+S^BZZ*`rNTw+!q-(diPJ$Wlo)i2gfy!{>dqBF%Y$Y7TVmGLZuc~r7iKt=x8bl5JYsxcF z4Kd*zm})CNMwbSe&muVqMVls8FS?O_`_0j{#b6oK)zw&@vGh#VNd8vp-~G->+zjP@ zCjeRnUuKFy$lfC~o`Gg)m`tnWp?v5~YHhOD7GtEX@;#D$GUR1S2Z)R(Dpl|Ug4Mc! zn=ne!HGmsBYijWTMYcSvfQ;c4`KD?b7iGGOO-Uqwirh;I{%vrFGA7Lckpc5KLQ6-jL&TtBX?6jZG&OA3+|~oThPE!)<(#QLQz80{p~hBJ-dCYo%1j=fyvXRR z$MF`oN|$WyQL>eh&q-7#`Kq9tPF7OSUUr{$`>>f-4dSXR8WBZ= zc5o$^^0;Yw6yd9XUtBLP$~oGm6896KB~PzuYB)QNsQ0qntU(1CY01!aSLU!fi&UXr zB71aEog-_tSXMP~+1D{~j9ZA#IfIEtr`$m`vub#hJ-|UbtMSNgBbCldW;qJkeX|h{ zjmfesBUk1mwb5&kg8fwO!}#$Si5cx@d`cd!yio$K0m1VW`k&jpcx1zgy~xJ(;@bBe zH~AY$h$jmL+@Qn2z`ran56JTJRth~94;cCFg;<=QPfLD-IIuXKZjYrYkpWvj4w_Dg zMYngrAd01@){?Aqp*m?&Xy9Qymgi69DzX|VXYf9bu_T*U-EsJt*Q)khbw}?jNBZbS zW&A4Qya}sKXb4h~O;z!_$%=DCOG0qj`Hp}XtB!KUKGqpze_)-~t!_RI)Ev>v_*O}G z39tin-$ad*$l=FqlTi~~k3?gMNkguH`?SldIx>wAB9wx1Zgo@cnedHZ-}pYpH@*}L z5-*L3hlpv2;F_o{+c;$<(m@rB(Uynsin@e5XUJz0=E{0*(&b*ULmbe`>ioQP@H8)H zoUqmOB5(@;YhFb?W^(!5%0*h{=suqUm z>N2F5Xe`#z7I_fa2t=A?-N2MrXJ;iz%;m>&yk_46#&quU|4sjvwz><`|=$k{U@lxW@~B?%KT910z=C^ZXctEaZq#5K^KEr!eTU+Zc~YaN!d z&$!}#^#}O5I39?n0UqC8%1bqVm8grFEvv|=IlbCKl%o}YY*-hcORZ3>xkIH8dX!2( z_V^D*5@VGsF0$tuu0+n5LPD9C=zWCek?wf{X29&kY*8dT2+je{5Dg}!4pLI>QidR+ z(sE@K!7O_xH9^hieUc6Vbj0;P=Ua(8r<96j}SM1_eMlpcYFCq*@!y*P?mK1%uZPLx3RpFD+40u z0vFobpP{Sls)nojul1EiZ}U+wY5uEOMZn!x%L0Mkl<_6L2`EsErB5!`i;J|>9~FD0 zbA395a)Tk(olR`;ZL~qvSj;%KzfJW-P}8*wW=LDTZmK_EFh0l3a84B8GR$W@XEc2ga0(N6f1Q#gMk{>Kqf?fD-$zap3oge)c}6pPr${phIq z($MCkqpSOaUC$}>Z;goR^JT-T8>|%jG+zuP%hjWWXjAWOd}PC=&+KGWL#I z0u!w?PG5%1-{q{yFm=olJs?wJB2kPpKWDSXLYot4+8mCxEbBm^(IT@GfOK;$PcW&y|W)KMM{xQ$J5*u*{Cahe>IfxDy@5#w`@*_pOdP#hGTK!`1^B zJLa%*o(jZEb%Ge46nmxy(CtLY2!e^-j&1OvlIa5&wec0;J6qJ? z(R(`SJ1`8~1c1&c=ErgpaHkmYpN#5%AecpYW)Mb6Igb4il znH@984#n5T6(Ugf#dZmU<#_^Z)xZQyt8sBUb@#@gt)P9&`vu{22s`7{mpg+V1Qt+U z>HE0UtkdA@$E-@Tx}KJzmI}AdAadV1mFAu&h}|3VWwHUGHq5*FHk@~7mO2l(<9MC= zl;=uIST?l~IhA3}o&=|aI_5bJT1<#?vP`d~LiM=7o2WE*UkkMgTF;MXVAr% zvk#ukm;d?GUtd3e_QPLaa+oK|r^<*5XMWB-g}+3*-#gy-?j>sj$ocTECch0|c0=!c zOMGJ`oWmqD4-Lh%WarIixim4M^pvE3&kUZ3Dy0_D~eA)s%VlkjH2$_`H`o4YQL zzmr=MKiDu>{23Xmo^ETvw)yYpbu8QTR!ZGFgqmXWyFVvg*LpuI;u}j&TNGs0k%OEZ_u^n-d_J_wbi$&fHIL#4Y&KA zvwVF*1v)9pC)B}eX1jv9lZm5R0n1Hq%n~D}6Ef3IP}p>RUd2#rC7DM#`H4#4xl&8$ zy+EA)#49|DVTL}xm_|`hoq3W%P!JV<)wIGr6_ZINiO3cO^7<=3)3TuztD2czeZ=!@ z&+RcC>-D_3sLob2&d7i)XdN2DP=*){sC7yVF_qo5e3nyVUC_*e7F$~478opjL;bP|$&g*M$~j)5=$1t?Fh#VA0tmTv za?r9rG;KA&&WSugW)H*$Gd{MGg=BoekO;=wY#ga@?#HB4c;NaW(X+k%_}HH#3b)-- zqGmyjvzL`0y$x!U>jqFp zhjg$$wf6|@9FxDXj_#B;E+Rzj!v8@V2Av}aALp6T?+58mU2JZA7nJ3*1ON39xA9$q zcsVPRySp&x46x}~oKRNiLtm5ps#bBJL;w^Tf%r^UsFJxV#g~(l1}^K5*SKHscFat6 zRLl1Lv!x+z5G9}b*bpC5q2@tc$hqs>n#>pxIsaZpJGX{S;ja87KHZGXOmwYui7cns z3;;^4i5;e55^h=m9C7$E4=QgF# zmp&%wDI#rg%#?eSaG=yHa|1hcX+OR(6Zdscx+x3bCjHX=UvF}Iih~to{w0z~o=q{~ z^%+?cxoqvnH_@bpibmkEP6XEDt6@C4zDs;Gky@(X+$pF~4b8F>!WUw7bqgG4hsNeFl-dVNUNU7~q|vFRfhm^N=Ko3%=m<#F*Nx=}RP( z%ZZmj`&{`EQxTJ6?#i-@39G9~lW7N|8w`MDBDu?*))JoBGPDB~1ZmBQAh-n<>ZV8w zzr&rGM5FZ7M6=hLG$qD7+V1fiA%|R5t7(-T8Et#CHR&x~+7RI9#HQ*Bhr*xxPkpH1XI@3*Zs)OH$BhTmDX}Knbnu&y@!3C0L@uyBcL2C?e3~#fcRAA z964|-7K!Zr+ZS&wc943gYWj=X!FJwuh9~Rc?%pZzWlwt@6{pC_jr~;a#08H$zYfmU zH*$LGxi4)hF)Kcf%<$N{szIl3a$`s*rqb&GO)w?*9$EZd;s~7-a)sxbJe(9BJ%9(i zBDCq>*UwEs`w5kI-kRUhV`+b!482-rxNjdjZR6I>vtZl#rGf(1H%73Fe-aZ5oe4fP zgFCi2Q4GUt6uF)KmIisM1{mxJ|C1~bjB^w|N<%pMPbp~+Sx?Le8+$L;LDlBKw@(?iX3AJr)(Z7;S52D!_+*vk-<%-f>O8HqE8db07?Q=n7 zh-~~3yNGF-C|W-+Nn@ z`Xr?O^Y-b^cAYY7A!@Wv`_i9oQwtmLH!Nr~tyfAoyoW!UATm%p!wXjlB=Qxa6KFd5 z94(1`{5Z@NoFe3uixvN9C*_>M+oQnIpl8-q%1xbQLNQf&2O7V>;R=>5%(tif$Q8f9 zPvuASLXC7EbwN_mBuFr&`(G_$86b93r5H>X6$qASA*>UcYGTDfS>ZH}JXl{k3Y;x;SDPNl6A zoIl05bu(6nQPa2RcAA>3+{F}1Y9-&iUY}oN{V%?H`0e+DjqHK42a}ACmECVciw<@# z2@sgrbTqOuTt^B?4(ddra5bCJ9c+Yy6hr8qZHx6YpN6kf>#6j~#f(5a7|Gc{s@a^omI+7Z zPxHBB68O`!J}sutetPX&19k-%+O=@tlNS^sZ@Gl%$HVi|g*&&ddM>nYvFf+RlGDvK zVRNa#AOWpjmWyd2KoaDFLv=~8SB|?AW@S=cR+BZ5vol1aVu#JL2(z$;8iA-;y-&_a zJ#MO(oBliA;IQ>-M2A8|zre-gXlppZ{$_5KAl$M z3>G!pk-+w4IlabXXIu=}ywz$IoN=3`6`7m@m7qN4XLxmQ#2@hMkq9+)~WP*wT90>0>R zrv9{7<>ByKTp5_oY9*i^WY>ndwQI57*!vN-mA54oE(pGfSxVvgetcZUfu&8z+S&qV zRqf>wYHQ}k*}Cl2Ea+ydI)g0CX(9@5&^%YsTfgSXOm2j7%6Ca$r0^TXeY8ZiW#LgFGazR^Y1T)$2U; z{D{?K%c0SE9x=rlQ%Fdd>0Oe#*kRBcZN1yhVtov=ELlMAcSuuV_?q8plNvk-cnR{^_!Ri5g2Oek_qCD^ox zh*q#+DO3%p__fT5Bq3jwv&B?p1gXqm$<17+et5Q8p>rKFlW&SezejOAIk_J7^elq_ zxvWmtt5Ootn}7rc#%G5O>@8X;Wt)+^_jp_`8286+q?#|*s~jf>22q@vQsLZNXcxmO6WpRE^e>ID8I;E~zGhQ{6Q06&*^-{hH7LtQ9@^OKAd0+}rnV!f)*>hZdvzhJGdbJ>PI$psQx zU;#c>s~l+41oyC0tAfmdw@AR@59$Z}Qx-F1taCl?re5-4v%kkRgd+#9k>ns{BVAH{ zSv3{z9dlkjPOJHcA2C|6cd=S6M!UOLS69QUuZH#Ve0T5r@4w%r5 zAZH1m4#yY8^4Y5YjYPwZw8Oap&{XfNhRn_b9)Q{l$a1_*>7BfNYPa+)>(9ijGO*(F zt+BbM-)ZnNmQ#!K)G*)?(+C=i<&)sb#^>dnf-PRv%b$_^U=yE@=9n-y-xf=@1Hp;uC$^SdZ0@zk`w))Pb2ekwmS(A=Y4cz)>tC90~{ja;G z7bXr7>!Nyw7#>-T=>gB-ka)1D=Tc+=@(=_(hDu_!f_7Gu6Vh#;>$0D@7Tz&eU~O0F zEgb7Z>$k3nejV#{)BL;5KiHlhcWSPIQm9V(-dfllyVK+fNKc*5;+{`BMBZwRIRX%D zWu=^2KEW|63O^zph(nJQFtz?}xbdj5TOfh<`&T=kP)Mr|s==fu~tmSJL2)H_{Vh-U}P6Cd} z-=h@j8 z8z$O!5%529fDltgnok?PZ+5upgf_0sunq9u$hh0e*5>kj6l4A#K6vn87hW14FW@0B zMhQOgkGpT+E&b=sUwb}Vg}EEwlb4c~95BOVep*kib5x||7r+MR$hzgT5^g-!5Ui?| z$JiE=35xA`u>|@F?+R2@17lwU2Tyh2KYRJb!~Ei_{Nn5U;+y>9+x+5uS+5uQyto9u znbzMGH>%5g0usbDpRDq;>U>7-RG0Dd0x))D*tdgfy$O2@_*&aMGk_;ay8DE z>r+=60B*mSEpm`arc;oli+PUTEFc9p>r?puMNScW>m24fzk=3C-%+e5Rh^?4gMN7* zauVlVv1oP*0)p5mD4IT(B&Op6)(u)6FRR50g&F>1QcgiWYMe^cT#aEm;Qx7|Ss+=_ znyzS#SMbLL^u+m=l^`@FQy`f++eJXgM?o!T{mryEg;uBKIqLc;+#fYL+>EGn>?-T^ z3cph79i{HkS|C@-Ton~cpj9!g&!O`9n*M`gA57~E7RFr%k-&3FLYkwDS6}5y2bP~s z>+y$wt!oq`35YCT;m$NFF4Abjl4Jzefpw84Z;JNIDZBCK0wP~uk}5Sj`1wyJ=_%>O zW?Bb_{V7yp6OEO;}EVX+aVWCRA<9H99=jYSw#RZ&_;=IJeT+-%-uV+OA2b)1>ceoI>s{G>Z zIv4fy`W%)O|D`%m3z;`p6$-Eo!AsJ5(toIy6`ctXsbQ0sSG_zl!09{>KP^k9K8{w; z1{zgLFF4OVWlVH+nDGh%@lz-rzb4KQ7NKv#1NH;_w&MIpMVY-y1prOHk24{-sJ$o{ zGmzD4jA4n3ddW&^Ce98N`U+v|vq@cIk|$l5Q#x^Rv-?g<+>j>g?h^KP^9|mARz%m|oDaQe?2>%uPBs5wSzk5fGTv>+-0pFqc7o&d zLb(`^20Mqg75p~=CfcR*k!d@G8WGi-G!rSr`uJCIpxY9e$4NaVBo$c;d%E|%jiBR3 zdON)+>I-Z?VI*L9;}1yh&ZhMh>J@g2-G_gCxcA_zZ@=E%d+^3@3Ik3$C% zH_RXQ=oR!2TEpY&Zk~h#S9=xm?KZ$(E#1#{!*1;glI_$&ryQiPz^djw(8kwzfeKKc zz5|GIG8h<8-=;xKC)6q~fw-2y*C1`3=IiCO$GAfV=ktHB%jGrZqEflS`ObpLAguPD zz@D1-#T0d$*HJLee_>@Xnh16qNML1a@@EovMEz-RN~-ffI)!xys;E2av#5LN7TJT) z_2YRl#{r+gE>J_}96;qXmi(AQ+2RKXIndrNCXO(|@NC5Y>cusvCRGe>~`GfiBO~ z0t5_6e8KFGfhrv8AIGMuWCxJ6kn1y&l8r68rIVFDuV=iIy42|uj>i2X%J>f@a;KIW zHpf(_{D($w_|e_zmY&tAB=KQXr-&Pr9kb{3iJ$h6wv=7W%IoQ6uw5)b>e*PAT`XCb z8Cl;u-O5^H)Y(5OHNIN~YOxNg(<$CPEp=GMB9+MYYO6qs#FRF`E<^2N?vy$4whUKc zN+EZpd^>{L4p7Z-fTlI6jLdAWgDG}Svy{novIL`IfwFH2RbuzcFHTN=`rEsgCnsO- z3Ilt#EX#kF{a>-(lN0iPIXM{-am(?Ub3{k(&#=Ic2P6N1RY)DXk@wpwBByBN{-gr- z-XA%?=(V+ZNA?eTY3;_5{exbb{WY@wrdQUs8QDMRrEH0j`hy<2yJ6)0Rz=JbkKCW^ zFe59sWam>iKFM}IIti~u-nZ;(^{zbYd(l*WREb?%J)Qi_8!lEU-dL&xUq0A9ym2m_ zM^P9u(;w4Fm`H3x-xHxq5=Lc@q|>DMJ-CU8!jX?qw3^kf-PJ6XI~V&N&N-^Caf${l znLH@AW~QqedtPADl(Gb;9P82SORsD;#?Gdwhk^EJS z$Yq$=tD0ZdAIQG>5{;mLF6I-W;pnkI355=+r;@Dp=&ttZ!g*HfVHTS@SkH|w_%uD#8x8sJKZUxar?O;GPdY&3-vVDyW^9B zD!fbq(qc=MXiVpSAd)7OjFGKKmp3ZF?YceDdHo55$>meJX$yaCl(;@zY>(-xez zd0*Na#8AZGyXdBfq{U1Q^Ii1*jEzxt!si{M-d-V5h4z9XhDX9>!X;SW7gk`87lJO>W6tgm=~v~ zlNz2}%a;e$44%JQR#gMF%qQzv*8h)1F`bkP_%)DHf33#loPvPR--VPXZ(hGwkEIYQ zW1G?L?m4uHpr`e0S68&#NXxsY)B1FGRv@Fc``6dcU;cRTlE0T)X7z-v|EJg4%gbV( z{a3w)E?r-L{Qmm~e|+%Oz$yJ>y`mksLmr+SzgIPuCpsp5L^mw>cTq0ScE&Ix6-I<2 z5Guv`)e?&MB?cGG3aSM4$UIhL(I#l&ka*CmdWjJqD_bW?7dWPC7Vj>Q_1Pn=-$VcV zn_L5(Q$D-8{y;DTJ(dwrqeF2+@;CGP_!nQ#JxU!*Y_p$n0fS-L2{7)B(=Ud~`Ika) zJ>66>Bxl=Kl5UfWIgi}(eW*`aXin)b_dVBHH6jQ~IrBR#&0KaN4sBSTpPb5*@CzKW zR!j4+V-eGEj^Bg8(8umP!x8<2(RCMyqOlyX-}B#)C+@og9+H#aKb}p z+S6unn}oRqWNMXKl0I>bwd$70jijEV4nLyc_jb#>+4ECAGcTvW#G)5WIfrY@ho*70 z%l*V$@9gmVp{|F{{DUO7iiK&6sta8w)qHNZW%?hBLFMu-Q)2a}oJMSZ;<5c$ZGTH! z9a#G?YER6N2r)re)?$xjz+`T0l1(^I_vH@yqh-7Bhn+dv-Nnk;JDg6{BU`P{rSrfX z*s?PNM+T(`oB#aNvW#z3bX~x=k=ynTD`4hL>|LMZ#fR)vFnOuGhjeb@=-G^a<7GzT z*DX@4_LdQ}Nco^mB7Z904{Qd%REC1qZ$`>v;;~kp!Y6TAc@Se))NrHA!tj7`4H%tn zU`63bz2?=i6LJI=y_s2PPO(gE;s0Kj7#zy`i0A`|W%TbH<^X97bg5jDo(4ailpm8` zyjnwPaS!I}K^)nKl9_PK>{TIg*wvh}m`lEU_MpELh1I!YrvUnjGNvF&A>(*)G>ok=-EY2uU&A$o};)fP=tk1Gs5B#}-LBD_SE=-~r=!2U4H zaY$>4*D!U0uc0;#y)jk8k*aIdO=H^m$Jrg;Df=oP@oHJj8%FWPP(sNV9YpLXgOKFx z*k*I4^KrK43`xg4Ie|?}N&sCzqQ507s(5)2l(g^=g9C4lM8s9=Q{Y4F@5Rx8Lu?kU zq%fcqUXqcGP|&G6BdEAdt*Crjq$-tJT)VYA>a{~5;f%Ky=sn4HvPm@|K#&cU^^_?{ zBz)y>IIfo*kp7f1qL>^IHparHx(U#zSug3le zl570LkbR0X1N<4;`!vDnVAtS}`W9i*E1+rA{;dzaI@KLccW?lAcJ^QiqUkBv|G^c)1{QWb;~;~l0q?kSD8&;4HEW3WPFv< zaH5qw2?Mj}bu{=_%PA9m5X#6AH4(zUB(Vc4H6!eFxBF#waXnem2F||R9dv>^E6#|e zD5g^d#fD9i?jgrs;uGd}I0Gq#EsSmCX|KXcp@8%*b+#z|p~mS!rc6Lok-y?w!^yE{ zfmQ0;1cq5tDnCSaB6usKW8_};h%p_;`ZecJj4?t0Ny?sI;L0>;Go|r@C6*C5)pHI^s{b>Dw5V z4tEi1gi!J41+c`9ck`iI5Q3PT;hkkUCDNl*vgJp__92N1ji~)EzWVx`Zw6cXSJ?=g ziXr6*64FWQg~YSt#%Xurim2N@@nlABMPCPZQH(#(G=1^)S6_WUqP%J5;xj8DKy35U z7E!&rFi44vc&lY~ehwuqz$*DxsJ6N(*jA@e4JrGrpT+OIsOBK}tMCPo28yX#i7DJV zyyQF0q8wLe)i|5h=kQ;+04~ZUd7g*46%jg11yq&g3~Pf6pn(5iup7u)*Z62s`^o@L z%?#s+qIcMs6sk~+S%@4uQ)SDSG5C%cccE)Y7^BSkC3y|sI59qLhH6)|*eEhw6)zi7(a&YszNf#x%ECfG}tkl(7hD z1N`ww57ed%Cwpx|H)+(35%^^9IDVyBr+`zaQ|cOfW>5A8x0Bg_T2`|PaiLiP0PU)`urc|Jnuoi~cT7?k{WYb(PH~HodnFd!X7kTZKxvF1b!Q_JIX)^% zNI-k+q1-?`$IdQ$7#Xf93OnnebMtIsOkJe`iRq-7e^(+K1Kp~80Kg5p1naf*X%N*9 zs<#_D>sMKc=(5d?*@*{59vh@?3Z%&pvtNhu5tb@J-DS@Y4u%ml;A*yDu3VXwh&96` z0Vs?EW5vkS$P}WP2{9@iWi z3C`vR5^dB*8Qdr(i#Al-tK$$X74vecV~@Rca(4D?RYoZoKpr!r_eHj$`zbi(kGpZE=h)%oh|DbJ-DcwmDX4dTeb#c zkX!nnh})eN3MBKrq14&@dAi*8i*)O)8Itm1!W5+GN6g$*BLSop%a!Fy)|Jrj>n~le zG4(V?-Cc`(bEwK5cQ($G0yXS>_Y0bCw-@X)iq~73#@K#j-3+OlEi&GI)HhY+NQ+ z%xTLVjodepzV>d5Ki#nGth?TB@nh2>?C)}xl*#dx#;G*4A!(pG`6`<4$#(X`qo{lU z*=Ov2w%4*Zmb28F!{lC-;-hEG`qS$S0ZPzE4_y+LGt%Ip!)v0BYL3)f6oRIwV>As# z?FBQ-dGUVAd+`<-i4<-=%}&Hch#SW#G)|z_?PD?aPFZ(<{jcXSWi zg!1I8v@{oGNNhHOK8F9Qv0$5PKzhr=m$czK>J_+OB=3DCSB|rHS>F39?UF3T zLFW7F*g9_={1M_ao48l?^l@`(bM47jTlFHnVVAT1);f-ehnFUO#?!DX!^0snTEAtn zRP}W7{DNRR@Shm}#SOomPp>2V5qy52Zav%oQoVy{^B6K?*p|czN zS-JD!2Zs-i6Sca@&K?=d!4Ba&KJiT}H83t@DO1kd8k!D> z6Q@yU7qN^CcBmy^)LdiZ8ZUVQ%VvgfOXG$}cfTzB#+BBjvrNwCB zX+=P{H}|8*)?P(?eQRSsdTh2(lHKQMDrXC)C{KK!-@kA5=a{rwTmU^R$l;z>Y+9bJ zx)Cd{V`{gybSpSjJ3EPU)!wR!%X7w>yQeGF5z-xP{ya|3gwk2-7v~{6Eke{t5hW1! z?^`Y2daBg?=QefeHcin_H%*c3>HW{L9b|F>qPVk@Ad9!(Lz|{XpB+9j%j*1Mwe?Q> z9FwR>Uz~&6U}{qrxapT`(y-B_tkojU;q!0$-(_8$UAvhwc&nLJ(r)0X#LveMlV;5;&cYd;3BJ#mg4LvSm9f(jhUMZI^kOx4&*P25TPGc-r(ln0~apQe0eXgaoN%JDh-a+9RsjuE*pS zdLoM>*85vcMH)ZGr7R9t-HEb9NJqMoPa_@H5wM4rS!kH8-)$y6T}hBN!mUWqCqe_M zEan($j=-ZPSGnxtAxIOjW6?M{-@Lp3&+hQ;z>7Ye4&Ovz?zE)x#G)@T6$6TwL>`&K zctR^`ACCtHVlDRCfoRj#!8Q|AIFT0DwApVp?jB-`XHQzCGe_UQ1x0T2CTelgiQz1l zb1dV+6L_u^Un|wx*D-e;cpRjcQPnHo5zATU>*J{AnUNhX)uq;=XO2JvIdoP=luFMM z;3nz0qP+DPCJRIm=26x&ut|h?bab~j7M19!$rbP$%^qNlX6K24nZErMu2G1i;IotGu45(0a&PnKyTPd5NSDG?|T$QYxoz&ue<%Mw3s!y^V?^`LR!u=KYmXxkm*{m$)4TtR$ zeteJjz zJkOCfpOVG0Byt-aZxsM1w|AQ^4`((~kO9WgAzmgrpbimFF<%#E2s*jCa8dMhX&v~M zemh)i(ru^v9NPkayPvb^9j%Ggr*@YSUO_aZK)Dp>;~5Z3%XB#2Y&YEB#vZY`$DiUr zpLC)hY>Nr;!ovTSMd{#bX@l$2EcSZwmW|A0dC%iqKfr%13+1O=mHwV-^$~Doqz8Fm zu)S5QKeuk`+ss~v=mDo)%Zt-XbkL;-sp$Hf-_0j*Q8z0^z(0k&r2HZ|jMesf`WK&Q zjNGjP0Btn&mQykg>u}13sB*+9rpc`U%$bC$<=jpl zox0d1k8w1Lmqxv<1GpuPeXC^lZ{b#=${bIaZxh>{N`g4{?XmG-5e;46yxZErk&smx zZ=jz4P*hWbMQ~H5!OWv)6ydx|9Igc6&pBe3)o8TD%D%7bw1Y*jtr{^nRN=xgr^ryd zgds4kaG7Dw(1<;+nZqO$CtlF%--R8git6kd^E^=UQrsTpM}qdA=+-N8O{hw8&XQV0 z^ul`2)|hD2s&7)33%TB!tpCM#55E0sFm$2z-$}3E(45$*z6cgH=N#E~!fF1SJhyXT zO)Vm&N1%c&itLoL;_Z+iV8S121$zJ$u4gD$%sA2(0k7yRg)tLKqG}hU5@>gEF4RMM z%0sp^?}!^!DVR3-10hlapqKqrq`a?JYyocZiGVGXrb$6}*)WBI;LC&PTDfGphlzd1 z7oW?eh0yJ}c2o$w!MeRQZ-b+Xrc3OmO#W<_m>{LJ;-ugNZ-z;UJD`VNm1&c)=fXKO zpeQUX%c+_WkRHL|fjmF_?4TjrgKN0MZ$VpATy;7y)xmF2*>@44p}ta78qvI}@dqH5 zqz_osi#37Vt7?;pE)e1c=sQUdKN1f)*aX-1iKtk&cR?4FQXJrzXqGkmefHaEw~uwyY{bWPBvsmZELYB-q)tO@PCpv0W*Zw zk{qz7?V(*Ox#Mv_9ma1Il{Vj$)cgm#nfp6LTSve56S144te1#a-&_Ob!CjgiNp)4X zsYyrk( z*_KV&cRTah^0(m;BDKXvwXrT~m)nTa;%tOSIKLn+!1mfUbl=WtOu;$UZ?~!>iceeMot1bQ z{UPDLp&9V?PTAA!kJ%{uYLmKM5lYARC3JhyT8|B`Esk|?qhU~-T)TzU>+-j=Xg9A} z{rXdq$74J`pL~VMaXk0&q^GXdU=Ubs)<+g_wol@=SlC&)07@E;BOA0^Qp z5=`6*MTX#Cr*ed}%eppPsht?thuv|%c09Ly<4{@|BzYiI=GA0ma~M*w*@26hVgB#- zmg1He18dyv7Z7a`icG8-0&u#?k(gA4<@f`;->~|gP zR9s}udW<|VT&RYv9JcWs!CoM$w1=y$UtJW9$*O*E@b2W<`}glQ@g@3ei46}cXyq@A zx^@FsbJMO)Bi+8Ptc!-rcPMLfChH~l~k*Rjtyxc)c<;k6C-}T6^g(_w8@-DSuU%&3OerE25PUMXUh-k zMNX_^`LRGyGfL}&ojsk_;}1L2^0J(o5NB9d9CFu29xa~aXu6zLO@nnlTAkLD>nFnu zg+bReO8Ro90ozO!GS`vS81@FAS(k?QW`(%Aw4~k&(ICxO&Pdc9wh>9bUkk|t#|AK* zf@Mhv@L9EL3Hwr^4|Wc@G$WE67I`#cb2#Dp4r`(C3OFF}mEBL3*1-(%glTmm-J#4IG3cF(X)?kDy>@&N-=$a(JG6URtm4ShGsy{|fy6aOs7n~S`Fbe2a3n<$s(d_7xELCvs3 z1Lg31$a)?^ae~7n4ZwZhNTMk1?sb>y-B_&=BnjDAZwTLmYQKwiT2(aUF?L)?j9SFl zo2*!IND8px8Y^{K?$ErFc2>K^sgx?Q3cs6e=E79JAPG%y* z@S0i>)cL`2znd!h=94z)W={9l&5X541o0UON(VU8?e(VQbVdY_Zr;@8@1wmZGXF(= zbPpB(a!ii854QD?hTCwFB)Q@3a3iUv=bV4ukfnP_OZ1SL z&W(guc%e(_d;r&7D@DhLSC(1rso|}@zGIWISrjZ-| zgo)G)(ch@1O%tj&=+<+3V^b<`eVA#AxJ2V<^_ejlxCd>%|0WtO+6uf%@@4kqT3;Sk zaFzGemg_Rv?i57KDNGI{-5|D??i2gEmByiIGb3ADHq58}O=dECjm(lqmnqR<9Vi2R zzV*WSO>eb!`eR-`f1_`|jFFrjV(*ErrcIZH@TT0!ZNi&23C(Ned$hoKVN{7Q3)4Cs zHqA$ZF&D~fE^PCczIeAf)bt;Ud&e94O+Bg3D#lQLd-@AdNR^!fwM7G$!HM0jxPGuU zGmnLUA-B}1r*aZbGfdsRvuS;`GpQQXH|$KSc^P3&p@n$5`zmtbdb_n{gYw;qg51edN~`OG%!~S3=t<| zzx!l(a?+fQBV$na&SU)-aHN7z@T`FfplaBgR#mV;dzU-C>^^;gsjFMaU6<;0?gyyY zFm1hD*YBH=>})RS1@N|x%NvI?Yom-;)=W{pw~xt4eE;N89Y0>J5bN%3?N)f z-(7g9;MbeM@Rz!p_j|*ha=37N<#G_5z4kIq3EWe7Hn(Qkun~t?&9QS5&wRX{)$%$* z{pU6`IQ8hVBUN&?z?hike(XlQDCU!C`4T0!e(7=PIJJ5=Wbvubtf}YO62%xiZ@Wje zOnX{1053-dM)gg!Ls>TI?q z@@WilW`(F7Afxr^$%ze>Ar59BOH# z63X2GYr2=65`v#@vdCt|M_t`{qc zZdb8k*;VB&Zf<7%)4p#13D@I?HV<6%%=DaFemv-Z#Ls>_$nnyoDljCAtJwnC0C@42 z^Yx74PG~e+c7%#=&HLJE(_{%`7t_46X4Lf!<+-A#xaQ?lyG&}w&z;^Ndy?(=sUYz- zIf%9sSzk+`{6k$&%VM6I6vS_}{`7b7`S+0*{`r0X@;~1{d-w8LEKEuh z0&7BIDd%K`Apsc6+0xOL=6J!)8@4UaNV-6H}a%V_L#gtvAn0 zT$aB|;-`L()(V&t-F)QEjZv~t&Vz!9nTV-g{;?-oFdAB5tR8^=o6 z!sQE!2Mfbr{4#!vng52OhO%;-(1PMZcx$ zC|Y@V;yo>6a=cf@9|Ct%G#2m!@oNz-s5-mmO%Z&*pGslOI6+Xx?gZA)Xa++NMaxT> z<5qq^LcwzEoO?u_S_o^kNgS0ASfb4>fboCghvm5%1s@hdXD+7IL&#q!-t zsC)PD=;&%Nynl4Gb8_$K==gZoRaq~JWmCSYrmJ$<^nv;FE#312nCfX55CTYcEdre+c{`+x` zwuj3cRpKyq6og?;a=3zNK9VYODBGeT$0~8PchJ|^~p2$@MIaj7TA&!nY zT<+t;?~nvgJ9p^8H{(PYR$}$iA&F{DH}&9Q*B&IcNLvrwjkBRA-#+NtlMVZ^tw*#= zH%-Y|*N(*Ze7b$r!gphA0i&s^MR?_Vn+qZI2htPzaN`F%8$P(hCo=Lv4rSyGoy)|; znG;9j(}DJBlOeOld^!og9K};pP3)_X1XR(?r!phDLo_|jv>KQF2Z)L?giW(C_hP$~ zA-WiFS3W}y$L6Xc6TvuXKZdXHoQ~3NcKT?xhE{QmH%|Z2-L{s#YiUW7p^h!}S{nNH zK}$oy8SmKOKifw3$7F-Fz3<=e&_KVff$!TJ*xBjOz@VjpZ%&g9@X_rwgu}KLCL3Dl zG=}4r7QRc5f#_1FA+#Np?-o;rMYSrM1%^@4wS~7q>`RcF(DD4i{^zY$Ql0;jJ>mTAJ3B2-!3&Fjg4^nsL2G)Z z1uGG<-r#oV6={%)1?so&M0o8XjCs{xv^zGdoBy+A``F?h-R5=+)tCM~N_>LP_{J`{ zNP-Tlm|H<#7;nP!RDYxE=wQGOdZyc6f2={cJ7d%R@64n$8S{LyxPK|N!HLV6?yF_7 zkReCpjKk`4h=P^n0$?5f1V}Xizyh8!0ywZYJV%baeOR ztbcT5`+X>O4W7aCLErK}pl-r%_`fb1SaM}9W+m(Qco5bm4&We)<$2?mWWIR6Ti3a< zRM++2)D97x0U0oIbo8NzBl;&$mVv~+`(;)_kLD|-#{<&2v!0`MWe57+h+59kgZ~}T znPv^5cog$+uJ6{&*$N z`U3Avs`=0(NP#~;Reud<#iDPNv*;J6%d)LKyBQ35&8%`KR=E=_0&^=a%cVg?c>JNk!Bcj()La`k#u&icPny(7E!k!nP0AE`gG z8?{(w6JQI|qMADrU@!=6@#r=PTlp$)?LGb!Tb1X}l=ny9e?~*LKO2#n+Ad$1f_gw~ zl>hIXC`7rKOb~0MxT5B>KEs7`%rOwj_ox)aAo*tC&+NP6s%3JmIaR}bQ!Ea#AUYDd z?(V7tYVfz30Dri_@@o%LtDE9jr~3=Eh1|(x3GtV9o(o4qtL+5Qcu&$B-rf?{h#Vry zeH-acy2RL8ddJIWc}^rUcQxo{L?d^6j;FR7>d5@5>Flje9cHsB=M&{<`leWZ02 z&rWN-2I0vQqNMimQ@ltPefJWdV&#d9I7t354kTMV?&UKM|V|6snhcHxS01=*=fl>53BmTL|ls@ zI!p!-1V?v&k{Z}rvXrk?UBHtU>#10Dhp-!DgGOx?+K(I&JH{V|lvJF7XX*E>nxH|Z zsW5#M=19mUH8#c=pa}h6If)4r!jSDbqEZDki*gJTG|tHhq*x&^L&GV@=Jk~-M(F~a z8YSD<3Qlhc!fi_M)TP7K=BJ+?qHN%*Wy%U5btcPr{uJ#(sVikt?YUgaSX+t%_r}){~py~MnMq< z@iN{3+|%QIDwx>A^dDv&*&E&^Q^CB;{oQNBKDBOL=d;6E*s=o zk$V(QpD}>s2S)}-;UBIw16{4?)9lB$@0C*|Jkl-CiiNZbTXA3~5~EiPhfg8?C8qk4 z%wywvQl6KLk!f$&_#!Bn(O1wYwc>1Apy1B-LPu1-E?i~8AhBHJxPs9Aj~(?wBAq*` zrSl9MAe?@!lg=Jx)0AqO^!ZTwusR-UX3e7+jtw1aZWgRR&113cb?FOL@5iY*abrPj|iDH`kfG-e4ixcfMZ6+k+>C zuXDkGxA}T@O5Ec~G3387(6^fL6a33@a6_vBk@uIjHL7>--eqs!qgh^=$d?XP!={4$ z?Nt)$Ncxgt!$_f#b|@m1c7Bj$(tU#e z*`w#)i=(^6(cNSBi;o{a(!G9I92UpJ)Tcu%R$v7URS}f4_9gKtn8XmyAtv8h<_r~S zdosfy?Vm5_6L=Ew|JJ+H+I_$yzp6fF7pv8x8SU<#SF4NlDTd|mUareu8vO6>0ygaK zci(;Wz|PT2c^+kjVT;zMzhJyB(scCHXEtt-++1DmMLa`-k9>4&b_T}6kw{kST>YBxE+zGj<+6ZP z4f0rFSo2W^7avNj<{NIC9DDE6+x9S{?iop1JDlzy60DA0(0??<06RjGOuw^lo!`81 z9rt}fAHD_!eW5Vg=a5*Z{#gQ93#=haFsTzM^ za@A6$&%XLzUfwQqrq$hTw1}p#y8y7wLgEp-feri-&3K@9f)%$N&F|mmeIKcS7Bl!> zPTXTWy^)W?#R_UL^ZxK5=cd!Yzl+&{{dMqTV&omc=ITq<+r8B5Pus4aXDf<-5O6(h zIi`c{8HiVE)SjcQ_u(Y{q31x$#8gjZ#GlZeR!s!lnN6!7+GJgS#@rQV*7kp|>lLST zTz>jGswuLnj*NEmASBp}a%}MCBb@E5sb|8=M4qELPbP zlh({ise_Zm(+5-+Vv7(A%&Pu?aQs?RMowiz#e%$h_T!&kp1gnimzO`HWO;J3WXTfW zJ^%B|=YRR(?SG!Ud-me>Tf5M>=W-#$EZo~8xtLIsPH=$M1o3!L%EiAz*;QbiT<;uw zYuh;-bSbA4XQtfOqqe+fJ1*L(pa%~ToL+6tW?II9`+z+u;uv& zN#T(Z7I?ZyTG#BJ>*AtC6?`s(Jd$C;zfVR-u%FX%`71nYGEL5$470z990AfOTrKnS zl5}Dy-XWIr3JQ{sMQF&Ne)f*LAV$K+Ce@caB^@<7``#i2+9It5M|Cvi*(mH|>2Yap zyjW;y&@0;za7i!hG$Wd9=xj^Hu`NTE`P2Giq`Bwvs>>8@*(%{1MVfqv&p%Ilz$oZP z3acT~;tMuR+^)?#a8k~y^C2c1V|x3(IPXUQ(*I}fxZ9Av&p=9^jIt=%IJ&DwDM;qc zdV$7VMyw&jl}b*7J1OPK_4+KkuGd6zuIeQvS|BPd>7~j^wL)KMOu*c0Fpmo*ZJf|u z8LhI1uK7T(rq$`PSfVX!QjHNohO|;-7h9~Ci@GUQ;;14UubWjpGYdHEbs}fB&y3_n zmE|=cec7yB6%z~F-A@;K6R58@A7qz<(t2uh|2n>S{64(L#Xig?P~TWAC}3pg?V;@H zDzUNqKX0xCi|yDo5#Eqf6K(qrRZ%&oE_z}rvz^hIP!dw_(OuUcBB6hEH`3AFrzcgc zXzm{q=_gh5WM?m^sUOZ1(Kwt3f9s-xeU$2;Ul@<&=;U9UI_WpBs`Ha! zxxv6F27_ON?(hIFtpUnudJ3%bye}#tvv~I@?qrntYagAB>M?90XgG%!2KzzV&_{bF z2EW1=j~@Kt57vw%_25u@p$Z*B^~ZzWfac;RvX}7+!OCHOZc)2ZYQTqj{>^iEdVg=w z*6Iy4+pV=R*Mrrl?4kxzH=vN4_>TY6#|mDT<|Ba6Z75#4o7A`KJvg0t!m;qII_v-5^%9p@qDg|eotIqf9!LKUs=TJ3t zGl*1X2U+1)vV*Wkz(1WZ1|kY&h?EH%p&s%xSnXO#(Lt@+Y80hQXg)wPgxiod!i{4O z3JjS&cdRqup)1U*`4otsJ&7at_u+$M_p%;yjz>i|{rT777Uns2Zr|>kuEG=_6Uvke zm)yky*kK=Y)f;!|X1T)MtD966Dm(-Dc5#Q}6-NmK$fr_8*nSKuL&&&XtPH@cE=ZMN z8=tBT(e#ZXJ8fs5p54{nv4D%3*Xl(O`-$B$1TR)4mWb8J&qK6$=^vc`J67c>B)Zn7 z)o7k(?h`yc^5=e117jJ{4GE2kOD1$RvB)eHm6Xw2OGZhBOwV?vo5G;r=oeE|%3PzG z7WR6>39xxzsVS&HVp`5I<|LG0q|8QjOxhu4TKxN(onP>;tsP`g3MRRl0mS~aE|%y( zbcd={3WqzaaKO{MAGocfHy0Lus!uqqqOGT(M^7C^=}74qHaOvUB+}a%UEOey!wu`v zZZZGI+**X{Ztu`S{fjJ|ua8$$9hq8Z0>=CyoL+^G=g|E~e;sZ|fl;SDXOg!7bt82J z*o%t$JGut`wQ@RLFEPEuJwo*6Y%u*nFB)@hN0wUV%P6@+c6qXgnBG*dkJ%SrfAesU;tNgEpLvOFLb1HIeMiplPI)-|W|;k@EEjZp zFyn!X4mTj&FnD%hE7CP4{#=y#9nLyAfj@%pzrNLC#>`d0s@C(N7#zI$jeeb5{xASqSi33xb3l+T*2F1~(D)F0-RjmY-i6NZh^^y`;s{l`x)EmJ+ zYt$=x%0u0i+Ui7v&ts=J>DI7VET-3eCWO$?8rx_>>nVP8=W$DP13GrAAzK~L!_L)6 zQ=Eo_E%3$nUw{4WD0@{cfwX+g9zD*!`3jBIXf|F|Xg&~r!D+d=LNs?Kq6-5| zoM%m~?6t*NiRTNr^XYnG46;A~->AyafeT5;-|()Zr|;n@v9O4j{R;p3kuDkfdAN5x z;K6!%t>Dg)Akd3oUc=x)Jjl)Ud~6cMW5Q@mK2golKu1xb>fQmOagOX9p%Kgds9Lcr zR1_UXT(6Nzs0}H0Y55*!R_eqn>%6GuLn2WQoGmAqSM00~aduZCTVdF8dM$=tICN7_ z*W!?pHMHO(w5Zcz!uPl*8r&0%5nkv(am4JG;pO&_aVQrip8Tp_PsJom9ffmYE?Qg# zo*f{VNR6?`#H#JttM@P8sh6rbCnnq5IPu^G`s}?L3EfOWC|*t1&4qpw$YbhupieHm zh&S$|pP1Hud!fT7O+~{KG^;G=X*=3C4lkDGvxYnA^mIxxRC7V|TTHKtYo5MgEcb#$ z(*LpshNhrHxVnbBj0q!d_0lB(Sa>~OmeY#hb*g!!(s2n46nuYGRv>+V;9MB&}q4+9j3j3%O|3r1HAXJpRLKP!HzGu|~(YS|>}1|t3K!>oFHkbRH!jAAqYK#jD*yxZ3lEJ_L4l68Lj$Gz-- zul`=1zMR80i!SH9Jg3OvFq24Z%7C6eNKX*nG=Jo2f=%kJ5+*N#8{z^6Fsa9Db^jI_ z>B@G15T(XJx-OXS-TBq<7dY>WMJ{L&{&>h^gdi?B%@2szXXP@n6;xh&EDBd6mK&!g zKs1bo`h^PI<*BU7dVQS*@h zPv-B|9n(0G`)<}#jbe~UR&VWvRJ!_Dk@n2<$V6-O8rwA?%yX~v+ACTS*`r}zdYzD7 z94MR1^XD)%aP0~o5^i}^_}p&0!+xNTQ=4ADzeTpdZ4w3kBtUlY-bId%LcY7)So-%! z7f7u~(gn)%wse7Q9d|MYQo+rs<7D}QAlEyp%p$gal7@{Uc2Ir03D?GMbP;Kh(-hL1 zFbyG!m8{YjUsTfx=06aTV6ILSp8V(Rw3Lzc1~&Vj-@o~5?$yI9*0}zozz3V;@NgWc z+J;f6NNyt9Q%u>-)b~fl^l@w08vk0ec!IfRnymlDS6_YmVBpWH&JSdDnEdbb3*Gfz zg1r}NCo>U+{dJ2-G?5cj;y7%t*0#gC3T*PE=15BA8540x9sNN)BVW_Jd> zBakViHYjd?gZwMrK1;&%LZoz@2qavQDwic`SqUpaPs^^o)Idgnu7RAgY8XJAs-k@a zlE!rui+?)fnZc5co*Nkd-o|u;&+$92hQkNP+hE)~n?P(~lp}7YlT48j=BIaW|Mc$V z!9g#cSsI!AQipVAC;G3e681GQz)>-9zQb<${Ar_^Vin?Am6OOZS0?kv4q3L36~Sgx zl1@5AP^^JtsB9L@Z*Uz|qYZH}b0T!)Ine@jnNZ%*rERG4G?>>@+|5=Z9*+ zTnKG@EQ0JhUS9L^D*GAlvxXTFbMl5>CI6%Y@J}qlvJwVj070cBdk(Y=R>!AhMz$@W z-)I&qmeusyzZlmm%vwSUQZiy#eVMFDrF#ZjtjV*nF>g}GjoXn|C7EE9k>#4kzEGC4 z^;{cT(AGq5TK|+;8T!1&o#4KUlUcmL)NLYlHDop<)*=@jG-|Dl4>~AI`q^hHX`sKlUPOq^kL`UcH{b!X5K$j;O(_YrlW7uc+YPVf!h_zQ+41ic8$3HQNke`IYl! zhg`~O{W0r{ZwBq_Av-Zl>jria?R|QT+>5##9c(zS9h>sovtJ*;v96dP&A3| zTA5m_V&Rue4o$Tt(S=NH0HBWUGTI?_y8dK{9kWHc&V3Ga`-MF3kTxkpz87+0WI*HH z7LmSu$IEmC{;C$cmZXZs`Owc~jP1d&rmcvNjSD!XooU!cNwvrFMcuT3R>_+2$F4@k z5@gdl87h(1$Ixq610o@?*VFPnoJu62q}R7F_s30xucD|Xp5g!%WiQHUHLF&{HSO;A zpWZqANB{WCqocuK_dL)t;ML)LFzOHQ4|a`9Cbvx}SF65L{a^?z+)L=J)m4OWie*&} zA8QA}8K#tBI4Wu*=vByvz&A=XdXkYVAX=sm;W5ZNvf_9d;e);7Xg(6N2h4NX1xv|} zDQ^(_yIh`^0u9JUV}Su}aM?JisqMl?5^mhpg%%n!g;HYDAl~_!vU9nm#lul$JcTDt zR#52{e+vxAVp;AOAV0=)nTuA)jUFbmj;ByXBPg5RitG$#;zGVei#IzODT6mp3e|6v zND74Aq)MeBVBQ1P{rGQk?l@tt;~)Dj(4q2@(qJ;|wX~bLf+F>Tp;lX_T}`BTJ05Vu zzozj~oq};hpjFMyx@F_Od;+>(Ks< zN*ki|k`5sdc}W*CvBt0G=(0498M5svTfT%VIB3swSyd6r*iI9qMNJgy>*)xn2GJO| zl0j0*z-Mz=Ho2ML!EG=kH+9J9g@ev)=)_HsW_A@_)0ln36d%goMeg-ye1NRi3(L+S z+oA8Y5PTnFimXDiVjGvo`y{$P9o8nv&*+;>@fvWO|Ev-c|6^xoS3^W-?@@ktbkux# zM?bq~$~EN*Ss2&T!%lIrr3a_#5QA;Ta5gdJGY)$wO(Sd2H_f#KMO$Oy>al#6+Appb zAabDpE_H|+8j8Btt~Jkk7@OA9k9ytHXQ|CFVd>I5=*QuO-HRzQ650C)qGywfk*`bU zQi<^|)~gyggtO`+rEVRb$GmHPom9Y!71yKe@aXQ&ReAcMTJ3jUSk24sxKy0tui5_@gSyY>FfD%F0sO0vPR97J z6_P zAa5E@utZQU5zA04epIOtYMrI>!C<(m|Azh+&x@w)BWfGH=5SRDw%6TNyoap$Z%H-i zNhGdc8pxw+Yn?)kM^F!fihUWivJpyPHu4rz*cUFkCf7B9M>8yv|D4 zAE>FAp;IuLgxH;orR&WDW={jIQB1mlE%zoK3PMXsxM&H@AnQ8fYC(GE>I4lg>${g! zEpp`dnGH8W{IdxrA}g9k!Qx;pV(6C@L*$X_Y-230=_zb`U#5jX82Kuvv{)oAm}MAXzNO zYDsrVV!F?<UVnyjplV7U1wGBqXUx0Dcjr=PByo?z|G}ds5r*i#=pM4D_R>0&@X-JRL}CY# zyN0EeI%9<)bh!BGsWcx&Y-vIfwmJ0aOSN?a++vML?`54^%9&0XiOHLz53G@=|G(ot z`t&0xI)A8^RsC#D=_La)f4vE&7rq^in zScZ0`R!qP*dLwQ%ZbbV!NCeylg<}ehc+NFf>4!)dM88LwpJtvETvQ-Pynzqj*Bigv zS=G@`pON6P`EwRf{3@np(f%HXeAV|=+3$!;xudj zFbWo<>c7`z-@kkINr`VHE~<=8CP&8)K|lL z?sS!orH(rBG%ETN*7~|1-myRQ4sQ)!UDz_ESn6kZifT9O$S#2T>h?`i+Ykz00R{F=2-(;#CQL z9Ek0BML6DSuPuu+`@E@UpQ`y-Vr)QTI`?YnIX}0T9AcMcH5|A65sKItom#K8d%!5R zZApvs<*sE>YAZCi7|gSIAKA(MAo~IJtbb;o7nla?mIyII+M=H6TPqsuCgzj};+fgE zDe1taCRD1FB(^8vb4h4>68pl&uwbwnuZ(60sRyB87Jfh}Tm!Z`5cv1oa@P@)ws{^z zItfP>unAb-y@&C_vHqB^BE5Dyiz-ov)NpCu1?A*DFf#D%X)GZeaP#KN*YmSF_;Qdd zBsj#oqN-MW7~~QE;7F+F^?EMP^-pJY3F>SRVW7sR{XrBAOG95-x9QUu)g6T-%dL9n5;~{|LXu<@zH}{MV9Itop8DX?yf4E zIDvgpPSKU^v3O!MhaQ�yPz3{J|dDF-gyXX4S!dqRutvo!n5Zl-j1|_nJPOn_c7& zCXaQ+gZEVDIT*gn%5)z9X+W00y{R!W_^{H>W7nTXhwhCdk91=YWC?K}=xQGXp0A4L zKG-UOy1mUk@)|ki;o3fl>Sg4nFm;74uX-dwok3Z9bdk;C=WlD#ZAC|{g|Enfg9U9J zudbD?WycnFpP7sWp!>H8hx+*tPRCi)|Xeq1c!F zwb?_dG9xqZu_ByKZr_jU)*H&gnYH>H9*0eX^Oq>zm*k3unD-CjCVnMAQ!>&xUxWao z<|brku_R?zZen(}hnSWL8)5{~JhHJy>W@4+(IfL`?&2?*!Hk?=Z3*ElnmQ3uI?)ug zRiz+em**YHl_(edN2ap4l6|7CA^A>pNc=19!>kUT15Rg}vZ1x1OLB*qNn5EpJS6up*n*<6>IwOiB#8MDF{lxXv}`4<;}vRN^FTxxkdF3g+|m znJT~rEFFMOwl6B0o6J-?c$#9VN(8#Q!T^n7IYfjH(Sb4OK!JS+&Pq+^fRF{SPwTlN z|4`LMaajq%fS!1o(pN({jnB>k&C!Ah8b-NeqbTKse%P~6z1_X>7-ZyTSghR!+;2L9AyFprJ| zVWWUo&&`wEQM5bnnlJTKwfl@Ze)+0TCe)HaALzYzm_1iv; zY$Q;z5lo*X*65Tyu^ySt|HO(-nHBTmoCB$y5L8oon7u`eIE{0Ou3s1uf~1lIUj5oJ zP>QIhgO*9i>=vTH6hmRZ1AzWRfoLN@*<(qmyShSh!c&f(Yx@D z)IB_@nm5P+!StfD1QW@sc~@hwZ38@*MAF#_0A$K9^mCMi#y zUn7gKxnizEJHpCr+VV8=Y!pyDcSF?asugK_>ir%$WY($9B3OT}>koFdPhCO-t6~$p zk^Rfl7Dg*Wv|E)Ng}XP<9aTLXs6X5p)f6(U)uw6CLyNqQtRG?jG&%FCbZsF%Ma0X} z`P#LCxbNIXKQ4ebs#esU7lwf9_~@#U*g{23ady<-d<8%Y`sMb?P$^bD+KW3;jAtTP zs!TunC9rkWv7YiXkDo5)Dx2pA2WZ2$of|xRu=)U>+D$BRAdo!HBC!G{od&3B+0{$fnt$2@|4cvNa6PD-HQB4$25+KW<-nRE{ zM>94MG~+SbPSsk*m88YGZvSpc)NdHgpNnZVX}<>tEtPn7!trSyzlGynj&9d>TIu40 zMUCDoW$fOr&6{@nXaWeKouWFr9uidS2j1cBcut+>?^xUiavK}ge;nv@Tz@I zm#Bx^%S$|upDZuQzKiu`&`Df!J^{{-`n5q^GQx{&_HM$9%>Xhkne{;Pa&h1NNI{F~ z^O@#o{KYMWC;K36BSHB`>wmHsWr#@!Uer6!u#oPP+lWugS%eF=$cmDu=+|ah%52M4 zS;|nDn2C_vT9iw)sQuL?04=6^`-9kRqR)t1Fc9NV_e=eNIc8#kE=ZIgMa5K~Vg{md zOw;q}JIcGSVtW?RFqYgo6wAC+2PuIyIQfyr`|%U6JWyk=Fji$SaA-mj?K?dx`}Wf^ zP<+#EJaP#EpzW-+eUc<4TL?wBrve>?qiqDFO#^=4CMn%UTG}KrwcegvNKI}%`)#${ zw7uLcJ$;e{)!KeX@v4OmPt_rs%JB(%a|`JwkbqKgxw{PEvu4ymprn^N48f#FbU32R z!XQUQa(YN08KyQMMvUDld>ansV}95_y6c$t)XvDlkR`*~iXR0fO0Fgk(L(KV;amL`ettUA9~ zp(R!)Q5^Q#N8)4Ix`+HShRJNL>0@h6MO;vG5koBeQKJ|Ywg)h(PkW6{NR_bz66P8# z>74+9kEE6z%-Y4kDD<{p%`fW@Xk{WN8k`%I@(MTc@NC{#Uvko>iEWxLR~Pj}00=YW zgUJ8M`erf3lyc^h7&=7)XvCN-eDM%M36eBq{`9zh9*fy%NWw{tevK5S32y|(?% z>XiOToOt;>7y%z6hD#(AwI37xZo=Thco>%}ati7Qcg}GgB>iscCG#jjb|+7trDt|y z=yRA7X5&dBfz9S$)^Qj=#NkfXY{ zCmB`I@lsHva|Ie>JM6HDrWDOev_Y6BO$8CItLbV7 zsLo8f!#N&Nc99QtmRc!67&G1=)CF@|G^IQ;;k=Yc2$epx-+sbh+LHe(InTUZG$Zv# zuG$${4I(QucPade6>&sNmA_ARhVCmW$-^1?U#grUh}k50FcrYhmsUs!`s4^oouq2u z{n@5nWHR^q<@YXt{>5sw813#}U0n@l&|vfR-X5a8?k?(PwM)*P^Kyk-b_%sEcfQ}L z=j4Q`&x665_oH)q4JC<$iIbG#Ehav#PmV*^?{6uPLRBmpUJ@95%uk&Mv?6Ff5dv& z4~8d~Zx_C6wEe$?g%5e<*El{JR!pFNDgdu|>c;KTT;ZmJLQ0leCRcuE_C zwKyx5h-A67y?aqg6Kb=>IEtl8YJ$$S#O&}QP4ZYRhy$tf36Li*R;cs8)$7$x zeYRr~Ly=FgYDU_Pp(amY8;ucH3^*g~C#TP0cw0(0C78_AG`jynI0*Gs#6e_J9xNTqAkwGQ$0TKdtNV|0|{b!S@F zP5BaY2;nPd02H5t=7Xe+Agqb3v`X21mMA^1^$e@|Jfj>#Fi$g>Vt^+6P#R{f6&Fi%pl49D30kz(uy;m&9cbC8{o3t3D+q379@ z7g*hY4$6KE5M8LO{gDr-@9vE#ufUyyTIjBLEr>Qkjnq}t=lTZ>U>UuZxWrIbh zNKh&N6Z63*X9d6>S(l$bjy#JV3eUAe^@b*e22{1PjqV3fyc@Yq*rq!sgt?Pk;7E^l zS{1I*E0T9Y9SH1lt*Y$`?7{NdW<}C`2+#d~9OTJgs-VH%iKI=gRO7$}$X1d(#Uu6G zkW;sjP)>9ZZxqsvmAKLp1zM^C8O5mx_#$Mwka3dhSi7cU05QKIob?)k(;MTx%yz_} zAA=UE6YaHYr_els6!mmY?#OHgVijV}l(v>kGFDttz6wnIOMlwfq2&C7PAQvqMCUBYkGuF$dx-2P`NwEY$;EWSZi?Cr-`3lemWK&F)g`B;yDq#eo z>tb5Nn7PDKfdEME~T#?E*3bR(er&Ls0*d2n#X6U5-AqdmY< z5aP}0i=HP%TkRlaSG%q|3xZ6 z%y6PgkXaO_v!_7l{UV`B|5CVnYap@U5YG;i&>uK)_ZtIo;C!k> z0e20CKpcM9=?(hzj4~Dubx%0>c$EE6*RcEMxs|0ie2C)-YG70%@1YHd?Y**br(<7f zaOv20sh1%hcI@l60#?|4;@#%2Q@vBpQKRgT0}FChLQ>2g8[m1e96Wzqmnx;TZ6 zU5u?{sho5#d-S0!7dyoi`uIdDx+*FC5Sp!RMiQw0vI1UQ^w7oBVick1sZmb*lFBEXg}ehQBH6)U9ml4fx$?Wl937Blu)H{ zZ&_rF-P#&IvpCoCSoivb{lb-Ptl3WuQ-2&Ap3V{og(+>fE}a;ym1H_17!s_@1zbJA zNnGUFvbgdS1Gk7wxV?9ejwU zg;54-k)LQ8{D?iPk1DIJVi)<4r*qlH#lU1@!hqMiY4sC5fCZQHjsGP+!Cxb#zmYc> zU_jjQSpNdbqu(mK<5>N2#muVtv0kCifJC~-)76Zr8q(W8L+js9)h__m}^pft0))CVoKOUxEGtOueB&9 z2~jg}!|il0)t^JItM6=p!R;h8U1u_pP=~Rhfx;LiRIaHYm2}r&M6XZivKr}^SVej+ zyjC%1hyBx%efH5p~CQ1nB@8N@Eevz4zt3qHt(9xo(<_J?s-yy?_t_Ws0dDeWW z7DIokWA_b@lW(2$HKB&sdO`^7)6tY7<3;dl@TpfAT|yl`a)2e}7>B&Kco3O8I!fp` zDB0AhIfzf78=o>Mqi}Rv{bG*Zmx%+h$SLDys8@RIp2tQ+d$lB=XcuMq4qb?=59Vrbxhb zh{V;GzA77q{gY!*hqi7rk{K-`;Neyngi2C4IqwV|=KT@|uu942F=AoWFz|`@tXO`? zE_ak7$@ZwMjU$>ZhOys2Uey^Fs#}&K%jO>2K@I6@ zqxQ9^TS4*z*=mM>4B~F>0-}sH$%WO&a*VvtrKqvr}C&R&mUg6Swo!-|J<}T)?bhJ5Q!3#=is&PXw14TxV?cVMtgG zmp!ZIRdeB9G}=eazI5B%ZM}#9nWsGK83={0K>;UzqppcOUi==c;<#kj-G1jtfo=JQ zw0Xo`Ct;{tyjNlZHnrC>F-9TqF2*sny06e}!pIJ^7$LbI<){@ zcFx4wHZKK6GmeL`xe^y<@irBieQe-4oP9ivAbF%G1~q&5*QXo1QmpgMR`!`GC4*j- zvqsxv7Gi}_G)!Afiu1rspi_*gH`I9Ut7mvzFcT#Z9;)9+xULrHPbfp%svyz#EF3Kl z2V1=1BoVEVVy!A2p@fRb;h!#=v-QF`31Zy4xSlL2-$4S060V;WLIu01-{?iRa-a37 zqtR=E=o$+Mlvn{~+b<;q^Mt%|PEPtK7T1=`+YjYpl`|#H>Gn}w598h7lF*2rZ&5wc zzoRe9JS#5iYJ$R%Ny&%>n}FXAM`QO39R_sAA_zy3iHlGbUK(}~rRucZ)hvz6lI@3v z+-}-I(y#K45FM!{@e2>Y&wI_H@G@eOf~UZpE#9x}jztMQLKYl7(w-Yl9t&;WLwcr_ zjQc57N>XEq9X&j5Q*-v6CcJcup-Y9ZMJ=+1^Req&%TBabr;T%M;8m-;ia>ql3*WO= z^Z#V5NMFQb5^4qP8RY^c9lDZX@8skXsU_U$s2zLILh`jnl9NfM!BAjF9F7&1*f?1X zx?%*sq|oOrMR(3XvoD<#h%Mt5V<1@q)7H~yObJLfbUEVZ?V`6N&ZDY-MC>8_#Id;& z_98u1=dsr=rjNC?BnovCK_OAPUVS)b>xOVcU@b9l?2(I2a+~}`|)cDDfT2@Aa*eA7B`$s`*hl$#f~Q(mWcS&VJAoIml-Bi`~f4H;P^hD zRE%OmJ;lNkjUSwnzrFqT5v) zJka+sOu$7S4n>}E#wmOjR!YUqUXs7|H?gcv&EXB^`zKB|uz0><&faw49b6kMQn9qC z2S{D%5t%EIY+Uv*V^(hm%k=g)8NtTI%29m*_OGKe+p90rbX)5Ipt8W zUapZB+5{g+BaY>yj?K>|6hCkJ0w~Q+fL2f?s!aJ2C85ibGq6qbOm}3A?X5dSJM>~Vd%;ovR~Im`h{812nLjjm0GT(( zbkQo{CTJm27eX>xO88-RP@&EQ>rj<4oSh0AD(2c28mZ3WE6KJ5R2?q@=+BIH`4uAE zB7_oj4nyDTGq?uns^t9|sS+XUYZ|CkISs8egM+I>Y|7+d;!Z)#8qqkoQ~@_log=?* z`jes@;^+hD8oqK*S=po`SHiNfOJ>>(HZh-ko~d_0Jf_X<(RzS8x5B0q!cKIw9c&On9jnU_~Tb(G^gfB=uTbSf7E zpsHDki;g$6)w0zSr^p23e7PQw9nMz3ZgVO6jj_$5xw#vTIdQ3i|#$)j@Ke{{6&#w8|!1p>yad;1!p1%vcAeQIG ztI4t%nA1A4{?5bKWNjGv4;%vu`R)M0S1o4Eq8wLe)i_(Pswq+OpVtK0b5@-XQ4RFB zrld64k2CAnzE`kn5FBI)tMZ=I%Fgd};b*JW(kYD({NhNjigV-#$w5>onDr#A|8MgT z^ZIHo7<$x#`^W@(c+;_5&oPO2X1i8c&Sv4GSB^*#-@ z73QOgeJ~|r>BRFA@-D$Z( zcX61ba#}Cw3}YvjaMg{=(b3U7;lE5i%n0n+jCOa=fmdIj5~kn7 z-e#&J;UR4^ANfMIm#OxBwQ#cV1bi9;aLe>_<@$^za5OiqYsWP`y8B=CIxFCO0pXmZ zQVG|Uq2l$@p>2E!i*|H31-|nJMHZ4SP*p`fA@j^k06TG$htH&3OzUgLDO_4b+Uq|k zQCz|5t3`u?liDM+F^2W>eD{0}!q+ZWPa3R?)okkD>{isQ0%p>8xY!}#VtV%yNZ{_# z(Xa4-{r=O@@VBF*hasKYJtmaXa!rJ(aU zGrcUX-X~rmM6|-!>2uTeqX+Ji5lCL1k>NMz=3Gz%6-hP|0BEkU{8)}@ zF7;@94F)4Q%sA6(Q@*0mq=sh_4+bw6X3ojJOD(pX{!RE09dAh4`@lkscT`wt1s z?~SMfo*u&94m{cSdAabwi@`IB?PNZD#FHG2jM{o_1}$^YWkLKnQ5SVeBfX7O#lO_m zyx+Uu8{}cDBh!6dy&>fm7?B8tsGGXCM+|R>NrfALBAHACE&aqa>P1ujy;!>G^?)l~ zRbyqc13~8597qkyvncuqbRxd(-7=S*)j-6!xFmQ4LpZI{dUQjJ=ml27WmNZuLxyck z9rxh)oE8{|Z%B&O$)cW0+7nTU!qil!>lMM?H;j6(EX2uBHVkvS+`&_l)yl(u zitd6J^>Rh7_ktlj%wE-aiVH*y&Xe_7h{KO2)nz7wz5DC0l=|f6=IHK|oT8WL^+>&k zm+%II=TMVYT;V!5Z;HjCtn+c3Modk6dQ}Nb!`@Tgak5_OYZ};z=Kk(Ej_lhn+G6*G)0X|S3!UBDn$E_Ko=<0~OpMOz{o6`sTSjcR zgl+V_M$CuAdv8f;8`%M^l=gtPSSL!Grn7r4^3|jqL-D2730yec;J1zw_-Zx{QnXSP zBmnbYXms%)Hd$ld@4<2Mv}W=Vh=B8Qi5Q&dX9ulBkcxF#lnyW}p`F{tgY-gWeX+b| zO9EQ6;h6S&m?|X4dm%qv=0HdCa&}ry@-s}>nO`jPYIdFzv}j&6EbD$KuVLzPi<F=P`(Ozb(#C!%hvMBb>w zkk9($l}65HtSUiRo~E3tfCA#Fiun)aU(2)ATlmf!B@B#war4O}pRDp}l`E9~MZTKk ztFyXZ<*N($KOln8ZyABtZjzc$i;&m0x_FUwo5ae4Eos;D4a_1-B2|5yzfSOW1%DTt%4F zHO3|J=Cdn=_2rLvp=Dz(7x{9fwkOe;yjjm?a4hl_jXT^7cBQLoHN|bsJG+-k%eB*z zmWy&~%<2Zwq%L6;HNuNcN+;{qE^6`CQ&`QHS_W@eGYdB$)r%Vu&xBzj)CSN`Q0e&( z5J|r5AL2hpcYBYX93AaGKE6NbKONDF#{>EYe%-}FcaOgu9NoSDTMvHp;P2l3-}JYS zA3gaed^s3A-PNQ~qG6vc={ofqg<3Cn4v&tmc8>3le*2H#M!$UltsNfz13K{Z=;+w% z)R&*DQ}Zzc3BjdvSnT}!+0Orca(svi&>j5G@WIaaC;ZslSL=C&Yrv}0q3n(fTUM7A zR{Srl_c?55RH$S1ed?q3;2*2}qS(%8@YJ$tn|A}dM#^>sXY?)Wk1h4>(cOPo!2x#5 zgYfg`qCA#~hv|Gecw#05HW||azy2fCfJYm_o*w?=$?=ya7=hNi9uu$yHudPvi?`3; z|JP41Gc0)j$!?`c8q^ ziZN1;NWTA0$O@gIMIu}KTKEqy;0VCWDu-+e>mr7PwZz% zq3J1Xe(NzX`1JG-_QNms9&pj4x%2pYdAf3*enpR=TG+qZ7R=iR&xZ0T*!=@+`swPo z^VM(Im*1e}-{9N9zGX$RzW95!y7;lY`YWtzlm7ZQ=<07@m`ZRHee?bI56ybKCMgnX z!u{dhYCs{=%fN{s`E!CzlsX)vI|Ukee4O%fgtpM;9`vA3;bQO#zr&=f6wr-xy&v(p zVm6J04naibj=iAgQmZe-6PbyXLrmJl9FOcbzI}*O>lmw&9iU8VY#WcwY}G@0cbvfa zC!q|FGI7Ewg#^&5@rTgl!UiPaadid){m@IGV)3u4to0Ch?0M~4)k2O?`-u3j!mpJ* z=0RX2%IUxFt!OX`BF4xHa+6QGIpAk8W*#=YvDIFcJ#?%

    s3DicB^i;q#Z@(ZP81#+U!62k!T24;JVX^d%^LdDEHlO}B zwgHbf??31J4tvn7l=J2N?BV~R)q25f;V6kG!tdXR9h@eJu9UvKNk>ZBpSDbkni9LX zG0CQ~F0>9flQ)ZvmnO3rpnrl%N^TU=j6)3pl%%)TmB=-h?|Ix zy_S1}?c>C5y%skq9syC3QNDYS6Cj86b8f$FX<5vuQ*s|KN`5%!ujJ#XM4q2y^KkvM{Px$JC1!O0m^qM|ZjGNsp0&?U=0U zrfq9JO72Xnq3%^C>QYDA_73V+sb(NAfaXzZqjW1yS@G{6G5DR!^y@cD~p@1McHcAdw^rq1rfWYZO{=Z6<-&~09Xw(V`%5$E`}v=kom!L}JJ zW0CWbs7#SVWlsyl#SULFi5-X~l+e!vu~sF#F0znqiH#;TlQ6jM3MTvrv= z$gz(K+ThbWh8UocRx4PmdE4+@&1Vv0;4zsuu8XL}w?)k9%1Mc_pG3{p51lA=na7V! zvjNZI@+o#+nCF-iDqAnmAb_4YKpmB>P2&t&`_pv5goVl_K99O~Bk$vMT26w;sLUgN z60Ww@$TiW4TCQAS(`Ig?v$k9%G=R!=JY!P0C?XV<~g3T8RNkqvE{nDs#+_@tg+aSf__oaGUwGrAz331FSqAj(9)UAOf zhH6FA;=P&|EWSymrz&}v=?XanftHS)$??yQ>?qWo7!B9DMt%JOP~r>bRbb<^4hoBG z7!y~#X;3N}5({sepV>+wE|0eph|8bhv-?A@MJa)nZBSYq*uFpA3|u*F!>KHm=Z)KT3=7XruZmwBeuc6P|M|7~^P6Kv zG>l7HF_YqBvuAPh6tsD$u064BUM$PAUOb(HYZ7s5epN633}41mGPHddl7E?$)P=

    V^n7lD9J)AOMHps2Zu$Jn#G8zOh$ z3R9r7a<9!%dZTs6Ic$Zj4OghbHW8;Mt6JBmGr{jejWl3_{Ir;%4#Iy#0f1Be$O%J% zZ35(+yqAvdKA|WQSP~)%ocoE+!mwTPw+N)JGEE~LTB*xN$Yl%J?4;sKixKwJAoPnn z5f&}GrCE#IZwZAh*k9S%vYw?kn6syNFQu;x+!#v5il-en;c);l9iBzv^Ftbi`wt!M zWl7emSsSV4RzL2ID?D8shxmLu-a+^`tth%B6w`86N&)h@FMeKSp11==QyV)gerA zpr;gn^hdwl8#uFyBES!LfeL!a5xh8>ADaRux2lxLj*iZbj#g6ezSW#0z|@K$U8Uv! zzUw*(lSd`lrX~i8Wb4(z7$_Bm-*a9+dT}CZSIRRurw|N;8)j{) z9*7DEmE1oPF{vNvFe>wCu`J(5p4QDO_E_+>UN=82OXW0azj)&TpxN*K6u~58&E)lI zsWGiQfI|wfdUo($*|q3m5H?yej0TRr&PgYCrfkneIS`@5c}SHaK5k6>C?pngM83)@ zGLm#@jVsAmfs>=`*Bj>@cX%ZK<}tiyRImD&3rjmN<#|27EP(+hM_X1iqgy^qksWv9 z3JHB>REW9sc8xFg*WU5ml}E1UZDdneAKA!x@$dc=z}l&AeZaej$FB#sXS!-XcfWHt zqKD-c&wYO94uzuYZ$jHNf{*Gz+ELZ?jyDw&l9(t;4XVO0989cfkI8#Ipk$fed&=c* znI`sws7ngSp039q-cT~eS27X$M&%rha0Yu$WTs_}b?8dx+U&3V3LTQvy+->puSyHk z=y4>_e7}R&JH~Y3)c##xAy!q9ml~zasl{ACoIAxnkNTC1eN@*jZs>TuM54k;iaqD| zpMRqGgRtFdo_d31fbJ{zl|B*p{w?bCXU#dL&I@&4q+#M}5_l+afKnZ@Z`IsYB|_Q* zbyWzb?=_BC9xo}D*{q5#8m4@Z$wRxZN)IkVV{}-hjxmx_US|veZbwqW><+VHUYwV{ zvorO|H$kgrad+X)h)dfbXV+Jp<5NpP1lN7JQ=R4TU*zxMPjW=#Us0q5s9*?xpjfQt z1k1uBpr`he!KaGettpqv@rQTN6}S*F<8=k2iLYa;oLWpKug|m_I*qMGz%D<+rS6V7 zDOyt)t}cCB)B9&h)ua#W(Oq-BDV{(S<~oF~{8)@Jq7~uC?Y%P0Qs{wV!#pU za7}@&xT_GQkRzU_rKQ?wuW3!77-}<85_IyIyeMZH4&&%9ER#}ps2;Lv@@8A$N{4hh zM;-2r(`qt_CS77!h1Tt#u!`|YTHCHMGKtxPeb0G1&~SEi zS3n6tKx;|3X3zVOCjwhKT!QrD*aW4Y?XGp^av!$7Zwc`$t*ls6b@A+kJ@oR!NldRB|ut zZ_Da%obo7AwG27n9wwL_V~s# z4;4?*OK|*(2`T0n6H5?O4%Cpgf4~jkWu;dvt^wbmtT1VuM8(f&_5(LcgYZ@s-w861u(H2*d#3A^i+PSnqh!>#^I6OXq}@Yh zJLgmLQ9hvb!uCkUm1!iMf>3E|YAr-MLqlr*+bY>>-inAmH>SQvZUw{dZRqaN9& zm{##}c+K@Fn<3f-*D6zmhNCtZS44G?;^S4RZtpftfzcQcfq;`jsAur+qda?(XS;~0 z`IuA%$sM_=?x&kkA1vByIeFjD^mOR}&7-@A1fSTULUPJTRF@9s=nN6TE}J?9#@0y~ zyU~#fFGNV;`wrm4vCGPESuZP()52yf8B>j zqf6Lth*?1SuwBLYyO~y~Tc5D^lFsIV4s^o^E$8$tH&49jn8|R1F2xmm=aWF_Y8A6w z&YztIeHYf_n4q($7ag1xcOGYZVb)Y{g1ff*yGBK9X5w!m*&FUma%1ZezD4mvlZuSM`w5uJ6h%=h8&UXtMA3sLN-H(C){&rC@$ws*=sjb zSA_RVB`NP=9v?doyQ1{&qE2X9Y9%OHinGZ%+51)1l%^qsKF-ju0ex<<`VG(^meaA7 z^$rt6QgXRRI#ypdELabtUm?cq3jpNy7d>~+XPeA33yi-kEk%kdhy zeXB+krePVkSVW>53XaD166eHF-Ivg$xk;ED9YWV$%=1g5uHIo=A^Bwa>2!kBkAqg; zpWAP}K-s7IVS7}OrQ?G?hURzcXF360i5buF@Al#_woxk$zS;7eX@*QqX&i2fTycFX zaJs0r9mfpEL%Y4tvo>G-_str4P+`wDaJj#m7~xD$NBe;(zuAItvuROT809&*O^l{1 zu_z)Z*cVbvl&@0lXZEapr50l2EWdHD(7C%cRnOHY?$>$%hne zBB$$>V!5LT5*_3xo8G0bw+;K*?B!&Us?nBL)M70chVH2^|kIaxFq7j?QV&=7% zmdDZTrI7&y8W-J4fn>mJtoQyu;cgmsV?;x9iokOc&A0 zv9Lt!2(G%AmyF(awY^R0#_M3h0wT24{yMs$c$;_xj#F*Nk|V;(d09W9Y{bd$wi->} zL9opi&~g%Zq{=-}rhnivps$!Y^Cy(Mh;hMfhiA2fjjLl<>{tL8F;M;Zpu3`-P0_^M z!mCsgTFn=T`t?wpAl2`^q-@6?Q{t;GZre$|LpPSTRh$06eB;8Wi|VE~7qM0lw>UZO z?@<1=HrYg0^F^Jxj*bkM2)wAQ;3L1%Cz_4UH#&P9-Bkon1Huqa#!4bipp9nZZeR!m z)Sj-Yg_9R_3zprx3UF|=1YMXDqI^MqptHoWMWinG*us;LKjI4Dzx&~f*Yj7jY00if zKd=KGx+*0D3gdLAuSrgnuVd%f_C)K{4iKY`xzvHzN4y4X01I>g*|;rD^BkFYOWT?a z%X=C6e=DckND3x3AMV6gbCnSR-U(Qk0gQ0>$Q>y>2xFGrFw(LyY0bC{IgJrc6K98b zcr2Q8=feV9wMy-&Qd(W+z)8SX=(!ar;-$t!6`D~Q7z=k`&SybPb~9A{;_6gioC>Kg z{+QJFnu_Dt?6%AZgI(&Ddw3k#NOsi^gQ_1!t4=Vq?L$uH2#aYk?rf%tx@gqDS?JaCtuz5(VR{~ZRs z_m&$AB^P{}3aZ_1*>6koh1_56I6)~g?@zOytlQ(GyO=e=yt+?G9MK#?`-m8ssG}Xl zwxTzo79p%dOYhyMc&_a1_`+ z=68s8N;q@FJ+v<~fbT@Qx$nB1IkZxK6#o7o*giz~HUQerchlsr)FtMw^ymetTth4Ks z5)GwpF@1fBo1M2?VP(n|B8;!SJB+?asvxDlgu2HBqNv=CPL5nMADc)oxUeyRE|)LM z;rTFoWFqq66%d(^A3p*u$g@Y2>XM%AkhVp?iA{y8JMlAj>d0E>=I$W0>o1cNN?r4A zv@RYhTbG zQl-GJbj_0zMCQ_&2_h=K@WM-aZ0F%k3BdOLFn|B{TWYiD>FBlH;r$NV&Z^0mGC%wF z^I)1-v`g;9XS37ld|j_8l=YO7VXvFwyhK1-(`~s8Bq%h&4kT}gqq}|nc2#@;QSPET zN44-`S=GyGbv+nne?xrL>}pvo7VyH_A@tEj+Xl4u2ks{XJ|kC}X$j2WGQMNXYTSO? zL=$@0B+(~n0`?HspHQ5#OXkftA(40Lvwu)Z=)1_~J#{f9fXOoD_LJ4UkRYhXf*EFk zf>9TbMU5EXfbrV^sz5pA@cN*!ckWTTc|ra!%|$V(ud)|!-_ZS2th|cILyXGT^BtEa z#KXVuI2VOz{aYbMfJk`@l3R0@RM+v+Z4!!M2oHzfW(@wAHP`c1q4STlMzFUjsG(A+ zkaU*n)I=fpp_FtzLZyDVepjBCA89}gRT&T9v}*aCy^Y;X&YP|aK8!`#{x;{xZrCZa z>Z489Ce_(lNj~P*YLx1FxrJx3^mt*gd0dn}^Ri=5qT#Z5fywN^hX83L*>jDr1SKLy zLj$@UcZ)@&Z_9DXIUP02cdHpl`jVX#yw{N3!w6|-|KyB`gLrlH*^QG5pf~Nf#;-Kym{7k(Zmkd0_&Y0Hyg!Bt8xU9b=ose0NPjK4L+lZb#lv|CdHhr@Js;r~?nWtqvl zb@4syaPk2aCXskaVCizAP4+faE?Oijpy90>nX*_x9wj;z%mv5+LEOj(nvTCMBiw%d zQVF4fIba+ywQYKharcLVUai`XoqhBgHm&;bUEZU|$w+!4t*4tw>sLrePeamr+Dckg zFQ2nBdbuQ1FxB5Mg4kEbF)RqfsW2Qm9@2PdoLhN>kbkx1cipJE|Gk6$wE_66l{$?( zb0%X0gXZ<73;aSdu6COc_|!~pec81KcmPL0xWDMhRbkqASa}?9QYou}z1ipW)du(| zR~zRwIxChRpfCvstbG6~GbvUD9+3wAGe<*KIZ3pke569$vJL)QuAa|6j;F!Js89f* z9eK$(3EC1#SFLM;r0q2ildj-%yOP5P$9$)L5xYvI)t=C&-tTXUR$|UYy~Ieqi6Y)s z*dG<32|$8<8Y9*>DJ!83@6TZ?G)MNgPstTc=mL?gW52Jzic=zWLek^r+0NcT6HE5Q zb*E^=0ox$8j_J!(tttnqQj{=j+jF^X)*QdA_36I@i`mUQ<@y``UYm1k4t zg)p%Aiu0yO0zQ?&1CdIu=i@)2XIIs{@c0LE!6f&~oDwzKKG*3Ci$ZXvNy|NW9;W2v z%!-bOb8y@!AB#ok;;JCI1jV?+-THo zy3nGCXw7=DfcqgEp4D}DRVd9b;%6*$lQB6|cW01xJr~YWcg^H)aWC9f*Go z$*vy9)3x~mD(oPhJ={-)tc&FwXSwqdlRL~_)oZ#X$RZ}%?c_DS<&ZaR)u0^jenz6& zye`(-jNzYY_3yG}we1GyIy+W12VVKltJ$R))J9NwvF_IIa*iD`{Ayyhg|{3$1MS5E00w?bU?rWPJ*+G@!`THC>o z6t{Rk+Z&`Q8HrfIR>U?p++}*mn|E4l%(u|zCid$KwM(oW>kGWlO>28PTeUVu z0FOl;QO`9CiqA*cW<1r`bLiKihU*iBB5@@!!MBv^nOqQAzdspn#*U@vIuf@;lpojA zdTvSjN^6$AqIjiZwwRXr#(L!|w1bk%X*GF#bobX^apPn+H{^;+DI4(Jh+e`Qc#I%& zts8ywy%}E3UZ6T}-j;S?2Y&JGAOHAWb_OT*to}%<&v|c^F@u-Q)@bf!j9%CdO}WZ0 zt0KKy(JL1?%dDEs%1H%Zp@Rs4XDLMx+3BkA_E!GTHv5#mV(3I;-%>zpw_&^z!T15s z)k8wrwtAf{G;VC67gJ(jJ^gTjMGPN=2n7e6pl$)lgF&iJ#tgK_<>)?0#a{HSZwE1# zW+Xh%RmypTorTxCQHiWl+JKmeD z7cgB&AT(7#q_+E+Q)jM!w)nP2dh*y*TX zcnM*l)isj&3CCbF^q`7Ha8}Tu96D!J0}oiXEowK&^FuB5BIhGOd=IPdhZT8(Xg}72 zkT?>Nb;zIRLTf^e2+eZ$m*TRJ>QwsM8=cp?{PEz2^*QAc|2Uh@o6(O4M@N(UCYLvs z_zA9->LV56*OItA;%Pp|AR#Xqb1YMc9|!IQ$Hb5-yrUDG83jsXZMjHdQyy@K%ntgc z)aM%4&9uZNBaBd`Kpsjw(aj1Sk5z4DYu#x)DW}ov<|LZd>V%OWkVN305>E@;#;@9U zC5<`j17}7IdMn@fWYp%;|6h_uQ<)s4Mv+*74wCmburd89 ze>|FO@qW4{Mv^OS2)qjVuq>{%sW@Hn)v{VyAY(j#(AKp2P)g+lNM<0-ru7(jN?551 z`_R^DgdndFOqLNI(8-;81w3kf`U_=9K!%qACwQ80F6QzU&772{%P}N}QTi-XwNZ55 zQYRsBhun~JJ4yRXWe{JiSBFyjF(V2owI$J}Q)Me8(>VqQQdl4-JZ+@1_r%@6;*I1% zmOY}H%~rdM9yy0tt z+a6PnV=|7#5p+;yC^4J_i*h*0%nBpnr;*m(nq$rl^y!8Sc{obGZ;{cm>lD6B`q7~a zM|Ukfyz?n3&y5bodW{u!dv3RMv%z zJeuxCtG_6kmy9~l3S1yPRNf)`@r(ma`MT4PRrGjj+`y9V4Kqy;B5j?*2^(KLKz$SFT&dS? z%hXK)!ypgNEfA*}kB!1f5=kpcA~=b$HId%jW^VD+3=odNjwc#XkYh4%tw3@R-RRvu z+Iu6`&vb@wc@IE;Wa2N;GI>xoJVe|FZ~$9DW$e3 z$Kdb|7-r_U5$M4{u!alJO@vc1<2hSSC!aGOYoPQQqk&bl+E}?4xP$}x=gy9~T9KH~ zFp&ZN*WI0yqTx&e4q%zB7_Lq(dW78^=s!$>9pFIxZHg;SsWvcwi6WcsIFjagYUTO^ z`NLEQb08;kA6LyQ@(LeuZ{nw^bn52S9rzziMY6^J_wu5FITfsPGOHFZJNjau`VVc1^{9aQ2Dg_N4bE+)RTAk&A6u6 z+(-&psNF70h5#%&#MB)wvu1U&1ts88Q!G*XGG8q~=R=E-XH~!KgZLl38pjL(x&gm> zY%^2D-a`Gi95o;bQ7ruIloKfHAw!&+?7Y;Ss^(yVue;8nNNw%FX`@K(pK7qiR<)T5AFu)B<=VRQq-WSXsm*TT2<6TRjLUF3dD$qYMCgHF> zvB3U1{ywo&sG!;WJgnXj3zY6A-H&1_BcCHN1eRmWl;Jau%fvaZtkt6ZAHqvO%&oho{m!lev~&o6|&^J%yF8ipFRcCMyK1x0|M->b!rB9Ms&Jb>VQpj2E3N)67e*gF2_YR zp*wh1FV(%9)CJJ4p^!dyYI)MdX)mG_(Pg9`L)WBKEgNaX_cJ+CtCI< zVZdR;z<|CH3!|19V&$+>+I;2~mbb6orYm>_lcUQvv_YtGhAF_R2CWagx1}9Fm>N7@ zMEmL|M0$&Pd)lfxq%!xKz77fp{DA%um|;L+jK8mn320j=J&Q&CIf#kal^?^BSs(bb zAZ8EHCxC`9k0S%Yu!GqPlevuSf>gPpk88$jmgwwcU z#YzS4_$TEO3}5Q;7-oQ-7L)Tr;dUY!NW!Ivi+`|!I@zw1TqJ{qV`_ptKOz1|}zR}HM0&v^Fp z?0x;NB(M_J-rYO4T2ldQ{IXb{asLO8xBh3b^^fB_M+EyW_S6qPtKl7V4u0<_n4Kf| zad`XS_ru%J#cle1IJ$>_1Wk{6dIajAs#9}P7mLxe_nejo9OTIMg18VEC4Y8BU(Ilk z?f#n;rWGfH?62l$3FgX!Y{zC?V=2)Co9}ToS3kcoKPTmQsXkbcm}*viu~0|#`D~DV zb>Ds{L9j5$4!+5=uf9HFF;Ze`k!hi{N=^&xfB)^9Z|)DWpP%jQAngLierOr;_E|H0 zi|>v4qnJ~?0g8|z7v-R%ib3B)wK_-c8g*V5CmnyCI?v!=`x%Du*PWeR9){|@$=>e6 z3Z4`T8Uy|chrr8x(8*v3x``MB&G7!$610ZWn26zTA1@a5`CAZLgQ*%i=fW3Gjv{vO zp!3@ty21wP&m(U`4>}-XG&S(Yk-x_WomcROsYSnzyp2ETJXQaiO8Dcbea)Vh6I!mP zcv8akGAF3>eKCB8s|OuWb^fd49;`3E`sV9z2Exl8WoKGV3$$Oa9 zM25hkHF&`%)vy9%EJjbjE=zG71jvXa?5f$!pW(?aaJI;M2;u0DU@{0)qz#%Rls3Ba z!`szZh~9^eje!{89@tHAKor(p;7UB9=i#H3{DLsLLteIh_yrQ_;uI~-y1hMn-g)tC zW&ZG#BH}o8n{qN9m`QcD7q5DBFhmu+JN$)H7E%l+0qBpkl8*8sB%Djai_q}Y)i`kF4bX@Iu=6$8(Pi6zK%R+od2kV4eHm<=#hL9PCE zqKpt9rF%f52w^CLY9k^;Q&kL$fx*vqV3st@h$R=h7V}lGGvkR-fVQ0=5bxiX%@%2s zwn~ND7D2>Wr!_|IalYt?aS;;9pWHo~o%B#T-hnHg3p-OW4PA6q9@blS>h>_+HF`l^ zr~6A+%jE3fN86KIDx45^FuB5|gfF}eb%P*75TZgpi}yffIqIf5!|@-8xp}aI!5sDE zXj-%OxWjP!-D?emW{xGVw69DFKZ_nah79g~yzIo8OiWwauNq2Us=>wKDcV&;6`-p9 zX)zbxDRw-%QDhG4P3raksH<7GlXqw>qf1Hp#OLZQtw%t6LsUIMh?6n99*5`eNNs=M zfjzTvN*-!H;tI`yM;I1tNVjGPHVc(uExgb@a^w1`NG9Z_E$05|Q*=IQUdtI(8Y!5) zHHU@XgPypS(Uo|F=@GcGe=69NVBn6z++iRBNew|hdQ-uCx7;LD6A;GkboTrbb<&=@ z6i%cP>ZpPci0DNysp~mzHUBUeshWfCMIftNV!#KY$`PQfBybl6#vvQ>*WMLT5iSPNlC2#P&iwRg zqa>&4s0eFLgDVw{C$oklP|dP+SPWe$=w5|=1@a>t7fFC4aEA6UsHLLlU8MVN)yF&s zU2wBnl!6gNR~5|&Vyra9^MGLtbA*r<2AzLlnsjs``daUxwhvj>Y`6V)DO33d_~6%L zU^rL(Vm_Z-bSajNVzE{jr?JN*zJxc3zA&*9Bzo?)bluy$Z@+*0(4=m|2JcU*>7eCt z+~hqRqFgsl178NDOhD6l$2atu6rz%;Ilek_CY{H|BrzZlF-MBlII@;yvL1u$*cgM%j@1|hL>L5dH6;FEqYG4HYRRN_#On8r1P7%S znt2AbMjx{UzZiEZrstPm`hH=O2SMBbh*qs1Egs%EMu}g3Npz$y{YV(kSODG&K9 zG0|}+ex709dA4)krQoPqicsch@^UDi+L;M7jFY>1{T^n{)4u1`;c%E*GV0c`7xVaC z*BwaSw!~fx23Q%*)Lo?!?n|nn9nKYp@+-NkdMykK=GwV(`nu4{bz|RhFlS9YYTyrg zXBVS0tG=`(R%16CgjdJqv~jo+3}YYS;QqpL!NwE+;lpAN*70fA#Y4VCATY$;Ga-@X z5`iW!vPe9brx5ZxGLGn3KR$^KsUyZ@{bf7Jq51_*C^P2+#d3Va;VeLugvz4Mrp+O| z8``Xy_MKdwB}?{PO1t8xQJZB*3oYCL(D@GkYlWDTx_CEGC!(Ia=Cg27*pd$}^Y-1l z+24j>Q=Z-3&ICaz*4=!RZM&hNC2BFws-|BXV`%bNJnM7cN zrM8a8;5?Jn@ZEDX57tk&vCq^-)tp-%n&89J3t@sM=Z^|8&o+mtrVqz73Qca6&L2+y ze7wxP-Rv1lRne{&u!pY6=w_y*Wp=Z9H@H^y3EF7PmAtiYp{XOgZ@mmgsH_M(+`w`igU!deWB+UxQ>e#~7< z-4EFpJ3C)}^B~V&*%VISQs9U0GPOF5wzFbCcrs#w%&MYOmMW-Wxxw$%hafmbNQQTS z-sptnv>Lj0SHTJ6)Ov0d{Lb-Eq0dqEUZJ0k|Au=A7Y07S9I?x@F6>M1V?Y591s&>m zCwUt^pwamI?;}8O_pJAgo=xCI9kob+?|6jx4+`C(qw_2h7BCQ3-x^ox)N}adrFN@~ zze>hJT8y+M^`y@C%3Z+U>pS2)w3~rv1DIR%=X&52T4^)bXm^uQQr`8DG5h;wfWzc@ zGXEdvnt?BLl+->Zdws%2XY%BL(LVXMcQzbHEct@iaaFp0ZoUI$^L&NCMj2|rd#XeRu{QyAVx79pIUMtpH=eKC`EJi{k zBlq8es_AYNeIE;w(}_jyHYWcjbCj3V;t?5H4C2@$red=}N7JZMXwCkdKJt zkl%X937{8=`sKsz`MKYH5Z0hqgVA4nPyw?M6I&9Un^{^r?R7!cvUJpJ{g#MPVx9a} z2h|a0ejl|VBkhzcg_)@^f$?J(%3Uz}`LA9WdPisswO$s@u&~wU)v~~frnOrgNAMbL zXa&s;(x-GLC=#dOgA=JJrvHxp9+LuX1JI0a6R@W8hQRHTYy#cZPH5_#^@B(j5R_@D zkqB<%;cdizTj-j2cpFl0i(PK|`_Eqg_VW12i(mI&D_+)*JRZVXlm)U~YXH7__V~%` zpWi&QkR6Gf8Ec$CFvW4n8x%hW9Q>*rM<+We(9q}y;{b76r;RCNXPq*8LFp!kVWgnQtH<7%b*xW zZJ2jbqSV>s@tj=fkh}F5gQh7`MF2zt& zs^0TitbouqRSk=^7d5>J_&w4CwzHH`zEAU*_JGMT__OgDTlGFqJyV=;Xzcm3mF-AL zqIAh>k>cs&3PM`4v6M&C2QDkvHY`HE-|}^)f#HvV`dG+Nu!oMj9C{%;62_+ zST*S4gcUz4k4;=%RndO~Z7`9tc(D9G>I2c9uOov zX6!fdLOHp;z;;%>=ETa+q!Q4UuNsi2nk&H91SZ51wNCPqwZ z2z!Zf3z){_y4hqVQlBoLm`-&~5@Wn#FY8N8c3p%MbIE5+`O) z4)yU+JQ4>*Eye3{0bxy^eVB{7Zr*blPtWPoa;0F$pITo(c7^Rp(?Pfaau4`?Hp>690KVkN#$7jnj;=F) zntr`F-9BBZw|5&;heGJ5FVGsM1}j5Fb5^r)oe1{}f#yucuDjW?nmde<)Wl2K{N_)N zlS;%~3qs)&Bul&9a9w*b0|{ewBmt`JF^%ov_rL5S(2o(I0Y%@XI}9VV2%#r1f(N2= z+3O_UMNg{hq5>BFc0P6_UnkVF7-^>;FH<*3M_fT?tx2b$xP;oes45{?!MG;lC`yfP z;y^jfm4e!^5Zb_x;XjUq);P!$Cvoo~0l5dUZuVSjD33P?FQ$fYcw3bXoQuhHS01Ii zFb(|J1HTAZcMD#Xx!~1@G`UNXR9Q|5Ex)fxU2ky=JmXcARw^AGU)P}l^HuNE6ssjEo-d5ZBoo)29f*1PId7(LZ znvP*&3^hS;8&-4DHW-t24AqHQH0FwYEl2$D0A13+v!oNWVek+6K9uTmWM@PVYJYJw z^4rF^vD+d9D5Y;fDu(dbNS)LLB?0Msd#Tebrcn7q-!2or((<~rfB4SD5U|r-T23Su z8wMd4n8&S+OXFh}6-XtU=t8})Z5+SXo7tyEV`HA88F^o`My9sx{*CoG|<>^cGl zHU&dkABjoT;<|p2 zKG8=k+!p)l83l)()&UsmV*aeXh_g*EnurpRc{Nc;4|+48=%P)FSv6mw&IqEx_9M+{ zwHsm%RYw&BJ5v{xBD)sZg6A=;SD4wcSS$lD?tE|EIxUU;c`lgpHQrAGN@S+a4ksd* zvGevvSV51R)eCDbI%hQ4?Hy3PWc4o^eQIfLMI+N&)na}qD~00Ishk)gJ@5Ym=w-G1k$w2Z4_}mxxLC!j7y_Id*4$4w9Y=t{*|qsHrYDc;+}NeEdw< z+*yueI=p^IopmDk)SK?&uA-qVjxyNZwS;8Egn9A&FkA%)Akf4XEHv;-FD=vR{Opo9 zk`Kh^ndM6bX3bIs98#1u$dI@6V}?;}2dsZyEM+u)XW?P;ka}4UE*4PI(oE8P+O=_Z zEWmnkPcxSY8hm6!U*Wy)6HHb|N_FW-`4+x1nt|UgVfLHwX${;^qGOY$$1y)v&*y&w zPdT61ZzPTHM1wlH$VL=|#^E-Qni_IeG4)X~F-wT%3xYyY>`x~3c|#{9#v)LtC1R@_ zz{{GVWUI$>2=pN4ooy)f3)?lz;jPekumOvPAq2Mq3j;i_V8u{WlP&Nes@dw018F<% zkDMBk)BBQvVrkwbWF{6^Vxwe;SzMUkQH za1nZam{50}zdTy?PcS?tHj6vGYgsB(5saly^Q|ximZ<6IKWT(!`fyCpP!K`%kRfU? z^fr*{5SofcA+`wA;=?nPG%DJjmoG5=OQlgo@5;YC_zE(DIA)@FWSr9irlgz;+N$e{ z38%`Cv9T}&>%3NjhM?0NxSf~`+X0%ss1-w<^vQ~QG-fc~L9Qk|4jqxYpS`YGqz!Zu zhN3qbuOeH`s=u$u*%Vx56k8)tp&M-<^#74lZ)LAtwweeRwJg|%8=mgjC_SB zz62%jzW(&Oeg~Aji)cLSklhw@lnCyMQpZ=YNfCxHyXus-bxg;3vur$Ku?_S#Qx`|w zZ!R3Zg$hK7izSdSB!wH1$G)pwi;<0F$9uZ%vmIJ-3DMi&c-1{{M0H}sI>?U+Ddle) z64V$c09F&yT4oOG5gca>1+DkMwnpYRmjMBqGjA+CorEv67qgjipqV1$J(3tctHuAz zgKu_R1{;~#g=U()K&_Q`gcu5rExVgNc+ks!$L7Pc0=?27FS}b?Razv04Zr*DJN97k zjIM*{&=F>8mzuUH>FZo>HqOItb4(lZA1Q`ljJ+%8W_M3I{e_~ z?mWP`5l-$LZDircdBr8njg0^(j;8UN;nmzn z2Dj^I4P3kN8Hyky+HBKcb8U6h6D>5MF`MRYP)b(Ob&WyBF-xbE*V;<4O=HDRjgXli zn4ihOCL6(Obs!BbZ}%L1>HBigVBC!l7m7eaQb~s6EtOw2~4zpj)}w!n34%wlKS{JmHQwJ@kFM& zsiL)ZL}ASoxrRRA5nT+#kh;T?XdPX^RA+dbKqdZSFW` zmG3iv`w*NX+K?;k3^?dx9D3Jq>pNQ%eqdCVb5+`4ATj8w$B=dhid)27V)4!dUTZxG z-WhN)8EK2|@3q;UgsDUV{SM(XiOs5`nCr8U-NxJuXNr$qmFra>jWb`QSwp7KH|9>5 z@&_j0u9Qli+(_3$wit#}+>27au)e#I?9e`Yc^Rf`4~#=Mn&eex zHEQjrp|P0=g+S$Ae!GpFEnY)H*+{!!O|T;5hY7dg@b>Y0=^71*q-^>cH~a|}TAdwd zgF){*#40@#Ij)$f(?7aEmHZqXWwPU@>%}@Te#ZOra#$6UU(0jQN;JOKjK&0`@3rvg zVkw8glH19a-K2Jon^9NoJ+*R~a5&i|nJHiV1=PJIdT)3367*)AIfz&QsM#z%RtjC7 zOZtbu^cnsNNEb<9u{LT(v?jPj-;)LY^_UOvH}_kY}SqG z{E@psqd?N{u($XqP|Smd+d7j2Xw-uD@{qg*y*196)zyjc>|7_JD!3#R>z;TDL?~7j ztz$ef1li1ZB8aY8K`6w8MYj@3!;I!XC!s<@qZzRkvMq(VIo6BAprOP;co4uh6Wua# zP#xdj3?c2cyfdK5?sXhjPNV<8+f_B08%1Rap)$dKqp>z#prt!o&9d>NJ_o%D;IS!W z#~XrWwZc6*+KY!(^y4XelyO?xc*oC*V`1^u&~eFf#t|55c}DnG3|7&O`RGpj_PaJ= z1D3aBYlxP|Xj1HA4MB>b{~l6RpB{yByt^opPrNkH(hv47>>1|k6Ex6#yd#fIXOYcu z;u~HsHG}N%Fxjb}nqh;Ey`&6wqk@bKShR6EhL;grZ+ou86bx8Dm46}L^;MHEh>qf1 z>B6F-EC}hpXNDyWeb|=86(HXf{a@e9AB$Ih@UR28*xh7S#9G>N97@K1dklf2O-Dy^8Hu>^wQJ?3iSIIA` zax%&(F%%e<)r)1W*mU@ZHY0CTKME{UU;#)93EAXha50%&Z-B3UXrz z+;LT7&3sZVQOXg~nBm%dq7@QSZeFwAp3MrS_ICxIqhib4poOUDR}Y(xtGqqMsNiJj zp?3>GywDKVZdHeuj!y)b19ZfM#3UeT9_Ge_e|kswtCyHqw62{j5a08RNbm+T^w?8t zvh6_~QZZ1vy-xSh;NW)ze}vukdv`mZ4sYXUM1A)A;q6av@%vl%^WmMt!;k9MWu)+J zw8`7;(>)<$8Y0PgqPRqi6(YusmnV}}_Xc}V!)K5xs3C(ev;=iI)FKF3gEB(oYi*mg zftCax9Omv@>Bu=TQZf@YXA()Kwm|L(gRU@S z>HOIS+$;>u7^Mv4E85bV*&LmgGuKY858b!fJilyBN_&#iPh_o?vb1d_~O_-JlnItt?I) zNOb#_jcK=ho=Uxab96pe^$nruJc)TAt6}2sIZ#n#ih@A;Q~1#J>4G4Ufo=Qcm$orj zqdZ?!0#1s9QrazC=NkVS|YRaJ- z=;5LO8`pqhVhR{Y`pahk+r0v?$a)H})rjOf7xOi%3&)wL*$msT>Hx2ee^3=u5+WZU zmw&J}D{!@h={*fYVdG;b?pc6;keSK4F{*{HN2Tc8Ni`C{X>#fmdzjvI8Xob%#%Fw8 zdixEJzMW36c;3Q=COjYJu?Regm5QJ=1t4%INF&FHI|CrX2s;}}fn>+&9ZVoNZoDC8 zy8?DQgqE+0^UvS^G^{fg4)HYiC;46#L%RUeI&~HY#kDfY#$yj z9;u0Ldx3_*Kh!b1uxdMzP$NbiV>c~SF@e7KkSZ!7Seu32^VIef>3=;C9UEgN4+?oq&NN-HoePqec!k{Tmv{? zRSSa(QF7Fz(E4EkVB2IG^J0|oE~>flzHW)3^@9Bmrh)Y+D5%}b?2(+`7Irki3R~1& z5~kP{^$S-O&Wp1V3R+Ko{2e~(f%G;^J?gM*>PWS&s=nPky)^;?u`b|=p`O{Z{wlG|;lz%Om;EON`m zboEUe^Csx{C^)AlJkak83Z)#(g_Ada)U+Yz<)dN=*}{n2_4ZQ%N3|0Ntd_0SGu zsac~ubwC(*c-?n88)O}6;iV1o?=Ne9`+LmjZLelcF)p`CMM{5CgWhhF8*^|0Na<2e zo9v=qp(<2F_)&{IDkcz7;A9061?qA3W>xn8AkEJ#>%_Sjt7x3PuNL)eYJ7vAkb`Wt z4*?~?dG%#IsfHKi>8ZKYCKI#hukGZu8mSW+K^N)X#c=vC6m*VX z3x82giVr4)J&(60jj7~b|UeHA-_ zKh%GQh^@C5Un{IncIt%Ox0lttxhWh&EDMdUPw+to?R`oo1=le2X4I?Ye6`$1hV7Nd zu7}i>+lk_go~dOPwut2#Vv;#_RPSc?yz8|cXueu->dol};t%2chwcde7p?EvGEL? zzzFdKsZW6o;)m#ANLBOHbp##(sTV*Av#gr-e%6y{y1G!A#cwYu*aed!k zZXh4nG6_TCoPi12jHA&kO3IgavN|PNL(n0LoGB;cevsv?S#rG6A*Fg%Bs$VF1X*`e?~%IeVzt|EI%CZr3VeyxVKos~JX*)#&ot^1owi{&?<^e` z8wf|#4Atp8F8YRVqn|_HRWM|g10PETLeS>Ec-jveMPFOquhyvwlpn|Em+PVw2trIv zc_EWPUnaS1=13P$;8(rqLcp9S0Y@5enoe76^dg$X+viOqbX(k47i}6}7|zsXgJplw z#EfMEA?k8`=#r((;yTX&D+O|BnmC1B2+aS8U=Ossf0*s-a430KVzV+g)P_44U8K=-JFUvk&uV0W?4@;Y<{zjAm(Z<%PG;Et`4Df1co!8 zU1v1EkLypy#;;vBA6s+NDT#C#M!cBB<+3)Igu+S8vq>AP2fP+PZ_*+%*ds=`fqXV1eG$}wdC86bTmp?} z;=V3nOVVUviEilGhRI_ivyjV2lVp|7>S!^>W1X3Lm zw(jr0(s5%XR2{$KCt$qJ%j^$`flGcciV4%vPz?uW<=MIjf>{%bhsV^JlVNy$0@u(L zv9lbbN^K}%oN0LO0|BHX6VdT#V0lUNMr9D8H)s+&aH{42{*${W6XWzE zSS<$dV;9SKyi_p}d6!R^8V1|R92dbJID~s1IpCUA^S|%$!6knG{H#QDK3pv@23WYkM_0T==>#rXSvY(%sMVhf6U}~9IIZY2IuW+O0J?kuupOaWE z?N$gzIkWG1LmmZd$~Ryj!s5Z`zW!$S8+E+S7ML-aN61lFQAc$E%XQS&@elRlrv;|I zHvQ`*3x|OkcU^1-!w0t-y{<(P5#*{zLJU!j{DgrJW#;dza&ZA=dqLO`9RNjdm$@lC zohjR1flf|6gv%Njm;N36jFn;q4vPe?(`Of>1)^;y2PwLA!vJV}GTG8PaTLYJLDtC} z_mg^bL4g$9@A?lNfXc-_*G+3nO6Bh1?WYtxmL~p&Lg9W3IrP2*ZQZvps_(KbE???k zNH+I2IEyN-r0>gTv|#tFYT_8z>c%Pd9RGGh*ERLzz13ZAtF-}-RCRpcmkS(@Cm?ge z-0Fvd>O>5Qm-Z;?x=B^sGM&9f*p^#}Y4h?JRP9l5zqf&tmKe6YP9u7d zw_27cdh`q?;KPImajXs+WOu_L4iIQk8kPFH)T2=Cy_+WDjfI)nAMjtGcw^DIi7hcr zT%@$Vzt59Ot+8TI3*OP@!)CCwoP&-~PPZ-SW!wxZyyxrXsv@s>+`Qy(%VtXvtcow$ zLRKQMCy}YBmM_%fic9Ta;i!{Z%OTzLc3kOJsFORcPW$t60g(d0tscHki^aRdjzLkk z!-U!QLGq$woPtE(qOi`i_TK zku^4nkiyyIAs#m#%FS3aZNiVO`ltmS>1gBqA=t|OY8Ztm&1f5kPpGy31j=3Sa}4(( z)4?*2kJ+>FSiL12T^cH@br|I=r+o#faDnz!i?1VsWE6(*adR;nKCzLc=&SPqGEGY8 zYL}i6`}{KpQjy=d(iwzV0b#BBx8YF6Rr88+R+Rkr2o&k`H-u$r_Rmm^l;bseRlpx0 zZGK8aZXku*hvn-EGDp_4#{j9oS=O`fF&FZ4vSHUhf16Fc4;Vflem|vw=;kOJd{WHS z_Rt4}M1K;>dA%rx@7xa+#7Ut~IO(TVGp`#2zh5pC0sm5A?-HW0s4qMgs!roje=2nI zz5*36hL~2X(BwL=M~Q#&3MoK$c3}4~sc{22M;lrzyQ203H!>eolVy#|ss7<#*wvEe zfZtX#guQA?3?YGkJ!zWfD4o{7-V|J7G6>=?&T{}^tI=2d97EdBKXfqp$IH4|Iv@7c z>7x%I1)AN?Z*Skdh1f&k#Shv02mP=6yZ9RdeeT}h-N~N4FJ{?))+_w_Hwcb2Q}_D$ z&#wueSZo6MDleW_9~9o{z9BRD8HeMbfvRiu>uP#ZE}*#2A9Wa*eg`y;B$MKB9Ng+V z_MXT43N5G5NB1Kq zjntuZ5+UvMKV*G}8_Ad(N=sPZ>Y)Krhyj&j~@zo(wCfYwqcfIBxllS*fO$F2d^5nBXac zuXkbcyvS#D{Z3;m4Bx5PZgs29Oq{63)`NIbkhL9QY!ghgU}nd=X31Iw0VYTA5~&p& z0Py&MBp54*ZQx+`*v#mvoyx>z>ydTjT08Z+&e}Rfdig{|5-#QhQo>Atvwq!aA853; z?uIwX_)1cGXFI*~YBs9RiAocB17L}F1QZ2*76N_@)^8K=| zCqJo;hK_Lr{o~^|zdbvC`s~f?7cYLQ1FX1Q6z|K)*0SEh zc!{cwz3(*PeI4bIdRQXozA4#nZT2G)o8v zF=bDOqG_-IBK%;@lMD5*gRhqj;c29Ps+^uXbcoJAK8DEZmxzm;@0vKg%*OOxD|GH& z`mf^{qOo=Xf;s}c3|t#g+_(aDU3Uzxpf{(d5aS(n$xXRy>&B1q<>^re$St0)Y6X>_Apykv?-~jEMC7(|1 zuLUM$^hj-!LX&%eEQTk4U~af6+y?MQqExgD6iNXi23!5~$vg<^GvYs5(2hCl440;B zUdCUw@R`uFb9K2ZBqKRvyN?&B#v6=SM~8SkPYzf&HeS*masIWCC zWV*%|H_ynx-#qT71g4L%I??qHIm>SM@HUdTN8~0AO?!sgkBz#X?; zWB;zGRfgJHS)dILYkJxBD!?cn^nSryH2-| zXQ$sJN^}YjuE|e%s_^@?T-c7x4A3Bv|K8JBM}0wZM;4-pva}dGF$lHRSkZLVFd(f_ zv#^~5sPLIC>4MT*|G>mqh~zGf*4glIkB1=EBm`TFD4T z*uHPu_K6A)P9LAWTerLg6ixLQxxliT#fSuE60Z3MC?x0AlgG#$28|4-dXo~pEXt{3 zv4f7}XMt$hQZof;tO>AO?f~U) z8f0S4`Kb&x)%o5vPpy20yY9B)gS@w{qaSfpk)F7~c76^JQ| z42}!h2j?HC*1>V*D-7;AACk!MOi}v)!{gaHL{mL7NPhN6fbo*zswr-$oB5;9W6yv! zsiW#o>dB-G);=hM3-PM1mkugGdzDj=`>F@AMw1$P{Xvq}r{_4bWLo{8=?|}{JHI&MbC`FXOk;4iydC^)khl}Z-fo(5#0b& zXUGHzZ<~)hEPso+s`V;e=dh#Jys6cekUy}+toC!T0-tOeg z)>RFK7Zt$3%1*b2yu`Y!Cshp^BZ{+Ur`h*WL{OJkOYjnU!Pag$XuI{`8~*MNy2EJkVqeMRhbw`9}JV9O*T;o-0%iH;ExCSqXx zW_2APZu>YIG7VyA$Z-ct*W@GTjK{fuqULq4T+6jfTs?)jvjSh2_|1cC+GlvhCN+9% z=H3m&;3CsvwkjrE32rH6dhN(+y*+8B-_UtJd3xJS8D9CFZNu(j-NuYIu9YYFM z%3TyzV$rHAD_wzPVm3lADF;%oWe%AUHj|w3@HWFx=O#K&niH5KH+q`PV-CFK$1V;3 z6fG^Z1DssF0C#z~B_JCk5^yofbuxUs=LVJzc;#t;wZ9lZwc!gyFIpPaM((hz-8&5w zL0+H*g4&f{UZUGR7t=`+S7utgD`^2$wdWLinO6#>cEpHsmo7+sE_%TQ6Uqx$9va0=F-tyPD+x(>jqQ^S;HtCxj=S({Dny~?wN4qQPTQ5L0Ch#n6oak zvSt3Fyb2lf#{pe&)-U0)6=7ryrXI?(3RrO_fXFT`d%P2z^G+1(Z&00 zn_(86K6ti2aTe)H)<9|qk5}q>;r^j9DHwrV8$p1Fv(}s!joR1XuuqMW<&U(BcweEXxA{xAc9Xn+b_%Pi+_8tW2ix} znY8#XZh`_8sHAVL%rZUCt|;2`h|TNKKOk>`CwB@eVlaC`J1(^%D2VB?6`J+LEsT8; zSu>F*lLW}q(<(D>ewgM7jHMRk-&fTFog{VDc|ExpSFoELUy;52B7K}yjZD0U#|%Kz z;BYc0CC*1}2R;*+(_WDwI%kRjDj4E9+S)YIxQM>&(djhh@^sop2bK?_$escaePB4c zRDv-rtPh}L&V}C26Honf3`Y0W5_iV7)P+_Qo>F(odi&bOWg+H56{PsP9TaD+{?Q1w z+pF6^6IT9U*_^Ipd*`$;lCbB+d~GjHdS+-gS}xu^=OL&=-*viEkH#;xI!8RCCvDMi z^_C%Wq@6(&G^*54A^IvL(Jd!qdq~*iPNP5yur~HTnfBo5Fz)N0mg%OhsFZ%#DTv0_ z;~c!kp6UWlnKCaffV%csINhFXA{)ABZVS9cwnsA@x4$R!+3n5obDz2445r!;GuCPD zNQW=weZhOA&WY5L^4;QFXm7mMpE`#N#aO;Z7L7KAq`EJk0d?_eYuqupFcJeYMN$WF zOK^Ou75Qc2L8mJGuxpJF`$ESq72;40#g*lHR^UcC-0~IV~n75=MKLvYr!@i*!Q0; zharc2c*4PaDq<(v1MI1Y>`66*i%3O$dTCJNL8l4e5fieq5HazW?lIw(V}o3deY6y# zS^2C|EC}KUx0>a}q-3}*N?*+srA_a~K2&PybWik&DfSSv!=HOnh>p#;kbmvP48@_` znu!~gkyT87#BK&Ih8>t5F3n3*&LA@RL!T@-fQCor7Tm&WHzeIHJ(H)^?A@$BpV{Hl z&<$(VYZJ_xXJ1i-^d5C1hEO>C5Yy16{>(YpvM!4q#F+U@S3isqo-|68P&Jmn_V5)W zZyRHDI$xCUF$9I~oxPKpKN)8hS_VE?XN!7PuNs9z;RVG2=(+-T79vtrLts($OW0Yn z7K72WoeJzN%X~KUyZ-V^HgV+RDeV56O0mCqYlOLCMA&G~Lh1|a-$_|& zlbuoD5j1vwYf3h)21{jwA`0+>(Lq>MuUi`Dv+QvV%85~5=9`ZJu8C|kysM#`&qFf0 zuVVOlD1=#*{|W@cL%$08z{`uN8H71cz&+^!{8R5U+-SD3PhaRhar1D0ZL9TofSVa# zhZr&dHLpxDabtQty=}OSa1mJ|!P_UWD5mk-i*JAF3*hZ#;S@WB^o{&&M?3ehaH0>4 z2-R_80ozx=7@PaAfLfuR_6|Z22ltQU8zCq%;6b@Z(FaF%0nbgi&w^Ki!K1~oTU+X% z?RgdI==7=G^e7c$RYRVnjZYJ{TyvPnS1dSCH>tS_4i=7U?YU|>TaJRs{K1>or8vkl z4v8Q_CIOIt!iHf#*V-_eW^BVa8`6L6zR@3l!oI;>G{XwO1dTyunYkE!OHk!hSo7hdpDqxasAQIb_Z27G&}50YdFvy z2c-Xi0cY&V7N|=+)gpv^p=?&hEDA+@!VLH1g2SA;ON+^)1TE~!8KsF^V0Rc3Sy~sC zJYzE-2cou262X@tc`k&*5Dvo>`mS8EFbM3u$kv8$M8DrpNF8ne=~HKI$HH?Llu1LY zb|m!wd{7gmGDYE)mdx|dM5vb8oOk#Tf}P9+D-8Yc{I8hKnR&~r_Vd}@ox zIwHB;XAd)dtM4XAFD${g!qOxnlH-5`nkIgPfYp_6&Z_Ye0O*ndm7o)|a64)9H`Up@ z{V@rH`AR)k>ZV(E0P8|b9fbv|Jll!d)d{*lADc`o5!F#-a2z6Iy^@?OZlVO|svB#; zHRvlTwWZ#Y!&4aYNh>O?N-?4@DBiic<8H>h!|TS10NK=;z(8qjjgVe)}};38?Uma#e?3Fw?%0lAlxa_*)#^ zda0r(Rj3)8V{qrTlF|XV%+mG`EQy=a!c)}FqOsqW{P-Lq zDvE<7h%h|m4xeZ-l(|E!zk$njT2k&}vhtuOc$6_W--uR_RIy$RHCLhz9VYo*71|@z zHG}V)7mx8uD=CeyH{MU5vj(hXC3Bu~16EuIL5vF=2osB4OXMI~?n62(-8()>{3Zm_i!Ld{`IlaxDWbAg+9UWKYWMnP6 zMGxARTcMLi$9Ei+GZ4-cdc%!vYXdD{`yeFICidaIwazo<55N-*%3=h2Z3n9V?u&3{ z(r;1UV|p%)V=<=H_yD)w5MWQ}lg1vxLs{N!Ztr=~N8`gu(#b(3qt~SKmN!dPHvY{l z*3q#20bz3)P7dehz5VVulcD4MF|szEipiyxJgEnX(PHc@?MI{A=?|Yi@fUAuJRHZi zlG|)D8zNQ3Y_v4~GgqA9Ce~YbvVMHzqb1^p!EbkTQKra8N{**417Rj7iv;L{lT4$l z{!v=X-<;(Dx#2+yUoS)PNPHol)FhmN9g8uE zs}pnFlmiYQI2k#yO{OQ<8;3^W)x*RBRzk-@6A0k`vTo$9lMJfs#p~=w%#YXeoCSvJ zT{UL{Kt~r~5dph1PRVx&{7h#4vC!Hk%RK4v_9)V&Sfao|m?SD6mJ9VRII=9fkrH=d zA=7W7JJZ*m1M)HY{9`JKWld3idFL=OL0?pTiuVJYMYv~n6}iy2P1HRvvk|3V)1g&a zfKobrXy-u)xna7B3kv1F=XR30M1Je!g$#o&ScT9q6dQ(On4ZhIt~<2ELz^K-)OH&J z3MKR|zmv7{1(uN1#=P-I1fH^Pq6qx(X!c}ONs1#QJ0^L!9?nn9%XEE1X&#v4CWd3Q zI7b*eU&d4uk{i0_v>n1sPTDQlXv#E@H|6;gOcrf!a{CDds(3?E`8P()}^F*7Fu zz0<2irCN|~-(7qSej9pURK%H0%G$z7`sT%I-Lbf+9VciCJd*Eb&F!sBlQFz{CpUN3X&J9$5h%;uTnTnf^{NXKs zAb;lGvn2|T#hN^T9ST3$i2qAUMkAc|ApaM7x*Fbr@meFS*e*?e1c+EpZ)uKh5kaB^ zCt9KUZojnQI)L(aM1%mNRk4AtL$?sc0EYm;JQ7 zso(>bf>JY|FK@~MmY@r>rW|D26#t~r7Dffi4p04?tCFd{4_kb&z$j|d#l+)x`fj0nfAK;?N2 zK{h&@M4dx9JtR6e+LRkt{vL&s%XY$H1KpE&ynLT$1ym{eD-FulpJn33h0#q~H$GOlJM z0&KiStuR{bAkQx96}DF>2vp-sw27d&^?s`gV#W6(!_z4_P!UzkwJMA9I#>TFt@be* zSe0faNJk=Bn8UoPtfp$-fRotsV%}xIfukgyK7Ho&hzIc3yyTTBF%Tk4I?4(Yt7~&W zHVx!W5O!Q<#-jHKf6J-r4Y5km1HpOF)mOYnxiWlLe;M|1!C|T7+m0jGXxtO*IpG`b z_{LBkd+*hgfwuLn_azDzhKY)6BEfxsVfS9Z%^_MHt$N21s<MxhVhndJnanbz>tHousR{Kp4RX_{%~}p#5xc#m0lpP^4H}XEiP2oOL^#~0 zP}J6$zUfULavNeXi_Z<6g@I{m^^dyp*Z|R^6`vTNm8?+@d!;u0B1d2ldJ$b%A?H*v zTb^lztJ)||j8+owtnhnr@*G7m>vLgVxhZz_BctCWg0-;MSv!b-BC54Q zptu?Z3`QrIMa3BQxdPD)PBBovP;F}~>tV|SY;+`>@h4Y$sB@g@1B*Fh=x8B=l_N3{ zJtSfm5s+>iubZ8|QQU5(;o)p=Cf7#UNC+~{J|LhbH70CL&q3WBddW62D}eYs*6{LA zK+clnw0!c7B4!6{D|WJWzMJAEH|NDoVkQlFJzg@RxSPdFE$WTW!$}a7QJS^cm>ncO zKs8&q0UGSY(~J`6c4VhTMxK3`1p|w}8E)X!b})m30}`Q#uX+?9TBk|R;}WxOf9tfi z)QE*~kl9QkvczDeK*{a3QvP=q47*q&p(IC17|Iu-Rv_;_!982TIK)vkN*&vDrOq< zWX-TvCp1T#WgZ%ZKOvcMHJzIzj8VMpA?P#`B7ZJ(2u44ZlR43L5%eR(|K#uDh}7_} zKFk)~!{n*Sxw53e`0w@xE;DIKmu@$mq7&(; zbJB@))fskz&YTp?pZG+Wi6)MUISg{BSy#1^=0;Ltph|qD

    d2F2@@mil`|{*}cnSZlkSa;1|?2gVjgdq!*NsW`BqAiPLTl`YR}MoEB+3y9xs zaTTVjRht0>7uxyFoD1Ss#B{NqcL=>Vykk~-5w9}n7MN2#pqGk4KUN%Dk>1aZc{ zJ#fI50yMM4PT&GN%3E&q0{w(c(Lvc%Gw+x5)IvjYVdLPu)BWLDv3R`f`X+VY&O?@K z;JIWw6l@(9#nfQnhwshJNn*@rV!tdFKpvY{he-rWg&>z{1_lG?Dxkz&V2wLn(&NQm7jvwKp&b`HA~?Yss#?_Rd*XWmaOqkokj! zYif8omhf^-AcKy; zqFuAhz1B|jtYjDWA3Xl+4`0Q*2$r}NI&5$_g|D7G{^2k8*H1wl52urIHgcENb5a($ z`@}^v(4tWfoZIqvxaO`TU3SC!0w5(y_p09T!8gG@1FX&cwjX&G4YPyR@Sl3zi{Z7- z;p51()*X;o(2Kx8P|hi9o0N!UPOqwXfXcK*-*`rqn*@Co|J=w~M}3jgRE=`<3Y zbUlE3eu{}er1(*B5ZT{M)QeFUoqiO!pX$}3>Gtw$mt!6b!aC2Z*=kv?tF>RMcYoy6 z>c?PBCRJmrKIrv&q0RnWu@OKhs2zlcUI<`_dPg!21ly=Sc6vPu-k{n9@Kpb*&1wp) z?uTEHeRcs-huzNoj;NwIY}KZ}tclm`_L%dAsi^{y>kmV+Y3FYY-!vXs z-lY^IYbQi;#ox)gd=eJo)&MY$rGlLB~K0Yr`R9Ekqkw3<= z<6|4lmYZ_!Jwv>TLuFxbrQ>4`dh#=&z{4f*(wK$93Pvy+pB~EL5}983F)~pzQ)4^O zz)@4QglE)g=_F+00UR!Mk}y%TPn&@;RzXBUkKiiF>Hak+{AD`kp7Gl@ z<=7*?{^F{kt-z;Gc#*Umy4w+jonDtl>k$UD;ASA4^)xyND$^JE5&$NqTf=l!a}1F> z$Gz|J$~!@OU!2eM9?)g5ZFmJOd7bzYo`m{@RJDoS@qhFoNhqEmo2HQTpz(42xIRF3?Ijk~}%E%sC?;%vK^ w&$l1X=Y2I2bRmO@9ObuBR(yMKp#E$WbvP^`YT50KK{fR;w$JQy0)&#Jk)y43zMFoV|Mt9laWNR3P3iHIukF9}_4RQ? zzY+f&;^!ItbT;Vc)vvfcYtirKCN4YpIl<35o?W!^2kYwx`IqbKFZ0p*`m~kbTwfow zo@}p2Ywi5A_4Q|Xu$kXpU*EQVZX!ISpGdssEB@JAU*9v&&`>#2mz}-&t*Ljhip@{x z1?oj(#iYifkK9-{-&v22@~_v|Z_sS#wso&&OJ*LZ%GY|#!?xcIZiTur;clF_(fH`@ zGrY6DzN1^K#|FK>zP^vvW}>wgMm=hw)EN)EFNdwGQTVgC!omCpClNWq|Fh%xnUT&l`wMI7B8Ku8B!{3 ztm>TJrT=gX9qI_LT}Sn6vn~2HXknMi9UB4sP?oQ-b*pU+-Md!5@bhGUJ$jM+ECA2u z8OlxUahWnN@xy)KAGLpW(A|z-msuDp%+!& zb}$YGl5LHNytO<~bB%K1z==&Cm+_`=TTuzI(i%Zp)2?svU9pt_vzzYuFN*Bzj~ldF zw3#nDVl--hiULnCb~?g$cwJ~ssblZuwp)MKG82H!_KVeB1#$9Osb%*dN`xN(4DZFY zmZmPvcH|XX$3f{0%_27FvVdAahcUhs2$TE6#q3i+fSDjdc&Nij4)uM6vZW0<)LCq( zTuo?s7(~se%)xfn((Q5cG|EvsFiP$WXygH;-*1K;Lx z|MVG$J%60VJC4($z4n>T=`cW3`43DJPFfa`V-5s;@?$K-O_?`(yV0A?QOlwc%mThf z_xbi%Z%$Lr!8aE?<6}(^(GCleE~(>?15xN9)}r^q9ztxhUNQagp_M;ltTt7f^|obD z85ZQ!8n0=|Tp1$BU(Ey1@PRGL@U<>!cY6)#_(O-(-Z<7Xc&v{y)e{e76Q9kaP@N7_ zBkwx?vGl$jII>?UVxGT=?(~g!CM`rAdjz6tu@#Gi+%)mMPM z(VZnr?VR!J5t`6~WP3+jZ)u2!6 zm@BhcF{$;I-R*ou;nj)V`PXvt_pG|i?l+V1n#r`lG+Eo&1y<~3De6d>WE46H)@x|8 zF7*+sv9ZY1x?rkLjqcsxb(?u&k1V7P9ExXP1o!=I^%A%I?3LWH%_Iu(SsFZSi%lN= zjH?PxqRndS9*o~+kZ0i~15S^UH=l=%yceNzaaOS}J7S0dem!j|S)kQrEP6Atc)~jl zI$@}zD4BmS(6G7DKJP)~5x-!2Wv2*;VoBdXa_k^O}FHj(ge4 z0oWxoiRl}18~ZVxk5T=QCjf6K?0_D2)G2@%(lollj*^$#c)gFSGnV-A0oHaoo)|AK zShuc5-Tayd8={&FFm?43?c>&xqk2bT!uc?Y1Wm7Jq;By)9tEp;A}Iq2$hhx2Pm@nS zPlhZ|-yWjKOFboho{TdyCB=oNWXEHHw>2*7Oe~TvNP301)Cjj`z}5oOP^Ea8nk z;SjK3pJk9Sg0BbQbY?;Cheg+nCZVNEzjOtok0MRnt}}Rf-EgE;4L$}h+7>|+5-adB z2+>R;jbl!mZN{4+!rw;is&4g3IsA#)g9;YZDYBWSDnP*#ze2NPy(Lxqj^~>B*?sr; zD7V~^8d>WvzNj^Hx|rq|ky;9f(Ap-x0D*oGd`-7AzMN{Xvy=~N>6I`~Ej=T=Mb}=f z%7>N_tc{|qf;F@0LNIS_?U1D3+jIf>p+zybeIcHDf1r2yRV#@cjtS`06do%qfqslz z*7>`@6dJ*9!uF}QfDms(DZ~*oncHIeAkycP_E-)0f+b<5f{mvKD6og4Cp z?}b{r9i+7tI^Ac;IMGNoyff9Rp7?bI@RTp0@@m1JBsMT|xm=I-K1M4Ca#=S7bz+WW zwORMqpKjUs1}l4NAsQ^~hLT!7`_*08v&dEcnuUES7wKawMThyB7YR#q+qw^O)suf> zKtFj6&syqy_0gH0T8R^VU~tcAQQH8ev345)JbRaga4kQitpR=bNJw{l9Jp_A;4hjg zI7}8(8q8%Vg;%=V{#>PDl8EeG_$+dCwzi1u%mQp{>oH)r)fd~pEOKtC0cjoz2S$=i zBaM08cPoS`j1jTWo12JDEh0~QX-&Y(0JwP4)t3oM$ROXj&<{2sU%roNeCc1c;}26d zgH2(E8GV{zrg7H#w2gNIa404}D~1`Vs=_ z*LE|{t<^GojYXNYvMMJ6T*yTflsCBrU6DaGrUl~fKsJf* z%!CQ9O~Ev8!)o*pU)vTmA!~-z{zn$}3*i6{M~94ajOJ-ybEAqf{TLIh4OlR#+6QGTO#b8m7aXlG!>Ev z$NAQ^$QM7omn4GAE{708sMU@q9W~#1Jxi-$6c9Q`Pto1B1r=t;yq3l-0M1S|MV=cP zMd+>9!@##}U)9diQfSQ>%Jt(E>cnwzBJ` ztb&g;wflmWzG}*cmP`*#zQ6*ueT7<*sh2cT;n$X2&WvOS@3nQE=*!EXwXjp?ZOd=c zh~}Uc+<9W4;|m>qVbTG zg9m9|!->2ImMW z%Y)KI@m$ZiGp^ z?2FN%KZ*h}6`mkhGyATcj$ZWiUbdv!l<&N>mn4k|c~Go#UsEkB>=vbVI!!v=Wx?vG zW$6%t;{6bH6zpuG^dCa2_HC3|=HK}>K{V?3BBVyr7MrakQ@G2P#{ZMBt7XV!!W)yr zrKlE+7$*n=7jYN}HJkxS; zQAz!@9nHP_9D-5rMfzaWx06V)l6pilJ)(o4_HWD*8No4Cn3xuX(*8UT){yEp(L#r9 z0bP3BUM({@`%*X|`1x&NhGU@2^2H3<)OfhhquCRr+=7wT$HGTFnOiLK-5j>`akw$Z zKqs!fvQ2yrjM&ypLVVG8^3!(M8gtvflQ)k-&Y zwx!>$b4B{$;DOR>iNT3>syW;yxrmx?{`1vemyKLUV68^~7 zWrlP`AvQ5xKB=xwg(tIOSNb+<6<|_?tx>u;=ne=t!?}m}1#g`^W7Hj%#U&bS$Em-K zJ=ZaBTd7RN?ExE7N2!)8ptd>^1d|2r0mdw*hVex1rgY2#vr}x%aaag@KPm>|KuY48 zu`|p$-A_|VMtXm3LO?L@!3_GlmQ4>jZa;#Up2c)2tjIZFqS5mQ@Wj9ewqumzRcR~A zI*uipBj*hxux@}4^RToMFqL_wOD(;G?>g2%AmU-#L~|=0*j!4dHX%AS%JR!rg2V~i zlE*bOUhssA1!MP3ZCW~xu83v7;oTU?S1J8=z04l*Q*%lxBx<7XEtKa=E`xcT{)B=2I$eA6hF2T zf?u%VSB&n6q>PGvJL1DgvaDbtCg?^pe{aY4`Xu7b&QV?>M0wd!JKRBX3Ojk**b@dC zk4bT!y1Nb!p9bZ>M(g|9i`5X?x2BcXp2f5Rp`&E#ncYpT zJea(R2?+**>+Ov+FHA;m-BZ?}tT={YW zp|bdo+E(upd*X4W=gu-1($TXn@KA^;=ZMsrmNFES;JcO;wjl_#j=Wvb9-$4I_R~q# zR(y;yNwXs>Xwqwt7wrBad(?>Z2+WEmN;2leh3d+4NgQS+)|8c5V^wNN`UVG@zS-tN z`+R-PFNArNaL3MUaOp)%FtHgrG43wtJYt(eDOdYud!9K|+qW2a&qi%{)r@?}j>3iY zl+(+glb}6*93$0Jwt_lh-bF#@c&DDp;^N!jFv;?6=V-8XT-3+4$-_^GuQ~ zm2%k1%MelfCUS|1@gEqc()A!xkut#0 zB<-G%ZKBk;r&BPN$zHn2=C(veA6tv>4;v7Au7`>;JCP{=rMpQ&LO!$WV*WE}2(sEq z(%U#xu4gad36YfPz=3BM77j7!u)iGIl(e}8#_51e)Xlas!f#V zFWR2L?>ix-hlEkf4tCmlBJugco)?i(s)?OF)wrSXpnFz!Qkj5f|9tvcS&N@LbcAK{1jh8K8t zCEoTK>ZwTL$tR8r=O38!llABoWS@-R{_mi;PVR#xnHT8}E*V2!2BEwsr41AzD_5 zsVDXpX3A&2X{JxX2F|G{m8cR;m!nMLm_YYr1V8V%^un0!>*cakRq-+xic1(|)$Xq2O3z zviWM>sNV`2+Bv7xzRkIEJq9EM$_q$3We@@{xZJM0)K+np3T%aHoZwC_mFtF2_KkVu6U{}>DN zvk>3m#aJ^xP#NssfqeWViLIrN809uHw>{9jK>R6 z0OJ~r7I#M>Xbyhk&Z|7c=G1PX%3w)@5iMkxp``H54N3qkQy0hW;ys&?4~0MQz*c+O z(&f%D#Q`X^zDBPq7`Tuxkg_N2w-&40z>W|th3Zx~Xn4=MJqj!RW4C!@ZXH=l4+iZiQu`}2?EwL1v8i>Zu@3?c%#zTpD1ZNKPK<=zHI!(ht7b+d`B?rjKK!T67zBh%q|59VKXL z+Md>)iYdYSde63;@?;U)dOvIZs18>X7GbC&vrKkt9_U(8^c5C7)e9q!8XmMK6LB=* zYpvk1ZJh#HUVA!X^?KCu_4Cf_VJqkxuU=ooD))T-L!lBnZcxLJkGp5k=3TvVBGPq| z0^`Xu%Gv^!J;19#$h5dpIG!NsSca^wrZ9tEobZrmaoj)PHW=Vf1{vn2jCEefV_h+y zvnZMS?P%(HPYh%IB!8)baIeWpN)!YH;t;rbQkp3Oo7AQ!?SRF&t($o%7qV|FyDiJP zOthZ*`OwzA3VEqp&X1lz)bytk1$+im>2HhJigOIrj^CbVh5Eql6=Ur&a=b%(NojN3 z_9hQDKJVF%YdfjhyLhnnvW;){394OZFbo@GkDi7UchBSwQG)ATi-T}cFo(cs1r1}2 zSYgNGy%*47v^ndYj$U9+xN{RAsL{53~LdIFQbJ`e#2y<8)?1L|3j_2m+DMT)@WHn^(h=2u& z3GiZ54m-#VnBv0vvhDgjyi1=y4p#-HWKSG2o2Q>_BDwEBTTFuihnHznXote&PvX`t zS1sSn%kGPJK<#j14rAM5y5X8#ak!O5D&FVAJ8>)?$+E+#Gi>VjtQ8MO*R!nL(5ha@ zXY7kCospHR=+Bx!_*sL;&st!+qsg@si*D8#qx`54LhsOZ-;5);v3SKdHBIislo&=9 zpqgnhlVMMzBa>chTXL8HIHybruB%G@PVlU9sqDK`1S!JLx={)5J2AjgTTe#^OYgr& zLF}-{|F#w;F%`tGy`5y&riFA8Gw?@->+$1xaO^4-6J)c!P?6Lc^1648l9eTaG-iejEM1(DcTbe*dfG}jk+C(CQ$h$_roe)dqb~dCPLtY3xA>YZ}ECMm^%i%482=~(w;cJr#mJ#6rBSIO_ zVlLYCsSDFWDkgx5c=nlbbpQ2s9EWT!Qk&xnS&b2+FetlbbTdiZA+L3uvS$*ePX)wg z?}eiUYbF|yNgQZ8wU$DRzIO59m`8Xag($Mm+P2wP#G9b}iO)=~Nn`0EQ=fHS1gR5G zTIoY&KsQ?KB)1jnld+Q&ELh^ljF(@_)p`~?aT%y0EA8iNnV3pPxT6*m0Kt=d7!9e- zm0BqZ2(z)E-Q6KlGo1X;2+{->!4IVoi>8~?%IX*>GHSqrCAF%`hMnL;Zvsv1m3cJO zKBum8TCBJD!Z-1;#)#svO8jY& z?J|02T4{vsy)lp1oYHo3kE!34Nh{Rt_kjb;VxL9m>}D%rAt5o z@h+IwJImbZF0EJIKf+R^-q=%~rBdjMsWoldhJ^O2xW0Z~C#L z)+l5{nX)v~(zafQ)YhGNetBu>=-h9_5A57FUbuFA zF-TIV_ktnmQA^@k9=C;4HKpazk}le?U1yA(GIlyx!P*jG%yU*&pY#(U%h&Mw%0*9+ z=yb%9414E}Cy@^$FmI+`^KO>{^=KFO>uy5aSe)6Ia6m1PE92IoP|**)TJ{3@2dafZ z-P80Ua^87I>BK%tZEUBcKlZoE)p2H94|vjQrd;-oF|Bzc)n(d)(Tif~d_9XfV1!~` z+SD_WPul%I@P#f`{}t?dW7~6KP?8~7Rk=UI<&&auYAcyp`^mmWEM0BMWSwftCHK$= z7j-oJlC~@d>gXBSh&yDQqAk8+N|>bGV0*)a&I2bDh2k?4n-)pq%>imqW~gb7&Sg!8 zAB)kLxhdIB<9)&aHoExxl;_Vy@<`D2omBuojKb=L)2AzNlMjXEv6G=_x zO?@byX>9smx82z7{S>LhHq+Q0C2vnUE8Xm8CMVmXhuuOEQ`1%`9&TehY*!n%`!Uh!Wv2UGe+;2Gm*y&@ z)OqcNH}g=U%ybp%L{_*|(T9f&mo=eB6{mQEZ<;Z>ZQIAzp~)4ZqC_e$tfSs%93qa+ zwjBUr&kwPz)YFs53V3fxfm1uyj6!<#7<9Rc=X-a|bHYDWGKjMB1`$PlQtg- z4Zmw=k{|h=>)FW6bS9yW+l`Mu0mC06JJ`tJze8X_N>?U`+cwHZPH_B=Wi30t;5{+U(w< zzL8s>{rZ3{5DZYfcJ0tY&s_1Q$KrIv#466<7YnPsc8%L@1`@=sDQL@SyvQ=Z=Qfs$ zehE(czQ$~Z3=B(Lv^3v^S4UTFh{~8UThplRxMIvM>?zdiwkp{U@dzpwheI%7iO)h~uxxZZ=y6^bTM0;Mu0d2MDSgkYcEFbVrR{U+ zDIyJiG%u9@`9+dJh~>&zj74_vqPH5b+>zL;7$vr<=@F;5o&ZnjHJwS=R+FGbGe4ym z&Jh@oTf)=-eM`9Pt61?c`1QuRtpb2mV;%#QP>%Hsffvj(C+}}L^0|$~99gdS&bI%F z@l6c9H8s3e!A$osuRmKfTPz<9A#y~2KWqD`S?umX3LK)l5_9l4?(};i4R1Vja@-W$ zNe_0cDOEO=LA;u=4x)T(=Ve!|3-g0#%FD^ij^_9To%*5!IY*scKRuKI8D}gV%T2nI z#L4a@GGu#5n$@2~BfkpC9LJ zEQ8S4A9Q#;l`JUHNIo%voVOeN+(F)+6T|dE(kBF`eLctR_@$f1$xC@_IUs*%>!c9| zm`YJbXXk4#Yl3^^NcVByry`rR?`5rYUnO&y;*$iEsSKQ;uM*X+ufSMLqqsAE-()Pa>YsqjmrQ zwL{}199}3xQkjl?dk}P5@dFZZCV)VMp~Q4MM!^w>jItLH>b1XA=9wj(N=kL+yJ@*O z&}^Zd3gr_IRBMx%@%}3BnP6JB#Dr~<6$@?HKs1to#&fL|2t%YTakjmblZt0CofvN6C7!D3*y^O|H!{shaw>#w{dhTxWJMWtk3S5+|`v zUFrG~mN0m6%HpxU;uNS01^U#18K><e=2eU4$Dhy4%sKW7~k=R4vg zPn|7XR$3ww3}Q)NwEWDkvQr)95^vkOdYH@L0dr-nnCRoHPVDU4Sr69FfN0?)$p=0^~Nt7%XQ_PiykpL{#y#8g|tBj_?KAalk}m z+i_+1ElZo=D*AvzhLWxKgwj^vVlzKomiq*}9Ps8B9ie7dq{Cs+*}fvoc6{A2^aqE@ zA)cLy-7%k(1A?bevMD*+8yuRdGhnN%3-0K8Fi)njUF|XkP7g$CPA(I_$Jvu2By2(J z7PO;?6_X)7`co_;y_a}?hjs7Uu0%kck-u6!v=iDoy4!c{U`zr>J^I>&wBHWw7fMi3+ROPHKyjHc6`Wz4AFDrYA`a^RyR|2!+mXR zsXdlM;vucuRNjm>*qui%R5%jkt0-8n(kTpEemvoL6|-z*Ofvy&nHQljYLV@i{o0Q# z;n~7_LXr+nY0mALlxou))k=wG1sibBEb(LY$5TH$T!_i!Y$qm>$qBTx4PrpQR0@T@ zh@`D=wx!zuu1n$znQ+uQT6O596GhQ;KBU2hr06eFq80n(`GK^G|7fqEhgg6wu3EuB z&<6q0g9ij5Nl{nj?quR-Lzl7Hg)WF2Y-rl2=)rEV1J=3kF(!O0iVYv^mX8P^ixl7x-l*93q8sifH&N=K?AQ`si@7b=wwu>Y}MLU zp=D=IvRtE)rm)Rho)dhDo}gc25fm2Wh48F-Pkn6%v_e`kc4g6(!r3N~(?&*EVNFK0 z7CM1i8(b^woSbUuLAYL|yLFsyLWWHrSVOHRrYp{tAkd}fZ%&Ii-D+sv(>5YbcRuhv zj6^%Pfr!frkP%l$VoZW`dDVHLm@Va4A?;1$9K!k=1U@{@TkD?BG>aYmYw*SuBB2}o~k2@{CF~r z);rJCxOa?~mrZ4BV^}-dDIo%PfBD35$BoF(Z>OBfR}p5NK3j)v`Dt~LK}p@7KEj*c znjx`w6JjmRcG_-m(#`z!6~Iy8rnRe9GIMR4WV;Cmz=<{-OKpvQDr_<^viZR2Q)=%i zBiUybRw__^*V`O3;U{Y*L7iNS*wq^rM{|y_lX$#W?O1Y}3jG$?+Gw_6Kc)^A+FW_2aV`v6)k&W=8_ar1{Q z+D}`IXSR$ZM}GQ(R^kOaV7#=Z<(y`JfV#JbKUG2Ieez#@yq(qh6@Vd=xX1hZ56+{ZTpRAtLXa-Acg;L$L zAgDo)EByGQ74R~Dt+wH2@u^k!%`Iq;TM;4WwqE9STO0I@ej7ZA zxAr6sj%fT{p4%g9{8OrXEGpTuCh>edECkKYnh_Z2>3IHOIewcH!hlc~2mB29WD~ z{7I>C1-uY4_`rc8Z%-`5Fre~}cum)SvK~JIDOh9baIb#VvL^Tu?SLAGY590y^=MFp z<6S`{k}TR(Y=vsQ=7yWcHZT!b7Z|MH?ODruO(mv0Ya<)m)qWuu`-SOcw{eCgJ7k?%;v?R zwJ{4|B(B9!hh-a*3$)v=Ipke`-#+(r_0?ajg?>-qbjILR-nAZUoC^0Ri#ejl=WWUQ zn8%m2H$N~sSlhBD>=LSAo|)#R^>_-_W6T6dr{1t7v@j*AwWV{r^_ZZp#!z?R0OOv5 zjI}+h`V!oy7&3-GStF{^Wr^W@_QG1GOBhY=uzl99JtF%3AiT-#W2`}SSGJj;`pN3a zIdyQLkcUfZeBdo#eQr0YA730;kH@q??|G}fdu>6>BN|yv@Eku|&@!dIjv2uXpWBNM zA5A9d`!DQu(*#A`ULYiaJL5R}2}XB>^!7HaAQ?_RteJ#58p2a?1?2Zs6P_+LuW_X0 zZ%uv5NW!7vso;(gKG>$#EPFA<7qggn&e_p-hS5ANw~q7f8ZP|eyOAlsm8)>Z=rl)S zFZ)9;o_KiQathoLfI_U=rkIdzDcGw7)WcR7FYXn>c5GXz9b>8xKZM{_WVuBc`C&+b zgVRH73_m`Qbnn@ib;{zlT)TU ziLgiQU~u%96UU}fV0dADJrfo0<9KYfY7~_BhVqRn9|IK%VQ$?57qFW2sp|>lfI-|q z|5xAtK4cK!fM&IoC4r>lTEyAfI@Pe0dmEg2AdvigIDZ%UO3_fTc{}j24F`ViIt=6R zZgyf2pE6>Lq~AIu!)%Rt@&vxbN|9k%X?3&!df!rMD9L8$s^ur1GFmTNC+PsT#d}2w z>&dyc+o?hGO}IBuJ?n?8;e9DX=6SAOt|TiE72X84f7TA=tJG)vrLZlHtmyYT`}$&; zg0EZB3R7(Hj7e9$VCf+<8c!>Kz~LJ;2)KEKcXTRk@RLa9t>c`d@f@&`6jM$jKXP7TE{wP?n|->5iJ7Rm z!dgoP7jz87V(|h9CPY0<@w9al9Ur>95FehN+D8&0gO=AOZ0AcigN=^*p<_=9^9|VP zbbi)2lF{Syq}&LCIvd-=o|nziETg5MPCE9aZpJg9_FVn8lX9_n5VM_>8zydKTyM`Y zFjdRG?d7j*B`2^@u7qo?WV;$KdItfDnvJw)dzeM{f9*_*c70i(TFCN78ZYcvtbZao3MPD|D)w)_BLA);OG z(9M3_&%>;oF|C(7p>t(6(}B>vDX4ob&9l`GhK8o|i|>CIf{*?6onkAPSYTf}>lv#= zC!B7-ZAHp4n_$oO=hKE*Aspd(Esm|?#>3WB2eXI^$-RO{-8Vcd8$DdLxQcdSa&9)p zd)E>s5wF+x+I~dw`^388!A7pXW(*IQ!JwzNEk9gu$a%*!f$kS|_qW?V`iX_L(0cPE z<^k38TbT_*&qSxagnw|`{5i{1dRnf;sT_;wEQyKLc2bl0nA!9ajfJvpVM^B`F{RqF zYjZbch-M$Si#du}x*GHs@@_Iy;Ef(&K5GYO#~!^jU5!tmV>%QH>Jv&yXHN^lYGFU| zjBrF8hPO`JcPTdB>~5wqpJwp5!F47seEjSBNJ)bpn~du`&A;DRUw@AjZo!2czJ??z88qhf=w?lC^6#Ch8kep}e?l7E6 zGN|zNGbu%o^SQ}rxM$h@@0mC=`y6qQ|C6T^w`rLq8|NQkqRJdCmEAt!OL0K3rR$_+ zQKSbTT>yT7n`y=IBHWgNT1}ZyESP=chT%Zoo^L$AZ>JZCOI>u5 zv{taA4k#UH8#WcN$Lwlvc7nPPwZ9K66rMCdlL5UG?3kA**cs5a47Ze;$Xq654b^Qr zrWsKg{wY-BffLBD?=LRP8Sc=|p2vSmbI1^!xq1aB@$JIna-yCcWvO)zh-5&r!UZ_v zD$98Y#DdDOm36I`EhDeqi3NAcBoJ}LZQCY#f!7P8`1PpuXK>Qw&?0S%-VFrDktBV_ z74<5=h%vj4&F-n+(|FUxaMMQgYn)uHq)W=){#`5U+He{r3$I9rgV5I|+mKP2?;CNR zhm|t8Y$s;lRUJ{;@)nx}wr_k(0-~8*+h!yvs58;N;+nEKz;xA`Mk=~S zN2yTNWImH2ZB)mO?NDorhe!ylRyZ%W8Y8dP2eDXbpZrgY0tk?1LNE*Rs?f63vCO)ik z$9JMsfUs=?;%jL8?c^}&kQhQ%R+@Sz8+|h=1R?g|raOVh!cju?MyJb5?@fBYQaksq zov=?Jw@w97PHw|)W+GbRB$hP7ll%o1$aed85F*5Xk>cpsj7J* z-^cg9XPOoQxdm{~T9gzMW;^C+?k%imNE6TpaG<{^q?LZ6vu76g7%Z~cg@~k86lNFt zW?K?CSj zsnUu8WorK-{}E+36y~28-F}SB*tdf)?%4s1y+CbdV)p}a8`oLxnrLmM>Q>u0vF=3s z1CR1gfVyhi4+>~#DQ1sF%)>b&Pc}C(J@YhD3YUJgtsnyVS=rgV6_7pc$r!_#JMh|# zxZx>3LbIp(_^y*cac2X9Fg|n4T+YmqAuN7Wbl3fiaa_}XR0PPYq{)s%kOzK!9Z3)3 zK}({WsZj?{Rf^GGz_7*x_C)g_k8zbOn~u;%-D~p^7d_&xszAHu3$v6j1ANG~oOn;S z#w?AonE4osaFVrFhwONok8G>PzffN>ua3o;1BtI?#D%r?y#SHv2H)M@QLscF{GX|i z&56w>;nc+lR=p?M$)UYMJ^T0oJxdI&HOeHVXTgA(Sepgj~vi-#t(R zHLk_{xigsmEyPQ?_KGr@Tgc2QH%6m%~jUw);L)hjD@u@#OnIa2NX#b9uV zgdN9gsJPDBbI$@TGOC*N_D04jEn-`VnFIX!Pc6dkNcO&DoqMPx(NZYH+IgBO5p&CnQV`MshkT$gU)=qB$`?{ae(&rl8m+1Y#KK+ zqo}+Bi!pm=CAa4ISs&Qbg;CD7t-J_Dfb|f$MQT{PE@XBc`Yv=(Y#XbmkbRew@^6n? zCWlpGkPj#E&}$Rf)LiVQ;TRmL*7HR*#Sy&<-@57D5Pxn9Vqi zmj8*G)!Uc@N2;w+Fv4z1@$Scm{iKcc-N3}RMDSw|}WEKu;)4gB*gE}wNFfBj4Z z1&NJB`YhlJ<7un{=3Lo6EU$EzU&j!Ho9`vMu)mWOkcrzUGz>o_P{-2ob-*Ah?4P*r zormfBzT9SQ-{RE-^4!+O@v*+{gb?+fZSNm4vvd=Lw~}Rxi{Mt5axX{8PAodbMXZaV zBnR6@)c2{o=w@oM!|W<91-ug_{?n`eMnZypH8%F`^3Og%cOnJGD*Za5vHP#h= zffvz26k5P~*G@rTIpHRPUB}k3j#@!qSHE6`<|pyg24Sx}wY@rvoeP9TuXYN^P(i_Xt1M`_WjV?Lv&P~4^F&4>0ufr&!a;h&RRh|eo`d*#U->MUt4c7 zA-wvuVq!N^IJQirc_#@v7nitB0`4_G4Q^?s^wfNp;gS-jLO`zNmt%tH4& z2~M?AGG%&w&WKPDCOs>{+QZDJ5`MdZF!6a7;>!1hX(op~N=-V2aA*R6nU%g5NHzOwV%9q64aydH|}3|Xv< zyf>VV-lM2=EMX%AiF{X_P@orm8>SL9k1daMO%Zi{bCZy{n*j^NqkEOuUEDU6ouf7w zN>@0TSQ*FCupp~w+_PSfW$hKN-pz%ZA|^R7$7xIlt3-c?TCmkt$G?-E$f#QPodn`pP)|Bzl!0T?);DICv;#>* zo(4^j9d5^>y9O5B6-M^n(2R27SYK@hGKX%vt{lE7%;Ubicv$KFGl?5Xu}byMU9fv- z4HIlVjl{v;l@FktEQe)kSnL<~RZ>b(l^1Y`-2yI5PWN8}*-9SV)pxF6%IoX4u<6C` zGo7pYn11#}EcXNTPzR?>HvdYuFLO-7k_D~X${R);ej=j(yRcKLl~^tz`PU2AWhK}j zy{5M<|CsVBJU}i6FWXuo#bQVBcLFk~s``-?3o--%arvFd5yNWYwQvetGssvl(AcTb zPPQozhZ~Hl959%XA|s~Q(!Ta$afws}BIQ9mSuIGeaIw(AZcf1M^$k9PIt50>^(cso zrGAiehUjTK%3|^#3d}NZZp5(_X}w{XI8l-}Z5gButvi`i(1|7~p?wy&_!)&G8u?io z6Uk{ixrJjSv;zrami*=p5AEc;_k0^&GxSzcAkA&dc|20*>{?9B>criQY@bPP`&A&P z{oO@~#YE|~&}?tZXte2)a)%s>eCc2UdB(_f7WrN|YJvs+*i&aICmLsbG>}2h-~w>#I#SQb%I8w|y6@ZYE@)v!V&a_faL|PeGiY21Zz*7Y+iQAVT$>o@f6ukZ<}?%XDvB1uanp60IqrS z6U7@*sB^YDYjiE0orHdM$`tyHDRf~;KNA$XzS)*`^|(HZ_=cn5x9+&C15wR0&IH5j zI0@~?y&wnasH5Mtg4BP4X00s4>%`;BM%HDTmOpD+uhstd$)4ppxfk}0P3r;?lvqda=?zMa^ypjvD{DXxK+Rh`Oxlul<_ zsyOLbrmG$h-VshVb!3noC}e`Hvdk2GKuT=QETSXLBlE;{KHELlA72D=G5<^V?H#<1W67jaot0e9q4$D8E4oP)O?N^-jjYt{{fS0iCF#y;Jfcm%D$dqg>pm0 zf|0MCdI=-^+3m8id4d!xHpM$}a$r-F1N%B(8oj=W__(@_^5+|T2V3-L4v5OMZrP{F zj#`#zG-TP=C&1TjG{@Y2Cl(( z4p#~%^vw=q5$T4^f7#NPCKb+(D|rO6n6&iH{@Iu8@fNq7HWSTFJgH$~(j2dxI~dl; zwgVz|Eexeqn6?6Bmo4KCAq*}wZU^G@pGT>oo%Ae~TRzq?wkM5N5-Ktq3|7P#S-+hb z@9qU1-;6=s6KO!3!KBn$!Z_A&L@BNnkEdnV+;Arp07pQ$zn;L)sio~wY-skZctVCb zp6WMbCK?Jl!%`R}I1_Be@4 zqypbbJmxLYW~!*cTRXo^Pabvbb1x0w3f3@QuESe(;H3vfIiifwjG`8@JWRdCx_)-gvJQ=3;AW3Wx-j&;#aPJHe}@=A0y#wl+2_JfT4xx?WnD9@&;`A;L4{g%_}x<-;wO2H_bn zH9sr097EZ;vxzg^IMyD=jhm#6I7ecWhu14u_dax6_Cm?%_e@x>Ic!e)RJ;DF%5Xp3JlVn|9=L}bP+tb9RWFpN=ZPAp{)P2Q$q-ee zj^A`BZG*@~l%6*FZa;PyvLttn=F$5$r-NtD3?)V1c7yHX)vT4AQ+ZF}7G+`RCYlQP z2{?I&tn5241KR0=39#*Ey*IpZ%#=PzK=041DVG&Y6sml&9HZX z__tG{hIN7jwL3^RH^yej!+B5hdMZ-sGZ}1FX36kVfO*>CdEp3!ES3wDqCh5q#Plzr z<2r+9NQkHQ>?s|O>tQG8avh3cZ3k@ePJOSf5RvEjAz#Hva@V`US`?dLHmwfY^W#A@ zqWL($6G_Jt$2Qy9WA}uDHaH07w)M4F7DsZ`Xb{Dpwv{~Duo4Gi->jc9p!a0lZf+i_ ze$J(>iZ*R>q%~Ib_jqF)4MwnQEk7u{Ye-?``?8?YNyIdXy>?^Vro4_+_+akrhA$Tu zLzGUE+cLZ2D-$1EvNjF{uY<~K4Xmp*!JuFGl&lFF5|@pe-kMWGCKT&j#KLxmw2OEnT&&sE-NafLBS?Ud5vRg+%fOkt2v=G^f3gL#1kO z6#2v8iP>S3>rl0!*Z``s;@#&Y^HhgCTwHpWj|My4nm0Df2Q1yAH8QDfHx-mK*XhBW z=Lv0NhWD+t$VWDcDONEe3?u8EOq&TIJDI*~CkRmd_*TN{wc7qX(i2P8=9n#NZ<|;a zqKD~`j)xhJi(zY>)%3^1--Lt!+mgfUCT?OkP}ZiO{X=FBRtBywbe6>DnXfqTZv+o0 zR!@0wC}Dc9=%#Oz!m}RcUD)>n+nvtw=t>DTw0#j}C}^K%i^VVsh{O%Yp7dJy_C&T$ z$jj^EJ<|yRqlG@<99sCWv+j2%NN!q+yX+-Hv4R4OCmUsiV>g+C3?JJ`Av|;uFgo#& z6noMw{e}N*2S8{LdAbI30VU_hC>WqWp2qK@fxXsKk-dK#5Ieu#QX9D9o`5XA@4^&IzrGpI*=N{kYU&< z)mF02YPtbaXbbq+s=Y{TYp0vvGEnzwum89p{E4#j5xdz zhQcFg1C375pqIvcq|;{DgtqC2+Z+lvBR_Y{u~f!&Y#Um;C$uK8B)_o%z_BfzwY4eb zmUXowyhddZB3%8X)Pa^|79V`O3KM>4#ga>!o_4@qSiw^~Nv$bujm8sZ&EJnvFzI|K z%9_IJ&9L3EnIhp9ZgBk>2Q%K2Fc`^PlL_kmpvJdRew& ztDc1ht)*K$Fj|hpS@+akN%16-R$`JV(Na2;C&okDSFZE1973;E8pS(OkmyG-Ov1fP z`tE=w)jpgg##D1MmG5hW@%o7!3Ey*kG-=G<3y;y4b6~~O>YG3tk#BdOu50tWb&{fM zB)WS!4&D;_JI`aBOM(T)$JpT!+7ia#@4OuVOUJ39-!kE_BHLt_alJr-k-I4qt%~>M zTg#x+3UY28h@RLo9$j0BG`w`ZdUSI6U1_)JgdO3)mC?yf?qH6ef{X?siyc3L13c^v zk!o-|wLTRBwa8cHTT;v<^edLwBh~vo9B!%7_VCIDdfD)1Yl$Zd_M@k{<=#Y>ou|6*>@%$_qjK4a`TRILe!`3-l zg{UAVW|P7Y8q1-%&yLpb@s(6Nc7E0wa$W>9ubx-UGwGveg=gP}fuT%)g3ht&fdHzzU40rI6OHwlr7i z3kLEm&Wx(0WG|F8Naxg7-G*`(IFhBIoh{u{KJ6P_bAq^LHyJiVTO<^&E~LRsG$`@y z9WskmerBmkgr8cg9~qj9{Y=j}K%Yy#$lc%YYo5QfHTEg`m{6+B3T*+s{-`{Fb%(tUcS5_mOOGBDWiY!khZ zgdt*5Ax>3F{9RZVJ(y6yBZG*>zYE^T7VEO6gv4|*{BTJ4X3>YoBRUJ~h zS;2V|j#+`Y-nZ=PG~j0}$u5^*6kUw0KGs_BZ$@8yoaeM?w;kXr4P^&27TXs)njjs?Ys_ zbf~?fOe;j1I5MqSj5!R14G;QUgiIM;8@`{#^as!-c-qLssHM(+FgX+_77uG{h8@X6ytNVRt2!Ula~_Pjh9H!WMO($O5FF;>`Y zn+$7b%-vtKZJ`hlty)Vd+VkRi8&3;bzs`m#W!MfAzSrP+^EpCz6x$Yo&Gu|vZSag; zvZd)Sz)0t*-v&Eh6kGmYlBK##g36m?`({(Gk)yTg?FI6W7{964`kZ}jXQfKnd@3S@ zCk%LwE?Yzgvi3j_8N75Ex={Fs#AbG4*+8D{C0kxNUQxY3rYb+K(rHj3 z66&i_9cLx23>X?=AmE`LBnATivalNRbIAa!i8}SUpxf*uhFu4OG-7?I>Tvw6 zUr6=Bu_pYi*d%5lLaIt{!5xf!k?2|yTGWf+qWYP0B}EblmT#shX^ju9l}cLOix?ec zwnm1m@kyK{uS@iIm=4dha&g;r#aP6%pZfvd7Xni=m!33yE||{R8AE2g(%N}ub`S(< zECWl?V|e2ZS|&ioc9Iv`k#!*Kz!Q91>4E3iUUTb~L$9Z}63&XoR>61uH6!-~99BU$ zC7DSfK0iMO9B4v#Q3I?r_)83!;StSVlGSt+>5VFsT`kncYgQKp6!;NrC-ux&aomvx@A4$xXLm` zrfuE)GCf}w7d+SbM~x8ARt?Xog9|!!blydoU9UpOKc1rTV=R=-psj062E<^z$#zmM zy?`-|E?1O6zC05Hxt3OELWHYn{FMt{@mQBuWHn>lE+NF!YEGfx*u7K9OU&!Xg!RxV zgM{xZ9T$22Vj0{UrC*4OGmN_(DWIe1Z1ZtUMI!pJ#$k_Rjt}1cG@h<>(z{~c(1)hg zki1B-?s7*V3t*2+aqo2Qb1|-=Jvv{nX z7zIEkgRe0R)!l2Fj`z&A4BH|WXj@yU(NqrX=%8Hbc}uG(=0uuJlriyc+BQeAS<|Ey zc-LC2q-|a7a-qSLJ*q>uwiG(FrPQ#Cu~s~Ds=$kQHJdX#R+9OIX>_jUrA%;8jR$@WK;nM+JK-K6}TfY*H){urdI6hd@PVnKa9 z3a}R7MrHJw^mx!AO486^msXgKfY2IOP7Kj-I4wt>kTN{OKN&v3v-VS(zhV2qY%-{_ zm)Gd-pf!x#7-ieS0LltunmJl#61VA^Vu%^)xeX%8EvJ}e73)K^`Q!^0Prvr|KkRFawp?Vp$D^m8Pcj_>A zL50f-^&PJhIzRS0-{sD~)=KW~dgteGHj3DQJUgvp6RcNT_0EOakL?lL^SzJQO>#%r zl(L!gjY)Ud=6OT2Rv_5thBdtNmJy`LDaKP{V~i31vM(i~+H6l^CeS4lDfd`%Lfbw) zrqGKOcvnoCGQtj3Cl!tbvrSB0iIECDb}KP(fW2|oMQHm%n^WAjt;IA#1h-rDY~AwY zfQxqPmb-Ps-72y-)u{}Q(PDL#S=SDt4o|c5l4wI zDX*~kPDSm$QP`y13Y2JMTxTsepNTsKY#R_tUe*YO242^$4DqleMl9DU+p_A=f;i~< zUCf}(VF5(|JSFKnZwJ_VbD(}O=?BgYV3@Ubc0nf)l~Y6zy)nJ}*s<*T0{LNtw~6;6 zUgVzJQ$|K)iLHOgF5=!-n(pb$Y151Lcb_W-;U7D`g{2!i zmQ^CZ5O>xreb0pYxmJ)Q?oyqb5h+^vCtn0DfTGf#}_#qjY&Z1G(bXQrKiS;@=VUu;>k zFHzE@&kKwcS|U64h&BSv5LL-rBBz=!yF?!1l{N;%IeAh+rM6b*k<|$&^^w6&|s1kJ5P+C{F&%|wqhqY%rb!IkPnj30&Gr_(_ z3mhG<&I}&4^F!ZB&9Yjutt|B?g=i8>(nXpRWoz(MFO#674(8#c6+@Ec`XFI{3*%DLlINwatNqIw9XabE+XkFWg2AH_|)_EkUB~O37&pD+Onh-fT zZevLhyzEq-?%D#j>vkY;iot&-ZKQ1l8DcxPBwmu@3+{zT5sNili~L1(GO31#qC9BR7QdQhh;&@H@5 z5r=O-c*oc8TLNq2m+^y;W&C2E?rO)Yj+SrWHhO`dN{d4*Mfy4thJP(xY{2eYaer{L z_e+tmCpl2Y1V-Iz$r9{%Y&|V8l(4tWFly5{bo5%f`%AO^UfT|>ucZ%{*@?YCP#)Lh zfiR&RdszoXgYFAbnDbVK7Wjj+b|B=t#NI&HNw%qaGj0SxulK|T`uBmv3^K?={GokZ zy>A&0RD*skk2f(X&s;TG?EP6gu3zvhLt}C+Cyd*<$Tbl8a&%$8HQ*@5?|A+`L@XVF zGp(_BFd81|*eQfH*R0`s?~6)3VNEE2dnmX~CzilZ$Wbrso+P^R#T5!2omTx_6cDI- zJa#wD!9{wXCT4b0)Y(N#NAOwq{kubh4~0Yy*hO*7KieX$<2o9cHIg=FZC2Mrm;75q z_xEEV33lY!uq&>BM0YiH(23>c@!}0x!4xV1Q&T@QiUNt-maoEdNNJUb<+`OLbKA)# zHajZanadTkq)%BY??Xzjn1|=Wrp1aImEPa8R(gk}kl(!TxIOZWS35GNz}mfDtaaL!tWfL4!Z2|Y1{fp~^D z`s6&1e8Ji)_eyJOWi%9c#ao!p5DLNlY6k5fy(?pR$vz{}@g2zGXI-+RvDbDi9B2r0 zKg&>=#{(e1yB}{am~10`daOvEimUm>_hxqteJ&07u@R3B4Z9}}Tl(C9^SC3!r_EXx zDtA~f)D*o?L!<>VA=-@G-DXNG?S#rmr-Y)OHLMd6^wtdnx3lAqt)obs+i-S^t`^+| zL}1%CF&?tx)n)elGB(YpU5I0}iC`a$qVn!)@%Sxf-+r?y}Vs4=t;? z*V-CZkv40Zu6V(Eu!GxB{1e2viUKCYUYHRl!Oy;lceI@xr_7G0qhk?zq+L9Tg=1#x zl5+sONy~~7$FNI~)A>c6a>`cJlbqO83O2bRViL+sY%TP@OYIm&&$7wyunFPA*SoXc z>1+2KC(MfL>1hkp)d~Fz=F?7+_o0K5JB&X&VCDI}Sr^W1w(r@_AtalH_XHJWCiz%O zJob{^tuEUxj-e~zt?_|RzDZlqg`uH2W{-x1;@nOMQHBt0-B=g5*}BTdo zS;$yMJ~mmp0y-#328GHvNeqhNGIj(+oGi>(@@rr=eb!lcm@2w%2Z$~|vWw>mYUNSJ z#5HY9Xi)n5wi{00W52zAd(Z4hnmRFa_OQSK%MlAPS_KVGJP%2ROouR<<4{y(JFu^H zD#cx7PJ^H&Go_}%=!FZT9X|=1g=C)S$Wy|UH8kA@?2w(OmeKA30AI6fAON{;8EvsFE%A;OZ^%D^7*4ijmU(p` z@WY5{gOEV`U?5-u=5|UpoNR9QTJAa4`tA4@2`q*Flwr;?$>?_lYtDlD&d*vZzo8}T zpc6XmeaZUPBONRa+KA|~rAqHNxgu5zMTa6ScEDx8N$zsP$oiILt!_p`C-d?v!3~%- zSIX#e6wCp#bj`3z_N}LEz*@7S(Q69??ubc{;ZJXQGA2aDsajg5rjJsN)<0oL-B$o)>Y>% z$Ew^Bp2UgOI3mO}fvO2`7mDu6Z?D^~9brK2Ej=KOuyET^IQY0dCQp!&y^z^G3aI)- z$n8-(OXSAXekO)Cvwp^oiQ|51#;lpA>Dcz-o#Vw(JmJdbg&{R#X~&Y|5-K8jG%u=K zP%*QuJeD86#XXttS$n|VNh{^$)z+~0GFbug+H(Q11}>IS#NG2gRS3ffS&C7z@qrS_ zS-E-I!mYt^uX!cW{FwOKTR!H(KDRhSCoSRnaKQd_{K+IN7P=AEu%Ub;s+mT07uL;=~}(=_d@T3MD`>Rx;}vST%*)(+P-&k#k({>_H5=`xM>}xYnSx z9?a=s*r>5^c{Ubb&jLAaprZN3f4HebA|&G0!~_o=)$~={l`Gnem$8GfeEJr4uH=~mC8n=uF!=;1=t)Q=slp$&Eo0}O*g5`!y{erZXkw2L$hyLofgE5FDi$ioN zHMF_!pNLPM+_WTJxnoFA1>UCuaeDc$H@$v5sfd_iu*Pt?KiZn-M!;WdNk>_zO(Pu@ zR2pb>m}@zU=CCaY>1+~6L|eeQyWjhLw3OR^}jJ{>RQ^ z{m3;Pz7g=O;uXUjqZbrdT#Ey<&{nz~KGXyt@cH#KSG1|a@Scg9m0dm7v1`?w9G=8W zsfdOhNAGJU8D8rX;iVfSMq#>5?$w&uNITZ|u2yVrPdwWp-Yz4XE=yniT3c%#c)ivV zBmmUoBOrz@m-@w4v^t`XUs33_bOhwJwoYHuOD-V7bdOsSHfB+R9t6m0CWs*}xxJBj zc#tHXS;K3l4X^hphX*4UNt6VJcWV#tFc?U~DANJi{h;Xzqk&GcVw&5NaCgIeB)~Va zSZ$+aL@V!t*uaYG;>oswc?g5dv6?Z8Dxl4(EgOX#%$E|lJGDy-f#eDN1boj z$7K=GS+dPUl0?78*Om?|!5{rqnnoncyHA<%Gpw>{lP@WH_X)G(`SPPqb0juYIJ0z`V zJSL5IwS{j$5cjOD?OxYWll*}i1Kgnefg#m8OrzvIzuv)5gr9)duwA1m?bW^S-de2y zhdK{FVbSDqU{!^6Z)`ZP*Ei=4ET!JN3r+_cxE+wBmd~o%>v#;BJAPl2 ze_p5F^3R+;#-S1aRrrPY<#SHo(0>P3(J?>0wtjieq(_j8~nS;J+eSh zu758KnFR08o&`dEzcwN>JIJ5Z@0;i@v6OJq71b4UTZ*uxy0jV1%*)ZSWqqO}MMyjD z_pLw-z#sleu~VikDSY5`XrJ8E@kul_P+@y1WK--e0*vB~lknWR8DsmH$y#85Gg=>4-$uLr(5TJG(4JR5|J70$He&8>Uiytc!< ze`p6nV~<;I*!|RWqFnl2E4fK4%f^!gcN>wZr=!#LI5~M7J-nmabya#ITbAR{XbMtBD`7^KH7oOp-wyA$ge^sT$YyM4U z!A7q?@VQ);KHez5IWq_HCBMDeP^{qPrWBbKB`a9#=&*i#|H!+)-VoM~(u;iVS*>WP zm&zb>&^p!TZ|m%G)(bKuQK=IfNO6IIAPKnL@pJFK^4SJbi4UZ_z(C%69Upu5wa+$? zX?!4)1qM>_K&j!~Uw(#xU>Mhu6z2l@N4t_Q3J9RrmEn>odcK!ZbmSBrrxh(aMH`77 zco+%ldU5Yw#H|w3@2Z7`2M5QRfMQNr^laH{6z{~l*8M1Kmc1Z2g(kCqHXRd1q(Dp9 zx--WSSrrKTWo5?9!N%{}7is%#8X5+xGM0@H%}670VqMwyN16D3#Z89{v$LOOf(eB| z#yNL!*tz4n-eH#XFok>6x^jxu(M|3QhEf8n1M@^5Z5Z?RLSO>dvNgjDdWq()#B(4N3+aNP~OXw&p}^U)yF}#I{cE4qGcdqN0yPqCk$!6RmX?uPWZjX~gDq zLO>Aiq>e)rl^3ZQ+6EE2X4GDEe>m++9qhUcL7TOGGgG(id)KViUJ6S%dgUDWky`n6 z86TS-%Ow=f`_`sZaR;=!N_5e=>kg5wMruxrku%qKt<`}1q-D+8=*|@i4;X2RYG&%H zMT}`f+PbH7cn>&-IWW^OVIf=5-_AXzf^Xv z!X;9;9>rEt$nF$;Ty&)SyNCyN*XD(_A7ha_fP{>oVG#%NSY?}-iamej@G&NBwGF7p z_OrF?Mv;Y@-`TaVwc;~nr$1+`drxT3aBTW7^wE4LV#UCxLy$?UF*Epn+iOTsbY@2i zC#tyzElu&yadsN_Jr&#ilSzhxujf2e5nPy8`plwh6%_BM&mynVsX3qCxsf1`^KMgW z5M~cPf0B;KKcemUsBP`U>ZUxI8G{R@l00EKOb^iChKiJ<)8m~-`t8RJPH=E09Thxo zEAu={pBGIeO)^h`w6@fAQYPFfJ~F8Cww2t|L{fh77mJtsY(*RbO(D^D(S634UgX{! zQWidYkv1N%yAM;B0^nN9UkYdgA)6I{=iV z<5g>MUelF4#LK7exvb9?+PjA@izoo3$di*80CLyL?@11 zBSB;=x;L7v9Ba*Y+p*kTH)cbANTIfg;w}NES`==h=8NlyF$T||FtPIkpT$(A8 z*o&y%cUhY3;CKIxybwK*KDYnO=sz?1&y4;vqhHO8E_lQ(u9wR2MX1OpY3P%l*AIWB zE2nUH-xg$Mv%friDJdz;Kx#}EuWj0@7-OnWdtynTj?B zPYcR6q<&eQgSOWA!Ex4I+FA^~%QQ`0Rm|d_S(s-LIJek@V)SYDMaGV0CLP5VmoYWWL`(B7vy|02hBlTZSTl+}wmhT( z7VQPtzE6n>1huc2j0L^!l8s+vtYk(1OM}l0=j0qf{hCn+{G1;NBhTo;aV&pN$~Z_NsNNF~5 zJ^IYUv?$v}xjY?OiIZ;M#q39r8X{m$a34q~SrMFuWiYyM`O|C)&GR09W(Zn*VdDnx zck@^I>Wpyjpv&>xmtFd60p;zNMOs=IBpkkOqrc)>{BwkaP#uDd8=tI??XTrDQz&*v zdl|NsWYU}r!+A1GE3a_0{ZGS9ipASbT)d!?UM7&{@T5vg{nc5&JMyap&(QlB(bKLjm|gww{=mv#&H#Kp zTCj_(cQIXT|0Az3OshF*+u0awldVZWes(APEQ0Pd)b|Nc{&v=O;!y{b!?Bu&qdB@u z6;4yM7lYw>?;mK~_i9Cay`A-IUxg=g?uhByeW;#g|L_5(IMWO)H0~I_CVcwd;M3do z*Fd^uIUes!8T~^dKgmrb4R zdj_?+*GBwAqONR0&^b%)L|j^|`3y>9$-^0q`r0QvAigxg;V-iw>5`)>{&k6%h1saT zD@m6%l;UTSWLix7f0W+z6S6=Lc{VLr**&AteMvdXS4EWx$34wj7u#O}B&uj%s#7T{ zU4>&5$x(m!&}1=H#OK?C=}He{q;@~k8l{9%PAhBe2aCz~)nU3%Nd{SgTZSFZuPc)B z%=2cI#=;9qw!U_ay<#&AzxNQQe~?N~;r}FhQ;r40&iz_)oDe^+g_}=6%hpYg!W_zc zHubB4u7&D<5VZVNA*#Qaxy^&)3*%2S>wK05)BV&O$wy|&<rXzG43UOxCAm*osQ2 zws}{j+LwjJFD)OqcL(lZOPnds!Y8uQ5?X%~(|@vYH>1hVN=GcnVSY`PvWsealmjmh zR#}HCeOGnsZq7(PpY!EiAs#@sl3CWEW>LZR*Dr!phpK|(+pnd^pGZxvLcFLI8nypI zVa)&e`3sO4pW3|R^O(InfE}Sjjow{j{D5f*?_%-!kTdk~O0Q2P_Kls_i=KpE*UUR( zGi1_(9V!dg91k;?EySiewl2Pi4eb|Rz=vS)znpwj1eh{dtQjqKr2KuXjWd~@SRs6( zztF*-X_fB4$jdB+y80`fS(MEb*@>EM?;<7b>~B2S=bzuN;gjNkhd>ufykSfXZ#NzS z>~}ohr7S_z?6irWo7()!Q12&9`}I|XWx2CO>*qe$RVXGSfUI`zO09fS0Dk}(Q8op^ zXY@Uv>v1J@a>hjK;kndBd{5&_k~>Cawp6F>d6LPm#SO!WNcx2!G;Q*-m}O-;*Y9dY zC(Q{hg78bMm6DbV7Y|;ojju-3@+mEKGFmGA{RMlUD}LP9Gz4G2WofxnqVHs4g+496 z^q__ZcStyFn;L!%qFl%7Aa1fcS9dtqjAjwPw1q!?5F;L+0ElP$_{+&z?r^03y_8yC zB0S(dY|+9vbFQ;vzChm<DEq9_Fq z=bo35p3M*~?hYY*K8cs19nw#as`yayh0lE$Bse9dV1k9t-++TcSQhXfWrgtfim>*N z?DO7;*2we9(SsgS`DuH7ecBGIWfo-??y6!Dx{WNsRqh}{{%mzDv$Q(|GqbRAh&_?ngR|^J6-(jO`uZzTJ|S_~gAOBM^8a$%PuaLC zE6VEMaDUCkvR|iQ;}b!_*XnzDPvM3!OGt5t&Nm3!8*Pm%Zae>+A%6ou`+G(nHD^uC z4n-ZNmJ2`>lWoaNMv{fJ%nKiWr+wi7cn{rtzR;nW<4suX{FU4W@0#c0!Neb*G+cHT z?eLxaTke%q^dHT`o#L;hr&dXSD-pgWTkH6-hGY>-TxJysRsXlq!}t&!bo+Ah{C!pG z{X48faD*AsOe7VtUi@{@!GCES=9#3cZmtF4C;(RWEeRtf)TNPoF|`sL=@s9UXHc)*8n8< z52L(*bo##THh<}8v401|B8`WQmB5#q#8fa+v2cu}>Y+NSJh#jgjM{%?LkSTn$RMx< z<8fq&<+qqj`hMN{5)+sT5MRIHTAI1yKR@>d3xk2)J(!BsXl(w5wlxY}n2EcKU!0=M zwig%PenvwD3(vfT&gYz&cl)qaTjj7^knc=kDxOep@yV)Gv~ zz+hp6fSoM_iW~QXsD~6Me)7<3|NMMvv%n{RiNvLI_nk>Y`4`riB*nM+i$2aKDu!bE zGl#!jT#)=}pjsI)NEnu^m|{0an=!G0g>Z+P*?1oFMX@tCIHMt{78I8!n}8T!wAm+! zi2c>?=x}mlnU263t8z9l9;@ZQ7r*lfGS(`n)%N4jXFi`EBJOUA+R761UTyqC-24;& z;BOn+<>B397Uikp>T)NHhmtR!ch=X>88O#4MCykMRZlON6U5G*R(y=!~t78e<%O zvH9gB(sKLV3)wwXguj1&K37cmhjK~q!!l&wxgPuSi9MYE-X?~YB&Oxa;guBjs{Kis zdP6j)@B^Q1h4W`bF`O~Q(C>WBi~E#X{34>tdjsg_P=S7_*8U>F2Ob*9Sh9#w=d%fEI8g0B zDDZ*x?<&8jwCzWckDV_7aS!ID@Y%M9%EV{FAT&1;g6#=5gf&r{UjW(N1^whp)aR1X zaC}a)#cOK%IVv^maP#dKlC^KgCm~-Ib*?!P)xHbq0PIdczGCx}clYrwl;& zmx~-OttUUBcgCWQeV^c9n_p$J-uRPo^$TIL4BkYsqez6vvlV1UZ`8cArt8x>x_#~J zeIPYNY7~>N+d=hf5Y&CqqtFV1dEJ>Kyi}+?dXzmjz8}aaKc)7j$Ro1eF*!v^-9xE;RzfU-h*Aj2^K{=CYt& z`ojgj_$2aHWrnLz)SdY=b%v^nChhqV96wc7zx$C5lKDU=gv>P9XN;x8qPPE$J-Ub= zd4Ow5i$1TyFAHLs4c#{G$1iPA^BXeoZWc2~qRHQPtoA={+#NY(itceg6AboHuqL_r zb-DB}8rH}Hj%{Jn`w1B3`N%(CA}}o3VCZE2k+{fMu6^zxArBJCA%i?N!%PJ#N$Oqx zW|K~}O}5Bpe7Tjvd){mH{{smj!%?^Iz3gcqmpStD1F37|@KmSYMPJ3yXAb@Bgvehm zW!_hw0Q>Wrv-nZ1AIKNxtBk;RKULP(pa^@oP)GS2q6lv~!indz##fTGD1%q$!HA#F zg%I>9e-gU=!f>O4*pI!)I-M`@tBo&vabgNA?sq(a2x#(TuPp8vtm() z&9L0T1T(yf{9s>~1P_-RpE=-=Vib)cc&)Q2<}w>(UOourn`p?_+l>@bRc>E~_|30X zZYp|ejv>hx$nBlX;_$}OT+GpDKX2|VKh(<}-Alm!kP&ujvqQn>ioSXDu(ohe~dA?ninWGjhy&uY%Lb>4M{P(RU#_G z*N-;lMKiVvJH~6Nrfv5oz80MLjJC#i#LF3Mon>G}+sD6s zd)+&_=pMg+ytek=7ya>UJe^H0k7t*Y-r8wzZFOyZGU?u|&ZhKHmXgu1@SX-J_em?&ST+_gJE~{K3mE0c-ZS^tF_&o^)eTHG5%>f&RB1+chUJU%vg4q zaow`k*qKbmlT0NyhTYk$mu*a2z3y<y%V!Z*8TRPf0+>n zzZjhN#+S3~i0I{LFq>v9Iq99s`ZImdy%^9co(v{gp&uU{^d?um$%}D!n)REDwZ%%G z45ox1N7Siaw#|0hn;rKvl^jg7PyArIaXC7k4Kf{U$K&&h@u)YNP1g>t&Vb)nuP%EF ze8p3=E}FZ;moFwagchb*KE3Fk^``R7%2IxHZ9ID3>z-so{j>3U#&Wb08A~2yDmS7d z;*az3$>orSH@ms$t(^2`1Vr}r>bndT-EA#b@3ESz_gT-?JFIAUh(Df|s-^pk^T%SZ zdwQ?I{&-Y4E-XIcA5V_DCwCrprC2|?*RYRI8~0n|A8V(TJ1q2%g=Vw2;Lf1WR)*v5 zNpG??92~7pE=MyuGEC>5jwk0#T}(12WVNW*T??M+!f8rJ)O5Q2NPx9i=)63y7 zR{8~jl znGn=}e4IG`$D`p5x8ZysU&KGboE+SYj-O4|r}W4E$a?I2$3*nA$%}k$Hg>wjFPx%= zHnYo_r%quaN$gT|>%Bg3UmxK0@1wP~-1^B0!NFkqbUf>vUtl+mbKAM&?kLB*Yu4}O zx|0bN0GQ`S0E6z77*urO@$aMFM{eR&b=6e#-EOY;k@nQdltK2p?&#)+AC{=D$7c4v z+x=nrv8sPpz|W*dJ9WelzxiG?_<#Nn28eH$SBJgP*{q-YAy*&>z!>}<%*KoNfN$y2 z>46yvx19Tt`}8<>ITFb8B%uQ%`PH*YxC3aybb?xCh^9Kbm&4g%cX-)*tl@;-{yw4( z?q=#4!PJsn&vHT!iACU#-JXc)(EZH)JFqeM757Lknx2f<;(ad{@8AE9E#CL^E@}DB zyBDG*+9NN22zBwrZ*Rnuoj%Sj&1kNEd$XMT{)gO4?w6RF8j}f7P6wii`OR zN?l3=seJBv(xRe=y)G>ucksE@!RPZ}?Jm6wLtOU$r2*n|vFy*Yb~`I9&c+&fi%vc^ z=K+DBzW(ivb%(RVyPb0Pl0J1iZCdOu13vvD29Ie^(I~pBSLpn+(*% zG;Rt| zf_gIk^)I^pSMI-MKZwqvfuH8yUQ7sPKfVPLc-yBbnGrd*Ivoypla!W%Z zDhD~j-B0MxcW6dV&y(D;D3(L#mrRqu2EPpmdr;nbtema6VT6%q)j@$y)AW zJiHW`OiNMS~F> z(t^BH3qm~@jD}1sqVJR5$t7{^vvIC_H6GBj-0^TcB`*E3nU+a!N(6+cjR%CZ6>I5P%0E_W}asKF759ju|(6$ z3rxo}r__!Cs(N%hygcbmy>rPBu0)J66{D&UbT(syQLlG0Buqe0;)fOhS=Fb=>SZ;A zQ|ewXI4$ZEXOoMD3{}HBqGypgx?-RMf4*d6VWt8Q`0P|6J3?ui+SCJn@qr$FSB$?~q%A9i%S+w7%>gf)LPu7i zqj({8ycg3LwxZ(Lg0q4%^5tmo!KJb2&}8CSv70UjAo_*^62Y9ii^p#)vE4UJq?nyR zDYAmgrAhB&m#JBRWvk4a?wRZU)G2p9p2(-A9=iQ4X`TcUH zX^}P1=jx2LhR6Vq+6}N@&6}1ScSk(FT70SoBS>%8XYR6lj7K6A*i^kHIaTT9RQ7C} z8_vB&(YMqfAy2_tu{;HgmV6^b&A@Q{dZ~MSOnX-1+qcK(7jKuD1>;)Rr_;;x-c**Q zZ@bgu-Uy{vuzQj@XE6_I0|Y?^6bb{u`NbauEM2Bpjugm3Kj&-`jhcBA=>L4 zn}sa>{_RosWO$PklOwwLIQRRv^fBmYADrfKkan*;PG<1Netb+%xyyR{TSE~N;bo6K z5*&lrPng9snnVyo&=uwc*~Snx8JzVAVfLu6J$i1}>&}JCk`|nP;l5O)=I zNB>3R>@wd#-972iy!B{prp!k$0rIYUMesQpT!6j4xh4RJ1LmX`=X`00QElhF(JUwi zlt+e`0iXGF1QMt-pOeT~)F@AoUblpY-zXGK_mX3hgO%0egtHq6A{jA;gYNkk8%M9p zJ>^kk9E3ttkzg8ge_#(^K-+b)G8l=i@<#$Tk&GrrYf<~m_SqCa4OpsP>CQqL2iq?W z9_LQRfFLnjjK$3gn+#+V-`HYqi*LyNNW627P?$T1 z(91BBpl4D`ke30r#Em8q4|2S$Yv?~hVgkYiPZ9H!doxf~zkV$8Gg0qF5n(ILBxm@GxP zbS>3mmRT80`*(tdl;!(P9JG@+s%w_zK~k44Z3@q0LB%a~BoQuu?mXXkY=oeM)q1QX zrc;4W?INy9Y6nj9fX|~|?z$&ox!(mOk7aF)8!wqmd#q{dNsPOdOJ|)MQi`JvD8}t- zIllWoSJYn~$6x1)1@DA9MU}r5-dG2P#vK;7WA(OC8$`ovRAE$??^fxJrGc?Q_ z7EU^oYJ_!EkH$E`33g<4q4_$vJQ9;TwP#E``hm|H7YSvVA6a1n3|b_bOTdJtST`P+ zT6%}MmF%8uR6){jD;oFU(dulxJHGBsqVBY}wESk-WuE1f+ALSs@D^0_a?%3eUBcAM zeu>hmTe6p{Qs^aR8qPt=5WF%T_2~Fqxh85Y;qbhaoLfG3n55_96^%o`BTcj<(1$FvQ`VQ+W`{kZ>R7bF}N07X*K6S`Ev`)1p-+RQ@VZJf}^zmd^9Jt9))r za`F1hKNA)P2g13K-A)M>yy@TVE-?Ej{C8UcBC$hjfXAU#IA5L8642ZH{pWr$&@VYG zsG3{JiS|BRc8AkA{~6TNx;W=W7~KTt(ZS;qF^E&~Nb&{f1_V||i8!QtC**xh!YH5FAE*@V_4Q#m0mz{D$J$w)X@%>C{Uwp@54TQKowG=E{r2?j%52gdP0ueOG7+7! ztqT$jST4_l%VX4E$Cr}{HM1Slf?2|)yDiVDUX^?@zj6vJwbz{;_m@QNk8{H1E$<;C zO-0!zY+SPQv3JZSG(W_|#5{R6-Q>~X!1$BiYL9AInp)zZbAz4bc+az`rKqj*@#tqZ z)Y;|zn`}7L)p(Y5vT}et?xWzV*jglO1a!X(cDe5faq0!M zyjzx~g#t0CU6*)Z4_3v(GCK$J|I5h{dr?etQXbsBdCM4LFrvQR3ONX*9V1%Fi{5D3 z)9anE>$;;+uRFxXQwNAN8kgS-*d7jvh(2lehO;j9@Nv$ReXJ%;mVcaE%ml?(C%BD0 z)?53}__=+85;WtqCHt!rDEgM{Z#Cl~%6*qB*&@^KjU%uuMKK zp9p^oGXxND(|^;i-yfEt#o!hrIs^N@l=Eb*JX=XatPMMoq(P%|w@r3WBBZ8`_tYMJvU&>O>MFmnW6s5~${gzy4jtAT z!V0~Qf#;_Qh=3u5PJr*_mJ^5{_3O>c1{h=K7Kih|*~~9AC!>WFF43*n$+EcI3ftxY627Bm zHJmxxD7+R5so5BRAAQeVvRM?z!ZN7@sy0KNMQv zXOqs5w=CE?h`lgFmXU>RqaHIK)GgAk{_Txr%|&SO8qRdX-gL?~E3ia=H|4XEEA~7g zVpSVny=$!HM30o?(UP_ni+9X6m-i<+u8EB3sD>`1XHAdLlJlytQj#Ng*u7HSa<rPeqRLT0V8xyL(5O%6c?2_n)#%@->xqA6G89a2rmUQ8cBN|nLU^*EFqweshF)b!Y z`0<3uclFv4Q3q8Wc>a#QrF}%-C5WU;q2gj=nZ_UG_}Oy6p#%zZOE)8)K0i%V?Vn4K=va9rsnz&NAk z%hnhg>R6CIo&qtT$u)W_i#<&mT*46983?`B2u(# zLwcguEsm6c^)>w!<^Yfh)6jpA=8*IlG*H?k^iEPC$?S!@cZfj*eL7uodL_DLxl%H_ z(&Z_Yzz0ZUOdxGXk8UjCECcGKI~dJ~85z%dLaC)FiGP7hCjuhRS{$M8I(^I5Y`zQx zV9!n!#6pZGG+aW85a*dl0|OTL2(1oGL#O@m<&e5V9eY2xxS$e@23c6hmD3Y>hHHip zU3{Dyj*q*;9u^*^X#K(H{WJ%0>m+yFCB{`&d<+9TX*hU!aiQKWee=z-}L?g3uHHwz0q~%y+S!tAU>-tAF82*R;lImvZ;hFYu+9zc zu9IHx;y|uR(8$3(`$Eh10_)|g@EnVWuvE}FPE3!LGn1-c8i|>X@*X}#ECpfHtV}YM zy=ZQBbHTdMM2`r8(dL@BC*W5PzCye^V-`j`ngx){A-x=E+n;K0Cl(_~Ttv*II?CeK z)vnygw%R`V=-O?ETpny9bq<+k$z*N8>KQSHm%<8lc3f_*!OC_#?G9Hayj_OkU<@SgWcFz zL26NmRUvzbxn9xB!7tDV#8}q@Xd2jxp8o$10=p5%Y%>ANL`OUsz~D_1n-U7p73WZn zP%1r!*Qp4aY!{Mol-<}EhR;^=A_+l` z-d2^-QiR_0xO)LGKObUtX%yWP9B(IdywOqko(|fh@$f_((!+stX_`u0D~GhS_TAbU z#6JILIC~@nvZ@=qL)_$-*-l8T6<)G1N z{L9?GR&qs^ZYz+wU-0Km70iIsdKr=Fjie`0lNgYNa-$Y$w-#|NUR| ze`?@g)PT5I%d6UtOw~s}yw%;GZ$dSj!G2RJ67185A)0MF>1=_dFb8KJ8W>L+Y~T6a zBlR$${-cEIfB%;7XRIbXOA@~h;Fiyrklo>zJ^J0*tV?pU3F8r)K$#ky$?xB;EJh4a#q$IH=VJRB;@`q{VqA!%%Sq*b_q-t&BaR z6-810m>a8I?AC&B(_#-OKM0nsfs!G#h~XHSg9B#Y$X&5Kr@9w_D0O5bSc40#s@M`c zpi_(AaHq|Q_AQ3bP^pF$R~FDR=eqB^^c{-47{9c>4y_u8w`;je=h$c&Qeqq;B#hDp zJsaCX|EXilj@491)qU}!1tv7nsfK=U305$E89jv9k%ML5du4f*r5V_WOG0uXcI9%C zW4rqB*+e1&BBf6Gi50L+PDenaGL6}3Ay}ELVc9YMm(!#d(9!l!ERP_X6cm5#Rh0@} z>!TChe-(*Mo#saToxtmB80MgB)8#okL_~?xo1{BAvl^Z{?Y@ZV!USDGl+ z1(kB_TMzv%ZFC2dA(2K{;$v8!^d`sR;NYV;ZuKm7^yLUPBe}O@_VN>k=O8BD7T?lI zGSNcjL60ppaa_^4{%wx!G>U?h54zb;If9rzt73{%k0#LL@{!2ck_>pKn_JLmFWthd zJa>!g7)Or4!5}A*9)nIv*XhbS42(O7nvuMik2jXrRnTN5ZK32Otmd{)a~Ivol-c#} zU`Py_G9=O4BZ<75jWwvbbb^W*=LN+S%d{*hHbS_A=>}#}JQF}N9}5fe%JFIw zgR!!YQ6IwNS&r(ZWgCxr3dKXzGa75iC9-`o=p}ipv3K{n>aM%1ErP|}=td^xzt8I5 zr|Hf(h`NEzXhh3K3KNQ8mnuaeIFzUh1Ogqm7L9zQmnDHn_At%SJ3+jPK3O1`!n&@`Q)N|Qp)4EY#02wd*UW)7$FX&a3pfV`fGuOsc?Adw8^=w9O6%6${zha z*#p8X777LLEvy=6J$_p&&>mK$y<+|G<-`=RG~8B3$Mg=ulJsd)Tsm) z7jlRf&tK0OQfD&vlw&UXhz# zS9HEytFD%+rj+6)I1dQtS{$7BHX!fEE(TOFFUJrs_B>1`=%^pAx}}#ijOUH@7BNg1 z?}-R=#BC6^S8vfNJRe=2_vqxe-tdS*pU9fxUtq2i>f)6OzY|OCyi+Pu;yz<@^I-Fm zIE?I5;`B2_3!)oKG&cMtwpz#N<$D`lop6No?&ug)3%~s_2jLP1Bq~W{r_Xs>4$z}` zQ-&fs2?@gzTUYTUPavAwqII20nPkCzwZ{va@bZ9HR=-pNQEw@Uoj4U2%3J1fXeYSE zoC6=q(HSJcTYCpe*u~-1y1Au`@pL*k8r}#g@v@9!j&t_5HyQV)(jEhr66f8)2%kzb z(IkHnG)4_A^$iUg3$3ASwSnrTj%Drt{#JPW=6{O$%Aae(<&!E{wv{Wto&Q#Nlh4s( zX>*Kwr7nCUONwLfH%OVdXsSsuQHFpWb&v}_oB4eo{`k2I14#@{e=vPbJ7md|1uH;h zVde(GnJAP%n{fx;vQymN6v6OvGS<{ANrQYgUXsO)=OGTA9|g#VHkIxZd(!-fjsc#i z=Rf|)FIGq6Yef8&u6%pb#kzZXiGWNA9q#vNDi`iDhPfg?5`|MD2OSJ09ClAk7F zfidz_JXs`F$*kUZb^v7mPv*m%$V$`;@1>f3`Fanpe;>U`AU?LI}Pg#s3OgeCa`=0Acn`O%CM`Z6`5WoZOP(88ZgUH?PW zUVw8#R24ik^u$TP6v7Li4OC$YuaEo&2nJC%0g}A z;F%F9AdihS0*&o&Ux?B0wHF0nOE*x$QbuxFTN5N6d}nr-j*t&d2`|lrT#PSD@Vhl0 zx2{7G<}3IA1D7s=+1&*L0xx>!O8=Eu$x&|#e8-T;Tt6*3+Fr6%%<8TGLLi~Q3!tvR zW7=AwTChfe=fJ8MW{6nCyS)68LnoZTrytGcWv}wG+j)D0Dg4>4SY^SY9oslEpx-pC z!;%dh$5Xf}SiD}Mmaq4bsE?BoVgkRICR6ECMZT0OY*JcC36pa^eL0#9hN@as>DpS( zRI{u#Gls5Q`sT-P9L2WZw-txXOq#!SB8q1g4J{Zn_8BF5Ip#E~M5O1l&aiti?GYMW zGR;t%h|?+RNNLo3d!D^%iKxG05tnt)Nej+vaoFifqzQxQib18e^i96aTP~`)5lua* zh9HYuN+gp|hqw{WtDk`eeCIiyj zgqj3Nm0pu<4OQXNuPg0SSv@|*rTb~vI}(TAi}6oWBB7)N$KAFPN&kU(Uy3s$ZYr-# z=*L9utJ|5imsQcQ#K@R6TVLOnI-78fLVc$Q4 zb+&1!oe#rj7aULIyBA1HaXETVn|YMay(pPGWuL<2O^(jGXIH(+WN^|`RxvbLXK?80 zpTkfF(b$B%NlqNc7aYuPL>?8)d(N6nV)7+zGVGnsU@iRYqK6}I5)e2Jy!)yo zU%l_$0AhaB=<46ODT9J=tT5JAOiRIz-yO@(lkpXX(p9}Z=cyLFskFhv18b7UiJg=KaK~Jf!3i@w;it#`}^6T7>KYq{jwv2Pf zoCcgnytURS!h6o&$9B7Yr2Qc#fTk(FiQ_mxRCE+v1r0{WZ3-yCOYC}KJLL^ZF~v4!U>&5SA(t` znmLDP2~FTZUi9hegPuDc>XN)g9Df<}isW^bwtqn~%}`qWsf|^adLNH_7c)lbLdiW{ zR@0=zWAGID#ENWyiRu_gS;5Jq@9v|O0td#JI?&`-_Kor_E9Ta6p_cGGFqsw@_CP$t~2&9dyR>12zrR? z5;KWVDKaA>t=WHx1Ny)6xxs30RU$!HN~nOZTA~9QTC8?n)~VCVptF`mnA$R;e;n3D zgU@OxAZdWEPA92tVCi(HH@qv4){Y6+=B_!!3L|TgYE77y0QH)E%3CwR$s?VSdx3Dr z-2qfhXM|KDm`}7$ z2r97}8>OIdc4K*$P<9iXeaNQMN>}OyPgoImR*rOhuS%dLp)yg6m>#6N89egXiLrfHXBdW_V zFj+butJ+U#>%X@`n99gPLXl-FuQ1lJI#&KgyYgRp$jnGl7dY*`@erfU+d zOPYcvj}XTdf=b}nR!N=syxufPWk4~#kR5$@n0D0k>HzX*ge1KodgR|oyA(>rwOmy_U7nsI`Fi39F-#EuVh%`CEiL}$p*p=lZ!>o@h-joE`u#%vE;v!r2$ zt3MA3?K@{nummhZ(@Q9Kzr<48d@9Wn-~T$MQ*~}F+!oBb*?v2{7#C@W(0~uhGC6Ge z7S)w2hlzN-$)~~UY&-*;61E?Wg&F4*1|D<(C7%-sABDkCcMtQ2$xNJ_2;t36x|8|y zG8-$4#NbJ3y;lhwn7j0=6;$w@Aofq+R7Lj%sN=Y#Y8YpnL>jg&XEr~GD3m4 z(`BNnOeT$pXS8Awt0`xJ&QcnnO~o76e)K-8k~n#UwWdfQ;Z0d?qdT2}2L#VI=A2Ag zjBV1g#U_?&OP^IPu&A8*nG)PCIQI^U3^E7Q9gc{|A0BY)g$^JvXhui=DZP+$%@h+s-~U_=!NMIHa|e^&S{juqKIh=_Hk;)>jwza@L7=BO zX0P61ccz=tnvCfsF|)+iGf_0n=fKViCV=7bDRCvM@1{9H$^|fiiU*&L4os=fg%jfR zVhkzpD0c_%MX=NaR1he1Hw2(IgUn&%1GSrASr!X!Srw6d{-!lSP*b-lJD$PGGKWC- zR`%pakHq8ea$cK8eVt2@68y$rzlk4v`h|jCn=G<4Gfq+~KakR&DH*@gwt;4^Vq0L= zC!)(3864eMWmC?=uXP7_d}MG7=nQo!J0M=>ZW|zlkvr?nG()T~YXT=1Dw@Q~S!|q- zAlp*StnL3rS{Nz6<>+IhoH>Y7)b47dJmV+^gGCn$mip3LDRDp^t5H)9eqh4!gOCneCz zN$-N#E>LJ=p(L<6;AU@K1gNIk@bmc-kfwiu^^47`?yQHl-POc_uS;qzq<*pr$6wq3x_f+lc@CC??HYdbJ{1E0Hx}LC z7dSxxM=L6#P70T$3pu-aK}`oc5KpjUK1+gy@im9DBqfQ`>&F!b;%?A$R$z)v>;&Kz`;!WYq^l-2HdiK= z!7}`H6eYeM&*`$*^08j?)0AFIKpYNt#8Zjs5sCkL^s~&ezz>k%i6kNJd!EwjjeKDJ3H z1}b3z%9Z40@GS`pj9;CY#7k_=yZp%v8s#=*a9X$aB0r$PA1f(Yzo#;t(_3G2h<`B~ zTB$^RPzqkpl&f>RgT5OTAcuf!Ubie$syzr7``+xMh1t%~*37Ua-`o39cBem$bJUEy zoNy^zD#nYNVwQg<*XU8EFvC{vn}OHXuI6dzPi?_1bMnq3t9*#P)do+l3!NGay!pR( zc<(-Y)=n4!ZC+b>H-=}k6!>;2#n{c{qLB7O%Rx73-_hEao-NYD z(8od3wfpoiuI)iC@Z>(u*RjbeLdH2UW!t>zx_@u-NtL?dYo|Ak^Rcc@>4+sSprZW6NL54R$D2SM+wEk_6?cDt#Q4Mq{x4h zne0|q<19*oEYB~i==abT3u%iow45XwOlmrafZiC$vTvI3n*-1r06=iTN zbfM9sIE9QwB@F?+*_9TN;6A&?QPz-tEZ;+@sF5JhhBsRL%k{8R7oS&82r4N)6d^-RM9Iq$?S8`#IRZVT z1BZZXbb=szDti&akMin_FA<89v)zi2k<;AMm7)rQZMhV$dLcli<@|S7)*uQWW;-mh33V0>`EYn>=xcj zW_V&^b*p(1h?d)s9ek8STaH*lzWKrIT_UJ>o^c^Is3WbQZcCIeKOF#p53U9fHlDD< z(~&S`qakrc=G)mSKlpK#x=QtYC)Q&G8~_mnzx*aB0!a)C+(mL&o#KdX#UyCy$o@u_ zWrg?WxjFBCTq@f0q@Z%y-T4wv(S(Tj*F|LJAUfy#ymx}Q{Y$3^RBkQBX+C%E#7fpk z4`+hj{ok8e|B)JcY*5(JEYBKUOy9ShgJBlKwlZ#wgKWj4J0?haCgVJ^Y&M8Pt-|^+ zbaEr9hhAZ&vb4*Zr(x_2cE2m*SRAD(+T}bfb*WsQnzMXJ|MX*kwAp(xcRJ_|h5y*w z?pqcQD)JV{QaNZmfTJR(^5ZatrC>DZd6oL}GYqW#wEzRBm7j+Bcw?gKR@$TdR&UyUbj93+g#`M*Q67SGm0v*$hZ zN#U-Q?}MkzJ>%_;&r8UrF77k}lZ;TQ{JYBnE$atI%PLh+*Edx@iqUe3`Qtz*TJFw> zc<%KQ*fr2k6N;9oTFYPhu~nNeCUuuFADEaosw&=ow)3@c{f9AdOqyzn{jd~FECv1E zGrMm~$9CuB(!0GEO2OmgbTZTa;B>Zdt@69%iV16MxMN@9xp>+=@5LfD5Umzy(w{qy z&8I7&Z(@PFj*}oWAC3@_5O*{gNBQ^%M?V*u_Su$0C@Y6<7zk7cWr80yOZxc}NW?~p zn2JX0!cO+)bLHL6rvx9UPMFacc5|1`mr=v%w=1eLtxaOBO%j97*ylJe0M1=`p%PE$ zRkB48zJm`LQZD9o-s-$et~);wBMg)2h_VZ9h(~v#B4$XdJBLw2pq8@{L;6&Y`cNv% ziQ1mcAwCGL*(K;!P!I%H?C5=gSk&E9;aLIc!4P;rxP(u0FQ4y9Lyw~#r!Yg3vd3Qj zL1vfQy&+CfCLw?SmNU`#nHskRF~G&K!GuIqIkM(0Z)9AnvEcgEq;a8C`6 zDVUzg=E~m@68N8-8!!7$LBb>_Y@j+6a!{w27X#*T?l&s*qX^xe<4a4JE}p+Jj0LBv z(OGKLKEzS^O>BismSB+&SJm-j+?6Ld6A`fjOFbo^$v8}Vgh*tgH|LTZ8@McjU$siD zmj|!4gecez8qjDQ?}to=lDQv9g3Vp%p*~G6ujO9#6n>t*A6#&F4--a#_74L)3+X@< zA5VH+7*z4T;u{vpajD1ZT;Jf^7h|y`&pWhN);N3N0qXoW59`JFus1mxPkU>@15%e> z;(lnDL#o)1yKIv4eXbd^#Ih_SfvIIK3DjU)0!aLi*|KCN%QnN_y+9f}?!k)*&dcZ|8s<-QS9(_=c*et~4$oX8$Mn#`uJ2D3gjK+6yQ)Gh0; zvq<5HI-O0g#YX5br=2R8Wi+pxgx{0i#gHa!Y3=|1{`>S_)cV>WpHq30T)Dl>za+K6 z1o(uPm(B+wNSK_jZ{N@+u=K;q@U>^A;NfXl~T!qc=xVF4nMUGP;F9rs&+1zu(>?=ilxi4jEuY4}=hNwjgn=Y>tL@cOZO2G)wY!U4zZ5t09l8s)JQvq_*s zoDT;I6fI;RyQGnUn@>QmvFqg=JXU3DnVzW723b2kmLgY|+-x%fy<6#KWQ>u=qV83B z3+_Ww8vI--k{Ow(vV0?7jF|s3beQuMXotrxX<}aTss7lb7|iR{)m6~jOLAeRg6*3V zB?VVpuR=G=-=xjx1_2(=sZOoyDzz+TV97dl1t)-y&>l~)!19VfIYx*t_TtH%5{4Pj zULhKV^%)FqgX!bMH71m{L}M5DL|W%3m~VHP9Ee$O3ocPq;E2F_UBmZMQKEw`d(PVw zj0goEiyo|{?k?x;#pT=Xj|!9$bPKv77hU}smtGA%ESVsi7W26z`NAdn94g6W_be7f zhRZ1}FMA0L@3&3|$*bg3xUpqj7MR!TUyS=^via$yt2InuZu#-^UiSog3qBU@kJJl~ zS6z2`)pg0MN?tD#(<_wLa?Yo@XHPr1-OgcWHz~2BDEQqADOJ`ynbW!N^w_8%d()fS z-`@P-Tfm39gMv5J4mr~E}rH`2-4AGK)K9Nr5Yh#{Y zj)?P^^$1dW0OQ#l|38SK^xUoN!?*oF8tzLIH>vQDQgPye0_+C}PK>Yi+ z2bbsP-3jfVytv;T98JtUp%O?_#uITI$xm*kv);MBeL-u-v$*Vvw&Sf+6`I;eJKMopQNuB_iOHIiQZdl^~?;2EfiyASI2_7ioa0( zN_edXJbHt9_22&%%>6vXtL^F2@$A{o65l+Ied&@#->3l?aTR~(iKfEK_+p$0pZwm3 zPB|oo&dce|%E@>(4X!y#5RJBS(?bYYS!DbkkIyE(-e^SxUl-4@?vLgACqM{ZUvQ!q z@lulAF4(E{!1L*_*Sny~R*-LSg=VEYO9XM_za5^Q#D#b)@x8qs2~+$V*YPIHq9`Xd zfqeXV7o}xh2^OhME=QO)qGuA9;^{ai?_q^8zUYmdC3&{vt;DPJl{kRNsvql!l$^8J zgvttRFMH>&TcC;Rd$|BV=dofpEs3CQM0u{CBhwnYCoqiI1)AiMZ% zXoTN*ayc2=w}WFA^k`yW6i%LL!Haas6%kLxf$}(THgV-Ac2fxu&7+*283xBqSosR^ zNjVz6lqp{GOu|ckCI#{$%cDsw>{hTfzUFYof|DP=SB`!7-mciHs;5#0|7cf9OVOnV z9!>*MvaXnZ-E*^?`=P15u2lc@_J(-|8@I>ex}?3_F4 zza~B2(9d@A9Jm`oBb}7P8q(_EMA`ISip(7Z77VXHT3~@?rjGoW0;({{|H#v0^eVut&^r<&L!%GD#vdn8wy*sei0ww*6ytBw^LuARyYZrhjaN~0t2^xlIx7#`fgm6p9wTMPPgfN?GKab#dMNPq((>a3T%&mFIANh%7LL#?ZJ8=| z<%gUSHp)jz!Y8nj&zt-vOR12?3Rh_zld6}E!Zqh*sY8`#kNWR_+*=kNhG#tQmz2kn z&n(#gX+$PcYx}Q(WsMni>@^>5zy1F0|M&m=zeMwXpvhx$#ik_G3@|-RgYJStHt8VYPq^nS}m7XR;w#z z`bYmSt~RT=!b)YeP+hI8R9CCHB0sI*r-)LxsNxO&9+c=!uCm(96?3(#Vr8{fJuc){ zOI7?|{I8g!2Suv9fQR@KmFZ!rfG?|bOP9IYD*hac)^nouoNS%`Q9oB3)m(YCfktz( zae7fh@iM(%Ez?(ZJfcsM zYIdB-sq@@W)wQacoWsU(N(W2SFwGHtLNDp@Rgs?G{{HRS57v?t>nK~GhF2R6`heOg zuNIp0A$7fW*jz1DsK52*3g(dpU7>+gsBcyND|%I?%hghodRJX-l&`2%jrvuj?$;_* zQGI2#*`z6|;_vNVv79SXx0>nYg1w;uG_&=lEIV^62S`uK$9L#%s2f+9-;(M_E!Gd7 z;0Ns-lfn+X*m$aqry;Cgaip{H)+E(>yrPQw- zR{N!^TEBKx>aWzUYQJ)uBE#@t#$V9GQrSGTU&-eQUr~*>=QN4s61H8VU!v)3T+u!()%yH<#ZUSx;zqn! z5v9blts3o#EAdEta)>9lW=`Zd15+b95K+UG5?x?;>Y6%tz}IE~;zHgw=(k}Fj_>9C z(4Sw=2{Tl41VU;Ec0ZkEfMpiE8_JIb;YJjoAQON8b}#~SImY3`oYG?<&_3=H`R|UT zoGTMR6t9Z3&a`p+#l!Ni=hS6h^)2d7F<0pqOIO9hR_)jGa;`+6L$F-3rs;B&wdSqz ztyT9Stzad`(74sKt5jJ^^q?*;SdxFjv4$ov|H$h+LDH9Pbjk$q^?;hk9H8uQ+&$sp zixZlv40eE6ZL<>W^n09>;YgDP{2m#Uk77%d-2!USHOCVl43#z;2 z)k=*k!C_GcLd7RFf-C-0JuEhlffEQB^HT5kzb1HOAC8+>GQ1h^Xxh)pAXlffcESiA%=2dyCF|6e1 ze=8L{sM=6Y(-L06b4&~XyHqmsvQF(6bNnOsV#1_U?MW&5lTy@^(#2%R9iKWWO>0v4 z6l~mLA2wI3!>TyJwg6YO;|Z2%(^PlGTbh|wx~kGd(KrZ}hg3(7rih+8AjgpP#}TWG zUHBm6vsEXokA|8!Mw_U+GF)lo#Q%ugz@RI|T@)j{xm7Co5G|?)T)MLiBv7UEqqb5* zJ*bAxk(&BP$f~wWliXab|LSd!4H?-8E><(pWiV}+bfK}{?(o*rTe znM9!v@IL@(HP^tjp=cRU+RU&;fV->pA$@>q>Dw}Ww?b|C$U{i#9}8i|V0hv!DIM6f zU4|=7>J$AtM!#0eARw7otjT_Yo~o?Wc~#20&0LNC*8~*@+AX4ms&i+F5+eE#7bU8T zpR6`{0qJvsbKF;l)J~4us?ft?4nOp-Fa*g)|BgWiRG1FKOwl`MOpqZLF^V&|5RRs> zLZzYbH5|5K^S6J^KMZ_4 z!VFMjtAc}%*tv3yhIrO~_E<-z7xCsLzC7RQ9_AZj~ym4T)DKVx&NPO@TPtQdH#gA6pF@u1xGEO(|5xOLm15x-H+Ar|prQI4M>vBYAIF8^(gUN6@ z%W&8qua@iJWa{*3nW41M0BKRDr7JXd8=xVHwh&cq(VWyGVxj>V$zg?`9ut>PA-=0%{QL0H$ zNj(N6ViHPxJ`rJBB$}cL@`v6M5m6ExSAod2as%XAy~69oTdL5!J;zZ;WN-y1V6jiQ zl8z=!e*WrWL!{b;>;tWa!9?a(^AqL0YvHsM5+=* zc+f1msG%VmC4jnA9hR}IHONm2H6jRa_ew>~JQ)0D2~JZOZt;iQxGFm;Fq56uDoB;FesU@cd zo77MpVj`k=>VOYWp501^Htpcxc+YEJlK+w@ZL^RPL7-JLopvYu5s0}fI z5-(wOizbCeP~=r8aKlufUOQf`GdoG30WP70CF8#pmQB@I)Pp%(;W=EvBw}hHtN<+6 zV(a!tcgR@BCKvcHV0wYCm|9pZd6FR-Gtt0=1}h;1Uz&^HYaW8{V>#=)yr~F2skc?Y z1}#{Dsk0JDw(3+|fQZd8E~+p^D=zRXKETO%IE>-dYOM9*A+LV5D!2~(kGY*HgpMHM z=wXhS+|X#N-e?=%VEc{3YJa6co0zsOUEolpC*{L(A8dA+{xyi1yWL}~fU}ckps-R` zmqdPYK|Tgo%yq(Z2cbiH>upYeK23FnIhYdQQyeG7T|T;KZ`Apr;B?&T5JJP7O@Jm2 z%Q~={kaZMriKkc{aUq_8Kg)@dHFdU@fID$rmuDybUzevXp4&1A7=`vmvp+77`zI!= zDPV2NSQ|PP8o;51)`$HCbLSpw-i?76h2)H*Q ze1gXLL=ZBp0;reLF~brw1T+V^;&g>C09FKT66zG7tuSR#uR}sqtyZl?0*le$pZ*Hg z5po*(gA(F-GiS<5u8IHP$D7IS@$3&tGx_2~h`l44Cc=!w+f{K<=0!ZirQF?I=Uw=y86T&c4( z8|PDj4=J3{)DTZ(tp+6st!M$WPCt#+8c`0#3X6%T?Q$Kugi?VTXo6TN7O_NiI-~Hm zQlbk8#hbXOLP!s#3w5GVgVKjruS#@EksGZ-094~%@p)EcYOF~E2UY;JS!N7XD}#cp zt+1}8R&K1YUZvV3QkbYBP?NO=PhY882klb@tpOoZrBbKqs}?aw4d|R|C6>c6l~k z@swgd%0%{*LDPVgA!@7)`o08u4AR01kV+Yi7aC9imC7|tA!sK$J_|Koy)vK#R6&(s zfu@8BhC-d|;W=#btQ5IltgRqArG$AU`lBicYa)5dM6s+EE0Dm{noOwiG8T&vRaJ>h zWmqEsq=ljxEYWVL(QMFD?jJv8kZm>ql1(Cwz%kTIU>%ALR^35D$cx(m(O+iD3BPro zuLAQM%>s*8fQe`}B?t-#Y+(9o0v>1_G%-Z(LK0P~VsDn9dMok_mdi9c^tlAVWu*cL zrSZ`GV3CQEqbg}ND?)XL2izzPg{H2?TcgCIs>C4_xF|t5z>F#{(Z6c92+-x$@JBQUF;_+48CqI!A5s%n0NfNx#4}WY*Q&Ja zgt##w4PLWSmEjpE3>;6HrTUt!Z&GVOdc~al!zutkBer;>*t8l0ONkGQ#0@k-)9{b% z2KEi1Gis(*$3O7}x(6(9OtZ)c6M~USvnj8O(34Y9%pksOn6EG?#HwPp2ue#;z%Lp> z8{Jr^&?gY_gsFL-7HRIPO&$hKN3m{y!3zW)zkW>U0<3TyOAB%Y(}j&s)7AB78LLxc z^&V(G@kcF9wSaxgOJj`#pOyLKqqU(eP7PIXuz*u;)R_RHwV};cs!(gdk=2^+VF`;> z68gom{1xx$7_4J=mK#mCIqKCObu zEkM&-WBRS8bT|#cz}Bk%6cVaJTffpaDYNZBt%QwPWLZM9iIcG)j`BKCY^hl1Hzk}O zje1o)TCra9VOL>NuvusIdsSZY>nXkxmpSV(L>y&mG^y=+tnFIeYP%k2yJp(1h1-^o zeZ<1CJ!3p5F@aa50(7R0AtV@3nG(^+7_A|Q;)->*LiF$<3la&0bImPJ2CDR+F_N}P zY{_AHt9eEA=&+un|E&lmBG6}%b!b%|XTKVZM!gB6?&~p35rq#WYo9qp>DhRE0(-FD z`jFV_hNia4Gj@)b*hq0Au|!% zshy0baSdG=9JtSxL!eC0BxjW?Lf|0TEyZPBt<-!5{}x)Yrao-sK`|9)4*uoDc_R-L zVqI9qea8;)c@%4Zq2>(}(>w1DhB5vZ99z1?wa@k;E5zkM$VkmLgpjDQ(wK@1V&0(X zWceFiTooZ3gglfGPo1gMy0jpw)~BpQBYI~=*kV=dheg4diLJmgo0aNxMaXI#p-rv| z>!b!-A;ChX3c8o6j!GST1!SCr6G6MynWzz0*k){5#TGvNx2)SGj9X%X@(K%->HorT z3Uge8B&p2A6SRs`aUnQOrthG_ToD&|W>5B2eE(8UFppPN%xLv?4-_b9lEdN_>>Q*a zo4_2+)h7SRm3GTHt@~_b=O>j`h2>%m;wz>4-`}^wObEu~$TCfv5!MvHf7|=>%zy5WP zRiJbYt0-a*`}pt>4}Lu_uz045Hx+&kQ2Uk8Hh8&0Rao>1$vM|AyMd0?`&5*gs1J36 z*mS=-Og;}&3_Z3{ggsG1mcFUTlAde zJ@f^SRKKF4;w2QtObYTW)rMx;N^&M^XouHfsHZ{Bf6c52%_P>LAJZX=QU5WFuWu=b z!zNc#qNIu#Q2|B|td@X^A7%)a&_dUDKA!j@iW`4EnAe!Yh{vC6n9PbkG1|_E}@)Py%HXB-W6;THu!%I>_ zLC5lHQE2>|yCC$2;1!8fqg$G%8l>zE47g}Z*G{`vV`NE-qiC>oLuI#GE=8~>rDX)a ziAGB39!_|uvMSK;R3LzZ+OSM$qF!O-R{^t#wPKA5lq&^*RD&gJL^zc}#Z~dA38`Qi z>J6^0#FZbTjyg+HXhw)VZ}2vQhGkdvF)$e7j3y_&NgM=(sR;VEBKx*t`c{B2i2DX} zQ8gAdFx4-sTRGLOT%cP+Gjl`;)zsAKxs#J8t5w4norH2!%r+#dY<~w_|)-iPy?fwC$ zz!(KuQ{^AD6HKU-w1Gpx>CEKvJSHZAmFra##72ztEW!rxupT2fVH;38EXVX*<$#{6 zGK39bvEWm&cE2u%!|5?RSLvAbjTZp;{qhwwTq{-Bfe`Jo(!fQ(dRQgCrp)TFBHow# zWkHo*RSDa!6pM$f93V)f*;pwDn~YhvRkkECR@$mll{8o)1^cDLdcS;#4p7yEL+Vr? zxMGi`_ukpy)TjFjFzh&v# zR)#EpXFCZIQ`4LS9#>tU$g~5pvNAFf;5Mh~%ybvH=G_^Y$pJ)Hrsp z2&od6Sb>s}E$GX%k!k9P(UWhsXrvYSe5(?s8;8W0U2=Q?9{X^76jw+9z;T+^p^%Wv{g7W|Mb+KelR#6qxLS=^K)n*me3MJ+D0I99O^f;%gpjaA})f%L`EOcZI zLm9W#8lUnNLdnOh(_Cfk7t1S!&VZMu&#Jv+VrOvr;zgk$G|VUh^;iu=9fUcR1e1;_ z6BXqeZ(u?uscbE z#{&`%rXUa-ml?Xiu9bNnK#w%5*h zoD&wcbU4CNjiwB9j!D6MRB}XOZY1%Z$(;CKp|8Eq(BfygCV}UCU`3-P_T!J zISnLz2}aB<*4U~O)>F;$iVZ6@tSfO{Ebgq;R$1AD#w)6$E2vsFUQtU81Mr#v5H^sZ zUJ<>?twWDc%drtd*)`rjn+#6=n0~nI#;9FvQ`)4BD_8~qZ`ZB}Mr*(BgVeE!~ePB?ST~%2}R=L70+_b8&%`LM%4;U@+mv|Xi?g}kc zsY_*R_$Q^H1!E#%TYA@dM--TEP<9kKw(a3cAaN*YscoqO7NS~NQQ{B5mmNY#O;l=~ z&jP$-`3T+6{|U|;<)JCedqHgo5MH1wq5I;WLl{vBdk-SXfu6wh=2*5%Bqvy1A{ih_ z=1+v9%N8->uoC2XiH)0E9qJ(^%$uC?E1tVyRoH74tGc(Y;88dn`T$WPkc6QIQAM!W zU?^Z)$|lTJDxk#5Td;ho49jc`1g-#Ey(VQ{6_~kEvw+U#6|vxlFt9?c1Vwe;u-cqQ7E5fl~o@*nsAYfQ;qPQ*pyWX>oz)psSi?<|ToN(Vf*M z)a-?tv4bf^4K`Jj1PA<7Ud|7125T58h+XnGb4`PES6{LjanFoofa@q6hlx6*E-6Ps0zkkb`T!hL_ z+%uMm8sHOW7Vn+r7uq^zVbJY6h|p8JRfGi}^wBj875kLPa4;dItJrk*$A|-zJA)`c zH|!quhQ^1FZ+)H*`cAf&tE~zxaP`9qoLS)Fi*thAn2W-#n9kqTCcSP7BdQuq3u-m~ zDO*2yL-@H#2>(L?rOng*3foUNgex>%^iiW^2Sp<@wEOEh&YWBUhRIEcNeXq*`W0%$ zN5AfI6-77@HA_`)&6U-j4u%L0d@&gu_u$!N=HL(UDmE23^I-8d#Ga0zq-NEEFfwE7 zVptNyw?$oY%P1)fg&3O*32_~RvM)pMBrNGFsNaltMSMfYIej!FOa)7E80-Mz_@kyc zkR^LvVtN@C82r2hBXXJ^Vl8S=!?6iEow%TB5BQnzE3e?4D1uuqBrfZ>p*cg!!A3)e~?R^)S04=#ku4ch&{QicM*QO$GP`bTs@T%i+1)eZ3hy`&Pj z_@J8Mf2s>*-G!3s0$==kE;J2=2bh7Xs9m(JT2}4KR;xU2e@hc5$UAyPY-y(bI5fbD zgulS9)|*=I>73ZpVoT@bmKG0D82@tmQ*TeNh)qo``^bv9i1F!Z%yX16QH}dp7C+ER zlvyj$+@*2B!oClqhC^zrx&_Cqt1_FX>o1@kY03{!BULEAfRWTzv2a*lZS2C@5IET` z4dFQz>=#k`1CR?3q*`u>0rEds>XgLOU)e8=>qjVuLv$2)ugtS7wr$nE=I+8*8>YC} zD1GcCk*k54O`#7>6(wM+tzykQ(xqG^>2zm0yBWfB4w&=t|0)#V z7pZg@g#wccS0y6-h=GQm`c_2>6#H;+ub_w)9df}kF3TC7JDX|Py@bcAZ>Ldgvb}Kq zuxu%h<3`Ah6qi{rGgtLn!PrA+QDx6pV*8pxE~Zs}!uTQa?7Jd_RE07`o9wJnqvNtr0Ha-~2_hXHJ(U`?9c)%xD6s7##7qU)gTjZWREDmQ zBe|48iZcgW5F%D)3c!`Z=9c9y)nBL(xwKRf|i=BHH777d4-K_`LYkAHPHKXeh4?V zMj3m!cm?ZKV9{cYR+b*HyG*UZ&&${X#Uhl=r3$g_bmTC{UF7l=LY~cU{}>(*EC=UPN-36vY%a(0k0&k73AR;^6)BlL!s0art0EX z*kICiiDgGbG_(055x#YruV%dq6Ljo#{EEUQ;V)mUuyb6UO+kfl9%3zaD}Z8y0HVZF z-BOut^h#{9&5KFRundch@Mvl)>@!fdu7Oyp7-WGxeqbhFudy*ZrlZcgu8i0jRfx7& z?ZSrab#^o@Lm^YB9Sd^3!hV_s_GKvn?&-QA0i!6aTp4ytFwp0}rKy%jEqZ=bU1}bq{3|>1uJk4!s2b2#7}LggP4n zRM=M%Dv~;fU*LbMH4$$K4vhs4zCg=fs#7(EA`0MFOg5`Gjsfj3`(o)*Wd+iuf>4sM zjY3t}|CHH!y~#R}a+erEu7Ns3EMb8ov#?Ec6F7v`KeV{z2HZICD~yd{R{$Gi5Kx7( z{1vabX*z(RN2#!4VYR7hf@iCZ^3M9Rz0nzbGjm~gb|w{rpqhhy?6!_ zE8|3|P4K411kduFwCwe6A%~}f$JhN%EuC>GrZb*u4fO4Kk=7~odpK~VQ~<$IDW=(; z8e7Vkv*y&)BZNaKUtg`He!f?gA-)=(*juvqxv(%?i{LF`c-aWUry{Zrz(Pcj(XBw9 z%{oo|K4g<&ZN*TCCGbNn^JRf3gmB?tZ$u5E;T6&HifUbUZR+-9Xqw!svn&Y5;OA=6 zA#TTK;}|hf<_H3G#^OY55+b4V5{(xKG1LlBCN%5V)O3yjrE`FQ0>ovE8yc1PEBk@} zlJG{kBF<5m2!MHQHcH(J)T{&#!j`@Og(Zvuss%OzvtNO5D!`8ohiRd>Iz2tL zQ0MsaBCcR%hKNXFXos#Kd|n~$S15%J>re!&R3YwdDsgX9i+h{KV!9FIvl_zGn6ZA- zH8sAkOq$0LibO{yHTp>M$umEEGm7D-ubU
      V7jB(ESj`yfDH%m*xxyZ)VMQp!V0GcubSytt z4QZsz;ZEU{$KehI4Z&(^sd~oVVEVRVG|B3=;#%~a6U!7+*1@)}iI|XwP=S?%f=T&b z6ODV=WJN`cgJS`KP~or}NolJd6RMZC%B+pje?3l7>8h-Y7;KibY898lR&A?(SO>^k z=5S(su9qI{lK;5s#hlnnIe!aG^}uxJbE=oZNq>=uPleoqfu8hU8D9;2Y}H_y4No!x zMAYbSOUl)eCy-a)|>hPDQVh@7#_e8rYumM78{2(*s>5Vg8Qd@X@eE#()dF}LWzgWplNRq_%~q3 zSgd?0y?>Ey8hJ78W8+zyh2Qr8Z=j`W61YYCeR|!UK>Z==5+f zok0#9GaM@x*yg4v%@qjQh+7zlRdNWu%cK{AbjE2f<}YiE(6(HZ!|s4_D-+ZuWYr)o z*^Eg_VG?5K?&^xo)ol)T(?u#z@Rl#+ z%K|d0Rc-+uX2&9+eI*YZ&|IyR@)b73q8f?RD!|&ez=m`z3Wgd2Z@5qd`-FURwb0B{ z1276ye{;L4RdfJQl}F&XA{&i0^B6W*fkqy~UO`v#81^nJ%=4vEaL5=fhcn9;L^QYt z$9++IVATmMy#m{1pvX?0dw zG2za!o;m)*7Rnzpy#vmG`QSRM>`QD#H&iqg%gjog6aZMQC`?NVMN!>32j!u8V&WQ3 zh9wchxx(RdS?PZWOnJ;-iy--R_Mbxq%+{Ad1+a9c#GVA`*IX#$vl`UTx?`4#LdQ~RFg4O-Y6QJU z=dl;dIq~4ISit#@olvQA6iNt>i^nTsGlG}n*erE6nu6w~(XU0WilCh}!7^g4 z7&3&b26alzkf^Q5L4zvnYh7mbTa6`ltmde2wuP#&6RtLaKd^8t1tTI$-ZSSbOqGtg z1~#s*R3&#Td)b#00dx*%;1DEi2`T#6a8?3I5@Tw8IN3EhE_oxOnSr_rkx^HL$6bzB zml$6bJr|)Mp<-n=DPz*A0@DyI8Ld)|r2~ARAncG3mp7TF6ETu;HsSA-W4p1|3xncX zkJ(5XLt7Dw#UhwGj$OIRI+|Qj^zxP!?I0(Z+r6p;XvIo~(A2)&Bv`SA#eA`IpUq+U z56sjeb<1FM=38aa@lgRHZ&F)8)r39?ffZ^vaEj^*FY%^CKLz~MP_R(vS477a*z$x> zFi4OBYAk>vL10?CD)JY_9H5J%X%gO8k&jFGDWf7f7!kRTpYi$L1R|}WBp*u+#u_U? z+YDN08k92*Rh%}m_a*&P!BJUh@Kug|aw^CCE|0NPFwCMpZV;1jwS=RR2qO5|;DB!C z8`Mj>YL@a4-_S8zf+}^vKk%%#$MXR-pV7)N-iqlq@|-1hY?lW#0f%u z##N=kv&ZKZ@H;I9v^8|(HgHvIiYuH}1sp6j%xnQ2ZZZ)hKh5!cHZUR{emO6PU*wM< zzo#Ma#LH(T{FG5q2_2TbhIk1pK+{goPy#eZ0o8#Fsg*>-1$2?!8UQmWSE{HVUhztU zulhXa;sqX{Z$+MMp7$bG#QqV-YUyzt7qQCKT3#>nP(uS6 zQf^Sf;jRVqIK=tLXZcE#Dg`D{7#7OiT5hWD^70AdSBTk=4-Z(d&eh~)btb9-w55=u`uZn|=E(!}Rizsp2Z=o3r&ZBp zPO3xkm)k80mt=8cTlP=;anGa%m{MjFm|w@a!^pQu$h=OpK$B;KC>Ayt6eFqB_z&?{ ztSqh6g(FyfSQm68otZcbtHR@rgSizdB95D2D|G0MsgBX1)R`QogR?ima02l`3PdIC zB3>KwdJ)9QP&~lJ4a`_ggjEqCKXeUK73Bjlcaa$Pwxv3}2iig`fA6@AY?{u2B#7*AtP0ao14lA`vi%|qgy zd0QNU7bXN*Vcw}k++TGl(=vbyhadN`43Qus$Vhi_JKoG82j0d*CLcInZ5aYc`Wg&9 z923fjVXltBoU}o+M=+ku{y6DPj{}0ZTACcL*M67VU--HjHW-lkFoEg^{J>q^LhC;K-7PRGNpANg~ z2RhA!2DMBuN;^!%6{HJxq=h4Aqlu%kfvB0{k$6&W%0gw1P6?%*h{z#AzE!KM9B;8I zwtSUS#>A?b;d6Zb0p>yS^K#PXRd@iGiS0-vJ6=}6%rWvoK(w;(2W{3xc~x9}`aycO^7}I5H+)f5RTTXi>U>3As5@N< zS5s-~t~7&Pfe{@|3M3$`6h;ucW~ugpZP^e76d@-|r5Tj1ba1c=l^q$%w9HjDyee?u z(W;E|T7!WjPdwycggg-!5tH|UB^2y~3r-0u(c}=7n7F2hdCLClbw-Uf4(A7efNrY* z`zY9)6*({~6>17VsuSj}mWhl+XI3kPs_1#K0bMuZHhbiRUE zpd8dxOIc`OIHF5zxK@;cLOdcs=kok1u3$aK&{05e5ZqwuO3>$(O3cI6!1h)-s*$i* zE7f`NIdoQugVvQ9NQe+X_(U*(HSnB>xJvVbV7U0pz>F2d=|m%J)N6}bl_WR8P?Vk#<7|H3S;S>-Gd6%J&8?NEetp-`%bS~!R+f*mm&V5V0P z_W(XG4fUwRas*kZQIsDR3)S5k$GWZahDB1V3M;CAJ;!D(vO#(i6><2l4~VQP!?+@# zZv)4AiCr<6(Iw!!5&@Dvi1v!STpY$1AXdSiDvNM^h~)<#9p>*jiYfXg!m3tQI9x53 zp63OY{mpt=L~F(FmLaD(j%`zhxD}Hn11qy*B8|JEAAkdA(FVs+6klp$p~!h?8YrUv z=J+Faa%Yi ztE%)XbnHl5-GaDfaec9>-tsMzkyk9vcZ;*wKkxvdCl>m^?P|pjEmFBE_u-`uPsr3u zD%;@8hIyKFxyK%A9E+r^pQl}OjFUw^utqhT^t$IB!B=CWVs=FU;ng4_uLKJoJcXNU zU3&Z@N`-j_4^&Js-8AJR>0~L~8vJsIC(c$DR!OU4oP>688`JjY%Uj5M(ae|gP>$vK z5*O87Vs@Lyg}jirHXvjLw~;Sx6=AhV5A!7@b3JVCqAKF=8jy#x(43e%774H=-c(%V z5%O)yJZm*icLyxzCMLBZ1lshcoc?wE<1#)LO*e^Ss6cK^72+NJNo}}EpEkji5`S8N zQxX!yvsNT zbgc4$*eTQyGLG1at1?@6&_*tU%MeODL>fW>pCSj|A>tZIWpefg{{OT0Z`*AoNuntD zDeAjMR2uk!(C)|z>m$Nh5F ztTm7OabEZNlk)}V6UHun503ySDXX(~cXpSEh;TP|H+MHPH@6FVb6V~r>y(`a2mxNU zqQ^BlstlKD63B}>cf`}g!oNMac2xbP+q}REZH}087eCc(r!D_JhsriY#)kMk!|E z${L32Smo3GQ;HF=f)dFROvze+mi)LxF@QGR&61q5j1GUxE0m2Aqr_osZHl1C0rQv1 z%<(BF9wNE;DZ6=~u{MBN2Z;ndoRDOa$H6jJZ3`$I=$?RJz$OHO_aiIooEwt6O5v!< z<6wn;uD93d&ou@kStWxk%tL~1N7u_8KnCVdy(a4)!KB1*V-68T=UI%0%=kYHs@R$Y zZDHA6x||LaX)|7JmQaO8OxG@1{$Ctb6jB@Sv)G{y|G`u&%BWCjFxtwf&@eBwzgo74 z;;RmAqrR?a$mIk=(>%`3^Q$BtmV>h5jU762E+Ju|hyj%U=P70F3OJ7BDl5SNZ)m51 zAtK3oefcNg1{-bC4z1$pBSLL0*>gNyWrq+7$i7Umam+8|>On>tm~)9jH)0|I%z?5* ziQ6$Azy|-~tR&ZH5BlT>%)CX15_ljg_oPF1L!9aRDQA6O=ig=$Wki5KRt8iCSe!t7U`iaUL3=+L2nsUE2H%X2S{0#MPMX&KTBay)+t2QDkX%#@6dltiu?4Z zWr`3;soi+eumt`kHn{VYbLo)fI++ROGP@3CedUMtsu?hbnx#w?Xm!Mj*A0@^mr*nz zyO?#nUtL*&@*7Sz*Xd*sxe-%4lsO7REn`}ZAzh7jC@2}-xne%{CzM_-+&~{2RIkvN zfHDNquP2%+a zRYX@N|Fbq54Rn_2t{YXc%NB9FP6lz>k4EJH)gT|2qd@wim!k^Ui6Pl3$4^I*i^RR< zWmm|%iL!A?G)ym;V>?wy(mVucoAGg z!#u{Na+8b)>CILc4Fq*q$=1BAdqC z(&;$pa0D7Fz;-7AwIpp@c-1Q(}$iCC&#y=UOEgDYzPFDv)~0)k=^4MlTE@R zV1*(=TiqW;pPqMLHj+)<*Y3+!aIqOQ;DFMlY28UjlZd{-$lgV_JuHKx0eC@x>j$Kx z>9BzLo^mSOcwl@SdER4mqXuS@FM>G2lm$ss0i>L1@FBys*odR1dJhxW0B8bVzx@WF zp9h&)GoaQo<5_hrj?~*b@k{;{bHYXG-JNg2=EI~P8)%|AOvJN|Kvq6PXevLZWy$fq z$Ac~T;&cqi?4F$Qs=#Dr7hD6^%{a!@e;v1in>e_Nu46b!a7#r@xf^b-(jorBT?T9G zCc13}c`6_c;$ci_fS}TLmPNNA^}NyKC{ln#*f|YqtSR=L!of)xhH^+}q8^oOVectj z#GS}dNRxzR0lBhDX+1WYvdznKo3sjWi6j7G=^6Za&NzUd-+iZwF_J^HWoK~I2l0QYC&=cf2Rz5C%H3|^<>g+fkA zG*-Z1$H)DGLk>lp;u}Yp6u}^kbF4#)MSOa|^$_{ksgTP*(A$UJA{vO$;NT3LGfKnB zG`}*coA@_C6Ob2WAiXS(KDtweOOytP$(Z}`1IE!Px()hQ(fE>AI8uykc#8{MF0KdW z^2NDv7q93tui7PR#g;a?cZXAK6-CcYqKE{%Dfh10v)k8cGRTAPcbE(HVYCHr$sodw zN3LeDu==>Z%bTWRx7=JMu(=z=vv6XJWkrZ?2L128GltYJF-a8gy6L~>FeHOPzE*FM zEvUkAmZjMnD1={H{8+BMi?6MEgP7KlQHFSfRfgWQ_|LwtbQf4zZdEw|zGswzN9%Kv zzmcE`Zqg@Nvxl%0M~vybg)n0zEg z@~_7S`ysYXX3*`sa@;{I(PC<6#3E!B&b*a;1S-E3CS76s*yI6*@W2&g~QNA}UNg<#!m9JTZ$ z%L-0Aiigl5JBqJCe8{9kj&U{hqQd=v1Cw27(!T;6Qz%hChhB~28`!^-=Mu37_?Hc@ zU=Qa7qfp)ekpigUrdjjkOpLW82tr9k)+K~6j|=E*hy#I@7fGT{9d=v8Z=yaAoG2I9 z6=H`N|E5j)2xzNR9d}1X?Fd&E;s?uM2a`ONee+@l#OOT6%I7FP=5kU{611is{$wdH zHClmGuaV=Lqfr9qi*jSqD%*M9g&9QNg^ejH{9LX6SJMmFg)bes9yNKlwuF;+P&V2M zfrL_BU`6nEBn2Jh%1}ffWuQVhjK`O-<6j0#mRLa})R=&JmQWY;qoRK$D=aQL47_&4 zFpI!1V9>xUfe_`$OuR!ckC;Xv&lXM97*Gs6#-_)O+#IpoqH>HV`YfSH^#B$tN|5=_ zKu6;bwb|~4Q+)D z{oaL1R0e<=;**4mf1G2ui~w{A>tWgp`{`(LkWMd$QQk*?DxivkMQpPDOTO3}roF`x zCSuPPi6(@<;$fvaJiD!e14g49i48jRL z%?kpBQoI}!f{7#8i4GtrKms}o(g+VwJ?#VD;}9hIm;eo?DB2^M6`Rk41_-tQZ-kB} zK`%zyKf?MnsJv+j3?wWNC}SvmY{F{vh5myL_6XWIeYhDMZg+pUV@ZPshlTMS=Tby; z9&&g>jfG)~oy-|-f+-l&et(*2xgT2d$K9j7{qN5VKoOiDli?tUhupg~ zlL#geSjw4dpmHj>oiY*S_bgosy#msrA915adST;839r@|Rkt-fRM{$??*haDlTLRQ zG?P9WL&@S_nZ&jT49j$yi{j4YQaHa;;4p~z3~0`kf$Nr7jl4f%O;f_tv1au8uqBAP zWS1r{p~vnp|*3R-tamVX&~FZVkfJn--`))@quu((&BHNj882 z36e^=qAYBR9>|`O`j*R)##erLASDweNkKzL1-@OQyOVcTeog`<~lO=}vnTEN^6bmcd&76b-6ew(o3`~*%Tl`h>FYi<- z`=Y??iqWPF4kS?1$_t=$)DtNw3u1-@ieU+}Cn2JT!3V1NL5Y^5Df*5N#43ACEIEcU zmSpM?2gMlCmnlnnjE+ckK@2=gQz?WYn2)G$Oo#@fAfBLJJ|qeDl9Z2dLdHzXcB29% zc=UhhfwJ;bO1waLWD7h689Em{CfCJco!95QCK8?mj0z4Ov z*HApdiqjbw>*2J?wkOK=Z+Jhv=1=q%Vm^LzXkoelz zmnU_TR9sH<3tRN#EmlxR#~i=L#n_rK?NyInCx5}(6B&xTwJeeSO%k|E5}jD^KXAQ zPApv1wNQc06T)Glm|<5wD+TYM&uFTu0Ko+_!wTnqJn^JRK&G|fCI>ZBUVxX^Gq(sC>c-3(M^;TlvRz8pEr$eO~*KB?|=z!xohiE zTusLxQE!3A=S-jxc}gNKh#0O2YKM@!Hdqr?BaqUeMA|Khun@hy+$s0W+Ym1UK9Q7GNg`0iwyV5G;P*|?AfpW$>gT_J ztol*y;VxDTsk3*@(kR|yWA`13TyVVDm?90MT=b|l|Sl_A>qrGQqpabea!u+arM?xhN8$U?DrTB0_^K z%)ONj2>+5Ee4xeu!QAo_*}A4gb_afl_!@=g8HYp1Mp%G-(wPl#|BUwJ-3)Hy z2#zUxbbJqP(%@(m1!EFzM zy>2Ubx4j?2>i_jtX(xJkxF^L9!IBrRLWvI?=q3Up#Vp`5%6idd3L}jB%*^? zmEG2m=e$9cH-&2eAb{Fa_RqLM+=cd8+Di%|(an8iUlvj}zwSpq#0xT(d+3;JBn)f8 zTnazO3&_|}w?HSyff`#*tDr?w6-NWa(FIIEl%du}xx3PVl{7Fn!E_={&O^F5hZ*jF zEHXU#ij%5B8!qyO64g<}$2Xzc&-TsF{y}hfbntHPcsJPod3&#mGTaZlN4ud`#0UF= ztMU4{Ox1ax4NPxh10KpSbSh%9NSlUPbe;~c<4_i*J^{%+BINTNH=4Fpuw`lcz%=_k z+I_c+H@KU6*dNHY>H}G5BO5cdQ~^i_S(Xe2@mM5bijWHE%IWx6b%p5ep(eX6$>tBq zkKwa{Q?Y3?JG9VjW0Tp&b+KH(5$F^QcA#w}u{j_5B)#ZbpNDcW3Uk;KI| z>O-)sX=8QH&Atez2zTP}8@D0HBO8%8(%5+bhoA;`MWN7Kd?kxLg+_R8$O_hiAOjxU zQ^aJ@5+1jf76pOV5g%uo_5n%Jhd?Tmk^zc=+SEXve~EgTN)CGQ5~vwG$YG-Sv|-d^ z?jQhCK&`*bKu@dPA+2eq?n#|fT7yX$ZGr2kKb?*mO+nTiw*>rS6hlWAxnyOZ5he(s5L0L2tD-Lg(ps$CPa1kbmq8*H<%Fd z7-&EvdDekMv+tR2JSo~!UUxi{KzS{_2*hebmmciHX7zOG(~#NRd}k!tsw9hib1j~l z-j+&@+yj1t<%Xs)yXAhC=RlkWtcg%31ZOr*AD&<(akpxN!Alz(2%BUY7ZE>8RZ2dc zkfca;(9U8IFAie-vuU+gIW6Yd(QMQ{Q_iG3hRtoTX;7G;tqZ$N%VVY4tUhX1HYxa% z0nOMeQnBd@(3f#>kU{NYUDjzs>U~kSp2l++}^|3?~M;UZY9l0)@8ArpMPn9|G>GJJosKU2X;44)u## zS+;Pt%uBE6SZ_Q07RM1sPyu1Y5tQk6xbw6_?e0rnxNM3{MW+&(1;8viHTYanUGJ`Z zQTK}#>+MSQpzsG2?yh|C=pvm5-p*ZqO4^<7M)*)Gs2 z)KGZVJ2Vo3@bVK=3Ax)?_i6j+n6CR<^t6e4vSC7~nT&%>tZf8Y?ubOJUf%SoqI>UO z5{BQ`bnrrYBiy5p9qi=qvD!UjX&5WT83)Z*1N)=q{i114mB+Q>=H@2UC*vWAQIuVo z@+yN+HNeDni_zd3Rc?bel?<GS zWK!X1>og}x|D&q)IXF2))etZ!U^d;e&EU`v=j8A#D5+Urb5B{vDtp5l$k;N!(Q)r( zO=OGbo2ZLs)Pboplx}7ErR%o!L*i z===ba|ABR?tkU{$@d0@-_E)Knj1H1&lB#!8IBG>1xvZKMcw8+4QgJ31 zYABjw$MJQDh=QQ9CM%kIe;n*L{*jc*xeLYgtdcSCgok0Guyba3UP zQ$>U1B4acehM{tjFv%Bn!uGGT<~k42bZAy<>{d&vWCy##{kiGBwm6H$O48#-A?J3%e^+u!0pvJH>`S;WNC*X1znMMJW>lpdX`497|!WUl~HsE&(8T#JA_YJsuA2Tn$k zze&akoCVS*OUvRBgytq$vT?MfJAViE#-suL2K{KToSw2bs?jThb<&j=8CLetC?y(* z%T8{7D>#J1QjRwxcr~y`9#-(<%`ioyJiZbMwGTP89%s?;XcyKMT15`Nd*qFu^g6jr zid+v)9Lns0!TwE~;fRzY3UJfm8KT{EypJW4J~w^xU)v$HetMdpEmlr57Qasyj5eBT zqvPIVbReGXzLi^jm0SW2ok{HhG61nPlgcG<#a4-JJhdXMlXbt|5;B>(grlpuDq5}9 zf6^oYGHKd6GXv)%ylEB3VWv}bW*c6q8@yJK=?C-hjlZb^71mrtbvg6Cm(>E@O#sm3 zEhk=N;>87iB0$X&=_A#)+5JW%X$8Mf578bInXgkJuC4K+T;;O1jhDU(wQaoQHhlaU zXZ}DPaLV)V93Yy8;Fcl8k!! z@7|YpXl@J*HKtZ)!^{QMpD$Na?AMQaMFhP0=*& zr)9f3v1)A_NJRgEwk;UM!vg)l8$A=}Yk+fT>2c6lh83YOXv`cV7;3c{1RQCC@8r*@ zG)Ziy0f2zJ_J>on+P6MLpX?8w84@i54872xo_-ih_A_>63JUIJ3eg(dV-L2Uoj@Z5 z9IY!*6l~}>CK7;vHt55cHq|9QMxXGplBIn*S3zW~%}VDCv(FT75QkSXE2|AO!&U)e zaB)Qa!cJMS2I28J2A^rtPYx(3RJ*jAbaAg%Jry0zgG-n$@(_Y5jiykulkQxpDL>8H zugd#JZ`=R*KX_T<*!smZ8dfZc{xHqsZpu-W1emJb$$+Z9QhQcFL!aQJ5i1(AX(>0M z!l7`?K6XCG(ZKl5hj0*K>o*Kx@OLN<*gHpujyzYEDT*8`)U-wSo5++2nhdd0Cv*df z$Nk25E;eD)q_Ni#UIl%FB}07_4VYUZQDj6j6=Wz$m5p9k$mBxNEuI=pJsA~3r>xkx zmizu1QEbDr1!XTm*P^5mjD07|4vJ+~0Hsw z2f?^VVY(V)OS;r?(}F_-MGh_TRlx2xw2L#B z7l#4I6&W_e&i2vnoA+-Y1P8-Ga2#DkS;7jdk1F*eRZ zuD~7qC`{O7fLp`2N_Yw7#v!96T|?kD6Q3KWn% zEXkYL6WFpeU-o=jgx}m$wbLEyecJQ}*+LRQb#TEp@W9CcMc^s>cGMQobyGw*yerdt z-BnT4FN&y$qmhyyr1F%g8ufGLW;$+<`RGmH`d831Aop3Wx{@cuc&uGC231;I(qVi9O0~5~(J(az zm62;TO@WOw)`OGe73EF9El+oljy1x^F>2$YjH1|Rm4vzOT7H75RnjK4OppXJCrX+R zS|*(&>M2*L_gxlrTsjs zBEF@rl;}Fie9;gu3)TVAhIB<)K6X#@;#K@T`3z)T5UnjSeh!Vu*p}i;@Dy%KU!$6PQD1@%W8u{-Ku%x8MT`5R^sBvJk_;l*WA1-d+wG4<0l*?S$y%1N+#rgh~!%=qE7NVS8KJcvaglI0;rHWUc`11O zSOISai|!lqFxH3-F`;aMD2My67~PiKdc^@)jH*T2KfJBQNJG&$PNx`LZ7=}p_G_G_ zXtET1A;y6E=v4uv1kYLUneS`$4w0**5OMJK54u1>FVS8-8n!3XY=Tj(urqBWgOf>| zwU6S<-A|JT=JJ&zYS`^GLlG*bv3PnKEu*Iw$Qn;FmJwj>#H+VE>d_Zrq^hP?4!s&FG_K*eD&JKaag{lyKHkOy1 zK3L(Kd2`^gI=#V_27f9g6g50r+F9=i6Q3Bt-X26{nEd4OO>&uA zGhi>cGU_d&^4o7poeDp>Eq|}&8I1S!Le^*t+|oSs<7CLchUw+FHk-}b zsWa8mT$Ey)#+XnmSne!^OX9y}lT2b)m@3K{UgR03iN+Y+^G|#)%Hz%sjv%SOS5*D( zh;CcM?$BUs+E`w?S0f5JE^=#{=?|mPq~qICb)ordG z@k7EkIifRJ+=b zMgMNfFenz)+qT1R8t&W|A6nAL@dHIU{SXw%h~oNPd@$lZ6Br`cm}=q^dc0+qWJp%2 zN<%OxOc7XvXL!X=mG+9TgVHWl(}+1a(|f8fcN8yqE-5Sb>6GWxGg4V`gwKBSEJV}) z#(4`9jgg#~R4%efzc8=oOESZpxAeR`cnvKHz0&fM{Dp(I@8?--EjK)Dk0rcGCXI&d z3>_NP<^LuO9M_Ex%qA1JN;}R`aR{Rd_1O1hk zwy*_1L|I1BaqPG_7>!zm94EC8!6U0=OIPicIgY2Jn!9Ze!^JCZB{AIVR=WxHzI&nc zPR5P1nrl zC;sc{u!(Pu&* z^7$4R%9KL)(OaRJvYjA}Kz*rWIc?lj;{HvCF^WF|N;&MFEHg;pfZw8flSy&4$pgPD zWkr;@sTlaj_%?U545nd$2LYNx_!AE5is_f)HmV+b85(wY~Z-qIC z^gr_VI}TY&SBJpe|1#l|qma@tQK5t5kn{Etni92K+ApGKFs2@KuY z`;K!5Eg|0ms#-qMR>94AkXmdqEn}r*;AUQp^W}Oya~3SG z&L&Cayf9$`oTO%?IT_wwBpjJr?tS5mjY(2t6tQR}B>7dF&qrd6(6dx01FZjTeLDkYf!h z-U7mJW;qnr7?}U{!CaCmyfqlPouYw+SBn=a2YoHiQXeUPRIva4?OTx%Wz!7X{LyUU zx-vSD&A2_RiB$0@da8`p^E|m6zoBl+i-|#;qdda7E3>}b+lNtB zBoX??Ip!2_5-ech=36??&@%yepZCd@w$i*aFEJKNOb?@yoEtb$?&{y^iCFmSZhxA@!w8Wu=qSHK2p3aT@jIUrI}1g+vD$ zDG5oX?lhZK;f5IdvbyBNayEp#+2Bpx6h;JP_>JqPyu-qxK-1)1fNg<`6JzCnt;RQY z%!nFySC4s8cm2C8U%BS=0@h1UW6ctyq`nTY_U)GD*G92_4Ubsum>q*3${4jZF%5D$atB!|;~E+WID zwixqBOtN@_L8)aBSj>xrDq$8tean+vq{KnUI0;=~I4L>~S@?A2|G=gT6_exA+7|Zh zxhW;{0q%iHc3Y>o7{%FT%(6dk6f^zJZq=^XU1m2=tQ85L%ah!}JDr|TuH~}90w_ZXP`ccsv5s=1E zMRlcg3ZM32(W7`O;znXrRmFa%M7ni8C&*&;NI|i1Xb! za{6iE@G%yVifoFl$&0gtqOq3mSQ7+J?xg2~;*6+zAp$C2Fb}tT2AHtiE@<)e{FSBSopx>tt zDJdZN=n(oiC9=-rTZw0un?+jtmc7uWW~L-iS1)pp*xdWY8oR*(RQsq{G+J&pPiK=A zb%q`cL?GWvIqS2VOU*N}O0u*<8ym#PraPjTy31g=n`OQy0+egpX%Sy_?j3)E_KGB2 zwm5G%<~AhPb#?cNBS*`^P$gznY82?{aEiBnc>Sp$HBEKqR#=s}S)*1f5aS4^$w++4 z9;d2jC_+OSi4S9nL*WCZi%KA+Ye6q^a~ zhD5O+<#9V1=kb`0^f4EAiB59tHkiD}u!kvr1G?{F@*>ka)w_FnV#UTa7QZ5CpUt<= zj4ct|*^c4zHk+)=ctR1UuBeN1!BUG&^`!np{8KP0eJJ zFjd%kGGGS_S%z}j@$AE%q7)pG{I*JyAM*ZWw+-3?0y;s=@lb}AQK47~RO|*y^`mT{ z!vvaZP9&T`N+P+Ry_PCxqL<`MDEYCRCQnexpSJPNI^HXNdDym7d9-Y{} zE>&ikw?bj%(%PmKf?8al(%O1qVCvdWd8HDI%iH&a4#G6L5LdKCL)yqJh?w}}H@r5h z)JJ&5VknG+*^HqBdD#k%{bHY?Q!)heyqg{X%+26fh~_$W>9J3>glkh*6ADkBZbmWP z5Hw2)zrqke?&j1+vE=!{XincNNnP8wS4btf*0XU;NWO zqS@}zGcoTfLc1?r4>#R-L1`f7F*21^bXc{2Sld9K4Tw4jv)jJmVYg{5y;hyft*%q$szc9WNn0ImE`AZ8;m?()St}WUnF_!?#j*}U z>Copoo>eMo)!l<(iDhbQjU)o3LVyqWm-=KGk?DKWAf2E`70D%R3D*=+TF4$tDgwl1 z_8`eX7%GX#u{?Ca{b^jhUG}cuvszJ>0=`uc+f~L*wjnLR*um2 zJL5P$EmpZALaJNR)We zU>ROuZYNAvaVT?kA8>4C&5Q(WPS_$P8lajDSv$QM|LC_oBh`Mn> zBq8i!u;#Sc5a8w^5Oi>(9laA_G!Z4QR~)P?JxKLQNgRb9xVup46GV*8KB1q^Lq+;F zy@@mIMxz;yQJXVNevKP*pMV4~n9GmVz>qzrCL=VuHbWx?V%jvz`5X(>VA{tBHsi}- zEG*jOwFT^2+TgHtlg!Lr3s9qk%`Hc8oKEa|RmT(*$boda2G`a^ln)bfRCIK(Kqx7D zmPKZ2FG79A2Qqs@i@Z&~f5m6JtNiuM5&MN)WrbV3wl0uRn*^s4l=e#Q4VMLGbril5 ztpM|&vA=V@J-%t^UT2YC6>(aMxk%6~SbSmRIa_i}<_1PR(%YOzX}G`$W~k;-py9c3 zi-!KPh6`5Qz+Rjn+_No#HVIg72kCpF%c6P+e~6q^Onl|l7&IvF$duxUTu^ikVI^k( zd=ca>G1Ollg!#0`qeK580bLu6vc8DjpK)&|S&Fmtl zVKivulA#+rf+$CTC{Y8$DShD9T9k*AlNl&eiA zMF~TMics#Rd9!KsK4=Has^?ATm<8RZSQN(%%ePprHBrlk26fc^=Xdzzrfq<3waJAL zhf|>_i3ZAzz6#wAc4Y`rF=#uOfQ%FXJN)$F5~{isxE8;uboq-09Wmwp292)5Y;grSnBp4Q%07dqFFcGrYY&+QXaEbPSTPhSV%k;OeXZl1wI97GF+>lt&SF5o(i8 zupcL<55;8-PBZN2zOzDyjVloO_$&R)jc*u@S$w0P`0aFz+(qd6k=`vfPV!H` zp8b~RzvWlI^{<*3$zG_1&@pEmjf?YJ4mKafNjg2d)g`V$Vi=0ArH=`LPx43J(Dakx zG-Ck+B?26~4q@p?OR|9G(ejOX=aZ00hQcJJZ&Nju`IgQOq61G!;|3?g&Se&jMo~7r z4g2Y6u{TUF7rE2zG3>^CQ5ma>MnwF4yp4I_w_TMbNgKvKaz?O42abXLnE)?yIo3FE#eZ>PRI{X01ho#p1su3so`~yw$mVnqSXCN$h-Pw^sVOHWh|f0K?z1>ccZ{TwT?!ki!VUC&p0) z(=#bQ%8KB;vH<#HFa#1#;k?H@JD|?IrHmK4f9Za z+!v}y4bWnE)*OcvmjE!LeKeYM+-NUXYtj^8(pMSru?hpNvqEI)o=2=Mi{^}yr7G&6 zQ;{8Xs@#prG-)-lvZ}ghf@xH1w^e0jWKcCdjyA7soIpX;u@-B(PtK&S+i1lQ-Ek>O z&N6_4LsT$@qx9EgIE*NDTRd*RKjs8(KgYere~qrAV~Rhucobj6!1DX?;=zQYBjk&` zG$f6{W%CxH5_y1b8>FDc&x&M-&oTruKjyciUOLo|lBV#ZJmiW;GeGtk#YWZB!%WTxM7*d@o|=Nmi1DQxKWRIi&mv*c}f||@Oq1C2~7Z5qT+0(*&wF$Ul?SD z;^^vZXd*;Y6#TdUb`|wM{31Z z97A31^nCHFN^o=>tLM_zE5r=X{Yd%-ilt6b!BvoP?KiHn#+pgXaOy-Eqsvf26V``e zsn@EbNcDv*T>7?bioX$(0iEV7(qDS^m)@yTIkJe=5LInwa#&N=dqE?b%FDdbtEkrV zRU>`B5&IoD@%M2yipH(r|NK8_i{*gQ3p8E+wS`}gZ{k6cUm2gH3rt%6tK}4Nt`GQ; zWyjPrzVxgw$~KHDhr_fV4P#!Haf7Nkt`PVNm1{U6XGi1Os{X8v3EF1Xd%PRB64Lt= zlANf+e%C8|lZ+Y+0YD4#ftV4Y!_R8A{rSxLDisi6NBzQdHPcpct4X28Klh z1IN28!}Q!$2EH}ug+UeWMG|}|IRGV$kD6G@Lrfv|d$(R2qW5=i{$*YBzklnhard_T zE13+ec5mk$(OiwCE3A8a`X`Y23M;Eg2jdcye(Q!NRvfPLoWHwy2g-(YgF*qhZhh0q z$YYLfm?yuYAA~hE`HZ>Y^MRh9Z!tIdT$6*ny~k|H(>4y{g%LLs*SG*L-}9c}Nima? zQ8YB=rUJqJTs~)jq5lrgx(&0DU9Rw zAsIo~S=3(8IDwA{xa3_6j~Z5p_|qTM)3PhYVGg=8L;ESNyoPC!AH}068RJ~P5Dm56 z7Iep`g_lmnN^D9_<6sp|NtmfTkBTI}z}x=6Pbn~kA3Ax>1cw3nL!n;v0AYf?eP30epS3EB>!KW!uwRha8E7BM1# z6$x0wD1*kR$(;5$zfj8!XhqHn3J#5mh7%ao!-6gky*a?3)N`YFlxDZ&HQT2Wz|K=N zXS_+qd8h{B9Gy5Oka`~vlgos4rs|6&;s9b<$blI*g&Zg+uIY`%c@ z{LMH-IcOCmLzc3mMjPDf^C5EEq z@@IPRerr>r7q9r>&_HSX2v;2K#I=eeg)RO(XCa-cRVKj@T=IfacS{!e0Z{RQcFhOC z$A?-z$Jsb41l-`ompx@alMU}2RW&NmXBIsxcxChLM(KZ6cm6gO}>xQqiB$P3PrkdMRy`pTT+UVoajM6$@+8=H;5;p zGqNMXnjDselkc2i*G{xh$0|Rl#gnN0>r(sa*=LHUe79IT*#y7Ad(jN>K!bDZ5wG&N>=vmUCvyv4h*83%eBc_=hz~`;Wy;g?I zT_gCebH9So2ecRtUC@yMnyzH~Cdq+!wQn&!G90O=7Z)(y7$ohA12FW5={P3Y6(b8* zOo6E9^sQ@~#S%t2jBpvR$`Gj?EI;G?T=1vec4*@-wg6e$wFxY_<)%R<6FOM`(hN>A zI(KI$znr1{)(QT=$KQ*jP@QX#r*p`OBIshVDjL z;6;X04Asx>A3)*fIJvw6@*tO!Qo?*@$JV5{HFDg&)PelER)_%8=v?VlvaDGS4FG5H zf1@lPcK8eSCgFr*p={YqR8XWvG&~d^(By79YA9HShnB4SpeaL7BSKkTR$KrOYr(VQ zN(!LRHO`On;-$hlf@;68+OcGJD)3yKI`5QnrRD4qe8d zHigF|U%FyaSR#q?_3o#*PnsFJWi>qYOe#iLkkSZQz6q&;S_m&mdC}zdY&T7Mg;ofc zM2%F!>QeK;Zz9I7x-t<0PGdwa)Ywi8g&U}dFWZBl6_~i`Q+XpPCM!lXhNImDW$HjX zfr+?GBul-UWPtKL<4|w&5i7arc*RW*qrBL|ca}J0efjP?C!Z?g%MqS(5)CmBJhy@J zz{R*R!oOA#*#{68(6P`EJS+C6se=O~VW3`$ON~F!hTl-3g=p#^K3SG1f(1{<#|2UF z7ZMV!FCg-KABziPI@v^>=?%IlM)?&Ha=ZwJ{V~w@#8_pV2K{N4VX*jN(#v3GM9syU zc-T)dl28OE770MSGysTNIJxO09?RNAbQxTgs%LRDxb;@X>pHVO1}vh~K}PM12o~J{ zaniIcKqO8O8Gsf8ug}E=n!?&k*Lq}ok{lC~b}0o43Tt>7M7QOz?oS_%@=NgxPHTne zfH|KtG^HM!n&YcvwETRp6&wlT(@4gXDKL*cbWtK|5f@mfK?y75HzWc_m?9gt4be^z zy)!DNUP|kQsc^`lfTt+Q@#bof)lC9N)EIWvVmF2Tf%&j}Y+iM-fydEuKaBAIP*(B^ zr_@Vd2qJU%FKoCX4Js5+j(%J8$fYO=IrK(6Ndq$8nT#^DCp3t9E?!v%XH;Hc5Btz8 zSFwC!ZCf>aW0z2;-GXTYh)4vm8rh zF=2lsA_C_sB=AYD37sh1gto;?S^YcNRa=@YE&Tf#+Zi5dj)Q`*K2arQmN{bPW?A~6 z(g2udI=v`I@A~jEDd1fC5wMh!*$rofTf~U2u*F%~Pwy9Dq9`jEJ%v}rXy}p$K}&EX zhWsS6kGv2Tc|YQw>Yi-|Kiblm3F3!%2nW2p8VYN7h42+PUKEPN-+~BpJ7RAF;b1HX zB&r5-^V&~meI(x7CCNZKCC@B*85cWyRmF6`zkow^9jH-(%nXu0Z0G|z8SG*nIF3_w z@RCPHe&ID0sE1|+x!P+xBNQ;yKn7ec8djCp7$v2$aHIu7=PO^C{qTrGwEo5fdlXG5 zbxbvw3p1C)k#^Cg9@8D4w_0z`F~gE8X3tjD;`FXcYwf=b{#;tgFDsxC=f!FWg{&GR zaM>IPeQ@OX>r0?ae+7~>Mgt5l8>;Fa1)7tmPc;ZD#JspIc_G7tUu1FoD@FiikJdA% zWH;Soxzci*Wgr}=6GKtJL9D5Qq|>R)3Su-!`o*S;xauHa8~~ZyP{J$15Rr>HmiV1g z>017N6g?)o&}L0Haqw{r!V~(*3dETfZ^H;=!(jV(XK&940!iB(S)h0A7;KSl9ZL30 z6u&WxM=_ltNkxt}zP|RQi&sECTeLjKg_@r$>YlL-Vs#1$9MX4xIkr)S4a=V*?a#z8UgxG=kK%T&ipcEJd48Sl6#r;6x zcqImn^S2R^f&$pf6={qR2=jcf9?S-2&{lx?CFE62mS$RLL7e+@$r?`Cf)>{{>yYD$ zwgBryEt*w}0th!^>>jk+*izCU4h2+c)8$yi8J~KtjhhvM=e#2MG!%P@Uxl&PIa=Q4j?YukA6`u-$yr&f7NBAEAqf;0hr;q$I()KBWNj?*4aA>K zHG3^izL3D&nUaz{#WMFDQb6&Wf;x%dv#=RjvH}fJeqcJF`zM#Vcq5mec!U)qej#q{ zWV!+V+2u$CaAt$U?q=!0|C%Bm05h~s{15k`#1%V{9H&$Hb2q{iS@`Q`4DkNYIVdYw z{!_AUia0xpmG}0*iR{#Bo}6m+nbd@HwOQy5zp{#vR$gWqfzu0~UF4%#SHAmNFCj{w zIHwnOe2I6rs8TgDn8}xp@6opHd$fHY*CfMFLb%(O{UbcinnofKHzI^oACOpq8wc9P zL(?E=a7d3q8k4Gq?vW?LZzS>xVudEL9J zv``=N4;+wyF3RyH296yfRU+Q5!|5>Tb3}q6`kDbJM?cY6r)HMt$aoyyBp;JWJV@9` z44)PcvG950{Ww8C(&nFDA-wZ<2E6k_3D28R>eai$MsB!iTX(0{4N30aki2lONJtn9 zagaOEne77IjPdpZ-of)>nv4s2S++7%`J+7d!Zm56u&M1r_rDb+^*K5DvVg{H#IKNd zI?&R%FVZ6~nO8W^(K0eYr+h6pSzkG!@=N{QA3t9E6-rj)wSz7icumE==4Y6Vwa)$- z#s^Irb7-D6@UrnTizZhf3#-lEP)@9uB^OqUf;BF~oGUd{SX8uw%rG$|$n_lDJ%#;; zb{@E#VLo72_NJGYx6R-tx-H{eBEZ0-asQv6srPc%Yp01}^y@9TOtjnPbubWuc-+S* z32J%yos z5t~VIi%|h2P#uj&TSI4mAcVVzQN`GO$ zDUf0^pwH}y0!%1@l{dUK;$yNQCUM3tI-1Fgk4cJV5*QJT8vrRU!H%hxLn_a=H(Z7Q za-a^yG$hXuy#>tTjZ|p1jZ6_i#T1B2gA4LW+)pkNXcVW$=!@3jDo@;4PB2X&`Amz+MOc~<(p%z`^sB@y73Jp+Vj=2HWulrI=2c=}PTo5< zpRwd`in~H55BcimK>QO5zp9nI-W( zMml3(?Hf`+329C@?i}*=eO%bItruS=W3oCGn^;o>X|PE|4k)KI>^4f!G=|@t%6$Qa z6EY}55+))5%8;vpD2S7^1g0p6?nu?6Tn1p+cBP&o_u zbP>FJ0^|A~@5l7UE;6}#?**n>fX*`O1mKG(ShE$ypfBAhzT^>0G_@^RB}#;pTMzFd zY0X4xs>c}Tnr!wOn5B3Wuf?O@F%8nZiA#DCgVY_PazJunpM=adlf0^glG^+R}{t&UoF_}IL72MuH_5S zsFVm?Lv!Zl_*R=Zs$RnX><$`LgYUHN;`HJF^}qdpFqEEtWsi)=-qWM3;^A79ibrG{*@<3nX$tsPUBebvNO&eF?Ut8bJ8{ib z^+2XLH(qUR0m(IFX32WFpm>BrOjiBDQgYJ$=h}<_ibC0kZiX1#ok(8Ay(__B+1s1Z(TvbL*b0eA9JecplrM zHo-Iv2W8*DttLw&7h`uv@6NW?v-?GxzYkeunWJnY#mipRU7_-(GwnZIrGRnIw@F1` zKp6}WWrc~S*LD>8imW5jr^O>HGLaVsJc=$Eo-LxbRiY#+(iYN?Dr96W&eL``DhTny zY^yG#IPm2B=c}ZM^9gcvyb-HBWUEGn00aGU)D)cAjNVJ4;JvNZ{hl<#sAy1(7QcoJ z%b|o~ojBr2g`ARm4z27coog=`Bq`9asX!Zi5{BaP^dQZ^2XrEeCti`C?Nm#~B= zwL&={ky;RZk?#pl@3XvVU$nC~{#A^3yy%O|App^61EZuSm=5$N!{CC-ZKFHQ zJ}RA^=ttQuvgf>XnswshfB>CL^O$ZzIIvou1FHpl-C*xH*!^ku=x;y&uzR$N<7&>jHK0&Yp2) zTOrWd(yif?X&GBMImIL_BhRA{Ix7>uDY@4)x^?$913`bxX7hJJj1&gH7&ksX>0(>U zjp`Z;5QN|$3kW54gHe7v?widHWwUbh8j}>8TB7eB{qWC_?FTLAXRf3} zB9)z-99qu_*~-Z4(&tta9IDR(Z&--QJT>VB0ddYs$_@C!yt@@|UHc;^oTZfusBR?3 z(?0s}{(fVztaYjeHs{d1hBSW57jM*$^kAag1C8m{UVofgtP9LKofZ^qNf}M>(`R2| z2|UnE_C*f&dV5$h#WG5~h378{)Th%4kx~*P4qU!TE^~CS+Zz`%j9OLd2eaIveCcK( zl7_`CYLI6saj76{`2 zgvY0`1t;Wm?u}*muZc&9WwzeNgM=`-Txy<<%gqhqegg8&mo*m7+m<2#y<0dab<=mR z@SsEwjtiPf=SB{}i z7!CX$!640LVaA#8B0h1Yrne~9e_$9PZNm?I6o`PvPKrGE0OR?91{ER*c<+`k=q7AA zB9@$;TUrHW#w0s6+EoDErM&97BU8HWg%RNAdTa`1`&1+ZBHg#ot}=_us_dzrCUa zBQj-WFY$m*By9QPd-|ibY(!(yH~1a4GG|Sb2mt#+NlAN8%n-M zw-Zo;EQC{yQrwE)5TmuY>dc9%<)vy|btI~+LIPK64}3dZ33_mdbRu5&W?g}0JV`#q z!@R+ND&ikIUE#9G4G+ty-ni9c5W!xHFbA%q7)4GglJTw16#{aD&KxoVii^USc%%T8 zI*&+(Sx2IwC+3RNrr)8=?bu6yq$(U>hpzTZh;f^-lJGEQo(C(PC79^W>JqZ}zh7TQ zQq3VpF0~x0#uKWsx3yXpPdAflU2&Q{%KMP!|Z% ze3Ek5u87Mk6RlY+ny)!Y{N6GYAcm1~rA=5}jy95>O#QG-H<5_gwm8Uf3R_@PlvNf2 zVrN+8NvSOJdTj;`?l9gAmNUsUrRLm9GhI54zl#gZ0Q1?1{wGI|xry?=ey+qe!_Z=4 zD{#}N-pP$qmXT9h0Gn#TJYnBQ{LtK&Gk zjx&llWcx*`*PdWke|;+qrjKHg_#0Kqe{IXxZTY@J6Q`toyVg-A0>IdJ?>wn8SS7y4fvIv z|Ex>;Ce$+Jbk0)xgCnRMZs0}P*0q!^HTz;DDfv5T2lPPudA>s=BY zfuHq=2=+PiRo|j%N&YJv<6w36L|HF8>Lpec$9t66woqEhS-&f4#Hhp+zi*;!EHXx6 zw$kxMDt?Mc91L$dO$N?d9o`;ar8n>4!vWw*U)&li`F%F@tuz1Yj{CY`P6hAy4)r%> z_f@f>4Mgf(^C{lFntbZB6**KWJ#eSP)VR4-ewxOT7F|zmh3MhI@gAl#X$9TC9qwwH z1?AdAG?I&i$)8yb+XiX^^7jD?&ot4Vxfib}xS4*j_geoh0T3^?$AhEz?^E<067^wF z)xBH9^eQ598m8ndJUV7KLWD0wgiwLgA4(TiPtFbKT`~hO3(2I3MzK7GZ9aHs$JE4J zpjIi;&cBAOI>O6`RzM5An?i5Z?_&$XF7E_eqaIx+=(2~lbVkv={O4pmNN@CKyMr>X zf>lXozpm2!dsP3UXkrzhBSP)vK;`WKg%L8#c|!8}l6HrShxoSKvXQadE)MVEo!vS` zo3x5ij7Y1Dvj1+Wco!|xTfwfbZVt@tWD$Pa4aRPFpVcNa_5?tNBfKlLiYDlJTPRFa z`Mv~`FB%0xn?~5;Np79Pa?A+pa=I+zaQ`_L4nu#fX0FvvEP!t2F0hR|uF0VmLmc77GXCgT8s zmY^rdo4jNwaU>~P^C+&8!5|*Lf4}!Sx9@(86A{X%!{Z{&qRaTl_yA!*p1+oa2Cm2B zX=59?soJ7A+RC(6L>flpRke#6H$)`Zz(v5`!W8IxMLcRaEjF7?PEJGiRf7RVt9=W& zi^p-+0M1S-|LGVb{Gv*>p(9#(o5}snv@~(z5Z~f3Zh9R6@|spG2N77an_|{xx{o(F zQq#G77m;cTWr|WLQy>zt?7i0vCs{hlndQ>K(i10UYs=`hazo^4zO$SR1 zt**kuj|W1-ME6LtA5hWlvUr21D$yx4ZZfO{jAo&LY?qTa$quT;EVAIFm^3E6gzZzF zaNI;X^9;`{{e+I|2O5ojR4q9r@=fLJ&KG9*N5%}Hfmv(V7=X%7* z(D5gCZb3Q?AJNQ)(+Q@AktJJ}sRcH<8K`Mf_Hrq&QMA7d!w_W!R{0>cK7H5}2X#8e z?Zb}T1Ue-x>103?L!YFkxoOP#e0`kJPp7Y?UY$OSfa$d_Fy8m+!!vE|hy7GgmW^~& z<+w>yrwGN7gLHu=A2bakt9*})ZI8A@mXvR+Muc?_9&umM(PvYg;)If3d=*DJ)?`$TqFF<)z+IVHJR-#fMpXiN?{dP#tR2OZwQl@nRHxqJaadJ4-6W-AxQ*8+X%* zRd#{_N)N_w(*87mo94Oi;}7X|Y&R*LZ8p^rDtvX&?H;^4Kid2Lhps4<6+?0EYsmoK z>CKKtnS#t^IE)RBG-uQWz%?EkdRrJ4Zu(U<{uzh z5~ImvAxFEL!VL5$)3!jTr0Vu?nxh0jN4bWn3)Zsq0Jc9yiU?I4lozPyl>(*GyAf64 zQ^+_jD1Zwc$@2gwK1&?oc3Bi&E);@*D(P(NvI0@VEC^YIh@pp_~|9u({Ihz)5*Tzk}fI%8Xdjup% zU@&@2_BJg$F~QpTWtxlifT7nO$S-!^DNT{x?>jqib>%VcFFHVfn+q-WqA>^LHv$tg zcSBRmi_PF;e2aI>#Y;DE}GWX1uC&hA-^r>uq@ zl*lwfAV-|yd&<*Q29m_k ze8F;msB1daI+e|Iyv=mnW;*3&s3tGnmPV!L*4<`p>iWyeu^imGoJ&@=+qDj!C^Jo< zSR2Wx5^nioVv{uI;okn6gYty2vc}z{AoM4f&M>HJ9A{%c^>VJg6A{IfbkqE1RI<;lzWctO+d?p!J z+5wPujZZW_zQCz1L7l2EBJj*AGLy-eTGNI@?#*u`x#DrhK53fri`go@5u^2_K7iGQ z{_5%)Lyxo-nEe$`JU}3l=0-S^JWu*$O&q z>rLATiKb$%g|;bH7uI+%Yk8T5bOt`9iwR;yOo+gW_&{5oF$X_e`na*Fmz^bFmwbyA zFGW_1E3v`VEkh#I1X+ieOIQjdK1q{mLmMJ4ryGXboqeBOu>(*^E#&8REN`#qMDQlb z;QapylYhSNO~=J_lU`GyP0HA^%Rfz+Z~%-kWO9MiAi{=F9x?Q{NvByq=H#;@%!&7q;Lw@V&cE>wYG1J8d|>dE%^(_7?P*TNmx9~ zzJ-`_w;^u}@rQqcDtEC={lq38rw{+{|Ng)Ke}ny$>d9M|mO<0849fMxA$A25=V2It z9!vF-&Tm#Nh?XS$f}Q@neYC%~|9#7`5Wz-{5V|l~v~m~Db+=l1b4lw1L&=~Op*2cz zXyKs3=!HmW07vM?kX{rNp*G?m$K?zO*6o#bgCjIP*2PqF&RhHY+||o_gy5@g&&P8) zgn6c*JOhJx7+G#(ukppqTj-gW&|mI;c3CXV=V@kSUutnin)*a>?%lEH>R8@7`F+du zB${4)X2v<=y;Y%P!PhDq=oxVE>ew_`H2Y`VL%a57E(rhaGtm)d7__15Xh2D)nLF3u zn(ekqrgG+WIP_<-SnA1Ke$&R?G&E$Vxqugb16LyP$XCs)1k>!0FN2c;Ee-!ZjWO;8 zETBJQGhE|ct`i=!E_K{h#zPHlHD(`j@Y+zi6CcGn9BuOWWdq$$)8RD`m@LL+S;9hD5$o z*$u71qS81I!W~$BxKraL7Ck>SoJ?lxRwfdf7C{AqEt)BlG>{*;7OM^2P}3(dTB1Q$ zV&#&gHt{x4dKBMgxQe4eoB^#k0*;Uk8dp-e`2&BzrT>y_Zt?STJISc+)MrLE{(J|+ zuw!*yQ7SAWE8dm7yu`>6VpxEM?0!BEpZc!WKNZ)uaNgc0a9 z2@H)~G6wK>t26{?`K3O!3LyX$N|;AxAgagcn&EJEhJit{mvIW9TV6 zhMu%zIDHs1nqZZHeAZ(nu?jlS3&rQA_BqkLGO>)&msROT^GrwA1-TVNHFFo_x^luJ zkaa%Yhi8aD-em%1hKs$l>$r(v4zlnUtRUjVv*SF8weI;$+?p%dn~Yl6JQgoW6pa!@ z9rI_0Hl1QQG^1mdNpm+bQu>{>40-|gYY6A(c*#X>I|Bv4-emW$t&#i z;rF{;5p!0`E1d3GNI>#&Yb$6-_{3eQ9>7|~yo5&mY8i@PNO;fLJ#A$Ps;@O2LqrKn zu*^!H_@cyAsYUU!sTWm#a{5r*$hW(6?QuqUIeiFwb0|-INK9n}Ol^)v9G+IzIZ?*% zzB`v%C1J;<^aOkIJp0_fwtU%eLXxyBncm8VNiETOd|_l*v}8nqL%zEa1GFx3Oz9D) zUZz~+qAh2Y8!9*y3do8_=#zLD^zhP(t;*^Q3aH9IVLnB-#GCKFn-L*KO2y2|N=F4^ zKMENw*ZRmrI#CMKrbu3LJp8}^`~UNQ4}J#tl*DLkTt)*>R4k&mRHu=}~ zaZCv&a$STB(F9B-f4RMpkm1-M%9>KMJ-N7#)WjNcjTCBhdDdmy?pj#e9yW|&54awx znfhp-oNzE=j71S(8V&RVd60e#gS`UyEM7{H6ALV#DWz6UC!q%BT#lLN2(9+F28HWg z=zU##1a~B+p9+pcc$t-kBSt`o!qC@Iz=kl?6eeZ9NyeK_pNY6w%5hN%mNEhgh4)?c zypWdZ9Y;sR03b#WwXSETqP$$O2@ zT*?pBc+!tn&+wyMj*3{6h_NW4m!e~-LR0v+?Y{-b?{{`~kB?oP0zl1BP3VoLzbh{c zYiV7#Y%=XPT-8-d96?$2p<+D5NL4rSLWb!{`yU?!|M!3YfBipz(kstX+eoCDLj1^FQ6Jjz%>f)NMK?Xq3>9x%(&rqRwVz!DTibO>TpzhxS6#agS2L83C?EfUjJJ%ldMwwKDdU z@~4bIr75pX(QHQ1W!yc-d(WW1r@ zyk8(R0I;|%fiI$2FiH*En6<7rLiP}}+uV)(S{zY7jfUg=1)L_J9cbp}<|e#ZA=pS+ z7O|X&l5(BIH?Pu9P<9DUaGh27e-*IhCK(i0@P+5>EFB;f}N1l2(nT;=@Y5}LC zm+D5ty;6K;+;!~r$;{Yv6~#AHNUa+|6o{>`4>;2gVeoq*yN~BHLX14OAsXNyN+f}g z)|zJ!9^6AytfI~18J{~R6uT$5zd~&2?3u~O<8lripWO!9D^RkzJ{!X$F4*`o`z_J-e39SI zHRO&vLJVdz9(hDeRK$Ppi4G{m2}1%T%^{E`PsbWN2*{p z1HOw#f+2hK+}G|)wS~)6$uvARt_F}qJc?06b^4Hsw1wA3^O<9~DvV-{$|S@ifI?Xs z`=oZe2-ncPF(^~%py3p4l&F~OoV_(F`e+xb>#76p_v>+Io*sAR?s4b$>+#%tL9Vu1 z<{-70Obfcv1f?asBpwT)@$f38OSfsi!1QcrTAYWno|m&o(L++Xd=e=d_fq5m43O|#=d z%p(h-eL2XY15HVa$Xu`JqL;$#rL3kMrM+YrZyH}!2*LixBRGVoqXx)T$C#um7~KZT zYr!DGKn!t=nc^@2B8pgVX)&Nt8i-kXO{xHU=J%2SQ>K0%>NS@Y`NLr*@yx54STGEniw9kA#2)jc@QZQs1swR1L1+dzhob)V$6vkwZqf#u^UO2*D+HaBV>Gn>0^ zU!)l=F_~#45I+&|n;+v___!cmZ7xvmCyrDj{@SRy>ey3}s4m2#Ux3h|MX!>(C8T(i z{*use607#-&u(MJ>54{dw)T8FwA&sgwxUuFRoIYW7IXof-#D8??;)O@zzh*!7Zhk> zFc?DPyI`S>xDs#5pf{6&S;7AN(k}Zvaka4qPF=vpv4*?7a~1bLzC~?LH{C@<3v0M= zi0_)7`f_u*AEfmi4Y2%iVKZ3py)Speh}&y-#tYUD^pP58maCae5Q9HL{y- zad#}Gm4^FE9KSd9p3yxsGz9VRf&{16RNmGTm^5fQ8b#S{x#JSMEG47DGQGSU#(~lX zl&dJE)o9ScUlM7f{PJY!%rk|kpW^n*9h;Ql%Mk-SfAhR=IE;*LTV#Y=Zu%;TEfGg^ z4JeNMqnMQYKOJh?n~Xmql@eNkB;QX9c2|;fhXtCR>G4p9(pWLOZo2J)@>TL}eNq}!Uh zG7TQvv|6zQDgAbsly}df!z4+}V9MjZH#Qm{ z`)aqEDB{~}-mO--(KMh+qB8$R^WnwTDEjE2M^|Y6_ZKNKPg0B`geNsG{jxTt+*|V# zgRfsZGggkHYOP&5rG?{^vAzTMVZlm?rYMa5E?NWOpNhUQaz*-rjG9#h&#}XWM!nm2 zQTB0wW};?k?DG$f0MqilG-Mk0`w=Zydixf*NK04?`eZYazVODVeJrH$mK|==D3ROa zV>0iH|7n&&wJZkimu>xq6umU2Mu9Cz{Uf?`Soa%uMtqg;rJxm77Glgr9Drv zhQ6~iGRhila{{)39w~;IL=Dn)G-UlR8_4XZH?3f8X=zD<6ZetEI(=ct0->=+8>k=1 z<3-+C`bt2A*dYs06Ap%ybe8#Z$y#LiYM4wQL;?_i2+ILB$5O`N!YwO?ovFGu+GY*5 zsk~Oz%&=k2`5Km8)=kH5+rr4X4-;OZOMn)1&j`s=qY;yvjP98cwG_>0aHiys zQI1*$rX$bmXr%z{%4b7#Yd(<2?owl%pIQcjqzu&!1Gb3ofMAn>*;O))q{P)hd)cwY zLTD6@2&$QN%6AN;20s2_cYk|-@B8ij;|I)m|GdP>kXz}gmx0F6p$4TIdVs&7^8I6MKqe^4}$&O?XGo~hv)Ve2Gw$J z@raYPRES&|sL&wiG6ta#15{8BAq!}G^h$0!OF=>B|IHG=FGqu_kqAx*$eA-dJW{gw zXnEgg4@x*;v32_CL;EHO#fb8yrx0v(j6@-vVmq58dXx-3lp_b0(S97*;K6ZMT~_ec zQeGL#nZw*RWoIFAM?s*`VW{R_&t~|l3f^jqR_`h=C)qVeX|J8@VvUB+?3shA|G_93 zFNzv?gCoN%V4iQ?j%f$G+|fKK2ucyZp82~(YVSrV$cL|UMpkmCmjq;yOdsPhTA{x` z+EbV44U7z8+>fe(sF!#1ciU2GHHcwt2Jg~o9uw~|dS41I%%wv4pGJ*g`VaxPOnBXa;!#NmqRO?$l| zrlaF1$#+ff(oy!GuuIb+Y93Ai)WNxqqt@2!)t4R@KRsAGGY2w+bIA;xrU!Aj|41m3{c$q^irFjPw~ zw)z^}#)W{`AkPWBGsPU>C=|uQ|4+g5#H+9CcZ+gO`Bp0w<)f_%q8FrVa4U{*OqW&Iytig3)pc4 zsAUSjEb|$o_Z2R$$Pk^kFbG{n2e%U$L35K&CQOjE-@Fm;SUScl&wSk&+kyi#ybZ`2 zTP+-p^nf$Yb#gPCCxv0IF5?X9)!-Wa>ktyU%%o}CksWY%BM0cF^EzsCNEi;yGQowzJ&@2;>+W1F081Zp3N-$4jkp>^+%4&)% z-5=CIKTyv34>ZL>asU0H> zcwR)|_$^Ge0*q0(a}{w8IK)diiE-K7-ASivA98Y-O!RUR4jhqr5{vTK7{+GFYbtU| zDwJ$GA0&R<_Yzs|dx@@clWIXLX@e(o6A7nxC$~Etq6BD3LrZ&?!?cGHn=c|v zOv7U3X(5&YuSU*=y}(FZAai#9EYc(4kQUSiSpZ_mA3{}KLdQr$26(Q)&}EMZK7R_m zoVzBsWXRO$H-pa7@=EXvdSwl#Kq8;x&%Z>&^fKv3LnMfU^iv1~@+DP$x7Q8cCjEGv z6Ng6%cn!OC!ci@DKP5R~MW8_hyKwLzJ7*I*Odmz4RzMjM!lqrp#A{)D+P3)Jrl|1D z6WyHXXEJE_hCs&7;^(JC0hKVR%3sX{zZge>( z*h1H+!97Q6(jXP040v&YDXoeWpJi;P@{*NP??BY6K|_SeninD`{UZDv${M1dRzm=s zHv;N4RLO%2Qpdmu8ciLQs;PVHgIyX#Eo>Nz4>k!<6$`<6t?|NaNnz&1Ss-VA6j@D~ z1M&5tax5ojrRMZ#n8Dn4IK2MuJs!I;Yu0_;s2tJ4Ld}Te?sywt6vt>R_BI}0Qa-Q^ zr^FF50=r0i`I(ls|MaIn1>9ml#{zswAKvG%s6U9l>E$lren9ygnNBtmuEKoEMj4Dw zCm5WQ0FBdZ6ai62AwsCgrZDaOEY0%(`h?Z5<1D8{2Y&{F2PYbIz(>|H2vvXng3M|Z ze14aFiU)V11^yy$ce!WsTOb0RL4jzJ1e0kGuppS47E=`)=JOIKAOp@C98Y36Du|A7 z{8N%Qh1po7YEQjlze+e2-HiB#l z^2&w*Xf<40ML=s6fJCfKyGP5d^|h7O^4f~k zqo>ONXrogBNS`Uyf1iS^K%Lgw+Is8B`cn(glNAK?#0%&! z&5K!x-)OC^ueP2%UALevuOZZ@_rd(ia%*{YqxE#v9_aE?9V9R6S30frCr?`|D-Oz* z>Q;jn_W)^SeFgrvVL@7YQa6iUC7nNo(fcb)@yM|AQ3;>vDAsmXy8imTS;sFDWn7m37#Iun^We z7St7jx>|{Qc<$NgCJts7&CooZqnVvGin-L(1PgB(#i z*vHsPtoA+;RFS3VGjXP*Qae{5$j?zu2C=sba^_{L;Nev?F4EDz9?vd%99=|NGP~T~ zZm_&OSFzo}Wjv$ceE7s;n1xM&r=Qd8BVIksi!N{Z*YN;@*2M$<`aM-Y?x&O3hn}wi z!I<+xm|2lTuTRdz_!wcgpEJ{nLjlu4@oiy6UN$j(C{3M5|Xu=c1je9TWZQi?II^Th&XRq z{E04r`Xsh}VEVy|)hr&8suX?D>3utPAh!Uq|! z>w`{;tt#Dza4Y)`NptizeEy!j-c+j6_8I&E~2GQUu z&ScErpI3H**9Y$cGG7Qf0rp2Do9*&shmB}E-J?aQ)uvkQP8<8i4h~ZbG`rk^%?S!W;gJNWs<1xmnA}ykzN4Eh+i6402V29=G14=R5 z>~%DpQiMsIRrO70u;*Te_uRBd59wRHxjU$f=uVR&%CNW(}db4_CQ~d(mVPO%lOZM#(6~ zu8@q;Gys~UY$IF;Vz!2YG$pFe5!GtBz5@_wO2HS_8p3?bR*gIy2{^f4!L>`~-LY&r z-@!~1bgVox?xy7A)*@Ut>&~>5Qrw<&U#HEhB)I}C)GR#nM8^ER=5<07^%b+q@4j|U zxf}D(sOZVp%%^Dbi)K@H*Eg32LKaG9hUU(8dS=*1x)*dZx1fyNSW`(+1al-#WW{pb zc?rn3U1#<(TMgm=q#Q(6jennl(DOk`0M@GefK~nreitM7pn=|x4TkKABEU2jbju4( zV>#BWM(oNftR-L=OVM75P(Cc!)|Dsg)!T!eAOFkygYNEvcPY7p{2eI6pYSaSFnIUY z2gyvJyNVjDhEKz%a+-=k&GeA0hc|bIyk~CjZzIxvrBJ)kdAhu|^kl7B0{4x?+OHOD z^^*R=6S}6e5)~w$_-PhGS$G84|*B!*+R=)in;*=-< zxr_dNchS}V!n^2)8M~;o0)3LrJbF;A2F3Y&GfbmmeU)S-b#bxYS!=DYu3EPiYa6Jo zTqVyvtfbZ{&Y54ORF}V<>d-(F2dO>4NHt`skOZP)Pl27hv&W0 zumqg-*2=1RwYL^Nd5Un>E8#f9V*IRaw4N+Iv2Ki?uFjaRjh!L9jRyiA^=EmhwZ5`q z!Rahjj!UV~D;MOG*76c8$tTO^5?BdWQ7^x~dXF`^*4o&3(t5gV-^i`5SLpXE*W`L@ z_33hJeSO)!f?lt<;;meh>#eo5r>!SXo$LN5Gx}3nlhB{_mDbaB`|^4fuf#Xj?y)9u z-!Hc|R?Tq%o}bpQ?edz0ac!)$)|PGjJe{$&%WHDIwZ638T6$t%TR&N?>5q3!BAiaE z)3IsVlP6U)MBQ2E>bm4b^<4|Anoi1hEF$itaRxTvA=&50(j~VlWnREwcc2;5EXZ&E zgSR@*?!^VN_%iLQy|mZn###+MU^rxIj$W~8#&>GVt1CbcRxLV5d(LOX z;Lrna*I=n530`_?U(>Bsf~@Eoz(H$`r40)Xv%1x)Wg+;tF%K}4M=>l0!?v$3Xm2FSWM?Z5n`NO^~W2qy1w zcaPT}b=JbwaE(+Thi1N?%N?GZ%w`a}=;Y<)+QD<})DCv*q}j_@=8oN}n)6MgCC}_AjtprCq)1 z)xXqC8k(1^!Nhd{MgQ{7<9hKgbu)+lJ+j7^%%1C}@ih}xPnLaNB|hq`hVu`bF(ASB zoUx9cv15-TPVJ1LbJf?(nCrCjH8WN(Uif^Bd{V|ge#YpU@?LY+F?ZRv*E6Vg)>v2Y zrSs-@BKn${tMFke&7t23%5Tv5@38aOLH9lrxol44vEL=Ce*dw5$Cpl}-+St-HerSL zR(U`AM_b;K_6WaBm=m3*a0h!!!f1mG=((>gUKxaKdTS$`-sy0TxYWu&@bBrkDMosg zQlJ{loK6Eo0f~bEz!$Mj$xU^VP>$%oPm_#7qGF1i#Zfj|%(MRD1fvM%GKwI*x`@jN zfl_U5td05L20%juu|*uvvW52{*%%Em8v(br0CmN!DKQl&LXlUBq&L)bMRz-l`u%uP z$nXo44VvKQM{z&R2JxV=AeY;M89jm^(|s)$G>WzKLNp~pj<2Gkwsl;O3S$p~+x-3%I}ihUUk znx}dl4Z80Rnu`t@o%*BDA!nSw7cJ^$w}-=NUX9AtUVo{-8pSh-kr&eZ)M(!7|4EMi zgODS+@Me%BRqV^i(LB{>lB4@Jj!Mepf)9Vzm` zn2QL_S@A!~&wmi|BNy8Y@}r7<8Tpx~dL8+>$CjCk@EHC1cO^U%$}g%%cRy+axRU#> zUD|j>F87^WSzBBEAwU`&!T001XfK~EorM_|h99#wt_Gq%w8e-X%&X~n7C3{0#?-sV z|6F7FLr%l|2i|{MSiSEiz158jW9GrJu0;Qm_G%R$7gYTe~fK$J<>_jVrbaa@d6C6j7jK^_?t~Z+kLk;`` z-EM$@CDK@MTyC}zw@(Q#C|W;HS9p#Q!|}3cGKn#%52i>kVyD-fHU2%PUF69dB-aX0 zIsqPabca{M=|jpx*N(VrL!5wi&z#%?7m&g`Ga547lc+!S}-Ggi(I4^?%o zfKhr4bx$SoV67R8r=XmlO&#hG+Vx8m=`8hR+#Hm%Etb^v{2`UmoyGnYkO(defX0z8;$G5gRf26h5x&PYg{BhS-=MS{DI$yE2sNjDx?)ezEyH-yh zcB2V8vST94aS-*=X%W~t5Q7Owt$9ei=-+|=H}1*m5t*aL(oD+JxANk72#D49D#AfY zc^&HE+1m4O>v^|yJ)+8+(R?z0pOl4(ei1eG_M3m3k!rWB;VW;9nOkG#=5UTP6HL<5 zauxwjc^6v5NN zyebfF>>)T7QY-^wE0i#q!P1U~LGQBNPlsvNzRaRQf>#N{_@Zd{V>Ci-Q=$@!)|m2m zoy?3-JOZ;vT8Qo~C|p~oOAqV6%Hj)3CQ4aOC2c)o)Zs;hHKZzTDbD61jX91{HGr?^ z^ete)S@q1Rzie?#>!Y6r&X1lde0UH*EX2aXHow6>f60iM!v3R2{LL0b9v1~=wlh(3 ztX_VbRgoL;{&;u_u989APRH%M4r9iyp`5G1P29`l?3xmh{Z0b3!9`VG<8LGQ&M|2s zAWT$BycZ>eR$Qe zBrxMk;zd;r7; z>9DY7fnRyZkbBOv+ZraG?HBlo8OBCK0%he_P!+0(7gW?I%8ccm-bF_6aDt3p_B##I0_)s`bZ-Ta7Nmb~& z^S;0H7q8xRmAg+5LaE3rdQv%KVquv0YE_l35Hh|@*f3Leieo-V9G4<%pLio;40h?m z3_yx_m^qofvr_lb(j>eltlm#ASU>l5U#i}pQ~_d!H64wj?6!tX_~l9(6$NcfFE592 zU|zCR!!fQ9YbVuvyEqzj&}~v~&QX4OvUJvLw!R37)zxNiB!fxmz6gi7<)+D~;;44j znUcd~#uNya6i2PPG7e3LepT-2(u~YNdmO2&-71{^uGmiU{j}H}O^RDZo|Ey%x;?a2 zP4a35kP`JPX-BZ(8B5&}CNYb*)$MyMli9M(+_Fx2XdXd_CDk|zr`d4k7;8z)TSjHVlX&4a9hUtdvz3_gfN(X&}aW~_y~ zS&b~!eXapMb757Xs^fe8#Ro>O)Wx^ERdUx1nQNxJRg$$tb2FqZzoaF*dM{ba6v~H* zp~5Oy!*Pi&jhwVw47kqIK^E*%Nc?L4O z%}e(HGAx{nbQomRNur|oi3=Z zY9))Q09ZTSC5Gsl!MK%{s_%-lx0rgpWZvJL{W0xdDlMCl{y8QQtYRNsIKx8uy3O0bqbS5knuw(Gc&{ClQ>xrp^9x@jIAt(BY!Uz* zdw46tise@k9HZZ1YIFFGE;+!Zbpf#v0V_XE;}Dh=^vjAFFUC$m@Y0Ej%Fq5hI<37m zWG9szuf{FAjC3pIkDK;Km48_na!F9R^daW=ii$`VRb}_ZKkScXqU3dlRqn31mSAb> zU1BDN)-x7JhhEvY@?@6!Y1H-sr)eJS4OBEep7s)$bMXOyEMR2W_H}y!ucY~{lSttz zO+Turrq0>{$kZ;cp58PWifpl1$ugsZrNQi5=k8k!I^l{~tBDqSM9JWVVF@c<0i}jo zm{%LHi*e|55y~SUKDtH^GcYA(c4YGmf^zL%OiT4A5ndCi`uylZwcc95t@*Xa z*$I$-A_>|X@5eWy#-^G>d4u&p4iy{Y9pa;yc(t_vbS4J+6A$csND6K)I3 zK>~9k9A>vnf?_phe&EP}h@zJ4MAO$^7GGjQbPv%@)WRa-9Obv;e$c;~jz6MBaEy0& zeG6R%w#3iyT!N1Win``L1o=yb(O^(s=Dz$J%BRfQ!{*&r73I{MNFwnNAOOAE3cAGt3L)o!V%-(RNpE3WvMSVnZdOr ziEW!Wm<~t*v(k@H${>aw6+DH=+9eAa2ZJ=u#|wo4@e*^?W$Es3}(q>?YH5^DoJCy%~3jn>a zDIm%-j^Oejc>FE@JB2l~lTL2Q*bWG5GkBNuvoudHieM+rpdU07A(q4c9md%x$#a~X zB1JNYlRdd@At_HT;4e_TMOf4r>m^Hi(;{Y}9Rc0|g2FC|)x<79p?FM_t!Qs)tPkXO-U!!gGF}#3t&i4N6 z0E=zE@BVOb6ujO$-g&#d_wG2@e)~3ndPi{7*xNl0e%|Z;fFO@{zu!KBDhE&tAZqCQ zJ8$2=-rN74D#9t{?H;sa062IPyxTq6`2ilcU+ul!>;4VFVe@bHy8FAw$05Lg15L2| z)9!vZIQ{|Q7(IKn8@%1ye)V=Ycmq${`+p0L4|jL=w%@j((?`2I-4?>z+ZPW36atoh zy!&6?12`xayxxAd{XKSsYs<%>g6*TdV{G@}eHQ^75KI8Gzso=o`-BYWh=6psdjyDhw@t9$*t0} zJkW?mrRd}Nd2|zDRBIAwwlmoN=gM5C6&$vJXOB6iG?Ga{aaDC-a+9KQ9Sx@_#7lxe z&t`J#L!dPLa+B^Z4;z+kBj!5d>YVn7;XMoP@PD#RX{`j+8;2<0!oMn6P_tQv*n%oZ zY>j?feFwQ1*bRsxy8lIXOUi_J(on+=;dm>Di2VW1S@f^qK+ZkJ78=x9-Bqg@E;6f? zlhcRDX>U#+o_$4I1XCG{N(KG^I1NmI#IATNy0aZL`Ij%s=(>ew9< zwd(pN>RH_r)yy6O;$=G~#-r5vK2u_lH&M)wgL^v+LbMWpRqgeJ1kNulAY35fPN55r$ z5MA7)jTMSBlrF!9uZ+^H~ z*@1ayAarlXhaN^-h!1*@(;SxcUOyez4^s9Sphim6qph&+`rShxv=3x9odX2&V+_{OeBzhb5;^Dp5Aa1l2b34`` z3&hLsK@vSaf36apOCFS<#}x=em%zvKSCMDHNq#gP zBPX*znY{*qcVE*&z3QWJo{&e6x7%`N8D|x}{_yCtNiy!v&wDAXg!qGZo5==WPx&}j zk1vsA#ozFgwWYd6eQ>mU-aXhp?wTWpQ(Ez0OOC81)Ip5YC$=<*U1xa;k$=}Ng2 zoIv|kyGvle+n1$q-P8C4l|TpMHz`n&w`rc&_CXXDJE*20Z3qz&q_&`1|K#oOw& zY?XGtYS_qqb|e|7BMiNCa64B)HZVZa9BQg-kNOo+sZEPKhKeTo%9<@(mHZTJN7vL- zVb(LqoThFh|0X@U0rV~%v1@BsV8g1VFnpA!qSJ2lo!IU?=rRA9w z!!qR}Bbisz-0HMNx7-bkUS)O6i1&?6F+?=pftL}^;K-={yDtO0XX~llU5bI4UjV(% z7n{oMcenTUcaLnoJuaeTjLXT>ZFT8Vw?YO$Mesxy;)e3{8P4i)UL1_O>7&w431A45yS=hWgbzveH!AIHooT(e%qR zQf{XPck{H6>n3uatR>gUTof}MzXQHr;6nB+M>^LY9ULB;3sLi61;u_+%U8WI`GIl zVM#R)qLeQ-S@Fer;p90|oV8?qk-cqJZB7Q~)ZI_VWUlIiAtB3GfBrMWgO#0(8qIJ> zDawME!IBM;Of<#fXhx)mtT2s6LCT#D1v9s)*h19m8Vf1zmdp^v{lJRj*?#0Ptn=eQG>`i4qDr z3pSkmtGIa>02FXkvNAOuum-IQH0wW*tD>?lWd-n8?hCUW(mVFU^Br54Jy!?R zM(T(1hV@>95FY`d!kR`S+Ksb7gX4{&}g-o(69`erCpAJ zUuo8luOApYn#=$B&vH;$1r5#wSrTtGuBiBLznMsaDo63^Xv54dNGeAyfTs6bc0JP!6= z>st|iwWzy(85d-r)@USr>f%ZN?z?7Vi2*6yGZg)6LwO9iv|BS5S!OFR;{?!mick)6 z8%9q1Yp^K_h-Y#6;xzfUZ`kDDoF@OKn`CTc@d(bb!kC#@?6AyDESeM#L$2h~WA&lY zEYo9URs^NkkY_&~#AOKjn*g?Rl?<^_2c}8CVc;eiev_pmSls58c6g(YD%d?Cve}1H?Vg`H_2T{M6Mnjo=7{-+erh_&{B}U`4%f|vT)936=FAUpXtrVGX6ahNUgx&)Q znw&QLQbK9`KxBmVx^@0{M%yx#?o&EteYUS-Z-=oDy;aSUu4tT$BKr*d;n8QZaTAKU zyHWn3Ra^CN7=heO=Ul3&l+EP(oAGau)hQ+>Y83|_%@NxPMSW6P5g13+2f&s9#B!#nPV;Vr#I%O^FGBHp;r{iReSS7iAx45XLo|-K73C;)Af;Fk9>bZHWd0qMdKi zG;WM}upTOW!b+oXXjoRg+=b0EXnIxy+j+ePxg$$&E87#a_1iQ#ii@js;3^&LdOnnk z-i#7V07YuSHfbK@(V`BaH)ssusyTRtRyL)k^@VdpusehzK^ML0gzD3+i<`1p-$OKB z7#pm!?EKJ>l4OfFYD;E4Q+^AEJYl#xlw29go(wI+2DTNjOAy;SrkVSEe0)@TMU|U2 zW0IZ=+ChTMv3sn%TW~O5Y6Gxlzk60)+_K@d${DS{s5<1$>zol9DlOpC6+Rk{bB6NE zkPaEj7vq`He#sBR#G{x;vUL}~L+zkp47Oy(>J)$GD_nNlP_>*--s-L!$1{iN`y4sU zGY!cMZ@exY&Q7az?y$F&Z+ex(hk;hZ>BBcH?fM~pmDkNMF38sPnF-e8`r%;2@&d_h z%i$_t5C;_{pAh#BMfrw!SY)-ANapu|{6e3RT4-PALGsLTA@QN7)|JGm@O3UFH8}P< zmz1Sb&j6~tO*}oPFBKi3ZBln9`r7I5QYP0ZPt^OWJgee|^E<6LJ}Vxymc3V=)t$5}9a)~uIAPgp67q4G zg9Og@b@3v0hSy6aVk_KV>bzc*v&#&bL?F-*1n)$`VIf4K?=biN{2Z3eIll(}^FmeP z@=7|y8sxZ7<#`EEdATh7DH@*5$kFg@Mv{hS6!`=s_Nbz|}IpU%$@ z-yiLspFdvooM%NgA(dd+p5azGzjD>d4nI#YfBYvqfmGmN5b>A8RbV))PG! zdvuC`Z1)BY{>%r+mnmp?>2>%!*XOh80ePR$7 zQSK|k!T5+e8~wCOX2MRK!-eVh_e%v{N(R2R+`<3p7rVJ(rVCITkkIg%PZ^Q)Ac9q<>lpYX=NqotZua7fB5%!BUpLb z!LPvvmJXJepHdlq+Q_k-Q4jz3>$^_pNw~7S8mw&4-{JDcY8(F7Uk?#9{TuM_<@Ipo z$b&aQ@tazXT8^O}s&hmP&va}H{FK-OnPnN=^wWs2bS$o5* zy`gH$_5!QD!0e~&p(rw32DHKdXe>_y{#TUY2ZkLkEiM0QhBDOLy6Gg9oWXcI6^ys@ zjTmp|OBrwHTQc6x@4$FFe-y^s`Fh6Nxd-Fz%wW77KjZCGG2YI6jJGqB@pisB<6XHI z<6Y5=cV%A2yYkP)c+r*rpMdWg-TV*6c8P875F1@ZHoCzqbwjXJ$&Q~sVYa%e*ed=n zCr*a%mlT`cK}IfN5VKyB%zES35rA7>>UUPc<)`a_h}BN8yb*3d4fwU%$=m9wO)ubI z@v6IoQkUQre{R#~Yv^o$Nqm&= zx#ksqU0=O|pI=gY9l0@83UHo9kKq5WmzS0RcGcI;>bK$0D-|4i&?|lpy;8-YSLWl;D>FIt$~WiGtM}s2tC~Zv&dZ@! z|G7AH{HZ^T*v{~ufKiuw`ycz5{8Sv1SG~vNr-JkDXs)g~y>npR&xX$ z>e3o;zg1wfOX1qnHT<=@p7TRM5B&da^{TBN+WfG(4j@-o!gb`5>%j6>*N0ES)#VKw zLmwWW0QX*5Uj=Tsz68hDWh{Yzo^Eu+)79!mxVF09UnhQvQbf4E0`O%K_|xW+47tsa zpR56k-gvSKtb6Gxyo9sx+G<;tr>Cp-`bxO6v4Wg_V`G&#eYgU+Sqq%`U?0NO;+4Jf>*z@WP_Ppw6&#P7Jd38SaygHLT zuYPm(yml}4yr$Xn+Pv&}?Vp!D17(QDmx@7e{LvY-?C(E>ML${p!?5V}r{UW2lVEjq zDO_4!*;(6o5^e&o9r(72KYsuYw*)8IHnQ~PoA`&AVYfcwzIk(u6BTBufXG4ACASV>rdJ%*uc{O;6LfKSD@tDanf$kB@@o}Le(f7E`L!=)@@wCc$*=tmOn&W; z!sOS!p2@G>gUPSWVDf8zCcjq2~^EeD%{Q(T9*RceD%Np3_-k)4ICA(86LV< zs#a#X=Q=CRja*cLz_|=0t$xgbDQjA0W5e?C=RiI8+Xl7vnD^NZ<{)TNZzmdT4H`>j ztIaeia)ue)%SsJtM(;h_^eK^B)%7sk_Pr~KxZvJ;otkTw* zoFGKv3GYhyc{XEecD~AX79rHx%-&;nc#U4|eS2>U+Sy+AUPp9I%_uZjD~K_&7X_-u z$SqZ*rW6EBL?GL;!lq#m6D;$Mta#V8N??6nmB9KxS|vbsw#srBlNgkZb4{CEV__N@ zB!vO3NOejuOY%^&sgh;RII*l(oLJVs(TQdKOHVB8-}1z={yUsl*8eCcmi4bcv8>NLv8;dd6U&o|6N|z=*~eQ^mP^yq3U}8)S!98-DSLB1Rze zQmh?<$YH{|D)?)u&&mxa1}LvFP&c0Q{ADnX_i+(r7?Ioi@i3*C_=MksTlm*u@v z54>3|;*=+RKJOqIPfmvkp6hs|+RcjLJPlRi4C;UQRsxk37X90=2AE$*3BX68CdG%s zhDC5FMMB#Aa^@^svD}-_zIgB|-u`h_3@yE0yeSGx$Kiks$Y1-3%I4py{Tv7VMk>+`eEmI~bws_ZZI%z($f2 z9!q&{^0?@Vm~9O^7^by=HJDG#|If?UDDH4Mw647C`1H1 zPL36dv|b{BN-}8HIyxu)k3U4?!O$NEQ%#G=_fWAN%_7pfSoZ!tB8Zu|rJ^Z{tyCsc zzx@_`DKk_9Ffs0pQ*u`y=%?k01XzRH`ZgWqG)z5f@O7`MTNOa(@0A(L zmFw@02lKZ-oy@9Tv1DqN_q`X5e?ix;o8~>C-E$GtbZPD>tLeyB!nn`O*Yx7PlW$k0d;q%7Bj-$lY-2QNq<)jK?o&g_3FYR>4J)t43%EN*L+V1gjfMLM~6cTm$2Ja^AM_wCFl3xrmzH0!7Ep8L6WY0bC9?st%w ztI@l!JNe!Bvi*s^Y=1KEW&4wVFZ+8A#pu}I*95*YqBGj+Y*m7D+S=L(2}>&`40CZ3 z2`J|}7t`lrw-AVa*Rfd$&KWZ;+l8fo2DQc3?t5gNk5aS|%8P9Ul;ysx+!DDC@fm*w zcgpsejTi~vaALKBd{G=P0BXGLH!Lp!1Nly1GHViyTNBI7UUi(^2PpEGnUytE*;H{2 zsC=s0fZGg9X5ftWpNMZwMj0ZVmz5#VjTn65vAhsBFdVhq&6;`lb}Se9=?adBz9uy3@rRQ8vn6aa%P4KxlttVHmAxWRTW_8 z>9T>#kgmon%CYN<=Toy)g=h)ZiEd|Ac3&AU&J4gE`E%BudhkG@jI9VtJKeA_aNJv} zTwE+G24hYbNNM;uiLg7{V~o6LO`?;I*;CVr|0n|AdXqAHYI{NtS_Ht&lw3-AG%hX4 z5+0ax+mYrjPA*on$bP^mS%KMeg`wUCw~+(x+h<6M)%|%W^_+xn9)7)o6$X~ zGNXGkpBdegnPzlPzKt2(;$onW`SL;$#Ey^gIJf|zCqReKd~uaa?; z?WBWv5jxi~Y=Ux`_*xu0HYyDB<}i{I25{xn*8V$BzE$2u;hpj*R_SE1fXw}-vmptu z5H|z5ll!^W@yM;~_c5v{98$kL3SEvoAC}VALDxS#`fQB`6W7fF;Y~6eiWF05jD(K1 z&uSBwF=pG;7V@F;^|X~0?E;F`OoLDf#nJfvgpO-@!v$FC0l~ai2j1fO>|1w$4t=vb z!1$`^0k1@Y_6J;v)USK5L~As^^Gcj^9=;|Qu7oiZv)BR-HLf&8$>USep!!>U{th!ze)6DMRVyfCv8vUD$Jv!A<1*hq z>C6UhX-z}idQ0T@{*Sn8zd9W%6|_RDr$B+%lw9n0;D|#?V*&{8Vx2x z%7{smJ~M~89An7UL?zu6b#Zo{ZDud;a9+I0#B(wXRBk*GENCYur%)`QzBrd=HPUw4 zD#%5`M<9m@W9seKuVoVQ!N6nBT&}V6c6a-zr4O-U+_S3LR@-nM8YOu?SA*{lUvGDJ zMaAg^)=GSjdgmel!m$NFnD{uowq{k?C(+KG+wz@fOHWkg5;{MRZlVOW6r7RsI!y-X zlPLd6Lispo)R^7qWY9*NHHHkT5Df1&iH8IIrg0C`n0cHAN==3l2pi)8d7jtQxtnne zzs%ugqBB*EYiqXYvq3A}Ljw zb5R=%b|&Ey!<~sAUW}guq}L)JvCMJZg7sKq-l_>e#fSm1dlx|@FPkxexjbc13Uhdl z|31ZIW(vKJ0}%d&NY@hB50at+a1;!aqJZ;Z&UGjHvK!&T&$y`K{4(vb>=%$F_my%H z(}R@XYD5GF%6H%0(_C3m?26gdol$euyiasFp4PhcsrYZX2e?GgopH{FOSDTm?9U`x z^%+#RIOTu2ruV7V^gf+e)BE&~V7f__hGZtE&a_&b#+fq= zc3e;u#)tth%uSrCY9qmt8Q(S7=jG`df}RHOU!TWWNl{tg=5r+*ZU z?$fW==svxNM)&CqjqX#wM)zrzM)&D_8r`QeHM&o~jYgNzOj~#lFJ3O9KHicxe!@6} zm&3Fd4G$*Lfe1waiej;2=s|F&*k>L`q1Ld#DAgKX8T&r~s{+X%wacc%5ehGM<6h0J zX6Y)G{0jotFtpX4Wz}ppJQvBEur~Wsa>}$AZ9{OmvR0SQ>93HNb%PUh-2WqB3DnQLp8Km9y=&uA5l{zl1 z+my_J>xC`5MUs!Z$oafpvBvLwbB}U@ z9{ICb+dZF>M?mGaXV9`#)yAh%`cv(2jg2mXBg2@QvpNc^Xnc{*=q45U#(l)7&+~OK z&ayO{(L*ltjk`#(qUY&ja1&+ZFInG7S?U{iQv|2BIx1C!YOQh}BejWn1K6UB)bku< zyF$8Xp~jXt7f@bmnDnAIK3sX zhzcnSZ3ZPsNQsyLl{a@SR1Ydhc4J)PKa2w?P5^)`_vxG}7>bk%yGKW?EJr_Q~Gp-KBzhHJrv3_(qF#Y>jrO=emu_O5X%TH5ryyOjiZI5i!6?R zjbR5dCa+25NmoKphW>`)nZBcwz*U^b!Bsq*#95BQ%V63^U26dY4t{zEGdRF=S@5sN zK|BV8#d$E8#zHTfWC9A{aG3OyVvHmn6}W2qQC=-TQHUk=Tb557*T(u6tMr;Qtm;gH zVn4qcPlrRjC=F1rs{lQ)0R8#T;#DP}Zid0utGcB8!`*6caNAYa)86bsHOQI-sE0}Q1@YdaneMNO`gv(t>4AZ|DhZm!~Sa1#d~$LS62R(db00_X@f&cS{g z&y>R?8gq7uirM8o%)G@NE;1UqcIg_IhmWsm@Z3x9(7%rh>RA@uP_=+pM3CYIj7%*M zUWTpUMBs-za%Ogu)MrJ?;cqp)(R5gTdu9!)NROf$%)3!FjS6Pihm(*fB`yj#T0wic z=^GMOfqsha(x7Ng!{A^Hv&gV>+OeX>1;|Vw!5|@vuA^gC(~GIC+H6?7Zcd!OvrK@K z;oxz>yTFg)%iT{CAK7qm;y~q!XA84P3NJtSkqm-}SOBvq|7d^0a>N<-uoTXO(KDQW zWc8CM%i}l0G%6Z8yF^(S8)IaWC0wTz!3GFOnl;8ejxoN5{S929pk?9T|A(;Ml00_$ zA<3K|`uNQ@#L#3REO2Yul%cvX$OQc>r?hwJ?WE)D7{mp!b&yy@az_7~re5R=Tm@BFYu= z(2@%R-J<@qf=;RQW?&4a7H=pLOs0j2K4v|U$4lng;& zl%z3BKrR7vaaSvFy-#h-Ue>Dr##|)%ezcG4mvX4USjWB*zKcG_Fc=X3NCFadBP|Ny z_=rp)@)M-KALCoiDv~iTAOPSU!wBGmyxD+Zwou?g()BjIiL;%^Qaj+FuoH?%vmD#N zsnbKlQW!-6FC>dBgyUUOG!|M5x&(H&K@udCS$YP4o>L8xw+dc-_nmWmfo4yz$VqZ` z=0?Qdzdc^MkeQCAs?niOKFT3%(IiPu`%5;CcSA9bDL<5kX?h&q28BUJ`!cNRaK({ zu!LG!e9@wg;6H7;R%j*pg4>NFvM;0^Si~b1Xs|~_Kzu8X4H6%98c?J~m5lku(=EIg ztHD_a)N$k^&{Zr%zYi`N1f!&`=8`Xw+gDn4A{1PtAQw>aRXSGtCxwqU0I0{T-v*AS=Sf^{Rk+@ zAdnQ1WVy*Si`9PcPAJ!ET#OxZLGNb}4AEr=)|)ZXBhTz#C3ND)LMKq-%%>{HGRUiR zDb%7eL{~BEA|e{ac)JI~zPggo?&Be=S?q}I) zz>=aY_6SAik!of!$ds@mHSCr_kj`5{-=Ij1K9IOR5V7}@i6mk`z!qSiN|o$giE>1f zq=>{otHz~@+^6gPt0>zp8cR*5L*FqwppCX%(W@T_<8mRw(20KgyLTnaGTu*5Uo}p) z+y8cE;$D^cBIFw_w1S29qveIB%_;nYI8NY576(0`Ccz{f-eT5i;(77-I?2-Ui0&zg zBM;JGoEAYoosgy|5m!c!#j)w|3J!MZ=wFY6>8S}n~@=Otpds8@sT#jL|0s3gW)JS6e6^t5a66}`3 z47aYz^)QMl5SqwCW`@LIF6k~-X4LeNnqgVI9RkN$_Iuo4jM1!qc-w#;wKV*S1hY_@ zC^r}Oh{i?%k9JlJFFY6dK#>HxBN3wzMLh>5UO*L?l%#tc;sVp%xD(pDzZ7|!#j!Tu zF3>vcM`K*|F!djl677TBvRH!D$utci8WppXnwC4I*<;j4~FzsOig0wu_rz9kS z)V*CPrW7fkeNgfw8;;Dh#LPtuUH%K~X33I)QMfgv+Mvw^tulZ=VJ*N7C3+Tbt`gWv zjilW!Yw|$~7QjyuqN@P+tWq9^Ki*SC@<~c3NsNaC)K0;QjHUX*ixOebP^7Kk9OXQ7 zTS>7VWDF!J?svY#If1X(d-_Tbl^riqZ@**cqnc9`P!5D5jfM~*;kyLX9aImZNX6+D zWIsn>$v8vnUF~5-OQ*iGijZGnl6(QkaO(+$GV;&_ zL!+@VmtPlo8IO;t;*U`8(Q-qSEmL^$!Ca{@!FZ!%2vpd3D;W829`U0ziXMfzY846R z$(fm}1|O}4eo2$D)*w`!w~L!p>dqsO3x;V5%k)-Q`?sYEO$t~E>3(jhD64OU&K6^< z@TaTjI@Z&e!(NEDd`P60cCi^+O72OPv|+ub2PKvkgHPm4m$qS9D6M_e^p<&LmgzN} zyI~23G@_z{ONz7GGI=uY^|sxMJ+mjC@~=wed;YY73O;p?>&{556-g#axRejofutie z?#phCwHdd9WJbhjDbVTZgi5^S;ncydUK{CJVYUpd8l{^D|qsReVI3C8TH=6ddQ+e(r7W;-Hj z1g9MTev3)>dnnbOVJf;gPg*3)z>#hp8eZ44x!bR7yDX%bE6bog52}cd04-Ge5wB(O z)bku=%INfV&ZnU>`0+)Oq0J2`1@XXol>m|=hgIu9DL=V%aI$$R#M4wRIs_C3UxNw4On zAQ_dxHmefDS4!~hWgpAl9p|V}G%he;qL28*u%vSJ|!bnb;J9+dPQIA zzz1B{=NBe{dZYKNb38`_&))XK zkuF@9gGG2mQvv*SdyhTJKt7?Qcgu~r8&-sRIX*r*-|lvg0P71FWTZ{k6Iol{b}lHz z-uChFZucCmsgBXbX2HBDSr{Z)OrfaofxU|t&Q#U6dvA7k{Fmd3F8A}x|>D)k5&cwKDoT4iNFtMDnt*Ewu|J_j9+6Ld9q(YFrt$? zj0bvoi8_Y{S;YWN?8Dd>r$sVcl*WD@1JGKFA+ATdfn(LcrtjXNT8`i8kYcF1RpzXyOP9l&473q0d%de)?uj!d^_X0co9m!<5SC zeq4{sUD6+3iFn`0*KSb8f#0;qeM6xSB0~5k8yHmdHli!DGH6@?KFIif9>9AnU-jdR zSU>0JkZIR^fLS0L2(KTQgp;!h&^rtZb`UGvqG1xD2Qzm6x@`n;opS>L3=GhGuRT+~ z>sGhUq~ymFcVVb|GuV|mg@Xw2uE2n#=yw=&rS04>DsXAE2QkK>K`#Wfei(sN1)wmi zz)hAEMLhQHPJOrC#R!q(bmj=03-tPd5Z%Hd=#CpeQLFmR$ANeBa}7k99gKtN7_A4# zD$k!${;G>Rgs1V6OAqasMhy$LTa5-i85Ml|vI`aVnQBPkw#49Fb7&)Eg%csYA>^O;YR=PTw%TjQZGAl&4-| zdp=Aq;{I)a82^x_AAvwQ5}dZo*GG)$IH8NlA(@-!i~%wOgEfGYbybXL8DZcN<+w>} zmv*O|ODJDlsr%5WsLJB|&CN}CvqCa^_h=CTuB|NQF6~)8#Sn;P!Job7-SVN9B9O+HBjH<4 zgApc;;X<_ylVjIirHYY|YxFTnQ-KhxHH0M%1sU+;zbCR0w4HobsWH^<044hgxg??Zj0o0C>gLC8ilnkOQ;1z{ErHUTiE&sRRc% z$rxic(7{8Q3usNid%7%9)&BfvQ6U^h*U4p6q*;hE^7bV%+_Lo!UtsLvT6|9`%f(Ti z#J>TNK@Pph3+DZ{UHGXg{eD|nATD6V;AyzD&A5J0G6FE1(?!@p-{~SkRg3*JOHY`={E~ao z0DQ?9(+E#Yjm3*3i!aho&_V;7Xf8J8?7!hJWEdI2My4ay>BGR#?UijH!?4Pb1RLrB zIAJ=au6D^Z+sB+sXDzS!AVvls~P zyHeit1zbFBJ$$zGN33`h{l>+Gsm)(xlQFb)%Y{%ojDEds$H3}PwvGFkbu+jIK}j5} zviR@QB%^N^!YB@)KmkXom=R$^k@lzeq~cIcNlAW8C5<)DFF0O{$SCWZHC#%ny6tu7 z%&limp|U-re63 z3{f;pZ^mdXq8ZTnaa=sBR%umjEDj|pMiTqFVDvvOOfeDKLK-7bh?U7lGr9)R65Ccs zVeA^<>)5orvlk`>lN_hxHg<7X)@}><%^YnxjohyZ z87HTfMc)T=K0{);T&RHFi1LbMngNk6j8GBE*<7Eyq{=Zi)GL-PHLs-W6=1NaqRP{e z_Uj-&v7e^#`&?=yvUrHMG)Q!cW*EF?WA!O1;>fM6h_f+UqyK{XF#Pht>F5V>^b;We zA}cWnZPZ7MeH4u;G%LE@4q{l%A}5k$?@1y0Bt57xC{lc#kk(7oh9A+ixI!&D0TSkL zsQT*oP2h?hyUUF-RdulsRN^zTzE8KCrEgxZ5;bmL7xHo!u3d*H49N*QgTu|Ea6~aW zX$|O&NRk3nwa)J4t~;+nju(d+ybL3v@`Ae_X+yLT`FxI4)p5gEul2*m)%?>wC&!wH zYN?l0sZm6iEy_TF@p_Zt06N(U3Sg9&7;V(zh(-9M)Os=?8tWzBM1A0Rx4zU31$p4X zzn(M$oS(zWe4&#AihiJziTGJAgq=d@@TdF{dQMr?M&(Zw2+xSFSZbWdi*56-a*>Pi zjw)0G>0+!S@6{GN#yQ^`)EC1$DMlDB75s~@eEqkli3Vc7s;Oiw&zinWqKxD6)s(>? z20rPKK7t^~_O&%7j?xsn6O&IsiM@zIJLzb|U8#h#Gfc-GYZjx#0S~z1ySd8IhsAiT zDEuy_#a)A(B;Uq@hv*h{l@13UN&2o{VM&`;vs6^&(O%(1)plHv*Sm*DyF1(6-PfCZ zt*IE9J?Ey+P%aol(8m;3iUuSVaEwR{ z*ds}*9tiGuhl?-~u=t3e3kwU+Y^CRz!BJpLBD}g!_{mGp=!3b)t!*GfIH-}>>RS;M z3E**i-rxngJ37{A;Qv_)BOx^jXeu&Fe#N`pE07n`o1l+dPJC52MZ%&UyUTY%=mRYt zr9eV<;!5Gbx5E7_8rf=X~cVB=*IG$qc?BR*;8!hnHK6R!{6p&*k?ro)Ko zAxJ#8vgc!tjf9*c$fPxx9RP{OA~1-ZbuT?6bmWpc)W+pLDBvh(SZ{<2X;b!=xjp|T z2|yH=a)5kvr2&3#$pl*XAuKWP<#GlW5+4noa4i--ziNv=)NzOtQbAV}i8k=iazz!D$Du`Tl56|5DL%Td>K+NA*j8 zbfIHhoEFC0 zT`Cg+vKHdpr>$VY12;~{7EaiYlSs_wie&ChvJD=A+C7TTrxO~s&}PF25LZ`%p819r zmT#K9#gAih-rF%${S zm@mSuoNRgRjwYtbr>~gs>S>lHI1z<^1;h~%z)z3pv;lMMt0pOle+d{4v1DO@2xhns zA36WHM=s}rq)@eeigzaOd0r?`d$e=dw(g6pMx9DbGq?4AwLkkmzwE9Ih zY~@$UMbV0eMGN+L)QUgB;#(+1E(e)8l*Woej-ie;oNu0cw%nHVjdj=x+%R%wueH*U zNYz;5W~5g0HpxZO)DPE`iU>3k(AWyv8o*`{S}VU$;|+rEsP5y7CViR`)}qb4|aK4^zJJ<#z55!3!tG;t0fOQ7{_6mXZNKmSaBvj7-aFoTyS?}BIM{ysHh_9Z+xy+U z-Q(crz3vYP@@V(_?IWmi0JQ+3hQ7b^_Wf%NNskrx-W|T(gLVu62XBIRyGJ`ez~lC- zy|;Vazacnm{>@%@fA{z}1Q@~oK|r}7g5w_$j?uGMyTRMN?N@JigE#QBz5lo1_;7b; zZ~JWvI(@Xe(+dwc+m9tB6c z$M4^EaSU&c4&EWSw+F}6^Y_QQ(9Cvs8*2j=q07fDsJaUsJi>l&!~gGK$aE}?xz&%h zu@n2d-@o1aes_Oo7b+sa1FFzHID)e8k42qUuzj?5jO`x0?;?N$f(c;ucNr*RpO66^ z5s(gdj{p(xwh8tddp2kReABfr)D+5?;hZxRxC!~>9l!o;B{V>Wr--I3)F`S9Pca)U zfLLx(Xwp(}E3!x(SJ|NEW|fnqoc~ZYGeQ29H;Giwh-%2ut1x9Uu*BkIf|6zqe`cDg z7M|mc&eTnKsB_T0Q?83}0DjaVgIp(!3~-T&aHC0k$YMFP86N-9V2px;NcFC$qx?>R z=1hBN|KH<;7C|Dtw<~W%U&oXC-iJaJZwC5=Zsu@YPBKuoP=KC^taPr-4FGMsisNa| zI=Dk!Z_0ZB8BV786&3Kzj18EBf6j)jf`qC@TEScmu!D^S9kZ`^Bnhl1M6&XV*B=oV zh;8hMU)-Kcvq(p3OalXd4dCgR{B0{_!g9fe+UcKz_~HVV+@?_q1L)9bn{$SXsKVkn zEr6@e!Xk)Uc@d#?$*&?uKCh14kC z1TPdI6J!OeZE}nXIURETWmM^8(=px95F`(nn^=TgObH6#W9wI14Ea8Z19HT^o!Qo6#|2vRDpsKVXn>M;sYIhh8;zPw@m+1B)u^FnxpM+^PDBe;u+vGS7AO@vF{`LB zi_2%`kwx&`ue@B69R7A3jW`0U&^sd}zL6k9IgUxFh^WKl>7rEn$#ASJRrHxv=$!!R z+7fCA+6X{2-%SsN+k=j0fm38eaR98EK_F1wY6hhkyKguww)p~xk`)yK!$ik28iXZ4 zQDUP$hIUo=!4gk+nT~1eL=HOxN%l}eAYQvs|H>ePT);NU&D|w&$$u9yuIj3NsTJ%0o zYQ$p^!V>dRy-?$JC1FQ~Ar$o_J3c>8d%_~!j=7GOO^#MAhpmC$8l_p$L3ChS@haT( zf0K)D)2j~?jq><&FVmnv#LxV|#rmBGwva$N%{d#nD~FnAc+IjSUdRWCSj2dh1)n)` zln}W36sqTo1R-A<)*gz(LYQlKnKP%sJAEi4Ruv+jIGRrhCVMc!R6BWy>W9CbzkA=^ zrepNu#g-Q!QRPiqPu>EQ)Z5;t6=_oEP-WR8Y|cD7^7eSd zRti~Q(F#qB_YcnZ_V@NsLvsGp_S^Tn+Dpu&jcj_|r-&Ul?6Y)3Nu1I^MsyXYPN5LZ zlR<2Tn^=%G&?2)Yeh@R~I@{(~7`FR>*Pv;RVZ_6|yd1_{LfA}McVR9BeHkQes`4BI zje`EwykrN!w0pmU4U7qaBR) zrBp}qiPm7 z6Nn0r(=WJV_MJ`@`JL~G>Ipq+0;xJ{dZvra08GrxiUWH8n{G9!Vi{MAhZdM6H1HC+ zM*vVi-pwd1@;?lJHT(!|W|Rv8(}o*XFi4LC;bTn)5;YGDo6L#mN5WK#*$1Cud$EkH zh~};yKq7k=9@PMX8N}Txx9Gc;`)Dz3iaJ|?IA1V^kJg&2Tx@!geXLnuY(^vPr>rGb z5)mx3Wt%9^tHY~^yC*ny#HzUTLYz-AS&}!Xo#YUP8qi#ZmNL+1Fyq_LOnv6s%c3m? zO<_mbYF<z-VC+a4 z_c^`*DmJg2$=`mXcsUowvxsnOZ6AV^FK-JLlEt!cAwMxT=!k=VLjO%SIf-^EN2c>;`8La+-y zkfXak$Iwv7jwLyHGmPNGdi>+wAuI+TVsI%|N_*vnQ5nBiOkY)iBWd=k<=&Ly8`q@X zaOk2F0f}Q{9TO9&mQUH+ej>(c%V%@}S<0$rpWj}`9Gff6oSbOJVVeQKx>TmMrn`<# zzdYw&AT?DXQ&DDdTUsaEeABT_DoDon_Qo_{;}}JCrE{Y+4zTe+K!-)kHA}0T(}ce8 z9B84AtHGj@on}cdHWVR<{Apgu9|gTS4sgv%nTSkiG)+@Hz$X9q3X5g>Va*ZTs#R?U zCRhCTgtSJ5t)VbX!lQ+i{H1}K@W_0=Ysc%wrW#r zJe%v}Hur6)$;v9)HH*xXzJp|$I)J&2BsK1PWCppcgU_yj8_Sz43X^!7X6A8G+R<@O zz6RMkqlCd1N-L9J)K9OuW?u-DJp1adRW()JL*HCjhFS&CMq}hNQ2c+ba z;vCxMCO-`f-HggDDNFG2M8*)3ubWj4SUVi+8sph`rF=tUA>z4ZMuZ{}hg7?-$mYsI zAhSU@5DZX1)bJa~07XE$zt25v)qjkNq%z%Mhf!ry?M#M=-{ZliwAWylKI&1Z0*%gh z-c=R~?zzn!JWcX%f2 zw^ownJz;rXxR$7X6dUeN&+gN%oN|~=;4+wcnsEVx7Z(Lzx};sCi50%UK4sBhz<#Rs z7DZM}xiBqO?4}+E`wa@)!9;O^Vz*=Y)R`>lyuRLjyW8FU3JUv;>7$#%)@KNk%D6f*TM$cVI<;VeEPl#% zDtQ8XMdn|QWulrynP6Iw#KAqFZ0L&CU5cAqztY~-Jb5wI)fS(s6>oP{wijNln>pUNELLG<0pIONlHa zc`q`&Z7Y_Aj*v2+q%wDv=_qf|osqBKDT5BsQUP*^83?WG{!H`1FxZ2&GR#x5i6+56 zniiP+`X-Ae7=J2rZG$txWgy z1?>!m^flTak33SLBXYu6a1tE02Z#h`X64!ig-4NWOe>8~AG&kigjqtGof$81CJ~^O zXsh5%gm~Z}--kvskm=cW$=RdP41@O^&ZV~D3!}{o)f|c$fMT7ji=>Zsr%jVGL@`g8 zR6d-?iG;|YxY0k*QWu46_sU-uk<%5C+NmdXmc~h~w;NJ3_5Ww@UAWselKj!H0z1A- zGJz=Dc}=7^UXLF$-iht3oqlEnfS5y}1M*8M8L4l#5JuUa2b^RgbIu`MD}ygL8%VL-WUthT0ZJvc2h@^p zBQ zTPkzTH@VJW)V(X!-^sNy(1cuNyb|m{21tx|Ln;UCOl`;kteAcB*RuE!KUF(cCDQKn_iJ# zH?ZVtMF}ilGNg-_wI!yjHCenKS~wO-dtz35vsgt7?fJ3btH)TU_FIwZ2Crx8i)Khm z`qyfG4nHLk!+0;c<>amE7m_#Zl0le$^Wn(^fA*ls{YVYd-=Q5F<(huRJN=MvsD2~4 zc63h*KuZI&D@>{1gb~;|rK7L@m)-h2qxkRS+1KLB2VqCp+ZfTzXWAECK1NX6ScX#E z%FASB{GVB%OI<9jWi|;SSNHH&6RdBtwLJehiK1(rDp(C zw}SXO&wjTFY(1NMPT&pB?oU63?ZMX9qdX(5j^koX%wGR$0=IRRR0Fn5o2exe2O@{G zJDzeKNiS1ywvyZA77RtsRl##=>YMbR=!s+}j0H9Y0>| ze}#=Ft>7g?62PoQq&Mr?@;W5}#E z$IJok(yjbh`nN;Lx_twt%j2{qi8r3L_#}7dUcA-!r5ZIXF}t0(4f*`p`#>J3SET&{ z?xStl=)s?~+vuCq*vHGYM!Ox&san4vU$LzgRC6X#)AsiHlV@*U|M=g6QaP%uRWlyv zg|LU4OeIeJ31;qTv-H}d5kQ+bI%~eI@&39)T@nuZ25J(czr=MiItdUFQ1yENT#LC!1BH8pl%@?f)Jkf)Yq= z#p577u}QIqY}U8f84Y@ z*_`pO;6_1Zh4^gm5w!m&9kyLHFEsFX(2~!w?MI{NZb3B#pYI2|!$gU9Z-Q_KJZ|4u zu8Z$qSC!}JsyBe1PK_*KH^QKYm`1Q)eT)gI*%*guUz$|GMiPxEy%k}(K9X!yZq<*` zrsX~%K&ih{1;Zf2a?V}I3G*!bEt?hpxFQDZs%f@T9O%wM3SOCBY1Ocl2AGDty-s2M zct7VrLRl|$>b50jBbk(p?@O#h!?+rX0^SryP7M0 zxI#+?s6H?o+w;K<2IG-PyO_=3Sq3=}|u^Y(bZHwFiVja@pKv-yX1lPdi<~t&JU4 z@!BI;{U*v-2NK}6N~Xx0VVg^qbHH|Lt-xQ%fnhEH`TbVOM%8(FikYaY1*g5Jaf?VoiXB@eTTU4a~_FX!=jjj%MK)kdeSGl{=<98v%07M z2=aN2q~z-_7B3eU^#{d?PccLGTtbnpxQGCPeu~M{xWM={xO}+UX!UNC&>WZy<);fd zFGxy{!-=Q65ge(5;Fj_nGOuI$HIUw^0@UJ=H=2RDg1La>5~oSyft_kdV26pxGiA;~&*QRW8&JhM4$x zHhrW1DW=n$VV!d(LV#fAjCcVFB1b}Ys;*90MNTOMeDxk~L$qiH>#x4TZGQ+Qe1(*% z3tmB|gtsMgKc5{E?-NLzVv<#Bqu)#Yq_!zU4I8R~aZ@LK9TYwr)0~kiYA-vhIsbLW zp##uSoaqiv0C#X|rbbDFlNtXwvCZSf0Ja&hAY9|HS1kbz@01M40|rjHWxEd5d9#MS zpa;xldvr)qbw?%oCo^aJb5+cnJ_`ZE0IGq75KOnTDQ{F&F6yr{cvY}t-}_q%Hi%%L zG-SawOOxMw6IrBpZxWr&*}5Wa5t{Q-T@De$^v`wuVK{|L!nykEFQBW1KLQJ_D$s>~ zIz>gs6g*ZT>o`<`LG=C;aP3T3EnL3oxWoOKK2y~kat|#}GUEZI?6SnN;du-nwWYvw zj-YA|X4PVWw`Q1knx`q&fr$AF6o)H-xM%ccPDwN=gStR#tTUX?Rb{KIOo^T!#Jq0K zk&?SZNunnh-h-v$Ok|7N0_sBFJu;=n1V(e{G=0>|Rk`cdWqbV0_7|BUK|Ua>(vNAb zM{>?GYw+bI;bBB9(2S0&-A|N&UQp&Hal-q{EoP$0eJGsnjw$C}ddq&)R|Mgyc;x3B zcXx`FLIst6`4OT@!KAxvUaaal?&@c1s}5nm=GoJAy#j;VnIGMIS)zdi37@M#=$+z{ zq&3PKJ9fUnGny2PXiOph99XbTu;b!m*f(~I>QGaw_E!yh>tarl|k4cHJ^mczxKai^m0gid2_&*h6l zFf2)Gai?A`eylIc)lg{l zRQR%G4nKSZ^-Yn1Noj74dDe*;Pkwl!7@yt`HuQ&Kk0mvkfcrxwgUP)DNc4U z%T@XJO{G|hg$SVl{c5rE?9HnlO#t-$4AabH|6Ol%vIf<#Y5`IaLU6q|N3_o@5m5|1 z7@(=#NSaJB&buEfE$VQ9sE3LTF^kdJI=CyS|5cPB3jF@(c2n8U10)Xl^s(uqB)>nu z5w(HOgEr8JwYrD{mVpC8`H`II9vFeCZX~)yH`+%N%B2G*?g(A*9lH_eCtXPjFW5VV z(^nR6Ff=WF#zQ4WXK<&L*=0Rhe zOcZK?Ia5tRkh2oaOnOX)cu^IefgYzIqbr!c9pzw?oo&=5cClub#Z!b@zwc4f`T@{3 zz$c|x>H5}}wa$fxZ&17n`d1MfET?QrlL(E(pM%pA(>7U6oL`9EQa^}!Bd{Y*b- zQEpo8$^CV4FZtcW4oXx+wAxJ8oQ!%k#69&v2(eqkiLSQ+hn`he;oW55;l5K z(|&{ri_%xl6<*=qBc9@5>%r<+9|iZLO*7D>gF@||uD z>9YAwF%jf9w%n2LixX1PDE4WJU+V0KG#+f&MvO zs}K3v3pj1)DfrdTL8l{yB6RdUXSzes$qJOL^QIu3&?P#!Sxp(PumJa4-FhE}iNA#`|(l(rPpgqZo>955EGn6aJ%7B`h z)P>a{+sWbmBdx>I&tR(BE~Wl-8fB2(pYRe1Jo_Sp28h^`&N7oRW(?lW8HRLT%=b}5 zpKNWtqq%VSPuc>~YjU<-3(jOoj2E;Q#p+5Ub!X>SQ+Bm9;+m;UOIkvOsutC7g`y>^ z)$mxM(}8$93XOC(ZxXY+#R6{=H#8xY%pg61IyIq%c)))H_!_ z%47!8CR|L4Yz}6S(^>fuML&drIxQxpBY;9;7;qqj@>eCAk(4~F2;>w(e`0r(=j5V$ z@4*mGbw$IdmCrL$(>sEUE1iPxX3j#kxr;vf?tFpfNJ+fx^E;pmxxoUB&r&wi_(0W>%cRl^YJu#f}vT902dFT-?)> z!^a6mta*%MEGTJx*n1)~zk{6YwIPkM0B}D5fsW{Gcd?nDlq)ASD*)I^1mn(*4xMHl zmZP_3ex(}MCww!hLG1_n28n6f%Q;;~b=Z=*%H59?GR*n#AH{8dyN>wcm>NA$ZK9=7 zcV;hhstvq!gDa+&iQS`0fmuF^*=2Y;wVb>~LD7F%rF+15*v-J+}PR7W;O~yV^KJ_?2dx`O)fX)17kt&LX zUDn2Bi5}pMu9ogxK zc11rQoXz6H0`&1}aGM3(L_nLYx7swhD_{U%ugsh@Pg-kGt5!rc(y=@AX6!6 z2P&~nwfu0f8*bT{0d`Z6C@9{9NZP!%)FrlBfkb4b5MKLi*Q)7j&$%kKpl*l5_3X(0 zgH@)`gy3Dvp+fX5)?if*^Odz${CQ?>RDMX|EOe0&;?P^ z{VhlF+YLlK|FRJcB?oRe@xoB}Bmx@q4?=ol&O!BIsfe5q2L`d|3R^+i}8 zZB_2Du?(3XSWvSQ-UF0GXRldb&Ct7tYulU56!%0QAbs$HIBgYr4gytbV}+MuM#Ug$ z8QP2PXR89zh?H)T6p6W&VPD%Tqas3(n1f5f2g!LkTe5tz(sA*m0nFfplEE9OBxwC8 z86^FVtWxMcj=?OIqIm*c!T*X$HW5F>T8=biT0-{a+6|x`fT}W@-F~$7{QO4!_8I`( zRYxd=z~G<(3^l5Hon(#>Zw5j)!5#xijevR#Kyf|$TxDNC{?PtiHk2j+=&?`G!PWev z);P9@^lMzLL491Wj^s}H)=8I}=?`gTqUr>z5gR;#!#^^gj~D7h7YbjVgNx1Z4t+45 zDq$cE_)EH5o;v=5Vd7UNY3nG3xZATw+nOl^kfaMKMR-U?4oXrY9M9PlKBQ9HuHY{5 zH`1w-+B@JQ#y)n{*6MMF-+P9U;u1ibPhqYG)fgzkQ#^vC?9U&`xg*UPK`+9Q#HYn< zc2Z0}5a@_;hlB&^O^B>g+(N!84hZqQ*d>!(=Res?Hq@cS1FLJ#NT)PT&UI|4W_{SLfBP2gf;3MJ?e9Oi_dt?m&pa-fmpkCKG&BbVoi;ut4dW%({#lSS( z)oiU}f+N0xs*V>}VpvUMXCqG;LSwa>5UyE`vYJ}=YV`xW1=d$WR87_VrM!AwuU}!B zHrhOSR!r8LD2ctvy@-WIDbPlEIj+E#`sQ?~D+0l1=fM_JO!XkkpgLMpaSGFIkcQMz z^Aw34VTD-d#owt`Y7q2`1`^0Q4u{7dG|n2RQ_wG;f)`=7AWA`ffqqAZ?=&SufuaX4 zG!L|{_|=qLT8p)`*x1FtaQB9~`lon3#sd-+r7sueq1yxZ?durLVUF=x{3R$tXxw@- z$W>dBhTnv@$^7~;yPZ1&z`UheQ>nXLI`gac2iB&X_eRyHA@2j*4u0O!j@KWt85^wR zm*o(lq!HKcfe!`UQ~Cgh6S|whq4eneT}G0Hhz`mf52~0!Lwak8?CfENv2+|hhng`K za|=izw!~~cSBpu&2BdrtESK3!gPhRe69mx@dY}8CUL|*MowXc{GItVhWGpJeQFDtBBFL|T=Pw{{<%TeRniNu z(FX+v-vu7_nEExX=RavFdFVgE$nmaf_T0gmI&^^MZ`WJ+91-HpyaWyYl;SD%PdS{@ zP@ZOF(_T@SX15Q$)*zG^f}!wK82WYUcO4YvWn_^fnfyH&@TL@5)!M6Pto|~Sj8A`S z0e54>h4*&}24&9+HXI#!`|uue^^U$69-#+%&j&#f5$3kTo{NL>(g-{ppPS0=1OH=| zBNIYDM>fMFwz*bQ+>{bu%d$=Hc!0%*6}jzI&CA7$I#fOq@RhzmA5+cmpkgG2_$lZQ z{3Jcl4FjQdSoz-Nls+2q)+z92$GG4+qrd=CO6`so2nq)AgVZ6AYgKZ3!rBH+qWb}UjguP&>m)S6m|6G7J|uO(@~Mg^f`)oFBen|rZnxY!t?-FQ~1 ziJuq;8y`*R55)L1D~|9}*6|cxNTE$8XwKL$?J_}V98tr)2RKROv`Kvg=S}0yiB6)) z9PWDJx^EX?!=IG;8bLX&304^_v1Or#1f9|We`t*?8ch=z)>A0auloB2{hUN9hYA4S zhDXG7?w|RIkwfR=aXSnQvpXOAJPlJlqf>#LY2BM0ua`j&NV(TQ-xF6zDA#TrBmE=N zWjivM-WQ-~goNGfF~d*pq%8+7=pYS%OxpCNAGpCG(SE3g8RNFRF&2e{KKRqvW>^hA zUfBC%v<4i0M5RMTD84jG-TmO3H-zCwe+Y^Md#kXBVRW;Q5zaD3fK9L_%!lluz4rw?01|ei6MJMdu24%|*A&YB4T_{)mSRIUE zCi)z!!|crJ-%lbUgqpAetMVpPJd6S|!L?w`2mE;SWryJ8>6CC;9*)0(Lh59GcC{$x z)#NW|bVR3*#rn@m-u#QlNGW!1MRLJ!**(RnF^|F>zlQ9(H75n2^rYDp>h(c)jX->I z>>Tk&D3u7Z4<`kR@~rq>?cat{v(*U5s^pmd(OY1k*C}Xp0^~)-65EZB>J zfG#^G*@Ol)ph4yKB7<(Sm74MsMD5X-5ULp-KOy(%TNP@U$cGZKJenY+eYrxw_E+3} zogBVFZ-m$sV;ws-rBA(&`5Q%#7dEfoMv|Klr*Jl-o7A6iR-4$q#R&YzwIX(XFW3)X zqM^8cjqWAU%LZQ(c4+i+W^D8zyhX3q=JkPViPNwDu3pdTx+$Ok-8Izc*Oh+#l8i!8 zfw`?71=Fa&sdWM-%UD$614ec^=9H)eBwh|Q-%**1I3zPFW4%hP<6~54V>|4e)lsoC zuTMs9j>=8BoWri8GD|d@di1-$tzi;C@k}TKj;zsE1w8RNTWE{nl4KI=3#`3>_{#&6fM$+*#>Cn>>rBBhd=4U>l3}`8RJ8XM~CrHNJzdU8e233lKXkyob4nv zw@r3*-3;~b_Ks^bA7kx}ZDzA2?G+e+Uhg};g7*xP%H|18h146r_du4 zlH%TX>q~V+{xZ)Uf2u|YC-V;gGIlY=B=+iB_U)N{AopIkI8wlIFo{e6Ro#K((q*a3_e)$j<;}!14zFsR{Hs+ z^<6ahitg}!(O@ORw^0qIc-#Cw+{>6$91qPVyF{RDPK(BzuO_8T9@K?AP@|7pB)Aaw z+hjKNdfCrOD zo`4vzDw}xBI=Ga(2ix%eQP<=_x)v$uk}8R$<~!6#!u#4m!-E-lfMGa-G$_b)9E3W8 z8TstHZ@&IRo_+S<{+Hi9h+!0sYhsL-=Fyhb)ddnOUF*t=0#s=yDh(kE%_&gp0ZHKnc?{Z$JT7+bqDFr5_3dPb5aT z26Rc)=J*(k7##yE`3{_i(6iCDOcL(3?@&iKj5!H5`PRgYC9;8GDV-1O5V~q&b8Px- zv;+WK&0$POI$Ici8={vj>!sKwVK`E}xrzL6x}QK?2;gcHX2CdFBpRW4F}aRM?rinS zdBsiy-M!Rd!MBQJa@VpW`A}r!!Ee=WVPzX#s&U(}7M5&1iV^L!rUrO_S3_aP5Z??r z)S3SdX;W_pP{@}pQ_mB4eB7K)z(c75MB&D=Y!h&e!57~*lU21`Q*A$p$nZ`>W2`kX zb)k!dyU6XSlJ8iL=PpNQ_B8o;1$**sdHVAL;Pg-$bJ`1J!Cs!4+gl?$x+$Wfsrjkk z7+@V4W+o-)vtzIf-ZK+79F0>5hg&$CZUs!KLvJuvN0W;=&r|Lz+MsV4_D}pI<;#0> zLNT^qq{G4XbV7IY+mg!l4e)Mn#I)|X(I~=bQ{2j;@3VaOtIShJt`1uPV zKelsr$tg$E!AL$Y=;t10N0J(ZYdO#*$LaujUQEu1eZsapt*j__aJ4N5$#rivrf|&* zw#vHBQF0@jN^ay@ij@juEl|rJ^VaYLh6+>qPP84@l1yf67gx(%v_D=!92@qWe4za< z_qaGf|H%FI4qE}FxYmw7B{H%))1ZdgG6^_IH<<>sL$2%Cx3?uZ3RWplLpZ6-Ii-2E zJ(V>d?x)_MTJ;&RE+gchductV$3&^KhtSufwz-jDl4BMexU--zY6^tvXuYM#emV3D z)3HUTk*m{AYH9q>+qN*Zr?;@=&zatkOhB-g^={bzohZ6D$p%q5|BhJY5F-StyLqwL zs6Wxe4|4lzmELl5GOH%6Aksc1SZYV&^V+ZG58JgYCNMhn&GOr%yo;QKZi!`F_xg>GDt0@o{U$e zTD#H_!WouTT zC{WsTBt(^N_LXGDS_~gvKqlW6cvse_F?IJEVh;w^S54}E z#$i>EE)kIbO`m$)IO>E&d~2^r(@6Q*>sL8H$Ko_V%)@NX% zBOH8BU*ukgLtOscb~#{Kj>^L|;bP1XuDgq&1xD6&&GubBf!s_5HR+fyOVnyCQSR6J zTz&9!_)2$b)GbIMBRJpyI=817VL$y=_F>9Q`6R})RuHxK@=7d7)L=<4&5^M$= zVB$Ghs4kyis=cXmn1l&&;0A9CnmBadgdSxe<krgO<)vH zW{w>98>Ww>cKacd^3osiJ$7f$tjZ0eIb9n;Su_w)^yfEEsfmi?*^J*oXJ{$Hpz8)zJl(?gye`{Iy#<35RQ3&#Pkf^({B zUe#)U&nA z_t&u0E?m@*~CA_J0n7LZ0AvH+$x8p(w?wcZoSaJLi>ReP7-o?bt6q7v0Rw6?sPV| zUf0rjs^<;<4ZXszBc@J!7X&f>Qs-QxVfY?=xG}*7zFEgc7X5kPcX(TP_SWP_AvEhN z#dWIXjFm@(FmBcYPljMf;3?#fagg?H90cx0dL2z;kWEoy_t)*&zQp`R?Q%ktX===; zRLdbQ=U5U{b%cfina75}c5{T^2#gf)VtjmDD#>oTnU$#N_i}PT0i8udqdvSV&Wj@trNR6tTHJ3>E#|;kK ze`J8?@u$X}kE1O$q71-g1n4_Kg&3DkwY6q`)}PJl0%{bNgx~a76sM%zrkR#I;=D+9 zCVYdq20>{Ez{kIig!lwSn)prRY=X$B>h`|+k@||IqEpS%lqyMvmkayaVeb=KWaw-qU|ZiJZWFI@|$l{p+{Wuccb_&hDBc2h{J7;SoL z$>&BrHJ^9%w3SMG`eREGlE4iSo6)mCugWHorW9;v1{x+J$$-lONTU@QFbdTi9ny`F zqKxp?4M{3kEJo3pLiZs0q`<9zzN!~+Rph3G%7%Dq>H>71Z_cavoWk|oN~Rk`4x!>y4qAtnJ%U`i;_ov$hdTh-{}mTT{2e?C#`5% z-5D2M!`f0eAdGKp=xmgRWpIma)h|m$R11l>EklopEn<^RuDMJ{f=;?pciest2;=owIvA^2<~A2ae#*^xVgEAK)u8Sb=B4f zc&m-?=JH1GZAWsv|FV-RZ?O_-z88SjCv!%$CX~oCmy-VZ&+Os-`?n29lQs%3ecL46 zl5ir4?IuLiU+lXrkG9;A_+L*Q9301bHiqtD>`XFfj_1wj{arYmQ8;c-Dw14nO&ogh z_HP-FXs(ZbK!~sY)GALS&pJXQdmFdjk}=<4%yRcS)DgbY?W|nCs8-F|=wZ-hzyMh$ z(irs1^Gz4T7=bdK+PejM(%)+nWKa5sJ#*iXp@ZE*BTd_6ls>!3iD$dq+@Yu8bFe2h zv8N&0nH-2UQriuEl7)ijMf2yn{($vFxK@d8~ahheS%+GSB#J2n>S4zNI3Hae)grcls76F(NM|*tr|tF7 zVgRr(0#B5yM3v~fU@~=jY=Q=Igv+hRydc|$hUbo&4!5u-NDgTk^FNI5m9Zux6f4- zyZ?jwxZRYG4JNp7f=C5wY4?Ni(u!Ur?i7*^4h#2Jz~ScSeT2zf^cJ`kvZ-ZhhxpHt ziMa5ex(KII!(fUWl>$0Zq9 z$y~1p)j!E^z$j4Ylv#y(Ma<&(K|8z9^l+$3_Td=)$BC&SPOAxZEkdL^VR6OhA`#!b zqY9=YUfa5WU!N{o7uNDF@kX@eK*`x<6%RF1(*ciH1Jmo}Mbs&gxKw1Yvm?btpU{UX zc^Te6g58LK;wQK_@ppm*pbrh?>nMj+o+Y$ZCyM4j{60(%fE(idz16{b(- z&|9BDxEi;BX4!gA!TZ(T0wJd}Tw|bt>;x1N=cOiQ@)w7*7eViV`A{ECin!A4+qkO} zuWN{c#!!WKuYR;C1GJN5Q|_p<9Pm#m=gVT6UDX@N8@WKB#j*n#3^SmuYnEN%FU;Ty zlgJF094fU!-FOlfnpiW~*m-{KTfyu80ln?{qG zB`$GVBws->3&u&)UuI6B5fYOnk3|?C{RJH#eF9d9$^@J`jA@Wu1POCJ5!>M^3oIl; zxqjkR7o$Ug6YP_)Nxu)Kr%~6OQAiM&?zp3GYNDT^exq1`t{R{3xio;z!#X7gT>kue%F_Tm zoe@1RswrCY!xrqjy-vm1C3?oMLa`0QKo%SkC%hwg$(Oc-uW|FDND^CUmk{o`vhhL9q~7Kzgq?;GXjN?$*gz zA^sJ~qv_WnGe+)HOM~J92LiEaK07|X*pzCG)W%nmVvvJ@1a+V~(O(2!jCBRVT`aoS z(by6?j?%5G1b+{Ze`NaL5-;Otui{W)=FWLF>c0CN)eNs=+79};Cfqs!g$Ok8-n!l23 z9K>u>IAJ1{q?47coSjlgg5c5biawV7;`_A~eKZkAoq(6F(S)#5Ybdh_k;q}x zVOgv&y9Pt)Gf2Z^wt*0glUiL{oPZK7Bft$3gY<&h_h6nfacpQ^h7j?03rQSnO52k}*Uw4}#&jlpW)w@UIF&~SuIu#~PNo$#L zlEzlrc8+zYj%vcY3TTpH_&RvVTDPK5RZxni*1YqW>wh%0A9L8`tOUKqq*_fjGZeWr z!3{tA=G(8o8zs-AMEgM)Pr3)vrECrqW%S!jMn>d^|ZXR!`Q$`y=YcXM<59BZ~XAnqIk3 zIqL{u10@zH+icbn#wggK^p_jJL4w%2O$oZP6=xOJqi73WW2l*xaj?E9su{pqjzrE&C*mP>m8>S?nc$+!_*Ph>MUHagi! zbhKs!i+-JnL9b*P0q>~}uY>bEu;#Zxws@qwRj?$Xm5!I?3f0KKjnq@H)V8~lw8>f~ z&<)b3(v1cFl$D25F0rYma?Vmn0Pqenj)FdTQ|>@lckt<+RV`LiSvRScFZxzJ>-Z9e zKhzD&6}!R4L?pvRJ=6u^r8*6i7(c|GIX>$!Rj9i+G4#2aggi^u*3sp;Ry@SYhELpW zln8qC`nnG$&9+qM4AWVdk)jw<-c`n$iW)3VKbGkKbTa++lg-VQ3|qsLsv;gql8$;8$WZZmPh` z5(A>~s-ZZ)t9)dbH#mIw(Eza4lz6$?fJ>$e8&?6B^h;`O5)wb&3s5@u?$5(=d^Xk% z;YBG(7^bmC=1eglBrDpzJg-!p27A`)_DP9;HXIomq&|c6Wq+lDI9tJH0+hOXnFotN zh)Q(GkQ+Bw;pwx?ev&*LPiLFvT%Fjbr)&no2N0K|X=Z(nH-A*jZQW;A-V-wqzH?P*EP;5yL&l-5j*xeW#rhJ<}Ifi1?q+ zFlycLEp#vm3>>BG*?be;)?$nE#_uldv|N{~x!PbLN2B;_jr9PBig^OH0>tM!8oFr8 zV3fqsGj#=B0n{Pvqk9P~P8Tpxk)mS2gct%)fN-V0QU@=fRXc!KLomS_3`I9r5x4^Y zj97jD}{vQJ>toGaLpzz!c=(Bc1m;ytxg79>h7Bvpar~WKD4&g27Pg zW^@}4`i7}Eg6i({tIu&nPz&{Bag{Z^(k|`t3Ih%p=@#HTLmijS9cj7J| zXU{ykWDk&m0H|os65tF>k7t!+1l^@wK(cv-X8_W z!hTFJ4EYIKV+S-7Jc@l7)}~}^)us+mSk)c`s$H{OO2gCS=s->T2)0wgYvpa?&m%gD zV7CO;M=yM&%l&W#lIgoZ_5yNuI>-~S(%66Cf30Q%s8w%fl4mR0<|m;Qi4$R~-ByIM zN2KWvGV%C*%`?vDH8g~dV@4+m?@0<$)XV)P$ZNuW?~&uiWEunK8IwxFrz1l<`js1{ zGfN(z`yVkAle;MDEO@2y6^aK>Xy1l6Mt zWw``SQ!ml0epOuB`cnt8UH3<}uqeW7^a&D2zKFObu|;2k2g(XLOMHcr@%2MkeF3CD zvI-}_cCLTNE02GJ7jjir&C7-Mw1Vsjz7rpN$z9AbuoJE9)&xBg@+-NnU897XzI+Wc z;k2?J7FH?WGRa*mxH?7;dpeid@Q!$1w)7kDm7m65?6of^? zvywW3u?6TK0b;yy@+2P#T?u&SMw#ig$k&nq%jp;;HEx4}CXEI<)(5BgA#~=*D`*_@ zogfCBL&)0$+Cj(l9z!U(;#TEpp8cx+(M3I%{9jWImeYQ>te4)Rn;3vsPyXxp=br#jK(D`^J$d*1`01OU zU%yk6_Tc_~69j-NZ|h)fq6T1BJdOOXS&?O3uQ518JCJx!FN-SD$0L#;=-#Clh&qW; z*VH>FgIY;e636XOUFJct!9egq-m?{yKhQ-%cUXEE>P$m8c#B^a4P1gY^M-#L`6r$> zZ~dM5lV*&P%a<=L(@$SNJsWM#Z@*Ny9?U8^szK2Ut3SmV)7G z?FfAW^^AkO9WUVFJ2Q=jP~%lNtv)(yu&%Mu0I9b(~4Y|pn7tT0)vRKqt0QG#8Yvnj7n#@-d=o`7voTw$LcA($t zwlFL3I0t}xSUbRm8G!;{UD2Qj*W(rZ`Sr{H%F1OuIR}e-4dx(BOohR6>eL3+4=&tg zNorU1oZW1=x(3`doDo5$OC(u`n8~E)PaCX*TIH9|bvh@^TBZ9M&J-wiQSo$vH+OZ~ z&QVc1nbngInr;Cs6oSntHDfmX?7MHie26y$6t5P4vWIj}oqaoh_YPQwBIGZ-OS(E&_L ztij{W8%!UdzQZ;?J6CUt*#>QaPhPxx{uWDXss&$%Dh!`!=3q^P1Y8B!3Uk!;mBpfQ z8q%~2fD1&9w&^hBT`i+y)6za${F%;ShWW3&?dQ-!R)l>7pZsw=m7&9j$r%`~%P=+6pfgQ8utZkSxZ_x>-v}flug7;=cM|KYgP+k?Q2{b{-^exy4usu{+tx zm|df;gLC=?+1bHW8c$YY!>i50bxvr+BOCX#IkNu~zIKo76a&`uZL@~jv(mePI9@c0 z+@`Mf?m(>ui$QD#walN3yaO948Fv~yANHJ=560P3YyC#oM-FLleB+V(fmAV8v#;~| z+RzZpq2|;HLuUIr_sJ;sM^3SainDv38j!5cx-&puVD`BRu*wJS>$)#~({U|AXZ)Jn zUVW*K@Ke;8Iq7Dst2H09MU<6B^;}^fUzr16JkhT}sn87l5!m{n zC~4`rpxbAk1(p}=19`d%?(F-4 z#y^I&an60qNRRf#NIXlgLOh5B?Wk#E+UG45PcrA>L?YJi9thKGj`lXb9vL&BC6pbdn(z)mz#+ABn*`Bj&!4>h`KPvq0V8y?)E|SA09Aomd3p-aF&@{!!9B+pLwav=Mmr0_ zDwJuB{K*s~1CuT;93WWxPfEnST?_pv%3brv+3|6qt_5d{q4@*wbalgd_M48Q7=Q>q z$gTm!D}I<9)qx_}|IMR>uWa4WxZ18)8CR)_IPCbJ$4P$*9pp$rd^#u z_;de8^mS))A}F@)u;3fBV?@Ok6CN$&2sIq$a|A`Cr2zR6>0yPo$+Z?RZIF5jnNinm z){D=iZbA{Eg>YeRG%Wb?f76J90M*svCE+L>V6~oAqe<}#{)8A;Mjdj~Wi@abgO1xR zfZAWe5`e2Oo%6eNFv$3z@9*lqO4aKbgGnfde-F{tsMR3^G~D zuLcdsp!jj81Q;09O|B-wCLq*H&vS@@Fj4y|0zszSTc9zM6rjnS06^$MYG^dE-Xrt` zbwXl&h&qIn#QepU2D}pFlJ>SdW!ejU(Wu3giH*J)<9Qjz?FJpInuBvpO064ev4ug0 zh!VEyRg`C&ddGk{(-N}(LSodUw9Q}arxPDC6PF!No&FOps@(Z-K_s_4cjkB)O+9y$ z@iopexbwxiQOsn=xkLL+p1;ELVmVAR58uBLiK#uU8&%D8(>oWFNFO~KTCWPQI78tZ zHTHrB-m5WSE5IcEOVPFsCtK-#jz{dj_vo+tVK9VqBhxwp5X=R0n&uAEx4>2AO*22X)Rm*UEmqO6~=H5<#vt{<{yjL*oA5nW&8K$Q?Ok7n|j9 z3wmss@jN@M7f-3mBLQ@xk2kx_*8z3F`}#I?pE_?CKVN+WY+bNYfO73m*d=ro3Qpf{ zDm9G9t!Oxsu_sU_p}F)Un)M6^!b<46XbNdPTfH~{b8ZK%;<|z~5~yO5Ou)}q1$l2d z)Ep6@jLQ$AHK6o1S#Q*xT5AcwuvV=#rn(XrVX57~EvtRb%HqtAEmh|l;^&#<>cdg& z9CgW76O7a(zXArqV^}eaL1hU$8-4*Q(1k^?0>4(Zhy0u;b_pWNx#5P7755 z5K-6zP_4J@K2}9jS-$whIg;-TSu;Sqt{k|BNqDdX=%hD*Cv7{hL&eNU1oSE|_0;OI z`C$*y)msL&^Mqiz$k1E6)RFhtbSV^}FVwZGBeNwF^Lf!crATP_NK;P~+Tu%5sW*FW zb-Hi1)=^8QWzFQZPlaM!pjuFeSaDWVi+`zH(4Q?a&Jc~WC2J~#kvrO00u4dH1k&MB zs0|zpIxHQux@h7-*njXHO;vAqyxK>yM)$GP_MZ75+2JH}6c}XO3o{|NPS>V4=5tYC zP4B@33Yf!fP_Hg~z>N(;y~FHUE($IW0~x(fNq4~cJLbjbjl0ezL7p%khGPrwKksr+E10znw(fQe;p)$ z#cTtcg?~e7)5o{CmbPG#rKi{7P<>cO=SFw;LO2dheV7T6qwh3uST1jIzfZ2%*Rr?e zfn4`ZZKFTeXyn6Ddu|_M#E9Ty?A*>X$Upk|=h?qcW^mknzMIKez0E`CQzb7^T$Df& z`cbeE0O-6>Q|-af3+xP{&NrX81Tu)X&P?S*w3WFmRVqw>fuvqz#78&yHzX2hbCFWuy;(8MV6$%%KVTa8VP5MEOv z)dEbDv*fAl-gL0;R9U{N9-f-m-NHXhoxQrm4{$c<@^ zQ{usTxsH=;W~1~4Y1^QK4Q;p5=M+c7+8AxYV`NFhvR>?%4MLRXd>d~;yZvNZt6Oix zolE||WDr4$+Mc5b(~Q}{$jvmN_6}l~ev(p%_1mD}#774MWzD0%RMdz!r&J{VCRjo_Ge$PzP? zcsoQ-<+4sGBrqc@e5bmE{{kDOQ?Pxmy#@~L(F|U_P*GBy126R{?i}eiTqj?EiotXQ zuFWT0cm`b$+3n4+iLzZ@)au#tQkE?D1vhh_MMlUDlX^9E>(Z+JCXk>IgM}EP55JNW z7W~T^l>_7r#w)S|eS~43r0rAf7K-knwA&7x?B`)u^ja>B~{*Khhyx z#d_Rd;;zy4h8hMT?;8BL`nvd;J>=k05r)E`7jdz#ph->PdyME@118J@@eb zWM+}GLK27^D*l3Lyc4KXgv0RGqL%K&$n$JM)J_IxXEgF2&RC+d>D@s#t;=RHSZC;{ zku_KIlNwXc5tj*5-!Nv}PndHSDqFRs%57q_8E>O+>7q;_P4xE?rQY5(_XSfg+l*1=rMaxd@wKk2*e|dxmx{v ztbTQ)UP>3PSU1~>9Eh_`8=gszZ6a%E{~0}c(!3}j%feN_4#YCS36m%jsYC!AR~v>E zx&DnenK3u(-S#&V0*6G!vG2?nqLF!Fohgqd#XuIMV4V|({!55Ky9KTLpDXY5d& z{jFFoAximg*>biyQ`Ll69qx!#Sw^^0oBMBiXZ=kBj#zF0FgY2d2o|7DHPKoHpC#S! znLxk}6Q`QgX8>nfSw0}!C%5LQ4xQ?nk&X5+*qfB+PX6??7oALhFdf!`%B6f!lm6J- z9AmV<8LE&z*z-Qv{}*T|4Brgm+7H&~tO4lqI-nhWEl%srVhTrSZ~gMEq#R~6orgO3 z9ZTD`NysjOq)d##<^;nNkkWo+%gxEGnh=Q6w4BT!)&dG?$ct*tnOwM16pG4=s@^n^ zGDPPNDK_i#8j~)9Lo^*!kiqStB&DAZ$+a1=Z*v1+yPas&*9j|0A7``r1pBUz+nO?w z1gk;*(xKE@XaT&%gWiEQF+L<1O$=tt^Hsf|>GM$%1_pjbEjhU?xqt~tV*vv;QPj`9 z2eJ2xINN#lkOF)iJV3ib2zZEI;=^*aav%;p@$8vF$OI(H27JtPY&C>n@)E%VN~Op+ ziuT5@1pKA~AWH*zVX|er($Ya$?q%oe^|IO9-91xs`{qRL=K1c$ru?;m|9;%9nnp=+ zyAQs;|8*~|Qk8OXlSvU~=4r8nXo_i4!GNE( zC={e1ar~wOHno@bJDL^hEx>C+6QC_32aJuPlz?17_K9^0(*MxDNHveT%62%Vw)%=# zpAm=|8J45&K@+R^v%4ws3`aZgmJjD+FuGZvuD4g;ct3GoI)iPJ>14o!9mrHJ)XMl_v-%8Vr}bqOdjrD!Q1GIvG{Jt< z_h!Xt&;wyo23x0dwe`kx=&yI8C{fscHhG@;w&XNBV{8#CTn^>^^dk zsQe@j*DZKOD7X8FMIJ(@j%HS;ay_H<85l3T2%VQo(P}{NdMP51uwd0i!JW5QlfBwd z^!6K0(ayc52)ds^pn6qJR`t80`4GV*YiIJtM`easvk)WLM^}8RKXf(D(q~2tAc(C; zwn;|3y6=Nd(JKKeSrS^P(iW+O3iu|pYd6;Z&mgC3@K|KAaP?Gkj)Lh*ogd&>Mq0Z$ zOygQjW1|sbUoNtT^G*Hte4}6i;kgFB=@u_*MYJ+}^iX}GopKvnxIaCCbL%sU;!Ts-Y z_~+{{;h(R+`Ud{_!u+c_X-HO!l3V^RO9@x?%pRsARe- zE>SInfwvXjG^QokzN<#-zI28`985DQ7saZo^)M)txYHy<3)k7Xnsor1RE1a7`U=&k zrvPPD!6kTo32+3czEb310IQqw?;AKT3I>gC^jv)P^}`2h*x!8f-F=-16UE+&{`TC*Xdc8?7BGdLHoKv|wh=ujI!26t+VRDfv7a z2dr?tgW#4uD*;dlfh8MU5yTlK2s5gRfJaYNgNXe*9;+L>+ED7KpjqI`crH*IpmWUU zCf0}4CVOPIj835iimmq`i_s3JaoCvwTsQG})FRVCq+1CNB9d5NV}G}fvi1ZOzQ2pHCSb3Ow=CN*xp!b3E2dM891rLp+=!6o z<;_8Kr*6tMKqafwWC&qRQkcIWY?x~Z9=Apniso10ero)fI zVnrYL@n*Ubig^p`PVRO*cog%3w1-%2fEfRd-)RNA>4BqA*KLpakD;wF2&+><(W;oJ z?;$r@GQO@CA9JU|_6m^OM%n+BJ@nX_?GNR8e3V6_xz#@5eWCW=OAo~+#oyh60X4pG zOl58{51721oG+>gskzsIK;R09EE5Dab3UKf7{LmH${JIO)&%@lEF2y(-fBtQ{w4|T zI+(wf!QZqKngRM<$g}%mFM2v588kcyNSmxbhTu(n91C|O@~ml#(Gk4`+hC(0X%~Et{O@)<^~&S&9I%>a%MuZyvV#{-2Mu;s&8?PTw5|TMWLz<3wCY}dp&{A>K1($4OR;K( z6rUd&kp28SlrXmiTz3lxm^;<)WR$jJa=jio#X0v#o1bGNbL0S+f)5T+Lz8C?I*H9Z z|Cw?Y!=o1%s>zTK*5qwtIvbPlIX23u`qlcBvoWNZeRst!xepR1S!7A7F;yP_lw$^T z+F>OcL+27l8dfk?eS=KFUYy}R-iMW`bU7>e0cvp!)>lfn6zK=gPfpbbT~g;yDoHgDNyF> zK_aTB23XrPN^n8nh`ygYpCI_A-%UcyR~(sS zgPUP_I^9dzgFuUEi>U*hp)4^!pTA!kgOEcyMcNK(NDo2h2QNuFnaZ9sjz#1xsB$st z!%JI3#%Xo;Lkq|K==oLK&4NGt;){Jj5=}JdoT)&!!xZcyyliV5uj%K2N{7uz^$&xd z#E2$Crv^w;9`sx`Si*K3CS5mTdwJ6KiFbq*5FY$jA0kS~CVG5~kM}5S1g|4}M~52I z&KE$f4q5jDTWOWlb5-isIRA3WZ3Y^DE0K<4cgHIa(pLb@)m8C}qMD`aMOQ;KQue6Q znIy9PnvUnDsoZQ1P@}XvytLrbBv-!`cTl#Z_VcGn(=|^(@H`~wMw)p{Chw1U>CxOhuCo+>QC0Eqv)HvxK>3d4PJk74^4W-3Hvn3OM zu4Iu9a2%{q?XAH@F-0BziD4UK>2}vSLwNov5vyM6>k^-WZBq)vPTbE7*Mu_T{QFFEv$1P&=XLT8lH>tOpRD z^LBXuNF4w_gZI(X0>fIrzzW%C>VcRC#hFK|Rqt;XVwNszYlda5U4pX z)gl?H!SV-~(Cw!u()-6u0{H(#x63x(i z??cWQD1GB+)AQP)H-L3W__Fazcpp=&BI1$Bt*+bx;-}ifr{!ZV0-t*dx7YQ$+#}>&#?6~n z%^Jc*0A>gd(DD3NcE)2z3XoFDkCgibeMlf~s+yHoVJCp&1LN=SsO}N6Rvla55zXk);A+C26KZ}+ zhylnbY3V|}Uvn1Z&si1R|o`kZq=6#flCXOhiL_K&_*{wE{rD# z`Ag{;pu3)84P0uT_#!xz37ug$I9kc%tNI`60*k};i>ODg66F{0Z`dMvq57QDRtSQy zT8)=eiu8ALTU2obEzHXJyl95_$xYyZu?DqKxdyqnYSKd4lDikAgmt30AT4ZUa&^}f zlVRerb|eZp@ zBRy1pAi|E{G|t^L=0Lx4YZ3%(^ohZNbw2X(U~dWn?Jk$Q9`1y@Gui?9Iqnn%0eQo{Vi zS4#eRmVS$8ogk(ORdkngc|Ukt-ji zcD>1I!UgwlLW`yn?Bh?x`rNcDZpk~&S8Y2logwB^Xr4Un6WClzPK3u9+Ryg_{~mMV zFsMbVP6_@u(8nCAgdhTBsSaq)IW(=;>OL~7<`qips=a2M4LT}(fnXJMA5b^m85)cn z+!>RJbKr;Vb+Z~ez8DSKauOdWU$2Vj&*y=3K8LE{N(h32&h7y+!V0cmD5`jp%2)v8 z{Hq3vHvmths!Rt|SU>{A2Ne8hLTnU#I@d!EfCxmtPj8NBWaI=2LP%A0Z_ACx5kE5A!Xoza9z!Tl0MDI7?{?z}nyzFPti_sLXE zh;wf@niV6D_uF0S>i4YlQD~=Psw|WV64%f>{(*@%(rTJKe{4axcvjQIwDB2E4&2bG zmUCs=)i4=>meAtC=0so>EuLqICBW<;047IdXI6q)9U{#1SptVVx_nS7&4WPn>A0B6 zo_S{r3+#ZcZ%fH)HahmJty=^}X*)t7)(FC;T_*GbiPqvRM~-jSGwJ6Xa3Ana}+68zWtq}LLiTv1%I{;=Q5 z^hi9`4Hq5?HHj2nR7~S9v$!bd>q7J@ef$C-00@8Phw3OP+;&krYw+ALFdSlx6IB|m z6*XNoCXzchp11b(ytqo#gYNuuh|B{IMlpe&)d>SAtvtvs`2i!@*LY>bdQ!kuP9hdN zv1#>!UafSoKJuh>$v>@CWsq`!b%QsNCev<#2_Pd@JLFpO&a=Y{KRMcw^DYLWX?0I& z_iy8-No+Sw1g+l$mc5fHc-JCYMn)shiD$w@2Y7WJ7)=G8j6=eqRa6m5bzD;+?Dg7G)sC0%oU# z*vR8Ix0C@Om*`V`rjE~k!`Jy0dhvaAy9FZ`|1Bhrlnh1C?|To2<|7YjowntuJ+EZH z6cw$@)44>^GHoSv_QB@&MngGv+f~I-Vz~Wng7160)DGCcwkV&2Nn1zJJS!2*k<^T) zH|1h8FIN!mMd94WDUEQgHqtA#zxOEVsx{K`6YPTzW3+_$BI9sGK?{EYAZLiIOun`(Opay;OwO+xnF*;<0CfQs_sxcGYq^Aba zty8^{{gA5l0Z1c0R3^I|X;ARc(}=A)%^0CaM}EGw3WKhidk;`C)7Qn*7SO6y?h zaJLJSfX{9H_*n;5q`%m>&Tk@fA0u`zn`bmf4oQve^MC$RP2PU=4PZMkZan@_)D5uP zZ^^Bx9C{NDctDV01V1GUyY^E#-5|6nRYSK*a+|Ewt_1mnywvep;N?q1y*5Zo)2l@> zuO`|}2BHv|^?7<0j!@JcHzUOn{Doe)xi86OqL%)sX{CpRCtPmQtH>=v9-tzA@mV z|9$Xj;<&eN%ijIS`_>qW0LBXZ?y-%m(4E99v4ws^2aBR{e3)S|#t{T#QkbE`$m~eQ zqqeD4^7gE@0mZUw6nc1q2Rp!88;7`-E2WKQp`23)e}k}J$P7p)4Jct1dS{z^&?PHF zy24uC-_`lp*X05g0u-(Z+=em_*a=*fJLJUJjC<7kl6Z`^so_adQ!K*9^Qt>38cH_D zsX&&4rbqP@Py^9!ONPN>1w?3P{9s8Zx%l#3bZaG77s<3#2)d0m0+JCQBooa_O(5ED zK2~;$Tm*J=iwWvtNBLjW6qO&>c-b0fe=X_$3ou}uQs(0ow`VekN6==-pVt*ZNJ5N2 z1lVfJhN3rYZYg%S>*53KY*C!~FnjpXw6<@=U~10<(>uW<|vwo>W6HWFwpHe?m-$0oJM~ z#GJ=Em6vv>-FyFjk+7~0H1a*d-H+?l+3v-|-Lp+KEq9%C5a;Xp>@#R==hdcJ@BFdc zDR%UP4N@q%yG*mhOl*oJK}vBw5OMZIAuJNwyizQ12j%#wFX|**8j}}pP1W>SXe_$T zu@B$sj;llGylCEBF7y-HcU`A2-8|BK6hSgIcRB$yP{TeN&FVFK?|I^03&UT!1F+0= z^n1ljK|sIP_m&x`>;xDWc^o`S8C?NV0L@3|H{%(w0-oJXfIqhSKDa=JTG|?>r^d2h z7+weWb@PYORS+k|$K-SFiT>tFTnwX}fdLm|jn#>-ut8s%CLbv@qz{k4<6GAk!hy9L zWt{fHQ9fpVsk_e>8xY9CqI+DFio8V2|7s|1;0~LO=keWQ1n3x+bGXIBa_3mln=VV5 z>pMEHmYkij_mp%_3-nEx$jIfrW5RT8@QaTf*}%~sP^`7VN3=$LsjO-D-1bp8x7fOu zuu+v9akikNi&2%~y0<{&VsOvK4J_EK;|co2X1yepq%k}ueqliZ^h3i0aTY*x#W%5} z2n2DN3`TR_lFLVu@lqM>V>0Z){h{t><#L<^71^3zZEZS0t3^v47aq2P?2zljp7UMa ziphgTC}5(!pc26L$d6x9^X}&v_T|kIU^<)epPs+VKHqJvKrQJW{3nUtvxV1`S!>DL zMf{4XSATes&OLjb+#Wtx^dL93+Z?*|!a8<^+x|MCLUk?Iv5?VE{}x{2WMSpDVk*O7 zbLDjZz)$sf2A@P%hOi1jiZG#RD?$aDeiC_z_jl=*o>f!CCzeu#_h=GYOinfchE?)*XmSR!VAo z$UlyfC{}Qo5Qsv0?81qK37TG2AFIXimrd!bLO~OXsglmszrd$#Qasp;#{6z<0G3g^ z5HXIsJvrovk}<;1=v07YpPiJ`%?dTdC!1YOw*?+x%+oYX(r2Q{S17gIhaycs|utbKDqni?Hv62zR12E_? zT99i&0v(?dL)><0@}_Q^``tY{nk#@BEvBG(MElV#E@ zvUuhQCnW1ettjoZCw6WvC_|buMMe!{>>}5FIbm&Z|Pp#1aJ!#y*f<;qdfEU zO^1>Dw4ArCv=nrl6-FATt+Vx)tRQ8UAR%9 zzLScQCP37D26pY+sMJ3=*Yo|g@pX3cJk2u;s~wYO zdd%0w-ZCxF|4WSs+r(Rdu$S#(Q(4adLWrdPr3EOCKHbiZ*qIGn2(DwSrv7>1(h0!48jPL{*8&PZ z&Dl9zW-w-|%rG$&n1rSwOEkM#@E+N}0squ}_qiuO{nzkLaAx}E>u|CTQ1eJ*V~CZ+x9sH@@I$nj9u#dp|<5A@H-z%KU`xn7sunE>7*PK z$wSW)y-Lr^ZH@)Q%*~dwIF4F@%4E4P5ap$FD^Ir$JSV%7Yz5g`+y6DY{&`WlKPCz(Jq z;;_2oi{s`)wMXfeF9!@H_XDW)BmTNo<6`e%a69l>MKp*8`NQ%U( znzn!JG~Gf~%y0}seL@#> zrIe+ zj?L|&$rwx*bfvo#>=aaE0@L?}2y?CL@oHybAuCS73s$Z<94<-E)4}L}(IEu{z)49c zX^Ppkm^}shEnK%{(b!OShv$|=+S}$@q6+{iE)M*v z><1x<>5h4A0~d|!kp(vVP^Xn8ZQ3*!%IQc0ePDpNsTU+H9(5NiZmHh8LN*MAa)e=c z#NsNODMqt1ucy^%RZe${HOsPksfM3@_1(AMj3kYO{wP|ISN;p41gT4mpa`+!8AUit zqOysH^s7zWk2z8rXNdkbKn`IA-8XibU_-Ieo%uYATb3aj^x6jb#)RfA|7#B2ua3B1 z+c@DnH+w%%kFcr5b@X?%o>D(uFaVgWQ@fn90TnZ}QV}8JuaI;@FC(f|a2=!<)(MKL zODUSrRHeHuDtGkDI4s+Jt2Iqd>-)W?-J3GsR;YDW#f*3_3$h$y$=-VUG|BmhB#H~x zkLcVjaKCz2ibVGV)9eK)n&AHZ`9{0v3H2+&OgV z@o~MX&LFnah$DT%FW9F?kNIM*zHJ(cZ9>!&Z|nBCS6}@u7WXh9sj;=cIevSdA(?nkp8f9 zCj5RT(DDP#(w9%4GN(=8)tA0zBY65ZRWM3#|=MUrCwx4gN z>?Cd-F%WEeCrBI>yI_n*c_Z|!l-^?>xM;iZRpNLyewC9F*+c~}#uCI9X z%~;C%b2(Ftr5PrqFKe+H?F-)8_A9IP0ny6CjUxfh>Az-{+g*^|pc?^@@J+atgJ>LL zAkWIvp;J1fF$u0IedEFg99U2RNH50G3(mzZ43n6k>_Ct$0D7DnN32p*cQnL+)PXKe z>HU`aC_=n%eF1{#weQ^I5E7e^wiNOmqVez1E;sU3J!HBDpNrh@f!c(@6W^hVs_T`v zGn>p5tv^{zUlpql?vTJ*OciOe_q(7Ox=Bx%=#P}_vV}F8+3-#ht(xO+fbb4uT#!|% zlbAUTXvdLmFB7kL%Fjf#aah47>7KU+Q-9uO?pkd5ZMwYvOX?71qAvj$&>tRrOVwvc zVr*Z5SY(7d(MOW14zyF36)id3qlhHIFCM@kol1x0_-qV;%@FTQP~xnU*i}r!&TCoZA~9_ifxGISF!y(V5->4-q_0l! zcQQZ-KNXZ#4trkLIZ{MR%v$i8{O=AYiY$O{pz|l}Rwx!gY{zPwvobJ(b*08e?H$a6 z5!;TVC$4qCjuw>y0Oq7F`Sk}(7=BW+_dLSeSW7(8qd{O=0`a=YQ&z`juSLiq@Tr@9yJIzb&2NHv|-ANP$*9QZ@FMLOzA$fc#%jJ`qjH0h5=tH?& z?-cOf(M{##gTT?KdNN{__C^u+^fjHTB<^C+SH1d>6)W(hLjTAp05G0VB^Q*~&d{ke zcU#!rkPk}-CmPxf6EptEL0ItKyr@@bP1DOseyjSekopdr(sog^_>lh>n=WT_H~+6o z9|?gjx6x%ZH7=1sjuGk@pVcw2x#5o&?N-4p=1R93zw`$|mI@#6moy%E7U6~G*0w=_ z9gP(CV-!YSar4w03{4Cgi7vIO4IfGs8$A}6*T3Dej+~X-ZQqouc;gEzF)^o^o>@M< zr72EKejGm{vV>Q(Uxc0BR$TJ(3LGq=&+}}+n{&|RPSB4PLD7j8yxT^?d<&fR6pLAx ztIr-heDE-pL5lb}!^Ep?Eb_ZS!_;p%U`y&JvPxp)s)+!&EM_0bv!DdlSz>f5)Pa*o z+yf~V528fHXe`j$eNBhsj8UaQdks-x(8e5`$!awk%rOR#tCMq#IY`ueQfjzRfEYMk zbBMv^c|9wMzw7tlB9h2xg>602BXKr%J2TiaP(V*r$UR~LG#-Vx2$BC%i)qhn;wc@W z{dV!E-mGm2bnvU5J4fE$_jqi>TZV1?E7rqiia{U**dp)hSLh7tqZ$j6gQ#W-l}p|| z%+(jHi?awD;Ac3b$$Tqb=4IstnC0OcdueepM!-u~nZ1PAT607*zI28{Z?)EY+i_;{ zJIH~9QV+QYx-(E!73N3c?@`V2VpY%a)N)|J>2UIv9spPbZ;{@N1APPB@r`YDql9kyhL#z}F4H=D z&ehEX$|80M#5|BnW=*c!PF8l5vptdA*5l@KdiLg3d<#Uks@TK8-!I6n2-C)v#h+u! zuBCmC+>N1R{%TGBI#!@IN~0io%+gbVYBvY&4z=-Sv44xDElwJoVqrJvSMHT&TI0bE zvLrY&uEV7Ea0LN{GPyzP&1fg*-%te{e9@-tLFcuUrZSz+106_Xt*Dtqt}?1k1oUU) zrHe9FER>*wXA7wX>jk<0L?@VY*M~aH#z4U{$O4c$2|dL_2k+oWfk;E@E;^cJTt8>m zvIPnZ(yaGrkpkZ=Jh&B&jNG9gV8hkA_Popq{rnTB%w_PkEJt6Cx)g}GI0z$$;jAkXq zQ}5P-vJ8feGZF{hdq`)+mH5g=bm!EeLIm9f<=Ag1WfJ#O1v!Cof|HLMe6Yv*v)Em2 zkN*{t)*63l)VA+vUmTY4Y;GOTsSV4%(?uV-I&1%(V3PL>B%s@@bH86a;o~nk^T*$| zdi%TnP>`}))Vz*?qK7T$Y%T1@U+r_YMc|yl540B9UuZ0fU4&g=Kr*2&MmPvw|n76AAiyz-2qvcb}_d+R}U^i_Ko_b{~jNs{Y%8$vE4=qjz4}( z7BlGJkgLzlTVR9yus70+t?u+eo}E4nUB$6~krPmS&?6^-Sp=1WlIl+&kQhZTbt<1V z_P%v_eg)hKQ`0Rx-R9{7s@u2SKMWq)?M{8ua~Numwc|Fv^lWi$mjJ}n8WOGwWi=#d ztr6Y~xB|={1aI+zV4xD!Jp>3tvCJ7I+Awn#$o;;^AH(y4^}}Qez-~Fg#`plu7I*{? zu&)E}7^ZG@SAylJmTIxwtZglhi;msP^ph;VfGx2+(tDn&^FfpG7+CmzwL>d>x*Q?c zu=U~)dv@d%Fd%1MoBFB1o6W8mNq$J=G-Arc_*!Oyt%(xN<;CjpU zRqOr_9}01%Sm{laYlKVNzzx5im6$@7m3b3-L?0Uo&)*J{835~_UcG&eU+xYc@BPm| z4|k4_M#J~-FGss)V(B1Jt-8j@*H-mn%(u9q+mZ|OG*O?LYwmbm|GZq5tEWW+0P`8T zaM1U=(5qb~Fb)P1!!wI!Yo0e}0eFxNpG7)F%!T{VKB93Yhy zN~=Gl{E34>bY0@0Wa#Lh8O~O+0fvQK-!~pnP95o!EXSh^IBU6qrkcrs3`{g*Ji&+W z?;ZkX1$5`gRm`f6Sj2GbOJ~+h+CP0(=f-`8Zt5dhYd%}eKC6feylFy_XKkp_j#_9z~di>4~{xr7l-!7{=Fqr%VFvA z4k!UX09HHD^7l^`_2Oz?Z<-%O`1T>r2Y}04(z7{kuqm)4+16-60+RRLuoe4Nm+F|| z=a~f8Nsgxh^W$uzi-Zkzk^NuUL)-=rMhP6O?2AWmmh8))|B(1leUbW5ee{EBZ#(}| z^Owv%0tO)Oc?JQZU3o9k5BP^oSz`Kn5j~9$tGA{4qfuh@LHYMhNha_6(FeQ&BAYQ5 zK-C;yFV&3RZ$V$Ah**q=g^v#1FL$yBNBgM{DYms)yG(-lp9fZxwPtBajXZ$Hih4a~ zINC&rNH5&F*32s2!JAy4_PHfXh%l)@2{3nga{Nd8H<>k&URsAKKE&>V>&q~OP1!a7 zsSusv;Jp&e)rApd>1sj05{T!}jnrTiTVD=?Bf4cJxOo?du0mqHuNdiIXJ_Y!Y@k@D z=8wZcHpsKDm55PgpJxw8Mm#c3{%PPnI!oP_WFVTu`$u>njK||_=;UlsZysQl7S$VG zUcBQpkn^>z(Y*xX%_s#gnw;BT>uP~3H5hH}1!`v+mv*REI_sJboQx>1?X>`2z5Ds+ z`1JFPk*PJLE8IxI3bQWHbc#)zWgNZdNrS;(L%s!YoJZAFq0LDQg<&-#1slfb1%IoP zDYGF1bL`SXvOf{t5h41i4mISZ0)j79gSx8&(^ni^I4-u1t-!CSa`d@W_f4*s)R%Dy zA>;hFYd*F6Nr!T<4=JO^N+G=BF=Tv0crsfu-9Wl`$YiR$0@$`^p!$-jZ3fypPO}87 z@V7;I`8VjOy0A~jgYJkEM(o6O@W(7Bpt1`@L3u<|W}B)}AT23cyR12XJbDg+)m6#C z0MhO(ps$%kE42_AfRl{Rq{J5Wevp=4-6rc_iWyb&ixb~2A=>#k&mD=Q5B%g2_{FHRnC^qnSC=APY8v&!5Mi0C!9Yg4WzdYBt)g*wD+ zKBltl-^^Edw&B3gNo(QfHYBsCMQma#xz*AW+k(f90K>s%1_sNnPpKg@Zy>NNYF)jA zl?sz!d+ni$ke@a~!9}?ZD3Kj{sJPv&5u*f#dQqwSGIQB+TgD6;15lNmG{ZHTAfY>& z7E1?@&4fn@3bQ?jK3zO#yY!FkBuJmzlH13u%fr>m&h)Uge+DIwQ{TwxR%|uC4$90- zBE_yZSs*kd{7qshI+o-1?UczK2uFn6*6X=}L|oFtLHWa{- zZqdyF?mpy`28RtF3g9UWH{d2M$r_YhG`359j#8{>Oe6Kumr2dnLRuiZ*IC<|VorOR zzP9(|Uoyiu)US_xp*UVmt8Y}5PRr?LNsbnP@H|2_g9K~m7DS&2ah@CvV$#2)Md;?l zG{)9T&KK2@w)M)`0Hh2uW&25i-Y9>3`QrK0|9<-8^W#6idGnV8A)yV_9$i%r;pve^ zH1sHo>K+B8`=n8FHeZwZ(O*G`DnMmL5aJ*%Sq5*MtVg*kG)-&%x=`o!sw{Ud3%=bc z=CZzo46=gfcW%y3{#u(;a4)&~g_iw8LrCq|@FH$0L&A;&W(>LIy#yyN_YT&(Hz+e; z#;w-WBxJs(OMT2*0)EEfF{`p^WnoEyM}~-aa&Ykc-SNBs{^_|yScr`i5f-LP{vsPR z14CXk@iJZMgzRIVv~&V@CAXfdMR33wv`$K0Ul*DhiUqp+>KvRzP8eM%vQ<8{<79(9 zNh9!Fcu}p&)B59}(Uf9yU0@T=WqNlvbpLW|@^BvvnF0SGA8VYIQS8r1muTa=u)lq4 zM!;xm%odW`>Od#=FMb^;gW9@r`oBe5U{k#q8!c-hT zK+#C%BNnzBjg6|lL;U0@83nH^lFC^^V;=&2p6iE_4#R2wQ2*U-$mOOD@R<7cvH8=J zGDe|HVXlfsPDrN^UUBZxQ0jVvp#VDBE;1B>8!*6DpwZQdygg79e#gn69>w`w@HGgx z8w^U9#Gb90j$|fuuL`$GE_9PE(%abAvV{^?vg94sH=_5+Hzq(tr}kjm1h@9utv5b< z6JuPJvT>D&*U}^=k9g!?Is*FENwe5Oa}^p&TxERMaTjCPct?Zb`|dp<)H;Ow?-$00 zbFO>fwb4j|8mhUB1*;JtbwWg+7%V$tnbf>*7lX~!28tzr6@Ye=-%NR#y)Dn4e_RgV z-~FG%V&@-EcK+|9L-2{&f&Yx}?|gS`jWnA@HL0g1eKFR#IN#qr`uyJeyQ9$y2-uET=;*#yrQ;S!DBGttw5>W&jujH@AC!3QjNfrSmcot6B~ZEu=&Jy+r+MIT`+ zYAw#!^V!#w{pYlrP>|^$ajI6$A2-!({c`cHIOBO$M?Kr}s^%?)$WG1M#B4mHP%v-? zhb-&s9Uuvm-0}15&+lISsQZZ-t6FsqgKD~$C8kj#7fa;N2|gPFwCE(!ij%9wy7-7U zeFIN7HTF$?LLnF1fe_{?8=J*zjH!X}uFT~~N-(@^2ZX#s_=PQD;r0R)U`|#!P(hB9 z5_nCs^guw0!39~PFY8OR;QUnW?1*kYGyScUsL=_`zhE{sXfPx`b=4iU6I*DY?U5S50b6t}S>i%U zNTE%~vVD*eNQTScv1Dlp{LWpFDc}MRAiX;9>w3TEU~jTA5jq1YGf$1K0&VgXXRZDK zm;NQC+AS7@Gsy@PG>TkIfBXI}gw~zat{39Eep_6kP(~AuE-q1i$7?6ojNSPJp&;1~ zHGnR0E(e?(Ih4ScTG^5hWG?U}Eiz|5*16A_IL&JZYjU`$6Q^PtaHB(9-o%xsXxh>E zQOOQ`Puq(_&RAL<5w`%#?p|gd_NPjp$~*eYdr-{vYhr3~BRUCH_gh9`5~+q;P1fwP z?5l?h-MPl&Az>WS1^<`qQ<{|DYoqe2wCvR6ZUjIOtH4Gaq6z>*a9i?KwvV9j%zS$9 z!BEafrfPRZ1>2anf1p$c5eh{d!y`mpsRA+q65Shfq$-}mKsR;ZCOfGXN?=pPb4EtP zA6>_DTQp;I1*R-?NIjAXFWM-Zl&IQ4ihex0_T%!&(vsq6TUw-^^(RG&I|Y9$?xXg& zVoWDYQ?<}edFnEu1l-NKnpNv7@;6fif$j}na#GaSSBvv&f(5t< zZwN1$p<|kVZumy}E%91BEnEcbZdwWidpp?us05#}ZAH9I9}G_Q_sMcOyJF5w78C~3 zK@XPF^U7>oL@b~$^eI#mQ<2{oGAbYbi@abe4G7>M7Fov^R@i$>jn24^raXJI(2jpL zFB$r=sHzZ%424U`4Kj|k%mh`IGOx2IQG7DkfDrfhe3`c;}N|+tfpb4I$epUnB>J=klhsSLL1Ik zZH+m_{8oP|8Z|@+D&}UF>X62U-J08a;MUOA1-G0x)u%c{pD@(Oib`}9tEKGZ!Ojy# z=RB5M+$vqNL!)RbL!T2-C;6hloK8+s&q4MDQv0}>Rg-e4I6ZiTe31=M+n80;(SEnL z$3jp~cja73=muFa^TuIH9w`(j4V@;2%i0P(zQp&-O{rBqP{ywh1c$nwl?8g9uN|l^ zL>r}7FTrhwqFO;*#h=4J(mNW?*rwvqOXq$2L+oS&Wq2g8V9ro-^eO{RJs8QVD;yC< zg!XVH=kh=_1B~!Bzt69h=j8%yQ;G8l(UNCZI5m_Vht+%8Zq|T;47Ft7y32D|oeEXx zmmnUUS7#tvEmu{or0gr{Iz}ysb53BQ;*@)+W=;*?XZK;y-fDdBwvkF_#j`9zc3*em zp%Gi=Wu(fyq&8*^Qm~)8eKmgAMr=m=1)idZD-lX0H2`>?M*s7hXOC>PW6!fmy}Sy2 z$8G*byu_o0LY<)F$iTlUFAmW1@`ejNVh|%#OjCDsTV;|`ZvVS9;){Ra+1Jo?&WkRc@ zzXZ?$Ja0tfBuMy@ZBjJB4e)BrF=-$bP@i^5Rfnb#M1;~%&aH0B0~@{((M{-Md>!6m z)r}X&L_>r$MCzER9osl&B{D%3gwdAA@QS8{KW89kBj(CxVbkSal0%&0mDSl<>EUT! z%maUJ2X4ZNLhMn7FDIUzKl<$0$^CYxg}drK>wO_kDkc_)Rt-o8i28+zR#A)YqN)~_ z>6$XAm}nf)(Y^8jvXQ#dtm;Nhd3AbP;*GidSWY(Ndq9|u0n-W8lCU56z#Q5$lD3U5 zIPiU~)n__vA_)6aZzOj11Q{im_fSbfObmvCTTJ9;5pNCDmWH`T+Oy?&RsMZbt#Ga5 zQtlqt(y#ddK4-@R_B4R)J4kt{%14PlsL8Slf|}Q>Ev|C7;*YH85=yBRTx;%NDS#fu z(vJf9gOJ2Xx=B* zW3BhI!1zb=1v3{_ER(w0;e4P$p;y3!&jM3`*PT&+k~g$i5Vk#1t9h^=>d zve7|0n`yhU?~d&Q3DT!@Y4uNRXID$1H-aGruNT#PIV+z+wQrvTUfTcgwc?+zH}jKn z^-sRo{Zli{e^S`=KmS;%3&VPJZ+Bl{ZXxvwS6iRF!mVttI>Y!b>GheMu-tE@ypwAS zBIg4ay5vvLRc=+|b^T*~Y0%q36il4|YF;65_vNYppf_!Nk%<5U#pw1)c%AF*#0)vBSTHs&X^%>_4=v)lz{OmW`=S~LG-||?78pQ zKZSM`XY8PZ1a}vl?oqCiM6jFgaEo>#yg9}5w@3eYS5$ZY_q<;MW&F`+=KBYlOLFo2hl zchpJ=(OTp5c`W>0%$p2S$E?5uGIdQvj&U01Y&KYE3j|GDsBO*5I$~%vVRj;rZmQ+6 z0YtN)hyjvvbD+A2Jqgfrxgy=qf&$L;&l3rj*;DusD=iaeq9@q+g=Bf(>8Mwncs4j} z-B)AWd5|#rxVErz5uN&;Ijmfy0`XFvK!GPEp6LPf+fh7%Xkxb$8$zgL{6LM``U=pQ z&1!J*oKE@ne<2VWUQw;b|R`ow(%%VJVA&Z2Q)t~44M}ZsZq^vGX+0ZLN zfL}j#V+P5g_{zFMM9MyiN(d}3xWHD8nt)j~DNbfSZH(Fqx~F_tQ0)#DXT17yZ_uO2 z0!l0W1uQk`H0b!TtJ18mW+khoV$vB2=bcw+9(aPdy+L0l7Z9pr-u1WfynD0Md%!)% z>(!?{S6afdu?1mQ#x(~wIDM%jnd6|vgvdL~_L?iykK3dh+X6|!=@v}wR8R}}TZD5) zU6h=CU}rx6ub+N=`Si&je|%11o^U_aMpU)u7t~Yr7i;$iNBhCKg6vk?%+ZnKH{`+MkWt-kgse1=eQ(SrXm!#|3;1_M&aAUK3Ic)V$H#!|Af%8GLRX;=VBb1*6@m!ZrmA=at}XW-41dw2zD)&~i3Dr7 z+4q#?>lPK5q$szjgVfA!1q&||N3~WWH@>k;446(JOnX6Lv&~s0q1JLTk8=7GmVkYw zmoRt%IQ@xNuovSDePJymh!dEX=+cCL!ARq1d6=ImQDAD)b3fF?_?4!QlK7R)-KbUTuL3IslwSk>vM2u*^B7QdAM5yZl_huiuA zl;V&MHYYBPD9W+<8*7nL+N6jWwF~~I+OX&xQTRB`jCnswf9hj%!@H;~?H%>s0C5}M zC774DGPzHMQD>Bx4#g2=1wRZm$uDXh2Z{_pqY<#rbOkDz%aVOLDQV!U{&)rS0;gkU zv!gn;?_V4ZX#*(v*vAItkP0*p>_Sdmr`CAJkjaJTGT6BdYzlSdC-&(kY-Z$ZrO#w3 z#byLh>P+l76_W^bLN4~IbcgGqhD z;v&QZJprUGikb4a5)2f3Wlvy_FYU{OnK-Yb(oIG@??sM zk56Gu_^@>!UyDf#HIIO8od~RlS7SN4zE6BKvRbU)o++S3B3BvE-gV(qcx*@Ls70Ug z`>LNOyPIHj#GJhr-L4Z*48KKJpOKI^%$zATWmI$sbV>eKNk=DEjf*W9=c12o* z9quh8TBWC9nuFG)DU$H$y2p1y4*9B9+bTISy7p*i(p$RJ5#Z;=rkV=JET4x@lsq0> zKIHGUZpGwmf?zi0v~Is|IxQy1m#4*baqBTBUPqlMTz=>UOA4iF=@#(ralhoO03@#yh4@B`ro(Zr+7O4%(B&@Og z*67oyq8~*2t7oXFPxZHLfGR;N&2px$VS{`y+O9!B`$7DqeuJ?HNrF3R%*YmM+c>OD zBYYd@34iXFtBpG5K%f|c%=TpFZQh7~MR4zq<)e@f56K%Z!=X!tH&BzlS|c)1x*qrE8@ZxT$+c79g-gZk8~J z0CxsfJPA{@kMB((WleoG6e!>JJR?_H$JJzBUzGPA4rv06WND0mys?bCtBwJpU71tl zz!6&{vUhKuy>Y}r?4hpdFPehgyzK-}HUR40Dd6S6cpVidAjwU_RPHDR?*)Dxl&x>i z>uun^)Ky|$eB86cBkQUGoxaYkAsvOvpaVF;nB05Mk?#^)=(yk`JU8s&xCr=xdO$0J zME|aSY74qgu)O!y{uZ~T`*AY#YLx-qKJwZI(#^Ao?7~t}0p}Zgv6DZMu7%zNAKJkk zxkMykch*zd#* zk}@60N{X(5IXQWO)RDU^R*gDI)}~0CM3?59;LM|WCn;MKJi1++3uxS9P#s*}ED&q{ zTDBiHr8is`HYgV6z36xd*!Gy)wze1^$+ib#b_RczZDBs5OqWuA)|N-rn??IvAR9s( zzhD=!Eh9%83Nv#LV~&OcX1oJ89rcBnfya@Zj*0i#FIa^2{2rBvYk&kt`=Q?Mx}{Id z>OXCt?rhg7yB4fQ>qVF0blY0UfZws8&8%MQ%i%rv(L|Af#u=WaO2r~y06Kx;lTX2t zIE0VmT)`h z-MR^@!>Z|9bURIrR_VarMjbS>}~@w!NhgvqAb zZjW|7q3HO7b0>?S7Np!r#PGr20Z$vnQs7@ms~f2F(ZviwJP66zLaMovySWqY*+1>) zo=M%bx}<>ik+PT8WlNgmPMR}HP#4-X7wRDBMqpj zL2mo+d4ns`s{tJf5d9(>i+cb1&AaD&&~J#uL1^nWGU#fG%vfDL5atcN3N|ORYLcl% z&2~7jeO1n`VB1+219C5zD|()(1<0=I4OUxR!hgAeLd!CEXxks_X>K@N?9(xt- z@xOTlN5*`1&-<0f7O=Nvfr|6J;J0s4)LkT+XdJA6c&eCBxhC_#%zFW<%6FBLiymeA zPj^)wj=zDGQPWwi8Po&q+G=jyTAVj7Ju0#aNK)g1z#GX@s-Ex50ElWuHGgrcQWs}=AlX6k4s=65q6Gny{HJ)D_K3p0%L&3u!kD03zxaxTIdJh9X zV*S{0X!M>7rdVqVi5WA#OL7<2EIhbZH3vXr5JO;=S}|rw^FlA);l_VAk!is zS}B6XP&LKHuXs*43HiF5FK0RO1%&S7%YV2YeJWZsmJ!8=!# zov9hn&11~orhzT^6M?EZ+znKzM5xfk*kCvu7C1f-FL0G8{hRI85Ji4%Lq{=0jdP76 zh<{ylYNC#oQ!>7Th8M%amn^y@zr*Wz_!-Vc+gI~V)D+~asdcR2^}b!z=ZlRxT0u_| zt}EiMfHJFE!=aT=SH;;G{?#nY*$lhp%y`vcLYb%Z)pPzTT1X1Y$R`ElJ9QcHivvL^Cs-89Zv{ZaxRpt)1lg8T0`Ct7l z|3q5VKlC<%-{mTwRt?O+)T@r12B$f|tS@TqnUbGZQzcR4VBl7V<-7uLKlMvdPhK_i zVwqQpyEPNVsPkD}FLM+RmNUPr)R{$nzA8_1IE0$&AEo-EIWMO0uW4;jLj-_gL#oLo zFj^%7e5}^F;!RVaVXsyVnWNqU16O}wKh!^EF$cjqH{)*V6>T>6dssuY<-BPPclYx0a(wyaxL%#@KKSmt?{=}oz#)bIf(PD? z3cMP4FTvCCSmhZH+CTg)R;raQ15!yzKW=Ic+$P9q(>9 zQ= zb>H;DC?P^!SkD;3BdZBMpgA0)3?_Om2@87HncYge-xl)`$cPjMOg6_DTMpr<5>U}1AKA8}Cr!|rY z)Ww!p%B$rTj!`1~2zNk+9x2q+4o}p73b?N$pz(>C&jOg`3BiMjQTbl~L&*we4gF5W zKFp6iL8h{HL?BvI;|v!a3?1L z#pHJ;Be0}CbZREJ`)IKt;rR$JIBr?I=L`~l(g3-g$kPVM5{mYu{9*7)8fgC{>+w8$ zbkQ-B((-d92InBU}w^#V;%6%gZ%tqe*R^C{#Abdb$i?HHM(k~JHP`v2Y7O-r#b#R7 zIb37FFYiN+*LnY1G(S-n1h!FNG=0uVOecj}H`VH7RV~+WnV~i=n?=|Zx`HC^Kxuhk#tswdvJqy)h!nJJc;lU+nz^5LSElm2E_oTyf3K(1_F2 za5~MyPpgu+kEhjhfkw5`OYP@@HYWNyOu2&S`pKM*UZZ5F7GY?^1NI~Qw&Luy=FCB* z41mVp%R&e&>OcfzR&2GJKv?3kUXhZTn6n3kz6RL(Y+9F)>MO3_1^@TXrImt({`w81XOR-Or#L&<*#I*+Y*GwX+1$C z6y7vP@FmWS;oq>q@qR5X02{pXQ2jF+7v-%SB3cJPb!#_NHaR1A1zS@0o|J(Zy zzxqn(e|p%DVh0jG%wN&yrRtw*4YsRKJP8M`_A2<>ZGgR6x}WXF-P&a&+nIw-IZ9!H zRn0ra8(+c!%0PYQ3_#9FU|@>-HVt4pfmU&)m}{xz8sM$7e6yMj2zSWheE#RATwOsf zDxE8w&MY+F9f~s3Q!H{J_?p9Qo8wgI#zOi<$ie~~A;gTsOT4Dk2N-)RIyJt2YW z#+~!m2SanA%QL+Ikw79ZnESEf3Ww&$k*zA(0bniY`V6e3vqisjveKvZoG7VJonB!v z?jKOb|5$=_>ZoCJNOeko81#nMKBYT)R*#wTREfi=+>!K}l&}Za!c|!K2(DK1+PAyf#q#H3 zKfpN$)iq4fs3nsJ#@5VDRg=IAjGNMy;FM!Mn0@h;E5^9l6wNTe9u1Pro~hO=e@{Ja zei1&hvW@U%02#T86MI#Qi~0lFH=lzM^v}g&iaZ=V7BHdEA@-D$)xN)Le7azs_4>Go z$X!WMDll(HEA(>l!pVw4z`YG!Wo-HlTv|u;*Xe!SR}5twR`nLC0{_KX2-guKpyp$o zWpDOuH&kO(k!THh5v6aj2lS|Y#s`a zz3W^yI$F*0+EHhMC{K{qYjIrIY@orhecV8y1AyqJNKNN~&ybyhnCT1ia5_)L9PxVT zPTi7ZgcYVGEaR?6$7*!e)mDqu!dT7PFV$)daY4`Cyn;Adb%#^OM=?8ttiR`TP~@wl zU(NHuqBuF3*6PU>e|b>N)$yt;=Z~*@I*SP^Y$9#5m{Q+SH26RUNjSj{Q@!urt!(Vhf4={Bsip^oh1qg;ECqUU7 zXIPB2^Dl3ZDCorO)AiC}xP&8H}@_YUnWa6Pe;4wP+jkI3; zI-2dEX+)AKL{zZ;$&?zVYckwTH5$4M^X!5{saPPVT} z_nNx(=n+>75ut&N06G5?t~-A7$5C2$_ZJ9@eKVWBoPH$zle*Wd=~ef+g?f}{ zhe4Hlt}K*?Yv~7oqPq=_oa;h|rAJ)he)h!|RlwOP9$k0husVw3sI6lY9w8y+sXk~H zUZoS%6wBmf`~>{l+{R9d$p_Wjc zJBn<}xP8SFr+RRRWz?J<`6w!;x?icfUsZM76Q{yolfo3tHJ3m9^~ko85_7$-ken-i zzHOp;n>|=F`zK&eo69x{dkXN>YPBSO;u~xADUsWodJZ~#LBStT%iHQsFq-<3y_xT1$E zE(^f}${H}--AWWyTk0jPj+>Apvgpn2LQ{%m6bt`zQ$lbk(Gl_obuGhx7itcG$EYrq zE7a4#r_=Id(u>z`m+em#D)SC}yc zSSk$@oINfxz7R^t z8Ka|!9c>WeoE_T`XF4Bed(Mz_%##<`w8B)PtcvFcQAr06G1~BUO9-x7w}B6Fzh_4S z3b9$XvciZ{1W86Zp`cS|MpSW|T2cG7a8)|9xN&Rwe$Wnu1T)@RVDLk>lTE8B0)li@ zHqfRZzTsPA4LX0yUmU#%v%MKhoTctO0s%c&MHNxEwm zx`~d}?n`o?(dV%ol&gh^&{ac!g}xaH&?xa+3SCctJc7~=4d03P%mjFk8LBe(yO z1YfN*oEjxh!obXW9RvQ=vddT>1b1XXO$6{SN$kK%&j>l)?S7t}Urkp?z}e@!qh3&F z#VLvu#cZab*q}+&J><|!ctX++Wgx|{g^7zi9aLCp6p+D%$rfckG&nsVlre}Z$X9e~ zcsceQuu5~9sA1Na$`6p85Z=n_7^#;76imlbzZMjVF#!l5PTBLTIx;QVOliGfQDjt- z>Y^N{S1z^oNtRiyd(g6cX5ENG+U_Dd@+f%Jdezg#Zn*dQOGA>1c3a(0--&I%XVJ+} zB1#R(;-aJ(Rg2m#PU7Suqmqy*S3Tq9g@MF6iaX9CAV%_n7#Mu|ck@hwjJ zHi4zbSp*s(Q2Ye}EYkLFK2%FY5aT_(vnprEdbCQm{0P`Sc%uR%>hQBKzxw*?(U$&I zF2bf3NNIwYb>eyf^Xy4D?M_^Ry6u)bQ#chv9o%^_`GC{(*;ikF`Q0AoO|u7|T?qza zTa@kI|wOX1@)y_?;EiLS6iI_=36(6f?aN zGj;0FlJ7Lja#EdElWbO>ssE}2;JjR+=Xso45umelKvh}Jp*D2@6zV?^?56HoSMX?B zhspp-&8)^DqIbBM6uOWkEC`#tf`{KMiCeZ z%qNG{(a`AhbKAphaw;WuR7YJWiqJl6A=E4S*eqt%hmy2m5a-FHYL+7p3Dny$HuHwF zc{H&x$EW}k=`=|F-2cFr&P3;PG;H8k$ulsmCbwk-H$^WWO|0R^7D164VUR=#CHP|@ z48ZCA4X^WQ-!a{+>yGcVdUJc#4Q}Gn(vUx&{_OWqeW5b(*#=-u$t>L1=DIHs7Oes^ z76ETie|&ES>T-tT2W^*b)Tmn{@bQBq`ABni0i{sK)HUwR9zPh}?9Tqvs+w02&+T4t zTMS1o(YW1`FU=eP=vKXjjVTn=0^D6XW0IHA-%|SPl(Z5hHHx|%6jOXJY9mRuQb4GI%?+MmLSHcZdD-wV23WjdCh$q ziTXkPwxhFQl@(uIwmC6-$)F%(t6Mh)(qw?yZ$kMHOBJE+vZn_JV*w4gnlDKz*JdRY z%^*ntT*j4PMaa}36oQ!vFesc_>eKA3Chf!uQv;BJXEg_(GSds=gr~V-M1sL(q)QYI zgeW3{)5QTt8?|u;KT65r4b}GQH~>q9eBW#9o*xka?|)sc<&buroVc`6mdA48Jp-KF zw2bb&oH3h@(#gD??1scSBY<=aEkmeW#;HYp(i!WLc!=5Qs-EM6^SW6Zjn%k? zGzf#-(foCBAD#U}5;7rn2`b#lq}@=&nNH6Ts$>PsZ}o_Yo97vA^2;xIms|BBO|Yx^aBCfh;NfLhpY=5CEAUXrjL~m7 zB2_(`K0Qa+4){lszo_9ii`kVRAF0m|^r`3iU+VX&-q!c(`{#I4f_ENtMKijcfYG^) z{i5CZ;Df{aM~PbfVy2}dsgtG?I1z1~&?C~d;|EeFs8+w2X-VueMtP9%J^lD{@dn_a zIeprz`l8hGZ)gFs3q(eLeOo`B6=&q8iFk)6SK0U0awe5C=$NL~mTpD6YG)_0ui9I+ae3ZYbANZGI)b{R?$2d*#+=SsKUs$CwFsh-LSztM zeBrcs-k~kCs?N^WTT|Mn zm_*I`WC^ar)TR$`+b`dw;i5@7tA&!orziT~WnDe0?dA-@x=O6DV`qFS_VGy;)?G1S zr9bVy{8UWqw>CF=K5De2GfD;*IfcwE&W(a)xz!=e+#b*g-#Qkmj5nw^Xb59X_U5tM zpTp?8qtthMh+X-T8y*Jqb(1kT^Qgzurssk5qvfTR;#wmlP$k=A2ek7ZR?YU^CO6O% zITEpz$Qj{QEa;ZdKst*# zgqj2JsLfT*bUaqK2}QABoLqEM_y1W6-wwR!_I&tSfVnd_l^-1bBB>bQdWr0jI81P9 z1?}U}$U>}1uRVx1V;yWWLB$j4NKM^-tFn8Ddp-N1^>*gz`?ui8ZQevJPC63Ka=Cyq zK0HC-O7WFet$iiA>!`<3dKq24_8oDYb-p?hHP3|XaG?*i7Co~74dn4z9#JYiON5(b z<_h!HXOJuqK$!QkfrU*%#H06j2V;tvg^+XdO)a!~iy~IX@9&Oo7FX8IoVP>=r$xi}h*a)Nc?(d&^jF3U^+WsFJ&oOaz}QPT7Eo58YS;gLfL8 z+fLMpDI~xGwVJZ2B@ZiTRW{(@ofJ?h{K;vvG(yJ>BNNlx_aZT<)Gof>mN-xm3;f89 zMW-ZmAgz?mI4F&oK`u*D&Q5Fgz6wIPaMh>TPVg-k)8YOady7j~>ug>Yi-yAX5kJ7} zw1$j;pf8Mi4-R7|SL{rKAsKZs-6@t8Mp#`!dz2<#^|rud(IrG@>`)Wq1V!nYKft*V zy=@}WOP4jr6Yga5NsQg)f?S!%PMjY$(|T{-py4eU@fkzXI&DWU_iqxNU)|2lB=8(* z^C?-bN@TaZ4sscBKs_R!BwrU22zt4?P*L!7X&v~Memhia z(ru^z9J?3(c0Xs^J6sc|Pwg%vw1QwrQRPySPhdbS9n;~Y+itkOjXk2f$G35yPdd?$ zw#9^a=HP$xqV#aJbiws;76${lWqW6Gyys!A@54Wih4MB>Wk@rvJ_7z7>3$v=Y;V-+ zFResa$LcyR`a4*K*U6t?MP_-)ur$}f__SY5BDztfI}$lWRe z&<0a)IYZ;H38!q3D+^9BP3{C>&N-Z2{h0t3s{sE9v-fElPY4;NYi6=87H;zB)WObq zjKwHk9QC#i;LdIA8+~X0Mx9Dnndb@fO@iF9q`HoMb7VbOSVK3o@3wYuL}XRM8>kn5 zEUFp8BKRrO)Xalt6ym&c94-gpFDPP{)M&WG+P-hILS(?|<{BLzQVFy>Sqcr1p7K~M z&3ocTRT`#^{{V>82M|J^W!f)L&Z!L@Qld=C=)PR>7- zOADggQ|+J-cm;I_Yu*M&C8kU4r%e82hZrNJwBn?|1b4%v$PVbSS7q8{9Jp|fEhq|I zmU&lA5l9c=@YH>N{K-K>wg=bnhu?y>rlsn1V5*1TptJ7+LPLG2xip}8Rg({jS)x8* zSuZyTa<8jRCb|HK7scQ4_V5~I$Wa$u+bvPCZtjB4D5WsKX+8gGRWF-8ig$;Ek!{w+ zfbf%Uxnfk1Zfm=*Out55W=rfKvKCkj`(682I42$1QQKPVi}%%47yOUYCP0SJnv(+# zj6Jk(C3gY|sK@xNqSBR{lA8aBnyJ5IuyqUvKcTp}mkko}>fJS99^93sNUW>6Nlm<~ z{hEC0=&bd+t3c~f)2pW2*^w)CzW^Qu`xzKK$WKOE0a>?ctH8y?#6z~v%A1cE5Co?5 zv|2T5WNEFRI+urU_2uDP+2HrBXwnhcukDPScQ>&~7_$1c$9~n_1W3a7Q3 zLiGP+M3Aj1(_JF-ca&N2M%9yo-ZsG6c~aqc%6TP|LRJz}w4wV~)pS&^t}|zNaW3c{ zb;0RPJklO_9SC>)MNsm%>B#?oF#Lb*V0cwEa~)If(9=aTCXoHc@OS&x?(6@(tp0k7 z@SnCgCt$0mY6nu7Q!B?YY#6Lc)q=#i_S|fDLM=g?kA!K*?Eq^)l)p|V;oJ(@tv>_3 z-bxLA#~A}(;|~X@4;dV_yCrg*$)uh^+G?QMX}Ki5A*y7slI)~Hom}JSZnUx{Rrh+O z?rf{39QvL4Wck}*3!&PgQ*CTYy5%}iT0BA!!uf-1f8Z)1=ygIHed3;|lO32sWAr_E zb2=PcY|0&TJsuE7)cu4s0b8Lx#X_1R+orwbAJASKK@Z)W#u%LA{PwF#qWH80-Z_bv z!5>ncH#h^K-YI*W{UO`SzU)%BYewn$zQk@XM(fex+TvLUI}L;Eeru=G9Kaah3qR%juW_#Cp~qI1_QxrvmpS%&91;t)R6Be*II1wo8jwSLa1zv#K8)ygh#M?%mrixx{?UvEgwAt@4Fc z*LFxX*X`;w)a{$f`e?X9hq5+jvOc%xggI2AXF30OLPpm8yZIIK);UWPzPN*T#wxed zK;8yJ*cVO)P0)YqTdlctbfksQ{~IKB4Eyy~a0N!DjpjVea#<~O&~e{3KzpTnw)(JH z<|sOr9}56A!?Zro*^^m4`LHu9FUpw>aaQXJL+;zi_sbu0FkQ~8rhz)YU!T;|s~^T0 zTn2s9DC*0J2W&G{AY2QpF&>OQu`UhH%?faJaY=&}!a>@xoZ?k?+{Ps7d@VQ+92vl1 z3RWc|z-QIECG1OwKDasL(t=2GSm@CR&B275GpvQfYv6#$S9U*D+5|Jm3DfFCzBhlC zv=3)H)Mg9kNm+6}s$DvVjkE%#XE{A95x;K_yf+btnXzn7VX&^p1>~PfR2m2Kk23@w zI7f8NhVnxxSxep9{BknIt12D5-7m5~zj@k>v*Bl7ef{12Q7X7m-KvhEBjwW*8;jxu zmZZX8lTojL8B7rbod3?vQ-IWH3}OxvOuJ`Tm-~rJM31I3X}_82rJPeF{@FKQKlrjoIrh);yt&W|$YgmWu!(YYM#r<`6x57+ zG*FJu#-!eqQrxB+$EH=HQSxO?5jdONGN7fD1mHUtrRQ0@28PV0)sG{&9_2~mp> zdy^Gw3Q19-xWP(Yl{+}EsGT)#aXO`nl!2gw1Rva2!+fw$e|>MpK0aMEj+N-a{a$7w zEAZM{0Mz;Z(XgK?`ubJ`+AZn+)-71uL=c~lq4a<=-Cl2sPG`sf@#IY%{vq0XBJ-c< zqkE|3mm_r4y}zx8gyf;y4k);d@@PxV>o(UgUuQFtlH|sx!!@UxUQqsd%a-l|FEK+V zKDWoR!ZTCKw6d)dH$+| z_-BgcxnGC9(bH#Y2ynn@HUj7{=krj1*1W^#D%J^X| zwO+_oUZm?&#TuXwe=m)0P%9i_gQDav>ZOus$R-2`NQwuSy8!E6SOC)a)pzJ~~1k1$4$1CZP}dgo=&Hp~@hvRNT?WXDv*qDmL6r@VsGqlUYDi_n?Z`V1Ml9G=(!U`{% zSG$^Z(8s}>_-t9hZ%5UDB$IDT5@O)Hw`U2wRGo^onm?v%%eAl z11vGf-6}ekU02@X=4RJF?d$em>UjLn=79^InSpc5>x1D(`0VvT4u>XI0U=pb%@)W8 zN)~^<*vv8R1V^)FN3i(Tvag#qjhBF_80VcdqrPt_%@sa{H7{qzWzsl)?hHoR57|zb z3KC9}1F;=peI14JAM1Kn7K_xRaLzhERo%&~SbU($Ly!QlBYjV&N5+ED^oN5I{E0Kg z6u;l4cR$3W^g^91SI`aAiwvpjq6csH>h#mttjo#yqM9I<0Y+7VZ%3o<5aoiSz-exR z(SKi^uGEVBkPB4;H0Fz0(SVB{XojH{+NbrYk`F+XR8j(3%6`s4FwgY0oOfYt`tUM2wts;`(T%@juDBC}J6cDnbJ*o+dI zF3Q!~eoZUxbfKMOldR;ngtP^}=|N$^*xkyvob8)!be{*cd=|2wJ`>or3tI*NXXv*N zzWf86p%3n7|CT*?keya=kH=#-D=#oNI_wdBYP!xJQHJ#IL1Hh|&Hsn-cuZboC}v@R zpI0aOJ3+6p02VD*A&%R8UQR1Tma{7#9fbO6BHX|4p8waoCvTrW zk;0@5BXA}}DrZH5f%N*0YV-KGDwpR82uhwAwA))PUCJY)95?HF`BKjt?3m&V9n%t~ zYC}BFVOf6U#81Nku9Xr_O!LB-D{-=7I^DjeUJ4X5QQB`7$Uv>HOOU8cRJ`0Lh3if> znB24OWg}tfM2Re6bUPg~unfOnRdVGxQ} zZX%U%FPG0S9xM)j3Cn~nX5o8kX|&D#b25XKIx81g>x+8jV3B($Go*5GJ@BwK8#jgE zF6J#(htbO8%^@82IC?fNR~WwC0?7u9TCu9~3|{z6Ol;y_LHEDmy{ zm(S|WN%G~pa=rvq56XX@DD<{GD?f_w)RlR5#k*DZWIffgW|s#?ZJen4CRp+DlD;D?~wr^hjyg!f;Xk` z2KQxR;_QyY@tHvTw8@Y}W7?gFUk=w(TaENp%mOMg^C{1W=@3p&Gpi=$@IIiTj1|#z z=3Z=fG6WX`>dGg`;n-YOXd;*-?Z@gX*r$7GH#@U6TSKcT#v7*p{oS^fzHMpAu%VtU z4O$xd=6*{<(H`&F;NRLt_J?GHNZwz3(W8N3TLa&Z{OKzaSC2K@{>BP zejT-@XIhdHAsdWthF*~dsaS%3`;H)MkJXsh!)3c;vp)GhS+Tu%n zru%YLEP2SnJ>#%C>Iw8a%A>s%QqF9|ZVM&sU z_xp978cTKE{Eh7(!x^CgBL_zxe7J}IM9MOCW8eKeD^-scYpusqtaE3x0PD(*>U+a# zIZqG%S3qZ)H-O?%EY933n#ONJhkn(~!(TQf1_xEMa&@%lxPqw9T{jxrjdIbW7t7gZ z@`0Q`UhuOa!#ksDKK2OG;LnfsU*mbP99rcp_{EvBWNXi^M`Kzur`)kq?ih-wxn-Af ze-{+fDcU~3SU^56Y_-HW%d_c~dRn<+vno1<3?#&M%nz6E;I{|m`sKQu4}ZgY_uSg| zbR%5*p8g}d){A9{09u$8)xx_0MuRXGkA8!2m9PBPrSZqmDnEasy+4NGGaRz}*&eE? z-SUMkXa+<^`G4g^0m{X63RoM(B{rW82`-#sjun%92TDN*l5a-g%)TuyTPD|;Q$5^Q z#qtmef+L~t?ygIK27jvw2!|Ujzwsb-y2*}proW1}pgS2aA^bAVbMa_!wY?yk;7OX` zU6OD{oXUHORUxRK(wC9h{^VHTu-LrohK6|5G2ia`O#Z)_* zzA9E96c1{y<|nmTgLvmLQ_^(&7!H!<&_6`r2+8SeF{g&Emk$^9e`>qYLv?(>S9qfU z=m}I@vn{Yu_mw4pmrX^w`7`S31>$xnqna=4)w%$WYryJg;VP~ZuIHDD9=YVX=~@b) zIu!b~*>YJl5aMn=-o}NfFR~-Gs{S=S9P2Ll52-JKV1tl{@9*l4VyF4*NwFBLvy+m1 z9@h0)3Ah$xaF~oB2;SfQiEAKh$%?<$bt##=*v#0XJ66=d1S;Apj2}55c1%8uF{wBK z&*JZSH3frAQ$hMD$dQmuYiNuxKmq!{@)8qhgdx{+M5hX9mgPiE&?HAEkYWwM3=O3m zThy1j7^VyGYUFHVYqfhzHLS%2M_yxCH+FcJyNP|a;oPvac2TgT;13bgqRW63IljLu z?6Hx$01dFc!Q%lt#m>vcX0YeVZl<&=cc#^^3uEJ^n$vyqnv7$j%2~NCvtaCf-B#>p zG_AkSoXu-R>zn1jYQA)H-L8;?mc^_uVkiCtaj7tHA)J0LwjZ8us$=p=Ft{@aj{*4} zY1^nFUqDAc>M+k+dnf*%9-ZjJUb`4$)K4z9MOXi=M_18s4@}WF4clfH#kxo5sFZJt z#ahV_O|PHR6Bd2EXOJTMz4v~c6{cVU1Gmt`F6!>?jYm6M>v|ys7C|zc}Sv2R>>3V284}y|; zjpC~Fu0@Asnw3`6Nce6i4sFG`Y4QlJp87}bOzKg8`Z2B9ucePWMOKQ*`6EHwdbb)O zI0yWf=(~On z2;i2~WdkxRNRKS(69y3fpvV9&{KqRJKv!%0G<*H#opy>;k4($+V#)0)QXIL7#PAit z;bVw@38}s~^Vp=GmS-hlWV+-kFM@^{eW4n~Ry?9r9NZ%>a73l!!dE7Y63c~-D*)a9 z$Wt#Q(z%0LI?td1#OXIW>FoP#mQqclK3|nStd7P;SPOWDXG4dYnQH=f#_Fz!b>U$4j&ygLlIpsWUTLH zRe>+}9nJjb`2O?k>8fs;9q=arMItf@aF;AKdZm|_@?uAcQRR$2-3_R3VKRBWfG8N2)87#2Tg~YS{N*{gfz<%n`*YVCHMn>0Vz3|Zte}kW zrN`BvsffOVN@5+!kTY!9Td2?uMx^5Xkxr@ssK!Lh$M<(1cUQ&2bW0_B-Id5DD%`TT z3SCnHO2LJ5`M&7e1Tqa(=4`>>-HMo=nBPy)VV4LgsM6DXB5AswrjAzDQwnfh)SFy3 zAMb@?1bKw#egN}qc2Z0}K=sy$(>=|qhgR=k#|`hUp;H0O)~aK>s>#aE%NZn>hux|- zuR8I0yRtUknPK>BoY=+k#M_TWj0Y4NY1;>`^K|$%CIx+3@N|umW{Dn&Q`PGdYpT5m za00e&=nWfXb2m_&dl^0VS16|7V1<5ysesTjo_xnfUM&zi9q0lg6V6fFS%7PalAd6K zn(}Ops#B_pE=^5#QmeAldc9*lS}H22z?8{ei6<*Xhvk|TkftlT6nOtMd)~X9431#$ z2U;fmC-9#K_&j*={%-O9?vek+$B!TJTt6%hi=%Ps(=ik)pn?Xgh{`#1iE;`gF;x2y zlJBf?f{JuKnbjcOpU)Rl^+fRhHq_}*pOTSZR3EeR^?KRt?e3mc>+{VCgyrvEY|397 z`0wsg5$x`_-+p=D&C!c_9(jcoiPk5-LcA{Ubnw(CIBV-7G_o6JM&`B97iC7tVATtj zu-xqfkBuM0;a~)w3y2Q~#fxVBQolRGcTg9)x%$!zdxk_Gh3MGi3=D;ZNLFWG{g&`9 zMfHy3vH(?$a;dOd^Sw+Rd~jp6-%#7=*!u;(Z4Wc*pOK`s!|4tJ!|K@u^GAaMuy;w~ z>G$Z?`%Q%Fx$iUj@Es*hL@7YkWW**WBY~hb^#v{FxT5;FW{EIJ$ z?u80)F{AH!$324GD|{3$R#bzX_lFNDH=X(Ytz-ud*CC9F;dcm|YYy3fda>8HBiBzu zitHbxq@K1M(-C<_*DF2hz|l7NaGL%waG)h-YNk@~C-kS)FadvN)9Qz|yKXpR{tA<5 z`=6V7O(`8$w_is+MNZYiXuAi&!CshSgNP4twzH<5vn-Q4-U4X2J}(fb<)qA}<+_Bl z5$a*F&Q_4LW?pg~lq4QMz`6ii1Yuy-^#_3CH<~hZDjRDNz5eK%-=+GrLotJzEyS}6$(Qf7cR;5ej294qvWDgqygwa)l6 zfF4K&Tbh4$Q~2Iq7HGQgwr<2d-^ImTRp2=f@;whz{rkh-dqvObd-)64YdlTfoQ$)d z`5vKeqv~i`oRz2(gXbg^s$Hy8Q9OkQ6I!e^|4L$ABEfEryW(sp0Hpu#q_~@~zE8kPe%Q-I zw(b0IvCpU(KqMRj~qF*0h=cf(&Y<&@Q&ztd@0C>cmk+HrX`mdTtkR zJm|&FT%Q@vi^|JuLHe?Jxh|#-wtJW^^g2>scW-20f--t)d;WU9c=SF#$JstiCeYAW z%qU=J=N-V^(^q0c_kZcG1d8prH6h-RR}+$bkE*boR~J69mATI7#3&J|_x)YpA0nZD z^$F?y-N(n3R5TB_3HKAL`C;clRMRk?Ddcf54js{z13Kh!>R^HH-76j?8u5oZxOY$Sl6&NJNxq8tAe`5G_a={^+?ZGBu`>X%uby{Y zL@ZcjKkiC(8o0rzQH(~vMcttRUN{5f-Sk+A&WjWlC1|J%PgGm_MUtJ(`)=ulOEG#ZR>F0KVyh9d+jSM<3>?OLg! zJ~Z=hpR1=|JQ%gLdX3HYYi&aHKs7qMsD;#xIAoXH@qd~6u#XTHm6hT8-66a z05$|`$9w1r9`auv)EfxI+pD*uDFa+d6o2LE*<{hpSa|^%VH%v8O2A(>jI@C!Byq z29(j)4F@FLxE|vc^MA~(g}Ltb4lUR}Vc|l3yyog4)Or&zp%2yW)%bWG-xvDpNjn;h zI_)`=JO!{DsUyH$RG@Eh4Z>sPWVTsBdWn08=uO#RhNFQPbM8i#86ONJVpj5_Dguzj zQS+R#7-+9tRDW1^dA0W`C$kr==t7#3r!e{kGcVzq;Q8fwtxo@CT~X>_R9y^ zX1CkmGf~Nesn##mLf5P6tU^AIEMM!xPOFdEXJ38&@Bzjb+N3{=62ydJb>;ewoWhy% zaQyW+`%76a@$?|U0~TGKfa-*Sy{kwOk1_V=!p!e#ucH(A_v-tvZnT(^xhh)KdNF2$ zLomPM*SS-^b(+Pm6Tp$g#C!u9AxFMhOiIHXh|`?w=#@Aq4i8n1-+ZKNMW{>&;hbz% zn7~>Gcc>3|t_u1A`ZG(2p9&%XQWt8ezQ7u8C!mXF!@kFu}71Ych&kx>a zUq2k7d9_+h>J?~Lv*&cqC@y)hF6K+kDd$U?Kk^&~lO6^!fQ}ksb+dUjQ8&b*`GEKZ zC*}GQ(A@Ovq&o)zQkW~!um97jNxPW#13}+oaeW#wH2n%@G zFW|4&c*x+-!v{wr8f=i)N}V|z1bQCLYaBcX8@ah!Ol+cfNEi*tC#nS)=rAf&pF4_a zoPjupXvBOz>Q>weHAhz?t~bCXG(oamn!ksceTk+#k=Qk^-JBH7n2j` zR_gYlF3#1eMrpVikE2eMW6iQ5)N{^a~gJv*4 zJQ9f@+3ZPC&G7to2j$=doNUg{uHq^4xMh>5TQTWx9%j{>gX}w~XHS~>`+B4m2( zmbVPcRP{!pq0n(o+5P5~Zm}zAx12Z)Zdh{GH1%c+$a>T{cwY+%&s5WI7EyY%s3XV|&a2rJ@*nV(V4-&u?EI(Xw3MOsMiKj;-@W=V59*;6 zYkdDvB?sH&@M=3?wGE+A;k^lYPcb7m)6gFk(#LHSY5aXd*AvJ!(`3WXzWnl=`=fAH zO@1J!!{~o!UYM>A65>5`JDv#<_SY}M(L`QQiRZArA%|^E43sBO#E+Jo>uuJ>`w!5I zOvx^_V!7E+y<`OUxWM#r_Ty8y#Og4CIT3jQ01ybEh}Orm}%K{ms+tA z#n;q5W!(^fI97#pq;48lA{PH_PBQ}~8#6a*{0}T@NBy*zb$W!D6`Y^$~qmLm?)?TK= z7&b!S2O@;v&6X?!lo}0lYEqqT*(CMwsN}XO3%oV8`&Y;kQ8fp@{AuVc_DC#5BZp$9 zwvkK+FP|GXSC;4PPC=%t+S3ACbiH&X0~oyfQ?Vp{f8nI< K-U|L-a;`w*Kw%tan z)c5M$502q!gBZ!*@6zMADwbM;E{)N)f?F^)8B?$d%$O~;#ddZ+>dt$?jj6u%YYdfe zQ)(>u=q8jFCjb0UElCPNvWFrduEXKAC@-^L;5=(c5V1RN98~f*+yH-rB6L@RKn%rD zG0C0>Ed$ljZkeNPOYv_oixsPCb`>6sn>A!DK?NxqF`T|kH>lD*RV3Er*~FSRvE$b5 zD5w%mFxtp+g=1f8%h_gO3@u=5LN~3y@vMwPS>sN0-pOnh4lsS1a9s_W4N-IuzQFvd zdOG3M(|Lz~$S#QitD8u*PN-DGRO^APHR)ndgi2u2s&A16S7x6$m%n%+(;8>1`#OFH zPfKlu4)epg#~yOeH$T05`R4UNP$N~%>w5ii@d7C3$pTP=*H>Zxq_42xUlsXj$i61{ zO2j4Z)0%4raQw>YumdUOr2d!<**62}dQ46Xv$|1KgtU*3L3+`Lqlb;U&XiQC^d)W(~@?tw)zjK4r9`sdalR)FNaa*pnZ zV7;y+Dxw^8^Z05aQY}xdQ!&d+HixEO6LBF^1faO1zl?5(ovA+=Vn`_!^d|H|7Upg`TO^y(e7EKWq_l@`(ST4{$jLiT{5X{M7dfIz3N9} zCBi*doprhj5KdB7<@m925S&9w8G@t2Hlkj|a)|myUyXjq&=n9Y(}(J@y6^Cc!(jvu z9vq4JNGuK5=S&4F&W_1%0Q%AnZ0(Dh>hi9+2)Qe3Mhh5px~>*!O`BwU?9ulOeCA-ORrz zVlN14wPo7%M6$Qz0X6(v8XwgwC?f)`YiianEBo>>=$2d3!`Es7yEOcvs~!HxEhS+z zkvhT&OC<7P6k)>WOt2|3_R5=BjLRJHexyU`Td#$m)fo&UAF*I!ZIU7S~j=Z`k5v zrd^O;e}M-edOdUO983;FuZ8G)Nhop(@rrdWPwB>tbB zom~SFVZ2A_-TU{==XcDrd$wFtu0e$HJw4nM7h8I8>JAauri8NzDW753V{RHmgQ0D% zB`De%6IBo8`_z7ZwNzIQ@ZZG_VMAk9_qw&_*#KhG2IkSAfBGy<3{$#Y+6O}!Uf4gF zgpn}qAF!T{4@NpJNlHb*zu2s6B_W(vA2D_7_)PMy`E6P$S**C)%MRb)-MK7JK2+-+ zbzdaZxt)2lb2=+Ong{UX{oSK$sXLVId!B)bN;R+k$&E)9JA9Fvm)vo&IL2R-|1$)2 zpDon1gmp*ouOT`a;lGxP6!@;Y`iK581^RVVcT11LzppJ?m}(VIgig{{+J26ATRNlc z@f@14`4ICg*!z+NJ{0gn8$wX7r3AOyr!reKDXAyu1+@JOcWKC+-)7A}aPBpaGNG68 z2ln#ed|_FF*<;=~VoSf8XYaO$W??NC=r}JO3WoQyslK3*7HwKXiC7YmI!rxv2TL7v zN3-Am_Ud>9@Ty0{BeS8M7OoK-WLBO6 z7$k(0eYs8AL=FO-mBBV31K$5FzZl+IAXH3Z8bsLx2K&@L2@UC#&MzU$;A(ba^v zBtJR{`4mFNlbeLZINVLCD`v!dfyJ==;|Ozu!KjbhgzklILUf(*+mAuntj)virYPW4 z<#!f_tHwwK^s!jfS*hp)G!=7j3I>x9xs%cDx_iLnX+SlyNjI|PUdy2%xRi*Cme356 zu0vJ};yYg_XmMHJKF4Z7BL9NKaC?b=GKEBBMbl_l9EixNPO4e8zB1-jqH`<;epwPC z4_D_JV_`*KK9{cV#dP`u5?n8{D zcfg(?AH!Nr|H(#Ob_UoK<5moG(7m)--KhiVW(FvwIE~-S;E^-9UqvnDwDYloQHPdR z&|y&;iGTeLVDtR{zX`V51nheK3HE`mDY+HQG<%@HL1%48(*x5EFyt;P|C;J)Z@ zGEsZ!>`C>}2m(Z;jYwUC(psIdh7dYf{Pa}Xj|5v9bA)X+efm&sC4d{O5$e61eTzBM zF(Wa0a}1Se6zKo&_>XSC1zG2>swGuFSyKkdfXv^nqv=)Ojwel%Oj{Ld2|>m4v}yct zQi35MH+5TYn|`Mvm2nar zJ2FZrC8B%l28h$7{evi2h^qh2lzsR1$?Joc;A)d09G?EnA{sw={qoflU7%Q0^TNId zM=aZtwkGdVOjol|w?)1U5LTfs$!cw}Is5GSg2I;kl4{4;!lpaA#-M**8Mi+3&{Rjs z5}k?LQqH(kXF`2Bt`}Zcaa)?GlR%?lJ|V5I|KT0?!(cCw$0GI@7hKdEhr7_iNCB->3CRAoL7T=F}0so;;5S~b(aDiwdWwHBS61# zUW0e}tS+YHFom)z!jCIvJ6R)+x2CmKaq8|j-RxsMA1jCrXl&{mjs{mz0))MGVNny8?hzEgsX`u0Rh z2&bfZ`{m2UX&rqz$~6)k;9X%=YuXI_h<;Ec)YE#i;OFM2x4H;*HWCD=$;ogef?*lx zE9W$QEOFhvm}U7DB7%$?p2JT)BXDe2mBM5VGKgx)r!sFGK^!TRZp9WrYVzXoXNmBn zFTSAR{P4)md&)Sd*jjHN2vg4TyfnAL?qWB-Z|z0g1KXgbrZ3#QlYnv;Mpnm@e(ec1 zkflwV{ZEGG(LamXY&6XOd5^sTT?d{n+85l~fM@YJqACE$Fm;I|b+7u~^Jx2z18~I$ z4}Kk4YEE>->5inks%&Hi`>dRSE88RX#Apr!DMekVu?XQ04#19ydJZtFj`kCEZYb|$ zN3~pPo0{Jl{%~fgC>%^KbtQoJ)cZLazAwu3AHA(n7<^o5@3EUt#i0k|$c1i=gc{L-6>Ws>|qZ5cF%-`0c+Y(1? zE?>fcqXlgpuc@hJxM7X0qm2nDYOk zNkkJiBz;L=TN+B0*|YO56`^!;`(aeKAt(oD*6DM+9l8b=E|J`qJ?~drLO6$~ zPMMWX4F_#iDe$!`@Q$QPvu;egRGSN@#g=n?oGJcHnMfmzXB;mjbBS7B>EvKpGAl>fEZ-aF z7<7r;_f>YCD$pNHV3NtiN!W6RDODxR=gWyKzy>T8fKIkADw^udR4RCyVySWjy1T*v zjeg!ogb$$uW6*&N`wpCyoX#F03t*qt3rYT=s%dsv2!sJO@ieEEuW%J1K9$aYxOdP~ zR)m_#+n8f>szPg^Yq00TCyttU<&)F@}VJ{=zI*5!x*fBZ5C`!cAg$|6= z(M~8`vWE3M;2|ns^+)K`O<1Q+Ae&RL8*y6}URJ&#!tf~31g97EulfQjVFY#)JI`wI z^PYg>#xA{=u*(PA_*7MN)^RZKrxJsCbR-CC1-yK&pQM(e-Fh#crJg?BDrG!R5pgTe z?52!I^1aiT^-z`xH0QlY1qSYm1qV}6DdUmoxz*j2LoKXN^bO+|OFotDKBW%X z4f8WO3cKr~ZTmChk(xiZdFQbv%d&v{ZJtIp63EyHrcWZ)=$t*V9_h{h*oaM;XN&BD z1F5YLR9(8Cyg`gOg>#9nUl=+(-P$owim0cBmPzGSWmz+J3sGQ-p)m44B`+5e zpBa%_a?ao-TQsUO+v`XK5RzcUTF?i58;YAyqL7odCMzN^itq%xZ2yiO5Fzet=PSwb zs3$VA!Nu;D9db&G7ZH`d=vc6YFwrO~wF`Gd-TkwodW9SiOfNc1Fp(^(cO?efR=|Tf z1X9$12Bl2>DgGi?AP!eC{Hb}N&kaQAwuqq2uR`G-BD zibDFenluf1Xpq-|@x$+*B4nB$0hJaMNQp#t_i4$k1i?^ zTPUe1&W`+>uK;L4z1%(-D#fY?d$AM5cqW1+%XEWZ0$WEN>qtNI@abZ%vU+xWj5d7J zxxujq%MZ{=_n+vTi-;?$a>kk>T&brLi}DweJ-TYI*}9?8IjXD-J_r4qVOch)X;nX? zaMvMYhd7bG`Z)fHK_eR6Gd38i$Q#GtQzKgN#!)qQQu`!-U~+CRq>DspA!v zOrfu4edM-Jp@}pKA^&u^G@PpFcC}+8*`}xi41+L6qQ_R0BgNs+U;Q&VBLC3|Pl^YI zr^t^{b2xO>DAAYcUAa>HwfP%DxR5eico)ZtciV1VYsZRBMHWGOV}-MR(n%3(uNfg( zz`bOl73Yz)fg4Y4#PS?Fs*&PR0%RD}oA%!AXvPMDrafkxsanIhqO@4m?cObs`Zc5Z zYc?y!&G%rhp%TYVI66ODN`mk9$C6zM)?UZ=6Svw^P{^i=K z_6j7Ju265b(_2LpcVDKW(*Bn6xqgybewEgHr8IKgC#_NemC-N6G+3G&dL(MHJ{M{m z>l6J%_TAOl*iTbd##?phCoL2@e=!$Nz3m0%CF7KtY4)bD8E~{KYMWC-Wd}BSE=G>pxkH(!`_% zFY26USV;THZN#V5JirATWJStT^lP&$rMG3HETt(-$VA9(E%Oyx)PAuEK!d5?{2+9j zs54?0^u##S{Zc<*j+t1X3lil=kulZhn1N^%()4`!j&km+(4Iv!j1_kd#WE+=K}=xv zPJW>AZurDY57f{rj8*CNESeBS`;L#wy#1666y9_jk6c6mXgX_6pF~N?7DCbOsX$BN zXd3}((}3SMNlLeomNrRDjko6(Qj=ZJVN)$PO)ob~PhTWKHMZYUylSAsGkJ(+;`sQz zxrOxONkFl<+L`x2O*5t*>|KE_eSa=rvG zs;bx7>kypNmkkRljg6y2*PJYy>meFu0~pn(ok}I7O4tDja}DP7P5^-qL@j%mwTppK=xw)HT$Ufu%0x~y zI5#ro6>j4GWKkJka?+-;X`0UKX*m`EgbDIN+ zdlE_7#4=b=D;c{_$Og-E@gsTnP8K-$Lto_9r2?6D#mhjKB4e|0&5XK1bko01?w=+D z<992*a8po^KnaI|ie*D?XR=T}Y>$(Jrv1+9l2bAgEmZo^+dU`@Z9uym zP^h-VaGqr~iWaZR@tQ*&PB2GOl_npMqq=h-GOD8Er9hERC1{N4(0_U;@`DqRE|3Ug zR=YV>YofC*;T}LSC97(o4Z=KWGKg?p%<4U$I&;w-&hdz{i}+AwsTCy%W5yYTykO3= zDi@D*I4>mjgS!Z$q^`ZB2@$L&nE36lew2KzPADNr**v??C)P)UG?YC zVD-(x0iwO`FUzXlCuh$^UgMUXL2awO@At|DIbo{vpt0uN=$uYPNg`q5L`v}n6Q9y2 zhoS2aw-iXBDi#ed2@F2ur_U*TIm12YId6v1)?n#s^BR~)Y{bmR0|z}+M7;`1nktmJ zfKE%B2pL>}CNGkP=&NtPzyB~qk<9de#Cn(y`e&DKmac2G`M-#T7WV=ji%mvarSp(e zq=ADuyTv##DPgJN=8MQ4NK?l&f58@grmvw1J!zbeeV#4*Xw*RELCG&tWC18~$0lV} zV4ble8PJ-JNJj@hU*dK|`vSH>;gMlQrjZ5#`XK|(( zYYf>xI~alYOg}uvhv8M-R3G94IJJ54lqLpiHpy0qWO;DE{~-A~`NzwD=I6f_xhABP z$J%ayq}*8US>Tn4C{l%1=TM+#3jHN?`L;xdBPiIr7o{{oZB`gZv64wm z(7BeF9bTky8ma|xAXPpA^5n$|RsOefUGJ5XJ)Ibee1c^&qTLW`@))+!2yw-LGs1py z`W%M0rF2sQlbM=al*z1wF0MG`Du}7I=3?x6xk((oNO9E<`tq!DNrDN3)}+Zn=bzDf zWtQ)5OT>Gzbd9RkKAv7fKU#8(j+DH1W@TCBFEED?zOn{D@i}Ndh{_0pH4!Tpfex8!#sjK!Ib}dIm_eGc=8_M>@?1NTpE)B zyWn;CN_3H@p?jHHi$oI=59+g;A|XpYLGFeghP|qc*fOsRR;6xtVkAt>QUe*YI7>lN zdtXG$G-|d^85X5Arc^8Q9UnK8KHSbV;pGeFQ(lZOTw>VW7qR{Mq`+R*a@j1ixDXFG@0=N%lpql*$)At3o2`VF zx+`7^L>obk9#(@hETS??89?0LCoZ5}}a-xNJBav>5#Fd69&`=e~C{{(l z7a`MyjFY&Im1{Z%5c3T3dIwMqK?kV9+}BN)IR1+ zZfeOy#)?bISAmIt=}!|oH1A{HQ!XLEnpSHMb{)1XW=6p+$VKy>4qRscjPz67)Z*%VV{A!o0xN*IA?yO@@6dE}^a>be40gPu=jHCzOfQ&EB< z!&k(Jv2$HL?FcBhGtsQ`y!SgrazV?$Sexe*^wahZV}(4e<`?oV<4g6 z5XTM^(H~fG_ZtOsgBukQu3Ov>Q#9iP#x~XUfz0rJ*9wSrhP6gFIFyJ5)cR4 zETaaCJ9)z!hZ`*u}c!rfh&M@u9XV6_rv9=MpPP{4hSArOWiwt9npJ%faWL)8-w zJ{}}LlqKxGMQUW}^&jGRyc!sl$a!c2Vmq%)-09F)3S2t$UF@ZghaLL5selo7A9=U= z>sarkbJQR?;lP4amJlgsPqnJa(MmH`gfwXYC!L+c#?D4YvQ$pGmpuBA=gYlp27P=i zD!R%k{Scb1O-2%^{;B|8T*nZYPR(Q~bwb|sZ}P?(aUc0(z@uokWE<%>jJ2C4~H zgG@SJ<4gF$_}PC}mn)?skb@8VC|MnZA3qkWif|#RU4Cp+xF?X`0LF?ru6p)&tS zUDW=ZoHrHP4QEJm($SV`0`Zgnozj^u60tDa~oC4KV=4~=qyqv?w65lak4qLhqG=w^f}jeE-=W9-&extYbemLt{cGxiIY zwz29kHca(#Xm~11AQYyw-KunCv__KYfM7_lE>pOAfRmV}$tt^Y69YGhOt`)Ghr{un zKAv~>84ylZghsB2+ugL=(cg7a|2Cs#9;iNf$4u{orZ7rRE%KI@!Hw86`Y5y7N_LSC zc|4bGSPYCNCiHl{n?^s;V_0x;zVW}rC%9`Q^*7=T1{e@`JW{`a@~F4c?l_XaY%#N_ zUY9lc42VegaJrfiRYQ9Fr)d3qYiy*E!WrlKemw?m;JM-BVj$5ORgO9B2Af3Ti;h`~ zl@GzW_sui}shL$1c8|j}=vz&Y+X3q?^i1OIV6tk{fOK<4miQww$R7qXXs;;4D!%XE zsb(e6nsGkK*0b98Fju7dR#7g7#gwpza4%L#S7}jn5~8YShuf)M%0K&DSJ&DAz1vA> zs?KO4p%!C91BEt9$XruiD(SYth)$o-Wi`+*VHN4v@LJh|9rn+2_Sr`Zk;Ad}lYhXy z+6kLM%6_F$`Z?1$(CP%JtPlPP;+O)9h8n67Egu!ZfXK;8+)?mfAG>P`fVl@2Phn2y4b zAd<||eoe?BHl7dy z`?NHr$aoRF8hq*$Mwd{FkL+Pdag2T5TX+!ZJ32_{I4D`ysW^x)pc`K@DWrVC2|g2n zfAPvs+#i%r}s8E^V-qccBk!BB2e`&Mc%#IC+m> zU=tFUl&B5~J05%vXQ>_M?%oB_i~=7~enh*iyMD!(GOwK(sUr5Y@s%fWU5qJnk(+Q$ za~7VG)_BDMu3>CrE>=_^#JF*pc0uUoy#zh_uvjPV(m~}EPZI`6E~>YyVqPE{(pCNJ z#oK04)+nm-gcPt#kyE+fya=uW4_yl;^T!z z+I_#%C^H1hdmMaIdGZzi_PhUbZ&Z29Qe@e}VLPZHRc+9|7IZ6!ejv7*CLq1ATe|>J z#+t;1<=&R$wm4bk)f8RYLOzgl)KX@`ygR-Ip`#cX)l@qnk3pRVzH6CLIl-&^9RG%x%;*k%x=lfmIyk?7G`+9VxIa-w-#C*y|)1>IUzXkbq6?HB5|F z2)qk%OpWd zUO8uH-7|x0OU2s{`La%#lBRU~$gcbGZg5E`M9(*<9_j9=%Q8)}%d!}waHLZ*V!_Je zxBbzW{X&NU)v*A=QDEW%RE3v@9Ym=*Wp~v}W3yz3z9F}rc98U|yd#8;)R6cE55Uhm z)iQH3Vv>RU)ddt5_#u7Vva@wTk>{?AY z=@xyL3c(gN$Qstiwr?#v(HfoB&b6Lbt?DWQ_31BM&sxR*ld&Rx5syfy6=2UO7f9*Q zmJB;*XO~DV;Z8^G*!>2QuQZaJOfn9J0z2YlB(cOs(PGdQE%-%+K4&S~a|ViiX{A7H z7`HG6k|i*1Jq^Z`fMi3LBYxg2dW*z)RP}4b9>Py7n=4^2(o=aJJI!MHNLfpQP&WY- z5~=G|hhx632sZ@Q5(CE`+1Mm!2dHg%JlySlQFw<|^lC~FIU7h+>BJs}uO+0|<8Xn{ z!8BXka5Bx)X?_+uo^)6O;!}&A9I#&|m{joxjA(-6`)pRg26>0^4+7!_HFt!{^Ex19 z89iB+yn!(cI#^*h9`&OSbi*;hwP_>`@l)C$8PJMuSFQIz-N!Hi(=Hr}G~tX>_{^`A zitD{3{yN;mvRXC!H<;_6INreGxrRA&)A@IBsj*0frA0nK>PnBuT#01kvV$43I(t~A zbGXSEM!v&T!8EI0l~NVSHVoWNscyY@OUoImxh|!zw8(l*`ma@v;O_FD$Daru?5@`<&jPPWd&!9@_AP<5J86>BxteU#2XKijQ zS1+KpF7jk=S)cvvyb9=<&BBc8_qKF#b%TY;JVFe{EP!@qu*`&%0TUuT`B&F91wX=g zWjKIqc&V!5Vxe{WaxTwv{7!Clj6#J8->atC2Zw=%I__Yrd*h;?5nww4mo*WV7*);FSH3hkVYKJNgbM>O(=fO z^m$OYZ6P3AY?3%OU~iMkBy_I`&#r+zS%PZ2{=B+ttuUa1xCXR>GErsBk0=UV7M+1@ znrFHr#@O7tRkTGf_LJuv^?x;miA5Bqh06S)zyrv|)!W2;@_DA-0r8ksw@2#%@@-YtKpm(=+kgVrf*_#D5)JLbl!i6*f?`s!n3N(L zx1H-f@{OurOh{Ax5_!)$Yy@sMDf?zl+umX8P=A}_vN(e_A^R-y2#W5)xSQ{8o321q zqH=78T8QLlu-zwZZqXX3V0#w%)!UYGoC6Tx@RnBP!T>01mg1u24Q;e+^u#JM#yDTD z2V{py4eU0TqF;8=YhAQ1m%1eUuu;W7B7-o#_GVRcfg$Ui;aJsb|;xtmk^2#5lbBRma^0P7up8?bT%14D@Lo7=Ne!YqB;B+y|Bc zg?x8_;L8@1YMGCUNij;+bulAK{_C0`dnUz2AJstrsB%h^eUuo#4xNHUh2S77Se5sr zR>_i1Nk(dvXIze615hZ-iHR3(; zYn@tA6VPS*huzSj6{j=KFYB_LRmsJyJkMq-@mh1%b23-Uz8PI_1LMN6GPKQP;}LQz>pI`YK;PO$HeL|LuFjXiw!(Z=B}I4sGLoShV4841DJm ziYz2upsI>|LKcah0CwUg51(KHYSCpHGIv)8P;*gMW>W5Ds|!4!=ZZ z2ZWn^Y|yN6K126WJ2s20S)^Ci?@^U2e9yX8N7AH&ZQl91&ETm`42g__#!%C6o=ULi!Z#MkL^)8?c5_L31u zUYd~MH|6GRPy-oBHWvWUTx0$*ABn-Zcc5s8%CkY))mWq5h9iBbJr5y@YIv*%60#r2 z@v{-At2>Te#9ZPGk)`SoL+k}~Xthz1ljK2H+iP~IN8_tE7?Hz_Gp$znj})3z@l4{u zfM(`hr(&}+!`-vW5Hp}Elqq_iW!0ICPf6$RA~3%*pbj{C2y;8|WZ&cE!UHc1oL;Es8b5*Z6GWDqbwHP&b>}A^;;e2?yKrGDL24~giwgO zsXGV6@cNikxB)1VNk`DqPfVkpRrx=&m7QJ>xYD{9Ns}E2GEWykYEYg<(MLch;@i$G zbJ-aU1dNL-f=AGV(>?+(iaQUw7T&!PZerNhB+y=TKIxNts0T923=9%&eT-W= zHMztar=f-s>y}1-8|HWMMuJiE^ym;C+}BsfTh#lWLvSiX;wVcs&Q+aWXc?ak;AU0Q8==Pr4S&Qd3u=`8oN6`eI} z3*8r1TjtL;boO9tIvYBAE}f+^Av&w}ZzG*;7_r$Bw$XJO(H|1;y(Ois#13erw8y-~ zT2b0KojtITug3WZim#MTU}|-P-&#)K^?c@~Xr(Gh0Or5Y=;A4-iW^Nk?(hHUK+3K1t324oRW7_Rts*n`#h4g%t0v$>7 z`FTE0Cz!A^ovzYievuNiXj)V(>wd_uVd_$YnsjEx;zK&m>nw#Mn$6RyT(3rXiZ0$C z(yQ}TM=9N9mLU$}ye`)mvWX%l_8jIDQMY9xZ`5Ik&${H5M$TreDnVGDDxb-K0^+H% z#Si%}`J{dW-#Md%fsrq6Iv%IvI-M1%MCo6q^*F63Wm%{76#frH5c(}fp!@HZ4z zE2ZSZCF!G`r+)=wxw;^I7Xwyg7x_N!eYo97;q{e-uh@Gi>U)dcaY!h{qP4AcT+X@1 zrKn(U#1)tTE(=+^yVm0|N_1(qg2Mx+Kf`-SEdHzq>avRQcn|6Hcy8BXt{$YBDsT zO*;KsI{h}KmB9Z%@hP_t+Y!f}&T`m*V_Zd;)HTK>@#Zrtg!Sc*c%j9{TrJa8Ew?Ap zn6z5Y=Ws02n#S#K2D8$-sAssXd1rTGX}R_q(sEHwjd@uin$#tXqC|MHac*VZ+D9$k zdIqccLdoD2Yi8jFq*e0b zaCo(MdT;Rg@1F;szk=3IPJV+9JQ)s8olf2TvpTgHF^~{kIw#rQzn|{?-?P&bRDkZ` zfBN_LzCYu~`o3B(3S0wLo%Y4ROk-wtY=i2nE==1Xxli~2M6jN^mTsq3#@7t z|N1j@_48M{65K?8`~Ld}dOco}6bUuq{%~$Jppfxp;6#x8Il(51IxM3*1sXVfob+;p zw$SG8^`J}PV(<#T!=$Se(2a9_81T7bHjRW1fr!iQAQ3J}b9Fj-iu$6<0>Jv5)gIk%Qe%8QWp9+$C!_oKl84Q%_%}^2 zv+*SbPj6G9AQi)1+?mBfO9OqqQeXIjcaa;}A{m>)KT;#%J| zOf{o0sS54S8V`7k1GVeG*z(sTBW@x(=2{-~wvQ9L^;+D-cmzaAM)~f3N`M^3&xQH6 zk!NV2d!kOh7s>xYd=wtMaJ$*z%_;z?;Xl2GoQ^xDB;N89i%n@!I()^@hYhO@oBt7s z!^pcO?2vU%`SUJ{OU^-spk_HjQPwC_W06>8VmYu)lbcJEgXS$v-#vl_YTA?M(1{Px zYUDcKJEC4RP>QVd#BOKbPR9U6?BAEO2IGuc3^g)7RdY=%kO zL4Lp#tEiWRJ3n8L%SN5gF^VZ4B(|#xYvkBR1#R&09YYMzK&cgs)x2$ZuHrL^F>sj7 z8{0+H;M)S`bm^qT*iS;u*7cnzRhgqB-K@v6*nEna7v>q}gi6*+Gzg$44p2vFYg0Ib z#{SeD&|#tC5?=&eyOH;?IxS9u!>B9*eiF8}Rm(NOiCWdRuxT>4!C70?5e=YpT@Q0V zEU^r@NfZc!d<{AT4U&`aTXWlaJL=Gn_~z;51{;J|!FCvuNXF)ih$JFqhHkD^IQHC; zjjb1B@w=jWQ?=pSMhS7uD55O2z1XdRCHitjrl%@-nDGiZ1c8>0oyqaf zmh33h9T^SRx<-BdF;L>J0MGLA&01072(Nj9MXM3Q^-zaj>*2G7J|2bfQgY_7L^bbD6xHawi&o`)`U}; ztu89N?GP58nO+sYIC+S&4gdL#{_}6AjA$5^v_dAuBfV#F^JKJnsICKH+nlcQNhh4n z!8VE5HUC(yeugi@DH)nR^vS=Nl-PyD`JhCf)3BxxW^T~d8oT*I+KLC1V=dS9a$O&j zm&vnwKm>J6&op&zVrf{Bf`T7mLd9O z>{bVU{l`LPa6;y+s>xwg$VMm>!J7&R8k&T>EJ4vb$Q!C&-VMqqBKeF9YKeP$$-yB` zBPqG*uf4qnq+$B@1WEzZWA=q5Shsf#T7bAl_U23VdNBJhC&{9uxh8+R0s$ZiMShI9 zPAEwMQC)fhK26X4=7S>VDjZ|a?rw!0R;d~^&=|`1-1#0bMjsq?mng{5?B%<3Y`0i&O*Og@;3;i zsxnR^En2C{2gqdu*=(iaii;8E)FAYWJrM>iyQNu++;0hm&D&qeWL3`N8_e2MyqDrv z25tf`ZbWXr?Vof zxQwas#(323lR>fgTu%6hdfBtSe@T$OrD!JYp8S>)pvEb?W!n#WPwwm+KFF(LNl6Yx z`@o2HKM#k!JBCB3)`h4tC;hunn^93FUkf5^+<(L=|{^|{yy-utm@EXfv@$l zdb`S{)1>+0l>>lgzWXVFNyeJV>+@V;S~&oR6kzrA_`S4i(ZwLxXpv#mbM&=NI=M3? z2R6!q5K63vR4L-)hQyCd#6k|pS6N0zk}j>XB^e`da*%wwvEFfq2jbr}g!hcab>Q}NSIy`4clJhfu-wAA&v$kx6kUDe+olnGR0YxwimG$EsgNLv zk)qU~EDXcJ#G2-qoYy@{mg&5wT<(Tx;?Rq_q=4+%di3EHC1dQC&XEXtBMpDA;4)bi0UF5E_Gxf?fLCa=wcj3+mOWPo4msgzQQ%OMt*L}HH zOj7tS^7rs3Iim5eAkqR<(1$-zES7VEW#JLfQ}aphOGWR-luP;O!#n5-T!@(Qx`5Gy z*RfGf&Bo)G6Xk|ZV`~tw^N(<;+hdN3))a=TO5fJ>{->mBQipZ8tFJf769|R53ZctC zW+RMfMfh=Zuk@1`dLSbRzMN1DI3gXcDX@tiD4BQw|~Sc#w%%TyGoM>t1oT$ zNA!@XiIGx8vwLcVMaCpjHI%|c^5~(;OQN&!P-aP))0x+=3k%rOaTOJYaW&LDK`pTG zeVyi%g@$t3_FH8VGY9*g^K_u$Y`7~x2|++>NVsOsd!Hu)WiieY6o1QU*-p3U2UP@B>u9sdR#O_NlBapFEDqBOueKJxsxsUo> zjg!zuG1McySr6T#ta4N$qgu?6$Y}ORWIetBQgOTc9wlqMRB+#Eu{v~|pg@Qqg!!zn zTHFz)RMmAjhA+&hg;tW_?1@?4)7<Z^-v%7d|OY+cGykzZO{>7lUf!vIp3< zx4|`%VV|!#A8E4>QP(JmQl3oiW&CYe9Zq8&MY5JY2i(Jz{cvMRaxcZpJ?X>~d1zWu zF1x*3`@uvwsQ^3Aq9b<M78 z4ay1=$4Qj@jAB1M+tY@1B8bw>IMH<`6=deN`Ufj=(Sc*CZTq}*Nk>RKY^xxEh7!?jpgFy7RRaE=( z3fe+zOBzfJ|N8=DjPo+zAu9|4l;qtjM(CV8z*cx?)j7q;_fDPL%gXS zECk!-AnG1qU4RRzSnG%K7A>av3O1i$JAkPx$Uwg$!*RLDLo}B#ntevw=6ysW*NFO$ zP#Qw%ve}O>dHEu#E-#Yv^~IND%_=IW2YQAbCNg(<(P?t(K_t3$wi>^Das2B~Kddi= zO8Br<#GTd_H0rrG$OIJD70>s?d<88)ASdt5t^J@HWczL1qs)#<_Y(T|a8qe^DG9kg zxg`x+XfUNp>EB=FFtFU@O4mSEF&inb!-ghpLIXo`}? z7K#mWdGr%|Z5Rt+Z59(yc}L~Jq!8*E{QD?P9;eAZVrm|dsvx=}H`V=QGwOpudkrV=dx@GZ6`(oXJt6qS z78R0HMx?rUFh^^M2zJ?2DKNH9!q|?E6nG)B0>zMV$Zuw+sE$!JzIsPI3#n&zYy3CT@Ge7-?iHS~7v_O-AI zH0$@EK(qd4vqr(wEJU~cO}l%2ORa;cc?dQgKJ_go=bgBX<1-Z3gts!pNR1|RdjvOZ zHZ$^-HS`PURr8`LlA?B8@I$zaeG;<-=wb<6mZ4p>BP_-itb$dpgh!BQ%`T zx7qz!0b4dhB&LU(vI%hI4Zhj(oGFG(PH7l!id=DBD{#E1vK@yE$9=QCKWA+o{_o8ic~D``HgLIrnHXVB zPfPoOF2C7=aI^m?5dwHQ664I* zA|;_HkMkK$N_V*jw*%0=9T7V2 zW#n4=O30gN!-jUz!LBDC#UmAOftEiT5}rg1Eak#4P}rmA2x{VoC@&EkO9Z}Y0Ve_y zOhlXA4k`n?jDfR@7$k$h%W%@L$rEMr1kk+_CI36W_H|p(+i?!;+Z@G| zt7$HjIY7sYN~RW2IuVlcj4w$(!h68bhx_AFdUYO{Ib5Z4|Bzo>9@3^Stod9U)}3=C zk7ypypo@1{o5-crSmw>Tp5^f(N;&422pz$?jd@AyZR_oAN;ggiBNh-rTg|V78;ZAy zL*O{ob|^U_telhe6Uqjh{BEn!bR7hnd;tw7fk(33V`=&aE(7|CnKR#_+(nEFZaX}y zIc!`NyJE%yz=(nBhX>sj?QDi7<_2D+5TVt4fyiGEgcGFveGrxH*kelgstdR6DBqzP zi`%Moe_+0G;p0VB)0>MJD~Ma19QXGq|5}r5B3AQxnb?kw43`MJs93>AZl#YE8=Y=+ z_89I;f~Nps2q&W!5hu__wQ)Bv1OjSL>tbo;1>J&Wcdh~)94$c`=7cDpmmg>nIkt$@ zWglC3;`2vb0sQySfAMnhBW+r;>(LMFK#Q)5k{*Szy3b!rEQQOjKF z!0RJk12%vKT7YcamZmw5OuVH{&4%H<4E?{A(`_IHlbjEG;){jMhyd>dSeOQku=mK0 zDBSa7mhCXoywYjSxC}Xs5l$0lhj?%*H0Rcb8MbPaI*_H5y3B%;fUVH6E0DxXj)^MN zqtY-I_Q0&qyqN5&FZ;#S$-Y<>QeWIL$?p{v$FZ4h=@ELn)GqhnG_aA(svme&KL}PG zVQ8C&9L>wS5-5DZgZ^^Tz)1v;burn6q|^hbM=5{x$tz-Nef_DhU2 zf@=uG_e&|XEN$h1z4Y`AF#q^(-|M}z+*l~O;Imjz?RLw4Taqux{pFq&lp^N+NzxJP zb~N0@tO5GfJxbz;<`CLP#K;64?I^Yty$O{d5s806;S=NRM&*iK4#zU0mhIclJ!AD! z?=S3;*xRR#_r1H^YMq@Mh?odVf$d^``*>?gKaA>cg!YnAPzOOe$?nj){Na{xc3bJ} ztbT1)!b|iv-%Y`-NYHcTxp1D>S9!kRm}nhd&+)O1KAFQ^-@zd@JKjRNX$TZ+A{+ri ztwMPnt==qHbKL_WL%BJ=U%N1z31@@QOK(z89%wx~Cu zsjzh?ZstxES!>tc1hm!N z7Po;23XQM>(Hmm8+vRWT>;s5$)8Ycv!pl`ru8R7)*H8X|_^Qd(DqAk$g|S2EqiNFy zH1-GXCj>qtSDIN4%-|}#WAtj=e%k~SdYB~9C20ceA*?^4IAxp6>u-D_Z`Ei1pp?+N z$mTt(&Y}L)jbzMP)7nY%m4+WE}jZCqK5;6F9kgT~&4L+KV7`M*@t zY+PO?&)>YF`zNcNipWEZ%9o2hn+nby>T^oEDgR=c&!I9mtQ|84-ldg@6$s{Kqb7M7fdA;1ivsm0$ajERGKrn8JK!YT%n9*G|jR2iEFa#fp)YWmiqc9Z6dUb6|B_M?x3dPwjy_068Ft8~H%f@i%3J+pk|NAv7=tj3XwuO{dcC{&3KXy7}0dN3UYjste!c zJUWU-(i3St-%MH`A{{;VN$YtdX_dWv#?I*ZicG;&f5ix54^Kl_5SmkAICMOu;m|m{ z@&F-!xaD{4sJi>Th5oex_^XjRjaqXiBMpP*^rj8`LNu;+n-KWeOm2PIH3xX8$(3Q+ zcvyKHa8fC&fw|ci<<$oGC|eunG&;{#AD}P^2dsSnDl^XN439_!|5>0RD<4PNkUmmA zZrKL^EnClL9>;U$L6W*W0R%njQZ=aAWnxG3rwocu? zeiBZJ)CrLuH%;~qdWu-GC$2q30}j{*sdYqO#%h&0P^F@Tsj!h5RkcC8&Vo@_O4>&_ zOZ$&8q;QrqhG9sRs$9$*eYb~%7S<$)oI@eK1ok>$0Nh3w^&!8GZD6}F)xIH#aEm+MI_*p89WfFbb)|kP9ZcU#66( z(e$~FXIK;jS2St32QU1ToSa$F@^JQ!8|7m$2whkeBrZYWTU$v26R^=wvr6oZDu$VX z^~o7>->DbUGwPLm(6w$f>NZ_yK}57_y0cF6^NaWyOVwmZ4prUh#a+(@ zXQ{fT^S9U+ZlmiZCx&TW2PK|k;kLcuio-oIcL}>)5r0~7BFPA5OXYFI?p+!8=#<|! zu(IYD%!_loaIDss2#r)aZpma$Fd5OvGCqI^Jx+TaW zCbZkpYkbQgZ`!I}Io|z@M74QcjI|lTKeOWBdBbX(4K7r6tYQJY^3U~r*6D2$&m~{U zpS*wdOXqf)2R&Nq^vvQov6tBbGJNYH)R5#Cm z>+uRh#m~ea@&!EHT`xh_$&FoVPe;$V;_zNpsmcf*Ro*?#os=D&UN5Kl0$Ss$>AX6v zwZo#@JP4<$KWh|?h;xlEnd)N!D!I}k2%Ehy-3HQ$H_7n**}b;q=2#6}{{X-xeKucX5}Rn7kHlrS-_k%rfttrm?q>Y9&4$eY)#0nVTCefJ=#}YYGjn4oa33)_5S1c$#A0(UcR9`NjU&|7%PZWxTD}fHarBu)4 zg2?*)aep&*EJfFmxFtmSQ8_CYhNLgGX338fuawP~vpn5culNe>pyYB|jE{!9pFZKn zNp5b)6_rvp;JX36gg5XQLF5`Y`sRDnznYyub>6%U?Z6KF>f7(W`>$jICw5YPB-Q7l zQzy*eCG$0!dl{n_wnLTI$z_qncPo130%w^N^Lail;45?xA@D4z2qHUO;osiUAKGM} z;#UlvXzW`IXzezPS0otUw6iWext&7t2+`JK2h)y z48hMD56)}Qq*S~*Y&i7B_oVbr9d7^Jkiby9gbCPWNYndJj-Xn>*g$& z*6NIrACN@gpCXq;7O)(6gv81zQI@$sO^rT>3K8ck_(6g3Ko75ETxe-!u% z6i7_bS`_izU~GMl*a;@4Kjn`{lP%s)*ThJ2r4@l!K_6DxwK5gQE52G4wE;55^9OCs ziVwM{oB+u*q}i+-0Z$1lRbU^QI*kzI1%k;k!UH|5v$$peR%T!GiowwAP58NSc$c34t{e?7$FW2>nsQr`?g{0b&Xw$j06_V*3 zg99lnkQ1I(qO$kI-N51v#DgSxL^bQJwu>G)Cs^evOyxja5crP>6N9g)iAXgR)2gW@ zowW1vV+Se|b;(EO2De&$?ANNpWp&l7Y+RH^z4UwAN}Ullf4uLQz3l|!L_&NdCfCP< zTJHqt>|CT1QkRZTY3KG9i!rdxG37WW?N}T@2W5s5!%46xhm*{WFcN+mXx*+kE3h6vz~)^3$9O5N3ki8N?FOr#X4MNu9cTnD5IvOMA&23N16BUA)sSWMcx>Fj zk{WEF-sZYEU=-I|r&weH+YcO1K1ELZ>2;a+V0uBHL6^vs>o4T*Ga*r^?1EBajE{ z6d1diwhhoElSl(6;qAoGoS4zvYHZ=u3<$@d`x8VI6qpR6l&3ieF7$&w`Fj)9Ph^H~ z72+M=O9w6YlDDVD=L(7_wyC`xb71TkzO-6ymxG4wvi%xt+y?SO4ef!=%XZLi*&g;e z93Z|x558=H9&Eor_{l)5kV);^ttLQRd0R8AGLMHcvXY zL5nsN@{IA><_3j8Cn{>~qZ!yqo*uyqlW>)ygg(g%Fh)#S8VNL&;LkF{kqN?SbBF`) z34MQv9KWbwJ!7%`!z`=N>yh;^%=J?_o$wls7I@EsEa$MB@T4CSI8CiB=`jSn1HsIk zRR(!bHE72LY$hP7sQygr`Rq&jqaBpKpf@;++8S%F1x?|A|G9IZj#dEk83!_;|Jti_ zo>d}~fK{=Xtr(9^YP5)}Igo#-7rKK3<8Sr45GmCL>M!G!PInwgb3E62{ek&I74UN) zM{^$+)jN&~AB)zEpQ_M>omY3@K2QbO7yrNW>k7*(j@8dQ2VF5eJ$tr`N)^(2v+Av| zU>KcIZ>@ScM+!NeQL+^4Wlw0@q>TMjnaxlQfXpJ2@_F&^e1(arXCLU93Qf_uk$_mh zYUjDA0Y!Ag)E(7HwLag&HyBcr)ueq{u2*RD;Ymo7qM!Fs{f|+N6Hx&+gK_or%>tOc z75q0JSEvaA5q@zY5-7_qBTh|nmCHuqb9BL%O{e$@mUdu$1FZJXC3<5+={XDWnBAhz zFmE&l<51&QnC&D1s(B&$09{bBvmlkggyz+h)1XTy;5lJY!E6In-Q#rPhvGY6)zC+N zmXqnL`cN!o7iio|v_=rXjnK}Aq;0t_lszscXLH882B1P?SFu;1yJJ+sVZCEf{I%kJ zLc0)Z)A`5E=kW2OG@+L##j2_a%V)se;Mt60qGY@Z<(5}R8cJ{=XVFcDuRCXmchAs{4cQo4wP>R*^>w?UH)v9&2)mFk*IrS>AFfUT5o%2XkR2sC-h^W{nTAUlA0!*KcmO^Q!FMWWim@yCNwG-MHEA4JT`_9 zc!@U1a_q9eY2tSJ45m#%x0O=~in}_f8S7K3({(KYn|Kd6U&0|0!?2p1WW|in;Iypa z+|9}ic~@UaAKJBI(Ah;VU=)$>*gi&~NwHEIX~c~)IfdDb0U>TuR)uVR)SL?(7q|II z$wKCaus(N<8P0i&Bs9>ew8XZGMKo9&Z=0w^YezOfp?Pz3V9b#Pf7WWAloW;%MyMLJ zH`2?XXNECzR4DE~vqSHjXRqxHZsBrt(?m9yG%hFwSW%JpfpfPs(+5>T^q0s!{6wU; zP_(BmDj}6ctMTIiG~h>ykDv?#Kr#Nc&Sq$B;q)w;^rxsM5~2JAOQvJsrygbx@+U}! zD37D4gkT4gH!5=(`vt*!;E|@tLEvSLn38A$axs9`^;KS6OzER@V4Nm}Fsu|9j(?ul z==f4jCO86WG@D&zK--yRU=0^A7yYK$jgTQXBa&ZiryDFtD@v|$7JayHKukXDH80~k zPN*9co;MM?up^vbxqk%0G$Vky`6tuV5MSZaR&|i@FzoEmYedEW&!>XHkp(HCCKk8% zcd~hsCZhAeXG(OCRKWkn-Y+-tiXZwFyD7awu2HVBeMcOxC8f%=csX8vGo}$v8+lMG zGp4j)dS_Nlf9N>NO{HpM6C}E@2q3(bF!Xt!7S#{yVphLgxO|YTC`-<#iZz^n(2H#pj8u@PT&onJiu|F3S%&S8LXF zc=wJjRuw23zs>5YX#eEt-v7<^{(W}mlo$qnIgrDE3pR;^Y!vkF zBU>`w03&3WlXB95*J$tIQk_$KjymtN^Nu@Dofr78evIAt{@~z&=mxZ2CBGlz44!8z z?gRbuyCA0dq?2G5dG$Lgt2gRClr@WbsPd@1QK?Y!p&dQXEs5jCE3GJj{bx$gUCf{&?LiXBO4#? z7867DKC*laj1C^6--G}}5w;7OiD!I0eA1dk0J>q8t)>NT z<3M40$*mFK%MKur5grkmk2-N6Fm`cyfu*VsRAo$i%=HpzXi|;{AJF?Xfj! zF9+JT@(^dOuL-%wdLj|y0xXg{xO+T0GeYU?0FQWT_?a5Rkgv9tVV!B`W{2UXDGKT~ z&EMEoCTj&h>6YxbMiAlwC0DpH>o=keigFWy6w<+vMbjQW3KjLoUr>&$7- z>`i0V9=jWMyN8WHXlh%EnRbmS{$r!Xj$(s*pKdx~A(PUU_KS+sm&)qG^#Si{pbBu& z{ybY6(J8t=@}s~Q;7;oG|0s(^x07~wE`w9a_QY3kmzHDXy%AN z6dik^aY~M)9I?gcC?kwA;Yhck3pxvx5-l9)9&_RPF(eZX(>BKb`EzhQaaqgiRh%fO zwN;yi?}MIkEQ2%ggwi93kKJ7%TnPqtFVq=ECXme#9HTckgztuvL}mh}*qzRy`v!K} zE1Sa!6e1gy2Z2aY1hcYSQY4n%&SA_o6XXP2I)P%R5j~aLDIl-jr?L2QWGD9N7LTdv zrNr0N1Nb^HmaKfc-8KvdG+@EVapj)EX+vVf1k-`{cD+aOJF*W52Q4kLX^OB7XG0pt^ zxmA+WI4Z)1-C%1)!^y013lxiF6BVOS3O-kUTb}-i`o$XHKs_V98DOdyy^C$%jrN#V zXbY~^tK1L-DO5!Yf`pX@G7mb&2#FBW!cg!p4wJV|z+UTY)aEXmC7XT!ZO+uZ1KjF2 zQ()Xz{cO3MU3VGF21Kki;WYLHi*MF92;MNE9b~lJZD_jJzHPUCebK~DLyP+-_UWME za%^)Sj!3T?=7DcKR>tG$obBt!Od6_^x!S%GIg|HerIHwMgqWp8t1Mm1H{TqP6Iq8d z^>)OiVM>8A>g(BbRbrambzM#{bZkN(vlHlpQ6qMOr5aX$2&W4&V@l1W48-d9l?I2j z7E*Xdvqqn?1;3ee8PoIYuidyXQwAa0fP@z2k0+1LoFIu`f6aWPtNn;L&*%!A8(xsM zU$dFSop`yRw$tR`zRkgLu^6K)hAE~4WNK?9_+gmcmGgI$SXcX@Q%1mHO3kQUMjyY10%t7z{WwQmEVJBU+c(hq^mkcI7pPt2$pO5zO{;73u4IFW1(w<><~DyVNiq z^v(l9XNI<u2YoE_IAP>3G>rw5#q53(CxTz*vq?1e^t`lE_%pY5O_C zyOGbD`o5Ezdr7lBH>O|l^PtZ%riC`b04Vs5{;QRkvoiZIfE`gTZTDF`D8iEu5A*)r zyUE{2=u@8D-A@dL(wKMk(EPURJ6e(zV_H=GQaMA5zYe`3xSb8xNcsuFCJy(Pf-Dgx>v`g#?K0ZVl~i@e&bwlrtUT^^m+aWUGU%gWH75?1!vOouqm|+1 zm>>nbcfxyxJbQjz1Y~0>h3*1JF=qwQTXRqH@#%^S*t~nmOS_v@K?h-}1}5uueih#4 zwx{mLLY$kBLF)IpB~d`??P{K3#25}jui@qj^GeeGN&Q_s=bqpdy@PG{!ML8pC=ZSS<~M=1G%vEuM{^VnQ3DotNYh4vLuIz|HV zO(GrB0+15G%428b8w>QgrSXQWV$7@sI;UX^oa=|z%g+XO7(+MX%q}9k5*}cR^EW?_ z!H|jGiQBpx8ER02MMwy+^nnmn3WvttksCjH@*C?|EaU}%z;ElNm&h?XSzlbUkx-&i z^DJ2f`64*W&Kkk|o*Qm>^6&oHSy3HR500?|B)o8(NO=0`=opp`X8YVCXHSF_wCpRijK7TNZUj1=ZJfaq7W) z@}V_&Zqz=-GeNOBg)W>xL1XwIMBHOkp{*)Zy=zmgD%`SiJtb{w*QFztdTag=$pS%{ zYDq+B8Hc+>{q`s{akz`Aw~bY<`o}Nc|Ksi1vp27g--9gcB9Hs^tn!S+t_>Bwd-3$y z`lAHE;O(71H2$`6M{lSsw4%FE82-bkZ=oA6wNy7e!-Dub%$T z4=-eW-W16}#%D>E2pnw$<)`>m8Rw=VY0GsTj!_KC3O*n224+A@$Eb^ziKXDwikkrh zM(LP$o|D#D(p`eE_nsXGUB7elVFQ?Ln1zk@Nvx z!ec>QIBC($@tCejwCN?zro^~y9*o99i(f$?cILd+CK zOsorsk$xL>Dwpf3%}6*L*$r|FQw#YyDM!wrpPewfGBTjujH<~krfXmN>UBT=xQrQb zLjL4fo;Jl3W23-Syw6t%Yx3gb(kROT#aMh`m)?5fw%LHD(XhE^fm-QyfEgmBPI2Oe zu2?FnSxzE7S0AZN6h! zJ6O#FyP5|L)jV*j*~U=p^I*PG%_%1InNh?B^S!BeHOuS-^TAp-SPZTh7R3cCrp2Jw zn61w++w$=j5XM>yh9NAKvZL_v2?8ABJxU0}MxeWlrC~3$AQtd&_c+g!X1@;Wjrgym5m>&@>zc|etZ3RLQG^j$u~*h5VadIm*s zs_5MGI+1(P(dycyKq!AZpE{;oXP9RRX{R542Pa7)u28VntWz;Aq4X{)as(@wlfu4WdR<{i-mq$=0t3cQ+YNTqkhG&xs;&~=HP!};RIbKK zj3oUsfzso7H_&+)Cw#bDR6t0)>@FLOGrBua{lJcS(KHjEN0&#aX{jc$_3&KC15z~s z`!l)Lo(~NgTiH|h6IR!TyQY&4In&{0BCw}|-VQ9T3Znrl{bl2RMSwIso|U&5;90cM zaXF_(BJJ|WjqS1@qwvLa8xKZ->DH}Ab%dMzP6BalJV+eh_TrX}nO_U*M&pPHVv2() zji)57;%+0jvJue9F{gcZ?drAxS3Eh!529Vi5;l3!wKR9Np&#@LEw?SF>{x$56x^=E z6@G)=(VUFHX?OZW&!W9yl*&)!xMt4=y)iu6M%iq3o{c^XY*#ogCSOuX4G|J7t6!7W zEjlm<*~`^gS@yMncFD^skJ6jxqoX#!i?MEcz{-OT&FO3b08w(gfVFO${hl+QwE?saR8jYsR+`);GjUIt(x~o;Zc7 zupJ2Kv6~JOmCh5?F+gcgY^iseRqxh|x|sW3dUUYUggt#zvYd#bcHFc9HiccjWKjDSy^sAlRlCOhk#qyqE#e!`4()e9-3EqFAoUW`t<4 z{lMou+Z79k&`^P3XK+v%*)>a6VjQD#O_?3DRqa({k9TM1B3J(BsUehah<-9^35?WQ z;Ru462;TmLGw86ha$?m%7gWC7n zWBYnz`dDfm{utOzt30hwsf;W=@M7G>8)MKtzai~ZPR*&GgJ|S}9Y@epW~!SO*PK9w z5AO+`JIe}8$J_6;vq=RXyVGsjl~tU@(FEJOm6D8wFbB_%;3`l7K`yrFp+Qf2ah+D@ zrOn=$av)vLLcf$z)+~4-AVq}*8S|EYN(j|TU$Due@ zC+5FJq@2s_S0;~dp+TKrCu0Vov7`;+rbZ&G7(4_arbaYhR1~sde>N+xD&8p}5rLtW zSgf)tu1iMAhRbt={2=9>tvL0I@M|`^w)} zq-}*iiqw!Iy)Qc`<{D=hGl(g+l`x`G$~Ejj?Gc*y+=$8}xD>qWe#CM7gR|#K?Y-lR zVnW-|B=q_?pzfx4dGhL?5j-Y+77lusx>PJ;2$nLd2ED@T;M^n-?0&g#-&vX5YrBS8m%D+AQ1~Yggpz7{PiHyCFl7c#ml+ESWaLDeXRcc1ChXaP zvk$*ZafR=HYdn7c=J}feA5-)WfMuAhSJX=he?LZI#42ix(1m5b{x|NxLMUWB6irmt zVGz0^CrnKU!FQ3{QMNGLHO%!jxhC12uPh;P$34}7%S*UiJZR}P@*v_hqTXvA65gGG zr+CHZXyiSXkKUIbkh8Z5jpH5ipurs_K)Zt6@fJQQh9k@a*riPk^LB2RjmMa5ReO`G zi)HRt2afJSsKTekW+gr(g^kFg@71oR$V#*0T;2NG_Pw|a)!X1~-952Xbw-aR$d7`Q za+i%5YQhP?*~GM#i6we?+nJ!CWhh68GR_s4<3|=35TjyrCcX3RHDXL%ci)?g#d<_kL zv~zc!(AbzJcTQV*_=&vYW}U5^{!+WUxbbkeHW?GXC}7NKF9J58=`ziW@iR=O>6p>c zJSG9RYgr9!zwrgBAOqHH^+9`UbubdmccD>>W-m}oSJAbdK_($jr&!e58pNgv$Wvny z<_GF$6xgIyU5x>xzUS?sWiP$VR~6xIe7pt*iC85GO~7nI$!UfAcPujus~73xxAg6i zu`Sek1FfW*2TYv(d*G92*ftDIFiO^{2nmf9EToN|SbCtzLj7s>$r`Xn1wyewE}2_z+L* zsvCQ?(T~V486)?^!I!H!M%$2FiU9{=uwt&m2QA_ib#~Be0`^G{V2ec2d*J>3@cT%1 z-GH}X*V-7qCkz5!3SSt-wD{xiHDft>Uo_1ZI`P%7-7nN;NP|-u@Dscr(zer5>CG?3 z``SgL3L!nJ-RS6qY?kuupgS@-NFU%aI*qPxo>xGqV#Dz$8g?0lJL_9w5aHIAQnWhb zlvTbjD!7l}9KjDofrEhneGJ#$Rnq#w9>Wie^Lz6uB*iqlZ&v!S~Ug&8hDj$P-QO&^stUgBAOq0n{a zj=1uBF5kA6%G|kurbohK7_qeiYx+*(H^H#BxTSGwWE~V4(7`{0rfxw@toa zG!&L1zk2xH_kT;1ufBQk?RVA*i0-5?cSWp=a!MTz*AMPL_-_9q1x{cnesy|of$yyX z-**g5Q#QC(WR1NlS7Qs!4p}YoK_P3Y=F?y@(I|`-NDK^Oz-yU<2w1&xlHx~owixAT zyIl~!hF2-ML-0i^j@z_2FF=m{Z*HE_pCK~eyZi#f9I4aiMpo!bH;*G3f<5G3R)QKH|?f@NQK*k_2X&&Xq!+(0G^s5&cSg@=fEHdBAgjw*4GW6(O ztFrB388$I+y1h>K$>8KSs{WLk?f33>J`Z>4F_Av~e7O7hcY6N2{djn1IQ#^^ZUQfV z4}S9d{>7o8V;T|5c@9z{VTBm|ro)q%UiXT6@P{ujRZztaVdM#FOQ@L#SwlKPl56!h z8-bP#IXKWrvltvmon&PVk68Z4#Y!eY;SYNa$spw2Y^Ng^iIJk2s6{4`Xle_RjtF!` z)NBTSHdU@BhDS_V296bNXiY7SOv{MjQm zBkC+YKDo~jP@S*Z4MOanx7i9luk)2g{Wk^>$OGj@5dUSPEf?+fmo+Skq52OPK#QLK z2h8`)Epk1#&R)%&eI$EzG`X`)&g_KMz9;>LOwJ8jy9Xh%Ype;CHiNJDbKo1~gm2Wv z85@$qzRiz$wOpAB?!F}jpF?@YC|Xxy>gj3(bNC9mD0W4mO8Rqr&~^C&FOh-%_Uo_p z$LNjnw6@-J$_7GYVsqi0P5>Mq7<_gvqI0mdvTov;!>JyzaqV|Zp_>tv0jI6P~5So@axWj}WD+=O~_SB~@$FP$qnt(qQ z&<%WXF~G(xYEhU1swVm53o3iCMP-5cG^#Detlzm_ZkS!%&dkjw^o=kb(6MnhDhMS$ z@j-U^NA0tMN6T=%=WYNsKC^JoJo-bzOwtW;E#i0-z~|12u~9h>4tB9a=~bit79X_U ziL*KFmefl2LE@~ki(CN4K*#X^A@~;_9{<b`*c7`$kaWxRfG3qBxRAy(oOe&gcQNN_dsL#?#VScp5^hBCq?Ugq>G^aSR*mcr zhpQ(r(0vDJ7~?}Nw+n5yGZJcqxMOOjfh*>!?;UYLV1lJv*geN=&tPv@`0)`>L=%7h z2WFQ8R*u%=5Pm+w-}l7&ps^1o=rOkrucOR5whA97_wk!QuxWEZQ7^BcXNX}`lE9>T zv;BbsHXH<(d4|?d!d-j_0})QCqL^qNx8>)=q?A01f1LKha*|y5Uxe#jBFnqZ-ToZl z{wf*-R7A;vL6P^v3af3>X)LpGB32Q`Cf0S&=vvQPe{UF6jzK~7S|(4-@$FGV11hk` z%|+`pRt0|1tm1yL76NMPnGb)%hq5ERmZ?WAkqx#~``jqMah8R8N5|NbAj+AvY-aR0i3Es zXO27ebrSYR6+d$3Iz3juYDjAv=C~jX_26Bf!uB*sJ_;zvp6i5 z($!Z@+>7#vGnklB*hfinFe^7Ki(BDC@d`=p^s)&6f2ZT5_;X4`>e}-u`+~Ws`g_2Uhwsbb7x@Z!EwCFr`aA zuafI>O{P!-;RhypoXrqX;CzjU0_7z6b)EPBV9U=U>4c>iZD?Fv7OQeGSFyp*I6yWz zMnFjnUVU56iqSPkdP*s^N{mtTH#YJfdTK!#bf=G9q2Tz9 z^{?_-_EACDi~g2uF*bXO5xO8N>~RvwLGw%pCC!pVJz zHiV(oRVKiER?JavRry}}Vz2o{k@0b{w+!b;@y2J_u{*I0?kXpUEYp}ZMl8FZzDfjv zAIU#`!qz(s&lQztKXoSV`*pFb{wx~9A`ADf&-J4Y+IbXD3NGuAi&3uY<+?s5f$g0m zuKV1T-3UlVFJPJtU&MR^Gbto?GVdmOzstEDNV(dO)T@gY>JRgOzFe%AF7Hd(xR25? z-A!>Wb6e)SnP6@)?Am~LYdLavZEPP=8;fMmRA`v7C&asMAUjwlK5sXzg2h#5@nl%r z7a#n^o0pmhZ(Ze+R4nDz!-4*ZJ7H5VpiQSA+xMc8psO@gd~0~PtF|KM(~ZZDO%@mg z#)QX9eTrg`xQLE?u38LTBJdbB^}JgAEUW5!H|t3dc_(%)ggE_ZM{XiC-qpcrTHkl4 z8`%fpnM9B{Q*=RF2sD~i&iV4r*B8ud7<>q@Gx==N_p+Q-wZJPKajI8fIWO~Bxg=g` zUFH9q3@^D|@3_|yX5Ee5M{w4S*=|1Rf@=Pl(M=4SRUxi8ypE!uanfZp+C<%)y>ynf zP>#R|VRxQoeI>W?&ygD{=!?o;j3rcI@aC?1+J%kcrw#X4<4_HfAExIwn@|c2Mhu3$ zGLt~xM5SyYk*=QMuX5Ezz?^5EMCwVJ*0=Q0n_v=eS2hjsZQ)p5@@agdBvV@qHrop( zX3Qf5QNE{(F8Wr8xYjiwi~=cs8rg+i1m=Ijbq}Pzf>jB4kN683RJ+8dWoy{F+uX}Q z)b3!gL8H#eRz_wB26Vj4Mnc6$3R}6(QlR|}JuCNnC-)om(2~yFV)o5G37}MAN{8<) zLprR{Cww@dH#Z6W+ejL4)>j)Q&MPYb`gV>eexk*f65_QlZ9rx<_kt6BxT(&Y_T5Dd z@+~^cW++|7U(wOVmkr0x2FCSjZO=t2B;?V$s>`{6&962w#G+Wkbed#N7Ds3ugTkrD zb}*XT#_b2A@oP7YN0)3nBqJS$QZGhnxmg-rLUAXiNucqq#yTpO*COwRs47%YnH5ow z0?c1C88&<^nDUBMAhN3->K ziCau!F96BEG!*^tt6wZ&v3`F4>KFJJYot)tM;ZNnBs}BrpZ&)Isp=6nk-4wj)wQZ- zx8^sKZs+T-4(=ZU3ALd0C_M1nZyyelmoL;LEkqn(Y?_2|nlDZ7eAf=FQ>;U)AOt!R19mV)KBs!_> zeqN5R8A!o?F8`1KR5tawZCYD4DtCvw&lxI%Gss1UGBr&U_>fx-^+YO-EkCT7R;@@ zD7Z|(k+{}dQI?IG;_7(z8pF3-*BEy%57jCoD(?4M1Zf%FHV>5UVw9(Cqb9wzPGqNH zih^5DQ3A1TB!|Q3^3sx={~GF%hNgN7{=+Q3B3usLHXx=vtHH6YaVtl`FmaM0mBM%$sUOk zo5q}mxFc}N*c_P9$*~?!KbZ17o5kS>17%gX{G1IAmF$W{6ru=86U_e z-U^6Ak|xRmc$O(+pKs4Q%UsUhTU7h1A{zt#5iRF8vZ;mtz|D=G#S!0~d7f4472CT9?Hc>tun-q<^-A3WH$TmUHbNJ@>5>p znG#Y7@B@-fA_yXq&@+(?^)9|X{`Du5lR_aP!~7q!8Jk0Sc}y|NqI4c~w`w~Kv0|2J zgODP!$s-;&ZOV3{nRMZ&uli&K9!s?G{s?{LUMoQ%$TRAX{VP=aeq$pr2afi8`OVIIb*(9^!dRJh3d!sJUtkc43fpH|n4(KC%C#ZRpVm}%0i9aiZX zi_b3wkc#3cZ z6aUF1=lv=heXt)Ch?ByPXwc7#YFSoP{c*km2L3Hj?;KHB;ECu97w3M!pFnOd3p4=} z#5Bx8mCC#xIsGMO2r9aBfU8GIjVsJKTJc=z8PyNON9qB5QkOKH@Q?UKP1QUGdbVCr z-RmkR2nqV@SyjCv?X>*$YbM^P41)Aa%lSXK7N2& zpv7*wi+M(-xy&xi{)(&=I=jlxm#_+F{O*k2ot+8i7S{5-r^G1#S{JKa%S@WU=sHB9 zv$HPO_L3y?#ju7-o{_2uNRH?PWo40F8P>|jdd!o9H(;c1C$jQW>|m{29_5!7AgJiT zur?hZMae!NbUO6)jqE2;sU#yGW6{?x%8yG-xm2@X5V@jYO+DH7dHY`D+;X27{*qtx zfyWlWz5csdnIST;`CjyW0P95Er^TYrUVO|)Ymww!bW5+=uy#9GnSJA{Yi>gR!#@9BQLlT3atw8#}Fq>{bDV(Qv-)`K+Tym5IUkr>vd120*KK>nSVi)&f`a1rQH z9}Oj4)n}@XB0oTCe#|QYRhhOXvxr!!V$uy&U3PWZG@-O8DAR_EsxDwTRr9bG_BS5q zTM^}Jl};(V5N^>Gx&RCa;*YL}fzemCQ?bIg7W?@Ixeb`cP=_vXS~R97_s7smT+GVz zZ1x^Kv`D+axoAOTl<=|YJ+;Wb`sPt1=PtAxhMe{BWvAEW-riVl`C`IVN3M#+xV#E? zg5Svle1jE6hFjur;d8ncmbCWL@~KsM)2w=PwUBGThe3bSvo_?}SuO}Urb1}kfh%JN z>RktWN{sOMdVXHcm|5288*nS}8|C!$KD$sev|-!$U*awjxTGEKct>s*+AJF??C1e^ zjH)QnDOE!|jRDh$FQU9?#ETDihYRuIeTlXk{c5kq2gRfqadtXg@>4>uq|ecf{HVVV z+~GdeW0gi80uh6ag5r@;?B_h2)l*$!nO)@7K0ob?o(>n{yKYx5RzkX9xRkrpZfbR{ z+v{No+~!`owQr|B+XtnCg?;7^VOepiMqx zLTyDXQZgxuqDV@qlvrXA2$CTJ2nYdiQKtHvhdJNe_vPI7yvcczaWnJ9+`~NpP|B?8 zn)7#;l8Er|#oXN7cKh@8MKa3MY;b#hwRZa??IpL@Z>NKN9QS(l&-v}z?S4EQri0U5 zJb(0G?SC5^8(CBQ+r)p~!aqCWpZ0U{&$~b1=V?Ry`{D)s*@l0*@XrQ38#Zct8ykDI zgN==YT61F~Z`59FY^04xn;Xr=R&8fvV+S6*sBLa+Y_fl@oA6Nl)1=q<7yh%ov9WEQ z!9c4`^=Er~`e^E1p=0xp?*;S=gDr;!YhK}Cajm`4Jg&Xp*tmva+g}^sHSCIkgXr?T zUURSIP6I~~(-`42`YjlIaB~Q6ZES4m(e4)(y}Plo3!{x`v<9qt(12E_xa>2zY~78T zUl{<(L1AsfSz-O}1Tw;mzVdAlZ4#Ky$;_KD#~g}KiD6(dhgEkD@Yl(WkYa}Ugm7e3 z1|#w28gb;S#F0shURqrvrrd48u1=X<`9C;9TTBG^uC3n_aV4NUD4 z5#y>wgCSgt3vIJ!=7plpxCv)+Q_9iY^krbJe?EG@(R|oozxOtpzded!_ud0GI3xRd z#YKzHJ~tk1Z8V<)LNT%kkom&~Oj0`+pg(UQeQVmFdC;aiF>7qJM{Q?O;`wz$B8?X^ z@EPp+9so%EEoS@<{<#@|a26X6C6ISuM-_cKWuHE}6oW4E2VWWhM40L}zMLJ5@TGv` zBlxWSD@vu+L6xwVm0E&+G5To(W9iq(5UR$(mw&@$hH`p3^H1VNX?=GAY zbD^nczq0`yc#F3elGb`&!>*1R&}f4p#1^arkz`X-B4;o66s(~gT{s2sVH*d0n~F;) zwAKWYfnEQE@0J?@oPA;6|I}nxfBZn~mN?AAHmydTPipW8)-JB_E!-Eer($B~^4M*B zZWsW-Vf&p;S7Drdw$k7;Xa?~I5C+fUVncJ6<~ZVxZNNq8ER8W6;?E`M75Ffumqaje zKG=-k0)%G7gy2$pO}W(bCbV67E|)qkEET))Z4aWTS(UliP8)hW9A2z)(DJMjCj&fk z2?HlOxI~uf3Q1qTiOU=`T^`O_=e9&Ie1p?ulmd?qt$nEh4JK-vd;YaMTiCYlJ-%36 z4^e3i8(93C!rF0j-?+<$u8_Nc9-M`5;<|tP2bVp4oy#{|C*!?#k{5!@I6c)e|GfYH0>;UGen4InjaD;%*(ozu0t+F zk%z*F&I`VT!ePBY{^Ludc8XLjSBLd$!;muAkQ26EGm`nsFhTBa?g0<)IiiSP89b+3=;Ves4M+uOjQP|hO*tZMvlzT)h>f%xy z_~eQo7Q?N)*S7`Y!0txdI#oq*?aw0kIm5qK*S#EN55y${#PS2V3Fom~j#2ZFHvk?e zH~|Tqs1rb9(58vM;6%wkH{taz{B?>NKfJ(Nw!~AA#YuFFHR;CJxL6<8WRNM=TeJ&5 znI6@-5(D?cph-NvhRA&;|2Q11mWiYe#G~W>UO0{ZemEJnKz;ibnjC15oFOny4M>*f z0?C#m0&i+s)*dmI&dYlFq|_$-Gz(@s?3_#kfIa<}5+lqKNn!mwpe*LIUG>gZ5((!5 z6c2x6&wP`FyX_T&oSAOg@(?%ku|j0duEmH3hDtbV4_pEa_fZE~VE7V1P74b9Jj}ai z0tgM=`oLC<-f3#)b_3DNnTDmUdVts9u*Dc6pIQO8fmAa=9>?4^n@Bf(j6Wyss&Dnl zs{a#n1{E%-TjWKVsQ?;w-44x(b+%NUJA^gLv%B{7vD&a#YILo?yQ)^-?P7*QLdpyf zzP$~;00w=}`&#@Qjpc2Ob}(GlGdl@6MzR)IKOz{(dc16xHfV96WE-vbIP2=o}db z=?yz-o}o~0VFKNo4;q?h?6o!Nc!BcfuZpwVJoaD#(;b)reXM}lMr(XB6Zab)TlSXC z1A@Lw%w&Q(rVD~>3v~i#EmYxNHrT0|6zKp?u7@9D4wmv8B#9Ybhu$8|FW}Nw76v8{b1*HSoIz^}~C3+EDkaOU^WCB~5gZ!M>-d zw-j2#-aYrw*_&*H?fD^n4aA3cNW0_Gz+FQFf7e{W+pwC_P%gtMywmM=ry31IDzeZ1 zyU4QHauwMrLu_{R5V2e8i_PEXxwq7UvD4#c4Q-XdTEPm0-vQf1-x+|B)TVG6kKtPLM|{maXnfub zrSoqx>gS^Y4vqFX=NQY=u9ij>XL{8P(59_|9<05w`xU$tUdsVuun^+M3FvLX=S%ds z{RbhU(Uy3&j5&yHY8#1bH7y#QR=Gylxhoz0rWwko5iZKDi%nPkbS_y0TU_=L1mCD_ zM>}f1b7of7!@#3-ZoY!)wis5J6Z2j=w*Yds*GlxczE$|%Iy3Zqi~d!uSw`}$`{rY= z$}v&obEGxLL{T_x;Hm2%rGpjx#K?V=-cfT7)mD~<2bx``DJx#;z_Hi)XXb$k(B-cM zSF(av$4-$W*o3p!2Cl)}Kce*)IEx#jCNj%8XO@)<(LQMrL7ge7hPnGKeO)^Yk_}v= z;{YhTk;b>e-a$_Yv?(=eRFwGe_=;`6#oaU;1B#L${ zB}8A82!OWt8FaYVC=a8M;-&G9_w54yv~}VhK6b4+vyp$>qvR|Y`P<_HPE4Pd3t60z zqd{@Z`8aai-O2w zXkzk|8_L$a=r?RI5jX!%yTB3QSZ@7TOaWQzo#)zhda$mbRe4dG?}DhliQF9m09vD| zwc&+8X`o;8)jg#BFX5l(_Fn+i-CjdS|Eb76388imvF(~%;^kb74gF5jqfV4w<$MxX*;Bi@kLN<;9N^REBJ`gI$frnj#05XXfPXsSH17!j=Yl%YX3oL z)%x0;S?AyWBcK{}XW=s=X^+iD$Q5qV(DZ-g54H5UOgL+@q!cxRQR8@VU|7Tf-@s)! z5R7l69{LT=eEF{CphxV1ty^$x5ze(y)DFNDL2J#^3)(B{YaZW-Y0O63H}^PA*` zW3Y_HV)}e)9NOpb>;Ww|3DWvnxYEG<6;-}3dJTOYKA+;CQ?y=j7oR<&wlzQ~Zu(X& zZ~473H{GN5g0s@Lh_Q#(2#weipY~bZ|0Bczb8QMo(l7BFx|a`(v#&OSNLs9UIu3p#8UxxeSzc3|G7GMUoPJ#?gQmU^xL zx7C&?7*@1<1haw}#!TEV;Fkxgme1{uo>mO<5a0MxX0lO79-M_ zr+sM4k&S5t#4>6Vb2-@;L;90V4=J{EDxA z!#63ZDfXGof^3Gf1Yd-dy)3UH&*GT2yi3*L$k&QvDz}NU8{V>!_6p>8hW(Mw)jn;> zP1A%}%Hg$UDHa-Ob*W*ipaQgP{(sc5`W&2z!?^aXZ7{csV}Nu>h-qg@-4B_)1TKru z4Hnt$MOsTGrdj;iK@izn!=pUQdXczy!#24g2K@poX`(!ym)h2wqU0?vc{^i_bLPg^~ zY)$i+Xt_qkbM$+GR}Y)6@TX|u{gT_ukQ1-VZjmD0FF6Y8iuv61#?M;)jON$ycyIC5 zqF!ApTY*D21_wif6($>Z{vF3_fmxmWjv$%~lh?gtblS7j^sWhwS(%h-^w|A`8}x0{ z783L=;8+an=@0~;TEyp0Yfb5@=^AEyK3Tra+)~VcA==uy*|s_J5u9SVWzlE3^N{Rd z`l|x*(6mL*@N;wK8Ty8rVTQhig=hF(FbvvcH#C>Z9OJCHZ&Og#IR=dbu8okUQi#B) zp`yv#Droi#(p2$x+El^x%|R=8dVKCn(kNHX!7#6$a<8sUNsO)<^Pdln2#M{)t}N4% z@{)Uq&F;+9B1h#pOCCRY%TL*2O)?b;O^A%(4v}NGJzwf@ZC;ow!N; z#p2{(yg}jSu#|2G((x{+@|$-&L*KW2dQpj^%vCOLJd*T$Zs%;xl>%v2Q3z|cnW%d z9^?dUSAvOB+Q@~RDk|P2@=j)=7wA&el=Q+1%qf5`3(h2ZpxRQ?Cb(=Mygu6O#<5vGp`S&&b)zN=#>c3uSRoteIN;Q(c zlO#wj|2{^d^EX)&RMSrL7g||h`HA(K3{eeO3@|ttEk(*=iwTe(bS?o2{Jo~`OM%ZS zKhmxZqDe#l+0=~2Rspfp(bFFP<@0xJom=R|v#F(EWZv<$bCP&(3griqGT=u>9pn1w zp+CCv^Lx>nYr5LPV?s_^uHH%!5BWVAcpl2*h<)SSSl^(VxH7zG;?+7L6r8u3oSve? z@BKEd2z}t&it_ptT)TWYMm%A_{lu`oF>CO%rF6!%K8=Qu`n5Q?(yt!6j zMnM9+L~=6SkK%;JZu~>1(6@`00UjkfP0VV({gx8n{04f zm(f!eZU+{C5yUaayGVU<7Q`$!X5LK>(6%!kS`)D}!_K{9&mlm-97w;%(=HY2&6n_d z!%lKth#f5`2h;}HI&K}_2=map#W%>kP#FcaZ&T5hzjLnA5x+_~wNu(3{;l#&7&qB{ z;ApFnbJ;b18|IBnA)#FkoX9lm>v6$i;)`SB+%qJU<@4Wjl`d@l3U{5gZQD2~*$~)O zc|QH^LlJh`*?Qc1w5thAtfRizt)_fv-n!_bu7=;swq;LUJp)d-P26G8@oii%!h}u( zH(&Yg1Iu?*$(g~SsSt#@Kn=a>Fm4OCNH=;IK5ivW!9p0R1%>grB+LS^i zvhdj+xhPh!qPebYTZoutp@VV>j62ljHDuCe{~DakeP*USRlX&h4`+|8^Lf*FB6RUM z7rZY$ZX~kWiDLj~%&gaIXUVAJw+kw%(KOKeViXJDf8Vn6F`SiXB{q@AZYzCz=&rOg z8k#(d^ImpyMM0MBP|-iu7t*OCYj{I*EUmgfXN4a5wPH2>%<~BuUr}RI^u17fyj%z( zcX(;v3zKq_^BpGHyeVPjticz%X8!USb>2H63l2$?+3S3hm=!NoL~#%C@*dey=@x&0 zKOPqNwoR8>`+!TTq9B*&w^8pR4WX;E#XT0c-LPq8o*p$>5(}mUE}huJrq8Zkz%JYH z{M{3CB;(?=&RSj>(igZH6e+LTW$*|L{JAxg{>Ys~VBluk)gCIwOu3wLD}Z`8Ebst0 z8>47q^W<}~TcLkJi%fDj6Qyo>sS$nO9fH)3g+ANH-wJqF_}waFz%2uSxLCwd<6MIo zR4|M{G5LLLUP1<pk>9Fi2rEP9|T5^UPLnIwFoN>ZT-v z-x*c2{6%d65|~}nkn3q2S8$-`oXRzS_X2%aQ#Qi}`ZX?En{VT*Wh*yKWx<%OdDK?X zFvc4@2KD>glx!8P8#la^z;n(tCOdqw7JD0EwaZ0gUbQmmqs$rh;RI8k`PRUEbR6ul zUN1KSL}{u+R6CTC>s>*0wk2KT?l&A`H1p_jULYyjKuYg-2$3nS+?svvwc&UsZ%OL4 z+zgJY`H}mD+PdbovTIsE*i=B!s+r$rcbpSgoi!*vVq2AU#(&zqrt5=REZwS<`Cj`< zpgmOC9qzO|9;G@Z>8PZH-_(MlFHCf~oA1F>FYV!6_0o)( zfVs}Hc6u-_`zjaKVt^*6)W!KOHcgs|gCNQr_yiiif2|`#cwR{TPtpBW8?-l_Y>eva zH>nP}1qZU7w2L>CCD-2p$6BcUTTp4JsMY(;u)4WfNK&nU%Q+9#(-~J>`{eZv zX;0=iqJ6?nm)ikG-B*y+E=ke~$A>n#VgS6Mcy_V5bL!fZW4RelExxOjEUrUZFt-}d zyX4HmNFY0EqRW^=xeOgJe|1=u#O;fA;qH5Z**JMd z&_c2T?N3qeOo!jas^$Z_zWu7F>4d4 z^&D8hEF0#qQJOMvmvbiNxeI-f<>xJ1MKc9@nkKfw(MW1ipKm-VIF(y7P0G+7i;aEZ zkzH0OxL162zv)hSOJ6a&;O7RhZhzD!O-e>BtBN5WKBqO@GZS=_kK~)-Qx5WM4Q+C% z-?Gqz64BVIum)4g+4^!IAw9_*JGvbfuxsEGtK!&Op2AwX9Cq_1Wr{%wbXPHETfQO^ zZ^NO@7GO>FVOQ(m$xUgU`sWyD-%ioFVTcpm@TQP7E?_ZI;PL=Gb8~5(kbNd86mm(c z=(N8zOZ-+IcvMK%?&M_OLKD^|_waq8@5n#c40*0s%LMYd<;`DdSsC7&R1Ox(77cTs z8~#kQW*L(8G;zt>TJ>WYta?p1nr6?_u`lPVRth%V-0!}Wg1e^5s&QDe5~3^@3{IXT z?yB^v77-9-<8X#TUxt(zRao!s{Mo3qF^X|h1WqN zMzg&)E{TrFA?c7d5vZUbj&}WKs1OXf-TC@es<~dnjiW7gF`liB8OB2`Ym|=WUXzD3 zzjxEPJ1(WRdJBsOAdz?(%0g+bYNd<*($YFG`_7_&*nAu-jwOYdB*#1^(p6^NL(ks4$4q*X$ zap5o3yysCpI7r~r6vZm7B{Db9bsH`&#K7FZffnZ!X7JKG0k?XqMWK4ZN_cnWt~U2k z>Q9VXXQw3JsVBdjd(j$nHj=TJ7|GL@p6k)g%KU-_YX1Q2Q9iYJ;4TdrcxO8uaCrsj z*fdFOqq+F&QiEpWDXXR`3FNeM{NhcyZP6W(jok2F}ODxUn^V`AuK)6JLUu+iQN(vkBLivk|@=xF7UN*)vNIoW0S1Ksj^{kQJYpQU- z}(usf*CqnWCL+(stS?U=h!X#&@%G z@9hNGtSn$to{VFSb?>FkOr2mzRHcdym1;FX3%K0yCQULaP3?k_+NN>VVo?C*5Ey4V z&|FwK!yOvo_*rMHx$zz{-GQt+l)6vQ3+(CzwNVniXkZuN;vlFY{oEiq_5H?n%gvVZ zJ%0SS*h1x3U!^3y*sl#Y6@kyA!VCe^U)Iy#Y`Ns8;IgYjv4ctMMK@=SnYHz&G-=zd z8=kgb&jQL|u^|s4jGEyB2U{M?hA;bJuuzz}bO5A_O#-P_x4n2-vP7r0xSsH!V16*< z&*yUDt7odweBAOvhp%4R6N&(|^f|tO1t+Yi02T-tg7btBL2rM=w|2{ov@)K0Doo=f zT#m=8S@XG3puffJmRAjnjcdQEoj>2$IERuu?E!L58*D+2wRCr5+j7lt&Y1ld64!<+ z5th198eK*+yzidd-TjMadV=G%I1^FwmBkI6q+v5$>q6C_Z=ZPe5@zuRG-mODsB6uj zA_U&I&l=%QeCe`%i-4L`_x+5NPyd2zy2iWY(LFrUcS9O|F8g;DfOYWDR2< za$H&+`Njs>z`q}6QUJGJ!@Cz69ty5LxZnLja6fH2aQD?_bmo2!Z-_@Jp5fDG2=4a~ z?$-$M0`&K!2JqK#{^CvGQh$UF2GuZUZ={yN5Ry}nvQ)--Cr%JjY(8jVhC%XfN|@fN zy|MiewfwIhptfQAOiQ&de**zO#lxX^zGHvQDfb93Izu$ROg_=;0NS4)N3Svy)$ z0H5~Sq#uBD@*2*J`1`UU1AcboA=^=ZzGh;ESrAXX=03&GdWAT>lJ77#7<{$dn&Yc& zMG}TB=0q^_Sb-UWnd+{8tb2H!O8O$v%3mWy=6+G!_Y1SH_oZ?M{wLUu{rL#X=a!v$ zT8iR2H9=FlFZ>2)0&9n~2PK7Td@egC^A&T(Ew8uY^E(POZp*qO!CC`Wl-;-ycH9k) z;#jV|1r>Z=BQ{873O0!2r{a>J6y8EzZ@=O3xaUUJyA4S^UuuxHwFK35YrqDJzMj%C z_ZcB9!~7q%iFC$H&>-ICP36n03z#Zk?nnoEHL(uh(%05a9Wp(;a6jh zdXdq{`bu~C>U2^?bfXr<+F2&wu@4nkUGuht0$ip1Z&f8oD`ymqLV1j)?D7VX9$!zFON+*YCr%A03g_vq7QSNd{zbA>;nGwAFBT zPDaA5x|KVQ4F&;uUOfAb&xH@==Ab=`Q%W6kjeM}kmUHi062x-TXKs0=p2F)0oreg47GhEHdYuX8wXfG{1chS1} zRA#Ivfkx%V-x2pRGk^B*c}m_qu+H7WU=9Ipt7wHVv zdc%xnEjRGaa1bayP+Z}Zm4~f|W@e6pQBjbqrd!9%P9+R4zBZmEw6GB0(O%eDe?8CDtMnZB)!dzc0X6y za1)Q6)Is*3wbw}lBLx*51tq4}Lc-p>gHu(RkjximD}x1{cMGagWaNzj^s3-RJZrDk zW&5hux227FHp{ELy7cVP!3(0T$_vTPI-gQI zwEt4G=s{s-S3h88!C>}s*F-ht&m~pB_6(!_PL&>AF_#2kyPwFs zgFdUZ&y&{oj8P92c)RU!^?0X=)jO6SfQ3AUqrsEPr~MB<1$4v+6?;;%u6*r9y}C&=Sp$XZy?!3FX7`o|_V+Qq*w8>(U!4}(9a zGIHbj%E46q37QNN(JVStnH~Y z9E&|8RXcjqQidLVx*D@ov)-K1)7`G_ULX=vDoeI!@Sfb(Y0PXULK;FUx$3z`7j+!k|0uF;YzV=O(<~g};Csiz&=w*qn<)^EhMiG(Rk+Du{M% zZdn{OyrD~OzlzL{is^&=K?1g6RF@}88?O0d2CSV=a4ZoIU{_-jY zwxwtF40vIsrYY*%{-$od=hwLnZltR_YnCe8jennX5omoMVVlbaW5-!EL)uaAL`SXf zBX2)qqFaU9=36>os2PT%#UG9vUh8!z+sphKT3_gt158j}{k>{pI~xZa899sQEBmi= zy!?BGs4hd|V$I{FjndbDzGizNcRH{4MCqELN zO8HqdBHES=t#N(O;KlxKIEj$`d97J0$AV1SzR%Cx_W+^%RFqq;=KjJi^0ZZ^#@%IV zT*nQ?hqERM^1XduEBh33)SFt+X?kCXXT(*lH0{LU;ml7S$Ce$RT)wBX>*eIh(()!0 zbpj5Y7qVVN(WB$40MvIphwPp{x#*Xm%L06O&N{{2i!2_F*EVr8%eII`_A?ALb&dSSt8M47D)!$pK*wXIu zRt7+;%x`x-(o-%N%^)$^g}m{Uv^?tn%2AjSAy+%r@s&XT3 zP8&+9-=?%q#f)IzAGtNBx8LynWs5vn;oluy526EQ@bF=KPd(JR#=`Dj<^E-sOITRZ zx~XD7=<>@OGGmS}6qO}!4J6pyw*xi2^U-_ywc%b@~H_(l) zm=GRVE`KxM#cpoE&5h@H1+|xu6yI-pX|b+Z2u=R9}mKq|K3~kkvaZ+K}&ex4l zUNoGiVb4;x;Z0%R(SNz}RR5K5a zQyp%%Ku1s)=~IGOB?q=js@(h^vrlFwo7(Ryuuu1!KXjjhBX6qG%KyMVIR#j@Wf6&4 zGGoqKF%gxuCArdyOr&yaV5|2res1v?^d@Y&ITy@EsqQ=}I(^-%jYN)V78; zg+8c2F+L;jsdG$yX|Nxg(qRw&zDr-oLYCo8@lwCgNwrDq%&onSRWjv;li|IzP6N18 ze{O~cwLRip8F$k}pE@-MAm7^W)Chexwrzg8P}}md8S>5b6-}|&aYir^&yd+|t+ixj zj|b+6us!nS`BwCN%)&`A{S~pq0#(|_)2noNvzBO;3gP~I)mhS}LfiIPV;0o|^O81> z3T@P0?4sO7kU7UPSS!!VN~dg>o6!o@JY5MVxbMEsK;UW417TZH^G`r{TgDmv{{e8B zision`tI65+0_tMB-h6*82#FblmFX=Zj8?6v(@qO7B_#P*@0bM{zkmM#-gtqUz@f5 zbNmIq=*=l8Dy#I&4yH}JT&mw`i22tC@at=Hio5+*AwLA=Qiml{iP92@Ek$@zIqo~Je-ZctlW(A%xqaPt-RE8yoQ&UaM&5DRU} zT(vchT{bXgq~+$EaPni?_2;lUtvO+3wdYiJW3G9WwKCPoe(h@Z@QAaZ&7iwU+fyRW zm!i~Z=M>Xxq7JdBV%N%0u?u;_!*+2Uw~t_8qpamgyWDS>G&jLF^`#m*hiFxv+e=YFPm-twDg zuS@{nq|oU0A7O(E+wS64Zu1cLnblnCR5c3%WVxl2?0i9=Q}L5BYW5p;blIS&|9!#4 z9xD&MG~ioxWSlK}QL1Wi_RbyC(TD97Xc%rBFG2?TJ*?5R<+&6Lu34ADecz=ZlPgY( z2Xih3@?n};HR>bq9@Xf>!foxl4m@<7Tjw2iU>Ajk@{&Nl)8-={!P~N={_h5sCtWVf z;VIRJVoDihQ{KbW-3Kg<_m>9yv5Ad#@o%_Y&Pkf+l^C*p^@0t)v3sj5KkXlsCD%H* zBjbp*i^%{QEI{B!`c1f1H-1I#_l4J3VAf*YMp}X6#87NvV9GzE&r}UJjc3inrY9@U zZYbp(CjgcWmnj?l*+FHvPIFB=ya|cvd!^H0CQM(Ni*jc!Yc*X;salM2*_sZ>8+smv zqZN&rSdZ0f{Y_)pk%i&Z!hg4Wm2n1pp~A6-t#BP%E0b3+)EI7YBe(C(D4$!RsH;2= zI*i^_m(I8aD?nD?BaR-uS+D@@6vD7n>ez=)v9CB(b#%~lll(ikjV}t%<1veuTcL#0 z4p3@*w$iX1Wv4cTE|h;RVql7DW(>s|N@YP577@#rvTm7&Z-Odr6*LKrVKSG1}5hbi#i*%xUzlb|di z5E8^zTQiGVjc^YCP@ts;O+S|y`QP#UZ%yVNCxZsRLr5}3lAIgZGhEorXSq!m7izhv zU$m!)OWVHM!rLY-*Ay|Q9MpEas&d>fcTZ-N#6fpo0P2BM{PeWFoq4^lA@U$WR=!MdxBVBb;y*aTyM!EnNd$H-dV=J<+ zq96^ab|~(PKvF7ySz0Tssev8 zz}t7tZR#?cMXvRoCl$mCH@~$kn5YFHCLM1Rq~iz&Lm)eS5c;?Xnz_ zJxl=ZXRux%O&CTo5SV|4UO#7m@`V>BlMX&DfF7WSDRex;bbm%p6Nm_&AC3o z+6eGrd&8ZMFDW=zP0ilY7Y*+rt!Q@eXD2WX5kEFVL8`h5R*P==gll-S?>^fCBs59; z%5`*esPV3v-W0UO@+`xKJG}Wvbv7uZRPbf9bS^zl6Buu`#eCsPL)N}4Q%Ufy+JbAs z>x3g=BST2+W3KYcl$JZP13<^2#A#kSGTQ)FPOFQ5et^FXL|aAq)t9dbxL8d0v?1i9 zye)sUl>*eOsSdvJFmdDNEEz3)1yMcnu#A*)yp@7gKz%j_bpY2IVXusG6P@n}Xlv}I zH$N(B*R5=I`>t3yH!Nlgm7L0D4%4_1p?4B4TQ}arW_YI@dz-7eKL}a99sDh;U}9L^ zT{~(N7#-h&H+5k+zI5MF4JdntjVaj+cCh4L9W#ZqLSF!&HbJz#E-PZq$2u`I zXSB^c?BSsC!={@Zy(864ZSEz)XCn3le5J0NzVg_Z&9kMQ1%73JZBbl=46}#7ep3oB zW_!eo@1>%IUm7i!#WXW*gLuKhgPkaK)0(Zuso^vIJn~gK=g~2r=;GFX&l&?F3VbrO z{uI;oZA%<%%4$jh1vYk+Pjp!dUag;O`(o+iitRwf-8>R+JureUC*-eJR^=jYAAj*=+JD1 zFiGrhzbQyA0UN_r;qveu31iakw>)TRx$T`bOu~mIcS=E8Peib3AIhNL%&vUPTozaw zPj(?XYRh8&NTt%)^VIWx?-VU|e7tt0tI4q8Gxy0uZc&ckyn==x7F$JTRi)+Mht8!a z>{OZeW$&~k&mONA=qRUmol?ZbbN(`XRDIqNw!$md?IaYERSXh_=3vFGF$WRV{Lrjy|;r+cTIB0fLihoS1~$4JX*q7 zZEvB>clN!r1>P*vQ~T|44+*yffMzxCPqQ{$wu*U)!s~-*zE*H!y=K{Mw^(U|%R6m- zof<9Ti~|gze*E?^MnIsbk~!Rk|mQB z_d#BTtLobGZIC1fAKITG+N?47FRl*$AHw!P#(&Vh@8pU%pKpdN3l_RusxxI0|B$K?XuE9+hjNv zyQQib=v1?|&jisaQ*7F%Br?5{Pd#VX%bl)@>lJDs6 zJB5P9vxGXgLTQ}0?D$#>0hVQanWNj6d&wr_V_ePP?`-rchFPY1DDW2Z2;n!_Sy+$eY?Ip@>3 zpo^Q{R{Q!sG@}M9J{@3kqb*8vVX3l=tALN@ne{pga%_#eCc%u;q3>D9fQh*D)!zw}J{`BOyq>nIG^bQtwiGR^4Y$hDF62uI z8cLi~V9vdB0UJH>2Hqt81=tqFcNhTKMnUmCkZZttRsS3DuZ+t+Yld~M&MC8Npqn_1 zmY)aKb<}4I3(R#`;9_A)L2lBg7V;@Giy+DDQYatS#S*VmB|8+REgZF+4hU zb0BkTtu|*NMm{aIFG#c8%SYwMzW;q4wo!|-$Hn6|gA#WXmr3(XCWlb!c)-_PnRx?P zSE+<(cMJI>91ifFM;gU6bj>NLNPL{6;lU;>{>`JbhQF-vbvw>@%coB$S)P%fjGW-O zBq_^Z@5i}hh|Uf!VY+EU70|LOU3GW_{mg;dA!*Zg#UKbJ_JB}d0jnFJiSMiZuzR?ow8$BI|}$!E^wW1ReZZRCzO+OPeI&PU|Yw%b_COeVOs-(VI3tFW>Hzrv-w$@*@)05d?$zlFd}mJh4DqJ~ii z8ME%jh3?D*oemdE3}tPK*y4!{)Gf4Eo=yg}u_fju*e)L;)|IfP)M&Qw zvQUcbs*J1N!lVvur60PBytGvWz!yDJ#>Nb|-P?(I^(A^TtDJ&W?AB|uSnn4+y}j!o zUIN{`A$`lWLq6LX(}AyORe8FSauREr^>!bu82dnHcX# zzKban3OCB2RZuP{r_#?&uTv?q?WOrJ1oxgJjGz?2_FBVbti)dvRK)5O6Yo7iJ4{u& zp^{hy{pTl5zmtwXzc453@~-fiI(VL6i*fd)XiQt4)YQOJ9DB5_yXG}_XZh0dxBz4g z+r6l?nmxAu+z1cJya_$~Hg2Toyt~?P3rDMPr_cT*0*>dH$7gYyXr&WFDGe$w6p~oo zb~Jipj;1ck#T^+PHJ5eIC?@f&*xuoob-2MircWDod@!<*#*NY>?Q~K^yw~ANp=Z2n zUyu><&r(S_Ybu1S;WH8YwCeAza7GWkD<&`X={~V`;6>}vmxktL9hnkmohW7uXZW@0 zHDcrY6jwm~VPmNr1rvlTqN~PxP-w)_lv>4;o0v&$L!X(u_}e(mHSaW-JSJnd9|3)# zddnN$f8ag+iHG$Isg9$wyWg+Km#|Dnql0Eg7ML0V2_u^cx3k%<`i{P@;?_iTRn zF<6xZ2lfN|HHfYpA6yuvP1npt^Z54rq}o{zjP0pgZHgR2iW2OTHv2I z{D<}6b_V}@CwR+^NAKXL{SWeo*OU+QvI&nqKW9zo+t>b2(E;fl#IBfUdVS)nmi%L* z@Fl2dCoL6!^A2P6m2@u5yy-Ey4#_83nhs)RpEip zzLH9ghnDUTQZTfCC(iU<%NDtni>)_J6eg*qA;!%qRgYDcj$bi0`-^1C)8`u-56~2} z`oi*)XiGnd(}tCp&+8m!drAQSM=i&PirmnB0QL1{#2Z<|+_p;N)BTxyGlnPN-`5&$ zbQC;&<1qgKfwP82a_NZ$nydF=v$+|3spa3<5=af(HV2fpjrGzr4?$c8bfTONK$Ng+ZbQdH;;k;j(ILIqiuo8Nf?#=l3Yoh0usMx`-@b50# zpq6mh`wb9MseY{xWxc)2vRXQelAU-Z#x%jZ+8tKm_jA{LegI9z8AqAyIf#SSJSfW@ zoZ$EKvT+@c@6ZgC7q+jwr*Ydob=5IWfR8h*$K@QmSZjulo9$gD2^+WgzTbHBo4lFP zG>W(98NYxpwY@+f+uk4gBDFOt_|NUy?L3=|I!S(e{lo3cEty`^W#Tf1cWre7Sg>Wn=Lo9?tr~Xfhb5{baG5oTP&!8jiAIG8$h;r-?Xq zqkP_OPJ7vL+?)5SvpC-ey$)e6Btp;K*cSd`O)ku&it4#~{ziT%U)X8du zPipj^SCd|^(0X4WZO%XWIEbQV)*r@5muv7-5gqS?+(Ya!H*Anmkk+tGF-z0H28}zPm4C@2=qWB5GWbb;=*%@u*;y?T&_SpIk>DkU`zZQ)% zYg+iiYHBDIZ)cubjRl?Jt;A2~^`8BD4_<#9EG|YH-LAlcG=G(i+x;ON$1K{6I`JUF z<261@qIfhC4FJuf0iZ#g=i=asDXf1SBv&}ZiJGeE=<&-axe{lpnjrv{Up}p_tNvdS{)`fFR0sI*))N}=fBX+vAbeY`_maWs_$+!FEeQ;OHMlbvXY7rkM$xs_=fQff=SbeQeK!z@g_E{pC3r_zGtvH%$Yhuz649=Kb|oVe_7dccJa; z$3q%PoRNd4zA5g1I3$prtVflxfYpb?YV_o3bb#|BpdQ#;Nm4+X<9`**PUw&68!Dz$ zhElcYO=weLhDj{84=4DBP4LY$T)WBa{1`X;{K^pV4Q>0IS*JZKE{-!zylIl_<~|T8 zsQ>(McZ ze%6u@asqaYV$zf2!jqUE!ejNryiG2W(RD>&MJ-CZSBMu$OpQN?2ZvQ?sDbgzFXHDf z(Z9=i2u4dR{3JRWjs(tL9RU$IIujrn3x2Gg_tH*MS*k_!R*qdgszV=(Mbr>qjmG&q z0b)OBU?!?_f)YHT&ha;*gb!W?*jJ`aQvG&U{w5j6sUUa)!s$5a=XA*)2}C%GF3*w? z-JnP3La5$6*%#nBl5@zTBY+kyz6e0-AkL$X;EYd`ZU{yvX-_cjn}gRq!2&DCiU8681FYBjyf*0fsb`94H2fY$s#_2dJ*~PzQ8w(d(c7YhJ z!G`;}X+vn7Sr0hM!kTDM{T(h(ej*6J`}T3Pq@Su*{F!O_^a+Dw;T!8M(n|#vzGw-D zPA2XKq_Ob$gC65hqKpEfexZQL-pPS$(GuWH)qhGBqhZ#&7UNi_`ippfEu8e?v4_%#r$UUBd>Pvm$%PpteXMvefrny44%CK-8Ki?AGK(!Bv>FD9A2c6!eo8->DWEfY$ zj3F1Jx*$Fqslgygx;;S&#FOHs1&FNrQ*3orE#X8=FY$s!ePSJQ8pv=pcp?(U=ID-r z9Juh3gZYIDz`&goMeGDg)7++B@cvVqb9V?{;rgM^>E%-c4Cvbh1Zo9<($P5w`N9Je z_|k&M32{2`ky$$alx^ToB5@25SG!oa$C_0i|9Yxtlccod^qZ+D3WY5PL^a!7den3eGBlPR^nPDWeeu5Bxs$fvp z6at7*2_Ky+-s1$B88f$7@GvKtkO;*Nu-OH8L%mDA-VfR(#K+v-7?hyw4Jjp0)Ce$C z?;k_bTN;8IT-40dDW^?Due|8W+5Lk-HtGs|=vHDI3?N~#-@c{CT&Z!)e`u-d7L%%q z^QHC2%i_qAa=8-MxCC4^jgDEP<6i|j#suI^a2L_~P#-5~qLG_XWC9eR8*Kd90HXm2;h z_O?5MM-U4*SFc%4)w)_Lo^9g5(GfH~5(5h2Num|%Q$Wy?Z%EY)6b@fk;!a1LSxIk? zI{o2M6-6-YbtBIw{Un!d#kXp&;7||=`om8GSz_c^jupxf ztZZ}eRWly^EY=yL+#sggO$6K$u{Sx&5y*gijxPj$j?y8B*VmT<0g8w@ zN{W)NIANl>LRaX2THdGAJZyNNNpo70^~lqao%&t`}|G`3$Qj+csOV_}v%cr=aL3>6KPS zoTlSme2lt?ekX}LXUSmEvEiqJ;3xUw+JnGa>F_?2%7O?@5ptR8q(>26!p zohHQF5U>>I5;N1|EKo`Fvm0SU$@YDqi*|IVrp7!ELQ|S>4$l!m>8F@T5HDZ1-#lM8 zN>D-75;PKvTLEwFW%z4Foxr>X_<5W}mx;vXvluWrlf5BroFJRFu6gQFLAsS&$Lt1C8z%7YZT>m)@x=O!R=wT*ho75?AejjcR>hyzD z#Tg#v5S5b_P>r%q^rI<`7r>UT&Ihl($uR*p=MbYuPw}p?iO?+YksStbkg;es1LFg+ z9^3<3@eW`s#XUKw!lVxin)bk>`Z#-;T_&SuoF|p)VbvC%B}lo*6&u+?^jr;X0K5x; zUe1eJt7*wu)}_)*>NKp26ft-q8zkcTT(}h6THx}WNXe}hy$#vm2Kw#O z=!rE?dEfxY-ufiGzGx3jGHAHp)*^B0s&k@01FI4F5G>kMBHCYgnn&7YtJ1GU7qzG& zrFi}2x4_20h0rJ6Z7y)Z0sqT*4(LPU|86@VSZv=Oz+>Mo^y|6U0`a!?{ji@8^;awr zRKZqCqRE#@+{=sdr`Jwv)0}-jx$(l$qT`Y<(5-kZNr5m=g$f-FFT+%*Q0rg8Q;_5~5Ai5J(^dLs}_)IW_>*5}) z85Y^UIfDHj&agFdX8s*|n{>vR5a=g@ZU1rmB)YRUN&J0uaSu%3=&17& z&u`dqDAsfqZL)HKxb9=`tHNG{EdqMpOT66^K{)jWGQ9@+UR)0opvllrCZNS5>wq z1ESZuF6qEFcomapb_D+alhJVuo0msY9~@sFA%#c>Vy<6F4+7ebf!N7mGRPCX-+@yX z4+crxgM+6o5a~27zbD-8^#l{$Z6&>NEM~YKnYQZ+XtMo!G@lEKYfi8STh~YXTk+oR zLJI+LaU{>`BQW$;__tc{pmvX=6|ORkuPudbKkbsr7XElFNgh`yi{}O9tsuIuGZ1&Q z?|enw^Ejt|d0E8G;b?i|GmfG|fR> zbBtj?>t;uKa-Vl0HWU-|c^vwZGcr1q1cxG9n;58Yf#u@zg z&J&yx7fnbiIjN*o3lS|(MQ@)^WuFT(_sQ=)n?0fRX(#cwWCh+CwR?DEL97F{7eI(P zS#Tfqg8QHzQJm@zhs>Kxki|=grt2knjy@~kiT*jqyAnHgA|VQ08(BRz-f}b}6?jz9 z-eSdxad&wa&_zpRQ(V2qjulSnN!7_v2iSSv~6Ho#Ma}^M=uv}F=)Sx+jR||AT?gTEdxX)XGZ6A&HGt@5% zsov2BDYYYe?e5Ztz3cvQ)~lzo$zi2rp!m8iL_#OB#PIAMkv*TBgriE_ZIZ2nZeTvA z3hNWwuR`15q+SEn6tF8|R6%LPp~;gk6VR-@XfkfP0Do%;u|eq}+QI4ZhxG8q{&iya zyC?%Cc~Oz+r6^oMmBcf60@Gu^mQ%m8RGl+AtpKEqCQAo8gfyJ#3>wbcwcAA!FeCu% zX8<7zI+r44H_3&RgSU>~>CVLz{Mfq~)|FTWIuJrz>5B7>!uxa+qgS=MWQ$^r)yi~C zu~h6>u8D1?kV7cp<-sr$=;S zs98~-x!_=QQmsk1xZv2v?R2hzi$*U(;~6bq++t|BV`68Xi>p-x5N|tZo%tY}FpFl1J@@ZBsnaW=@8eb3578;C*Ac{8Cy*)r*9sKgi?nqgX>}U}{ zZikF=5Xb&RM?0Y!Nzx)AOscD_=v{5=jkwo#_saI$_JurfCUpv%#&oh=v3e>5!wGqz zjytOl7s1Om%j4d{DCxz3APaapA;y3#&i_&oqal-&Pvsz%Va|7%N19ah3F&w+PEN(y z5tsn3Zs4Pw4e>)|lMpm^&=EokQ2HhL-3C~Y1ebA&Q;*ct4UrTFL2nPlJ6B1WYI|Rc zj&^n$pr1iq%+0X5cT3YG@+q8I=FGbro^ z*{C1)OvW;rh@%5Y4+|KeS^A6=u0J^A)jS!Uf?1dXSu`>Xg%Q(8^E0?OrSGlc6O|9{ z<(W7Rm;x=N?mGq_;Yvn&=5^}VN!+7#43ohq>-E$fx-%Rz5NF)lok`0xtbshPRm3p* zT$6b^bIjA~?syhu(&5_a1->ndGFBeXC`AL!T8|J%jC5fU-&?fwygH@3{cI1qqr(Yd z*;T6>)vSV{reeffIBA2sw_*9vhw>x$s0GC~NAY-N_NuO*dbN&n3mn7> z$tZLxtDz89_2JG4wnxA~5X}>O!cr4SaCmg5dBGzC(h|uYs+OCt1e4xC%dR(KzW)L! z(0twLsuaC823_Wxr=#9=716u{cIIT%p^F2r;-Y^eo#@E`ti#b!hVeY)VhYT}(ejbF zNk&?oBm{5h3a%@0uiuW)BD+j>B5y!#j=6<~#oVI6Q$~mrF!4CIdLPo88dZDeT5* zCbOIBY$ldyVTcpuBo?=%9bUmM1LOFuAW|cE9J2TduW`C;qa+aO(dJ1cM6Dbd^EmD0 zHSGkfk4K2T8)q8TY(7C{hjP;2(Kb~j$0i7Fnm-3f(lbJm=~S55lN%1K2C+t#vzaz9 zbdIu+8Z|fyIwQ}q891vMj}1PgbF&mUH-w(IDWk|Q;=xkc;gNulm$kSp^6No1xbEl1 zVm#lWQlu>la*5^unUk|rNB}hTkno@gz3LjR*ILP;t*@~Vavm#eBYq`*>(4${H+!3H^5%SZ2$_*{sK^0(BcgSHElKLTaW0aHLJx&YbJ z(Hk0{N1aJN7W`O;RFq<-c^y7w24uOzR!(-qODWD42-O#jQmI? z^mbt+$q8hf-%k2j`ZW>L*ZO3+oX5n$)e67Wfe?H6&D*CezafNa@ZWsA4{3meoIA)a z2eoK_#r#rI0@8v=P=g&oGe&7QQL>2u)+rcJ&iWv(K=eyG0QN!x4&%Af@ipbG0=P#E zn9tUg4^S^T8UHG1$IdVTr*OebFH1zgyc_nb75VBsxdx1RrbY6QFZ}KiPdcT2=^x(l9R}A>nFTjl9)nAsZzxc~7%208Zbj~sRSb~Hf`ePr#4KPZ;kq|Px zC^DH*yYXcfWwc?rVRfVz<92$LbicWK?rY+1zTHO8<(pa-xLVkrkn$}41^fR^lWPQq zp@{S`*&!%FbO9fg&|gGH^~OxW0{=gU!0H@P;TKT6{sI<9 ziB>iA%G6GedEHJxY9_#hT18Ebr?0cLs<)B5%&ITJs7i$K&GnWN^utUBv~h(&pW##Q zD2(4!y_HLHdQ+{NnI>l;H2CG1FepWJ^F^wkIh45jK7N1ukgYTo=KH`JTG!+>vhMl}gok15ig3pnmb*eVslTzzxE zVryqLHQt?9v#^1cIFLQ+U5okT;Fgh#ix>5h=KLHd5@FjRBpsbm4?nCz=U)%?wo}J3W#ehV^{seP%@K2R#NW9v-Kil z4E;alM6u|YEx(SQJ$r)uwu~!6NdruH&R%O0;XKFh3#Xl5X`cuH0!+n2T%-ZAdnL|m zD4JgWa{(z6)L;A9cNfHvarXogKFNq0b4+XSw1Y|UVocHq^ah-)P9H&J(s7*jC=o9t z)(3tT?Irr^Q4?kdzd*{B=>mi=hze}oU>9nzQnjH>--Yo&Zxqu+KWFS)Uqe@02Y=5-ew2@A$Eg9-Y7xW9!zUI$|k30lr2FV?NiZ|g+~7n;8Y9I+v3XL^8re9 zjN9Bvz-u6zfOcmjZljAdmP<4Dkk~>K=!Kh}*MI1}XTNLS+@zV?MtJJ`F*)+px z;isIcR+6huG8`jGr#g;#Re?#nBO-`gWqx=d?Ueg4=@=Tp3!)(;#X!o!yNhsbf5i?{{j6Zc~3C%3-aPxfJy*@?_9`}-pK;t zRN_}GV4sDDv-cP@2I(bkNXkU6sWJnt*t4JMg8sP{rS+sPiJ%}EI>1(IbbyDZ-LA<# zbs8_2tf8&?$k6=IjaH*i-4_7r;j7D8YK|=JIKReIdA!&Wv^Kg#msTX!l-d%ne@@8tLGDOjY)2Y&|4o_Be~#gtM-Mgw!};S?U*FGbTBN#o zk^OC4(vN16ihQUH|DY`oN%_$eKRc?eB*vZ2a=aloy2?~8mS#>@?wtG0*U54_F+;I7s4!@f1Q@xQxk{@D#)Y(r_yZdz^?nE6qlAmbJAoQ|`6q zeM>evleNUC>SkD&Y+WmK?WPcS-?NZW>B&uoEN;AlwPxyC`9++{U-XhukP=hCG9yw- ziuRzk30&yiv;{CXhWw6Ufu)L3FZ+dz_!<6PX<;98YSUO>jX zT*_=QbYDk5OgfrHJ|YwHqQLS(by0npOsbO;kv1koI3H z+LZ+e&LE})k^q)Gg#ex)92el)3)i+vqK7v((@@VlUp#&s!rCZNyxbet0K=Qy415o2 z)(xuj&q(rn!(}iXuFu(^gkxcgx`ADQFHCVArOF*gJ4V=+U#5b&vQgFC0YHgA-rkd5 zqwCgF5@+3~+NN$l2DbtIOx;cbiNs4d6Qs%zzta&`M+F6fd{Ig2r*)`$bSVYsBM8n* z0Llwmkci^bI7RzCc0uv1&KVDD3HpKieF33KZd`vKbzLBiy_^&hH|gN2#fKHdh)KDkl#lRS@4<&RD#?w{L-tgVr- zB9`e*PIO~*I>8j1E-W^ckBIxic#nABG<$J>m~_1jM4!v|f}aLniH}xSf*%E5J?~|4 z>AQP(z3=RYRv7>gy>6hmW1Ul~&SLMQj@iyUO)sI5?ttI7Wt_78 z*q$X1)2qMk39@h9E#4OUX@5!!=%cjNCf-Wp;QK!^ajQ=41;=`y#G~zOFg`19hD};N zGT@@JOvYV)M0Mw_$tboiBR9{J=QgO1voYYQp!S0-PXxQx&B4J#TtMM_BJhzP4fXT@ zegMoMaGDTg){RHg;WEyYN22$pWbakN9F#8IZix%N5ypOVUA0L3K-0S*!)SvQv{*2V zIdW*Ah_m#AmX44JcezefwVBBx;yA4^X0_xl&{?59yeYl0{YSrNSAxJ3R4a#sJr2mC z=W(u!f?;7!qsBIAFbjYcy_G{18_cU`-cgF%Ibm;+NUv}prh{>*m@;Dc7%fxqJ0LNX zHlI;i@ECgA%ga$WOE6cgtcVOl{Y%at?0fL@-~U}@VZ$7hO8?N02NUo}iiX*6g2@;s zsBMN%#Gba}&RM`DR?k5;^;v=NO*k&7v_Bc{5VQ@sYJg3uh)89epV&oS)U>>9+|lJ? zD|-J=V?f+CL6Is@pb%2A+lHxr7aoxLT;z(|z=V)~)wrIkvKDKCY+ zu*|a6-?>ANA4krZ#(W)>XbC>x*N4SxPrp#u%h@7knJE?!V=upzWLPXa23ou-9D(tf zV7iQx!SOX~TXGlvS3Loa9O*p*IwNSw2`IL?*#RgKjcGR!*O{b|A8#(D>XYI9+W>yYk^nJd~dLejMRqKX^Qyh~{!b96f zdr_CFQu!0%Jji@-Hc`SlJ&dVsLorljoflXH9(Xcm8g;UutZ&98BnRtLB5q0`E8S#B zm6W55j09`~cDC$!kSf=n4?5)=)d)0y-^|3opC@6 zG&4gwyWZBHY>6+NLu(i5)P?+VUm-iF!I>c5Q6gr=x0VTOM8A`A-+6LzMYZ*#h zJDxRVI`V~C)+pL$?yDOP-D7=;X-ptj_k=<3UjbriYd>m=@TV9C->Bmx5#o{lDPmA-i5pUXL-_ zuLT<7u#n6pA9(FC@Bpe;|&YG%v5b6<17>+6?uSSCpGerRLFqz z)yfP}L2usb-{#OLk0GMd20M%RKrFtav}9+Asw^Six|T!uzk&~~G@|}c4qijbwmIIw z-VGfTsYUVDR8F-*=+t5$n*WIhTGqKp5exAe_UJGYs5&-)vUNPp~{=2A8G z)K6|k1Nb>97}k2>gW>ordA_ZbIJ=pQVA6l6>J5{21Fc={**r7!ee88z`<@vVtvyhC zAw0+FHa6LX&pD@HY?}tI@1IRA)Tyn$wq|2#4tzd5VZ}t@jxKNRf{yaAPdX^-6fc0% zp-Mlt0%^GZl$ao<0Cg#W-@eSoD)BrDH1qp6%%pBD+I1vH{z2vxuh)wrNXQVoWN_7b2&gPDBMDh;II3w)0)TP=Ix#e$G~OFtgEP=T(h$^hhTX^pCy z>dkiJAEs}+#|>@G*%L+SUy5L4SeD4Uy&Eq!fmu>H@`GBTiz!q!gsMxkEY~#hVRopAucH|P3vFz4I8M^BsMKx1Z^qIi z5~R=A1j-uL5A}PHDr!IsTJKt`f3Y77>H@8h6s0kku`Jw>QY4r(xQxZ46>dm zYtF?Z@~FiNO2S)6;7Ahr6PEl{-d6PDmUSDtni@t!RGz(RA-NvbtSEd@0nOz#|HMwH z3vX3UUFq^$Bs|!v;AJGy!EU9D=uWa(nMr{sEt9P6P3lhxi0{bEW2h})AM9ulvc}#@ zUjBkprXVP9Yo7Yk;sOI2%gE~EGSiQQ16Bd4sd8ha#{T9;rMEDiCOS!z9z`@9#Ydz< zijIzto<;4e@hIl6kB@W}P0ifQjbnZ5Djjat;u+1@ssTJjrC0r}VQ zXq?8q$Bm~?162dP_2bNIT-;gx}R0mkfjygeEquh!Q3S@-H9MRK$RoF?e7C2XpK`EEcB~_bT`rN;kA) z^V^;Hv_y^Sj~lJPBq`Meb+M`ddvIJ;H5FpldG5GCU4nTffpW0`JX32}&k_>xdFE-7 zBMLgpBKX!>Z{*%&Z)42^m_yYS9zPxq=vF>s^1W$>wb1<4ZFczFDjhyKx%Kw!Nlo1e z^0V}0Ja@11yKu*XYCN~sUO`yAiu*|+cDNS#hIC}u_SU&t6D(9tU768Fh0#XAGzi}EnDP&mkiI6)c^eG%H36FROL@gi%t~L=`Rr?~ zCWw{Q6dqU~f~%akqIjd{^yo%h#2C_T^L8o{jJ1K(0jC4R^jxp{tu)_c;@+CVd<3iG zEK=wp6u61v6Y}*1ezpg6fPxhB=-|yuX?i?P0I#876u5O;HQ3Px-%5ILi(<|CkGIz& zi%+3;o5T!Yb2wlmqpQ%W8jFvEztvjc?{}jZ3ed@xhu&n(kPid%>080l^=!;VH+j9sd98c8Zkb_A~mS_A<5P?4;tVqrXm zDil|1Dp#r7%gIWx9(@pvo>4O42>)d29eRFf6arXOtWdBHuF6}59WvR&Rkbmh8KLN0 z?uA4%>n4>%i3~F?)2WZc3iimgbp;b5@K^0p<6!T-mRY>h5DOY)#d%O>nc3$7$?0IFtsv8Ea*44fK9DnX-v?Wv@ zM2s;S??In`;j;F#x5?-@%M*XCMBTcA^Uyd4b$G8{qLKJX^swL?zXpFim`A&F+V5;Im#~cWTdr^*kirW z%d`1k`DH19eS;dg$b+D@oF2*E2|K|C>dhyU#cr3 zMqf;8R9>j+NY3)^RQ3sh_<}B1`YENYk?^{GC=LO$SSVMlgyowz^$MQHX^)a4$Q|rb zKTuyUS*KF=;>$xG+*8QwpA%MzBa&x>XX@}0Db_u84TosF@|_waDD~%4;6;sKchQL zF^hyL!b|$Qb+_=2ydU-yDl%dqr=*F2o#9&Vu^o5ky;fzhgM>QdD9bapD0a1C*FPZg z&I%yNsP}d1yDoo%^dUJ7e6CCzNK8~){2^ZqQ2sM~nDrI#4(m2+VqW5{zV2`g=5@VZ z2Y$OEHzp^sZ%W)g{Du80a#Ouk2GQpN@ern}c7~&7Wx_y(-MSY!MfM2dl; zso;Yqc2SZNim2<`vaOD*HNLs{Gk&H}sp_Y0x+9xheJg6O(k~U0_KgXj6)6{1m7PhrYl-HS`zhv8t6V&YDX{IZ`&^eBAIMx)oU(J?y)H#xUVaS%b!qHm}iFH*FlK9 zcC&@>%eY^%NVtRZ%LPS^^YM!MShThM!Ki~3t~^0cXF3S+N_Co-7R#u^H}-Ta*vZpz zBL3}-m;5S;l8U;=pQ-YmU`tdy6C~RrbyX~p@E5_VC6v!FALUSCcYGGE+okJwYf8AT z#?ht2F%;Jm*aGd0SZn!a&?~2cquXN6Xq3gMSaIkI&@HvfoYz7X!JQIBqCZ~qDSE=? zef_fUd0rs7X;pW~)p1xmTtCNTd0ZLUj~+)O{$+%tjo5FKU@F#6zsbMUe;tey&-{8^ z;7b{pDzc6`{e19Eo_H8F=4o+EpZ_d25r5vf!(|H5ofS~=&0E`q(>n=^6b!drRY$uPjV5qCj?-R* zF&*m#H(ohDP?!p=SV)*KE$Cz&$%s8S8Xl%5pGaS=!B`7fnY)rUGVEs1g`9mWqca za9U&x65d&`F$}E`(1HWKbBD_=MIQoP-_3F(&`&L1#$xAdTwdZIOKmdyuA2;e{8f>) zs?EiX?TCBNHWbY5buiVW!0n^BP;_1VOJ4uV-) zT&MoOQ49E+h!dXy>`V8@O#^cyl}yMC_sx9JHB(c()4ObRz7V78T3jUH?^;(CPQ`5_ zliZVsk*Y010iy|s1C-uR%JSrKF3FZ;^sSWVKF&%HMh1$Q1&mOySfdUl4QDheG1>h$3!HP}KukyM<^f%|@}M?{PotPLxJ=(x(SJD6rkLIx5_(ytT}PNc`b?G^%R~ zp?JP;PNp#Ix$-GUacyKaGc9x_11bDU#ENEo-x)C|2A+#frHaB>2M!o>J?mr$jNC<0 z1;ug4W9%8Pf{Uek*Ljfevu9dDerlha&KHk++3{i@lbkIgO{jm)?UFp_!19B?q}cu8 zH5GPKvH~c8ffcP`4W^MUaRMoz5_B{c5_%>hK!JR*NNj@7@D2V?9I&6n z7~sh9dSn0BZ^UWf;-E1+BX?>5=j&LURZ0913cU;_nX?ioS*J4@8NMXi%W7t@ix`S# zfPnePJd8gqfzTPVM}F=Be<~Itu2$&-!J&009XSU%x1T?lWr;ro!8rVxrh^Io73aaV zP|y!l3hCA;RkDgY#M(?fFmUQnLp+Jp-G-;HQPN4E2BelSF>qKPEcpTYsk5Fmc*RsE zIoVSQx>B4=zf4r#n0oXRFfplt{Wu#6LFpptsW@$xWJV!gJ^JwKV7t+Na|n+zc$y zmF`{Bl)5s*Qm`-(ZdHcEaLR%$tV?4 z+}EVL?or{N13CX>r~gwkJGWVxPoKb2#~V>IGjUHpXhv0=@F!R%<*#qNjr9Z6mx5|g zyAS8gAM6{m85GjWoBi=!egfxsy=+~suqQUNd(Ao%Cz>!5Be&56pJz4W>k3qP5f7@O zWlF;ri!Q}pgD#f!2PMhGt&xj=I%l*!NSDDrpZBs$@&!PXIvo;$3)a!kqf>A(0ku!E*@yHnyjd!Y2bZ}{6bnB1HgywrfT6fdb3uP}+8T@Wo4W)GK0?oI zNoonGZT!SFjS)?P-XLXj_dXrVO_y5@7gVY*9+eG?yQkPLFrO3=V~`k3m>Ss+b^5Ff z=+F&9Tassq(di+P=;)3(=^xO&D8;`InJWp0vttD=tXt7;d*M25fU~MUzZF)6&K!O^ zU?q$Zm%}*2dckLL&QizJfy0o?t0BFv7KnfV1$uXCXxOh6m7qp7_oV|bhq1yD6$tH5 zs{u0O!(#2t?GM`eq{7{zZ`F!|IdW%qI1&c;o&HvI#RlF}S%q|=4lwmWp@#jH>@77m$UAai$)2P_D6yIfsr39I>8)T=*!<6cYyBoP)kGMH&o@ zcnW&?I&!d-R6Eg0wb`H&BsrBll7f$x3X-ewNbrha;Z1s&I;bxegR7uy*y!s48FFN8 zZR+lq=*uJ?j8k#v3h`PrkHv#ols^a+75P ze~DgX0;Gdv^mDE`e7)Hu8Yx6H9$h}^PirK5nRi-aRC9qAloa!1h209in$zY>Ah zC!|M}96t$|X>KS#TsBGXr0$dwWW)YcWc-I$s_E_3^g&>w|bM{&)N1$H|iT-va)3`Q-2~cna_7_2Ti#U^G7bYa)Jk zKdP|RNZ!BdF#N#oo4i$V?>v{>KV`Zp3INC_ zp^vvfKiopqos^;=2s(Nv1x#?y&ym|5t0SOfMpZ^NM$)ZiQr(>-P_$DpkYn4lq$@+Q zRJV$989rW$PjyT3fJ$LWpROdjbUEj3+e1xmBp)a4IJg!rM5Pz4$HQUoTI~k)@j)&P z*^NW1uOeG916KiS5+5jT;^V-*uCYOJUG!aOS?r=klViV5`)|Kz5(_nTJygWusY4k# z;?)ZMM|#@ek|F+9JRNUR^zka>{pmXv2 zc6;~z-q+WEyh&HPcUqVC@4fE7xIB2Z_weEB>AQ_T-uK?U+-Sz}t5>HgFHeqzW*^*N zTY7MR^`0by`9`;&4zQAF{wDb{Nd>$*TNP=7q zxS|XaLKsZuhK>#2)+7GSGj3LuUp!l9UqpY2A2g=?ah!}}`Dff4p2gTJie;vxJo{cs zw!JhameBOJZqM?A>bhonJ~TmbvLU!Lsc+Uf+;V(aAzQ>fgHy=A8K! ziJuj^yi5n>9T{>~oF9<3+ulpc7f?18O*-)e>NVd+7b`24#kezwYtA+FLYCeUl=IoD zMQ_RHw7-rX8Tdd@5?NA`iu}AK=hO4`XbbDOg~^NQ^(uY0Gd^BU82 znqB4GabER>EX?OChj82(?L%GwE4&_G%;O5j(;+<;{T)0dn>-ILaNNQVv=7C>Q+;)% z`K$O<<k5iw~fWBo=MQva{&>}Tx*A>-{2?0euikid@N0F-TE+jZG8c>e zoz~8J^rrnK2w`G1AXCex)2EFl7V0s6XsNtYwf+xy1WsW(nz$E_;Z1=3C!Z5{I2kut| z=A-xhq-t-K$I<5U^0JP_r7_2SFCLuMv(f2dH|yk!f>-Sd+JC+ncP~IS+g-qx^|Num z_b;I9gleGe>!y@=k6IKQdDD{<+DCEG87H&@0q{Wr?wDfD?l%X6VcI#@U;P<}yQ*df~qGv+~$V&4BE>urT;-pT{qf9Cdl$9W{_@WgbvL716o%NJ94~cP!6K^AxGu(L@&i$ockQ)Q*Tb|c4XmF z^W2eQz6PX}{cs;6D2$I4~K4oWO| zTUvXaQ=XS8qmh#}j5BtiE1lu1?qlm_v96MAuQFEJS;Vs2ZU&XWB%m=ZwtNyMfmUIB zN>Qc9;2a=iPA%kv+7l0pIibq4KmFHWB?T{tE)A7Thec8#mWiQJ(2)U+dP^vhQzper z2dUtmvnuhI@~2=kt7r*exm7)}nFGP$r`;bgj|y?NnaZiCXT>fXh{r?gNqn3M;uLo= zr|LMP;h#mXQHKSlNtsX!QZr;&6dv6!lb9^2GN=qQJNGD|&VPU<=_haeX)8TV$GKUY zFV`SodpheoDp+Ee`LS2mh@ne3t7~E!PKF<``7&?Cpnkon! z0B3t{#ZepSDWo~FH}zNmLjbm9Q>jHT3zN88XlrFytd)PMCb<~p(T3D~KSbR${-;%B zxzeg9RU^S%jQUy$kYsyADW?bif--;om~)2~$0TJ#xb2=*+vuAC2&(l4GAKRGQO6MBl)E}<-vkl+UJD_s|%iq4-z$*9W6G*M;BsfPspd1>`)3W`! z%>SdJl9A}&GB$*6(i?*xedU$yCgJ9=i zki{hW<_QOaAfOd|F~CE03P0m3_!+#?u0H7?JnOI`XU^x0`5It(RU(xl|3yUzMuai~!TAKCE1*bAJIK zw)?Xg&kKkjldp@}S=?|q*}XR16mbUv!HLWL%Y-qj3FxX=`MNrsHp@~t*ikeXgA+q# zU~!iw?i@0iU;`7cs+I4&qi;;FTi9hvedvUXz%=VNTjbCZ-v=<=ig6K_b*o4ia9p{? zVQ6l=X+J-Bc`MrKb)&ubBp#)t;yF(s+6c61-3fY`^oP|L{y=&R zXE~Lif&2Ot4hb@MoG0+3P&XX^B$N zRE2|qM6Lh!k?@e^v|G6-iY4Z%^VeZ;p>Oz4jUr3L)yZ5nX>~SCktT_Gcfm#XjMV+v zjH9lwVUZ^`iLO4IKehXWVjR(hg3pUl9%p7|X`ls%w63B(d-xf9gNKlBliV|^)#_A0 zfkTLNS+OVTK+NZ?LisPJ18@ed`9RG^?^?hy#^@r-s1=T$&EXp}f?y=J=0ci4$fOoy zE4<~7C#T@z@j1ST$sHxCATLDyEG*a8$Tq#O993@Js#4lcIm=tN*s=sl4!F?8-wV7G zM0xh0c%UH?p1S&%AP!K_G00cpTdy&sllJ3Y&Q|WB+g`^z3m*YVXqw{hU!vuu=$Bt~ z=hbM@eKMt}gHHha4LsX1mz@-V<*I6^{R3+)L~6!^B%45Rdbca6+t*~2fs;>kLx>6L zW3ZwIWmE7q*=x-SQCKpTc?4eV>|k@FqEJUkz_@ z^i?aW*yFH#`X4{mmwx%_ugbH>Pr#Zie!_pMOLu-+)Cu-WaOAZT|AVX6E%>tKuD!-^ zzrYzmH9(=T*pdXyFuPPmYlL*VjAzK|)y}R7&84bP{8?FEa^_&AzoNqdVs&;2m?r)c z$qB)nqqDktoju#uPoJ< zP1cp2gQ_&>2AC=Amfaa%_EV<~N9X{z zi=P?5d|3Zq{Xa?~q=j zKYlG%S>%WWR=ow}epX9GCB!cM z+sE582p>3VTTs%Oh>oG8D?mqALMB#7V>jue21m?S8EvuD@@RBatZN9_ymZPoRQphw z!`#(XdwGt%Nx#Il?YVHl#H~4oxvbh%@!g##TJOXx&Tf+NJX{SFYJ6+70X~(QDLZVCB|6BQEC-$dUBUjyUW&oBs!cZ)0)7qcCPRpBrxf;~LP}X+ z;ZP*q%`$AFb|^jwag90K3lunVvke*uA8CW~=RCTMp`z_Li=O||+=|}s97G4N6$p6% z9k{Z)#bQiu3g4YB^Oj(dcL*i0Ye$~5vXQdm^I~!d)dD*B09Ij20=AjA>2Afq^+PsE z6OLQ@MdjQ?3|7l-Uzk1QB;rm>C?Y6`=&6331q; z#Iv2_&jIzWVWaILftD(r&$>hE%g!wN-wQADX6usASNMA9AS_`gRc<516dT|qg-6Xv z@A@RA%x3EB%kX6=GLry{g_w}$XA2}B$u)|(-SX6Lqi?;W4<@YVTjO&-44*b-%ldGr zj9K<9pVcW)QSim;K*HaDe&a>!K7e)vPG%Ax9tK%+)gUC#t3*g|45*)TYbH+B zE|6`fxJ2gFDTpjX+6_O8bHprh(W`@(FJ(sAb)NR>oDXr~9(X6;Xvx)t7=W25`OR<+ zv$>d77Y^YWD8g%MPAbDhH_3q?q1qp#jyl_~o!F@baB_7$Gn3SXUznb%lo!0#6W&J9 zntHRAR0TJ9Q;?T!1P45=z`E*o-~t05y30{IPE-zJBPW|6cgDl4NN3Sc_Z8eC1|H z>7;cH5MaurQD6S*tdNLD75B}MNh(aIS`8)WA?T~m)lIB+L-LyyI@DF^L{RL%a#2+_ zENCidnz9Ah9=NbER{fkXykTOJK9pr-;nj}+Q_xr8oIzlNdIoA18>RGh0%|`V716AS zHMpgh2B@2qmquB=G|2|5x5)o0?pLyI)paA03C^*#^XljQsMUVi-fu_yzi#eDdpmFT zb#cdYA#C)sZqkb;!(2%Jxh&`d+G5DVIUFTJaYuD!Z#m?Z29CWWD?+R>0&`;ii>_SI!%c8r-Q;XCXj1nu|~N* z%+%1Li2U@pM8tV-0`$a-4@-xr#*<4QB7}h(94>o zI`MvCHULo=QU2!h;*(M(U4djOS%E7dl515ep(1ta0HPer0OnOr6QQ3E;wkVIfi1|b z8tB-#I$!BfmBnRC(;Jz>g{h+U6?ZCLK^b^pPbFWfSg9>WahRO!N|PK!2pui@`+%f| z^Kh&vcZt;oS=OopK>op8z>!**?|_lbbZ$K@2i5ddw| z*3J}C5MH2u?~tc*z}gs+qcCbn(P%oR&#+N;mO_P~RgMlml=Vk4sotZGnD%iJeY`E6 z)Up0n{g=~GJm})zA8%t(1&q-_@KH%AQwJ#sXX2Y>S-_f&=t?tFV5q}L?qQpcKU-^O zH-H`=6pL)+YW3rEvcjsMzQGoi@+ygT5v9V$YR+<$LWTlPW_C3bYSd* zcL@k1j`6sa1-$!#M6na+n9@8Mkdr>tGAqzY%629;?-y}~F@FP=V$bd9RPX7fjV%^s z)+Fsu{`3($645t1FkD%)(YuT`6kzJIy08~ylG6375UR4{j1I>)espDFWAdY|e7yZ1 z7|9AWjJeDHvUrN<3$-`Ut>!06uboPKwrpY=8EjM-C6tN(ylT&GJv!$TJS=RkpYCS7 zSclju7(MM$fQ4#9WdzTpJ{F5#DDqn?Y<`{2CxvZL{Y0s!haPhf%D^+KE-?X{U5Zwn zc+@qC^*GMSLSGg}!E;L6VCGbcKX@3N$O6houM)1$iA|Q#lTb+(N3d}zs9Q12psik! zSB9Q6+!@rf8*fYk{RQ(?b87#B{Y$RqLWpQ}j>JmFxlpPVMYyUAb7rT^RF%b$X0tkZ zd|j$cJa0f@<%_qnCJW1j_7ke+LNrg$@aPDQ!N2*n$M)dleU{c zj241wLE$%M49K?`wNb=*-eSWUyOPqi{dk2`nj1YEWl>~KU*tG5CYL4C$}%34zNMng z1s0Hu4YVXlCfIIR!p<^2-m|5Stc6ve%W|1=ZIb$2&e`@Tv8G+P%K=YPA+a#{RjS}j zsmdR|+*XefQWUbKBR)=%sm-!j~M^Kuz(&zK!`K}a8 zItZ;ppGiCmDrvRtfq7zaZ7oZ?k17Q50{)A0vWu>3yJ?gSA)*TT67qzr$}BDDkEIj= z(wN;%M}iqDu*hRs=$x1ugyoT>Ek>6Bwpsc<`UMN04#Z(iMGwEQa%xc}rIOb=8*vQ2 z?|H5(vDc_{_f^~<_E1*ynrvxsEizYGp=qX5?kD53tZP@H)-nt<6Oia75&EP6QKC%~ zXn4{CkCoG8{94sK+o5d4<}#9fQ>j+P(Fm$pQD0}5gDt=3A$lK*8yv!(q~js{vRn_f zR0bQYRRGMe#3dut3(Ef>&^UVu zRf=I6m1=ze+8n4RU71+|lAVdYJP&sU*JH*nLN>K28mTv|q9IjRm1QBNN1HNRj59jm z;^?NMNV1-?wtbwEyJcU9)2aPkNK65ST#!!J;o91WqA;OWg`$Jih32xSd1Pib5*ibq z;MpsN<*kza6@J@OrMHI;+b{VlE8XISWk3RLl8{P(+be`ONanCSjNt}Zsi&lx#-#Vg zS^r7oBoKfEMCww~YBXw$V^Q5KmFBs|hzmS&$gyj7?W+0G= zPBj4EL+SxHLeSRgoL}eR&w*D}E}_4+-$&06_7C2)qwRLhs`m*6XesLy21aDC1kEW`Yq1}M+EzH0RBLWC&?mKZygs(BA5;Ytj$jSg@wSxf6V(2hkkj1xk8w$ zO|splL(Ul4dtApDJOL5ok66W{wXhuK8g<9Wo3UIFV+Ph~=^)I^V`2^C88brY4^4uF z*iNueoJO#SMoC_X&=h$$m9QkIKh_HM(Dpc-Yf%x82}9v4lIp}=D`g}$3QM#OsHiG? zbVb7+FjMt@_BHMGVl3>D3>FUdsJzF!zSX5rqEAC(B)5_4Dt~301%$a^2NCohGTBM z=Wt+&$PwwriWbL09z>q`8ayb#%Yy3oou!z^K;3%ibpgAXjk*aIhk$@;%o%5DWyo{{ zar8g`=ULo2|DXRey0r6Hpo%e8#m!})9xGoCdDt#e%A*RmuN;GoOhr7bWvE&s&b3QB z)9ed*4m)|?i%+pOd~Koo6gr7yxqGLl5&2=UdJbbkBGin4uGG;z?fKRuM%4}yJPm| zxa!pGBs(a6T<>L_xR(%KCKde5ar=Wuz(~T1oD&VW6@G0L=L^d6rPSu;_cuTDO-ZTk zXU9d)$^KBhsz73KJ4q>R9k30!8}4`d%Fx_KOwATNuc(Kj52jABB`5}DL>J3Kf&uGY zRw3!%f=S*OyX}*n@HzfA{F6>FECU;h&Zb|M!os2X{5Y-+9Rh zZ1+yyVa@eg_N6DwvH4Sw`H>(bc%(M-mr0&OmcmGte)OgKk*0)L=0K!htONne<|8Cf zl_a5`4l1z}Nd;7t|De`GKx98;gIX)V6!B-)a6sE{1 zG&c_RH+NnMNe0v`JU2v@g4RGM8eL}-$a0(w7AAufe1IZx`-n?TFnknSh<$xO6aS)@ z9ml;-(zRs~X0r(HM_J#^UvVO2-I2_+h7BsXO^^r%t4&nF#@|l|;VKdpT`i*O){&?r zSN1DS%xNr@2vOY0o*Ap`18CoYlpEl)BK)s!18)icW@Ss85&h9PEEmF-r~FxT&D5o8}!AV4?eAG#TN zLYaK>^eg!MSzD7&*&C7%%>Mj{y~$_V9GLAKyQQRUSjH2UBMNX_cCVh(nV?PKg*Y&C zlBR-%6i#gZVpNsTNjyCj^Q4SU;zpvBPDfS8DvixhaVZZT&me~D+DpdLKS%tfAr78Y zsPMNdhCIP_ihD%%i;*Par|GK>@G~#;uVt5ugL*56%omO(mG`o7{wC?i=>Ycni5zIb z9l=ZtM|kRd7=)&}X&k5uDGBOW=J7bqPe8N%Wr87iKmCcSHXSHj`I8r6zv3m?Q(ihA zXU%@YB>7KkvN{O2`t8WIu%N7sSM#KEzJDe-@3Ra&JC^GA;N=M_2vF}JX0VsUqt02S zYQhLA6$hdVI2TC8M38-K_l$s(pIh3?^@z-Dki8LA5J?Kw@F)d48N`mnQc(qUy%HG@ zDXt>fS1%rk!EneN&p18M=q6}IP6`T20|rI{h+wsPS3++t`oJ^Ns~L_6s`$B+}MwWn3yBGMy} zu`aFZS89vD`G%F86>L{wRGF2x3$#U2{H2;1hcRo|oR&_*>qg+9)JZC$6LAp$`L8;& zar_?X9TTD)uu2l55GWS z1l}p@7`&o@ECyaK4(J2xM%H5+6pAW(JZJBwWFKku{4&_AFV(67HkF3qvP!X$i$1c z>fMbfBqW0^7M~x^A1wGTNl(uNc~I!2l`wx&5Jx(`X7ya2nxr-RRyZ7Yu+n;!(WqJs zgA=m&ADGeF4)r9@Nh+>US0nSJyyI*f_g>2v;6*&?S9D*@8(DpOtE$p00ziph*0;b? z&F;_6p(Hz{df?Qtf;n`x@WdL&;@z>qV<~lh)5?_s?id$nl&rL`k905>5E)oL<~jsg z+VrEp)FTVSq;40$qxHP9JIjeyHIw#dnf)l&>5o3-^&EMirJ8CiBu({DeSSwx)utwM zdt}6RTFJTVj7!H7-sm|!vYH{4RvDJWYG5tuC;wJG`(CdROdVUJ^rllXLhdD}z{|rC zW7!+kL&q0o!}dklxM5XvS(Tz_FX#84Q@k2oCv9&yWekU^xJb>!*aILTQH9(YRrOWm zGvcTr?uKMk^_J4cSDqQs3)iRlSsjsnH0g}9(X%=Rn9%H~y_sDoCEihfM9x?!II$XJ zDaDW+$9dWzZ!D-<1{EuZ0{aq^mR@NNlR^D5Jx_;8HzlPZ{91esjXzZm25BejCe?p6 zpubPstiMmMRe#=WdX4SZtlpu+OItT)?%tSB+$$4R0(DqqQ%q)K3|ZFUHWbgq@7IFo z7~{jD)>-Gy^T-J$DfD0{(W4=5QCgmlSk_R4H8bBmyWl3JhF{`W`eV?Pr;rm@0l|4o z$>g7!_x{`&CU34_1HyK(aRt~GFhJ(jL&!v3W)BnV6GQTvm5f>g^LaXohi5{N*N45L zJ@8HoUWgV2tDM$z`lzBqLP0M+f~2^YiA-#fiSq|?KcKVN4{<7wC#R>^)#x(5F2Y;^ zfWeW;gZZI;u1>u%qW9vj*JwgtSm5G;AOy*v0~r_qQ$H1!yUu9eUs93Fw}qJqJfQM? ztyBTzWI4JPe{>S2n*d9x$4t2p?C$yIoA&da-=o$}dk-><>>a#*z4K;25`0>( zZaRZXDe5cVSf~rAz(+cA#4LxU!QWN?uRiVagJpSX^HD$oE=`)AK+H!x4h-sb*ZE!y8xt{8}!C+X>A1d6ON zXwC}Gw9<85O!rvcN7)IB-=k+jy6tD5$&V%$j|6=t&jfJ^r2_MM*DN-W6!Um9?t|kI zI3_{AR3r+bAymQQJcWtrk?YtVnI72&JEWjieQBsWL(Wz}7EPWFqV%|C_td<{SxFvjSFQ#~T3K{<_jq~H{K{Cke z$H^kp)XW!6Wg;-%!6jAv^oLpOh#Okebk7;*xR;#@xqKjwuedJzivnrHN5d>z=w{;u z`f34dTIUPn%Pb@qk4MBovpW&?f|b)6u%!JZx1!FGIZzvnTZlfia&w_Ca}nZGyeaXo z!eyx`KTQxC;cS9Qx=Jpu!u93k{3LaX#eZ9u83Dx%?|aT2vP21KOnzLobSEr- zCwObd-9eJ)UTP>$m||7I!w}gkh_OZXJpnpni+YR;C;-iwhFb>eMKZQ&+i`N54$ulA z53!*LN`a3=PEbx|=wmH#8|y!u%H4p%Ngfn>k}3ny72~S~QIG~r)tROsW+I`(gAFR; z|3Zg{M(0H@Jfe&|O4=Rl88ossP#cfEMG5irM9hu=^0GPDML{=#I1}rw9zcvg>ToNNs8wggQ|st=8GyJ*7Q|CK2vucPJ$Y~78C>vUZ()D@JgAQ z5|%5_L=9sn_7U$`r14CvcS*dnFdtydA`1%7DFEA>oH*N_bMjqJ?~Z#E`2ksu=&2094D5zOCzLCWnO$8kuL>a|kWS^24R} zsj9{a9ZA9W31MK)GbuAkvCRQNUq5+5M8Mjw+}bDAG;nrv3sdPe>q5<8&< zeK)qjg7lN=3sOx(SjRAoUdrWwX^x)Eus{D0QdtnR@nd$h>h;ngSWR^BR6o9YiLRUv zzyvUgQ4gn#l}n!eh(pP_6}|i>eVJY|57GFlvMd$96?#Qf&K;17i!JGCEkyb=t0}jG z$aI{NHHejK0zoJu7bxpv$G9lT&f_O?P{k3rhDW;1;i)D;W|rdr>u}(-O735+77opjPI$4^7x8Xj7N%2}Y4#3c0|h)jBL$ zI?n5&6L7o*UW+5Hf$&ID+Gk#R?c{XOpGT^^1AFxBnIO50XI57)HIzR^BOJmZZIP1>< zlz;eCPD*o?&ZvrJ8{xJVE!Ftg)f&sMfiU51`B>nGA)!T|9ES8tBM|${+Ke4rF3XxT z_RF%|@oyz#Z9RKz*~yBQt`E!;)m}C4rpg>veG9jSEUa9vy;vO1-fg32_p>%%dZe<< zfwxiY<#EVXsJ*Lr`Z-rA!0deM*z}2L0|A3piVS>gXW$5AT*8ZQqu2BBibUjPgt(?l zln1d!6UMKt76n!jkC5ppz#|)W9*;ZwK(ZHntg>nf;!e)rou%U>AHt0e7O|j^tp}A1 zjF^|Brl72j_*@YMueI9DdswZ<;|f(~^=inV9dIa?#E}dGd`j*STFG%%91_usCMjZI zu0ZQvNyiZ-Jt()3E=oknuwJg#A~pHusX!r2D^mZ~x2?wVQ$eID=o5kG(!RBPk5uDckWOS}|c5)t8{u?=v{m>cKiIWlxbUMisw1iNg zZHEGFqs{$jb1!PYZNGW{?$`F4HjwM__&VxOI%h?H5&#L0)0MeqcrF4DWvZB6eg<7| z;w0#nxasZSUqh_g1lI_dA0mp{@ zP_`Xxx-)tiVEo#fWK6HD$iJS#ac+`|#BhY_5jo+tSPi7m4^J*6m6EFMb6EXKSQOanQVDHz$LOzo~>4l_!&hzHem7Qh~&ol%4!u?LLv z>p_PP+f&1;)f-4+t|A4#Ip*QtA=@uj?axdJ*JK(`wK<5-Df-Ij`jFNTPi0NHzuYpb zOlyAv;xlyO$Vxg$<%HXABqp%|629(Q_K+b`SX90GhGBtOhXjwhP( zEE`|d;j$czRFm(#}&1(c~CFvEnq>z-JPt4Yb_duT_&=Skhicj^$ob=R< zj0y_T&e}=k8*fb|#?h+Q zb2exSsr8&Lq^_l$=%u-U0NhdS3o)se^5@RT{weDdNNNFd)TH7xQ7dX(Z+3-b3~~BB zWRQChe`$48`FOhnQvvOk8ag=byfeyrz5T4h<}COwa14SIxQDMB@;Am6=KU-ipMg@O zI8TeD!8D~;YK?MGvyFx8Oy)w4>okc?!4z+Ab24oBIs zxcsl9&l3z=0R^i}iQ0jD#c1DvkZHMY%%XOkO(=;QxF1p(YpCcKCAs)~9G#9P{o!>K zA44SeWN=Iw;*2^ z!UXSNXOQfSwuLBV6iF&8D`*6IUZD0f%fHfjw49yN(W^K_kkjRTlh@CmIJaHsHc-RjT5Wm8z5VIE|Xu+vKJrTr8F z2%rj(S|rpN0F~E~28E3L20%f!^8qB0jC0fg*Cd<)?ARkDS&SECA(=!bh8Sc~{$&C? zb378#eWL7Ai^>@yAiM5W;%Ag&`7fC#G-LrDV-`2avU!^&4xNYWNJ6$i8NO9=&=%!J z-Ou(^6!V|o>SOs!j)Hxy+bIco3PYApl;sj-c|>^vK$G*&B34#fP!FJB{T8HZ5h%pL zxQ~|;z~v@R7nbQH7n>=>HI-U7<_^aYD{q#u&JvMGi-^-wgJj)#q2S{_SHNifXtk%{>S1w)viB^8Zdl~eTLuVMPvY(%B(K8__C5H^w?{bvH=&tMRg zulred(j$%Y&-#G;EJz!@sO!&F@1XNx-P0G;yP6U9PcQ0mzbiVU9~C`8>_N`E4n4J! zF%)KCqf{S>l~#cJ5nPyAt5}?vXiokQVkwV^UPiZwB@$gNbg?hVa1F1~3|Z+^qm`xQ z)#x*DNyT7q?JL2d z<|gf^)R;MNP?NI>ouIc12x{Fa0fIPb)2HCuPwZ`bM$gve2alp65k>l$b{CF&f|3Ip z4O4(I=pefD-lI4nXZs(~C*sh!?YHA$pm8pEeYf*u9B6!*#OK?^-rv#Vl8^R^qr9WX zfseZJI0o+A{i-FOhgO4d!JA*8qyE?eqB%qa#d<26m-eYB#(sP{W4B}TMG5SwG>hp{ z1B&&RjD>_P3x?EXF_$9Bs;zf=G}vHz6q_|`k77a!oVsX95nbl=<2>ntBn1N?*9+P%BA`w#C~y)LgouMg*e{OWRT z`R;?-!@KrEmzTJRThPpiJ37OAkyND{{#EXidQS&!_>K|5G<(C~1DVv(xVBbMrNj#G#F z8T)?%qXb^wT@xr}AG_re@YpEj?RE8@ID-Na?yXq8u41ougP=0S=KR9!&+zbP-|{=4 zFvW`HgH9snwvTBy!^F4_deh2fI_PGX)uSV|qJ`*H)>WQyA0$;IF8WZ)l-R0yCK&k{ z+C5K4$w_wQG<=7{S`A;H#e;Fy|7~x2)4lj49;MUUZMLK3<(ZnbyQj&NhO@yF#4rn* z5>D^3(YeeWF%!7F?OU>FV3*!fMEYJQ8zw&Rd`}kyId2bBKSWs0`Dp?Fxu91#2lVpi z8xjJlP{Ro>UM&wEJgBX%tyskE-pq8s-|0&2t{~(0)_f#$xs(pjg1r@oWZ8|Nko4q< z^z!@bujp3ABO0a1YgO%9916BLlnq))B?(z0DX(I3g(fEoF*zdoaU=`U^-xvHibQrN zRKq(HUyP}yj>^ueKgAdiaeG0MYgzgO(@w%Xzf9shT{s?Pm$|?umU<+wJ9X!%w}SFU zKECCW)G+0Q{j4a*#j|n0SBJ>?`sGa_NY z#^c8VyPie?{^~rt(=B+h|ExelxTmr2`?l&|%5v%7lhwMo>(!pLWYZ%fC(suH`;+x( zI|Daex#1DTSz&?IE+lW3@m23un^9|LJEA&VE0}b_0Gs03)PyfDFYA}9IL-Yxi{h&V z{Ayuk0p>>QLA=^*Ev(#ou=G&;Q*}C{D5-pMdWt6o(@E<&O4BLm0HMcyPU|hcLw1}doSOQGkl0rBIb)wk+ zI2Te}OPzN2y`-?N``$Q$jZnyzmz89=O^ESzj-W|rrgZJ_(>FEh-Pk2FQ# zD?z6oSrOg)?W_dk$KsidW_Ro2|0zD`STJelUnYX-Int@(IMyA(C%f=ouHeXYI^Q)| z?}*D^cT@SRQv?CiIH_M(!z z$iIOy{0p8U0|U0Vj^NBBxI@(7ZvA2Xq1vW#w`6;e*8|HP| zE!|(M7P|XEZ0&b5wg#ndh|%Nj&(*3;R)fr*yAX@4ma~0RKMgW~rC*kxp#4_((`=s}Gd6!sJA8r-{!yplFt z+*?_z-Mf3&vRbS?0Bz+`QCq2dSzWPvS+1?ze^`59=~7q7aOgABK|cpVvbMXyewOb) zs4YLRZ8Hzo0tP45&+@%OKTAswYO4>Htof|0m8=W;d0=%z^I3UNTe@rav%DP8=0ZQ4 zg=NWgE!CEnA6or9D1-B6VOg@Dd$rZO+_bk=zyA>WxfkrmSr)-(?LqDS(tXQf{P6CS z{d&-ZY*a~C_J{LXUaH+&UA6jISqiR8tI&f8dB3*2BvA7HGDm^c`d!e=-@7{pPOjA+ zJh)$bxNKYG?%oUN_k%cjuXgw0a_!!|W!nUOFJR&g;^e*B+S&n439|OX+Wm))x&Qu@ z`4n(c%;(-}?cqJ!czqX4;t$s5z)3jw%e4o0`MLz0AC}{G5humE9<0{ZmTmYvoPyg$ zoV-`Nw{)+zbl)~x-@jWjA1_WqKP$DB6`Q8rzaOF@+Gd?=bIFsit%X!gABr}X!>VK5 z=KTTLr=JBQw{FD^Ffbi440j9iyZ?Yy=h0lZz$iIQu3WR#a_#>86+tg;+!JtMBW;IsY+k<8N3O)<9<<%u|H11kt_Aa>7+?x(oZOa&Nqa@FI7mz*0<1z5~$=&;<_Bd=TRp~2B)0-;Bcje&%WH89b&L?tKK39VK_2t>V zSu}Z8x%W5GNgGoNfG!}5Y;m)r1J-2E(OFp$$LE24Tdpn#Z(Zx?c)Pq?Te~Zm3+L!8 zua;ggl!t0u0v*c(xd0jQ_GVClL;@bDtb$|LU7I&r3*Y?~RJ>i@6+jk5V3f+*?c{Kxl1gskU;@SV5*H??swi&U8TuIZ9knE8wi40y1X1qEzd7?PSUFktMV0udvtG_Wwqt?>&$(kOX2xaq$6gNVLo=K?WIg+25KLHQjz{}WCg z1?bMRk;{A|_xvGI<>!y$J8rs_{^+UiI)s7ft>Ss~ueNw3?G@gPnUj;obP6(l0fYbu z8(LjiDk>yrV0XP;3bAMvlr@g`^TYX-EZ%4c0=fkP`D%yxZ<^hfzfIBu{E0g+gV^9V zrKSzU%GH7)au|dSlVH&*6eEVA&EKjRh6fpL7SZ%5qshUkI-%gZPoFN6<6+!6|3vRT z;k!?tFjd1NnWAAID`0(@2vJ@~>9EK&(}!&I=~IPz+w96q4M@JDx>-aiS>?Stz45GFXrR9*bbTZK}YAIBfZDm52tsiNnxn{R5KXa$U7tbr-# zS^?YRa59Ga3z%gRjH}pFRn5IW`>X-BG$%3KAXB0IX&2LWVmVRwT`!9v(I|f}=e~~l zfyMN3v+%R_RnnP^Dbi6+%k0|6u{*(>&y6tCPA*WBz0@N2xo79AW*%=OQbJ(_nWjJ% zN1%S7nM$4I?gwHuA+AheaGF37Z@rQn-TBYrQ9m18tNuR@JTt08S@nvZGj^AfJ2;h0 z|2P(1RbUg(lWRaq-bC(HdQ$OqomEWR8hj3JSkWziQ#}P}r+fZ5mKOxA^R;vvwp!Ps zKO^H>ypHLPYXFgTHrEfL;bHU*H()IB8PZWa5@7UA2yF}soE14AW;>vG7pypFJDRC# zZTdZqD3e>VqlT%m{`w0KlFmH!Gkf`SwL-I1sVplA19(}Gg`NbxQwR7PbQoA}2Fn$n z*U&Q?_r6lNn$O~V=W?L-K$B_tP1QokPoI)pQXEJZUWS1qhJgm_1WuKvc>q)@8hJE? zrl3vnOTeNF%2fX|P5fttE{H5sI{euz_-ED?B{0XE=n>DM^wUo~dD4lU0j!5=-M17= z&D*`?FRV{k$*xd7FiJYK9e>V7+vy-1y#ac>_#YoXcJF-rScm^Cnr5A|crbtrfFEzi zz2RB>@pkkVB+5y~>d$;knag1FDr(zwVnA6X`QXjVJxtaA8iKxa8A8SDi#b6kb;|5- zCo+fROV4CMBe#-W5(C-%pr={WvpjUFrVD}q1w#s1W0Tk|#9|glhejsU!(=3xxQML% zsr;#cCHA=vY3(W(5M{^eq2q6dV~TqMe{@>&qrGf2x?ZPxK%~_F=}+11Hx*S6g@1cp zS@!58f!v8*v2TOdy#&$~sampQtb7_{wq9^`iu>_bAs<{qjre|D`bv39!iuvi^KZc{ z;?8&y_sr08iJh#Mjn;YcVcDW78$5vrb@`B2c^L}Mfwrh>GNSRvCMjB=2lsR8!1=o5 zdqN8*37UFrXFuZ@z!%%srw8kVnWH2w=cH3%16QBbKP(+`|7HhJlqO#d!~BhY`U#V9 zZVWnSLO#*iI&aq}18Ti+JV|@q1t_o#g(t*eXbUEaGDMkWByqjdi}M^ZRMtmHKf6do zC*1*qK-KZW*1lfHS@)WK9e2CV?B$nos;%^b&+|gjCueSEiDGVoLmLYTcT9;%8Q@r( zY4ZoDie}#vf6=M)0c)r+K6a!|0Eg*Nk#kEDd0-Jw+=6%)iM^ia_ z4emJ`>Og6nj)7md;qyM52vT@1SnU(cYGzMJb$-YGh!XxGx8r`{0N432LNo_S2)s)n zacFcI3*#aToRD4&6k( zbTGN1KgC5S?j*QMur;R)!+4Y@=pt2N1V$FpszSZ7l{znU^r(VE(XCXi4=4Fq1qWRa z4FA2mylyuA!S2fp#SHj<29onHaWxM>y2_(E!Yj+!neJI<8j=Z5J+a@aHyDz(CAR2^ zJ2ov24lq%Z4_SU_zs*okJQYI-3V>NOt?tD|iNB$Xs=K! jq8szu>mS6Qc{Uk!k~dj4zP*0?_P75Zi0s5-%5MVzx}_Su diff --git a/public/app/settings.css.gz b/public/app/settings.css.gz index fd1bb0af49d6c469ec2ac06cc892e0cfdae52fb0..2165eb77737397be1c62a2633437a67b5db3c130 100644 GIT binary patch delta 15 WcmaE=|5Tq%zMF$Xc;-g7`{DpB&ILjM delta 15 WcmaE=|5Tq%zMF&NO87>$`{DpF3I)Lc diff --git a/public/app/settings.css.map.gz b/public/app/settings.css.map.gz index ceabc673e8e949b19b8dcadf602cdb845f7ba471..6a276288924a0077aa8247c2b257d266568d0332 100644 GIT binary patch delta 15 WcmX>ka7chnzMF$Xc;-en8x8;@e*_Ew delta 15 WcmX>ka7chnzMF&NO87=L8x8;`y9A2> diff --git a/public/app/settings.js.gz b/public/app/settings.js.gz index d2785a3a1fd9de38d141861ba406be9836f570b5..e8243a6f85e8c6cfb33b8252801038cd2d32e4ef 100644 GIT binary patch delta 15 WcmbOiF)xBmzMF$XcIHMl2^|0@_XJ)5 delta 15 WcmbOiF)xBmzMF&NZumwv2^|0{Ed<;E diff --git a/public/app/settings.js.map.gz b/public/app/settings.js.map.gz deleted file mode 100644 index b25287f3eb2c17585d22230718f0d24e8e00a07a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 69420 zcmV(oK=HpHiwFoSf$C)f19N3`bZKs9b1rIgE^T3O0POwgdK*WRFo@ntN$u$uut1R1 zVq4VKL;<2;ilQizmT8GC7J(vJB7lNW02kT%u4Zmve$L;SJ2_W!G9q$`%*rf)lI-sO z&hhiURG}*OjEsyu{=9vWPKqoa-Cn!bxP6ih(%Wmdi*!28MyEydV{yB2dzg&J@JoDn z6#j30ef@qc{>G!0_}dw@8oTT3yN%P<`ub_>(WCn<_|oWzPmgxiJHI!E?e+DyjaXE` zm-N(KU+>b-o_Kn6u->_7!ON}2&ieXJV`F`NgOxs5Uq7IyEhqv{P~|G7D#`kKLRGLb zwr&34JFL9FzP?XSSXed_4?5J$TNvk8H?wgjo59u4UubaH0{(W4=svgdxWIdj=VAitYPomJKyR4h~o#_z=pnI6O#UJJ3?JK!`)F0M0Gr%F@llgNl zil4XKx4LB*?Ev;aeqlZf*x6YhwSI+evsUA}ElcMu(}kGe`UAPGIA$@r_2=}sD@y*s zz)-gR=)d28>+$E-5YGty`3?ST!(n+Y{=EGIexAbN+1P-`4*coEpLKXQmdl~QtiWB# zT93Nx@p8Mdy}rK9w#odtj`fb2y>lQ5*Gv5WUaTHFTl0JK0KEIh_W|04&Q?R6#aGxF zK&OCwvGdo^ZRd0Ao4UPg))x~i)v+@v7-TH3vSacP#HK|vnVmUubsYec$$u2Pxc2G#8@x;mKR)i zU=(j)XqN~WS8eLdT)x&sJM5kLps+J;!kOHZYA`o#nYGqGfx39uV!wCS<6p&vEOzez zpuy?c*D6k0RQuR^w7DKX2Y_N|5mx38dtp*T5X95iUYcJzbSa9Pyff*zgwvx(*DVP& z-jzY}2{(5y4TaZL7fxyUG%d`QudAqpQfZAK z*|Hk~RMcB-1z>i=zW=Gnj;{QR*e!9G$C92`=aUKm4GUK|(Xe7q#lX(xv0MMxVwCFv zEVCJ|f;jo^Zi|l~4#E!r44%d1mL@OFal{>4hl|pg8Y4Eu;|jD2bQt1GLYRiB;kN*R z84)2k)j=$$dLBdByU*oRr=_W4GrsLX5H+(h7u#t|_lMn!S&rJCS>j-TMy?>>L<5&d zQe7eH6Vx|SbFoXqS@YbI;Dujsm<&_k(V@Aow4lIDZS%lCcV`Pb*1g9ki}N8Yt=9%7 z|E4r|+}tC^T8zjs7lOX| zVJ?E3GGFv@6JIt)Ek+}l4LpG12P>1z%%b+sYkP|jv)025JM3B3iyFkNxjwr&{x}@Ft9*XM^2BgkL zPp@E4Uu9|}4#)=I&7)AQ0gFyPcHC>}yzRNN-zs7r>%?DG$GMYkL>)T>qUxki%ce-u zhatXFQVp;vqMcOGsbaGPZM`qWKgYNg^05n_ci`z4cu7*bX{>pHV;}zTlC{2rbK174 z-j4p_Bl#6N5&XHYS^WgCcY-pc7cXGN1P3ifjTmNqBmumusKj5@jneIVptVF1_yrS^ zhTVjh;^{Z2{1ctnpIL`4sbikZVTDEgxy6UwxUcZ)gb)5eF8&s4%bb3*7zaqEd6tPC zV;fjW{MVYZ$WW;7ZP(Cbi5Mg7#`BvjtqrF7)=0h%Uc1N>J7l34z;E;p7{ML)Snb14 zeD_wK*oPqsak~m0x^&3n*YI>7Zla9`t#4rbHoQEG6rjf!arp2#*vR?dD_3R}&*VT1 zF@T?omXZasA;YFWj2Tb(m6HxkbrgsB2LpXOz)!hH#KJBv#(^qV{ID2ma6gPiz~r_VtpS;bNScC0V`El59FGa9889&V-S4Uee3Q zrN;2nOqlJkb27~W?CK}QMwls*!1{SWSjU2wpVQB%y6@| z2e~=AOov=c5DW~KaONJk1Q_h246;P)W5(9)&%ZNccBSQEGF2wu)G zENRs*cnyx*j3Dxf6>u9!G!vw8%x%*}yy+wSIcisJt19>WRm>Swu%K>{jVe_E6zsbV zniK16sXBMK*2vH9*w@FsmOWD=YyI67wfb%s(;XtxnNPL8z@`I%zU%!geopbR&|t@u z4{Ga`Fi&kgBD|aKz1o#eEhAVP#fu8o%%StaJUiMxNxyUGJn}OYxkSNm>TKHCvTK;^VTW-`CTHka$r z-aToEgWLL?s1tJ~tHZjp{^|wCH?XrOA={JfKkSV?jcw(x+1P!#Nms239p*p0Nw77a zTi=3Q_2Typ=!f_4w59G>7oF*)l{nD_2K%0-)-os!d-vRfXTN46Y|9U6YalA#A?c2b z19uD#{9RK8zlFt=26Guo;jJ#WGgoOC5|MrM-$jkk4%BQ5c488Z;;Y8{EIH7zTh?s18* zb5}a@P1BW6B3$NMmt$A_bS_B*n_c!H1YfTmM>=ZiIU}oTVdN1y$FE?xZ3Y$Q#2iTD z768u9g9>@BZx+6<&Imnq(Y~s^NKd|be|?|#WS_|LIoz6~q9~m!=%c)lr&;Uo^Q)LsqoZzN4@6kIb_sfR{g)Ovy@C9ouD!pbKZO15|^#e?;j|a2D4m zF%ruKCzh27(H=<=L7XYEhPnGKd0i*GB9+PGxaT1gVYE+5k-?@B|mm;W6GV<1lL z>Tiq|z*XkTu6@}AUTNy|c`bd_k`I_n54zlg4Q#s#wUDWoG*ZFOOfF|;vI*a{bsddm z-)k*wwfVW_c4@>so9Mh_cFCsz%*5ZUgd=^vAZnBs9n1RVtt}^(%k&GLj)yI!ZHdv& z{8Jkbbi1+AmOna^3YIqHhU3f_MP>4(`Qnqu?}W6ZK7q^vQW>v|9E~?8vDd#KsHP37 zi>u7+r|po$HZ~$XG@&GAKTUFMKABHCC#Q>=cTQXG{)yav5sS{w5;Gg zO6_!&bUJZ-hU4G;;(Z@=MnnfsY`evhO`>ip%?or#|q_oXq>>_pGGfvtq1y*?7h&ju9 z(W*9e=F)H5xuW`Va6sumVsJq_-EUhGBQF7N3zfp<42>hEcY(iWNMC;}@$-wA?V@=L zO88?}m+8|L`Pjs2`J{R}Ax~z-uAFh!%EP3Ptx>f(=q3%PshH*shrgX^yv$NWol5^52mc7^f;aa`pnk%U50zkx>jC zIPTm&1Z;XaaEvOI1ot?6!Jqn|j(n{s zrfQuiyWuSz>7ayu7uX+ZTu7pCvt**3e5mW$|-TaR_Rv&{SaR}F; zwGHNWaTJga3Nhs@uKOX=m%wH5vBf;Qy+CV;0ff&S6OLOb|;i66*0#_Le+n1=Tyc9DbmBGHEn}pg zD~^J?Vm`)R|5>Y@$;~A^-dp@$S*|XHtw5n0g@eJt3X+XE|F&bbz_d<&Ll6@xY{vvQ zFiNLgOHA*o(3qAQ?C%yvaMtY4#K1RPmg}%9%bMwS%X}XTBtra@7gq~lbk(}~`QU(%+D7b3Gc8g6zI{l1asYGcN+$MI2=YNEB-*v8Tt}tq@R>@x zxa*jX_@j_nx`BPU%0Zo=nQLMPZcr~(yuWwG!wbL9PbtK^BeXsEWJNym+X;8n6ac0{jE z$pg}&?)Rnn$BmF)75_Mnzm@b5!2J9)*4m}#TCar4t7G_se8V2RD~D56%Fl^E(5i_v zx~_m{%k`YI$|$2f%S*LmkR57@O6{1Plx$Ats^rXM+EJ{~YN;Lbq}mxvZgSW{E&#vX zl^ZK2^ax{Sy|pDM#tVxRSDlZsgUH~7o-k%f1>EYh0jqL-Z(T#&sCOS*?#oRs19<~V zo}CWbHoy`{A{?DR?YXVqWNvW7EIMXqzMBjY{0gJ%>d|$4v@EHGC;SK_Jp2TGHH9_%N%WI2c-BLT8 zbH#QHND#{NNIIpTvg3g5@h7x}I-4bWWLs~1SH@}6(iq=a*q2m^4E8nCVQ)yDVyMSq z>*6Q*n@EmMk`ya3uyM%vDZ~z zVslz&sM1@~U_^!t7br>YdtM0u(}r7?+2?3wIv|(9jK`bg(&f&e!biZjzs3Te7&xE1 zfHFBcYu&7E13M&I^0lpS(BK=}b||ds%69k0A~R+H>Dxuv;MdxX{KYqxaSo?XsbQ20 zteGG-vB2w|Enre|P)+c{g#U0o349i97SfouzC#tCGlx}W@;!R7PqAAC?Ipb-4dB#0 zlIl8Nj7TFd*|J2Q=0-FImJj`3P*tG)au*M26hWB7*OhxKxyF_u&1l&4#aN1mx-vIbyDGRjRmtYk z05=Nu;*gH6fqo_Z;9ADqh>}>Sa*0%nKl^Rwjm~aU37Q^qXG}-M6mZbo;!d27ETXH= zv(}I5h!%bkhAJ{$$h5@)T^49tVZjrN;`je|r&(OR6(lf^zeI%4&C)N=Ln*5^UX z>prVKk4ud^?!Z28>W&@v%;yGc%9$I@JiWDoR&_$Lv*aDcjsUX_`jIdg{-oww-FqF??qJQI0^=jOTvr zaVx5%zZtPr<`^Dy-2NOxweQ^DYNz9m!uu(92$+x_QF-EMg>G0k+&|$Q5L;}je+1zkL6GP;e zHj99G3ZxKcFyPusG46T?Z<$l26pl$-OkO7&r~!$k`q7FEIcPByuWtnS@_>KQVfIPJ z`7=*@VGJV7Wo@tz)GYa?nyY6ewuvRy5kCREgkUp%!%Wc1Hn?--DUO$Xz z15C*lT{0Udf7?Rh*k3cI!GObl)e`b(d03@v?Q+p_&Aj+noC|6bWA_`|7BdXn>RaY&X;jIPhA-_uq(VpYnl+@M#zk=y95DE$?cH`!}VAiUP#@mdRPH#ND| zXLPepD&sniline*zvMAkx;w=;G)-=~oeyFLsAgHrV(?|OWYWuRCWrBWbH$Rt^8=-R z7x1joE$rA!1X6_8x>E`7n8m@L2F%hiVE(4~JhpbQjA`j(p#I|v4tZh)LUK!Jt)N90ytKfXq z==2ohhy2{386iG0MNXH+vZMWknCZffig~B2#BK`FoJJP=qt17Bss^MDj(Prz76@C1MT{Nwm6T;E(tgZ8~DVIES?x|EA?6{Z_@wZkKmV52Rkah`qfp5C} zCQmcPYTJ?1y9pxPsYZkcCRrpR!d*m!(&v3H+I6W5(?caD02A@WSH{x)|J*L)kd2$P zW_e3JC=sJzPug4o4JVQIl01`Wt04m5*Wt{_GaYBgr4ghN7lALO5sRjq ztIFyy3DU9nh9$MCio=fgrL%x0Ji|O1Y6r7hS*~`!n{X3z@Y_Y(EFQ&8Hd4MtdmnWS zSdp%Z&p=9VyIwH2HhWr1Ny@?ADtZxn;R2my4$M`&$PhZlo6g^HN6RzZ?vw@W8&_tz zz@mNZe7`pGmQD_5EPR8nHAbY@DmNe_+hu^is?reI^V+;#wo3E-1HQd>VDMv`A4{IZ z2DL?|1uK6^V&XrK?G5u3BeIQcT>u4?hhTblEc1Ae`V$=osNb1;1fBf^KNDLaweRDH zW{e-Yv|?=BaHQ*aa8(Gkwk0YD^p!%u7y$myw7NRAr@9|ERODHQkty|Q(Vm00myroJ zWYInkTVbIX?)8QyU75;Cg~K#o&PrFUQONp|>1d{<%|83o)}3++YH8_c{eE7)&=(uP zRhyya8w_An8h~@jIMXtehtr+;VB7JPAW5O#F+$Rvmc+9-Z-!GfrRC6)Hrn8>Ge%BX zx*b?Nryz_u&dRFFSrD>Z4X>+QbQFo!KrG3ybMH73c|QVkR{8)>yA-I$FX8vPoino( zin1geP#a{+xOKEd7>C|1zCrGV$}p&Xn~r1an{$;;_*KfWos$0Wy2{mY%B=?+X*E(V zJI0vSe39xh?ZM~-y0dCeOAZ*muy~w$hWvDV{JXBug^gdqt~0kS8wMpA0=p{Dr@wqC zV4t> z^s>8AP{pbpDu>(X`t54Vc0cA=TJ}q4r55?MVioQt>qpyQA2h2%%>AOao79anm&2s0JIf@=ZPw{eLEz|j~% z6B{QVlU)k!3)-ZT!;vU)%S#RDdu|sbb}Y5oG3ItayTb2w6#;H30K~;2jvA*LOs9fi z1dPe=WAhOb8pJM_yMlsM-Wne*v^TQbJ>qfo+H8duNL`9TulU3#&MT-x*dr zu#MX}0|~^gDahqCPGlLt=N!w$zk3&bM`Jca2Kpr~TAFXetEDS9L}f{tt!dPDSuw^7 zI|}umxhk1QfdeYVhY39AOhd9m7i+e+6&AZ(v~DU^CV7-O!#mf1Q_Qn^7KD%k;}dcCk+O_&Rn}H0N8_)$H0AG8s-H8 zFPL{$YS4SJ%WVYH=-A#nUAKzyP4s;=EgWEwY%~!PHOLHI|w*#DW zyFeTNL3`9yVjTC-_?9{5_s0;8WgvR)CmkM7>xIj6x*FXEgznx+%A+IR4r zYq&Z-uE%45J0O2*>$vg;nC`|4Iy+xFfz|CRN4k%@J{5~u`+kloP8?bRtgAnrLG1dz zTftYhn6)y3#dbK=s|hjG<1x{vAwO$r;)Imr?=ol&GEEC-`>RL^6#U{wp0WgM4>^>0 zUDT^TyMd}C^F;B4?zBAss2v(7{_sKzME5dB>zvp=?O5o0gp>i3{yiD4%kmT25k?$E&<&yqTMVIh`ac<~y*SXe1tu=W@#v zhDclDbe*hpif1vNL|pX@PDq_HX>AE4@1QgAl}8q0ag`6Zg3^GO&Jp!zq*M9Bw{8^7FPWTb{Fe8Yi~HQ5n^sK7RF} zeu-^!`|zL)?y>mq4Uf>}E(JLTjx~0Nys5949Wc-ZQvDBf_&i_^p8#^tX%5Vp)6tq7 zn20KlR)a^a?~pIhrUfRHki(YYx0p7;R`dZ18A!I?5lXYb#b$jHl>2zR9N^3EIzr7$ z%9w$ovmHg4ZMwQ+&>#F34)JU)?53%5&m(y9<)e|S{TxG6buzTd8sk9My{Yt!?P`J; zxH=H2xw%aI9_vg}NZ1vvThNXoEG9#B^ruqNY9}}KChFe1wnRYPk$5J?)GEb z8aF{24dRG$iS1;xlh)nYE>9AH=R3;I5}(U+zn-&4^tm{y@CB zixz9v8Oed8+YBYMCUsoPum}jUNjOuRFH=N}lJhSan1_PYjVD}gV!Buv z(~SpPHYgOvPciq)K5!#TIJWSPkOY#bBa(O-%Eo7|YNbSD!3OL*i~g|jIO=DM3o*%F zd14ZooIpFlj*XmL(q1TVbW#h1I|_;F5;&zJ=dd~op!^HY5A?tqnrWo zz+Dvo7hqPxdm^dnMx#+U6{H1Hmb^pGInM&L2z3=jOGC#A7+H*#> zsLhx!jG)5Z4_m(AOaNhjF!hvu8V(0;+;Ns9^5#;!X$MpG#nR>& zE=rW7_aA{BsJeuhgsr0!P42MkXj3NN?Oe3npuvV>;q;^h*hap`(pWhTCF^L(hI~aa+%JYb+arlmn|tlrz5^# z!VD+Sl}`lXa8$eKdapsijsYuIl-yT3zWAm(3(Q%IZ5)tz$s@{2idJe)bteoH8h4x8 zhT?l0i05d}PNjT#6w8?7m@lH7ze8p4oW!ozb1;r!nGf0VCrMMlgbn`Gl8)h)aIa+R zEntG$LHfMS^20gM<+x`!JVtdIGz}aoYR`s2ab<7OcCiz^&KqdIX5z1LA7!~ZF|?Bd(9VoP?>=(x56?J$MZq}iVR`~ zfbvq$xnpa{#<4dI-J*G8d_<-vq+#2Y2X?gpK~3!<4qnH|#kbtXoWuk?%Rmg)J&9hF zU{;M;+q2a{jleKQtU5}+49z+)%FNn-x{9^ zW0SVelZ0B5O&wC&POR(L5!qq!fJ8hi>*&qS9oYGTA)})?On5SmHPjtQ)tWlN5Qwky zyK6h;gO8o{&DEASD4fXvX(Y;4D3r4{^KvqWV2j&g#a4=C2S+#-XE`fwtRqcxz|xMT zh!n&JJ9#(?)4%|=?L(HOPP~rO)x0- zW@P|Yvzor#>y82jmUKC$CDl^7jh7WuH0QwH%uz{8VbGt?GQ})`GkXB@Y1_LxeD+f9 zP+mYw?BjFD@`V%U%K|QuaGr2Q(3=V2t^H zbl}5l*Lasa`U#Kp{g9v?i~Uvxb}pZH;K3*m@|IB}IhNiIe`7D%$iE+EP_S-;mUl1o zdZ=~vt^57&wC<;|v+ltp5@zf_;SKR9!!vvuht~ZkT=#2S@zUyhEVRoh>^mN-K%mFkc{c^00l*xp0<_$5f8)& z>-?*F+GwN58FA?zlg9X z=F(I&@zQsp_MG9Hg@h*Y5<=(}doKWa3jx_<1ukHrCv`PlPgpv1H0nvm^+dz#fhYNq zS7L<3#k`?|-WTl^`!MuW5B=fy8~OqTDFs;dNPUOJ-BlCH!9)eBsO{54E3R|3#cFFL z_1m1jRSttu{M~AQYDs{68LTa{beKAMOXA>PMVpjSG)K44G1^VcFy`$=sV(247(*2k z*05_7yv`7*yZ!YIQ22G;ggY?zoYm|_Tyd;+A(AeSXy$8pyPW@r`#YB)OJKwUx}nyU z&U$nGr5K4CM~Ls|2tg4JC~J zXIf06Zm7$ag5}LC)`8B1)Ae}=Dy+I;k@Jo@jwM>PFwB-pP|#wx+%Di1W1X~RykU3D z!b(02`(%a_#zc`6=_tDuWxIX4<`Mc)A3td^#J&qc8ldccr(&pq#$s1o2fYi63q4yZ zQYNzX8wi0u{WMll?WFO{&Lc2Q=u2uf)*EO8CDLl^8YF-wyC530y=V#~mj*Ui3rNw6 zHYQz2nSbD04;L){;0Z|FIJVcwX5io)6{T}`YSE?)r5}PQH>l1g4{2?oXb0X*FP5!y zSB8@^Wqcm1JH}Ydg1jx)#Ak;GK`rYSSbk35KrK+()k!&&Td_IS&gyuz{_1@1GG-+- zL6fJk;~kij&di!nS2~4PrdyP0qkL_ffoYMebW-=VxNC(QIdeA`k^Wco|i zkCihD6FJ_IOKpQGIXXbLnPkUv<4fVyf;;LoJ}!xMEpyxxcckU6SN&ZZKGB%svC!}; z)$7OBqI-kE-WgtziQ9a&jqR7#VT=`E`z?u6U+N__8CCo2 zRt&l-YH{wU6;3&?40`{tO)D2neFc|P5i1|SjxrWfi@7c3O=@609uVT@j$EGI@@EfJ zbHv^HWcMGRb(o2UFR{Dh!lV6FTFg#DRDQ)0Jo!LDi3A2MN_r|i3HUSm1#yjS(8%K} z*U8CutXHi46@zsKK16ghiWeUE_nu67TK77xskZ`zE(gQ|uxsNXtg9i>hpbpKO)F>S z!%(0UID;GZ0-_wKuScVkdQ^|5dR&!*``8Yg6PZXp45Ao<8`D)#OqWS1w5_A#@@!Bj z&8S(j#PK>qCSHlGOn(N2uNxX!e07Yna3RmjXWucxULa9)74BJ%L!PVMk~@sEv5v{8 zNAr#0NW6JPAL$%FD|ijAqJbg#`>&FLq5jd8L>)Zery58bwza$ac9@7x`Tlm)^M-1!SEBWrKtQuAAV3`%uB=b}^t^b$&Cn&oCIXb}Xc1mQ%4i6Qx z#lx&Q0#&oHJD%t=>!@K2+7+v|)iDmX9kjG_DE|P|J!re3OAIZA>@h`VnKSdSVWkZ2>kfWGUz-tR|eU( zsu)x|3r3r&{-fg5T!a=oCRa54d>KnO#jGXKO<@e53Y7>c^_Y-4z#cS&br@I4vgtSy zVt8%5;^I3vR22@))G%AQ@8Ltba^W3S9I`aVHuS3Ghq-907TNKt5p(^6i`Z$_}{GtmwQAn=Xs>N|`q7!Iu3 zYfBBejE{^wY}c?HZ&j4OW$uS!x-j8`7Y$))(vDefF`KrLzLXs4IPd&kz z_fGY7Rr%G8)YdhoX(f~2^^UE2ylSycGgdm~7MELYNQVUs-EYK8*_QcIuj@1D^*I^( z-ZAWTCX2-bP;s5M=iUWcWc0u!;WRQ%>HEzp@DWM|*LTai^Lgw{s!WphE)}#O>%GT`8r9=gXE#md*o-ouiwy)PpVJU*({Z zpiQigwR1F66dAyYH?WJL6)dM_pUZSm*h-;@B+Ig6&?4$REIZfDaga}H%G<8WwD?f}kKq}n|`6~MfJtnIMG26c2sI@ zt!bR0yDYj4X&8PDP{%UFLxvzq_D?wW&i5Jnjyz^<*SEu1zjd`6SZS=AK1996J==T^ z1$G+4R#>)p6WnT3?)T!byQU7rTNRr`u^@A+VP|%)m+U3m1WjHxBj7KccfpZ zOtk@|+c5x4LUvYwG38^I44cIhP-6*sz>nh_QD`1N6&@&+g_{V1U5D#fM=ftu2e(~? z<|pLnL8?pc<% z{Y}k!&#!YEe3h*3EUr{L7~?roX zEQL6{juw45ZF%+hp?H}$m(cp6N;r!N!mGbmOl-$9gd-zI5x=sZ&hhdelmcED6lc69 zvR38iol4<=`1w2K8c;tm632RGHu|g+2p=IOQ)bjdM1(|`fVi`B@;%p62|vr~R9lmw zC9c1yxE9|sh>#}!L0rkl0#DlcnV-3DS%m6SQLVYUaSc1a_hywCcZZ2_9fKSn%o=;? z1N**K`YEKSyPDC7y&uFoqN?u3cFwqP>|BqD&$f>*-_`NS3$p2Hds8wvzSzzOnJTnw z+j3P})VDkf$F4rPLKB7DUQ>rFQl3N>8BDkk1elsO%Wxo zxrxu*&42|YKX@A)F8q9`>>RbhP_@FrM1|@}!-7RcI4%f9o}b%ZDDlmixp6Ka@wU^WdxL*_ z+E(bAB8U25aNnjQtM%q(E6`sXcE+v>G0CpEPD?siCHnhK3%1(o`nO`J8&&I$mF92} z)KkqEEx<8p>l<@Q+MZCyue>J67PrIbu8h%Leq`@V%_tXo`f07T5a=4-}hx>9O zKUVwC1P_v8m45Dg4R-hKVZheYNF4a7{0_>=dw!W3Z1&!_Dk-I?$_cH9ZUJMHdGZfW zOyzG3EP8WezwyCkn{0aF@3zjU*Asts@MULLz0_ft!{%Sr_GOkySXj{7Ro*ak`4uf0 zOw{L;%Fk za8OOW>`&C?WIyF$uS>T^J8V<#53CCbe&0%@7*o1WXKN3fsFU~vK{bk&C#4pUT>fId zi{0FS-Sy{q1$9;s75^N2ak117#%ScQVQbf`P5yl$$mXpLU0bo%8~TY8C3(}9LE6x| zvycipXp-VPXJw0@kw12yn@c80PMfe62ey%rN_;;z3!}wDTUj}M`APNav_c`HyUck! zR`=|3NzCdb9%nw2*!Npc=FP7cA+83c*QD9*%DC&*l5&e2ie2eofIQo=GnH;QOg7<< zEp-PjlB`XE#jiZ+SWB<2PD9B_1(UMRn*^+9U~fVy_?)wR!58f~-H0ZCro3B5I`W(2p$H3vk;^(C=OvwW zLN!1*v$HsSZCv{7r(~qYN+t_Kd;MOSLqbUj{-}^xcXjANv6B$yIZY2x|GgNq+czNLZ2dqPL}jjqR{n^uC%L%=hGN}z_w0X zU%9OrHM89)o>yfg-tuygmOA=l%X@6Pp=jyma-^-SjHnJv{-Ax6C0G72UA5kHE-z*D z`avfE)C=HU4e}4?g1m}R9M6ZSY3nBGnOP>4m?ANEexD;z*G~T>iF!b*I&Fo00Qcoa zZNltc;uVLK`*SUH*`jNRhxS@W1%B$2b4hZ`v77c~ocZ>iyC!}F3t1GDMf!vwR?@c3 ziaeqJWA=&1b5M3)fqnWp{;vBJ?3q;T|I9u)DJ-{S8oou61}vI$9)-0PVWi7Mq%vz@ zv-c5xZu(8MCXC(a6K11SbDr!4zUI|NBE_`+N|LjFlqWu%w}S)os>OCfaSfc@kD}a_ zbUM>g#Yu;mt~x;Ym2k45BZF*$LdMG~>on%l^5(0KwK+Y(Jt!Y05T#UZf#+D6^qM#ld-gkTwLq1y{u>Mp=4`a~Mm*WYwr z6=rhZw%B7}466|1*Y9Oqy51h(8s0aS;N!LqRQ{_MhEH{(Kz&dFV|;9pzc?Dp5bddd zbfv)_Jm04pD3NGaY>F5Ag-)uCS{E+uHLQ}sKb+)Ol_~7Nocd!N?$in1>F~H+<9+I+ zV}nrCzw0Ppe|Y1+;*+#AxQs)#xxTcM7CFukCc+sKyX^;UnH%vJb41u4`BES$d_HCF zq`=5Zl30LB=XideLvQ>REm9%azgd3EELLFKIcqHj}A=WV=spj+;?ANyE>lZf-7tbYW|58-jaSs|39#}OvLiP0r>9Ni?X9v zSfN}Wv0&tDCr)Z4cXbmqHeW0gs$tj}Ik2J0fgPP0RD8aU@w)mPH-^vg7ucf5b3jza za$kIzc+|3>(Gat*55U*wc#gUKW+^@drI~^$b`Z2~mYXk&DK}r&1ms;1wEXM{w|uFX zE4!00&ciP)O+W2xmEnP+Gp|jcz>AI-tVtN=sK+e>pM8Y<*r(#udX_C7an$ERXW8|9 zZiUf@qeERFZyEQ=^JG`Y4eDqOdZ)b@Y`(&F#rnB9#T*eo_(Gcuz#R=^mo4-eX}d8e zoIEOa25+cxW=>dD_HLE z&Y-3b2X<;fiTR_UWXx>W07`xfCzJ8sD0W&c2HCzfhF1bc`{s=2n z*mjqA4gPtXY@B&%R4RhMAn_59VA7WW%(uXw-+` zJ)+TvrQ6zf9eD6M*UmfSz>bc!9L|>NJ8eGX5xgxucRY(?zK*^QVQyH855A<=F{^oZ|?<(%~{; zqd!inbk~U=XoEMwF?}m{8jK0*3v*Fz%w^3+=MHjxTsG$~aJ%RyG( zBaR$BE@^28XJQlNfxs}o&Yy+mocXwNsq3qn% zggf0h*7nNAP0~gjBeBWL>n&LLI##*&V}F?5X=@SBR_V(|eu_OnUYOvlM~LH7OFwqu z^A0>g`pVuT?j7dLG8B1;$pg4s2&1KL4=XJyVqWr)oO*a z8H5}yJz)B=LdpM@$A9Db*QC?nH!w*if2?x@d%6p&`7E>P@YuDv?i!+M)N#A^rEQ>GM9$Q! zmGcY!;bF)^?ivq|&jERNuFx|>NzuD@uzmP6ZMjIjt78vsDcqtg4DCcy9zOvq?-0wr zv+vPPub2Sa9b1W^dE=5Py{{c(LF{G%ar4q_anru5l9z$ZSRJ>$?wV%Wn}GPc6;Z=F zUV_@5q@5dM!{_0=rFlISsdQTgo0VBI+!SDrc6eSmLXyQ|fxEFM6F@Nii|@K#z%#_h zQ#B~ptS$@bDC6e6su3($O31-u4)}9{^;+J?n4sb-$ zodCrxrBx->7v+`xeec%=+u(2u;^zU(p~F6ZJh;7de5aJO~{V2WZI0@;B1-B zt1~VI&GzX4?d4dIvDvuSstyk6;gAv0Jmh|=x)(qS7cCZZF~E$!4K;gFin-?#h#NEt zAq?X={rTJ(Rez({odzzH7#=E=^SxiJr{YJbxB zG**daHx!ijWM1bDH!P-kGLlaa|1HO^tC(U*RfGn^MmqPxMj&7&QdjMO_`;1YMJ}fg z+W(B~f=Rk8qe1QKQpy4JeMY3CQTn4&aGkGO{&Mgc9}C`<{8bV>#CDjf4LA3O%-gHX zOZRk+!Z!;)Vc6Xm{EtvM8({ec>p~?!oQjnU8S(@WL*!~?qrTXRYj2!SYjjCVAxw8T9A*XtITI0EZ0W5x7x>C#lEXdN@-K-(@;=X zFCJN}11sL<#XsM{-?l`XW!btfmLf>lFcjtb&#gw$kv}?0IqTJ;2fug(Ow)LgXj_h$ z!I_~YV!d)>6L@`-J&6felKUNHrnogH@YaIX{H0vcP8>AU{9BQ9_gs`~z#_oT@3zfo{ovQ^B040dUX)+rK1$=r$eqHqOW$>Pag0Z% ztB-vwYk}bNXoQxpW4H1fw6f1z@c=h9dSc%` z)b+$qD_uI4)7F;kcwtKnvAY`6UgC{SThZ58(SjRC&3T`6Y!oqV*b33ZCGC*{wx3&O z@*3EzoZH*D$v0y6)bMDOvYjdKzzsH_(cs{=$?S?pq<7kptl zc9iOL$7nX)f$d8pS|ajzK_{8Lln;TiJSP!0|qJD+f)-oT%St?FD!z!*&{B6~ThHXP%v zV01A{;$TAZ?RX99VL0T4B%gLz?(|?lG$(tG#Ueb6!&jRlsdeqJ_CqGj&V^r?Ldc{{PU5BJpsp;YYqUGDg3mpEx%u|r%iHlmod}e=~rdF zzzj)|Q+TOJ$4{+NE?hIx4&Y}N>&dyHO=&h8NBTeiJn~sO=h3+e6dC-`?mb$2*zZ=URTGj0!oi5P0i?Uyi zsky~|J#2aDHFKVQQkLLX7O}v`QF+3`V1kC$4fC1@)zLm}sOHGyP^5U-3%8UZg?~%; zxNDTM!Buy(^P%uJp`Dm4lozfV%7ft>cT}X0Qp&RfmG$*2S#B7|s-NfG57pa6)t(C{ z!4Qxp0gCp+Cf5d@xWn<&Hdz7Mjy!rCyrD?rHXX71 zt2Zu%qhqDCRz8B)kZ?>8hT&e@t{sv?bvj7SkP&2UKu!rem;w1ajd0eIrmr-@k8N__ zEZVlZ-BG2RBSh9-Tvcdvx~Zfgm)ih~)#2e;G*oc3-qHCljnOcU_ZOMMTLuOUE?LhY z5HfmRZM%&s68DYUksYA+bBmF?)w^W6ELs%pxl?x3>72~jJLjuCB)zkfws&XGQ8*X` zDcs`@tpr0?zCE^bzjVW1sT4;g)=`n5@hjdWx+6FPa@KjriFW8%{FL2F4(xY0qqDZV zbl7vyz0bo9eDp7>@4T85iHkbm;PnZut$ooxtt~u@z3h@7ynrs!_SAq1542Izmbxzx z=6<*LaLX$#BjZYtQ{@Dyqc#znW?xg%{)nGh%a|(iWUdKN9VWeBY2~#i@KuY!5O%ZT zoF*1k3!43m&9(zcVU1}j{0EU}mP-lLbMBg=Ok5VrJX2PGjAmnC<-)4~QG`rU<@ zUfPV(hA4KMivK`pc+XHnFCc+#1;oxp02lng7;eiqQM37Ie|F%cDl(Juq6A+%J~v~> zF3I4WJYL`Uxvjxr<9FVV0k~~X@SYxE2audzv>5&52Zl@XIo}NVb~{{`*&KgG9p?69 z%XVpg0S-Cuoy7u}?oYqDk5frqc`OU6$#o9p!Mlq)@^z?!^<=sfw z^er|8pGL)V=_pB7xn;xGd}Yg%P|Jqa`I?p~i;P;nZ4{IupM4@-8`b*RhMDDPnEPH8 zjD;;eyGd#gF~4qHLi|`{=vFtpLIn@s1Q5B}Vp$NJVHxoZ#*6i}>dE^Jt^SObDlaNP zYKxNA>fFsvYgV%Dk1f{F{aA{j{?OTQa|-;1w@(K)y3J3?La=E7pi_#+I%#|7fh>7v z@w2?+!IBQ9cS8b5Tdm-oeBfA`c_NQfwvw~f!idfA>tZM*H2@6PVHhq)-0!fVK0tOf zb_S3y=?-;jJ6aY`DkX-%KVdL+yp5mRDAs|zpJK__AJc}Z^h!i^g%<-hf%6{w$Od== zJ@|wU!8Grslo2lWEn-Q%yn?0NmZBk^&!L*8z#U)q?6@HSN@s$}h=7>9*S5Di_HVam zS0^o2$T;*|VjKI`P#*o%QmG0PxgJIa;|LWU(a#Eo%VF&UG#oDg3@#el)Wq>7I#ccV z42ysb@Yx}r`QtG9S==e`8E| zAC==BkGs@{CowBh*e!PUds1xI311l&O{25lIz%0uRKfGZ4Obo@ zJW@i;b~!LbX~TReqjr@PxC-p(Nbi_D>EG`}>+mr#NJMUmz~`N4hc`%c!WJhd5>%vo zVOw}MU;EDHj&^D7YL`}AE=@qahUMDP%LRy2wDU_0$M5GjUR-zH4czD@z_D2 zSip#~xVp^Rw)7FSaW7`63rd^wFfMJ*sk1q!^EU_2K6mX*V6|DuuujP<&w#2Cb8WNu z)uDJ*WxdY0`9j-Pn>s+mf$ zACJc58@r6M3sf58u% zl~<)>HAUNCaKKx8W7+yGQpO6t@`t99U!dX>R9G@lhDYi2;C0#HN@k-L)XcWFe|P*j zed)w4`G_*D^f;c#ovgCqei>Fb`@)&|$Tgo^W6;OjbwT#(=ibav5BCZG9>X7WT*c&X zZ#zI{#DF@xfaiXF1@{>~zI+3B@T`S8xu09xS|ulaUw78KzXCGaXZ9#N>$wyjZ|mD) z%d3y@GQ*<&X={Y1S;G6U%|iph7!Y!GzP$q9osBJ3LQ8p#SQSY+^s=+-YkrY zA3E^!QX1RzU8zn;1*=r;K0`5w$u-*!3P=>?5hf7VWp#DCw`pt6;L5#yjLXuYqV)oy zp^Cl;8@o)Nqs@H`e|~D6#l|8JgQgGBVPF^hDfei@JMi?Wr60S*0*NQ!?{^=WkV{)` zh@60>;tqF^A+miIviqKVoF)WQAWfT?1Ne?hzP?70(Y z%gL|lGc{BZg!|0+Y@>9m?aL9NN+AB|ciOfBv6pik+Z-f!s`UYv&o1mO4+*~+;4Ql* zj)AcsH)NeXlTqv@+wsK!SisFh)TQ8$GZq5T-!HVeiM9nLM@_n8Y+yvc0to}w^{JZc z0x#AJxqYgefVhhD7H>{-PLFov^6rAxs_G;iu#>a{^GG}=$Cv0UU>airgJRkzvaVhs zFZ}<4QC1DrsIPFSWUFx3%4=YRABxV%TUuUn-ID$e>HI)RzCTPNbHL0Z*Gb7SBnOn( z11Q!&Vv3;%<`Fj?$5tiy`-Wje2Mk`-Fz5tMO4$kg@$@_wZ@8dC2s!4RH*!S{hKjB> zgT7G>E5^mcj*GmEfWt;!XC+JUz>17pUjM}fW*>;~x61Wupl;e!d_nwL`F_N&yg}~d zyI4BWT5)dTW0g82exs88NDrF^=GQh)GR%wU&OG7iOQoNiY(*}MAV;K&Qv8y+HU3>D zy7!)Al%M#Gve1n&qica-y9W4Io9TAOEpJkot`XVzvQArZc{c)iWmp^gcB0#vPU}U6 zo49t&>THX5^dPQGAh9c>!+)j6gO4<^B;(Uk#MOOIv{qjLQD0<`17j7gv=GOxbAK=e zuXP@FO)z1!Rf)r~QA{MkYPStv7>XT7)53Z7Kz0cwMZfaa^Ljn<7%f)%N)qb^qp4zQ zX(yb?4B==6v%mV{)4=9z*lnz~ya7q<_2w~`&6Jq=eL{jni?!0_!Dz;xW^IcfpXs=bu96HbzP6E;-rU+1|hW!Mgr zi+b1g{MNkaYMT+*D0WM9{6J-qDWfDnAFtd#y3+2+IZLusf+VQ?(c?ch^d4D0eQ61& z#XJb`fxc%CWGu3Ihfk$9ae^csgh&E)h#r=IH7 zL$4zTva{;7!@0c_WUy~DbiQ0B!EQD|)aZ@Y?(@sH zLj0ny>2llEJXkuD6R*3RZ>)|uc>&VO)_EGqY1_+*7+UFj_qmQdiGz17fU;5;SK(a` zkqJ}kOIa$?i2)F>^q<#G6mcJT@7oY^6R1V!sdi=Dja}*FNw6D-A`Lk@B0HJ2jm|nH z7iELaWB`1fscoU4zu}Tr_@#@MH_L-heHwHN4~8A{9Gh@p4&_1ppc8fnH*2z^(%gUz zaP@_*An>ZS(DF$g>rJvl`ZA(?!-A4{RiYj<`9;^&3BidOY=W`Ih?>dHxC7= z7>fsSrMLJ^!PKm!BMqMmrqlL<`Cr~@yGLYpz#%4=S<=A4uB~%IwZqgh2G}td!X~6O z=xQ&y>QIK*JBv>5n0$~axv`>l>=KXt1##}_OL7RGI9g;IqXqVVDd zM4_Yh*8?g=v0{NrF+j*}SBRt5RiIx=icF}esd+1gAy*hy+DiWld(;Z9_-dT>_*jK3h5a1&v#~}3lm8C1e zf~0fPnOsUf$8*|XW+bwW&c}G+NX9D2s=0-{b9Zhfn^7+%ICjvfcJlTo)lq}` zorPmFN_`X9I>yjqUqHqFH$V|gP3G_ zjws8RK=^Q;nXfaUvXPidS?@IHdspQJG-@M1HE)TG&a`Mb(SLmveFG>j(a+N0#rS&q z0A?2e2A9$&#(B4IR%!n=BDohYMt7F3D_pVZ!x7} z2N}f!)L3>=)n%Z*ipoBV!!lRrlzD9Y{lk>z-(A_pVu=O|ooH~mG^8Lk=@Se2gqh_f z-Si5h>_B!87vn%2($c3Hvm#wSY`J>IuS}ca+ySBJQYap42a{^Zu+u*w4E=0Bi{&^+ zwq?+!#I|j1|0tF+6bE8I~3qg9&S`7bE-~m?xQ3P z4L0)zez5LJD-=O`s*kp)?_c2`>8C!sSWEekmOfKM5 zY+!;}O{VEnhkIRh|Q-E=ZWu)G&V_#2cyiEXck z!-BuL8%bU-1_vcz*Hor@x8U7t*F)Q&C39-fNr`Q9EakEmW|M+-WA?Ts4Hrl8!Uxb+ zF2vqp8CIw#1)%;k-G=s8+fM|_FGSdSn>%6!qA>l-TRpf42dce$<}Y+OQ{ zS!)p6xnjHeps4(c3ui442}*4%LY3md>ac*Qv=sX9?f2;u6EZBfm^GoLMC)QoBlNZ> zn?gaYte`=_OyXP}p2Nx`zBMmOh@;YES;Ds@_8P=<(t;~4MSC|%SBS3~aMh)uv2kGV zxik0#2Y;aLvy%1BYr@fUC*+tIBQ7{K_Vlq#qVYALeAUJ{?I+ODPe_A}@GriF#Dm>Q z$*tyY%>9eDNM`8p_zD41cCML`+AGH%UvtukWyQd+X)EaB*vLWNjXY8fb@j5DfDVLdkpE5FOUTOb*wsznAqj{=37Yi5S)KSejX%-!| zP5Bg+1+-R-+wiuY-E3PI-=ff>&&yru+afC(=EK&)i7%ZkvV&^=mu``Rc%|K1r|)W- zwhYVd4#H5Pp1Z|n7*vN+Xm4qz!OCGvXDyYCo?!WutJfR$PAQOnXRb_dxp#Gs=W^Hz zpmix7DjV>>@#+wr$_GxmG8H*w&s*7+A5kp(mLr3e(iEpjubGK$+Mw+}c96L3;Iy`Q zh@FLvVJ$H-57oqvq0eSBW+?}QK2||vhDw`E7Ld#dIu&j|loXD(B!QTo%6{#Y-X@}> zcEc?=`Vde$wY|;+J{7Gp)M4HPlTLU%T|Tl+@5s0o&biJvLUs_$h$ zQ3T4b^Sdt*UB&7aEt$hkC;nqQV;ZOq_+9M;;1fj}Eauxk9X%KKENdG+rxO5T8Jy>v zm*X5G9dg?2A6bsKmEf#Ckn#IZELmR2b4-S}1vQkQfp%mb=*|P{+!>_dL^<`zMCPQo zu%mWN72eZC>+>*w+R=$!c4Pnx2xjq%ie>?m^bXqCC96U2XiGmrX)?ft8M-r18K=P9 zh3n)+a!0Dx!=Vb`e3yt56*u5x?2Q|sa!wE8K$EY1-hT)3igxUNu~%;JQHrl9B?)#s z67s67Y|F$KcHH(~uqr&hm^4NxyG7k=Tk6P-w)dLyG_XKOHRi}RM+*Kskt4u}ZG3LI zf*+K`JmOj%6MrFZ*~xkVSG>`4kV9gG2t7Jd8+`&w5E#_@c?P7^{)iiz(mC1|GM^^EHA3PD|WglXoXP{ zAj!0DdBwn9Y#OPlw7zkua*I$h(Hvst*2*P4-iX5JzE-MwAo1>MscOnjptOtprixtN zg8W;lqA_DyM{8b3_!B-Q5UKsTCc$I#yYN5RVLY4?2i<%?M<@E84t&&Ew#87jx_wLJQ^l#?w!H#AFm=LSyM zVmTD;^t4b!0g2UYPv7<+TLe25Wn3}1p^KsMjzDza&_D+&NzkT|3I5JhCuj^{V!2qM zcsCh>F@|TMcf4tziV_8!(oUZmuqrGl$6sA{4GziU7^Q^k`pn#KGYJ|{?sr;D zP%g9FJ_7u5p)FC%f8aYk;$i(nw(U|vhXS~ExbolohuA|UzaF$m0j=C7$E|;4AZC5O zf9bz_G~a!2fA{phQ+NM#z3;v@f6qGq!@Kuiyu$x&yZZl^{%=*9KI310>F&p)gZ86+ zEU^zI@bN4Euom3L;J>$mwp@So7Jk})kUqR7v*61ZUVVJdicsCx{;DYVdJ6&c%sV|l zQL8N<)=M?P*ml-dK>*)^G@d>H`EuGO4)ZOL9&=<+uRbB|@ELFFZ5@#GvPJhfQWr6E zZto9j(3t0i#%(`#w8Nl1xUKWe;9y+Sz@4AB^Eos~4CQN5{yK%e7XOmu9++KTk`!YQq zC%yBv<>mhvpXJlMm`-NB>1>iNpQOvp<@J7lFPje1VlRK0jn0eav=H^@Rhmqa>%~jP z`S=EXOm*V z;?t~meofH7V1-F%G#f5jR!m}{qI+kPd^%n5IPIOy7DSi(qik9%SaOn{>}A6=pDng> z`vUmaPZ!;mlf`D170+j*-ZWbf6X&BhV&@ja17m>=Px8rPJ2%bO7c95CP`Qyn86Spu ze~b}UFxS(anAX3^W)rx%bhG`*Qr%{d=bN(I_ z5~sk19cub3&PU>ooB|n^2|P2IMt?@fK#nw`VKRP|Pmwl>zC9+N0ETlQ8Y>~#R`kd>#}fWFTT9R52Ei| z_OwLLx7grRz3e2a=~{KO>=7)V7@$}|(boIhAC486(bq3#u+YS@+Qlh=RGs%m{g;}C za?um>E)t!@19AIB)10RH{&sYSHu?@5WAqF@WCDKKI*2!G;x*fiFZA#QUx**#f8t2$ zBT|TeTG#xTXhy<1N+SuNS#ef<=F(3CUO-UK*5?AR-t5Hc639@i)XPllAu9mCtpZ{< zwkLuZ;e`Z2X_aXsPVL)81TAS5!Z!{2=M?~^TY67i1O=}G>jJ6UmxHO;Ei)Qj!W#bsX}9jkS_vZP%JYOvIUfzKu@9?){7|j}YqEPi>TOTf z3-J%H#9mwVkP6zK>@@@cTf@Q+R#8J%@N(v@Rao5pyp;IqeBQM`?-IHfC`2&o0uHi5 zVA;-a3|CwpbpaILs%&-zrI-Q&>-&)y;LC+Z zCSa<@+o=aem=#pn9tkan9%uBI=V0I`9Fg2Ky%?pIT}&iqX}O@Pi6E1XT!VL_MdkpP6F=<+O`&<%QYo~GmO$(~rA zBRPg5I)c@r$(I+98c2$$C%Dbiv>#fdlWZWE;qK`5K(LjM_t-&K>tVVUhaJW!K8d{* zSVb(-2!(u&C`}9=l?#T8x2MhyGJFF;RAz$GUwI_{c?{ji<#`lo(j5qW(zvWln%ss(I24MVvO4$YOP9Y{fng0`5p7$V=odU{`@>AD&4tg!QOtNWIv5SApHkK~7`~o3bFB|S>*IuD%ZoS|j3v;4Q zbv>M(tRfJ<`}J|OqTi}g{GBQJ^a)$XQXT6n;!CwGeA03qv=jv^z0-XhN{~^Ds6VL1 zWZz`Rjc5g6rtUu_%h5O=T%Ul{1>oXrIvp2l%gch)&%}Mz?B&B{yuX%C2FcWeX~bK> zMoPMjZHlDA43IunG?;)xu_60vL&ONO(Ey1>82cpc&w43v^2tS>iFZ+NkQcKFNo#0X zCTSrE2x{X=^zP6rdqRpsFECVSj%USLt=WW0jg#KAb|Nk`0k$siQE9V4o!z@Dt3R1_ znw}-%d=CUmRLsV(97UvbNFJ(s)EmtDY2n;UhHw?c7*a8+38J$R8;sJlKMj$bac*vzwoRH)U?*)geV=TWTuWkWf^!R6vq~# zdI>aXvCvw;I{ZVEm4w{%J4}>7eSLIoLHn~cPIWWLF6=Ks!b~D;##b09Rx~R6C>uB5 z#2N1XYlxx>u@V`2tY;^babI;j}s(j%-9k^!<^)T zBLvx|8C`%j)Vnkoe5YMPcr4tFK@Q5^kV^DKg#beJ{xKlErB_fd7Zvj~%5f9nD=)Zm za({o6Px=BL`nAMf2H>#RZ{O4tF4Q>YKQvc$i*Z%u@k;f>syMPFT&^Vz&H>j=p<`C) zxLinG@2gb|+p6N&ysH9tQO+VGp&VY?_~pj5qMA$V+DmMk8R1WP*>S?fNUd$YhbDZnKA8}G)*L3|nyg=6 zXjx+f77xR`S!r{>Ci<>W1HUjDG`qbWbhw%tP0jKIU$*D@$E7`Ly zb{ri+(Ie5JK%T@}p*#f`E%}8+&4A(Xb1muh#F>@&_NX@;AJvfs!&cXeVm3?*Syt3d zie5T`(o1l9!kja$gE|0SkO2w>fnYfPAb=%7ise{=46T(7F5=P<#}QOGQgEJJKoJ@AeU-!gY9I`(CY$_xXt~=}zaSU{xU=>fr zA_6f43iyb~HiW1N7=VepU5qsq?|HlSTG%YKJl48$ofOefAQZrkrzmb#*d&u(+~Q(x#y3RI1n(RP6lSj>=w*;e&?~7W$aMf)!HtH9 z2RUEVaTg2BnsnQ2#^U!-u%7~>pJZ2B7;&0S2gxzYB8I&*>7AvcWydZi69_*omLL2Q zm@6ILXHr-Yp(;X7(-;!qHBNJ$=DR?TH)%k;3@w(TToR^wTx3l(<{Db?n}dQXF+bA#PXO@%Tx!s%!SjpQF_k=Y|5ipWeHb zLv~SU+`-7_6HbV!k)0d{2rimdt*4GsjjNebR4ApOQPM^pN+K29H8coaXzO0(BY-Ul zR$Tr$Z*`S?t<=Io!Zs;W;PgJ+9@OYNDT*^R%pnRVtwlA$I?;~CINk-eWOcsv+MONK z;ud_x=+#raYiuO6$oj|z12D))G@F3&EwS$0v$WzHtgU4CWTy&}-Ysd|(?F}J{AGTb zPU56UYxTpr%{OOOCQBg1xE(^DTyYLi`w8>U&*oZC~QB893B||lLW8gvD4~74C z+W|ph`}P1{`*va2EW{RwuZ?eC`5`j-4oN8a6Z8mI4B%Ta_*pjq4Q~$iTx0S2$7XQB7xMv zD1?EEmxMg(oe<#YXEN#|eIhDgW7KDp?23o!^epd_o~np?z=xtZLXha$Nc1vH`xpK(YH2UeF&j<2!VBG$(X;f!S{6Ap$AC-f z=V~B+X+&JSC|-cIt?tCg9-j$qnc+(_@aB=PtDrYs0OEr#Vjbpb)+31OIxo=D$ z@gtnAuGL2O&{$q<$JpiCB%x0BYD=GfTFL)>uSb>$~}(ma*=6rZ3%3L zS)W9<@bFloJT6cc?@Pj4fplNz!0u?<`I@@taZJPH3T)$`$t4ZPP)#G6R3A}io}=%{+^{;7!0s50UIooL}Z|b#in3F4K;X>f`eG%o&1g8XcViK zNIFw1EoY@CKozl49je!Pt&h4^X{x$0tARUC0}|(VBs4!!a7K-xk<~|80R(~SwP;IC zvF>cyB29_a6X2BN5~6%DJKm}P=vudCc4RQE*~4wHN}LMhBjvLXtET{5ZRIzd zm?2%O$gvjS(80b4tdL%L-k$^z0YZwn0iMVsM~ENV*M}DkFmmfBT+W$wnD;a%qlFYU z(XH6zX*zxbeWI-vAch8j-bvj*Q86908jA3ljp6O_Y$`Qiz_tScb2QD5sA`d>T3Fi8 zdqs16El8eGGoPF;-(4PL$CG4oy{wj?Xr4`ngMY(?2pZYSLEm_xpr*bNpNN@$UUYdIQ`ay+VOYq9dcxVgN$&}B_zEUs$MWu$C*NK1~pf=WpY z!@x(yob}9+IvT<~F@lSrm>mmZ{Y?BgVidmMF~FHR72r6W6;d#rM11K)0i^j8MO&zY z`lkTQFOllO7`~Ltn7$)z3S%4gP&twsAOk3yB_^;D*}85syd%)@64q17aX!)LmAnm; z$teJV;8cS`#r!t^uGA@7@GA+#%}0uXW;sV-@?q*+|BZ)0|PqmIi;F9PEQHD6p~ zXsBZ%eH;a%N0V#xR*XFjO)hXn`jj=S7g`p}Oe>kcjNf@1`5@+OWmfE>MI`mhAwB4I z3s;KA`da);<^UiQ7E^yJ%^}5Wpn<9uA?;T}k~s@sKOh7V7}H738WjzTxl$s#lHig` z-~&iQOdxGXkFS|<76EmVWTUBIM)GM&N-af6{0LmSARrp3#UXvy$q`z!xiSy{dvvN0 zEJQvL(-lY&#CaytK!ySz(&~U|XmOU$27L%6RGeqyu_%FP5QT-KLiWol}Xif>;=b~%`)_ZV@!Aj`7X3`HSkk2&YtjI>)40mHMl5iC#<|S zT9E*#+Wn%WB_*pm(TpC8ECP#HBkcqf5+!O_?v{9i|JM0vjhPEs=Xy_9KTXHGa!fqg4T6nMy#BfRQu9M%nTII@Cn3HAe&}olBw)Pqv`b+b)i9z z2*PM{&D#U`)qyV`?~a%S(T-*T%%r-?%GTAk+=yFk_pfZb zZJ)~nCsOB-X-p=|1*@lmF`SVV>a=(7;WAj+=0!4CnxumS0AvYIC-@kU#`)ir$7o0; zbP@u`j(UPg0ZhLl>#c(ZNl+Q5 zIP^#j-5^PE5cKwdzjK|0skZgCXlQ%81@fu1z(8xKGXWW5K;U4P8!JdH3SkYRhnVdZ zUH8_2PC$%xnSrKZDnq(`1cBWspA3_Mi2_Iiaby75VF>~>NuQIz^*cwrx=BQ*U=*f6 z6pb8RVZ<=9;tVcMX?v^aL}i0}c_xknh7}Bn`zY{QPIBfoYS#(eqh$=U(Ig)X)E&A# zp0Xv*xwbo(nr9X6?V0u%Mw@F=Pv?$$THPJbqFfqWJFP(7DlcPY@r+zF;HVZ?A3 z7V^DCQ!nasn%m2Fp*cF7;Fevtno-4S=xQo@yoG}{uzMS(4{azra*tS0Y;%;HC!!t{ z*~|A?ZQrh8Agh+Wb(S@TK^nOaWf<`)j4bEky}~kEh21RVxa|+m7?_BKt~BX660idE zmvI6F;jvqH?bPc{XpSflkT(9XdhhR(xT6UFCO_J39&>3!8r_L!qc!51cEU+^xkUUP-tx z)Qy~{qG+6{`eIuN3P*zBUY*DrYvBntYdi$0=!H1RMM7Jlb(O9PMm%;PGj5vhIoKtX zypTDpM7*hMN(6WdjK{50{*>9Qr-|RliaJwnCT}`oCzt>8{rlp_+OswBKY)tA^p4fx zL;cwg%b9OMj%6eAEGXRVk0DoZm^0ls#a%b8(NUdu?4%3M!uJFYtv;8CgmAefLb5DR zkYWF86zf-CzW57<;ydf=+N46XgGvm3+d;pz=SemhT-OoId!T1dCq242@G36bH`0lo zjX*mb9p&iHLnfv`OdPEqiJN4i#YuwkhNj@U68HM;2sN^+q$lz^)D{>kNZ(Z@6^TO= z=y|zFBxgK;bGz9Ejh@0TjA}BwsE%f0u@(k7QP^{FOWN)g>@qNh-)cn~v>u1dzrw4W zuG%QM2+gQ_5(!qTK*Bu921P>~0qf%tBJZZT1~r>bP|=~B@OQLLbxE-agqs!5VI}Du z0m*zUOytQ|cC0$FdX}S^*D*AXypZZO*b5pX-(WLvR0|#(d`ahKC2(#CJa1D(ksrm2 zm8!!d7eZdv;oRv}lpt*;HJ4NVOH)y`rOb%^% zjnzoqK1Bf;Z96MK8qp7684Uw+F<}s+oCedUs@9J_Ziu(9d_w#>25qX4w=z#F33|*C zs%)CtU#wN`j#zFs7t^NV%zdjs!%*gUPrlxTtT)^vNYtEf_|LqYPj~P zW(13U(2dow`+ZSQ9!+)P8WY25>VurnLWC_e2}3$&16pVp$JAH38&1i{Fg?|3+T;1j0|v=ws}V?SV-*lH zK_%+;)}DX{Xp(KAV_As*+QvpIl>^ zyZ1#Is^OHlOw)5L^0O#`#Yqma_vRql+m6Xg~V3iHi=OEdGQw&gryc|M2oq14> zimQImv`g1Cj5n+-5HR091vJ4v1h!XSVNmdXG#jSk=4W4UM!qVtrE(2e>p)w$Q~qzX z)z&wYfS_JloA0(R!D%eMB-S{6v>*(lCgukJ3btBD|I5U>w{?Oh1l0Z$|P6pPg}ULfsebmv-+bFh&o#- z*ohN*P?UAn!X= zdQ50D{|p8O@FYh5>=}M&j`B;0?J1phwu+k#_hbg4R{{e*OT|*&c*ro#C0U6ISH!}& zf*eY<{EI7cYjxB1B{hjCQcqh9id3OLuNunk_GU6r;AuQt{Md zu-ms`GLo^GfflL}8Uw^$Bd4VDSAuKL2Z0sT^fW5HXQu6Usy!cZ^zXXs}T-Fz{eAWkKoW7vwx4hVAN~y}g zfQYO*bqn4hXN>aVMqO@2MZvMELyNHEe0Bx!={{)H+_Foe{*QKf8$fV#&h%crzr6;w z+U(n~;#;A=)nJvIdL=R6QWLGdf#9yu=;}P*Qr!|KBkc_Ky71{w+(IH68&Lt34n$jD z8s;O>vGU_v=OYrA@>|>aMtdVazHmOO)t8^Q;Pd;@VSxDP7I|9&Y0bc#N9zO_$daVI zzx{e|WtXTZMY&JY*O1-76BmX`0LBZIV4So-j#IefDQP0zru6JuWTZ(`4D7LhyW&>e zb;Zs+PzOynhsxQIU^WxbCEv54pQJ~q$q%6DC(h)VnJ4JW)QsxV+(SSMRw-;xBWQtz z?bFq$mf`>Gv(bp|kw?O=1h_9{;1~N~AX*QNc~NNaR`G1jm=VNf3b8$ebTcs1fEUqq zcej^_q64cr=vR;*U_5obw6(R=?}t$wfE=J?fP%$t2YK<)fN|M1Z7?ksxiG}^mefJ^ z-Wi?(^4h2((9qIuk7k3)mi{ZTlBM1xe20*TT))_K=)1;M%<8NAfsl~r1E4O? zYjL!Et-v06-UC*JY5Iso_|}j$(Mh@w-n-CkLyoE;huz>atl-aH(k>H=*5f$Rqu(^F zLybd6uK=TD#_I*OeCd^-KKdhw{<&9#sq{jTFL&>w@z_d5K#XCrKbmF()vRiCc{wu8 z)U{^D(3Q1Y&u&?YZFg)-7MU4ZzjZ+rPZtce33|EY9;QU3!)a##SwN=0kc^8| zpuw8yM)V00`KXPGPEFn6;$2Hb{TM}D?4pylT9e^C3Avp|4@lgsMzf-O>z)5uzI{z9ND_b@zetC}Sj?PqS%+LBpL=P}t1G)ljfDn?-6FWxrWVyc}_gY7X! z4tTr=0qAF=b8(nQjcD(#`K9brki3b+UAKLaP9|ADRaP-#u};Bs|7-|`G7xu(0ZL8|Dk^BHF1l-f!@lmWKPnJxc#i((_6rIdXa?4<>w zf%aG>&^=C4aAAko;)=}5soeAullH=f6-LP}{pYuUs{i8dxvz-3`F0sSmM>~r;N)lf z;LEf47wrERL(#!v7)pRDlLb7bCM?0DGB+!OqxxcoU@flYLQHU|35~t9cZON82iN)# z15_6X3O|C$?~mZ?BEhPG@c^{DebKa2Uzq_gB3fZn6Jx@eTHRa7oo3ya+De6B{^I)S z3jARP16)I?Ql9=y0VA_+&M4{ zZh_wnuMRFSdL>#;Qt}%Q?f*@{R|5=il&V$ieID>?hLu%vgN(9o7;4lVQ9~}Q#|g$B z3vf4bZIyA_joRi5i=~~}GM+`F900R$U|$P1UBMO{`Wbs2*%? z4&@W>PwtJ?Sru7AJGvNcvM5#ZJ;)I$aFI00Tx!H9p$wkG1&f9dp)wT8hN#vma@CIv zB{3N!CFO2_&dDW=q5Y>EDV9Tm$lB4fXHSscmJzLx(*WlYXRkGiaNcA6(rM>c+6P(y zu}tMdT*d*ic_j_dt7uyJuU$x)8ui*ozPn2dx!z77)qsrUWR7VA-u5sZOM>Zv0N;Rn z@986miFKT014;o0DP4h{MN55s^{4@}gI_}B%4i;#FNjCi{)$~_z)aPKGD#suqI#o< zCi=Nx+xi-^8o3p)pXPP_<5=^4f86-WD26lFm< zzsus(OL0TRmBGgYnCKX{xtD^!T0R52!il(zF0w>U&D=v`3r&bI-1MUPUGE(SbxGc$ zjK7R|MR;GO?Vp!SGn5uqJ zyonra0fO`Ui@v^{*0fM{`6BzrB$eq&QIXRGCq_NP;|#&%Ai9o3UKq(oa0{0Sd9j}Ydq5Iy zg<+3Vac5=uq{;Gyl}5__rM+LtJH*7xHln%(CMHWaN=>`TE8XubSfPv|LW(S|yn?yr z>RS0xoXQ{dl#!7VL%;;rl1qwqA*(iA=>4n@ELK15iJH2LOQ2(5`Esm1k^w@75ceOn zy)0S?pycDE5Vtj$#1xVikdc-yWt?)lucPnA9WBBi5f6kJ>=X)v`vwBfL{l*lh!Qmd zt_Kw%(`7NANtR;L#sobHQ4KEXtfsR^F4tv(Ng5=erUITYVDo7-g>wauSOsRpD}@QQ zuLMN$X$lf*S{MvEQNgi6!dWS3R~jH?TdWpX(iCFx1md`Wpb~IxtMn~+b2AC`O~;GJ zkFT&+N|Z16)-|l**W3(z4;t1Dsw1CE^!t_5U@}~vn_C6N!Y1_XXo2DBmV_qJ?u zBOOtQ?{cfB>eIIkS|E_*w=BJ!w;;>JrM`FIcLJx6(BD{f}JS zs&iYxzQC*-?YFCoVUe~E4Y;5z(?C`qQQf$5m?*a!z73kwdB|}GtL4GJj4YQ zz9#~e{9veu2kQrm8C;wg!khJz$^3Ph=E@?`dsDLSDpWgimu|B}1%DO9esN8;i2Xp- zyFkOJgB7?~5R3&;x5qn2tBkZeX;FFzhzf~ zizl#F0ioiZC5xUX1te)lo-fDjD_V?g5-^n(R1?gpx=X^|M4Fx{|9D2 zQu2pkGMa%!61YdqFb&WQrOi-9>}esB+pB4zegdl`+u4M;C5&gDfcllAtjq7Y@S@O-kD+)-uX-22Mb@(nLU~6 z-m0ins*Yi#Ih$p_E-9L&L7<~KMz7uh=;l;D3Z=;?W`da&d_59HMI!=smY4v9$5(g%XNO7ISAAC|8@{Xs!5CySV7 z#!6q~22%P`k=v*07-;sYbOfeng6J|v2FKT|Y{gyp-}MAIe5CgX=v-74C!k#B>kdE# zBX^okHAAd0Yk-sU6%Da+jE!>R8ND5|zWXE3A=t3t@h)s;5qBx&6{q2;6`U<0u8G~NWL3T^qIlZ`;6Tz5S@lXYQA zG^}7s9V8p1hzir5l3^G$ikRu-x`eZRCpG{LT4wx3FtI3QSD#QWTfPt89R@CgcZVSu zvX&}|^w64t{Wf>NoDDDUqHg;eHqwmGvwx*^)q{1=w!NEh;p>uG3#s2U!SR>-UnjlZ zYzQm|+BLj$s*=F}kkJipfj$IqWKj`y`lm&P5b^Gbn)VK$oJzw~3&BEuiQy~-^&?37 z46OfC3?qgVGWvT+D5359_H(*mhv;Z#x^#BEqpNI+8qT4$BU{n_VZ)xd8{$1GFzFCm z0l4XWiUO2g(Zt5a#%LRu;jg7AarJoCkm<;mMvZSPMlAtxFxaHG64OH@{>#y8nNP!R zyB^G)v@D%wRxh7%G`srHr}q=Y0;ZxW3cg{-pP>TS(ELr$AY4~m>yil z*0e;v6i8DrzZ67EX#WK_59#$9@_I~Ae=WceyM-{~DOpY!wIHmQ0Zv5|%hz9oSH@v9Y+xQ5oe^}o%aQ657Cr*(D~@r9UtPf5wn zQkBzKe04R4@c)txtyH3ZR|;OQl&y383Vk;;067F~^SZiBp7dR~*mHA^Zp?Q2j^+YK z@|>SXIh?bi%uyrqvcjccsS+=0iZTC8Y|)`i!3Ba`M(IR^G?n zYJ(@+g-%Tdy!oG4y!RPITZca-#|#~I80wU6;d$LJz-GTmd$S1`Y77*W*t zz&qPut3W1G;A}U7h~z+{AEzm$EKe~-UxscPU~>&9qYuamQ?zhnXkY~ZC)u~Cw93J@ z2rvGV*3w^h+PTied*0umNBU#uG*^nT=T`YT9Kg>>NwGEv9}LH4$y2vhVeDpdQAqot zy4OwGb+mS+XEzz4ud>&4?OR4z*7iWw-|!gc>)2!yKI5E{vTfdSefww{p+;@-wKW<` za^SP!2@57lcXV}ecj+ht=&XmVPWb|;?5eV|1x>rFBF8#TZYNlT@`4mt`tDtl2)&(sNQVX|6%^Nd(7Y#Q0w#YdQZ9yMpA@H?{d zWTnxWvC7?$LL^WCS507Njc7#fwRl14-%6>2h$DZ(f=$ZXiay-3 zZbMg6!*Gbo@KP_Ob-`@Or5ZJmTwe1kb}Bdcs&~qc!};#0F;(HlbzAUomy!Hp&D8^7~`PrStbsqooHc zE4DMqFg=TU15lEtBk-NKchAqRf}8y%+FqgvpIvS5Z*NVS(eqg$v)zgFHye?IFZ_bY zwBlSQf~zENCXCm*q{as!T!)3pxEd0kVR<#HdJ_!cWx7Q5E|_c^DpJT$6H#(D5~ttr zLzX}f690mLYt)Azdn$VogdfG-$!8FX6SLh?$jBmkwX~{&U^AEErV|2GTFyVd$g}=a z;4SijC~Km@q8A*s@|X)TG9$JY>Dz^)eI1Lc9DUw zv5yW<$7ISTri2Zdy3;1Uc-9m{741Bx{TKlb01*U!yyX>v1cL%6kQ`R0I6_-730gX` zzma9J@cy_q!{n;A%GXIjW!*mc5>JT*q4?LUkeNf!Im2Pvhq(PU%(2e4;-nD`tysw# z>A{_#PyZ9M>d!<+YX*hYrVZ5S!t&k591PPEwv};fEM!ZszA{15wv6+LvRN+tpIl_f80-ukgKu=|OOV{u%iXqW3yOGLSb=#Kf2esN=fw9$JpI?2)j`HvkX zMMV%{w^!VrFBgBrfBuJ{W(@{PNr&1Kd-klu_Sa`hNh*~qz`6N7q^)dg!36rE0VBy#ZLMZXsv1;*_+HqOS{AP7DH&V*I z22dhuTKCs2+_ZOTa@dG!$I3+;etTLB$TfWdUyUbj86=Fy`CqYL+!-Zc zSI;<2C|W_)GJokc)*2a;+S}OhEX<*53XdOmz9!dyFa|D3Q%$j_HE&`m(C=;YvDJEf zaB}PI(UVfJ7fvTroMk7|8@DR!g&P)F@t?nE~4Fa{Cju6rdJ?r13vRqKx(>cV4 zKx@2&_(>FmfGc$L9z!hZ{S@(&`r)J_L* ziy{g6{x)W!aWge`i5S4*aKK0+svKDx%o`b=)m-5D?IanGWzF}u54}lQA^H$TFUKsw zy@6P`2!1M^KUQwQH-nl5BnlvqvJuJ|0z_JEkexFZTS~=kk0F#;I8~EF3MMt#T(O=& z0)Iw!yzDPT!h{nxh&B{*P`8&817?ouIqPRCn6ELX4bA>-p zB!{Ke)V=;3f9~b9C2u<7tSn>p!d+^pPO8|-gVYQgdq|O=kWDIHSa0Gi3Kr;{*1}?B;h;wE1$zrIv zIH$+N^l4oWw%9DSA{b)PtL})F_z8@psiRgfNt~l76<{mpq8ex-PJ?_x??=pqQJj(i zu*(MK@x+*)QFM!zCPg}ve}H7$n8+SRG?^A}v+0@WKx{wor*>I)pDBeSv}qlBEjEGy zW7??|vyJAHmGFC#jt64FYRmum{(bSI=zTeBL@IBREw`8Xm!vjW0KUM>wP8j4%l!Ys&IUo4n-DlWahtXygv|shuh8;Tnm^M9o9)N?FRySP)c+BU0p}XX@}0 zD%FG(?E;ly_Pwq&&zO7@PEdKPNYaEf2{ys`9ov>ytH`04Qx}PhW>!d#ZD%lwREKyw zPhyF6CC@-M4U;4%*e6DEJ zEQY>b3=G0yv+oUat`zZQf0U`c8d2Gq_)9rTH$*+8Sx!>1xf7VXytUU5r%6nsX-31JU*5pS8H~*8A9(Y-HePevPNw;P@jR|mKAHkJr*dfCgx7~ zL|W$u%(oLH2TIo4#3fP#mIy3O4Bsn?3OZ<(T3;(LA}IJ!^uV?{sW6Wz-U6>hUP*m$c-3{AS6!F9s^s-zT3%9G%QY{e?N^=X zW#_lf%TQuRD)@L$N|iNFW)1GKo|`C$-t^|@yThke9*#Zj@?EDNf0h7#756J&M^JEJ zezhd1aVp@ z`m)`cl**|p9$!Y)=V`f5pYH<}5s!E7a1KQ@XF0=t@#dxC*i)`W21Yl1TvLn|JDI^{ zJIw|W`s1yYTrgz+fMIGdW5KV&u%Ho2GH#EJx`(03Rj`JsQV>!I-Rbl?8Zau{_`#~g zeT}HQ^N09P4MMJCX|Pq)m)0E22O+b4Z|@GZI} z-YPp~aqMrZ*DZrc-L&>?bQ(DpEW)|FWdNc$K_Fau=`C6#5a9IAlF=zaIADy);2Hp2 z0oN@KzA2AURlbfS-pNb z@=wp~%@k1?GZ6vr5STc?(IjCD{fmU4@Ub(w&jIBVo>d)GFo|MZQIA zNsSnqTZT%5B)pVCC&hKC>^AoBGxn@&{j_)88%XX?jiMn>LJixl2X)G-mDhL^)YOD9 z=*$SNkGnQQZn{mA2G9LL6`X!d@>kf&H|a%op%B%GX|3_TgR>5rjuh5U)2KY&IO|@l~9Q#J#u@4Z+~)eO-UG} z=D%j6K5Vp6s_tekX0?$4*XhZ{0J9=jWAocUB$FbA${&DyEYzj|C1`Cu1R>7})DQx( zUJb0=X_oc64nqBLB4Smy$-oUzzNabJi@D{C+D%RBY*jBy68r37LOrP<*# zR!7t}`3Kvr!q&_D30fI?4+D~Kzi82@N8!pg?`bV)m`jjQHh?$0lRiCQkAdZ$HBo$L z#T;h}Num$eqDfO@2u1UKaiTn8%e4+E&N!B#s`_`~Q3D8`0DwPM_ z8c@I(r(XxMVdyT3YRHZ|_Giy{26IuM&aJY*Fhz6d&tykvF00FD11F^9fr{60)IqEYUd2vB zD%d{}(xk%!Yk=7#h2Syd%h8_!X%EZHlbTWBm?27bj?vR(hzX8hQbpY&7?4=Nrr1=7 zZGvj}1^*KV><2W?U5j3?@4fg!lm<=?3d1{cg@NUKortq4ksq$YAcsK~EPYkp>&+&H zE{S&YhUx4gfrLlEU_LT0lXok?bSCVTpL)QbiiAk&b*dmJwEnCo#~{b{uXkoz;z1yc z!++6mFgc5&Jh&7J+JP)j{RV}(S03Y-S8o97Qtc*=Cy|<4_p~)hdnx4a)f^@Ueb5I> zRzM#k){0+BjqlC4zs<2K^|dpi&V;yrBg~61WsZMr{T4Q%0iF1BwUY1YEQU z2Q4vx4Ku}cwdSaYZQ2`)dxk5-st%1)no6lp9^TsOm5_SfV}z@m=mce|*=9M6L7tC^)lMg-7^hO9 zq>3qnA6T&&%}llh)R%XOsPqTv2&V2CbqVQZk)l+*0pSuix%vvsAOvTNlp{*q0t#XD znlp$Al9-XLmlV^Cw2bF6%_e}OkX@Ik|8&Cu?=cI zC?v*KVl-o7WdEvDwW>vjW^lD7dX^BK9TJL0=e>7mtd!yNAu~+j>+I;1OY>H^+n%@% z`Qps#&o8A}p=pR84_Lvz#N{x}G1vQ9Qn0XJO`tI3^csk->m?*0mI7@>^=jCk6_%hv z4fmt7UJhY}J*p+NtJVW(#s|gPHr(%U`$4%XM_=kSwdP2j+0ISqm|aXk+ioxs9sC3? z51{tYgIdxbO-S4bIbT7mQ|RbhGVSb-8V%Uwucm+Lq$=7M2xgazc2Z~>T#2rxFcL*6 zv*?f1)T7Z5>>QKlYpP|mTB@#2nYITAetIq^xJ zD7drl(VBfML33>|?Pow6e!)#n2#2EX*}o=<@QIEKn84Mlt6% z_5s^G$*{Eoedc7!*B_&eTrBA*o&2lN6u#bUVvQ6a8v8IG_wtC9=ZAb>^mRx+4i>|Y?YJ5@(O@r)`3c7mu|^Q5{tiJ)kw zpd&}OX>nHuW2t5p<}!4=WS^QA=K)zB(;;0+bm?-++t!DgxOP5D+%cCeU5H99+Dyjd z!L`~AYU7=p8j>4_R$FDVVgafG<|Ha8YU2IKy{@r9d0td6G%a?~qRMgDr2V(QGmeFd zx)v(p@H8O>DA8)A_9H!PFv$?lil*a5$`p@69G`J+Zt=Nye5pN)>CbVt}ei$2EuG;tBKLIrNBf~fPx^Z!bCoF-1nOHtb`dTP zk{b%1TUlG8(UkHbEQ3BvVJKCSO5UGr zV9g#f6d6yl3)qPd#T0|LSla_5k^$gpOei0JCbe=_br~?@mWm+(9XJKx*ui&jl+s4w zx~RUu$vLg2$DZ|7ln$|#%yXO zSf-(hp?yRO+whcFf^77q8^i*G&ILg|5lb*OXGdBSp;%FlY)nCUR8MpSus;(>Mtwxj zIQ>=4M8z*$U@SYcES(B6<@*iE_i=&ousw1@ZCEw*t~@E>6W!2mI-L&Ee(7Y~a)H6B z^+tkUsam;P8&X*d1SJc#zyV6OAkUqHH-k;Fny@>M_f{Lx-rc9lo>;IrgOd#OJzyMD zyI4cqh?}#w8vUg@!BkFrt556Pd`KDh z+EMEudbz!^7PYru{cA63cV2g1wWIA<(fX@{y%*hA8&PdI>z&oT_FP+(F~0vY`FyR- zRivm6pQictnBPjoarqEcu@16EXM)W4=_E7MF*px#O0wj)3CKnSI; z*fv(LF{>K8_1N1wD$bPUvJUeZ)rdwV8)0eoA=?p)Gst?`6o@)>Y8J;Jfe>xt7)ZF5 z9?LYW*$5`>oiMIj;o2Hc&t{`@&>LYuGr5ew(`WMFQ@a90#C326E$`XQ@};7{Y?Q&4 zf^mw5r9%RkJ0IJ5){aniaMXw-S@EMAO(NRcdkJJ>kxtoI#I;v*!wxuOqL7=SAZt-f zZ9?ipXjLq1M)`dU8)C%Any9FCxD4@lmsQ7NgDCg{tI!G$6dpkFj^dQ0!T@wa<)X4Z z8RJf_8X1UVG*LCiOGKmiHx-1hja>vFdPf6drc*8{?e_79>;Sa6>yWJEdw0PLa8vX60GKviR2 zMZ=ub2P4&EG*p|PoaTJ~f)It#TGJ=iO&LxaQ`|3=_#R;e5WX^I^j-uK1(kw`(S@Xn zK8f~9%~1Q<2r^3SKaHM6`w=$fZ)Lr>9`&#(=yj3S+#B(+c#R$4wfLfQ(1@Pz@9n?o zL|dJ;=sHc#8c`S3C+I>C&Q0gcxgAZqWF!>87Ua$*7P^^(TR*~NoQRVnc;0#guNHaR zZb#j{Mzpp5swtrV^R+DvLd6=kr3~Ms5e3Hn98KjFaGFex!DGCa3yQRdPy(lcO468= z%m3NzG{pu1q(Om`Cg)AdDN&>2Elgar0su$uNelz!Cj!=BQID7*SMQ7rxq#9Q+074V z&uds&2~)%ZV1L^G3=W73XgV#LL=t<25ACZ$+ULssNJ7fqNDWl*7)4S>96 zdDFt1rasTM<;|<@==GcJt?q6oT7SFV-2)o#MdwYYX$&EvSMpXP_&CkAzJ(loE>qSX zhM84qr<6zvuV`dCo2n>|NuXTfFKCZz^}0_CLHl!yyIsBMY<0kbZp}jsw^!b z1{<1W{eC*SMXQwn7U1D^cJ)vY@4hx@x1p~2*XT$3C$}G?h%gF5>UAr2GAf%g8J|Lt z3Y2XSgZs$Uxy7uwf;zhY04zp1$(E?lGLnl+z+*yLZsY!ex_uI15gNqn@7#x)kLpCN zkrTR;hN73S9`fdf6QGw7LgA?j7C@i@HJmBDWWW;G30Ln+1g;qj{p@NMM{|` z*hWwYYg11pVngi3l}z~JDMr56({!@t@e_2G4#?`!L9IH%N#t^Ak^#meaFO(8vmr#M zz`AGCE9LWP4it+zMpIll$Oy8l)+>yKam<`*v63!afvv*NdsR3MJ-h^E8Km!)M zg7~Jq$ksK)yF%)KcP05%+sQ>E027HSDglGB2g1^BPpS#ynL_laH7Nyz9(?V#Cpk^t zqGmpwJ+8PLc#FUWveuBEb>&pB`=0#eZoha2mueWpT6nt*H^jSJ zj7L(vDzr$JgYsA1+f%8N8?;{|x}nZ?w>-}B9!PG$+6WUh*xrrzx8FgfLrZKdo1wf^ zk?T*x4ME;2QA#lzBc+ISz|OUwF85OmTV(YY+!oF|@=k4@axUhvLmwIp6D^s-Zr6&f zDuSv3BdX%JItx zqg^O#ggrtA%=pDvAPmvJ^1KmU*a+#ODo7VuX?IToi_{=iJSE?ZHH;w)3#7cne#3>) z9CFzk^c{@n5a^p>Q>KHi*}-mf>ojymT@0Hvy4txz7x+RB-OM{3*KvCS>{M=vjq$@x zoX>gkn8%{M{ioyw$AbeofmrsnRAb*53uMKsyKhJ8nXYn@X?i!fm{ZZ_^lrs^-qS=T37?#_$n~GeG0U^UopTF z*eKT({RQEK}I$6$?0-G?-k2} zsOk&cf4-dbFF@qhU&4~jv*~c~Z-Cbc)WE*BpHZ4JDp3lZk)52-K3XEqeX-!E4ORk2 zTc$bAdgr>rV+zKprERad9sm>E@0Cg1^2Vi*{+;qgZ6pf}Rc50aPfUX(cOB3o1H~#O5E7 zOqE1hM<+*c2g7)^=!gxFWt+>v^lgG6LwE(6R|6Yz{8UkILf=Co&g?`_#ax`09CGf> zY2A*DbG*qNDaLD-lyb%GVPr&zRcWoait}X>$Z^pLM2Q3_g8(DMI)##$fQvHg62gWm zCsjMBU@5+Vwbup3X`j;@g*8D@va`CzYq|f=spAmNF*k3U#EloI2oY*orH7UiJ$79nJ5y*~` zF+On;4wm}ByjD+G)$t_nrA6_qDPwesC(O@f+xj|b|KK0jDq~l?EN7^w&PDOxgD@7W zfq-UPCH9(2S%qy$9$E^5=s*nJSe?)5P$h ztiA&Z@Bg3RiSmOteq}p5&8CH!oGB0nhW7-4gXmk3COJONgO3p>4BzIvcrU@kY^j5v80U?^Mf^e{yOGAovRF_AA$;1f1fFQGmZZS&#RYFQ)th$94l7`S|$3Tb7H zC*>-qm3=(*RjBOaDfQvIpJC^>HG@;$e}{pnGr{Rz#pY*_rUuGzyjd-shNTaxBbKFerTOrIKlkA+y#qQ^q5SR3RH!nM zJ%L1DPI7BXc}iWwd0Mrr%WMS7HV~2iEi0|>6yosIj`^BD5Nj@a`Z21l3W(4v$aanv zSkzjgCIm|p-BFK8X_LrKLo`I$tqaPPU_K;Q_6N@n$sR=;2GB%3^JAp0pOH&bU~pAV zM4Qzfc~<+;JJAU?4%QWzK;69Iiy#na4L^+VP@TfhxsqntMp49bf2EPg(Q;D2>|q=3#+w2RPWihHH%xg2PLIWI<(==Z8t zmtuC5oog}W)x7hny|2x&{eS*10!x@%Z#qi`0g%Al(R(>XwUo_-PA4@K`ilKo0j2#} zE7iiv&TL#tUFdLhCao~dM$GTS0Gz_m`VB%zeGV0TnqGoNGqS3Klnk6~>I$X-w znhJ4OMRbcL9`$OYg{}!3Cyl&;h;-0hm26mcU}Xi?XvAD9aG_)&8@)YAlS@Ij{8g)) z%?J>ksv>x1(7C^WCAQnM3C|0NKPNwzqr1D|^knl|5mkmA2qa5X?q4Phsu}fDn)hVT}p33qyTBhdK`tKih*PnMjbYJatHac(Ma<^+dc58HB*)^oIS4GPE+v7>v z%P>BNz94OpHvR`$?gPQe=a4WLz|Y8M-Oy z;kRR|XKNUZ+^nEBat-4YNPTN2r_d|Vn__KgyQ6$$7JQU~G%lH76hR}B;BeRQBTOTb z=GZbrcS*d7vihwC$CJ4DVr5urC^1QLjt||LQtDB?mNNA1H?7-unt4{9G0vc3&Mql- zWL@T{ju^>^BYA--*YUnSg+qeG9j6KW;J7hesf{Yqcp5B0pzF{OOroEmAtdqb^SDy% z_hjLYX{WzW*8@J`Q9!84=qqS{B<_NhKzpZO)!x%!d#LY#T~XYJNX47LEFJN-`ikkS-}pZ1=2~w$css8JO$|(%K^97m$dIY%0Fg zo?hG17e(oh=H#MhP?CNXm^`U~ldo#=X}Co=L}~Tum90|WaA%JenENmp3z$Hastnf; za@A~(02jiScHTT+i}qi=*?#%5(~h3M+1>)AOD0$@$mK3G;0Ee-t!w+`b;30 z8Jlw{%@AZ_Nw5^&a>uh%Fj)DRTqI;%6V;FwqIQ;6n-56SzO)+EZr!Ta*Vrg;*=)-S z2sz+F7tc$)5d?YmqI{qsk}fs%Zvr`FR~2*>e)TFtdf6};6x=7RjJLgJgcdvkkkBy2 z^N-Q$O7!E8y779n?7o?kV%o=m{R-Iy(5+W8z;ad%l>ULX79u?+qcopEaNB-gV7Jfd zBnOkF=qp!DU>^e&4M^gSpGjY9PKbh%sSG0YYI{#$&{MEiPXNE@1TrZ;7yiaD#ua5ovz{;vRbvXb3t(_Din{k)fHz9R{9J& z9KcrRmjG$vpCE;zr-wkUaCMnB^v-w=U8vR0=0x!IgbYIVB!X#*veW0;X<_Yv4RGb9 zw~)$Te`#^5c%-`Y+qGU_agz8!ywxYF#*$oH+=pJ84d`i*pRTUdn3PuLxeaa|7fVx7 zj4hvDfLYG!-IeBw{BM<`Nf-)YMYY4rw8Oa3kRxUBjXzF`^ll6@$g1^LD2ga?n=3~=%E%^1 z4(5kHMeQ$*Nc@{z;lDVDFES{A4W5pC5XW-|#sfQem#vZ#dP0F`_;*cgx(T-X^DLNEQ^OK{G&1 zVYBSc@RFZ8?I^AeP`g;oEDUAYmL99>L=nhSNmaRrT%J>pr4pqG>%ICRW~{D#Xh5P@ zq!Y6skd1p&uAVQ^3=3-M2|NgfR-{~MbwxeFq;35?Nv+j^7sq1-G|4E@P=i6HQ7iw~ z#KZw^e9f#8atqpV4yUihEXx#;fU4gBxSy3sA`b^M8TIYG$snQq(rVqh7pOt5NtHV3 z71Lb<+Jf0ZlMqM!|9F3U0p^T+erp2RqIXUA)ywXyjs|2*m)Zb1MJvw-a_UlSp?=Z7o&o#x z(-hd+F^YVXLf{?pb}VHw&pnZ*^OC`{pCks)HXdffpX(pevz@khk zbTYn`k}2B>k_Af69m{E^sf6>J4^kk1WGm&c$Er*}6AXR>^(N!#*&0p!ODQY0TARSc z&(rI|%~EK5kjUE!VU4*C2oN}OvlW>YKGF*1j|Il9!Bh{=e~dSygYErj|Fv2|?hXis z`EIg#6WiK%r^~qKFn)B5Xr5$)sWdl;qH}E%s_o>@%fYF2$WX{%4_aYLBGN57bhkpp zjN6B7kS1hwWsTao@qesW-M%n-$Z5n8OKCf7w=fJN<=GUkkEQsy7L}F=76&JAe&~e7 zm}hI0oAl+(zeU_UXb%8U_n|XLa*_A4M5cs5IscE`DM!cb^GZ_bHW5>I&c5T^fgt1q zpb+>dTLm}gRBm09d3jYz25$UdQLBDwUOo*>1<>}Nwk*t)tdLg5boXLrQN&gR5&$Md zVSf3K@ zvfdpkWtKh4XH9au6m+pVknsHH7n(W=O5TBV1Wsm}93BQqc5!)jq#rt3=4pZvmFzlE zJnj8Ei)hDN^YH0Ysd_*D_)KP8=2`mCT6QuiNwGw6iT){y1K@Z$NeVeu!{QBr_<5FT zX^kODoZniAQWbC6MQ*3aLgLlB3$=s3p=WW77(Xg{wg2*^%t*J!(`KCWE-r%6f$WRh zb2T9ZU?wYmGn~U{F1%Ra2iMdi zYog7vXwSMZF|STGQif$#hzP{<6PXi*TC=892QzqxI7xAN*hcV$rx{pR-8NicU_*B~ z$)>5wVTg1pECm|pB$Jf$d(=)y4no7)SH&0GOX&>^lr8P1-~dTLw!a6(cUUZb<9~@DEVsp8l`+fc}MTdlMA3oZRRt`w$)BJ#nkdXD8A5y(iTG4M4x zBm*pP_Pcr;)&~Q#0c!DsD{mHe9&}3#uGjC;4WTdKHyx$}rw$cJKP{ zNJ`AfoW<8ubL;=;T2hN&w~AEv?_IxknvM+}Yf%fiFI_zeowTe0984KE>dSwbm%<9k z0n~CNl1js=*F)ikX!TWfovuPoTGE>}I@EP(L{M(Oc2QS4EGQ~)THTvV0yc&cWoh&M z(0aqbSk$;L)hmzUuKyD7RWN4&*npl{HH(Z=@;b3<-yalFtq3SwS!sZ{Nm*%NNGGCl zwCYEtRgh$``ik_gqJAamR$nt5nV=k1X#AI*y-u|EqPrXIZok>PMY(Z?$+=)QhIv07 zM6+=rxc@>%h6iae4Xh~iD1Y;D z@jwdL@7!$Wuv|DpG2bVI0OMyWAvSB3vEK`ui41b?2d2k?#_- z4U(*NX90PI8!e8M!hFLT*+l2&)9R)AAG%Dh@)2GK|I=Ve9aK4SXk(Kt7r*6QhArIw%xwR!lVZ@N4(0oW=V597qiwZ#N92|Tg>-S_*tz#y_<1~7ITfAxZ&ay$j z`Qzy%8TIk`{cTLjj6OQJd}4y>SVu9cSZAV}kEI2y4d_ZTQzEFtK<*)%k3U*-XE%WE z9|Vi6=X(A9e6*r@=zd=Y@(t2if4aGBJsYbjODnW7Lq;~po%TU|HCdKHAz)41E8`gBfW3K>ev(s&jGXv!<2c zm!S=_v_^oKCa_H`@jQ8)>X88nEy}3%U|ZajK2WBpYNVtV^e#>zL5b~VjSSPp$GSA> zK;H-N6mX3=#N$?$;O;vj#a>dROWCMMM`WZwxc1;lirpqQ??-WlF@6KM??Lh+?w#sA zy|l6N;4Txqk>x{Njy*3>0+VJ}D}rLt*8xT><@oDRnqespEJ zP_m<~y}$jR=*bE=jG4>+xO|G>3%R?|tmX&s=zV`XlkjZm#56G2pfE`(lka)m9^G1W z&Ifo{+FU>0&3UqKu~pD})+YxGRR(hk)9#Big()}``fZdpze(ql+&1tC$kwsN0+=$e zjA}|qz+#u8R4(YyhHm5XcZRtRdTKtKS6iH!jD$b@t!Spcr73~D&e0Rbv@in=Tl4rv51kWs$#;b{bPL#{LET3L73hCnTOq) z1$y(sZ#W7h%WJYfq~8%w@`ujW6#r9$H)vnuoze zmYCZNZBhU!(WVJ7Jb~O!kgnqOB%kJB+p$ftmCa=&+opsqilPx%v!-h2m!nO;NFk3M)s%af3{vnpvR=hFM3$@>8#H{sd%Q z&zkS3%Ati5lo5691W`is7=ktD^_pyM5d?vZ8=mMmfoLL{UJo!=9lRNhEc0GM7OsH8Q>tHpZsqA?cnYj&wM#U#+_L?Di>!g2$-}X@H>!CyTOS;Mmw|HSGkU*Lw zxDufDO70D(Q^@KleI*(ZriQeVV+}ru3KtogueX}T?3iW;{zI~LV=zkcB65F*vz<+Hz%`Hwk#eq% z@)5ktzzyzt%@b=RJ(<2v`n5t~)NJ(9T3uj{`!QR7&vMHWj(W2kkW6(}m)CHLY3)UA zmU?M0trZRQ^m3DOEg`3<+K{0lw7Y3hud~rdOVO$xdEH^N#PBf|#cs{=Emp85YuT-d zI$HmE2Y$I}8^o}d(1j4D6A+XneeFgcT5e}`RR~czX*-yJiWDGD`1{){AnMZ1HRw&y zqm0RxbkPTJr#@&i`?%klBdll{6zd<|q>m`I14zjPXPBxjOr?Ua3B?O=Z;mkYe z;@$h(QuhI?hL4kU^!_%ffWZIZOi)nt6(0-s4T2lXZ}-g`r(>lwB7Q*XEmB|{4by^@#>P1n@cP$t=iiQ}Yf1)PL6r;}tjOeTZt zW-lKu9}n`=Wg7I-NC0=StZhGKCo&v8C^v5TO+i&j6fTj=8H-)$w8K_^Zi7b9EY?3m zu`)DYuWDcJ-C~0cjurSl@ShPFRDfFjn`WF9i%&Ew8nVTDIiX*9=+23h@~3J~$*)L! zF(;b^W(hL>fKMVPMiIm~RD7@2)KOvV3o>P!OcD*o&%m>)di&5DrdIbW$r@bXcZ~9f zY)9HHF%auk6#(}JY5{3I!M@dRSi1;U2XWXJlN#Qn0~bU_o?}uBpeIZ^c#OpYVqmlj zLEnpK(QZl>VMo7;V{}Ao4_Ut_z2%d18S-8>r==WHrU9|mW~ctb%#`9E^ZnhSUnI$_ zEe-c9C3~hp>;ACzxQTB5VnvM0LmjF2rPZ)tN;iz+9~N$E%9eFr#3?iKgrrZ&fh{E)zo1M^ei6#A)nM){M+n?A%)Lj-w4zHm^bc1&2P$I5i72?>*XiE_1*ppHSdb+NP~)Ow(R^(8G_`nJl+-vrQr$r_fJFUR(mA|^|Fo+6zrT0g zxvPBs#!E&(yLa#oX|Ct8Cyix~&7(l`6M;zZNOg;sX;DBRcvDLx3}%bGG95>|T$0+mrP| z{9{7-xG&jnE20m7Z?op>Hfz4Fqv^b4Oy&OQasnJpKFo>~^4$_6DLBT`7s);<2;WUk zQkfAKBP5I|S21X3p$7UMF{n;pgv_GiEFEn@2pmlDtQF?3*SyQ3lRc}%wyVa`$|`o3 zPOBWX3`ii}THz>2Et^~>89u+hdBS+T27;tUpoXW z)4TV#VICAb$(tuCI5hvT%0sHDl%Lj=41*wtQp>eB{`=b)XW2KX%39(qfr`*SnX*|9 zMv|D!M$u7rvNxfa@|J&2My@%Mqc|ELVY1HREOiz19{BCb9P>3?im`3Z)F6^!k0KJu ztXX3YqOSFmhIB3XRSocu{Fv;EHolZ_`o4|Q9l+O;MrGiH_GQ$M&&bRpD{o*R#`yyC z1*GJs(-pripCvDwjQZg95DG6_mIuV^`+ME(S7Ih0{pV38>vWPqts7nEGsu^ekCtYm z47`aV!DI^F^>`+u6j@rJub0(rU@Gws(n)3+Mzai#O!?4_gn2T^^NEbvjsJ`ROOCBG(7dIay{|w#osJ|Fr`GK=5z>DX({UoE2@fe^Jn$WQvNIRZv$Zn zS#@Ovu18qtZw*k`>m@*k=kK~1MM^P&3qd&@Ia^cA*&7lAn*I46ds8g5IWXEA?3NO$ z!!(|-Xwv}WvU&BM&ID}=Pw9yp~c%%F;0pNEf`M<4t?YrUSKga zfszN0$0Emh?WR+yo)=Gg#lh$XO$Y7Vqfc<2;zE|~VoVD0)3nuu^)nyzuT@uA1DRV7 znUYf)iVX5;@g^N6;^rEGY?(S*a(gfX!ycYG6@#m($USFOd&y{&i{6uIR-Ay1+@~1^ z^ZDUV)Trr@V>L#6!U6MQ^DJpif~#0YlNWYRmU)lEQxTFqI}B^(O`b*7blY`2UHC#zdZ%C(3Lb|DW0 zY8uiEIG`v4i(807kw|h2h>lc7RuWf{Y-^BAL}%D#foGgvXmAs_q98p41r!H!Lx_cC zwXS5_K-OZy)?qr#C)XHjqK73KNd8X6f{co$o`^#_6W5~Or-SS?Bh{$>Vo5T@!jddQ z>^PTYh;q`njREIbf+71^iAeWAtVdSYpVStA@pUT&D6n0nUZrhFA8?Dr_$v+550lAY zanAYZLg4BICI@}E2mt-pozXayKYe4eQfFBu3Q?h?Yur{^4gk;UV+nz_JV?Mq)=w}g zz5fdHEwrvx_Ly%b{XY91;O-!RJC#2)llS{*Aiii3Ia>od`wc)Gp2PWk06(le##%Gad7IkK6|D;hE*y|Oj@mX2D zd++{(pML)3ArQM(S+ryZcS=(_IqnIP{PZmQcs?BE<4==fI=i^My8aB6#rnU>qZ#CH zK`%_uS4wBvl2<0UYox_>F-?a>GwNKC$1SNu1@4C9PmD3CBr%i@+GlR0`J1GlT{S7P z?m*+61hkWwn5#g1(90%0w72P}D zcF-vD!K5^uP1Q3`?=#J($>6p80EX(bVNJKi z{F+tWTXmJN0Tz_#Wqk{Xg|*tVqcO`y#n33L*psJv&7rBKCssce?T!T=ORn=vJ(S7; z4T1~wdXTZ7t0gVR^OG|4Q;HHkOvc|uLlbR}(@{H12KgzeHVR(n!-uh5S^(E{S6mKg z*fO4^7g;_l^b5f>Os-!ilhn?#aFRN?6FMN}|aSbU*8f%}dwd)8j#MoMO!DCsQEArzpXDoQ=jaG8ugG{`N#%lKK1FPou|6 z%!s5&VelzrYLBQmrt6zdF?W(UYG_XdjrFq&^3oG+VaX+kzYBEzM6~*NS$uyQZNG7P zor)C}pNV#VEE^UiT(SiI_|HTM_*cwzSrB;3`DmFsz5SGzm)KKw4lYegsa$jAB!^8- zv*`dj?IQq0_|qz2d=Q}>1QqaA6ii2hB2$~+pcxuZ_wpFu{9c85g|VYQ-ou8U#=kH=VAC%eaPs{1P5z6-%)M z)^$w+>n9~ukt+tEa$rX-2t#n$p)MdzcM2wib<1@Ko5m#ueY)ue(w;F zvGgGr7MZXEY@D*OuNWuQEC}WBfzks*L2O09j+&55{TVPukkDxQG844(2>eTL7qjDG z2F8#PC5>Y_E})Hkw2K95_|^E6vemHx2BUPr)M{2co>jA8N{pmg!W7}|q9<1C?htrb z43dr37TY^OL2BzMu1Kd%d<$aR_qS;*g2`mfGwGwb)Yic9 z!n)R^N0xoJNk=T_f;-f5OE@ScI*P0BeH&~k@?nxqGp=XSLH@Q=M{l4;&5>FL4_1?u zK||_0$q=8fBaBKcT?{9oRxg9E1F3n79=&J5CC%LY7|? zk^m`;3clw2lURWOtn(;JFfqvteH~GEOs}OXt@&dOE6zv5uol4pu^a(u7; zyUp{ZXt;q|biX{|aJ>I2MwlF7m{aL85)JcFCQg8q#hy&k6s!@>qhc(Mdoy}1n2jPu z1|HLSU*v-sMc)(m)dU2)1Hl*pMiZw@Y;V&X5g3LG0hh^SWbSn*r5zi$jz&;!Xp#=| zi?q}hTWw7Me?SU&EyBHHN=6{*hj5;hK+^_C4d{aki1Z(2JUR|gm?O!1GH-RX8Fl`U zX;9}6L{B&>^w_|iu2;5o+y_g;N9<5FOyKDd_8= z4Gt0>c|^!EzdZL!_g{F~uPq+46wEz_^Y43L+ z^+LW0yg?`#@F4?a$t`+@Q3Vb9K1HI$1dqbdGR2t|v(ziniIBXMT3|<#B?fqES;dFX zs~01APbtrlX5kEV$i?Lhn&lE50iEO2>MniZxu=s+HeABerG*w~YcCt7`D|Jv6lYb} zxY=r<0coyRY=VSslh>&C8_}E0bS&lAa*yg79}|9OHNM!GnZEy59L7a(Z6$)8e_&5= za(|*gTy(J8o8$v=(;=tw#o8qvv^#jBB0FU?J6($`V2Cflj~eGgLymKaDdmu{Qg7u- zxIBw5S@+UDef<_W8&r2rzh`rl;o!hK3qkpSa87I(^dr+N%3c}TwkF=!lkMNRV@Ozh z@5~I*Y1TJ|Mob)}WjN-uizi&M2r@}}JQ_DK&QVh}(45VC5?i6^KynvV8V2*B3=+0{ z3`lSHy&~w$w=h4^&o4(@wCe02ylt9LejNxaK^~{{sh9Ut`nluDLbTv8~%s)<>`XAe7NPthZH^1{7Kn5;i25v0^T~h@CI)g;zy_jQz{#YokSJdlj!Jiad8@54F@C82Z24c461W^4{fOL zid$(}6am>IYMe!>yZ6Pfi!8ltLa zqQuYo^D4ety@${EdX@f1&-DK8XY3Lt_4LRr$_-==eGf$k`|7?6UA+dj99)x($LXja zL+~he4l4@vwR~LSNKwl;^WJXUF4;bqVBmO->u`87)Ves0BP-gvP6j4J&qRNzSC)l@ zbU_C7zII2J%~|23RWTVRMdkr6bRyt)g=AS)8mh1$jnqq3{f-){Z4JZq^*>aot6vBn zTpR!dXI_lIw<_cq#JE~J50d*SoIX}+PrkEa3rSV!RKV6X^(ehhr2Ipx2&eh!=|JEZ zVz4Ey@s>Qx`e_W!a!qQv6i!Upgh=DSsf@-!q8f^Fiyk*qqqjsWRJ3qSrv;FHyJzA8 zK*ybAO7TEu<2BxAfd!tJG~key8k3YOs{%r+NbdDss${4@XQ&l z^>r^FN77)UG}nH5oC}yww?NS#DC@E&R_1OSLl!n8UBUf$R$6g9&2l^ZU-cF|<9h(| z8U#4(fPe=j{-a4ZMEg6+t(78FGl%PH?8J_}if1efw}w(QNi?F)4}YUMDX0{WJW zqFJ9KD?*(_C31n_@L2LnYtWJ>rgx+C5+BME5=@FFzoJDWH3mOj=1!qdRoqsg_6CXt zQHaA3k|kM++dkM4DPqN*f88nq1SzpO&T<-J*^y4$)dJ1(p2IDdWe#jdXvc90=!R8Z zEGKI&v4-7zP*n_Z2FXj)WT4_$@rYA^q#$Hn20DOYCeSN^9C0RvR-G|9kKK!eOmhh- z!cVHKhuH`skhjx8a=j()AE&f3LG<2iAK2`zsS;p-g{3?_H0T3IqCgj`*HVLhjjnA` zf+fq)9MKfK+pnV~Ng(kK8qqbA_vrw;SP3G&@N4Pc|6Mfll)tibp?ODUA43|7*kFD3}Se5SE5)$^_%x zCU_n09j-;2w!JZL;zc?T7iJM|h5Q$#d2!@K*GBT~#~-8OTF?mBLy9sj6VIR_VFc75 z1n)KRYh?Ri*AE2h9^!SCtY&V>({vhlL&Z!Y=!jCdZtGd?J%xb%f=b>-+xO1ZbRzSY zZa<}&VZNY>3OGVuLGeSCgOM&q*ukU^ZuFt@W<}9$QYKh=^VD0u;e>8fa4E`znY-ZT z-jGY@_%~=Q+>90M;f+b%f+NOYHQs8+3(grNH1l^W1e{)|v|#^f^zS7|ei~>EvQ<2W zYS0RX=TeQU?y}K|pv!)LDtOo5QM`1KPQ0E5q2XZyV&z|LpiUBSi_$ zM-AbYo$OO?|GVO_Y{V&J2N71OTq}*KFoC6<2Vru1m=be`+ER$vX;a%*vSekD9ac0$ zC=|{E)X^)*JWN=oGLV96h-5PqhIF?r_S=>saYl&6`5C2M(I3pw6UBN%e$4*jA z>FI4+kkXFd&$=yhyW?FgBN3Ud@MZ_H^2VX$6N^}1pWf7&OD5gng`U$Zs~Gy7c7b|7 z9ta);rQ7N!udCjDYq2*?H1aka>aAAdA(fUVaZ>u5vspnTDkt=-ZRT!$eyz zWeQVKypgOROFd+o`caKiz4i07fDpkbtxTfU>_pIUb>E2SlV?Qq!Oi#htjR>n&!mbN zM@Qw&=-d>KWcmytWsWFO6^4QUUt_^`fD|;N{JMfW%z9)<4Qk98#48lgmzwB&ijPc3 z&CBdO8>jt@1e@?{`85>&P}?76pna|XTMOFzu*KT@@LILE>|K$q*R_JB@3Eo-SU$jo z>jV76bpl3WtO=8h#bDN_kbVZFVFjv&U+39qiZ9FIGPOd%6ZwF`f_fchp{w<&8NVQY znYXXy-o@Qvan3B*pYmE3J&k%WXmNF|a3|%*V9b<3vL-_}Sznn$lk4)Ds|8@|$Rb=6hx)xb z^(OlFAo+ZavA>s=c)$aJ2+~pSy7_(tkouuC-8F{${*t7LO*Waxyyd0x)K_y$tbkH=7 z)o$I=!cJdb=w(!cN;<2qnT{Ssg9~>>DNEN8g@T{b2rNM z;^{aT8Cfbt>F5H|jB&M^f8g3ltAqnQZb#8TTM# z0_aen-Ej_qKp;~rbs(s`3P=wumekP^7*OGDimaijMH9rl0jTpu{CTgW&o%#HqqrkWuywFq%Z?AYN`kNFVV@rn$fHDlyrlVsYVP! zi=gIVMpMH~F-V{N8&XI0Ca4>+KoK$MoJv<02>@c;*t{Gb30-6=dZ=tqrhIu01$q}` z_wn^89Tm;vba|9d(_;B!a*>c67Qzw2B~`Ba-C__DHMFepp3@KHw`zXON8Y? z6D3$98c|AmWaYXQ4Tfn?Kh<+30WqHrb&h5#+;99P}1x$pNE?x)-@x#`C|F@Px9$yQxmw!9*MnVy-R zo}QlRmkeEKl)!0hd~q&!3l7IJC_v&MC<2rrR|}@VCus>xaS+{+vc-c1YT{qn;-S{} zsuMEuQc`&=_Ao)DIe{u1rZ=!RuAab%j0P4|dST})Nxe4$Q!YTSR@Mo?mub3UDe|DF zwj28%rFKD{x-GX#kO*PA&{_>?CQ?(q5EF-?n1B_X*OfBXSOdzKOuRA|^V`bxS~7BQ zLwNC(qzO-d{fe#Km90Qr=DH%TLNKa zCOx|}d@eAOB~Y98F%kvp77gkebt0_mM?tDNdmORhJL1XvTD+B)SMC0h8VU#)t{@ZH zjCH<*Z$>2UjYjXXcxPZf#OOg5LO5N6u*3D4Gwm6^sYsDa1q%4et|N;~kp)38$s+S2 zMrDi4T%u@(!FG0Y!r;*sjZQx@0_E@nh{o-#fcp+=0L}hIXkpe|Tymc3vYoOeDdawJ z7`Wk@M1sQt=B>7RL#~?kd}Y==$)Y7|H?t^}KC>=?Ykmh%D+cu0)CL1mZ>}GZELui& z28Gc_9u5Q>q&FMP&!0q876xtl*qp3pvt$Wz;8fPfd35<4bI=SSsM#vQdpH?>vFVwQ zs9?0?@XJpeo%y+u+9tZJwfN$Te+)?lbNU%zlv*ia8e->toDwD>^)VM*K}zG$ps}&GqiAx;O-k@l9UT2&!a5= zg<86~XoCH4r4#qc1BBv59IYVEMmi?v;4z-{%>x6Ut|7ZPeWGg-CFNV9x+S8YM^|Ey z#PMVnQ+cxkTt$cmR&mt_eVzdGKGX$>T6omqx_Io^KSRA) z&KC<3ESAgUdB}f_;5j7#M)p~~NES{sT#HlDh-^0u?zLh3Zk)f>m=rV6Z&VY;dD^;~ zmqjbC<>m1~f`V&hbN8VR>kHb%6?;n4-$GUYZ$Ng_5{l{WM;YbQbB%1gL=|e`Lh0Hc=w-aGXe-Wu`s>EImWqY z6WA;31u=q-Sc$IBdmTep=QV?K)a$lJT0%gG1^~n=nDapQ>vb)KLbKLpMO;AbSnOc0 zc6)~%6S4|10J67EIDVk=L!g*Ppm{fG9ut2DpwBhnX@r^;A9AOZR9O;vKp$?ypc$HN z*Fz&Z0pi3gYqkZEWf@x>f}rePX$8kVJvQyx#KW@sjBxcjvg)#6ZN2;6(vuZ6U2lxo z`u3&T5|d{G9>tel#nWe(Wct9htr7)M z5topLR3am5aUPeuQGvw^v#rv*m~<{EFUww^CwYt^Xu#yD{E)30WdTO?%eki5netNA zOu?(I*8N`A8&O`vWP|=2GAIWUign_MmnCva<~g)dDgcNwl4+JA8a6M`CYS6=C{GX4 zQE-AMqIlV;zSg2^^8KkGp%_i`3Yj$(L69QflV{Ug;$xtwk|Wa45k$S+)2l+dh`9^J z&W>!Zl6pZMu7pQ3#V%W6Wma}wgsNB%CY~+mq7_&wOzSMG+lqF|H*p?=ju)cMQ!Z;T z+EBg|7c0n;O}ZQ~F<-CVt2;aHN6{|w)OqPN>tucs0(7#@V$_6ChTt(}2oCm-g8jqb z+25bN`p4^^pS^kp>^jdOTI~3|XiowtF%t|UX59Q`1>u*0r)rzxx=-qyemoJr$@DD_8}esLK>e);iutJ+C-m#B)qEBxSr4c@;jv z*CgVd?3Ju-yo-0%j4Ru+Kxa$0M%Z!7*g{>0Qy>xv3q>pnn8`w?oCC*JVpq$(rqQjt zwh2hcK@|P~#7JTA*0}NQlPW(`K1AC2@01>8y#h`7=}fIcB-)K1h!*DSxuJBMC$pI- zD|Vxa%#r3Eq+yT8(I;BN$nbKhI+SJ6#@8robk_E(Gv}NAGY{+n)H6d#2k7*tj1$8U ziwUB|L*P}wEhRMeG6G2~kYj@Ef@5!B%$+xaTu{ueWtxK3>~MviNiri~$F3i+_kim05pEQg z08yE{_Mm8iAwX$|Cm4ir-Qt3JR=C23u`j5O$bk#lMiUWSx**-ing+Xf7mCC(!`Tz^ zH6nO#k4*Y-wSw5JxU{{VRPW>hCFuAhKOxtLIMEblx_q$+7IGnX8w@RsyA4DJQJam7 zM?h)QoVbxaBAxmGzn*xEoh^ZSwNQ3*aU5m~fCQ(?L zg2}gF{+C+Xrt4B47hd9vpa z&)PcjNrWkWcY~*?veiE#6^Y(pMVoiZHs3UdeK+4VJB4Gg4;vC~lwvu@gO_Xki4cMp zs{m0_opL&z$!6u~H6}gD&o}Cae}?SLO>%zh#Ly+jHcodhCkM|b3EDnO^SAGi(oksPka<2cLyxUpCpaoNB&9GcfK z+Q0t2c?#1POU18^={A`Jo|iG1)GsMTU#)gnLR)$30Qm1$w>eFRTqnGpy4Bi!+zl0@K`Bg4Xm zjduIL7)5I2Lt)K*ex9x~(QtMcFD($p4K>_vFDy8)k;9Lc_^%Fkye)FCgPUIViGdxi z*xV!@C-Z1_yT%%uwxw3|=~W(QN9n<1*f{aQi4g!&$47axfc*Bn?H0Vzv9hJnl!Qs1 zzEJl&a7_<(f`i9}O&1LwM47S+Od|A>6_CRv!N?!1Uk+-t4paPfLVFdDcF zPw1{T5=?WMXTgaW&k0z(lKw_uk1VK`WZKIlhp@634#IhgdCo{jAU;iiU>xHA>thNU*L2<= zz&ypd*pnqK? zIf$=sj_*FEmHJoyd%%Bx;=f1y_a*;*#()3GfB*3qQ|GYmUEtIMI+3vDkDug^Bl+W{ z{P9fw_^15wkA#}=Qkmcy^LQFD+mII6V*5EuFwaoOuMZP7A43&g8E&s0tC|%ofa-1B zAaEgS059bYJJ%-Z6)+LB;#0)Jj8faCIqb}nI(3##TTNNdG=rGhg=d24b?R1-16g1x zjz%psteOfmn1wjru_Bo_qR3lQuSokmk8lToY8+D5DvY#->8eUm3QO?|Vzd%h?F~`Y zYL?@wEm36^VqB>;@a1sD{NN?;_LSpLxt{!x8uMejN6QfA;!%2L8sjm6W#7MVT=Fm!!(k5C^>SehEg>KSfe|{ z8W*Yt)nNq5S4Oqg25 z_(ovH8j+nNEQQ=PFIpIAF#z5iW*qLp{ITpjMjdhf>tYq3$)JazR60e)W{s`~;d+^Z z?uZ|PL1wN4A)jS{f#}$Y5)4$RTcRNMua<)hu!g3=phnDZUKq@^=h$naQBcp;k$pS^ zvx(XiMRN4YV@GL-@bDp-Mi}e?VzfS*f(KFE#qTBwoi_^PQJjl=S#nw%=a*J6;*fJ0 zrz?lBq|<(W*`R!|T;a|pi5n!$GJ)ux5#P+{jKHLoF0Q(3D(11B^yX-T=KsL<0U;Z7 z!Awyb&x%uGSUnZf4%@BJ43E+^94vu9Esm8`Br*m}LJ+e!8a zE;?j1>@kFtH!YiF4{Kv#jd8M?bzz(s&8TQ*!L zcf@8?1HFO?EY2Gn56(Q+Ep{Y7u~NYlcZRmb*aHT^9l;P?_7PYx{Zli!8IuGO1kgf6 zjz3l^3^m*3ZV4(2#=l_f(E1k{x0%f2+A*h#Cy>N}1fYp!_c`N;(wzEE2AF=avL9(b zl(G->QL&0?EJyVCYJXA_d!I}zbxl4A*>q{QDRl2qS~L0_oW|gD4J(iW06*qu%=eMa z(-iZBc=~B4hK4Pg_OUQPUsz*ebs#x#jKx;=7kT>kB)+J9R2|?jA9cA28|s}*vkj1}W$TBgYMSZG)?HjnL3UWr8}OdGtOG;!IS}gXwBL zUtR^#DQE@Pi&M%Qtu1}|A}y2GQs9t;HMb{821}EH1s^pW{~#Y^+uZcpi_*6_b*n?!};`i_3AxN{} zawloTm+`o^j=-o%D%V}pn43k<+(@5&$Zm#yg|T^Ai9Ufzc23qW_ynpqc>LWkMu4Zo zIQK*zf3b*PtPavutnFtEm|hRy^bwp)qt(g??W@DqnLYYFII3ejWIJl*GCxWm)i7D= z-d^zLZJ7j((+?Jrt3H-<8q0-!na5)grjx z3oVv)6PcY)0o(I9KTju85&4t?Y#*h(j={;Qk@J%@`2bkEc)2KP2kx0uz61rw8n)$! z-)wu0uR(D^C1m_r_=yq!@TZpa4R~He!T2pqg#kF~LC^s_*#TZ|6AZ$#SIop@f)TFt zb}|E@LGF4zjNO7YW8{=nDA{#BNc_0(C9>T25?#e66+!Eii#VCPu!b$+ln{<`yw1Vfisco$_|(SrpxtbBf`5Z+hS^%M$nW9j578{0CPI_}hB!$t z!N>3+Rz28166djTyvT5~0S@>ms^uBdcaY~?k*E~zw$@(8ZB+*(ihec5ObFSzpya#WQq zBchnydmf}PvN-{bCRn9$;zpBAZlvR z5XEF|3Q=@OqVuJ!!Tq!v62Lhd&NR+d$roo3Hv>jctIKwXM{sX_unU8zge}J6gN*`I z2_ZPIHC||2QkZ$;5Xf6Uimay0f%y7RI+izY3(e`#&<1nU;Sl}ZcszDv)~x%wQ97cn zt%?!J)$v@0|9H-UFoU5};+2Y%p^9v`?rUlLtFOKasKo#-f9uLy;a3RPf5Ls!qRZNoTv zws#dfYjC)X#ZiGfV)$cSlX@#xsFdTL5fwr1eki4kxw8Q>j6m~ie%9>Tw;KjXw z)aiG`zo7-GIjEXNFY?9c+M|9r9GHD-Hb#Ab)bT;up|pG}W{xjF@ndL#?#t7g{(Q%f z;oPH~Ds|t?qqg~~!}}TgKS5D~F1tNJQueZIRiMWvDKFGcU#vkv2>rGNwS!Q*rKn1X zo#GbZJIrpu%PrsV$DnOQyZ6O7=Dr=pqMsGaxB*JX8eMYMPfp~Bwu4{NiBxsHVXjD0 z^jkhtVyP$Rt8~6WxgV2Ne3o811z%&cR>7C&(IQXhe>uFq=pkOxUtezjS2_HqfAgSMSO@fR>z0fFWkieN;?^=84#Q5bZ85k0#(cmJv>kQ@8}IjgEVEU~2WY_d zr40%j-+aURs?tN!1NI^ZZP}fg=V+9mtW~#_RT8(@l#SXQ!4e=W2gZdA;!9NeQs~PQ z;vaOex{7CbRVvoTGG66yz?rPkS8SO=w%#O~F+5PIsHzxyQtV#hfFqr0@)$;vfGt^+ zCEKT~^a66f8!1sJEQj7bSX)!Lyy4e(T$WnSIbl9)(o+V~2sa?2f8*jj$}gtqErWTd zmeDlc;f_(d;jd&yfVzV7T2y-d6WWyA8#D%uj#wcOee>iw7d_F|wyM%i7-NpIgeK|?(6H$li=x#gWx&1yajDc z2BDEnadu^gFD@<`7ai>8(W@O%Ya45Ax3{5hG#;d@{ioaQ{;)X`|5tZ_QS{bqJ)Po; z!JMtCk8F1YcYpx#2(G=Jh?9~ua1*$6z@4U$B;qNq=A)lw0-LNMktWq48M%ixoazQ@ zDPXV44*#u^jvfX-ip4K>NpU!Z>qN-qo{3Xj$Qv#rKMUqyB_;S+$_eT`kS^<14&HWPWsojwBNg9O$r|eSy+6*ONv%?@Bhh&s*HLIMavj-Rf$J1o zQ&~k=pGGiH_EeeRr6H#VP9?#buOCpUSk*_7S&&82}5YbFaT z+v%BQ_H8TZq3f{V#GLSDzXEvF28{&Ub4muS=+WX(uLg+bB zDeO$DJAo>HgYP_o6Akoc+hBuYNHCb%mTq~gZjfUIH9}V&LoJ43kfKeAqI@HdroYHs zv|Ep#zj*T3zy12+=-HN+l-xo70i5A0c#8rI=-$RcGGla?af5DS)ELQW$|n`mgR&lI z?hJX)T;5+sr2R~xcGw=Zdd)$vUI6!n#M;jmY&A*WlA`m;R=sYs)ly;49f-wNtHr)+ ztCk9Yl{KqZ(9zTKmE)toKXe71$I&ESefc%?Gs6A~Nw%-8SvDZ$Oj1 za5x--J0T_e*KAA9hEru-|XlD(HTRino*|`(dv)3I`)c-9NadKLwf;{pokY zQQuZxcR?jS?A?GSVcoaFVb>g&!1Jh@wu>|=#x?AOy_Sui(KWPPq{)8RZ}!9Hz*bui zx)uHL(j>rXhwZk_(*}bw9-?&CnNpWLDA%>nRnwcIj^%CL(QcdYfbG*`LCLL3nF<)_ zj%da-3-X))fL7=Jjdp=mJdH11wN)z|4BCQU+O#?BRqz9XgQn)IHQ1$+POa7L2!7DD z_#Cb|pAmz@54>Fyqz){&IkMGsy;6`RT@!G?TBA9%;LujrEh7uwzm0hiGfAm&v`AA> zs8NAUm6i7NOu(VDV6zamI!&=Ox)z)5f;mn9dbD~$3Uu^3V%BZLnojAAm!ktC3zs7U zK5uNnfZ{Mq!|`|?ZR7R(0&x}1D2O1uZui?e{YG;K6H<{}EQYYn2FSWM+duq}r?kR^ z2qyKo&kp3)V8ybcE?`A`y&YD-Uf!8p*abW7j-VGu z+6T#D(7zTdUXb0e-5Chs$OhSLUCU-|gMJ@o*tWj{J6z)S7;+{WFw|={!*<^pPJ6Tc z-3ziK#B_o9p)Ia;d)Ly9?I%%&p=$c!5`WhI1ed-alK5hy4N9D_>CV+HAuvDp?S zOW$;l0z-dU7avfhrmSwYR^8sRHZvg6v*q}j_@=8kN}n)+MgFV_`&y8zw5wOW`nqD$ zz`Udrad=elWp&V*I7WuI4xk2|a3{An{LSnv&JtgUD4 z(Bp_xIb+~l^*J-Z!(cBb0QD@E>YF%kNi7sJC%O#sn1%3CEi=b_2?gM zaY@=Eyqz$|oyKqq?7skq0B{@Xw422X$qmF^FGz7L>cC}l=-s;-LEE3O zv%3KDCOjIH4!d{Fqp=<;6G|46d~z6TFukNm4tu1@bsvG ziQiP85nMv%;1s6oI2WL5Fp2NuDQYr1R*)hU9Pzo_a0lv9w8bKW3m zoG;mI*eVT??zCw!1-lCYBfCal--v>5gHJdCIny(Qqqr~7=<5*b7$iDt+#f@CV8mRu z4b6DY^mlBLlQbDi4dY7w{yQ!t6}EB9__$TCQE#0Dg@o`bCkxdH`X(3fCjeM7+!Tf@ zs)uNqjdNcsY|ZCU_Tpk8=RmP(u2Z)N^4+^QV~zu%!Kx^5Wl*4|IzdyFVIF{#ib@`Z zp=-#dSQDrSEzEbtxd=PHCCLSeLp#qa>d}PNCp|3zv%Gt^%ye=y7ESKm ztBI!0lgT7rG}6WFYTJnH2#JZFi5;k>qT;F$e>%b+)uq6ON~|g5b;5RL(W!v36o}X! zYfR|CK767qq6^~taO`%Y5tmA8b>;pgghvPl3dv~T5O92#u$rw;=Ly2ctpp|$1w!Z? z&1`+o7fDobN5Lr;5Oj;++UaKTT>~}%60&8Rf`8Gcv35}9Z-xa86~m?(W^YpZ*s!N(B^6h6Dh5_EoR| diff --git a/public/app/splash.css.gz b/public/app/splash.css.gz index dfe96b38bce6a2223c656e6b81f60f237f57a5a7..e8723f4b815807e4528c76c62bb5f030c26c8610 100644 GIT binary patch delta 15 WcmZqRZs2B<@8;kTp1F~&iWLAIJ_ES` delta 15 WcmZqRZs2B<@8;mR9KMmQiWLALbObj5 diff --git a/public/app/splash.css.map.gz b/public/app/splash.css.map.gz index 8b308b57b17a261d06252dffce6c2dede99a0374..35909d6b10371dc19c4472bed25860599f23e187 100644 GIT binary patch delta 15 WcmZ3-vW|sKzMF$Xc;-en4JH5}=>xI= delta 15 WcmZ3-vW|sKzMF&Na`;9z4JH629|SM} diff --git a/public/app/splash.js.gz b/public/app/splash.js.gz index e07dc5b5a597453dd5c984339f7deabf2d69927b..cb8b75872058e4fc2ed7469cb9f234e77925ac3e 100644 GIT binary patch delta 15 Wcmeya{#~6-zMF$XcIHO5kHP>hQUz`R delta 15 Wcmeya{#~6-zMF&NZumyFkHP>khz0Bb diff --git a/public/app/splash.js.map.gz b/public/app/splash.js.map.gz deleted file mode 100644 index 4ffc56a8470e751689bf48cd5428885acdaadb46..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49765 zcmV(|K+(S+iwFoSf$C)f19Na}VRL9MYI81aVQ>KL{n>UK$+92{{z^!DpOZi)2u>QQ zX%mB#Op2l?lBv{|c*GzOBtrxcNCZfVnW+3~Z{M*KVeujUx#XsHW;-9zwgr6rZ@$ZWl@MjnP>BB$k@NC>_ z?5?lxHul%o_Z#i?^|IA?vA&+S9&N0*7dwsZ_4RFd@S?G?zP`c!xoX2h@lTsx<6rpC z*82LEc?JWmw$-2At=XfgcV5TlpU?~F7Y1974c7jQgQbn`di$vHZhid-w4@AR4n9d{ZyikQX(r!nln;G>&EcyoPyQ;&AvTlCKQ`VNdXrO{fj>QM_?o#3)h z<+61*YJOD!s0M|#4X57v-wI@e8U4n$LA1$WI>&Qw!ZqgLLnVcQ#T-`MIly1XH$sXz z<`ct_NfnI5n=8bT-z1Klcj%?nHDb!04(#fT*;W68BXq??aPPWmUN1T{ue=4PRG!#2 zpdYlwzu@TJ?P%s(BJla`r@5P@5@Yy_rb`!oX(`Fz3!8zbR>ilfNbh~a}W@AKS z-0xJqZI5v$epCzI^l8S9Mieopx3D9>&}t1(+UmGjb8PE5;sVW51213_V-5DLAiD0r zEZ)G>E)g+4cW5w#tH01LduCoJ>WrIkDmSGX%}rkh*81n8ckAtkE%tkNz5Uap6n5_& zV1qMqs8?LH`0P{b(dK&lIUp1xivXE_+JMO#X9DzREu?R48#E8PbSDLZYiND2+-@-pP0}#$){h;4FnmrxY{6VUpF(Hey|8w!A;qg}*k{BxTqb9>MgE!$oC2JsEHMjlOk zXx6&}r^H-n>e(-BKnLF9?S-VZf!DCBlNK~uX9%$g>p&#g(3Hs8%UuO)Xh#>02R>}$ zfNw)_30`YWAQ{;8Pxx-R6~WmT_We&ycJ#*&#BPbhJnqtJ)cK?ak6`WM3g5(i5ql~o zb|#PA`lprw035bo*mM=f$!9AqK7)1?e*j_dEH1V*cWI6z?$|n9l+Mx^vmyRmf?k0S zLwZRB6X%1?_$@$aMob7Ub4%m%)L>Eq9yKAfhVMQ_Fk@j~-M;)DfR zm&$d>g(&jijp)4KOYjcs1@a%iwi+i$)k<|(e`^_11{-qB)@w#Ge;Fpo-OXL#;R8n$ z@oQc3?tBl$^#>DDXQQVf*wa^;nu&w5(Py(bRBOUwkWXFrS~}|luI#spna6M1H~Pl8 zldi=bI}D;4q)%W|Ea}6TTq(H**c8!ECiqmbS%SCTCuUjv1zREi+<@0R@Ye%)_~_A{ z7BX&17B~vgk04tcIyfgCo9pfBHzAf^krN@Ghq~2&0qz|?0zCimM}U}+pvA0_!mN)Z zf^R4;@h5eoZ1e-z>Tv{N#f0QxH{qf9>u31*9-Y|xY(SUQF@KrE3P8Qz;?r*2QFL{} zC;v_Ye~a~HPQL-hJ7m)WU}DGEMpih>Qq@rbWN6e6_G@^uRLl`}YHPV~m z>juii4qGTD@H0IFL2$=CR{QW1pS_hQ_F;@e+^)ih4LaoQ*YMXJxQSleZGDB{_aZ2> z;FbYRZ^sXxLyeplp?1Egcq%7im;roUwv;ZAO&K=*VVlW>H(YdNsiSsWelXa#1M-x6 zL@es!QXKf?Ge0bbTY0B%3&eq)^{#cQd~of}BltPPzf;$}9Ay{8B?H9j1Gxd`v09E% z^N=?H9w;~g8JwtNKw{9QiND}P$v-#X^$z@Xf*L=(z&f_XRgGD`(e~3o?b)bK9heO4pz%VQU?;yaepnGCVxJh3|pYS{TZ6OVJuyc^$JO;ZTM*x%y!s0nFav6`Y$C$m?e_J`gufI%xAkA zoUJ4h&IKqQ{=}YzCJA@jD+W0;-MkYZZsuc!$edkE5e*ELaMm8V1Q_n44$@=zGC)oX z3i>=;ch3Y6TDtYVtr-2Gt(n_(L@#F=mbU5vUW4NfV~9d(1>6Qw%|v+|bK7hn-3&4Q zoV2UH)hDarPs|xqxS(#47geSLXxMiCQg!YS)+o>J*w@Eu%U-F`wf^F&T0^&s z84d|4GeCs)Hu?e>^xfcV@pFoQmKyDt@j-39Qs$|xM}l|Vy;r;PYs)CsM(ueOYv#~} zaGo9Qkfz@`bOHS#LI~)u;TT6=R1z1)Tz6Pf-b&N6}*U?=?VZ6uXh*bGH># z;u`+P?|aeNo|N8zfOy(cT$12H3@Ae236VM@m{|1gRN6r8gYr4tuf>X@T3v~QXRSuj z4QL;oBjX^wVMom~6zVNZpnLN{OY@9_t|lEXP~QAeadsO=0W4s;12bTV6)@XqjZbFc zVJl$E-n4l@(07TMoTHBEf*{*Loxo`aRk)Wec52RjI)IZK;D={qmhJ?3ZADIZ5HtFk zsD@9b+SR_>SAb5r3M!`;IFmvQY}-<+JL|80@}!t0LRA-KXA6^nRt z)kar~wqw0y0N4+pi=$oLj~F3?a_6=Ffdhzto_Q8u@qc%_?lR>ta45_&+keh7t0ZfE z+xnCCS$syXx>^Y;`4!NWj9U`RK#K5OmF~42^Mj)9KfA=r%q4`>@90}4#Ns_V%|yT7C_GK-3onfXceKi&I|+JqJLFq zo{>W9zWJD|a!eHY9BIulQFx~fJarwUbg+V-7`czqJL;N4b(N*zfo7L!%8HlTckFfH znFU}1bon>WmCW<%*!DSs4LEyU;2O;RBU=9oXK{VfMrOI>%(8MJ+9NF@s52$iFn7PD zuj|G^vW{zX8~|lE()i|0ZbRO!ZMtW1q8%}XA6nAQ7hcRaYYR_zG!;}_wZ-5Y;&2qS z$(SX_c6e ze86;iFytO=V8=D6#az9llM23OdO5R_O?a=p>u4_fL2qHJ&)-_^kVeh335SdAQpf<9 zi+^*EM(+9()U&+kTHY^jZ9TCB(*rym4_nIG(nde?Upsi9JB_7|{L!6Mh_s3?-j5pG zjafuKG;c!s_??)QG^CK3Ln{;1k)!kGq#cYeh?;4m=He?YY^WTm2a7%di?ogtFC}+{-<5eOIf-LtYLJra1#gJw3vk z(_XcYgm1@ELi9z20BC!kL5GX2>M#l^UK;QC&@SLlTPGgiWAC=-Hu7%;l$@TCzdQAC zV)ndT$l{C~4T@vV$N2;4?9St*W=Fy-A&pu_XX-mBpWkfm zYt38pD2M`vCMHk0p=|AoVao;+ar1Ar3mg%S<<7Uo6p*#v2CiMF2kQ!2l^3P?E{f_K z$lW0Tpf#FWTR{j^2Ku#M-9y^{68?E^{{>Lp8MJitpNj005b6#P+pfqZUe3kX(0^zL zbSelS+cNv9Q%znpc+XqXZORQ^+KOpoLJ<_}IM+(g3O=H=PFHECQ&g;uTFizJRPTql zqu^wt+J8`5b$)Blt@H2xGol)GXAv?ZX^+iT%oXmurRo199BLVInQ+!*NhxXsqs9s1 zz}Uxu(7;tV5RGr79)>N>e1)#&s7LI+ty^$x5ze*YYX|6V{GnB0z7Dw}Dy^UPqxtGN zhj7$+QN0-T?W9ejq+ZcfuV^=D{VPx-LlV;+WTuHx+L;x>8ZzBRJ#^3)(B{YaZW-Y0 zNaX~{^Bd%bW3Y_HVupNb9NOpb>=7+D3DWvn_^g5XBdUB~3|jg+d_KcL$G2W_7oT0D zwlzTTH+{2FcEaA68}3ni!C7fr#MnjdAmp61Yh#%B@^z!lMc#{6wW~ANe%rwn)t7^V zO7A2E7rfJ*j-@dQGT^pSDc;WTIAVDh`1>6B>rb9MKablky0@T)zwO#GL$;!jm{_f! zRDT^)B(oA%PPu3m5K_q3sM;NL6BsxnxrgKhXP+Er)J@dIMIE+%?(g}Q9hkSFOs4d6 z7aghFm7XiWZFMCI#ue=W!OSzmI4XD3+VjBdF1Ka`EQF&Ul>o6THE|EUJIuP>kFUit ziuRXnl?b8@i6Ax=Q)t0KEx_^ock~4&sEUr94M2GKDySkdhM{*(ICqEun^E35PL)c7 zdlbK5F(Qq5+Q+sW*_c*DETc9lmy<(54h~>Kvcpw7ra##TkYY=xGU>W**ZW)#w`F{% zqSirdGx2O4p-D+iamZ{IWiy;5gd(KuWd#*^7RR(1T&fO7zET`hwM~@W@Rp5q;E~@s z_D4EbhqNU(O%q}%hwrv4vCv4XOD$Uk6`^I<|3@9GPtln;jO)}XWj znUOjsl~G9Kw7-JN^i@=9ub><&{)Qj|{bK_g?cm>+_<}qrC}MMNpDZV++JtX+Jq9r7 zU(P)yR5b3x&Mc3Kj%!prL%$bz^|0*pxIxMri#DwwhE?ik2=xQ6LMdYM!9MZhI#c=dv$F{V)VIn{qw;Q zA+w#>m1SCz{C)e7g!BOB)OjxURRr>GH>TRPxLn7i>d2YOy147Oj)b$2S+;?F3FW9w z(5yAJ6E~^9SezV;H}Y-{OX;>R9q*zlzw3@?==)|!FDh}AxyqHTN0Odj+c{e^d6DEI zPD|!8X}AKFcxAryGBfo3MazpsoHtcl)TQHEN$@Jg9Xq2}*NcF(xchzS{&6j$S0z6x z#PE2D(euzr+eQhnty4R_WURVPtI(~j735?MY1zcIP3F412Cvh>OqSXs3H!vshQ{gl zL5GDbo`Bw;2RQ-Tm0_ZkE^;9!ii)?1ypx&e1-ewVCB3jhIRzVHSoTb-)OPUbnm0Nx z4!I=W=Xt6O2V zC!q`FbvoWb^Ja7{PS%%AOozj{(36%QVv;ej6h_q>xsCn>(!oHPe_zvIJ^j~){_BNS z#ck-QR3qs-NrKe!?_(r7e^azUHSIKip_K)epV*+y5Y>Ri0E2_kQlu<)m;f0-=L(R( z-*?r0Dezh4N7}JLbl%c`wl$-%=^>UndfMZ^dj5{Ba}&LIHnbFs%sakzP7?1;q5Mcv z2K>mVV_Y9S^hZ~IelI%Lny$9+n2?i>tG80bLw-*No`>={V&6D7);H)TJ{w*%3u+w^ z3eHn!0lT&vfMmtV0A!8@s?&|PV{j9m|BBZqY^%<%E%wyy4~%B{tYi64ZgzrptXC#EXNC>5q+Dx+Rau;TVN=g7a-T5KIMSY!YgVT@~ z*XhkNZ{GEoQIG&Hk=#t8C*+-uJ=m5weM}fT|11p81L~cq#3yN>nbcwhGy2Y^hXt;1 zEVT`C&RQ91RM;lbM)aA*5S=tdn*>-?kwNHplhZ28i%poL2 z;6o4qhvtm`R@GMfHA+vQYqr$sGC1x8A36Xu{*<$Ls2xm4Y1zhqG5(=5=-Wld0FM$K zsJp&5_voXpK`Y7w$XC!Fv|QtfL33-fr(O9I=Y%h+}qkyq6kLUFIm<3+1APZ$*1 zYX=8Eb@;L5S?4f5!t`Jz97|2YhOxb2fo8H-;z-FJ1w+y*z1r_Y}c(1^Q5oq6hwW9XlVxX@yo|19|MO z(znO%N;{*W$+LLf%kElHkX1Y6`^SbtI(1|XZ)lFCRrlxA>yck8R?|;BpOEntH8#c2 z3$@3~UJ$v%ONU;Vl$)IIFv;dk2`gs}q1ZL^SIDUI&Iws?NTSSM7n;Ppc&Q?a2Z)#V z$c{?4_yhd$(Bs=STxuNxE~$#5Twd5ly@ND_uFekkSln{Mrj>bm(q>64m=?HlVh`IP zySj&6w&D4!C+0}T{xEU2GKXdLS62Fd8S5FT;6et2Z4H zM;3KclEE*Gs#*S`wg3stu4%~iG>$7c&~r}Z+P?&WzN0CdVFSY&7p={=@zt`G8>Z4T zW@{d`;~U0!W5=L=pPQ1cqIJ_&kP-yWnZ{&?FVoV~l1VJy_Vb2Q8hnu->a=_UMst%1%wR+1g)C+X@18!fz?He;v=?HS!evGJ7~K;sD9~I zr6h-f1KaTw$Huj`$8!Np+Yx_w=_!B&_!sG{iM&VadL_8xMQ=lIT#su@K7Gg~0a$KD zNMGo6s07+WmEGZoPQas7rzD+Jl<=EbQ1pd~E_d@i1nQ+dyjHz5qbKw+W7Tnle&=qL zdB%jiSQaqXS=LSu#${jS!s-WTa!T#bcd>2KOzcNdWVJIqTW!$Z zaI!I~tKXzLzA#wrN-9H==#QPM5n8MmFnfyc^+JouV?$R73i zw*Lb&`bk&Cx3@9>QTIpq^G=JxS|Nsd+;Wqm%1L!sTfWPfL%9qcFn{$}mBg)!u6Osn zz-*j6BdC|GK>JfvJJaEJsjB&au5Ul;X*wY=RSl7;T58)KL8++$UY(7FU5&x2=hlry z@ss!3T0I9AFw2HHZdIlX+~J%_b?(AYWcgXgR?*CWo~DVNcr=ol)TbLy3QpzbT$3`i z$6{k&1Z0;L3hotO-EX^7-qcsj4*0o2tlK{u=WR+xEvt$l9zLfv+%pq&l#k?_5mFBF zYz zW}BfR5cg(qA&{HWI`z*n&c2(YbHf-Xx*kj+XGz)7tGBRt01}Cpu`HD4s#dz_Upra{X5U%#51Wr;#j&IiljN8umM7^`xgFQp)X`EPUmXX1?u{Wqi-RLstT-+=P98i+4EiLT>6>s zphH-IUR;DrHSY#g4-OK9G)1XOYl+OwbKQoE3n?%+aG=FGg&DjIPQb0+YEh^`v=ZJO zxvT9xl=?HH*4eJecN)kq=U%i1osDEHCPwn~W#D>rvogP6f!f~ydz4Qt9=JG^xYXhq!|WnfWe1NuR*0gRz`P2|>kaG$IjEnBxpo4|RjnDjV0CbtYPSBr(ABr)2F>%OYRhP2(xb72in1O!Mmr-fu9u+~%M? zOIR`q(=GY;7uTq-tcVw_dD4?xZe6RkTUX}iZQ5Zj8k^)@)jonD03aI@Kkfvi3>H*{ zv!Z%NCNqY2qq+f|7j0&wGH4j$L!9L6EUEpBna%435-Q80u91fxU!^P-|74B`p;C1a zdKb=2ZpL%(*{GZmO-}0wWOg2N54@qJ?5w}|+zRG3bTl2#$9|;S-EhIsP`Van@llSc zGy5i5fZX;g+b(UPfy4A0AuGz*`>1)hHBbHx%g~GI*SmMa#Bu{JTxTOfS$};zSG2-` zNoeDZzSint(hk;LxxPYi+C{?FmR^K#XQNWT{|G$0)P2a5eO;aFb%))In==1(_kuZY zxm;DG1S?lHvP^Q0i}*TPs3Y~d+iF^L!+{xf{bv*u_GJL0V|X{*TOh20LL^jX_CD zqG>h`xXtvDDrng5xSuH&qD7sr}@ljjma>S|tehM9xM0e75;~1k^ za($6#C!D8HArp3ZuO&l0Ej^>>y_u@wpvdubSc*mmyBvq>U^(t?MWuU0j>VR{YTE}} zM*@=;0MtF**E4E6Djy5t&I-QlS-DxO)3OF!vOirjOKY@tQK((u+{g&zYCDA~&>l>G zXdq?XO#3|AC#0Tne5nPZ$h1U&C@=MzySA}z+zw`foHun-h{@Eo6+BC%HPSmx752Gg z7PyX4q0n+Wv%JW6NJpf%yZaIVAc0~m@6N=}JAti^8YhNrq^dIvM>wq^`ZvG_$ER~}|x!ek-c``{@?Gl&T3Uk_FaSP@U823NW zwOCos9U9?yh8L{4@pm%afpk5V(ksZQJ4R+j+4-V{UBt_opicKwizMrJ>suW+zsuJ| z9^hiVTD76tPI|GwwcO+hAs-Mk1WbQfPk*E1k{{2>SOwj(+` z?Y^D|l+p4?0YsRz<0Tn31Gbn@zQ$;2Gjr(xNEh1#Qmr6-@v>rxPBnBr;gM%BG2}1g zBonH@s?mJf2||ajURpqW09qQTP>6*S2<3qVf}G$yAw)1f0r9Qdabv@bZ=nh-IgS?) zva0NSYI*e6&&T<>WwCMHSB+5GwB&a(=&S{-3$g%J4tZ!M)B+ePL|3c#0awWn_ z$4{fnXvgntsbzutEZfRCP*+4$z}%J| zxoToPz@^_hH}&ue>{hsbp<3fM)xWaFhjJ)JVG^nZ6e|2jC6Zo@V`~r5iLJORW3J#Q=lw5LacLx$vP7sA~_nh=bretUW~u2Rj;OxLWB*Di0@RT zn{oGg#hZiGW~|C04?R>=Z0o3{ryv0c21ap^)oi*}6`bg7s^?WXIlr0a@y$@ZOTDRPGFSkS5&__Cl<`Q0m%c$vxm=fGPc7ycf89rUYjRS z5>6*t-kGZmkFjm3zQ^queb27?7cCxzDUv#FB#+@BF!vt?D$Q7VT)A&%=E(nwf_!ef zg^}#sr10Xm)~q@z^Gx8K?I!1lnjz?^IezNKtMkr*1mRO`85K@iPSppMS^2t!zuJ}c z8ZKhMZj)ygzP?lywDXpvx1~|Ol`6ev7BFKt$R0JuIC&+cprXSn#Pm8y*xNtgR8?vf z^M%>UXoc7vPm_U+ys=Mw_S_QZ?bW($Up3m?hWx+KT)V2SgzC$}#CKHu05n5igNS%r z+L&jvyvpf9&mR3RbOrBdWy*QyQ)wm&UuqUT@MiY;8_X;k9b4@=q^A6-qO8!aVYJ_> zT84|<7s3o-l2XiDLdGPswOlhcZ9}mvOQo|1@xON@n*bvAQk!{@R9{z>Zv&O39=5Ml zS!%<%Py;k|1pBuuNnYGAe}}-9pb8^-z&~TLDY#TTQIqvVdb2LlqA% zoxK@|4sFt!zXOxyNoVF=pcN%|O=|b9&ZZ{)55k!Z9C0U9uqJih+1fsJE<3W8C-|*yv2;8(y`Ds>RZDyycod<`8Rn zpuDp!vTD>0mOJvJzkjSsB@|Q)Y)Qw*Iq<^Db>ZvV{-kb$=hwLnZltR_ZC5JWjr)ys z5$Jp!VY`+M#&&~l$F!rtiB39SN8Y~0L^r)+$(!1rza598#UD;vLF;uaeZ=)Ow4ulb z2biF|`g7I9c6dJ=899sgEBmiAy!;1V(1js!spj$WR^{uRO67p~`3t4qQ$H~pWIZ<< zecFwLFi6dmnYFGxDAk?a<8KL1rTp}bh_)p|Yg`|+c=fOwP9kQ1zT2*pV?ieE-sflT zYk*LFDyl74*Z#t;8naoY#@%6RT*nP1gtI0{>79LFEBh33)EipRX$N13XT(*lwCzm9 z@l-Ma$CmAoT)wN*b(Q4F(g|iLbo_yx7cv38@6qwu1L|9zlyX;}++S6x^4Y29jJ`LV zirwL;)Cj3jg0x-7$52?U{u$;HwTvyVbj=Z^u9HQ`$;+Sxb(W$aWE|6MOQIO-2s4gX4ZGwg0)Qxfj!Gw%jeBSK^%ixn49$Q~iJ!ZNva zMTkMQ={XYpx7ZG9)-GAT#7wK}G9DmgV#4osg5!h~W)8lD(r1$L(a^Xk7Dh4i+F#fi zfVP}%*-!~3IP3XaCx|7XHLCzNU-=Tk8oTIDFc(&!Z$+*tdqoHb_iaA1+HUUqKK^7P zK*KzpmFV>{W`k9#zn`^YtD~-eE2WrKH?)5}(o-!M%^@+_m4We;bOM=wUIiU*Eoq1G zT{+{s!o=QLnlUc)^j|Lm>3*4I!kBTLfT>XO!I0H41lUj$B`V$T-h{e`_Auh%XfzJ| zRDJ{Fmq32o}cp6z~`RfEMMLljbb+Kyivmm&WtnJu7F$inc_Un)~7 zDlNf3D>T*{I{lXN#g_KO^A7gaz39xS-{6!e(!~_S)d2F+b~JtE=lKF5-^zlPKgq-* zE&ZqQ1zKubS-6V}bx`4cs5tvgT}(4FHrjwsS`sqv;(N6V0crEpme~y5t=1l0 z$`Bv2ua?N6Pmx0>Px>iw==#To^s9%zPulncwsqRN;kM?~&32=FUR9uHD=0x)=4k6E znPamN%h+WuN7~BDtX=@}yPfNRT*b$1D0tJkyp$Q#2Hgl!&p~%J%0HZm@+wbGdp1T* zTi2;p#Ikv|DH~Atml+y$V$54Xy_8`azkXyY?CWOykLn^rN)RiD`DR7gjQ?f!$;@O!`+Y_B>3;j0 z?o)K+4OOf4FW4uiqQjP{`8_jn-Ml5(P+41%%E)ITm0JT_eTeaMt5KjgVcX5QU^Ys1 z7s#L&>RxRma!l*5Bs&`>dE&)cCpxj9S!^d3&F_>#5bZw8pfjyioOGG%s)K|##FG~~ z9|ja64_D#PRlTI=&5e$=IX%%m@DCHHQYyC~aI8$Vi5;JK*xA|hrDTu=-I&Z!{s6a73A@50HVV{Wi)IT<)!yf#7hrW=N@#32jq<*oJ zYLnKvTL&GhWXcOC0dr*ZAmRbV$EYBlOwWviWJRSl(qj z=9?R;!eFuEj9?<3A+y`L+mWRL9+)G-_9&EwSJCq+3nv9ZR+eLw%ya#JgNugC2brPx~RR_LAi?{bB1+wR-RYYV%VxSqj}{4T?r?;@1f2> z;Avk6!nUI3uYmBDj5GSb0dSd$<-Y*>?$|)t(GXT7H^eL${o1jUp4WwLiq7Wq6$S}b zOMao*fgN3)LcG4hDw6BJwHw3d_zQf|+cQv97SWg=OdEFn#jw*5^RJKK*Kh3^?)IBr zeh5l+3`?X^xYx@MpSLML{06#bTnDwn;t2PAsaPw!lQ7T2gO=u>_O;3Io#HdETE^+B z8$@eThWT|c-?EI-JEj(hZQ|5+mMvM-Jz8nb^6UAn6(=8#4Rwy(**qpMP;3l0sH-jL z-OhZt`3n0L@N@H8J1TyNg*H`ax*EqWTNpFaadS>MxjgNHR#@)RoUp25Rx0@@*F4JN zd+KDrb~Sr=#97d0)ZL^Ts5uo%QSP*Js&lnbhv=)=wK7!fLfHziU0lZ2TQ1cxz9$b_F;Zj>74TtbayKl_+}jHR7tHlTuSe?{iWMn!ZetL z)v>Z`X}B9oPvBNC(0(Z#n;kEnkYkQx`VF~>hLX;pr4J`|Vqr<3#Qm80t^t<(98YK( zyix4b&J43dP;u^Ois!Aqd3LJ=@C^!$?*21wP+{BcZ{-#bai3ewrA}4b6CkTCon+^W z`kacNlu>ioa?0HM`rjA4%=fWtr+#Obd2qJqMWw32**kYkM<2H9(JWUqq z(-tBg(c7}3peR-NUardFDbL4_eZ zRDjgr8@sov^3(p4vgBF^cVZl|b}$)0iviUn!{k{kq3(Q)q+ej;LoEVA? z3{3fJ^qH#RhViU<*bZdn*@>l`3zwU>m5t%-pfX&ieOEiY35n@zrPF98%ut$(YG*EM zHGN8{>c_Zj&IaTSJ&)qiipET=#~O70q_OPC!gy-oKij>^ID@@V;aKBNyv(GP$txOa z47a$E+jr-b&n;2ZRh~y3MsKQ1XWW7nAgk{YM~~k2EI`{{7?w&M`_QSylg5eyj<_dV zi17?X;RQTq@pAJjtZW0N#%C)n%TabFG~rG+fweu~xk>tnVU&kx=PCJ~O zcG{XJvQ@^iQJi8Ah*uwWu}6dhD3| zntzxA|E+zI#xn_CwX}95B#5nc<`%VD@f`lKK+6D{eyT9?zvcPg+RQyp1`U3NkYs9@ zI5%)$xVV|mt^6J1KtNo&=*|$AwnC*pw@g~D8DdT~sO@-F<+xw%p3EqTgYKaK)cpXr z>ZB5NB2j(rpS)LA3{y4gxMOw^*1Hgt^g^lE zk=Q!<-<$v-BXR)Wz1VhrwAEdpLL&|RcF6FHNT#ZADM>5os=2i&*5hvHuVES(i)mTw zwUeora{k-QNT-1chl6rus{+3t^&PtVHgst`pOt+Z$Pe+tO?oYhoGQPLJyphDP>y;3 z!hCmaaQsEBjDv^L;dg7cS%&wn5(2Sl{Jv;sL*LFn_7^L%r}6Q=<4FH zAK*^|(WWodhLRWoYl}Ic)`ieicIA(*(uxMv*U>it&TiVCC(T8uh+#lTmf=&53sbam zU&!#F4&dEZ+*PC6ZWlTN+C;k%Oqz-+cPoY6o-1o!8y54$PtIgL$K7ueb1a0;pMFKe zegpqJY*pvnhI@Wm5g{I`-5K(R2?dd>=pvKaVJGOA0n;IGHu={Mt2`GCtaq|7TQ}ar zc6_HCBb=+x-;bHX9sI2-Yhqa49Xpg17@g39H*~c)zVy&hjc9xw#3)Wx?Vm9=3wXm!ie99UE&%<3y1!AqF83UWkc4 zTi2`#7qS!j*7hy?j+wS&83*MkT;qyg-f8I(cTG0dDAdik(VYlHOB;eYSABtMERUuE z*-;T=Uh4dJs(R23IY^kta+rnNkA1g`CQcVmqNzlzvXncTV7z<86TmwD{-%1z83ju0 z&%hN&nQh`r+pfD=b@CC%Ni`N!8ufCv;+iD(ci(uDOT_T-*}FVKN5a^-hn)agTE2Xz zEt3VJ%{^6+))NtI+lMmhOtT~3GCu~E+ml_0j@r^sDydW&p(^$7oJz)yV$)|e?L_}grqhQh>sDbXbD}6wBrGwWEFPl&tzjfJ6J)>zLjZM%7 z7}7DmGY1m+=Urg(9W_BTir&H`ljD0=RyB-jSxx@kIVh z?D)xw;_HJDzfN>xgSOf&w}NSl%R60tof<9Ti;l_odxDn6afgSQ18G)!Deqh-&&-bY zp%wereXd$5MB8NPB+NBrJ_ncbR{TX)3&`F3XGn~(m zo9xClaRw$k%2VA=1|7Q46$XB8%>_Pb6u3@+XS5pT%>atm?NpK;v-o-8YFj8m)i$fs zzs*L$4TrWw6Vv=_aW#~aeGXiWD!XQ)?!#_04G<7WBTtLoOSt~l1)bTFTG*~)47IPk z*@%!1!P#(&VvnOfU!hGM2RGHNC$68EM3 zUjZC}%CpyVDp7)kUya92Ky)oMHL!eV=cJp7rqj-xF5GXm+6;vq2+ApBpp$r4ZVq18wCQ+sZo$Pn@OQ-*)`LMwnGZhKXX=ZSyr#Bw`t+CjG#0xZj*Ge@^C_mWK} z#JHNl-`eQq$6m8YKjU>GF~sz0ZlU1Xomlv?HOg5Ek(;}%PqaM14&e(h7#u#m~-!3z(!BJjyFko0k%c)Ek;FlQBZsb zUS9^%k_`)>h`GZb3}9g0ow zX!EcDWzM73vD0BonvK8Wg=@HB0htJv&mYzKImf_YkUv%f8c22)6?3H`>k(4ixx zmc8ta@|Gvb+6=w$yLqA1RwnU`;nA_1eVK4;wLK3p3TdfBk({AIx{@{Igs2|-_9jNbhdv9)6H9|s+Lv$s>j3X=Z@Zv zNt?DS20c(tlwhHM~_hD$XqfkP2>hfm|(g%a?B80zJyklbGM9&6;Hht zW3m*{bo9b3T6#-XUK`BHCZ$L{P-RTBBpn%VG-0Z9^*lazEQ1xEeBn$!#mT?ZM(%XI z`#PK*&0CO@HMnPzM|4$+dLKzgox3fU1yrs-pV~p!A0)07q0G?j>k=mgS)8}-wp{cV zf1RVatOJ4H1zf9{K)bH;k3_v3&)Z>BYB)8diq0bO8JU`pLW-wow8&d1yH?%_WEF*- zKMKgiJLWYvI{w-T7;1`^Z3M0?M2xLJwcv&&*gkxiFtWw`+D=+_6c-+J z>2Mm?cu@qrJQRFgGs_`!5hKdcA0Gx*@CqEu!=_7;ymJ!ehm z+t=Yw(MD`(kQCfi z^E%&{#hCO{+P*1OjG=t$Mx;2Qf>2#mhX6G|D&v&fYH+=T)$kH@ zlCjtVKDC3eoofO1hv)#%`Pb~hw^{LMr)9esU!(PIF`3TSdcJ0@K{`5{uVqmTvUD_8 z+fF*o_KKg%V$SASHtzm9n5*sF?Ix3AGFQvzgLFF0=9}q8`8FT*i_2H(MShY_^U=wC zpG~t#dNj!9YW&mg_N%!XZl&Wn+g%;aH}tFX;ZZgp)V7a4Wxe@u>~%URv-v0SdXf+G zX?`(Z>o=*`kKtTRcgKT#`aGYM^G$nqI+=HW_fF5}JVkl={Cw1#=5wBmX|Xv`DmICv&DXPoR6|( zJSoQ6WO|jHWa0=;%IkJ>GANGH!F9hnP0Q`e(Q7q!c`9h?sX(La_A^Y+vSgGFvr;_H zk^)b}>^&&QgS0$_?K;rcO1l^d5;TR|B_EE(e3IXjQv9cNm3&E#C&e)NaGTu#A8vmb z>2{-Hic~x=PkCc}W;M)y9qExjos<$?nytw>?=e#eeum z?6LJ7(y8sqUL%s|ZxF1-FQT3k%l`+b22dHJfC zc86m)jYYDN^wLp+r)zqeCFx`$8UUInBS3?+EXBDMQ&{^j%0A-|$7-skqsK3k?6Wvi z{Ss03aXPws`m`qcS~Jjl{PJmiP4)kh@Mn^VlRCnOx1P{||Nif=K=`)a9Au-D>1pyb zSrQlkYj9^UEv`QU{3-slW?+_rBPY*rPHV~eh=^xDGJ%o&YI_o%01RO!Ax1@v7Ja7Y zgXz!d;5=K?cp~0@7>NnKoNHzRr)s>PdSr%qNgvxYA#mt$xYM1@HX#> z+`K>j@HX#>co*BgVLGOf#2MLt8k*wX`vU^m@mf-w3Rt~As3%XJCi^%q0_wiKl_U}5 zCH_~z?3n(Ty`f@CRVdX+-o!Q)W|*a7`*4D9*aY9q!nK>sE{t*W&#wv*-_W+dnRnXr z;^MT>#G59$X6^%lg8J|G2kaNz9nQ}Zrx*Lwp0pV;tpk3#R}4HBXG*LhZC=3Sw~uRT z{(@w}X%Jva2W4`Z3v?dqK~wm;Y$oSr28Zm|0d-eT@=-Yz=cxH%q!%uj0ejTPdwTEm z3qh_B!5hgDA^KW!L}H+|B!rxR9iy1^wXlhLPZTl+>wN0+X+qA%Pma&jtGC4QO81%|yc=exN_UB-ucm7ySad6)ZYz zgZOH>E?dEWzSwune~!IKk@*Yn2y%emW?Mom=VQ57PbKjyhIyIc1$l#A!}Y>Juceo1 zK20ii@lV-C?_w)15TiBNa6dO}2u%y?0Y_O_6Ah}r!{y0O1mSnzK2DbOQ`L$;GcBJ! zVQ}=mvECxRRAAwYmT>45;%-113yrg{c|C;Pm3hID01;E=?#ifNau5cXwrJ`JRE(^fVRcdmu!j@_Y>7C=;bg z3~<$>-r&5SmCn6n7+1lJAs3^%AU+$Z!6?i613?MI6aUfzL{|MNwz{sCa4e>m1;L^| zu?{&6WVjkU5gB81bjLsrTzJXB!a@aL;P$a1c7mj7Zc{IK@2SnXI|R?We&}<0`P2Xd z`gQ?>z#L^G!Ng60<^XWeevpW3W|ADrt`3u8qPx

      tO@cBC_YB0(yi`ML(b9RPoq+G704K4xKO`{{$=*VxRuJ`3Cfo)kyY(c2N9l1Zs zf3>E5e`hvg3@4(OTPb4=wm&9TZwP$zeLK$?xlPfkpNpK38`vTOuMn^lp&-Vis5u zoDMy{xIU=z5omAMr}nlxf=3h!I9IP(PSv_zDV}ZMz{w#rJrn~9;z^Qg|_l5a@W z3=|Gu*V0~3oLNb44|~J$VI4&<>~*~?&xctl+lp_~vX_mZ^#Yupxa3T5PzNB0GQgoA z5)8*51+t{bu^cIsAz0byA}$Sa9KnPm73b*{&S@~o(*6~!i7ak-vKNpN&6d-Wg=F~= z2wK)rgGp(@4F8+_kSq&X@oBQeFlc%@DJ}(}y-d&`U;A+TDD4lf5&{lQaV`09TYL{6F~7q01=oWuoWi6wjoAM@{?0R zFf%dNOg!iP+OV)i(j{vii8r_bf`1A_(p5VheJ9qLqTC>++s_2tGO;%$$`Qzbd`d3_ zeopc+h}Tz_0s(x)oMgV_D^8f`ZJ3RwK{cSfG6({$@M$R|pwC7ki81vkZ;&iqfrqyg zi59=5#3UChyN4T&4-h0Ww1(Yu_%B;Wmf}ot6>}~^5vn!`jmbwi!(*^^^%wFH9hHv} zY9a+qSS{oBQS9R!zgVy|y^3FqXzXt6?XD&L0x*bRhXiC=tgj_-eIi z1l7%on&fhbTU^b}$n~O)yPRXyWZPyd z7Qcr={1g=ZIRC7b5hwX{kRG8fV%W>l-f1>kbWHfUAoy9ic=thMt#o*wNo7HTrU`&EpPh{)>B8R#?4F_8k91yC}}4TrICv68ahhNwRNwG5#W|YE3W^X1zn|I^Lm&| z*(P-goZpArgF1aLRdI%gIY8y41yrM~6a8q469llOs|&$v_xy-}TXKleqo;V+*hFX^ z_{a_;ILKHun}G>|SPvcmt#}8pmExWpRAJKl1xeEheJ)%IZY^?oo=eHCk^CI9 z^Wl#A*l%eQnFjjjr^yp*p7Ou}j{O{x@P?v2Fv+0d{<)EeQ&+zx`ZKT^kq^P5O(mlJ zMWA`2UAAh&Msm?eYEp{VUw(;f3|t69(%qH<7aZ`vOs@fbX#8Jo2Ly{9+5>nT+J#}W z6k8zPHohMA*F*gkO9WN0m6B-o>v=jTefcwJr?qL$UYOhj;b_ruNf_u>Jd$z&Oal~F zM^PG*-iUbj#4;vaPH+_tipG+jJE~yl{(7E^{Sb@@v6a9gf!4qngn^5fj6B+%5aH-& zI_e{TB0j**Xv}7^2cq0Co1PYZvQw2w59Cl(M+g=@ABjx_-)^5och)9}zYmWO z7p9YRR1VKUWkQqU-UU$ymh)k7dyM(3cRrbjVKzJ~7*j6YYt#sNu ztx@l5$(!t?`+3}Oh>_-^xC> z*E^igEG5Po7NghbsPhufZ`^Sx)pQnZvT}jA?xWx}-tLJYoO%P9UITqE zuErVAWNh}~HVygVb{(GJO_LtL#kohMoPBZReQ_keIC8)6ot}u6hvoztKcd-+>Rz7a zgG?+$vh@ejB~1RR%hqH-3|iME9oPb|V)D#R!2SPxa+Jd6m5I~`r&otaA@Y%!>u;n7 z0d2=f?BqBbm6_h}$f-+5qbwc3!BZEAbQ+i66K)R%f{E^TvcWVJGh9nd+cgC=*?uj# zo(qa=POt}C(?|P@e{c7pg@Cv?lBdlH82W1bTP=7{yT{22SDB_)mcn+J_eo_7e>|2X zk1LeLb5D6Ii08pZGUjvz86oWBwgpu z2{gJoMPg2Zev=ylDUD7McTO_YMC4$G#japM4K;btf`eM(z5I>uXco(sN;+4NmaEbW zpbzn*I(%N|UwzVFc}vxuSsnb~bRcPdS7P%Mg=f?mI$3>^AAllIJr;ebCDxrSo2M%Q zJ%LUIf)MqK`7!@AFF{>%gi%0iW=96onmyeH`-pRae5QQ$aq|?Qt8M&-6Emc16(!aZ z0y@|mK^3ykf#=5&LV%beZh$B9$PwX({`KKS2aLk{372zj9p*hP$!H~o&2%dnq6tYQ$F;m}A)@7}80_<@>~mr6KKZ?8vnRAZ?Iiv) zS%J4F-2on15bHqg1rTCR7TibOb05?ric|gmfO&HXvUmx>bc3uc(Psrb(La@VS7OIb zB!t(sk=0Y?288YM9pm(NN~%Q{kr zL%1hKa1oT}M}k>D6+aFchc9G|@c>x=y<~V^O2u@VaL|bc$n&R)w@?T5cY&B+5;cNx zeDT|uu@mhIV>|XxJJK4U04Td9A+V9ywr(@ML$L7@)lNR>VmCivn>1l>aizm$3(P=A?$EI$iwz?0LpjWf3dp-W5E zzEZP3NIj+c9{H&%wM#S%4a2P7+jjYbIU;mGEJ-08hXz%OU~x0#qjd07AvP0O_+ld1 zclFv*Q3p*O@cfhbR-7a8T|_0l5^7Ed%MAWQg3s!KfD$m6tAL1w<+|#j0nPEdMx--x zCvbtqecn8_eKOfAP`@aodPf_i)Q;@6yG!qPuZBm(pqa}i2epcU(yOiz37yCi!?OoO z_VWBV9#!IQlWZMz0}DA-SfAK_71|Cb^%|(AfL#%z3Q8jmO_}|A4w{u0ZN^P|@VAB# z8m>!3YUSQ1t4WKSvt@m zrs2%z&~V;v-1bSpm;kU>0E8&$T#A(atQ1lX-a28YI~P;%Qn6#XCVH{*RunP=g4Ym|usGq*>d^DH+WY?car4&*iw86I zc#hckza}8QHyqCq>>iE)5Agfq*JJ25pc%Vnyrq4KKE*HW)2^*VRh|xHT~t0PTwmzA zy?%);NPq6c3xz#A1EL#4&6@Je1qY+!dPBO!MaMR7r`H4(kD>7uPVWSXOEH|xmHWK3k)fcLfd zFS!GNPFO7csdR@FkAVlO0z%fW#3XYTZayJI5t!3)&6*WWi-l66xRN4BCGr8LAtjK$ zqeoXvIg5xoN%PTE2qVQbBcqn$B)$hJT`&+0wBnGx>-Z48*<2k6pgjgv2oa)~h~)~R z2!gdM$bhy0pQihIsuJDiyF4OC7$4a>wLDx&4s*kgQu&XW#e7BCqX9%`|b;E z+aBzfYr?ZU9>Q8d>pC$rR>4fFf9WJeH7;-6)PqT8#RQ{sL^lFT@&}c*iQM8%v z?GgIw;8#d?N6La^M~eV*J7koDIQGXn+6mQ2k`@VJQe9=fceSlI;$GYR&$i!oDCB`N zsWaF#rjzB0)e|8Yo|6~qw72?j5xi`RG94^TvOx+6vVf-(VhqUQ{5KUb8Z$|SR1RVp z=6qLqq)A1ekd8;w>_nU$feGO120qHg7(Y}t2|;5=Jt3q3rC*ZYt%C(ga2Y2!^+ZkG z5J_Sce!PW=BQWgI~ZP zpvJn)!P0YcGz(KCi$;N= zFk%{cc?uV&^u1MlqVmDLJQc?QGoZ!PeMjIUTq{V=yhi;xiF>q;;e0eH1_O16ZjYx7 z#09r@7t-n@0tc~1G76o_dMt!heYib=?GZ2#MDrM*u+&5n90A>F>3L*8S|Zs) z-E#AlVA30C+4UyO_g?@7ny)!sRifAWsITX*axT$axuPq=)oUEa^h#xY#tET(Q2LOh zlM^;@X^p$*X}#$NIwAje7zBe`@qvkTmG4pS>==M7YW~H?Lh)@qa;|W3x8~1yCGo;= zH*%edqj8oR%55b$9EpZ|bz*NUz!PrP*l;j^k|gIzZH3-d`crV?u@jkb*Yv=__DJ$v z?y!>ZX09s{&@FHtw@&#}=ChuqVJ9mZOof@e>583P{ErVG%I|B>*2Mn@toTFkSRG!} zpZ$F?4*}#zb|TM$qTS&fawW$(GkjCrb<-Lh)mg_*hTzP7PvF$*GnvRHq!D!)Nnf8J z^EKBfEvdeI@fS=bbk^0iNsVX+l^XoELw;+|(|j_xsw0~Bz|NdadUSE%RqXpW(uqDF zfps`JEHIvjTugzPI9xsyH_1e+lZ4<6UBPuF?)BRVT4a~WP81BNEiqS+zNRY+Tj)KGBA$c3L*`H#{rA42pXrW zHcA4anQR;J-Ok)Y7lE=Ih$DnL+2<9sZpb&pfmC{HUnoh=drK!Lf=7$?KT3sY2h%BCRCqu|O!_ zHMKuquRI*l?>3rt5u*uCK}|GGM89I&iczLWJZN4=g~nXLwomdb7MFr?oa<`3_NitJ zi+#|I*RcD3-bfzJcls!5r!W#Lsv8gGP_C-VkQ0H2l5_!sAg)`+BOmE)i7?3yr8)XU z%qz`_(KPi!E@&>s7P^Ef9kB_`HH{-0%O56SjqdB}5VihV0<|J+8Y=hXBg9wG`zB;r zZzz?eIDCC^dN+2rB}HJ@o)~WN`-JksmkBv#NP(r1?B}EDgLQJUmXF?M>6s803gDhFU_M(@K0t%)c>1HD9oyp!oWcb!y(|#{^KRI$R^+R*>NnQe+#MSG=I0eS0mhC&dLUB~`N>BB)a$&BPsFp60#NZD0I2EC=2Lphb}m(5#OnDGIfZY80-D$X$F`URLVy!ykE^%uXtMHwniv)&nI zAIp&NLx1cexB(^^I1)mJ7eyuuYB#+sl7cp@G^~#FV%*9T!e>O^4`mOr=uLg z&93wz2COa-6}|_>>-S)BlxWpJuT1UqST^khq-Fw4s8!U|c=|d^s|Opo%dCeIjH*N! zUtDh~K|jo7KpW=``V5~2M`8S?>aALm)0=AD%rrR*p}{Z59AAa1ibPSeC>zQD6{stl zNW`6iv*4WZ)%fbr0)4Yn2a?q?escds&{rc2FqEoS9DNq@s(JH|+)!`!4g3Y4GlXnuT?&#DVP5;7ZJ=1hil&!;Eg)rr`l}H8?t&OH?jA$JCmB&=j%fp)_An`4ib)!Q z-hh+U$s>qNI!f~aCE|s|`oPbky+mI4vL%S4eIlB& z(CBXhoVpjiEv^hcAD~1>xXrx`yatMM(C$pcZFG^Ra%tus5?g2jy>QdZ<~O}}9MUCa z3!i=&KfUL-Rv7T8%!lT9H^&YD>KSk@T8#ibpeIYO5CH_8`0*s;~@-lf0({xkG)i9cs}17iBvCI)?K) zdayYd&Tp^!`g&f|BGvvy_NQ@4-ctdVIVBZ>wMyb}UWzR-ay(b;dD|6HGdC>R zS%#F#%t78rF{aCF>1fNW_ir%4bY#+z>4n!abJ8@_T(ice_BFO~Y;oXlk&VT!WTR<= zYSJ0@+O%>~z?c`B`8AK`VI37aO?YC=Gd$V@76&m7l6YY}g^(65Q}QJ|0r7w|+={{; zW#Z1ti%FAZZS`i#z1D(n$wp_gmKast91D}J8(!CL3UT*63mKK3++@h&#w%EBp{|wh z#i{&WFBt_XF$F9$BBi8c7iycph2GEmAY%2ip7>G^aS413fUm%>N779jYq~;>CFZjY zB>5;U#cd6)Ri)$wWW39z%oaoUb@I)mqj}^bl7TRfup(h_-+=pnG8GGfSe+3_J!lA- zE{gR`@(fdFr|8dtj^mQgYC3!5N?j(T*AM}<6matbE3>f_&Qv_&C$J*^QJhh`AtI7x zIm)PMWiZ%8g~SGF|D~c`S%BaSVoD$hV98Sm;0eNU0j|ApZL1`Dcylui^>ycq$B#o; z8zub9y>$gJyvfbL_n=|jpgRAIB)>OY2Gik&oDC{C7PhDx*ai5)6xUIy+;OyHgl*+z zE|@DDRm~j$l=#E#UFkKtW<4cw)_tmN>h@!B8_>_x?Ie&$yo57BstoZvpI~)VP$0+` zwXAv4gsMlEQh+{$;Jgf=yr2b%Bt1!UwBKVF6wm6M@wisbBv$b^n$<$H79`6ny6Yqt z2luH~#5m6-?-hD1u#mwkBF=|&16EI%TgUGQY(E4ElkYZss45N?W^Vg%8!Y?eMm5aJ zGCh$$dWE=uZXd9=M#4&1rZ+j!^~uROrr300v7vlK+!w}sB>1L1NQdLBA8a7{T)r3m zH1bM(w7L@gDDvw0phzp<-MbTfXFs&c0D$Oq1H~QdoKkiAy-%`}?DP0~_qOcvMK+>D zD}Jvh>ebgxS`d)*=RCWd1r&pCKrsxGcxV3T{P-A(T|__dD1raQ43rkVwD6m6HR)^2 zcJ65g35|3I{JJgUliN|FaOc>dann ztan*D*(yfU)9Pl}q!S_oE-K4p+|@@^ciuUlq}FBR=6MR-2F+0~xsriJoI4BnLNy-Jva(xuxialtpj*e|ZD z7KtBddKY9EZLoqC3x=^o4hmVVIE5fb69)`_Y%b6G?jrxnJmR@?)6C zU|cGuj2J&g%M|>MNDP(D=ad!#hTiV-a?&p{%oQsuBEwLBlk*4r9{l{rKU5Yr%t5L2 z55shH4jxI#xEP;fGRAY%Hp3@kPrGUFG-48KmLQvktU&lC9v4*EpA2`1+J;;;zy?)B zq%zJ=>>@8}TERB%=yI_&z5gdEAa0kSNEIkh2=RQDuzSju@ZL0|BpYAqAzZk@VD@6F zN2}se>2plx!Nn~5v1e$O4uOv47|uLI7VDw3C8InS!mN<%ktr%035c^K1Ry@X5>iR? zQ<)Ge7oY?x|3)=AFs=S7n&9(`9#OzmzRb@kWIaL(0*!7)0MucSIpbWUwiDX3a=0Ew zstgdb4=pdPRB=psDeQ%1maYDWAL#Mp#2M3=uagQb!F&Arz`yqN3x&O$En=1#zknEf z`K2PmV%0Iw;+1yz<$j3JX_%{K}+ z-ioGb8+0CN8n7ymPeNDvoRg+4kb6T_f0ym3U+J4pQ}r7;>0;;Y)k`xghcWuT&}O|5 zysN5pL&GVKNhjf!=+iEthjAvl{TVVxev)V84*DzeTCECLTanKO+#Sy0wD z;}TMW^(hlKC6JYVHl|9-NkK*eHUT?Z_H~e|)SeGIYRgbQD{)K*CSq&dnyPixGrA?@|fhahsGU&DLn zQ&RXJFuuWU(1$Qu7MrS*aLzM@gbz>LbZ`QGLNoJO3>S(^3@R4fk6`I@@cz$6V&92F z#&{2jCA58Ce@^Ed5ChH3kj}1m^(UL+3+K?8s4gTW>}m6RUxAzhAM%dBR0-}PuNYwE?M zfQEE!%Z?uh6+e_sbuo5;O>pQ=Ms>-Hi5#6AIi5Ay{sufKd|(D>8H1_EzLdyQu(%W? zOX&XvHxJqM8uEHf(S9w^5Ql|iE*W`F7_%V2%ZeQ%-|~WThC)ec_!w_k@MWfI69s3X z5UI!m6gz2-v9v#jU+^|*nX5ckD)d+^uk}GaelD8gNwNriZ)>KZlLg>_DAe#S) zC3~Mj&Kvm03(U~TAK)AB7M?Zy9AfsHtam;EM~#7^7ZwRAh(gi95Oil7d=PIILid*&xMqXGP!c!sq>{9rgfOM!1|70zxZBbf9bst3cQ-9T$sdv=`} zhCU9uu6@l6eQOWYUWm_ewvA185pvG)jBT^P_4Tu9#5%Rr*Vb$-%|XbAC$5xG$^7k^Q zc(dt?C=p$r+g9=Kp(7Tu7R@noOf?uAI!J&H3}*60t2B^;F9f0(`P0XMig%=&!3!IN&IkyK%z7QjcaqJ@ObR?{nPhEmQh!Q7d|PH7 zLu~>3U|WNbH4awt3KyI*1wnaR^E8|m7Z}h~MphqHnSLZ3unI^+l^Y{9_7^uQy@T;I z$#I?yD5BvoJtP%Ua(Hz3Ea`rpPE!8*=ulVD6fHq_lAnxnD#D|*_%FIZzL_9 z?QPwuCBNGZfHm5w>$A!i5k@(H(G&7QmPB;VpRe5;Ha)@Dx|LS+>u9JqIo5Oap+P%u};vEaB@!Vc}4Po&r9cEtaa3cu~>B0`PMd?n& zH(n~4UJNrE;h5z}CcHR}a_JBF2Vx^xG>g>d1HU2+sJGlaE;8~I3UIqCg)Co24~Su( z=5rNqDQiVNduAuT^QfD>b*|O~3zbt>X0(Yn+9a9=Ay^(${-F}mH^e#bf}y@4K$HJk zT`?20(l>NI`v$8CVr4aj2iAw+DkrWe-sm|!x)B#Kg>>7zor(lwZ6I~P$p|sM)T{nk znr{kmZ_QvnqSbL0DfAEu+$8BS`T7DsI{-RBL5gLv|K_DMJsxF%*HADD+`6qA>}Z4U zWCOTGv1a{;+iQu%r%<~MVg|4|959m6RcKX%#mB+lYAx{h+er!q=w!=-V6tY&hk^NY zF?)D#AOM%ZPi2L|kG+z2fCQ3TKZa6B$fVT<`56oPq7?o19AXK_GqpJ6U^0{C8NU-m z;P=GN;QEDFm_VTl#nqb1RqFO~vJ$K%??t0$luS6mKbd-mo*x*602USV3f93@dCS`& zlRaEj8P>N3N|em=J-#YL{C3yYIBj5}bxu(5Ud| zL78Rdp9dtz$0=mcpJtaAlefC4A(TqQfO8YrE6xuhJBp3K6!#_>RFS81g+Hin7_?eb z_xf}ExmVDZP<;?F#$>t+eg1*V+ADs}CPzh?g=;11)-{}m#yP0N`}rjriJv47J>LN4 zs{@o;mdSx0xNS<(e}EP;9EdYUnd zaam>)t$oBEn_e%^ny?3YAOi6dm`PK|Q8U@lQQc#O6I_ex0E^&Fq1^k25euqOHI@v{ zv+{!UKUqO2Lq3zgFa=@6P?ITEL>B{y?FZr3ZtL!IGy9zNuutpIYh^4pbh$RnDQ%5}*X;vw2$;n}xngB3-@K_; z@I1{2lpI0sV4wPd`g++Km9iIK9`N8EFRy<|SS5}~S&W{k!%L)8Gg7n*)P{MSoldYk zpTbP$gh(_&?lr4%LS1lq$M!DMMjL46e2Yv*GcRQfp)(o9szU~dC$fY0OU%4Xuc9L- zY<{N5(6VK#eIz@Pa%2-1S?b{=)-2Z@JFZcu!PjBavSP>#Fqwr|0YhIe1_$A=+4qJy zSGsnY_3~4Zk7{)1yWwqL{JgP{hl^G@$;9SPVD0kOUPGEf$;XaT@X8aHH#(rAj|ygB zLNY8Ukyw}ApK`WJr?%}b#6V6-69YTLwccYp?k;$(%3=o@b;wbc zXKYdIYR#^HK;)ejK#)=IYt(mB{siemavJztnKqD^sJ8e+z8InWXZSGdE8rd0Y}UlQ z#9MvM;TX*8X0r+Wc1>Z#OwDM)4!}m_gIiLsIo@%#MD>`ITT`*Ro|bG zq(th#FHIuFK+#n2LFaZ+k_w8b>)W!ePU{W6x%e}ErckLKrf#|;n_PYIwO9GCHIw#@ z37<777uMu+stj%2#l&RTl2W}+V|}B2+Kum$%i((4S|`fu%r9KBZO#g=`1nnh_8}`e zUW@!A^}>-=*KJvK-LB-?Ch(FOMZ&yHwqJFVm))PcFC!wEY-rVM_9yq)6cF6g6~yIF zs4C1e!|&-JL|(huLilCeFIgnq!TDuRQR95PqCOUFZGSN8V1+AB(9@X?Lb_6)<)y_k z>WGa6FS}8Ck)MzVqRqb_MwdcHEH0ll(|*4Ts(_byIR)=(aXC{8tMk#INbv@vLOM7} zt1qdhu7^ubz0yr!b884sbG3frkVJ6FkK2OPAcmD9(|(vfP#5aQCE->jFf7r zJSyJ{hBBk9i{+$*I>6J@cy%#dWn9ziH8qYdaE<}Pf$$q>XM}IdgM?l=btc^w*NmB2 zO#He?pW#sCRx$QQtZuneC`t6kD^n#;xK={H90s0y7eijx9de~1RyfzsF{K|@nGTc3 z$%KEI;Aj)}+oZut_0uo%FZEyNT!?33Z8LDs3`{jy?HzyH0K{ZaAor;<0H@HgU=XZe6BVz(vZQ`q==!$B#%RA-=!9 zrae`rOEnyQ93Lo54OT4VV3-zkvW8^Do*NAh zQiop9rAqKm2}wjXqYYW??P8S{Ng3qlH!P! zm_5W<>A}d1lCrQC>J=;Lp**CmuSUJieV_ynqdrAj7q`)}+c+R6*{iPgv))y2Af-w* zi-tT2HS9ZDpj7wr8gGJ{S`emJ7{T?iVl%;J*eq@EEcf(*Gma^92s`;EyT~sTp&Bu3 zINo<~*1^eIPJseIt(xTWd*73w!Ml%m5D0mJH7a#^cJ@%nr2&D-tz4>lK%2Y}prvsu zwX{<1Xz=cLt_JdyOltjWHtEAo8{X$`jZXG83ibdWXaf_>%R|2pe$_zgKD2t~P zP=OP)wjR>$7KCbuf%shw3s>VR>vf%O^-JYAkM|%@QQTcHm=R|+_ESc^r(OY6X8)1; zL`VQ%a+9A`zZ)|SuW&nJxnh*mOTIUsfrR+Z*6xx?L92J23%qj0Vi(1IAr`H?$i%PU z()|_V3S18iq!`L##8<42sO{VeK4GP8@A)09J@gzVB%glKD%XG^mu=qDc)@1E1mD%u z$WHq7fS(7pd)7p?pp{*h89IqSTuUZRO(7J|_r=L)hCSClMk%h1%x0!uS2Elqtm>?3 z#`moegHqtR=v1m$ku~6eF(b83*}%wMlGIQfcl_F(@mjrDP@UKQ3!lox zqd{@BIK)(Ji%1iipGv!M&>67&;MFO1e|$yd=aj4fYHDCb8(1l7q6@J=qN)ttp@oEA z$T(Ht;&sMgP}f5IoYRp?YfX$a*#^PO;CzxnngsG%?w{GT{re-~qbyUFYIy&u02r-6%u#_)`sz5$%CQ*l-$ z@k1yK3YcWc3bhoy-ucAvCCP5lFoRvBP}&0o%tz*7`hE$7&Xhe0a}W4au@Gs!P9F#k zt$*H=bC7fU?!8%-_(KqkgYRfMScX7x9$X6r{XjjFeuEM^tJp}aATq&!GOy#^Jt1m%UigWp|=PJ8RGx<9(F}Z>Lv=|FP z=^`7bXmXYcM(5ip0WI2ugO(b^hLs{*tu^XtoBqZEJS8)lSRKNGp~1}FIDKSGnPk5a ziEUsv#M3b&DO3-_R+*c4p)cT_gc~JL^x`Z@Xq$(9}K)A$B zRjLweWx&}Yql;3vfT0=VLkwYpay{fjCe<_}t>d}O@=0Gb$bnQUjIy99XYkPkXIK%5 z>cy>41&22oR*+yG`ed+1KP1qwh|^zYlUzt~zh(WkfT7_G$oWS*NuiqAna#?4{0R0$ z-iVr+i3j>YW3SqT-@$$=e|_O?tRJAh6jX!Sy+31KYhRdU!%Kc|_9t}t37q3qy>(H= zf!NIc73)l#Xu?d4FGoj#vS=8OT%gK}cu*BBQyRWhbSd^4bg`^ID4Zs4jZ*y6JEiSG zx(r?f<)FAEj|DXR(;*SKU>*H3IRU4rrdcv>A5)nstcoN^Q2QjCz0VKgo27z{aG7gF zvEYL*GdE!y7>dih6!b?Y*Re>yxl5odCG^aeq?Ul%#*bXnn9wBX4N^9D@AIkLbh*`V zLFM}5Q8~M~6OHYt^HC8o28q!*QzM6=PM=i)9lAkiOY$r+IzJ#1o%|q9`g?SO%JJ_5 z=J3Md?AWTkbt~F!FI*=#a8~vE7jISQauTKkR$3czIZO+zYJ8fOEWu3^I1IVG2GZ-g zM+5{Y&<9mR!+x!(1T|{7FCBO}j1`WkKxltjkC2%V7HgmLaA?^_6_l5Jsn-o!~d1hpR#qW7lX~zC){+CXw;(dW( zcG+mBSe&7i$AZ$~OcbZg@|;m$6S)v#(VNL3et4)^%i;MHl!p?_s77IS0l9)0XBuD! z|?k?JYPg-?n?F=5cn8R#2xq`|<5=b)EwA_q&UzcZcsn++;KQc__iDfnoq zAp1O>2wo8^yx9N~91X={a21rZ8$D7WkB_VXPThT<{Cb{_rn$Itg?KHRr&FDzB*7Ya zuw1-g%n0E0B~A-^n2W8Tp2Ud~s~DD^11ug)A!A=*AtqJu5|(S`J{Eu>$Q~((p`(`o z%oTb5^7dF3OEt$%vAQje0oy#uv9}Uq@nmts?~@mW0O=^3d{=4?UvD;vMhX#)-&sg{ zdBj?B=_sP4Hf1xDFzFOEb@#0`0(NHwP$M|KD@_&`#=2g;kNkey?8GEcl*PK^Cj`W z1^n;w@xdSP6yDS8#iQfVWP0$&x%k~r7k*n`_~*gzcfQo?-vgQXa8UpL?~4TgM>Vz@ z$@|wGh9B5{lU*wvoRyOMr+hrV0DycFdZG*T!!1J=A1y z3UT6&8?JXDD!phk9ghcBYB#8l_i|~-ZX8&B`E11;Tm`I2e4x0A4bn=)2gm z*hPyb$6=H9-+s>|7HaBxsEEVUgkpEZt9kt=dfMQUA^ui89dF`uJc@AqhHG=1&%EQk z{w%g9#`SP?P|Qm;^sJqcAvZq!`1S+>7s-im)-;3yOIQucr_Hgxoz4rII zrR4a#vTnN?a7eN^focq!jpS!?#u=`msR|z?f2eA#RHNZ%^2#||OE&Qj1i;?u`A9q= z_qCtV3iz|J2b>vufFDYLhwCi6l1w}LCIMeuJM;V!h7@X9zva8H(}i=PkOt?&jVc!g zQHE#+J8L8tw!8L4m5(+F(;LSTAR#0K+e9j~H4GsI04Zhu&j=W8clM2T?_oX%z?%-6 zGCyt2_I1>~)6{v1&?e2UcIJ5Xggj2K=R|;T+@9<~Sf>>oi7&3>Bfzs+JQn@!KP6)Y z_YHOY<@U94Y5%Eq6#;L@SGC{MwdF5$?J2|19Lx#fn6u*=84$iiX0JFsGu==}HAWSM}8QR&O-@>8kZ~HNGhLLp0u7 zz47Yc*XoS5ivL?>wx_-A&h}dJru+Kkdb^vv-4Nmd7`0qT6qBx?Q(%J(;JYmD^fOTj zb=t%$&y>wQT%X}Dh@za2x^w8_;z^H4uaPIps~F7M_Pwetb;(C@wl z{1|oZhf*a&`E9^+{1E!Wpz}lB-C@M9sjugvEl+#oGAYP1Y$XC zz>>^{gs3rPOSEH3JU0|;uS*KkpD`MFpTRg&2fETru^HpkHI-WNPOp|^Vk&+{gfWn$vggYu#$ooL|ad-(D5SVp>CXu z6?9~zhu#tjagjNV@{y3gYDJy+OZiiy z2dLQo9t_OsZ$RiUN!;AWly(xHa8z-J!B_++y?!TI4+%`u%?_G{xv2K9mQG z(QSt2*O>wvLx=yP4u`-2aJJ{>kJ`#lAWMb4sYe1B0T4xHl2R6>oB=pe$jBPVY;KJ!fn1lV8mO_M zyL!r#;Pbl9@SvwDI*@6^F`m*Gp&Jc$ep`zK{{A~Gw~3Yb!x0GV&CkWo^G{=UoM62IgMM9dVf76)+bgeV^2p1x9EHvYjIU zi?0@_3n2s~Kd3)bZ<8q5tmudm)RvT7!n{a7+b;q;Bu5l|7(^4_nI9u{{fu0m0;9$_ z+i9RZ3PAhOdoc)h4w`Drfoz^|AP53l!xtkwR44E={R}^&SK8-~Iy%8RtjL-3Ib$Fz zEYE5-GlGHK<>cZhNl*flvVvGssGYJ}B@^?e*bc@ZjaEo)l~=zRoBVTrk!@qd~eYtSsn>DS>>#@>|g zeihR#Ks@TzMsr;gHcc7@JuG!Jp+Fg&qa47h9<0fTxm4gn$z#Dody*%Ys$u!7RyUgw zVLH`^wF`CbF95`Le>UTJ0gm@ZVZiZm6NjO_{-*nU|K+V@d(cmI)8llKlZxjo12=5YruEO!{60vr%2z^N zsp{kqbn#uOyW8GO!0BFGJTh|vGulh@bIF8^hV<3A#Ef~6fdf=a>Jr5s$%$VM`h8x0 zuSTX^(oT^C8tSQRUn4Lzx7L68xV!$m`*GvdUiU@!4P5T_7mwX9HeT6Zc!dyr5HUFU0jY!qd$xIfOqpSyTt?5SO=P!sh`8WOkk3l{Hci-JF zjRclB1WhBjo}zn^=;>84RqkMuG#@~RLh@c1k?4)x^-jgi1i7D-dMaf;$VO9vsxwlW zQk7`)Tn7*%q+c#Qy?yneEP_bs0 z6+5&pb5!7uq$^cXQUw9HuTS8RAalogf-pM1m@d^u6?sn$l_1o0cnGEg2d%=Al-p-X zr8w^K+ym22f19BPe8HoLQj_sl(Emu>1xu0sPHxoS(`bKaA%I;`(uc~`6@bx90Rtw7 z;)6==mAbTFrmaou_D8w-CZ8|N_GC&rAUu#RD@$Vcc{y!mFEFp-WKXcx78^f@Mr34j z@m_x#w%!}X>5pb4?`K$&-3U#dRN%>tdVCu15e`vSeR@?bZEOd3_Gpf^57V*02{b~= zJOrRu&1WcZAug-?=J{H(|LV>5%a`3w^8C&A77$%t6WX9$;R+*RKZU%)x{hSw&zz^y zt6y)XF4azTzJ^>hRetgyQR}}$Bs^w0?bj}RvBX?;;WXMV^bP;1QDlj@IvK>D*XP3& zX_C0^F1YAkkh;H^bJP_!Eb_!A1IQ=yr*@xEj3c^G@Od%Hq^|xZhy&E)it<(XHfRj#<->GPvXuwucF^(8!bd<7 znx^>s`($}3`Tl#|c|BQlpUlX~9TLEPg0u;k z+i%&V04Ja1h7c3f$6!SRvfkrsve%juqOfEt11w){?+FTe0x2ld!NT}_GKO#|n9KsE zPabEJg*Vwr_w)D`M_;v~nmrCnhy39~bLsoP|51DP_z75(#ZUN8ed&k4FY5fr6*%%* ziT}}6>lS?3a@SsC97N=dpc=rd3$r8vGcGPw%>f~uF5?-pdbQJzL361p6o1y1mz+6R zc|quKfLL8z0;Y-oL^%|_JVbIut9{-uxZ)Xnp*B046T#sLsgdkOMDs7@C(rYf(%JzV z;e60rLysf>EZEVL%9VWV)*=FGR=n=FnWB*5{h6qNU$M?nV`wKFlSVi2HgNN zh263{BglU0e5wc?;CAsd1DN-$RB%t7C_;H^sXp$Zl;?cMa->q|c&~ndDZXnT8<4>k z`NTYmWaHkHo98{AVNNSOp$Fm6lGH0LFR8y^(YAeFR_l=`TO5xiuq2~KLrn&SMs56G z6AK5t33an3tFy-R8pG*pu}YsK5?J*!AonwmB??F|6DZAXF=s& z^pY8_0e!*hpi2l4|F;jf=MX+{RLFTf7tt}4bOq?>O3cIx`F+lZsKF8QRYqH^lsTCk z`emsg&56!sgK8hDQdPRT>LAatdp@kNZ3iw~FmY>+;aXPhy7=ygCtB~sEY5EB)iPep z4N|mkrQ>TAal3|Js44YU?IC)t{GuJ@#jM?#hp+;2U9ZfH3NVphqXl&PfV#(W=~8W>e$jse6Asy@Wu;czDe_I$D<*x45A;&B7l9Dk!ifNlvBVH7hPsly zhCsgp3vU@WcZf1DLOxl6MH??B6rW1XlpQw6B0vi#{L`t=RSYsAWc z`Sx@r0iG{8FqIPB?2J2O~FU%g2HF3h?ZHFC5CH4UYFn3deQHk%N z`j-bH01htT>;OS+k|@sdH7ZPAb`}vLZXWapfOG;_SvxJuqL-&K*9GeNzvp2rrdoQ? z4IFP1v2^F`JK+$BLLmf-p^x%aaFb~j)-_r9P`PPcXK{Z;mI7q^cUu=`T2^Q)Wi1s< znTphkPy*0|IP8z&+4j+=hcMG$$5HOc2Id_8awmavlw z?+{{&4REsMqUL09b(~Ym7j^b!_%dYQ&w#~3OvuaA1(J{C8pYgh1 z@VOtvPn)u3y+2UKEPIyEniQxg_+oV+;qTwS@R~#KK|2B`GfNK+qAa_(Ji9V-+pdj+ zMs}S6pZ5N}#kAwCdGPe9G`$~vdL~mz^Ynx0Eo&-j*4b*UY5+jv2s1-`!8S0RC{YYAIKRW;=(=fP9nC7 zs|hgxQ*`m0;S6STF{`W(!ZT7s(Uc5RhKYVw0zX1Y(I-81wqK`{X`Vtfnd43Y#l-~T zmd{KA%SW=~S9DIE886K*+=zjhl_x#3|F*IWCK4(uZ88g}yaJ*VJGB5#uBm5c3f1xp zGf-6Qf)~NS+Xz}yZ`P9P;0AB%DYA{=fTtB$SKT&TVBkY{ImxG)O3sLUDu6uLLGd1d#c%v?uvv8SWZ!i^xrKNGM9AI(9?mI_4fG9- z>_E>tdp;NF*AY^f?~2$51N8#iHxkg1N@w6J3gHD@;No}nHmnZ@W&;%PqmVbiorT?! zf@}Cax+eBTB8}sG;MCy)>4znka*Dv*R;M004|pb1DL}PAqg*qAw6*sD1`>)Ks%aQ4 zoB=ho6*ATGs#prc4?QCH5@5L_DfCV}VSPH=TMtmY|2AuRd2dvDyvEZ`SBg z*QFDI-+%3*u54J)RM0eK3$Q(KVPmYq0&#f5#3X&F%E-ctRsKuRSK*vNV1s%FY8D%% z^mPJi-yRjwtcWF4rI!Y%o0OMERUsM42CKKo|0?cRvTpS?BasQtv9tZ^yS=2-ec9dX zCVM|_>?XV0Z}xQ6t1}^N42ym?NY2Nlkp4?q=>W9Fkf3Zl$;RT2>dW3rNVo|qVPZf- z=!qdxQV?R2&@m)nLUG7~r_28*HeHBpj!SDBFt^8?OC|yCmad{urMMVolaq{ie>x~U zV*RJ?*JzQCSJzErVNn~dTxIoXvaIfxKC zTJ#SANevg^SW)g0tBta(bq9d_gKGgtYGJ+tMmE#A`Lr5T|BHg@RWZWr;D0q-QU_Ho z9QxQ~;NrKOTYS;9H}e0NO2CC|j#Sq~27HWUZXa8xdZ;FUNTTVXPTF^gkUPvw9~!zD*y)R3alY)qeHqwFk&3PI}}9YQD@j$~53Cp|Ik zqb&JwTRdrEVUp(eCzEv4$G<<^#%$9Vql4h1S{tT7L=?`%H_LiS4I9ywX2xTv<47K0 zn~y$OYiBor9v>8oY~*_V!)&s`%EP_E7Pac~QFe6+Z(}uQImsbI0Vgw|`%O0Uid}j4 z9yV;S*gcsCe(n?h9{d%Nxol8D8c3Rrq3hcA2`dNB!lusnuhl4Grh{{^`hodV_f+TV z%xBG5Ne}~Cqd?43*d~@ypCV56%z%X!Z4^A%7B^)KlxeCu@yvoj;FJ=T*lyOyFWx6;GAZ%7n-X_+nLqcR(jlRgxA@#rLFI}@Aty*R^|zX5C1mUeV% z@buEg`qe5mN&B5YeZ-DL^2H7eSJrIwE~5;;*mbYTyKs_eL+!(r7?mK7h# zkGA&V_J3d`E6_0JF8lrB38F6~B}ccKze7athugWtXUit0k-0T#?^~xA{#vpA@!1g{7pP9(pW6CFghA>eOnH?Oi`v_ELa&OX0vEsvk7yGQ zGBF|?e)L2aWeW1&U}9kkBk4B7bRbU~$!?hKV>%_qn3sFSw&-&$*_Euh$@aM$QY`^) zn$M)dleU{cj242rr|_FH2IR|}+9={YZ?WNwT}kQMzP&;!FO8m!vM4gAFLIojlFO25 zWf_l2-%``&0t-mS23nCM6KppuVP_Q|AJ|ey*240bRk=*LHc5Rh=WKhFSkw0Ia=?>Z zNGuF~wK_Ocs(Ms&gh$VWysHS^d+J8GnZc)k0@Hb%Ow}hQt=eBUwxG|fN0YYL9iK(m zty!oyD`B-at7G`j?1_QrkF_1f9YH@s`Gz<0)3zFQoo*LT)(S0cbvQ?UnV;d`qtdLE zKA$Jgccoa;L1-QNT;f?&NvmxS%oB@iYgyWTR3V5L@L!yhU5!@TO_O2_5mm^SkSAPS zW@$lxETssL#_WDR5zLUsB2Q%nSYm1rmWPtI7+nI`X6gInd#ngI5{ESxJ$%pV%p|p( zYJuu(#3}f`m!&RI+n}1JpVQ%ZfU;W9WJ`ma62q(lC(|hpv*~Hkx65;C83vjONDQ(B zeNuoZ(WVJBJRX3@%1JhTt%|{HQ#N9A8Ogq>hMnSQ1l6pmuZzpkX4vx(y${6=4q;Ey z@eqDlu7_GGgALXy0A^U?k`d~K<%HtK5pmqwP}5BbEA)X8*3q&2B&eJ}23^;)=6m|& zz@iDdZs;+Rgys>XH!kWm+1)$@0tGib(d`tniD-U3B3M~^khr8IMWI{nDb)G|nWM9Z z;756ATD*kvjWCT`y*UDH4wTuf%`E}R&ct4x#XE!RvEUaWo7xPG)EidniOSB&dRfw= zO_?pG1s!m4bn{6fSx;H?H_gf2atO7a?eAh@3NYk?bh-}L)<*ckgjyAf4ptYM%bw+t zS=dNuOnic8uNjuNPWD&$ZBLcn9yn~jDiCy@}8Y%$oj8?4I&xrR0D8Yq#kew1yQbF^XoGHIWW1(m-NT(yX5)) z-u|0zvej)^71W@lAEm3p2x}1T(At9@mCushjO@IJP%ZwDV4sh`k!bNaL#${{y;=&U z0|9HZQ-4rZ`#;$G_XlA?gZWUHJ5loMrbEtA*?Zi?;5`8mp1&S$QPP%v0hi(>YT~=nqY1hSbi?;7=o3eWN0wL~M$@n_651)E{e2d~AChme<$d zW2RB~io`*2NlW31jlwdt11hSLAblvr4qRAsSp1d`1}Rnq$wmwNyHpqCZFaQyQ+ko^ zVv>f%H>y_O;`W$A2+Ku64MigWZC+w|cOVa9+Kd!5=(i>r^0mqnNI%P~;ZZR#KNU@( zpXw%%KY13(16Jf)7KALV_#JayK8FKKM2=`amclp^f+RBAR|!?arotDX1H!N5b&2j8 zu$#rCpG~MrxBz#VFDSO4e#_5b;B8^G36nFUnRy#^o?mJSvF zh3t>w$K^s=_VOJ01p)VBI4nj@4%V8|-!PN#W0?&3F?ruU*1?dERi#t#C4ucKEopz5 zQUnT#ssTwr@W*5Lu|$7EM&=k>(i@JMkVmK2&`Ky5=RJFW@YGK}y%)$kE&ZjO>?TGJ z#0}zWJcG2>fEWDk#(LA05?g_11FfnK6Irq0xvI8AVsE=I5%8RQNpx|DN9(@OJl7h}h*Rdz~H&J|g+e z@*Mmq2F8p`yS3CZ_8qY|N7fr{K*f)nP&avy5ng6B{LJwegh#-E!it;|4Y(D5Z8Yu+ z%4DYW?dJEFFxO7mtnFt1?I^7iM6}42_C79@?}<*klrv+H6uegf}{;1 zmB|z77pq;s(f|q3Rb^Kg=A&9FWmy3g<#?zS7+6Hv)Fu|M#UDTX;F$g}0uTWEK0gq> zh<};8LJyDllI7b(TM;qcV^98^fRl*8g$_2Rhxif{q8pfZVYVbahxmLlT?&WN^Wx&8 zJ~%nVvdQ?2LVJCGZ)5wFkYqqV!;?zXDcTK`smWDw4(XAL(ZcyC2j`(g+&Gj6JHz)S$85+v|)o9ZWCmX!7>$fa1I#eqj>p= znl3X@cMDL|vd{J_P0VR5l|fP5$xkhOs~v5!IAiJJmDGm04MP4Td3R)s@j#&#=_*8VRH= zR3JeA=5M+gWkxB0%KSHQ7PPjeoUu0~ADI357JF09wK*``YwVViwqY4hSaK=AaoN3k zPG^EPg;(&vluMcldbyw2{Kcp$6O?#*BIZe{pu~+txu6c~jyW5fp~h1lJf3lF8h>=#2Q#6X0iF=wHh&7YBt}4ww@iO{yFe)ACI= zO!E=!^%FVJf;)nl7>@AN`7jDib<;Rd6;cuuz%0{gULJ!={MU1g-TV9RsA|&@#x)kN z3nz&E5{JtC!dbK5FiHN?nyilAt$#UmO*1HK}!xt#9%mNiD#T1Xmk^_q9g?cWUre266I#J-fex42Tlbm#>`i;fn2*47PBX*oKIij8Px?{)* zW#02TZ;|K`$jX=3^((c-UqZu5&I-268&#(B?E`I*6o08<#$n7FHm9Z2@VXIrHubWa z=tNuuK>q8_Y#fJ4ddGw)2dt8WsLW9{ZW@&nz_a>TVxY|^3Y^IMSjjJPg@pjEzw#aA zn`yt#-bXk}$k#^g56t4jE*VHKS|m8sfZKip7>6hEZbYQ8*`LS6q~mANOwsa|JjVK# z>WVxRpg6=+b12|(Sb5J;%IYYCSusD0J+rtoOD!m~(6&!g^ppB!E)_Vdq8S<_R~ofOoT zn1{PWdeF-!y>mgQAn#GrS=k$enp&0xlOLRAS8lXa$7*Nc#rNsLZ%Ydg4}Qm_gI^Xa zHyit}(OKj<5b+7TQ`RwXM=)O?`yyX>v2#QNLzD=|u%$fkr$MTMqrEqz2!AU&bl|xf zz;~YtA!70rx}lH;nzd7$IcQ&j5Iw_&iz%4!xw^~QKF>>WcP(5&4M8DNpC2EK?S@Pu zrxc~w8x*4qc~?lk7uf>&oin#R+jj&ZO1buYxa#n}g=F~=6|oTiSy*sr<0qSe^iFLq zP;R--$YhR!^{0CBeu8rM2bzRmKJQ$ZdSI%y@$?-c!!Pp?=Zn5QP&&7KuU z$33&OUS%?=`|)!^7XK%v!nR{X$>ox&ax~S*Je%*dn5Ki*@&&jbpAT!gFXqOqzP(jf z`56JA#4qbxV5wpEXD45hol+rj>R7=Xx>|T*jbrid*x<30I=^V;iibPKcN!%t?Ia{U z(*;CEmUFs}ot8HJDs|qZ_hqw09%!kd8VgBN zJyf6npr&e5lWTiqq;@{aYZoY&9x1%hb9!VoLn^IOGl|u}TGUVet$OygUL%-uwn2GO zXQYzc%}#)qha<+)KB|X~FUq>@i?V*ha_X|2g>NtC_n%Ys8htKpH#%huhjO||&BWLv zAR$SO{2*1?R^&6%q$Tc#Y*G)_;Ko;h8PN;Z8Twfhk$!UCn--I2O^i&T*-?8lyI3y0 z!}5^4xKMCn#mjOEJ~>Luyhm2FtPLSIC*WqzQtB~NX9T-@zVW8}eEXNAv)$c=)Fiw6 zuU~J!*-HeUHfWm8pu~#$Dl``A0&4J)4mmN)Vfj3nHVxvR0h)r>SQE5Ob!uFgb;4P@ zq9kPrOyS&(3Jp9hH6n=1`$@{1{W`Te7Oh~uG;uHDNq~ejF&*YgPE}>jt-r$M_ z6_R2eZ^k`vJOalg=$EQXK^TRqbX?{zF+Fk<+auE>+hB(j4XZB=b!W)g3dlmv{w5zA zE=A}nL+^dlonQyE9@W5ttzmO96F@I0V~YW+f@-AFou_olsps#+Am25USJ_F5Iss`H zKng-YQ0p+WsiDIq@@IcT?x>FCL$N{0v(1W6M@k(j_DRfJXOq?PgN)OJkL|_ym#2{N zPxG`qx*BDpvU!v(LNU&A(Udd-;~iX5{-@u}Vn^K2qNaP!I7frxM9AeMaeT#fIb0M- zBR(1z#X`TBF3?vCSPZ*dm|hk!!FW0$4w~JGuotWj*NA2NuecR;a?O$2VBA9Vp_Q8p zeVL08pW;o4e|eXsru;NPXoRzgX7{SNyu9nnNft`#6pR11E;9m(8Q#hAg=xdG)TEaZ z(wO|XZs|@~;!p6_O#7p(EQ8cgo-oC#f`=ipR}h?w?0W`u#uoJ$7vKTSnTA_G>P0rS zY1>hDl8?{|ArG;k2ugvEL{3mnW$0rqa2uQ7oXXvR!bu(!dXg#w(G}yX1yPU&P1TvE zAZ8-5!-EZK;{RfYheqesG6JHEJWARf>=`t&Hc%UngVhZ2^d!uV0P?aq*wcx^-fMLe zXP_q&O9BXmVO1PORm0E?eMS#Sq^S$)ssxS@6Ow{%0&ynQTRnp00I0*QL55eI#+RJ| ztvV2o_+dV%Jg>1@0F!+91{70)wL7JUVQ`*iq4Wxn1*mX7emxO;@tG6iF+Pb5CvC9W z_ps!3rj9?$r_==pym+Ssv!~MT3)qHE(U5h%CK}W&95i3l39)9c0urIR>u@sL@U@^I z=y{z2#NsPuYD!qHKod2Loe@a9Vkq9E&-^PpL|)<&rI?Q8#FRO zb>I+MkmZLLB%!)1bzMF2@wHnze;PLRMW`WEiFu?*RU&) z@Q1$qLDuGpE$FMU4Hl%I%wCXc8pAqG+*pD=p)mzcaFVdIkCG!wXKi8I};do3B*@HC{GUBR z_G$8i(OrDF{XhR7|1Zd)VjkHmljZ5nFbna1*D7yyA(@HKvNsU^%kfCC1e0eU1n+&K z%c7Ff3Sx8=Od&D{Gm&DZ*b1iPWm-;O(MZ>4O>iEu@~BGX0Zj2IODB-Tyy*4LCn&CB zjRqz#Na=cz9aEVzsTR>(zQw9rEc$7BB^KE`lj4EutwaZ@Bt1zXQGoTuD9ieTjN0=F z$WH`oU^UlsF!F>DYRDEKzCuw)ev4wq#xbVKnM%ci>K5CTN*)TU5du;IKx9K&zF;%d zaxF?lE3%Dla@NmSiB)#Zs5NO~V4mn9m^^K%=2g=QwY(A^R9B!@=C=<`*eGaom+gs0 zkzNY9z^2tYELl3v>uMEnyais1Bd&q)NK)EoL3-^ZgV3KRsxAb3^z4}+xr}F4S1&b` zKSd)VtKs085_SKjNi8Irinh1iv|4aFfxJq)U~O8g!$~yxwcu!GX&oKCrZq-6+%#LN z2ken`fKbIkF=G04mfV*TB(ckisDQq)nm|O1iobNoF#*eS2rUmB=T*S+UBH-i@Gs*y zUjlVWAab1bX8_7Sd@3iUxk_hLMYD}?+enrgeC&FICFVew@V0y`@WYVMqE8NDdZh`7 zeP(UOjxCpE%^CY;>GAltlCid)J+|y*zNPCu^F*~*&AX{Hht<%+ts%XY%eDJe2uioHCF*$TCH70+AeDg~IGZw;G15p5t~(8{fWkL}bQkyK51@vRRA z0bY@ayo?anbcqruHfX~5wbjC774Zm}o+3Q5VdwF2Ay=amm2IdO1{%7epqNE4q7SczFC>uAc)mo$`-#8H{g!yRv05y#eWXKPMs|8#9 zo@lI;abF~Y=%>8elBqjj9TYprn4c2A2AyUed8De0Q!T9^RqVCoIqQ!+TeR+$8q+x| zz0!GLbUn?$#tXig6cP?j8;~^v>OPCR34+bZmLoW=z4OVL*4fE6_E`g%7oB@Zo*`<&JDRlNu z&ml{{+#7Ig*o$S`!KT}jmnml8<6j7J_*#sZmsE`Ai<<>Uez^xW?N&Z@{g0gV237*Ks+H`X_j-bN`t#OedF#X$ zHs{iUjx=GaDa4P?Rqbyx9sL|q4I$FS|A-6?+T6|YdO&u%UOF0MN5!mbb z?9Sn+t9)TC=UeUIYSU2ELahq0r89d`5rBO21Bt-0^g;SVw<+ie8Q7k;Qh`8%vcHIe1!;TMI`Esou37y#xNPe41`->Z3vM?b=HN~V#T3*cAzd>F0KB9(#=!xg zAZhFfQfj3o%EJu_X8=3)2q~x11(}aOlVP%>A}Iy?21$@6g4fBEmTpm*h9Wn)kbJ0w zu|NsRnikWCPcf$r_|ekK#5XSswhDMUK^3mrfx6TN>EEUY31Hj|jaMkFI+zz5SAA3SI}LqcqUuxrfu|M} zw4|o-t9F7OjSWnOS4^lP(1)o+1HwkqDtt#k{0`Kk^7XLjpASg>{!Sl|?*wV17ft=S z>K!;>);)bey{j30M+J)EMKc}tMQ8M*rYDF!$ay!Rr%pD7{MKxg`XjN@8gM_2gsoL9 zPE52UYmivVBchkdEnnO*2Z4)GVck&U+2QV5T|uafCRiActzlGzJ|+ciy|?HSKKwBl<)f z8n^vcI*v3hv#Hm4HjOmC%u>Pld%eG<#}yy#`lGz1$B~cv=`{U0&o14sI`VmJH3%2H z`2{-ak1ZgYLqt$)=CXNZpNeAar6+TCJ2hWaz@9SPn=Un=Sby2HIaYbsn=&W9kFsj( zogNJ~m>$Ju&D*1xkOHU9{VwNe4J10JgWzU~SNT}#Y8;{wa<-wqy+u^^4P|ixeIo-E zK?LWqfeT$r8Zz%41UU$U$Qp_-Bs7QUTHYUc!n zRjf#zj+e^l_)@yxCJ&qzZ?ttzH(6MIWVr3W{q1iFjhLu92J~Vdf&>rc+zh&_eh)F& zN?baVp%mXq-~%3PB=f&hHZ7@lF3Iy7e7cKsvF*J{Q9?Y<349LOCIt)yI0V5HvX_v} za=2RhUPR09Tlwd#|AiOYQl_KdX=Yz^i7zo9YLJfeWPE-kpdc?bOKV5hFr`GMcq(zT zCcEQIhzfEdI_-?;?e&BLti+#*;$8>1M+0PBJ}0Y$48j+9=O_4GMeZroY9(^y`8z&g6qyn6>ax*O?8dZODiT5jCC zyV_X3yK2qo;j-xH!AhhfBM|HVeNG-W9^QY@xOZ>K?r5cIMjF_>qm{)3S zy1xn?-4Ay3x+tf!0RNzI_uiex{fGCgUYGAeuMe*S`PJpd@|_2bhj;9SE-zK}6a@Y1 zO5@)BhmF-$2V_fC*bs!h=xO!ds`$SLR!>X!t9CI6e6hNfhxZx}?(;boIW zEmE5Mi6oBOSlPrVvL4w57`Cx?li}gKnp>*XBbNB<8mA8RGxq-kMhU#Ub6230ee9Mi zz+o9?E^=_H@sZljwlFVEGi+ds)>G@K8fAck4clyG`mOwME^?Ofmrw(rQ= zOMQAv@p-$wVw{D*^EF)%q|d`2eA^mI9ktAa>bw%J)!jp7KUMzU7kCIOT->tSL8+)9G-~ zggC$;z};-j}Ok{|cBUjF@l^L}#`(u_l8 zmY1^Wp|OeTkFGc7lHBlwyw0&s zT^~|eN^kSGtL>z-y_HZ^k`)X=HNYnCel_9C%gg5FDo%6n&7$~f0l!*US%A6GdJwNR zItwfJ9xOc+|J0q%$Y;DfKRLk@gUL1Z9Hr?Lbb!#~9;m(ALQ?9=Xn2`nlXZtxN%lH; zn)iNGVe@5E0Zo}h&FuImxG#si-F~1F|L1FGyycQHDOyB1(F6g;kLIfqr1ZYWD?5i&7O; z&MDYHzcUUDG|T2S53R;V`?LmmDLyIZ$cA~UiVuPeQ$>3sA4@Lp5N+&Hn(Dq|^d|CE zl^{{|!+BK4A8nLg@W}aW3zbVLr@YD#&Bh zS%;jIJ!sw&#Oy9G(t~r13t527D-vC|L>FMyr_5rehxyP}ue>>w{geiSD^X@^SB+e@ zivbj+6cqk|*{0OyRs!4%>+UqS3^|(~nlv{hDGabcqtJjM!k@RVW8A2(*j0M=wR=j_ zn14s*OulA6<&ZbpO*P%nUNV4KJL#QlXJ!Cvbt^gsxbY3b%*fD4!oBuI5eGJ?;33O#O1HMseNZg z{;tl@u>u=mDlPa*_Q6om#zfJ+IZaPqsSJ4EwO($wH+S~8_qyK&QORB8pFkP@22YWJ z0oz+oaAp$RF=}w9`LOv=ZPT=0u|3G^f#r_zd;EBR8{50~#Q-M?G+y8A|K z?N>9l2BmL^(bN8S^}0<~qs*SW5R0ry-xh(gz)cAJwc~g+RrB6 z{tW$y{r>M$^shZdr~idd(T_7uk%xgH&SoAxs8NH$eqxsAdv}mm(uRwBD|Z|B?%c7g z7IzSL|Mv8!Pu8HXc~I)DVqX~J}Y-C)&>1Mu)3l7tUPEe-Ld;wUXEyUp`Q(JS#n)VjpgNs zRzDA_;Jo22OZIcGv3iG__U<r$Ibp2Te}q-uKa+gJ|jj&+;&2V|dqdPZ*DiW^{H zI${{^78G{>0jtiVYuy5q>?Hf_nyr=__wTO=dTHb4gS!>u9(d}meAgF6StO_x`?ew|S>|7gZpy-LKxmSLR@|V%Z;V%f`xSe_s8E8e@``#oz*B$pan( zkDuJRUuloS#!{8OvNXG?VtiK~E)`giB8&>;sM%2 z7TMxvM+dCQfupmsB96}k`?g$Nj^4V~(Ft~Wr*Zd=U@n}av%Fe)!BAF?X$5pF4`dHA z;_c0#GEB!IsH}ox*BzTTx*NayEvN*$yd!`th{_#)h1`=}u2ezA@}2geVtG+}P!Vr$ z1{Ls^cQzMp!PS*jfiDiX51hmOdo!UD?D9@yW%a&bj_fX%mS>V#+o3-M8R^?!0Ug=m z<`8l=8X$CcX{oVt&somOeD`~>%T>Xq3&20H*|j@&XX1?=ClP~CHU7vJf7Sg2O5ck- zyPWHS5^|KdqE^6JK?P*YcSWhz*S({_(O-RwKai!C^=Fpr_LViC1Bux!C)OmiUH&RV z%mg<1t2XT41iC7}dOfRutJpMfFS#o=Zbg9T-?jpw7ynkZa}eL7zPQQmxnUY#vtiX_ zITTeAqRx6bf7y-+5`4`aTQNJf8wkXy+%X8Q`kEbcgLb}V$Ew+jP>fNC%lPYe49%3+ z+OrjY%GQICL6y5kx`LbTTR4d5Yj!RY!{qH@I0!22(D^Soc@&^~osC@P8@U?}iK;$- z6yI^vtqey`ebph1L~r@$F}zy;NZKpB88as*jp-C*`~nC85H_^Bvg9iy=U{h(T?(;i z6_hoO_w&Q+D_Mfk5Cn7!1oG83^WQYPEq|M&2lx|rUIwwjZ%Wh`iIr0jj9@Yc- z^<0SZI!cE{rkOruqmLhJ)Z2!v&OU|uXQx^33;-=Bk)x}%oXUqOOa_1Sx9I(o=-l3` z&JSRMQ`kG}%UfRIun*G@Q&p;swN%mb*v%I;PqYFiDOLoNbFG2xaeO|7Y}A-@3yiDS zQ(et{IRC5xwlpU(+^A5Y{COXfm|<}>_uZgKA?+G}FXz67*%HO{akKEV?&qv`KBY)U zIW4nmAExdEOFlQkOgp(iL-x{0+~i={aL}Ik|&V0oe~z(NzsL@hrOnq~uNH zPUXk7P}fDxv~9rW;D(jl3OChLfOfj)4^w$T&^ljBw_&SwBl$fsuElGZ{ILNLSz~j3 zFB%>sUvLAa5}zR*#Ula6(1g&&puky^^I^6Fig&^KOSYq#s$HYsh0Tb0J12R!WKk$y2K^aKbRqV4c9J$}|svO1_atLudxt_+J7RT~OZM?`Y!R zDRe<(nbF~QX2IXFt|*-=-b9b=d|S_l9Uw(p^f&nCd%|^xf31-_DmrS2XVOEyuNhWLeNr%%63#gRmLrgv=nv0_@ zJDX&Efm1z*c!Jcjn70@c)=(l@A!6<2!>l-;)+p1R69S`C9e=pJ_~CZFku2X`T2eWm zOcuKHQO&A|I?N$?{IZo)UOc$V6BO%G-cZe6e1MtGdFovtINI4ptVnv6w5~S#Vme0x z59(OS?dYUgPOrpua3oIA36|a17^V;^nH-)^1~By;ehcmnclGGx@4x5$FAK{{D|arN zpT^M9;RjaQd{~}z2bF`17HV|*M27j#_)NB-!kO97n$V*Z{fGGhZ#9aDb>0JE~pB*1hX5m^uk6609i zKvpyd$sgN?=&6pAT2w_aA)7+ln?f<>Y%;;idDI_d6B&&oMro#f>hdK9^JNn;Eo=&z z&}x|}L}sOoERg>>5p7|jKx)+|Srb%xb>r7ZB^eE6so4pqRBxB*1X6!v9$BDHe5+{c zm!~--0%9aejHaEz{0vcuVarvu1FH`nxd>u)#3MBgUrH#?@y z-k>P;t1p3yppn$zL__HA8damO!O~eB-A<O}